X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FmysqlConn.c;h=4673c7dbe7c8767014ee2d5586a4fb872cca91d6;hb=88751acefe20e568fc945d7e5f5c11e0a9c7be60;hp=79c82e9d4194f49514cf14aa8202d4461fc63312;hpb=7289d420ddc81d9975ed6d55dfdfd70dff2b2d48;p=NeonServV5.git diff --git a/src/mysqlConn.c b/src/mysqlConn.c index 79c82e9..4673c7d 100644 --- a/src/mysqlConn.c +++ b/src/mysqlConn.c @@ -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();