diff --git a/.gitignore b/.gitignore index 2ee6732..f4c006b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ dbus-glue.h *.cache *.zip *.bak +*.[0-9] diff --git a/Makefile.in b/Makefile.in index 610bb8f..56000b7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -24,38 +24,22 @@ # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) # -PACKAGE_NAME=@PACKAGE_NAME@ - -#---[ PLugin configuration ]------------------------------------------------------------- - -PLUGIN_NAME=ipc3270c - -PLUGIN_SOURCES= \ - $(wildcard src/$(PLUGIN_NAME)/*.c) \ - $(wildcard src/$(PLUGIN_NAME)/@OSNAME@/*.c) \ - $(wildcard src/$(PLUGIN_NAME)/@OSNAME@/*.rc) - -PLUGIN_TEST_SOURCES= \ - src/testprograms/$(PLUGIN_NAME).c - #---[ Library configuration ]------------------------------------------------------------ -LIBRARY_NAME=hllapi +LIBNAME=libhllapi -LIBRARY_SOURCES= \ - $(wildcard src/$(LIBRARY_NAME)/*.c) \ - $(wildcard src/$(LIBRARY_NAME)/*.cc) \ - $(wildcard src/$(LIBRARY_NAME)/@OSNAME@/*.c) \ - $(wildcard src/$(LIBRARY_NAME)/@OSNAME@/*.rc) +SOURCES= \ + $(wildcard src/core/*.cc) \ + $(wildcard src/core/@OSNAME@/*.rc) \ + $(wildcard src/core/@OSNAME@/*.cc) -LIBRARY_TEST_SOURCES= \ - src/testprograms/$(LIBRARY_NAME).c +TEST_SOURCES= \ + $(wildcard src/testprogram/*.cc) #---[ Tools ]---------------------------------------------------------------------------- -CC=@CC@ -LD=@CC@ CXX=@CXX@ +LD=@CXX@ LN_S=@LN_S@ MKDIR=@MKDIR_P@ INSTALL=@INSTALL@ @@ -65,7 +49,11 @@ XGETTEXT=@XGETTEXT@ MSGCAT=@MSGCAT@ WINDRES=@WINDRES@ AR=@AR@ -DBUSBINDINGTOOL=@DBUSBINDINGTOOL@ +VALGRIND=@VALGRIND@ +GENMARSHAL=@GENMARSHAL@ +CONVERT=@CONVERT@ +OPTIPNG=@OPTIPNG@ +ZIP=@ZIP@ #---[ Paths ]---------------------------------------------------------------------------- @@ -82,9 +70,7 @@ sysconfdir=@sysconfdir@ BASEDIR=@BASEDIR@ -POTDIR=$(BASEDIR)/.pot - -OBJDIR=$(BASEDIR)/.obj +OBJDIR=$(BASEDIR)/.obj/$(LIBNAME) OBJDBG=$(OBJDIR)/Debug OBJRLS=$(OBJDIR)/Release @@ -96,44 +82,18 @@ BINRLS=$(BINDIR)/Release DEPENDS= \ Makefile \ - @DEPENDS@ + src/include/*.h CFLAGS= \ @CFLAGS@ \ -g \ -Isrc/include \ -DBUILD_DATE=`date +%Y%m%d` \ - @LIB3270_CFLAGS@ \ - @V3270_CFLAGS@ \ - @GTK_CFLAGS@ \ - @GLIB_CFLAGS@ \ - @PW3270_CFLAGS@ \ - @DBUS_CFLAGS@ \ - @GDBUS_CFLAGS@ - -GTK_LIBS=@GTK_LIBS@ -V3270_LIBS=@V3270_LIBS@ -GLIB_LIBS=@GLIB_LIBS@ -DBUS_LIBS=@DBUS_LIBS@ @GDBUS_LIBS@ -STATIC_LDFLAGS=@STATIC_LDFLAGS@ -LDFLAGS=@LDFLAGS@ + @IPC3270_CFLAGS@ LIBS= \ @LIBS@ \ - @LIBICONV@ \ - @INTL_LIBS@ \ - @LIB3270_LIBS@ \ - @PW3270_LIBS@ - -src/include/dbus-glue.h: \ - pw3270dbus.xml - - @echo $@ ... - @$(DBUSBINDINGTOOL) \ - --mode=glib-server \ - --output=$@ \ - --prefix=pw3270_dbus $^ - + @IPC3270_LIBS@ #---[ Debug Rules ]---------------------------------------------------------------------- @@ -142,32 +102,20 @@ $(OBJDBG)/%.o: \ $(DEPENDS) @echo $< ... - @$(MKDIR) $(@D) - - @$(CC) \ - $(CFLAGS) \ - -Wall -Wextra -fstack-check \ - -DDEBUG=1 \ - -o $@ -c $< - -$(OBJDBG)/%.o: \ - %.cc \ - $(DEPENDS) - - @echo $< ... - @$(MKDIR) $(@D) + @$(MKDIR) $(dir $@) @$(CXX) \ $(CFLAGS) \ -Wall -Wextra -fstack-check \ -DDEBUG=1 \ - -o $@ -c $< + -o $@ \ + -c $< $(OBJDBG)/%.o: \ %.rc @echo $< ... - @$(MKDIR) $(@D) + @$(MKDIR) $(dir $@) @$(WINDRES) $< -O coff -o $@ #---[ Release Rules ]-------------------------------------------------------------------- @@ -177,277 +125,112 @@ $(OBJRLS)/%.o: \ $(DEPENDS) @echo $< ... - @$(MKDIR) $(@D) - @$(CC) \ - $(CFLAGS) \ - -DNDEBUG=1 \ - -o $@ -c $< - -$(OBJRLS)/%.o: \ - %.cc \ - $(DEPENDS) - - @echo $< ... - @$(MKDIR) $(@D) + @$(MKDIR) $(dir $@) @$(CXX) \ $(CFLAGS) \ -DNDEBUG=1 \ - -o $@ -c $< + -o $@ \ + -c $< $(OBJRLS)/%.o: \ %.rc @echo $< ... - @$(MKDIR) $(@D) + @$(MKDIR) $(dir $@) @$(WINDRES) $< -O coff -o $@ -#---[ Misc Rules ]----------------------------------------------------------------------- - -$(POTDIR)/$(PLUGIN_NAME)/%.pot: \ - %.c - - @echo $(notdir $@) ... - @$(MKDIR) $(@D) - @$(XGETTEXT) \ - --language=C \ - --keyword=_ \ - --keyword=N_ \ - --keyword=MSG_:2 \ - --output=$@ \ - $< - @touch $@ - -$(POTDIR)/$(PLUGIN_NAME)/%.pot: \ - %.rc - - @echo $< ... - @$(MKDIR) $(@D) - @touch $@ - - #---[ Release Targets ]------------------------------------------------------------------ all: \ - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \ - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ \ - $(POTDIR)/$(PLUGIN_NAME).pot + $(BINRLS)/$(SONAME) \ + $(BINRLS)/static/$(LIBNAME).a \ + $(POTDIR)/$(LIBNAME).pot Release: \ - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \ - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ + $(BINRLS)/$(SONAME) -$(BINRLS)/$(PLUGIN_NAME)@DLLEXT@: \ - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) +$(BINRLS)/$(SONAME): \ + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) - @$(MKDIR) $(@D) + @$(MKDIR) $(dir $@) @echo $< ... @$(LD) \ - -shared -Wl,-soname,$(@F) \ + @DLL_LDFLAGS@ \ -o $@ \ $(LDFLAGS) \ - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ - $(V3270_LIBS) \ - $(LIBS) \ - $(GTK_LIBS) \ - $(DBUS_LIBS) - -$(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@: \ - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ - - @echo $< ... - @rm -f $@ - @$(LN_S) \ - $^ \ - $@ - -$(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \ - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ - - @rm -f $@ - @$(LN_S) \ $^ \ - $@ - -$(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ - $(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJRLS)/$(SRC).o) - - @$(MKDIR) $(@D) - @echo $< ... - @$(CXX) \ - -shared -Wl,-soname,$(@F) \ - -o $@ \ - $(LDFLAGS) $(STATIC_LDFLAGS)\ - $(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJRLS)/$(SRC).o) \ - -lpw3270cpp \ - -L$(BINDBG) \ - $(LIBS) \ - $(DBUS_LIBS) - -zip: \ - $(PLUGIN_NAME)-@PACKAGE_VERSION@.@host@.zip - -$(PLUGIN_NAME)-@PACKAGE_VERSION@.@host@.zip: \ - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \ - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ \ - $(POTDIR)/$(PLUGIN_NAME).pot - - @rm -f $@ - @zip -9 -j $@ \ - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \ - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ \ - $(POTDIR)/$(PLUGIN_NAME).pot + $(LIBS) #---[ Install Targets ]------------------------------------------------------------------ install: \ - install-shared \ - install-plugin + $(BINRLS)/$(SONAME) -install-plugin: \ - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ - - @$(MKDIR) $(DESTDIR)$(libdir)/pw3270-plugins - - @$(INSTALL_PROGRAM) \ - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \ - $(DESTDIR)$(libdir)/pw3270-plugins - -install-shared: \ - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ - - @$(MKDIR) $(DESTDIR)/$(libdir) + # Install library + @$(MKDIR) $(DESTDIR)$(libdir) @$(INSTALL_PROGRAM) \ - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ - $(DESTDIR)/$(libdir) + $(BINRLS)/$(SONAME) \ + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ @$(LN_S) \ - lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ - $(DESTDIR)/$(libdir)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \ + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ @$(LN_S) \ - lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \ - $(DESTDIR)/$(libdir)/lib$(LIBRARY_NAME)@DLLEXT@ - -#---[ Misc Targets ]--------------------------------------------------------------------- + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \ + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@ -$(POTDIR)/$(PLUGIN_NAME).pot: \ - $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(PLUGIN_NAME)/$(SRC).pot) - - @rm -f $@ - @mkdir -p `dirname $@` - @$(MSGCAT) --sort-output $^ > $@ - -locale: \ - $(POTDIR)/$(PLUGIN_NAME).pot - -run-plugin: \ - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@ - - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@ - -run-library: \ - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@ - - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@ #---[ Debug Targets ]-------------------------------------------------------------------- Debug: \ - Debug-plugin \ - Debug-library - -Debug-plugin: \ - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@ - -Debug-library: \ - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@ - -zip-debug: \ - $(PLUGIN_NAME)-debug-@PACKAGE_VERSION@.@host@.zip - -$(PLUGIN_NAME)-debug-@PACKAGE_VERSION@.@host@.zip: \ - $(BINDBG)/$(PLUGIN_NAME)@DLLEXT@ \ - $(BINDBG)/lib$(LIBRARY_NAME)@DLLEXT@ \ - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@ \ - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@ - - @rm -f $@ - @zip -9 -j $@ \ - $(BINDBG)/$(PLUGIN_NAME)@DLLEXT@ \ - $(BINDBG)/lib$(LIBRARY_NAME)@DLLEXT@ \ - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@ \ - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@ - + $(BINDBG)/$(LIBNAME)@EXEEXT@ -$(BINDBG)/$(PLUGIN_NAME)@EXEEXT@: \ - $(foreach SRC, $(basename $(PLUGIN_TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ - $(BINDBG)/$(PLUGIN_NAME)@DLLEXT@ +$(BINDBG)/$(LIBNAME)@EXEEXT@: \ + $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ + $(BINDBG)/$(SONAME) - @$(MKDIR) $(@D) + @$(MKDIR) $(dir $@) @echo $< ... @$(LD) \ -o $@ \ - $(foreach SRC, $(basename $(PLUGIN_TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ + $^ \ -L$(BINDBG) \ -Wl,-rpath,$(BINDBG) \ $(LDFLAGS) \ - $(LIBS) \ - $(V3270_LIBS) \ - $(GTK_LIBS) \ - $(GLIB_LIBS) \ - $(DBUS_LIBS) + $(LIBS) + +run: \ + $(BINDBG)/$(LIBNAME)@EXEEXT@ -$(BINDBG)/$(PLUGIN_NAME)@DLLEXT@: \ - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) +ifeq ($(VALGRIND),no) - @$(MKDIR) $(@D) - @echo $< ... - @$(LD) \ - -shared -Wl,-soname,$(@F) \ - -o $@ \ - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ - $(LDFLAGS) \ - -L$(BINDBG) \ - $(LIBS) \ - $(V3270_LIBS) \ - $(GTK_LIBS) \ - $(GLIB_LIBS) \ - $(DBUS_LIBS) + @LD_LIBRARY_PATH=$(BINDBG) \ + $(BINDBG)/$(LIBNAME)@EXEEXT@ -$(BINDBG)/$(LIBRARY_NAME)@EXEEXT@: \ - $(foreach SRC, $(basename $(LIBRARY_TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ - $(BINDBG)/lib$(LIBRARY_NAME)@DLLEXT@ +else + @touch valgrind.suppression + + @LD_LIBRARY_PATH=$(BINDBG) \ + $(VALGRIND) --leak-check=full --track-origins=yes --gen-suppressions=all --suppressions=valgrind.suppression \ + $(BINDBG)/$(LIBNAME)@EXEEXT@ +endif - @$(MKDIR) $(@D) - @echo $< ... - @$(CXX) \ - -o $@ \ - $(foreach SRC, $(basename $(LIBRARY_TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ - -Wl,-rpath,$(BINDBG) \ - $(LDFLAGS) \ - -L$(BINDBG) \ - -l$(LIBRARY_NAME) \ - $(LIBS) \ - $(V3270_LIBS) \ - $(GTK_LIBS) \ - $(GLIB_LIBS) \ - $(DBUS_LIBS) -$(BINDBG)/lib$(LIBRARY_NAME)@DLLEXT@: \ - $(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJDBG)/$(SRC).o) +$(BINDBG)/$(SONAME): \ + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) - @$(MKDIR) $(@D) + @$(MKDIR) $(dir $@) @echo $< ... - @$(CXX) \ + @$(LD) \ -shared -Wl,-soname,$(@F) \ -o $@ \ - $(LDFLAGS) $(STATIC_LDFLAGS)\ - $(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJDBG)/$(SRC).o) \ - -lpw3270cpp \ -L$(BINDBG) \ - $(LIBS) \ - $(DBUS_LIBS) + $(LDFLAGS) \ + $^ \ + $(LIBS) + #---[ Clean Targets ]-------------------------------------------------------------------- @@ -455,19 +238,18 @@ clean: \ cleanDebug \ cleanRelease - @rm -fr $(BASEDIR)/.tmp/$(PLUGIN_NAME) - @rm -fr $(POTDIR)/$(PLUGIN_NAME) - cleanDebug: @rm -fr $(OBJDBG) @rm -fr $(BINDBG) - @rm -fr $(OBJDIR)/marshal cleanRelease: @rm -fr $(OBJRLS) @rm -fr $(BINRLS) - @rm -fr $(OBJDIR)/marshal + +clean: \ + cleanDebug \ + cleanRelease diff --git a/configure.ac b/configure.ac index b7bb525..6331eb3 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ AC_PREREQ(2.61) dnl Initialise automake with the package name, version and dnl bug-reporting address. -AC_INIT([ipc3270], [5.1], [perry.werneck@gmail.com]) +AC_INIT([hllapi], [5.2], [perry.werneck@gmail.com]) dnl Place auxilliary scripts here. AC_CONFIG_AUX_DIR([scripts]) @@ -54,7 +54,7 @@ AC_PROG_CXX AC_PROG_SED AC_PROG_LN_S -AC_LANG([C]) +AC_LANG([C++]) dnl --------------------------------------------------------------------------- dnl Initialize defaults @@ -65,8 +65,7 @@ RLS_CFLAGS="-DNDEBUG=1" PLUGINS="" APP_RESOURCES="" APP_LDFLAGS="" -DLL_LDFLAGS="-shared" -STATIC_LDFLAGS="" +DLL_LDFLAGS="-shared -Wl,-soname,\$(@F)" DEPENDS="" dnl --------------------------------------------------------------------------- @@ -85,9 +84,12 @@ case "$host" in DLLEXT=".dll" DLLPREFIX="" - app_win32_revision=$(date +%y.%m.%d.%H) + app_win32_revision=$(date +%-y.%-m.%-d.%-H) AC_SUBST(WIN32_VERSION,$app_win32_revision) - AC_CONFIG_FILES(src/ipc3270c/windows/resources.rc) + + app_win32_file_version=$(date +%-y,%-m,%-d,%-H) + AC_SUBST(WIN32_FILE_VERSION,$app_win32_file_version) + AC_CONFIG_FILES(src/hllapi/windows/resources.rc) ;; @@ -125,7 +127,7 @@ dnl --------------------------------------------------------------------------- dnl Version info dnl --------------------------------------------------------------------------- -AC_SUBST(PACKAGE_DESCRIPTION,"PW3270 IPC Compatible Module") +AC_SUBST(PACKAGE_DESCRIPTION,"PW3270 HLLAPI Module") app_vrs_major=$(echo $VERSION | cut -d. -f1) app_vrs_minor=$(echo $VERSION | cut -d. -f2) @@ -136,7 +138,7 @@ AC_DEFINE_UNQUOTED(PACKAGE_MINOR_VERSION, $app_vrs_minor) AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major) AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor) -AC_ARG_WITH([release], [AS_HELP_STRING([--with-release], [Set release])], [ app_cv_release="$withval" ],[ app_cv_release="`date +%y`.`date +%m`.`date +%d`" ]) +AC_ARG_WITH([release], [AS_HELP_STRING([--with-release], [Set release])], [ app_cv_release="$withval" ],[ app_cv_release="`date +%-y`.`date +%-m`.`date +%-d`" ]) app_rls_major=$(echo $app_cv_release.0.0 | cut -d. -f1) app_rls_minor=$(echo $app_cv_release.0.0 | cut -d. -f2) @@ -149,6 +151,20 @@ AC_SUBST(PACKAGE_RELEASE,$app_cv_release) AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major) AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor) +case "$host" in + *-mingw32|*-pc-msys) + AC_SUBST(SONAME,hllapi.dll) + ;; + + s390x-*) + AC_SUBST(SONAME,libhllapi.so) + ;; + + *) + AC_SUBST(SONAME,libhllapi.so.$app_vrs_major.$app_vrs_minor) + +esac + dnl --------------------------------------------------------------------------- dnl Check for libintl dnl --------------------------------------------------------------------------- @@ -164,68 +180,13 @@ AC_PATH_TOOL([MSGFMT], [msgfmt], [no]) AC_SUBST(INTL_LIBS) dnl --------------------------------------------------------------------------- -dnl Check for LIB3270 -dnl --------------------------------------------------------------------------- - -PKG_CHECK_MODULES( [LIB3270], [lib3270], AC_DEFINE(HAVE_LIB3270), AC_MSG_ERROR([LIB3270 not present.])) - -AC_SUBST(LIB3270_LIBS) -AC_SUBST(LIB3270_CFLAGS) - -dnl --------------------------------------------------------------------------- -dnl Check for PW3270 -dnl --------------------------------------------------------------------------- - -PKG_CHECK_MODULES( [PW3270], [pw3270], AC_DEFINE(HAVE_PW3270), AC_MSG_ERROR([PW3270 not present.])) - -AC_SUBST(PW3270_LIBS) -AC_SUBST(PW3270_CFLAGS) - -dnl --------------------------------------------------------------------------- -dnl Check for LIBV3270 +dnl Check for IPC3270 dnl --------------------------------------------------------------------------- -PKG_CHECK_MODULES( [V3270], [libv3270], AC_DEFINE(HAVE_V3270), AC_MSG_ERROR([V3270 not present.])) - -AC_SUBST(V3270_LIBS) -AC_SUBST(V3270_CFLAGS) - -dnl --------------------------------------------------------------------------- -dnl Check for GTK -dnl --------------------------------------------------------------------------- - -PKG_CHECK_MODULES( [GTK], [gtk+-3.0], AC_DEFINE(HAVE_GTK), AC_MSG_ERROR([GTK not present.])) - -AC_SUBST(GTK_LIBS) -AC_SUBST(GTK_CFLAGS) - -dnl --------------------------------------------------------------------------- -dnl Check for GLIB -dnl --------------------------------------------------------------------------- - -PKG_CHECK_MODULES( [GLIB], [glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0], AC_DEFINE(HAVE_GLIB), AC_MSG_ERROR([GLIB not present.] )) -AC_SUBST(GLIB_LIBS) -AC_SUBST(GLIB_CFLAGS) - -dnl --------------------------------------------------------------------------- -dnl Check for D-Bus -dnl --------------------------------------------------------------------------- - -AC_PATH_TOOL([DBUSBINDINGTOOL],[dbus-binding-tool],[no]) - -PKG_CHECK_MODULES( [DBUS], [dbus-1], app_cv_libdbus=yes, AC_MSG_NOTICE([ No DBUS support.]) ) -AC_SUBST(DBUS_LIBS) -AC_SUBST(DBUS_CFLAGS) - -PKG_CHECK_MODULES( [GDBUS], [dbus-glib-1], app_cv_dbus=yes, AC_MSG_NOTICE([No GDBUS support.]) ) -AC_SUBST(GDBUS_LIBS) -AC_SUBST(GDBUS_CFLAGS) - -if test "$app_cv_dbus" == "yes"; then - AC_DEFINE(HAVE_DBUS) - DEPENDS="$DEPENDS src/include/dbus-glue.h" -fi +PKG_CHECK_MODULES( [IPC3270], [ipc3270], AC_DEFINE(HAVE_IPC3270), AC_MSG_ERROR([LIB3270 not present.])) +AC_SUBST(IPC3270_LIBS) +AC_SUBST(IPC3270_CFLAGS) dnl --------------------------------------------------------------------------- dnl Check for pic diff --git a/src/core/calls.cc b/src/core/calls.cc new file mode 100644 index 0000000..4d2d4da --- /dev/null +++ b/src/core/calls.cc @@ -0,0 +1,826 @@ +/* + * "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 + * + * Este programa está nomeado como calls.cc e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include + #include + #include + + #include + #include + #include "client.h" + + using namespace std; + using namespace PW3270_NAMESPACE; + +/*--[ Globals ]--------------------------------------------------------------------------------------*/ + + static session * hSession = NULL; + static time_t hllapi_timeout = 120; + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + HLLAPI_API_CALL hllapi_init(LPSTR mode) + { + trace("%s(%s)",__FUNCTION__,mode); + + try + { + if(hSession) + delete hSession; + hSession = session::create(mode); + + if(!hSession) { + return HLLAPI_STATUS_UNAVAILABLE; + } + + hSession->set_display_charset(); + + trace("hSession=%p",hSession); + } + catch(std::exception &e) + { + trace("Error \"%s\"",e.what()); + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return HLLAPI_STATUS_SUCCESS; + + } + + HLLAPI_API_CALL hllapi_deinit(void) + { + trace("%s()",__FUNCTION__); + + try + { + if(hSession) + { + delete hSession; + hSession = NULL; + } + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_get_revision(void) + { + try + { + return atoi(session::get_default()->get_revision().c_str()); + } + catch(std::exception &e) + { + return -1; + } + return (DWORD) -1; + } + + HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait) + { + try + { + session::get_default()->connect(uri,hllapi_timeout); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return hllapi_get_state(); + } + + HLLAPI_API_CALL hllapi_is_connected(void) + { + if(!session::has_default()) + { + return 0; + } + + return session::get_default()->is_connected(); + } + + HLLAPI_API_CALL hllapi_get_state(void) + { + switch(hllapi_get_message_id()) + { + case LIB3270_MESSAGE_NONE: // 0 - No message + return HLLAPI_STATUS_SUCCESS; // keyboard was unlocked and ready for input. + + case LIB3270_MESSAGE_DISCONNECTED: // 4 - Disconnected from host + return HLLAPI_STATUS_DISCONNECTED; // Your application program was not connected to a valid session. + + case LIB3270_MESSAGE_MINUS: + case LIB3270_MESSAGE_PROTECTED: + case LIB3270_MESSAGE_NUMERIC: + case LIB3270_MESSAGE_OVERFLOW: + case LIB3270_MESSAGE_INHIBIT: + case LIB3270_MESSAGE_KYBDLOCK: + return HLLAPI_STATUS_KEYBOARD_LOCKED; // keyboard is locked. + + case LIB3270_MESSAGE_SYSWAIT: + case LIB3270_MESSAGE_TWAIT: + case LIB3270_MESSAGE_AWAITING_FIRST: + case LIB3270_MESSAGE_X: + case LIB3270_MESSAGE_RESOLVING: + case LIB3270_MESSAGE_CONNECTING: + return HLLAPI_STATUS_WAITING; // time-out while still busy (in XCLOCK or XSYSTEM in X) for the 3270 terminal emulation. + } + + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + HLLAPI_API_CALL hllapi_disconnect(void) + { + session::get_default()->disconnect(); + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + session::get_default()->wait_for_ready(seconds); + + return hllapi_get_state(); + } + + HLLAPI_API_CALL hllapi_wait(WORD seconds) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + session::get_default()->wait(seconds); + + return hllapi_get_state(); + } + + HLLAPI_API_CALL hllapi_get_message_id(void) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + return session::get_default()->get_program_message(); + } + + HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + if(!(buffer && *buffer)) + return HLLAPI_STATUS_SYSTEM_ERROR; + + try + { + size_t sz = strlen(buffer); + string str = session::get_default()->get_string_at(row,col,sz); + strncpy(buffer,str.c_str(),sz); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_enter(void) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + return session::get_default()->enter(); + } + + HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + try + { + session::get_default()->set_string_at(row,col,text); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text) + { + + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + int rc = HLLAPI_STATUS_SYSTEM_ERROR; + + try + { + rc = session::get_default()->cmp_string_at(row,col,text); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return rc; + } + + HLLAPI_API_CALL hllapi_find_text(LPSTR text) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + return (int) session::get_default()->find_string((const char *) text, false); + } + + HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms) + { + session::get_default()->set_unlock_delay(ms); + return 0; + } + + HLLAPI_API_CALL hllapi_set_charset(LPSTR text) + { + try + { + + session::get_default()->set_display_charset(NULL, (const char *) text); + + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return 0; + } + + HLLAPI_API_CALL hllapi_pfkey(WORD key) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + return session::get_default()->pfkey(key); + } + + HLLAPI_API_CALL hllapi_pakey(WORD key) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + return session::get_default()->pakey(key); + } + + HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir) + { + #ifdef _WIN32 + HKEY hKey = 0; + unsigned long datalen = strlen(datadir); + + *datadir = 0; + + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) + { + unsigned long datatype; // #defined in winnt.h (predefined types 0-11) + if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS) + *datadir = 0; + RegCloseKey(hKey); + } +#endif // _WIN32 + + return *datadir; + } + + HLLAPI_API_CALL hllapi_setcursor(WORD pos) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + session::get_default()->set_cursor_addr(pos-1); + + return HLLAPI_STATUS_SUCCESS; + + } + + HLLAPI_API_CALL hllapi_set_cursor_address(WORD pos) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + session::get_default()->set_cursor_addr(pos-1); + + return HLLAPI_STATUS_SUCCESS; + + } + + HLLAPI_API_CALL hllapi_get_cursor_address() + { + return session::get_default()->get_cursor_addr()+1; + } + + HLLAPI_API_CALL hllapi_getcursor() + { + return session::get_default()->get_cursor_addr()+1; + } + + HLLAPI_API_CALL hllapi_get_screen(WORD offset, LPSTR buffer, WORD len) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + int rc = HLLAPI_STATUS_SYSTEM_ERROR; + + if(offset < 1) + { + return HLLAPI_STATUS_BAD_PARAMETER; + } + + offset--; + + if(!session::has_default()) + { + return HLLAPI_STATUS_DISCONNECTED; + } + + if(!(buffer && *buffer)) { + return HLLAPI_STATUS_BAD_PARAMETER; + } + + try + { + size_t szBuffer; + + if(len > 0) + { + szBuffer = (size_t) len; + } + else + { + return HLLAPI_STATUS_BAD_PARAMETER; + } + + memset(buffer,' ',szBuffer); + + string str = session::get_default()->get_string(offset,szBuffer,false); + strncpy(buffer,str.c_str(),szBuffer); + rc = HLLAPI_STATUS_SUCCESS; + } + catch(std::exception &e) + { + rc = HLLAPI_STATUS_SYSTEM_ERROR; + } + + return rc; + } + + HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + try + { + session::get_default()->input_string(buffer); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_erase(void) + { + try + { + session::get_default()->erase(); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_erase_eof(void) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + try + { + session::get_default()->erase_eof(); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_erase_eol(void) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + try + { + session::get_default()->erase_eol(); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_erase_input(void) + { + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + try + { + session::get_default()->erase_input(); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_action(LPSTR buffer) { + try + { + session::get_default()->action((const char *) buffer); + } + catch(std::exception &e) + { + return HLLAPI_STATUS_SYSTEM_ERROR; + } + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_print(void) + { + return session::get_default()->print(); + } + + char * hllapi_get_string(int offset, size_t len) + { + try + { + string str = session::get_default()->get_string(offset-1,len); + char * ret = strdup(str.c_str()); + return ret; + } + catch(std::exception &e) + { + } + + return NULL; + } + + void hllapi_free(void *p) + { + free(p); + } + + HLLAPI_API_CALL hllapi_reset(void) + { + return HLLAPI_STATUS_SUCCESS; + } + + HLLAPI_API_CALL hllapi_input_string(LPSTR input, WORD length) + { + static const char control_char = '@'; + + size_t szText; + char * text; + int rc = 0; + + if(!hllapi_is_connected()) { + return HLLAPI_STATUS_DISCONNECTED; + } + + if(!input) + { + return HLLAPI_STATUS_BAD_PARAMETER; + } + + if(length > 0 ) + szText = length; + else + szText = strlen(input); + + text = (char *) malloc(szText+2); + memcpy(text,input,szText); + text[szText] = 0; + + trace("input[%s]",text); + + if(strchr(text,control_char)) + { + // Convert control char + char * buffer = text; + char * ptr; + + for(ptr = strchr(text,control_char);ptr;ptr = strchr(buffer,control_char)) + { + *(ptr++) = 0; + + trace("input[%s]",buffer); + hllapi_emulate_input(buffer,-1,0); + + switch(*(ptr++)) + { + case 'P': // Print + rc = hllapi_print(); + break; + + case 'E': // Enter + hllapi_enter(); + break; + + case 'F': // Erase EOF + hllapi_erase_eof(); + break; + + case '1': // PF1 + hllapi_pfkey(1); + break; + + case '2': // PF2 + hllapi_pfkey(2); + break; + + case '3': // PF3 + hllapi_pfkey(3); + break; + + case '4': // PF4 + hllapi_pfkey(4); + break; + + case '5': // PF5 + hllapi_pfkey(5); + break; + + case '6': // PF6 + hllapi_pfkey(6); + break; + + case '7': // PF7 + hllapi_pfkey(7); + break; + + case '8': // PF8 + hllapi_pfkey(8); + break; + + case '9': // PF9 + hllapi_pfkey(9); + break; + + case 'a': // PF10 + hllapi_pfkey(10); + break; + + case 'b': // PF11 + hllapi_pfkey(11); + break; + + case 'c': // PF12 + hllapi_pfkey(12); + break; + + case 'd': // PF13 + hllapi_pfkey(13); + break; + + case 'e': // PF14 + hllapi_pfkey(14); + break; + + case 'f': // PF15 + hllapi_pfkey(15); + break; + + case 'g': // PF16 + hllapi_pfkey(16); + break; + + case 'h': // PF17 + hllapi_pfkey(17); + break; + + case 'i': // PF18 + hllapi_pfkey(18); + break; + + case 'j': // PF19 + hllapi_pfkey(19); + break; + + case 'k': // PF20 + hllapi_pfkey(20); + break; + + case 'l': // PF21 + hllapi_pfkey(21); + break; + + case 'm': // PF22 + hllapi_pfkey(22); + break; + + case 'n': // PF23 + hllapi_pfkey(23); + break; + + case 'o': // PF24 + hllapi_pfkey(24); + break; + + case '@': // Send '@' character + hllapi_emulate_input((LPSTR) "@",-1,0); + break; + + case 'x': // PA1 + hllapi_pakey(1); + break; + + case 'y': // PA2 + hllapi_pakey(2); + break; + + case 'z': // PA3 + hllapi_pakey(3); + break; + + case 'B': // PC_LEFTTAB = "@B" + break; + + case 'T': // PC_RIGHTTAB = "@T" + break; + + case 'N': // PC_NEWLINE = "@N" + break; + + case 'C': // PC_CLEAR = "@C" + hllapi_erase_input(); + break; + + case 'D': // PC_DELETE = "@D" + break; + + case 'H': // PC_HELP = "@H" + break; + + case 'I': // PC_INSERT = "@I" + break; + + case 'L': // PC_CURSORLEFT = "@L" + break; + + case 'R': // PC_RESET = "@R" + hllapi_reset(); + break; + + case 'U': // PC_CURSORUP = "@U" + break; + + case 'V': // PC_CURSORDOWN = "@V" + break; + + case 'Z': // PC_CURSORRIGHT = "@Z" + break; + + case '0': // PC_HOME = "@0" + break; + + case 'p': // PC_PLUSKEY = "@p" + break; + + case 'q': // PC_END = "@q" + break; + + case 's': // PC_SCRLK = "@s" + break; + + case 't': // PC_NUMLOCK = "@t" + break; + + case 'u': // PC_PAGEUP = "@u" + break; + + case 'v': // PC_PAGEDOWN = "@v" + break; + + case '/': // PC_OVERRUNOFQUEUE = "@/" ' Queue overflow, used in Get Key only + break; + + case '$': // PC_ALTCURSOR = "@$" ' Presentation Manager only, unused in VB environment + break; + + case '<': // PC_BACKSPACE = "@<" + break; + + +/* + +Global Const PC_TEST = "@A@C" +Global Const PC_WORDDELETE = "@A@D" +Global Const PC_FIELDEXIT = "@A@E" +Global Const PC_ERASEINPUT = "@A@F" +Global Const PC_SYSTEMREQUEST = "@A@H" +Global Const PC_INSERTTOGGLE = "@A@I" +Global Const PC_CURSORSELECT = "@A@J" +Global Const PC_CURSLEFTFAST = "@A@L" +Global Const PC_GETCURSOR = "@A@N" +Global Const PC_LOCATECURSOR = "@A@O" +Global Const PC_ATTENTION = "@A@Q" +Global Const PC_DEVICECANCEL = "@A@R" +Global Const PC_PRINTPS = "@A@T" +Global Const PC_CURSUPFAST = "@A@U" +Global Const PC_CURSDOWNFAST = "@A@V" +Global Const PC_HEX = "@A@X" +Global Const PC_FUNCTIONKEY = "@A@Y" +Global Const PC_CURSRIGHTFAST = "@A@Z" + +Global Const PC_REVERSEVIDEO = "@A@9" +Global Const PC_UNDERSCORE = "@A@b" +Global Const PC_BLINK = "@A@c" +Global Const PC_RED = "@A@d" +Global Const PC_PINK = "@A@e" +Global Const PC_GREEN = "@A@f" +Global Const PC_YELLOW = "@A@g" +Global Const PC_BLUE = "@A@h" +Global Const PC_TURQOISE = "@A@i" +Global Const PC_WHITE = "@A@j" +Global Const PC_RSTHOSTCOLORS = "@A@l" +Global Const PC_PRINTPC = "@A@t" + +Global Const PC_FIELDMINUS = "@A@-" +Global Const PC_FIELDPLUS = "@A@+" + +*/ + + } + + buffer = ptr; + + } + + if(*buffer) + hllapi_emulate_input(buffer,-1,0); + + } + else + { + hllapi_emulate_input(text,szText,0); + } + + free(text); + + return rc; + } + diff --git a/src/core/environ.bat b/src/core/environ.bat new file mode 100644 index 0000000..c77f38a --- /dev/null +++ b/src/core/environ.bat @@ -0,0 +1,6 @@ +@echo off + +set VC=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC +set WINSDK=C:\Program Files (x86)\Windows Kits\8.1 +set PATH=%PATH%;"%VC%\bin";"%WINSDK%\bin\x86\" + diff --git a/src/core/hllapi.cbp b/src/core/hllapi.cbp new file mode 100644 index 0000000..f30461a --- /dev/null +++ b/src/core/hllapi.cbp @@ -0,0 +1,89 @@ + + + + + + diff --git a/src/core/hllapi.cc b/src/core/hllapi.cc new file mode 100644 index 0000000..d562e1c --- /dev/null +++ b/src/core/hllapi.cc @@ -0,0 +1,466 @@ +/* + * "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 + * + * Este programa está nomeado como hllapi.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include "client.h" + + /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ + + static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc); + static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc); + static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc); + static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc); + static int copy_str_to_ps(char *buffer, unsigned short *length, unsigned short *rc); + static int search_ps(char *buffer, unsigned short *length, unsigned short *rc); + static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc); + static int wait_system(char *buffer, unsigned short *length, unsigned short *rc); + static int reset_system(char *buffer, unsigned short *length, unsigned short *rc); + static int pause_system(char *buffer, unsigned short *length, unsigned short *rc); + static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc); + + static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); + static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); + static int input_string(char *buffer, unsigned short *length, unsigned short *rc); + + static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc); + +/*--[ Globals ]--------------------------------------------------------------------------------------*/ + + static const struct _hllapi_call + { + unsigned long func; + int (*exec)(char *buffer, unsigned short *length, unsigned short *rc); + } hllapi_call[] = + { + { HLLAPI_CMD_CONNECTPS, connect_ps }, + { HLLAPI_CMD_DISCONNECTPS, disconnect_ps }, + { HLLAPI_CMD_GETREVISION, get_library_revision }, + { HLLAPI_CMD_QUERYCURSOR, get_cursor_position }, + { HLLAPI_CMD_SETCURSOR, set_cursor_position }, + { HLLAPI_CMD_COPYPSTOSTR, copy_ps_to_str }, + { HLLAPI_CMD_INPUTSTRING, input_string }, + { HLLAPI_CMD_WAIT, wait_system }, + { HLLAPI_CMD_COPYPS, copy_ps }, + { HLLAPI_CMD_SEARCHPS, search_ps }, + { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps }, + { HLLAPI_CMD_SENDFILE, invalid_request }, + { HLLAPI_CMD_RECEIVEFILE, invalid_request }, + { HLLAPI_RESET_SYSTEM, reset_system }, + { HLLAPI_CMD_PAUSE, pause_system }, + { HLLAPI_SET_SESSION_PARAMETERS, set_session_parameters } + + }; + + static enum _pause_mode + { + PAUSE_MODE_IPAUSE, ///< @brief Interruptible pause. After the Start Host Notification (23) function is executed, a host event satisfies a pause. + PAUSE_MODE_FPAUSE ///< @brief A full-duration pause lasts for however long you specified in the Pause (18) function. + } pause_mode = PAUSE_MODE_IPAUSE; + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + +HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc) +{ + unsigned int f; + + trace("%s(%d)",__FUNCTION__,*func); + + for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++) + { + if(hllapi_call[f].func == *func) + { + int status = hllapi_call[f].exec(buffer,length,rc); + trace("hllapi(%d) exits with rc=%d",*func,status); + return status; + } + } + + trace("hllapi(%d) failed",*func); + + *rc = HLLAPI_STATUS_UNSUPPORTED; + return *rc; + +} + +static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc) +{ + *rc = HLLAPI_STATUS_BAD_PARAMETER; + return *rc; +} + +static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc) +{ + char *tempbuffer = NULL; + + trace("%s: len=%d buflen=%d",__FUNCTION__,*length,(int) strlen(buffer)); + + if(strlen(buffer) > *length) + buffer[*length] = 0; + + if(!strrchr(buffer,':')) + { + int sz = strlen(buffer); + + tempbuffer = (char *) malloc(sz+2); + strcpy(tempbuffer,buffer); + tempbuffer[sz-1] = ':'; + tempbuffer[sz] = buffer[sz-1]; + tempbuffer[sz+1] = 0; + buffer = tempbuffer; + } + + *rc = hllapi_init(buffer); + + if(tempbuffer) + free(tempbuffer); + + return 0; +} + +static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc) +{ + *rc = hllapi_deinit(); + return 0; +} + +static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc) +{ + *rc = hllapi_get_revision(); + return 0; +} + +static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) +{ + int pos = hllapi_getcursor(); + + trace("%s(%d)",__FUNCTION__,pos); + + if(pos < 0) + return -1; + + *rc = pos; + return 0; +} + +static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) +{ + trace("%s(%d)",__FUNCTION__,*rc); + *rc = hllapi_setcursor(*rc); + return 0; +} + +static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc) +{ + + // Length Length of the target data string. + // PS Position Position within the host presentation space of the first byte in your target data string. + *rc = hllapi_get_screen(*rc,buffer,*length); + + return 0; +} + +static int input_string(char *buffer, unsigned short *length, unsigned short *rc) +{ + *rc = hllapi_input_string(buffer,*length); + return 0; +} + +static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) +{ + /* + * Data String Target string for search. + * Length Length of the target data string. Overridden in EOT mode. + * PS Position Position within the host presentation space where the search is to begin (SRCHFRWD option) or to end + * (SRCHBKWD option). Overridden in SRCHALL (default) mode. + * + * Return in *ps: + * + * = 0 The string was not found. + * > 0 The string was found at the indicated host presentation space position. + * + * Return code: + * + * 0 The Search Presentation Space function was successful. + * 1 Your program is not connected to a host session. + * 2 An error was made in specifying parameters. + * 7 The host presentation space position is not valid. + * 9 A system error was encountered. + * 24 The search string was not found. + * + */ + size_t szBuffer = strlen(buffer); + char * text; + int rc = HLLAPI_STATUS_SYSTEM_ERROR; + + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + if(*length < szBuffer) + szBuffer = *length; + + + text = hllapi_get_string(*ps,szBuffer); + if(!text) + return HLLAPI_STATUS_SYSTEM_ERROR; + + if(strncmp(text,buffer,szBuffer)) + { + // String not found + *ps = 0; + rc = HLLAPI_STATUS_NOT_FOUND; + } + else + { + // String found + *ps = 1; + rc = HLLAPI_STATUS_SUCCESS; + } + + hllapi_free(text); + + return rc; +} + +static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) +{ + /* + * Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space is configured. When the Set Session Parameters (9) function with the EAB option is issued, the length of the data string must be at least twice the length of the presentation space. + * DBCS Only: When the EAD option is specified, the length of the data string must be at least three times the length of the presentation space. When both the EAB and EAD options are specified, the length of the data string must be at least four times the length of the presentation space. + * + * Length NA (the length of the host presentation space is implied). + * PS Position NA. + * + * Return values: + * + * 0 The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked. + * 1 Your program is not connected to a host session. + * 4 The host presentation space contents were copied. The connected host presentation space was waiting for host response. + * 5 The host presentation space was copied. The keyboard was locked. + * 9 A system error was encountered. + * + */ + size_t szBuffer = strlen(buffer); + char * text; + + if(!hllapi_is_connected()) + return HLLAPI_STATUS_DISCONNECTED; + + text = hllapi_get_string(1, szBuffer); + + if(!text) + return HLLAPI_STATUS_SYSTEM_ERROR; + + memcpy(buffer,text,szBuffer); + + hllapi_free(text); + + return hllapi_get_state(); +} + +static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) +{ + /* + * Checks the status of the host-connected presentation space. If the session is + * waiting for a host response (indicated by XCLOCK (X []) or XSYSTEM), the Wait + * function causes HLLAPI to wait up to 1 minute to see if the condition clears. + * + */ + + /* + * Return Code Definition + * + * HLLAPI_STATUS_SUCCESS 0 The keyboard is unlocked and ready for input. + * HLLAPI_STATUS_DISCONNECTED 1 Your application program is not connected to a valid session. + * HLLAPI_STATUS_TIMEOUT 4 Timeout while still in XCLOCK (X []) or XSYSTEM. + * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The keyboard is locked. + * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered. + * + */ + + /* + time_t end = time(0) + 60; + + while(time(0) < end) + { + int state = hllapi_get_state(); + + if(state != HLLAPI_STATUS_WAITING) + return state; + + hllapi_wait(1); + + } + + return HLLAPI_STATUS_TIMEOUT; + */ + + int state = hllapi_wait_for_ready(60); + return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state); + +} + +static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps) +{ + /* + * Call Parameters + * + * Data String of ASCII data to be copied into the host presentation space. + * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode. + * PS Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space. + * + * Return Parameters + * + * HLLAPI_STATUS_SUCCESS 0 The Copy String to Presentation Space function was successful. + * HLLAPI_STATUS_DISCONNECTED 1 Your program is not connected to a host session. + * HLLAPI_STATUS_BAD_PARAMETER 2 Parameter error or zero length for copy. + * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte). + * 6 The copy was completed, but the data was truncated. + * 7 The host presentation space position is not valid. + * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered. + * + */ + size_t szText = strlen(text); + + if(*length < szText) + szText = *length; + + if(!szText) + return HLLAPI_STATUS_BAD_PARAMETER; + + switch(hllapi_get_message_id()) + { + case LIB3270_MESSAGE_NONE: + break; + + case LIB3270_MESSAGE_DISCONNECTED: + return HLLAPI_STATUS_DISCONNECTED; + + case LIB3270_MESSAGE_MINUS: + case LIB3270_MESSAGE_PROTECTED: + case LIB3270_MESSAGE_NUMERIC: + case LIB3270_MESSAGE_OVERFLOW: + case LIB3270_MESSAGE_INHIBIT: + case LIB3270_MESSAGE_KYBDLOCK: + return HLLAPI_STATUS_KEYBOARD_LOCKED; + + default: + return HLLAPI_STATUS_SYSTEM_ERROR; + } + + return hllapi_emulate_input(text,szText,0); +} + +static int reset_system(char *buffer, unsigned short *length, unsigned short *rc) +{ + return hllapi_reset(); +} + + +static int pause_system(char *buffer, unsigned short *length, unsigned short *rc) +{ + if(!*length) + { + // If you use the IPAUSE option and the pause value is zero, then the function + // waits up to 2400 half-second intervals, unless interrupted sooner. If you use the + // FPAUSE option and the pause value is zero, then the function returns + // immediately. + + if(pause_mode == PAUSE_MODE_FPAUSE) + { + return HLLAPI_STATUS_SUCCESS; + } + return hllapi_wait_for_ready(1200); + } + + if(pause_mode == PAUSE_MODE_FPAUSE) + { + // Pause fixo - Aguarda pelo tempo informado, independente de eventos. + return hllapi_wait( (*length) / 2); + } + + // Pause "flexivel", aguarda mudança no conteúdo da tela!!! + + // #warning Mudar comportamento na lib! + + return hllapi_wait_for_ready((*length) / 2); +} + +static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc) +{ + if(!(*length && buffer && *buffer)) + { + return HLLAPI_STATUS_BAD_PARAMETER; + } + + *rc = hllapi_set_session_parameter(buffer, *length, *rc); + + return 0; +} + +HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value) +{ + if(!param) + { + return HLLAPI_STATUS_BAD_PARAMETER; + } + + if(!len) + { + len = strlen(param); + } + + if(!strncasecmp(param,"IPAUSE",len)) + { + // IPAUSE + pause_mode = PAUSE_MODE_IPAUSE; + } + else if(!strncasecmp(param,"FPAUSE",len)) + { + // FPAUSE + pause_mode = PAUSE_MODE_FPAUSE; + } + else if(!strncasecmp(param,"UNLOCKDELAY",len)) + { + // UNLOCKDELAY + hllapi_set_unlock_delay(value); + } + else + { + return HLLAPI_STATUS_BAD_PARAMETER; + } + + return HLLAPI_STATUS_SUCCESS; +} diff --git a/src/core/idlcomp.bat b/src/core/idlcomp.bat new file mode 100644 index 0000000..fe0bdce --- /dev/null +++ b/src/core/idlcomp.bat @@ -0,0 +1,3 @@ +@echo off + +midl.exe /I "%WINSDK%\Include\um" /I "%WINSDK%\Include\shared" /cpp_cmd "cl.exe" pw3270.idl diff --git a/src/core/remotectl.h b/src/core/remotectl.h new file mode 100644 index 0000000..e53ada2 --- /dev/null +++ b/src/core/remotectl.h @@ -0,0 +1,84 @@ +/* + * "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. 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 remotectl.h e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + * Agradecimento: + * + * Hélio Passos + * + */ + + #define ENABLE_NLS + #define GETTEXT_PACKAGE PACKAGE_NAME + + #include + #include + #include + + #include + #include + #include + + typedef struct _remotequery + { +#ifdef _WIN32 + HANDLE hPipe; /**< Pipe handle (for response) */ +#endif // _WIN32 + + H3270 * hSession; /**< 3270 Session */ + int cmd; /**< Command */ + int rc; /**< Response status */ + + int pos; + unsigned short length; /**< Query string length */ + const gchar * text; /**< Query string */ + + } QUERY; + + G_GNUC_INTERNAL void enqueue_request(QUERY *qry); + G_GNUC_INTERNAL void request_complete(QUERY *qry, int rc, const gchar *text); + + G_GNUC_INTERNAL void request_status(QUERY *qry, int rc); + G_GNUC_INTERNAL void request_value(QUERY *qry, int rc, unsigned int value); + G_GNUC_INTERNAL void request_buffer(QUERY *qry, int rc, size_t sz, const gpointer buffer); + +// int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc); + + +#ifdef _WIN32 + + #define PIPE_BUFFER_LENGTH 8192 + + void init_source_pipe(HANDLE hPipe); + void popup_lasterror(const gchar *fmt, ...); + +#endif // _WIN32 + + + + + + diff --git a/src/core/windows/resources.rc.in b/src/core/windows/resources.rc.in new file mode 100644 index 0000000..4bab1b3 --- /dev/null +++ b/src/core/windows/resources.rc.in @@ -0,0 +1,29 @@ +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION @WIN32_FILE_VERSION@ +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,@PACKAGE_MINOR_RELEASE@ + +BEGIN + + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "FileDescription", "pw3270 HLLAPI Client Module\0" + VALUE "CompanyName", "Banco do Brasil S/A.\0" + VALUE "FileVersion", "@WIN32_VERSION@\0" + VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" + VALUE "OriginalFilename", "hllapi@DLLEXT@\0" + VALUE "ProductName", "pw3270\0" + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@\0" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 0x04E4 + END + +END + diff --git a/src/daemon/linux/daemon.c b/src/daemon/linux/daemon.c deleted file mode 100644 index a429514..0000000 --- a/src/daemon/linux/daemon.c +++ /dev/null @@ -1,122 +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 daemon.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * - * Referencias: - * - * https://live.gnome.org/DBusGlibBindings - * - */ - -#include -#include -#include -#include - -#include "daemon.h" -#include "dbus-glue.h" - -#define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270" -#define PW3270_DBUS_SERVICE "br.com.bb.pw3270" - - -/*---[ Globals ]---------------------------------------------------------------------------------*/ - - static DBusGConnection * connection = NULL; - static DBusGProxy * proxy = NULL; - static H3270 * hSession = NULL; - - GMainLoop * main_loop = NULL; - - -/*---[ Implement ]-------------------------------------------------------------------------------*/ - -static int initialize(void) -{ - GError * error = NULL; - guint result; - - connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); - if(error) - { - g_message("Error \"%s\" getting session dbus",error->message); - g_error_free(error); - return -1; - } - - proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); - - org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); - - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH); - - return 0; -} - -static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args) -{ - g_logv(module,rc ? G_LOG_LEVEL_WARNING : G_LOG_LEVEL_MESSAGE, fmt, args); -} - -int main(int numpar, char *param[]) -{ - g_type_init (); - - if (!g_thread_supported ()) - g_thread_init (NULL); - - dbus_g_thread_init (); - - lib3270_set_log_handler(loghandler); - pw3270_dbus_register_io_handlers(); - - hSession = lib3270_session_new(""); - - main_loop = g_main_loop_new (NULL, FALSE); - - if(initialize()) - return -1; - - g_main_loop_run(main_loop); - - lib3270_session_free(hSession); - - return 0; -} - -void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - g_main_loop_quit(main_loop); - dbus_g_method_return(context,0); -} - -H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object) -{ - return hSession; -} - diff --git a/src/daemon/linux/iocallback.c b/src/daemon/linux/iocallback.c deleted file mode 100644 index 5292f4c..0000000 --- a/src/daemon/linux/iocallback.c +++ /dev/null @@ -1,361 +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 iocallback.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * - */ - -#if defined(_WIN32) /*[*/ - #include -#elif defined(__APPLE__) - #include - #include -#else - #include - #include -#endif /*]*/ - -#include -#include -#include "daemon.h" - -static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm); -static void static_RemoveSource(void *id); - -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)); -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)); - -static void * static_AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); -static void static_RemoveTimeOut(void * timer); -static int static_Sleep(H3270 *hSession, int seconds); -static int static_RunPendingEvents(H3270 *hSession, int wait); - -static gboolean IO_prepare(GSource *source, gint *timeout); -static gboolean IO_check(GSource *source); -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); -static void IO_finalize(GSource *source); /* Can be NULL */ -static gboolean IO_closure(gpointer data); - -/*---[ Structs ]-------------------------------------------------------------------------------------------*/ - - typedef struct _IO_Source - { - GSource gsrc; - GPollFD poll; -#if defined(_WIN32) - HANDLE source; -#else - int source; -#endif // _WIN32 - void (*fn)(H3270 *session); - H3270 *session; - } IO_Source; - - typedef struct _timer - { - unsigned char remove; - void (*fn)(H3270 *session); - H3270 *session; - } TIMER; - - static GSourceFuncs IOSources = - { - IO_prepare, - IO_check, - IO_dispatch, - IO_finalize, - IO_closure, - NULL - }; - -/*---[ Implement ]-----------------------------------------------------------------------------------------*/ - -#ifdef _WIN32 -static void * AddSource(HANDLE source, H3270 *session, gushort events, void (*fn)(H3270 *session)) -#else -static void * AddSource(int source, H3270 *session, gushort events, void (*fn)(H3270 *session)) -#endif // _WIN32 -{ - IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source)); - - src->source = source; - src->fn = fn; - src->poll.fd = (int) source; - src->poll.events = events; - src->session = session; - - g_source_attach((GSource *) src,NULL); - g_source_add_poll((GSource *) src,&src->poll); - - return src; -} - -#ifdef _WIN32 -static void * static_AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) -#else -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) -#endif // _WIN32 -{ - return AddSource(source,session,G_IO_IN|G_IO_HUP|G_IO_ERR,fn); -} - -static void static_RemoveSource(void *id) -{ - if(id) - g_source_destroy((GSource *) id); -} - -#if defined(_WIN32) -static void * static_AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) -{ - return 0; -} -#else -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) -{ - return AddSource(source,session,G_IO_HUP|G_IO_ERR,fn); -} -#endif // _WIN32 - -static gboolean do_timer(TIMER *t) -{ - if(!t->remove) - t->fn(t->session); - return FALSE; -} - -static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*proc)(H3270 *session)) -{ - TIMER *t = g_malloc0(sizeof(TIMER)); - - t->fn = proc; - t->session = session; - - g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) interval, (GSourceFunc) do_timer, t, g_free); - - return t; -} - -static void static_RemoveTimeOut(void * timer) -{ - ((TIMER *) timer)->remove++; -} - -static gboolean IO_prepare(GSource *source, gint *timeout) -{ - /* - * Called before all the file descriptors are polled. - * If the source can determine that it is ready here - * (without waiting for the results of the poll() call) - * it should return TRUE. - * - * It can also return a timeout_ value which should be the maximum - * timeout (in milliseconds) which should be passed to the poll() call. - * The actual timeout used will be -1 if all sources returned -1, - * or it will be the minimum of all the timeout_ values - * returned which were >= 0. - * - */ - return 0; -} - -static gboolean IO_check(GSource *source) -{ - /* - * Called after all the file descriptors are polled. - * The source should return TRUE if it is ready to be dispatched. - * Note that some time may have passed since the previous prepare - * function was called, so the source should be checked again here. - * - */ -#if defined(_WIN32) /*[*/ - - if(WaitForSingleObject(((IO_Source *) source)->source,0) == WAIT_OBJECT_0) - return TRUE; - -#else /*][*/ - - struct pollfd fds; - - memset(&fds,0,sizeof(fds)); - - fds.fd = ((IO_Source *) source)->poll.fd; - fds.events = ((IO_Source *) source)->poll.events; - - if(poll(&fds,1,0) > 0) - return TRUE; - -#endif /*]*/ - - return FALSE; -} - -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) -{ - /* - * Called to dispatch the event source, - * after it has returned TRUE in either its prepare or its check function. - * The dispatch function is passed in a callback function and data. - * The callback function may be NULL if the source was never connected - * to a callback using g_source_set_callback(). The dispatch function - * should call the callback function with user_data and whatever additional - * parameters are needed for this type of event source. - */ - ((IO_Source *) source)->fn(((IO_Source *) source)->session); - return TRUE; -} - -static void IO_finalize(GSource *source) -{ - -} - -static gboolean IO_closure(gpointer data) -{ - return 0; -} - -struct bgParameter -{ - gboolean running; - gboolean timer; - H3270 *session; - int rc; - int(*callback)(H3270 *session, void *); - void *parm; - -}; - -gpointer BgCall(struct bgParameter *p) -{ -// trace("%s starts",__FUNCTION__); - p->rc = p->callback(p->session, p->parm); - p->running = FALSE; -// trace("%s ends",__FUNCTION__); - return 0; -} - -static gboolean wait_for_thread(struct bgParameter *p) -{ - if(!p->running) - { - p->timer = 0; - return FALSE; - } - return TRUE; -} - -static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm) -{ - struct bgParameter p = { TRUE, TRUE, session, -1, callback, parm }; - GThread * thread; - -// trace("Starting auxiliary thread for callback %p",callback); - - p.running = TRUE; - p.timer = TRUE; - - thread = g_thread_create( (GThreadFunc) BgCall, &p, 0, NULL); - - if(!thread) - { - g_error("Can't start background thread"); - return -1; - } - - g_timeout_add(50,(GSourceFunc) wait_for_thread,(gpointer) &p); - - while(p.timer) - g_main_context_iteration(g_main_loop_get_context(main_loop),TRUE); - - return p.rc; -} - -static int static_Sleep(H3270 *hSession, int seconds) -{ - time_t end = time(0) + seconds; - - while(time(0) < end) - g_main_iteration(TRUE); - - return 0; -} - -static int static_RunPendingEvents(H3270 *hSession, int wait) -{ - GMainContext *context = g_main_loop_get_context(main_loop); - int rc = 0; - while(g_main_context_pending(context)) - { - rc = 1; - g_main_context_iteration(context,FALSE); - } - - if(wait) - g_main_context_iteration(context,TRUE); - - return rc; -} - -static void beep(H3270 *session) -{ -} - -void pw3270_dbus_register_io_handlers(void) -{ - static const struct lib3270_callbacks hdl = - { - sizeof(struct lib3270_callbacks), - - static_AddTimeOut, - static_RemoveTimeOut, - - static_AddInput, - static_RemoveSource, - - static_AddExcept, - -#ifdef G_THREADS_ENABLED - static_CallAndWait, -#else - NULL, -#endif - - static_Sleep, - static_RunPendingEvents, - beep - - }; - - #error Need rewrite - - if(lib3270_register_handlers(&hdl)) - { - g_error("%s","Can't set lib3270 I/O handlers"); - } - -} diff --git a/src/hllapi/Makefile.in b/src/hllapi/Makefile.in deleted file mode 100644 index 32c86be..0000000 --- a/src/hllapi/Makefile.in +++ /dev/null @@ -1,315 +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=hllapi -LIBNAME=lib$(MODULE_NAME)@DLLEXT@ - -PLUGIN_SOURCES=pluginmain.c -API_SOURCES=calls.c hllapi.c - -#---[ 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)/src/plugins/$(MODULE_NAME) -POTDIR=$(BASEDIR)/.pot/plugins/$(MODULE_NAME) - -OBJDIR=$(BASEDIR)/.obj/plugins/$(MODULE_NAME) -OBJDBG=$(OBJDIR)/Debug -OBJRLS=$(OBJDIR)/Release - -BINDIR=$(BASEDIR)/.bin -BINDBG=$(BINDIR)/Debug -BINRLS=$(BINDIR)/Release - -MKDIR=@MKDIR_P@ -CC=@CC@ -CXX=@CXX@ -LD=@CXX@ -AR=@AR@ -XGETTEXT=@XGETTEXT@ -MSGCAT=@MSGCAT@ -INSTALL=@INSTALL@ -INSTALL_DATA=@INSTALL_DATA@ -INSTALL_PROGRAM=@INSTALL_PROGRAM@ -LN_S=@LN_S@ - -CFLAGS=\ - @CFLAGS@ \ - @LIBV3270_CFLAGS@ \ - @GTK_CFLAGS@ \ - -I$(BASEDIR)/src/include - -LIBS=@LIBS@ - -API_LIBS=\ - $(LIBS) \ - -lpw3270cpp \ - @LIBICONV@ - -PLUGIN_LIBS=\ - $(LIBS) \ - @GTK_LIBS@ \ - @GLIB_LIBS@ \ - @LIB3270_LIBS@ \ - @LIBV3270_LIBS@ \ - @PW3270_LIBS@ - -LDFLAGS=\ - @LDFLAGS@ - -#---[ Rules ]---------------------------------------------------------------------------- - -DEPENDS=*.h Makefile - -$(OBJDBG)/%.o: \ - %.c \ - $(DEPENDS) - - @echo $< ... - @$(MKDIR) `dirname $@` - @$(CC) $(CFLAGS) \ - @DBG_CFLAGS@ \ - -DBUILD_DATE=`date +"0x%Y%m%d"`\ - -o $@ -c $< - -$(OBJDBG)/%.o: \ - %.cc \ - $(DEPENDS) - - @echo $< ... - @$(MKDIR) `dirname $@` - @$(CXX) $(CFLAGS) \ - @DBG_CFLAGS@ \ - -DBUILD_DATE=`date +"0x%Y%m%d"`\ - -o $@ -c $< - -$(OBJRLS)/%.o: \ - %.c \ - $(DEPENDS) - - @echo $< ... - @$(MKDIR) `dirname $@` - @$(CC) $(CFLAGS) \ - @RLS_CFLAGS@ \ - -DBUILD_DATE=`date +"0x%Y%m%d"` \ - -o $@ -c $< - -$(OBJRLS)/%.o: \ - %.cc \ - $(DEPENDS) - - @echo $< ... - @$(MKDIR) `dirname $@` - @$(CXX) $(CFLAGS) \ - @RLS_CFLAGS@ \ - -DBUILD_DATE=`date +"0x%Y%m%d"` \ - -o $@ -c $< - -$(POTDIR)/%.pot: %.c - - @echo $(notdir $@) ... - @$(MKDIR) `dirname $@` - @$(XGETTEXT) \ - --default-domain=$(PACKAGE) \ - --language=C \ - --keyword=_ \ - --keyword=N_ \ - --keyword=MSG_:2 \ - --output=$@ \ - $< - - @touch $@ - -#---[ Release Targets ]------------------------------------------------------------------ - -Release: \ - $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ - -install: \ - $(BINRLS)/$(LIBNAME) \ - $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ - - @echo $@ ... - @$(MKDIR) $(DESTDIR)$(libdir)/$(PACKAGE_TARNAME)-plugins - @$(INSTALL_PROGRAM) $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(DESTDIR)$(libdir)/$(PACKAGE_TARNAME)-plugins/$(MODULE_NAME)@DLLEXT@ - - @$(MKDIR) $(DESTDIR)$(libdir) - @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)$(libdir) - -$(DESTDIR)$(libdir)/$(PACKAGE_TARNAME)-plugins/$(MODULE_NAME)@DLLEXT@: \ - $(BINRLS)/$(LIBNAME) \ - $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ - - @echo $@ ... - @$(MKDIR) `dirname $@` - @$(INSTALL_PROGRAM) $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $@ - - @$(MKDIR) $(DESTDIR)$(libdir) - @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)$(libdir) - -$(BINRLS)/$(LIBNAME): \ - $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@ - - @echo $(basename $@) ... - @$(MKDIR) `dirname $@` - @$(LN_S) -f $(LIBNAME).@PACKAGE_MAJOR_VERSION@ $@ - -$(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@: \ - $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ - - @echo $(basename $@) ... - @$(MKDIR) `dirname $@` - @$(LN_S) -f $(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $@ - -$(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ - $(foreach SRC, $(basename $(API_SOURCES)), $(OBJRLS)/$(SRC).o) - - @echo $@ ... - @$(MKDIR) `dirname $@` - @$(LD) \ - $(LDFLAGS) \ - @DLL_LDFLAGS@ \ - -Wl,-soname,`basename $@` \ - -L$(BASEDIR)/.bin/Release \ - @STATIC_LDFLAGS@ \ - -o $@ $^ \ - $(API_LIBS) - -$(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@: \ - $(BINRLS)/$(LIBNAME) \ - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) - - @echo $@ ... - @$(MKDIR) `dirname $@` - @$(LD) \ - $(LDFLAGS) \ - @DLL_LDFLAGS@ \ - -Wl,-soname,$(MODULE_NAME)d \ - -L$(BASEDIR)/.bin/Release \ - -o $@ $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \ - $(PLUGIN_LIBS) - -pot: \ - $(BASEDIR)/.pot/plugins/$(MODULE_NAME).pot - -$(BASEDIR)/.pot/plugins/$(MODULE_NAME).pot: \ - $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(SRC).pot) - - @rm -f $@ - @mkdir -p `dirname $@` - @$(MSGCAT) --sort-output $^ > $@ - -$(SRCDIR): \ - clean - - @$(MKDIR) $@ - @$(INSTALL_DATA) *.c *.cc *.h *.in *.cbp $@ - - -#---[ Debug Targets ]-------------------------------------------------------------------- - -Debug: \ - $(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@ - -test: \ - $(BINDBG)/$(LIBNAME) \ - $(OBJDBG)/testprogram.o - - $(LD) -Wl,--rpath,$(BINDBG) -o $(BINDBG)/$(MODULE_NAME)@EXEEXT@ $(OBJDBG)/testprogram.o -L$(BINDBG) $(LIBS) -l$(MODULE_NAME) - -$(BINDBG)/$(LIBNAME): \ - $(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@ - - @echo $(basename $@) ... - @$(MKDIR) `dirname $@` - @$(LN_S) -f $(LIBNAME).@PACKAGE_MAJOR_VERSION@ $@ - -$(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@: \ - $(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ - - @echo $(basename $@) ... - @$(MKDIR) `dirname $@` - @$(LN_S) -f $(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $@ - -$(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ - $(foreach SRC, $(basename $(API_SOURCES)), $(OBJDBG)/$(SRC).o) - - @echo $@ ... - @$(MKDIR) `dirname $@` - @$(LD) \ - -shared \ - -Wl,-soname,`basename $@` \ - $(LDFLAGS) \ - -L$(BASEDIR)/.bin/Debug \ - -o $@ $^ \ - $(API_LIBS) - -$(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@: \ - $(BINDBG)/$(LIBNAME) \ - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) - - @echo $@ ... - @$(MKDIR) `dirname $@` - @$(LD) \ - -shared \ - -Wl,-soname,$(MODULE_NAME)d,--rpath,$(BASEDIR)/.bin/Debug \ - $(LDFLAGS) \ - -L$(BASEDIR)/.bin/Debug \ - -o $@ $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \ - $(PLUGIN_LIBS) - - -#---[ Clean Targets]--------------------------------------------------------------------- - -cleanDebug: - - @rm -fr $(BINDBG)/$(MODULE_NAME)@DLLEXT@ \ - $(OBJDBG) \ - dbus-glue.h - -cleanRelease: - - @rm -fr $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \ - $(OBJRLS) \ - dbus-glue.h - - @rm -fr $(POTDIR) - -clean: \ - cleanDebug \ - cleanRelease - - diff --git a/src/hllapi/calls.cc b/src/hllapi/calls.cc deleted file mode 100644 index 4d2d4da..0000000 --- a/src/hllapi/calls.cc +++ /dev/null @@ -1,826 +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 - * - * Este programa está nomeado como calls.cc e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - - #include - #include - #include - - #include - #include - #include "client.h" - - using namespace std; - using namespace PW3270_NAMESPACE; - -/*--[ Globals ]--------------------------------------------------------------------------------------*/ - - static session * hSession = NULL; - static time_t hllapi_timeout = 120; - -/*--[ Implement ]------------------------------------------------------------------------------------*/ - - HLLAPI_API_CALL hllapi_init(LPSTR mode) - { - trace("%s(%s)",__FUNCTION__,mode); - - try - { - if(hSession) - delete hSession; - hSession = session::create(mode); - - if(!hSession) { - return HLLAPI_STATUS_UNAVAILABLE; - } - - hSession->set_display_charset(); - - trace("hSession=%p",hSession); - } - catch(std::exception &e) - { - trace("Error \"%s\"",e.what()); - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return HLLAPI_STATUS_SUCCESS; - - } - - HLLAPI_API_CALL hllapi_deinit(void) - { - trace("%s()",__FUNCTION__); - - try - { - if(hSession) - { - delete hSession; - hSession = NULL; - } - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_get_revision(void) - { - try - { - return atoi(session::get_default()->get_revision().c_str()); - } - catch(std::exception &e) - { - return -1; - } - return (DWORD) -1; - } - - HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait) - { - try - { - session::get_default()->connect(uri,hllapi_timeout); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return hllapi_get_state(); - } - - HLLAPI_API_CALL hllapi_is_connected(void) - { - if(!session::has_default()) - { - return 0; - } - - return session::get_default()->is_connected(); - } - - HLLAPI_API_CALL hllapi_get_state(void) - { - switch(hllapi_get_message_id()) - { - case LIB3270_MESSAGE_NONE: // 0 - No message - return HLLAPI_STATUS_SUCCESS; // keyboard was unlocked and ready for input. - - case LIB3270_MESSAGE_DISCONNECTED: // 4 - Disconnected from host - return HLLAPI_STATUS_DISCONNECTED; // Your application program was not connected to a valid session. - - case LIB3270_MESSAGE_MINUS: - case LIB3270_MESSAGE_PROTECTED: - case LIB3270_MESSAGE_NUMERIC: - case LIB3270_MESSAGE_OVERFLOW: - case LIB3270_MESSAGE_INHIBIT: - case LIB3270_MESSAGE_KYBDLOCK: - return HLLAPI_STATUS_KEYBOARD_LOCKED; // keyboard is locked. - - case LIB3270_MESSAGE_SYSWAIT: - case LIB3270_MESSAGE_TWAIT: - case LIB3270_MESSAGE_AWAITING_FIRST: - case LIB3270_MESSAGE_X: - case LIB3270_MESSAGE_RESOLVING: - case LIB3270_MESSAGE_CONNECTING: - return HLLAPI_STATUS_WAITING; // time-out while still busy (in XCLOCK or XSYSTEM in X) for the 3270 terminal emulation. - } - - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - HLLAPI_API_CALL hllapi_disconnect(void) - { - session::get_default()->disconnect(); - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - session::get_default()->wait_for_ready(seconds); - - return hllapi_get_state(); - } - - HLLAPI_API_CALL hllapi_wait(WORD seconds) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - session::get_default()->wait(seconds); - - return hllapi_get_state(); - } - - HLLAPI_API_CALL hllapi_get_message_id(void) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - return session::get_default()->get_program_message(); - } - - HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - if(!(buffer && *buffer)) - return HLLAPI_STATUS_SYSTEM_ERROR; - - try - { - size_t sz = strlen(buffer); - string str = session::get_default()->get_string_at(row,col,sz); - strncpy(buffer,str.c_str(),sz); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_enter(void) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - return session::get_default()->enter(); - } - - HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - try - { - session::get_default()->set_string_at(row,col,text); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text) - { - - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - int rc = HLLAPI_STATUS_SYSTEM_ERROR; - - try - { - rc = session::get_default()->cmp_string_at(row,col,text); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return rc; - } - - HLLAPI_API_CALL hllapi_find_text(LPSTR text) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - return (int) session::get_default()->find_string((const char *) text, false); - } - - HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms) - { - session::get_default()->set_unlock_delay(ms); - return 0; - } - - HLLAPI_API_CALL hllapi_set_charset(LPSTR text) - { - try - { - - session::get_default()->set_display_charset(NULL, (const char *) text); - - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return 0; - } - - HLLAPI_API_CALL hllapi_pfkey(WORD key) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - return session::get_default()->pfkey(key); - } - - HLLAPI_API_CALL hllapi_pakey(WORD key) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - return session::get_default()->pakey(key); - } - - HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir) - { - #ifdef _WIN32 - HKEY hKey = 0; - unsigned long datalen = strlen(datadir); - - *datadir = 0; - - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) - { - unsigned long datatype; // #defined in winnt.h (predefined types 0-11) - if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS) - *datadir = 0; - RegCloseKey(hKey); - } -#endif // _WIN32 - - return *datadir; - } - - HLLAPI_API_CALL hllapi_setcursor(WORD pos) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - session::get_default()->set_cursor_addr(pos-1); - - return HLLAPI_STATUS_SUCCESS; - - } - - HLLAPI_API_CALL hllapi_set_cursor_address(WORD pos) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - session::get_default()->set_cursor_addr(pos-1); - - return HLLAPI_STATUS_SUCCESS; - - } - - HLLAPI_API_CALL hllapi_get_cursor_address() - { - return session::get_default()->get_cursor_addr()+1; - } - - HLLAPI_API_CALL hllapi_getcursor() - { - return session::get_default()->get_cursor_addr()+1; - } - - HLLAPI_API_CALL hllapi_get_screen(WORD offset, LPSTR buffer, WORD len) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - int rc = HLLAPI_STATUS_SYSTEM_ERROR; - - if(offset < 1) - { - return HLLAPI_STATUS_BAD_PARAMETER; - } - - offset--; - - if(!session::has_default()) - { - return HLLAPI_STATUS_DISCONNECTED; - } - - if(!(buffer && *buffer)) { - return HLLAPI_STATUS_BAD_PARAMETER; - } - - try - { - size_t szBuffer; - - if(len > 0) - { - szBuffer = (size_t) len; - } - else - { - return HLLAPI_STATUS_BAD_PARAMETER; - } - - memset(buffer,' ',szBuffer); - - string str = session::get_default()->get_string(offset,szBuffer,false); - strncpy(buffer,str.c_str(),szBuffer); - rc = HLLAPI_STATUS_SUCCESS; - } - catch(std::exception &e) - { - rc = HLLAPI_STATUS_SYSTEM_ERROR; - } - - return rc; - } - - HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - try - { - session::get_default()->input_string(buffer); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_erase(void) - { - try - { - session::get_default()->erase(); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_erase_eof(void) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - try - { - session::get_default()->erase_eof(); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_erase_eol(void) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - try - { - session::get_default()->erase_eol(); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_erase_input(void) - { - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - try - { - session::get_default()->erase_input(); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_action(LPSTR buffer) { - try - { - session::get_default()->action((const char *) buffer); - } - catch(std::exception &e) - { - return HLLAPI_STATUS_SYSTEM_ERROR; - } - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_print(void) - { - return session::get_default()->print(); - } - - char * hllapi_get_string(int offset, size_t len) - { - try - { - string str = session::get_default()->get_string(offset-1,len); - char * ret = strdup(str.c_str()); - return ret; - } - catch(std::exception &e) - { - } - - return NULL; - } - - void hllapi_free(void *p) - { - free(p); - } - - HLLAPI_API_CALL hllapi_reset(void) - { - return HLLAPI_STATUS_SUCCESS; - } - - HLLAPI_API_CALL hllapi_input_string(LPSTR input, WORD length) - { - static const char control_char = '@'; - - size_t szText; - char * text; - int rc = 0; - - if(!hllapi_is_connected()) { - return HLLAPI_STATUS_DISCONNECTED; - } - - if(!input) - { - return HLLAPI_STATUS_BAD_PARAMETER; - } - - if(length > 0 ) - szText = length; - else - szText = strlen(input); - - text = (char *) malloc(szText+2); - memcpy(text,input,szText); - text[szText] = 0; - - trace("input[%s]",text); - - if(strchr(text,control_char)) - { - // Convert control char - char * buffer = text; - char * ptr; - - for(ptr = strchr(text,control_char);ptr;ptr = strchr(buffer,control_char)) - { - *(ptr++) = 0; - - trace("input[%s]",buffer); - hllapi_emulate_input(buffer,-1,0); - - switch(*(ptr++)) - { - case 'P': // Print - rc = hllapi_print(); - break; - - case 'E': // Enter - hllapi_enter(); - break; - - case 'F': // Erase EOF - hllapi_erase_eof(); - break; - - case '1': // PF1 - hllapi_pfkey(1); - break; - - case '2': // PF2 - hllapi_pfkey(2); - break; - - case '3': // PF3 - hllapi_pfkey(3); - break; - - case '4': // PF4 - hllapi_pfkey(4); - break; - - case '5': // PF5 - hllapi_pfkey(5); - break; - - case '6': // PF6 - hllapi_pfkey(6); - break; - - case '7': // PF7 - hllapi_pfkey(7); - break; - - case '8': // PF8 - hllapi_pfkey(8); - break; - - case '9': // PF9 - hllapi_pfkey(9); - break; - - case 'a': // PF10 - hllapi_pfkey(10); - break; - - case 'b': // PF11 - hllapi_pfkey(11); - break; - - case 'c': // PF12 - hllapi_pfkey(12); - break; - - case 'd': // PF13 - hllapi_pfkey(13); - break; - - case 'e': // PF14 - hllapi_pfkey(14); - break; - - case 'f': // PF15 - hllapi_pfkey(15); - break; - - case 'g': // PF16 - hllapi_pfkey(16); - break; - - case 'h': // PF17 - hllapi_pfkey(17); - break; - - case 'i': // PF18 - hllapi_pfkey(18); - break; - - case 'j': // PF19 - hllapi_pfkey(19); - break; - - case 'k': // PF20 - hllapi_pfkey(20); - break; - - case 'l': // PF21 - hllapi_pfkey(21); - break; - - case 'm': // PF22 - hllapi_pfkey(22); - break; - - case 'n': // PF23 - hllapi_pfkey(23); - break; - - case 'o': // PF24 - hllapi_pfkey(24); - break; - - case '@': // Send '@' character - hllapi_emulate_input((LPSTR) "@",-1,0); - break; - - case 'x': // PA1 - hllapi_pakey(1); - break; - - case 'y': // PA2 - hllapi_pakey(2); - break; - - case 'z': // PA3 - hllapi_pakey(3); - break; - - case 'B': // PC_LEFTTAB = "@B" - break; - - case 'T': // PC_RIGHTTAB = "@T" - break; - - case 'N': // PC_NEWLINE = "@N" - break; - - case 'C': // PC_CLEAR = "@C" - hllapi_erase_input(); - break; - - case 'D': // PC_DELETE = "@D" - break; - - case 'H': // PC_HELP = "@H" - break; - - case 'I': // PC_INSERT = "@I" - break; - - case 'L': // PC_CURSORLEFT = "@L" - break; - - case 'R': // PC_RESET = "@R" - hllapi_reset(); - break; - - case 'U': // PC_CURSORUP = "@U" - break; - - case 'V': // PC_CURSORDOWN = "@V" - break; - - case 'Z': // PC_CURSORRIGHT = "@Z" - break; - - case '0': // PC_HOME = "@0" - break; - - case 'p': // PC_PLUSKEY = "@p" - break; - - case 'q': // PC_END = "@q" - break; - - case 's': // PC_SCRLK = "@s" - break; - - case 't': // PC_NUMLOCK = "@t" - break; - - case 'u': // PC_PAGEUP = "@u" - break; - - case 'v': // PC_PAGEDOWN = "@v" - break; - - case '/': // PC_OVERRUNOFQUEUE = "@/" ' Queue overflow, used in Get Key only - break; - - case '$': // PC_ALTCURSOR = "@$" ' Presentation Manager only, unused in VB environment - break; - - case '<': // PC_BACKSPACE = "@<" - break; - - -/* - -Global Const PC_TEST = "@A@C" -Global Const PC_WORDDELETE = "@A@D" -Global Const PC_FIELDEXIT = "@A@E" -Global Const PC_ERASEINPUT = "@A@F" -Global Const PC_SYSTEMREQUEST = "@A@H" -Global Const PC_INSERTTOGGLE = "@A@I" -Global Const PC_CURSORSELECT = "@A@J" -Global Const PC_CURSLEFTFAST = "@A@L" -Global Const PC_GETCURSOR = "@A@N" -Global Const PC_LOCATECURSOR = "@A@O" -Global Const PC_ATTENTION = "@A@Q" -Global Const PC_DEVICECANCEL = "@A@R" -Global Const PC_PRINTPS = "@A@T" -Global Const PC_CURSUPFAST = "@A@U" -Global Const PC_CURSDOWNFAST = "@A@V" -Global Const PC_HEX = "@A@X" -Global Const PC_FUNCTIONKEY = "@A@Y" -Global Const PC_CURSRIGHTFAST = "@A@Z" - -Global Const PC_REVERSEVIDEO = "@A@9" -Global Const PC_UNDERSCORE = "@A@b" -Global Const PC_BLINK = "@A@c" -Global Const PC_RED = "@A@d" -Global Const PC_PINK = "@A@e" -Global Const PC_GREEN = "@A@f" -Global Const PC_YELLOW = "@A@g" -Global Const PC_BLUE = "@A@h" -Global Const PC_TURQOISE = "@A@i" -Global Const PC_WHITE = "@A@j" -Global Const PC_RSTHOSTCOLORS = "@A@l" -Global Const PC_PRINTPC = "@A@t" - -Global Const PC_FIELDMINUS = "@A@-" -Global Const PC_FIELDPLUS = "@A@+" - -*/ - - } - - buffer = ptr; - - } - - if(*buffer) - hllapi_emulate_input(buffer,-1,0); - - } - else - { - hllapi_emulate_input(text,szText,0); - } - - free(text); - - return rc; - } - diff --git a/src/hllapi/client.h b/src/hllapi/client.h deleted file mode 100644 index 640e60a..0000000 --- a/src/hllapi/client.h +++ /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., 59 Temple - * Place, Suite 330, Boston, MA, 02111-1307, USA - * - * Este programa está nomeado como private.h e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - - #include - - #ifndef ETIMEDOUT - #define ETIMEDOUT 1238 - #endif // ETIMEDOUT - - #define PIPE_BUFFER_LENGTH 8192 - - #define set_active(x) /* x */ - - #if defined(DEBUG) && defined(_WIN32) - #undef trace - #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); - #endif // DEBUG - - #ifdef __cplusplus - extern "C" { - #endif - - char * hllapi_get_string(int offset, size_t len); - void hllapi_free(void *p); - - #ifdef __cplusplus - } /* end of extern "C" */ - #endif - - diff --git a/src/hllapi/environ.bat b/src/hllapi/environ.bat deleted file mode 100644 index c77f38a..0000000 --- a/src/hllapi/environ.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo off - -set VC=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC -set WINSDK=C:\Program Files (x86)\Windows Kits\8.1 -set PATH=%PATH%;"%VC%\bin";"%WINSDK%\bin\x86\" - diff --git a/src/hllapi/hllapi.c b/src/hllapi/hllapi.c deleted file mode 100644 index d562e1c..0000000 --- a/src/hllapi/hllapi.c +++ /dev/null @@ -1,466 +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 - * - * Este programa está nomeado como hllapi.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - - #include - #include - #include - #include - #include - #include - #include - #include - #include "client.h" - - /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ - - static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc); - static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc); - static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc); - static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc); - static int copy_str_to_ps(char *buffer, unsigned short *length, unsigned short *rc); - static int search_ps(char *buffer, unsigned short *length, unsigned short *rc); - static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc); - static int wait_system(char *buffer, unsigned short *length, unsigned short *rc); - static int reset_system(char *buffer, unsigned short *length, unsigned short *rc); - static int pause_system(char *buffer, unsigned short *length, unsigned short *rc); - static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc); - - static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); - static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); - static int input_string(char *buffer, unsigned short *length, unsigned short *rc); - - static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc); - -/*--[ Globals ]--------------------------------------------------------------------------------------*/ - - static const struct _hllapi_call - { - unsigned long func; - int (*exec)(char *buffer, unsigned short *length, unsigned short *rc); - } hllapi_call[] = - { - { HLLAPI_CMD_CONNECTPS, connect_ps }, - { HLLAPI_CMD_DISCONNECTPS, disconnect_ps }, - { HLLAPI_CMD_GETREVISION, get_library_revision }, - { HLLAPI_CMD_QUERYCURSOR, get_cursor_position }, - { HLLAPI_CMD_SETCURSOR, set_cursor_position }, - { HLLAPI_CMD_COPYPSTOSTR, copy_ps_to_str }, - { HLLAPI_CMD_INPUTSTRING, input_string }, - { HLLAPI_CMD_WAIT, wait_system }, - { HLLAPI_CMD_COPYPS, copy_ps }, - { HLLAPI_CMD_SEARCHPS, search_ps }, - { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps }, - { HLLAPI_CMD_SENDFILE, invalid_request }, - { HLLAPI_CMD_RECEIVEFILE, invalid_request }, - { HLLAPI_RESET_SYSTEM, reset_system }, - { HLLAPI_CMD_PAUSE, pause_system }, - { HLLAPI_SET_SESSION_PARAMETERS, set_session_parameters } - - }; - - static enum _pause_mode - { - PAUSE_MODE_IPAUSE, ///< @brief Interruptible pause. After the Start Host Notification (23) function is executed, a host event satisfies a pause. - PAUSE_MODE_FPAUSE ///< @brief A full-duration pause lasts for however long you specified in the Pause (18) function. - } pause_mode = PAUSE_MODE_IPAUSE; - -/*--[ Implement ]------------------------------------------------------------------------------------*/ - -HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc) -{ - unsigned int f; - - trace("%s(%d)",__FUNCTION__,*func); - - for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++) - { - if(hllapi_call[f].func == *func) - { - int status = hllapi_call[f].exec(buffer,length,rc); - trace("hllapi(%d) exits with rc=%d",*func,status); - return status; - } - } - - trace("hllapi(%d) failed",*func); - - *rc = HLLAPI_STATUS_UNSUPPORTED; - return *rc; - -} - -static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc) -{ - *rc = HLLAPI_STATUS_BAD_PARAMETER; - return *rc; -} - -static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc) -{ - char *tempbuffer = NULL; - - trace("%s: len=%d buflen=%d",__FUNCTION__,*length,(int) strlen(buffer)); - - if(strlen(buffer) > *length) - buffer[*length] = 0; - - if(!strrchr(buffer,':')) - { - int sz = strlen(buffer); - - tempbuffer = (char *) malloc(sz+2); - strcpy(tempbuffer,buffer); - tempbuffer[sz-1] = ':'; - tempbuffer[sz] = buffer[sz-1]; - tempbuffer[sz+1] = 0; - buffer = tempbuffer; - } - - *rc = hllapi_init(buffer); - - if(tempbuffer) - free(tempbuffer); - - return 0; -} - -static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc) -{ - *rc = hllapi_deinit(); - return 0; -} - -static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc) -{ - *rc = hllapi_get_revision(); - return 0; -} - -static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) -{ - int pos = hllapi_getcursor(); - - trace("%s(%d)",__FUNCTION__,pos); - - if(pos < 0) - return -1; - - *rc = pos; - return 0; -} - -static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) -{ - trace("%s(%d)",__FUNCTION__,*rc); - *rc = hllapi_setcursor(*rc); - return 0; -} - -static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc) -{ - - // Length Length of the target data string. - // PS Position Position within the host presentation space of the first byte in your target data string. - *rc = hllapi_get_screen(*rc,buffer,*length); - - return 0; -} - -static int input_string(char *buffer, unsigned short *length, unsigned short *rc) -{ - *rc = hllapi_input_string(buffer,*length); - return 0; -} - -static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) -{ - /* - * Data String Target string for search. - * Length Length of the target data string. Overridden in EOT mode. - * PS Position Position within the host presentation space where the search is to begin (SRCHFRWD option) or to end - * (SRCHBKWD option). Overridden in SRCHALL (default) mode. - * - * Return in *ps: - * - * = 0 The string was not found. - * > 0 The string was found at the indicated host presentation space position. - * - * Return code: - * - * 0 The Search Presentation Space function was successful. - * 1 Your program is not connected to a host session. - * 2 An error was made in specifying parameters. - * 7 The host presentation space position is not valid. - * 9 A system error was encountered. - * 24 The search string was not found. - * - */ - size_t szBuffer = strlen(buffer); - char * text; - int rc = HLLAPI_STATUS_SYSTEM_ERROR; - - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - if(*length < szBuffer) - szBuffer = *length; - - - text = hllapi_get_string(*ps,szBuffer); - if(!text) - return HLLAPI_STATUS_SYSTEM_ERROR; - - if(strncmp(text,buffer,szBuffer)) - { - // String not found - *ps = 0; - rc = HLLAPI_STATUS_NOT_FOUND; - } - else - { - // String found - *ps = 1; - rc = HLLAPI_STATUS_SUCCESS; - } - - hllapi_free(text); - - return rc; -} - -static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) -{ - /* - * Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space is configured. When the Set Session Parameters (9) function with the EAB option is issued, the length of the data string must be at least twice the length of the presentation space. - * DBCS Only: When the EAD option is specified, the length of the data string must be at least three times the length of the presentation space. When both the EAB and EAD options are specified, the length of the data string must be at least four times the length of the presentation space. - * - * Length NA (the length of the host presentation space is implied). - * PS Position NA. - * - * Return values: - * - * 0 The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked. - * 1 Your program is not connected to a host session. - * 4 The host presentation space contents were copied. The connected host presentation space was waiting for host response. - * 5 The host presentation space was copied. The keyboard was locked. - * 9 A system error was encountered. - * - */ - size_t szBuffer = strlen(buffer); - char * text; - - if(!hllapi_is_connected()) - return HLLAPI_STATUS_DISCONNECTED; - - text = hllapi_get_string(1, szBuffer); - - if(!text) - return HLLAPI_STATUS_SYSTEM_ERROR; - - memcpy(buffer,text,szBuffer); - - hllapi_free(text); - - return hllapi_get_state(); -} - -static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) -{ - /* - * Checks the status of the host-connected presentation space. If the session is - * waiting for a host response (indicated by XCLOCK (X []) or XSYSTEM), the Wait - * function causes HLLAPI to wait up to 1 minute to see if the condition clears. - * - */ - - /* - * Return Code Definition - * - * HLLAPI_STATUS_SUCCESS 0 The keyboard is unlocked and ready for input. - * HLLAPI_STATUS_DISCONNECTED 1 Your application program is not connected to a valid session. - * HLLAPI_STATUS_TIMEOUT 4 Timeout while still in XCLOCK (X []) or XSYSTEM. - * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The keyboard is locked. - * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered. - * - */ - - /* - time_t end = time(0) + 60; - - while(time(0) < end) - { - int state = hllapi_get_state(); - - if(state != HLLAPI_STATUS_WAITING) - return state; - - hllapi_wait(1); - - } - - return HLLAPI_STATUS_TIMEOUT; - */ - - int state = hllapi_wait_for_ready(60); - return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state); - -} - -static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps) -{ - /* - * Call Parameters - * - * Data String of ASCII data to be copied into the host presentation space. - * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode. - * PS Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space. - * - * Return Parameters - * - * HLLAPI_STATUS_SUCCESS 0 The Copy String to Presentation Space function was successful. - * HLLAPI_STATUS_DISCONNECTED 1 Your program is not connected to a host session. - * HLLAPI_STATUS_BAD_PARAMETER 2 Parameter error or zero length for copy. - * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte). - * 6 The copy was completed, but the data was truncated. - * 7 The host presentation space position is not valid. - * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered. - * - */ - size_t szText = strlen(text); - - if(*length < szText) - szText = *length; - - if(!szText) - return HLLAPI_STATUS_BAD_PARAMETER; - - switch(hllapi_get_message_id()) - { - case LIB3270_MESSAGE_NONE: - break; - - case LIB3270_MESSAGE_DISCONNECTED: - return HLLAPI_STATUS_DISCONNECTED; - - case LIB3270_MESSAGE_MINUS: - case LIB3270_MESSAGE_PROTECTED: - case LIB3270_MESSAGE_NUMERIC: - case LIB3270_MESSAGE_OVERFLOW: - case LIB3270_MESSAGE_INHIBIT: - case LIB3270_MESSAGE_KYBDLOCK: - return HLLAPI_STATUS_KEYBOARD_LOCKED; - - default: - return HLLAPI_STATUS_SYSTEM_ERROR; - } - - return hllapi_emulate_input(text,szText,0); -} - -static int reset_system(char *buffer, unsigned short *length, unsigned short *rc) -{ - return hllapi_reset(); -} - - -static int pause_system(char *buffer, unsigned short *length, unsigned short *rc) -{ - if(!*length) - { - // If you use the IPAUSE option and the pause value is zero, then the function - // waits up to 2400 half-second intervals, unless interrupted sooner. If you use the - // FPAUSE option and the pause value is zero, then the function returns - // immediately. - - if(pause_mode == PAUSE_MODE_FPAUSE) - { - return HLLAPI_STATUS_SUCCESS; - } - return hllapi_wait_for_ready(1200); - } - - if(pause_mode == PAUSE_MODE_FPAUSE) - { - // Pause fixo - Aguarda pelo tempo informado, independente de eventos. - return hllapi_wait( (*length) / 2); - } - - // Pause "flexivel", aguarda mudança no conteúdo da tela!!! - - // #warning Mudar comportamento na lib! - - return hllapi_wait_for_ready((*length) / 2); -} - -static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc) -{ - if(!(*length && buffer && *buffer)) - { - return HLLAPI_STATUS_BAD_PARAMETER; - } - - *rc = hllapi_set_session_parameter(buffer, *length, *rc); - - return 0; -} - -HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value) -{ - if(!param) - { - return HLLAPI_STATUS_BAD_PARAMETER; - } - - if(!len) - { - len = strlen(param); - } - - if(!strncasecmp(param,"IPAUSE",len)) - { - // IPAUSE - pause_mode = PAUSE_MODE_IPAUSE; - } - else if(!strncasecmp(param,"FPAUSE",len)) - { - // FPAUSE - pause_mode = PAUSE_MODE_FPAUSE; - } - else if(!strncasecmp(param,"UNLOCKDELAY",len)) - { - // UNLOCKDELAY - hllapi_set_unlock_delay(value); - } - else - { - return HLLAPI_STATUS_BAD_PARAMETER; - } - - return HLLAPI_STATUS_SUCCESS; -} diff --git a/src/hllapi/hllapi.cbp b/src/hllapi/hllapi.cbp deleted file mode 100644 index f30461a..0000000 --- a/src/hllapi/hllapi.cbp +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - diff --git a/src/hllapi/idlcomp.bat b/src/hllapi/idlcomp.bat deleted file mode 100644 index fe0bdce..0000000 --- a/src/hllapi/idlcomp.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -midl.exe /I "%WINSDK%\Include\um" /I "%WINSDK%\Include\shared" /cpp_cmd "cl.exe" pw3270.idl diff --git a/src/hllapi/maketest.sh b/src/hllapi/maketest.sh deleted file mode 100755 index 293e64b..0000000 --- a/src/hllapi/maketest.sh +++ /dev/null @@ -1 +0,0 @@ -make LIB3270_MODE=Debug test diff --git a/src/hllapi/pw3270.idl b/src/hllapi/pw3270.idl deleted file mode 100644 index b05f3f9..0000000 --- a/src/hllapi/pw3270.idl +++ /dev/null @@ -1,53 +0,0 @@ -// This is the type library for libhllapi.dll - -// -// References: -// -// http://support.microsoft.com/kb/189133 -// http://msdn.microsoft.com/en-us/library/windows/desktop/aa367300(v=vs.85).aspx -// -[ - // Use GUIDGEN.EXE to create the UUID that uniquely identifies - // this library on the user's system. NOTE: This must be done!! - uuid(4CC73F7D-5C10-4313-8FFD-F01999A44656), - - // This helpstring defines how the library will appear in the - // References dialog of VB. - helpstring("PW3270 HLLAPI typelib"), - - // Assume standard English locale. - lcid(0x0409), - - // Assign a version number to keep track of changes. - version(5.0) -] - -library HLLAPI -{ - - // Now define the module that will "declare" your C functions. - [ - helpstring("HLLAPI calls for pw3270"), - - version(5.0), - - // Give the name of your DLL here. - dllname("libhllapi.dll") - ] - - module hllApiFunctions - { - [ - helpstring("Initialize pw3270´s instance."), - entry("hllapi_init") - ] - // The [in], [out], and [in, out] keywords tell the Automation - // client which direction parameters need to be passed. Some - // calls can be optimized if a function only needs a parameter - // to be passed one-way. - DWORD __stdcall hllapi_init( [in] LPSTR mode); - - - } // End of Module - -}; // End of Library diff --git a/src/hllapi/remotectl.h b/src/hllapi/remotectl.h deleted file mode 100644 index e53ada2..0000000 --- a/src/hllapi/remotectl.h +++ /dev/null @@ -1,84 +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. 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 remotectl.h e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - * Agradecimento: - * - * Hélio Passos - * - */ - - #define ENABLE_NLS - #define GETTEXT_PACKAGE PACKAGE_NAME - - #include - #include - #include - - #include - #include - #include - - typedef struct _remotequery - { -#ifdef _WIN32 - HANDLE hPipe; /**< Pipe handle (for response) */ -#endif // _WIN32 - - H3270 * hSession; /**< 3270 Session */ - int cmd; /**< Command */ - int rc; /**< Response status */ - - int pos; - unsigned short length; /**< Query string length */ - const gchar * text; /**< Query string */ - - } QUERY; - - G_GNUC_INTERNAL void enqueue_request(QUERY *qry); - G_GNUC_INTERNAL void request_complete(QUERY *qry, int rc, const gchar *text); - - G_GNUC_INTERNAL void request_status(QUERY *qry, int rc); - G_GNUC_INTERNAL void request_value(QUERY *qry, int rc, unsigned int value); - G_GNUC_INTERNAL void request_buffer(QUERY *qry, int rc, size_t sz, const gpointer buffer); - -// int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc); - - -#ifdef _WIN32 - - #define PIPE_BUFFER_LENGTH 8192 - - void init_source_pipe(HANDLE hPipe); - void popup_lasterror(const gchar *fmt, ...); - -#endif // _WIN32 - - - - - - diff --git a/src/hllapi/windows/resources.rc.in b/src/hllapi/windows/resources.rc.in deleted file mode 100644 index bca0509..0000000 --- a/src/hllapi/windows/resources.rc.in +++ /dev/null @@ -1,29 +0,0 @@ -#include - -VS_VERSION_INFO VERSIONINFO -FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 -PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 - -BEGIN - - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "FileDescription", "pw3270 HLLAPI Client Module\0" - VALUE "CompanyName", "Banco do Brasil S/A.\0" - VALUE "FileVersion", "@WIN32_VERSION@\0" - VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" - VALUE "OriginalFilename", "hllapi@DLLEXT@\0" - VALUE "ProductName", "pw3270\0" - VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" - END - END - - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 0x04E4 - END - -END - diff --git a/src/include/config.h.in b/src/include/config.h.in index ca153ed..e4353f7 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -27,15 +27,12 @@ * */ -#ifndef LIBV3270_CONFIG_INCLUDED +#ifndef CONFIG_H_INCLUDED - #define LIBV3270_CONFIG_INCLUDED 1 + #define CONFIG_H_INCLUDED 1 #undef PACKAGE_NAME #undef PACKAGE_VERSION #undef PACKAGE_RELEASE - #undef HAVE_GNOME - #undef HAVE_GTKMAC - -#endif /* LIBV3270_CONFIG_INCLUDED */ +#endif /* CONFIG_H_INCLUDED */ diff --git a/src/include/lib3270/hllapi.h b/src/include/lib3270/hllapi.h new file mode 100644 index 0000000..640e60a --- /dev/null +++ b/src/include/lib3270/hllapi.h @@ -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., 59 Temple + * Place, Suite 330, Boston, MA, 02111-1307, USA + * + * Este programa está nomeado como private.h e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include + + #ifndef ETIMEDOUT + #define ETIMEDOUT 1238 + #endif // ETIMEDOUT + + #define PIPE_BUFFER_LENGTH 8192 + + #define set_active(x) /* x */ + + #if defined(DEBUG) && defined(_WIN32) + #undef trace + #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); + #endif // DEBUG + + #ifdef __cplusplus + extern "C" { + #endif + + char * hllapi_get_string(int offset, size_t len); + void hllapi_free(void *p); + + #ifdef __cplusplus + } /* end of extern "C" */ + #endif + + diff --git a/src/ipc3270c/linux/daemon.h b/src/ipc3270c/linux/daemon.h deleted file mode 100644 index 152a618..0000000 --- a/src/ipc3270c/linux/daemon.h +++ /dev/null @@ -1,46 +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 daemon.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * - * Referencias: - * - * https://live.gnome.org/DBusGlibBindings - * - */ - - #include "service.h" - -/*---[ Globals ]---------------------------------------------------------------------------------*/ - - G_GNUC_INTERNAL GMainLoop * main_loop; - - -/*---[ Prototipes ]------------------------------------------------------------------------------*/ - - G_GNUC_INTERNAL void pw3270_dbus_register_io_handlers(void); - diff --git a/src/ipc3270c/linux/globals.h b/src/ipc3270c/linux/globals.h deleted file mode 100644 index 6568a54..0000000 --- a/src/ipc3270c/linux/globals.h +++ /dev/null @@ -1,67 +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 globals.h e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * - */ - -#ifndef PW3270_DBUS_GLOBALS_H_INCLUDED - - #define PW3270_DBUS_GLOBALS_H_INCLUDED 1 - - #include - #include - #include - - #include - #include - #include - #include - -#if ! GLIB_CHECK_VERSION(2,44,0) - - G_GNUC_INTERNAL void hllapi_autoptr_cleanup_generic_gfree(void *p); - #define g_autofree __attribute__((cleanup(hllapi_autoptr_cleanup_generic_gfree))) - -#endif // ! GLIB(2,44,0) - - // - // Disabling warning on unused-function defined in dbus-glib-bindings.h - // warning: 'org_freedesktop_DBus_reload_config' defined but not used [-Wunused-function] ... - // - #pragma GCC diagnostic ignored "-Wunused-function" - - #include - #include - #include - - #define ERROR_DOMAIN g_quark_from_static_string("pw3270DBUS") - - G_GNUC_INTERNAL gpointer pw3270_dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path); - - -#endif // PW3270_DBUS_GLOBALS_H_INCLUDED diff --git a/src/ipc3270c/linux/gobject.c b/src/ipc3270c/linux/gobject.c deleted file mode 100644 index 9ab17dc..0000000 --- a/src/ipc3270c/linux/gobject.c +++ /dev/null @@ -1,621 +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 gobject.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * - * Referencias: - * - * https://live.gnome.org/DBusGlibBindings - * - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "service.h" - -/*---[ Globals ]---------------------------------------------------------------------------------*/ - - -/*---[ Implement ]-------------------------------------------------------------------------------*/ - -G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT) - -static void pw3270_dbus_finalize(GObject *object) -{ - G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object); -} - - -static void pw3270_dbus_class_init(PW3270DbusClass *klass) -{ - GObjectClass *object_class; - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = pw3270_dbus_finalize; - debug("%s",__FUNCTION__); -} - -static void pw3270_dbus_init(PW3270Dbus *object) -{ - debug("%s(%p)",__FUNCTION__,object); -} - -PW3270Dbus * pw3270_dbus_new(void) -{ - return (PW3270Dbus *) g_object_new(PW3270_TYPE_DBUS, NULL); -} - -void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - debug("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_revision()); -} - -void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) -{ - H3270 *hSession = pw3270_dbus_get_session_handle(PW3270_DBUS(object)); - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - - if(uri && *uri) - { - lib3270_set_url(hSession,uri); - g_message("Connecting to \"%s\" by remote request",lib3270_get_url(hSession)); - } - else - { - g_message("%s","Connecting by remote request"); - } - - dbus_g_method_return(context,lib3270_reconnect(hSession,0)); -} - -void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - - g_message("Changing host to \"%s\" by remote request",uri); - - dbus_g_method_return(context,lib3270_set_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri) != 0); -} - -void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)))); -} - - -void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - - g_message("Disconnecting by remote request"); - lib3270_disconnect(pw3270_dbus_get_session_handle(object)); - dbus_g_method_return(context,0); -} - -void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object))); -} - -void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_connection_state(pw3270_dbus_get_session_handle(object))); -} - -void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_secure(pw3270_dbus_get_session_handle(object))); -} - -GError * pw3270_dbus_get_error_from_errno(int code) -{ - return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code)); -} - -int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - H3270 * hSession = pw3270_dbus_get_session_handle(object); - GError * error = NULL; - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - - if(!lib3270_is_connected(hSession)) - { - error = pw3270_dbus_get_error_from_errno(ENOTCONN); - } - else - { - LIB3270_MESSAGE state = lib3270_get_program_message(hSession); - - switch(state) - { - case LIB3270_MESSAGE_NONE: - return 0; - - case LIB3270_MESSAGE_DISCONNECTED: - error = pw3270_dbus_get_error_from_errno(ENOTCONN); - break; - - case LIB3270_MESSAGE_MINUS: - case LIB3270_MESSAGE_PROTECTED: - case LIB3270_MESSAGE_NUMERIC: - case LIB3270_MESSAGE_OVERFLOW: - case LIB3270_MESSAGE_INHIBIT: - case LIB3270_MESSAGE_KYBDLOCK: - case LIB3270_MESSAGE_X: - error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state); - break; - - case LIB3270_MESSAGE_SYSWAIT: - case LIB3270_MESSAGE_TWAIT: - case LIB3270_MESSAGE_CONNECTED: - case LIB3270_MESSAGE_AWAITING_FIRST: - error = pw3270_dbus_get_error_from_errno(EBUSY); - break; - - case LIB3270_MESSAGE_RESOLVING: - case LIB3270_MESSAGE_CONNECTING: - error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" )); - break; - - case LIB3270_MESSAGE_USER: - error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state); - } - } - - if(error) - { - dbus_g_method_return_error(context,error); - g_error_free(error); - return -1; - } - - return 0; -} - -void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - char * text; - gchar * utftext; - H3270 * hSession = pw3270_dbus_get_session_handle(object); - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - - if(pw3270_dbus_check_valid_state(object,context)) - return; - - text = lib3270_get_string_at_address(hSession,0,-1,'\n'); - - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); - - lib3270_free(text); - - dbus_g_method_return(context,utftext); - - g_free(utftext); - -} - -void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - if(pw3270_dbus_check_valid_state(object,context)) - return; - dbus_g_method_return(context,lib3270_enter(pw3270_dbus_get_session_handle(object))); -} - -void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context) -{ - gchar * text; - H3270 * hSession = pw3270_dbus_get_session_handle(object); - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - if(pw3270_dbus_check_valid_state(object,context)) - return; - - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); - - int sz = lib3270_set_string_at(hSession,row,col,(const unsigned char *) text); - - trace("%s returns %d",__FUNCTION__,sz); - dbus_g_method_return(context,sz); - - g_free(text); -} - -void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context) -{ - gchar * text; - H3270 * hSession = pw3270_dbus_get_session_handle(object); - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - if(pw3270_dbus_check_valid_state(object,context)) - return; - - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); - - dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1)); - - g_free(text); -} - - -void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context) -{ - gchar * text; - H3270 * hSession = pw3270_dbus_get_session_handle(object); - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - if(pw3270_dbus_check_valid_state(object,context)) - return; - - text = lib3270_get_string_at(hSession, row, col, len, lf); - if(!text) - { - GError *error = pw3270_dbus_get_error_from_errno(errno); - dbus_g_method_return_error(context,error); - g_error_free(error); - } - else - { - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); - - lib3270_free(text); - - dbus_g_method_return(context,utftext); - - g_free(utftext); - } - } - - void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context) - { - gchar * text; - H3270 * hSession = pw3270_dbus_get_session_handle(object); - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - if(pw3270_dbus_check_valid_state(object,context)) - return; - - if(len < 0) { - len = lib3270_get_length(hSession); - } - - text = lib3270_get_string_at_address(hSession,offset,len,lf); - if(!text) - { - GError *error = pw3270_dbus_get_error_from_errno(errno); - dbus_g_method_return_error(context,error); - g_error_free(error); - } - else - { - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); - - lib3270_free(text); - - debug("\n%s\n",utftext); - - dbus_g_method_return(context,utftext); - - g_free(utftext); - } - - } - - void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p connected=%s",__FUNCTION__,object,context, lib3270_is_connected(pw3270_dbus_get_session_handle(object)) ? "Yes" : "No"); - dbus_g_method_return(context,lib3270_is_connected(pw3270_dbus_get_session_handle(object))); - } - - void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_is_ready(pw3270_dbus_get_session_handle(object))); - } - - void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_in_tn3270e(pw3270_dbus_get_session_handle(object))); - } - - void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_wait_for_ready(pw3270_dbus_get_session_handle(object),timeout)); - } - - void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_set_cursor_position(pw3270_dbus_get_session_handle(object),row,col)); - } - - void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_set_cursor_address(pw3270_dbus_get_session_handle(object),addr)); - } - - void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_cursor_address(pw3270_dbus_get_session_handle(object))); - } - - void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object))); - } - - void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_height(pw3270_dbus_get_session_handle(object))); - } - - void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object))); - } - - void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),(LIB3270_TOGGLE) id,value)); - } - -void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, char lf, DBusGMethodInvocation *context) -{ - gchar * text; - H3270 * hSession = pw3270_dbus_get_session_handle(object); - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - if(pw3270_dbus_check_valid_state(object,context)) - return; - - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); - - dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text,lf)); - - g_free(text); -} - -void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - if(pw3270_dbus_check_valid_state(object,context)) - return; - dbus_g_method_return(context,lib3270_pfkey(pw3270_dbus_get_session_handle(object),key)); -} - -void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - if(pw3270_dbus_check_valid_state(object,context)) - return; - dbus_g_method_return(context,lib3270_pakey(pw3270_dbus_get_session_handle(object),key)); -} - - void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_field_start(pw3270_dbus_get_session_handle(object),baddr)); - } - - void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_field_len(pw3270_dbus_get_session_handle(object),baddr)); - } - - void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_next_unprotected(pw3270_dbus_get_session_handle(object),baddr)); - } - - void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_is_protected(pw3270_dbus_get_session_handle(object),baddr)); - } - - void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_get_is_protected_at(pw3270_dbus_get_session_handle(object),row,col)); - } - - void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context) - { - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_action(pw3270_dbus_get_session_handle(object),text)); - } - - void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context) - { - gchar *text; - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - - if(pw3270_dbus_check_valid_state(object,context)) - return; - - text = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); - - trace("Clipboard:\n%s\n",text); - - if(!text) - { - GError *error = pw3270_dbus_get_error_from_errno(ENOENT); - dbus_g_method_return_error(context,error); - g_error_free(error); - } - else - { - dbus_g_method_return(context,text); - g_free(text); - } -} - -void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1); - dbus_g_method_return(context,0); -} - -void pw3270_dbus_set_script(PW3270Dbus *object, const gchar G_GNUC_UNUSED(*text), int mode, DBusGMethodInvocation *context) -{ - GtkWidget *widget = pw3270_get_terminal_widget(NULL); - - trace("%s object=%p context=%p",__FUNCTION__,object,context); - - if(!widget) - { - GError *error = pw3270_dbus_get_error_from_errno(EINVAL); - dbus_g_method_return_error(context,error); - g_error_free(error); - return; - } - - dbus_g_method_return(context,v3270_set_script(widget,mode == 0 ? 0 : 'S')); -} - -void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context) -{ - lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text); - dbus_g_method_return(context,0); -} - -void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - dbus_g_method_return(context,lib3270_get_host_charset(pw3270_dbus_get_session_handle(object))); -} - -void pw3270_dbus_get_display_charset(PW3270Dbus G_GNUC_UNUSED(*object), DBusGMethodInvocation *context) -{ - // Allways return UTF-8 to avoid double conversion - dbus_g_method_return(context,"UTF-8"); -} - -void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context) -{ - dbus_g_method_return(context,lib3270_set_host_charset(pw3270_dbus_get_session_handle(object),charset)); -} - -void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - trace("%s object=%p context=%p",__FUNCTION__,object,context); - dbus_g_method_return(context,lib3270_eraseeof(pw3270_dbus_get_session_handle(object))); -} - -void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context) -{ - dbus_g_method_return(context,lib3270_print_all(pw3270_dbus_get_session_handle(object))); -} - -void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context) -{ - lib3270_set_unlock_delay(pw3270_dbus_get_session_handle(object),(unsigned short) value); - dbus_g_method_return(context,0); -} - - -void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context) -{ - int sz = strlen(from); - - if(sz > 0) - { - unsigned char buffer[sz+1]; - memcpy(buffer,from,sz); - dbus_g_method_return(context,lib3270_ebc2asc(pw3270_dbus_get_session_handle(object),buffer,sz)); - return; - } - - dbus_g_method_return(context,""); - -} - -void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context) -{ - int sz = strlen(from); - - if(sz > 0) - { - unsigned char buffer[sz+1]; - memcpy(buffer,from,sz); - dbus_g_method_return(context,lib3270_asc2ebc(pw3270_dbus_get_session_handle(object),buffer,sz)); - return; - } - - dbus_g_method_return(context,""); - -} - -void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context) -{ - /* - dbus_g_method_return(context, - v3270_transfer_file( - v3270_get_default_widget(), - (LIB3270_FT_OPTION) flags, - local, - remote, - lrecl, - blksize, - primspace, - secspace, - dft - )); - */ - return; -} - diff --git a/src/ipc3270c/linux/main.c b/src/ipc3270c/linux/main.c deleted file mode 100644 index 9e4637d..0000000 --- a/src/ipc3270c/linux/main.c +++ /dev/null @@ -1,189 +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 main.c e possui - linhas de código. - * - * Referências: - * - * https://github.com/fbuihuu/samples-dbus/blob/master/dbus-server.c - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include "service.h" -#include "globals.h" -#include "dbus-glue.h" - -#include - -/*---[ Globals ]---------------------------------------------------------------------------------*/ - - static DBusGConnection * connection = NULL; - static DBusGProxy * proxy = NULL; - static gchar * service_name = NULL; - - -/*---[ Implement ]-------------------------------------------------------------------------------*/ - - LIB3270_EXPORT int pw3270_plugin_start(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal) - { - GError * error = NULL; - guint result; - char session_id = 0; - char id = 'a'; - gchar * ptr; - const gchar * name = v3270_get_session_name(terminal); - - connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error); - if(error) - { - GtkWidget *dialog = gtk_message_dialog_new( - GTK_WINDOW(window), - (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _( "Can't connect to DBUS server" )); - - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); - - g_message("Error \"%s\" getting session dbus",error->message); - - g_error_free(error); - - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - - return -1; - } - - proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); - - for(id='a'; id < 'z' && !error && !service_name; id++) - { - gboolean has_owner = FALSE; - - service_name = g_strdup_printf("br.com.bb.%s.%c",name,(int) id); - for(ptr=service_name;*ptr;ptr++) - *ptr = g_ascii_tolower(*ptr); - - org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL); - - if(has_owner) - { - trace("Service \"%s\" has owner",service_name) - g_free(service_name); - service_name = NULL; - } - else - { - session_id = id; - g_message("DBUS service name is %s",service_name); - org_freedesktop_DBus_request_name(proxy, service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); - } - } - - if(error) - { - GtkWidget *dialog = gtk_message_dialog_new( - GTK_WINDOW(window), - (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _( "Can't get DBUS object name" )); - - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); - - g_message("Error \"%s\" requesting DBUS name",error->message); - - g_error_free(error); - - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - - return -1; - } - - if(session_id) - { - - g_autofree gchar * session = g_strdup_printf("%s:%c",name,g_ascii_toupper(session_id)); - - static const gchar * path = "/br/com/bb/pw3270"; - g_message("DBUS service path is %s, session name is %s",path,session); - v3270_set_session_name(terminal,session); - - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,path); - - } - - return 0; - } - - LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget G_GNUC_UNUSED(*terminal)) - { - if(proxy) - { - debug("%s: Releasing proxy",__FUNCTION__); - g_object_unref(proxy); - proxy = NULL; - } - - if(service_name) - { - g_free(service_name); - service_name = NULL; - } - return 0; - } - - void pw3270_dbus_quit(PW3270Dbus G_GNUC_UNUSED(*object), DBusGMethodInvocation *context) - { - gtk_main_quit(); - dbus_g_method_return(context,0); - } - - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus G_GNUC_UNUSED(*object)) - { - debug("%s=%p",__FUNCTION__,lib3270_get_default_session_handle()); - return lib3270_get_default_session_handle(); - } - -#if ! GLIB_CHECK_VERSION(2,44,0) -// Reference: https://github.com/ImageMagick/glib/blob/master/glib/glib-autocleanups.h -void hllapi_autoptr_cleanup_generic_gfree(void *p) -{ - void **pp = (void**)p; - g_free (*pp); -} -#endif // ! GLIB(2,44,0) - diff --git a/src/ipc3270c/linux/misc.c b/src/ipc3270c/linux/misc.c deleted file mode 100644 index 08c5fa2..0000000 --- a/src/ipc3270c/linux/misc.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como misc.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * - * Referencias: - * - * https://live.gnome.org/DBusGlibBindings - * - */ - -#include "globals.h" - -/*---[ Implement ]-------------------------------------------------------------------------------*/ - -gpointer pw3270_dbus_register_object(DBusGConnection *connection,DBusGProxy G_GNUC_UNUSED(*proxy),GType object_type,const DBusGObjectInfo *info,const gchar *path) -{ - GObject *object = G_OBJECT(g_object_new(object_type, NULL)); - dbus_g_object_type_install_info (object_type, info); - dbus_g_connection_register_g_object (connection, path, object); - return object; -} - diff --git a/src/ipc3270c/linux/service.h b/src/ipc3270c/linux/service.h deleted file mode 100644 index aba8322..0000000 --- a/src/ipc3270c/linux/service.h +++ /dev/null @@ -1,138 +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 service.h e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * - */ - -#ifndef _PW3270_DBUS_SERVICE_H - - #define _PW3270_DBUS_SERVICE_H 1 - - #define ENABLE_NLS - #define GETTEXT_PACKAGE PACKAGE_NAME - - #include "globals.h" - - #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ()) - #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus)) - #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass)) - #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS)) - #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS)) - #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass)) - - G_BEGIN_DECLS - - typedef struct _PW3270Dbus PW3270Dbus; - typedef struct _PW3270DbusClass PW3270DbusClass; - - struct _PW3270Dbus - { - GObject parent; - }; - - struct _PW3270DbusClass - { - GObjectClass parent; - }; - - PW3270Dbus * pw3270_dbus_new (void); - GType pw3270_dbus_get_type (void); - - void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); - void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); - void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); - - void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context); - - void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context); - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); - GError * pw3270_dbus_get_error_from_errno(int code); - - void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context); - - void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context); - void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context); - void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context); - - void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context); - - void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context); - - void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context); - - void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); - void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); - void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); - - void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); - void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context); - - void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context); - - void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context); - - void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context); - - // Actions - void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); - void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); - void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); - void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context); - void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context); - void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, char lf, DBusGMethodInvocation *context); - void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context); - - void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context); - void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context); - - void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context); - void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context); - void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context); - - void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context); - void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context); - - void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context); - - void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context); - - G_END_DECLS - -#endif // _PW3270_DBUS_SERVICE_H diff --git a/src/ipc3270c/windows/main.c b/src/ipc3270c/windows/main.c deleted file mode 100644 index 321aa1b..0000000 --- a/src/ipc3270c/windows/main.c +++ /dev/null @@ -1,671 +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. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como - e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - * Agradecimento: - * - * Hélio Passos - * - */ - - #include "private.h" - -#ifdef _WIN32 - #include -#else - #error HLLAPI is designed for windows. -#endif // _WIN32 - - #include - #include - #include - #include - #include - #include - -/*--[ Defines ]--------------------------------------------------------------------------------------*/ - - #pragma pack(1) - - enum PIPE_STATE - { - PIPE_STATE_WAITING, - PIPE_STATE_READ, - PIPE_STATE_PENDING_READ, - PIPE_STATE_UNDEFINED - }; - - typedef struct _pipe_source - { - GSource gsrc; - HANDLE hPipe; - - enum PIPE_STATE state; - - OVERLAPPED overlap; - unsigned char buffer[PIPE_BUFFER_LENGTH+1]; - } pipe_source; - - #pragma pack() - - -/*--[ Globals ]--------------------------------------------------------------------------------------*/ - -// static const gchar control_char = '@'; - -/*--[ Implement ]------------------------------------------------------------------------------------*/ - - static void IO_accept(pipe_source *source) - { - set_active(FALSE); - - if(ConnectNamedPipe(source->hPipe,&source->overlap)) - { - popup_lasterror("%s",_( "Error in ConnectNamedPipe" )); - return; - } - - switch(GetLastError()) - { - // The overlapped connection in progress. - case ERROR_IO_PENDING: - // trace("%s: ERROR_IO_PENDING",__FUNCTION__); - source->state = PIPE_STATE_WAITING; - break; - - // Client is already connected, so signal an event. - case ERROR_PIPE_CONNECTED: - trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__); - set_active(TRUE); - SetEvent(source->overlap.hEvent); - break; - - // If an error occurs during the connect operation... - default: - popup_lasterror("%s", _( "ConnectNamedPipe failed" )); - } - - } - - static gboolean IO_prepare(GSource *source, gint *timeout) - { - /* - * Called before all the file descriptors are polled. - * If the source can determine that it is ready here - * (without waiting for the results of the poll() call) - * it should return TRUE. - * - * It can also return a timeout_ value which should be the maximum - * timeout (in milliseconds) which should be passed to the poll() call. - * The actual timeout used will be -1 if all sources returned -1, - * or it will be the minimum of all the timeout_ values - * returned which were >= 0. - * - */ - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0) - return TRUE; - - *timeout = 10; - return FALSE; - } - - static gboolean IO_check(GSource *source) - { - /* - * Called after all the file descriptors are polled. - * The source should return TRUE if it is ready to be dispatched. - * Note that some time may have passed since the previous prepare - * function was called, so the source should be checked again here. - * - */ - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0) - return TRUE; - - return FALSE; - } - - static void send_text(pipe_source *source, char *text) - { - struct hllapi_packet_text *pkt; - DWORD szBlock; - int f; - - if(text) - { - szBlock = sizeof(struct hllapi_packet_text)+strlen(text); - pkt = (struct hllapi_packet_text *) g_malloc0(szBlock); - pkt->packet_id = 0; - strcpy(pkt->text,text); - lib3270_free(text); - } - else - { - szBlock = sizeof(struct hllapi_packet_text); - pkt = (struct hllapi_packet_text *) g_malloc0(szBlock); - pkt->packet_id = errno ? errno : -1; - } - - trace("szBlock=%d text=\"%s\"",szBlock, ( (struct hllapi_packet_text *) pkt)->text); - for(f=0;f< (int) szBlock;f++) - { - trace("rsp(%d)= %d \"%s\"",f,* (((char *) pkt)+f),((char *) pkt)+f); - } - - WriteFile(source->hPipe,pkt,szBlock,&szBlock,NULL); - - g_free(pkt); - } - - static void send_result(pipe_source *source, int rc) - { - struct hllapi_packet_result pkt = { rc }; - DWORD wrote = sizeof(pkt); - WriteFile(source->hPipe,&pkt,wrote,&wrote,NULL); - } - - static int do_file_transfer(struct hllapi_packet_file_transfer G_GNUC_UNUSED(* source)) - { - /* - const gchar * local = (const char *) source->text; - const gchar * remote = (const char *) (local+strlen(local)+1); - - return v3270_transfer_file( v3270_get_default_widget(), - (LIB3270_FT_OPTION) source->options, - local, - remote, - source->lrecl, - source->blksize, - source->primspace, - source->secspace, - source->dft ); - */ - return EINVAL; - } - - static void get_host(pipe_source *source) { - send_text(source,strdup(lib3270_get_url(lib3270_get_default_session_handle()))); - } - - static void process_input(pipe_source *source, DWORD G_GNUC_UNUSED(cbRead)) - { - const struct hllapi_packet_query * query = ((struct hllapi_packet_query *) source->buffer); - - trace("%s id=%d",__FUNCTION__,query->packet_id); - - switch(query->packet_id) - { - case HLLAPI_PACKET_CONNECT: - send_result(source,lib3270_reconnect( lib3270_get_default_session_handle(), - ((struct hllapi_packet_connect *) source->buffer)->wait)); - break; - - case HLLAPI_PACKET_CONNECT_URL: - send_result(source,lib3270_connect_url(lib3270_get_default_session_handle(),(const char *) (query+1),0)); - break; - - case HLLAPI_PACKET_SET_HOST: - send_result(source,lib3270_set_url(lib3270_get_default_session_handle(), - ((struct hllapi_packet_text *) source->buffer)->text)); - break; - - case HLLAPI_PACKET_GET_HOST: - get_host(source); - break; - - case HLLAPI_PACKET_DISCONNECT: - send_result(source,lib3270_disconnect(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_IS_CONNECTED: - send_result(source,lib3270_in_tn3270e(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_IS_READY: - send_result(source,lib3270_is_ready(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_ENTER: - send_result(source,lib3270_enter(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_PRINT: - send_result(source,lib3270_print_all(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_ERASE: - send_result(source,lib3270_erase(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_ERASE_EOF: - send_result(source,lib3270_eraseeof(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_ERASE_EOL: - send_result(source,lib3270_eraseeol(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_ERASE_INPUT: - send_result(source,lib3270_eraseinput(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_PFKEY: - send_result(source,lib3270_pfkey( lib3270_get_default_session_handle(), - ((struct hllapi_packet_keycode *) source->buffer)->keycode)); - break; - - case HLLAPI_PACKET_PAKEY: - send_result(source,lib3270_pakey( lib3270_get_default_session_handle(), - ((struct hllapi_packet_keycode *) source->buffer)->keycode)); - break; - - case HLLAPI_PACKET_SET_CURSOR_POSITION: - send_result(source,lib3270_set_cursor_position( lib3270_get_default_session_handle(), - ((struct hllapi_packet_cursor *) source->buffer)->row, - ((struct hllapi_packet_cursor *) source->buffer)->col)); - break; - - case HLLAPI_PACKET_SET_TEXT_AT: - send_result(source,lib3270_set_text_at( lib3270_get_default_session_handle(), - ((struct hllapi_packet_text_at *) source->buffer)->row, - ((struct hllapi_packet_text_at *) source->buffer)->col, - (unsigned char *) ((struct hllapi_packet_text_at *) source->buffer)->text)); - break; - - case HLLAPI_PACKET_GET_TEXT_AT: - send_text(source,lib3270_get_string_at( lib3270_get_default_session_handle(), - ((struct hllapi_packet_at *) source->buffer)->row, - ((struct hllapi_packet_at *) source->buffer)->col, - ((struct hllapi_packet_at *) source->buffer)->len, - ((struct hllapi_packet_at *) source->buffer)->lf)); - break; - - case HLLAPI_PACKET_GET_TEXT_AT_OFFSET: - send_text(source,lib3270_get_string_at_address( lib3270_get_default_session_handle(), - ((struct hllapi_packet_query_offset *) source->buffer)->addr, - ((struct hllapi_packet_query_offset *) source->buffer)->len, - ((struct hllapi_packet_query_offset *) source->buffer)->lf)); - break; - - case HLLAPI_PACKET_CMP_TEXT_AT: - send_result(source,lib3270_cmp_text_at( lib3270_get_default_session_handle(), - ((struct hllapi_packet_text_at *) source->buffer)->row, - ((struct hllapi_packet_text_at *) source->buffer)->col, - ((struct hllapi_packet_text_at *) source->buffer)->text, - ((struct hllapi_packet_text_at *) source->buffer)->lf)); - break; - - case HLLAPI_PACKET_INPUT_STRING: - send_result(source,lib3270_input_string(lib3270_get_default_session_handle(), - (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text)); - break; - - case HLLAPI_PACKET_EMULATE_INPUT: - send_result(source,lib3270_emulate_input(lib3270_get_default_session_handle(), - (const char *) ((struct hllapi_packet_emulate_input *) source->buffer)->text, - (int) ((struct hllapi_packet_emulate_input *) source->buffer)->len, - (int) ((struct hllapi_packet_emulate_input *) source->buffer)->pasting)); - break; - - case HLLAPI_PACKET_SET_CURSOR: - send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(), - ((struct hllapi_packet_addr *) source->buffer)->addr)); - break; - - case HLLAPI_PACKET_GET_CURSOR: - send_result(source,lib3270_get_cursor_address(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_GET_WIDTH: - send_result(source,lib3270_get_width(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_GET_HEIGHT: - send_result(source,lib3270_get_height(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_GET_LENGTH: - send_result(source,lib3270_get_length(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_GET_PROGRAM_MESSAGE: - send_result(source,lib3270_get_program_message(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_GET_SSL_STATE: - send_result(source,lib3270_get_secure(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_SET_UNLOCK_DELAY: - lib3270_set_unlock_delay(lib3270_get_default_session_handle(),(unsigned short) ((struct hllapi_packet_set_int *) source->buffer)->value); - send_result(source,0); - break; - - case HLLAPI_PACKET_SET_TOGGLE: - send_result(source,lib3270_set_toggle(lib3270_get_default_session_handle(), - (LIB3270_TOGGLE) ((struct hllapi_packet_set *) source->buffer)->id, - ((struct hllapi_packet_set *) source->buffer)->value)); - break; - - case HLLAPI_PACKET_FIELD_START: - send_result(source,lib3270_get_field_start(lib3270_get_default_session_handle(), - ((struct hllapi_packet_addr *) source->buffer)->addr)); - break; - - - case HLLAPI_PACKET_FIELD_LEN: - send_result(source,lib3270_get_field_len(lib3270_get_default_session_handle(), - ((struct hllapi_packet_addr *) source->buffer)->addr)); - break; - - case HLLAPI_PACKET_NEXT_UNPROTECTED: - send_result(source,lib3270_get_next_unprotected(lib3270_get_default_session_handle(), - ((struct hllapi_packet_addr *) source->buffer)->addr)); - break; - - case HLLAPI_PACKET_IS_PROTECTED: - send_result(source,lib3270_get_is_protected(lib3270_get_default_session_handle(), - ((struct hllapi_packet_addr *) source->buffer)->addr)); - break; - - case HLLAPI_PACKET_IS_PROTECTED_AT: - send_result(source,lib3270_get_is_protected_at( lib3270_get_default_session_handle(), - ((struct hllapi_packet_query_at *) source->buffer)->row, - ((struct hllapi_packet_query_at *) source->buffer)->col)); - break; - - case HLLAPI_PACKET_QUIT: - gtk_main_quit(); - send_result(source,0); - break; - - case HLLAPI_PACKET_SET_HOST_CHARSET: - send_result(source,lib3270_set_host_charset( lib3270_get_default_session_handle(), - (const char *) ((struct hllapi_packet_set_text *) source->buffer)->text)); - break; - - case HLLAPI_PACKET_ASC2EBC: - send_text(source,(char *) lib3270_asc2ebc( - lib3270_get_default_session_handle(), - (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text,-1 - )); - break; - - case HLLAPI_PACKET_EBC2ASC: - send_text(source,(char *) lib3270_ebc2asc( - lib3270_get_default_session_handle(), - (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text,-1 - )); - break; - - case HLLAPI_PACKET_FILE_TRANSFER: - send_result(source,do_file_transfer((struct hllapi_packet_file_transfer *) source)); - break; - - case HLLAPI_PACKET_GET_HOST_CHARSET: - trace("%s","HLLAPI_PACKET_GET_HOST_CHARSET"); - send_text(source,(char *) lib3270_get_host_charset(lib3270_get_default_session_handle())); - break; - - case HLLAPI_PACKET_ACTION: - send_result(source,lib3270_action(lib3270_get_default_session_handle(), - (const char *) ((struct hllapi_packet_text *) source->buffer)->text)); - break; - - - default: - send_result(source, EINVAL); - g_message("Invalid remote request (id=%d)",source->buffer[0]); - } - - } - - static void read_input_pipe(pipe_source *source) - { - DWORD cbRead = 0; - - if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0) - process_input(source,cbRead); - - // The read operation is still pending. - switch(GetLastError()) - { - case 0: - break; - - case ERROR_IO_PENDING: - // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__); - source->state = PIPE_STATE_PENDING_READ; - break; - - case ERROR_PIPE_LISTENING: - // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__); - source->state = PIPE_STATE_READ; - break; - - case ERROR_BROKEN_PIPE: - trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__); - - if(!DisconnectNamedPipe(source->hPipe)) - { - set_active(FALSE); - popup_lasterror("%s",_( "Error in DisconnectNamedPipe" )); - } - else - { - IO_accept(source); - } - break; - - case ERROR_PIPE_NOT_CONNECTED: - trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__); - set_active(FALSE); - break; - - default: - if(source->hPipe != INVALID_HANDLE_VALUE) - popup_lasterror("%s",_( "Error receiving message from pipe" ) ); - } - - } - - static gboolean IO_dispatch(GSource *source, GSourceFunc G_GNUC_UNUSED(callback), gpointer G_GNUC_UNUSED(data)) - { - /* - * Called to dispatch the event source, - * after it has returned TRUE in either its prepare or its check function. - * The dispatch function is passed in a callback function and data. - * The callback function may be NULL if the source was never connected - * to a callback using g_source_set_callback(). The dispatch function - * should call the callback function with user_data and whatever additional - * parameters are needed for this type of event source. - */ - BOOL fSuccess; - DWORD cbRead = 0; -// DWORD dwErr = 0; - - fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE ); - - // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead); - - switch(((pipe_source *) source)->state) - { - case PIPE_STATE_WAITING: - if(fSuccess) - { - trace("Pipe connected (cbRet=%d)",(int) cbRead); - set_active(TRUE); - ((pipe_source *) source)->state = PIPE_STATE_READ; - } - else - { - popup_lasterror("%s", _( "Pipe connection failed" )); - } - break; - - case PIPE_STATE_READ: - // trace("Reading pipe (cbRead=%d)",(int) cbRead); - read_input_pipe( (pipe_source *) source); - break; - - case PIPE_STATE_PENDING_READ: - if(fSuccess && cbRead > 0) - process_input((pipe_source *) source,cbRead); - ((pipe_source *) source)->state = PIPE_STATE_READ; - break; - - case PIPE_STATE_UNDEFINED: - break; - -//#ifdef DEBUG -// default: -// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state); -//#endif - } - - return TRUE; - } - - static void IO_finalize(GSource *source) - { -// trace("%s: source=%p",__FUNCTION__,source); - - if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE) - { - CloseHandle(((pipe_source *) source)->hPipe); - ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE; - } - - } - - static gboolean IO_closure(gpointer G_GNUC_UNUSED(data)) - { - return 0; - } - - void popup_lasterror(const gchar *fmt, ...) - { - char buffer[4096]; - va_list arg_ptr; - int sz; - DWORD errcode = GetLastError(); - char *ptr; - LPVOID lpMsgBuf = 0; - - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL); - - for(ptr= (char *) lpMsgBuf;*ptr && *ptr != '\n';ptr++); - *ptr = 0; - - va_start(arg_ptr, fmt); - vsnprintf(buffer,4095,fmt,arg_ptr); - va_end(arg_ptr); - - sz = strlen(buffer); - snprintf(buffer+sz,4096-sz,": %s\n(rc=%d)",lpMsgBuf,(int) errcode); - - printf("%s\n",buffer); - -#ifdef DEBUG - fprintf(stderr,"%s\n",buffer); - fflush(stderr); -#endif - - LocalFree(lpMsgBuf); - } - - LIB3270_EXPORT int pw3270_plugin_start(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal) - { - char id; - const gchar * name = v3270_get_session_name(terminal); - - for(id='A';id < 'Z';id++) - { - g_autofree gchar * pipename = g_strdup_printf("\\\\.\\pipe\\%s_%c",name,id); - gchar * ptr; - HANDLE hPipe; - - for(ptr=pipename;*ptr;ptr++) - *ptr = g_ascii_tolower(*ptr); - - hPipe = CreateNamedPipe( TEXT(pipename), // pipe name - PIPE_ACCESS_DUPLEX | // read/write access - FILE_FLAG_OVERLAPPED, // overlapped mode - PIPE_TYPE_MESSAGE | // pipe type - PIPE_READMODE_MESSAGE | // pipe mode - PIPE_WAIT, // blocking mode - 1, // number of instances - PIPE_BUFFER_LENGTH, // output buffer size - PIPE_BUFFER_LENGTH, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attributes - - trace("%s = %p",pipename,hPipe); - - if(hPipe != INVALID_HANDLE_VALUE) - { - static GSourceFuncs pipe_source_funcs = - { - IO_prepare, - IO_check, - IO_dispatch, - IO_finalize, - IO_closure, - NULL - }; - g_autofree gchar * session = g_strdup_printf("%s:%c",name,id); - pipe_source * source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source)); - - source->hPipe = hPipe; - source->state = PIPE_STATE_WAITING; - source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL); - - g_source_attach((GSource *) source,NULL); - IO_accept(source); - - v3270_set_session_name(terminal,session); - g_message("Session %s attached to %s",session,pipename); - - return 0; - } - - } - - popup_lasterror( "%s", _( "Can´t create remote control pipe" )); - - return -1; - } - - LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget G_GNUC_UNUSED(*terminal)) - { - - return 0; - } - - G_GNUC_INTERNAL void set_active(gboolean on) - { - trace("%s(%s)",__FUNCTION__,on ? "Active" : "Inactive"); - // v3270_set_script(v3270_get_default_widget(),'H'); - } diff --git a/src/ipc3270c/windows/private.h b/src/ipc3270c/windows/private.h deleted file mode 100644 index c9494d2..0000000 --- a/src/ipc3270c/windows/private.h +++ /dev/null @@ -1,50 +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 - * - * Este programa está nomeado como -e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - - #include - #define ENABLE_NLS - #define GETTEXT_PACKAGE PACKAGE_NAME - - #include - #include - #include - - #include - #include - #include - #include - - #include - - #define PIPE_BUFFER_LENGTH HLLAPI_MAXLENGTH+30 - - G_GNUC_INTERNAL void popup_lasterror(const gchar *fmt, ...); - G_GNUC_INTERNAL void set_active(gboolean on); - - diff --git a/src/ipc3270c/windows/resources.rc.in b/src/ipc3270c/windows/resources.rc.in deleted file mode 100644 index 6c0501f..0000000 --- a/src/ipc3270c/windows/resources.rc.in +++ /dev/null @@ -1,29 +0,0 @@ -#include - -VS_VERSION_INFO VERSIONINFO -FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 -PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 - -BEGIN - - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "FileDescription", "IPC Compatibility Plugin for pw3270\0" - VALUE "CompanyName", "Banco do Brasil S/A.\0" - VALUE "FileVersion", "@WIN32_VERSION@\0" - VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" - VALUE "OriginalFilename", "ipc3270@DLLEXT@\0" - VALUE "ProductName", "pw3270\0" - VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" - END - END - - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 0x04E4 - END - -END - diff --git a/src/testprogram/hllapi.c b/src/testprogram/hllapi.c new file mode 100644 index 0000000..a321c4a --- /dev/null +++ b/src/testprogram/hllapi.c @@ -0,0 +1,185 @@ +/* + * "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 + * + * Este programa está nomeado como testprogram.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include + #include + #include + #include + #include + + #if defined(DEBUG) && defined(_WIN32) + #undef trace + #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } } + #endif // DEBUG + + #define MAX_DATA_SIZE 8000 //< Maximum data size for this application. + +// static CHAR hllapi_data[MAX_DATA_SIZE]; + +/*---[ Implement ]--------------------------------------------------------------------------------*/ + + /* + static void connect_ps(const char *session) + { + WORD len; + WORD fn = HLLAPI_CMD_CONNECTPS; + WORD rc = 0; + + strncpy(hllapi_data,session,MAX_DATA_SIZE); + + len = strlen(session); + hllapi(&fn,hllapi_data,&len,&rc); + + } + */ + + int main(int argc, char **argv) + { + const char *host = NULL; + const char *session = "pw3270:A"; + + #pragma GCC diagnostic push + static struct option options[] = + { + { "host", required_argument, 0, 'h' }, + { "session-name", required_argument, 0, 'S' }, + { 0, 0, 0, 0} + }; + #pragma GCC diagnostic pop + + int long_index =0; + int opt; + while((opt = getopt_long(argc, argv, "h:S:", options, &long_index )) != -1) + { + + switch(opt) + { + case 'h': + host = optarg; + break; + + case 'S': + session = optarg; + break; + + } + + } + + int rc = hllapi_init((char *) session); + if(rc) + { + printf("hllapi_init returns with rc=%d\n",rc); + return rc; + } + + printf("Library revision is %d\n",(int) hllapi_get_revision()); + + if(host) { + + printf("connect=%d\n",(int) hllapi_connect((char *) host,1)); + printf("wait_for_ready=%d\n",(int) hllapi_wait_for_ready(10)); + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No"); + + printf("disconnect=%d\n",(int) hllapi_disconnect()); + } + + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No"); + + rc = hllapi_deinit(); + printf("hllapi_deinit exits with rc=%d\n",rc); + + return 0; + } + +/* + int main(int numpar, char *param[]) + { + char buffer[BUFFER_LENGTH]; + unsigned short rc; + unsigned short len; + unsigned long fn; + + static const struct _cmd + { + const char * name; + unsigned short fn; + const char * arg; + } cmd[] = + { + { "GetRevision", HLLAPI_CMD_GETREVISION, " " }, + { "ConnectPS", HLLAPI_CMD_CONNECTPS, "pw3270A" }, + { "InputString", HLLAPI_CMD_INPUTSTRING, "test" }, + + }; + + int f; + + + for(f=0;f< (sizeof(cmd)/sizeof(struct _cmd)); f++) + { + len = strlen(cmd[f].arg); + memcpy(buffer,cmd[f].arg,len); + hllapi((LPWORD) &cmd[f].fn,buffer,&len,&rc); + printf("%s exits with rc=%d\n[%s]\n",cmd[f].name,rc,buffer); + } + + len = 80; + rc = 1040; + fn = HLLAPI_CMD_COPYPSTOSTR; + hllapi((LPWORD) &fn,buffer,&len,&rc); + printf("%s exits with rc=%d\n%s\n","HLLAPI_CMD_COPYPSTOSTR",rc,buffer); + + // Performance + len = strlen(cmd[0].arg); + memcpy(buffer,cmd[0].arg,len); + if(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0) + { + time_t end = time(0) + 5; + int qtd = 0; + do + { + qtd++; + } while(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0 && time(0) + * + * 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 testprogram.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + + /** + * @brief Test program for pw3270 HLLAPI compatibility plugin. + * + */ + + #include + #include + #include + #include + #include + #include + #include + + /*---[ Globals ]------------------------------------------------------------------------------------*/ + + const gchar * plugin_path = ".bin/Debug"; + const gchar * session_name = "pw3270"; + const gchar * plugin_name = "ipc3270c." G_MODULE_SUFFIX; + + /*---[ Implement ]----------------------------------------------------------------------------------*/ + + static void close_module(GtkWidget *widget, GModule *module) + { + g_message("Closing module %p",module); + + static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL; + if(!g_module_symbol(module,"pw3270_plugin_stop",(void **) &stop)) + { + g_message("Can't get stop method from plugin: %s",g_module_error()); + } + else + { + stop(gtk_widget_get_toplevel(widget),widget); + } + + g_module_close(module); + g_message("Module %p was closed",module); + } + + static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal) + { + v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button)); + } + + static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal) + { + v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button)); + } + + static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal) + { + v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button)); + } + + static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal) + { + v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button)); + } + + static void toggle_started_trace(GtkToggleToolButton *button, GModule *module) + { + if(!module) + return; + + GtkWidget * terminal = GTK_WIDGET(g_object_get_data(G_OBJECT(button),"terminal")); + + const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop"); + + static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL; + if(!g_module_symbol(module,method_name,(void **) &call)) + { + g_message("Can't get method \"%s\": %s",method_name,g_module_error()); + return; + } + + g_message("Calling %s",method_name); + call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal)); + + } + + static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback) + { + GtkToolItem * item = gtk_toggle_tool_button_new(); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label); + + g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal); + + if(tooltip) + gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip); + + return item; + } + + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { + + GtkWidget * window = gtk_application_window_new(app); + GtkWidget * terminal = v3270_new(); + GtkWidget * notebook = gtk_notebook_new(); + GModule * module = NULL; + + gtk_widget_set_name(window,session_name); + v3270_set_session_name(terminal, session_name); + + // Setup tabs + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal))); + + // Load plugin + { + g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL); + + g_message("Loading %s",plugin); + + module = g_module_open(plugin,G_MODULE_BIND_LOCAL); + + if(module) + { + g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module); + } + else + { + g_message("Can't open \"%s\": %s",plugin,g_module_error()); + gtk_main_quit(); + } + + } + // Create trace window + { + GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0); + GtkWidget * trace = v3270_trace_new(terminal); + GtkWidget * toolbar = gtk_toolbar_new(); + GtkToolItem * start = gtk_toggle_tool_button_new(); + + gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL); + + g_object_set_data(G_OBJECT(start),"terminal",terminal); + + gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable"); + g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module); + gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module"); + + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1); + + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1); + + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1); + + gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0); + gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace")); + } + + // Setup and show main window + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); + gtk_container_add(GTK_CONTAINER(window),notebook); + gtk_widget_show_all (window); + + // Setup title. + const gchar *url = lib3270_get_url(v3270_get_session(terminal)); + if(url) { + + v3270_set_url(terminal,url); + v3270_reconnect(terminal); + + gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url); + gtk_window_set_title(GTK_WINDOW(window), title); + g_free(title); + + } else { + + gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal)); + + } + +} + +int main (int argc, char **argv) { + + static const GOptionEntry app_options[] = { + { "plugin-path", 'P', 0, G_OPTION_ARG_STRING, &plugin_path, "Path for plugin search", NULL }, + { "session-name", 'S', 0, G_OPTION_ARG_STRING, &session_name, "Session name", "pw3270" }, + { "module", 'm', 0, G_OPTION_ARG_STRING, &plugin_name, "Module name", "ipc3270c." G_MODULE_SUFFIX }, + + { NULL } + }; + + GtkApplication *app; + int status; + + app = gtk_application_new("br.com.bb.ipc3270c",G_APPLICATION_FLAGS_NONE); + + g_application_add_main_option_entries(G_APPLICATION(app),app_options); + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); + + status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + + g_message("rc=%d",status); + return status; + +} + diff --git a/src/testprogram/linux/test.sh b/src/testprogram/linux/test.sh new file mode 100755 index 0000000..376ed60 --- /dev/null +++ b/src/testprogram/linux/test.sh @@ -0,0 +1,126 @@ +#!/bin/bash + +SESSION=a +DEST=br.com.bb.pw3270 +BPATH=/br/com/bb/pw3270 + +run_command() +{ + + case $1 in + + revision) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getRevision + ;; + + message) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getMessageID + ;; + + ssl) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getSecureState + ;; + + connect) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.connect string:$2 int32:10 + ;; + + disconnect) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.disconnect + ;; + + url) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getURL + ;; + + quit) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.quit + ;; + + get) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getScreenContents + ;; + + gettext) +# addr,len,lf +# dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:0 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:10 + ;; + + protect) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getIsProtectedAt int32:$2 int32:$3 + ;; + + set) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setTextAt int32:$2 int32:$3 string:$4 + ;; + + action) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.action string:$2 + ;; + + enter) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.enter + ;; + + isconnected) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.isConnected + ;; + + hostcharset) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getHostCharset + ;; + + displaycharset) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getDisplayCharset + ;; + + unlockdelay) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setUnlockDelay int32:$2 + ;; + + *) + echo "Comando $1 desconhecido" + ;; + + esac +} + + + +until [ -z "$1" ] +do + if [ ${1:0:2} = '--' ]; then + tmp=${1:2} + parameter=${tmp%%=*} + parameter=$(echo $parameter | tr "[:lower:]" "[:upper:]") + value=${tmp##*=} + + case "$parameter" in + SESSION) + SESSION=$value + ;; + HELP) + echo "$0 options" + echo "" + echo "Options:" + echo "" + echo " --session pw3270's session manager" + echo "" + exit 0 + ;; + + *) + eval $parameter=$value + ;; + + esac + + else + run_command $@ + exit 0 + fi + + shift +done + diff --git a/src/testprograms/hllapi.c b/src/testprograms/hllapi.c deleted file mode 100644 index a321c4a..0000000 --- a/src/testprograms/hllapi.c +++ /dev/null @@ -1,185 +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 - * - * Este programa está nomeado como testprogram.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - - #include - #include - #include - #include - #include - - #if defined(DEBUG) && defined(_WIN32) - #undef trace - #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } } - #endif // DEBUG - - #define MAX_DATA_SIZE 8000 //< Maximum data size for this application. - -// static CHAR hllapi_data[MAX_DATA_SIZE]; - -/*---[ Implement ]--------------------------------------------------------------------------------*/ - - /* - static void connect_ps(const char *session) - { - WORD len; - WORD fn = HLLAPI_CMD_CONNECTPS; - WORD rc = 0; - - strncpy(hllapi_data,session,MAX_DATA_SIZE); - - len = strlen(session); - hllapi(&fn,hllapi_data,&len,&rc); - - } - */ - - int main(int argc, char **argv) - { - const char *host = NULL; - const char *session = "pw3270:A"; - - #pragma GCC diagnostic push - static struct option options[] = - { - { "host", required_argument, 0, 'h' }, - { "session-name", required_argument, 0, 'S' }, - { 0, 0, 0, 0} - }; - #pragma GCC diagnostic pop - - int long_index =0; - int opt; - while((opt = getopt_long(argc, argv, "h:S:", options, &long_index )) != -1) - { - - switch(opt) - { - case 'h': - host = optarg; - break; - - case 'S': - session = optarg; - break; - - } - - } - - int rc = hllapi_init((char *) session); - if(rc) - { - printf("hllapi_init returns with rc=%d\n",rc); - return rc; - } - - printf("Library revision is %d\n",(int) hllapi_get_revision()); - - if(host) { - - printf("connect=%d\n",(int) hllapi_connect((char *) host,1)); - printf("wait_for_ready=%d\n",(int) hllapi_wait_for_ready(10)); - printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No"); - - printf("disconnect=%d\n",(int) hllapi_disconnect()); - } - - printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No"); - - rc = hllapi_deinit(); - printf("hllapi_deinit exits with rc=%d\n",rc); - - return 0; - } - -/* - int main(int numpar, char *param[]) - { - char buffer[BUFFER_LENGTH]; - unsigned short rc; - unsigned short len; - unsigned long fn; - - static const struct _cmd - { - const char * name; - unsigned short fn; - const char * arg; - } cmd[] = - { - { "GetRevision", HLLAPI_CMD_GETREVISION, " " }, - { "ConnectPS", HLLAPI_CMD_CONNECTPS, "pw3270A" }, - { "InputString", HLLAPI_CMD_INPUTSTRING, "test" }, - - }; - - int f; - - - for(f=0;f< (sizeof(cmd)/sizeof(struct _cmd)); f++) - { - len = strlen(cmd[f].arg); - memcpy(buffer,cmd[f].arg,len); - hllapi((LPWORD) &cmd[f].fn,buffer,&len,&rc); - printf("%s exits with rc=%d\n[%s]\n",cmd[f].name,rc,buffer); - } - - len = 80; - rc = 1040; - fn = HLLAPI_CMD_COPYPSTOSTR; - hllapi((LPWORD) &fn,buffer,&len,&rc); - printf("%s exits with rc=%d\n%s\n","HLLAPI_CMD_COPYPSTOSTR",rc,buffer); - - // Performance - len = strlen(cmd[0].arg); - memcpy(buffer,cmd[0].arg,len); - if(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0) - { - time_t end = time(0) + 5; - int qtd = 0; - do - { - qtd++; - } while(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0 && time(0) - * - * 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 testprogram.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - - - /** - * @brief Test program for pw3270 HLLAPI compatibility plugin. - * - */ - - #include - #include - #include - #include - #include - #include - #include - - /*---[ Globals ]------------------------------------------------------------------------------------*/ - - const gchar * plugin_path = ".bin/Debug"; - const gchar * session_name = "pw3270"; - const gchar * plugin_name = "ipc3270c." G_MODULE_SUFFIX; - - /*---[ Implement ]----------------------------------------------------------------------------------*/ - - static void close_module(GtkWidget *widget, GModule *module) - { - g_message("Closing module %p",module); - - static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL; - if(!g_module_symbol(module,"pw3270_plugin_stop",(void **) &stop)) - { - g_message("Can't get stop method from plugin: %s",g_module_error()); - } - else - { - stop(gtk_widget_get_toplevel(widget),widget); - } - - g_module_close(module); - g_message("Module %p was closed",module); - } - - static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal) - { - v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button)); - } - - static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal) - { - v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button)); - } - - static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal) - { - v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button)); - } - - static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal) - { - v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button)); - } - - static void toggle_started_trace(GtkToggleToolButton *button, GModule *module) - { - if(!module) - return; - - GtkWidget * terminal = GTK_WIDGET(g_object_get_data(G_OBJECT(button),"terminal")); - - const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop"); - - static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL; - if(!g_module_symbol(module,method_name,(void **) &call)) - { - g_message("Can't get method \"%s\": %s",method_name,g_module_error()); - return; - } - - g_message("Calling %s",method_name); - call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal)); - - } - - static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback) - { - GtkToolItem * item = gtk_toggle_tool_button_new(); - gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label); - - g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal); - - if(tooltip) - gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip); - - return item; - } - - static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { - - GtkWidget * window = gtk_application_window_new(app); - GtkWidget * terminal = v3270_new(); - GtkWidget * notebook = gtk_notebook_new(); - GModule * module = NULL; - - gtk_widget_set_name(window,session_name); - v3270_set_session_name(terminal, session_name); - - // Setup tabs - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal))); - - // Load plugin - { - g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL); - - g_message("Loading %s",plugin); - - module = g_module_open(plugin,G_MODULE_BIND_LOCAL); - - if(module) - { - g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module); - } - else - { - g_message("Can't open \"%s\": %s",plugin,g_module_error()); - gtk_main_quit(); - } - - } - // Create trace window - { - GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0); - GtkWidget * trace = v3270_trace_new(terminal); - GtkWidget * toolbar = gtk_toolbar_new(); - GtkToolItem * start = gtk_toggle_tool_button_new(); - - gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL); - - g_object_set_data(G_OBJECT(start),"terminal",terminal); - - gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable"); - g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module); - gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module"); - - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1); - - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1); - - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1); - - gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0); - gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace")); - } - - // Setup and show main window - gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); - gtk_container_add(GTK_CONTAINER(window),notebook); - gtk_widget_show_all (window); - - // Setup title. - const gchar *url = lib3270_get_url(v3270_get_session(terminal)); - if(url) { - - v3270_set_url(terminal,url); - v3270_reconnect(terminal); - - gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url); - gtk_window_set_title(GTK_WINDOW(window), title); - g_free(title); - - } else { - - gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal)); - - } - -} - -int main (int argc, char **argv) { - - static const GOptionEntry app_options[] = { - { "plugin-path", 'P', 0, G_OPTION_ARG_STRING, &plugin_path, "Path for plugin search", NULL }, - { "session-name", 'S', 0, G_OPTION_ARG_STRING, &session_name, "Session name", "pw3270" }, - { "module", 'm', 0, G_OPTION_ARG_STRING, &plugin_name, "Module name", "ipc3270c." G_MODULE_SUFFIX }, - - { NULL } - }; - - GtkApplication *app; - int status; - - app = gtk_application_new("br.com.bb.ipc3270c",G_APPLICATION_FLAGS_NONE); - - g_application_add_main_option_entries(G_APPLICATION(app),app_options); - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); - - status = g_application_run (G_APPLICATION (app), argc, argv); - g_object_unref (app); - - g_message("rc=%d",status); - return status; - -} - diff --git a/src/testprograms/linux/test.sh b/src/testprograms/linux/test.sh deleted file mode 100755 index 376ed60..0000000 --- a/src/testprograms/linux/test.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash - -SESSION=a -DEST=br.com.bb.pw3270 -BPATH=/br/com/bb/pw3270 - -run_command() -{ - - case $1 in - - revision) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getRevision - ;; - - message) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getMessageID - ;; - - ssl) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getSecureState - ;; - - connect) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.connect string:$2 int32:10 - ;; - - disconnect) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.disconnect - ;; - - url) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getURL - ;; - - quit) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.quit - ;; - - get) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getScreenContents - ;; - - gettext) -# addr,len,lf -# dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:0 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:10 - ;; - - protect) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getIsProtectedAt int32:$2 int32:$3 - ;; - - set) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setTextAt int32:$2 int32:$3 string:$4 - ;; - - action) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.action string:$2 - ;; - - enter) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.enter - ;; - - isconnected) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.isConnected - ;; - - hostcharset) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getHostCharset - ;; - - displaycharset) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getDisplayCharset - ;; - - unlockdelay) - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setUnlockDelay int32:$2 - ;; - - *) - echo "Comando $1 desconhecido" - ;; - - esac -} - - - -until [ -z "$1" ] -do - if [ ${1:0:2} = '--' ]; then - tmp=${1:2} - parameter=${tmp%%=*} - parameter=$(echo $parameter | tr "[:lower:]" "[:upper:]") - value=${tmp##*=} - - case "$parameter" in - SESSION) - SESSION=$value - ;; - HELP) - echo "$0 options" - echo "" - echo "Options:" - echo "" - echo " --session pw3270's session manager" - echo "" - exit 0 - ;; - - *) - eval $parameter=$value - ;; - - esac - - else - run_command $@ - exit 0 - fi - - shift -done - -- libgit2 0.21.2