Skip to content

Commit

Permalink
conf: add conf_get_i32
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Mar 3, 2024
1 parent a35d110 commit 6fae7cc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/re_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
27 changes: 27 additions & 0 deletions src/conf/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 6fae7cc

Please sign in to comment.