changed Makefile; build all commands as an own file
[NeonServV5.git] / main.c
diff --git a/main.c b/main.c
index 2fab2b070916bd59e2990f5665cdc75ef555a997..2fcc3dbec18349f0feae58657adb0cb8422dc1d1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2,38 +2,93 @@
 #include "main.h"
 #include "ClientSocket.h"
 #include "UserNode.h"
+#include "ChanNode.h"
+#include "IRCEvents.h"
+#include "IRCParser.h"
+#include "modcmd.h"
+#include "WHOHandler.h"
+#include "bots.h"
+#include "mysqlConn.h"
+#include "HandleInfoHandler.h"
+#include "lang.h"
+#include "tools.h"
+#include "timeq.h"
+#include "EventLogger.h"
+#include "ModeNode.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 "ChanNode.c"
-#include "ChanUser.c"
-#include "IRCEvents.c"
-#include "WHOHandler.c"
+time_t start_time;
 
-void just_test_it() {
-    struct UserNode *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, "pktest:pktest123", user); //pktest Hostmask(s): *@127.0.0.1
-    connect_socket(client);
+void cleanup() {
+    free_sockets();
+    free_parser();
+    free_UserNode();
+    free_ChanNode();
+    free_bind();
+    free_modcmd();
+    free_whoqueue();
+    free_bots();
+    free_mysql();
+    free_handleinfohandler();
+    free_lang();
 }
 
 int main(void)
 {
-    parser_init();
+    start_time = time(0);
+    
+    init_mysql();
+    init_lang();
+    init_parser();
     init_UserNode();
     init_ChanNode();
-    just_test_it();
+    init_ModeNode();
+    init_bind();
+       init_modcmd();
+    init_handleinfohandler();
+    init_tools();
+    init_bots();
+    
+    load_languages();
     
     time_t socket_wait;
     while(1) {
         socket_wait = time(0) + SOCKET_SELECT_TIME;
         do {
             socket_loop(SOCKET_SELECT_TIME);
-        } while(time(0) > socket_wait);
+        } while(time(0) < socket_wait);
+        timeq_tick();
+        loop_bots();
         clearTempUsers();
+        destroyEvents();
     }
 }
+
+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;
+}
+