Changeset 74c119d
- Timestamp:
- 2006-01-15T15:42:20Z (19 years ago)
- Branches:
- master
- Children:
- 6fda350
- Parents:
- 13caf0a
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
r13caf0a r74c119d 56 56 } 57 57 58 /* TIME_WAIT (?) sucks.. */ 59 i = 1; 60 setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) ); 61 58 62 #ifdef IPV6 59 63 listen_addr.sin6_family = AF_INETx; -
conf.c
r13caf0a r74c119d 92 92 } 93 93 else if( opt == 'n' ) 94 conf->nofork =1;94 conf->nofork = 1; 95 95 else if( opt == 'v' ) 96 conf->verbose =1;96 conf->verbose = 1; 97 97 else if( opt == 'I' ) 98 conf->runmode =RUNMODE_INETD;98 conf->runmode = RUNMODE_INETD; 99 99 else if( opt == 'D' ) 100 conf->runmode =RUNMODE_DAEMON;100 conf->runmode = RUNMODE_DAEMON; 101 101 else if( opt == 'F' ) 102 conf->runmode =RUNMODE_FORKDAEMON;102 conf->runmode = RUNMODE_FORKDAEMON; 103 103 else if( opt == 'c' ) 104 104 { … … 108 108 CONF_FILE = g_strdup( optarg ); 109 109 g_free( conf ); 110 /* Re-evaluate arguments. */ 111 optind = 1; 110 112 return( conf_load( argc, argv ) ); 111 113 } -
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 } -
ipc.h
r13caf0a r74c119d 30 30 void ipc_child_read( gpointer data, gint source, GaimInputCondition cond ); 31 31 void ipc_to_master( char **cmd ); 32 void ipc_to_children( char **cmd ); 33 void ipc_to_children_str( char *msg_buf ); 32 34 33 35 struct bitlbee_child -
irc.c
r13caf0a r74c119d 432 432 433 433 return cmd; 434 } 435 436 char *irc_build_line( char **cmd ) 437 { 438 int i, len; 439 char *s; 440 441 if( cmd[0] == NULL ) 442 return NULL; 443 444 len = 1; 445 for( i = 0; cmd[i]; i ++ ) 446 len += strlen( cmd[i] ) + 1; 447 448 if( strchr( cmd[i-1], ' ' ) != NULL ) 449 len ++; 450 451 s = g_new0( char, len + 1 ); 452 for( i = 0; cmd[i]; i ++ ) 453 { 454 if( cmd[i+1] == NULL && strchr( cmd[i], ' ' ) != NULL ) 455 strcat( s, ":" ); 456 457 strcat( s, cmd[i] ); 458 459 if( cmd[i+1] ) 460 strcat( s, " " ); 461 } 462 strcat( s, "\r\n" ); 463 464 return s; 434 465 } 435 466 -
irc.h
r13caf0a r74c119d 109 109 int irc_process( irc_t *irc ); 110 110 char **irc_parse_line( char *line ); 111 char *irc_build_line( char **cmd ); 111 112 112 113 void irc_vawrite( irc_t *irc, char *format, va_list params );
Note: See TracChangeset
for help on using the changeset viewer.