Commit a6b9c37eeff0ed181dfeb9be2a90de3b690f6c71

Authored by Perry Werneck
1 parent 444b8b50
Exists in master

Implementando plugin ooRexx.

pw3270-rexx.cbp
... ... @@ -36,16 +36,16 @@
36 36 <Compiler>
37 37 <Add option="-Wall" />
38 38 <Add option="`pkg-config --cflags gtk+-3.0`" />
  39 + <Add directory="src/include" />
39 40 </Compiler>
40 41 <Linker>
41 42 <Add option="`pkg-config --libs gtk+-3.0`" />
42 43 <Add library="pw3270cpp" />
43 44 </Linker>
44   - <Unit filename="src/plugin.cc" />
45   - <Unit filename="src/private.h" />
46   - <Unit filename="src/rexx_methods.cc" />
47   - <Unit filename="src/rx3270.cc" />
48   - <Unit filename="src/typed_routines.cc" />
  45 + <Unit filename="src/extension/rexx_methods.cc" />
  46 + <Unit filename="src/extension/rx3270.cc" />
  47 + <Unit filename="src/extension/typed_routines.cc" />
  48 + <Unit filename="src/include/rx3270.h" />
49 49 <Extensions>
50 50 <code_completion />
51 51 <envvars />
... ...
src/extension/rexx_methods.cc 0 → 100644
... ... @@ -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 +}
... ...
src/extension/rx3270.cc 0 → 100644
... ... @@ -0,0 +1,200 @@
  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 rx3270.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 + /*
  31 + *
  32 + * Reference:
  33 + *
  34 + * http://www.oorexx.org/docs/rexxpg/x2950.htm
  35 + *
  36 + */
  37 +
  38 + #include <rx3270.h>
  39 +
  40 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  41 +
  42 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  43 +
  44 +// now build the actual entry list
  45 +RexxRoutineEntry rx3270_functions[] =
  46 +{
  47 + REXX_TYPED_ROUTINE(rx3270version, rx3270version),
  48 + REXX_TYPED_ROUTINE(rx3270QueryCState, rx3270QueryCState),
  49 + REXX_TYPED_ROUTINE(rx3270Disconnect, rx3270Disconnect),
  50 + REXX_TYPED_ROUTINE(rx3270Connect, rx3270Connect),
  51 + REXX_TYPED_ROUTINE(rx3270isConnected, rx3270isConnected),
  52 + REXX_TYPED_ROUTINE(rx3270WaitForEvents, rx3270WaitForEvents),
  53 + REXX_TYPED_ROUTINE(rx3270Sleep, rx3270Sleep),
  54 + REXX_TYPED_ROUTINE(rx3270SendENTERKey, rx3270SendENTERKey),
  55 + REXX_TYPED_ROUTINE(rx3270SendPFKey, rx3270SendPFKey),
  56 + REXX_TYPED_ROUTINE(rx3270SendPAKey, rx3270SendPAKey),
  57 + REXX_TYPED_ROUTINE(rx3270WaitForTerminalReady, rx3270WaitForTerminalReady),
  58 + REXX_TYPED_ROUTINE(rx3270WaitForStringAt, rx3270WaitForStringAt),
  59 + REXX_TYPED_ROUTINE(rx3270GetStringAt, rx3270GetStringAt),
  60 + REXX_TYPED_ROUTINE(rx3270IsTerminalReady, rx3270IsTerminalReady),
  61 + REXX_TYPED_ROUTINE(rx3270queryStringAt, rx3270queryStringAt),
  62 + REXX_TYPED_ROUTINE(rx3270SetStringAt, rx3270SetStringAt),
  63 + REXX_TYPED_ROUTINE(rx3270CloseApplication, rx3270CloseApplication),
  64 +
  65 + REXX_TYPED_ROUTINE(rx3270Erase, rx3270Erase),
  66 + REXX_TYPED_ROUTINE(rx3270EraseEOF, rx3270EraseEOF),
  67 + REXX_TYPED_ROUTINE(rx3270EraseEOL, rx3270EraseEOL),
  68 + REXX_TYPED_ROUTINE(rx3270EraseInput, rx3270EraseInput),
  69 +
  70 + REXX_TYPED_ROUTINE(rx3270IsProtected, rx3270IsProtected),
  71 + REXX_TYPED_ROUTINE(rx3270IsProtectedAt, rx3270IsProtectedAt),
  72 + REXX_TYPED_ROUTINE(rx3270SetUnlockDelay, rx3270SetUnlockDelay),
  73 +
  74 + REXX_TYPED_ROUTINE(ebc2asc, ebc2asc),
  75 + REXX_TYPED_ROUTINE(asc2ebc, asc2ebc),
  76 +
  77 +
  78 + // rx3270Popup
  79 + REXX_LAST_METHOD()
  80 +};
  81 +
  82 +RexxMethodEntry rx3270_methods[] =
  83 +{
  84 + REXX_METHOD(rx3270_method_version, rx3270_method_version ),
  85 + REXX_METHOD(rx3270_method_revision, rx3270_method_revision ),
  86 + REXX_METHOD(rx3270_method_init, rx3270_method_init ),
  87 + REXX_METHOD(rx3270_method_uninit, rx3270_method_uninit ),
  88 + REXX_METHOD(rx3270_method_connect, rx3270_method_connect ),
  89 + REXX_METHOD(rx3270_method_disconnect, rx3270_method_disconnect ),
  90 + REXX_METHOD(rx3270_method_sleep, rx3270_method_sleep ),
  91 + REXX_METHOD(rx3270_method_is_connected, rx3270_method_is_connected ),
  92 + REXX_METHOD(rx3270_method_is_ready, rx3270_method_is_ready ),
  93 + REXX_METHOD(rx3270_method_wait_for_ready, rx3270_method_wait_for_ready ),
  94 + REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor ),
  95 + REXX_METHOD(rx3270_method_set_cursor, rx3270_method_get_cursor_addr ),
  96 + REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor_addr ),
  97 + REXX_METHOD(rx3270_method_enter, rx3270_method_enter ),
  98 + REXX_METHOD(rx3270_method_enter, rx3270_method_erase ),
  99 + REXX_METHOD(rx3270_method_enter, rx3270_method_erase_eof ),
  100 + REXX_METHOD(rx3270_method_enter, rx3270_method_erase_eol ),
  101 + REXX_METHOD(rx3270_method_enter, rx3270_method_erase_input ),
  102 + REXX_METHOD(rx3270_method_pfkey, rx3270_method_pfkey ),
  103 + REXX_METHOD(rx3270_method_pakey, rx3270_method_pakey ),
  104 + REXX_METHOD(rx3270_method_get_text, rx3270_method_get_text ),
  105 + REXX_METHOD(rx3270_method_get_text_at, rx3270_method_get_text_at ),
  106 + REXX_METHOD(rx3270_method_set_text_at, rx3270_method_set_text_at ),
  107 + REXX_METHOD(rx3270_method_cmp_text_at, rx3270_method_cmp_text_at ),
  108 + REXX_METHOD(rx3270_method_event_trace, rx3270_method_event_trace ),
  109 + REXX_METHOD(rx3270_method_screen_trace, rx3270_method_screen_trace ),
  110 + REXX_METHOD(rx3270_method_ds_trace, rx3270_method_ds_trace ),
  111 + REXX_METHOD(rx3270_method_set_option, rx3270_method_set_option ),
  112 + REXX_METHOD(rx3270_method_test, rx3270_method_test ),
  113 + REXX_METHOD(rx3270_method_wait_for_text_at, rx3270_method_wait_for_text_at ),
  114 +
  115 + REXX_METHOD(rx3270_method_get_field_len, rx3270_method_get_field_len ),
  116 + REXX_METHOD(rx3270_method_get_field_start, rx3270_method_get_field_start ),
  117 + REXX_METHOD(rx3270_method_get_next_unprotected, rx3270_method_get_next_unprotected ),
  118 +
  119 + REXX_METHOD(rx3270_method_get_is_protected, rx3270_method_get_is_protected ),
  120 + REXX_METHOD(rx3270_method_get_is_protected_at, rx3270_method_get_is_protected_at ),
  121 +
  122 + REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ),
  123 + REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ),
  124 + REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ),
  125 + REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ),
  126 +
  127 + REXX_METHOD(rx3270_method_erase, rx3270_method_erase ),
  128 + REXX_METHOD(rx3270_method_erase_eof, rx3270_method_erase_eof ),
  129 + REXX_METHOD(rx3270_method_erase_eol, rx3270_method_erase_eol ),
  130 + REXX_METHOD(rx3270_method_erase_input, rx3270_method_erase_input ),
  131 +
  132 + REXX_METHOD(rx3270_method_popup, rx3270_method_popup ),
  133 + REXX_METHOD(rx3270_method_get_filename, rx3270_method_get_filename ),
  134 +
  135 + REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ),
  136 + REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ),
  137 + REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ),
  138 +
  139 + REXX_METHOD(rx3270_method_get_display_charset, rx3270_method_get_display_charset ),
  140 + REXX_METHOD(rx3270_method_set_display_charset, rx3270_method_set_display_charset ),
  141 +
  142 + REXX_METHOD(rx3270_method_get_host_charset, rx3270_method_get_host_charset ),
  143 + REXX_METHOD(rx3270_method_set_host_charset, rx3270_method_set_host_charset ),
  144 +
  145 + REXX_METHOD(rx3270_method_set_unlock_delay, rx3270_method_set_unlock_delay ),
  146 +
  147 + REXX_LAST_METHOD()
  148 +};
  149 +
  150 +RexxPackageEntry rx3270_package_entry =
  151 +{
  152 + STANDARD_PACKAGE_HEADER
  153 + REXX_CURRENT_INTERPRETER_VERSION, // anything after 4.0.0 will work
  154 + "rx3270", // name of the package
  155 + PACKAGE_VERSION, // package information
  156 + NULL, // no load/unload functions
  157 + NULL,
  158 + rx3270_functions, // the exported functions
  159 + rx3270_methods // no methods in rx3270.
  160 +};
  161 +
  162 +// package loading stub.
  163 +/*
  164 +OOREXX_GET_PACKAGE(rx3270);
  165 +*/
  166 +
  167 +static H3270 * default_session = NULL;
  168 +
  169 +static PW3270_NAMESPACE::session * factory(const char *name) {
  170 +
  171 + if(!default_session)
  172 + return PW3270_NAMESPACE::session::create_local();
  173 +
  174 + return PW3270_NAMESPACE::session::create_local(default_session);
  175 +}
  176 +
  177 +BEGIN_EXTERN_C()
  178 +
  179 +LIB3270_EXPORT void rx3270_set_session(H3270 *session) {
  180 + default_session = session;
  181 + PW3270_NAMESPACE::session::set_plugin(factory);
  182 +}
  183 +
  184 +LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option)
  185 +{
  186 + static const RexxLibraryPackage package = { "rx3270", &rx3270_package_entry };
  187 +
  188 + option->optionName = REGISTER_LIBRARY;
  189 + option->option = (void *) &package;
  190 +
  191 +}
  192 +
  193 +LIB3270_EXPORT RexxPackageEntry * RexxEntry RexxGetPackage(void)
  194 +{
  195 + return &rx3270_package_entry;
  196 +}
  197 +
  198 +END_EXTERN_C()
  199 +
  200 +
