moved all modes to an extra ModeNode struct
[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 #include "ModeNode.h"
18
19 time_t start_time;
20
21 void cleanup() {
22     free_sockets();
23     free_parser();
24     free_UserNode();
25     free_ChanNode();
26     free_bind();
27     free_modcmd();
28     free_whoqueue();
29     free_bots();
30     free_mysql();
31     free_handleinfohandler();
32     free_lang();
33 }
34
35 int main(void)
36 {
37     start_time = time(0);
38     
39     init_mysql();
40     init_lang();
41     init_parser();
42     init_UserNode();
43     init_ChanNode();
44     init_ModeNode();
45     init_bind();
46         init_modcmd();
47     init_handleinfohandler();
48     init_tools();
49     init_bots();
50     
51     time_t socket_wait;
52     while(1) {
53         socket_wait = time(0) + SOCKET_SELECT_TIME;
54         do {
55             socket_loop(SOCKET_SELECT_TIME);
56         } while(time(0) < socket_wait);
57         timeq_tick();
58         loop_bots();
59         clearTempUsers();
60         destroyEvents();
61     }
62 }
63
64 int stricmp (const char *s1, const char *s2)
65 {
66    if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
67    if (s2 == NULL) return *s1;
68    char c1, c2;
69    while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
70    {
71      if (*s1 == '\0') break;
72      ++s1; ++s2;
73    }
74    return c1 - c2;
75 }
76
77 int stricmplen (const char *s1, const char *s2, int len)
78 {
79    if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
80    if (s2 == NULL) return *s1;
81    char c1, c2;
82    int i = 0;
83    while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
84    {
85      i++;
86      if (*s1 == '\0') break;
87      ++s1; ++s2;
88      if(i == len) break;
89    }
90    return c1 - c2;
91 }
92