summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvenaas <venaas>2007-11-29 09:01:42 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2007-11-29 09:01:42 +0000
commitb79f901f19fe09bc6281ace20b3149be3e1ee355 (patch)
tree5c14fca10b085cb17c74de8a339c29600695700d
parent18592cef57c5a05d97dbdc56df5a1191bce494b0 (diff)
include with globbing
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@200 e88ac4ed-0b26-0410-9574-a7f39faa03bf
-rw-r--r--gconfig.c24
-rw-r--r--gconfig.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/gconfig.c b/gconfig.c
index b286426..bf83899 100644
--- a/gconfig.c
+++ b/gconfig.c
@@ -10,6 +10,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <glob.h>
#include <sys/types.h>
#include "debug.h"
#include "util.h"
@@ -76,6 +77,25 @@ FILE *pushgconffile(struct gconffile **cf, const char *path) {
return f;
}
+FILE *pushgconffiles(struct gconffile **cf, const char *path) {
+ int i;
+ FILE *f;
+ glob_t globbuf;
+
+ memset(&globbuf, 0, sizeof(glob_t));
+ if (glob(path, 0, NULL, &globbuf)) {
+ debug(DBG_INFO, "could not glob %s", path);
+ return NULL;
+ }
+ for (i = globbuf.gl_pathc - 1; i >= 0; i--) {
+ f = pushgconffile(cf, globbuf.gl_pathv[i]);
+ if (!f)
+ break;
+ }
+ globfree(&globbuf);
+ return f;
+}
+
FILE *popgconffile(struct gconffile **cf) {
int i;
@@ -111,7 +131,6 @@ void getgenericconfig(struct gconffile **cf, char *block, ...) {
/* initialise lots of stuff to avoid stupid compiler warnings */
char *tokens[3], *s, *opt = NULL, *val = NULL, *word, *optval, **str = NULL, ***mstr = NULL;
int type = 0, tcount, conftype = 0, n;
-
void (*cbk)(struct gconffile **, char *, char *, char *) = NULL;
if (!cf || !*cf || !(*cf)->file)
@@ -169,7 +188,8 @@ void getgenericconfig(struct gconffile **cf, char *block, ...) {
debugx(1, DBG_ERR, "configuration error, option %s needs a non-empty value", opt);
if (conftype == CONF_STR && !strcasecmp(opt, "include")) {
- pushgconffile(cf, val);
+ if (!pushgconffiles(cf, val))
+ debugx(1, DBG_ERR, "failed to include config file %s", val);
continue;
}
diff --git a/gconfig.h b/gconfig.h
index 11c4000..409b1ba 100644
--- a/gconfig.h
+++ b/gconfig.h
@@ -9,4 +9,5 @@ struct gconffile {
void getgenericconfig(struct gconffile **cf, char *block, ...);
FILE *pushgconffile(struct gconffile **cf, const char *path);
+FILE *pushgconffiles(struct gconffile **cf, const char *path);
FILE *popgconffile(struct gconffile **cf);