]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_info: Added ?hooks. Now outputs XHTML. Added more build info.
authorPaul Querna <pquerna@apache.org>
Sun, 5 Sep 2004 05:48:32 +0000 (05:48 +0000)
committerPaul Querna <pquerna@apache.org>
Sun, 5 Sep 2004 05:48:32 +0000 (05:48 +0000)
updated mod_info docs.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104999 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_info.html.en
docs/manual/mod/mod_info.xml
modules/generators/mod_info.c

diff --git a/CHANGES b/CHANGES
index 6de88825cc8b5998a253665ef81eea6938235923..a996921940a2f7398f1930d8b61ba7a5704fc1fd 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) mod_info: Added listing of the Request Hooks and added more build 
+     information like 'httpd -V' contains. Changed output to XHTML. 
+     [Paul Querna]
+
   *) mod_info: Rewrote config tree walk using a recursive function.
      Added ?config option. Added printout of config filename and line numbers.
      [Rici Lake <rici ricilake.net>, Paul Querna]
index 14ea0254c5eea63e19f33331022abb8bc82497af..e4b323ba014071e6c60f00e6ff7d4f2ddf501064 100644 (file)
@@ -104,6 +104,8 @@ configuration</td></tr>
             <dd>Only information relevant to the named module</dd>
         <dt><code>?config</code></dt>
             <dd>Just the configuration directives, not sorted by module</dd>
+        <dt><code>?hooks</code></dt>
+            <dd>Only the list of Hooks each module is attached to</dd>
         <dt><code>?list</code></dt>
             <dd>Only a simple list of enabled modules</dd>
         <dt><code>?server</code></dt>
index 3f435becc77465f8bc4b60fae93fa9b82c31b00b..fcf72cd1d6912fd39a461338206c8a89e33ea948 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
-<!-- $Revision: 1.19 $ -->
+<!-- $Revision: 1.20 $ -->
 
 <!--
  Copyright 2002-2004 The Apache Software Foundation
@@ -91,6 +91,8 @@ configuration</description>
             <dd>Only information relevant to the named module</dd>
         <dt><code>?config</code></dt>
             <dd>Just the configuration directives, not sorted by module</dd>
+        <dt><code>?hooks</code></dt>
+            <dd>Only the list of Hooks each module is attached to</dd>
         <dt><code>?list</code></dt>
             <dd>Only a simple list of enabled modules</dd>
         <dt><code>?server</code></dt>
index 6d84f7f0e46bc2962330aaf71b863296680be419..10fdc18615bb91f16606123e10614702788ddabd 100644 (file)
@@ -26,6 +26,7 @@
  * GET /server-info?module_name - Returns configuration for a single module
  * GET /server-info?list - Returns quick list of included modules
  * GET /server-info?config - Returns full configuration
+ * GET /server-info?hooks - Returns a listing of the modules active for each hook
  *
  * Original Author: 
  *   Rasmus Lerdorf <rasmus vex.net>, May 1996
  * 
  */
 
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_lib.h"
+#define APR_WANT_STRFUNC
+#include "apr_want.h"
+
 #define CORE_PRIVATE
 
 #include "httpd.h"
 #include "http_protocol.h"
 #include "http_request.h"
 #include "util_script.h"
-#include "apr_strings.h"
-#include "apr_lib.h"
-#define APR_WANT_STRFUNC
-#include "apr_want.h"
 #include "ap_mpm.h"
 
 typedef struct
@@ -110,7 +114,8 @@ static void mod_info_indent(request_rec *r, int nest,
         thisfn = ap_escape_html(r->pool, thisfn);
         ap_rprintf(r, "<dd><tt><strong>In file: %s</strong></tt></dd>\n",
                    thisfn);
-        ap_set_module_config(r->request_config, &info_module, thisfn);
+        ap_set_module_config(r->request_config, &info_module,
+                             (void *) thisfn);
     }
 
     ap_rputs("<dd><tt>", r);
@@ -227,6 +232,7 @@ typedef struct
     hook_get_t get;
 } hook_lookup_t;
 
