Commit 7bcf57ee87deb783a250f6ada6328cc116cccbec
1 parent
6232053a
Exists in
master
and in
5 other branches
Implementando mais funções hllapi
Showing
7 changed files
with
96 additions
and
24 deletions
Show diff stats
src/include/pw3270/hllapi.h
@@ -63,29 +63,6 @@ extern "C" { | @@ -63,29 +63,6 @@ extern "C" { | ||
63 | #define HLLAPI_STATUS_UNAVAILABLE 11 /**< Resource unavailable at this time */ | 63 | #define HLLAPI_STATUS_UNAVAILABLE 11 /**< Resource unavailable at this time */ |
64 | 64 | ||
65 | 65 | ||
66 | - | ||
67 | - typedef enum _hllapi_packet | ||
68 | - { | ||
69 | - HLLAPI_PACKET_CONNECT, | ||
70 | - HLLAPI_PACKET_DISCONNECT, | ||
71 | - HLLAPI_PACKET_GET_PROGRAM_MESSAGE, | ||
72 | - HLLAPI_PACKET_GET_TEXT_AT, | ||
73 | - HLLAPI_PACKET_SET_TEXT_AT, | ||
74 | - HLLAPI_PACKET_CMP_TEXT_AT, | ||
75 | - HLLAPI_PACKET_ENTER, | ||
76 | - HLLAPI_PACKET_PFKEY, | ||
77 | - HLLAPI_PACKET_PAKEY, | ||
78 | - HLLAPI_PACKET_SET_CURSOR_POSITION, | ||
79 | - HLLAPI_PACKET_GET_CURSOR_POSITION, | ||
80 | - HLLAPI_PACKET_INPUT_STRING, | ||
81 | - HLLAPI_PACKET_IS_CONNECTED, | ||
82 | - | ||
83 | - HLLAPI_PACKET_INVALID | ||
84 | - | ||
85 | - } HLLAPI_PACKET; | ||
86 | - | ||
87 | - | ||
88 | - | ||
89 | #ifdef _WIN32 | 66 | #ifdef _WIN32 |
90 | // http://www.mingw.org/wiki/Visual_Basic_DLL | 67 | // http://www.mingw.org/wiki/Visual_Basic_DLL |
91 | __declspec (dllexport) int __stdcall hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc); | 68 | __declspec (dllexport) int __stdcall hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc); |
@@ -108,6 +85,8 @@ extern "C" { | @@ -108,6 +85,8 @@ extern "C" { | ||
108 | __declspec (dllexport) DWORD __stdcall hllapi_wait(WORD seconds); | 85 | __declspec (dllexport) DWORD __stdcall hllapi_wait(WORD seconds); |
109 | __declspec (dllexport) DWORD __stdcall hllapi_pfkey(WORD key); | 86 | __declspec (dllexport) DWORD __stdcall hllapi_pfkey(WORD key); |
110 | __declspec (dllexport) DWORD __stdcall hllapi_pakey(WORD key); | 87 | __declspec (dllexport) DWORD __stdcall hllapi_pakey(WORD key); |
88 | + __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD key); | ||
89 | + __declspec (dllexport) DWORD __stdcall hllapi_getcursor(); | ||
111 | 90 | ||
112 | #else | 91 | #else |
113 | 92 |
src/plugins/remotectl/calls.c
@@ -61,6 +61,8 @@ | @@ -61,6 +61,8 @@ | ||
61 | static int (*cmp_text_at)(void *h, int row, int col, const char *text) = NULL; | 61 | static int (*cmp_text_at)(void *h, int row, int col, const char *text) = NULL; |
62 | static int (*pfkey)(void *hSession, int key) = NULL; | 62 | static int (*pfkey)(void *hSession, int key) = NULL; |
63 | static int (*pakey)(void *hSession, int key) = NULL; | 63 | static int (*pakey)(void *hSession, int key) = NULL; |
64 | + static int (*getcursor)(void *hSession) = NULL; | ||
65 | + static int (*setcursor)(void *hSession, int baddr) = NULL; | ||
64 | 66 | ||
65 | static const struct _entry_point | 67 | static const struct _entry_point |
66 | { | 68 | { |
@@ -85,6 +87,8 @@ | @@ -85,6 +87,8 @@ | ||
85 | { (void **) &cmp_text_at, (void *) hllapi_pipe_cmp_text_at, "lib3270_cmp_text_at" }, | 87 | { (void **) &cmp_text_at, (void *) hllapi_pipe_cmp_text_at, "lib3270_cmp_text_at" }, |
86 | { (void **) &pfkey, (void *) hllapi_pipe_pfkey, "lib3270_pfkey" }, | 88 | { (void **) &pfkey, (void *) hllapi_pipe_pfkey, "lib3270_pfkey" }, |
87 | { (void **) &pakey, (void *) hllapi_pipe_pakey, "lib3270_pakey" }, | 89 | { (void **) &pakey, (void *) hllapi_pipe_pakey, "lib3270_pakey" }, |
90 | + { (void **) &setcursor, (void *) hllapi_pipe_setcursor, "lib3270_set_cursor_address" }, | ||
91 | + { (void **) &getcursor, (void *) hllapi_pipe_getcursor, "lib3270_get_cursor_address" }, | ||
88 | 92 | ||
89 | { NULL, NULL } | 93 | { NULL, NULL } |
90 | }; | 94 | }; |
@@ -182,7 +186,6 @@ | @@ -182,7 +186,6 @@ | ||
182 | hModule = LoadLibrary(dllname); | 186 | hModule = LoadLibrary(dllname); |
183 | rc = GetLastError(); | 187 | rc = GetLastError(); |
184 | } | 188 | } |
185 | -// hModule = LoadLibraryEx("lib3270.dll.5.0",NULL,LOAD_LIBRARY_SEARCH_DEFAULT_DIRS|LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); | ||
186 | 189 | ||
187 | SetErrorMode(errorMode); | 190 | SetErrorMode(errorMode); |
188 | 191 | ||
@@ -385,3 +388,16 @@ | @@ -385,3 +388,16 @@ | ||
385 | return *datadir; | 388 | return *datadir; |
386 | } | 389 | } |
387 | 390 | ||
391 | + __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD pos) | ||
392 | + { | ||
393 | + if(!(setcursor && hSession)) | ||
394 | + return EINVAL; | ||
395 | + return setcursor(hSession,pos+1); | ||
396 | + } | ||
397 | + | ||
398 | + __declspec (dllexport) DWORD __stdcall hllapi_getcursor() | ||
399 | + { | ||
400 | + if(!(getcursor && hSession)) | ||
401 | + return -EINVAL; | ||
402 | + return getcursor(hSession)-1; | ||
403 | + } |
src/plugins/remotectl/client.h
@@ -54,4 +54,7 @@ | @@ -54,4 +54,7 @@ | ||
54 | int hllapi_pipe_wait_for_ready(void *h, int seconds); | 54 | int hllapi_pipe_wait_for_ready(void *h, int seconds); |
55 | int hllapi_pipe_sleep(void *h, int seconds); | 55 | int hllapi_pipe_sleep(void *h, int seconds); |
56 | int hllapi_pipe_is_connected(void *h); | 56 | int hllapi_pipe_is_connected(void *h); |
57 | + int hllapi_pipe_getcursor(void *h); | ||
58 | + int hllapi_pipe_setcursor(void *h, int baddr); | ||
59 | + | ||
57 | 60 |
src/plugins/remotectl/hllapi.c
@@ -41,6 +41,9 @@ | @@ -41,6 +41,9 @@ | ||
41 | static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc); | 41 | static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc); |
42 | static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc); | 42 | static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc); |
43 | 43 | ||
44 | + static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); | ||
45 | + static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); | ||
46 | + | ||
44 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 47 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
45 | 48 | ||
46 | static const struct _hllapi_call | 49 | static const struct _hllapi_call |
@@ -52,6 +55,8 @@ | @@ -52,6 +55,8 @@ | ||
52 | { HLLAPI_CMD_CONNECTPS, connect_ps }, | 55 | { HLLAPI_CMD_CONNECTPS, connect_ps }, |
53 | { HLLAPI_CMD_DISCONNECTPS, disconnect_ps }, | 56 | { HLLAPI_CMD_DISCONNECTPS, disconnect_ps }, |
54 | { HLLAPI_CMD_GETREVISION, get_library_revision }, | 57 | { HLLAPI_CMD_GETREVISION, get_library_revision }, |
58 | + { HLLAPI_CMD_QUERYCURSOR, get_cursor_position }, | ||
59 | + { HLLAPI_CMD_SETCURSOR, set_cursor_position }, | ||
55 | }; | 60 | }; |
56 | 61 | ||
57 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 62 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
@@ -96,6 +101,18 @@ static int get_library_revision(char *buffer, unsigned short *length, unsigned s | @@ -96,6 +101,18 @@ static int get_library_revision(char *buffer, unsigned short *length, unsigned s | ||
96 | return 0; | 101 | return 0; |
97 | } | 102 | } |
98 | 103 | ||
104 | +static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) | ||
105 | +{ | ||
106 | + *rc = hllapi_getcursor()-1; | ||
107 | + return 0; | ||
108 | +} | ||
109 | + | ||
110 | +static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) | ||
111 | +{ | ||
112 | + *rc = hllapi_setcursor(*rc+1); | ||
113 | + return 0; | ||
114 | +} | ||
115 | + | ||
99 | 116 | ||
100 | /* | 117 | /* |
101 | static int cmd_connect_ps(const char *name) | 118 | static int cmd_connect_ps(const char *name) |
src/plugins/remotectl/packets.h
@@ -26,6 +26,28 @@ | @@ -26,6 +26,28 @@ | ||
26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | + | ||
30 | + typedef enum _hllapi_packet | ||
31 | + { | ||
32 | + HLLAPI_PACKET_CONNECT, | ||
33 | + HLLAPI_PACKET_DISCONNECT, | ||
34 | + HLLAPI_PACKET_GET_PROGRAM_MESSAGE, | ||
35 | + HLLAPI_PACKET_GET_TEXT_AT, | ||
36 | + HLLAPI_PACKET_SET_TEXT_AT, | ||
37 | + HLLAPI_PACKET_CMP_TEXT_AT, | ||
38 | + HLLAPI_PACKET_ENTER, | ||
39 | + HLLAPI_PACKET_PFKEY, | ||
40 | + HLLAPI_PACKET_PAKEY, | ||
41 | + HLLAPI_PACKET_SET_CURSOR_POSITION, | ||
42 | + HLLAPI_PACKET_GET_CURSOR_POSITION, | ||
43 | + HLLAPI_PACKET_INPUT_STRING, | ||
44 | + HLLAPI_PACKET_IS_CONNECTED, | ||
45 | + HLLAPI_PACKET_SET_CURSOR, | ||
46 | + HLLAPI_PACKET_GET_CURSOR, | ||
47 | + | ||
48 | + HLLAPI_PACKET_INVALID | ||
49 | + | ||
50 | + } HLLAPI_PACKET; | ||
29 | 51 | ||
30 | #pragma pack(1) | 52 | #pragma pack(1) |
31 | 53 | ||
@@ -94,6 +116,12 @@ struct hllapi_packet_wait | @@ -94,6 +116,12 @@ struct hllapi_packet_wait | ||
94 | int packet_id; | 116 | int packet_id; |
95 | int timeout; | 117 | int timeout; |
96 | }; | 118 | }; |
119 | + | ||
120 | +struct hllapi_packet_addr | ||
121 | +{ | ||
122 | + int packet_id; | ||
123 | + int addr; | ||
124 | +}; | ||
97 | 125 | ||
98 | 126 | ||
99 | #pragma pack() | 127 | #pragma pack() |
src/plugins/remotectl/pluginmain.c
@@ -234,6 +234,16 @@ | @@ -234,6 +234,16 @@ | ||
234 | send_result(source,lib3270_input_string(lib3270_get_default_session_handle(), | 234 | send_result(source,lib3270_input_string(lib3270_get_default_session_handle(), |
235 | (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text)); | 235 | (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text)); |
236 | break; | 236 | break; |
237 | + | ||
238 | + case HLLAPI_PACKET_SET_CURSOR: | ||
239 | + send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(), | ||
240 | + ((struct hllapi_packet_addr *) source->buffer)->addr)); | ||
241 | + break; | ||
242 | + | ||
243 | + case HLLAPI_PACKET_GET_CURSOR: | ||
244 | + send_result(source,lib3270_get_cursor_address(lib3270_get_default_session_handle())); | ||
245 | + break; | ||
246 | + | ||
237 | 247 | ||
238 | default: | 248 | default: |
239 | send_result(source, EINVAL); | 249 | send_result(source, EINVAL); |
src/plugins/remotectl/remote.c
@@ -281,3 +281,22 @@ | @@ -281,3 +281,22 @@ | ||
281 | 281 | ||
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | + | ||
285 | + int hllapi_pipe_getcursor(void *h) | ||
286 | + { | ||
287 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR }; | ||
288 | + struct hllapi_packet_result response; | ||
289 | + DWORD cbSize = sizeof(query); | ||
290 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
291 | + return (LIB3270_MESSAGE) response.rc; | ||
292 | + | ||
293 | + } | ||
294 | + | ||
295 | + int hllapi_pipe_setcursor(void *h, int baddr) | ||
296 | + { | ||
297 | + struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr }; | ||
298 | + struct hllapi_packet_result response; | ||
299 | + DWORD cbSize = sizeof(query); | ||
300 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
301 | + return response.rc; | ||
302 | + } |