Changes in / [4c266f2:2face62]
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
r4c266f2 r2face62 282 282 283 283 close( fds[0] ); 284 285 ipc_master_free_all(); 284 286 } 285 287 } -
ipc.c
r4c266f2 r2face62 32 32 33 33 34 static int ipc_master_cmd_die( irc_t *irc, char **cmd ) 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 ) 35 49 { 36 50 if( global.conf->runmode == RUNMODE_FORKDAEMON ) … … 42 56 } 43 57 44 static int ipc_master_cmd_rehash( irc_t * irc, char **cmd )58 static int ipc_master_cmd_rehash( irc_t *data, char **cmd ) 45 59 { 46 60 runmode_t oldmode; … … 64 78 65 79 static const command_t ipc_master_commands[] = { 80 { "client", 3, ipc_master_cmd_client, 0 }, 66 81 { "die", 0, ipc_master_cmd_die, 0 }, 67 82 { "wallops", 1, NULL, IPC_CMD_TO_CHILDREN }, 68 83 { "lilo", 1, NULL, IPC_CMD_TO_CHILDREN }, 84 { "opermsg", 1, NULL, IPC_CMD_TO_CHILDREN }, 69 85 { "rehash", 0, ipc_master_cmd_rehash, 0 }, 70 86 { "kill", 2, NULL, IPC_CMD_TO_CHILDREN }, … … 75 91 static int ipc_child_cmd_die( irc_t *irc, char **cmd ) 76 92 { 77 bitlbee_shutdown( NULL ); 93 if( irc->status >= USTATUS_LOGGED_IN ) 94 irc_write( irc, "ERROR :Operator requested server shutdown, bye bye!" ); 95 96 irc_abort( irc ); 78 97 79 98 return 1; … … 98 117 if( strchr( irc->umode, 's' ) ) 99 118 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] ); 100 130 101 131 return 1; … … 135 165 { "wallops", 1, ipc_child_cmd_wallops, 0 }, 136 166 { "lilo", 1, ipc_child_cmd_lilo, 0 }, 167 { "opermsg", 1, ipc_child_cmd_opermsg, 0 }, 137 168 { "rehash", 0, ipc_child_cmd_rehash, 0 }, 138 169 { "kill", 2, ipc_child_cmd_kill, 0 }, … … 217 248 if( c->ipc_fd == source ) 218 249 { 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 250 ipc_master_free_one( c ); 251 child_list = g_slist_remove( child_list, c ); 225 252 break; 226 253 } … … 253 280 { 254 281 char *s = irc_build_line( cmd ); 255 ipc_to_master_str( s );282 ipc_to_master_str( "%s", s ); 256 283 g_free( s ); 257 284 } … … 262 289 } 263 290 264 void ipc_to_master_str( char *msg_buf ) 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 ) 305 { 306 write( global.listen_socket, msg_buf, strlen( msg_buf ) ); 307 } 308 else if( global.conf->runmode == RUNMODE_DAEMON ) 309 { 310 char **cmd; 311 312 cmd = irc_parse_line( msg_buf ); 313 ipc_command_exec( NULL, cmd, ipc_master_commands ); 314 g_free( cmd ); 315 } 316 317 g_free( msg_buf ); 318 } 319 320 void ipc_to_children( char **cmd ) 265 321 { 266 322 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 267 323 { 268 write( global.listen_socket, msg_buf, strlen( msg_buf ) );269 }270 else if( global.conf->runmode == RUNMODE_DAEMON )271 {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 278 ipc_command_exec( NULL, cmd, ipc_master_commands );279 280 g_free( cmd );281 g_free( s );282 }283 }284 285 void ipc_to_children( char **cmd )286 {287 if( global.conf->runmode == RUNMODE_FORKDAEMON )288 {289 324 char *msg_buf = irc_build_line( cmd ); 290 ipc_to_children_str( msg_buf );325 ipc_to_children_str( "%s", msg_buf ); 291 326 g_free( msg_buf ); 292 327 } … … 300 335 } 301 336 302 void ipc_to_children_str( char *msg_buf ) 303 { 304 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 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 ) 305 351 { 306 352 int msg_len = strlen( msg_buf ); … … 315 361 else if( global.conf->runmode == RUNMODE_DAEMON ) 316 362 { 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 363 char **cmd; 364 365 cmd = irc_parse_line( msg_buf ); 323 366 ipc_to_children( cmd ); 324 325 367 g_free( cmd ); 326 g_free( s ); 327 } 328 } 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 } -
ipc.h
r4c266f2 r2face62 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 37 29 struct bitlbee_child 38 30 { … … 40 32 int ipc_fd; 41 33 gint ipc_inpa; 34 35 char *host; 36 char *nick; 37 char *realname; 42 38 }; 43 39 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 44 51 extern GSList *child_list; -
irc.c
r4c266f2 r2face62 27 27 #include "bitlbee.h" 28 28 #include "crypting.h" 29 #include "ipc.h" 29 30 30 31 static gboolean irc_userping( gpointer _irc ); … … 689 690 u->realname = g_strdup( irc->realname ); 690 691 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 ); 695 698 696 699 irc->status = USTATUS_LOGGED_IN;
Note: See TracChangeset
for help on using the changeset viewer.