Reads the current process environment.
Security Library (libc.a)
#include <usersec.h>
char **getpenv ( Which)
int Which;
The getpenv subroutine reads the specified environment variables and returns them in a character buffer.
Item | Description |
---|---|
Which | Specifies which environment variables are to be returned.
This parameter is a bit mask and may contain one or more of the following
values, as defined in the usersec.h file:
All variables are returned by setting the Which parameter to logically OR the PENV_USER and PENV_SYSTEM values. The variables are returned in a null-terminated array of character pointers in the form var=val. The user-state environment variables are prefaced by the string USRENVIRON:, and the system-state variables are prefaced with SYSENVIRON:. If a user-state environment is requested, the current directory is always returned in the PWD variable. If this variable is not present in the existing environment, the getpenv subroutine adds it to the returned string. |
Upon successful return, the getpenv subroutine returns the environment values. If the getpenv subroutine fails, a null value is returned and the errno global variable is set to indicate the error.
The getpenv subroutine fails if one or more of the following are true:
Item | Description |
---|---|
EINVAL | The Which parameter contains values other than PENV_USR or PENV_SYS. |
Other errors can also be set by subroutines invoked by the getpenv subroutine.