You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by br...@hyperreal.org on 1998/06/16 05:37:32 UTC

cvs commit: apache-1.3/src/support httpd.8

brian       98/06/15 20:37:32

  Modified:    .        STATUS
               htdocs/manual/mod core.html directives.html
               src      CHANGES
               src/include http_conf_globals.h
               src/main http_main.c http_core.c
               src/support httpd.8
  Log:
  Submitted by:	Ralf Engelschall
  Reviewed by:	Brian Behlendorf
  
    *) Add <IfDefine>..</IfDefine> sections to the core module (with same spirit
       as <IfModule>..</IfModule> sections) which can be used to skip or process
       contained commands dependend of ``-D PARAMETER'' options on the command
       line.
  
  Revision  Changes    Path
  1.428     +0 -9      apache-1.3/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/STATUS,v
  retrieving revision 1.427
  retrieving revision 1.428
  diff -u -r1.427 -r1.428
  --- STATUS	1998/06/16 03:28:45	1.427
  +++ STATUS	1998/06/16 03:37:07	1.428
  @@ -44,15 +44,6 @@
         <19...@engelschall.com>
         Status: Ralf +1
   
  -    * Ralf's "<IfDefine>...</IfDefine>":
  -      This patch adds a useful <IfDefine>...</IfDefine> section to the core
  -      module very similar to the existing <IfModule>...<IfModule> sections.
  -      The intent is to provide _LOGICAL_ conditions based on arbitrary defined
  -      parameters. The parameters are specified on the "httpd" command line via
  -      -D options.
  -      See: http://www.engelschall.com/sw/apache/ [ifdefine]
  -      Status (for 1.3.1-dev): Ralf +1
  -
       * Ralf's "substitute some more configuration parameters":
         This patch lets APACI's configure script determine more configuration
         parameters (Group, Port, ServerAdmin, ServerName) via some intelligent
  
  
  
  1.125     +68 -0     apache-1.3/htdocs/manual/mod/core.html
  
  Index: core.html
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/htdocs/manual/mod/core.html,v
  retrieving revision 1.124
  retrieving revision 1.125
  diff -u -r1.124 -r1.125
  --- core.html	1998/06/16 02:11:30	1.124
  +++ core.html	1998/06/16 03:37:15	1.125
  @@ -43,6 +43,7 @@
   <LI><A HREF="#group">Group</A>
   <LI><A HREF="#hostnamelookups">HostNameLookups</A>
   <LI><A HREF="#identitycheck">IdentityCheck</A>
  +<LI><A HREF="#ifdefine">&lt;IfDefine&gt;</A>
   <LI><A HREF="#ifmodule">&lt;IfModule&gt;</A>
   <LI><A HREF="#include">Include</A>
   <LI><A HREF="#keepalive">KeepAlive</A>
  @@ -1083,6 +1084,73 @@
   of latency to each hit.  So in general this is not very useful on public
   servers accessible from the Internet.
   <P><HR>
  +
  +<H2><A NAME="ifdefine">&lt;IfDefine&gt; directive</A></H2>
  +<A
  + HREF="directive-dict.html#Syntax"
  + REL="Help"
  +><STRONG>Syntax:</STRONG></A> &lt;IfDefine [!]<EM>parameter-name</EM>&gt; <EM>...</EM>
  +&lt;/IfDefine&gt;<BR>
  +<A
  + HREF="directive-dict.html#Default"
  + REL="Help"
  +><STRONG>Default:</STRONG></A> None<BR>
  +<A
  + HREF="directive-dict.html#Context"
  + REL="Help"
  +><STRONG>Context:</STRONG></A> all<BR>
  +<A
  + HREF="directive-dict.html#Status"
  + REL="Help"
  +><STRONG>Status:</STRONG></A> Core<BR>
  +<A
  + HREF="directive-dict.html#Compatibility"
  + REL="Help"
  +><STRONG>Compatibility:</STRONG></A> &lt;IfDefine&gt; is only available in 1.3 and
  +later.<P>
  +
  +<P>
  +
  +The &lt;IfDefine <EM>test</EM>&gt;...&lt;/IfDefine&gt;
  +section is used to mark directives that are conditional. The
  +directives within an IfDefine section are only
  +processed if the <EM>test</EM> is true. If <EM>test</EM>
  +is false, everything between the start and end markers
  +is ignored.<P>
  +
  +The <EM>test</EM> in the &lt;IfDefine&gt; section directive
  +can be one of two forms:
  +
  +<UL>
  +<LI><EM>parameter-name</EM>
  +<LI><CODE>!</CODE><EM>parameter-name</EM>
  +</UL>
  +
  +<P>In the former case, the directives between the start and end markers are
  +only processed if the parameter named <EM>parameter-name</EM> is defined.
  +The second format reverses the test, and only processes the directives if
  +<EM>parameter-name</EM> is <STRONG>not</STRONG> defined.
  +
  +<P>The <EM>paramater-name</EM> argument is a define as given on the
  +<CODE>httpd</CODE> command line via <CODE>-D</CODE><EM>parameter-</EM>, at the
  +time the server was started.
  +
  +<P>&lt;IfDefine&gt; sections are nest-able, which can be used to implement
  +simple multiple-parameter tests.
  +
  +Example:
  +
  +<PRE>
  +  $ httpd -DReverseProxy ...
  +
  +  # httpd.conf
  +  &lt;IfDefine ReverseProxy&gt;
  +  LoadModule rewrite_module libexec/mod_rewrite.so
  +  LoadModule proxy_module   libexec/libproxy.so
  +  &lt;/IfDefine&gt;
  +</PRE>
  +
  +<P> <HR>
   
   <H2><A NAME="ifmodule">&lt;IfModule&gt; directive</A></H2>
   <A
  
  
  
  1.46      +1 -0      apache-1.3/htdocs/manual/mod/directives.html
  
  Index: directives.html
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/htdocs/manual/mod/directives.html,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- directives.html	1998/05/29 02:55:17	1.45
  +++ directives.html	1998/06/16 03:37:15	1.46
  @@ -108,6 +108,7 @@
   <LI><A HREF="mod_autoindex.html#headername">HeaderName</A>
   <LI><A HREF="core.html#hostnamelookups">HostNameLookups</A>
   <LI><A HREF="core.html#identitycheck">IdentityCheck</A>
  +<LI><A HREF="core.html#ifdefine">&lt;IfDefine&gt;</A>
   <LI><A HREF="core.html#ifmodule">&lt;IfModule&gt;</A>
   <LI><A HREF="mod_imap.html#imapbase">ImapBase</A>
   <LI><A HREF="mod_imap.html#imapdefault">ImapDefault</A>
  
  
  
  1.919     +8 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.918
  retrieving revision 1.919
  diff -u -r1.918 -r1.919
  --- CHANGES	1998/06/16 03:28:50	1.918
  +++ CHANGES	1998/06/16 03:37:20	1.919
  @@ -1,5 +1,13 @@
   Changes with Apache 1.3.1
   
  +  *) Add <IfDefine>..</IfDefine> sections to the core module (with same spirit
  +     as <IfModule>..</IfModule> sections) which can be used to skip or process
  +     contained commands dependend of ``-D PARAMETER'' options on the command
  +     line. This can be used to achieve logical conditions like <IfDefine
  +     ReverseProxy> instead of physically ones (e.g. <IfModule mod_proxy.c>)
  +     and thus especially can be used for conditionally loading DSO-based
  +     modules via LoadModule, etc. [Ralf S. Engelschall]
  +
     *) PORT: clean up a warning in mod_status for OS/2.  [Brian Havard]
   
     *) Make table elements const. This may prevent obscure errors. [Ben Laurie]
  
  
  
  1.32      +2 -1      apache-1.3/src/include/http_conf_globals.h
  
  Index: http_conf_globals.h
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/include/http_conf_globals.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- http_conf_globals.h	1998/05/11 20:08:06	1.31
  +++ http_conf_globals.h	1998/06/16 03:37:24	1.32
  @@ -102,9 +102,10 @@
   extern API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN];
   extern char ap_server_confname[MAX_STRING_LEN];
   
  -/* for -C and -c switches */
  +/* for -C, -c and -D switches */
   extern array_header *ap_server_pre_read_config;
   extern array_header *ap_server_post_read_config;
  +extern array_header *ap_server_config_defines;
   
   /* We want this to have the least chance of being corrupted if there
    * is some memory corruption, so we allocate it statically.
  
  
  
  1.365     +12 -2     apache-1.3/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v
  retrieving revision 1.364
  retrieving revision 1.365
  diff -u -r1.364 -r1.365
  --- http_main.c	1998/06/10 12:08:49	1.364
  +++ http_main.c	1998/06/16 03:37:27	1.365
  @@ -280,6 +280,7 @@
   
   array_header *ap_server_pre_read_config;
   array_header *ap_server_post_read_config;
  +array_header *ap_server_config_defines;
   
   /* *Non*-shared http_main globals... */
   
  @@ -3257,6 +3258,7 @@
       pcommands = ap_make_sub_pool(NULL);
       ap_server_pre_read_config  = ap_make_array(pcommands, 1, sizeof(char *));
       ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
  +    ap_server_config_defines   = ap_make_array(pcommands, 1, sizeof(char *));
   }
   
   #ifndef MULTITHREAD
  @@ -4229,7 +4231,7 @@
       ap_setup_prelinked_modules();
   
       while ((c = getopt(argc, argv,
  -				    "C:c:Xd:f:vVhlL:St"
  +				    "D:C:c:Xd:f:vVhlL:St"
   #ifdef DEBUG_SIGSTOP
   				    "Z:"
   #endif
  @@ -4244,6 +4246,10 @@
   	    new = (char **)ap_push_array(ap_server_pre_read_config);
   	    *new = ap_pstrdup(pcommands, optarg);
   	    break;
  +	case 'D':
  +	    new = (char **)ap_push_array(ap_server_config_defines);
  +	    *new = ap_pstrdup(pcommands, optarg);
  +	    break;
   	case 'd':
   	    ap_cpystrn(ap_server_root, optarg, sizeof(ap_server_root));
   	    break;
  @@ -5391,7 +5397,7 @@
   
       ap_setup_prelinked_modules();
   
  -    while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlZ:iusSt")) != -1) {
  +    while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVhlZ:iusSt")) != -1) {
           char **new;
   	switch (c) {
   	case 'c':
  @@ -5400,6 +5406,10 @@
   	    break;
   	case 'C':
   	    new = (char **)ap_push_array(ap_server_pre_read_config);
  +	    *new = ap_pstrdup(pcommands, optarg);
  +	    break;
  +	case 'D':
  +	    new = (char **)ap_push_array(ap_server_config_defines);
   	    *new = ap_pstrdup(pcommands, optarg);
   	    break;
   #ifdef WIN32
  
  
  
  1.204     +55 -0     apache-1.3/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
  retrieving revision 1.203
  retrieving revision 1.204
  diff -u -r1.203 -r1.204
  --- http_core.c	1998/05/28 15:28:13	1.203
  +++ http_core.c	1998/06/16 03:37:28	1.204
  @@ -657,6 +657,7 @@
   static const char end_filesmatch_section[] = "</FilesMatch>";
   static const char end_virtualhost_section[] = "</VirtualHost>";
   static const char end_ifmodule_section[] = "</IfModule>";
  +static const char end_ifdefine_section[] = "</IfDefine>";
   
   
   API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden)
  @@ -1174,6 +1175,58 @@
       return NULL;
   }
   
  +static int ap_exists_config_define(char *name)
  +{
  +    char **defines;
  +    int i;
  +
  +    defines = (char **)ap_server_config_defines->elts;
  +    for (i = 0; i < ap_server_config_defines->nelts; i++) {
  +        if (strcmp(defines[i], name) == 0)
  +            return 1;
  +    }
  +    return 0;
  +}
  +
  +static const char *end_ifdefine(cmd_parms *cmd, void *dummy) 
  +{
  +    return NULL;
  +}
  +
  +static const char *start_ifdefine(cmd_parms *cmd, void *dummy, char *arg)
  +{
  +    char *endp;
  +    char l[MAX_STRING_LEN];
  +    int defined;
  +    int not = 0;
  +    int nest = 1;
  +
  +    endp = strrchr(arg, '>');
  +    if (endp)
  +	*endp = '\0';
  +    if (arg[0] == '!') {
  +        not = 1;
  +	arg++;
  +    }
  +
  +    defined = ap_exists_config_define(arg);
  +
  +    if ((!not && defined) || (not && !defined))
  +	return NULL;
  +
  +    while (nest && !(ap_cfg_getline(l, MAX_STRING_LEN, cmd->config_file))) {
  +        if (!strncasecmp(l, "<IfDefine", 9))
  +	  nest++;
  +	if (!strcasecmp(l, "</IfDefine>"))
  +	  nest--;
  +    }
  +    if (nest) {
  +	cmd->end_token = end_ifdefine_section;
  +	return missing_endsection(cmd, nest);
  +    }
  +    return NULL;
  +}
  +
   /* httpd.conf commands... beginning with the <VirtualHost> business */
   
   static const char *virtualhost_section (cmd_parms *cmd, void *dummy, char *arg)
  @@ -1915,6 +1968,8 @@
   { "</Limit>", endlimit_section, NULL, OR_ALL, NO_ARGS, "Marks end of <Limit>" },
   { "<IfModule", start_ifmod, NULL, OR_ALL, RAW_ARGS, "Container for directives based on existance of specified modules" },
   { end_ifmodule_section, end_ifmod, NULL, OR_ALL, NO_ARGS, "Marks end of <IfModule>" },
  +{ "<IfDefine", start_ifdefine, NULL, OR_ALL, RAW_ARGS, "Container for directives based on existance of command line defines" },
  +{ end_ifdefine_section, end_ifdefine, NULL, OR_ALL, NO_ARGS, "Marks end of <IfDefine>" },
   { "<DirectoryMatch", dirsection, (void*)1, RSRC_CONF, RAW_ARGS, "Container for directives affecting resources located in the specified directories" },
   { end_directorymatch_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS, "Marks end of <DirectoryMatch>" },
   { "<LocationMatch", urlsection, (void*)1, RSRC_CONF, RAW_ARGS, "Container for directives affecting resources accessed through the specified URL paths" },
  
  
  
  1.11      +7 -0      apache-1.3/src/support/httpd.8
  
  Index: httpd.8
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/support/httpd.8,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- httpd.8	1998/06/10 12:08:51	1.10
  +++ httpd.8	1998/06/16 03:37:32	1.11
  @@ -69,6 +69,8 @@
   .BI \-C " directive"
   ] [
   .BI \-c " directive"
  +] [
  +.BI \-D " parameter"
   ]
   
   .B httpd 
  @@ -137,6 +139,11 @@
   .TP
   .BI \-c " directive"
   Process the configuration \fIdirective\fP after reading config files.
  +.TP
  +.BI \-D " parameter"
  +Sets a configuration \fIparameter\fP which can be used with
  +<IfDefine>...</IfDefine> sections in the configuration files
  +to conditionally skip or process commands.
   .TP
   .B \-h
   Output a list of directives together with expected arguments and
  
  
  

Re: cvs commit: apache-1.3/src/support httpd.8

Posted by Brian Behlendorf <br...@hyperreal.org>.
At 03:37 AM 6/16/98 -0000, Ralf wrote:
>    *) Add <IfDefine>..</IfDefine> sections to the core module (with same
spirit
>       as <IfModule>..</IfModule> sections) which can be used to skip or
process
>       contained commands dependend of ``-D PARAMETER'' options on the
command
>       line.

This is going to be very useful in building a test suite; thanks Ralf.

	Brian


--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
pure chewing satisfaction                                  brian@apache.org
                                                        brian@hyperreal.org