+/* TODO: Find Any Missing Hooks */
 static hook_lookup_t request_hooks[] = {
     {"Post-Read Request", ap_hook_get_post_read_request},
     {"Header Parse", ap_hook_get_header_parser},
@@ -310,15 +316,255 @@ static const char *find_more_info(server_rec *s, const char *module_name)
     return 0;
 }
 
+static int show_server_settings(request_rec *r)
+{
+    server_rec *serv = r->server;
+    int max_daemons, forked, threaded;
+
+    ap_rputs("<a name=\"server\"<h2>Server Settings</h2></a>", r);
+    ap_rprintf(r,
+               "<dl><dt><strong>Server Version:</strong> "
+               "<font size=\"+1\"><tt>%s</tt></font></dt>\n",
+               ap_get_server_version());
+    ap_rprintf(r,
+               "<dt><strong>Server Built:</strong> "
+               "<font size=\"+1\"><tt>%s</tt></font></dt>\n",
+               ap_get_server_built());
+    ap_rprintf(r,
+               "<dt><strong>Module Magic Number:</strong> "
+               "<tt>%d:%d</tt></dt>\n", MODULE_MAGIC_NUMBER_MAJOR,
+               MODULE_MAGIC_NUMBER_MINOR);
+    ap_rprintf(r,
+               "<dt><strong>Hostname/port:</strong> "
+               "<tt>%s:%u</tt></dt>\n", ap_get_server_name(r),
+               ap_get_server_port(r));
+    ap_rprintf(r,
+               "<dt><strong>Timeouts:</strong> "
+               "<tt>connection: %d &nbsp;&nbsp; "
+               "keep-alive: %d</tt></dt>",
+               (int) (apr_time_sec(serv->timeout)),
+               (int) (apr_time_sec(serv->timeout)));
+    ap_mpm_query(AP_MPMQ_MAX_DAEMON_USED, &max_daemons);
+    ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded);
+    ap_mpm_query(AP_MPMQ_IS_FORKED, &forked);
+    ap_rprintf(r, "<dt><strong>MPM Name:</strong> <tt>%s</tt></dt>\n",
+               ap_show_mpm());
+    ap_rprintf(r,
+               "<dt><strong>MPM Information:</strong> "
+               "<tt>Max Daemons: %d Threaded: %s Forked: %s</tt></dt>\n",
+               max_daemons, threaded ? "yes" : "no", forked ? "yes" : "no");
+    ap_rprintf(r,
+               "<dt><strong>Server Architecture:</strong> "
+               "<tt>%ld-bit</tt></dt>\n", 8 * (long) sizeof(void *));
+    ap_rprintf(r,
+               "<dt><strong>Server Root:</strong> "
+               "<tt>%s</tt></dt>\n", ap_server_root);
+    ap_rprintf(r,
+               "<dt><strong>Config File:</strong> "
+               "<tt>%s</tt></dt>\n", ap_conftree->filename);
+
+    ap_rputs("<dt><strong>Server Built With:</strong>\n<tt>\n<pre>", r);
+
+    /* TODO: Not all of these are getting set like they do in main.c. 
+     *       Missing some headers? 
+     */
+
+#ifdef BIG_SECURITY_HOLE
+    ap_rputs(" -D BIG_SECURITY_HOLE\n", r);
+#endif
+
+#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
+    ap_rputs(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n", r);
+#endif
+
+#ifdef OS
+    ap_rputs(" -D OS=\"" OS "\"\n", r);
+#endif
+
+#ifdef APACHE_MPM_DIR
+    ap_rputs(" -D APACHE_MPM_DIR=\"" APACHE_MPM_DIR "\"\n", r);
+#endif
+
+#ifdef HAVE_SHMGET
+    ap_rputs(" -D HAVE_SHMGET\n", r);
+#endif
+
+#if APR_FILE_BASED_SHM
+    ap_rputs(" -D APR_FILE_BASED_SHM\n", r);
+#endif
+
+#if APR_HAS_SENDFILE
+    ap_rputs(" -D APR_HAS_SENDFILE\n", r);
+#endif
+
+#if APR_HAS_MMAP
+    ap_rputs(" -D APR_HAS_MMAP\n", r);
+#endif
+
+#ifdef NO_WRITEV
+    ap_rputs(" -D NO_WRITEV\n", r);
+#endif
+
+#ifdef NO_LINGCLOSE
+    ap_rputs(" -D NO_LINGCLOSE\n", r);
+#endif
+
+#if APR_HAVE_IPV6
+    ap_rputs(" -D APR_HAVE_IPV6 (IPv4-mapped addresses ", r);
+#ifdef AP_ENABLE_V4_MAPPED
+    ap_rputs("enabled)\n", r);
+#else
+    ap_rputs("disabled)\n", r);
+#endif
+#endif
+
+#if APR_USE_FLOCK_SERIALIZE
+    ap_rputs(" -D APR_USE_FLOCK_SERIALIZE\n", r);
+#endif
+
+#if APR_USE_SYSVSEM_SERIALIZE
+    ap_rputs(" -D APR_USE_SYSVSEM_SERIALIZE\n", r);
+#endif
+
+#if APR_USE_POSIXSEM_SERIALIZE
+    ap_rputs(" -D APR_USE_POSIXSEM_SERIALIZE\n", r);
+#endif
+
+#if APR_USE_FCNTL_SERIALIZE
+    ap_rputs(" -D APR_USE_FCNTL_SERIALIZE\n", r);
+#endif
+
+#if APR_USE_PROC_PTHREAD_SERIALIZE
+    ap_rputs(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n", r);
+#endif
+#if APR_PROCESS_LOCK_IS_GLOBAL
+    ap_rputs(" -D APR_PROCESS_LOCK_IS_GLOBAL\n", r);
+#endif
+
+#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+    ap_rputs(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n", r);
+#endif
+
+#if APR_HAS_OTHER_CHILD
+    ap_rputs(" -D APR_HAS_OTHER_CHILD\n", r);
+#endif
+
+#ifdef AP_HAVE_RELIABLE_PIPED_LOGS
+    ap_rputs(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n", r);
+#endif
+
+#ifdef BUFFERED_LOGS
+    ap_rputs(" -D BUFFERED_LOGS\n", r);
+#ifdef PIPE_BUF
+    ap_rputs(" -D PIPE_BUF=%ld\n", (long) PIPE_BUF, r);
+#endif
+#endif
+
+#if APR_CHARSET_EBCDIC
+    ap_rputs(" -D APR_CHARSET_EBCDIC\n", r);
+#endif
+
+#ifdef NEED_HASHBANG_EMUL
+    ap_rputs(" -D NEED_HASHBANG_EMUL\n", r);
+#endif
+
+#ifdef SHARED_CORE
+    ap_rputs(" -D SHARED_CORE\n", r);
+#endif
+
+/* This list displays the compiled in default paths: */
+#ifdef HTTPD_ROOT
+    ap_rputs(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n", r);
+#endif
+
+#ifdef SUEXEC_BIN
+    ap_rputs(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n", r);
+#endif
+
+#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)
+    ap_rputs(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n", r);
+#endif
+
+#ifdef DEFAULT_PIDLOG
+    ap_rputs(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n", r);
+#endif
+
+#ifdef DEFAULT_SCOREBOARD
+    ap_rputs(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n", r);
+#endif
+
+#ifdef DEFAULT_LOCKFILE
+    ap_rputs(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n", r);
+#endif
+
+#ifdef DEFAULT_ERRORLOG
+    ap_rputs(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n", r);
+#endif
+
+
+#ifdef AP_TYPES_CONFIG_FILE
+    ap_rputs(" -D AP_TYPES_CONFIG_FILE=\"" AP_TYPES_CONFIG_FILE "\"\n", r);
+#endif
+
+#ifdef SERVER_CONFIG_FILE
+    ap_rputs(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n", r);
+#endif
+    ap_rputs("</pre></tt></dt>\n", r);
+    ap_rputs("</dl><hr />", r);
+    return 0;
+}
+
+static int dump_a_hook(request_rec *r, hook_get_t hook_get)
+{
+    int i;
+    char qs;
+    hook_struct_t *elts;
+    apr_array_header_t *hooks = hook_get();
+
+    if (!hooks) {
+        return 0;
+    }
+
+    if (r->args && strcasecmp(r->args, "hooks") == 0) {
+        qs = '?';
+    }
+    else {
+        qs = '#';
+    }
+
+    elts = (hook_struct_t *) hooks->elts;
+
+    for (i = 0; i < hooks->nelts; i++) {
+        ap_rprintf(r,
+                       "&nbsp;&nbsp; %02d <a href=\"%c%s\">%s</a> <br/>",
+                       elts[i].nOrder, qs, elts[i].szName, elts[i].szName);
+    }
+    return 0;
+}
+
+static int show_hooks_settings(request_rec *r)
+{
+    int i;
+    ap_rputs("<a name=\"hooks\"><h2>Active Hooks</h2></a>\n<dl>", r);
+
+    for (i = 0; request_hooks[i].name; i++) {
+        ap_rprintf(r, "<dt><strong>%s:</strong>\n <br /><tt>\n",
+                   request_hooks[i].name);
+        dump_a_hook(r, request_hooks[i].get);
+        ap_rputs("\n  </tt>\n</dt>\n", r);
+    }
+
+    ap_rputs("</dl>\n<hr />\n", r);
+
+    return 0;
+}
+
 static int display_info(request_rec *r)
 {
     module *modp = NULL;
+    server_rec *serv = r->server;
     const char *more_info;
     const command_rec *cmd = NULL;
-#ifdef NEVERMORE
-    const handler_rec *hand = NULL;
-#endif
-    server_rec *serv = r->server;
     int comma = 0;
 
     if (strcmp(r->handler, "server-info"))
@@ -330,14 +576,27 @@ static int display_info(request_rec *r)
 
     ap_set_content_type(r, "text/html");
 
-    ap_rputs(DOCTYPE_HTML_3_2
-             "<html><head><title>Server Information</title></head>\n", r);
-    ap_rputs("<body><h1 align=\"center\">Apache Server Information</h1>\n",
+    ap_rputs(DOCTYPE_XHTML_1_0T
+             "<html>\n <head>\n  <title>Server Information</title>\n </head>\n",
              r);
+    ap_rputs("<body><h1 style=\"text-align: center\">"
+             "Apache Server Information</h1>\n", r);
     if (!r->args || strcasecmp(r->args, "list")) {
         if (!r->args) {
-            ap_rputs("<dl><dt><tt><a href=\"#server\">Server Settings</a>, ",
-                     r);
+            ap_rputs("<dl><dt><tt>Subpages:<br />", r);
+            ap_rputs("<a href=\"?config\">Configuration Files</a>, "
+                     "<a href=\"?server\">Server Settings</a>, "
+                     "<a href=\"?list\">Module List</a>,  "
+                     "<a href=\"?hooks\">Active Hooks</a>", r);
+            ap_rputs("</tt></dt></dl><hr />", r);
+
+            ap_rputs("<dl><dt><tt>Sections:<br />", r);
+            ap_rputs("<a href=\"#server\">Server Settings</a>, "
+                     "<a href=\"#hooks\">Active Hooks</a>", r);
+            ap_rputs("</tt></dt></dl><hr />", r);
+
+            ap_rputs("<dl><dt><tt>Loaded Modules: <br />", r);
+            /* TODO: Sort by Alpha */
             for (modp = ap_top_module; modp; modp = modp->next) {
                 ap_rprintf(r, "<a href=\"#%s\">%s</a>", modp->name,
                            modp->name);
@@ -346,51 +605,16 @@ static int display_info(request_rec *r)
                 }
             }
             ap_rputs("</tt></dt></dl><hr />", r);
-
         }
+
         if (!r->args || !strcasecmp(r->args, "server")) {
-            int max_daemons, forked, threaded;
-
-            ap_rprintf(r,
-                       "<dl><dt><a name=\"server\"><strong>Server Version:</strong> "
-                       "<font size=\"+1\"><tt>%s</tt></font></a></dt>\n",
-                       ap_get_server_version());
-            ap_rprintf(r,
-                       "<dt><strong>Server Built:</strong> "
-                       "<font size=\"+1\"><tt>%s</tt></font></dt>\n",
-                       ap_get_server_built());
-            ap_rprintf(r,
-                       "<dt><strong>API Version:</strong> "
-                       "<tt>%d:%d</tt></dt>\n", MODULE_MAGIC_NUMBER_MAJOR,
-                       MODULE_MAGIC_NUMBER_MINOR);
-            ap_rprintf(r,
-                       "<dt><strong>Hostname/port:</strong> "
-                       "<tt>%s:%u</tt></dt>\n", ap_get_server_name(r),
-                       ap_get_server_port(r));
-            ap_rprintf(r,
-                       "<dt><strong>Timeouts:</strong> "
-                       "<tt>connection: %d &nbsp;&nbsp; "
-                       "keep-alive: %d</tt></dt>",
-                       (int) (apr_time_sec(serv->timeout)),
-                       (int) (apr_time_sec(serv->timeout)));
-            ap_mpm_query(AP_MPMQ_MAX_DAEMON_USED, &max_daemons);
-            ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded);
-            ap_mpm_query(AP_MPMQ_IS_FORKED, &forked);
-            ap_rprintf(r, "<dt><strong>MPM Name:</strong> <tt>%s</tt></dt>\n",
-                       ap_show_mpm());
-            ap_rprintf(r,
-                       "<dt><strong>MPM Information:</strong> "
-                       "<tt>Max Daemons: %d Threaded: %s Forked: %s</tt></dt>\n",
-                       max_daemons, threaded ? "yes" : "no",
-                       forked ? "yes" : "no");
-            ap_rprintf(r,
-                       "<dt><strong>Server Root:</strong> "
-                       "<tt>%s</tt></dt>\n", ap_server_root);
-            ap_rprintf(r,
-                       "<dt><strong>Config File:</strong> "
-                       "<tt>%s</tt></dt>\n", ap_conftree->filename);
-            ap_rputs("</dl><hr />", r);
+            show_server_settings(r);
         }
+
+        if (!r->args || !strcasecmp(r->args, "hooks")) {
+            show_hooks_settings(r);
+        }
+
         if (r->args && 0 == strcasecmp(r->args, "config")) {
             ap_rputs("<dl><dt><strong>Configuration:</strong>\n", r);
             mod_info_module_cmds(r, NULL, ap_conftree, 0, 0);
@@ -400,38 +624,18 @@ static int display_info(request_rec *r)
             for (modp = ap_top_module; modp; modp = modp->next) {
                 if (!r->args || !strcasecmp(modp->name, r->args)) {
                     ap_rprintf(r,
-                               "<dl><dt><a name=\"%s\"><strong>Module Name:</strong> "
-                               "<font size=\"+1\"><tt>%s</tt></font></a></dt>\n",
-                               modp->name, modp->name);
+                               "<dl><dt><a name=\"%s\"><strong>Module Name:</strong></a> "
+                               "<font size=\"+1\"><tt><a href=\"?%s\">%s</a></tt></font></dt>\n",
+                               modp->name, modp->name, modp->name);
                     ap_rputs("<dt><strong>Content handlers:</strong> ", r);
-#ifdef NEVERMORE
-                    hand = modp->handlers;
-                    if (hand) {
-                        while (hand) {
-                            if (hand->content_type) {
-                                ap_rprintf(r, " <tt>%s</tt>\n",
-                                           hand->content_type);
-                            }
-                            else {
-                                break;
-                            }
-                            hand++;
-                            if (hand && hand->content_type) {
-                                ap_rputs(",", r);
-                            }
-                        }
-                    }
-                    else {
-                        ap_rputs("<tt> <em>none</em></tt>", r);
-                    }
-#else
+
                     if (module_find_hook(modp, ap_hook_get_handler)) {
                         ap_rputs("<tt> <em>yes</em></tt>", r);
                     }
                     else {
                         ap_rputs("<tt> <em>none</em></tt>", r);
                     }
-#endif
+
                     ap_rputs("</dt>", r);
                     ap_rputs
                         ("<dt><strong>Configuration Phase Participation:</strong>\n",