]> granicus.if.org Git - php/commitdiff
More cleanup - move getenv() to SAPI
authorZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 17:55:01 +0000 (17:55 +0000)
committerZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 17:55:01 +0000 (17:55 +0000)
ext/standard/basic_functions.c
main/SAPI.c
main/SAPI.h
sapi/aolserver/aolserver.c
sapi/apache/mod_php4.c
sapi/cgi/cgi_main.c
sapi/isapi/php4isapi.c
sapi/phttpd/phttpd.c
sapi/roxen/roxen.c
sapi/servlet/servlet.c
sapi/thttpd/thttpd.c

index 53204b665fea0b1252390c183c8eec248aeb18db..2309df2db2c7e8aed11a8534f1c197f42622ff4e 100644 (file)
@@ -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;
 }
index e1b329daee5b672755a433b4aa245003aad0db42..7f8f5686929907bc039a2410d9bcb81ec0c0a105 100644 (file)
@@ -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
index 2b65a1a7a759b83b50f5b316a7a091505e8d1aee..88554cf18a9fb3212178b7c5dfa9bf8211f9dda3 100644 (file)
@@ -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, ...);
 
index d1b5dc86d8bcf990ec2b1a74e02fbec8e1dd7775..a7d200754e4670ddbd5da343b6978df934c4b858 100644 (file)
@@ -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 */
 
index edf848dd6a6b7a29c147c547b3dc9ec9186af752..7a9cb0ee94147ca9c3ee170b5df0d3445336c840 100644 (file)
@@ -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 */
 
index bf6138cd3c17ee076dea3c6f6143f4f9564fde53..db0c5cda526855cbb111f0298f1c5cb793b3af47 100644 (file)
@@ -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 */
 
index 8c4ff5c6958c14278790d79f2bfdbd2d79d63fcc..9f71738211372df2ca46aeef360bbde528ac66cc 100644 (file)
@@ -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 */
 
index 76184a7e7a7af2ed097c5e705e9edbbf0c9b77cf..194cf9ebf50e39463a0d2789b387d42e90da526f 100644 (file)
@@ -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 */
index 1d4f920e441246d0ddfaebdf915359fa99024ae0..0b87ed855e2fc35b9690c0f2b40e8b0335a697b9 100644 (file)
@@ -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 */
 
index 4ba10f9d132440ee3b43872655641f33160434cf..bc80e0f3be51cf90cf564619d113e314a77dc4b0 100644 (file)
@@ -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 */
 
index 4fab0c2abfeae72a60aa7aeb21469ceb93ad0c87..236439e4e3b37e1f241c6001e94f86588dc5bc30 100644 (file)
@@ -113,6 +113,7 @@ static sapi_module_struct sapi_module = {
        sapi_thttpd_ub_write,
        NULL,
        NULL,                                                                   /* get uid */
+       NULL,                                                                   /* getenv */
 
        php_error,