mod_info.c revision 08cecb2a91c86c409dc905266479725e3dbfb19d
/* Copyright 1999-2004 Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Info Module. Display configuration information for the server and
* all included modules.
*
* <Location /server-info>
* SetHandler server-info
* </Location>
*
* GET /server-info - Returns full configuration page for server and all modules
* GET /server-info?server - Returns server configuration only
* GET /server-info?module_name - Returns configuration for a single module
* GET /server-info?list - Returns quick list of included modules
*
* Rasmus Lerdorf <rasmus@vex.net>, May 1996
*
* 05.01.96 Initial Version
*
* Lou Langholtz <ldl@usi.utah.edu>, July 1997
*
* 07.11.97 Addition of the AddModuleInfo directive
*
* Ryan Morgan <rmorgan@covalent.net>
*
* 8.11.00 Port to Apache 2.0. Read configuation from the configuration
* tree rather than reparse the entire configuation file.
*
*/
#define CORE_PRIVATE
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_main.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 {
const char *name; /* matching module name */
const char *info; /* additional info */
} info_entry;
typedef struct {
{
return conf;
}
{
return new;
}
int close)
{
const char *s;
s = string;
/* keep space for \0 byte */
while (*s) {
if (*s == '<') {
if (close) {
ap_rputs("</", r);
} else {
ap_rputs("<", r);
}
}
else if (*s == '>') {
ap_rputs(">", r);
}
else if (*s == '&') {
ap_rputs("&", r);
}
else if (*s == ' ') {
if (close) {
ap_rputs(">", r);
break;
} else {
ap_rputc(*s, r);
}
} else {
ap_rputc(*s, r);
}
s++;
}
}
{
const command_rec *cmd;
char htmlstring[MAX_STRING_LEN];
int block_start = 0;
int nest = 0;
if (nest > block_start) {
block_start++;
ap_rputs("<dd><tt>", r);
mod_info_html_cmd_string(r, htmlstring, 0);
ap_rputs("</tt></dd>\n", r);
}
if (nest == 2) {
ap_rprintf(r, "<dd><tt> %s "
"<i>%s</i></tt></dd>\n",
} else if (nest == 1) {
ap_rprintf(r,
"<dd><tt> %s <i>%s</i></tt></dd>\n",
} else {
ap_rputs("<dd><tt>", r);
ap_rprintf(r, " <i>%s</i></tt></dd>\n",
}
}
++cmd;
}
nest++;
} else {
if (block_start) {
ap_rputs("<dd><tt>", r);
ap_rputs("</tt></dd>\n", r);
block_start--;
}
}
else {
}
nest--;
}
}
}
typedef struct { /*XXX: should get something from apr_hooks.h instead */
void (*pFunc)(void); /* just to get the right size */
const char *szName;
const char * const *aszPredecessors;
const char * const *aszSuccessors;
int nOrder;
/*
* hook_get_t is a pointer to a function that takes void as an argument and
* returns a pointer to an apr_array_header_t. The nasty WIN32 ifdef
* is required to account for the fact that the ap_hook* calls all use
* STDCALL calling convention.
*/
typedef apr_array_header_t * (
#ifdef WIN32
#endif
* hook_get_t)(void);
typedef struct {
const char *name;
static hook_lookup_t request_hooks[] = {
{"Post-Read Request", ap_hook_get_post_read_request},
{"Header Parse", ap_hook_get_header_parser},
{"Translate Path", ap_hook_get_translate_name},
{"Check Access", ap_hook_get_access_checker},
{"Verify User ID", ap_hook_get_check_user_id},
{"Verify User Access", ap_hook_get_auth_checker},
{"Check Type", ap_hook_get_type_checker},
{"Fixups", ap_hook_get_fixups},
{"Logging", ap_hook_get_log_transaction},
{NULL},
};
{
int i;
if (!hooks) {
return 0;
}
return 1;
}
}
return 0;
}
static void module_participate(request_rec *r,
int *comma)
{
if (*comma) {
ap_rputs(", ", r);
}
*comma = 1;
}
}
{
int i, comma=0;
ap_rputs("<dt><strong>Request Phase Participation:</strong>\n", r);
for (i=0; request_hooks[i].name; i++) {
}
if (!comma) {
ap_rputs("<tt> <em>none</em></tt>", r);
}
ap_rputs("</dt>\n", r);
}
{
int i;
&info_module);
if (!module_name) {
return 0;
}
}
entry++;
}
return 0;
}
static int display_info(request_rec *r)
{
const char *more_info;
#ifdef NEVERMORE
#endif
int comma = 0;
return DECLINED;
if (r->method_number != M_GET)
return DECLINED;
ap_set_content_type(r, "text/html");
"<html><head><title>Server Information</title></head>\n", r);
ap_rputs("<body><h1 align=\"center\">Apache Server Information</h1>\n", r);
if (!r->args) {
ap_rputs("<dl><dt><tt><a href=\"#server\">Server Settings</a>, ", r);
ap_rputs(", ", r);
}
}
ap_rputs("</tt></dt></dl><hr />", r);
}
ap_rprintf(r, "<dl><dt><a name=\"server\"><strong>Server Version:</strong> "
"<font size=\"+1\"><tt>%s</tt></font></a></dt>\n",
ap_rprintf(r, "<dt><strong>Server Built:</strong> "
"<font size=\"+1\"><tt>%s</tt></font></dt>\n",
ap_rprintf(r, "<dt><strong>API Version:</strong> "
"<tt>%d:%d</tt></dt>\n",
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 "
"keep-alive: %d</tt></dt>",
ap_rprintf(r, "<dt><strong>MPM Information:</strong> "
"<tt>Max Daemons: %d Threaded: %s Forked: %s</tt></dt>\n",
ap_rprintf(r, "<dt><strong>Server Root:</strong> "
"<tt>%s</tt></dt>\n", ap_server_root);
ap_rprintf(r, "<dt><strong>Config File:</strong> "
ap_rputs("</dl><hr />", r);
}
ap_rprintf(r, "<dl><dt><a name=\"%s\"><strong>Module Name:</strong> "
"<font size=\"+1\"><tt>%s</tt></font></a></dt>\n",
ap_rputs("<dt><strong>Content handlers:</strong> ", r);
#ifdef NEVERMORE
if (hand) {
while (hand) {
if (hand->content_type) {
}
else {
break;
}
hand++;
ap_rputs(",", r);
}
}
}
else {
ap_rputs("<tt> <em>none</em></tt>", r);
}
#else
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",
r);
if (modp->create_dir_config) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Create Directory Config</tt>", r);
comma = 1;
}
if (modp->merge_dir_config) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Merge Directory Configs</tt>", r);
comma = 1;
}
if (modp->create_server_config) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Create Server Config</tt>", r);
comma = 1;
}
if (modp->merge_server_config) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Merge Server Configs</tt>", r);
comma = 1;
}
if (!comma)
ap_rputs("<tt> <em>none</em></tt>", r);
comma = 0;
ap_rputs("</dt>", r);
if (cmd) {
ap_rputs("<dt><strong>Module Directives:</strong></dt>", r);
while (cmd) {
ap_rputs("<dd><tt>", r);
ap_rputs(" - <i>", r);
}
ap_rputs("</i></tt></dd>\n", r);
}
else {
break;
}
cmd++;
}
ap_rputs("<dt><strong>Current Configuration:</strong></dt>\n", r);
}
else {
ap_rputs("<dt><strong>Module Directives:</strong> <tt>none</tt></dt>", r);
}
if (more_info) {
ap_rputs("<dt><strong>Additional Information:</strong>\n</dt><dd>",
r);
ap_rputs("</dd>", r);
}
ap_rputs("</dl><hr />\n", r);
if (r->args) {
break;
}
}
}
ap_rputs("<p><b>No such module</b></p>\n", r);
}
}
else {
ap_rputs("<dl><dt>Server Module List</dt>", r);
ap_rputs("<dd>", r);
ap_rputs("</dd>", r);
}
ap_rputs("</dl><hr />", r);
}
ap_rputs("</body></html>\n", r);
/* Done, turn off timeout, close file and return */
return 0;
}
{
&info_module);
return NULL;
}
static const command_rec info_cmds[] =
{
"a module name and additional information on that module"),
{NULL}
};
static void register_hooks(apr_pool_t *p)
{
}
{
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
create_info_config, /* server config */
merge_info_config, /* merge server config */
info_cmds, /* command apr_table_t */
};