added some code
authorpk910 <philipp@zoelle1.de>
Thu, 24 Jul 2014 13:17:22 +0000 (15:17 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 24 Jul 2014 13:17:22 +0000 (15:17 +0200)
src/Makefile.am
src/cmd.h
src/cmd_nick.c
src/cmd_nick.h [deleted file]
src/cmd_user.c
src/ircd_parse.c
src/ircd_users.c
src/ircd_users.h

index 5fc1b20122ef930616ce5ccff4a8b23d1720c1dc..9534bf49723c36aecc336edbdc9d3309b2107699 100644 (file)
@@ -24,5 +24,6 @@ nextircd_SOURCES = \
        ircd_auth.c \
        ircd_users.c \
        cmd_nick.c \
+       cmd_user.c \
        main.c
 
index a2896a4768322472c45ca1d316163876f950a553..b3ec2690032e54d8f0b55b851374f98d94a23a98 100644 (file)
--- a/src/cmd.h
+++ b/src/cmd.h
@@ -22,9 +22,9 @@ struct Client;
 struct Auth;
 struct Server;
 
-
 int cmd_nick_cli(struct Client *client, char *argv[], int argc);
 int cmd_nick_auth(struct Auth *auth, char *argv[], int argc);
-
+int cmd_user_cli(struct Client *client, char *argv[], int argc);
+int cmd_user_auth(struct Auth *auth, char *argv[], int argc);
 
 #endif
index effb22f037c2b97f37b80ae667db9644287eb1d8..ae47e01eb590e66e5efae015d7695d2dc8c56e12 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
 
+#include <string.h>
+
 #include "cmd.h"
 #include "struct_auth.h"
+#include "ircd_users.h"
+#include "ircd_auth.h"
 
 int cmd_nick_cli(struct Client *client, char *argv[], int argc) {
        
@@ -24,6 +28,17 @@ int cmd_nick_cli(struct Client *client, char *argv[], int argc) {
 }
 
 int cmd_nick_auth(struct Auth *auth, char *argv[], int argc) {
+       char *nick = argv[0];
+       
+       if(!is_nick_valid(nick)) {
+               
+               return 0;
+       }
+       
+       strncpy(auth->nick, nick, NICKLEN);
+       auth->have_nick = 1;
+       
+       auth_try_finish(auth);
        
        return 0;
 }
diff --git a/src/cmd_nick.h b/src/cmd_nick.h
deleted file mode 100644 (file)
index 66df83d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* cmd_ping.h - NextIRCd
- * Copyright (C) 2012-2013  Philipp Kreil (pk910)
- * 
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License 
- * along with this program. If not, see <http://www.gnu.org/licenses/>. 
- */
-
-#ifndef _cmd_ping_h
-#define _cmd_ping_h
-
-struct Client;
-struct Auth;
-
-int cmd_nick_cli(struct Client *client, char *argv[], int argc);
-int cmd_nick_auth(struct Auth *auth, char *argv[], int argc);
-
-#endif
index ea06a082e73e2f3e2523e563f100515a3e28c1ba..f2a8d389865580bc2c27746214344af495f935a2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "cmd.h"
 #include "struct_auth.h"
+#include "struct_user.h"
 #include "ircd_users.h"
 #include "ircd_auth.h"
 
@@ -38,12 +39,12 @@ int cmd_user_auth(struct Auth *auth, char *argv[], int argc) {
                if(user == hostname)
                        user = "NoUser";
        }
-       if(!is_user_valid(user)) {
+       if(!is_ident_valid(user)) {
                // invalid user
                return 0;
        }
        
-       strncpy(auth->ident, user, USERLEN);
+       strncpy(auth->ident, user, IDENTLEN);
        strncpy(auth->realname, realname, REALLEN);
        auth->have_user = 1;
        
index 12dc6deb66faa12f582bb1ddf836a40aef61b3a4..54cdad20ef102d82455ea184b09d5f81b177a44f 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
 
+#include <stdlib.h>
+
 #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 +33,7 @@ static struct ServerMsg parse_static_srvmsg;
 #define PARSE_CLIFLAG_OPONLY 0x01
 
 //include all commands
-#include "cmd_ping.h"
+#include "cmd.h"
 
 
 struct {
@@ -54,7 +60,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 */
@@ -71,8 +77,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 */
        },
        
@@ -101,18 +107,18 @@ static char **parse_irc_params(char *data, int *argc, int maxargs) {
     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;
 }
@@ -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;
        }
 }
 
index 9faaacd2d9bfb1f9a30b0e5c21c5aeb6dbc46acc..f3fcbb5a635e59edc9485939cb4ca6bfbe46d730 100644 (file)
@@ -14,6 +14,9 @@
  * You should have received a copy of the GNU General Public License 
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
+
+#include <time.h>
+
 #include "struct_user.h"
 
 struct UserDictEntry {
@@ -33,6 +36,9 @@ void find_user_by_nick(char *nick) {
 }
 
 int is_nick_valid(char *nick) {
-       
+       return 1;
 }
 
+int is_ident_valid(char *ident) {
+       return 1;
+}
index a45a176af0dcdab849f56cbdd29f1cc48edaf2c8..56c77adfdf8482c59b394478b1ed9c3b63382802 100644 (file)
@@ -19,5 +19,6 @@
 #define _ircd_users_h
 
 int is_nick_valid(char *nick);
+int is_ident_valid(char *ident);
 
 #endif