1 /* get_env.c - A getenv() replacement.
2 Copyright (C) 2003, 2004 g10 Code GmbH
4 This file is part of GPGME.
6 GPGME is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of
9 the License, or (at your option) any later version.
11 GPGME is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
31 #if defined(HAVE_THREAD_SAFE_GETENV) || !defined (HAVE_GETENV_R)
32 /* We prefer using getenv() if it is thread-safe. */
34 /* Retrieve the environment variable NAME and return a copy of it in a
35 malloc()'ed buffer in *VALUE. If the environment variable is not
36 set, return NULL in *VALUE. */
38 _gpgme_getenv (const char *name, char **value)
42 env_value = getenv (name);
47 *value = strdup (env_value);
49 return gpg_error_from_errno (errno);
56 /* FIXME: Implement this when we have the specification for it. */
57 #error Use of getenv_r not implemented.