]> PatchyGit - patchyircd.git/commitdiff
split parser in a separate func
authorEgor <egor@patchysicp.xyz>
Fri, 6 May 2022 07:57:33 +0000 (10:57 +0300)
committerEgor <egor@patchysicp.xyz>
Fri, 6 May 2022 07:57:33 +0000 (10:57 +0300)
irc.c
irc.h
net.c

diff --git a/irc.c b/irc.c
index e40ece9..6228066 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -11,9 +11,8 @@ const char *hostname = "irc.patchysicp.xyz";
 void sendbuf(struct client_data *client) {
        send_log(client->FD, databuf.buf, databuf.len, 0);
 }
-int processPacket(struct client_data *client) {
+int parsePacket(struct client_data *client) {
        char *source = NULL;
-       (void)source;
        char *command = NULL;
        char *args[16] = {0};
        int argc = 0;
@@ -82,6 +81,10 @@ int processPacket(struct client_data *client) {
                if (i == argc-1)
                        printf("\n");
        }
+       return processPacket(client, source, command, argc, args);
+}
+int processPacket(struct client_data *client, char *source, char *command, int argc, char *args[]) {
+       (void)source;
        databuf.len = 0;
        if(strcmp(command, "PING") == 0) {
                if (!args[0]) // FIXME: error message
diff --git a/irc.h b/irc.h
index a413f33..45efa7d 100644 (file)
--- a/irc.h
+++ b/irc.h
@@ -5,7 +5,8 @@
 #include "net.h"
 #include "util.h"
 
-int processPacket(struct client_data *client);
+int parsePacket(struct client_data *client);
+int processPacket(struct client_data *client, char *source, char *command, int argc, char *args[]);
 void newUser(struct client_data *client);
 void sendMOTD(struct client_data *client);
 void setNick(struct client_data *client, char* nickname);
diff --git a/net.c b/net.c
index ffe6220..15a9ffa 100644 (file)
--- a/net.c
+++ b/net.c
@@ -105,7 +105,7 @@ void recvProc(struct client_data *cl) {
                while(1){
                        x = memchr(cl->buf, '\n', cl->bufLen);
                        if(!x) break;
-                       packetReturn = processPacket(cl);
+                       packetReturn = parsePacket(cl);
                        // Client QUIT
                        if(packetReturn == 1) {
                                return;