init_db : update boolean to modified value 15/139515/3 accepted/tizen/unified/20170721.024513 submit/tizen/20170720.062337
authorKichan Kwon <k_c.kwon@samsung.com>
Wed, 19 Jul 2017 07:49:38 +0000 (16:49 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Thu, 20 Jul 2017 06:16:20 +0000 (15:16 +0900)
- The lang option of update is removed because of the lack of default value

Change-Id: I8568e369a4ddd140b070256c1a4d199090cd58aa
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
src/init_db/system_info_db_init.c

index f3eb9e920b84e29d0279d0b20815024dd3a36f40..979dd64c7062bc6ba7deff5c265d4d98cb58d974 100644 (file)
@@ -274,12 +274,12 @@ static int system_info_create_db(void)
 
 static void show_help(void)
 {
+       /* TODO : support -l (--lang) option */
        printf("system_info_init_db [OPTIONS]\n");
        printf("  -h --help         Show this help\n");
        printf("  -k --key=KEY      System info key to update\n");
        printf("  -t --type=TYPE    System info type to update (int/bool/double/string)\n");
        printf("  -g --tag=TAG      System info tag to update (platform/custom)\n");
-       printf("  -l --lang=LANG    System info value to update (capi/webapi/csapi\n");
        printf("  -v --value=VALUE  System info value to update\n");
 }
 
@@ -293,14 +293,13 @@ static int system_info_update_db(int argc, char *argv[])
        char type[KEY_MAX] = {0};
        char tag[KEY_MAX] = {0};
        char value[KEY_MAX] = {0};
-       char lang[KEY_MAX] = {0};
+       char value_bool[LANG_MAX] = {0};
 
        struct option long_options[] = {
                { "key",   required_argument, 0, 0 },
                { "type",  required_argument, 0, 0 },
                { "tag",   required_argument, 0, 0 },
                { "value", required_argument, 0, 0 },
-               { "lang",  required_argument, 0, 0 },
                { "help",  no_argument,       0, 0 },
                { 0,       0,                 0, 0 },
        };
@@ -323,9 +322,6 @@ static int system_info_update_db(int argc, char *argv[])
                case 'v':
                        snprintf(value, sizeof(value), "%s", optarg);
                        break;
-               case 'l':
-                       snprintf(lang, sizeof(lang), "%s", optarg);
-                       break;
                case 'h':
                default:
                        show_help();
@@ -367,7 +363,11 @@ static int system_info_update_db(int argc, char *argv[])
                return -ENOENT;
        }
 
-       ret = db_set_value(&db, tag, key, type, value, strlen(value));
+       if (!strncmp(type, "bool", 4)) {
+               memset(value_bool, value[0] == 't' ? 'T' : 'F', LANG_MAX);
+               ret = db_set_value(&db, tag, key, type, value_bool, LANG_MAX);
+       } else
+               ret = db_set_value(&db, tag, key, type, value, strlen(value));
        if (ret != 0)
                _E("Failed to set value (%d)", ret);