Commit 36238ae418522b954cb2467523481d8e38a45c6c

Authored by Perry Werneck
1 parent 6688c6aa
Exists in master

Refactoring for python3 and version 5.2

@@ -24,26 +24,51 @@ @@ -24,26 +24,51 @@
24 # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) 24 # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
25 # 25 #
26 26
27 -SOURCES=actions.cc get.cc init.cc misc.cc py3270.cc set.cc  
28 -LIBNAME=py3270@DLLEXT@ 27 +#---[ Library configuration ]------------------------------------------------------------
29 28
30 -#---[ Configuration values ]------------------------------------------------------------- 29 +LIBNAME=tn3270
31 30
32 -PACKAGE_NAME=@PACKAGE_NAME@  
33 -PACKAGE_VERSION=@PACKAGE_VERSION@  
34 -PACKAGE_TARNAME=@PACKAGE_TARNAME@ 31 +SOURCES= \
  32 + $(wildcard src/module/*.cc) \
  33 + $(wildcard src/module/@OSNAME@/*.cc) \
  34 + $(wildcard src/terminal/*.cc)
  35 +
  36 +#---[ Tools ]----------------------------------------------------------------------------
  37 +
  38 +CXX=@CXX@
  39 +LD=@CXX@
  40 +LN_S=@LN_S@
  41 +MKDIR=@MKDIR_P@
  42 +INSTALL=@INSTALL@
  43 +INSTALL_DATA=@INSTALL_DATA@
  44 +INSTALL_PROGRAM=@INSTALL_PROGRAM@
  45 +XGETTEXT=@XGETTEXT@
  46 +MSGCAT=@MSGCAT@
  47 +WINDRES=@WINDRES@
  48 +AR=@AR@
  49 +VALGRIND=@VALGRIND@
  50 +GENMARSHAL=@GENMARSHAL@
  51 +CONVERT=@CONVERT@
  52 +OPTIPNG=@OPTIPNG@
  53 +ZIP=@ZIP@
  54 +DOXYGEN=@DOXYGEN@
  55 +
  56 +#---[ Paths ]----------------------------------------------------------------------------
35 57
36 prefix=@prefix@ 58 prefix=@prefix@
37 exec_prefix=@exec_prefix@ 59 exec_prefix=@exec_prefix@
38 bindir=@bindir@ 60 bindir=@bindir@
39 sbindir=@sbindir@ 61 sbindir=@sbindir@
40 libdir=@libdir@ 62 libdir=@libdir@
  63 +includedir=@includedir@
  64 +datarootdir=@datarootdir@
  65 +localedir=@localedir@
  66 +docdir=@docdir@
  67 +sysconfdir=@sysconfdir@
41 68
42 BASEDIR=@BASEDIR@ 69 BASEDIR=@BASEDIR@
43 -SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)  
44 -PYTHONLIBPATH=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`  
45 70
46 -OBJDIR=$(BASEDIR)/.obj 71 +OBJDIR=$(BASEDIR)/.obj/$(LIBNAME)
47 OBJDBG=$(OBJDIR)/Debug 72 OBJDBG=$(OBJDIR)/Debug
48 OBJRLS=$(OBJDIR)/Release 73 OBJRLS=$(OBJDIR)/Release
49 74
@@ -51,218 +76,143 @@ BINDIR=$(BASEDIR)/.bin @@ -51,218 +76,143 @@ BINDIR=$(BASEDIR)/.bin
51 BINDBG=$(BINDIR)/Debug 76 BINDBG=$(BINDIR)/Debug
52 BINRLS=$(BINDIR)/Release 77 BINRLS=$(BINDIR)/Release
53 78
54 -INSTALL=@INSTALL@  
55 -INSTALL_DATA=@INSTALL_DATA@  
56 -INSTALL_PROGRAM=@INSTALL_PROGRAM@  
57 -  
58 -LN_S=@LN_S@  
59 -  
60 -VALGRIND=@VALGRIND@  
61 -AMTAR=@AMTAR@  
62 -SHELL=@SHELL@  
63 -STRIP=@STRIP@  
64 -MKDIR=@MKDIR_P@  
65 -RPMBUILD=@RPMBUILD@ 79 +#---[ Rules ]----------------------------------------------------------------------------
66 80
67 -CXX=@CXX@  
68 -CC=@CC@  
69 -LD=@CXX@ 81 +DEPENDS= \
  82 + Makefile \
  83 + src/include/*.h
70 84
71 -LIBS=\  
72 - -lpw3270cpp \  
73 - @PYTHON_LIBS@ \  
74 - @DBUS_LIBS@ \  
75 - @LIBS@ \  
76 - @LIBICONV@ \  
77 85
78 -CFLAGS=\ 86 +CFLAGS= \
79 @CFLAGS@ \ 87 @CFLAGS@ \
80 @PYTHON_CFLAGS@ \ 88 @PYTHON_CFLAGS@ \
81 - @DBUS_CFLAGS@ 89 + -g \
  90 + -Isrc/include \
  91 + -DBUILD_DATE=`date +%Y%m%d` \
  92 + @IPC3270_CFLAGS@
82 93
83 -LDFLAGS=\  
84 - @LDFLAGS@ 94 +LDFLAGS= \
  95 + @LDFLAGS@
85 96
86 -#---[ Rules ]---------------------------------------------------------------------------- 97 +LIBS= \
  98 + @LIBS@ \
  99 + @PYTHON_LIBS@ \
  100 + @IPC3270_LIBS@
87 101
88 -DEPENDS=src/*.h Makefile 102 +#---[ Debug Rules ]----------------------------------------------------------------------
89 103
90 $(OBJDBG)/%.o: \ 104 $(OBJDBG)/%.o: \
91 - src/%.cc \ 105 + %.cc \
92 $(DEPENDS) 106 $(DEPENDS)
93 107
94 @echo $< ... 108 @echo $< ...
95 - @$(MKDIR) `dirname $@`  
96 - @$(CXX) $(CFLAGS) -fstack-check \  
97 - -DDEBUG=1 \  
98 - -DBUILD_DATE=`date +"%Y%m%d"`\  
99 - -g -o $@ -c $< 109 + @$(MKDIR) $(dir $@)
100 110
101 -$(OBJRLS)/%.o: \  
102 - src/%.cc \  
103 - $(DEPENDS) 111 + @$(CXX) \
  112 + $(CFLAGS) \
  113 + -Wall -Wextra -fstack-check \
  114 + -DDEBUG=1 \
  115 + -o $@ \
  116 + -c $<
  117 +
  118 +$(OBJDBG)/%.o: \
  119 + %.rc
104 120
105 @echo $< ... 121 @echo $< ...
106 - @$(MKDIR) `dirname $@`  
107 - @$(CXX) $(CFLAGS) \  
108 - -DNDEBUG=1 \  
109 - -DBUILD_DATE=`date +"%Y%m%d"` \  
110 - -o $@ -c $< 122 + @$(MKDIR) $(dir $@)
  123 + @$(WINDRES) $< -O coff -o $@
111 124
112 -%.tar.bz2: \  
113 - %.tar 125 +#---[ Release Rules ]--------------------------------------------------------------------
  126 +
  127 +$(OBJRLS)/%.o: \
  128 + %.cc \
  129 + $(DEPENDS)
114 130
115 @echo $< ... 131 @echo $< ...
116 - @bzip2 --compress -9 --stdout $< > $@  
117 - @chmod 0644 $@ 132 + @$(MKDIR) $(dir $@)
  133 + @$(CXX) \
  134 + $(CFLAGS) \
  135 + -DNDEBUG=1 \
  136 + -o $@ \
  137 + -c $<
118 138
119 -%.tar.gz: \  
120 - %.tar 139 +$(OBJRLS)/%.o: \
  140 + %.rc
121 141
122 @echo $< ... 142 @echo $< ...
123 - @gzip -9 --stdout $< > $@  
124 - @chmod 0644 $@ 143 + @$(MKDIR) $(dir $@)
  144 + @$(WINDRES) $< -O coff -o $@
125 145
126 #---[ Release Targets ]------------------------------------------------------------------ 146 #---[ Release Targets ]------------------------------------------------------------------
127 147
128 all: \ 148 all: \
129 - $(BINRLS)/$(LIBNAME) 149 + $(BINRLS)/$(LIBNAME)@DLLEXT@
130 150
131 Release: \ 151 Release: \
132 - $(BINRLS)/$(LIBNAME) 152 + $(BINRLS)/$(LIBNAME)@DLLEXT@
133 153
134 -install: \  
135 - $(BINRLS)/$(LIBNAME) 154 +$(BINRLS)/$(LIBNAME)@DLLEXT@: \
  155 + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)
  156 +
  157 + @$(MKDIR) $(dir $@)
  158 + @echo $< ...
  159 + @$(LD) \
  160 + -shared -Wl,-soname,$(@F) \
  161 + -o $@ \
  162 + $(LDFLAGS) \
  163 + $^ \
  164 + $(LIBS)
136 165
137 - @$(MKDIR) $(DESTDIR)/$(PYTHONLIBPATH)  
138 - @$(INSTALL_PROGRAM) $(BINRLS)/py3270@DLLEXT@ $(DESTDIR)/$(PYTHONLIBPATH)/py3270@DLLEXT@ 166 +#---[ Install Targets ]------------------------------------------------------------------
139 167
140 -zip: \  
141 - py3270-@PACKAGE_VERSION@.@host_cpu@.zip 168 +install: \
  169 + $(BINRLS)/$(LIBNAME)@DLLEXT@
142 170
143 -py3270-@PACKAGE_VERSION@.@host_cpu@.zip: \  
144 - Makefile \  
145 - $(BINRLS)/py3270@DLLEXT@  
146 -  
147 - @rm -f $@  
148 - @zip -9 -j $@ $(BINRLS)/py3270@DLLEXT@  
149 -  
150 -tgz: \  
151 - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz  
152 -  
153 -bz2: \  
154 - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2  
155 -  
156 -tar: \  
157 - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar  
158 -  
159 -rpm: \  
160 - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2  
161 -  
162 -ifneq ($(RPMBUILD),no)  
163 - @$(MKDIR) $(BASEDIR)/rpm  
164 - @$(MKDIR) $(BASEDIR)/rpm/SPECS  
165 - @$(MKDIR) $(BASEDIR)/rpm/SOURCES  
166 - @$(MKDIR) $(BASEDIR)/rpm/SRPMS  
167 - @$(MKDIR) $(BASEDIR)/rpm/RPMS  
168 - @$(MKDIR) $(BASEDIR)/rpm/BUILD  
169 - @$(MKDIR) $(BASEDIR)/rpm/BUILDROOT  
170 - @umask 002 ; $(RPMBUILD) \  
171 - --define="_topdir $(BASEDIR)/rpm" \  
172 - --define="_packager $(USER)@$(HOSTNAME)" \  
173 - --clean \  
174 - -ta $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2  
175 -endif  
176 -  
177 -srpm: \  
178 - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2  
179 -  
180 -ifneq ($(RPMBUILD),no)  
181 - @$(MKDIR) $(BASEDIR)/rpm  
182 - @$(MKDIR) $(BASEDIR)/rpm/SPECS  
183 - @$(MKDIR) $(BASEDIR)/rpm/SOURCES  
184 - @$(MKDIR) $(BASEDIR)/rpm/SRPMS  
185 - @$(MKDIR) $(BASEDIR)/rpm/RPMS  
186 - @$(MKDIR) $(BASEDIR)/rpm/BUILD  
187 - @$(MKDIR) $(BASEDIR)/rpm/BUILDROOT  
188 - @umask 002 ; $(RPMBUILD) \  
189 - --define="_topdir $(PWD)/rpm" \  
190 - --define="_packager $(USER)@$(HOSTNAME)" \  
191 - --clean \  
192 - -ts $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2  
193 - @find rpm -iname "*.rpm" -exec chmod 664 {} \;  
194 -endif  
195 -  
196 -$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar: \  
197 - $(SRCDIR)  
198 -  
199 - @$(AMTAR) \  
200 - --verbose \  
201 - --format=ustar \  
202 - --create \  
203 - --exclude-vcs \  
204 - --directory $(BASEDIR)/.src \  
205 - --owner=root \  
206 - --group=root \  
207 - --file=$@ \  
208 - $(PACKAGE_TARNAME)-@PACKAGE_VERSION@  
209 -  
210 -  
211 -$(SRCDIR): \  
212 - clean \  
213 -  
214 - # Copia fontes  
215 - @$(MKDIR) $(SRCDIR)/src  
216 - @cp src/*.cc $(SRCDIR)/src  
217 - @cp src/*.in $(SRCDIR)/src  
218 - @cp src/private.h $(SRCDIR)/src  
219 -  
220 - # Copia extras  
221 - @cp -r scripts $(SRCDIR)  
222 - @cp -r testprograms $(SRCDIR)  
223 -  
224 - # Copia documentos  
225 - @cp AUTHORS $(SRCDIR)  
226 - @cp LICENCA $(SRCDIR)  
227 - @cp LICENSE $(SRCDIR)  
228 - @cp README.md $(SRCDIR)  
229 -  
230 - # Copia configuradores  
231 - @cp configure.ac $(SRCDIR)  
232 - @cp *.in $(SRCDIR)  
233 - @cp *.sh $(SRCDIR)  
234 - @cp *.cbp $(SRCDIR)  
235 - @cp rpm/*.spec $(SRCDIR)  
236 -  
237 -$(BINRLS)/$(LIBNAME): \  
238 - $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)  
239 171
240 - @echo $(basename $@) ...  
241 - @$(MKDIR) `dirname $@`  
242 - @$(LD) -shared -Wl,-soname,$(LIBNAME) $(LDFLAGS) -o $@ $^ $(LIBS) 172 +#---[ Debug Targets ]--------------------------------------------------------------------
243 173
244 Debug: \ 174 Debug: \
245 - $(BINDBG)/$(LIBNAME) 175 + $(BINDBG)/$(LIBNAME)@DLLEXT@
  176 +
  177 +
  178 +run: \
  179 + $(BINDBG)/$(LIBNAME)@DLLEXT@
  180 +
  181 + @PYTHONPATH=$(BINDBG) python3 \
  182 + ./testprograms/sample.py
246 183
247 -$(BINDBG)/$(LIBNAME): \ 184 +$(BINDBG)/$(LIBNAME)@DLLEXT@: \
248 $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) 185 $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o)
249 186
250 - @echo $(basename $@) ...  
251 - @$(MKDIR) `dirname $@`  
252 - @$(LD) -shared -Wl,-soname,$(LIBNAME) $(LDFLAGS) -o $@ $^ $(LIBS) 187 + @$(MKDIR) $(dir $@)
  188 + @echo $< ...
  189 + @$(LD) \
  190 + -shared -Wl,-soname,$(@F) \
  191 + -o $@ \
  192 + -L$(BINDBG) \
  193 + $(LDFLAGS) \
  194 + $^ \
  195 + $(LIBS)
253 196
254 -run: \  
255 - $(BINDBG)/$(LIBNAME)  
256 197
257 - PYTHONPATH=$(BINDBG) python ./testprograms/sample.py 198 +#---[ Clean Targets ]--------------------------------------------------------------------
  199 +
  200 +clean: \
  201 + cleanDebug \
  202 + cleanRelease
  203 +
  204 +cleanDebug:
  205 +
  206 + @rm -fr $(OBJDBG)
  207 + @rm -fr $(BINDBG)
  208 +
  209 +cleanRelease:
258 210
259 -cleanDebug: \  
260 - clean 211 + @rm -fr $(OBJRLS)
  212 + @rm -fr $(BINRLS)
261 213
262 -clean:  
263 -  
264 - @rm -fr $(BINDIR)  
265 - @rm -fr $(OBJDIR)  
266 - @rm -fr $(SRCDIR) 214 +clean: \
  215 + cleanDebug \
  216 + cleanRelease
267 217
268 218
@@ -31,7 +31,7 @@ AC_PREREQ(2.61) @@ -31,7 +31,7 @@ AC_PREREQ(2.61)
31 31
32 dnl Initialise automake with the package name, version and 32 dnl Initialise automake with the package name, version and
33 dnl bug-reporting address. 33 dnl bug-reporting address.
34 -AC_INIT([py3270], [5.2], [perry.werneck@gmail.com]) 34 +AC_INIT([python3-tn3270], [5.2], [perry.werneck@gmail.com])
35 35
36 dnl Place auxilliary scripts here. 36 dnl Place auxilliary scripts here.
37 AC_CONFIG_AUX_DIR([scripts]) 37 AC_CONFIG_AUX_DIR([scripts])
@@ -60,7 +60,10 @@ dnl --------------------------------------------------------------------------- @@ -60,7 +60,10 @@ dnl ---------------------------------------------------------------------------
60 dnl Version info 60 dnl Version info
61 dnl --------------------------------------------------------------------------- 61 dnl ---------------------------------------------------------------------------
62 62
63 -AC_SUBST(PACKAGE_DESCRIPTION,"Python binding for pw3270/lib3270") 63 +app_cv_description="Python binding for pw3270/lib3270"
  64 +
  65 +AC_SUBST(PACKAGE_DESCRIPTION,"$app_cv_description")
  66 +AC_DEFINE_UNQUOTED(PACKAGE_DESCRIPTION,"$app_cv_description")
64 67
65 app_vrs_major=$(echo $VERSION | cut -d. -f1) 68 app_vrs_major=$(echo $VERSION | cut -d. -f1)
66 app_vrs_minor=$(echo $VERSION | cut -d. -f2) 69 app_vrs_minor=$(echo $VERSION | cut -d. -f2)
@@ -71,16 +74,19 @@ AC_DEFINE_UNQUOTED(PACKAGE_MINOR_VERSION, $app_vrs_minor) @@ -71,16 +74,19 @@ AC_DEFINE_UNQUOTED(PACKAGE_MINOR_VERSION, $app_vrs_minor)
71 AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major) 74 AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major)
72 AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor) 75 AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor)
73 76
74 -AC_ARG_WITH([release], [AS_HELP_STRING([--with-release], [Set release])], [ app_cv_release="$withval" ],[ app_cv_release="`date +%-y`.`date +%-m`.`date +%-d`" ]) 77 +app_cv_release="`date +%-y`.`date +%-m`.`date +%-d`"
  78 +app_cv_revision=`date +%y%m%d`
75 79
76 app_rls_major=$(echo $app_cv_release.0.0 | cut -d. -f1) 80 app_rls_major=$(echo $app_cv_release.0.0 | cut -d. -f1)
77 app_rls_minor=$(echo $app_cv_release.0.0 | cut -d. -f2) 81 app_rls_minor=$(echo $app_cv_release.0.0 | cut -d. -f2)
78 82
79 AC_DEFINE_UNQUOTED(PACKAGE_RELEASE, $app_cv_release) 83 AC_DEFINE_UNQUOTED(PACKAGE_RELEASE, $app_cv_release)
  84 +AC_DEFINE_UNQUOTED(PACKAGE_REVISION,$app_cv_revision)
80 AC_DEFINE_UNQUOTED(PACKAGE_MAJOR_RELEASE, $app_rls_major) 85 AC_DEFINE_UNQUOTED(PACKAGE_MAJOR_RELEASE, $app_rls_major)
81 AC_DEFINE_UNQUOTED(PACKAGE_MINOR_RELEASE, $app_rls_minor) 86 AC_DEFINE_UNQUOTED(PACKAGE_MINOR_RELEASE, $app_rls_minor)
82 87
83 AC_SUBST(PACKAGE_RELEASE,$app_cv_release) 88 AC_SUBST(PACKAGE_RELEASE,$app_cv_release)
  89 +AC_SUBST(PACKAGE_REVISION,$app_cv_revision)
84 AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major) 90 AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major)
85 AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor) 91 AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor)
86 92
@@ -102,7 +108,7 @@ case &quot;$host&quot; in @@ -102,7 +108,7 @@ case &quot;$host&quot; in
102 app_win32_file_version=$(date +%-y,%-m,%-d,%-H) 108 app_win32_file_version=$(date +%-y,%-m,%-d,%-H)
103 AC_SUBST(WIN32_FILE_VERSION,$app_win32_file_version) 109 AC_SUBST(WIN32_FILE_VERSION,$app_win32_file_version)
104 110
105 -dnl AC_CONFIG_FILES(src/core/windows/resources.rc) 111 + AC_CONFIG_FILES(src/module/windows/resources.rc)
106 dnl AC_CONFIG_FILES(win/py3270.nsi) 112 dnl AC_CONFIG_FILES(win/py3270.nsi)
107 113
108 if test "$host_cpu" = "x86_64"; then 114 if test "$host_cpu" = "x86_64"; then
@@ -115,7 +121,7 @@ dnl app_cv_winarch=&quot;32&quot; @@ -115,7 +121,7 @@ dnl app_cv_winarch=&quot;32&quot;
115 121
116 AC_SUBST(PROGRAMFILES,$app_cv_programfiles) 122 AC_SUBST(PROGRAMFILES,$app_cv_programfiles)
117 dnl AC_SUBST(WINARCH,$app_cv_winarch) 123 dnl AC_SUBST(WINARCH,$app_cv_winarch)
118 - AC_SUBST(SONAME,py3270.dll) 124 +dnl AC_SUBST(SONAME,py3270.dll)
119 125
120 ;; 126 ;;
121 127
@@ -125,7 +131,7 @@ dnl AC_SUBST(WINARCH,$app_cv_winarch) @@ -125,7 +131,7 @@ dnl AC_SUBST(WINARCH,$app_cv_winarch)
125 app_cv_osname="linux" 131 app_cv_osname="linux"
126 LOGDIR="/var/log" 132 LOGDIR="/var/log"
127 DLLEXT=".so" 133 DLLEXT=".so"
128 - AC_SUBST(SONAME,py3270.so.$app_vrs_major.$app_vrs_minor) 134 +dnl AC_SUBST(SONAME,py3270.so.$app_vrs_major.$app_vrs_minor)
129 135
130 esac 136 esac
131 137
@@ -203,12 +209,66 @@ dnl --------------------------------------------------------------------------- @@ -203,12 +209,66 @@ dnl ---------------------------------------------------------------------------
203 dnl Check for Python 209 dnl Check for Python
204 dnl --------------------------------------------------------------------------- 210 dnl ---------------------------------------------------------------------------
205 211
206 -PKG_CHECK_MODULES( [PYTHON], [python], AC_DEFINE(HAVE_PYTHON), AC_MSG_ERROR([Python devel is unavailable])) 212 +PKG_CHECK_MODULES( [PYTHON], [python3], AC_DEFINE(HAVE_PYTHON3), AC_MSG_ERROR([Python devel is unavailable]))
207 213
208 AC_SUBST(PYTHON_LIBS) 214 AC_SUBST(PYTHON_LIBS)
209 AC_SUBST(PYTHON_CFLAGS) 215 AC_SUBST(PYTHON_CFLAGS)
210 216
211 dnl --------------------------------------------------------------------------- 217 dnl ---------------------------------------------------------------------------
  218 +dnl Check for ELF symbol visibility support
  219 +dnl ---------------------------------------------------------------------------
  220 +m4_define([GLIB_CHECK_COMPILE_WARNINGS],
  221 +[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
  222 +rm -f conftest.$ac_objext
  223 +glib_ac_compile_save="$ac_compile"
  224 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext'
  225 +AS_IF([_AC_EVAL_STDERR($ac_compile) &&
  226 + AC_TRY_COMMAND([(if test -s conftest.err; then false ; else true; fi)])],
  227 + [$2],
  228 + [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
  229 +cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
  230 +m4_ifvaln([$3],[$3])dnl])
  231 +ac_compile="$glib_ac_compile_save"
  232 +rm -f conftest.$ac_objext conftest.err m4_ifval([$1], [conftest.$ac_ext])[]dnl
  233 +])# GLIB_CHECK_COMPILE_WARNINGS
  234 +
  235 +AC_MSG_CHECKING(for GNUC visibility attribute)
  236 +GLIB_CHECK_COMPILE_WARNINGS([
  237 +void
  238 +__attribute__ ((visibility ("hidden")))
  239 + f_hidden (void)
  240 +{
  241 +}
  242 +void
  243 +__attribute__ ((visibility ("internal")))
  244 + f_internal (void)
  245 +{
  246 +}
  247 +void
  248 +__attribute__ ((visibility ("protected")))
  249 + f_protected (void)
  250 +{
  251 +}
  252 +void
  253 +__attribute__ ((visibility ("default")))
  254 + f_default (void)
  255 +{
  256 +}
  257 +int main (int argc, char **argv)
  258 +{
  259 + f_hidden();
  260 + f_internal();
  261 + f_protected();
  262 + f_default();
  263 + return 0;
  264 +}
  265 +],g_have_gnuc_visibility=yes,g_have_gnuc_visibility=no)
  266 +AC_MSG_RESULT($g_have_gnuc_visibility)
  267 +if test x$g_have_gnuc_visibility = xyes; then
  268 + AC_DEFINE(HAVE_GNUC_VISIBILITY, 1, [supports GCC visibility attributes])
  269 +fi
  270 +
  271 +dnl ---------------------------------------------------------------------------
212 dnl Check for pic 272 dnl Check for pic
213 dnl --------------------------------------------------------------------------- 273 dnl ---------------------------------------------------------------------------
214 274
@@ -254,7 +314,7 @@ dnl --------------------------------------------------------------------------- @@ -254,7 +314,7 @@ dnl ---------------------------------------------------------------------------
254 dnl Configure which files to generate. 314 dnl Configure which files to generate.
255 dnl --------------------------------------------------------------------------- 315 dnl ---------------------------------------------------------------------------
256 316
257 -# AC_CONFIG_FILES(Makefile) 317 +AC_CONFIG_FILES(Makefile)
258 318
259 dnl --------------------------------------------------------------------------- 319 dnl ---------------------------------------------------------------------------
260 dnl Output the generated config.status script. 320 dnl Output the generated config.status script.
py3270.cbp 0 → 100644
@@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
  1 +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
  2 +<CodeBlocks_project_file>
  3 + <FileVersion major="1" minor="6" />
  4 + <Project>
  5 + <Option title="Python binding for pw3270/lib3270" />
  6 + <Option makefile_is_custom="1" />
  7 + <Option pch_mode="2" />
  8 + <Option compiler="gcc" />
  9 + <Build>
  10 + <Target title="Debug">
  11 + <Option output=".bin/Debug/py3270" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
  12 + <Option object_output=".obj/Debug/" />
  13 + <Option type="3" />
  14 + <Option compiler="gcc" />
  15 + <Option host_application="./test.sh" />
  16 + <Option run_host_application_in_terminal="1" />
  17 + <Compiler>
  18 + <Add option="-g" />
  19 + <Add option="-DDEBUG=1" />
  20 + </Compiler>
  21 + </Target>
  22 + <Target title="Release">
  23 + <Option output=".bin/Release/py3270" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" />
  24 + <Option object_output=".obj/Release/" />
  25 + <Option type="3" />
  26 + <Option compiler="gcc" />
  27 + <Compiler>
  28 + <Add option="-O2" />
  29 + <Add option="-DNDEBUG=1" />
  30 + </Compiler>
  31 + <Linker>
  32 + <Add option="-s" />
  33 + </Linker>
  34 + </Target>
  35 + </Build>
  36 + <Compiler>
  37 + <Add option="-Wall" />
  38 + <Add option="`pkg-config --cflags python`" />
  39 + <Add option="-fPIC" />
  40 + </Compiler>
  41 + <Linker>
  42 + <Add option="`pkg-config --libs python dbus-1`" />
  43 + <Add library="pw3270cpp" />
  44 + </Linker>
  45 + <Unit filename="src/include/config.h" />
  46 + <Unit filename="src/include/config.h.in" />
  47 + <Unit filename="src/include/py3270.h" />
  48 + <Unit filename="src/module/init.cc" />
  49 + <Unit filename="src/module/properties.cc" />
  50 + <Unit filename="src/terminal/actions.cc" />
  51 + <Unit filename="src/terminal/get.cc" />
  52 + <Unit filename="src/terminal/init.cc" />
  53 + <Unit filename="src/terminal/misc.cc" />
  54 + <Unit filename="src/terminal/set.cc" />
  55 + <Extensions>
  56 + <code_completion />
  57 + <envvars />
  58 + <debugger />
  59 + <lib_finder disable_auto="1" />
  60 + </Extensions>
  61 + </Project>
  62 +</CodeBlocks_project_file>
python-pw3270.cbp
@@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>  
2 -<CodeBlocks_project_file>  
3 - <FileVersion major="1" minor="6" />  
4 - <Project>  
5 - <Option title="Python binding for pw3270/lib3270" />  
6 - <Option makefile_is_custom="1" />  
7 - <Option pch_mode="2" />  
8 - <Option compiler="gcc" />  
9 - <Build>  
10 - <Target title="Debug">  
11 - <Option output=".bin/Debug/py3270" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />  
12 - <Option object_output=".obj/Debug/" />  
13 - <Option type="3" />  
14 - <Option compiler="gcc" />  
15 - <Option host_application="./test.sh" />  
16 - <Option run_host_application_in_terminal="1" />  
17 - <Compiler>  
18 - <Add option="-g" />  
19 - <Add option="-DDEBUG=1" />  
20 - </Compiler>  
21 - </Target>  
22 - <Target title="Release">  
23 - <Option output=".bin/Release/py3270" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" />  
24 - <Option object_output=".obj/Release/" />  
25 - <Option type="3" />  
26 - <Option compiler="gcc" />  
27 - <Compiler>  
28 - <Add option="-O2" />  
29 - <Add option="-DNDEBUG=1" />  
30 - </Compiler>  
31 - <Linker>  
32 - <Add option="-s" />  
33 - </Linker>  
34 - </Target>  
35 - </Build>  
36 - <Compiler>  
37 - <Add option="-Wall" />  
38 - <Add option="`pkg-config --cflags python`" />  
39 - <Add option="-fPIC" />  
40 - </Compiler>  
41 - <Linker>  
42 - <Add option="`pkg-config --libs python dbus-1`" />  
43 - <Add library="pw3270cpp" />  
44 - </Linker>  
45 - <Unit filename="src/actions.cc" />  
46 - <Unit filename="src/config.h.in" />  
47 - <Unit filename="src/get.cc" />  
48 - <Unit filename="src/init.cc" />  
49 - <Unit filename="src/misc.cc" />  
50 - <Unit filename="src/private.h" />  
51 - <Unit filename="src/py3270.cc" />  
52 - <Unit filename="src/set.cc" />  
53 - <Extensions>  
54 - <code_completion />  
55 - <envvars />  
56 - <debugger />  
57 - <lib_finder disable_auto="1" />  
58 - </Extensions>  
59 - </Project>  
60 -</CodeBlocks_project_file>  
src/include/config.h.in
1 -/**  
2 - * @file config.h 1 +/*
  2 + * Software pw3270, desenvolvido com base nos códigos fontes do C3270 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.
3 * 5 *
4 - * @brief Configuração para o aplicativo. 6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
5 * 7 *
6 - * Gerado automaticamente pelo processo ./configure esse arquivo descreve  
7 - * as configurações de ambiente detectadas automaticamente. 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.
8 * 11 *
9 - * @author perry.werneck@gmail.com 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., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como config.h.in 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 de Mendonça)
10 * 27 *
11 */ 28 */
12 29
@@ -14,38 +31,12 @@ @@ -14,38 +31,12 @@
14 31
15 #define CONFIG_H_INCLUDED 1 32 #define CONFIG_H_INCLUDED 1
16 33
17 - /**  
18 - * @brief Nome do pacote.  
19 - */  
20 #undef PACKAGE_NAME 34 #undef PACKAGE_NAME
21 -  
22 - /**  
23 - * @brief Versão atual.  
24 - */  
25 #undef PACKAGE_VERSION 35 #undef PACKAGE_VERSION
26 -  
27 - /**  
28 - * @brief Revisão svn quando o pacote foi configurado.  
29 - *  
30 - */  
31 #undef PACKAGE_REVISION 36 #undef PACKAGE_REVISION
32 -  
33 - /**  
34 - * @brief Descrição do aplicativo.  
35 - */  
36 #undef PACKAGE_DESCRIPTION 37 #undef PACKAGE_DESCRIPTION
  38 + #undef PRODUCT_NAME
37 39
38 - /**  
39 - * @brief Indica se o compilador atual possui suporte a "visibility"  
40 - *  
41 - * Quando disponível indica que o compilador atual permite tornar  
42 - * visíveis numa biblioteca apenas as funções declaradas para isso  
43 - * evitando que todos os símbolos fiquem visíveis.  
44 - *  
45 - * Isso permite um melhor controle sobre quais funções podem ser usados  
46 - * pelo programa principal.  
47 - *  
48 - */  
49 #undef HAVE_GNUC_VISIBILITY 40 #undef HAVE_GNUC_VISIBILITY
50 41
51 #endif // CONFIG_H_INCLUDED 42 #endif // CONFIG_H_INCLUDED
src/include/py3270.h
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin 18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19 * St, Fifth Floor, Boston, MA 02110-1301 USA 19 * St, Fifth Floor, Boston, MA 02110-1301 USA
20 * 20 *
21 - * Este programa está nomeado como private.h e possui - linhas de código. 21 + * Este programa está nomeado como - e possui - linhas de código.
22 * 22 *
23 * Contatos: 23 * Contatos:
24 * 24 *
@@ -27,21 +27,15 @@ @@ -27,21 +27,15 @@
27 * 27 *
28 */ 28 */
29 29
30 -#ifndef PRIVATE_H_INCLUDED 30 +#ifndef PY3270_H_INCLUDED
31 31
32 - #define PRIVATE_H_INCLUDED 32 + #define PY3270_H_INCLUDED
33 33
34 - // http://stackoverflow.com/questions/28683358/error-hypot-has-not-been-declared-in-cmath-while-trying-to-embed-python  
35 - #include <cmath>  
36 -  
37 - // https://lists.gt.net/python/dev/340073  
38 - #pragma GCC diagnostic push  
39 - #pragma GCC system_header 34 + #define PY_SSIZE_T_CLEAN
40 #include <Python.h> 35 #include <Python.h>
41 - #pragma GCC diagnostic pop  
42 36
43 - #include <pw3270/pw3270cpp.h>  
44 - #include "config.h" 37 + #include <config.h>
  38 + #include <lib3270/ipc.h>
45 39
46 #if defined(_WIN32) 40 #if defined(_WIN32)
47 41
@@ -66,24 +60,18 @@ @@ -66,24 +60,18 @@
66 60
67 #endif 61 #endif
68 62
  63 + #include <functional>
69 64
70 - using namespace std;  
71 -  
72 - typedef struct {  
73 -  
74 - PyObject_HEAD  
75 -  
76 - PW3270_NAMESPACE::session * session;  
77 -  
78 - } pw3270_TerminalObject; 65 + extern "C" {
79 66
80 - extern PyObject * terminalError; 67 + DLL_PRIVATE PyObject * py3270_get_module_version(PyObject *self, PyObject *args);
  68 + DLL_PRIVATE PyObject * py3270_get_module_revision(PyObject *self, PyObject *args);
81 69
82 - extern "C" { 70 + /*
83 71
84 - DLL_PRIVATE PyObject * terminal_new(PyTypeObject *type, PyObject *args, PyObject *kwds);  
85 - DLL_PRIVATE int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds);  
86 - DLL_PRIVATE void terminal_dealloc(pw3270_TerminalObject * self); 72 + DLL_PRIVATE PyObject * py3270_alloc(PyTypeObject *type, PyObject *args, PyObject *kwds);
  73 + DLL_PRIVATE int py3270_init(py3270_TerminalObject *self, PyObject *args, PyObject *kwds);
  74 + DLL_PRIVATE void py3270_dealloc(py3270_TerminalObject * self);
87 75
88 DLL_PRIVATE PyObject * terminal_get_version(PyObject *self, PyObject *args); 76 DLL_PRIVATE PyObject * terminal_get_version(PyObject *self, PyObject *args);
89 DLL_PRIVATE PyObject * terminal_get_revision(PyObject *self, PyObject *args); 77 DLL_PRIVATE PyObject * terminal_get_revision(PyObject *self, PyObject *args);
@@ -109,7 +97,8 @@ @@ -109,7 +97,8 @@
109 97
110 DLL_PRIVATE PyObject * terminal_wait_for_ready(PyObject *self, PyObject *args); 98 DLL_PRIVATE PyObject * terminal_wait_for_ready(PyObject *self, PyObject *args);
111 DLL_PRIVATE PyObject * terminal_wait_for_string_at(PyObject *self, PyObject *args); 99 DLL_PRIVATE PyObject * terminal_wait_for_string_at(PyObject *self, PyObject *args);
  100 + */
112 101
113 } 102 }
114 103
115 -#endif // PRIVATE_H_INCLUDED 104 +#endif // PY3270_H_INCLUDED
src/module/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/module/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/module/init.cc
@@ -18,150 +18,92 @@ @@ -18,150 +18,92 @@
18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin 18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19 * St, Fifth Floor, Boston, MA 02110-1301 USA 19 * St, Fifth Floor, Boston, MA 02110-1301 USA
20 * 20 *
21 - * Este programa está nomeado como py3270.cc e possui - linhas de código. 21 + * Este programa está nomeado como - e possui - linhas de código.
22 * 22 *
23 * Contatos: 23 * Contatos:
24 * 24 *
25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) 25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) 26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27 * 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> 28 + * <https://docs.python.org/3/extending/extending.html>
34 * 29 *
35 */ 30 */
36 31
37 - #include "private.h"  
38 -  
39 -/*---[ Globals ]------------------------------------------------------------------------------------*/  
40 -  
41 - PyObject * terminalError = NULL; 32 + #include <py3270.h>
42 33
43 /*---[ Implement ]----------------------------------------------------------------------------------*/ 34 /*---[ Implement ]----------------------------------------------------------------------------------*/
44 35
45 -static PyObject * get_revision(PyObject *self, PyObject *args) { 36 +PyMODINIT_FUNC PyInit_tn3270(void)
  37 +{
  38 + static PyMethodDef methods[] = {
46 39
47 -#ifdef PACKAGE_REVISION  
48 - return PyLong_FromLong(atoi(PACKAGE_REVISION));  
49 -#else  
50 - return PyLong_FromLong(BUILD_DATE);  
51 -#endif // PACKAGE_REVISION 40 + {
  41 + "version",
  42 + py3270_get_module_version,
  43 + METH_NOARGS,
  44 + "Get " PACKAGE_NAME " version"
  45 + },
52 46
53 -} 47 + {
  48 + "revision",
  49 + py3270_get_module_revision,
  50 + METH_NOARGS,
  51 + "Get " PACKAGE_NAME " revision"
54 52
55 -static PyMethodDef terminal_methods[] = { 53 + },
56 54
57 - { "Version", terminal_get_version, METH_NOARGS, "Get the lib3270 version string." },  
58 - { "Revision", terminal_get_revision, METH_NOARGS, "Get the lib3270 revision number." }, 55 + {
  56 + NULL,
  57 + NULL,
  58 + 0,
  59 + NULL
  60 + }
59 61
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." }, 62 + };
63 63
64 - { "SetCursorPosition", terminal_set_cursor_at, METH_VARARGS, "Set cursor position." }, 64 + static struct PyModuleDef definition = {
  65 + PyModuleDef_HEAD_INIT,
  66 + "tn3270", // name of module
  67 + PACKAGE_DESCRIPTION, // module documentation, may be NUL
  68 + -1, // size of per-interpreter state of the module or -1 if the module keeps state in global variables.
  69 + methods // Module methods
  70 + };
65 71
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" }, 72 + Py_Initialize();
68 73
69 - { "Connect", terminal_connect, METH_VARARGS, "Connect to the host." },  
70 - { "Disconnect", terminal_disconnect, METH_NOARGS, "Disconnect from host." }, 74 + PyObject *module = PyModule_Create(&definition);
71 75
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." }, 76 + if(module) {
75 77
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." }, 78 + PyObject * except = PyErr_NewException("tn3270.error", NULL, NULL);
80 79
81 - {NULL} // Sentinel 80 + Py_XINCREF(except);
  81 + if (PyModule_AddObject(module, "error", except) < 0) {
  82 + Py_XDECREF(except);
  83 + Py_CLEAR(except);
  84 + Py_DECREF(module);
  85 + return NULL;
  86 + }
82 87
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 } 88 }
153 89
154 - // Adiciona objeto para tratamento de erros.  
155 - terminalError = PyErr_NewException((char *) "py3270.error", NULL, NULL);  
156 90
157 - (void) Py_INCREF(terminalError);  
158 - PyModule_AddObject(m, "error", terminalError); 91 + /*
159 92
160 - // Adiciona terminal  
161 - if(PyType_Ready(&pw3270_TerminalType) < 0)  
162 - return 93 + m = PyModule_Create(&spammodule);
  94 + if (m == NULL)
  95 + return NULL;
  96 +
  97 + SpamError = PyErr_NewException("spam.error", NULL, NULL);
  98 + Py_XINCREF(SpamError);
  99 + if (PyModule_AddObject(m, "error", SpamError) < 0) {
  100 + Py_XDECREF(SpamError);
  101 + Py_CLEAR(SpamError);
  102 + Py_DECREF(m);
  103 + return NULL;
  104 + }
163 105
164 - (void) Py_INCREF(&pw3270_TerminalType);  
165 - PyModule_AddObject(m, "Terminal", (PyObject *)&pw3270_TerminalType); 106 + */
166 107
  108 + return module;
