Commit 83bd04985bbbdee001c240a3a62d9c7b4eacb60b

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

Packing C++ version preview

@@ -95,9 +95,11 @@ CFLAGS= \ @@ -95,9 +95,11 @@ CFLAGS= \
95 95
96 LIBS= \ 96 LIBS= \
97 @LIBS@ \ 97 @LIBS@ \
  98 + @LIBSSL_LIBS@ \
98 @LIBICONV@ \ 99 @LIBICONV@ \
99 @INTL_LIBS@ 100 @INTL_LIBS@
100 101
  102 +
101 #---[ Debug Rules ]---------------------------------------------------------------------- 103 #---[ Debug Rules ]----------------------------------------------------------------------
102 104
103 $(OBJDBG)/%.o: \ 105 $(OBJDBG)/%.o: \
@@ -166,13 +168,14 @@ $(POTDIR)/$(LIBNAME)/%.pot: \ @@ -166,13 +168,14 @@ $(POTDIR)/$(LIBNAME)/%.pot: \
166 168
167 all: \ 169 all: \
168 $(BINRLS)/$(LIBNAME)@DLLEXT@ \ 170 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
169 - $(BINRLS)/$(LIBNAME).a \ 171 + $(BINRLS)/static/$(LIBNAME).a \
170 $(POTDIR)/$(LIBNAME).pot 172 $(POTDIR)/$(LIBNAME).pot
171 173
172 174
173 Release: \ 175 Release: \
174 $(BINRLS)/$(LIBNAME)@DLLEXT@ \ 176 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
175 - $(BINRLS)/$(LIBNAME).a 177 + $(BINRLS)/static/$(LIBNAME).a
  178 +
176 179
177 $(BINRLS)/$(LIBNAME)@DLLEXT@: \ 180 $(BINRLS)/$(LIBNAME)@DLLEXT@: \
178 $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ 181 $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@
@@ -196,15 +199,18 @@ $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ @@ -196,15 +199,18 @@ $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \
196 199
197 @$(MKDIR) `dirname $@` 200 @$(MKDIR) `dirname $@`
198 @echo $< ... 201 @echo $< ...
  202 +
199 @$(LD) \ 203 @$(LD) \
200 - -shared -Wl,-soname,$(@F) \ 204 + -shared \
  205 + -Wl,-soname,$(@F) \
201 -o $@ \ 206 -o $@ \
202 $(LDFLAGS) \ 207 $(LDFLAGS) \
203 $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \ 208 $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \
204 -L$(BINRLS) \ 209 -L$(BINRLS) \
205 - $(LIBS) 210 + $(LIBS) \
  211 + -l3270
206 212
207 -$(BINRLS)/$(LIBNAME).a: \ 213 +$(BINRLS)/static/$(LIBNAME).a: \
208 $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) 214 $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)
209 215
210 @echo $@ ... 216 @echo $@ ...
@@ -216,7 +222,7 @@ $(BINRLS)/$(LIBNAME).a: \ @@ -216,7 +222,7 @@ $(BINRLS)/$(LIBNAME).a: \
216 222
217 install: \ 223 install: \
218 $(BINRLS)/$(LIBNAME)@DLLEXT@ \ 224 $(BINRLS)/$(LIBNAME)@DLLEXT@ \
219 - $(BINRLS)/$(LIBNAME).a 225 + $(BINRLS)/static/$(LIBNAME).a
220 226
221 # Install library 227 # Install library
222 @mkdir -p $(DESTDIR)$(libdir) 228 @mkdir -p $(DESTDIR)$(libdir)
@@ -236,17 +242,10 @@ install: \ @@ -236,17 +242,10 @@ install: \
236 242
237 # Install static library 243 # Install static library
238 @$(INSTALL_DATA) \ 244 @$(INSTALL_DATA) \
239 - $(BINRLS)/$(LIBNAME).a \ 245 + $(BINRLS)/static/$(LIBNAME).a \
240 $(DESTDIR)$(libdir) 246 $(DESTDIR)$(libdir)
241 247
242 # Install SDK 248 # Install SDK
243 -  
244 - @mkdir -p $(DESTDIR)$(includedir)/$(LIBNAME)  
245 -  
246 - @$(INSTALL_DATA) \  
247 - ../include/$(LIBNAME)/*.h \  
248 - $(DESTDIR)$(includedir)/$(LIBNAME)  
249 -  
250 @$(INSTALL_DATA) \ 249 @$(INSTALL_DATA) \
251 ../include/$(LIBNAME).h \ 250 ../include/$(LIBNAME).h \
252 $(DESTDIR)$(includedir)/$(LIBNAME).h 251 $(DESTDIR)$(includedir)/$(LIBNAME).h
@@ -361,12 +360,18 @@ clean: \ @@ -361,12 +360,18 @@ clean: \
361 cleanDebug: 360 cleanDebug:
362 361
363 @rm -fr $(OBJDBG) 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 cleanRelease: 367 cleanRelease:
367 368
368 @rm -fr $(OBJRLS) 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 @rm -fr $(POTDIR) 375 @rm -fr $(POTDIR)
371 @rm -f lib$(LIBNAME).pot 376 @rm -f lib$(LIBNAME).pot
372 377
@@ -110,10 +110,10 @@ @@ -110,10 +110,10 @@
110 110
111 if(in && converter != (iconv_t)(-1)) { 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 memset(ptr=outBuffer,0,out); 118 memset(ptr=outBuffer,0,out);
119 119
@@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
40 <Linker> 40 <Linker>
41 <Add option="`pkg-config --libs lib3270`" /> 41 <Add option="`pkg-config --libs lib3270`" />
42 </Linker> 42 </Linker>
  43 + <Unit filename="../include/config.h.in" />
43 <Unit filename="../include/lib3270++.h" /> 44 <Unit filename="../include/lib3270++.h" />
44 <Unit filename="../include/lib3270.h" /> 45 <Unit filename="../include/lib3270.h" />
45 <Unit filename="../include/lib3270/action_table.h" /> 46 <Unit filename="../include/lib3270/action_table.h" />
local/events.cc
@@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
37 */ 37 */
38 38
39 #include "../private.h" 39 #include "../private.h"
  40 + #include <stdio.h>
