diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1315b9e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,21 @@
+Makefile
+*~
+*.bak
+*.layout
+aclocal.m4
+autom4te.cache
+*.log
+config.status
+configure
+config.h
+stamp-h1
+.bin
+.obj
+.src
+*.zip
+*.tar
+*.bz2
+rpm
+*.pc
+*.depend
+
diff --git a/pw3270-rexx.cbp b/pw3270-rexx.cbp
new file mode 100644
index 0000000..708f250
--- /dev/null
+++ b/pw3270-rexx.cbp
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/rexx_methods.cc b/src/rexx_methods.cc
new file mode 100644
index 0000000..de72bb4
--- /dev/null
+++ b/src/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 "rx3270.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.h b/src/rx3270.h
new file mode 100644
index 0000000..38e3c0b
--- /dev/null
+++ b/src/rx3270.h
@@ -0,0 +1,136 @@
+/*
+ * "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 pluginmain.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)
+ *
+ */
+
+#ifndef RX3270_H_INCLUDED
+
+ #define RX3270_H_INCLUDED 1
+
+ #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);
+
+/*---[ Globals ]---------------------------------------------------------------------------------------------*/
+
+/*--[ 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/typed_routines.cc b/src/typed_routines.cc
new file mode 100644
index 0000000..1089fa8
--- /dev/null
+++ b/src/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 "rx3270.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;
+}
+
--
libgit2 0.21.2