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 | 388 | LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr) |
389 | 389 | { |
390 | 390 | CHECK_SESSION_HANDLE(h); |
391 | + | |
392 | + trace("%s(%d)",__FUNCTION__,baddr); | |
391 | 393 | |
392 | 394 | if(h->selected && !lib3270_get_toggle(h,LIB3270_TOGGLE_KEEP_SELECTED)) |
393 | 395 | lib3270_unselect(h); | ... | ... |
src/plugins/remotectl/calls.c
... | ... | @@ -392,12 +392,13 @@ |
392 | 392 | { |
393 | 393 | if(!(setcursor && hSession)) |
394 | 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 | 399 | __declspec (dllexport) DWORD __stdcall hllapi_getcursor() |
399 | 400 | { |
400 | 401 | if(!(getcursor && hSession)) |
401 | 402 | return -EINVAL; |
402 | - return getcursor(hSession)-1; | |
403 | + return getcursor(hSession); | |
403 | 404 | } | ... | ... |
src/plugins/remotectl/hllapi.c
... | ... | @@ -34,6 +34,9 @@ |
34 | 34 | #include <pw3270/hllapi.h> |
35 | 35 | #include <stdio.h> |
36 | 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 | 41 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
39 | 42 | |
... | ... | @@ -68,7 +71,9 @@ |
68 | 71 | #endif // _WIN32 |
69 | 72 | { |
70 | 73 | int f; |
71 | - | |
74 | + | |
75 | + trace("%s(%d)",__FUNCTION__,*func); | |
76 | + | |
72 | 77 | for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++) |
73 | 78 | { |
74 | 79 | if(hllapi_call[f].func == *func) |
... | ... | @@ -81,11 +86,34 @@ |
81 | 86 | } |
82 | 87 | |
83 | 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 | 109 | if(hllapi_init(buffer) == 0) |
86 | 110 | *rc = HLLAPI_STATUS_SUCESS; |
87 | 111 | else |
88 | - *rc = HLLAPI_STATUS_UNAVAILABLE; | |
112 | + *rc = HLLAPI_STATUS_UNAVAILABLE; | |
113 | + | |
114 | + if(tempbuffer) | |
115 | + free(tempbuffer); | |
116 | + | |
89 | 117 | return 0; |
90 | 118 | } |
91 | 119 | |
... | ... | @@ -102,14 +130,22 @@ static int get_library_revision(char *buffer, unsigned short *length, unsigned s |
102 | 130 | } |
103 | 131 | |
104 | 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 | 142 | return 0; |
108 | 143 | } |
109 | 144 | |
110 | 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 | 149 | return 0; |
114 | 150 | } |
115 | 151 | ... | ... |
src/plugins/remotectl/packets.h
... | ... | @@ -58,38 +58,38 @@ struct hllapi_packet_result |
58 | 58 | |
59 | 59 | struct hllapi_packet_query |
60 | 60 | { |
61 | - int packet_id; | |
61 | + unsigned char packet_id; | |
62 | 62 | }; |
63 | 63 | |
64 | 64 | struct hllapi_packet_connect |
65 | 65 | { |
66 | - int packet_id; | |
66 | + unsigned char packet_id; | |
67 | 67 | unsigned char wait; |
68 | 68 | char hostname[1]; |
69 | 69 | }; |
70 | 70 | |
71 | 71 | struct hllapi_packet_keycode |
72 | 72 | { |
73 | - int packet_id; | |
73 | + unsigned char packet_id; | |
74 | 74 | unsigned short keycode; |
75 | 75 | }; |
76 | 76 | |
77 | 77 | struct hllapi_packet_cursor |
78 | 78 | { |
79 | - int packet_id; | |
79 | + unsigned char packet_id; | |
80 | 80 | unsigned short row; |
81 | 81 | unsigned short col; |
82 | 82 | }; |
83 | 83 | |
84 | 84 | struct hllapi_packet_text |
85 | 85 | { |
86 | - int packet_id; | |
86 | + unsigned char packet_id; | |
87 | 87 | char text[1]; |
88 | 88 | }; |
89 | 89 | |
90 | 90 | struct hllapi_packet_at |
91 | 91 | { |
92 | - int packet_id; | |
92 | + unsigned char packet_id; | |
93 | 93 | unsigned short row; |
94 | 94 | unsigned short col; |
95 | 95 | unsigned short len; |
... | ... | @@ -97,7 +97,7 @@ struct hllapi_packet_at |
97 | 97 | |
98 | 98 | struct hllapi_packet_text_at |
99 | 99 | { |
100 | - int packet_id; | |
100 | + unsigned char packet_id; | |
101 | 101 | unsigned short row; |
102 | 102 | unsigned short col; |
103 | 103 | char text[1]; |
... | ... | @@ -105,7 +105,7 @@ struct hllapi_packet_text_at |
105 | 105 | |
106 | 106 | struct hllapi_packet_query_at |
107 | 107 | { |
108 | - int packet_id; | |
108 | + unsigned char packet_id; | |
109 | 109 | unsigned short row; |
110 | 110 | unsigned short col; |
111 | 111 | unsigned short len; |
... | ... | @@ -113,14 +113,14 @@ struct hllapi_packet_query_at |
113 | 113 | |
114 | 114 | struct hllapi_packet_wait |
115 | 115 | { |
116 | - int packet_id; | |
116 | + unsigned char packet_id; | |
117 | 117 | int timeout; |
118 | 118 | }; |
119 | 119 | |
120 | 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 | 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 | 174 | case HLLAPI_PACKET_CONNECT: |
175 | 175 | send_result(source,lib3270_connect( lib3270_get_default_session_handle(), |
... | ... | @@ -235,7 +235,7 @@ |
235 | 235 | (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text)); |
236 | 236 | break; |
237 | 237 | |
238 | - case HLLAPI_PACKET_SET_CURSOR: | |
238 | + case HLLAPI_PACKET_SET_CURSOR: | |
239 | 239 | send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(), |
240 | 240 | ((struct hllapi_packet_addr *) source->buffer)->addr)); |
241 | 241 | break; | ... | ... |
src/plugins/remotectl/remote.c
... | ... | @@ -287,6 +287,9 @@ |
287 | 287 | static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR }; |
288 | 288 | struct hllapi_packet_result response; |
289 | 289 | DWORD cbSize = sizeof(query); |
290 | + | |
291 | + trace("%s",__FUNCTION__); | |
292 | + | |
290 | 293 | TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); |
291 | 294 | return (LIB3270_MESSAGE) response.rc; |
292 | 295 | |
... | ... | @@ -297,6 +300,9 @@ |
297 | 300 | struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr }; |
298 | 301 | struct hllapi_packet_result response; |
299 | 302 | DWORD cbSize = sizeof(query); |
303 | + | |
304 | + trace("%s(%d)",__FUNCTION__,query.addr); | |
305 | + | |
300 | 306 | TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); |
301 | 307 | return response.rc; |
302 | 308 | } | ... | ... |