Skip to content

Commit 36f6199

Browse files
committed
mod_so: Add -D DUMP_MODULE_DATA to print module data in structured
format (TOML) including MMN information. * modules/core/mod_so.c (print_mod_data): New function. (dump_loaded_modules): Use it if DUMP_MODULE_DATA is defined. * docs/manual/programs/httpd.xml: Move -DDUMP_* docs to a new section, cover the above new option. Github: closes #537 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1926737 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9b06444 commit 36f6199

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

docs/manual/programs/httpd.xml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ config files.</dd>
101101
<dd>Process the configuration <var>directive</var> after reading config
102102
files.</dd>
103103

104-
105104
<dt><code>-D <var>parameter</var></code></dt>
106105

107106
<dd>Sets a configuration <var>parameter </var>which can be used with
@@ -154,15 +153,11 @@ shows the virtualhost settings).</dd>
154153
<dt><code>-t</code></dt>
155154

156155
<dd>Run syntax tests for configuration files only. The program
157-
immediately exits after these syntax parsing tests with either a return code
158-
of 0 (Syntax OK) or return code not equal to 0 (Syntax Error). If -D
159-
<var>DUMP</var>_<var>VHOSTS </var>is also set, details of the virtual host
160-
configuration will be printed. If -D <var>DUMP</var>_<var>MODULES </var> is
161-
set, all loaded modules will be printed. If -D <var>DUMP</var>_<var>CERTS </var>
162-
is set and <module>mod_ssl</module> is used, configured SSL certificates will
163-
be printed. If -D <var>DUMP</var>_<var>CA</var>_<var>_CERTS </var> is set and
164-
<module>mod_ssl</module> is used, configured SSL CA certificates and configured
165-
directories containing SSL CA certificates will be printed.</dd>
156+
immediately exits after these syntax parsing tests with either a
157+
return code of 0 (Syntax OK) or return code not equal to 0 (Syntax
158+
Error). This option can be combined with various <var>-D
159+
DUMP_...</var> arguments to print information about the configuration,
160+
<a href="#dumpconf">as listed below</a>.</dd>
166161

167162
<dt><code>-v</code></dt>
168163

@@ -203,4 +198,25 @@ be read.</dd>
203198

204199
</section>
205200

201+
<section id="dumpconf"><title>Dumping configuration data</title>
202+
203+
<p>The following options can be combined with <var>-t</var> to show
204+
information about the configuration:</p>
205+
206+
<dl>
207+
<dt><var>-D DUMP_VHOSTS</var></dt> <dd>print details of the virtual
208+
host configuration.</dd>
209+
210+
<dt><var>-D DUMP_MODULES</var></dt> <dd>print (human-readable)
211+
details of all loaded modules.</dd>
212+
213+
<dt><var>-D DUMP_MODULES</var> <var>-D DUMP_MODULE_DATA</var></dt>
214+
<dd>print details of all loaded modules in a structured (TOML) format.</dd>
215+
216+
<dt><var>-D DUMP_CERTS</var></dt>
217+
<dd>If <module>mod_ssl</module> is loaded, print details of
218+
configured SSL/TLS certificates.</dd>
219+
</dl>
220+
</section>
221+
206222
</manualpage>

modules/core/mod_so.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,26 @@ static module *ap_find_loaded_module_symbol(server_rec *s, const char *modname)
361361
return NULL;
362362
}
363363

364+
/* Print structured module data in TOML format for -D DUMP_MODULE_DATA
365+
* output. */
366+
static void print_mod_data(apr_file_t *out, int is_static,
367+
const ap_module_symbol_t *modsym)
368+
{
369+
const char *name = modsym->name;
370+
const module *mod = modsym->modp;
371+
372+
apr_file_printf(out, "%s.static = %d\n", name, is_static);
373+
apr_file_printf(out, "%s.source = \"%s\"\n", name, mod->name);
374+
apr_file_printf(out, "%s.major = %d\n", name, mod->version);
375+
apr_file_printf(out, "%s.minor = %d\n", name, mod->minor_version);
376+
}
377+
364378
static void dump_loaded_modules(apr_pool_t *p, server_rec *s)
365379
{
366380
ap_module_symbol_t *modie;
367381
ap_module_symbol_t *modi;
368382
so_server_conf *sconf;
369-
int i;
383+
int i, toml = ap_exists_config_define("DUMP_MODULE_DATA");
370384
apr_file_t *out = NULL;
371385

372386
if (!ap_exists_config_define("DUMP_MODULES")) {
@@ -375,14 +389,17 @@ static void dump_loaded_modules(apr_pool_t *p, server_rec *s)
375389

376390
apr_file_open_stdout(&out, p);
377391

378-
apr_file_printf(out, "Loaded Modules:\n");
392+
if (!toml) apr_file_printf(out, "Loaded Modules:\n");
379393

380394
sconf = (so_server_conf *)ap_get_module_config(s->module_config,
381395
&so_module);
382396
for (i = 0; ; i++) {
383397
modi = &ap_prelinked_module_symbols[i];
384398
if (modi->name != NULL) {
385-
apr_file_printf(out, " %s (static)\n", modi->name);
399+
if (toml)
400+
print_mod_data(out, 1, modi);
401+
else
402+
apr_file_printf(out, " %s (static)\n", modi->name);
386403
}
387404
else {
388405
break;
@@ -393,7 +410,10 @@ static void dump_loaded_modules(apr_pool_t *p, server_rec *s)
393410
for (i = 0; i < sconf->loaded_modules->nelts; i++) {
394411
modi = &modie[i];
395412
if (modi->name != NULL) {
396-
apr_file_printf(out, " %s (shared)\n", modi->name);
413+
if (toml)
414+
print_mod_data(out, 0, modi);
415+
else
416+
apr_file_printf(out, " %s (shared)\n", modi->name);
397417
}
398418
}
399419
}

0 commit comments

Comments
 (0)