diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2016-12-16 12:59:09 +0100 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2017-03-03 14:02:27 +0100 |
commit | 784e693fe5b397516b8b8521386205512e989c70 (patch) | |
tree | d560c9e1add6a5497741d6be246d4adc7d17ecda /src | |
parent | 71f93716df8e3e93b5cdc307938a913e1a3058a5 (diff) | |
download | libusbg-784e693fe5b397516b8b8521386205512e989c70.tar.gz libusbg-784e693fe5b397516b8b8521386205512e989c70.tar.bz2 libusbg-784e693fe5b397516b8b8521386205512e989c70.zip |
libusbgx: common: Allow to export int attribute in hex format
Add a helper to export int attributes in hex format.
Now each function may decide which format should be used
(decimal or hex).
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/usbg_common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/usbg_common.c b/src/usbg_common.c index 948cce8..d3040c8 100644 --- a/src/usbg_common.c +++ b/src/usbg_common.c @@ -451,6 +451,25 @@ int usbg_set_config_node_int(config_setting_t *root, return ret == CONFIG_TRUE ? 0 : USBG_ERROR_OTHER_ERROR; } +int usbg_set_config_node_int_hex(config_setting_t *root, + const char *node_name, void *val) +{ + config_setting_t *node; + int ret = 0; + + node = config_setting_add(root, node_name, CONFIG_TYPE_INT); + if (!node) + return USBG_ERROR_NO_MEM; + + ret = config_setting_set_format(node, CONFIG_FORMAT_HEX); + if (ret != CONFIG_TRUE) + return USBG_ERROR_OTHER_ERROR; + + ret = config_setting_set_int(node, *(int *)val); + + return ret == CONFIG_TRUE ? 0 : USBG_ERROR_OTHER_ERROR; +} + int usbg_set_config_node_bool(config_setting_t *root, const char *node_name, void *val) { |