- Timestamp:
- 2006-06-03T20:20:43Z (18 years ago)
- Branches:
- master
- Children:
- 5973412
- Parents:
- a15c097 (diff), fb62f81f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.