putenv()

modify value of environment variable 

Function


SYNOPSIS

#include <stdlib.h>

int putenv(const char *string);


DESCRIPTION

The putenv() function looks up an environment variable and then modifies it. Specifically, putenv() takes a string of the form "name=value" and it makes the value of the environment variable name equal to value by altering an existing variable or creating a new one. In either case, a copy of string becomes part of the environment, so subsequent changes to string have no effect on the environment. The ordering of variables in the environment after putenv() is called, is undefined.


PARAMETERS

string 

Points to a string of the form "name=value".


RETURN VALUES

If successful, putenv() returns a value of zero. On failure, it returns a value of -1 and sets errno to one of the following values:

EINVAL 

The parameter name is NULL or is not in the form "name=value".

ENOMEM 

There is not enough memory to allocate name value.


CONFORMANCE

ANSI/ISO 9889-1990.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

The NuTCRACKER Platform copies the environment string, rather than embedding it within the environment.

When a NuTCRACKER Platform application starts, the NuTCRACKER Platform converts all paths in the environment from Windows format to NuTCRACKER Platform format. When exec()ing another program, the environment is converted back to Win32 format. When adding paths to the environment with putenv(), you should ensure that these paths are in NuTCRACKER Platform format, by using _NutPathToNutc() when appropriate. If you fail to do this, the path can be misinterpreted when the NuTCRACKER Platform tries to convert the environment back to Win32 format.

You can control which environment variables get converted and which do not with the by setting the NUT_ENV_CONVERT or NUT_ENV_LITERAL environment variables.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
_NutWIN32getenv(), _NutWIN32putenv(), getenv()

Miscellaneous:
environ


PTC MKS Toolkit 10.4 Documentation Build 39.