Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 98364 invoked from network); 5 Sep 2004 01:43:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 5 Sep 2004 01:43:08 -0000 Received: (qmail 88705 invoked by uid 500); 5 Sep 2004 01:43:07 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 88551 invoked by uid 500); 5 Sep 2004 01:43:06 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 88538 invoked by uid 500); 5 Sep 2004 01:43:05 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Received: (qmail 88535 invoked by uid 99); 5 Sep 2004 01:43:05 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sat, 04 Sep 2004 18:43:04 -0700 Received: (qmail 98312 invoked by uid 1888); 5 Sep 2004 01:43:03 -0000 Date: 5 Sep 2004 01:43:03 -0000 Message-ID: <20040905014303.98311.qmail@minotaur.apache.org> From: pquerna@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/generators mod_info.c X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N pquerna 2004/09/04 18:43:03 Modified: modules/generators mod_info.c Log: No Functional Changes to mod_info. This is purely a style cleanup for mod_info. I plan on making more functional changes later. Revision Changes Path 1.58 +241 -200 httpd-2.0/modules/generators/mod_info.c Index: mod_info.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/generators/mod_info.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- mod_info.c 3 Sep 2004 02:31:06 -0000 1.57 +++ mod_info.c 5 Sep 2004 01:43:03 -0000 1.58 @@ -64,74 +64,87 @@ #include "apr_want.h" #include "ap_mpm.h" -typedef struct { - const char *name; /* matching module name */ - const char *info; /* additional info */ +typedef struct +{ + const char *name; /* matching module name */ + const char *info; /* additional info */ } info_entry; -typedef struct { +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) +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)); + 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) +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 *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); + new->more_info = + apr_array_append(p, overrides->more_info, base->more_info); return new; } -static void mod_info_indent(request_rec * r, int nest, const char* thisfn, int linenum) +static void mod_info_indent(request_rec *r, int nest, const char *thisfn, + int linenum) { int i; - const char *prevfn = ap_get_module_config(r->request_config, &info_module); + const char *prevfn = + ap_get_module_config(r->request_config, &info_module); char buf[32]; - if (thisfn == NULL) thisfn = "*UNKNOWN*"; + if (thisfn == NULL) + thisfn = "*UNKNOWN*"; if (prevfn == NULL || 0 != strcmp(prevfn, thisfn)) { thisfn = ap_escape_html(r->pool, thisfn); - ap_rprintf(r, "
In file: %s
\n", thisfn); + ap_rprintf(r, "
In file: %s
\n", + thisfn); ap_set_module_config(r->request_config, &info_module, thisfn); } ap_rputs("
", r); - if (linenum > 0) sprintf(buf, "%d", linenum); - else buf[0] = '\0'; - for (i = strlen(buf); i < 4; ++i) ap_rputs(" ", r); + if (linenum > 0) + sprintf(buf, "%d", linenum); + else + buf[0] = '\0'; + for (i = strlen(buf); i < 4; ++i) + ap_rputs(" ", r); ap_rputs(buf, r); ap_rputs(": ", r); - for (i = 1; i <= nest; ++i) ap_rputs("  ", r); + for (i = 1; i <= nest; ++i) + ap_rputs("  ", r); } -static void mod_info_show_cmd(request_rec * r, const ap_directive_t * dir, - int nest) +static void mod_info_show_cmd(request_rec *r, const ap_directive_t * dir, + int nest) { mod_info_indent(r, nest, dir->filename, dir->line_num); ap_rprintf(r, "%s %s
\n", - ap_escape_html(r->pool, dir->directive), - ap_escape_html(r->pool, dir->args)); + ap_escape_html(r->pool, dir->directive), + ap_escape_html(r->pool, dir->args)); } -static void mod_info_show_open(request_rec * r, const ap_directive_t * dir, - int nest) +static void mod_info_show_open(request_rec *r, const ap_directive_t * dir, + int nest) { mod_info_indent(r, nest, dir->filename, dir->line_num); - ap_rprintf(r, "%s %s\n", - ap_escape_html(r->pool, dir->directive), - ap_escape_html(r->pool, dir->args)); + ap_rprintf(r, "%s %s\n", + ap_escape_html(r->pool, dir->directive), + ap_escape_html(r->pool, dir->args)); } -static void mod_info_show_close(request_rec * r, const ap_directive_t * dir, +static void mod_info_show_close(request_rec *r, const ap_directive_t * dir, int nest) { const char *dirname = dir->directive; @@ -139,58 +152,64 @@ if (*dirname == '<') { ap_rprintf(r, "</%s>", ap_escape_html(r->pool, dirname + 1)); - } - else { - ap_rprintf(r, "/%s", - ap_escape_html(r->pool, dirname)); - } + } + else { + ap_rprintf(r, "/%s", ap_escape_html(r->pool, dirname)); + } } - -static int mod_info_has_cmd(const command_rec * cmds, ap_directive_t * dir) + +static int mod_info_has_cmd(const command_rec *cmds, ap_directive_t * dir) { - const command_rec * cmd; - if (cmds == NULL) return 1; + const command_rec *cmd; + if (cmds == NULL) + return 1; for (cmd = cmds; cmd->name; ++cmd) { - if (strcasecmp(cmd->name, dir->directive) == 0) return 1; - } + if (strcasecmp(cmd->name, dir->directive) == 0) + return 1; + } return 0; } -static void mod_info_show_parents(request_rec * r, ap_directive_t * node, - int from, int to) { - if (from < to) mod_info_show_parents(r, node->parent, from, to - 1); +static void mod_info_show_parents(request_rec *r, ap_directive_t * node, + int from, int to) +{ + if (from < to) + mod_info_show_parents(r, node->parent, from, to - 1); mod_info_show_open(r, node, to); } -static int mod_info_module_cmds(request_rec * r, const command_rec * cmds, +static int mod_info_module_cmds(request_rec *r, const command_rec *cmds, ap_directive_t * node, int from, int level) { int shown = from; - ap_directive_t * dir; - if (level == 0) ap_set_module_config(r->request_config, &info_module, NULL); + ap_directive_t *dir; + if (level == 0) + ap_set_module_config(r->request_config, &info_module, NULL); for (dir = node; dir; dir = dir->next) { if (dir->first_child != NULL) { if (level < mod_info_module_cmds(r, cmds, dir->first_child, - shown, level + 1)) { + shown, level + 1)) { shown = level; mod_info_show_close(r, dir, level); } - } else if (mod_info_has_cmd(cmds, dir)) { + } + else if (mod_info_has_cmd(cmds, dir)) { if (shown < level) { mod_info_show_parents(r, dir->parent, shown, level - 1); shown = level; } mod_info_show_cmd(r, dir, level); - } + } } return shown; } -typedef struct { /*XXX: should get something from apr_hooks.h instead */ - void (*pFunc)(void); /* just to get the right size */ +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; + const char *const *aszPredecessors; + const char *const *aszSuccessors; int nOrder; } hook_struct_t; @@ -200,13 +219,14 @@ * is required to account for the fact that the ap_hook* calls all use * STDCALL calling convention. */ -typedef apr_array_header_t * ( +typedef apr_array_header_t *( #ifdef WIN32 -__stdcall + __stdcall #endif -* hook_get_t)(void); + * hook_get_t) (void); -typedef struct { +typedef struct +{ const char *name; hook_get_t get; } hook_lookup_t; @@ -224,8 +244,7 @@ {NULL}, }; -static int module_find_hook(module *modp, - hook_get_t hook_get) +static int module_find_hook(module *modp, hook_get_t hook_get) { int i; apr_array_header_t *hooks = hook_get(); @@ -235,9 +254,9 @@ return 0; } - elts = (hook_struct_t *)hooks->elts; + elts = (hook_struct_t *) hooks->elts; - for (i=0; i< hooks->nelts; i++) { + for (i = 0; i < hooks->nelts; i++) { if (strcmp(elts[i].szName, modp->name) == 0) { return 1; } @@ -248,8 +267,7 @@ static void module_participate(request_rec *r, module *modp, - hook_lookup_t *lookup, - int *comma) + hook_lookup_t * lookup, int *comma) { if (module_find_hook(modp, lookup->get)) { if (*comma) { @@ -262,11 +280,11 @@ static void module_request_hook_participate(request_rec *r, module *modp) { - int i, comma=0; + int i, comma = 0; ap_rputs("
Request Phase Participation:\n", r); - for (i=0; request_hooks[i].name; i++) { + for (i = 0; request_hooks[i].name; i++) { module_participate(r, modp, &request_hooks[i], &comma); } @@ -279,8 +297,9 @@ static const char *find_more_info(server_rec *s, const char *module_name) { int i; - info_svr_conf *conf = (info_svr_conf *) ap_get_module_config(s->module_config, - &info_module); + info_svr_conf *conf = + (info_svr_conf *) ap_get_module_config(s->module_config, + &info_module); info_entry *entry = (info_entry *) conf->more_info->elts; if (!module_name) { @@ -311,18 +330,21 @@ r->allowed |= (AP_METHOD_BIT << M_GET); if (r->method_number != M_GET) - return DECLINED; + return DECLINED; ap_set_content_type(r, "text/html"); ap_rputs(DOCTYPE_HTML_3_2 - "Server Information\n", r); - ap_rputs("

