Add unzipfx as extra vendored dependency, for CI builds
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
9dc031d5aa
commit
685e62df24
36 changed files with 30307 additions and 0 deletions
554
deps/unzipfx/win32/nt.c
vendored
Normal file
554
deps/unzipfx/win32/nt.c
vendored
Normal file
|
@ -0,0 +1,554 @@
|
|||
/*
|
||||
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in unzip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
|
||||
Copyright (c) 1996 Scott Field (dedicated to Info-Zip group)
|
||||
|
||||
Module Name:
|
||||
|
||||
nt.c
|
||||
|
||||
Abstract:
|
||||
|
||||
This module implements WinNT security descriptor operations for the
|
||||
Win32 Info-ZIP project. Operation such as setting file security,
|
||||
using/querying local and remote privileges, and queuing of operations
|
||||
is performed here. The contents of this module are only relevant
|
||||
when the code is running on Windows NT, and the target volume supports
|
||||
persistent Acl storage.
|
||||
|
||||
User privileges that allow accessing certain privileged aspects of the
|
||||
security descriptor (such as the Sacl) are only used if the user specified
|
||||
to do so.
|
||||
|
||||
Author:
|
||||
|
||||
Scott Field (sfield@microsoft.com)
|
||||
|
||||
Last revised: 18 Jan 97
|
||||
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define UNZIP_INTERNAL
|
||||
#include <windows.h>
|
||||
#include "../unzip.h"
|
||||
#ifdef __RSXNT__
|
||||
# include "../win32/rsxntwin.h"
|
||||
#endif
|
||||
#include "../win32/nt.h"
|
||||
|
||||
|
||||
#ifdef NTSD_EAS /* This file is only needed for NTSD handling */
|
||||
|
||||
/* Borland C++ does not define FILE_SHARE_DELETE. Others also? */
|
||||
#ifndef FILE_SHARE_DELETE
|
||||
# define FILE_SHARE_DELETE 0x00000004
|
||||
#endif
|
||||
|
||||
/* This macro definition is missing in old versions of MS' winbase.h. */
|
||||
#ifndef InterlockedExchangePointer
|
||||
# define InterlockedExchangePointer(Target, Value) \
|
||||
(PVOID)InterlockedExchange((PLONG)(Target), (LONG)(Value))
|
||||
#endif
|
||||
|
||||
|
||||
/* private prototypes */
|
||||
|
||||
static BOOL Initialize(VOID);
|
||||
static VOID GetRemotePrivilegesSet(CHAR *FileName, PDWORD dwRemotePrivileges);
|
||||
static VOID InitLocalPrivileges(VOID);
|
||||
|
||||
|
||||
volatile BOOL bInitialized = FALSE; /* module level stuff initialized? */
|
||||
HANDLE hInitMutex = NULL; /* prevent multiple initialization */
|
||||
|
||||
BOOL g_bRestorePrivilege = FALSE; /* for local set file security override */
|
||||
BOOL g_bSaclPrivilege = FALSE; /* for local set sacl operations, only when
|
||||
restore privilege not present */
|
||||
|
||||
/* our single cached volume capabilities structure that describes the last
|
||||
volume root we encountered. A single entry like this works well in the
|
||||
zip/unzip scenario for a number of reasons:
|
||||
1. typically one extraction path during unzip.
|
||||
2. typically process one volume at a time during zip, and then move
|
||||
on to the next.
|
||||
3. no cleanup code required and no memory leaks.
|
||||
4. simple code.
|
||||
|
||||
This approach should be reworked to a linked list approach if we expect to
|
||||
be called by many threads which are processing a variety of input/output
|
||||
volumes, since lock contention and stale data may become a bottleneck. */
|
||||
|
||||
VOLUMECAPS g_VolumeCaps;
|
||||
CRITICAL_SECTION VolumeCapsLock;
|
||||
|
||||
|
||||
static BOOL Initialize(VOID)
|
||||
{
|
||||
HANDLE hMutex;
|
||||
HANDLE hOldMutex;
|
||||
|
||||
if (bInitialized) return TRUE;
|
||||
|
||||
hMutex = CreateMutex(NULL, TRUE, NULL);
|
||||
if(hMutex == NULL) return FALSE;
|
||||
|
||||
hOldMutex = (HANDLE)InterlockedExchangePointer((void *)&hInitMutex,
|
||||
hMutex);
|
||||
|
||||
if (hOldMutex != NULL) {
|
||||
/* somebody setup the mutex already */
|
||||
InterlockedExchangePointer((void *)&hInitMutex,
|
||||
hOldMutex);
|
||||
|
||||
CloseHandle(hMutex); /* close new, un-needed mutex */
|
||||
|
||||
/* wait for initialization to complete and return status */
|
||||
WaitForSingleObject(hOldMutex, INFINITE);
|
||||
ReleaseMutex(hOldMutex);
|
||||
|
||||
return bInitialized;
|
||||
}
|
||||
|
||||
if (!bInitialized) {
|
||||
/* initialize module level resources */
|
||||
|
||||
InitializeCriticalSection( &VolumeCapsLock );
|
||||
memset(&g_VolumeCaps, 0, sizeof(VOLUMECAPS));
|
||||
|
||||
InitLocalPrivileges();
|
||||
|
||||
bInitialized = TRUE;
|
||||
}
|
||||
|
||||
InterlockedExchangePointer((void *)&hInitMutex,
|
||||
NULL);
|
||||
|
||||
ReleaseMutex(hMutex); /* release correct mutex */
|
||||
|
||||
CloseHandle(hMutex); /* free the no longer needed handle resource */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL ValidateSecurity(uch *securitydata)
|
||||
{
|
||||
PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR)securitydata;
|
||||
PACL pAcl;
|
||||
PSID pSid;
|
||||
BOOL bAclPresent;
|
||||
BOOL bDefaulted;
|
||||
|
||||
if(!IsWinNT()) return TRUE; /* don't do anything if not on WinNT */
|
||||
|
||||
if(!IsValidSecurityDescriptor(sd)) return FALSE;
|
||||
|
||||
/* verify Dacl integrity */
|
||||
|
||||
if(!GetSecurityDescriptorDacl(sd, &bAclPresent, &pAcl, &bDefaulted))
|
||||
return FALSE;
|
||||
|
||||
if(bAclPresent && pAcl!=NULL) {
|
||||
if(!IsValidAcl(pAcl)) return FALSE;
|
||||
}
|
||||
|
||||
/* verify Sacl integrity */
|
||||
|
||||
if(!GetSecurityDescriptorSacl(sd, &bAclPresent, &pAcl, &bDefaulted))
|
||||
return FALSE;
|
||||
|
||||
if(bAclPresent && pAcl!=NULL) {
|
||||
if(!IsValidAcl(pAcl)) return FALSE;
|
||||
}
|
||||
|
||||
/* verify owner integrity */
|
||||
|
||||
if(!GetSecurityDescriptorOwner(sd, &pSid, &bDefaulted))
|
||||
return FALSE;
|
||||
|
||||
if(pSid != NULL) {
|
||||
if(!IsValidSid(pSid)) return FALSE;
|
||||
}
|
||||
|
||||
/* verify group integrity */
|
||||
|
||||
if(!GetSecurityDescriptorGroup(sd, &pSid, &bDefaulted))
|
||||
return FALSE;
|
||||
|
||||
if(pSid != NULL) {
|
||||
if(!IsValidSid(pSid)) return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static VOID GetRemotePrivilegesSet(char *FileName, PDWORD dwRemotePrivileges)
|
||||
{
|
||||
HANDLE hFile;
|
||||
|
||||
*dwRemotePrivileges = 0;
|
||||
|
||||
/* see if we have the SeRestorePrivilege */
|
||||
|
||||
hFile = CreateFileA(
|
||||
FileName,
|
||||
ACCESS_SYSTEM_SECURITY | WRITE_DAC | WRITE_OWNER | READ_CONTROL,
|
||||
FILE_SHARE_READ | FILE_SHARE_DELETE, /* no sd updating allowed here */
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS,
|
||||
NULL
|
||||
);
|
||||
|
||||
if(hFile != INVALID_HANDLE_VALUE) {
|
||||
/* no remote way to determine SeRestorePrivilege -- just try a
|
||||
read/write to simulate it */
|
||||
SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION |
|
||||
SACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION |
|
||||
GROUP_SECURITY_INFORMATION;
|
||||
PSECURITY_DESCRIPTOR sd;
|
||||
DWORD cbBuf = 0;
|
||||
|
||||
GetKernelObjectSecurity(hFile, si, NULL, cbBuf, &cbBuf);
|
||||
|
||||
if(ERROR_INSUFFICIENT_BUFFER == GetLastError()) {
|
||||
if((sd = HeapAlloc(GetProcessHeap(), 0, cbBuf)) != NULL) {
|
||||
if(GetKernelObjectSecurity(hFile, si, sd, cbBuf, &cbBuf)) {
|
||||
if(SetKernelObjectSecurity(hFile, si, sd))
|
||||
*dwRemotePrivileges |= OVERRIDE_RESTORE;
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, sd);
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(hFile);
|
||||
} else {
|
||||
|
||||
/* see if we have the SeSecurityPrivilege */
|
||||
/* note we don't need this if we have SeRestorePrivilege */
|
||||
|
||||
hFile = CreateFileA(
|
||||
FileName,
|
||||
ACCESS_SYSTEM_SECURITY,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, /* max */
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
if(hFile != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(hFile);
|
||||
*dwRemotePrivileges |= OVERRIDE_SACL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL GetVolumeCaps(
|
||||
char *rootpath, /* filepath, or NULL */
|
||||
char *name, /* filename associated with rootpath */
|
||||
PVOLUMECAPS VolumeCaps /* result structure describing capabilities */
|
||||
)
|
||||
{
|
||||
char TempRootPath[MAX_PATH + 1];
|
||||
DWORD cchTempRootPath = 0;
|
||||
BOOL bSuccess = TRUE; /* assume success until told otherwise */
|
||||
|
||||
if(!bInitialized) if(!Initialize()) return FALSE;
|
||||
|
||||
/* process the input path to produce a consistent path suitable for
|
||||
compare operations and also suitable for certain picky Win32 API
|
||||
that don't like forward slashes */
|
||||
|
||||
if(rootpath != NULL && rootpath[0] != '\0') {
|
||||
DWORD i;
|
||||
|
||||
cchTempRootPath = lstrlenA(rootpath);
|
||||
if(cchTempRootPath > MAX_PATH) return FALSE;
|
||||
|
||||
/* copy input, converting forward slashes to back slashes as we go */
|
||||
|
||||
for(i = 0 ; i <= cchTempRootPath ; i++) {
|
||||
if(rootpath[i] == '/') TempRootPath[i] = '\\';
|
||||
else TempRootPath[i] = rootpath[i];
|
||||
}
|
||||
|
||||
/* check for UNC and Null terminate or append trailing \ as
|
||||
appropriate */
|
||||
|
||||
/* possible valid UNCs we are passed follow:
|
||||
\\machine\foo\bar (path is \\machine\foo\)
|
||||
\\machine\foo (path is \\machine\foo\)
|
||||
\\machine\foo\
|
||||
\\.\c$\ (FIXFIX: Win32API doesn't like this - GetComputerName())
|
||||
LATERLATER: handling mounted DFS drives in the future will require
|
||||
slightly different logic which isn't available today.
|
||||
This is required because directories can point at
|
||||
different servers which have differing capabilities.
|
||||
*/
|
||||
|
||||
if(TempRootPath[0] == '\\' && TempRootPath[1] == '\\') {
|
||||
DWORD slash = 0;
|
||||
|
||||
for(i = 2 ; i < cchTempRootPath ; i++) {
|
||||
if(TempRootPath[i] == '\\') {
|
||||
slash++;
|
||||
|
||||
if(slash == 2) {
|
||||
i++;
|
||||
TempRootPath[i] = '\0';
|
||||
cchTempRootPath = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if there was only one slash found, just tack another onto the
|
||||
end */
|
||||
|
||||
if(slash == 1 && TempRootPath[cchTempRootPath] != '\\') {
|
||||
TempRootPath[cchTempRootPath] = TempRootPath[0]; /* '\\' */
|
||||
TempRootPath[cchTempRootPath+1] = '\0';
|
||||
cchTempRootPath++;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if(TempRootPath[1] == ':') {
|
||||
|
||||
/* drive letter specified, truncate to root */
|
||||
TempRootPath[2] = '\\';
|
||||
TempRootPath[3] = '\0';
|
||||
cchTempRootPath = 3;
|
||||
} else {
|
||||
|
||||
/* must be file on current drive */
|
||||
TempRootPath[0] = '\0';
|
||||
cchTempRootPath = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} /* if path != NULL */
|
||||
|
||||
/* grab lock protecting cached entry */
|
||||
EnterCriticalSection( &VolumeCapsLock );
|
||||
|
||||
if(!g_VolumeCaps.bValid ||
|
||||
lstrcmpiA(g_VolumeCaps.RootPath, TempRootPath) != 0)
|
||||
{
|
||||
|
||||
/* no match found, build up new entry */
|
||||
|
||||
DWORD dwFileSystemFlags;
|
||||
DWORD dwRemotePrivileges = 0;
|
||||
BOOL bRemote = FALSE;
|
||||
|
||||
/* release lock during expensive operations */
|
||||
LeaveCriticalSection( &VolumeCapsLock );
|
||||
|
||||
bSuccess = GetVolumeInformationA(
|
||||
(TempRootPath[0] == '\0') ? NULL : TempRootPath,
|
||||
NULL, 0,
|
||||
NULL, NULL,
|
||||
&dwFileSystemFlags,
|
||||
NULL, 0);
|
||||
|
||||
|
||||
/* only if target volume supports Acls, and we were told to use
|
||||
privileges do we need to go out and test for the remote case */
|
||||
|
||||
if(bSuccess && (dwFileSystemFlags & FS_PERSISTENT_ACLS) &&
|
||||
VolumeCaps->bUsePrivileges)
|
||||
{
|
||||
if(GetDriveTypeA( (TempRootPath[0] == '\0') ? NULL : TempRootPath )
|
||||
== DRIVE_REMOTE)
|
||||
{
|
||||
bRemote = TRUE;
|
||||
|
||||
/* make a determination about our remote capabilities */
|
||||
|
||||
GetRemotePrivilegesSet(name, &dwRemotePrivileges);
|
||||
}
|
||||
}
|
||||
|
||||
/* always take the lock again, since we release it below */
|
||||
EnterCriticalSection( &VolumeCapsLock );
|
||||
|
||||
/* replace the existing data if successful */
|
||||
if(bSuccess) {
|
||||
|
||||
lstrcpynA(g_VolumeCaps.RootPath, TempRootPath, cchTempRootPath+1);
|
||||
g_VolumeCaps.dwFileSystemFlags = dwFileSystemFlags;
|
||||
g_VolumeCaps.bRemote = bRemote;
|
||||
g_VolumeCaps.dwRemotePrivileges = dwRemotePrivileges;
|
||||
g_VolumeCaps.bValid = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(bSuccess) {
|
||||
/* copy input elements */
|
||||
g_VolumeCaps.bUsePrivileges = VolumeCaps->bUsePrivileges;
|
||||
g_VolumeCaps.dwFileAttributes = VolumeCaps->dwFileAttributes;
|
||||
|
||||
/* give caller results */
|
||||
memcpy(VolumeCaps, &g_VolumeCaps, sizeof(VOLUMECAPS));
|
||||
} else {
|
||||
g_VolumeCaps.bValid = FALSE;
|
||||
}
|
||||
|
||||
LeaveCriticalSection( &VolumeCapsLock ); /* release lock */
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
|
||||
BOOL SecuritySet(char *resource, PVOLUMECAPS VolumeCaps, uch *securitydata)
|
||||
{
|
||||
HANDLE hFile;
|
||||
DWORD dwDesiredAccess = 0;
|
||||
DWORD dwFlags = 0;
|
||||
PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR)securitydata;
|
||||
SECURITY_DESCRIPTOR_CONTROL sdc;
|
||||
SECURITY_INFORMATION RequestedInfo = 0;
|
||||
DWORD dwRev;
|
||||
BOOL bRestorePrivilege = FALSE;
|
||||
BOOL bSaclPrivilege = FALSE;
|
||||
BOOL bSuccess;
|
||||
|
||||
if(!bInitialized) if(!Initialize()) return FALSE;
|
||||
|
||||
/* defer directory processing */
|
||||
|
||||
if(VolumeCaps->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
/* opening a directory requires FILE_FLAG_BACKUP_SEMANTICS */
|
||||
dwFlags |= FILE_FLAG_BACKUP_SEMANTICS;
|
||||
}
|
||||
|
||||
/* evaluate the input security descriptor and act accordingly */
|
||||
|
||||
if(!IsValidSecurityDescriptor(sd))
|
||||
return FALSE;
|
||||
|
||||
if(!GetSecurityDescriptorControl(sd, &sdc, &dwRev))
|
||||
return FALSE;
|
||||
|
||||
/* setup privilege usage based on if told we can use privileges, and if so,
|
||||
what privileges we have */
|
||||
|
||||
if(VolumeCaps->bUsePrivileges) {
|
||||
if(VolumeCaps->bRemote) {
|
||||
/* use remotely determined privileges */
|
||||
if(VolumeCaps->dwRemotePrivileges & OVERRIDE_RESTORE)
|
||||
bRestorePrivilege = TRUE;
|
||||
|
||||
if(VolumeCaps->dwRemotePrivileges & OVERRIDE_SACL)
|
||||
bSaclPrivilege = TRUE;
|
||||
|
||||
} else {
|
||||
/* use local privileges */
|
||||
bRestorePrivilege = g_bRestorePrivilege;
|
||||
bSaclPrivilege = g_bSaclPrivilege;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* if a Dacl is present write Dacl out */
|
||||
/* if we have SeRestorePrivilege, write owner and group info out */
|
||||
|
||||
if(sdc & SE_DACL_PRESENT) {
|
||||
dwDesiredAccess |= WRITE_DAC;
|
||||
RequestedInfo |= DACL_SECURITY_INFORMATION;
|
||||
|
||||
if(bRestorePrivilege) {
|
||||
dwDesiredAccess |= WRITE_OWNER;
|
||||
RequestedInfo |= (OWNER_SECURITY_INFORMATION |
|
||||
GROUP_SECURITY_INFORMATION);
|
||||
}
|
||||
}
|
||||
|
||||
/* if a Sacl is present and we have either SeRestorePrivilege or
|
||||
SeSystemSecurityPrivilege try to write Sacl out */
|
||||
|
||||
if((sdc & SE_SACL_PRESENT) && (bRestorePrivilege || bSaclPrivilege)) {
|
||||
dwDesiredAccess |= ACCESS_SYSTEM_SECURITY;
|
||||
RequestedInfo |= SACL_SECURITY_INFORMATION;
|
||||
}
|
||||
|
||||
if(RequestedInfo == 0) /* nothing to do */
|
||||
return FALSE;
|
||||
|
||||
if(bRestorePrivilege)
|
||||
dwFlags |= FILE_FLAG_BACKUP_SEMANTICS;
|
||||
|
||||
hFile = CreateFileA(
|
||||
resource,
|
||||
dwDesiredAccess,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,/* max sharing */
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
dwFlags,
|
||||
NULL
|
||||
);
|
||||
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
|
||||
bSuccess = SetKernelObjectSecurity(hFile, RequestedInfo, sd);
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
static VOID InitLocalPrivileges(VOID)
|
||||
{
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES tp;
|
||||
|
||||
/* try to enable some interesting privileges that give us the ability
|
||||
to get some security information that we normally cannot.
|
||||
|
||||
note that enabling privileges is only relevant on the local machine;
|
||||
when accessing files that are on a remote machine, any privileges
|
||||
that are present on the remote machine get enabled by default. */
|
||||
|
||||
if(!OpenProcessToken(GetCurrentProcess(),
|
||||
TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken))
|
||||
return;
|
||||
|
||||
tp.PrivilegeCount = 1;
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
if(LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tp.Privileges[0].Luid)) {
|
||||
|
||||
/* try to enable SeRestorePrivilege; if this succeeds, we can write
|
||||
all aspects of the security descriptor */
|
||||
|
||||
if(AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL) &&
|
||||
GetLastError() == ERROR_SUCCESS) g_bRestorePrivilege = TRUE;
|
||||
|
||||
}
|
||||
|
||||
/* try to enable SeSystemSecurityPrivilege, if SeRestorePrivilege not
|
||||
present; if this succeeds, we can write the Sacl */
|
||||
|
||||
if(!g_bRestorePrivilege &&
|
||||
LookupPrivilegeValue(NULL, SE_SECURITY_NAME, &tp.Privileges[0].Luid)) {
|
||||
|
||||
if(AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL) &&
|
||||
GetLastError() == ERROR_SUCCESS) g_bSaclPrivilege = TRUE;
|
||||
}
|
||||
|
||||
CloseHandle(hToken);
|
||||
}
|
||||
#endif /* NTSD_EAS */
|
33
deps/unzipfx/win32/nt.h
vendored
Normal file
33
deps/unzipfx/win32/nt.h
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in unzip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* nt.h: central header for EF_NTSD "SD" extra field */
|
||||
|
||||
#ifndef _NT_H
|
||||
#define _NT_H
|
||||
|
||||
#define NTSD_BUFFERSIZE (1024) /* threshold to cause malloc() */
|
||||
#define OVERRIDE_BACKUP 1 /* we have SeBackupPrivilege on remote */
|
||||
#define OVERRIDE_RESTORE 2 /* we have SeRestorePrivilege on remote */
|
||||
#define OVERRIDE_SACL 4 /* we have SeSystemSecurityPrivilege on remote */
|
||||
|
||||
typedef struct {
|
||||
BOOL bValid; /* are our contents valid? */
|
||||
BOOL bUsePrivileges; /* use privilege overrides? */
|
||||
DWORD dwFileSystemFlags; /* describes target file system */
|
||||
BOOL bRemote; /* is volume remote? */
|
||||
DWORD dwRemotePrivileges; /* relevant only on remote volumes */
|
||||
DWORD dwFileAttributes;
|
||||
char RootPath[MAX_PATH+1]; /* path to network / filesystem */
|
||||
} VOLUMECAPS, *PVOLUMECAPS, *LPVOLUMECAPS;
|
||||
|
||||
BOOL SecuritySet(char *resource, PVOLUMECAPS VolumeCaps, uch *securitydata);
|
||||
BOOL GetVolumeCaps(char *rootpath, char *name, PVOLUMECAPS VolumeCaps);
|
||||
BOOL ValidateSecurity(uch *securitydata);
|
||||
|
||||
#endif /* _NT_H */
|
571
deps/unzipfx/win32/w32cfg.h
vendored
Normal file
571
deps/unzipfx/win32/w32cfg.h
vendored
Normal file
|
@ -0,0 +1,571 @@
|
|||
/*
|
||||
Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2009-Jan-02 or later
|
||||
(the contents of which are also included in unzip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
Win32 specific configuration section:
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __w32cfg_h
|
||||
#define __w32cfg_h
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# define USE_STRM_INPUT
|
||||
#endif
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
/* We treat the file system underneath the Cygwin Unix emulator environment
|
||||
* as "native VFAT/NTFS" and use the WIN32 API for its special attributes...
|
||||
*/
|
||||
# ifdef UNIX
|
||||
# undef UNIX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && !defined(MSC))
|
||||
# define MSC
|
||||
#endif
|
||||
|
||||
/* enable multibyte character set support by default */
|
||||
#if (!defined(_MBCS) && !defined(NO_MBCS))
|
||||
# define _MBCS
|
||||
#endif
|
||||
#if (defined(_MBCS) && defined(NO_MBCS))
|
||||
# undef _MBCS
|
||||
#endif
|
||||
#if (defined(__CYGWIN__) && defined(_MBCS))
|
||||
# undef _MBCS /* Cygwin RTL lacks support for __mb_cur_max */
|
||||
#endif
|
||||
#if (defined(__DJGPP__) && !defined(__EMX__) && defined(_MBCS))
|
||||
# undef _MBCS /* __mb_cur_max missing for RSXNTdj 1.6 beta */
|
||||
#endif
|
||||
|
||||
#include <sys/types.h> /* off_t, time_t, dev_t, ... */
|
||||
#include <sys/stat.h>
|
||||
#include <io.h> /* read(), open(), etc. */
|
||||
#include <time.h>
|
||||
#if ((defined(__RSXNT__) || defined(__EMX__)) && !defined(tzset))
|
||||
# define tzset _tzset
|
||||
#endif
|
||||
#if (defined(__LCC__) && !defined(tzset))
|
||||
# define tzset _tzset
|
||||
#endif
|
||||
#ifdef W32_USE_IZ_TIMEZONE
|
||||
# ifdef __BORLANDC__
|
||||
# define tzname tzname
|
||||
# define IZTZ_DEFINESTDGLOBALS
|
||||
# endif
|
||||
# ifdef __WATCOMC__
|
||||
# define IZTZ_DEFINESTDGLOBALS
|
||||
# endif
|
||||
# ifndef tzset
|
||||
# define tzset _tzset
|
||||
# endif
|
||||
# ifndef timezone
|
||||
# define timezone _timezone
|
||||
# endif
|
||||
# ifndef daylight
|
||||
# define daylight _daylight
|
||||
# endif
|
||||
# ifndef tzname
|
||||
# define tzname _tzname
|
||||
# endif
|
||||
# if (!defined(NEED__ISINDST) && !defined(__BORLANDC__))
|
||||
# define NEED__ISINDST
|
||||
# endif
|
||||
# ifdef IZTZ_GETLOCALETZINFO
|
||||
# undef IZTZ_GETLOCALETZINFO
|
||||
# endif
|
||||
# define IZTZ_GETLOCALETZINFO GetPlatformLocalTimezone
|
||||
#endif /* W32_USE_IZ_TIMEZONE */
|
||||
#include <memory.h>
|
||||
#if (!defined(__RSXNT__) && !defined(__CYGWIN__))
|
||||
# include <direct.h> /* mkdir() */
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#ifdef __CYGWIN__
|
||||
# include <unistd.h>
|
||||
extern int setmode(int, int); /* this is missing in <fcntl.h> */
|
||||
#endif
|
||||
#if (defined(MSC) || defined(__WATCOMC__) || defined(__MINGW32__))
|
||||
# include <sys/utime.h>
|
||||
#else
|
||||
# include <utime.h>
|
||||
#endif
|
||||
#define GOT_UTIMBUF
|
||||
|
||||
#ifdef _MBCS
|
||||
# if (!defined(__EMX__) && !defined(__DJGPP__) && !defined(__CYGWIN__))
|
||||
# if (!defined(__MINGW32__) || defined(__MSVCRT__))
|
||||
# include <stdlib.h>
|
||||
# include <mbstring.h>
|
||||
/* for MSC (and compatible compilers), use routines supplied by RTL */
|
||||
# define CLEN(ptr) _mbclen((const uch *)(ptr))
|
||||
# define PREINCSTR(ptr) (ptr = (char *)_mbsinc((const uch *)(ptr)))
|
||||
# define MBSCHR(str, c) (char *)_mbschr((const uch *)(str), (c))
|
||||
# define MBSRCHR(str, c) (char *)_mbsrchr((const uch *)(str), (c))
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__MINGW32__) && !defined(MB_CUR_MAX))
|
||||
# ifdef __MSVCRT__
|
||||
extern int *__p___mb_cur_max(void);
|
||||
# define MB_CUR_MAX (*__p___mb_cur_max())
|
||||
# else
|
||||
extern int *_imp____mb_cur_max_dll;
|
||||
# define MB_CUR_MAX (*_imp____mb_cur_max_dll)
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__LCC__) && !defined(MB_CUR_MAX))
|
||||
extern int *_imp____mb_cur_max;
|
||||
# define MB_CUR_MAX (*_imp____mb_cur_max)
|
||||
# endif
|
||||
# if (defined(__DJGPP__) && !defined(__EMX__) && !defined(MB_CUR_MAX))
|
||||
extern int *_imp____mb_cur_max;
|
||||
# define MB_CUR_MAX (*_imp____mb_cur_max)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* for UnZip, the "basic" part of the win32 api is sufficient */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#if defined(__FILEIO_C)
|
||||
# ifndef __CYGWIN__
|
||||
# include <conio.h>
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# ifdef __RSXNT__
|
||||
# include "../win32/rsxntwin.h"
|
||||
# endif
|
||||
# ifndef TIME_ZONE_ID_INVALID
|
||||
# define TIME_ZONE_ID_INVALID (DWORD)0xFFFFFFFFL
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(__ENVARGS_C) || defined(__EXTRACT_C) || defined(__UNZIP_C) || \
|
||||
defined(ZCRYPT_INTERNAL))
|
||||
# include <windows.h>
|
||||
# ifdef __RSXNT__
|
||||
# include "../win32/rsxntwin.h"
|
||||
# endif
|
||||
# ifndef TIME_ZONE_ID_INVALID
|
||||
# define TIME_ZONE_ID_INVALID (DWORD)0xFFFFFFFFL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef Cdecl
|
||||
# define Cdecl __cdecl
|
||||
#endif
|
||||
|
||||
/* the following definitions are considered as "obsolete" by Microsoft and
|
||||
* might be missing in some versions of <windows.h>
|
||||
*/
|
||||
#ifndef AnsiToOem
|
||||
# define AnsiToOem CharToOemA
|
||||
#endif
|
||||
#ifndef OemToAnsi
|
||||
# define OemToAnsi OemToCharA
|
||||
#endif
|
||||
|
||||
#define DIR_END '\\' /* OS uses '\\' as directory separator */
|
||||
#define DIR_END2 '/' /* also check for '/' (RTL may convert) */
|
||||
#ifdef DATE_FORMAT
|
||||
# undef DATE_FORMAT
|
||||
#endif
|
||||
#define DATE_FORMAT dateformat()
|
||||
#ifdef DATE_SEPCHAR
|
||||
# undef DATE_SEPCHAR
|
||||
#endif
|
||||
#define DATE_SEPCHAR dateseparator()
|
||||
#define lenEOL 2
|
||||
#define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
|
||||
|
||||
#if (defined(__RSXNT__) && !defined(HAVE_MKTIME))
|
||||
# define HAVE_MKTIME /* use mktime() in time conversion routines */
|
||||
#endif
|
||||
#if (defined(MSC) && !defined(HAVE_MKTIME))
|
||||
# define HAVE_MKTIME /* use mktime() in time conversion routines */
|
||||
#endif
|
||||
#if (defined(__CYGWIN__) && defined(HAVE_MKTIME))
|
||||
# undef HAVE_MKTIME /* Cygnus' mktime() implementation is buggy */
|
||||
#endif
|
||||
#if (defined(W32_USE_IZ_TIMEZONE) && !defined(HAVE_MKTIME))
|
||||
# define HAVE_MKTIME /* use mktime() in time conversion routines */
|
||||
#endif
|
||||
#if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME))
|
||||
# define USE_EF_UT_TIME
|
||||
#endif
|
||||
#if (!defined(NO_DIR_ATTRIB) && !defined(SET_DIR_ATTRIB))
|
||||
# define SET_DIR_ATTRIB
|
||||
#endif
|
||||
#if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
|
||||
# define TIMESTAMP
|
||||
#endif
|
||||
#if (!defined(NO_NTSD_EAS) && !defined(NTSD_EAS))
|
||||
# define NTSD_EAS /* enable NTSD support unless explicitly suppressed */
|
||||
#endif
|
||||
#if (defined(NTSD_EAS) && !defined(RESTORE_ACL))
|
||||
# define RESTORE_ACL /* "restore ACLs" only needed when NTSD_EAS active */
|
||||
#endif
|
||||
#if (!defined(NO_UNICODE_SUPPORT) && !defined(UNICODE_SUPPORT))
|
||||
# define UNICODE_SUPPORT /* enable UTF-8 filename support by default */
|
||||
#endif
|
||||
#if (defined(UNICODE_SUPPORT) && !defined(UNICODE_WCHAR))
|
||||
# define UNICODE_WCHAR /* wchar_t is UTF-16 encoded on WIN32 */
|
||||
#endif
|
||||
#ifdef UTF8_MAYBE_NATIVE
|
||||
# undef UTF8_MAYBE_NATIVE /* UTF-8 cannot be system charset on WIN32 */
|
||||
#endif
|
||||
|
||||
/* The following compiler systems provide or use a runtime library with a
|
||||
* locale-aware isprint() implementation. For these systems, the "enhanced"
|
||||
* unprintable charcode detection in fnfilter() gets enabled.
|
||||
*/
|
||||
#if (!defined(HAVE_WORKING_ISPRINT) && !defined(NO_WORKING_ISPRINT))
|
||||
# if defined(MSC) || defined(__BORLANDC__)
|
||||
# define HAVE_WORKING_ISPRINT
|
||||
# endif
|
||||
# if defined(__MINGW32__) && defined(__MSVCRT__)
|
||||
# define HAVE_WORKING_ISPRINT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* WIN32 runs solely on little-endian processors; enable support
|
||||
* for the 32-bit optimized CRC-32 C code by default.
|
||||
*/
|
||||
#ifdef IZ_CRC_BE_OPTIMIZ
|
||||
# undef IZ_CRC_BE_OPTIMIZ
|
||||
#endif
|
||||
#if !defined(IZ_CRC_LE_OPTIMIZ) && !defined(NO_CRC_OPTIMIZ)
|
||||
# define IZ_CRC_LE_OPTIMIZ
|
||||
#endif
|
||||
|
||||
/* handlers for OEM <--> ANSI string conversions */
|
||||
#ifdef __RSXNT__
|
||||
/* RSXNT uses OEM coded strings in functions supplied by C RTL */
|
||||
# ifdef CRTL_CP_IS_ISO
|
||||
# undef CRTL_CP_IS_ISO
|
||||
# endif
|
||||
# ifndef CRTL_CP_IS_OEM
|
||||
# define CRTL_CP_IS_OEM
|
||||
# endif
|
||||
#else
|
||||
/* "real" native WIN32 compilers use ANSI coded strings in C RTL calls */
|
||||
# ifndef CRTL_CP_IS_ISO
|
||||
# define CRTL_CP_IS_ISO
|
||||
# endif
|
||||
# ifdef CRTL_CP_IS_OEM
|
||||
# undef CRTL_CP_IS_OEM
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef CRTL_CP_IS_ISO
|
||||
/* C RTL's file system support assumes ANSI coded strings */
|
||||
# define ISO_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
|
||||
# define OEM_TO_INTERN(src, dst) OemToAnsi(src, dst)
|
||||
# define INTERN_TO_ISO(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
|
||||
# define INTERN_TO_OEM(src, dst) AnsiToOem(src, dst)
|
||||
#endif /* CRTL_CP_IS_ISO */
|
||||
#ifdef CRTL_CP_IS_OEM
|
||||
/* C RTL's file system support assumes OEM coded strings */
|
||||
# define ISO_TO_INTERN(src, dst) AnsiToOem(src, dst)
|
||||
# define OEM_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
|
||||
# define INTERN_TO_ISO(src, dst) OemToAnsi(src, dst)
|
||||
# define INTERN_TO_OEM(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
|
||||
#endif /* CRTL_CP_IS_OEM */
|
||||
#define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1)
|
||||
#define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1)
|
||||
#ifndef WINDLL
|
||||
/* Despite best intentions, for the command-line version UzpPassword()
|
||||
* could return either character set, depending on whether running under
|
||||
* Win95 (DOS-session) or WinNT (native WinNT command interpreter)! */
|
||||
# define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
|
||||
# define STR_TO_CP3(dst, src) (OemToAnsi(src, dst), dst)
|
||||
#else
|
||||
/* The WINDLL front end is known to supply ISO/ANSI-coded passwords! */
|
||||
# define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
|
||||
#endif
|
||||
/* dummy defines to disable these functions, they are not needed */
|
||||
#define STR_TO_OEM
|
||||
#define STR_TO_ISO
|
||||
|
||||
/* Static variables that we have to add to Uz_Globs: */
|
||||
#define SYSTEM_SPECIFIC_GLOBALS \
|
||||
int created_dir, renamed_fullpath, fnlen;\
|
||||
unsigned nLabelDrive;\
|
||||
char lastRootPath[4];\
|
||||
int lastVolOldFAT, lastVolLocTim;\
|
||||
char *rootpath, *buildpathHPFS, *buildpathFAT, *endHPFS, *endFAT;\
|
||||
ZCONST char *wildname;\
|
||||
char *dirname, matchname[FILNAMSIZ];\
|
||||
int rootlen, have_dirname, dirnamelen, notfirstcall;\
|
||||
zvoid *wild_dir;
|
||||
|
||||
/* created_dir, renamed_fullpath, fnlen, and nLabelDrive are used by */
|
||||
/* both mapname() and checkdir(). */
|
||||
/* lastRootPath, lastVolOldFAT and lastVolLocTim are used by */
|
||||
/* IsVolumeOldFAT() and NTQueryVolInfo(). */
|
||||
/* rootlen, rootpath, buildpathHPFS, buildpathFAT, endHPFS, and endFAT */
|
||||
/* are used by checkdir(). */
|
||||
/* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
|
||||
/* and notfirstcall are used by do_wild(). */
|
||||
|
||||
/* This replacement for C-RTL-supplied getch() (or similar) functionality
|
||||
* avoids leaving unabsorbed LFs in the keyboard buffer under Windows95,
|
||||
* and supports the <ALT>+[0]<digit><digit><digit> feature.
|
||||
*/
|
||||
int getch_win32 OF((void));
|
||||
|
||||
/* Up to now, all versions of Microsoft C runtime libraries lack the support
|
||||
* for customized (non-US) switching rules between daylight saving time and
|
||||
* standard time in the TZ environment variable string.
|
||||
* But non-US timezone rules are correctly supported when timezone information
|
||||
* is read from the OS system settings in the Win32 registry.
|
||||
* The following work-around deletes any TZ environment setting from
|
||||
* the process environment. This results in a fallback of the RTL time
|
||||
* handling code to the (correctly interpretable) OS system settings, read
|
||||
* from the registry.
|
||||
*/
|
||||
#ifdef USE_EF_UT_TIME
|
||||
# if (defined(__WATCOMC__) || defined(__CYGWIN__) || \
|
||||
defined(W32_USE_IZ_TIMEZONE))
|
||||
# define iz_w32_prepareTZenv()
|
||||
# else
|
||||
# define iz_w32_prepareTZenv() putenv("TZ=")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This patch of stat() is useful for at least two compilers. It is */
|
||||
/* difficult to take a stat() of a root directory under Windows95, so */
|
||||
/* zstat_win32() detects that case and fills in suitable values. */
|
||||
#ifndef __RSXNT__
|
||||
# ifndef W32_STATROOT_FIX
|
||||
# define W32_STATROOT_FIX
|
||||
# endif
|
||||
#endif /* !__RSXNT__ */
|
||||
|
||||
#define W32_STAT_BANDAID
|
||||
#if defined(REENTRANT)
|
||||
# define __W32STAT_GLOBALS__ Uz_Globs *pG,
|
||||
# define __W32STAT_G__ pG,
|
||||
#else
|
||||
# define __W32STAT_GLOBALS__
|
||||
# define __W32STAT_G__
|
||||
#endif
|
||||
#ifdef SSTAT
|
||||
# undef SSTAT
|
||||
#endif
|
||||
#ifdef WILD_STAT_BUG
|
||||
# define SSTAT(path, pbuf) (iswild(path) || zstat_win32(__W32STAT_G__ path, pbuf))
|
||||
#else
|
||||
# define SSTAT(path, pbuf) zstat_win32(__W32STAT_G__ path, pbuf)
|
||||
#endif
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
# ifdef __386__
|
||||
# ifndef WATCOMC_386
|
||||
# define WATCOMC_386
|
||||
# endif
|
||||
# define __32BIT__
|
||||
# undef far
|
||||
# define far
|
||||
# undef near
|
||||
# define near
|
||||
# undef Cdecl
|
||||
# define Cdecl
|
||||
|
||||
/* gaah -- Watcom's docs claim that _get_osfhandle exists, but it doesn't. */
|
||||
# define _get_osfhandle _os_handle
|
||||
|
||||
/* Get asm routines to link properly without using "__cdecl": */
|
||||
# ifndef USE_ZLIB
|
||||
# pragma aux crc32 "_*" parm caller [] value [eax] modify [eax]
|
||||
# pragma aux get_crc_table "_*" parm caller [] value [eax] \
|
||||
modify [eax ecx edx]
|
||||
# endif /* !USE_ZLIB */
|
||||
# endif /* __386__ */
|
||||
#endif /* __WATCOMC__ */
|
||||
|
||||
#define SCREENWIDTH 80
|
||||
#define SCREENSIZE(scrrows, scrcols) screensize(scrrows, scrcols)
|
||||
int screensize(int *tt_rows, int *tt_cols);
|
||||
|
||||
/* on the DOS or NT console screen, line-wraps are always enabled */
|
||||
#define SCREENLWRAP 1
|
||||
#define TABSIZE 8
|
||||
|
||||
|
||||
/* 64-bit-Integers & Large File Support
|
||||
* (pasted here from Zip 3b, osdep.h - Myles Bennett 7-jun-2004)
|
||||
* (updated from Zip 3.0d - Ed Gordon 6-oct-2004)
|
||||
*
|
||||
* If this is set it is assumed that the port
|
||||
* supports 64-bit file calls. The types are
|
||||
* defined here. Any local implementations are
|
||||
* in w32i64.c and the prototypes for the calls are
|
||||
* in unzip.h. Note that a port must support
|
||||
* these calls fully or should not set
|
||||
* LARGE_FILE_SUPPORT.
|
||||
*/
|
||||
|
||||
/* Automatically set ZIP64_SUPPORT if supported */
|
||||
|
||||
#ifndef NO_ZIP64_SUPPORT
|
||||
# ifndef ZIP64_SUPPORT
|
||||
# if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
|
||||
# define ZIP64_SUPPORT
|
||||
# elif defined(__LCC__)
|
||||
/* LCC links against crtdll.dll -> no support of 64-bit offsets :( */
|
||||
# elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100))
|
||||
# define ZIP64_SUPPORT
|
||||
# elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520))
|
||||
/* Borland C RTL lacks any support to get/set 64-bit file pointer :( */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef ZIP64_SUPPORT
|
||||
/* base type for file offsets and file sizes */
|
||||
# if (defined(__GNUC__) || defined(ULONG_LONG_MAX))
|
||||
typedef long long zoff_t;
|
||||
# else
|
||||
/* all other compilers use this as intrinsic 64-bit type */
|
||||
typedef __int64 zoff_t;
|
||||
# endif
|
||||
# define ZOFF_T_DEFINED
|
||||
|
||||
/* user-defined types and format strings for 64-bit numbers and
|
||||
* file pointer functions (these depend on the rtl library and library
|
||||
* headers used; they are NOT compiler-specific)
|
||||
*/
|
||||
# if defined(_MSC_VER) || defined(__MINGW32__) || defined(__LCC__)
|
||||
/* MS C and VC, MinGW32, lcc32 */
|
||||
/* these systems use the Microsoft C RTL */
|
||||
|
||||
/* 64-bit stat struct */
|
||||
typedef struct _stati64 z_stat;
|
||||
# define Z_STAT_DEFINED
|
||||
|
||||
# ifdef __LCC__
|
||||
/* The LCC headers lack these declarations of MSC rtl functions in
|
||||
sys/stat.h. */
|
||||
struct _stati64 {
|
||||
unsigned int st_dev;
|
||||
unsigned short st_ino;
|
||||
unsigned short st_mode;
|
||||
short st_nlink;
|
||||
short st_uid;
|
||||
short st_gid;
|
||||
unsigned int st_rdev;
|
||||
__int64 st_size;
|
||||
time_t st_atime;
|
||||
time_t st_mtime;
|
||||
time_t st_ctime;
|
||||
};
|
||||
int _stati64(const char *, struct _stati64 *);
|
||||
int _fstati64(int, struct _stati64 *);
|
||||
__int64 _lseeki64(int, __int64, int);
|
||||
# endif /* __LCC__ */
|
||||
|
||||
/* printf format size prefix for zoff_t values */
|
||||
# define FZOFFT_FMT "I64"
|
||||
# define FZOFFT_HEX_WID_VALUE "16"
|
||||
|
||||
# define SHORTHDRSTATS "%9I64u %02u%c%02u%c%02u %02u:%02u %c"
|
||||
# define SHORTFILETRAILER " -------- -------\n%9I64u %9lu file%s\n"
|
||||
|
||||
# elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520))
|
||||
/* Borland C 5.2 or newer */
|
||||
|
||||
/* 64-bit stat struct */
|
||||
typedef struct stati64 z_stat;
|
||||
# define Z_STAT_DEFINED
|
||||
|
||||
/* Borland C does not provide a 64-bit-capable _lseeki64(), so we
|
||||
need to use the stdio.h stream functions instead. */
|
||||
# ifndef USE_STRM_INPUT
|
||||
# define USE_STRM_INPUT
|
||||
# endif
|
||||
|
||||
/* printf format size prefix for zoff_t values */
|
||||
# define FZOFFT_FMT "L"
|
||||
# define FZOFFT_HEX_WID_VALUE "16"
|
||||
|
||||
# define SHORTHDRSTATS "%9Lu %02u%c%02u%c%02u %02u:%02u %c"
|
||||
# define SHORTFILETRAILER " -------- -------\n%9Lu %9lu file%s\n"
|
||||
|
||||
# elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100))
|
||||
/* WATCOM C */
|
||||
|
||||
/* 64-bit stat struct */
|
||||
typedef struct _stati64 z_stat;
|
||||
# define Z_STAT_DEFINED
|
||||
|
||||
/* printf format size prefix for zoff_t values */
|
||||
# define FZOFFT_FMT "ll"
|
||||
# define FZOFFT_HEX_WID_VALUE "16"
|
||||
|
||||
# define SHORTHDRSTATS "%9llu %02u%c%02u%c%02u %02u:%02u %c"
|
||||
# define SHORTFILETRAILER " -------- -------\n%9llu %9lu file%s\n"
|
||||
|
||||
# elif (defined(__IBMC__) && (__IBMC__ >= 350))
|
||||
/* IBM C */
|
||||
|
||||
/* 64-bit stat struct */
|
||||
|
||||
/* printf format size prefix for zoff_t values */
|
||||
# define FZOFFT_FMT "I64"
|
||||
# define FZOFFT_HEX_WID_VALUE "16"
|
||||
|
||||
# define SHORTHDRSTATS "%9I64u %02u%c%02u%c%02u %02u:%02u %c"
|
||||
# define SHORTFILETRAILER " -------- -------\n%9I64u %9lu file%s\n"
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* If port has LARGE_FILE_SUPPORT then define here
|
||||
to make automatic unless overridden */
|
||||
|
||||
#ifndef LARGE_FILE_SUPPORT
|
||||
# ifndef NO_LARGE_FILE_SUPPORT
|
||||
# if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
# define LARGE_FILE_SUPPORT
|
||||
# elif defined(__LCC__)
|
||||
/* LCC links against crtdll.dll -> no support of 64-bit offsets :( */
|
||||
# elif defined(__CYGWIN__)
|
||||
# define LARGE_FILE_SUPPORT
|
||||
# elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100))
|
||||
# define LARGE_FILE_SUPPORT
|
||||
# elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520))
|
||||
/* Borland C RTL lacks any support to get/set 64-bit file pointer :( */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef LARGE_FILE_SUPPORT
|
||||
/* No Large File Support */
|
||||
|
||||
/* base type for file offsets and file sizes */
|
||||
typedef long zoff_t;
|
||||
# define ZOFF_T_DEFINED
|
||||
|
||||
/* stat struct */
|
||||
typedef struct stat z_stat;
|
||||
# define Z_STAT_DEFINED
|
||||
|
||||
# define FZOFFT_FMT "l"
|
||||
# define FZOFFT_HEX_WID_VALUE "8"
|
||||
|
||||
|
||||
# define SHORTHDRSTATS "%9lu %02u%c%02u%c%02u %02u:%02u %c"
|
||||
# define SHORTFILETRAILER " -------- -------\n%9lu %9lu file%s\n"
|
||||
|
||||
#endif /* LARGE_FILE_SUPPORT */
|
||||
|
||||
#endif /* !__w32cfg_h */
|
3139
deps/unzipfx/win32/win32.c
vendored
Normal file
3139
deps/unzipfx/win32/win32.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
129
deps/unzipfx/win32/win32i64.c
vendored
Normal file
129
deps/unzipfx/win32/win32i64.c
vendored
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2009-Jan-02 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
win32/win32i64.c - UnZip 6
|
||||
|
||||
64-bit filesize support for WIN32 Zip and UnZip.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#include "../zip.h"
|
||||
|
||||
/* --------------------------------------------------- */
|
||||
/* Large File Support
|
||||
*
|
||||
* Initial functions by E. Gordon and R. Nausedat
|
||||
* 9/10/2003
|
||||
*
|
||||
* These implement 64-bit file support for Windows. The
|
||||
* defines and headers are in win32/osdep.h.
|
||||
*
|
||||
* These moved from win32.c by Mike White to avoid conflicts
|
||||
* in WiZ of same name functions in UnZip and Zip libraries.
|
||||
* 9/25/04 EG
|
||||
*/
|
||||
|
||||
#if defined(LARGE_FILE_SUPPORT) && !defined(__CYGWIN__)
|
||||
# ifdef USE_STRM_INPUT
|
||||
|
||||
# ifndef zftello
|
||||
/* 64-bit buffered ftello
|
||||
*
|
||||
* Win32 does not provide a 64-bit buffered
|
||||
* ftell (in the published api anyway) so below provides
|
||||
* hopefully close version.
|
||||
* We have not gotten _telli64 to work with buffered
|
||||
* streams. Below cheats by using fgetpos improperly and
|
||||
* may not work on other ports.
|
||||
*/
|
||||
|
||||
zoff_t zftello(stream)
|
||||
FILE *stream;
|
||||
{
|
||||
fpos_t fpos = 0;
|
||||
|
||||
if (fgetpos(stream, &fpos) != 0) {
|
||||
return -1L;
|
||||
} else {
|
||||
return fpos;
|
||||
}
|
||||
}
|
||||
# endif /* ndef zftello */
|
||||
|
||||
|
||||
# ifndef zfseeko
|
||||
/* 64-bit buffered fseeko
|
||||
*
|
||||
* Win32 does not provide a 64-bit buffered
|
||||
* fseeko, so use _lseeki64 and fflush. Note
|
||||
* that SEEK_CUR can lose track of location
|
||||
* if fflush is done between the last buffered
|
||||
* io and this call.
|
||||
*/
|
||||
|
||||
int zfseeko(stream, offset, origin)
|
||||
FILE *stream;
|
||||
zoff_t offset;
|
||||
int origin;
|
||||
{
|
||||
|
||||
/* fseek() or its replacements are supposed to clear the eof status
|
||||
of the stream. fflush() and _lseeki64() do not touch the stream's
|
||||
eof flag, so we have to do it manually. */
|
||||
#if ((defined(_MSC_VER) && (_MSC_VER >= 1200)) || \
|
||||
(defined(__MINGW32__) && defined(__MSVCRT_VERSION__)))
|
||||
/* For the MSC environment (VS 6 or higher), and for recent releases of
|
||||
the MinGW environment, we "know" the internals of the FILE structure.
|
||||
So, we can clear just the EOF bit of the status flag. */
|
||||
stream->_flag &= ~_IOEOF;
|
||||
#else
|
||||
/* Unfortunately, there is no standard "cleareof()" function, so we have
|
||||
to use clearerr(). This has the unwanted side effect of clearing the
|
||||
ferror() state as well. */
|
||||
clearerr(stream);
|
||||
#endif
|
||||
|
||||
if (origin == SEEK_CUR) {
|
||||
/* instead of synching up lseek easier just to figure and
|
||||
use an absolute offset */
|
||||
offset += zftello(stream);
|
||||
origin = SEEK_SET;
|
||||
}
|
||||
fflush(stream);
|
||||
if (_lseeki64(fileno(stream), offset, origin) == (zoff_t)-1L) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
# endif /* ndef fseeko */
|
||||
# endif /* USE_STRM_INPUT */
|
||||
#endif /* Win32 LARGE_FILE_SUPPORT */
|
||||
|
||||
#if 0
|
||||
FILE* zfopen(filename, mode)
|
||||
const char *filename;
|
||||
const char *mode;
|
||||
{
|
||||
FILE* fTemp;
|
||||
|
||||
fTemp = fopen(filename, mode);
|
||||
if( fTemp == NULL )
|
||||
return NULL;
|
||||
|
||||
/* sorry, could not make VC60 and its rtl work properly without setting the
|
||||
* file buffer to NULL. the problem seems to be _telli64 which seems to
|
||||
* return the max stream position, comments are welcome
|
||||
*/
|
||||
setbuf(fTemp, NULL);
|
||||
|
||||
return fTemp;
|
||||
}
|
||||
#endif
|
||||
/* --------------------------------------------------- */
|
Loading…
Add table
Add a link
Reference in a new issue