httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: [PATCH] allow ENV var's in config file.
Date Thu, 28 Oct 1999 18:31:15 GMT
ho hum.

m4.

perl.

insert dean's usual rant about growing a config language organically.

doesn't this break things like mod_rewrite which already use $ as a
special character in its command arguments?

Dean

On Wed, 20 Oct 1999, Dirk-Willem van Gulik wrote:

> 
> This let you do things lke
> 
> 	DocumentRoot	${DOCROOT}
> or
> 	TransferLog	${DIR}/${OPS_CLASS}_access.log
> 
> i.e simple environment variables in the various
> config files in quite some places.
> 
> Any objections against commiting this _horrible_ hack right
> now.. (because of course the all singing and dancing 2.0
> series will be so clever it won't need this :-)).
> 
> Dw
> 
> Index: util.c
> ===================================================================
> RCS file: /home/cvs/apache-1.3/src/main/util.c,v
> retrieving revision 1.160
> diff -u -r1.160 util.c
> --- util.c	1999/04/21 18:25:44	1.160
> +++ util.c	1999/10/20 20:13:21
> @@ -648,6 +648,36 @@
>  /* Get a word, (new) config-file style --- quoted strings and backslashes
>   * all honored
>   */
> +API_EXPORT(char *) ap_resolve_env(pool *p, const char * word)
> +{
> +	char tmp[ MAX_STRING_LEN ];
> +	char * s, * e;
> +	tmp[0] = '\0';
> +
> +	if (!(s=index(word,'$')))
> +		return (char *)word;
> +
> +	do {
> +		/* XXX - relies on strncat() to add '\0' 
> +		 */
> +		strncat(tmp,word,s - word); 
> +		if ((s[1] == '{') && (e=index(s,'}'))) {
> +			*e = '\0'; 
> +			word = e + 1;
> +			e = getenv(s+2);
> +#if 1
> +			if (!e) 
> +				e="!unset!";
> +#endif
> +			strcat(tmp,e);
> +		} else {
> +			/* ignore invalid strings */
> +			word = s+1;
> +		};
> +	} while (s=index(word,'$'));
> +
> +	return ap_pstrdup(p,tmp);
> +}
>  
>  static char *substring_conf(pool *p, const char *start, int len, char quote)
>  {
> @@ -664,7 +694,7 @@
>      }
>  
>      *resp++ = '\0';
> -    return result;
> +    return ap_resolve_env(p, result);
>  }
>  
>  API_EXPORT(char *) ap_getword_conf_nc(pool *p, char **line)
> @@ -710,6 +740,8 @@
>      while (*strend && ap_isspace(*strend))
>  	++strend;
>      *line = strend;
> +
> +     
>      return res;
>  }
>  
> 
> 


Mime
View raw message