else
return false;
}
+
+int muse_client_get_module_index(char *module_name, int *module_index)
+{
+ int idx = 0;
+ char *str;
+ char *hosts;
+ char *host;
+ char *ptr = NULL;
+ bool module_name_matched = false;
+ dictionary *muse_client_dict;
+
+ g_return_val_if_fail(module_name, MM_ERROR_INVALID_ARGUMENT);
+ g_return_val_if_fail(module_index, MM_ERROR_INVALID_ARGUMENT);
+
+ LOGD("Enter");
+
+ muse_client_dict = iniparser_load(CONFFILE);
+ g_return_val_if_fail(muse_client_dict, PARSE_ERROR);
+
+ str = iniparser_getstring(muse_client_dict, MUSE_HOST, NULL);
+ if (!str) {
+ LOGE("Error - iniparser_getstring (%s)", MUSE_HOST);
+ iniparser_freedict(muse_client_dict);
+ return PARSE_ERROR;
+ }
+
+ hosts = strdup(str);
+ if (!hosts) {
+ LOGE("Error - hosts allocation");
+ iniparser_freedict(muse_client_dict);
+ return PARSE_ERROR;
+ }
+
+ host = strtok_r(hosts, INI_PARSER_COMMA, &ptr);
+
+ while (host) {
+ g_strstrip(host);
+ if (strncmp(module_name, host, strlen(host)) == 0) {
+ module_name_matched = true;
+ *module_index = idx;
+ break;
+ }
+
+ host = strtok_r(NULL, INI_PARSER_COMMA, &ptr);
+ idx++;
+ }
+
+ MUSE_FREE(hosts);
+
+ iniparser_freedict(muse_client_dict);
+
+ if (module_name_matched) {
+ LOGD("Leave");
+ return MM_ERROR_NONE;
+ } else {
+ LOGE("You have to check if [%s] is exact", module_name);
+ *module_index = MUSE_ERR;
+ LOGD("Leave");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+}
#include "muse_server_config.h"
#include "muse_server_private.h"
-#define PARSE_ERROR -1
-
static muse_server_config_t *g_muse_server_conf = NULL;
static int _muse_server_config_parser(void);
g_muse_server_conf->muse_dict = iniparser_load(CONFFILE);
g_return_val_if_fail(g_muse_server_conf->muse_dict, PARSE_ERROR);
- str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSEHOST, NULL);
+ str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSE_HOST, NULL);
if (!str) {
- LOGE("Error - iniparser_getstring (%s)", MUSEHOST);
+ LOGE("Error - iniparser_getstring (%s)", MUSE_HOST);
goto out;
}
goto out;
}
- str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSELOG, NULL);
+ str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSE_LOG, NULL);
if (!str) {
- LOGE("Error - iniparser_getstring (%s)", MUSELOG);
+ LOGE("Error - iniparser_getstring (%s)", MUSE_LOG);
goto out;
}
else
g_muse_server_conf->log_enabled = FALSE;
- str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSELOCK, NULL);
+ str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSE_LOCK, NULL);
if (!str) {
- LOGE("Error - iniparser_getstring (%s)", MUSELOCK);
+ LOGE("Error - iniparser_getstring (%s)", MUSE_LOCK);
goto out;
}
goto out;
}
- str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSEMINTIMEOUT, NULL);
+ str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSE_MIN_TIMEOUT, NULL);
if (!str) {
- LOGE("Error - iniparser_getstring (%s)", MUSEMINTIMEOUT);
+ LOGE("Error - iniparser_getstring (%s)", MUSE_MIN_TIMEOUT);
goto out;
}
goto out;
}
- str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSEMAXTIMEOUT, NULL);
+ str = iniparser_getstring(g_muse_server_conf->muse_dict, MUSE_MAX_TIMEOUT, NULL);
if (!str) {
- LOGE("Error - iniparser_getstring (%s)", MUSEMAXTIMEOUT);
+ LOGE("Error - iniparser_getstring (%s)", MUSE_MAX_TIMEOUT);
goto out;
}
goto out;
}
- str = iniparser_getstring(g_muse_server_conf->muse_dict, MEMORYTHRESHOLD, NULL);
+ str = iniparser_getstring(g_muse_server_conf->muse_dict, MEMORY_THRESHOLD, NULL);
if (!str) {
- LOGE("Error - iniparser_getstring (%s)", MEMORYTHRESHOLD);
+ LOGE("Error - iniparser_getstring (%s)", MEMORY_THRESHOLD);
goto out;
}
g_muse_server_conf->gst_param_cnt = 0;
for (; g_muse_server_conf->gst_param_cnt < MUSE_MAX_PARAM_NUM; g_muse_server_conf->gst_param_cnt++) {
memset(gst_param_value, 0, MUSE_MAX_MSG_LEN);
- snprintf(gst_param_value, strlen(MUSEGST) + 3, "%s%d", MUSEGST, g_muse_server_conf->gst_param_cnt + 1);
+ snprintf(gst_param_value, strlen(MUSE_GST) + 3, "%s%d", MUSE_GST, g_muse_server_conf->gst_param_cnt + 1);
str = iniparser_getstring(g_muse_server_conf->muse_dict, gst_param_value, NULL);
g_strstrip(str);
}
g_muse_server_conf->host_cnt = 0;
- host = strtok_r(g_muse_server_conf->hosts, COMMA, &ptr);
+ host = strtok_r(g_muse_server_conf->hosts, INI_PARSER_COMMA, &ptr);
while (host) {
host_cnt = g_muse_server_conf->host_cnt;
}
/* path */
- snprintf(host_name, MUSE_MAX_MSG_LEN, "%s%s%s", host, COLON, PATH);
+ snprintf(host_name, MUSE_MAX_MSG_LEN, "%s%s%s", host, INI_PARSER_COLON, PATH);
g_muse_server_conf->host_infos[host_cnt] = (host_info_t *) calloc(1, sizeof(host_info_t));
if (!g_muse_server_conf->host_infos[host_cnt]) {
LOGD("[%d] %s", host_cnt, g_muse_server_conf->host_infos[host_cnt]->path);
/* preloaded */
- snprintf(host_name, MUSE_MAX_MSG_LEN, "%s%s%s", host, COLON, PRELOADED);
+ snprintf(host_name, MUSE_MAX_MSG_LEN, "%s%s%s", host, INI_PARSER_COLON, PRELOADED);
g_muse_server_conf->host_infos[host_cnt]->preloaded =
strdup(iniparser_getstring(g_muse_server_conf->muse_dict, host_name, NULL));
}
/* timeout */
- snprintf(host_name, MUSE_MAX_MSG_LEN, "%s%s%s", host, COLON, TIMEOUT);
+ snprintf(host_name, MUSE_MAX_MSG_LEN, "%s%s%s", host, INI_PARSER_COLON, TIMEOUT);
g_muse_server_conf->host_infos[host_cnt]->timeout =
atoi(iniparser_getstring(g_muse_server_conf->muse_dict, host_name, NULL));
}
/* disable_watchdog_api */
- snprintf(host_name, MUSE_MAX_MSG_LEN, "%s%s%s", host, COLON, DIABLEWATCHDOGAPI);
+ snprintf(host_name, MUSE_MAX_MSG_LEN, "%s%s%s", host, INI_PARSER_COLON, DIABLE_WATCHDOG_API);
g_muse_server_conf->host_infos[host_cnt]->disable_watchdog_api =
atoi(iniparser_getstring(g_muse_server_conf->muse_dict, host_name, NULL));
- host = strtok_r(NULL, COMMA, &ptr);
+ host = strtok_r(NULL, INI_PARSER_COMMA, &ptr);
g_muse_server_conf->host_cnt++;
MUSE_FREE(host_name);
}
iniparser_freedict(g_muse_server_conf->muse_dict);
if (g_muse_server_conf->hosts) {
- host = strtok_r(g_muse_server_conf->hosts, COMMA, &ptr);
+ host = strtok_r(g_muse_server_conf->hosts, INI_PARSER_COMMA, &ptr);
g_muse_server_conf->host_cnt = 0;
while (host) {
MUSE_FREE(g_muse_server_conf->host_infos[g_muse_server_conf->host_cnt]->path);
MUSE_FREE(g_muse_server_conf->host_infos[g_muse_server_conf->host_cnt]->preloaded);
MUSE_FREE(g_muse_server_conf->host_infos[g_muse_server_conf->host_cnt]);
- host = strtok_r(NULL, COMMA, &ptr);
+ host = strtok_r(NULL, INI_PARSER_COMMA, &ptr);
g_muse_server_conf->host_cnt++;
}