Commit 4ea0d6c5857064187cf28dad83e3e1e46b0e0a17
1 parent
7bcf57ee
Exists in
master
and in
5 other branches
Ajustando chamadas hllapi
Showing
6 changed files
with
68 additions
and
23 deletions
Show diff stats
src/lib3270/screen.c
| @@ -388,6 +388,8 @@ LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h) | @@ -388,6 +388,8 @@ LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h) | ||
| 388 | LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr) | 388 | LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr) |
| 389 | { | 389 | { |
| 390 | CHECK_SESSION_HANDLE(h); | 390 | CHECK_SESSION_HANDLE(h); |
| 391 | + | ||
| 392 | + trace("%s(%d)",__FUNCTION__,baddr); | ||
| 391 | 393 | ||
| 392 | if(h->selected && !lib3270_get_toggle(h,LIB3270_TOGGLE_KEEP_SELECTED)) | 394 | if(h->selected && !lib3270_get_toggle(h,LIB3270_TOGGLE_KEEP_SELECTED)) |
| 393 | lib3270_unselect(h); | 395 | lib3270_unselect(h); |
src/plugins/remotectl/calls.c
| @@ -392,12 +392,13 @@ | @@ -392,12 +392,13 @@ | ||
| 392 | { | 392 | { |
| 393 | if(!(setcursor && hSession)) | 393 | if(!(setcursor && hSession)) |
| 394 | return EINVAL; | 394 | return EINVAL; |
| 395 | - return setcursor(hSession,pos+1); | 395 | + trace("%s(%d)",__FUNCTION__,pos); |
| 396 | + return setcursor(hSession,pos-1); | ||
| 396 | } | 397 | } |
| 397 | 398 | ||
| 398 | __declspec (dllexport) DWORD __stdcall hllapi_getcursor() | 399 | __declspec (dllexport) DWORD __stdcall hllapi_getcursor() |
| 399 | { | 400 | { |
| 400 | if(!(getcursor && hSession)) | 401 | if(!(getcursor && hSession)) |
| 401 | return -EINVAL; | 402 | return -EINVAL; |
| 402 | - return getcursor(hSession)-1; | 403 | + return getcursor(hSession); |
| 403 | } | 404 | } |
src/plugins/remotectl/hllapi.c
| @@ -34,6 +34,9 @@ | @@ -34,6 +34,9 @@ | ||
| 34 | #include <pw3270/hllapi.h> | 34 | #include <pw3270/hllapi.h> |
| 35 | #include <stdio.h> | 35 | #include <stdio.h> |
| 36 | #include <lib3270/log.h> | 36 | #include <lib3270/log.h> |
| 37 | + | ||
| 38 | + #undef trace | ||
| 39 | + #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } } | ||
| 37 | 40 | ||
| 38 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | 41 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
| 39 | 42 | ||
| @@ -68,7 +71,9 @@ | @@ -68,7 +71,9 @@ | ||
| 68 | #endif // _WIN32 | 71 | #endif // _WIN32 |
| 69 | { | 72 | { |
| 70 | int f; | 73 | int f; |
| 71 | - | 74 | + |
| 75 | + trace("%s(%d)",__FUNCTION__,*func); | ||
| 76 | + | ||
| 72 | for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++) | 77 | for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++) |
| 73 | { | 78 | { |
| 74 | if(hllapi_call[f].func == *func) | 79 | if(hllapi_call[f].func == *func) |
| @@ -81,11 +86,34 @@ | @@ -81,11 +86,34 @@ | ||
| 81 | } | 86 | } |
| 82 | 87 | ||
| 83 | static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc) | 88 | static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc) |
| 84 | -{ | 89 | +{ |
| 90 | + char *tempbuffer = NULL; | ||
| 91 | + | ||
| 92 | + trace("%s: len=%d buflen=%d",__FUNCTION__,*length,strlen(buffer)); | ||
| 93 | + | ||
| 94 | + if(strlen(buffer) > *length) | ||
| 95 | + buffer[*length] = 0; | ||
| 96 | + | ||
| 97 | + if(!strrchr(buffer,':')) | ||
| 98 | + { | ||
| 99 | + int sz = strlen(buffer); | ||
| 100 | + | ||
| 101 | + tempbuffer = malloc(sz+2); | ||
| 102 | + strcpy(tempbuffer,buffer); | ||
| 103 | + tempbuffer[sz-1] = ':'; | ||
| 104 | + tempbuffer[sz] = buffer[sz-1]; | ||
| 105 | + tempbuffer[sz+1] = 0; | ||
| 106 | + buffer = tempbuffer; | ||
| 107 | + } | ||
| 108 | + | ||
| 85 | if(hllapi_init(buffer) == 0) | 109 | if(hllapi_init(buffer) == 0) |
| 86 | *rc = HLLAPI_STATUS_SUCESS; | 110 | *rc = HLLAPI_STATUS_SUCESS; |
| 87 | else | 111 | else |
| 88 | - *rc = HLLAPI_STATUS_UNAVAILABLE; | 112 | + *rc = HLLAPI_STATUS_UNAVAILABLE; |
| 113 | + | ||
| 114 | + if(tempbuffer) | ||
| 115 | + free(tempbuffer); | ||
| 116 | + | ||
| 89 | return 0; | 117 | return 0; |
| 90 | } | 118 | } |
| 91 | 119 | ||
| @@ -102,14 +130,22 @@ static int get_library_revision(char *buffer, unsigned short *length, unsigned s | @@ -102,14 +130,22 @@ static int get_library_revision(char *buffer, unsigned short *length, unsigned s | ||
| 102 | } | 130 | } |
| 103 | 131 | ||
| 104 | static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) | 132 | static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) |
| 105 | -{ | ||
| 106 | - *rc = hllapi_getcursor()-1; | 133 | +{ |
| 134 | + int pos = hllapi_getcursor(); | ||
| 135 | + | ||
| 136 | + trace("%s(%d)",__FUNCTION__,pos); | ||
| 137 | + | ||
| 138 | + if(pos < 0) | ||
| 139 | + return -1; | ||
| 140 | + | ||
| 141 | + *rc = pos; | ||
| 107 | return 0; | 142 | return 0; |
| 108 | } | 143 | } |
| 109 | 144 | ||
| 110 | static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) | 145 | static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) |
| 111 | -{ | ||
| 112 | - *rc = hllapi_setcursor(*rc+1); | 146 | +{ |
| 147 | + trace("%s(%d)",__FUNCTION__,*rc); | ||
| 148 | + *rc = hllapi_setcursor(*rc); | ||
| 113 | return 0; | 149 | return 0; |
| 114 | } | 150 | } |
| 115 | 151 |
src/plugins/remotectl/packets.h
| @@ -58,38 +58,38 @@ struct hllapi_packet_result | @@ -58,38 +58,38 @@ struct hllapi_packet_result | ||
| 58 | 58 | ||
| 59 | struct hllapi_packet_query | 59 | struct hllapi_packet_query |
| 60 | { | 60 | { |
| 61 | - int packet_id; | 61 | + unsigned char packet_id; |
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| 64 | struct hllapi_packet_connect | 64 | struct hllapi_packet_connect |
| 65 | { | 65 | { |
| 66 | - int packet_id; | 66 | + unsigned char packet_id; |
| 67 | unsigned char wait; | 67 | unsigned char wait; |
| 68 | char hostname[1]; | 68 | char hostname[1]; |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | struct hllapi_packet_keycode | 71 | struct hllapi_packet_keycode |
| 72 | { | 72 | { |
| 73 | - int packet_id; | 73 | + unsigned char packet_id; |
| 74 | unsigned short keycode; | 74 | unsigned short keycode; |
| 75 | }; | 75 | }; |
| 76 | 76 | ||
| 77 | struct hllapi_packet_cursor | 77 | struct hllapi_packet_cursor |
| 78 | { | 78 | { |
| 79 | - int packet_id; | 79 | + unsigned char packet_id; |
| 80 | unsigned short row; | 80 | unsigned short row; |
| 81 | unsigned short col; | 81 | unsigned short col; |
| 82 | }; | 82 | }; |
| 83 | 83 | ||
| 84 | struct hllapi_packet_text | 84 | struct hllapi_packet_text |
| 85 | { | 85 | { |
| 86 | - int packet_id; | 86 | + unsigned char packet_id; |
| 87 | char text[1]; | 87 | char text[1]; |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | struct hllapi_packet_at | 90 | struct hllapi_packet_at |
| 91 | { | 91 | { |
| 92 | - int packet_id; | 92 | + unsigned char packet_id; |
| 93 | unsigned short row; | 93 | unsigned short row; |
| 94 | unsigned short col; | 94 | unsigned short col; |
| 95 | unsigned short len; | 95 | unsigned short len; |
| @@ -97,7 +97,7 @@ struct hllapi_packet_at | @@ -97,7 +97,7 @@ struct hllapi_packet_at | ||
| 97 | 97 | ||
| 98 | struct hllapi_packet_text_at | 98 | struct hllapi_packet_text_at |
| 99 | { | 99 | { |
| 100 | - int packet_id; | 100 | + unsigned char packet_id; |
| 101 | unsigned short row; | 101 | unsigned short row; |
| 102 | unsigned short col; | 102 | unsigned short col; |
| 103 | char text[1]; | 103 | char text[1]; |
| @@ -105,7 +105,7 @@ struct hllapi_packet_text_at | @@ -105,7 +105,7 @@ struct hllapi_packet_text_at | ||
| 105 | 105 | ||
| 106 | struct hllapi_packet_query_at | 106 | struct hllapi_packet_query_at |
| 107 | { | 107 | { |
| 108 | - int packet_id; | 108 | + unsigned char packet_id; |
| 109 | unsigned short row; | 109 | unsigned short row; |
| 110 | unsigned short col; | 110 | unsigned short col; |
| 111 | unsigned short len; | 111 | unsigned short len; |
| @@ -113,14 +113,14 @@ struct hllapi_packet_query_at | @@ -113,14 +113,14 @@ struct hllapi_packet_query_at | ||
| 113 | 113 | ||
| 114 | struct hllapi_packet_wait | 114 | struct hllapi_packet_wait |
| 115 | { | 115 | { |
| 116 | - int packet_id; | 116 | + unsigned char packet_id; |
| 117 | int timeout; | 117 | int timeout; |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | struct hllapi_packet_addr | 120 | struct hllapi_packet_addr |
| 121 | { | 121 | { |
| 122 | - int packet_id; | ||
| 123 | - int addr; | 122 | + unsigned char packet_id; |
| 123 | + unsigned short addr; | ||
| 124 | }; | 124 | }; |
| 125 | 125 | ||
| 126 | 126 |
src/plugins/remotectl/pluginmain.c
| @@ -167,9 +167,9 @@ | @@ -167,9 +167,9 @@ | ||
| 167 | static void process_input(pipe_source *source, DWORD cbRead) | 167 | static void process_input(pipe_source *source, DWORD cbRead) |
| 168 | { | 168 | { |
| 169 | 169 | ||
| 170 | - trace("%s id=%d",__FUNCTION__,source->buffer[0]); | 170 | + trace("%s id=%d",__FUNCTION__,((struct hllapi_packet_query *) source->buffer)->packet_id); |
| 171 | 171 | ||
| 172 | - switch(source->buffer[0]) | 172 | + switch(((struct hllapi_packet_query *) source->buffer)->packet_id) |
| 173 | { | 173 | { |
| 174 | case HLLAPI_PACKET_CONNECT: | 174 | case HLLAPI_PACKET_CONNECT: |
| 175 | send_result(source,lib3270_connect( lib3270_get_default_session_handle(), | 175 | send_result(source,lib3270_connect( lib3270_get_default_session_handle(), |
| @@ -235,7 +235,7 @@ | @@ -235,7 +235,7 @@ | ||
| 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 | 237 | ||
| 238 | - case HLLAPI_PACKET_SET_CURSOR: | 238 | + case HLLAPI_PACKET_SET_CURSOR: |
| 239 | send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(), | 239 | send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(), |
| 240 | ((struct hllapi_packet_addr *) source->buffer)->addr)); | 240 | ((struct hllapi_packet_addr *) source->buffer)->addr)); |
| 241 | break; | 241 | break; |
src/plugins/remotectl/remote.c
| @@ -287,6 +287,9 @@ | @@ -287,6 +287,9 @@ | ||
| 287 | static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR }; | 287 | static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR }; |
| 288 | struct hllapi_packet_result response; | 288 | struct hllapi_packet_result response; |
| 289 | DWORD cbSize = sizeof(query); | 289 | DWORD cbSize = sizeof(query); |
| 290 | + | ||
| 291 | + trace("%s",__FUNCTION__); | ||
| 292 | + | ||
| 290 | TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | 293 | TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); |
| 291 | return (LIB3270_MESSAGE) response.rc; | 294 | return (LIB3270_MESSAGE) response.rc; |
| 292 | 295 | ||
| @@ -297,6 +300,9 @@ | @@ -297,6 +300,9 @@ | ||
| 297 | struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr }; | 300 | struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr }; |
| 298 | struct hllapi_packet_result response; | 301 | struct hllapi_packet_result response; |
| 299 | DWORD cbSize = sizeof(query); | 302 | DWORD cbSize = sizeof(query); |
| 303 | + | ||
| 304 | + trace("%s(%d)",__FUNCTION__,query.addr); | ||
| 305 | + | ||
| 300 | TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | 306 | TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); |
| 301 | return response.rc; | 307 | return response.rc; |
| 302 | } | 308 | } |