Get Environment Variable (QtmhGetEnv) API

Important: Information for this topic supports the latest PTF levels for HTTP Server for i5/OS . It is recommended that you install the latest PTFs to upgrade to the latest level of the HTTP Server for i5/OS. Some of the topics documented here are not available prior to this update. See http://www.ibm.com/servers/eserver/iseries/software/http/services/service.htm Link outside Information Center for more information.
Required Parameter Group:
1 Receiver variable Output Char(*)
2 Length of receiver variable Input Binary(4)
3 Length of response Output Binary(4)
4 Request variable Input Char(*)
5 Length of request variable Input Binary(4)
6 Error Code I/O Char(*)

The QtmhGetEnv API allows you to get the value set by the server for a particular HTTP environment variable.

Required parameter group

Receiver variable
OUTPUT:CHAR(*)

The output variable that contains the value set by the server for the requested environment variable. In CGI input mode %%MIXED%%, this value will be in CCSID 37; otherwise, it will be in the CCSID of the current job. Note that the QUERY_STRING in %%BINARY%% mode is not converted by the server.

Length of receiver variable
INPUT:BINARY(4)

The input variable containing the length of the space provided to receive the environment variable value.

Length of response
OUTPUT:BINARY(4)

The output variable that contains the length of the environment variable value. When the API is unable to determine the value for the requested environment variable, the length of the environment variable value is set to zero. When the size required for the environment variable value is larger than the length of the receiver variable, the size required to receive the value is returned.

Request variable
INPUT:CHAR(*)

The input variable containing the desired environment variable name.

Length of request variable
INPUT:BINARY(4)

The input variable containing the length (without trailing blanks) of the desired environment variable name.

Error Code
I/O:CHAR(*)

The structure in which to return error information. For the format of the structure and for details on how to process API errors, see the API error reporting topic in the iSeries™ Information Center.

Error messages

CPF24B4 E
Severe Error while addressing parameter list.
CPF3C17 E
Error occurred with input data parameter.
CPF3C19 E
Error occurred with receiver variable specified.
CPF3CF1 E
Error code parameter not valid.
Note: The Environment Variable APIs provide the getenv() (Get Value of Environment Variable) function necessary to retrieve environment variables in ILE C. Therefore, programs written in ILE C do not need to use the QtmhGetEnv() API. This API, for ILE C, is more difficult to use (and is slower) than the getenv() API on which it is based.

Programs that need CCSID conversion support for environment variables should use the Get environment variable with CCSID (QzsrGetEnvCCSID) API.