diff options
author | Jeonghoon Park <jh1979.park@samsung.com> | 2017-11-07 14:53:03 +0900 |
---|---|---|
committer | Jeonghoon Park <jh1979.park@samsung.com> | 2017-11-07 14:53:03 +0900 |
commit | 0fecff5b65c14959cf8ab130d1559e8c95b2cdbe (patch) | |
tree | fb42ff4d3ca68a56b2fadac0e701ec8be6bf323b /src | |
parent | 12e05590144eccac1671a1145899805e8223574b (diff) | |
download | rcc-0fecff5b65c14959cf8ab130d1559e8c95b2cdbe.tar.gz rcc-0fecff5b65c14959cf8ab130d1559e8c95b2cdbe.tar.bz2 rcc-0fecff5b65c14959cf8ab130d1559e8c95b2cdbe.zip |
get conf file path from app common api
Change-Id: I5a12e0047e9255eca48b91d776269ce64b9e3cc7
Diffstat (limited to 'src')
-rw-r--r-- | src/controller_util.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/controller_util.c b/src/controller_util.c index b894f76..3bba0d5 100644 --- a/src/controller_util.c +++ b/src/controller_util.c @@ -21,12 +21,14 @@ #include <stdlib.h> #include <glib.h> - +#include <stdio.h> +#include <app_common.h> #include "log.h" #define CONF_GROUP_DEFAULT_NAME "default" #define CONF_KEY_PATH_NAME "path" #define CONF_KEY_ADDRESS_NAME "address" +#define CONF_FILE_NAME "pi.conf" struct controller_util_s { char *path; @@ -38,12 +40,20 @@ struct controller_util_s controller_util = { 0, }; static int _read_conf_file(void) { GKeyFile *gkf = NULL; + char conf_path[PATH_MAX] = {0,}; + char *prefix = NULL; gkf = g_key_file_new(); retv_if(!gkf, -1); - if (!g_key_file_load_from_file(gkf, CONF_FILE, G_KEY_FILE_NONE, NULL)) { - _E("could not read config file %s", CONF_FILE); + prefix = app_get_resource_path(); + retv_if(!prefix, -1); + snprintf(conf_path, sizeof(conf_path)-1, "%s%s", prefix, CONF_FILE_NAME); + free(prefix); + prefix = NULL; + + if (!g_key_file_load_from_file(gkf, conf_path, G_KEY_FILE_NONE, NULL)) { + _E("could not read config file %s", conf_path); return -1; } |