- Timestamp:
- 2006-01-15T15:42:20Z (18 years ago)
- Branches:
- master
- Children:
- 6fda350
- Parents:
- 13caf0a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ipc.c
r13caf0a r74c119d 31 31 GSList *child_list = NULL; 32 32 33 33 34 static int ipc_master_cmd_die( irc_t *data, char **cmd ) 34 35 { 36 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 37 ipc_to_children_str( "DIE\r\n" ); 38 35 39 bitlbee_shutdown( NULL ); 40 41 return 1; 36 42 } 37 43 38 44 static int ipc_master_cmd_wallops( irc_t *data, char **cmd ) 39 45 { 40 GSList *l; 41 char msg_buf[513]; 42 int msg_len; 43 44 if( ( msg_len = g_snprintf( msg_buf, sizeof( msg_buf ) - 1, "%s :%s\r\n", cmd[0], cmd[1] ) ) > ( sizeof( msg_buf ) - 1 ) ) 45 return 0; 46 47 for( l = child_list; l; l = l->next ) 48 { 49 struct bitlbee_child *c = l->data; 50 write( c->ipc_fd, msg_buf, msg_len ); 51 } 46 ipc_to_children( cmd ); 52 47 53 48 return 1; … … 56 51 static const command_t ipc_master_commands[] = { 57 52 { "die", 0, ipc_master_cmd_die, 0 }, 58 { "wallops", 1, ipc_master_cmd_wallops, 1},59 { "lilo", 1, ipc_master_cmd_wallops, 1},53 { "wallops", 1, ipc_master_cmd_wallops, 0 }, 54 { "lilo", 1, ipc_master_cmd_wallops, 0 }, 60 55 { NULL } 61 56 }; 62 57 58 59 static int ipc_child_cmd_die( irc_t *data, char **cmd ) 60 { 61 bitlbee_shutdown( NULL ); 62 63 return 1; 64 } 65 63 66 static int ipc_child_cmd_wallops( irc_t *data, char **cmd ) 64 67 { … … 75 78 irc_t *irc = data; 76 79 77 irc_write( irc, ":%s NOTICE %s :%s", irc->myhost, irc->nick, cmd[1] ); 80 if( strchr( irc->umode, 's' ) ) 81 irc_write( irc, ":%s NOTICE %s :%s", irc->myhost, irc->nick, cmd[1] ); 78 82 79 83 return 1; … … 81 85 82 86 static const command_t ipc_child_commands[] = { 83 { "wallops", 1, ipc_child_cmd_wallops, 1 }, 84 { "lilo", 1, ipc_child_cmd_lilo, 1 }, 87 { "die", 0, ipc_child_cmd_die, 0 }, 88 { "wallops", 1, ipc_child_cmd_wallops, 0 }, 89 { "lilo", 1, ipc_child_cmd_lilo, 0 }, 85 90 { NULL } 86 91 }; 92 87 93 88 94 static void ipc_command_exec( void *data, char **cmd, const command_t *commands ) … … 191 197 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 192 198 { 193 int i, len; 194 char *s; 199 char *s = irc_build_line( cmd ); 200 write( global.listen_socket, s, strlen( s ) ); 201 g_free( s ); 202 } 203 } 204 205 void ipc_to_children( char **cmd ) 206 { 207 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 208 { 209 char *msg_buf = irc_build_line( cmd ); 210 ipc_to_children_str( msg_buf ); 211 g_free( msg_buf ); 212 } 213 } 214 215 void ipc_to_children_str( char *msg_buf ) 216 { 217 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 218 { 219 int msg_len = strlen( msg_buf ); 220 GSList *l; 195 221 196 len = 1; 197 for( i = 0; cmd[i]; i ++ ) 198 len += strlen( cmd[i] ) + 1; 199 200 if( strchr( cmd[i-1], ' ' ) != NULL ) 201 len ++; 202 203 s = g_new0( char, len + 1 ); 204 for( i = 0; cmd[i]; i ++ ) 222 for( l = child_list; l; l = l->next ) 205 223 { 206 if( cmd[i+1] == NULL && strchr( cmd[i], ' ' ) != NULL ) 207 strcat( s, ":" ); 208 209 strcat( s, cmd[i] ); 210 211 if( cmd[i+1] ) 212 strcat( s, " " ); 224 struct bitlbee_child *c = l->data; 225 write( c->ipc_fd, msg_buf, msg_len ); 213 226 } 214 strcat( s, "\r\n" ); 215 216 write( global.listen_socket, s, len ); 217 } 218 } 227 } 228 }
Note: See TracChangeset
for help on using the changeset viewer.