X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmain.c;h=183ebaedb3e1e205215b51ed0a8c7395d9beb91d;hb=be180588e158f3b1297ffaf3a715577fb3d73f85;hp=0aa1a1bb8b2bec5be0908f34ec345c7ccb5e78e4;hpb=8942135758dbad0f07add7c1e2567867d4f53d6b;p=NeonServV5.git diff --git a/src/main.c b/src/main.c index 0aa1a1b..183ebae 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,19 @@ +/* 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 . + */ #include "main.h" #include "ClientSocket.h" @@ -15,6 +31,10 @@ #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; @@ -32,8 +52,44 @@ void cleanup() { 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 @@ -48,7 +104,9 @@ int main(void) } #endif - init_mysql(); + if(!load_mysql_config()) return 0; + + queue_init(); init_lang(); init_parser(); init_UserNode(); @@ -58,7 +116,9 @@ int main(void) init_modcmd(); init_handleinfohandler(); init_tools(); + register_commands(); init_bots(); + init_DBHelper(); load_languages(); @@ -72,6 +132,7 @@ int main(void) loop_bots(); clearTempUsers(); destroyEvents(); + queue_loop(); } }