You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Brian Behlendorf <br...@hyperreal.com> on 1996/11/04 01:55:25 UTC
cvs commit: apache/src Configuration.tmpl Configure http_config.c http_config.h http_core.c http_main.c mod_info.c
brian 96/11/03 16:55:24
Modified: src Configuration.tmpl Configure http_config.c
http_config.h http_core.c http_main.c mod_info.c
Log:
Reviewed by: Brian Behlendorf
Submitted by: Tom Tromey (tromey@cygnus.com)
Implemented the "AddModule" functionality.
Revision Changes Path
1.50 +6 -1 apache/src/Configuration.tmpl
Index: Configuration.tmpl
===================================================================
RCS file: /export/home/cvs/apache/src/Configuration.tmpl,v
retrieving revision 1.49
retrieving revision 1.50
diff -C3 -r1.49 -r1.50
*** Configuration.tmpl 1996/11/03 20:56:03 1.49
--- Configuration.tmpl 1996/11/04 00:55:16 1.50
***************
*** 8,14 ****
# or an existing one modified. This will also most likely require some minor
# changes to Configure to recognize those changes.
! # There are 4 types of lines here:
# '#' comments, distinguished by having a '#' as the first non-blank character
#
--- 8,14 ----
# or an existing one modified. This will also most likely require some minor
# changes to Configure to recognize those changes.
! # There are 5 types of lines here:
# '#' comments, distinguished by having a '#' as the first non-blank character
#
***************
*** 20,25 ****
--- 20,30 ----
# Module selection lines, distinguished by having 'Module' at the front.
# These list the configured modules, in priority order (highest priority
# first). They're down at the bottom.
+ #
+ # Optional module selection lines, distinguished by having `%Module'
+ # at the front. These specify a module that is to be compiled in (but
+ # not enabled). The AddModule directive can be used to enable such a
+ # module. By default no such modules are defined.
################################################################
1.34 +25 -11 apache/src/Configure
Index: Configure
===================================================================
RCS file: /export/home/cvs/apache/src/Configure,v
retrieving revision 1.33
retrieving revision 1.34
diff -C3 -r1.33 -r1.34
*** Configure 1996/10/25 13:06:35 1.33
--- Configure 1996/11/04 00:55:16 1.34
***************
*** 1,5 ****
#!/bin/sh
! # $Id: Configure,v 1.33 1996/10/25 13:06:35 jim Exp $
trap 'rm -f $tmpfile; exit' 0 1 2 3 15
# Apache configuration script, first cut --- rst.
--- 1,5 ----
#!/bin/sh
! # $Id: Configure,v 1.34 1996/11/04 00:55:16 brian Exp $
trap 'rm -f $tmpfile; exit' 0 1 2 3 15
# Apache configuration script, first cut --- rst.
***************
*** 37,44 ****
# Check for syntax errors...
! if egrep -v '^Module[ ]+[A-Za-z0-9_]+[ ]+[^ ]+$' $tmpfile | \
! grep -v = > /dev/null
then
echo "Syntax error --- The configuration file is used only to"
echo "define the list of included modules or to set Makefile"
--- 37,44 ----
# Check for syntax errors...
! if egrep -v '^%?Module[ ]+[A-Za-z0-9_]+[ ]+[^ ]+$' $tmpfile \
! | grep -v = > /dev/null
then
echo "Syntax error --- The configuration file is used only to"
echo "define the list of included modules or to set Makefile"
***************
*** 53,61 ****
if [ -f Makefile ] ; then mv Makefile Makefile.bak; fi
if [ -f modules.c ] ; then mv modules.c modules.c.bak; fi
! awk >modules.c <$tmpfile '\
! BEGIN { modules[n++] = "core_module" } \
! /^Module/ { modules[n++] = $2 } \
END { print "/* modules.c --- automatically generated by Apache"; \
print " * configuration script. DO NOT HAND EDIT!!!!!"; \
print " */"; \
--- 53,62 ----
if [ -f Makefile ] ; then mv Makefile Makefile.bak; fi
if [ -f modules.c ] ; then mv modules.c modules.c.bak; fi
! sed -e 's/_module//' $tmpfile | awk >modules.c '\
! BEGIN { modules[n++] = "core" ; pmodules[pn++] = "core"} \
! /^Module/ { modules[n++] = $2 ; pmodules[pn++] = $2 } \
! /^%Module/ { pmodules[pn++] = $2 } \
END { print "/* modules.c --- automatically generated by Apache"; \
print " * configuration script. DO NOT HAND EDIT!!!!!"; \
print " */"; \
***************
*** 63,83 ****
print "#include \"httpd.h\""; \
print "#include \"http_config.h\""; \
print ""; \
! for (i = 0; i < n; ++i) { \
! printf ("extern module %s;\n", modules[i]); \
} \
print ""; \
print "module *prelinked_modules[] = {"; \
for (i = 0; i < n; ++i) { \
! printf " &%s,\n", modules[i]; \
} \
print " NULL"; \
print "};"; \
print "char *module_names[] = {"; \
! for (i = n-1; i > -1; --i) { \
printf " \"%s\",\n", modules[i]; \
} \
! print " NULL"; \
print "};"; \
}'
--- 64,96 ----
print "#include \"httpd.h\""; \
print "#include \"http_config.h\""; \
print ""; \
! for (i = 0; i < pn; ++i) { \
! printf ("extern module %s_module;\n", pmodules[i]); \
} \
print ""; \
print "module *prelinked_modules[] = {"; \
for (i = 0; i < n; ++i) { \
! printf " &%s_module,\n", modules[i]; \
} \
print " NULL"; \
print "};"; \
print "char *module_names[] = {"; \
! for (i = 0; i < n; ++i) { \
printf " \"%s\",\n", modules[i]; \
} \
! print " NULL"; \
! print "};"; \
! print "module *preloaded_modules[] = {"; \
! for (i = 0; i < pn; ++i) { \
! printf " &%s_module,\n", pmodules[i]; \
! } \
! print " NULL"; \
! print "};"; \
! print "char *preloaded_module_names[] = {"; \
! for (i = 0; i < pn; ++i) { \
! printf " \"%s\",\n", pmodules[i]; \
! } \
! print " NULL"; \
print "};"; \
}'
***************
*** 91,96 ****
--- 104,110 ----
print "# is re-run."; \
} \
/^Module/ { modules[n++] = $3 } \
+ /^%Module/ { modules[n++] = $3 } \
END { print "MODULES=\\"; \
for (i = 0; i < n; ++i) { \
if (i < n-1) printf (" %s \\\n", modules[i]); \
1.31 +71 -11 apache/src/http_config.c
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C3 -r1.30 -r1.31
*** http_config.c 1996/11/03 20:52:09 1.30
--- http_config.c 1996/11/04 00:55:17 1.31
***************
*** 83,89 ****
--- 83,92 ----
* of modules which control just about all of the server operation.
*/
+ /* num_modules is the number of currently active modules. */
static int num_modules = 0;
+ /* total_modules is the number of modules linked in. */
+ static int total_modules = 0;
module *top_module = NULL;
typedef int (*handler)(request_rec *);
***************
*** 119,132 ****
void *
create_empty_config (pool *p)
{
! void **conf_vector = (void **)pcalloc(p, sizeof(void*) * num_modules);
return (void *)conf_vector;
}
void *
create_default_per_dir_config (pool *p)
{
! void **conf_vector = (void **)pcalloc(p, sizeof(void*) * (num_modules+DYNAMIC_MODULE_LIMIT));
module *modp;
for (modp = top_module; modp; modp = modp->next) {
--- 122,135 ----
void *
create_empty_config (pool *p)
{
! void **conf_vector = (void **)pcalloc(p, sizeof(void*) * total_modules);
return (void *)conf_vector;
}
void *
create_default_per_dir_config (pool *p)
{
! void **conf_vector = (void **)pcalloc(p, sizeof(void*) * (total_modules+DYNAMIC_MODULE_LIMIT));
module *modp;
for (modp = top_module; modp; modp = modp->next) {
***************
*** 141,147 ****
void *
merge_per_dir_configs (pool *p, void *base, void *new)
{
! void **conf_vector = (void **)pcalloc(p, sizeof(void*) * num_modules);
void **base_vector = (void **) base;
void **new_vector = (void **) new;
module *modp;
--- 144,150 ----
void *
merge_per_dir_configs (pool *p, void *base, void *new)
{
! void **conf_vector = (void **)pcalloc(p, sizeof(void*) * total_modules);
void **base_vector = (void **) base;
void **new_vector = (void **) new;
module *modp;
***************
*** 162,168 ****
void *
create_server_config (pool *p, server_rec *s)
{
! void **conf_vector = (void **)pcalloc(p, sizeof(void*) * (num_modules+DYNAMIC_MODULE_LIMIT));
module *modp;
for (modp = top_module; modp; modp = modp->next) {
--- 165,171 ----
void *
create_server_config (pool *p, server_rec *s)
{
! void **conf_vector = (void **)pcalloc(p, sizeof(void*) * (total_modules+DYNAMIC_MODULE_LIMIT));
module *modp;
for (modp = top_module; modp; modp = modp->next) {
***************
*** 371,390 ****
exit(1);
}
! m->next = top_module;
! top_module = m;
! m->module_index = num_modules++;
}
void setup_prelinked_modules ()
{
! extern module *prelinked_modules[];
! module **m = prelinked_modules;
! while (*m) {
add_module (*m);
- ++m;
}
}
/*****************************************************************
--- 374,450 ----
exit(1);
}
! if (m->next == NULL) {
! m->next = top_module;
! top_module = m;
! }
! if (m->module_index == -1) {
! m->module_index = num_modules++;
! }
}
void setup_prelinked_modules ()
{
! extern module *prelinked_modules[], *preloaded_modules[];
! module **m;
! /* First, set all module indices, and init total_modules. */
! total_modules = 0;
! for (m = preloaded_modules; *m; ++m, ++total_modules) {
! (*m)->module_index = total_modules;
! }
!
! for (m = prelinked_modules; *m; ++m) {
add_module (*m);
}
+ }
+
+ char *find_module_name (module *m)
+ {
+ extern char *preloaded_module_names[];
+
+ if (m->module_index >= 0 && m->module_index < total_modules)
+ return preloaded_module_names[m->module_index];
+ return NULL;
+ }
+
+ /* Add a named module. Returns 1 if module found, 0 otherwise. */
+ int add_named_module (char *name)
+ {
+ extern module *preloaded_modules[];
+ extern char *preloaded_module_names[];
+ int i;
+
+ for (i = 0; preloaded_module_names[i]; ++i) {
+ if (strcmp (preloaded_module_names[i], name) == 0) {
+ /* Only add modules that are not already enabled. */
+ if (preloaded_modules[i]->next == NULL) {
+ add_module (preloaded_modules[i]);
+ }
+ return 1;
+ }
+ }
+
+ return 0;
+ }
+
+ /* Clear the internal list of modules, in preparation for starting
+ over. */
+ void clear_module_list ()
+ {
+ module **m = &top_module;
+ module **next_m;
+
+ while (*m) {
+ next_m = &((*m)->next);
+ *m = NULL;
+ m = next_m;
+ }
+
+ num_modules = 0;
+
+ /* This is required; so we add it always. */
+ add_named_module ("core");
}
/*****************************************************************
1.20 +5 -2 apache/src/http_config.h
Index: http_config.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C3 -r1.19 -r1.20
*** http_config.h 1996/11/03 21:25:06 1.19
--- http_config.h 1996/11/04 00:55:17 1.20
***************
*** 226,232 ****
*/
#define MODULE_MAGIC_NUMBER 19961007
! #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, 0, __FILE__, NULL
/* Generic accessors for other modules to get at their own module-specific
* data
--- 226,232 ----
*/
#define MODULE_MAGIC_NUMBER 19961007
! #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, -1, __FILE__, NULL
/* Generic accessors for other modules to get at their own module-specific
* data
***************
*** 249,254 ****
--- 249,257 ----
/* Finally, the hook for dynamically loading modules in... */
void add_module (module *m);
+ int add_named_module (char *name);
+ void clear_module_list ();
+ char *find_module_name (module *m);
#ifdef CORE_PRIVATE
***************
*** 285,289 ****
int run_fixups (request_rec *); /* poke around for other metainfo, etc.... */
int invoke_handler (request_rec *);
int log_transaction (request_rec *r);
!
#endif
--- 288,292 ----
int run_fixups (request_rec *); /* poke around for other metainfo, etc.... */
int invoke_handler (request_rec *);
int log_transaction (request_rec *r);
!
#endif
1.42 +16 -0 apache/src/http_core.c
Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -C3 -r1.41 -r1.42
*** http_core.c 1996/11/03 20:29:39 1.41
--- http_core.c 1996/11/04 00:55:18 1.42
***************
*** 751,756 ****
--- 751,769 ----
return errmsg;
}
+ const char *add_module_command (cmd_parms *cmd, void *dummy, char *arg)
+ {
+ if (add_named_module (arg))
+ return NULL;
+ return "required module not found";
+ }
+
+ const char *clear_module_list_command (cmd_parms *cmd, void *dummy)
+ {
+ clear_module_list ();
+ return NULL;
+ }
+
const char *set_server_string_slot (cmd_parms *cmd, void *dummy, char *arg)
{
/* This one's pretty generic... */
***************
*** 1129,1134 ****
--- 1142,1150 ----
"a port number or a numeric IP address and a port number"},
{ "<VirtualHost", virtualhost_section, NULL, RSRC_CONF, RAW_ARGS, NULL },
{ "</VirtualHost>", end_virtualhost_section, NULL, RSRC_CONF, NO_ARGS, NULL },
+ { "AddModule", add_module_command, NULL, RSRC_CONF, ITERATE,
+ "the name of a module" },
+ { "ClearModuleList", clear_module_list_command, NULL, RSRC_CONF, NO_ARGS, NULL },
{ NULL },
};
1.84 +16 -2 apache/src/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -C3 -r1.83 -r1.84
*** http_main.c 1996/11/03 20:52:10 1.83
--- http_main.c 1996/11/04 00:55:19 1.84
***************
*** 341,351 ****
void usage(char *bin)
{
! fprintf(stderr,"Usage: %s [-d directory] [-f file] [-v] [-h]\n",bin);
fprintf(stderr,"-d directory : specify an alternate initial ServerRoot\n");
fprintf(stderr,"-f file : specify an alternate ServerConfigFile\n");
fprintf(stderr,"-v : show version number\n");
fprintf(stderr,"-h : list directives\n");
exit(1);
}
--- 341,352 ----
void usage(char *bin)
{
! fprintf(stderr,"Usage: %s [-d directory] [-f file] [-v] [-h] [-l]\n",bin);
fprintf(stderr,"-d directory : specify an alternate initial ServerRoot\n");
fprintf(stderr,"-f file : specify an alternate ServerConfigFile\n");
fprintf(stderr,"-v : show version number\n");
fprintf(stderr,"-h : list directives\n");
+ fprintf(stderr,"-l : list modules\n");
exit(1);
}
***************
*** 1865,1870 ****
--- 1866,1881 ----
} /* standalone_main */
+ void show_modules()
+ {
+ extern char *preloaded_module_names[];
+ int t;
+
+ printf ("Compiled-in modules:\n");
+ for (t = 0; preloaded_module_names[t]; ++t)
+ printf (" %s\n", preloaded_module_names[t]);
+ }
+
extern char *optarg;
extern int optind;
***************
*** 1895,1901 ****
strcpy (server_root, HTTPD_ROOT);
strcpy (server_confname, SERVER_CONFIG_FILE);
! while((c = getopt(argc,argv,"Xd:f:vh")) != -1) {
switch(c) {
case 'd':
strcpy (server_root, optarg);
--- 1906,1912 ----
strcpy (server_root, HTTPD_ROOT);
strcpy (server_confname, SERVER_CONFIG_FILE);
! while((c = getopt(argc,argv,"Xd:f:vhl")) != -1) {
switch(c) {
case 'd':
strcpy (server_root, optarg);
***************
*** 1908,1913 ****
--- 1919,1927 ----
exit(0);
case 'h':
show_directives();
+ exit(0);
+ case 'l':
+ show_modules();
exit(0);
case 'X':
++one_process; /* Weird debugging mode. */
1.5 +11 -9 apache/src/mod_info.c
Index: mod_info.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_info.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C3 -r1.4 -r1.5
*** mod_info.c 1996/11/03 20:48:35 1.4
--- mod_info.c 1996/11/04 00:55:20 1.5
***************
*** 235,242 ****
int display_info(request_rec *r) {
module *modp = NULL;
char buf[256];
! extern char *module_names[];
! char **names = module_names;
command_rec *cmd=NULL;
handler_rec *hand=NULL;
server_rec *serv = r->server;
--- 235,241 ----
int display_info(request_rec *r) {
module *modp = NULL;
char buf[256];
! char *name;
command_rec *cmd=NULL;
handler_rec *hand=NULL;
server_rec *serv = r->server;
***************
*** 277,284 ****
mod_info_cfg_access = mod_info_load_config(r->pool,buf);
if(!r->args) {
rputs("<tt><a href=\"#server\">Server Settings</a>, ",r);
! for(modp = top_module, names=module_names; modp; modp = modp->next, names++) {
! sprintf(buf,"<a href=\"#%s\">%s</a>",*names,*names);
rputs(buf, r);
if(modp->next) rputs(", ",r);
}
--- 276,284 ----
mod_info_cfg_access = mod_info_load_config(r->pool,buf);
if(!r->args) {
rputs("<tt><a href=\"#server\">Server Settings</a>, ",r);
! for(modp = top_module; modp; modp = modp->next) {
! name=find_module_name (modp);
! sprintf(buf,"<a href=\"#%s\">%s</a>",name,name);
rputs(buf, r);
if(modp->next) rputs(", ",r);
}
***************
*** 312,320 ****
rputs(buf,r);
}
rputs("<hr><dl>",r);
! for(modp = top_module, names=module_names; modp; modp = modp->next, names++) {
! if(!r->args || !strcasecmp(*names,r->args)) {
! sprintf(buf,"<dt><a name=\"%s\"><strong>Module Name:</strong> <font size=+1><tt>%s</tt></a></font>\n",*names,*names);
rputs(buf,r);
rputs("<dt><strong>Content-types affected:</strong>",r);
hand = modp->handlers;
--- 312,321 ----
rputs(buf,r);
}
rputs("<hr><dl>",r);
! for(modp = top_module; modp; modp = modp->next) {
! name=find_module_name (modp);
! if(!r->args || !strcasecmp(name,r->args)) {
! sprintf(buf,"<dt><a name=\"%s\"><strong>Module Name:</strong> <font size=+1><tt>%s</tt></a></font>\n",name,name);
rputs(buf,r);
rputs("<dt><strong>Content-types affected:</strong>",r);
hand = modp->handlers;
***************
*** 392,399 ****
}
if(!modp && r->args && strcasecmp(r->args,"server")) rputs("<b>No such module</b>\n",r);
} else {
! for(modp = top_module; modp; modp = modp->next, names++) {
! rputs(*names,r);
if(modp->next) rputs("<br>",r);
}
}
--- 393,401 ----
}
if(!modp && r->args && strcasecmp(r->args,"server")) rputs("<b>No such module</b>\n",r);
} else {
! for(modp = top_module; modp; modp = modp->next) {
! name=find_module_name (modp);
! rputs(name,r);
if(modp->next) rputs("<br>",r);
}
}