Commit 6688c6aaceb66ccdc69ebecafaa50e797e9dbc70
1 parent
afde7866
Exists in
master
Refactoring for new version.
Showing
13 changed files
with
771 additions
and
790 deletions
Show diff stats
configure.ac
| @@ -57,18 +57,6 @@ AC_PROG_LN_S | @@ -57,18 +57,6 @@ AC_PROG_LN_S | ||
| 57 | AC_LANG([C++]) | 57 | AC_LANG([C++]) |
| 58 | 58 | ||
| 59 | dnl --------------------------------------------------------------------------- | 59 | dnl --------------------------------------------------------------------------- |
| 60 | -dnl Initialize defaults | ||
| 61 | -dnl --------------------------------------------------------------------------- | ||
| 62 | - | ||
| 63 | -DBG_CFLAGS="-g -fstack-check -DDEBUG=1" | ||
| 64 | -RLS_CFLAGS="-DNDEBUG=1" | ||
| 65 | -PLUGINS="" | ||
| 66 | -APP_RESOURCES="" | ||
| 67 | -APP_LDFLAGS="" | ||
| 68 | -DLL_LDFLAGS="-shared -Wl,-soname,\$(@F)" | ||
| 69 | -DEPENDS="" | ||
| 70 | - | ||
| 71 | -dnl --------------------------------------------------------------------------- | ||
| 72 | dnl Version info | 60 | dnl Version info |
| 73 | dnl --------------------------------------------------------------------------- | 61 | dnl --------------------------------------------------------------------------- |
| 74 | 62 | ||
| @@ -96,11 +84,6 @@ AC_SUBST(PACKAGE_RELEASE,$app_cv_release) | @@ -96,11 +84,6 @@ AC_SUBST(PACKAGE_RELEASE,$app_cv_release) | ||
| 96 | AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major) | 84 | AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major) |
| 97 | AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor) | 85 | AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor) |
| 98 | 86 | ||
| 99 | -AC_ARG_WITH([application-datadir], [AS_HELP_STRING([--with-application-datadir], [Set path for configuration file])], [ app_cv_source_appdatadir="$withval" ],[ app_cv_source_appdatadir="\$(datarootdir)/\$(PACKAGE_NAME)" ]) | ||
| 100 | - | ||
| 101 | -AC_DEFINE_UNQUOTED(APPDATADIR, $app_cv_source_appdatadir) | ||
| 102 | -AC_SUBST(APPDATADIR,$app_cv_source_appdatadir) | ||
| 103 | - | ||
| 104 | dnl --------------------------------------------------------------------------- | 87 | dnl --------------------------------------------------------------------------- |
| 105 | dnl Check for OS specifics | 88 | dnl Check for OS specifics |
| 106 | dnl --------------------------------------------------------------------------- | 89 | dnl --------------------------------------------------------------------------- |
| @@ -124,14 +107,14 @@ dnl AC_CONFIG_FILES(win/py3270.nsi) | @@ -124,14 +107,14 @@ dnl AC_CONFIG_FILES(win/py3270.nsi) | ||
| 124 | 107 | ||
| 125 | if test "$host_cpu" = "x86_64"; then | 108 | if test "$host_cpu" = "x86_64"; then |
| 126 | app_cv_programfiles="PROGRAMFILES64" | 109 | app_cv_programfiles="PROGRAMFILES64" |
| 127 | - app_cv_winarch="64" | 110 | +dnl app_cv_winarch="64" |
| 128 | else | 111 | else |
| 129 | app_cv_programfiles="PROGRAMFILES" | 112 | app_cv_programfiles="PROGRAMFILES" |
| 130 | - app_cv_winarch="32" | 113 | +dnl app_cv_winarch="32" |
| 131 | fi | 114 | fi |
| 132 | 115 | ||
| 133 | AC_SUBST(PROGRAMFILES,$app_cv_programfiles) | 116 | AC_SUBST(PROGRAMFILES,$app_cv_programfiles) |
| 134 | - AC_SUBST(WINARCH,$app_cv_winarch) | 117 | +dnl AC_SUBST(WINARCH,$app_cv_winarch) |
| 135 | AC_SUBST(SONAME,py3270.dll) | 118 | AC_SUBST(SONAME,py3270.dll) |
| 136 | 119 | ||
| 137 | ;; | 120 | ;; |
| @@ -139,8 +122,6 @@ dnl AC_CONFIG_FILES(win/py3270.nsi) | @@ -139,8 +122,6 @@ dnl AC_CONFIG_FILES(win/py3270.nsi) | ||
| 139 | *) | 122 | *) |
| 140 | CFLAGS="$CFLAGS -pthread" | 123 | CFLAGS="$CFLAGS -pthread" |
| 141 | LDFLAGS="$LDFLAGS -pthread" | 124 | LDFLAGS="$LDFLAGS -pthread" |
| 142 | - app_cv_datadir="/usr/share" | ||
| 143 | - app_cv_confdir="/etc" | ||
| 144 | app_cv_osname="linux" | 125 | app_cv_osname="linux" |
| 145 | LOGDIR="/var/log" | 126 | LOGDIR="/var/log" |
| 146 | DLLEXT=".so" | 127 | DLLEXT=".so" |
| @@ -148,16 +129,6 @@ dnl AC_CONFIG_FILES(win/py3270.nsi) | @@ -148,16 +129,6 @@ dnl AC_CONFIG_FILES(win/py3270.nsi) | ||
| 148 | 129 | ||
| 149 | esac | 130 | esac |
| 150 | 131 | ||
| 151 | -AC_SUBST(DATADIR,$app_cv_datadir) | ||
| 152 | -AC_SUBST(CONFDIR,$app_cv_confdir) | ||
| 153 | -AC_SUBST(OSNAME,$app_cv_osname) | ||
| 154 | -AC_SUBST(LIBS) | ||
| 155 | -AC_SUBST(LOGDIR) | ||
| 156 | -AC_SUBST(DLLEXT) | ||
| 157 | -AC_SUBST(DLLPREFIX) | ||
| 158 | -AC_SUBST(LDFLAGS) | ||
| 159 | -AC_SUBST(DLL_LDFLAGS) | ||
| 160 | - | ||
| 161 | dnl --------------------------------------------------------------------------- | 132 | dnl --------------------------------------------------------------------------- |
| 162 | dnl Check for other programs | 133 | dnl Check for other programs |
| 163 | dnl --------------------------------------------------------------------------- | 134 | dnl --------------------------------------------------------------------------- |
| @@ -237,7 +208,6 @@ PKG_CHECK_MODULES( [PYTHON], [python], AC_DEFINE(HAVE_PYTHON), AC_MSG_ERROR([Pyt | @@ -237,7 +208,6 @@ PKG_CHECK_MODULES( [PYTHON], [python], AC_DEFINE(HAVE_PYTHON), AC_MSG_ERROR([Pyt | ||
| 237 | AC_SUBST(PYTHON_LIBS) | 208 | AC_SUBST(PYTHON_LIBS) |
| 238 | AC_SUBST(PYTHON_CFLAGS) | 209 | AC_SUBST(PYTHON_CFLAGS) |
| 239 | 210 | ||
| 240 | - | ||
| 241 | dnl --------------------------------------------------------------------------- | 211 | dnl --------------------------------------------------------------------------- |
| 242 | dnl Check for pic | 212 | dnl Check for pic |
| 243 | dnl --------------------------------------------------------------------------- | 213 | dnl --------------------------------------------------------------------------- |
| @@ -269,6 +239,18 @@ if test "$app_cv_pic" == "yes"; then | @@ -269,6 +239,18 @@ if test "$app_cv_pic" == "yes"; then | ||
| 269 | fi | 239 | fi |
| 270 | 240 | ||
| 271 | dnl --------------------------------------------------------------------------- | 241 | dnl --------------------------------------------------------------------------- |
| 242 | +dnl Configure program options | ||
| 243 | +dnl --------------------------------------------------------------------------- | ||
| 244 | + | ||
| 245 | +AC_SUBST(OSNAME,$app_cv_osname) | ||
| 246 | +AC_SUBST(LIBS) | ||
| 247 | +AC_SUBST(DLLEXT) | ||
| 248 | +AC_SUBST(CFLAGS) | ||
| 249 | +AC_SUBST(CXXFLAGS) | ||
| 250 | +AC_SUBST(LDFLAGS) | ||
| 251 | +AC_SUBST(BASEDIR,$ac_pwd) | ||
| 252 | + | ||
| 253 | +dnl --------------------------------------------------------------------------- | ||
| 272 | dnl Configure which files to generate. | 254 | dnl Configure which files to generate. |
| 273 | dnl --------------------------------------------------------------------------- | 255 | dnl --------------------------------------------------------------------------- |
| 274 | 256 | ||
| @@ -277,7 +259,6 @@ dnl --------------------------------------------------------------------------- | @@ -277,7 +259,6 @@ dnl --------------------------------------------------------------------------- | ||
| 277 | dnl --------------------------------------------------------------------------- | 259 | dnl --------------------------------------------------------------------------- |
| 278 | dnl Output the generated config.status script. | 260 | dnl Output the generated config.status script. |
| 279 | dnl --------------------------------------------------------------------------- | 261 | dnl --------------------------------------------------------------------------- |
| 280 | -AC_SUBST(BASEDIR,$ac_pwd) | ||
| 281 | 262 | ||
| 282 | AC_OUTPUT | 263 | AC_OUTPUT |
| 283 | 264 |
src/core/actions.cc
| @@ -1,128 +0,0 @@ | @@ -1,128 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | - * | ||
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | - * | ||
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | - * Free Software Foundation. | ||
| 11 | - * | ||
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | - * obter mais detalhes. | ||
| 16 | - * | ||
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | - * | ||
| 21 | - * Este programa está nomeado como actions.cc e possui - linhas de código. | ||
| 22 | - * | ||
| 23 | - * Contatos | ||
| 24 | - * | ||
| 25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | - * | ||
| 28 | - * Referências: | ||
| 29 | - * | ||
| 30 | - * <https://docs.python.org/2/extending/newtypes.html> | ||
| 31 | - * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 32 | - * | ||
| 33 | - */ | ||
| 34 | - | ||
| 35 | - #include "private.h" | ||
| 36 | - | ||
| 37 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 38 | - | ||
| 39 | - PyObject * terminal_pfkey(PyObject *self, PyObject *args) { | ||
| 40 | - | ||
| 41 | - int rc, key; | ||
| 42 | - | ||
| 43 | - if (!PyArg_ParseTuple(args, "i", &key)) { | ||
| 44 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 45 | - return NULL; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - try { | ||
| 49 | - | ||
| 50 | - rc = ((pw3270_TerminalObject *) self)->session->pfkey(key); | ||
| 51 | - | ||
| 52 | - } catch(std::exception &e) { | ||
| 53 | - | ||
| 54 | - PyErr_SetString(terminalError, e.what()); | ||
| 55 | - return NULL; | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - return PyLong_FromLong(rc); | ||
| 59 | - | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - PyObject * terminal_pakey(PyObject *self, PyObject *args) { | ||
| 63 | - | ||
| 64 | - int rc, key; | ||
| 65 | - | ||
| 66 | - if (!PyArg_ParseTuple(args, "i", &key)) { | ||
| 67 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 68 | - return NULL; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - try { | ||
| 72 | - | ||
| 73 | - rc = ((pw3270_TerminalObject *) self)->session->pakey(key); | ||
| 74 | - | ||
| 75 | - } catch(std::exception &e) { | ||
| 76 | - | ||
| 77 | - PyErr_SetString(terminalError, e.what()); | ||
| 78 | - return NULL; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - return PyLong_FromLong(rc); | ||
| 82 | - | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - PyObject * terminal_enter(PyObject *self, PyObject *args) { | ||
| 86 | - | ||
| 87 | - int rc; | ||
| 88 | - | ||
| 89 | - try { | ||
| 90 | - | ||
| 91 | - rc = ((pw3270_TerminalObject *) self)->session->enter(); | ||
| 92 | - | ||
| 93 | - } catch(std::exception &e) { | ||
| 94 | - | ||
| 95 | - PyErr_SetString(terminalError, e.what()); | ||
| 96 | - return NULL; | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - return PyLong_FromLong(rc); | ||
| 100 | - | ||
| 101 | - | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - PyObject * terminal_action(PyObject *self, PyObject *args) { | ||
| 105 | - | ||
| 106 | - int rc; | ||
| 107 | - const char *name; | ||
| 108 | - | ||
| 109 | - if (!PyArg_ParseTuple(args, "s", &name)) { | ||
| 110 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 111 | - return NULL; | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - try { | ||
| 115 | - | ||
| 116 | - rc = ((pw3270_TerminalObject *) self)->session->action(name); | ||
| 117 | - | ||
| 118 | - } catch(std::exception &e) { | ||
| 119 | - | ||
| 120 | - PyErr_SetString(terminalError, e.what()); | ||
| 121 | - return NULL; | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | - return PyLong_FromLong(rc); | ||
| 125 | - | ||
| 126 | - | ||
| 127 | - } | ||
| 128 | - |
src/core/get.cc
| @@ -1,154 +0,0 @@ | @@ -1,154 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | - * | ||
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | - * | ||
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | - * Free Software Foundation. | ||
| 11 | - * | ||
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | - * obter mais detalhes. | ||
| 16 | - * | ||
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | - * | ||
| 21 | - * Este programa está nomeado como get.cc e possui - linhas de código. | ||
| 22 | - * | ||
| 23 | - * Contatos: | ||
| 24 | - * | ||
| 25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | - * | ||
| 28 | - * Referências: | ||
| 29 | - * | ||
| 30 | - * <https://docs.python.org/2/extending/newtypes.html> | ||
| 31 | - * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 32 | - * | ||
| 33 | - */ | ||
| 34 | - | ||
| 35 | - #include "private.h" | ||
| 36 | - | ||
| 37 | - | ||
| 38 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 39 | - | ||
| 40 | -PyObject * terminal_get_version(PyObject *self, PyObject *args) { | ||
| 41 | - | ||
| 42 | - return PyString_FromString( ((pw3270_TerminalObject *) self)->session->get_version().c_str() ); | ||
| 43 | - | ||
| 44 | -} | ||
| 45 | - | ||
| 46 | -PyObject * terminal_get_revision(PyObject *self, PyObject *args) { | ||
| 47 | - | ||
| 48 | - return PyString_FromString( ((pw3270_TerminalObject *) self)->session->get_revision().c_str() ); | ||
| 49 | - | ||
| 50 | -} | ||
| 51 | - | ||
| 52 | -PyObject * terminal_is_connected(PyObject *self, PyObject *args) { | ||
| 53 | - | ||
| 54 | - return PyBool_FromLong( ((pw3270_TerminalObject *) self)->session->is_connected() ); | ||
| 55 | - | ||
| 56 | -} | ||
| 57 | - | ||
| 58 | -PyObject * terminal_is_ready(PyObject *self, PyObject *args) { | ||
| 59 | - | ||
| 60 | - return PyBool_FromLong( ((pw3270_TerminalObject *) self)->session->is_ready() ); | ||
| 61 | - | ||
| 62 | -} | ||
| 63 | - | ||
| 64 | -PyObject * terminal_is_protected_at(PyObject *self, PyObject *args) { | ||
| 65 | - | ||
| 66 | - int rc, row, col; | ||
| 67 | - | ||
| 68 | - if (!PyArg_ParseTuple(args, "ii", &row, &col)) { | ||
| 69 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 70 | - return NULL; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - try { | ||
| 74 | - | ||
| 75 | - rc = ((pw3270_TerminalObject *) self)->session->get_is_protected_at(row,col); | ||
| 76 | - | ||
| 77 | - } catch(std::exception &e) { | ||
| 78 | - | ||
| 79 | - PyErr_SetString(terminalError, e.what()); | ||
| 80 | - return NULL; | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - return PyBool_FromLong( rc ); | ||
| 84 | - | ||
| 85 | -} | ||
| 86 | - | ||
| 87 | - | ||
| 88 | -PyObject * terminal_cmp_string_at(PyObject *self, PyObject *args) { | ||
| 89 | - | ||
| 90 | - int row, col, rc; | ||
| 91 | - const char *text; | ||
| 92 | - | ||
| 93 | - if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { | ||
| 94 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 95 | - return NULL; | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - try { | ||
| 99 | - | ||
| 100 | - rc = ((pw3270_TerminalObject *) self)->session->cmp_string_at(row,col,text); | ||
| 101 | - | ||
| 102 | - } catch(std::exception &e) { | ||
| 103 | - | ||
| 104 | - PyErr_SetString(terminalError, e.what()); | ||
| 105 | - return NULL; | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - return PyLong_FromLong(rc); | ||
| 109 | - | ||
| 110 | -} | ||
| 111 | - | ||
| 112 | -PyObject * terminal_get_string_at(PyObject *self, PyObject *args) { | ||
| 113 | - | ||
| 114 | - int row, col, sz; | ||
| 115 | - string rc; | ||
| 116 | - | ||
| 117 | - if (!PyArg_ParseTuple(args, "iii", &row, &col, &sz)) { | ||
| 118 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 119 | - return NULL; | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - try { | ||
| 123 | - | ||
| 124 | - rc = ((pw3270_TerminalObject *) self)->session->get_string_at(row,col,sz); | ||
| 125 | - | ||
| 126 | - } catch(std::exception &e) { | ||
| 127 | - | ||
| 128 | - PyErr_SetString(terminalError, e.what()); | ||
| 129 | - return NULL; | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - return PyString_FromString(rc.c_str()); | ||
| 133 | - | ||
| 134 | -} | ||
| 135 | - | ||
| 136 | -PyObject * terminal_get_contents(PyObject *self) { | ||
| 137 | - | ||
| 138 | - string rc; | ||
| 139 | - | ||
| 140 | - try { | ||
| 141 | - | ||
| 142 | - rc = ((pw3270_TerminalObject *) self)->session->get_string(); | ||
| 143 | - | ||
| 144 | - } catch(std::exception &e) { | ||
| 145 | - | ||
| 146 | - PyErr_SetString(terminalError, e.what()); | ||
| 147 | - return NULL; | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - return PyString_FromString(rc.c_str()); | ||
| 151 | - | ||
| 152 | - | ||
| 153 | - | ||
| 154 | -} |
src/core/init.cc
| @@ -1,87 +0,0 @@ | @@ -1,87 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | - * | ||
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | - * | ||
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | - * Free Software Foundation. | ||
| 11 | - * | ||
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | - * obter mais detalhes. | ||
| 16 | - * | ||
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | - * | ||
| 21 | - * Este programa está nomeado como py3270.cc e possui - linhas de código. | ||
| 22 | - * | ||
| 23 | - * Contatos: | ||
| 24 | - * | ||
| 25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | - * | ||
| 28 | - * Implementa métodos básicos inicio/final do objeto python | ||
| 29 | - * | ||
| 30 | - * Referências: | ||
| 31 | - * | ||
| 32 | - * <https://docs.python.org/2/extending/newtypes.html> | ||
| 33 | - * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 34 | - * | ||
| 35 | - */ | ||
| 36 | - | ||
| 37 | - #include "private.h" | ||
| 38 | - | ||
| 39 | - | ||
| 40 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 41 | - | ||
| 42 | -PyObject * terminal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { | ||
| 43 | - | ||
| 44 | - PW3270_NAMESPACE::session * session; | ||
| 45 | - const char *id = ""; | ||
| 46 | - | ||
| 47 | - if (!PyArg_ParseTuple(args, "s", &id)) { | ||
| 48 | - id = ""; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - trace("%s(%s)",__FUNCTION__,id); | ||
| 52 | - | ||
| 53 | - try { | ||
| 54 | - | ||
| 55 | - session = PW3270_NAMESPACE::session::create(id); | ||
| 56 | - | ||
| 57 | - } catch(std::exception &e) { | ||
| 58 | - | ||
| 59 | - trace("%s failed: %s",__FUNCTION__,e.what()); | ||
| 60 | - PyErr_SetString(terminalError, e.what()); | ||
| 61 | - return NULL; | ||
| 62 | - | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - pw3270_TerminalObject *self = (pw3270_TerminalObject *) type->tp_alloc(type, 0); | ||
| 66 | - | ||
| 67 | - self->session = session; | ||
| 68 | - | ||
| 69 | - return (PyObject *)self; | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | - | ||
| 73 | -int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds) { | ||
| 74 | - | ||
| 75 | - return 0; | ||
| 76 | - | ||
| 77 | -} | ||
| 78 | - | ||
| 79 | -void terminal_dealloc(pw3270_TerminalObject * self) { | ||
| 80 | - | ||
| 81 | - trace("%s",__FUNCTION__); | ||
| 82 | - | ||
| 83 | - delete self->session; | ||
| 84 | - | ||
| 85 | - self->ob_type->tp_free((PyObject*)self); | ||
| 86 | - | ||
| 87 | -} |
src/core/misc.cc
| @@ -1,134 +0,0 @@ | @@ -1,134 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | - * | ||
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | - * | ||
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | - * Free Software Foundation. | ||
| 11 | - * | ||
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | - * obter mais detalhes. | ||
| 16 | - * | ||
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | - * | ||
| 21 | - * Este programa está nomeado como misc.cc e possui - linhas de código. | ||
| 22 | - * | ||
| 23 | - * Contatos: | ||
| 24 | - * | ||
| 25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | - * | ||
| 28 | - * Implementa métodos básicos inicio/final do objeto python | ||
| 29 | - * | ||
| 30 | - * Referências: | ||
| 31 | - * | ||
| 32 | - * <https://docs.python.org/2/extending/newtypes.html> | ||
| 33 | - * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 34 | - * | ||
| 35 | - */ | ||
| 36 | - | ||
| 37 | - #include "private.h" | ||
| 38 | - | ||
| 39 | - | ||
| 40 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 41 | - | ||
| 42 | - PyObject * terminal_connect(PyObject *self, PyObject *args) { | ||
| 43 | - | ||
| 44 | - int rc = -1; | ||
| 45 | - int wait = 60; | ||
| 46 | - const char * host = ""; | ||
| 47 | - | ||
| 48 | - if (!PyArg_ParseTuple(args, "s|i", &host, &wait)) { | ||
| 49 | - PyErr_SetString(terminalError, "connect requires a host URL"); | ||
| 50 | - return NULL; | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - try { | ||
| 54 | - | ||
| 55 | - rc = ((pw3270_TerminalObject *) self)->session->connect(host,wait); | ||
| 56 | - | ||
| 57 | - } catch(std::exception &e) { | ||
| 58 | - | ||
| 59 | - PyErr_SetString(terminalError, e.what()); | ||
| 60 | - return NULL; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - return PyLong_FromLong(rc); | ||
| 64 | - | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - PyObject * terminal_disconnect(PyObject *self, PyObject *args) { | ||
| 68 | - | ||
| 69 | - int rc = -1; | ||
| 70 | - | ||
| 71 | - try { | ||
| 72 | - | ||
| 73 | - rc = ((pw3270_TerminalObject *) self)->session->disconnect(); | ||
| 74 | - | ||
| 75 | - } catch(std::exception &e) { | ||
| 76 | - | ||
| 77 | - PyErr_SetString(terminalError, e.what()); | ||
| 78 | - return NULL; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - return PyLong_FromLong(rc); | ||
| 82 | - | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - PyObject * terminal_wait_for_ready(PyObject *self, PyObject *args) { | ||
| 86 | - | ||
| 87 | - int rc; | ||
| 88 | - int timeout = 60; | ||
| 89 | - | ||
| 90 | - if (!PyArg_ParseTuple(args, "|i", &timeout)) { | ||
| 91 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 92 | - return NULL; | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - try { | ||
| 96 | - | ||
| 97 | - rc = ((pw3270_TerminalObject *) self)->session->wait_for_ready(timeout); | ||
| 98 | - | ||
| 99 | - } catch(std::exception &e) { | ||
| 100 | - | ||
| 101 | - PyErr_SetString(terminalError, e.what()); | ||
| 102 | - return NULL; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - return PyLong_FromLong(rc); | ||
| 106 | - | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - | ||
| 110 | - PyObject * terminal_wait_for_string_at(PyObject *self, PyObject *args) { | ||
| 111 | - | ||
| 112 | - int row, col, rc; | ||
| 113 | - int timeout = 10; | ||
| 114 | - const char *text; | ||
| 115 | - | ||
| 116 | - if (!PyArg_ParseTuple(args, "iis|i", &row, &col, &text, &timeout)) { | ||
| 117 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 118 | - return NULL; | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - try { | ||
| 122 | - | ||
| 123 | - rc = ((pw3270_TerminalObject *) self)->session->wait_for_string_at(row,col,text,timeout); | ||
| 124 | - | ||
| 125 | - } catch(std::exception &e) { | ||
| 126 | - | ||
| 127 | - PyErr_SetString(terminalError, e.what()); | ||
| 128 | - return NULL; | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | - return PyLong_FromLong(rc); | ||
| 132 | - | ||
| 133 | - } | ||
| 134 | - |
src/core/py3270.cc
| @@ -1,167 +0,0 @@ | @@ -1,167 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | - * | ||
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | - * | ||
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | - * Free Software Foundation. | ||
| 11 | - * | ||
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | - * obter mais detalhes. | ||
| 16 | - * | ||
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | - * | ||
| 21 | - * Este programa está nomeado como py3270.cc e possui - linhas de código. | ||
| 22 | - * | ||
| 23 | - * Contatos: | ||
| 24 | - * | ||
| 25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | - * | ||
| 28 | - * Implementa métodos básicos para a extensão python. | ||
| 29 | - * | ||
| 30 | - * Referências: | ||
| 31 | - * | ||
| 32 | - * <https://docs.python.org/2/extending/newtypes.html> | ||
| 33 | - * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 34 | - * | ||
| 35 | - */ | ||
| 36 | - | ||
| 37 | - #include "private.h" | ||
| 38 | - | ||
| 39 | -/*---[ Globals ]------------------------------------------------------------------------------------*/ | ||
| 40 | - | ||
| 41 | - PyObject * terminalError = NULL; | ||
| 42 | - | ||
| 43 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 44 | - | ||
| 45 | -static PyObject * get_revision(PyObject *self, PyObject *args) { | ||
| 46 | - | ||
| 47 | -#ifdef PACKAGE_REVISION | ||
| 48 | - return PyLong_FromLong(atoi(PACKAGE_REVISION)); | ||
| 49 | -#else | ||
| 50 | - return PyLong_FromLong(BUILD_DATE); | ||
| 51 | -#endif // PACKAGE_REVISION | ||
| 52 | - | ||
| 53 | -} | ||
| 54 | - | ||
| 55 | -static PyMethodDef terminal_methods[] = { | ||
| 56 | - | ||
| 57 | - { "Version", terminal_get_version, METH_NOARGS, "Get the lib3270 version string." }, | ||
| 58 | - { "Revision", terminal_get_revision, METH_NOARGS, "Get the lib3270 revision number." }, | ||
| 59 | - | ||
| 60 | - { "IsConnected", terminal_is_connected, METH_NOARGS, "True if the terminal is connected to the host." }, | ||
| 61 | - { "IsReady", terminal_is_ready, METH_NOARGS, "True if the terminal has finished network activity." }, | ||
| 62 | - { "IsProtected", terminal_is_protected_at, METH_VARARGS, "True if the position is read-only." }, | ||
| 63 | - | ||
| 64 | - { "SetCursorPosition", terminal_set_cursor_at, METH_VARARGS, "Set cursor position." }, | ||
| 65 | - | ||
| 66 | - { "WaitForStringAt", terminal_wait_for_string_at, METH_VARARGS, "Wait for string at position" }, | ||
| 67 | - { "WaitForReady", terminal_wait_for_ready, METH_VARARGS, "Wait for network communication to finish" }, | ||
| 68 | - | ||
| 69 | - { "Connect", terminal_connect, METH_VARARGS, "Connect to the host." }, | ||
| 70 | - { "Disconnect", terminal_disconnect, METH_NOARGS, "Disconnect from host." }, | ||
| 71 | - | ||
| 72 | - { "CmpStringAt", terminal_cmp_string_at, METH_VARARGS, "Compare string with terminal buffer at the position." }, | ||
| 73 | - { "GetStringAt", terminal_get_string_at, METH_VARARGS, "Get string from terminal buffer." }, | ||
| 74 | - { "SetStringAt", terminal_set_string_at, METH_VARARGS, "Set string in terminal buffer." }, | ||
| 75 | - | ||
| 76 | - { "PFKey", terminal_pfkey, METH_VARARGS, "Send PF key." }, | ||
| 77 | - { "PAKey", terminal_pakey, METH_VARARGS, "Send PA key." }, | ||
| 78 | - { "Enter", terminal_enter, METH_NOARGS, "Send Enter Key." }, | ||
| 79 | - { "Action", terminal_action, METH_VARARGS, "Send Action by name." }, | ||
| 80 | - | ||
| 81 | - {NULL} // Sentinel | ||
| 82 | - | ||
| 83 | -}; | ||
| 84 | - | ||
| 85 | -/* | ||
| 86 | -static PyMemberDef terminal_members[] = { | ||
| 87 | - | ||
| 88 | - { NULL } // Sentinel | ||
| 89 | - | ||
| 90 | -}; | ||
| 91 | -*/ | ||
| 92 | - | ||
| 93 | -static PyTypeObject pw3270_TerminalType = { | ||
| 94 | - PyObject_HEAD_INIT(NULL) | ||
| 95 | - 0, /*ob_size*/ | ||
| 96 | - "py3270.terminal", /*tp_name*/ | ||
| 97 | - sizeof(pw3270_TerminalObject), /*tp_basicsize*/ | ||
| 98 | - 0, /*tp_itemsize*/ | ||
| 99 | - (destructor) terminal_dealloc, /*tp_dealloc*/ | ||
| 100 | - 0, /*tp_print*/ | ||
| 101 | - 0, /*tp_getattr*/ | ||
| 102 | - 0, /*tp_setattr*/ | ||
| 103 | - 0, /*tp_compare*/ | ||
| 104 | - 0, /*tp_repr*/ | ||
| 105 | - 0, /*tp_as_number*/ | ||
| 106 | - 0, /*tp_as_sequence*/ | ||
| 107 | - 0, /*tp_as_mapping*/ | ||
| 108 | - 0, /*tp_hash */ | ||
| 109 | - 0, /*tp_call*/ | ||
| 110 | - terminal_get_contents, /*tp_str*/ | ||
| 111 | - 0, /*tp_getattro*/ | ||
| 112 | - 0, /*tp_setattro*/ | ||
| 113 | - 0, /*tp_as_buffer*/ | ||
| 114 | - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ | ||
| 115 | - "3270 terminal object", /* tp_doc */ | ||
| 116 | - 0, /* tp_traverse */ | ||
| 117 | - 0, /* tp_clear */ | ||
| 118 | - 0, /* tp_richcompare */ | ||
| 119 | - 0, /* tp_weaklistoffset */ | ||
| 120 | - 0, /* tp_iter */ | ||
| 121 | - 0, /* tp_iternext */ | ||
| 122 | - terminal_methods, /* tp_methods */ | ||
| 123 | - 0, // terminal_members, /* tp_members */ | ||
| 124 | - 0, /* tp_getset */ | ||
| 125 | - 0, /* tp_base */ | ||
| 126 | - 0, /* tp_dict */ | ||
| 127 | - 0, /* tp_descr_get */ | ||
| 128 | - 0, /* tp_descr_set */ | ||
| 129 | - 0, /* tp_dictoffset */ | ||
| 130 | - (initproc) terminal_init, /* tp_init */ | ||
| 131 | - 0, /* tp_alloc */ | ||
| 132 | - terminal_new, /* tp_new */ | ||
| 133 | - | ||
| 134 | -}; | ||
| 135 | - | ||
| 136 | -static PyMethodDef MyMethods[] = { | ||
| 137 | - | ||
| 138 | - { "Revision", get_revision, METH_VARARGS, "Get module revision." }, | ||
| 139 | - | ||
| 140 | - {NULL, NULL, 0, NULL} /* Sentinel */ | ||
| 141 | - | ||
| 142 | -}; | ||
| 143 | - | ||
| 144 | -PyMODINIT_FUNC initpy3270(void) { | ||
| 145 | - | ||
| 146 | - // Cria o módulo | ||
| 147 | - | ||
| 148 | - PyObject *m = Py_InitModule("py3270", MyMethods); | ||
| 149 | - | ||
| 150 | - if (m == NULL) { | ||
| 151 | - return; | ||
| 152 | - } | ||
| 153 | - | ||
| 154 | - // Adiciona objeto para tratamento de erros. | ||
| 155 | - terminalError = PyErr_NewException((char *) "py3270.error", NULL, NULL); | ||
| 156 | - | ||
| 157 | - (void) Py_INCREF(terminalError); | ||
| 158 | - PyModule_AddObject(m, "error", terminalError); | ||
| 159 | - | ||
| 160 | - // Adiciona terminal | ||
| 161 | - if(PyType_Ready(&pw3270_TerminalType) < 0) | ||
| 162 | - return | ||
| 163 | - | ||
| 164 | - (void) Py_INCREF(&pw3270_TerminalType); | ||
| 165 | - PyModule_AddObject(m, "Terminal", (PyObject *)&pw3270_TerminalType); | ||
| 166 | - | ||
| 167 | -} |
src/core/set.cc
| @@ -1,86 +0,0 @@ | @@ -1,86 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | - * | ||
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | - * | ||
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | - * Free Software Foundation. | ||
| 11 | - * | ||
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | - * obter mais detalhes. | ||
| 16 | - * | ||
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | - * | ||
| 21 | - * Este programa está nomeado como set.cc e possui - linhas de código. | ||
| 22 | - * | ||
| 23 | - * Contatos | ||
| 24 | - * | ||
| 25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | - * | ||
| 28 | - * Referências: | ||
| 29 | - * | ||
| 30 | - * <https://docs.python.org/2/extending/newtypes.html> | ||
| 31 | - * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 32 | - * | ||
| 33 | - */ | ||
| 34 | - | ||
| 35 | - #include "private.h" | ||
| 36 | - | ||
| 37 | - | ||
| 38 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 39 | - | ||
| 40 | - PyObject * terminal_set_string_at(PyObject *self, PyObject *args) { | ||
| 41 | - | ||
| 42 | - int row, col, rc; | ||
| 43 | - const char *text; | ||
| 44 | - | ||
| 45 | - if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { | ||
| 46 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 47 | - return NULL; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - try { | ||
| 51 | - | ||
| 52 | - rc = ((pw3270_TerminalObject *) self)->session->set_string_at(row,col,text); | ||
| 53 | - | ||
| 54 | - } catch(std::exception &e) { | ||
| 55 | - | ||
| 56 | - PyErr_SetString(terminalError, e.what()); | ||
| 57 | - return NULL; | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - return PyLong_FromLong(rc); | ||
| 61 | - | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - PyObject * terminal_set_cursor_at(PyObject *self, PyObject *args) { | ||
| 65 | - | ||
| 66 | - int row, col, rc; | ||
| 67 | - | ||
| 68 | - if (!PyArg_ParseTuple(args, "ii", &row, &col)) { | ||
| 69 | - PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 70 | - return NULL; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - try { | ||
| 74 | - | ||
| 75 | - rc = ((pw3270_TerminalObject *) self)->session->set_cursor_position(row,col); | ||
| 76 | - | ||
| 77 | - } catch(std::exception &e) { | ||
| 78 | - | ||
| 79 | - PyErr_SetString(terminalError, e.what()); | ||
| 80 | - return NULL; | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - return PyLong_FromLong(rc); | ||
| 84 | - | ||
| 85 | - } | ||
| 86 | - |
| @@ -0,0 +1,128 @@ | @@ -0,0 +1,128 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como actions.cc e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + * Referências: | ||
| 29 | + * | ||
| 30 | + * <https://docs.python.org/2/extending/newtypes.html> | ||
| 31 | + * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 32 | + * | ||
| 33 | + */ | ||
| 34 | + | ||
| 35 | + #include "private.h" | ||
| 36 | + | ||
| 37 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 38 | + | ||
| 39 | + PyObject * terminal_pfkey(PyObject *self, PyObject *args) { | ||
| 40 | + | ||
| 41 | + int rc, key; | ||
| 42 | + | ||
| 43 | + if (!PyArg_ParseTuple(args, "i", &key)) { | ||
| 44 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 45 | + return NULL; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + try { | ||
| 49 | + | ||
| 50 | + rc = ((pw3270_TerminalObject *) self)->session->pfkey(key); | ||
| 51 | + | ||
| 52 | + } catch(std::exception &e) { | ||
| 53 | + | ||
| 54 | + PyErr_SetString(terminalError, e.what()); | ||
| 55 | + return NULL; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + return PyLong_FromLong(rc); | ||
| 59 | + | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + PyObject * terminal_pakey(PyObject *self, PyObject *args) { | ||
| 63 | + | ||
| 64 | + int rc, key; | ||
| 65 | + | ||
| 66 | + if (!PyArg_ParseTuple(args, "i", &key)) { | ||
| 67 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 68 | + return NULL; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + try { | ||
| 72 | + | ||
| 73 | + rc = ((pw3270_TerminalObject *) self)->session->pakey(key); | ||
| 74 | + | ||
| 75 | + } catch(std::exception &e) { | ||
| 76 | + | ||
| 77 | + PyErr_SetString(terminalError, e.what()); | ||
| 78 | + return NULL; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + return PyLong_FromLong(rc); | ||
| 82 | + | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + PyObject * terminal_enter(PyObject *self, PyObject *args) { | ||
| 86 | + | ||
| 87 | + int rc; | ||
| 88 | + | ||
| 89 | + try { | ||
| 90 | + | ||
| 91 | + rc = ((pw3270_TerminalObject *) self)->session->enter(); | ||
| 92 | + | ||
| 93 | + } catch(std::exception &e) { | ||
| 94 | + | ||
| 95 | + PyErr_SetString(terminalError, e.what()); | ||
| 96 | + return NULL; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + return PyLong_FromLong(rc); | ||
| 100 | + | ||
| 101 | + | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + PyObject * terminal_action(PyObject *self, PyObject *args) { | ||
| 105 | + | ||
| 106 | + int rc; | ||
| 107 | + const char *name; | ||
| 108 | + | ||
| 109 | + if (!PyArg_ParseTuple(args, "s", &name)) { | ||
| 110 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 111 | + return NULL; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + try { | ||
| 115 | + | ||
| 116 | + rc = ((pw3270_TerminalObject *) self)->session->action(name); | ||
| 117 | + | ||
| 118 | + } catch(std::exception &e) { | ||
| 119 | + | ||
| 120 | + PyErr_SetString(terminalError, e.what()); | ||
| 121 | + return NULL; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + return PyLong_FromLong(rc); | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + } | ||
| 128 | + |
| @@ -0,0 +1,154 @@ | @@ -0,0 +1,154 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como get.cc e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + * Referências: | ||
| 29 | + * | ||
| 30 | + * <https://docs.python.org/2/extending/newtypes.html> | ||
| 31 | + * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 32 | + * | ||
| 33 | + */ | ||
| 34 | + | ||
| 35 | + #include "private.h" | ||
| 36 | + | ||
| 37 | + | ||
| 38 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 39 | + | ||
| 40 | +PyObject * terminal_get_version(PyObject *self, PyObject *args) { | ||
| 41 | + | ||
| 42 | + return PyString_FromString( ((pw3270_TerminalObject *) self)->session->get_version().c_str() ); | ||
| 43 | + | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +PyObject * terminal_get_revision(PyObject *self, PyObject *args) { | ||
| 47 | + | ||
| 48 | + return PyString_FromString( ((pw3270_TerminalObject *) self)->session->get_revision().c_str() ); | ||
| 49 | + | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +PyObject * terminal_is_connected(PyObject *self, PyObject *args) { | ||
| 53 | + | ||
| 54 | + return PyBool_FromLong( ((pw3270_TerminalObject *) self)->session->is_connected() ); | ||
| 55 | + | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +PyObject * terminal_is_ready(PyObject *self, PyObject *args) { | ||
| 59 | + | ||
| 60 | + return PyBool_FromLong( ((pw3270_TerminalObject *) self)->session->is_ready() ); | ||
| 61 | + | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +PyObject * terminal_is_protected_at(PyObject *self, PyObject *args) { | ||
| 65 | + | ||
| 66 | + int rc, row, col; | ||
| 67 | + | ||
| 68 | + if (!PyArg_ParseTuple(args, "ii", &row, &col)) { | ||
| 69 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 70 | + return NULL; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + try { | ||
| 74 | + | ||
| 75 | + rc = ((pw3270_TerminalObject *) self)->session->get_is_protected_at(row,col); | ||
| 76 | + | ||
| 77 | + } catch(std::exception &e) { | ||
| 78 | + | ||
| 79 | + PyErr_SetString(terminalError, e.what()); | ||
| 80 | + return NULL; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + return PyBool_FromLong( rc ); | ||
| 84 | + | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | + | ||
| 88 | +PyObject * terminal_cmp_string_at(PyObject *self, PyObject *args) { | ||
| 89 | + | ||
| 90 | + int row, col, rc; | ||
| 91 | + const char *text; | ||
| 92 | + | ||
| 93 | + if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { | ||
| 94 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 95 | + return NULL; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + try { | ||
| 99 | + | ||
| 100 | + rc = ((pw3270_TerminalObject *) self)->session->cmp_string_at(row,col,text); | ||
| 101 | + | ||
| 102 | + } catch(std::exception &e) { | ||
| 103 | + | ||
| 104 | + PyErr_SetString(terminalError, e.what()); | ||
| 105 | + return NULL; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + return PyLong_FromLong(rc); | ||
| 109 | + | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +PyObject * terminal_get_string_at(PyObject *self, PyObject *args) { | ||
| 113 | + | ||
| 114 | + int row, col, sz; | ||
| 115 | + string rc; | ||
| 116 | + | ||
| 117 | + if (!PyArg_ParseTuple(args, "iii", &row, &col, &sz)) { | ||
| 118 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 119 | + return NULL; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + try { | ||
| 123 | + | ||
| 124 | + rc = ((pw3270_TerminalObject *) self)->session->get_string_at(row,col,sz); | ||
| 125 | + | ||
| 126 | + } catch(std::exception &e) { | ||
| 127 | + | ||
| 128 | + PyErr_SetString(terminalError, e.what()); | ||
| 129 | + return NULL; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + return PyString_FromString(rc.c_str()); | ||
| 133 | + | ||
| 134 | +} | ||
| 135 | + | ||
| 136 | +PyObject * terminal_get_contents(PyObject *self) { | ||
| 137 | + | ||
| 138 | + string rc; | ||
| 139 | + | ||
| 140 | + try { | ||
| 141 | + | ||
| 142 | + rc = ((pw3270_TerminalObject *) self)->session->get_string(); | ||
| 143 | + | ||
| 144 | + } catch(std::exception &e) { | ||
| 145 | + | ||
| 146 | + PyErr_SetString(terminalError, e.what()); | ||
| 147 | + return NULL; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + return PyString_FromString(rc.c_str()); | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + | ||
| 154 | +} |
| @@ -0,0 +1,167 @@ | @@ -0,0 +1,167 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como py3270.cc e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + * Implementa métodos básicos para a extensão python. | ||
| 29 | + * | ||
| 30 | + * Referências: | ||
| 31 | + * | ||
| 32 | + * <https://docs.python.org/2/extending/newtypes.html> | ||
| 33 | + * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 34 | + * | ||
| 35 | + */ | ||
| 36 | + | ||
| 37 | + #include "private.h" | ||
| 38 | + | ||
| 39 | +/*---[ Globals ]------------------------------------------------------------------------------------*/ | ||
| 40 | + | ||
| 41 | + PyObject * terminalError = NULL; | ||
| 42 | + | ||
| 43 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 44 | + | ||
| 45 | +static PyObject * get_revision(PyObject *self, PyObject *args) { | ||
| 46 | + | ||
| 47 | +#ifdef PACKAGE_REVISION | ||
| 48 | + return PyLong_FromLong(atoi(PACKAGE_REVISION)); | ||
| 49 | +#else | ||
| 50 | + return PyLong_FromLong(BUILD_DATE); | ||
| 51 | +#endif // PACKAGE_REVISION | ||
| 52 | + | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +static PyMethodDef terminal_methods[] = { | ||
| 56 | + | ||
| 57 | + { "Version", terminal_get_version, METH_NOARGS, "Get the lib3270 version string." }, | ||
| 58 | + { "Revision", terminal_get_revision, METH_NOARGS, "Get the lib3270 revision number." }, | ||
| 59 | + | ||
| 60 | + { "IsConnected", terminal_is_connected, METH_NOARGS, "True if the terminal is connected to the host." }, | ||
| 61 | + { "IsReady", terminal_is_ready, METH_NOARGS, "True if the terminal has finished network activity." }, | ||
| 62 | + { "IsProtected", terminal_is_protected_at, METH_VARARGS, "True if the position is read-only." }, | ||
| 63 | + | ||
| 64 | + { "SetCursorPosition", terminal_set_cursor_at, METH_VARARGS, "Set cursor position." }, | ||
| 65 | + | ||
| 66 | + { "WaitForStringAt", terminal_wait_for_string_at, METH_VARARGS, "Wait for string at position" }, | ||
| 67 | + { "WaitForReady", terminal_wait_for_ready, METH_VARARGS, "Wait for network communication to finish" }, | ||
| 68 | + | ||
| 69 | + { "Connect", terminal_connect, METH_VARARGS, "Connect to the host." }, | ||
| 70 | + { "Disconnect", terminal_disconnect, METH_NOARGS, "Disconnect from host." }, | ||
| 71 | + | ||
| 72 | + { "CmpStringAt", terminal_cmp_string_at, METH_VARARGS, "Compare string with terminal buffer at the position." }, | ||
| 73 | + { "GetStringAt", terminal_get_string_at, METH_VARARGS, "Get string from terminal buffer." }, | ||
| 74 | + { "SetStringAt", terminal_set_string_at, METH_VARARGS, "Set string in terminal buffer." }, | ||
| 75 | + | ||
| 76 | + { "PFKey", terminal_pfkey, METH_VARARGS, "Send PF key." }, | ||
| 77 | + { "PAKey", terminal_pakey, METH_VARARGS, "Send PA key." }, | ||
| 78 | + { "Enter", terminal_enter, METH_NOARGS, "Send Enter Key." }, | ||
| 79 | + { "Action", terminal_action, METH_VARARGS, "Send Action by name." }, | ||
| 80 | + | ||
| 81 | + {NULL} // Sentinel | ||
| 82 | + | ||
| 83 | +}; | ||
| 84 | + | ||
| 85 | +/* | ||
| 86 | +static PyMemberDef terminal_members[] = { | ||
| 87 | + | ||
| 88 | + { NULL } // Sentinel | ||
| 89 | + | ||
| 90 | +}; | ||
| 91 | +*/ | ||
| 92 | + | ||
| 93 | +static PyTypeObject pw3270_TerminalType = { | ||
| 94 | + PyObject_HEAD_INIT(NULL) | ||
| 95 | + 0, /*ob_size*/ | ||
| 96 | + "py3270.terminal", /*tp_name*/ | ||
| 97 | + sizeof(pw3270_TerminalObject), /*tp_basicsize*/ | ||
| 98 | + 0, /*tp_itemsize*/ | ||
| 99 | + (destructor) terminal_dealloc, /*tp_dealloc*/ | ||
| 100 | + 0, /*tp_print*/ | ||
| 101 | + 0, /*tp_getattr*/ | ||
| 102 | + 0, /*tp_setattr*/ | ||
| 103 | + 0, /*tp_compare*/ | ||
| 104 | + 0, /*tp_repr*/ | ||
| 105 | + 0, /*tp_as_number*/ | ||
| 106 | + 0, /*tp_as_sequence*/ | ||
| 107 | + 0, /*tp_as_mapping*/ | ||
| 108 | + 0, /*tp_hash */ | ||
| 109 | + 0, /*tp_call*/ | ||
| 110 | + terminal_get_contents, /*tp_str*/ | ||
| 111 | + 0, /*tp_getattro*/ | ||
| 112 | + 0, /*tp_setattro*/ | ||
| 113 | + 0, /*tp_as_buffer*/ | ||
| 114 | + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ | ||
| 115 | + "3270 terminal object", /* tp_doc */ | ||
| 116 | + 0, /* tp_traverse */ | ||
| 117 | + 0, /* tp_clear */ | ||
| 118 | + 0, /* tp_richcompare */ | ||
| 119 | + 0, /* tp_weaklistoffset */ | ||
| 120 | + 0, /* tp_iter */ | ||
| 121 | + 0, /* tp_iternext */ | ||
| 122 | + terminal_methods, /* tp_methods */ | ||
| 123 | + 0, // terminal_members, /* tp_members */ | ||
| 124 | + 0, /* tp_getset */ | ||
| 125 | + 0, /* tp_base */ | ||
| 126 | + 0, /* tp_dict */ | ||
| 127 | + 0, /* tp_descr_get */ | ||
| 128 | + 0, /* tp_descr_set */ | ||
| 129 | + 0, /* tp_dictoffset */ | ||
| 130 | + (initproc) terminal_init, /* tp_init */ | ||
| 131 | + 0, /* tp_alloc */ | ||
| 132 | + terminal_new, /* tp_new */ | ||
| 133 | + | ||
| 134 | +}; | ||
| 135 | + | ||
| 136 | +static PyMethodDef MyMethods[] = { | ||
| 137 | + | ||
| 138 | + { "Revision", get_revision, METH_VARARGS, "Get module revision." }, | ||
| 139 | + | ||
| 140 | + {NULL, NULL, 0, NULL} /* Sentinel */ | ||
| 141 | + | ||
| 142 | +}; | ||
| 143 | + | ||
| 144 | +PyMODINIT_FUNC initpy3270(void) { | ||
| 145 | + | ||
| 146 | + // Cria o módulo | ||
| 147 | + | ||
| 148 | + PyObject *m = Py_InitModule("py3270", MyMethods); | ||
| 149 | + | ||
| 150 | + if (m == NULL) { | ||
| 151 | + return; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + // Adiciona objeto para tratamento de erros. | ||
| 155 | + terminalError = PyErr_NewException((char *) "py3270.error", NULL, NULL); | ||
| 156 | + | ||
| 157 | + (void) Py_INCREF(terminalError); | ||
| 158 | + PyModule_AddObject(m, "error", terminalError); | ||
| 159 | + | ||
| 160 | + // Adiciona terminal | ||
| 161 | + if(PyType_Ready(&pw3270_TerminalType) < 0) | ||
| 162 | + return | ||
| 163 | + | ||
| 164 | + (void) Py_INCREF(&pw3270_TerminalType); | ||
| 165 | + PyModule_AddObject(m, "Terminal", (PyObject *)&pw3270_TerminalType); | ||
| 166 | + | ||
| 167 | +} |
| @@ -0,0 +1,134 @@ | @@ -0,0 +1,134 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como misc.cc e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + * Implementa métodos básicos inicio/final do objeto python | ||
| 29 | + * | ||
| 30 | + * Referências: | ||
| 31 | + * | ||
| 32 | + * <https://docs.python.org/2/extending/newtypes.html> | ||
| 33 | + * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 34 | + * | ||
| 35 | + */ | ||
| 36 | + | ||
| 37 | + #include "private.h" | ||
| 38 | + | ||
| 39 | + | ||
| 40 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 41 | + | ||
| 42 | + PyObject * terminal_connect(PyObject *self, PyObject *args) { | ||
| 43 | + | ||
| 44 | + int rc = -1; | ||
| 45 | + int wait = 60; | ||
| 46 | + const char * host = ""; | ||
| 47 | + | ||
| 48 | + if (!PyArg_ParseTuple(args, "s|i", &host, &wait)) { | ||
| 49 | + PyErr_SetString(terminalError, "connect requires a host URL"); | ||
| 50 | + return NULL; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + try { | ||
| 54 | + | ||
| 55 | + rc = ((pw3270_TerminalObject *) self)->session->connect(host,wait); | ||
| 56 | + | ||
| 57 | + } catch(std::exception &e) { | ||
| 58 | + | ||
| 59 | + PyErr_SetString(terminalError, e.what()); | ||
| 60 | + return NULL; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + return PyLong_FromLong(rc); | ||
| 64 | + | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + PyObject * terminal_disconnect(PyObject *self, PyObject *args) { | ||
| 68 | + | ||
| 69 | + int rc = -1; | ||
| 70 | + | ||
| 71 | + try { | ||
| 72 | + | ||
| 73 | + rc = ((pw3270_TerminalObject *) self)->session->disconnect(); | ||
| 74 | + | ||
| 75 | + } catch(std::exception &e) { | ||
| 76 | + | ||
| 77 | + PyErr_SetString(terminalError, e.what()); | ||
| 78 | + return NULL; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + return PyLong_FromLong(rc); | ||
| 82 | + | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + PyObject * terminal_wait_for_ready(PyObject *self, PyObject *args) { | ||
| 86 | + | ||
| 87 | + int rc; | ||
| 88 | + int timeout = 60; | ||
| 89 | + | ||
| 90 | + if (!PyArg_ParseTuple(args, "|i", &timeout)) { | ||
| 91 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 92 | + return NULL; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + try { | ||
| 96 | + | ||
| 97 | + rc = ((pw3270_TerminalObject *) self)->session->wait_for_ready(timeout); | ||
| 98 | + | ||
| 99 | + } catch(std::exception &e) { | ||
| 100 | + | ||
| 101 | + PyErr_SetString(terminalError, e.what()); | ||
| 102 | + return NULL; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + return PyLong_FromLong(rc); | ||
| 106 | + | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + | ||
| 110 | + PyObject * terminal_wait_for_string_at(PyObject *self, PyObject *args) { | ||
| 111 | + | ||
| 112 | + int row, col, rc; | ||
| 113 | + int timeout = 10; | ||
| 114 | + const char *text; | ||
| 115 | + | ||
| 116 | + if (!PyArg_ParseTuple(args, "iis|i", &row, &col, &text, &timeout)) { | ||
| 117 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 118 | + return NULL; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + try { | ||
| 122 | + | ||
| 123 | + rc = ((pw3270_TerminalObject *) self)->session->wait_for_string_at(row,col,text,timeout); | ||
| 124 | + | ||
| 125 | + } catch(std::exception &e) { | ||
| 126 | + | ||
| 127 | + PyErr_SetString(terminalError, e.what()); | ||
| 128 | + return NULL; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + return PyLong_FromLong(rc); | ||
| 132 | + | ||
| 133 | + } | ||
| 134 | + |
| @@ -0,0 +1,86 @@ | @@ -0,0 +1,86 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como set.cc e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + * Referências: | ||
| 29 | + * | ||
| 30 | + * <https://docs.python.org/2/extending/newtypes.html> | ||
| 31 | + * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 32 | + * | ||
| 33 | + */ | ||
| 34 | + | ||
| 35 | + #include "private.h" | ||
| 36 | + | ||
| 37 | + | ||
| 38 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 39 | + | ||
| 40 | + PyObject * terminal_set_string_at(PyObject *self, PyObject *args) { | ||
| 41 | + | ||
| 42 | + int row, col, rc; | ||
| 43 | + const char *text; | ||
| 44 | + | ||
| 45 | + if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { | ||
| 46 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 47 | + return NULL; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + try { | ||
| 51 | + | ||
| 52 | + rc = ((pw3270_TerminalObject *) self)->session->set_string_at(row,col,text); | ||
| 53 | + | ||
| 54 | + } catch(std::exception &e) { | ||
| 55 | + | ||
| 56 | + PyErr_SetString(terminalError, e.what()); | ||
| 57 | + return NULL; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + return PyLong_FromLong(rc); | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + PyObject * terminal_set_cursor_at(PyObject *self, PyObject *args) { | ||
| 65 | + | ||
| 66 | + int row, col, rc; | ||
| 67 | + | ||
| 68 | + if (!PyArg_ParseTuple(args, "ii", &row, &col)) { | ||
| 69 | + PyErr_SetString(terminalError, strerror(EINVAL)); | ||
| 70 | + return NULL; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + try { | ||
| 74 | + | ||
| 75 | + rc = ((pw3270_TerminalObject *) self)->session->set_cursor_position(row,col); | ||
| 76 | + | ||
| 77 | + } catch(std::exception &e) { | ||
| 78 | + | ||
| 79 | + PyErr_SetString(terminalError, e.what()); | ||
| 80 | + return NULL; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + return PyLong_FromLong(rc); | ||
| 84 | + | ||
| 85 | + } | ||
| 86 | + |
| @@ -0,0 +1,87 @@ | @@ -0,0 +1,87 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como py3270.cc e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + * Implementa métodos básicos inicio/final do objeto python | ||
| 29 | + * | ||
| 30 | + * Referências: | ||
| 31 | + * | ||
| 32 | + * <https://docs.python.org/2/extending/newtypes.html> | ||
| 33 | + * <https://docs.python.org/2.7/extending/extending.html#a-simple-example> | ||
| 34 | + * | ||
| 35 | + */ | ||
| 36 | + | ||
| 37 | + #include "private.h" | ||
| 38 | + | ||
| 39 | + | ||
| 40 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | ||
| 41 | + | ||
| 42 | +PyObject * terminal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { | ||
| 43 | + | ||
| 44 | + PW3270_NAMESPACE::session * session; | ||
| 45 | + const char *id = ""; | ||
| 46 | + | ||
| 47 | + if (!PyArg_ParseTuple(args, "s", &id)) { | ||
| 48 | + id = ""; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + trace("%s(%s)",__FUNCTION__,id); | ||
| 52 | + | ||
| 53 | + try { | ||
| 54 | + | ||
| 55 | + session = PW3270_NAMESPACE::session::create(id); | ||
| 56 | + | ||
| 57 | + } catch(std::exception &e) { | ||
| 58 | + | ||
| 59 | + trace("%s failed: %s",__FUNCTION__,e.what()); | ||
| 60 | + PyErr_SetString(terminalError, e.what()); | ||
| 61 | + return NULL; | ||
| 62 | + | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + pw3270_TerminalObject *self = (pw3270_TerminalObject *) type->tp_alloc(type, 0); | ||
| 66 | + | ||
| 67 | + self->session = session; | ||
| 68 | + | ||
| 69 | + return (PyObject *)self; | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | + | ||
| 73 | +int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds) { | ||
| 74 | + | ||
| 75 | + return 0; | ||
| 76 | + | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +void terminal_dealloc(pw3270_TerminalObject * self) { | ||
| 80 | + | ||
| 81 | + trace("%s",__FUNCTION__); | ||
| 82 | + | ||
| 83 | + delete self->session; | ||
| 84 | + | ||
| 85 | + self->ob_type->tp_free((PyObject*)self); | ||
| 86 | + | ||
| 87 | +} |