Changeset 8076ec0
- Timestamp:
- 2007-12-05T01:30:50Z (17 years ago)
- Branches:
- master
- Children:
- dc0ba9c
- Parents:
- dce3903 (diff), 793cc25 (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. - Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
rdce3903 r8076ec0 293 293 srand( time( NULL ) ^ getpid() ); 294 294 295 b_main_init(); 296 295 297 /* Close the listening socket, we're a client. */ 296 298 close( global.listen_socket ); -
bitlbee.conf
rdce3903 r8076ec0 19 19 ## 20 20 # RunMode = Inetd 21 22 ## User: 23 ## 24 ## If BitlBee is started by root as a daemon, it can drop root privileges, 25 ## and change to the specified user. 26 ## 27 # User = bitlbee 21 28 22 29 ## DaemonPort/DaemonInterface: -
conf.c
rdce3903 r8076ec0 63 63 conf->ping_interval = 180; 64 64 conf->ping_timeout = 300; 65 conf->user = NULL; 65 66 conf->max_filetransfer_size = G_MAXUINT; 66 67 proxytype = 0; … … 77 78 } 78 79 79 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR: " ) ) >= 0 )80 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 ) 80 81 /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ 81 82 { … … 133 134 " -D Daemon mode. (Still EXPERIMENTAL!)\n" 134 135 " -F Forking daemon. (one process per client)\n" 136 " -u Run daemon as specified user.\n" 135 137 " -P Specify PID-file (not for inetd mode)\n" 136 138 " -i Specify the interface (by IP address) to listen on.\n" … … 152 154 ipc_master_set_statefile( optarg ); 153 155 } 156 else if( opt == 'u' ) 157 { 158 g_free( conf->user ); 159 conf->user = g_strdup( optarg ); 160 } 154 161 } 155 162 … … 193 200 else if( g_strcasecmp( ini->key, "daemoninterface" ) == 0 ) 194 201 { 202 g_free( conf->iface ); 195 203 conf->iface = g_strdup( ini->value ); 196 204 } 197 205 else if( g_strcasecmp( ini->key, "daemonport" ) == 0 ) 198 206 { 207 g_free( conf->port ); 199 208 conf->port = g_strdup( ini->value ); 200 209 } … … 210 219 else if( g_strcasecmp( ini->key, "authpassword" ) == 0 ) 211 220 { 221 g_free( conf->auth_pass ); 212 222 conf->auth_pass = g_strdup( ini->value ); 213 223 } 214 224 else if( g_strcasecmp( ini->key, "operpassword" ) == 0 ) 215 225 { 226 g_free( conf->oper_pass ); 216 227 conf->oper_pass = g_strdup( ini->value ); 217 228 } 218 229 else if( g_strcasecmp( ini->key, "hostname" ) == 0 ) 219 230 { 231 g_free( conf->hostname ); 220 232 conf->hostname = g_strdup( ini->value ); 221 233 } … … 282 294 g_free( url ); 283 295 } 296 else if( g_strcasecmp( ini->key, "user" ) == 0 ) 297 { 298 g_free( conf->user ); 299 conf->user = g_strdup( ini->value ); 300 } 284 301 else 285 302 { -
conf.h
rdce3903 r8076ec0 49 49 int ping_interval; 50 50 int ping_timeout; 51 char *user; 51 52 size_t max_filetransfer_size; 52 53 } conf_t; -
configure
rdce3903 r8076ec0 135 135 [ -z "$CFLAGS" ] && CFLAGS=-g 136 136 echo 'DEBUG=1' >> Makefile.settings 137 echo '#define DEBUG' >> config.h137 CFLAGS="$CFLAGS -DDEBUG" 138 138 else 139 139 [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing" -
irc.c
rdce3903 r8076ec0 324 324 } 325 325 326 if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ))326 if( ( cs = set_getstr( &irc->set, "charset" ) ) ) 327 327 { 328 328 conv[IRC_MAX_LINE] = 0; 329 if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) != -1 ) 330 lines[i] = conv; 329 if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) == -1 ) 330 { 331 if( irc->status & USTATUS_LOGGED_IN ) 332 irc_usermsg( irc, "ERROR: Charset mismatch detected. The charset " 333 "setting is currently set to %s, so please make " 334 "sure your IRC client will send and accept text in " 335 "that charset, or tell BitlBee which charset to " 336 "expect by changing the charset setting. See " 337 "`help set charset' for more information. Your " 338 "message was ignored.", cs ); 339 *conv = 0; 340 } 341 lines[i] = conv; 331 342 } 332 343 -
lib/events.h
rdce3903 r8076ec0 45 45 #include <gmodule.h> 46 46 47 /* The conditions you can pass to gaim_input_add()/that will be passed to47 /* The conditions you can pass to b_input_add()/that will be passed to 48 48 the given callback function. */ 49 49 typedef enum { … … 58 58 #define GAIM_ERR_COND (G_IO_HUP | G_IO_ERR | G_IO_NVAL) 59 59 60 / / #define event_debug( x... ) printf( x )60 /* #define event_debug( x... ) printf( x ) */ 61 61 #define event_debug( x... ) 62 62 -
lib/events_libevent.c
rdce3903 r8076ec0 32 32 #include <unistd.h> 33 33 #include <sys/types.h> 34 #include "proxy.h"35 36 34 #include <sys/time.h> 37 35 #include <event.h> 38 39 static guint id_next; 36 #include "proxy.h" 37 38 static void b_main_restart(); 39 static guint id_next = 1; 40 40 static GHashTable *id_hash; 41 41 static int quitting = 0; … … 48 48 static GHashTable *write_hash; 49 49 50 struct event_base *leh; 51 struct event_base *old_leh; 52 50 53 struct b_event_data 51 54 { … … 59 62 void b_main_init() 60 63 { 61 event_init(); 62 63 id_next = 1; 64 if( leh != NULL ) 65 { 66 /* Clean up the hash tables? */ 67 68 b_main_restart(); 69 old_leh = leh; 70 } 71 72 leh = event_init(); 73 64 74 id_hash = g_hash_table_new( g_int_hash, g_int_equal ); 65 75 read_hash = g_hash_table_new( g_int_hash, g_int_equal ); … … 69 79 void b_main_run() 70 80 { 71 event_dispatch(); 81 /* This while loop is necessary to exit the event loop and start a 82 different one (necessary for ForkDaemon mode). */ 83 while( event_base_dispatch( leh ) == 0 && !quitting ) 84 { 85 if( old_leh != NULL ) 86 { 87 /* For some reason this just isn't allowed... 88 Possibly a bug in older versions, will see later. 89 event_base_free( old_leh ); */ 90 old_leh = NULL; 91 } 92 93 event_debug( "New event loop.\n" ); 94 } 95 } 96 97 static void b_main_restart() 98 { 99 struct timeval tv; 100 101 memset( &tv, 0, sizeof( struct timeval ) ); 102 event_base_loopexit( leh, &tv ); 103 104 event_debug( "b_main_restart()\n" ); 72 105 } 73 106 74 107 void b_main_quit() 75 108 { 76 struct timeval tv; 77 78 /* libevent sometimes generates events before really quitting, 109 /* Tell b_main_run() that it shouldn't restart the loop. Also, 110 libevent sometimes generates events before really quitting, 79 111 we want to stop them. */ 80 112 quitting = 1; 81 113 82 memset( &tv, 0, sizeof( struct timeval ) ); 83 event_loopexit( &tv ); 114 b_main_restart(); 84 115 } 85 116 -
protocols/jabber/conference.c
rdce3903 r8076ec0 24 24 #include "jabber.h" 25 25 26 static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 27 26 28 struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ) 27 29 { … … 35 37 xt_add_attr( node, "xmlns", XMLNS_MUC ); 36 38 node = jabber_make_packet( "presence", NULL, roomjid, node ); 39 jabber_cache_add( ic, node, jabber_chat_join_failed ); 37 40 38 41 if( !jabber_write_packet( ic, node ) ) 39 42 { 40 43 g_free( roomjid ); 41 xt_free_node( node );42 44 return NULL; 43 45 } 44 xt_free_node( node );45 46 46 47 jc = g_new0( struct jabber_chat, 1 ); … … 63 64 64 65 return c; 66 } 67 68 static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 69 { 70 struct jabber_error *err; 71 struct jabber_buddy *bud; 72 char *room; 73 74 room = xt_find_attr( orig, "to" ); 75 if( ( bud = jabber_buddy_by_jid( ic, room, 0 ) ) ) 76 jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) ); 77 78 err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR ); 79 if( err ) 80 { 81 imcb_error( ic, "Error joining groupchat %s: %s%s%s", 82 bud->bare_jid, err->code, err->text ? ": " : "", 83 err->text ? err->text : "" ); 84 jabber_error_free( err ); 85 } 86 87 return XT_HANDLED; 88 } 89 90 struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name ) 91 { 92 char *normalized = jabber_normalize( name ); 93 struct groupchat *ret; 94 struct jabber_chat *jc; 95 96 for( ret = ic->groupchats; ret; ret = ret->next ) 97 { 98 jc = ret->data; 99 if( strcmp( normalized, jc->name ) == 0 ) 100 break; 101 } 102 g_free( normalized ); 103 104 return ret; 65 105 } 66 106 … … 148 188 char *s; 149 189 150 if( ( chat = jabber_chat_by_ name( ic, bud->bare_jid ) ) == NULL )190 if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL ) 151 191 { 152 192 /* How could this happen?? We could do kill( self, 11 ) … … 250 290 return; 251 291 } 252 else if( ( chat = jabber_chat_by_ name( ic, bud->bare_jid ) ) == NULL )292 else if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL ) 253 293 { 254 294 /* How could this happen?? We could do kill( self, 11 ) -
protocols/jabber/iq.c
rdce3903 r8076ec0 31 31 { 32 32 struct im_connection *ic = data; 33 struct jabber_data *jd = ic->proto_data;34 33 struct xt_node *c, *reply = NULL; 35 34 char *type, *s; … … 47 46 if( strcmp( type, "result" ) == 0 || strcmp( type, "error" ) == 0 ) 48 47 { 49 struct jabber_cache_entry *entry; 50 51 if( ( s = xt_find_attr( node, "id" ) ) == NULL || 52 strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 ) 53 { 54 /* Silently ignore it, without an ID (or a non-cache 55 ID) we don't know how to handle the packet and we 56 probably don't have to. */ 57 return XT_HANDLED; 58 } 59 60 entry = g_hash_table_lookup( jd->node_cache, s ); 61 62 if( entry == NULL ) 63 imcb_log( ic, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s ); 64 else if( entry->func ) 65 return entry->func( ic, node, entry->node ); 48 return jabber_cache_handle_packet( ic, node ); 66 49 } 67 50 else if( strcmp( type, "get" ) == 0 ) -
protocols/jabber/jabber.c
rdce3903 r8076ec0 226 226 jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s ); 227 227 g_free( s ); 228 229 printf( "%s\n", jd->cached_id_prefix );230 228 } 231 229 … … 272 270 return jabber_write( ic, message, strlen( message ) ); 273 271 274 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_ name( ic, s + 1 ) )272 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_jid( ic, s + 1 ) ) 275 273 bud = jabber_buddy_by_ext_jid( ic, who, 0 ); 276 274 else … … 399 397 if( strchr( room, '@' ) == NULL ) 400 398 imcb_error( ic, "Invalid room name: %s", room ); 401 else if( jabber_chat_by_ name( ic, room ) )399 else if( jabber_chat_by_jid( ic, room ) ) 402 400 imcb_error( ic, "Already present in chat `%s'", room ); 403 401 else -
protocols/jabber/jabber.h
rdce3903 r8076ec0 227 227 void jabber_cache_entry_free( gpointer entry ); 228 228 void jabber_cache_clean( struct im_connection *ic ); 229 xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node ); 229 230 const struct jabber_away_state *jabber_away_state_by_code( char *code ); 230 231 const struct jabber_away_state *jabber_away_state_by_name( char *name ); … … 249 250 int jabber_buddy_remove( struct im_connection *ic, char *full_jid ); 250 251 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid ); 251 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name );252 252 time_t jabber_get_timestamp( struct xt_node *xt ); 253 253 struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns ); … … 272 272 /* conference.c */ 273 273 struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ); 274 struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name ); 274 275 void jabber_chat_free( struct groupchat *c ); 275 276 int jabber_chat_msg( struct groupchat *ic, char *message, int flags ); -
protocols/jabber/jabber_util.c
rdce3903 r8076ec0 183 183 return FALSE; 184 184 } 185 } 186 187 xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node ) 188 { 189 struct jabber_data *jd = ic->proto_data; 190 struct jabber_cache_entry *entry; 191 char *s; 192 193 if( ( s = xt_find_attr( node, "id" ) ) == NULL || 194 strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 ) 195 { 196 /* Silently ignore it, without an ID (or a non-cache 197 ID) we don't know how to handle the packet and we 198 probably don't have to. */ 199 return XT_HANDLED; 200 } 201 202 entry = g_hash_table_lookup( jd->node_cache, s ); 203 204 if( entry == NULL ) 205 { 206 imcb_log( ic, "WARNING: Received %s-%s packet with unknown/expired ID %s!", 207 node->name, xt_find_attr( node, "type" ) ? : "(no type)", s ); 208 } 209 else if( entry->func ) 210 { 211 return entry->func( ic, node, entry->node ); 212 } 213 214 return XT_HANDLED; 185 215 } 186 216 … … 595 625 } 596 626 597 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name )598 {599 char *normalized = jabber_normalize( name );600 struct groupchat *ret;601 struct jabber_chat *jc;602 603 for( ret = ic->groupchats; ret; ret = ret->next )604 {605 jc = ret->data;606 if( strcmp( normalized, jc->name ) == 0 )607 break;608 }609 g_free( normalized );610 611 return ret;612 }613 614 627 time_t jabber_get_timestamp( struct xt_node *xt ) 615 628 { … … 663 676 struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns ) 664 677 { 665 struct jabber_error *err = g_new0( struct jabber_error, 1 );678 struct jabber_error *err; 666 679 struct xt_node *c; 667 680 char *s; 668 681 682 if( node == NULL ) 683 return NULL; 684 685 err = g_new0( struct jabber_error, 1 ); 669 686 err->type = xt_find_attr( node, "type" ); 670 687 -
protocols/jabber/presence.c
rdce3903 r8076ec0 40 40 { 41 41 *s = 0; 42 if( jabber_chat_by_ name( ic, from ) )42 if( jabber_chat_by_jid( ic, from ) ) 43 43 is_chat = 1; 44 44 *s = '/'; … … 164 164 else if( strcmp( type, "error" ) == 0 ) 165 165 { 166 return jabber_cache_handle_packet( ic, node ); 167 168 /* 166 169 struct jabber_error *err; 167 168 170 if( ( c = xt_find_node( node->children, "error" ) ) ) 169 171 { … … 173 175 err->text ? err->text : "" ); 174 176 jabber_error_free( err ); 175 } 176 /* What else to do with it? */ 177 } */ 177 178 } 178 179 -
protocols/jabber/si.c
rdce3903 r8076ec0 372 372 tf->sid = g_strdup_printf( "BitlBeeJabberSID%d", tf->ft->local_id ); 373 373 374 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_ name( ic, s + 1 ) )374 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_jid( ic, s + 1 ) ) 375 375 bud = jabber_buddy_by_ext_jid( ic, who, 0 ); 376 376 else -
protocols/oscar/msgcookie.c
rdce3903 r8076ec0 131 131 } 132 132 133 #if 0 /* debugging feature */134 int aim_dumpcookie(aim_msgcookie_t *cookie)135 {136 137 if (!cookie)138 return -EINVAL;139 140 printf("\tCookie at %p: %d/%s with %p, next %p\n",141 cookie, cookie->type, cookie->cookie,142 cookie->data, cookie->next);143 144 return 0;145 }146 #endif147 148 133 /** 149 134 * aim_cookie_free - free an aim_msgcookie_t struct -
unix.c
rdce3903 r8076ec0 34 34 #include <sys/time.h> 35 35 #include <sys/wait.h> 36 #include <pwd.h> 36 37 37 38 global_t global; /* Against global namespace pollution */ … … 45 46 struct sigaction sig, old; 46 47 47 memset( &global, 0, sizeof( global_t ) );48 49 48 log_init(); 50 49 CONF_FILE = g_strdup( CONF_FILE_DEF ); … … 87 86 return( i ); 88 87 88 if( ( global.conf->user && *global.conf->user ) && 89 ( global.conf->runmode == RUNMODE_DAEMON || 90 global.conf->runmode == RUNMODE_FORKDAEMON ) && 91 ( !getuid() || !geteuid() ) ) 92 { 93 struct passwd *pw = NULL; 94 pw = getpwnam( global.conf->user ); 95 if( pw ) 96 { 97 setgid( pw->pw_gid ); 98 setuid( pw->pw_uid ); 99 } 100 } 101 89 102 global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); 90 if ( global.storage == NULL) { 103 if( global.storage == NULL ) 104 { 91 105 log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage ); 92 106 return( 1 ); 93 107 } 94 95 108 96 109 /* Catch some signals to tell the user what's happening before quitting */
Note: See TracChangeset
for help on using the changeset viewer.