1 /* main.c - NeonServ v5.2
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"
50 free_handleinfohandler();
54 static int load_mysql_config() {
55 char mysql_host[MAXLEN], mysql_port_str[MAXLEN], mysql_user[MAXLEN], mysql_pass[MAXLEN], mysql_base[MAXLEN];
57 if(loadINI("neonserv.ini") == FILE_SUCCESS) {
59 ReadString("MySQL", "host", mysql_host);
61 perror("invalid neonserv.ini: missing MySQL host");
64 mysql_port_str[0] = '\0';
65 ReadString("MySQL", "port", mysql_port_str);
66 mysql_serverport = atoi(mysql_port_str);
68 mysql_serverport = 3306;
70 ReadString("MySQL", "user", mysql_user);
72 perror("invalid neonserv.ini: missing MySQL user");
76 ReadString("MySQL", "pass", mysql_pass);
78 perror("invalid neonserv.ini: missing MySQL pass");
82 ReadString("MySQL", "base", mysql_base);
84 perror("invalid neonserv.ini: missing MySQL base");
88 perror("Unable to load neonserv.ini");
91 init_mysql(mysql_host, mysql_serverport, mysql_user, mysql_pass, mysql_base);
103 // Start Windows Sockets.
104 res = WSAStartup(MAKEWORD(2, 0), &wsadata);
107 perror("Unable to start Windows Sockets");
112 if(!load_mysql_config()) return 0;
122 init_handleinfohandler();
131 socket_wait = time(0) + SOCKET_SELECT_TIME;
133 socket_loop(SOCKET_SELECT_TIME);
134 } while(time(0) < socket_wait);
143 int stricmp (const char *s1, const char *s2)
145 if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
146 if (s2 == NULL) return *s1;
148 while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
150 if (*s1 == '\0') break;
156 int stricmplen (const char *s1, const char *s2, int len)
158 if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
159 if (s2 == NULL) return *s1;
162 while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
165 if (*s1 == '\0') break;