summaryrefslogtreecommitdiff
path: root/server/config.c
diff options
context:
space:
mode:
authorEric Covener <covener@apache.org>2016-06-10 22:44:39 +0000
committerEric Covener <covener@apache.org>2016-06-10 22:44:39 +0000
commit2d0b6b55981853b713854c08a16857a450d08687 (patch)
treee2c7d5d11dfd58d1365ec0eca1fbafd977a2434c /server/config.c
parent4bc9cc097657aa2c9b0b392213ec6dc6b250c26b (diff)
downloadhttpd-2d0b6b55981853b713854c08a16857a450d08687.tar.gz
Add -DDUMP_INCLUDES configtest option to show the tree
of Included configuration files. Example: Included configuration files: (*) .../conf/httpd.conf (517) .../conf/extra/proxy-html.conf (91) /dev/null Submitted By: Jacob Champion <champion.pxi gmail.com> Committed By: covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1747808 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/config.c')
-rw-r--r--server/config.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/server/config.c b/server/config.c
index 741bc00fd5..b02fac2dca 100644
--- a/server/config.c
+++ b/server/config.c
@@ -1797,6 +1797,54 @@ static int fname_alphasort(const void *fn1, const void *fn2)
return strcmp(f1->fname,f2->fname);
}
+/**
+ * Used by -D DUMP_INCLUDES to output the config file "tree".
+ */
+static void dump_config_name(const char *fname, apr_pool_t *p)
+{
+ unsigned i, recursion, line_number;
+ void *data;
+ apr_file_t *out = NULL;
+
+ apr_file_open_stdout(&out, p);
+
+ /* ap_include_sentinel is defined by the core Include directive; use it to
+ * figure out how deep in the stack we are.
+ */
+ apr_pool_userdata_get(&data, "ap_include_sentinel", p);
+
+ if (data) {
+ recursion = *(unsigned *)data;
+ } else {
+ recursion = 0;
+ }
+
+ /* Indent once for each level. */
+ for (i = 0; i < (recursion + 1); ++i) {
+ apr_file_printf(out, " ");
+ }
+
+ /* ap_include_lineno is similarly defined to tell us where in the last
+ * config file we were.
+ */
+ apr_pool_userdata_get(&data, "ap_include_lineno", p);
+
+ if (data) {
+ line_number = *(unsigned *)data;
+ } else {
+ line_number = 0;
+ }
+
+ /* Print the line number and the name of the parsed file. */
+ if (line_number > 0) {
+ apr_file_printf(out, "(%u)", line_number);
+ } else {
+ apr_file_printf(out, "(*)");
+ }
+
+ apr_file_printf(out, " %s\n", fname);
+}
+
AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
const char *fname,
ap_directive_t **conftree,
@@ -1821,6 +1869,10 @@ AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
fname, &rv);
}
+ if (ap_exists_config_define("DUMP_INCLUDES")) {
+ dump_config_name(fname, p);
+ }
+
parms.config_file = cfp;
error = ap_build_config(&parms, p, ptemp, conftree);
ap_cfg_closefile(cfp);
@@ -2417,6 +2469,16 @@ AP_DECLARE(server_rec*) ap_read_config(process_rec *process, apr_pool_t *ptemp,
init_config_globals(p);
+ if (ap_exists_config_define("DUMP_INCLUDES")) {
+ apr_file_t *out = NULL;
+ apr_file_open_stdout(&out, p);
+
+ /* Included files will be dumped as the config is walked; print a
+ * header.
+ */
+ apr_file_printf(out, "Included configuration files:\n");
+ }
+
/* All server-wide config files now have the SAME syntax... */
error = process_command_config(s, ap_server_pre_read_config, conftree,
p, ptemp);