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"
37 #include "ConfigParser.h"
51 free_handleinfohandler();
55 static int load_mysql_config() {
56 char *mysql_host, *mysql_user, *mysql_pass, *mysql_base;
58 if(loadConfig("neonserv.conf")) {
59 mysql_host = get_string_field("MySQL.host");
61 perror("invalid neonserv.conf: missing MySQL.host");
64 mysql_serverport = get_int_field("MySQL.port");
66 mysql_serverport = 3306;
67 mysql_user = get_string_field("MySQL.user");
69 perror("invalid neonserv.conf: missing MySQL.user");
72 mysql_pass = get_string_field("MySQL.pass");
74 perror("invalid neonserv.conf: missing MySQL.pass");
77 mysql_base = get_string_field("MySQL.base");
79 perror("invalid neonserv.conf: missing MySQL base");
83 perror("Unable to load neonserv.conf");
86 init_mysql(mysql_host, mysql_serverport, mysql_user, mysql_pass, mysql_base);
98 // Start Windows Sockets.
99 res = WSAStartup(MAKEWORD(2, 0), &wsadata);
102 perror("Unable to start Windows Sockets");
107 if(!load_mysql_config()) return 0;
117 init_handleinfohandler();
127 socket_wait = time(0) + SOCKET_SELECT_TIME;
129 socket_loop(SOCKET_SELECT_TIME);
130 } while(time(0) < socket_wait);
139 int stricmp (const char *s1, const char *s2)
141 if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
142 if (s2 == NULL) return *s1;
144 while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
146 if (*s1 == '\0') break;
152 int stricmplen (const char *s1, const char *s2, int len)
154 if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
155 if (s2 == NULL) return *s1;
158 while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
161 if (*s1 == '\0') break;