Changeset 8358691
- Timestamp:
- 2010-08-31T20:05:36Z (14 years ago)
- Branches:
- master
- Children:
- f5c0d8e
- Parents:
- ad2d8bc
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.h
rad2d8bc r8358691 165 165 void root_command_string( irc_t *irc, char *command ); 166 166 void root_command( irc_t *irc, char *command[] ); 167 gboolean root_command_add( const char *command, int params, void (*func)(irc_t *, char **args), int flags ); 167 168 gboolean cmd_identify_finish( gpointer data, gint fd, b_input_condition cond ); 168 169 gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond ); -
commands.h
rad2d8bc r8358691 37 37 } command_t; 38 38 39 extern co nst command_tcommands[];39 extern command_t root_commands[]; 40 40 41 41 #define IRC_CMD_PRE_LOGIN 1 -
irc_commands.c
rad2d8bc r8358691 626 626 irc_send_msg_raw( irc->root, "NOTICE", irc->user->nick, "COMPLETIONS OK" ); 627 627 628 for( i = 0; commands[i].command; i ++ )629 irc_send_msg_f( irc->root, "NOTICE", irc->user->nick, "COMPLETIONS %s", commands[i].command );628 for( i = 0; root_commands[i].command; i ++ ) 629 irc_send_msg_f( irc->root, "NOTICE", irc->user->nick, "COMPLETIONS %s", root_commands[i].command ); 630 630 631 631 for( h = global.help; h; h = h->next ) -
otr.c
rad2d8bc r8358691 84 84 /** otr sub-command handlers: **/ 85 85 86 static void cmd_otr(irc_t *irc, char **args); 86 87 void cmd_otr_connect(irc_t *irc, char **args); 87 88 void cmd_otr_disconnect(irc_t *irc, char **args); … … 199 200 global.otr_ops.account_name = &op_account_name; 200 201 global.otr_ops.account_name_free = NULL; 202 203 root_command_add( "otr", 1, cmd_otr, 0 ); 201 204 } 202 205 … … 418 421 } 419 422 420 void cmd_otr(irc_t *irc, char **args)423 static void cmd_otr(irc_t *irc, char **args) 421 424 { 422 425 const command_t *cmd; -
otr.h
rad2d8bc r8358691 39 39 struct im_connection; 40 40 struct account; 41 42 // 'otr' root command, hooked up in root_commands.c43 void cmd_otr(struct irc *, char **args);44 41 45 42 -
root_commands.c
rad2d8bc r8358691 29 29 #include "help.h" 30 30 #include "ipc.h" 31 #include "otr.h"32 31 33 32 void root_command_string( irc_t *irc, char *command ) … … 56 55 57 56 len = strlen( cmd[0] ); 58 for( i = 0; commands[i].command; i++ )59 if( g_strncasecmp( commands[i].command, cmd[0], len ) == 0 )60 { 61 if( commands[i+1].command &&62 g_strncasecmp( commands[i+1].command, cmd[0], len ) == 0 )57 for( i = 0; root_commands[i].command; i++ ) 58 if( g_strncasecmp( root_commands[i].command, cmd[0], len ) == 0 ) 59 { 60 if( root_commands[i+1].command && 61 g_strncasecmp( root_commands[i+1].command, cmd[0], len ) == 0 ) 63 62 /* Only match on the first letters if the match is unique. */ 64 63 break; 65 64 66 MIN_ARGS( commands[i].required_parameters );65 MIN_ARGS( root_commands[i].required_parameters ); 67 66 68 commands[i].execute( irc, cmd );67 root_commands[i].execute( irc, cmd ); 69 68 return; 70 69 } … … 1325 1324 1326 1325 /* IMPORTANT: Keep this list sorted! The short command logic needs that. */ 1327 co nst command_tcommands[] = {1326 command_t root_commands[] = { 1328 1327 { "account", 1, cmd_account, 0 }, 1329 1328 { "add", 2, cmd_add, 0 }, … … 1340 1339 { "info", 1, cmd_info, 0 }, 1341 1340 { "no", 0, cmd_yesno, 0 }, 1342 { "otr", 1, cmd_otr, 0 },1343 1341 { "qlist", 0, cmd_qlist, 0 }, 1344 1342 { "register", 1, cmd_register, 0 }, … … 1349 1347 { "transfer", 0, cmd_transfer, 0 }, 1350 1348 { "yes", 0, cmd_yesno, 0 }, 1351 { NULL } 1349 /* Not expecting too many plugins adding root commands so just make a 1350 dumb array with some empty entried at the end. */ 1351 { NULL }, 1352 { NULL }, 1353 { NULL }, 1354 { NULL }, 1355 { NULL }, 1356 { NULL }, 1357 { NULL }, 1358 { NULL }, 1359 { NULL }, 1352 1360 }; 1361 static const int num_root_commands = sizeof( root_commands ) / sizeof( command_t ); 1362 1363 gboolean root_command_add( const char *command, int params, void (*func)(irc_t *, char **args), int flags ) 1364 { 1365 int i; 1366 1367 if( root_commands[num_root_commands-2].command ) 1368 /* Planning fail! List is full. */ 1369 return FALSE; 1370 1371 for( i = 0; root_commands[i].command; i++ ) 1372 { 1373 if( g_strcasecmp( root_commands[i].command, command ) == 0 ) 1374 return FALSE; 1375 else if( g_strcasecmp( root_commands[i].command, command ) > 0 ) 1376 break; 1377 } 1378 memmove( root_commands + i + 1, root_commands + i, 1379 sizeof( command_t ) * ( num_root_commands - i - 1 ) ); 1380 1381 root_commands[i].command = g_strdup( command ); 1382 root_commands[i].required_parameters = params; 1383 root_commands[i].execute = func; 1384 root_commands[i].flags = flags; 1385 1386 return TRUE; 1387 }
Note: See TracChangeset
for help on using the changeset viewer.