This commit is contained in:
Igor Pavlov
2023-12-22 17:17:05 +00:00
committed by Kornel
parent ec44a8a070
commit a36c48cece
954 changed files with 42199 additions and 25482 deletions

View File

@@ -1,8 +1,12 @@
/* Precomp.h -- StdAfx
2013-06-16 : Igor Pavlov : Public domain */
2023-03-04 : Igor Pavlov : Public domain */
#ifndef __7Z_PRECOMP_H
#define __7Z_PRECOMP_H
#ifndef ZIP7_INC_PRECOMP_H
#define ZIP7_INC_PRECOMP_H
#if defined(_MSC_VER) && _MSC_VER >= 1800
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#include "../../Compiler.h"
#include "../../7zTypes.h"

View File

@@ -26,6 +26,12 @@
#define kInputBufSize ((size_t)1 << 18)
#define wcscat lstrcatW
#define wcslen (size_t)lstrlenW
#define wcscpy lstrcpyW
// wcsncpy() and lstrcpynW() work differently. We don't use them.
static const char * const kExts[] =
{
"bat"
@@ -64,7 +70,7 @@ static unsigned FindExt(const wchar_t *s, unsigned *extLen)
return len;
}
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c)))
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c)))
static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len)
{
@@ -72,13 +78,13 @@ static unsigned FindItem(const char * const *items, unsigned num, const wchar_t
for (i = 0; i < num; i++)
{
const char *item = items[i];
unsigned itemLen = (unsigned)strlen(item);
const unsigned itemLen = (unsigned)strlen(item);
unsigned j;
if (len != itemLen)
continue;
for (j = 0; j < len; j++)
{
unsigned c = (Byte)item[j];
const unsigned c = (Byte)item[j];
if (c != s[j] && MAKE_CHAR_UPPER(c) != s[j])
break;
}
@@ -96,10 +102,20 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
}
#endif
#ifdef _CONSOLE
static void PrintStr(const char *s)
{
fputs(s, stdout);
}
#endif
static void PrintErrorMessage(const char *message)
{
#ifdef _CONSOLE
printf("\n7-Zip Error: %s\n", message);
PrintStr("\n7-Zip Error: ");
PrintStr(message);
PrintStr("\n");
#else
#ifdef UNDER_CE
WCHAR messageW[256 + 4];
@@ -179,7 +195,7 @@ static WRes RemoveDirWithSubItems(WCHAR *path)
WIN32_FIND_DATAW fd;
HANDLE handle;
WRes res = 0;
size_t len = wcslen(path);
const size_t len = wcslen(path);
wcscpy(path + len, L"*");
handle = FindFirstFileW(path, &fd);
path[len] = L'\0';
@@ -228,7 +244,7 @@ static WRes RemoveDirWithSubItems(WCHAR *path)
}
#ifdef _CONSOLE
int MY_CDECL main()
int Z7_CDECL main(void)
#else
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef UNDER_CE
@@ -290,7 +306,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
BoolInt quoteMode = False;
for (;; cmdLineParams++)
{
wchar_t c = *cmdLineParams;
const wchar_t c = *cmdLineParams;
if (c == L'\"')
quoteMode = !quoteMode;
else if (c == 0 || (c == L' ' && !quoteMode))
@@ -324,7 +340,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
unsigned k;
for (k = 0; k < 8; k++)
{
unsigned t = value & 0xF;
const unsigned t = value & 0xF;
value >>= 4;
s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
}
@@ -386,7 +402,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
{
lookStream.bufSize = kInputBufSize;
lookStream.realStream = &archiveStream.vt;
LookToRead2_Init(&lookStream);
LookToRead2_INIT(&lookStream)
}
}
@@ -455,11 +471,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
unsigned extLen;
const WCHAR *name = temp + nameStartPos;
unsigned len = (unsigned)wcslen(name);
unsigned nameLen = FindExt(temp + nameStartPos, &extLen);
unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen);
unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen);
const unsigned nameLen = FindExt(temp + nameStartPos, &extLen);
const unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen);
const unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen);
unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12));
const unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12));
if (minPrice > price)
{
minPrice = price;
@@ -500,7 +516,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#endif
{
SRes res2 = File_Close(&outFile);
const SRes res2 = File_Close(&outFile);
if (res != SZ_OK)
break;
if (res2 != SZ_OK)
@@ -550,7 +566,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
WCHAR oldCurDir[MAX_PATH + 2];
oldCurDir[0] = 0;
{
DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir);
const DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir);
if (needLen == 0 || needLen > MAX_PATH)
oldCurDir[0] = 0;
SetCurrentDirectory(workCurDir);

View File

@@ -1,6 +1,9 @@
PROG = 7zS2.sfx
MY_FIXED = 1
CFLAGS = $(CFLAGS) \
-DZ7_EXTRACT_ONLY \
C_OBJS = \
$O\7zAlloc.obj \
$O\7zArcIn.obj \

View File

@@ -1,6 +1,8 @@
PROG = 7zS2con.sfx
MY_FIXED = 1
CFLAGS = $(CFLAGS) -D_CONSOLE
CFLAGS = $(CFLAGS) -D_CONSOLE \
-DZ7_EXTRACT_ONLY \
C_OBJS = \
$O\7zAlloc.obj \