You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by di...@locus.apache.org on 2000/03/14 15:09:52 UTC

cvs commit: apache-2.0/src/main http_config.c util.c

dirkx       00/03/14 06:09:52

  Modified:    src      CHANGES
               src/include httpd.h
               src/main http_config.c util.c
  Log:
  Another one in the department of fairly useless patches which
  are best described as feature creep. Allows ${ENV} constructs
  in the config file. This avoids the need for mod_perl or
  m4 cleverness whilst mainting some of the usefullness. It
  does not do (of course) multiline things or anything that clever.
  
  Feel free to flame me.
  
  Revision  Changes    Path
  1.26      +12 -0     apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -u -r1.25 -r1.26
  --- CHANGES	2000/03/14 13:32:07	1.25
  +++ CHANGES	2000/03/14 14:09:51	1.26
  @@ -1,5 +1,17 @@
   Changes with Apache 2.0a2-dev
   
  +  *) Added the capability to do ${ENVVAR} constructs in the
  +     config file. E.g. 'ServerAdmin ${POSTMASTER}'. As commited
  +     it does this on a line by line basis; i.e. if the envvar
  +     expands to something with spaces you have to protect it
  +     by adding quotes around it (Unless of course you expect it
  +     to contains more than one argument. Alternatively you
  +     can compile it on a per token basis; which is what people
  +     usually expect by setting RESOLVE_ENV_PER_TOKEN. But this
  +     hampers fancier hacks.
  +     [Dirk-Willem van Gulik]
  +
  +     
     *) Changed the 'ErrorDocument' syntax in that it NO longer
        supports the asymetric
   
  
  
  
  1.30      +1 -0      apache-2.0/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -u -r1.29 -r1.30
  --- httpd.h	2000/03/14 08:01:46	1.29
  +++ httpd.h	2000/03/14 14:09:52	1.30
  @@ -918,6 +918,7 @@
   API_EXPORT(char *) ap_getword_nulls_nc(ap_context_t *p, char **line, char stop);
   API_EXPORT(char *) ap_getword_conf(ap_context_t *p, const char **line);
   API_EXPORT(char *) ap_getword_conf_nc(ap_context_t *p, char **line);
  +API_EXPORT(char *) ap_resolve_env(ap_context_t *p, const char * word); 
   
   API_EXPORT(const char *) ap_size_list_item(const char **field, int *len);
   API_EXPORT(char *) ap_get_list_item(ap_context_t *p, const char **field);
  
  
  
  1.27      +8 -0      apache-2.0/src/main/http_config.c
  
  Index: http_config.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_config.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -u -r1.26 -r1.27
  --- http_config.c	2000/03/10 00:06:52	1.26
  +++ http_config.c	2000/03/14 14:09:52	1.27
  @@ -636,6 +636,9 @@
   
       switch (cmd->args_how) {
       case RAW_ARGS:
  +#ifdef RESOLVE_ENV_PER_TOKEN
  +	args = ap_resolve_env(parms->pool,args);
  +#endif
   	return ((const char *(*)(cmd_parms *, void *, const char *))
   		(cmd->func)) (parms, mconfig, args);
   
  @@ -829,6 +832,7 @@
       return mconfig;
   }
   
  +
   CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l)
   {
       void *oldconfig;
  @@ -839,7 +843,11 @@
       if ((l[0] == '#') || (!l[0]))
   	return NULL;
   
  +#if RESOLVE_ENV_PER_TOKEN
       args = l;
  +#else
  +    args = ap_resolve_env(parms->temp_pool,l); 
  +#endif
       cmd_name = ap_getword_conf(parms->temp_pool, &args);
       if (*cmd_name == '\0')
   	return NULL;
  
  
  
  1.34      +39 -0     apache-2.0/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util.c,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -u -r1.33 -r1.34
  --- util.c	2000/03/13 20:27:21	1.33
  +++ util.c	2000/03/14 14:09:52	1.34
  @@ -706,7 +706,11 @@
       }
   
       *resp++ = '\0';
  +#if RESOLVE_ENV_PER_TOKEN
  +    return ap_resolve_env(p,result);
  +#else
       return result;
  +#endif
   }
   
   API_EXPORT(char *) ap_getword_conf_nc(ap_context_t *p, char **line)
  @@ -755,6 +759,41 @@
       return res;
   }
   
  +/* Check a string for any ${ENV} environment variable
  + * construct and replace each them by the value of
  + * that environment variable, if it exists. If the
  + * environment value does not exist, replace by an
  + * empty string. Any unrecognized construct is not
  + * replaced and silently ignored.
  + */
  +API_EXPORT(char *) ap_resolve_env(ap_context_t *p, const char * word)
  +{
  +       char tmp[ MAX_STRING_LEN ];
  +       char * s, * e;
  +       tmp[0] = '\0';
  +
  +       if (!(s=strchr(word,'$')))
  +               return (char *)word;
  +
  +       do {
  +               /* XXX - relies on strncat() to add '\0'
  +                */
  +	       strncat(tmp,word,s - word);
  +               if ((s[1] == '{') && (e=strchr(s,'}'))) {
  +                       *e = '\0';
  +                       word = e + 1;
  +                       e = getenv(s+2);
  +                       strcat(tmp,e ? e : "");
  +               } else {
  +                       /* ignore invalid strings */
  +                       word = s+1;
  +                       strcat(tmp,"$");
  +               };
  +       } while ((s=strchr(word,'$')));
  +       strcat(tmp,word);
  +
  +       return ap_pstrdup(p,tmp);
  +}
   API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp)
   {
   #ifdef DEBUG
  
  
  

Re: cvs commit: apache-2.0/src/main http_config.c util.c

Posted by Dirk-Willem van Gulik <di...@webweaving.org>.

Dean Gaudet wrote:
> 
> On 14 Mar 2000 dirkx@locus.apache.org wrote:
> 
> > dirkx       00/03/14 06:09:52
> >
> >   Modified:    src      CHANGES
> >                src/include httpd.h
> >                src/main http_config.c util.c
> >   Log:
> >   Another one in the department of fairly useless patches which
> >   are best described as feature creep. Allows ${ENV} constructs
> >   in the config file. This avoids the need for mod_perl or
> >   m4 cleverness whilst mainting some of the usefullness. It
> >   does not do (of course) multiline things or anything that clever.
> 
> whimper.  moan.  sigh.  i was sooo hoping we'd just move to xml or
> something programmatic.

Hmm this sounds like a carte blanche from Dean. Now there is this
horrible XML in/out hack from where this came from...

Dw

Re: cvs commit: apache-2.0/src/main http_config.c util.c

Posted by Manoj Kasichainula <ma...@io.com>.
On Thu, Mar 16, 2000 at 11:29:11AM -0800, Greg Stein wrote:
> I'm with Dean on this one. Turning the config language into a
> gadget-filled text processor is Bad and Wrong.

+1


Re: cvs commit: apache-2.0/src/main http_config.c util.c

Posted by rb...@apache.org.
> >   Log:
> >   Another one in the department of fairly useless patches which
> >   are best described as feature creep. Allows ${ENV} constructs
> >   in the config file. This avoids the need for mod_perl or
> >   m4 cleverness whilst mainting some of the usefullness. It
> >   does not do (of course) multiline things or anything that clever.
> 
> whimper.  moan.  sigh.  i was sooo hoping we'd just move to xml or
> something programmatic.

It looks like people want to move to a config API, which would allow
different installations of Apache to have different config languages./
There are people working oin this even as we speak.  I still don't know
how I feel about this, but it should make you happier Dean.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: cvs commit: apache-2.0/src/main http_config.c util.c

Posted by Greg Stein <gs...@lyra.org>.
On Tue, 14 Mar 2000, Dean Gaudet wrote:
> On 14 Mar 2000 dirkx@locus.apache.org wrote:
> > dirkx       00/03/14 06:09:52
> > 
> >   Modified:    src      CHANGES
> >                src/include httpd.h
> >                src/main http_config.c util.c
> >   Log:
> >   Another one in the department of fairly useless patches which
> >   are best described as feature creep. Allows ${ENV} constructs
> >   in the config file. This avoids the need for mod_perl or
> >   m4 cleverness whilst mainting some of the usefullness. It
> >   does not do (of course) multiline things or anything that clever.
> 
> whimper.  moan.  sigh.  i was sooo hoping we'd just move to xml or
> something programmatic.

I'm with Dean on this one. Turning the config language into a
gadget-filled text processor is Bad and Wrong. IMO, we should alter the
config processing to read the config from a file or a pipe. The pipe could
simply be output from M4 or Perl (or your favorite tool).

Add one feature such as ENV processing, then another little feature gets
added, then another... Soon you have a near duplicate of other tools, but
without the rest of the stuff that makes them great.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/


Re: cvs commit: apache-2.0/src/main http_config.c util.c

Posted by Dean Gaudet <dg...@arctic.org>.
On 14 Mar 2000 dirkx@locus.apache.org wrote:

> dirkx       00/03/14 06:09:52
> 
>   Modified:    src      CHANGES
>                src/include httpd.h
>                src/main http_config.c util.c
>   Log:
>   Another one in the department of fairly useless patches which
>   are best described as feature creep. Allows ${ENV} constructs
>   in the config file. This avoids the need for mod_perl or
>   m4 cleverness whilst mainting some of the usefullness. It
>   does not do (of course) multiline things or anything that clever.

whimper.  moan.  sigh.  i was sooo hoping we'd just move to xml or
something programmatic.

Dean