diff --git a/Makefile.in b/Makefile.in index 210ccee..297a540 100644 --- a/Makefile.in +++ b/Makefile.in @@ -24,8 +24,8 @@ # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) # -GLUELIB=lib3270-mono@DLLEXT@ -LIBNAME=pw3270-sharp.dll +GLUELIB=@NATIVE_SONAME@ +LIBNAME=tn3270-sharp.dll TESTPROGRAM?=sample #---[ Configuration values ]------------------------------------------------------------- @@ -67,181 +67,42 @@ RPMBUILD=@RPMBUILD@ #---[ Rules ]---------------------------------------------------------------------------- $(BINDBG)/%.exe: \ - testprograms/%.cs \ + src/testprograms/%.cs \ $(BINDBG)/$(LIBNAME) @$(MCS) -reference:$(BINDBG)/$(LIBNAME) -debug -out:$@ $< $(BINDBG)/%.exe: \ - testprograms/%.vb \ + src/testprograms/%.vb \ $(BINDBG)/$(LIBNAME) @$(VBNC) -reference:$(BINDBG)/$(LIBNAME) -debug -out:$@ $< -$(BINRLS)/%.exe: \ - testprograms/%.cs +#---[ Debug Targets ]-------------------------------------------------------------------- - @$(MCS) -reference:$(BINRLS)/$(LIBNAME) -out:$@ $< - -%.tar.bz2: \ - %.tar - - @echo $< ... - @bzip2 --compress -9 --stdout $< > $@ - @chmod 0644 $@ - -%.tar.gz: \ - %.tar - - @echo $< ... - @gzip -9 --stdout $< > $@ - @chmod 0644 $@ - -install-%: \ - src/%/Makefile \ - all - - @make -C `dirname $<` DESTDIR=$(DESTDIR) install - -#---[ Targets ]-------------------------------------------------------------------------- - -all: \ - $(BINRLS)/$(GLUELIB) \ - $(BINRLS)/$(LIBNAME) - -install: \ - install-native \ - install-pw3270-sharp - - -Release: \ - $(BINRLS)/$(GLUELIB) \ - $(BINRLS)/$(LIBNAME) - -zip: \ - @ZIPNAME@-@PACKAGE_VERSION@.@host@.zip - -@ZIPNAME@-@PACKAGE_VERSION@.@host@.zip: \ - $(BINRLS)/$(GLUELIB) \ - $(BINRLS)/$(LIBNAME) \ - $(BINRLS)/sample.exe - - @zip -9 -j $@ \ - $(BINRLS)/$(GLUELIB) \ - $(BINRLS)/$(LIBNAME) \ - $(BINRLS)/*.xml \ - testprograms/sample.cs \ - testprograms/vbsample.vb \ - src/pw3270-sharp/pw3270-sharp.cs \ - $(BINRLS)/sample.exe - -rpm: \ - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 - -ifneq ($(RPMBUILD),no) - @$(MKDIR) $(BASEDIR)/rpm - @$(MKDIR) $(BASEDIR)/rpm/SPECS - @$(MKDIR) $(BASEDIR)/rpm/SOURCES - @$(MKDIR) $(BASEDIR)/rpm/SRPMS - @$(MKDIR) $(BASEDIR)/rpm/RPMS - @$(MKDIR) $(BASEDIR)/rpm/BUILD - @$(MKDIR) $(BASEDIR)/rpm/BUILDROOT - @umask 002 ; $(RPMBUILD) \ - --define="_topdir $(BASEDIR)/rpm" \ - --define="_packager $(USER)@$(HOSTNAME)" \ - --clean \ - -ta $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 -endif - -bz2: \ - $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.bz2 - -$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar: \ - $(SRCDIR) - - @$(AMTAR) \ - --verbose \ - --format=ustar \ - --create \ - --exclude-vcs \ - --directory $(BASEDIR)/.src \ - --owner=root \ - --group=root \ - --file=$@ \ - $(PACKAGE_TARNAME)-@PACKAGE_VERSION@ - - -$(SRCDIR): \ - clean - - @$(MKDIR) $(SRCDIR) - @cp *.ac $(SRCDIR) - @cp *.in $(SRCDIR) - @cp *.cbp $(SRCDIR) - @cp *.sh $(SRCDIR) - @cp rpm/*.spec $(SRCDIR) - @cp README.md $(SRCDIR) - @cp LICENCA $(SRCDIR) - @cp LICENSE $(SRCDIR) - @cp AUTHORS $(SRCDIR) - - @$(MKDIR) $(SRCDIR)/testprograms - @cp testprograms/* $(SRCDIR)/testprograms - - @$(MKDIR) $(SRCDIR)/scripts - @cp scripts/* $(SRCDIR)/scripts - - @$(MKDIR) $(SRCDIR)/src/include - @cp src/include/*.in $(SRCDIR)/src/include - - @$(MKDIR) $(SRCDIR)/src/native - @cp src/native/*.in $(SRCDIR)/src/native - @cp src/native/*.cc $(SRCDIR)/src/native - @cp src/native/*.h $(SRCDIR)/src/native - - @$(MKDIR) $(SRCDIR)/src/pw3270-sharp - @cp src/pw3270-sharp/*.in $(SRCDIR)/src/pw3270-sharp - @cp src/pw3270-sharp/*.cs $(SRCDIR)/src/pw3270-sharp +Debug: \ + $(BINDBG)/$(LIBNAME) -$(BINRLS)/$(GLUELIB): \ - src/native/*.cc \ - src/native/*.h \ - src/include/*.h +$(BINDBG)/$(GLUELIB): \ + src/native/* \ + src/native/core/* @make -C src/native $@ -$(BINRLS)/$(LIBNAME): \ - src/pw3270-sharp/*.cs \ - src/include/*.h - - @make -C src/pw3270-sharp $@ - -Debug: \ - $(BINDBG)/$(GLUELIB) \ - $(BINDBG)/$(LIBNAME) \ - $(BINDBG)/sample.exe - - -run: \ +$(BINDBG)/$(LIBNAME): \ $(BINDBG)/$(GLUELIB) \ - $(BINDBG)/$(LIBNAME) \ - $(BINDBG)/$(TESTPROGRAM).exe + src/core/* - @$(MONO) $(BINDBG)/$(TESTPROGRAM).exe + @make -C src/core $@ -$(BINDBG)/$(GLUELIB): \ - src/native/*.cc \ - src/native/*.h \ - src/include/*.h +#---[ Test targets ]--------------------------------------------------------------------- - @make -C src/native $@ +ipc-test: \ + $(BINDBG)/ipc.exe -$(BINDBG)/$(LIBNAME): \ - src/pw3270-sharp/*.cs \ - src/include/*.h - @make -C src/pw3270-sharp $@ +#---[ Clean Targets ]-------------------------------------------------------------------- cleanDebug: \ clean diff --git a/configure.ac b/configure.ac index 5e71d14..f7190bb 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,10 @@ dnl --------------------------------------------------------------------------- AC_PATH_TOOL([AR], [ar], [ar]) AC_PATH_TOOL([WINDRES], [windres], [no]) AC_PATH_TOOL([VALGRIND], [valgrind], [no]) +AC_PATH_TOOL([MCS], [mcs], [no]) +AC_PATH_TOOL([GACUTIL], [gacutil], [no]) +AC_PATH_TOOL([SN], [sn], [no]) +AC_PATH_TOOL([VBNC], [vbnc], [no]) PKG_CHECK_EXISTS @@ -287,10 +291,10 @@ dnl --------------------------------------------------------------------------- dnl Configure which files to generate. dnl --------------------------------------------------------------------------- -dnl AC_CONFIG_FILES(Makefile) +AC_CONFIG_FILES(Makefile) AC_CONFIG_FILES(src/native/Makefile) -dnl AC_CONFIG_FILES(src/pw3270-sharp/Makefile) -dnl AC_CONFIG_FILES(src/pw3270-sharp/pw3270-sharp.pc) +AC_CONFIG_FILES(src/core/Makefile) +AC_CONFIG_FILES(src/core/tn3270-sharp.pc) dnl --------------------------------------------------------------------------- dnl Output the generated config.status script. diff --git a/src/core/Makefile.in b/src/core/Makefile.in new file mode 100644 index 0000000..2965a4e --- /dev/null +++ b/src/core/Makefile.in @@ -0,0 +1,108 @@ +# +# "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 +# (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a +# aplicativos mainframe. Registro no INPI sob o nome G3270. +# +# Copyright (C) <2008> +# +# Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob +# os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela +# Free Software Foundation. +# +# Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER +# GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO +# A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para +# obter mais detalhes. +# +# Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este +# programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA, 02111-1307, USA +# +# Contatos: +# +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) +# + +MODULE_NAME=tn3270-sharp + +SOURCES=$(MODULE_NAME).cs +LIBNAME=$(MODULE_NAME).dll + +#---[ Configuration values ]------------------------------------------------------------- + +PACKAGE_NAME=@PACKAGE_NAME@ +PACKAGE_VERSION=@PACKAGE_VERSION@ +PACKAGE_TARNAME=@PACKAGE_TARNAME@ + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +sbindir=@sbindir@ +libdir=@libdir@ + +BASEDIR=@BASEDIR@ +SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) + +OBJDIR=$(BASEDIR)/.obj +OBJDBG=$(OBJDIR)/Debug +OBJRLS=$(OBJDIR)/Release + +BINDIR=$(BASEDIR)/.bin +BINDBG=$(BINDIR)/Debug +BINRLS=$(BINDIR)/Release + +INSTALL=@INSTALL@ +INSTALL_DATA=@INSTALL_DATA@ +INSTALL_PROGRAM=@INSTALL_PROGRAM@ + +LN_S=@LN_S@ + +MCS=@MCS@ +MKDIR=@MKDIR_P@ +GACUTIL=@GACUTIL@ +SN=@SN@ + +#---[ Targets ]-------------------------------------------------------------------------- + +all: \ + $(BINRLS)/$(LIBNAME) + +Release: \ + $(BINRLS)/$(LIBNAME) + +install: \ + $(BINRLS)/$(LIBNAME) + + @$(GACUTIL) -i $(BINRLS)/$(LIBNAME) -root $(DESTDIR)/usr/lib + + @$(MKDIR) $(DESTDIR)/usr/share/gapi-2.0/$(MODULE_NAME) + @$(INSTALL_DATA) $(BINRLS)/$(MODULE_NAME).xml $(DESTDIR)/usr/share/gapi-2.0/$(MODULE_NAME) + + @$(MKDIR) $(DESTDIR)/usr/lib/mono/$(MODULE_NAME)-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ + @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)/usr/lib/mono/$(MODULE_NAME)-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ + + @$(MKDIR) $(DESTDIR)/$(libdir)/pkgconfig + @$(INSTALL_DATA) $(MODULE_NAME).pc $(DESTDIR)/$(libdir)/pkgconfig + +Debug: \ + $(BINDBG)/$(LIBNAME) + +$(BINRLS)/$(MODULE_NAME).key: + + @$(SN) -k $@ + +$(BINDBG)/$(LIBNAME): \ + $(SOURCES) + + @$(MKDIR) `dirname $@` + @$(MCS) -debug -target:library -out:$@ $< + +$(BINRLS)/$(LIBNAME): \ + $(SOURCES) \ + $(BINRLS)/$(MODULE_NAME).key + + @$(MKDIR) `dirname $@` + @$(MCS) -doc:$(BINRLS)/$(MODULE_NAME).xml -keyfile:$(BINRLS)/$(MODULE_NAME).key -target:library -out:$@ $(SOURCES) + + diff --git a/src/core/tn3270-sharp.cs b/src/core/tn3270-sharp.cs new file mode 100644 index 0000000..df7d9f9 --- /dev/null +++ b/src/core/tn3270-sharp.cs @@ -0,0 +1,618 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como tn3270-sharp.cs e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + * Referências: + * + * https://msdn.microsoft.com/en-us/library/5ast78ax.aspx + * + */ + +using System; +using System.Text; +using System.Runtime.InteropServices; + +namespace pw3270 { + + /// + /// Session with 3270 HOST. + /// + public class Session { + + /// + /// lib3270 session handle + /// + private IntPtr hSession; + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static IntPtr tn3270_create_session(string name); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_destroy_session(IntPtr session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_version(IntPtr session, StringBuilder str, int strlen); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_connect(IntPtr Session, string host, int wait); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_is_connected(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_is_ready(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_disconnect(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_wait_for_ready(IntPtr Session, int seconds); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_wait(IntPtr Session, int seconds); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_cstate(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_program_message(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_secure(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_contents(IntPtr Session, StringBuilder str, int strlen); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_string(IntPtr Session, int addr, StringBuilder str, int strlen); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_string_at(IntPtr Session, int row, int col, StringBuilder str, int strlen); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_set_string_at(IntPtr Session, int row, int col, string str); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_wait_for_string_at(IntPtr Session, int row, int col, string key, int timeout); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_cmp_string_at(IntPtr Session, int row, int col, string str); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_set_unlock_delay(IntPtr Session, int ms); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_set_cursor_position(IntPtr Session, int row, int col); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_set_cursor_addr(IntPtr Session, int addr); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_cursor_addr(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_enter(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_pfkey(IntPtr Session, int key); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_pakey(IntPtr Session, int key); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_width(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_height(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_length(IntPtr Session); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_set_charset(IntPtr Session, string str); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_set_url(IntPtr Session, string str); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_url(IntPtr Session, StringBuilder str, int strlen); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_set_error_message(IntPtr Session, string str); + + [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] + extern static int tn3270_get_error_message(IntPtr Session, StringBuilder str, int strlen); + + /// + /// Create a new session with lib3270/pw3270 + /// + /// + /// Session name or empty string for a hidden session + /// + public Session(string name) { + hSession = tn3270_create_session(name); + tn3270_set_charset(hSession,"UTF-8"); + } + + /// + /// Disconnect from host, destroy session. + /// + /// + ~Session() { + tn3270_destroy_session(hSession); + } + + /// + /// Get lib3270/pw3270 Version identifier + /// + /// + /// + /// The version of the active instance. + /// + /// + public string GetVersion() { + StringBuilder str = new StringBuilder(10); + tn3270_get_version(hSession, str, 10); + return str.ToString(); + } + + /// + /// Lib3270 version. + /// + /// + /// + /// Lib3270 version string + /// + /// + public string Version { + get { + return GetVersion(); + } + } + + /// + /// Get lib3270/pw3270 Revision number + /// + /// + /// + /// The revision of the active instance. + /// + /// + public string GetRevision() { + StringBuilder str = new StringBuilder(10); + tn3270_get_revision(hSession, str, 10); + return str.ToString(); + } + + public string Revision { + get { + return GetRevision(); + } + } + + /// + /// Connect to 3270 host. + /// + /// + /// URL of the target host (tn3270://hostname:port) + /// How many seconds should the call wait for the connection becomes ready + /// + /// + /// + /// + public int Connect(string host, int wait) { + return tn3270_connect(hSession, host, wait); + } + + /// + /// Get connection state + /// + /// + /// + /// true if the session is connected to a remote host. + /// + /// + public bool IsConnected() { + return tn3270_is_connected(hSession) != 0; + } + + public bool Connected { + get { + return tn3270_is_connected(hSession) != 0; + } + } + + public bool IsReady() { + return tn3270_is_ready(hSession) != 0; + } + + public bool Ready { + get { + return tn3270_is_ready(hSession) != 0; + } + } + + /// + /// Disconnect from 3270 host. + /// + /// + public int Disconnect() { + return tn3270_disconnect(hSession); + } + + /// + /// Wait for network activity + /// + /// + /// Seconds to wait + /// + /// + /// + /// + /// + public int WaitForReady(int seconds) { + return tn3270_wait_for_ready(hSession, seconds); + } + + /// + /// "Sleep" keeping the network activity. + /// + /// + /// Number of seconds to wait + /// + /// + /// + /// + /// + public int Wait(int seconds) { + return tn3270_wait(hSession, seconds); + } + + /// + /// Get contents + /// + /// + /// + /// Contents from terminal screen. + /// + /// + public override string ToString() { + int strlen = (tn3270_get_width(hSession)+1) * (tn3270_get_height(hSession)+1); + StringBuilder str = new StringBuilder(strlen+1); + strlen = tn3270_get_contents(hSession, str, strlen); + return str.ToString(); + } + + + /// + /// Get contents at address + /// + /// + /// Address of text in the screen buffer + /// Number of characters to get + /// + /// + /// Contents from terminal screen. + /// + /// + public string GetString(int addr, int strlen) { + StringBuilder str = new StringBuilder(strlen+1); + tn3270_get_string(hSession, addr, str, strlen); + return str.ToString(); + } + + /// + /// Get contents at position. + /// + /// + /// Start row + /// Start col + /// Number of characters to get + /// + /// + /// Contents from terminal screen. + /// + /// + public string GetStringAt(int row, int col, int strlen) { + StringBuilder str = new StringBuilder(strlen+1); + tn3270_get_string_at(hSession, row, col, str, strlen); + return str.ToString(); + } + + /// + /// Set contents at position + /// + /// + /// Start row + /// Start col + /// Text to set + /// + public void SetStringAt(int row, int col, string str) { + tn3270_set_string_at(hSession, row, col, str); + } + + /// + /// Wait for text at position. + /// + /// + /// Start row + /// Start col + /// Text to wait + /// Seconds to wait + /// + /// + /// + /// + /// + public int WaitForStringAt(int row, int col, string str, int timeout) { + return tn3270_wait_for_string_at(hSession, row, col, str, timeout); + } + + /// + /// Compare contents at position + /// + /// + /// Start row + /// Start col + /// Text to compare + /// + /// + /// Result (0 = The strings are the same). + /// + /// + public int CmpStringAt(int row, int col, string str) { + return tn3270_cmp_string_at(hSession, row, col, str); + } + + /// + /// Set cursor position. + /// + /// + /// New cursor row + /// New cursor column + /// + public void SetCursorPosition(int row, int col) { + tn3270_set_cursor_position(hSession, row, col); + } + + /// + /// Set cursor position based on address. + /// + /// + /// Address of the new cursor position + /// + public void SetCursorPosition(int addr) { + tn3270_set_cursor_addr(hSession, addr); + } + + /// + /// Get cursor address + /// + /// + public int GetCursorPosition() { + return tn3270_get_cursor_addr(hSession); + } + + /// + /// Cursor address + /// + /// + public int CursorPosition { + set { + tn3270_set_cursor_addr(hSession, value); + } + get { + return tn3270_get_cursor_addr(hSession); + } + } + + /// + /// Set the "screen ready" delay + /// + /// + public int SetUnlockDelay(int ms) { + return tn3270_set_unlock_delay(hSession, ms); + } + + /// + /// Set the "screen ready" delay + /// + /// + public int UnlockDelay { + set { + tn3270_set_unlock_delay(hSession, value); + } + } + + + /// + /// Send "Enter" key + /// + /// + /// + /// + /// + /// + public int Enter() { + return tn3270_enter(hSession); + } + + /// + /// Send "PF" key + /// + /// + /// Key identifier 1=PF1, 2=PF2, ... + /// + /// + /// + /// + /// + public int PfKey(int key) { + return tn3270_pfkey(hSession, key); + } + + /// + /// Send "PA" key + /// + /// + /// Key identifier 1=PA1, 2=PA2, ... + /// + /// + /// + /// + /// + public int PaKey(int key) { + return tn3270_pakey(hSession, key); + } + + /// + /// Get screen width + /// + /// + /// + /// Screen width in characters (negative on error) + /// + /// + public int GetWidth() { + return tn3270_get_width(hSession); + } + + /// + /// Screen width in characters + /// + /// + /// + /// Screen width in characters (negative on error) + /// + /// + public int Width { + get { + return tn3270_get_width(hSession); + } + } + + /// + /// Get screen height + /// + /// + /// + /// Screen width in characters (negative on error) + /// + /// + public int GetHeight() { + return tn3270_get_height(hSession); + } + + /// + /// Screen height in characters + /// + /// + /// + /// Screen height in characters (negative on error) + /// + /// + public int Height { + get { + return tn3270_get_height(hSession); + } + } + + /// + /// Get length of terminal buffer (width * height) + /// + /// + /// + /// Terminal length in characters (negative on error) + /// + /// + public int GetLength() { + return tn3270_get_length(hSession); + } + + /// + /// Length of terminal buffer (width * height) + /// + /// + /// + /// Terminal length in characters (negative on error) + /// + /// + public int Length { + get { + return tn3270_get_length(hSession); + } + } + + public string CharSet { + set { + tn3270_set_charset(hSession,value); + } + } + + /// + /// 3270 host URL + /// + /// + /// + /// 3270 host URL + /// + /// + public string Url { + set { + tn3270_set_url(hSession,value); + } + get { + StringBuilder str = new StringBuilder(1025); + tn3270_get_url(hSession, str, 1024); + return str.ToString(); + } + } + + /// + /// Last lib3270 error message + /// + /// + /// + /// Last lib3270 error message + /// + /// + public string Error { + set { + tn3270_set_error_message(hSession,value); + } + get { + StringBuilder str = new StringBuilder(1025); + tn3270_get_error_message(hSession, str, 1024); + return str.ToString(); + } + } + + } + +} diff --git a/src/core/tn3270-sharp.pc.in b/src/core/tn3270-sharp.pc.in new file mode 100644 index 0000000..a728ed7 --- /dev/null +++ b/src/core/tn3270-sharp.pc.in @@ -0,0 +1,11 @@ +prefix=${pcfiledir}/../.. +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +gapidir=${prefix}/share/tn3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ + + +Name: tn3270-sharp +Description: .BET Bindings for pw3270 +Version: @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ +Cflags: -I:${gapidir}/tn3270-sharp.xml +Libs: -r:${libdir}/mono/tn3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@/tn3270-sharp.dll diff --git a/src/pw3270-sharp/Makefile.in b/src/pw3270-sharp/Makefile.in deleted file mode 100644 index 21b3205..0000000 --- a/src/pw3270-sharp/Makefile.in +++ /dev/null @@ -1,108 +0,0 @@ -# -# "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 -# (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a -# aplicativos mainframe. Registro no INPI sob o nome G3270. -# -# Copyright (C) <2008> -# -# Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob -# os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela -# Free Software Foundation. -# -# Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER -# GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO -# A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para -# obter mais detalhes. -# -# Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este -# programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple -# Place, Suite 330, Boston, MA, 02111-1307, USA -# -# Contatos: -# -# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) -# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) -# - -MODULE_NAME=pw3270-sharp - -SOURCES=$(MODULE_NAME).cs -LIBNAME=$(MODULE_NAME).dll - -#---[ Configuration values ]------------------------------------------------------------- - -PACKAGE_NAME=@PACKAGE_NAME@ -PACKAGE_VERSION=@PACKAGE_VERSION@ -PACKAGE_TARNAME=@PACKAGE_TARNAME@ - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -sbindir=@sbindir@ -libdir=@libdir@ - -BASEDIR=@BASEDIR@ -SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) - -OBJDIR=$(BASEDIR)/.obj -OBJDBG=$(OBJDIR)/Debug -OBJRLS=$(OBJDIR)/Release - -BINDIR=$(BASEDIR)/.bin -BINDBG=$(BINDIR)/Debug -BINRLS=$(BINDIR)/Release - -INSTALL=@INSTALL@ -INSTALL_DATA=@INSTALL_DATA@ -INSTALL_PROGRAM=@INSTALL_PROGRAM@ - -LN_S=@LN_S@ - -MCS=@MCS@ -MKDIR=@MKDIR_P@ -GACUTIL=@GACUTIL@ -SN=@SN@ - -#---[ Targets ]-------------------------------------------------------------------------- - -all: \ - $(BINRLS)/$(LIBNAME) - -Release: \ - $(BINRLS)/$(LIBNAME) - -install: \ - $(BINRLS)/$(LIBNAME) - - @$(GACUTIL) -i $(BINRLS)/$(LIBNAME) -root $(DESTDIR)/usr/lib - - @$(MKDIR) $(DESTDIR)/usr/share/gapi-2.0/$(MODULE_NAME) - @$(INSTALL_DATA) $(BINRLS)/$(MODULE_NAME).xml $(DESTDIR)/usr/share/gapi-2.0/$(MODULE_NAME) - - @$(MKDIR) $(DESTDIR)/usr/lib/mono/$(MODULE_NAME)-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ - @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)/usr/lib/mono/$(MODULE_NAME)-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ - - @$(MKDIR) $(DESTDIR)/$(libdir)/pkgconfig - @$(INSTALL_DATA) $(MODULE_NAME).pc $(DESTDIR)/$(libdir)/pkgconfig - -Debug: \ - $(BINDBG)/$(LIBNAME) - -$(BINRLS)/$(MODULE_NAME).key: - - @$(SN) -k $@ - -$(BINDBG)/$(LIBNAME): \ - $(SOURCES) - - @$(MKDIR) `dirname $@` - @$(MCS) -debug -target:library -out:$@ $< - -$(BINRLS)/$(LIBNAME): \ - $(SOURCES) \ - $(BINRLS)/$(MODULE_NAME).key - - @$(MKDIR) `dirname $@` - @$(MCS) -doc:$(BINRLS)/$(MODULE_NAME).xml -keyfile:$(BINRLS)/$(MODULE_NAME).key -target:library -out:$@ $(SOURCES) - - diff --git a/src/pw3270-sharp/pw3270-sharp.cs b/src/pw3270-sharp/pw3270-sharp.cs deleted file mode 100644 index df7d9f9..0000000 --- a/src/pw3270-sharp/pw3270-sharp.cs +++ /dev/null @@ -1,618 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como tn3270-sharp.cs e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - * Referências: - * - * https://msdn.microsoft.com/en-us/library/5ast78ax.aspx - * - */ - -using System; -using System.Text; -using System.Runtime.InteropServices; - -namespace pw3270 { - - /// - /// Session with 3270 HOST. - /// - public class Session { - - /// - /// lib3270 session handle - /// - private IntPtr hSession; - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static IntPtr tn3270_create_session(string name); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_destroy_session(IntPtr session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_version(IntPtr session, StringBuilder str, int strlen); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_connect(IntPtr Session, string host, int wait); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_is_connected(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_is_ready(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_disconnect(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_wait_for_ready(IntPtr Session, int seconds); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_wait(IntPtr Session, int seconds); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_cstate(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_program_message(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_secure(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_contents(IntPtr Session, StringBuilder str, int strlen); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_string(IntPtr Session, int addr, StringBuilder str, int strlen); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_string_at(IntPtr Session, int row, int col, StringBuilder str, int strlen); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_set_string_at(IntPtr Session, int row, int col, string str); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_wait_for_string_at(IntPtr Session, int row, int col, string key, int timeout); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_cmp_string_at(IntPtr Session, int row, int col, string str); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_set_unlock_delay(IntPtr Session, int ms); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_set_cursor_position(IntPtr Session, int row, int col); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_set_cursor_addr(IntPtr Session, int addr); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_cursor_addr(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_enter(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_pfkey(IntPtr Session, int key); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_pakey(IntPtr Session, int key); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_width(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_height(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_length(IntPtr Session); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_set_charset(IntPtr Session, string str); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_set_url(IntPtr Session, string str); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_url(IntPtr Session, StringBuilder str, int strlen); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_set_error_message(IntPtr Session, string str); - - [DllImport ("lib3270-mono",CallingConvention=CallingConvention.Cdecl)] - extern static int tn3270_get_error_message(IntPtr Session, StringBuilder str, int strlen); - - /// - /// Create a new session with lib3270/pw3270 - /// - /// - /// Session name or empty string for a hidden session - /// - public Session(string name) { - hSession = tn3270_create_session(name); - tn3270_set_charset(hSession,"UTF-8"); - } - - /// - /// Disconnect from host, destroy session. - /// - /// - ~Session() { - tn3270_destroy_session(hSession); - } - - /// - /// Get lib3270/pw3270 Version identifier - /// - /// - /// - /// The version of the active instance. - /// - /// - public string GetVersion() { - StringBuilder str = new StringBuilder(10); - tn3270_get_version(hSession, str, 10); - return str.ToString(); - } - - /// - /// Lib3270 version. - /// - /// - /// - /// Lib3270 version string - /// - /// - public string Version { - get { - return GetVersion(); - } - } - - /// - /// Get lib3270/pw3270 Revision number - /// - /// - /// - /// The revision of the active instance. - /// - /// - public string GetRevision() { - StringBuilder str = new StringBuilder(10); - tn3270_get_revision(hSession, str, 10); - return str.ToString(); - } - - public string Revision { - get { - return GetRevision(); - } - } - - /// - /// Connect to 3270 host. - /// - /// - /// URL of the target host (tn3270://hostname:port) - /// How many seconds should the call wait for the connection becomes ready - /// - /// - /// - /// - public int Connect(string host, int wait) { - return tn3270_connect(hSession, host, wait); - } - - /// - /// Get connection state - /// - /// - /// - /// true if the session is connected to a remote host. - /// - /// - public bool IsConnected() { - return tn3270_is_connected(hSession) != 0; - } - - public bool Connected { - get { - return tn3270_is_connected(hSession) != 0; - } - } - - public bool IsReady() { - return tn3270_is_ready(hSession) != 0; - } - - public bool Ready { - get { - return tn3270_is_ready(hSession) != 0; - } - } - - /// - /// Disconnect from 3270 host. - /// - /// - public int Disconnect() { - return tn3270_disconnect(hSession); - } - - /// - /// Wait for network activity - /// - /// - /// Seconds to wait - /// - /// - /// - /// - /// - public int WaitForReady(int seconds) { - return tn3270_wait_for_ready(hSession, seconds); - } - - /// - /// "Sleep" keeping the network activity. - /// - /// - /// Number of seconds to wait - /// - /// - /// - /// - /// - public int Wait(int seconds) { - return tn3270_wait(hSession, seconds); - } - - /// - /// Get contents - /// - /// - /// - /// Contents from terminal screen. - /// - /// - public override string ToString() { - int strlen = (tn3270_get_width(hSession)+1) * (tn3270_get_height(hSession)+1); - StringBuilder str = new StringBuilder(strlen+1); - strlen = tn3270_get_contents(hSession, str, strlen); - return str.ToString(); - } - - - /// - /// Get contents at address - /// - /// - /// Address of text in the screen buffer - /// Number of characters to get - /// - /// - /// Contents from terminal screen. - /// - /// - public string GetString(int addr, int strlen) { - StringBuilder str = new StringBuilder(strlen+1); - tn3270_get_string(hSession, addr, str, strlen); - return str.ToString(); - } - - /// - /// Get contents at position. - /// - /// - /// Start row - /// Start col - /// Number of characters to get - /// - /// - /// Contents from terminal screen. - /// - /// - public string GetStringAt(int row, int col, int strlen) { - StringBuilder str = new StringBuilder(strlen+1); - tn3270_get_string_at(hSession, row, col, str, strlen); - return str.ToString(); - } - - /// - /// Set contents at position - /// - /// - /// Start row - /// Start col - /// Text to set - /// - public void SetStringAt(int row, int col, string str) { - tn3270_set_string_at(hSession, row, col, str); - } - - /// - /// Wait for text at position. - /// - /// - /// Start row - /// Start col - /// Text to wait - /// Seconds to wait - /// - /// - /// - /// - /// - public int WaitForStringAt(int row, int col, string str, int timeout) { - return tn3270_wait_for_string_at(hSession, row, col, str, timeout); - } - - /// - /// Compare contents at position - /// - /// - /// Start row - /// Start col - /// Text to compare - /// - /// - /// Result (0 = The strings are the same). - /// - /// - public int CmpStringAt(int row, int col, string str) { - return tn3270_cmp_string_at(hSession, row, col, str); - } - - /// - /// Set cursor position. - /// - /// - /// New cursor row - /// New cursor column - /// - public void SetCursorPosition(int row, int col) { - tn3270_set_cursor_position(hSession, row, col); - } - - /// - /// Set cursor position based on address. - /// - /// - /// Address of the new cursor position - /// - public void SetCursorPosition(int addr) { - tn3270_set_cursor_addr(hSession, addr); - } - - /// - /// Get cursor address - /// - /// - public int GetCursorPosition() { - return tn3270_get_cursor_addr(hSession); - } - - /// - /// Cursor address - /// - /// - public int CursorPosition { - set { - tn3270_set_cursor_addr(hSession, value); - } - get { - return tn3270_get_cursor_addr(hSession); - } - } - - /// - /// Set the "screen ready" delay - /// - /// - public int SetUnlockDelay(int ms) { - return tn3270_set_unlock_delay(hSession, ms); - } - - /// - /// Set the "screen ready" delay - /// - /// - public int UnlockDelay { - set { - tn3270_set_unlock_delay(hSession, value); - } - } - - - /// - /// Send "Enter" key - /// - /// - /// - /// - /// - /// - public int Enter() { - return tn3270_enter(hSession); - } - - /// - /// Send "PF" key - /// - /// - /// Key identifier 1=PF1, 2=PF2, ... - /// - /// - /// - /// - /// - public int PfKey(int key) { - return tn3270_pfkey(hSession, key); - } - - /// - /// Send "PA" key - /// - /// - /// Key identifier 1=PA1, 2=PA2, ... - /// - /// - /// - /// - /// - public int PaKey(int key) { - return tn3270_pakey(hSession, key); - } - - /// - /// Get screen width - /// - /// - /// - /// Screen width in characters (negative on error) - /// - /// - public int GetWidth() { - return tn3270_get_width(hSession); - } - - /// - /// Screen width in characters - /// - /// - /// - /// Screen width in characters (negative on error) - /// - /// - public int Width { - get { - return tn3270_get_width(hSession); - } - } - - /// - /// Get screen height - /// - /// - /// - /// Screen width in characters (negative on error) - /// - /// - public int GetHeight() { - return tn3270_get_height(hSession); - } - - /// - /// Screen height in characters - /// - /// - /// - /// Screen height in characters (negative on error) - /// - /// - public int Height { - get { - return tn3270_get_height(hSession); - } - } - - /// - /// Get length of terminal buffer (width * height) - /// - /// - /// - /// Terminal length in characters (negative on error) - /// - /// - public int GetLength() { - return tn3270_get_length(hSession); - } - - /// - /// Length of terminal buffer (width * height) - /// - /// - /// - /// Terminal length in characters (negative on error) - /// - /// - public int Length { - get { - return tn3270_get_length(hSession); - } - } - - public string CharSet { - set { - tn3270_set_charset(hSession,value); - } - } - - /// - /// 3270 host URL - /// - /// - /// - /// 3270 host URL - /// - /// - public string Url { - set { - tn3270_set_url(hSession,value); - } - get { - StringBuilder str = new StringBuilder(1025); - tn3270_get_url(hSession, str, 1024); - return str.ToString(); - } - } - - /// - /// Last lib3270 error message - /// - /// - /// - /// Last lib3270 error message - /// - /// - public string Error { - set { - tn3270_set_error_message(hSession,value); - } - get { - StringBuilder str = new StringBuilder(1025); - tn3270_get_error_message(hSession, str, 1024); - return str.ToString(); - } - } - - } - -} diff --git a/src/pw3270-sharp/pw3270-sharp.pc.in b/src/pw3270-sharp/pw3270-sharp.pc.in deleted file mode 100644 index 233ebc4..0000000 --- a/src/pw3270-sharp/pw3270-sharp.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=${pcfiledir}/../.. -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -gapidir=${prefix}/share/pw3270-sharp-1.0 - - -Name: pw3270-sharp -Description: Mono Bindings for pw3270 -Version: @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ -Cflags: -I:${gapidir}/pw3270-sharp.xml -Libs: -r:${libdir}/mono/pw3270-sharp-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@/pw3270-sharp.dll diff --git a/src/testprograms/ipc.cs b/src/testprograms/ipc.cs new file mode 100644 index 0000000..0a2ce2e --- /dev/null +++ b/src/testprograms/ipc.cs @@ -0,0 +1,63 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como sample.cs e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +using pw3270; + +class ipc { + + static void Main(string[] args) { + + pw3270.Session host = new pw3270.Session("pw3270:A"); + + System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); + System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); + + // host.CharSet = "ISO-8859-1"; + + if(host.Connected) { + + System.Console.WriteLine("Connected to " + host.Url); + System.Console.WriteLine("Wait for ready returned " + host.WaitForReady(5)); + + // System.Console.WriteLine(host.GetStringAt(1,1,1920)); + System.Console.WriteLine(host.GetString(1,1920)); + // System.Console.WriteLine(host); + + } else { + + System.Console.WriteLine("Host is disconnected"); + + } + + System.Console.WriteLine("Error: " + host.Error); + + + } + +} diff --git a/src/testprograms/sample.cs b/src/testprograms/sample.cs new file mode 100644 index 0000000..c051e2e --- /dev/null +++ b/src/testprograms/sample.cs @@ -0,0 +1,60 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como sample.cs e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +using pw3270; + +class sample { + + static void Main(string[] args) { + + pw3270.Session host = new pw3270.Session(""); + + System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); + System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); + + // host.Connect("tn3270://zos.efglobe.com:telnet",10); + host.Connect("tn3270://zos.efglobe.com:telnet",10); + + if(host.Connected) { + + System.Console.WriteLine("Connected to " + host.Url); + + System.Console.WriteLine("Wait for ready returned " + host.WaitForReady(5)); + + System.Console.WriteLine(host); + + host.Disconnect(); + } + + System.Console.WriteLine("Error: " + host.Error); + + + } + +} diff --git a/src/testprograms/simple.cs b/src/testprograms/simple.cs new file mode 100644 index 0000000..288ff6a --- /dev/null +++ b/src/testprograms/simple.cs @@ -0,0 +1,64 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como simple.cs e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; + +class test { + + [DllImport ("lib3270-mono")] + extern static IntPtr tn3270_create_session(string name); + + [DllImport ("lib3270-mono")] + extern static void tn3270_destroy_session(IntPtr session); + + [DllImport ("lib3270-mono")] + extern static void tn3270_get_version(IntPtr session, StringBuilder str, int strlen); + + [DllImport ("lib3270-mono")] + extern static void tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); + + static void Main(string[] args) { + + IntPtr handle = tn3270_create_session(""); + + StringBuilder str = new StringBuilder(100); + tn3270_get_version(handle, str, 100); + System.Console.WriteLine(str); + + tn3270_get_revision(handle, str, 100); + System.Console.WriteLine(str); + + tn3270_destroy_session(handle); + + } +} diff --git a/src/testprograms/vbclass.vb b/src/testprograms/vbclass.vb new file mode 100644 index 0000000..ae70eb3 --- /dev/null +++ b/src/testprograms/vbclass.vb @@ -0,0 +1,201 @@ +' +' "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 +' (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a +' aplicativos mainframe. Registro no INPI sob o nome G3270. +' +' Copyright (C) <2008> +' +' Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob +' os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela +' Free Software Foundation. +' +' Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER +' GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO +' A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para +' obter mais detalhes. +' +' Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este +' programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin +' St, Fifth Floor, Boston, MA 02110-1301 USA +' +' Este programa está nomeado como vbclass.vb e possui - linhas de código. +' +' Contatos: +' +' perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) +' erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) +' + +Imports System +Imports System.Text +Imports System.Runtime.InteropServices + +Public Class pw3270 + + _ + Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr + End Function + + _ + Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long + End Function + + _ + Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_connect(ByVal hSession As IntPtr, ByVal buffer As String, ByVal seconds as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_is_connected(ByVal hSession As IntPtr) as Integer + End Function + + _ + Private Shared Function tn3270_disconnect(ByVal hSession As IntPtr) as Integer + End Function + + _ + Private Shared Function tn3270_wait_for_ready(ByVal hSession As IntPtr, ByVal seconds as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_wait(ByVal hSession As IntPtr, ByVal seconds as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_get_cstate(ByVal hSession As IntPtr) as Integer + End Function + + _ + Private Shared Function tn3270_get_program_message(ByVal hSession As IntPtr) as Integer + End Function + + _ + Private Shared Function tn3270_get_secure(ByVal hSession As IntPtr) as Integer + End Function + + _ + Private Shared Function tn3270_get_string(ByVal hSession As IntPtr, ByVal addr as Integer, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer + End Function + + _ + 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 + End Function + + _ + 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 + End Function + + _ + 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 + End Function + + _ + 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 + End Function + + _ + Private Shared Function tn3270_set_unlock_delay(ByVal hSession As IntPtr, ByVal ms as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_set_cursor_position(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_set_cursor_addr(ByVal hSession As IntPtr, ByVal addr as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_enter(ByVal hSession As IntPtr) as Integer + End Function + + _ + Private Shared Function tn3270_pfkey(ByVal hSession As IntPtr, ByVal key as Integer) as Integer + End Function + + _ + Private Shared Function tn3270_pakey(ByVal hSession As IntPtr, ByVal key as Integer) as Integer + End Function + + Private Shared hSession As IntPtr + + Public Sub New(ByVal name as String) + hSession = tn3270_create_session(name) + End Sub + + Public Sub Connect(ByRef url as String, ByVal seconds as Integer) + tn3270_connect(hSession, url, seconds) + End Sub + + Public Sub Disconnect() + tn3270_disconnect(hSession) + End Sub + + Public Sub Finalize() + tn3270_destroy_session(hSession) + End Sub + + Public ReadOnly Property Version As String + Get + dim buffer As New StringBuilder(1024) + tn3270_get_version(hSession, buffer, 1024) + return buffer.toString + End Get + End Property + + Public ReadOnly Property Revision As String + Get + dim buffer As New StringBuilder(1024) + tn3270_get_revision(hSession, buffer, 1024) + return buffer.toString + End Get + End Property + + Public ReadOnly Property Connected As Boolean + Get + return tn3270_is_connected(hSession) + End Get + End Property + + Public Function GetStringAt(ByVal row as Integer, ByVal col as Integer, ByVal strlen as Integer) + dim buffer As New StringBuilder(strlen) + tn3270_get_string_at(hSession, row, col, buffer, strlen) + return buffer.toString + End Function + + Public Sub WaitForReady(ByVal seconds as Integer) + tn3270_wait_for_ready(hSession, seconds) + End Sub + + +End Class + + +Public Module modmain + + Sub Main() + + dim host as new pw3270("") + + Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision) + + host.Connect("tn3270://zos.efglobe.com:telnet",10) + + if host.Connected Then + + Console.WriteLine(host.GetStringAt(14,19,38)) + + host.Disconnect() + End If + + End Sub + + +End Module diff --git a/src/testprograms/vbsample.vb b/src/testprograms/vbsample.vb new file mode 100644 index 0000000..bc03724 --- /dev/null +++ b/src/testprograms/vbsample.vb @@ -0,0 +1,56 @@ +' +' "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 +' (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a +' aplicativos mainframe. Registro no INPI sob o nome G3270. +' +' Copyright (C) <2008> +' +' Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob +' os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela +' Free Software Foundation. +' +' Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER +' GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO +' A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para +' obter mais detalhes. +' +' Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este +' programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin +' St, Fifth Floor, Boston, MA 02110-1301 USA +' +' Este programa está nomeado como vbsample.vb e possui - linhas de código. +' +' Contatos: +' +' perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) +' erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) +' + +Imports System + +' This module houses the application's entry point. +Public Module modmain + + ' Application's entry point. + Sub Main() + + dim host as new pw3270.Session("") + + Console.WriteLine("Using pw3270 version " + host.getVersion() + " revision " + host.GetRevision()) + Console.WriteLine("Screen size is " + host.GetWidth() + "x" + host.GetHeigth()) + + host.Connect("tn3270://zos.efglobe.com:telnet",10) + + if host.IsConnected() then + + Console.WriteLine("Connected to host") + + Console.WriteLine(host.GetStringAt(14,19,38)) + + host.Disconnect() + + End If + + End Sub + +End Module diff --git a/src/testprograms/vbtest.vb b/src/testprograms/vbtest.vb new file mode 100644 index 0000000..d96459a --- /dev/null +++ b/src/testprograms/vbtest.vb @@ -0,0 +1,49 @@ + +Imports System +Imports System.Text +Imports System.Runtime.InteropServices + +' This module houses the application's entry point. +Public Module modmain + + + _ + Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr + End Function + + _ + Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long + End Function + + _ + Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long + End Function + + _ + Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long + End Function + + ' Application's entry point. + Sub Main() + + dim host as IntPtr = tn3270_create_session("") + dim buffer As New StringBuilder(1024) + + ' Get library version + tn3270_get_version(host, buffer, 1024) + dim vrs as String = buffer.toString + + ' Get Library revision + tn3270_get_revision(host, buffer, 1024) + dim rev as String = buffer.toString + + ' Write text to the console. + Console.WriteLine ("Using pw3270 version " + vrs + " revision " + rev) + + + + tn3270_destroy_session(host) + + End Sub + +End Module diff --git a/testprograms/ipc.cs b/testprograms/ipc.cs deleted file mode 100644 index 0a2ce2e..0000000 --- a/testprograms/ipc.cs +++ /dev/null @@ -1,63 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como sample.cs e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - -using pw3270; - -class ipc { - - static void Main(string[] args) { - - pw3270.Session host = new pw3270.Session("pw3270:A"); - - System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); - System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); - - // host.CharSet = "ISO-8859-1"; - - if(host.Connected) { - - System.Console.WriteLine("Connected to " + host.Url); - System.Console.WriteLine("Wait for ready returned " + host.WaitForReady(5)); - - // System.Console.WriteLine(host.GetStringAt(1,1,1920)); - System.Console.WriteLine(host.GetString(1,1920)); - // System.Console.WriteLine(host); - - } else { - - System.Console.WriteLine("Host is disconnected"); - - } - - System.Console.WriteLine("Error: " + host.Error); - - - } - -} diff --git a/testprograms/sample.cs b/testprograms/sample.cs deleted file mode 100644 index c051e2e..0000000 --- a/testprograms/sample.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como sample.cs e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - -using pw3270; - -class sample { - - static void Main(string[] args) { - - pw3270.Session host = new pw3270.Session(""); - - System.Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision); - System.Console.WriteLine("Screen size is " + host.Width + "x" + host.Height + " (" + host.Length + ")"); - - // host.Connect("tn3270://zos.efglobe.com:telnet",10); - host.Connect("tn3270://zos.efglobe.com:telnet",10); - - if(host.Connected) { - - System.Console.WriteLine("Connected to " + host.Url); - - System.Console.WriteLine("Wait for ready returned " + host.WaitForReady(5)); - - System.Console.WriteLine(host); - - host.Disconnect(); - } - - System.Console.WriteLine("Error: " + host.Error); - - - } - -} diff --git a/testprograms/simple.cs b/testprograms/simple.cs deleted file mode 100644 index 288ff6a..0000000 --- a/testprograms/simple.cs +++ /dev/null @@ -1,64 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como simple.cs e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; - -class test { - - [DllImport ("lib3270-mono")] - extern static IntPtr tn3270_create_session(string name); - - [DllImport ("lib3270-mono")] - extern static void tn3270_destroy_session(IntPtr session); - - [DllImport ("lib3270-mono")] - extern static void tn3270_get_version(IntPtr session, StringBuilder str, int strlen); - - [DllImport ("lib3270-mono")] - extern static void tn3270_get_revision(IntPtr session, StringBuilder str, int strlen); - - static void Main(string[] args) { - - IntPtr handle = tn3270_create_session(""); - - StringBuilder str = new StringBuilder(100); - tn3270_get_version(handle, str, 100); - System.Console.WriteLine(str); - - tn3270_get_revision(handle, str, 100); - System.Console.WriteLine(str); - - tn3270_destroy_session(handle); - - } -} diff --git a/testprograms/vbclass.vb b/testprograms/vbclass.vb deleted file mode 100644 index ae70eb3..0000000 --- a/testprograms/vbclass.vb +++ /dev/null @@ -1,201 +0,0 @@ -' -' "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 -' (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a -' aplicativos mainframe. Registro no INPI sob o nome G3270. -' -' Copyright (C) <2008> -' -' Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob -' os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela -' Free Software Foundation. -' -' Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER -' GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO -' A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para -' obter mais detalhes. -' -' Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este -' programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin -' St, Fifth Floor, Boston, MA 02110-1301 USA -' -' Este programa está nomeado como vbclass.vb e possui - linhas de código. -' -' Contatos: -' -' perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) -' erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) -' - -Imports System -Imports System.Text -Imports System.Runtime.InteropServices - -Public Class pw3270 - - _ - Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr - End Function - - _ - Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long - End Function - - _ - Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_connect(ByVal hSession As IntPtr, ByVal buffer As String, ByVal seconds as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_is_connected(ByVal hSession As IntPtr) as Integer - End Function - - _ - Private Shared Function tn3270_disconnect(ByVal hSession As IntPtr) as Integer - End Function - - _ - Private Shared Function tn3270_wait_for_ready(ByVal hSession As IntPtr, ByVal seconds as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_wait(ByVal hSession As IntPtr, ByVal seconds as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_get_cstate(ByVal hSession As IntPtr) as Integer - End Function - - _ - Private Shared Function tn3270_get_program_message(ByVal hSession As IntPtr) as Integer - End Function - - _ - Private Shared Function tn3270_get_secure(ByVal hSession As IntPtr) as Integer - End Function - - _ - Private Shared Function tn3270_get_string(ByVal hSession As IntPtr, ByVal addr as Integer, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Integer - End Function - - _ - 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 - End Function - - _ - 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 - End Function - - _ - 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 - End Function - - _ - 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 - End Function - - _ - Private Shared Function tn3270_set_unlock_delay(ByVal hSession As IntPtr, ByVal ms as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_set_cursor_position(ByVal hSession As IntPtr, ByVal row as Integer, ByVal col as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_set_cursor_addr(ByVal hSession As IntPtr, ByVal addr as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_enter(ByVal hSession As IntPtr) as Integer - End Function - - _ - Private Shared Function tn3270_pfkey(ByVal hSession As IntPtr, ByVal key as Integer) as Integer - End Function - - _ - Private Shared Function tn3270_pakey(ByVal hSession As IntPtr, ByVal key as Integer) as Integer - End Function - - Private Shared hSession As IntPtr - - Public Sub New(ByVal name as String) - hSession = tn3270_create_session(name) - End Sub - - Public Sub Connect(ByRef url as String, ByVal seconds as Integer) - tn3270_connect(hSession, url, seconds) - End Sub - - Public Sub Disconnect() - tn3270_disconnect(hSession) - End Sub - - Public Sub Finalize() - tn3270_destroy_session(hSession) - End Sub - - Public ReadOnly Property Version As String - Get - dim buffer As New StringBuilder(1024) - tn3270_get_version(hSession, buffer, 1024) - return buffer.toString - End Get - End Property - - Public ReadOnly Property Revision As String - Get - dim buffer As New StringBuilder(1024) - tn3270_get_revision(hSession, buffer, 1024) - return buffer.toString - End Get - End Property - - Public ReadOnly Property Connected As Boolean - Get - return tn3270_is_connected(hSession) - End Get - End Property - - Public Function GetStringAt(ByVal row as Integer, ByVal col as Integer, ByVal strlen as Integer) - dim buffer As New StringBuilder(strlen) - tn3270_get_string_at(hSession, row, col, buffer, strlen) - return buffer.toString - End Function - - Public Sub WaitForReady(ByVal seconds as Integer) - tn3270_wait_for_ready(hSession, seconds) - End Sub - - -End Class - - -Public Module modmain - - Sub Main() - - dim host as new pw3270("") - - Console.WriteLine("Using pw3270 version " + host.Version + " revision " + host.Revision) - - host.Connect("tn3270://zos.efglobe.com:telnet",10) - - if host.Connected Then - - Console.WriteLine(host.GetStringAt(14,19,38)) - - host.Disconnect() - End If - - End Sub - - -End Module diff --git a/testprograms/vbsample.vb b/testprograms/vbsample.vb deleted file mode 100644 index bc03724..0000000 --- a/testprograms/vbsample.vb +++ /dev/null @@ -1,56 +0,0 @@ -' -' "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 -' (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a -' aplicativos mainframe. Registro no INPI sob o nome G3270. -' -' Copyright (C) <2008> -' -' Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob -' os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela -' Free Software Foundation. -' -' Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER -' GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO -' A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para -' obter mais detalhes. -' -' Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este -' programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin -' St, Fifth Floor, Boston, MA 02110-1301 USA -' -' Este programa está nomeado como vbsample.vb e possui - linhas de código. -' -' Contatos: -' -' perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) -' erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) -' - -Imports System - -' This module houses the application's entry point. -Public Module modmain - - ' Application's entry point. - Sub Main() - - dim host as new pw3270.Session("") - - Console.WriteLine("Using pw3270 version " + host.getVersion() + " revision " + host.GetRevision()) - Console.WriteLine("Screen size is " + host.GetWidth() + "x" + host.GetHeigth()) - - host.Connect("tn3270://zos.efglobe.com:telnet",10) - - if host.IsConnected() then - - Console.WriteLine("Connected to host") - - Console.WriteLine(host.GetStringAt(14,19,38)) - - host.Disconnect() - - End If - - End Sub - -End Module diff --git a/testprograms/vbtest.vb b/testprograms/vbtest.vb deleted file mode 100644 index d96459a..0000000 --- a/testprograms/vbtest.vb +++ /dev/null @@ -1,49 +0,0 @@ - -Imports System -Imports System.Text -Imports System.Runtime.InteropServices - -' This module houses the application's entry point. -Public Module modmain - - - _ - Private Shared Function tn3270_create_session(ByVal Name As String) As IntPtr - End Function - - _ - Private Shared Function tn3270_destroy_session(ByVal hSession As IntPtr) as Long - End Function - - _ - Private Shared Function tn3270_get_version(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long - End Function - - _ - Private Shared Function tn3270_get_revision(ByVal hSession As IntPtr, ByVal buffer As StringBuilder, ByVal strlen as Integer) as Long - End Function - - ' Application's entry point. - Sub Main() - - dim host as IntPtr = tn3270_create_session("") - dim buffer As New StringBuilder(1024) - - ' Get library version - tn3270_get_version(host, buffer, 1024) - dim vrs as String = buffer.toString - - ' Get Library revision - tn3270_get_revision(host, buffer, 1024) - dim rev as String = buffer.toString - - ' Write text to the console. - Console.WriteLine ("Using pw3270 version " + vrs + " revision " + rev) - - - - tn3270_destroy_session(host) - - End Sub - -End Module -- libgit2 0.21.2