... ...
src/extension/typed_routines.cc 0 → 100644
... ... @@ -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 +
... ...
src/include/rx3270.h 0 → 100644
... ... @@ -0,0 +1,142 @@
  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 private.h 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 + #define ENABLE_NLS
  35 + #define GETTEXT_PACKAGE "pw3270"
  36 +
  37 + #include <libintl.h>
  38 + #include <glib/gi18n.h>
  39 + #include <gtk/gtk.h>
  40 +
  41 + #include <stdint.h>
  42 + #include <errno.h>
  43 + #include <stdio.h>
  44 + #include <stdarg.h>
  45 + #include <pw3270cpp.h>
  46 + #include <oorexxapi.h>
  47 +
  48 +/*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/
  49 +
  50 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270version);
  51 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270QueryCState);
  52 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Disconnect);
  53 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Connect);
  54 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270isConnected);
  55 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForEvents);
  56 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Sleep);
  57 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendENTERKey);
  58 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPFKey);
  59 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPAKey);
  60 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForTerminalReady);
  61 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForStringAt);
  62 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270GetStringAt);
  63 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsTerminalReady);
  64 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt);
  65 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt);
  66 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270CloseApplication);
  67 + REXX_TYPED_ROUTINE_PROTOTYPE(ebc2asc);
  68 + REXX_TYPED_ROUTINE_PROTOTYPE(asc2ebc);
  69 +
  70 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Erase);
  71 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOF);
  72 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOL);
  73 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseInput);
  74 +
  75 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtected);
  76 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtectedAt);
  77 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetUnlockDelay);
  78 +
  79 + REXX_METHOD_PROTOTYPE(rx3270_method_version);
  80 + REXX_METHOD_PROTOTYPE(rx3270_method_revision);
  81 + REXX_METHOD_PROTOTYPE(rx3270_method_init);
  82 + REXX_METHOD_PROTOTYPE(rx3270_method_uninit);
  83 + REXX_METHOD_PROTOTYPE(rx3270_method_connect);
  84 + REXX_METHOD_PROTOTYPE(rx3270_method_disconnect);
  85 + REXX_METHOD_PROTOTYPE(rx3270_method_sleep);
  86 + REXX_METHOD_PROTOTYPE(rx3270_method_is_connected);
  87 + REXX_METHOD_PROTOTYPE(rx3270_method_is_ready);
  88 + REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_ready);
  89 + REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor);
  90 + REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
  91 + REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
  92 + REXX_METHOD_PROTOTYPE(rx3270_method_enter);
  93 + REXX_METHOD_PROTOTYPE(rx3270_method_erase);
  94 + REXX_METHOD_PROTOTYPE(rx3270_method_erase_eof);
  95 + REXX_METHOD_PROTOTYPE(rx3270_method_erase_eol);
  96 + REXX_METHOD_PROTOTYPE(rx3270_method_erase_input);
  97 + REXX_METHOD_PROTOTYPE(rx3270_method_pfkey);
  98 + REXX_METHOD_PROTOTYPE(rx3270_method_pakey);
  99 + REXX_METHOD_PROTOTYPE(rx3270_method_get_text);
  100 + REXX_METHOD_PROTOTYPE(rx3270_method_get_text_at);
  101 + REXX_METHOD_PROTOTYPE(rx3270_method_set_text_at);
  102 + REXX_METHOD_PROTOTYPE(rx3270_method_cmp_text_at);
  103 + REXX_METHOD_PROTOTYPE(rx3270_method_event_trace);
  104 + REXX_METHOD_PROTOTYPE(rx3270_method_screen_trace);
  105 + REXX_METHOD_PROTOTYPE(rx3270_method_ds_trace);
  106 + REXX_METHOD_PROTOTYPE(rx3270_method_set_option);
  107 + REXX_METHOD_PROTOTYPE(rx3270_method_test);
  108 + REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_text_at);
  109 + REXX_METHOD_PROTOTYPE(rx3270_method_get_field_len);
  110 + REXX_METHOD_PROTOTYPE(rx3270_method_get_field_start);
  111 + REXX_METHOD_PROTOTYPE(rx3270_method_get_next_unprotected);
  112 + REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected);
  113 + REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected_at);
  114 + REXX_METHOD_PROTOTYPE(rx3270_method_get_selection);
  115 + REXX_METHOD_PROTOTYPE(rx3270_method_set_selection);
  116 + REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard);
  117 + REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard);
  118 + REXX_METHOD_PROTOTYPE(rx3270_method_popup);
  119 + REXX_METHOD_PROTOTYPE(rx3270_method_get_filename);
  120 + REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
  121 + REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
  122 + REXX_METHOD_PROTOTYPE(rx3270_method_input_text);
  123 + REXX_METHOD_PROTOTYPE(rx3270_method_get_display_charset);
  124 + REXX_METHOD_PROTOTYPE(rx3270_method_set_display_charset);
  125 + REXX_METHOD_PROTOTYPE(rx3270_method_get_host_charset);
  126 + REXX_METHOD_PROTOTYPE(rx3270_method_set_host_charset);
  127 + REXX_METHOD_PROTOTYPE(rx3270_method_set_unlock_delay);
  128 +
  129 +/*--[ 3270 Session ]-----------------------------------------------------------------------------------------*/
  130 +
  131 +#ifdef __cplusplus
  132 + extern "C" {
  133 +#endif
  134 +
  135 + LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option);
  136 + LIB3270_EXPORT void rx3270_set_session(H3270 *session);
  137 +
  138 +#ifdef __cplusplus
  139 + }
  140 +#endif
  141 +
  142 +#endif // RX3270_H_INCLUDED
