HP 3000 Manuals

getenv [ MPE/iX Developer's Kit Reference Manual Volume I ] MPE/iX 5.0 Documentation


MPE/iX Developer's Kit Reference Manual Volume I

getenv 

Returns an environment value.

Syntax 

     #include <stdlib.h>
     char *getenv (const char *name);

Parameters 

name       A pointer to a string of characters to match in the
           environment list.

Return Values 

<>NULL     A pointer to the value portion of a name=value string is
           returned.

NULL       A matching name was not found, and errno is not modified.

NULL +     An error occurred, and errno is set to indicate the error
errno      condition.

Description 

The getenv() function takes a string, name, and searches for a matching
name in the environment list (in environ) associated with the calling
process.

If a match to name is found, getenv() returns a pointer to the value 
portion of that string.  The value is terminated by a null character.  If
a matching name is not found, getenv() returns a NULL pointer but does
not modify the current value of errno.

The environment list contains strings in the form name=value.  If more
than one string has the same name, getenv() returns the value for the
first matching name found.  The length of name is limited by {ARG_MAX} as
defined in <limits.h>.

Implementation Considerations 

Refer to the EFAULT error description below.

Errors 

If an error occurs, errno is set to the following value:

EFAULT            CAUSE           The system detected a NULL or bad address in
                                  attempting to use the name parameter or while
                                  dereferencing environ and traversing the process's
                                  environment list.
                  ACTION          Check to see if the pointer is correctly initialized
                                  or if the environment list is corrupted.

See Also 

environ(), POSIX.1 (Section 4.6.1)



MPE/iX 5.0 Documentation