INtime SDK Help
getenv, getenv_s

Searches the environment-variable table for a specified entry.

#include <stdlib.h>

char *getenv (const char *varname);
errno_t getenv_s (size_t *valuelenresult, char *value,
rsize_t maxsize, const char *varname);

Parameters

varname
Name of environment variable being sought. The varname argument should match the case of the environment variable.
valuelenresult
pointer to a user-provided location where getenv_s will store the length of the environment variable.
value
pointer to a user-provided character array where setenv_s will store the contents of the environment variable.
maxsize
maximum number of characters that getenv_s is allowed to write to dest (size of the buffer).

Remarks

getenv is case-sensitive.

getenv operates only on the local process. The process environment is pre-loaded from "global" values which are set in the registry. The registry INtime\RtKernelLoader\INTIME.INI\CLIB contains values which are loaded into the environment.

The first call to getenv sets up an environment-variable table shared by all threads using the C library. A prototype for the table is contained in the file :config:r?env. When getenv is called for the first time, the table is initialized from :config:r?env. You can create an environment-variable file locally, :prog:r?env, that getenv uses in addition to :config:r?env, as a basis for the table. The maximum allowable number of entries in the environment-variable table is 40. Entries in the r?env files are of this form:

varname = [ASCII string]

A space character is required on both sides of the equal sign for fscanf parsing. For example, a typical entry in :config:r?env appears like this:

TZ = PST8PDT

Return Values

A pointer to the environment-variable table entry containing the current string value of varname. To update the entry, pass this pointer to putenv.
Success.
A null pointer if the given variable is not currently defined.
Failure.

getenv_s returns zero if the environment variable was found, non-zero if it was not found or if a runtime constrant violation occurred. On any error, writes zero to valuelenresult (unless valuelenresult is a null pointer).

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/stdlib.h stdlib.h clib.lib

See Also

putenv, fscanf