summaryrefslogtreecommitdiff
path: root/src/snuffleupagus.c
diff options
context:
space:
mode:
authorSebastien Blot2018-01-18 11:07:06 +0100
committerSebastien Blot2018-01-18 11:08:08 +0100
commita09a48c605a36e052446f47b4e0eb98f9b8398a2 (patch)
tree580befadb5d0c999058da8c5643bea543909c5d6 /src/snuffleupagus.c
parent8b69ee4f557bb1314d98afb09ab133d036f30483 (diff)
Add globbing support for configuration file path (closes #125)
Diffstat (limited to 'src/snuffleupagus.c')
-rw-r--r--src/snuffleupagus.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c
index 78a8659..32a4198 100644
--- a/src/snuffleupagus.c
+++ b/src/snuffleupagus.c
@@ -1,3 +1,5 @@
1#include <glob.h>
2
1#ifdef HAVE_CONFIG_H 3#ifdef HAVE_CONFIG_H
2#include "config.h" 4#include "config.h"
3#endif 5#endif
@@ -182,15 +184,39 @@ static PHP_INI_MH(OnUpdateConfiguration) {
182 } 184 }
183 185
184 config_file = strtok(new_value->val, ","); 186 config_file = strtok(new_value->val, ",");
185 if (sp_parse_config(config_file) != SUCCESS) { 187
186 SNUFFLEUPAGUS_G(is_config_valid) = false; 188 glob_t globbuf;
189
190 int ret = glob(config_file, GLOB_BRACE|GLOB_NOCHECK, NULL, &globbuf);
191
192 if (ret != 0) {
187 return FAILURE; 193 return FAILURE;
188 } 194 }
189 while ((config_file = strtok(NULL, ","))) { 195
190 if (sp_parse_config(config_file) != SUCCESS) { 196 size_t i = 0;
197 while (globbuf.gl_pathv[i]) {
198 if (sp_parse_config(globbuf.gl_pathv[i]) != SUCCESS) {
191 SNUFFLEUPAGUS_G(is_config_valid) = false; 199 SNUFFLEUPAGUS_G(is_config_valid) = false;
192 return FAILURE; 200 return FAILURE;
193 } 201 }
202 i++;
203 }
204 globfree(&globbuf);
205 i = 0;
206
207 while ((config_file = strtok(NULL, ","))) {
208 ret = glob(config_file, GLOB_BRACE|GLOB_NOCHECK, NULL, &globbuf);
209 if (ret != 0 ) {
210 return FAILURE;
211 }
212 while (globbuf.gl_pathv[i]) {
213 if (sp_parse_config(globbuf.gl_pathv[i]) != SUCCESS) {
214 SNUFFLEUPAGUS_G(is_config_valid) = false;
215 return FAILURE;
216 }
217 i++;
218 }
219 globfree(&globbuf);
194 } 220 }
195 221
196 SNUFFLEUPAGUS_G(is_config_valid) = true; 222 SNUFFLEUPAGUS_G(is_config_valid) = true;