Changes in / [2face62:4c266f2]
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
r2face62 r4c266f2 282 282 283 283 close( fds[0] ); 284 285 ipc_master_free_all();286 284 } 287 285 } -
ipc.c
r2face62 r4c266f2 32 32 33 33 34 static int ipc_master_cmd_client( irc_t *data, char **cmd ) 35 { 36 struct bitlbee_child *child = (void*) data; 37 38 child->host = g_strdup( cmd[1] ); 39 child->nick = g_strdup( cmd[2] ); 40 child->realname = g_strdup( cmd[3] ); 41 42 ipc_to_children_str( "OPERMSG :Client connecting (PID=%d): %s@%s (%s)\r\n", 43 child->pid, child->nick, child->host, child->realname ); 44 45 return 1; 46 } 47 48 static int ipc_master_cmd_die( irc_t *data, char **cmd ) 34 static int ipc_master_cmd_die( irc_t *irc, char **cmd ) 49 35 { 50 36 if( global.conf->runmode == RUNMODE_FORKDAEMON ) … … 56 42 } 57 43 58 static int ipc_master_cmd_rehash( irc_t * data, char **cmd )44 static int ipc_master_cmd_rehash( irc_t *irc, char **cmd ) 59 45 { 60 46 runmode_t oldmode; … … 78 64 79 65 static const command_t ipc_master_commands[] = { 80 { "client", 3, ipc_master_cmd_client, 0 },81 66 { "die", 0, ipc_master_cmd_die, 0 }, 82 67 { "wallops", 1, NULL, IPC_CMD_TO_CHILDREN }, 83 68 { "lilo", 1, NULL, IPC_CMD_TO_CHILDREN }, 84 { "opermsg", 1, NULL, IPC_CMD_TO_CHILDREN },85 69 { "rehash", 0, ipc_master_cmd_rehash, 0 }, 86 70 { "kill", 2, NULL, IPC_CMD_TO_CHILDREN }, … … 91 75 static int ipc_child_cmd_die( irc_t *irc, char **cmd ) 92 76 { 93 if( irc->status >= USTATUS_LOGGED_IN ) 94 irc_write( irc, "ERROR :Operator requested server shutdown, bye bye!" ); 95 96 irc_abort( irc ); 77 bitlbee_shutdown( NULL ); 97 78 98 79 return 1; … … 117 98 if( strchr( irc->umode, 's' ) ) 118 99 irc_write( irc, ":%s NOTICE %s :%s", irc->myhost, irc->nick, cmd[1] ); 119 120 return 1;121 }122 123 static int ipc_child_cmd_opermsg( irc_t *irc, char **cmd )124 {125 if( irc->status < USTATUS_LOGGED_IN )126 return 1;127 128 if( strchr( irc->umode, 'o' ) )129 irc_write( irc, ":%s NOTICE %s :*** OperMsg *** %s", irc->myhost, irc->nick, cmd[1] );130 100 131 101 return 1; … … 165 135 { "wallops", 1, ipc_child_cmd_wallops, 0 }, 166 136 { "lilo", 1, ipc_child_cmd_lilo, 0 }, 167 { "opermsg", 1, ipc_child_cmd_opermsg, 0 },168 137 { "rehash", 0, ipc_child_cmd_rehash, 0 }, 169 138 { "kill", 2, ipc_child_cmd_kill, 0 }, … … 248 217 if( c->ipc_fd == source ) 249 218 { 250 ipc_master_free_one( c ); 251 child_list = g_slist_remove( child_list, c ); 219 close( c->ipc_fd ); 220 gaim_input_remove( c->ipc_inpa ); 221 g_free( c ); 222 223 child_list = g_slist_remove( child_list, l ); 224 252 225 break; 253 226 } … … 280 253 { 281 254 char *s = irc_build_line( cmd ); 282 ipc_to_master_str( "%s",s );255 ipc_to_master_str( s ); 283 256 g_free( s ); 284 257 } … … 289 262 } 290 263 291 void ipc_to_master_str( char *format, ... ) 292 { 293 char *msg_buf; 294 va_list params; 295 296 va_start( params, format ); 297 msg_buf = g_strdup_vprintf( format, params ); 298 va_end( params ); 299 300 if( strlen( msg_buf ) > 512 ) 301 { 302 /* Don't send it, it's too long... */ 303 } 304 else if( global.conf->runmode == RUNMODE_FORKDAEMON ) 264 void ipc_to_master_str( char *msg_buf ) 265 { 266 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 305 267 { 306 268 write( global.listen_socket, msg_buf, strlen( msg_buf ) ); … … 308 270 else if( global.conf->runmode == RUNMODE_DAEMON ) 309 271 { 310 char **cmd; 311 312 cmd = irc_parse_line( msg_buf ); 272 char *s, **cmd; 273 274 /* irc_parse_line() wants a read-write string, so get it one: */ 275 s = g_strdup( msg_buf ); 276 cmd = irc_parse_line( s ); 277 313 278 ipc_command_exec( NULL, cmd, ipc_master_commands ); 279 314 280 g_free( cmd ); 315 } 316 317 g_free( msg_buf ); 281 g_free( s ); 282 } 318 283 } 319 284 … … 323 288 { 324 289 char *msg_buf = irc_build_line( cmd ); 325 ipc_to_children_str( "%s",msg_buf );290 ipc_to_children_str( msg_buf ); 326 291 g_free( msg_buf ); 327 292 } … … 335 300 } 336 301 337 void ipc_to_children_str( char *format, ... ) 338 { 339 char *msg_buf; 340 va_list params; 341 342 va_start( params, format ); 343 msg_buf = g_strdup_vprintf( format, params ); 344 va_end( params ); 345 346 if( strlen( msg_buf ) > 512 ) 347 { 348 /* Don't send it, it's too long... */ 349 } 350 else if( global.conf->runmode == RUNMODE_FORKDAEMON ) 302 void ipc_to_children_str( char *msg_buf ) 303 { 304 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 351 305 { 352 306 int msg_len = strlen( msg_buf ); … … 361 315 else if( global.conf->runmode == RUNMODE_DAEMON ) 362 316 { 363 char **cmd; 364 365 cmd = irc_parse_line( msg_buf ); 317 char *s, **cmd; 318 319 /* irc_parse_line() wants a read-write string, so get it one: */ 320 s = g_strdup( msg_buf ); 321 cmd = irc_parse_line( s ); 322 366 323 ipc_to_children( cmd ); 324 367 325 g_free( cmd ); 368 } 369 370 g_free( msg_buf ); 371 } 372 373 void ipc_master_free_one( struct bitlbee_child *c ) 374 { 375 gaim_input_remove( c->ipc_inpa ); 376 closesocket( c->ipc_fd ); 377 378 g_free( c->host ); 379 g_free( c->nick ); 380 g_free( c->realname ); 381 g_free( c ); 382 } 383 384 void ipc_master_free_all() 385 { 386 GSList *l; 387 388 for( l = child_list; l; l = l->next ) 389 ipc_master_free_one( l->data ); 390 391 g_slist_free( child_list ); 392 child_list = NULL; 393 } 326 g_free( s ); 327 } 328 } -
ipc.h
r2face62 r4c266f2 27 27 #include "bitlbee.h" 28 28 29 void ipc_master_read( gpointer data, gint source, GaimInputCondition cond ); 30 void ipc_child_read( gpointer data, gint source, GaimInputCondition cond ); 31 32 void ipc_to_master( char **cmd ); 33 void ipc_to_master_str( char *msg_buf ); 34 void ipc_to_children( char **cmd ); 35 void ipc_to_children_str( char *msg_buf ); 36 29 37 struct bitlbee_child 30 38 { … … 32 40 int ipc_fd; 33 41 gint ipc_inpa; 34 35 char *host;36 char *nick;37 char *realname;38 42 }; 39 43 40 void ipc_master_read( gpointer data, gint source, GaimInputCondition cond );41 void ipc_child_read( gpointer data, gint source, GaimInputCondition cond );42 43 void ipc_master_free_one( struct bitlbee_child *child );44 void ipc_master_free_all();45 46 void ipc_to_master( char **cmd );47 void ipc_to_master_str( char *format, ... );48 void ipc_to_children( char **cmd );49 void ipc_to_children_str( char *format, ... );50 51 44 extern GSList *child_list; -
irc.c
r2face62 r4c266f2 27 27 #include "bitlbee.h" 28 28 #include "crypting.h" 29 #include "ipc.h"30 29 31 30 static gboolean irc_userping( gpointer _irc ); … … 690 689 u->realname = g_strdup( irc->realname ); 691 690 u->online = 1; 691 // u->send_handler = msg_echo; 692 692 irc_spawn( irc, u ); 693 693 694 694 irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQ's are answered there." ); 695 696 if( global.conf->runmode == RUNMODE_FORKDAEMON )697 ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname );698 695 699 696 irc->status = USTATUS_LOGGED_IN;
Note: See TracChangeset
for help on using the changeset viewer.