diff --git a/src/include/pw3270/hllapi.h b/src/include/pw3270/hllapi.h index 26a08c4..d6b7ed4 100644 --- a/src/include/pw3270/hllapi.h +++ b/src/include/pw3270/hllapi.h @@ -41,7 +41,7 @@ extern "C" { #define HLLAPI_MAXLENGTH 4096 - /* Function codes */ + /* Function codes - Reference http://www.ibm.com/support/knowledgecenter/SSEQ5Y_6.0.0/com.ibm.pcomm.doc/books/html/emulator_programming08.htm */ #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */ #define HLLAPI_CMD_DISCONNECTPS 2 /**< disconnect presentation space */ #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */ @@ -50,7 +50,10 @@ extern "C" { #define HLLAPI_CMD_SEARCHPS 6 /**< Search the presentation space for a specified string. */ #define HLLAPI_CMD_QUERYCURSOR 7 /**< Determines the location of the cursor in the presentation space. */ #define HLLAPI_CMD_COPYPSTOSTR 8 /**< Copy presentation space to string */ + #define HLLAPI_SET_SESSION_PARAMETERS 9 /**< Lets you change certain default session options in EHLLAPI for all sessions. */ #define HLLAPI_CMD_COPYSTRTOPS 15 /**< Copies an ASCII string directly to a specified position in the presentation space. */ + #define HLLAPI_CMD_PAUSE 18 /**< Waits for a specified amount of time. */ + #define HLLAPI_RESET_SYSTEM 21 /**< Reinitializes EHLLAPI to its starting state. */ #define HLLAPI_CMD_SETCURSOR 40 /**< Places the cursor at a specified position in presentation space.*/ #define HLLAPI_CMD_SENDFILE 90 /**< Send file to the host */ #define HLLAPI_CMD_RECEIVEFILE 91 /**< Receive a file from the host */ @@ -149,6 +152,8 @@ extern "C" { HLLAPI_API_CALL hllapi_init(LPSTR mode); HLLAPI_API_CALL hllapi_deinit(void); + HLLAPI_API_CALL hllapi_reset(void); + HLLAPI_API_CALL hllapi_get_revision(void); HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir); diff --git a/src/plugins/hllapi/Makefile.in b/src/plugins/hllapi/Makefile.in index 4a3a2a6..11aee09 100644 --- a/src/plugins/hllapi/Makefile.in +++ b/src/plugins/hllapi/Makefile.in @@ -80,6 +80,9 @@ $(BINDBG)$(DLL_NAME).$(VERSION): \ test: \ $(BINDBG)/test@EXEEXT@ +cleantest: \ + clean + cleanDebug: \ clean diff --git a/src/plugins/hllapi/calls.cc b/src/plugins/hllapi/calls.cc index efb2e09..92b66e1 100644 --- a/src/plugins/hllapi/calls.cc +++ b/src/plugins/hllapi/calls.cc @@ -379,3 +379,12 @@ { free(p); } + + HLLAPI_API_CALL hllapi_reset(void) + { + + + return HLLAPI_STATUS_SUCCESS; + } + + diff --git a/src/plugins/hllapi/hllapi.c b/src/plugins/hllapi/hllapi.c index 47f1ef0..9965a50 100644 --- a/src/plugins/hllapi/hllapi.c +++ b/src/plugins/hllapi/hllapi.c @@ -47,6 +47,8 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *rc); static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc); static int wait_system(char *buffer, unsigned short *length, unsigned short *rc); + static int reset_system(char *buffer, unsigned short *length, unsigned short *rc); + static int pause_system(char *buffer, unsigned short *length, unsigned short *rc); static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); @@ -75,6 +77,8 @@ { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps }, { HLLAPI_CMD_SENDFILE, invalid_request }, { HLLAPI_CMD_RECEIVEFILE, invalid_request }, + { HLLAPI_RESET_SYSTEM, reset_system }, + { HLLAPI_CMD_PAUSE, pause_system }, }; @@ -409,14 +413,16 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) /* * Return Code Definition * - * 0 The keyboard is unlocked and ready for input. - * 1 Your application program is not connected to a valid session. - * 4 Timeout while still in XCLOCK (X []) or XSYSTEM. - * 5 The keyboard is locked. - * 9 A system error was encountered. + * HLLAPI_STATUS_SUCCESS 0 The keyboard is unlocked and ready for input. + * HLLAPI_STATUS_DISCONNECTED 1 Your application program is not connected to a valid session. + * HLLAPI_STATUS_TIMEOUT 4 Timeout while still in XCLOCK (X []) or XSYSTEM. + * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The keyboard is locked. + * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered. * */ - time_t end = time(0) + 3600; + + /* + time_t end = time(0) + 60; while(time(0) < end) { @@ -425,12 +431,16 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) if(state != HLLAPI_STATUS_WAITING) return state; - if(hllapi_wait(1)) - return HLLAPI_STATUS_SYSTEM_ERROR; + hllapi_wait(1); } return HLLAPI_STATUS_TIMEOUT; + */ + + int state = hllapi_wait_for_ready(60); + return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state); + } static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps) @@ -438,19 +448,19 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps /* * Call Parameters * - * Data String String of ASCII data to be copied into the host presentation space. + * Data String of ASCII data to be copied into the host presentation space. * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode. - * PS Position Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space. + * PS Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space. * * Return Parameters * - * 0 The Copy String to Presentation Space function was successful. - * 1 Your program is not connected to a host session. - * 2 Parameter error or zero length for copy. - * 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte). - * 6 The copy was completed, but the data was truncated. - * 7 The host presentation space position is not valid. - * 9 A system error was encountered. + * HLLAPI_STATUS_SUCCESS 0 The Copy String to Presentation Space function was successful. + * HLLAPI_STATUS_DISCONNECTED 1 Your program is not connected to a host session. + * HLLAPI_STATUS_BAD_PARAMETER 2 Parameter error or zero length for copy. + * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte). + * 6 The copy was completed, but the data was truncated. + * 7 The host presentation space position is not valid. + * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered. * */ size_t szText = strlen(text); @@ -459,7 +469,7 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps szText = *length; if(!szText) - return 2; + return HLLAPI_STATUS_BAD_PARAMETER; switch(hllapi_get_message_id()) { @@ -483,3 +493,13 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps return hllapi_emulate_input(text,szText,0); } + +static int reset_system(char *buffer, unsigned short *length, unsigned short *rc) +{ + return hllapi_reset(); +} + +static int pause_system(char *buffer, unsigned short *length, unsigned short *rc) +{ + return hllapi_wait_for_ready((*length) / 2); +} diff --git a/src/plugins/hllapi/testprogram.c b/src/plugins/hllapi/testprogram.c index 16cc6a9..d5b1917 100644 --- a/src/plugins/hllapi/testprogram.c +++ b/src/plugins/hllapi/testprogram.c @@ -54,10 +54,12 @@ len = strlen(session); hllapi(&fn,hllapi_data,&len,&rc); + /* if(rc) { trace("HLLAPI_CMD_CONNECTPS(%s) exits with rc=%d", session, (int) rc); } + */ } -- libgit2 0.21.2