EHLLAPI Call Format

The EHLLAPI entry point (hllapi) is always called with the following four parameters:
  1. EHLLAPI Function Number (input)
  2. Data Buffer (input/output)
  3. Buffer Length (input/output)
  4. Position (input); Return Code (output)
The prototype for IBM® Standard EHLLAPI is:
[long hllapi (LPWORD, LPSTR, LPWORD, LPWORD);
The prototype for IBM® Enhanced EHLLAPI is:
[long hllapi (LPINT, LPSTR, LPINT, LPINT);
Each parameter is passed by reference not by value. Thus each parameter to the function call must be a pointer to the value, not the value itself. For example, the following is a correct example of calling the EHLLAPI Query Session Status function:
    #include "hapi_c.h"
    struct HLDQuerySessionStatus QueryData;
    int    Func, Len, Rc;
    long   Rc;
 
    memset(QueryData, 0, sizeof(QueryData)); // Init buffer
    QueryData.qsst_shortname = 'A';          // Session to query
    Func = HA_QUERY_SESSION_STATUS;          // Function number
    Len  = sizeof(QueryData);                // Len of buffer
    Rc   = 0;                                // Unused on input
 
    hllapi(&Func, (char *)&QueryData, &Len, &Rc);  // Call EHLLAPI
    if (Rc != 0) {                            // Check return code
      // ...Error handling
    }
All the parameters in the hllapi call are pointers and the return code of the EHLLAPI function is returned in the value of the 4th parameter, not as the value of the function. For example, the following is not correct:
    if (hllapi(&Func, (char *)&QueryData, &Len, &Rc) != 0) { // WRONG!
      // ...Error handling
    }

Although the hllapi function is defined to return a long data type for IBM® Standard and Enhanced EHLLAPI, and void data type for WinHLLAPI, its value is undefined and should not be used.

The second through fourth parameters of the hllapi call can return information to the application. The description of each EHLLAPI function describes what, if any, information is returned in these parameters.