httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject [apreq-2] libapreq_cgi and getenv
Date Mon, 20 Oct 2003 04:18:48 GMT
Hi,
   I've been looking at libapreq_cgi, and am having some
problems getting cookie data from within a cgi program
(which I'll describe in a separate message). I don't know if
this is related, but would there be any objection (or harm?)
in using, within libapreq_cgi.c, the apr function
apr_env_get(), rather than getenv(), as in the following:
================================================================
Index: libapreq_cgi.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/libapreq_cgi.c,v
retrieving revision 1.10
diff -u -r1.10 libapreq_cgi.c
--- libapreq_cgi.c	14 Oct 2003 18:53:30 -0000	1.10
+++ libapreq_cgi.c	20 Oct 2003 04:14:56 -0000
@@ -59,6 +59,7 @@
 #include "apreq_cookie.h"
 #include "apr_strings.h"
 #include "apr_lib.h"
+#include "apr_env.h"

 #include <stdlib.h>
 #include <stdio.h>
@@ -103,14 +104,20 @@

 APREQ_DECLARE(const char *)apreq_env_query_string(void *env)
 {
-    return getenv("QUERY_STRING");
+    dCTX;
+    char *value;
+    apr_status_t s;
+    s = apr_env_get(&value, "QUERY_STRING", ctx->pool);
+    return value;
 }
+
 APREQ_DECLARE(const char *)apreq_env_header_in(void *env,
                                                const char *name)
 {
     dCTX;
     char *key = apr_pstrdup(ctx->pool, name);
-    char *k;
+    char *k, *value;
+    apr_status_t s;
     for (k = key; *k; ++k) {
         if (*k == '-')
             *k = '_';
@@ -118,8 +125,8 @@
             *k = apr_toupper(*k);
     }

-
-    return getenv(key);
+    s = apr_env_get(&value, key, ctx->pool);
+    return value;
 }

 APREQ_DECLARE(apr_status_t)apreq_env_header_out(void *ctx, const char *name,
===========================================================================

-- 
best regards,
randy

Mime
View raw message