implemented event logger
[NeonServV5.git] / main.c
1
2 #include "main.h"
3 #include "ClientSocket.h"
4 #include "UserNode.h"
5 #include "ChanNode.h"
6 #include "IRCEvents.h"
7 #include "IRCParser.h"
8 #include "modcmd.h"
9 #include "WHOHandler.h"
10 #include "bots.h"
11 #include "mysqlConn.h"
12 #include "HandleInfoHandler.h"
13 #include "lang.h"
14 #include "tools.h"
15 #include "timeq.h"
16 #include "EventLogger.h"
17
18 time_t start_time;
19
20 void cleanup() {
21     free_sockets();
22     free_parser();
23     free_UserNode();
24     free_ChanNode();
25     free_bind();
26     free_modcmd();
27     free_whoqueue();
28     free_bots();
29     free_mysql();
30     free_handleinfohandler();
31     free_lang();
32 }
33
34 int main(void)
35 {
36     start_time = time(0);
37     
38     init_mysql();
39     init_lang();
40     init_parser();
41     init_UserNode();
42     init_ChanNode();
43     init_bind();
44         init_modcmd();
45     init_handleinfohandler();
46     init_tools();
47     init_bots();
48     
49     time_t socket_wait;
50     while(1) {
51         socket_wait = time(0) + SOCKET_SELECT_TIME;
52         do {
53             socket_loop(SOCKET_SELECT_TIME);
54         } while(time(0) < socket_wait);
55         timeq_tick();
56         loop_bots();
57         clearTempUsers();
58         destroyEvents();
59     }
60 }
61
62 int stricmp (const char *s1, const char *s2)
63 {
64    if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
65    if (s2 == NULL) return *s1;
66    char c1, c2;
67    while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
68    {
69      if (*s1 == '\0') break;
70      ++s1; ++s2;
71    }
72    return c1 - c2;
73 }
74
75 int stricmplen (const char *s1, const char *s2, int len)
76 {
77    if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
78    if (s2 == NULL) return *s1;
79    char c1, c2;
80    int i = 0;
81    while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
82    {
83      i++;
84      if (*s1 == '\0') break;
85      ++s1; ++s2;
86      if(i == len) break;
87    }
88    return c1 - c2;
89 }
90