diff --git a/Makefile.in b/Makefile.in index 7fb3d7d..0ee460a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -24,26 +24,51 @@ # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) # -SOURCES=actions.cc get.cc init.cc misc.cc py3270.cc set.cc -LIBNAME=py3270@DLLEXT@ +#---[ Library configuration ]------------------------------------------------------------ -#---[ Configuration values ]------------------------------------------------------------- +LIBNAME=tn3270 -PACKAGE_NAME=@PACKAGE_NAME@ -PACKAGE_VERSION=@PACKAGE_VERSION@ -PACKAGE_TARNAME=@PACKAGE_TARNAME@ +SOURCES= \ + $(wildcard src/module/*.cc) \ + $(wildcard src/module/@OSNAME@/*.cc) \ + $(wildcard src/terminal/*.cc) + +#---[ Tools ]---------------------------------------------------------------------------- + +CXX=@CXX@ +LD=@CXX@ +LN_S=@LN_S@ +MKDIR=@MKDIR_P@ +INSTALL=@INSTALL@ +INSTALL_DATA=@INSTALL_DATA@ +INSTALL_PROGRAM=@INSTALL_PROGRAM@ +XGETTEXT=@XGETTEXT@ +MSGCAT=@MSGCAT@ +WINDRES=@WINDRES@ +AR=@AR@ +VALGRIND=@VALGRIND@ +GENMARSHAL=@GENMARSHAL@ +CONVERT=@CONVERT@ +OPTIPNG=@OPTIPNG@ +ZIP=@ZIP@ +DOXYGEN=@DOXYGEN@ + +#---[ Paths ]---------------------------------------------------------------------------- prefix=@prefix@ exec_prefix=@exec_prefix@ bindir=@bindir@ sbindir=@sbindir@ libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +localedir=@localedir@ +docdir=@docdir@ +sysconfdir=@sysconfdir@ BASEDIR=@BASEDIR@ -SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) -PYTHONLIBPATH=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"` -OBJDIR=$(BASEDIR)/.obj +OBJDIR=$(BASEDIR)/.obj/$(LIBNAME) OBJDBG=$(OBJDIR)/Debug OBJRLS=$(OBJDIR)/Release @@ -51,218 +76,143 @@ BINDIR=$(BASEDIR)/.bin BINDBG=$(BINDIR)/Debug BINRLS=$(BINDIR)/Release -INSTALL=@INSTALL@ -INSTALL_DATA=@INSTALL_DATA@ -INSTALL_PROGRAM=@INSTALL_PROGRAM@ - -LN_S=@LN_S@ - -VALGRIND=@VALGRIND@ -AMTAR=@AMTAR@ -SHELL=@SHELL@ -STRIP=@STRIP@ -MKDIR=@MKDIR_P@ -RPMBUILD=@RPMBUILD@ +#---[ Rules ]---------------------------------------------------------------------------- -CXX=@CXX@ -CC=@CC@ -LD=@CXX@ +DEPENDS= \ + Makefile \ + src/include/*.h -LIBS=\ - -lpw3270cpp \ - @PYTHON_LIBS@ \ - @DBUS_LIBS@ \ - @LIBS@ \ - @LIBICONV@ \ -CFLAGS=\ +CFLAGS= \ @CFLAGS@ \ @PYTHON_CFLAGS@ \ - @DBUS_CFLAGS@ + -g \ + -Isrc/include \ + -DBUILD_DATE=`date +%Y%m%d` \ + @IPC3270_CFLAGS@ -LDFLAGS=\ - @LDFLAGS@ +LDFLAGS= \ + @LDFLAGS@ -#---[ Rules ]---------------------------------------------------------------------------- +LIBS= \ + @LIBS@ \ + @PYTHON_LIBS@ \ + @IPC3270_LIBS@ -DEPENDS=src/*.h Makefile +#---[ Debug Rules ]---------------------------------------------------------------------- $(OBJDBG)/%.o: \ - src/%.cc \ + %.cc \ $(DEPENDS) @echo $< ... - @$(MKDIR) `dirname $@` - @$(CXX) $(CFLAGS) -fstack-check \ - -DDEBUG=1 \ - -DBUILD_DATE=`date +"%Y%m%d"`\ - -g -o $@ -c $< + @$(MKDIR) $(dir $@) -$(OBJRLS)/%.o: \ - src/%.cc \ - $(DEPENDS) + @$(CXX) \ + $(CFLAGS) \ + -Wall -Wextra -fstack-check \ + -DDEBUG=1 \ + -o $@ \ + -c $< + +$(OBJDBG)/%.o: \ + %.rc @echo $< ... - @$(MKDIR) `dirname $@` - @$(CXX) $(CFLAGS) \ - -DNDEBUG=1 \ - -DBUILD_DATE=`date +"%Y%m%d"` \ - -o $@ -c $< + @$(MKDIR) $(dir $@) + @$(WINDRES) $< -O coff -o $@ -%.tar.bz2: \ - %.tar +#---[ Release Rules ]-------------------------------------------------------------------- + +$(OBJRLS)/%.o: \ + %.cc \ + $(DEPENDS) @echo $< ... - @bzip2 --compress -9 --stdout $< > $@ - @chmod 0644 $@ + @$(MKDIR) $(dir $@) + @$(CXX) \ + $(CFLAGS) \ + -DNDEBUG=1 \ + -o $@ \ + -c $< -%.tar.gz: \ - %.tar +$(OBJRLS)/%.o: \ + %.rc @echo $< ... - @gzip -9 --stdout $< > $@ - @chmod 0644 $@ + @$(MKDIR) $(dir $@) + @$(WINDRES) $< -O coff -o $@ #---[ Release Targets ]------------------------------------------------------------------ all: \ - $(BINRLS)/$(LIBNAME) + $(BINRLS)/$(LIBNAME)@DLLEXT@ Release: \ - $(BINRLS)/$(LIBNAME) + $(BINRLS)/$(LIBNAME)@DLLEXT@ -install: \ - $(BINRLS)/$(LIBNAME) +$(BINRLS)/$(LIBNAME)@DLLEXT@: \ + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) + + @$(MKDIR) $(dir $@) + @echo $< ... + @$(LD) \ + -shared -Wl,-soname,$(@F) \ + -o $@ \ + $(LDFLAGS) \ + $^ \ + $(LIBS) - @$(MKDIR) $(DESTDIR)/$(PYTHONLIBPATH) - @$(INSTALL_PROGRAM) $(BINRLS)/py3270@DLLEXT@ $(DESTDIR)/$(PYTHONLIBPATH)/py3270@DLLEXT@ +#---[ Install Targets ]------------------------------------------------------------------ -zip: \ - py3270-@PACKAGE_VERSION@.@host_cpu@.zip +install: \ + $(BINRLS)/$(LIBNAME)@DLLEXT@ -py3270-@PACKAGE_VERSION@.@host_cpu@.zip: \ - Makefile \ - $(BINRLS)/py3270@DLLEXT@ - - @rm -f $@ - @zip -9 -j $@ $(BINRLS)/py3270@DLLEXT@ - -tgz: \ - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz - -bz2: \ - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 - -tar: \ - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar - -rpm: \ - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 - -ifneq ($(RPMBUILD),no) - @$(MKDIR) $(BASEDIR)/rpm - @$(MKDIR) $(BASEDIR)/rpm/SPECS - @$(MKDIR) $(BASEDIR)/rpm/SOURCES - @$(MKDIR) $(BASEDIR)/rpm/SRPMS - @$(MKDIR) $(BASEDIR)/rpm/RPMS - @$(MKDIR) $(BASEDIR)/rpm/BUILD - @$(MKDIR) $(BASEDIR)/rpm/BUILDROOT - @umask 002 ; $(RPMBUILD) \ - --define="_topdir $(BASEDIR)/rpm" \ - --define="_packager $(USER)@$(HOSTNAME)" \ - --clean \ - -ta $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 -endif - -srpm: \ - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 - -ifneq ($(RPMBUILD),no) - @$(MKDIR) $(BASEDIR)/rpm - @$(MKDIR) $(BASEDIR)/rpm/SPECS - @$(MKDIR) $(BASEDIR)/rpm/SOURCES - @$(MKDIR) $(BASEDIR)/rpm/SRPMS - @$(MKDIR) $(BASEDIR)/rpm/RPMS - @$(MKDIR) $(BASEDIR)/rpm/BUILD - @$(MKDIR) $(BASEDIR)/rpm/BUILDROOT - @umask 002 ; $(RPMBUILD) \ - --define="_topdir $(PWD)/rpm" \ - --define="_packager $(USER)@$(HOSTNAME)" \ - --clean \ - -ts $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 - @find rpm -iname "*.rpm" -exec chmod 664 {} \; -endif - -$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar: \ - $(SRCDIR) - - @$(AMTAR) \ - --verbose \ - --format=ustar \ - --create \ - --exclude-vcs \ - --directory $(BASEDIR)/.src \ - --owner=root \ - --group=root \ - --file=$@ \ - $(PACKAGE_TARNAME)-@PACKAGE_VERSION@ - - -$(SRCDIR): \ - clean \ - - # Copia fontes - @$(MKDIR) $(SRCDIR)/src - @cp src/*.cc $(SRCDIR)/src - @cp src/*.in $(SRCDIR)/src - @cp src/private.h $(SRCDIR)/src - - # Copia extras - @cp -r scripts $(SRCDIR) - @cp -r testprograms $(SRCDIR) - - # Copia documentos - @cp AUTHORS $(SRCDIR) - @cp LICENCA $(SRCDIR) - @cp LICENSE $(SRCDIR) - @cp README.md $(SRCDIR) - - # Copia configuradores - @cp configure.ac $(SRCDIR) - @cp *.in $(SRCDIR) - @cp *.sh $(SRCDIR) - @cp *.cbp $(SRCDIR) - @cp rpm/*.spec $(SRCDIR) - -$(BINRLS)/$(LIBNAME): \ - $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) - @echo $(basename $@) ... - @$(MKDIR) `dirname $@` - @$(LD) -shared -Wl,-soname,$(LIBNAME) $(LDFLAGS) -o $@ $^ $(LIBS) +#---[ Debug Targets ]-------------------------------------------------------------------- Debug: \ - $(BINDBG)/$(LIBNAME) + $(BINDBG)/$(LIBNAME)@DLLEXT@ + + +run: \ + $(BINDBG)/$(LIBNAME)@DLLEXT@ + + @PYTHONPATH=$(BINDBG) python3 \ + ./testprograms/sample.py -$(BINDBG)/$(LIBNAME): \ +$(BINDBG)/$(LIBNAME)@DLLEXT@: \ $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) - @echo $(basename $@) ... - @$(MKDIR) `dirname $@` - @$(LD) -shared -Wl,-soname,$(LIBNAME) $(LDFLAGS) -o $@ $^ $(LIBS) + @$(MKDIR) $(dir $@) + @echo $< ... + @$(LD) \ + -shared -Wl,-soname,$(@F) \ + -o $@ \ + -L$(BINDBG) \ + $(LDFLAGS) \ + $^ \ + $(LIBS) -run: \ - $(BINDBG)/$(LIBNAME) - PYTHONPATH=$(BINDBG) python ./testprograms/sample.py +#---[ Clean Targets ]-------------------------------------------------------------------- + +clean: \ + cleanDebug \ + cleanRelease + +cleanDebug: + + @rm -fr $(OBJDBG) + @rm -fr $(BINDBG) + +cleanRelease: -cleanDebug: \ - clean + @rm -fr $(OBJRLS) + @rm -fr $(BINRLS) -clean: - - @rm -fr $(BINDIR) - @rm -fr $(OBJDIR) - @rm -fr $(SRCDIR) +clean: \ + cleanDebug \ + cleanRelease diff --git a/configure.ac b/configure.ac index 0bc6f74..353705c 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ AC_PREREQ(2.61) dnl Initialise automake with the package name, version and dnl bug-reporting address. -AC_INIT([py3270], [5.2], [perry.werneck@gmail.com]) +AC_INIT([python3-tn3270], [5.2], [perry.werneck@gmail.com]) dnl Place auxilliary scripts here. AC_CONFIG_AUX_DIR([scripts]) @@ -60,7 +60,10 @@ dnl --------------------------------------------------------------------------- dnl Version info dnl --------------------------------------------------------------------------- -AC_SUBST(PACKAGE_DESCRIPTION,"Python binding for pw3270/lib3270") +app_cv_description="Python binding for pw3270/lib3270" + +AC_SUBST(PACKAGE_DESCRIPTION,"$app_cv_description") +AC_DEFINE_UNQUOTED(PACKAGE_DESCRIPTION,"$app_cv_description") app_vrs_major=$(echo $VERSION | cut -d. -f1) app_vrs_minor=$(echo $VERSION | cut -d. -f2) @@ -71,16 +74,19 @@ AC_DEFINE_UNQUOTED(PACKAGE_MINOR_VERSION, $app_vrs_minor) AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major) AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor) -AC_ARG_WITH([release], [AS_HELP_STRING([--with-release], [Set release])], [ app_cv_release="$withval" ],[ app_cv_release="`date +%-y`.`date +%-m`.`date +%-d`" ]) +app_cv_release="`date +%-y`.`date +%-m`.`date +%-d`" +app_cv_revision=`date +%y%m%d` app_rls_major=$(echo $app_cv_release.0.0 | cut -d. -f1) app_rls_minor=$(echo $app_cv_release.0.0 | cut -d. -f2) AC_DEFINE_UNQUOTED(PACKAGE_RELEASE, $app_cv_release) +AC_DEFINE_UNQUOTED(PACKAGE_REVISION,$app_cv_revision) AC_DEFINE_UNQUOTED(PACKAGE_MAJOR_RELEASE, $app_rls_major) AC_DEFINE_UNQUOTED(PACKAGE_MINOR_RELEASE, $app_rls_minor) AC_SUBST(PACKAGE_RELEASE,$app_cv_release) +AC_SUBST(PACKAGE_REVISION,$app_cv_revision) AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major) AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor) @@ -102,7 +108,7 @@ case "$host" in app_win32_file_version=$(date +%-y,%-m,%-d,%-H) AC_SUBST(WIN32_FILE_VERSION,$app_win32_file_version) -dnl AC_CONFIG_FILES(src/core/windows/resources.rc) + AC_CONFIG_FILES(src/module/windows/resources.rc) dnl AC_CONFIG_FILES(win/py3270.nsi) if test "$host_cpu" = "x86_64"; then @@ -115,7 +121,7 @@ dnl app_cv_winarch="32" AC_SUBST(PROGRAMFILES,$app_cv_programfiles) dnl AC_SUBST(WINARCH,$app_cv_winarch) - AC_SUBST(SONAME,py3270.dll) +dnl AC_SUBST(SONAME,py3270.dll) ;; @@ -125,7 +131,7 @@ dnl AC_SUBST(WINARCH,$app_cv_winarch) app_cv_osname="linux" LOGDIR="/var/log" DLLEXT=".so" - AC_SUBST(SONAME,py3270.so.$app_vrs_major.$app_vrs_minor) +dnl AC_SUBST(SONAME,py3270.so.$app_vrs_major.$app_vrs_minor) esac @@ -203,12 +209,66 @@ dnl --------------------------------------------------------------------------- dnl Check for Python dnl --------------------------------------------------------------------------- -PKG_CHECK_MODULES( [PYTHON], [python], AC_DEFINE(HAVE_PYTHON), AC_MSG_ERROR([Python devel is unavailable])) +PKG_CHECK_MODULES( [PYTHON], [python3], AC_DEFINE(HAVE_PYTHON3), AC_MSG_ERROR([Python devel is unavailable])) AC_SUBST(PYTHON_LIBS) AC_SUBST(PYTHON_CFLAGS) dnl --------------------------------------------------------------------------- +dnl Check for ELF symbol visibility support +dnl --------------------------------------------------------------------------- +m4_define([GLIB_CHECK_COMPILE_WARNINGS], +[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl +rm -f conftest.$ac_objext +glib_ac_compile_save="$ac_compile" +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext' +AS_IF([_AC_EVAL_STDERR($ac_compile) && + AC_TRY_COMMAND([(if test -s conftest.err; then false ; else true; fi)])], + [$2], + [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD +cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD +m4_ifvaln([$3],[$3])dnl]) +ac_compile="$glib_ac_compile_save" +rm -f conftest.$ac_objext conftest.err m4_ifval([$1], [conftest.$ac_ext])[]dnl +])# GLIB_CHECK_COMPILE_WARNINGS + +AC_MSG_CHECKING(for GNUC visibility attribute) +GLIB_CHECK_COMPILE_WARNINGS([ +void +__attribute__ ((visibility ("hidden"))) + f_hidden (void) +{ +} +void +__attribute__ ((visibility ("internal"))) + f_internal (void) +{ +} +void +__attribute__ ((visibility ("protected"))) + f_protected (void) +{ +} +void +__attribute__ ((visibility ("default"))) + f_default (void) +{ +} +int main (int argc, char **argv) +{ + f_hidden(); + f_internal(); + f_protected(); + f_default(); + return 0; +} +],g_have_gnuc_visibility=yes,g_have_gnuc_visibility=no) +AC_MSG_RESULT($g_have_gnuc_visibility) +if test x$g_have_gnuc_visibility = xyes; then + AC_DEFINE(HAVE_GNUC_VISIBILITY, 1, [supports GCC visibility attributes]) +fi + +dnl --------------------------------------------------------------------------- dnl Check for pic dnl --------------------------------------------------------------------------- @@ -254,7 +314,7 @@ dnl --------------------------------------------------------------------------- dnl Configure which files to generate. dnl --------------------------------------------------------------------------- -# AC_CONFIG_FILES(Makefile) +AC_CONFIG_FILES(Makefile) dnl --------------------------------------------------------------------------- dnl Output the generated config.status script. diff --git a/py3270.cbp b/py3270.cbp new file mode 100644 index 0000000..72dd957 --- /dev/null +++ b/py3270.cbp @@ -0,0 +1,62 @@ + + + + + + diff --git a/python-pw3270.cbp b/python-pw3270.cbp deleted file mode 100644 index 1cce649..0000000 --- a/python-pw3270.cbp +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - diff --git a/src/include/config.h.in b/src/include/config.h.in index 26b3ff5..2ea2386 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -1,12 +1,29 @@ -/** - * @file config.h +/* + * Software pw3270, desenvolvido com base nos códigos fontes do C3270 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. * - * @brief Configuração para o aplicativo. + * Copyright (C) <2008> * - * Gerado automaticamente pelo processo ./configure esse arquivo descreve - * as configurações de ambiente detectadas automaticamente. + * 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. * - * @author perry.werneck@gmail.com + * 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 config.h.in e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) * */ @@ -14,38 +31,12 @@ #define CONFIG_H_INCLUDED 1 - /** - * @brief Nome do pacote. - */ #undef PACKAGE_NAME - - /** - * @brief Versão atual. - */ #undef PACKAGE_VERSION - - /** - * @brief Revisão svn quando o pacote foi configurado. - * - */ #undef PACKAGE_REVISION - - /** - * @brief Descrição do aplicativo. - */ #undef PACKAGE_DESCRIPTION + #undef PRODUCT_NAME - /** - * @brief Indica se o compilador atual possui suporte a "visibility" - * - * Quando disponível indica que o compilador atual permite tornar - * visíveis numa biblioteca apenas as funções declaradas para isso - * evitando que todos os símbolos fiquem visíveis. - * - * Isso permite um melhor controle sobre quais funções podem ser usados - * pelo programa principal. - * - */ #undef HAVE_GNUC_VISIBILITY #endif // CONFIG_H_INCLUDED diff --git a/src/include/py3270.h b/src/include/py3270.h index db4e266..5b46e13 100644 --- a/src/include/py3270.h +++ b/src/include/py3270.h @@ -18,7 +18,7 @@ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin * St, Fifth Floor, Boston, MA 02110-1301 USA * - * Este programa está nomeado como private.h e possui - linhas de código. + * Este programa está nomeado como - e possui - linhas de código. * * Contatos: * @@ -27,21 +27,15 @@ * */ -#ifndef PRIVATE_H_INCLUDED +#ifndef PY3270_H_INCLUDED - #define PRIVATE_H_INCLUDED + #define PY3270_H_INCLUDED - // http://stackoverflow.com/questions/28683358/error-hypot-has-not-been-declared-in-cmath-while-trying-to-embed-python - #include - - // https://lists.gt.net/python/dev/340073 - #pragma GCC diagnostic push - #pragma GCC system_header + #define PY_SSIZE_T_CLEAN #include - #pragma GCC diagnostic pop - #include - #include "config.h" + #include + #include #if defined(_WIN32) @@ -66,24 +60,18 @@ #endif + #include - using namespace std; - - typedef struct { - - PyObject_HEAD - - PW3270_NAMESPACE::session * session; - - } pw3270_TerminalObject; + extern "C" { - extern PyObject * terminalError; + DLL_PRIVATE PyObject * py3270_get_module_version(PyObject *self, PyObject *args); + DLL_PRIVATE PyObject * py3270_get_module_revision(PyObject *self, PyObject *args); - extern "C" { + /* - DLL_PRIVATE PyObject * terminal_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - DLL_PRIVATE int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds); - DLL_PRIVATE void terminal_dealloc(pw3270_TerminalObject * self); + DLL_PRIVATE PyObject * py3270_alloc(PyTypeObject *type, PyObject *args, PyObject *kwds); + DLL_PRIVATE int py3270_init(py3270_TerminalObject *self, PyObject *args, PyObject *kwds); + DLL_PRIVATE void py3270_dealloc(py3270_TerminalObject * self); DLL_PRIVATE PyObject * terminal_get_version(PyObject *self, PyObject *args); DLL_PRIVATE PyObject * terminal_get_revision(PyObject *self, PyObject *args); @@ -109,7 +97,8 @@ DLL_PRIVATE PyObject * terminal_wait_for_ready(PyObject *self, PyObject *args); DLL_PRIVATE PyObject * terminal_wait_for_string_at(PyObject *self, PyObject *args); + */ } -#endif // PRIVATE_H_INCLUDED +#endif // PY3270_H_INCLUDED diff --git a/src/module/actions.cc b/src/module/actions.cc deleted file mode 100644 index e7cf448..0000000 --- a/src/module/actions.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como actions.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) - * - * Referências: - * - * - * - * - */ - - #include "private.h" - -/*---[ Implement ]----------------------------------------------------------------------------------*/ - - PyObject * terminal_pfkey(PyObject *self, PyObject *args) { - - int rc, key; - - if (!PyArg_ParseTuple(args, "i", &key)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->pfkey(key); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - } - - PyObject * terminal_pakey(PyObject *self, PyObject *args) { - - int rc, key; - - if (!PyArg_ParseTuple(args, "i", &key)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->pakey(key); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - } - - PyObject * terminal_enter(PyObject *self, PyObject *args) { - - int rc; - - try { - - rc = ((pw3270_TerminalObject *) self)->session->enter(); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - - } - - PyObject * terminal_action(PyObject *self, PyObject *args) { - - int rc; - const char *name; - - if (!PyArg_ParseTuple(args, "s", &name)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->action(name); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - - } - diff --git a/src/module/get.cc b/src/module/get.cc deleted file mode 100644 index d3ea909..0000000 --- a/src/module/get.cc +++ /dev/null @@ -1,154 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como get.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) - * - * Referências: - * - * - * - * - */ - - #include "private.h" - - -/*---[ Implement ]----------------------------------------------------------------------------------*/ - -PyObject * terminal_get_version(PyObject *self, PyObject *args) { - - return PyString_FromString( ((pw3270_TerminalObject *) self)->session->get_version().c_str() ); - -} - -PyObject * terminal_get_revision(PyObject *self, PyObject *args) { - - return PyString_FromString( ((pw3270_TerminalObject *) self)->session->get_revision().c_str() ); - -} - -PyObject * terminal_is_connected(PyObject *self, PyObject *args) { - - return PyBool_FromLong( ((pw3270_TerminalObject *) self)->session->is_connected() ); - -} - -PyObject * terminal_is_ready(PyObject *self, PyObject *args) { - - return PyBool_FromLong( ((pw3270_TerminalObject *) self)->session->is_ready() ); - -} - -PyObject * terminal_is_protected_at(PyObject *self, PyObject *args) { - - int rc, row, col; - - if (!PyArg_ParseTuple(args, "ii", &row, &col)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->get_is_protected_at(row,col); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyBool_FromLong( rc ); - -} - - -PyObject * terminal_cmp_string_at(PyObject *self, PyObject *args) { - - int row, col, rc; - const char *text; - - if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->cmp_string_at(row,col,text); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - -} - -PyObject * terminal_get_string_at(PyObject *self, PyObject *args) { - - int row, col, sz; - string rc; - - if (!PyArg_ParseTuple(args, "iii", &row, &col, &sz)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->get_string_at(row,col,sz); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyString_FromString(rc.c_str()); - -} - -PyObject * terminal_get_contents(PyObject *self) { - - string rc; - - try { - - rc = ((pw3270_TerminalObject *) self)->session->get_string(); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyString_FromString(rc.c_str()); - - - -} diff --git a/src/module/init.cc b/src/module/init.cc index 945bef4..03463da 100644 --- a/src/module/init.cc +++ b/src/module/init.cc @@ -18,150 +18,92 @@ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin * St, Fifth Floor, Boston, MA 02110-1301 USA * - * Este programa está nomeado como py3270.cc e possui - linhas de código. + * Este programa está nomeado como - e possui - linhas de código. * * Contatos: * * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) * - * Implementa métodos básicos para a extensão python. - * - * Referências: - * - * - * + * * */ - #include "private.h" - -/*---[ Globals ]------------------------------------------------------------------------------------*/ - - PyObject * terminalError = NULL; + #include /*---[ Implement ]----------------------------------------------------------------------------------*/ -static PyObject * get_revision(PyObject *self, PyObject *args) { +PyMODINIT_FUNC PyInit_tn3270(void) +{ + static PyMethodDef methods[] = { -#ifdef PACKAGE_REVISION - return PyLong_FromLong(atoi(PACKAGE_REVISION)); -#else - return PyLong_FromLong(BUILD_DATE); -#endif // PACKAGE_REVISION + { + "version", + py3270_get_module_version, + METH_NOARGS, + "Get " PACKAGE_NAME " version" + }, -} + { + "revision", + py3270_get_module_revision, + METH_NOARGS, + "Get " PACKAGE_NAME " revision" -static PyMethodDef terminal_methods[] = { + }, - { "Version", terminal_get_version, METH_NOARGS, "Get the lib3270 version string." }, - { "Revision", terminal_get_revision, METH_NOARGS, "Get the lib3270 revision number." }, + { + NULL, + NULL, + 0, + NULL + } - { "IsConnected", terminal_is_connected, METH_NOARGS, "True if the terminal is connected to the host." }, - { "IsReady", terminal_is_ready, METH_NOARGS, "True if the terminal has finished network activity." }, - { "IsProtected", terminal_is_protected_at, METH_VARARGS, "True if the position is read-only." }, + }; - { "SetCursorPosition", terminal_set_cursor_at, METH_VARARGS, "Set cursor position." }, + static struct PyModuleDef definition = { + PyModuleDef_HEAD_INIT, + "tn3270", // name of module + PACKAGE_DESCRIPTION, // module documentation, may be NUL + -1, // size of per-interpreter state of the module or -1 if the module keeps state in global variables. + methods // Module methods + }; - { "WaitForStringAt", terminal_wait_for_string_at, METH_VARARGS, "Wait for string at position" }, - { "WaitForReady", terminal_wait_for_ready, METH_VARARGS, "Wait for network communication to finish" }, + Py_Initialize(); - { "Connect", terminal_connect, METH_VARARGS, "Connect to the host." }, - { "Disconnect", terminal_disconnect, METH_NOARGS, "Disconnect from host." }, + PyObject *module = PyModule_Create(&definition); - { "CmpStringAt", terminal_cmp_string_at, METH_VARARGS, "Compare string with terminal buffer at the position." }, - { "GetStringAt", terminal_get_string_at, METH_VARARGS, "Get string from terminal buffer." }, - { "SetStringAt", terminal_set_string_at, METH_VARARGS, "Set string in terminal buffer." }, + if(module) { - { "PFKey", terminal_pfkey, METH_VARARGS, "Send PF key." }, - { "PAKey", terminal_pakey, METH_VARARGS, "Send PA key." }, - { "Enter", terminal_enter, METH_NOARGS, "Send Enter Key." }, - { "Action", terminal_action, METH_VARARGS, "Send Action by name." }, + PyObject * except = PyErr_NewException("tn3270.error", NULL, NULL); - {NULL} // Sentinel + Py_XINCREF(except); + if (PyModule_AddObject(module, "error", except) < 0) { + Py_XDECREF(except); + Py_CLEAR(except); + Py_DECREF(module); + return NULL; + } -}; - -/* -static PyMemberDef terminal_members[] = { - - { NULL } // Sentinel - -}; -*/ - -static PyTypeObject pw3270_TerminalType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "py3270.terminal", /*tp_name*/ - sizeof(pw3270_TerminalObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor) terminal_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - terminal_get_contents, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "3270 terminal object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - terminal_methods, /* tp_methods */ - 0, // terminal_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) terminal_init, /* tp_init */ - 0, /* tp_alloc */ - terminal_new, /* tp_new */ - -}; - -static PyMethodDef MyMethods[] = { - - { "Revision", get_revision, METH_VARARGS, "Get module revision." }, - - {NULL, NULL, 0, NULL} /* Sentinel */ - -}; - -PyMODINIT_FUNC initpy3270(void) { - - // Cria o módulo - - PyObject *m = Py_InitModule("py3270", MyMethods); - - if (m == NULL) { - return; } - // Adiciona objeto para tratamento de erros. - terminalError = PyErr_NewException((char *) "py3270.error", NULL, NULL); - (void) Py_INCREF(terminalError); - PyModule_AddObject(m, "error", terminalError); + /* - // Adiciona terminal - if(PyType_Ready(&pw3270_TerminalType) < 0) - return + m = PyModule_Create(&spammodule); + if (m == NULL) + return NULL; + + SpamError = PyErr_NewException("spam.error", NULL, NULL); + Py_XINCREF(SpamError); + if (PyModule_AddObject(m, "error", SpamError) < 0) { + Py_XDECREF(SpamError); + Py_CLEAR(SpamError); + Py_DECREF(m); + return NULL; + } - (void) Py_INCREF(&pw3270_TerminalType); - PyModule_AddObject(m, "Terminal", (PyObject *)&pw3270_TerminalType); + */ + return module; } diff --git a/src/module/misc.cc b/src/module/misc.cc deleted file mode 100644 index d9ccb8c..0000000 --- a/src/module/misc.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como misc.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) - * - * Implementa métodos básicos inicio/final do objeto python - * - * Referências: - * - * - * - * - */ - - #include "private.h" - - -/*---[ Implement ]----------------------------------------------------------------------------------*/ - - PyObject * terminal_connect(PyObject *self, PyObject *args) { - - int rc = -1; - int wait = 60; - const char * host = ""; - - if (!PyArg_ParseTuple(args, "s|i", &host, &wait)) { - PyErr_SetString(terminalError, "connect requires a host URL"); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->connect(host,wait); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - } - - PyObject * terminal_disconnect(PyObject *self, PyObject *args) { - - int rc = -1; - - try { - - rc = ((pw3270_TerminalObject *) self)->session->disconnect(); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - } - - PyObject * terminal_wait_for_ready(PyObject *self, PyObject *args) { - - int rc; - int timeout = 60; - - if (!PyArg_ParseTuple(args, "|i", &timeout)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->wait_for_ready(timeout); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - } - - - PyObject * terminal_wait_for_string_at(PyObject *self, PyObject *args) { - - int row, col, rc; - int timeout = 10; - const char *text; - - if (!PyArg_ParseTuple(args, "iis|i", &row, &col, &text, &timeout)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->wait_for_string_at(row,col,text,timeout); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - } - diff --git a/src/module/properties.cc b/src/module/properties.cc new file mode 100644 index 0000000..28182bb --- /dev/null +++ b/src/module/properties.cc @@ -0,0 +1,41 @@ +/* + * "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., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - 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 + +/*---[ Implement ]----------------------------------------------------------------------------------*/ + +PyObject * py3270_get_module_version(PyObject *self, PyObject *args) { + return PyUnicode_FromString(PACKAGE_VERSION); +} + +PyObject * py3270_get_module_revision(PyObject *self, PyObject *args) { + return PyLong_FromLong(PACKAGE_REVISION); +} + diff --git a/src/module/set.cc b/src/module/set.cc deleted file mode 100644 index 759495d..0000000 --- a/src/module/set.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como set.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) - * - * Referências: - * - * - * - * - */ - - #include "private.h" - - -/*---[ Implement ]----------------------------------------------------------------------------------*/ - - PyObject * terminal_set_string_at(PyObject *self, PyObject *args) { - - int row, col, rc; - const char *text; - - if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->set_string_at(row,col,text); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - } - - PyObject * terminal_set_cursor_at(PyObject *self, PyObject *args) { - - int row, col, rc; - - if (!PyArg_ParseTuple(args, "ii", &row, &col)) { - PyErr_SetString(terminalError, strerror(EINVAL)); - return NULL; - } - - try { - - rc = ((pw3270_TerminalObject *) self)->session->set_cursor_position(row,col); - - } catch(std::exception &e) { - - PyErr_SetString(terminalError, e.what()); - return NULL; - } - - return PyLong_FromLong(rc); - - } - diff --git a/src/module/windows/resources.rc.in b/src/module/windows/resources.rc.in new file mode 100644 index 0000000..dcbe259 --- /dev/null +++ b/src/module/windows/resources.rc.in @@ -0,0 +1,29 @@ +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION @WIN32_FILE_VERSION@ +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,@PACKAGE_MINOR_RELEASE@ + +BEGIN + + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "FileDescription", "@PACKAGE_DESCRIPTION@\0" + VALUE "CompanyName", "Banco do Brasil S/A.\0" + VALUE "FileVersion", "@WIN32_VERSION@\0" + VALUE "LegalCopyright", "(C) 2019 Banco do Brasil S/A. All Rights Reserved\0" + VALUE "OriginalFilename", "py3270@DLLEXT@\0" + VALUE "ProductName", "@PRODUCT_NAME@\0" + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@\0" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 0x04E4 + END + +END + diff --git a/src/object/init.cc b/src/object/init.cc deleted file mode 100644 index 34b9662..0000000 --- a/src/object/init.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como py3270.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) - * - * Implementa métodos básicos inicio/final do objeto python - * - * Referências: - * - * - * - * - */ - - #include "private.h" - - -/*---[ Implement ]----------------------------------------------------------------------------------*/ - -PyObject * terminal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - - PW3270_NAMESPACE::session * session; - const char *id = ""; - - if (!PyArg_ParseTuple(args, "s", &id)) { - id = ""; - } - - trace("%s(%s)",__FUNCTION__,id); - - try { - - session = PW3270_NAMESPACE::session::create(id); - - } catch(std::exception &e) { - - trace("%s failed: %s",__FUNCTION__,e.what()); - PyErr_SetString(terminalError, e.what()); - return NULL; - - } - - pw3270_TerminalObject *self = (pw3270_TerminalObject *) type->tp_alloc(type, 0); - - self->session = session; - - return (PyObject *)self; -} - - -int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds) { - - return 0; - -} - -void terminal_dealloc(pw3270_TerminalObject * self) { - - trace("%s",__FUNCTION__); - - delete self->session; - - self->ob_type->tp_free((PyObject*)self); - -} diff --git a/src/terminal/actions.cc b/src/terminal/actions.cc new file mode 100644 index 0000000..cffd5d6 --- /dev/null +++ b/src/terminal/actions.cc @@ -0,0 +1,129 @@ +/* + * "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., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como actions.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) + * + * Referências: + * + * + * + * + */ + + #include + +/*---[ Implement ]----------------------------------------------------------------------------------*/ + +/* + PyObject * terminal_pfkey(PyObject *self, PyObject *args) { + + int rc, key; + + if (!PyArg_ParseTuple(args, "i", &key)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->pfkey(key); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + } + + PyObject * terminal_pakey(PyObject *self, PyObject *args) { + + int rc, key; + + if (!PyArg_ParseTuple(args, "i", &key)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->pakey(key); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + } + + PyObject * terminal_enter(PyObject *self, PyObject *args) { + + int rc; + + try { + + rc = ((pw3270_TerminalObject *) self)->session->enter(); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + + } + + PyObject * terminal_action(PyObject *self, PyObject *args) { + + int rc; + const char *name; + + if (!PyArg_ParseTuple(args, "s", &name)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->action(name); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + + } +*/ diff --git a/src/terminal/get.cc b/src/terminal/get.cc new file mode 100644 index 0000000..2d853e2 --- /dev/null +++ b/src/terminal/get.cc @@ -0,0 +1,156 @@ +/* + * "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., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como get.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) + * + * Referências: + * + * + * + * + */ + + #include + +/*---[ Implement ]----------------------------------------------------------------------------------*/ + +/* +PyObject * terminal_get_version(PyObject *self, PyObject *args) { + + return PyString_FromString( ((pw3270_TerminalObject *) self)->session->get_version().c_str() ); + +} + +PyObject * terminal_get_revision(PyObject *self, PyObject *args) { + + return PyString_FromString( ((pw3270_TerminalObject *) self)->session->get_revision().c_str() ); + +} + +PyObject * terminal_is_connected(PyObject *self, PyObject *args) { + + return PyBool_FromLong( ((pw3270_TerminalObject *) self)->session->is_connected() ); + +} + +PyObject * terminal_is_ready(PyObject *self, PyObject *args) { + + return PyBool_FromLong( ((pw3270_TerminalObject *) self)->session->is_ready() ); + +} + +PyObject * terminal_is_protected_at(PyObject *self, PyObject *args) { + + int rc, row, col; + + if (!PyArg_ParseTuple(args, "ii", &row, &col)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->get_is_protected_at(row,col); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyBool_FromLong( rc ); + +} + + +PyObject * terminal_cmp_string_at(PyObject *self, PyObject *args) { + + int row, col, rc; + const char *text; + + if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->cmp_string_at(row,col,text); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + +} + +PyObject * terminal_get_string_at(PyObject *self, PyObject *args) { + + int row, col, sz; + string rc; + + if (!PyArg_ParseTuple(args, "iii", &row, &col, &sz)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->get_string_at(row,col,sz); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyString_FromString(rc.c_str()); + +} + +PyObject * terminal_get_contents(PyObject *self) { + + string rc; + + try { + + rc = ((pw3270_TerminalObject *) self)->session->get_string(); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyString_FromString(rc.c_str()); + + + +} + +*/ diff --git a/src/terminal/init.cc b/src/terminal/init.cc new file mode 100644 index 0000000..7abb2f8 --- /dev/null +++ b/src/terminal/init.cc @@ -0,0 +1,88 @@ +/* + * "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., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como py3270.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) + * + * Implementa métodos básicos inicio/final do objeto python + * + * Referências: + * + * + * + * + */ + + #include + +/*---[ Implement ]----------------------------------------------------------------------------------*/ + +/* +PyObject * terminal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { + + PW3270_NAMESPACE::session * session; + const char *id = ""; + + if (!PyArg_ParseTuple(args, "s", &id)) { + id = ""; + } + + trace("%s(%s)",__FUNCTION__,id); + + try { + + session = PW3270_NAMESPACE::session::create(id); + + } catch(std::exception &e) { + + trace("%s failed: %s",__FUNCTION__,e.what()); + PyErr_SetString(terminalError, e.what()); + return NULL; + + } + + pw3270_TerminalObject *self = (pw3270_TerminalObject *) type->tp_alloc(type, 0); + + self->session = session; + + return (PyObject *)self; +} + + +int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds) { + + return 0; + +} + +void terminal_dealloc(pw3270_TerminalObject * self) { + + trace("%s",__FUNCTION__); + + delete self->session; + + self->ob_type->tp_free((PyObject*)self); + +} +*/ diff --git a/src/terminal/misc.cc b/src/terminal/misc.cc new file mode 100644 index 0000000..3c3acc3 --- /dev/null +++ b/src/terminal/misc.cc @@ -0,0 +1,135 @@ +/* + * "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., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como misc.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) + * + * Implementa métodos básicos inicio/final do objeto python + * + * Referências: + * + * + * + * + */ + + #include + +/*---[ Implement ]----------------------------------------------------------------------------------*/ + +/* + PyObject * terminal_connect(PyObject *self, PyObject *args) { + + int rc = -1; + int wait = 60; + const char * host = ""; + + if (!PyArg_ParseTuple(args, "s|i", &host, &wait)) { + PyErr_SetString(terminalError, "connect requires a host URL"); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->connect(host,wait); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + } + + PyObject * terminal_disconnect(PyObject *self, PyObject *args) { + + int rc = -1; + + try { + + rc = ((pw3270_TerminalObject *) self)->session->disconnect(); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + } + + PyObject * terminal_wait_for_ready(PyObject *self, PyObject *args) { + + int rc; + int timeout = 60; + + if (!PyArg_ParseTuple(args, "|i", &timeout)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->wait_for_ready(timeout); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + } + + + PyObject * terminal_wait_for_string_at(PyObject *self, PyObject *args) { + + int row, col, rc; + int timeout = 10; + const char *text; + + if (!PyArg_ParseTuple(args, "iis|i", &row, &col, &text, &timeout)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->wait_for_string_at(row,col,text,timeout); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + } + +*/ diff --git a/src/terminal/set.cc b/src/terminal/set.cc new file mode 100644 index 0000000..6a6b963 --- /dev/null +++ b/src/terminal/set.cc @@ -0,0 +1,87 @@ +/* + * "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., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como set.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) + * + * Referências: + * + * + * + * + */ + + #include + +/*---[ Implement ]----------------------------------------------------------------------------------*/ + +/* + PyObject * terminal_set_string_at(PyObject *self, PyObject *args) { + + int row, col, rc; + const char *text; + + if (!PyArg_ParseTuple(args, "iis", &row, &col, &text)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->set_string_at(row,col,text); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + } + + PyObject * terminal_set_cursor_at(PyObject *self, PyObject *args) { + + int row, col, rc; + + if (!PyArg_ParseTuple(args, "ii", &row, &col)) { + PyErr_SetString(terminalError, strerror(EINVAL)); + return NULL; + } + + try { + + rc = ((pw3270_TerminalObject *) self)->session->set_cursor_position(row,col); + + } catch(std::exception &e) { + + PyErr_SetString(terminalError, e.what()); + return NULL; + } + + return PyLong_FromLong(rc); + + } + +*/ diff --git a/testprograms/sample.py b/testprograms/sample.py index c7b682a..f9582bc 100644 --- a/testprograms/sample.py +++ b/testprograms/sample.py @@ -1,26 +1,27 @@ #!/usr/bin/python #-*- coding: utf-8 -import py3270 +import tn3270 -print "Teste extensão pw3270" +print("Teste extensão pw3270") -print py3270.Revision() +print("Using TN3270 Version " + tn3270.version()) +print(tn3270.revision()) -term = py3270.Terminal("") +#term = py3270.Terminal("") -print "Using pw3270 version " + term.Version() + " revision " + term.Revision() +#print "Using pw3270 version " + term.Version() + " revision " + term.Revision() -term.Connect("tn3270://zos.efglobe.com:telnet",10); +#term.Connect("tn3270://zos.efglobe.com:telnet",10); -print term.IsConnected() -print term.IsReady() +#print term.IsConnected() +#print term.IsReady() -print term.GetStringAt(14,19,38) +#print term.GetStringAt(14,19,38) -print "-----------------------------------------------------------------------" -print term -print "-----------------------------------------------------------------------" +#print "-----------------------------------------------------------------------" +#print term +#print "-----------------------------------------------------------------------" -- libgit2 0.21.2