64-Bit Fixes for cabman (patch from Colin Finck)

See issue #2236 for more details.

svn path=/trunk/; revision=26912
This commit is contained in:
Christoph von Wittich 2007-05-27 10:26:43 +00:00
parent cdda19fd20
commit a94fcd5985
10 changed files with 457 additions and 444 deletions

File diff suppressed because it is too large Load diff

View file

@ -19,6 +19,8 @@
#define MAX_PATH 260
#endif
#endif
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -56,7 +58,7 @@
#ifdef DBG
extern unsigned long DebugTraceLevel;
extern uint32_t DebugTraceLevel;
#ifdef _MSC_VER
#define __FUNCTION__ ""
@ -121,59 +123,59 @@ extern unsigned long DebugTraceLevel;
typedef struct _CFHEADER
{
unsigned long Signature; // File signature 'MSCF' (CAB_SIGNATURE)
unsigned long Reserved1; // Reserved field
unsigned long CabinetSize; // Cabinet file size
unsigned long Reserved2; // Reserved field
unsigned long FileTableOffset; // Offset of first CFFILE
unsigned long Reserved3; // Reserved field
unsigned short Version; // Cabinet version (CAB_VERSION)
unsigned short FolderCount; // Number of folders
unsigned short FileCount; // Number of files
unsigned short Flags; // Cabinet flags (CAB_FLAG_*)
unsigned short SetID; // Cabinet set id
unsigned short CabinetNumber; // Zero-based cabinet number
uint32_t Signature; // File signature 'MSCF' (CAB_SIGNATURE)
uint32_t Reserved1; // Reserved field
uint32_t CabinetSize; // Cabinet file size
uint32_t Reserved2; // Reserved field
uint32_t FileTableOffset; // Offset of first CFFILE
uint32_t Reserved3; // Reserved field
uint16_t Version; // Cabinet version (CAB_VERSION)
uint16_t FolderCount; // Number of folders
uint16_t FileCount; // Number of files
uint16_t Flags; // Cabinet flags (CAB_FLAG_*)
uint16_t SetID; // Cabinet set id
uint16_t CabinetNumber; // Zero-based cabinet number
/* Optional fields (depends on Flags)
unsigned short CabinetResSize // Per-cabinet reserved area size
char FolderResSize // Per-folder reserved area size
char FileResSize // Per-file reserved area size
char CabinetReserved[] // Per-cabinet reserved area
char CabinetPrev[] // Name of previous cabinet file
char DiskPrev[] // Name of previous disk
char CabinetNext[] // Name of next cabinet file
char DiskNext[] // Name of next disk
uint16_t CabinetResSize // Per-cabinet reserved area size
char FolderResSize // Per-folder reserved area size
char FileResSize // Per-file reserved area size
char CabinetReserved[] // Per-cabinet reserved area
char CabinetPrev[] // Name of previous cabinet file
char DiskPrev[] // Name of previous disk
char CabinetNext[] // Name of next cabinet file
char DiskNext[] // Name of next disk
*/
} CFHEADER, *PCFHEADER;
typedef struct _CFFOLDER
{
unsigned long DataOffset; // Absolute offset of first CFDATA block in this folder
unsigned short DataBlockCount; // Number of CFDATA blocks in this folder in this cabinet
unsigned short CompressionType; // Type of compression used for all CFDATA blocks in this folder
uint32_t DataOffset; // Absolute offset of first CFDATA block in this folder
uint16_t DataBlockCount; // Number of CFDATA blocks in this folder in this cabinet
uint16_t CompressionType; // Type of compression used for all CFDATA blocks in this folder
/* Optional fields (depends on Flags)
char FolderReserved[] // Per-folder reserved area
char FolderReserved[] // Per-folder reserved area
*/
} CFFOLDER, *PCFFOLDER;
typedef struct _CFFILE
{
unsigned long FileSize; // Uncompressed file size in bytes
unsigned long FileOffset; // Uncompressed offset of file in the folder
unsigned short FileControlID; // File control ID (CAB_FILE_*)
unsigned short FileDate; // File date stamp, as used by DOS
unsigned short FileTime; // File time stamp, as used by DOS
unsigned short Attributes; // File attributes (CAB_ATTRIB_*)
uint32_t FileSize; // Uncompressed file size in bytes
uint32_t FileOffset; // Uncompressed offset of file in the folder
uint16_t FileControlID; // File control ID (CAB_FILE_*)
uint16_t FileDate; // File date stamp, as used by DOS
uint16_t FileTime; // File time stamp, as used by DOS
uint16_t Attributes; // File attributes (CAB_ATTRIB_*)
/* After this is the NULL terminated filename */
} CFFILE, *PCFFILE;
typedef struct _CFDATA
{
unsigned long Checksum; // Checksum of CFDATA entry
unsigned short CompSize; // Number of compressed bytes in this block
unsigned short UncompSize; // Number of uncompressed bytes in this block
uint32_t Checksum; // Checksum of CFDATA entry
uint16_t CompSize; // Number of compressed bytes in this block
uint16_t UncompSize; // Number of uncompressed bytes in this block
/* Optional fields (depends on Flags)
char DataReserved[] // Per-datablock reserved area
*/
@ -183,25 +185,25 @@ typedef struct _CFDATA_NODE
{
struct _CFDATA_NODE *Next;
struct _CFDATA_NODE *Prev;
unsigned long ScratchFilePosition; // Absolute offset in scratch file
unsigned long AbsoluteOffset; // Absolute offset in cabinet
unsigned long UncompOffset; // Uncompressed offset in folder
CFDATA Data;
uint32_t ScratchFilePosition; // Absolute offset in scratch file
uint32_t AbsoluteOffset; // Absolute offset in cabinet
uint32_t UncompOffset; // Uncompressed offset in folder
CFDATA Data;
} CFDATA_NODE, *PCFDATA_NODE;
typedef struct _CFFOLDER_NODE
{
struct _CFFOLDER_NODE *Next;
struct _CFFOLDER_NODE *Prev;
unsigned long UncompOffset; // File size accumulator
unsigned long AbsoluteOffset;
unsigned long TotalFolderSize; // Total size of folder in current disk
PCFDATA_NODE DataListHead;
PCFDATA_NODE DataListTail;
unsigned long Index;
bool Commit; // true if the folder should be committed
bool Delete; // true if marked for deletion
CFFOLDER Folder;
uint32_t UncompOffset; // File size accumulator
uint32_t AbsoluteOffset;
uint32_t TotalFolderSize; // Total size of folder in current disk
PCFDATA_NODE DataListHead;
PCFDATA_NODE DataListTail;
uint32_t Index;
bool Commit; // true if the folder should be committed
bool Delete; // true if marked for deletion
CFFOLDER Folder;
} CFFOLDER_NODE, *PCFFOLDER_NODE;
typedef struct _CFFILE_NODE
@ -213,7 +215,7 @@ typedef struct _CFFILE_NODE
PCFDATA_NODE DataBlock; // First data block of file. NULL if not known
bool Commit; // true if the file data should be committed
bool Delete; // true if marked for deletion
PCFFOLDER_NODE FolderNode; // Folder this file belong to
PCFFOLDER_NODE FolderNode; // Folder this file belong to
} CFFILE_NODE, *PCFFILE_NODE;
@ -252,15 +254,15 @@ public:
/* Default destructor */
virtual ~CCABCodec() {};
/* Compresses a data block */
virtual unsigned long Compress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength) = 0;
virtual uint32_t Compress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength) = 0;
/* Uncompresses a data block */
virtual unsigned long Uncompress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength) = 0;
virtual uint32_t Uncompress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength) = 0;
};
@ -287,13 +289,13 @@ public:
CCFDATAStorage();
/* Default destructor */
virtual ~CCFDATAStorage();
unsigned long Create(char* FileName);
unsigned long Destroy();
unsigned long Truncate();
unsigned long Position();
unsigned long Seek(long Position);
unsigned long ReadBlock(PCFDATA Data, void* Buffer, unsigned long* BytesRead);
unsigned long WriteBlock(PCFDATA Data, void* Buffer, unsigned long* BytesWritten);
uint32_t Create(char* FileName);
uint32_t Destroy();
uint32_t Truncate();
uint32_t Position();
uint32_t Seek(int32_t Position);
uint32_t ReadBlock(PCFDATA Data, void* Buffer, uint32_t* BytesRead);
uint32_t WriteBlock(PCFDATA Data, void* Buffer, uint32_t* BytesWritten);
private:
char FullName[MAX_PATH];
bool FileCreated;
@ -317,7 +319,7 @@ public:
/* Removes a filename from a fully qualified filename */
void RemoveFileName(char* Path);
/* Normalizes a path */
bool NormalizePath(char* Path, unsigned long Length);
bool NormalizePath(char* Path, uint32_t Length);
/* Returns name of cabinet file */
char* GetCabinetName();
/* Sets the name of the cabinet file */
@ -331,40 +333,40 @@ public:
/* Returns destination path */
char* GetDestinationPath();
/* Returns zero-based current disk number */
unsigned long GetCurrentDiskNumber();
uint32_t GetCurrentDiskNumber();
/* Opens the current cabinet file */
unsigned long Open();
uint32_t Open();
/* Closes the current open cabinet file */
void Close();
/* Locates the first file in the current cabinet file that matches a search criteria */
unsigned long FindFirst(char* FileName, PCAB_SEARCH Search);
uint32_t FindFirst(char* FileName, PCAB_SEARCH Search);
/* Locates the next file in the current cabinet file */
unsigned long FindNext(PCAB_SEARCH Search);
uint32_t FindNext(PCAB_SEARCH Search);
/* Extracts a file from the current cabinet file */
unsigned long ExtractFile(char* FileName);
uint32_t ExtractFile(char* FileName);
/* Select codec engine to use */
void SelectCodec(unsigned long Id);
void SelectCodec(uint32_t Id);
#ifndef CAB_READ_ONLY
/* Creates a new cabinet file */
unsigned long NewCabinet();
uint32_t NewCabinet();
/* Forces a new disk to be created */
unsigned long NewDisk();
uint32_t NewDisk();
/* Forces a new folder to be created */
unsigned long NewFolder();
uint32_t NewFolder();
/* Writes a file to scratch storage */
unsigned long WriteFileToScratchStorage(PCFFILE_NODE FileNode);
uint32_t WriteFileToScratchStorage(PCFFILE_NODE FileNode);
/* Forces the current disk to be written */
unsigned long WriteDisk(unsigned long MoreDisks);
uint32_t WriteDisk(uint32_t MoreDisks);
/* Commits the current disk */
unsigned long CommitDisk(unsigned long MoreDisks);
uint32_t CommitDisk(uint32_t MoreDisks);
/* Closes the current disk */
unsigned long CloseDisk();
uint32_t CloseDisk();
/* Closes the current cabinet */
unsigned long CloseCabinet();
uint32_t CloseCabinet();
/* Adds a file to the current disk */
unsigned long AddFile(char* FileName);
uint32_t AddFile(char* FileName);
/* Sets the maximum size of the current disk */
void SetMaxDiskSize(unsigned long Size);
void SetMaxDiskSize(uint32_t Size);
#endif /* CAB_READ_ONLY */
/* Default event handlers */
@ -379,17 +381,17 @@ public:
/* Handler called when a file is about to be added */
virtual void OnAdd(PCFFILE Entry, char* FileName);
/* Handler called when a cabinet need a name */
virtual bool OnCabinetName(unsigned long Number, char* Name);
virtual bool OnCabinetName(uint32_t Number, char* Name);
/* Handler called when a disk needs a label */
virtual bool OnDiskLabel(unsigned long Number, char* Label);
virtual bool OnDiskLabel(uint32_t Number, char* Label);
#endif /* CAB_READ_ONLY */
private:
PCFFOLDER_NODE LocateFolderNode(unsigned long Index);
unsigned long GetAbsoluteOffset(PCFFILE_NODE File);
unsigned long LocateFile(char* FileName, PCFFILE_NODE *File);
unsigned long ReadString(char* String, unsigned long MaxLength);
unsigned long ReadFileTable();
unsigned long ReadDataBlocks(PCFFOLDER_NODE FolderNode);
PCFFOLDER_NODE LocateFolderNode(uint32_t Index);
uint32_t GetAbsoluteOffset(PCFFILE_NODE File);
uint32_t LocateFile(char* FileName, PCFFILE_NODE *File);
uint32_t ReadString(char* String, uint32_t MaxLength);
uint32_t ReadFileTable();
uint32_t ReadDataBlocks(PCFFOLDER_NODE FolderNode);
PCFFOLDER_NODE NewFolderNode();
PCFFILE_NODE NewFileNode();
PCFDATA_NODE NewDataNode(PCFFOLDER_NODE FolderNode);
@ -398,45 +400,45 @@ private:
void DestroyDeletedFileNodes();
void DestroyFolderNodes();
void DestroyDeletedFolderNodes();
unsigned long ComputeChecksum(void* Buffer, unsigned int Size, unsigned long Seed);
unsigned long ReadBlock(void* Buffer, unsigned long Size, unsigned long* BytesRead);
uint32_t ComputeChecksum(void* Buffer, unsigned int Size, uint32_t Seed);
uint32_t ReadBlock(void* Buffer, uint32_t Size, uint32_t* BytesRead);
#ifndef CAB_READ_ONLY
unsigned long InitCabinetHeader();
unsigned long WriteCabinetHeader(bool MoreDisks);
unsigned long WriteFolderEntries();
unsigned long WriteFileEntries();
unsigned long CommitDataBlocks(PCFFOLDER_NODE FolderNode);
unsigned long WriteDataBlock();
unsigned long GetAttributesOnFile(PCFFILE_NODE File);
unsigned long SetAttributesOnFile(PCFFILE_NODE File);
unsigned long GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File);
uint32_t InitCabinetHeader();
uint32_t WriteCabinetHeader(bool MoreDisks);
uint32_t WriteFolderEntries();
uint32_t WriteFileEntries();
uint32_t CommitDataBlocks(PCFFOLDER_NODE FolderNode);
uint32_t WriteDataBlock();
uint32_t GetAttributesOnFile(PCFFILE_NODE File);
uint32_t SetAttributesOnFile(PCFFILE_NODE File);
uint32_t GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File);
#if !defined(WIN32)
void ConvertDateAndTime(time_t* Time, unsigned short* DosDate, unsigned short* DosTime);
void ConvertDateAndTime(time_t* Time, uint16_t* DosDate, uint16_t* DosTime);
#endif
#endif /* CAB_READ_ONLY */
unsigned long CurrentDiskNumber; // Zero based disk number
uint32_t CurrentDiskNumber; // Zero based disk number
char CabinetName[256]; // Filename of current cabinet
char CabinetPrev[256]; // Filename of previous cabinet
char DiskPrev[256]; // Label of cabinet in file CabinetPrev
char CabinetNext[256]; // Filename of next cabinet
char DiskNext[256]; // Label of cabinet in file CabinetNext
unsigned long TotalHeaderSize; // Size of header and optional fields
unsigned long NextFieldsSize; // Size of next cabinet name and next disk label
unsigned long TotalFolderSize; // Size of all folder entries
unsigned long TotalFileSize; // Size of all file entries
unsigned long FolderUncompSize; // Uncompressed size of folder
unsigned long BytesLeftInBlock; // Number of bytes left in current block
uint32_t TotalHeaderSize; // Size of header and optional fields
uint32_t NextFieldsSize; // Size of next cabinet name and next disk label
uint32_t TotalFolderSize; // Size of all folder entries
uint32_t TotalFileSize; // Size of all file entries
uint32_t FolderUncompSize; // Uncompressed size of folder
uint32_t BytesLeftInBlock; // Number of bytes left in current block
bool ReuseBlock;
char DestPath[MAX_PATH];
char CabinetReservedFile[MAX_PATH];
void* CabinetReservedFileBuffer;
unsigned long CabinetReservedFileSize;
uint32_t CabinetReservedFileSize;
FILEHANDLE FileHandle;
bool FileOpen;
CFHEADER CABHeader;
unsigned long CabinetReserved;
unsigned long FolderReserved;
unsigned long DataReserved;
uint32_t CabinetReserved;
uint32_t FolderReserved;
uint32_t DataReserved;
PCFFOLDER_NODE FolderListHead;
PCFFOLDER_NODE FolderListTail;
PCFFOLDER_NODE CurrentFolderNode;
@ -444,32 +446,32 @@ private:
PCFFILE_NODE FileListHead;
PCFFILE_NODE FileListTail;
CCABCodec *Codec;
unsigned long CodecId;
uint32_t CodecId;
bool CodecSelected;
void* InputBuffer;
void* CurrentIBuffer; // Current offset in input buffer
unsigned long CurrentIBufferSize; // Bytes left in input buffer
uint32_t CurrentIBufferSize; // Bytes left in input buffer
void* OutputBuffer;
unsigned long TotalCompSize; // Total size of current CFDATA block
uint32_t TotalCompSize; // Total size of current CFDATA block
void* CurrentOBuffer; // Current offset in output buffer
unsigned long CurrentOBufferSize; // Bytes left in output buffer
unsigned long BytesLeftInCabinet;
uint32_t CurrentOBufferSize; // Bytes left in output buffer
uint32_t BytesLeftInCabinet;
bool RestartSearch;
unsigned long LastFileOffset; // Uncompressed offset of last extracted file
uint32_t LastFileOffset; // Uncompressed offset of last extracted file
#ifndef CAB_READ_ONLY
unsigned long LastBlockStart; // Uncompressed offset of last block in folder
unsigned long MaxDiskSize;
unsigned long DiskSize;
unsigned long PrevCabinetNumber; // Previous cabinet number (where split file starts)
uint32_t LastBlockStart; // Uncompressed offset of last block in folder
uint32_t MaxDiskSize;
uint32_t DiskSize;
uint32_t PrevCabinetNumber; // Previous cabinet number (where split file starts)
bool CreateNewDisk;
bool CreateNewFolder;
CCFDATAStorage *ScratchFile;
FILEHANDLE SourceFile;
bool ContinueFile;
unsigned long TotalBytesLeft;
uint32_t TotalBytesLeft;
bool BlockIsSplit; // true if current data block is split
unsigned long NextFolderNumber; // Zero based folder number
uint32_t NextFolderNumber; // Zero based folder number
#endif /* CAB_READ_ONLY */
};

