X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmain.c;h=47de2620ac71a63571a354b65a89ff16daba0d80;hb=9d2bbd34f22639745b23b7916ed3123c0dfed557;hp=0aa1a1bb8b2bec5be0908f34ec345c7ccb5e78e4;hpb=34480d6d55eeea4b6615d89d3ecb1976cff5e423;p=NeonServV5.git diff --git a/src/main.c b/src/main.c index 0aa1a1b..47de262 100644 --- a/src/main.c +++ b/src/main.c @@ -15,6 +15,7 @@ #include "timeq.h" #include "EventLogger.h" #include "ModeNode.h" +#include "lib/ini.h" time_t start_time; @@ -32,8 +33,50 @@ void cleanup() { free_lang(); } +static int load_mysql_config() { + char mysql_host[MAXLEN], mysql_port_str[MAXLEN], mysql_user[MAXLEN], mysql_pass[MAXLEN], mysql_base[MAXLEN]; + int mysql_serverport; + if(loadINI("neonserv.ini") == FILE_SUCCESS) { + mysql_host[0] = '\0'; + ReadString("MySQL", "host", mysql_host); + if(!*mysql_host) { + perror("invalid neonserv.ini: missing MySQL host"); + return 0; + } + mysql_port_str[0] = '\0'; + ReadString("MySQL", "port", mysql_port_str); + mysql_serverport = atoi(mysql_port_str); + if(!mysql_serverport) + mysql_serverport = 3306; + mysql_user[0] = '\0'; + ReadString("MySQL", "user", mysql_user); + if(!*mysql_user) { + perror("invalid neonserv.ini: missing MySQL user"); + return 0; + } + mysql_pass[0] = '\0'; + ReadString("MySQL", "pass", mysql_pass); + if(!*mysql_pass) { + perror("invalid neonserv.ini: missing MySQL pass"); + return 0; + } + mysql_base[0] = '\0'; + ReadString("MySQL", "base", mysql_base); + if(!*mysql_base) { + perror("invalid neonserv.ini: missing MySQL base"); + return 0; + } + } else { + perror("Unable to load neonserv.ini"); + 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 +91,8 @@ int main(void) } #endif - init_mysql(); + if(!load_mysql_config()) return 0; + init_lang(); init_parser(); init_UserNode();