wrote modcmd bind system
[NeonServV5.git] / main.c
diff --git a/main.c b/main.c
index e12f79de2a6d3fc8981797f459526199fab8ac9a..564e7b0cfa34db3f328ef80cdd13028c93792250 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2,21 +2,27 @@
 #include "main.h"
 #include "ClientSocket.h"
 #include "UserNode.h"
-
-//all c files - so we don't need a big Makefile right now :D
-#include "ClientSocket.c"
-#include "IRCParser.c"
-#include "UserNode.c"
-
-#include "ChanUser.h"
 #include "ChanNode.h"
+#include "IRCEvents.h"
+#include "IRCParser.h"
+#include "modcmd.h"
 
 void just_test_it() {
-    struct UserNode *user = addUser("TestBot");
+    struct UserNode *user;
+    struct ClientSocket *client;
+    
+    user = addUser("TestBot");
     strcpy(user->ident, "test");
     strcpy(user->realname, "testUser!");
     user->flags |= USERFLAG_ISBOT;
-    struct ClientSocket *client = create_socket("127.0.0.1", 6667, NULL, user);
+    client = create_socket("127.0.0.1", 6667, "pktest:pktest123", user); //pktest Hostmask(s): *@127.0.0.1
+    connect_socket(client);
+    
+    user = addUser("TestBot2");
+    strcpy(user->ident, "test");
+    strcpy(user->realname, "testUser!");
+    user->flags |= USERFLAG_ISBOT;
+    client = create_socket("127.0.0.1", 6667, "pktest:pktest123", user); //pktest Hostmask(s): *@127.0.0.1
     connect_socket(client);
 }
 
@@ -24,8 +30,47 @@ int main(void)
 {
     parser_init();
     init_UserNode();
+    init_ChanNode();
+    init_bind();
+       init_modcmd();
     just_test_it();
+    
+    time_t socket_wait;
     while(1) {
-        socket_loop(1);
+        socket_wait = time(0) + SOCKET_SELECT_TIME;
+        do {
+            socket_loop(SOCKET_SELECT_TIME);
+        } while(time(0) > socket_wait);
+        clearTempUsers();
     }
 }
+
+int stricmp (const char *s1, const char *s2)
+{
+   if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
+   if (s2 == NULL) return *s1;
+   char c1, c2;
+   while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
+   {
+     if (*s1 == '\0') break;
+     ++s1; ++s2;
+   }
+   return c1 - c2;
+}
+
+int stricmplen (const char *s1, const char *s2, int len)
+{
+   if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
+   if (s2 == NULL) return *s1;
+   char c1, c2;
+   int i = 0;
+   while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
+   {
+     i++;
+     if (*s1 == '\0') break;
+     ++s1; ++s2;
+     if(i == len) break;
+   }
+   return c1 - c2;
+}
+