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