From d9348c134d2c8988e4ad2162e367f591940bdb66 Mon Sep 17 00:00:00 2001 From: Suchang Woo Date: Thu, 16 Jul 2015 20:38:31 +0900 Subject: [PATCH] vconf-compat: add vconf_get_dbl, vconf_set_dbl Change-Id: I6a52f9c89f6738d51ad5f1d5a97e321c7049325c Signed-off-by: Suchang Woo --- vconf-compat/vconf.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ vconf-compat/vconf.h | 20 ++++++++++++++++++++ vconf-compat/vconf.sym | 2 ++ 3 files changed, 70 insertions(+) diff --git a/vconf-compat/vconf.c b/vconf-compat/vconf.c index 18632e9..198c5fb 100644 --- a/vconf-compat/vconf.c +++ b/vconf-compat/vconf.c @@ -560,6 +560,27 @@ EXPORT int vconf_set_str(const char *key, const char *strval) return r; } +EXPORT int vconf_set_dbl(const char *key, double dblval) +{ + int r; + struct buxton_value *val; + + if (!key) { + errno = EINVAL; + return -1; + } + + val = buxton_value_create_double(dblval); + if (!val) + return -1; + + r = vconf_set(key, val); + + buxton_value_free(val); + + return r; +} + static int vconf_get(const char *key, enum buxton_key_type type, struct buxton_value **val) { @@ -678,3 +699,30 @@ EXPORT char *vconf_get_str(const char *key) return str; } +EXPORT int vconf_get_dbl(const char *key, double *dblval) +{ + int r; + struct buxton_value *val; + double d; + + if (!key || !dblval) { + errno = EINVAL; + return -1; + } + + r = vconf_get(key, BUXTON_TYPE_DOUBLE, &val); + if (r == -1) + return -1; + + r = buxton_value_get_double(val, &d); + + buxton_value_free(val); + + if (r == -1) + return -1; + + *dblval = d; + + return 0; +} + diff --git a/vconf-compat/vconf.h b/vconf-compat/vconf.h index a75c80e..c43d345 100644 --- a/vconf-compat/vconf.h +++ b/vconf-compat/vconf.h @@ -164,6 +164,16 @@ int vconf_set_bool(const char *key, int boolval); int vconf_set_str(const char *key, const char *strval); /** + * Set a double-precision float value + * + * @param[in] key the name of key + * @param[in] dblval a double value + * @return 0 on success, -1 on error + * @deprecated use buxton APIs + */ +int vconf_set_dbl(const char *key, double dblval); + +/** * Get an integer value * * @param[in] key the name of key @@ -192,6 +202,16 @@ int vconf_get_bool(const char *key, int *boolval); */ char *vconf_get_str(const char *key); +/** + * Get a double-precision float value + * + * @param[in] key the name of key + * @param[out] dblval a pointer to a double value to be set + * @return 0 on success, -1 on error + * @deprecated use buxton APIs + */ +int vconf_get_dbl(const char *key, double *dblval); + #ifdef __cplusplus } #endif diff --git a/vconf-compat/vconf.sym b/vconf-compat/vconf.sym index b9c1b76..a76ac2e 100644 --- a/vconf-compat/vconf.sym +++ b/vconf-compat/vconf.sym @@ -11,9 +11,11 @@ VCONF_BUXTON_1.0 { vconf_set_int; vconf_set_bool; vconf_set_str; + vconf_set_dbl; vconf_get_int; vconf_get_bool; vconf_get_str; + vconf_get_dbl; local: *; }; -- 2.7.4