Apache Server Information

\n", r); + "Server Information\n", r); + ap_rputs("

Apache Server Information

\n", + r); if (!r->args || strcasecmp(r->args, "list")) { if (!r->args) { - ap_rputs("
Server Settings, ", r); + ap_rputs("
Server Settings, ", + r); for (modp = ap_top_module; modp; modp = modp->next) { - ap_rprintf(r, "%s", modp->name, modp->name); + ap_rprintf(r, "%s", modp->name, + modp->name); if (modp->next) { ap_rputs(", ", r); } @@ -333,35 +355,44 @@ if (!r->args || !strcasecmp(r->args, "server")) { int max_daemons, forked, threaded; - ap_rprintf(r, "
Server Version: " - "%s
\n", - ap_get_server_version()); - ap_rprintf(r, "
Server Built: " - "%s
\n", - ap_get_server_built()); - ap_rprintf(r, "
API Version: " - "%d:%d
\n", - MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); - ap_rprintf(r, "
Hostname/port: " - "%s:%u
\n", - ap_get_server_name(r), ap_get_server_port(r)); - ap_rprintf(r, "
Timeouts: " - "connection: %d    " - "keep-alive: %d
", - (int)(apr_time_sec(serv->timeout)), - (int)(apr_time_sec(serv->timeout))); + ap_rprintf(r, + "
Server Version: " + "%s
\n", + ap_get_server_version()); + ap_rprintf(r, + "
Server Built: " + "%s
\n", + ap_get_server_built()); + ap_rprintf(r, + "
API Version: " + "%d:%d
\n", MODULE_MAGIC_NUMBER_MAJOR, + MODULE_MAGIC_NUMBER_MINOR); + ap_rprintf(r, + "
Hostname/port: " + "%s:%u
\n", ap_get_server_name(r), + ap_get_server_port(r)); + ap_rprintf(r, + "
Timeouts: " + "connection: %d    " + "keep-alive: %d
", + (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, "
MPM Name: %s
\n", ap_show_mpm()); - ap_rprintf(r, "
MPM Information: " - "Max Daemons: %d Threaded: %s Forked: %s
\n", + ap_rprintf(r, "
MPM Name: %s
\n", + ap_show_mpm()); + ap_rprintf(r, + "
MPM Information: " + "Max Daemons: %d Threaded: %s Forked: %s
\n", max_daemons, threaded ? "yes" : "no", forked ? "yes" : "no"); - ap_rprintf(r, "
Server Root: " - "%s
\n", ap_server_root); - ap_rprintf(r, "
Config File: " - "%s
\n", ap_conftree->filename); + ap_rprintf(r, + "
Server Root: " + "%s
\n", ap_server_root); + ap_rprintf(r, + "
Config File: " + "%s
\n", ap_conftree->filename); ap_rputs("

