1 /* main.c - NeonServ v5.1
2 * Copyright (C) 2011 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "ClientSocket.h"
22 #include "IRCEvents.h"
23 #include "IRCParser.h"
25 #include "WHOHandler.h"
27 #include "mysqlConn.h"
28 #include "HandleInfoHandler.h"
32 #include "EventLogger.h"
48 free_handleinfohandler();
52 static int load_mysql_config() {
53 char mysql_host[MAXLEN], mysql_port_str[MAXLEN], mysql_user[MAXLEN], mysql_pass[MAXLEN], mysql_base[MAXLEN];
55 if(loadINI("neonserv.ini") == FILE_SUCCESS) {
57 ReadString("MySQL", "host", mysql_host);
59 perror("invalid neonserv.ini: missing MySQL host");
62 mysql_port_str[0] = '\0';
63 ReadString("MySQL", "port", mysql_port_str);
64 mysql_serverport = atoi(mysql_port_str);
66 mysql_serverport = 3306;
68 ReadString("MySQL", "user", mysql_user);
70 perror("invalid neonserv.ini: missing MySQL user");
74 ReadString("MySQL", "pass", mysql_pass);
76 perror("invalid neonserv.ini: missing MySQL pass");
80 ReadString("MySQL", "base", mysql_base);
82 perror("invalid neonserv.ini: missing MySQL base");
86 perror("Unable to load neonserv.ini");
89 init_mysql(mysql_host, mysql_serverport, mysql_user, mysql_pass, mysql_base);
101 // Start Windows Sockets.
102 res = WSAStartup(MAKEWORD(2, 0), &wsadata);
105 perror("Unable to start Windows Sockets");
110 if(!load_mysql_config()) return 0;
119 init_handleinfohandler();
127 socket_wait = time(0) + SOCKET_SELECT_TIME;
129 socket_loop(SOCKET_SELECT_TIME);
130 } while(time(0) < socket_wait);
138 int stricmp (const char *s1, const char *s2)
140 if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
141 if (s2 == NULL) return *s1;
143 while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
145 if (*s1 == '\0') break;
151 int stricmplen (const char *s1, const char *s2, int len)
153 if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
154 if (s2 == NULL) return *s1;
157 while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
160 if (*s1 == '\0') break;