Changeset f4a5940
- Timestamp:
- 2006-01-15T20:31:59Z (19 years ago)
- Branches:
- master
- Children:
- daa9e02
- Parents:
- 6fda350
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.h
r6fda350 rf4a5940 44 44 #define IRC_CMD_TO_MASTER 8 45 45 46 #define IPC_CMD_TO_CHILDREN 1 47 46 48 #endif -
conf.c
r6fda350 rf4a5940 64 64 conf->ping_interval = 180; 65 65 conf->ping_timeout = 300; 66 proxytype = 0; 66 67 67 68 i = conf_loadini( conf, CONF_FILE ); … … 76 77 } 77 78 78 while( ( opt = getopt( argc, argv, "i:p:nvIDFc:d:h" ) ) >= 0 ) 79 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:nvIDFc:d:h" ) ) >= 0 ) 80 /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ 79 81 { 80 82 if( opt == 'i' ) … … 108 110 CONF_FILE = g_strdup( optarg ); 109 111 g_free( conf ); 110 /* Re-evaluate arguments. */ 112 /* Re-evaluate arguments. Don't use this option twice, 113 you'll end up in an infinite loop! Hope this trick 114 works with all libcs BTW.. */ 111 115 optind = 1; 112 116 return( conf_load( argc, argv ) ); -
ipc.c
r6fda350 rf4a5940 42 42 } 43 43 44 static int ipc_master_cmd_wallops( irc_t *data, char **cmd ) 45 { 46 ipc_to_children( cmd ); 44 static int ipc_master_cmd_rehash( irc_t *data, char **cmd ) 45 { 46 runmode_t oldmode; 47 48 oldmode = global.conf->runmode; 49 50 g_free( global.conf ); 51 global.conf = conf_load( 0, NULL ); 52 53 if( global.conf->runmode != oldmode ) 54 { 55 log_message( LOGLVL_WARNING, "Can't change RunMode setting at runtime, restoring original setting" ); 56 global.conf->runmode = oldmode; 57 } 58 59 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 60 ipc_to_children( cmd ); 47 61 48 62 return 1; … … 51 65 static const command_t ipc_master_commands[] = { 52 66 { "die", 0, ipc_master_cmd_die, 0 }, 53 { "wallops", 1, ipc_master_cmd_wallops, 0 }, 54 { "lilo", 1, ipc_master_cmd_wallops, 0 }, 67 { "wallops", 1, NULL, IPC_CMD_TO_CHILDREN }, 68 { "lilo", 1, NULL, IPC_CMD_TO_CHILDREN }, 69 { "rehash", 0, ipc_master_cmd_rehash, 0 }, 55 70 { NULL } 56 71 }; … … 80 95 if( strchr( irc->umode, 's' ) ) 81 96 irc_write( irc, ":%s NOTICE %s :%s", irc->myhost, irc->nick, cmd[1] ); 97 98 return 1; 99 } 100 101 static int ipc_child_cmd_rehash( irc_t *data, char **cmd ) 102 { 103 runmode_t oldmode; 104 105 oldmode = global.conf->runmode; 106 107 g_free( global.conf ); 108 global.conf = conf_load( 0, NULL ); 109 110 global.conf->runmode = oldmode; 82 111 83 112 return 1; … … 88 117 { "wallops", 1, ipc_child_cmd_wallops, 0 }, 89 118 { "lilo", 1, ipc_child_cmd_lilo, 0 }, 119 { "rehash", 0, ipc_child_cmd_rehash, 0 }, 90 120 { NULL } 91 121 }; … … 102 132 if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) 103 133 { 104 commands[i].execute( data, cmd ); 134 if( commands[i].flags & IPC_CMD_TO_CHILDREN ) 135 ipc_to_children( cmd ); 136 else 137 commands[i].execute( data, cmd ); 138 105 139 return; 106 140 } … … 198 232 { 199 233 char *s = irc_build_line( cmd ); 200 write( global.listen_socket, s, strlen( s ) ); 234 ipc_to_master_str( s ); 235 g_free( s ); 236 } 237 else if( global.conf->runmode == RUNMODE_DAEMON ) 238 { 239 ipc_command_exec( NULL, cmd, ipc_master_commands ); 240 } 241 } 242 243 void ipc_to_master_str( char *msg_buf ) 244 { 245 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 246 { 247 write( global.listen_socket, msg_buf, strlen( msg_buf ) ); 248 } 249 else if( global.conf->runmode == RUNMODE_DAEMON ) 250 { 251 char *s, **cmd; 252 253 /* irc_parse_line() wants a read-write string, so get it one: */ 254 s = g_strdup( msg_buf ); 255 cmd = irc_parse_line( s ); 256 257 ipc_command_exec( NULL, cmd, ipc_master_commands ); 258 259 g_free( cmd ); 201 260 g_free( s ); 202 261 } … … 210 269 ipc_to_children_str( msg_buf ); 211 270 g_free( msg_buf ); 271 } 272 else if( global.conf->runmode == RUNMODE_DAEMON ) 273 { 274 GSList *l; 275 276 for( l = irc_connection_list; l; l = l->next ) 277 ipc_command_exec( l->data, cmd, ipc_child_commands ); 212 278 } 213 279 } … … 226 292 } 227 293 } 228 } 294 else if( global.conf->runmode == RUNMODE_DAEMON ) 295 { 296 char *s, **cmd; 297 298 /* irc_parse_line() wants a read-write string, so get it one: */ 299 s = g_strdup( msg_buf ); 300 cmd = irc_parse_line( s ); 301 302 ipc_to_children( cmd ); 303 304 g_free( cmd ); 305 g_free( s ); 306 } 307 } -
ipc.h
r6fda350 rf4a5940 29 29 void ipc_master_read( gpointer data, gint source, GaimInputCondition cond ); 30 30 void ipc_child_read( gpointer data, gint source, GaimInputCondition cond ); 31 31 32 void ipc_to_master( char **cmd ); 33 void ipc_to_master_str( char *msg_buf ); 32 34 void ipc_to_children( char **cmd ); 33 35 void ipc_to_children_str( char *msg_buf ); -
irc_commands.c
r6fda350 rf4a5940 233 233 } 234 234 235 /* TODO: Attach this one to NOTICE too! */236 235 static int irc_cmd_privmsg( irc_t *irc, char **cmd ) 237 236 { … … 530 529 } 531 530 532 /* TODO: Alias to NS */533 531 static int irc_cmd_nickserv( irc_t *irc, char **cmd ) 534 532 { … … 576 574 577 575 irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS ", "END" ); 576 577 return( 1 ); 578 } 579 580 static int irc_cmd_rehash( irc_t *irc, char **cmd ) 581 { 582 ipc_to_master( cmd ); 583 584 irc_reply( irc, 382, "%s :Rehashing", CONF_FILE ); 578 585 579 586 return( 1 ); … … 610 617 { "wallops", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 611 618 { "lilo", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 619 { "rehash", 0, irc_cmd_rehash, IRC_CMD_OPER_ONLY }, 612 620 { NULL } 613 621 };
Note: See TracChangeset
for help on using the changeset viewer.