167 } 109 }
src/module/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/module/properties.cc 0 → 100644
@@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
  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 - 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 + */
  29 +
  30 + #include <py3270.h>
  31 +
  32 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  33 +
  34 +PyObject * py3270_get_module_version(PyObject *self, PyObject *args) {
  35 + return PyUnicode_FromString(PACKAGE_VERSION);
  36 +}
  37 +
  38 +PyObject * py3270_get_module_revision(PyObject *self, PyObject *args) {
  39 + return PyLong_FromLong(PACKAGE_REVISION);
  40 +}
  41 +
src/module/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 -  
src/module/windows/resources.rc.in 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +#include <windows.h>
  2 +
  3 +VS_VERSION_INFO VERSIONINFO
  4 +FILEVERSION @WIN32_FILE_VERSION@
  5 +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,@PACKAGE_MINOR_RELEASE@
  6 +
  7 +BEGIN
  8 +
  9 + BLOCK "StringFileInfo"
  10 + BEGIN
  11 + BLOCK "080904E4"
  12 + BEGIN
  13 + VALUE "FileDescription", "@PACKAGE_DESCRIPTION@\0"
  14 + VALUE "CompanyName", "Banco do Brasil S/A.\0"
  15 + VALUE "FileVersion", "@WIN32_VERSION@\0"
  16 + VALUE "LegalCopyright", "(C) 2019 Banco do Brasil S/A. All Rights Reserved\0"
  17 + VALUE "OriginalFilename", "py3270@DLLEXT@\0"
  18 + VALUE "ProductName", "@PRODUCT_NAME@\0"
  19 + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@\0"
  20 + END
  21 + END
  22 +
  23 + BLOCK "VarFileInfo"
  24 + BEGIN
  25 + VALUE "Translation", 0x809, 0x04E4
  26 + END
  27 +
  28 +END
  29 +
