-/* 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
*/
#include "mysqlConn.h"
+#include "ConfigParser.h"
+#include "tools.h"
#define DATABASE_VERSION "20"
static void show_mysql_error();
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();