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