-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);