Commit 8429a725ffbddcf17d6f228e988666b10783c5a9

Authored by Perry Werneck
1 parent af992aa9

Packing C++ version preview

Makefile.in
... ... @@ -80,6 +80,12 @@ $(BINDBG)/lib@LIB3270_NAME@@DLLEXT@: \
80 80  
81 81 @$(MAKE) -C src/lib3270 $@
82 82  
  83 +$(BINDBG)/lib@LIB3270_NAME@++@DLLEXT@: \
  84 + src/lib3270++/* \
  85 + $(DEPENDS)
  86 +
  87 + @$(MAKE) -C src/lib3270++ $@
  88 +
83 89 #---[ Release Rules ]--------------------------------------------------------------------
84 90  
85 91 $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@: \
... ... @@ -88,6 +94,12 @@ $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@: \
88 94  
89 95 @$(MAKE) -C src/lib3270 $@
90 96  
  97 +$(BINRLS)/lib@LIB3270_NAME@++@DLLEXT@: \
  98 + src/lib3270/* \
  99 + $(DEPENDS)
  100 +
  101 + @$(MAKE) -C src/lib3270++ $@
  102 +
91 103  
92 104 #---[ Misc Rules ]-----------------------------------------------------------------------
93 105  
... ... @@ -105,12 +117,13 @@ $(POTDIR)/lib3270++.pot: \
105 117  
106 118 #---[ Release Targets ]------------------------------------------------------------------
107 119  
108   -all: \
109   - $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@ \
110   - lib@LIB3270_NAME@.pot
  120 +all:
  121 + @$(MAKE) -C src/lib3270 $@
  122 + @$(MAKE) -C src/lib3270++ $@
111 123  
112 124 Release: \
113   - $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@
  125 + $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@ \
  126 + $(BINRLS)/lib@LIB3270_NAME@++@DLLEXT@
114 127  
115 128 #---[ Misc Targets ]---------------------------------------------------------------------
116 129  
... ... @@ -127,10 +140,10 @@ lib@LIB3270_NAME@.pot: \
127 140  
128 141 #---[ Install Targets ]------------------------------------------------------------------
129 142  
130   -install: \
131   - $(BINRLS)/lib@LIB3270_NAME@@DLLEXT@
  143 +install:
132 144  
133   - @$(MAKE) DESTDIR=$(DESTDIR) -C src/lib3270 $@
  145 + $(MAKE) DESTDIR=$(DESTDIR) -C src/lib3270 $@
  146 + $(MAKE) DESTDIR=$(DESTDIR) -C src/lib3270++ $@
134 147  
135 148 #---[ Debug Targets ]--------------------------------------------------------------------
136 149  
... ... @@ -150,11 +163,13 @@ cleanDebug:
150 163  
151 164 @rm -fr $(BINDBG)
152 165 @$(MAKE) -C src/lib3270 $@
  166 + @$(MAKE) -C src/lib3270++ $@
153 167  
154 168 cleanRelease:
155 169  
156 170 @rm -fr $(BINRLS)
157 171 @$(MAKE) -C src/lib3270 $@
  172 + @$(MAKE) -C src/lib3270++ $@
158 173  
159 174 clean: \
160 175 cleanDebug \
... ...
configure.ac
... ... @@ -452,6 +452,8 @@ AC_CONFIG_FILES(src/lib3270/Makefile)
452 452 AC_CONFIG_FILES(src/lib3270/version.c)
453 453 AC_CONFIG_FILES(src/lib3270/lib3270.pc)
454 454  
  455 +AC_CONFIG_FILES(src/lib3270++/lib3270++.pc)
  456 +
455 457 AC_CONFIG_FILES(src/lib3270++/Makefile)
456 458  
457 459 dnl ---------------------------------------------------------------------------
... ...
rpm/lib3270.spec
1 1 #
2   -# spec file for package lib3270
  2 +# spec file for packages lib3270 and lib3270++
3 3 #
4 4 # Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
5 5 # Copyright (C) <2008> <Banco do Brasil S.A.>
... ... @@ -23,7 +23,6 @@
23 23  
24 24 %define _libvrs %{MAJOR_VERSION}_%{MINOR_VERSION}
25 25  
26   -%define libname lib32705_2
27 26 %define documentroot /srv/www/htdocs/mentor
28 27  
29 28 #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.
70 69  
71 70 See more details at https://softwarepublico.gov.br/social/pw3270/
72 71  
  72 +#---[ C++ API ]-------------------------------------------------------------------------------------------------------
  73 +
  74 +%package -n lib3270++-%{_libvrs}
  75 +
  76 +Summary: TN3270 Access C++ library
  77 +Group: Development/Libraries/C and C++
  78 +
  79 +Requires: %{name} = %{version}
  80 +
  81 +Provides: lib3270++%{MAJOR_VERSION}_%{MINOR_VERSION}
  82 +Conflicts: otherproviders(lib3270++%{MAJOR_VERSION}_%{MINOR_VERSION})
  83 +
  84 +%description
  85 +
  86 +TN3270 access library originally designed as part of the pw3270 application (C++ Version).
  87 +
  88 +See more details at https://softwarepublico.gov.br/social/pw3270/
  89 +
73 90 #---[ Development ]---------------------------------------------------------------------------------------------------
74 91  
75 92 %package devel
76 93  
77 94 Summary: TN3270 Access library development files
78 95 Group: Development/Libraries/C and C++
  96 +
79 97 Requires: %{name} = %{version}
  98 +Requires: lib3270++-%{_libvrs} = %{version}
80 99  
81 100 Provides: lib3270-devel = %{version}
82 101 Conflicts: otherproviders(lib3270-devel)
83 102  
84 103 %description devel
85 104  
86   -TN3270 access library for C development files.
  105 +TN3270 access library for C/C++ development files.
87 106  
88 107 Originally designed as part of the pw3270 application.
89 108  
... ... @@ -115,6 +134,12 @@ rm -rf $RPM_BUILD_ROOT
115 134 %{_libdir}/lib3270.so.5
116 135 %{_libdir}/lib3270.so.5.2
117 136  
  137 +%files -n lib3270++-%{_libvrs}
  138 +%defattr(-,root,root)
  139 +
  140 +%{_libdir}/lib3270++.so.5
  141 +%{_libdir}/lib3270++.so.5.2
  142 +
118 143 %files devel
119 144 %defattr(-,root,root)
120 145  
... ... @@ -127,6 +152,11 @@ rm -rf $RPM_BUILD_ROOT
127 152 %{_libdir}/lib3270.so
128 153 %{_libdir}/lib3270.a
129 154  
  155 +%{_includedir}/lib3270++.h
  156 +
  157 +%{_libdir}/lib3270++.so
  158 +%{_libdir}/lib3270++.a
  159 +
130 160 %pre
131 161 /sbin/ldconfig
132 162 exit 0
... ... @@ -139,4 +169,12 @@ exit 0
139 169 /sbin/ldconfig
140 170 exit 0
141 171  
  172 +%post -n lib3270++-%{_libvrs}
  173 +/sbin/ldconfig
  174 +exit 0
  175 +
  176 +%postun -n lib3270++-%{_libvrs}
  177 +/sbin/ldconfig
  178 +exit 0
  179 +
142 180 %changelog
... ...
src/include/lib3270++.h
... ... @@ -121,7 +121,7 @@
121 121  
122 122 MESSAGE_X = LIB3270_MESSAGE_X, ///< @brief --
123 123 MESSAGE_RESOLVING = LIB3270_MESSAGE_RESOLVING, ///< @brief Resolving hostname (running DNS query)
124   -// MESSAGE_CONNECTING, = LIB3270_MESSAGE_CONNECTING ///< @brief Connecting to host
  124 + MESSAGE_CONNECTING = LIB3270_MESSAGE_CONNECTING ///< @brief Connecting to host
125 125  
126 126 };
127 127  
... ...
src/lib3270++/Makefile.in
... ... @@ -95,9 +95,11 @@ CFLAGS= \
95 95  
96 96 LIBS= \
97 97 @LIBS@ \
  98 + @LIBSSL_LIBS@ \
98 99 @LIBICONV@ \
99 100 @INTL_LIBS@
100 101  
  102 +
101 103 #---[ Debug Rules ]----------------------------------------------------------------------
102 104  
103 105 $(OBJDBG)/%.o: \
... ... @@ -166,13 +168,14 @@ $(POTDIR)/$(LIBNAME)/%.pot: \
166 168  
167 169 all: \
168 170 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
169   - $(BINRLS)/$(LIBNAME).a \
  171 + $(BINRLS)/static/$(LIBNAME).a \
170 172 $(POTDIR)/$(LIBNAME).pot
171 173  
172 174  
173 175 Release: \
174 176 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
175   - $(BINRLS)/$(LIBNAME).a
  177 + $(BINRLS)/static/$(LIBNAME).a
  178 +
176 179  
177 180 $(BINRLS)/$(LIBNAME)@DLLEXT@: \
178 181 $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@
... ... @@ -196,15 +199,18 @@ $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \
196 199  
197 200 @$(MKDIR) `dirname $@`
198 201 @echo $< ...
  202 +
199 203 @$(LD) \
200   - -shared -Wl,-soname,$(@F) \
  204 + -shared \
  205 + -Wl,-soname,$(@F) \
201 206 -o $@ \
202 207 $(LDFLAGS) \
203 208 $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \
204 209 -L$(BINRLS) \
205   - $(LIBS)
  210 + $(LIBS) \
  211 + -l3270
206 212  
207   -$(BINRLS)/$(LIBNAME).a: \
  213 +$(BINRLS)/static/$(LIBNAME).a: \
208 214 $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)
209 215  
210 216 @echo $@ ...
... ... @@ -216,7 +222,7 @@ $(BINRLS)/$(LIBNAME).a: \
216 222  
217 223 install: \
218 224 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
219   - $(BINRLS)/$(LIBNAME).a
  225 + $(BINRLS)/static/$(LIBNAME).a
220 226  
221 227 # Install library
222 228 @mkdir -p $(DESTDIR)$(libdir)
... ... @@ -236,17 +242,10 @@ install: \
236 242  
237 243 # Install static library
238 244 @$(INSTALL_DATA) \
239   - $(BINRLS)/$(LIBNAME).a \
  245 + $(BINRLS)/static/$(LIBNAME).a \
240 246 $(DESTDIR)$(libdir)
241 247  
242 248 # Install SDK
243   -
244   - @mkdir -p $(DESTDIR)$(includedir)/$(LIBNAME)
245   -
246   - @$(INSTALL_DATA) \
247   - ../include/$(LIBNAME)/*.h \
248   - $(DESTDIR)$(includedir)/$(LIBNAME)
249   -
250 249 @$(INSTALL_DATA) \
251 250 ../include/$(LIBNAME).h \
252 251 $(DESTDIR)$(includedir)/$(LIBNAME).h
... ... @@ -361,12 +360,18 @@ clean: \
361 360 cleanDebug:
362 361  
363 362 @rm -fr $(OBJDBG)
364   - @rm -fr $(BINDBG)
  363 + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@
  364 + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@
  365 + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@
365 366  
366 367 cleanRelease:
367 368  
368 369 @rm -fr $(OBJRLS)
369   - @rm -fr $(BINRLS)
  370 +
  371 + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@
  372 + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@
  373 + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@
  374 +
370 375 @rm -fr $(POTDIR)
371 376 @rm -f lib$(LIBNAME).pot
372 377  
... ...
src/lib3270++/abstract.cc
... ... @@ -110,10 +110,10 @@
110 110  
111 111 if(in && converter != (iconv_t)(-1)) {
112 112  
113   - size_t out = (in << 1);
114   - char * ptr;
115   - char * outBuffer = (char *) malloc(out);
116   - char * inBuffer = (char *) str;
  113 + size_t out = (in << 1);
  114 + char * ptr;
  115 + char * outBuffer = (char *) malloc(out);
  116 + ICONV_CONST char * inBuffer = (ICONV_CONST char *) str;
117 117  
118 118 memset(ptr=outBuffer,0,out);
119 119  
... ...
src/lib3270++/lib3270++.cbp
... ... @@ -40,6 +40,7 @@
40 40 <Linker>
41 41 <Add option="`pkg-config --libs lib3270`" />
42 42 </Linker>
  43 + <Unit filename="../include/config.h.in" />
43 44 <Unit filename="../include/lib3270++.h" />
44 45 <Unit filename="../include/lib3270.h" />
45 46 <Unit filename="../include/lib3270/action_table.h" />
... ...
src/lib3270++/local/events.cc
... ... @@ -37,6 +37,7 @@
37 37 */
38 38  
39 39 #include "../private.h"
  40 + #include <stdio.h>
