Commit 0a83cefaa63a05ee7e696263b279b4c2294c7c19

Authored by Perry Werneck
1 parent 445fb1d5
Exists in master

Refactoring .NET module.

@@ -24,8 +24,8 @@ @@ -24,8 +24,8 @@
24 # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) 24 # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
25 # 25 #
26 26
27 -GLUELIB=lib3270-mono@DLLEXT@  
28 -LIBNAME=pw3270-sharp.dll 27 +GLUELIB=@NATIVE_SONAME@
  28 +LIBNAME=tn3270-sharp.dll
29 TESTPROGRAM?=sample 29 TESTPROGRAM?=sample
30 30
31 #---[ Configuration values ]------------------------------------------------------------- 31 #---[ Configuration values ]-------------------------------------------------------------
@@ -67,181 +67,42 @@ RPMBUILD=@RPMBUILD@ @@ -67,181 +67,42 @@ RPMBUILD=@RPMBUILD@
67 #---[ Rules ]---------------------------------------------------------------------------- 67 #---[ Rules ]----------------------------------------------------------------------------
68 68
69 $(BINDBG)/%.exe: \ 69 $(BINDBG)/%.exe: \
70 - testprograms/%.cs \ 70 + src/testprograms/%.cs \
71 $(BINDBG)/$(LIBNAME) 71 $(BINDBG)/$(LIBNAME)
72 72
73 @$(MCS) -reference:$(BINDBG)/$(LIBNAME) -debug -out:$@ $< 73 @$(MCS) -reference:$(BINDBG)/$(LIBNAME) -debug -out:$@ $<
74 74
75 $(BINDBG)/%.exe: \ 75 $(BINDBG)/%.exe: \
76 - testprograms/%.vb \ 76 + src/testprograms/%.vb \
77 $(BINDBG)/$(LIBNAME) 77 $(BINDBG)/$(LIBNAME)
78 78
79 @$(VBNC) -reference:$(BINDBG)/$(LIBNAME) -debug -out:$@ $< 79 @$(VBNC) -reference:$(BINDBG)/$(LIBNAME) -debug -out:$@ $<
80 80
81 -$(BINRLS)/%.exe: \  
82 - testprograms/%.cs 81 +#---[ Debug Targets ]--------------------------------------------------------------------
83 82
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 -install-%: \  
101 - src/%/Makefile \  
102 - all  
103 -  
104 - @make -C `dirname $<` DESTDIR=$(DESTDIR) install  
105 -  
106 -#---[ Targets ]--------------------------------------------------------------------------  
107 -  
108 -all: \  
109 - $(BINRLS)/$(GLUELIB) \  
110 - $(BINRLS)/$(LIBNAME)  
111 -  
112 -install: \  
113 - install-native \  
114 - install-pw3270-sharp  
115 -  
116 -  
117 -Release: \  
118 - $(BINRLS)/$(GLUELIB) \  
119 - $(BINRLS)/$(LIBNAME)  
120 -  
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 83 +Debug: \
  84 + $(BINDBG)/$(LIBNAME)