View file

@ -37,7 +37,7 @@ private:
virtual void OnAdd(PCFFILE Entry, char* FileName);
/* Configuration */
bool ProcessAll;
unsigned long Mode;
uint32_t Mode;
bool PromptOnOverwrite;
char Location[MAX_PATH];
char FileName[MAX_PATH];

View file

@ -11,6 +11,7 @@
* CSH 21/03-2001 Created
* CSH 15/08-2003 Made it portable
* CF 04/05-2007 Reformatted the code to be more consistent and use TABs instead of spaces
* CF 04/05-2007 Made it compatible with 64-bit operating systems
*/
#include <stdlib.h>
#include <stdio.h>
@ -20,31 +21,31 @@
#if defined(WIN32)
#define GetSizeOfFile(handle) _GetSizeOfFile(handle)
static long _GetSizeOfFile(FILEHANDLE handle)
static int32_t _GetSizeOfFile(FILEHANDLE handle)
{
unsigned long size = GetFileSize(handle, NULL);
uint32_t size = GetFileSize(handle, NULL);
if (size == INVALID_FILE_SIZE)
return -1;
return size;
}
#define ReadFileData(handle, buffer, size, bytesread) _ReadFileData(handle, buffer, size, bytesread)
static bool _ReadFileData(FILEHANDLE handle, void* buffer, unsigned long size, unsigned long* bytesread)
static bool _ReadFileData(FILEHANDLE handle, void* buffer, uint32_t size, uint32_t* bytesread)
{
return ReadFile(handle, buffer, size, bytesread, NULL);
return ReadFile(handle, buffer, size, (LPDWORD)bytesread, NULL);
}
#else
#define GetSizeOfFile(handle) _GetSizeOfFile(handle)
static long _GetSizeOfFile(FILEHANDLE handle)
static int32_t _GetSizeOfFile(FILEHANDLE handle)
{
long size;
int32_t size;
fseek(handle, 0, SEEK_END);
size = ftell(handle);
fseek(handle, 0, SEEK_SET);
return size;
}
#define ReadFileData(handle, buffer, size, bytesread) _ReadFileData(handle, buffer, size, bytesread)
static bool _ReadFileData(FILEHANDLE handle, void* buffer, unsigned long size, unsigned long* bytesread)
static bool _ReadFileData(FILEHANDLE handle, void* buffer, uint32_t size, uint32_t* bytesread)
{
*bytesread = fread(buffer, 1, size, handle);
return *bytesread == size;
@ -127,7 +128,7 @@ void CDFParser::WriteInfLine(char* InfLine)
char eolbuf[2];
char* destpath;
#if defined(WIN32)
unsigned long BytesWritten;
uint32_t BytesWritten;
#endif
if (DontGenerateInf)
@ -173,7 +174,7 @@ void CDFParser::WriteInfLine(char* InfLine)
}
#if defined(WIN32)
if (!WriteFile(InfFileHandle, InfLine, strlen(InfLine), &BytesWritten, NULL))
if (!WriteFile(InfFileHandle, InfLine, (DWORD)strlen(InfLine), (LPDWORD)&BytesWritten, NULL))
{
DPRINT(MID_TRACE, ("ERROR WRITING '%d'.\n", (unsigned int)GetLastError()));
return;
@ -187,7 +188,7 @@ void CDFParser::WriteInfLine(char* InfLine)
eolbuf[1] = 0x0a;
#if defined(WIN32)
if (!WriteFile(InfFileHandle, eolbuf, sizeof(eolbuf), &BytesWritten, NULL))
if (!WriteFile(InfFileHandle, eolbuf, sizeof(eolbuf), (LPDWORD)&BytesWritten, NULL))
{
DPRINT(MID_TRACE, ("ERROR WRITING '%d'.\n", (unsigned int)GetLastError()));
return;
@ -199,7 +200,7 @@ void CDFParser::WriteInfLine(char* InfLine)
}
unsigned long CDFParser::Load(char* FileName)
uint32_t CDFParser::Load(char* FileName)
/*
* FUNCTION: Loads a directive file into memory
* ARGUMENTS:
@ -208,8 +209,8 @@ unsigned long CDFParser::Load(char* FileName)
* Status of operation
*/
{
unsigned long BytesRead;
long FileSize;
uint32_t BytesRead;
int32_t FileSize;
if (FileLoaded)
return CAB_STATUS_SUCCESS;
@ -238,7 +239,7 @@ unsigned long CDFParser::Load(char* FileName)
return CAB_STATUS_CANNOT_OPEN;
}
FileBufferSize = (unsigned long)FileSize;
FileBufferSize = (uint32_t)FileSize;
FileBuffer = (char*)AllocateMemory(FileBufferSize);
if (!FileBuffer)
@ -265,7 +266,7 @@ unsigned long CDFParser::Load(char* FileName)
}
unsigned long CDFParser::Parse()
uint32_t CDFParser::Parse()
/*
* FUNCTION: Parses a loaded directive file
* RETURNS:
@ -273,7 +274,7 @@ unsigned long CDFParser::Parse()
*/
{
bool Command;
unsigned long Status;
uint32_t Status;
if (!FileLoaded)
return CAB_STATUS_NOFILE;
@ -436,7 +437,7 @@ void CDFParser::SetFileRelativePath(char* Path)
}
bool CDFParser::OnDiskLabel(unsigned long Number, char* Label)
bool CDFParser::OnDiskLabel(uint32_t Number, char* Label)
/*
* FUNCTION: Called when a disk needs a label
* ARGUMENTS:
@ -469,7 +470,7 @@ bool CDFParser::OnDiskLabel(unsigned long Number, char* Label)
{
sprintf(Buffer, "%lu", Number);
strcat(Label, Buffer);
j += strlen(Buffer);
j += (int)strlen(Buffer);
}
else
{
@ -488,7 +489,7 @@ bool CDFParser::OnDiskLabel(unsigned long Number, char* Label)
}
bool CDFParser::OnCabinetName(unsigned long Number, char* Name)
bool CDFParser::OnCabinetName(uint32_t Number, char* Name)
/*
* FUNCTION: Called when a cabinet needs a name
* ARGUMENTS:
@ -517,7 +518,7 @@ bool CDFParser::OnCabinetName(unsigned long Number, char* Name)
if (CabinetNameTemplateSet)
{
strcpy(Name, GetDestinationPath());
j = strlen(Name);
j = (int)strlen(Name);
for (i = 0; i < strlen(CabinetNameTemplate); i++)
{
ch = CabinetNameTemplate[i];
@ -525,7 +526,7 @@ bool CDFParser::OnCabinetName(unsigned long Number, char* Name)
{
sprintf(Buffer, "%lu", Number);
strcat(Name, Buffer);
j += strlen(Buffer);
j += (int)strlen(Buffer);
}
else
{
@ -543,7 +544,7 @@ bool CDFParser::OnCabinetName(unsigned long Number, char* Name)
}
bool CDFParser::SetDiskName(PCABINET_NAME *List, unsigned long Number, char* String)
bool CDFParser::SetDiskName(PCABINET_NAME *List, uint32_t Number, char* String)
/*
* FUNCTION: Sets an entry in a list
* ARGUMENTS:
@ -581,7 +582,7 @@ bool CDFParser::SetDiskName(PCABINET_NAME *List, unsigned long Number, char* Str
}
bool CDFParser::GetDiskName(PCABINET_NAME *List, unsigned long Number, char* String)
bool CDFParser::GetDiskName(PCABINET_NAME *List, uint32_t Number, char* String)
/*
* FUNCTION: Returns an entry in a list
* ARGUMENTS:
@ -609,7 +610,7 @@ bool CDFParser::GetDiskName(PCABINET_NAME *List, unsigned long Number, char* Str
}
bool CDFParser::SetDiskNumber(PDISK_NUMBER *List, unsigned long Number, unsigned long Value)
bool CDFParser::SetDiskNumber(PDISK_NUMBER *List, uint32_t Number, uint32_t Value)
/*
* FUNCTION: Sets an entry in a list
* ARGUMENTS:
@ -647,7 +648,7 @@ bool CDFParser::SetDiskNumber(PDISK_NUMBER *List, unsigned long Number, unsigned
}
bool CDFParser::GetDiskNumber(PDISK_NUMBER *List, unsigned long Number, unsigned long* Value)
bool CDFParser::GetDiskNumber(PDISK_NUMBER *List, uint32_t Number, uint32_t* Value)
/*
* FUNCTION: Returns an entry in a list
* ARGUMENTS:
@ -675,7 +676,7 @@ bool CDFParser::GetDiskNumber(PDISK_NUMBER *List, unsigned long Number, unsigned
}
bool CDFParser::DoDiskLabel(unsigned long Number, char* Label)
bool CDFParser::DoDiskLabel(uint32_t Number, char* Label)
/*
* FUNCTION: Sets the label of a disk
* ARGUMENTS:
@ -705,7 +706,7 @@ void CDFParser::DoDiskLabelTemplate(char* Template)
}
bool CDFParser::DoCabinetName(unsigned long Number, char* Name)
bool CDFParser::DoCabinetName(uint32_t Number, char* Name)
/*
* FUNCTION: Sets the name of a cabinet
* ARGUMENTS:
@ -735,7 +736,7 @@ void CDFParser::DoCabinetNameTemplate(char* Template)
}
unsigned long CDFParser::DoMaxDiskSize(bool NumberValid, unsigned long Number)
uint32_t CDFParser::DoMaxDiskSize(bool NumberValid, uint32_t Number)
/*
* FUNCTION: Sets the maximum disk size
* ARGUMENTS:
@ -747,7 +748,7 @@ unsigned long CDFParser::DoMaxDiskSize(bool NumberValid, unsigned long Number)
* Standard sizes are 2.88M, 1.44M, 1.25M, 1.2M, 720K, 360K, and CDROM
*/
{
unsigned long A, B, Value;
uint32_t A, B, Value;
if (IsNextToken(TokenInteger, true))
{
@ -852,14 +853,14 @@ void CDFParser::DoInfFileName(char* FileName)
InfFileNameSet = true;
}
unsigned long CDFParser::SetupNewDisk()
uint32_t CDFParser::SetupNewDisk()
/*
* FUNCTION: Sets up parameters for a new disk
* RETURNS:
* Status of operation
*/
{
unsigned long Value;
uint32_t Value;
if (!GetDiskNumber(&MaxDiskSize, GetCurrentDiskNumber(), &Value))
{
@ -874,7 +875,7 @@ unsigned long CDFParser::SetupNewDisk()
}
unsigned long CDFParser::PerformSetCommand()
uint32_t CDFParser::PerformSetCommand()
/*
* FUNCTION: Performs a set variable command
* RETURNS:
@ -883,7 +884,7 @@ unsigned long CDFParser::PerformSetCommand()
{
SETTYPE SetType;
bool NumberValid = false;
unsigned long Number = 0;
uint32_t Number = 0;
if (!IsNextToken(TokenIdentifier, true))
return CAB_STATUS_FAILURE;
@ -970,7 +971,7 @@ unsigned long CDFParser::PerformSetCommand()
}
unsigned long CDFParser::PerformNewCommand()
uint32_t CDFParser::PerformNewCommand()
/*
* FUNCTION: Performs a new disk|cabinet|folder command
* RETURNS:
@ -978,7 +979,7 @@ unsigned long CDFParser::PerformNewCommand()
*/
{
NEWTYPE NewType;
unsigned long Status;
uint32_t Status;
if (!IsNextToken(TokenIdentifier, true))
return CAB_STATUS_FAILURE;
@ -1053,7 +1054,7 @@ unsigned long CDFParser::PerformNewCommand()
}
unsigned long CDFParser::PerformInfBeginCommand()
uint32_t CDFParser::PerformInfBeginCommand()
/*
* FUNCTION: Begins inf mode
* RETURNS:
@ -1065,7 +1066,7 @@ unsigned long CDFParser::PerformInfBeginCommand()
}
unsigned long CDFParser::PerformInfEndCommand()
uint32_t CDFParser::PerformInfEndCommand()
/*
* FUNCTION: Begins inf mode
* RETURNS:
@ -1077,7 +1078,7 @@ unsigned long CDFParser::PerformInfEndCommand()
}
unsigned long CDFParser::PerformCommand()
uint32_t CDFParser::PerformCommand()
/*
* FUNCTION: Performs a command
* RETURNS:
@ -1097,15 +1098,15 @@ unsigned long CDFParser::PerformCommand()
}
unsigned long CDFParser::PerformFileCopy()
uint32_t CDFParser::PerformFileCopy()
/*
* FUNCTION: Performs a file copy
* RETURNS:
* Status of operation
*/
{
unsigned long Status;
unsigned long i, j;
uint32_t Status;
uint32_t i, j;
char ch;
char SrcName[MAX_PATH];
char DstName[MAX_PATH];
@ -1137,7 +1138,7 @@ unsigned long CDFParser::PerformFileCopy()
if (CurrentToken != TokenEnd)
{
j = strlen(CurrentString); i = 0;
j = (uint32_t)strlen(CurrentString); i = 0;
while ((CurrentChar + i < LineLength) &&
((ch = Line[CurrentChar + i]) != ' ') &&
(ch != 0x09) &&
@ -1157,7 +1158,7 @@ unsigned long CDFParser::PerformFileCopy()
if (CurrentToken != TokenEnd)
{
j = strlen(CurrentString); i = 0;
j = (uint32_t)strlen(CurrentString); i = 0;
while ((CurrentChar + i < LineLength) &&
((ch = Line[CurrentChar + i]) != ' ') &&
(ch != 0x09) &&
@ -1273,7 +1274,7 @@ bool CDFParser::ReadLine()
* true if there is a new line, false if not
*/
{
unsigned long i, j;
uint32_t i, j;
char ch;
if (CurrentOffset >= FileBufferSize)
@ -1310,7 +1311,7 @@ void CDFParser::NextToken()
* FUNCTION: Reads the next token from the current line
*/
{
unsigned long i;
uint32_t i;
char ch = ' ';
if (CurrentChar >= LineLength)

View file

@ -11,14 +11,14 @@
typedef struct _CABINET_NAME {
struct _CABINET_NAME *Next;
unsigned long DiskNumber;
uint32_t DiskNumber;
char Name[128];
} CABINET_NAME, *PCABINET_NAME;
typedef struct _DISK_NUMBER {
struct _DISK_NUMBER *Next;
unsigned long DiskNumber;
unsigned long Number;
uint32_t DiskNumber;
uint32_t Number;
} DISK_NUMBER, *PDISK_NUMBER;
typedef enum {
@ -58,35 +58,35 @@ class CDFParser : public CCabinet {
public:
CDFParser();
virtual ~CDFParser();
unsigned long Load(char* FileName);
unsigned long Parse();
uint32_t Load(char* FileName);
uint32_t Parse();
void SetFileRelativePath(char* Path);
bool InfFileOnly;
bool DontGenerateInf;
char FileRelativePath[300];
private:
/* Event handlers */
virtual bool OnDiskLabel(unsigned long Number, char* Label);
virtual bool OnCabinetName(unsigned long Number, char* Name);
virtual bool OnDiskLabel(uint32_t Number, char* Label);
virtual bool OnCabinetName(uint32_t Number, char* Name);
void WriteInfLine(char* InfLine);
bool SetDiskName(PCABINET_NAME *List, unsigned long Number, char* String);
bool GetDiskName(PCABINET_NAME *List, unsigned long Number, char* String);
bool SetDiskNumber(PDISK_NUMBER *List, unsigned long Number, unsigned long Value);
bool GetDiskNumber(PDISK_NUMBER *List, unsigned long Number, unsigned long* Value);
bool DoDiskLabel(unsigned long Number, char* Label);
bool SetDiskName(PCABINET_NAME *List, uint32_t Number, char* String);
bool GetDiskName(PCABINET_NAME *List, uint32_t Number, char* String);
bool SetDiskNumber(PDISK_NUMBER *List, uint32_t Number, uint32_t Value);
bool GetDiskNumber(PDISK_NUMBER *List, uint32_t Number, uint32_t* Value);
bool DoDiskLabel(uint32_t Number, char* Label);
void DoDiskLabelTemplate(char* Template);
bool DoCabinetName(unsigned long Number, char* Name);
bool DoCabinetName(uint32_t Number, char* Name);
void DoCabinetNameTemplate(char* Template);
void DoInfFileName(char* InfFileName);
unsigned long DoMaxDiskSize(bool NumberValid, unsigned long Number);
unsigned long SetupNewDisk();
unsigned long PerformSetCommand();
unsigned long PerformNewCommand();
unsigned long PerformInfBeginCommand();
unsigned long PerformInfEndCommand();
unsigned long PerformCommand();
unsigned long PerformFileCopy();
uint32_t DoMaxDiskSize(bool NumberValid, uint32_t Number);
uint32_t SetupNewDisk();
uint32_t PerformSetCommand();
uint32_t PerformNewCommand();
uint32_t PerformInfBeginCommand();
uint32_t PerformInfEndCommand();
uint32_t PerformCommand();
uint32_t PerformFileCopy();
void SkipSpaces();
bool IsNextToken(DFP_TOKEN Token, bool NoSpaces);
bool ReadLine();
@ -95,15 +95,15 @@ private:
bool FileLoaded;
FILEHANDLE FileHandle;
char* FileBuffer;
unsigned long FileBufferSize;
unsigned long CurrentOffset;
uint32_t FileBufferSize;
uint32_t CurrentOffset;
char Line[128];
unsigned long LineLength;
unsigned long CurrentLine;
unsigned long CurrentChar;
uint32_t LineLength;
uint32_t CurrentLine;
uint32_t CurrentChar;
/* Token */
DFP_TOKEN CurrentToken;
unsigned long CurrentInteger;
uint32_t CurrentInteger;
char CurrentString[256];
/* State */
@ -112,27 +112,27 @@ private:
bool FolderCreated;
/* Standard directive variable */
bool Cabinet;
unsigned long CabinetFileCountThreshold;
uint32_t CabinetFileCountThreshold;
PCABINET_NAME CabinetName;
bool CabinetNameTemplateSet;
char CabinetNameTemplate[128];
bool InfFileNameSet;
char InfFileName[256];
bool Compress;
unsigned long CompressionType;
uint32_t CompressionType;
PCABINET_NAME DiskLabel;
bool DiskLabelTemplateSet;
char DiskLabelTemplate[128];
unsigned long FolderFileCountThreshold;
unsigned long FolderSizeThreshold;
unsigned long MaxCabinetSize;
unsigned long MaxDiskFileCount;
uint32_t FolderFileCountThreshold;
uint32_t FolderSizeThreshold;
uint32_t MaxCabinetSize;
uint32_t MaxDiskFileCount;
PDISK_NUMBER MaxDiskSize;
bool MaxDiskSizeAllSet;
unsigned long MaxDiskSizeAll;
unsigned long ReservePerCabinetSize;
unsigned long ReservePerDataBlockSize;
unsigned long ReservePerFolderSize;
uint32_t MaxDiskSizeAll;
uint32_t ReservePerCabinetSize;
uint32_t ReservePerDataBlockSize;
uint32_t ReservePerFolderSize;
char SourceDir[256];
FILEHANDLE InfFileHandle;
bool InfModeEnabled;

View file

@ -9,6 +9,7 @@
* CSH 21/03-2001 Created
* CSH 15/08-2003 Made it portable
* CF 04/05-2007 Reformatted the code to be more consistent and use TABs instead of spaces
* CF 04/05-2007 Made it compatible with 64-bit operating systems
*/
#include <stdlib.h>
#include <stdarg.h>
@ -19,9 +20,9 @@
#ifdef DBG
unsigned long DebugTraceLevel = MIN_TRACE;
//unsigned long DebugTraceLevel = MID_TRACE;
//unsigned long DebugTraceLevel = MAX_TRACE;
uint32_t DebugTraceLevel = MIN_TRACE;
//uint32_t DebugTraceLevel = MID_TRACE;
//uint32_t DebugTraceLevel = MAX_TRACE;
#endif /* DBG */
@ -44,7 +45,7 @@ char* Pad(char* Str, char PadChar, unsigned int Length)
{
unsigned int Len;
Len = strlen(Str);
Len = (uint32_t)strlen(Str);
if (Len < Length)
{
@ -55,7 +56,7 @@ char* Pad(char* Str, char PadChar, unsigned int Length)
}
char* Date2Str(char* Str, unsigned short Date)
char* Date2Str(char* Str, uint16_t Date)
/*
* FUNCTION: Converts a DOS style date to a string
* ARGUMENTS:
@ -65,7 +66,7 @@ char* Date2Str(char* Str, unsigned short Date)
* Pointer to string
*/
{
unsigned long dw;
uint32_t dw;
/* Month */
Str[0] = (char)('0' + ((Date & 0x01E0) >> 5) / 10);
@ -86,7 +87,7 @@ char* Date2Str(char* Str, unsigned short Date)
}
char* Time2Str(char* Str, unsigned short Time)
char* Time2Str(char* Str, uint16_t Time)
/*
* FUNCTION: Converts a DOS style time to a string
* ARGUMENTS:
@ -97,8 +98,8 @@ char* Time2Str(char* Str, unsigned short Time)
*/
{
bool PM;
unsigned long Hour;
unsigned long dw;
uint32_t Hour;
uint32_t dw;
Hour = ((Time & 0xF800) >> 11);
PM = (Hour >= 12);
@ -126,7 +127,7 @@ char* Time2Str(char* Str, unsigned short Time)
}
char* Attr2Str(char* Str, unsigned short Attr)
char* Attr2Str(char* Str, uint16_t Attr)
/*
* FUNCTION: Converts attributes to a string
* ARGUMENTS:
@ -364,7 +365,7 @@ bool CCABManager::CreateCabinet()
* FUNCTION: Create cabinet
*/
{
unsigned long Status;
uint32_t Status;
Status = Load((char*)&FileName);
if (Status != CAB_STATUS_SUCCESS)
@ -384,7 +385,7 @@ bool CCABManager::CreateSimpleCabinet()
* FUNCTION: Create cabinet
*/
{
unsigned long Status;
uint32_t Status;
Status = NewCabinet();
if (Status != CAB_STATUS_SUCCESS)
@ -422,8 +423,8 @@ bool CCABManager::DisplayCabinet()
{
CAB_SEARCH Search;
char Str[20];
unsigned long FileCount = 0;
unsigned long ByteCount = 0;
uint32_t FileCount = 0;
uint32_t ByteCount = 0;
if (Open() == CAB_STATUS_SUCCESS)
{
@ -485,7 +486,7 @@ bool CCABManager::ExtractFromCabinet()
*/
{
CAB_SEARCH Search;
unsigned long Status;
uint32_t Status;
if (Open() == CAB_STATUS_SUCCESS)
{

View file

@ -11,6 +11,7 @@
* CSH 21/03-2001 Created
* CSH 15/08-2003 Made it portable
* CF 04/05-2007 Reformatted the code to be more consistent and use TABs instead of spaces
* CF 04/05-2007 Made it compatible with 64-bit operating systems
*/
#include <stdio.h>
#include "mszip.h"
@ -52,10 +53,10 @@ CMSZipCodec::~CMSZipCodec()
}
unsigned long CMSZipCodec::Compress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength)
uint32_t CMSZipCodec::Compress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength)
/*
* FUNCTION: Compresses data in a buffer
* ARGUMENTS:
@ -65,16 +66,16 @@ unsigned long CMSZipCodec::Compress(void* OutputBuffer,
* OutputLength = Address of buffer to place size of compressed data
*/
{
unsigned short* Magic;
uint16_t* Magic;
DPRINT(MAX_TRACE, ("InputLength (%lu).\n", InputLength));
Magic = (unsigned short*)OutputBuffer;
Magic = (uint16_t*)OutputBuffer;
*Magic = MSZIP_MAGIC;
ZStream.next_in = (unsigned char*)InputBuffer;
ZStream.avail_in = InputLength;
ZStream.next_out = (unsigned char*)((unsigned long)OutputBuffer + 2);
ZStream.next_out = (unsigned char*)((uintptr_t)OutputBuffer + 2);
ZStream.avail_out = CAB_BLOCKSIZE + 12;
/* WindowBits is passed < 0 to tell that there is no zlib header */
@ -112,10 +113,10 @@ unsigned long CMSZipCodec::Compress(void* OutputBuffer,
}
unsigned long CMSZipCodec::Uncompress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength)
uint32_t CMSZipCodec::Uncompress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength)
/*
* FUNCTION: Uncompresses data in a buffer
* ARGUMENTS:
@ -125,11 +126,11 @@ unsigned long CMSZipCodec::Uncompress(void* OutputBuffer,
* OutputLength = Address of buffer to place size of uncompressed data
*/
{
unsigned short Magic;
uint16_t Magic;
DPRINT(MAX_TRACE, ("InputLength (%lu).\n", InputLength));
Magic = *((unsigned short*)InputBuffer);
Magic = *((uint16_t*)InputBuffer);
if (Magic != MSZIP_MAGIC)
{
@ -137,7 +138,7 @@ unsigned long CMSZipCodec::Uncompress(void* OutputBuffer,
return CS_BADSTREAM;
}
ZStream.next_in = (unsigned char*)((unsigned long)InputBuffer + 2);
ZStream.next_in = (unsigned char*)((uintptr_t)InputBuffer + 2);
ZStream.avail_in = InputLength - 2;
ZStream.next_out = (unsigned char*)OutputBuffer;
ZStream.avail_out = CAB_BLOCKSIZE + 12;

View file

@ -22,15 +22,15 @@ public:
/* Default destructor */
virtual ~CMSZipCodec();
/* Compresses a data block */
virtual unsigned long Compress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength);
virtual uint32_t Compress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength);
/* Uncompresses a data block */
virtual unsigned long Uncompress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength);
virtual uint32_t Uncompress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength);
private:
int Status;
z_stream ZStream; /* Zlib stream */

View file

@ -9,6 +9,7 @@
* CSH 21/03-2001 Created
* CSH 15/08-2003 Made it portable
* CF 04/05-2007 Reformatted the code to be more consistent and use TABs instead of spaces
* CF 04/05-2007 Made it compatible with 64-bit operating systems
*/
#include "raw.h"
@ -31,10 +32,10 @@ CRawCodec::~CRawCodec()
}
unsigned long CRawCodec::Compress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength)
uint32_t CRawCodec::Compress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength)
/*
* FUNCTION: Compresses data in a buffer
* ARGUMENTS:
@ -49,10 +50,10 @@ unsigned long CRawCodec::Compress(void* OutputBuffer,
return CS_SUCCESS;
}
unsigned long CRawCodec::Uncompress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength)
uint32_t CRawCodec::Uncompress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength)
/*
* FUNCTION: Uncompresses data in a buffer
* ARGUMENTS:

View file

@ -19,15 +19,15 @@ public:
/* Default destructor */
virtual ~CRawCodec();
/* Compresses a data block */
virtual unsigned long Compress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength);
virtual uint32_t Compress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength);
/* Uncompresses a data block */
virtual unsigned long Uncompress(void* OutputBuffer,
void* InputBuffer,
unsigned long InputLength,
unsigned long* OutputLength);
virtual uint32_t Uncompress(void* OutputBuffer,
void* InputBuffer,
uint32_t InputLength,
uint32_t* OutputLength);
};
#endif /* __RAW_H */