VxWorks Reference Manual : Libraries

envLib

NAME

envLib - environment variable library

ROUTINES

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

DESCRIPTION

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).

INCLUDE FILES

envLib.h

SEE ALSO

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)


Libraries : Routines

envLibInit( )

NAME

envLibInit( ) - initialize environment variable facility

SYNOPSIS

STATUS envLibInit
    (
    BOOL installHooks
    )

DESCRIPTION

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( ).

RETURNS

OK, or ERROR if an environment cannot be allocated or the hooks cannot be installed.

SEE ALSO

envLib


Libraries : Routines

envPrivateCreate( )

NAME

envPrivateCreate( ) - create a private environment

SYNOPSIS

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 */
    )

DESCRIPTION

This routine creates a private set of environment variables for a specified task, if the environment variable task create hook is not installed.

RETURNS

OK, or ERROR if memory is insufficient.

SEE ALSO

envLibInit( ), envPrivateDestroy( )


Libraries : Routines

envPrivateDestroy( )

NAME

envPrivateDestroy( ) - destroy a private environment

SYNOPSIS

STATUS envPrivateDestroy
    (
    int taskId /* task with private env to destroy */
    )

DESCRIPTION

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.

RETURNS

OK, or ERROR if the task does not exist.

SEE ALSO

envLib, envPrivateCreate( )


Libraries : Routines

putenv( )

NAME

putenv( ) - set an environment variable

SYNOPSIS

STATUS putenv
    (
    char * pEnvString /* string to add to env */
    )

DESCRIPTION

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.

RETURNS

OK, or ERROR if space cannot be malloc'd.

SEE ALSO

envLibInit( ), getenv( )


Libraries : Routines

getenv( )

NAME

getenv( ) - get an environment variable (ANSI)

SYNOPSIS

char *getenv
    (
    const char * name /* env variable to get value for */
    )

DESCRIPTION

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.

RETURNS

A pointer to the string value, or a NULL pointer.

SEE ALSO

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)


Libraries : Routines

envShow( )

NAME

envShow( ) - display the environment for a task

SYNOPSIS

void envShow
    (
    int taskId /* task for which environment is printed */
    )

DESCRIPTION

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.

RETURNS

N/A

SEE ALSO

envLib