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