--- mqtt/src/mqttd.c 2012/01/27 15:05:38 1.2 +++ mqtt/src/mqttd.c 2012/04/11 15:08:27 1.2.2.1 @@ -7,7 +7,7 @@ io_enableDEBUG; -sl_config cfg; +cfg_root_t cfg; sessions_t Sessions; sched_root_task_t *root; sqlite3 *acc, *pub; @@ -37,8 +37,8 @@ sigHand(int sig) switch (sig) { case SIGHUP: - UnloadConfig(&cfg); - if (!LoadConfig(szCfgName, &cfg)) { + cfgUnloadConfig(&cfg); + if (!cfgLoadConfig(szCfgName, &cfg)) { ioDEBUG(1, "Config reload OK!"); break; } @@ -60,11 +60,12 @@ sigHand(int sig) int main(int argc, char **argv) { - char ch, batch = 0, szStr[STRSIZ]; + char ch, batch = 0; register int i; int sock = -1, ret = 0; struct passwd *pass; struct sigaction sa; + ait_val_t v; TAILQ_INIT(&Sessions); @@ -88,19 +89,20 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (LoadConfig(szCfgName, &cfg)) { + if (cfgLoadConfig(szCfgName, &cfg)) { printf("Error:: can't load #%d - %s\n", cfg_GetErrno(), cfg_GetError()); return 1; } pthread_mutex_init(&mtx_sess, NULL); pthread_mutex_init(&mtx_pub, NULL); openlog("mqttd", LOG_PID | LOG_CONS, LOG_DAEMON); + /* load 3 plugins */ for (i = 0; i < 3; i++) if (!mqttLoadRTLM(&cfg, i)) { printf("Error:: Can't load RTL module\n"); while (i--) mqttUnloadRTLM(i); - UnloadConfig(&cfg); + cfgUnloadConfig(&cfg); closelog(); pthread_mutex_destroy(&mtx_pub); pthread_mutex_destroy(&mtx_sess); @@ -169,8 +171,9 @@ main(int argc, char **argv) goto end; } - cfg_LoadAttribute(&cfg, CFG("mqttd"), CFG("user"), CFG(szStr), sizeof szStr, MQTT_USER); - pass = getpwnam(szStr); + cfg_loadAttribute(&cfg, "mqttd", "user", &v, MQTT_USER); + pass = getpwnam(AIT_GET_STR(&v)); + AIT_FREE_VAL(&v); if (pass) { setgid(pass->pw_gid); setuid(pass->pw_uid); @@ -194,7 +197,7 @@ end: for (i = 0; i < 3; i++) mqttUnloadRTLM(i); closelog(); - UnloadConfig(&cfg); + cfgUnloadConfig(&cfg); pthread_mutex_destroy(&mtx_pub); pthread_mutex_destroy(&mtx_sess); return ret;