diff --git a/src/include/pw3270/hllapi.h b/src/include/pw3270/hllapi.h index 85bff64..be0cfdd 100644 --- a/src/include/pw3270/hllapi.h +++ b/src/include/pw3270/hllapi.h @@ -63,29 +63,6 @@ extern "C" { #define HLLAPI_STATUS_UNAVAILABLE 11 /**< Resource unavailable at this time */ - - typedef enum _hllapi_packet - { - HLLAPI_PACKET_CONNECT, - HLLAPI_PACKET_DISCONNECT, - HLLAPI_PACKET_GET_PROGRAM_MESSAGE, - HLLAPI_PACKET_GET_TEXT_AT, - HLLAPI_PACKET_SET_TEXT_AT, - HLLAPI_PACKET_CMP_TEXT_AT, - HLLAPI_PACKET_ENTER, - HLLAPI_PACKET_PFKEY, - HLLAPI_PACKET_PAKEY, - HLLAPI_PACKET_SET_CURSOR_POSITION, - HLLAPI_PACKET_GET_CURSOR_POSITION, - HLLAPI_PACKET_INPUT_STRING, - HLLAPI_PACKET_IS_CONNECTED, - - HLLAPI_PACKET_INVALID - - } HLLAPI_PACKET; - - - #ifdef _WIN32 // http://www.mingw.org/wiki/Visual_Basic_DLL __declspec (dllexport) int __stdcall hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc); @@ -108,6 +85,8 @@ extern "C" { __declspec (dllexport) DWORD __stdcall hllapi_wait(WORD seconds); __declspec (dllexport) DWORD __stdcall hllapi_pfkey(WORD key); __declspec (dllexport) DWORD __stdcall hllapi_pakey(WORD key); + __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD key); + __declspec (dllexport) DWORD __stdcall hllapi_getcursor(); #else diff --git a/src/plugins/remotectl/calls.c b/src/plugins/remotectl/calls.c index 6dfffe8..edca890 100644 --- a/src/plugins/remotectl/calls.c +++ b/src/plugins/remotectl/calls.c @@ -61,6 +61,8 @@ static int (*cmp_text_at)(void *h, int row, int col, const char *text) = NULL; static int (*pfkey)(void *hSession, int key) = NULL; static int (*pakey)(void *hSession, int key) = NULL; + static int (*getcursor)(void *hSession) = NULL; + static int (*setcursor)(void *hSession, int baddr) = NULL; static const struct _entry_point { @@ -85,6 +87,8 @@ { (void **) &cmp_text_at, (void *) hllapi_pipe_cmp_text_at, "lib3270_cmp_text_at" }, { (void **) &pfkey, (void *) hllapi_pipe_pfkey, "lib3270_pfkey" }, { (void **) &pakey, (void *) hllapi_pipe_pakey, "lib3270_pakey" }, + { (void **) &setcursor, (void *) hllapi_pipe_setcursor, "lib3270_set_cursor_address" }, + { (void **) &getcursor, (void *) hllapi_pipe_getcursor, "lib3270_get_cursor_address" }, { NULL, NULL } }; @@ -182,7 +186,6 @@ hModule = LoadLibrary(dllname); rc = GetLastError(); } -// hModule = LoadLibraryEx("lib3270.dll.5.0",NULL,LOAD_LIBRARY_SEARCH_DEFAULT_DIRS|LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); SetErrorMode(errorMode); @@ -385,3 +388,16 @@ return *datadir; } + __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD pos) + { + if(!(setcursor && hSession)) + return EINVAL; + return setcursor(hSession,pos+1); + } + + __declspec (dllexport) DWORD __stdcall hllapi_getcursor() + { + if(!(getcursor && hSession)) + return -EINVAL; + return getcursor(hSession)-1; + } diff --git a/src/plugins/remotectl/client.h b/src/plugins/remotectl/client.h index 1328f97..4bf0e05 100644 --- a/src/plugins/remotectl/client.h +++ b/src/plugins/remotectl/client.h @@ -54,4 +54,7 @@ int hllapi_pipe_wait_for_ready(void *h, int seconds); int hllapi_pipe_sleep(void *h, int seconds); int hllapi_pipe_is_connected(void *h); + int hllapi_pipe_getcursor(void *h); + int hllapi_pipe_setcursor(void *h, int baddr); + diff --git a/src/plugins/remotectl/hllapi.c b/src/plugins/remotectl/hllapi.c index b3beefe..c003ef7 100644 --- a/src/plugins/remotectl/hllapi.c +++ b/src/plugins/remotectl/hllapi.c @@ -41,6 +41,9 @@ static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc); static int get_library_revision(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); + /*--[ Globals ]--------------------------------------------------------------------------------------*/ static const struct _hllapi_call @@ -52,6 +55,8 @@ { HLLAPI_CMD_CONNECTPS, connect_ps }, { HLLAPI_CMD_DISCONNECTPS, disconnect_ps }, { HLLAPI_CMD_GETREVISION, get_library_revision }, + { HLLAPI_CMD_QUERYCURSOR, get_cursor_position }, + { HLLAPI_CMD_SETCURSOR, set_cursor_position }, }; /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -96,6 +101,18 @@ static int get_library_revision(char *buffer, unsigned short *length, unsigned s return 0; } +static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) +{ + *rc = hllapi_getcursor()-1; + return 0; +} + +static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) +{ + *rc = hllapi_setcursor(*rc+1); + return 0; +} + /* static int cmd_connect_ps(const char *name) diff --git a/src/plugins/remotectl/packets.h b/src/plugins/remotectl/packets.h index 50c0b7c..c82e599 100644 --- a/src/plugins/remotectl/packets.h +++ b/src/plugins/remotectl/packets.h @@ -26,6 +26,28 @@ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) * */ + + typedef enum _hllapi_packet + { + HLLAPI_PACKET_CONNECT, + HLLAPI_PACKET_DISCONNECT, + HLLAPI_PACKET_GET_PROGRAM_MESSAGE, + HLLAPI_PACKET_GET_TEXT_AT, + HLLAPI_PACKET_SET_TEXT_AT, + HLLAPI_PACKET_CMP_TEXT_AT, + HLLAPI_PACKET_ENTER, + HLLAPI_PACKET_PFKEY, + HLLAPI_PACKET_PAKEY, + HLLAPI_PACKET_SET_CURSOR_POSITION, + HLLAPI_PACKET_GET_CURSOR_POSITION, + HLLAPI_PACKET_INPUT_STRING, + HLLAPI_PACKET_IS_CONNECTED, + HLLAPI_PACKET_SET_CURSOR, + HLLAPI_PACKET_GET_CURSOR, + + HLLAPI_PACKET_INVALID + + } HLLAPI_PACKET; #pragma pack(1) @@ -94,6 +116,12 @@ struct hllapi_packet_wait int packet_id; int timeout; }; + +struct hllapi_packet_addr +{ + int packet_id; + int addr; +}; #pragma pack() diff --git a/src/plugins/remotectl/pluginmain.c b/src/plugins/remotectl/pluginmain.c index 38c1be1..b18e566 100644 --- a/src/plugins/remotectl/pluginmain.c +++ b/src/plugins/remotectl/pluginmain.c @@ -234,6 +234,16 @@ send_result(source,lib3270_input_string(lib3270_get_default_session_handle(), (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text)); break; + + case HLLAPI_PACKET_SET_CURSOR: + send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(), + ((struct hllapi_packet_addr *) source->buffer)->addr)); + break; + + case HLLAPI_PACKET_GET_CURSOR: + send_result(source,lib3270_get_cursor_address(lib3270_get_default_session_handle())); + break; + default: send_result(source, EINVAL); diff --git a/src/plugins/remotectl/remote.c b/src/plugins/remotectl/remote.c index 5beacf6..d927a34 100644 --- a/src/plugins/remotectl/remote.c +++ b/src/plugins/remotectl/remote.c @@ -281,3 +281,22 @@ return 0; } + + int hllapi_pipe_getcursor(void *h) + { + static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR }; + struct hllapi_packet_result response; + DWORD cbSize = sizeof(query); + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); + return (LIB3270_MESSAGE) response.rc; + + } + + int hllapi_pipe_setcursor(void *h, int baddr) + { + struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr }; + struct hllapi_packet_result response; + DWORD cbSize = sizeof(query); + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); + return response.rc; + } -- libgit2 0.21.2