diff --git a/pw3270-rexx.cbp b/pw3270-rexx.cbp
index ee69fed..70287fc 100644
--- a/pw3270-rexx.cbp
+++ b/pw3270-rexx.cbp
@@ -36,16 +36,16 @@
+
-
-
-
-
-
+
+
+
+
diff --git a/src/extension/rexx_methods.cc b/src/extension/rexx_methods.cc
new file mode 100644
index 0000000..0adca70
--- /dev/null
+++ b/src/extension/rexx_methods.cc
@@ -0,0 +1,648 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como rexx_methods.cc e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ *
+ * Referencias:
+ *
+ * * http://www.oorexx.org/docs/rexxpg/x2950.htm
+ *
+ */
+
+ #include
+ #include
+ #include
+ #include
+
+ using namespace std;
+ using namespace PW3270_NAMESPACE;
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+RexxMethod1(int, rx3270_method_init, OPTIONAL_CSTRING, type)
+{
+ // Set session class in rexx object
+ try
+ {
+ if(!(type && *type))
+ type = "";
+ RexxPointerObject sessionPtr = context->NewPointer(session::create(type));
+ context->SetObjectVariable("CSELF", sessionPtr);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return 0;
+}
+
+RexxMethod1(int, rx3270_method_uninit, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+
+ trace("rx3270_method_uninit hSession=%p",hSession);
+
+ if(hSession)
+ delete hSession;
+
+ trace("%s","rx3270_method_uninit");
+ return 0;
+}
+
+RexxMethod1(RexxStringObject, rx3270_method_version, CSELF, sessionPtr)
+{
+ session * hSession = (session *) sessionPtr;
+
+ if(hSession)
+ return context->String((CSTRING) hSession->get_version().c_str());
+
+ return context->String((CSTRING) PACKAGE_VERSION);
+}
+
+RexxMethod1(RexxStringObject, rx3270_method_revision, CSELF, sessionPtr)
+{
+ session * hSession = (session *) sessionPtr;
+
+ if(hSession)
+ return context->String((CSTRING) hSession->get_revision().c_str());
+
+ return context->String((CSTRING) PACKAGE_REVISION);
+}
+
+RexxMethod3(int, rx3270_method_connect, CSELF, sessionPtr, CSTRING, uri, OPTIONAL_int, wait)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+
+ return hSession->connect(uri,wait != 0);
+}
+
+RexxMethod1(int, rx3270_method_disconnect, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->disconnect();
+}
+
+RexxMethod2(int, rx3270_method_sleep, CSELF, sessionPtr, int, seconds)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->wait(seconds);
+}
+
+RexxMethod1(logical_t, rx3270_method_is_connected, CSELF, sessionPtr)
+{
+ try
+ {
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return false;
+ return hSession->is_connected();
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return 0;
+}
+
+RexxMethod1(logical_t, rx3270_method_is_ready, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return false;
+ return hSession->is_ready();
+}
+
+RexxMethod2(int, rx3270_method_wait_for_ready, CSELF, sessionPtr, OPTIONAL_int, seconds)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->wait_for_ready(seconds > 0 ? seconds : 60);
+}
+
+RexxMethod3(int, rx3270_method_set_cursor, CSELF, sessionPtr, int, row, int, col)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->set_cursor_position(row,col);
+}
+
+RexxMethod1(int, rx3270_method_get_cursor_addr, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->get_cursor_addr();
+}
+
+RexxMethod2(int, rx3270_method_set_cursor_addr, CSELF, sessionPtr, int, addr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->set_cursor_addr(addr);
+}
+
+RexxMethod1(int, rx3270_method_enter, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->enter();
+}
+
+RexxMethod1(int, rx3270_method_erase, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->erase();
+}
+
+RexxMethod1(int, rx3270_method_erase_eof, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->erase_eof();
+}
+
+RexxMethod1(int, rx3270_method_erase_eol, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->erase_eol();
+}
+
+RexxMethod1(int, rx3270_method_erase_input, CSELF, sessionPtr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->erase_input();
+}
+
+
+RexxMethod2(int, rx3270_method_pfkey, CSELF, sessionPtr, int, key)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->pfkey(key);
+}
+
+RexxMethod2(int, rx3270_method_pakey, CSELF, sessionPtr, int, key)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->pakey(key);
+}
+
+RexxMethod4(RexxStringObject, rx3270_method_get_text_at, CSELF, sessionPtr, int, row, int, col, int, sz)
+{
+
+ try
+ {
+ session * hSession = (session *) sessionPtr;
+ string str = hSession->get_string_at(row,col,sz);
+ return context->String((CSTRING) str.c_str());
+
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return context->String("");
+}
+
+
+RexxMethod4(int, rx3270_method_set_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, text)
+{
+ try
+ {
+ session * hSession = (session *) sessionPtr;
+ return hSession->set_string_at(row,col,text);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return -1;
+}
+
+RexxMethod2(int, rx3270_method_input_text, CSELF, sessionPtr, CSTRING, text)
+{
+ try
+ {
+ session * hSession = (session *) sessionPtr;
+ return hSession->input_string(text);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return -1;
+
+}
+
+RexxMethod4(int, rx3270_method_cmp_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key)
+{
+ try
+ {
+ session * hSession = (session *) sessionPtr;
+ return hSession->cmp_string_at(row,col,key);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+ return -1;
+}
+
+RexxMethod2(int, rx3270_method_event_trace, CSELF, sessionPtr, int, flag)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ hSession->set_toggle(LIB3270_TOGGLE_EVENT_TRACE,flag);
+ return 0;
+}
+
+RexxMethod2(int, rx3270_method_screen_trace, CSELF, sessionPtr, int, flag)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ hSession->set_toggle(LIB3270_TOGGLE_SCREEN_TRACE,flag);
+ return 0;
+
+}
+
+RexxMethod2(int, rx3270_method_ds_trace, CSELF, sessionPtr, int, flag)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ hSession->set_toggle(LIB3270_TOGGLE_DS_TRACE,flag);
+ return 0;
+}
+
+RexxMethod3(int, rx3270_method_set_option, CSELF, sessionPtr, CSTRING, name, int, flag)
+{
+ static const struct _toggle_info
+ {
+ const char * name;
+ LIB3270_TOGGLE id;
+ }
+ toggle[LIB3270_TOGGLE_COUNT] =
+ {
+ { "monocase", LIB3270_TOGGLE_MONOCASE },
+ { "cursorblink", LIB3270_TOGGLE_CURSOR_BLINK },
+ { "showtiming", LIB3270_TOGGLE_SHOW_TIMING },
+ { "cursorpos", LIB3270_TOGGLE_CURSOR_POS },
+ { "dstrace", LIB3270_TOGGLE_DS_TRACE },
+ { "linewrap", LIB3270_TOGGLE_LINE_WRAP },
+ { "blankfill", LIB3270_TOGGLE_BLANK_FILL },
+ { "screentrace", LIB3270_TOGGLE_SCREEN_TRACE },
+ { "eventtrace", LIB3270_TOGGLE_EVENT_TRACE },
+ { "marginedpaste", LIB3270_TOGGLE_MARGINED_PASTE },
+ { "rectselect", LIB3270_TOGGLE_RECTANGLE_SELECT },
+ { "crosshair", LIB3270_TOGGLE_CROSSHAIR },
+ { "fullscreen", LIB3270_TOGGLE_FULL_SCREEN },
+ { "reconnect", LIB3270_TOGGLE_RECONNECT },
+ { "insert", LIB3270_TOGGLE_INSERT },
+ { "smartpaste", LIB3270_TOGGLE_SMART_PASTE },
+ { "bold", LIB3270_TOGGLE_BOLD },
+ { "keepselected", LIB3270_TOGGLE_KEEP_SELECTED },
+ { "underline", LIB3270_TOGGLE_UNDERLINE },
+ { "autoconnect", LIB3270_TOGGLE_CONNECT_ON_STARTUP },
+ { "kpalternative", LIB3270_TOGGLE_KP_ALTERNATIVE },
+ { "beep", LIB3270_TOGGLE_BEEP },
+ { "fieldattr", LIB3270_TOGGLE_VIEW_FIELD },
+ { "altscreen", LIB3270_TOGGLE_ALTSCREEN },
+ { "keepalive", LIB3270_TOGGLE_KEEP_ALIVE },
+ };
+
+ session *hSession = (session *) sessionPtr;
+ if(hSession)
+ {
+ for(int f = 0; f < LIB3270_TOGGLE_COUNT; f++)
+ {
+ if(!strcasecmp(name,toggle[f].name))
+ {
+ hSession->set_toggle(toggle[f].id,flag);
+ return 0;
+ }
+ }
+ return ENOENT;
+ }
+ return -1;
+}
+
+
+RexxMethod4(logical_t, rx3270_method_test, CSELF, sessionPtr, CSTRING, key, int, row, int, col)
+{
+ try
+ {
+ session * hSession = (session *) sessionPtr;
+
+ if(!hSession->is_ready())
+ hSession->iterate(false);
+
+ if(hSession->is_ready())
+ {
+ string str = hSession->get_string_at(row,col,strlen(key));
+ return (strcasecmp(str.c_str(),key) == 0);
+ }
+
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return false;
+}
+
+RexxMethod5(int, rx3270_method_wait_for_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key, int, timeout)
+{
+ try
+ {
+ session * hSession = (session *) sessionPtr;
+ return hSession->wait_for_string_at(row,col,key,timeout);
+
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return -1;
+}
+
+RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONAL_int, baddr, OPTIONAL_int, sz)
+{
+ try
+ {
+ session * hSession = (session *) sessionPtr;
+ string str = hSession->get_string(baddr,sz > 0 ? sz : -1);
+ return context->String((CSTRING) str.c_str());
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return context->String("");
+}
+
+
+RexxMethod2(int, rx3270_method_get_field_len, CSELF, sessionPtr, OPTIONAL_int, baddr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->get_field_len(baddr);
+}
+
+RexxMethod2(int, rx3270_method_get_field_start, CSELF, sessionPtr, OPTIONAL_int, baddr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+ return hSession->get_field_start(baddr)+1;
+}
+
+RexxMethod2(int, rx3270_method_get_next_unprotected, CSELF, sessionPtr, OPTIONAL_int, baddr)
+{
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+
+ baddr = hSession->get_next_unprotected(baddr);
+ if(baddr < 1)
+ return -1;
+
+ return baddr;
+}
+
+RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int, baddr)
+{
+
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+
+ return hSession->get_is_protected(baddr);
+}
+
+RexxMethod3(int, rx3270_method_get_is_protected_at, CSELF, sessionPtr, int, row, int, col)
+{
+
+ session *hSession = (session *) sessionPtr;
+ if(!hSession)
+ return -1;
+
+ return hSession->get_is_protected_at(row,col);
+}
+
+
+RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr)
+{
+ try
+ {
+ string str = ((session *) sessionPtr)->get_copy();
+ return context->String((CSTRING) str.c_str());
+
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return context->String("");
+}
+
+RexxMethod2(int, rx3270_method_set_selection, CSELF, sessionPtr, CSTRING, text)
+{
+ try
+ {
+ return ((session *) sessionPtr)->set_copy(text);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return -1;
+}
+
+RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr)
+{
+ session * hSession = (session *) sessionPtr;
+
+ if(hSession)
+ {
+ string str = hSession->get_clipboard();
+ return context->String((CSTRING) str.c_str());
+ }
+
+ trace("%s","rx3270_method_get_clipboard: Clipboard is empty");
+ return context->String("");
+}
+
+RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text)
+{
+ return ((session *) sessionPtr)->set_clipboard(text);
+}
+
+RexxMethod5(int, rx3270_method_popup, CSELF, sessionPtr, CSTRING, s_id, CSTRING, title, CSTRING, message, OPTIONAL_CSTRING, det)
+{
+ LIB3270_NOTIFY id = LIB3270_NOTIFY_INFO;
+ session * hSession = (session *) sessionPtr;
+
+ if(!hSession)
+ return -1;
+
+ if(*s_id)
+ {
+ static const struct _descr
+ {
+ char str;
+ LIB3270_NOTIFY id;
+ } descr[] =
+ {
+ { 'I', LIB3270_NOTIFY_INFO },
+ { 'W', LIB3270_NOTIFY_WARNING },
+ { 'E', LIB3270_NOTIFY_ERROR },
+ { 'C', LIB3270_NOTIFY_CRITICAL },
+ };
+
+ for(int f=0;f<4;f++)
+ {
+ if(toupper(*s_id) == descr[f].str)
+ {
+ id = descr[f].id;
+ trace("Using mode %c (%d)",toupper(*s_id),(int) id);
+ }
+ }
+ }
+
+ return hSession->popup_dialog(id, title, message, "%s", det ? det : "");
+}
+
+RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CSTRING, action_name, CSTRING, title, OPTIONAL_CSTRING, extension, OPTIONAL_CSTRING, filename)
+{
+/*
+ static const struct _action
+ {
+ const cchar * action_name;
+ GtkFileChooserAction id;
+ } action[] =
+ {
+ { "open", GTK_FILE_CHOOSER_ACTION_OPEN },
+ { "save", GTK_FILE_CHOOSER_ACTION_SAVE },
+ { "folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER },
+ { "select_folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER },
+ { "create_folder", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER }
+ };
+
+ GtkFileChooserAction id = GTK_FILE_CHOOSER_ACTION_OPEN;
+ string ret;
+
+ for(int f=0;f<5;f++)
+ {
+ if(!strcasecmp(action_name,action[f].action_name))
+ {
+ id = action[f].id;
+ break;
+ }
+ }
+
+ debug("%s(%s)","rx3270_method_get_filename",action_name);
+ ret = ((session *) sessionPtr)->file_chooser_dialog(id, title, extension,filename);
+ debug("%s(%s)","rx3270_method_get_filename",action_name);
+
+ return context->String(ret.c_str());
+*/
+ return context->String("");
+}
+
+RexxMethod2(int, rx3270_method_set_host_charset, CSELF, sessionPtr, CSTRING, text)
+{
+ return ((session *) sessionPtr)->set_host_charset(text);
+}
+
+RexxMethod1(RexxStringObject, rx3270_method_get_host_charset, CSELF, sessionPtr)
+{
+ string ret = ((session *) sessionPtr)->get_host_charset();
+ return context->String(ret.c_str());
+}
+
+RexxMethod1(RexxStringObject, rx3270_method_get_display_charset, CSELF, sessionPtr)
+{
+ string ret = ((session *) sessionPtr)->get_display_charset();
+ return context->String(ret.c_str());
+}
+
+RexxMethod2(int, rx3270_method_set_display_charset, CSELF, sessionPtr, CSTRING, text)
+{
+ ((session *) sessionPtr)->set_display_charset(NULL,text);
+ return 0;
+}
+
+RexxMethod2(int, rx3270_method_set_unlock_delay, CSELF, sessionPtr, int, delay)
+{
+ session *hSession = (session *) sessionPtr;
+
+ if(!hSession)
+ return -1;
+
+ try
+ {
+ hSession->set_unlock_delay((unsigned short) delay);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return 0;
+}
diff --git a/src/extension/rx3270.cc b/src/extension/rx3270.cc
new file mode 100644
index 0000000..58db827
--- /dev/null
+++ b/src/extension/rx3270.cc
@@ -0,0 +1,200 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como rx3270.c e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+ /*
+ *
+ * Reference:
+ *
+ * http://www.oorexx.org/docs/rexxpg/x2950.htm
+ *
+ */
+
+ #include
+
+/*--[ Globals ]--------------------------------------------------------------------------------------*/
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+// now build the actual entry list
+RexxRoutineEntry rx3270_functions[] =
+{
+ REXX_TYPED_ROUTINE(rx3270version, rx3270version),
+ REXX_TYPED_ROUTINE(rx3270QueryCState, rx3270QueryCState),
+ REXX_TYPED_ROUTINE(rx3270Disconnect, rx3270Disconnect),
+ REXX_TYPED_ROUTINE(rx3270Connect, rx3270Connect),
+ REXX_TYPED_ROUTINE(rx3270isConnected, rx3270isConnected),
+ REXX_TYPED_ROUTINE(rx3270WaitForEvents, rx3270WaitForEvents),
+ REXX_TYPED_ROUTINE(rx3270Sleep, rx3270Sleep),
+ REXX_TYPED_ROUTINE(rx3270SendENTERKey, rx3270SendENTERKey),
+ REXX_TYPED_ROUTINE(rx3270SendPFKey, rx3270SendPFKey),
+ REXX_TYPED_ROUTINE(rx3270SendPAKey, rx3270SendPAKey),
+ REXX_TYPED_ROUTINE(rx3270WaitForTerminalReady, rx3270WaitForTerminalReady),
+ REXX_TYPED_ROUTINE(rx3270WaitForStringAt, rx3270WaitForStringAt),
+ REXX_TYPED_ROUTINE(rx3270GetStringAt, rx3270GetStringAt),
+ REXX_TYPED_ROUTINE(rx3270IsTerminalReady, rx3270IsTerminalReady),
+ REXX_TYPED_ROUTINE(rx3270queryStringAt, rx3270queryStringAt),
+ REXX_TYPED_ROUTINE(rx3270SetStringAt, rx3270SetStringAt),
+ REXX_TYPED_ROUTINE(rx3270CloseApplication, rx3270CloseApplication),
+
+ REXX_TYPED_ROUTINE(rx3270Erase, rx3270Erase),
+ REXX_TYPED_ROUTINE(rx3270EraseEOF, rx3270EraseEOF),
+ REXX_TYPED_ROUTINE(rx3270EraseEOL, rx3270EraseEOL),
+ REXX_TYPED_ROUTINE(rx3270EraseInput, rx3270EraseInput),
+
+ REXX_TYPED_ROUTINE(rx3270IsProtected, rx3270IsProtected),
+ REXX_TYPED_ROUTINE(rx3270IsProtectedAt, rx3270IsProtectedAt),
+ REXX_TYPED_ROUTINE(rx3270SetUnlockDelay, rx3270SetUnlockDelay),
+
+ REXX_TYPED_ROUTINE(ebc2asc, ebc2asc),
+ REXX_TYPED_ROUTINE(asc2ebc, asc2ebc),
+
+
+ // rx3270Popup
+ REXX_LAST_METHOD()
+};
+
+RexxMethodEntry rx3270_methods[] =
+{
+ REXX_METHOD(rx3270_method_version, rx3270_method_version ),
+ REXX_METHOD(rx3270_method_revision, rx3270_method_revision ),
+ REXX_METHOD(rx3270_method_init, rx3270_method_init ),
+ REXX_METHOD(rx3270_method_uninit, rx3270_method_uninit ),
+ REXX_METHOD(rx3270_method_connect, rx3270_method_connect ),
+ REXX_METHOD(rx3270_method_disconnect, rx3270_method_disconnect ),
+ REXX_METHOD(rx3270_method_sleep, rx3270_method_sleep ),
+ REXX_METHOD(rx3270_method_is_connected, rx3270_method_is_connected ),
+ REXX_METHOD(rx3270_method_is_ready, rx3270_method_is_ready ),
+ REXX_METHOD(rx3270_method_wait_for_ready, rx3270_method_wait_for_ready ),
+ REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor ),
+ REXX_METHOD(rx3270_method_set_cursor, rx3270_method_get_cursor_addr ),
+ REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor_addr ),
+ REXX_METHOD(rx3270_method_enter, rx3270_method_enter ),
+ REXX_METHOD(rx3270_method_enter, rx3270_method_erase ),
+ REXX_METHOD(rx3270_method_enter, rx3270_method_erase_eof ),
+ REXX_METHOD(rx3270_method_enter, rx3270_method_erase_eol ),
+ REXX_METHOD(rx3270_method_enter, rx3270_method_erase_input ),
+ REXX_METHOD(rx3270_method_pfkey, rx3270_method_pfkey ),
+ REXX_METHOD(rx3270_method_pakey, rx3270_method_pakey ),
+ REXX_METHOD(rx3270_method_get_text, rx3270_method_get_text ),
+ REXX_METHOD(rx3270_method_get_text_at, rx3270_method_get_text_at ),
+ REXX_METHOD(rx3270_method_set_text_at, rx3270_method_set_text_at ),
+ REXX_METHOD(rx3270_method_cmp_text_at, rx3270_method_cmp_text_at ),
+ REXX_METHOD(rx3270_method_event_trace, rx3270_method_event_trace ),
+ REXX_METHOD(rx3270_method_screen_trace, rx3270_method_screen_trace ),
+ REXX_METHOD(rx3270_method_ds_trace, rx3270_method_ds_trace ),
+ REXX_METHOD(rx3270_method_set_option, rx3270_method_set_option ),
+ REXX_METHOD(rx3270_method_test, rx3270_method_test ),
+ REXX_METHOD(rx3270_method_wait_for_text_at, rx3270_method_wait_for_text_at ),
+
+ REXX_METHOD(rx3270_method_get_field_len, rx3270_method_get_field_len ),
+ REXX_METHOD(rx3270_method_get_field_start, rx3270_method_get_field_start ),
+ REXX_METHOD(rx3270_method_get_next_unprotected, rx3270_method_get_next_unprotected ),
+
+ REXX_METHOD(rx3270_method_get_is_protected, rx3270_method_get_is_protected ),
+ REXX_METHOD(rx3270_method_get_is_protected_at, rx3270_method_get_is_protected_at ),
+
+ REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ),
+ REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ),
+ REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ),
+ REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ),
+
+ REXX_METHOD(rx3270_method_erase, rx3270_method_erase ),
+ REXX_METHOD(rx3270_method_erase_eof, rx3270_method_erase_eof ),
+ REXX_METHOD(rx3270_method_erase_eol, rx3270_method_erase_eol ),
+ REXX_METHOD(rx3270_method_erase_input, rx3270_method_erase_input ),
+
+ REXX_METHOD(rx3270_method_popup, rx3270_method_popup ),
+ REXX_METHOD(rx3270_method_get_filename, rx3270_method_get_filename ),
+
+ REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ),
+ REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ),
+ REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ),
+
+ REXX_METHOD(rx3270_method_get_display_charset, rx3270_method_get_display_charset ),
+ REXX_METHOD(rx3270_method_set_display_charset, rx3270_method_set_display_charset ),
+
+ REXX_METHOD(rx3270_method_get_host_charset, rx3270_method_get_host_charset ),
+ REXX_METHOD(rx3270_method_set_host_charset, rx3270_method_set_host_charset ),
+
+ REXX_METHOD(rx3270_method_set_unlock_delay, rx3270_method_set_unlock_delay ),
+
+ REXX_LAST_METHOD()
+};
+
+RexxPackageEntry rx3270_package_entry =
+{
+ STANDARD_PACKAGE_HEADER
+ REXX_CURRENT_INTERPRETER_VERSION, // anything after 4.0.0 will work
+ "rx3270", // name of the package
+ PACKAGE_VERSION, // package information
+ NULL, // no load/unload functions
+ NULL,
+ rx3270_functions, // the exported functions
+ rx3270_methods // no methods in rx3270.
+};
+
+// package loading stub.
+/*
+OOREXX_GET_PACKAGE(rx3270);
+*/
+
+static H3270 * default_session = NULL;
+
+static PW3270_NAMESPACE::session * factory(const char *name) {
+
+ if(!default_session)
+ return PW3270_NAMESPACE::session::create_local();
+
+ return PW3270_NAMESPACE::session::create_local(default_session);
+}
+
+BEGIN_EXTERN_C()
+
+LIB3270_EXPORT void rx3270_set_session(H3270 *session) {
+ default_session = session;
+ PW3270_NAMESPACE::session::set_plugin(factory);
+}
+
+LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option)
+{
+ static const RexxLibraryPackage package = { "rx3270", &rx3270_package_entry };
+
+ option->optionName = REGISTER_LIBRARY;
+ option->option = (void *) &package;
+
+}
+
+LIB3270_EXPORT RexxPackageEntry * RexxEntry RexxGetPackage(void)
+{
+ return &rx3270_package_entry;
+}
+
+END_EXTERN_C()
+
+
diff --git a/src/extension/typed_routines.cc b/src/extension/typed_routines.cc
new file mode 100644
index 0000000..e805b0c
--- /dev/null
+++ b/src/extension/typed_routines.cc
@@ -0,0 +1,323 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como typed_routines.cc e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ using namespace std;
+ using namespace PW3270_NAMESPACE;
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+RexxRoutine0(CSTRING, rx3270version)
+{
+ try
+ {
+ return session::get_default()->get_version().c_str();
+ }
+ catch(std::exception& e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return NULL;
+}
+
+RexxRoutine0(CSTRING, rx3270QueryCState)
+{
+ #define DECLARE_XLAT_STATE( x ) { x, #x }
+
+ static const struct _xlat_state
+ {
+ LIB3270_CSTATE state;
+ const char * ret;
+ } xlat_state[] =
+ {
+ { LIB3270_NOT_CONNECTED, "NOT_CONNECTED" },
+ { LIB3270_RESOLVING, "RESOLVING" },
+ { LIB3270_PENDING, "PENDING" },
+ { LIB3270_CONNECTED_INITIAL, "CONNECTED_INITIAL" },
+ { LIB3270_CONNECTED_ANSI, "CONNECTED_ANSI" },
+ { LIB3270_CONNECTED_3270, "CONNECTED_3270" },
+ { LIB3270_CONNECTED_INITIAL_E, "CONNECTED_INITIAL_E" },
+ { LIB3270_CONNECTED_NVT, "CONNECTED_NVT" },
+ { LIB3270_CONNECTED_SSCP, "CONNECTED_SSCP" },
+ { LIB3270_CONNECTED_TN3270E, "CONNECTED_TN3270E" },
+ };
+
+ size_t f;
+ LIB3270_CSTATE state = session::get_default()->get_cstate();
+
+ for(f=0;f < (sizeof(xlat_state)/sizeof(struct _xlat_state)); f++)
+ {
+ if(state == xlat_state[f].state)
+ return xlat_state[f].ret;
+ }
+
+ return "UNEXPECTED";
+}
+
+RexxRoutine0(int, rx3270Disconnect)
+{
+ return session::get_default()->disconnect();
+}
+
+RexxRoutine2(int, rx3270Connect, CSTRING, hostname, int, wait)
+{
+ return session::get_default()->connect(hostname,wait);
+}
+
+RexxRoutine0(int, rx3270isConnected)
+{
+ return session::get_default()->is_connected();
+}
+
+RexxRoutine0(int, rx3270WaitForEvents)
+{
+ return session::get_default()->iterate();
+}
+
+RexxRoutine1(int, rx3270Sleep, int, seconds)
+{
+ return session::get_default()->wait(seconds);
+}
+
+RexxRoutine0(int, rx3270SendENTERKey)
+{
+ return session::get_default()->enter();
+}
+
+RexxRoutine0(int, rx3270Erase)
+{
+ return session::get_default()->erase();
+}
+
+RexxRoutine0(int, rx3270EraseEOF)
+{
+ return session::get_default()->erase_eof();
+}
+
+RexxRoutine0(int, rx3270EraseEOL)
+{
+ return session::get_default()->erase_eol();
+}
+
+RexxRoutine0(int, rx3270EraseInput)
+{
+ return session::get_default()->erase_input();
+}
+
+RexxRoutine1(int, rx3270SendPFKey, int, key)
+{
+ return session::get_default()->pfkey(key);
+}
+
+RexxRoutine1(int, rx3270SendPAKey, int, key)
+{
+ return session::get_default()->pakey(key);
+}
+
+RexxRoutine1(int, rx3270WaitForTerminalReady, int, seconds)
+{
+ return session::get_default()->wait_for_ready(seconds);
+}
+
+RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int, timeout)
+{
+ try
+ {
+ return session::get_default()->wait_for_string_at(row,col,key,timeout);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return ETIMEDOUT;
+
+}
+
+RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz)
+{
+ try
+ {
+ string str = session::get_default()->get_string_at(row,col,(int) sz);
+ return context->String((CSTRING) str.c_str());
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return context->String("");
+}
+
+RexxRoutine0(int, rx3270IsTerminalReady)
+{
+ return session::get_default()->is_ready();
+}
+
+RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key)
+{
+ try
+ {
+ return session::get_default()->cmp_string_at(row,col,key);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return -1;
+}
+
+RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col)
+{
+ try
+ {
+ return session::get_default()->set_cursor_position(row,col);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return -1;
+}
+
+RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text)
+{
+ try
+ {
+ return session::get_default()->set_string_at(row,col,text);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+ return -1;
+}
+
+RexxRoutine0(int, rx3270CloseApplication)
+{
+ return session::get_default()->quit();
+}
+
+
+RexxRoutine2(RexxStringObject, asc2ebc, CSTRING, str, OPTIONAL_int, sz)
+{
+ try
+ {
+ if(sz < 1)
+ sz = strlen(str);
+
+ if(sz)
+ {
+ char buffer[sz+1];
+ memcpy(buffer,str,sz);
+ buffer[sz] = 0;
+ return context->String((CSTRING) session::get_default()->asc2ebc((unsigned char *)buffer,sz));
+ }
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return context->String("");
+}
+
+RexxRoutine2(RexxStringObject, ebc2asc, CSTRING, str, OPTIONAL_int, sz)
+{
+ try
+ {
+ if(sz < 1)
+ sz = strlen(str);
+
+ if(sz)
+ {
+ char buffer[sz+1];
+ memcpy(buffer,str,sz);
+ buffer[sz] = 0;
+ return context->String((CSTRING) session::get_default()->ebc2asc((unsigned char *)buffer,sz));
+ }
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return context->String("");
+}
+
+RexxRoutine1(int, rx3270IsProtected, int, baddr)
+{
+ try
+ {
+ return session::get_default()->get_is_protected(baddr);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return -1;
+}
+
+RexxRoutine2(int, rx3270IsProtectedAt, int, row, int, col)
+{
+ try
+ {
+ return session::get_default()->get_is_protected_at(row,col);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return -1;
+}
+
+RexxRoutine1(int, rx3270SetUnlockDelay, int, delay)
+{
+ try
+ {
+ session::get_default()->set_unlock_delay((unsigned short) delay);
+ }
+ catch(std::exception &e)
+ {
+ context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
+ }
+
+ return 0;
+}
+
diff --git a/src/include/rx3270.h b/src/include/rx3270.h
new file mode 100644
index 0000000..8ee1843
--- /dev/null
+++ b/src/include/rx3270.h
@@ -0,0 +1,142 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como private.h e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+#ifndef RX3270_H_INCLUDED
+
+ #define RX3270_H_INCLUDED 1
+
+ #define ENABLE_NLS
+ #define GETTEXT_PACKAGE "pw3270"
+
+ #include
+ #include
+ #include
+
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+/*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/
+
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270version);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270QueryCState);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Disconnect);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Connect);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270isConnected);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForEvents);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Sleep);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendENTERKey);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPFKey);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPAKey);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForTerminalReady);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForStringAt);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270GetStringAt);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsTerminalReady);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270CloseApplication);
+ REXX_TYPED_ROUTINE_PROTOTYPE(ebc2asc);
+ REXX_TYPED_ROUTINE_PROTOTYPE(asc2ebc);
+
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Erase);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOF);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOL);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseInput);
+
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtected);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtectedAt);
+ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetUnlockDelay);
+
+ REXX_METHOD_PROTOTYPE(rx3270_method_version);
+ REXX_METHOD_PROTOTYPE(rx3270_method_revision);
+ REXX_METHOD_PROTOTYPE(rx3270_method_init);
+ REXX_METHOD_PROTOTYPE(rx3270_method_uninit);
+ REXX_METHOD_PROTOTYPE(rx3270_method_connect);
+ REXX_METHOD_PROTOTYPE(rx3270_method_disconnect);
+ REXX_METHOD_PROTOTYPE(rx3270_method_sleep);
+ REXX_METHOD_PROTOTYPE(rx3270_method_is_connected);
+ REXX_METHOD_PROTOTYPE(rx3270_method_is_ready);
+ REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_ready);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
+ REXX_METHOD_PROTOTYPE(rx3270_method_enter);
+ REXX_METHOD_PROTOTYPE(rx3270_method_erase);
+ REXX_METHOD_PROTOTYPE(rx3270_method_erase_eof);
+ REXX_METHOD_PROTOTYPE(rx3270_method_erase_eol);
+ REXX_METHOD_PROTOTYPE(rx3270_method_erase_input);
+ REXX_METHOD_PROTOTYPE(rx3270_method_pfkey);
+ REXX_METHOD_PROTOTYPE(rx3270_method_pakey);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_text);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_text_at);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_text_at);
+ REXX_METHOD_PROTOTYPE(rx3270_method_cmp_text_at);
+ REXX_METHOD_PROTOTYPE(rx3270_method_event_trace);
+ REXX_METHOD_PROTOTYPE(rx3270_method_screen_trace);
+ REXX_METHOD_PROTOTYPE(rx3270_method_ds_trace);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_option);
+ REXX_METHOD_PROTOTYPE(rx3270_method_test);
+ REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_text_at);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_field_len);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_field_start);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_next_unprotected);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected_at);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_selection);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_selection);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard);
+ REXX_METHOD_PROTOTYPE(rx3270_method_popup);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_filename);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
+ REXX_METHOD_PROTOTYPE(rx3270_method_input_text);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_display_charset);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_display_charset);
+ REXX_METHOD_PROTOTYPE(rx3270_method_get_host_charset);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_host_charset);
+ REXX_METHOD_PROTOTYPE(rx3270_method_set_unlock_delay);
+
+/*--[ 3270 Session ]-----------------------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+ LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option);
+ LIB3270_EXPORT void rx3270_set_session(H3270 *session);
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif // RX3270_H_INCLUDED
diff --git a/src/plugin.cc b/src/plugin.cc
deleted file mode 100644
index a5c1234..0000000
--- a/src/plugin.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como rexx_methods.cc e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * Referencias:
- *
- * * http://www.oorexx.org/docs/rexxpg/x2950.htm
- *
- */
-
- #include "private.h"
-
-
-/*---[ Implement ]----------------------------------------------------------------------------------*/
-
-
-
-
diff --git a/src/plugin/plugin.cc b/src/plugin/plugin.cc
new file mode 100644
index 0000000..8305171
--- /dev/null
+++ b/src/plugin/plugin.cc
@@ -0,0 +1,395 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como rexx_methods.cc e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ *
+ * Referencias:
+ *
+ * * http://www.oorexx.org/docs/rexxpg/x2950.htm
+ *
+ */
+
+ #include "private.h"
+ #include
+ #include
+ #include
+
+/*--[ Globals ]--------------------------------------------------------------------------------------*/
+
+#if GTK_CHECK_VERSION(2,32,0)
+ static GMutex mutex;
+#else
+ static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+#endif // GTK_CHECK_VERSION
+
+ static gchar * script_name = NULL;
+
+/*--[ Rexx application data block ]--------------------------------------------------------------------------*/
+
+ struct rexx_application_data {
+ GtkAction * action;
+ GtkWidget * widget;
+ GtkWidget * trace;
+ const gchar * filename;
+ };
+
+/*---[ Implement ]----------------------------------------------------------------------------------*/
+
+ static void trace_cleanup(GtkWidget *widget, gpointer dunno) {
+
+ rexx_application_data *data = (rexx_application_data *) g_object_get_data(G_OBJECT(widget),"rexx_app_data");
+
+ trace("%s: data=%p",__FUNCTION__,data);
+
+ if(data)
+ data->trace = NULL;
+
+ }
+
+ static GtkWidget * get_trace_window(rexx_application_data *data) {
+
+ if(data->trace)
+ return data->trace;
+
+ data->trace = pw3270_trace_new();
+ g_signal_connect(G_OBJECT(data->trace), "destroy",G_CALLBACK(trace_cleanup), NULL);
+
+ pw3270_trace_set_destroy_on_close(data->trace,TRUE);
+
+ g_object_set_data(G_OBJECT(data->trace),"rexx_app_data",data);
+
+ gtk_window_set_title(GTK_WINDOW(data->trace),_("Rexx trace"));
+
+ gtk_window_set_transient_for(GTK_WINDOW(data->trace),GTK_WINDOW(gtk_widget_get_toplevel(data->widget)));
+ gtk_window_set_destroy_with_parent(GTK_WINDOW(data->trace),TRUE);
+
+
+ gtk_window_set_default_size(GTK_WINDOW(data->trace),590,430);
+ gtk_widget_show_all(data->trace);
+ return data->trace;
+ }
+
+ static void read_line(struct rexx_application_data *data, PRXSTRING Retstr) {
+
+ gchar *value = pw3270_trace_get_command(get_trace_window(data));
+
+ if(value) {
+
+ if(strlen(value) > (RXAUTOBUFLEN-1))
+ {
+ Retstr->strptr = (char *) RexxAllocateMemory(strlen(value)+1);
+ strcpy(Retstr->strptr,value);
+ }
+ else
+ {
+ g_snprintf(Retstr->strptr,RXAUTOBUFLEN-1,"%s",value);
+ }
+ g_free(value);
+
+ } else {
+
+ *Retstr->strptr = 0;
+
+ }
+
+ Retstr->strlength = strlen(Retstr->strptr);
+
+ }
+
+ static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) {
+
+// trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction);
+
+ switch(subfunction)
+ {
+ case RXSIOSAY: // SAY a line to STDOUT
+ {
+ struct rexx_application_data *data = (struct rexx_application_data *) context->GetApplicationData();
+
+ GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(data->widget)),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK_CANCEL,
+ "%s", (((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr );
+
+ gtk_window_set_title(GTK_WINDOW(dialog), _( "Script message" ) );
+
+ if(data->trace)
+ pw3270_trace_printf(data->trace,"%s\n",(((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr);
+
+ if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL)
+ context->RaiseException0(Rexx_Error_Program_interrupted);
+
+ gtk_widget_destroy(dialog);
+ }
+ break;
+
+ case RXSIOTRC: // Trace output
+ {
+ struct rexx_application_data *data = (struct rexx_application_data *) context->GetApplicationData();
+ lib3270_write_log(NULL, "rx3270", "%s", (((RXSIOTRC_PARM *) parmBlock)->rxsio_string).strptr);
+ pw3270_trace_printf(get_trace_window(data),"%s\n",(((RXSIOTRC_PARM *) parmBlock)->rxsio_string).strptr);
+ }
+ break;
+
+ case RXSIOTRD: // Read from char stream
+ read_line((struct rexx_application_data *) context->GetApplicationData(), & (((RXSIODTR_PARM *) parmBlock)->rxsiodtr_retc) );
+ break;
+
+ case RXSIODTR: // DEBUG read from char stream
+ read_line((struct rexx_application_data *) context->GetApplicationData(), & (((RXSIODTR_PARM *) parmBlock)->rxsiodtr_retc) );
+ break;
+
+ default:
+ return RXEXIT_NOT_HANDLED;
+
+ }
+
+ return RXEXIT_HANDLED;
+ }
+
+ static void call_rexx_script(GtkAction *action, GtkWidget *widget, const gchar *filename) {
+
+ const gchar * args = (const gchar *) g_object_get_data(G_OBJECT(action),"args");
+
+ struct rexx_application_data appdata;
+
+ RexxInstance * instance;
+ RexxThreadContext * threadContext;
+ RexxOption options[25];
+ RexxContextExit exits[2];
+
+ memset(&appdata,0,sizeof(appdata));
+ appdata.action = action;
+ appdata.widget = widget;
+ appdata.filename = filename;
+
+ memset(options,0,sizeof(options));
+ memset(exits,0,sizeof(exits));
+
+ exits[0].sysexit_code = RXSIO;
+ exits[0].handler = Rexx_IO_exit;
+
+ // http://www.oorexx.org/docs/rexxpg/c2539.htm
+
+ options[0].optionName = DIRECT_EXITS;
+ options[0].option = (void *) exits;
+
+ options[1].optionName = APPLICATION_DATA;
+ options[1].option = (void *) &appdata;
+
+ rx3270_set_package_option(&options[2]);
+
+ options[3].optionName = EXTERNAL_CALL_PATH;
+ options[3].option = pw3270_get_datadir(NULL);
+
+ trace("Rexxdir: \"%s\"",(gchar *) ((void *) options[3].option));
+
+ if(!RexxCreateInterpreter(&instance, &threadContext, options)) {
+
+ GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CANCEL,
+ _( "Can't start %s script" ), "rexx" );
+
+ gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" ));
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),_( "Can't create %s interpreter instance" ), "rexx");
+
+ gtk_dialog_run(GTK_DIALOG (dialog));
+ gtk_widget_destroy(dialog);
+
+ } else {
+
+ RexxArrayObject rxArgs;
+
+ trace("%s %s(%s)",__FUNCTION__,filename,args);
+
+ if(args) {
+
+ gchar **arg = g_strsplit(args,",",-1);
+ size_t sz = g_strv_length(arg);
+
+ rxArgs = threadContext->NewArray(sz);
+ for(unsigned int i = 0; iArrayPut(rxArgs, threadContext->String(arg[i]), i + 1);
+
+ g_strfreev(arg);
+
+ } else {
+
+ rxArgs = threadContext->NewArray(1);
+ threadContext->ArrayPut(rxArgs, threadContext->String(""),1);
+ }
+
+ v3270_set_script(widget,'R',TRUE);
+ script_name = g_path_get_basename(filename);
+ trace("%s: Calling",filename);
+ RexxObjectPtr result = threadContext->CallProgram(filename, rxArgs);
+ trace("%s: Returns",filename);
+ g_free(script_name);
+ script_name = NULL;
+ v3270_set_script(widget,'R',FALSE);
+
+ if (threadContext->CheckCondition()) {
+
+ RexxCondition condition;
+
+ // retrieve the error information and get it into a decoded form
+ RexxDirectoryObject cond = threadContext->GetConditionInfo();
+ threadContext->DecodeConditionInfo(cond, &condition);
+ // display the errors
+ GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CANCEL,
+ _( "%s script failed" ), "Rexx" );
+
+ gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" ));
+
+ gtk_message_dialog_format_secondary_text(
+ GTK_MESSAGE_DIALOG(dialog),
+ _( "%s error %d: %s\n%s" ),
+ "Rexx",
+ (int) condition.code,
+ threadContext->CString(condition.errortext),
+ threadContext->CString(condition.message)
+
+ );
+
+ gtk_dialog_run(GTK_DIALOG (dialog));
+ gtk_widget_destroy(dialog);
+
+ } else if (result != NULLOBJECT) {
+
+ CSTRING resultString = threadContext->CString(result);
+ lib3270_write_log(NULL,"REXX","%s exits with rc=%s",filename,resultString);
+ }
+
+ instance->Terminate();
+
+ if(appdata.trace) {
+
+ pw3270_trace_printf(appdata.trace,"%s","** Rexx script ends\n");
+ g_object_set_data(G_OBJECT(appdata.trace),"rexx_app_data",NULL);
+
+ }
+
+ trace("%s ends",__FUNCTION__);
+ }
+
+ g_free(options[3].option);
+
+ }
+
+
+extern "C" {
+
+ LIB3270_EXPORT int pw3270_plugin_start(GtkWidget *window, GtkWidget *terminal) {
+
+ trace("%s",__FUNCTION__);
+
+#if GTK_CHECK_VERSION(2,32,0)
+ g_mutex_init(&mutex);
+#endif // GTK_CHECK_VERSION
+
+ rx3270_set_session(lib3270_get_default_session_handle());
+
+ return 0;
+ }
+
+ LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget *window, GtkWidget *terminal) {
+#if GTK_CHECK_VERSION(2,32,0)
+ g_mutex_clear(&mutex);
+#endif // GTK_CHECK_VERSION
+
+ trace("%s",__FUNCTION__);
+
+ return 0;
+ }
+
+ LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget) {
+
+ gchar *filename = (gchar *) g_object_get_data(G_OBJECT(action),"src");
+
+ lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p",gtk_action_get_name(action),widget);
+
+#if GTK_CHECK_VERSION(2,32,0)
+ if(!g_mutex_trylock(&mutex))
+#else
+ if(!g_static_mutex_trylock(&mutex))
+#endif // GTK_CHECK_VERSION
+ {
+ GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CANCEL,
+ "%s", _( "Can't start script" ));
+
+ gtk_window_set_title(GTK_WINDOW(dialog),_( "System busy" ));
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",_( "Please, try again in a few moments" ));
+
+ gtk_dialog_run(GTK_DIALOG (dialog));
+ gtk_widget_destroy(dialog);
+ return;
+ }
+
+ pw3270_set_action_state(action,FALSE);
+
+ if(filename && *filename) {
+
+ // Has filename, call it directly
+ call_rexx_script(action,widget,filename);
+
+ } else {
+
+ filename = pw3270_file_chooser(GTK_FILE_CHOOSER_ACTION_OPEN, "rexx", _( "Select script to run" ), NULL, "rex");
+
+ if(filename) {
+
+ if(*filename) {
+ call_rexx_script(action,widget,filename);
+ }
+ g_free(filename);
+ }
+
+
+ }
+
+ pw3270_set_action_state(action,TRUE);
+
+#if GTK_CHECK_VERSION(2,32,0)
+ g_mutex_unlock(&mutex);
+#else
+ g_static_mutex_unlock(&mutex);
+#endif // GTK_CHECK_VERSION
+
+ }
+
+}
+
+
+
diff --git a/src/private.h b/src/private.h
deleted file mode 100644
index b94e51d..0000000
--- a/src/private.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como private.h e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
-#ifndef RX3270_H_INCLUDED
-
- #define RX3270_H_INCLUDED 1
-
- #define ENABLE_NLS
- #define GETTEXT_PACKAGE "pw3270"
-
- #include
- #include
- #include
-
- #include
- #include
- #include
- #include
- #include
- #include
-
-/*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/
-
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270version);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270QueryCState);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Disconnect);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Connect);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270isConnected);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForEvents);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Sleep);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendENTERKey);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPFKey);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SendPAKey);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForTerminalReady);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForStringAt);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270GetStringAt);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsTerminalReady);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270CloseApplication);
- REXX_TYPED_ROUTINE_PROTOTYPE(ebc2asc);
- REXX_TYPED_ROUTINE_PROTOTYPE(asc2ebc);
-
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270Erase);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOF);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOL);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseInput);
-
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtected);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtectedAt);
- REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetUnlockDelay);
-
- REXX_METHOD_PROTOTYPE(rx3270_method_version);
- REXX_METHOD_PROTOTYPE(rx3270_method_revision);
- REXX_METHOD_PROTOTYPE(rx3270_method_init);
- REXX_METHOD_PROTOTYPE(rx3270_method_uninit);
- REXX_METHOD_PROTOTYPE(rx3270_method_connect);
- REXX_METHOD_PROTOTYPE(rx3270_method_disconnect);
- REXX_METHOD_PROTOTYPE(rx3270_method_sleep);
- REXX_METHOD_PROTOTYPE(rx3270_method_is_connected);
- REXX_METHOD_PROTOTYPE(rx3270_method_is_ready);
- REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_ready);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
- REXX_METHOD_PROTOTYPE(rx3270_method_enter);
- REXX_METHOD_PROTOTYPE(rx3270_method_erase);
- REXX_METHOD_PROTOTYPE(rx3270_method_erase_eof);
- REXX_METHOD_PROTOTYPE(rx3270_method_erase_eol);
- REXX_METHOD_PROTOTYPE(rx3270_method_erase_input);
- REXX_METHOD_PROTOTYPE(rx3270_method_pfkey);
- REXX_METHOD_PROTOTYPE(rx3270_method_pakey);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_text);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_text_at);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_text_at);
- REXX_METHOD_PROTOTYPE(rx3270_method_cmp_text_at);
- REXX_METHOD_PROTOTYPE(rx3270_method_event_trace);
- REXX_METHOD_PROTOTYPE(rx3270_method_screen_trace);
- REXX_METHOD_PROTOTYPE(rx3270_method_ds_trace);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_option);
- REXX_METHOD_PROTOTYPE(rx3270_method_test);
- REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_text_at);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_field_len);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_field_start);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_next_unprotected);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected_at);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_selection);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_selection);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard);
- REXX_METHOD_PROTOTYPE(rx3270_method_popup);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_filename);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
- REXX_METHOD_PROTOTYPE(rx3270_method_input_text);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_display_charset);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_display_charset);
- REXX_METHOD_PROTOTYPE(rx3270_method_get_host_charset);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_host_charset);
- REXX_METHOD_PROTOTYPE(rx3270_method_set_unlock_delay);
-
-/*--[ 3270 Session ]-----------------------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
- LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option);
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif // RX3270_H_INCLUDED
diff --git a/src/rexx_methods.cc b/src/rexx_methods.cc
deleted file mode 100644
index e230714..0000000
--- a/src/rexx_methods.cc
+++ /dev/null
@@ -1,648 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como rexx_methods.cc e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * Referencias:
- *
- * * http://www.oorexx.org/docs/rexxpg/x2950.htm
- *
- */
-
- #include "private.h"
- #include
- #include
- #include
-
- using namespace std;
- using namespace PW3270_NAMESPACE;
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-RexxMethod1(int, rx3270_method_init, OPTIONAL_CSTRING, type)
-{
- // Set session class in rexx object
- try
- {
- if(!(type && *type))
- type = "";
- RexxPointerObject sessionPtr = context->NewPointer(session::create(type));
- context->SetObjectVariable("CSELF", sessionPtr);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return 0;
-}
-
-RexxMethod1(int, rx3270_method_uninit, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
-
- trace("rx3270_method_uninit hSession=%p",hSession);
-
- if(hSession)
- delete hSession;
-
- trace("%s","rx3270_method_uninit");
- return 0;
-}
-
-RexxMethod1(RexxStringObject, rx3270_method_version, CSELF, sessionPtr)
-{
- session * hSession = (session *) sessionPtr;
-
- if(hSession)
- return context->String((CSTRING) hSession->get_version().c_str());
-
- return context->String((CSTRING) PACKAGE_VERSION);
-}
-
-RexxMethod1(RexxStringObject, rx3270_method_revision, CSELF, sessionPtr)
-{
- session * hSession = (session *) sessionPtr;
-
- if(hSession)
- return context->String((CSTRING) hSession->get_revision().c_str());
-
- return context->String((CSTRING) PACKAGE_REVISION);
-}
-
-RexxMethod3(int, rx3270_method_connect, CSELF, sessionPtr, CSTRING, uri, OPTIONAL_int, wait)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
-
- return hSession->connect(uri,wait != 0);
-}
-
-RexxMethod1(int, rx3270_method_disconnect, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->disconnect();
-}
-
-RexxMethod2(int, rx3270_method_sleep, CSELF, sessionPtr, int, seconds)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->wait(seconds);
-}
-
-RexxMethod1(logical_t, rx3270_method_is_connected, CSELF, sessionPtr)
-{
- try
- {
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return false;
- return hSession->is_connected();
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return 0;
-}
-
-RexxMethod1(logical_t, rx3270_method_is_ready, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return false;
- return hSession->is_ready();
-}
-
-RexxMethod2(int, rx3270_method_wait_for_ready, CSELF, sessionPtr, OPTIONAL_int, seconds)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->wait_for_ready(seconds > 0 ? seconds : 60);
-}
-
-RexxMethod3(int, rx3270_method_set_cursor, CSELF, sessionPtr, int, row, int, col)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->set_cursor_position(row,col);
-}
-
-RexxMethod1(int, rx3270_method_get_cursor_addr, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->get_cursor_addr();
-}
-
-RexxMethod2(int, rx3270_method_set_cursor_addr, CSELF, sessionPtr, int, addr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->set_cursor_addr(addr);
-}
-
-RexxMethod1(int, rx3270_method_enter, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->enter();
-}
-
-RexxMethod1(int, rx3270_method_erase, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->erase();
-}
-
-RexxMethod1(int, rx3270_method_erase_eof, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->erase_eof();
-}
-
-RexxMethod1(int, rx3270_method_erase_eol, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->erase_eol();
-}
-
-RexxMethod1(int, rx3270_method_erase_input, CSELF, sessionPtr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->erase_input();
-}
-
-
-RexxMethod2(int, rx3270_method_pfkey, CSELF, sessionPtr, int, key)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->pfkey(key);
-}
-
-RexxMethod2(int, rx3270_method_pakey, CSELF, sessionPtr, int, key)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->pakey(key);
-}
-
-RexxMethod4(RexxStringObject, rx3270_method_get_text_at, CSELF, sessionPtr, int, row, int, col, int, sz)
-{
-
- try
- {
- session * hSession = (session *) sessionPtr;
- string str = hSession->get_string_at(row,col,sz);
- return context->String((CSTRING) str.c_str());
-
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return context->String("");
-}
-
-
-RexxMethod4(int, rx3270_method_set_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, text)
-{
- try
- {
- session * hSession = (session *) sessionPtr;
- return hSession->set_string_at(row,col,text);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return -1;
-}
-
-RexxMethod2(int, rx3270_method_input_text, CSELF, sessionPtr, CSTRING, text)
-{
- try
- {
- session * hSession = (session *) sessionPtr;
- return hSession->input_string(text);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return -1;
-
-}
-
-RexxMethod4(int, rx3270_method_cmp_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key)
-{
- try
- {
- session * hSession = (session *) sessionPtr;
- return hSession->cmp_string_at(row,col,key);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
- return -1;
-}
-
-RexxMethod2(int, rx3270_method_event_trace, CSELF, sessionPtr, int, flag)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- hSession->set_toggle(LIB3270_TOGGLE_EVENT_TRACE,flag);
- return 0;
-}
-
-RexxMethod2(int, rx3270_method_screen_trace, CSELF, sessionPtr, int, flag)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- hSession->set_toggle(LIB3270_TOGGLE_SCREEN_TRACE,flag);
- return 0;
-
-}
-
-RexxMethod2(int, rx3270_method_ds_trace, CSELF, sessionPtr, int, flag)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- hSession->set_toggle(LIB3270_TOGGLE_DS_TRACE,flag);
- return 0;
-}
-
-RexxMethod3(int, rx3270_method_set_option, CSELF, sessionPtr, CSTRING, name, int, flag)
-{
- static const struct _toggle_info
- {
- const char * name;
- LIB3270_TOGGLE id;
- }
- toggle[LIB3270_TOGGLE_COUNT] =
- {
- { "monocase", LIB3270_TOGGLE_MONOCASE },
- { "cursorblink", LIB3270_TOGGLE_CURSOR_BLINK },
- { "showtiming", LIB3270_TOGGLE_SHOW_TIMING },
- { "cursorpos", LIB3270_TOGGLE_CURSOR_POS },
- { "dstrace", LIB3270_TOGGLE_DS_TRACE },
- { "linewrap", LIB3270_TOGGLE_LINE_WRAP },
- { "blankfill", LIB3270_TOGGLE_BLANK_FILL },
- { "screentrace", LIB3270_TOGGLE_SCREEN_TRACE },
- { "eventtrace", LIB3270_TOGGLE_EVENT_TRACE },
- { "marginedpaste", LIB3270_TOGGLE_MARGINED_PASTE },
- { "rectselect", LIB3270_TOGGLE_RECTANGLE_SELECT },
- { "crosshair", LIB3270_TOGGLE_CROSSHAIR },
- { "fullscreen", LIB3270_TOGGLE_FULL_SCREEN },
- { "reconnect", LIB3270_TOGGLE_RECONNECT },
- { "insert", LIB3270_TOGGLE_INSERT },
- { "smartpaste", LIB3270_TOGGLE_SMART_PASTE },
- { "bold", LIB3270_TOGGLE_BOLD },
- { "keepselected", LIB3270_TOGGLE_KEEP_SELECTED },
- { "underline", LIB3270_TOGGLE_UNDERLINE },
- { "autoconnect", LIB3270_TOGGLE_CONNECT_ON_STARTUP },
- { "kpalternative", LIB3270_TOGGLE_KP_ALTERNATIVE },
- { "beep", LIB3270_TOGGLE_BEEP },
- { "fieldattr", LIB3270_TOGGLE_VIEW_FIELD },
- { "altscreen", LIB3270_TOGGLE_ALTSCREEN },
- { "keepalive", LIB3270_TOGGLE_KEEP_ALIVE },
- };
-
- session *hSession = (session *) sessionPtr;
- if(hSession)
- {
- for(int f = 0; f < LIB3270_TOGGLE_COUNT; f++)
- {
- if(!strcasecmp(name,toggle[f].name))
- {
- hSession->set_toggle(toggle[f].id,flag);
- return 0;
- }
- }
- return ENOENT;
- }
- return -1;
-}
-
-
-RexxMethod4(logical_t, rx3270_method_test, CSELF, sessionPtr, CSTRING, key, int, row, int, col)
-{
- try
- {
- session * hSession = (session *) sessionPtr;
-
- if(!hSession->is_ready())
- hSession->iterate(false);
-
- if(hSession->is_ready())
- {
- string str = hSession->get_string_at(row,col,strlen(key));
- return (strcasecmp(str.c_str(),key) == 0);
- }
-
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return false;
-}
-
-RexxMethod5(int, rx3270_method_wait_for_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key, int, timeout)
-{
- try
- {
- session * hSession = (session *) sessionPtr;
- return hSession->wait_for_string_at(row,col,key,timeout);
-
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return -1;
-}
-
-RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONAL_int, baddr, OPTIONAL_int, sz)
-{
- try
- {
- session * hSession = (session *) sessionPtr;
- string str = hSession->get_string(baddr,sz > 0 ? sz : -1);
- return context->String((CSTRING) str.c_str());
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return context->String("");
-}
-
-
-RexxMethod2(int, rx3270_method_get_field_len, CSELF, sessionPtr, OPTIONAL_int, baddr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->get_field_len(baddr);
-}
-
-RexxMethod2(int, rx3270_method_get_field_start, CSELF, sessionPtr, OPTIONAL_int, baddr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
- return hSession->get_field_start(baddr)+1;
-}
-
-RexxMethod2(int, rx3270_method_get_next_unprotected, CSELF, sessionPtr, OPTIONAL_int, baddr)
-{
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
-
- baddr = hSession->get_next_unprotected(baddr);
- if(baddr < 1)
- return -1;
-
- return baddr;
-}
-
-RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int, baddr)
-{
-
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
-
- return hSession->get_is_protected(baddr);
-}
-
-RexxMethod3(int, rx3270_method_get_is_protected_at, CSELF, sessionPtr, int, row, int, col)
-{
-
- session *hSession = (session *) sessionPtr;
- if(!hSession)
- return -1;
-
- return hSession->get_is_protected_at(row,col);
-}
-
-
-RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr)
-{
- try
- {
- string str = ((session *) sessionPtr)->get_copy();
- return context->String((CSTRING) str.c_str());
-
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return context->String("");
-}
-
-RexxMethod2(int, rx3270_method_set_selection, CSELF, sessionPtr, CSTRING, text)
-{
- try
- {
- return ((session *) sessionPtr)->set_copy(text);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return -1;
-}
-
-RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr)
-{
- session * hSession = (session *) sessionPtr;
-
- if(hSession)
- {
- string str = hSession->get_clipboard();
- return context->String((CSTRING) str.c_str());
- }
-
- trace("%s","rx3270_method_get_clipboard: Clipboard is empty");
- return context->String("");
-}
-
-RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text)
-{
- return ((session *) sessionPtr)->set_clipboard(text);
-}
-
-RexxMethod5(int, rx3270_method_popup, CSELF, sessionPtr, CSTRING, s_id, CSTRING, title, CSTRING, message, OPTIONAL_CSTRING, det)
-{
- LIB3270_NOTIFY id = LIB3270_NOTIFY_INFO;
- session * hSession = (session *) sessionPtr;
-
- if(!hSession)
- return -1;
-
- if(*s_id)
- {
- static const struct _descr
- {
- char str;
- LIB3270_NOTIFY id;
- } descr[] =
- {
- { 'I', LIB3270_NOTIFY_INFO },
- { 'W', LIB3270_NOTIFY_WARNING },
- { 'E', LIB3270_NOTIFY_ERROR },
- { 'C', LIB3270_NOTIFY_CRITICAL },
- };
-
- for(int f=0;f<4;f++)
- {
- if(toupper(*s_id) == descr[f].str)
- {
- id = descr[f].id;
- trace("Using mode %c (%d)",toupper(*s_id),(int) id);
- }
- }
- }
-
- return hSession->popup_dialog(id, title, message, "%s", det ? det : "");
-}
-
-RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CSTRING, action_name, CSTRING, title, OPTIONAL_CSTRING, extension, OPTIONAL_CSTRING, filename)
-{
-/*
- static const struct _action
- {
- const cchar * action_name;
- GtkFileChooserAction id;
- } action[] =
- {
- { "open", GTK_FILE_CHOOSER_ACTION_OPEN },
- { "save", GTK_FILE_CHOOSER_ACTION_SAVE },
- { "folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER },
- { "select_folder", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER },
- { "create_folder", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER }
- };
-
- GtkFileChooserAction id = GTK_FILE_CHOOSER_ACTION_OPEN;
- string ret;
-
- for(int f=0;f<5;f++)
- {
- if(!strcasecmp(action_name,action[f].action_name))
- {
- id = action[f].id;
- break;
- }
- }
-
- debug("%s(%s)","rx3270_method_get_filename",action_name);
- ret = ((session *) sessionPtr)->file_chooser_dialog(id, title, extension,filename);
- debug("%s(%s)","rx3270_method_get_filename",action_name);
-
- return context->String(ret.c_str());
-*/
- return context->String("");
-}
-
-RexxMethod2(int, rx3270_method_set_host_charset, CSELF, sessionPtr, CSTRING, text)
-{
- return ((session *) sessionPtr)->set_host_charset(text);
-}
-
-RexxMethod1(RexxStringObject, rx3270_method_get_host_charset, CSELF, sessionPtr)
-{
- string ret = ((session *) sessionPtr)->get_host_charset();
- return context->String(ret.c_str());
-}
-
-RexxMethod1(RexxStringObject, rx3270_method_get_display_charset, CSELF, sessionPtr)
-{
- string ret = ((session *) sessionPtr)->get_display_charset();
- return context->String(ret.c_str());
-}
-
-RexxMethod2(int, rx3270_method_set_display_charset, CSELF, sessionPtr, CSTRING, text)
-{
- ((session *) sessionPtr)->set_display_charset(NULL,text);
- return 0;
-}
-
-RexxMethod2(int, rx3270_method_set_unlock_delay, CSELF, sessionPtr, int, delay)
-{
- session *hSession = (session *) sessionPtr;
-
- if(!hSession)
- return -1;
-
- try
- {
- hSession->set_unlock_delay((unsigned short) delay);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return 0;
-}
diff --git a/src/rx3270.cc b/src/rx3270.cc
deleted file mode 100644
index 909467b..0000000
--- a/src/rx3270.cc
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como rx3270.c e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
- /*
- *
- * Reference:
- *
- * http://www.oorexx.org/docs/rexxpg/x2950.htm
- *
- */
-
- #include "private.h"
-
-/*--[ Globals ]--------------------------------------------------------------------------------------*/
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-// now build the actual entry list
-RexxRoutineEntry rx3270_functions[] =
-{
- REXX_TYPED_ROUTINE(rx3270version, rx3270version),
- REXX_TYPED_ROUTINE(rx3270QueryCState, rx3270QueryCState),
- REXX_TYPED_ROUTINE(rx3270Disconnect, rx3270Disconnect),
- REXX_TYPED_ROUTINE(rx3270Connect, rx3270Connect),
- REXX_TYPED_ROUTINE(rx3270isConnected, rx3270isConnected),
- REXX_TYPED_ROUTINE(rx3270WaitForEvents, rx3270WaitForEvents),
- REXX_TYPED_ROUTINE(rx3270Sleep, rx3270Sleep),
- REXX_TYPED_ROUTINE(rx3270SendENTERKey, rx3270SendENTERKey),
- REXX_TYPED_ROUTINE(rx3270SendPFKey, rx3270SendPFKey),
- REXX_TYPED_ROUTINE(rx3270SendPAKey, rx3270SendPAKey),
- REXX_TYPED_ROUTINE(rx3270WaitForTerminalReady, rx3270WaitForTerminalReady),
- REXX_TYPED_ROUTINE(rx3270WaitForStringAt, rx3270WaitForStringAt),
- REXX_TYPED_ROUTINE(rx3270GetStringAt, rx3270GetStringAt),
- REXX_TYPED_ROUTINE(rx3270IsTerminalReady, rx3270IsTerminalReady),
- REXX_TYPED_ROUTINE(rx3270queryStringAt, rx3270queryStringAt),
- REXX_TYPED_ROUTINE(rx3270SetStringAt, rx3270SetStringAt),
- REXX_TYPED_ROUTINE(rx3270CloseApplication, rx3270CloseApplication),
-
- REXX_TYPED_ROUTINE(rx3270Erase, rx3270Erase),
- REXX_TYPED_ROUTINE(rx3270EraseEOF, rx3270EraseEOF),
- REXX_TYPED_ROUTINE(rx3270EraseEOL, rx3270EraseEOL),
- REXX_TYPED_ROUTINE(rx3270EraseInput, rx3270EraseInput),
-
- REXX_TYPED_ROUTINE(rx3270IsProtected, rx3270IsProtected),
- REXX_TYPED_ROUTINE(rx3270IsProtectedAt, rx3270IsProtectedAt),
- REXX_TYPED_ROUTINE(rx3270SetUnlockDelay, rx3270SetUnlockDelay),
-
- REXX_TYPED_ROUTINE(ebc2asc, ebc2asc),
- REXX_TYPED_ROUTINE(asc2ebc, asc2ebc),
-
-
- // rx3270Popup
- REXX_LAST_METHOD()
-};
-
-RexxMethodEntry rx3270_methods[] =
-{
- REXX_METHOD(rx3270_method_version, rx3270_method_version ),
- REXX_METHOD(rx3270_method_revision, rx3270_method_revision ),
- REXX_METHOD(rx3270_method_init, rx3270_method_init ),
- REXX_METHOD(rx3270_method_uninit, rx3270_method_uninit ),
- REXX_METHOD(rx3270_method_connect, rx3270_method_connect ),
- REXX_METHOD(rx3270_method_disconnect, rx3270_method_disconnect ),
- REXX_METHOD(rx3270_method_sleep, rx3270_method_sleep ),
- REXX_METHOD(rx3270_method_is_connected, rx3270_method_is_connected ),
- REXX_METHOD(rx3270_method_is_ready, rx3270_method_is_ready ),
- REXX_METHOD(rx3270_method_wait_for_ready, rx3270_method_wait_for_ready ),
- REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor ),
- REXX_METHOD(rx3270_method_set_cursor, rx3270_method_get_cursor_addr ),
- REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor_addr ),
- REXX_METHOD(rx3270_method_enter, rx3270_method_enter ),
- REXX_METHOD(rx3270_method_enter, rx3270_method_erase ),
- REXX_METHOD(rx3270_method_enter, rx3270_method_erase_eof ),
- REXX_METHOD(rx3270_method_enter, rx3270_method_erase_eol ),
- REXX_METHOD(rx3270_method_enter, rx3270_method_erase_input ),
- REXX_METHOD(rx3270_method_pfkey, rx3270_method_pfkey ),
- REXX_METHOD(rx3270_method_pakey, rx3270_method_pakey ),
- REXX_METHOD(rx3270_method_get_text, rx3270_method_get_text ),
- REXX_METHOD(rx3270_method_get_text_at, rx3270_method_get_text_at ),
- REXX_METHOD(rx3270_method_set_text_at, rx3270_method_set_text_at ),
- REXX_METHOD(rx3270_method_cmp_text_at, rx3270_method_cmp_text_at ),
- REXX_METHOD(rx3270_method_event_trace, rx3270_method_event_trace ),
- REXX_METHOD(rx3270_method_screen_trace, rx3270_method_screen_trace ),
- REXX_METHOD(rx3270_method_ds_trace, rx3270_method_ds_trace ),
- REXX_METHOD(rx3270_method_set_option, rx3270_method_set_option ),
- REXX_METHOD(rx3270_method_test, rx3270_method_test ),
- REXX_METHOD(rx3270_method_wait_for_text_at, rx3270_method_wait_for_text_at ),
-
- REXX_METHOD(rx3270_method_get_field_len, rx3270_method_get_field_len ),
- REXX_METHOD(rx3270_method_get_field_start, rx3270_method_get_field_start ),
- REXX_METHOD(rx3270_method_get_next_unprotected, rx3270_method_get_next_unprotected ),
-
- REXX_METHOD(rx3270_method_get_is_protected, rx3270_method_get_is_protected ),
- REXX_METHOD(rx3270_method_get_is_protected_at, rx3270_method_get_is_protected_at ),
-
- REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ),
- REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ),
- REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ),
- REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ),
-
- REXX_METHOD(rx3270_method_erase, rx3270_method_erase ),
- REXX_METHOD(rx3270_method_erase_eof, rx3270_method_erase_eof ),
- REXX_METHOD(rx3270_method_erase_eol, rx3270_method_erase_eol ),
- REXX_METHOD(rx3270_method_erase_input, rx3270_method_erase_input ),
-
- REXX_METHOD(rx3270_method_popup, rx3270_method_popup ),
- REXX_METHOD(rx3270_method_get_filename, rx3270_method_get_filename ),
-
- REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ),
- REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ),
- REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ),
-
- REXX_METHOD(rx3270_method_get_display_charset, rx3270_method_get_display_charset ),
- REXX_METHOD(rx3270_method_set_display_charset, rx3270_method_set_display_charset ),
-
- REXX_METHOD(rx3270_method_get_host_charset, rx3270_method_get_host_charset ),
- REXX_METHOD(rx3270_method_set_host_charset, rx3270_method_set_host_charset ),
-
- REXX_METHOD(rx3270_method_set_unlock_delay, rx3270_method_set_unlock_delay ),
-
- REXX_LAST_METHOD()
-};
-
-RexxPackageEntry rx3270_package_entry =
-{
- STANDARD_PACKAGE_HEADER
- REXX_CURRENT_INTERPRETER_VERSION, // anything after 4.0.0 will work
- "rx3270", // name of the package
- PACKAGE_VERSION, // package information
- NULL, // no load/unload functions
- NULL,
- rx3270_functions, // the exported functions
- rx3270_methods // no methods in rx3270.
-};
-
-// package loading stub.
-/*
-OOREXX_GET_PACKAGE(rx3270);
-*/
-
-BEGIN_EXTERN_C()
-
-LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option)
-{
- static const RexxLibraryPackage package = { "rx3270", &rx3270_package_entry };
-
- option->optionName = REGISTER_LIBRARY;
- option->option = (void *) &package;
-
-}
-
-LIB3270_EXPORT RexxPackageEntry * RexxEntry RexxGetPackage(void)
-{
- return &rx3270_package_entry;
-}
-
-END_EXTERN_C()
-
-
diff --git a/src/typed_routines.cc b/src/typed_routines.cc
deleted file mode 100644
index d564bca..0000000
--- a/src/typed_routines.cc
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA, 02111-1307, USA
- *
- * Este programa está nomeado como typed_routines.cc e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
- #include "private.h"
- #include
- #include
- #include
- #include
-
- using namespace std;
- using namespace PW3270_NAMESPACE;
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-RexxRoutine0(CSTRING, rx3270version)
-{
- try
- {
- return session::get_default()->get_version().c_str();
- }
- catch(std::exception& e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return NULL;
-}
-
-RexxRoutine0(CSTRING, rx3270QueryCState)
-{
- #define DECLARE_XLAT_STATE( x ) { x, #x }
-
- static const struct _xlat_state
- {
- LIB3270_CSTATE state;
- const char * ret;
- } xlat_state[] =
- {
- { LIB3270_NOT_CONNECTED, "NOT_CONNECTED" },
- { LIB3270_RESOLVING, "RESOLVING" },
- { LIB3270_PENDING, "PENDING" },
- { LIB3270_CONNECTED_INITIAL, "CONNECTED_INITIAL" },
- { LIB3270_CONNECTED_ANSI, "CONNECTED_ANSI" },
- { LIB3270_CONNECTED_3270, "CONNECTED_3270" },
- { LIB3270_CONNECTED_INITIAL_E, "CONNECTED_INITIAL_E" },
- { LIB3270_CONNECTED_NVT, "CONNECTED_NVT" },
- { LIB3270_CONNECTED_SSCP, "CONNECTED_SSCP" },
- { LIB3270_CONNECTED_TN3270E, "CONNECTED_TN3270E" },
- };
-
- size_t f;
- LIB3270_CSTATE state = session::get_default()->get_cstate();
-
- for(f=0;f < (sizeof(xlat_state)/sizeof(struct _xlat_state)); f++)
- {
- if(state == xlat_state[f].state)
- return xlat_state[f].ret;
- }
-
- return "UNEXPECTED";
-}
-
-RexxRoutine0(int, rx3270Disconnect)
-{
- return session::get_default()->disconnect();
-}
-
-RexxRoutine2(int, rx3270Connect, CSTRING, hostname, int, wait)
-{
- return session::get_default()->connect(hostname,wait);
-}
-
-RexxRoutine0(int, rx3270isConnected)
-{
- return session::get_default()->is_connected();
-}
-
-RexxRoutine0(int, rx3270WaitForEvents)
-{
- return session::get_default()->iterate();
-}
-
-RexxRoutine1(int, rx3270Sleep, int, seconds)
-{
- return session::get_default()->wait(seconds);
-}
-
-RexxRoutine0(int, rx3270SendENTERKey)
-{
- return session::get_default()->enter();
-}
-
-RexxRoutine0(int, rx3270Erase)
-{
- return session::get_default()->erase();
-}
-
-RexxRoutine0(int, rx3270EraseEOF)
-{
- return session::get_default()->erase_eof();
-}
-
-RexxRoutine0(int, rx3270EraseEOL)
-{
- return session::get_default()->erase_eol();
-}
-
-RexxRoutine0(int, rx3270EraseInput)
-{
- return session::get_default()->erase_input();
-}
-
-RexxRoutine1(int, rx3270SendPFKey, int, key)
-{
- return session::get_default()->pfkey(key);
-}
-
-RexxRoutine1(int, rx3270SendPAKey, int, key)
-{
- return session::get_default()->pakey(key);
-}
-
-RexxRoutine1(int, rx3270WaitForTerminalReady, int, seconds)
-{
- return session::get_default()->wait_for_ready(seconds);
-}
-
-RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int, timeout)
-{
- try
- {
- return session::get_default()->wait_for_string_at(row,col,key,timeout);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return ETIMEDOUT;
-
-}
-
-RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz)
-{
- try
- {
- string str = session::get_default()->get_string_at(row,col,(int) sz);
- return context->String((CSTRING) str.c_str());
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return context->String("");
-}
-
-RexxRoutine0(int, rx3270IsTerminalReady)
-{
- return session::get_default()->is_ready();
-}
-
-RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key)
-{
- try
- {
- return session::get_default()->cmp_string_at(row,col,key);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return -1;
-}
-
-RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col)
-{
- try
- {
- return session::get_default()->set_cursor_position(row,col);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return -1;
-}
-
-RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text)
-{
- try
- {
- return session::get_default()->set_string_at(row,col,text);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
- return -1;
-}
-
-RexxRoutine0(int, rx3270CloseApplication)
-{
- return session::get_default()->quit();
-}
-
-
-RexxRoutine2(RexxStringObject, asc2ebc, CSTRING, str, OPTIONAL_int, sz)
-{
- try
- {
- if(sz < 1)
- sz = strlen(str);
-
- if(sz)
- {
- char buffer[sz+1];
- memcpy(buffer,str,sz);
- buffer[sz] = 0;
- return context->String((CSTRING) session::get_default()->asc2ebc((unsigned char *)buffer,sz));
- }
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return context->String("");
-}
-
-RexxRoutine2(RexxStringObject, ebc2asc, CSTRING, str, OPTIONAL_int, sz)
-{
- try
- {
- if(sz < 1)
- sz = strlen(str);
-
- if(sz)
- {
- char buffer[sz+1];
- memcpy(buffer,str,sz);
- buffer[sz] = 0;
- return context->String((CSTRING) session::get_default()->ebc2asc((unsigned char *)buffer,sz));
- }
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return context->String("");
-}
-
-RexxRoutine1(int, rx3270IsProtected, int, baddr)
-{
- try
- {
- return session::get_default()->get_is_protected(baddr);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return -1;
-}
-
-RexxRoutine2(int, rx3270IsProtectedAt, int, row, int, col)
-{
- try
- {
- return session::get_default()->get_is_protected_at(row,col);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return -1;
-}
-
-RexxRoutine1(int, rx3270SetUnlockDelay, int, delay)
-{
- try
- {
- session::get_default()->set_unlock_delay((unsigned short) delay);
- }
- catch(std::exception &e)
- {
- context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
- }
-
- return 0;
-}
-
diff --git a/ui/80rexx.xml b/ui/80rexx.xml
new file mode 100644
index 0000000..57e9c3c
--- /dev/null
+++ b/ui/80rexx.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
--
libgit2 0.21.2