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