diff options
Diffstat (limited to 'C/Util')
-rw-r--r-- | C/Util/7z/7z.dsp | 8 | ||||
-rw-r--r-- | C/Util/7z/7zMain.c | 85 | ||||
-rw-r--r-- | C/Util/7z/Precomp.h | 10 | ||||
-rw-r--r-- | C/Util/7z/makefile | 2 | ||||
-rw-r--r-- | C/Util/7z/makefile.gcc | 4 | ||||
-rw-r--r-- | C/Util/7zipInstall/7zipInstall.c | 135 | ||||
-rw-r--r-- | C/Util/7zipInstall/7zipInstall.dsp | 8 | ||||
-rw-r--r-- | C/Util/7zipInstall/Precomp.h | 11 | ||||
-rw-r--r-- | C/Util/7zipInstall/makefile | 14 | ||||
-rw-r--r-- | C/Util/7zipUninstall/7zipUninstall.c | 128 | ||||
-rw-r--r-- | C/Util/7zipUninstall/7zipUninstall.dsp | 8 | ||||
-rw-r--r-- | C/Util/7zipUninstall/Precomp.h | 11 | ||||
-rw-r--r-- | C/Util/7zipUninstall/makefile | 4 | ||||
-rw-r--r-- | C/Util/Lzma/LzmaUtil.c | 145 | ||||
-rw-r--r-- | C/Util/Lzma/LzmaUtil.dsp | 16 | ||||
-rw-r--r-- | C/Util/Lzma/Precomp.h | 14 | ||||
-rw-r--r-- | C/Util/LzmaLib/LzmaLib.dsp | 20 | ||||
-rw-r--r-- | C/Util/LzmaLib/LzmaLibExports.c | 13 | ||||
-rw-r--r-- | C/Util/LzmaLib/Precomp.c | 4 | ||||
-rw-r--r-- | C/Util/LzmaLib/Precomp.h | 14 | ||||
-rw-r--r-- | C/Util/LzmaLib/makefile | 22 | ||||
-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 |
25 files changed, 484 insertions, 255 deletions
diff --git a/C/Util/7z/7z.dsp b/C/Util/7z/7z.dsp index be0f0a7..11e1b03 100644 --- a/C/Util/7z/7z.dsp +++ b/C/Util/7z/7z.dsp | |||
@@ -42,7 +42,7 @@ RSC=rc.exe | |||
42 | # PROP Ignore_Export_Lib 0 | 42 | # PROP Ignore_Export_Lib 0 |
43 | # PROP Target_Dir "" | 43 | # PROP Target_Dir "" |
44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c | 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c |
45 | # ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAcs /Yu"Precomp.h" /FD /c | 45 | # ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "Z7_PPMD_SUPPORT" /FAcs /Yu"Precomp.h" /FD /c |
46 | # ADD BASE RSC /l 0x419 /d "NDEBUG" | 46 | # ADD BASE RSC /l 0x419 /d "NDEBUG" |
47 | # ADD RSC /l 0x419 /d "NDEBUG" | 47 | # ADD RSC /l 0x419 /d "NDEBUG" |
48 | BSC32=bscmake.exe | 48 | BSC32=bscmake.exe |
@@ -67,7 +67,7 @@ LINK32=link.exe | |||
67 | # PROP Ignore_Export_Lib 0 | 67 | # PROP Ignore_Export_Lib 0 |
68 | # PROP Target_Dir "" | 68 | # PROP Target_Dir "" |
69 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c | 69 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c |
70 | # ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c | 70 | # ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "Z7_PPMD_SUPPORT" /Yu"Precomp.h" /FD /GZ /c |
71 | # ADD BASE RSC /l 0x419 /d "_DEBUG" | 71 | # ADD BASE RSC /l 0x419 /d "_DEBUG" |
72 | # ADD RSC /l 0x419 /d "_DEBUG" | 72 | # ADD RSC /l 0x419 /d "_DEBUG" |
73 | BSC32=bscmake.exe | 73 | BSC32=bscmake.exe |
@@ -145,6 +145,10 @@ SOURCE=..\..\7zTypes.h | |||
145 | # End Source File | 145 | # End Source File |
146 | # Begin Source File | 146 | # Begin Source File |
147 | 147 | ||
148 | SOURCE=..\..\7zWindows.h | ||
149 | # End Source File | ||
150 | # Begin Source File | ||
151 | |||
148 | SOURCE=..\..\Bcj2.c | 152 | SOURCE=..\..\Bcj2.c |
149 | # End Source File | 153 | # End Source File |
150 | # Begin Source File | 154 | # Begin Source File |
diff --git a/C/Util/7z/7zMain.c b/C/Util/7z/7zMain.c index 9d55509..547920a 100644 --- a/C/Util/7z/7zMain.c +++ b/C/Util/7z/7zMain.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* 7zMain.c - Test application for 7z Decoder | 1 | /* 7zMain.c - Test application for 7z Decoder |
2 | 2021-04-29 : Igor Pavlov : Public domain */ | 2 | 2023-04-04 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
5 | 5 | ||
@@ -32,10 +32,10 @@ | |||
32 | #endif | 32 | #endif |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | |||
36 | #define kInputBufSize ((size_t)1 << 18) | 35 | #define kInputBufSize ((size_t)1 << 18) |
37 | 36 | ||
38 | static const ISzAlloc g_Alloc = { SzAlloc, SzFree }; | 37 | static const ISzAlloc g_Alloc = { SzAlloc, SzFree }; |
38 | // static const ISzAlloc g_Alloc_temp = { SzAllocTemp, SzFreeTemp }; | ||
39 | 39 | ||
40 | 40 | ||
41 | static void Print(const char *s) | 41 | static void Print(const char *s) |
@@ -53,19 +53,19 @@ static int Buf_EnsureSize(CBuf *dest, size_t size) | |||
53 | } | 53 | } |
54 | 54 | ||
55 | #ifndef _WIN32 | 55 | #ifndef _WIN32 |
56 | #define _USE_UTF8 | 56 | #define MY_USE_UTF8 |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | /* #define _USE_UTF8 */ | 59 | /* #define MY_USE_UTF8 */ |
60 | 60 | ||
61 | #ifdef _USE_UTF8 | 61 | #ifdef MY_USE_UTF8 |
62 | 62 | ||
63 | #define _UTF8_START(n) (0x100 - (1 << (7 - (n)))) | 63 | #define MY_UTF8_START(n) (0x100 - (1 << (7 - (n)))) |
64 | 64 | ||
65 | #define _UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6)) | 65 | #define MY_UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6)) |
66 | 66 | ||
67 | #define _UTF8_HEAD(n, val) ((Byte)(_UTF8_START(n) + (val >> (6 * (n))))) | 67 | #define MY_UTF8_HEAD(n, val) ((Byte)(MY_UTF8_START(n) + (val >> (6 * (n))))) |
68 | #define _UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F))) | 68 | #define MY_UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F))) |
69 | 69 | ||
70 | static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) | 70 | static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) |
71 | { | 71 | { |
@@ -82,7 +82,7 @@ static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) | |||
82 | if (val < 0x80) | 82 | if (val < 0x80) |
83 | continue; | 83 | continue; |
84 | 84 | ||
85 | if (val < _UTF8_RANGE(1)) | 85 | if (val < MY_UTF8_RANGE(1)) |
86 | { | 86 | { |
87 | size++; | 87 | size++; |
88 | continue; | 88 | continue; |
@@ -90,7 +90,7 @@ static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) | |||
90 | 90 | ||
91 | if (val >= 0xD800 && val < 0xDC00 && src != srcLim) | 91 | if (val >= 0xD800 && val < 0xDC00 && src != srcLim) |
92 | { | 92 | { |
93 | UInt32 c2 = *src; | 93 | const UInt32 c2 = *src; |
94 | if (c2 >= 0xDC00 && c2 < 0xE000) | 94 | if (c2 >= 0xDC00 && c2 < 0xE000) |
95 | { | 95 | { |
96 | src++; | 96 | src++; |
@@ -119,33 +119,33 @@ static Byte *Utf16_To_Utf8(Byte *dest, const UInt16 *src, const UInt16 *srcLim) | |||
119 | continue; | 119 | continue; |
120 | } | 120 | } |
121 | 121 | ||
122 | if (val < _UTF8_RANGE(1)) | 122 | if (val < MY_UTF8_RANGE(1)) |
123 | { | 123 | { |
124 | dest[0] = _UTF8_HEAD(1, val); | 124 | dest[0] = MY_UTF8_HEAD(1, val); |
125 | dest[1] = _UTF8_CHAR(0, val); | 125 | dest[1] = MY_UTF8_CHAR(0, val); |
126 | dest += 2; | 126 | dest += 2; |
127 | continue; | 127 | continue; |
128 | } | 128 | } |
129 | 129 | ||
130 | if (val >= 0xD800 && val < 0xDC00 && src != srcLim) | 130 | if (val >= 0xD800 && val < 0xDC00 && src != srcLim) |
131 | { | 131 | { |
132 | UInt32 c2 = *src; | 132 | const UInt32 c2 = *src; |
133 | if (c2 >= 0xDC00 && c2 < 0xE000) | 133 | if (c2 >= 0xDC00 && c2 < 0xE000) |
134 | { | 134 | { |
135 | src++; | 135 | src++; |
136 | val = (((val - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000; | 136 | val = (((val - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000; |
137 | dest[0] = _UTF8_HEAD(3, val); | 137 | dest[0] = MY_UTF8_HEAD(3, val); |
138 | dest[1] = _UTF8_CHAR(2, val); | 138 | dest[1] = MY_UTF8_CHAR(2, val); |
139 | dest[2] = _UTF8_CHAR(1, val); | 139 | dest[2] = MY_UTF8_CHAR(1, val); |
140 | dest[3] = _UTF8_CHAR(0, val); | 140 | dest[3] = MY_UTF8_CHAR(0, val); |
141 | dest += 4; | 141 | dest += 4; |
142 | continue; | 142 | continue; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | dest[0] = _UTF8_HEAD(2, val); | 146 | dest[0] = MY_UTF8_HEAD(2, val); |
147 | dest[1] = _UTF8_CHAR(1, val); | 147 | dest[1] = MY_UTF8_CHAR(1, val); |
148 | dest[2] = _UTF8_CHAR(0, val); | 148 | dest[2] = MY_UTF8_CHAR(0, val); |
149 | dest += 3; | 149 | dest += 3; |
150 | } | 150 | } |
151 | } | 151 | } |
@@ -163,7 +163,7 @@ static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen) | |||
163 | #endif | 163 | #endif |
164 | 164 | ||
165 | static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s | 165 | static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s |
166 | #ifndef _USE_UTF8 | 166 | #ifndef MY_USE_UTF8 |
167 | , UINT codePage | 167 | , UINT codePage |
168 | #endif | 168 | #endif |
169 | ) | 169 | ) |
@@ -171,7 +171,7 @@ static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s | |||
171 | unsigned len = 0; | 171 | unsigned len = 0; |
172 | for (len = 0; s[len] != 0; len++) {} | 172 | for (len = 0; s[len] != 0; len++) {} |
173 | 173 | ||
174 | #ifndef _USE_UTF8 | 174 | #ifndef MY_USE_UTF8 |
175 | { | 175 | { |
176 | const unsigned size = len * 3 + 100; | 176 | const unsigned size = len * 3 + 100; |
177 | if (!Buf_EnsureSize(buf, size)) | 177 | if (!Buf_EnsureSize(buf, size)) |
@@ -216,7 +216,7 @@ static WRes MyCreateDir(const UInt16 *name) | |||
216 | CBuf buf; | 216 | CBuf buf; |
217 | WRes res; | 217 | WRes res; |
218 | Buf_Init(&buf); | 218 | Buf_Init(&buf); |
219 | RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); | 219 | RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)) |
220 | 220 | ||
221 | res = | 221 | res = |
222 | #ifdef _WIN32 | 222 | #ifdef _WIN32 |
@@ -239,7 +239,7 @@ static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name) | |||
239 | CBuf buf; | 239 | CBuf buf; |
240 | WRes res; | 240 | WRes res; |
241 | Buf_Init(&buf); | 241 | Buf_Init(&buf); |
242 | RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); | 242 | RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)) |
243 | res = OutFile_Open(p, (const char *)buf.data); | 243 | res = OutFile_Open(p, (const char *)buf.data); |
244 | Buf_Free(&buf, &g_Alloc); | 244 | Buf_Free(&buf, &g_Alloc); |
245 | return res; | 245 | return res; |
@@ -253,7 +253,7 @@ static SRes PrintString(const UInt16 *s) | |||
253 | SRes res; | 253 | SRes res; |
254 | Buf_Init(&buf); | 254 | Buf_Init(&buf); |
255 | res = Utf16_To_Char(&buf, s | 255 | res = Utf16_To_Char(&buf, s |
256 | #ifndef _USE_UTF8 | 256 | #ifndef MY_USE_UTF8 |
257 | , CP_OEMCP | 257 | , CP_OEMCP |
258 | #endif | 258 | #endif |
259 | ); | 259 | ); |
@@ -328,12 +328,12 @@ typedef struct _FILETIME | |||
328 | 328 | ||
329 | static LONG TIME_GetBias() | 329 | static LONG TIME_GetBias() |
330 | { | 330 | { |
331 | time_t utc = time(NULL); | 331 | const time_t utc = time(NULL); |
332 | struct tm *ptm = localtime(&utc); | 332 | struct tm *ptm = localtime(&utc); |
333 | int localdaylight = ptm->tm_isdst; /* daylight for local timezone */ | 333 | const int localdaylight = ptm->tm_isdst; /* daylight for local timezone */ |
334 | ptm = gmtime(&utc); | 334 | ptm = gmtime(&utc); |
335 | ptm->tm_isdst = localdaylight; /* use local daylight, not that of Greenwich */ | 335 | ptm->tm_isdst = localdaylight; /* use local daylight, not that of Greenwich */ |
336 | LONG bias = (int)(mktime(ptm)-utc); | 336 | const LONG bias = (int)(mktime(ptm) - utc); |
337 | return bias; | 337 | return bias; |
338 | } | 338 | } |
339 | 339 | ||
@@ -352,7 +352,7 @@ static BOOL WINAPI FileTimeToLocalFileTime(const FILETIME *fileTime, FILETIME *l | |||
352 | { | 352 | { |
353 | UInt64 v = GET_TIME_64(fileTime); | 353 | UInt64 v = GET_TIME_64(fileTime); |
354 | v = (UInt64)((Int64)v - (Int64)TIME_GetBias() * TICKS_PER_SEC); | 354 | v = (UInt64)((Int64)v - (Int64)TIME_GetBias() * TICKS_PER_SEC); |
355 | SET_FILETIME(localFileTime, v); | 355 | SET_FILETIME(localFileTime, v) |
356 | return TRUE; | 356 | return TRUE; |
357 | } | 357 | } |
358 | 358 | ||
@@ -364,7 +364,7 @@ static const UInt64 kUnixTimeOffset = | |||
364 | 364 | ||
365 | static Int64 Time_FileTimeToUnixTime64(const FILETIME *ft) | 365 | static Int64 Time_FileTimeToUnixTime64(const FILETIME *ft) |
366 | { | 366 | { |
367 | UInt64 winTime = GET_TIME_64(ft); | 367 | const UInt64 winTime = GET_TIME_64(ft); |
368 | return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset; | 368 | return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset; |
369 | } | 369 | } |
370 | 370 | ||
@@ -384,8 +384,8 @@ static void FILETIME_To_timespec(const FILETIME *ft, struct MY_ST_TIMESPEC *ts) | |||
384 | if (sec2 == sec) | 384 | if (sec2 == sec) |
385 | { | 385 | { |
386 | ts->tv_sec = sec2; | 386 | ts->tv_sec = sec2; |
387 | UInt64 winTime = GET_TIME_64(ft); | 387 | const UInt64 winTime = GET_TIME_64(ft); |
388 | ts->tv_nsec = (long)((winTime % 10000000) * 100);; | 388 | ts->tv_nsec = (long)((winTime % 10000000) * 100); |
389 | return; | 389 | return; |
390 | } | 390 | } |
391 | } | 391 | } |
@@ -407,7 +407,7 @@ static WRes Set_File_FILETIME(const UInt16 *name, const FILETIME *mTime) | |||
407 | CBuf buf; | 407 | CBuf buf; |
408 | int res; | 408 | int res; |
409 | Buf_Init(&buf); | 409 | Buf_Init(&buf); |
410 | RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); | 410 | RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)) |
411 | FILETIME_To_timespec(NULL, ×[0]); | 411 | FILETIME_To_timespec(NULL, ×[0]); |
412 | FILETIME_To_timespec(mTime, ×[1]); | 412 | FILETIME_To_timespec(mTime, ×[1]); |
413 | res = utimensat(AT_FDCWD, (const char *)buf.data, times, flags); | 413 | res = utimensat(AT_FDCWD, (const char *)buf.data, times, flags); |
@@ -461,7 +461,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s) | |||
461 | ms[1] = 29; | 461 | ms[1] = 29; |
462 | for (mon = 0;; mon++) | 462 | for (mon = 0;; mon++) |
463 | { | 463 | { |
464 | unsigned d = ms[mon]; | 464 | const unsigned d = ms[mon]; |
465 | if (v < d) | 465 | if (v < d) |
466 | break; | 466 | break; |
467 | v -= d; | 467 | v -= d; |
@@ -474,7 +474,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s) | |||
474 | UIntToStr_2(s, sec); s[2] = 0; | 474 | UIntToStr_2(s, sec); s[2] = 0; |
475 | } | 475 | } |
476 | 476 | ||
477 | static void PrintLF() | 477 | static void PrintLF(void) |
478 | { | 478 | { |
479 | Print("\n"); | 479 | Print("\n"); |
480 | } | 480 | } |
@@ -541,7 +541,7 @@ static void GetAttribString(UInt32 wa, BoolInt isDir, char *s) | |||
541 | 541 | ||
542 | // #define NUM_PARENTS_MAX 128 | 542 | // #define NUM_PARENTS_MAX 128 |
543 | 543 | ||
544 | int MY_CDECL main(int numargs, char *args[]) | 544 | int Z7_CDECL main(int numargs, char *args[]) |
545 | { | 545 | { |
546 | ISzAlloc allocImp; | 546 | ISzAlloc allocImp; |
547 | ISzAlloc allocTempImp; | 547 | ISzAlloc allocTempImp; |
@@ -581,6 +581,7 @@ int MY_CDECL main(int numargs, char *args[]) | |||
581 | 581 | ||
582 | allocImp = g_Alloc; | 582 | allocImp = g_Alloc; |
583 | allocTempImp = g_Alloc; | 583 | allocTempImp = g_Alloc; |
584 | // allocTempImp = g_Alloc_temp; | ||
584 | 585 | ||
585 | { | 586 | { |
586 | WRes wres = | 587 | WRes wres = |
@@ -611,7 +612,7 @@ int MY_CDECL main(int numargs, char *args[]) | |||
611 | { | 612 | { |
612 | lookStream.bufSize = kInputBufSize; | 613 | lookStream.bufSize = kInputBufSize; |
613 | lookStream.realStream = &archiveStream.vt; | 614 | lookStream.realStream = &archiveStream.vt; |
614 | LookToRead2_Init(&lookStream); | 615 | LookToRead2_INIT(&lookStream) |
615 | } | 616 | } |
616 | } | 617 | } |
617 | 618 | ||
@@ -767,7 +768,7 @@ int MY_CDECL main(int numargs, char *args[]) | |||
767 | } | 768 | } |
768 | else | 769 | else |
769 | { | 770 | { |
770 | WRes wres = OutFile_OpenUtf16(&outFile, destPath); | 771 | const WRes wres = OutFile_OpenUtf16(&outFile, destPath); |
771 | if (wres != 0) | 772 | if (wres != 0) |
772 | { | 773 | { |
773 | PrintError_WRes("cannot open output file", wres); | 774 | PrintError_WRes("cannot open output file", wres); |
@@ -779,7 +780,7 @@ int MY_CDECL main(int numargs, char *args[]) | |||
779 | processedSize = outSizeProcessed; | 780 | processedSize = outSizeProcessed; |
780 | 781 | ||
781 | { | 782 | { |
782 | WRes wres = File_Write(&outFile, outBuffer + offset, &processedSize); | 783 | const WRes wres = File_Write(&outFile, outBuffer + offset, &processedSize); |
783 | if (wres != 0 || processedSize != outSizeProcessed) | 784 | if (wres != 0 || processedSize != outSizeProcessed) |
784 | { | 785 | { |
785 | PrintError_WRes("cannot write output file", wres); | 786 | PrintError_WRes("cannot write output file", wres); |
@@ -819,7 +820,7 @@ int MY_CDECL main(int numargs, char *args[]) | |||
819 | #endif | 820 | #endif |
820 | 821 | ||
821 | { | 822 | { |
822 | WRes wres = File_Close(&outFile); | 823 | const WRes wres = File_Close(&outFile); |
823 | if (wres != 0) | 824 | if (wres != 0) |
824 | { | 825 | { |
825 | PrintError_WRes("cannot close output file", wres); | 826 | PrintError_WRes("cannot close output file", wres); |
diff --git a/C/Util/7z/Precomp.h b/C/Util/7z/Precomp.h index 588a66f..bc8fa21 100644 --- a/C/Util/7z/Precomp.h +++ b/C/Util/7z/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/7z/makefile b/C/Util/7z/makefile index 9a49fd5..dfc560e 100644 --- a/C/Util/7z/makefile +++ b/C/Util/7z/makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT | 1 | CFLAGS = $(CFLAGS) -DZ7_PPMD_SUPPORT -DZ7_EXTRACT_ONLY |
2 | 2 | ||
3 | PROG = 7zDec.exe | 3 | PROG = 7zDec.exe |
4 | 4 | ||
diff --git a/C/Util/7z/makefile.gcc b/C/Util/7z/makefile.gcc index 4263d67..f48d362 100644 --- a/C/Util/7z/makefile.gcc +++ b/C/Util/7z/makefile.gcc | |||
@@ -1,6 +1,6 @@ | |||
1 | PROG = 7zdec | 1 | PROG = 7zdec |
2 | 2 | ||
3 | LOCAL_FLAGS = -D_7ZIP_PPMD_SUPPPORT | 3 | LOCAL_FLAGS = -DZ7_PPMD_SUPPORT -DZ7_EXTRACT_ONLY |
4 | 4 | ||
5 | include ../../../CPP/7zip/LzmaDec_gcc.mak | 5 | include ../../../CPP/7zip/LzmaDec_gcc.mak |
6 | 6 | ||
@@ -19,8 +19,6 @@ OBJS = \ | |||
19 | $O/Ppmd7Dec.o \ | 19 | $O/Ppmd7Dec.o \ |
20 | $O/7zCrc.o \ | 20 | $O/7zCrc.o \ |
21 | $O/7zCrcOpt.o \ | 21 | $O/7zCrcOpt.o \ |
22 | $O/Sha256.o \ | ||
23 | $O/Sha256Opt.o \ | ||
24 | $O/7zAlloc.o \ | 22 | $O/7zAlloc.o \ |
25 | $O/7zArcIn.o \ | 23 | $O/7zArcIn.o \ |
26 | $O/7zBuf.o \ | 24 | $O/7zBuf.o \ |
diff --git a/C/Util/7zipInstall/7zipInstall.c b/C/Util/7zipInstall/7zipInstall.c index 2649734..7f5fd19 100644 --- a/C/Util/7zipInstall/7zipInstall.c +++ b/C/Util/7zipInstall/7zipInstall.c | |||
@@ -1,16 +1,31 @@ | |||
1 | /* 7zipInstall.c - 7-Zip Installer | 1 | /* 7zipInstall.c - 7-Zip Installer |
2 | 2022-07-15 : Igor Pavlov : Public domain */ | 2 | 2023-04-04 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
5 | 5 | ||
6 | #define SZ_ERROR_ABORT 100 | 6 | #define SZ_ERROR_ABORT 100 |
7 | 7 | ||
8 | #ifdef _MSC_VER | 8 | #include "../../7zWindows.h" |
9 | |||
10 | #if defined(_MSC_VER) && _MSC_VER < 1600 | ||
9 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union | 11 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union |
10 | #endif | 12 | #endif |
11 | 13 | ||
12 | #include <windows.h> | 14 | #ifdef Z7_OLD_WIN_SDK |
15 | struct IShellView; | ||
16 | #define SHFOLDERAPI EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE | ||
17 | SHFOLDERAPI SHGetFolderPathW(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath); | ||
18 | #define BIF_NEWDIALOGSTYLE 0x0040 // Use the new dialog layout with the ability to resize | ||
19 | typedef enum { | ||
20 | SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists | ||
21 | SHGFP_TYPE_DEFAULT = 1, // default value, may not exist | ||
22 | } SHGFP_TYPE; | ||
23 | #endif | ||
24 | #if defined(__MINGW32__) || defined(__MINGW64__) | ||
25 | #include <shlobj.h> | ||
26 | #else | ||
13 | #include <ShlObj.h> | 27 | #include <ShlObj.h> |
28 | #endif | ||
14 | 29 | ||
15 | #include "../../7z.h" | 30 | #include "../../7z.h" |
16 | #include "../../7zAlloc.h" | 31 | #include "../../7zAlloc.h" |
@@ -22,40 +37,46 @@ | |||
22 | 37 | ||
23 | #include "resource.h" | 38 | #include "resource.h" |
24 | 39 | ||
25 | #if defined(__GNUC__) && (__GNUC__ >= 8) | 40 | #if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__) |
26 | #pragma GCC diagnostic ignored "-Wcast-function-type" | 41 | // #pragma GCC diagnostic ignored "-Wcast-function-type" |
42 | #endif | ||
43 | |||
44 | #if defined(__clang__) || defined(__GNUC__) | ||
45 | typedef void (*Z7_voidFunction)(void); | ||
46 | #define MY_CAST_FUNC (Z7_voidFunction) | ||
47 | #elif defined(_MSC_VER) && _MSC_VER > 1920 | ||
48 | #define MY_CAST_FUNC (void *) | ||
49 | // #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()' | ||
50 | #else | ||
51 | #define MY_CAST_FUNC | ||
27 | #endif | 52 | #endif |
28 | 53 | ||
29 | #define LLL_(quote) L##quote | 54 | #define LLL_(quote) L##quote |
30 | #define LLL(quote) LLL_(quote) | 55 | #define LLL(quote) LLL_(quote) |
31 | 56 | ||
32 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) | ||
33 | |||
34 | #define wcscat lstrcatW | 57 | #define wcscat lstrcatW |
35 | #define wcslen lstrlenW | 58 | #define wcslen (size_t)lstrlenW |
36 | #define wcscpy lstrcpyW | 59 | #define wcscpy lstrcpyW |
37 | // wcsncpy() and lstrcpynW() work differently. We don't use them. | 60 | // wcsncpy() and lstrcpynW() work differently. We don't use them. |
38 | 61 | ||
39 | |||
40 | #define kInputBufSize ((size_t)1 << 18) | 62 | #define kInputBufSize ((size_t)1 << 18) |
41 | 63 | ||
42 | 64 | #define Z7_7ZIP_CUR_VER ((MY_VER_MAJOR << 16) | MY_VER_MINOR) | |
43 | #define _7ZIP_CUR_VER ((MY_VER_MAJOR << 16) | MY_VER_MINOR) | 65 | #define Z7_7ZIP_DLL_VER_COMPAT ((16 << 16) | 3) |
44 | #define _7ZIP_DLL_VER_COMPAT ((16 << 16) | 3) | ||
45 | 66 | ||
46 | static LPCSTR const k_7zip = "7-Zip"; | 67 | static LPCSTR const k_7zip = "7-Zip"; |
47 | 68 | ||
48 | static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip"; | 69 | static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip"; |
49 | 70 | ||
50 | // #define _64BIT_INSTALLER 1 | 71 | // #define Z7_64BIT_INSTALLER 1 |
51 | 72 | ||
52 | #ifdef _WIN64 | 73 | #ifdef _WIN64 |
53 | #define _64BIT_INSTALLER 1 | 74 | #define Z7_64BIT_INSTALLER 1 |
54 | #endif | 75 | #endif |
55 | 76 | ||
56 | #define k_7zip_with_Ver_base L"7-Zip " LLL(MY_VERSION) | 77 | #define k_7zip_with_Ver_base L"7-Zip " LLL(MY_VERSION) |
57 | 78 | ||
58 | #ifdef _64BIT_INSTALLER | 79 | #ifdef Z7_64BIT_INSTALLER |
59 | 80 | ||
60 | // #define USE_7ZIP_32_DLL | 81 | // #define USE_7ZIP_32_DLL |
61 | 82 | ||
@@ -84,14 +105,14 @@ static LPCWSTR const k_7zip_Setup = k_7zip_with_Ver L" Setup"; | |||
84 | static LPCWSTR const k_Reg_Path = L"Path"; | 105 | static LPCWSTR const k_Reg_Path = L"Path"; |
85 | 106 | ||
86 | static LPCWSTR const k_Reg_Path32 = L"Path" | 107 | static LPCWSTR const k_Reg_Path32 = L"Path" |
87 | #ifdef _64BIT_INSTALLER | 108 | #ifdef Z7_64BIT_INSTALLER |
88 | L"64" | 109 | L"64" |
89 | #else | 110 | #else |
90 | L"32" | 111 | L"32" |
91 | #endif | 112 | #endif |
92 | ; | 113 | ; |
93 | 114 | ||
94 | #if defined(_64BIT_INSTALLER) && !defined(_WIN64) | 115 | #if defined(Z7_64BIT_INSTALLER) && !defined(_WIN64) |
95 | #define k_Reg_WOW_Flag KEY_WOW64_64KEY | 116 | #define k_Reg_WOW_Flag KEY_WOW64_64KEY |
96 | #else | 117 | #else |
97 | #define k_Reg_WOW_Flag 0 | 118 | #define k_Reg_WOW_Flag 0 |
@@ -126,8 +147,6 @@ static WCHAR cmdError[MAX_PATH + 4]; | |||
126 | static WCHAR path[MAX_PATH * 2 + 40]; | 147 | static WCHAR path[MAX_PATH * 2 + 40]; |
127 | 148 | ||
128 | 149 | ||
129 | // #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c))) | ||
130 | |||
131 | 150 | ||
132 | static void CpyAscii(wchar_t *dest, const char *s) | 151 | static void CpyAscii(wchar_t *dest, const char *s) |
133 | { | 152 | { |
@@ -200,9 +219,12 @@ static DWORD GetFileVersion(LPCWSTR s) | |||
200 | return 0; | 219 | return 0; |
201 | } | 220 | } |
202 | 221 | ||
203 | my_GetFileVersionInfoSizeW = (Func_GetFileVersionInfoSizeW)GetProcAddress(g_version_dll_hModule, "GetFileVersionInfoSizeW"); | 222 | my_GetFileVersionInfoSizeW = (Func_GetFileVersionInfoSizeW) MY_CAST_FUNC GetProcAddress(g_version_dll_hModule, |
204 | my_GetFileVersionInfoW = (Func_GetFileVersionInfoW)GetProcAddress(g_version_dll_hModule, "GetFileVersionInfoW"); | 223 | "GetFileVersionInfoSizeW"); |
205 | my_VerQueryValueW = (Func_VerQueryValueW)GetProcAddress(g_version_dll_hModule, "VerQueryValueW"); | 224 | my_GetFileVersionInfoW = (Func_GetFileVersionInfoW) MY_CAST_FUNC GetProcAddress(g_version_dll_hModule, |
225 | "GetFileVersionInfoW"); | ||
226 | my_VerQueryValueW = (Func_VerQueryValueW) MY_CAST_FUNC GetProcAddress(g_version_dll_hModule, | ||
227 | "VerQueryValueW"); | ||
206 | 228 | ||
207 | if (!my_GetFileVersionInfoSizeW | 229 | if (!my_GetFileVersionInfoSizeW |
208 | || !my_GetFileVersionInfoW | 230 | || !my_GetFileVersionInfoW |
@@ -253,7 +275,7 @@ static int ReverseFind_PathSepar(const wchar_t *s) | |||
253 | } | 275 | } |
254 | } | 276 | } |
255 | 277 | ||
256 | static WRes CreateComplexDir() | 278 | static WRes CreateComplexDir(void) |
257 | { | 279 | { |
258 | WCHAR s[MAX_PATH + 10]; | 280 | WCHAR s[MAX_PATH + 10]; |
259 | 281 | ||
@@ -287,7 +309,7 @@ static WRes CreateComplexDir() | |||
287 | { | 309 | { |
288 | size_t len = wcslen(s); | 310 | size_t len = wcslen(s); |
289 | { | 311 | { |
290 | int pos = ReverseFind_PathSepar(s); | 312 | const int pos = ReverseFind_PathSepar(s); |
291 | if (pos < 0) | 313 | if (pos < 0) |
292 | return wres; | 314 | return wres; |
293 | if ((unsigned)pos < prefixSize) | 315 | if ((unsigned)pos < prefixSize) |
@@ -297,7 +319,7 @@ static WRes CreateComplexDir() | |||
297 | if (len == 1) | 319 | if (len == 1) |
298 | return 0; | 320 | return 0; |
299 | s[pos] = 0; | 321 | s[pos] = 0; |
300 | len = pos; | 322 | len = (unsigned)pos; |
301 | } | 323 | } |
302 | } | 324 | } |
303 | 325 | ||
@@ -309,7 +331,7 @@ static WRes CreateComplexDir() | |||
309 | break; | 331 | break; |
310 | if (wres == ERROR_ALREADY_EXISTS) | 332 | if (wres == ERROR_ALREADY_EXISTS) |
311 | { | 333 | { |
312 | DWORD attrib = GetFileAttributesW(s); | 334 | const DWORD attrib = GetFileAttributesW(s); |
313 | if (attrib != INVALID_FILE_ATTRIBUTES) | 335 | if (attrib != INVALID_FILE_ATTRIBUTES) |
314 | if ((attrib & FILE_ATTRIBUTE_DIRECTORY) == 0) | 336 | if ((attrib & FILE_ATTRIBUTE_DIRECTORY) == 0) |
315 | return ERROR_ALREADY_EXISTS; | 337 | return ERROR_ALREADY_EXISTS; |
@@ -323,7 +345,7 @@ static WRes CreateComplexDir() | |||
323 | 345 | ||
324 | for (;;) | 346 | for (;;) |
325 | { | 347 | { |
326 | size_t pos = wcslen(s); | 348 | const size_t pos = wcslen(s); |
327 | if (pos >= len) | 349 | if (pos >= len) |
328 | return 0; | 350 | return 0; |
329 | s[pos] = CHAR_PATH_SEPARATOR; | 351 | s[pos] = CHAR_PATH_SEPARATOR; |
@@ -339,7 +361,7 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest) | |||
339 | { | 361 | { |
340 | DWORD cnt = MAX_PATH * sizeof(name[0]); | 362 | DWORD cnt = MAX_PATH * sizeof(name[0]); |
341 | DWORD type = 0; | 363 | DWORD type = 0; |
342 | LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, (DWORD *)&cnt); | 364 | const LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, &cnt); |
343 | if (type != REG_SZ) | 365 | if (type != REG_SZ) |
344 | return False; | 366 | return False; |
345 | return res == ERROR_SUCCESS; | 367 | return res == ERROR_SUCCESS; |
@@ -348,11 +370,11 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest) | |||
348 | static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) | 370 | static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) |
349 | { | 371 | { |
350 | HKEY key = 0; | 372 | HKEY key = 0; |
351 | LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key); | 373 | const LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key); |
352 | if (res != ERROR_SUCCESS) | 374 | if (res != ERROR_SUCCESS) |
353 | return False; | 375 | return False; |
354 | { | 376 | { |
355 | BoolInt res2 = MyRegistry_QueryString(key, valName, dest); | 377 | const BoolInt res2 = MyRegistry_QueryString(key, valName, dest); |
356 | RegCloseKey(key); | 378 | RegCloseKey(key); |
357 | return res2; | 379 | return res2; |
358 | } | 380 | } |
@@ -550,7 +572,7 @@ static void NormalizePrefix(WCHAR *s) | |||
550 | 572 | ||
551 | for (;; i++) | 573 | for (;; i++) |
552 | { | 574 | { |
553 | wchar_t c = s[i]; | 575 | const wchar_t c = s[i]; |
554 | if (c == 0) | 576 | if (c == 0) |
555 | break; | 577 | break; |
556 | if (c == '/') | 578 | if (c == '/') |
@@ -587,7 +609,7 @@ static LPCWSTR FindSubString(LPCWSTR s1, const char *s2) | |||
587 | return NULL; | 609 | return NULL; |
588 | for (i = 0;; i++) | 610 | for (i = 0;; i++) |
589 | { | 611 | { |
590 | Byte b = s2[i]; | 612 | const char b = s2[i]; |
591 | if (b == 0) | 613 | if (b == 0) |
592 | return s1; | 614 | return s1; |
593 | if (MyWCharLower_Ascii(s1[i]) != (Byte)MyCharLower_Ascii(b)) | 615 | if (MyWCharLower_Ascii(s1[i]) != (Byte)MyCharLower_Ascii(b)) |
@@ -610,7 +632,7 @@ static void Set7zipPostfix(WCHAR *s) | |||
610 | 632 | ||
611 | static int Install(void); | 633 | static int Install(void); |
612 | 634 | ||
613 | static void OnClose() | 635 | static void OnClose(void) |
614 | { | 636 | { |
615 | if (g_Install_was_Pressed && !g_Finished) | 637 | if (g_Install_was_Pressed && !g_Finished) |
616 | { | 638 | { |
@@ -624,7 +646,13 @@ static void OnClose() | |||
624 | g_HWND = NULL; | 646 | g_HWND = NULL; |
625 | } | 647 | } |
626 | 648 | ||
627 | static INT_PTR CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | 649 | static |
650 | #ifdef Z7_OLD_WIN_SDK | ||
651 | BOOL | ||
652 | #else | ||
653 | INT_PTR | ||
654 | #endif | ||
655 | CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | ||
628 | { | 656 | { |
629 | // UNUSED_VAR(hwnd) | 657 | // UNUSED_VAR(hwnd) |
630 | UNUSED_VAR(lParam) | 658 | UNUSED_VAR(lParam) |
@@ -730,7 +758,7 @@ static LONG SetRegKey_Path2(HKEY parentKey) | |||
730 | return res; | 758 | return res; |
731 | } | 759 | } |
732 | 760 | ||
733 | static void SetRegKey_Path() | 761 | static void SetRegKey_Path(void) |
734 | { | 762 | { |
735 | SetRegKey_Path2(HKEY_CURRENT_USER); | 763 | SetRegKey_Path2(HKEY_CURRENT_USER); |
736 | SetRegKey_Path2(HKEY_LOCAL_MACHINE); | 764 | SetRegKey_Path2(HKEY_LOCAL_MACHINE); |
@@ -828,7 +856,7 @@ static void SetShellProgramsGroup(HWND hwndOwner) | |||
828 | static LPCWSTR const k_Shell_Approved = L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"; | 856 | static LPCWSTR const k_Shell_Approved = L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"; |
829 | static LPCWSTR const k_7zip_ShellExtension = L"7-Zip Shell Extension"; | 857 | static LPCWSTR const k_7zip_ShellExtension = L"7-Zip Shell Extension"; |
830 | 858 | ||
831 | static void WriteCLSID() | 859 | static void WriteCLSID(void) |
832 | { | 860 | { |
833 | HKEY destKey; | 861 | HKEY destKey; |
834 | LONG res; | 862 | LONG res; |
@@ -879,12 +907,12 @@ static LPCSTR const k_ShellEx_Items[] = | |||
879 | , "Drive\\shellex\\DragDropHandlers" | 907 | , "Drive\\shellex\\DragDropHandlers" |
880 | }; | 908 | }; |
881 | 909 | ||
882 | static void WriteShellEx() | 910 | static void WriteShellEx(void) |
883 | { | 911 | { |
884 | unsigned i; | 912 | unsigned i; |
885 | WCHAR destPath[MAX_PATH + 40]; | 913 | WCHAR destPath[MAX_PATH + 40]; |
886 | 914 | ||
887 | for (i = 0; i < ARRAY_SIZE(k_ShellEx_Items); i++) | 915 | for (i = 0; i < Z7_ARRAY_SIZE(k_ShellEx_Items); i++) |
888 | { | 916 | { |
889 | CpyAscii(destPath, k_ShellEx_Items[i]); | 917 | CpyAscii(destPath, k_ShellEx_Items[i]); |
890 | CatAscii(destPath, "\\7-Zip"); | 918 | CatAscii(destPath, "\\7-Zip"); |
@@ -968,7 +996,7 @@ static const wchar_t *GetCmdParam(const wchar_t *s) | |||
968 | quoteMode = !quoteMode; | 996 | quoteMode = !quoteMode; |
969 | continue; | 997 | continue; |
970 | } | 998 | } |
971 | if (pos >= ARRAY_SIZE(cmd) - 1) | 999 | if (pos >= Z7_ARRAY_SIZE(cmd) - 1) |
972 | exit(1); | 1000 | exit(1); |
973 | cmd[pos++] = c; | 1001 | cmd[pos++] = c; |
974 | } | 1002 | } |
@@ -1026,7 +1054,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
1026 | for (;;) | 1054 | for (;;) |
1027 | { | 1055 | { |
1028 | { | 1056 | { |
1029 | wchar_t c = *s; | 1057 | const wchar_t c = *s; |
1030 | if (c == 0) | 1058 | if (c == 0) |
1031 | break; | 1059 | break; |
1032 | if (c == ' ') | 1060 | if (c == ' ') |
@@ -1070,11 +1098,12 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
1070 | } | 1098 | } |
1071 | } | 1099 | } |
1072 | 1100 | ||
1073 | #if defined(_64BIT_INSTALLER) && !defined(_WIN64) | 1101 | #if defined(Z7_64BIT_INSTALLER) && !defined(_WIN64) |
1074 | { | 1102 | { |
1075 | BOOL isWow64 = FALSE; | 1103 | BOOL isWow64 = FALSE; |
1076 | Func_IsWow64Process func_IsWow64Process = (Func_IsWow64Process) | 1104 | const Func_IsWow64Process func_IsWow64Process = (Func_IsWow64Process) |
1077 | GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "IsWow64Process"); | 1105 | MY_CAST_FUNC GetProcAddress(GetModuleHandleW(L"kernel32.dll"), |
1106 | "IsWow64Process"); | ||
1078 | 1107 | ||
1079 | if (func_IsWow64Process) | 1108 | if (func_IsWow64Process) |
1080 | func_IsWow64Process(GetCurrentProcess(), &isWow64); | 1109 | func_IsWow64Process(GetCurrentProcess(), &isWow64); |
@@ -1093,7 +1122,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
1093 | { | 1122 | { |
1094 | HKEY key = 0; | 1123 | HKEY key = 0; |
1095 | BoolInt ok = False; | 1124 | BoolInt ok = False; |
1096 | LONG res = RegOpenKeyExW(HKEY_CURRENT_USER, k_Reg_Software_7zip, 0, KEY_READ | k_Reg_WOW_Flag, &key); | 1125 | const LONG res = RegOpenKeyExW(HKEY_CURRENT_USER, k_Reg_Software_7zip, 0, KEY_READ | k_Reg_WOW_Flag, &key); |
1097 | if (res == ERROR_SUCCESS) | 1126 | if (res == ERROR_SUCCESS) |
1098 | { | 1127 | { |
1099 | ok = MyRegistry_QueryString(key, k_Reg_Path32, path); | 1128 | ok = MyRegistry_QueryString(key, k_Reg_Path32, path); |
@@ -1109,7 +1138,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
1109 | CpyAscii(path, "\\Program Files\\"); | 1138 | CpyAscii(path, "\\Program Files\\"); |
1110 | #else | 1139 | #else |
1111 | 1140 | ||
1112 | #ifdef _64BIT_INSTALLER | 1141 | #ifdef Z7_64BIT_INSTALLER |
1113 | { | 1142 | { |
1114 | DWORD ttt = GetEnvironmentVariableW(L"ProgramW6432", path, MAX_PATH); | 1143 | DWORD ttt = GetEnvironmentVariableW(L"ProgramW6432", path, MAX_PATH); |
1115 | if (ttt == 0 || ttt > MAX_PATH) | 1144 | if (ttt == 0 || ttt > MAX_PATH) |
@@ -1150,7 +1179,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
1150 | return 1; | 1179 | return 1; |
1151 | 1180 | ||
1152 | { | 1181 | { |
1153 | HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); | 1182 | const HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); |
1154 | // SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); | 1183 | // SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); |
1155 | SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); | 1184 | SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); |
1156 | } | 1185 | } |
@@ -1244,7 +1273,7 @@ static int Install(void) | |||
1244 | allocTempImp.Free = SzFreeTemp; | 1273 | allocTempImp.Free = SzFreeTemp; |
1245 | 1274 | ||
1246 | { | 1275 | { |
1247 | DWORD len = GetModuleFileNameW(NULL, sfxPath, MAX_PATH); | 1276 | const DWORD len = GetModuleFileNameW(NULL, sfxPath, MAX_PATH); |
1248 | if (len == 0 || len > MAX_PATH) | 1277 | if (len == 0 || len > MAX_PATH) |
1249 | return 1; | 1278 | return 1; |
1250 | } | 1279 | } |
@@ -1286,7 +1315,7 @@ if (res == SZ_OK) | |||
1286 | 1315 | ||
1287 | for (;;) | 1316 | for (;;) |
1288 | { | 1317 | { |
1289 | wchar_t c = path[i++]; | 1318 | const wchar_t c = path[i++]; |
1290 | if (c == 0) | 1319 | if (c == 0) |
1291 | break; | 1320 | break; |
1292 | if (c != ' ') | 1321 | if (c != ' ') |
@@ -1318,7 +1347,7 @@ if (res == SZ_OK) | |||
1318 | { | 1347 | { |
1319 | lookStream.bufSize = kInputBufSize; | 1348 | lookStream.bufSize = kInputBufSize; |
1320 | lookStream.realStream = &archiveStream.vt; | 1349 | lookStream.realStream = &archiveStream.vt; |
1321 | LookToRead2_Init(&lookStream); | 1350 | LookToRead2_INIT(&lookStream) |
1322 | } | 1351 | } |
1323 | } | 1352 | } |
1324 | 1353 | ||
@@ -1372,7 +1401,7 @@ if (res == SZ_OK) | |||
1372 | } | 1401 | } |
1373 | 1402 | ||
1374 | { | 1403 | { |
1375 | size_t len = SzArEx_GetFileNameUtf16(&db, i, NULL); | 1404 | const size_t len = SzArEx_GetFileNameUtf16(&db, i, NULL); |
1376 | if (len >= MAX_PATH) | 1405 | if (len >= MAX_PATH) |
1377 | { | 1406 | { |
1378 | res = SZ_ERROR_FAIL; | 1407 | res = SZ_ERROR_FAIL; |
@@ -1468,8 +1497,8 @@ if (res == SZ_OK) | |||
1468 | #endif | 1497 | #endif |
1469 | ) | 1498 | ) |
1470 | { | 1499 | { |
1471 | DWORD ver = GetFileVersion(path); | 1500 | const DWORD ver = GetFileVersion(path); |
1472 | fileLevel = ((ver < _7ZIP_DLL_VER_COMPAT || ver > _7ZIP_CUR_VER) ? 2 : 1); | 1501 | fileLevel = ((ver < Z7_7ZIP_DLL_VER_COMPAT || ver > Z7_7ZIP_CUR_VER) ? 2 : 1); |
1473 | tempIndex++; | 1502 | tempIndex++; |
1474 | continue; | 1503 | continue; |
1475 | } | 1504 | } |
@@ -1537,7 +1566,7 @@ if (res == SZ_OK) | |||
1537 | #endif | 1566 | #endif |
1538 | 1567 | ||
1539 | { | 1568 | { |
1540 | SRes winRes2 = File_Close(&outFile); | 1569 | const WRes winRes2 = File_Close(&outFile); |
1541 | if (res != SZ_OK) | 1570 | if (res != SZ_OK) |
1542 | break; | 1571 | break; |
1543 | if (winRes2 != 0) | 1572 | if (winRes2 != 0) |
diff --git a/C/Util/7zipInstall/7zipInstall.dsp b/C/Util/7zipInstall/7zipInstall.dsp index d3b5c4c..4c6ea4d 100644 --- a/C/Util/7zipInstall/7zipInstall.dsp +++ b/C/Util/7zipInstall/7zipInstall.dsp | |||
@@ -152,6 +152,10 @@ SOURCE=..\..\7zVersion.h | |||
152 | # End Source File | 152 | # End Source File |
153 | # Begin Source File | 153 | # Begin Source File |
154 | 154 | ||
155 | SOURCE=..\..\7zWindows.h | ||
156 | # End Source File | ||
157 | # Begin Source File | ||
158 | |||
155 | SOURCE=..\..\Bcj2.c | 159 | SOURCE=..\..\Bcj2.c |
156 | # End Source File | 160 | # End Source File |
157 | # Begin Source File | 161 | # Begin Source File |
@@ -220,6 +224,10 @@ SOURCE=..\..\LzmaDec.h | |||
220 | # PROP Default_Filter "" | 224 | # PROP Default_Filter "" |
221 | # Begin Source File | 225 | # Begin Source File |
222 | 226 | ||
227 | SOURCE=..\..\Compiler.h | ||
228 | # End Source File | ||
229 | # Begin Source File | ||
230 | |||
223 | SOURCE=.\Precomp.c | 231 | SOURCE=.\Precomp.c |
224 | # ADD CPP /Yc"Precomp.h" | 232 | # ADD CPP /Yc"Precomp.h" |
225 | # End Source File | 233 | # End Source File |
diff --git a/C/Util/7zipInstall/Precomp.h b/C/Util/7zipInstall/Precomp.h index 4c90d47..bc8fa21 100644 --- a/C/Util/7zipInstall/Precomp.h +++ b/C/Util/7zipInstall/Precomp.h | |||
@@ -1,11 +1,14 @@ | |||
1 | /* Precomp.h -- StdAfx | 1 | /* Precomp.h -- StdAfx |
2 | 2015-05-24 : 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 | 6 | ||
7 | #include "../../Compiler.h" | 7 | #if defined(_MSC_VER) && _MSC_VER >= 1800 |
8 | #pragma warning(disable : 4464) // relative include path contains '..' | ||
9 | #endif | ||
8 | 10 | ||
11 | #include "../../Compiler.h" | ||
9 | #include "../../7zTypes.h" | 12 | #include "../../7zTypes.h" |
10 | 13 | ||
11 | #endif | 14 | #endif |
diff --git a/C/Util/7zipInstall/makefile b/C/Util/7zipInstall/makefile index ab8893a..18e2783 100644 --- a/C/Util/7zipInstall/makefile +++ b/C/Util/7zipInstall/makefile | |||
@@ -1,15 +1,16 @@ | |||
1 | PROG = 7zipInstall.exe | 1 | PROG = 7zipInstall.exe |
2 | MY_FIXED = 1 | 2 | MY_FIXED = 1 |
3 | 3 | ||
4 | !IFDEF _64BIT_INSTALLER | 4 | !IFDEF Z7_64BIT_INSTALLER |
5 | CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER | 5 | CFLAGS = $(CFLAGS) -DZ7_64BIT_INSTALLER |
6 | !ENDIF | 6 | !ENDIF |
7 | 7 | ||
8 | CFLAGS = $(CFLAGS) -D_LZMA_SIZE_OPT | ||
9 | |||
10 | CFLAGS = $(CFLAGS) \ | 8 | CFLAGS = $(CFLAGS) \ |
11 | -D_7Z_NO_METHOD_LZMA2 \ | 9 | -DZ7_LZMA_SIZE_OPT \ |
12 | -D_7Z_NO_METHODS_FILTERS | 10 | -DZ7_NO_METHOD_LZMA2 \ |
11 | -DZ7_NO_METHODS_FILTERS \ | ||
12 | -DZ7_USE_NATIVE_BRANCH_FILTER \ | ||
13 | -DZ7_EXTRACT_ONLY \ | ||
13 | 14 | ||
14 | MAIN_OBJS = \ | 15 | MAIN_OBJS = \ |
15 | $O\7zipInstall.obj \ | 16 | $O\7zipInstall.obj \ |
@@ -25,6 +26,7 @@ C_OBJS = \ | |||
25 | $O\7zDec.obj \ | 26 | $O\7zDec.obj \ |
26 | $O\7zStream.obj \ | 27 | $O\7zStream.obj \ |
27 | $O\Bcj2.obj \ | 28 | $O\Bcj2.obj \ |
29 | $O\Bra.obj \ | ||
28 | $O\CpuArch.obj \ | 30 | $O\CpuArch.obj \ |
29 | $O\DllSecur.obj \ | 31 | $O\DllSecur.obj \ |
30 | $O\LzmaDec.obj \ | 32 | $O\LzmaDec.obj \ |
diff --git a/C/Util/7zipUninstall/7zipUninstall.c b/C/Util/7zipUninstall/7zipUninstall.c index c8e8a89..8bc18b3 100644 --- a/C/Util/7zipUninstall/7zipUninstall.c +++ b/C/Util/7zipUninstall/7zipUninstall.c | |||
@@ -3,40 +3,64 @@ | |||
3 | 3 | ||
4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
5 | 5 | ||
6 | #ifdef _MSC_VER | 6 | // #define SZ_ERROR_ABORT 100 |
7 | |||
8 | #include "../../7zWindows.h" | ||
9 | |||
10 | #if defined(_MSC_VER) && _MSC_VER < 1600 | ||
7 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union | 11 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union |
8 | #pragma warning(disable : 4011) // vs2010: identifier truncated to _CRT_SECURE_CPP_OVERLOAD_SECURE | ||
9 | #endif | 12 | #endif |
10 | 13 | ||
11 | // #define SZ_ERROR_ABORT 100 | 14 | #ifdef Z7_OLD_WIN_SDK |
12 | 15 | struct IShellView; | |
13 | #include <windows.h> | 16 | #define SHFOLDERAPI EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE |
17 | SHFOLDERAPI SHGetFolderPathW(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath); | ||
18 | #define BIF_NEWDIALOGSTYLE 0x0040 // Use the new dialog layout with the ability to resize | ||
19 | typedef enum { | ||
20 | SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists | ||
21 | SHGFP_TYPE_DEFAULT = 1, // default value, may not exist | ||
22 | } SHGFP_TYPE; | ||
23 | #endif | ||
24 | #if defined(__MINGW32__) || defined(__MINGW64__) | ||
25 | #include <shlobj.h> | ||
26 | #else | ||
14 | #include <ShlObj.h> | 27 | #include <ShlObj.h> |
28 | #endif | ||
15 | 29 | ||
16 | #include "../../7zVersion.h" | 30 | #include "../../7zVersion.h" |
17 | 31 | ||
18 | #include "resource.h" | 32 | #include "resource.h" |
19 | 33 | ||
20 | #if defined(__GNUC__) && (__GNUC__ >= 8) | 34 | #if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__) |
21 | #pragma GCC diagnostic ignored "-Wcast-function-type" | 35 | // #pragma GCC diagnostic ignored "-Wcast-function-type" |
22 | #endif | 36 | #endif |
23 | 37 | ||
38 | #if defined(_MSC_VER) && _MSC_VER > 1920 | ||
39 | #define MY_CAST_FUNC (void *) | ||
40 | // #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()' | ||
41 | #else | ||
42 | #define MY_CAST_FUNC | ||
43 | #endif | ||
44 | |||
45 | |||
24 | #define LLL_(quote) L##quote | 46 | #define LLL_(quote) L##quote |
25 | #define LLL(quote) LLL_(quote) | 47 | #define LLL(quote) LLL_(quote) |
26 | 48 | ||
27 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) | 49 | #define wcscat lstrcatW |
50 | #define wcslen (size_t)lstrlenW | ||
51 | #define wcscpy lstrcpyW | ||
28 | 52 | ||
29 | // static LPCWSTR const k_7zip = L"7-Zip"; | 53 | // static LPCWSTR const k_7zip = L"7-Zip"; |
30 | 54 | ||
31 | // #define _64BIT_INSTALLER 1 | 55 | // #define Z7_64BIT_INSTALLER 1 |
32 | 56 | ||
33 | #ifdef _WIN64 | 57 | #ifdef _WIN64 |
34 | #define _64BIT_INSTALLER 1 | 58 | #define Z7_64BIT_INSTALLER 1 |
35 | #endif | 59 | #endif |
36 | 60 | ||
37 | #define k_7zip_with_Ver_base L"7-Zip " LLL(MY_VERSION) | 61 | #define k_7zip_with_Ver_base L"7-Zip " LLL(MY_VERSION) |
38 | 62 | ||
39 | #ifdef _64BIT_INSTALLER | 63 | #ifdef Z7_64BIT_INSTALLER |
40 | 64 | ||
41 | // #define USE_7ZIP_32_DLL | 65 | // #define USE_7ZIP_32_DLL |
42 | 66 | ||
@@ -64,14 +88,14 @@ static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip"; | |||
64 | static LPCWSTR const k_Reg_Path = L"Path"; | 88 | static LPCWSTR const k_Reg_Path = L"Path"; |
65 | 89 | ||
66 | static LPCWSTR const k_Reg_Path32 = L"Path" | 90 | static LPCWSTR const k_Reg_Path32 = L"Path" |
67 | #ifdef _64BIT_INSTALLER | 91 | #ifdef Z7_64BIT_INSTALLER |
68 | L"64" | 92 | L"64" |
69 | #else | 93 | #else |
70 | L"32" | 94 | L"32" |
71 | #endif | 95 | #endif |
72 | ; | 96 | ; |
73 | 97 | ||
74 | #if defined(_64BIT_INSTALLER) && !defined(_WIN64) | 98 | #if defined(Z7_64BIT_INSTALLER) && !defined(_WIN64) |
75 | #define k_Reg_WOW_Flag KEY_WOW64_64KEY | 99 | #define k_Reg_WOW_Flag KEY_WOW64_64KEY |
76 | #else | 100 | #else |
77 | #define k_Reg_WOW_Flag 0 | 101 | #define k_Reg_WOW_Flag 0 |
@@ -116,14 +140,14 @@ static WCHAR copyPath[MAX_PATH * 2 + 40]; | |||
116 | 140 | ||
117 | static LPCWSTR const kUninstallExe = L"Uninstall.exe"; | 141 | static LPCWSTR const kUninstallExe = L"Uninstall.exe"; |
118 | 142 | ||
119 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c))) | 143 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) |
120 | 144 | ||
121 | 145 | ||
122 | static void CpyAscii(wchar_t *dest, const char *s) | 146 | static void CpyAscii(wchar_t *dest, const char *s) |
123 | { | 147 | { |
124 | for (;;) | 148 | for (;;) |
125 | { | 149 | { |
126 | Byte b = (Byte)*s++; | 150 | const Byte b = (Byte)*s++; |
127 | *dest++ = b; | 151 | *dest++ = b; |
128 | if (b == 0) | 152 | if (b == 0) |
129 | return; | 153 | return; |
@@ -173,7 +197,7 @@ static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_ | |||
173 | for (;;) | 197 | for (;;) |
174 | { | 198 | { |
175 | wchar_t c1; | 199 | wchar_t c1; |
176 | wchar_t c2 = *s2++; | 200 | const wchar_t c2 = *s2++; |
177 | if (c2 == 0) | 201 | if (c2 == 0) |
178 | return True; | 202 | return True; |
179 | c1 = *s1++; | 203 | c1 = *s1++; |
@@ -184,7 +208,7 @@ static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_ | |||
184 | 208 | ||
185 | static void NormalizePrefix(WCHAR *s) | 209 | static void NormalizePrefix(WCHAR *s) |
186 | { | 210 | { |
187 | size_t len = wcslen(s); | 211 | const size_t len = wcslen(s); |
188 | if (len != 0) | 212 | if (len != 0) |
189 | if (s[len - 1] != WCHAR_PATH_SEPARATOR) | 213 | if (s[len - 1] != WCHAR_PATH_SEPARATOR) |
190 | { | 214 | { |
@@ -197,7 +221,7 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest) | |||
197 | { | 221 | { |
198 | DWORD cnt = MAX_PATH * sizeof(name[0]); | 222 | DWORD cnt = MAX_PATH * sizeof(name[0]); |
199 | DWORD type = 0; | 223 | DWORD type = 0; |
200 | LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, (DWORD *)&cnt); | 224 | const LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, &cnt); |
201 | if (type != REG_SZ) | 225 | if (type != REG_SZ) |
202 | return False; | 226 | return False; |
203 | return res == ERROR_SUCCESS; | 227 | return res == ERROR_SUCCESS; |
@@ -206,11 +230,11 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest) | |||
206 | static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) | 230 | static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) |
207 | { | 231 | { |
208 | HKEY key = 0; | 232 | HKEY key = 0; |
209 | LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key); | 233 | const LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key); |
210 | if (res != ERROR_SUCCESS) | 234 | if (res != ERROR_SUCCESS) |
211 | return False; | 235 | return False; |
212 | { | 236 | { |
213 | BoolInt res2 = MyRegistry_QueryString(key, valName, dest); | 237 | const BoolInt res2 = MyRegistry_QueryString(key, valName, dest); |
214 | RegCloseKey(key); | 238 | RegCloseKey(key); |
215 | return res2; | 239 | return res2; |
216 | } | 240 | } |
@@ -237,11 +261,11 @@ static LONG MyRegistry_DeleteKey(HKEY parentKey, LPCWSTR name) | |||
237 | static int MyRegistry_QueryString2_32(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) | 261 | static int MyRegistry_QueryString2_32(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) |
238 | { | 262 | { |
239 | HKEY key = 0; | 263 | HKEY key = 0; |
240 | LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag_32, &key); | 264 | const LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag_32, &key); |
241 | if (res != ERROR_SUCCESS) | 265 | if (res != ERROR_SUCCESS) |
242 | return False; | 266 | return False; |
243 | { | 267 | { |
244 | BoolInt res2 = MyRegistry_QueryString(key, valName, dest); | 268 | const BoolInt res2 = MyRegistry_QueryString(key, valName, dest); |
245 | RegCloseKey(key); | 269 | RegCloseKey(key); |
246 | return res2; | 270 | return res2; |
247 | } | 271 | } |
@@ -282,7 +306,7 @@ static void MyReg_DeleteVal_Path_if_Equal(HKEY hKey, LPCWSTR name) | |||
282 | static void SetRegKey_Path2(HKEY parentKey) | 306 | static void SetRegKey_Path2(HKEY parentKey) |
283 | { | 307 | { |
284 | HKEY key = 0; | 308 | HKEY key = 0; |
285 | LONG res = MyRegistry_OpenKey_ReadWrite(parentKey, k_Reg_Software_7zip, &key); | 309 | const LONG res = MyRegistry_OpenKey_ReadWrite(parentKey, k_Reg_Software_7zip, &key); |
286 | if (res == ERROR_SUCCESS) | 310 | if (res == ERROR_SUCCESS) |
287 | { | 311 | { |
288 | MyReg_DeleteVal_Path_if_Equal(key, k_Reg_Path32); | 312 | MyReg_DeleteVal_Path_if_Equal(key, k_Reg_Path32); |
@@ -293,7 +317,7 @@ static void SetRegKey_Path2(HKEY parentKey) | |||
293 | } | 317 | } |
294 | } | 318 | } |
295 | 319 | ||
296 | static void SetRegKey_Path() | 320 | static void SetRegKey_Path(void) |
297 | { | 321 | { |
298 | SetRegKey_Path2(HKEY_CURRENT_USER); | 322 | SetRegKey_Path2(HKEY_CURRENT_USER); |
299 | SetRegKey_Path2(HKEY_LOCAL_MACHINE); | 323 | SetRegKey_Path2(HKEY_LOCAL_MACHINE); |
@@ -426,7 +450,7 @@ static BoolInt AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, | |||
426 | return AreStringsEqual_NoCase(s + wcslen(prefix), name); | 450 | return AreStringsEqual_NoCase(s + wcslen(prefix), name); |
427 | } | 451 | } |
428 | 452 | ||
429 | static void WriteCLSID() | 453 | static void WriteCLSID(void) |
430 | { | 454 | { |
431 | WCHAR s[MAX_PATH + 30]; | 455 | WCHAR s[MAX_PATH + 30]; |
432 | 456 | ||
@@ -435,14 +459,14 @@ static void WriteCLSID() | |||
435 | if (AreEqual_Path_PrefixName(s, path, L"7-zip.dll")) | 459 | if (AreEqual_Path_PrefixName(s, path, L"7-zip.dll")) |
436 | { | 460 | { |
437 | { | 461 | { |
438 | LONG res = MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc); | 462 | const LONG res = MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc); |
439 | if (res == ERROR_SUCCESS) | 463 | if (res == ERROR_SUCCESS) |
440 | MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip); | 464 | MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip); |
441 | } | 465 | } |
442 | 466 | ||
443 | { | 467 | { |
444 | unsigned i; | 468 | unsigned i; |
445 | for (i = 0; i < ARRAY_SIZE(k_ShellEx_Items); i++) | 469 | for (i = 0; i < Z7_ARRAY_SIZE(k_ShellEx_Items); i++) |
446 | { | 470 | { |
447 | WCHAR destPath[MAX_PATH]; | 471 | WCHAR destPath[MAX_PATH]; |
448 | CpyAscii(destPath, k_ShellEx_Items[i]); | 472 | CpyAscii(destPath, k_ShellEx_Items[i]); |
@@ -454,7 +478,7 @@ static void WriteCLSID() | |||
454 | 478 | ||
455 | { | 479 | { |
456 | HKEY destKey = 0; | 480 | HKEY destKey = 0; |
457 | LONG res = MyRegistry_OpenKey_ReadWrite(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey); | 481 | const LONG res = MyRegistry_OpenKey_ReadWrite(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey); |
458 | if (res == ERROR_SUCCESS) | 482 | if (res == ERROR_SUCCESS) |
459 | { | 483 | { |
460 | RegDeleteValueW(destKey, k_7zip_CLSID); | 484 | RegDeleteValueW(destKey, k_7zip_CLSID); |
@@ -472,14 +496,14 @@ static void WriteCLSID() | |||
472 | if (AreEqual_Path_PrefixName(s, path, L"7-zip32.dll")) | 496 | if (AreEqual_Path_PrefixName(s, path, L"7-zip32.dll")) |
473 | { | 497 | { |
474 | { | 498 | { |
475 | LONG res = MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc); | 499 | const LONG res = MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc); |
476 | if (res == ERROR_SUCCESS) | 500 | if (res == ERROR_SUCCESS) |
477 | MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip); | 501 | MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip); |
478 | } | 502 | } |
479 | 503 | ||
480 | { | 504 | { |
481 | unsigned i; | 505 | unsigned i; |
482 | for (i = 0; i < ARRAY_SIZE(k_ShellEx_Items); i++) | 506 | for (i = 0; i < Z7_ARRAY_SIZE(k_ShellEx_Items); i++) |
483 | { | 507 | { |
484 | WCHAR destPath[MAX_PATH]; | 508 | WCHAR destPath[MAX_PATH]; |
485 | CpyAscii(destPath, k_ShellEx_Items[i]); | 509 | CpyAscii(destPath, k_ShellEx_Items[i]); |
@@ -491,7 +515,7 @@ static void WriteCLSID() | |||
491 | 515 | ||
492 | { | 516 | { |
493 | HKEY destKey = 0; | 517 | HKEY destKey = 0; |
494 | LONG res = MyRegistry_OpenKey_ReadWrite_32(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey); | 518 | const LONG res = MyRegistry_OpenKey_ReadWrite_32(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey); |
495 | if (res == ERROR_SUCCESS) | 519 | if (res == ERROR_SUCCESS) |
496 | { | 520 | { |
497 | RegDeleteValueW(destKey, k_7zip_CLSID); | 521 | RegDeleteValueW(destKey, k_7zip_CLSID); |
@@ -526,7 +550,7 @@ static const wchar_t *GetCmdParam(const wchar_t *s) | |||
526 | BoolInt quoteMode = False; | 550 | BoolInt quoteMode = False; |
527 | for (;; s++) | 551 | for (;; s++) |
528 | { | 552 | { |
529 | wchar_t c = *s; | 553 | const wchar_t c = *s; |
530 | if (c == 0 || (c == L' ' && !quoteMode)) | 554 | if (c == 0 || (c == L' ' && !quoteMode)) |
531 | break; | 555 | break; |
532 | if (c == L'\"') | 556 | if (c == L'\"') |
@@ -534,7 +558,7 @@ static const wchar_t *GetCmdParam(const wchar_t *s) | |||
534 | quoteMode = !quoteMode; | 558 | quoteMode = !quoteMode; |
535 | continue; | 559 | continue; |
536 | } | 560 | } |
537 | if (pos >= ARRAY_SIZE(cmd) - 1) | 561 | if (pos >= Z7_ARRAY_SIZE(cmd) - 1) |
538 | exit(1); | 562 | exit(1); |
539 | cmd[pos++] = c; | 563 | cmd[pos++] = c; |
540 | } | 564 | } |
@@ -558,7 +582,7 @@ static void RemoveQuotes(wchar_t *s) | |||
558 | } | 582 | } |
559 | */ | 583 | */ |
560 | 584 | ||
561 | static BoolInt DoesFileOrDirExist() | 585 | static BoolInt DoesFileOrDirExist(void) |
562 | { | 586 | { |
563 | return (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES); | 587 | return (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES); |
564 | } | 588 | } |
@@ -573,7 +597,7 @@ static BOOL RemoveFileAfterReboot2(const WCHAR *s) | |||
573 | #endif | 597 | #endif |
574 | } | 598 | } |
575 | 599 | ||
576 | static BOOL RemoveFileAfterReboot() | 600 | static BOOL RemoveFileAfterReboot(void) |
577 | { | 601 | { |
578 | return RemoveFileAfterReboot2(path); | 602 | return RemoveFileAfterReboot2(path); |
579 | } | 603 | } |
@@ -584,7 +608,7 @@ static BoolInt IsThereSpace(const wchar_t *s) | |||
584 | { | 608 | { |
585 | for (;;) | 609 | for (;;) |
586 | { | 610 | { |
587 | wchar_t c = *s++; | 611 | const wchar_t c = *s++; |
588 | if (c == 0) | 612 | if (c == 0) |
589 | return False; | 613 | return False; |
590 | if (c == ' ') | 614 | if (c == ' ') |
@@ -594,7 +618,7 @@ static BoolInt IsThereSpace(const wchar_t *s) | |||
594 | 618 | ||
595 | static void AddPathParam(wchar_t *dest, const wchar_t *src) | 619 | static void AddPathParam(wchar_t *dest, const wchar_t *src) |
596 | { | 620 | { |
597 | BoolInt needQuote = IsThereSpace(src); | 621 | const BoolInt needQuote = IsThereSpace(src); |
598 | if (needQuote) | 622 | if (needQuote) |
599 | CatAscii(dest, "\""); | 623 | CatAscii(dest, "\""); |
600 | wcscat(dest, src); | 624 | wcscat(dest, src); |
@@ -618,9 +642,9 @@ static BoolInt GetErrorMessage(DWORD errorCode, WCHAR *message) | |||
618 | return True; | 642 | return True; |
619 | } | 643 | } |
620 | 644 | ||
621 | static BOOL RemoveDir() | 645 | static BOOL RemoveDir(void) |
622 | { | 646 | { |
623 | DWORD attrib = GetFileAttributesW(path); | 647 | const DWORD attrib = GetFileAttributesW(path); |
624 | if (attrib == INVALID_FILE_ATTRIBUTES) | 648 | if (attrib == INVALID_FILE_ATTRIBUTES) |
625 | return TRUE; | 649 | return TRUE; |
626 | if (RemoveDirectoryW(path)) | 650 | if (RemoveDirectoryW(path)) |
@@ -670,7 +694,7 @@ static const char * const k_Names = | |||
670 | 694 | ||
671 | 695 | ||
672 | 696 | ||
673 | static int Install() | 697 | static int Install(void) |
674 | { | 698 | { |
675 | SRes res = SZ_OK; | 699 | SRes res = SZ_OK; |
676 | WRes winRes = 0; | 700 | WRes winRes = 0; |
@@ -724,7 +748,7 @@ static int Install() | |||
724 | 748 | ||
725 | for (;;) | 749 | for (;;) |
726 | { | 750 | { |
727 | char c = *curName; | 751 | const char c = *curName; |
728 | if (c == 0) | 752 | if (c == 0) |
729 | break; | 753 | break; |
730 | curName++; | 754 | curName++; |
@@ -743,7 +767,7 @@ static int Install() | |||
743 | SetWindowTextW(g_InfoLine_HWND, temp); | 767 | SetWindowTextW(g_InfoLine_HWND, temp); |
744 | 768 | ||
745 | { | 769 | { |
746 | DWORD attrib = GetFileAttributesW(path); | 770 | const DWORD attrib = GetFileAttributesW(path); |
747 | if (attrib == INVALID_FILE_ATTRIBUTES) | 771 | if (attrib == INVALID_FILE_ATTRIBUTES) |
748 | continue; | 772 | continue; |
749 | if (attrib & FILE_ATTRIBUTE_READONLY) | 773 | if (attrib & FILE_ATTRIBUTE_READONLY) |
@@ -803,7 +827,7 @@ static int Install() | |||
803 | } | 827 | } |
804 | 828 | ||
805 | 829 | ||
806 | static void OnClose() | 830 | static void OnClose(void) |
807 | { | 831 | { |
808 | if (g_Install_was_Pressed && !g_Finished) | 832 | if (g_Install_was_Pressed && !g_Finished) |
809 | { | 833 | { |
@@ -817,7 +841,13 @@ static void OnClose() | |||
817 | g_HWND = NULL; | 841 | g_HWND = NULL; |
818 | } | 842 | } |
819 | 843 | ||
820 | static INT_PTR CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | 844 | static |
845 | #ifdef Z7_OLD_WIN_SDK | ||
846 | BOOL | ||
847 | #else | ||
848 | INT_PTR | ||
849 | #endif | ||
850 | CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | ||
821 | { | 851 | { |
822 | UNUSED_VAR(lParam) | 852 | UNUSED_VAR(lParam) |
823 | 853 | ||
@@ -905,7 +935,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
905 | #endif | 935 | #endif |
906 | 936 | ||
907 | #ifndef UNDER_CE | 937 | #ifndef UNDER_CE |
908 | func_RegDeleteKeyExW = (Func_RegDeleteKeyExW) | 938 | func_RegDeleteKeyExW = (Func_RegDeleteKeyExW) MY_CAST_FUNC |
909 | GetProcAddress(GetModuleHandleW(L"advapi32.dll"), "RegDeleteKeyExW"); | 939 | GetProcAddress(GetModuleHandleW(L"advapi32.dll"), "RegDeleteKeyExW"); |
910 | #endif | 940 | #endif |
911 | 941 | ||
@@ -976,7 +1006,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
976 | 1006 | ||
977 | { | 1007 | { |
978 | wchar_t *name; | 1008 | wchar_t *name; |
979 | DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH); | 1009 | const DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH); |
980 | if (len == 0 || len > MAX_PATH) | 1010 | if (len == 0 || len > MAX_PATH) |
981 | return 1; | 1011 | return 1; |
982 | 1012 | ||
@@ -987,7 +1017,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
987 | wchar_t *s = modulePrefix; | 1017 | wchar_t *s = modulePrefix; |
988 | for (;;) | 1018 | for (;;) |
989 | { | 1019 | { |
990 | wchar_t c = *s++; | 1020 | const wchar_t c = *s++; |
991 | if (c == 0) | 1021 | if (c == 0) |
992 | break; | 1022 | break; |
993 | if (c == WCHAR_PATH_SEPARATOR) | 1023 | if (c == WCHAR_PATH_SEPARATOR) |
@@ -1037,7 +1067,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
1037 | unsigned k; | 1067 | unsigned k; |
1038 | for (k = 0; k < 8; k++) | 1068 | for (k = 0; k < 8; k++) |
1039 | { | 1069 | { |
1040 | unsigned t = value & 0xF; | 1070 | const unsigned t = value & 0xF; |
1041 | value >>= 4; | 1071 | value >>= 4; |
1042 | s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); | 1072 | s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); |
1043 | } | 1073 | } |
@@ -1134,7 +1164,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
1134 | return 1; | 1164 | return 1; |
1135 | 1165 | ||
1136 | { | 1166 | { |
1137 | HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); | 1167 | const HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); |
1138 | // SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); | 1168 | // SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); |
1139 | SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); | 1169 | SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); |
1140 | } | 1170 | } |
diff --git a/C/Util/7zipUninstall/7zipUninstall.dsp b/C/Util/7zipUninstall/7zipUninstall.dsp index cc7b6b6..bb7473f 100644 --- a/C/Util/7zipUninstall/7zipUninstall.dsp +++ b/C/Util/7zipUninstall/7zipUninstall.dsp | |||
@@ -104,6 +104,14 @@ SOURCE=..\..\7zVersion.h | |||
104 | # PROP Default_Filter "" | 104 | # PROP Default_Filter "" |
105 | # Begin Source File | 105 | # Begin Source File |
106 | 106 | ||
107 | SOURCE=..\..\7zWindows.h | ||
108 | # End Source File | ||
109 | # Begin Source File | ||
110 | |||
111 | SOURCE=..\..\Compiler.h | ||
112 | # End Source File | ||
113 | # Begin Source File | ||
114 | |||
107 | SOURCE=.\Precomp.c | 115 | SOURCE=.\Precomp.c |
108 | # ADD CPP /Yc"Precomp.h" | 116 | # ADD CPP /Yc"Precomp.h" |
109 | # End Source File | 117 | # End Source File |
diff --git a/C/Util/7zipUninstall/Precomp.h b/C/Util/7zipUninstall/Precomp.h index 4c90d47..bc8fa21 100644 --- a/C/Util/7zipUninstall/Precomp.h +++ b/C/Util/7zipUninstall/Precomp.h | |||
@@ -1,11 +1,14 @@ | |||
1 | /* Precomp.h -- StdAfx | 1 | /* Precomp.h -- StdAfx |
2 | 2015-05-24 : 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 | 6 | ||
7 | #include "../../Compiler.h" | 7 | #if defined(_MSC_VER) && _MSC_VER >= 1800 |
8 | #pragma warning(disable : 4464) // relative include path contains '..' | ||
9 | #endif | ||
8 | 10 | ||
11 | #include "../../Compiler.h" | ||
9 | #include "../../7zTypes.h" | 12 | #include "../../7zTypes.h" |
10 | 13 | ||
11 | #endif | 14 | #endif |
diff --git a/C/Util/7zipUninstall/makefile b/C/Util/7zipUninstall/makefile index 60c2fe2..9d8aafc 100644 --- a/C/Util/7zipUninstall/makefile +++ b/C/Util/7zipUninstall/makefile | |||
@@ -1,8 +1,8 @@ | |||
1 | PROG = 7zipUninstall.exe | 1 | PROG = 7zipUninstall.exe |
2 | MY_FIXED = 1 | 2 | MY_FIXED = 1 |
3 | 3 | ||
4 | !IFDEF _64BIT_INSTALLER | 4 | !IFDEF Z7_64BIT_INSTALLER |
5 | CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER | 5 | CFLAGS = $(CFLAGS) -DZ7_64BIT_INSTALLER |
6 | !ENDIF | 6 | !ENDIF |
7 | 7 | ||
8 | MAIN_OBJS = \ | 8 | MAIN_OBJS = \ |
diff --git a/C/Util/Lzma/LzmaUtil.c b/C/Util/Lzma/LzmaUtil.c index 62a5907..b9b974b 100644 --- a/C/Util/Lzma/LzmaUtil.c +++ b/C/Util/Lzma/LzmaUtil.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* LzmaUtil.c -- Test application for LZMA compression | 1 | /* LzmaUtil.c -- Test application for LZMA compression |
2 | 2021-11-01 : Igor Pavlov : Public domain */ | 2 | 2023-03-07 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #include "../../Precomp.h" | 4 | #include "Precomp.h" |
5 | 5 | ||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
@@ -21,48 +21,80 @@ static const char * const kCantWriteMessage = "Cannot write output file"; | |||
21 | static const char * const kCantAllocateMessage = "Cannot allocate memory"; | 21 | static const char * const kCantAllocateMessage = "Cannot allocate memory"; |
22 | static const char * const kDataErrorMessage = "Data error"; | 22 | static const char * const kDataErrorMessage = "Data error"; |
23 | 23 | ||
24 | static void PrintHelp(char *buffer) | 24 | static void Print(const char *s) |
25 | { | 25 | { |
26 | strcat(buffer, | 26 | fputs(s, stdout); |
27 | "\nLZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n" | ||
28 | "Usage: lzma <e|d> inputFile outputFile\n" | ||
29 | " e: encode file\n" | ||
30 | " d: decode file\n"); | ||
31 | } | 27 | } |
32 | 28 | ||
33 | static int PrintError(char *buffer, const char *message) | 29 | static void PrintHelp(void) |
34 | { | 30 | { |
35 | strcat(buffer, "\nError: "); | 31 | Print( |
36 | strcat(buffer, message); | 32 | "\n" "LZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE |
37 | strcat(buffer, "\n"); | 33 | "\n" |
34 | "\n" "Usage: lzma <e|d> inputFile outputFile" | ||
35 | "\n" " e: encode file" | ||
36 | "\n" " d: decode file" | ||
37 | "\n"); | ||
38 | } | ||
39 | |||
40 | static int PrintError(const char *message) | ||
41 | { | ||
42 | Print("\nError: "); | ||
43 | Print(message); | ||
44 | Print("\n"); | ||
38 | return 1; | 45 | return 1; |
39 | } | 46 | } |
40 | 47 | ||
41 | static int PrintError_WRes(char *buffer, const char *message, WRes wres) | 48 | #define CONVERT_INT_TO_STR(charType, tempSize) \ |
49 | unsigned char temp[tempSize]; unsigned i = 0; \ | ||
50 | while (val >= 10) { temp[i++] = (unsigned char)('0' + (unsigned)(val % 10)); val /= 10; } \ | ||
51 | *s++ = (charType)('0' + (unsigned)val); \ | ||
52 | while (i != 0) { i--; *s++ = (charType)temp[i]; } \ | ||
53 | *s = 0; \ | ||
54 | return s; | ||
55 | |||
56 | static char * Convert_unsigned_To_str(unsigned val, char *s) | ||
42 | { | 57 | { |
43 | strcat(buffer, "\nError: "); | 58 | CONVERT_INT_TO_STR(char, 32) |
44 | strcat(buffer, message); | 59 | } |
45 | sprintf(buffer + strlen(buffer), "\nSystem error code: %d", (unsigned)wres); | 60 | |
61 | static void Print_unsigned(unsigned code) | ||
62 | { | ||
63 | char str[32]; | ||
64 | Convert_unsigned_To_str(code, str); | ||
65 | Print(str); | ||
66 | } | ||
67 | |||
68 | static int PrintError_WRes(const char *message, WRes wres) | ||
69 | { | ||
70 | PrintError(message); | ||
71 | Print("\nSystem error code: "); | ||
72 | Print_unsigned((unsigned)wres); | ||
46 | #ifndef _WIN32 | 73 | #ifndef _WIN32 |
47 | { | 74 | { |
48 | const char *s = strerror(wres); | 75 | const char *s = strerror(wres); |
49 | if (s) | 76 | if (s) |
50 | sprintf(buffer + strlen(buffer), " : %s", s); | 77 | { |
78 | Print(" : "); | ||
79 | Print(s); | ||
80 | } | ||
51 | } | 81 | } |
52 | #endif | 82 | #endif |
53 | strcat(buffer, "\n"); | 83 | Print("\n"); |
54 | return 1; | 84 | return 1; |
55 | } | 85 | } |
56 | 86 | ||
57 | static int PrintErrorNumber(char *buffer, SRes val) | 87 | static int PrintErrorNumber(SRes val) |
58 | { | 88 | { |
59 | sprintf(buffer + strlen(buffer), "\n7-Zip error code: %d\n", (unsigned)val); | 89 | Print("\n7-Zip error code: "); |
90 | Print_unsigned((unsigned)val); | ||
91 | Print("\n"); | ||
60 | return 1; | 92 | return 1; |
61 | } | 93 | } |
62 | 94 | ||
63 | static int PrintUserError(char *buffer) | 95 | static int PrintUserError(void) |
64 | { | 96 | { |
65 | return PrintError(buffer, "Incorrect command"); | 97 | return PrintError("Incorrect command"); |
66 | } | 98 | } |
67 | 99 | ||
68 | 100 | ||
@@ -70,10 +102,10 @@ static int PrintUserError(char *buffer) | |||
70 | #define OUT_BUF_SIZE (1 << 16) | 102 | #define OUT_BUF_SIZE (1 << 16) |
71 | 103 | ||
72 | 104 | ||
73 | static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream, | 105 | static SRes Decode2(CLzmaDec *state, ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream, |
74 | UInt64 unpackSize) | 106 | UInt64 unpackSize) |
75 | { | 107 | { |
76 | int thereIsSize = (unpackSize != (UInt64)(Int64)-1); | 108 | const int thereIsSize = (unpackSize != (UInt64)(Int64)-1); |
77 | Byte inBuf[IN_BUF_SIZE]; | 109 | Byte inBuf[IN_BUF_SIZE]; |
78 | Byte outBuf[OUT_BUF_SIZE]; | 110 | Byte outBuf[OUT_BUF_SIZE]; |
79 | size_t inPos = 0, inSize = 0, outPos = 0; | 111 | size_t inPos = 0, inSize = 0, outPos = 0; |
@@ -83,7 +115,7 @@ static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inS | |||
83 | if (inPos == inSize) | 115 | if (inPos == inSize) |
84 | { | 116 | { |
85 | inSize = IN_BUF_SIZE; | 117 | inSize = IN_BUF_SIZE; |
86 | RINOK(inStream->Read(inStream, inBuf, &inSize)); | 118 | RINOK(inStream->Read(inStream, inBuf, &inSize)) |
87 | inPos = 0; | 119 | inPos = 0; |
88 | } | 120 | } |
89 | { | 121 | { |
@@ -124,7 +156,7 @@ static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inS | |||
124 | } | 156 | } |
125 | 157 | ||
126 | 158 | ||
127 | static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream) | 159 | static SRes Decode(ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream) |
128 | { | 160 | { |
129 | UInt64 unpackSize; | 161 | UInt64 unpackSize; |
130 | int i; | 162 | int i; |
@@ -137,27 +169,29 @@ static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream) | |||
137 | 169 | ||
138 | /* Read and parse header */ | 170 | /* Read and parse header */ |
139 | 171 | ||
140 | RINOK(SeqInStream_Read(inStream, header, sizeof(header))); | 172 | { |
141 | 173 | size_t size = sizeof(header); | |
174 | RINOK(SeqInStream_ReadMax(inStream, header, &size)) | ||
175 | if (size != sizeof(header)) | ||
176 | return SZ_ERROR_INPUT_EOF; | ||
177 | } | ||
142 | unpackSize = 0; | 178 | unpackSize = 0; |
143 | for (i = 0; i < 8; i++) | 179 | for (i = 0; i < 8; i++) |
144 | unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8); | 180 | unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8); |
145 | 181 | ||
146 | LzmaDec_Construct(&state); | 182 | LzmaDec_CONSTRUCT(&state) |
147 | RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc)); | 183 | RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc)) |
148 | res = Decode2(&state, outStream, inStream, unpackSize); | 184 | res = Decode2(&state, outStream, inStream, unpackSize); |
149 | LzmaDec_Free(&state, &g_Alloc); | 185 | LzmaDec_Free(&state, &g_Alloc); |
150 | return res; | 186 | return res; |
151 | } | 187 | } |
152 | 188 | ||
153 | static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, char *rs) | 189 | static SRes Encode(ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream, UInt64 fileSize) |
154 | { | 190 | { |
155 | CLzmaEncHandle enc; | 191 | CLzmaEncHandle enc; |
156 | SRes res; | 192 | SRes res; |
157 | CLzmaEncProps props; | 193 | CLzmaEncProps props; |
158 | 194 | ||
159 | UNUSED_VAR(rs); | ||
160 | |||
161 | enc = LzmaEnc_Create(&g_Alloc); | 195 | enc = LzmaEnc_Create(&g_Alloc); |
162 | if (enc == 0) | 196 | if (enc == 0) |
163 | return SZ_ERROR_MEM; | 197 | return SZ_ERROR_MEM; |
@@ -187,7 +221,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file | |||
187 | } | 221 | } |
188 | 222 | ||
189 | 223 | ||
190 | static int main2(int numArgs, const char *args[], char *rs) | 224 | int Z7_CDECL main(int numArgs, const char *args[]) |
191 | { | 225 | { |
192 | CFileSeqInStream inStream; | 226 | CFileSeqInStream inStream; |
193 | CFileOutStream outStream; | 227 | CFileOutStream outStream; |
@@ -208,29 +242,31 @@ static int main2(int numArgs, const char *args[], char *rs) | |||
208 | 242 | ||
209 | if (numArgs == 1) | 243 | if (numArgs == 1) |
210 | { | 244 | { |
211 | PrintHelp(rs); | 245 | PrintHelp(); |
212 | return 0; | 246 | return 0; |
213 | } | 247 | } |
214 | 248 | ||
215 | if (numArgs < 3 || numArgs > 4 || strlen(args[1]) != 1) | 249 | if (numArgs < 3 || numArgs > 4 || strlen(args[1]) != 1) |
216 | return PrintUserError(rs); | 250 | return PrintUserError(); |
217 | 251 | ||
218 | c = args[1][0]; | 252 | c = args[1][0]; |
219 | encodeMode = (c == 'e' || c == 'E'); | 253 | encodeMode = (c == 'e' || c == 'E'); |
220 | if (!encodeMode && c != 'd' && c != 'D') | 254 | if (!encodeMode && c != 'd' && c != 'D') |
221 | return PrintUserError(rs); | 255 | return PrintUserError(); |
222 | 256 | ||
257 | /* | ||
223 | { | 258 | { |
224 | size_t t4 = sizeof(UInt32); | 259 | size_t t4 = sizeof(UInt32); |
225 | size_t t8 = sizeof(UInt64); | 260 | size_t t8 = sizeof(UInt64); |
226 | if (t4 != 4 || t8 != 8) | 261 | if (t4 != 4 || t8 != 8) |
227 | return PrintError(rs, "Incorrect UInt32 or UInt64"); | 262 | return PrintError("Incorrect UInt32 or UInt64"); |
228 | } | 263 | } |
264 | */ | ||
229 | 265 | ||
230 | { | 266 | { |
231 | WRes wres = InFile_Open(&inStream.file, args[2]); | 267 | const WRes wres = InFile_Open(&inStream.file, args[2]); |
232 | if (wres != 0) | 268 | if (wres != 0) |
233 | return PrintError_WRes(rs, "Cannot open input file", wres); | 269 | return PrintError_WRes("Cannot open input file", wres); |
234 | } | 270 | } |
235 | 271 | ||
236 | if (numArgs > 3) | 272 | if (numArgs > 3) |
@@ -239,18 +275,18 @@ static int main2(int numArgs, const char *args[], char *rs) | |||
239 | useOutFile = True; | 275 | useOutFile = True; |
240 | wres = OutFile_Open(&outStream.file, args[3]); | 276 | wres = OutFile_Open(&outStream.file, args[3]); |
241 | if (wres != 0) | 277 | if (wres != 0) |
242 | return PrintError_WRes(rs, "Cannot open output file", wres); | 278 | return PrintError_WRes("Cannot open output file", wres); |
243 | } | 279 | } |
244 | else if (encodeMode) | 280 | else if (encodeMode) |
245 | PrintUserError(rs); | 281 | PrintUserError(); |
246 | 282 | ||
247 | if (encodeMode) | 283 | if (encodeMode) |
248 | { | 284 | { |
249 | UInt64 fileSize; | 285 | UInt64 fileSize; |
250 | WRes wres = File_GetLength(&inStream.file, &fileSize); | 286 | const WRes wres = File_GetLength(&inStream.file, &fileSize); |
251 | if (wres != 0) | 287 | if (wres != 0) |
252 | return PrintError_WRes(rs, "Cannot get file length", wres); | 288 | return PrintError_WRes("Cannot get file length", wres); |
253 | res = Encode(&outStream.vt, &inStream.vt, fileSize, rs); | 289 | res = Encode(&outStream.vt, &inStream.vt, fileSize); |
254 | } | 290 | } |
255 | else | 291 | else |
256 | { | 292 | { |
@@ -264,23 +300,14 @@ static int main2(int numArgs, const char *args[], char *rs) | |||
264 | if (res != SZ_OK) | 300 | if (res != SZ_OK) |
265 | { | 301 | { |
266 | if (res == SZ_ERROR_MEM) | 302 | if (res == SZ_ERROR_MEM) |
267 | return PrintError(rs, kCantAllocateMessage); | 303 | return PrintError(kCantAllocateMessage); |
268 | else if (res == SZ_ERROR_DATA) | 304 | else if (res == SZ_ERROR_DATA) |
269 | return PrintError(rs, kDataErrorMessage); | 305 | return PrintError(kDataErrorMessage); |
270 | else if (res == SZ_ERROR_WRITE) | 306 | else if (res == SZ_ERROR_WRITE) |
271 | return PrintError_WRes(rs, kCantWriteMessage, outStream.wres); | 307 | return PrintError_WRes(kCantWriteMessage, outStream.wres); |
272 | else if (res == SZ_ERROR_READ) | 308 | else if (res == SZ_ERROR_READ) |
273 | return PrintError_WRes(rs, kCantReadMessage, inStream.wres); | 309 | return PrintError_WRes(kCantReadMessage, inStream.wres); |
274 | return PrintErrorNumber(rs, res); | 310 | return PrintErrorNumber(res); |
275 | } | 311 | } |
276 | return 0; | 312 | return 0; |
277 | } | 313 | } |
278 | |||
279 | |||
280 | int MY_CDECL main(int numArgs, const char *args[]) | ||
281 | { | ||
282 | char rs[1000] = { 0 }; | ||
283 | int res = main2(numArgs, args, rs); | ||
284 | fputs(rs, stdout); | ||
285 | return res; | ||
286 | } | ||
diff --git a/C/Util/Lzma/LzmaUtil.dsp b/C/Util/Lzma/LzmaUtil.dsp index 4e38e4a..e2e7d42 100644 --- a/C/Util/Lzma/LzmaUtil.dsp +++ b/C/Util/Lzma/LzmaUtil.dsp | |||
@@ -106,6 +106,10 @@ SOURCE=..\..\7zVersion.h | |||
106 | # End Source File | 106 | # End Source File |
107 | # Begin Source File | 107 | # Begin Source File |
108 | 108 | ||
109 | SOURCE=..\..\7zWindows.h | ||
110 | # End Source File | ||
111 | # Begin Source File | ||
112 | |||
109 | SOURCE=..\..\Alloc.c | 113 | SOURCE=..\..\Alloc.c |
110 | # End Source File | 114 | # End Source File |
111 | # Begin Source File | 115 | # Begin Source File |
@@ -114,6 +118,10 @@ SOURCE=..\..\Alloc.h | |||
114 | # End Source File | 118 | # End Source File |
115 | # Begin Source File | 119 | # Begin Source File |
116 | 120 | ||
121 | SOURCE=..\..\Compiler.h | ||
122 | # End Source File | ||
123 | # Begin Source File | ||
124 | |||
117 | SOURCE=..\..\CpuArch.h | 125 | SOURCE=..\..\CpuArch.h |
118 | # End Source File | 126 | # End Source File |
119 | # Begin Source File | 127 | # Begin Source File |
@@ -162,6 +170,14 @@ SOURCE=.\LzmaUtil.c | |||
162 | # End Source File | 170 | # End Source File |
163 | # Begin Source File | 171 | # Begin Source File |
164 | 172 | ||
173 | SOURCE=..\..\Precomp.h | ||
174 | # End Source File | ||
175 | # Begin Source File | ||
176 | |||
177 | SOURCE=.\Precomp.h | ||
178 | # End Source File | ||
179 | # Begin Source File | ||
180 | |||
165 | SOURCE=..\..\Threads.c | 181 | SOURCE=..\..\Threads.c |
166 | # End Source File | 182 | # End Source File |
167 | # Begin Source File | 183 | # Begin Source File |
diff --git a/C/Util/Lzma/Precomp.h b/C/Util/Lzma/Precomp.h new file mode 100644 index 0000000..bc8fa21 --- /dev/null +++ b/C/Util/Lzma/Precomp.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* Precomp.h -- StdAfx | ||
2 | 2023-03-04 : Igor Pavlov : Public domain */ | ||
3 | |||
4 | #ifndef ZIP7_INC_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 | ||
10 | |||
11 | #include "../../Compiler.h" | ||
12 | #include "../../7zTypes.h" | ||
13 | |||
14 | #endif | ||
diff --git a/C/Util/LzmaLib/LzmaLib.dsp b/C/Util/LzmaLib/LzmaLib.dsp index 6ce91dc..bacd967 100644 --- a/C/Util/LzmaLib/LzmaLib.dsp +++ b/C/Util/LzmaLib/LzmaLib.dsp | |||
@@ -101,6 +101,10 @@ SOURCE=.\LzmaLib.def | |||
101 | 101 | ||
102 | SOURCE=.\LzmaLibExports.c | 102 | SOURCE=.\LzmaLibExports.c |
103 | # End Source File | 103 | # End Source File |
104 | # Begin Source File | ||
105 | |||
106 | SOURCE=.\Precomp.h | ||
107 | # End Source File | ||
104 | # End Group | 108 | # End Group |
105 | # Begin Source File | 109 | # Begin Source File |
106 | 110 | ||
@@ -108,6 +112,10 @@ SOURCE=..\..\7zTypes.h | |||
108 | # End Source File | 112 | # End Source File |
109 | # Begin Source File | 113 | # Begin Source File |
110 | 114 | ||
115 | SOURCE=..\..\7zWindows.h | ||
116 | # End Source File | ||
117 | # Begin Source File | ||
118 | |||
111 | SOURCE=..\..\Alloc.c | 119 | SOURCE=..\..\Alloc.c |
112 | # End Source File | 120 | # End Source File |
113 | # Begin Source File | 121 | # Begin Source File |
@@ -116,6 +124,14 @@ SOURCE=..\..\Alloc.h | |||
116 | # End Source File | 124 | # End Source File |
117 | # Begin Source File | 125 | # Begin Source File |
118 | 126 | ||
127 | SOURCE=..\..\Compiler.h | ||
128 | # End Source File | ||
129 | # Begin Source File | ||
130 | |||
131 | SOURCE=..\..\CpuArch.h | ||
132 | # End Source File | ||
133 | # Begin Source File | ||
134 | |||
119 | SOURCE=..\..\IStream.h | 135 | SOURCE=..\..\IStream.h |
120 | # End Source File | 136 | # End Source File |
121 | # Begin Source File | 137 | # Begin Source File |
@@ -168,6 +184,10 @@ SOURCE=..\..\LzmaLib.h | |||
168 | # End Source File | 184 | # End Source File |
169 | # Begin Source File | 185 | # Begin Source File |
170 | 186 | ||
187 | SOURCE=..\..\Precomp.h | ||
188 | # End Source File | ||
189 | # Begin Source File | ||
190 | |||
171 | SOURCE=.\resource.rc | 191 | SOURCE=.\resource.rc |
172 | # End Source File | 192 | # End Source File |
173 | # Begin Source File | 193 | # Begin Source File |
diff --git a/C/Util/LzmaLib/LzmaLibExports.c b/C/Util/LzmaLib/LzmaLibExports.c index 4a28a9a..a46c9a8 100644 --- a/C/Util/LzmaLib/LzmaLibExports.c +++ b/C/Util/LzmaLib/LzmaLibExports.c | |||
@@ -1,14 +1,15 @@ | |||
1 | /* LzmaLibExports.c -- LZMA library DLL Entry point | 1 | /* LzmaLibExports.c -- LZMA library DLL Entry point |
2 | 2015-11-08 : Igor Pavlov : Public domain */ | 2 | 2023-03-05 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #include "../../Precomp.h" | 4 | #include "Precomp.h" |
5 | 5 | ||
6 | #include <windows.h> | 6 | #include "../../7zWindows.h" |
7 | 7 | ||
8 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved); | ||
8 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) | 9 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) |
9 | { | 10 | { |
10 | UNUSED_VAR(hInstance); | 11 | UNUSED_VAR(hInstance) |
11 | UNUSED_VAR(dwReason); | 12 | UNUSED_VAR(dwReason) |
12 | UNUSED_VAR(lpReserved); | 13 | UNUSED_VAR(lpReserved) |
13 | return TRUE; | 14 | return TRUE; |
14 | } | 15 | } |
diff --git a/C/Util/LzmaLib/Precomp.c b/C/Util/LzmaLib/Precomp.c new file mode 100644 index 0000000..01605e3 --- /dev/null +++ b/C/Util/LzmaLib/Precomp.c | |||
@@ -0,0 +1,4 @@ | |||
1 | /* Precomp.c -- StdAfx | ||
2 | 2013-01-21 : Igor Pavlov : Public domain */ | ||
3 | |||
4 | #include "Precomp.h" | ||
diff --git a/C/Util/LzmaLib/Precomp.h b/C/Util/LzmaLib/Precomp.h new file mode 100644 index 0000000..bc8fa21 --- /dev/null +++ b/C/Util/LzmaLib/Precomp.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* Precomp.h -- StdAfx | ||
2 | 2023-03-04 : Igor Pavlov : Public domain */ | ||
3 | |||
4 | #ifndef ZIP7_INC_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 | ||
10 | |||
11 | #include "../../Compiler.h" | ||
12 | #include "../../7zTypes.h" | ||
13 | |||
14 | #endif | ||
diff --git a/C/Util/LzmaLib/makefile b/C/Util/LzmaLib/makefile index b36f1de..b8e054e 100644 --- a/C/Util/LzmaLib/makefile +++ b/C/Util/LzmaLib/makefile | |||
@@ -21,6 +21,7 @@ C_OBJS = \ | |||
21 | $O\Threads.obj \ | 21 | $O\Threads.obj \ |
22 | 22 | ||
23 | OBJS = \ | 23 | OBJS = \ |
24 | $O\Precomp.obj \ | ||
24 | $(LIB_OBJS) \ | 25 | $(LIB_OBJS) \ |
25 | $(C_OBJS) \ | 26 | $(C_OBJS) \ |
26 | $O\resource.res | 27 | $O\resource.res |
@@ -30,7 +31,24 @@ OBJS = \ | |||
30 | $(SLIBPATH): $O $(OBJS) | 31 | $(SLIBPATH): $O $(OBJS) |
31 | lib -out:$(SLIBPATH) $(OBJS) $(LIBS) | 32 | lib -out:$(SLIBPATH) $(OBJS) $(LIBS) |
32 | 33 | ||
34 | |||
35 | MAK_SINGLE_FILE = 1 | ||
36 | |||
37 | $O\Precomp.obj: Precomp.c | ||
38 | $(CCOMPL_PCH) | ||
39 | |||
40 | !IFDEF MAK_SINGLE_FILE | ||
41 | |||
33 | $(LIB_OBJS): $(*B).c | 42 | $(LIB_OBJS): $(*B).c |
34 | $(COMPL_O2) | 43 | $(CCOMPL_USE) |
35 | $(C_OBJS): ../../$(*B).c | 44 | $(C_OBJS): ../../$(*B).c |
36 | $(COMPL_O2) | 45 | $(CCOMPL_USE) |
46 | |||
47 | !ELSE | ||
48 | |||
49 | {.}.c{$O}.obj:: | ||
50 | $(CCOMPLB_USE) | ||
51 | {../../../C}.c{$O}.obj:: | ||
52 | $(CCOMPLB_USE) | ||
53 | |||
54 | !ENDIF | ||
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 \ |