ehllapi JNA generator

101 views
Skip to first unread message

Mohan Radhakrishnan

unread,
Jan 24, 2018, 8:48:43 AM1/24/18
to NativeLibs4Java
Hi,
       We have a requirement to code some JNA interfaces to ehllapi 32-bit DLL. Has anyone generated those ? Are these header files available somewhere ?

I thought I could get an idea based on the generated interfaces.

Thanks,
Mohan

Bill Blalock

unread,
Jun 3, 2018, 5:58:19 PM6/3/18
to NativeLibs4Java
This is the JNA interface to PCSHLL32.DLL which I use:

import com.sun.jna.Pointer;

import com.sun.jna.ptr.IntByReference;

import com.sun.jna.win32.StdCallLibrary;


/**

 * Extended HLLAPI entry point of <code>PCSHLL32.DLL</code><p>

 * Documentation for functions is from Personal Communications for Windows, Version 6.0

 * Emulator Programming, SC318478-10  copyright IBM Corporation

 * @author Bill Blalock

 *

 */



public interface EHllApi32 extends StdCallLibrary {     //


        /**

         * per hapi_c32.h <>

         * <code> long hllapi (LPINT, LPSTR, LPINT, LPINT) </code>

         * @param functionNbr HELLAPI function number

         * @param dataBuffer byte buffer input to function. and sometimes returned by function

         * @param bufferLen length of byte buffer input to function, and sometimes returned by function

         * @param posOrReturnCode input is position of presentation space, return code from function

         * @return no practical use

         */


        // long hllapi (LPINT, LPSTR, LPINT, LPINT)

        long hllapi( IntByReference functionNbr, Pointer dataBuffer, IntByReference bufferLen, IntByReference posOrReturnCode );
     
}




Object to access the single entry point of PCSHLL32.DLL

                eHllApi32 = (EHllApi32) Native.loadLibrary("pcshll32", EHllApi32.class);


Object to receive value returned by EHLLAPI function call

/**

 * Container for values returned by HllApi.

 *

 * @author Bill Blalock

 *

 */


class HllApiVal {

  /** Code returned by HLLAPI.  */

  public int hllApiCod;


 
/** Length of data sent to EHLLAPI. */

  public int srcDataLen;


  /** Length of data returned by EHLLAPI. */

  public int hllApiLen; // length of data returned by hllapi

 

  /** Data returned by EHLLAPI. */

  public byte[] hllApiDta; // data returned by  

       

}



Method to call EHLLAPI function and retrieve the values returned by the function in HllApiVal

    /**
     * Call JNA object representing entry point EHLLAPI32 / PCSHL32 DLL to control

     * 5250 emulator.
     * @param func HLLAPI function number

     * @param dta HLLAPI data buffer for input and output

     * @param dtaLen HLLAPI length of data buffer

     * @param pos HLLAPI position in data buffer

     */


   

    public HllApiVal hllApi(int func, byte[] dta, int dtaLen, int pos)
    {

        // object to return with results from call to hllApi

        HllApiVal hav = new HllApiVal();

       
        int inputDtaLength = dta.length;

        Pointer dtaPtr = new Memory(inputDtaLength);

        if (dta != null )

            dtaPtr.write(0, dta, 0, inputDtaLength);

        IntByReference funcIntPtr = new IntByReference(func);

        IntByReference dtaLenPtr = new IntByReference(dtaLen);

        IntByReference posIntPtr = new IntByReference(pos);

           

        eHllApi32.hllapi(funcIntPtr, dtaPtr, dtaLenPtr, posIntPtr);

               

        hav.hllApiCod = posIntPtr.getValue();       // code returned by function call
        hav.hllApiLen = dtaLenPtr.getValue();       // length of byte array returned

        hav.hllApiDta = dtaPtr.getByteArray(0,      // byte array returned

                    inputDtaLength);
        hav.srcDataLen = inputDtaLength;            // length of input byteArray


        return hav;

    }




Reply all
Reply to author
Forward
0 new messages