#include "tools.h"
#include "IOHandler/IOSockets.h"
#include "ircd_parse.h"
-struct Server;
#include "struct_client.h"
#include "struct_auth.h"
#include "struct_servermsg.h"
#define PARSE_CLIFLAG_OPONLY 0x01
//include all commands
-#include "cmd_nick.h"
+#include "cmd.h"
struct {
} parse_command_list[] = {
{{"PING", "P"}, /* Ping Command */
- {NULL, 0, 1, 0}, /* Client */
- {NULL, 0, 1, 0}, /* Unauthed */
+ {cmd_ping_cli, 0, 1, 0}, /* Client */
+ {cmd_ping_auth, 0, 1, 0}, /* Unauthed */
{NULL, 0, 1, 0} /* Server */
},
{{"PASS", NULL}, /* PASS Command */
{NULL, 0, 1, 0} /* Server */
},
{{"USER", "U"}, /* User Command */
- {NULL, 0, 1, 0}, /* Client */
- {NULL, 0, 1, 0}, /* Unauthed */
+ {cmd_user_cli, 4, 4, 0}, /* Client */
+ {cmd_user_auth, 4, 1, 0}, /* Unauthed */
{NULL, 0, 1, 0} /* Server */
},
//find next " "
int i;
char *token = *data;
- for(i = 0; *data[i]; i++) {
- if(*data[i] != ' ') {
- *data[i] = '\0';
+ for(i = 0; (*data)[i]; i++) {
+ if((*data)[i] == ' ') {
+ (*data)[i] = '\0';
*data += i+1;
break;
}
}
static char **parse_irc_params(char *data, int *argc, int maxargs) {
- if(maxargs == 0) {
- *argc = 0;
+ *argc = 0;
+ if(maxargs == 0)
return NULL;
- }
char **argv = calloc(maxargs, sizeof(*argv));
while(*data) {
//skip leading spaces
argv[*argc++] = data + 1;
break;
}
- argv[*argc++] = data;
+ argv[(*argc)++] = data;
if (*argc >= maxargs)
break;
while (*data != ' ' && *data)
int found = 0;
int i;
for(i = 0; (parse_command_list[i].tokens.client || parse_command_list[i].tokens.server); i++) {
- if(stricmp(parse_command_list[i].tokens.client, token)) {
+ if(stricmp(parse_command_list[i].tokens.client, token) == 0) {
found = 1;
break;
}
int found = 0;
int i;
for(i = 0; (parse_command_list[i].tokens.client || parse_command_list[i].tokens.server); i++) {
- if(stricmp(parse_command_list[i].tokens.client, token)) {
+ if(stricmp(parse_command_list[i].tokens.client, token) == 0) {
found = 1;
break;
}
goto parse_server_data_finish;
}
- srvmsg->arglen = srvmsg->msglen - (buf - (unsigned char *)buffer->buffer);
+ srvmsg->arglen = srvmsg->msglen - (buf - (unsigned char*)buffer->buffer);
srvmsg->args = buf;
int found = 0;