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