Changes in / [a15c097:9779c18]
- Files:
-
- 1 added
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
account.c
ra15c097 r9779c18 53 53 { 54 54 account_t *a, *ret = NULL; 55 char *handle, *s; 55 56 int nr; 57 58 /* This checks if the id string ends with (...) */ 59 if( ( handle = strchr( id, '(' ) ) && ( s = strchr( handle, ')' ) ) && s[1] == 0 ) 60 { 61 struct prpl *proto; 62 63 *s = *handle = 0; 64 handle ++; 65 66 if( ( proto = find_protocol( id ) ) ) 67 { 68 for( a = irc->accounts; a; a = a->next ) 69 if( a->prpl == proto && 70 a->prpl->cmp_buddynames( handle, a->user ) == 0 ) 71 ret = a; 72 } 73 74 /* Restore the string. */ 75 handle --; 76 *handle = '('; 77 *s = ')'; 78 79 if( ret ) 80 return ret; 81 } 56 82 57 83 if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 ) … … 141 167 void account_off( irc_t *irc, account_t *a ) 142 168 { 143 account_offline( a->gc ); 169 a->gc->wants_to_die = TRUE; 170 signoff( a->gc ); 144 171 a->gc = NULL; 145 172 if( a->reconnect ) -
bitlbee.c
ra15c097 r9779c18 111 111 BitlBee process. So let's only close TTY-fds. */ 112 112 if( isatty( 0 ) ) close( 0 ); 113 if( isatty( 0) ) close( 1 );114 if( isatty( 0) ) close( 2 );113 if( isatty( 1 ) ) close( 1 ); 114 if( isatty( 2 ) ) close( 2 ); 115 115 } 116 116 #endif -
bitlbee.h
ra15c097 r9779c18 111 111 #include "query.h" 112 112 #include "sock.h" 113 #include "util.h" 113 114 114 115 typedef struct global { … … 133 134 void root_command( irc_t *irc, char *command[] ); 134 135 void bitlbee_shutdown( gpointer data ); 135 double gettime( void );136 G_MODULE_EXPORT void http_encode( char *s );137 G_MODULE_EXPORT void http_decode( char *s );138 G_MODULE_EXPORT char *strip_newlines(char *source);139 136 140 137 extern global_t global; -
conf.c
ra15c097 r9779c18 95 95 conf->port = i; 96 96 } 97 else if( opt == ' p' )97 else if( opt == 'P' ) 98 98 { 99 99 g_free( conf->pidfile ); -
configure
ra15c097 r9779c18 171 171 CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0` 172 172 EOF 173 echo '#define GLIB2' >> config.h 174 elif type glib-config > /dev/null 2> /dev/null; then 175 cat<<EOF>>Makefile.settings 176 EFLAGS+=`glib-config --libs` 177 CFLAGS+=`glib-config --cflags` 178 EOF 179 echo '#define GLIB1' >> config.h 180 else 181 echo 'Cannot find glib development libraries, aborting. (Install libglib-dev?)' 173 else 174 echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)' 182 175 exit 1; 183 176 fi 184 185 if [ -r /usr/include/iconv.h ]; then186 :;187 elif [ -r /usr/local/include/iconv.h ]; then188 echo CFLAGS+=-I/usr/local/include >> Makefile.settings;189 else190 echo191 echo 'Warning: Could not find iconv.h, you might have to install it and/or modify'192 echo 'Makefile.settings to tell where this file is.';193 fi194 195 177 196 178 detect_gnutls() … … 333 315 334 316 echo 335 if [ -z "$BITLBEE_VERSION" -a -d .bzr -a -x "`which bzr`" ]; then 317 if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then 318 nick=`bzr nick` 319 if [ -n "$nick" -a "$nick" != "bitlbee" ]; then 320 nick="-$nick" 321 else 322 nick="" 323 fi 336 324 rev=`bzr revno` 337 325 echo 'Using bzr revision #'$rev' as version number' 338 BITLBEE_VERSION=\"bzr -$rev\"326 BITLBEE_VERSION=\"bzr$nick-$rev\" 339 327 fi 340 328 … … 409 397 ;; 410 398 *BSD ) 411 echo 'EFLAGS+=-liconv' >> Makefile.settings; 399 ;; 400 Darwin ) 401 ;; 402 IRIX ) 412 403 ;; 413 404 SunOS ) 414 405 echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings 415 406 echo 'STRIP=\# skip strip' >> Makefile.settings 416 echo 'EFLAGS+=-liconv' >> Makefile.settings;417 ;;418 Darwin )419 echo 'EFLAGS+=-liconv' >> Makefile.settings;420 ;;421 IRIX )422 407 ;; 423 408 CYGWIN* ) -
doc/README
ra15c097 r9779c18 47 47 48 48 BitlBee's only real dependency is GLib. This is available on virtually every 49 platform. Any recent version of GLib ( including 1.x versions) will work.49 platform. Any recent version of GLib (2.0 or higher) will work. 50 50 51 51 These days, MSN Messenger clients have to connect to the MS Passport servers -
doc/bitlbee.8
ra15c097 r9779c18 116 116 .SH AUTHORS 117 117 .PP 118 Wilmer van der Gaast < lintux@lintux.cx>118 Wilmer van der Gaast <wilmer@gaast.net> 119 119 .BR 120 120 Jelmer Vernooij <jelmer@vernstok.nl> -
doc/bitlbee.xinetd
ra15c097 r9779c18 14 14 server = /usr/local/sbin/bitlbee 15 15 16 ## xinetd is fucking retarded, what's the use of this port flag if 17 ## it HAS to be the same as in /etc/services ? 18 # port = 6667 16 ## You might want to limit access to localhost only: 17 # bind = 127.0.0.1 18 19 ## Thanks a lot to friedman@splode.com for telling us about the type 20 ## argument, so now this file can be used without having to edit 21 ## /etc/services too. 22 type = UNLISTED 23 port = 6667 19 24 } -
doc/user-guide/commands.xml
ra15c097 r9779c18 141 141 <short-description>Add a buddy to your contact list</short-description> 142 142 <syntax>add <connection> <handle> [<nick>]</syntax> 143 <syntax>add -tmp <connection> <handle> [<nick>]</syntax> 143 144 144 145 <description> … … 149 150 <para> 150 151 If you want, you can also tell BitlBee what nick to give the new contact. Of course you can also use the <emphasis>rename</emphasis> command for that, but sometimes this might be more convenient. 152 </para> 153 154 <para> 155 Adding -tmp adds the buddy to the internal BitlBee structures only, not to the real contact list (like done by <emphasis>set handle_unknown add</emphasis>). This allows you to talk to people who are not in your contact list. 151 156 </para> 152 157 </description> … … 616 621 617 622 <para> 618 To identify yourself in later sessions, you can use the <emphasis>identify</emphasis> command. 623 To identify yourself in later sessions, you can use the <emphasis>identify</emphasis> command. To change your password later, you can use the <emphasis>set password</emphasis> command. 619 624 </para> 620 625 </description> -
ipc.c
ra15c097 r9779c18 507 507 } 508 508 509 if (bind(serversock, &un_addr, sizeof(un_addr)) == -1) {509 if (bind(serversock, (struct sockaddr *)&un_addr, sizeof(un_addr)) == -1) { 510 510 log_message( LOGLVL_WARNING, "Unable to bind UNIX socket to %s: %s", IPCSOCKET, strerror(errno) ); 511 511 return 0; … … 571 571 ipc_to_children_str( "OPERMSG :New BitlBee master process started (version " BITLBEE_VERSION ")\r\n" ); 572 572 573 fclose( fp ); 573 574 return 1; 574 575 } -
ipc.h
ra15c097 r9779c18 47 47 48 48 void ipc_to_master( char **cmd ); 49 void ipc_to_master_str( char *format, ... ) ;49 void ipc_to_master_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 ); 50 50 void ipc_to_children( char **cmd ); 51 void ipc_to_children_str( char *format, ... ) ;51 void ipc_to_children_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 ); 52 52 53 53 /* We need this function in inetd mode, so let's just make it non-static. */ -
irc.c
ra15c097 r9779c18 55 55 irc->fd = fd; 56 56 irc->io_channel = g_io_channel_unix_new( fd ); 57 #ifdef GLIB258 57 g_io_channel_set_encoding (irc->io_channel, NULL, NULL); 59 58 g_io_channel_set_buffered (irc->io_channel, FALSE); 60 59 g_io_channel_set_flags( irc->io_channel, G_IO_FLAG_NONBLOCK, NULL ); 61 #else62 fcntl( irc->fd, F_SETFL, O_NONBLOCK);63 #endif64 60 irc->r_watch_source_id = g_io_add_watch( irc->io_channel, G_IO_IN | G_IO_ERR | G_IO_HUP, bitlbee_io_current_client_read, irc ); 65 61 … … 199 195 } 200 196 201 static gboolean irc_free_ userhash( gpointer key, gpointer value, gpointer data )197 static gboolean irc_free_hashkey( gpointer key, gpointer value, gpointer data ) 202 198 { 203 199 g_free( key ); … … 233 229 234 230 for (account = irc->accounts; account; account = account->next) { 235 if (account->gc) 236 account_offline(account->gc); 237 else if (account->reconnect) 238 g_source_remove(account->reconnect); 231 if (account->gc) { 232 account->gc->wants_to_die = TRUE; 233 signoff(account->gc); 234 } else if (account->reconnect) { 235 cancel_auto_reconnect(account); 236 } 239 237 } 240 238 … … 285 283 } 286 284 287 g_hash_table_foreach_remove(irc->userhash, irc_free_ userhash, NULL);285 g_hash_table_foreach_remove(irc->userhash, irc_free_hashkey, NULL); 288 286 g_hash_table_destroy(irc->userhash); 289 287 290 g_hash_table_foreach_remove(irc->watches, irc_free_ userhash, NULL);288 g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL); 291 289 g_hash_table_destroy(irc->watches); 292 290 … … 346 344 void irc_process( irc_t *irc ) 347 345 { 348 char **lines, *temp, **cmd ;346 char **lines, *temp, **cmd, *cs; 349 347 int i; 350 348 … … 355 353 for( i = 0; *lines[i] != '\0'; i ++ ) 356 354 { 355 char conv[IRC_MAX_LINE+1]; 356 357 /* [WvG] Because irc_tokenize splits at every newline, the lines[] list 358 should end with an empty string. This is why this actually works. 359 Took me a while to figure out, Maurits. :-P */ 357 360 if( lines[i+1] == NULL ) 358 361 { … … 362 365 i ++; 363 366 break; 364 } 367 } 368 369 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 370 { 371 conv[IRC_MAX_LINE] = 0; 372 if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) != -1 ) 373 lines[i] = conv; 374 } 365 375 366 376 if( ( cmd = irc_parse_line( lines[i] ) ) == NULL ) … … 388 398 } 389 399 400 /* Splits a long string into separate lines. The array is NULL-terminated and, unless the string 401 contains an incomplete line at the end, ends with an empty string. */ 390 402 char **irc_tokenize( char *buffer ) 391 403 { … … 428 440 } 429 441 442 /* Split an IRC-style line into little parts/arguments. */ 430 443 char **irc_parse_line( char *line ) 431 444 { … … 487 500 } 488 501 502 /* Converts such an array back into a command string. Mainly used for the IPC code right now. */ 489 503 char *irc_build_line( char **cmd ) 490 504 { … … 539 553 540 554 u = user_find( irc, irc->mynick ); 541 i f( u ) is_private = u->is_private;555 is_private = u->is_private; 542 556 543 557 va_start( params, format ); … … 563 577 { 564 578 int size; 565 char line[IRC_MAX_LINE ];566 579 char line[IRC_MAX_LINE+1], *cs; 580 567 581 if( irc->quit ) 568 582 return; 569 570 g_vsnprintf( line, IRC_MAX_LINE - 3, format, params ); 571 583 584 line[IRC_MAX_LINE] = 0; 585 g_vsnprintf( line, IRC_MAX_LINE - 2, format, params ); 586 572 587 strip_newlines( line ); 588 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 589 { 590 char conv[IRC_MAX_LINE+1]; 591 592 conv[IRC_MAX_LINE] = 0; 593 if( do_iconv( "UTF-8", cs, line, conv, 0, IRC_MAX_LINE - 2 ) != -1 ) 594 strcpy( line, conv ); 595 } 573 596 strcat( line, "\r\n" ); 574 597 575 598 if( irc->sendbuffer != NULL ) { 576 599 size = strlen( irc->sendbuffer ) + strlen( line ); … … 803 826 irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title ); 804 827 else 805 irc_reply( irc, 331, "%s :No topic for this channel" );828 irc_reply( irc, 331, "%s :No topic for this channel", channel ); 806 829 } 807 830 } … … 859 882 if( g_hash_table_lookup( irc->watches, nick ) ) 860 883 { 861 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged online" );884 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged online" ); 862 885 } 863 886 g_free( nick ); … … 876 899 void irc_kill( irc_t *irc, user_t *u ) 877 900 { 878 char *nick; 879 880 irc_write( irc, ":%s!%s@%s QUIT :%s", u->nick, u->user, u->host, "Leaving..." ); 901 char *nick, *s; 902 char reason[64]; 903 904 if( u->gc && u->gc->flags & OPT_LOGGING_OUT ) 905 { 906 if( u->gc->user->proto_opt[0][0] ) 907 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, 908 u->gc->user->proto_opt[0] ); 909 else if( ( s = strchr( u->gc->username, '@' ) ) ) 910 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, 911 s + 1 ); 912 else 913 g_snprintf( reason, sizeof( reason ), "%s %s.%s", irc->myhost, 914 u->gc->prpl->name, irc->myhost ); 915 916 /* proto_opt might contain garbage after the : */ 917 if( ( s = strchr( reason, ':' ) ) ) 918 *s = 0; 919 } 920 else 921 { 922 strcpy( reason, "Leaving..." ); 923 } 924 925 irc_write( irc, ":%s!%s@%s QUIT :%s", u->nick, u->user, u->host, reason ); 881 926 882 927 nick = g_strdup( u->nick ); … … 884 929 if( g_hash_table_lookup( irc->watches, nick ) ) 885 930 { 886 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged offline" );931 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged offline" ); 887 932 } 888 933 g_free( nick ); … … 984 1029 else if( c && c->gc && c->gc->prpl ) 985 1030 { 986 return( serv_send_chat( irc,c->gc, c->id, s ) );1031 return( bim_chat_msg( c->gc, c->id, s ) ); 987 1032 } 988 1033 … … 994 1039 user_t *u = data; 995 1040 1041 /* Shouldn't happen, but just to be sure. */ 1042 if( u->sendbuf_len < 2 ) 1043 return FALSE; 1044 996 1045 u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */ 997 serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );1046 bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags ); 998 1047 999 1048 g_free( u->sendbuf ); … … 1003 1052 u->sendbuf_flags = 0; 1004 1053 1005 return ( FALSE );1054 return FALSE; 1006 1055 } 1007 1056 … … 1016 1065 if( u->sendbuf_len > 0 && u->sendbuf_flags != flags) 1017 1066 { 1018 / /Flush the buffer1067 /* Flush the buffer */ 1019 1068 g_source_remove( u->sendbuf_timer ); 1020 1069 buddy_send_handler_delayed( u ); … … 1024 1073 { 1025 1074 u->sendbuf_len = strlen( msg ) + 2; 1026 u->sendbuf = g_new (char, u->sendbuf_len );1075 u->sendbuf = g_new( char, u->sendbuf_len ); 1027 1076 u->sendbuf[0] = 0; 1028 1077 u->sendbuf_flags = flags; … … 1031 1080 { 1032 1081 u->sendbuf_len += strlen( msg ) + 1; 1033 u->sendbuf = g_renew 1082 u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len ); 1034 1083 } 1035 1084 … … 1047 1096 else 1048 1097 { 1049 serv_send_im( irc, u, msg, flags );1098 bim_buddy_msg( u->gc, u->handle, msg, flags ); 1050 1099 } 1051 1100 } -
irc.h
ra15c097 r9779c18 105 105 106 106 irc_t *irc_new( int fd ); 107 void irc_abort( irc_t *irc, int immed, char *format, ... ) ;107 void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); 108 108 void irc_free( irc_t *irc ); 109 109 … … 114 114 115 115 void irc_vawrite( irc_t *irc, char *format, va_list params ); 116 void irc_write( irc_t *irc, char *format, ... ) ;117 void irc_write_all( int now, char *format, ... ) ;118 void irc_reply( irc_t *irc, int code, char *format, ... ) ;119 G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) ;116 void irc_write( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 117 void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 118 void irc_reply( irc_t *irc, int code, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); 119 G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 120 120 char **irc_tokenize( char *buffer ); 121 121 -
irc_commands.c
ra15c097 r9779c18 177 177 if( !u->gc->prpl->chat_open( u->gc, u->handle ) ) 178 178 { 179 irc_usermsg( irc, "Could not open a groupchat with %s , maybe you don't have a connection to him/her yet?", u->nick );179 irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); 180 180 } 181 181 } … … 321 321 { 322 322 user_t *u; 323 char buff[IRC_MAX_LINE] ;323 char buff[IRC_MAX_LINE], *s; 324 324 int lenleft, i; 325 325 … … 331 331 for( i = 1; cmd[i]; i ++ ) 332 332 { 333 if( ( u = user_find( irc, cmd[i] ) ) && u->online ) 334 { 335 /* [SH] Make sure we don't use too much buffer space. */ 336 lenleft -= strlen( u->nick ) + 1; 337 338 if( lenleft < 0 ) 333 char *this, *next; 334 335 this = cmd[i]; 336 while( *this ) 337 { 338 if( ( next = strchr( this, ' ' ) ) ) 339 *next = 0; 340 341 if( ( u = user_find( irc, this ) ) && u->online ) 342 { 343 lenleft -= strlen( u->nick ) + 1; 344 345 if( lenleft < 0 ) 346 break; 347 348 strcat( buff, u->nick ); 349 strcat( buff, " " ); 350 } 351 352 if( next ) 353 { 354 *next = ' '; 355 this = next + 1; 356 } 357 else 339 358 { 340 359 break; 341 } 342 343 /* [SH] Add the nick to the buffer. Note 344 * that an extra space is always added. Even 345 * if it's the last nick in the list. Who 346 * cares? 347 */ 348 349 strcat( buff, u->nick ); 350 strcat( buff, " " ); 351 } 352 } 353 354 /* [WvG] Well, maybe someone cares, so why not remove it? */ 360 } 361 } 362 363 /* *sigh* */ 364 if( lenleft < 0 ) 365 break; 366 } 367 355 368 if( strlen( buff ) > 0 ) 356 369 buff[strlen(buff)-1] = '\0'; … … 385 398 386 399 if( u && u->online ) 387 irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "is online" );400 irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" ); 388 401 else 389 irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", time( NULL ), "is offline" );402 irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" ); 390 403 } 391 404 else if( cmd[i][0] == '-' ) … … 448 461 449 462 if( gc && gc->flags & OPT_LOGGED_IN ) 450 proto_away( gc, u->away );463 bim_set_away( gc, u->away ); 451 464 } 452 465 } -
log.h
ra15c097 r9779c18 54 54 void log_init(void); 55 55 void log_link(int level, int output); 56 void log_message(int level, char *message, ...) ;56 void log_message(int level, char *message, ...) G_GNUC_PRINTF( 2, 3 ); 57 57 void log_error(char *functionname); 58 58 -
protocols/http_client.c
ra15c097 r9779c18 69 69 70 70 return( req ); 71 } 72 73 void *http_dorequest_url( char *url_string, http_input_function func, gpointer data ) 74 { 75 url_t *url = g_new0( url_t, 1 ); 76 char *request; 77 void *ret; 78 79 if( !url_set( url, url_string ) ) 80 { 81 g_free( url ); 82 return NULL; 83 } 84 85 if( url->proto != PROTO_HTTP && url->proto != PROTO_HTTPS ) 86 { 87 g_free( url ); 88 return NULL; 89 } 90 91 request = g_strdup_printf( "GET %s HTTP/1.0\r\n" 92 "Host: %s\r\n" 93 "User-Agent: BitlBee " BITLBEE_VERSION " " ARCH "/" CPU "\r\n" 94 "\r\n", url->file, url->host ); 95 96 ret = http_dorequest( url->host, url->port, 97 url->proto == PROTO_HTTPS, request, func, data ); 98 99 g_free( url ); 100 g_free( request ); 101 return ret; 71 102 } 72 103 … … 126 157 127 158 error: 159 req->status_string = g_strdup( "Error while writing HTTP request" ); 160 128 161 req->func( req ); 129 162 … … 185 218 if( !sockerr_again() ) 186 219 { 220 req->status_string = g_strdup( strerror( errno ) ); 187 221 goto cleanup; 188 222 } … … 209 243 210 244 got_reply: 245 /* Maybe if the webserver is overloaded, or when there's bad SSL 246 support... */ 247 if( req->bytes_read == 0 ) 248 { 249 req->status_string = g_strdup( "Empty HTTP reply" ); 250 goto cleanup; 251 } 252 211 253 /* Zero termination is very convenient. */ 212 254 req->reply_headers[req->bytes_read] = 0; … … 222 264 evil_server = 1; 223 265 } 224 else 266 else if( end1 ) 225 267 { 226 268 end1 += 2; 227 269 } 228 229 if( end1 ) 230 { 231 *end1 = 0; 232 233 if( evil_server ) 234 req->reply_body = end1 + 1; 270 else 271 { 272 req->status_string = g_strdup( "Malformed HTTP reply" ); 273 goto cleanup; 274 } 275 276 *end1 = 0; 277 278 if( evil_server ) 279 req->reply_body = end1 + 1; 280 else 281 req->reply_body = end1 + 2; 282 283 req->body_size = req->reply_headers + req->bytes_read - req->reply_body; 284 285 if( ( end1 = strchr( req->reply_headers, ' ' ) ) != NULL ) 286 { 287 if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 ) 288 { 289 req->status_string = g_strdup( "Can't parse status code" ); 290 req->status_code = -1; 291 } 235 292 else 236 req->reply_body = end1 + 2; 237 } 238 239 if( ( end1 = strchr( req->reply_headers, ' ' ) ) != NULL ) 240 { 241 if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 ) 242 req->status_code = -1; 243 } 244 else 245 { 293 { 294 char *eol; 295 296 if( evil_server ) 297 eol = strchr( end1, '\n' ); 298 else 299 eol = strchr( end1, '\r' ); 300 301 req->status_string = g_strndup( end1 + 1, eol - end1 - 1 ); 302 303 /* Just to be sure... */ 304 if( ( eol = strchr( req->status_string, '\r' ) ) ) 305 *eol = 0; 306 if( ( eol = strchr( req->status_string, '\n' ) ) ) 307 *eol = 0; 308 } 309 } 310 else 311 { 312 req->status_string = g_strdup( "Can't locate status code" ); 246 313 req->status_code = -1; 247 314 } … … 252 319 int error = 0, new_port, new_proto; 253 320 321 /* We might fill it again, so let's not leak any memory. */ 322 g_free( req->status_string ); 323 req->status_string = NULL; 324 254 325 loc = strstr( req->reply_headers, "\nLocation: " ); 255 326 if( loc == NULL ) /* We can't handle this redirect... */ 327 { 328 req->status_string = g_strdup( "Can't locate Location: header" ); 256 329 goto cleanup; 330 } 257 331 258 332 loc += 11; … … 271 345 don't need this yet anyway, I won't implement it. */ 272 346 347 req->status_string = g_strdup( "Can't handle recursive redirects" ); 348 273 349 goto cleanup; 274 350 } … … 288 364 if( !url_set( url, loc ) ) 289 365 { 366 req->status_string = g_strdup( "Malformed redirect URL" ); 290 367 g_free( url ); 291 368 goto cleanup; … … 298 375 going to use strcat(), whether you like it or not. :-) */ 299 376 300 /* First, find the GET/POST/whatever from the original request. */ 301 s = strchr( req->request, ' ' ); 377 sprintf( new_request, "GET %s HTTP/1.0", url->file ); 378 379 s = strstr( req->request, "\r\n" ); 302 380 if( s == NULL ) 303 381 { 382 req->status_string = g_strdup( "Error while rebuilding request string" ); 304 383 g_free( new_request ); 305 384 g_free( url ); … … 307 386 } 308 387 309 *s = 0; 310 sprintf( new_request, "%s %s HTTP/1.0\r\n", req->request, url->file ); 311 *s = ' '; 312 313 s = strstr( req->request, "\r\n" ); 314 if( s == NULL ) 315 { 316 g_free( new_request ); 317 g_free( url ); 318 goto cleanup; 319 } 320 321 strcat( new_request, s + 2 ); 388 strcat( new_request, s ); 322 389 new_host = g_strdup( url->host ); 323 390 new_port = url->port; … … 333 400 334 401 req->fd = -1; 335 req->ssl = 0;402 req->ssl = NULL; 336 403 337 404 if( new_proto == PROTO_HTTPS ) … … 351 418 if( error ) 352 419 { 420 req->status_string = g_strdup( "Connection problem during redirect" ); 353 421 g_free( new_request ); 354 422 goto cleanup; … … 379 447 g_free( req->request ); 380 448 g_free( req->reply_headers ); 449 g_free( req->status_string ); 381 450 g_free( req ); 382 451 } -
protocols/http_client.h
ra15c097 r9779c18 37 37 int request_length; 38 38 int status_code; 39 char *status_string; 39 40 char *reply_headers; 40 41 char *reply_body; 42 int body_size; 41 43 int finished; 42 44 … … 53 55 54 56 void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ); 57 void *http_dorequest_url( char *url_string, http_input_function func, gpointer data ); -
protocols/jabber/jabber.c
ra15c097 r9779c18 1045 1045 */ 1046 1046 if(find_buddy(GJ_GC(jap->gjc), jap->user) == NULL) { 1047 show_got_added(GJ_GC(jap->gjc), NULL, jap->user, NULL, NULL);1047 show_got_added(GJ_GC(jap->gjc), jap->user, NULL); 1048 1048 } 1049 1049 g_free(jap->user); … … 1549 1549 if(jd->gjc != NULL) { 1550 1550 gjab_delete(jd->gjc); 1551 /* YAY for modules with their own memory pool managers!... 1551 1552 g_free(jd->gjc->sid); 1553 And a less sarcastic yay for valgrind. :-) */ 1552 1554 jd->gjc = NULL; 1553 1555 } … … 1885 1887 } 1886 1888 1887 static void jabber_set_idle(struct gaim_connection *gc, int idle) {1888 struct jabber_data *jd = (struct jabber_data *)gc->proto_data;1889 jd->idle = idle ? time(NULL) - idle : idle;1890 }1891 1892 1889 static void jabber_keepalive(struct gaim_connection *gc) { 1893 1890 struct jabber_data *jd = (struct jabber_data *)gc->proto_data; 1894 1891 gjab_send_raw(jd->gjc, " \t "); 1895 }1896 1897 static void jabber_buddy_free(struct buddy *b)1898 {1899 while (b->proto_data) {1900 g_free(((GSList *)b->proto_data)->data);1901 b->proto_data = g_slist_remove(b->proto_data, ((GSList *)b->proto_data)->data);1902 }1903 1892 } 1904 1893 … … 2338 2327 } 2339 2328 2340 2341 static GList *jabber_actions()2342 {2343 GList *m = NULL;2344 2345 m = g_list_append(m, _("Set User Info"));2346 /*2347 m = g_list_append(m, _("Set Dir Info"));2348 m = g_list_append(m, _("Change Password"));2349 */2350 2351 return m;2352 }2353 2354 2355 2329 void jabber_init() 2356 2330 { 2357 2331 struct prpl *ret = g_new0(struct prpl, 1); 2358 2332 2359 /* the NULL's aren't required but they're nice to have */2360 2333 ret->name = "jabber"; 2361 2334 ret->away_states = jabber_away_states; 2362 ret->actions = jabber_actions;2363 2335 ret->login = jabber_login; 2364 2336 ret->close = jabber_close; … … 2368 2340 ret->set_away = jabber_set_away; 2369 2341 ret->get_away = jabber_get_away_msg; 2370 ret->set_idle = jabber_set_idle;2371 2342 ret->add_buddy = jabber_add_buddy; 2372 2343 ret->remove_buddy = jabber_remove_buddy; 2373 ret->add_permit = NULL;2374 ret->add_deny = NULL;2375 ret->rem_permit = NULL;2376 ret->rem_deny = NULL;2377 ret->set_permit_deny = NULL;2378 2344 ret->keepalive = jabber_keepalive; 2379 ret->buddy_free = jabber_buddy_free;2380 2345 ret->alias_buddy = jabber_roster_update; 2381 2346 ret->group_buddy = jabber_group_change; -
protocols/jabber/xmlparse.c
ra15c097 r9779c18 1461 1461 s = protocolEncodingName; 1462 1462 #endif 1463 if ( (ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s))1463 if (ns ? XmlInitEncodingNS(&initEncoding, &encoding, s) : XmlInitEncoding(&initEncoding, &encoding, s)) 1464 1464 return XML_ERROR_NONE; 1465 1465 return handleUnknownEncoding(parser, protocolEncodingName); … … 1475 1475 int standalone = -1; 1476 1476 if (!(ns 1477 ? XmlParseXmlDeclNS 1478 : XmlParseXmlDecl)(isGeneralTextEntity, 1477 ? XmlParseXmlDeclNS(isGeneralTextEntity, 1479 1478 encoding, 1480 1479 s, … … 1484 1483 &encodingName, 1485 1484 &newEncoding, 1486 &standalone)) 1485 &standalone) 1486 : XmlParseXmlDecl(isGeneralTextEntity, 1487 encoding, 1488 s, 1489 next, 1490 &eventPtr, 1491 &version, 1492 &encodingName, 1493 &newEncoding, 1494 &standalone))) 1487 1495 return XML_ERROR_SYNTAX; 1488 1496 if (!isGeneralTextEntity && standalone == 1) … … 1537 1545 } 1538 1546 enc = (ns 1539 ? XmlInitUnknownEncodingNS 1540 : XmlInitUnknownEncoding)(unknownEncodingMem, 1547 ? XmlInitUnknownEncodingNS(unknownEncodingMem, 1541 1548 info.map, 1542 1549 info.convert, 1543 info.data); 1550 info.data) 1551 : XmlInitUnknownEncoding(unknownEncodingMem, 1552 info.map, 1553 info.convert, 1554 info.data)); 1544 1555 if (enc) { 1545 1556 unknownEncodingData = info.data; -
protocols/msn/msn_util.c
ra15c097 r9779c18 130 130 { 131 131 msn_buddy_list_add( bla->gc, "AL", bla->handle, bla->realname ); 132 133 if( find_buddy( bla->gc, bla->handle ) == NULL ) 134 show_got_added( bla->gc, bla->handle, NULL ); 132 135 133 136 g_free( bla->handle ); -
protocols/msn/ns.c
ra15c097 r9779c18 650 650 if( key == NULL ) 651 651 { 652 hide_login_progress( gc, "Error during Passport authentication" ); 652 char *err; 653 654 err = g_strdup_printf( "Error during Passport authentication (%s)", 655 rep->error_string ? rep->error_string : "Unknown error" ); 656 657 hide_login_progress( gc, err ); 653 658 signoff( gc ); 659 660 g_free( err ); 654 661 } 655 662 else -
protocols/msn/passport.c
ra15c097 r9779c18 69 69 } 70 70 71 reqs = g_malloc( strlen( header ) + strlen( dummy ) + 128 ); 72 sprintf( reqs, "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header ); 71 reqs = g_strdup_printf( "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header ); 73 72 74 73 *dummy = 0; … … 88 87 struct passport_reply *rep = req->data; 89 88 90 if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers)89 if( !g_slist_find( msn_connections, rep->data ) ) 91 90 { 92 91 destroy_reply( rep ); … … 94 93 } 95 94 96 if( req-> status_code == 200 )95 if( req->finished && req->reply_headers && req->status_code == 200 ) 97 96 { 98 97 char *dummy; … … 109 108 rep->result = g_strdup( dummy ); 110 109 } 110 else 111 { 112 rep->error_string = g_strdup( "Could not parse Passport server response" ); 113 } 114 } 115 else 116 { 117 rep->error_string = g_strdup_printf( "HTTP error: %s", 118 req->status_string ? req->status_string : "Unknown error" ); 111 119 } 112 120 … … 145 153 } 146 154 147 #define PPR_REQUEST "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n"148 155 static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header ) 149 156 { … … 155 162 rep->header = header; 156 163 157 req = http_dorequest ( "nexus.passport.com", 443, 1, PPR_REQUEST, passport_retrieve_dalogin_ready, rep );164 req = http_dorequest_url( "https://nexus.passport.com/rdr/pprdr.asp", passport_retrieve_dalogin_ready, rep ); 158 165 159 166 if( !req ) … … 169 176 char *urlend; 170 177 171 if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers)178 if( !g_slist_find( msn_connections, rep->data ) ) 172 179 { 173 180 destroy_reply( rep ); … … 175 182 } 176 183 184 if( !req->finished || !req->reply_headers || req->status_code != 200 ) 185 { 186 rep->error_string = g_strdup_printf( "HTTP error while fetching DALogin: %s", 187 req->status_string ? req->status_string : "Unknown error" ); 188 goto failure; 189 } 190 177 191 dalogin = strstr( req->reply_headers, "DALogin=" ); 178 192 179 193 if( !dalogin ) 194 { 195 rep->error_string = g_strdup( "Parse error while fetching DALogin" ); 180 196 goto failure; 197 } 181 198 182 199 dalogin += strlen( "DALogin=" ); … … 208 225 g_free( rep->result ); 209 226 g_free( rep->header ); 227 g_free( rep->error_string ); 210 228 g_free( rep ); 211 229 } -
protocols/msn/passport.h
ra15c097 r9779c18 39 39 char *result; 40 40 char *header; 41 char *error_string; 41 42 }; 42 43 -
protocols/msn/sb.c
ra15c097 r9779c18 523 523 { 524 524 msn_sb_destroy( sb ); 525 return ( 0 );526 } 527 if( err->flags & STATUS_FATAL )525 return 0; 526 } 527 else if( err->flags & STATUS_FATAL ) 528 528 { 529 529 signoff( gc ); 530 return ( 0 );531 } 532 if( err->flags & STATUS_SB_IM_SPARE )530 return 0; 531 } 532 else if( err->flags & STATUS_SB_IM_SPARE ) 533 533 { 534 534 if( sb->who ) … … 553 553 sb->msgq = NULL; 554 554 } 555 556 /* Do NOT return 0 here, we want to keep this sb. */ 555 557 } 556 558 } -
protocols/msn/tables.c
ra15c097 r9779c18 127 127 128 128 { 910, "Server is busy", STATUS_FATAL }, 129 { 911, "Authentication failed", STATUS_ FATAL },129 { 911, "Authentication failed", STATUS_SB_FATAL | STATUS_FATAL }, 130 130 { 912, "Server is busy", STATUS_FATAL }, 131 131 { 913, "Not allowed when hiding", 0 }, -
protocols/nogaim.c
ra15c097 r9779c18 37 37 #include "nogaim.h" 38 38 #include <ctype.h> 39 #include <iconv.h>40 41 static char *proto_away_alias[8][5] =42 {43 { "Away from computer", "Away", "Extended away", NULL },44 { "NA", "N/A", "Not available", NULL },45 { "Busy", "Do not disturb", "DND", "Occupied", NULL },46 { "Be right back", "BRB", NULL },47 { "On the phone", "Phone", "On phone", NULL },48 { "Out to lunch", "Lunch", "Food", NULL },49 { "Invisible", "Hidden" },50 { NULL }51 };52 static char *proto_away_alias_find( GList *gcm, char *away );53 39 54 40 static int remove_chat_buddy_silent( struct conversation *b, char *handle ); … … 159 145 GSList *get_connections() { return connections; } 160 146 161 int proto_away( struct gaim_connection *gc, char *away )162 {163 GList *m, *ms;164 char *s;165 166 if( !away ) away = "";167 ms = m = gc->prpl->away_states( gc );168 169 while( m )170 {171 if( *away )172 {173 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )174 break;175 }176 else177 {178 if( g_strcasecmp( m->data, "Available" ) == 0 )179 break;180 if( g_strcasecmp( m->data, "Online" ) == 0 )181 break;182 }183 m = m->next;184 }185 186 if( m )187 {188 gc->prpl->set_away( gc, m->data, *away ? away : NULL );189 }190 else191 {192 s = proto_away_alias_find( ms, away );193 if( s )194 {195 gc->prpl->set_away( gc, s, away );196 if( set_getint( gc->irc, "debug" ) )197 serv_got_crap( gc, "Setting away state to %s", s );198 }199 else200 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );201 }202 203 g_list_free( ms );204 205 return( 1 );206 }207 208 static char *proto_away_alias_find( GList *gcm, char *away )209 {210 GList *m;211 int i, j;212 213 for( i = 0; *proto_away_alias[i]; i ++ )214 {215 for( j = 0; proto_away_alias[i][j]; j ++ )216 if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 )217 break;218 219 if( !proto_away_alias[i][j] ) /* If we reach the end, this row */220 continue; /* is not what we want. Next! */221 222 /* Now find an entry in this row which exists in gcm */223 for( j = 0; proto_away_alias[i][j]; j ++ )224 {225 m = gcm;226 while( m )227 {228 if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 )229 return( proto_away_alias[i][j] );230 m = m->next;231 }232 }233 }234 235 return( NULL );236 }237 238 147 /* multi.c */ 239 148 … … 306 215 { 307 216 va_list params; 308 char text[1024], buf[1024], *acc_id; 309 char *msg; 217 char *text; 310 218 account_t *a; 311 219 312 220 va_start( params, format ); 313 g_vsnprintf( text, sizeof( text ),format, params );221 text = g_strdup_vprintf( format, params ); 314 222 va_end( params ); 315 223 316 if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 &&317 do_iconv( "UTF8", set_getstr( gc->irc, "charset" ), text, buf, 0, 1024 ) != -1 )318 msg = buf;319 else320 msg = text;321 322 224 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || 323 225 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 324 strip_html( msg);226 strip_html( text ); 325 227 326 228 /* Try to find a different connection on the same protocol. */ … … 329 231 break; 330 232 331 /* If we found one, add the screenname to the acc_id. */233 /* If we found one, include the screenname in the message. */ 332 234 if( a ) 333 acc_id = g_strdup_printf( "%s(%s)", gc->prpl->name, gc->username);235 irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, text ); 334 236 else 335 acc_id = g_strdup( gc->prpl->name ); 336 337 irc_usermsg( gc->irc, "%s - %s", acc_id, msg ); 338 339 g_free( acc_id ); 237 irc_usermsg( gc->irc, "%s - %s", gc->prpl->name, text ); 238 239 g_free( text ); 340 240 } 341 241 … … 369 269 /* Also necessary when we're not away, at least for some of the 370 270 protocols. */ 371 proto_away( gc, u->away ); 372 373 if( strcmp( gc->prpl->name, "ICQ" ) == 0 ) 374 { 375 for( u = gc->irc->users; u; u = u->next ) 376 if( u->gc == gc ) 377 break; 378 379 if( u == NULL ) 380 serv_got_crap( gc, "\x02""***\x02"" BitlBee now supports ICQ server-side contact lists. " 381 "See \x02""help import_buddies\x02"" for more information." ); 382 } 271 bim_set_away( gc, u->away ); 383 272 } 384 273 … … 397 286 while( g_source_remove_by_user_data( (gpointer) a ) ); 398 287 a->reconnect = 0; 399 }400 401 void account_offline( struct gaim_connection *gc )402 {403 gc->wants_to_die = TRUE;404 signoff( gc );405 288 } 406 289 … … 412 295 413 296 serv_got_crap( gc, "Signing off.." ); 414 297 gc->flags |= OPT_LOGGING_OUT; 298 415 299 gaim_input_remove( gc->keepalive ); 416 300 gc->keepalive = 0; … … 510 394 else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] ) 511 395 { 512 u->host = g_strdup( gc->user->proto_opt[0] ); 396 char *colon; 397 398 if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) ) 399 u->host = g_strndup( gc->user->proto_opt[0], 400 colon - gc->user->proto_opt[0] ); 401 else 402 u->host = g_strdup( gc->user->proto_opt[0] ); 403 513 404 u->user = g_strdup( handle ); 514 405 … … 559 450 { 560 451 user_t *u = user_findhandle( gc, handle ); 561 char *name, buf[1024];562 452 563 453 if( !u ) return; 564 454 565 /* Convert all UTF-8 */ 566 if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 && 567 do_iconv( "UTF-8", set_getstr( gc->irc, "charset" ), realname, buf, 0, sizeof( buf ) ) != -1 ) 568 name = buf; 569 else 570 name = realname; 571 572 if( g_strcasecmp( u->realname, name ) != 0 ) 455 if( g_strcasecmp( u->realname, realname ) != 0 ) 573 456 { 574 457 if( u->realname != u->nick ) g_free( u->realname ); 575 458 576 u->realname = g_strdup( name );459 u->realname = g_strdup( realname ); 577 460 578 461 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( gc->irc, "display_namechanges" ) ) … … 584 467 /* prpl.c */ 585 468 586 void show_got_added( struct gaim_connection *gc, char *id, char *handle, const char *realname, const char *msg ) 587 { 588 return; 469 struct show_got_added_data 470 { 471 struct gaim_connection *gc; 472 char *handle; 473 }; 474 475 void show_got_added_no( gpointer w, struct show_got_added_data *data ) 476 { 477 g_free( data->handle ); 478 g_free( data ); 479 } 480 481 void show_got_added_yes( gpointer w, struct show_got_added_data *data ) 482 { 483 data->gc->prpl->add_buddy( data->gc, data->handle ); 484 add_buddy( data->gc, NULL, data->handle, data->handle ); 485 486 return show_got_added_no( w, data ); 487 } 488 489 void show_got_added( struct gaim_connection *gc, char *handle, const char *realname ) 490 { 491 struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 ); 492 char *s; 493 494 /* TODO: Make a setting for this! */ 495 if( user_findhandle( gc, handle ) != NULL ) 496 return; 497 498 s = g_strdup_printf( "The user %s is not in your buddy list yet. Do you want to add him/her now?", handle ); 499 500 data->gc = gc; 501 data->handle = g_strdup( handle ); 502 query_add( gc->irc, gc, s, show_got_added_yes, show_got_added_no, data ); 589 503 } 590 504 … … 616 530 return; 617 531 } 618 return; 532 /* Why did we have this here.... 533 return; */ 619 534 } 620 535 … … 680 595 irc_t *irc = gc->irc; 681 596 user_t *u; 682 char buf[8192];683 597 684 598 u = user_findhandle( gc, handle ); … … 722 636 strip_html( msg ); 723 637 724 if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 &&725 do_iconv( "UTF-8", set_getstr( irc, "charset" ), msg, buf, 0, 8192 ) != -1 )726 msg = buf;727 728 638 while( strlen( msg ) > 425 ) 729 639 { … … 822 732 struct conversation *c; 823 733 user_t *u; 824 char buf[8192];825 734 826 735 /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ … … 834 743 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) 835 744 strip_html( msg ); 836 837 if( g_strncasecmp( set_getstr( gc->irc, "charset" ), "none", 4 ) != 0 &&838 do_iconv( "UTF-8", set_getstr( gc->irc, "charset" ), msg, buf, 0, 8192 ) != -1 )839 msg = buf;840 745 841 746 if( c && u ) … … 956 861 957 862 return( 0 ); 958 }959 960 961 /* prefs.c */962 963 /* Necessary? */964 void build_block_list()965 {966 return;967 }968 969 void build_allow_list()970 {971 return;972 863 } 973 864 … … 1051 942 } 1052 943 1053 int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags ) 1054 { 1055 char buf[8192]; 1056 1057 if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && 1058 do_iconv( set_getstr( irc, "charset" ), "UTF-8", msg, buf, 0, 8192 ) != -1 ) 944 945 946 947 /* The plan is to not allow straight calls to prpl functions anymore, but do 948 them all from some wrappers. We'll start to define some down here: */ 949 950 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ) 951 { 952 char *buf = NULL; 953 int st; 954 955 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 956 { 957 buf = escape_html( msg ); 1059 958 msg = buf; 1060 1061 if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 1062 { 1063 char *html; 1064 1065 html = escape_html( msg ); 1066 strncpy( buf, html, 8192 ); 1067 g_free( html ); 1068 959 } 960 961 st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); 962 g_free( buf ); 963 964 return st; 965 } 966 967 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ) 968 { 969 char *buf = NULL; 970 int st; 971 972 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 973 { 974 buf = escape_html( msg ); 1069 975 msg = buf; 1070 976 } 1071 977 1072 return( ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags ) ); 1073 } 1074 1075 int serv_send_chat( irc_t *irc, struct gaim_connection *gc, int id, char *msg ) 1076 { 1077 char buf[8192]; 1078 1079 if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && 1080 do_iconv( set_getstr( irc, "charset" ), "UTF-8", msg, buf, 0, 8192 ) != -1 ) 1081 msg = buf; 1082 1083 if( gc->flags & OPT_CONN_HTML) { 1084 char * html = escape_html(msg); 1085 strncpy(buf, html, 8192); 1086 g_free(html); 1087 } 1088 1089 return( gc->prpl->chat_send( gc, id, msg ) ); 1090 } 1091 1092 /* Convert from one charset to another. 1093 1094 from_cs, to_cs: Source and destination charsets 1095 src, dst: Source and destination strings 1096 size: Size if src. 0 == use strlen(). strlen() is not reliable for UNICODE/UTF16 strings though. 1097 maxbuf: Maximum number of bytes to write to dst 1098 1099 Returns the number of bytes written to maxbuf or -1 on an error. 1100 */ 1101 signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ) 1102 { 1103 iconv_t cd; 1104 size_t res; 1105 size_t inbytesleft, outbytesleft; 1106 char *inbuf = src; 1107 char *outbuf = dst; 1108 1109 cd = iconv_open( to_cs, from_cs ); 1110 if( cd == (iconv_t) -1 ) 1111 return( -1 ); 1112 1113 inbytesleft = size ? size : strlen( src ); 1114 outbytesleft = maxbuf - 1; 1115 res = iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft ); 1116 *outbuf = '\0'; 1117 iconv_close( cd ); 1118 1119 if( res == (size_t) -1 ) 1120 return( -1 ); 978 st = gc->prpl->chat_send( gc, id, msg ); 979 g_free( buf ); 980 981 return st; 982 } 983 984 static char *bim_away_alias_find( GList *gcm, char *away ); 985 986 int bim_set_away( struct gaim_connection *gc, char *away ) 987 { 988 GList *m, *ms; 989 char *s; 990 991 if( !away ) away = ""; 992 ms = m = gc->prpl->away_states( gc ); 993 994 while( m ) 995 { 996 if( *away ) 997 { 998 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 999 break; 1000 } 1001 else 1002 { 1003 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1004 break; 1005 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1006 break; 1007 } 1008 m = m->next; 1009 } 1010 1011 if( m ) 1012 { 1013 gc->prpl->set_away( gc, m->data, *away ? away : NULL ); 1014 } 1121 1015 else 1122 return( outbuf - dst ); 1123 } 1124 1125 char *set_eval_charset( irc_t *irc, set_t *set, char *value ) 1126 { 1127 iconv_t cd; 1128 1129 if ( g_strncasecmp( value, "none", 4 ) == 0 ) 1130 return( value ); 1131 1132 cd = iconv_open( "UTF-8", value ); 1133 if( cd == (iconv_t) -1 ) 1134 return( NULL ); 1135 1136 iconv_close( cd ); 1137 return( value ); 1138 } 1016 { 1017 s = bim_away_alias_find( ms, away ); 1018 if( s ) 1019 { 1020 gc->prpl->set_away( gc, s, away ); 1021 if( set_getint( gc->irc, "debug" ) ) 1022 serv_got_crap( gc, "Setting away state to %s", s ); 1023 } 1024 else 1025 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); 1026 } 1027 1028 g_list_free( ms ); 1029 1030 return( 1 ); 1031 } 1032 1033 static char *bim_away_alias_list[8][5] = 1034 { 1035 { "Away from computer", "Away", "Extended away", NULL }, 1036 { "NA", "N/A", "Not available", NULL }, 1037 { "Busy", "Do not disturb", "DND", "Occupied", NULL }, 1038 { "Be right back", "BRB", NULL }, 1039 { "On the phone", "Phone", "On phone", NULL }, 1040 { "Out to lunch", "Lunch", "Food", NULL }, 1041 { "Invisible", "Hidden" }, 1042 { NULL } 1043 }; 1044 1045 static char *bim_away_alias_find( GList *gcm, char *away ) 1046 { 1047 GList *m; 1048 int i, j; 1049 1050 for( i = 0; *bim_away_alias_list[i]; i ++ ) 1051 { 1052 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1053 if( g_strncasecmp( away, bim_away_alias_list[i][j], strlen( bim_away_alias_list[i][j] ) ) == 0 ) 1054 break; 1055 1056 if( !bim_away_alias_list[i][j] ) /* If we reach the end, this row */ 1057 continue; /* is not what we want. Next! */ 1058 1059 /* Now find an entry in this row which exists in gcm */ 1060 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1061 { 1062 m = gcm; 1063 while( m ) 1064 { 1065 if( g_strcasecmp( bim_away_alias_list[i][j], m->data ) == 0 ) 1066 return( bim_away_alias_list[i][j] ); 1067 m = m->next; 1068 } 1069 } 1070 } 1071 1072 return( NULL ); 1073 } 1074 1075 void bim_add_allow( struct gaim_connection *gc, char *handle ) 1076 { 1077 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1078 { 1079 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); 1080 } 1081 1082 gc->prpl->add_permit( gc, handle ); 1083 } 1084 1085 void bim_rem_allow( struct gaim_connection *gc, char *handle ) 1086 { 1087 GSList *l; 1088 1089 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1090 { 1091 g_free( l->data ); 1092 gc->permit = g_slist_delete_link( gc->permit, l ); 1093 } 1094 1095 gc->prpl->rem_permit( gc, handle ); 1096 } 1097 1098 void bim_add_block( struct gaim_connection *gc, char *handle ) 1099 { 1100 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1101 { 1102 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); 1103 } 1104 1105 gc->prpl->add_deny( gc, handle ); 1106 } 1107 1108 void bim_rem_block( struct gaim_connection *gc, char *handle ) 1109 { 1110 GSList *l; 1111 1112 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1113 { 1114 g_free( l->data ); 1115 gc->deny = g_slist_delete_link( gc->deny, l ); 1116 } 1117 1118 gc->prpl->rem_deny( gc, handle ); 1119 } -
protocols/nogaim.h
ra15c097 r9779c18 15 15 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> 16 16 * (and possibly other members of the Gaim team) 17 * Copyright 2002-2004 Wilmer van der Gaast < lintux@lintux.cx>17 * Copyright 2002-2004 Wilmer van der Gaast <wilmer@gaast.net> 18 18 */ 19 19 … … 52 52 #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ 53 53 54 #define PERMIT_ALL 1 55 #define PERMIT_NONE 2 56 #define PERMIT_SOME 3 57 #define DENY_SOME 4 58 59 #define WEBSITE "http://www.bitlee.org/" 54 #define WEBSITE "http://www.bitlbee.org/" 60 55 #define IM_FLAG_AWAY 0x0020 61 #define OPT_CONN_HTML 0x0000000162 #define OPT_LOGGED_IN 0x0001000063 56 #define GAIM_AWAY_CUSTOM "Custom" 64 57 65 #define GAIM_LOGO 0 66 #define GAIM_ERROR 1 67 #define GAIM_WARNING 2 68 #define GAIM_INFO 3 58 #define OPT_CONN_HTML 0x00000001 59 #define OPT_LOGGED_IN 0x00010000 60 #define OPT_LOGGING_OUT 0x00020000 69 61 70 62 /* ok. now the fun begins. first we create a connection structure */ 71 struct gaim_connection { 72 /* we need to do either oscar or TOC */ 73 /* we make this as an int in case if we want to add more protocols later */ 63 struct gaim_connection 64 { 74 65 struct prpl *prpl; 75 66 guint32 flags; 76 67 68 /* each connection then can have its own protocol-specific data */ 69 void *proto_data; 70 77 71 /* all connections need an input watcher */ 78 72 int inpa; 73 guint keepalive; 79 74 80 75 /* buddy list stuff. there is still a global groups for the buddy list, but … … 84 79 int permdeny; 85 80 86 /* all connections need a list of chats, even if they don't have chat */87 GSList *buddy_chats;88 89 /* each connection then can have its own protocol-specific data */90 void *proto_data;91 92 81 struct aim_user *user; 93 82 … … 95 84 char displayname[128]; 96 85 char password[32]; 97 guint keepalive;98 /* stuff needed for per-connection idle times */99 guint idle_timer;100 time_t login_time;101 time_t lastsent;102 int is_idle;103 86 104 87 char *away; 105 int is_auto_away;106 88 107 89 int evil; … … 110 92 /* BitlBee */ 111 93 irc_t *irc; 112 int lstitems; /* added for msnP8 */113 94 114 95 struct conversation *conversations; … … 164 145 const char *name; 165 146 166 /* for ICQ and Yahoo, who have off/on per-conversation options */167 /* char *checkbox; this should be per-connection */168 169 GList *(* away_states)(struct gaim_connection *gc);170 GList *(* actions)();171 void (* do_action)(struct gaim_connection *, char *);172 /* user_opts returns a GList* of g_malloc'd struct proto_user_opts */173 GList *(* user_opts)();174 GList *(* chat_info)(struct gaim_connection *);175 176 /* all the server-related functions */177 178 /* a lot of these (like get_dir) are protocol-dependent and should be removed. ones like179 * set_dir (which is also protocol-dependent) can stay though because there's a dialog180 * (i.e. the prpl says you can set your dir info, the ui shows a dialog and needs to call181 * set_dir in order to set it) */182 183 147 void (* login) (struct aim_user *); 148 void (* keepalive) (struct gaim_connection *); 184 149 void (* close) (struct gaim_connection *); 150 185 151 int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away); 186 int (* send_typing) (struct gaim_connection *, char *who, int typing);187 void (* set_info) (struct gaim_connection *, char *info);188 void (* get_info) (struct gaim_connection *, char *who);189 152 void (* set_away) (struct gaim_connection *, char *state, char *message); 190 153 void (* get_away) (struct gaim_connection *, char *who); 191 void (* set_idle) (struct gaim_connection *, int idletime); 154 int (* send_typing) (struct gaim_connection *, char *who, int typing); 155 192 156 void (* add_buddy) (struct gaim_connection *, char *name); 157 void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); 193 158 void (* remove_buddy) (struct gaim_connection *, char *name, char *group); 194 159 void (* add_permit) (struct gaim_connection *, char *name); … … 197 162 void (* rem_deny) (struct gaim_connection *, char *name); 198 163 void (* set_permit_deny)(struct gaim_connection *); 164 165 void (* set_info) (struct gaim_connection *, char *info); 166 void (* get_info) (struct gaim_connection *, char *who); 167 void (* alias_buddy) (struct gaim_connection *, char *who); /* save/store buddy's alias on server list/roster */ 168 169 /* Group chat stuff. */ 199 170 void (* join_chat) (struct gaim_connection *, GList *data); 200 171 void (* chat_invite) (struct gaim_connection *, int id, char *who, char *message); 201 172 void (* chat_leave) (struct gaim_connection *, int id); 202 void (* chat_whisper) (struct gaim_connection *, int id, char *who, char *message);203 173 int (* chat_send) (struct gaim_connection *, int id, char *message); 204 174 int (* chat_open) (struct gaim_connection *, char *who); 205 void (* keepalive) (struct gaim_connection *); 206 207 /* get "chat buddy" info and away message */ 208 void (* get_cb_info) (struct gaim_connection *, int, char *who); 209 void (* get_cb_away) (struct gaim_connection *, int, char *who); 210 211 /* save/store buddy's alias on server list/roster */ 212 void (* alias_buddy) (struct gaim_connection *, char *who); 213 214 /* change a buddy's group on a server list/roster */ 215 void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); 216 217 void (* buddy_free) (struct buddy *); 218 175 176 /* DIE! */ 219 177 char *(* get_status_string) (struct gaim_connection *gc, int stat); 220 178 179 GList *(* away_states)(struct gaim_connection *gc); 180 181 /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */ 221 182 int (* cmp_buddynames) (const char *who1, const char *who2); 222 183 }; … … 235 196 236 197 /* nogaim.c */ 237 int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags); 238 int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg ); 239 240 G_MODULE_EXPORT signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ); 241 char *set_eval_charset( irc_t *irc, set_t *set, char *value ); 198 int bim_set_away( struct gaim_connection *gc, char *away ); 199 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ); 200 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ); 201 202 void bim_add_allow( struct gaim_connection *gc, char *handle ); 203 void bim_rem_allow( struct gaim_connection *gc, char *handle ); 204 void bim_add_block( struct gaim_connection *gc, char *handle ); 205 void bim_rem_block( struct gaim_connection *gc, char *handle ); 242 206 243 207 void nogaim_init(); 244 int proto_away( struct gaim_connection *gc, char *away );245 208 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); 246 209 … … 254 217 G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg ); 255 218 G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg ); 256 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) ;219 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 257 220 G_MODULE_EXPORT void account_online( struct gaim_connection *gc ); 258 G_MODULE_EXPORT void account_offline( struct gaim_connection *gc );259 221 G_MODULE_EXPORT void signoff( struct gaim_connection *gc ); 260 222 … … 264 226 265 227 /* list.c */ 266 G_MODULE_EXPORT int bud_list_cache_exists( struct gaim_connection *gc );267 G_MODULE_EXPORT void do_import( struct gaim_connection *gc, void *null );268 228 G_MODULE_EXPORT void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ); 269 229 G_MODULE_EXPORT struct buddy *find_buddy( struct gaim_connection *gc, char *handle ); 270 G_MODULE_EXPORT void do_export( struct gaim_connection *gc );271 230 G_MODULE_EXPORT void signoff_blocked( struct gaim_connection *gc ); 272 231 … … 278 237 279 238 /* prpl.c */ 280 G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char * id, char *handle, const char *realname, const char *msg);239 G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *handle, const char *realname ); 281 240 282 241 /* server.c */ … … 289 248 G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id ); 290 249 291 /* util.c */292 G_MODULE_EXPORT void strip_linefeed( gchar *text );293 G_MODULE_EXPORT char *add_cr( char *text );294 G_MODULE_EXPORT char *tobase64( const char *text );295 G_MODULE_EXPORT char *normalize( const char *s );296 G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec );297 G_MODULE_EXPORT void strip_html( char *msg );298 G_MODULE_EXPORT char *escape_html( const char *html );299 G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value);300 G_MODULE_EXPORT char *ipv6_wrap( char *src );301 G_MODULE_EXPORT char *ipv6_unwrap( char *src );302 303 /* prefs.c */304 G_MODULE_EXPORT void build_block_list();305 G_MODULE_EXPORT void build_allow_list();306 307 250 struct conversation *conv_findchannel( char *channel ); 308 251 309 310 252 #endif -
protocols/oscar/aim.h
ra15c097 r9779c18 728 728 }; 729 729 730 #define AIM_CHATFLAGS_NOREFLECT 0x0001 731 #define AIM_CHATFLAGS_AWAY 0x0002 730 #define AIM_CHATFLAGS_NOREFLECT 0x0001 731 #define AIM_CHATFLAGS_AWAY 0x0002 732 #define AIM_CHATFLAGS_UNICODE 0x0004 733 #define AIM_CHATFLAGS_ISO_8859_1 0x0008 734 732 735 int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen); 733 736 int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance); -
protocols/oscar/chat.c
ra15c097 r9779c18 159 159 if (flags & AIM_CHATFLAGS_AWAY) 160 160 aim_addtlvtochain_noval(&otl, 0x0007); 161 161 162 /* [WvG] This wasn't there originally, but we really should send 163 the right charset flags, as we also do with normal 164 messages. Hope this will work. :-) */ 165 /* 166 if (flags & AIM_CHATFLAGS_UNICODE) 167 aimbs_put16(&fr->data, 0x0002); 168 else if (flags & AIM_CHATFLAGS_ISO_8859_1) 169 aimbs_put16(&fr->data, 0x0003); 170 else 171 aimbs_put16(&fr->data, 0x0000); 172 173 aimbs_put16(&fr->data, 0x0000); 174 */ 175 162 176 /* 163 177 * SubTLV: Type 1: Message -
protocols/oscar/im.c
ra15c097 r9779c18 1469 1469 case 0x9c: /* ICQ 5 seems to send this */ 1470 1470 aim_send_im_ch2_statusmessage(sess, userinfo->sn, args->cookie, 1471 gc->away , sess->aim_icq_state, dc);1471 gc->away ? gc->away : "", sess->aim_icq_state, dc); 1472 1472 break; 1473 1473 -
protocols/oscar/oscar.c
ra15c097 r9779c18 2 2 * gaim 3 3 * 4 * Some code copyright (C) 2002-2006, Jelmer Vernooij <jelmer@samba.org> 5 * and the BitlBee team. 4 6 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> 5 7 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> … … 136 138 int i, j; 137 139 char *x = strchr(name, '-'); 138 if (!x) return NULL;140 if (!x) return g_strdup(name); 139 141 x = strchr(++x, '-'); 140 if (!x) return NULL;142 if (!x) return g_strdup(name); 141 143 tmp = g_strdup(++x); 142 144 … … 383 385 if (g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.icq.com") != 0 && 384 386 g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.oscar.aol.com") != 0) { 385 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails." );387 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",user->proto_opt[USEROPT_AUTH]); 386 388 } 387 389 … … 1119 1121 aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); 1120 1122 // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); 1121 show_got_added(data->gc, NULL, uin, NULL, NULL); 1123 if(find_buddy(data->gc, uin) == NULL) 1124 show_got_added(data->gc, uin, NULL); 1122 1125 1123 1126 g_free(uin); … … 2057 2060 name = g_strdup(normalize(curitem->name)); 2058 2061 gc->permit = g_slist_append(gc->permit, name); 2059 build_allow_list();2060 2062 tmp++; 2061 2063 } … … 2071 2073 name = g_strdup(normalize(curitem->name)); 2072 2074 gc->deny = g_slist_append(gc->deny, name); 2073 build_block_list();2074 2075 tmp++; 2075 2076 } … … 2277 2278 tm.tm_mday = (int)info->birthday; 2278 2279 tm.tm_mon = (int)info->birthmonth-1; 2279 tm.tm_year = (int)info->birthyear -1900;2280 tm.tm_year = (int)info->birthyear%100; 2280 2281 strftime(date, sizeof(date), "%Y-%m-%d", &tm); 2281 2282 info_string_append(str, "\n", _("Birthday"), date); … … 2501 2502 int ret; 2502 2503 guint8 len = strlen(message); 2504 guint16 flags; 2503 2505 char *s; 2504 2506 … … 2509 2511 if (*s & 128) 2510 2512 break; 2511 2513 2514 flags = AIM_CHATFLAGS_NOREFLECT; 2515 2512 2516 /* Message contains high ASCII chars, time for some translation! */ 2513 2517 if (*s) { … … 2516 2520 If we can't, fall back to UTF16. */ 2517 2521 if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { 2522 flags |= AIM_CHATFLAGS_ISO_8859_1; 2518 2523 len = ret; 2519 2524 } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) { 2525 flags |= AIM_CHATFLAGS_UNICODE; 2520 2526 len = ret; 2521 2527 } else { … … 2528 2534 } 2529 2535 2530 ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len);2536 ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len); 2531 2537 2532 2538 if (s != message) { … … 2601 2607 int ret; 2602 2608 static int chat_id = 0; 2603 char * chatname = g_new0(char, strlen(gc->username)+4);2604 2605 g_snprintf(chatname, strlen(gc->username) + 4,"%s%d", gc->username, chat_id++);2609 char * chatname; 2610 2611 chatname = g_strdup_printf("%s%d", gc->username, chat_id++); 2606 2612 2607 2613 ret = oscar_chat_join(gc, chatname); -
protocols/oscar/oscar_util.c
ra15c097 r9779c18 109 109 110 110 curPtr = sn; 111 while ( (*curPtr) != (char) NULL) {111 while ( (*curPtr) != (char) '\0') { 112 112 if ((*curPtr) != ' ') 113 113 i++; … … 140 140 curPtr1 = sn1; 141 141 curPtr2 = sn2; 142 while ( (*curPtr1 != (char) NULL) && (*curPtr2 != (char) NULL) ) {142 while ( (*curPtr1 != (char) '\0') && (*curPtr2 != (char) '\0') ) { 143 143 if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') ) { 144 144 if (*curPtr1 == ' ') -
protocols/oscar/service.c
ra15c097 r9779c18 733 733 int tlvlen; 734 734 735 data = AIM_ICQ_STATE_ WEBAWARE | AIM_ICQ_STATE_HIDEIP | status; /* yay for error checking ;^) */735 data = AIM_ICQ_STATE_HIDEIP | status; /* yay for error checking ;^) */ 736 736 737 737 tlvlen = aim_addtlvtochain32(&tl, 0x0006, data); … … 881 881 #endif 882 882 883 /* len can't be 0 here anyway... 883 884 } else if ((offset == 0x00001000) && (len == 0x00000000)) { 884 885 … … 887 888 aimbs_put32(&fr->data, 0xe9800998); 888 889 aimbs_put32(&fr->data, 0xecf8427e); 889 890 */ 890 891 } else 891 892 do_error_dialog(sess->aux_data, "WARNING: unknown hash request", "Gaim"); -
protocols/ssl_nss.c
ra15c097 r9779c18 122 122 if( source == -1 ) 123 123 goto ssl_connected_failure; 124 125 124 126 127 125 /* Until we find out how to handle non-blocking I/O with NSS... */ 126 sock_make_blocking( conn->fd ); 127 128 128 conn->prfd = SSL_ImportFD(NULL, PR_ImportTCPSocket(source)); 129 129 SSL_OptionSet(conn->prfd, SSL_SECURITY, PR_TRUE); … … 181 181 return( ((struct scd*)conn)->fd ); 182 182 } 183 184 GaimInputCondition ssl_getdirection( void *conn ) 185 { 186 /* Just in case someone calls us, let's return the most likely case: */ 187 return GAIM_INPUT_READ; 188 } -
protocols/yahoo/yahoo.c
ra15c097 r9779c18 227 227 else if( g_strcasecmp( state, GAIM_AWAY_CUSTOM ) == 0 ) 228 228 { 229 if (gc->is_idle) 230 yd->current_status = YAHOO_STATUS_IDLE; 231 else 232 yd->current_status = YAHOO_STATUS_AVAILABLE; 229 yd->current_status = YAHOO_STATUS_AVAILABLE; 233 230 234 231 gc->away = NULL; 235 232 } 236 233 } 237 else if( gc->is_idle )238 yd->current_status = YAHOO_STATUS_IDLE;239 234 else 240 235 yd->current_status = YAHOO_STATUS_AVAILABLE; … … 615 610 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 616 611 617 serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, 0, 612 serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, 613 ( stat == YAHOO_STATUS_IDLE ) ? away : 0, 618 614 ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 ); 619 615 } -
query.c
ra15c097 r9779c18 140 140 if( ans ) 141 141 { 142 serv_got_crap( q->gc, "Accepted: %s", q->question ); 142 143 q->yes( NULL, q->data ); 143 serv_got_crap( q->gc, "Accepted: %s", q->question );144 144 } 145 145 else 146 146 { 147 serv_got_crap( q->gc, "Rejected: %s", q->question ); 147 148 q->no( NULL, q->data ); 148 serv_got_crap( q->gc, "Rejected: %s", q->question );149 149 } 150 150 q->data = NULL; -
root_commands.c
ra15c097 r9779c18 57 57 s --; 58 58 } 59 else 60 { 61 break; 62 } 63 } 64 else if( *s == '\\' && ( ( !q && s[1] ) || ( q && q == s[1] ) ) ) 65 { 66 char *cpy; 67 68 for( cpy = s; *cpy; cpy ++ ) 69 cpy[0] = cpy[1]; 59 70 } 60 71 else if( *s == q ) … … 245 256 int i = 0; 246 257 258 if( strchr( irc->umode, 'b' ) ) 259 irc_usermsg( irc, "Account list:" ); 260 247 261 for( a = irc->accounts; a; a = a->next ) 248 262 { … … 347 361 { 348 362 account_t *a; 363 int add_for_real = 1; 364 365 if( g_strcasecmp( cmd[1], "-tmp" ) == 0 ) 366 { 367 add_for_real = 0; 368 cmd ++; /* So evil... :-D */ 369 } 349 370 350 371 if( !( a = account_get( irc, cmd[1] ) ) ) … … 376 397 } 377 398 } 378 a->gc->prpl->add_buddy( a->gc, cmd[2] ); 399 400 /* By making this optional, you can talk to people without having to 401 add them to your *real* (server-side) contact list. */ 402 if( add_for_real ) 403 a->gc->prpl->add_buddy( a->gc, cmd[2] ); 404 379 405 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); 380 406 … … 492 518 format = "%s\t%s"; 493 519 else 494 format = "%-32.32 %-16.16s";520 format = "%-32.32s %-16.16s"; 495 521 496 522 irc_usermsg( irc, format, "Handle", "Nickname" ); … … 532 558 else 533 559 { 534 gc->prpl->rem_permit( gc, cmd[2] );535 gc->prpl->add_deny( gc, cmd[2] );536 irc_usermsg( irc, "Buddy `%s' moved from your permit- to your deny-list", cmd[2] );560 bim_rem_allow( gc, cmd[2] ); 561 bim_add_block( gc, cmd[2] ); 562 irc_usermsg( irc, "Buddy `%s' moved from your allow- to your block-list", cmd[2] ); 537 563 } 538 564 } … … 551 577 format = "%s\t%s"; 552 578 else 553 format = "%-32.32 %-16.16s";579 format = "%-32.32s %-16.16s"; 554 580 555 581 irc_usermsg( irc, format, "Handle", "Nickname" ); … … 591 617 else 592 618 { 593 gc->prpl->rem_deny( gc, cmd[2] );594 gc->prpl->add_permit( gc, cmd[2] );595 596 irc_usermsg( irc, "Buddy `%s' moved from your deny- to your permit-list", cmd[2] );619 bim_rem_block( gc, cmd[2] ); 620 bim_add_allow( gc, cmd[2] ); 621 622 irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); 597 623 } 598 624 } … … 753 779 else 754 780 { 755 char utf8[1024];756 757 781 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 758 782 759 if( g_strncasecmp( set_getstr( irc, "charset" ), "none", 4 ) != 0 && 760 do_iconv( set_getstr( irc, "charset" ), "UTF-8", cmd[2], utf8, 0, 1024 ) != -1 ) 761 a->gc->prpl->set_info( a->gc, utf8 ); 762 else 763 a->gc->prpl->set_info( a->gc, cmd[2] ); 783 a->gc->prpl->set_info( a->gc, cmd[2] ); 764 784 } 765 785 } -
set.c
ra15c097 r9779c18 150 150 if( s ) 151 151 { 152 t->next = s->next; 152 if( t ) 153 t->next = s->next; 154 else 155 irc->set = s->next; 156 153 157 g_free( s->key ); 154 158 if( s->value ) g_free( s->value ); -
user.c
ra15c097 r9779c18 168 168 u->nick = g_strdup( newnick ); 169 169 if( !u->user ) u->user = u->nick; 170 if( !u->host ) u-> user = u->host;171 if( !u->realname ) u-> user = u->realname;170 if( !u->host ) u->host = u->nick; 171 if( !u->realname ) u->realname = u->nick; 172 172 173 173 /* Remove the old reference to this user from the hash and create a -
util.c
ra15c097 r9779c18 445 445 } 446 446 #endif 447 448 /* Convert from one charset to another. 449 450 from_cs, to_cs: Source and destination charsets 451 src, dst: Source and destination strings 452 size: Size if src. 0 == use strlen(). strlen() is not reliable for UNICODE/UTF16 strings though. 453 maxbuf: Maximum number of bytes to write to dst 454 455 Returns the number of bytes written to maxbuf or -1 on an error. 456 */ 457 signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ) 458 { 459 GIConv cd; 460 size_t res; 461 size_t inbytesleft, outbytesleft; 462 char *inbuf = src; 463 char *outbuf = dst; 464 465 cd = g_iconv_open( to_cs, from_cs ); 466 if( cd == (GIConv) -1 ) 467 return( -1 ); 468 469 inbytesleft = size ? size : strlen( src ); 470 outbytesleft = maxbuf - 1; 471 res = g_iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft ); 472 *outbuf = '\0'; 473 g_iconv_close( cd ); 474 475 if( res == (size_t) -1 ) 476 return( -1 ); 477 else 478 return( outbuf - dst ); 479 } 480 481 char *set_eval_charset( irc_t *irc, set_t *set, char *value ) 482 { 483 GIConv cd; 484 485 if ( g_strncasecmp( value, "none", 4 ) == 0 ) 486 return( value ); 487 488 cd = g_iconv_open( "UTF-8", value ); 489 if( cd == (GIConv) -1 ) 490 return( NULL ); 491 492 g_iconv_close( cd ); 493 return( value ); 494 } -
utils/bitlbeed.c
ra15c097 r9779c18 6 6 * (without access to /etc/inetd.conf or whatever) * 7 7 * * 8 * Copyright 2002-2004 Wilmer van der Gaast < lintux@debian.org>*8 * Copyright 2002-2004 Wilmer van der Gaast <wilmer@gaast.net> * 9 9 * * 10 10 * Licensed under the GNU General Public License *
Note: See TracChangeset
for help on using the changeset viewer.