Commit b0f14ba36b8b224dd849c33836e4a9f8f0bafd6b

Authored by perry.werneck@gmail.com
1 parent 3337cc2a

Reimplementando modulo hllapi

src/plugins/remotectl/calls.c
... ... @@ -72,14 +72,14 @@
72 72 { (void **) &host_disconnect, (void *) hllapi_pipe_disconnect, "lib3270_disconnect" },
73 73 { (void **) &wait_for_ready, (void *) NULL, "lib3270_wait_for_ready" },
74 74 { (void **) &script_sleep, (void *) NULL, "lib3270_wait" },
75   - { (void **) &get_message, (void *) NULL, "lib3270_get_program_message" },
76   - { (void **) &get_text, (void *) NULL, "lib3270_get_text_at" },
  75 + { (void **) &get_message, (void *) hllapi_pipe_get_message, "lib3270_get_program_message" },
  76 + { (void **) &get_text, (void *) hllapi_pipe_get_text_at, "lib3270_get_text_at" },
77 77 { (void **) &release_memory, (void *) hllapi_pipe_release_memory, "lib3270_free" },
78   - { (void **) &action_enter, (void *) NULL, "lib3270_enter" },
79   - { (void **) &set_text_at, (void *) NULL, "lib3270_set_string_at" },
80   - { (void **) &cmp_text_at, (void *) NULL, "lib3270_cmp_text_at" },
81   - { (void **) &pfkey, (void *) NULL, "lib3270_pfkey" },
82   - { (void **) &pakey, (void *) NULL, "lib3270_pakey" },
  78 + { (void **) &action_enter, (void *) hllapi_pipe_enter, "lib3270_enter" },
  79 + { (void **) &set_text_at, (void *) hllapi_pipe_set_text_at, "lib3270_set_string_at" },
  80 + { (void **) &cmp_text_at, (void *) hllapi_pipe_cmp_text_at, "lib3270_cmp_text_at" },
  81 + { (void **) &pfkey, (void *) hllapi_pipe_pfkey, "lib3270_pfkey" },
  82 + { (void **) &pakey, (void *) hllapi_pipe_pakey, "lib3270_pakey" },
83 83  
84 84 { NULL, NULL }
85 85 };
... ...
src/plugins/remotectl/client.h
... ... @@ -44,15 +44,15 @@
44 44 void hllapi_pipe_release_memory(void *p);
45 45 int hllapi_pipe_connect(void *h, const char *n, int wait);
46 46 void hllapi_pipe_disconnect(void *h);
47   -
48   -/*
49   - int hllapi_pipe_wait_for_ready(void *h, int seconds);
50   - int hllapi_pipe_sleep(void *h, int seconds);
51 47 LIB3270_MESSAGE hllapi_pipe_get_message(void *h);
52   - char * hllapi_pipe_get_text(void *h, int row, int col, int len);
  48 + char * hllapi_pipe_get_text_at(void *h, int row, int col, int len);
53 49 int hllapi_pipe_enter(void *h);
54 50 int hllapi_pipe_set_text_at(void *h, int row, int col, const unsigned char *str);
55 51 int hllapi_pipe_cmp_text_at(void *h, int row, int col, const char *text);
56 52 int hllapi_pipe_pfkey(void *h, int key);
57 53 int hllapi_pipe_pakey(void *h, int key);
  54 +
  55 +/*
  56 + int hllapi_pipe_wait_for_ready(void *h, int seconds);
  57 + int hllapi_pipe_sleep(void *h, int seconds);
58 58 */
... ...
src/plugins/remotectl/packets.h
... ... @@ -31,48 +31,65 @@
31 31  
32 32 struct hllapi_packet_result
33 33 {
34   - int rc;
  34 + int rc;
35 35 };
36 36  
37 37 struct hllapi_packet_query
38 38 {
39   - unsigned char packet_id;
  39 + int packet_id;
40 40 };
41 41  
42 42 struct hllapi_packet_connect
43 43 {
44   - unsigned char packet_id;
  44 + int packet_id;
45 45 unsigned char wait;
46 46 char hostname[1];
47 47 };
48 48  
49 49 struct hllapi_packet_keycode
50 50 {
51   - unsigned char packet_id;
  51 + int packet_id;
52 52 unsigned short keycode;
53 53 };
54 54  
55 55 struct hllapi_packet_cursor
56 56 {
57   - unsigned char packet_id;
  57 + int packet_id;
58 58 unsigned short row;
59 59 unsigned short col;
60 60 };
61 61  
62 62 struct hllapi_packet_text
63 63 {
64   - unsigned char packet_id;
  64 + int packet_id;
65 65 char text[1];
66 66 };
67 67  
  68 +struct hllapi_packet_at
  69 +{
  70 + int packet_id;
  71 + unsigned short row;
  72 + unsigned short col;
  73 + unsigned short len;
  74 +};
68 75  
69 76 struct hllapi_packet_text_at
70 77 {
71   - unsigned char packet_id;
  78 + int packet_id;
72 79 unsigned short row;
73 80 unsigned short col;
74 81 char text[1];
75 82 };
76 83  
  84 +struct hllapi_packet_query_at
  85 +{
  86 + int packet_id;
  87 + unsigned short row;
  88 + unsigned short col;
  89 + unsigned short len;
  90 +};
  91 +
  92 +
  93 +
77 94 #pragma pack()
78 95  
... ...
src/plugins/remotectl/pluginmain.c
... ... @@ -134,13 +134,28 @@
134 134 return FALSE;
135 135 }
136 136  
137   -/*
138   - static void send_message(pipe_source *source, const void *pkt, int sz)
  137 + static void send_text(pipe_source *source, char *text)
139 138 {
140   - WriteFile(qry->hPipe,&data,wrote,&wrote,NULL);
  139 + struct hllapi_packet_text *pkt;
  140 + DWORD szBlock;
141 141  
  142 + if(text)
  143 + {
  144 + szBlock = sizeof(struct hllapi_packet_text)+strlen(text);
  145 + pkt = g_malloc0(szBlock);
  146 + pkt->packet_id = 0;
  147 + strcpy(pkt->text,text);
  148 + lib3270_free(text);
  149 + }
  150 + else
  151 + {
  152 + szBlock = sizeof(struct hllapi_packet_text);
  153 + pkt = g_malloc0(szBlock);
  154 + pkt->packet_id = errno ? errno : -1;
  155 + }
  156 +
  157 + WriteFile(source->hPipe,&pkt,szBlock,&szBlock,NULL);
142 158 }
143   -*/
144 159  
145 160 static void send_result(pipe_source *source, int rc)
146 161 {
... ... @@ -197,6 +212,13 @@
197 212 (unsigned char *) ((struct hllapi_packet_text_at *) source->buffer)->text));
198 213 break;
199 214  
  215 + case HLLAPI_PACKET_GET_TEXT_AT:
  216 + send_text(source,lib3270_get_text_at( lib3270_get_default_session_handle(),
  217 + ((struct hllapi_packet_at *) source->buffer)->row,
  218 + ((struct hllapi_packet_at *) source->buffer)->col,
  219 + ((struct hllapi_packet_at *) source->buffer)->len));
  220 + break;
  221 +
200 222 case HLLAPI_PACKET_CMP_TEXT_AT:
201 223 send_result(source,lib3270_cmp_text_at( lib3270_get_default_session_handle(),
202 224 ((struct hllapi_packet_text_at *) source->buffer)->row,
... ...