+/* main.c - NeonServ v5.2
+ * Copyright (C) 2011 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "main.h"
#include "ClientSocket.h"
#include "timeq.h"
#include "EventLogger.h"
#include "ModeNode.h"
+#include "IRCQueue.h"
+#include "DBHelper.h"
+#include "commands.h"
+#include "ConfigParser.h"
time_t start_time;
free_lang();
}
+static int load_mysql_config() {
+ char *mysql_host, *mysql_user, *mysql_pass, *mysql_base;
+ int mysql_serverport;
+ if(loadConfig("neonserv.conf")) {
+ mysql_host = get_string_field("MySQL.host");
+ if(!mysql_host) {
+ perror("invalid neonserv.conf: missing MySQL.host");
+ return 0;
+ }
+ mysql_serverport = get_int_field("MySQL.port");
+ if(!mysql_serverport)
+ mysql_serverport = 3306;
+ mysql_user = get_string_field("MySQL.user");
+ if(!mysql_user) {
+ perror("invalid neonserv.conf: missing MySQL.user");
+ return 0;
+ }
+ mysql_pass = get_string_field("MySQL.pass");
+ if(!mysql_pass) {
+ perror("invalid neonserv.conf: missing MySQL.pass");
+ return 0;
+ }
+ mysql_base = get_string_field("MySQL.base");
+ if(!mysql_base) {
+ perror("invalid neonserv.conf: missing MySQL base");
+ return 0;
+ }
+ } else {
+ perror("Unable to load neonserv.conf");
+ return 0;
+ }
+ init_mysql(mysql_host, mysql_serverport, mysql_user, mysql_pass, mysql_base);
+ return 1;
+}
+
int main(void)
{
+
start_time = time(0);
#ifdef WIN32
}
#endif
- init_mysql();
+ if(!load_mysql_config()) return 0;
+
+ queue_init();
init_lang();
init_parser();
init_UserNode();
init_modcmd();
init_handleinfohandler();
init_tools();
+ register_commands();
init_bots();
+ init_DBHelper();
load_languages();
loop_bots();
clearTempUsers();
destroyEvents();
+ queue_loop();
}
}