Changes in root_commands.c [8358691:674a01d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r8358691 r674a01d 55 55 56 56 len = strlen( cmd[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 )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 ) 62 62 /* Only match on the first letters if the match is unique. */ 63 63 break; 64 64 65 MIN_ARGS( root_commands[i].required_parameters );65 MIN_ARGS( commands[i].required_parameters ); 66 66 67 root_commands[i].execute( irc, cmd );67 commands[i].execute( irc, cmd ); 68 68 return; 69 69 } … … 1284 1284 } 1285 1285 1286 static void cmd_nick( irc_t *irc, char **cmd ) 1287 { 1288 irc_usermsg( irc, "This command is deprecated. Try: account %s set display_name", cmd[1] ); 1289 } 1290 1286 1291 /* Maybe this should be a stand-alone command as well? */ 1287 1292 static void bitlbee_whatsnew( irc_t *irc ) 1288 1293 { 1289 1294 int last = set_getint( &irc->b->set, "last_version" ); 1290 GString *msg = g_string_new( "" ); 1291 char s[16]; 1295 char s[16], *msg; 1292 1296 1293 1297 if( last >= BITLBEE_VERSION_CODE ) 1294 1298 return; 1295 1299 1296 if( last < 0x010206 ) /* 1.2.6 */ 1297 { 1298 g_string_append( msg, 1299 "Twitter support. See \x02help account add twitter\x02.\n" ); 1300 } 1301 if( last < 0x010300 ) /* 1.3dev */ 1302 { 1303 g_string_append( msg, 1304 "Support for multiple configurable control channels, " 1305 "each with a subset of your contact list. See " 1306 "\x02help channels\x02 for more information.\n" 1307 "File transfer support for some protocols (more if " 1308 "you use libpurple). Just /DCC SEND stuff. Incoming " 1309 "files also become DCC transfers.\n" 1310 "Many more things, briefly described in " 1311 "\x02help news1.3\x02.\n" ); 1312 } 1313 1314 if( msg->len > 0 ) 1300 msg = help_get_whatsnew( &(global.help), last ); 1301 1302 if( msg ) 1315 1303 irc_usermsg( irc, "%s: This seems to be your first time using this " 1316 1304 "this version of BitlBee. Here's a list of new " 1317 1305 "features you may like to know about:\n\n%s\n", 1318 irc->user->nick, msg->str ); 1319 1320 g_string_free( msg, TRUE ); 1306 irc->user->nick, msg ); 1307 1308 g_free( msg ); 1309 1321 1310 g_snprintf( s, sizeof( s ), "%d", BITLBEE_VERSION_CODE ); 1322 1311 set_setstr( &irc->b->set, "last_version", s ); … … 1324 1313 1325 1314 /* IMPORTANT: Keep this list sorted! The short command logic needs that. */ 1326 co mmand_t root_commands[] = {1315 const command_t commands[] = { 1327 1316 { "account", 1, cmd_account, 0 }, 1328 1317 { "add", 2, cmd_add, 0 }, … … 1338 1327 { "identify", 1, cmd_identify, 0 }, 1339 1328 { "info", 1, cmd_info, 0 }, 1329 { "nick", 1, cmd_nick, 0 }, 1340 1330 { "no", 0, cmd_yesno, 0 }, 1341 1331 { "qlist", 0, cmd_qlist, 0 }, … … 1347 1337 { "transfer", 0, cmd_transfer, 0 }, 1348 1338 { "yes", 0, cmd_yesno, 0 }, 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 }, 1339 { NULL } 1360 1340 }; 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.