40 41
41 extern "C" { 42 extern "C" {
42 #include <lib3270/actions.h> 43 #include <lib3270/actions.h>
@@ -47,6 +48,35 @@ @@ -47,6 +48,35 @@
47 48
48 /*---[ Implement ]----------------------------------------------------------------------------------*/ 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 namespace TN3270 { 80 namespace TN3270 {
51 81
52 /// @brief Popup Handler. 82 /// @brief Popup Handler.
@@ -55,7 +85,7 @@ @@ -55,7 +85,7 @@
55 Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270); 85 Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270);
56 86
57 if(!session) { 87 if(!session) {
58 - throw std::runtime_error("Invalid session handler"); 88 + throw std::runtime_error(_( "Invalid session handler" ));
59 } 89 }
60 90
61 class PopupEvent : public TN3270::Event { 91 class PopupEvent : public TN3270::Event {
@@ -108,7 +138,7 @@ @@ -108,7 +138,7 @@
108 Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270); 138 Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270);
109 139
110 if(!session) { 140 if(!session) {
111 - throw std::runtime_error("Invalid session handler"); 141 + throw std::runtime_error(_("Invalid session handler"));
112 } 142 }
113 143
114 class ConnectionEvent : public TN3270::Event { 144 class ConnectionEvent : public TN3270::Event {
@@ -130,7 +160,7 @@ @@ -130,7 +160,7 @@
130 160
131 /// @brief Get event description. 161 /// @brief Get event description.
132 std::string toString() const override { 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,7 +65,7 @@
65 65
66 cbk = lib3270_get_session_callbacks(this->hSession,sizeof(struct lib3270_session_callbacks)); 66 cbk = lib3270_get_session_callbacks(this->hSession,sizeof(struct lib3270_session_callbacks));
67 if(!cbk) { 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 cbk->update_connect = connectHandler; 71 cbk->update_connect = connectHandler;
@@ -120,7 +120,7 @@ @@ -120,7 +120,7 @@
120 char * text = lib3270_get_text(hSession, baddr, len, lf); 120 char * text = lib3270_get_text(hSession, baddr, len, lf);
121 121
122 if(!text) { 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 string rc = convertFromHost(text); 126 string rc = convertFromHost(text);
@@ -138,7 +138,7 @@ @@ -138,7 +138,7 @@
138 char * text = lib3270_get_text_at(hSession, row, col, sz, lf); 138 char * text = lib3270_get_text_at(hSession, row, col, sz, lf);
139 139
140 if(!text) { 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 string rc = convertFromHost(text); 144 string rc = convertFromHost(text);
@@ -41,12 +41,27 @@ @@ -41,12 +41,27 @@
41 #define PRIVATE_H_INCLUDED 41 #define PRIVATE_H_INCLUDED
42 42
43 #include <config.h> 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 #include <mutex> 51 #include <mutex>
45 #include <lib3270++.h> 52 #include <lib3270++.h>
46 #include <lib3270/popup.h> 53 #include <lib3270/popup.h>
47 #include <system_error> 54 #include <system_error>
48 #include <stdexcept> 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 #ifdef HAVE_ICONV 66 #ifdef HAVE_ICONV
52 #include <iconv.h> 67 #include <iconv.h>