home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 April / PCO0499.ISO / filesbbs / os2 / apach134.arj / APACH134.ZIP / src / modules / standard / mod_info.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-01  |  25.3 KB  |  695 lines

  1. /* ====================================================================
  2.  * Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  *
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer. 
  10.  *
  11.  * 2. Redistributions in binary form must reproduce the above copyright
  12.  *    notice, this list of conditions and the following disclaimer in
  13.  *    the documentation and/or other materials provided with the
  14.  *    distribution.
  15.  *
  16.  * 3. All advertising materials mentioning features or use of this
  17.  *    software must display the following acknowledgment:
  18.  *    "This product includes software developed by the Apache Group
  19.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  20.  *
  21.  * 4. The names "Apache Server" and "Apache Group" must not be used to
  22.  *    endorse or promote products derived from this software without
  23.  *    prior written permission. For written permission, please contact
  24.  *    apache@apache.org.
  25.  *
  26.  * 5. Products derived from this software may not be called "Apache"
  27.  *    nor may "Apache" appear in their names without prior written
  28.  *    permission of the Apache Group.
  29.  *
  30.  * 6. Redistributions of any form whatsoever must retain the following
  31.  *    acknowledgment:
  32.  *    "This product includes software developed by the Apache Group
  33.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  36.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  38.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  41.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  44.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  45.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  46.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Group and was originally based
  51.  * on public domain software written at the National Center for
  52.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  53.  * For more information on the Apache Group and the Apache HTTP server
  54.  * project, please see <http://www.apache.org/>.
  55.  *
  56.  */
  57.  
  58. /* 
  59.  * Info Module.  Display configuration information for the server and
  60.  * all included modules.
  61.  *
  62.  * <Location /server-info>
  63.  * SetHandler server-info
  64.  * </Location>
  65.  *
  66.  * GET /server-info - Returns full configuration page for server and all modules
  67.  * GET /server-info?server - Returns server configuration only
  68.  * GET /server-info?module_name - Returns configuration for a single module
  69.  * GET /server-info?list - Returns quick list of included modules
  70.  *
  71.  * Rasmus Lerdorf <rasmus@vex.net>, May 1996
  72.  *
  73.  * 05.01.96 Initial Version
  74.  *
  75.  * Lou Langholtz <ldl@usi.utah.edu>, July 1997
  76.  *
  77.  * 07.11.97 Addition of the AddModuleInfo directive
  78.  * 
  79.  */
  80.  
  81. #include "httpd.h"
  82. #include "http_config.h"
  83. #include "http_core.h"
  84. #include "http_log.h"
  85. #include "http_main.h"
  86. #include "http_protocol.h"
  87. #include "util_script.h"
  88. #include "http_conf_globals.h"
  89.  
  90. typedef struct {
  91.     char *name;                 /* matching module name */
  92.     char *info;                 /* additional info */
  93. } info_entry;
  94.  
  95. typedef struct {
  96.     array_header *more_info;
  97. } info_svr_conf;
  98.  
  99. typedef struct info_cfg_lines {
  100.     char *cmd;
  101.     char *line;
  102.     struct info_cfg_lines *next;
  103. } info_cfg_lines;
  104.  
  105. module MODULE_VAR_EXPORT info_module;
  106. extern module *top_module;
  107.  
  108. static void *create_info_config(pool *p, server_rec *s)
  109. {
  110.     info_svr_conf *conf = (info_svr_conf *) ap_pcalloc(p, sizeof(info_svr_conf));
  111.  
  112.     conf->more_info = ap_make_array(p, 20, sizeof(info_entry));
  113.     return conf;
  114. }
  115.  
  116. static void *merge_info_config(pool *p, void *basev, void *overridesv)
  117. {
  118.     info_svr_conf *new = (info_svr_conf *) ap_pcalloc(p, sizeof(info_svr_conf));
  119.     info_svr_conf *base = (info_svr_conf *) basev;
  120.     info_svr_conf *overrides = (info_svr_conf *) overridesv;
  121.  
  122.     new->more_info = ap_append_arrays(p, overrides->more_info, base->more_info);
  123.     return new;
  124. }
  125.  
  126. static char *mod_info_html_cmd_string(const char *string, char *buf, size_t buf_len)
  127. {
  128.     const char *s;
  129.     char *t;
  130.     char *end_buf;
  131.  
  132.     s = string;
  133.     t = buf;
  134.     /* keep space for \0 byte */
  135.     end_buf = buf + buf_len - 1;
  136.     while ((*s) && (t < end_buf)) {
  137.         if (*s == '<') {
  138.             strncpy(t, "<", end_buf - t);
  139.             t += 4;
  140.         }
  141.         else if (*s == '>') {
  142.             strncpy(t, ">", end_buf - t);
  143.             t += 4;
  144.         }
  145.         else if (*s == '&') {
  146.             strncpy(t, "&", end_buf - t);
  147.             t += 5;
  148.         }
  149.         else {
  150.             *t++ = *s;
  151.         }
  152.         s++;
  153.     }
  154.     /* oops, overflowed... don't overwrite */
  155.     if (t > end_buf) {
  156.     *end_buf = '\0';
  157.     }
  158.     else {
  159.     *t = '\0';
  160.     }
  161.     return (buf);
  162. }
  163.  
  164. static info_cfg_lines *mod_info_load_config(pool *p, const char *filename,
  165.                                             request_rec *r)
  166. {
  167.     char s[MAX_STRING_LEN];
  168.     configfile_t *fp;
  169.     info_cfg_lines *new, *ret, *prev;
  170.     const char *t;
  171.  
  172.     fp = ap_pcfg_openfile(p, filename);
  173.     if (!fp) {
  174.         ap_log_rerror(APLOG_MARK, APLOG_WARNING, r, 
  175.             "mod_info: couldn't open config file %s",
  176.             filename);
  177.         return NULL;
  178.     }
  179.     ret = NULL;
  180.     prev = NULL;
  181.     while (!ap_cfg_getline(s, MAX_STRING_LEN, fp)) {
  182.         if (*s == '#') {
  183.             continue;           /* skip comments */
  184.         }
  185.         new = ap_palloc(p, sizeof(struct info_cfg_lines));
  186.         new->next = NULL;
  187.         if (!ret) {
  188.             ret = new;
  189.         }
  190.         if (prev) {
  191.             prev->next = new;
  192.         }
  193.     t = s;
  194.     new->cmd = ap_getword_conf(p, &t);
  195.     if (*t) {
  196.         new->line = ap_pstrdup(p, t);
  197.     }
  198.     else {
  199.         new->line = NULL;
  200.     }
  201.         prev = new;
  202.     }
  203.     ap_cfg_closefile(fp);
  204.     return (ret);
  205. }
  206.  
  207. static void mod_info_module_cmds(request_rec *r, info_cfg_lines *cfg,
  208.                                  const command_rec *cmds, char *label)
  209. {
  210.     const command_rec *cmd = cmds;
  211.     info_cfg_lines *li = cfg, *li_st = NULL, *li_se = NULL;
  212.     info_cfg_lines *block_start = NULL;
  213.     int lab = 0, nest = 0;
  214.     char buf[MAX_STRING_LEN];
  215.  
  216.     while (li) {
  217.         if (!strncasecmp(li->cmd, "<directory", 10) ||
  218.             !strncasecmp(li->cmd, "<location", 9) ||
  219.             !strncasecmp(li->cmd, "<limit", 6) ||
  220.             !strncasecmp(li->cmd, "<files", 6)) {
  221.             if (nest) {
  222.                 li_se = li;
  223.             }
  224.             else {
  225.                 li_st = li;
  226.             }
  227.             li = li->next;
  228.             nest++;
  229.             continue;
  230.         }
  231.         else if (nest && (!strncasecmp(li->cmd, "</limit", 7) ||
  232.                           !strncasecmp(li->cmd, "</location", 10) ||
  233.                           !strncasecmp(li->cmd, "</directory", 11) ||
  234.                           !strncasecmp(li->cmd, "</files", 7))) {
  235.             if (block_start) {
  236.                 if ((nest == 1 && block_start == li_st) ||
  237.                     (nest == 2 && block_start == li_se)) {
  238.                     ap_rputs("<dd><tt>", r);
  239.                     if (nest == 2) {
  240.                         ap_rputs("  ", r);
  241.                     }
  242.                     ap_rputs(mod_info_html_cmd_string(li->cmd, buf, sizeof(buf)), r);
  243.                     ap_rputs(" ", r);
  244.                     if (li->line) {
  245.                         ap_rputs(mod_info_html_cmd_string(li->line, buf, sizeof(buf)), r);
  246.                     }
  247.                     ap_rputs("</tt>\n", r);
  248.                     nest--;
  249.                     if (!nest) {
  250.                         block_start = NULL;
  251.                         li_st = NULL;
  252.                     }
  253.                     else {
  254.                         block_start = li_st;
  255.                     }
  256.                     li_se = NULL;
  257.                 }
  258.                 else {
  259.                     nest--;
  260.                     if (!nest) {
  261.                         li_st = NULL;
  262.                     }
  263.                     li_se = NULL;
  264.                 }
  265.             }
  266.             else {
  267.                 nest--;
  268.                 if (!nest) {
  269.                     li_st = NULL;
  270.                 }
  271.                 li_se = NULL;
  272.             }
  273.             li = li->next;
  274.             continue;
  275.         }
  276.         cmd = cmds;
  277.         while (cmd) {
  278.             if (cmd->name) {
  279.                 if (!strcasecmp(cmd->name, li->cmd)) {
  280.                     if (!lab) {
  281.                         ap_rputs("<dt><strong>", r);
  282.                         ap_rputs(label, r);
  283.                         ap_rputs("</strong>\n", r);
  284.                         lab = 1;
  285.                     }
  286.                     if (((nest && block_start == NULL) ||
  287.                          (nest == 2 && block_start == li_st)) &&
  288.                         (strncasecmp(li->cmd, "<directory", 10) &&
  289.                          strncasecmp(li->cmd, "<location", 9) &&
  290.                          strncasecmp(li->cmd, "<limit", 6) &&
  291.                          strncasecmp(li->cmd, "</limit", 7) &&
  292.                          strncasecmp(li->cmd, "</location", 10) &&
  293.                          strncasecmp(li->cmd, "</directory", 11) &&
  294.                          strncasecmp(li->cmd, "</files", 7))) {
  295.                         ap_rputs("<dd><tt>", r);
  296.                         ap_rputs(mod_info_html_cmd_string(li_st->cmd, buf, sizeof(buf)), r);
  297.                         ap_rputs(" ", r);
  298.                         if (li_st->line) {
  299.                             ap_rputs(mod_info_html_cmd_string(li_st->line, buf, sizeof(buf)), r);
  300.                         }
  301.                         ap_rputs("</tt>\n", r);
  302.                         block_start = li_st;
  303.                         if (li_se) {
  304.                             ap_rputs("<dd><tt>  ", r);
  305.                             ap_rputs(mod_info_html_cmd_string(li_se->cmd, buf, sizeof(buf)), r);
  306.                             ap_rputs(" ", r);
  307.                             if (li_se->line) {
  308.                                 ap_rputs(mod_info_html_cmd_string(li_se->line, buf, sizeof(buf)), r);
  309.                             }
  310.                             ap_rputs("</tt>\n", r);
  311.                             block_start = li_se;
  312.                         }
  313.                     }
  314.                     ap_rputs("<dd><tt>", r);
  315.                     if (nest) {
  316.                         ap_rputs("  ", r);
  317.                     }
  318.                     if (nest == 2) {
  319.                         ap_rputs("  ", r);
  320.                     }
  321.                     ap_rputs(mod_info_html_cmd_string(li->cmd, buf, sizeof(buf)), r);
  322.                     if (li->line) {
  323.                         ap_rputs(" <i>", r);
  324.                         ap_rputs(mod_info_html_cmd_string(li->line, buf, sizeof(buf)), r);
  325.                         ap_rputs("</i>", r);
  326.                     }
  327.             ap_rputs("</tt>", r);
  328.                 }
  329.             }
  330.             else
  331.                 break;
  332.             cmd++;
  333.         }
  334.         li = li->next;
  335.     }
  336. }
  337.  
  338. static char *find_more_info(server_rec *s, const char *module_name)
  339. {
  340.     int i;
  341.     info_svr_conf *conf = (info_svr_conf *) ap_get_module_config(s->module_config,
  342.                                                               &info_module);
  343.     info_entry *entry = (info_entry *) conf->more_info->elts;
  344.  
  345.     if (!module_name) {
  346.         return 0;
  347.     }
  348.     for (i = 0; i < conf->more_info->nelts; i++) {
  349.         if (!strcmp(module_name, entry->name)) {
  350.             return entry->info;
  351.         }
  352.         entry++;
  353.     }
  354.     return 0;
  355. }
  356.  
  357. static int display_info(request_rec *r)
  358. {
  359.     module *modp = NULL;
  360.     char buf[MAX_STRING_LEN], *cfname;
  361.     char *more_info;
  362.     const command_rec *cmd = NULL;
  363.     const handler_rec *hand = NULL;
  364.     server_rec *serv = r->server;
  365.     int comma = 0;
  366.     info_cfg_lines *mod_info_cfg_httpd = NULL;
  367.     info_cfg_lines *mod_info_cfg_srm = NULL;
  368.     info_cfg_lines *mod_info_cfg_access = NULL;
  369.  
  370.     r->allowed |= (1 << M_GET);
  371.     if (r->method_number != M_GET)
  372.     return DECLINED;
  373.  
  374.     r->content_type = "text/html";
  375.     ap_send_http_header(r);
  376.     if (r->header_only) {
  377.         return 0;
  378.     }
  379.     ap_hard_timeout("send server info", r);
  380.  
  381.     ap_rputs("<html><head><title>Server Information</title></head>\n", r);
  382.     ap_rputs("<body><h1 align=center>Apache Server Information</h1>\n", r);
  383.     if (!r->args || strcasecmp(r->args, "list")) {
  384.         cfname = ap_server_root_relative(r->pool, ap_server_confname);
  385.         mod_info_cfg_httpd = mod_info_load_config(r->pool, cfname, r);
  386.         cfname = ap_server_root_relative(r->pool, serv->srm_confname);
  387.         mod_info_cfg_srm = mod_info_load_config(r->pool, cfname, r);
  388.         cfname = ap_server_root_relative(r->pool, serv->access_confname);
  389.         mod_info_cfg_access = mod_info_load_config(r->pool, cfname, r);
  390.         if (!r->args) {
  391.             ap_rputs("<tt><a href=\"#server\">Server Settings</a>, ", r);
  392.             for (modp = top_module; modp; modp = modp->next) {
  393.                 ap_rprintf(r, "<a href=\"#%s\">%s</a>", modp->name, modp->name);
  394.                 if (modp->next) {
  395.                     ap_rputs(", ", r);
  396.                 }
  397.             }
  398.             ap_rputs("</tt><hr>", r);
  399.  
  400.         }
  401.         if (!r->args || !strcasecmp(r->args, "server")) {
  402.             ap_rprintf(r, "<a name=\"server\"><strong>Server Version:</strong> "
  403.                         "<font size=+1><tt>%s</tt></a></font><br>\n",
  404.                         ap_get_server_version());
  405.             ap_rprintf(r, "<strong>Server Built:</strong> "
  406.                         "<font size=+1><tt>%s</tt></a></font><br>\n",
  407.                         ap_get_server_built());
  408.             ap_rprintf(r, "<strong>API Version:</strong> "
  409.                         "<tt>%d:%d</tt><br>\n",
  410.                         MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
  411.             ap_rprintf(r, "<strong>Run Mode:</strong> <tt>%s</tt><br>\n",
  412.                         (ap_standalone ? "standalone" : "inetd"));
  413.             ap_rprintf(r, "<strong>User/Group:</strong> "
  414.                         "<tt>%s(%d)/%d</tt><br>\n",
  415.                         ap_user_name, (int) ap_user_id, (int) ap_group_id);
  416.             ap_rprintf(r, "<strong>Hostname/port:</strong> "
  417.                         "<tt>%s:%u</tt><br>\n",
  418.                         serv->server_hostname, serv->port);
  419.             ap_rprintf(r, "<strong>Daemons:</strong> "
  420.                         "<tt>start: %d    "
  421.                         "min idle: %d    "
  422.                         "max idle: %d    "
  423.                         "max: %d</tt><br>\n",
  424.                         ap_daemons_to_start, ap_daemons_min_free,
  425.                         ap_daemons_max_free, ap_daemons_limit);
  426.             ap_rprintf(r, "<strong>Max Requests:</strong> "
  427.                         "<tt>per child: %d    "
  428.                         "keep alive: %s    "
  429.                         "max per connection: %d</tt><br>\n",
  430.                         ap_max_requests_per_child,
  431.                         (serv->keep_alive ? "on" : "off"),
  432.                         serv->keep_alive_max);
  433.             ap_rprintf(r, "<strong>Threads:</strong> "
  434.                         "<tt>per child: %d    </tt><br>\n",
  435.                         ap_threads_per_child);
  436.             ap_rprintf(r, "<strong>Excess requests:</strong> "
  437.                         "<tt>per child: %d    </tt><br>\n",
  438.                         ap_excess_requests_per_child);
  439.             ap_rprintf(r, "<strong>Timeouts:</strong> "
  440.                         "<tt>connection: %d    "
  441.                         "keep-alive: %d</tt><br>",
  442.                         serv->timeout, serv->keep_alive_timeout);
  443.             ap_rprintf(r, "<strong>Server Root:</strong> "
  444.                         "<tt>%s</tt><br>\n", ap_server_root);
  445.             ap_rprintf(r, "<strong>Config File:</strong> "
  446.                         "<tt>%s</tt><br>\n", ap_server_confname);
  447.             ap_rprintf(r, "<strong>PID File:</strong> "
  448.                         "<tt>%s</tt><br>\n", ap_pid_fname);
  449.             ap_rprintf(r, "<strong>Scoreboard File:</strong> "
  450.                         "<tt>%s</tt><br>\n", ap_scoreboard_fname);
  451.         }
  452.         ap_rputs("<hr><dl>", r);
  453.         for (modp = top_module; modp; modp = modp->next) {
  454.             if (!r->args || !strcasecmp(modp->name, r->args)) {
  455.                 ap_rprintf(r, "<dt><a name=\"%s\"><strong>Module Name:</strong> "
  456.                             "<font size=+1><tt>%s</tt></a></font>\n",
  457.                             modp->name, modp->name);
  458.                 ap_rputs("<dt><strong>Content handlers:</strong>", r);
  459.                 hand = modp->handlers;
  460.                 if (hand) {
  461.                     while (hand) {
  462.                         if (hand->content_type) {
  463.                             ap_rprintf(r, " <tt>%s</tt>\n", hand->content_type);
  464.                         }
  465.                         else {
  466.                             break;
  467.                         }
  468.                         hand++;
  469.                         if (hand && hand->content_type) {
  470.                             ap_rputs(",", r);
  471.                         }
  472.                     }
  473.                 }
  474.                 else {
  475.                     ap_rputs("<tt> <EM>none</EM></tt>", r);
  476.                 }
  477.                 ap_rputs("<dt><strong>Configuration Phase Participation:</strong> \n",
  478.                       r);
  479.                 if (modp->child_init) {
  480.                     ap_rputs("<tt>Child Init</tt>", r);
  481.                     comma = 1;
  482.                 }
  483.                 if (modp->create_dir_config) {
  484.                     if (comma) {
  485.                         ap_rputs(", ", r);
  486.                     }
  487.                     ap_rputs("<tt>Create Directory Config</tt>", r);
  488.                     comma = 1;
  489.                 }
  490.                 if (modp->merge_dir_config) {
  491.                     if (comma) {
  492.                         ap_rputs(", ", r);
  493.                     }
  494.                     ap_rputs("<tt>Merge Directory Configs</tt>", r);
  495.                     comma = 1;
  496.                 }
  497.                 if (modp->create_server_config) {
  498.                     if (comma) {
  499.                         ap_rputs(", ", r);
  500.                     }
  501.                     ap_rputs("<tt>Create Server Config</tt>", r);
  502.                     comma = 1;
  503.                 }
  504.                 if (modp->merge_server_config) {
  505.                     if (comma) {
  506.                         ap_rputs(", ", r);
  507.                     }
  508.                     ap_rputs("<tt>Merge Server Configs</tt>", r);
  509.                     comma = 1;
  510.                 }
  511.                 if (modp->child_exit) {
  512.                     if (comma) {
  513.                         ap_rputs(", ", r);
  514.                     }
  515.                     ap_rputs("<tt>Child Exit</tt>", r);
  516.                     comma = 1;
  517.                 }
  518.                 if (!comma)
  519.                     ap_rputs("<tt> <EM>none</EM></tt>", r);
  520.                 comma = 0;
  521.                 ap_rputs("<dt><strong>Request Phase Participation:</strong> \n",
  522.                       r);
  523.                 if (modp->post_read_request) {
  524.                     ap_rputs("<tt>Post-Read Request</tt>", r);
  525.                     comma = 1;
  526.                 }
  527.                 if (modp->header_parser) {
  528.                     if (comma) {
  529.                         ap_rputs(", ", r);
  530.                     }
  531.                     ap_rputs("<tt>Header Parse</tt>", r);
  532.                     comma = 1;
  533.                 }
  534.                 if (modp->translate_handler) {
  535.                     if (comma) {
  536.                         ap_rputs(", ", r);
  537.                     }
  538.                     ap_rputs("<tt>Translate Path</tt>", r);
  539.                     comma = 1;
  540.                 }
  541.                 if (modp->access_checker) {
  542.                     if (comma) {
  543.                         ap_rputs(", ", r);
  544.                     }
  545.                     ap_rputs("<tt>Check Access</tt>", r);
  546.                     comma = 1;
  547.                 }
  548.                 if (modp->ap_check_user_id) {
  549.                     if (comma) {
  550.                         ap_rputs(", ", r);
  551.                     }
  552.                     ap_rputs("<tt>Verify User ID</tt>", r);
  553.                     comma = 1;
  554.                 }
  555.                 if (modp->auth_checker) {
  556.                     if (comma) {
  557.                         ap_rputs(", ", r);
  558.                     }
  559.                     ap_rputs("<tt>Verify User Access</tt>", r);
  560.                     comma = 1;
  561.                 }
  562.                 if (modp->type_checker) {
  563.                     if (comma) {
  564.                         ap_rputs(", ", r);
  565.                     }
  566.                     ap_rputs("<tt>Check Type</tt>", r);
  567.                     comma = 1;
  568.                 }
  569.                 if (modp->fixer_upper) {
  570.                     if (comma) {
  571.                         ap_rputs(", ", r);
  572.                     }
  573.                     ap_rputs("<tt>Fixups</tt>", r);
  574.                     comma = 1;
  575.                 }
  576.                 if (modp->logger) {
  577.                     if (comma) {
  578.                         ap_rputs(", ", r);
  579.                     }
  580.                     ap_rputs("<tt>Logging</tt>", r);
  581.                     comma = 1;
  582.                 }
  583.                 if (!comma)
  584.                     ap_rputs("<tt> <EM>none</EM></tt>", r);
  585.                 comma = 0;
  586.                 ap_rputs("<dt><strong>Module Directives:</strong> ", r);
  587.                 cmd = modp->cmds;
  588.                 if (cmd) {
  589.                     while (cmd) {
  590.                         if (cmd->name) {
  591.                             ap_rprintf(r, "<dd><tt>%s - <i>",
  592.                     mod_info_html_cmd_string(cmd->name,
  593.                     buf, sizeof(buf)));
  594.                             if (cmd->errmsg) {
  595.                                 ap_rputs(cmd->errmsg, r);
  596.                             }
  597.                             ap_rputs("</i></tt>\n", r);
  598.                         }
  599.                         else {
  600.                             break;
  601.                         }
  602.                         cmd++;
  603.                     }
  604.                     ap_rputs("<dt><strong>Current Configuration:</strong>\n", r);
  605.                     mod_info_module_cmds(r, mod_info_cfg_httpd, modp->cmds,
  606.                                          "httpd.conf");
  607.                     mod_info_module_cmds(r, mod_info_cfg_srm, modp->cmds,
  608.                                          "srm.conf");
  609.                     mod_info_module_cmds(r, mod_info_cfg_access, modp->cmds,
  610.                                          "access.conf");
  611.                 }
  612.                 else {
  613.                     ap_rputs("<tt> none</tt>\n", r);
  614.                 }
  615.                 more_info = find_more_info(serv, modp->name);
  616.                 if (more_info) {
  617.                     ap_rputs("<dt><strong>Additional Information:</strong>\n<dd>",
  618.                           r);
  619.                     ap_rputs(more_info, r);
  620.                 }
  621.                 ap_rputs("<dt><hr>\n", r);
  622.                 if (r->args) {
  623.                     break;
  624.                 }
  625.             }
  626.         }
  627.         if (!modp && r->args && strcasecmp(r->args, "server")) {
  628.             ap_rputs("<b>No such module</b>\n", r);
  629.         }
  630.     }
  631.     else {
  632.         for (modp = top_module; modp; modp = modp->next) {
  633.             ap_rputs(modp->name, r);
  634.             if (modp->next) {
  635.                 ap_rputs("<br>", r);
  636.             }
  637.         }
  638.     }
  639.     ap_rputs("</dl>\n", r);
  640.     ap_rputs(ap_psignature("",r), r);
  641.     ap_rputs("</body></html>\n", r);
  642.     /* Done, turn off timeout, close file and return */
  643.     ap_kill_timeout(r);
  644.     return 0;
  645. }
  646.  
  647. static const char *add_module_info(cmd_parms *cmd, void *dummy, char *name,
  648.                                    char *info)
  649. {
  650.     server_rec *s = cmd->server;
  651.     info_svr_conf *conf = (info_svr_conf *) ap_get_module_config(s->module_config,
  652.                                                               &info_module);
  653.     info_entry *new = ap_push_array(conf->more_info);
  654.  
  655.     new->name = name;
  656.     new->info = info;
  657.     return NULL;
  658. }
  659.  
  660. static const command_rec info_cmds[] =
  661. {
  662.     {"AddModuleInfo", add_module_info, NULL, RSRC_CONF, TAKE2,
  663.      "a module name and additional information on that module"},
  664.     {NULL}
  665. };
  666.  
  667. static const handler_rec info_handlers[] =
  668. {
  669.     {"server-info", display_info},
  670.     {NULL}
  671. };
  672.  
  673. module MODULE_VAR_EXPORT info_module =
  674. {
  675.     STANDARD_MODULE_STUFF,
  676.     NULL,                       /* initializer */
  677.     NULL,                       /* dir config creater */
  678.     NULL,                       /* dir merger --- default is to override */
  679.     create_info_config,         /* server config */
  680.     merge_info_config,          /* merge server config */
  681.     info_cmds,                  /* command table */
  682.     info_handlers,              /* handlers */
  683.     NULL,                       /* filename translation */
  684.     NULL,                       /* check_user_id */
  685.     NULL,                       /* check auth */
  686.     NULL,                       /* check access */
  687.     NULL,                       /* type_checker */
  688.     NULL,                       /* fixups */
  689.     NULL,                       /* logger */
  690.     NULL,                       /* header parser */
  691.     NULL,                       /* child_init */
  692.     NULL,                       /* child_exit */
  693.     NULL                        /* post read-request */
  694. };
  695.