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:
  1. Table of HCL OneDB™ environment variables that the application has modified or defined with the ifx_putenv() function or directly (the InetLogin structure)
  2. Table of HCL OneDB environment variables that the user has defined in the Registry with the Setnet32 utility
  3. Non-HCL OneDB environment variables retrieved from the C runtime environment variables
  4. Table of defined defaults for HCL OneDB 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 ONEDB_HOME environment variable:
char ONEDB_HOMEVal[100];

/* Get current value of ONEDB_HOME */
ONEDB_HOMEVal = ifx_getenv( "ONEDB_HOME" );
/* Check if ONEDB_HOME is set */
If( ONEDB_HOMEVal != NULL )
   printf( "Current ONEDB_HOME value is %\n", ONEDB_HOMEVal );

Return codes

The ifx_getenv() function returns a pointer to the HCL OneDB 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 HCL OneDB environment table, the return value is NULL.