diff --git a/Makefile.in b/Makefile.in
index c1cab4f..58d110c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -112,7 +112,7 @@ $(OBJDBG)/%.o: \
@$(CXX) \
$(CFLAGS) \
- -Wall -Wextra -fstack-check \
+ -g -Wall -Wextra -fstack-check \
-DDEBUG=1 \
-o $@ \
-c $<
@@ -159,7 +159,7 @@ $(BINRLS)/$(SONAME): \
@$(MKDIR) $(dir $@)
@echo $< ...
@$(LD) \
- @DLL_LDFLAGS@ \
+ -shared -Wl,-soname,$(@F) \
-o $@ \
$(LDFLAGS) \
$^ \
diff --git a/configure.ac b/configure.ac
index c1a9d39..c76ea36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,18 +57,6 @@ AC_PROG_LN_S
AC_LANG([C++])
dnl ---------------------------------------------------------------------------
-dnl Initialize defaults
-dnl ---------------------------------------------------------------------------
-
-DBG_CFLAGS="-g -fstack-check -DDEBUG=1"
-RLS_CFLAGS="-DNDEBUG=1"
-PLUGINS=""
-APP_RESOURCES=""
-APP_LDFLAGS=""
-DLL_LDFLAGS="-shared -Wl,-soname,\$(@F)"
-DEPENDS=""
-
-dnl ---------------------------------------------------------------------------
dnl Version info
dnl ---------------------------------------------------------------------------
@@ -109,7 +97,9 @@ case "$host" in
*-mingw32|*-pc-msys)
app_cv_osname="windows"
- CFLAGS="$CFLAGS -pthread -D_WIN32_WINNT=0x0600"
+ CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0600"
+ LDFLAGS="-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic -static-libgcc -static-libstdc++ $LDFLAGS"
+
LIBS="$LIBS -lws2_32 -lwtsapi32 -lcomdlg32"
DLLEXT=".dll"
@@ -137,8 +127,8 @@ case "$host" in
;;
*)
- CFLAGS="$CFLAGS -pthread"
- LDFLAGS="$LDFLAGS -pthread"
+ CFLAGS="$CFLAGS"
+ LDFLAGS="$LDFLAGS"
app_cv_datadir="/usr/share"
app_cv_confdir="/etc"
app_cv_osname="linux"
@@ -155,8 +145,6 @@ AC_SUBST(LIBS)
AC_SUBST(LOGDIR)
AC_SUBST(DLLEXT)
AC_SUBST(DLLPREFIX)
-AC_SUBST(LDFLAGS)
-AC_SUBST(DLL_LDFLAGS)
dnl ---------------------------------------------------------------------------
dnl Check for other programs
@@ -261,10 +249,9 @@ if test "$app_cv_static_ipc3270" == "auto"; then
fi
if test "$app_cv_static_ipc3270" == "yes"; then
- LDFLAGS="-static -static-libgcc -static-libstdc++ $LDFLAGS"
PKG_CHECK_MODULES( [IPC3270], [ipc3270-static], AC_DEFINE(USING_STATIC_IPC3270), AC_MSG_ERROR([IPC3270 not present.]))
else
- PKG_CHECK_MODULES( [IPC3270], [ipc3270], AC_DEFINE(USING_SHARED_IPC3270), AC_MSG_ERROR([IPC3270 not present.]))
+ PKG_CHECK_MODULES( [IPC3270], [ipc3270], AC_DEFINE(USING_DYNAMIC_IPC3270), AC_MSG_ERROR([IPC3270 not present.]))
fi
AC_SUBST(IPC3270_LIBS)
@@ -309,12 +296,14 @@ dnl ---------------------------------------------------------------------------
dnl Configure which files to generate.
dnl ---------------------------------------------------------------------------
-AC_SUBST(DEPENDS)
AC_CONFIG_FILES(Makefile)
dnl ---------------------------------------------------------------------------
dnl Output the generated config.status script.
dnl ---------------------------------------------------------------------------
+
+AC_SUBST(LDFLAGS)
+
AC_SUBST(BASEDIR,$ac_pwd)
AC_OUTPUT
diff --git a/hllapi.cbp b/hllapi.cbp
index 4d8ed48..1caf025 100644
--- a/hllapi.cbp
+++ b/hllapi.cbp
@@ -42,6 +42,7 @@
+
diff --git a/rpm/libhllapi.spec b/rpm/libhllapi.spec
index ec28864..9508647 100644
--- a/rpm/libhllapi.spec
+++ b/rpm/libhllapi.spec
@@ -1,5 +1,5 @@
#
-# spec file for packages pw3270-plugin-ipc
+# spec file for package libhllapi
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (C) <2008>
@@ -16,15 +16,10 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
-#---[ Versions ]------------------------------------------------------------------------------------------------------
-
-%define MAJOR_VERSION 5
-%define MINOR_VERSION 2
-
-#---[ Main package ]--------------------------------------------------------------------------------------------------
+#---[ Package header ]------------------------------------------------------------------------------------------------
Summary: HLLAPI client library for lib3270/pw3270
-Name: libhllapi5_2
+Name: libhllapi
Version: 5.2
Release: 0
License: LGPL-3.0
@@ -32,8 +27,7 @@ Source: lib3270-hllapi-bindings-%{version}.tar.xz
Url: https://github.com/PerryWerneck/lib3270-hllapi-bindings.git
-Group: System/X11/Terminals
-BuildRoot: /var/tmp/%{name}-%{version}
+Group: Development/Libraries/C and C++
BuildRequires: autoconf >= 2.61
BuildRequires: automake
@@ -63,6 +57,24 @@ HLLAPI client library for pw3270/lib3270
See more details at https://softwarepublico.gov.br/social/pw3270/
+#---[ Library ]-------------------------------------------------------------------------------------------------------
+
+%define MAJOR_VERSION %(echo %{version} | cut -d. -f1)
+%define MINOR_VERSION %(echo %{version} | cut -d. -f2)
+%define _libvrs %{MAJOR_VERSION}_%{MINOR_VERSION}
+
+%package -n %{name}%{_libvrs}
+Summary: HLLAPI client library for lib3270/pw3270
+Group: Development/Libraries/C and C++
+
+%description -n %{name}%{_libvrs}
+
+HLLAPI client library for pw3270/lib3270
+
+See more details at https://softwarepublico.gov.br/social/pw3270/
+
+#---[ Development package ]-------------------------------------------------------------------------------------------
+
%package devel
Summary: HLLAPI Development files.
@@ -76,7 +88,8 @@ Development files for lib3270/pw3270 HLLAPI client library.
%prep
%setup -n lib3270-hllapi-bindings-%{version}
-NOCONFIGURE=1 ./autogen.sh
+NOCONFIGURE=1 \
+ ./autogen.sh
%configure
@@ -87,33 +100,33 @@ make all
%install
rm -rf $RPM_BUILD_ROOT
-make \
- DESTDIR=%{?buildroot:%{buildroot}} \
- install
+%makeinstall
-%files
+%files -n %{name}%{_libvrs}
%defattr(-,root,root)
-%doc AUTHORS LICENSE README.md
-%{_libdir}/libhllapi.so.%{MAJOR_VERSION}
-%{_libdir}/libhllapi.so.%{MAJOR_VERSION}.%{MINOR_VERSION}
+# https://en.opensuse.org/openSUSE:Packaging_for_Leap#RPM_Distro_Version_Macros
+%if 0%{?sle_version} > 120200
+%doc AUTHORS README.md
+%license LICENSE
+%else
+%doc AUTHORS README.md LICENSE
+%endif
+
+%{_libdir}/%{name}.so.%{MAJOR_VERSION}
+%{_libdir}/%{name}.so.%{MAJOR_VERSION}.%{MINOR_VERSION}
%files devel
%defattr(-,root,root)
-%{_libdir}/libhllapi.so
+
+%{_libdir}/%{name}.so
%{_includedir}/lib3270/hllapi.h
-%pre
-/sbin/ldconfig
-exit 0
+%pre -n %{name}%{_libvrs} -p /sbin/ldconfig
-%post
-/sbin/ldconfig
-exit 0
+%post -n %{name}%{_libvrs} -p /sbin/ldconfig
-%postun
-/sbin/ldconfig
-exit 0
+%postun -n %{name}%{_libvrs} -p /sbin/ldconfig
%changelog
diff --git a/src/core/tools.cc b/src/core/tools.cc
index c1244db..c4f206e 100644
--- a/src/core/tools.cc
+++ b/src/core/tools.cc
@@ -34,6 +34,54 @@
HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir) {
+ LSTATUS rc;
+ HKEY hKey = 0;
+ unsigned long szDatadir = strlen(datadir);
+
+ static const char * keys[] = {
+
+ "Software\\" LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),
+ "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),
+
+#ifdef LIB3270_NAME
+ "Software\\" LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME),
+ "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME),
+#endif
+
+ "Software\\pw3270",
+ "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\pw3270"
+ };
+
+ size_t ix;
+
+ string installLocation;
+
+ *datadir = 0;
+
+ for(ix = 0; !*datadir && ix < (sizeof(keys)/sizeof(keys[0])); ix++) {
+
+ rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keys[ix],0,KEY_QUERY_VALUE,&hKey);
+ if(rc == ERROR_SUCCESS) {
+
+ unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
+ unsigned long datalen = (unsigned long) szDatadir;
+
+ memset(datadir,0,datalen);
+
+ rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen);
+ if(rc != ERROR_SUCCESS) {
+ *datadir = 0; // Just in case
+ }
+
+ RegCloseKey(hKey);
+
+ }
+
+ }
+
+
+
+ /*
#ifdef _WIN32
HKEY hKey = 0;
unsigned long datalen = strlen(datadir);
@@ -48,6 +96,7 @@
RegCloseKey(hKey);
}
#endif // _WIN32
+*/
return *datadir;
}
diff --git a/src/core/windows/init.cc b/src/core/windows/init.cc
new file mode 100644
index 0000000..8d29ed1
--- /dev/null
+++ b/src/core/windows/init.cc
@@ -0,0 +1,200 @@
+/*
+ * "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 - e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+/**
+ * @file
+ *
+ * @brief Win32 delayed loading support methods.
+ *
+ * @author perry.werneck@gmail.com
+ *
+ */
+
+ #include
+ #include
+ #include
+ #include "../private.h"
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ #ifdef USING_STATIC_IPC3270
+
+ extern "C" {
+
+ extern __declspec (dllexport) PfnDliHook __pfnDliNotifyHook2;
+ extern __declspec (dllexport) PfnDliHook __pfnDliFailureHook2;
+
+ FARPROC WINAPI hllapi_delay_load_hook(unsigned reason, DelayLoadInfo * info);
+
+ }
+
+ using std::string;
+
+/*---[ Implement ]----------------------------------------------------------------------------------*/
+
+ // https://docs.microsoft.com/en-us/cpp/build/reference/loading-all-imports-for-a-delay-loaded-dll?view=vs-2019
+
+ PfnDliHook __pfnDliNotifyHook2 = hllapi_delay_load_hook;
+ PfnDliHook __pfnDliFailureHook2 = hllapi_delay_load_hook;
+
+ static HANDLE hModule = 0;
+ static HANDLE hEventLog = 0;
+
+ BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwcallpurpose, LPVOID lpvResvd) {
+ switch(dwcallpurpose) {
+ case DLL_PROCESS_ATTACH:
+ hModule = hInstance;
+ hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME));
+ break;
+
+ case DLL_PROCESS_DETACH:
+ hModule = 0;
+ DeregisterEventSource(hEventLog);
+ hEventLog = 0;
+ break;
+
+ }
+
+ return TRUE;
+ }
+
+ static void eventlog(const char *msg) {
+
+ char username[UNLEN + 1];
+ DWORD szName = sizeof(username);
+
+ memset(username,0,UNLEN + 1);
+
+ if(!GetUserName(username, &szName)) {
+ username[0] = 0;
+ }
+
+ const char *outMsg[] = {
+ username,
+ PACKAGE_NAME,
+ msg
+ };
+
+ debug("Event: \"%s\"",msg);
+
+ ReportEvent(
+ hEventLog,
+ EVENTLOG_ERROR_TYPE,
+ 1,
+ 0,
+ NULL,
+ 3,
+ 0,
+ outMsg,
+ NULL
+ );
+
+ }
+
+ static void dummyProc() {
+ throw std::runtime_error("Operation not supported");
+ }
+
+ FARPROC WINAPI hllapi_delay_load_hook(unsigned reason, DelayLoadInfo * info) {
+
+ static string savedpath;
+
+ // https://docs.microsoft.com/en-us/cpp/build/reference/structure-and-constant-definitions?view=vs-2019
+ switch (reason) {
+ case dliNoteStartProcessing:
+ {
+
+ char datadir[4096];
+ memset(datadir,' ',sizeof(datadir));
+ datadir[sizeof(datadir)-1] = 0;
+
+ hllapi_get_datadir(datadir);
+
+ if(*datadir) {
+
+ char curdir[4096];
+ memset(curdir,0,sizeof(curdir));
+
+ if(GetCurrentDirectory(sizeof(curdir)-1,curdir)) {
+ savedpath = curdir;
+ } else {
+ savedpath.clear();
+ }
+
+ SetCurrentDirectory(curdir);
+
+ }
+
+ }
+ break;
+
+ case dliNoteEndProcessing:
+ if(!savedpath.empty()) {
+ SetCurrentDirectory(savedpath.c_str());
+ savedpath.clear();
+
+ }
+ break;
+
+ case dliNotePreLoadLibrary:
+ break;
+
+ case dliNotePreGetProcAddress:
+ break;
+
+ case dliFailLoadLib:
+ {
+ string msg = "Can't load ";
+ msg += (const char *) info->szDll;
+ eventlog(msg.c_str());
+ }
+ return (FARPROC) hModule;
+
+ case dliFailGetProc:
+ {
+ string msg = "Can't find method on ";
+ msg += (const char *) info->szDll;
+ eventlog(msg.c_str());
+ }
+ return (FARPROC) dummyProc;
+
+ }
+
+ // Returning NULL causes the delay load machinery to perform default
+ // processing for this notification.
+ return NULL;
+
+ }
+
+ #endif // USING_STATIC_IPC3270
+
diff --git a/src/include/config.h.in b/src/include/config.h.in
index f0a57ed..bb7acd1 100644
--- a/src/include/config.h.in
+++ b/src/include/config.h.in
@@ -47,4 +47,7 @@
#undef PACKAGE_VERSION
#undef PACKAGE_RELEASE
+ #undef USING_STATIC_IPC3270
+ #undef USING_DYNAMIC_IPC3270
+
#endif /* CONFIG_H_INCLUDED */
diff --git a/src/testprogram/testprogram.cc b/src/testprogram/testprogram.cc
index ba7cf9b..268bed4 100644
--- a/src/testprogram/testprogram.cc
+++ b/src/testprogram/testprogram.cc
@@ -44,7 +44,7 @@
char buffer[SCREEN_LENGTH+1];
const char *host = "";
- const char *session = "pw3270:a";
+ const char *session = ""; // "pw3270:a";
#pragma GCC diagnostic push
static struct option options[] =
diff --git a/win/hllapi.nsi b/win/hllapi.nsi
index 3d683c2..f8778d3 100644
--- a/win/hllapi.nsi
+++ b/win/hllapi.nsi
@@ -4,11 +4,11 @@
Name "hllapi"
Caption "hllapi - PW3270 HLLAPI Module"
-outfile "hllapi-5.2.19.9-i686.exe"
+outfile "hllapi-5.2.19.9-x86_64.exe"
XPStyle on
-installDir "$PROGRAMFILES\hllapi"
+installDir "$PROGRAMFILES64\hllapi"
# Get installation folder from registry if available
InstallDirRegKey HKLM "Software\hllapi" "InstallLocation"
@@ -17,10 +17,10 @@ RequestExecutionLevel admin
# Properties
VIProductVersion "5.2.19.9"
-VIFileVersion "19.9.2.11"
+VIFileVersion "19.9.23.14"
VIAddVersionKey "ProductVersion" "5.2.19.9"
-VIAddVersionKey "FileVersion" "19.9.2.11"
+VIAddVersionKey "FileVersion" "19.9.23.14"
VIAddVersionKey "ProductName" "hllapi"
VIAddVersionKey "FileDescription" "PW3270 HLLAPI Module"
@@ -51,7 +51,7 @@ SubSection "hllapi" SecMain
Section "Core" SecCore
- SetRegView 32
+ SetRegView 64
${DisableX64FSRedirection}
# define the output path for this file
@@ -107,7 +107,7 @@ Section "Uninstall"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\hllapi"
DeleteRegKey HKLM "Software\hllapi"
- SetRegView 32
+ SetRegView 64
DeleteRegKey HKLM "Software\hllapi"
SectionEnd
diff --git a/win/pack.sh b/win/pack.sh
index d1410f6..1713df6 100755
--- a/win/pack.sh
+++ b/win/pack.sh
@@ -2,6 +2,7 @@
PROJECT_DIR=$(readlink -f $(dirname $(dirname $(readlink -f $0))))
PUBLISH=0
+CLEAR_OLD=0
pack() {
@@ -11,7 +12,8 @@ pack() {
BUILDDIR=$(mktemp -d)
- ./configure --cache=.${1}.cache \
+ ./configure \
+ --cache=.${1}.cache \
--host=${1}-w64-mingw32 \
--prefix=/usr/${1}-w64-mingw32/sys-root/mingw \
--bindir=${BUILDDIR} \
@@ -54,19 +56,27 @@ pack() {
exit -1
fi
- if [ -d ~/public_html ]; then
- mkdir -p ~/public_html/win
- cp -v *.exe ~/public_html/win
- if [ "$?" != "0" ]; then
- exit -1
+ PRODUCT_NAME=$(${1}-w64-mingw32-pkg-config --variable=product_name lib3270)
+
+ if [ ! -z ${PRODUCT_NAME} ]; then
+
+ if [ -d ~/public_html/win/${PRODUCT_NAME}/${2} ]; then
+
+ if [ "${CLEAR_OLD}" == "1" ]; then
+ rm -fr ~/public_html/win/${PRODUCT_NAME}/${2}/hllapi-*.exe
+ fi
+
+ cp -v *.exe ~/public_html/win/${PRODUCT_NAME}/${2}
+
fi
- fi
- if [ "${PUBLISH}" == "1" ] && [ ! -z ${WIN_PACKAGE_SERVER} ]; then
- scp *.exe ${WIN_PACKAGE_SERVER}
- if [ "$?" != "0" ]; then
- exit -1
+ if [ "${PUBLISH}" == "1" ] && [ ! -z ${WIN_PACKAGE_SERVER} ]; then
+ echo scp *.exe ${WIN_PACKAGE_SERVER}/${PRODUCT_NAME}/${2}
+ if [ "$?" != "0" ]; then
+ exit -1
+ fi
fi
+
fi
mv -f *.exe ${PROJECT_DIR}
@@ -99,10 +109,7 @@ do
;;
CLEAR)
- if [ -d ~/public_html/win ]; then
- rm -fr ~/public_html/win/hllapi-*-{i686,x86_64}.exe
- fi
-
+ CLEAR_OLD=1
;;
HELP)
echo "${0} nome_da_matriz"
@@ -137,7 +144,7 @@ if [ "$?" != "0" ]; then
exit -1
fi
-pack i686
-pack x86_64
+pack i686 x86_32
+pack x86_64 x86_64
--
libgit2 0.21.2