Commit 9eb2524eb713b382be36a0a1e4e4417ea94f432b
Committed by
GitHub
Exists in
develop
Merge pull request #44 from PerryWerneck/develop
Better search for datafile, updating ci-build.
Showing
5 changed files
with
88 additions
and
18 deletions
Show diff stats
configure.ac
| @@ -114,6 +114,7 @@ case "$host" in | @@ -114,6 +114,7 @@ case "$host" in | ||
| 114 | INSTALL_PACKAGES="$INSTALL_PACKAGES delayed" | 114 | INSTALL_PACKAGES="$INSTALL_PACKAGES delayed" |
| 115 | 115 | ||
| 116 | AC_CONFIG_FILES(win/lib3270.mak) | 116 | AC_CONFIG_FILES(win/lib3270.mak) |
| 117 | + AC_CONFIG_FILES(win/build.conf) | ||
| 117 | 118 | ||
| 118 | ;; | 119 | ;; |
| 119 | 120 |
locale/pt_BR.po
| @@ -5,7 +5,7 @@ msgid "" | @@ -5,7 +5,7 @@ msgid "" | ||
| 5 | msgstr "" | 5 | msgstr "" |
| 6 | "Project-Id-Version: pw3270 5.0\n" | 6 | "Project-Id-Version: pw3270 5.0\n" |
| 7 | "Report-Msgid-Bugs-To: \n" | 7 | "Report-Msgid-Bugs-To: \n" |
| 8 | -"POT-Creation-Date: 2023-03-13 03:12-0300\n" | 8 | +"POT-Creation-Date: 2023-03-28 21:15-0300\n" |
| 9 | "PO-Revision-Date: 2021-09-01 23:53-0300\n" | 9 | "PO-Revision-Date: 2021-09-01 23:53-0300\n" |
| 10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" | 10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" |
| 11 | "Language-Team: Português <perry.werneck@gmail.com>\n" | 11 | "Language-Team: Português <perry.werneck@gmail.com>\n" |
| @@ -2071,7 +2071,7 @@ msgstr "Aguardando resposta do pedido de upload" | @@ -2071,7 +2071,7 @@ msgstr "Aguardando resposta do pedido de upload" | ||
| 2071 | msgid "Warning" | 2071 | msgid "Warning" |
| 2072 | msgstr "Alerta" | 2072 | msgstr "Alerta" |
| 2073 | 2073 | ||
| 2074 | -#: src/core/windows/util.c:126 src/core/windows/util.c:169 | 2074 | +#: src/core/windows/util.c:123 src/core/windows/util.c:166 |
| 2075 | #, c-format | 2075 | #, c-format |
| 2076 | msgid "Windows error %d" | 2076 | msgid "Windows error %d" |
| 2077 | msgstr "Erro windows foi %d" | 2077 | msgstr "Erro windows foi %d" |
src/core/windows/util.c
| @@ -33,6 +33,7 @@ | @@ -33,6 +33,7 @@ | ||
| 33 | #include <windows.h> | 33 | #include <windows.h> |
| 34 | #include <lmcons.h> | 34 | #include <lmcons.h> |
| 35 | #include <internals.h> | 35 | #include <internals.h> |
| 36 | +#include <io.h> | ||
| 36 | 37 | ||
| 37 | #include "winversc.h" | 38 | #include "winversc.h" |
| 38 | #include <ws2tcpip.h> | 39 | #include <ws2tcpip.h> |
| @@ -219,15 +220,23 @@ LIB3270_EXPORT const char * lib3270_win32_local_charset(void) { | @@ -219,15 +220,23 @@ LIB3270_EXPORT const char * lib3270_win32_local_charset(void) { | ||
| 219 | #define SECS_TO_100NS 10000000ULL /* 10^7 */ | 220 | #define SECS_TO_100NS 10000000ULL /* 10^7 */ |
| 220 | 221 | ||
| 221 | LIB3270_EXPORT char * lib3270_get_installation_path() { | 222 | LIB3270_EXPORT char * lib3270_get_installation_path() { |
| 222 | - char lpFilename[4096]; | 223 | + char lpFilename[MAX_PATH+1]; |
| 223 | 224 | ||
| 224 | memset(lpFilename,0,sizeof(lpFilename)); | 225 | memset(lpFilename,0,sizeof(lpFilename)); |
| 225 | - DWORD szPath = GetModuleFileName(hModule,lpFilename,sizeof(lpFilename)); | 226 | + DWORD szPath = GetModuleFileName(hModule,lpFilename,MAX_PATH); |
| 226 | lpFilename[szPath] = 0; | 227 | lpFilename[szPath] = 0; |
| 227 | 228 | ||
| 228 | - char * ptr = strrchr(lpFilename,'\\'); | ||
| 229 | - if(ptr) | ||
| 230 | - ptr[1] = 0; | 229 | + char *ptr = strrchr(lpFilename,'\\'); |
| 230 | + if(ptr) { | ||
| 231 | + ptr[0] = 0; | ||
| 232 | + | ||
| 233 | + ptr = strrchr(lpFilename,'\\'); | ||
| 234 | + if(ptr && !(strcasecmp(ptr,"\\bin") && strcasecmp(ptr,"\\lib"))) { | ||
| 235 | + *ptr = 0; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + strncat(lpFilename,"\\",MAX_PATH); | ||
| 239 | + } | ||
| 231 | 240 | ||
| 232 | return strdup(lpFilename); | 241 | return strdup(lpFilename); |
| 233 | } | 242 | } |
| @@ -274,13 +283,8 @@ static char * build_filename(const char *str, va_list args) { | @@ -274,13 +283,8 @@ static char * build_filename(const char *str, va_list args) { | ||
| 274 | 283 | ||
| 275 | memset(filename,0,szFilename); | 284 | memset(filename,0,szFilename); |
| 276 | 285 | ||
| 277 | -#ifdef DEBUG | ||
| 278 | - filename[0] = '.'; | ||
| 279 | - filename[1] = '\\'; | ||
| 280 | -#else | ||
| 281 | DWORD szPath = GetModuleFileName(hModule,filename,szFilename); | 286 | DWORD szPath = GetModuleFileName(hModule,filename,szFilename); |
| 282 | filename[szPath] = 0; | 287 | filename[szPath] = 0; |
| 283 | -#endif // DEBUG | ||
| 284 | 288 | ||
| 285 | ptr = strrchr(filename,'\\'); | 289 | ptr = strrchr(filename,'\\'); |
| 286 | if(ptr) { | 290 | if(ptr) { |
| @@ -303,14 +307,74 @@ static char * build_filename(const char *str, va_list args) { | @@ -303,14 +307,74 @@ static char * build_filename(const char *str, va_list args) { | ||
| 303 | } | 307 | } |
| 304 | 308 | ||
| 305 | char * lib3270_build_data_filename(const char *str, ...) { | 309 | char * lib3270_build_data_filename(const char *str, ...) { |
| 306 | - va_list args; | ||
| 307 | - va_start (args, str); | ||
| 308 | 310 | ||
| 309 | - char *filename = build_filename(str, args); | 311 | + char *ptr; |
| 312 | + lib3270_autoptr(char) instpath = lib3270_get_installation_path(); | ||
| 310 | 313 | ||
| 311 | - va_end (args); | 314 | + for(ptr = instpath; *ptr; ptr++) { |
| 315 | + if(*ptr == '/') { | ||
| 316 | + *ptr = '\\'; | ||
| 317 | + } | ||
| 318 | + } | ||
| 312 | 319 | ||
| 313 | - return filename; | 320 | + if( *(instpath+strlen(instpath)-1) = '\\') { |
| 321 | + instpath[strlen(instpath)-1] = 0; | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + char relative[MAX_PATH+1]; | ||
| 325 | + memset(relative,0,MAX_PATH); | ||
| 326 | + | ||
| 327 | + { | ||
| 328 | + va_list args; | ||
| 329 | + va_start (args, str); | ||
| 330 | + | ||
| 331 | + while(str) { | ||
| 332 | + | ||
| 333 | + if(str[0] == '\\' || str[0] == '/') { | ||
| 334 | + strncat(relative,str,MAX_PATH); | ||
| 335 | + } else { | ||
| 336 | + strncat(relative,"\\",MAX_PATH); | ||
| 337 | + strncat(relative,str,MAX_PATH); | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + str = va_arg(args, const char *); | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + va_end (args); | ||
| 344 | + } | ||
| 345 | + | ||
| 346 | + for(ptr = relative; *ptr; ptr++) { | ||
| 347 | + if(*ptr == '/') { | ||
| 348 | + *ptr = '\\'; | ||
| 349 | + } | ||
| 350 | + } | ||
| 351 | + | ||
| 352 | + char filename[MAX_PATH+1]; | ||
| 353 | + memset(filename,0,MAX_PATH+1); | ||
| 354 | + | ||
| 355 | + // Check instdir | ||
| 356 | + strncpy(filename,instpath,MAX_PATH); | ||
| 357 | + strncat(filename,"\\share",MAX_PATH); | ||
| 358 | + strncat(filename,relative,MAX_PATH); | ||
| 359 | + | ||
| 360 | + if(access(filename,0) == 0) { | ||
| 361 | + return strdup(filename); | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + strncpy(filename,instpath,MAX_PATH); | ||
| 365 | + strncat(filename,"\\share\\",MAX_PATH); | ||
| 366 | + strncat(filename,LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),MAX_PATH); | ||
| 367 | + strncat(filename,relative,MAX_PATH); | ||
| 368 | + | ||
| 369 | + if(access(filename,0) == 0) { | ||
| 370 | + return strdup(filename); | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + // Default behavior. | ||
| 374 | + strncpy(filename,instpath,MAX_PATH); | ||
| 375 | + strncat(filename,relative,MAX_PATH); | ||
| 376 | + | ||
| 377 | + return strdup(filename); | ||
| 314 | } | 378 | } |
| 315 | 379 | ||
| 316 | char * lib3270_build_config_filename(const char *str, ...) { | 380 | char * lib3270_build_config_filename(const char *str, ...) { |
win/ci-build.sh
| @@ -27,7 +27,10 @@ echo "Building lib3270" | @@ -27,7 +27,10 @@ echo "Building lib3270" | ||
| 27 | make clean > $LOGFILE 2>&1 || die "Make clean failure" | 27 | make clean > $LOGFILE 2>&1 || die "Make clean failure" |
| 28 | make all > $LOGFILE 2>&1 || die "Make failure" | 28 | make all > $LOGFILE 2>&1 || die "Make failure" |
| 29 | make DESTDIR=.bin/package install | 29 | make DESTDIR=.bin/package install |
| 30 | -tar --create --xz --file=mingw-lib3270.tar.xz --directory=.bin/package --verbose . | 30 | + |
| 31 | +. ./win/build.conf | ||
| 32 | + | ||
| 33 | +tar --create --xz --file=mingw-lib3270.${TARGET_ARCH}.tar.xz --directory=.bin/package --verbose . | ||
| 31 | 34 | ||
| 32 | 35 | ||
| 33 | 36 |