diff --git a/pw3270.cbp b/pw3270.cbp
index f6c2e15..54b62c2 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -283,6 +283,7 @@
+
diff --git a/src/plugins/rx3270/Makefile.in b/src/plugins/rx3270/Makefile.in
index ae8986d..7ee8149 100644
--- a/src/plugins/rx3270/Makefile.in
+++ b/src/plugins/rx3270/Makefile.in
@@ -29,7 +29,7 @@
MODULE_NAME=rx3270
DEPENDS=*.h ../../include/*.h ../../include/lib3270/*.h Makefile
PLUGIN_SRC=pluginmain.cc
-EXTAPI_SRC=rxapimain.cc text.cc typed_routines.cc local.cc remote.cc rexx_methods.cc rx3270.cc
+EXTAPI_SRC=rxapimain.cc text.cc typed_routines.cc local.cc remote.cc rexx_methods.cc rx3270.cc exception.cc
#---[ Tools ]------------------------------------------------------------------
diff --git a/src/plugins/rx3270/exception.cc b/src/plugins/rx3270/exception.cc
new file mode 100644
index 0000000..e5b3512
--- /dev/null
+++ b/src/plugins/rx3270/exception.cc
@@ -0,0 +1,86 @@
+/*
+ * "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 exception.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"
+
+#ifdef HAVE_SYSLOG
+ #include
+#endif // HAVE_SYSLOG
+
+ #include
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+rx3270::exception::exception(const char *fmt, ...)
+{
+ char buffer[4096];
+ va_list arg_ptr;
+
+ va_start(arg_ptr, fmt);
+ vsnprintf(buffer,4095,fmt,arg_ptr);
+ va_end(arg_ptr);
+
+ msg = strdup(buffer);
+}
+
+extern "C" {
+ static void memfree(void *ptr)
+ {
+ free(ptr);
+ }
+}
+
+rx3270::exception::~exception()
+{
+ memfree(msg);
+}
+
+const char * rx3270::exception::getMessage(void)
+{
+ return this->msg;
+}
+
+void rx3270::exception::logMessage(void)
+{
+#ifdef HAVE_SYSLOG
+ openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
+ syslog(LOG_INFO,"%s",this->getMessage());
+ closelog();
+#else
+ fprintf(stderr,"%s",this->getMessage());
+#endif
+}
+
+void rx3270::exception::RaiseException(RexxMethodContext *context)
+{
+ // TODO: Raise rexx exception
+ trace("%s: %s",__FUNCTION__,this->getMessage());
+ logMessage();
+}
+
diff --git a/src/plugins/rx3270/rexx_methods.cc b/src/plugins/rx3270/rexx_methods.cc
index 079e0cc..ae1b032 100644
--- a/src/plugins/rx3270/rexx_methods.cc
+++ b/src/plugins/rx3270/rexx_methods.cc
@@ -43,8 +43,16 @@
RexxMethod1(int, rx3270_method_init, CSTRING, type)
{
// Set session class in rexx object
- RexxPointerObject sessionPtr = context->NewPointer(rx3270::create(type));
- context->SetObjectVariable("CSELF", sessionPtr);
+ try
+ {
+ RexxPointerObject sessionPtr = context->NewPointer(rx3270::create(type));
+ context->SetObjectVariable("CSELF", sessionPtr);
+ }
+ catch(rx3270::exception e)
+ {
+ e.RaiseException(context);
+ }
+
return 0;
}
diff --git a/src/plugins/rx3270/rx3270.cc b/src/plugins/rx3270/rx3270.cc
index 16bc2b3..5931fae 100644
--- a/src/plugins/rx3270/rx3270.cc
+++ b/src/plugins/rx3270/rx3270.cc
@@ -118,9 +118,18 @@ char * rx3270::get_revision(void)
rx3270 * rx3270::get_default()
{
- if(defSession)
- return defSession;
- return create_local();
+ try
+ {
+ if(defSession)
+ return defSession;
+ return create_local();
+ }
+ catch(exception e)
+ {
+ e.logMessage();
+ }
+
+ return NULL;
}
void rx3270::log(const char *fmt, ...)
diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h
index 6862404..95ca642 100644
--- a/src/plugins/rx3270/rx3270.h
+++ b/src/plugins/rx3270/rx3270.h
@@ -144,6 +144,22 @@
public:
+ class exception
+ {
+ public:
+ exception(const char *fmt, ...);
+ ~exception();
+
+ const char * getMessage(void);
+ void logMessage(void);
+
+ void RaiseException(RexxMethodContext *context);
+
+ private:
+ char *msg;
+
+ };
+
rx3270(const char *local = REXX_DEFAULT_CHARSET, const char *remote = "ISO-8859-1");
virtual ~rx3270();
--
libgit2 0.21.2