diff --git a/Makefile.in b/Makefile.in index 1417efb..4f2493c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -80,6 +80,12 @@ $(BINDBG)/lib@LIB3270_NAME@@DLLEXT@: \ @$(MAKE) -C src/lib3270 $@ +$(BINDBG)/lib@LIB3270_NAME@++@DLLEXT@: \ + src/lib3270++/* \ + $(DEPENDS) + + @$(MAKE) -C src/lib3270++ $@ + #---[ Release Rules ]-------------------------------------------------------------------- $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@: \ @@ -88,6 +94,12 @@ $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@: \ @$(MAKE) -C src/lib3270 $@ +$(BINRLS)/lib@LIB3270_NAME@++@DLLEXT@: \ + src/lib3270/* \ + $(DEPENDS) + + @$(MAKE) -C src/lib3270++ $@ + #---[ Misc Rules ]----------------------------------------------------------------------- @@ -105,12 +117,13 @@ $(POTDIR)/lib3270++.pot: \ #---[ Release Targets ]------------------------------------------------------------------ -all: \ - $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@ \ - lib@LIB3270_NAME@.pot +all: + @$(MAKE) -C src/lib3270 $@ + @$(MAKE) -C src/lib3270++ $@ Release: \ - $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@ + $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@ \ + $(BINRLS)/lib@LIB3270_NAME@++@DLLEXT@ #---[ Misc Targets ]--------------------------------------------------------------------- @@ -127,10 +140,10 @@ lib@LIB3270_NAME@.pot: \ #---[ Install Targets ]------------------------------------------------------------------ -install: \ - $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@ +install: - @$(MAKE) DESTDIR=$(DESTDIR) -C src/lib3270 $@ + $(MAKE) DESTDIR=$(DESTDIR) -C src/lib3270 $@ + $(MAKE) DESTDIR=$(DESTDIR) -C src/lib3270++ $@ #---[ Debug Targets ]-------------------------------------------------------------------- @@ -150,11 +163,13 @@ cleanDebug: @rm -fr $(BINDBG) @$(MAKE) -C src/lib3270 $@ + @$(MAKE) -C src/lib3270++ $@ cleanRelease: @rm -fr $(BINRLS) @$(MAKE) -C src/lib3270 $@ + @$(MAKE) -C src/lib3270++ $@ clean: \ cleanDebug \ diff --git a/configure.ac b/configure.ac index 5d92ed2..e46a0ec 100644 --- a/configure.ac +++ b/configure.ac @@ -452,6 +452,8 @@ AC_CONFIG_FILES(src/lib3270/Makefile) AC_CONFIG_FILES(src/lib3270/version.c) AC_CONFIG_FILES(src/lib3270/lib3270.pc) +AC_CONFIG_FILES(src/lib3270++/lib3270++.pc) + AC_CONFIG_FILES(src/lib3270++/Makefile) dnl --------------------------------------------------------------------------- diff --git a/rpm/lib3270.spec b/rpm/lib3270.spec index 1acb279..628b774 100644 --- a/rpm/lib3270.spec +++ b/rpm/lib3270.spec @@ -1,5 +1,5 @@ # -# spec file for package lib3270 +# spec file for packages lib3270 and lib3270++ # # Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (C) <2008> @@ -23,7 +23,6 @@ %define _libvrs %{MAJOR_VERSION}_%{MINOR_VERSION} -%define libname lib32705_2 %define documentroot /srv/www/htdocs/mentor #Compat macro for new _fillupdir macro introduced in Nov 2017 @@ -70,20 +69,40 @@ TN3270 access library originally designed as part of the pw3270 application. See more details at https://softwarepublico.gov.br/social/pw3270/ +#---[ C++ API ]------------------------------------------------------------------------------------------------------- + +%package -n lib3270++-%{_libvrs} + +Summary: TN3270 Access C++ library +Group: Development/Libraries/C and C++ + +Requires: %{name} = %{version} + +Provides: lib3270++%{MAJOR_VERSION}_%{MINOR_VERSION} +Conflicts: otherproviders(lib3270++%{MAJOR_VERSION}_%{MINOR_VERSION}) + +%description + +TN3270 access library originally designed as part of the pw3270 application (C++ Version). + +See more details at https://softwarepublico.gov.br/social/pw3270/ + #---[ Development ]--------------------------------------------------------------------------------------------------- %package devel Summary: TN3270 Access library development files Group: Development/Libraries/C and C++ + Requires: %{name} = %{version} +Requires: lib3270++-%{_libvrs} = %{version} Provides: lib3270-devel = %{version} Conflicts: otherproviders(lib3270-devel) %description devel -TN3270 access library for C development files. +TN3270 access library for C/C++ development files. Originally designed as part of the pw3270 application. @@ -115,6 +134,12 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/lib3270.so.5 %{_libdir}/lib3270.so.5.2 +%files -n lib3270++-%{_libvrs} +%defattr(-,root,root) + +%{_libdir}/lib3270++.so.5 +%{_libdir}/lib3270++.so.5.2 + %files devel %defattr(-,root,root) @@ -127,6 +152,11 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/lib3270.so %{_libdir}/lib3270.a +%{_includedir}/lib3270++.h + +%{_libdir}/lib3270++.so +%{_libdir}/lib3270++.a + %pre /sbin/ldconfig exit 0 @@ -139,4 +169,12 @@ exit 0 /sbin/ldconfig exit 0 +%post -n lib3270++-%{_libvrs} +/sbin/ldconfig +exit 0 + +%postun -n lib3270++-%{_libvrs} +/sbin/ldconfig +exit 0 + %changelog diff --git a/src/include/lib3270++.h b/src/include/lib3270++.h index 1404430..b49f2dd 100644 --- a/src/include/lib3270++.h +++ b/src/include/lib3270++.h @@ -121,7 +121,7 @@ MESSAGE_X = LIB3270_MESSAGE_X, ///< @brief -- MESSAGE_RESOLVING = LIB3270_MESSAGE_RESOLVING, ///< @brief Resolving hostname (running DNS query) -// MESSAGE_CONNECTING, = LIB3270_MESSAGE_CONNECTING ///< @brief Connecting to host + MESSAGE_CONNECTING = LIB3270_MESSAGE_CONNECTING ///< @brief Connecting to host }; diff --git a/src/lib3270++/Makefile.in b/src/lib3270++/Makefile.in index a8801eb..33e451c 100644 --- a/src/lib3270++/Makefile.in +++ b/src/lib3270++/Makefile.in @@ -95,9 +95,11 @@ CFLAGS= \ LIBS= \ @LIBS@ \ + @LIBSSL_LIBS@ \ @LIBICONV@ \ @INTL_LIBS@ + #---[ Debug Rules ]---------------------------------------------------------------------- $(OBJDBG)/%.o: \ @@ -166,13 +168,14 @@ $(POTDIR)/$(LIBNAME)/%.pot: \ all: \ $(BINRLS)/$(LIBNAME)@DLLEXT@ \ - $(BINRLS)/$(LIBNAME).a \ + $(BINRLS)/static/$(LIBNAME).a \ $(POTDIR)/$(LIBNAME).pot Release: \ $(BINRLS)/$(LIBNAME)@DLLEXT@ \ - $(BINRLS)/$(LIBNAME).a + $(BINRLS)/static/$(LIBNAME).a + $(BINRLS)/$(LIBNAME)@DLLEXT@: \ $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ @@ -196,15 +199,18 @@ $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ @$(MKDIR) `dirname $@` @echo $< ... + @$(LD) \ - -shared -Wl,-soname,$(@F) \ + -shared \ + -Wl,-soname,$(@F) \ -o $@ \ $(LDFLAGS) \ $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \ -L$(BINRLS) \ - $(LIBS) + $(LIBS) \ + -l3270 -$(BINRLS)/$(LIBNAME).a: \ +$(BINRLS)/static/$(LIBNAME).a: \ $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) @echo $@ ... @@ -216,7 +222,7 @@ $(BINRLS)/$(LIBNAME).a: \ install: \ $(BINRLS)/$(LIBNAME)@DLLEXT@ \ - $(BINRLS)/$(LIBNAME).a + $(BINRLS)/static/$(LIBNAME).a # Install library @mkdir -p $(DESTDIR)$(libdir) @@ -236,17 +242,10 @@ install: \ # Install static library @$(INSTALL_DATA) \ - $(BINRLS)/$(LIBNAME).a \ + $(BINRLS)/static/$(LIBNAME).a \ $(DESTDIR)$(libdir) # Install SDK - - @mkdir -p $(DESTDIR)$(includedir)/$(LIBNAME) - - @$(INSTALL_DATA) \ - ../include/$(LIBNAME)/*.h \ - $(DESTDIR)$(includedir)/$(LIBNAME) - @$(INSTALL_DATA) \ ../include/$(LIBNAME).h \ $(DESTDIR)$(includedir)/$(LIBNAME).h @@ -361,12 +360,18 @@ clean: \ cleanDebug: @rm -fr $(OBJDBG) - @rm -fr $(BINDBG) + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@ cleanRelease: @rm -fr $(OBJRLS) - @rm -fr $(BINRLS) + + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@ + @rm -fr $(POTDIR) @rm -f lib$(LIBNAME).pot diff --git a/src/lib3270++/abstract.cc b/src/lib3270++/abstract.cc index 5ceb99d..d65f3db 100644 --- a/src/lib3270++/abstract.cc +++ b/src/lib3270++/abstract.cc @@ -110,10 +110,10 @@ if(in && converter != (iconv_t)(-1)) { - size_t out = (in << 1); - char * ptr; - char * outBuffer = (char *) malloc(out); - char * inBuffer = (char *) str; + size_t out = (in << 1); + char * ptr; + char * outBuffer = (char *) malloc(out); + ICONV_CONST char * inBuffer = (ICONV_CONST char *) str; memset(ptr=outBuffer,0,out); diff --git a/src/lib3270++/lib3270++.cbp b/src/lib3270++/lib3270++.cbp index 566cef6..362c31a 100644 --- a/src/lib3270++/lib3270++.cbp +++ b/src/lib3270++/lib3270++.cbp @@ -40,6 +40,7 @@ + diff --git a/src/lib3270++/local/events.cc b/src/lib3270++/local/events.cc index 4d6c5ad..39cd2e2 100644 --- a/src/lib3270++/local/events.cc +++ b/src/lib3270++/local/events.cc @@ -37,6 +37,7 @@ */ #include "../private.h" + #include extern "C" { #include @@ -47,6 +48,35 @@ /*---[ Implement ]----------------------------------------------------------------------------------*/ +#ifndef HAVE_VASPRINTF + int vasprintf(char **strp, const char *fmt, va_list ap) { + char buf[1024]; + + int nc = vsnprintf(buf, sizeof(buf), fmt, args); + + if(nc < 0) { + + *strp = strdup(_("Error in vasprintf")); + + } else if (nc < sizeof(buf)) { + + *strp = malloc(nc+1); + strcpy(*strp, buf); + + } else { + + *strp = malloc(nc + 1); + if(vsnprintf(*strp, nc, fmt, args) < 0) { + free(*strp); + *strp = strdup(NULL,_( "Out of memory in vasprintf" ) ); + } + + } + + return nc; + } +#endif // !HAVE_VASPRINTF + namespace TN3270 { /// @brief Popup Handler. @@ -55,7 +85,7 @@ Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270); if(!session) { - throw std::runtime_error("Invalid session handler"); + throw std::runtime_error(_( "Invalid session handler" )); } class PopupEvent : public TN3270::Event { @@ -108,7 +138,7 @@ Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270); if(!session) { - throw std::runtime_error("Invalid session handler"); + throw std::runtime_error(_("Invalid session handler")); } class ConnectionEvent : public TN3270::Event { @@ -130,7 +160,7 @@ /// @brief Get event description. std::string toString() const override { - return this->connected ? "connected" : "disconnected"; + return this->connected ? _("connected") : _("disconnected"); } }; diff --git a/src/lib3270++/local/session.cc b/src/lib3270++/local/session.cc index aa8adcc..5318d5f 100644 --- a/src/lib3270++/local/session.cc +++ b/src/lib3270++/local/session.cc @@ -65,7 +65,7 @@ cbk = lib3270_get_session_callbacks(this->hSession,sizeof(struct lib3270_session_callbacks)); if(!cbk) { - throw std::runtime_error( "Invalid callback table, possible version mismatch in lib3270" ); + throw std::runtime_error( _("Invalid callback table, possible version mismatch in lib3270") ); } cbk->update_connect = connectHandler; @@ -120,7 +120,7 @@ char * text = lib3270_get_text(hSession, baddr, len, lf); if(!text) { - throw std::runtime_error("Can't get screen contents"); + throw std::runtime_error( _("Can't get screen contents") ); } string rc = convertFromHost(text); @@ -138,7 +138,7 @@ char * text = lib3270_get_text_at(hSession, row, col, sz, lf); if(!text) { - throw std::runtime_error("Can't get screen contents"); + throw std::runtime_error( _("Can't get screen contents") ); } string rc = convertFromHost(text); diff --git a/src/lib3270++/private.h b/src/lib3270++/private.h index 87aad4f..b4057b9 100644 --- a/src/lib3270++/private.h +++ b/src/lib3270++/private.h @@ -41,12 +41,27 @@ #define PRIVATE_H_INCLUDED #include + + #ifdef WIN32 + #include + #include + #include + #endif // WIN32 + #include #include #include #include #include +#ifdef HAVE_LIBINTL + #include + #define _( x ) gettext(x) + #define N_( x ) x +#else + #define _( x ) x + #define N_( x ) x +#endif // HAVE_LIBINTL #ifdef HAVE_ICONV #include diff --git a/src/lib3270/Makefile.in b/src/lib3270/Makefile.in index 4ea6aae..32b9a7a 100644 --- a/src/lib3270/Makefile.in +++ b/src/lib3270/Makefile.in @@ -168,13 +168,13 @@ $(POTDIR)/$(LIBNAME)/%.pot: \ all: \ $(BINRLS)/$(LIBNAME)@DLLEXT@ \ - $(BINRLS)/$(LIBNAME).a \ + $(BINRLS)/static/$(LIBNAME).a \ $(POTDIR)/$(LIBNAME).pot Release: \ $(BINRLS)/$(LIBNAME)@DLLEXT@ \ - $(BINRLS)/$(LIBNAME).a + $(BINRLS)/static/$(LIBNAME).a $(BINRLS)/$(LIBNAME)@DLLEXT@: \ $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ @@ -205,7 +205,7 @@ $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \ $(LIBS) -$(BINRLS)/$(LIBNAME).a: \ +$(BINRLS)/static/$(LIBNAME).a: \ $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) @echo $@ ... @@ -217,7 +217,7 @@ $(BINRLS)/$(LIBNAME).a: \ install: \ $(BINRLS)/$(LIBNAME)@DLLEXT@ \ - $(BINRLS)/$(LIBNAME).a + $(BINRLS)/static/$(LIBNAME).a # Install library @mkdir -p $(DESTDIR)$(libdir) @@ -237,7 +237,7 @@ install: \ # Install static library @$(INSTALL_DATA) \ - $(BINRLS)/$(LIBNAME).a \ + $(BINRLS)/static/$(LIBNAME).a \ $(DESTDIR)$(libdir) # Install SDK diff --git a/src/lib3270/lib3270.pc.in b/src/lib3270/lib3270.pc.in index 42f2715..232f9b4 100644 --- a/src/lib3270/lib3270.pc.in +++ b/src/lib3270/lib3270.pc.in @@ -11,6 +11,6 @@ Name: @PACKAGE_NAME@ Description: @PACKAGE_DESCRIPTION@ Version: @PACKAGE_VERSION@ Libs: -L\@libdir@ -l@LIB3270_NAME@ -Libs.private: @LIBSSL_LIBS@ +Libs.private: @LIBSSL_LIBS@ @INTL_LIBS@ Cflags: -I@includedir@ -- libgit2 0.21.2