aboutsummaryrefslogtreecommitdiff
path: root/C/Util/7z/7zMain.c
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2024-05-14 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2024-05-15 23:55:04 +0500
commitfc662341e6f85da78ada0e443f6116b978f79f22 (patch)
tree1be1cc402a7a9cbc18d4eeea6b141354c2d559e3 /C/Util/7z/7zMain.c
parent5b39dc76f1bc82f941d5c800ab9f34407a06b53a (diff)
download7zip-24.05.tar.gz
7zip-24.05.tar.bz2
7zip-24.05.zip
24.0524.05
Diffstat (limited to 'C/Util/7z/7zMain.c')
-rw-r--r--C/Util/7z/7zMain.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/C/Util/7z/7zMain.c b/C/Util/7z/7zMain.c
index 547920a..6baf979 100644
--- a/C/Util/7z/7zMain.c
+++ b/C/Util/7z/7zMain.c
@@ -1,20 +1,11 @@
1/* 7zMain.c - Test application for 7z Decoder 1/* 7zMain.c - Test application for 7z Decoder
22023-04-04 : Igor Pavlov : Public domain */ 22024-02-28 : 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 <string.h> 7#include <string.h>
8 8
9#include "../../CpuArch.h"
10
11#include "../../7z.h"
12#include "../../7zAlloc.h"
13#include "../../7zBuf.h"
14#include "../../7zCrc.h"
15#include "../../7zFile.h"
16#include "../../7zVersion.h"
17
18#ifndef USE_WINDOWS_FILE 9#ifndef USE_WINDOWS_FILE
19/* for mkdir */ 10/* for mkdir */
20#ifdef _WIN32 11#ifdef _WIN32
@@ -32,6 +23,15 @@
32#endif 23#endif
33#endif 24#endif
34 25
26#include "../../7zFile.h"
27#include "../../7z.h"
28#include "../../7zAlloc.h"
29#include "../../7zBuf.h"
30#include "../../7zCrc.h"
31#include "../../7zVersion.h"
32
33#include "../../CpuArch.h"
34
35#define kInputBufSize ((size_t)1 << 18) 35#define kInputBufSize ((size_t)1 << 18)
36 36
37static const ISzAlloc g_Alloc = { SzAlloc, SzFree }; 37static const ISzAlloc g_Alloc = { SzAlloc, SzFree };
@@ -168,12 +168,12 @@ static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s
168 #endif 168 #endif
169 ) 169 )
170{ 170{
171 unsigned len = 0; 171 size_t len = 0;
172 for (len = 0; s[len] != 0; len++) {} 172 for (len = 0; s[len] != 0; len++) {}
173 173
174 #ifndef MY_USE_UTF8 174 #ifndef MY_USE_UTF8
175 { 175 {
176 const unsigned size = len * 3 + 100; 176 const size_t size = len * 3 + 100;
177 if (!Buf_EnsureSize(buf, size)) 177 if (!Buf_EnsureSize(buf, size))
178 return SZ_ERROR_MEM; 178 return SZ_ERROR_MEM;
179 { 179 {
@@ -320,21 +320,20 @@ static void UIntToStr_2(char *s, unsigned value)
320// typedef long BOOL; 320// typedef long BOOL;
321typedef int BOOL; 321typedef int BOOL;
322 322
323typedef struct _FILETIME 323typedef struct
324{ 324{
325 DWORD dwLowDateTime; 325 DWORD dwLowDateTime;
326 DWORD dwHighDateTime; 326 DWORD dwHighDateTime;
327} FILETIME; 327} FILETIME;
328 328
329static LONG TIME_GetBias() 329static LONG TIME_GetBias(void)
330{ 330{
331 const 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 const 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 const LONG bias = (int)(mktime(ptm) - utc); 336 return (int)(mktime(ptm) - utc);
337 return bias;
338} 337}
339 338
340#define TICKS_PER_SEC 10000000 339#define TICKS_PER_SEC 10000000
@@ -359,11 +358,11 @@ static BOOL WINAPI FileTimeToLocalFileTime(const FILETIME *fileTime, FILETIME *l
359static const UInt32 kNumTimeQuantumsInSecond = 10000000; 358static const UInt32 kNumTimeQuantumsInSecond = 10000000;
360static const UInt32 kFileTimeStartYear = 1601; 359static const UInt32 kFileTimeStartYear = 1601;
361static const UInt32 kUnixTimeStartYear = 1970; 360static const UInt32 kUnixTimeStartYear = 1970;
362static const UInt64 kUnixTimeOffset =
363 (UInt64)60 * 60 * 24 * (89 + 365 * (kUnixTimeStartYear - kFileTimeStartYear));
364 361
365static Int64 Time_FileTimeToUnixTime64(const FILETIME *ft) 362static Int64 Time_FileTimeToUnixTime64(const FILETIME *ft)
366{ 363{
364 const UInt64 kUnixTimeOffset =
365 (UInt64)60 * 60 * 24 * (89 + 365 * (kUnixTimeStartYear - kFileTimeStartYear));
367 const UInt64 winTime = GET_TIME_64(ft); 366 const UInt64 winTime = GET_TIME_64(ft);
368 return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset; 367 return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset;
369} 368}
@@ -384,8 +383,10 @@ static void FILETIME_To_timespec(const FILETIME *ft, struct MY_ST_TIMESPEC *ts)
384 if (sec2 == sec) 383 if (sec2 == sec)
385 { 384 {
386 ts->tv_sec = sec2; 385 ts->tv_sec = sec2;
387 const UInt64 winTime = GET_TIME_64(ft); 386 {
388 ts->tv_nsec = (long)((winTime % 10000000) * 100); 387 const UInt64 winTime = GET_TIME_64(ft);
388 ts->tv_nsec = (long)((winTime % 10000000) * 100);
389 }
389 return; 390 return;
390 } 391 }
391 } 392 }
@@ -429,7 +430,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s)
429{ 430{
430 unsigned year, mon, hour, min, sec; 431 unsigned year, mon, hour, min, sec;
431 Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 432 Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
432 unsigned t; 433 UInt32 t;
433 UInt32 v; 434 UInt32 v;
434 // UInt64 v64 = nt->Low | ((UInt64)nt->High << 32); 435 // UInt64 v64 = nt->Low | ((UInt64)nt->High << 32);
435 UInt64 v64; 436 UInt64 v64;
@@ -461,7 +462,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s)
461 ms[1] = 29; 462 ms[1] = 29;
462 for (mon = 0;; mon++) 463 for (mon = 0;; mon++)
463 { 464 {
464 const unsigned d = ms[mon]; 465 const UInt32 d = ms[mon];
465 if (v < d) 466 if (v < d)
466 break; 467 break;
467 v -= d; 468 v -= d;