$NetBSD: patch-af,v 1.4 2004/11/07 13:18:16 jmmv Exp $

--- gpgme/get-env.c.orig	2003-09-13 19:45:04.000000000 +0200
+++ gpgme/get-env.c
@@ -21,6 +21,9 @@
 #include <config.h>
 #endif
 #include <stdlib.h>
+#if HAVE_RFUNCS_H
+#include <rfuncs.h>
+#endif
 #include <errno.h>
 #include <string.h>
 
@@ -52,7 +55,26 @@ _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];
+  int err;
+  if (err = getenv_r (name, env_value, 256))
+      *value = NULL;
+  else
+    {
+      *value = strdup (env_value);
+      if (!*value)
+        err = ENOMEM;
+    }
+  if (err != 0 && err != ENOENT)
+      return gpg_error_from_errno (err);
+  else
+      return (0);
+}
 
 #endif
