Support for POSIX functions getenv(), setenv(), and clearenv()

Environment variables are contained in an array of null-terminated strings of the form name=value in the POSIX process. These environment variables are manipulated by the functions listed below, or by the external variable extern char **environ. The names cannot contain the equal sign character (=).

Access to environment variables using **environ cannot be guaranteed in a POSIX application that uses multiple threads. Access by these functions serializes access to the environment variables and guarantees consistency of the environment variable array in a threaded environment.

The functions that manipulate environment variables are listed as follows:

Syntax

#include <sys/types.h>
char  *getenv(const char *name);
int    setenv(const char *name, char *newvalue, int overwrite);
int    clearenv(void); 
getenv()
Searches the environment variable list for a string of the form name=value and returns a pointer to value if such a string is present, NULL otherwise. For details, see the POSIX 1003.1 definition.
setenv()
Searches the environment variable list for a string of the form name=value. If found and the overwrite argument is nonzero, the newvalue is substituted for the current value. If the string is not found, add it to the environment variable list. For details, see the POSIX 1003.1 definition.
clearenv()
Clears all of the environment variables in the POSIX process. For details, see the POSIX 1003.1 definition.