VxWorks Reference Manual : Libraries
envLib - environment variable library
envLibInit( ) - initialize environment variable facility
envPrivateCreate( ) - create a private environment
envPrivateDestroy( ) - destroy a private environment
putenv( ) - set an environment variable
getenv( ) - get an environment variable (ANSI)
envShow( ) - display the environment for a task
This library provides a UNIX-compatible environment variable facility. Environment variables are created or modified with a call to putenv( ):
putenv ("variableName=value");The value of a variable may be retrieved with a call to getenv( ), which returns a pointer to the value string.Tasks may share a common set of environment variables, or they may optionally create their own private environments, either automatically when the task create hook is installed, or by an explicit call to envPrivateCreate( ). The task must be spawned with the VX_PRIVATE_ENV option set to receive a private set of environment variables. Private environments created by the task creation hook inherit the values of the environment of the task that called taskSpawn( ) (since task create hooks run in the context of the calling task).
envLib.h
envLib, UNIX BSD 4.3 manual entry for environ(5V), * American National Standard for Information Systems - * Programming Language - C, ANSI X3.159-1989: General Utilities (stdlib.h)
envLibInit( ) - initialize environment variable facility
STATUS envLibInit ( BOOL installHooks )
If installHooks is TRUE, task create and delete hooks are installed that will optionally create and destroy private environments for the task being created or destroyed, depending on the state of VX_PRIVATE_ENV in the task options word. If installHooks is FALSE and a task requires a private environment, it is the application's responsibility to create and destroy the private environment, using envPrivateCreate( ) and envPrivateDestroy( ).
OK, or ERROR if an environment cannot be allocated or the hooks cannot be installed.
envPrivateCreate( ) - create a private environment
STATUS envPrivateCreate ( int taskId, /* task to have private environment */ int envSource /* -1 = make an empty private environment 0 = copy global to new private env taskId = copy the specified */ /* env */ )
This routine creates a private set of environment variables for a specified task, if the environment variable task create hook is not installed.
OK, or ERROR if memory is insufficient.
envLibInit( ), envPrivateDestroy( )
envPrivateDestroy( ) - destroy a private environment
STATUS envPrivateDestroy ( int taskId /* task with private env to destroy */ )
This routine destroys a private set of environment variables that were created with envPrivateCreate( ). Calling this routine is unnecessary if the environment variable task create hook is installed and the task was spawned with VX_PRIVATE_ENV.
OK, or ERROR if the task does not exist.
putenv( ) - set an environment variable
STATUS putenv ( char * pEnvString /* string to add to env */ )
This routine sets an environment variable to a value by altering an existing variable or creating a new one. The parameter points to a string of the form "variableName=value". Unlike the UNIX implementation, the string passed as a parameter is copied to a private buffer.
OK, or ERROR if space cannot be malloc'd.
envLibInit( ), getenv( )
getenv( ) - get an environment variable (ANSI)
char *getenv ( const char * name /* env variable to get value for */ )
This routine searches the environment list (see the UNIX BSD 4.3 manual entry for environ(5V)) for a string of the form "name=value" and returns the value portion of the string, if the string is present; otherwise it returns a NULL pointer.
A pointer to the string value, or a NULL pointer.
envLibInit( ), putenv( ), UNIX BSD 4.3 manual entry for environ(5V), American National Standard for Information Systems - Programming Language - C, ANSI X3.159-1989: General Utilities (stdlib.h)
envShow( ) - display the environment for a task
void envShow ( int taskId /* task for which environment is printed */ )
This routine prints to standard output all the environment variables for a specified task. If taskId is NULL, then the calling task's environment is displayed.
N/A