Changeset 6197702 for root_commands.c
- Timestamp:
- 2010-10-09T18:41:19Z (14 years ago)
- Branches:
- master
- Children:
- d150a9d
- Parents:
- 23b29c6 (diff), 27b407f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r23b29c6 r6197702 55 55 56 56 len = strlen( cmd[0] ); 57 for( i = 0; commands[i].command; i++ )58 if( g_strncasecmp( commands[i].command, cmd[0], len ) == 0 )59 { 60 if( commands[i+1].command &&61 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 ) 62 62 /* Only match on the first letters if the match is unique. */ 63 63 break; 64 64 65 MIN_ARGS( commands[i].required_parameters );65 MIN_ARGS( root_commands[i].required_parameters ); 66 66 67 commands[i].execute( irc, cmd );67 root_commands[i].execute( irc, cmd ); 68 68 return; 69 69 } … … 1313 1313 1314 1314 /* IMPORTANT: Keep this list sorted! The short command logic needs that. */ 1315 co nst command_tcommands[] = {1315 command_t root_commands[] = { 1316 1316 { "account", 1, cmd_account, 0 }, 1317 1317 { "add", 2, cmd_add, 0 }, … … 1337 1337 { "transfer", 0, cmd_transfer, 0 }, 1338 1338 { "yes", 0, cmd_yesno, 0 }, 1339 { NULL } 1339 /* Not expecting too many plugins adding root commands so just make a 1340 dumb array with some empty entried at the end. */ 1341 { NULL }, 1342 { NULL }, 1343 { NULL }, 1344 { NULL }, 1345 { NULL }, 1346 { NULL }, 1347 { NULL }, 1348 { NULL }, 1349 { NULL }, 1340 1350 }; 1351 static const int num_root_commands = sizeof( root_commands ) / sizeof( command_t ); 1352 1353 gboolean root_command_add( const char *command, int params, void (*func)(irc_t *, char **args), int flags ) 1354 { 1355 int i; 1356 1357 if( root_commands[num_root_commands-2].command ) 1358 /* Planning fail! List is full. */ 1359 return FALSE; 1360 1361 for( i = 0; root_commands[i].command; i++ ) 1362 { 1363 if( g_strcasecmp( root_commands[i].command, command ) == 0 ) 1364 return FALSE; 1365 else if( g_strcasecmp( root_commands[i].command, command ) > 0 ) 1366 break; 1367 } 1368 memmove( root_commands + i + 1, root_commands + i, 1369 sizeof( command_t ) * ( num_root_commands - i - 1 ) ); 1370 1371 root_commands[i].command = g_strdup( command ); 1372 root_commands[i].required_parameters = params; 1373 root_commands[i].execute = func; 1374 root_commands[i].flags = flags; 1375 1376 return TRUE; 1377 }
Note: See TracChangeset
for help on using the changeset viewer.