diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/conf.c | 86 | ||||
-rw-r--r-- | src/common/conf.h | 14 |
2 files changed, 87 insertions, 13 deletions
diff --git a/src/common/conf.c b/src/common/conf.c index 8ec2f3fb4..96b9bff9f 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -373,6 +373,80 @@ int config_lookup_mutable_string(const struct config_t *config, const char *name return CONFIG_FALSE; } +/** + * Wrapper for config_setting_get_int64() using defined-size variables + * + * @see config_setting_get_int64_real() + */ +int64 config_setting_get_int64_real(const struct config_setting_t *setting) +{ + return (int64)config_setting_get_int64(setting); +} + +/** + * Wrapper for config_setting_lookup_int64() using defined-size variables + * + * @see config_setting_lookup_int64() + */ +int config_setting_lookup_int64_real(const struct config_setting_t *setting, const char *name, int64 *value) +{ + long long int lli = 0; + + if (config_setting_lookup_int64(setting, name, &lli) != CONFIG_TRUE) + return CONFIG_FALSE; + + *value = (int64)lli; + + return CONFIG_TRUE; +} + +/** + * Wrapper for config_setting_set_int64() using defined-size variables + * + * @see config_setting_set_int64() + */ +int config_setting_set_int64_real(struct config_setting_t *setting, int64 value) +{ + return config_setting_set_int64(setting, (long long int)value); +} + +/** + * Wrapper for config_setting_get_int64_elem() using defined-size variables + * + * @see config_setting_get_int64_elem() + */ +int64 config_setting_get_int64_elem_real(const struct config_setting_t *setting, int idx) +{ + return (int64)config_setting_get_int64_elem(setting, idx); +} + +/** + * Wrapper for config_setting_set_int64_elem() using defined-size variables + * + * @see config_setting_set_int64_elem() + */ +struct config_setting_t *config_setting_set_int64_elem_real(struct config_setting_t *setting, int idx, int64 value) +{ + return config_setting_set_int64_elem(setting, idx, (long long int)value); +} + +/** + * Wrapper for config_lookup_int64() using defined-size variables + * + * @see config_lookup_int64() + */ +int config_lookup_int64_real(const struct config_t *config, const char *filepath, int64 *value) +{ + long long int lli = 0; + + if (config_lookup_int64(config, filepath, &lli) != CONFIG_TRUE) + return CONFIG_FALSE; + + *value = (int64)lli; + + return CONFIG_TRUE; +} + void libconfig_defaults(void) { libconfig = &libconfig_s; @@ -393,20 +467,20 @@ void libconfig_defaults(void) { libconfig->destroy = config_destroy; /* */ libconfig->setting_get_int = config_setting_get_int; - libconfig->setting_get_int64 = config_setting_get_int64; + libconfig->setting_get_int64 = config_setting_get_int64_real; libconfig->setting_get_float = config_setting_get_float; libconfig->setting_get_bool = config_setting_get_bool; libconfig->setting_get_string = config_setting_get_string; /* */ libconfig->setting_lookup = config_setting_lookup; libconfig->setting_lookup_int = config_setting_lookup_int; - libconfig->setting_lookup_int64 = config_setting_lookup_int64; + libconfig->setting_lookup_int64 = config_setting_lookup_int64_real; libconfig->setting_lookup_float = config_setting_lookup_float; libconfig->setting_lookup_bool = config_setting_lookup_bool; libconfig->setting_lookup_string = config_setting_lookup_string; /* */ libconfig->setting_set_int = config_setting_set_int; - libconfig->setting_set_int64 = config_setting_set_int64; + libconfig->setting_set_int64 = config_setting_set_int64_real; libconfig->setting_set_float = config_setting_set_float; libconfig->setting_set_bool = config_setting_set_bool; libconfig->setting_set_string = config_setting_set_string; @@ -415,13 +489,13 @@ void libconfig_defaults(void) { libconfig->setting_get_format = config_setting_get_format; /* */ libconfig->setting_get_int_elem = config_setting_get_int_elem; - libconfig->setting_get_int64_elem = config_setting_get_int64_elem; + libconfig->setting_get_int64_elem = config_setting_get_int64_elem_real; libconfig->setting_get_float_elem = config_setting_get_float_elem; libconfig->setting_get_bool_elem = config_setting_get_bool_elem; libconfig->setting_get_string_elem = config_setting_get_string_elem; /* */ libconfig->setting_set_int_elem = config_setting_set_int_elem; - libconfig->setting_set_int64_elem = config_setting_set_int64_elem; + libconfig->setting_set_int64_elem = config_setting_set_int64_elem_real; libconfig->setting_set_float_elem = config_setting_set_float_elem; libconfig->setting_set_bool_elem = config_setting_set_bool_elem; libconfig->setting_set_string_elem = config_setting_set_string_elem; @@ -441,7 +515,7 @@ void libconfig_defaults(void) { libconfig->lookup = config_lookup; /* */ libconfig->lookup_int = config_lookup_int; - libconfig->lookup_int64 = config_lookup_int64; + libconfig->lookup_int64 = config_lookup_int64_real; libconfig->lookup_float = config_lookup_float; libconfig->lookup_bool = config_lookup_bool; libconfig->lookup_string = config_lookup_string; diff --git a/src/common/conf.h b/src/common/conf.h index cb1ca6bee..bd6acc4be 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -46,7 +46,7 @@ struct libconfig_interface { void (*destroy) (struct config_t *config); int (*setting_get_int) (const struct config_setting_t *setting); - long long (*setting_get_int64) (const struct config_setting_t *setting); + int64 (*setting_get_int64) (const struct config_setting_t *setting); double (*setting_get_float) (const struct config_setting_t *setting); int (*setting_get_bool) (const struct config_setting_t *setting); @@ -55,12 +55,12 @@ struct libconfig_interface { struct config_setting_t * (*setting_lookup) (struct config_setting_t *setting, const char *name); int (*setting_lookup_int) (const struct config_setting_t *setting, const char *name, int *value); - int (*setting_lookup_int64) (const struct config_setting_t *setting, const char *name, long long *value); + int (*setting_lookup_int64) (const struct config_setting_t *setting, const char *name, int64 *value); int (*setting_lookup_float) (const struct config_setting_t *setting, const char *name, double *value); int (*setting_lookup_bool) (const struct config_setting_t *setting, const char *name, int *value); int (*setting_lookup_string) (const struct config_setting_t *setting, const char *name, const char **value); - int (*setting_set_int) (struct config_setting_t *setting ,int value); - int (*setting_set_int64) (struct config_setting_t *setting, long long value); + int (*setting_set_int) (struct config_setting_t *setting, int value); + int (*setting_set_int64) (struct config_setting_t *setting, int64 value); int (*setting_set_float) (struct config_setting_t *setting, double value); int (*setting_set_bool) (struct config_setting_t *setting, int value); int (*setting_set_string) (struct config_setting_t *setting, const char *value); @@ -69,12 +69,12 @@ struct libconfig_interface { short (*setting_get_format) (const struct config_setting_t *setting); int (*setting_get_int_elem) (const struct config_setting_t *setting, int idx); - long long (*setting_get_int64_elem) (const struct config_setting_t *setting, int idx); + int64 (*setting_get_int64_elem) (const struct config_setting_t *setting, int idx); double (*setting_get_float_elem) (const struct config_setting_t *setting, int idx); int (*setting_get_bool_elem) (const struct config_setting_t *setting, int idx); const char * (*setting_get_string_elem) (const struct config_setting_t *setting, int idx); struct config_setting_t * (*setting_set_int_elem) (struct config_setting_t *setting, int idx, int value); - struct config_setting_t * (*setting_set_int64_elem) (struct config_setting_t *setting, int idx, long long value); + struct config_setting_t * (*setting_set_int64_elem) (struct config_setting_t *setting, int idx, int64 value); struct config_setting_t * (*setting_set_float_elem) (struct config_setting_t *setting, int idx, double value); struct config_setting_t * (*setting_set_bool_elem) (struct config_setting_t *setting, int idx, int value); struct config_setting_t * (*setting_set_string_elem) (struct config_setting_t *setting, int idx, const char *value); @@ -93,7 +93,7 @@ struct libconfig_interface { struct config_setting_t * (*lookup) (const struct config_t *config, const char *filepath); int (*lookup_int) (const struct config_t *config, const char *filepath, int *value); - int (*lookup_int64) (const struct config_t *config, const char *filepath, long long *value); + int (*lookup_int64) (const struct config_t *config, const char *filepath, int64 *value); int (*lookup_float) (const struct config_t *config, const char *filepath, double *value); int (*lookup_bool) (const struct config_t *config, const char *filepath, int *value); int (*lookup_string) (const struct config_t *config, const char *filepath, const char **value); |