... ...
src/plugin.cc
... ... @@ -1,42 +0,0 @@
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 "private.h"
36   -
37   -
38   -/*---[ Implement ]----------------------------------------------------------------------------------*/
39   -
40   -
41   -
42   -
src/plugin/plugin.cc 0 → 100644
... ... @@ -0,0 +1,395 @@
  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 "private.h"
  36 + #include <pw3270/plugin.h>
  37 + #include <pw3270/trace.h>
  38 + #include <lib3270/log.h>
  39 +
  40 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  41 +
  42 +#if GTK_CHECK_VERSION(2,32,0)
  43 + static GMutex mutex;
  44 +#else
  45 + static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
  46 +#endif // GTK_CHECK_VERSION
  47 +
  48 + static gchar * script_name = NULL;
  49 +
  50 +/*--[ Rexx application data block ]--------------------------------------------------------------------------*/
  51 +
  52 + struct rexx_application_data {
  53 + GtkAction * action;
  54 + GtkWidget * widget;
  55 + GtkWidget * trace;
  56 + const gchar * filename;
  57 + };
  58 +
  59 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  60 +
  61 + static void trace_cleanup(GtkWidget *widget, gpointer dunno) {
  62 +
  63 + rexx_application_data *data = (rexx_application_data *) g_object_get_data(G_OBJECT(widget),"rexx_app_data");
  64 +
  65 + trace("%s: data=%p",__FUNCTION__,data);
  66 +
  67 + if(data)
  68 + data->trace = NULL;
  69 +
  70 + }
  71 +
  72 + static GtkWidget * get_trace_window(rexx_application_data *data) {
  73 +
  74 + if(data->trace)
  75 + return data->trace;
  76 +
  77 + data->trace = pw3270_trace_new();
  78 + g_signal_connect(G_OBJECT(data->trace), "destroy",G_CALLBACK(trace_cleanup), NULL);
  79 +
  80 + pw3270_trace_set_destroy_on_close(data->trace,TRUE);
  81 +
  82 + g_object_set_data(G_OBJECT(data->trace),"rexx_app_data",data);
  83 +
  84 + gtk_window_set_title(GTK_WINDOW(data->trace),_("Rexx trace"));
  85 +
  86 + gtk_window_set_transient_for(GTK_WINDOW(data->trace),GTK_WINDOW(gtk_widget_get_toplevel(data->widget)));
  87 + gtk_window_set_destroy_with_parent(GTK_WINDOW(data->trace),TRUE);
  88 +
  89 +
  90 + gtk_window_set_default_size(GTK_WINDOW(data->trace),590,430);
  91 + gtk_widget_show_all(data->trace);
  92 + return data->trace;
  93 + }
  94 +
  95 + static void read_line(struct rexx_application_data *data, PRXSTRING Retstr) {
  96 +
  97 + gchar *value = pw3270_trace_get_command(get_trace_window(data));
  98 +
  99 + if(value) {
  100 +
  101 + if(strlen(value) > (RXAUTOBUFLEN-1))
  102 + {
  103 + Retstr->strptr = (char *) RexxAllocateMemory(strlen(value)+1);
  104 + strcpy(Retstr->strptr,value);
  105 + }
  106 + else
  107 + {
  108 + g_snprintf(Retstr->strptr,RXAUTOBUFLEN-1,"%s",value);
  109 + }
  110 + g_free(value);
  111 +
  112 + } else {
  113 +
  114 + *Retstr->strptr = 0;
  115 +
  116 + }
  117 +
  118 + Retstr->strlength = strlen(Retstr->strptr);
  119 +
  120 + }
  121 +
  122 + static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) {
  123 +
  124 +// trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction);
  125 +
  126 + switch(subfunction)
  127 + {
  128 + case RXSIOSAY: // SAY a line to STDOUT
  129 + {
  130 + struct rexx_application_data *data = (struct rexx_application_data *) context->GetApplicationData();
  131 +
  132 + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(data->widget)),
  133 + GTK_DIALOG_DESTROY_WITH_PARENT,
  134 + GTK_MESSAGE_INFO,
  135 + GTK_BUTTONS_OK_CANCEL,
  136 + "%s", (((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr );
  137 +
  138 + gtk_window_set_title(GTK_WINDOW(dialog), _( "Script message" ) );
  139 +
  140 + if(data->trace)
  141 + pw3270_trace_printf(data->trace,"%s\n",(((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr);
  142 +
  143 + if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL)
  144 + context->RaiseException0(Rexx_Error_Program_interrupted);
  145 +
  146 + gtk_widget_destroy(dialog);
  147 + }
  148 + break;
  149 +
  150 + case RXSIOTRC: // Trace output
  151 + {
  152 + struct rexx_application_data *data = (struct rexx_application_data *) context->GetApplicationData();
  153 + lib3270_write_log(NULL, "rx3270", "%s", (((RXSIOTRC_PARM *) parmBlock)->rxsio_string).strptr);
  154 + pw3270_trace_printf(get_trace_window(data),"%s\n",(((RXSIOTRC_PARM *) parmBlock)->rxsio_string).strptr);
  155 + }
  156 + break;
  157 +
  158 + case RXSIOTRD: // Read from char stream
  159 + read_line((struct rexx_application_data *) context->GetApplicationData(), & (((RXSIODTR_PARM *) parmBlock)->rxsiodtr_retc) );
  160 + break;
  161 +
  162 + case RXSIODTR: // DEBUG read from char stream
  163 + read_line((struct rexx_application_data *) context->GetApplicationData(), & (((RXSIODTR_PARM *) parmBlock)->rxsiodtr_retc) );
  164 + break;
  165 +
  166 + default:
  167 + return RXEXIT_NOT_HANDLED;
  168 +
  169 + }
  170 +
  171 + return RXEXIT_HANDLED;
  172 + }
  173 +
  174 + static void call_rexx_script(GtkAction *action, GtkWidget *widget, const gchar *filename) {
  175 +
  176 + const gchar * args = (const gchar *) g_object_get_data(G_OBJECT(action),"args");
  177 +
  178 + struct rexx_application_data appdata;
  179 +
  180 + RexxInstance * instance;
  181 + RexxThreadContext * threadContext;
  182 + RexxOption options[25];
  183 + RexxContextExit exits[2];
  184 +
  185 + memset(&appdata,0,sizeof(appdata));
  186 + appdata.action = action;
  187 + appdata.widget = widget;
  188 + appdata.filename = filename;
  189 +
  190 + memset(options,0,sizeof(options));
  191 + memset(exits,0,sizeof(exits));
  192 +
  193 + exits[0].sysexit_code = RXSIO;
  194 + exits[0].handler = Rexx_IO_exit;
  195 +
  196 + // http://www.oorexx.org/docs/rexxpg/c2539.htm
  197 +
  198 + options[0].optionName = DIRECT_EXITS;
  199 + options[0].option = (void *) exits;
  200 +
  201 + options[1].optionName = APPLICATION_DATA;
  202 + options[1].option = (void *) &appdata;
  203 +
  204 + rx3270_set_package_option(&options[2]);
  205 +
  206 + options[3].optionName = EXTERNAL_CALL_PATH;
  207 + options[3].option = pw3270_get_datadir(NULL);
  208 +
  209 + trace("Rexxdir: \"%s\"",(gchar *) ((void *) options[3].option));
  210 +
  211 + if(!RexxCreateInterpreter(&instance, &threadContext, options)) {
  212 +
  213 + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)),
  214 + GTK_DIALOG_DESTROY_WITH_PARENT,
  215 + GTK_MESSAGE_ERROR,
  216 + GTK_BUTTONS_CANCEL,
  217 + _( "Can't start %s script" ), "rexx" );
  218 +
  219 + gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" ));
  220 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),_( "Can't create %s interpreter instance" ), "rexx");
  221 +
  222 + gtk_dialog_run(GTK_DIALOG (dialog));
  223 + gtk_widget_destroy(dialog);
  224 +
  225 + } else {
  226 +
  227 + RexxArrayObject rxArgs;
  228 +
  229 + trace("%s %s(%s)",__FUNCTION__,filename,args);
  230 +
  231 + if(args) {
  232 +
  233 + gchar **arg = g_strsplit(args,",",-1);
  234 + size_t sz = g_strv_length(arg);
  235 +
  236 + rxArgs = threadContext->NewArray(sz);
  237 + for(unsigned int i = 0; i<sz; i++)
  238 + threadContext->ArrayPut(rxArgs, threadContext->String(arg[i]), i + 1);
  239 +
  240 + g_strfreev(arg);
  241 +
  242 + } else {
  243 +
  244 + rxArgs = threadContext->NewArray(1);
  245 + threadContext->ArrayPut(rxArgs, threadContext->String(""),1);
  246 + }
  247 +
  248 + v3270_set_script(widget,'R',TRUE);
  249 + script_name = g_path_get_basename(filename);
  250 + trace("%s: Calling",filename);
  251 + RexxObjectPtr result = threadContext->CallProgram(filename, rxArgs);
  252 + trace("%s: Returns",filename);
  253 + g_free(script_name);
  254 + script_name = NULL;
  255 + v3270_set_script(widget,'R',FALSE);
  256 +
  257 + if (threadContext->CheckCondition()) {
  258 +
  259 + RexxCondition condition;
  260 +
  261 + // retrieve the error information and get it into a decoded form
  262 + RexxDirectoryObject cond = threadContext->GetConditionInfo();
  263 + threadContext->DecodeConditionInfo(cond, &condition);
  264 + // display the errors
  265 + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)),
  266 + GTK_DIALOG_DESTROY_WITH_PARENT,
  267 + GTK_MESSAGE_ERROR,
  268 + GTK_BUTTONS_CANCEL,
  269 + _( "%s script failed" ), "Rexx" );
  270 +
  271 + gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" ));
  272 +
  273 + gtk_message_dialog_format_secondary_text(
  274 + GTK_MESSAGE_DIALOG(dialog),
  275 + _( "%s error %d: %s\n%s" ),
  276 + "Rexx",
  277 + (int) condition.code,
  278 + threadContext->CString(condition.errortext),
  279 + threadContext->CString(condition.message)
  280 +
  281 + );
  282 +
  283 + gtk_dialog_run(GTK_DIALOG (dialog));
  284 + gtk_widget_destroy(dialog);
  285 +
  286 + } else if (result != NULLOBJECT) {
  287 +
  288 + CSTRING resultString = threadContext->CString(result);
  289 + lib3270_write_log(NULL,"REXX","%s exits with rc=%s",filename,resultString);
  290 + }
  291 +
  292 + instance->Terminate();
  293 +
  294 + if(appdata.trace) {
  295 +
  296 + pw3270_trace_printf(appdata.trace,"%s","** Rexx script ends\n");
  297 + g_object_set_data(G_OBJECT(appdata.trace),"rexx_app_data",NULL);
  298 +
  299 + }
  300 +
  301 + trace("%s ends",__FUNCTION__);
  302 + }
  303 +
  304 + g_free(options[3].option);
  305 +
  306 + }
  307 +
  308 +
  309 +extern "C" {
  310 +
  311 + LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) {
  312 +
  313 + trace("%s",__FUNCTION__);
  314 +
  315 +#if GTK_CHECK_VERSION(2,32,0)
  316 + g_mutex_init(&mutex);
  317 +#endif // GTK_CHECK_VERSION
  318 +
  319 + rx3270_set_session(lib3270_get_default_session_handle());
  320 +
  321 + return 0;
  322 + }
  323 +
  324 + LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal) {
  325 +#if GTK_CHECK_VERSION(2,32,0)
  326 + g_mutex_clear(&mutex);
  327 +#endif // GTK_CHECK_VERSION
  328 +
  329 + trace("%s",__FUNCTION__);
  330 +
  331 + return 0;
  332 + }
  333 +
  334 + LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget) {
  335 +
  336 + gchar *filename = (gchar *) g_object_get_data(G_OBJECT(action),"src");
  337 +
  338 + lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p",gtk_action_get_name(action),widget);
  339 +
  340 +#if GTK_CHECK_VERSION(2,32,0)
  341 + if(!g_mutex_trylock(&mutex))
  342 +#else
  343 + if(!g_static_mutex_trylock(&mutex))
  344 +#endif // GTK_CHECK_VERSION
  345 + {
  346 + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)),
  347 + GTK_DIALOG_DESTROY_WITH_PARENT,
  348 + GTK_MESSAGE_ERROR,
  349 + GTK_BUTTONS_CANCEL,
  350 + "%s", _( "Can't start script" ));
  351 +
  352 + gtk_window_set_title(GTK_WINDOW(dialog),_( "System busy" ));
  353 + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",_( "Please, try again in a few moments" ));
  354 +
  355 + gtk_dialog_run(GTK_DIALOG (dialog));
  356 + gtk_widget_destroy(dialog);
  357 + return;
  358 + }
  359 +
  360 + pw3270_set_action_state(action,FALSE);
  361 +
  362 + if(filename && *filename) {
  363 +
  364 + // Has filename, call it directly
  365 + call_rexx_script(action,widget,filename);
  366 +
  367 + } else {
  368 +
  369 + filename = pw3270_file_chooser(GTK_FILE_CHOOSER_ACTION_OPEN, "rexx", _( "Select script to run" ), NULL, "rex");
  370 +
  371 + if(filename) {
  372 +
  373 + if(*filename) {
  374 + call_rexx_script(action,widget,filename);
  375 + }
  376 + g_free(filename);
  377 + }
  378 +
  379 +
  380 + }
  381 +
  382 + pw3270_set_action_state(action,TRUE);
  383 +
  384 +#if GTK_CHECK_VERSION(2,32,0)
  385 + g_mutex_unlock(&mutex);
  386 +#else
  387 + g_static_mutex_unlock(&mutex);
  388 +#endif // GTK_CHECK_VERSION
  389 +
  390 + }
  391 +
  392 +}
  393 +
  394 +
  395 +
... ...
src/private.h
... ... @@ -1,141 +0,0 @@
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 private.h 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   - #define ENABLE_NLS
35   - #define GETTEXT_PACKAGE "pw3270"
36   -
37   - #include <libintl.h>
38   - #include <glib/gi18n.h>
39   - #include <gtk/gtk.h>
40   -
41   - #include <stdint.h>
42   - #include <errno.h>
43   - #include <stdio.h>
44   - #include <stdarg.h>
45   - #include <pw3270cpp.h>
46   - #include <oorexxapi.h>
47   -
48   -/*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/
49   -
50   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270version);
51   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270QueryCState);
52   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Disconnect);
53   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Connect);
54   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270isConnected);
55   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForEvents);
56   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Sleep);
57   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendENTERKey);
58   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPFKey);
59   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPAKey);
60   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForTerminalReady);
61   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForStringAt);
62   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270GetStringAt);
63   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsTerminalReady);
64   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt);
65   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt);
66   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270CloseApplication);
67   - REXX_TYPED_ROUTINE_PROTOTYPE(ebc2asc);
68   - REXX_TYPED_ROUTINE_PROTOTYPE(asc2ebc);
69   -
70   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Erase);
71   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOF);
72   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOL);
73   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseInput);
74   -
75   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtected);
76   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtectedAt);
77   - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetUnlockDelay);
78   -
79   - REXX_METHOD_PROTOTYPE(rx3270_method_version);
80   - REXX_METHOD_PROTOTYPE(rx3270_method_revision);
81   - REXX_METHOD_PROTOTYPE(rx3270_method_init);
82   - REXX_METHOD_PROTOTYPE(rx3270_method_uninit);
83   - REXX_METHOD_PROTOTYPE(rx3270_method_connect);
84   - REXX_METHOD_PROTOTYPE(rx3270_method_disconnect);
85   - REXX_METHOD_PROTOTYPE(rx3270_method_sleep);
86   - REXX_METHOD_PROTOTYPE(rx3270_method_is_connected);
87   - REXX_METHOD_PROTOTYPE(rx3270_method_is_ready);
88   - REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_ready);
89   - REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor);
90   - REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
91   - REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
92   - REXX_METHOD_PROTOTYPE(rx3270_method_enter);
93   - REXX_METHOD_PROTOTYPE(rx3270_method_erase);
94   - REXX_METHOD_PROTOTYPE(rx3270_method_erase_eof);
95   - REXX_METHOD_PROTOTYPE(rx3270_method_erase_eol);
96   - REXX_METHOD_PROTOTYPE(rx3270_method_erase_input);
97   - REXX_METHOD_PROTOTYPE(rx3270_method_pfkey);
98   - REXX_METHOD_PROTOTYPE(rx3270_method_pakey);
99   - REXX_METHOD_PROTOTYPE(rx3270_method_get_text);
100   - REXX_METHOD_PROTOTYPE(rx3270_method_get_text_at);
101   - REXX_METHOD_PROTOTYPE(rx3270_method_set_text_at);
102   - REXX_METHOD_PROTOTYPE(rx3270_method_cmp_text_at);
103   - REXX_METHOD_PROTOTYPE(rx3270_method_event_trace);
104   - REXX_METHOD_PROTOTYPE(rx3270_method_screen_trace);
105   - REXX_METHOD_PROTOTYPE(rx3270_method_ds_trace);
106   - REXX_METHOD_PROTOTYPE(rx3270_method_set_option);
107   - REXX_METHOD_PROTOTYPE(rx3270_method_test);
108   - REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_text_at);
109   - REXX_METHOD_PROTOTYPE(rx3270_method_get_field_len);
110   - REXX_METHOD_PROTOTYPE(rx3270_method_get_field_start);
111   - REXX_METHOD_PROTOTYPE(rx3270_method_get_next_unprotected);
112   - REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected);
113   - REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected_at);
114   - REXX_METHOD_PROTOTYPE(rx3270_method_get_selection);
115   - REXX_METHOD_PROTOTYPE(rx3270_method_set_selection);
116   - REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard);
117   - REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard);
118   - REXX_METHOD_PROTOTYPE(rx3270_method_popup);
119   - REXX_METHOD_PROTOTYPE(rx3270_method_get_filename);
120   - REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
121   - REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
122   - REXX_METHOD_PROTOTYPE(rx3270_method_input_text);
123   - REXX_METHOD_PROTOTYPE(rx3270_method_get_display_charset);
124   - REXX_METHOD_PROTOTYPE(rx3270_method_set_display_charset);
125   - REXX_METHOD_PROTOTYPE(rx3270_method_get_host_charset);
126   - REXX_METHOD_PROTOTYPE(rx3270_method_set_host_charset);
127   - REXX_METHOD_PROTOTYPE(rx3270_method_set_unlock_delay);
128   -
129   -/*--[ 3270 Session ]-----------------------------------------------------------------------------------------*/
130   -
131   -#ifdef __cplusplus
132   - extern "C" {
133   -#endif
134   -
135   - LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option);
136   -
137   -#ifdef __cplusplus
138   - }
139   -#endif
140   -
141   -#endif // RX3270_H_INCLUDED
src/rexx_methods.cc
... ... @@ -1,648 +0,0 @@
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 "private.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   -}
src/rx3270.cc
... ... @@ -1,185 +0,0 @@
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 rx3270.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   - /*
31   - *
32   - * Reference:
33   - *
34   - * http://www.oorexx.org/docs/rexxpg/x2950.htm
35   - *
36   - */
37   -
38   - #include "private.h"
39   -
40   -/*--[ Globals ]--------------------------------------------------------------------------------------*/
41   -
42   -/*--[ Implement ]------------------------------------------------------------------------------------*/
43   -
44   -// now build the actual entry list
45   -RexxRoutineEntry rx3270_functions[] =
46   -{
47   - REXX_TYPED_ROUTINE(rx3270version, rx3270version),
48   - REXX_TYPED_ROUTINE(rx3270QueryCState, rx3270QueryCState),
49   - REXX_TYPED_ROUTINE(rx3270Disconnect, rx3270Disconnect),
50   - REXX_TYPED_ROUTINE(rx3270Connect, rx3270Connect),
51   - REXX_TYPED_ROUTINE(rx3270isConnected, rx3270isConnected),
52   - REXX_TYPED_ROUTINE(rx3270WaitForEvents, rx3270WaitForEvents),
53   - REXX_TYPED_ROUTINE(rx3270Sleep, rx3270Sleep),
54   - REXX_TYPED_ROUTINE(rx3270SendENTERKey, rx3270SendENTERKey),
55   - REXX_TYPED_ROUTINE(rx3270SendPFKey, rx3270SendPFKey),
56   - REXX_TYPED_ROUTINE(rx3270SendPAKey, rx3270SendPAKey),
57   - REXX_TYPED_ROUTINE(rx3270WaitForTerminalReady, rx3270WaitForTerminalReady),
58   - REXX_TYPED_ROUTINE(rx3270WaitForStringAt, rx3270WaitForStringAt),
59   - REXX_TYPED_ROUTINE(rx3270GetStringAt, rx3270GetStringAt),
60   - REXX_TYPED_ROUTINE(rx3270IsTerminalReady, rx3270IsTerminalReady),
61   - REXX_TYPED_ROUTINE(rx3270queryStringAt, rx3270queryStringAt),
62   - REXX_TYPED_ROUTINE(rx3270SetStringAt, rx3270SetStringAt),
63   - REXX_TYPED_ROUTINE(rx3270CloseApplication, rx3270CloseApplication),
64   -
65   - REXX_TYPED_ROUTINE(rx3270Erase, rx3270Erase),
66   - REXX_TYPED_ROUTINE(rx3270EraseEOF, rx3270EraseEOF),
67   - REXX_TYPED_ROUTINE(rx3270EraseEOL, rx3270EraseEOL),
68   - REXX_TYPED_ROUTINE(rx3270EraseInput, rx3270EraseInput),
69   -
70   - REXX_TYPED_ROUTINE(rx3270IsProtected, rx3270IsProtected),
71   - REXX_TYPED_ROUTINE(rx3270IsProtectedAt, rx3270IsProtectedAt),
72   - REXX_TYPED_ROUTINE(rx3270SetUnlockDelay, rx3270SetUnlockDelay),
73   -
74   - REXX_TYPED_ROUTINE(ebc2asc, ebc2asc),
75   - REXX_TYPED_ROUTINE(asc2ebc, asc2ebc),
76   -
77   -
78   - // rx3270Popup
79   - REXX_LAST_METHOD()
80   -};
81   -
82   -RexxMethodEntry rx3270_methods[] =
83   -{
84   - REXX_METHOD(rx3270_method_version, rx3270_method_version ),
85   - REXX_METHOD(rx3270_method_revision, rx3270_method_revision ),
86   - REXX_METHOD(rx3270_method_init, rx3270_method_init ),
87   - REXX_METHOD(rx3270_method_uninit, rx3270_method_uninit ),
88   - REXX_METHOD(rx3270_method_connect, rx3270_method_connect ),
89   - REXX_METHOD(rx3270_method_disconnect, rx3270_method_disconnect ),
90   - REXX_METHOD(rx3270_method_sleep, rx3270_method_sleep ),
91   - REXX_METHOD(rx3270_method_is_connected, rx3270_method_is_connected ),
92   - REXX_METHOD(rx3270_method_is_ready, rx3270_method_is_ready ),
93   - REXX_METHOD(rx3270_method_wait_for_ready, rx3270_method_wait_for_ready ),
94   - REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor ),
95   - REXX_METHOD(rx3270_method_set_cursor, rx3270_method_get_cursor_addr ),
96   - REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor_addr ),
97   - REXX_METHOD(rx3270_method_enter, rx3270_method_enter ),
98   - REXX_METHOD(rx3270_method_enter, rx3270_method_erase ),
99   - REXX_METHOD(rx3270_method_enter, rx3270_method_erase_eof ),
100   - REXX_METHOD(rx3270_method_enter, rx3270_method_erase_eol ),
101   - REXX_METHOD(rx3270_method_enter, rx3270_method_erase_input ),
102   - REXX_METHOD(rx3270_method_pfkey, rx3270_method_pfkey ),
103   - REXX_METHOD(rx3270_method_pakey, rx3270_method_pakey ),
104   - REXX_METHOD(rx3270_method_get_text, rx3270_method_get_text ),
105   - REXX_METHOD(rx3270_method_get_text_at, rx3270_method_get_text_at ),
106   - REXX_METHOD(rx3270_method_set_text_at, rx3270_method_set_text_at ),
107   - REXX_METHOD(rx3270_method_cmp_text_at, rx3270_method_cmp_text_at ),
108   - REXX_METHOD(rx3270_method_event_trace, rx3270_method_event_trace ),
109   - REXX_METHOD(rx3270_method_screen_trace, rx3270_method_screen_trace ),
110   - REXX_METHOD(rx3270_method_ds_trace, rx3270_method_ds_trace ),
111   - REXX_METHOD(rx3270_method_set_option, rx3270_method_set_option ),
112   - REXX_METHOD(rx3270_method_test, rx3270_method_test ),
113   - REXX_METHOD(rx3270_method_wait_for_text_at, rx3270_method_wait_for_text_at ),
114   -
115   - REXX_METHOD(rx3270_method_get_field_len, rx3270_method_get_field_len ),
116   - REXX_METHOD(rx3270_method_get_field_start, rx3270_method_get_field_start ),
117   - REXX_METHOD(rx3270_method_get_next_unprotected, rx3270_method_get_next_unprotected ),
118   -
119   - REXX_METHOD(rx3270_method_get_is_protected, rx3270_method_get_is_protected ),
120   - REXX_METHOD(rx3270_method_get_is_protected_at, rx3270_method_get_is_protected_at ),
121   -
122   - REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ),
123   - REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ),
124   - REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ),
125   - REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ),
126   -
127   - REXX_METHOD(rx3270_method_erase, rx3270_method_erase ),
128   - REXX_METHOD(rx3270_method_erase_eof, rx3270_method_erase_eof ),
129   - REXX_METHOD(rx3270_method_erase_eol, rx3270_method_erase_eol ),
130   - REXX_METHOD(rx3270_method_erase_input, rx3270_method_erase_input ),
131   -
132   - REXX_METHOD(rx3270_method_popup, rx3270_method_popup ),
133   - REXX_METHOD(rx3270_method_get_filename, rx3270_method_get_filename ),
134   -
135   - REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ),
136   - REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ),
137   - REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ),
138   -
139   - REXX_METHOD(rx3270_method_get_display_charset, rx3270_method_get_display_charset ),
140   - REXX_METHOD(rx3270_method_set_display_charset, rx3270_method_set_display_charset ),
141   -
142   - REXX_METHOD(rx3270_method_get_host_charset, rx3270_method_get_host_charset ),
143   - REXX_METHOD(rx3270_method_set_host_charset, rx3270_method_set_host_charset ),
144   -
145   - REXX_METHOD(rx3270_method_set_unlock_delay, rx3270_method_set_unlock_delay ),
146   -
147   - REXX_LAST_METHOD()
148   -};
149   -
150   -RexxPackageEntry rx3270_package_entry =
151   -{
152   - STANDARD_PACKAGE_HEADER
153   - REXX_CURRENT_INTERPRETER_VERSION, // anything after 4.0.0 will work
154   - "rx3270", // name of the package
155   - PACKAGE_VERSION, // package information
156   - NULL, // no load/unload functions
157   - NULL,
158   - rx3270_functions, // the exported functions
159   - rx3270_methods // no methods in rx3270.
160   -};
161   -
162   -// package loading stub.
163   -/*
164   -OOREXX_GET_PACKAGE(rx3270);
165   -*/
166   -
167   -BEGIN_EXTERN_C()
168   -
169   -LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option)
170   -{
171   - static const RexxLibraryPackage package = { "rx3270", &rx3270_package_entry };
172   -
173   - option->optionName = REGISTER_LIBRARY;
174   - option->option = (void *) &package;
175   -
176   -}
177   -
178   -LIB3270_EXPORT RexxPackageEntry * RexxEntry RexxGetPackage(void)
179   -{
180   - return &rx3270_package_entry;
181   -}
182   -
183   -END_EXTERN_C()
184   -
185   -
src/typed_routines.cc
... ... @@ -1,323 +0,0 @@
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 "private.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   -
ui/80rexx.xml 0 → 100644
... ... @@ -0,0 +1,42 @@
  1 +<!-----------------------------------------------------------------------------
  2 +
  3 + Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  4 + (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  5 + aplicativos mainframe. Registro no INPI sob o nome G3270.
  6 +
  7 + Copyright (C) <2008> <Banco do Brasil S.A.>
  8 +
  9 + Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + Free Software Foundation.
  12 +
  13 + Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + obter mais detalhes.
  17 +
  18 + Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + St, Fifth Floor, Boston, MA 02110-1301 USA
  21 +
  22 +
  23 + Contatos:
  24 +
  25 + perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + licinio@bb.com.br (Licínio Luis Branco)
  28 + kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 +
  30 +------------------------------------------------------------------------------>
  31 +
  32 +<ui>
  33 + <menubar name='topmenu' topmenu='yes'>
  34 + <menu name='FileMenu' label='_File' />
  35 + <menu name='EditMenu' label='_Edit' />
  36 + <menu name='View' label='_View' />
  37 + <menu name='ScriptsMenu' label='Scripts' visible='yes' >
  38 + <menuitem action='rexx' label='External Rexx script'/>
  39 + </menu>
  40 + </menubar>
  41 +</ui>
  42 +
... ...