Commit 62f1e686f8fd241d6fd68d52df0555f71fba77d2
1 parent
dc87d175
Exists in
master
Iniciando implementação de módulo ooRexx em separado.
Showing
5 changed files
with
1180 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
2 | +<CodeBlocks_project_file> | ||
3 | + <FileVersion major="1" minor="6" /> | ||
4 | + <Project> | ||
5 | + <Option title="ooRexx bindings for pw3270/lib3270" /> | ||
6 | + <Option pch_mode="2" /> | ||
7 | + <Option compiler="gcc" /> | ||
8 | + <Build> | ||
9 | + <Target title="Debug"> | ||
10 | + <Option output=".bin/Debug/rx3270" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" /> | ||
11 | + <Option object_output=".obj/Debug/" /> | ||
12 | + <Option type="3" /> | ||
13 | + <Option compiler="gcc" /> | ||
14 | + <Option createDefFile="1" /> | ||
15 | + <Compiler> | ||
16 | + <Add option="-g" /> | ||
17 | + <Add option="-fPIC" /> | ||
18 | + <Add option="-DDEBUG=1" /> | ||
19 | + </Compiler> | ||
20 | + </Target> | ||
21 | + <Target title="Release"> | ||
22 | + <Option output=".bin/Release/rx3270" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" /> | ||
23 | + <Option object_output=".obj/Release/" /> | ||
24 | + <Option type="3" /> | ||
25 | + <Option compiler="gcc" /> | ||
26 | + <Option createDefFile="1" /> | ||
27 | + <Compiler> | ||
28 | + <Add option="-O2" /> | ||
29 | + <Add option="-DNDEBUG=1" /> | ||
30 | + </Compiler> | ||
31 | + <Linker> | ||
32 | + <Add option="-s" /> | ||
33 | + </Linker> | ||
34 | + </Target> | ||
35 | + </Build> | ||
36 | + <Compiler> | ||
37 | + <Add option="-Wall" /> | ||
38 | + </Compiler> | ||
39 | + <Linker> | ||
40 | + <Add library="pw3270cpp" /> | ||
41 | + </Linker> | ||
42 | + <Unit filename="src/rexx_methods.cc" /> | ||
43 | + <Unit filename="src/rx3270.h" /> | ||
44 | + <Unit filename="src/typed_routines.cc" /> | ||
45 | + <Extensions> | ||
46 | + <code_completion /> | ||
47 | + <envvars /> | ||
48 | + <debugger /> | ||
49 | + <lib_finder disable_auto="1" /> | ||
50 | + </Extensions> | ||
51 | + </Project> | ||
52 | +</CodeBlocks_project_file> |
@@ -0,0 +1,648 @@ | @@ -0,0 +1,648 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | ||
19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como rexx_methods.cc e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
28 | + * | ||
29 | + * Referencias: | ||
30 | + * | ||
31 | + * * http://www.oorexx.org/docs/rexxpg/x2950.htm | ||
32 | + * | ||
33 | + */ | ||
34 | + | ||
35 | + #include "rx3270.h" | ||
36 | + #include <time.h> | ||
37 | + #include <string.h> | ||
38 | + #include <ctype.h> | ||
39 | + | ||
40 | + using namespace std; | ||
41 | + using namespace PW3270_NAMESPACE; | ||
42 | + | ||
43 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
44 | + | ||
45 | +RexxMethod1(int, rx3270_method_init, OPTIONAL_CSTRING, type) | ||
46 | +{ | ||
47 | + // Set session class in rexx object | ||
48 | + try | ||
49 | + { | ||
50 | + if(!(type && *type)) | ||
51 | + type = ""; | ||
52 | + RexxPointerObject sessionPtr = context->NewPointer(session::create(type)); | ||
53 | + context->SetObjectVariable("CSELF", sessionPtr); | ||
54 | + } | ||
55 | + catch(std::exception &e) | ||
56 | + { | ||
57 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
58 | + } | ||
59 | + | ||
60 | + return 0; | ||
61 | +} | ||
62 | + | ||
63 | +RexxMethod1(int, rx3270_method_uninit, CSELF, sessionPtr) | ||
64 | +{ | ||
65 | + session *hSession = (session *) sessionPtr; | ||
66 | + | ||
67 | + trace("rx3270_method_uninit hSession=%p",hSession); | ||
68 | + | ||
69 | + if(hSession) | ||
70 | + delete hSession; | ||
71 | + | ||
72 | + trace("%s","rx3270_method_uninit"); | ||
73 | + return 0; | ||
74 | +} | ||
75 | + | ||
76 | +RexxMethod1(RexxStringObject, rx3270_method_version, CSELF, sessionPtr) | ||
77 | +{ | ||
78 | + session * hSession = (session *) sessionPtr; | ||
79 | + | ||
80 | + if(hSession) | ||
81 | + return context->String((CSTRING) hSession->get_version().c_str()); | ||
82 | + | ||
83 | + return context->String((CSTRING) PACKAGE_VERSION); | ||
84 | +} | ||
85 | + | ||
86 | +RexxMethod1(RexxStringObject, rx3270_method_revision, CSELF, sessionPtr) | ||
87 | +{ | ||
88 | + session * hSession = (session *) sessionPtr; | ||
89 | + | ||
90 | + if(hSession) | ||
91 | + return context->String((CSTRING) hSession->get_revision().c_str()); | ||
92 | + | ||
93 | + return context->String((CSTRING) PACKAGE_REVISION); | ||
94 | +} | ||
95 | + | ||
96 | +RexxMethod3(int, rx3270_method_connect, CSELF, sessionPtr, CSTRING, uri, OPTIONAL_int, wait) | ||
97 | +{ | ||
98 | + session *hSession = (session *) sessionPtr; | ||
99 | + if(!hSession) | ||
100 | + return -1; | ||
101 | + | ||
102 | + return hSession->connect(uri,wait != 0); | ||
103 | +} | ||
104 | + | ||
105 | +RexxMethod1(int, rx3270_method_disconnect, CSELF, sessionPtr) | ||
106 | +{ | ||
107 | + session *hSession = (session *) sessionPtr; | ||
108 | + if(!hSession) | ||
109 | + return -1; | ||
110 | + return hSession->disconnect(); | ||
111 | +} | ||
112 | + | ||
113 | +RexxMethod2(int, rx3270_method_sleep, CSELF, sessionPtr, int, seconds) | ||
114 | +{ | ||
115 | + session *hSession = (session *) sessionPtr; | ||
116 | + if(!hSession) | ||
117 | + return -1; | ||
118 | + return hSession->wait(seconds); | ||
119 | +} | ||
120 | + | ||
121 | +RexxMethod1(logical_t, rx3270_method_is_connected, CSELF, sessionPtr) | ||
122 | +{ | ||
123 | + try | ||
124 | + { | ||
125 | + session *hSession = (session *) sessionPtr; | ||
126 | + if(!hSession) | ||
127 | + return false; | ||
128 | + return hSession->is_connected(); | ||
129 | + } | ||
130 | + catch(std::exception &e) | ||
131 | + { | ||
132 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
133 | + } | ||
134 | + | ||
135 | + return 0; | ||
136 | +} | ||
137 | + | ||
138 | +RexxMethod1(logical_t, rx3270_method_is_ready, CSELF, sessionPtr) | ||
139 | +{ | ||
140 | + session *hSession = (session *) sessionPtr; | ||
141 | + if(!hSession) | ||
142 | + return false; | ||
143 | + return hSession->is_ready(); | ||
144 | +} | ||
145 | + | ||
146 | +RexxMethod2(int, rx3270_method_wait_for_ready, CSELF, sessionPtr, OPTIONAL_int, seconds) | ||
147 | +{ | ||
148 | + session *hSession = (session *) sessionPtr; | ||
149 | + if(!hSession) | ||
150 | + return -1; | ||
151 | + return hSession->wait_for_ready(seconds > 0 ? seconds : 60); | ||
152 | +} | ||
153 | + | ||
154 | +RexxMethod3(int, rx3270_method_set_cursor, CSELF, sessionPtr, int, row, int, col) | ||
155 | +{ | ||
156 | + session *hSession = (session *) sessionPtr; | ||
157 | + if(!hSession) | ||
158 | + return -1; | ||
159 | + return hSession->set_cursor_position(row,col); | ||
160 | +} | ||
161 | + | ||
162 | +RexxMethod1(int, rx3270_method_get_cursor_addr, CSELF, sessionPtr) | ||
163 | +{ | ||
164 | + session *hSession = (session *) sessionPtr; | ||
165 | + if(!hSession) | ||
166 | + return -1; | ||
167 | + return hSession->get_cursor_addr(); | ||
168 | +} | ||
169 | + | ||
170 | +RexxMethod2(int, rx3270_method_set_cursor_addr, CSELF, sessionPtr, int, addr) | ||
171 | +{ | ||
172 | + session *hSession = (session *) sessionPtr; | ||
173 | + if(!hSession) | ||
174 | + return -1; | ||
175 | + return hSession->set_cursor_addr(addr); | ||
176 | +} | ||
177 | + | ||
178 | +RexxMethod1(int, rx3270_method_enter, CSELF, sessionPtr) | ||
179 | +{ | ||
180 | + session *hSession = (session *) sessionPtr; | ||
181 | + if(!hSession) | ||
182 | + return -1; | ||
183 | + return hSession->enter(); | ||
184 | +} | ||
185 | + | ||
186 | +RexxMethod1(int, rx3270_method_erase, CSELF, sessionPtr) | ||
187 | +{ | ||
188 | + session *hSession = (session *) sessionPtr; | ||
189 | + if(!hSession) | ||
190 | + return -1; | ||
191 | + return hSession->erase(); | ||
192 | +} | ||
193 | + | ||
194 | +RexxMethod1(int, rx3270_method_erase_eof, CSELF, sessionPtr) | ||
195 | +{ | ||
196 | + session *hSession = (session *) sessionPtr; | ||
197 | + if(!hSession) | ||
198 | + return -1; | ||
199 | + return hSession->erase_eof(); | ||
200 | +} | ||
201 | + | ||
202 | +RexxMethod1(int, rx3270_method_erase_eol, CSELF, sessionPtr) | ||
203 | +{ | ||
204 | + session *hSession = (session *) sessionPtr; | ||
205 | + if(!hSession) | ||
206 | + return -1; | ||
207 | + return hSession->erase_eol(); | ||
208 | +} | ||
209 | + | ||
210 | +RexxMethod1(int, rx3270_method_erase_input, CSELF, sessionPtr) | ||
211 | +{ | ||
212 | + session *hSession = (session *) sessionPtr; | ||
213 | + if(!hSession) | ||
214 | + return -1; | ||
215 | + return hSession->erase_input(); | ||
216 | +} | ||
217 | + | ||
218 | + | ||
219 | +RexxMethod2(int, rx3270_method_pfkey, CSELF, sessionPtr, int, key) | ||
220 | +{ | ||
221 | + session *hSession = (session *) sessionPtr; | ||
222 | + if(!hSession) | ||
223 | + return -1; | ||
224 | + return hSession->pfkey(key); | ||
225 | +} | ||
226 | + | ||
227 | +RexxMethod2(int, rx3270_method_pakey, CSELF, sessionPtr, int, key) | ||
228 | +{ | ||
229 | + session *hSession = (session *) sessionPtr; | ||
230 | + if(!hSession) | ||
231 | + return -1; | ||
232 | + return hSession->pakey(key); | ||
233 | +} | ||
234 | + | ||
235 | +RexxMethod4(RexxStringObject, rx3270_method_get_text_at, CSELF, sessionPtr, int, row, int, col, int, sz) | ||
236 | +{ | ||
237 | + | ||
238 | + try | ||
239 | + { | ||
240 | + session * hSession = (session *) sessionPtr; | ||
241 | + string str = hSession->get_string_at(row,col,sz); | ||
242 | + return context->String((CSTRING) str.c_str()); | ||
243 | + | ||
244 | + } | ||
245 | + catch(std::exception &e) | ||
246 | + { | ||
247 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
248 | + } | ||
249 | + | ||
250 | + return context->String(""); | ||
251 | +} | ||
252 | + | ||
253 | + | ||
254 | +RexxMethod4(int, rx3270_method_set_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, text) | ||
255 | +{ | ||
256 | + try | ||
257 | + { | ||
258 | + session * hSession = (session *) sessionPtr; | ||
259 | + return hSession->set_string_at(row,col,text); | ||
260 | + } | ||
261 | + catch(std::exception &e) | ||
262 | + { | ||
263 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
264 | + } | ||
265 | + | ||
266 | + return -1; | ||
267 | +} | ||
268 | + | ||
269 | +RexxMethod2(int, rx3270_method_input_text, CSELF, sessionPtr, CSTRING, text) | ||
270 | +{ | ||
271 | + try | ||
272 | + { | ||
273 | + session * hSession = (session *) sessionPtr; | ||
274 | + return hSession->input_string(text); | ||
275 | + } | ||
276 | + catch(std::exception &e) | ||
277 | + { | ||
278 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
279 | + } | ||
280 | + | ||
281 | + return -1; | ||
282 | + | ||
283 | +} | ||
284 | + | ||
285 | +RexxMethod4(int, rx3270_method_cmp_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key) | ||
286 | +{ | ||
287 | + try | ||
288 | + { | ||
289 | + session * hSession = (session *) sessionPtr; | ||
290 | + return hSession->cmp_string_at(row,col,key); | ||
291 | + } | ||
292 | + catch(std::exception &e) | ||
293 | + { | ||
294 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
295 | + } | ||
296 | + return -1; | ||
297 | +} | ||
298 | + | ||
299 | +RexxMethod2(int, rx3270_method_event_trace, CSELF, sessionPtr, int, flag) | ||
300 | +{ | ||
301 | + session *hSession = (session *) sessionPtr; | ||
302 | + if(!hSession) | ||
303 | + return -1; | ||
304 | + hSession->set_toggle(LIB3270_TOGGLE_EVENT_TRACE,flag); | ||
305 | + return 0; | ||
306 | +} | ||
307 | + | ||
308 | +RexxMethod2(int, rx3270_method_screen_trace, CSELF, sessionPtr, int, flag) | ||
309 | +{ | ||
310 | + session *hSession = (session *) sessionPtr; | ||
311 | + if(!hSession) | ||
312 | + return -1; | ||
313 | + hSession->set_toggle(LIB3270_TOGGLE_SCREEN_TRACE,flag); | ||
314 | + return 0; | ||
315 | + | ||
316 | +} | ||
317 | + | ||
318 | +RexxMethod2(int, rx3270_method_ds_trace, CSELF, sessionPtr, int, flag) | ||
319 | +{ | ||
320 | + session *hSession = (session *) sessionPtr; | ||
321 | + if(!hSession) | ||
322 | + return -1; | ||
323 | + hSession->set_toggle(LIB3270_TOGGLE_DS_TRACE,flag); | ||
324 | + return 0; | ||
325 | +} | ||
326 | + | ||
327 | +RexxMethod3(int, rx3270_method_set_option, CSELF, sessionPtr, CSTRING, name, int, flag) | ||
328 | +{ | ||
329 | + static const struct _toggle_info | ||
330 | + { | ||
331 | + const char * name; | ||
332 | + LIB3270_TOGGLE id; | ||
333 | + } | ||
334 | + toggle[LIB3270_TOGGLE_COUNT] = | ||
335 | + { | ||
336 | + { "monocase", LIB3270_TOGGLE_MONOCASE }, | ||
337 | + { "cursorblink", LIB3270_TOGGLE_CURSOR_BLINK }, | ||
338 | + { "showtiming", LIB3270_TOGGLE_SHOW_TIMING }, | ||
339 | + { "cursorpos", LIB3270_TOGGLE_CURSOR_POS }, | ||
340 | + { "dstrace", LIB3270_TOGGLE_DS_TRACE }, | ||
341 | + { "linewrap", LIB3270_TOGGLE_LINE_WRAP }, | ||
342 | + { "blankfill", LIB3270_TOGGLE_BLANK_FILL }, | ||
343 | + { "screentrace", LIB3270_TOGGLE_SCREEN_TRACE }, | ||
344 | + { "eventtrace", LIB3270_TOGGLE_EVENT_TRACE }, | ||
345 | + { "marginedpaste", LIB3270_TOGGLE_MARGINED_PASTE }, | ||
346 | + { "rectselect", LIB3270_TOGGLE_RECTANGLE_SELECT }, | ||
347 | + { "crosshair", LIB3270_TOGGLE_CROSSHAIR }, | ||
348 | + { "fullscreen", LIB3270_TOGGLE_FULL_SCREEN }, | ||
349 | + { "reconnect", LIB3270_TOGGLE_RECONNECT }, | ||
350 | + { "insert", LIB3270_TOGGLE_INSERT }, | ||
351 | + { "smartpaste", LIB3270_TOGGLE_SMART_PASTE }, | ||
352 | + { "bold", LIB3270_TOGGLE_BOLD }, | ||
353 | + { "keepselected", LIB3270_TOGGLE_KEEP_SELECTED }, | ||
354 | + { "underline", LIB3270_TOGGLE_UNDERLINE }, | ||
355 | + { "autoconnect", LIB3270_TOGGLE_CONNECT_ON_STARTUP }, | ||
356 | + { "kpalternative", LIB3270_TOGGLE_KP_ALTERNATIVE }, | ||
357 | + { "beep", LIB3270_TOGGLE_BEEP }, | ||
358 | + { "fieldattr", LIB3270_TOGGLE_VIEW_FIELD }, | ||
359 | + { "altscreen", LIB3270_TOGGLE_ALTSCREEN }, | ||
360 | + { "keepalive", LIB3270_TOGGLE_KEEP_ALIVE }, | ||
361 | + }; | ||
362 | + | ||
363 | + session *hSession = (session *) sessionPtr; | ||
364 | + if(hSession) | ||
365 | + { | ||
366 | + for(int f = 0; f < LIB3270_TOGGLE_COUNT; f++) | ||
367 | + { | ||
368 | + if(!strcasecmp(name,toggle[f].name)) | ||
369 | + { | ||
370 | + hSession->set_toggle(toggle[f].id,flag); | ||
371 | + return 0; | ||
372 | + } | ||
373 | + } | ||
374 | + return ENOENT; | ||
375 | + } | ||
376 | + return -1; | ||
377 | +} | ||
378 | + | ||
379 | + | ||
380 | +RexxMethod4(logical_t, rx3270_method_test, CSELF, sessionPtr, CSTRING, key, int, row, int, col) | ||
381 | +{ | ||
382 | + try | ||
383 | + { | ||
384 | + session * hSession = (session *) sessionPtr; | ||
385 | + | ||
386 | + if(!hSession->is_ready()) | ||
387 | + hSession->iterate(false); | ||
388 | + | ||
389 | + if(hSession->is_ready()) | ||
390 | + { | ||
391 | + string str = hSession->get_string_at(row,col,strlen(key)); | ||
392 | + return (strcasecmp(str.c_str(),key) == 0); | ||
393 | + } | ||
394 | + | ||
395 | + } | ||
396 | + catch(std::exception &e) | ||
397 | + { | ||
398 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
399 | + } | ||
400 | + | ||
401 | + return false; | ||
402 | +} | ||
403 | + | ||
404 | +RexxMethod5(int, rx3270_method_wait_for_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key, int, timeout) | ||
405 | +{ | ||
406 | + try | ||
407 | + { | ||
408 | + session * hSession = (session *) sessionPtr; | ||
409 | + return hSession->wait_for_string_at(row,col,key,timeout); | ||
410 | + | ||
411 | + } | ||
412 | + catch(std::exception &e) | ||
413 | + { | ||
414 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
415 | + } | ||
416 | + | ||
417 | + return -1; | ||
418 | +} | ||
419 | + | ||
420 | +RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONAL_int, baddr, OPTIONAL_int, sz) | ||
421 | +{ | ||
422 | + try | ||
423 | + { | ||
424 | + session * hSession = (session *) sessionPtr; | ||
425 | + string str = hSession->get_string(baddr,sz > 0 ? sz : -1); | ||
426 | + return context->String((CSTRING) str.c_str()); | ||
427 | + } | ||
428 | + catch(std::exception &e) | ||
429 | + { | ||
430 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
431 | + } | ||
432 | + | ||
433 | + return context->String(""); | ||
434 | +} | ||
435 | + | ||
436 | + | ||
437 | +RexxMethod2(int, rx3270_method_get_field_len, CSELF, sessionPtr, OPTIONAL_int, baddr) | ||
438 | +{ | ||
439 | + session *hSession = (session *) sessionPtr; | ||
440 | + if(!hSession) | ||
441 | + return -1; | ||
442 | + return hSession->get_field_len(baddr); | ||
443 | +} | ||
444 | + | ||
445 | +RexxMethod2(int, rx3270_method_get_field_start, CSELF, sessionPtr, OPTIONAL_int, baddr) | ||
446 | +{ | ||
447 | + session *hSession = (session *) sessionPtr; | ||
448 | + if(!hSession) | ||
449 | + return -1; | ||
450 | + return hSession->get_field_start(baddr)+1; | ||
451 | +} | ||
452 | + | ||
453 | +RexxMethod2(int, rx3270_method_get_next_unprotected, CSELF, sessionPtr, OPTIONAL_int, baddr) | ||
454 | +{ | ||
455 | + session *hSession = (session *) sessionPtr; | ||
456 | + if(!hSession) | ||
457 | + return -1; | ||
458 | + | ||
459 | + baddr = hSession->get_next_unprotected(baddr); | ||
460 | + if(baddr < 1) | ||
461 | + return -1; | ||
462 | + | ||
463 | + return baddr; | ||
464 | +} | ||
465 | + | ||
466 | +RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int, baddr) | ||
467 | +{ | ||
468 | + | ||
469 | + session *hSession = (session *) sessionPtr; | ||
470 | + if(!hSession) | ||
471 | + return -1; | ||
472 | + | ||
473 | + return hSession->get_is_protected(baddr); | ||
474 | +} | ||
475 | + | ||
476 | +RexxMethod3(int, rx3270_method_get_is_protected_at, CSELF, sessionPtr, int, row, int, col) | ||
477 | +{ | ||
478 | + | ||
479 | + session *hSession = (session *) sessionPtr; | ||
480 | + if(!hSession) | ||
481 | + return -1; | ||
482 | + | ||
483 | + return hSession->get_is_protected_at(row,col); | ||
484 | +} | ||
485 | + | ||
486 | + | ||
487 | +RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr) | ||
488 | +{ | ||
489 | + try | ||
490 | + { | ||
491 | + string str = ((session *) sessionPtr)->get_copy(); | ||
492 | + return context->String((CSTRING) str.c_str()); | ||
493 | + | ||
494 | + } | ||
495 | + catch(std::exception &e) | ||
496 | + { | ||
497 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
498 | + } | ||
499 | + | ||
500 | + return context->String(""); | ||
501 | +} | ||
502 | + | ||
503 | +RexxMethod2(int, rx3270_method_set_selection, CSELF, sessionPtr, CSTRING, text) | ||
504 | +{ | ||
505 | + try | ||
506 | + { | ||
507 | + return ((session *) sessionPtr)->set_copy(text); | ||
508 | + } | ||
509 | + catch(std::exception &e) | ||
510 | + { | ||
511 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
512 | + } | ||
513 | + | ||
514 | + return -1; | ||
515 | +} | ||
516 | + | ||
517 | +RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr) | ||
518 | +{ | ||
519 | + session * hSession = (session *) sessionPtr; | ||
520 | + | ||
521 | + if(hSession) | ||
522 | + { | ||
523 | + string str = hSession->get_clipboard(); | ||
524 | + return context->String((CSTRING) str.c_str()); | ||
525 | + } | ||
526 | + | ||
527 | + trace("%s","rx3270_method_get_clipboard: Clipboard is empty"); | ||
528 | + return context->String(""); | ||
529 | +} | ||
530 | + | ||
531 | +RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text) | ||
532 | +{ | ||
533 | + return ((session *) sessionPtr)->set_clipboard(text); | ||
534 | +} | ||
535 | + | ||
536 | +RexxMethod5(int, rx3270_method_popup, CSELF, sessionPtr, CSTRING, s_id, CSTRING, title, CSTRING, message, OPTIONAL_CSTRING, det) | ||
537 | +{ | ||
538 | + LIB3270_NOTIFY id = LIB3270_NOTIFY_INFO; | ||
539 | + session * hSession = (session *) sessionPtr; | ||
540 | + | ||
541 | + if(!hSession) | ||
542 | + return -1; | ||
543 | + | ||
544 | + if(*s_id) | ||
545 | + { | ||
546 | + static const struct _descr | ||
547 | + { | ||
548 | + char str; | ||
549 | + LIB3270_NOTIFY id; | ||
550 | + } descr[] = | ||
551 | + { | ||
552 | + { 'I', LIB3270_NOTIFY_INFO }, | ||
553 | + { 'W', LIB3270_NOTIFY_WARNING }, | ||
554 | + { 'E', LIB3270_NOTIFY_ERROR }, | ||
555 | + { 'C', LIB3270_NOTIFY_CRITICAL }, | ||
556 | + }; | ||
557 | + | ||
558 | + for(int f=0;f<4;f++) | ||
559 | + { | ||
560 | + if(toupper(*s_id) == descr[f].str) | ||
561 | + { | ||
562 | + id = descr[f].id; | ||
563 | + trace("Using mode %c (%d)",toupper(*s_id),(int) id); | ||
564 | + } | ||
565 | + } | ||
566 | + } | ||
567 | + | ||
568 | + return hSession->popup_dialog(id, title, message, "%s", det ? det : ""); | ||
569 | +} | ||
570 | + | ||
571 | +RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CSTRING, action_name, CSTRING, title, OPTIONAL_CSTRING, extension, OPTIONAL_CSTRING, filename) | ||
572 | +{ | ||
573 | +/* | ||
574 | + static const struct _action | ||
575 | + { | ||
576 | + const cchar * action_name; | ||
577 | + GtkFileChooserAction id; | ||
578 | + } action[] = | ||
579 | + { | ||
580 | + { "open", GTK_FILE_CHOOSER_ACTION_OPEN }, | ||
581 | + { "save", GTK_FILE_CHOOSER_ACTION_SAVE }, | ||
582 | + { "folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER }, | ||
583 | + { "select_folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER }, | ||
584 | + { "create_folder", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER } | ||
585 | + }; | ||
586 | + | ||
587 | + GtkFileChooserAction id = GTK_FILE_CHOOSER_ACTION_OPEN; | ||
588 | + string ret; | ||
589 | + | ||
590 | + for(int f=0;f<5;f++) | ||
591 | + { | ||
592 | + if(!strcasecmp(action_name,action[f].action_name)) | ||
593 | + { | ||
594 | + id = action[f].id; | ||
595 | + break; | ||
596 | + } | ||
597 | + } | ||
598 | + | ||
599 | + debug("%s(%s)","rx3270_method_get_filename",action_name); | ||
600 | + ret = ((session *) sessionPtr)->file_chooser_dialog(id, title, extension,filename); | ||
601 | + debug("%s(%s)","rx3270_method_get_filename",action_name); | ||
602 | + | ||
603 | + return context->String(ret.c_str()); | ||
604 | +*/ | ||
605 | + return context->String(""); | ||
606 | +} | ||
607 | + | ||
608 | +RexxMethod2(int, rx3270_method_set_host_charset, CSELF, sessionPtr, CSTRING, text) | ||
609 | +{ | ||
610 | + return ((session *) sessionPtr)->set_host_charset(text); | ||
611 | +} | ||
612 | + | ||
613 | +RexxMethod1(RexxStringObject, rx3270_method_get_host_charset, CSELF, sessionPtr) | ||
614 | +{ | ||
615 | + string ret = ((session *) sessionPtr)->get_host_charset(); | ||
616 | + return context->String(ret.c_str()); | ||
617 | +} | ||
618 | + | ||
619 | +RexxMethod1(RexxStringObject, rx3270_method_get_display_charset, CSELF, sessionPtr) | ||
620 | +{ | ||
621 | + string ret = ((session *) sessionPtr)->get_display_charset(); | ||
622 | + return context->String(ret.c_str()); | ||
623 | +} | ||
624 | + | ||
625 | +RexxMethod2(int, rx3270_method_set_display_charset, CSELF, sessionPtr, CSTRING, text) | ||
626 | +{ | ||
627 | + ((session *) sessionPtr)->set_display_charset(NULL,text); | ||
628 | + return 0; | ||
629 | +} | ||
630 | + | ||
631 | +RexxMethod2(int, rx3270_method_set_unlock_delay, CSELF, sessionPtr, int, delay) | ||
632 | +{ | ||
633 | + session *hSession = (session *) sessionPtr; | ||
634 | + | ||
635 | + if(!hSession) | ||
636 | + return -1; | ||
637 | + | ||
638 | + try | ||
639 | + { | ||
640 | + hSession->set_unlock_delay((unsigned short) delay); | ||
641 | + } | ||
642 | + catch(std::exception &e) | ||
643 | + { | ||
644 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
645 | + } | ||
646 | + | ||
647 | + return 0; | ||
648 | +} |
@@ -0,0 +1,136 @@ | @@ -0,0 +1,136 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | ||
19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como pluginmain.c e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
28 | + */ | ||
29 | + | ||
30 | +#ifndef RX3270_H_INCLUDED | ||
31 | + | ||
32 | + #define RX3270_H_INCLUDED 1 | ||
33 | + | ||
34 | + #include <stdint.h> | ||
35 | + #include <errno.h> | ||
36 | + #include <stdio.h> | ||
37 | + #include <stdarg.h> | ||
38 | + #include <pw3270cpp.h> | ||
39 | + #include <oorexxapi.h> | ||
40 | + | ||
41 | +/*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ | ||
42 | + | ||
43 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270version); | ||
44 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270QueryCState); | ||
45 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Disconnect); | ||
46 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Connect); | ||
47 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270isConnected); | ||
48 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForEvents); | ||
49 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Sleep); | ||
50 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendENTERKey); | ||
51 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPFKey); | ||
52 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPAKey); | ||
53 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForTerminalReady); | ||
54 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForStringAt); | ||
55 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270GetStringAt); | ||
56 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsTerminalReady); | ||
57 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt); | ||
58 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt); | ||
59 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270CloseApplication); | ||
60 | + REXX_TYPED_ROUTINE_PROTOTYPE(ebc2asc); | ||
61 | + REXX_TYPED_ROUTINE_PROTOTYPE(asc2ebc); | ||
62 | + | ||
63 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Erase); | ||
64 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOF); | ||
65 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOL); | ||
66 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseInput); | ||
67 | + | ||
68 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtected); | ||
69 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtectedAt); | ||
70 | + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetUnlockDelay); | ||
71 | + | ||
72 | + REXX_METHOD_PROTOTYPE(rx3270_method_version); | ||
73 | + REXX_METHOD_PROTOTYPE(rx3270_method_revision); | ||
74 | + REXX_METHOD_PROTOTYPE(rx3270_method_init); | ||
75 | + REXX_METHOD_PROTOTYPE(rx3270_method_uninit); | ||
76 | + REXX_METHOD_PROTOTYPE(rx3270_method_connect); | ||
77 | + REXX_METHOD_PROTOTYPE(rx3270_method_disconnect); | ||
78 | + REXX_METHOD_PROTOTYPE(rx3270_method_sleep); | ||
79 | + REXX_METHOD_PROTOTYPE(rx3270_method_is_connected); | ||
80 | + REXX_METHOD_PROTOTYPE(rx3270_method_is_ready); | ||
81 | + REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_ready); | ||
82 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor); | ||
83 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); | ||
84 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); | ||
85 | + REXX_METHOD_PROTOTYPE(rx3270_method_enter); | ||
86 | + REXX_METHOD_PROTOTYPE(rx3270_method_erase); | ||
87 | + REXX_METHOD_PROTOTYPE(rx3270_method_erase_eof); | ||
88 | + REXX_METHOD_PROTOTYPE(rx3270_method_erase_eol); | ||
89 | + REXX_METHOD_PROTOTYPE(rx3270_method_erase_input); | ||
90 | + REXX_METHOD_PROTOTYPE(rx3270_method_pfkey); | ||
91 | + REXX_METHOD_PROTOTYPE(rx3270_method_pakey); | ||
92 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_text); | ||
93 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_text_at); | ||
94 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_text_at); | ||
95 | + REXX_METHOD_PROTOTYPE(rx3270_method_cmp_text_at); | ||
96 | + REXX_METHOD_PROTOTYPE(rx3270_method_event_trace); | ||
97 | + REXX_METHOD_PROTOTYPE(rx3270_method_screen_trace); | ||
98 | + REXX_METHOD_PROTOTYPE(rx3270_method_ds_trace); | ||
99 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_option); | ||
100 | + REXX_METHOD_PROTOTYPE(rx3270_method_test); | ||
101 | + REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_text_at); | ||
102 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_field_len); | ||
103 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_field_start); | ||
104 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_next_unprotected); | ||
105 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected); | ||
106 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected_at); | ||
107 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_selection); | ||
108 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); | ||
109 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); | ||
110 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard); | ||
111 | + REXX_METHOD_PROTOTYPE(rx3270_method_popup); | ||
112 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_filename); | ||
113 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); | ||
114 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); | ||
115 | + REXX_METHOD_PROTOTYPE(rx3270_method_input_text); | ||
116 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_display_charset); | ||
117 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_display_charset); | ||
118 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_host_charset); | ||
119 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_host_charset); | ||
120 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_unlock_delay); | ||
121 | + | ||
122 | +/*---[ Globals ]---------------------------------------------------------------------------------------------*/ | ||
123 | + | ||
124 | +/*--[ 3270 Session ]-----------------------------------------------------------------------------------------*/ | ||
125 | + | ||
126 | +#ifdef __cplusplus | ||
127 | + extern "C" { | ||
128 | +#endif | ||
129 | + | ||
130 | + LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option); | ||
131 | + | ||
132 | +#ifdef __cplusplus | ||
133 | + } | ||
134 | +#endif | ||
135 | + | ||
136 | +#endif // RX3270_H_INCLUDED |
@@ -0,0 +1,323 @@ | @@ -0,0 +1,323 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | ||
19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como typed_routines.cc e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
28 | + */ | ||
29 | + | ||
30 | + #include "rx3270.h" | ||
31 | + #include <time.h> | ||
32 | + #include <string.h> | ||
33 | + #include <exception> | ||
34 | + #include <pw3270/class.h> | ||
35 | + | ||
36 | + using namespace std; | ||
37 | + using namespace PW3270_NAMESPACE; | ||
38 | + | ||
39 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
40 | + | ||
41 | +RexxRoutine0(CSTRING, rx3270version) | ||
42 | +{ | ||
43 | + try | ||
44 | + { | ||
45 | + return session::get_default()->get_version().c_str(); | ||
46 | + } | ||
47 | + catch(std::exception& e) | ||
48 | + { | ||
49 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
50 | + } | ||
51 | + | ||
52 | + return NULL; | ||
53 | +} | ||
54 | + | ||
55 | +RexxRoutine0(CSTRING, rx3270QueryCState) | ||
56 | +{ | ||
57 | + #define DECLARE_XLAT_STATE( x ) { x, #x } | ||
58 | + | ||
59 | + static const struct _xlat_state | ||
60 | + { | ||
61 | + LIB3270_CSTATE state; | ||
62 | + const char * ret; | ||
63 | + } xlat_state[] = | ||
64 | + { | ||
65 | + { LIB3270_NOT_CONNECTED, "NOT_CONNECTED" }, | ||
66 | + { LIB3270_RESOLVING, "RESOLVING" }, | ||
67 | + { LIB3270_PENDING, "PENDING" }, | ||
68 | + { LIB3270_CONNECTED_INITIAL, "CONNECTED_INITIAL" }, | ||
69 | + { LIB3270_CONNECTED_ANSI, "CONNECTED_ANSI" }, | ||
70 | + { LIB3270_CONNECTED_3270, "CONNECTED_3270" }, | ||
71 | + { LIB3270_CONNECTED_INITIAL_E, "CONNECTED_INITIAL_E" }, | ||
72 | + { LIB3270_CONNECTED_NVT, "CONNECTED_NVT" }, | ||
73 | + { LIB3270_CONNECTED_SSCP, "CONNECTED_SSCP" }, | ||
74 | + { LIB3270_CONNECTED_TN3270E, "CONNECTED_TN3270E" }, | ||
75 | + }; | ||
76 | + | ||
77 | + size_t f; | ||
78 | + LIB3270_CSTATE state = session::get_default()->get_cstate(); | ||
79 | + | ||
80 | + for(f=0;f < (sizeof(xlat_state)/sizeof(struct _xlat_state)); f++) | ||
81 | + { | ||
82 | + if(state == xlat_state[f].state) | ||
83 | + return xlat_state[f].ret; | ||
84 | + } | ||
85 | + | ||
86 | + return "UNEXPECTED"; | ||
87 | +} | ||
88 | + | ||
89 | +RexxRoutine0(int, rx3270Disconnect) | ||
90 | +{ | ||
91 | + return session::get_default()->disconnect(); | ||
92 | +} | ||
93 | + | ||
94 | +RexxRoutine2(int, rx3270Connect, CSTRING, hostname, int, wait) | ||
95 | +{ | ||
96 | + return session::get_default()->connect(hostname,wait); | ||
97 | +} | ||
98 | + | ||
99 | +RexxRoutine0(int, rx3270isConnected) | ||
100 | +{ | ||
101 | + return session::get_default()->is_connected(); | ||
102 | +} | ||
103 | + | ||
104 | +RexxRoutine0(int, rx3270WaitForEvents) | ||
105 | +{ | ||
106 | + return session::get_default()->iterate(); | ||
107 | +} | ||
108 | + | ||
109 | +RexxRoutine1(int, rx3270Sleep, int, seconds) | ||
110 | +{ | ||
111 | + return session::get_default()->wait(seconds); | ||
112 | +} | ||
113 | + | ||
114 | +RexxRoutine0(int, rx3270SendENTERKey) | ||
115 | +{ | ||
116 | + return session::get_default()->enter(); | ||
117 | +} | ||
118 | + | ||
119 | +RexxRoutine0(int, rx3270Erase) | ||
120 | +{ | ||
121 | + return session::get_default()->erase(); | ||
122 | +} | ||
123 | + | ||
124 | +RexxRoutine0(int, rx3270EraseEOF) | ||
125 | +{ | ||
126 | + return session::get_default()->erase_eof(); | ||
127 | +} | ||
128 | + | ||
129 | +RexxRoutine0(int, rx3270EraseEOL) | ||
130 | +{ | ||
131 | + return session::get_default()->erase_eol(); | ||
132 | +} | ||
133 | + | ||
134 | +RexxRoutine0(int, rx3270EraseInput) | ||
135 | +{ | ||
136 | + return session::get_default()->erase_input(); | ||
137 | +} | ||
138 | + | ||
139 | +RexxRoutine1(int, rx3270SendPFKey, int, key) | ||
140 | +{ | ||
141 | + return session::get_default()->pfkey(key); | ||
142 | +} | ||
143 | + | ||
144 | +RexxRoutine1(int, rx3270SendPAKey, int, key) | ||
145 | +{ | ||
146 | + return session::get_default()->pakey(key); | ||
147 | +} | ||
148 | + | ||
149 | +RexxRoutine1(int, rx3270WaitForTerminalReady, int, seconds) | ||
150 | +{ | ||
151 | + return session::get_default()->wait_for_ready(seconds); | ||
152 | +} | ||
153 | + | ||
154 | +RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int, timeout) | ||
155 | +{ | ||
156 | + try | ||
157 | + { | ||
158 | + return session::get_default()->wait_for_string_at(row,col,key,timeout); | ||
159 | + } | ||
160 | + catch(std::exception &e) | ||
161 | + { | ||
162 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
163 | + } | ||
164 | + | ||
165 | + return ETIMEDOUT; | ||
166 | + | ||
167 | +} | ||
168 | + | ||
169 | +RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz) | ||
170 | +{ | ||
171 | + try | ||
172 | + { | ||
173 | + string str = session::get_default()->get_string_at(row,col,(int) sz); | ||
174 | + return context->String((CSTRING) str.c_str()); | ||
175 | + } | ||
176 | + catch(std::exception &e) | ||
177 | + { | ||
178 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
179 | + } | ||
180 | + | ||
181 | + return context->String(""); | ||
182 | +} | ||
183 | + | ||
184 | +RexxRoutine0(int, rx3270IsTerminalReady) | ||
185 | +{ | ||
186 | + return session::get_default()->is_ready(); | ||
187 | +} | ||
188 | + | ||
189 | +RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key) | ||
190 | +{ | ||
191 | + try | ||
192 | + { | ||
193 | + return session::get_default()->cmp_string_at(row,col,key); | ||
194 | + } | ||
195 | + catch(std::exception &e) | ||
196 | + { | ||
197 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
198 | + } | ||
199 | + | ||
200 | + return -1; | ||
201 | +} | ||
202 | + | ||
203 | +RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col) | ||
204 | +{ | ||
205 | + try | ||
206 | + { | ||
207 | + return session::get_default()->set_cursor_position(row,col); | ||
208 | + } | ||
209 | + catch(std::exception &e) | ||
210 | + { | ||
211 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
212 | + } | ||
213 | + | ||
214 | + return -1; | ||
215 | +} | ||
216 | + | ||
217 | +RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text) | ||
218 | +{ | ||
219 | + try | ||
220 | + { | ||
221 | + return session::get_default()->set_string_at(row,col,text); | ||
222 | + } | ||
223 | + catch(std::exception &e) | ||
224 | + { | ||
225 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
226 | + } | ||
227 | + return -1; | ||
228 | +} | ||
229 | + | ||
230 | +RexxRoutine0(int, rx3270CloseApplication) | ||
231 | +{ | ||
232 | + return session::get_default()->quit(); | ||
233 | +} | ||
234 | + | ||
235 | + | ||
236 | +RexxRoutine2(RexxStringObject, asc2ebc, CSTRING, str, OPTIONAL_int, sz) | ||
237 | +{ | ||
238 | + try | ||
239 | + { | ||
240 | + if(sz < 1) | ||
241 | + sz = strlen(str); | ||
242 | + | ||
243 | + if(sz) | ||
244 | + { | ||
245 | + char buffer[sz+1]; | ||
246 | + memcpy(buffer,str,sz); | ||
247 | + buffer[sz] = 0; | ||
248 | + return context->String((CSTRING) session::get_default()->asc2ebc((unsigned char *)buffer,sz)); | ||
249 | + } | ||
250 | + } | ||
251 | + catch(std::exception &e) | ||
252 | + { | ||
253 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
254 | + } | ||
255 | + | ||
256 | + return context->String(""); | ||
257 | +} | ||
258 | + | ||
259 | +RexxRoutine2(RexxStringObject, ebc2asc, CSTRING, str, OPTIONAL_int, sz) | ||
260 | +{ | ||
261 | + try | ||
262 | + { | ||
263 | + if(sz < 1) | ||
264 | + sz = strlen(str); | ||
265 | + | ||
266 | + if(sz) | ||
267 | + { | ||
268 | + char buffer[sz+1]; | ||
269 | + memcpy(buffer,str,sz); | ||
270 | + buffer[sz] = 0; | ||
271 | + return context->String((CSTRING) session::get_default()->ebc2asc((unsigned char *)buffer,sz)); | ||
272 | + } | ||
273 | + } | ||
274 | + catch(std::exception &e) | ||
275 | + { | ||
276 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
277 | + } | ||
278 | + | ||
279 | + return context->String(""); | ||
280 | +} | ||
281 | + | ||
282 | +RexxRoutine1(int, rx3270IsProtected, int, baddr) | ||
283 | +{ | ||
284 | + try | ||
285 | + { | ||
286 | + return session::get_default()->get_is_protected(baddr); | ||
287 | + } | ||
288 | + catch(std::exception &e) | ||
289 | + { | ||
290 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
291 | + } | ||
292 | + | ||
293 | + return -1; | ||
294 | +} | ||
295 | + | ||
296 | +RexxRoutine2(int, rx3270IsProtectedAt, int, row, int, col) | ||
297 | +{ | ||
298 | + try | ||
299 | + { | ||
300 | + return session::get_default()->get_is_protected_at(row,col); | ||
301 | + } | ||
302 | + catch(std::exception &e) | ||
303 | + { | ||
304 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
305 | + } | ||
306 | + | ||
307 | + return -1; | ||
308 | +} | ||
309 | + | ||
310 | +RexxRoutine1(int, rx3270SetUnlockDelay, int, delay) | ||
311 | +{ | ||
312 | + try | ||
313 | + { | ||
314 | + session::get_default()->set_unlock_delay((unsigned short) delay); | ||
315 | + } | ||
316 | + catch(std::exception &e) | ||
317 | + { | ||
318 | + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); | ||
319 | + } | ||
320 | + | ||
321 | + return 0; | ||
322 | +} | ||
323 | + |