summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvenaas <venaas>2008-07-03 09:39:31 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2008-07-03 09:39:31 +0000
commit988b7a71fb925531ae02b208ef7508c5d047314d (patch)
treeffb28db6254a81db04ffcf86dd2b437d90120a93
parent4fe30e213be69224bad17c1bba027bf61069f592 (diff)
gconfig support for long int
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/branches/release-1.1@294 e88ac4ed-0b26-0410-9574-a7f39faa03bf
-rw-r--r--gconfig.c22
-rw-r--r--gconfig.h1
2 files changed, 20 insertions, 3 deletions
diff --git a/gconfig.c b/gconfig.c
index 5efc97f..b3b0487 100644
--- a/gconfig.c
+++ b/gconfig.c
@@ -235,8 +235,9 @@ void getconfigline(struct gconffile **cf, char *block, char **opt, char **val, i
void getgenericconfig(struct gconffile **cf, char *block, ...) {
va_list ap;
- char *opt = NULL, *val, *word, *optval, **str = NULL, ***mstr = NULL;
+ char *opt = NULL, *val, *word, *optval, **str = NULL, ***mstr = NULL, *endptr;
uint8_t *bln = NULL;
+ long int *lint = NULL;
int type = 0, conftype = 0, n;
void (*cbk)(struct gconffile **, char *, char *, char *) = NULL;
@@ -272,6 +273,11 @@ void getgenericconfig(struct gconffile **cf, char *block, ...) {
if (!bln)
debugx(1, DBG_ERR, "getgenericconfig: internal parameter error");
break;
+ case CONF_LINT:
+ lint = va_arg(ap, long int *);
+ if (!lint)
+ debugx(1, DBG_ERR, "getgenericconfig: internal parameter error");
+ break;
case CONF_CBK:
cbk = va_arg(ap, void (*)(struct gconffile **, char *, char *, char *));
break;
@@ -289,7 +295,7 @@ void getgenericconfig(struct gconffile **cf, char *block, ...) {
debugx(1, DBG_ERR, "configuration error, unknown option %s", opt);
}
- 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)
debugx(1, DBG_ERR, "configuration error in block %s, wrong syntax for option %s", block, opt);
@@ -323,6 +329,16 @@ void getgenericconfig(struct gconffile **cf, char *block, ...) {
else
debugx(1, DBG_ERR, "configuration error, value for option %s must be on or off, not %s", opt, val);
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)
+ debugx(1, DBG_ERR, "configuration error in block %s, value for option %s must be an integer, not %s", block, opt, val);
+ else
+ debugx(1, DBG_ERR, "configuration error, value for option %s must be an integer, not %s", opt, val);
+ }
+ break;
case CONF_CBK:
optval = malloc(strlen(opt) + strlen(val) + 2);
if (!optval)
@@ -339,7 +355,7 @@ void 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);
}
}
diff --git a/gconfig.h b/gconfig.h
index af44dac..9948a7b 100644
--- a/gconfig.h
+++ b/gconfig.h
@@ -2,6 +2,7 @@
#define CONF_CBK 2
#define CONF_MSTR 3
#define CONF_BLN 4
+#define CONF_LINT 5
struct gconffile {
char *path;