Ottomata has submitted this change and it was merged.
Change subject: Now supporting 'include /etc/kafkatee.d/*.conf' style glob
matches for config includes
......................................................................
Now supporting 'include /etc/kafkatee.d/*.conf' style glob matches for config
includes
Change-Id: I8dfb3bb817af122d59de57dae35d0792349c995b
---
M ezd.c
1 file changed, 19 insertions(+), 3 deletions(-)
Approvals:
Ottomata: Verified; Looks good to me, approved
Edenhill: Looks good to me, but someone else must approve
diff --git a/ezd.c b/ezd.c
index 2f295dc..c0afe3a 100644
--- a/ezd.c
+++ b/ezd.c
@@ -45,6 +45,7 @@
#include <strings.h>
#include <errno.h>
#include <fcntl.h>
+#include <glob.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
@@ -197,6 +198,8 @@
char buf[8192];
int line = 0;
static int inc_depth = 0;
+ glob_t glob_matches;
+ int g = 0; /* iterator index in glob_matches.gl_pathv */
if (!(fp = fopen(path, "r"))) {
snprintf(errstr, errstr_size,
@@ -290,12 +293,25 @@
return -1;
}
- if (ezd_conf_file_read(t, conf_set_cb,
- errstr+errof, errstr_size-errof,
- opaque) == -1) {
+ /* Read in matching include files. */
+ if (glob(t, GLOB_ERR, NULL, &glob_matches) != 0) {
+ snprintf(errstr+errof, errstr_size-errof,
+ "Failed to read include file pattern
'%s'", t);
inc_depth--;
return -1;
+ }
+
+ /* For each matched include file, call
ezd_conf_file_read. */
+ for (g = 0; g < glob_matches.gl_pathc; g++) {
+ if
(ezd_conf_file_read(glob_matches.gl_pathv[g], conf_set_cb,
+ errstr+errof, errstr_size-errof,
+ opaque) == -1) {
+ inc_depth--;
+ globfree(&glob_matches);
+ return -1;
+ }
}
+ globfree(&glob_matches);
continue;
}
--
To view, visit https://gerrit.wikimedia.org/r/110635
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8dfb3bb817af122d59de57dae35d0792349c995b
Gerrit-PatchSet: 4
Gerrit-Project: analytics/kafkatee
Gerrit-Branch: master
Gerrit-Owner: Ottomata <[email protected]>
Gerrit-Reviewer: Edenhill <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits