diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-06-21 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:59:19 +0500 |
| commit | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch) | |
| tree | fe5e17420300b715021a76328444088d32047963 /C/Util/SfxSetup | |
| parent | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff) | |
| download | 7zip-23.01.tar.gz 7zip-23.01.tar.bz2 7zip-23.01.zip | |
23.0123.01
Diffstat (limited to 'C/Util/SfxSetup')
| -rw-r--r-- | C/Util/SfxSetup/Precomp.h | 10 | ||||
| -rw-r--r-- | C/Util/SfxSetup/SfxSetup.c | 46 | ||||
| -rw-r--r-- | C/Util/SfxSetup/makefile | 3 | ||||
| -rw-r--r-- | C/Util/SfxSetup/makefile_con | 4 |
4 files changed, 44 insertions, 19 deletions
diff --git a/C/Util/SfxSetup/Precomp.h b/C/Util/SfxSetup/Precomp.h index 588a66f..bc8fa21 100644 --- a/C/Util/SfxSetup/Precomp.h +++ b/C/Util/SfxSetup/Precomp.h | |||
| @@ -1,8 +1,12 @@ | |||
| 1 | /* Precomp.h -- StdAfx | 1 | /* Precomp.h -- StdAfx |
| 2 | 2013-06-16 : Igor Pavlov : Public domain */ | 2 | 2023-03-04 : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #ifndef __7Z_PRECOMP_H | 4 | #ifndef ZIP7_INC_PRECOMP_H |
| 5 | #define __7Z_PRECOMP_H | 5 | #define ZIP7_INC_PRECOMP_H |
| 6 | |||
| 7 | #if defined(_MSC_VER) && _MSC_VER >= 1800 | ||
| 8 | #pragma warning(disable : 4464) // relative include path contains '..' | ||
| 9 | #endif | ||
| 6 | 10 | ||
| 7 | #include "../../Compiler.h" | 11 | #include "../../Compiler.h" |
| 8 | #include "../../7zTypes.h" | 12 | #include "../../7zTypes.h" |
diff --git a/C/Util/SfxSetup/SfxSetup.c b/C/Util/SfxSetup/SfxSetup.c index ef19aea..7304a0b 100644 --- a/C/Util/SfxSetup/SfxSetup.c +++ b/C/Util/SfxSetup/SfxSetup.c | |||
| @@ -26,6 +26,12 @@ | |||
| 26 | 26 | ||
| 27 | #define kInputBufSize ((size_t)1 << 18) | 27 | #define kInputBufSize ((size_t)1 << 18) |
| 28 | 28 | ||
| 29 | |||
| 30 | #define wcscat lstrcatW | ||
| 31 | #define wcslen (size_t)lstrlenW | ||
| 32 | #define wcscpy lstrcpyW | ||
| 33 | // wcsncpy() and lstrcpynW() work differently. We don't use them. | ||
| 34 | |||
| 29 | static const char * const kExts[] = | 35 | static const char * const kExts[] = |
| 30 | { | 36 | { |
| 31 | "bat" | 37 | "bat" |
| @@ -64,7 +70,7 @@ static unsigned FindExt(const wchar_t *s, unsigned *extLen) | |||
| 64 | return len; | 70 | return len; |
| 65 | } | 71 | } |
| 66 | 72 | ||
| 67 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c))) | 73 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) |
| 68 | 74 | ||
| 69 | static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len) | 75 | static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len) |
| 70 | { | 76 | { |
| @@ -72,13 +78,13 @@ static unsigned FindItem(const char * const *items, unsigned num, const wchar_t | |||
| 72 | for (i = 0; i < num; i++) | 78 | for (i = 0; i < num; i++) |
| 73 | { | 79 | { |
| 74 | const char *item = items[i]; | 80 | const char *item = items[i]; |
| 75 | unsigned itemLen = (unsigned)strlen(item); | 81 | const unsigned itemLen = (unsigned)strlen(item); |
| 76 | unsigned j; | 82 | unsigned j; |
| 77 | if (len != itemLen) | 83 | if (len != itemLen) |
| 78 | continue; | 84 | continue; |
| 79 | for (j = 0; j < len; j++) | 85 | for (j = 0; j < len; j++) |
| 80 | { | 86 | { |
| 81 | unsigned c = (Byte)item[j]; | 87 | const unsigned c = (Byte)item[j]; |
| 82 | if (c != s[j] && MAKE_CHAR_UPPER(c) != s[j]) | 88 | if (c != s[j] && MAKE_CHAR_UPPER(c) != s[j]) |
| 83 | break; | 89 | break; |
| 84 | } | 90 | } |
| @@ -96,10 +102,20 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType) | |||
| 96 | } | 102 | } |
| 97 | #endif | 103 | #endif |
| 98 | 104 | ||
| 105 | |||
| 106 | #ifdef _CONSOLE | ||
| 107 | static void PrintStr(const char *s) | ||
| 108 | { | ||
| 109 | fputs(s, stdout); | ||
| 110 | } | ||
| 111 | #endif | ||
| 112 | |||
| 99 | static void PrintErrorMessage(const char *message) | 113 | static void PrintErrorMessage(const char *message) |
| 100 | { | 114 | { |
| 101 | #ifdef _CONSOLE | 115 | #ifdef _CONSOLE |
| 102 | printf("\n7-Zip Error: %s\n", message); | 116 | PrintStr("\n7-Zip Error: "); |
| 117 | PrintStr(message); | ||
| 118 | PrintStr("\n"); | ||
| 103 | #else | 119 | #else |
| 104 | #ifdef UNDER_CE | 120 | #ifdef UNDER_CE |
| 105 | WCHAR messageW[256 + 4]; | 121 | WCHAR messageW[256 + 4]; |
| @@ -179,7 +195,7 @@ static WRes RemoveDirWithSubItems(WCHAR *path) | |||
| 179 | WIN32_FIND_DATAW fd; | 195 | WIN32_FIND_DATAW fd; |
| 180 | HANDLE handle; | 196 | HANDLE handle; |
| 181 | WRes res = 0; | 197 | WRes res = 0; |
| 182 | size_t len = wcslen(path); | 198 | const size_t len = wcslen(path); |
| 183 | wcscpy(path + len, L"*"); | 199 | wcscpy(path + len, L"*"); |
| 184 | handle = FindFirstFileW(path, &fd); | 200 | handle = FindFirstFileW(path, &fd); |
| 185 | path[len] = L'\0'; | 201 | path[len] = L'\0'; |
| @@ -228,7 +244,7 @@ static WRes RemoveDirWithSubItems(WCHAR *path) | |||
| 228 | } | 244 | } |
| 229 | 245 | ||
| 230 | #ifdef _CONSOLE | 246 | #ifdef _CONSOLE |
| 231 | int MY_CDECL main() | 247 | int Z7_CDECL main(void) |
| 232 | #else | 248 | #else |
| 233 | int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | 249 | int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, |
| 234 | #ifdef UNDER_CE | 250 | #ifdef UNDER_CE |
| @@ -290,7 +306,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 290 | BoolInt quoteMode = False; | 306 | BoolInt quoteMode = False; |
| 291 | for (;; cmdLineParams++) | 307 | for (;; cmdLineParams++) |
| 292 | { | 308 | { |
| 293 | wchar_t c = *cmdLineParams; | 309 | const wchar_t c = *cmdLineParams; |
| 294 | if (c == L'\"') | 310 | if (c == L'\"') |
| 295 | quoteMode = !quoteMode; | 311 | quoteMode = !quoteMode; |
| 296 | else if (c == 0 || (c == L' ' && !quoteMode)) | 312 | else if (c == 0 || (c == L' ' && !quoteMode)) |
| @@ -324,7 +340,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 324 | unsigned k; | 340 | unsigned k; |
| 325 | for (k = 0; k < 8; k++) | 341 | for (k = 0; k < 8; k++) |
| 326 | { | 342 | { |
| 327 | unsigned t = value & 0xF; | 343 | const unsigned t = value & 0xF; |
| 328 | value >>= 4; | 344 | value >>= 4; |
| 329 | s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); | 345 | s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); |
| 330 | } | 346 | } |
| @@ -386,7 +402,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 386 | { | 402 | { |
| 387 | lookStream.bufSize = kInputBufSize; | 403 | lookStream.bufSize = kInputBufSize; |
| 388 | lookStream.realStream = &archiveStream.vt; | 404 | lookStream.realStream = &archiveStream.vt; |
| 389 | LookToRead2_Init(&lookStream); | 405 | LookToRead2_INIT(&lookStream) |
| 390 | } | 406 | } |
| 391 | } | 407 | } |
| 392 | 408 | ||
| @@ -455,11 +471,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 455 | unsigned extLen; | 471 | unsigned extLen; |
| 456 | const WCHAR *name = temp + nameStartPos; | 472 | const WCHAR *name = temp + nameStartPos; |
| 457 | unsigned len = (unsigned)wcslen(name); | 473 | unsigned len = (unsigned)wcslen(name); |
| 458 | unsigned nameLen = FindExt(temp + nameStartPos, &extLen); | 474 | const unsigned nameLen = FindExt(temp + nameStartPos, &extLen); |
| 459 | unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen); | 475 | const unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen); |
| 460 | unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen); | 476 | const unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen); |
| 461 | 477 | ||
| 462 | unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12)); | 478 | const unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12)); |
| 463 | if (minPrice > price) | 479 | if (minPrice > price) |
| 464 | { | 480 | { |
| 465 | minPrice = price; | 481 | minPrice = price; |
| @@ -500,7 +516,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 500 | #endif | 516 | #endif |
| 501 | 517 | ||
| 502 | { | 518 | { |
| 503 | SRes res2 = File_Close(&outFile); | 519 | const SRes res2 = File_Close(&outFile); |
| 504 | if (res != SZ_OK) | 520 | if (res != SZ_OK) |
| 505 | break; | 521 | break; |
| 506 | if (res2 != SZ_OK) | 522 | if (res2 != SZ_OK) |
| @@ -550,7 +566,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 550 | WCHAR oldCurDir[MAX_PATH + 2]; | 566 | WCHAR oldCurDir[MAX_PATH + 2]; |
| 551 | oldCurDir[0] = 0; | 567 | oldCurDir[0] = 0; |
| 552 | { | 568 | { |
| 553 | DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir); | 569 | const DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir); |
| 554 | if (needLen == 0 || needLen > MAX_PATH) | 570 | if (needLen == 0 || needLen > MAX_PATH) |
| 555 | oldCurDir[0] = 0; | 571 | oldCurDir[0] = 0; |
| 556 | SetCurrentDirectory(workCurDir); | 572 | SetCurrentDirectory(workCurDir); |
diff --git a/C/Util/SfxSetup/makefile b/C/Util/SfxSetup/makefile index 544da67..bc0cf8b 100644 --- a/C/Util/SfxSetup/makefile +++ b/C/Util/SfxSetup/makefile | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | PROG = 7zS2.sfx | 1 | PROG = 7zS2.sfx |
| 2 | MY_FIXED = 1 | 2 | MY_FIXED = 1 |
| 3 | 3 | ||
| 4 | CFLAGS = $(CFLAGS) \ | ||
| 5 | -DZ7_EXTRACT_ONLY \ | ||
| 6 | |||
| 4 | C_OBJS = \ | 7 | C_OBJS = \ |
| 5 | $O\7zAlloc.obj \ | 8 | $O\7zAlloc.obj \ |
| 6 | $O\7zArcIn.obj \ | 9 | $O\7zArcIn.obj \ |
diff --git a/C/Util/SfxSetup/makefile_con b/C/Util/SfxSetup/makefile_con index d0f8352..9f4b916 100644 --- a/C/Util/SfxSetup/makefile_con +++ b/C/Util/SfxSetup/makefile_con | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | PROG = 7zS2con.sfx | 1 | PROG = 7zS2con.sfx |
| 2 | MY_FIXED = 1 | 2 | MY_FIXED = 1 |
| 3 | CFLAGS = $(CFLAGS) -D_CONSOLE | 3 | |
| 4 | CFLAGS = $(CFLAGS) -D_CONSOLE \ | ||
| 5 | -DZ7_EXTRACT_ONLY \ | ||
| 4 | 6 | ||
| 5 | C_OBJS = \ | 7 | C_OBJS = \ |
| 6 | $O\7zAlloc.obj \ | 8 | $O\7zAlloc.obj \ |
