Changes in irc.c [f73b969:fc630f9]
Legend:
- Unmodified
- Added
- Removed
-
irc.c
rf73b969 rfc630f9 199 199 } 200 200 201 static gboolean irc_free_ userhash( gpointer key, gpointer value, gpointer data )201 static gboolean irc_free_hashkey( gpointer key, gpointer value, gpointer data ) 202 202 { 203 203 g_free( key ); … … 232 232 irc_connection_list = g_slist_remove( irc_connection_list, irc ); 233 233 234 for (account = irc->accounts; account; account = account->next) 235 if (account->gc) 234 for (account = irc->accounts; account; account = account->next) { 235 if (account->gc) { 236 account->gc->wants_to_die = TRUE; 236 237 signoff(account->gc); 238 } else if (account->reconnect) { 239 cancel_auto_reconnect(account); 240 } 241 } 237 242 238 243 g_free(irc->sendbuffer); … … 282 287 } 283 288 284 g_hash_table_foreach_remove(irc->userhash, irc_free_ userhash, NULL);289 g_hash_table_foreach_remove(irc->userhash, irc_free_hashkey, NULL); 285 290 g_hash_table_destroy(irc->userhash); 286 291 287 g_hash_table_foreach_remove(irc->watches, irc_free_ userhash, NULL);292 g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL); 288 293 g_hash_table_destroy(irc->watches); 289 294 … … 343 348 void irc_process( irc_t *irc ) 344 349 { 345 char **lines, *temp, **cmd ;350 char **lines, *temp, **cmd, *cs; 346 351 int i; 347 352 … … 352 357 for( i = 0; *lines[i] != '\0'; i ++ ) 353 358 { 359 char conv[IRC_MAX_LINE+1]; 360 361 /* [WvG] Because irc_tokenize splits at every newline, the lines[] list 362 should end with an empty string. This is why this actually works. 363 Took me a while to figure out, Maurits. :-P */ 354 364 if( lines[i+1] == NULL ) 355 365 { … … 359 369 i ++; 360 370 break; 361 } 371 } 372 373 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 374 { 375 conv[IRC_MAX_LINE] = 0; 376 if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) != -1 ) 377 lines[i] = conv; 378 } 362 379 363 380 if( ( cmd = irc_parse_line( lines[i] ) ) == NULL ) … … 385 402 } 386 403 404 /* Splits a long string into separate lines. The array is NULL-terminated and, unless the string 405 contains an incomplete line at the end, ends with an empty string. */ 387 406 char **irc_tokenize( char *buffer ) 388 407 { … … 425 444 } 426 445 446 /* Split an IRC-style line into little parts/arguments. */ 427 447 char **irc_parse_line( char *line ) 428 448 { … … 484 504 } 485 505 506 /* Converts such an array back into a command string. Mainly used for the IPC code right now. */ 486 507 char *irc_build_line( char **cmd ) 487 508 { … … 536 557 537 558 u = user_find( irc, irc->mynick ); 538 i f( u ) is_private = u->is_private;559 is_private = u->is_private; 539 560 540 561 va_start( params, format ); … … 560 581 { 561 582 int size; 562 char line[IRC_MAX_LINE ];563 583 char line[IRC_MAX_LINE+1], *cs; 584 564 585 if( irc->quit ) 565 586 return; 566 567 g_vsnprintf( line, IRC_MAX_LINE - 3, format, params ); 568 587 588 line[IRC_MAX_LINE] = 0; 589 g_vsnprintf( line, IRC_MAX_LINE - 2, format, params ); 590 569 591 strip_newlines( line ); 592 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 593 { 594 char conv[IRC_MAX_LINE+1]; 595 596 conv[IRC_MAX_LINE] = 0; 597 if( do_iconv( "UTF-8", cs, line, conv, 0, IRC_MAX_LINE - 2 ) != -1 ) 598 strcpy( line, conv ); 599 } 570 600 strcat( line, "\r\n" ); 571 601 572 602 if( irc->sendbuffer != NULL ) { 573 603 size = strlen( irc->sendbuffer ) + strlen( line ); … … 800 830 irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title ); 801 831 else 802 irc_reply( irc, 331, "%s :No topic for this channel" );832 irc_reply( irc, 331, "%s :No topic for this channel", channel ); 803 833 } 804 834 } … … 856 886 if( g_hash_table_lookup( irc->watches, nick ) ) 857 887 { 858 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged online" );888 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged online" ); 859 889 } 860 890 g_free( nick ); … … 881 911 if( g_hash_table_lookup( irc->watches, nick ) ) 882 912 { 883 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged offline" );913 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged offline" ); 884 914 } 885 915 g_free( nick ); … … 981 1011 else if( c && c->gc && c->gc->prpl ) 982 1012 { 983 return( serv_send_chat( irc,c->gc, c->id, s ) );1013 return( bim_chat_msg( c->gc, c->id, s ) ); 984 1014 } 985 1015 … … 991 1021 user_t *u = data; 992 1022 1023 /* Shouldn't happen, but just to be sure. */ 1024 if( u->sendbuf_len < 2 ) 1025 return FALSE; 1026 993 1027 u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */ 994 serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );1028 bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags ); 995 1029 996 1030 g_free( u->sendbuf ); … … 1000 1034 u->sendbuf_flags = 0; 1001 1035 1002 return ( FALSE );1036 return FALSE; 1003 1037 } 1004 1038 … … 1013 1047 if( u->sendbuf_len > 0 && u->sendbuf_flags != flags) 1014 1048 { 1015 / /Flush the buffer1049 /* Flush the buffer */ 1016 1050 g_source_remove( u->sendbuf_timer ); 1017 1051 buddy_send_handler_delayed( u ); … … 1021 1055 { 1022 1056 u->sendbuf_len = strlen( msg ) + 2; 1023 u->sendbuf = g_new (char, u->sendbuf_len );1057 u->sendbuf = g_new( char, u->sendbuf_len ); 1024 1058 u->sendbuf[0] = 0; 1025 1059 u->sendbuf_flags = flags; … … 1028 1062 { 1029 1063 u->sendbuf_len += strlen( msg ) + 1; 1030 u->sendbuf = g_renew 1064 u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len ); 1031 1065 } 1032 1066 … … 1044 1078 else 1045 1079 { 1046 serv_send_im( irc, u, msg, flags );1080 bim_buddy_msg( u->gc, u->handle, msg, flags ); 1047 1081 } 1048 1082 }
Note: See TracChangeset
for help on using the changeset viewer.