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;
}
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
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;
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, ...);
php_ns_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
NULL, /* get uid */
+ NULL, /* getenv */
php_error, /* error handler */
}
+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 */
sapi_apache_ub_write, /* unbuffered write */
sapi_apache_flush, /* flush */
php_apache_get_uid, /* get uid */
-
+ php_apache_getenv, /* getenv */
php_error, /* error handler */
sapi_cgibin_ub_write, /* unbuffered write */
sapi_cgibin_flush, /* flush */
NULL, /* get uid */
+ NULL, /* getenv */
php_error, /* error handler */
sapi_isapi_ub_write, /* unbuffered write */
NULL, /* flush */
NULL, /* get uid */
+ NULL, /* getenv */
php_error, /* error handler */
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 */
php_roxen_sapi_ub_write, /* unbuffered write */
NULL, /* flush */
NULL, /* get uid */
+ NULL, /* getenv */
php_error, /* error handler */
sapi_servlet_ub_write, /* unbuffered write */
NULL, /* flush */
NULL, /* get uid */
+ NULL, /* getenv */
php_error, /* error handler */
sapi_thttpd_ub_write,
NULL,
NULL, /* get uid */
+ NULL, /* getenv */
php_error,