Changes in irc.c [b0a33a5:5b52a48]
Legend:
- Unmodified
- Added
- Removed
-
irc.c
rb0a33a5 r5b52a48 33 33 GSList *irc_connection_list = NULL; 34 34 35 static char *passchange (irc_t *irc, void *set, char *value) 36 { 37 irc_setpass (irc, value); 38 return (NULL); 35 static char *passchange( irc_t *irc, void *set, char *value ) 36 { 37 irc_setpass( irc, value ); 38 irc_usermsg( irc, "Password successfully changed" ); 39 return NULL; 39 40 } 40 41 … … 46 47 char buf[128]; 47 48 #ifdef IPV6 48 struct sockaddr_in6 sock6[1]; 49 unsigned int i6; 49 struct sockaddr_in6 sock[1]; 50 #else 51 struct sockaddr_in sock[1]; 50 52 #endif 51 struct sockaddr_in sock[1];52 53 53 54 irc = g_new0( irc_t, 1 ); … … 69 70 70 71 i = sizeof( *sock ); 71 #ifdef IPV672 i6 = sizeof( *sock6 );73 #endif74 72 75 73 if( global.conf->hostname ) 76 74 irc->myhost = g_strdup( global.conf->hostname ); 77 75 #ifdef IPV6 78 else if( getsockname( irc->fd, (struct sockaddr*) sock 6, &i6 ) == 0 && sock6->sin6_family == AF_INET6)79 { 80 if( ( peer = gethostbyaddr( (char*) &sock 6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6) ) )76 else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) 77 { 78 if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) 81 79 irc->myhost = g_strdup( peer->h_name ); 82 else if( inet_ntop( AF_INET 6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )80 else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) 83 81 irc->myhost = g_strdup( ipv6_unwrap( buf ) ); 84 82 } 83 #else 84 else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) 85 { 86 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) 87 irc->myhost = g_strdup( peer->h_name ); 88 else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) 89 irc->myhost = g_strdup( buf ); 90 } 85 91 #endif 86 else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET )87 {88 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) )89 irc->myhost = g_strdup( peer->h_name );90 else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )91 irc->myhost = g_strdup( buf );92 }93 92 94 93 i = sizeof( *sock ); 95 94 #ifdef IPV6 96 i6 = sizeof( *sock6 ); 97 if( getpeername( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 ) 98 { 99 if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) ) 95 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) 96 { 97 if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) 100 98 irc->host = g_strdup( peer->h_name ); 101 else if( inet_ntop( AF_INET 6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )99 else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) 102 100 irc->host = g_strdup( ipv6_unwrap( buf ) ); 103 101 } 104 else 102 #else 103 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) 104 { 105 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) 106 irc->host = g_strdup( peer->h_name ); 107 else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) 108 irc->host = g_strdup( buf ); 109 } 105 110 #endif 106 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET )107 {108 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) )109 irc->host = g_strdup( peer->h_name );110 else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )111 irc->host = g_strdup( buf );112 }113 111 114 112 /* Rare, but possible. */ … … 123 121 irc_connection_list = g_slist_append( irc_connection_list, irc ); 124 122 125 set_add( irc, "away_devoice", "true", set_eval_away_devoice);126 set_add( irc, "auto_connect", "true", set_eval_bool);127 set_add( irc, "auto_reconnect", "false", set_eval_bool);128 set_add( irc, "auto_reconnect_delay", "300", set_eval_int);129 set_add( irc, "buddy_sendbuffer", "false", set_eval_bool);130 set_add( irc, "buddy_sendbuffer_delay", "200", set_eval_int);131 set_add( irc, "charset", "iso8859-1", set_eval_charset);132 set_add( irc, "debug", "false", set_eval_bool);133 set_add( irc, "default_target", "root", NULL);134 set_add( irc, "display_namechanges", "false", set_eval_bool);135 set_add( irc, "handle_unknown", "root", NULL);136 set_add( irc, "lcnicks", "true", set_eval_bool);137 set_add( irc, "ops", "both", set_eval_ops);138 set_add( irc, "private", "true", set_eval_bool);139 set_add( irc, "query_order", "lifo", NULL);140 set_add( irc, "save_on_quit", "true", set_eval_bool);141 set_add( irc, "strip_html", "true", NULL);142 set_add( irc, "to_char", ": ", set_eval_to_char);143 set_add( irc, "typing_notice", "false", set_eval_bool);144 set_add( irc, "password", NULL, passchange);123 set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); 124 set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 125 set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); 126 set_add( &irc->set, "auto_reconnect_delay", "300", set_eval_int, irc ); 127 set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); 128 set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 129 set_add( &irc->set, "charset", "iso8859-1", set_eval_charset, irc ); 130 set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 131 set_add( &irc->set, "default_target", "root", NULL, irc ); 132 set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 133 set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 134 set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 135 set_add( &irc->set, "ops", "both", set_eval_ops, irc ); 136 set_add( &irc->set, "password", NULL, passchange, irc ); 137 set_add( &irc->set, "private", "true", set_eval_bool, irc ); 138 set_add( &irc->set, "query_order", "lifo", NULL, irc ); 139 set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc ); 140 set_add( &irc->set, "strip_html", "true", NULL, irc ); 141 set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 142 set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); 145 143 146 144 conf_loaddefaults( irc ); … … 206 204 void irc_free(irc_t * irc) 207 205 { 208 account_t *account , *accounttmp;206 account_t *account; 209 207 user_t *user, *usertmp; 210 nick_t *nick, *nicktmp;211 208 help_t *helpnode, *helpnodetmp; 212 set_t *setnode, *setnodetmp;213 209 214 210 log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd ); 215 211 216 if( irc->status & USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )212 if( irc->status & USTATUS_IDENTIFIED && set_getint( &irc->set, "save_on_quit" ) ) 217 213 if( storage_save( irc, TRUE ) != STORAGE_OK ) 218 214 irc_usermsg( irc, "Error while saving settings!" ); … … 254 250 query_del(irc, irc->queries); 255 251 256 if (irc->accounts != NULL) { 257 account = irc->accounts; 258 while (account != NULL) { 259 g_free(account->user); 260 g_free(account->pass); 261 g_free(account->server); 262 accounttmp = account; 263 account = account->next; 264 g_free(accounttmp); 265 } 266 } 252 while (irc->accounts) 253 account_del(irc, irc->accounts); 254 255 while (irc->set) 256 set_del(&irc->set, irc->set->key); 267 257 268 258 if (irc->users != NULL) { … … 289 279 g_hash_table_destroy(irc->watches); 290 280 291 if (irc->nicks != NULL) {292 nick = irc->nicks;293 while (nick != NULL) {294 g_free(nick->nick);295 g_free(nick->handle);296 297 nicktmp = nick;298 nick = nick->next;299 g_free(nicktmp);300 }301 }302 281 if (irc->help != NULL) { 303 282 helpnode = irc->help; … … 310 289 } 311 290 } 312 if (irc->set != NULL) {313 setnode = irc->set;314 while (setnode != NULL) {315 g_free(setnode->key);316 g_free(setnode->def);317 g_free(setnode->value);318 319 setnodetmp = setnode;320 setnode = setnode->next;321 g_free(setnodetmp);322 }323 }324 291 g_free(irc); 325 292 … … 332 299 void irc_setpass (irc_t *irc, const char *pass) 333 300 { 334 if (irc->password)g_free (irc->password);301 g_free (irc->password); 335 302 336 303 if (pass) { 337 304 irc->password = g_strdup (pass); 338 irc_usermsg (irc, "Password successfully changed");339 305 } else { 340 306 irc->password = NULL; … … 367 333 } 368 334 369 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )335 if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 370 336 { 371 337 conv[IRC_MAX_LINE] = 0; … … 587 553 588 554 strip_newlines( line ); 589 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )555 if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 590 556 { 591 557 char conv[IRC_MAX_LINE+1]; … … 655 621 char namelist[385] = ""; 656 622 struct conversation *c = NULL; 657 char *ops = set_getstr( irc, "ops" );658 623 659 624 /* RFCs say there is no error reply allowed on NAMES, so when the … … 670 635 } 671 636 672 if( u->gc && !u->away && set_get int( irc, "away_devoice" ) )637 if( u->gc && !u->away && set_getbool( &irc->set, "away_devoice" ) ) 673 638 strcat( namelist, "+" ); 674 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ||675 ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) )676 strcat( namelist, "@" );677 639 678 640 strcat( namelist, u->nick ); … … 683 645 { 684 646 GList *l; 647 char *ops = set_getstr( &irc->set, "ops" ); 685 648 686 649 /* root and the user aren't in the channel userlist but should … … 930 893 { 931 894 char *nick, *s; 932 char reason[ 64];895 char reason[128]; 933 896 934 897 if( u->gc && u->gc->flags & OPT_LOGGING_OUT ) 935 898 { 936 if( u->gc-> user->proto_opt[0][0])899 if( u->gc->acc->server ) 937 900 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, 938 u->gc-> user->proto_opt[0]);901 u->gc->acc->server ); 939 902 else if( ( s = strchr( u->gc->username, '@' ) ) ) 940 903 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, … … 942 905 else 943 906 g_snprintf( reason, sizeof( reason ), "%s %s.%s", irc->myhost, 944 u->gc-> prpl->name, irc->myhost );907 u->gc->acc->prpl->name, irc->myhost ); 945 908 946 909 /* proto_opt might contain garbage after the : */ … … 1018 981 else if( g_strncasecmp( s + 1, "TYPING", 6 ) == 0 ) 1019 982 { 1020 if( u && u->gc && u->gc-> prpl->send_typing && strlen( s ) >= 10 )983 if( u && u->gc && u->gc->acc->prpl->send_typing && strlen( s ) >= 10 ) 1021 984 { 1022 985 time_t current_typing_notice = time( NULL ); … … 1024 987 if( current_typing_notice - u->last_typing_notice >= 5 ) 1025 988 { 1026 u->gc-> prpl->send_typing( u->gc, u->handle, s[8] == '1' );989 u->gc->acc->prpl->send_typing( u->gc, u->handle, s[8] == '1' ); 1027 990 u->last_typing_notice = current_typing_notice; 1028 991 } … … 1057 1020 } 1058 1021 } 1059 else if( c && c->gc && c->gc-> prpl )1022 else if( c && c->gc && c->gc->acc && c->gc->acc->prpl ) 1060 1023 { 1061 1024 return( bim_chat_msg( c->gc, c->id, s ) ); … … 1089 1052 if( !u || !u->gc ) return; 1090 1053 1091 if( set_getint( irc, "buddy_sendbuffer" ) && set_getint( irc, "buddy_sendbuffer_delay" ) > 0 )1054 if( set_getint( &irc->set, "buddy_sendbuffer" ) && set_getint( &irc->set, "buddy_sendbuffer_delay" ) > 0 ) 1092 1055 { 1093 1056 int delay; … … 1116 1079 strcat( u->sendbuf, "\n" ); 1117 1080 1118 delay = set_getint( irc, "buddy_sendbuffer_delay" );1081 delay = set_getint( &irc->set, "buddy_sendbuffer_delay" ); 1119 1082 if( delay <= 5 ) 1120 1083 delay *= 1000; … … 1181 1144 int len = strlen( irc->nick) + 3; 1182 1145 prefix = g_new (char, len ); 1183 g_snprintf( prefix, len, "%s%s", irc->nick, set_getstr( irc, "to_char" ) );1146 g_snprintf( prefix, len, "%s%s", irc->nick, set_getstr( &irc->set, "to_char" ) ); 1184 1147 prefix[len-1] = 0; 1185 1148 }
Note: See TracChangeset
for help on using the changeset viewer.