Changes in / [51a799e:ba7d16f]
- Files:
-
- 13 deleted
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r51a799e rba7d16f 126 126 ctags: 127 127 ctags `find . -name "*.c"` `find . -name "*.h"` 128 129 # Using this as a bogus Make target to test if a GNU-compatible version of130 # make is available.131 helloworld:132 @echo Hello World -
bitlbee.c
r51a799e rba7d16f 36 36 static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition condition ); 37 37 38 static gboolean try_listen( struct addrinfo *res )39 {40 int i;41 42 global.listen_socket = socket( res->ai_family, res->ai_socktype, res->ai_protocol );43 if( global.listen_socket < 0 )44 {45 log_error( "socket" );46 return FALSE;47 }48 49 #ifdef IPV6_V6ONLY50 if( res->ai_family == AF_INET6 )51 {52 i = 0;53 setsockopt( global.listen_socket, IPPROTO_IPV6, IPV6_V6ONLY,54 (char *) &i, sizeof( i ) );55 }56 #endif57 58 /* TIME_WAIT (?) sucks.. */59 i = 1;60 setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) );61 62 i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen );63 if( i == -1 )64 {65 closesocket( global.listen_socket );66 global.listen_socket = -1;67 68 log_error( "bind" );69 return FALSE;70 }71 72 return TRUE;73 }74 75 38 int bitlbee_daemon_init() 76 39 { … … 79 42 FILE *fp; 80 43 81 log_link( LOGLVL_ERROR, LOGOUTPUT_ CONSOLE);82 log_link( LOGLVL_WARNING, LOGOUTPUT_ CONSOLE);44 log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG ); 45 log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG ); 83 46 84 47 memset( &hints, 0, sizeof( hints ) ); … … 100 63 101 64 global.listen_socket = -1; 102 103 /* Try IPv6 first (which will become an IPv6+IPv4 socket). */ 65 104 66 for( res = addrinfo_bind; res; res = res->ai_next ) 105 if( res->ai_family == AF_INET6 && try_listen( res ) ) 106 break; 107 108 /* The rest (so IPv4, I guess). */ 109 if( res == NULL ) 110 for( res = addrinfo_bind; res; res = res->ai_next ) 111 if( res->ai_family != AF_INET6 && try_listen( res ) ) 112 break; 113 67 { 68 global.listen_socket = socket( res->ai_family, res->ai_socktype, res->ai_protocol ); 69 if( global.listen_socket < 0 ) 70 continue; 71 72 /* TIME_WAIT (?) sucks.. */ 73 i = 1; 74 setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) ); 75 76 i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen ); 77 if( i == -1 ) 78 { 79 log_error( "bind" ); 80 return( -1 ); 81 } 82 83 break; 84 } 85 114 86 freeaddrinfo( addrinfo_bind ); 115 87 … … 121 93 } 122 94 123 global.listen_watch_source_id = b_input_add( global.listen_socket, B_EV_IO_READ, bitlbee_io_new_client, NULL );95 global.listen_watch_source_id = b_input_add( global.listen_socket, GAIM_INPUT_READ, bitlbee_io_new_client, NULL ); 124 96 125 97 #ifndef _WIN32 … … 135 107 exit( 0 ); 136 108 137 setsid();138 109 chdir( "/" ); 139 110 … … 166 137 #endif 167 138 168 if( !global.conf->nofork )169 {170 log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );171 log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );172 }173 174 139 return( 0 ); 175 140 } … … 321 286 child->pid = client_pid; 322 287 child->ipc_fd = fds[0]; 323 child->ipc_inpa = b_input_add( child->ipc_fd, B_EV_IO_READ, ipc_master_read, child );288 child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child ); 324 289 child_list = g_slist_append( child_list, child ); 325 290 … … 349 314 /* We can store the IPC fd there now. */ 350 315 global.listen_socket = fds[1]; 351 global.listen_watch_source_id = b_input_add( fds[1], B_EV_IO_READ, ipc_child_read, irc );316 global.listen_watch_source_id = b_input_add( fds[1], GAIM_INPUT_READ, ipc_child_read, irc ); 352 317 353 318 close( fds[0] ); -
bitlbee.h
r51a799e rba7d16f 35 35 36 36 #define PACKAGE "BitlBee" 37 #define BITLBEE_VERSION "1.2. 6a"37 #define BITLBEE_VERSION "1.2.5" 38 38 #define VERSION BITLBEE_VERSION 39 #define BITLBEE_VER(a,b,c) (((a) << 16) + ((b) << 8) + (c))40 #define BITLBEE_VERSION_CODE BITLBEE_VER(1, 2, 6)41 39 42 40 #define MAX_STRING 511 -
conf.c
r51a799e rba7d16f 82 82 } 83 83 84 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u: V" ) ) >= 0 )84 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 ) 85 85 /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ 86 86 { … … 148 148 " -d Specify alternative user configuration directory\n" 149 149 " -x Command-line interface to password encryption/hashing\n" 150 " -h Show this help page.\n" 151 " -V Show version info.\n" ); 152 return NULL; 153 } 154 else if( opt == 'V' ) 155 { 156 printf( "BitlBee %s\nAPI version %06x\n", 157 BITLBEE_VERSION, BITLBEE_VERSION_CODE ); 150 " -h Show this help page.\n" ); 158 151 return NULL; 159 152 } -
configure
r51a799e rba7d16f 26 26 oscar=1 27 27 yahoo=1 28 twitter=129 purple=130 28 31 29 debug=0 … … 68 66 --oscar=0/1 Disable/enable Oscar part (ICQ, AIM) $oscar 69 67 --yahoo=0/1 Disable/enable Yahoo part $yahoo 70 --twitter=0/1 Disable/enable Twitter part $twitter71 72 --purple=0/1 Disable/enable libpurple support $purple73 68 74 69 --debug=0/1 Disable/enable debugging $debug … … 272 267 detect_ldap() 273 268 { 274 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)269 TMPFILE=$(mktemp) 275 270 if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then 276 271 cat<<EOF>>Makefile.settings … … 300 295 detect_resolv_dynamic() 301 296 { 302 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)297 TMPFILE=$(mktemp) 303 298 ret=1 304 299 echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -lresolv >/dev/null 2>/dev/null … … 314 309 detect_resolv_static() 315 310 { 316 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)311 TMPFILE=$(mktemp) 317 312 ret=1 318 313 for i in $systemlibdirs; do … … 481 476 fi 482 477 483 if ! make helloworld > /dev/null 2>&1; then484 echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."485 echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"486 echo "under the name 'gmake'."487 echo488 if gmake helloworld > /dev/null 2>&1; then489 echo "gmake seems to be available on your machine, great."490 echo491 else492 echo "gmake is not installed (or not working). Please try to install it."493 echo494 fi495 fi496 497 478 cat <<EOF>bitlbee.pc 498 479 prefix=$prefix … … 511 492 protoobjs='' 512 493 513 if [ "$purple" = 0 ]; then514 echo '#undef WITH_PURPLE' >> config.h515 else516 if ! $PKG_CONFIG purple; then517 echo518 echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'519 exit 1520 fi521 echo '#define WITH_PURPLE' >> config.h522 cat<<EOF>>Makefile.settings523 EFLAGS += $($PKG_CONFIG purple --libs)524 PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)525 EOF526 protocols=$protocols'purple '527 protoobjs=$protoobjs'purple_mod.o '528 529 # Having both libpurple and native IM modules in one binary may530 # do strange things. Let's not do that.531 msn=0532 jabber=0533 oscar=0534 yahoo=0535 twitter=0536 537 if [ "$events" = "libevent" ]; then538 echo539 echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'540 echo 'outside libpurple, talking to GLib directly. At least for now the combination'541 echo 'libpurple + libevent is *not* recommended!'542 fi543 fi544 545 494 if [ "$msn" = 0 ]; then 546 495 echo '#undef WITH_MSN' >> config.h … … 575 524 fi 576 525 577 if [ "$twitter" = 0 ]; then578 echo '#undef WITH_TWITTER' >> config.h579 else580 echo '#define WITH_TWITTER' >> config.h581 protocols=$protocols'twitter '582 protoobjs=$protoobjs'twitter_mod.o '583 fi584 585 526 if [ "$protocols" = "PROTOCOLS = " ]; then 586 527 echo "Warning: You haven't selected any communication protocol to compile!" -
dcc.c
r51a799e rba7d16f 154 154 155 155 /* watch */ 156 df->watch_in = b_input_add( df->fd, B_EV_IO_READ, dccs_send_proto, df );156 df->watch_in = b_input_add( df->fd, GAIM_INPUT_READ, dccs_send_proto, df ); 157 157 158 158 df->ic->irc->file_transfers = g_slist_prepend( df->ic->irc->file_transfers, file ); … … 267 267 file_transfer_t *file = df->ft; 268 268 269 if( ( cond & B_EV_IO_READ ) &&269 if( ( cond & GAIM_INPUT_READ ) && 270 270 ( file->status & FT_STATUS_LISTENING ) ) 271 271 { … … 287 287 288 288 /* reschedule for reading on new fd */ 289 df->watch_in = b_input_add( fd, B_EV_IO_READ, dccs_send_proto, df );289 df->watch_in = b_input_add( fd, GAIM_INPUT_READ, dccs_send_proto, df ); 290 290 291 291 return FALSE; 292 292 } 293 293 294 if( cond & B_EV_IO_READ )294 if( cond & GAIM_INPUT_READ ) 295 295 { 296 296 int ret; … … 364 364 365 365 /* watch */ 366 df->watch_out = b_input_add( df->fd, B_EV_IO_WRITE, dccs_recv_proto, df );366 df->watch_out = b_input_add( df->fd, GAIM_INPUT_WRITE, dccs_recv_proto, df ); 367 367 ft->write_request = dccs_recv_write_request; 368 368 … … 377 377 file_transfer_t *ft = df->ft; 378 378 379 if( ( cond & B_EV_IO_WRITE ) &&379 if( ( cond & GAIM_INPUT_WRITE ) && 380 380 ( ft->status & FT_STATUS_CONNECTING ) ) 381 381 { 382 382 ft->status = FT_STATUS_TRANSFERRING; 383 383 384 //df->watch_in = b_input_add( df->fd, B_EV_IO_READ, dccs_recv_proto, df );384 //df->watch_in = b_input_add( df->fd, GAIM_INPUT_READ, dccs_recv_proto, df ); 385 385 386 386 df->watch_out = 0; … … 388 388 } 389 389 390 if( cond & B_EV_IO_READ )390 if( cond & GAIM_INPUT_READ ) 391 391 { 392 392 int ret, done; … … 445 445 return dcc_abort( df, "BUG: write_request() called while watching" ); 446 446 447 df->watch_in = b_input_add( df->fd, B_EV_IO_READ, dccs_recv_proto, df );447 df->watch_in = b_input_add( df->fd, GAIM_INPUT_READ, dccs_recv_proto, df ); 448 448 449 449 return TRUE; … … 488 488 489 489 if( df->bytes_sent < df->ft->file_size ) 490 df->watch_out = b_input_add( df->fd, B_EV_IO_WRITE, dccs_send_can_write, df );490 df->watch_out = b_input_add( df->fd, GAIM_INPUT_WRITE, dccs_send_can_write, df ); 491 491 492 492 return TRUE; -
debian/bitlbee.init
r51a799e rba7d16f 38 38 d_start() { 39 39 # Make sure BitlBee can actually write its PID... 40 touch $PIDFILE41 chown bitlbee: $PIDFILE40 touch /var/run/bitlbee.pid 41 chown bitlbee: /var/run/bitlbee.pid 42 42 43 43 start-stop-daemon --start --quiet --pidfile $PIDFILE \ -
debian/changelog
r51a799e rba7d16f 1 bitlbee (1.2.6a-1) unstable; urgency=low2 3 * New upstream version.4 * Native support for Twitter.5 * Fixed /WHOIS response format. (Closes: #576120)6 * Problems with bitlbee-skype are solved by now. (Closes: #575572)7 8 -- Wilmer van der Gaast <wilmer@peer.gaast.net> Tue, 20 Apr 2010 00:34:51 +02009 10 1 bitlbee (1.2.5-1) unstable; urgency=low 11 2 -
debian/control
r51a799e rba7d16f 5 5 Uploaders: Jelmer Vernooij <jelmer@samba.org> 6 6 Standards-Version: 3.8.0 7 Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), debconf-2.0, po-debconf , libpurple-dev7 Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), debconf-2.0, po-debconf 8 8 Homepage: http://www.bitlbee.org/ 9 9 Vcs-Bzr: http://code.bitlbee.org/bitlbee/ -
debian/rules
r51a799e rba7d16f 1 1 #!/usr/bin/make -f 2 2 3 BITLBEE_CONFIGURE_FLAGS ?=4 3 DEBUG ?= 0 5 4 … … 15 14 build-arch-stamp: 16 15 [ -d debian ] 17 ./configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent $(BITLBEE_CONFIGURE_FLAGS)16 ./configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent 18 17 $(MAKE) 19 18 # $(MAKE) -C doc/ all … … 100 99 find usr -type f -exec md5sum {} \; > DEBIAN/md5sums 101 100 102 dpkg-gencontrol -ldebian/changelog -isp -pbitlbee-dev -Pdebian/bitlbee-dev -v1:$(BITLBEE_VERSION)-0101 dpkg-gencontrol -ldebian/changelog -isp -pbitlbee-dev -Pdebian/bitlbee-dev 103 102 104 103 dpkg --build debian/bitlbee-dev .. -
doc/CHANGES
r51a799e rba7d16f 3 3 4 4 http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on 5 6 Version 1.2.6a:7 - Fixed a typo that renders the Twitter groupchat mode unusable. A last-8 minute change that came a few minutes late.9 10 Finished 19 Apr 201011 12 Version 1.2.6:13 - Native (very basic) support for Twitter, implemented by Geert Mulders.14 Currently supported are posting tweets, reading the ones of people you15 follow, and sending (not yet receiving!) direct messages.16 - Fixed format of status messages in /WHOIS to improve IRC client17 compatibility.18 - Show timestamps of offline messages/channel backlogs.19 - Allow saving MSN display names locally since sometimes this stuff breaks20 server-side. (Use the local_display_name per-account setting.)21 - Suppress empty "Headline:" messages for certain new XMPP broadcast22 messages.23 - Better handling of XMPP contacts with multiple resources on-line. Default24 behaviour now is to write to wherever the last message came from, or to25 the bare JID (usually becomes a broadcast) if there wasn't any recent msg.26 - Added a switchboard_keepalives setting which should solve some issues with27 talking to offline MSN contacts. (Although full support for offline28 messages is not ready yet!)29 - The usual misc. bug fixes.30 31 Finished 19 Apr 201032 5 33 6 Version 1.2.5: … … 50 23 the main client). 51 24 52 Fi nished 17 Mar 201025 Fixed 17 Mar 2010 53 26 54 27 Version 1.2.4: -
doc/user-guide/commands.xml
r51a799e rba7d16f 21 21 <description> 22 22 <para> 23 Adds an account on the given server with the specified protocol, username and password to the account list. Supported protocols right now are: Jabber, MSN, OSCAR (AIM/ICQ) , Yahoo and Twitter. For more information about adding an account, see <emphasis>help account add <protocol></emphasis>.23 Adds an account on the given server with the specified protocol, username and password to the account list. Supported protocols right now are: Jabber, MSN, OSCAR (AIM/ICQ) and Yahoo. For more information about adding an account, see <emphasis>help account add <protocol></emphasis>. 24 24 </para> 25 25 </description> … … 63 63 </ircexample> 64 64 </bitlbee-command> 65 66 <bitlbee-command name="twitter">67 <syntax>account add twitter <handle> <password></syntax>68 69 <description>70 <para>71 This module gives you simple access to Twitter. Although it uses the Twitter API, only Twitter itself is supported at the moment.72 </para>73 74 <para>75 By default all your Twitter contacts will come from a contact called twitter_(yourusername). You can change this behaviour using the <emphasis>mode</emphasis> setting (see <emphasis>help set mode</emphasis>).76 </para>77 78 <para>79 To send tweets yourself, send them to the twitter_(yourusername) contact, or just write in the groupchat channel if you enabled that option.80 </para>81 82 <para>83 Since Twitter now requires OAuth authentication, you should not enter your Twitter password into BitlBee. Just type a bogus password. The first time you log in, BitlBee will start OAuth authentication. (See <emphasis>help set oauth</emphasis>.)84 </para>85 </description>86 </bitlbee-command>87 65 88 66 <bitlbee-command name="yahoo"> … … 423 401 424 402 <bitlbee-setting name="auto_reconnect" type="boolean" scope="both"> 425 <default> true</default>403 <default>false</default> 426 404 427 405 <description> … … 578 556 <para> 579 557 With this option enabled, root will inform you when someone in your buddy list changes his/her "friendly name". 580 </para>581 </description>582 </bitlbee-setting>583 584 <bitlbee-setting name="display_timestamps" type="boolean" scope="global">585 <default>true</default>586 587 <description>588 <para>589 When incoming messages are old (i.e. offline messages and channel backlogs), BitlBee will prepend them with a timestamp. If you find them ugly or useless, you can use this setting to hide them.590 558 </para> 591 559 </description> … … 641 609 </bitlbee-setting> 642 610 643 <bitlbee-setting name="local_display_name" type="boolean" scope="account">644 <default>false</default>645 646 <description>647 <para>648 Mostly meant to work around a bug in MSN servers (forgetting the display name set by the user), this setting tells BitlBee to store your display name locally and set this name on the MSN servers when connecting.649 </para>650 </description>651 652 </bitlbee-setting>653 654 611 <bitlbee-setting name="mail_notifications" type="boolean" scope="account"> 655 612 <default>false</default> … … 658 615 <para> 659 616 Some protocols (MSN, Yahoo!) can notify via IM about new e-mail. Since most people use their Hotmail/Yahoo! addresses as a spam-box, this is disabled default. If you want these notifications, you can enable this setting. 660 </para>661 </description>662 663 </bitlbee-setting>664 665 <bitlbee-setting name="message_length" type="integer" scope="account">666 <default>140</default>667 668 <description>669 <para>670 Since Twitter rejects messages longer than 140 characters, BitlBee can count message length and emit a warning instead of waiting for Twitter to reject it.671 </para>672 673 <para>674 You can change this limit here but this won't disable length checks on Twitter's side. You can also set it to 0 to disable the check in case you believe BitlBee doesn't count the characters correctly.675 </para>676 </description>677 678 </bitlbee-setting>679 680 <bitlbee-setting name="mode" type="string" scope="account">681 <possible-values>one, many, chat</possible-values>682 <default>one</default>683 684 <description>685 <para>686 By default, everything from the Twitter module will come from one nick, twitter_(yourusername). If you prefer to have individual nicks for everyone, you can set this setting to "many" instead.687 </para>688 689 <para>690 If you prefer to have all your Twitter things in a separate channel, you can set this setting to "chat".691 </para>692 693 <para>694 In the last two modes, you can send direct messages by /msg'ing your contacts directly. Note, however, that incoming DMs are not fetched yet.695 617 </para> 696 618 </description> … … 722 644 </bitlbee-setting> 723 645 724 <bitlbee-setting name="oauth" type="boolean" scope="account">725 <default>true</default>726 727 <description>728 <para>729 This enables OAuth authentication for Twitter accounts. From June 2010 this will be mandatory.730 </para>731 732 <para>733 With OAuth enabled, you shouldn't tell BitlBee your Twitter password. Just add your account with a bogus password and type <emphasis>account on</emphasis>. BitlBee will then give you a URL to authenticate with Twitter. If this succeeds, Twitter will return a PIN code which you can give back to BitlBee to finish the process.734 </para>735 736 <para>737 The resulting access token will be saved permanently, so you have to do this only once.738 </para>739 </description>740 741 </bitlbee-setting>742 743 646 <bitlbee-setting name="ops" type="string" scope="global"> 744 647 <default>both</default> … … 876 779 </bitlbee-setting> 877 780 878 <bitlbee-setting name="show_offline" type="boolean" scope="global">879 <default>false</default>880 881 <description>882 <para>883 If enabled causes BitlBee to also show offline users in Channel. Online-users will get op, away-users voice and offline users none of both. This option takes effect as soon as you reconnect.884 </para>885 </description>886 </bitlbee-setting>887 888 781 <bitlbee-setting name="simulate_netsplit" type="boolean" scope="global"> 889 782 <default>true</default> … … 931 824 <para> 932 825 If BitlBee fails to detect this sometimes (most likely in AIM messages over an ICQ connection), you can set this setting to <emphasis>always</emphasis>, but this might sometimes accidentally strip non-HTML things too. 933 </para>934 </description>935 </bitlbee-setting>936 937 <bitlbee-setting name="switchboard_keepalives" type="boolean" scope="account">938 <default>false</default>939 940 <description>941 <para>942 Turn on this flag if you have difficulties talking to offline/invisible contacts.943 </para>944 945 <para>946 With this setting enabled, BitlBee will send keepalives to MSN switchboards with offline/invisible contacts every twenty seconds. This should keep the server and client on the other side from shutting it down.947 </para>948 949 <para>950 This is useful because BitlBee doesn't support MSN offline messages yet and the MSN servers won't let the user reopen switchboards to offline users. Once offline messaging is supported, this flag might be removed.951 </para>952 </description>953 </bitlbee-setting>954 955 <bitlbee-setting name="timezone" type="string" scope="global">956 <default>local</default>957 <possible-values>local, utc, gmt, timezone-spec</possible-values>958 959 <description>960 <para>961 If message timestamps are available for offline messages or chatroom backlogs, BitlBee will display them as part of the message. By default it will use the local timezone. If you're not in the same timezone as the BitlBee server, you can adjust the timestamps using this setting.962 </para>963 964 <para>965 Values local/utc/gmt should be self-explanatory. timezone-spec is a time offset in hours:minutes, for example: -8 for Pacific Standard Time, +2 for Central European Summer Time, +5:30 for Indian Standard Time.966 826 </para> 967 827 </description> -
help.c
r51a799e rba7d16f 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-200 9Wilmer van der Gaast and others *4 * Copyright 2002-2005 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 169 169 return NULL; 170 170 } 171 172 int help_add_mem( help_t **help, const char *title, const char *content )173 {174 help_t *h, *l = NULL;175 176 for( h = *help; h; h = h->next )177 {178 if( g_strcasecmp( h->title, title ) == 0 )179 return 0;180 181 l = h;182 }183 184 if( l )185 h = l->next = g_new0( struct help, 1 );186 else187 *help = h = g_new0( struct help, 1 );188 h->fd = -1;189 h->title = g_strdup( title );190 h->length = strlen( content );191 h->offset.mem_offset = g_strdup( content );192 193 return 1;194 } -
help.h
r51a799e rba7d16f 46 46 void help_free( help_t **help ); 47 47 char *help_get( help_t **help, char *title ); 48 int help_add_mem( help_t **help, const char *title, const char *content_ );49 48 50 49 #endif -
ipc.c
r51a799e rba7d16f 514 514 } 515 515 516 child->ipc_inpa = b_input_add( child->ipc_fd, B_EV_IO_READ, ipc_master_read, child );516 child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child ); 517 517 518 518 child_list = g_slist_append( child_list, child ); … … 552 552 } 553 553 554 b_input_add( serversock, B_EV_IO_READ, new_ipc_client, NULL );554 b_input_add( serversock, GAIM_INPUT_READ, new_ipc_client, NULL ); 555 555 556 556 return 1; … … 597 597 return 0; 598 598 } 599 child->ipc_inpa = b_input_add( child->ipc_fd, B_EV_IO_READ, ipc_master_read, child );599 child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child ); 600 600 601 601 child_list = g_slist_append( child_list, child ); -
irc.c
r51a799e rba7d16f 52 52 { 53 53 irc_t *irc = set->data; 54 char *test;55 gsize test_bytes = 0;56 54 GIConv ic, oc; 57 55 … … 59 57 value = g_strdup( "utf-8" ); 60 58 59 if( ( ic = g_iconv_open( "utf-8", value ) ) == (GIConv) -1 ) 60 { 61 return NULL; 62 } 61 63 if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 ) 62 64 { 63 return NULL; 64 } 65 66 /* Do a test iconv to see if the user picked an IRC-compatible 67 charset (for example utf-16 goes *horribly* wrong). */ 68 if( ( test = g_convert_with_iconv( " ", 1, oc, NULL, &test_bytes, NULL ) ) == NULL || 69 test_bytes > 1 ) 70 { 71 g_free( test ); 72 g_iconv_close( oc ); 73 irc_usermsg( irc, "Unsupported character set: The IRC protocol " 74 "only supports 8-bit character sets." ); 75 return NULL; 76 } 77 g_free( test ); 78 79 if( ( ic = g_iconv_open( "utf-8", value ) ) == (GIConv) -1 ) 80 { 81 g_iconv_close( oc ); 65 g_iconv_close( ic ); 82 66 return NULL; 83 67 } … … 125 109 sock_make_nonblocking( irc->fd ); 126 110 127 irc->r_watch_source_id = b_input_add( irc->fd, B_EV_IO_READ, bitlbee_io_current_client_read, irc );111 irc->r_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_READ, bitlbee_io_current_client_read, irc ); 128 112 129 113 irc->status = USTATUS_OFFLINE; … … 191 175 s = set_add( &irc->set, "default_target", "root", NULL, irc ); 192 176 s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 193 s = set_add( &irc->set, "display_timestamps", "true", set_eval_bool, irc );194 177 s = set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 195 178 s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); … … 201 184 s = set_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc ); 202 185 s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc ); 203 s = set_add( &irc->set, "show_offline", "false", set_eval_bool, irc );204 186 s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc ); 205 187 s = set_add( &irc->set, "status", NULL, set_eval_away_status, irc ); 206 188 s->flags |= SET_NULL_OK; 207 189 s = set_add( &irc->set, "strip_html", "true", NULL, irc ); 208 s = set_add( &irc->set, "timezone", "local", set_eval_timezone, irc );209 190 s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 210 191 s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); … … 214 195 /* Evaluator sets the iconv/oconv structures. */ 215 196 set_eval_charset( set_find( &irc->set, "charset" ), set_getstr( &irc->set, "charset" ) ); 216 217 nogaim_init();218 197 219 198 return( irc ); … … 698 677 in the event queue. */ 699 678 /* Really can't be done as long as the code doesn't do error checking very well: 700 if( bitlbee_io_current_client_write( irc, irc->fd, B_EV_IO_WRITE ) ) */679 if( bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE ) ) */ 701 680 702 681 /* So just always do it via the event handler. */ 703 irc->w_watch_source_id = b_input_add( irc->fd, B_EV_IO_WRITE, bitlbee_io_current_client_write, irc );682 irc->w_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc ); 704 683 } 705 684 … … 727 706 if( now ) 728 707 { 729 bitlbee_io_current_client_write( irc, irc->fd, B_EV_IO_WRITE );708 bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE ); 730 709 } 731 710 temp = temp->next; -
irc_commands.c
r51a799e rba7d16f 498 498 irc_reply( irc, 301, "%s :%s", u->nick, u->away ); 499 499 if( u->status_msg ) 500 irc_reply( irc, 3 20, "%s :%s", u->nick, u->status_msg );500 irc_reply( irc, 333, "%s :Status: %s", u->nick, u->status_msg ); 501 501 502 502 irc_reply( irc, 318, "%s :End of /WHOIS list", nick ); -
lib/Makefile
r51a799e rba7d16f 10 10 11 11 # [SH] Program variables 12 objects = arc.o base64.o $(EVENT_HANDLER) ftutil.o http_client.o ini.o md5.o misc.o oauth.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o12 objects = arc.o base64.o $(EVENT_HANDLER) http_client.o ini.o md5.o misc.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o ftutil.o 13 13 14 14 CFLAGS += -Wall -
lib/events.h
r51a799e rba7d16f 48 48 the given callback function. */ 49 49 typedef enum { 50 B_EV_IO_READ = 1 << 0, 51 B_EV_IO_WRITE = 1 << 1, 52 B_EV_FLAG_FORCE_ONCE = 1 << 16, 53 B_EV_FLAG_FORCE_REPEAT = 1 << 17, 50 GAIM_INPUT_READ = 1 << 1, 51 GAIM_INPUT_WRITE = 1 << 2 54 52 } b_input_condition; 55 53 typedef gboolean (*b_event_handler)(gpointer data, gint fd, b_input_condition cond); -
lib/events_glib.c
r51a799e rba7d16f 49 49 b_event_handler function; 50 50 gpointer data; 51 guint flags;52 51 } GaimIOClosure; 53 52 … … 77 76 78 77 if (condition & GAIM_READ_COND) 79 gaim_cond |= B_EV_IO_READ;78 gaim_cond |= GAIM_INPUT_READ; 80 79 if (condition & GAIM_WRITE_COND) 81 gaim_cond |= B_EV_IO_WRITE;80 gaim_cond |= GAIM_INPUT_WRITE; 82 81 83 82 event_debug( "gaim_io_invoke( %d, %d, 0x%x )\n", g_io_channel_unix_get_fd(source), condition, data ); … … 88 87 event_debug( "Returned FALSE, cancelling.\n" ); 89 88 90 if (closure->flags & B_EV_FLAG_FORCE_ONCE) 91 return FALSE; 92 else if (closure->flags & B_EV_FLAG_FORCE_REPEAT) 93 return TRUE; 94 else 95 return st; 89 return st; 96 90 } 97 91 … … 111 105 closure->function = function; 112 106 closure->data = data; 113 closure->flags = condition;114 107 115 if (condition & B_EV_IO_READ)108 if (condition & GAIM_INPUT_READ) 116 109 cond |= GAIM_READ_COND; 117 if (condition & B_EV_IO_WRITE)110 if (condition & GAIM_INPUT_WRITE) 118 111 cond |= GAIM_WRITE_COND; 119 112 -
lib/events_libevent.c
r51a799e rba7d16f 60 60 b_event_handler function; 61 61 void *data; 62 guint flags;63 62 }; 64 63 … … 127 126 { 128 127 if( event & EV_READ ) 129 cond |= B_EV_IO_READ;128 cond |= GAIM_INPUT_READ; 130 129 if( event & EV_WRITE ) 131 cond |= B_EV_IO_WRITE;130 cond |= GAIM_INPUT_WRITE; 132 131 } 133 132 … … 151 150 return; 152 151 } 153 else if( !st && !( b_ev->flags & B_EV_FLAG_FORCE_REPEAT ))152 else if( !st ) 154 153 { 155 154 event_debug( "Handler returned FALSE: " ); … … 175 174 event_debug( "b_input_add( %d, %d, 0x%x, 0x%x ) ", fd, condition, function, data ); 176 175 177 if( ( condition & B_EV_IO_READ && ( b_ev = g_hash_table_lookup( read_hash, &fd ) ) ) ||178 ( condition & B_EV_IO_WRITE && ( b_ev = g_hash_table_lookup( write_hash, &fd ) ) ) )176 if( ( condition & GAIM_INPUT_READ && ( b_ev = g_hash_table_lookup( read_hash, &fd ) ) ) || 177 ( condition & GAIM_INPUT_WRITE && ( b_ev = g_hash_table_lookup( write_hash, &fd ) ) ) ) 179 178 { 180 179 /* We'll stick with this libevent entry, but give it a new BitlBee id. */ … … 199 198 200 199 out_cond = EV_PERSIST; 201 if( condition & B_EV_IO_READ )200 if( condition & GAIM_INPUT_READ ) 202 201 out_cond |= EV_READ; 203 if( condition & B_EV_IO_WRITE )202 if( condition & GAIM_INPUT_WRITE ) 204 203 out_cond |= EV_WRITE; 205 204 … … 213 212 } 214 213 215 b_ev->flags = condition;216 214 g_hash_table_insert( id_hash, &b_ev->id, b_ev ); 217 215 return b_ev->id; -
lib/http_client.c
r51a799e rba7d16f 149 149 if( req->bytes_written < req->request_length ) 150 150 req->inpa = b_input_add( source, 151 req->ssl ? ssl_getdirection( req->ssl ) : B_EV_IO_WRITE,151 req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE, 152 152 http_connected, req ); 153 153 else 154 req->inpa = b_input_add( source, B_EV_IO_READ, http_incoming_data, req );154 req->inpa = b_input_add( source, GAIM_INPUT_READ, http_incoming_data, req ); 155 155 156 156 return FALSE; … … 234 234 /* There will be more! */ 235 235 req->inpa = b_input_add( req->fd, 236 req->ssl ? ssl_getdirection( req->ssl ) : B_EV_IO_READ,236 req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ, 237 237 http_incoming_data, req ); 238 238 -
lib/misc.c
r51a799e rba7d16f 77 77 78 78 return mktime(&tm); 79 }80 81 time_t mktime_utc( struct tm *tp )82 {83 struct tm utc;84 time_t res, tres;85 86 tp->tm_isdst = -1;87 res = mktime( tp );88 /* Problem is, mktime() just gave us the GMT timestamp for the89 given local time... While the given time WAS NOT local. So90 we should fix this now.91 92 Now I could choose between messing with environment variables93 (kludgy) or using timegm() (not portable)... Or doing the94 following, which I actually prefer...95 96 tzset() may also work but in other places I actually want to97 use local time.98 99 FFFFFFFFFFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUU!! */100 gmtime_r( &res, &utc );101 utc.tm_isdst = -1;102 if( utc.tm_hour == tp->tm_hour && utc.tm_min == tp->tm_min )103 /* Sweet! We're in UTC right now... */104 return res;105 106 tres = mktime( &utc );107 res += res - tres;108 109 /* Yes, this is a hack. And it will go wrong around DST changes.110 BUT this is more likely to be threadsafe than messing with111 environment variables, and possibly more portable... */112 113 return res;114 79 } 115 80 … … 306 271 for( i = j = 0; t[i]; i ++, j ++ ) 307 272 { 308 if( !isalnum( t[i] ) && !strchr( "._-~", t[i] ) ) 273 /* if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' ) */ 274 if( !isalnum( t[i] ) ) 309 275 { 310 276 sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] ); -
lib/misc.h
r51a799e rba7d16f 43 43 44 44 G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec ); 45 G_MODULE_EXPORT time_t mktime_utc( struct tm *tp );46 45 double gettime( void ); 47 46 -
lib/proxy.c
r51a799e rba7d16f 91 91 b_event_remove(phb->inpa); 92 92 if( phb->proxy_func ) 93 phb->proxy_func(phb->proxy_data, -1, B_EV_IO_READ);93 phb->proxy_func(phb->proxy_data, -1, GAIM_INPUT_READ); 94 94 else { 95 phb->func(phb->data, -1, B_EV_IO_READ);95 phb->func(phb->data, -1, GAIM_INPUT_READ); 96 96 g_free(phb); 97 97 } … … 102 102 b_event_remove(phb->inpa); 103 103 if( phb->proxy_func ) 104 phb->proxy_func(phb->proxy_data, source, B_EV_IO_READ);104 phb->proxy_func(phb->proxy_data, source, GAIM_INPUT_READ); 105 105 else { 106 phb->func(phb->data, source, B_EV_IO_READ);106 phb->func(phb->data, source, GAIM_INPUT_READ); 107 107 g_free(phb); 108 108 } … … 147 147 return -1; 148 148 } else { 149 phb->inpa = b_input_add(fd, B_EV_IO_WRITE, gaim_io_connected, phb);149 phb->inpa = b_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb); 150 150 phb->fd = fd; 151 151 … … 179 179 if ((memcmp(HTTP_GOODSTRING, inputline, strlen(HTTP_GOODSTRING)) == 0) || 180 180 (memcmp(HTTP_GOODSTRING2, inputline, strlen(HTTP_GOODSTRING2)) == 0)) { 181 phb->func(phb->data, source, B_EV_IO_READ);181 phb->func(phb->data, source, GAIM_INPUT_READ); 182 182 g_free(phb->host); 183 183 g_free(phb); … … 186 186 187 187 close(source); 188 phb->func(phb->data, -1, B_EV_IO_READ);188 phb->func(phb->data, -1, GAIM_INPUT_READ); 189 189 g_free(phb->host); 190 190 g_free(phb); … … 204 204 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 205 205 close(source); 206 phb->func(phb->data, -1, B_EV_IO_READ);206 phb->func(phb->data, -1, GAIM_INPUT_READ); 207 207 g_free(phb->host); 208 208 g_free(phb); … … 215 215 if (send(source, cmd, strlen(cmd), 0) < 0) { 216 216 close(source); 217 phb->func(phb->data, -1, B_EV_IO_READ);217 phb->func(phb->data, -1, GAIM_INPUT_READ); 218 218 g_free(phb->host); 219 219 g_free(phb); … … 230 230 if (send(source, cmd, strlen(cmd), 0) < 0) { 231 231 close(source); 232 phb->func(phb->data, -1, B_EV_IO_READ);232 phb->func(phb->data, -1, GAIM_INPUT_READ); 233 233 g_free(phb->host); 234 234 g_free(phb); … … 240 240 if (send(source, cmd, strlen(cmd), 0) < 0) { 241 241 close(source); 242 phb->func(phb->data, -1, B_EV_IO_READ);243 g_free(phb->host); 244 g_free(phb); 245 return FALSE; 246 } 247 248 phb->inpa = b_input_add(source, B_EV_IO_READ, http_canread, phb);242 phb->func(phb->data, -1, GAIM_INPUT_READ); 243 g_free(phb->host); 244 g_free(phb); 245 return FALSE; 246 } 247 248 phb->inpa = b_input_add(source, GAIM_INPUT_READ, http_canread, phb); 249 249 250 250 return FALSE; … … 273 273 memset(packet, 0, sizeof(packet)); 274 274 if (read(source, packet, 9) >= 4 && packet[1] == 90) { 275 phb->func(phb->data, source, B_EV_IO_READ);275 phb->func(phb->data, source, GAIM_INPUT_READ); 276 276 g_free(phb->host); 277 277 g_free(phb); … … 280 280 281 281 close(source); 282 phb->func(phb->data, -1, B_EV_IO_READ);282 phb->func(phb->data, -1, GAIM_INPUT_READ); 283 283 g_free(phb->host); 284 284 g_free(phb); … … 299 299 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 300 300 close(source); 301 phb->func(phb->data, -1, B_EV_IO_READ);301 phb->func(phb->data, -1, GAIM_INPUT_READ); 302 302 g_free(phb->host); 303 303 g_free(phb); … … 309 309 if (!(hp = gethostbyname(phb->host))) { 310 310 close(source); 311 phb->func(phb->data, -1, B_EV_IO_READ);311 phb->func(phb->data, -1, GAIM_INPUT_READ); 312 312 g_free(phb->host); 313 313 g_free(phb); … … 326 326 if (write(source, packet, 9) != 9) { 327 327 close(source); 328 phb->func(phb->data, -1, B_EV_IO_READ);329 g_free(phb->host); 330 g_free(phb); 331 return FALSE; 332 } 333 334 phb->inpa = b_input_add(source, B_EV_IO_READ, s4_canread, phb);328 phb->func(phb->data, -1, GAIM_INPUT_READ); 329 g_free(phb->host); 330 g_free(phb); 331 return FALSE; 332 } 333 334 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s4_canread, phb); 335 335 336 336 return FALSE; … … 359 359 if (read(source, buf, 10) < 10) { 360 360 close(source); 361 phb->func(phb->data, -1, B_EV_IO_READ);361 phb->func(phb->data, -1, GAIM_INPUT_READ); 362 362 g_free(phb->host); 363 363 g_free(phb); … … 366 366 if ((buf[0] != 0x05) || (buf[1] != 0x00)) { 367 367 close(source); 368 phb->func(phb->data, -1, B_EV_IO_READ);369 g_free(phb->host); 370 g_free(phb); 371 return FALSE; 372 } 373 374 phb->func(phb->data, source, B_EV_IO_READ);368 phb->func(phb->data, -1, GAIM_INPUT_READ); 369 g_free(phb->host); 370 g_free(phb); 371 return FALSE; 372 } 373 374 phb->func(phb->data, source, GAIM_INPUT_READ); 375 375 g_free(phb->host); 376 376 g_free(phb); … … 396 396 if (write(source, buf, (5 + strlen(phb->host) + 2)) < (5 + strlen(phb->host) + 2)) { 397 397 close(source); 398 phb->func(phb->data, -1, B_EV_IO_READ);398 phb->func(phb->data, -1, GAIM_INPUT_READ); 399 399 g_free(phb->host); 400 400 g_free(phb); … … 402 402 } 403 403 404 phb->inpa = b_input_add(source, B_EV_IO_READ, s5_canread_again, phb);404 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb); 405 405 } 406 406 … … 414 414 if (read(source, buf, 2) < 2) { 415 415 close(source); 416 phb->func(phb->data, -1, B_EV_IO_READ);416 phb->func(phb->data, -1, GAIM_INPUT_READ); 417 417 g_free(phb->host); 418 418 g_free(phb); … … 422 422 if ((buf[0] != 0x01) || (buf[1] != 0x00)) { 423 423 close(source); 424 phb->func(phb->data, -1, B_EV_IO_READ);424 phb->func(phb->data, -1, GAIM_INPUT_READ); 425 425 g_free(phb->host); 426 426 g_free(phb); … … 442 442 if (read(source, buf, 2) < 2) { 443 443 close(source); 444 phb->func(phb->data, -1, B_EV_IO_READ);444 phb->func(phb->data, -1, GAIM_INPUT_READ); 445 445 g_free(phb->host); 446 446 g_free(phb); … … 450 450 if ((buf[0] != 0x05) || (buf[1] == 0xff)) { 451 451 close(source); 452 phb->func(phb->data, -1, B_EV_IO_READ);452 phb->func(phb->data, -1, GAIM_INPUT_READ); 453 453 g_free(phb->host); 454 454 g_free(phb); … … 465 465 if (write(source, buf, 3 + i + j) < 3 + i + j) { 466 466 close(source); 467 phb->func(phb->data, -1, B_EV_IO_READ);467 phb->func(phb->data, -1, GAIM_INPUT_READ); 468 468 g_free(phb->host); 469 469 g_free(phb); … … 471 471 } 472 472 473 phb->inpa = b_input_add(source, B_EV_IO_READ, s5_readauth, phb);473 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_readauth, phb); 474 474 } else { 475 475 s5_sendconnect(phb, source); … … 491 491 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 492 492 close(source); 493 phb->func(phb->data, -1, B_EV_IO_READ);493 phb->func(phb->data, -1, GAIM_INPUT_READ); 494 494 g_free(phb->host); 495 495 g_free(phb); … … 513 513 if (write(source, buf, i) < i) { 514 514 close(source); 515 phb->func(phb->data, -1, B_EV_IO_READ);516 g_free(phb->host); 517 g_free(phb); 518 return FALSE; 519 } 520 521 phb->inpa = b_input_add(source, B_EV_IO_READ, s5_canread, phb);515 phb->func(phb->data, -1, GAIM_INPUT_READ); 516 g_free(phb->host); 517 g_free(phb); 518 return FALSE; 519 } 520 521 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread, phb); 522 522 523 523 return FALSE; -
lib/ssl_bogus.c
r51a799e rba7d16f 59 59 b_input_condition ssl_getdirection( void *conn ) 60 60 { 61 return B_EV_IO_READ;61 return GAIM_INPUT_READ; 62 62 } 63 63 -
lib/ssl_client.h
r51a799e rba7d16f 71 71 G_MODULE_EXPORT int ssl_getfd( void *conn ); 72 72 73 /* This function returns B_EV_IO_READ/WRITE. With SSL connections it's73 /* This function returns GAIM_INPUT_READ/WRITE. With SSL connections it's 74 74 possible that something has to be read while actually were trying to 75 75 write something (think about key exchange/refresh/etc). So when an -
lib/ssl_gnutls.c
r51a799e rba7d16f 106 106 struct scd *conn = data; 107 107 108 return ssl_connected( conn, conn->fd, B_EV_IO_WRITE );108 return ssl_connected( conn, conn->fd, GAIM_INPUT_WRITE ); 109 109 } 110 110 … … 244 244 { 245 245 return( gnutls_record_get_direction( ((struct scd*)conn)->session ) ? 246 B_EV_IO_WRITE : B_EV_IO_READ );247 } 246 GAIM_INPUT_WRITE : GAIM_INPUT_READ ); 247 } -
lib/ssl_nss.c
r51a799e rba7d16f 193 193 { 194 194 /* Just in case someone calls us, let's return the most likely case: */ 195 return B_EV_IO_READ;195 return GAIM_INPUT_READ; 196 196 } -
lib/ssl_openssl.c
r51a799e rba7d16f 102 102 struct scd *conn = data; 103 103 104 return ssl_connected( conn, conn->fd, B_EV_IO_WRITE );104 return ssl_connected( conn, conn->fd, GAIM_INPUT_WRITE ); 105 105 } 106 106 … … 270 270 b_input_condition ssl_getdirection( void *conn ) 271 271 { 272 return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? B_EV_IO_WRITE : B_EV_IO_READ );273 } 272 return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ ); 273 } -
lib/ssl_sspi.c
r51a799e rba7d16f 275 275 GaimInputCondition ssl_getdirection( void *conn ) 276 276 { 277 return B_EV_IO_WRITE; /* FIXME: or B_EV_IO_READ */278 } 277 return GAIM_INPUT_WRITE; /* FIXME: or GAIM_INPUT_READ */ 278 } -
lib/url.c
r51a799e rba7d16f 27 27 28 28 /* Convert an URL to a url_t structure */ 29 int url_set( url_t *url, c onst char *set_url )29 int url_set( url_t *url, char *set_url ) 30 30 { 31 31 char s[MAX_STRING+1]; -
lib/url.h
r51a799e rba7d16f 42 42 } url_t; 43 43 44 int url_set( url_t *url, c onst char *set_url );44 int url_set( url_t *url, char *set_url ); -
lib/xmltree.c
r51a799e rba7d16f 449 449 while( node ) 450 450 { 451 char *colon; 452 453 if( g_strcasecmp( node->name, name ) == 0 || 454 ( ( colon = strchr( node->name, ':' ) ) && 455 g_strcasecmp( colon + 1, name ) == 0 ) ) 451 if( g_strcasecmp( node->name, name ) == 0 ) 456 452 break; 457 453 … … 465 461 { 466 462 int i; 467 char *colon;468 463 469 464 if( !node ) … … 473 468 if( g_strcasecmp( node->attr[i].key, key ) == 0 ) 474 469 break; 475 476 /* This is an awful hack that only takes care of namespace prefixes477 inside a tag. Since IMHO excessive namespace usage in XMPP is478 massive overkill anyway (this code exists for almost four years479 now and never really missed it): Meh. */480 if( !node->attr[i].key && strcmp( key, "xmlns" ) == 0 &&481 ( colon = strchr( node->name, ':' ) ) )482 {483 *colon = '\0';484 for( i = 0; node->attr[i].key; i ++ )485 if( strncmp( node->attr[i].key, "xmlns:", 6 ) == 0 &&486 strcmp( node->attr[i].key + 6, node->name ) == 0 )487 break;488 *colon = ':';489 }490 470 491 471 return node->attr[i].value; -
log.c
r51a799e rba7d16f 172 172 fprintf(stdout, "Debug: %s\n", message); 173 173 #endif 174 /* Always log stuff in syslogs too. */175 log_syslog(level, message);176 174 return; 177 175 } -
protocols/jabber/conference.c
r51a799e rba7d16f 272 272 } 273 273 274 if( bud != jc->me && bud->flags & JBFLAG_IS_ANONYMOUS ) 275 { 276 /* If JIDs are anonymized, add them to the local 277 list for the duration of this chat. */ 274 if( bud != jc->me ) 275 { 278 276 imcb_add_buddy( ic, bud->ext_jid, NULL ); 279 277 imcb_buddy_nick_hint( ic, bud->ext_jid, bud->resource ); -
protocols/jabber/io.c
r51a799e rba7d16f 64 64 most cases it probably won't be necessary.) */ 65 65 if( ( ret = jabber_write_queue( ic ) ) && jd->tx_len > 0 ) 66 jd->w_inpa = b_input_add( jd->fd, B_EV_IO_WRITE, jabber_write_callback, ic );66 jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, ic ); 67 67 } 68 68 else … … 504 504 505 505 if( jd->r_inpa <= 0 ) 506 jd->r_inpa = b_input_add( jd->fd, B_EV_IO_READ, jabber_read_callback, ic );506 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic ); 507 507 508 508 greet = g_strdup_printf( "%s<stream:stream to=\"%s\" xmlns=\"jabber:client\" " -
protocols/jabber/jabber_util.c
r51a799e rba7d16f 671 671 time_t jabber_get_timestamp( struct xt_node *xt ) 672 672 { 673 struct tm tp, utc; 673 674 struct xt_node *c; 675 time_t res, tres; 674 676 char *s = NULL; 675 struct tm tp;676 677 677 678 for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) … … 691 692 tp.tm_year -= 1900; 692 693 tp.tm_mon --; 693 694 return mktime_utc( &tp ); 694 tp.tm_isdst = -1; /* GRRRRRRRRRRR */ 695 696 res = mktime( &tp ); 697 /* Problem is, mktime() just gave us the GMT timestamp for the 698 given local time... While the given time WAS NOT local. So 699 we should fix this now. 700 701 Now I could choose between messing with environment variables 702 (kludgy) or using timegm() (not portable)... Or doing the 703 following, which I actually prefer... */ 704 gmtime_r( &res, &utc ); 705 utc.tm_isdst = -1; /* Once more: GRRRRRRRRRRRRRRRRRR!!! */ 706 if( utc.tm_hour == tp.tm_hour && utc.tm_min == tp.tm_min ) 707 /* Sweet! We're in UTC right now... */ 708 return res; 709 710 tres = mktime( &utc ); 711 res += res - tres; 712 713 /* Yes, this is a hack. And it will go wrong around DST changes. 714 BUT this is more likely to be threadsafe than messing with 715 environment variables, and possibly more portable... */ 716 717 return res; 695 718 } 696 719 -
protocols/jabber/message.c
r51a799e rba7d16f 80 80 if( type && strcmp( type, "headline" ) == 0 ) 81 81 { 82 if( ( c = xt_find_node( node->children, "subject" ) ) && c->text_len > 0 )83 g_string_append_printf( fullmsg, "Headline: %s\n", c->text);82 c = xt_find_node( node->children, "subject" ); 83 g_string_append_printf( fullmsg, "Headline: %s\n", c && c->text_len > 0 ? c->text : "" ); 84 84 85 85 /* <x xmlns="jabber:x:oob"><url>http://....</url></x> can contain a URL, it seems. */ -
protocols/jabber/s5bytestream.c
r51a799e rba7d16f 406 406 bt->phase = BS_PHASE_CONNECTED; 407 407 408 bt->tf->watch_out = b_input_add( fd, B_EV_IO_WRITE, jabber_bs_recv_handshake, bt );408 bt->tf->watch_out = b_input_add( fd, GAIM_INPUT_WRITE, jabber_bs_recv_handshake, bt ); 409 409 410 410 /* since it takes forever(3mins?) till connect() fails on itself we schedule a timeout */ … … 433 433 bt->phase = BS_PHASE_REQUEST; 434 434 435 bt->tf->watch_in = b_input_add( fd, B_EV_IO_READ, jabber_bs_recv_handshake, bt );435 bt->tf->watch_in = b_input_add( fd, GAIM_INPUT_READ, jabber_bs_recv_handshake, bt ); 436 436 437 437 bt->tf->watch_out = 0; … … 589 589 590 590 tf->ft->data = tf; 591 tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_recv_read, bt );591 tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_recv_read, bt ); 592 592 tf->ft->write_request = jabber_bs_recv_write_request; 593 593 … … 631 631 if( ( ret == -1 ) && ( errno == EAGAIN ) ) 632 632 { 633 tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_recv_read, bt );633 tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_recv_read, bt ); 634 634 return FALSE; 635 635 } … … 707 707 imcb_file_finished( ft ); 708 708 else 709 bt->tf->watch_out = b_input_add( tf->fd, B_EV_IO_WRITE, jabber_bs_send_can_write, bt );709 bt->tf->watch_out = b_input_add( tf->fd, GAIM_INPUT_WRITE, jabber_bs_send_can_write, bt ); 710 710 711 711 return TRUE; … … 918 918 bt->streamhosts = g_slist_append( bt->streamhosts, sh ); 919 919 920 bt->tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_send_handshake, bt );920 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt ); 921 921 bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 922 922 } else { … … 1055 1055 bt->phase = BS_PHASE_CONNECTED; 1056 1056 1057 bt->tf->watch_in = b_input_add( fd, B_EV_IO_READ, jabber_bs_send_handshake, bt );1057 bt->tf->watch_in = b_input_add( fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt ); 1058 1058 return FALSE; 1059 1059 } -
protocols/msn/invitation.c
r51a799e rba7d16f 209 209 sock_make_nonblocking( fd ); 210 210 211 msn_file->r_event_id = b_input_add( fd, B_EV_IO_READ, msn_ftp_read, file );211 msn_file->r_event_id = b_input_add( fd, GAIM_INPUT_READ, msn_ftp_read, file ); 212 212 213 213 return FALSE; … … 230 230 } 231 231 232 msn_file->r_event_id = b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftps_connected, file );232 msn_file->r_event_id = b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftps_connected, file ); 233 233 234 234 g_snprintf( buf, sizeof( buf ), … … 318 318 319 319 sock_make_nonblocking( msn_file->fd ); 320 msn_file->r_event_id = b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftp_read, file );320 msn_file->r_event_id = b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftp_read, file ); 321 321 322 322 return FALSE; … … 415 415 ( msn_file->data_sent + msn_file->sbufpos - 3 < file->file_size ) ) { 416 416 if( !msn_file->w_event_id ) 417 msn_file->w_event_id = b_input_add( msn_file->fd, B_EV_IO_WRITE, msn_ftp_send, file );417 msn_file->w_event_id = b_input_add( msn_file->fd, GAIM_INPUT_WRITE, msn_ftp_send, file ); 418 418 return TRUE; 419 419 } … … 452 452 /* we might already be listening if this is data from an overflow */ 453 453 if( !msn_file->w_event_id ) 454 msn_file->w_event_id = b_input_add( msn_file->fd, B_EV_IO_WRITE, msn_ftp_send, file );454 msn_file->w_event_id = b_input_add( msn_file->fd, GAIM_INPUT_WRITE, msn_ftp_send, file ); 455 455 } 456 456 … … 617 617 618 618 msn_file->r_event_id = 619 b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftp_read, file );619 b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftp_read, file ); 620 620 621 621 return TRUE; -
protocols/msn/msn.c
r51a799e rba7d16f 31 31 GSList *msn_switchboards; 32 32 33 static char * set_eval_display_name( set_t *set, char *value );33 static char *msn_set_display_name( set_t *set, char *value ); 34 34 35 35 static void msn_init( account_t *acc ) 36 36 { 37 set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); 38 set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc ); 39 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 40 set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc ); 37 set_t *s; 38 39 s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); 40 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 41 42 s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 41 43 } 42 44 … … 169 171 static void msn_set_my_name( struct im_connection *ic, char *info ) 170 172 { 171 msn_set_display_name( ic, info );173 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info ); 172 174 } 173 175 … … 285 287 } 286 288 287 static char * set_eval_display_name( set_t *set, char *value )289 static char *msn_set_display_name( set_t *set, char *value ) 288 290 { 289 291 account_t *acc = set->data; 290 292 struct im_connection *ic = acc->ic; 291 292 /* Allow any name if we're offline. */ 293 struct msn_data *md; 294 char buf[1024], *fn; 295 296 /* Double-check. */ 293 297 if( ic == NULL ) 294 return value; 298 return NULL; 299 300 md = ic->proto_data; 295 301 296 302 if( strlen( value ) > 129 ) … … 299 305 return NULL; 300 306 } 307 308 fn = msn_http_encode( value ); 309 310 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn ); 311 msn_write( ic, buf, strlen( buf ) ); 312 g_free( fn ); 301 313 302 314 /* Returning NULL would be better, because the server still has to 303 315 confirm the name change. However, it looks a bit confusing to the 304 316 user. */ 305 return msn_set_display_name( ic, value ) ? value : NULL;317 return value; 306 318 } 307 319 -
protocols/msn/msn.h
r51a799e rba7d16f 31 31 #define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r" 32 32 #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r" 33 #define SB_KEEPALIVE_MESSAGE "\r\r\rDONT HANG UP ON ME!\r\r\r"34 33 35 34 #ifdef DEBUG_MSN … … 54 53 "TypingUser: %s\r\n" \ 55 54 "\r\n\r\n" 56 57 #define SB_KEEPALIVE_HEADERS "MIME-Version: 1.0\r\n" \58 "Content-Type: text/x-ping\r\n" \59 "\r\n\r\n"60 55 61 56 #define PROFILE_URL "http://members.msn.com/" … … 89 84 gint inp; 90 85 struct msn_handler_data *handler; 91 gint keepalive;92 86 93 87 int trId; … … 168 162 char *msn_http_encode( const char *input ); 169 163 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 170 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname );171 164 172 165 /* tables.c */ … … 187 180 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); 188 181 int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ); 189 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial );190 void msn_sb_stop_keepalives( struct msn_switchboard *sb );191 182 192 183 /* invitation.c */ -
protocols/msn/msn_util.c
r51a799e rba7d16f 38 38 imcb_error( ic, "Short write() to main server" ); 39 39 imc_logout( ic, TRUE ); 40 return 0;41 } 42 43 return 1;40 return( 0 ); 41 } 42 43 return( 1 ); 44 44 } 45 45 … … 377 377 g_string_free( ret, TRUE ); 378 378 } 379 380 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname )381 {382 char *fn = msn_http_encode( rawname );383 struct msn_data *md = ic->proto_data;384 char buf[1024];385 386 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );387 g_free( fn );388 389 return msn_write( ic, buf, strlen( buf ) ) != 0;390 } -
protocols/msn/ns.c
r51a799e rba7d16f 35 35 36 36 static void msn_auth_got_passport_token( struct msn_auth_data *mad ); 37 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name );38 37 39 38 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) … … 76 75 if( msn_write( ic, s, strlen( s ) ) ) 77 76 { 78 ic->inpa = b_input_add( md->fd, B_EV_IO_READ, msn_ns_callback, ic );77 ic->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, ic ); 79 78 imcb_log( ic, "Connected to server, waiting for reply" ); 80 79 } … … 232 231 else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) 233 232 { 233 set_t *s; 234 234 235 if( num_parts == 7 ) 235 msn_ns_got_display_name( ic, cmd[4] ); 236 { 237 http_decode( cmd[4] ); 238 239 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 240 ic->displayname[sizeof(ic->displayname)-1] = 0; 241 242 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 243 { 244 g_free( s->value ); 245 s->value = g_strdup( cmd[4] ); 246 } 247 } 236 248 else 249 { 237 250 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 251 } 238 252 239 253 imcb_log( ic, "Authenticated, getting buddy list" ); … … 422 436 else if( strcmp( cmd[0], "FLN" ) == 0 ) 423 437 { 424 if( cmd[1] == NULL ) 425 return 1; 426 427 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL ); 428 429 msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE ); 438 if( cmd[1] ) 439 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL ); 430 440 } 431 441 else if( strcmp( cmd[0], "NLN" ) == 0 ) … … 453 463 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 454 464 st->name, NULL ); 455 456 msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) );457 465 } 458 466 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 559 567 return( 0 ); 560 568 } 561 #if 0562 /* Discard this one completely for now since I don't care about the ack563 and since MSN servers can apparently screw up the formatting. */564 569 else if( strcmp( cmd[0], "REA" ) == 0 ) 565 570 { … … 592 597 } 593 598 } 594 #endif595 599 else if( strcmp( cmd[0], "IPG" ) == 0 ) 596 600 { … … 742 746 } 743 747 } 744 745 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name )746 {747 set_t *s;748 749 if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL )750 return FALSE; /* Shouldn't happen.. */751 752 http_decode( name );753 754 if( s->value && strcmp( s->value, name ) == 0 )755 {756 return TRUE;757 /* The names match, nothing to worry about. */758 }759 else if( s->value != NULL &&760 ( strcmp( name, ic->acc->user ) == 0 ||761 set_getbool( &ic->acc->set, "local_display_name" ) ) )762 {763 /* The server thinks our display name is our e-mail address764 which is probably wrong, or the user *wants* us to do this:765 Always use the locally set display_name. */766 return msn_set_display_name( ic, s->value );767 }768 else769 {770 if( s->value && *s->value )771 imcb_log( ic, "BitlBee thinks your display name is `%s' but "772 "the MSN server says it's `%s'. Using the MSN "773 "server's name. Set local_display_name to true "774 "to use the local name.", s->value, name );775 776 if( g_utf8_validate( name, -1, NULL ) )777 {778 g_free( s->value );779 s->value = g_strdup( name );780 }781 else782 {783 imcb_log( ic, "Warning: Friendly name in server response was corrupted" );784 }785 786 return TRUE;787 }788 } -
protocols/msn/sb.c
r51a799e rba7d16f 180 180 i = strlen( buf ); 181 181 } 182 else if( strcmp( text, SB_KEEPALIVE_MESSAGE ) == 0 )183 {184 buf = g_strdup( SB_KEEPALIVE_HEADERS );185 i = strlen( buf );186 }187 182 else 188 183 { … … 261 256 262 257 msn_msgq_purge( ic, &sb->msgq ); 263 msn_sb_stop_keepalives( sb );264 258 265 259 if( sb->key ) g_free( sb->key ); … … 321 315 322 316 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 323 sb->inp = b_input_add( sb->fd, B_EV_IO_READ, msn_sb_callback, sb );317 sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb ); 324 318 else 325 319 debug( "Error %d while connecting to switchboard server", 2 ); … … 334 328 struct msn_data *md = ic->proto_data; 335 329 336 if( msn_handler( sb->handler ) != -1 ) 337 return TRUE; 338 339 if( sb->msgq != NULL ) 330 if( msn_handler( sb->handler ) == -1 ) 340 331 { 341 332 time_t now = time( NULL ); 342 char buf[1024];343 333 344 334 if( now - md->first_sb_failure > 600 ) … … 357 347 "There might be problems delivering your messages." ); 358 348 359 if( md->msgq == NULL ) 360 { 361 md->msgq = sb->msgq; 362 } 363 else 364 { 365 GSList *l; 366 367 for( l = md->msgq; l->next; l = l->next ); 368 l->next = sb->msgq; 369 } 370 sb->msgq = NULL; 371 372 debug( "Moved queued messages back to the main queue, " 373 "creating a new switchboard to retry." ); 374 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 375 if( !msn_write( ic, buf, strlen( buf ) ) ) 376 return FALSE; 377 } 378 379 msn_sb_destroy( sb ); 380 return FALSE; 349 if( sb->msgq != NULL ) 350 { 351 char buf[1024]; 352 353 if( md->msgq == NULL ) 354 { 355 md->msgq = sb->msgq; 356 } 357 else 358 { 359 GSList *l; 360 361 for( l = md->msgq; l->next; l = l->next ); 362 l->next = sb->msgq; 363 } 364 sb->msgq = NULL; 365 366 debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." ); 367 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 368 if( !msn_write( ic, buf, strlen( buf ) ) ) 369 return FALSE; 370 } 371 372 msn_sb_destroy( sb ); 373 374 return FALSE; 375 } 376 else 377 { 378 return TRUE; 379 } 381 380 } 382 381 … … 478 477 479 478 sb->ready = 1; 480 481 msn_sb_start_keepalives( sb, FALSE );482 479 } 483 480 else if( strcmp( cmd[0], "CAL" ) == 0 ) … … 529 526 } 530 527 531 msn_sb_start_keepalives( sb, FALSE );532 533 528 return( st ); 534 529 } … … 592 587 if( sb->who ) 593 588 { 594 msn_sb_stop_keepalives( sb );595 596 589 /* This is a single-person chat, and the other person is leaving. */ 597 590 g_free( sb->who ); … … 756 749 return( 1 ); 757 750 } 758 759 static gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond )760 {761 struct msn_switchboard *sb = data;762 return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE );763 }764 765 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial )766 {767 struct buddy *b;768 769 if( sb && sb->who && sb->keepalive == 0 &&770 ( b = imcb_find_buddy( sb->ic, sb->who ) ) && !b->present &&771 set_getbool( &sb->ic->acc->set, "switchboard_keepalives" ) )772 {773 if( initial )774 msn_sb_keepalive( sb, 0, 0 );775 776 sb->keepalive = b_timeout_add( 20000, msn_sb_keepalive, sb );777 }778 }779 780 void msn_sb_stop_keepalives( struct msn_switchboard *sb )781 {782 if( sb && sb->keepalive > 0 )783 {784 b_event_remove( sb->keepalive );785 sb->keepalive = 0;786 }787 } -
protocols/nogaim.c
r51a799e rba7d16f 39 39 40 40 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); 41 static char *format_timestamp( irc_t *irc, time_t msg_ts );42 41 43 42 GSList *connections; … … 117 116 { 118 117 GList *gl; 119 120 for( gl = protocols; gl; gl = gl->next ) 118 for (gl = protocols; gl; gl = gl->next) 121 119 { 122 120 struct prpl *proto = gl->data; 123 124 if( g_strcasecmp( proto->name, name ) == 0 ) 121 if(!g_strcasecmp(proto->name, name)) 125 122 return proto; 126 123 } 127 128 124 return NULL; 129 125 } … … 136 132 extern void byahoo_initmodule(); 137 133 extern void jabber_initmodule(); 138 extern void twitter_initmodule();139 extern void purple_initmodule();140 134 141 135 #ifdef WITH_MSN … … 153 147 #ifdef WITH_JABBER 154 148 jabber_initmodule(); 155 #endif156 157 #ifdef WITH_TWITTER158 twitter_initmodule();159 #endif160 161 #ifdef WITH_PURPLE162 purple_initmodule();163 149 #endif 164 150 … … 665 651 u->away = u->status_msg = NULL; 666 652 667 if( set_getbool( &ic->irc->set, "show_offline" ) && !u->online ) 668 { 669 /* always set users as online */ 653 if( ( flags & OPT_LOGGED_IN ) && !u->online ) 654 { 670 655 irc_spawn( ic->irc, u ); 671 656 u->online = 1; 672 if( !( flags & OPT_LOGGED_IN ) )673 {674 /* set away message if user isn't really online */675 u->away = g_strdup( "User is offline" );676 }677 }678 else if( ( flags & OPT_LOGGED_IN ) && !u->online )679 {680 irc_spawn( ic->irc, u );681 u->online = 1;682 657 } 683 658 else if( !( flags & OPT_LOGGED_IN ) && u->online ) … … 685 660 struct groupchat *c; 686 661 687 if( set_getbool( &ic->irc->set, "show_offline" ) ) 688 { 689 /* keep offline users in channel and set away message to "offline" */ 690 u->away = g_strdup( "User is offline" ); 691 692 /* Keep showing him/her in the control channel but not in groupchats. */ 693 for( c = ic->groupchats; c; c = c->next ) 694 { 695 if( remove_chat_buddy_silent( c, handle ) && c->joined ) 696 irc_part( c->ic->irc, u, c->channel ); 697 } 662 irc_kill( ic->irc, u ); 663 u->online = 0; 664 665 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */ 666 for( c = ic->groupchats; c; c = c->next ) 667 remove_chat_buddy_silent( c, handle ); 668 } 669 670 if( flags & OPT_AWAY ) 671 { 672 if( state && message ) 673 { 674 u->away = g_strdup_printf( "%s (%s)", state, message ); 675 } 676 else if( state ) 677 { 678 u->away = g_strdup( state ); 679 } 680 else if( message ) 681 { 682 u->away = g_strdup( message ); 698 683 } 699 684 else 700 685 { 701 /* kill offline users */702 irc_kill( ic->irc, u );703 u->online = 0;704 705 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */706 for( c = ic->groupchats; c; c = c->next )707 remove_chat_buddy_silent( c, handle );708 }709 }710 711 if( flags & OPT_AWAY )712 {713 if( state && message )714 {715 u->away = g_strdup_printf( "%s (%s)", state, message );716 }717 else if( state )718 {719 u->away = g_strdup( state );720 }721 else if( message )722 {723 u->away = g_strdup( message );724 }725 else726 {727 686 u->away = g_strdup( "Away" ); 728 687 } … … 733 692 } 734 693 735 /* early if-clause for show_offline even if there is some redundant code here because this isn't LISP but C ;) */ 736 if( set_getbool( &ic->irc->set, "show_offline" ) && set_getbool( &ic->irc->set, "away_devoice" ) ) 694 /* LISPy... */ 695 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 696 ( u->online ) && /* Don't touch offline people */ 697 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 698 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 737 699 { 738 700 char *from; … … 747 709 ic->irc->myhost ); 748 710 } 749 750 /* if we use show_offline, we op online users, voice away users, and devoice/deop offline users */ 751 if( flags & OPT_LOGGED_IN ) 752 { 753 /* user is "online" (either really online or away) */ 754 irc_write( ic->irc, ":%s MODE %s %cv%co %s %s", from, ic->irc->channel, 755 u->away?'+':'-', u->away?'-':'+', u->nick, u->nick ); 756 } 757 else 758 { 759 /* user is offline */ 760 irc_write( ic->irc, ":%s MODE %s -vo %s %s", from, ic->irc->channel, u->nick, u->nick ); 761 } 762 } 763 else 764 { 765 /* LISPy... */ 766 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 767 ( u->online ) && /* Don't touch offline people */ 768 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 769 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 770 { 771 char *from; 772 773 if( set_getbool( &ic->irc->set, "simulate_netsplit" ) ) 774 { 775 from = g_strdup( ic->irc->myhost ); 776 } 777 else 778 { 779 from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick, 780 ic->irc->myhost ); 781 } 782 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 783 u->away?'-':'+', u->nick ); 784 g_free( from ); 785 } 711 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, 712 u->away?'-':'+', u->nick ); 713 g_free( from ); 786 714 } 787 715 } … … 790 718 { 791 719 irc_t *irc = ic->irc; 792 char *wrapped , *ts = NULL;720 char *wrapped; 793 721 user_t *u; 794 722 … … 832 760 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 833 761 strip_html( msg ); 834 835 if( set_getbool( &ic->irc->set, "display_timestamps" ) && 836 ( ts = format_timestamp( irc, sent_at ) ) ) 837 { 838 char *new = g_strconcat( ts, msg, NULL ); 839 g_free( ts ); 840 ts = msg = new; 841 } 842 762 843 763 wrapped = word_wrap( msg, 425 ); 844 764 irc_msgfrom( irc, u->nick, wrapped ); 845 765 g_free( wrapped ); 846 g_free( ts );847 766 } 848 767 … … 886 805 887 806 return c; 888 }889 890 void imcb_chat_name_hint( struct groupchat *c, const char *name )891 {892 if( !c->joined )893 {894 struct im_connection *ic = c->ic;895 char stripped[MAX_NICK_LENGTH+1], *full_name;896 897 strncpy( stripped, name, MAX_NICK_LENGTH );898 stripped[MAX_NICK_LENGTH] = '\0';899 nick_strip( stripped );900 if( set_getbool( &ic->irc->set, "lcnicks" ) )901 nick_lc( stripped );902 903 full_name = g_strdup_printf( "&%s", stripped );904 905 if( stripped[0] &&906 nick_cmp( stripped, ic->irc->channel + 1 ) != 0 &&907 irc_chat_by_channel( ic->irc, full_name ) == NULL )908 {909 g_free( c->channel );910 c->channel = full_name;911 }912 else913 {914 g_free( full_name );915 }916 }917 807 } 918 808 … … 977 867 if( c && u ) 978 868 { 979 char *ts = NULL; 980 if( set_getbool( &ic->irc->set, "display_timestamps" ) ) 981 ts = format_timestamp( ic->irc, sent_at ); 982 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); 983 g_free( ts ); 869 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 984 870 } 985 871 else … … 1175 1061 } 1176 1062 1177 char *set_eval_timezone( set_t *set, char *value ) 1178 { 1179 char *s; 1180 1181 if( strcmp( value, "local" ) == 0 || 1182 strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 ) 1183 return value; 1184 1185 /* Otherwise: +/- at the beginning optional, then one or more numbers, 1186 possibly followed by a colon and more numbers. Don't bother bound- 1187 checking them since users are free to shoot themselves in the foot. */ 1188 s = value; 1189 if( *s == '+' || *s == '-' ) 1190 s ++; 1191 1192 /* \d+ */ 1193 if( !isdigit( *s ) ) 1194 return SET_INVALID; 1195 while( *s && isdigit( *s ) ) s ++; 1196 1197 /* EOS? */ 1198 if( *s == '\0' ) 1199 return value; 1200 1201 /* Otherwise, colon */ 1202 if( *s != ':' ) 1203 return SET_INVALID; 1204 s ++; 1205 1206 /* \d+ */ 1207 if( !isdigit( *s ) ) 1208 return SET_INVALID; 1209 while( *s && isdigit( *s ) ) s ++; 1210 1211 /* EOS */ 1212 return *s == '\0' ? value : SET_INVALID; 1213 } 1214 1215 static char *format_timestamp( irc_t *irc, time_t msg_ts ) 1216 { 1217 time_t now_ts = time( NULL ); 1218 struct tm now, msg; 1219 char *set; 1220 1221 /* If the timestamp is <= 0 or less than a minute ago, discard it as 1222 it doesn't seem to add to much useful info and/or might be noise. */ 1223 if( msg_ts <= 0 || msg_ts > now_ts - 60 ) 1224 return NULL; 1225 1226 set = set_getstr( &irc->set, "timezone" ); 1227 if( strcmp( set, "local" ) == 0 ) 1228 { 1229 localtime_r( &now_ts, &now ); 1230 localtime_r( &msg_ts, &msg ); 1231 } 1232 else 1233 { 1234 int hr, min = 0, sign = 60; 1235 1236 if( set[0] == '-' ) 1237 { 1238 sign *= -1; 1239 set ++; 1240 } 1241 else if( set[0] == '+' ) 1242 { 1243 set ++; 1244 } 1245 1246 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 ) 1247 { 1248 msg_ts += sign * ( hr * 60 + min ); 1249 now_ts += sign * ( hr * 60 + min ); 1250 } 1251 1252 gmtime_r( &now_ts, &now ); 1253 gmtime_r( &msg_ts, &msg ); 1254 } 1255 1256 if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday ) 1257 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ", 1258 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1259 else 1260 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d " 1261 "%02d:%02d:%02d\x02]\x02 ", 1262 msg.tm_year + 1900, msg.tm_mon + 1, msg.tm_mday, 1263 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1264 } 1063 1064 1265 1065 1266 1066 /* The plan is to not allow straight calls to prpl functions anymore, but do … … 1305 1105 { 1306 1106 char *away, *msg = NULL; 1307 1308 if( ic->acc->prpl->away_states == NULL ||1309 ic->acc->prpl->set_away == NULL )1310 return 0;1311 1107 1312 1108 away = set_getstr( &ic->acc->set, "away" ) ? -
protocols/nogaim.h
r51a799e rba7d16f 134 134 * - The user sees this name ie. when imcb_log() is used. */ 135 135 const char *name; 136 void *data;137 136 138 137 /* Added this one to be able to add per-account settings, don't think … … 308 307 * user, too. */ 309 308 G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); 310 G_MODULE_EXPORT void imcb_chat_name_hint( struct groupchat *c, const char *name );311 309 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); 312 310 /* To remove a handle from a group chat. Reason can be NULL. */ … … 331 329 332 330 /* Misc. stuff */ 333 char *set_eval_timezone( set_t *set, char *value );334 331 char *set_eval_away_devoice( set_t *set, char *value ); 335 332 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); -
protocols/oscar/oscar.c
r51a799e rba7d16f 205 205 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); 206 206 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); 207 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); 207 208 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); 208 209 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); … … 290 291 odata = (struct oscar_data *)ic->proto_data; 291 292 292 if (condition & B_EV_IO_READ) {293 if (condition & GAIM_INPUT_READ) { 293 294 if (aim_get_command(odata->sess, conn) >= 0) { 294 295 aim_rxdispatch(odata->sess); … … 362 363 363 364 aim_conn_completeconnect(sess, conn); 364 ic->inpa = b_input_add(conn->fd, B_EV_IO_READ,365 ic->inpa = b_input_add(conn->fd, GAIM_INPUT_READ, 365 366 oscar_callback, conn); 366 367 … … 492 493 493 494 aim_conn_completeconnect(sess, bosconn); 494 ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ,495 ic->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ, 495 496 oscar_callback, bosconn); 496 497 imcb_log(ic, _("Connection established, cookie sent")); … … 569 570 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0); 570 571 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0); 572 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x1f, gaim_memrequest, 0); 571 573 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0); 572 574 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); … … 602 604 } 603 605 606 struct pieceofcrap { 607 struct im_connection *ic; 608 unsigned long offset; 609 unsigned long len; 610 char *modname; 611 int fd; 612 aim_conn_t *conn; 613 unsigned int inpa; 614 }; 615 616 static gboolean damn_you(gpointer data, gint source, b_input_condition c) 617 { 618 struct pieceofcrap *pos = data; 619 struct oscar_data *od = pos->ic->proto_data; 620 char in = '\0'; 621 int x = 0; 622 unsigned char m[17]; 623 624 while (read(pos->fd, &in, 1) == 1) { 625 if (in == '\n') 626 x++; 627 else if (in != '\r') 628 x = 0; 629 if (x == 2) 630 break; 631 in = '\0'; 632 } 633 if (in != '\n') { 634 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM." 635 " You may be disconnected shortly."); 636 b_event_remove(pos->inpa); 637 closesocket(pos->fd); 638 g_free(pos); 639 return FALSE; 640 } 641 /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */ 642 read(pos->fd, m, 16); 643 m[16] = '\0'; 644 b_event_remove(pos->inpa); 645 closesocket(pos->fd); 646 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); 647 g_free(pos); 648 649 return FALSE; 650 } 651 652 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) { 653 struct pieceofcrap *pos = data; 654 char buf[BUF_LONG]; 655 656 if (source < 0) { 657 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM." 658 " You may be disconnected shortly."); 659 if (pos->modname) 660 g_free(pos->modname); 661 g_free(pos); 662 return FALSE; 663 } 664 665 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA 666 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", 667 pos->offset, pos->len, pos->modname ? pos->modname : ""); 668 write(pos->fd, buf, strlen(buf)); 669 if (pos->modname) 670 g_free(pos->modname); 671 pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); 672 return FALSE; 673 } 674 604 675 /* size of icbmui.ocm, the largest module in AIM 3.5 */ 605 676 #define AIM_MAX_FILE_SIZE 98304 677 678 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { 679 va_list ap; 680 struct pieceofcrap *pos; 681 guint32 offset, len; 682 char *modname; 683 int fd; 684 685 va_start(ap, fr); 686 offset = (guint32)va_arg(ap, unsigned long); 687 len = (guint32)va_arg(ap, unsigned long); 688 modname = va_arg(ap, char *); 689 va_end(ap); 690 691 if (len == 0) { 692 aim_sendmemblock(sess, fr->conn, offset, len, NULL, 693 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); 694 return 1; 695 } 696 /* uncomment this when you're convinced it's right. remember, it's been wrong before. 697 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { 698 char *buf; 699 int i = 8; 700 if (modname) 701 i += strlen(modname); 702 buf = g_malloc(i); 703 i = 0; 704 if (modname) { 705 memcpy(buf, modname, strlen(modname)); 706 i += strlen(modname); 707 } 708 buf[i++] = offset & 0xff; 709 buf[i++] = (offset >> 8) & 0xff; 710 buf[i++] = (offset >> 16) & 0xff; 711 buf[i++] = (offset >> 24) & 0xff; 712 buf[i++] = len & 0xff; 713 buf[i++] = (len >> 8) & 0xff; 714 buf[i++] = (len >> 16) & 0xff; 715 buf[i++] = (len >> 24) & 0xff; 716 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); 717 g_free(buf); 718 return 1; 719 } 720 */ 721 722 pos = g_new0(struct pieceofcrap, 1); 723 pos->ic = sess->aux_data; 724 pos->conn = fr->conn; 725 726 pos->offset = offset; 727 pos->len = len; 728 pos->modname = modname ? g_strdup(modname) : NULL; 729 730 fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos); 731 if (fd < 0) { 732 if (pos->modname) 733 g_free(pos->modname); 734 g_free(pos); 735 imcb_error(sess->aux_data, "Gaim was unable to get a valid hash for logging into AIM." 736 " You may be disconnected shortly."); 737 } 738 pos->fd = fd; 739 740 return 1; 741 } 606 742 607 743 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { … … 702 838 703 839 aim_conn_completeconnect(sess, tstconn); 704 odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ,840 odata->cnpa = b_input_add(tstconn->fd, GAIM_INPUT_READ, 705 841 oscar_callback, tstconn); 706 842 … … 730 866 731 867 aim_conn_completeconnect(sess, tstconn); 732 odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ,868 odata->paspa = b_input_add(tstconn->fd, GAIM_INPUT_READ, 733 869 oscar_callback, tstconn); 734 870 … … 766 902 aim_conn_completeconnect(sess, ccon->conn); 767 903 ccon->inpa = b_input_add(tstconn->fd, 768 B_EV_IO_READ,904 GAIM_INPUT_READ, 769 905 oscar_callback, tstconn); 770 906 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); … … 2515 2651 char * chatname; 2516 2652 2517 chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "", 2518 ic->acc->user, chat_id++); 2653 chatname = g_strdup_printf("%s%d", ic->acc->user, chat_id++); 2519 2654 2520 2655 ret = oscar_chat_join(ic, chatname, NULL, NULL); -
protocols/yahoo/yahoo.c
r51a799e rba7d16f 138 138 struct im_connection *ic = imcb_new( acc ); 139 139 struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); 140 char *s;141 140 142 141 yd->logged_in = FALSE; 143 142 yd->current_status = YAHOO_STATUS_AVAILABLE; 144 145 if( ( s = strchr( acc->user, '@' ) ) && g_strcasecmp( s, "@yahoo.com" ) == 0 )146 imcb_error( ic, "Your Yahoo! username should just be a username. "147 "Do not include any @domain part." );148 143 149 144 imcb_log( ic, "Connecting" ); … … 686 681 687 682 inp->d = d; 688 d->tag = inp->h = b_input_add( fd, B_EV_IO_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d );683 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d ); 689 684 } 690 685 else if( cond == YAHOO_INPUT_WRITE ) … … 697 692 698 693 inp->d = d; 699 d->tag = inp->h = b_input_add( fd, B_EV_IO_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );694 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d ); 700 695 } 701 696 else … … 833 828 YList *m; 834 829 835 if( g_strcasecmp( who, ic->acc->user ) == 0 )836 /* WTF, Yahoo! seems to echo these now? */837 return;838 839 830 inv = g_malloc( sizeof( struct byahoo_conf_invitation ) ); 840 831 memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); -
set.c
r51a799e rba7d16f 29 29 char *SET_INVALID = "nee"; 30 30 31 set_t *set_add( set_t **head, c onst char *key, constchar *def, set_eval eval, void *data )31 set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data ) 32 32 { 33 33 set_t *s = set_find( head, key ); … … 63 63 } 64 64 65 set_t *set_find( set_t **head, c onst char *key )65 set_t *set_find( set_t **head, char *key ) 66 66 { 67 67 set_t *s = *head; … … 77 77 } 78 78 79 char *set_getstr( set_t **head, c onst char *key )79 char *set_getstr( set_t **head, char *key ) 80 80 { 81 81 set_t *s = set_find( head, key ); … … 87 87 } 88 88 89 int set_getint( set_t **head, c onst char *key )89 int set_getint( set_t **head, char *key ) 90 90 { 91 91 char *s = set_getstr( head, key ); … … 101 101 } 102 102 103 int set_getbool( set_t **head, c onst char *key )103 int set_getbool( set_t **head, char *key ) 104 104 { 105 105 char *s = set_getstr( head, key ); … … 111 111 } 112 112 113 int set_setstr( set_t **head, c onst char *key, char *value )113 int set_setstr( set_t **head, char *key, char *value ) 114 114 { 115 115 set_t *s = set_find( head, key ); … … 150 150 } 151 151 152 int set_setint( set_t **head, c onst char *key, int value )152 int set_setint( set_t **head, char *key, int value ) 153 153 { 154 154 char s[24]; /* Not quite 128-bit clean eh? ;-) */ … … 158 158 } 159 159 160 void set_del( set_t **head, c onst char *key )160 void set_del( set_t **head, char *key ) 161 161 { 162 162 set_t *s = *head, *t = NULL; … … 182 182 } 183 183 184 int set_reset( set_t **head, c onst char *key )184 int set_reset( set_t **head, char *key ) 185 185 { 186 186 set_t *s; … … 211 211 { 212 212 return is_bool( value ) ? value : SET_INVALID; 213 }214 215 char *set_eval_list( set_t *set, char *value )216 {217 GSList *options = set->eval_data, *opt;218 219 for( opt = options; opt; opt = opt->next )220 if( strcmp( value, opt->data ) == 0 )221 return value;222 223 /* TODO: It'd be nice to show the user a list of allowed values,224 but we don't have enough context here to do that. May225 want to fix that. */226 227 return NULL;228 213 } 229 214 -
set.h
r51a799e rba7d16f 69 69 set_setstr() should be able to free() the returned string! */ 70 70 set_eval eval; 71 void *eval_data;72 71 struct set *next; 73 72 } set_t; 74 73 75 74 /* Should be pretty clear. */ 76 set_t *set_add( set_t **head, c onst char *key, constchar *def, set_eval eval, void *data );75 set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data ); 77 76 78 77 /* Returns the raw set_t. Might be useful sometimes. */ 79 set_t *set_find( set_t **head, c onst char *key );78 set_t *set_find( set_t **head, char *key ); 80 79 81 80 /* Returns a pointer to the string value of this setting. Don't modify the 82 81 returned string, and don't free() it! */ 83 G_MODULE_EXPORT char *set_getstr( set_t **head, c onst char *key );82 G_MODULE_EXPORT char *set_getstr( set_t **head, char *key ); 84 83 85 84 /* Get an integer. In previous versions set_getint() was also used to read 86 85 boolean values, but this SHOULD be done with set_getbool() now! */ 87 G_MODULE_EXPORT int set_getint( set_t **head, c onst char *key );88 G_MODULE_EXPORT int set_getbool( set_t **head, c onst char *key );86 G_MODULE_EXPORT int set_getint( set_t **head, char *key ); 87 G_MODULE_EXPORT int set_getbool( set_t **head, char *key ); 89 88 90 89 /* set_setstr() strdup()s the given value, so after using this function 91 90 you can free() it, if you want. */ 92 int set_setstr( set_t **head, c onst char *key, char *value );93 int set_setint( set_t **head, c onst char *key, int value );94 void set_del( set_t **head, c onst char *key );95 int set_reset( set_t **head, c onst char *key );91 int set_setstr( set_t **head, char *key, char *value ); 92 int set_setint( set_t **head, char *key, int value ); 93 void set_del( set_t **head, char *key ); 94 int set_reset( set_t **head, char *key ); 96 95 97 96 /* Two very useful generic evaluators. */ 98 97 char *set_eval_int( set_t *set, char *value ); 99 98 char *set_eval_bool( set_t *set, char *value ); 100 101 /* Another more complicated one. */102 char *set_eval_list( set_t *set, char *value );103 99 104 100 /* Some not very generic evaluators that really shouldn't be here... */ -
storage_xml.c
r51a799e rba7d16f 496 496 goto write_error; 497 497 498 fsync( fd );499 498 close( fd ); 500 499 -
unix.c
r51a799e rba7d16f 56 56 57 57 log_init(); 58 59 58 global.conf_file = g_strdup( CONF_FILE_DEF ); 60 59 global.conf = conf_load( argc, argv ); … … 63 62 64 63 b_main_init(); 64 nogaim_init(); 65 65 66 66 srand( time( NULL ) ^ getpid() ); 67 68 67 global.helpfile = g_strdup( HELP_FILE ); 69 if( help_init( &global.help, global.helpfile ) == NULL )70 log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );71 72 global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage );73 if( global.storage == NULL )74 {75 log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );76 return( 1 );77 }78 68 79 69 if( global.conf->runmode == RUNMODE_INETD ) … … 83 73 84 74 i = bitlbee_inetd_init(); 85 log_message( LOGLVL_INFO, "Bitl Bee %s starting in inetd mode.", BITLBEE_VERSION );75 log_message( LOGLVL_INFO, "Bitlbee %s starting in inetd mode.", BITLBEE_VERSION ); 86 76 87 77 } 88 78 else if( global.conf->runmode == RUNMODE_DAEMON ) 89 79 { 90 log_link( LOGLVL_ERROR, LOGOUTPUT_ CONSOLE);91 log_link( LOGLVL_WARNING, LOGOUTPUT_ CONSOLE);80 log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG ); 81 log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG ); 92 82 93 83 i = bitlbee_daemon_init(); 94 log_message( LOGLVL_INFO, "Bitl Bee %s starting in daemon mode.", BITLBEE_VERSION );84 log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION ); 95 85 } 96 86 else if( global.conf->runmode == RUNMODE_FORKDAEMON ) 97 87 { 98 log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE );99 log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE );100 101 88 /* In case the operator requests a restart, we need this. */ 102 89 old_cwd = g_malloc( 256 ); … … 109 96 110 97 i = bitlbee_daemon_init(); 111 log_message( LOGLVL_INFO, "Bitl Bee %s starting in forking daemon mode.", BITLBEE_VERSION );98 log_message( LOGLVL_INFO, "Bitlbee %s starting in forking daemon mode.", BITLBEE_VERSION ); 112 99 } 113 100 if( i != 0 ) … … 126 113 setuid( pw->pw_uid ); 127 114 } 115 } 116 117 global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); 118 if( global.storage == NULL ) 119 { 120 log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage ); 121 return( 1 ); 128 122 } 129 123 … … 145 139 if( !getuid() || !geteuid() ) 146 140 log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" ); 141 if( help_init( &global.help, global.helpfile ) == NULL ) 142 log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE ); 147 143 148 144 b_main_run();
Note: See TracChangeset
for help on using the changeset viewer.