40 41  
41 42 extern "C" {
42 43 #include <lib3270/actions.h>
... ... @@ -47,6 +48,35 @@
47 48  
48 49 /*---[ Implement ]----------------------------------------------------------------------------------*/
49 50  
  51 +#ifndef HAVE_VASPRINTF
  52 + int vasprintf(char **strp, const char *fmt, va_list ap) {
  53 + char buf[1024];
  54 +
  55 + int nc = vsnprintf(buf, sizeof(buf), fmt, args);
  56 +
  57 + if(nc < 0) {
  58 +
  59 + *strp = strdup(_("Error in vasprintf"));
  60 +
  61 + } else if (nc < sizeof(buf)) {
  62 +
  63 + *strp = malloc(nc+1);
  64 + strcpy(*strp, buf);
  65 +
  66 + } else {
  67 +
  68 + *strp = malloc(nc + 1);
  69 + if(vsnprintf(*strp, nc, fmt, args) < 0) {
  70 + free(*strp);
  71 + *strp = strdup(NULL,_( "Out of memory in vasprintf" ) );
  72 + }
  73 +
  74 + }
  75 +
  76 + return nc;
  77 + }
  78 +#endif // !HAVE_VASPRINTF
  79 +
50 80 namespace TN3270 {
51 81  
52 82 /// @brief Popup Handler.
... ... @@ -55,7 +85,7 @@
55 85 Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270);
56 86  
57 87 if(!session) {
58   - throw std::runtime_error("Invalid session handler");
  88 + throw std::runtime_error(_( "Invalid session handler" ));
59 89 }
60 90  
61 91 class PopupEvent : public TN3270::Event {
... ... @@ -108,7 +138,7 @@
108 138 Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270);
109 139  
110 140 if(!session) {
111   - throw std::runtime_error("Invalid session handler");
  141 + throw std::runtime_error(_("Invalid session handler"));
112 142 }
113 143  
114 144 class ConnectionEvent : public TN3270::Event {
... ... @@ -130,7 +160,7 @@
130 160  
131 161 /// @brief Get event description.
132 162 std::string toString() const override {
133   - return this->connected ? "connected" : "disconnected";
  163 + return this->connected ? _("connected") : _("disconnected");
134 164 }
135 165  
136 166 };
... ...
src/lib3270++/local/session.cc
... ... @@ -65,7 +65,7 @@
65 65  
66 66 cbk = lib3270_get_session_callbacks(this->hSession,sizeof(struct lib3270_session_callbacks));
67 67 if(!cbk) {
68   - throw std::runtime_error( "Invalid callback table, possible version mismatch in lib3270" );
  68 + throw std::runtime_error( _("Invalid callback table, possible version mismatch in lib3270") );
69 69 }
70 70  
71 71 cbk->update_connect = connectHandler;
... ... @@ -120,7 +120,7 @@
120 120 char * text = lib3270_get_text(hSession, baddr, len, lf);
121 121  
122 122 if(!text) {
123   - throw std::runtime_error("Can't get screen contents");
  123 + throw std::runtime_error( _("Can't get screen contents") );
124 124 }
125 125  
126 126 string rc = convertFromHost(text);
... ... @@ -138,7 +138,7 @@
138 138 char * text = lib3270_get_text_at(hSession, row, col, sz, lf);
139 139  
140 140 if(!text) {
141   - throw std::runtime_error("Can't get screen contents");
  141 + throw std::runtime_error( _("Can't get screen contents") );
142 142 }
143 143  
144 144 string rc = convertFromHost(text);
... ...
src/lib3270++/private.h
... ... @@ -41,12 +41,27 @@
41 41 #define PRIVATE_H_INCLUDED
42 42  
43 43 #include <config.h>
  44 +
  45 + #ifdef WIN32
  46 + #include <winsock2.h>
  47 + #include <windows.h>
  48 + #include <ws2tcpip.h>
  49 + #endif // WIN32
  50 +
44 51 #include <mutex>
45 52 #include <lib3270++.h>
46 53 #include <lib3270/popup.h>
47 54 #include <system_error>
48 55 #include <stdexcept>
49 56  
  57 +#ifdef HAVE_LIBINTL
  58 + #include <libintl.h>
  59 + #define _( x ) gettext(x)
  60 + #define N_( x ) x
  61 +#else
  62 + #define _( x ) x
  63 + #define N_( x ) x
  64 +#endif // HAVE_LIBINTL
50 65  
51 66 #ifdef HAVE_ICONV
52 67 #include <iconv.h>
... ...
src/lib3270/Makefile.in
... ... @@ -168,13 +168,13 @@ $(POTDIR)/$(LIBNAME)/%.pot: \
168 168  
169 169 all: \
170 170 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
171   - $(BINRLS)/$(LIBNAME).a \
  171 + $(BINRLS)/static/$(LIBNAME).a \
172 172 $(POTDIR)/$(LIBNAME).pot
173 173  
174 174  
175 175 Release: \
176 176 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
177   - $(BINRLS)/$(LIBNAME).a
  177 + $(BINRLS)/static/$(LIBNAME).a
178 178  
179 179 $(BINRLS)/$(LIBNAME)@DLLEXT@: \
180 180 $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@
... ... @@ -205,7 +205,7 @@ $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \
205 205 $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \
206 206 $(LIBS)
207 207  
208   -$(BINRLS)/$(LIBNAME).a: \
  208 +$(BINRLS)/static/$(LIBNAME).a: \
209 209 $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)
210 210  
211 211 @echo $@ ...
... ... @@ -217,7 +217,7 @@ $(BINRLS)/$(LIBNAME).a: \
217 217  
218 218 install: \
219 219 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
220   - $(BINRLS)/$(LIBNAME).a
  220 + $(BINRLS)/static/$(LIBNAME).a
221 221  
222 222 # Install library
223 223 @mkdir -p $(DESTDIR)$(libdir)
... ... @@ -237,7 +237,7 @@ install: \
237 237  
238 238 # Install static library
239 239 @$(INSTALL_DATA) \
240   - $(BINRLS)/$(LIBNAME).a \
  240 + $(BINRLS)/static/$(LIBNAME).a \
241 241 $(DESTDIR)$(libdir)
242 242  
243 243 # Install SDK
... ...
src/lib3270/lib3270.pc.in
... ... @@ -11,6 +11,6 @@ Name: @PACKAGE_NAME@
11 11 Description: @PACKAGE_DESCRIPTION@
12 12 Version: @PACKAGE_VERSION@
13 13 Libs: -L\@libdir@ -l@LIB3270_NAME@
14   -Libs.private: @LIBSSL_LIBS@
  14 +Libs.private: @LIBSSL_LIBS@ @INTL_LIBS@
15 15 Cflags: -I@includedir@
16 16  
... ...