Changeset 6c56f42


Ignore:
Timestamp:
2010-04-11T23:04:24Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
aa44bdd
Parents:
eabc9d2
Message:

Allow short versions of root commands (just give enough to match exactly
one command), for the lazy users.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • root_commands.c

    reabc9d2 r6c56f42  
    9292void root_command( irc_t *irc, char *cmd[] )
    9393{       
    94         int i;
     94        int i, len;
    9595       
    9696        if( !cmd[0] )
    9797                return;
    9898       
     99        len = strlen( cmd[0] );
    99100        for( i = 0; commands[i].command; i++ )
    100                 if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 )
    101                 {
     101                if( g_strncasecmp( commands[i].command, cmd[0], len ) == 0 )
     102                {
     103                        if( commands[i+1].command &&
     104                            g_strncasecmp( commands[i+1].command, cmd[0], len ) == 0 )
     105                                /* Only match on the first letters if the match is unique. */
     106                                break;
     107                       
    102108                        MIN_ARGS( commands[i].required_parameters );
    103109                       
     
    11791185#endif
    11801186
     1187/* IMPORTANT: Keep this list sorted! The short command logic needs that. */
    11811188const command_t commands[] = {
     1189        { "account",        1, cmd_account,        0 },
     1190        { "add",            2, cmd_add,            0 },
     1191        { "drop",           1, cmd_drop,           0 },
    11821192        { "help",           0, cmd_help,           0 },
    1183         { "account",        1, cmd_account,        0 },
    11841193        { "identify",       1, cmd_identify,       0 },
     1194        { "no",             0, cmd_yesno,          0 },
    11851195        { "register",       1, cmd_register,       0 },
    1186         { "drop",           1, cmd_drop,           0 },
     1196        { "remove",         1, cmd_remove,         0 },
     1197        { "rename",         2, cmd_rename,         0 },
    11871198        { "save",           0, cmd_save,           0 },
    1188         { "add",            2, cmd_add,            0 },
    1189         { "remove",         1, cmd_remove,         0 },
    1190 #if 0
    1191         { "info",           1, cmd_info,           0 },
    1192 #endif
    1193         { "rename",         2, cmd_rename,         0 },
    1194 #if 0
    1195         { "block",          1, cmd_block,          0 },
    1196         { "allow",          1, cmd_allow,          0 },
    1197 #endif
    11981199        { "set",            0, cmd_set,            0 },
    11991200        { "yes",            0, cmd_yesno,          0 },
    1200         { "no",             0, cmd_yesno,          0 },
    12011201#if 0
     1202        { "allow",          1, cmd_allow,          0 },
    12021203        { "blist",          0, cmd_blist,          0 },
     1204        { "block",          1, cmd_block,          0 },
     1205        { "chat",           1, cmd_chat,           0 },
     1206        { "ft",             0, cmd_transfer,       0 },
     1207        { "info",           1, cmd_info,           0 },
     1208        { "join_chat",      2, cmd_join_chat,      0 },
    12031209        { "nick",           1, cmd_nick,           0 },
    12041210        { "qlist",          0, cmd_qlist,          0 },
    1205         { "join_chat",      2, cmd_join_chat,      0 },
    1206         { "chat",           1, cmd_chat,           0 },
    12071211        { "transfer",       0, cmd_transfer,       0 },
    12081212#endif
Note: See TracChangeset for help on using the changeset viewer.