X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FmysqlConn.c;h=867af65dccf8014afa546c88f43077d9094ce116;hb=19160d1e7f3bf41a6f7edbc5ec539d4588e1c69a;hp=a1fb75b6484d9ca98f76efc5f4ca8bad6efe4bb3;hpb=689da1db7e2517c187ce76c6c553e20d630a7f36;p=NeonServV5.git diff --git a/src/mysqlConn.c b/src/mysqlConn.c index a1fb75b..867af65 100644 --- a/src/mysqlConn.c +++ b/src/mysqlConn.c @@ -1,4 +1,4 @@ -/* mysqlConn.c - NeonServ v5.4 +/* 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,7 +16,8 @@ */ #include "mysqlConn.h" -#define DATABASE_VERSION "15" +#include "ConfigParser.h" +#define DATABASE_VERSION "20" static void show_mysql_error(); @@ -96,14 +97,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();