", r); } if (r->args && 0 == strcasecmp(r->args, "config")) { @@ -370,117 +401,128 @@ ap_rputs("

", r); } else { - for (modp = ap_top_module; modp; modp = modp->next) { - if (!r->args || !strcasecmp(modp->name, r->args)) { - ap_rprintf(r, "
Module Name: " - "%s
\n", - modp->name, modp->name); - ap_rputs("
Content handlers: ", r); + for (modp = ap_top_module; modp; modp = modp->next) { + if (!r->args || !strcasecmp(modp->name, r->args)) { + ap_rprintf(r, + "
Module Name: " + "%s
\n", + modp->name, modp->name); + ap_rputs("
Content handlers: ", r); #ifdef NEVERMORE - hand = modp->handlers; - if (hand) { - while (hand) { - if (hand->content_type) { - ap_rprintf(r, " %s\n", hand->content_type); - } - else { - break; - } - hand++; - if (hand && hand->content_type) { - ap_rputs(",", r); + hand = modp->handlers; + if (hand) { + while (hand) { + if (hand->content_type) { + ap_rprintf(r, " %s\n", + hand->content_type); + } + else { + break; + } + hand++; + if (hand && hand->content_type) { + ap_rputs(",", r); + } } } - } - else { - ap_rputs(" none", r); - } + else { + ap_rputs(" none", r); + } #else - if (module_find_hook(modp, ap_hook_get_handler)) { - ap_rputs(" yes", r); - } - else { - ap_rputs(" none", r); - } + if (module_find_hook(modp, ap_hook_get_handler)) { + ap_rputs(" yes", r); + } + else { + ap_rputs(" none", r); + } #endif - ap_rputs("
", r); - ap_rputs("
Configuration Phase Participation:\n", - r); - if (modp->create_dir_config) { - if (comma) { - ap_rputs(", ", r); + ap_rputs("
", r); + ap_rputs + ("
Configuration Phase Participation:\n", + r); + if (modp->create_dir_config) { + if (comma) { + ap_rputs(", ", r); + } + ap_rputs("Create Directory Config", r); + comma = 1; } - ap_rputs("Create Directory Config", r); - comma = 1; - } - if (modp->merge_dir_config) { - if (comma) { - ap_rputs(", ", r); + if (modp->merge_dir_config) { + if (comma) { + ap_rputs(", ", r); + } + ap_rputs("Merge Directory Configs", r); + comma = 1; } - ap_rputs("Merge Directory Configs", r); - comma = 1; - } - if (modp->create_server_config) { - if (comma) { - ap_rputs(", ", r); + if (modp->create_server_config) { + if (comma) { + ap_rputs(", ", r); + } + ap_rputs("Create Server Config", r); + comma = 1; } - ap_rputs("Create Server Config", r); - comma = 1; - } - if (modp->merge_server_config) { - if (comma) { - ap_rputs(", ", r); + if (modp->merge_server_config) { + if (comma) { + ap_rputs(", ", r); + } + ap_rputs("Merge Server Configs", r); + comma = 1; } - ap_rputs("Merge Server Configs", r); - comma = 1; - } - if (!comma) - ap_rputs(" none", r); - comma = 0; - ap_rputs("
", r); - - module_request_hook_participate(r, modp); - - cmd = modp->cmds; - if (cmd) { - ap_rputs("
Module Directives:
", r); - while (cmd) { - if (cmd->name) { - ap_rprintf(r, "
%s%s - ", - ap_escape_html(r->pool, cmd->name), - cmd->name[0] == '<' ? ">" : ""); - if (cmd->errmsg) { - ap_rputs(cmd->errmsg, r); + if (!comma) + ap_rputs(" none", r); + comma = 0; + ap_rputs("
", r); + + module_request_hook_participate(r, modp); + + cmd = modp->cmds; + if (cmd) { + ap_rputs + ("
Module Directives:
", + r); + while (cmd) { + if (cmd->name) { + ap_rprintf(r, "
%s%s - ", + ap_escape_html(r->pool, cmd->name), + cmd->name[0] == '<' ? ">" : ""); + if (cmd->errmsg) { + ap_rputs(cmd->errmsg, r); + } + ap_rputs("
\n", r); } - ap_rputs("
\n", r); - } - else { - break; + else { + break; + } + cmd++; } - cmd++; + ap_rputs + ("
Current Configuration:
\n", + r); + mod_info_module_cmds(r, modp->cmds, ap_conftree, 0, + 0); + } + else { + ap_rputs + ("
Module Directives: none
", + r); + } + more_info = find_more_info(serv, modp->name); + if (more_info) { + ap_rputs + ("
Additional Information:\n
", + r); + ap_rputs(more_info, r); + ap_rputs("
", r); + } + ap_rputs("

