getenv, NLgetenv
Purpose
Returns the value of an environment variable.
Library
Standard C Library (libc.a)
Syntax
char *getenv (name) char *NLgetenv (name)
char *name; char *name;
Description
The getenv subroutine searches the environment list for a
string of the form name=value. Environment variables are
sometimes called shell variables since they are fre-
quently set with shell commands.
The NLgetenv normally searches the environment for name
in the same way as getenv, except that special actions
may be taken if no environment definition is present for
name (NULL is a valid definition) or if a file meant to
supercede the current environment is specified through a
call to NLgetfile.
Return Value
The getenv subroutine returns a pointer to the value in
the current environment if such a string is present. If
such a string is not present, a NULL pointer is returned.
When no "override" file is found, NLgetenv follows this
procedure:
1. The definition of name is returned, if a non-null
definition for name exists in the environment.
2. If no definition (or a null definition) of name is
found in the environment definitions, the environment
variable NLFILE is searched for the pathname of a
file containing environment definitions. These defi-
nitions are of the form parameter=value. They are
read directly from the environment and interpreted as
definitions.
o If a non-null definition for name is found, it is
returned.
o If a null definition for name is found, or if
there is no default value for name, NULL is
returned.
3. If no non-null definition for name is found in this
file, or if NLFILE is not defined in the environment,
NLgetenv returns a traditional default value; if
there is no default value for name, NULL is returned.
If NLgetfile is called with a superceding file parameter
before NLgetenv is called, the search procedure is dif-
ferent. The "override" file is searched; the environment
of the process is not consulted in this operation:
1. If a non-null definition for name is found in the
file, then NLgetenv returns the definition.
2. If name is not defined in the file, then:
o A default definition is returned, if one exists.
o If no default definition exists, NLgetenv returns
NULL.
Related Information
In this book: "NLgetfile," "putenv," and "environment."
The sh command in AIX Operating System Commands
Reference.
"Overview of International Character Support" in Managing
the AIX Operating System.