diff options
| author | Zeev Suraski <zeev@php.net> | 2000-02-10 17:55:01 +0000 | 
|---|---|---|
| committer | Zeev Suraski <zeev@php.net> | 2000-02-10 17:55:01 +0000 | 
| commit | 0fd89aa20d7a8226e68f13f4418e9183b46acd6e (patch) | |
| tree | 384b86d20f3e45e2eb7357c1c76eb492d279b953 | |
| parent | 7d926a0e0c0862b4469200b5ebb7cc85c263b2dc (diff) | |
| download | php-git-0fd89aa20d7a8226e68f13f4418e9183b46acd6e.tar.gz | |
More cleanup - move getenv() to SAPI
| -rw-r--r-- | ext/standard/basic_functions.c | 49 | ||||
| -rw-r--r-- | main/SAPI.c | 12 | ||||
| -rw-r--r-- | main/SAPI.h | 2 | ||||
| -rw-r--r-- | sapi/aolserver/aolserver.c | 1 | ||||
| -rw-r--r-- | sapi/apache/mod_php4.c | 10 | ||||
| -rw-r--r-- | sapi/cgi/cgi_main.c | 1 | ||||
| -rw-r--r-- | sapi/isapi/php4isapi.c | 1 | ||||
| -rw-r--r-- | sapi/phttpd/phttpd.c | 3 | ||||
| -rw-r--r-- | sapi/roxen/roxen.c | 1 | ||||
| -rw-r--r-- | sapi/servlet/servlet.c | 1 | ||||
| -rw-r--r-- | sapi/thttpd/thttpd.c | 1 | 
11 files changed, 42 insertions, 40 deletions
| diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 53204b665f..2309df2db2 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -482,53 +482,26 @@ PHP_RSHUTDOWN_FUNCTION(basic)  PHP_FUNCTION(getenv)  { -#if FHTTPD -	int i; -#endif  	pval **str;  	char *ptr; -#if APACHE -	SLS_FETCH(); -#endif +  	if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {  		WRONG_PARAM_COUNT;  	}  	convert_to_string_ex(str); -#if FHTTPD -	ptr=NULL; -	if ((*str)->type == IS_STRING && req){ -		for(i=0;i<req->nlines;i++){ -			if (req->lines[i].paramc>1){ -				if (req->lines[i].params[0]){ -					if (!strcmp(req->lines[i].params[0], -								(*str)->value.str.val)){ -						ptr=req->lines[i].params[1]; -						i=req->nlines; -					} -				} -			} -		} +	if ((*str)->type != IS_STRING) { +		RETURN_FALSE;  	} -	if (!ptr) ptr = getenv((*str)->value.str.val); -	if (ptr -#else - -	if ((*str)->type == IS_STRING && -#if APACHE -		((ptr = (char *)table_get(((request_rec *) SG(server_context))->subprocess_env, (*str)->value.str.val)) || (ptr = getenv((*str)->value.str.val))) -#endif -#if CGI_BINARY -		(ptr = getenv((*str)->value.str.val)) -#endif - -#if USE_SAPI -		(ptr = sapi_rqst->getenv(sapi_rqst->scid,(*str)->value.str.val)) -#endif -#endif -		) { -		RETURN_STRING(ptr,1); +	 +	 +	ptr = sapi_getenv((*str)->value.str.val, (*str)->value.str.len); +	if (!ptr) { +		ptr = getenv((*str)->value.str.val); +	} +	if (ptr) { +		RETURN_STRING(ptr, 1);  	}  	RETURN_FALSE;  } diff --git a/main/SAPI.c b/main/SAPI.c index e1b329daee..7f8f568692 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -402,3 +402,15 @@ SAPI_API int sapi_get_uid()  		return statbuf.st_uid;  	}  } + + +SAPI_API char *sapi_getenv(char *name, int name_len) +{ +	if (sapi_module.getenv) { +		SLS_FETCH(); + +		return sapi_module.getenv(name, name_len SLS_CC); +	} else { +		return NULL; +	} +}
\ No newline at end of file diff --git a/main/SAPI.h b/main/SAPI.h index 2b65a1a7a7..88554cf18a 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -128,6 +128,7 @@ SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(char  SAPI_API int sapi_flush();  SAPI_API int sapi_get_uid(); +SAPI_API char *sapi_getenv(char *name, int name_len);  struct _sapi_module_struct {  	char *name; @@ -141,6 +142,7 @@ struct _sapi_module_struct {  	int (*ub_write)(const char *str, unsigned int str_length);  	void (*flush)(void *server_context);  	int (*get_uid)(SLS_D); +	char *(*getenv)(char *name, int name_len SLS_DC);  	void (*sapi_error)(int type, const char *error_msg, ...); diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index d1b5dc86d8..a7d200754e 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -303,6 +303,7 @@ static sapi_module_struct sapi_module = {  	php_ns_sapi_ub_write,					/* unbuffered write */  	NULL,									/* flush */  	NULL,									/* get uid */ +	NULL,									/* getenv */  	php_error,								/* error handler */ diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index edf848dd6a..7a9cb0ee94 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -306,6 +306,14 @@ static int php_apache_get_uid(SLS_D)  } +static char *php_apache_getenv(char *name, int name_len SLS_DC) +{ +	char *value; + +	return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name)); +} + +  static sapi_module_struct sapi_module = {  	"Apache",						/* name */ @@ -318,7 +326,7 @@ static sapi_module_struct sapi_module = {  	sapi_apache_ub_write,			/* unbuffered write */  	sapi_apache_flush,				/* flush */  	php_apache_get_uid,				/* get uid */ - +	php_apache_getenv,				/* getenv */  	php_error,						/* error handler */ diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index bf6138cd3c..db0c5cda52 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -189,6 +189,7 @@ static sapi_module_struct sapi_module = {  	sapi_cgibin_ub_write,			/* unbuffered write */  	sapi_cgibin_flush,				/* flush */  	NULL,							/* get uid */ +	NULL,							/* getenv */  	php_error,						/* error handler */ diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c index 8c4ff5c695..9f71738211 100644 --- a/sapi/isapi/php4isapi.c +++ b/sapi/isapi/php4isapi.c @@ -351,6 +351,7 @@ static sapi_module_struct sapi_module = {  	sapi_isapi_ub_write,			/* unbuffered write */  	NULL,							/* flush */  	NULL,							/* get uid */ +	NULL,							/* getenv */  	php_error,						/* error handler */ diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c index 76184a7e7a..194cf9ebf5 100644 --- a/sapi/phttpd/phttpd.c +++ b/sapi/phttpd/phttpd.c @@ -173,7 +173,8 @@ static sapi_module_struct sapi_module = {      php_phttpd_sapi_ub_write,               /* unbuffered write */  	NULL,									/* flush */  	NULL,									/* get uid */ -  + 	NULL,									/* getenv */ +      php_error,                              /* error handler */      php_phttpd_sapi_header_handler,         /* header handler */ diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index 1d4f920e44..0b87ed855e 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -527,6 +527,7 @@ static sapi_module_struct sapi_module = {    php_roxen_sapi_ub_write,					/* unbuffered write */    NULL,										/* flush */    NULL,										/* get uid */ +  NULL,										/* getenv */    php_error,								/* error handler */ diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c index 4ba10f9d13..bc80e0f3be 100644 --- a/sapi/servlet/servlet.c +++ b/sapi/servlet/servlet.c @@ -222,6 +222,7 @@ static sapi_module_struct sapi_module = {  	sapi_servlet_ub_write,			/* unbuffered write */  	NULL,							/* flush */  	NULL,							/* get uid */ +	NULL,							/* getenv */  	php_error,						/* error handler */ diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 4fab0c2abf..236439e4e3 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -113,6 +113,7 @@ static sapi_module_struct sapi_module = {  	sapi_thttpd_ub_write,  	NULL,  	NULL,									/* get uid */ +	NULL,									/* getenv */  	php_error, | 
