summaryrefslogtreecommitdiff
path: root/security/gpgme/patches/patch-af
blob: 74192f83bf7356b5b60d38c26f7139820b23f73c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
$NetBSD: patch-af,v 1.6 2009/11/15 18:41:55 drochner Exp $

--- src/get-env.c.orig	2004-12-07 21:47:40.000000000 +0100
+++ src/get-env.c
@@ -22,6 +22,9 @@
 #include <config.h>
 #endif
 #include <stdlib.h>
+#if HAVE_RFUNCS_H
+#include <rfuncs.h>
+#endif
 #include <errno.h>
 #include <string.h>
 
@@ -53,7 +56,25 @@ _gpgme_getenv (const char *name, char **
 
 #else
 
-/* FIXME: Implement this when we have the specification for it.  */
-#error Use of getenv_r not implemented.
+/* Retrieve the environment variable NAME and return a copy of it in a
+   malloc()'ed buffer in *VALUE.  If the environment variable is not
+   set, return NULL in *VALUE.  */
+gpgme_error_t
+_gpgme_getenv (const char *name, char **value)
+{
+  char env_value[256];
+  if (getenv_r (name, env_value, 256) < 0)
+      *value = NULL;
+  else
+    {
+      *value = strdup (env_value);
+      if (!*value)
+        errno = ENOMEM;
+    }
+  if (!*value && errno != ENOENT)
+      return gpg_error_from_errno (errno);
+  else
+      return (0);
+}
 
 #endif