#include <dirent.h>
#include <inttypes.h>
#include <unistd.h>
+#include <errno.h>
#include <glib.h>
-#include <vconf.h>
+
+#include "direct.h"
+#include "common.h"
#define BUF_LEN 1024
-static void _get_vconf_keys(const char *path, keylist_t *keylist)
+enum vconf_t {
+ VCONF_TYPE_NONE = 0, /**< Vconf none type for Error detection */
+ VCONF_TYPE_STRING = 40, /**< Vconf string type */
+ VCONF_TYPE_INT = 41, /**< Vconf integer type */
+ VCONF_TYPE_DOUBLE = 42, /**< Vconf double type */
+ VCONF_TYPE_BOOL = 43, /**< Vconf boolean type */
+ VCONF_TYPE_DIR /**< Vconf directory type */
+};
+
+struct buxton_layer *system_layer;
+
+static void _set_vconf_key(const char *path)
{
int type = 0;
FILE *fp = NULL;
fp = fopen(path, "r+");
if (fp == NULL) {
- fprintf(stderr, "unable to open key path[%s] : %d", path, errno);
+ fprintf(stderr, "unable to open key path[%s] : %d\n", path, errno);
return;
}
read_size = fread((void *)&type, sizeof(int), 1, fp);
if ((read_size <= 0) || (read_size > sizeof(int))) {
if (!ferror(fp)) {
- fprintf(stderr, "number of read items for type is 0 with false ferror. err : %d", errno);
+ fprintf(stderr, "number of read items for type is 0 with false ferror. err : %d\n", errno);
errno = ENODATA;
}
goto out_func;
read_size = fread((void *)&value_int, sizeof(int), 1, fp);
if ((read_size <= 0) || (read_size > sizeof(int))) {
if (!ferror(fp))
- fprintf(stderr, "number of read items for value is wrong. err : %d", errno);
+ fprintf(stderr, "number of read items for value is wrong. err : %d\n", errno);
goto out_func;
} else {
- vconf_keylist_add_int(keylist, keyname, value_int);
+ struct buxton_value *v;
+ v = buxton_value_create_int32(value_int);
+ direct_set(system_layer, keyname, v);
+ buxton_value_free(v);
}
break;
read_size = fread((void *)&value_dbl, sizeof(double), 1, fp);
if ((read_size <= 0) || (read_size > sizeof(double))) {
if (!ferror(fp))
- fprintf(stderr, "number of read items for value is wrong. err : %d", errno);
+ fprintf(stderr, "number of read items for value is wrong. err : %d\n", errno);
goto out_func;
} else {
- vconf_keylist_add_dbl(keylist, keyname, value_dbl);
+ struct buxton_value *v;
+ v = buxton_value_create_double(value_dbl);
+ direct_set(system_layer, keyname, v);
+ buxton_value_free(v);
}
break;
read_size = fread((void *)&value_int, sizeof(int), 1, fp);
if ((read_size <= 0) || (read_size > sizeof(int))) {
if (!ferror(fp))
- fprintf(stderr, "number of read items for value is wrong. err : %d", errno);
+ fprintf(stderr, "number of read items for value is wrong. err : %d\n", errno);
goto out_func;
} else {
- vconf_keylist_add_bool(keylist, keyname, value_int);
+ struct buxton_value *v;
+ v = buxton_value_create_boolean(value_int);
+ direct_set(system_layer, keyname, v);
+ buxton_value_free(v);
}
break;
}
if (ferror(fp)) {
- fprintf(stderr, "fgets error for getting string key : %d", errno);
+ fprintf(stderr, "fgets error for getting string key : %d\n", errno);
} else {
+ struct buxton_value *v;
if (value)
- vconf_keylist_add_str(keylist, keyname, value);
+ v = buxton_value_create_string(value);
else
- vconf_keylist_add_str(keylist, keyname, "");
+ v = buxton_value_create_string("");
+ direct_set(system_layer, keyname, v);
+ buxton_value_free(v);
}
if (value)
free(value);
struct dirent file_info;
struct dirent *result;
char buf[BUF_LEN];
- keylist_t *keylist;
dir = opendir(directory);
if (!dir)
return -1;
- keylist = vconf_keylist_new();
-
while (readdir_r(dir, &file_info, &result) == 0) {
if (result == NULL)
break;
snprintf(buf, sizeof(buf), "%s/%s", directory,
file_info.d_name);
- _get_vconf_keys(buf, keylist);
+ _set_vconf_key(buf);
}
- vconf_set(keylist);
-
- vconf_keylist_free(keylist);
closedir(dir);
return 0;
int main(int argc, char *argv[])
{
+ direct_init(MODULE_DIR, CONFPATH);
+ system_layer = buxton_create_layer("system");
+ buxton_layer_set_type(system_layer, BUXTON_LAYER_NORMAL);
+
if (_load_vconf_dir("/opt/var/kdb/db") < 0)
- fprintf(stderr, "fail to migrate db backend keys : %d", errno);
+ fprintf(stderr, "fail to migrate db backend keys : %d\n", errno);
if (_load_vconf_dir("/opt/var/kdb/file") < 0)
- fprintf(stderr, "fail to migrate file backend keys : %d", errno);
+ fprintf(stderr, "fail to migrate file backend keys : %d\n", errno);
- if (_load_vconf_dir("/opt/var/kdb/memory_init/memory") < 0)
- fprintf(stderr, "fail to migrate memory backend keys : %d", errno);
+ buxton_free_layer(system_layer);
+ direct_exit();
return EXIT_SUCCESS;
}