Changeset 8e419cb for commands.c
- Timestamp:
- 2006-01-10T21:35:08Z (18 years ago)
- Branches:
- master
- Children:
- a4dc9f7
- Parents:
- 3e91c3e (diff), dd8d4c5 (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
-
commands.c
r3e91c3e r8e419cb 32 32 #include <string.h> 33 33 34 co mmand_t commands[] = {34 const command_t commands[] = { 35 35 { "help", 0, cmd_help }, 36 36 { "identify", 1, cmd_identify }, … … 55 55 }; 56 56 57 int root_command_string( irc_t *irc, user_t *u, char *command, int flags ) 58 { 59 char *cmd[IRC_MAX_ARGS]; 60 char *s; 61 int k; 62 char q = 0; 63 64 memset( cmd, 0, sizeof( cmd ) ); 65 cmd[0] = command; 66 k = 1; 67 for( s = command; *s && k < ( IRC_MAX_ARGS - 1 ); s ++ ) 68 if( *s == ' ' && !q ) 69 { 70 *s = 0; 71 while( *++s == ' ' ); 72 if( *s == '"' || *s == '\'' ) 73 { 74 q = *s; 75 s ++; 76 } 77 if( *s ) 78 { 79 cmd[k++] = s; 80 s --; 81 } 82 } 83 else if( *s == q ) 84 { 85 q = *s = 0; 86 } 87 cmd[k] = NULL; 88 89 return( root_command( irc, cmd ) ); 90 } 91 92 int root_command( irc_t *irc, char *cmd[] ) 93 { 94 int i; 95 96 if( !cmd[0] ) 97 return( 0 ); 98 99 for( i = 0; commands[i].command; i++ ) 100 if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) 101 { 102 if( !cmd[commands[i].required_parameters] ) 103 { 104 irc_usermsg( irc, "Not enough parameters given (need %d)", commands[i].required_parameters ); 105 return( 0 ); 106 } 107 commands[i].execute( irc, cmd ); 108 return( 1 ); 109 } 110 111 irc_usermsg( irc, "Unknown command: %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[0] ); 112 113 return( 1 ); 114 } 115 57 116 int cmd_help( irc_t *irc, char **cmd ) 58 117 { … … 97 156 case STORAGE_OK: 98 157 irc_usermsg( irc, "Password accepted" ); 158 irc_umode_set( irc, "+R", 1 ); 99 159 break; 100 160 default: … … 122 182 case STORAGE_OK: 123 183 irc->status = USTATUS_IDENTIFIED; 184 irc_umode_set( irc, "+R", 1 ); 124 185 break; 125 186 … … 146 207 case STORAGE_OK: 147 208 irc_setpass( irc, NULL ); 209 irc->status = USTATUS_LOGGED_IN; 210 irc_umode_set( irc, "-R", 1 ); 148 211 irc_usermsg( irc, "Account `%s' removed", irc->nick ); 149 212 return( 0 );
Note: See TracChangeset
for help on using the changeset viewer.