The ifx_getenv() function
The ifx_getenv() function retrieves the value of a current environment variable.
Syntax
char *ifx_getenv( varname );
const char *varname;
- varname
- A pointer to a buffer that contains the name of an environment variable.
Usage
The ifx_getenv() function
searches for the environment variable in the following order:
- Table of HCL Informix® environment variables that the application has modified or defined with the ifx_putenv() function or directly (the InetLogin structure)
- Table of Informix® environment variables that the user has defined in the Registry with the Setnet32 utility
- Non-Informix® environment variables retrieved from the C runtime environment variables
- Table of defined defaults for Informix® environment variables
The ifx_getenv() function is not case sensitive. You can specify the name of the environment variable in any case.
The ifx_getenv() function operates only on the data structures accessible to the C runtime library and not on the environment segment that the operating system creates for the process. Therefore, programs that use ifx_getenv() might retrieve invalid information.
The ifx_putenv() and ifx_getenv() functions use the copy of the environment to which the global variable _environ points to access the environment.
The following program fragment uses ifx_getenv() to
retrieve the current value of the INFORMIXDIR environment
variable:
char InformixDirVal[100];
/* Get current value of INFORMIXDIR */
InformixDirVal = ifx_getenv( "informixdir" );
/* Check if INFORMIXDIR is set */
If( InformixDirVal != NULL )
printf( "Current INFORMIXDIR value is %\n", InformixDirVal );
Return codes
The ifx_getenv() function
returns a pointer to the Informix® environment
table entry that contains varname, or returns NULL if the function
does not find varname in the table.
Restriction: Do
not use the returned pointer to modify the value of the environment
variable. Use the ifx_putenv() function instead.
If ifx_getenv() does not find "varname" in the Informix® environment
table, the return value is NULL.