--- mqtt/src/dl.c 2011/11/23 00:42:16 1.1.2.1 +++ mqtt/src/dl.c 2011/11/23 08:09:40 1.1.2.3 @@ -25,13 +25,13 @@ mqttLog(const char *fmt, ...) void * mqttLoadRTLM(sl_config *cfg, int modtype) { - char *str; + const char *str; void *rtlm = NULL; if (!cfg) return NULL; - str = CFG(cfg_GetAttribute(cfg, CFG("mqttd"), CFG(modtype ? "pub_file" : "acc_file"))); + str = (const char*) CFG(cfg_GetAttribute(cfg, CFG("mqttd"), CFG(modtype ? "pub_file" : "acc_file"))); if (!str) { mqttLog("Error:: RTL module not found\n"); return NULL; @@ -69,4 +69,22 @@ void mqttUnloadRTLM(int modtype) { dlclose((modtype ? pub_rtlm : acc_rtlm)); +} + +inline int +mqttMkDir(sl_config *cfg) +{ + const char *str; + + if (!cfg) + return -1; + + str = (const char*) cfg_GetAttribute(cfg, CFG("mqttd"), CFG("statedir")); + if (!str) + return -1; + + if (mkdir(str, 0600) == -1 && errno != EEXIST) + return -1; + + return 0; }