VMS Help
CRTL, getenv
*Conan The Librarian
|
Searches the environment array for the current process and
returns the value associated with a specified environment name.
Format
#include <stdlib.h>
char *getenv (const char *name);
name
One of the following values:
o HOME-Your login directory
o TERM-The type of terminal being used
o PATH-The default device and directory
o USER-The name of the user who initiated the process
o Logical name or CLI symbolic name
o An environment variable set with setenv or putenv.
The case of the specified name is important.
In certain situations, this function attempts to perform a
logical name translation on the user-specified argument:
1. If the argument to getenv does not match any of the
environment strings present in your environment array, getenv
attempts to translate your argument as a logical name by
searching the logical name tables indicated by the LNM$FILE_
DEV logical, as is done for file processing.
getenv first does a case-sensitive lookup. If that fails, it
does a case-insensitive lookup. In most instances, logical
names are defined in uppercase, but getenv can also find
logical names that include lowercase letters.
getenv does not perform iterative logical name translation.
2. If no logical name exists, getenv attempts to translate
the argument string as a command-language interpreter (CLI)
symbol. If it succeeds, it returns the translated symbol text.
If it fails, the return value is NULL.
getenv does not perform iterative CLI translation.
If your CLI is the DEC/Shell, the function does not attempt a
logical name translation since Shell environment symbols are
implemented as DCL symbols.
NOTE
In OpenVMS Version 7.1, a cache of VMS environment variables
(that is, logical names and DCL symbols) has been added to
the getenv function to avoid the library making repeated
calls to translate a logical name or to obtain the value
of a DCL symbol. By default, the cache is disabled. If
your application does not need to track changes in OpenVMS
environment variables that can occur during its execution,
the cache can be enabled by setting the DECC$ENABLE_
GETENV_CACHE logical before invoking the application (any
equivalence string).
x Pointer to an array containing the translated
symbol. An equivalence name is returned at
index zero.
NULL Indicates that the translation failed.