Changes in / [3f9440d:fef6116]
- Files:
-
- 30 added
- 22 deleted
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r3f9440d rfef6116 10 10 11 11 # Program variables 12 objects = account.o bitlbee.o conf.o crypting.o help.o i ni.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o unix.o url.o user.o util.o12 objects = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o user.o 13 13 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ini.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h url.h user.h protocols/http_client.h protocols/md5.h protocols/nogaim.h protocols/proxy.h protocols/sha.h protocols/ssl_client.h 14 subdirs = protocols 14 subdirs = protocols lib 15 15 16 16 # Expansion of variables … … 42 42 43 43 distclean: clean $(subdirs) 44 rm -f Makefile.settings config.h 44 rm -f Makefile.settings config.h bitlbee.pc 45 45 find . -name 'DEADJOE' -o -name '*.orig' -o -name '*.rej' -o -name '*~' -exec rm -f {} \; 46 46 -
account.c
r3f9440d rfef6116 28 28 #include "account.h" 29 29 30 char *set_eval_account( set_t *set, char *value ); 31 30 32 account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) 31 33 { 32 34 account_t *a; 35 set_t *s; 33 36 34 37 if( irc->accounts ) 35 38 { 36 39 for( a = irc->accounts; a->next; a = a->next ); 37 a = a->next = g_new0 40 a = a->next = g_new0( account_t, 1 ); 38 41 } 39 42 else … … 45 48 a->user = g_strdup( user ); 46 49 a->pass = g_strdup( pass ); 50 a->auto_connect = 1; 47 51 a->irc = irc; 48 52 53 s = set_add( &a->set, "auto_connect", NULL, set_eval_account, a ); 54 s->flags |= ACC_SET_NOSAVE; 55 56 s = set_add( &a->set, "password", NULL, set_eval_account, a ); 57 s->flags |= ACC_SET_NOSAVE; 58 59 s = set_add( &a->set, "server", NULL, set_eval_account, a ); 60 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 61 62 s = set_add( &a->set, "username", NULL, set_eval_account, a ); 63 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 64 set_setstr( &a->set, "username", user ); 65 49 66 return( a ); 67 } 68 69 char *set_eval_account( set_t *set, char *value ) 70 { 71 account_t *acc = set->data; 72 73 /* Double-check: We refuse to edit on-line accounts. */ 74 if( set->flags & ACC_SET_OFFLINE_ONLY && acc->gc ) 75 return NULL; 76 77 if( strcmp( set->key, "username" ) == 0 ) 78 { 79 g_free( acc->user ); 80 acc->user = g_strdup( value ); 81 return value; 82 } 83 else if( strcmp( set->key, "password" ) == 0 ) 84 { 85 g_free( acc->pass ); 86 acc->pass = g_strdup( value ); 87 return NULL; /* password shouldn't be visible in plaintext! */ 88 } 89 else if( strcmp( set->key, "server" ) == 0 ) 90 { 91 g_free( acc->server ); 92 if( *value ) 93 acc->server = g_strdup( value ); 94 else 95 acc->server = NULL; 96 return value; 97 } 98 else if( strcmp( set->key, "auto_connect" ) == 0 ) 99 { 100 if( !is_bool( value ) ) 101 return NULL; 102 103 acc->auto_connect = bool2int( value ); 104 return value; 105 } 106 107 return NULL; 50 108 } 51 109 … … 129 187 } 130 188 189 while( a->set ) 190 set_del( &a->set, a->set->key ); 191 131 192 g_free( a->user ); 132 193 g_free( a->pass ); … … 142 203 void account_on( irc_t *irc, account_t *a ) 143 204 { 144 struct aim_user *u;145 146 205 if( a->gc ) 147 206 { … … 152 211 cancel_auto_reconnect( a ); 153 212 154 u = g_new0 ( struct aim_user, 1 );155 u->irc = irc;156 u->prpl = a->prpl;157 strncpy( u->username, a->user, sizeof( u->username ) - 1 );158 strncpy( u->password, a->pass, sizeof( u->password ) - 1 );159 if( a->server) strncpy( u->proto_opt[0], a->server, sizeof( u->proto_opt[0] ) - 1 );160 161 a->gc = (struct gaim_connection *) u; /* Bit hackish :-/ */162 213 a->reconnect = 0; 163 164 a->prpl->login( u ); 214 a->prpl->login( a ); 165 215 } 166 216 -
account.h
r3f9440d rfef6116 34 34 char *server; 35 35 36 int auto_connect; 36 37 int reconnect; 38 39 set_t *set; 37 40 38 41 struct irc *irc; … … 47 50 void account_off( irc_t *irc, account_t *a ); 48 51 52 #define ACC_SET_NOSAVE 1 53 #define ACC_SET_OFFLINE_ONLY 2 54 49 55 #endif -
bitlbee.c
r3f9440d rfef6116 291 291 irc_t *irc; 292 292 293 /* Since we're fork()ing here, let's make sure we won't 294 get the same random numbers as the parent/siblings. */ 295 srand( time( NULL ) ^ getpid() ); 296 293 297 /* Close the listening socket, we're a client. */ 294 298 close( global.listen_socket ); -
bitlbee.h
r3f9440d rfef6116 130 130 #include "query.h" 131 131 #include "sock.h" 132 #include " util.h"132 #include "misc.h" 133 133 #include "proxy.h" 134 134 -
conf.c
r3f9440d rfef6116 34 34 #include "ipc.h" 35 35 36 #include "pro tocols/proxy.h"36 #include "proxy.h" 37 37 38 38 char *CONF_FILE; … … 55 55 conf->nofork = 0; 56 56 conf->verbose = 0; 57 conf->primary_storage = "text"; 57 conf->primary_storage = "xml"; 58 conf->migrate_storage = g_strsplit( "text", ",", -1 ); 58 59 conf->runmode = RUNMODE_INETD; 59 60 conf->authmode = AUTHMODE_OPEN; … … 322 323 if( g_strcasecmp( ini->section, "defaults" ) == 0 ) 323 324 { 324 set_t *s = set_find( irc, ini->key );325 set_t *s = set_find( &irc->set, ini->key ); 325 326 326 327 if( s ) -
configure
r3f9440d rfef6116 31 31 32 32 events=glib 33 ldap=auto 33 34 ssl=auto 34 35 … … 66 67 67 68 --ipv6=0/1 IPv6 socket support $ipv6 69 70 --ldap=0/1/auto LDAP support $ldap 68 71 69 72 --events=... Event handler (glib, libevent) $events … … 141 144 fi 142 145 143 echo CFLAGS+=-I`pwd` -I`pwd`/ protocols -I. >> Makefile.settings146 echo CFLAGS+=-I`pwd` -I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings 144 147 145 148 echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings 146 149 147 150 if [ -n "$CC" ]; then 148 echo "CC=$CC" >> Makefile.settings;151 CC=$CC 149 152 elif type gcc > /dev/null 2> /dev/null; then 150 echo "CC=gcc" >> Makefile.settings;153 CC=gcc 151 154 elif type cc > /dev/null 2> /dev/null; then 152 echo "CC=cc" >> Makefile.settings;155 CC=cc 153 156 else 154 157 echo 'Cannot find a C compiler, aborting.' 155 158 exit 1; 156 159 fi 160 161 echo "CC=$CC" >> Makefile.settings; 157 162 158 163 if [ -n "$LD" ]; then … … 232 237 } 233 238 234 if [ "$msn" = 1 -o "$jabber" = 1 ]; then 235 if [ "$ssl" = "auto" ]; then 236 detect_gnutls 237 if [ "$ret" = "0" ]; then 238 detect_nss 239 fi; 240 elif [ "$ssl" = "gnutls" ]; then 241 detect_gnutls; 242 elif [ "$ssl" = "nss" ]; then 243 detect_nss; 244 elif [ "$ssl" = "openssl" ]; then 239 detect_ldap() 240 { 241 TMPFILE=`mktemp` 242 if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then 243 cat<<EOF>>Makefile.settings 244 EFLAGS+=-lldap 245 CFLAGS+= 246 EOF 247 ldap=1 248 rm -f $TMPFILE 249 ret=1 250 else 251 ldap=0 252 ret=0 253 fi 254 } 255 256 if [ "$ssl" = "auto" ]; then 257 detect_gnutls 258 if [ "$ret" = "0" ]; then 259 detect_nss 260 fi 261 elif [ "$ssl" = "gnutls" ]; then 262 detect_gnutls 263 elif [ "$ssl" = "nss" ]; then 264 detect_nss 265 elif [ "$ssl" = "openssl" ]; then 266 echo 267 echo 'No detection code exists for OpenSSL. Make sure that you have a complete' 268 echo 'install of OpenSSL (including devel/header files) before reporting' 269 echo 'compilation problems.' 270 echo 271 echo 'Also, keep in mind that the OpenSSL is, according to some people, not' 272 echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better' 273 echo 'supported by us. However, on many BSD machines, OpenSSL can be considered' 274 echo 'part of the operating system, which makes it GPL-compatible.' 275 echo 276 echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2' 277 echo ' http://www.gnome.org/~markmc/openssl-and-the-gpl.html' 278 echo 279 echo 'Please note that distributing a BitlBee binary which links to OpenSSL is' 280 echo 'probably illegal. If you want to create and distribute a binary BitlBee' 281 echo 'package, you really should use GnuTLS or NSS instead.' 282 echo 283 echo 'Also, the OpenSSL license requires us to say this:' 284 echo ' * "This product includes software developed by the OpenSSL Project' 285 echo ' * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"' 286 287 echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings 288 289 ret=1 290 elif [ "$ssl" = "bogus" ]; then 291 echo 292 echo 'Using bogus SSL code. This means some features have to be disabled.' 293 294 ## Yes, you, at the console! How can you authenticate if you don't have any SSL!? 295 if [ "$msn" = "1" ]; then 245 296 echo 246 echo 'No detection code exists for OpenSSL. Make sure that you have a complete' 247 echo 'install of OpenSSL (including devel/header files) before reporting' 248 echo 'compilation problems.' 249 echo 250 echo 'Also, keep in mind that the OpenSSL is, according to some people, not' 251 echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better' 252 echo 'supported by us. However, on many BSD machines, OpenSSL can be considered' 253 echo 'part of the operating system, which makes it GPL-compatible.' 254 echo 255 echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2' 256 echo ' http://www.gnome.org/~markmc/openssl-and-the-gpl.html' 257 echo 258 echo 'Please note that distributing a BitlBee binary which links to OpenSSL is' 259 echo 'probably illegal. If you want to create and distribute a binary BitlBee' 260 echo 'package, you really should use GnuTLS or NSS instead.' 261 echo 262 echo 'Also, the OpenSSL license requires us to say this:' 263 echo ' * "This product includes software developed by the OpenSSL Project' 264 echo ' * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"' 265 266 echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings 267 268 ret=1; 269 elif [ "$ssl" = "bogus" ]; then 270 echo 271 echo 'Using bogus SSL code. This will not make the MSN module work, but it will' 272 echo 'allow you to use the Jabber module - although without working SSL support.' 273 274 ret=1; 275 else 276 echo 277 echo 'ERROR: Unknown SSL library specified.' 278 exit 1; 279 fi 280 281 if [ "$ret" = "0" ]; then 282 echo 283 echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' 284 echo ' This is necessary for MSN and full Jabber support. To continue,' 285 echo ' install a suitable SSL library or disable MSN support (--msn=0).' 286 echo ' If you want Jabber without SSL support you can try --ssl=bogus.' 287 288 exit 1; 289 fi; 290 291 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 292 fi 297 echo 'Real SSL support is necessary for MSN authentication, will build without' 298 echo 'MSN protocol support.' 299 msn=0 300 fi 301 302 ret=1 303 else 304 echo 305 echo 'ERROR: Unknown SSL library specified.' 306 exit 1 307 fi 308 309 if [ "$ret" = "0" ]; then 310 echo 311 echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' 312 echo ' Please note that this script doesn'\''t have detection code for OpenSSL,' 313 echo ' so if you want to use that, you have to select it by hand. If you don'\''t' 314 echo ' need SSL support, you can select the "bogus" SSL library. (--ssl=bogus)' 315 316 exit 1 317 fi; 318 319 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 320 321 STORAGES="text xml" 322 323 if [ "$ldap" = "auto" ]; then 324 detect_ldap 325 fi 326 327 if [ "$ldap" = 0 ]; then 328 echo "#undef WITH_LDAP" >> config.h 329 elif [ "$ldap" = 1 ]; then 330 echo "#define WITH_LDAP 1" >> config.h 331 STORAGES="$STORAGES ldap" 332 fi 333 334 for i in $STORAGES; do 335 STORAGE_OBJS="$STORAGE_OBJS storage_$i.o" 336 done 337 echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings 293 338 294 339 if [ "$strip" = 0 ]; then … … 304 349 elif type strip > /dev/null 2> /dev/null; then 305 350 echo "STRIP=strip" >> Makefile.settings; 306 elif /bin/test -x /usr/ccs/bin/strip; then307 echo "STRIP=/usr/ccs/bin/strip" >> Makefile.settings;308 351 else 309 352 echo … … 384 427 if [ "$protocols" = "PROTOCOLS = " ]; then 385 428 echo "WARNING: You haven't selected any communication protocol to compile!" 386 echo " Bitl bee will run, but you will be unable to connect to IM servers!"429 echo " BitlBee will run, but you will be unable to connect to IM servers!" 387 430 fi 388 431 … … 419 462 420 463 if [ "$debug" = "1" ]; then 421 echo ' Debugging enabled.' ;422 else 423 echo ' Debugging disabled.' ;464 echo ' Debugging enabled.' 465 else 466 echo ' Debugging disabled.' 424 467 fi 425 468 426 469 if [ "$strip" = "1" ]; then 427 echo ' Binary stripping enabled.'; 428 else 429 echo ' Binary stripping disabled.'; 430 fi 431 432 echo ' Using event handler: '$events; 433 echo ' Using SSL library: '$ssl; 434 435 #if [ "$flood" = "0" ]; then 436 # echo ' Flood protection disabled.'; 437 #else 438 # echo ' Flood protection enabled.'; 439 #fi 470 echo ' Binary stripping enabled.' 471 else 472 echo ' Binary stripping disabled.' 473 fi 474 475 echo ' Using event handler: '$events 476 echo ' Using SSL library: '$ssl 477 echo ' Building with these storage backends: '$STORAGES 440 478 441 479 if [ -n "$protocols" ]; then 442 echo ' Building with these protocols:' $protocols ;443 else 444 echo ' Building without IM-protocol support. We wish you a lot of fun...' ;445 fi 480 echo ' Building with these protocols:' $protocols 481 else 482 echo ' Building without IM-protocol support. We wish you a lot of fun...' 483 fi -
irc.c
r3f9440d rfef6116 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 … … 120 121 irc_connection_list = g_slist_append( irc_connection_list, irc ); 121 122 122 set_add( irc, "away_devoice", "true", set_eval_away_devoice);123 set_add( irc, "auto_connect", "true", set_eval_bool);124 set_add( irc, "auto_reconnect", "false", set_eval_bool);125 set_add( irc, "auto_reconnect_delay", "300", set_eval_int);126 set_add( irc, "buddy_sendbuffer", "false", set_eval_bool);127 set_add( irc, "buddy_sendbuffer_delay", "200", set_eval_int);128 set_add( irc, "charset", "iso8859-1", set_eval_charset);129 set_add( irc, "debug", "false", set_eval_bool);130 set_add( irc, "default_target", "root", NULL);131 set_add( irc, "display_namechanges", "false", set_eval_bool);132 set_add( irc, "handle_unknown", "root", NULL);133 set_add( irc, "lcnicks", "true", set_eval_bool);134 set_add( irc, "ops", "both", set_eval_ops);135 set_add( irc, "private", "true", set_eval_bool);136 set_add( irc, "query_order", "lifo", NULL);137 set_add( irc, "save_on_quit", "true", set_eval_bool);138 set_add( irc, "strip_html", "true", NULL);139 set_add( irc, "to_char", ": ", set_eval_to_char);140 set_add( irc, "typing_notice", "false", set_eval_bool);141 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 ); 142 143 143 144 conf_loaddefaults( irc ); … … 211 212 log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd ); 212 213 213 if( irc->status & USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )214 if( irc->status & USTATUS_IDENTIFIED && set_getint( &irc->set, "save_on_quit" ) ) 214 215 if( storage_save( irc, TRUE ) != STORAGE_OK ) 215 216 irc_usermsg( irc, "Error while saving settings!" ); … … 329 330 void irc_setpass (irc_t *irc, const char *pass) 330 331 { 331 if (irc->password)g_free (irc->password);332 g_free (irc->password); 332 333 333 334 if (pass) { 334 335 irc->password = g_strdup (pass); 335 irc_usermsg (irc, "Password successfully changed");336 336 } else { 337 337 irc->password = NULL; … … 364 364 } 365 365 366 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )366 if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 367 367 { 368 368 conv[IRC_MAX_LINE] = 0; … … 584 584 585 585 strip_newlines( line ); 586 if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )586 if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) 587 587 { 588 588 char conv[IRC_MAX_LINE+1]; … … 666 666 } 667 667 668 if( u->gc && !u->away && set_get int( irc, "away_devoice" ) )668 if( u->gc && !u->away && set_getbool( &irc->set, "away_devoice" ) ) 669 669 strcat( namelist, "+" ); 670 670 … … 676 676 { 677 677 GList *l; 678 char *ops = set_getstr( irc, "ops" );678 char *ops = set_getstr( &irc->set, "ops" ); 679 679 680 680 /* root and the user aren't in the channel userlist but should … … 924 924 { 925 925 char *nick, *s; 926 char reason[ 64];926 char reason[128]; 927 927 928 928 if( u->gc && u->gc->flags & OPT_LOGGING_OUT ) 929 929 { 930 if( u->gc-> user->proto_opt[0][0])930 if( u->gc->acc->server ) 931 931 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, 932 u->gc-> user->proto_opt[0]);932 u->gc->acc->server ); 933 933 else if( ( s = strchr( u->gc->username, '@' ) ) ) 934 934 g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost, … … 936 936 else 937 937 g_snprintf( reason, sizeof( reason ), "%s %s.%s", irc->myhost, 938 u->gc-> prpl->name, irc->myhost );938 u->gc->acc->prpl->name, irc->myhost ); 939 939 940 940 /* proto_opt might contain garbage after the : */ … … 1012 1012 else if( g_strncasecmp( s + 1, "TYPING", 6 ) == 0 ) 1013 1013 { 1014 if( u && u->gc && u->gc-> prpl->send_typing && strlen( s ) >= 10 )1014 if( u && u->gc && u->gc->acc->prpl->send_typing && strlen( s ) >= 10 ) 1015 1015 { 1016 1016 time_t current_typing_notice = time( NULL ); … … 1018 1018 if( current_typing_notice - u->last_typing_notice >= 5 ) 1019 1019 { 1020 u->gc-> prpl->send_typing( u->gc, u->handle, s[8] == '1' );1020 u->gc->acc->prpl->send_typing( u->gc, u->handle, s[8] == '1' ); 1021 1021 u->last_typing_notice = current_typing_notice; 1022 1022 } … … 1051 1051 } 1052 1052 } 1053 else if( c && c->gc && c->gc-> prpl )1053 else if( c && c->gc && c->gc->acc && c->gc->acc->prpl ) 1054 1054 { 1055 1055 return( bim_chat_msg( c->gc, c->id, s ) ); … … 1083 1083 if( !u || !u->gc ) return; 1084 1084 1085 if( set_getint( irc, "buddy_sendbuffer" ) && set_getint( irc, "buddy_sendbuffer_delay" ) > 0 )1085 if( set_getint( &irc->set, "buddy_sendbuffer" ) && set_getint( &irc->set, "buddy_sendbuffer_delay" ) > 0 ) 1086 1086 { 1087 1087 int delay; … … 1110 1110 strcat( u->sendbuf, "\n" ); 1111 1111 1112 delay = set_getint( irc, "buddy_sendbuffer_delay" );1112 delay = set_getint( &irc->set, "buddy_sendbuffer_delay" ); 1113 1113 if( delay <= 5 ) 1114 1114 delay *= 1000; … … 1175 1175 int len = strlen( irc->nick) + 3; 1176 1176 prefix = g_new (char, len ); 1177 g_snprintf( prefix, len, "%s%s", irc->nick, set_getstr( irc, "to_char" ) );1177 g_snprintf( prefix, len, "%s%s", irc->nick, set_getstr( &irc->set, "to_char" ) ); 1178 1178 prefix[len-1] = 0; 1179 1179 } -
irc_commands.c
r3f9440d rfef6116 150 150 irc_part( irc, u, c->channel ); 151 151 152 if( c->gc && c->gc->prpl)152 if( c->gc ) 153 153 { 154 154 c->joined = 0; 155 c->gc-> prpl->chat_leave( c->gc, c->id );155 c->gc->acc->prpl->chat_leave( c->gc, c->id ); 156 156 } 157 157 } … … 173 173 user_t *u = user_find( irc, cmd[1] + 1 ); 174 174 175 if( u && u->gc && u->gc-> prpl && u->gc->prpl->chat_open )175 if( u && u->gc && u->gc->acc->prpl->chat_open ) 176 176 { 177 177 irc_reply( irc, 403, "%s :Initializing groupchat in a different channel", cmd[1] ); 178 178 179 if( !u->gc-> prpl->chat_open( u->gc, u->handle ) )179 if( !u->gc->acc->prpl->chat_open( u->gc, u->handle ) ) 180 180 { 181 181 irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); … … 205 205 206 206 if( u && c && ( u->gc == c->gc ) ) 207 if( c->gc && c->gc-> prpl && c->gc->prpl->chat_invite )208 { 209 c->gc-> prpl->chat_invite( c->gc, c->id, "", u->handle );207 if( c->gc && c->gc->acc->prpl->chat_invite ) 208 { 209 c->gc->acc->prpl->chat_invite( c->gc, c->id, "", u->handle ); 210 210 irc_reply( irc, 341, "%s %s", nick, channel ); 211 211 return; … … 230 230 { 231 231 unsigned int i; 232 char *t = set_getstr( irc, "default_target" );232 char *t = set_getstr( &irc->set, "default_target" ); 233 233 234 234 if( g_strcasecmp( t, "last" ) == 0 && irc->last_target ) … … 477 477 478 478 if( u->gc ) 479 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc-> user->username,480 *u->gc-> user->proto_opt[0] ? u->gc->user->proto_opt[0] : "", u->gc->prpl->name );479 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->gc->acc->user, 480 *u->gc->acc->server ? u->gc->acc->server : "", u->gc->acc->prpl->name ); 481 481 else 482 482 irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); -
nick.c
r3f9440d rfef6116 86 86 87 87 nick_strip( nick ); 88 if (set_getint(irc, "lcnicks"))88 if( set_getint( &irc->set, "lcnicks" ) ) 89 89 nick_lc( nick ); 90 90 } -
protocols/Makefile
r3f9440d rfef6116 10 10 11 11 # [SH] Program variables 12 objects = $(EVENT_HANDLER) http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT)12 objects = nogaim.o 13 13 14 14 # [SH] The next two lines should contain the directory name (in $(subdirs)) -
protocols/jabber/jabber.c
r3f9440d rfef6116 561 561 static void gjab_start(gjconn gjc) 562 562 { 563 struct aim_user *user;563 account_t *acc; 564 564 int port = -1, ssl = 0; 565 565 char *server = NULL, *s; … … 568 568 return; 569 569 570 user = GJ_GC(gjc)->user;571 if ( *user->proto_opt[0]) {570 acc = GJ_GC(gjc)->acc; 571 if (acc->server) { 572 572 /* If there's a dot, assume there's a hostname in the beginning */ 573 if (strchr( user->proto_opt[0], '.')) {574 server = g_strdup( user->proto_opt[0]);573 if (strchr(acc->server, '.')) { 574 server = g_strdup(acc->server); 575 575 if ((s = strchr(server, ':'))) 576 576 *s = 0; … … 578 578 579 579 /* After the hostname, there can be a port number */ 580 s = strchr( user->proto_opt[0], ':');580 s = strchr(acc->server, ':'); 581 581 if (s && isdigit(s[1])) 582 582 sscanf(s + 1, "%d", &port); 583 583 584 584 /* And if there's the string ssl, the user wants an SSL-connection */ 585 if (strstr( user->proto_opt[0], ":ssl") || g_strcasecmp(user->proto_opt[0], "ssl") == 0)585 if (strstr(acc->server, ":ssl") || g_strcasecmp(acc->server, "ssl") == 0) 586 586 ssl = 1; 587 587 } … … 616 616 g_free(server); 617 617 618 if (! user->gc || (gjc->fd < 0)) {618 if (!acc->gc || (gjc->fd < 0)) { 619 619 STATE_EVT(JCONN_STATE_OFF) 620 620 return; … … 1516 1516 } 1517 1517 1518 static void jabber_login( struct aim_user *user)1519 { 1520 struct gaim_connection *gc = new_gaim_conn( user);1518 static void jabber_login(account_t *acc) 1519 { 1520 struct gaim_connection *gc = new_gaim_conn(acc); 1521 1521 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); 1522 char *loginname = create_valid_jid( user->username, DEFAULT_SERVER, "BitlBee");1522 char *loginname = create_valid_jid(acc->user, DEFAULT_SERVER, "BitlBee"); 1523 1523 1524 1524 jd->hash = g_hash_table_new(g_str_hash, g_str_equal); … … 1527 1527 set_login_progress(gc, 1, _("Connecting")); 1528 1528 1529 if (!(jd->gjc = gjab_new(loginname, user->password, gc))) {1529 if (!(jd->gjc = gjab_new(loginname, acc->pass, gc))) { 1530 1530 g_free(loginname); 1531 1531 hide_login_progress(gc, _("Unable to connect")); -
protocols/msn/msn.c
r3f9440d rfef6116 27 27 #include "msn.h" 28 28 29 static void msn_login( struct aim_user *acct)30 { 31 struct gaim_connection *gc = new_gaim_conn( acc t);29 static void msn_login( account_t *acc ) 30 { 31 struct gaim_connection *gc = new_gaim_conn( acc ); 32 32 struct msn_data *md = g_new0( struct msn_data, 1 ); 33 33 … … 37 37 md->fd = -1; 38 38 39 if( strchr( acc t->username, '@' ) == NULL )39 if( strchr( acc->user, '@' ) == NULL ) 40 40 { 41 41 hide_login_progress( gc, "Invalid account name" ); -
protocols/nogaim.c
r3f9440d rfef6116 145 145 /* multi.c */ 146 146 147 struct gaim_connection *new_gaim_conn( struct aim_user *user)147 struct gaim_connection *new_gaim_conn( account_t *acc ) 148 148 { 149 149 struct gaim_connection *gc; 150 account_t *a;151 150 152 151 gc = g_new0( struct gaim_connection, 1 ); 153 152 154 gc->prpl = user->prpl;155 g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username);156 g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password);157 /* [MD] BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user.158 * This fixes daemon mode breakage where IRC doesn't point to the currently active connection.159 */160 gc->irc = user->irc;153 /* Maybe we should get rid of this memory waste later. ;-) */ 154 g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user ); 155 g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass ); 156 157 gc->irc = acc->irc; 158 gc->acc = acc; 159 acc->gc = gc; 161 160 162 161 connections = g_slist_append( connections, gc ); 163 164 user->gc = gc;165 gc->user = user;166 167 // Find the account_t so we can set its gc pointer168 for( a = gc->irc->accounts; a; a = a->next )169 if( ( struct aim_user * ) a->gc == user )170 {171 a->gc = gc;172 break;173 }174 162 175 163 return( gc ); … … 189 177 190 178 connections = g_slist_remove( connections, gc ); 191 g_free( gc->user );192 179 g_free( gc ); 193 180 } … … 220 207 va_end( params ); 221 208 222 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) ||223 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) )209 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || 210 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) 224 211 strip_html( text ); 225 212 226 213 /* Try to find a different connection on the same protocol. */ 227 214 for( a = gc->irc->accounts; a; a = a->next ) 228 if( a->prpl == gc-> prpl && a->gc != gc )215 if( a->prpl == gc->acc->prpl && a->gc != gc ) 229 216 break; 230 217 231 218 /* If we found one, include the screenname in the message. */ 232 219 if( a ) 233 irc_usermsg( gc->irc, "%s(%s) - %s", gc-> prpl->name, gc->username, text );220 irc_usermsg( gc->irc, "%s(%s) - %s", gc->acc->prpl->name, gc->username, text ); 234 221 else 235 irc_usermsg( gc->irc, "%s - %s", gc-> prpl->name, text );222 irc_usermsg( gc->irc, "%s - %s", gc->acc->prpl->name, text ); 236 223 237 224 g_free( text ); … … 242 229 struct gaim_connection *gc = d; 243 230 244 if( gc-> prpl && gc->prpl->keepalive )245 gc-> prpl->keepalive( gc );231 if( gc->acc->prpl->keepalive ) 232 gc->acc->prpl->keepalive( gc ); 246 233 247 234 return TRUE; … … 297 284 b_event_remove( gc->keepalive ); 298 285 gc->flags |= OPT_LOGGING_OUT; 286 299 287 gc->keepalive = 0; 300 gc-> prpl->close( gc );288 gc->acc->prpl->close( gc ); 301 289 b_event_remove( gc->inpa ); 302 290 … … 323 311 /* Uhm... This is very sick. */ 324 312 } 325 else if( !gc->wants_to_die && set_getint( irc, "auto_reconnect" ) )326 { 327 int delay = set_getint( irc, "auto_reconnect_delay" );313 else if( !gc->wants_to_die && set_getint( &irc->set, "auto_reconnect" ) ) 314 { 315 int delay = set_getint( &irc->set, "auto_reconnect_delay" ); 328 316 329 317 serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); … … 364 352 irc_t *irc = gc->irc; 365 353 366 if( set_getint( irc, "debug" ) && 0 ) /* This message is too useless */354 if( set_getint( &irc->set, "debug" ) && 0 ) /* This message is too useless */ 367 355 serv_got_crap( gc, "Receiving user add from handle: %s", handle ); 368 356 369 357 if( user_findhandle( gc, handle ) ) 370 358 { 371 if( set_getint( irc, "debug" ) )359 if( set_getint( &irc->set, "debug" ) ) 372 360 serv_got_crap( gc, "User already exists, ignoring add request: %s", handle ); 373 361 … … 378 366 379 367 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 380 strcpy( nick, nick_get( gc->irc, handle, gc-> prpl, realname ) );368 strcpy( nick, nick_get( gc->irc, handle, gc->acc->prpl, realname ) ); 381 369 382 370 u = user_add( gc->irc, nick ); … … 390 378 u->user = g_strndup( handle, s - handle ); 391 379 } 392 else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0])380 else if( *gc->acc->server ) 393 381 { 394 382 char *colon; 395 383 396 if( ( colon = strchr( gc-> user->proto_opt[0], ':' ) ) )397 u->host = g_strndup( gc-> user->proto_opt[0],398 colon - gc-> user->proto_opt[0]);384 if( ( colon = strchr( gc->acc->server, ':' ) ) ) 385 u->host = g_strndup( gc->acc->server, 386 colon - gc->acc->server ); 399 387 else 400 u->host = g_strdup( gc-> user->proto_opt[0]);388 u->host = g_strdup( gc->acc->server ); 401 389 402 390 u->user = g_strdup( handle ); … … 409 397 else 410 398 { 411 u->host = g_strdup( gc-> user->prpl->name );399 u->host = g_strdup( gc->acc->prpl->name ); 412 400 u->user = g_strdup( handle ); 413 401 } … … 457 445 u->realname = g_strdup( realname ); 458 446 459 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( gc->irc, "display_namechanges" ) )447 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( &gc->irc->set, "display_namechanges" ) ) 460 448 serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname ); 461 449 } … … 479 467 void show_got_added_yes( gpointer w, struct show_got_added_data *data ) 480 468 { 481 data->gc-> prpl->add_buddy( data->gc, data->handle );469 data->gc->acc->prpl->add_buddy( data->gc, data->handle ); 482 470 add_buddy( data->gc, NULL, data->handle, data->handle ); 483 471 … … 513 501 if( !u ) 514 502 { 515 if( g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "add" ) == 0 )503 if( g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "add" ) == 0 ) 516 504 { 517 505 add_buddy( gc, NULL, handle, NULL ); … … 520 508 else 521 509 { 522 if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 )510 if( set_getint( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 ) 523 511 { 524 512 serv_got_crap( gc, "serv_got_update() for handle %s:", handle ); … … 558 546 } 559 547 560 if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )548 if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) ) 561 549 { 562 550 u->away = g_strdup( "Away" ); 563 551 } 564 else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber")) )552 else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) ) 565 553 { 566 554 if( type & UC_DND ) … … 571 559 u->away = g_strdup( "Away" ); 572 560 } 573 else if( ( type & UC_UNAVAILABLE ) && gc-> prpl->get_status_string )574 { 575 u->away = g_strdup( gc-> prpl->get_status_string( gc, type ) );561 else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string ) 562 { 563 u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) ); 576 564 } 577 565 else … … 579 567 580 568 /* LISPy... */ 581 if( ( set_getint( gc->irc, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */569 if( ( set_getint( &gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 582 570 ( u->online ) && /* Don't touch offline people */ 583 571 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ … … 598 586 if( !u ) 599 587 { 600 char *h = set_getstr( irc, "handle_unknown" );588 char *h = set_getstr( &irc->set, "handle_unknown" ); 601 589 602 590 if( g_strcasecmp( h, "ignore" ) == 0 ) 603 591 { 604 if( set_getint( irc, "debug" ) )592 if( set_getint( &irc->set, "debug" ) ) 605 593 serv_got_crap( gc, "Ignoring message from unknown handle %s", handle ); 606 594 … … 609 597 else if( g_strncasecmp( h, "add", 3 ) == 0 ) 610 598 { 611 int private = set_getint( irc, "private" );599 int private = set_getint( &irc->set, "private" ); 612 600 613 601 if( h[3] ) … … 630 618 } 631 619 632 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) ||633 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) )620 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || 621 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) 634 622 strip_html( msg ); 635 623 … … 671 659 user_t *u; 672 660 673 if( !set_getint( gc->irc, "typing_notice" ) )661 if( !set_getint( &gc->irc->set, "typing_notice" ) ) 674 662 return; 675 663 … … 693 681 GList *ir; 694 682 695 if( set_getint( gc->irc, "debug" ) )683 if( set_getint( &gc->irc->set, "debug" ) ) 696 684 serv_got_crap( gc, "You were removed from conversation %d", (int) id ); 697 685 … … 732 720 733 721 /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ 734 if( g_strcasecmp( who, gc->user ->username ) == 0 )722 if( g_strcasecmp( who, gc->username ) == 0 ) 735 723 return; 736 724 … … 738 726 for( c = gc->conversations; c && c->id != id; c = c->next ); 739 727 740 if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) ||741 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) )728 if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || 729 ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) 742 730 strip_html( msg ); 743 731 … … 772 760 g_free( s ); 773 761 774 if( set_getint( gc->irc, "debug" ) )762 if( set_getint( &gc->irc->set, "debug" ) ) 775 763 serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle ); 776 764 … … 786 774 int me = 0; 787 775 788 if( set_getint( b->gc->irc, "debug" ) )776 if( set_getint( &b->gc->irc->set, "debug" ) ) 789 777 serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); 790 778 791 779 /* It might be yourself! */ 792 if( b->gc-> prpl->cmp_buddynames( handle, b->gc->user->username ) == 0 )780 if( b->gc->acc->prpl->cmp_buddynames( handle, b->gc->username ) == 0 ) 793 781 { 794 782 u = user_find( b->gc->irc, b->gc->irc->nick ); … … 820 808 int me = 0; 821 809 822 if( set_getint( b->gc->irc, "debug" ) )810 if( set_getint( &b->gc->irc->set, "debug" ) ) 823 811 serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); 824 812 825 813 /* It might be yourself! */ 826 if( g_strcasecmp( handle, b->gc->user ->username ) == 0 )814 if( g_strcasecmp( handle, b->gc->username ) == 0 ) 827 815 { 828 816 u = user_find( b->gc->irc, b->gc->irc->nick ); … … 882 870 } 883 871 884 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ) 885 { 872 char *set_eval_away_devoice( set_t *set, char *value ) 873 { 874 irc_t *irc = set->data; 886 875 int st; 887 876 … … 897 886 /* Horror.... */ 898 887 899 if( st != set_getint( irc, "away_devoice" ) )888 if( st != set_getint( &irc->set, "away_devoice" ) ) 900 889 { 901 890 char list[80] = ""; … … 937 926 } 938 927 939 return( set_eval_bool( irc,set, value ) );928 return( set_eval_bool( set, value ) ); 940 929 } 941 930 … … 957 946 } 958 947 959 st = gc-> prpl->send_im( gc, handle, msg, strlen( msg ), flags );948 st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); 960 949 g_free( buf ); 961 950 … … 974 963 } 975 964 976 st = gc-> prpl->chat_send( gc, id, msg );965 st = gc->acc->prpl->chat_send( gc, id, msg ); 977 966 g_free( buf ); 978 967 … … 988 977 989 978 if( !away ) away = ""; 990 ms = m = gc-> prpl->away_states( gc );979 ms = m = gc->acc->prpl->away_states( gc ); 991 980 992 981 while( m ) … … 1009 998 if( m ) 1010 999 { 1011 gc-> prpl->set_away( gc, m->data, *away ? away : NULL );1000 gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL ); 1012 1001 } 1013 1002 else … … 1016 1005 if( s ) 1017 1006 { 1018 gc-> prpl->set_away( gc, s, away );1019 if( set_getint( gc->irc, "debug" ) )1007 gc->acc->prpl->set_away( gc, s, away ); 1008 if( set_getint( &gc->irc->set, "debug" ) ) 1020 1009 serv_got_crap( gc, "Setting away state to %s", s ); 1021 1010 } 1022 1011 else 1023 gc-> prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );1012 gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); 1024 1013 } 1025 1014 … … 1073 1062 void bim_add_allow( struct gaim_connection *gc, char *handle ) 1074 1063 { 1075 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc-> prpl->cmp_buddynames ) == NULL )1064 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) == NULL ) 1076 1065 { 1077 1066 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); 1078 1067 } 1079 1068 1080 gc-> prpl->add_permit( gc, handle );1069 gc->acc->prpl->add_permit( gc, handle ); 1081 1070 } 1082 1071 … … 1085 1074 GSList *l; 1086 1075 1087 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc-> prpl->cmp_buddynames ) ) )1076 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) ) ) 1088 1077 { 1089 1078 g_free( l->data ); … … 1091 1080 } 1092 1081 1093 gc-> prpl->rem_permit( gc, handle );1082 gc->acc->prpl->rem_permit( gc, handle ); 1094 1083 } 1095 1084 1096 1085 void bim_add_block( struct gaim_connection *gc, char *handle ) 1097 1086 { 1098 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc-> prpl->cmp_buddynames ) == NULL )1087 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) == NULL ) 1099 1088 { 1100 1089 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); 1101 1090 } 1102 1091 1103 gc-> prpl->add_deny( gc, handle );1092 gc->acc->prpl->add_deny( gc, handle ); 1104 1093 } 1105 1094 … … 1108 1097 GSList *l; 1109 1098 1110 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc-> prpl->cmp_buddynames ) ) )1099 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) ) ) 1111 1100 { 1112 1101 g_free( l->data ); … … 1114 1103 } 1115 1104 1116 gc-> prpl->rem_deny( gc, handle );1117 } 1105 gc->acc->prpl->rem_deny( gc, handle ); 1106 } -
protocols/nogaim.h
r3f9440d rfef6116 39 39 40 40 #include "bitlbee.h" 41 #include "account.h" 41 42 #include "proxy.h" 42 43 #include "md5.h" … … 63 64 struct gaim_connection 64 65 { 65 struct prpl *prpl;66 account_t *acc; 66 67 guint32 flags; 67 68 … … 78 79 GSList *deny; 79 80 int permdeny; 80 81 struct aim_user *user;82 81 83 82 char username[64]; … … 126 125 }; 127 126 128 struct aim_user {129 char username[64];130 char alias[SELF_ALIAS_LEN];131 char password[32];132 char user_info[2048];133 int options;134 struct prpl *prpl;135 /* prpls can use this to save information about the user,136 * like which server to connect to, etc */137 char proto_opt[7][256];138 139 struct gaim_connection *gc;140 irc_t *irc;141 };142 143 127 struct prpl { 144 128 int options; 145 129 const char *name; 146 130 147 void (* login) ( struct aim_user*);131 void (* login) (account_t *); 148 132 void (* keepalive) (struct gaim_connection *); 149 133 void (* close) (struct gaim_connection *); … … 206 190 207 191 void nogaim_init(); 208 char *set_eval_away_devoice( irc_t *irc,set_t *set, char *value );192 char *set_eval_away_devoice( set_t *set, char *value ); 209 193 210 194 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); … … 212 196 213 197 /* multi.c */ 214 G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( struct aim_user *user);198 G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( account_t *acc ); 215 199 G_MODULE_EXPORT void destroy_gaim_conn( struct gaim_connection *gc ); 216 200 G_MODULE_EXPORT void set_login_progress( struct gaim_connection *gc, int step, char *msg ); -
protocols/oscar/oscar.c
r3f9440d rfef6116 356 356 } 357 357 358 static void oscar_login( struct aim_user *user) {358 static void oscar_login(account_t *acc) { 359 359 aim_session_t *sess; 360 360 aim_conn_t *conn; 361 361 char buf[256]; 362 struct gaim_connection *gc = new_gaim_conn( user);362 struct gaim_connection *gc = new_gaim_conn(acc); 363 363 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); 364 364 365 if (isdigit( *user->username)) {365 if (isdigit(acc->user[0])) { 366 366 odata->icq = TRUE; 367 367 /* This is odd but it's necessary for a proper do_import and do_export. 368 368 We don't do those anymore, but let's stick with it, just in case 369 it accidentally fixes something else too... */369 it accidentally fixes something else too... </bitlbee> */ 370 370 gc->password[8] = 0; 371 371 } else { … … 390 390 } 391 391 392 if (g_strcasecmp( user->proto_opt[USEROPT_AUTH], "login.icq.com") != 0 &&393 g_strcasecmp( user->proto_opt[USEROPT_AUTH], "login.oscar.aol.com") != 0) {394 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.", user->proto_opt[USEROPT_AUTH]);392 if (g_strcasecmp(acc->server, "login.icq.com") != 0 && 393 g_strcasecmp(acc->server, "login.oscar.aol.com") != 0) { 394 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",acc->server); 395 395 } 396 396 … … 402 402 403 403 conn->status |= AIM_CONN_STATUS_INPROGRESS; 404 conn->fd = proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? 405 user->proto_opt[USEROPT_AUTH] : AIM_DEFAULT_LOGIN_SERVER, 406 user->proto_opt[USEROPT_AUTHPORT][0] ? 407 atoi(user->proto_opt[USEROPT_AUTHPORT]) : AIM_LOGIN_PORT, 408 oscar_login_connect, gc); 404 conn->fd = proxy_connect(acc->server, AIM_LOGIN_PORT, oscar_login_connect, gc); 409 405 if (conn->fd < 0) { 410 406 hide_login_progress(gc, _("Couldn't connect to host")); … … 485 481 struct aim_authresp_info *info; 486 482 int i; char *host; int port; 487 struct aim_user *user;488 483 aim_conn_t *bosconn; 489 484 490 485 struct gaim_connection *gc = sess->aux_data; 491 486 struct oscar_data *od = gc->proto_data; 492 user = gc->user; 493 port = user->proto_opt[USEROPT_AUTHPORT][0] ? 494 atoi(user->proto_opt[USEROPT_AUTHPORT]) : AIM_LOGIN_PORT, 487 port = AIM_LOGIN_PORT; 495 488 496 489 va_start(ap, fr); … … 871 864 struct aim_redirect_data *redir; 872 865 struct gaim_connection *gc = sess->aux_data; 873 struct aim_user *user = gc->user;874 866 aim_conn_t *tstconn; 875 867 int i; … … 877 869 int port; 878 870 879 port = user->proto_opt[USEROPT_AUTHPORT][0] ?880 atoi(user->proto_opt[USEROPT_AUTHPORT]) : AIM_LOGIN_PORT,881 882 871 va_start(ap, fr); 883 872 redir = va_arg(ap, struct aim_redirect_data *); 884 873 va_end(ap); 885 874 875 port = AIM_LOGIN_PORT; 886 876 for (i = 0; i < (int)strlen(redir->ip); i++) { 887 877 if (redir->ip[i] == ':') { … … 1723 1713 odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint)maxsiglen; 1724 1714 1715 /* FIXME: It seems we're not really using this, and it broke now that 1716 struct aim_user is dead. 1725 1717 aim_bos_setprofile(sess, fr->conn, gc->user->user_info, NULL, gaim_caps); 1726 1718 */ 1719 1727 1720 return 1; 1728 1721 } -
protocols/yahoo/libyahoo2.c
r3f9440d rfef6116 89 89 #define vsnprintf _vsnprintf 90 90 #endif 91 92 #include "base64.h" 91 93 92 94 #ifdef USE_STRUCT_CALLBACKS … … 695 697 } 696 698 697 static char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 698 "abcdefghijklmnopqrstuvwxyz" 699 "0123456789._"; 699 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ 700 700 static void to_y64(unsigned char *out, const unsigned char *in, int inlen) 701 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ 702 { 703 for (; inlen >= 3; inlen -= 3) 704 { 705 *out++ = base64digits[in[0] >> 2]; 706 *out++ = base64digits[((in[0]<<4) & 0x30) | (in[1]>>4)]; 707 *out++ = base64digits[((in[1]<<2) & 0x3c) | (in[2]>>6)]; 708 *out++ = base64digits[in[2] & 0x3f]; 709 in += 3; 710 } 711 if (inlen > 0) 712 { 713 unsigned char fragment; 714 715 *out++ = base64digits[in[0] >> 2]; 716 fragment = (in[0] << 4) & 0x30; 717 if (inlen > 1) 718 fragment |= in[1] >> 4; 719 *out++ = base64digits[fragment]; 720 *out++ = (inlen < 2) ? '-' 721 : base64digits[(in[1] << 2) & 0x3c]; 722 *out++ = '-'; 723 } 724 *out = '\0'; 701 { 702 base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"); 725 703 } 726 704 -
protocols/yahoo/yahoo.c
r3f9440d rfef6116 121 121 } 122 122 123 static void byahoo_login( struct aim_user *user)124 { 125 struct gaim_connection *gc = new_gaim_conn( user);123 static void byahoo_login( account_t *acc ) 124 { 125 struct gaim_connection *gc = new_gaim_conn( acc ); 126 126 struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 ); 127 127 … … 130 130 131 131 set_login_progress( gc, 1, "Connecting" ); 132 yd->y2_id = yahoo_init( user->username, user->password);132 yd->y2_id = yahoo_init( acc->user, acc->pass ); 133 133 yahoo_login( yd->y2_id, yd->current_status ); 134 134 } … … 425 425 yd = gc->proto_data; 426 426 427 if( !strcmp(gc->prpl->name, "yahoo")&& yd->y2_id == id )427 if( strcmp( gc->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) 428 428 return( gc ); 429 429 } -
query.c
r3f9440d rfef6116 63 63 } 64 64 65 if( g_strcasecmp( set_getstr( irc, "query_order" ), "lifo" ) == 0 || irc->queries == q )65 if( g_strcasecmp( set_getstr( &irc->set, "query_order" ), "lifo" ) == 0 || irc->queries == q ) 66 66 query_display( irc, q ); 67 67 … … 172 172 query_t *q; 173 173 174 if( g_strcasecmp( set_getstr( irc, "query_order" ), "fifo" ) == 0 )174 if( g_strcasecmp( set_getstr( &irc->set, "query_order" ), "fifo" ) == 0 ) 175 175 q = irc->queries; 176 176 else -
root_commands.c
r3f9440d rfef6116 127 127 } 128 128 129 static void cmd_account( irc_t *irc, char **cmd ); 130 129 131 static void cmd_identify( irc_t *irc, char **cmd ) 130 132 { 131 133 storage_status_t status = storage_load( irc->nick, cmd[1], irc ); 134 char *account_on[] = { "account", "on", NULL }; 132 135 133 136 switch (status) { … … 139 142 break; 140 143 case STORAGE_OK: 141 irc_usermsg( irc, "Password accepted " );144 irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); 142 145 irc_umode_set( irc, "+R", 1 ); 146 if( set_getint( &irc->set, "auto_connect" ) ) 147 cmd_account( irc, account_on ); 143 148 break; 149 case STORAGE_OTHER_ERROR: 144 150 default: 145 irc_usermsg( irc, " Something very weird happened" );151 irc_usermsg( irc, "Unknown error while loading configuration" ); 146 152 break; 147 153 } … … 226 232 227 233 a = account_add( irc, prpl, cmd[3], cmd[4] ); 228 229 234 if( cmd[5] ) 230 a->server = g_strdup(cmd[5] );235 set_setstr( &a->set, "server", cmd[5] ); 231 236 232 237 irc_usermsg( irc, "Account successfully added" ); … … 306 311 307 312 for( a = irc->accounts; a; a = a->next ) 308 if( !a->gc )313 if( !a->gc && a->auto_connect ) 309 314 account_on( irc, a ); 310 315 } … … 352 357 } 353 358 } 359 else if( g_strcasecmp( cmd[1], "set" ) == 0 ) 360 { 361 char *acc_handle, *set_name = NULL, *tmp; 362 363 if( !cmd[2] ) 364 { 365 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); 366 return; 367 } 368 369 acc_handle = g_strdup( cmd[2] ); 370 if( ( tmp = strchr( acc_handle, '/' ) ) ) 371 { 372 *tmp = 0; 373 set_name = tmp + 1; 374 } 375 a = account_get( irc, acc_handle ); 376 377 if( a == NULL ) 378 { 379 irc_usermsg( irc, "Invalid account" ); 380 return; 381 } 382 383 if( cmd[3] ) 384 { 385 set_t *s = set_find( &a->set, set_name ); 386 387 if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY ) 388 { 389 irc_usermsg( irc, "This setting can only be changed when the account is off-line" ); 390 return; 391 } 392 393 set_setstr( &a->set, set_name, cmd[3] ); 394 395 if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] ) 396 irc_usermsg( irc, "Warning: Correct syntax: \002account set <variable> <value>\002 (without =)" ); 397 } 398 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ 399 { 400 char *s = set_getstr( &a->set, set_name ); 401 if( s ) 402 irc_usermsg( irc, "%s = `%s'", set_name, s ); 403 else 404 irc_usermsg( irc, "%s is empty", set_name ); 405 } 406 else 407 { 408 set_t *s = a->set; 409 while( s ) 410 { 411 if( s->value || s->def ) 412 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 413 else 414 irc_usermsg( irc, "%s is empty", s->key ); 415 s = s->next; 416 } 417 } 418 419 g_free( acc_handle ); 420 } 354 421 else 355 422 { … … 394 461 else 395 462 { 396 nick_set( irc, cmd[2], a->gc-> prpl, cmd[3] );463 nick_set( irc, cmd[2], a->gc->acc->prpl, cmd[3] ); 397 464 } 398 465 } … … 401 468 add them to your *real* (server-side) contact list. */ 402 469 if( add_for_real ) 403 a->gc-> prpl->add_buddy( a->gc, cmd[2] );470 a->gc->acc->prpl->add_buddy( a->gc, cmd[2] ); 404 471 405 472 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); … … 435 502 } 436 503 437 if( !gc-> prpl->get_info )504 if( !gc->acc->prpl->get_info ) 438 505 { 439 506 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 441 508 else 442 509 { 443 gc-> prpl->get_info( gc, cmd[2] );510 gc->acc->prpl->get_info( gc, cmd[2] ); 444 511 } 445 512 } … … 476 543 else if( u->send_handler == buddy_send_handler ) 477 544 { 478 nick_set( irc, u->handle, u->gc-> prpl, cmd[2] );545 nick_set( irc, u->handle, u->gc->acc->prpl, cmd[2] ); 479 546 } 480 547 … … 495 562 s = g_strdup( u->handle ); 496 563 497 u->gc-> prpl->remove_buddy( u->gc, u->handle, NULL );564 u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); 498 565 user_del( irc, cmd[1] ); 499 566 nick_del( irc, cmd[1] ); … … 552 619 } 553 620 554 if( !gc-> prpl->add_deny || !gc->prpl->rem_permit )621 if( !gc->acc->prpl->add_deny || !gc->acc->prpl->rem_permit ) 555 622 { 556 623 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 611 678 } 612 679 613 if( !gc-> prpl->rem_deny || !gc->prpl->add_permit )680 if( !gc->acc->prpl->rem_deny || !gc->acc->prpl->add_permit ) 614 681 { 615 682 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 666 733 if( cmd[1] && cmd[2] ) 667 734 { 668 set_setstr( irc, cmd[1], cmd[2] );735 set_setstr( &irc->set, cmd[1], cmd[2] ); 669 736 670 737 if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) … … 673 740 if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ 674 741 { 675 char *s = set_getstr( irc, cmd[1] );742 char *s = set_getstr( &irc->set, cmd[1] ); 676 743 if( s ) 677 744 irc_usermsg( irc, "%s = `%s'", cmd[1], s ); 745 else 746 irc_usermsg( irc, "%s is empty", cmd[1] ); 678 747 } 679 748 else … … 684 753 if( s->value || s->def ) 685 754 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 755 else 756 irc_usermsg( irc, "%s is empty", s->key ); 686 757 s = s->next; 687 758 } … … 727 798 if( online == 1 ) 728 799 { 729 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );800 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 730 801 irc_usermsg( irc, format, u->nick, s, "Online" ); 731 802 } … … 738 809 if( away == 1 ) 739 810 { 740 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );811 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 741 812 irc_usermsg( irc, format, u->nick, s, u->away ); 742 813 } … … 748 819 if( offline == 1 ) 749 820 { 750 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );821 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 751 822 irc_usermsg( irc, format, u->nick, s, "Offline" ); 752 823 } … … 773 844 irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); 774 845 } 775 else if ( !a-> gc->prpl->set_info )846 else if ( !a->prpl->set_info ) 776 847 { 777 848 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 781 852 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 782 853 783 a-> gc->prpl->set_info( a->gc, cmd[2] );854 a->prpl->set_info( a->gc, cmd[2] ); 784 855 } 785 856 } … … 800 871 for( num = 0; q; q = q->next, num ++ ) 801 872 if( q->gc ) /* Not necessary yet, but it might come later */ 802 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc-> prpl->name, q->gc->username, q->question );873 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->acc->prpl->name, q->gc->username, q->question ); 803 874 else 804 875 irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); … … 828 899 user_t *u; 829 900 901 /* FIXME: Hmmm, this is actually pretty dangerous code... REMOVEME? :-) */ 830 902 for( u = irc->users; u; u = u->next ) 831 903 if( u->gc == gc ) 832 904 { 833 u->gc-> prpl->remove_buddy( u->gc, u->handle, NULL );905 u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); 834 906 user_del( irc, u->nick ); 835 907 } … … 846 918 for( n = gc->irc->nicks; n; n = n->next ) 847 919 { 848 if( n->proto == gc-> prpl && !user_findhandle( gc, n->handle ) )849 { 850 gc-> prpl->add_buddy( gc, n->handle );920 if( n->proto == gc->acc->prpl && !user_findhandle( gc, n->handle ) ) 921 { 922 gc->acc->prpl->add_buddy( gc, n->handle ); 851 923 add_buddy( gc, NULL, n->handle, NULL ); 852 924 } -
set.c
r3f9440d rfef6116 26 26 #include "bitlbee.h" 27 27 28 set_t *set_add( irc_t *irc, char *key, char *def, void *eval ) 29 { 30 set_t *s = set_find( irc, key ); 31 32 if( !s ) 33 { 34 if( ( s = irc->set ) ) 28 set_t *set_add( set_t **head, char *key, char *def, void *eval, void *data ) 29 { 30 set_t *s = set_find( head, key ); 31 32 /* Possibly the setting already exists. If it doesn't exist yet, 33 we create it. If it does, we'll just change the default. */ 34 if( !s ) 35 { 36 if( ( s = *head ) ) 35 37 { 36 38 while( s->next ) s = s->next; 37 s->next = g_new 39 s->next = g_new0( set_t, 1 ); 38 40 s = s->next; 39 41 } 40 42 else 41 43 { 42 s = irc->set = g_new( set_t, 1 );44 s = *head = g_new0( set_t, 1 ); 43 45 } 44 memset( s, 0, sizeof( set_t ) );45 46 s->key = g_strdup( key ); 46 47 } … … 53 54 if( def ) s->def = g_strdup( def ); 54 55 55 if( s->eval ) 56 { 57 g_free( s->eval ); 58 s->eval = NULL; 59 } 60 if( eval ) s->eval = eval; 61 62 return( s ); 63 } 64 65 set_t *set_find( irc_t *irc, char *key ) 66 { 67 set_t *s = irc->set; 56 s->eval = eval; 57 s->data = data; 58 59 return s; 60 } 61 62 set_t *set_find( set_t **head, char *key ) 63 { 64 set_t *s = *head; 68 65 69 66 while( s ) … … 74 71 } 75 72 76 return ( s );77 } 78 79 char *set_getstr( irc_t *irc, char *key )80 { 81 set_t *s = set_find( irc, key );73 return s; 74 } 75 76 char *set_getstr( set_t **head, char *key ) 77 { 78 set_t *s = set_find( head, key ); 82 79 83 80 if( !s || ( !s->value && !s->def ) ) 84 return ( NULL );85 86 return ( s->value?s->value:s->def );87 } 88 89 int set_getint( irc_t *irc, char *key )90 { 91 char *s = set_getstr( irc, key );81 return NULL; 82 83 return s->value ? s->value : s->def; 84 } 85 86 int set_getint( set_t **head, char *key ) 87 { 88 char *s = set_getstr( head, key ); 92 89 int i = 0; 93 90 94 91 if( !s ) 95 return ( 0 );92 return 0; 96 93 97 94 if( ( g_strcasecmp( s, "true" ) == 0 ) || ( g_strcasecmp( s, "yes" ) == 0 ) || ( g_strcasecmp( s, "on" ) == 0 ) ) 98 return ( 1 );95 return 1; 99 96 100 97 if( sscanf( s, "%d", &i ) != 1 ) 101 return( 0 ); 102 103 return( i ); 104 } 105 106 int set_setstr( irc_t *irc, char *key, char *value ) 107 { 108 set_t *s = set_find( irc, key ); 98 return 0; 99 100 return i; 101 } 102 103 int set_getbool( set_t **head, char *key ) 104 { 105 char *s = set_getstr( head, key ); 106 107 if( !s ) 108 return 0; 109 110 return bool2int( s ); 111 } 112 113 int set_setstr( set_t **head, char *key, char *value ) 114 { 115 set_t *s = set_find( head, key ); 109 116 char *nv = value; 110 117 111 118 if( !s ) 112 s = set_add( irc, key, NULL, NULL );113 114 if( s->eval && !( nv = s->eval( irc,s, value ) ) )115 return ( 0 );119 s = set_add( head, key, NULL, NULL, NULL ); 120 121 if( s->eval && !( nv = s->eval( s, value ) ) ) 122 return 0; 116 123 117 124 if( s->value ) … … 121 128 } 122 129 130 /* If there's a default setting and it's equal to what we're trying to 131 set, stick with s->value = NULL. Otherwise, remember the setting. */ 123 132 if( !s->def || ( strcmp( nv, s->def ) != 0 ) ) 124 133 s->value = g_strdup( nv ); … … 127 136 g_free( nv ); 128 137 129 return ( 1 );130 } 131 132 int set_setint( irc_t *irc, char *key, int value )138 return 1; 139 } 140 141 int set_setint( set_t **head, char *key, int value ) 133 142 { 134 143 char s[24]; /* Not quite 128-bit clean eh? ;-) */ 135 144 136 sprintf( s, "%d", value );137 return ( set_setstr( irc, key, s ));138 } 139 140 void set_del( irc_t *irc, char *key )141 { 142 set_t *s = irc->set, *t = NULL;145 g_snprintf( s, sizeof( s ), "%d", value ); 146 return set_setstr( head, key, s ); 147 } 148 149 void set_del( set_t **head, char *key ) 150 { 151 set_t *s = *head, *t = NULL; 143 152 144 153 while( s ) … … 153 162 t->next = s->next; 154 163 else 155 irc->set= s->next;164 *head = s->next; 156 165 157 166 g_free( s->key ); … … 162 171 } 163 172 164 char *set_eval_int( irc_t *irc, set_t *set, char *value ) 165 { 166 char *s = value; 167 168 for( ; *s; s ++ ) 169 if( *s < '0' || *s > '9' ) 170 return( NULL ); 171 172 return( value ); 173 } 174 175 char *set_eval_bool( irc_t *irc, set_t *set, char *value ) 176 { 177 if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) ) 178 return( value ); 179 if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) ) 180 return( value ); 181 return( set_eval_int( irc, set, value ) ); 182 } 183 184 char *set_eval_to_char( irc_t *irc, set_t *set, char *value ) 173 char *set_eval_int( set_t *set, char *value ) 174 { 175 char *s; 176 177 for( s = value; *s; s ++ ) 178 if( !isdigit( *s ) ) 179 return NULL; 180 181 return value; 182 } 183 184 char *set_eval_bool( set_t *set, char *value ) 185 { 186 return is_bool( value ) ? value : NULL; 187 } 188 189 char *set_eval_to_char( set_t *set, char *value ) 185 190 { 186 191 char *s = g_new( char, 3 ); … … 191 196 sprintf( s, "%c ", *value ); 192 197 193 return( s ); 194 } 195 196 char *set_eval_ops( irc_t *irc, set_t *set, char *value ) 197 { 198 return s; 199 } 200 201 char *set_eval_ops( set_t *set, char *value ) 202 { 203 irc_t *irc = set->data; 204 198 205 if( g_strcasecmp( value, "user" ) == 0 ) 199 {200 206 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 201 207 irc->channel, "+o-o", irc->nick, irc->mynick ); 202 return( value );203 }204 208 else if( g_strcasecmp( value, "root" ) == 0 ) 205 {206 209 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 207 210 irc->channel, "-o+o", irc->nick, irc->mynick ); 208 return( value );209 }210 211 else if( g_strcasecmp( value, "both" ) == 0 ) 211 {212 212 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 213 213 irc->channel, "+oo", irc->nick, irc->mynick ); 214 return( value );215 }216 214 else if( g_strcasecmp( value, "none" ) == 0 ) 217 {218 215 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 219 216 irc->channel, "-oo", irc->nick, irc->mynick ); 220 return( value ); 221 } 222 223 return( NULL ); 224 } 225 217 else 218 return NULL; 219 220 return value; 221 } 222 223 char *set_eval_charset( set_t *set, char *value ) 224 { 225 GIConv cd; 226 227 if ( g_strncasecmp( value, "none", 4 ) == 0 ) 228 return value; 229 230 cd = g_iconv_open( "UTF-8", value ); 231 if( cd == (GIConv) -1 ) 232 return NULL; 233 234 g_iconv_close( cd ); 235 return value; 236 } -
set.h
r3f9440d rfef6116 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-200 4Wilmer van der Gaast and others *4 * Copyright 2002-2006 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 26 26 typedef struct set 27 27 { 28 void *data; 29 28 30 char *key; 29 31 char *value; 30 32 char *def; /* Default */ 31 33 32 /* Eval: Returns NULL if the value is incorrect. Can return a 33 corrected value. set_setstr() should be able to free() the 34 returned string! */ 35 char *(*eval) ( irc_t *irc, struct set *set, char *value ); 34 int flags; 35 36 /* Eval: Returns NULL if the value is incorrect or exactly the 37 passed value variable. When returning a corrected value, 38 set_setstr() should be able to free() the returned string! */ 39 char *(*eval) ( struct set *set, char *value ); 36 40 struct set *next; 37 41 } set_t; 38 42 39 set_t *set_add( irc_t *irc, char *key, char *def, void *eval ); 40 G_MODULE_EXPORT set_t *set_find( irc_t *irc, char *key ); 41 G_MODULE_EXPORT char *set_getstr( irc_t *irc, char *key ); 42 G_MODULE_EXPORT int set_getint( irc_t *irc, char *key ); 43 int set_setstr( irc_t *irc, char *key, char *value ); 44 int set_setint( irc_t *irc, char *key, int value ); 45 void set_del( irc_t *irc, char *key ); 43 set_t *set_add( set_t **head, char *key, char *def, void *eval, void *data ); 44 set_t *set_find( set_t **head, char *key ); 45 G_MODULE_EXPORT char *set_getstr( set_t **head, char *key ); 46 G_MODULE_EXPORT int set_getint( set_t **head, char *key ); 47 G_MODULE_EXPORT int set_getbool( set_t **head, char *key ); 48 int set_setstr( set_t **head, char *key, char *value ); 49 int set_setint( set_t **head, char *key, int value ); 50 void set_del( set_t **head, char *key ); 46 51 47 char *set_eval_int( irc_t *irc, set_t *set, char *value ); 48 char *set_eval_bool( irc_t *irc, set_t *set, char *value ); 49 char *set_eval_to_char( irc_t *irc, set_t *set, char *value ); 50 char *set_eval_ops( irc_t *irc, set_t *set, char *value ); 52 char *set_eval_int( set_t *set, char *value ); 53 char *set_eval_bool( set_t *set, char *value ); 51 54 52 55 char *set_eval_to_char( set_t *set, char *value ); 56 char *set_eval_ops( set_t *set, char *value ); 57 char *set_eval_charset( set_t *set, char *value ); -
storage.c
r3f9440d rfef6116 6 6 7 7 /* Support for multiple storage backends */ 8 9 /* Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org> */ 8 10 9 11 /* … … 29 31 30 32 extern storage_t storage_text; 33 extern storage_t storage_xml; 31 34 32 static GList text_entry = { &storage_text, NULL, NULL }; 33 static GList *storage_backends = &text_entry; 35 static GList *storage_backends = NULL; 34 36 35 37 void register_storage_backend(storage_t *backend) … … 41 43 { 42 44 GList *gl; 43 storage_t *st ;45 storage_t *st = NULL; 44 46 45 47 for (gl = storage_backends; gl; gl = gl->next) { … … 63 65 int i; 64 66 storage_t *storage; 65 67 68 register_storage_backend(&storage_text); 69 register_storage_backend(&storage_xml); 70 66 71 storage = storage_init_single(primary); 67 72 if (storage == NULL) -
storage.h
r3f9440d rfef6116 33 33 STORAGE_ALREADY_EXISTS, 34 34 STORAGE_OTHER_ERROR /* Error that isn't caused by user input, such as 35 36 35 a database that is unreachable. log() will be 36 used for the exact error message */ 37 37 } storage_status_t; 38 38 -
storage_text.c
r3f9440d rfef6116 116 116 } 117 117 fclose( fp ); 118 119 if( set_getint( irc, "auto_connect" ) )120 {121 strcpy( s, "account on" ); /* Can't do this directly because r_c_s alters the string */122 root_command_string( irc, ru, s, 0 );123 }124 118 125 119 return STORAGE_OK; -
unix.c
r3f9440d rfef6116 48 48 49 49 b_main_init(); 50 51 50 log_init(); 52 53 51 nogaim_init(); 54 52 53 srand( time( NULL ) ^ getpid() ); 54 55 55 CONF_FILE = g_strdup( CONF_FILE_DEF ); 56 57 56 global.helpfile = g_strdup( HELP_FILE ); 58 57 59 58 global.conf = conf_load( argc, argv ); 60 59 if( global.conf == NULL ) 61 60 return( 1 ); 62 63 61 64 62 if( global.conf->runmode == RUNMODE_INETD ) 65 63 { … … 89 87 if( i != 0 ) 90 88 return( i ); 91 89 92 90 global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); 93 91 if ( global.storage == NULL) { -
user.c
r3f9440d rfef6116 67 67 68 68 u->user = u->realname = u->host = u->nick = g_strdup( nick ); 69 u->is_private = set_getint( irc, "private" );69 u->is_private = set_getint( &irc->set, "private" ); 70 70 71 71 key = g_strdup( nick ); … … 147 147 while( u ) 148 148 { 149 if( u->gc == gc && u->handle && gc-> prpl->cmp_buddynames ( u->handle, handle ) == 0 )149 if( u->gc == gc && u->handle && gc->acc->prpl->cmp_buddynames ( u->handle, handle ) == 0 ) 150 150 break; 151 151 u = u->next;
Note: See TracChangeset
for help on using the changeset viewer.