Author: cwittich Date: Sun May 27 14:26:43 2007 New Revision: 26912
URL: http://svn.reactos.org/svn/reactos?rev=26912&view=rev Log: 64-Bit Fixes for cabman (patch from Colin Finck) See issue #2236 for more details.
Modified: trunk/reactos/tools/cabman/cabinet.cxx trunk/reactos/tools/cabman/cabinet.h trunk/reactos/tools/cabman/cabman.h trunk/reactos/tools/cabman/dfp.cxx trunk/reactos/tools/cabman/dfp.h trunk/reactos/tools/cabman/main.cxx trunk/reactos/tools/cabman/mszip.cxx trunk/reactos/tools/cabman/mszip.h trunk/reactos/tools/cabman/raw.cxx trunk/reactos/tools/cabman/raw.h
Modified: trunk/reactos/tools/cabman/cabinet.cxx URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/cabinet.cxx?re... ============================================================================== --- trunk/reactos/tools/cabman/cabinet.cxx (original) +++ trunk/reactos/tools/cabman/cabinet.cxx Sun May 27 14:26:43 2007 @@ -10,6 +10,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 * TODO: * - Checksum of datablocks should be calculated * - EXTRACT.EXE complains if a disk is created manually @@ -27,31 +28,31 @@
#if defined(WIN32) #define GetSizeOfFile(handle) _GetSizeOfFile(handle) -static long _GetSizeOfFile(FILEHANDLE handle) -{ - unsigned long size = GetFileSize(handle, NULL); +static int32_t _GetSizeOfFile(FILEHANDLE handle) +{ + 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) -{ - return ReadFile(handle, buffer, size, bytesread, NULL) != 0; +static bool _ReadFileData(FILEHANDLE handle, void* buffer, uint32_t size, uint32_t* bytesread) +{ + return ReadFile(handle, buffer, size, (LPDWORD)bytesread, NULL) != 0; } #else #define GetSizeOfFile(handle) _GetSizeOfFile(handle) -static long _GetSizeOfFile(FILEHANDLE handle) -{ - long size; +static int32_t _GetSizeOfFile(FILEHANDLE handle) +{ + 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; @@ -63,10 +64,10 @@ #if 0 #ifdef DBG
-void DumpBuffer(void* Buffer, unsigned long Size) +void DumpBuffer(void* Buffer, uint32_t Size) { FILEHANDLE FileHandle; - unsigned long BytesWritten; + uint32_t BytesWritten;
/* Create file, overwrite if it already exists */ FileHandle = CreateFile("dump.bin", // Create this file @@ -113,7 +114,7 @@ }
-unsigned long CCFDATAStorage::Create(char* FileName) +uint32_t CCFDATAStorage::Create(char* FileName) /* * FUNCTION: Creates the file * ARGUMENTS: @@ -164,7 +165,7 @@ }
-unsigned long CCFDATAStorage::Destroy() +uint32_t CCFDATAStorage::Destroy() /* * FUNCTION: Destroys the file * RETURNS: @@ -181,7 +182,7 @@ }
-unsigned long CCFDATAStorage::Truncate() +uint32_t CCFDATAStorage::Truncate() /* * FUNCTION: Truncate the scratch file to zero bytes * RETURNS: @@ -206,7 +207,7 @@ }
-unsigned long CCFDATAStorage::Position() +uint32_t CCFDATAStorage::Position() /* * FUNCTION: Returns current position in file * RETURNS: @@ -216,12 +217,12 @@ #if defined(WIN32) return SetFilePointer(FileHandle, 0, NULL, FILE_CURRENT); #else - return (unsigned long)ftell(FileHandle); -#endif -} - - -unsigned long CCFDATAStorage::Seek(long Position) + return (uint32_t)ftell(FileHandle); +#endif +} + + +uint32_t CCFDATAStorage::Seek(int32_t Position) /* * FUNCTION: Seeks to an absolute position * ARGUMENTS: @@ -247,7 +248,7 @@ }
-unsigned long CCFDATAStorage::ReadBlock(PCFDATA Data, void* Buffer, unsigned long* BytesRead) +uint32_t CCFDATAStorage::ReadBlock(PCFDATA Data, void* Buffer, uint32_t* BytesRead) /* * FUNCTION: Reads a CFDATA block from the file * ARGUMENTS: @@ -259,7 +260,7 @@ */ { #if defined(WIN32) - if (!ReadFile(FileHandle, Buffer, Data->CompSize, BytesRead, NULL)) + if (!ReadFile(FileHandle, Buffer, Data->CompSize, (LPDWORD)BytesRead, NULL)) return CAB_STATUS_CANNOT_READ; #else
@@ -271,7 +272,7 @@ }
-unsigned long CCFDATAStorage::WriteBlock(PCFDATA Data, void* Buffer, unsigned long* BytesWritten) +uint32_t CCFDATAStorage::WriteBlock(PCFDATA Data, void* Buffer, uint32_t* BytesWritten) /* * FUNCTION: Writes a CFDATA block to the file * ARGUMENTS: @@ -283,7 +284,7 @@ */ { #if defined(WIN32) - if (!WriteFile(FileHandle, Buffer, Data->CompSize, BytesWritten, NULL)) + if (!WriteFile(FileHandle, Buffer, Data->CompSize, (LPDWORD)BytesWritten, NULL)) return CAB_STATUS_CANNOT_WRITE; #else *BytesWritten = fwrite(Buffer, 1, Data->CompSize, FileHandle); @@ -391,15 +392,15 @@ while (Path[i] != 0) { #if defined(WIN32) - if (Path[i] == '/') - newpath[i] = '\'; - else + if (Path[i] == '/') + newpath[i] = '\'; + else #else - if (Path[i] == '\') - newpath[i] = '/'; + if (Path[i] == '\') + newpath[i] = '/'; else #endif - newpath[i] = Path[i]; + newpath[i] = Path[i];
i++; } @@ -418,7 +419,7 @@ * Pointer to filename */ { - unsigned long i, j; + uint32_t i, j;
j = i = (Path[0] ? (Path[1] == ':' ? 2 : 0) : 0);
@@ -438,7 +439,7 @@ */ { char* FileName; - unsigned long i; + uint32_t i;
i = (Path [0] ? (Path[1] == ':' ? 2 : 0) : 0); FileName = GetFileName(Path + i); @@ -452,7 +453,7 @@
bool CCabinet::NormalizePath(char* Path, - unsigned long Length) + uint32_t Length) /* * FUNCTION: Normalizes a path * ARGUMENTS: @@ -462,10 +463,10 @@ * true if there was enough room in Path, or false */ { - unsigned long n; + uint32_t n; bool OK = true;
- if ((n = strlen(Path)) && + if ((n = (uint32_t)strlen(Path)) && (!IsSeparator(Path[n - 1])) && (OK = ((n + 1) < Length))) { @@ -531,7 +532,7 @@ */ { FILEHANDLE FileHandle; - unsigned long BytesRead; + uint32_t BytesRead;
#if defined(WIN32) FileHandle = CreateFile(ConvertPath(FileName, true), // Open this file @@ -556,7 +557,7 @@ #endif
CabinetReservedFileSize = GetSizeOfFile(FileHandle); - if (CabinetReservedFileSize == (unsigned long)-1) + if (CabinetReservedFileSize == (uint32_t)-1) { DPRINT(MIN_TRACE, ("Cannot read from cabinet reserved file.\n")); return false; @@ -600,7 +601,7 @@ }
-unsigned long CCabinet::GetCurrentDiskNumber() +uint32_t CCabinet::GetCurrentDiskNumber() /* * FUNCTION: Returns current disk number * RETURNS: @@ -611,7 +612,7 @@ }
-unsigned long CCabinet::Open() +uint32_t CCabinet::Open() /* * FUNCTION: Opens a cabinet file * RETURNS: @@ -619,13 +620,13 @@ */ { PCFFOLDER_NODE FolderNode; - unsigned long Status; - unsigned long Index; + uint32_t Status; + uint32_t Index;
if (!FileOpen) { - unsigned long BytesRead; - unsigned long Size; + uint32_t BytesRead; + uint32_t Size;
OutputBuffer = AllocateMemory(CAB_BLOCKSIZE + 12); // This should be enough if (!OutputBuffer) @@ -682,7 +683,7 @@ /* Read/skip any reserved bytes */ if (CABHeader.Flags & CAB_FLAG_RESERVE) { - if ((Status = ReadBlock(&Size, sizeof(unsigned long), &BytesRead)) + if ((Status = ReadBlock(&Size, sizeof(uint32_t), &BytesRead)) != CAB_STATUS_SUCCESS) { DPRINT(MIN_TRACE, ("Cannot read from file (%d).\n", (unsigned int)Status)); @@ -803,8 +804,8 @@ }
-unsigned long CCabinet::FindFirst(char* FileName, - PCAB_SEARCH Search) +uint32_t CCabinet::FindFirst(char* FileName, + PCAB_SEARCH Search) /* * FUNCTION: Finds the first file in the cabinet that matches a search criteria * ARGUMENTS: @@ -821,7 +822,7 @@ }
-unsigned long CCabinet::FindNext(PCAB_SEARCH Search) +uint32_t CCabinet::FindNext(PCAB_SEARCH Search) /* * FUNCTION: Finds next file in the cabinet that matches a search criteria * ARGUMENTS: @@ -830,9 +831,10 @@ * Status of operation */ { - unsigned long Status; - - if (RestartSearch) { + uint32_t Status; + + if (RestartSearch) + { Search->Next = FileListHead;
/* Skip split files already extracted */ @@ -850,8 +852,10 @@
/* FIXME: Check search criteria */
- if (!Search->Next) { - if (strlen(DiskNext) > 0) { + if (!Search->Next) + { + if (strlen(DiskNext) > 0) + { CloseCabinet();
SetCabinetName(CabinetNext); @@ -865,7 +869,8 @@ Search->Next = FileListHead; if (!Search->Next) return CAB_STATUS_NOFILE; - } else + } + else return CAB_STATUS_NOFILE; }
@@ -876,7 +881,7 @@ }
-unsigned long CCabinet::ExtractFile(char* FileName) +uint32_t CCabinet::ExtractFile(char* FileName) /* * FUNCTION: Extracts a file from the cabinet * ARGUMENTS: @@ -885,21 +890,21 @@ * Status of operation */ { - unsigned long Size; - unsigned long Offset; - unsigned long BytesRead; - unsigned long BytesToRead; - unsigned long BytesWritten; - unsigned long BytesSkipped; - unsigned long BytesToWrite; - unsigned long TotalBytesRead; - unsigned long CurrentOffset; + uint32_t Size; + uint32_t Offset; + uint32_t BytesRead; + uint32_t BytesToRead; + uint32_t BytesWritten; + uint32_t BytesSkipped; + uint32_t BytesToWrite; + uint32_t TotalBytesRead; + uint32_t CurrentOffset; unsigned char* Buffer; unsigned char* CurrentBuffer; FILEHANDLE DestFile; PCFFILE_NODE File; CFDATA CFData; - unsigned long Status; + uint32_t Status; bool Skip; #if defined(WIN32) FILETIME FileTime; @@ -1084,7 +1089,7 @@ BytesToRead = CFData.CompSize;
DPRINT(MAX_TRACE, ("Read: (0x%lX,0x%lX).\n", - (long unsigned int)CurrentBuffer, (long unsigned int)Buffer)); + (uintptr_t)CurrentBuffer, (uintptr_t)Buffer));
if (((Status = ReadBlock(CurrentBuffer, BytesToRead, &BytesRead)) != CAB_STATUS_SUCCESS) || (BytesToRead != BytesRead)) @@ -1099,7 +1104,7 @@ /* if (CFData.Checksum != 0) { - unsigned long Checksum = ComputeChecksum(CurrentBuffer, BytesRead, 0); + uint32_t Checksum = ComputeChecksum(CurrentBuffer, BytesRead, 0); if (Checksum != CFData.Checksum) { CloseFile(DestFile); @@ -1264,14 +1269,14 @@ (unsigned int)Size));
#if defined(WIN32) - if (!WriteFile(DestFile, (void*)((unsigned long)OutputBuffer + BytesSkipped), - BytesToWrite, &BytesWritten, NULL) || + if (!WriteFile(DestFile, (void*)((uintptr_t)OutputBuffer + BytesSkipped), + BytesToWrite, (LPDWORD)&BytesWritten, NULL) || (BytesToWrite != BytesWritten)) { DPRINT(MIN_TRACE, ("Status 0x%lX.\n", GetLastError())); #else BytesWritten = BytesToWrite; - if (fwrite((void*)((unsigned long)OutputBuffer + BytesSkipped), + if (fwrite((void*)((uintptr_t)OutputBuffer + BytesSkipped), BytesToWrite, 1, DestFile) < 1) { #endif @@ -1297,7 +1302,7 @@ }
-void CCabinet::SelectCodec(unsigned long Id) +void CCabinet::SelectCodec(uint32_t Id) /* * FUNCTION: Selects codec engine to use * ARGUMENTS: @@ -1338,14 +1343,14 @@
/* CAB write methods */
-unsigned long CCabinet::NewCabinet() +uint32_t CCabinet::NewCabinet() /* * FUNCTION: Creates a new cabinet * RETURNS: * Status of operation */ { - unsigned long Status; + uint32_t Status;
CurrentDiskNumber = 0;
@@ -1409,7 +1414,7 @@ }
-unsigned long CCabinet::NewDisk() +uint32_t CCabinet::NewDisk() /* * FUNCTION: Forces a new disk to be created * RETURNS: @@ -1433,7 +1438,7 @@ }
-unsigned long CCabinet::NewFolder() +uint32_t CCabinet::NewFolder() /* * FUNCTION: Forces a new folder to be created * RETURNS: @@ -1478,7 +1483,7 @@ }
-unsigned long CCabinet::WriteFileToScratchStorage(PCFFILE_NODE FileNode) +uint32_t CCabinet::WriteFileToScratchStorage(PCFFILE_NODE FileNode) /* * FUNCTION: Writes a file to the scratch file * ARGUMENTS: @@ -1487,10 +1492,10 @@ * Status of operation */ { - unsigned long BytesToRead; - unsigned long BytesRead; - unsigned long Status; - unsigned long Size; + uint32_t BytesToRead; + uint32_t BytesRead; + uint32_t Status; + uint32_t Size;
if (!ContinueFile) { @@ -1535,11 +1540,11 @@
FileNode->File.FileOffset = CurrentFolderNode->UncompOffset; CurrentFolderNode->UncompOffset += TotalBytesLeft; - FileNode->File.FileControlID = (unsigned short)(NextFolderNumber - 1); + FileNode->File.FileControlID = (uint16_t)(NextFolderNumber - 1); CurrentFolderNode->Commit = true; PrevCabinetNumber = CurrentDiskNumber;
- Size = sizeof(CFFILE) + strlen(GetFileName(FileNode->FileName)) + 1; + Size = sizeof(CFFILE) + (uint32_t)strlen(GetFileName(FileNode->FileName)) + 1; CABHeader.FileTableOffset += Size; TotalFileSize += Size; DiskSize += Size; @@ -1551,7 +1556,7 @@ { do { - if (TotalBytesLeft > (unsigned long)CAB_BLOCKSIZE - CurrentIBufferSize) + if (TotalBytesLeft > (uint32_t)CAB_BLOCKSIZE - CurrentIBufferSize) BytesToRead = CAB_BLOCKSIZE - CurrentIBufferSize; else BytesToRead = TotalBytesLeft; @@ -1565,7 +1570,7 @@
*(unsigned char**)&CurrentIBuffer += BytesRead;
- CurrentIBufferSize += (unsigned short)BytesRead; + CurrentIBufferSize += (uint16_t)BytesRead;
if (CurrentIBufferSize == CAB_BLOCKSIZE) { @@ -1609,7 +1614,7 @@ }
-unsigned long CCabinet::WriteDisk(unsigned long MoreDisks) +uint32_t CCabinet::WriteDisk(uint32_t MoreDisks) /* * FUNCTION: Forces the current disk to be written * ARGUMENTS: @@ -1619,7 +1624,7 @@ */ { PCFFILE_NODE FileNode; - unsigned long Status; + uint32_t Status;
ContinueFile = false; FileNode = FileListHead; @@ -1695,7 +1700,7 @@ }
-unsigned long CCabinet::CommitDisk(unsigned long MoreDisks) +uint32_t CCabinet::CommitDisk(uint32_t MoreDisks) /* * FUNCTION: Commits the current disk * ARGUMENTS: @@ -1705,7 +1710,7 @@ */ { PCFFOLDER_NODE FolderNode; - unsigned long Status; + uint32_t Status;
OnCabinetName(CurrentDiskNumber, CabinetName);
@@ -1720,7 +1725,7 @@ NULL); // No attribute template if (FileHandle == INVALID_HANDLE_VALUE) { - unsigned long Status; + uint32_t Status; /* If file exists, ask to overwrite file */ if (((Status = GetLastError()) == ERROR_FILE_EXISTS) && (OnOverwrite(NULL, CabinetName))) @@ -1801,7 +1806,7 @@ }
-unsigned long CCabinet::CloseDisk() +uint32_t CCabinet::CloseDisk() /* * FUNCTION: Closes the current disk * RETURNS: @@ -1819,14 +1824,14 @@ }
-unsigned long CCabinet::CloseCabinet() +uint32_t CCabinet::CloseCabinet() /* * FUNCTION: Closes the current cabinet * RETURNS: * Status of operation */ { - unsigned long Status; + uint32_t Status;
DestroyFileNodes();
@@ -1857,7 +1862,7 @@ }
-unsigned long CCabinet::AddFile(char* FileName) +uint32_t CCabinet::AddFile(char* FileName) /* * FUNCTION: Adds a file to the current disk * ARGUMENTS: @@ -1918,7 +1923,7 @@
/* FIXME: Check for and handle large files (>= 2GB) */ FileNode->File.FileSize = GetSizeOfFile(SrcFile); - if (FileNode->File.FileSize == (unsigned long)-1) + if (FileNode->File.FileSize == (uint32_t)-1) { DPRINT(MIN_TRACE, ("Cannot read from file.\n")); FreeMemory(NewFileName); @@ -1935,7 +1940,7 @@ }
-void CCabinet::SetMaxDiskSize(unsigned long Size) +void CCabinet::SetMaxDiskSize(uint32_t Size) /* * FUNCTION: Sets the maximum size of the current disk * ARGUMENTS: @@ -2003,7 +2008,7 @@ }
-bool CCabinet::OnDiskLabel(unsigned long Number, char* Label) +bool CCabinet::OnDiskLabel(uint32_t Number, char* Label) /* * FUNCTION: Called when a disk needs a label * ARGUMENTS: @@ -2017,7 +2022,7 @@ }
-bool CCabinet::OnCabinetName(unsigned long Number, char* Name) +bool CCabinet::OnCabinetName(uint32_t Number, char* Name) /* * FUNCTION: Called when a cabinet needs a name * ARGUMENTS: @@ -2032,7 +2037,7 @@
#endif /* CAB_READ_ONLY */
-PCFFOLDER_NODE CCabinet::LocateFolderNode(unsigned long Index) +PCFFOLDER_NODE CCabinet::LocateFolderNode(uint32_t Index) /* * FUNCTION: Locates a folder node * ARGUMENTS: @@ -2064,7 +2069,7 @@ }
-unsigned long CCabinet::GetAbsoluteOffset(PCFFILE_NODE File) +uint32_t CCabinet::GetAbsoluteOffset(PCFFILE_NODE File) /* * FUNCTION: Returns the absolute offset of a file * ARGUMENTS: @@ -2105,8 +2110,8 @@ }
-unsigned long CCabinet::LocateFile(char* FileName, - PCFFILE_NODE *File) +uint32_t CCabinet::LocateFile(char* FileName, + PCFFILE_NODE *File) /* * FUNCTION: Locates a file in the cabinet * ARGUMENTS: @@ -2119,7 +2124,7 @@ */ { PCFFILE_NODE Node; - unsigned long Status; + uint32_t Status;
DPRINT(MAX_TRACE, ("FileName '%s'\n", FileName));
@@ -2150,7 +2155,7 @@ }
-unsigned long CCabinet::ReadString(char* String, unsigned long MaxLength) +uint32_t CCabinet::ReadString(char* String, uint32_t MaxLength) /* * FUNCTION: Reads a NULL-terminated string from the cabinet * ARGUMENTS: @@ -2160,10 +2165,10 @@ * Status of operation */ { - unsigned long BytesRead; - unsigned long Offset; - unsigned long Status; - unsigned long Size; + uint32_t BytesRead; + uint32_t Offset; + uint32_t Status; + uint32_t Size; bool Found;
Offset = 0; @@ -2203,7 +2208,7 @@ #if defined(WIN32) SetLastError(NO_ERROR); (unsigned int)SetFilePointer(FileHandle, - -(long)Size, + -(int32_t)Size, NULL, FILE_CURRENT); if (GetLastError() != NO_ERROR) @@ -2212,7 +2217,7 @@ return CAB_STATUS_INVALID_CAB; } #else - if (fseek(FileHandle, (off_t)(-(long)Size), SEEK_CUR) != 0) + if (fseek(FileHandle, (off_t)(-(int32_t)Size), SEEK_CUR) != 0) { DPRINT(MIN_TRACE, ("fseek() failed.\n")); return CAB_STATUS_INVALID_CAB; @@ -2222,16 +2227,16 @@ }
-unsigned long CCabinet::ReadFileTable() +uint32_t CCabinet::ReadFileTable() /* * FUNCTION: Reads the file table from the cabinet file * RETURNS: * Status of operation */ { - unsigned long i; - unsigned long Status; - unsigned long BytesRead; + uint32_t i; + uint32_t Status; + uint32_t BytesRead; PCFFILE_NODE File;
DPRINT(MAX_TRACE, ("Reading file table at absolute offset (0x%lX).\n", @@ -2240,7 +2245,7 @@ /* Seek to file table */ #if defined(WIN32) SetLastError(NO_ERROR); - (unsigned int)SetFilePointer(FileHandle, + SetFilePointer(FileHandle, CABHeader.FileTableOffset, NULL, FILE_BEGIN); @@ -2297,7 +2302,7 @@ }
-unsigned long CCabinet::ReadDataBlocks(PCFFOLDER_NODE FolderNode) +uint32_t CCabinet::ReadDataBlocks(PCFFOLDER_NODE FolderNode) /* * FUNCTION: Reads all CFDATA blocks for a folder from the cabinet file * ARGUMENTS: @@ -2306,12 +2311,12 @@ * Status of operation */ { - unsigned long AbsoluteOffset; - unsigned long UncompOffset; + uint32_t AbsoluteOffset; + uint32_t UncompOffset; PCFDATA_NODE Node; - unsigned long BytesRead; - unsigned long Status; - unsigned long i; + uint32_t BytesRead; + uint32_t Status; + uint32_t i;
DPRINT(MAX_TRACE, ("Reading data blocks for folder (%lu) at absolute offset (0x%lX).\n", FolderNode->Index, FolderNode->Folder.DataOffset)); @@ -2546,7 +2551,7 @@
DPRINT(MAX_TRACE, ("Deleting file: '%s'\n", CurNode->FileName));
- TotalFileSize -= (sizeof(CFFILE) + strlen(GetFileName(CurNode->FileName)) + 1); + TotalFileSize -= (sizeof(CFFILE) + (uint32_t)strlen(GetFileName(CurNode->FileName)) + 1);
if (CurNode->FileName) FreeMemory(CurNode->FileName); @@ -2621,9 +2626,9 @@ }
-unsigned long CCabinet::ComputeChecksum(void* Buffer, - unsigned int Size, - unsigned long Seed) +uint32_t CCabinet::ComputeChecksum(void* Buffer, + unsigned int Size, + uint32_t Seed) /* * FUNCTION: Computes checksum for data block * ARGUMENTS: @@ -2635,9 +2640,9 @@ */ { int UlongCount; // Number of ULONGs in block - unsigned long Checksum; // Checksum accumulator + uint32_t Checksum; // Checksum accumulator unsigned char* pb; - unsigned long ul; + uint32_t ul;
/* FIXME: Doesn't seem to be correct. EXTRACT.EXE won't accept checksums computed by this routine */ @@ -2651,11 +2656,11 @@ /* Checksum integral multiple of ULONGs */ while (UlongCount-- > 0) { - /* NOTE: Build unsigned long in big/little-endian independent manner */ + /* NOTE: Build uint32_t in big/little-endian independent manner */ ul = *pb++; // Get low-order byte - ul |= (((unsigned long)(*pb++)) << 8); // Add 2nd byte - ul |= (((unsigned long)(*pb++)) << 16); // Add 3nd byte - ul |= (((unsigned long)(*pb++)) << 24); // Add 4th byte + ul |= (((uint32_t)(*pb++)) << 8); // Add 2nd byte + ul |= (((uint32_t)(*pb++)) << 16); // Add 3nd byte + ul |= (((uint32_t)(*pb++)) << 24); // Add 4th byte
Checksum ^= ul; // Update checksum } @@ -2665,9 +2670,9 @@ switch (Size % 4) { case 3: - ul |= (((unsigned long)(*pb++)) << 16); // Add 3rd byte + ul |= (((uint32_t)(*pb++)) << 16); // Add 3rd byte case 2: - ul |= (((unsigned long)(*pb++)) << 8); // Add 2nd byte + ul |= (((uint32_t)(*pb++)) << 8); // Add 2nd byte case 1: ul |= *pb++; // Get low-order byte default: @@ -2680,15 +2685,15 @@ }
-unsigned long CCabinet::ReadBlock(void* Buffer, - unsigned long Size, - unsigned long* BytesRead) +uint32_t CCabinet::ReadBlock(void* Buffer, + uint32_t Size, + uint32_t* BytesRead) /* * FUNCTION: Read a block of data from file * ARGUMENTS: * Buffer = Pointer to data buffer * Size = Length of data buffer - * BytesRead = Pointer to unsigned long that on return will contain + * BytesRead = Pointer to uint32_t that on return will contain * number of bytes read * RETURNS: * Status of operation @@ -2701,22 +2706,22 @@
#ifndef CAB_READ_ONLY
-unsigned long CCabinet::InitCabinetHeader() +uint32_t CCabinet::InitCabinetHeader() /* * FUNCTION: Initializes cabinet header and optional fields * RETURNS: * Status of operation */ { - unsigned long TotalSize; - unsigned long Size; + uint32_t TotalSize; + uint32_t Size;
CABHeader.FileTableOffset = 0; // Not known yet CABHeader.FolderCount = 0; // Not known yet CABHeader.FileCount = 0; // Not known yet CABHeader.Flags = 0; // Not known yet
- CABHeader.CabinetNumber = (unsigned short)CurrentDiskNumber; + CABHeader.CabinetNumber = (uint16_t)CurrentDiskNumber;
if ((CurrentDiskNumber > 0) && (OnCabinetName(PrevCabinetNumber, CabinetPrev))) { @@ -2740,10 +2745,10 @@ DPRINT(MAX_TRACE, ("CabinetPrev '%s'.\n", CabinetPrev));
/* Calculate size of name of previous cabinet */ - TotalSize += strlen(CabinetPrev) + 1; + TotalSize += (uint32_t)strlen(CabinetPrev) + 1;
/* Calculate size of label of previous disk */ - TotalSize += strlen(DiskPrev) + 1; + TotalSize += (uint32_t)strlen(DiskPrev) + 1; }
if ((CABHeader.Flags & CAB_FLAG_HASNEXT) > 0) @@ -2752,12 +2757,12 @@ DPRINT(MAX_TRACE, ("CabinetNext '%s'.\n", CabinetNext));
/* Calculate size of name of next cabinet */ - Size = strlen(CabinetNext) + 1; + Size = (uint32_t)strlen(CabinetNext) + 1; TotalSize += Size; NextFieldsSize = Size;
/* Calculate size of label of next disk */ - Size = strlen(DiskNext) + 1; + Size = (uint32_t)strlen(DiskNext) + 1; TotalSize += Size; NextFieldsSize += Size; } @@ -2769,7 +2774,7 @@ { CABHeader.Flags |= CAB_FLAG_RESERVE; TotalSize += CabinetReservedFileSize; - TotalSize += sizeof(unsigned long); /* For CabinetResSize, FolderResSize, and FileResSize fields */ + TotalSize += sizeof(uint32_t); /* For CabinetResSize, FolderResSize, and FileResSize fields */ }
DiskSize += TotalSize; @@ -2780,7 +2785,7 @@ }
-unsigned long CCabinet::WriteCabinetHeader(bool MoreDisks) +uint32_t CCabinet::WriteCabinetHeader(bool MoreDisks) /* * FUNCTION: Writes the cabinet header and optional fields * ARGUMENTS: @@ -2791,8 +2796,8 @@ { PCFFOLDER_NODE FolderNode; PCFFILE_NODE FileNode; - unsigned long BytesWritten; - unsigned long Size; + uint32_t BytesWritten; + uint32_t Size;
if (MoreDisks) { @@ -2836,9 +2841,9 @@
CABHeader.CabinetSize = DiskSize;
- /* Write header */ -#if defined(WIN32) - if (!WriteFile(FileHandle, &CABHeader, sizeof(CFHEADER), &BytesWritten, NULL)) + /* Write header */ +#if defined(WIN32) + if (!WriteFile(FileHandle, &CABHeader, sizeof(CFHEADER), (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -2855,20 +2860,20 @@ /* Write per-cabinet reserved area if present */ if (CABHeader.Flags & CAB_FLAG_RESERVE) { - unsigned long ReservedSize; + uint32_t ReservedSize;
ReservedSize = CabinetReservedFileSize & 0xffff; ReservedSize |= (0 << 16); /* Folder reserved area size */ ReservedSize |= (0 << 24); /* Folder reserved area size */ #if defined(WIN32) - if (!WriteFile(FileHandle, &ReservedSize, sizeof(unsigned long), &BytesWritten, NULL)) + if (!WriteFile(FileHandle, &ReservedSize, sizeof(uint32_t), (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; } #else - BytesWritten = sizeof(unsigned long); - if (fwrite(&ReservedSize, sizeof(unsigned long), 1, FileHandle) < 1) + BytesWritten = sizeof(uint32_t); + if (fwrite(&ReservedSize, sizeof(uint32_t), 1, FileHandle) < 1) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -2876,7 +2881,7 @@ #endif
#if defined(WIN32) - if (!WriteFile(FileHandle, CabinetReservedFileBuffer, CabinetReservedFileSize, &BytesWritten, NULL)) + if (!WriteFile(FileHandle, CabinetReservedFileBuffer, CabinetReservedFileSize, (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -2896,9 +2901,9 @@ DPRINT(MAX_TRACE, ("CabinetPrev '%s'.\n", CabinetPrev));
/* Write name of previous cabinet */ - Size = strlen(CabinetPrev) + 1; -#if defined(WIN32) - if (!WriteFile(FileHandle, CabinetPrev, Size, &BytesWritten, NULL)) + Size = (uint32_t)strlen(CabinetPrev) + 1; +#if defined(WIN32) + if (!WriteFile(FileHandle, CabinetPrev, Size, (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -2915,9 +2920,9 @@ DPRINT(MAX_TRACE, ("DiskPrev '%s'.\n", DiskPrev));
/* Write label of previous disk */ - Size = strlen(DiskPrev) + 1; -#if defined(WIN32) - if (!WriteFile(FileHandle, DiskPrev, Size, &BytesWritten, NULL)) + Size = (uint32_t)strlen(DiskPrev) + 1; +#if defined(WIN32) + if (!WriteFile(FileHandle, DiskPrev, Size, (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -2937,9 +2942,9 @@ DPRINT(MAX_TRACE, ("CabinetNext '%s'.\n", CabinetNext));
/* Write name of next cabinet */ - Size = strlen(CabinetNext) + 1; -#if defined(WIN32) - if (!WriteFile(FileHandle, CabinetNext, Size, &BytesWritten, NULL)) + Size = (uint32_t)strlen(CabinetNext) + 1; +#if defined(WIN32) + if (!WriteFile(FileHandle, CabinetNext, Size, (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -2956,9 +2961,9 @@ DPRINT(MAX_TRACE, ("DiskNext '%s'.\n", DiskNext));
/* Write label of next disk */ - Size = strlen(DiskNext) + 1; -#if defined(WIN32) - if (!WriteFile(FileHandle, DiskNext, Size, &BytesWritten, NULL)) + Size = (uint32_t)strlen(DiskNext) + 1; +#if defined(WIN32) + if (!WriteFile(FileHandle, DiskNext, Size, (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -2977,7 +2982,7 @@ }
-unsigned long CCabinet::WriteFolderEntries() +uint32_t CCabinet::WriteFolderEntries() /* * FUNCTION: Writes folder entries * RETURNS: @@ -2985,7 +2990,7 @@ */ { PCFFOLDER_NODE FolderNode; - unsigned long BytesWritten; + uint32_t BytesWritten;
DPRINT(MAX_TRACE, ("Writing folder table.\n"));
@@ -2999,10 +3004,10 @@
#if defined(WIN32) if (!WriteFile(FileHandle, - &FolderNode->Folder, - sizeof(CFFOLDER), - &BytesWritten, - NULL)) + &FolderNode->Folder, + sizeof(CFFOLDER), + (LPDWORD)&BytesWritten, + NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -3023,7 +3028,7 @@ }
-unsigned long CCabinet::WriteFileEntries() +uint32_t CCabinet::WriteFileEntries() /* * FUNCTION: Writes file entries for all files * RETURNS: @@ -3031,7 +3036,7 @@ */ { PCFFILE_NODE File; - unsigned long BytesWritten; + uint32_t BytesWritten; bool SetCont = false;
DPRINT(MAX_TRACE, ("Writing file table.\n")); @@ -3063,7 +3068,7 @@ if (!WriteFile(FileHandle, &File->File, sizeof(CFFILE), - &BytesWritten, + (LPDWORD)&BytesWritten, NULL)) return CAB_STATUS_CANNOT_WRITE; #else @@ -3078,7 +3083,9 @@ #if defined(WIN32) if (!WriteFile(FileHandle, GetFileName(File->FileName), - strlen(GetFileName(File->FileName)) + 1, &BytesWritten, NULL)) + (DWORD)strlen(GetFileName(File->FileName)) + 1, + (LPDWORD)&BytesWritten, + NULL)) return CAB_STATUS_CANNOT_WRITE; #else BytesWritten = strlen(GetFileName(File->FileName)) + 1; @@ -3102,7 +3109,7 @@ }
-unsigned long CCabinet::CommitDataBlocks(PCFFOLDER_NODE FolderNode) +uint32_t CCabinet::CommitDataBlocks(PCFFOLDER_NODE FolderNode) /* * FUNCTION: Writes data blocks to the cabinet * ARGUMENTS: @@ -3112,9 +3119,9 @@ */ { PCFDATA_NODE DataNode; - unsigned long BytesWritten; - unsigned long BytesRead; - unsigned long Status; + uint32_t BytesWritten; + uint32_t BytesRead; + uint32_t Status;
DataNode = FolderNode->DataListHead; if (DataNode != NULL) @@ -3139,7 +3146,7 @@
#if defined(WIN32) if (!WriteFile(FileHandle, &DataNode->Data, - sizeof(CFDATA), &BytesWritten, NULL)) + sizeof(CFDATA), (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -3155,7 +3162,7 @@
#if defined(WIN32) if (!WriteFile(FileHandle, InputBuffer, - DataNode->Data.CompSize, &BytesWritten, NULL)) + DataNode->Data.CompSize, (LPDWORD)&BytesWritten, NULL)) { DPRINT(MIN_TRACE, ("Cannot write to file.\n")); return CAB_STATUS_CANNOT_WRITE; @@ -3175,15 +3182,15 @@ }
-unsigned long CCabinet::WriteDataBlock() +uint32_t CCabinet::WriteDataBlock() /* * FUNCTION: Writes the current data block to the scratch file * RETURNS: * Status of operation */ { - unsigned long Status; - unsigned long BytesWritten; + uint32_t Status; + uint32_t BytesWritten; PCFDATA_NODE DataNode;
if (!BlockIsSplit) @@ -3217,14 +3224,14 @@
if (BlockIsSplit) { - DataNode->Data.CompSize = (unsigned short)(MaxDiskSize - DiskSize); + DataNode->Data.CompSize = (uint16_t)(MaxDiskSize - DiskSize); DataNode->Data.UncompSize = 0; CreateNewDisk = true; } else { - DataNode->Data.CompSize = (unsigned short)CurrentOBufferSize; - DataNode->Data.UncompSize = (unsigned short)CurrentIBufferSize; + DataNode->Data.CompSize = (uint16_t)CurrentOBufferSize; + DataNode->Data.UncompSize = (uint16_t)CurrentIBufferSize; }
DataNode->Data.Checksum = 0; @@ -3266,8 +3273,8 @@ #if !defined(WIN32)
void CCabinet::ConvertDateAndTime(time_t* Time, - unsigned short* DosDate, - unsigned short* DosTime) + uint16_t* DosDate, + uint16_t* DosTime) /* * FUNCTION: Returns file times of a file * ARGUMENTS: @@ -3297,7 +3304,7 @@ #endif // !WIN32
-unsigned long CCabinet::GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File) +uint32_t CCabinet::GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File) /* * FUNCTION: Returns file times of a file * ARGUMENTS: @@ -3337,7 +3344,7 @@ }
-unsigned long CCabinet::GetAttributesOnFile(PCFFILE_NODE File) +uint32_t CCabinet::GetAttributesOnFile(PCFFILE_NODE File) /* * FUNCTION: Returns attributes on a file * ARGUMENTS: @@ -3347,7 +3354,7 @@ */ { #if defined(WIN32) - long Attributes; + int32_t Attributes;
Attributes = GetFileAttributes(File->FileName); if (Attributes == -1) @@ -3400,7 +3407,7 @@ }
-unsigned long CCabinet::SetAttributesOnFile(PCFFILE_NODE File) +uint32_t CCabinet::SetAttributesOnFile(PCFFILE_NODE File) /* * FUNCTION: Sets attributes on a file * ARGUMENTS: @@ -3410,7 +3417,7 @@ */ { #if defined(WIN32) - unsigned long Attributes = 0; + uint32_t Attributes = 0;
if (File->File.Attributes & CAB_ATTRIB_READONLY) Attributes |= FILE_ATTRIBUTE_READONLY;
Modified: trunk/reactos/tools/cabman/cabinet.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/cabinet.h?rev=... ============================================================================== --- trunk/reactos/tools/cabman/cabinet.h (original) +++ trunk/reactos/tools/cabman/cabinet.h Sun May 27 14:26:43 2007 @@ -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 @@
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 @@ { 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 @@ 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 @@ /* 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 @@ 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 @@ /* 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 */ };
Modified: trunk/reactos/tools/cabman/cabman.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/cabman.h?rev=2... ============================================================================== --- trunk/reactos/tools/cabman/cabman.h (original) +++ trunk/reactos/tools/cabman/cabman.h Sun May 27 14:26:43 2007 @@ -37,7 +37,7 @@ 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];
Modified: trunk/reactos/tools/cabman/dfp.cxx URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/dfp.cxx?rev=26... ============================================================================== --- trunk/reactos/tools/cabman/dfp.cxx (original) +++ trunk/reactos/tools/cabman/dfp.cxx Sun May 27 14:26:43 2007 @@ -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) -{ - unsigned long size = GetFileSize(handle, NULL); +static int32_t _GetSizeOfFile(FILEHANDLE handle) +{ + 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) -{ - return ReadFile(handle, buffer, size, bytesread, NULL); +static bool _ReadFileData(FILEHANDLE handle, void* buffer, uint32_t size, uint32_t* bytesread) +{ + return ReadFile(handle, buffer, size, (LPDWORD)bytesread, NULL); } #else #define GetSizeOfFile(handle) _GetSizeOfFile(handle) -static long _GetSizeOfFile(FILEHANDLE handle) -{ - long size; +static int32_t _GetSizeOfFile(FILEHANDLE handle) +{ + 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 @@ char eolbuf[2]; char* destpath; #if defined(WIN32) - unsigned long BytesWritten; + uint32_t BytesWritten; #endif
if (DontGenerateInf) @@ -173,7 +174,7 @@ }
#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 @@ 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 @@ }
-unsigned long CDFParser::Load(char* FileName) +uint32_t CDFParser::Load(char* FileName) /* * FUNCTION: Loads a directive file into memory * ARGUMENTS: @@ -208,8 +209,8 @@ * Status of operation */ { - unsigned long BytesRead; - long FileSize; + uint32_t BytesRead; + int32_t FileSize;
if (FileLoaded) return CAB_STATUS_SUCCESS; @@ -238,7 +239,7 @@ 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::Parse() +uint32_t CDFParser::Parse() /* * FUNCTION: Parses a loaded directive file * RETURNS: @@ -273,7 +274,7 @@ */ { bool Command; - unsigned long Status; + uint32_t Status;
if (!FileLoaded) return CAB_STATUS_NOFILE; @@ -436,7 +437,7 @@ }
-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 @@ { sprintf(Buffer, "%lu", Number); strcat(Label, Buffer); - j += strlen(Buffer); + j += (int)strlen(Buffer); } else { @@ -488,7 +489,7 @@ }
-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 @@ 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 @@ { sprintf(Buffer, "%lu", Number); strcat(Name, Buffer); - j += strlen(Buffer); + j += (int)strlen(Buffer); } else { @@ -543,7 +544,7 @@ }
-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::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::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::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::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 @@ }
-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 @@ }
-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 @@ * 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 @@ 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::PerformSetCommand() +uint32_t CDFParser::PerformSetCommand() /* * FUNCTION: Performs a set variable command * RETURNS: @@ -883,7 +884,7 @@ { 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::PerformNewCommand() +uint32_t CDFParser::PerformNewCommand() /* * FUNCTION: Performs a new disk|cabinet|folder command * RETURNS: @@ -978,7 +979,7 @@ */ { NEWTYPE NewType; - unsigned long Status; + uint32_t Status;
if (!IsNextToken(TokenIdentifier, true)) return CAB_STATUS_FAILURE; @@ -1053,7 +1054,7 @@ }
-unsigned long CDFParser::PerformInfBeginCommand() +uint32_t CDFParser::PerformInfBeginCommand() /* * FUNCTION: Begins inf mode * RETURNS: @@ -1065,7 +1066,7 @@ }
-unsigned long CDFParser::PerformInfEndCommand() +uint32_t CDFParser::PerformInfEndCommand() /* * FUNCTION: Begins inf mode * RETURNS: @@ -1077,7 +1078,7 @@ }
-unsigned long CDFParser::PerformCommand() +uint32_t CDFParser::PerformCommand() /* * FUNCTION: Performs a command * RETURNS: @@ -1097,15 +1098,15 @@ }
-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 @@
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 @@
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 @@ * 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 @@ * FUNCTION: Reads the next token from the current line */ { - unsigned long i; + uint32_t i; char ch = ' ';
if (CurrentChar >= LineLength)
Modified: trunk/reactos/tools/cabman/dfp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/dfp.h?rev=2691... ============================================================================== --- trunk/reactos/tools/cabman/dfp.h (original) +++ trunk/reactos/tools/cabman/dfp.h Sun May 27 14:26:43 2007 @@ -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 @@ 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 @@ 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 @@ 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;
Modified: trunk/reactos/tools/cabman/main.cxx URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/main.cxx?rev=2... ============================================================================== --- trunk/reactos/tools/cabman/main.cxx (original) +++ trunk/reactos/tools/cabman/main.cxx Sun May 27 14:26:43 2007 @@ -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 @@ { unsigned int Len;
- Len = strlen(Str); + Len = (uint32_t)strlen(Str);
if (Len < Length) { @@ -55,7 +56,7 @@ }
-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 @@ * Pointer to string */ { - unsigned long dw; + uint32_t dw;
/* Month */ Str[0] = (char)('0' + ((Date & 0x01E0) >> 5) / 10); @@ -86,7 +87,7 @@ }
-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 @@ */ { 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* Attr2Str(char* Str, unsigned short Attr) +char* Attr2Str(char* Str, uint16_t Attr) /* * FUNCTION: Converts attributes to a string * ARGUMENTS: @@ -364,7 +365,7 @@ * FUNCTION: Create cabinet */ { - unsigned long Status; + uint32_t Status;
Status = Load((char*)&FileName); if (Status != CAB_STATUS_SUCCESS) @@ -384,7 +385,7 @@ * FUNCTION: Create cabinet */ { - unsigned long Status; + uint32_t Status;
Status = NewCabinet(); if (Status != CAB_STATUS_SUCCESS) @@ -422,8 +423,8 @@ { 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 @@ */ { CAB_SEARCH Search; - unsigned long Status; + uint32_t Status;
if (Open() == CAB_STATUS_SUCCESS) {
Modified: trunk/reactos/tools/cabman/mszip.cxx URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/mszip.cxx?rev=... ============================================================================== --- trunk/reactos/tools/cabman/mszip.cxx (original) +++ trunk/reactos/tools/cabman/mszip.cxx Sun May 27 14:26:43 2007 @@ -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 @@ }
-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 @@ * 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::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 @@ * 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 @@ 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;
Modified: trunk/reactos/tools/cabman/mszip.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/mszip.h?rev=26... ============================================================================== --- trunk/reactos/tools/cabman/mszip.h (original) +++ trunk/reactos/tools/cabman/mszip.h Sun May 27 14:26:43 2007 @@ -22,15 +22,15 @@ /* 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 */
Modified: trunk/reactos/tools/cabman/raw.cxx URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/raw.cxx?rev=26... ============================================================================== --- trunk/reactos/tools/cabman/raw.cxx (original) +++ trunk/reactos/tools/cabman/raw.cxx Sun May 27 14:26:43 2007 @@ -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 @@ }
-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 @@ 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:
Modified: trunk/reactos/tools/cabman/raw.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/raw.h?rev=2691... ============================================================================== --- trunk/reactos/tools/cabman/raw.h (original) +++ trunk/reactos/tools/cabman/raw.h Sun May 27 14:26:43 2007 @@ -19,15 +19,15 @@ /* 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 */