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"
49 free_handleinfohandler();
53 static int load_mysql_config() {
54 char mysql_host[MAXLEN], mysql_port_str[MAXLEN], mysql_user[MAXLEN], mysql_pass[MAXLEN], mysql_base[MAXLEN];
56 if(loadINI("neonserv.ini") == FILE_SUCCESS) {
58 ReadString("MySQL", "host", mysql_host);
60 perror("invalid neonserv.ini: missing MySQL host");
63 mysql_port_str[0] = '\0';
64 ReadString("MySQL", "port", mysql_port_str);
65 mysql_serverport = atoi(mysql_port_str);
67 mysql_serverport = 3306;
69 ReadString("MySQL", "user", mysql_user);
71 perror("invalid neonserv.ini: missing MySQL user");
75 ReadString("MySQL", "pass", mysql_pass);
77 perror("invalid neonserv.ini: missing MySQL pass");
81 ReadString("MySQL", "base", mysql_base);
83 perror("invalid neonserv.ini: missing MySQL base");
87 perror("Unable to load neonserv.ini");
90 init_mysql(mysql_host, mysql_serverport, mysql_user, mysql_pass, mysql_base);
102 // Start Windows Sockets.
103 res = WSAStartup(MAKEWORD(2, 0), &wsadata);
106 perror("Unable to start Windows Sockets");
111 if(!load_mysql_config()) return 0;
121 init_handleinfohandler();
129 socket_wait = time(0) + SOCKET_SELECT_TIME;
131 socket_loop(SOCKET_SELECT_TIME);
132 } while(time(0) < socket_wait);
141 int stricmp (const char *s1, const char *s2)
143 if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
144 if (s2 == NULL) return *s1;
146 while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
148 if (*s1 == '\0') break;
154 int stricmplen (const char *s1, const char *s2, int len)
156 if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
157 if (s2 == NULL) return *s1;
160 while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
163 if (*s1 == '\0') break;