X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fircd_parse.c;h=950541c10c08749830b7092d0f7626388a6be103;hb=HEAD;hp=12dc6deb66faa12f582bb1ddf836a40aef61b3a4;hpb=b71e2c21fa000761fa80d66597f880496d9f45f2;p=NextIRCd.git
diff --git a/src/ircd_parse.c b/src/ircd_parse.c
index 12dc6de..950541c 100644
--- a/src/ircd_parse.c
+++ b/src/ircd_parse.c
@@ -15,8 +15,15 @@
* along with this program. If not, see .
*/
+#include
+#include
+
#include "tools.h"
#include "IOHandler/IOSockets.h"
+#include "ircd_parse.h"
+#include "struct_client.h"
+#include "struct_auth.h"
+#include "struct_servermsg.h"
typedef int cmd_client_t(struct Client *client, char *argv[], int argc);
typedef int cmd_auth_t(struct Auth *auth, char *argv[], int argc);
@@ -27,7 +34,7 @@ static struct ServerMsg parse_static_srvmsg;
#define PARSE_CLIFLAG_OPONLY 0x01
//include all commands
-#include "cmd_ping.h"
+#include "cmd.h"
struct {
@@ -54,10 +61,10 @@ struct {
unsigned int flags : 8;
} server;
-} parse_command_list {
+} 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 */
@@ -71,8 +78,8 @@ struct {
{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 */
},
@@ -83,9 +90,9 @@ static char *parse_irc_token(char **data) {
//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;
}
@@ -94,25 +101,24 @@ static char *parse_irc_token(char **data) {
}
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
- while (*line == ' ')
- *line++ = 0;
- if (*line == ':') {
+ while (*data == ' ')
+ *data++ = 0;
+ if (*data == ':') {
//the rest is a single parameter
- argv[*argc++] = line + 1;
+ argv[*argc++] = data + 1;
break;
}
- argv[*argc++] = line;
- if (argc >= maxargs)
+ argv[(*argc)++] = data;
+ if (*argc >= maxargs)
break;
- while (*line != ' ' && *line)
- line++;
+ while (*data != ' ' && *data)
+ data++;
}
return argv;
}
@@ -125,7 +131,7 @@ void parse_client_data(struct Client *client, char *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;
}
@@ -155,7 +161,7 @@ void parse_unauth_data(struct Auth *auth, char *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;
}
@@ -237,7 +243,7 @@ void parse_server_data(struct Server *server, struct IOSocketBuffer *buffer) {
srvmsg->destinations = malloc(sizeof(struct ServerMsgDstMap));
srvmsg->destinations->dstcount = 1;
srvmsg->destinations->dst[0].destination.srvnum = ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
- srvmsg->destinations->dst[0].destination.resolved_destination = 0;
+ srvmsg->destinations->dst[0].resolved_destination = 0;
break;
case SERVERMSG_TYPE_MULTICAST:
if(buflen < 5) {
@@ -255,7 +261,7 @@ void parse_server_data(struct Server *server, struct IOSocketBuffer *buffer) {
srvmsg->destinations->dstcount = srvcount;
for(i = 0; i < srvcount; i++) {
srvmsg->destinations->dst[i].destination.srvnum = ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
- srvmsg->destinations->dst[i].destination.resolved_destination = 0;
+ srvmsg->destinations->dst[i].resolved_destination = 0;
buf += 4;
buflen -= 4;
}
@@ -275,7 +281,7 @@ void parse_server_data(struct Server *server, struct IOSocketBuffer *buffer) {
goto parse_server_data_finish;
}
- srvmsg->arglen = srvmsg->msglen - (buf - buffer->buffer);
+ srvmsg->arglen = srvmsg->msglen - (buf - (unsigned char*)buffer->buffer);
srvmsg->args = buf;
int found = 0;
@@ -299,7 +305,7 @@ void parse_server_data(struct Server *server, struct IOSocketBuffer *buffer) {
memmove(buffer->buffer, buffer->buffer + srvmsg->msglen, srvmsg->msglen - buffer->bufpos);
buffer->bufpos -= srvmsg->msglen;
} else
- srvmsg->bufpos = 0;
+ buffer->bufpos = 0;
}
}