X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FmysqlConn.c;h=4673c7dbe7c8767014ee2d5586a4fb872cca91d6;hb=88751acefe20e568fc945d7e5f5c11e0a9c7be60;hp=e76641044d7f69f719f12266dd79684be50a1be3;hpb=4b9de3472bf8bb35214bd3c31289b7c601304686;p=NeonServV5.git diff --git a/src/mysqlConn.c b/src/mysqlConn.c index e766410..4673c7d 100644 --- a/src/mysqlConn.c +++ b/src/mysqlConn.c @@ -1,4 +1,4 @@ -/* mysqlConn.c - NeonServ v5.5 +/* mysqlConn.c - NeonServ v5.6 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -16,6 +16,8 @@ */ #include "mysqlConn.h" +#include "ConfigParser.h" +#include "tools.h" #define DATABASE_VERSION "20" static void show_mysql_error(); @@ -96,14 +98,39 @@ void mysql_free() { mysql_conn->escaped_strings = NULL; } -void init_mysql(char *host, int port, char *user, char *pass, char *base) { - THREAD_MUTEX_INIT(synchronized); - mysql_host = strdup(host); - mysql_serverport = port; - mysql_user = strdup(user); - mysql_pass = strdup(pass); - mysql_base = strdup(base); +int reload_mysql() { + char *new_mysql_host = get_string_field("MySQL.host"); + char *new_mysql_user = get_string_field("MySQL.user"); + char *new_mysql_pass = get_string_field("MySQL.pass"); + char *new_mysql_base = get_string_field("MySQL.base"); + if(!(new_mysql_host && new_mysql_user && new_mysql_pass && new_mysql_base)) + return 0; + + //replace login data + if(mysql_host) + free(mysql_host); + mysql_host = strdup(new_mysql_host); + + if(mysql_user) + free(mysql_user); + mysql_user = strdup(new_mysql_user); + + if(mysql_pass) + free(mysql_pass); + mysql_pass = strdup(new_mysql_pass); + if(mysql_base) + free(mysql_base); + mysql_base = strdup(new_mysql_base); + + mysql_serverport = get_int_field("MySQL.port"); + if(!mysql_serverport) + mysql_serverport = 3306; + return 1; +} + +void init_mysql() { + THREAD_MUTEX_INIT(synchronized); MYSQL *mysql_conn = get_mysql_conn();