Changeset 3b99524
- Timestamp:
- 2008-08-31T15:41:51Z (16 years ago)
- Branches:
- master
- Children:
- 07054a5
- Parents:
- 3611717
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r3611717 r3b99524 78 78 } 79 79 80 #define MIN_ARGS( x, y... ) \ 81 do \ 82 { \ 83 int i; \ 84 for( i = 1; i <= x; i ++ ) \ 85 if( cmd[i] == NULL ) \ 86 { \ 87 irc_usermsg( irc, "Not enough parameters given (need %d).", x ); \ 88 return y; \ 89 } \ 90 } while( 0 ) 91 80 92 void root_command( irc_t *irc, char *cmd[] ) 81 93 { … … 88 100 if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) 89 101 { 90 if( !cmd[commands[i].required_parameters] ) 91 { 92 irc_usermsg( irc, "Not enough parameters given (need %d)", commands[i].required_parameters ); 93 return; 94 } 102 MIN_ARGS( commands[i].required_parameters ); 103 95 104 commands[i].execute( irc, cmd ); 96 105 return; … … 270 279 char *id; 271 280 272 if( !set_full ) 273 { 274 /* FIXME: Broken # */ 275 irc_usermsg( irc, "Not enough parameters given (need %d)", 3 ); 276 return 0; 277 } 281 MIN_ARGS( 3, 0 ); 278 282 279 283 if( ( tmp = strchr( set_full, '/' ) ) ) … … 374 378 struct prpl *prpl; 375 379 376 if( cmd[2] == NULL || cmd[3] == NULL || cmd[4] == NULL ) 377 { 378 irc_usermsg( irc, "Not enough parameters" ); 379 return; 380 } 380 MIN_ARGS( 4 ); 381 381 382 382 prpl = find_protocol( cmd[2] ); … … 400 400 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) 401 401 { 402 if( !cmd[2] ) 403 { 404 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); 405 } 406 else if( !( a = account_get( irc, cmd[2] ) ) ) 402 MIN_ARGS( 2 ); 403 404 if( !( a = account_get( irc, cmd[2] ) ) ) 407 405 { 408 406 irc_usermsg( irc, "Invalid account" ); … … 532 530 else if( g_strcasecmp( cmd[1], "set" ) == 0 ) 533 531 { 534 if( !cmd[2] ) 535 { 536 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); 537 return; 538 } 532 MIN_ARGS( 2 ); 539 533 540 534 cmd_set_real( irc, cmd + 1, cmd_account_set_findhead ); … … 1014 1008 if( g_strcasecmp( cmd[1], "add" ) == 0 ) 1015 1009 { 1016 if( !( cmd[2] && cmd[3] && cmd[4] ) ) 1017 { 1018 irc_usermsg( irc, "Not enough parameters given (need %d)", 4 ); 1019 return; 1020 } 1010 MIN_ARGS( 4 ); 1021 1011 1022 1012 if( !( acc = account_get( irc, cmd[2] ) ) ) … … 1053 1043 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) 1054 1044 { 1055 if( !cmd[2] ) 1056 { 1057 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); 1058 return; 1059 } 1045 MIN_ARGS( 2 ); 1060 1046 1061 1047 if( ( c = chat_get( irc, cmd[2] ) ) ) … … 1071 1057 { 1072 1058 user_t *u; 1073 1074 if( !cmd[2] ) 1075 { 1076 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); 1077 return; 1078 } 1059 1060 MIN_ARGS( 2 ); 1079 1061 1080 1062 if( ( u = user_find( irc, cmd[2] ) ) && u->ic && u->ic->acc->prpl->chat_with )
Note: See TracChangeset
for help on using the changeset viewer.