Commit 83bd04985bbbdee001c240a3a62d9c7b4eacb60b

Authored by Perry Werneck
1 parent e205d199
Exists in master and in 1 other branch develop

Packing C++ version preview

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  
... ...
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  
... ...
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" />
... ...
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 };
... ...
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);
... ...
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>
... ...