205 85
206 86
207 -$(BINRLS)/$(GLUELIB): \  
208 - src/native/*.cc \  
209 - src/native/*.h \  
210 - src/include/*.h 87 +$(BINDBG)/$(GLUELIB): \
  88 + src/native/* \
  89 + src/native/core/*
211 90
212 @make -C src/native $@ 91 @make -C src/native $@
213 92
214 -$(BINRLS)/$(LIBNAME): \  
215 - src/pw3270-sharp/*.cs \  
216 - src/include/*.h  
217 -  
218 - @make -C src/pw3270-sharp $@  
219 -  
220 -Debug: \  
221 - $(BINDBG)/$(GLUELIB) \  
222 - $(BINDBG)/$(LIBNAME) \  
223 - $(BINDBG)/sample.exe  
224 -  
225 -  
226 -run: \ 93 +$(BINDBG)/$(LIBNAME): \
227 $(BINDBG)/$(GLUELIB) \ 94 $(BINDBG)/$(GLUELIB) \
228 - $(BINDBG)/$(LIBNAME) \  
229 - $(BINDBG)/$(TESTPROGRAM).exe 95 + src/core/*
230 96
231 - @$(MONO) $(BINDBG)/$(TESTPROGRAM).exe 97 + @make -C src/core $@
232 98
233 -$(BINDBG)/$(GLUELIB): \  
234 - src/native/*.cc \  
235 - src/native/*.h \  
236 - src/include/*.h 99 +#---[ Test targets ]---------------------------------------------------------------------
237 100
238 - @make -C src/native $@ 101 +ipc-test: \
  102 + $(BINDBG)/ipc.exe
239 103
240 -$(BINDBG)/$(LIBNAME): \  
241 - src/pw3270-sharp/*.cs \  
242 - src/include/*.h  
243 104
244 - @make -C src/pw3270-sharp $@ 105 +#---[ Clean Targets ]--------------------------------------------------------------------
245 106
246 cleanDebug: \ 107 cleanDebug: \
247 clean 108 clean
@@ -127,6 +127,10 @@ dnl --------------------------------------------------------------------------- @@ -127,6 +127,10 @@ dnl ---------------------------------------------------------------------------
127 AC_PATH_TOOL([AR], [ar], [ar]) 127 AC_PATH_TOOL([AR], [ar], [ar])
128 AC_PATH_TOOL([WINDRES], [windres], [no]) 128 AC_PATH_TOOL([WINDRES], [windres], [no])
129 AC_PATH_TOOL([VALGRIND], [valgrind], [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])
130 134
131 PKG_CHECK_EXISTS 135 PKG_CHECK_EXISTS
132 136
@@ -287,10 +291,10 @@ dnl --------------------------------------------------------------------------- @@ -287,10 +291,10 @@ dnl ---------------------------------------------------------------------------
287 dnl Configure which files to generate. 291 dnl Configure which files to generate.
288 dnl --------------------------------------------------------------------------- 292 dnl ---------------------------------------------------------------------------
289 293
290 -dnl AC_CONFIG_FILES(Makefile) 294 +AC_CONFIG_FILES(Makefile)
291 AC_CONFIG_FILES(src/native/Makefile) 295 AC_CONFIG_FILES(src/native/Makefile)
292 -dnl AC_CONFIG_FILES(src/pw3270-sharp/Makefile)  
293 -dnl 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)
294 298
295 dnl --------------------------------------------------------------------------- 299 dnl ---------------------------------------------------------------------------
296 dnl Output the generated config.status script. 300 dnl Output the generated config.status script.
src/core/Makefile.in 0 → 100644
@@ -0,0 +1,108 @@ @@ -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 +
src/core/tn3270-sharp.cs 0 → 100644
@@ -0,0 +1,618 @@ @@ -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 +}
src/core/tn3270-sharp.pc.in 0 → 100644
@@ -0,0 +1,11 @@ @@ -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: .BET 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/pw3270-sharp/Makefile.in
@@ -1,108 +0,0 @@ @@ -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,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,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  
src/testprograms/ipc.cs 0 → 100644
@@ -0,0 +1,63 @@ @@ -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 +}
src/testprograms/sample.cs 0 → 100644
@@ -0,0 +1,60 @@ @@ -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 +}
src/testprograms/simple.cs 0 → 100644
@@ -0,0 +1,64 @@ @@ -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 +}
src/testprograms/vbclass.vb 0 → 100644
@@ -0,0 +1,201 @@ @@ -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
src/testprograms/vbsample.vb 0 → 100644
@@ -0,0 +1,56 @@ @@ -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
src/testprograms/vbtest.vb 0 → 100644
@@ -0,0 +1,49 @@ @@ -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,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,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,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,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,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,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