--- mqtt/src/mqttd.c 2011/11/29 22:42:23 1.1.1.1.2.2 +++ mqtt/src/mqttd.c 2011/11/29 23:23:31 1.1.1.1.2.3 @@ -23,6 +23,9 @@ int main(int argc, char **argv) { char ch, szCfgName[MAXPATHLEN]; + register int i; + sqlite3 *acc = NULL, *pub = NULL; + FILE *logg = NULL; strlcpy(szCfgName, DEFAULT_CONFIG, sizeof szCfgName); while ((ch = getopt(argc, argv, "hvc:")) != -1) @@ -45,7 +48,37 @@ main(int argc, char **argv) printf("Error:: can't load #%d - %s\n", cfg_GetErrno(), cfg_GetError()); return 1; } + for (i = 0; i < 3; i++) + if (!mqttLoadRTLM(&cfg, i)) { + printf("Error:: Can't load RTL module\n"); + while (i--) + mqttUnloadRTLM(i); + UnloadConfig(&cfg); + return 2; + } + acc = call.OpenACC(&cfg); + if (!acc) + goto end; + pub = call.OpenPUB(&cfg); + if (!pub) + goto end; + logg = call.OpenLOG(&cfg); + if (!logg) + goto end; + if (mqttMkDir(&cfg)) { + printf("Error:: in statedir #%d - %s\n", errno, strerror(errno)); + goto end; + } + + VERB(2) printf("Service is ready for start engine ...\n"); + +end: + call.CloseLOG(logg); + call.ClosePUB(pub); + call.CloseACC(acc); + for (i = 0; i < 3; i++) + mqttUnloadRTLM(i); UnloadConfig(&cfg); return 0; }