diff --git a/include/re_conf.h b/include/re_conf.h index 8c5d00852..1db507d5a 100644 --- a/include/re_conf.h +++ b/include/re_conf.h @@ -15,6 +15,7 @@ int conf_get(const struct conf *conf, const char *name, struct pl *pl); int conf_get_str(const struct conf *conf, const char *name, char *str, size_t size); int conf_get_u32(const struct conf *conf, const char *name, uint32_t *num); +int conf_get_i32(const struct conf *conf, const char *name, int32_t *num); int conf_get_bool(const struct conf *conf, const char *name, bool *val); int conf_apply(const struct conf *conf, const char *name, conf_h *ch, void *arg); diff --git a/src/conf/conf.c b/src/conf/conf.c index d07f68e52..2fe1a2417 100644 --- a/src/conf/conf.c +++ b/src/conf/conf.c @@ -225,6 +225,33 @@ int conf_get_u32(const struct conf *conf, const char *name, uint32_t *num) } +/** + * Get the numeric signed value of a configuration item + * + * @param conf Configuration object + * @param name Name of config item key + * @param num Returned numeric value of config item, if present + * + * @return 0 if success, otherwise errorcode + */ +int conf_get_i32(const struct conf *conf, const char *name, int32_t *num) +{ + struct pl pl; + int err; + + if (!conf || !name || !num) + return EINVAL; + + err = conf_get(conf, name, &pl); + if (err) + return err; + + *num = pl_i32(&pl); + + return 0; +} + + /** * Get the boolean value of a configuration item *