\n", r); + if (r->args) { + break; } - ap_rputs("
Current Configuration:
\n", r); - mod_info_module_cmds(r, modp->cmds, ap_conftree, 0, 0); - } - else { - ap_rputs("
Module Directives: none
", r); - } - more_info = find_more_info(serv, modp->name); - if (more_info) { - ap_rputs("
Additional Information:\n
", - r); - ap_rputs(more_info, r); - ap_rputs("
", r); - } - ap_rputs("

\n", r); - if (r->args) { - break; } } - } - if (!modp && r->args && strcasecmp(r->args, "server")) { - ap_rputs("

No such module

\n", r); - } + if (!modp && r->args && strcasecmp(r->args, "server")) { + ap_rputs("

No such module

\n", r); + } } } else { @@ -492,18 +534,19 @@ } ap_rputs("

", r); } - ap_rputs(ap_psignature("",r), r); + ap_rputs(ap_psignature("", r), r); ap_rputs("\n", r); /* Done, turn off timeout, close file and return */ return 0; } -static const char *add_module_info(cmd_parms *cmd, void *dummy, +static const char *add_module_info(cmd_parms *cmd, void *dummy, const char *name, const char *info) { server_rec *s = cmd->server; - info_svr_conf *conf = (info_svr_conf *) ap_get_module_config(s->module_config, - &info_module); + info_svr_conf *conf = + (info_svr_conf *) ap_get_module_config(s->module_config, + &info_module); info_entry *new = apr_array_push(conf->more_info); new->name = name; @@ -511,20 +554,18 @@ return NULL; } -static const command_rec info_cmds[] = -{ +static const command_rec info_cmds[] = { AP_INIT_TAKE2("AddModuleInfo", add_module_info, NULL, RSRC_CONF, "a module name and additional information on that module"), {NULL} }; -static void register_hooks(apr_pool_t *p) +static void register_hooks(apr_pool_t * p) { ap_hook_handler(display_info, NULL, NULL, APR_HOOK_MIDDLE); } -module AP_MODULE_DECLARE_DATA info_module = -{ +module AP_MODULE_DECLARE_DATA info_module = { STANDARD20_MODULE_STUFF, NULL, /* dir config creater */ NULL, /* dir merger --- default is to override */