fixed last commit
[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 "lang.h"
13
14 void cleanup() {
15     free_sockets();
16     free_parser();
17     free_UserNode();
18     free_ChanNode();
19     free_bind();
20     free_modcmd();
21     free_whoqueue();
22     free_bots();
23     free_mysql();
24     free_lang();
25 }
26
27 int main(void)
28 {
29     init_mysql();
30     init_lang();
31     init_parser();
32     init_UserNode();
33     init_ChanNode();
34     init_bind();
35         init_modcmd();
36     init_bots();
37     
38     time_t socket_wait;
39     while(1) {
40         socket_wait = time(0) + SOCKET_SELECT_TIME;
41         do {
42             socket_loop(SOCKET_SELECT_TIME);
43         } while(time(0) > socket_wait);
44         clearTempUsers();
45     }
46 }
47
48 int stricmp (const char *s1, const char *s2)
49 {
50    if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
51    if (s2 == NULL) return *s1;
52    char c1, c2;
53    while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
54    {
55      if (*s1 == '\0') break;
56      ++s1; ++s2;
57    }
58    return c1 - c2;
59 }
60
61 int stricmplen (const char *s1, const char *s2, int len)
62 {
63    if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
64    if (s2 == NULL) return *s1;
65    char c1, c2;
66    int i = 0;
67    while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
68    {
69      i++;
70      if (*s1 == '\0') break;
71      ++s1; ++s2;
72      if(i == len) break;
73    }
74    return c1 - c2;
75 }
76