5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2007 - 2008 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.
20 #include "silcruntime.h"
22 /* Set environment variable with value */
24 SilcBool silc_setenv(const char *variable, const char *value)
26 #if defined(HAVE_SETENV)
27 return setenv(variable, value, TRUE) == 0;
28 #elif defined (HAVE_PUTENV)
30 silc_snprintf(tmp, sizeof(tmp), "%s=%s", variable, value);
31 return putenv(tmp) == 0;
32 #endif /* HAVE_SETENV */
36 /* Get environment variable value */
38 const char *silc_getenv(const char *variable)
40 #if defined(HAVE_GETENV)
41 return (const char *)getenv(variable);
42 #endif /* HAVE_GETENV */
46 /* Unset environment variable */
48 SilcBool silc_unsetenv(const char *variable)
50 #if defined(HAVE_UNSETENV)
51 return unsetenv(variable) == 0;
52 #endif /* HAVE_GETENV */
56 /* Clear environment */
58 SilcBool silc_clearenv(void)
60 #if defined(HAVE_CLEARENV)
61 return clearenv() == 0;
62 #endif /* HAVE_GETENV */