added free functions to free everything (maybe a restart function later?)
[NeonServV5.git] / main.c
diff --git a/main.c b/main.c
index 79cd5d9d476906d026a61707d9aeada922d9fc63..58609a3ce906bcd315c21b9c785c2a8cf514d021 100644 (file)
--- a/main.c
+++ b/main.c
@@ -5,6 +5,9 @@
 #include "ChanNode.h"
 #include "IRCEvents.h"
 #include "IRCParser.h"
+#include "modcmd.h"
+#include "WHOHandler.h"
+#include "bots.h"
 
 void just_test_it() {
     struct UserNode *user;
@@ -15,6 +18,7 @@ void just_test_it() {
     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
+    client->flags |= SOCKET_FLAG_PREFERRED;
     connect_socket(client);
     
     user = addUser("TestBot2");
@@ -25,12 +29,25 @@ void just_test_it() {
     connect_socket(client);
 }
 
+void cleanup() {
+    free_sockets();
+    free_parser();
+    free_UserNode();
+    free_ChanNode();
+    free_bind();
+    free_modcmd();
+    free_whoqueue();
+    free_bots();
+}
+
 int main(void)
 {
-    parser_init();
+    init_parser();
     init_UserNode();
     init_ChanNode();
     init_bind();
+       init_modcmd();
+    init_bots();
     just_test_it();
     
     time_t socket_wait;
@@ -42,3 +59,33 @@ int main(void)
         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;
+}
+