pkgsrc/security/gpgme/patches/patch-af
drochner 7b9cca0501 resolve confusion about different behaviour of getenv_r in librfuncs
and NetBSD-current which caused serius lossage:
depend on librfuncs>=1.0.7nb1 which implements NetBSD-current's
behaviour, change the patch to _gpgme_getenv() accordingly,
and bump PKGREVISION
2006-03-01 16:22:20 +00:00

42 lines
1 KiB
Text

$NetBSD: patch-af,v 1.5 2006/03/01 16:22:21 drochner Exp $
--- gpgme/get-env.c.orig 2004-12-07 21:47:40.000000000 +0100
+++ gpgme/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