added some code
[NextIRCd.git] / src / ircd_parse.c
index 1bfa8b78fbf482a29f47f372bff1b6491c2ed7f6..12dc6deb66faa12f582bb1ddf836a40aef61b3a4 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
 
-#include <stdlib.h>
-#include <string.h>
-
 #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"
 
 typedef int cmd_client_t(struct Client *client, char *argv[], int argc);
 typedef int cmd_auth_t(struct Auth *auth, char *argv[], int argc);
@@ -35,7 +27,7 @@ static struct ServerMsg parse_static_srvmsg;
 #define PARSE_CLIFLAG_OPONLY 0x01
 
 //include all commands
-#include "cmd_nick.h"
+#include "cmd_ping.h"
 
 
 struct {
@@ -62,7 +54,7 @@ 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 */
@@ -109,18 +101,18 @@ static char **parse_irc_params(char *data, int *argc, int maxargs) {
     char **argv = calloc(maxargs, sizeof(*argv));
     while(*data) {
         //skip leading spaces
-        while (*data == ' ')
-            *data++ = 0;
-        if (*data == ':') {
+        while (*line == ' ')
+            *line++ = 0;
+        if (*line == ':') {
            //the rest is a single parameter
-           argv[*argc++] = data + 1;
+           argv[*argc++] = line + 1;
            break;
         }
-        argv[*argc++] = data;
-        if (*argc >= maxargs)
+        argv[*argc++] = line;
+        if (argc >= maxargs)
             break;
-        while (*data != ' ' && *data)
-            data++;
+        while (*line != ' ' && *line)
+            line++;
     }
     return argv;
 }
@@ -245,7 +237,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].resolved_destination = 0;
+                       srvmsg->destinations->dst[0].destination.resolved_destination = 0;
                        break;
                case SERVERMSG_TYPE_MULTICAST:
                        if(buflen < 5) {
@@ -263,7 +255,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].resolved_destination = 0;
+                               srvmsg->destinations->dst[i].destination.resolved_destination = 0;
                                buf += 4;
                                buflen -= 4;
                        }
@@ -283,7 +275,7 @@ void parse_server_data(struct Server *server, struct IOSocketBuffer *buffer) {
                        goto parse_server_data_finish;
                }
                
-               srvmsg->arglen = srvmsg->msglen - (buf - (unsigned char *)buffer->buffer);
+               srvmsg->arglen = srvmsg->msglen - (buf - buffer->buffer);
                srvmsg->args = buf;
                
                int found = 0;
@@ -307,7 +299,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 
-                       buffer->bufpos = 0;
+                       srvmsg->bufpos = 0;
        }
 }