5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
22 /* Set environment variable with value */
24 SilcBool silc_setenv(const char *variable, const char *value)
26 SILC_LOG_DEBUG(("Set %s=%s", variable, value));
27 #if defined(HAVE_SETENV)
28 return setenv(variable, value, TRUE) == 0;
29 #elif defined (HAVE_PUTENV)
31 silc_snprintf(tmp, sizeof(tmp), "%s=%s", variable, value);
32 return putenv(tmp) == 0;
33 #endif /* HAVE_SETENV */
37 /* Get environment variable value */
39 const char *silc_getenv(const char *variable)
41 SILC_LOG_DEBUG(("Get %s value", variable));
42 #if defined(HAVE_GETENV)
43 return (const char *)getenv(variable);
44 #endif /* HAVE_GETENV */
48 /* Unset environment variable */
50 SilcBool silc_unsetenv(const char *variable)
52 SILC_LOG_DEBUG(("Unset %s value", variable));
53 #if defined(HAVE_UNSETENV)
54 return unsetenv(variable) == 0;
55 #endif /* HAVE_GETENV */
59 /* Clear environment */
61 SilcBool silc_clearenv(void)
63 SILC_LOG_DEBUG(("Clear allenvironment variables"));
64 #if defined(HAVE_CLEARENV)
65 return clearenv() == 0;
66 #endif /* HAVE_GETENV */