*/
cmd->limited = tog ? ~limited : limited;
- errmsg = ap_walk_config(NULL, cmd, cmd->context, 1);
+ errmsg = ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
cmd->limited = -1;
conf = (core_dir_config *)ap_set_config_vectors(cmd, new_dir_conf,
&core_module);
- errmsg = ap_walk_config(NULL, cmd, new_dir_conf, 1);
+ errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_dir_conf);
if (errmsg != NULL)
return errmsg;
conf = (core_dir_config *)ap_set_config_vectors(cmd, new_url_conf,
&core_module);
- errmsg = ap_walk_config(NULL, cmd, new_url_conf, 1);
+ errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_url_conf);
if (errmsg != NULL)
return errmsg;
conf = (core_dir_config *)ap_set_config_vectors(cmd, new_file_conf,
&core_module);
- errmsg = ap_walk_config(NULL, cmd, new_file_conf, 1);
+ errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
if (errmsg != NULL)
return errmsg;
found = ap_find_linked_module(arg);
if ((!not && found) || (not && !found)) {
- return ap_walk_config(NULL, cmd, cmd->context, 1);
+ return ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
}
return NULL;
defined = ap_exists_config_define(arg);
if ((!not && defined) || (not && !defined)) {
- return ap_walk_config(NULL, cmd, cmd->context, 1);
+ return ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
}
return NULL;
cmd->server = s;
- errmsg = ap_walk_config(NULL, cmd, s->lookup_defaults, 1);
+ errmsg = ap_walk_config(cmd->directive->first_child, cmd,
+ s->lookup_defaults);
cmd->server = main_server;
return NULL;
}
-static const char *ap_walk_config_sub(ap_directive_t *current,
+static const char *ap_walk_config_sub(const ap_directive_t *current,
cmd_parms *parms, void *config)
{
- void *oldconfig;
- const command_rec *cmd;
module *mod = top_module;
- const char *retval;
- parms->directive = current;
+ while (1) {
+ const command_rec *cmd;
- oldconfig = parms->context;
- parms->context = config;
- do {
if (!(cmd = ap_find_command_in_modules(current->directive, &mod))) {
- retval = ap_pstrcat(parms->pool, "Invalid command '",
- current->directive,
- "', perhaps mis-spelled or defined by a module "
- "not included in the server configuration", NULL);
+ return ap_pstrcat(parms->pool, "Invalid command '",
+ current->directive,
+ "', perhaps mis-spelled or defined by a module "
+ "not included in the server configuration",
+ NULL);
}
else {
void *mconfig = ap_set_config_vectors(parms,config, mod);
+ const char *retval;
retval = invoke_cmd(cmd, parms, mconfig, current->args);
+ if (retval == NULL || strcmp(retval, DECLINE_CMD) != 0)
+ return retval;
+
mod = mod->next; /* Next time around, skip this one */
}
- } while (retval && !strcmp(retval, DECLINE_CMD));
- parms->context = oldconfig;
-
- return retval;
+ }
+ /* NOTREACHED */
}
-API_EXPORT(const char *) ap_walk_config(ap_directive_t *conftree,
- cmd_parms *parms, void *config,
- int container)
+API_EXPORT(const char *) ap_walk_config(ap_directive_t *current,
+ cmd_parms *parms, void *config)
{
- static ap_directive_t *current;
+ void *oldconfig = parms->context;
- if (conftree != NULL) {
- current = conftree;
- }
- if (container && current->first_child) {
- current = current->first_child;
- }
+ parms->context = config;
- while (current != NULL) {
+ /* scan through all directives, executing each one */
+ for (; current != NULL; current = current->next) {
const char *errmsg;
+ parms->directive = current;
+
/* actually parse the command and execute the correct function */
errmsg = ap_walk_config_sub(current, parms, config);
- if (errmsg != NULL)
+ if (errmsg != NULL) {
+ /* restore the context (just in case) */
+ parms->context = oldconfig;
return errmsg;
-
- if (current->next == NULL) {
- current = current->parent;
- break;
- } else {
- current = current->next;
- continue;
- }
+ }
}
+ parms->context = oldconfig;
return NULL;
}
errmsg = ap_build_config(cfp, p, ptemp, &conftree);
if (errmsg == NULL)
- errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults, 0);
+ errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
if (errmsg) {
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
"Syntax error in -C/-c directive:\n%s", errmsg);
errmsg = ap_build_config(cfp, p, ptemp, &conftree);
if (errmsg == NULL)
- errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults, 0);
+ errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
if (errmsg != NULL) {
/* ### wrong line number. need to pull from ap_directive_t */
errmsg = ap_build_config(f, r->pool, r->pool, &conftree);
if (errmsg == NULL)
- errmsg = ap_walk_config(conftree, &parms, dc, 0);
+ errmsg = ap_walk_config(conftree, &parms, dc);
ap_cfg_closefile(f);