⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_info.c

📁 Apache HTTP Server 是一个功能强大的灵活的与HTTP/1.1相兼容的web服务器.这里给出的是Apache HTTP服务器的源码。
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as * applicable. * * 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 * *     http://www.apache.org/licenses/LICENSE-2.0 * * 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 {    apr_array_header_t *more_info;} info_svr_conf;module AP_MODULE_DECLARE_DATA info_module;static void *create_info_config(apr_pool_t *p, server_rec *s){    info_svr_conf *conf = (info_svr_conf *) apr_pcalloc(p, sizeof(info_svr_conf));    conf->more_info = apr_array_make(p, 20, sizeof(info_entry));    return conf;}static void *merge_info_config(apr_pool_t *p, void *basev, void *overridesv){    info_svr_conf *new = (info_svr_conf *) apr_pcalloc(p, sizeof(info_svr_conf));    info_svr_conf *base = (info_svr_conf *) basev;    info_svr_conf *overrides = (info_svr_conf *) overridesv;    new->more_info = apr_array_append(p, overrides->more_info, base->more_info);    return new;}static void mod_info_html_cmd_string(request_rec *r, const char *string,                                     int close){    const char *s;    s = string;    /* keep space for \0 byte */    while (*s) {        if (*s == '<') {	    if (close) {                ap_rputs("&lt;/", r);	    } else {                ap_rputs("&lt;", r);	    }        }        else if (*s == '>') {            ap_rputs("&gt;", r);        }        else if (*s == '&') {            ap_rputs("&amp;", r);        }	else if (*s == ' ') {	    if (close) {	        ap_rputs("&gt;", r);	        break;	    } else {                ap_rputc(*s, r);            }	} else {            ap_rputc(*s, r);        }        s++;    }}static void mod_info_module_cmds(request_rec * r, const command_rec * cmds,				 ap_directive_t * conftree){    const command_rec *cmd;    ap_directive_t *tmptree = conftree;    char htmlstring[MAX_STRING_LEN];    int block_start = 0;    int nest = 0;    while (tmptree != NULL) {	cmd = cmds;	while (cmd->name) {	    if ((cmd->name[0] != '<') &&                 (strcasecmp(cmd->name, tmptree->directive) == 0)) {		if (nest > block_start) {		    block_start++;		    apr_snprintf(htmlstring, sizeof(htmlstring), "%s %s",                                tmptree->parent->directive,				tmptree->parent->args);                    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>&nbsp;&nbsp;&nbsp;&nbsp;%s "			       "<i>%s</i></tt></dd>\n",                               ap_escape_html(r->pool,tmptree->directive),                                ap_escape_html(r->pool,tmptree->args));		} else if (nest == 1) {		    ap_rprintf(r,			       "<dd><tt>&nbsp;&nbsp;%s <i>%s</i></tt></dd>\n",                               ap_escape_html(r->pool,tmptree->directive),                                ap_escape_html(r->pool,tmptree->args));		} else {                    ap_rputs("<dd><tt>", r);                    mod_info_html_cmd_string(r, tmptree->directive, 0);                    ap_rprintf(r, " <i>%s</i></tt></dd>\n",                                ap_escape_html(r->pool,tmptree->args));		}	    }	    ++cmd;	}	if (tmptree->first_child != NULL) {	    tmptree = tmptree->first_child;	    nest++;	} else if (tmptree->next != NULL) {	    tmptree = tmptree->next;	} else {	    if (block_start) {		apr_snprintf(htmlstring, sizeof(htmlstring), "%s %s",			    tmptree->parent->directive,			    tmptree->parent->args);		ap_rputs("<dd><tt>", r);                mod_info_html_cmd_string(r, htmlstring, 1);                ap_rputs("</tt></dd>\n", r);		block_start--;	    }            if (tmptree->parent) {                tmptree = tmptree->parent->next;            }            else {                tmptree = NULL;            }	    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_struct_t;/* * 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__stdcall #endif* hook_get_t)(void);typedef struct {    const char *name;    hook_get_t get;} hook_lookup_t;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},};static int module_find_hook(module *modp,                            hook_get_t hook_get){    int i;    apr_array_header_t *hooks = hook_get();    hook_struct_t *elts;    if (!hooks) {        return 0;    }    elts = (hook_struct_t *)hooks->elts;    for (i=0; i< hooks->nelts; i++) {        if (strcmp(elts[i].szName, modp->name) == 0) {            return 1;        }    }    return 0;}static void module_participate(request_rec *r,                               module *modp,                               hook_lookup_t *lookup,                               int *comma){    if (module_find_hook(modp, lookup->get)) {        if (*comma) {            ap_rputs(", ", r);        }        ap_rvputs(r, "<tt>", lookup->name, "</tt>", NULL);        *comma = 1;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -