Commit cff9cde558df936a9cd02b798621f69f32b2b918
Committed by
GitHub
Exists in
master
Merge pull request #1 from PerryWerneck/develop
Updating to version 5.2
Showing
43 changed files
with
2819 additions
and
2584 deletions
Show diff stats
.gitignore
Makefile.in
... | ... | @@ -24,8 +24,8 @@ |
24 | 24 | # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) |
25 | 25 | # |
26 | 26 | |
27 | -GLUELIB=lib3270-mono@DLLEXT@ | |
28 | -LIBNAME=pw3270-sharp.dll | |
27 | +GLUELIB=@NATIVE_SONAME@ | |
28 | +LIBNAME=tn3270-sharp.dll | |
29 | 29 | TESTPROGRAM?=sample |
30 | 30 | |
31 | 31 | #---[ Configuration values ]------------------------------------------------------------- |
... | ... | @@ -67,181 +67,73 @@ RPMBUILD=@RPMBUILD@ |
67 | 67 | #---[ Rules ]---------------------------------------------------------------------------- |
68 | 68 | |
69 | 69 | $(BINDBG)/%.exe: \ |
70 | - testprograms/%.cs \ | |
70 | + src/testprograms/%.cs \ | |
71 | 71 | $(BINDBG)/$(LIBNAME) |
72 | 72 | |
73 | 73 | @$(MCS) -reference:$(BINDBG)/$(LIBNAME) -debug -out:$@ $< |
74 | 74 | |
75 | 75 | $(BINDBG)/%.exe: \ |
76 | - testprograms/%.vb \ | |
76 | + src/testprograms/%.vb \ | |
77 | 77 | $(BINDBG)/$(LIBNAME) |
78 | 78 | |
79 | 79 | @$(VBNC) -reference:$(BINDBG)/$(LIBNAME) -debug -out:$@ $< |
80 | 80 | |
81 | -$(BINRLS)/%.exe: \ | |
82 | - testprograms/%.cs | |
83 | - | |
84 | - @$(MCS) -reference:$(BINRLS)/$(LIBNAME) -out:$@ $< | |
85 | - | |
86 | -%.tar.bz2: \ | |
87 | - %.tar | |
88 | - | |
89 | - @echo $< ... | |
90 | - @bzip2 --compress -9 --stdout $< > $@ | |
91 | - @chmod 0644 $@ | |
92 | - | |
93 | -%.tar.gz: \ | |
94 | - %.tar | |
95 | - | |
96 | - @echo $< ... | |
97 | - @gzip -9 --stdout $< > $@ | |
98 | - @chmod 0644 $@ | |
99 | - | |
100 | 81 | install-%: \ |
101 | 82 | src/%/Makefile \ |
102 | 83 | all |
103 | 84 | |
104 | 85 | @make -C `dirname $<` DESTDIR=$(DESTDIR) install |
105 | 86 | |
106 | -#---[ Targets ]-------------------------------------------------------------------------- | |
87 | +#---[ Release Targets ]------------------------------------------------------------------ | |
107 | 88 | |
108 | 89 | all: \ |
109 | - $(BINRLS)/$(GLUELIB) \ | |
110 | 90 | $(BINRLS)/$(LIBNAME) |
111 | 91 | |
112 | -install: \ | |
113 | - install-native \ | |
114 | - install-pw3270-sharp | |
115 | - | |
116 | - | |
117 | 92 | Release: \ |
118 | - $(BINRLS)/$(GLUELIB) \ | |
119 | 93 | $(BINRLS)/$(LIBNAME) |
120 | 94 | |
121 | -zip: \ | |
122 | - @ZIPNAME@-@PACKAGE_VERSION@.@host@.zip | |
123 | - | |
124 | -@ZIPNAME@-@PACKAGE_VERSION@.@host@.zip: \ | |
125 | - $(BINRLS)/$(GLUELIB) \ | |
126 | - $(BINRLS)/$(LIBNAME) \ | |
127 | - $(BINRLS)/sample.exe | |
128 | - | |
129 | - @zip -9 -j $@ \ | |
130 | - $(BINRLS)/$(GLUELIB) \ | |
131 | - $(BINRLS)/$(LIBNAME) \ | |
132 | - $(BINRLS)/*.xml \ | |
133 | - testprograms/sample.cs \ | |
134 | - testprograms/vbsample.vb \ | |
135 | - src/pw3270-sharp/pw3270-sharp.cs \ | |
136 | - $(BINRLS)/sample.exe | |
137 | - | |
138 | -rpm: \ | |
139 | - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 | |
140 | - | |
141 | -ifneq ($(RPMBUILD),no) | |
142 | - @$(MKDIR) $(BASEDIR)/rpm | |
143 | - @$(MKDIR) $(BASEDIR)/rpm/SPECS | |
144 | - @$(MKDIR) $(BASEDIR)/rpm/SOURCES | |
145 | - @$(MKDIR) $(BASEDIR)/rpm/SRPMS | |
146 | - @$(MKDIR) $(BASEDIR)/rpm/RPMS | |
147 | - @$(MKDIR) $(BASEDIR)/rpm/BUILD | |
148 | - @$(MKDIR) $(BASEDIR)/rpm/BUILDROOT | |
149 | - @umask 002 ; $(RPMBUILD) \ | |
150 | - --define="_topdir $(BASEDIR)/rpm" \ | |
151 | - --define="_packager $(USER)@$(HOSTNAME)" \ | |
152 | - --clean \ | |
153 | - -ta $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 | |
154 | -endif | |
155 | - | |
156 | -bz2: \ | |
157 | - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 | |
158 | - | |
159 | -$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar: \ | |
160 | - $(SRCDIR) | |
161 | - | |
162 | - @$(AMTAR) \ | |
163 | - --verbose \ | |
164 | - --format=ustar \ | |
165 | - --create \ | |
166 | - --exclude-vcs \ | |
167 | - --directory $(BASEDIR)/.src \ | |
168 | - --owner=root \ | |
169 | - --group=root \ | |
170 | - --file=$@ \ | |
171 | - $(PACKAGE_TARNAME)-@PACKAGE_VERSION@ | |
172 | - | |
173 | - | |
174 | -$(SRCDIR): \ | |
175 | - clean | |
176 | - | |
177 | - @$(MKDIR) $(SRCDIR) | |
178 | - @cp *.ac $(SRCDIR) | |
179 | - @cp *.in $(SRCDIR) | |
180 | - @cp *.cbp $(SRCDIR) | |
181 | - @cp *.sh $(SRCDIR) | |
182 | - @cp rpm/*.spec $(SRCDIR) | |
183 | - @cp README.md $(SRCDIR) | |
184 | - @cp LICENCA $(SRCDIR) | |
185 | - @cp LICENSE $(SRCDIR) | |
186 | - @cp AUTHORS $(SRCDIR) | |
187 | - | |
188 | - @$(MKDIR) $(SRCDIR)/testprograms | |
189 | - @cp testprograms/* $(SRCDIR)/testprograms | |
190 | - | |
191 | - @$(MKDIR) $(SRCDIR)/scripts | |
192 | - @cp scripts/* $(SRCDIR)/scripts | |
193 | - | |
194 | - @$(MKDIR) $(SRCDIR)/src/include | |
195 | - @cp src/include/*.in $(SRCDIR)/src/include | |
196 | - | |
197 | - @$(MKDIR) $(SRCDIR)/src/native | |
198 | - @cp src/native/*.in $(SRCDIR)/src/native | |
199 | - @cp src/native/*.cc $(SRCDIR)/src/native | |
200 | - @cp src/native/*.h $(SRCDIR)/src/native | |
201 | - | |
202 | - @$(MKDIR) $(SRCDIR)/src/pw3270-sharp | |
203 | - @cp src/pw3270-sharp/*.in $(SRCDIR)/src/pw3270-sharp | |
204 | - @cp src/pw3270-sharp/*.cs $(SRCDIR)/src/pw3270-sharp | |
205 | - | |
206 | 95 | |
207 | 96 | $(BINRLS)/$(GLUELIB): \ |
208 | - src/native/*.cc \ | |
209 | - src/native/*.h \ | |
210 | - src/include/*.h | |
97 | + src/native/* \ | |
98 | + src/native/core/* | |
211 | 99 | |
212 | 100 | @make -C src/native $@ |
213 | 101 | |
214 | 102 | $(BINRLS)/$(LIBNAME): \ |
215 | - src/pw3270-sharp/*.cs \ | |
216 | - src/include/*.h | |
103 | + $(BINRLS)/$(GLUELIB) \ | |
104 | + src/core/* | |
217 | 105 | |
218 | - @make -C src/pw3270-sharp $@ | |
106 | + @make -C src/core $@ | |
219 | 107 | |
220 | -Debug: \ | |
221 | - $(BINDBG)/$(GLUELIB) \ | |
222 | - $(BINDBG)/$(LIBNAME) \ | |
223 | - $(BINDBG)/sample.exe | |
108 | +install: \ | |
109 | + install-native \ | |
110 | + install-core | |
224 | 111 | |
112 | +#---[ Debug Targets ]-------------------------------------------------------------------- | |
225 | 113 | |
226 | -run: \ | |
227 | - $(BINDBG)/$(GLUELIB) \ | |
228 | - $(BINDBG)/$(LIBNAME) \ | |
229 | - $(BINDBG)/$(TESTPROGRAM).exe | |
114 | +Debug: \ | |
115 | + $(BINDBG)/$(LIBNAME) | |
230 | 116 | |
231 | - @$(MONO) $(BINDBG)/$(TESTPROGRAM).exe | |
232 | 117 | |
233 | 118 | $(BINDBG)/$(GLUELIB): \ |
234 | - src/native/*.cc \ | |
235 | - src/native/*.h \ | |
236 | - src/include/*.h | |
119 | + src/native/* \ | |
120 | + src/native/core/* | |
237 | 121 | |
238 | 122 | @make -C src/native $@ |
239 | 123 | |
240 | 124 | $(BINDBG)/$(LIBNAME): \ |
241 | - src/pw3270-sharp/*.cs \ | |
242 | - src/include/*.h | |
125 | + $(BINDBG)/$(GLUELIB) \ | |
126 | + src/core/* | |
127 | + | |
128 | + @make -C src/core $@ | |
129 | + | |
130 | +#---[ Test targets ]--------------------------------------------------------------------- | |
131 | + | |
132 | +ipc-test: \ | |
133 | + $(BINDBG)/ipc.exe | |
134 | + | |
243 | 135 | |
244 | - @make -C src/pw3270-sharp $@ | |
136 | +#---[ Clean Targets ]-------------------------------------------------------------------- | |
245 | 137 | |
246 | 138 | cleanDebug: \ |
247 | 139 | clean | ... | ... |
configure.ac
1 | +dnl | |
2 | +dnl Software pw3270, desenvolvido com base nos códigos fontes do C3270 e X3270 | |
3 | +dnl (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | +dnl aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | +dnl | |
6 | +dnl Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | +dnl | |
8 | +dnl Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | +dnl os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | +dnl Free Software Foundation. | |
11 | +dnl | |
12 | +dnl Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | +dnl GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | +dnl A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | +dnl obter mais detalhes. | |
16 | +dnl | |
17 | +dnl Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | +dnl programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | |
19 | +dnl Place, Suite 330, Boston, MA, 02111-1307, USA | |
20 | +dnl | |
21 | +dnl Contatos: | |
22 | +dnl | |
23 | +dnl perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
24 | +dnl erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
25 | +dnl | |
1 | 26 | |
2 | 27 | dnl Process this file with autoconf to produce a configure script. |
3 | 28 | |
4 | 29 | dnl The minimum version of autoconf required. |
5 | -AC_PREREQ(2.59) | |
30 | +AC_PREREQ(2.61) | |
6 | 31 | |
7 | 32 | dnl Initialise automake with the package name, version and |
8 | 33 | dnl bug-reporting address. |
9 | -AC_INIT([lib3270-mono-bindings], [5.1], [perry.werneck@gmail.com]) | |
34 | +AC_INIT([lib3270-mono-bindings], [5.2], [perry.werneck@gmail.com]) | |
10 | 35 | |
11 | 36 | dnl Place auxilliary scripts here. |
12 | 37 | AC_CONFIG_AUX_DIR([scripts]) |
... | ... | @@ -24,8 +49,8 @@ dnl Check for iconv |
24 | 49 | AM_ICONV |
25 | 50 | |
26 | 51 | dnl Checks for programs. |
27 | -AC_PROG_CXX | |
28 | 52 | AC_PROG_CC |
53 | +AC_PROG_CXX | |
29 | 54 | AC_PROG_SED |
30 | 55 | AC_PROG_LN_S |
31 | 56 | |
... | ... | @@ -34,173 +59,123 @@ AC_LANG([C++]) |
34 | 59 | dnl --------------------------------------------------------------------------- |
35 | 60 | dnl Initialize defaults |
36 | 61 | dnl --------------------------------------------------------------------------- |
37 | -DLLFLAGS="-shared -Wl,-soname,\$(@F)" | |
38 | -LDSTATIC="" | |
39 | -DBG_CFLAGS="-DDEBUG=1" | |
62 | + | |
63 | +DBG_CFLAGS="-g -fstack-check -DDEBUG=1" | |
40 | 64 | RLS_CFLAGS="-DNDEBUG=1" |
65 | +PLUGINS="" | |
66 | +APP_RESOURCES="" | |
67 | +APP_LDFLAGS="" | |
68 | +DLL_LDFLAGS="-shared -Wl,-soname,\$(@F)" | |
41 | 69 | |
42 | 70 | dnl --------------------------------------------------------------------------- |
43 | 71 | dnl Check for OS specifics |
44 | 72 | dnl --------------------------------------------------------------------------- |
45 | 73 | |
46 | 74 | case "$host" in |
47 | - *-mingw32) | |
48 | - RLS_LDFLAGS="-Wl,--strip-all" | |
49 | - DBG_LDFLAGS="" | |
50 | - APP_LDFLAGS="" | |
51 | - | |
52 | - DBG_DATADIR="" | |
53 | - RLS_DATADIR="" | |
75 | + *-mingw32|*-pc-msys) | |
76 | + app_cv_osname="windows" | |
54 | 77 | |
55 | - EXEEXT=".exe" | |
56 | - | |
57 | - DLLPREFIX="" | |
78 | + CFLAGS="$CFLAGS -pthread -D_WIN32_WINNT=0x0600" | |
79 | + LIBS="$LIBS -lws2_32 -lwtsapi32 -lcomdlg32" | |
58 | 80 | DLLEXT=".dll" |
59 | 81 | |
60 | - CFLAGS="$CFLAGS -Wall -Werror -D_WIN32_WINNT=0x0600" | |
61 | - LDFLAGS="-static-libgcc -static-libstdc++ $LDFLAGS" | |
62 | - LDSTATIC="-Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic" | |
63 | - LIBS="$LIBS -lws2_32 -lntdll -lwtsapi32" | |
82 | + app_win32_revision=$(date +%-y.%-m.%-d.%-H) | |
83 | + AC_SUBST(WIN32_VERSION,$app_win32_revision) | |
64 | 84 | |
65 | - LOGDIR=. | |
66 | - ;; | |
85 | + app_win32_file_version=$(date +%-y,%-m,%-d,%-H) | |
86 | + AC_SUBST(WIN32_FILE_VERSION,$app_win32_file_version) | |
67 | 87 | |
68 | - *) | |
69 | - RLS_LDFLAGS="" | |
70 | - DBG_LDFLAGS="" | |
71 | - APP_LDFLAGS="" | |
88 | + AC_CONFIG_FILES(src/native/windows/resources.rc) | |
72 | 89 | |
73 | - DBG_DATADIR="-DDATADIR=." | |
74 | - DBG_CFLAGS="-fstack-check $DBG_CFLAGS" | |
75 | - | |
76 | - RLS_DATADIR="-DDATADIR=\$(datarootdir)/\$(PACKAGE_NAME)" | |
77 | - | |
78 | - EXEEXT="" | |
79 | - | |
80 | - DLLPREFIX="lib" | |
81 | - DLLEXT=".so" | |
82 | - | |
83 | - CFLAGS="$CFLAGS -Wall -Werror" | |
90 | + if test "$host_cpu" = "x86_64"; then | |
91 | + app_cv_programfiles="PROGRAMFILES64" | |
92 | + app_cv_winarch="64" | |
93 | + else | |
94 | + app_cv_programfiles="PROGRAMFILES" | |
95 | + app_cv_winarch="32" | |
96 | + fi | |
84 | 97 | |
85 | - # LIBS="-Wl,--no-allow-shlib-undefined,--as-needed,--no-undefined -pthread $LIBS" | |
86 | - LIBS="-pthread $LIBS" | |
98 | + AC_SUBST(PROGRAMFILES,$app_cv_programfiles) | |
99 | + AC_SUBST(WINARCH,$app_cv_winarch) | |
100 | + ;; | |
87 | 101 | |
102 | + *) | |
103 | + CFLAGS="$CFLAGS -pthread" | |
104 | + LDFLAGS="$LDFLAGS -pthread" | |
105 | + app_cv_datadir="/usr/share" | |
106 | + app_cv_confdir="/etc" | |
107 | + app_cv_osname="linux" | |
88 | 108 | LOGDIR="/var/log" |
89 | - | |
109 | + DLLEXT=".so" | |
90 | 110 | |
91 | 111 | esac |
92 | 112 | |
113 | +AC_SUBST(DATADIR,$app_cv_datadir) | |
114 | +AC_SUBST(CONFDIR,$app_cv_confdir) | |
115 | +AC_SUBST(OSNAME,$app_cv_osname) | |
93 | 116 | AC_SUBST(LIBS) |
94 | - | |
95 | -AC_SUBST(DBG_DATADIR) | |
96 | -AC_SUBST(DBG_CFLAGS) | |
97 | - | |
98 | -AC_SUBST(RLS_DATADIR) | |
99 | -AC_SUBST(RLS_CFLAGS) | |
100 | - | |
101 | -AC_SUBST(DBG_LDFLAGS) | |
102 | -AC_SUBST(RLS_LDFLAGS) | |
103 | -AC_SUBST(APP_LDFLAGS) | |
104 | - | |
105 | -AC_SUBST(EXEEXT) | |
117 | +AC_SUBST(LOGDIR) | |
106 | 118 | AC_SUBST(DLLEXT) |
107 | 119 | AC_SUBST(DLLPREFIX) |
108 | - | |
109 | -AC_SUBST(LOGDIR) | |
110 | -AC_SUBST(LDSTATIC) | |
120 | +AC_SUBST(LDFLAGS) | |
121 | +AC_SUBST(DLL_LDFLAGS) | |
111 | 122 | |
112 | 123 | dnl --------------------------------------------------------------------------- |
113 | 124 | dnl Check for other programs |
114 | 125 | dnl --------------------------------------------------------------------------- |
115 | -AC_PATH_TOOL([STRIP], [strip]) | |
116 | -AC_PATH_TOOL([RPMBUILD], [rpmbuild], [no]) | |
117 | -AC_PATH_TOOL([MAKENSIS], [makensis], [no]) | |
118 | -AC_PATH_TOOL([VALGRIND], [valgrind], [no]) | |
126 | + | |
127 | +AC_PATH_TOOL([AR], [ar], [ar]) | |
119 | 128 | AC_PATH_TOOL([WINDRES], [windres], [no]) |
120 | -AC_PATH_TOOL([ZIP], [zip], [zip]) | |
121 | -AC_PATH_TOOL([MCS], [mcs], [mcs]) | |
122 | -AC_PATH_TOOL([VBNC], [vbnc2], [vbnc2]) | |
123 | -AC_PATH_TOOL([GACUTIL], [gacutil], [gacutil]) | |
124 | -AC_PATH_TOOL([SN], [sn], [sn]) | |
125 | -AC_PATH_PROG([MONO], [mono], [no]) | |
129 | +AC_PATH_TOOL([VALGRIND], [valgrind], [no]) | |
130 | +AC_PATH_TOOL([MCS], [mcs], [no]) | |
131 | +AC_PATH_TOOL([GACUTIL], [gacutil], [no]) | |
132 | +AC_PATH_TOOL([SN], [sn], [no]) | |
133 | +AC_PATH_TOOL([VBNC], [vbnc], [no]) | |
134 | + | |
135 | +PKG_CHECK_EXISTS | |
126 | 136 | |
127 | 137 | dnl --------------------------------------------------------------------------- |
128 | 138 | dnl Version info |
129 | 139 | dnl --------------------------------------------------------------------------- |
130 | 140 | |
131 | -AC_DEFINE(PACKAGE_RELEASE,APP_LEVEL) | |
132 | -AC_SUBST(PACKAGE_RELEASE, APP_LEVEL) | |
141 | +AC_SUBST(PACKAGE_DESCRIPTION,".NET Bindings for lib3270/pw3270") | |
142 | +app_cv_zipname=$PACKAGE | |
133 | 143 | |
134 | 144 | app_vrs_major=$(echo $VERSION | cut -d. -f1) |
135 | 145 | app_vrs_minor=$(echo $VERSION | cut -d. -f2) |
136 | 146 | |
137 | -AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major) | |
138 | -AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor) | |
139 | - | |
140 | 147 | AC_DEFINE_UNQUOTED(PACKAGE_MAJOR_VERSION, $app_vrs_major) |
141 | 148 | AC_DEFINE_UNQUOTED(PACKAGE_MINOR_VERSION, $app_vrs_minor) |
142 | 149 | |
143 | 150 | AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major) |
144 | 151 | AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor) |
145 | 152 | |
146 | -app_cv_description="C# Bindings for lib3270/pw3270" | |
147 | -app_cv_zipname=$PACKAGE | |
148 | - | |
149 | -AC_DEFINE_UNQUOTED(PACKAGE_DESCRIPTION,"$app_cv_description") | |
150 | -AC_SUBST(PACKAGE_DESCRIPTION,"$app_cv_description") | |
151 | - | |
152 | -dnl --------------------------------------------------------------------------- | |
153 | -dnl Check for integer types & library functions | |
154 | -dnl --------------------------------------------------------------------------- | |
153 | +AC_ARG_WITH([release], [AS_HELP_STRING([--with-release], [Set release])], [ app_cv_release="$withval" ],[ app_cv_release="`date +%-y`.`date +%-m`.`date +%-d`" ]) | |
155 | 154 | |
156 | -AC_CHECK_TYPES([pid_t, uint8_t, uint16_t, uint32_t, int32_t, uint64_t, int64_t]) | |
157 | - | |
158 | -dnl --------------------------------------------------------------------------- | |
159 | -dnl Check for libintl | |
160 | -dnl --------------------------------------------------------------------------- | |
161 | - | |
162 | -AC_PATH_TOOL([XGETTEXT], [xgettext], [no]) | |
163 | -AC_PATH_TOOL([MSGCAT], [msgcat], [no]) | |
164 | -AC_PATH_TOOL([MSGINIT], [msginit], [no]) | |
165 | -AC_PATH_TOOL([MSGMERGE], [msgmerge], [no]) | |
166 | -AC_PATH_TOOL([MSGFMT], [msgfmt], [no]) | |
167 | - | |
168 | -AC_CHECK_HEADER(libintl.h, [ | |
169 | - AC_DEFINE(HAVE_LIBINTL, 1) | |
170 | -]) | |
155 | +app_rls_major=$(echo $app_cv_release.0.0 | cut -d. -f1) | |
156 | +app_rls_minor=$(echo $app_cv_release.0.0 | cut -d. -f2) | |
171 | 157 | |
172 | -dnl -------------------------------------------------- | |
173 | -dnl test for clock_gettime | |
174 | -dnl -------------------------------------------------- | |
158 | +AC_DEFINE_UNQUOTED(PACKAGE_RELEASE, $app_cv_release) | |
159 | +AC_DEFINE_UNQUOTED(PACKAGE_MAJOR_RELEASE, $app_rls_major) | |
160 | +AC_DEFINE_UNQUOTED(PACKAGE_MINOR_RELEASE, $app_rls_minor) | |
175 | 161 | |
176 | -AC_CHECK_FUNCS(clock_gettime, [], [ | |
177 | - AC_CHECK_LIB(rt, clock_gettime, [ | |
178 | - AC_DEFINE(HAVE_CLOCK_GETTIME, 1) | |
179 | - LIBS="$LIBS -lrt" | |
180 | - ]) | |
181 | -]) | |
162 | +AC_SUBST(PACKAGE_RELEASE,$app_cv_release) | |
163 | +AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major) | |
164 | +AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor) | |
182 | 165 | |
183 | -dnl -------------------------------------------------- | |
184 | -dnl test for in_addr_t | |
185 | -dnl -------------------------------------------------- | |
186 | -AC_MSG_CHECKING(for in_addr_t in netinet/in.h) | |
187 | -AC_EGREP_HEADER(in_addr_t, netinet/in.h, | |
188 | - [ AC_DEFINE([HAVE_IN_ADDR_T], [1], [Define to 1 if in_addr_t is available.]) AC_MSG_RESULT(yes) ], | |
189 | - AC_MSG_RESULT(no)) | |
166 | +case "$host" in | |
167 | + *-mingw32|*-pc-msys) | |
168 | + AC_SUBST(NATIVE_SONAME,lib3270-mono.dll) | |
169 | + ;; | |
190 | 170 | |
191 | -dnl --------------------------------------------------------------------------- | |
192 | -dnl test for reentrant time routines | |
193 | -dnl --------------------------------------------------------------------------- | |
171 | + s390x-*) | |
172 | + AC_SUBST(NATIVE_SONAME,lib3270-mono.so) | |
173 | + ;; | |
194 | 174 | |
195 | -AC_MSG_CHECKING(for localtime_r in time.h) | |
196 | -AC_EGREP_HEADER(localtime_r, time.h, | |
197 | - [ AC_DEFINE([HAVE_LOCALTIME_R], [1], [Define to 1 if localtime_r is available.]) AC_MSG_RESULT(yes) ], | |
198 | - AC_MSG_RESULT(no)) | |
175 | + *) | |
176 | + AC_SUBST(NATIVE_SONAME,lib3270-mono.so.$app_vrs_major.$app_vrs_minor) | |
199 | 177 | |
200 | -AC_MSG_CHECKING(for gmtime_r in time.h) | |
201 | -AC_EGREP_HEADER(gmtime_r, time.h, | |
202 | - [ AC_DEFINE([HAVE_GMTIME_R], [1], [Define to 1 if gmtime_r is available.]) AC_MSG_RESULT(yes) ], | |
203 | - AC_MSG_RESULT(no)) | |
178 | +esac | |
204 | 179 | |
205 | 180 | dnl --------------------------------------------------------------------------- |
206 | 181 | dnl Check for C++ 2011 support |
... | ... | @@ -224,126 +199,82 @@ AS_VAR_POPDEF([CACHEVAR])dnl |
224 | 199 | AX_CHECK_COMPILE_FLAG([-std=gnu++11], [CFLAGS="$CFLAGS -std=gnu++11"]) |
225 | 200 | |
226 | 201 | dnl --------------------------------------------------------------------------- |
227 | -dnl Check for ELF symbol visibility support | |
202 | +dnl Check for libintl | |
228 | 203 | dnl --------------------------------------------------------------------------- |
229 | -m4_define([GLIB_CHECK_COMPILE_WARNINGS], | |
230 | -[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl | |
231 | -rm -f conftest.$ac_objext | |
232 | -glib_ac_compile_save="$ac_compile" | |
233 | -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext' | |
234 | -AS_IF([_AC_EVAL_STDERR($ac_compile) && | |
235 | - AC_TRY_COMMAND([(if test -s conftest.err; then false ; else true; fi)])], | |
236 | - [$2], | |
237 | - [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD | |
238 | -cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD | |
239 | -m4_ifvaln([$3],[$3])dnl]) | |
240 | -ac_compile="$glib_ac_compile_save" | |
241 | -rm -f conftest.$ac_objext conftest.err m4_ifval([$1], [conftest.$ac_ext])[]dnl | |
242 | -])# GLIB_CHECK_COMPILE_WARNINGS | |
243 | - | |
244 | -AC_MSG_CHECKING(for GNUC visibility attribute) | |
245 | -GLIB_CHECK_COMPILE_WARNINGS([ | |
246 | -void | |
247 | -__attribute__ ((visibility ("hidden"))) | |
248 | - f_hidden (void) | |
249 | -{ | |
250 | -} | |
251 | -void | |
252 | -__attribute__ ((visibility ("internal"))) | |
253 | - f_internal (void) | |
254 | -{ | |
255 | -} | |
256 | -void | |
257 | -__attribute__ ((visibility ("protected"))) | |
258 | - f_protected (void) | |
259 | -{ | |
260 | -} | |
261 | -void | |
262 | -__attribute__ ((visibility ("default"))) | |
263 | - f_default (void) | |
264 | -{ | |
265 | -} | |
266 | -int main (int argc, char **argv) | |
267 | -{ | |
268 | - f_hidden(); | |
269 | - f_internal(); | |
270 | - f_protected(); | |
271 | - f_default(); | |
272 | - return 0; | |
273 | -} | |
274 | -],g_have_gnuc_visibility=yes,g_have_gnuc_visibility=no) | |
275 | -AC_MSG_RESULT($g_have_gnuc_visibility) | |
276 | -if test x$g_have_gnuc_visibility = xyes; then | |
277 | - AC_DEFINE(HAVE_GNUC_VISIBILITY, 1, [supports GCC visibility attributes]) | |
278 | -fi | |
204 | + | |
205 | +INTL_LIBS="" | |
206 | + | |
207 | +AC_PATH_TOOL([XGETTEXT], [xgettext], [no]) | |
208 | +AC_PATH_TOOL([MSGCAT], [msgcat], [no]) | |
209 | +AC_PATH_TOOL([MSGINIT], [msginit], [no]) | |
210 | +AC_PATH_TOOL([MSGMERGE], [msgmerge], [no]) | |
211 | +AC_PATH_TOOL([MSGFMT], [msgfmt], [no]) | |
212 | + | |
213 | +AC_SUBST(INTL_LIBS) | |
279 | 214 | |
280 | 215 | dnl --------------------------------------------------------------------------- |
281 | -dnl Check for compiler visibility flag | |
216 | +dnl Check for IPC3270 | |
282 | 217 | dnl --------------------------------------------------------------------------- |
283 | -AC_MSG_CHECKING(whether $CC accepts -fvisibility=hidden) | |
284 | - | |
285 | -SAVED_CFLAGS="${CFLAGS}" | |
286 | -CFLAGS="-fvisibility=hidden" | |
287 | -GLIB_CHECK_COMPILE_WARNINGS([ | |
288 | -int main (int argc, char **argv) | |
289 | -{ | |
290 | - return 0; | |
291 | -} | |
292 | -],app_cv_fvisibility_ok=yes,app_cv_fvisibility_ok=no) | |
293 | -AC_MSG_RESULT($app_cv_fvisibility_ok) | |
294 | - | |
295 | -CFLAGS="${SAVED_CFLAGS}" | |
296 | - | |
297 | -dnl AC_CACHE_VAL(app_cv_fvisibility_ok, | |
298 | -dnl [ac_save_cc="$CC" | |
299 | -dnl CC="$CC -fvisibility=hidden" | |
300 | -dnl AC_TRY_RUN([int main() { return 0; }], | |
301 | -dnl app_cv_fvisibility_ok=yes, | |
302 | -dnl app_cv_fvisibility_ok=no, | |
303 | -dnl app_cv_fvisibility_ok=no) | |
304 | -dnl CC="$ac_save_cc"]) | |
305 | -dnl AC_MSG_RESULT($app_cv_fvisibility_ok) | |
306 | -if test $app_cv_fvisibility_ok = yes; then | |
307 | - CFLAGS="$CFLAGS -fvisibility=hidden" | |
218 | + | |
219 | +AC_ARG_WITH([static-ipc3270], | |
220 | + [AS_HELP_STRING([--with-static-ipc3270], [Uses static version of ipc3270])], | |
221 | +[ | |
222 | + app_cv_static_ipc3270=$withval | |
223 | +],[ | |
224 | + app_cv_static_ipc3270="auto" | |
225 | +]) | |
226 | + | |
227 | +if test "$app_cv_static_ipc3270" == "auto"; then | |
228 | + case "$host" in | |
229 | + *-mingw32|*-pc-msys) | |
230 | + app_cv_static_ipc3270="yes" | |
231 | + ;; | |
232 | + | |
233 | + *) | |
234 | + app_cv_static_ipc3270="no" | |
235 | + | |
236 | + esac | |
237 | + | |
308 | 238 | fi |
309 | 239 | |
310 | -dnl --------------------------------------------------------------------------- | |
311 | -dnl Check for D-Bus | |
312 | -dnl --------------------------------------------------------------------------- | |
240 | +if test "$app_cv_static_ipc3270" == "yes"; then | |
241 | + LDFLAGS="-static -static-libgcc -static-libstdc++ $LDFLAGS" | |
242 | + PKG_CHECK_MODULES( [IPC3270], [ipc3270-static], AC_DEFINE(USING_STATIC_IPC3270), AC_MSG_ERROR([IPC3270 not present.])) | |
243 | +else | |
244 | + PKG_CHECK_MODULES( [IPC3270], [ipc3270], AC_DEFINE(USING_SHARED_IPC3270), AC_MSG_ERROR([IPC3270 not present.])) | |
245 | +fi | |
313 | 246 | |
314 | -PKG_CHECK_MODULES( [DBUS], [dbus-1], AC_DEFINE(HAVE_DBUS), AC_MSG_NOTICE([ No DBUS support.]) ) | |
315 | -AC_SUBST(DBUS_LIBS) | |
316 | -AC_SUBST(DBUS_CFLAGS) | |
247 | +AC_SUBST(IPC3270_LIBS) | |
248 | +AC_SUBST(IPC3270_CFLAGS) | |
317 | 249 | |
318 | 250 | dnl --------------------------------------------------------------------------- |
319 | 251 | dnl Check for pic |
320 | 252 | dnl --------------------------------------------------------------------------- |
253 | + | |
321 | 254 | AC_ARG_ENABLE([pic], |
322 | 255 | [AS_HELP_STRING([--disable-pic], [disable support for PIC libraries (required to compile on 64bits)])], |
323 | 256 | [ |
324 | 257 | app_cv_pic="$enableval" |
325 | 258 | ],[ |
326 | 259 | |
327 | - case "$host" in | |
328 | - *-mingw32) | |
329 | - app_cv_pic="no" | |
260 | + case "$host_cpu" in | |
261 | + x86_64) | |
262 | + app_cv_pic="yes" | |
330 | 263 | ;; |
331 | 264 | |
332 | - s390x-*) | |
333 | - app_cv_pic="yes" | |
265 | + aarch64) | |
266 | + app_cv_pic="yes" | |
334 | 267 | ;; |
335 | 268 | |
336 | 269 | *) |
337 | - if test "$host_cpu" = "x86_64"; then | |
338 | - app_cv_pic="yes" | |
339 | - else | |
340 | - app_cv_pic="no" | |
341 | - fi | |
270 | + app_cv_pic="no" | |
342 | 271 | esac |
272 | + | |
343 | 273 | ]) |
344 | 274 | |
345 | 275 | if test "$app_cv_pic" == "yes"; then |
346 | 276 | CFLAGS="$CFLAGS -fPIC" |
277 | + CXXFLAGS="$CXXFLAGS -fPIC" | |
347 | 278 | fi |
348 | 279 | |
349 | 280 | dnl --------------------------------------------------------------------------- |
... | ... | @@ -357,27 +288,22 @@ if test "$app_cv_trace" == "yes"; then |
357 | 288 | fi |
358 | 289 | |
359 | 290 | dnl --------------------------------------------------------------------------- |
360 | -dnl Output config | |
361 | -dnl --------------------------------------------------------------------------- | |
362 | - | |
363 | -AC_SUBST(DLLFLAGS) | |
364 | -AC_SUBST(BASEDIR,$ac_pwd) | |
365 | - | |
366 | -AC_DEFINE_UNQUOTED(ZIPNAME, $app_cv_zipname) | |
367 | -AC_SUBST(ZIPNAME,$app_cv_zipname) | |
368 | - | |
369 | - | |
370 | -dnl --------------------------------------------------------------------------- | |
371 | 291 | dnl Configure which files to generate. |
372 | 292 | dnl --------------------------------------------------------------------------- |
373 | 293 | |
374 | 294 | AC_CONFIG_FILES(Makefile) |
375 | 295 | AC_CONFIG_FILES(src/native/Makefile) |
376 | -AC_CONFIG_FILES(src/pw3270-sharp/Makefile) | |
377 | -AC_CONFIG_FILES(src/pw3270-sharp/pw3270-sharp.pc) | |
296 | +AC_CONFIG_FILES(src/core/Makefile) | |
297 | +AC_CONFIG_FILES(src/core/tn3270-sharp.pc) | |
378 | 298 | |
379 | 299 | dnl --------------------------------------------------------------------------- |
380 | 300 | dnl Output the generated config.status script. |
381 | 301 | dnl --------------------------------------------------------------------------- |
302 | +AC_DEFINE_UNQUOTED(ZIPNAME, $app_cv_zipname) | |
303 | +AC_SUBST(ZIPNAME,$app_cv_zipname) | |
304 | + | |
305 | +AC_SUBST(BASEDIR,$ac_pwd) | |
306 | + | |
382 | 307 | AC_OUTPUT |
383 | 308 | |
309 | + | ... | ... |
pw3270-sharp.cbp
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <CodeBlocks_project_file> |
3 | 3 | <FileVersion major="1" minor="6" /> |
4 | 4 | <Project> |
5 | - <Option title="Mono Bindings for lib3270" /> | |
5 | + <Option title=".NET Bindings for lib3270/pw3270" /> | |
6 | 6 | <Option makefile_is_custom="1" /> |
7 | 7 | <Option pch_mode="2" /> |
8 | 8 | <Option compiler="gcc" /> | ... | ... |
... | ... | @@ -0,0 +1,108 @@ |
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., 59 Temple | |
19 | +# Place, Suite 330, Boston, MA, 02111-1307, USA | |
20 | +# | |
21 | +# Contatos: | |
22 | +# | |
23 | +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
24 | +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
25 | +# | |
26 | + | |
27 | +MODULE_NAME=tn3270-sharp | |
28 | + | |
29 | +SOURCES=$(MODULE_NAME).cs | |
30 | +LIBNAME=$(MODULE_NAME).dll | |
31 | + | |
32 | +#---[ Configuration values ]------------------------------------------------------------- | |
33 | + | |
34 | +PACKAGE_NAME=@PACKAGE_NAME@ | |
35 | +PACKAGE_VERSION=@PACKAGE_VERSION@ | |
36 | +PACKAGE_TARNAME=@PACKAGE_TARNAME@ | |
37 | + | |
38 | +prefix=@prefix@ | |
39 | +exec_prefix=@exec_prefix@ | |
40 | +bindir=@bindir@ | |
41 | +sbindir=@sbindir@ | |
42 | +libdir=@libdir@ | |
43 | + | |
44 | +BASEDIR=@BASEDIR@ | |
45 | +SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | |
46 | + | |
47 | +OBJDIR=$(BASEDIR)/.obj | |
48 | +OBJDBG=$(OBJDIR)/Debug | |
49 | +OBJRLS=$(OBJDIR)/Release | |
50 | + | |
51 | +BINDIR=$(BASEDIR)/.bin | |
52 | +BINDBG=$(BINDIR)/Debug | |
53 | +BINRLS=$(BINDIR)/Release | |
54 | + | |
55 | +INSTALL=@INSTALL@ | |
56 | +INSTALL_DATA=@INSTALL_DATA@ | |
57 | +INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
58 | + | |
59 | +LN_S=@LN_S@ | |
60 | + | |
61 | +MCS=@MCS@ | |
62 | +MKDIR=@MKDIR_P@ | |
63 | +GACUTIL=@GACUTIL@ | |
64 | +SN=@SN@ | |
65 | + | |
66 | +#---[ Targets ]-------------------------------------------------------------------------- | |
67 | + | |
68 | +all: \ | |
69 | + $(BINRLS)/$(LIBNAME) | |
70 | + | |
71 | +Release: \ | |
72 | + $(BINRLS)/$(LIBNAME) | |
73 | + | |
74 | +install: \ | |
75 | + $(BINRLS)/$(LIBNAME) | |
76 | + | |
77 | + @$(GACUTIL) -i $(BINRLS)/$(LIBNAME) -root $(DESTDIR)/usr/lib | |
78 | + | |
79 | + @$(MKDIR) $(DESTDIR)/usr/share/gapi-2.0/$(MODULE_NAME) | |
80 | + @$(INSTALL_DATA) $(BINRLS)/$(MODULE_NAME).xml $(DESTDIR)/usr/share/gapi-2.0/$(MODULE_NAME) | |
81 | + | |
82 | + @$(MKDIR) $(DESTDIR)/usr/lib/mono/$(MODULE_NAME)-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
83 | + @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)/usr/lib/mono/$(MODULE_NAME)-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
84 | + | |
85 | + @$(MKDIR) $(DESTDIR)/$(libdir)/pkgconfig | |
86 | + @$(INSTALL_DATA) $(MODULE_NAME).pc $(DESTDIR)/$(libdir)/pkgconfig | |
87 | + | |
88 | +Debug: \ | |
89 | + $(BINDBG)/$(LIBNAME) | |
90 | + | |
91 | +$(BINRLS)/$(MODULE_NAME).key: | |
92 | + | |
93 | + @$(SN) -k $@ | |
94 | + | |
95 | +$(BINDBG)/$(LIBNAME): \ | |
96 | + $(SOURCES) | |
97 | + | |
98 | + @$(MKDIR) `dirname $@` | |
99 | + @$(MCS) -debug -target:library -out:$@ $< | |
100 | + | |
101 | +$(BINRLS)/$(LIBNAME): \ | |
102 | + $(SOURCES) \ | |
103 | + $(BINRLS)/$(MODULE_NAME).key | |
104 | + | |
105 | + @$(MKDIR) `dirname $@` | |
106 | + @$(MCS) -doc:$(BINRLS)/$(MODULE_NAME).xml -keyfile:$(BINRLS)/$(MODULE_NAME).key -target:library -out:$@ $(SOURCES) | |
107 | + | |
108 | + | ... | ... |
... | ... | @@ -0,0 +1,618 @@ |
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 tn3270-sharp.cs 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://msdn.microsoft.com/en-us/library/5ast78ax.aspx | |
31 | + * | |
32 | + */ | |
33 | + | |
34 | +using System; | |
35 | +using System.Text; | |
36 | +using System.Runtime.InteropServices; | |
37 | + | |
38 | +namespace pw3270 { | |
39 | + | |
40 | + /// <summary> | |
41 | + /// Session with 3270 HOST. | |
42 | + /// </summary> | |
43 | + public class Session { | |
44 | + | |
45 | + /// <summary> | |
46 | + /// lib3270 session handle | |
47 | + /// </summary> | |
48 | + private IntPtr hSession; | |
49 | + | |
50 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
51 | + extern static IntPtr tn3270_create_session(string name); | |
52 | + | |
53 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
54 | + extern static int tn3270_destroy_session(IntPtr session); | |
55 | + | |
56 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
57 | + extern static int tn3270_get_version(IntPtr session, StringBuilder str, int strlen); | |
58 | + | |
59 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
60 | + extern static int tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); | |
61 | + | |
62 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
63 | + extern static int tn3270_connect(IntPtr Session, string host, int wait); | |
64 | + | |
65 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
66 | + extern static int tn3270_is_connected(IntPtr Session); | |
67 | + | |
68 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
69 | + extern static int tn3270_is_ready(IntPtr Session); | |
70 | + | |
71 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
72 | + extern static int tn3270_disconnect(IntPtr Session); | |
73 | + | |
74 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
75 | + extern static int tn3270_wait_for_ready(IntPtr Session, int seconds); | |
76 | + | |
77 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
78 | + extern static int tn3270_wait(IntPtr Session, int seconds); | |
79 | + | |
80 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
81 | + extern static int tn3270_get_cstate(IntPtr Session); | |
82 | + | |
83 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
84 | + extern static int tn3270_get_program_message(IntPtr Session); | |
85 | + | |
86 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
87 | + extern static int tn3270_get_secure(IntPtr Session); | |
88 | + | |
89 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
90 | + extern static int tn3270_get_contents(IntPtr Session, StringBuilder str, int strlen); | |
91 | + | |
92 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
93 | + extern static int tn3270_get_string(IntPtr Session, int addr, StringBuilder str, int strlen); | |
94 | + | |
95 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
96 | + extern static int tn3270_get_string_at(IntPtr Session, int row, int col, StringBuilder str, int strlen); | |
97 | + | |
98 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
99 | + extern static int tn3270_set_string_at(IntPtr Session, int row, int col, string str); | |
100 | + | |
101 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
102 | + extern static int tn3270_wait_for_string_at(IntPtr Session, int row, int col, string key, int timeout); | |
103 | + | |
104 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
105 | + extern static int tn3270_cmp_string_at(IntPtr Session, int row, int col, string str); | |
106 | + | |
107 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
108 | + extern static int tn3270_set_unlock_delay(IntPtr Session, int ms); | |
109 | + | |
110 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
111 | + extern static int tn3270_set_cursor_position(IntPtr Session, int row, int col); | |
112 | + | |
113 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
114 | + extern static int tn3270_set_cursor_addr(IntPtr Session, int addr); | |
115 | + | |
116 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
117 | + extern static int tn3270_get_cursor_addr(IntPtr Session); | |
118 | + | |
119 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
120 | + extern static int tn3270_enter(IntPtr Session); | |
121 | + | |
122 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
123 | + extern static int tn3270_pfkey(IntPtr Session, int key); | |
124 | + | |
125 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
126 | + extern static int tn3270_pakey(IntPtr Session, int key); | |
127 | + | |
128 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
129 | + extern static int tn3270_get_width(IntPtr Session); | |
130 | + | |
131 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
132 | + extern static int tn3270_get_height(IntPtr Session); | |
133 | + | |
134 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
135 | + extern static int tn3270_get_length(IntPtr Session); | |
136 | + | |
137 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
138 | + extern static int tn3270_set_charset(IntPtr Session, string str); | |
139 | + | |
140 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
141 | + extern static int tn3270_set_url(IntPtr Session, string str); | |
142 | + | |
143 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
144 | + extern static int tn3270_get_url(IntPtr Session, StringBuilder str, int strlen); | |
145 | + | |
146 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
147 | + extern static int tn3270_set_error_message(IntPtr Session, string str); | |
148 | + | |
149 | + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
150 | + extern static int tn3270_get_error_message(IntPtr Session, StringBuilder str, int strlen); | |
151 | + | |
152 | + /// <summary> | |
153 | + /// Create a new session with lib3270/pw3270 | |
154 | + /// </summary> | |
155 | + /// | |
156 | + /// <param name="name">Session name or empty string for a hidden session</param> | |
157 | + /// | |
158 | + public Session(string name) { | |
159 | + hSession = tn3270_create_session(name); | |
160 | + tn3270_set_charset(hSession,"UTF-8"); | |
161 | + } | |
162 | + | |
163 | + /// <summary> | |
164 | + /// Disconnect from host, destroy session. | |
165 | + /// </summary> | |
166 | + /// | |
167 | + ~Session() { | |
168 | + tn3270_destroy_session(hSession); | |
169 | + } | |
170 | + | |
171 | + /// <summary> | |
172 | + /// Get lib3270/pw3270 Version identifier | |
173 | + /// </summary> | |
174 | + /// | |
175 | + /// <returns> | |
176 | + /// The version of the active instance. | |
177 | + /// </returns> | |
178 | + /// | |
179 | + public string GetVersion() { | |
180 | + StringBuilder str = new StringBuilder(10); | |
181 | + tn3270_get_version(hSession, str, 10); | |
182 | + return str.ToString(); | |
183 | + } | |
184 | + | |
185 | + /// <summary> | |
186 | + /// Lib3270 version. | |
187 | + /// </summary> | |
188 | + /// | |
189 | + /// <returns> | |
190 | + /// Lib3270 version string | |
191 | + /// </returns> | |
192 | + /// | |
193 | + public string Version { | |
194 | + get { | |
195 | + return GetVersion(); | |
196 | + } | |
197 | + } | |
198 | + | |
199 | + /// <summary> | |
200 | + /// Get lib3270/pw3270 Revision number | |
201 | + /// </summary> | |
202 | + /// | |
203 | + /// <returns> | |
204 | + /// The revision of the active instance. | |
205 | + /// </returns> | |
206 | + /// | |
207 | + public string GetRevision() { | |
208 | + StringBuilder str = new StringBuilder(10); | |
209 | + tn3270_get_revision(hSession, str, 10); | |
210 | + return str.ToString(); | |
211 | + } | |
212 | + | |
213 | + public string Revision { | |
214 | + get { | |
215 | + return GetRevision(); | |
216 | + } | |
217 | + } | |
218 | + | |
219 | + /// <summary> | |
220 | + /// Connect to 3270 host. | |
221 | + /// </summary> | |
222 | + /// | |
223 | + /// <param name="host">URL of the target host (tn3270://hostname:port)</param> | |
224 | + /// <param name="wait">How many seconds should the call wait for the connection becomes ready</param> | |
225 | + /// | |
226 | + /// <returns> | |
227 | + /// </returns> | |
228 | + /// | |
229 | + public int Connect(string host, int wait) { | |
230 | + return tn3270_connect(hSession, host, wait); | |
231 | + } | |
232 | + | |
233 | + /// <summary> | |
234 | + /// Get connection state | |
235 | + /// </summary> | |
236 | + /// | |
237 | + /// <returns> | |
238 | + /// true if the session is connected to a remote host. | |
239 | + /// </returns> | |
240 | + /// | |
241 | + public bool IsConnected() { | |
242 | + return tn3270_is_connected(hSession) != 0; | |
243 | + } | |
244 | + | |
245 | + public bool Connected { | |
246 | + get { | |
247 | + return tn3270_is_connected(hSession) != 0; | |
248 | + } | |
249 | + } | |
250 | + | |
251 | + public bool IsReady() { | |
252 | + return tn3270_is_ready(hSession) != 0; | |
253 | + } | |
254 | + | |
255 | + public bool Ready { | |
256 | + get { | |
257 | + return tn3270_is_ready(hSession) != 0; | |
258 | + } | |
259 | + } | |
260 | + | |
261 | + /// <summary> | |
262 | + /// Disconnect from 3270 host. | |
263 | + /// </summary> | |
264 | + /// | |
265 | + public int Disconnect() { | |
266 | + return tn3270_disconnect(hSession); | |
267 | + } | |
268 | + | |
269 | + /// <summary> | |
270 | + /// Wait for network activity | |
271 | + /// </summary> | |
272 | + /// | |
273 | + /// <param name="seconds">Seconds to wait</param> | |
274 | + /// | |
275 | + /// <returns> | |
276 | + /// | |
277 | + /// </returns> | |
278 | + /// | |
279 | + public int WaitForReady(int seconds) { | |
280 | + return tn3270_wait_for_ready(hSession, seconds); | |
281 | + } | |
282 | + | |
283 | + /// <summary> | |
284 | + /// "Sleep" keeping the network activity. | |
285 | + /// </summary> | |
286 | + /// | |
287 | + /// <param name="seconds">Number of seconds to wait</param> | |
288 | + /// | |
289 | + /// <returns> | |
290 | + /// | |
291 | + /// </returns> | |
292 | + /// | |
293 | + public int Wait(int seconds) { | |
294 | + return tn3270_wait(hSession, seconds); | |
295 | + } | |
296 | + | |
297 | + /// <summary> | |
298 | + /// Get contents | |
299 | + /// </summary> | |
300 | + /// | |
301 | + /// <returns> | |
302 | + /// Contents from terminal screen. | |
303 | + /// </returns> | |
304 | + /// | |
305 | + public override string ToString() { | |
306 | + int strlen = (tn3270_get_width(hSession)+1) * (tn3270_get_height(hSession)+1); | |
307 | + StringBuilder str = new StringBuilder(strlen+1); | |
308 | + strlen = tn3270_get_contents(hSession, str, strlen); | |
309 | + return str.ToString(); | |
310 | + } | |
311 | + | |
312 | + | |
313 | + /// <summary> | |
314 | + /// Get contents at address | |
315 | + /// </summary> | |
316 | + /// | |
317 | + /// <param name="addr">Address of text in the screen buffer</param> | |
318 | + /// <param name="strlen">Number of characters to get</param> | |
319 | + /// | |
320 | + /// <returns> | |
321 | + /// Contents from terminal screen. | |
322 | + /// </returns> | |
323 | + /// | |
324 | + public string GetString(int addr, int strlen) { | |
325 | + StringBuilder str = new StringBuilder(strlen+1); | |
326 | + tn3270_get_string(hSession, addr, str, strlen); | |
327 | + return str.ToString(); | |
328 | + } | |
329 | + | |
330 | + /// <summary> | |
331 | + /// Get contents at position. | |
332 | + /// </summary> | |
333 | + /// | |
334 | + /// <param name="row">Start row</param> | |
335 | + /// <param name="col">Start col</param> | |
336 | + /// <param name="strlen">Number of characters to get</param> | |
337 | + /// | |
338 | + /// <returns> | |
339 | + /// Contents from terminal screen. | |
340 | + /// </returns> | |
341 | + /// | |
342 | + public string GetStringAt(int row, int col, int strlen) { | |
343 | + StringBuilder str = new StringBuilder(strlen+1); | |
344 | + tn3270_get_string_at(hSession, row, col, str, strlen); | |
345 | + return str.ToString(); | |
346 | + } | |
347 | + | |
348 | + /// <summary> | |
349 | + /// Set contents at position | |
350 | + /// </summary> | |
351 | + /// | |
352 | + /// <param name="row">Start row</param> | |
353 | + /// <param name="col">Start col</param> | |
354 | + /// <param name="str">Text to set</param> | |
355 | + /// | |
356 | + public void SetStringAt(int row, int col, string str) { | |
357 | + tn3270_set_string_at(hSession, row, col, str); | |
358 | + } | |
359 | + | |
360 | + /// <summary> | |
361 | + /// Wait for text at position. | |
362 | + /// </summary> | |
363 | + /// | |
364 | + /// <param name="row">Start row</param> | |
365 | + /// <param name="col">Start col</param> | |
366 | + /// <param name="str">Text to wait</param> | |
367 | + /// <param name="timeout">Seconds to wait</param> | |
368 | + /// | |
369 | + /// <returns> | |
370 | + /// | |
371 | + /// </returns> | |
372 | + /// | |
373 | + public int WaitForStringAt(int row, int col, string str, int timeout) { | |
374 | + return tn3270_wait_for_string_at(hSession, row, col, str, timeout); | |
375 | + } | |
376 | + | |
377 | + /// <summary> | |
378 | + /// Compare contents at position | |
379 | + /// </summary> | |
380 | + /// | |
381 | + /// <param name="row">Start row</param> | |
382 | + /// <param name="col">Start col</param> | |
383 | + /// <param name="str">Text to compare</param> | |
384 | + /// | |
385 | + /// <returns> | |
386 | + /// Result (0 = The strings are the same). | |
387 | + /// </returns> | |
388 | + /// | |
389 | + public int CmpStringAt(int row, int col, string str) { | |
390 | + return tn3270_cmp_string_at(hSession, row, col, str); | |
391 | + } | |
392 | + | |
393 | + /// <summary> | |
394 | + /// Set cursor position. | |
395 | + /// </summary> | |
396 | + /// | |
397 | + /// <param name="row">New cursor row</param> | |
398 | + /// <param name="col">New cursor column</param> | |
399 | + /// | |
400 | + public void SetCursorPosition(int row, int col) { | |
401 | + tn3270_set_cursor_position(hSession, row, col); | |
402 | + } | |
403 | + | |
404 | + /// <summary> | |
405 | + /// Set cursor position based on address. | |
406 | + /// </summary> | |
407 | + /// | |
408 | + /// <param name="addr">Address of the new cursor position</param> | |
409 | + /// | |
410 | + public void SetCursorPosition(int addr) { | |
411 | + tn3270_set_cursor_addr(hSession, addr); | |
412 | + } | |
413 | + | |
414 | + /// <summary> | |
415 | + /// Get cursor address | |
416 | + /// </summary> | |
417 | + /// | |
418 | + public int GetCursorPosition() { | |
419 | + return tn3270_get_cursor_addr(hSession); | |
420 | + } | |
421 | + | |
422 | + /// <summary> | |
423 | + /// Cursor address | |
424 | + /// </summary> | |
425 | + /// | |
426 | + public int CursorPosition { | |
427 | + set { | |
428 | + tn3270_set_cursor_addr(hSession, value); | |
429 | + } | |
430 | + get { | |
431 | + return tn3270_get_cursor_addr(hSession); | |
432 | + } | |
433 | + } | |
434 | + | |
435 | + /// <summary> | |
436 | + /// Set the "screen ready" delay | |
437 | + /// </summary> | |
438 | + /// | |
439 | + public int SetUnlockDelay(int ms) { | |
440 | + return tn3270_set_unlock_delay(hSession, ms); | |
441 | + } | |
442 | + | |
443 | + /// <summary> | |
444 | + /// Set the "screen ready" delay | |
445 | + /// </summary> | |
446 | + /// | |
447 | + public int UnlockDelay { | |
448 | + set { | |
449 | + tn3270_set_unlock_delay(hSession, value); | |
450 | + } | |
451 | + } | |
452 | + | |
453 | + | |
454 | + /// <summary> | |
455 | + /// Send "Enter" key | |
456 | + /// </summary> | |
457 | + /// | |
458 | + /// <returns> | |
459 | + /// | |
460 | + /// </returns> | |
461 | + /// | |
462 | + public int Enter() { | |
463 | + return tn3270_enter(hSession); | |
464 | + } | |
465 | + | |
466 | + /// <summary> | |
467 | + /// Send "PF" key | |
468 | + /// </summary> | |
469 | + /// | |
470 | + /// <param name="key">Key identifier 1=PF1, 2=PF2, ...</param> | |
471 | + /// | |
472 | + /// <returns> | |
473 | + /// | |
474 | + /// </returns> | |
475 | + /// | |
476 | + public int PfKey(int key) { | |
477 | + return tn3270_pfkey(hSession, key); | |
478 | + } | |
479 | + | |
480 | + /// <summary> | |
481 | + /// Send "PA" key | |
482 | + /// </summary> | |
483 | + /// | |
484 | + /// <param name="key">Key identifier 1=PA1, 2=PA2, ...</param> | |
485 | + /// | |
486 | + /// <returns> | |
487 | + /// | |
488 | + /// </returns> | |
489 | + /// | |
490 | + public int PaKey(int key) { | |
491 | + return tn3270_pakey(hSession, key); | |
492 | + } | |
493 | + | |
494 | + /// <summary> | |
495 | + /// Get screen width | |
496 | + /// </summary> | |
497 | + /// | |
498 | + /// <returns> | |
499 | + /// Screen width in characters (negative on error) | |
500 | + /// </returns> | |
501 | + /// | |
502 | + public int GetWidth() { | |
503 | + return tn3270_get_width(hSession); | |
504 | + } | |
505 | + | |
506 | + /// <summary> | |
507 | + /// Screen width in characters | |
508 | + /// </summary> | |
509 | + /// | |
510 | + /// <returns> | |
511 | + /// Screen width in characters (negative on error) | |
512 | + /// </returns> | |
513 | + /// | |
514 | + public int Width { | |
515 | + get { | |
516 | + return tn3270_get_width(hSession); | |
517 | + } | |
518 | + } | |
519 | + | |
520 | + /// <summary> | |
521 | + /// Get screen height | |
522 | + /// </summary> | |
523 | + /// | |
524 | + /// <returns> | |
525 | + /// Screen width in characters (negative on error) | |
526 | + /// </returns> | |
527 | + /// | |
528 | + public int GetHeight() { | |
529 | + return tn3270_get_height(hSession); | |
530 | + } | |
531 | + | |
532 | + /// <summary> | |
533 | + /// Screen height in characters | |
534 | + /// </summary> | |
535 | + /// | |
536 | + /// <returns> | |
537 | + /// Screen height in characters (negative on error) | |
538 | + /// </returns> | |
539 | + /// | |
540 | + public int Height { | |
541 | + get { | |
542 | + return tn3270_get_height(hSession); | |
543 | + } | |
544 | + } | |
545 | + | |
546 | + /// <summary> | |
547 | + /// Get length of terminal buffer (width * height) | |
548 | + /// </summary> | |
549 | + /// | |
550 | + /// <returns> | |
551 | + /// Terminal length in characters (negative on error) | |
552 | + /// </returns> | |
553 | + /// | |
554 | + public int GetLength() { | |
555 | + return tn3270_get_length(hSession); | |
556 | + } | |
557 | + | |
558 | + /// <summary> | |
559 | + /// Length of terminal buffer (width * height) | |
560 | + /// </summary> | |
561 | + /// | |
562 | + /// <returns> | |
563 | + /// Terminal length in characters (negative on error) | |
564 | + /// </returns> | |
565 | + /// | |
566 | + public int Length { | |
567 | + get { | |
568 | + return tn3270_get_length(hSession); | |
569 | + } | |
570 | + } | |
571 | + | |
572 | + public string CharSet { | |
573 | + set { | |
574 | + tn3270_set_charset(hSession,value); | |
575 | + } | |
576 | + } | |
577 | + | |
578 | + /// <summary> | |
579 | + /// 3270 host URL | |
580 | + /// </summary> | |
581 | + /// | |
582 | + /// <returns> | |
583 | + /// 3270 host URL | |
584 | + /// </returns> | |
585 | + /// | |
586 | + public string Url { | |
587 | + set { | |
588 | + tn3270_set_url(hSession,value); | |
589 | + } | |
590 | + get { | |
591 | + StringBuilder str = new StringBuilder(1025); | |
592 | + tn3270_get_url(hSession, str, 1024); | |
593 | + return str.ToString(); | |
594 | + } | |
595 | + } | |
596 | + | |
597 | + /// <summary> | |
598 | + /// Last lib3270 error message | |
599 | + /// </summary> | |
600 | + /// | |
601 | + /// <returns> | |
602 | + /// Last lib3270 error message | |
603 | + /// </returns> | |
604 | + /// | |
605 | + public string Error { | |
606 | + set { | |
607 | + tn3270_set_error_message(hSession,value); | |
608 | + } | |
609 | + get { | |
610 | + StringBuilder str = new StringBuilder(1025); | |
611 | + tn3270_get_error_message(hSession, str, 1024); | |
612 | + return str.ToString(); | |
613 | + } | |
614 | + } | |
615 | + | |
616 | + } | |
617 | + | |
618 | +} | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +prefix=${pcfiledir}/../.. | |
2 | +exec_prefix=${prefix} | |
3 | +libdir=${exec_prefix}/lib | |
4 | +gapidir=${prefix}/share/tn3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
5 | + | |
6 | + | |
7 | +Name: tn3270-sharp | |
8 | +Description: .NET Bindings for pw3270 | |
9 | +Version: @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
10 | +Cflags: -I:${gapidir}/tn3270-sharp.xml | |
11 | +Libs: -r:${libdir}/mono/tn3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@/tn3270-sharp.dll | ... | ... |
src/include/config.h.in
1 | +/* | |
2 | + * "Software G3270, 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 config.h 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) | |
27 | + * | |
28 | + */ | |
29 | + | |
1 | 30 | /** |
2 | 31 | * @file config.h |
3 | 32 | * |
... | ... | @@ -28,20 +57,7 @@ |
28 | 57 | * @brief Revisão svn quando o pacote foi configurado. |
29 | 58 | * |
30 | 59 | */ |
31 | - #undef PACKAGE_REVISION | |
32 | - | |
33 | - /** | |
34 | - * @brief Indica se o compilador atual possui suporte a "visibility" | |
35 | - * | |
36 | - * Quando disponível indica que o compilador atual permite tornar | |
37 | - * visíveis numa biblioteca apenas as funções declaradas para isso | |
38 | - * evitando que todos os símbolos fiquem visíveis. | |
39 | - * | |
40 | - * Isso permite um melhor controle sobre quais funções podem ser usados | |
41 | - * pelo programa principal. | |
42 | - * | |
43 | - */ | |
44 | - #undef HAVE_GNUC_VISIBILITY | |
60 | + #undef PACKAGE_RELEASE | |
45 | 61 | |
46 | 62 | /** |
47 | 63 | * @brief Ativa trace em um arquivo texto. |
... | ... | @@ -50,5 +66,4 @@ |
50 | 66 | #undef ENABLE_TRACE_TO_FILE |
51 | 67 | |
52 | 68 | |
53 | - | |
54 | 69 | #endif // CONFIG_H_INCLUDED | ... | ... |
... | ... | @@ -0,0 +1,165 @@ |
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 private.h 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 | + * http://www.mono-project.com/docs/advanced/pinvoke/ | |
31 | + * http://tirania.org/blog/archive/2011/Dec-19.html | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | +/** | |
36 | + * @file private.h | |
37 | + * | |
38 | + * @brief Internal definitions for the .NET Native module. | |
39 | + * | |
40 | + * @author Perry Werneck <perry.werneck@gmail.com> | |
41 | + * | |
42 | + */ | |
43 | + | |
44 | +#ifndef PRIVATE_H_INCLUDED | |
45 | + | |
46 | + #define PRIVATE_H_INCLUDED | |
47 | + | |
48 | + #include <config.h> | |
49 | + | |
50 | + #if defined(_WIN32) | |
51 | + | |
52 | + #include <windows.h> | |
53 | + | |
54 | + #define DLL_PRIVATE extern | |
55 | + #define DLL_PUBLIC extern __declspec (dllexport) __attribute__((cdecl)) | |
56 | + | |
57 | + #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) | |
58 | + | |
59 | + #define DLL_PRIVATE __hidden extern | |
60 | + #define DLL_PUBLIC extern | |
61 | + | |
62 | + #else | |
63 | + | |
64 | + #define DLL_PRIVATE __attribute__((visibility("hidden"))) extern | |
65 | + #define DLL_PUBLIC __attribute__((visibility("default"))) extern | |
66 | + | |
67 | + #endif | |
68 | + | |
69 | + #include <cstdio> | |
70 | + #include <string> | |
71 | + | |
72 | + #ifdef DEBUG | |
73 | + #define debug( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n" , __FILE__, (int) __LINE__, __VA_ARGS__ ); fflush(stderr); | |
74 | + #else | |
75 | + #define debug( fmt, ... ) /* */ | |
76 | + #endif // DEBUG | |
77 | + | |
78 | + /* | |
79 | + #ifdef ENABLE_TRACE_TO_FILE | |
80 | + DLL_PRIVATE void write_trace(const char *fmt, ...); | |
81 | + #define trace( ... ) write_trace(__VA_ARGS__) | |
82 | + #else | |
83 | + #define trace( ... ) | |
84 | + #endif // ENABLE_TRACE_TO_FILE | |
85 | + */ | |
86 | + | |
87 | + #include <lib3270/ipc.h> | |
88 | + #include <cerrno> | |
89 | + #include <cstring> | |
90 | + #include <functional> | |
91 | + | |
92 | + using std::string; | |
93 | + using std::exception; | |
94 | + | |
95 | + DLL_PRIVATE string tn3270_lasterror; | |
96 | + DLL_PRIVATE int call(TN3270::Host *ses, std::function<int(TN3270::Host &ses)> worker) noexcept; | |
97 | + DLL_PRIVATE int call(TN3270::Host *ses, char* str, int length, std::function<string(TN3270::Host &ses, int length)> worker); | |
98 | + | |
99 | + DLL_PRIVATE int tn3270_set_error(TN3270::Host *ses, const char *msg) noexcept; | |
100 | + DLL_PRIVATE int tn3270_set_error(TN3270::Host *ses, const std::exception &e) noexcept; | |
101 | + | |
102 | + extern "C" { | |
103 | + | |
104 | + DLL_PUBLIC TN3270::Host * tn3270_create_session(const char *name); | |
105 | + | |
106 | + DLL_PUBLIC int tn3270_destroy_session(TN3270::Host *ses); | |
107 | + | |
108 | + DLL_PUBLIC int tn3270_get_version(TN3270::Host *ses, char* str, int strlen); | |
109 | + DLL_PUBLIC int tn3270_get_revision(TN3270::Host *ses, char* str, int strlen); | |
110 | + | |
111 | + DLL_PUBLIC int tn3270_connect(TN3270::Host *ses, const char *host, time_t wait); | |
112 | + DLL_PUBLIC int tn3270_disconnect(TN3270::Host *ses); | |
113 | + DLL_PUBLIC int tn3270_is_connected(TN3270::Host *ses); | |
114 | + DLL_PUBLIC int tn3270_is_ready(TN3270::Host *ses); | |
115 | + | |
116 | + DLL_PUBLIC int tn3270_set_url(TN3270::Host *ses, const char *url); | |
117 | + DLL_PUBLIC int tn3270_get_url(TN3270::Host *ses, char* str, int strlen); | |
118 | + | |
119 | + DLL_PUBLIC int tn3270_get_luname(TN3270::Host *ses, char * str, int strlen); | |
120 | + | |
121 | + DLL_PUBLIC int tn3270_get_error_message(TN3270::Host *ses, char* str, int strlen); | |
122 | + | |
123 | + DLL_PUBLIC int tn3270_set_cursor_position(TN3270::Host *ses, int row, int col); | |
124 | + DLL_PUBLIC int tn3270_set_cursor_addr(TN3270::Host *ses, int addr); | |
125 | + DLL_PUBLIC int tn3270_get_cursor_addr(TN3270::Host *ses); | |
126 | + | |
127 | + DLL_PUBLIC int tn3270_action(TN3270::Host *ses, const char *name); | |
128 | + | |
129 | + DLL_PUBLIC int tn3270_erase(TN3270::Host *ses); | |
130 | + DLL_PUBLIC int tn3270_erase_eof(TN3270::Host *ses); | |
131 | + DLL_PUBLIC int tn3270_erase_eol(TN3270::Host *ses); | |
132 | + DLL_PUBLIC int tn3270_erase_input(TN3270::Host *ses); | |
133 | + | |
134 | + DLL_PUBLIC int tn3270_wait_for_ready(TN3270::Host *ses, int seconds); | |
135 | + DLL_PUBLIC int tn3270_wait(TN3270::Host *ses, int seconds); | |
136 | + | |
137 | + DLL_PUBLIC int tn3270_get_cstate(TN3270::Host *ses); | |
138 | + DLL_PUBLIC int tn3270_get_program_message(TN3270::Host *ses); | |
139 | + DLL_PUBLIC int tn3270_get_secure(TN3270::Host *ses); | |
140 | + | |
141 | + DLL_PUBLIC int tn3270_get_contents(TN3270::Host *ses, char* str, int strlen); | |
142 | + DLL_PUBLIC int tn3270_get_string(TN3270::Host *ses, int addr, char* str, int strlen); | |
143 | + DLL_PUBLIC int tn3270_get_string_at(TN3270::Host *ses, int row, int col, char* str, int strlen); | |
144 | + | |
145 | + DLL_PUBLIC int tn3270_set_string_at(TN3270::Host *ses, int row, int col, const char* str); | |
146 | + | |
147 | + DLL_PUBLIC int tn3270_wait_for_string_at(TN3270::Host *ses, int row, int col, const char *key, int timeout); | |
148 | + DLL_PUBLIC int tn3270_cmp_string_at(TN3270::Host *ses, int row, int col, const char* str); | |
149 | + | |
150 | + DLL_PUBLIC int tn3270_set_unlock_delay(TN3270::Host *ses, int ms); | |
151 | + | |
152 | + DLL_PUBLIC int tn3270_enter(TN3270::Host *ses); | |
153 | + DLL_PUBLIC int tn3270_pfkey(TN3270::Host *ses, int key); | |
154 | + DLL_PUBLIC int tn3270_pakey(TN3270::Host *ses, int key); | |
155 | + | |
156 | + DLL_PUBLIC int tn3270_get_width(TN3270::Host *ses); | |
157 | + DLL_PUBLIC int tn3270_get_height(TN3270::Host *ses); | |
158 | + DLL_PUBLIC int tn3270_get_length(TN3270::Host *ses); | |
159 | + | |
160 | + DLL_PUBLIC int tn3270_set_charset(TN3270::Host *ses, const char* str); | |
161 | + | |
162 | + } | |
163 | + | |
164 | + | |
165 | +#endif // PRIVATE_H_INCLUDED | ... | ... |
src/native/Makefile.in
... | ... | @@ -24,25 +24,54 @@ |
24 | 24 | # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) |
25 | 25 | # |
26 | 26 | |
27 | -SOURCES=actions.cc get.cc init.cc screen.cc set.cc network.cc | |
28 | -LIBNAME=lib3270-mono@DLLEXT@ | |
27 | +#---[ Library configuration ]------------------------------------------------------------ | |
29 | 28 | |
30 | -#---[ Configuration values ]------------------------------------------------------------- | |
29 | +LIBNAME=lib3270-mono | |
30 | +SONAME=@NATIVE_SONAME@ | |
31 | 31 | |
32 | -PACKAGE_NAME=@PACKAGE_NAME@ | |
33 | -PACKAGE_VERSION=@PACKAGE_VERSION@ | |
34 | -PACKAGE_TARNAME=@PACKAGE_TARNAME@ | |
32 | +SOURCES= \ | |
33 | + $(wildcard core/*.cc) \ | |
34 | + $(wildcard @OSNAME@/*.rc) \ | |
35 | + $(wildcard @OSNAME@/*.cc) | |
36 | + | |
37 | +TEST_SOURCES= \ | |
38 | + $(wildcard testprogram/*.cc) | |
39 | + | |
40 | +#---[ Tools ]---------------------------------------------------------------------------- | |
41 | + | |
42 | +CXX=@CXX@ | |
43 | +LD=@CXX@ | |
44 | +LN_S=@LN_S@ | |
45 | +MKDIR=@MKDIR_P@ | |
46 | +INSTALL=@INSTALL@ | |
47 | +INSTALL_DATA=@INSTALL_DATA@ | |
48 | +INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
49 | +XGETTEXT=@XGETTEXT@ | |
50 | +MSGCAT=@MSGCAT@ | |
51 | +WINDRES=@WINDRES@ | |
52 | +AR=@AR@ | |
53 | +VALGRIND=@VALGRIND@ | |
54 | +GENMARSHAL=@GENMARSHAL@ | |
55 | +CONVERT=@CONVERT@ | |
56 | +OPTIPNG=@OPTIPNG@ | |
57 | +ZIP=@ZIP@ | |
58 | + | |
59 | +#---[ Paths ]---------------------------------------------------------------------------- | |
35 | 60 | |
36 | 61 | prefix=@prefix@ |
37 | 62 | exec_prefix=@exec_prefix@ |
38 | 63 | bindir=@bindir@ |
39 | 64 | sbindir=@sbindir@ |
40 | 65 | libdir=@libdir@ |
66 | +includedir=@includedir@ | |
67 | +datarootdir=@datarootdir@ | |
68 | +localedir=@localedir@ | |
69 | +docdir=@docdir@ | |
70 | +sysconfdir=@sysconfdir@ | |
41 | 71 | |
42 | 72 | BASEDIR=@BASEDIR@ |
43 | -SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | |
44 | 73 | |
45 | -OBJDIR=$(BASEDIR)/.obj | |
74 | +OBJDIR=$(BASEDIR)/.obj/$(LIBNAME) | |
46 | 75 | OBJDBG=$(OBJDIR)/Debug |
47 | 76 | OBJRLS=$(OBJDIR)/Release |
48 | 77 | |
... | ... | @@ -50,116 +79,180 @@ BINDIR=$(BASEDIR)/.bin |
50 | 79 | BINDBG=$(BINDIR)/Debug |
51 | 80 | BINRLS=$(BINDIR)/Release |
52 | 81 | |
53 | -INSTALL=@INSTALL@ | |
54 | -INSTALL_DATA=@INSTALL_DATA@ | |
55 | -INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
82 | +#---[ Rules ]---------------------------------------------------------------------------- | |
56 | 83 | |
57 | -LN_S=@LN_S@ | |
84 | +DEPENDS= \ | |
85 | + Makefile \ | |
86 | + $(BASEDIR)/src/include/*.h | |
58 | 87 | |
59 | -VALGRIND=@VALGRIND@ | |
60 | -AMTAR=@AMTAR@ | |
61 | -SHELL=@SHELL@ | |
62 | -STRIP=@STRIP@ | |
63 | -MKDIR=@MKDIR_P@ | |
64 | 88 | |
65 | -CXX=@CXX@ | |
66 | -CC=@CC@ | |
67 | -LD=@CXX@ | |
89 | +CFLAGS= \ | |
90 | + @CFLAGS@ \ | |
91 | + -g \ | |
92 | + -I$(BASEDIR)/src/include \ | |
93 | + -DBUILD_DATE=`date +%Y%m%d` \ | |
94 | + @IPC3270_CFLAGS@ | |
68 | 95 | |
69 | -LIBS=-lpw3270cpp @LIBS@ @LIBICONV@ @DBUS_LIBS@ | |
70 | -CFLAGS=-I../include @CFLAGS@ @DBUS_CFLAGS@ | |
71 | -LDFLAGS=@LDFLAGS@ | |
72 | -LDSTATIC=@LDSTATIC@ | |
96 | +LDFLAGS=\ | |
97 | + @LDFLAGS@ | |
73 | 98 | |
74 | -#---[ Rules ]---------------------------------------------------------------------------- | |
99 | +LIBS= \ | |
100 | + @LIBS@ \ | |
101 | + @IPC3270_LIBS@ | |
75 | 102 | |
76 | -DEPENDS=*.h Makefile | |
103 | +#---[ Debug Rules ]---------------------------------------------------------------------- | |
77 | 104 | |
78 | 105 | $(OBJDBG)/%.o: \ |
79 | 106 | %.cc \ |
80 | 107 | $(DEPENDS) |
81 | 108 | |
82 | 109 | @echo $< ... |
83 | - @$(MKDIR) `dirname $@` | |
84 | - @$(CXX) $(CFLAGS) -fstack-check -DDEBUG=1 \ | |
85 | - -DBUILD_DATE=`date +"0x%Y%m%d"`\ | |
86 | - -g -o $@ -c $< | |
110 | + @$(MKDIR) $(dir $@) | |
111 | + | |
112 | + @$(CXX) \ | |
113 | + $(CFLAGS) \ | |
114 | + -Wall -Wextra -fstack-check \ | |
115 | + -DDEBUG=1 \ | |
116 | + -o $@ \ | |
117 | + -c $< | |
118 | + | |
119 | +$(OBJDBG)/%.o: \ | |
120 | + %.rc | |
121 | + | |
122 | + @echo $< ... | |
123 | + @$(MKDIR) $(dir $@) | |
124 | + @$(WINDRES) $< -O coff -o $@ | |
125 | + | |
126 | +#---[ Release Rules ]-------------------------------------------------------------------- | |
87 | 127 | |
88 | 128 | $(OBJRLS)/%.o: \ |
89 | 129 | %.cc \ |
90 | 130 | $(DEPENDS) |
91 | 131 | |
92 | 132 | @echo $< ... |
93 | - @$(MKDIR) `dirname $@` | |
94 | - @$(CXX) $(CFLAGS) -DNDEBUG=1 \ | |
95 | - -DBUILD_DATE=`date +"0x%Y%m%d"` \ | |
96 | - -o $@ -c $< | |
133 | + @$(MKDIR) $(dir $@) | |
134 | + @$(CXX) \ | |
135 | + $(CFLAGS) \ | |
136 | + -DNDEBUG=1 \ | |
137 | + -o $@ \ | |
138 | + -c $< | |
139 | + | |
140 | +$(OBJRLS)/%.o: \ | |
141 | + %.rc | |
142 | + | |
143 | + @echo $< ... | |
144 | + @$(MKDIR) $(dir $@) | |
145 | + @$(WINDRES) $< -O coff -o $@ | |
97 | 146 | |
98 | 147 | #---[ Release Targets ]------------------------------------------------------------------ |
99 | 148 | |
100 | 149 | all: \ |
101 | - $(BINRLS)/$(LIBNAME) | |
150 | + $(BINRLS)/$(SONAME) | |
102 | 151 | |
103 | 152 | Release: \ |
104 | - $(BINRLS)/$(LIBNAME) | |
153 | + $(BINRLS)/$(SONAME) | |
154 | + | |
155 | +$(BINRLS)/$(SONAME): \ | |
156 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) | |
157 | + | |
158 | + @$(MKDIR) $(dir $@) | |
159 | + @echo $< ... | |
160 | + @$(LD) \ | |
161 | + @DLL_LDFLAGS@ \ | |
162 | + -o $@ \ | |
163 | + $(LDFLAGS) \ | |
164 | + $^ \ | |
165 | + $(LIBS) | |
166 | + | |
167 | +#---[ Install Targets ]------------------------------------------------------------------ | |
105 | 168 | |
106 | 169 | install: \ |
107 | - $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
170 | + $(BINRLS)/$(SONAME) | |
108 | 171 | |
109 | - @$(MKDIR) $(DESTDIR)/$(libdir) | |
110 | - @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $(DESTDIR)/$(libdir) | |
172 | + # Install library | |
173 | + @$(MKDIR) $(DESTDIR)$(libdir) | |
111 | 174 | |
112 | - @rm -f $(DESTDIR)/$(libdir)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@ | |
113 | - @rm -f $(DESTDIR)/$(libdir)/$(LIBNAME) | |
175 | + @$(INSTALL_PROGRAM) \ | |
176 | + $(BINRLS)/$(SONAME) \ | |
177 | + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
114 | 178 | |
115 | - @$(LN_S) $(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $(DESTDIR)/$(libdir)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@ | |
116 | - @$(LN_S) $(LIBNAME).@PACKAGE_MAJOR_VERSION@ $(DESTDIR)/$(libdir)/$(LIBNAME) | |
179 | + @$(LN_S) \ | |
180 | + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ | |
181 | + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
117 | 182 | |
118 | -$(BINRLS)/$(LIBNAME): \ | |
119 | - $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@ | |
183 | + @$(LN_S) \ | |
184 | + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \ | |
185 | + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@ | |
120 | 186 | |
121 | - @rm -f $@ | |
122 | - @$(LN_S) $(LIBNAME).@PACKAGE_MAJOR_VERSION@ $@ | |
123 | 187 | |
188 | +#---[ Debug Targets ]-------------------------------------------------------------------- | |
124 | 189 | |
125 | -$(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@: \ | |
126 | - $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
190 | +Debug: \ | |
191 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
127 | 192 | |
128 | - @rm -f $@ | |
129 | - @$(LN_S) $(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $@ | |
193 | +$(BINDBG)/$(LIBNAME)@EXEEXT@: \ | |
194 | + $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
195 | + $(BINDBG)/$(SONAME) | |
130 | 196 | |
197 | + @$(MKDIR) $(dir $@) | |
198 | + @echo $< ... | |
199 | + @$(LD) \ | |
200 | + -o $@ \ | |
201 | + $^ \ | |
202 | + -L$(BINDBG) \ | |
203 | + -Wl,-rpath,$(BINDBG) \ | |
204 | + $(LDFLAGS) \ | |
205 | + $(LIBS) | |
206 | + | |
207 | +run: \ | |
208 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
131 | 209 | |
132 | -$(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ | |
133 | - $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) | |
210 | +ifeq ($(VALGRIND),no) | |
134 | 211 | |
135 | - @echo $(basename $@) ... | |
136 | - @$(MKDIR) `dirname $@` | |
137 | - @$(LD) -shared -Wl,-soname,$(LIBNAME) $(LDFLAGS) -o $@ $^ $(LIBS) $(LDSTATIC) | |
212 | + @LD_LIBRARY_PATH=$(BINDBG) \ | |
213 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
138 | 214 | |
139 | -#---[ Debug Targets ]-------------------------------------------------------------------- | |
215 | +else | |
216 | + @touch valgrind.suppression | |
140 | 217 | |
141 | -Debug: \ | |
142 | - $(BINDBG)/$(LIBNAME) | |
218 | + @LD_LIBRARY_PATH=$(BINDBG) \ | |
219 | + $(VALGRIND) --leak-check=full --track-origins=yes --gen-suppressions=all --suppressions=valgrind.suppression \ | |
220 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
221 | +endif | |
143 | 222 | |
144 | -$(BINDBG)/$(LIBNAME): \ | |
145 | - $(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@ | |
146 | 223 | |
147 | - @rm -f $@ | |
148 | - @$(LN_S) $(LIBNAME).@PACKAGE_MAJOR_VERSION@ $@ | |
224 | +$(BINDBG)/$(SONAME): \ | |
225 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) | |
149 | 226 | |
227 | + @$(MKDIR) $(dir $@) | |
228 | + @echo $< ... | |
229 | + @$(LD) \ | |
230 | + -shared -Wl,-soname,$(@F) \ | |
231 | + -o $@ \ | |
232 | + -L$(BINDBG) \ | |
233 | + $(LDFLAGS) \ | |
234 | + $^ \ | |
235 | + $(LIBS) | |
150 | 236 | |
151 | -$(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@: \ | |
152 | - $(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
153 | 237 | |
154 | - @rm -f $@ | |
155 | - @$(LN_S) $(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $@ | |
238 | +#---[ Clean Targets ]-------------------------------------------------------------------- | |
156 | 239 | |
240 | +clean: \ | |
241 | + cleanDebug \ | |
242 | + cleanRelease | |
157 | 243 | |
158 | -$(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ | |
159 | - $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) | |
244 | +cleanDebug: | |
245 | + | |
246 | + @rm -fr $(OBJDBG) | |
247 | + @rm -fr $(BINDBG) | |
248 | + | |
249 | +cleanRelease: | |
250 | + | |
251 | + @rm -fr $(OBJRLS) | |
252 | + @rm -fr $(BINRLS) | |
160 | 253 | |
161 | - @echo $(basename $@) ... | |
162 | - @$(MKDIR) `dirname $@` | |
163 | - @$(LD) -shared -Wl,-soname,$(LIBNAME) $(LDFLAGS) -o $@ $^ $(LIBS) $(LDSTATIC) | |
254 | +clean: \ | |
255 | + cleanDebug \ | |
256 | + cleanRelease | |
164 | 257 | |
165 | 258 | ... | ... |
src/native/actions.cc
... | ... | @@ -1,105 +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 | - */ | |
29 | - | |
30 | - #include "private.h" | |
31 | - | |
32 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | - | |
34 | -int tn3270_enter(h3270::session *ses) { | |
35 | - try { | |
36 | - return ses->enter(); | |
37 | - } catch(std::exception &e) { | |
38 | - tn3270_lasterror = e.what(); | |
39 | - return -1; | |
40 | - } | |
41 | -} | |
42 | - | |
43 | -int tn3270_pfkey(h3270::session *ses, int key) { | |
44 | - try { | |
45 | - return ses->pfkey(key); | |
46 | - } catch(std::exception &e) { | |
47 | - tn3270_lasterror = e.what(); | |
48 | - return -1; | |
49 | - } | |
50 | -} | |
51 | - | |
52 | -int tn3270_pakey(h3270::session *ses, int key) { | |
53 | - try { | |
54 | - return ses->pakey(key); | |
55 | - } catch(std::exception &e) { | |
56 | - tn3270_lasterror = e.what(); | |
57 | - return -1; | |
58 | - } | |
59 | -} | |
60 | - | |
61 | -int tn3270_action(h3270::session *ses, const char *name) { | |
62 | - try { | |
63 | - return ses->action(name); | |
64 | - } catch(std::exception &e) { | |
65 | - tn3270_lasterror = e.what(); | |
66 | - return -1; | |
67 | - } | |
68 | -} | |
69 | - | |
70 | -int tn3270_erase(h3270::session *ses) { | |
71 | - try { | |
72 | - return ses->erase(); | |
73 | - } catch(std::exception &e) { | |
74 | - tn3270_lasterror = e.what(); | |
75 | - return -1; | |
76 | - } | |
77 | -} | |
78 | - | |
79 | -int tn3270_erase_eof(h3270::session *ses) { | |
80 | - try { | |
81 | - return ses->erase_eof(); | |
82 | - } catch(std::exception &e) { | |
83 | - tn3270_lasterror = e.what(); | |
84 | - return -1; | |
85 | - } | |
86 | -} | |
87 | - | |
88 | -int tn3270_erase_eol(h3270::session *ses) { | |
89 | - try { | |
90 | - return ses->erase_eol(); | |
91 | - } catch(std::exception &e) { | |
92 | - tn3270_lasterror = e.what(); | |
93 | - return -1; | |
94 | - } | |
95 | -} | |
96 | - | |
97 | -int tn3270_erase_input(h3270::session *ses) { | |
98 | - try { | |
99 | - return ses->erase_input(); | |
100 | - } catch(std::exception &e) { | |
101 | - tn3270_lasterror = e.what(); | |
102 | - return -1; | |
103 | - } | |
104 | -} | |
105 | - |
... | ... | @@ -0,0 +1,124 @@ |
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 | + */ | |
29 | + | |
30 | + /** | |
31 | + * @file actions.cc | |
32 | + * | |
33 | + * @brief Actions wrapper. | |
34 | + * | |
35 | + * @author Perry Werneck <perry.werneck@gmail.com> | |
36 | + * | |
37 | + */ | |
38 | + | |
39 | + #include <native.h> | |
40 | + | |
41 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
42 | + | |
43 | + static int action(TN3270::Host *ses, std::function<void(TN3270::Host &ses)> worker) noexcept { | |
44 | + | |
45 | + try { | |
46 | + | |
47 | + if(!ses->isConnected()) { | |
48 | + tn3270_lasterror = "Not connected"; | |
49 | + } | |
50 | + | |
51 | + worker(*ses); | |
52 | + return 0; | |
53 | + | |
54 | + } catch(const std::system_error &e) { | |
55 | + | |
56 | + tn3270_set_error(ses,e); | |
57 | + | |
58 | + } catch(const std::exception &e) { | |
59 | + | |
60 | + tn3270_set_error(ses,e); | |
61 | + | |
62 | + } catch(...) { | |
63 | + | |
64 | + tn3270_set_error(ses,"Unexpected error"); | |
65 | + | |
66 | + } | |
67 | + | |
68 | + return -1; | |
69 | + | |
70 | + } | |
71 | + | |
72 | + | |
73 | +static int action(TN3270::Host *ses, TN3270::Action id) noexcept { | |
74 | + | |
75 | + return action(ses, [id](TN3270::Host &ses) { | |
76 | + ses.push(id); | |
77 | + }); | |
78 | + | |
79 | +} | |
80 | + | |
81 | +int tn3270_pfkey(TN3270::Host *ses, int key) { | |
82 | + | |
83 | + return action(ses, [key](TN3270::Host &ses) { | |
84 | + ses.pfkey(key); | |
85 | + }); | |
86 | + | |
87 | +} | |
88 | + | |
89 | +int tn3270_pakey(TN3270::Host *ses, int key) { | |
90 | + | |
91 | + return action(ses, [key](TN3270::Host &ses) { | |
92 | + ses.pakey(key); | |
93 | + }); | |
94 | + | |
95 | +} | |
96 | + | |
97 | +int tn3270_action(TN3270::Host *ses, const char *name) { | |
98 | + | |
99 | + return action(ses, [name](TN3270::Host &ses) { | |
100 | + ses.action(name); | |
101 | + }); | |
102 | + | |
103 | +} | |
104 | + | |
105 | +int tn3270_enter(TN3270::Host *ses) { | |
106 | + return action(ses,TN3270::ENTER); | |
107 | +} | |
108 | + | |
109 | +int tn3270_erase(TN3270::Host *ses) { | |
110 | + return action(ses,TN3270::ERASE); | |
111 | +} | |
112 | + | |
113 | +int tn3270_erase_eof(TN3270::Host *ses) { | |
114 | + return action(ses,TN3270::ERASE_EOF); | |
115 | +} | |
116 | + | |
117 | +int tn3270_erase_eol(TN3270::Host *ses) { | |
118 | + return action(ses,TN3270::ERASE_EOL); | |
119 | +} | |
120 | + | |
121 | +int tn3270_erase_input(TN3270::Host *ses) { | |
122 | + return action(ses,TN3270::ERASE_INPUT); | |
123 | +} | |
124 | + | ... | ... |
... | ... | @@ -0,0 +1,166 @@ |
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 | + */ | |
29 | + | |
30 | + #include <native.h> | |
31 | + | |
32 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | + | |
34 | + /** | |
35 | + * @brief Obtém a versão da biblioteca. | |
36 | + * | |
37 | + */ | |
38 | +DLL_PUBLIC int tn3270_get_version(TN3270::Host *ses, char * str, int strlen) { | |
39 | + | |
40 | + if(!(str && strlen)) | |
41 | + return -1; | |
42 | + | |
43 | + return call(ses,[str,strlen](TN3270::Host &ses){ | |
44 | + | |
45 | + strncpy(str,ses.getVersion().c_str(),strlen); | |
46 | + return 0; | |
47 | + | |
48 | + }); | |
49 | + | |
50 | + } | |
51 | + | |
52 | + /** | |
53 | + * @brief Obtém a revisão da biblioteca. | |
54 | + * | |
55 | + */ | |
56 | + int tn3270_get_revision(TN3270::Host *ses, char* str, int strlen) { | |
57 | + | |
58 | + if(!(str && strlen)) | |
59 | + return -1; | |
60 | + | |
61 | + return call(ses,[str,strlen](TN3270::Host &ses){ | |
62 | + | |
63 | + strncpy(str,ses.getRevision().c_str(),strlen); | |
64 | + return 0; | |
65 | + | |
66 | + }); | |
67 | + | |
68 | + } | |
69 | + | |
70 | + int tn3270_get_cstate(TN3270::Host *ses) { | |
71 | + | |
72 | + return call(ses,[](TN3270::Host &ses){ | |
73 | + | |
74 | + return (int) ses.getConnectionState(); | |
75 | + | |
76 | + }); | |
77 | + | |
78 | + } | |
79 | + | |
80 | + int tn3270_get_program_message(TN3270::Host *ses) { | |
81 | + | |
82 | + return call(ses,[](TN3270::Host &ses){ | |
83 | + | |
84 | + return (int) ses.getProgramMessage(); | |
85 | + | |
86 | + }); | |
87 | + | |
88 | + } | |
89 | + | |
90 | + int tn3270_get_secure(TN3270::Host *ses) { | |
91 | + | |
92 | + | |
93 | + return call(ses,[](TN3270::Host &ses){ | |
94 | + | |
95 | + return (int) ses.getSSLState(); | |
96 | + | |
97 | + }); | |
98 | + | |
99 | + } | |
100 | + | |
101 | + int tn3270_get_width(TN3270::Host *ses) { | |
102 | + | |
103 | + return call(ses,[](TN3270::Host &ses){ | |
104 | + | |
105 | + return (int) ses.getScreenWidth(); | |
106 | + | |
107 | + }); | |
108 | + | |
109 | + } | |
110 | + | |
111 | + int tn3270_get_height(TN3270::Host *ses) { | |
112 | + | |
113 | + return call(ses,[](TN3270::Host &ses){ | |
114 | + | |
115 | + return (int) ses.getScreenHeight(); | |
116 | + | |
117 | + }); | |
118 | + | |
119 | + } | |
120 | + | |
121 | + int tn3270_get_length(TN3270::Host *ses) { | |
122 | + | |
123 | + return call(ses,[](TN3270::Host &ses){ | |
124 | + | |
125 | + return (int) ses.getScreenLength(); | |
126 | + | |
127 | + }); | |
128 | + | |
129 | + } | |
130 | + | |
131 | + int tn3270_get_cursor_addr(TN3270::Host *ses) { | |
132 | + | |
133 | + return call(ses,[](TN3270::Host &ses){ | |
134 | + | |
135 | + return (int) ses.getCursorAddress(); | |
136 | + | |
137 | + }); | |
138 | + | |
139 | + } | |
140 | + | |
141 | + int tn3270_get_url(TN3270::Host *ses, char* str, int length) { | |
142 | + | |
143 | + return call(ses, str, length, [](TN3270::Host &ses, int length) { | |
144 | + | |
145 | + return ses.getHostURL(); | |
146 | + | |
147 | + }); | |
148 | + | |
149 | + } | |
150 | + | |
151 | + DLL_PUBLIC int tn3270_get_luname(TN3270::Host *ses, char * str, int length) { | |
152 | + | |
153 | + return call(ses, str, length, [](TN3270::Host &ses, int length) { | |
154 | + | |
155 | + return ses.getLUName(); | |
156 | + | |
157 | + }); | |
158 | + | |
159 | + } | |
160 | + | |
161 | + int tn3270_get_error_message(TN3270::Host *ses, char* str, int length) { | |
162 | + | |
163 | + strncpy(str,tn3270_lasterror.c_str(),length); | |
164 | + return 0; | |
165 | + | |
166 | + } | ... | ... |
... | ... | @@ -0,0 +1,86 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como init.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 | + */ | |
29 | + | |
30 | + #include <native.h> | |
31 | + | |
32 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | + | |
34 | + std::string tn3270_lasterror = ""; | |
35 | + | |
36 | +/** | |
37 | + * @brief Cria uma sessão tn3270. | |
38 | + * | |
39 | + * @param name Nome da janela ou "" para criar uma sessão oculta. | |
40 | + * | |
41 | + * @return Identificador da sessão criada. | |
42 | + * | |
43 | + */ | |
44 | + TN3270::Host * tn3270_create_session(const char *name) { | |
45 | + | |
46 | + try { | |
47 | + | |
48 | + return new TN3270::Host(name); | |
49 | + | |
50 | + } catch(const exception &e) { | |
51 | + | |
52 | + tn3270_lasterror = e.what(); | |
53 | + | |
54 | + } catch(...) { | |
55 | + | |
56 | + tn3270_lasterror = "Unexpected error"; | |
57 | + | |
58 | + } | |
59 | + | |
60 | + return nullptr; | |
61 | + } | |
62 | + | |
63 | + /** | |
64 | + * @brief Destrói uma sessão. | |
65 | + * | |
66 | + */ | |
67 | + int tn3270_destroy_session(TN3270::Host *ses) { | |
68 | + | |
69 | + try { | |
70 | + | |
71 | + delete ses; | |
72 | + return 0; | |
73 | + | |
74 | + } catch(const exception &e) { | |
75 | + | |
76 | + tn3270_lasterror = e.what(); | |
77 | + | |
78 | + } catch(...) { | |
79 | + | |
80 | + tn3270_lasterror = "Unexpected error"; | |
81 | + | |
82 | + } | |
83 | + | |
84 | + return -1; | |
85 | + } | |
86 | + | ... | ... |
... | ... | @@ -0,0 +1,102 @@ |
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 network.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 | + */ | |
29 | + | |
30 | + #include <native.h> | |
31 | + | |
32 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | + | |
34 | +int tn3270_connect(TN3270::Host *ses, const char *url, time_t timeout) { | |
35 | + | |
36 | + return call(ses,[url,timeout](TN3270::Host &ses){ | |
37 | + | |
38 | + ses.connect(url); | |
39 | + | |
40 | + if(timeout) { | |
41 | + ses.waitForReady(timeout); | |
42 | + } | |
43 | + | |
44 | + return 0; | |
45 | + | |
46 | + }); | |
47 | + | |
48 | +} | |
49 | + | |
50 | +int tn3270_disconnect(TN3270::Host *ses) { | |
51 | + | |
52 | + return call(ses,[](TN3270::Host &ses){ | |
53 | + | |
54 | + ses.disconnect(); | |
55 | + return 0; | |
56 | + | |
57 | + }); | |
58 | + | |
59 | +} | |
60 | + | |
61 | +int tn3270_is_connected(TN3270::Host *ses) { | |
62 | + | |
63 | + return call(ses,[](TN3270::Host &ses){ | |
64 | + | |
65 | + return (ses.isConnected() ? 1 : 0); | |
66 | + | |
67 | + }); | |
68 | + | |
69 | +} | |
70 | + | |
71 | +int tn3270_is_ready(TN3270::Host *ses) { | |
72 | + | |
73 | + return call(ses,[](TN3270::Host &ses){ | |
74 | + | |
75 | + return (int) (ses.isReady() ? 1 : 0); | |
76 | + | |
77 | + }); | |
78 | + | |
79 | +} | |
80 | + | |
81 | +int tn3270_wait_for_ready(TN3270::Host *ses, int seconds) { | |
82 | + | |
83 | + return call(ses,[seconds](TN3270::Host &ses){ | |
84 | + | |
85 | + ses.waitForReady(seconds); | |
86 | + return 0; | |
87 | + | |
88 | + }); | |
89 | + | |
90 | +} | |
91 | + | |
92 | +int tn3270_wait(TN3270::Host *ses, int seconds) { | |
93 | + | |
94 | + return call(ses,[seconds](TN3270::Host &ses){ | |
95 | + | |
96 | + ses.wait(seconds); | |
97 | + return 0; | |
98 | + | |
99 | + }); | |
100 | + | |
101 | +} | |
102 | + | ... | ... |
... | ... | @@ -0,0 +1,96 @@ |
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 screen.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 | + */ | |
29 | + | |
30 | + #include <native.h> | |
31 | + | |
32 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | + | |
34 | +int tn3270_get_contents(TN3270::Host *ses, char* str, int length) { | |
35 | + | |
36 | + return call(ses,str,length,[](TN3270::Host &ses, int length){ | |
37 | + | |
38 | + return ses.toString(0,length); | |
39 | + | |
40 | + }); | |
41 | + | |
42 | +} | |
43 | + | |
44 | +int tn3270_get_string(TN3270::Host *ses, int addr, char* str, int length) { | |
45 | + | |
46 | + return call(ses,str,length,[addr](TN3270::Host &ses, int length){ | |
47 | + | |
48 | + return ses.toString(addr,length); | |
49 | + | |
50 | + }); | |
51 | + | |
52 | + | |
53 | +} | |
54 | + | |
55 | +int tn3270_get_string_at(TN3270::Host *ses, int row, int col, char* str, int length) { | |
56 | + | |
57 | + return call(ses,str,length,[row,col](TN3270::Host &ses, int length){ | |
58 | + | |
59 | + return ses.toString((unsigned int) row, (unsigned int) col, length); | |
60 | + | |
61 | + }); | |
62 | + | |
63 | +} | |
64 | + | |
65 | +int tn3270_set_string_at(TN3270::Host *ses, int row, int col, const char* str) { | |
66 | + | |
67 | + return call(ses,[row,col,str](TN3270::Host &ses){ | |
68 | + | |
69 | + ses.push((unsigned int) row, (unsigned int) col, str); | |
70 | + return 0; | |
71 | + | |
72 | + }); | |
73 | + | |
74 | + | |
75 | +} | |
76 | + | |
77 | +int tn3270_wait_for_string_at(TN3270::Host *ses, int row, int col, const char *key, int timeout) { | |
78 | + | |
79 | + return call(ses,[row,col,key,timeout](TN3270::Host &ses){ | |
80 | + | |
81 | + ses.wait((unsigned int) row, (unsigned int) col, key, timeout); | |
82 | + return 0; | |
83 | + | |
84 | + }); | |
85 | + | |
86 | +} | |
87 | + | |
88 | +int tn3270_cmp_string_at(TN3270::Host *ses, int row, int col, const char* str) { | |
89 | + | |
90 | + return call(ses,[row,col,str](TN3270::Host &ses){ | |
91 | + | |
92 | + return ses.compare((unsigned int) row, (unsigned int) col, str); | |
93 | + | |
94 | + }); | |
95 | + | |
96 | +} | ... | ... |
... | ... | @@ -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 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 | + */ | |
29 | + | |
30 | + #include <native.h> | |
31 | + | |
32 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | + | |
34 | +int tn3270_set_unlock_delay(TN3270::Host *ses, int ms) { | |
35 | + | |
36 | + return call(ses,[ms](TN3270::Host &ses) { | |
37 | + | |
38 | + ses.setUnlockDelay(ms); | |
39 | + return 0; | |
40 | + | |
41 | + }); | |
42 | + | |
43 | +} | |
44 | + | |
45 | +int tn3270_set_cursor_position(TN3270::Host *ses, int row, int col) { | |
46 | + | |
47 | + return call(ses,[row,col](TN3270::Host &ses) { | |
48 | + | |
49 | + ses.setCursor((unsigned short) row, (unsigned short) row); | |
50 | + return 0; | |
51 | + | |
52 | + }); | |
53 | + | |
54 | + | |
55 | +} | |
56 | + | |
57 | +int tn3270_set_cursor_addr(TN3270::Host *ses, int addr) { | |
58 | + | |
59 | + return call(ses,[addr](TN3270::Host &ses) { | |
60 | + | |
61 | + ses.setCursor(addr); | |
62 | + return 0; | |
63 | + | |
64 | + }); | |
65 | + | |
66 | +} | |
67 | + | |
68 | +int tn3270_set_charset(TN3270::Host *ses, const char* str) { | |
69 | + | |
70 | + return call(ses,[str](TN3270::Host &ses) { | |
71 | + | |
72 | + ses.setCharSet(str); | |
73 | + return 0; | |
74 | + | |
75 | + }); | |
76 | + | |
77 | +} | |
78 | + | |
79 | +int tn3270_set_url(TN3270::Host *ses, const char *url) { | |
80 | + | |
81 | + return call(ses,[url](TN3270::Host &ses) { | |
82 | + | |
83 | + ses.setHostURL(url); | |
84 | + return 0; | |
85 | + | |
86 | + }); | |
87 | +} | |
88 | + | ... | ... |
... | ... | @@ -0,0 +1,121 @@ |
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 | + */ | |
29 | + | |
30 | + /** | |
31 | + * @file | |
32 | + * | |
33 | + * @brief | |
34 | + * | |
35 | + * @author | |
36 | + * | |
37 | + */ | |
38 | + | |
39 | + #include <native.h> | |
40 | + | |
41 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
42 | + | |
43 | +int call(TN3270::Host *ses, std::function<int(TN3270::Host &ses)> worker) noexcept { | |
44 | + | |
45 | + if(!ses) { | |
46 | + | |
47 | + return tn3270_set_error(ses, "Invalid session handle"); | |
48 | + | |
49 | + } | |
50 | + | |
51 | + try { | |
52 | + | |
53 | + return worker(*ses); | |
54 | + | |
55 | + } catch(const exception &e) { | |
56 | + | |
57 | + tn3270_set_error(ses, e); | |
58 | + | |
59 | + } catch(...) { | |
60 | + | |
61 | + tn3270_set_error(ses, "Unexpected error"); | |
62 | + | |
63 | + } | |
64 | + | |
65 | + return -1; | |
66 | + | |
67 | +} | |
68 | + | |
69 | +int call(TN3270::Host *ses, char* str, int length, std::function<string(TN3270::Host &ses, int length)> worker) { | |
70 | + | |
71 | + if(!(str && length)) { | |
72 | + | |
73 | + return tn3270_set_error(ses, "The output buffer is invalid"); | |
74 | + | |
75 | + } | |
76 | + | |
77 | + if(!ses) { | |
78 | + | |
79 | + return tn3270_set_error(ses, "Invalid session handle"); | |
80 | + | |
81 | + } | |
82 | + | |
83 | + try { | |
84 | + | |
85 | + std::string contents = worker(*ses, length); | |
86 | + | |
87 | + memset(str,0,length); | |
88 | + strncpy(str,contents.c_str(),length); | |
89 | + if(contents.size() < ((size_t) length)) { | |
90 | + str[contents.size()] = 0; | |
91 | + return contents.size(); | |
92 | + } | |
93 | + | |
94 | + return length; | |
95 | + | |
96 | + } catch(const exception &e) { | |
97 | + | |
98 | + tn3270_set_error(ses, e); | |
99 | + | |
100 | + } catch(...) { | |
101 | + | |
102 | + tn3270_set_error(ses, "Unexpected error"); | |
103 | + | |
104 | + } | |
105 | + | |
106 | + return -1; | |
107 | + | |
108 | + | |
109 | +} | |
110 | + | |
111 | +int tn3270_set_error(TN3270::Host *ses, const char *str) noexcept { | |
112 | + tn3270_lasterror = str; | |
113 | + return -1; | |
114 | +} | |
115 | + | |
116 | +int tn3270_set_error(TN3270::Host *ses, const std::exception &e) noexcept { | |
117 | + tn3270_lasterror = e.what(); | |
118 | + return -1; | |
119 | +} | |
120 | + | |
121 | + | ... | ... |
src/native/get.cc
... | ... | @@ -1,203 +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 | - */ | |
29 | - | |
30 | - #include "private.h" | |
31 | - | |
32 | - | |
33 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
34 | - | |
35 | - /** | |
36 | - * @brief Obtém a versão da biblioteca. | |
37 | - * | |
38 | - */ | |
39 | - int tn3270_get_version(h3270::session *ses, char* str, int strlen) { | |
40 | - | |
41 | - if(!ses) { | |
42 | - return -1; | |
43 | - } | |
44 | - | |
45 | - try { | |
46 | - strncpy(str,ses->get_version().c_str(),strlen); | |
47 | - } catch(std::exception &e) { | |
48 | - tn3270_lasterror = e.what(); | |
49 | - return -1; | |
50 | - } | |
51 | - return 0; | |
52 | - } | |
53 | - | |
54 | - /** | |
55 | - * @brief Obtém a revisão da biblioteca. | |
56 | - * | |
57 | - */ | |
58 | - int tn3270_get_revision(h3270::session *ses, char* str, int strlen) { | |
59 | - | |
60 | - if(!ses) { | |
61 | - return -1; | |
62 | - } | |
63 | - | |
64 | - try { | |
65 | - strncpy(str,ses->get_revision().c_str(),strlen); | |
66 | - } catch(std::exception &e) { | |
67 | - tn3270_lasterror = e.what(); | |
68 | - return -1; | |
69 | - } | |
70 | - return 0; | |
71 | - } | |
72 | - | |
73 | - int tn3270_get_cstate(h3270::session *ses) { | |
74 | - | |
75 | - if(!ses) { | |
76 | - return -1; | |
77 | - } | |
78 | - | |
79 | - trace_to_file("%s: %d",__FUNCTION__,(int) ses->get_cstate()); | |
80 | - | |
81 | - try { | |
82 | - return (int) ses->get_cstate(); | |
83 | - } catch(std::exception &e) { | |
84 | - tn3270_lasterror = e.what(); | |
85 | - } | |
86 | - return -1; | |
87 | - | |
88 | - } | |
89 | - | |
90 | - int tn3270_get_program_message(h3270::session *ses) { | |
91 | - | |
92 | - if(!ses) { | |
93 | - return -1; | |
94 | - } | |
95 | - | |
96 | - try { | |
97 | - return (int) ses->get_program_message(); | |
98 | - } catch(std::exception &e) { | |
99 | - tn3270_lasterror = e.what(); | |
100 | - } | |
101 | - return -1; | |
102 | - | |
103 | - } | |
104 | - | |
105 | - int tn3270_get_secure(h3270::session *ses) { | |
106 | - | |
107 | - if(!ses) { | |
108 | - return -1; | |
109 | - } | |
110 | - | |
111 | - try { | |
112 | - return (int) ses->get_secure(); | |
113 | - } catch(std::exception &e) { | |
114 | - tn3270_lasterror = e.what(); | |
115 | - } | |
116 | - return -1; | |
117 | - | |
118 | - } | |
119 | - | |
120 | - int tn3270_get_width(h3270::session *ses) { | |
121 | - | |
122 | - if(!ses) { | |
123 | - return 0; | |
124 | - } | |
125 | - | |
126 | - try { | |
127 | - return (int) ses->get_width(); | |
128 | - } catch(std::exception &e) { | |
129 | - tn3270_lasterror = e.what(); | |
130 | - } | |
131 | - return -1; | |
132 | - | |
133 | - } | |
134 | - | |
135 | - int tn3270_get_height(h3270::session *ses) { | |
136 | - | |
137 | - if(!ses) { | |
138 | - return 0; | |
139 | - } | |
140 | - | |
141 | - try { | |
142 | - return (int) ses->get_height(); | |
143 | - } catch(std::exception &e) { | |
144 | - tn3270_lasterror = e.what(); | |
145 | - } | |
146 | - return -1; | |
147 | - | |
148 | - } | |
149 | - | |
150 | - int tn3270_get_length(h3270::session *ses) { | |
151 | - | |
152 | - if(!ses) { | |
153 | - return 0; | |
154 | - } | |
155 | - | |
156 | - try { | |
157 | - return (int) ses->get_length(); | |
158 | - } catch(std::exception &e) { | |
159 | - tn3270_lasterror = e.what(); | |
160 | - } | |
161 | - return -1; | |
162 | - | |
163 | - } | |
164 | - | |
165 | - int tn3270_get_cursor_addr(h3270::session *ses) { | |
166 | - | |
167 | - if(ses) { | |
168 | - | |
169 | - try { | |
170 | - return (int) ses->get_cursor_addr(); | |
171 | - } catch(std::exception &e) { | |
172 | - tn3270_lasterror = e.what(); | |
173 | - } | |
174 | - | |
175 | - } | |
176 | - return -1; | |
177 | - | |
178 | - } | |
179 | - | |
180 | - int tn3270_get_url(h3270::session *ses, char* str, int strlen) { | |
181 | - | |
182 | - if(ses) { | |
183 | - | |
184 | - try { | |
185 | - | |
186 | - strncpy(str,ses->get_url().c_str(),strlen); | |
187 | - return 0; | |
188 | - | |
189 | - } catch(std::exception &e) { | |
190 | - tn3270_lasterror = e.what(); | |
191 | - } | |
192 | - | |
193 | - } | |
194 | - return -1; | |
195 | - | |
196 | - } | |
197 | - | |
198 | - int tn3270_get_error_message(h3270::session *ses, char* str, int strlen) { | |
199 | - | |
200 | - strncpy(str,tn3270_lasterror.c_str(),strlen); | |
201 | - return 0; | |
202 | - | |
203 | - } |
src/native/init.cc
... | ... | @@ -1,93 +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 init.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 | - */ | |
29 | - | |
30 | - #include "private.h" | |
31 | - | |
32 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | - | |
34 | - std::string tn3270_lasterror = ""; | |
35 | - | |
36 | -/** | |
37 | - * @brief Cria uma sessão tn3270. | |
38 | - * | |
39 | - * @param name Nome da janela ou "" para criar uma sessão oculta. | |
40 | - * | |
41 | - * @return Identificador da sessão criada. | |
42 | - * | |
43 | - */ | |
44 | - h3270::session * tn3270_create_session(const char *name) { | |
45 | - | |
46 | - trace_to_file("%s(%s)",__FUNCTION__,name ? name : ""); | |
47 | - | |
48 | - try { | |
49 | - return h3270::session::create(name); | |
50 | - } catch(std::exception &e) { | |
51 | - tn3270_lasterror = e.what(); | |
52 | - trace_to_file("%s(%s)",__FUNCTION__,e.what()); | |
53 | - } | |
54 | - return nullptr; | |
55 | - } | |
56 | - | |
57 | - /** | |
58 | - * @brief Destrói uma sessão. | |
59 | - * | |
60 | - */ | |
61 | - int tn3270_destroy_session(h3270::session *ses) { | |
62 | - | |
63 | - trace_to_file("%s",__FUNCTION__); | |
64 | - | |
65 | - try { | |
66 | - delete ses; | |
67 | - } catch(std::exception &e) { | |
68 | - tn3270_lasterror = e.what(); | |
69 | - return -1; | |
70 | - } | |
71 | - return 0; | |
72 | - } | |
73 | - | |
74 | -#ifdef ENABLE_TRACE_TO_FILE | |
75 | - void write_trace(const char *fmt, ...) { | |
76 | - | |
77 | - FILE *trace = fopen(PACKAGE_NAME ".trace","a"); | |
78 | - if(trace) { | |
79 | - va_list arg_ptr; | |
80 | - va_start(arg_ptr, fmt); | |
81 | - vfprintf(trace, fmt, arg_ptr); | |
82 | - fprintf(trace,"\n"); | |
83 | - va_end(arg_ptr); | |
84 | - fclose(trace); | |
85 | - } | |
86 | -#ifdef DEBUG | |
87 | - else { | |
88 | - perror(PACKAGE_NAME ".trace"); | |
89 | - } | |
90 | -#endif // DEBUG | |
91 | - | |
92 | - } | |
93 | -#endif // ENABLE_TRACE_TO_FILE |
... | ... | @@ -0,0 +1,52 @@ |
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="LIB3270 Native .NET Bindings" /> | |
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/LIB3270 Native " prefix_auto="1" extension_auto="1" /> | |
12 | + <Option object_output=".obj/Debug/" /> | |
13 | + <Option type="1" /> | |
14 | + <Option compiler="gcc" /> | |
15 | + <Compiler> | |
16 | + <Add option="-g" /> | |
17 | + </Compiler> | |
18 | + </Target> | |
19 | + <Target title="Release"> | |
20 | + <Option output=".bin/Release/LIB3270 Native " prefix_auto="1" extension_auto="1" /> | |
21 | + <Option object_output=".obj/Release/" /> | |
22 | + <Option type="1" /> | |
23 | + <Option compiler="gcc" /> | |
24 | + <Compiler> | |
25 | + <Add option="-O2" /> | |
26 | + </Compiler> | |
27 | + <Linker> | |
28 | + <Add option="-s" /> | |
29 | + </Linker> | |
30 | + </Target> | |
31 | + </Build> | |
32 | + <Compiler> | |
33 | + <Add option="-Wall" /> | |
34 | + </Compiler> | |
35 | + <Unit filename="../include/native.h" /> | |
36 | + <Unit filename="core/actions.cc" /> | |
37 | + <Unit filename="core/get.cc" /> | |
38 | + <Unit filename="core/init.cc" /> | |
39 | + <Unit filename="core/network.cc" /> | |
40 | + <Unit filename="core/screen.cc" /> | |
41 | + <Unit filename="core/set.cc" /> | |
42 | + <Unit filename="core/tools.cc" /> | |
43 | + <Unit filename="testprogram/testprogram.cc" /> | |
44 | + <Unit filename="windows/resources.rc.in" /> | |
45 | + <Extensions> | |
46 | + <code_completion /> | |
47 | + <envvars /> | |
48 | + <debugger /> | |
49 | + <lib_finder disable_auto="1" /> | |
50 | + </Extensions> | |
51 | + </Project> | |
52 | +</CodeBlocks_project_file> | ... | ... |
src/native/network.cc
... | ... | @@ -1,123 +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 network.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 | - */ | |
29 | - | |
30 | - #include "private.h" | |
31 | - | |
32 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | - | |
34 | -int tn3270_connect(h3270::session *ses, const char *host, time_t wait) { | |
35 | - | |
36 | - if(ses) { | |
37 | - | |
38 | - try { | |
39 | - debug("%s(%s,%d)",__FUNCTION__,host,(int) wait); | |
40 | - return ses->connect(host,wait); | |
41 | - } catch(std::exception &e) { | |
42 | - tn3270_lasterror = e.what(); | |
43 | - } | |
44 | - | |
45 | - } | |
46 | - | |
47 | - return -1; | |
48 | -} | |
49 | - | |
50 | -int tn3270_disconnect(h3270::session *ses) { | |
51 | - | |
52 | - if(ses) { | |
53 | - | |
54 | - try { | |
55 | - return ses->disconnect(); | |
56 | - } catch(std::exception &e) { | |
57 | - tn3270_lasterror = e.what(); | |
58 | - } | |
59 | - | |
60 | - } | |
61 | - | |
62 | - return -1; | |
63 | -} | |
64 | - | |
65 | -int tn3270_is_connected(h3270::session *ses) { | |
66 | - | |
67 | - if(ses) { | |
68 | - | |
69 | - try { | |
70 | - return (int) ses->is_connected(); | |
71 | - } catch(std::exception &e) { | |
72 | - tn3270_lasterror = e.what(); | |
73 | - } | |
74 | - | |
75 | - } | |
76 | - | |
77 | - return -1; | |
78 | -} | |
79 | - | |
80 | -int tn3270_is_ready(h3270::session *ses) { | |
81 | - | |
82 | - if(ses) { | |
83 | - | |
84 | - try { | |
85 | - return (int) ses->is_ready(); | |
86 | - } catch(std::exception &e) { | |
87 | - tn3270_lasterror = e.what(); | |
88 | - } | |
89 | - | |
90 | - } | |
91 | - | |
92 | - return -1; | |
93 | -} | |
94 | - | |
95 | -int tn3270_wait_for_ready(h3270::session *ses, int seconds) { | |
96 | - | |
97 | - if(ses) { | |
98 | - | |
99 | - try { | |
100 | - return (int) ses->wait_for_ready(seconds); | |
101 | - } catch(std::exception &e) { | |
102 | - tn3270_lasterror = e.what(); | |
103 | - } | |
104 | - | |
105 | - } | |
106 | - return -1; | |
107 | - | |
108 | -} | |
109 | - | |
110 | -int tn3270_wait(h3270::session *ses, int seconds) { | |
111 | - | |
112 | - if(ses) { | |
113 | - | |
114 | - try { | |
115 | - return (int) ses->wait(seconds); | |
116 | - } catch(std::exception &e) { | |
117 | - tn3270_lasterror = e.what(); | |
118 | - } | |
119 | - | |
120 | - } | |
121 | - return -1; | |
122 | -} | |
123 | - |
src/native/private.h
... | ... | @@ -1,143 +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 private.h 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 | - * http://www.mono-project.com/docs/advanced/pinvoke/ | |
31 | - * http://tirania.org/blog/archive/2011/Dec-19.html | |
32 | - * | |
33 | - */ | |
34 | -#ifndef PRIVATE_H_INCLUDED | |
35 | - | |
36 | - #define PRIVATE_H_INCLUDED | |
37 | - | |
38 | - #include <config.h> | |
39 | - | |
40 | - #if defined(_WIN32) | |
41 | - | |
42 | - #include <windows.h> | |
43 | - | |
44 | - #define DLL_PRIVATE extern | |
45 | - #define DLL_PUBLIC extern __declspec (dllexport) __attribute__((cdecl)) | |
46 | - | |
47 | - #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) | |
48 | - | |
49 | - #define DLL_PRIVATE __hidden extern | |
50 | - #define DLL_PUBLIC extern | |
51 | - | |
52 | - #else | |
53 | - | |
54 | - #define DLL_PRIVATE __attribute__((visibility("hidden"))) extern | |
55 | - #define DLL_PUBLIC __attribute__((visibility("default"))) extern | |
56 | - | |
57 | - #endif | |
58 | - | |
59 | - #include <cstdio> | |
60 | - #include <string> | |
61 | - | |
62 | - #ifdef DEBUG | |
63 | - #define debug( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n" , __FILE__, (int) __LINE__, __VA_ARGS__ ); fflush(stderr); | |
64 | - #else | |
65 | - #define debug( fmt, ... ) /* */ | |
66 | - #endif // DEBUG | |
67 | - | |
68 | - #ifdef ENABLE_TRACE_TO_FILE | |
69 | - DLL_PRIVATE void write_trace(const char *fmt, ...); | |
70 | - #define trace_to_file( ... ) write_trace(__VA_ARGS__) | |
71 | - #else | |
72 | - #define trace_to_file( ... ) /* */ | |
73 | - #endif // ENABLE_TRACE_TO_FILE | |
74 | - | |
75 | - #include <pw3270/pw3270cpp.h> | |
76 | - #include <cerrno> | |
77 | - #include <cstring> | |
78 | - | |
79 | - DLL_PRIVATE std::string tn3270_lasterror; | |
80 | - | |
81 | - extern "C" { | |
82 | - | |
83 | - DLL_PUBLIC h3270::session * tn3270_create_session(const char *name); | |
84 | - | |
85 | - DLL_PUBLIC int tn3270_destroy_session(h3270::session *ses); | |
86 | - | |
87 | - DLL_PUBLIC int tn3270_get_version(h3270::session *ses, char* str, int strlen); | |
88 | - DLL_PUBLIC int tn3270_get_revision(h3270::session *ses, char* str, int strlen); | |
89 | - | |
90 | - DLL_PUBLIC int tn3270_connect(h3270::session *ses, const char *host, time_t wait); | |
91 | - DLL_PUBLIC int tn3270_disconnect(h3270::session *ses); | |
92 | - DLL_PUBLIC int tn3270_is_connected(h3270::session *ses); | |
93 | - DLL_PUBLIC int tn3270_is_ready(h3270::session *ses); | |
94 | - | |
95 | - DLL_PUBLIC int tn3270_set_url(h3270::session *ses, const char *url); | |
96 | - DLL_PUBLIC int tn3270_get_url(h3270::session *ses, char* str, int strlen); | |
97 | - | |
98 | - DLL_PUBLIC int tn3270_set_error_message(h3270::session *ses, const char *url); | |
99 | - DLL_PUBLIC int tn3270_get_error_message(h3270::session *ses, char* str, int strlen); | |
100 | - | |
101 | - DLL_PUBLIC int tn3270_set_cursor_addr(h3270::session *ses, int addr); | |
102 | - DLL_PUBLIC int tn3270_get_cursor_addr(h3270::session *ses); | |
103 | - | |
104 | - DLL_PUBLIC int tn3270_action(h3270::session *ses, const char *name); | |
105 | - | |
106 | - DLL_PUBLIC int tn3270_erase(h3270::session *ses); | |
107 | - DLL_PUBLIC int tn3270_erase_eof(h3270::session *ses); | |
108 | - DLL_PUBLIC int tn3270_erase_eol(h3270::session *ses); | |
109 | - DLL_PUBLIC int tn3270_erase_input(h3270::session *ses); | |
110 | - | |
111 | - DLL_PUBLIC int tn3270_wait_for_ready(h3270::session *ses, int seconds); | |
112 | - DLL_PUBLIC int tn3270_wait(h3270::session *ses, int seconds); | |
113 | - | |
114 | - DLL_PUBLIC int tn3270_get_cstate(h3270::session *ses); | |
115 | - DLL_PUBLIC int tn3270_get_program_message(h3270::session *ses); | |
116 | - DLL_PUBLIC int tn3270_get_secure(h3270::session *ses); | |
117 | - | |
118 | - DLL_PUBLIC int tn3270_get_contents(h3270::session *ses, char* str, int strlen); | |
119 | - DLL_PUBLIC int tn3270_get_string(h3270::session *ses, int addr, char* str, int strlen); | |
120 | - DLL_PUBLIC int tn3270_get_string_at(h3270::session *ses, int row, int col, char* str, int strlen); | |
121 | - | |
122 | - DLL_PUBLIC int tn3270_set_string_at(h3270::session *ses, int row, int col, const char* str); | |
123 | - | |
124 | - DLL_PUBLIC int tn3270_wait_for_string_at(h3270::session *ses, int row, int col, const char *key, int timeout); | |
125 | - DLL_PUBLIC int tn3270_cmp_string_at(h3270::session *ses, int row, int col, const char* str); | |
126 | - | |
127 | - DLL_PUBLIC int tn3270_set_unlock_delay(h3270::session *ses, int ms); | |
128 | - DLL_PUBLIC int tn3270_set_cursor_position(h3270::session *ses, int row, int col); | |
129 | - | |
130 | - DLL_PUBLIC int tn3270_enter(h3270::session *ses); | |
131 | - DLL_PUBLIC int tn3270_pfkey(h3270::session *ses, int key); | |
132 | - DLL_PUBLIC int tn3270_pakey(h3270::session *ses, int key); | |
133 | - | |
134 | - DLL_PUBLIC int tn3270_get_width(h3270::session *ses); | |
135 | - DLL_PUBLIC int tn3270_get_height(h3270::session *ses); | |
136 | - DLL_PUBLIC int tn3270_get_length(h3270::session *ses); | |
137 | - | |
138 | - DLL_PUBLIC int tn3270_set_charset(h3270::session *ses, const char* str); | |
139 | - | |
140 | - } | |
141 | - | |
142 | - | |
143 | -#endif // PRIVATE_H_INCLUDED |
src/native/screen.cc
... | ... | @@ -1,140 +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 screen.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 | - */ | |
29 | - | |
30 | - #include "private.h" | |
31 | - | |
32 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | - | |
34 | -int tn3270_get_contents(h3270::session *ses, char* str, int sz) { | |
35 | - | |
36 | - if(!ses) { | |
37 | - return -1; | |
38 | - } | |
39 | - | |
40 | - try { | |
41 | - | |
42 | - std::string contents = ses->get_contents(); | |
43 | - | |
44 | - memset(str,0,sz); | |
45 | - strncpy(str,contents.c_str(),sz); | |
46 | - if(contents.size() < ((size_t) sz)) { | |
47 | - str[contents.size()] = 0; | |
48 | - return contents.size(); | |
49 | - } | |
50 | - | |
51 | - } catch(std::exception &e) { | |
52 | - tn3270_lasterror = e.what(); | |
53 | - return -1; | |
54 | - } | |
55 | - | |
56 | - return sz; | |
57 | - | |
58 | -} | |
59 | - | |
60 | -int tn3270_get_string(h3270::session *ses, int addr, char* str, int strlen) { | |
61 | - | |
62 | - if(!ses) { | |
63 | - return -1; | |
64 | - } | |
65 | - | |
66 | - try { | |
67 | - memset(str,0,strlen); | |
68 | - strncpy(str,ses->get_string(addr,strlen).c_str(),strlen); | |
69 | - } catch(std::exception &e) { | |
70 | - tn3270_lasterror = e.what(); | |
71 | - return -1; | |
72 | - } | |
73 | - | |
74 | - return 0; | |
75 | -} | |
76 | - | |
77 | -int tn3270_get_string_at(h3270::session *ses, int row, int col, char* str, int sz) { | |
78 | - | |
79 | - if(!ses) { | |
80 | - return -1; | |
81 | - } | |
82 | - | |
83 | - try { | |
84 | - memset(str,0,sz+1); | |
85 | - strncpy(str,ses->get_string_at(row,col,sz).c_str(),sz); | |
86 | - trace_to_file("%s(%d,%d,%d):\n%s\n",__FUNCTION__,row,col,sz,str); | |
87 | - } catch(std::exception &e) { | |
88 | - tn3270_lasterror = e.what(); | |
89 | - return -1; | |
90 | - } | |
91 | - return (int) strlen(str); | |
92 | -} | |
93 | - | |
94 | -int tn3270_set_string_at(h3270::session *ses, int row, int col, const char* str) { | |
95 | - | |
96 | - if(!ses) { | |
97 | - return -1; | |
98 | - } | |
99 | - | |
100 | - try { | |
101 | - trace_to_file("%s(%d,%d):\n%s\n",__FUNCTION__,row,col,str); | |
102 | - debug("%s(%d,%d,\"%s\")",__FUNCTION__,row,col,str); | |
103 | - ses->set_string_at(row,col,str); | |
104 | - } catch(std::exception &e) { | |
105 | - tn3270_lasterror = e.what(); | |
106 | - return -1; | |
107 | - } | |
108 | - return 0; | |
109 | -} | |
110 | - | |
111 | -int tn3270_wait_for_string_at(h3270::session *ses, int row, int col, const char *key, int timeout) { | |
112 | - | |
113 | - if(ses) { | |
114 | - | |
115 | - try { | |
116 | - return ses->wait_for_string_at(row,col,key,timeout); | |
117 | - } catch(std::exception &e) { | |
118 | - tn3270_lasterror = e.what(); | |
119 | - } | |
120 | - | |
121 | - } | |
122 | - | |
123 | - return -1; | |
124 | - | |
125 | -} | |
126 | - | |
127 | -int tn3270_cmp_string_at(h3270::session *ses, int row, int col, const char* str) { | |
128 | - | |
129 | - if(ses) { | |
130 | - | |
131 | - try { | |
132 | - return ses->cmp_string_at(row,col,str); | |
133 | - } catch(std::exception &e) { | |
134 | - tn3270_lasterror = e.what(); | |
135 | - } | |
136 | - | |
137 | - } | |
138 | - | |
139 | - return -1; | |
140 | -} |
src/native/set.cc
... | ... | @@ -1,94 +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 | - */ | |
29 | - | |
30 | - #include "private.h" | |
31 | - | |
32 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
33 | - | |
34 | -int tn3270_set_unlock_delay(h3270::session *ses, int ms) { | |
35 | - try { | |
36 | - ses->set_unlock_delay((unsigned short) ms); | |
37 | - } catch(std::exception &e) { | |
38 | - tn3270_lasterror = e.what(); | |
39 | - return -1; | |
40 | - } | |
41 | - return 0; | |
42 | -} | |
43 | - | |
44 | -int tn3270_set_cursor_position(h3270::session *ses, int row, int col) { | |
45 | - try { | |
46 | - ses->set_cursor_position(row,col); | |
47 | - } catch(std::exception &e) { | |
48 | - tn3270_lasterror = e.what(); | |
49 | - return -1; | |
50 | - } | |
51 | - return 0; | |
52 | -} | |
53 | - | |
54 | -int tn3270_set_cursor_addr(h3270::session *ses, int addr) { | |
55 | - try { | |
56 | - ses->set_cursor_addr(addr); | |
57 | - } catch(std::exception &e) { | |
58 | - tn3270_lasterror = e.what(); | |
59 | - return -1; | |
60 | - } | |
61 | - return 0; | |
62 | -} | |
63 | - | |
64 | -int tn3270_set_charset(h3270::session *ses, const char* str) { | |
65 | - | |
66 | - if(!ses) { | |
67 | - return EINVAL; | |
68 | - } | |
69 | - | |
70 | - try { | |
71 | - trace_to_file("%s: \"%s\" -> \"%s\"",__FUNCTION__,ses->get_display_charset().c_str(),str); | |
72 | - ses->set_display_charset(NULL, str); | |
73 | - } catch(std::exception &e) { | |
74 | - tn3270_lasterror = e.what(); | |
75 | - return -1; | |
76 | - } | |
77 | - return 0; | |
78 | -} | |
79 | - | |
80 | -int tn3270_set_url(h3270::session *ses, const char *url) { | |
81 | - try { | |
82 | - debug("%s(%s)",__FUNCTION__,url); | |
83 | - ses->set_url(url); | |
84 | - } catch(std::exception &e) { | |
85 | - tn3270_lasterror = e.what(); | |
86 | - return -1; | |
87 | - } | |
88 | - return 0; | |
89 | -} | |
90 | - | |
91 | -int tn3270_set_error_message(h3270::session *ses, const char *str) { | |
92 | - tn3270_lasterror = str; | |
93 | - return 0; | |
94 | -} |
... | ... | @@ -0,0 +1,167 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - 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 | +/** | |
31 | + * @file | |
32 | + * | |
33 | + * @brief | |
34 | + * | |
35 | + * @author perry.werneck@gmail.com | |
36 | + * | |
37 | + */ | |
38 | + | |
39 | + #include <getopt.h> | |
40 | + #include <cstdlib> | |
41 | + #include <native.h> | |
42 | + | |
43 | + using namespace std; | |
44 | + | |
45 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
46 | + | |
47 | + | |
48 | +/* | |
49 | + // test host object | |
50 | + static void testHost(const char *session) { | |
51 | + | |
52 | + TN3270::Host host{session,nullptr,10}; | |
53 | + | |
54 | + try { | |
55 | + | |
56 | + cout | |
57 | + << "Version: " << host.getVersion() | |
58 | + << "\tRevision: " << host.getRevision() | |
59 | + << std::endl; | |
60 | + | |
61 | + host.connect(nullptr); | |
62 | + | |
63 | + cout | |
64 | + << "Wait for unlock returns " << host.getKeyboardLockState() << std::endl | |
65 | + << "Connection state is " << toCharString(host.getConnectionState()) << std::endl | |
66 | + << "Program message is " << toCharString(host.getProgramMessage()) << std::endl | |
67 | + << "Luname is " << host.getLUName() << std::endl | |
68 | + << std::endl; | |
69 | + | |
70 | + if(host) { | |
71 | + cout << host << endl; | |
72 | + } | |
73 | + | |
74 | + host.setCursor(10,10); | |
75 | + | |
76 | + host.wait(10); | |
77 | + | |
78 | + // host.input("test@0another line"); | |
79 | + | |
80 | + host.push(TN3270::ENTER); | |
81 | + | |
82 | + cout << endl << "[" << host.toString((unsigned int) 1, (unsigned int) 3,7) << "]" << endl; | |
83 | + cout << endl << "[" << host.toString((int) 15, (int) 10) << "]" << endl; | |
84 | + | |
85 | + host.pfkey(3); | |
86 | + | |
87 | + host.wait(10); | |
88 | + | |
89 | + host.disconnect(); | |
90 | + | |
91 | + } catch(const std::exception &e) { | |
92 | + | |
93 | + cerr << std::endl << e.what() << std::endl << std::endl; | |
94 | + | |
95 | + } | |
96 | + | |
97 | + } | |
98 | + */ | |
99 | + | |
100 | + int main(int argc, char **argv) { | |
101 | + | |
102 | + const char * session = ""; // "pw3270:a"; | |
103 | + char buffer[4096]; | |
104 | + | |
105 | + #pragma GCC diagnostic push | |
106 | + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" | |
107 | + static struct option options[] = { | |
108 | + { "session", required_argument, 0, 's' }, | |
109 | + { 0, 0, 0, 0} | |
110 | + | |
111 | + }; | |
112 | + #pragma GCC diagnostic pop | |
113 | + | |
114 | + int long_index =0; | |
115 | + int opt; | |
116 | + while((opt = getopt_long(argc, argv, "s:", options, &long_index )) != -1) { | |
117 | + | |
118 | + switch(opt) { | |
119 | + case 's': | |
120 | + session = optarg; | |
121 | + break; | |
122 | + | |
123 | + } | |
124 | + | |
125 | + } | |
126 | + | |
127 | + cout << "Session: " << session << endl; | |
128 | + | |
129 | + TN3270::Host * host = tn3270_create_session(session); | |
130 | + | |
131 | + tn3270_get_version(host,buffer,sizeof(buffer)); | |
132 | + cout << "Version: " << buffer << endl; | |
133 | + | |
134 | + tn3270_get_revision(host,buffer,sizeof(buffer)); | |
135 | + cout << "Revision: " << buffer << endl; | |
136 | + | |
137 | + tn3270_connect(host,nullptr,10); | |
138 | + | |
139 | + cout << "Connection state is " << tn3270_get_cstate(host) << std::endl | |
140 | + << "Program message is " << tn3270_get_program_message(host) << std::endl; | |
141 | + | |
142 | + tn3270_get_contents(host,buffer,sizeof(buffer)); | |
143 | + cout << buffer << endl; | |
144 | + | |
145 | + tn3270_set_cursor_position(host,10,10); | |
146 | + tn3270_wait(host,10); | |
147 | + | |
148 | + tn3270_enter(host); | |
149 | + tn3270_wait_for_ready(host,10); | |
150 | + | |
151 | + tn3270_get_contents(host,buffer,sizeof(buffer)); | |
152 | + cout << buffer << endl; | |
153 | + | |
154 | + tn3270_pfkey(host,3); | |
155 | + tn3270_wait_for_ready(host,10); | |
156 | + | |
157 | + tn3270_get_contents(host,buffer,sizeof(buffer)); | |
158 | + cout << buffer << endl; | |
159 | + | |
160 | + tn3270_disconnect(host); | |
161 | + | |
162 | + tn3270_destroy_session(host); | |
163 | + | |
164 | + return 0; | |
165 | + } | |
166 | + | |
167 | + | ... | ... |
... | ... | @@ -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", "lib3270-mono-bindings@DLLEXT@\0" | |
18 | + VALUE "ProductName", "pw3270\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/pw3270-sharp/Makefile.in
... | ... | @@ -1,108 +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., 59 Temple | |
19 | -# Place, Suite 330, Boston, MA, 02111-1307, USA | |
20 | -# | |
21 | -# Contatos: | |
22 | -# | |
23 | -# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
24 | -# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
25 | -# | |
26 | - | |
27 | -MODULE_NAME=pw3270-sharp | |
28 | - | |
29 | -SOURCES=$(MODULE_NAME).cs | |
30 | -LIBNAME=$(MODULE_NAME).dll | |
31 | - | |
32 | -#---[ Configuration values ]------------------------------------------------------------- | |
33 | - | |
34 | -PACKAGE_NAME=@PACKAGE_NAME@ | |
35 | -PACKAGE_VERSION=@PACKAGE_VERSION@ | |
36 | -PACKAGE_TARNAME=@PACKAGE_TARNAME@ | |
37 | - | |
38 | -prefix=@prefix@ | |
39 | -exec_prefix=@exec_prefix@ | |
40 | -bindir=@bindir@ | |
41 | -sbindir=@sbindir@ | |
42 | -libdir=@libdir@ | |
43 | - | |
44 | -BASEDIR=@BASEDIR@ | |
45 | -SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | |
46 | - | |
47 | -OBJDIR=$(BASEDIR)/.obj | |
48 | -OBJDBG=$(OBJDIR)/Debug | |
49 | -OBJRLS=$(OBJDIR)/Release | |
50 | - | |
51 | -BINDIR=$(BASEDIR)/.bin | |
52 | -BINDBG=$(BINDIR)/Debug | |
53 | -BINRLS=$(BINDIR)/Release | |
54 | - | |
55 | -INSTALL=@INSTALL@ | |
56 | -INSTALL_DATA=@INSTALL_DATA@ | |
57 | -INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
58 | - | |
59 | -LN_S=@LN_S@ | |
60 | - | |
61 | -MCS=@MCS@ | |
62 | -MKDIR=@MKDIR_P@ | |
63 | -GACUTIL=@GACUTIL@ | |
64 | -SN=@SN@ | |
65 | - | |
66 | -#---[ Targets ]-------------------------------------------------------------------------- | |
67 | - | |
68 | -all: \ | |
69 | - $(BINRLS)/$(LIBNAME) | |
70 | - | |
71 | -Release: \ | |
72 | - $(BINRLS)/$(LIBNAME) | |
73 | - | |
74 | -install: \ | |
75 | - $(BINRLS)/$(LIBNAME) | |
76 | - | |
77 | - @$(GACUTIL) -i $(BINRLS)/$(LIBNAME) -root $(DESTDIR)/usr/lib | |
78 | - | |
79 | - @$(MKDIR) $(DESTDIR)/usr/share/gapi-2.0/$(MODULE_NAME) | |
80 | - @$(INSTALL_DATA) $(BINRLS)/$(MODULE_NAME).xml $(DESTDIR)/usr/share/gapi-2.0/$(MODULE_NAME) | |
81 | - | |
82 | - @$(MKDIR) $(DESTDIR)/usr/lib/mono/$(MODULE_NAME)-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
83 | - @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)/usr/lib/mono/$(MODULE_NAME)-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
84 | - | |
85 | - @$(MKDIR) $(DESTDIR)/$(libdir)/pkgconfig | |
86 | - @$(INSTALL_DATA) $(MODULE_NAME).pc $(DESTDIR)/$(libdir)/pkgconfig | |
87 | - | |
88 | -Debug: \ | |
89 | - $(BINDBG)/$(LIBNAME) | |
90 | - | |
91 | -$(BINRLS)/$(MODULE_NAME).key: | |
92 | - | |
93 | - @$(SN) -k $@ | |
94 | - | |
95 | -$(BINDBG)/$(LIBNAME): \ | |
96 | - $(SOURCES) | |
97 | - | |
98 | - @$(MKDIR) `dirname $@` | |
99 | - @$(MCS) -debug -target:library -out:$@ $< | |
100 | - | |
101 | -$(BINRLS)/$(LIBNAME): \ | |
102 | - $(SOURCES) \ | |
103 | - $(BINRLS)/$(MODULE_NAME).key | |
104 | - | |
105 | - @$(MKDIR) `dirname $@` | |
106 | - @$(MCS) -doc:$(BINRLS)/$(MODULE_NAME).xml -keyfile:$(BINRLS)/$(MODULE_NAME).key -target:library -out:$@ $(SOURCES) | |
107 | - | |
108 | - |
src/pw3270-sharp/pw3270-sharp.cs
... | ... | @@ -1,618 +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 tn3270-sharp.cs 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://msdn.microsoft.com/en-us/library/5ast78ax.aspx | |
31 | - * | |
32 | - */ | |
33 | - | |
34 | -using System; | |
35 | -using System.Text; | |
36 | -using System.Runtime.InteropServices; | |
37 | - | |
38 | -namespace pw3270 { | |
39 | - | |
40 | - /// <summary> | |
41 | - /// Session with 3270 HOST. | |
42 | - /// </summary> | |
43 | - public class Session { | |
44 | - | |
45 | - /// <summary> | |
46 | - /// lib3270 session handle | |
47 | - /// </summary> | |
48 | - private IntPtr hSession; | |
49 | - | |
50 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
51 | - extern static IntPtr tn3270_create_session(string name); | |
52 | - | |
53 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
54 | - extern static int tn3270_destroy_session(IntPtr session); | |
55 | - | |
56 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
57 | - extern static int tn3270_get_version(IntPtr session, StringBuilder str, int strlen); | |
58 | - | |
59 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
60 | - extern static int tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); | |
61 | - | |
62 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
63 | - extern static int tn3270_connect(IntPtr Session, string host, int wait); | |
64 | - | |
65 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
66 | - extern static int tn3270_is_connected(IntPtr Session); | |
67 | - | |
68 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
69 | - extern static int tn3270_is_ready(IntPtr Session); | |
70 | - | |
71 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
72 | - extern static int tn3270_disconnect(IntPtr Session); | |
73 | - | |
74 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
75 | - extern static int tn3270_wait_for_ready(IntPtr Session, int seconds); | |
76 | - | |
77 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
78 | - extern static int tn3270_wait(IntPtr Session, int seconds); | |
79 | - | |
80 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
81 | - extern static int tn3270_get_cstate(IntPtr Session); | |
82 | - | |
83 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
84 | - extern static int tn3270_get_program_message(IntPtr Session); | |
85 | - | |
86 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
87 | - extern static int tn3270_get_secure(IntPtr Session); | |
88 | - | |
89 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
90 | - extern static int tn3270_get_contents(IntPtr Session, StringBuilder str, int strlen); | |
91 | - | |
92 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
93 | - extern static int tn3270_get_string(IntPtr Session, int addr, StringBuilder str, int strlen); | |
94 | - | |
95 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
96 | - extern static int tn3270_get_string_at(IntPtr Session, int row, int col, StringBuilder str, int strlen); | |
97 | - | |
98 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
99 | - extern static int tn3270_set_string_at(IntPtr Session, int row, int col, string str); | |
100 | - | |
101 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
102 | - extern static int tn3270_wait_for_string_at(IntPtr Session, int row, int col, string key, int timeout); | |
103 | - | |
104 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
105 | - extern static int tn3270_cmp_string_at(IntPtr Session, int row, int col, string str); | |
106 | - | |
107 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
108 | - extern static int tn3270_set_unlock_delay(IntPtr Session, int ms); | |
109 | - | |
110 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
111 | - extern static int tn3270_set_cursor_position(IntPtr Session, int row, int col); | |
112 | - | |
113 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
114 | - extern static int tn3270_set_cursor_addr(IntPtr Session, int addr); | |
115 | - | |
116 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
117 | - extern static int tn3270_get_cursor_addr(IntPtr Session); | |
118 | - | |
119 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
120 | - extern static int tn3270_enter(IntPtr Session); | |
121 | - | |
122 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
123 | - extern static int tn3270_pfkey(IntPtr Session, int key); | |
124 | - | |
125 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
126 | - extern static int tn3270_pakey(IntPtr Session, int key); | |
127 | - | |
128 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
129 | - extern static int tn3270_get_width(IntPtr Session); | |
130 | - | |
131 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
132 | - extern static int tn3270_get_height(IntPtr Session); | |
133 | - | |
134 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
135 | - extern static int tn3270_get_length(IntPtr Session); | |
136 | - | |
137 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
138 | - extern static int tn3270_set_charset(IntPtr Session, string str); | |
139 | - | |
140 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
141 | - extern static int tn3270_set_url(IntPtr Session, string str); | |
142 | - | |
143 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
144 | - extern static int tn3270_get_url(IntPtr Session, StringBuilder str, int strlen); | |
145 | - | |
146 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
147 | - extern static int tn3270_set_error_message(IntPtr Session, string str); | |
148 | - | |
149 | - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] | |
150 | - extern static int tn3270_get_error_message(IntPtr Session, StringBuilder str, int strlen); | |
151 | - | |
152 | - /// <summary> | |
153 | - /// Create a new session with lib3270/pw3270 | |
154 | - /// </summary> | |
155 | - /// | |
156 | - /// <param name="name">Session name or empty string for a hidden session</param> | |
157 | - /// | |
158 | - public Session(string name) { | |
159 | - hSession = tn3270_create_session(name); | |
160 | - tn3270_set_charset(hSession,"UTF-8"); | |
161 | - } | |
162 | - | |
163 | - /// <summary> | |
164 | - /// Disconnect from host, destroy session. | |
165 | - /// </summary> | |
166 | - /// | |
167 | - ~Session() { | |
168 | - tn3270_destroy_session(hSession); | |
169 | - } | |
170 | - | |
171 | - /// <summary> | |
172 | - /// Get lib3270/pw3270 Version identifier | |
173 | - /// </summary> | |
174 | - /// | |
175 | - /// <returns> | |
176 | - /// The version of the active instance. | |
177 | - /// </returns> | |
178 | - /// | |
179 | - public string GetVersion() { | |
180 | - StringBuilder str = new StringBuilder(10); | |
181 | - tn3270_get_version(hSession, str, 10); | |
182 | - return str.ToString(); | |
183 | - } | |
184 | - | |
185 | - /// <summary> | |
186 | - /// Lib3270 version. | |
187 | - /// </summary> | |
188 | - /// | |
189 | - /// <returns> | |
190 | - /// Lib3270 version string | |
191 | - /// </returns> | |
192 | - /// | |
193 | - public string Version { | |
194 | - get { | |
195 | - return GetVersion(); | |
196 | - } | |
197 | - } | |
198 | - | |
199 | - /// <summary> | |
200 | - /// Get lib3270/pw3270 Revision number | |
201 | - /// </summary> | |
202 | - /// | |
203 | - /// <returns> | |
204 | - /// The revision of the active instance. | |
205 | - /// </returns> | |
206 | - /// | |
207 | - public string GetRevision() { | |
208 | - StringBuilder str = new StringBuilder(10); | |
209 | - tn3270_get_revision(hSession, str, 10); | |
210 | - return str.ToString(); | |
211 | - } | |
212 | - | |
213 | - public string Revision { | |
214 | - get { | |
215 | - return GetRevision(); | |
216 | - } | |
217 | - } | |
218 | - | |
219 | - /// <summary> | |
220 | - /// Connect to 3270 host. | |
221 | - /// </summary> | |
222 | - /// | |
223 | - /// <param name="host">URL of the target host (tn3270://hostname:port)</param> | |
224 | - /// <param name="wait">How many seconds should the call wait for the connection becomes ready</param> | |
225 | - /// | |
226 | - /// <returns> | |
227 | - /// </returns> | |
228 | - /// | |
229 | - public int Connect(string host, int wait) { | |
230 | - return tn3270_connect(hSession, host, wait); | |
231 | - } | |
232 | - | |
233 | - /// <summary> | |
234 | - /// Get connection state | |
235 | - /// </summary> | |
236 | - /// | |
237 | - /// <returns> | |
238 | - /// true if the session is connected to a remote host. | |
239 | - /// </returns> | |
240 | - /// | |
241 | - public bool IsConnected() { | |
242 | - return tn3270_is_connected(hSession) != 0; | |
243 | - } | |
244 | - | |
245 | - public bool Connected { | |
246 | - get { | |
247 | - return tn3270_is_connected(hSession) != 0; | |
248 | - } | |
249 | - } | |
250 | - | |
251 | - public bool IsReady() { | |
252 | - return tn3270_is_ready(hSession) != 0; | |
253 | - } | |
254 | - | |
255 | - public bool Ready { | |
256 | - get { | |
257 | - return tn3270_is_ready(hSession) != 0; | |
258 | - } | |
259 | - } | |
260 | - | |
261 | - /// <summary> | |
262 | - /// Disconnect from 3270 host. | |
263 | - /// </summary> | |
264 | - /// | |
265 | - public int Disconnect() { | |
266 | - return tn3270_disconnect(hSession); | |
267 | - } | |
268 | - | |
269 | - /// <summary> | |
270 | - /// Wait for network activity | |
271 | - /// </summary> | |
272 | - /// | |
273 | - /// <param name="seconds">Seconds to wait</param> | |
274 | - /// | |
275 | - /// <returns> | |
276 | - /// | |
277 | - /// </returns> | |
278 | - /// | |
279 | - public int WaitForReady(int seconds) { | |
280 | - return tn3270_wait_for_ready(hSession, seconds); | |
281 | - } | |
282 | - | |
283 | - /// <summary> | |
284 | - /// "Sleep" keeping the network activity. | |
285 | - /// </summary> | |
286 | - /// | |
287 | - /// <param name="seconds">Number of seconds to wait</param> | |
288 | - /// | |
289 | - /// <returns> | |
290 | - /// | |
291 | - /// </returns> | |
292 | - /// | |
293 | - public int Wait(int seconds) { | |
294 | - return tn3270_wait(hSession, seconds); | |
295 | - } | |
296 | - | |
297 | - /// <summary> | |
298 | - /// Get contents | |
299 | - /// </summary> | |
300 | - /// | |
301 | - /// <returns> | |
302 | - /// Contents from terminal screen. | |
303 | - /// </returns> | |
304 | - /// | |
305 | - public override string ToString() { | |
306 | - int strlen = (tn3270_get_width(hSession)+1) * (tn3270_get_height(hSession)+1); | |
307 | - StringBuilder str = new StringBuilder(strlen+1); | |
308 | - strlen = tn3270_get_contents(hSession, str, strlen); | |
309 | - return str.ToString(); | |
310 | - } | |
311 | - | |
312 | - | |
313 | - /// <summary> | |
314 | - /// Get contents at address | |
315 | - /// </summary> | |
316 | - /// | |
317 | - /// <param name="addr">Address of text in the screen buffer</param> | |
318 | - /// <param name="strlen">Number of characters to get</param> | |
319 | - /// | |
320 | - /// <returns> | |
321 | - /// Contents from terminal screen. | |
322 | - /// </returns> | |
323 | - /// | |
324 | - public string GetString(int addr, int strlen) { | |
325 | - StringBuilder str = new StringBuilder(strlen+1); | |
326 | - tn3270_get_string(hSession, addr, str, strlen); | |
327 | - return str.ToString(); | |
328 | - } | |
329 | - | |
330 | - /// <summary> | |
331 | - /// Get contents at position. | |
332 | - /// </summary> | |
333 | - /// | |
334 | - /// <param name="row">Start row</param> | |
335 | - /// <param name="col">Start col</param> | |
336 | - /// <param name="strlen">Number of characters to get</param> | |
337 | - /// | |
338 | - /// <returns> | |
339 | - /// Contents from terminal screen. | |
340 | - /// </returns> | |
341 | - /// | |
342 | - public string GetStringAt(int row, int col, int strlen) { | |
343 | - StringBuilder str = new StringBuilder(strlen+1); | |
344 | - tn3270_get_string_at(hSession, row, col, str, strlen); | |
345 | - return str.ToString(); | |
346 | - } | |
347 | - | |
348 | - /// <summary> | |
349 | - /// Set contents at position | |
350 | - /// </summary> | |
351 | - /// | |
352 | - /// <param name="row">Start row</param> | |
353 | - /// <param name="col">Start col</param> | |
354 | - /// <param name="str">Text to set</param> | |
355 | - /// | |
356 | - public void SetStringAt(int row, int col, string str) { | |
357 | - tn3270_set_string_at(hSession, row, col, str); | |
358 | - } | |
359 | - | |
360 | - /// <summary> | |
361 | - /// Wait for text at position. | |
362 | - /// </summary> | |
363 | - /// | |
364 | - /// <param name="row">Start row</param> | |
365 | - /// <param name="col">Start col</param> | |
366 | - /// <param name="str">Text to wait</param> | |
367 | - /// <param name="timeout">Seconds to wait</param> | |
368 | - /// | |
369 | - /// <returns> | |
370 | - /// | |
371 | - /// </returns> | |
372 | - /// | |
373 | - public int WaitForStringAt(int row, int col, string str, int timeout) { | |
374 | - return tn3270_wait_for_string_at(hSession, row, col, str, timeout); | |
375 | - } | |
376 | - | |
377 | - /// <summary> | |
378 | - /// Compare contents at position | |
379 | - /// </summary> | |
380 | - /// | |
381 | - /// <param name="row">Start row</param> | |
382 | - /// <param name="col">Start col</param> | |
383 | - /// <param name="str">Text to compare</param> | |
384 | - /// | |
385 | - /// <returns> | |
386 | - /// Result (0 = The strings are the same). | |
387 | - /// </returns> | |
388 | - /// | |
389 | - public int CmpStringAt(int row, int col, string str) { | |
390 | - return tn3270_cmp_string_at(hSession, row, col, str); | |
391 | - } | |
392 | - | |
393 | - /// <summary> | |
394 | - /// Set cursor position. | |
395 | - /// </summary> | |
396 | - /// | |
397 | - /// <param name="row">New cursor row</param> | |
398 | - /// <param name="col">New cursor column</param> | |
399 | - /// | |
400 | - public void SetCursorPosition(int row, int col) { | |
401 | - tn3270_set_cursor_position(hSession, row, col); | |
402 | - } | |
403 | - | |
404 | - /// <summary> | |
405 | - /// Set cursor position based on address. | |
406 | - /// </summary> | |
407 | - /// | |
408 | - /// <param name="addr">Address of the new cursor position</param> | |
409 | - /// | |
410 | - public void SetCursorPosition(int addr) { | |
411 | - tn3270_set_cursor_addr(hSession, addr); | |
412 | - } | |
413 | - | |
414 | - /// <summary> | |
415 | - /// Get cursor address | |
416 | - /// </summary> | |
417 | - /// | |
418 | - public int GetCursorPosition() { | |
419 | - return tn3270_get_cursor_addr(hSession); | |
420 | - } | |
421 | - | |
422 | - /// <summary> | |
423 | - /// Cursor address | |
424 | - /// </summary> | |
425 | - /// | |
426 | - public int CursorPosition { | |
427 | - set { | |
428 | - tn3270_set_cursor_addr(hSession, value); | |
429 | - } | |
430 | - get { | |
431 | - return tn3270_get_cursor_addr(hSession); | |
432 | - } | |
433 | - } | |
434 | - | |
435 | - /// <summary> | |
436 | - /// Set the "screen ready" delay | |
437 | - /// </summary> | |
438 | - /// | |
439 | - public int SetUnlockDelay(int ms) { | |
440 | - return tn3270_set_unlock_delay(hSession, ms); | |
441 | - } | |
442 | - | |
443 | - /// <summary> | |
444 | - /// Set the "screen ready" delay | |
445 | - /// </summary> | |
446 | - /// | |
447 | - public int UnlockDelay { | |
448 | - set { | |
449 | - tn3270_set_unlock_delay(hSession, value); | |
450 | - } | |
451 | - } | |
452 | - | |
453 | - | |
454 | - /// <summary> | |
455 | - /// Send "Enter" key | |
456 | - /// </summary> | |
457 | - /// | |
458 | - /// <returns> | |
459 | - /// | |
460 | - /// </returns> | |
461 | - /// | |
462 | - public int Enter() { | |
463 | - return tn3270_enter(hSession); | |
464 | - } | |
465 | - | |
466 | - /// <summary> | |
467 | - /// Send "PF" key | |
468 | - /// </summary> | |
469 | - /// | |
470 | - /// <param name="key">Key identifier 1=PF1, 2=PF2, ...</param> | |
471 | - /// | |
472 | - /// <returns> | |
473 | - /// | |
474 | - /// </returns> | |
475 | - /// | |
476 | - public int PfKey(int key) { | |
477 | - return tn3270_pfkey(hSession, key); | |
478 | - } | |
479 | - | |
480 | - /// <summary> | |
481 | - /// Send "PA" key | |
482 | - /// </summary> | |
483 | - /// | |
484 | - /// <param name="key">Key identifier 1=PA1, 2=PA2, ...</param> | |
485 | - /// | |
486 | - /// <returns> | |
487 | - /// | |
488 | - /// </returns> | |
489 | - /// | |
490 | - public int PaKey(int key) { | |
491 | - return tn3270_pakey(hSession, key); | |
492 | - } | |
493 | - | |
494 | - /// <summary> | |
495 | - /// Get screen width | |
496 | - /// </summary> | |
497 | - /// | |
498 | - /// <returns> | |
499 | - /// Screen width in characters (negative on error) | |
500 | - /// </returns> | |
501 | - /// | |
502 | - public int GetWidth() { | |
503 | - return tn3270_get_width(hSession); | |
504 | - } | |
505 | - | |
506 | - /// <summary> | |
507 | - /// Screen width in characters | |
508 | - /// </summary> | |
509 | - /// | |
510 | - /// <returns> | |
511 | - /// Screen width in characters (negative on error) | |
512 | - /// </returns> | |
513 | - /// | |
514 | - public int Width { | |
515 | - get { | |
516 | - return tn3270_get_width(hSession); | |
517 | - } | |
518 | - } | |
519 | - | |
520 | - /// <summary> | |
521 | - /// Get screen height | |
522 | - /// </summary> | |
523 | - /// | |
524 | - /// <returns> | |
525 | - /// Screen width in characters (negative on error) | |
526 | - /// </returns> | |
527 | - /// | |
528 | - public int GetHeight() { | |
529 | - return tn3270_get_height(hSession); | |
530 | - } | |
531 | - | |
532 | - /// <summary> | |
533 | - /// Screen height in characters | |
534 | - /// </summary> | |
535 | - /// | |
536 | - /// <returns> | |
537 | - /// Screen height in characters (negative on error) | |
538 | - /// </returns> | |
539 | - /// | |
540 | - public int Height { | |
541 | - get { | |
542 | - return tn3270_get_height(hSession); | |
543 | - } | |
544 | - } | |
545 | - | |
546 | - /// <summary> | |
547 | - /// Get length of terminal buffer (width * height) | |
548 | - /// </summary> | |
549 | - /// | |
550 | - /// <returns> | |
551 | - /// Terminal length in characters (negative on error) | |
552 | - /// </returns> | |
553 | - /// | |
554 | - public int GetLength() { | |
555 | - return tn3270_get_length(hSession); | |
556 | - } | |
557 | - | |
558 | - /// <summary> | |
559 | - /// Length of terminal buffer (width * height) | |
560 | - /// </summary> | |
561 | - /// | |
562 | - /// <returns> | |
563 | - /// Terminal length in characters (negative on error) | |
564 | - /// </returns> | |
565 | - /// | |
566 | - public int Length { | |
567 | - get { | |
568 | - return tn3270_get_length(hSession); | |
569 | - } | |
570 | - } | |
571 | - | |
572 | - public string CharSet { | |
573 | - set { | |
574 | - tn3270_set_charset(hSession,value); | |
575 | - } | |
576 | - } | |
577 | - | |
578 | - /// <summary> | |
579 | - /// 3270 host URL | |
580 | - /// </summary> | |
581 | - /// | |
582 | - /// <returns> | |
583 | - /// 3270 host URL | |
584 | - /// </returns> | |
585 | - /// | |
586 | - public string Url { | |
587 | - set { | |
588 | - tn3270_set_url(hSession,value); | |
589 | - } | |
590 | - get { | |
591 | - StringBuilder str = new StringBuilder(1025); | |
592 | - tn3270_get_url(hSession, str, 1024); | |
593 | - return str.ToString(); | |
594 | - } | |
595 | - } | |
596 | - | |
597 | - /// <summary> | |
598 | - /// Last lib3270 error message | |
599 | - /// </summary> | |
600 | - /// | |
601 | - /// <returns> | |
602 | - /// Last lib3270 error message | |
603 | - /// </returns> | |
604 | - /// | |
605 | - public string Error { | |
606 | - set { | |
607 | - tn3270_set_error_message(hSession,value); | |
608 | - } | |
609 | - get { | |
610 | - StringBuilder str = new StringBuilder(1025); | |
611 | - tn3270_get_error_message(hSession, str, 1024); | |
612 | - return str.ToString(); | |
613 | - } | |
614 | - } | |
615 | - | |
616 | - } | |
617 | - | |
618 | -} |
src/pw3270-sharp/pw3270-sharp.pc.in
... | ... | @@ -1,11 +0,0 @@ |
1 | -prefix=${pcfiledir}/../.. | |
2 | -exec_prefix=${prefix} | |
3 | -libdir=${exec_prefix}/lib | |
4 | -gapidir=${prefix}/share/pw3270-sharp-1.0 | |
5 | - | |
6 | - | |
7 | -Name: pw3270-sharp | |
8 | -Description: Mono Bindings for pw3270 | |
9 | -Version: @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
10 | -Cflags: -I:${gapidir}/pw3270-sharp.xml | |
11 | -Libs: -r:${libdir}/mono/pw3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@/pw3270-sharp.dll |
... | ... | @@ -0,0 +1,63 @@ |
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 sample.cs 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 | +using pw3270; | |
31 | + | |
32 | +class ipc { | |
33 | + | |
34 | + static void Main(string[] args) { | |
35 | + | |
36 | + pw3270.Session host = new pw3270.Session("pw3270:A"); | |
37 | + | |
38 | + System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); | |
39 | + System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); | |
40 | + | |
41 | + // host.CharSet = "ISO-8859-1"; | |
42 | + | |
43 | + if(host.Connected) { | |
44 | + | |
45 | + System.Console.WriteLine("Connected to " + host.Url); | |
46 | + System.Console.WriteLine("Wait for ready returned " + host.WaitForReady(5)); | |
47 | + | |
48 | + // System.Console.WriteLine(host.GetStringAt(1,1,1920)); | |
49 | + System.Console.WriteLine(host.GetString(1,1920)); | |
50 | + // System.Console.WriteLine(host); | |
51 | + | |
52 | + } else { | |
53 | + | |
54 | + System.Console.WriteLine("Host is disconnected"); | |
55 | + | |
56 | + } | |
57 | + | |
58 | + System.Console.WriteLine("Error: " + host.Error); | |
59 | + | |
60 | + | |
61 | + } | |
62 | + | |
63 | +} | ... | ... |
... | ... | @@ -0,0 +1,60 @@ |
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 sample.cs 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 | +using pw3270; | |
31 | + | |
32 | +class sample { | |
33 | + | |
34 | + static void Main(string[] args) { | |
35 | + | |
36 | + pw3270.Session host = new pw3270.Session(""); | |
37 | + | |
38 | + System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); | |
39 | + System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); | |
40 | + | |
41 | + // host.Connect("tn3270://zos.efglobe.com:telnet",10); | |
42 | + host.Connect("tn3270://zos.efglobe.com:telnet",10); | |
43 | + | |
44 | + if(host.Connected) { | |
45 | + | |
46 | + System.Console.WriteLine("Connected to " + host.Url); | |
47 | + | |
48 | + System.Console.WriteLine("Wait for ready returned " + host.WaitForReady(5)); | |
49 | + | |
50 | + System.Console.WriteLine(host); | |
51 | + | |
52 | + host.Disconnect(); | |
53 | + } | |
54 | + | |
55 | + System.Console.WriteLine("Error: " + host.Error); | |
56 | + | |
57 | + | |
58 | + } | |
59 | + | |
60 | +} | ... | ... |
... | ... | @@ -0,0 +1,64 @@ |
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 simple.cs 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 | +using System; | |
31 | +using System.Collections.Generic; | |
32 | +using System.Linq; | |
33 | +using System.Text; | |
34 | +using System.Runtime.InteropServices; | |
35 | + | |
36 | +class test { | |
37 | + | |
38 | + [DllImport ("lib3270-mono")] | |
39 | + extern static IntPtr tn3270_create_session(string name); | |
40 | + | |
41 | + [DllImport ("lib3270-mono")] | |
42 | + extern static void tn3270_destroy_session(IntPtr session); | |
43 | + | |
44 | + [DllImport ("lib3270-mono")] | |
45 | + extern static void tn3270_get_version(IntPtr session, StringBuilder str, int strlen); | |
46 | + | |
47 | + [DllImport ("lib3270-mono")] | |
48 | + extern static void tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); | |
49 | + | |
50 | + static void Main(string[] args) { | |
51 | + | |
52 | + IntPtr handle = tn3270_create_session(""); | |
53 | + | |
54 | + StringBuilder str = new StringBuilder(100); | |
55 | + tn3270_get_version(handle, str, 100); | |
56 | + System.Console.WriteLine(str); | |
57 | + | |
58 | + tn3270_get_revision(handle, str, 100); | |
59 | + System.Console.WriteLine(str); | |
60 | + | |
61 | + tn3270_destroy_session(handle); | |
62 | + | |
63 | + } | |
64 | +} | ... | ... |
... | ... | @@ -0,0 +1,201 @@ |
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 vbclass.vb 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 | +Imports System | |
30 | +Imports System.Text | |
31 | +Imports System.Runtime.InteropServices | |
32 | + | |
33 | +Public Class pw3270 | |
34 | + | |
35 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
36 | + Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr | |
37 | + End Function | |
38 | + | |
39 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
40 | + Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long | |
41 | + End Function | |
42 | + | |
43 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
44 | + Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer | |
45 | + End Function | |
46 | + | |
47 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
48 | + Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer | |
49 | + End Function | |
50 | + | |
51 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
52 | + Private Shared Function tn3270_connect(ByVal hSession As IntPtr, ByVal buffer As String, ByVal seconds as Integer) as Integer | |
53 | + End Function | |
54 | + | |
55 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
56 | + Private Shared Function tn3270_is_connected(ByVal hSession As IntPtr) as Integer | |
57 | + End Function | |
58 | + | |
59 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
60 | + Private Shared Function tn3270_disconnect(ByVal hSession As IntPtr) as Integer | |
61 | + End Function | |
62 | + | |
63 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
64 | + Private Shared Function tn3270_wait_for_ready(ByVal hSession As IntPtr, ByVal seconds as Integer) as Integer | |
65 | + End Function | |
66 | + | |
67 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
68 | + Private Shared Function tn3270_wait(ByVal hSession As IntPtr, ByVal seconds as Integer) as Integer | |
69 | + End Function | |
70 | + | |
71 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
72 | + Private Shared Function tn3270_get_cstate(ByVal hSession As IntPtr) as Integer | |
73 | + End Function | |
74 | + | |
75 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
76 | + Private Shared Function tn3270_get_program_message(ByVal hSession As IntPtr) as Integer | |
77 | + End Function | |
78 | + | |
79 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
80 | + Private Shared Function tn3270_get_secure(ByVal hSession As IntPtr) as Integer | |
81 | + End Function | |
82 | + | |
83 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
84 | + Private Shared Function tn3270_get_string(ByVal hSession As IntPtr, ByVal addr as Integer, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer | |
85 | + End Function | |
86 | + | |
87 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
88 | + Private Shared Function tn3270_get_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer | |
89 | + End Function | |
90 | + | |
91 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
92 | + Private Shared Function tn3270_set_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As String) as Integer | |
93 | + End Function | |
94 | + | |
95 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
96 | + Private Shared Function tn3270_wait_for_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal key As String, ByVal timeout as Integer) as Integer | |
97 | + End Function | |
98 | + | |
99 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
100 | + Private Shared Function tn3270_cmp_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As String) as Integer | |
101 | + End Function | |
102 | + | |
103 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
104 | + Private Shared Function tn3270_set_unlock_delay(ByVal hSession As IntPtr, ByVal ms as Integer) as Integer | |
105 | + End Function | |
106 | + | |
107 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
108 | + Private Shared Function tn3270_set_cursor_position(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer) as Integer | |
109 | + End Function | |
110 | + | |
111 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
112 | + Private Shared Function tn3270_set_cursor_addr(ByVal hSession As IntPtr, ByVal addr as Integer) as Integer | |
113 | + End Function | |
114 | + | |
115 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
116 | + Private Shared Function tn3270_enter(ByVal hSession As IntPtr) as Integer | |
117 | + End Function | |
118 | + | |
119 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
120 | + Private Shared Function tn3270_pfkey(ByVal hSession As IntPtr, ByVal key as Integer) as Integer | |
121 | + End Function | |
122 | + | |
123 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
124 | + Private Shared Function tn3270_pakey(ByVal hSession As IntPtr, ByVal key as Integer) as Integer | |
125 | + End Function | |
126 | + | |
127 | + Private Shared hSession As IntPtr | |
128 | + | |
129 | + Public Sub New(ByVal name as String) | |
130 | + hSession = tn3270_create_session(name) | |
131 | + End Sub | |
132 | + | |
133 | + Public Sub Connect(ByRef url as String, ByVal seconds as Integer) | |
134 | + tn3270_connect(hSession, url, seconds) | |
135 | + End Sub | |
136 | + | |
137 | + Public Sub Disconnect() | |
138 | + tn3270_disconnect(hSession) | |
139 | + End Sub | |
140 | + | |
141 | + Public Sub Finalize() | |
142 | + tn3270_destroy_session(hSession) | |
143 | + End Sub | |
144 | + | |
145 | + Public ReadOnly Property Version As String | |
146 | + Get | |
147 | + dim buffer As New StringBuilder(1024) | |
148 | + tn3270_get_version(hSession, buffer, 1024) | |
149 | + return buffer.toString | |
150 | + End Get | |
151 | + End Property | |
152 | + | |
153 | + Public ReadOnly Property Revision As String | |
154 | + Get | |
155 | + dim buffer As New StringBuilder(1024) | |
156 | + tn3270_get_revision(hSession, buffer, 1024) | |
157 | + return buffer.toString | |
158 | + End Get | |
159 | + End Property | |
160 | + | |
161 | + Public ReadOnly Property Connected As Boolean | |
162 | + Get | |
163 | + return tn3270_is_connected(hSession) | |
164 | + End Get | |
165 | + End Property | |
166 | + | |
167 | + Public Function GetStringAt(ByVal row as Integer, ByVal col as Integer, ByVal strlen as Integer) | |
168 | + dim buffer As New StringBuilder(strlen) | |
169 | + tn3270_get_string_at(hSession, row, col, buffer, strlen) | |
170 | + return buffer.toString | |
171 | + End Function | |
172 | + | |
173 | + Public Sub WaitForReady(ByVal seconds as Integer) | |
174 | + tn3270_wait_for_ready(hSession, seconds) | |
175 | + End Sub | |
176 | + | |
177 | + | |
178 | +End Class | |
179 | + | |
180 | + | |
181 | +Public Module modmain | |
182 | + | |
183 | + Sub Main() | |
184 | + | |
185 | + dim host as new pw3270("") | |
186 | + | |
187 | + Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision) | |
188 | + | |
189 | + host.Connect("tn3270://zos.efglobe.com:telnet",10) | |
190 | + | |
191 | + if host.Connected Then | |
192 | + | |
193 | + Console.WriteLine(host.GetStringAt(14,19,38)) | |
194 | + | |
195 | + host.Disconnect() | |
196 | + End If | |
197 | + | |
198 | + End Sub | |
199 | + | |
200 | + | |
201 | +End Module | ... | ... |
... | ... | @@ -0,0 +1,56 @@ |
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 vbsample.vb 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 | +Imports System | |
30 | + | |
31 | +' This module houses the application's entry point. | |
32 | +Public Module modmain | |
33 | + | |
34 | + ' Application's entry point. | |
35 | + Sub Main() | |
36 | + | |
37 | + dim host as new pw3270.Session("") | |
38 | + | |
39 | + Console.WriteLine("Using pw3270 version " + host.getVersion() + " revision " + host.GetRevision()) | |
40 | + Console.WriteLine("Screen size is " + host.GetWidth() + "x" + host.GetHeigth()) | |
41 | + | |
42 | + host.Connect("tn3270://zos.efglobe.com:telnet",10) | |
43 | + | |
44 | + if host.IsConnected() then | |
45 | + | |
46 | + Console.WriteLine("Connected to host") | |
47 | + | |
48 | + Console.WriteLine(host.GetStringAt(14,19,38)) | |
49 | + | |
50 | + host.Disconnect() | |
51 | + | |
52 | + End If | |
53 | + | |
54 | + End Sub | |
55 | + | |
56 | +End Module | ... | ... |
... | ... | @@ -0,0 +1,49 @@ |
1 | + | |
2 | +Imports System | |
3 | +Imports System.Text | |
4 | +Imports System.Runtime.InteropServices | |
5 | + | |
6 | +' This module houses the application's entry point. | |
7 | +Public Module modmain | |
8 | + | |
9 | + | |
10 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
11 | + Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr | |
12 | + End Function | |
13 | + | |
14 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
15 | + Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long | |
16 | + End Function | |
17 | + | |
18 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
19 | + Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long | |
20 | + End Function | |
21 | + | |
22 | + <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
23 | + Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long | |
24 | + End Function | |
25 | + | |
26 | + ' Application's entry point. | |
27 | + Sub Main() | |
28 | + | |
29 | + dim host as IntPtr = tn3270_create_session("") | |
30 | + dim buffer As New StringBuilder(1024) | |
31 | + | |
32 | + ' Get library version | |
33 | + tn3270_get_version(host, buffer, 1024) | |
34 | + dim vrs as String = buffer.toString | |
35 | + | |
36 | + ' Get Library revision | |
37 | + tn3270_get_revision(host, buffer, 1024) | |
38 | + dim rev as String = buffer.toString | |
39 | + | |
40 | + ' Write text to the console. | |
41 | + Console.WriteLine ("Using pw3270 version " + vrs + " revision " + rev) | |
42 | + | |
43 | + | |
44 | + | |
45 | + tn3270_destroy_session(host) | |
46 | + | |
47 | + End Sub | |
48 | + | |
49 | +End Module | ... | ... |
testprograms/ipc.cs
... | ... | @@ -1,63 +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 sample.cs 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 | -using pw3270; | |
31 | - | |
32 | -class ipc { | |
33 | - | |
34 | - static void Main(string[] args) { | |
35 | - | |
36 | - pw3270.Session host = new pw3270.Session("pw3270:A"); | |
37 | - | |
38 | - System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); | |
39 | - System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); | |
40 | - | |
41 | - // host.CharSet = "ISO-8859-1"; | |
42 | - | |
43 | - if(host.Connected) { | |
44 | - | |
45 | - System.Console.WriteLine("Connected to " + host.Url); | |
46 | - System.Console.WriteLine("Wait for ready returned " + host.WaitForReady(5)); | |
47 | - | |
48 | - // System.Console.WriteLine(host.GetStringAt(1,1,1920)); | |
49 | - System.Console.WriteLine(host.GetString(1,1920)); | |
50 | - // System.Console.WriteLine(host); | |
51 | - | |
52 | - } else { | |
53 | - | |
54 | - System.Console.WriteLine("Host is disconnected"); | |
55 | - | |
56 | - } | |
57 | - | |
58 | - System.Console.WriteLine("Error: " + host.Error); | |
59 | - | |
60 | - | |
61 | - } | |
62 | - | |
63 | -} |
testprograms/sample.cs
... | ... | @@ -1,60 +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 sample.cs 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 | -using pw3270; | |
31 | - | |
32 | -class sample { | |
33 | - | |
34 | - static void Main(string[] args) { | |
35 | - | |
36 | - pw3270.Session host = new pw3270.Session(""); | |
37 | - | |
38 | - System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); | |
39 | - System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); | |
40 | - | |
41 | - // host.Connect("tn3270://zos.efglobe.com:telnet",10); | |
42 | - host.Connect("tn3270://zos.efglobe.com:telnet",10); | |
43 | - | |
44 | - if(host.Connected) { | |
45 | - | |
46 | - System.Console.WriteLine("Connected to " + host.Url); | |
47 | - | |
48 | - System.Console.WriteLine("Wait for ready returned " + host.WaitForReady(5)); | |
49 | - | |
50 | - System.Console.WriteLine(host); | |
51 | - | |
52 | - host.Disconnect(); | |
53 | - } | |
54 | - | |
55 | - System.Console.WriteLine("Error: " + host.Error); | |
56 | - | |
57 | - | |
58 | - } | |
59 | - | |
60 | -} |
testprograms/simple.cs
... | ... | @@ -1,64 +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 simple.cs 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 | -using System; | |
31 | -using System.Collections.Generic; | |
32 | -using System.Linq; | |
33 | -using System.Text; | |
34 | -using System.Runtime.InteropServices; | |
35 | - | |
36 | -class test { | |
37 | - | |
38 | - [DllImport ("lib3270-mono")] | |
39 | - extern static IntPtr tn3270_create_session(string name); | |
40 | - | |
41 | - [DllImport ("lib3270-mono")] | |
42 | - extern static void tn3270_destroy_session(IntPtr session); | |
43 | - | |
44 | - [DllImport ("lib3270-mono")] | |
45 | - extern static void tn3270_get_version(IntPtr session, StringBuilder str, int strlen); | |
46 | - | |
47 | - [DllImport ("lib3270-mono")] | |
48 | - extern static void tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); | |
49 | - | |
50 | - static void Main(string[] args) { | |
51 | - | |
52 | - IntPtr handle = tn3270_create_session(""); | |
53 | - | |
54 | - StringBuilder str = new StringBuilder(100); | |
55 | - tn3270_get_version(handle, str, 100); | |
56 | - System.Console.WriteLine(str); | |
57 | - | |
58 | - tn3270_get_revision(handle, str, 100); | |
59 | - System.Console.WriteLine(str); | |
60 | - | |
61 | - tn3270_destroy_session(handle); | |
62 | - | |
63 | - } | |
64 | -} |
testprograms/vbclass.vb
... | ... | @@ -1,201 +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 vbclass.vb 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 | -Imports System | |
30 | -Imports System.Text | |
31 | -Imports System.Runtime.InteropServices | |
32 | - | |
33 | -Public Class pw3270 | |
34 | - | |
35 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
36 | - Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr | |
37 | - End Function | |
38 | - | |
39 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
40 | - Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long | |
41 | - End Function | |
42 | - | |
43 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
44 | - Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer | |
45 | - End Function | |
46 | - | |
47 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
48 | - Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer | |
49 | - End Function | |
50 | - | |
51 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
52 | - Private Shared Function tn3270_connect(ByVal hSession As IntPtr, ByVal buffer As String, ByVal seconds as Integer) as Integer | |
53 | - End Function | |
54 | - | |
55 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
56 | - Private Shared Function tn3270_is_connected(ByVal hSession As IntPtr) as Integer | |
57 | - End Function | |
58 | - | |
59 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
60 | - Private Shared Function tn3270_disconnect(ByVal hSession As IntPtr) as Integer | |
61 | - End Function | |
62 | - | |
63 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
64 | - Private Shared Function tn3270_wait_for_ready(ByVal hSession As IntPtr, ByVal seconds as Integer) as Integer | |
65 | - End Function | |
66 | - | |
67 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
68 | - Private Shared Function tn3270_wait(ByVal hSession As IntPtr, ByVal seconds as Integer) as Integer | |
69 | - End Function | |
70 | - | |
71 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
72 | - Private Shared Function tn3270_get_cstate(ByVal hSession As IntPtr) as Integer | |
73 | - End Function | |
74 | - | |
75 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
76 | - Private Shared Function tn3270_get_program_message(ByVal hSession As IntPtr) as Integer | |
77 | - End Function | |
78 | - | |
79 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
80 | - Private Shared Function tn3270_get_secure(ByVal hSession As IntPtr) as Integer | |
81 | - End Function | |
82 | - | |
83 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
84 | - Private Shared Function tn3270_get_string(ByVal hSession As IntPtr, ByVal addr as Integer, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer | |
85 | - End Function | |
86 | - | |
87 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
88 | - Private Shared Function tn3270_get_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer | |
89 | - End Function | |
90 | - | |
91 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
92 | - Private Shared Function tn3270_set_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As String) as Integer | |
93 | - End Function | |
94 | - | |
95 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
96 | - Private Shared Function tn3270_wait_for_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal key As String, ByVal timeout as Integer) as Integer | |
97 | - End Function | |
98 | - | |
99 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
100 | - Private Shared Function tn3270_cmp_string_at(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer, ByVal buffer As String) as Integer | |
101 | - End Function | |
102 | - | |
103 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
104 | - Private Shared Function tn3270_set_unlock_delay(ByVal hSession As IntPtr, ByVal ms as Integer) as Integer | |
105 | - End Function | |
106 | - | |
107 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
108 | - Private Shared Function tn3270_set_cursor_position(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer) as Integer | |
109 | - End Function | |
110 | - | |
111 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
112 | - Private Shared Function tn3270_set_cursor_addr(ByVal hSession As IntPtr, ByVal addr as Integer) as Integer | |
113 | - End Function | |
114 | - | |
115 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
116 | - Private Shared Function tn3270_enter(ByVal hSession As IntPtr) as Integer | |
117 | - End Function | |
118 | - | |
119 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
120 | - Private Shared Function tn3270_pfkey(ByVal hSession As IntPtr, ByVal key as Integer) as Integer | |
121 | - End Function | |
122 | - | |
123 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
124 | - Private Shared Function tn3270_pakey(ByVal hSession As IntPtr, ByVal key as Integer) as Integer | |
125 | - End Function | |
126 | - | |
127 | - Private Shared hSession As IntPtr | |
128 | - | |
129 | - Public Sub New(ByVal name as String) | |
130 | - hSession = tn3270_create_session(name) | |
131 | - End Sub | |
132 | - | |
133 | - Public Sub Connect(ByRef url as String, ByVal seconds as Integer) | |
134 | - tn3270_connect(hSession, url, seconds) | |
135 | - End Sub | |
136 | - | |
137 | - Public Sub Disconnect() | |
138 | - tn3270_disconnect(hSession) | |
139 | - End Sub | |
140 | - | |
141 | - Public Sub Finalize() | |
142 | - tn3270_destroy_session(hSession) | |
143 | - End Sub | |
144 | - | |
145 | - Public ReadOnly Property Version As String | |
146 | - Get | |
147 | - dim buffer As New StringBuilder(1024) | |
148 | - tn3270_get_version(hSession, buffer, 1024) | |
149 | - return buffer.toString | |
150 | - End Get | |
151 | - End Property | |
152 | - | |
153 | - Public ReadOnly Property Revision As String | |
154 | - Get | |
155 | - dim buffer As New StringBuilder(1024) | |
156 | - tn3270_get_revision(hSession, buffer, 1024) | |
157 | - return buffer.toString | |
158 | - End Get | |
159 | - End Property | |
160 | - | |
161 | - Public ReadOnly Property Connected As Boolean | |
162 | - Get | |
163 | - return tn3270_is_connected(hSession) | |
164 | - End Get | |
165 | - End Property | |
166 | - | |
167 | - Public Function GetStringAt(ByVal row as Integer, ByVal col as Integer, ByVal strlen as Integer) | |
168 | - dim buffer As New StringBuilder(strlen) | |
169 | - tn3270_get_string_at(hSession, row, col, buffer, strlen) | |
170 | - return buffer.toString | |
171 | - End Function | |
172 | - | |
173 | - Public Sub WaitForReady(ByVal seconds as Integer) | |
174 | - tn3270_wait_for_ready(hSession, seconds) | |
175 | - End Sub | |
176 | - | |
177 | - | |
178 | -End Class | |
179 | - | |
180 | - | |
181 | -Public Module modmain | |
182 | - | |
183 | - Sub Main() | |
184 | - | |
185 | - dim host as new pw3270("") | |
186 | - | |
187 | - Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision) | |
188 | - | |
189 | - host.Connect("tn3270://zos.efglobe.com:telnet",10) | |
190 | - | |
191 | - if host.Connected Then | |
192 | - | |
193 | - Console.WriteLine(host.GetStringAt(14,19,38)) | |
194 | - | |
195 | - host.Disconnect() | |
196 | - End If | |
197 | - | |
198 | - End Sub | |
199 | - | |
200 | - | |
201 | -End Module |
testprograms/vbsample.vb
... | ... | @@ -1,56 +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 vbsample.vb 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 | -Imports System | |
30 | - | |
31 | -' This module houses the application's entry point. | |
32 | -Public Module modmain | |
33 | - | |
34 | - ' Application's entry point. | |
35 | - Sub Main() | |
36 | - | |
37 | - dim host as new pw3270.Session("") | |
38 | - | |
39 | - Console.WriteLine("Using pw3270 version " + host.getVersion() + " revision " + host.GetRevision()) | |
40 | - Console.WriteLine("Screen size is " + host.GetWidth() + "x" + host.GetHeigth()) | |
41 | - | |
42 | - host.Connect("tn3270://zos.efglobe.com:telnet",10) | |
43 | - | |
44 | - if host.IsConnected() then | |
45 | - | |
46 | - Console.WriteLine("Connected to host") | |
47 | - | |
48 | - Console.WriteLine(host.GetStringAt(14,19,38)) | |
49 | - | |
50 | - host.Disconnect() | |
51 | - | |
52 | - End If | |
53 | - | |
54 | - End Sub | |
55 | - | |
56 | -End Module |
testprograms/vbtest.vb
... | ... | @@ -1,49 +0,0 @@ |
1 | - | |
2 | -Imports System | |
3 | -Imports System.Text | |
4 | -Imports System.Runtime.InteropServices | |
5 | - | |
6 | -' This module houses the application's entry point. | |
7 | -Public Module modmain | |
8 | - | |
9 | - | |
10 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
11 | - Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr | |
12 | - End Function | |
13 | - | |
14 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
15 | - Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long | |
16 | - End Function | |
17 | - | |
18 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
19 | - Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long | |
20 | - End Function | |
21 | - | |
22 | - <DllImport("lib3270-mono", CallingConvention := CallingConvention.Cdecl)> _ | |
23 | - Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long | |
24 | - End Function | |
25 | - | |
26 | - ' Application's entry point. | |
27 | - Sub Main() | |
28 | - | |
29 | - dim host as IntPtr = tn3270_create_session("") | |
30 | - dim buffer As New StringBuilder(1024) | |
31 | - | |
32 | - ' Get library version | |
33 | - tn3270_get_version(host, buffer, 1024) | |
34 | - dim vrs as String = buffer.toString | |
35 | - | |
36 | - ' Get Library revision | |
37 | - tn3270_get_revision(host, buffer, 1024) | |
38 | - dim rev as String = buffer.toString | |
39 | - | |
40 | - ' Write text to the console. | |
41 | - Console.WriteLine ("Using pw3270 version " + vrs + " revision " + rev) | |
42 | - | |
43 | - | |
44 | - | |
45 | - tn3270_destroy_session(host) | |
46 | - | |
47 | - End Sub | |
48 | - | |
49 | -End Module |