src/object/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/terminal/actions.cc 0 → 100644
@@ -0,0 +1,129 @@ @@ -0,0 +1,129 @@
  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 <py3270.h>
  36 +
  37 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  38 +
  39 +/*
  40 + PyObject * terminal_pfkey(PyObject *self, PyObject *args) {
  41 +
  42 + int rc, key;
  43 +
  44 + if (!PyArg_ParseTuple(args, "i", &key)) {
  45 + PyErr_SetString(terminalError, strerror(EINVAL));
  46 + return NULL;
  47 + }
  48 +
  49 + try {
  50 +
  51 + rc = ((pw3270_TerminalObject *) self)->session->pfkey(key);
  52 +
  53 + } catch(std::exception &e) {
  54 +
  55 + PyErr_SetString(terminalError, e.what());
  56 + return NULL;
  57 + }
  58 +
  59 + return PyLong_FromLong(rc);
  60 +
  61 + }
  62 +
  63 + PyObject * terminal_pakey(PyObject *self, PyObject *args) {
  64 +
  65 + int rc, key;
  66 +
  67 + if (!PyArg_ParseTuple(args, "i", &key)) {
  68 + PyErr_SetString(terminalError, strerror(EINVAL));
  69 + return NULL;
  70 + }
  71 +
  72 + try {
  73 +
  74 + rc = ((pw3270_TerminalObject *) self)->session->pakey(key);
  75 +
  76 + } catch(std::exception &e) {
  77 +
  78 + PyErr_SetString(terminalError, e.what());
  79 + return NULL;
  80 + }
  81 +
  82 + return PyLong_FromLong(rc);
  83 +
  84 + }
  85 +
  86 + PyObject * terminal_enter(PyObject *self, PyObject *args) {
  87 +
  88 + int rc;
  89 +
  90 + try {
  91 +
  92 + rc = ((pw3270_TerminalObject *) self)->session->enter();
  93 +
  94 + } catch(std::exception &e) {
  95 +
  96 + PyErr_SetString(terminalError, e.what());
  97 + return NULL;
  98 + }
  99 +
  100 + return PyLong_FromLong(rc);
  101 +
  102 +
  103 + }
  104 +
  105 + PyObject * terminal_action(PyObject *self, PyObject *args) {
  106 +
  107 + int rc;
  108 + const char *name;
  109 +
  110 + if (!PyArg_ParseTuple(args, "s", &name)) {
  111 + PyErr_SetString(terminalError, strerror(EINVAL));
  112 + return NULL;
  113 + }
  114 +
  115 + try {
  116 +
  117 + rc = ((pw3270_TerminalObject *) self)->session->action(name);
  118 +
  119 + } catch(std::exception &e) {
  120 +
  121 + PyErr_SetString(terminalError, e.what());
  122 + return NULL;
  123 + }
  124 +
  125 + return PyLong_FromLong(rc);
  126 +
  127 +
  128 + }
  129 +*/
src/terminal/get.cc 0 → 100644
@@ -0,0 +1,156 @@ @@ -0,0 +1,156 @@
  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 <py3270.h>
  36 +
  37 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  38 +
  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 +}
  155 +
  156 +*/
src/terminal/init.cc 0 → 100644
@@ -0,0 +1,88 @@ @@ -0,0 +1,88 @@
  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 <py3270.h>
  38 +
  39 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  40 +
  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 +}
  88 +*/
src/terminal/misc.cc 0 → 100644
@@ -0,0 +1,135 @@ @@ -0,0 +1,135 @@
  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 <py3270.h>
  38 +
  39 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  40 +
  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 +
  135 +*/
src/terminal/set.cc 0 → 100644
@@ -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 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 <py3270.h>
  36 +
  37 +/*---[ Implement ]----------------------------------------------------------------------------------*/
  38 +
  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 +
  87 +*/
testprograms/sample.py
1 #!/usr/bin/python 1 #!/usr/bin/python
2 #-*- coding: utf-8 2 #-*- coding: utf-8
3 3
4 -import py3270 4 +import tn3270
5 5
6 -print "Teste extensão pw3270" 6 +print("Teste extensão pw3270")
7 7
8 -print py3270.Revision() 8 +print("Using TN3270 Version " + tn3270.version())
  9 +print(tn3270.revision())
9 10
10 -term = py3270.Terminal("") 11 +#term = py3270.Terminal("")
11 12
12 -print "Using pw3270 version " + term.Version() + " revision " + term.Revision() 13 +#print "Using pw3270 version " + term.Version() + " revision " + term.Revision()
13 14
14 -term.Connect("tn3270://zos.efglobe.com:telnet",10); 15 +#term.Connect("tn3270://zos.efglobe.com:telnet",10);
15 16
16 -print term.IsConnected()  
17 -print term.IsReady() 17 +#print term.IsConnected()
  18 +#print term.IsReady()
18 19
19 -print term.GetStringAt(14,19,38) 20 +#print term.GetStringAt(14,19,38)
20 21
21 -print "-----------------------------------------------------------------------"  
22 -print term  
23 -print "-----------------------------------------------------------------------" 22 +#print "-----------------------------------------------------------------------"
  23 +#print term
  24 +#print "-----------------------------------------------------------------------"
24 25
25 26
26 27