diff options
author | venaas <venaas> | 2008-07-03 09:39:31 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2008-07-03 09:39:31 +0000 |
commit | d239bb28d2d199dd5263b059b312e889e4616289 (patch) | |
tree | 32abd987363ead2d3530e50be5fe1b6c6a2508c9 /gconfig.c | |
parent | 9ebb9eed56f7f69255230d9d8ed77b83a824ae96 (diff) |
gconfig support for long int
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@294 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'gconfig.c')
-rw-r--r-- | gconfig.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -353,8 +353,9 @@ int getconfigline(struct gconffile **cf, char *block, char **opt, char **val, in /* caller must free returned values also on error */ int getgenericconfig(struct gconffile **cf, char *block, ...) { va_list ap; - char *opt = NULL, *val, *word, *optval, **str = NULL, ***mstr = NULL, **newmstr; + char *opt = NULL, *val, *word, *optval, **str = NULL, ***mstr = NULL, **newmstr, *endptr; uint8_t *bln = NULL; + long int *lint = NULL; int type = 0, conftype = 0, n; int (*cbk)(struct gconffile **, void *, char *, char *, char *) = NULL; void *cbkarg = NULL; @@ -394,6 +395,11 @@ int getgenericconfig(struct gconffile **cf, char *block, ...) { if (!bln) goto errparam; break; + case CONF_LINT: + lint = va_arg(ap, long int *); + if (!lint) + goto errparam; + break; case CONF_CBK: cbk = va_arg(ap, int (*)(struct gconffile **, void *, char *, char *, char *)); if (!cbk) @@ -415,7 +421,7 @@ int getgenericconfig(struct gconffile **cf, char *block, ...) { goto errexit; } - if (((type == CONF_STR || type == CONF_MSTR || type == CONF_BLN) && conftype != CONF_STR) || + if (((type == CONF_STR || type == CONF_MSTR || type == CONF_BLN || type == CONF_LINT) && conftype != CONF_STR) || (type == CONF_CBK && conftype != CONF_CBK)) { if (block) debug(DBG_ERR, "configuration error in block %s, wrong syntax for option %s", block, opt); @@ -458,6 +464,17 @@ int getgenericconfig(struct gconffile **cf, char *block, ...) { goto errexit; } break; + case CONF_LINT: + endptr = NULL; + *lint = strtol(val, &endptr, 0); + if (*lint == LONG_MIN || *lint == LONG_MAX || !endptr || endptr == val || *endptr != '\0') { + if (block) + debug(DBG_ERR, "configuration error in block %s, value for option %s must be an integer, not %s", block, opt, val); + else + debug(DBG_ERR, "configuration error, value for option %s must be an integer, not %s", opt, val); + goto errexit; + } + break; case CONF_CBK: optval = malloc(strlen(opt) + strlen(val) + 2); if (!optval) { @@ -479,7 +496,7 @@ int getgenericconfig(struct gconffile **cf, char *block, ...) { debug(DBG_DBG, "getgenericconfig: block %s: %s = %s", block, opt, val); else debug(DBG_DBG, "getgenericconfig: %s = %s", opt, val); - if (type == CONF_BLN) + if (type == CONF_BLN || type == CONF_LINT) free(val); } |