mirror of
https://github.com/fadden/nulib2.git
synced 2025-01-14 01:29:43 +00:00
Use integer types with explicit widths
Replace types like "unsigned char" and "ushort" with <stdint.h> types like uint8_t. Remove uchar/ushort/uint/ulong from autoconf.
This commit is contained in:
parent
ce1b57e2ad
commit
20c9ac1195
@ -16,13 +16,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* master header identification */
|
/* master header identification */
|
||||||
static const uchar kNuMasterID[kNufileIDLen] =
|
static const uint8_t kNuMasterID[kNufileIDLen] =
|
||||||
{ 0x4e, 0xf5, 0x46, 0xe9, 0x6c, 0xe5 };
|
{ 0x4e, 0xf5, 0x46, 0xe9, 0x6c, 0xe5 };
|
||||||
|
|
||||||
/* other identification; can be no longer than kNufileIDLen */
|
/* other identification; can be no longer than kNufileIDLen */
|
||||||
static const uchar kNuBinary2ID[] =
|
static const uint8_t kNuBinary2ID[] =
|
||||||
{ 0x0a, 0x47, 0x4c };
|
{ 0x0a, 0x47, 0x4c };
|
||||||
static const uchar kNuSHKSEAID[] =
|
static const uint8_t kNuSHKSEAID[] =
|
||||||
{ 0xa2, 0x2e, 0x00 };
|
{ 0xa2, 0x2e, 0x00 };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -60,8 +60,6 @@ Nu_NuArchiveNew(NuArchive** ppArchive)
|
|||||||
|
|
||||||
/* validate some assumptions we make throughout the code */
|
/* validate some assumptions we make throughout the code */
|
||||||
Assert(sizeof(int) >= 2);
|
Assert(sizeof(int) >= 2);
|
||||||
Assert(sizeof(ushort) >= 2);
|
|
||||||
Assert(sizeof(ulong) >= 4);
|
|
||||||
Assert(sizeof(void*) >= sizeof(NuArchive*));
|
Assert(sizeof(void*) >= sizeof(NuArchive*));
|
||||||
|
|
||||||
*ppArchive = Nu_Calloc(NULL, sizeof(**ppArchive));
|
*ppArchive = Nu_Calloc(NULL, sizeof(**ppArchive));
|
||||||
@ -252,8 +250,8 @@ Nu_UpdateWrapper(NuArchive* pArchive, FILE* fp)
|
|||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
Boolean hasBinary2, hasSea;
|
Boolean hasBinary2, hasSea;
|
||||||
uchar identBuf[kNufileIDLen];
|
uint8_t identBuf[kNufileIDLen];
|
||||||
ulong archiveLen, archiveLen512;
|
uint32_t archiveLen, archiveLen512;
|
||||||
|
|
||||||
Assert(pArchive->newMasterHeader.isValid); /* need new crc and len */
|
Assert(pArchive->newMasterHeader.isValid); /* need new crc and len */
|
||||||
|
|
||||||
@ -306,20 +304,20 @@ Nu_UpdateWrapper(NuArchive* pArchive, FILE* fp)
|
|||||||
|
|
||||||
err = Nu_FSeek(fp, kNuBNYFileSizeLo - kNufileIDLen, SEEK_CUR);
|
err = Nu_FSeek(fp, kNuBNYFileSizeLo - kNufileIDLen, SEEK_CUR);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
Nu_WriteTwo(pArchive, fp, (ushort)(archiveLen512 & 0xffff));
|
Nu_WriteTwo(pArchive, fp, (uint16_t)(archiveLen512 & 0xffff));
|
||||||
|
|
||||||
err = Nu_FSeek(fp, kNuBNYFileSizeHi - (kNuBNYFileSizeLo+2), SEEK_CUR);
|
err = Nu_FSeek(fp, kNuBNYFileSizeHi - (kNuBNYFileSizeLo+2), SEEK_CUR);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
Nu_WriteTwo(pArchive, fp, (ushort)(archiveLen512 >> 16));
|
Nu_WriteTwo(pArchive, fp, (uint16_t)(archiveLen512 >> 16));
|
||||||
|
|
||||||
err = Nu_FSeek(fp, kNuBNYEOFLo - (kNuBNYFileSizeHi+2), SEEK_CUR);
|
err = Nu_FSeek(fp, kNuBNYEOFLo - (kNuBNYFileSizeHi+2), SEEK_CUR);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
Nu_WriteTwo(pArchive, fp, (ushort)(archiveLen & 0xffff));
|
Nu_WriteTwo(pArchive, fp, (uint16_t)(archiveLen & 0xffff));
|
||||||
Nu_WriteOne(pArchive, fp, (uchar)((archiveLen >> 16) & 0xff));
|
Nu_WriteOne(pArchive, fp, (uint8_t)((archiveLen >> 16) & 0xff));
|
||||||
|
|
||||||
err = Nu_FSeek(fp, kNuBNYEOFHi - (kNuBNYEOFLo+3), SEEK_CUR);
|
err = Nu_FSeek(fp, kNuBNYEOFHi - (kNuBNYEOFLo+3), SEEK_CUR);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
Nu_WriteOne(pArchive, fp, (uchar)(archiveLen >> 24));
|
Nu_WriteOne(pArchive, fp, (uint8_t)(archiveLen >> 24));
|
||||||
|
|
||||||
err = Nu_FSeek(fp, kNuBNYDiskSpace - (kNuBNYEOFHi+1), SEEK_CUR);
|
err = Nu_FSeek(fp, kNuBNYDiskSpace - (kNuBNYEOFHi+1), SEEK_CUR);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
@ -358,11 +356,11 @@ Nu_UpdateWrapper(NuArchive* pArchive, FILE* fp)
|
|||||||
|
|
||||||
err = Nu_FSeek(fp, kNuSEALength1 - (kNuSEAFunkySize+4), SEEK_CUR);
|
err = Nu_FSeek(fp, kNuSEALength1 - (kNuSEAFunkySize+4), SEEK_CUR);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
Nu_WriteTwo(pArchive, fp, (ushort)archiveLen);
|
Nu_WriteTwo(pArchive, fp, (uint16_t)archiveLen);
|
||||||
|
|
||||||
err = Nu_FSeek(fp, kNuSEALength2 - (kNuSEALength1+2), SEEK_CUR);
|
err = Nu_FSeek(fp, kNuSEALength2 - (kNuSEALength1+2), SEEK_CUR);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
Nu_WriteTwo(pArchive, fp, (ushort)archiveLen);
|
Nu_WriteTwo(pArchive, fp, (uint16_t)archiveLen);
|
||||||
|
|
||||||
/* seek past end of SEA wrapper */
|
/* seek past end of SEA wrapper */
|
||||||
err = Nu_FSeek(fp, kNuSEAOffset - (kNuSEALength2+2), SEEK_CUR);
|
err = Nu_FSeek(fp, kNuSEAOffset - (kNuSEALength2+2), SEEK_CUR);
|
||||||
@ -499,7 +497,7 @@ static NuError
|
|||||||
Nu_ReadMasterHeader(NuArchive* pArchive)
|
Nu_ReadMasterHeader(NuArchive* pArchive)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
ushort crc;
|
uint16_t crc;
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
NuMasterHeader* pHeader;
|
NuMasterHeader* pHeader;
|
||||||
Boolean isBinary2 = false;
|
Boolean isBinary2 = false;
|
||||||
@ -669,7 +667,7 @@ retry:
|
|||||||
if (pHeader->mhMasterEOF == kNuMasterHeaderSize) {
|
if (pHeader->mhMasterEOF == kNuMasterHeaderSize) {
|
||||||
err = kNuErrNoRecords;
|
err = kNuErrNoRecords;
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Master EOF is %ld, archive is probably truncated",
|
"Master EOF is %u, archive is probably truncated",
|
||||||
pHeader->mhMasterEOF);
|
pHeader->mhMasterEOF);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -929,7 +927,7 @@ bail:
|
|||||||
* exist.
|
* exist.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_OpenRW(const char* archivePathname, const char* tmpPathname, ulong flags,
|
Nu_OpenRW(const char* archivePathname, const char* tmpPathname, uint32_t flags,
|
||||||
NuArchive** ppArchive)
|
NuArchive** ppArchive)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
@ -1066,7 +1064,7 @@ Nu_WriteMasterHeader(NuArchive* pArchive, FILE* fp,
|
|||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
long crcOffset;
|
long crcOffset;
|
||||||
ushort crc;
|
uint16_t crc;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(fp != NULL);
|
Assert(fp != NULL);
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
/*
|
/*
|
||||||
* Read one byte, optionally computing a CRC.
|
* Read one byte, optionally computing a CRC.
|
||||||
*/
|
*/
|
||||||
uchar
|
uint8_t
|
||||||
Nu_ReadOneC(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
Nu_ReadOneC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
int ic;
|
int ic;
|
||||||
|
|
||||||
@ -36,15 +36,15 @@ Nu_ReadOneC(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
|||||||
Assert(pCrc != NULL);
|
Assert(pCrc != NULL);
|
||||||
|
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
|
|
||||||
return (uchar) ic;
|
return (uint8_t) ic;
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar
|
uint8_t
|
||||||
Nu_ReadOne(NuArchive* pArchive, FILE* fp)
|
Nu_ReadOne(NuArchive* pArchive, FILE* fp)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
return Nu_ReadOneC(pArchive, fp, &dummyCrc);
|
return Nu_ReadOneC(pArchive, fp, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ Nu_ReadOne(NuArchive* pArchive, FILE* fp)
|
|||||||
* Write one byte, optionally computing a CRC.
|
* Write one byte, optionally computing a CRC.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uchar val, ushort* pCrc)
|
Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uint8_t val, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(fp != NULL);
|
Assert(fp != NULL);
|
||||||
@ -62,9 +62,9 @@ Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uchar val, ushort* pCrc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Nu_WriteOne(NuArchive* pArchive, FILE* fp, uchar val)
|
Nu_WriteOne(NuArchive* pArchive, FILE* fp, uint8_t val)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
Nu_WriteOneC(pArchive, fp, val, &dummyCrc);
|
Nu_WriteOneC(pArchive, fp, val, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ Nu_WriteOne(NuArchive* pArchive, FILE* fp, uchar val)
|
|||||||
/*
|
/*
|
||||||
* Read two little-endian bytes, optionally computing a CRC.
|
* Read two little-endian bytes, optionally computing a CRC.
|
||||||
*/
|
*/
|
||||||
ushort
|
uint16_t
|
||||||
Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
int ic1, ic2;
|
int ic1, ic2;
|
||||||
|
|
||||||
@ -82,17 +82,17 @@ Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
|||||||
Assert(pCrc != NULL);
|
Assert(pCrc != NULL);
|
||||||
|
|
||||||
ic1 = getc(fp);
|
ic1 = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic1, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic1, *pCrc);
|
||||||
ic2 = getc(fp);
|
ic2 = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic2, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic2, *pCrc);
|
||||||
|
|
||||||
return ic1 | ic2 << 8;
|
return ic1 | ic2 << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
ushort
|
uint16_t
|
||||||
Nu_ReadTwo(NuArchive* pArchive, FILE* fp)
|
Nu_ReadTwo(NuArchive* pArchive, FILE* fp)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
return Nu_ReadTwoC(pArchive, fp, &dummyCrc);
|
return Nu_ReadTwoC(pArchive, fp, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ Nu_ReadTwo(NuArchive* pArchive, FILE* fp)
|
|||||||
* Write two little-endian bytes, optionally computing a CRC.
|
* Write two little-endian bytes, optionally computing a CRC.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, ushort val, ushort* pCrc)
|
Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, uint16_t val, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
int ic1, ic2;
|
int ic1, ic2;
|
||||||
|
|
||||||
@ -110,18 +110,18 @@ Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, ushort val, ushort* pCrc)
|
|||||||
Assert(pCrc != NULL);
|
Assert(pCrc != NULL);
|
||||||
|
|
||||||
ic1 = val & 0xff;
|
ic1 = val & 0xff;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic1, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic1, *pCrc);
|
||||||
ic2 = val >> 8;
|
ic2 = val >> 8;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic2, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic2, *pCrc);
|
||||||
|
|
||||||
putc(ic1, fp);
|
putc(ic1, fp);
|
||||||
putc(ic2, fp);
|
putc(ic2, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Nu_WriteTwo(NuArchive* pArchive, FILE* fp, ushort val)
|
Nu_WriteTwo(NuArchive* pArchive, FILE* fp, uint16_t val)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
Nu_WriteTwoC(pArchive, fp, val, &dummyCrc);
|
Nu_WriteTwoC(pArchive, fp, val, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,8 +129,8 @@ Nu_WriteTwo(NuArchive* pArchive, FILE* fp, ushort val)
|
|||||||
/*
|
/*
|
||||||
* Read four little-endian bytes, optionally computing a CRC.
|
* Read four little-endian bytes, optionally computing a CRC.
|
||||||
*/
|
*/
|
||||||
ulong
|
uint32_t
|
||||||
Nu_ReadFourC(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
Nu_ReadFourC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
int ic1, ic2, ic3, ic4;
|
int ic1, ic2, ic3, ic4;
|
||||||
|
|
||||||
@ -139,21 +139,21 @@ Nu_ReadFourC(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
|||||||
Assert(pCrc != NULL);
|
Assert(pCrc != NULL);
|
||||||
|
|
||||||
ic1 = getc(fp);
|
ic1 = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic1, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic1, *pCrc);
|
||||||
ic2 = getc(fp);
|
ic2 = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic2, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic2, *pCrc);
|
||||||
ic3 = getc(fp);
|
ic3 = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic3, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic3, *pCrc);
|
||||||
ic4 = getc(fp);
|
ic4 = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic4, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic4, *pCrc);
|
||||||
|
|
||||||
return ic1 | ic2 << 8 | (ulong)ic3 << 16 | (ulong)ic4 << 24;
|
return ic1 | ic2 << 8 | (uint32_t)ic3 << 16 | (uint32_t)ic4 << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong
|
uint32_t
|
||||||
Nu_ReadFour(NuArchive* pArchive, FILE* fp)
|
Nu_ReadFour(NuArchive* pArchive, FILE* fp)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
return Nu_ReadFourC(pArchive, fp, &dummyCrc);
|
return Nu_ReadFourC(pArchive, fp, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ Nu_ReadFour(NuArchive* pArchive, FILE* fp)
|
|||||||
* Write four little-endian bytes, optionally computing a CRC.
|
* Write four little-endian bytes, optionally computing a CRC.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Nu_WriteFourC(NuArchive* pArchive, FILE* fp, ulong val, ushort* pCrc)
|
Nu_WriteFourC(NuArchive* pArchive, FILE* fp, uint32_t val, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
int ic1, ic2, ic3, ic4;
|
int ic1, ic2, ic3, ic4;
|
||||||
|
|
||||||
@ -171,13 +171,13 @@ Nu_WriteFourC(NuArchive* pArchive, FILE* fp, ulong val, ushort* pCrc)
|
|||||||
Assert(pCrc != NULL);
|
Assert(pCrc != NULL);
|
||||||
|
|
||||||
ic1 = val & 0xff;
|
ic1 = val & 0xff;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic1, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic1, *pCrc);
|
||||||
ic2 = (val >> 8) & 0xff;
|
ic2 = (val >> 8) & 0xff;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic2, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic2, *pCrc);
|
||||||
ic3 = (val >> 16) & 0xff;
|
ic3 = (val >> 16) & 0xff;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic3, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic3, *pCrc);
|
||||||
ic4 = val >> 24;
|
ic4 = val >> 24;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic4, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic4, *pCrc);
|
||||||
|
|
||||||
putc(ic1, fp);
|
putc(ic1, fp);
|
||||||
putc(ic2, fp);
|
putc(ic2, fp);
|
||||||
@ -186,9 +186,9 @@ Nu_WriteFourC(NuArchive* pArchive, FILE* fp, ulong val, ushort* pCrc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Nu_WriteFour(NuArchive* pArchive, FILE* fp, ulong val)
|
Nu_WriteFour(NuArchive* pArchive, FILE* fp, uint32_t val)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
Nu_WriteFourC(pArchive, fp, val, &dummyCrc);
|
Nu_WriteFourC(pArchive, fp, val, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ Nu_WriteFour(NuArchive* pArchive, FILE* fp, ulong val)
|
|||||||
* messing-with, the better.
|
* messing-with, the better.
|
||||||
*/
|
*/
|
||||||
NuDateTime
|
NuDateTime
|
||||||
Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuDateTime temp;
|
NuDateTime temp;
|
||||||
int ic;
|
int ic;
|
||||||
@ -211,37 +211,37 @@ Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
|||||||
Assert(pCrc != NULL);
|
Assert(pCrc != NULL);
|
||||||
|
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
temp.second = ic;
|
temp.second = ic;
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
temp.minute = ic;
|
temp.minute = ic;
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
temp.hour = ic;
|
temp.hour = ic;
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
temp.year = ic;
|
temp.year = ic;
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
temp.day = ic;
|
temp.day = ic;
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
temp.month = ic;
|
temp.month = ic;
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
temp.extra = ic;
|
temp.extra = ic;
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
temp.weekDay = ic;
|
temp.weekDay = ic;
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
NuDateTime
|
NuDateTime
|
||||||
Nu_ReadDateTime(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
Nu_ReadDateTime(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
return Nu_ReadDateTimeC(pArchive, fp, &dummyCrc);
|
return Nu_ReadDateTimeC(pArchive, fp, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ Nu_ReadDateTime(NuArchive* pArchive, FILE* fp, ushort* pCrc)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime,
|
Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime,
|
||||||
ushort* pCrc)
|
uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
int ic;
|
int ic;
|
||||||
|
|
||||||
@ -260,35 +260,35 @@ Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime,
|
|||||||
Assert(pCrc != NULL);
|
Assert(pCrc != NULL);
|
||||||
|
|
||||||
ic = dateTime.second;
|
ic = dateTime.second;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
ic = dateTime.minute;
|
ic = dateTime.minute;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
ic = dateTime.hour;
|
ic = dateTime.hour;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
ic = dateTime.year;
|
ic = dateTime.year;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
ic = dateTime.day;
|
ic = dateTime.day;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
ic = dateTime.month;
|
ic = dateTime.month;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
ic = dateTime.extra;
|
ic = dateTime.extra;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
ic = dateTime.weekDay;
|
ic = dateTime.weekDay;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Nu_WriteDateTime(NuArchive* pArchive, FILE* fp, NuDateTime dateTime)
|
Nu_WriteDateTime(NuArchive* pArchive, FILE* fp, NuDateTime dateTime)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
Nu_WriteDateTimeC(pArchive, fp, dateTime, &dummyCrc);
|
Nu_WriteDateTimeC(pArchive, fp, dateTime, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,9 +298,9 @@ Nu_WriteDateTime(NuArchive* pArchive, FILE* fp, NuDateTime dateTime)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
|
Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
|
||||||
ushort* pCrc)
|
uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
uchar* buffer = vbuffer;
|
uint8_t* buffer = vbuffer;
|
||||||
int ic;
|
int ic;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
@ -311,7 +311,7 @@ Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
|
|||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
ic = getc(fp);
|
ic = getc(fp);
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
*buffer++ = ic;
|
*buffer++ = ic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
|
|||||||
void
|
void
|
||||||
Nu_ReadBytes(NuArchive* pArchive, FILE* fp, void* vbuffer, long count)
|
Nu_ReadBytes(NuArchive* pArchive, FILE* fp, void* vbuffer, long count)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
Nu_ReadBytesC(pArchive, fp, vbuffer, count, &dummyCrc);
|
Nu_ReadBytesC(pArchive, fp, vbuffer, count, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,9 +329,9 @@ Nu_ReadBytes(NuArchive* pArchive, FILE* fp, void* vbuffer, long count)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count,
|
Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count,
|
||||||
ushort* pCrc)
|
uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
const uchar* buffer = vbuffer;
|
const uint8_t* buffer = vbuffer;
|
||||||
int ic;
|
int ic;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
@ -342,7 +342,7 @@ Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count,
|
|||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
ic = *buffer++;
|
ic = *buffer++;
|
||||||
*pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc);
|
*pCrc = Nu_UpdateCRC16((uint8_t)ic, *pCrc);
|
||||||
putc(ic, fp);
|
putc(ic, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,7 +350,7 @@ Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count,
|
|||||||
void
|
void
|
||||||
Nu_WriteBytes(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count)
|
Nu_WriteBytes(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count)
|
||||||
{
|
{
|
||||||
ushort dummyCrc CLEAN_INIT;
|
uint16_t dummyCrc CLEAN_INIT;
|
||||||
Nu_WriteBytesC(pArchive, fp, vbuffer, count, &dummyCrc);
|
Nu_WriteBytesC(pArchive, fp, vbuffer, count, &dummyCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,12 +48,12 @@ Nu_bzfree(void* opaque, void* address)
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
bz_stream bzstream;
|
bz_stream bzstream;
|
||||||
int bzerr;
|
int bzerr;
|
||||||
uchar* outbuf = NULL;
|
uint8_t* outbuf = NULL;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(pStraw != NULL);
|
Assert(pStraw != NULL);
|
||||||
@ -98,7 +98,7 @@ Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
|||||||
* Loop while we have data.
|
* Loop while we have data.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
ulong getSize;
|
uint32_t getSize;
|
||||||
int action;
|
int action;
|
||||||
|
|
||||||
/* should be able to read a full buffer every time */
|
/* should be able to read a full buffer every time */
|
||||||
@ -139,8 +139,8 @@ Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
|||||||
(bzerr == BZ_STREAM_END && bzstream.avail_out != kNuGenCompBufSize))
|
(bzerr == BZ_STREAM_END && bzstream.avail_out != kNuGenCompBufSize))
|
||||||
{
|
{
|
||||||
DBUG(("+++ writing %d bytes\n",
|
DBUG(("+++ writing %d bytes\n",
|
||||||
(uchar*)bzstream.next_out - outbuf));
|
(uint8_t*)bzstream.next_out - outbuf));
|
||||||
err = Nu_FWrite(fp, outbuf, (uchar*)bzstream.next_out - outbuf);
|
err = Nu_FWrite(fp, outbuf, (uint8_t*)bzstream.next_out - outbuf);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
Nu_ReportError(NU_BLOB, err, "fwrite failed in bzip2");
|
Nu_ReportError(NU_BLOB, err, "fwrite failed in bzip2");
|
||||||
goto bz_bail;
|
goto bz_bail;
|
||||||
@ -175,13 +175,13 @@ bail:
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
|
Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc)
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
bz_stream bzstream;
|
bz_stream bzstream;
|
||||||
int bzerr;
|
int bzerr;
|
||||||
ulong compRemaining;
|
uint32_t compRemaining;
|
||||||
uchar* outbuf;
|
uint8_t* outbuf;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(pThread != NULL);
|
Assert(pThread != NULL);
|
||||||
@ -226,7 +226,7 @@ Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
* Loop while we have data.
|
* Loop while we have data.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
ulong getSize;
|
uint32_t getSize;
|
||||||
|
|
||||||
/* read as much as we can */
|
/* read as much as we can */
|
||||||
if (bzstream.avail_in == 0) {
|
if (bzstream.avail_in == 0) {
|
||||||
@ -258,9 +258,10 @@ Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
|
|
||||||
/* write every time there's anything (buffer will usually be full) */
|
/* write every time there's anything (buffer will usually be full) */
|
||||||
if (bzstream.avail_out != kNuGenCompBufSize) {
|
if (bzstream.avail_out != kNuGenCompBufSize) {
|
||||||
DBUG(("+++ writing %d bytes\n",(uchar*)bzstream.next_out - outbuf));
|
DBUG(("+++ writing %d bytes\n",
|
||||||
|
(uint8_t*) bzstream.next_out - outbuf));
|
||||||
err = Nu_FunnelWrite(pArchive, pFunnel, outbuf,
|
err = Nu_FunnelWrite(pArchive, pFunnel, outbuf,
|
||||||
(uchar*)bzstream.next_out - outbuf);
|
(uint8_t*)bzstream.next_out - outbuf);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
Nu_ReportError(NU_BLOB, err, "write failed in bzip2");
|
Nu_ReportError(NU_BLOB, err, "write failed in bzip2");
|
||||||
goto bz_bail;
|
goto bz_bail;
|
||||||
@ -268,7 +269,7 @@ Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
|
|
||||||
if (pCrc != NULL)
|
if (pCrc != NULL)
|
||||||
*pCrc = Nu_CalcCRC16(*pCrc, outbuf,
|
*pCrc = Nu_CalcCRC16(*pCrc, outbuf,
|
||||||
(uchar*) bzstream.next_out - outbuf);
|
(uint8_t*) bzstream.next_out - outbuf);
|
||||||
|
|
||||||
bzstream.next_out = outbuf;
|
bzstream.next_out = outbuf;
|
||||||
bzstream.avail_out = kNuGenCompBufSize;
|
bzstream.avail_out = kNuGenCompBufSize;
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_CompressUncompressed(NuArchive* pArchive, NuStraw* pStraw,
|
Nu_CompressUncompressed(NuArchive* pArchive, NuStraw* pStraw,
|
||||||
FILE* fp, ulong srcLen, ulong* pDstLen, ushort *pCrc)
|
FILE* fp, uint32_t srcLen, uint32_t* pDstLen, uint16_t *pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
/*uchar* buffer = NULL;*/
|
/*uint8_t* buffer = NULL;*/
|
||||||
ulong count, getsize;
|
uint32_t count, getsize;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(pStraw != NULL);
|
Assert(pStraw != NULL);
|
||||||
@ -97,8 +97,8 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
|
|||||||
long origOffset;
|
long origOffset;
|
||||||
NuStraw* pStraw = NULL;
|
NuStraw* pStraw = NULL;
|
||||||
NuDataSink* pDataSink = NULL;
|
NuDataSink* pDataSink = NULL;
|
||||||
ulong srcLen = 0, dstLen = 0;
|
uint32_t srcLen = 0, dstLen = 0;
|
||||||
ushort threadCrc;
|
uint16_t threadCrc;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(pDataSource != NULL);
|
Assert(pDataSource != NULL);
|
||||||
@ -116,7 +116,7 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
|
|||||||
|
|
||||||
pThread->thThreadClass = NuThreadIDGetClass(threadID);
|
pThread->thThreadClass = NuThreadIDGetClass(threadID);
|
||||||
pThread->thThreadKind = NuThreadIDGetKind(threadID);
|
pThread->thThreadKind = NuThreadIDGetKind(threadID);
|
||||||
pThread->actualThreadEOF = (ulong)-1;
|
pThread->actualThreadEOF = (uint32_t)-1;
|
||||||
/* nuThreadIdx and fileOffset should already be set */
|
/* nuThreadIdx and fileOffset should already be set */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -328,8 +328,8 @@ Nu_CopyPresizedToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
|
|||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuStraw* pStraw = NULL;
|
NuStraw* pStraw = NULL;
|
||||||
ulong srcLen, bufferLen;
|
uint32_t srcLen, bufferLen;
|
||||||
ulong count, getsize;
|
uint32_t count, getsize;
|
||||||
|
|
||||||
srcLen = Nu_DataSourceGetDataLen(pDataSource);
|
srcLen = Nu_DataSourceGetDataLen(pDataSource);
|
||||||
bufferLen = Nu_DataSourceGetOtherLen(pDataSource);
|
bufferLen = Nu_DataSourceGetOtherLen(pDataSource);
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* crctab calculated by Mark G. Mendel, Network Systems Corporation */
|
/* crctab calculated by Mark G. Mendel, Network Systems Corporation */
|
||||||
const ushort gNuCrc16Table[256] = {
|
const uint16_t gNuCrc16Table[256] = {
|
||||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||||
@ -83,13 +83,12 @@ const ushort gNuCrc16Table[256] = {
|
|||||||
* Depending on CPU architecture, one may be dramatically faster than
|
* Depending on CPU architecture, one may be dramatically faster than
|
||||||
* the other.
|
* the other.
|
||||||
*/
|
*/
|
||||||
ushort
|
uint16_t
|
||||||
Nu_CalcCRC16(ushort seed, const uchar* ptr, int count)
|
Nu_CalcCRC16(uint16_t seed, const uint8_t* ptr, int count)
|
||||||
{
|
{
|
||||||
ushort CRC = seed;
|
uint16_t CRC = seed;
|
||||||
#ifndef CRC_TAB
|
#ifndef CRC_TAB
|
||||||
int x;
|
int x;
|
||||||
Assert(sizeof(ushort) == 2); /* I think this is assumed */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -119,7 +119,7 @@ bail:
|
|||||||
* The result will be 2x the size of the original, +1 for a null byte.
|
* The result will be 2x the size of the original, +1 for a null byte.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
ConvertToHexStr(const uchar* inBuf, int inLen, char* outBuf)
|
ConvertToHexStr(const uint8_t* inBuf, int inLen, char* outBuf)
|
||||||
{
|
{
|
||||||
while (inLen--) {
|
while (inLen--) {
|
||||||
*outBuf++ = HexConv((*inBuf >> 4) & 0x0f);
|
*outBuf++ = HexConv((*inBuf >> 4) & 0x0f);
|
||||||
@ -186,7 +186,7 @@ Nu_DebugDumpRecord(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
char dateBuf[kNuDateOutputLen];
|
char dateBuf[kNuDateOutputLen];
|
||||||
const NuThreadMod* pThreadMod;
|
const NuThreadMod* pThreadMod;
|
||||||
const NuThread* pThread;
|
const NuThread* pThread;
|
||||||
ulong idx;
|
uint32_t idx;
|
||||||
|
|
||||||
Assert(pRecord != NULL);
|
Assert(pRecord != NULL);
|
||||||
|
|
||||||
|
@ -324,10 +324,10 @@ Nu_NewThreads_GetNumThreads(const NuNewThreads* pNewThreads)
|
|||||||
/*
|
/*
|
||||||
* Total up the compressed EOFs of all threads.
|
* Total up the compressed EOFs of all threads.
|
||||||
*/
|
*/
|
||||||
static ulong
|
static uint32_t
|
||||||
Nu_NewThreads_TotalCompThreadEOF(NuNewThreads* pNewThreads)
|
Nu_NewThreads_TotalCompThreadEOF(NuNewThreads* pNewThreads)
|
||||||
{
|
{
|
||||||
ulong compThreadEOF;
|
uint32_t compThreadEOF;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* we should be all full up at this point; if not, we have a bug */
|
/* we should be all full up at this point; if not, we have a bug */
|
||||||
@ -401,7 +401,7 @@ Nu_CopyArchiveRecord(NuArchive* pArchive, NuRecord* pRecord)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert(outputOffset + pRecord->recHeaderLength + pRecord->totalCompLength ==
|
Assert(outputOffset + pRecord->recHeaderLength + pRecord->totalCompLength ==
|
||||||
(ulong)ftell(pArchive->tmpFp));
|
(uint32_t)ftell(pArchive->tmpFp));
|
||||||
Assert(pRecord->fileOffset == outputOffset);
|
Assert(pRecord->fileOffset == outputOffset);
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
@ -605,8 +605,8 @@ Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp, NuRecord* pRecord,
|
|||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
NuDataSource* pDataSource = NULL;
|
NuDataSource* pDataSource = NULL;
|
||||||
ulong sourceLen;
|
uint32_t sourceLen;
|
||||||
ulong threadBufSize;
|
uint32_t threadBufSize;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're going to copy the data out of the data source. Because
|
* We're going to copy the data out of the data source. Because
|
||||||
@ -645,7 +645,7 @@ Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp, NuRecord* pRecord,
|
|||||||
sourceLen = Nu_DataSourceGetDataLen(pDataSource);
|
sourceLen = Nu_DataSourceGetDataLen(pDataSource);
|
||||||
if (sourceLen > pThread->thCompThreadEOF) {
|
if (sourceLen > pThread->thCompThreadEOF) {
|
||||||
err = kNuErrPreSizeOverflow;
|
err = kNuErrPreSizeOverflow;
|
||||||
Nu_ReportError(NU_BLOB, err, "can't fit %ld bytes into %ld-byte buffer",
|
Nu_ReportError(NU_BLOB, err, "can't fit %u bytes into %u-byte buffer",
|
||||||
sourceLen, pThread->thCompThreadEOF);
|
sourceLen, pThread->thCompThreadEOF);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -679,7 +679,7 @@ Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp, NuRecord* pRecord,
|
|||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert((ulong)ftell(fp) == pThread->fileOffset + threadBufSize);
|
Assert((uint32_t)ftell(fp) == pThread->fileOffset + threadBufSize);
|
||||||
|
|
||||||
skip_update:
|
skip_update:
|
||||||
Nu_DataSourceUnPrepareInput(pArchive, pDataSource);
|
Nu_DataSourceUnPrepareInput(pArchive, pDataSource);
|
||||||
@ -804,7 +804,7 @@ Nu_HandleAddThreadMods(NuArchive* pArchive, NuRecord* pRecord,
|
|||||||
if (pThreadMod->entry.add.threadID == kNuThreadIDDiskImage) {
|
if (pThreadMod->entry.add.threadID == kNuThreadIDDiskImage) {
|
||||||
const NuDataSource* pDataSource =
|
const NuDataSource* pDataSource =
|
||||||
pThreadMod->entry.add.pDataSource;
|
pThreadMod->entry.add.pDataSource;
|
||||||
ulong uncompLen;
|
uint32_t uncompLen;
|
||||||
|
|
||||||
if (Nu_DataSourceGetThreadFormat(pDataSource) ==
|
if (Nu_DataSourceGetThreadFormat(pDataSource) ==
|
||||||
kNuThreadFormatUncompressed)
|
kNuThreadFormatUncompressed)
|
||||||
@ -1339,7 +1339,7 @@ Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord, FILE* fp)
|
|||||||
maxLen = len > kNuDefaultFilenameThreadSize ?
|
maxLen = len > kNuDefaultFilenameThreadSize ?
|
||||||
len : kNuDefaultFilenameThreadSize;
|
len : kNuDefaultFilenameThreadSize;
|
||||||
err = Nu_DataSourceBuffer_New(kNuThreadFormatUncompressed,
|
err = Nu_DataSourceBuffer_New(kNuThreadFormatUncompressed,
|
||||||
maxLen, (const uchar*)pRecord->filename, 0,
|
maxLen, (const uint8_t*)pRecord->filename, 0,
|
||||||
strlen(pRecord->filename), NULL, &pTmpDataSource);
|
strlen(pRecord->filename), NULL, &pTmpDataSource);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
|
|
||||||
@ -1852,7 +1852,7 @@ Nu_PurgeEmptyRecords(NuArchive* pArchive, NuRecordSet* pRecordSet)
|
|||||||
if (Nu_RecordIsEmpty(pArchive, pRecord)) {
|
if (Nu_RecordIsEmpty(pArchive, pRecord)) {
|
||||||
DBUG(("--- Purging empty record %06ld '%s' (0x%08lx-->0x%08lx)\n",
|
DBUG(("--- Purging empty record %06ld '%s' (0x%08lx-->0x%08lx)\n",
|
||||||
pRecord->recordIdx, pRecord->filename,
|
pRecord->recordIdx, pRecord->filename,
|
||||||
(ulong)ppRecord, (ulong)pRecord));
|
(uint32_t)ppRecord, (uint32_t)pRecord));
|
||||||
err = Nu_RecordSet_DeleteRecordPtr(pArchive, pRecordSet, ppRecord);
|
err = Nu_RecordSet_DeleteRecordPtr(pArchive, pRecordSet, ppRecord);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
/* pRecord is now invalid, and *ppRecord has been updated */
|
/* pRecord is now invalid, and *ppRecord has been updated */
|
||||||
|
@ -48,7 +48,7 @@ Nu_zfree(voidpf opaque, voidpf address)
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
z_stream zstream;
|
z_stream zstream;
|
||||||
@ -100,7 +100,7 @@ Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
|||||||
* Loop while we have data.
|
* Loop while we have data.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
ulong getSize;
|
uint32_t getSize;
|
||||||
int flush;
|
int flush;
|
||||||
|
|
||||||
/* should be able to read a full buffer every time */
|
/* should be able to read a full buffer every time */
|
||||||
@ -176,12 +176,12 @@ bail:
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord,
|
Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc)
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
z_stream zstream;
|
z_stream zstream;
|
||||||
int zerr;
|
int zerr;
|
||||||
ulong compRemaining;
|
uint32_t compRemaining;
|
||||||
Bytef* outbuf;
|
Bytef* outbuf;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
@ -229,7 +229,7 @@ Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
* Loop while we have data.
|
* Loop while we have data.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
ulong getSize;
|
uint32_t getSize;
|
||||||
|
|
||||||
/* read as much as we can */
|
/* read as much as we can */
|
||||||
if (zstream.avail_in == 0) {
|
if (zstream.avail_in == 0) {
|
||||||
@ -282,7 +282,7 @@ Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
if (zstream.total_out != pThread->actualThreadEOF) {
|
if (zstream.total_out != pThread->actualThreadEOF) {
|
||||||
err = kNuErrBadData;
|
err = kNuErrBadData;
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"size mismatch on inflated file (%ld vs %ld)",
|
"size mismatch on inflated file (%ld vs %u)",
|
||||||
zstream.total_out, pThread->actualThreadEOF);
|
zstream.total_out, pThread->actualThreadEOF);
|
||||||
goto z_bail;
|
goto z_bail;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ NuGetRecordIdxByName(NuArchive* pArchive, const char* name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NUFXLIB_API NuError
|
NUFXLIB_API NuError
|
||||||
NuGetRecordIdxByPosition(NuArchive* pArchive, unsigned long position,
|
NuGetRecordIdxByPosition(NuArchive* pArchive, uint32_t position,
|
||||||
NuRecordIdx* pRecordIdx)
|
NuRecordIdx* pRecordIdx)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
@ -282,7 +282,7 @@ NuGetRecordIdxByPosition(NuArchive* pArchive, unsigned long position,
|
|||||||
|
|
||||||
NUFXLIB_API NuError
|
NUFXLIB_API NuError
|
||||||
NuOpenRW(const char* archivePathname, const char* tmpPathname,
|
NuOpenRW(const char* archivePathname, const char* tmpPathname,
|
||||||
unsigned long flags, NuArchive** ppArchive)
|
uint32_t flags, NuArchive** ppArchive)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
|
|
||||||
@ -570,7 +570,7 @@ NuDebugDumpArchive(NuArchive* pArchive)
|
|||||||
|
|
||||||
NUFXLIB_API NuError
|
NUFXLIB_API NuError
|
||||||
NuCreateDataSourceForFile(NuThreadFormat threadFormat,
|
NuCreateDataSourceForFile(NuThreadFormat threadFormat,
|
||||||
unsigned long otherLen, const char* pathname, short isFromRsrcFork,
|
uint32_t otherLen, const char* pathname, short isFromRsrcFork,
|
||||||
NuDataSource** ppDataSource)
|
NuDataSource** ppDataSource)
|
||||||
{
|
{
|
||||||
return Nu_DataSourceFile_New(threadFormat, otherLen,
|
return Nu_DataSourceFile_New(threadFormat, otherLen,
|
||||||
@ -579,7 +579,7 @@ NuCreateDataSourceForFile(NuThreadFormat threadFormat,
|
|||||||
|
|
||||||
NUFXLIB_API NuError
|
NUFXLIB_API NuError
|
||||||
NuCreateDataSourceForFP(NuThreadFormat threadFormat,
|
NuCreateDataSourceForFP(NuThreadFormat threadFormat,
|
||||||
unsigned long otherLen, FILE* fp, long offset, long length,
|
uint32_t otherLen, FILE* fp, long offset, long length,
|
||||||
NuCallback fcloseFunc, NuDataSource** ppDataSource)
|
NuCallback fcloseFunc, NuDataSource** ppDataSource)
|
||||||
{
|
{
|
||||||
return Nu_DataSourceFP_New(threadFormat, otherLen,
|
return Nu_DataSourceFP_New(threadFormat, otherLen,
|
||||||
@ -588,7 +588,7 @@ NuCreateDataSourceForFP(NuThreadFormat threadFormat,
|
|||||||
|
|
||||||
NUFXLIB_API NuError
|
NUFXLIB_API NuError
|
||||||
NuCreateDataSourceForBuffer(NuThreadFormat threadFormat,
|
NuCreateDataSourceForBuffer(NuThreadFormat threadFormat,
|
||||||
unsigned long otherLen, const unsigned char* buffer, long offset,
|
uint32_t otherLen, const uint8_t* buffer, long offset,
|
||||||
long length, NuCallback freeFunc, NuDataSource** ppDataSource)
|
long length, NuCallback freeFunc, NuDataSource** ppDataSource)
|
||||||
{
|
{
|
||||||
return Nu_DataSourceBuffer_New(threadFormat, otherLen,
|
return Nu_DataSourceBuffer_New(threadFormat, otherLen,
|
||||||
@ -602,7 +602,7 @@ NuFreeDataSource(NuDataSource* pDataSource)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NUFXLIB_API NuError
|
NUFXLIB_API NuError
|
||||||
NuDataSourceSetRawCrc(NuDataSource* pDataSource, unsigned short crc)
|
NuDataSourceSetRawCrc(NuDataSource* pDataSource, uint16_t crc)
|
||||||
{
|
{
|
||||||
if (pDataSource == NULL)
|
if (pDataSource == NULL)
|
||||||
return kNuErrInvalidArg;
|
return kNuErrInvalidArg;
|
||||||
@ -628,7 +628,7 @@ NuCreateDataSinkForFP(short doExpand, NuValue convertEOL, FILE* fp,
|
|||||||
|
|
||||||
NUFXLIB_API NuError
|
NUFXLIB_API NuError
|
||||||
NuCreateDataSinkForBuffer(short doExpand, NuValue convertEOL,
|
NuCreateDataSinkForBuffer(short doExpand, NuValue convertEOL,
|
||||||
unsigned char* buffer, unsigned long bufLen, NuDataSink** ppDataSink)
|
uint8_t* buffer, uint32_t bufLen, NuDataSink** ppDataSink)
|
||||||
{
|
{
|
||||||
return Nu_DataSinkBuffer_New((Boolean)(doExpand != 0), convertEOL, buffer,
|
return Nu_DataSinkBuffer_New((Boolean)(doExpand != 0), convertEOL, buffer,
|
||||||
bufLen, ppDataSink);
|
bufLen, ppDataSink);
|
||||||
@ -641,7 +641,7 @@ NuFreeDataSink(NuDataSink* pDataSink)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NUFXLIB_API NuError
|
NUFXLIB_API NuError
|
||||||
NuDataSinkGetOutCount(NuDataSink* pDataSink, ulong* pOutCount)
|
NuDataSinkGetOutCount(NuDataSink* pDataSink, uint32_t* pOutCount)
|
||||||
{
|
{
|
||||||
if (pDataSink == NULL || pOutCount == NULL)
|
if (pDataSink == NULL || pOutCount == NULL)
|
||||||
return kNuErrInvalidArg;
|
return kNuErrInvalidArg;
|
||||||
@ -741,7 +741,7 @@ NuRecordCopyThreads(const NuRecord* pNuRecord, NuThread** ppThreads)
|
|||||||
return kNuErrNone;
|
return kNuErrNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
NUFXLIB_API unsigned long
|
NUFXLIB_API uint32_t
|
||||||
NuRecordGetNumThreads(const NuRecord* pNuRecord)
|
NuRecordGetNumThreads(const NuRecord* pNuRecord)
|
||||||
{
|
{
|
||||||
if (pNuRecord == NULL)
|
if (pNuRecord == NULL)
|
||||||
@ -777,7 +777,7 @@ NuSetSelectionFilter(NuArchive* pArchive, NuCallback filterFunc)
|
|||||||
NuError err;
|
NuError err;
|
||||||
NuCallback oldFunc = kNuInvalidCallback;
|
NuCallback oldFunc = kNuInvalidCallback;
|
||||||
|
|
||||||
/*Assert(!((ulong)filterFunc % 4));*/
|
/*Assert(!((uint32_t)filterFunc % 4));*/
|
||||||
|
|
||||||
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
||||||
oldFunc = pArchive->selectionFilterFunc;
|
oldFunc = pArchive->selectionFilterFunc;
|
||||||
@ -793,7 +793,7 @@ NuSetOutputPathnameFilter(NuArchive* pArchive, NuCallback filterFunc)
|
|||||||
NuError err;
|
NuError err;
|
||||||
NuCallback oldFunc = kNuInvalidCallback;
|
NuCallback oldFunc = kNuInvalidCallback;
|
||||||
|
|
||||||
/*Assert(!((ulong)filterFunc % 4));*/
|
/*Assert(!((uint32_t)filterFunc % 4));*/
|
||||||
|
|
||||||
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
||||||
oldFunc = pArchive->outputPathnameFunc;
|
oldFunc = pArchive->outputPathnameFunc;
|
||||||
@ -809,7 +809,7 @@ NuSetProgressUpdater(NuArchive* pArchive, NuCallback updateFunc)
|
|||||||
NuError err;
|
NuError err;
|
||||||
NuCallback oldFunc = kNuInvalidCallback;
|
NuCallback oldFunc = kNuInvalidCallback;
|
||||||
|
|
||||||
/*Assert(!((ulong)updateFunc % 4));*/
|
/*Assert(!((uint32_t)updateFunc % 4));*/
|
||||||
|
|
||||||
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
||||||
oldFunc = pArchive->progressUpdaterFunc;
|
oldFunc = pArchive->progressUpdaterFunc;
|
||||||
@ -825,7 +825,7 @@ NuSetErrorHandler(NuArchive* pArchive, NuCallback errorFunc)
|
|||||||
NuError err;
|
NuError err;
|
||||||
NuCallback oldFunc = kNuInvalidCallback;
|
NuCallback oldFunc = kNuInvalidCallback;
|
||||||
|
|
||||||
/*Assert(!((ulong)errorFunc % 4));*/
|
/*Assert(!((uint32_t)errorFunc % 4));*/
|
||||||
|
|
||||||
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
||||||
oldFunc = pArchive->errorHandlerFunc;
|
oldFunc = pArchive->errorHandlerFunc;
|
||||||
@ -841,7 +841,7 @@ NuSetErrorMessageHandler(NuArchive* pArchive, NuCallback messageHandlerFunc)
|
|||||||
NuError err;
|
NuError err;
|
||||||
NuCallback oldFunc = kNuInvalidCallback;
|
NuCallback oldFunc = kNuInvalidCallback;
|
||||||
|
|
||||||
/*Assert(!((ulong)messageHandlerFunc % 4));*/
|
/*Assert(!((uint32_t)messageHandlerFunc % 4));*/
|
||||||
|
|
||||||
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
||||||
oldFunc = pArchive->messageHandlerFunc;
|
oldFunc = pArchive->messageHandlerFunc;
|
||||||
@ -855,7 +855,7 @@ NUFXLIB_API NuCallback
|
|||||||
NuSetGlobalErrorMessageHandler(NuCallback messageHandlerFunc)
|
NuSetGlobalErrorMessageHandler(NuCallback messageHandlerFunc)
|
||||||
{
|
{
|
||||||
NuCallback oldFunc = kNuInvalidCallback;
|
NuCallback oldFunc = kNuInvalidCallback;
|
||||||
/*Assert(!((ulong)messageHandlerFunc % 4));*/
|
/*Assert(!((uint32_t)messageHandlerFunc % 4));*/
|
||||||
|
|
||||||
oldFunc = gNuGlobalErrorMessageHandler;
|
oldFunc = gNuGlobalErrorMessageHandler;
|
||||||
gNuGlobalErrorMessageHandler = messageHandlerFunc;
|
gNuGlobalErrorMessageHandler = messageHandlerFunc;
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_ExpandUncompressed(NuArchive* pArchive, const NuRecord* pRecord,
|
Nu_ExpandUncompressed(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc)
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
/*uchar* buffer = NULL;*/
|
/*uint8_t* buffer = NULL;*/
|
||||||
ulong count, getsize;
|
uint32_t count, getsize;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(pThread != NULL);
|
Assert(pThread != NULL);
|
||||||
@ -68,8 +68,8 @@ Nu_ExpandRaw(NuArchive* pArchive, const NuThread* pThread, FILE* infp,
|
|||||||
NuFunnel* pFunnel)
|
NuFunnel* pFunnel)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
/*uchar* buffer = NULL;*/
|
/*uint8_t* buffer = NULL;*/
|
||||||
ulong count, getsize;
|
uint32_t count, getsize;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(pThread != NULL);
|
Assert(pThread != NULL);
|
||||||
@ -113,8 +113,8 @@ Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel)
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
ushort calcCrc;
|
uint16_t calcCrc;
|
||||||
ushort* pCalcCrc;
|
uint16_t* pCalcCrc;
|
||||||
|
|
||||||
if (!pThread->thThreadEOF && !pThread->thCompThreadEOF) {
|
if (!pThread->thThreadEOF && !pThread->thCompThreadEOF) {
|
||||||
/* somebody stored an empty file! */
|
/* somebody stored an empty file! */
|
||||||
|
@ -219,11 +219,11 @@ typedef struct NuFileInfo {
|
|||||||
Boolean isRegularFile; /* is this a regular file? */
|
Boolean isRegularFile; /* is this a regular file? */
|
||||||
Boolean isDirectory; /* is this a directory? */
|
Boolean isDirectory; /* is this a directory? */
|
||||||
|
|
||||||
ulong dataEof;
|
uint32_t dataEof;
|
||||||
ulong rsrcEof;
|
uint32_t rsrcEof;
|
||||||
|
|
||||||
ulong fileType;
|
uint32_t fileType;
|
||||||
ulong auxType;
|
uint32_t auxType;
|
||||||
NuDateTime modWhen;
|
NuDateTime modWhen;
|
||||||
mode_t unixMode; /* UNIX-style permissions */
|
mode_t unixMode; /* UNIX-style permissions */
|
||||||
} NuFileInfo;
|
} NuFileInfo;
|
||||||
@ -312,7 +312,7 @@ Nu_GetFileInfo(NuArchive* pArchive, const char* pathname,
|
|||||||
OSType fileType, creator;
|
OSType fileType, creator;
|
||||||
FSCatalogInfo catalogInfo;
|
FSCatalogInfo catalogInfo;
|
||||||
FSRef ref;
|
FSRef ref;
|
||||||
unsigned long proType, proAux;
|
uint32_t proType, proAux;
|
||||||
|
|
||||||
strcpy(path, pathname);
|
strcpy(path, pathname);
|
||||||
strcat(path, "/rsrc");
|
strcat(path, "/rsrc");
|
||||||
|
@ -128,7 +128,7 @@ Nu_ProgressDataInit_Expand(NuArchive* pArchive, NuProgressData* pProgressData,
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_ProgressDataCompressPrep(NuArchive* pArchive, NuStraw* pStraw,
|
Nu_ProgressDataCompressPrep(NuArchive* pArchive, NuStraw* pStraw,
|
||||||
NuThreadFormat threadFormat, ulong sourceLen)
|
NuThreadFormat threadFormat, uint32_t sourceLen)
|
||||||
{
|
{
|
||||||
NuProgressData* pProgressData;
|
NuProgressData* pProgressData;
|
||||||
|
|
||||||
@ -176,9 +176,9 @@ Nu_ProgressDataExpandPrep(NuArchive* pArchive, NuFunnel* pFunnel,
|
|||||||
* Compute a completion percentage.
|
* Compute a completion percentage.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
Nu_ComputePercent(ulong total, ulong progress)
|
Nu_ComputePercent(uint32_t total, uint32_t progress)
|
||||||
{
|
{
|
||||||
ulong perc;
|
uint32_t perc;
|
||||||
|
|
||||||
if (!total)
|
if (!total)
|
||||||
return 0;
|
return 0;
|
||||||
@ -305,7 +305,7 @@ Nu_FunnelFree(NuArchive* pArchive, NuFunnel* pFunnel)
|
|||||||
* failing and is actually resulting in a larger file.
|
* failing and is actually resulting in a larger file.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, ulong maxBytes)
|
Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, uint32_t maxBytes)
|
||||||
{
|
{
|
||||||
Assert(pFunnel != NULL);
|
Assert(pFunnel != NULL);
|
||||||
Assert(maxBytes > 0);
|
Assert(maxBytes > 0);
|
||||||
@ -325,8 +325,8 @@ Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, ulong maxBytes)
|
|||||||
* (The exception is courtesy Glen Bredon's "Merlin".)
|
* (The exception is courtesy Glen Bredon's "Merlin".)
|
||||||
*/
|
*/
|
||||||
static Boolean
|
static Boolean
|
||||||
Nu_CheckHighASCII(const NuFunnel* pFunnel, const unsigned char* buffer,
|
Nu_CheckHighASCII(const NuFunnel* pFunnel, const uint8_t* buffer,
|
||||||
unsigned long count)
|
uint32_t count)
|
||||||
{
|
{
|
||||||
Boolean isHighASCII;
|
Boolean isHighASCII;
|
||||||
|
|
||||||
@ -406,11 +406,11 @@ static const char gNuIsBinary[256] = {
|
|||||||
* if pFunnel->CheckStripHighASCII is set.
|
* if pFunnel->CheckStripHighASCII is set.
|
||||||
*/
|
*/
|
||||||
static NuValue
|
static NuValue
|
||||||
Nu_DetermineConversion(NuFunnel* pFunnel, const uchar* buffer, ulong count)
|
Nu_DetermineConversion(NuFunnel* pFunnel, const uint8_t* buffer, uint32_t count)
|
||||||
{
|
{
|
||||||
ulong bufCount, numBinary, numLF, numCR;
|
uint32_t bufCount, numBinary, numLF, numCR;
|
||||||
Boolean isHighASCII;
|
Boolean isHighASCII;
|
||||||
uchar val;
|
uint8_t val;
|
||||||
|
|
||||||
if (count < kNuMinConvThreshold)
|
if (count < kNuMinConvThreshold)
|
||||||
return kNuConvertOff;
|
return kNuConvertOff;
|
||||||
@ -485,7 +485,7 @@ Nu_DetermineConversion(NuFunnel* pFunnel, const uchar* buffer, ulong count)
|
|||||||
* your perspective.
|
* your perspective.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
Nu_FunnelPutBlock(NuFunnel* pFunnel, const uchar* buf, ulong len)
|
Nu_FunnelPutBlock(NuFunnel* pFunnel, const uint8_t* buf, uint32_t len)
|
||||||
{
|
{
|
||||||
Assert(pFunnel != NULL);
|
Assert(pFunnel != NULL);
|
||||||
Assert(pFunnel->pDataSink != NULL);
|
Assert(pFunnel->pDataSink != NULL);
|
||||||
@ -514,7 +514,7 @@ Nu_FunnelPutBlock(NuFunnel* pFunnel, const uchar* buf, ulong len)
|
|||||||
static inline void
|
static inline void
|
||||||
Nu_PutEOL(NuFunnel* pFunnel)
|
Nu_PutEOL(NuFunnel* pFunnel)
|
||||||
{
|
{
|
||||||
uchar ch;
|
uint8_t ch;
|
||||||
|
|
||||||
if (pFunnel->convertEOLTo == kNuEOLCR) {
|
if (pFunnel->convertEOLTo == kNuEOLCR) {
|
||||||
ch = kNuCharCR;
|
ch = kNuCharCR;
|
||||||
@ -541,10 +541,10 @@ Nu_PutEOL(NuFunnel* pFunnel)
|
|||||||
* CR, LF, or CRLF; all three get converted to whatever the system uses.
|
* CR, LF, or CRLF; all three get converted to whatever the system uses.
|
||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_FunnelWriteConvert(NuFunnel* pFunnel, const uchar* buffer, ulong count)
|
Nu_FunnelWriteConvert(NuFunnel* pFunnel, const uint8_t* buffer, uint32_t count)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
ulong progressCount = count;
|
uint32_t progressCount = count;
|
||||||
|
|
||||||
/*if (pFunnel->outMaxExceeded)
|
/*if (pFunnel->outMaxExceeded)
|
||||||
return kNuErrOutMax;*/
|
return kNuErrOutMax;*/
|
||||||
@ -589,7 +589,7 @@ Nu_FunnelWriteConvert(NuFunnel* pFunnel, const uchar* buffer, ulong count)
|
|||||||
} else {
|
} else {
|
||||||
/* do the EOL conversion and optional high-bit stripping */
|
/* do the EOL conversion and optional high-bit stripping */
|
||||||
Boolean lastCR = pFunnel->lastCR; /* make local copy */
|
Boolean lastCR = pFunnel->lastCR; /* make local copy */
|
||||||
uchar uch;
|
uint8_t uch;
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
if (pFunnel->doStripHighASCII)
|
if (pFunnel->doStripHighASCII)
|
||||||
@ -662,8 +662,8 @@ bail:
|
|||||||
* if they fit, or flushed out the bottom if not.
|
* if they fit, or flushed out the bottom if not.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_FunnelWrite(NuArchive* pArchive, NuFunnel* pFunnel, const uchar* buffer,
|
Nu_FunnelWrite(NuArchive* pArchive, NuFunnel* pFunnel, const uint8_t* buffer,
|
||||||
ulong count)
|
uint32_t count)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
|
|
||||||
@ -857,7 +857,7 @@ Nu_StrawSendProgressUpdate(NuArchive* pArchive, NuStraw* pStraw)
|
|||||||
* Read data from a straw.
|
* Read data from a straw.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uchar* buffer, long len)
|
Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uint8_t* buffer, long len)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
/*
|
/*
|
||||||
* Selected definitions from compress.h.
|
* Selected definitions from compress.h.
|
||||||
*/
|
*/
|
||||||
typedef unsigned short CODE;
|
typedef uint16_t CODE;
|
||||||
typedef unsigned char UCHAR;
|
typedef uint8_t UCHAR;
|
||||||
typedef unsigned int INTCODE;
|
typedef uint32_t INTCODE;
|
||||||
typedef unsigned int HASH;
|
typedef uint32_t HASH;
|
||||||
typedef int FLAG;
|
typedef int FLAG;
|
||||||
|
|
||||||
#ifndef FALSE /* let's get some sense to this */
|
#ifndef FALSE /* let's get some sense to this */
|
||||||
@ -80,7 +80,7 @@ static UCHAR gNu_magic_header[] = { 0x1F,0x9D };
|
|||||||
* Normally in COMPUSI.UNI.
|
* Normally in COMPUSI.UNI.
|
||||||
*/
|
*/
|
||||||
static inline ALLOCTYPE FAR *
|
static inline ALLOCTYPE FAR *
|
||||||
Nu_LZC_emalloc(NuArchive* pArchive, unsigned int x, int y)
|
Nu_LZC_emalloc(NuArchive* pArchive, uint32_t x, int y)
|
||||||
{
|
{
|
||||||
return Nu_Malloc(pArchive, x*y);
|
return Nu_Malloc(pArchive, x*y);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ Nu_LZC_efree(NuArchive* pArchive, ALLOCTYPE FAR * ptr)
|
|||||||
typedef struct LZCState {
|
typedef struct LZCState {
|
||||||
NuArchive* pArchive;
|
NuArchive* pArchive;
|
||||||
int doCalcCRC;
|
int doCalcCRC;
|
||||||
ushort crc;
|
uint16_t crc;
|
||||||
|
|
||||||
/* compression */
|
/* compression */
|
||||||
NuStraw* pStraw;
|
NuStraw* pStraw;
|
||||||
@ -163,7 +163,7 @@ typedef struct LZCState {
|
|||||||
/* expansion */
|
/* expansion */
|
||||||
FILE* infp;
|
FILE* infp;
|
||||||
NuFunnel* pFunnel;
|
NuFunnel* pFunnel;
|
||||||
ushort* pCrc;
|
uint16_t* pCrc;
|
||||||
long compRemaining;
|
long compRemaining;
|
||||||
|
|
||||||
|
|
||||||
@ -251,18 +251,18 @@ static CONST INTCODE gNu_mc[] = {
|
|||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
#ifdef DEBUG_LZC
|
#ifdef DEBUG_LZC
|
||||||
#define allocx(type, ptr, size) \
|
#define allocx(type, ptr, size) \
|
||||||
(((ptr) = (type FAR *) Nu_LZC_emalloc(pArchive, (unsigned int)(size),sizeof(type))) == NULLPTR(type) \
|
(((ptr) = (type FAR *) Nu_LZC_emalloc(pArchive, (uint32_t)(size),sizeof(type))) == NULLPTR(type) \
|
||||||
? (DBUG(("%s: "#ptr" -- ", "LZC")), NOMEM) : OK \
|
? (DBUG(("%s: "#ptr" -- ", "LZC")), NOMEM) : OK \
|
||||||
)
|
)
|
||||||
#else
|
#else
|
||||||
#define allocx(type,ptr,size) \
|
#define allocx(type,ptr,size) \
|
||||||
(((ptr) = (type FAR *) Nu_LZC_emalloc(pArchive, (unsigned int)(size),sizeof(type))) == NULLPTR(type) \
|
(((ptr) = (type FAR *) Nu_LZC_emalloc(pArchive, (uint32_t)(size),sizeof(type))) == NULLPTR(type) \
|
||||||
? NOMEM : OK \
|
? NOMEM : OK \
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define allocx(type,ptr,size) \
|
#define allocx(type,ptr,size) \
|
||||||
(((ptr) = (type FAR *) Nu_LZC_emalloc(pArchive, (unsigned int)(size),sizeof(type))) == NULLPTR(type) \
|
(((ptr) = (type FAR *) Nu_LZC_emalloc(pArchive, (uint32_t)(size),sizeof(type))) == NULLPTR(type) \
|
||||||
? NOMEM : OK \
|
? NOMEM : OK \
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
@ -558,7 +558,7 @@ static NuError
|
|||||||
Nu_LZCGetcCRC(LZCState* pLzcState, int* pSym)
|
Nu_LZCGetcCRC(LZCState* pLzcState, int* pSym)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
uchar c;
|
uint8_t c;
|
||||||
|
|
||||||
if (!pLzcState->uncompRemaining) {
|
if (!pLzcState->uncompRemaining) {
|
||||||
*pSym = kNuLZCEOF;
|
*pSym = kNuLZCEOF;
|
||||||
@ -580,7 +580,7 @@ Nu_LZCGetcCRC(LZCState* pLzcState, int* pSym)
|
|||||||
* compress stdin to stdout
|
* compress stdin to stdout
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
Nu_LZC_compress(LZCState* pLzcState, ulong* pDstLen)
|
Nu_LZC_compress(LZCState* pLzcState, uint32_t* pDstLen)
|
||||||
{
|
{
|
||||||
int c,adjbits;
|
int c,adjbits;
|
||||||
register HASH hash;
|
register HASH hash;
|
||||||
@ -760,7 +760,7 @@ Nu_LZC_compress(LZCState* pLzcState, ulong* pDstLen)
|
|||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_CompressLZC(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressLZC(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc, int maxbits)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc, int maxbits)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
LZCState lzcState;
|
LZCState lzcState;
|
||||||
@ -808,14 +808,14 @@ Nu_CompressLZC(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
|||||||
|
|
||||||
NuError
|
NuError
|
||||||
Nu_CompressLZC12(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressLZC12(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
return Nu_CompressLZC(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, 12);
|
return Nu_CompressLZC(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
NuError
|
NuError
|
||||||
Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
return Nu_CompressLZC(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, 16);
|
return Nu_CompressLZC(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, 16);
|
||||||
}
|
}
|
||||||
@ -839,9 +839,9 @@ Nu_LZCPutcCRC(LZCState* pLzcState, char c)
|
|||||||
NuError err;
|
NuError err;
|
||||||
|
|
||||||
err = Nu_FunnelWrite(pLzcState->pArchive, pLzcState->pFunnel,
|
err = Nu_FunnelWrite(pLzcState->pArchive, pLzcState->pFunnel,
|
||||||
(uchar*) &c, 1);
|
(uint8_t*) &c, 1);
|
||||||
if (pLzcState->doCalcCRC)
|
if (pLzcState->doCalcCRC)
|
||||||
pLzcState->crc = Nu_CalcCRC16(pLzcState->crc, (uchar*) &c, 1);
|
pLzcState->crc = Nu_CalcCRC16(pLzcState->crc, (uint8_t*) &c, 1);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -899,7 +899,7 @@ Nu_LZC_nextcode(LZCState* pLzcState, INTCODE* codeptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Nu_LZC_decompress(LZCState* pLzcState, ulong compressedLen)
|
Nu_LZC_decompress(LZCState* pLzcState, uint32_t compressedLen)
|
||||||
{
|
{
|
||||||
NuArchive* pArchive = pLzcState->pArchive;
|
NuArchive* pArchive = pLzcState->pArchive;
|
||||||
register int i;
|
register int i;
|
||||||
@ -1062,7 +1062,7 @@ Nu_LZC_decompress(LZCState* pLzcState, ulong compressedLen)
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord,
|
Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc)
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
LZCState lzcState;
|
LZCState lzcState;
|
||||||
|
189
nufxlib/Lzw.c
189
nufxlib/Lzw.c
@ -119,17 +119,17 @@ static const int gNuBitMask[] = {
|
|||||||
typedef struct LZWCompressState {
|
typedef struct LZWCompressState {
|
||||||
NuArchive* pArchive;
|
NuArchive* pArchive;
|
||||||
|
|
||||||
ushort entry[kNuLZWHashSize]; /* uint or ushort */
|
uint16_t entry[kNuLZWHashSize]; /* uint or ushort */
|
||||||
ushort prefix[kNuLZWMaxCode+1]; /* uint or ushort */
|
uint16_t prefix[kNuLZWMaxCode+1]; /* uint or ushort */
|
||||||
uchar suffix[kNuLZWMaxCode+1];
|
uint8_t suffix[kNuLZWMaxCode+1];
|
||||||
|
|
||||||
ushort hashFunc[kNuLZWHashFuncTblSize]; /* uint or ushort */
|
uint16_t hashFunc[kNuLZWHashFuncTblSize]; /* uint or ushort */
|
||||||
|
|
||||||
uchar inputBuf[kNuLZWBlockSize]; /* 4K of raw input */
|
uint8_t inputBuf[kNuLZWBlockSize]; /* 4K of raw input */
|
||||||
uchar rleBuf[kNuLZWBlockSize*2 + kNuSafetyPadding];
|
uint8_t rleBuf[kNuLZWBlockSize*2 + kNuSafetyPadding];
|
||||||
uchar lzwBuf[(kNuLZWBlockSize * 3) / 2 + kNuSafetyPadding];
|
uint8_t lzwBuf[(kNuLZWBlockSize * 3) / 2 + kNuSafetyPadding];
|
||||||
|
|
||||||
ushort chunkCrc; /* CRC for LZW/1 */
|
uint16_t chunkCrc; /* CRC for LZW/1 */
|
||||||
|
|
||||||
/* LZW/2 state variables */
|
/* LZW/2 state variables */
|
||||||
int nextFree;
|
int nextFree;
|
||||||
@ -194,10 +194,10 @@ Nu_AllocLZWCompressState(NuArchive* pArchive)
|
|||||||
static NuError
|
static NuError
|
||||||
Nu_CompressBlockRLE(LZWCompressState* lzwState, int* pRLESize)
|
Nu_CompressBlockRLE(LZWCompressState* lzwState, int* pRLESize)
|
||||||
{
|
{
|
||||||
const uchar* inPtr = lzwState->inputBuf;
|
const uint8_t* inPtr = lzwState->inputBuf;
|
||||||
const uchar* endPtr = inPtr + kNuLZWBlockSize;
|
const uint8_t* endPtr = inPtr + kNuLZWBlockSize;
|
||||||
uchar* outPtr = lzwState->rleBuf;
|
uint8_t* outPtr = lzwState->rleBuf;
|
||||||
uchar matchChar;
|
uint8_t matchChar;
|
||||||
int matchCount;
|
int matchCount;
|
||||||
|
|
||||||
while (inPtr < endPtr) {
|
while (inPtr < endPtr) {
|
||||||
@ -297,10 +297,10 @@ Nu_ClearLZWTable(LZWCompressState* lzwState)
|
|||||||
* (Turning this into a macro might speed things up.)
|
* (Turning this into a macro might speed things up.)
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
Nu_LZWPutCode(uchar** pOutBuf, ulong prefixCode, int codeBits, int* pAtBit)
|
Nu_LZWPutCode(uint8_t** pOutBuf, uint32_t prefixCode, int codeBits, int* pAtBit)
|
||||||
{
|
{
|
||||||
int atBit = *pAtBit;
|
int atBit = *pAtBit;
|
||||||
uchar* outBuf = *pOutBuf;
|
uint8_t* outBuf = *pOutBuf;
|
||||||
|
|
||||||
/*DBUG_LZW(("### PUT: prefixCode=0x%04lx, codeBits=%d, atBit=%d\n",
|
/*DBUG_LZW(("### PUT: prefixCode=0x%04lx, codeBits=%d, atBit=%d\n",
|
||||||
prefixCode, codeBits, atBit));*/
|
prefixCode, codeBits, atBit));*/
|
||||||
@ -313,20 +313,20 @@ Nu_LZWPutCode(uchar** pOutBuf, ulong prefixCode, int codeBits, int* pAtBit)
|
|||||||
|
|
||||||
/* merge it with the buffer contents (if necessary) and write lo bits */
|
/* merge it with the buffer contents (if necessary) and write lo bits */
|
||||||
outBuf--;
|
outBuf--;
|
||||||
*outBuf = (uchar)((*outBuf & gNuBitMask[atBit]) | prefixCode);
|
*outBuf = (uint8_t)((*outBuf & gNuBitMask[atBit]) | prefixCode);
|
||||||
outBuf++;
|
outBuf++;
|
||||||
} else {
|
} else {
|
||||||
/* nothing to merge with; write lo byte at next posn and advance */
|
/* nothing to merge with; write lo byte at next posn and advance */
|
||||||
*outBuf++ = (uchar)prefixCode;
|
*outBuf++ = (uint8_t)prefixCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* codes are at least 9 bits, so we know we have to write one more */
|
/* codes are at least 9 bits, so we know we have to write one more */
|
||||||
*outBuf++ = (uchar)(prefixCode >> 8);
|
*outBuf++ = (uint8_t)(prefixCode >> 8);
|
||||||
|
|
||||||
/* in some cases, we may have to write yet another */
|
/* in some cases, we may have to write yet another */
|
||||||
atBit += codeBits;
|
atBit += codeBits;
|
||||||
if (atBit > 16)
|
if (atBit > 16)
|
||||||
*outBuf++ = (uchar)(prefixCode >> 16);
|
*outBuf++ = (uint8_t)(prefixCode >> 16);
|
||||||
|
|
||||||
*pAtBit = atBit & 0x07;
|
*pAtBit = atBit & 0x07;
|
||||||
*pOutBuf = outBuf;
|
*pOutBuf = outBuf;
|
||||||
@ -354,19 +354,19 @@ Nu_LZWPutCode(uchar** pOutBuf, ulong prefixCode, int codeBits, int* pAtBit)
|
|||||||
* lost in this situation.
|
* lost in this situation.
|
||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_CompressLZWBlock(LZWCompressState* lzwState, const uchar* inputBuf,
|
Nu_CompressLZWBlock(LZWCompressState* lzwState, const uint8_t* inputBuf,
|
||||||
int inputCount, int* pOutputCount)
|
int inputCount, int* pOutputCount)
|
||||||
{
|
{
|
||||||
int nextFree, ic, atBit, codeBits;
|
int nextFree, ic, atBit, codeBits;
|
||||||
int hash, hashDelta;
|
int hash, hashDelta;
|
||||||
int prefixCode, code, highCode;
|
int prefixCode, code, highCode;
|
||||||
const uchar* inputEnd = inputBuf + inputCount;
|
const uint8_t* inputEnd = inputBuf + inputCount;
|
||||||
/* local copies of lzwState members, for speed */
|
/* local copies of lzwState members, for speed */
|
||||||
const ushort* pHashFunc = lzwState->hashFunc;
|
const uint16_t* pHashFunc = lzwState->hashFunc;
|
||||||
ushort* pEntry = lzwState->entry;
|
uint16_t* pEntry = lzwState->entry;
|
||||||
ushort* pPrefix = lzwState->prefix;
|
uint16_t* pPrefix = lzwState->prefix;
|
||||||
uchar* pSuffix = lzwState->suffix;
|
uint8_t* pSuffix = lzwState->suffix;
|
||||||
uchar* outBuf = lzwState->lzwBuf;
|
uint8_t* outBuf = lzwState->lzwBuf;
|
||||||
|
|
||||||
Assert(lzwState != NULL);
|
Assert(lzwState != NULL);
|
||||||
Assert(inputBuf != NULL);
|
Assert(inputBuf != NULL);
|
||||||
@ -557,13 +557,13 @@ Nu_CompressLZWBlock(LZWCompressState* lzwState, const uchar* inputBuf,
|
|||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_CompressLZW(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressLZW(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pThreadCrc, Boolean isType2)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pThreadCrc, Boolean isType2)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
LZWCompressState* lzwState;
|
LZWCompressState* lzwState;
|
||||||
long initialOffset;
|
long initialOffset;
|
||||||
const uchar* lzwInputBuf;
|
const uint8_t* lzwInputBuf;
|
||||||
uint blockSize, rleSize, lzwSize;
|
uint32_t blockSize, rleSize, lzwSize;
|
||||||
long compressedLen;
|
long compressedLen;
|
||||||
Boolean keepLzw;
|
Boolean keepLzw;
|
||||||
|
|
||||||
@ -784,7 +784,7 @@ bail:
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
return Nu_CompressLZW(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, false);
|
return Nu_CompressLZW(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, false);
|
||||||
}
|
}
|
||||||
@ -794,7 +794,7 @@ Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
return Nu_CompressLZW(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, true);
|
return Nu_CompressLZW(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, true);
|
||||||
}
|
}
|
||||||
@ -813,21 +813,21 @@ Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
|||||||
/*
|
/*
|
||||||
* Static tables useful for bit manipulation.
|
* Static tables useful for bit manipulation.
|
||||||
*/
|
*/
|
||||||
static const uint gNuMaskTable[17] = {
|
static const uint32_t gNuMaskTable[17] = {
|
||||||
0x0000, 0x01ff, 0x03ff, 0x03ff, 0x07ff, 0x07ff, 0x07ff, 0x07ff,
|
0x0000, 0x01ff, 0x03ff, 0x03ff, 0x07ff, 0x07ff, 0x07ff, 0x07ff,
|
||||||
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
|
||||||
0x0fff
|
0x0fff
|
||||||
};
|
};
|
||||||
/* convert high byte of "entry" into a bit width */
|
/* convert high byte of "entry" into a bit width */
|
||||||
static const uint gNuBitWidth[17] = {
|
static const uint32_t gNuBitWidth[17] = {
|
||||||
8,9,10,10,11,11,11,11,12,12,12,12,12,12,12,12,12
|
8,9,10,10,11,11,11,11,12,12,12,12,12,12,12,12,12
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* entry in the trie */
|
/* entry in the trie */
|
||||||
typedef struct TableEntry {
|
typedef struct TableEntry {
|
||||||
uchar ch;
|
uint8_t ch;
|
||||||
uint prefix;
|
uint32_t prefix;
|
||||||
} TableEntry;
|
} TableEntry;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -839,25 +839,26 @@ typedef struct LZWExpandState {
|
|||||||
NuArchive* pArchive;
|
NuArchive* pArchive;
|
||||||
|
|
||||||
TableEntry trie[4096-256]; /* holds from 9 bits to 12 bits */
|
TableEntry trie[4096-256]; /* holds from 9 bits to 12 bits */
|
||||||
uchar stack[kNuLZWBlockSize];
|
uint8_t stack[kNuLZWBlockSize];
|
||||||
|
|
||||||
uint entry; /* 16-bit index into table */
|
// some of these don't need to be 32 bits; they were "uint" before
|
||||||
uint oldcode; /* carryover state for LZW/2 */
|
uint32_t entry; /* 16-bit index into table */
|
||||||
uint incode; /* carryover state for LZW/2 */
|
uint32_t oldcode; /* carryover state for LZW/2 */
|
||||||
uint finalc; /* carryover state for LZW/2 */
|
uint32_t incode; /* carryover state for LZW/2 */
|
||||||
|
uint32_t finalc; /* carryover state for LZW/2 */
|
||||||
Boolean resetFix; /* work around an LZW/2 bug */
|
Boolean resetFix; /* work around an LZW/2 bug */
|
||||||
|
|
||||||
ushort chunkCrc; /* CRC we calculate for LZW/1 */
|
uint16_t chunkCrc; /* CRC we calculate for LZW/1 */
|
||||||
ushort fileCrc; /* CRC stored with file */
|
uint16_t fileCrc; /* CRC stored with file */
|
||||||
|
|
||||||
uchar diskVol; /* disk volume # */
|
uint8_t diskVol; /* disk volume # */
|
||||||
uchar rleEscape; /* RLE escape char, usually 0xdb */
|
uint8_t rleEscape; /* RLE escape char, usually 0xdb */
|
||||||
|
|
||||||
ulong dataInBuffer; /* #of bytes in compBuf */
|
uint32_t dataInBuffer; /* #of bytes in compBuf */
|
||||||
uchar* dataPtr; /* current data offset */
|
uint8_t* dataPtr; /* current data offset */
|
||||||
|
|
||||||
uchar lzwOutBuf[kNuLZWBlockSize + kNuSafetyPadding];
|
uint8_t lzwOutBuf[kNuLZWBlockSize + kNuSafetyPadding];
|
||||||
uchar rleOutBuf[kNuLZWBlockSize + kNuSafetyPadding];
|
uint8_t rleOutBuf[kNuLZWBlockSize + kNuSafetyPadding];
|
||||||
} LZWExpandState;
|
} LZWExpandState;
|
||||||
|
|
||||||
|
|
||||||
@ -897,7 +898,8 @@ Nu_AllocLZWExpandState(NuArchive* pArchive)
|
|||||||
# define Nu_LZWStackEmpty() ( stackPtr == lzwState->stack )
|
# define Nu_LZWStackEmpty() ( stackPtr == lzwState->stack )
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
Nu_LZWPushCheck(uchar uch, const LZWExpandState* lzwState,const uchar* stackPtr)
|
Nu_LZWPushCheck(uint8_t uch, const LZWExpandState* lzwState,
|
||||||
|
const uint8_t* stackPtr)
|
||||||
{
|
{
|
||||||
if (stackPtr >= lzwState->stack + sizeof(lzwState->stack)) {
|
if (stackPtr >= lzwState->stack + sizeof(lzwState->stack)) {
|
||||||
Nu_ReportError(lzwState->NU_BLOB, kNuErrBadData, "stack overflow");
|
Nu_ReportError(lzwState->NU_BLOB, kNuErrBadData, "stack overflow");
|
||||||
@ -906,7 +908,7 @@ Nu_LZWPushCheck(uchar uch, const LZWExpandState* lzwState,const uchar* stackPtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
Nu_LZWPopCheck(const LZWExpandState* lzwState, const uchar* stackPtr)
|
Nu_LZWPopCheck(const LZWExpandState* lzwState, const uint8_t* stackPtr)
|
||||||
{
|
{
|
||||||
if (stackPtr == lzwState->stack) {
|
if (stackPtr == lzwState->stack) {
|
||||||
Nu_ReportError(lzwState->NU_BLOB, kNuErrBadData, "stack underflow");
|
Nu_ReportError(lzwState->NU_BLOB, kNuErrBadData, "stack underflow");
|
||||||
@ -928,12 +930,10 @@ Nu_LZWPopCheck(const LZWExpandState* lzwState, const uchar* stackPtr)
|
|||||||
* (Turning this into a macro might speed things up.)
|
* (Turning this into a macro might speed things up.)
|
||||||
*/
|
*/
|
||||||
static inline uint
|
static inline uint
|
||||||
Nu_LZWGetCode(const uchar** pInBuf, uint entry, int* pAtBit, uint* pLastByte)
|
Nu_LZWGetCode(const uint8_t** pInBuf, uint32_t entry, int* pAtBit, uint* pLastByte)
|
||||||
{
|
{
|
||||||
uint numBits, startBit, lastBit;
|
uint32_t numBits, startBit, lastBit;
|
||||||
ulong value;
|
uint32_t value;
|
||||||
|
|
||||||
Assert(sizeof(uint) >= 2);
|
|
||||||
|
|
||||||
numBits = (entry +1) >> 8; /* bit-width of next code */
|
numBits = (entry +1) >> 8; /* bit-width of next code */
|
||||||
startBit = *pAtBit;
|
startBit = *pAtBit;
|
||||||
@ -952,7 +952,7 @@ Nu_LZWGetCode(const uchar** pInBuf, uint entry, int* pAtBit, uint* pLastByte)
|
|||||||
/* need two more bytes */
|
/* need two more bytes */
|
||||||
value |= *(*pInBuf)++ << 8;
|
value |= *(*pInBuf)++ << 8;
|
||||||
*pLastByte = *(*pInBuf)++;
|
*pLastByte = *(*pInBuf)++;
|
||||||
value |= (ulong) *pLastByte << 16;
|
value |= (uint32_t) *pLastByte << 16;
|
||||||
} else {
|
} else {
|
||||||
/* only need one more byte */
|
/* only need one more byte */
|
||||||
*pLastByte = *(*pInBuf)++;
|
*pLastByte = *(*pInBuf)++;
|
||||||
@ -978,17 +978,17 @@ Nu_LZWGetCode(const uchar** pInBuf, uint entry, int* pAtBit, uint* pLastByte)
|
|||||||
* Reads from lzwState->dataPtr, writes to lzwState->lzwOutBuf.
|
* Reads from lzwState->dataPtr, writes to lzwState->lzwOutBuf.
|
||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_ExpandLZW1(LZWExpandState* lzwState, uint expectedLen)
|
Nu_ExpandLZW1(LZWExpandState* lzwState, uint32_t expectedLen)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
TableEntry* tablePtr;
|
TableEntry* tablePtr;
|
||||||
int atBit;
|
int atBit;
|
||||||
uint entry, oldcode, incode, ptr;
|
uint32_t entry, oldcode, incode, ptr;
|
||||||
uint lastByte, finalc;
|
uint32_t lastByte, finalc;
|
||||||
const uchar* inbuf;
|
const uint8_t* inbuf;
|
||||||
uchar* outbuf;
|
uint8_t* outbuf;
|
||||||
uchar* outbufend;
|
uint8_t* outbufend;
|
||||||
uchar* stackPtr;
|
uint8_t* stackPtr;
|
||||||
|
|
||||||
Assert(lzwState != NULL);
|
Assert(lzwState != NULL);
|
||||||
Assert(expectedLen > 0 && expectedLen <= kNuLZWBlockSize);
|
Assert(expectedLen > 0 && expectedLen <= kNuLZWBlockSize);
|
||||||
@ -1024,7 +1024,7 @@ Nu_ExpandLZW1(LZWExpandState* lzwState, uint expectedLen)
|
|||||||
err = kNuErrBadData;
|
err = kNuErrBadData;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
Nu_LZWPush((uchar)finalc);
|
Nu_LZWPush((uint8_t)finalc);
|
||||||
ptr = oldcode;
|
ptr = oldcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1062,7 +1062,7 @@ bail:
|
|||||||
/* adjust input buffer */
|
/* adjust input buffer */
|
||||||
lzwState->dataInBuffer -= (inbuf - lzwState->dataPtr);
|
lzwState->dataInBuffer -= (inbuf - lzwState->dataPtr);
|
||||||
Assert(lzwState->dataInBuffer < 32767*65536);
|
Assert(lzwState->dataInBuffer < 32767*65536);
|
||||||
lzwState->dataPtr = (uchar*)inbuf;
|
lzwState->dataPtr = (uint8_t*)inbuf;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -1078,19 +1078,19 @@ bail:
|
|||||||
* value is not known.
|
* value is not known.
|
||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_ExpandLZW2(LZWExpandState* lzwState, uint expectedLen,
|
Nu_ExpandLZW2(LZWExpandState* lzwState, uint32_t expectedLen,
|
||||||
uint expectedInputUsed)
|
uint32_t expectedInputUsed)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
TableEntry* tablePtr;
|
TableEntry* tablePtr;
|
||||||
int atBit;
|
int atBit;
|
||||||
uint entry, oldcode, incode, ptr;
|
uint32_t entry, oldcode, incode, ptr;
|
||||||
uint lastByte, finalc;
|
uint32_t lastByte, finalc;
|
||||||
const uchar* inbuf;
|
const uint8_t* inbuf;
|
||||||
const uchar* inbufend;
|
const uint8_t* inbufend;
|
||||||
uchar* outbuf;
|
uint8_t* outbuf;
|
||||||
uchar* outbufend;
|
uint8_t* outbufend;
|
||||||
uchar* stackPtr;
|
uint8_t* stackPtr;
|
||||||
|
|
||||||
/*DBUG_LZW(("### LZW/2 block start (compIn=%d, rleOut=%d, entry=0x%04x)\n",
|
/*DBUG_LZW(("### LZW/2 block start (compIn=%d, rleOut=%d, entry=0x%04x)\n",
|
||||||
expectedInputUsed, expectedLen, lzwState->entry));*/
|
expectedInputUsed, expectedLen, lzwState->entry));*/
|
||||||
@ -1171,7 +1171,7 @@ main_loop:
|
|||||||
err = kNuErrBadData;
|
err = kNuErrBadData;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
Nu_LZWPush((uchar)finalc);
|
Nu_LZWPush((uint8_t)finalc);
|
||||||
ptr = oldcode;
|
ptr = oldcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1203,7 +1203,7 @@ main_loop:
|
|||||||
|
|
||||||
bail:
|
bail:
|
||||||
/*DBUG_LZW(("### end of block\n"));*/
|
/*DBUG_LZW(("### end of block\n"));*/
|
||||||
if (expectedInputUsed != (unsigned int) -1 && inbuf != inbufend) {
|
if (expectedInputUsed != (uint32_t) -1 && inbuf != inbufend) {
|
||||||
/* data was corrupted; if we keep going this will get worse */
|
/* data was corrupted; if we keep going this will get worse */
|
||||||
DBUG(("--- inbuf != inbufend in ExpandLZW2 (diff=%d)\n",
|
DBUG(("--- inbuf != inbufend in ExpandLZW2 (diff=%d)\n",
|
||||||
inbufend - inbuf));
|
inbufend - inbuf));
|
||||||
@ -1215,7 +1215,7 @@ bail:
|
|||||||
/* adjust input buffer */
|
/* adjust input buffer */
|
||||||
lzwState->dataInBuffer -= (inbuf - lzwState->dataPtr);
|
lzwState->dataInBuffer -= (inbuf - lzwState->dataPtr);
|
||||||
Assert(lzwState->dataInBuffer < 32767*65536);
|
Assert(lzwState->dataInBuffer < 32767*65536);
|
||||||
lzwState->dataPtr = (uchar*)inbuf;
|
lzwState->dataPtr = (uint8_t*)inbuf;
|
||||||
|
|
||||||
/* save off local copies of stuff */
|
/* save off local copies of stuff */
|
||||||
lzwState->entry = entry;
|
lzwState->entry = entry;
|
||||||
@ -1231,14 +1231,14 @@ bail:
|
|||||||
* Expands a chunk of RLEd data into 4K of output.
|
* Expands a chunk of RLEd data into 4K of output.
|
||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_ExpandRLE(LZWExpandState* lzwState, const uchar* inbuf,
|
Nu_ExpandRLE(LZWExpandState* lzwState, const uint8_t* inbuf,
|
||||||
uint expectedInputUsed)
|
uint32_t expectedInputUsed)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
uchar *outbuf;
|
uint8_t *outbuf;
|
||||||
uchar *outbufend;
|
uint8_t *outbufend;
|
||||||
const uchar *inbufend;
|
const uint8_t *inbufend;
|
||||||
uchar uch, rleEscape;
|
uint8_t uch, rleEscape;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
outbuf = lzwState->rleOutBuf;
|
outbuf = lzwState->rleOutBuf;
|
||||||
@ -1284,7 +1284,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Utility function to get a byte from the input buffer.
|
* Utility function to get a byte from the input buffer.
|
||||||
*/
|
*/
|
||||||
static inline uchar
|
static inline uint8_t
|
||||||
Nu_GetHeaderByte(LZWExpandState* lzwState)
|
Nu_GetHeaderByte(LZWExpandState* lzwState)
|
||||||
{
|
{
|
||||||
lzwState->dataInBuffer--;
|
lzwState->dataInBuffer--;
|
||||||
@ -1304,12 +1304,13 @@ Nu_GetHeaderByte(LZWExpandState* lzwState)
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pThreadCrc)
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel,
|
||||||
|
uint16_t* pThreadCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
Boolean isType2;
|
Boolean isType2;
|
||||||
LZWExpandState* lzwState;
|
LZWExpandState* lzwState;
|
||||||
ulong compRemaining, uncompRemaining, minSize;
|
uint32_t compRemaining, uncompRemaining, minSize;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(pThread != NULL);
|
Assert(pThread != NULL);
|
||||||
@ -1396,11 +1397,11 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
while (uncompRemaining) {
|
while (uncompRemaining) {
|
||||||
Boolean rleUsed;
|
Boolean rleUsed;
|
||||||
Boolean lzwUsed;
|
Boolean lzwUsed;
|
||||||
ulong getSize;
|
uint32_t getSize;
|
||||||
uint rleLen; /* length after RLE; 4096 if no RLE */
|
uint32_t rleLen; /* length after RLE; 4096 if no RLE */
|
||||||
uint lzwLen = 0; /* type 2 only */
|
uint32_t lzwLen = 0; /* type 2 only */
|
||||||
uint writeLen, inCount;
|
uint32_t writeLen, inCount;
|
||||||
const uchar* writeBuf;
|
const uint8_t* writeBuf;
|
||||||
|
|
||||||
/* if we're low, and there's more data available, read more */
|
/* if we're low, and there's more data available, read more */
|
||||||
if (lzwState->dataInBuffer < kNuLZWDesiredChunk && compRemaining) {
|
if (lzwState->dataInBuffer < kNuLZWDesiredChunk && compRemaining) {
|
||||||
@ -1429,7 +1430,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
getSize);
|
getSize);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"failed reading compressed data (%ld bytes)", getSize);
|
"failed reading compressed data (%u bytes)", getSize);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
lzwState->dataInBuffer += getSize;
|
lzwState->dataInBuffer += getSize;
|
||||||
@ -1491,7 +1492,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
} else {
|
} else {
|
||||||
if (pRecord->isBadMac || pArchive->valIgnoreLZW2Len) {
|
if (pRecord->isBadMac || pArchive->valIgnoreLZW2Len) {
|
||||||
/* might be big-endian, might be okay; just ignore it */
|
/* might be big-endian, might be okay; just ignore it */
|
||||||
lzwLen = (unsigned int) -1;
|
lzwLen = (uint32_t) -1;
|
||||||
} else if (lzwState->dataInBuffer < lzwLen) {
|
} else if (lzwState->dataInBuffer < lzwLen) {
|
||||||
/* rare -- GSHK will do this if you don't let it finish */
|
/* rare -- GSHK will do this if you don't let it finish */
|
||||||
err = kNuErrBufferUnderrun;
|
err = kNuErrBufferUnderrun;
|
||||||
@ -1590,7 +1591,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
DBUG(("--- Found %ld bytes following compressed data (compRem=%ld)\n",
|
DBUG(("--- Found %ld bytes following compressed data (compRem=%ld)\n",
|
||||||
lzwState->dataInBuffer, compRemaining));
|
lzwState->dataInBuffer, compRemaining));
|
||||||
if (lzwState->dataInBuffer > 32) {
|
if (lzwState->dataInBuffer > 32) {
|
||||||
Nu_ReportError(NU_BLOB, kNuErrNone, "(Warning) lots of fluff (%ld)",
|
Nu_ReportError(NU_BLOB, kNuErrNone, "(Warning) lots of fluff (%u)",
|
||||||
lzwState->dataInBuffer);
|
lzwState->dataInBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1602,7 +1603,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
if (compRemaining) {
|
if (compRemaining) {
|
||||||
err = kNuErrBadData;
|
err = kNuErrBadData;
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"not all compressed data was used (%ld/%ld)",
|
"not all compressed data was used (%u/%u)",
|
||||||
compRemaining, lzwState->dataInBuffer);
|
compRemaining, lzwState->dataInBuffer);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ typedef unsigned char Boolean;
|
|||||||
(x) <= '9' ? (x) - '0' : toupper(x) +10 - 'A' )
|
(x) <= '9' ? (x) - '0' : toupper(x) +10 - 'A' )
|
||||||
|
|
||||||
/* convert number from 0-15 to hex digit */
|
/* convert number from 0-15 to hex digit */
|
||||||
#define HexConv(x) ( ((uint)(x)) <= 15 ? \
|
#define HexConv(x) ( ((unsigned int)(x)) <= 15 ? \
|
||||||
( (x) <= 9 ? (x) + '0' : (x) -10 + 'A') : -1 )
|
( (x) <= 9 ? (x) + '0' : (x) -10 + 'A') : -1 )
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,7 +330,8 @@ Nu_Malloc(NuArchive* pArchive, size_t size)
|
|||||||
Assert(size > 0);
|
Assert(size > 0);
|
||||||
_result = malloc(size);
|
_result = malloc(size);
|
||||||
if (_result == NULL) {
|
if (_result == NULL) {
|
||||||
Nu_ReportError(NU_BLOB, kNuErrMalloc, "malloc(%u) failed", (uint) size);
|
Nu_ReportError(NU_BLOB, kNuErrMalloc,
|
||||||
|
"malloc(%u) failed", (unsigned int) size);
|
||||||
DebugAbort(); /* leave a core dump if we're built for it */
|
DebugAbort(); /* leave a core dump if we're built for it */
|
||||||
}
|
}
|
||||||
DebugFill(_result, size);
|
DebugFill(_result, size);
|
||||||
@ -354,7 +355,8 @@ Nu_Realloc(NuArchive* pArchive, void* ptr, size_t size)
|
|||||||
Assert(size > 0); /* disallow this usage */
|
Assert(size > 0); /* disallow this usage */
|
||||||
_result = realloc(ptr, size);
|
_result = realloc(ptr, size);
|
||||||
if (_result == NULL) {
|
if (_result == NULL) {
|
||||||
Nu_ReportError(NU_BLOB, kNuErrMalloc, "realloc(%u) failed",(uint) size);
|
Nu_ReportError(NU_BLOB, kNuErrMalloc,
|
||||||
|
"realloc(%u) failed", (unsigned int) size);
|
||||||
DebugAbort(); /* leave a core dump if we're built for it */
|
DebugAbort(); /* leave a core dump if we're built for it */
|
||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define __NufxLib__
|
#define __NufxLib__
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -148,27 +149,27 @@ typedef enum NuResult {
|
|||||||
* NuRecordIdxs are assigned to records in an archive. You may assume that
|
* NuRecordIdxs are assigned to records in an archive. You may assume that
|
||||||
* the values are unique, but that is all.
|
* the values are unique, but that is all.
|
||||||
*/
|
*/
|
||||||
typedef unsigned long NuRecordIdx;
|
typedef uint32_t NuRecordIdx;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NuThreadIdxs are assigned to threads within a record. Again, you may
|
* NuThreadIdxs are assigned to threads within a record. Again, you may
|
||||||
* assume that the values are unique within a record, but that is all.
|
* assume that the values are unique within a record, but that is all.
|
||||||
*/
|
*/
|
||||||
typedef unsigned long NuThreadIdx;
|
typedef uint32_t NuThreadIdx;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Thread ID, a combination of thread_class and thread_kind. Standard
|
* Thread ID, a combination of thread_class and thread_kind. Standard
|
||||||
* values have explicit identifiers.
|
* values have explicit identifiers.
|
||||||
*/
|
*/
|
||||||
typedef unsigned long NuThreadID;
|
typedef uint32_t NuThreadID;
|
||||||
#define NuMakeThreadID(class, kind) /* construct a NuThreadID */ \
|
#define NuMakeThreadID(class, kind) /* construct a NuThreadID */ \
|
||||||
((unsigned long)(class) << 16 | (unsigned long)(kind))
|
((uint32_t)(class) << 16 | (uint32_t)(kind))
|
||||||
#define NuGetThreadID(pThread) /* pull NuThreadID out of NuThread */ \
|
#define NuGetThreadID(pThread) /* pull NuThreadID out of NuThread */ \
|
||||||
(NuMakeThreadID((pThread)->thThreadClass, (pThread)->thThreadKind))
|
(NuMakeThreadID((pThread)->thThreadClass, (pThread)->thThreadKind))
|
||||||
#define NuThreadIDGetClass(threadID) /* get threadClass from NuThreadID */ \
|
#define NuThreadIDGetClass(threadID) /* get threadClass from NuThreadID */ \
|
||||||
((unsigned short) ((unsigned long)(threadID) >> 16))
|
((uint16_t) ((uint32_t)(threadID) >> 16))
|
||||||
#define NuThreadIDGetKind(threadID) /* get threadKind from NuThreadID */ \
|
#define NuThreadIDGetKind(threadID) /* get threadKind from NuThreadID */ \
|
||||||
((unsigned short) ((threadID) & 0xffff))
|
((uint16_t) ((threadID) & 0xffff))
|
||||||
#define kNuThreadClassMessage 0x0000
|
#define kNuThreadClassMessage 0x0000
|
||||||
#define kNuThreadClassControl 0x0001
|
#define kNuThreadClassControl 0x0001
|
||||||
#define kNuThreadClassData 0x0002
|
#define kNuThreadClassData 0x0002
|
||||||
@ -201,7 +202,7 @@ typedef enum NuThreadFormat {
|
|||||||
((char) ((sysInfo) & 0xff))
|
((char) ((sysInfo) & 0xff))
|
||||||
/* return a file_sys_info with a replaced filesystem separator */
|
/* return a file_sys_info with a replaced filesystem separator */
|
||||||
#define NuSetSepInSysInfo(sysInfo, newSep) \
|
#define NuSetSepInSysInfo(sysInfo, newSep) \
|
||||||
((unsigned short) (((sysInfo) & 0xff00) | ((newSep) & 0xff)) )
|
((uint16_t) (((sysInfo) & 0xff00) | ((newSep) & 0xff)) )
|
||||||
|
|
||||||
/* GS/OS-defined file system identifiers; sadly, UNIX is not among them */
|
/* GS/OS-defined file system identifiers; sadly, UNIX is not among them */
|
||||||
typedef enum NuFileSysID {
|
typedef enum NuFileSysID {
|
||||||
@ -273,7 +274,7 @@ typedef enum NuValueID {
|
|||||||
kNuValueIgnoreLZW2Len = 14,
|
kNuValueIgnoreLZW2Len = 14,
|
||||||
kNuValueHandleBadMac = 15
|
kNuValueHandleBadMac = 15
|
||||||
} NuValueID;
|
} NuValueID;
|
||||||
typedef unsigned long NuValue;
|
typedef uint32_t NuValue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enumerated values for things you pass in a NuValue.
|
* Enumerated values for things you pass in a NuValue.
|
||||||
@ -322,7 +323,7 @@ typedef enum NuAttrID {
|
|||||||
kNuAttrHeaderOffset = 3,
|
kNuAttrHeaderOffset = 3,
|
||||||
kNuAttrJunkOffset = 4,
|
kNuAttrJunkOffset = 4,
|
||||||
} NuAttrID;
|
} NuAttrID;
|
||||||
typedef unsigned long NuAttr;
|
typedef uint32_t NuAttr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Archive types.
|
* Archive types.
|
||||||
@ -381,14 +382,14 @@ typedef union NuDataSink NuDataSink; /* dummy def for internal struct */
|
|||||||
* NuFX Date/Time structure; same as TimeRec from IIgs "misctool.h".
|
* NuFX Date/Time structure; same as TimeRec from IIgs "misctool.h".
|
||||||
*/
|
*/
|
||||||
typedef struct NuDateTime {
|
typedef struct NuDateTime {
|
||||||
unsigned char second; /* 0-59 */
|
uint8_t second; /* 0-59 */
|
||||||
unsigned char minute; /* 0-59 */
|
uint8_t minute; /* 0-59 */
|
||||||
unsigned char hour; /* 0-23 */
|
uint8_t hour; /* 0-23 */
|
||||||
unsigned char year; /* year - 1900 */
|
uint8_t year; /* year - 1900 */
|
||||||
unsigned char day; /* 0-30 */
|
uint8_t day; /* 0-30 */
|
||||||
unsigned char month; /* 0-11 */
|
uint8_t month; /* 0-11 */
|
||||||
unsigned char extra; /* (must be zero) */
|
uint8_t extra; /* (must be zero) */
|
||||||
unsigned char weekDay; /* 1-7 (1=sunday) */
|
uint8_t weekDay; /* 1-7 (1=sunday) */
|
||||||
} NuDateTime;
|
} NuDateTime;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -399,20 +400,20 @@ typedef struct NuDateTime {
|
|||||||
*/
|
*/
|
||||||
typedef struct NuThread {
|
typedef struct NuThread {
|
||||||
/* from the archive */
|
/* from the archive */
|
||||||
unsigned short thThreadClass;
|
uint16_t thThreadClass;
|
||||||
NuThreadFormat thThreadFormat;
|
NuThreadFormat thThreadFormat;
|
||||||
unsigned short thThreadKind;
|
uint16_t thThreadKind;
|
||||||
unsigned short thThreadCRC; /* comp or uncomp data; see rec vers */
|
uint16_t thThreadCRC; /* comp or uncomp data; see rec vers */
|
||||||
unsigned long thThreadEOF;
|
uint32_t thThreadEOF;
|
||||||
unsigned long thCompThreadEOF;
|
uint32_t thCompThreadEOF;
|
||||||
|
|
||||||
/* extra goodies */
|
/* extra goodies */
|
||||||
NuThreadIdx threadIdx;
|
NuThreadIdx threadIdx;
|
||||||
unsigned long actualThreadEOF; /* disk images might be off */
|
uint32_t actualThreadEOF; /* disk images might be off */
|
||||||
long fileOffset; /* fseek offset to data in shk */
|
long fileOffset; /* fseek offset to data in shk */
|
||||||
|
|
||||||
/* internal use only */
|
/* internal use only */
|
||||||
unsigned short used; /* mark as uninteresting */
|
uint16_t used; /* mark as uninteresting */
|
||||||
} NuThread;
|
} NuThread;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -428,52 +429,52 @@ typedef struct NuThread {
|
|||||||
#define kNuOurRecordVersion 3 /* what we write */
|
#define kNuOurRecordVersion 3 /* what we write */
|
||||||
typedef struct NuRecord {
|
typedef struct NuRecord {
|
||||||
/* version 0+ */
|
/* version 0+ */
|
||||||
unsigned char recNufxID[kNufxIDLen];
|
uint8_t recNufxID[kNufxIDLen];
|
||||||
unsigned short recHeaderCRC;
|
uint16_t recHeaderCRC;
|
||||||
unsigned short recAttribCount;
|
uint16_t recAttribCount;
|
||||||
unsigned short recVersionNumber;
|
uint16_t recVersionNumber;
|
||||||
unsigned long recTotalThreads;
|
uint32_t recTotalThreads;
|
||||||
NuFileSysID recFileSysID;
|
NuFileSysID recFileSysID;
|
||||||
unsigned short recFileSysInfo;
|
uint16_t recFileSysInfo;
|
||||||
unsigned long recAccess;
|
uint32_t recAccess;
|
||||||
unsigned long recFileType;
|
uint32_t recFileType;
|
||||||
unsigned long recExtraType;
|
uint32_t recExtraType;
|
||||||
unsigned short recStorageType; /* NuStorage*,file_sys_block_size */
|
uint16_t recStorageType; /* NuStorage*,file_sys_block_size */
|
||||||
NuDateTime recCreateWhen;
|
NuDateTime recCreateWhen;
|
||||||
NuDateTime recModWhen;
|
NuDateTime recModWhen;
|
||||||
NuDateTime recArchiveWhen;
|
NuDateTime recArchiveWhen;
|
||||||
|
|
||||||
/* option lists only in version 1+ */
|
/* option lists only in version 1+ */
|
||||||
unsigned short recOptionSize;
|
uint16_t recOptionSize;
|
||||||
unsigned char* recOptionList; /* NULL if v0 or recOptionSize==0 */
|
uint8_t* recOptionList; /* NULL if v0 or recOptionSize==0 */
|
||||||
|
|
||||||
/* data specified by recAttribCount, not accounted for by option list */
|
/* data specified by recAttribCount, not accounted for by option list */
|
||||||
long extraCount;
|
long extraCount;
|
||||||
unsigned char* extraBytes;
|
uint8_t* extraBytes;
|
||||||
|
|
||||||
unsigned short recFilenameLength; /* usually zero */
|
uint16_t recFilenameLength; /* usually zero */
|
||||||
char* recFilename; /* doubles as disk volume_name */
|
char* recFilename; /* doubles as disk volume_name */
|
||||||
|
|
||||||
/* extra goodies; "dirtyHeader" does not apply to anything below */
|
/* extra goodies; "dirtyHeader" does not apply to anything below */
|
||||||
NuRecordIdx recordIdx; /* session-unique record index */
|
NuRecordIdx recordIdx; /* session-unique record index */
|
||||||
char* threadFilename; /* extracted from filename thread */
|
char* threadFilename; /* extracted from filename thread */
|
||||||
char* newFilename; /* memorized during "add file" call */
|
char* newFilename; /* memorized during "add file" call */
|
||||||
const char* filename; /* points at recFilen or threadFilen */
|
const char* filename; /* points at recFilen or threadFilen */
|
||||||
unsigned long recHeaderLength; /* size of rec hdr, incl thread hdrs */
|
uint32_t recHeaderLength; /* size of rec hdr, incl thread hdrs */
|
||||||
unsigned long totalCompLength; /* total len of data in archive file */
|
uint32_t totalCompLength; /* total len of data in archive file */
|
||||||
long fakeThreads; /* used by "MaskDataless" */
|
long fakeThreads; /* used by "MaskDataless" */
|
||||||
int isBadMac; /* malformed "bad mac" header */
|
int isBadMac; /* malformed "bad mac" header */
|
||||||
|
|
||||||
long fileOffset; /* file offset of record header */
|
long fileOffset; /* file offset of record header */
|
||||||
|
|
||||||
/* use provided interface to access this */
|
/* use provided interface to access this */
|
||||||
struct NuThread* pThreads; /* ptr to thread array */
|
struct NuThread* pThreads; /* ptr to thread array */
|
||||||
|
|
||||||
/* private -- things the application shouldn't look at */
|
/* private -- things the application shouldn't look at */
|
||||||
struct NuRecord* pNext; /* used internally */
|
struct NuRecord* pNext; /* used internally */
|
||||||
NuThreadMod* pThreadMods; /* used internally */
|
NuThreadMod* pThreadMods; /* used internally */
|
||||||
short dirtyHeader; /* set in "copy" when hdr fields uptd */
|
short dirtyHeader; /* set in "copy" when hdr fields uptd */
|
||||||
short dropRecFilename; /* if set, we're dropping this name */
|
short dropRecFilename; /* if set, we're dropping this name */
|
||||||
} NuRecord;
|
} NuRecord;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -488,18 +489,18 @@ typedef struct NuRecord {
|
|||||||
#define kNuMaxMHVersion 2 /* max we can handle */
|
#define kNuMaxMHVersion 2 /* max we can handle */
|
||||||
#define kNuOurMHVersion 2 /* what we write */
|
#define kNuOurMHVersion 2 /* what we write */
|
||||||
typedef struct NuMasterHeader {
|
typedef struct NuMasterHeader {
|
||||||
unsigned char mhNufileID[kNufileIDLen];
|
uint8_t mhNufileID[kNufileIDLen];
|
||||||
unsigned short mhMasterCRC;
|
uint16_t mhMasterCRC;
|
||||||
unsigned long mhTotalRecords;
|
uint32_t mhTotalRecords;
|
||||||
NuDateTime mhArchiveCreateWhen;
|
NuDateTime mhArchiveCreateWhen;
|
||||||
NuDateTime mhArchiveModWhen;
|
NuDateTime mhArchiveModWhen;
|
||||||
unsigned short mhMasterVersion;
|
uint16_t mhMasterVersion;
|
||||||
unsigned char mhReserved1[kNufileMasterReserved1Len];
|
uint8_t mhReserved1[kNufileMasterReserved1Len];
|
||||||
unsigned long mhMasterEOF;
|
uint32_t mhMasterEOF;
|
||||||
unsigned char mhReserved2[kNufileMasterReserved2Len];
|
uint8_t mhReserved2[kNufileMasterReserved2Len];
|
||||||
|
|
||||||
/* private -- internal use only */
|
/* private -- internal use only */
|
||||||
short isValid;
|
short isValid;
|
||||||
} NuMasterHeader;
|
} NuMasterHeader;
|
||||||
|
|
||||||
|
|
||||||
@ -514,14 +515,14 @@ typedef struct NuMasterHeader {
|
|||||||
* a small subset of the full record.
|
* a small subset of the full record.
|
||||||
*/
|
*/
|
||||||
typedef struct NuRecordAttr {
|
typedef struct NuRecordAttr {
|
||||||
NuFileSysID fileSysID;
|
NuFileSysID fileSysID;
|
||||||
/*unsigned short fileSysInfo;*/
|
/*uint16_t fileSysInfo;*/
|
||||||
unsigned long access;
|
uint32_t access;
|
||||||
unsigned long fileType;
|
uint32_t fileType;
|
||||||
unsigned long extraType;
|
uint32_t extraType;
|
||||||
NuDateTime createWhen;
|
NuDateTime createWhen;
|
||||||
NuDateTime modWhen;
|
NuDateTime modWhen;
|
||||||
NuDateTime archiveWhen;
|
NuDateTime archiveWhen;
|
||||||
} NuRecordAttr;
|
} NuRecordAttr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -529,20 +530,20 @@ typedef struct NuRecordAttr {
|
|||||||
*/
|
*/
|
||||||
typedef struct NuFileDetails {
|
typedef struct NuFileDetails {
|
||||||
/* used during AddFile call */
|
/* used during AddFile call */
|
||||||
NuThreadID threadID; /* data, rsrc, disk img? */
|
NuThreadID threadID; /* data, rsrc, disk img? */
|
||||||
const char* origName;
|
const char* origName;
|
||||||
|
|
||||||
/* these go straight into the NuRecord */
|
/* these go straight into the NuRecord */
|
||||||
const char* storageName;
|
const char* storageName;
|
||||||
NuFileSysID fileSysID;
|
NuFileSysID fileSysID;
|
||||||
unsigned short fileSysInfo;
|
uint16_t fileSysInfo;
|
||||||
unsigned long access;
|
uint32_t access;
|
||||||
unsigned long fileType;
|
uint32_t fileType;
|
||||||
unsigned long extraType;
|
uint32_t extraType;
|
||||||
unsigned short storageType; /* use Unknown, or disk block size */
|
uint16_t storageType; /* use Unknown, or disk block size */
|
||||||
NuDateTime createWhen;
|
NuDateTime createWhen;
|
||||||
NuDateTime modWhen;
|
NuDateTime modWhen;
|
||||||
NuDateTime archiveWhen;
|
NuDateTime archiveWhen;
|
||||||
} NuFileDetails;
|
} NuFileDetails;
|
||||||
|
|
||||||
|
|
||||||
@ -550,23 +551,23 @@ typedef struct NuFileDetails {
|
|||||||
* Passed into the SelectionFilter callback.
|
* Passed into the SelectionFilter callback.
|
||||||
*/
|
*/
|
||||||
typedef struct NuSelectionProposal {
|
typedef struct NuSelectionProposal {
|
||||||
const NuRecord* pRecord;
|
const NuRecord* pRecord;
|
||||||
const NuThread* pThread;
|
const NuThread* pThread;
|
||||||
} NuSelectionProposal;
|
} NuSelectionProposal;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Passed into the OutputPathnameFilter callback.
|
* Passed into the OutputPathnameFilter callback.
|
||||||
*/
|
*/
|
||||||
typedef struct NuPathnameProposal {
|
typedef struct NuPathnameProposal {
|
||||||
const char* pathname;
|
const char* pathname;
|
||||||
char filenameSeparator;
|
char filenameSeparator;
|
||||||
const NuRecord* pRecord;
|
const NuRecord* pRecord;
|
||||||
const NuThread* pThread;
|
const NuThread* pThread;
|
||||||
|
|
||||||
const char* newPathname;
|
const char* newPathname;
|
||||||
unsigned char newFilenameSeparator;
|
uint8_t newFilenameSeparator;
|
||||||
/*NuThreadID newStorage;*/
|
/*NuThreadID newStorage;*/
|
||||||
NuDataSink* newDataSink;
|
NuDataSink* newDataSink;
|
||||||
} NuPathnameProposal;
|
} NuPathnameProposal;
|
||||||
|
|
||||||
|
|
||||||
@ -606,36 +607,36 @@ typedef enum NuProgressState {
|
|||||||
*/
|
*/
|
||||||
typedef struct NuProgressData {
|
typedef struct NuProgressData {
|
||||||
/* what are we doing */
|
/* what are we doing */
|
||||||
NuOperation operation;
|
NuOperation operation;
|
||||||
/* what specifically are we doing */
|
/* what specifically are we doing */
|
||||||
NuProgressState state;
|
NuProgressState state;
|
||||||
/* how far along are we */
|
/* how far along are we */
|
||||||
short percentComplete; /* 0-100 */
|
short percentComplete; /* 0-100 */
|
||||||
|
|
||||||
/* original pathname (in archive for expand, on disk for compress) */
|
/* original pathname (in archive for expand, on disk for compress) */
|
||||||
const char* origPathname;
|
const char* origPathname;
|
||||||
/* processed pathname (PathnameFilter for expand, in-record for compress) */
|
/* processed pathname (PathnameFilter for expand, in-record for compress) */
|
||||||
const char* pathname;
|
const char* pathname;
|
||||||
/* basename of "pathname" */
|
/* basename of "pathname" */
|
||||||
const char* filename;
|
const char* filename;
|
||||||
/* pointer to the record we're expanding from */
|
/* pointer to the record we're expanding from */
|
||||||
const NuRecord* pRecord;
|
const NuRecord* pRecord;
|
||||||
|
|
||||||
unsigned long uncompressedLength; /* size of uncompressed data */
|
uint32_t uncompressedLength; /* size of uncompressed data */
|
||||||
unsigned long uncompressedProgress; /* #of bytes in/out */
|
uint32_t uncompressedProgress; /* #of bytes in/out */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
NuThreadFormat threadFormat; /* compression being applied */
|
NuThreadFormat threadFormat; /* compression being applied */
|
||||||
} compress;
|
} compress;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
unsigned long totalCompressedLength; /* all "data" threads */
|
uint32_t totalCompressedLength; /* all "data" threads */
|
||||||
unsigned long totalUncompressedLength;
|
uint32_t totalUncompressedLength;
|
||||||
|
|
||||||
/*unsigned long compressedLength; * size of compressed data */
|
/*uint32_t compressedLength; * size of compressed data */
|
||||||
/*unsigned long compressedProgress; * #of compressed bytes in/out*/
|
/*uint32_t compressedProgress; * #of compressed bytes in/out*/
|
||||||
const NuThread* pThread; /* thread we're working on */
|
const NuThread* pThread; /* thread we're working on */
|
||||||
NuValue convertEOL; /* set if LF/CR conv is on */
|
NuValue convertEOL; /* set if LF/CR conv is on */
|
||||||
} expand;
|
} expand;
|
||||||
|
|
||||||
/* pay no attention */
|
/* pay no attention */
|
||||||
@ -737,11 +738,11 @@ NUFXLIB_API NuError NuGetRecord(NuArchive* pArchive, NuRecordIdx recordIdx,
|
|||||||
NUFXLIB_API NuError NuGetRecordIdxByName(NuArchive* pArchive, const char* name,
|
NUFXLIB_API NuError NuGetRecordIdxByName(NuArchive* pArchive, const char* name,
|
||||||
NuRecordIdx* pRecordIdx);
|
NuRecordIdx* pRecordIdx);
|
||||||
NUFXLIB_API NuError NuGetRecordIdxByPosition(NuArchive* pArchive,
|
NUFXLIB_API NuError NuGetRecordIdxByPosition(NuArchive* pArchive,
|
||||||
unsigned long position, NuRecordIdx* pRecordIdx);
|
uint32_t position, NuRecordIdx* pRecordIdx);
|
||||||
|
|
||||||
/* read/write interfaces */
|
/* read/write interfaces */
|
||||||
NUFXLIB_API NuError NuOpenRW(const char* archivePathname,
|
NUFXLIB_API NuError NuOpenRW(const char* archivePathname,
|
||||||
const char* tempPathname, unsigned long flags,
|
const char* tempPathname, uint32_t flags,
|
||||||
NuArchive** ppArchive);
|
NuArchive** ppArchive);
|
||||||
NUFXLIB_API NuError NuFlush(NuArchive* pArchive, long* pStatusFlags);
|
NUFXLIB_API NuError NuFlush(NuArchive* pArchive, long* pStatusFlags);
|
||||||
NUFXLIB_API NuError NuAddRecord(NuArchive* pArchive,
|
NUFXLIB_API NuError NuAddRecord(NuArchive* pArchive,
|
||||||
@ -779,27 +780,27 @@ NUFXLIB_API NuError NuDebugDumpArchive(NuArchive* pArchive);
|
|||||||
|
|
||||||
/* sources and sinks */
|
/* sources and sinks */
|
||||||
NUFXLIB_API NuError NuCreateDataSourceForFile(NuThreadFormat threadFormat,
|
NUFXLIB_API NuError NuCreateDataSourceForFile(NuThreadFormat threadFormat,
|
||||||
unsigned long otherLen, const char* pathname,
|
uint32_t otherLen, const char* pathname,
|
||||||
short isFromRsrcFork, NuDataSource** ppDataSource);
|
short isFromRsrcFork, NuDataSource** ppDataSource);
|
||||||
NUFXLIB_API NuError NuCreateDataSourceForFP(NuThreadFormat threadFormat,
|
NUFXLIB_API NuError NuCreateDataSourceForFP(NuThreadFormat threadFormat,
|
||||||
unsigned long otherLen, FILE* fp, long offset, long length,
|
uint32_t otherLen, FILE* fp, long offset, long length,
|
||||||
NuCallback closeFunc, NuDataSource** ppDataSource);
|
NuCallback closeFunc, NuDataSource** ppDataSource);
|
||||||
NUFXLIB_API NuError NuCreateDataSourceForBuffer(NuThreadFormat threadFormat,
|
NUFXLIB_API NuError NuCreateDataSourceForBuffer(NuThreadFormat threadFormat,
|
||||||
unsigned long otherLen, const unsigned char* buffer, long offset,
|
uint32_t otherLen, const uint8_t* buffer, long offset,
|
||||||
long length, NuCallback freeFunc, NuDataSource** ppDataSource);
|
long length, NuCallback freeFunc, NuDataSource** ppDataSource);
|
||||||
NUFXLIB_API NuError NuFreeDataSource(NuDataSource* pDataSource);
|
NUFXLIB_API NuError NuFreeDataSource(NuDataSource* pDataSource);
|
||||||
NUFXLIB_API NuError NuDataSourceSetRawCrc(NuDataSource* pDataSource,
|
NUFXLIB_API NuError NuDataSourceSetRawCrc(NuDataSource* pDataSource,
|
||||||
unsigned short crc);
|
uint16_t crc);
|
||||||
NUFXLIB_API NuError NuCreateDataSinkForFile(short doExpand, NuValue convertEOL,
|
NUFXLIB_API NuError NuCreateDataSinkForFile(short doExpand, NuValue convertEOL,
|
||||||
const char* pathname, char fssep, NuDataSink** ppDataSink);
|
const char* pathname, char fssep, NuDataSink** ppDataSink);
|
||||||
NUFXLIB_API NuError NuCreateDataSinkForFP(short doExpand, NuValue convertEOL,
|
NUFXLIB_API NuError NuCreateDataSinkForFP(short doExpand, NuValue convertEOL,
|
||||||
FILE* fp, NuDataSink** ppDataSink);
|
FILE* fp, NuDataSink** ppDataSink);
|
||||||
NUFXLIB_API NuError NuCreateDataSinkForBuffer(short doExpand,
|
NUFXLIB_API NuError NuCreateDataSinkForBuffer(short doExpand,
|
||||||
NuValue convertEOL, unsigned char* buffer, unsigned long bufLen,
|
NuValue convertEOL, uint8_t* buffer, uint32_t bufLen,
|
||||||
NuDataSink** ppDataSink);
|
NuDataSink** ppDataSink);
|
||||||
NUFXLIB_API NuError NuFreeDataSink(NuDataSink* pDataSink);
|
NUFXLIB_API NuError NuFreeDataSink(NuDataSink* pDataSink);
|
||||||
NUFXLIB_API NuError NuDataSinkGetOutCount(NuDataSink* pDataSink,
|
NUFXLIB_API NuError NuDataSinkGetOutCount(NuDataSink* pDataSink,
|
||||||
unsigned long* pOutCount);
|
uint32_t* pOutCount);
|
||||||
|
|
||||||
/* miscellaneous non-archive operations */
|
/* miscellaneous non-archive operations */
|
||||||
NUFXLIB_API NuError NuGetVersion(long* pMajorVersion, long* pMinorVersion,
|
NUFXLIB_API NuError NuGetVersion(long* pMajorVersion, long* pMinorVersion,
|
||||||
@ -811,12 +812,12 @@ NUFXLIB_API void NuRecordCopyAttr(NuRecordAttr* pRecordAttr,
|
|||||||
const NuRecord* pRecord);
|
const NuRecord* pRecord);
|
||||||
NUFXLIB_API NuError NuRecordCopyThreads(const NuRecord* pRecord,
|
NUFXLIB_API NuError NuRecordCopyThreads(const NuRecord* pRecord,
|
||||||
NuThread** ppThreads);
|
NuThread** ppThreads);
|
||||||
NUFXLIB_API unsigned long NuRecordGetNumThreads(const NuRecord* pRecord);
|
NUFXLIB_API uint32_t NuRecordGetNumThreads(const NuRecord* pRecord);
|
||||||
NUFXLIB_API const NuThread* NuThreadGetByIdx(const NuThread* pThread, long idx);
|
NUFXLIB_API const NuThread* NuThreadGetByIdx(const NuThread* pThread, long idx);
|
||||||
NUFXLIB_API short NuIsPresizedThreadID(NuThreadID threadID);
|
NUFXLIB_API short NuIsPresizedThreadID(NuThreadID threadID);
|
||||||
|
|
||||||
#define NuGetThread(pRecord, idx) ( (const NuThread*) \
|
#define NuGetThread(pRecord, idx) ( (const NuThread*) \
|
||||||
((unsigned long) (idx) < (unsigned long) (pRecord)->recTotalThreads ? \
|
((uint32_t) (idx) < (uint32_t) (pRecord)->recTotalThreads ? \
|
||||||
&(pRecord)->pThreads[(idx)] : NULL) \
|
&(pRecord)->pThreads[(idx)] : NULL) \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ typedef enum NuOpenMode {
|
|||||||
*/
|
*/
|
||||||
typedef struct NuRecordSet {
|
typedef struct NuRecordSet {
|
||||||
Boolean loaded;
|
Boolean loaded;
|
||||||
ulong numRecords;
|
uint32_t numRecords;
|
||||||
NuRecord* nuRecordHead;
|
NuRecord* nuRecordHead;
|
||||||
NuRecord* nuRecordTail;
|
NuRecord* nuRecordTail;
|
||||||
} NuRecordSet;
|
} NuRecordSet;
|
||||||
@ -95,7 +95,7 @@ typedef struct NuRecordSet {
|
|||||||
* Archive state.
|
* Archive state.
|
||||||
*/
|
*/
|
||||||
struct NuArchive {
|
struct NuArchive {
|
||||||
ulong structMagic;
|
uint32_t structMagic;
|
||||||
Boolean busy;
|
Boolean busy;
|
||||||
|
|
||||||
NuOpenMode openMode;
|
NuOpenMode openMode;
|
||||||
@ -135,7 +135,7 @@ struct NuArchive {
|
|||||||
NuRecordSet newRecordSet; /* newly-added records */
|
NuRecordSet newRecordSet; /* newly-added records */
|
||||||
|
|
||||||
/* state for compression functions */
|
/* state for compression functions */
|
||||||
uchar* compBuf; /* large general-purpose buffer */
|
uint8_t* compBuf; /* large general-purpose buffer */
|
||||||
void* lzwCompressState; /* state for LZW/1 and LZW/2 */
|
void* lzwCompressState; /* state for LZW/1 and LZW/2 */
|
||||||
void* lzwExpandState; /* state for LZW/1 and LZW/2 */
|
void* lzwExpandState; /* state for LZW/1 and LZW/2 */
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ struct NuThreadMod {
|
|||||||
*/
|
*/
|
||||||
typedef struct NuFunnel {
|
typedef struct NuFunnel {
|
||||||
/* data storage */
|
/* data storage */
|
||||||
uchar* buffer; /* kNuFunnelBufSize worth of storage */
|
uint8_t* buffer; /* kNuFunnelBufSize worth of storage */
|
||||||
long bufCount; /* #of bytes in buffer */
|
long bufCount; /* #of bytes in buffer */
|
||||||
|
|
||||||
/* text conversion; if "auto", on first flush we convert to "on" or "off" */
|
/* text conversion; if "auto", on first flush we convert to "on" or "off" */
|
||||||
@ -270,10 +270,10 @@ typedef struct NuFunnel {
|
|||||||
Boolean isFirstWrite; /* cleared on first write */
|
Boolean isFirstWrite; /* cleared on first write */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
ulong inCount; /* total #of bytes in the top */
|
uint32_t inCount; /* total #of bytes in the top */
|
||||||
ulong outCount; /* total #of bytes out the bottom */
|
uint32_t outCount; /* total #of bytes out the bottom */
|
||||||
|
|
||||||
ulong outMax; /* flag an err when outCount exceeds this */
|
uint32_t outMax; /* flag an err when outCount exceeds this */
|
||||||
Boolean outMaxExceeded; /* in fact, it's this flag */
|
Boolean outMaxExceeded; /* in fact, it's this flag */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -302,11 +302,11 @@ typedef struct NuStraw {
|
|||||||
NuDataSource* pDataSource;
|
NuDataSource* pDataSource;
|
||||||
|
|
||||||
/* progress update fields */
|
/* progress update fields */
|
||||||
ulong lastProgress;
|
uint32_t lastProgress;
|
||||||
ulong lastDisplayed;
|
uint32_t lastDisplayed;
|
||||||
} NuStraw;
|
} NuStraw;
|
||||||
|
|
||||||
/*NuError Nu_CopyStreamToStream(FILE* outfp, FILE* infp, ulong count);*/
|
/*NuError Nu_CopyStreamToStream(FILE* outfp, FILE* infp, uint32_t count);*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -329,10 +329,10 @@ typedef enum NuDataSourceType {
|
|||||||
typedef struct NuDataSourceCommon {
|
typedef struct NuDataSourceCommon {
|
||||||
NuDataSourceType sourceType;
|
NuDataSourceType sourceType;
|
||||||
NuThreadFormat threadFormat; /* is it already compressed? */
|
NuThreadFormat threadFormat; /* is it already compressed? */
|
||||||
ushort rawCrc; /* crc for already-compressed data*/
|
uint16_t rawCrc; /* crc for already-compressed data*/
|
||||||
/*Boolean doClose; \* close on completion? */
|
/*Boolean doClose; \* close on completion? */
|
||||||
ulong dataLen; /* length of data (var for buf) */
|
uint32_t dataLen; /* length of data (var for buf) */
|
||||||
ulong otherLen; /* uncomp len or preset buf size */
|
uint32_t otherLen; /* uncomp len or preset buf size */
|
||||||
int refCount; /* so we can copy structs */
|
int refCount; /* so we can copy structs */
|
||||||
} NuDataSourceCommon;
|
} NuDataSourceCommon;
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ union NuDataSource {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
NuDataSourceCommon common;
|
NuDataSourceCommon common;
|
||||||
const uchar* buffer; /* non-const if doClose=true */
|
const uint8_t* buffer; /* non-const if doClose=true */
|
||||||
long offset; /* starting offset */
|
long offset; /* starting offset */
|
||||||
|
|
||||||
long curOffset; /* current offset */
|
long curOffset; /* current offset */
|
||||||
@ -387,7 +387,7 @@ typedef struct NuDataSinkCommon {
|
|||||||
NuDataSinkType sinkType;
|
NuDataSinkType sinkType;
|
||||||
Boolean doExpand; /* expand file? */
|
Boolean doExpand; /* expand file? */
|
||||||
NuValue convertEOL; /* convert EOL? (req "expand") */
|
NuValue convertEOL; /* convert EOL? (req "expand") */
|
||||||
ulong outCount;
|
uint32_t outCount;
|
||||||
} NuDataSinkCommon;
|
} NuDataSinkCommon;
|
||||||
|
|
||||||
union NuDataSink {
|
union NuDataSink {
|
||||||
@ -411,8 +411,8 @@ union NuDataSink {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
NuDataSinkCommon common;
|
NuDataSinkCommon common;
|
||||||
uchar* buffer;
|
uint8_t* buffer;
|
||||||
ulong bufLen; /* max amount of data "buffer" holds */
|
uint32_t bufLen; /* max amount of data "buffer" holds */
|
||||||
NuError stickyErr;
|
NuError stickyErr;
|
||||||
} toBuffer;
|
} toBuffer;
|
||||||
};
|
};
|
||||||
@ -500,7 +500,7 @@ NuError Nu_AllocCompressionBufferIFN(NuArchive* pArchive);
|
|||||||
NuError Nu_StreamOpenRO(FILE* infp, NuArchive** ppArchive);
|
NuError Nu_StreamOpenRO(FILE* infp, NuArchive** ppArchive);
|
||||||
NuError Nu_OpenRO(const char* filename, NuArchive** ppArchive);
|
NuError Nu_OpenRO(const char* filename, NuArchive** ppArchive);
|
||||||
NuError Nu_OpenRW(const char* archivePathname, const char* tempPathname,
|
NuError Nu_OpenRW(const char* archivePathname, const char* tempPathname,
|
||||||
ulong flags, NuArchive** ppArchive);
|
uint32_t flags, NuArchive** ppArchive);
|
||||||
NuError Nu_WriteMasterHeader(NuArchive* pArchive, FILE* fp,
|
NuError Nu_WriteMasterHeader(NuArchive* pArchive, FILE* fp,
|
||||||
NuMasterHeader* pMasterHeader);
|
NuMasterHeader* pMasterHeader);
|
||||||
NuError Nu_Close(NuArchive* pArchive);
|
NuError Nu_Close(NuArchive* pArchive);
|
||||||
@ -509,28 +509,28 @@ NuError Nu_RenameTempToArchive(NuArchive* pArchive);
|
|||||||
NuError Nu_DeleteArchiveFile(NuArchive* pArchive);
|
NuError Nu_DeleteArchiveFile(NuArchive* pArchive);
|
||||||
|
|
||||||
/* ArchiveIO.c */
|
/* ArchiveIO.c */
|
||||||
uchar Nu_ReadOneC(NuArchive* pArchive, FILE* fp, ushort* pCrc);
|
uint8_t Nu_ReadOneC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc);
|
||||||
uchar Nu_ReadOne(NuArchive* pArchive, FILE* fp);
|
uint8_t Nu_ReadOne(NuArchive* pArchive, FILE* fp);
|
||||||
void Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uchar val, ushort* pCrc);
|
void Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uint8_t val, uint16_t* pCrc);
|
||||||
void Nu_WriteOne(NuArchive* pArchive, FILE* fp, uchar val);
|
void Nu_WriteOne(NuArchive* pArchive, FILE* fp, uint8_t val);
|
||||||
ushort Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, ushort* pCrc);
|
uint16_t Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc);
|
||||||
ushort Nu_ReadTwo(NuArchive* pArchive, FILE* fp);
|
uint16_t Nu_ReadTwo(NuArchive* pArchive, FILE* fp);
|
||||||
void Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, ushort val, ushort* pCrc);
|
void Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, uint16_t val, uint16_t* pCrc);
|
||||||
void Nu_WriteTwo(NuArchive* pArchive, FILE* fp, ushort val);
|
void Nu_WriteTwo(NuArchive* pArchive, FILE* fp, uint16_t val);
|
||||||
ulong Nu_ReadFourC(NuArchive* pArchive, FILE* fp, ushort* pCrc);
|
uint32_t Nu_ReadFourC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc);
|
||||||
ulong Nu_ReadFour(NuArchive* pArchive, FILE* fp);
|
uint32_t Nu_ReadFour(NuArchive* pArchive, FILE* fp);
|
||||||
void Nu_WriteFourC(NuArchive* pArchive, FILE* fp, ulong val, ushort* pCrc);
|
void Nu_WriteFourC(NuArchive* pArchive, FILE* fp, uint32_t val, uint16_t* pCrc);
|
||||||
void Nu_WriteFour(NuArchive* pArchive, FILE* fp, ulong val);
|
void Nu_WriteFour(NuArchive* pArchive, FILE* fp, uint32_t val);
|
||||||
NuDateTime Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, ushort* pCrc);
|
NuDateTime Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc);
|
||||||
NuDateTime Nu_ReadDateTime(NuArchive* pArchive, FILE* fp, ushort* pCrc);
|
NuDateTime Nu_ReadDateTime(NuArchive* pArchive, FILE* fp, uint16_t* pCrc);
|
||||||
void Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime,
|
void Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime,
|
||||||
ushort* pCrc);
|
uint16_t* pCrc);
|
||||||
void Nu_WriteDateTime(NuArchive* pArchive, FILE* fp, NuDateTime dateTime);
|
void Nu_WriteDateTime(NuArchive* pArchive, FILE* fp, NuDateTime dateTime);
|
||||||
void Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
|
void Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
|
||||||
ushort* pCrc);
|
uint16_t* pCrc);
|
||||||
void Nu_ReadBytes(NuArchive* pArchive, FILE* fp, void* vbuffer, long count);
|
void Nu_ReadBytes(NuArchive* pArchive, FILE* fp, void* vbuffer, long count);
|
||||||
void Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer,
|
void Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer,
|
||||||
long count, ushort* pCrc);
|
long count, uint16_t* pCrc);
|
||||||
void Nu_WriteBytes(NuArchive* pArchive, FILE* fp, const void* vbuffer,
|
void Nu_WriteBytes(NuArchive* pArchive, FILE* fp, const void* vbuffer,
|
||||||
long count);
|
long count);
|
||||||
NuError Nu_HeaderIOFailed(NuArchive* pArchive, FILE* fp);
|
NuError Nu_HeaderIOFailed(NuArchive* pArchive, FILE* fp);
|
||||||
@ -540,9 +540,9 @@ NuError Nu_RewindArchive(NuArchive* pArchive);
|
|||||||
|
|
||||||
/* Bzip2.c */
|
/* Bzip2.c */
|
||||||
NuError Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
NuError Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc);
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc);
|
||||||
NuError Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
|
NuError Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc);
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc);
|
||||||
|
|
||||||
/* Compress.c */
|
/* Compress.c */
|
||||||
NuError Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
|
NuError Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
|
||||||
@ -554,18 +554,18 @@ NuError Nu_CopyPresizedToArchive(NuArchive* pArchive,
|
|||||||
NuThread* pThread, char** ppSavedCopy);
|
NuThread* pThread, char** ppSavedCopy);
|
||||||
|
|
||||||
/* Crc16.c */
|
/* Crc16.c */
|
||||||
extern const ushort gNuCrc16Table[256];
|
extern const uint16_t gNuCrc16Table[256];
|
||||||
ushort Nu_CalcCRC16(ushort seed, const uchar* ptr, int count);
|
uint16_t Nu_CalcCRC16(uint16_t seed, const uint8_t* ptr, int count);
|
||||||
#ifdef __Crc16_c__ /* just doing "static inline" warns def-but-not-used */
|
#ifdef __Crc16_c__ /* just doing "static inline" warns def-but-not-used */
|
||||||
#define CRC_INLINE /**/
|
#define CRC_INLINE /**/
|
||||||
#else
|
#else
|
||||||
#define CRC_INLINE extern inline
|
#define CRC_INLINE extern inline
|
||||||
#endif
|
#endif
|
||||||
#if defined(inline) && !defined(__Crc16_c__) /* somebody ovrd inline def? */
|
#if defined(inline) && !defined(__Crc16_c__) /* somebody ovrd inline def? */
|
||||||
ushort Nu_UpdateCRC16(uchar val, ushort crc);
|
uint16_t Nu_UpdateCRC16(uint8_t val, uint16_t crc);
|
||||||
#else
|
#else
|
||||||
CRC_INLINE ushort
|
CRC_INLINE uint16_t
|
||||||
Nu_UpdateCRC16(uchar val, ushort crc)
|
Nu_UpdateCRC16(uint8_t val, uint16_t crc)
|
||||||
{
|
{
|
||||||
return (gNuCrc16Table[((crc >> 8) & 0xFF) ^ val] ^ (crc << 8)) & 0xFFFF;
|
return (gNuCrc16Table[((crc >> 8) & 0xFF) ^ val] ^ (crc << 8)) & 0xFFFF;
|
||||||
}
|
}
|
||||||
@ -595,9 +595,9 @@ NuError Nu_Flush(NuArchive* pArchive, long* pStatusFlags);
|
|||||||
|
|
||||||
/* Deflate.c */
|
/* Deflate.c */
|
||||||
NuError Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
NuError Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc);
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc);
|
||||||
NuError Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord,
|
NuError Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc);
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc);
|
||||||
|
|
||||||
/* Expand.c */
|
/* Expand.c */
|
||||||
NuError Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord,
|
NuError Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
@ -637,12 +637,12 @@ NuError Nu_FunnelNew(NuArchive* pArchive, NuDataSink* pDataSink,
|
|||||||
NuValue convertEOL, NuValue convertEOLTo, NuProgressData* pProgress,
|
NuValue convertEOL, NuValue convertEOLTo, NuProgressData* pProgress,
|
||||||
NuFunnel** ppFunnel);
|
NuFunnel** ppFunnel);
|
||||||
NuError Nu_FunnelFree(NuArchive* pArchive, NuFunnel* pFunnel);
|
NuError Nu_FunnelFree(NuArchive* pArchive, NuFunnel* pFunnel);
|
||||||
/*void Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, ulong maxBytes);*/
|
/*void Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, uint32_t maxBytes);*/
|
||||||
NuError Nu_FunnelWrite(NuArchive* pArchive, NuFunnel* pFunnel,
|
NuError Nu_FunnelWrite(NuArchive* pArchive, NuFunnel* pFunnel,
|
||||||
const uchar* buffer, ulong count);
|
const uint8_t* buffer, uint32_t count);
|
||||||
NuError Nu_FunnelFlush(NuArchive* pArchive, NuFunnel* pFunnel);
|
NuError Nu_FunnelFlush(NuArchive* pArchive, NuFunnel* pFunnel);
|
||||||
NuError Nu_ProgressDataCompressPrep(NuArchive* pArchive, NuStraw* pStraw,
|
NuError Nu_ProgressDataCompressPrep(NuArchive* pArchive, NuStraw* pStraw,
|
||||||
NuThreadFormat threadFormat, ulong sourceLen);
|
NuThreadFormat threadFormat, uint32_t sourceLen);
|
||||||
NuError Nu_ProgressDataExpandPrep(NuArchive* pArchive, NuFunnel* pFunnel,
|
NuError Nu_ProgressDataExpandPrep(NuArchive* pArchive, NuFunnel* pFunnel,
|
||||||
const NuThread* pThread);
|
const NuThread* pThread);
|
||||||
NuError Nu_FunnelSetProgressState(NuFunnel* pFunnel, NuProgressState state);
|
NuError Nu_FunnelSetProgressState(NuFunnel* pFunnel, NuProgressState state);
|
||||||
@ -654,25 +654,26 @@ NuError Nu_StrawNew(NuArchive* pArchive, NuDataSource* pDataSource,
|
|||||||
NuError Nu_StrawFree(NuArchive* pArchive, NuStraw* pStraw);
|
NuError Nu_StrawFree(NuArchive* pArchive, NuStraw* pStraw);
|
||||||
NuError Nu_StrawSetProgressState(NuStraw* pStraw, NuProgressState state);
|
NuError Nu_StrawSetProgressState(NuStraw* pStraw, NuProgressState state);
|
||||||
NuError Nu_StrawSendProgressUpdate(NuArchive* pArchive, NuStraw* pStraw);
|
NuError Nu_StrawSendProgressUpdate(NuArchive* pArchive, NuStraw* pStraw);
|
||||||
NuError Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uchar* buffer,
|
NuError Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uint8_t* buffer,
|
||||||
long len);
|
long len);
|
||||||
NuError Nu_StrawRewind(NuArchive* pArchive, NuStraw* pStraw);
|
NuError Nu_StrawRewind(NuArchive* pArchive, NuStraw* pStraw);
|
||||||
|
|
||||||
/* Lzc.c */
|
/* Lzc.c */
|
||||||
NuError Nu_CompressLZC12(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
NuError Nu_CompressLZC12(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc);
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc);
|
||||||
NuError Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
NuError Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc);
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc);
|
||||||
NuError Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord,
|
NuError Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc);
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc);
|
||||||
|
|
||||||
/* Lzw.c */
|
/* Lzw.c */
|
||||||
NuError Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
NuError Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc);
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc);
|
||||||
NuError Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
NuError Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc);
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc);
|
||||||
NuError Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
NuError Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pThreadCrc);
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel,
|
||||||
|
uint16_t* pThreadCrc);
|
||||||
|
|
||||||
/* MiscUtils.c */
|
/* MiscUtils.c */
|
||||||
/*extern const char* kNufxLibName;*/
|
/*extern const char* kNufxLibName;*/
|
||||||
@ -701,8 +702,8 @@ NuResult Nu_InternalFreeCallback(NuArchive* pArchive, void* args);
|
|||||||
void Nu_RecordAddThreadMod(NuRecord* pRecord, NuThreadMod* pThreadMod);
|
void Nu_RecordAddThreadMod(NuRecord* pRecord, NuThreadMod* pThreadMod);
|
||||||
Boolean Nu_RecordIsEmpty(NuArchive* pArchive, const NuRecord* pRecord);
|
Boolean Nu_RecordIsEmpty(NuArchive* pArchive, const NuRecord* pRecord);
|
||||||
Boolean Nu_RecordSet_GetLoaded(const NuRecordSet* pRecordSet);
|
Boolean Nu_RecordSet_GetLoaded(const NuRecordSet* pRecordSet);
|
||||||
ulong Nu_RecordSet_GetNumRecords(const NuRecordSet* pRecordSet);
|
uint32_t Nu_RecordSet_GetNumRecords(const NuRecordSet* pRecordSet);
|
||||||
void Nu_RecordSet_SetNumRecords(NuRecordSet* pRecordSet, ulong val);
|
void Nu_RecordSet_SetNumRecords(NuRecordSet* pRecordSet, uint32_t val);
|
||||||
void Nu_RecordSet_IncNumRecords(NuRecordSet* pRecordSet);
|
void Nu_RecordSet_IncNumRecords(NuRecordSet* pRecordSet);
|
||||||
NuRecord* Nu_RecordSet_GetListHead(const NuRecordSet* pRecordSet);
|
NuRecord* Nu_RecordSet_GetListHead(const NuRecordSet* pRecordSet);
|
||||||
NuRecord** Nu_RecordSet_GetListHeadPtr(NuRecordSet* pRecordSet);
|
NuRecord** Nu_RecordSet_GetListHeadPtr(NuRecordSet* pRecordSet);
|
||||||
@ -740,7 +741,7 @@ NuError Nu_GetRecord(NuArchive* pArchive, NuRecordIdx recordIdx,
|
|||||||
const NuRecord** ppRecord);
|
const NuRecord** ppRecord);
|
||||||
NuError Nu_GetRecordIdxByName(NuArchive* pArchive, const char* name,
|
NuError Nu_GetRecordIdxByName(NuArchive* pArchive, const char* name,
|
||||||
NuRecordIdx* pRecordIdx);
|
NuRecordIdx* pRecordIdx);
|
||||||
NuError Nu_GetRecordIdxByPosition(NuArchive* pArchive, ulong position,
|
NuError Nu_GetRecordIdxByPosition(NuArchive* pArchive, uint32_t position,
|
||||||
NuRecordIdx* pRecordIdx);
|
NuRecordIdx* pRecordIdx);
|
||||||
NuError Nu_FindRecordForWriteByIdx(NuArchive* pArchive, NuRecordIdx recIdx,
|
NuError Nu_FindRecordForWriteByIdx(NuArchive* pArchive, NuRecordIdx recIdx,
|
||||||
NuRecord** ppFoundRecord);
|
NuRecord** ppFoundRecord);
|
||||||
@ -758,56 +759,58 @@ NuError Nu_DeleteRecord(NuArchive* pArchive, NuRecordIdx rec);
|
|||||||
|
|
||||||
/* SourceSink.c */
|
/* SourceSink.c */
|
||||||
NuError Nu_DataSourceFile_New(NuThreadFormat threadFormat,
|
NuError Nu_DataSourceFile_New(NuThreadFormat threadFormat,
|
||||||
ulong otherLen, const char* pathname, Boolean isFromRsrcFork,
|
uint32_t otherLen, const char* pathname, Boolean isFromRsrcFork,
|
||||||
NuDataSource** ppDataSource);
|
NuDataSource** ppDataSource);
|
||||||
NuError Nu_DataSourceFP_New(NuThreadFormat threadFormat,
|
NuError Nu_DataSourceFP_New(NuThreadFormat threadFormat,
|
||||||
ulong otherLen, FILE* fp, long offset, long length,
|
uint32_t otherLen, FILE* fp, long offset, long length,
|
||||||
NuCallback fcloseFunc, NuDataSource** ppDataSource);
|
NuCallback fcloseFunc, NuDataSource** ppDataSource);
|
||||||
NuError Nu_DataSourceBuffer_New(NuThreadFormat threadFormat,
|
NuError Nu_DataSourceBuffer_New(NuThreadFormat threadFormat,
|
||||||
ulong otherLen, const uchar* buffer, long offset, long length,
|
uint32_t otherLen, const uint8_t* buffer, long offset, long length,
|
||||||
NuCallback freeFunc, NuDataSource** ppDataSource);
|
NuCallback freeFunc, NuDataSource** ppDataSource);
|
||||||
NuDataSource* Nu_DataSourceCopy(NuDataSource* pDataSource);
|
NuDataSource* Nu_DataSourceCopy(NuDataSource* pDataSource);
|
||||||
NuError Nu_DataSourceFree(NuDataSource* pDataSource);
|
NuError Nu_DataSourceFree(NuDataSource* pDataSource);
|
||||||
NuDataSourceType Nu_DataSourceGetType(const NuDataSource* pDataSource);
|
NuDataSourceType Nu_DataSourceGetType(const NuDataSource* pDataSource);
|
||||||
NuThreadFormat Nu_DataSourceGetThreadFormat(const NuDataSource* pDataSource);
|
NuThreadFormat Nu_DataSourceGetThreadFormat(const NuDataSource* pDataSource);
|
||||||
ulong Nu_DataSourceGetDataLen(const NuDataSource* pDataSource);
|
uint32_t Nu_DataSourceGetDataLen(const NuDataSource* pDataSource);
|
||||||
ulong Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource);
|
uint32_t Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource);
|
||||||
void Nu_DataSourceSetOtherLen(NuDataSource* pDataSource, long otherLen);
|
void Nu_DataSourceSetOtherLen(NuDataSource* pDataSource, long otherLen);
|
||||||
ushort Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource);
|
uint16_t Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource);
|
||||||
void Nu_DataSourceSetRawCrc(NuDataSource* pDataSource, ushort crc);
|
void Nu_DataSourceSetRawCrc(NuDataSource* pDataSource, uint16_t crc);
|
||||||
NuError Nu_DataSourcePrepareInput(NuArchive* pArchive,
|
NuError Nu_DataSourcePrepareInput(NuArchive* pArchive,
|
||||||
NuDataSource* pDataSource);
|
NuDataSource* pDataSource);
|
||||||
void Nu_DataSourceUnPrepareInput(NuArchive* pArchive,
|
void Nu_DataSourceUnPrepareInput(NuArchive* pArchive,
|
||||||
NuDataSource* pDataSource);
|
NuDataSource* pDataSource);
|
||||||
const char* Nu_DataSourceFile_GetPathname(NuDataSource* pDataSource);
|
const char* Nu_DataSourceFile_GetPathname(NuDataSource* pDataSource);
|
||||||
NuError Nu_DataSourceGetBlock(NuDataSource* pDataSource, uchar* buf, ulong len);
|
NuError Nu_DataSourceGetBlock(NuDataSource* pDataSource, uint8_t* buf,
|
||||||
|
uint32_t len);
|
||||||
NuError Nu_DataSourceRewind(NuDataSource* pDataSource);
|
NuError Nu_DataSourceRewind(NuDataSource* pDataSource);
|
||||||
NuError Nu_DataSinkFile_New(Boolean doExpand, NuValue convertEOL,
|
NuError Nu_DataSinkFile_New(Boolean doExpand, NuValue convertEOL,
|
||||||
const char* pathname, char fssep, NuDataSink** ppDataSink);
|
const char* pathname, char fssep, NuDataSink** ppDataSink);
|
||||||
NuError Nu_DataSinkFP_New(Boolean doExpand, NuValue convertEOL, FILE* fp,
|
NuError Nu_DataSinkFP_New(Boolean doExpand, NuValue convertEOL, FILE* fp,
|
||||||
NuDataSink** ppDataSink);
|
NuDataSink** ppDataSink);
|
||||||
NuError Nu_DataSinkBuffer_New(Boolean doExpand, NuValue convertEOL,
|
NuError Nu_DataSinkBuffer_New(Boolean doExpand, NuValue convertEOL,
|
||||||
uchar* buffer, ulong bufLen, NuDataSink** ppDataSink);
|
uint8_t* buffer, uint32_t bufLen, NuDataSink** ppDataSink);
|
||||||
NuError Nu_DataSinkVoid_New(Boolean doExpand, NuValue convertEOL,
|
NuError Nu_DataSinkVoid_New(Boolean doExpand, NuValue convertEOL,
|
||||||
NuDataSink** ppDataSink);
|
NuDataSink** ppDataSink);
|
||||||
NuError Nu_DataSinkFree(NuDataSink* pDataSink);
|
NuError Nu_DataSinkFree(NuDataSink* pDataSink);
|
||||||
NuDataSinkType Nu_DataSinkGetType(const NuDataSink* pDataSink);
|
NuDataSinkType Nu_DataSinkGetType(const NuDataSink* pDataSink);
|
||||||
Boolean Nu_DataSinkGetDoExpand(const NuDataSink* pDataSink);
|
Boolean Nu_DataSinkGetDoExpand(const NuDataSink* pDataSink);
|
||||||
NuValue Nu_DataSinkGetConvertEOL(const NuDataSink* pDataSink);
|
NuValue Nu_DataSinkGetConvertEOL(const NuDataSink* pDataSink);
|
||||||
ulong Nu_DataSinkGetOutCount(const NuDataSink* pDataSink);
|
uint32_t Nu_DataSinkGetOutCount(const NuDataSink* pDataSink);
|
||||||
const char* Nu_DataSinkFile_GetPathname(const NuDataSink* pDataSink);
|
const char* Nu_DataSinkFile_GetPathname(const NuDataSink* pDataSink);
|
||||||
char Nu_DataSinkFile_GetFssep(const NuDataSink* pDataSink);
|
char Nu_DataSinkFile_GetFssep(const NuDataSink* pDataSink);
|
||||||
FILE* Nu_DataSinkFile_GetFP(const NuDataSink* pDataSink);
|
FILE* Nu_DataSinkFile_GetFP(const NuDataSink* pDataSink);
|
||||||
void Nu_DataSinkFile_SetFP(NuDataSink* pDataSink, FILE* fp);
|
void Nu_DataSinkFile_SetFP(NuDataSink* pDataSink, FILE* fp);
|
||||||
void Nu_DataSinkFile_Close(NuDataSink* pDataSink);
|
void Nu_DataSinkFile_Close(NuDataSink* pDataSink);
|
||||||
NuError Nu_DataSinkPutBlock(NuDataSink* pDataSink, const uchar* buf, ulong len);
|
NuError Nu_DataSinkPutBlock(NuDataSink* pDataSink, const uint8_t* buf,
|
||||||
|
uint32_t len);
|
||||||
NuError Nu_DataSinkGetError(NuDataSink* pDataSink);
|
NuError Nu_DataSinkGetError(NuDataSink* pDataSink);
|
||||||
|
|
||||||
/* Squeeze.c */
|
/* Squeeze.c */
|
||||||
NuError Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
NuError Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc);
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc);
|
||||||
NuError Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
|
NuError Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc);
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc);
|
||||||
|
|
||||||
/* Thread.c */
|
/* Thread.c */
|
||||||
#ifdef __Thread_c__
|
#ifdef __Thread_c__
|
||||||
@ -837,9 +840,9 @@ NuError Nu_FindThreadByID(const NuRecord* pRecord, NuThreadID threadID,
|
|||||||
NuThread** ppThread);
|
NuThread** ppThread);
|
||||||
void Nu_CopyThreadContents(NuThread* pDstThread, const NuThread* pSrcThread);
|
void Nu_CopyThreadContents(NuThread* pDstThread, const NuThread* pSrcThread);
|
||||||
NuError Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord,
|
NuError Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord,
|
||||||
ushort* pCrc);
|
uint16_t* pCrc);
|
||||||
NuError Nu_WriteThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, FILE* fp,
|
NuError Nu_WriteThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, FILE* fp,
|
||||||
ushort* pCrc);
|
uint16_t* pCrc);
|
||||||
NuError Nu_ComputeThreadData(NuArchive* pArchive, NuRecord* pRecord);
|
NuError Nu_ComputeThreadData(NuArchive* pArchive, NuRecord* pRecord);
|
||||||
NuError Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord,long numThreads);
|
NuError Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord,long numThreads);
|
||||||
NuError Nu_ExtractThreadBulk(NuArchive* pArchive, const NuRecord* pRecord,
|
NuError Nu_ExtractThreadBulk(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
/*
|
/*
|
||||||
* Local constants.
|
* Local constants.
|
||||||
*/
|
*/
|
||||||
static const uchar kNufxID[kNufxIDLen] = { 0x4e, 0xf5, 0x46, 0xd8 };
|
static const uint8_t kNufxID[kNufxIDLen] = { 0x4e, 0xf5, 0x46, 0xd8 };
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -106,11 +106,11 @@ Nu_RecordFree(NuArchive* pArchive, NuRecord* pRecord)
|
|||||||
* another. It is assumed that the length value has already been copied.
|
* another. It is assumed that the length value has already been copied.
|
||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
CopySizedField(NuArchive* pArchive, void* vppDst, const void* vpSrc, uint len)
|
CopySizedField(NuArchive* pArchive, void* vppDst, const void* vpSrc, uint32_t len)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
uchar** ppDst = vppDst;
|
uint8_t** ppDst = vppDst;
|
||||||
const uchar* pSrc = vpSrc;
|
const uint8_t* pSrc = vpSrc;
|
||||||
|
|
||||||
Assert(ppDst != NULL);
|
Assert(ppDst != NULL);
|
||||||
|
|
||||||
@ -288,14 +288,14 @@ Nu_RecordSet_SetLoaded(NuRecordSet* pRecordSet, Boolean val)
|
|||||||
pRecordSet->loaded = val;
|
pRecordSet->loaded = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong
|
uint32_t
|
||||||
Nu_RecordSet_GetNumRecords(const NuRecordSet* pRecordSet)
|
Nu_RecordSet_GetNumRecords(const NuRecordSet* pRecordSet)
|
||||||
{
|
{
|
||||||
return pRecordSet->numRecords;
|
return pRecordSet->numRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Nu_RecordSet_SetNumRecords(NuRecordSet* pRecordSet, ulong val)
|
Nu_RecordSet_SetNumRecords(NuRecordSet* pRecordSet, uint32_t val)
|
||||||
{
|
{
|
||||||
pRecordSet->numRecords = val;
|
pRecordSet->numRecords = val;
|
||||||
}
|
}
|
||||||
@ -876,7 +876,7 @@ static NuError
|
|||||||
Nu_ReadRecordHeader(NuArchive* pArchive, NuRecord* pRecord)
|
Nu_ReadRecordHeader(NuArchive* pArchive, NuRecord* pRecord)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
ushort crc;
|
uint16_t crc;
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
|
|
||||||
@ -941,7 +941,7 @@ Nu_ReadRecordHeader(NuArchive* pArchive, NuRecord* pRecord)
|
|||||||
}
|
}
|
||||||
if (pRecord->recTotalThreads > kNuReasonableTotalThreads) {
|
if (pRecord->recTotalThreads > kNuReasonableTotalThreads) {
|
||||||
err = kNuErrBadRecord;
|
err = kNuErrBadRecord;
|
||||||
Nu_ReportError(NU_BLOB, err, "Unreasonable number of threads (%lu)",
|
Nu_ReportError(NU_BLOB, err, "Unreasonable number of threads (%u)",
|
||||||
pRecord->recTotalThreads);
|
pRecord->recTotalThreads);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -1056,7 +1056,7 @@ Nu_ReadRecordHeader(NuArchive* pArchive, NuRecord* pRecord)
|
|||||||
Nu_ReportError(NU_BLOB, err, "Stored RH CRC=0x%04x, calc=0x%04x",
|
Nu_ReportError(NU_BLOB, err, "Stored RH CRC=0x%04x, calc=0x%04x",
|
||||||
pRecord->recHeaderCRC, crc);
|
pRecord->recHeaderCRC, crc);
|
||||||
Nu_ReportError(NU_BLOB_DEBUG, kNuErrNone,
|
Nu_ReportError(NU_BLOB_DEBUG, kNuErrNone,
|
||||||
"--- Problematic record is id=%ld", pRecord->recordIdx);
|
"--- Problematic record is id=%u", pRecord->recordIdx);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1171,7 +1171,7 @@ NuError
|
|||||||
Nu_WriteRecordHeader(NuArchive* pArchive, NuRecord* pRecord, FILE* fp)
|
Nu_WriteRecordHeader(NuArchive* pArchive, NuRecord* pRecord, FILE* fp)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
ushort crc;
|
uint16_t crc;
|
||||||
long crcOffset;
|
long crcOffset;
|
||||||
int bytesWritten;
|
int bytesWritten;
|
||||||
|
|
||||||
@ -1199,7 +1199,7 @@ Nu_WriteRecordHeader(NuArchive* pArchive, NuRecord* pRecord, FILE* fp)
|
|||||||
Nu_WriteTwoC(pArchive, fp, pRecord->recAttribCount, &crc);
|
Nu_WriteTwoC(pArchive, fp, pRecord->recAttribCount, &crc);
|
||||||
Nu_WriteTwoC(pArchive, fp, pRecord->recVersionNumber, &crc);
|
Nu_WriteTwoC(pArchive, fp, pRecord->recVersionNumber, &crc);
|
||||||
Nu_WriteFourC(pArchive, fp, pRecord->recTotalThreads, &crc);
|
Nu_WriteFourC(pArchive, fp, pRecord->recTotalThreads, &crc);
|
||||||
Nu_WriteTwoC(pArchive, fp, (ushort)pRecord->recFileSysID, &crc);
|
Nu_WriteTwoC(pArchive, fp, (uint16_t)pRecord->recFileSysID, &crc);
|
||||||
Nu_WriteTwoC(pArchive, fp, pRecord->recFileSysInfo, &crc);
|
Nu_WriteTwoC(pArchive, fp, pRecord->recFileSysInfo, &crc);
|
||||||
Nu_WriteFourC(pArchive, fp, pRecord->recAccess, &crc);
|
Nu_WriteFourC(pArchive, fp, pRecord->recAccess, &crc);
|
||||||
Nu_WriteFourC(pArchive, fp, pRecord->recFileType, &crc);
|
Nu_WriteFourC(pArchive, fp, pRecord->recFileType, &crc);
|
||||||
@ -1423,7 +1423,7 @@ Nu_GetTOCIfNeeded(NuArchive* pArchive)
|
|||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuRecord* pRecord;
|
NuRecord* pRecord;
|
||||||
ulong count;
|
uint32_t count;
|
||||||
|
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
|
|
||||||
@ -1464,7 +1464,7 @@ Nu_StreamContents(NuArchive* pArchive, NuCallback contentFunc)
|
|||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuRecord tmpRecord;
|
NuRecord tmpRecord;
|
||||||
NuResult result;
|
NuResult result;
|
||||||
ulong count;
|
uint32_t count;
|
||||||
|
|
||||||
if (contentFunc == NULL) {
|
if (contentFunc == NULL) {
|
||||||
err = kNuErrInvalidArg;
|
err = kNuErrInvalidArg;
|
||||||
@ -1555,7 +1555,7 @@ Nu_StreamExtract(NuArchive* pArchive)
|
|||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuRecord tmpRecord;
|
NuRecord tmpRecord;
|
||||||
Boolean hasInterestingThread;
|
Boolean hasInterestingThread;
|
||||||
ulong count;
|
uint32_t count;
|
||||||
long idx;
|
long idx;
|
||||||
|
|
||||||
/* reset this just to be safe */
|
/* reset this just to be safe */
|
||||||
@ -1692,7 +1692,7 @@ Nu_Contents(NuArchive* pArchive, NuCallback contentFunc)
|
|||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuRecord* pRecord;
|
NuRecord* pRecord;
|
||||||
NuResult result;
|
NuResult result;
|
||||||
ulong count;
|
uint32_t count;
|
||||||
|
|
||||||
if (contentFunc == NULL) {
|
if (contentFunc == NULL) {
|
||||||
err = kNuErrInvalidArg;
|
err = kNuErrInvalidArg;
|
||||||
@ -1732,7 +1732,7 @@ Nu_ExtractRecordByPtr(NuArchive* pArchive, NuRecord* pRecord)
|
|||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
Boolean hasInterestingThread;
|
Boolean hasInterestingThread;
|
||||||
ulong idx;
|
uint32_t idx;
|
||||||
|
|
||||||
Assert(!Nu_IsStreaming(pArchive)); /* we don't skip things we don't read */
|
Assert(!Nu_IsStreaming(pArchive)); /* we don't skip things we don't read */
|
||||||
Assert(pRecord != NULL);
|
Assert(pRecord != NULL);
|
||||||
@ -1801,7 +1801,7 @@ Nu_Extract(NuArchive* pArchive)
|
|||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
NuRecord* pRecord = NULL;
|
NuRecord* pRecord = NULL;
|
||||||
ulong count;
|
uint32_t count;
|
||||||
long offset;
|
long offset;
|
||||||
|
|
||||||
/* reset this just to be safe */
|
/* reset this just to be safe */
|
||||||
@ -1977,7 +1977,7 @@ bail:
|
|||||||
* Find the recordIdx of a record by zero-based position.
|
* Find the recordIdx of a record by zero-based position.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_GetRecordIdxByPosition(NuArchive* pArchive, ulong position,
|
Nu_GetRecordIdxByPosition(NuArchive* pArchive, uint32_t position,
|
||||||
NuRecordIdx* pRecordIdx)
|
NuRecordIdx* pRecordIdx)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
@ -2644,7 +2644,7 @@ Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname,
|
|||||||
if (doAdd || doUpdate) {
|
if (doAdd || doUpdate) {
|
||||||
Assert(newCapacity);
|
Assert(newCapacity);
|
||||||
err = Nu_DataSourceBuffer_New(kNuThreadFormatUncompressed,
|
err = Nu_DataSourceBuffer_New(kNuThreadFormatUncompressed,
|
||||||
newCapacity, (const uchar*)strdup(pathname), 0,
|
newCapacity, (const uint8_t*)strdup(pathname), 0,
|
||||||
requiredCapacity /*(strlen)*/, Nu_InternalFreeCallback,
|
requiredCapacity /*(strlen)*/, Nu_InternalFreeCallback,
|
||||||
&pDataSource);
|
&pDataSource);
|
||||||
BailError(err);
|
BailError(err);
|
||||||
|
@ -140,7 +140,7 @@ Nu_DataSourceFree(NuDataSource* pDataSource)
|
|||||||
* Create a data source for an unopened file.
|
* Create a data source for an unopened file.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_DataSourceFile_New(NuThreadFormat threadFormat, ulong otherLen,
|
Nu_DataSourceFile_New(NuThreadFormat threadFormat, uint32_t otherLen,
|
||||||
const char* pathname, Boolean isFromRsrcFork, NuDataSource** ppDataSource)
|
const char* pathname, Boolean isFromRsrcFork, NuDataSource** ppDataSource)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
@ -176,7 +176,7 @@ bail:
|
|||||||
* must be seekable.
|
* must be seekable.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_DataSourceFP_New(NuThreadFormat threadFormat, ulong otherLen,
|
Nu_DataSourceFP_New(NuThreadFormat threadFormat, uint32_t otherLen,
|
||||||
FILE* fp, long offset, long length, NuCallback fcloseFunc,
|
FILE* fp, long offset, long length, NuCallback fcloseFunc,
|
||||||
NuDataSource** ppDataSource)
|
NuDataSource** ppDataSource)
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ Nu_DataSourceFP_New(NuThreadFormat threadFormat, ulong otherLen,
|
|||||||
return kNuErrInvalidArg;
|
return kNuErrInvalidArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherLen && otherLen < (ulong)length) {
|
if (otherLen && otherLen < (uint32_t)length) {
|
||||||
DBUG(("--- rejecting FP len=%ld other=%ld\n", length, otherLen));
|
DBUG(("--- rejecting FP len=%ld other=%ld\n", length, otherLen));
|
||||||
err = kNuErrPreSizeOverflow;
|
err = kNuErrPreSizeOverflow;
|
||||||
goto bail;
|
goto bail;
|
||||||
@ -221,8 +221,8 @@ bail:
|
|||||||
* blank comment fields.
|
* blank comment fields.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_DataSourceBuffer_New(NuThreadFormat threadFormat, ulong otherLen,
|
Nu_DataSourceBuffer_New(NuThreadFormat threadFormat, uint32_t otherLen,
|
||||||
const uchar* buffer, long offset, long length, NuCallback freeFunc,
|
const uint8_t* buffer, long offset, long length, NuCallback freeFunc,
|
||||||
NuDataSource** ppDataSource)
|
NuDataSource** ppDataSource)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
@ -237,7 +237,7 @@ Nu_DataSourceBuffer_New(NuThreadFormat threadFormat, ulong otherLen,
|
|||||||
freeFunc = NULL;
|
freeFunc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherLen && otherLen < (ulong)length) {
|
if (otherLen && otherLen < (uint32_t)length) {
|
||||||
DBUG(("--- rejecting buffer len=%ld other=%ld\n", length, otherLen));
|
DBUG(("--- rejecting buffer len=%ld other=%ld\n", length, otherLen));
|
||||||
err = kNuErrPreSizeOverflow;
|
err = kNuErrPreSizeOverflow;
|
||||||
goto bail;
|
goto bail;
|
||||||
@ -287,7 +287,7 @@ Nu_DataSourceGetThreadFormat(const NuDataSource* pDataSource)
|
|||||||
/*
|
/*
|
||||||
* Get "dataLen" from a dataSource.
|
* Get "dataLen" from a dataSource.
|
||||||
*/
|
*/
|
||||||
ulong
|
uint32_t
|
||||||
Nu_DataSourceGetDataLen(const NuDataSource* pDataSource)
|
Nu_DataSourceGetDataLen(const NuDataSource* pDataSource)
|
||||||
{
|
{
|
||||||
Assert(pDataSource != NULL);
|
Assert(pDataSource != NULL);
|
||||||
@ -303,7 +303,7 @@ Nu_DataSourceGetDataLen(const NuDataSource* pDataSource)
|
|||||||
/*
|
/*
|
||||||
* Get "otherLen" from a dataSource.
|
* Get "otherLen" from a dataSource.
|
||||||
*/
|
*/
|
||||||
ulong
|
uint32_t
|
||||||
Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource)
|
Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource)
|
||||||
{
|
{
|
||||||
Assert(pDataSource != NULL);
|
Assert(pDataSource != NULL);
|
||||||
@ -324,7 +324,7 @@ Nu_DataSourceSetOtherLen(NuDataSource* pDataSource, long otherLen)
|
|||||||
/*
|
/*
|
||||||
* Get the "raw CRC" value.
|
* Get the "raw CRC" value.
|
||||||
*/
|
*/
|
||||||
ushort
|
uint16_t
|
||||||
Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource)
|
Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource)
|
||||||
{
|
{
|
||||||
Assert(pDataSource != NULL);
|
Assert(pDataSource != NULL);
|
||||||
@ -336,7 +336,7 @@ Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource)
|
|||||||
* already-compressed data, and you wanted to propagate the thread CRC.
|
* already-compressed data, and you wanted to propagate the thread CRC.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Nu_DataSourceSetRawCrc(NuDataSource* pDataSource, ushort crc)
|
Nu_DataSourceSetRawCrc(NuDataSource* pDataSource, uint16_t crc)
|
||||||
{
|
{
|
||||||
Assert(pDataSource != NULL);
|
Assert(pDataSource != NULL);
|
||||||
pDataSource->common.rawCrc = crc;
|
pDataSource->common.rawCrc = crc;
|
||||||
@ -435,7 +435,7 @@ Nu_DataSourceFile_GetPathname(NuDataSource* pDataSource)
|
|||||||
* Read a block of data from a dataSource.
|
* Read a block of data from a dataSource.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_DataSourceGetBlock(NuDataSource* pDataSource, uchar* buf, ulong len)
|
Nu_DataSourceGetBlock(NuDataSource* pDataSource, uint8_t* buf, uint32_t len)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
|
|
||||||
@ -643,8 +643,8 @@ bail:
|
|||||||
* Create a data sink for a buffer in memory.
|
* Create a data sink for a buffer in memory.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_DataSinkBuffer_New(Boolean doExpand, NuValue convertEOL, uchar* buffer,
|
Nu_DataSinkBuffer_New(Boolean doExpand, NuValue convertEOL, uint8_t* buffer,
|
||||||
ulong bufLen, NuDataSink** ppDataSink)
|
uint32_t bufLen, NuDataSink** ppDataSink)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
|
|
||||||
@ -735,7 +735,7 @@ Nu_DataSinkGetConvertEOL(const NuDataSink* pDataSink)
|
|||||||
/*
|
/*
|
||||||
* Return the #of bytes written to the sink.
|
* Return the #of bytes written to the sink.
|
||||||
*/
|
*/
|
||||||
ulong
|
uint32_t
|
||||||
Nu_DataSinkGetOutCount(const NuDataSink* pDataSink)
|
Nu_DataSinkGetOutCount(const NuDataSink* pDataSink)
|
||||||
{
|
{
|
||||||
return pDataSink->common.outCount;
|
return pDataSink->common.outCount;
|
||||||
@ -809,7 +809,7 @@ Nu_DataSinkFile_Close(NuDataSink* pDataSink)
|
|||||||
* Write a block of data to a DataSink.
|
* Write a block of data to a DataSink.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_DataSinkPutBlock(NuDataSink* pDataSink, const uchar* buf, ulong len)
|
Nu_DataSinkPutBlock(NuDataSink* pDataSink, const uint8_t* buf, uint32_t len)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
|
|
||||||
|
@ -77,13 +77,13 @@ typedef struct EncTreeNode {
|
|||||||
typedef struct SQState {
|
typedef struct SQState {
|
||||||
NuArchive* pArchive;
|
NuArchive* pArchive;
|
||||||
int doCalcCRC; /* boolean; if set, compute CRC on input */
|
int doCalcCRC; /* boolean; if set, compute CRC on input */
|
||||||
ushort crc;
|
uint16_t crc;
|
||||||
|
|
||||||
NuStraw* pStraw;
|
NuStraw* pStraw;
|
||||||
long uncompRemaining;
|
long uncompRemaining;
|
||||||
|
|
||||||
#ifdef FULL_SQ_HEADER
|
#ifdef FULL_SQ_HEADER
|
||||||
ushort checksum;
|
uint16_t checksum;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -98,12 +98,12 @@ typedef struct SQState {
|
|||||||
*/
|
*/
|
||||||
EncTreeNode node[kNuSQNumNodes];
|
EncTreeNode node[kNuSQNumNodes];
|
||||||
|
|
||||||
int treeHead; /* index to head node of final tree */
|
int treeHead; /* index to head node of final tree */
|
||||||
|
|
||||||
/* encoding table */
|
/* encoding table */
|
||||||
int codeLen[kNuSQNumVals]; /* number of bits in code for symbol N */
|
int codeLen[kNuSQNumVals]; /* number of bits in code for symbol N */
|
||||||
ushort code[kNuSQNumVals]; /* bits for symbol N (first bit in lsb) */
|
uint16_t code[kNuSQNumVals]; /* bits for symbol N (first bit in lsb) */
|
||||||
ushort tmpCode; /* temporary code value */
|
uint16_t tmpCode; /* temporary code value */
|
||||||
} SQState;
|
} SQState;
|
||||||
|
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ static NuError
|
|||||||
Nu_SQGetcCRC(SQState* pSqState, int* pSym)
|
Nu_SQGetcCRC(SQState* pSqState, int* pSym)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
uchar c;
|
uint8_t c;
|
||||||
|
|
||||||
if (!pSqState->uncompRemaining) {
|
if (!pSqState->uncompRemaining) {
|
||||||
*pSym = kNuSQEOFToken;
|
*pSym = kNuSQEOFToken;
|
||||||
@ -437,7 +437,7 @@ Nu_SQBuildEncTable(SQState* pSqState, int level, int root)
|
|||||||
*/
|
*/
|
||||||
pSqState->codeLen[root] = level;
|
pSqState->codeLen[root] = level;
|
||||||
pSqState->code[root] =
|
pSqState->code[root] =
|
||||||
pSqState->tmpCode & (((ushort)~0) >> (16 - level));
|
pSqState->tmpCode & (((uint16_t)~0) >> (16 - level));
|
||||||
return (level > 16) ? -1 : 0;
|
return (level > 16) ? -1 : 0;
|
||||||
} else {
|
} else {
|
||||||
if (l != kNuSQNoChild) {
|
if (l != kNuSQNoChild) {
|
||||||
@ -475,7 +475,7 @@ Nu_SQScale(SQState* pSqState, int ceiling)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int wt, ovflw, divisor;
|
int wt, ovflw, divisor;
|
||||||
ushort sum;
|
uint16_t sum;
|
||||||
int increased; /* flag */
|
int increased; /* flag */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -615,7 +615,7 @@ Nu_SQCompressInput(SQState* pSqState, FILE* fp, long* pCompressedLen)
|
|||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
int sym = kNuSQEOFToken-1;
|
int sym = kNuSQEOFToken-1;
|
||||||
unsigned long bits, code; /* must hold at least 23 bits */
|
uint32_t bits, code; /* must hold at least 23 bits */
|
||||||
int codeLen, gotbits;
|
int codeLen, gotbits;
|
||||||
long compressedLen;
|
long compressedLen;
|
||||||
|
|
||||||
@ -665,7 +665,7 @@ static NuError
|
|||||||
Nu_SQWriteShort(FILE* outfp, short val)
|
Nu_SQWriteShort(FILE* outfp, short val)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
uchar tmpc;
|
uint8_t tmpc;
|
||||||
|
|
||||||
tmpc = val & 0xff;
|
tmpc = val & 0xff;
|
||||||
err = Nu_FWrite(outfp, &tmpc, 1);
|
err = Nu_FWrite(outfp, &tmpc, 1);
|
||||||
@ -691,7 +691,7 @@ bail:
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
|
||||||
ulong srcLen, ulong* pDstLen, ushort* pCrc)
|
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
SQState sqState;
|
SQState sqState;
|
||||||
@ -822,8 +822,8 @@ bail:
|
|||||||
* State during uncompression.
|
* State during uncompression.
|
||||||
*/
|
*/
|
||||||
typedef struct USQState {
|
typedef struct USQState {
|
||||||
ulong dataInBuffer;
|
uint32_t dataInBuffer;
|
||||||
uchar* dataPtr;
|
uint8_t* dataPtr;
|
||||||
int bitPosn;
|
int bitPosn;
|
||||||
int bits;
|
int bits;
|
||||||
|
|
||||||
@ -900,17 +900,17 @@ Nu_USQReadShort(USQState* pUsqState, short* pShort)
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
|
Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
|
||||||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc)
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
USQState usqState;
|
USQState usqState;
|
||||||
ulong compRemaining, getSize;
|
uint32_t compRemaining, getSize;
|
||||||
#ifdef FULL_SQ_HEADER
|
#ifdef FULL_SQ_HEADER
|
||||||
ushort magic, fileChecksum, checksum;
|
uint16_t magic, fileChecksum, checksum;
|
||||||
#endif
|
#endif
|
||||||
short nodeCount;
|
short nodeCount;
|
||||||
int i, inrep;
|
int i, inrep;
|
||||||
uchar lastc = 0;
|
uint8_t lastc = 0;
|
||||||
|
|
||||||
err = Nu_AllocCompressionBufferIFN(pArchive);
|
err = Nu_AllocCompressionBufferIFN(pArchive);
|
||||||
if (err != kNuErrNone)
|
if (err != kNuErrNone)
|
||||||
@ -945,7 +945,7 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
err = Nu_FRead(infp, usqState.dataPtr, getSize);
|
err = Nu_FRead(infp, usqState.dataPtr, getSize);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"failed reading compressed data (%ld bytes)", getSize);
|
"failed reading compressed data (%u bytes)", getSize);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
usqState.dataInBuffer += getSize;
|
usqState.dataInBuffer += getSize;
|
||||||
@ -1046,7 +1046,7 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
getSize);
|
getSize);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"failed reading compressed data (%ld bytes)", getSize);
|
"failed reading compressed data (%u bytes)", getSize);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
usqState.dataInBuffer += getSize;
|
usqState.dataInBuffer += getSize;
|
||||||
@ -1135,7 +1135,7 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
if (usqState.dataInBuffer > 1) {
|
if (usqState.dataInBuffer > 1) {
|
||||||
DBUG(("--- Found %ld bytes following compressed data (compRem=%ld)\n",
|
DBUG(("--- Found %ld bytes following compressed data (compRem=%ld)\n",
|
||||||
usqState.dataInBuffer, compRemaining));
|
usqState.dataInBuffer, compRemaining));
|
||||||
Nu_ReportError(NU_BLOB, kNuErrNone, "(Warning) unexpected fluff (%ld)",
|
Nu_ReportError(NU_BLOB, kNuErrNone, "(Warning) unexpected fluff (%u)",
|
||||||
usqState.dataInBuffer);
|
usqState.dataInBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* these should exist everywhere */
|
/* these should exist everywhere */
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
@ -55,10 +54,6 @@
|
|||||||
# define SNPRINTF_DECLARED
|
# define SNPRINTF_DECLARED
|
||||||
# define VSNPRINTF_DECLARED
|
# define VSNPRINTF_DECLARED
|
||||||
# define SPRINTF_RETURNS_INT
|
# define SPRINTF_RETURNS_INT
|
||||||
# define uchar unsigned char
|
|
||||||
# define ushort unsigned short
|
|
||||||
# define uint unsigned int
|
|
||||||
# define ulong unsigned long
|
|
||||||
# define inline /*Visual C++6.0 can't inline ".c" files*/
|
# define inline /*Visual C++6.0 can't inline ".c" files*/
|
||||||
# define mode_t int
|
# define mode_t int
|
||||||
# define ENABLE_SQ
|
# define ENABLE_SQ
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
void
|
void
|
||||||
Nu_StripHiIfAllSet(char* str)
|
Nu_StripHiIfAllSet(char* str)
|
||||||
{
|
{
|
||||||
uchar* cp;
|
uint8_t* cp;
|
||||||
|
|
||||||
for (cp = (uchar*)str; *cp != '\0'; cp++)
|
for (cp = (uint8_t*)str; *cp != '\0'; cp++)
|
||||||
if (!(*cp & 0x80))
|
if (!(*cp & 0x80))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (cp = (uchar*)str; *cp != '\0'; cp++)
|
for (cp = (uint8_t*)str; *cp != '\0'; cp++)
|
||||||
*cp &= 0x7f;
|
*cp &= 0x7f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ Nu_CopyThreadContents(NuThread* pDstThread, const NuThread* pSrcThread)
|
|||||||
* Read a single thread header from the archive.
|
* Read a single thread header from the archive.
|
||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_ReadThreadHeader(NuArchive* pArchive, NuThread* pThread, ushort* pCrc)
|
Nu_ReadThreadHeader(NuArchive* pArchive, NuThread* pThread, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ Nu_ReadThreadHeader(NuArchive* pArchive, NuThread* pThread, ushort* pCrc)
|
|||||||
* benefit for us, and adds complexity.
|
* benefit for us, and adds complexity.
|
||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, ushort* pCrc)
|
Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuThread* pThread;
|
NuThread* pThread;
|
||||||
@ -308,7 +308,7 @@ bail:
|
|||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
Nu_WriteThreadHeader(NuArchive* pArchive, const NuThread* pThread, FILE* fp,
|
Nu_WriteThreadHeader(NuArchive* pArchive, const NuThread* pThread, FILE* fp,
|
||||||
ushort* pCrc)
|
uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
Assert(pArchive != NULL);
|
Assert(pArchive != NULL);
|
||||||
Assert(pThread != NULL);
|
Assert(pThread != NULL);
|
||||||
@ -316,7 +316,7 @@ Nu_WriteThreadHeader(NuArchive* pArchive, const NuThread* pThread, FILE* fp,
|
|||||||
Assert(pCrc != NULL);
|
Assert(pCrc != NULL);
|
||||||
|
|
||||||
Nu_WriteTwoC(pArchive, fp, pThread->thThreadClass, pCrc);
|
Nu_WriteTwoC(pArchive, fp, pThread->thThreadClass, pCrc);
|
||||||
Nu_WriteTwoC(pArchive, fp, (ushort)pThread->thThreadFormat, pCrc);
|
Nu_WriteTwoC(pArchive, fp, (uint16_t)pThread->thThreadFormat, pCrc);
|
||||||
Nu_WriteTwoC(pArchive, fp, pThread->thThreadKind, pCrc);
|
Nu_WriteTwoC(pArchive, fp, pThread->thThreadKind, pCrc);
|
||||||
Nu_WriteTwoC(pArchive, fp, pThread->thThreadCRC, pCrc);
|
Nu_WriteTwoC(pArchive, fp, pThread->thThreadCRC, pCrc);
|
||||||
Nu_WriteFourC(pArchive, fp, pThread->thThreadEOF, pCrc);
|
Nu_WriteFourC(pArchive, fp, pThread->thThreadEOF, pCrc);
|
||||||
@ -334,7 +334,7 @@ Nu_WriteThreadHeader(NuArchive* pArchive, const NuThread* pThread, FILE* fp,
|
|||||||
*/
|
*/
|
||||||
NuError
|
NuError
|
||||||
Nu_WriteThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, FILE* fp,
|
Nu_WriteThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, FILE* fp,
|
||||||
ushort* pCrc)
|
uint16_t* pCrc)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuThread* pThread;
|
NuThread* pThread;
|
||||||
@ -430,7 +430,7 @@ Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord, long numThreads)
|
|||||||
/* it's the first filename thread, read the whole thing */
|
/* it's the first filename thread, read the whole thing */
|
||||||
if (pThread->thCompThreadEOF > kNuReasonableFilenameLen) {
|
if (pThread->thCompThreadEOF > kNuReasonableFilenameLen) {
|
||||||
err = kNuErrBadRecord;
|
err = kNuErrBadRecord;
|
||||||
Nu_ReportError(NU_BLOB, err, "Bad thread filename len (%lu)",
|
Nu_ReportError(NU_BLOB, err, "Bad thread filename len (%u)",
|
||||||
pThread->thCompThreadEOF);
|
pThread->thCompThreadEOF);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -589,7 +589,7 @@ Nu_ExtractThreadCommon(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
char* newPathStorage = NULL;
|
char* newPathStorage = NULL;
|
||||||
const char* newPathname;
|
const char* newPathname;
|
||||||
NuResult result;
|
NuResult result;
|
||||||
uchar newFssep;
|
uint8_t newFssep;
|
||||||
Boolean doFreeSink = false;
|
Boolean doFreeSink = false;
|
||||||
|
|
||||||
Assert(pRecord != NULL);
|
Assert(pRecord != NULL);
|
||||||
@ -1269,7 +1269,7 @@ Nu_UpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx,
|
|||||||
Nu_DataSourceGetOtherLen(pDataSource))
|
Nu_DataSourceGetOtherLen(pDataSource))
|
||||||
{
|
{
|
||||||
err = kNuErrPreSizeOverflow;
|
err = kNuErrPreSizeOverflow;
|
||||||
Nu_ReportError(NU_BLOB, err, "can't put %ld bytes into %ld",
|
Nu_ReportError(NU_BLOB, err, "can't put %u bytes into %u",
|
||||||
Nu_DataSourceGetOtherLen(pDataSource),
|
Nu_DataSourceGetOtherLen(pDataSource),
|
||||||
pFoundThread->thCompThreadEOF);
|
pFoundThread->thCompThreadEOF);
|
||||||
goto bail;
|
goto bail;
|
||||||
@ -1281,7 +1281,7 @@ Nu_UpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx,
|
|||||||
Nu_DataSourceGetOtherLen(pDataSource) > kNuReasonableFilenameLen))
|
Nu_DataSourceGetOtherLen(pDataSource) > kNuReasonableFilenameLen))
|
||||||
{
|
{
|
||||||
err = kNuErrInvalidFilename;
|
err = kNuErrInvalidFilename;
|
||||||
Nu_ReportError(NU_BLOB, err, "invalid filename (%ld bytes)",
|
Nu_ReportError(NU_BLOB, err, "invalid filename (%u bytes)",
|
||||||
Nu_DataSourceGetOtherLen(pDataSource));
|
Nu_DataSourceGetOtherLen(pDataSource));
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueAllowDuplicates:
|
case kNuValueAllowDuplicates:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueAllowDuplicates value %ld", value);
|
"Invalid kNuValueAllowDuplicates value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valAllowDuplicates = value;
|
pArchive->valAllowDuplicates = value;
|
||||||
@ -99,7 +99,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueConvertExtractedEOL:
|
case kNuValueConvertExtractedEOL:
|
||||||
if (value < kNuConvertOff || value > kNuConvertAuto) {
|
if (value < kNuConvertOff || value > kNuConvertAuto) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueConvertExtractedEOL value %ld", value);
|
"Invalid kNuValueConvertExtractedEOL value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valConvertExtractedEOL = value;
|
pArchive->valConvertExtractedEOL = value;
|
||||||
@ -107,7 +107,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueDataCompression:
|
case kNuValueDataCompression:
|
||||||
if (value < kNuCompressNone || value > kNuCompressBzip2) {
|
if (value < kNuCompressNone || value > kNuCompressBzip2) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueDataCompression value %ld", value);
|
"Invalid kNuValueDataCompression value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valDataCompression = value;
|
pArchive->valDataCompression = value;
|
||||||
@ -115,7 +115,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueDiscardWrapper:
|
case kNuValueDiscardWrapper:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueDiscardWrapper value %ld", value);
|
"Invalid kNuValueDiscardWrapper value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valDiscardWrapper = value;
|
pArchive->valDiscardWrapper = value;
|
||||||
@ -123,7 +123,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueEOL:
|
case kNuValueEOL:
|
||||||
if (value < kNuEOLUnknown || value > kNuEOLCRLF) {
|
if (value < kNuEOLUnknown || value > kNuEOLCRLF) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueEOL value %ld", value);
|
"Invalid kNuValueEOL value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valEOL = value;
|
pArchive->valEOL = value;
|
||||||
@ -131,7 +131,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueHandleExisting:
|
case kNuValueHandleExisting:
|
||||||
if (value < kNuMaybeOverwrite || value > kNuMustOverwrite) {
|
if (value < kNuMaybeOverwrite || value > kNuMustOverwrite) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueHandleExisting value %ld", value);
|
"Invalid kNuValueHandleExisting value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valHandleExisting = value;
|
pArchive->valHandleExisting = value;
|
||||||
@ -139,7 +139,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueIgnoreCRC:
|
case kNuValueIgnoreCRC:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueIgnoreCRC value %ld", value);
|
"Invalid kNuValueIgnoreCRC value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valIgnoreCRC = value;
|
pArchive->valIgnoreCRC = value;
|
||||||
@ -147,7 +147,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueMaskDataless:
|
case kNuValueMaskDataless:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueMaskDataless value %ld", value);
|
"Invalid kNuValueMaskDataless value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valMaskDataless = value;
|
pArchive->valMaskDataless = value;
|
||||||
@ -155,7 +155,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueMimicSHK:
|
case kNuValueMimicSHK:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueMimicSHK value %ld", value);
|
"Invalid kNuValueMimicSHK value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valMimicSHK = value;
|
pArchive->valMimicSHK = value;
|
||||||
@ -163,7 +163,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueModifyOrig:
|
case kNuValueModifyOrig:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueModifyOrig value %ld", value);
|
"Invalid kNuValueModifyOrig value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valModifyOrig = value;
|
pArchive->valModifyOrig = value;
|
||||||
@ -171,7 +171,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueOnlyUpdateOlder:
|
case kNuValueOnlyUpdateOlder:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueOnlyUpdateOlder value %ld", value);
|
"Invalid kNuValueOnlyUpdateOlder value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valOnlyUpdateOlder = value;
|
pArchive->valOnlyUpdateOlder = value;
|
||||||
@ -179,7 +179,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueStripHighASCII:
|
case kNuValueStripHighASCII:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueStripHighASCII value %ld", value);
|
"Invalid kNuValueStripHighASCII value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valStripHighASCII = value;
|
pArchive->valStripHighASCII = value;
|
||||||
@ -187,7 +187,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueJunkSkipMax:
|
case kNuValueJunkSkipMax:
|
||||||
if (value > kMaxJunkSkipMax) {
|
if (value > kMaxJunkSkipMax) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueJunkSkipMax value %ld", value);
|
"Invalid kNuValueJunkSkipMax value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valJunkSkipMax = value;
|
pArchive->valJunkSkipMax = value;
|
||||||
@ -195,7 +195,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueIgnoreLZW2Len:
|
case kNuValueIgnoreLZW2Len:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueIgnoreLZW2Len value %ld", value);
|
"Invalid kNuValueIgnoreLZW2Len value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valIgnoreLZW2Len = value;
|
pArchive->valIgnoreLZW2Len = value;
|
||||||
@ -203,7 +203,7 @@ Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
|
|||||||
case kNuValueHandleBadMac:
|
case kNuValueHandleBadMac:
|
||||||
if (value != true && value != false) {
|
if (value != true && value != false) {
|
||||||
Nu_ReportError(NU_BLOB, err,
|
Nu_ReportError(NU_BLOB, err,
|
||||||
"Invalid kNuValueHandleBadMac value %ld", value);
|
"Invalid kNuValueHandleBadMac value %u", value);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
pArchive->valHandleBadMac = value;
|
pArchive->valHandleBadMac = value;
|
||||||
@ -312,14 +312,14 @@ Nu_ConvertCompressValToFormat(NuArchive* pArchive, NuValue compValue)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
Nu_ReportError(NU_BLOB, kNuErrInvalidArg,
|
Nu_ReportError(NU_BLOB, kNuErrInvalidArg,
|
||||||
"Unknown compress value %ld", compValue);
|
"Unknown compress value %u", compValue);
|
||||||
Assert(false);
|
Assert(false);
|
||||||
return kNuThreadFormatUncompressed;
|
return kNuThreadFormatUncompressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unsup) {
|
if (unsup) {
|
||||||
Nu_ReportError(NU_BLOB, kNuErrNone,
|
Nu_ReportError(NU_BLOB, kNuErrNone,
|
||||||
"Unsupported compression 0x%04x requested (%ld), storing",
|
"Unsupported compression 0x%04x requested (%u), storing",
|
||||||
threadFormat, compValue);
|
threadFormat, compValue);
|
||||||
return kNuThreadFormatUncompressed;
|
return kNuThreadFormatUncompressed;
|
||||||
}
|
}
|
||||||
|
@ -27,18 +27,6 @@
|
|||||||
/* Define if your <sys/time.h> declares struct tm. */
|
/* Define if your <sys/time.h> declares struct tm. */
|
||||||
#undef TM_IN_SYS_TIME
|
#undef TM_IN_SYS_TIME
|
||||||
|
|
||||||
/* Define to `unsigned char' if <sys/types.h> doesn't define. */
|
|
||||||
#undef uchar
|
|
||||||
|
|
||||||
/* Define to `unsigned short' if <sys/types.h> doesn't define. */
|
|
||||||
#undef ushort
|
|
||||||
|
|
||||||
/* Define to `unsigned int' if <sys/types.h> doesn't define. */
|
|
||||||
#undef uint
|
|
||||||
|
|
||||||
/* Define to `unsigned long' if <sys/types.h> doesn't define. */
|
|
||||||
#undef ulong
|
|
||||||
|
|
||||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||||
#undef mode_t
|
#undef mode_t
|
||||||
|
|
||||||
|
44
nufxlib/configure
vendored
44
nufxlib/configure
vendored
@ -3879,50 +3879,6 @@ $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "uchar" "ac_cv_type_uchar" "$ac_includes_default"
|
|
||||||
if test "x$ac_cv_type_uchar" = xyes; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define uchar unsigned char
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "ushort" "ac_cv_type_ushort" "$ac_includes_default"
|
|
||||||
if test "x$ac_cv_type_ushort" = xyes; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define ushort unsigned short
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "uint" "ac_cv_type_uint" "$ac_includes_default"
|
|
||||||
if test "x$ac_cv_type_uint" = xyes; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define uint unsigned int
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "ulong" "ac_cv_type_ulong" "$ac_includes_default"
|
|
||||||
if test "x$ac_cv_type_ulong" = xyes; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define ulong unsigned long
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
for ac_func in fdopen ftruncate memmove mkdir mkstemp mktime timelocal \
|
for ac_func in fdopen ftruncate memmove mkdir mkstemp mktime timelocal \
|
||||||
localtime_r snprintf strcasecmp strncasecmp strtoul strerror vsnprintf
|
localtime_r snprintf strcasecmp strncasecmp strtoul strerror vsnprintf
|
||||||
|
@ -29,10 +29,6 @@ AC_TYPE_MODE_T
|
|||||||
AC_TYPE_OFF_T
|
AC_TYPE_OFF_T
|
||||||
AC_TYPE_SIZE_T
|
AC_TYPE_SIZE_T
|
||||||
AC_STRUCT_TM
|
AC_STRUCT_TM
|
||||||
AC_CHECK_TYPE(uchar, unsigned char)
|
|
||||||
AC_CHECK_TYPE(ushort, unsigned short)
|
|
||||||
AC_CHECK_TYPE(uint, unsigned int)
|
|
||||||
AC_CHECK_TYPE(ulong, unsigned long)
|
|
||||||
|
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
AC_CHECK_FUNCS(fdopen ftruncate memmove mkdir mkstemp mktime timelocal \
|
AC_CHECK_FUNCS(fdopen ftruncate memmove mkdir mkstemp mktime timelocal \
|
||||||
|
@ -142,7 +142,7 @@ PrintEntry(NuArchive* pArchive, void* vpRecord)
|
|||||||
|
|
||||||
(void)pArchive; /* shut up, gcc */
|
(void)pArchive; /* shut up, gcc */
|
||||||
|
|
||||||
printf("RecordIdx %ld: '%s'\n",
|
printf("RecordIdx %u: '%s'\n",
|
||||||
pRecord->recordIdx, pRecord->filename);
|
pRecord->recordIdx, pRecord->filename);
|
||||||
|
|
||||||
for (idx = 0; idx < (int) pRecord->recTotalThreads; idx++) {
|
for (idx = 0; idx < (int) pRecord->recTotalThreads; idx++) {
|
||||||
@ -198,7 +198,7 @@ PrintEntry(NuArchive* pArchive, void* vpRecord)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" ThreadIdx %ld - 0x%08lx (%s)\n", pThread->threadIdx,
|
printf(" ThreadIdx %u - 0x%08x (%s)\n", pThread->threadIdx,
|
||||||
threadID, threadLabel);
|
threadID, threadLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ AddRecordFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
err = NuAddRecord(ExerciserState_GetNuArchive(pState),
|
err = NuAddRecord(ExerciserState_GetNuArchive(pState),
|
||||||
&nuFileDetails, &recordIdx);
|
&nuFileDetails, &recordIdx);
|
||||||
if (err == kNuErrNone)
|
if (err == kNuErrNone)
|
||||||
printf("Exerciser: success, new recordIdx=%ld\n", recordIdx);
|
printf("Exerciser: success, new recordIdx=%u\n", recordIdx);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +487,7 @@ AddThreadFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
|
|
||||||
/* create a data source from the buffer */
|
/* create a data source from the buffer */
|
||||||
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
||||||
maxLen, (unsigned char*)lineBuf, 0, ourLen, FreeCallback,
|
maxLen, (uint8_t*)lineBuf, 0, ourLen, FreeCallback,
|
||||||
&pDataSource);
|
&pDataSource);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -502,7 +502,7 @@ AddThreadFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
strtol(argv[1], NULL, 0), threadID, pDataSource, &threadIdx);
|
strtol(argv[1], NULL, 0), threadID, pDataSource, &threadIdx);
|
||||||
if (err == kNuErrNone) {
|
if (err == kNuErrNone) {
|
||||||
pDataSource = NULL; /* library owns it now */
|
pDataSource = NULL; /* library owns it now */
|
||||||
printf("Exerciser: success; function returned threadIdx=%ld\n",
|
printf("Exerciser: success; function returned threadIdx=%u\n",
|
||||||
threadIdx);
|
threadIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,7 +673,7 @@ GetValueFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
err = NuGetValue(ExerciserState_GetNuArchive(pState),
|
err = NuGetValue(ExerciserState_GetNuArchive(pState),
|
||||||
(NuValueID) strtol(argv[1], NULL, 0), &value);
|
(NuValueID) strtol(argv[1], NULL, 0), &value);
|
||||||
if (err == kNuErrNone)
|
if (err == kNuErrNone)
|
||||||
printf(" --> %ld\n", value);
|
printf(" --> %u\n", value);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,7 +693,7 @@ GetMasterHeaderFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
err = NuGetMasterHeader(ExerciserState_GetNuArchive(pState),
|
err = NuGetMasterHeader(ExerciserState_GetNuArchive(pState),
|
||||||
&pMasterHeader);
|
&pMasterHeader);
|
||||||
if (err == kNuErrNone) {
|
if (err == kNuErrNone) {
|
||||||
printf("Exerciser: success (version=%u, totalRecords=%lu, EOF=%lu)\n",
|
printf("Exerciser: success (version=%u, totalRecords=%u, EOF=%u)\n",
|
||||||
pMasterHeader->mhMasterVersion, pMasterHeader->mhTotalRecords,
|
pMasterHeader->mhMasterVersion, pMasterHeader->mhTotalRecords,
|
||||||
pMasterHeader->mhMasterEOF);
|
pMasterHeader->mhMasterEOF);
|
||||||
}
|
}
|
||||||
@ -720,9 +720,9 @@ GetRecordFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
printf("\tfileSysID : %d\n", pRecord->recFileSysID);
|
printf("\tfileSysID : %d\n", pRecord->recFileSysID);
|
||||||
printf("\tfileSysInfo : 0x%04x ('%c')\n", pRecord->recFileSysInfo,
|
printf("\tfileSysInfo : 0x%04x ('%c')\n", pRecord->recFileSysInfo,
|
||||||
NuGetSepFromSysInfo(pRecord->recFileSysInfo));
|
NuGetSepFromSysInfo(pRecord->recFileSysInfo));
|
||||||
printf("\taccess : 0x%02lx\n", pRecord->recAccess);
|
printf("\taccess : 0x%02x\n", pRecord->recAccess);
|
||||||
printf("\tfileType : 0x%04lx\n", pRecord->recFileType);
|
printf("\tfileType : 0x%04x\n", pRecord->recFileType);
|
||||||
printf("\textraType : 0x%04lx\n", pRecord->recExtraType);
|
printf("\textraType : 0x%04x\n", pRecord->recExtraType);
|
||||||
printf("\tcreateWhen : ...\n");
|
printf("\tcreateWhen : ...\n");
|
||||||
printf("\tmodWhen : ...\n"); /* too lazy */
|
printf("\tmodWhen : ...\n"); /* too lazy */
|
||||||
printf("\tarchiveWhen : ...\n");
|
printf("\tarchiveWhen : ...\n");
|
||||||
@ -746,7 +746,7 @@ GetRecordIdxByNameFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
err = NuGetRecordIdxByName(ExerciserState_GetNuArchive(pState),
|
err = NuGetRecordIdxByName(ExerciserState_GetNuArchive(pState),
|
||||||
argv[1], &recIdx);
|
argv[1], &recIdx);
|
||||||
if (err == kNuErrNone)
|
if (err == kNuErrNone)
|
||||||
printf("Exerciser: success, returned recordIdx=%ld\n", recIdx);
|
printf("Exerciser: success, returned recordIdx=%u\n", recIdx);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ GetRecordIdxByPositionFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
err = NuGetRecordIdxByPosition(ExerciserState_GetNuArchive(pState),
|
err = NuGetRecordIdxByPosition(ExerciserState_GetNuArchive(pState),
|
||||||
strtol(argv[1], NULL, 0), &recIdx);
|
strtol(argv[1], NULL, 0), &recIdx);
|
||||||
if (err == kNuErrNone)
|
if (err == kNuErrNone)
|
||||||
printf("Exerciser: success, returned recordIdx=%ld\n", recIdx);
|
printf("Exerciser: success, returned recordIdx=%u\n", recIdx);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1020,7 +1020,7 @@ UpdatePresizedThreadFunc(ExerciserState* pState, int argc, char** argv)
|
|||||||
|
|
||||||
/* use "ourLen" for both buffer len and data len */
|
/* use "ourLen" for both buffer len and data len */
|
||||||
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
||||||
ourLen, (unsigned char*)lineBuf, 0, ourLen, FreeCallback,
|
ourLen, (uint8_t*)lineBuf, 0, ourLen, FreeCallback,
|
||||||
&pDataSource);
|
&pDataSource);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "Exerciser: data source create failed (err=%d)\n",
|
fprintf(stderr, "Exerciser: data source create failed (err=%d)\n",
|
||||||
@ -1056,7 +1056,7 @@ static const struct {
|
|||||||
CommandFunc func;
|
CommandFunc func;
|
||||||
int expectedArgCount;
|
int expectedArgCount;
|
||||||
const char* argumentList;
|
const char* argumentList;
|
||||||
unsigned long flags;
|
uint32_t flags;
|
||||||
const char* description;
|
const char* description;
|
||||||
} gCommandTable[] = {
|
} gCommandTable[] = {
|
||||||
{ "--- exerciser commands ---", HelpFunc, 0, "", 0,
|
{ "--- exerciser commands ---", HelpFunc, 0, "", 0,
|
||||||
|
@ -51,35 +51,35 @@ strcasecmp(const char *str1, const char *str2)
|
|||||||
typedef struct ImgHeader {
|
typedef struct ImgHeader {
|
||||||
char magic[4];
|
char magic[4];
|
||||||
char creator[4];
|
char creator[4];
|
||||||
short headerLen;
|
uint16_t headerLen;
|
||||||
short version;
|
uint16_t version;
|
||||||
long imageFormat;
|
uint32_t imageFormat;
|
||||||
unsigned long flags;
|
uint32_t flags;
|
||||||
long numBlocks;
|
uint32_t numBlocks;
|
||||||
long dataOffset;
|
uint32_t dataOffset;
|
||||||
long dataLen;
|
uint32_t dataLen;
|
||||||
long cmntOffset;
|
uint32_t cmntOffset;
|
||||||
long cmntLen;
|
uint32_t cmntLen;
|
||||||
long creatorOffset;
|
uint32_t creatorOffset;
|
||||||
long creatorLen;
|
uint32_t creatorLen;
|
||||||
long spare[4];
|
uint32_t spare[4];
|
||||||
} ImgHeader;
|
} ImgHeader;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read a two-byte little-endian value.
|
* Read a two-byte little-endian value.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ReadShortLE(FILE* fp, short* pBuf)
|
ReadShortLE(FILE* fp, uint16_t* pBuf)
|
||||||
{
|
{
|
||||||
*pBuf = getc(fp);
|
*pBuf = getc(fp);
|
||||||
*pBuf += (short) getc(fp) << 8;
|
*pBuf += (uint16_t) getc(fp) << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write a two-byte little-endian value.
|
* Write a two-byte little-endian value.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
WriteShortLE(FILE* fp, unsigned short val)
|
WriteShortLE(FILE* fp, uint16_t val)
|
||||||
{
|
{
|
||||||
putc(val, fp);
|
putc(val, fp);
|
||||||
putc(val >> 8, fp);
|
putc(val >> 8, fp);
|
||||||
@ -89,19 +89,19 @@ WriteShortLE(FILE* fp, unsigned short val)
|
|||||||
* Read a four-byte little-endian value.
|
* Read a four-byte little-endian value.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ReadLongLE(FILE* fp, long* pBuf)
|
ReadLongLE(FILE* fp, uint32_t* pBuf)
|
||||||
{
|
{
|
||||||
*pBuf = getc(fp);
|
*pBuf = getc(fp);
|
||||||
*pBuf += (long) getc(fp) << 8;
|
*pBuf += (uint32_t) getc(fp) << 8;
|
||||||
*pBuf += (long) getc(fp) << 16;
|
*pBuf += (uint32_t) getc(fp) << 16;
|
||||||
*pBuf += (long) getc(fp) << 24;
|
*pBuf += (uint32_t) getc(fp) << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write a four-byte little-endian value.
|
* Write a four-byte little-endian value.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
WriteLongLE(FILE* fp, unsigned long val)
|
WriteLongLE(FILE* fp, uint32_t val)
|
||||||
{
|
{
|
||||||
putc(val, fp);
|
putc(val, fp);
|
||||||
putc(val >> 8, fp);
|
putc(val >> 8, fp);
|
||||||
@ -121,7 +121,7 @@ ReadImgHeader(FILE* fp, ImgHeader* pHeader)
|
|||||||
ReadShortLE(fp, &pHeader->headerLen);
|
ReadShortLE(fp, &pHeader->headerLen);
|
||||||
ReadShortLE(fp, &pHeader->version);
|
ReadShortLE(fp, &pHeader->version);
|
||||||
ReadLongLE(fp, &pHeader->imageFormat);
|
ReadLongLE(fp, &pHeader->imageFormat);
|
||||||
ReadLongLE(fp, (long*)&pHeader->flags);
|
ReadLongLE(fp, &pHeader->flags);
|
||||||
ReadLongLE(fp, &pHeader->numBlocks);
|
ReadLongLE(fp, &pHeader->numBlocks);
|
||||||
ReadLongLE(fp, &pHeader->dataOffset);
|
ReadLongLE(fp, &pHeader->dataOffset);
|
||||||
ReadLongLE(fp, &pHeader->dataLen);
|
ReadLongLE(fp, &pHeader->dataLen);
|
||||||
@ -193,15 +193,15 @@ DumpImgHeader(ImgHeader* pHeader)
|
|||||||
printf("\tcreator = '%.4s'\n", pHeader->creator);
|
printf("\tcreator = '%.4s'\n", pHeader->creator);
|
||||||
printf("\theaderLen = %d\n", pHeader->headerLen);
|
printf("\theaderLen = %d\n", pHeader->headerLen);
|
||||||
printf("\tversion = %d\n", pHeader->version);
|
printf("\tversion = %d\n", pHeader->version);
|
||||||
printf("\timageFormat = %ld\n", pHeader->imageFormat);
|
printf("\timageFormat = %u\n", pHeader->imageFormat);
|
||||||
printf("\tflags = 0x%08lx\n", pHeader->flags);
|
printf("\tflags = 0x%08x\n", pHeader->flags);
|
||||||
printf("\tnumBlocks = %ld\n", pHeader->numBlocks);
|
printf("\tnumBlocks = %u\n", pHeader->numBlocks);
|
||||||
printf("\tdataOffset = %ld\n", pHeader->dataOffset);
|
printf("\tdataOffset = %u\n", pHeader->dataOffset);
|
||||||
printf("\tdataLen = %ld\n", pHeader->dataLen);
|
printf("\tdataLen = %u\n", pHeader->dataLen);
|
||||||
printf("\tcmntOffset = %ld\n", pHeader->cmntOffset);
|
printf("\tcmntOffset = %u\n", pHeader->cmntOffset);
|
||||||
printf("\tcmntLen = %ld\n", pHeader->cmntLen);
|
printf("\tcmntLen = %u\n", pHeader->cmntLen);
|
||||||
printf("\tcreatorOffset = %ld\n", pHeader->creatorOffset);
|
printf("\tcreatorOffset = %u\n", pHeader->creatorOffset);
|
||||||
printf("\tcreatorLen = %ld\n", pHeader->creatorLen);
|
printf("\tcreatorLen = %u\n", pHeader->creatorLen);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ CreateDosSource(const ImgHeader* pHeader, FILE* fp,
|
|||||||
|
|
||||||
if (pHeader->dataLen % 4096) {
|
if (pHeader->dataLen % 4096) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: image size must be multiple of 4096 (%ld isn't)\n",
|
"ERROR: image size must be multiple of 4096 (%u isn't)\n",
|
||||||
pHeader->dataLen);
|
pHeader->dataLen);
|
||||||
err = kNuErrGeneric;
|
err = kNuErrGeneric;
|
||||||
goto bail;
|
goto bail;
|
||||||
@ -278,7 +278,7 @@ CreateDosSource(const ImgHeader* pHeader, FILE* fp,
|
|||||||
|
|
||||||
diskBuffer = malloc(pHeader->dataLen);
|
diskBuffer = malloc(pHeader->dataLen);
|
||||||
if (diskBuffer == NULL) {
|
if (diskBuffer == NULL) {
|
||||||
fprintf(stderr, "ERROR: malloc(%ld) failed\n", pHeader->dataLen);
|
fprintf(stderr, "ERROR: malloc(%u) failed\n", pHeader->dataLen);
|
||||||
err = kNuErrMalloc;
|
err = kNuErrMalloc;
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ CreateDosSource(const ImgHeader* pHeader, FILE* fp,
|
|||||||
* "true", so NufxLib will free the buffer for us.
|
* "true", so NufxLib will free the buffer for us.
|
||||||
*/
|
*/
|
||||||
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, 0,
|
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, 0,
|
||||||
(const unsigned char*) diskBuffer, 0, pHeader->dataLen,
|
(const uint8_t*) diskBuffer, 0, pHeader->dataLen,
|
||||||
FreeCallback, ppDataSource);
|
FreeCallback, ppDataSource);
|
||||||
if (err == kNuErrNone)
|
if (err == kNuErrNone)
|
||||||
diskBuffer = NULL;
|
diskBuffer = NULL;
|
||||||
|
@ -67,7 +67,7 @@ CopyThreadRecompressed(NuArchive* pInArchive, NuArchive* pOutArchive,
|
|||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuDataSource* pDataSource = NULL;
|
NuDataSource* pDataSource = NULL;
|
||||||
NuDataSink* pDataSink = NULL;
|
NuDataSink* pDataSink = NULL;
|
||||||
uchar* buffer = NULL;
|
uint8_t* buffer = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a buffer large enough to hold all the uncompressed data, and
|
* Allocate a buffer large enough to hold all the uncompressed data, and
|
||||||
@ -95,7 +95,7 @@ CopyThreadRecompressed(NuArchive* pInArchive, NuArchive* pOutArchive,
|
|||||||
*/
|
*/
|
||||||
err = NuExtractThread(pInArchive, pThread->threadIdx, pDataSink);
|
err = NuExtractThread(pInArchive, pThread->threadIdx, pDataSink);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to extract thread %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: unable to extract thread %u (err=%d)\n",
|
||||||
pThread->threadIdx, err);
|
pThread->threadIdx, err);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ CopyThreadUncompressed(NuArchive* pInArchive, NuArchive* pOutArchive,
|
|||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuDataSource* pDataSource = NULL;
|
NuDataSource* pDataSource = NULL;
|
||||||
NuDataSink* pDataSink = NULL;
|
NuDataSink* pDataSink = NULL;
|
||||||
uchar* buffer = NULL;
|
uint8_t* buffer = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have some data files that were left uncompressed, perhaps
|
* If we have some data files that were left uncompressed, perhaps
|
||||||
@ -225,7 +225,7 @@ CopyThreadUncompressed(NuArchive* pInArchive, NuArchive* pOutArchive,
|
|||||||
*/
|
*/
|
||||||
err = NuExtractThread(pInArchive, pThread->threadIdx, pDataSink);
|
err = NuExtractThread(pInArchive, pThread->threadIdx, pDataSink);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to extract thread %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: unable to extract thread %u (err=%d)\n",
|
||||||
pThread->threadIdx, err);
|
pThread->threadIdx, err);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ CopyRecord(NuArchive* pInArchive, NuArchive* pOutArchive, long flags,
|
|||||||
*/
|
*/
|
||||||
err = NuGetRecord(pInArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pInArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to get recordIdx %ld\n", recordIdx);
|
fprintf(stderr, "ERROR: unable to get recordIdx %u\n", recordIdx);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ CopyRecord(NuArchive* pInArchive, NuArchive* pOutArchive, long flags,
|
|||||||
|
|
||||||
numThreads = NuRecordGetNumThreads(pRecord);
|
numThreads = NuRecordGetNumThreads(pRecord);
|
||||||
if (!numThreads) {
|
if (!numThreads) {
|
||||||
fprintf(stderr, "WARNING: recordIdx=%ld was empty\n", recordIdx);
|
fprintf(stderr, "WARNING: recordIdx=%u was empty\n", recordIdx);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ int
|
|||||||
Test_AddStuff(NuArchive* pArchive)
|
Test_AddStuff(NuArchive* pArchive)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
uchar* buf = NULL;
|
uint8_t* buf = NULL;
|
||||||
NuDataSource* pDataSource = NULL;
|
NuDataSource* pDataSource = NULL;
|
||||||
NuRecordIdx recordIdx;
|
NuRecordIdx recordIdx;
|
||||||
long status;
|
long status;
|
||||||
@ -237,7 +237,7 @@ Test_AddStuff(NuArchive* pArchive)
|
|||||||
*/
|
*/
|
||||||
printf("... add 'English' record\n");
|
printf("... add 'English' record\n");
|
||||||
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
||||||
0, (const uchar*)testMsg, 0, strlen(testMsg), NULL, &pDataSource);
|
0, (const uint8_t*)testMsg, 0, strlen(testMsg), NULL, &pDataSource);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: 'English' source create failed (err=%d)\n", err);
|
"ERROR: 'English' source create failed (err=%d)\n", err);
|
||||||
@ -386,7 +386,7 @@ Test_Contents(NuArchive* pArchive)
|
|||||||
|
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: couldn't get record index %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: couldn't get record index %u (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ Test_Contents(NuArchive* pArchive)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cc) {
|
if (cc) {
|
||||||
fprintf(stderr, "ERROR: got '%s' for %ld (%ld), not expected\n",
|
fprintf(stderr, "ERROR: got '%s' for %ld (%u), not expected\n",
|
||||||
pRecord->filename, posn, recordIdx);
|
pRecord->filename, posn, recordIdx);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ Test_Extract(NuArchive* pArchive)
|
|||||||
const NuRecord* pRecord;
|
const NuRecord* pRecord;
|
||||||
const NuThread* pThread;
|
const NuThread* pThread;
|
||||||
NuDataSink* pDataSink = NULL;
|
NuDataSink* pDataSink = NULL;
|
||||||
uchar* buf = NULL;
|
uint8_t* buf = NULL;
|
||||||
|
|
||||||
printf("... extracting files\n");
|
printf("... extracting files\n");
|
||||||
|
|
||||||
@ -549,7 +549,7 @@ Test_Extract(NuArchive* pArchive)
|
|||||||
}
|
}
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: couldn't get record index %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: couldn't get record index %u (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -559,14 +559,14 @@ Test_Extract(NuArchive* pArchive)
|
|||||||
pThread = NuGetThread(pRecord, 1);
|
pThread = NuGetThread(pRecord, 1);
|
||||||
assert(pThread != NULL);
|
assert(pThread != NULL);
|
||||||
if (NuGetThreadID(pThread) != kNuThreadIDDataFork) {
|
if (NuGetThreadID(pThread) != kNuThreadIDDataFork) {
|
||||||
fprintf(stderr, "ERROR: 'bytes' had unexpected threadID 0x%08lx\n",
|
fprintf(stderr, "ERROR: 'bytes' had unexpected threadID 0x%08x\n",
|
||||||
NuGetThreadID(pThread));
|
NuGetThreadID(pThread));
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = malloc(pThread->actualThreadEOF);
|
buf = malloc(pThread->actualThreadEOF);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "ERROR: malloc(%ld) failed\n",pThread->actualThreadEOF);
|
fprintf(stderr, "ERROR: malloc(%u) failed\n",pThread->actualThreadEOF);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ Test_Extract(NuArchive* pArchive)
|
|||||||
}
|
}
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: couldn't get record index %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: couldn't get record index %u (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -658,14 +658,14 @@ Test_Extract(NuArchive* pArchive)
|
|||||||
pThread = NuGetThread(pRecord, 1);
|
pThread = NuGetThread(pRecord, 1);
|
||||||
assert(pThread != NULL);
|
assert(pThread != NULL);
|
||||||
if (NuGetThreadID(pThread) != kNuThreadIDDataFork) {
|
if (NuGetThreadID(pThread) != kNuThreadIDDataFork) {
|
||||||
fprintf(stderr, "ERROR: 'English' had unexpected threadID 0x%08lx\n",
|
fprintf(stderr, "ERROR: 'English' had unexpected threadID 0x%08x\n",
|
||||||
NuGetThreadID(pThread));
|
NuGetThreadID(pThread));
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = malloc(pThread->actualThreadEOF);
|
buf = malloc(pThread->actualThreadEOF);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "ERROR: malloc(%ld) failed\n",pThread->actualThreadEOF);
|
fprintf(stderr, "ERROR: malloc(%u) failed\n", pThread->actualThreadEOF);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,7 +727,7 @@ Test_Extract(NuArchive* pArchive)
|
|||||||
}
|
}
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: couldn't get record index %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: couldn't get record index %u (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -737,7 +737,7 @@ Test_Extract(NuArchive* pArchive)
|
|||||||
pThread = NuGetThread(pRecord, 1);
|
pThread = NuGetThread(pRecord, 1);
|
||||||
assert(pThread != NULL);
|
assert(pThread != NULL);
|
||||||
if (NuGetThreadID(pThread) != kNuThreadIDRsrcFork) {
|
if (NuGetThreadID(pThread) != kNuThreadIDRsrcFork) {
|
||||||
fprintf(stderr, "ERROR: 'Long' had unexpected threadID 0x%08lx\n",
|
fprintf(stderr, "ERROR: 'Long' had unexpected threadID 0x%08x\n",
|
||||||
NuGetThreadID(pThread));
|
NuGetThreadID(pThread));
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -802,7 +802,7 @@ Test_Delete(NuArchive* pArchive)
|
|||||||
}
|
}
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: couldn't get record index %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: couldn't get record index %u (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -816,7 +816,7 @@ Test_Delete(NuArchive* pArchive)
|
|||||||
err = NuDeleteThread(pArchive, pThread->threadIdx);
|
err = NuDeleteThread(pArchive, pThread->threadIdx);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: couldn't delete thread #%d (%ld) (err=%d)\n",
|
"ERROR: couldn't delete thread #%d (%u) (err=%d)\n",
|
||||||
idx, recordIdx, err);
|
idx, recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -828,7 +828,7 @@ Test_Delete(NuArchive* pArchive)
|
|||||||
err = NuDeleteThread(pArchive, pThread->threadIdx);
|
err = NuDeleteThread(pArchive, pThread->threadIdx);
|
||||||
FAIL_BAD;
|
FAIL_BAD;
|
||||||
if (err == kNuErrNone) {
|
if (err == kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: allowed to re-delete thread (%ld) (err=%d)\n",
|
fprintf(stderr, "ERROR: allowed to re-delete thread (%u) (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -839,7 +839,7 @@ Test_Delete(NuArchive* pArchive)
|
|||||||
FAIL_BAD;
|
FAIL_BAD;
|
||||||
if (err == kNuErrNone) {
|
if (err == kNuErrNone) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: able to delete modified record (%ld) (err=%d)\n",
|
"ERROR: able to delete modified record (%u) (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -847,7 +847,7 @@ Test_Delete(NuArchive* pArchive)
|
|||||||
/*
|
/*
|
||||||
* Make sure the attr hasn't been updated yet.
|
* Make sure the attr hasn't been updated yet.
|
||||||
*/
|
*/
|
||||||
err = NuGetAttr(pArchive, kNuAttrNumRecords, (unsigned long*) &count);
|
err = NuGetAttr(pArchive, kNuAttrNumRecords, (uint32_t*) &count);
|
||||||
if (count != kNumEntries) {
|
if (count != kNumEntries) {
|
||||||
fprintf(stderr, "ERROR: kNuAttrNumRecords %ld vs %d\n",
|
fprintf(stderr, "ERROR: kNuAttrNumRecords %ld vs %d\n",
|
||||||
count, kNumEntries);
|
count, kNumEntries);
|
||||||
@ -864,7 +864,7 @@ Test_Delete(NuArchive* pArchive)
|
|||||||
}
|
}
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: couldn't get record index %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: couldn't get record index %u (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -876,7 +876,7 @@ Test_Delete(NuArchive* pArchive)
|
|||||||
|
|
||||||
err = NuDeleteRecord(pArchive, recordIdx);
|
err = NuDeleteRecord(pArchive, recordIdx);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to delete record #%d (%ld) (err=%d)\n",
|
fprintf(stderr, "ERROR: unable to delete record #%d (%u) (err=%d)\n",
|
||||||
kNumEntries-1, recordIdx, err);
|
kNumEntries-1, recordIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -887,7 +887,7 @@ Test_Delete(NuArchive* pArchive)
|
|||||||
FAIL_BAD;
|
FAIL_BAD;
|
||||||
if (err == kNuErrNone) {
|
if (err == kNuErrNone) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: allowed to delete from deleted (%ld) (err=%d)\n",
|
"ERROR: allowed to delete from deleted (%u) (err=%d)\n",
|
||||||
pThread->threadIdx, err);
|
pThread->threadIdx, err);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -915,8 +915,8 @@ Test_MasterCount(NuArchive* pArchive, long expected)
|
|||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMasterHeader->mhTotalRecords != (ulong)expected) {
|
if (pMasterHeader->mhTotalRecords != (uint32_t)expected) {
|
||||||
fprintf(stderr, "ERROR: unexpected MH count (%ld vs %ld)\n",
|
fprintf(stderr, "ERROR: unexpected MH count (%u vs %ld)\n",
|
||||||
pMasterHeader->mhTotalRecords, expected);
|
pMasterHeader->mhTotalRecords, expected);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -235,14 +235,14 @@ ArchiveData_DumpContents(const ArchiveData* pArcData)
|
|||||||
const NuThread* pThread;
|
const NuThread* pThread;
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
printf("%5ld '%s'\n",
|
printf("%5u '%s'\n",
|
||||||
ArchiveRecord_GetRecordIdx(pArcRec),
|
ArchiveRecord_GetRecordIdx(pArcRec),
|
||||||
ArchiveRecord_GetFilename(pArcRec));
|
ArchiveRecord_GetFilename(pArcRec));
|
||||||
|
|
||||||
count = ArchiveRecord_GetNumThreads(pArcRec);
|
count = ArchiveRecord_GetNumThreads(pArcRec);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
pThread = ArchiveRecord_GetThread(pArcRec, i);
|
pThread = ArchiveRecord_GetThread(pArcRec, i);
|
||||||
printf(" %5ld 0x%04x 0x%04x\n", pThread->threadIdx,
|
printf(" %5u 0x%04x 0x%04x\n", pThread->threadIdx,
|
||||||
pThread->thThreadClass, pThread->thThreadKind);
|
pThread->thThreadClass, pThread->thThreadKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,9 +369,9 @@ NuError
|
|||||||
ExtractToBuffer(NuArchive* pArchive, ArchiveData* pArchiveData)
|
ExtractToBuffer(NuArchive* pArchive, ArchiveData* pArchiveData)
|
||||||
{
|
{
|
||||||
NuError err;
|
NuError err;
|
||||||
unsigned char buffer[kHappySize];
|
uint8_t buffer[kHappySize];
|
||||||
NuDataSink* pDataSink = NULL;
|
NuDataSink* pDataSink = NULL;
|
||||||
unsigned long count;
|
uint32_t count;
|
||||||
|
|
||||||
err = NuCreateDataSinkForBuffer(true, kNuConvertOff, buffer, kHappySize,
|
err = NuCreateDataSinkForBuffer(true, kNuConvertOff, buffer, kHappySize,
|
||||||
&pDataSink);
|
&pDataSink);
|
||||||
@ -391,7 +391,7 @@ ExtractToBuffer(NuArchive* pArchive, ArchiveData* pArchiveData)
|
|||||||
FILE* fp;
|
FILE* fp;
|
||||||
if ((fp = fopen("out.buf", kNuFileOpenWriteTrunc)) != NULL) {
|
if ((fp = fopen("out.buf", kNuFileOpenWriteTrunc)) != NULL) {
|
||||||
|
|
||||||
printf("*** Writing %ld bytes\n", count);
|
printf("*** Writing %u bytes\n", count);
|
||||||
if (fwrite(buffer, count, 1, fp) != 1)
|
if (fwrite(buffer, count, 1, fp) != 1)
|
||||||
err = kNuErrFileWrite;
|
err = kNuErrFileWrite;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -29,8 +29,8 @@ const int kMaxHeldLen = 1024 * 1024;
|
|||||||
* A list of CRCs.
|
* A list of CRCs.
|
||||||
*/
|
*/
|
||||||
typedef struct CRCList {
|
typedef struct CRCList {
|
||||||
int numEntries;
|
int numEntries;
|
||||||
unsigned short* entries;
|
uint16_t* entries;
|
||||||
} CRCList;
|
} CRCList;
|
||||||
|
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ GatherCRCs(NuArchive* pArchive)
|
|||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
const NuMasterHeader* pMasterHeader;
|
const NuMasterHeader* pMasterHeader;
|
||||||
CRCList* pCRCList = NULL;
|
CRCList* pCRCList = NULL;
|
||||||
unsigned short* pEntries = NULL;
|
uint16_t* pEntries = NULL;
|
||||||
long recCount, maxCRCs;
|
long recCount, maxCRCs;
|
||||||
long recIdx, crcIdx;
|
long recIdx, crcIdx;
|
||||||
int i;
|
int i;
|
||||||
@ -178,12 +178,12 @@ GatherCRCs(NuArchive* pArchive)
|
|||||||
|
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to get recordIdx %ld\n", recordIdx);
|
fprintf(stderr, "ERROR: unable to get recordIdx %u\n", recordIdx);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NuRecordGetNumThreads(pRecord) == 0) {
|
if (NuRecordGetNumThreads(pRecord) == 0) {
|
||||||
fprintf(stderr, "ERROR: not expecting empty record (%ld)!\n",
|
fprintf(stderr, "ERROR: not expecting empty record (%u)!\n",
|
||||||
recordIdx);
|
recordIdx);
|
||||||
err = kNuErrGeneric;
|
err = kNuErrGeneric;
|
||||||
goto bail;
|
goto bail;
|
||||||
@ -281,7 +281,7 @@ RecompressThread(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
NuDataSource* pDataSource = NULL;
|
NuDataSource* pDataSource = NULL;
|
||||||
NuDataSink* pDataSink = NULL;
|
NuDataSink* pDataSink = NULL;
|
||||||
unsigned char* buf = NULL;
|
uint8_t* buf = NULL;
|
||||||
|
|
||||||
if (pThread->actualThreadEOF == 0) {
|
if (pThread->actualThreadEOF == 0) {
|
||||||
buf = malloc(1);
|
buf = malloc(1);
|
||||||
@ -296,7 +296,7 @@ RecompressThread(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
*/
|
*/
|
||||||
buf = malloc(pThread->actualThreadEOF);
|
buf = malloc(pThread->actualThreadEOF);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "ERROR: failed allocating %ld bytes\n",
|
fprintf(stderr, "ERROR: failed allocating %u bytes\n",
|
||||||
pThread->actualThreadEOF);
|
pThread->actualThreadEOF);
|
||||||
err = kNuErrGeneric;
|
err = kNuErrGeneric;
|
||||||
goto bail;
|
goto bail;
|
||||||
@ -314,7 +314,7 @@ RecompressThread(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
*/
|
*/
|
||||||
err = NuExtractThread(pArchive, pThread->threadIdx, pDataSink);
|
err = NuExtractThread(pArchive, pThread->threadIdx, pDataSink);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: failed extracting thread %ld in '%s': %s\n",
|
fprintf(stderr, "ERROR: failed extracting thread %u in '%s': %s\n",
|
||||||
pThread->threadIdx, pRecord->filename, NuStrError(err));
|
pThread->threadIdx, pRecord->filename, NuStrError(err));
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -325,7 +325,7 @@ RecompressThread(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
*/
|
*/
|
||||||
err = NuDeleteThread(pArchive, pThread->threadIdx);
|
err = NuDeleteThread(pArchive, pThread->threadIdx);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to delete thread %ld\n",
|
fprintf(stderr, "ERROR: unable to delete thread %u\n",
|
||||||
pThread->threadIdx);
|
pThread->threadIdx);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ RecompressThread(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
err = NuAddThread(pArchive, pRecord->recordIdx, NuGetThreadID(pThread),
|
err = NuAddThread(pArchive, pRecord->recordIdx, NuGetThreadID(pThread),
|
||||||
pDataSource, NULL);
|
pDataSource, NULL);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to add new thread ID=0x%08lx (err=%d)\n",
|
fprintf(stderr, "ERROR: unable to add new thread ID=0x%08x (err=%d)\n",
|
||||||
NuGetThreadID(pThread), err);
|
NuGetThreadID(pThread), err);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -375,13 +375,13 @@ RecompressRecord(NuArchive* pArchive, NuRecordIdx recordIdx, long* pLen)
|
|||||||
const NuThread* pThread;
|
const NuThread* pThread;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
printf(" Recompressing %ld\n", recordIdx);
|
printf(" Recompressing %u\n", recordIdx);
|
||||||
|
|
||||||
*pLen = 0;
|
*pLen = 0;
|
||||||
|
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to get record %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: unable to get record %u (err=%d)\n",
|
||||||
recordIdx, err);
|
recordIdx, err);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -393,8 +393,8 @@ RecompressRecord(NuArchive* pArchive, NuRecordIdx recordIdx, long* pLen)
|
|||||||
NuGetThreadID(pThread));*/
|
NuGetThreadID(pThread));*/
|
||||||
err = RecompressThread(pArchive, pRecord, pThread);
|
err = RecompressThread(pArchive, pRecord, pThread);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: failed recompressing thread %ld "
|
fprintf(stderr, "ERROR: failed recompressing thread %u "
|
||||||
" in record %ld (err=%d)\n",
|
" in record %u (err=%d)\n",
|
||||||
pThread->threadIdx, pRecord->recordIdx, err);
|
pThread->threadIdx, pRecord->recordIdx, err);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -423,12 +423,12 @@ RecompressArchive(NuArchive* pArchive, NuValue compression)
|
|||||||
|
|
||||||
err = NuSetValue(pArchive, kNuValueDataCompression, compression);
|
err = NuSetValue(pArchive, kNuValueDataCompression, compression);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to set compression to %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: unable to set compression to %u (err=%d)\n",
|
||||||
compression, err);
|
compression, err);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Recompressing threads with compression type %ld\n", compression);
|
printf("Recompressing threads with compression type %u\n", compression);
|
||||||
|
|
||||||
err = NuGetAttr(pArchive, kNuAttrNumRecords, &countAttr);
|
err = NuGetAttr(pArchive, kNuAttrNumRecords, &countAttr);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
@ -447,7 +447,7 @@ RecompressArchive(NuArchive* pArchive, NuValue compression)
|
|||||||
*/
|
*/
|
||||||
pIndices = malloc(countAttr * sizeof(*pIndices));
|
pIndices = malloc(countAttr * sizeof(*pIndices));
|
||||||
if (pIndices == NULL) {
|
if (pIndices == NULL) {
|
||||||
fprintf(stderr, "ERROR: malloc on %ld indices failed\n", countAttr);
|
fprintf(stderr, "ERROR: malloc on %u indices failed\n", countAttr);
|
||||||
err = kNuErrGeneric;
|
err = kNuErrGeneric;
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -470,7 +470,7 @@ RecompressArchive(NuArchive* pArchive, NuValue compression)
|
|||||||
|
|
||||||
err = RecompressRecord(pArchive, pIndices[idx], &recHeldLen);
|
err = RecompressRecord(pArchive, pIndices[idx], &recHeldLen);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: failed recompressing record %ld (err=%d)\n",
|
fprintf(stderr, "ERROR: failed recompressing record %u (err=%d)\n",
|
||||||
pIndices[idx], err);
|
pIndices[idx], err);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
@ -272,9 +272,9 @@ SelectionFilter(NuArchive* pArchive, void* vproposal)
|
|||||||
* Print a three-digit progress percentage; range is 0% to 100%.
|
* Print a three-digit progress percentage; range is 0% to 100%.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
PrintPercentage(ulong total, ulong progress)
|
PrintPercentage(uint32_t total, uint32_t progress)
|
||||||
{
|
{
|
||||||
ulong perc;
|
uint32_t perc;
|
||||||
|
|
||||||
if (!total) {
|
if (!total) {
|
||||||
/*printf(" %%");*/
|
/*printf(" %%");*/
|
||||||
@ -292,7 +292,7 @@ PrintPercentage(ulong total, ulong progress)
|
|||||||
perc = 100;
|
perc = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%3ld%%", perc);
|
printf("%3d%%", perc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -125,37 +125,37 @@ typedef struct BNYArchive {
|
|||||||
* something else follows this entry.
|
* something else follows this entry.
|
||||||
*/
|
*/
|
||||||
typedef struct BNYEntry {
|
typedef struct BNYEntry {
|
||||||
ushort access;
|
uint16_t access;
|
||||||
ushort fileType;
|
uint16_t fileType;
|
||||||
ulong auxType;
|
uint32_t auxType;
|
||||||
uchar storageType;
|
uint8_t storageType;
|
||||||
ulong fileSize; /* in 512-byte blocks */
|
uint32_t fileSize; /* in 512-byte blocks */
|
||||||
ushort prodosModDate;
|
uint16_t prodosModDate;
|
||||||
ushort prodosModTime;
|
uint16_t prodosModTime;
|
||||||
NuDateTime modWhen; /* computed from previous two fields */
|
NuDateTime modWhen; /* computed from previous two fields */
|
||||||
ushort prodosCreateDate;
|
uint16_t prodosCreateDate;
|
||||||
ushort prodosCreateTime;
|
uint16_t prodosCreateTime;
|
||||||
NuDateTime createWhen; /* computed from previous two fields */
|
NuDateTime createWhen; /* computed from previous two fields */
|
||||||
ulong eof;
|
uint32_t eof;
|
||||||
ulong realEOF; /* eof is bogus for directories */
|
uint32_t realEOF; /* eof is bogus for directories */
|
||||||
char fileName[kBNYMaxFileName+1];
|
char fileName[kBNYMaxFileName+1];
|
||||||
char nativeName[kBNYMaxNativeName+1];
|
char nativeName[kBNYMaxNativeName+1];
|
||||||
ulong diskSpace; /* in 512-byte blocks */
|
uint32_t diskSpace; /* in 512-byte blocks */
|
||||||
uchar osType; /* not exactly same as NuFileSysID */
|
uint8_t osType; /* not exactly same as NuFileSysID */
|
||||||
ushort nativeFileType;
|
uint16_t nativeFileType;
|
||||||
uchar phantomFlag;
|
uint8_t phantomFlag;
|
||||||
uchar dataFlags; /* advisory flags */
|
uint8_t dataFlags; /* advisory flags */
|
||||||
uchar version;
|
uint8_t version;
|
||||||
uchar filesToFollow; /* #of files after this one */
|
uint8_t filesToFollow; /* #of files after this one */
|
||||||
|
|
||||||
uchar blockBuf[kBNYBlockSize];
|
uint8_t blockBuf[kBNYBlockSize];
|
||||||
} BNYEntry;
|
} BNYEntry;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test for the magic number on a file in SQueezed format.
|
* Test for the magic number on a file in SQueezed format.
|
||||||
*/
|
*/
|
||||||
static inline Boolean
|
static inline Boolean
|
||||||
IsSqueezed(uchar one, uchar two)
|
IsSqueezed(uint8_t one, uint8_t two)
|
||||||
{
|
{
|
||||||
return (one == 0x76 && two == 0xff);
|
return (one == 0x76 && two == 0xff);
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ BNYSeek(BNYArchive* pBny, long offset)
|
|||||||
* Convert from ProDOS compact date format to the expanded DateTime format.
|
* Convert from ProDOS compact date format to the expanded DateTime format.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
BNYConvertDateTime(ushort prodosDate, ushort prodosTime, NuDateTime* pWhen)
|
BNYConvertDateTime(uint16_t prodosDate, uint16_t prodosTime, NuDateTime* pWhen)
|
||||||
{
|
{
|
||||||
pWhen->second = 0;
|
pWhen->second = 0;
|
||||||
pWhen->minute = prodosTime & 0x3f;
|
pWhen->minute = prodosTime & 0x3f;
|
||||||
@ -324,7 +324,7 @@ static NuError
|
|||||||
BNYDecodeHeader(BNYArchive* pBny, BNYEntry* pEntry)
|
BNYDecodeHeader(BNYArchive* pBny, BNYEntry* pEntry)
|
||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
uchar* raw;
|
uint8_t* raw;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
Assert(pBny != NULL);
|
Assert(pBny != NULL);
|
||||||
@ -522,8 +522,8 @@ bail:
|
|||||||
* State during uncompression.
|
* State during uncompression.
|
||||||
*/
|
*/
|
||||||
typedef struct USQState {
|
typedef struct USQState {
|
||||||
ulong dataInBuffer;
|
uint32_t dataInBuffer;
|
||||||
uchar* dataPtr;
|
uint8_t* dataPtr;
|
||||||
int bitPosn;
|
int bitPosn;
|
||||||
int bits;
|
int bits;
|
||||||
|
|
||||||
@ -603,14 +603,14 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
|
|||||||
{
|
{
|
||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
USQState usqState;
|
USQState usqState;
|
||||||
ulong compRemaining, getSize;
|
uint32_t compRemaining, getSize;
|
||||||
#ifdef FULL_SQ_HEADER
|
#ifdef FULL_SQ_HEADER
|
||||||
ushort magic, fileChecksum, checksum;
|
uint16_t magic, fileChecksum, checksum;
|
||||||
#endif
|
#endif
|
||||||
short nodeCount;
|
short nodeCount;
|
||||||
int i, inrep;
|
int i, inrep;
|
||||||
uchar* tmpBuf = NULL;
|
uint8_t* tmpBuf = NULL;
|
||||||
uchar lastc = 0;
|
uint8_t lastc = 0;
|
||||||
|
|
||||||
tmpBuf = Malloc(kSqBufferSize);
|
tmpBuf = Malloc(kSqBufferSize);
|
||||||
if (tmpBuf == NULL) {
|
if (tmpBuf == NULL) {
|
||||||
@ -677,7 +677,7 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
|
|||||||
err = BNYRead(pBny, usqState.dataPtr, getSize);
|
err = BNYRead(pBny, usqState.dataPtr, getSize);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
ReportError(err,
|
ReportError(err,
|
||||||
"failed reading compressed data (%ld bytes)", getSize);
|
"failed reading compressed data (%u bytes)", getSize);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
usqState.dataInBuffer += getSize;
|
usqState.dataInBuffer += getSize;
|
||||||
@ -787,7 +787,7 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
|
|||||||
getSize);
|
getSize);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
ReportError(err,
|
ReportError(err,
|
||||||
"failed reading compressed data (%ld bytes)", getSize);
|
"failed reading compressed data (%u bytes)", getSize);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
usqState.dataInBuffer += getSize;
|
usqState.dataInBuffer += getSize;
|
||||||
@ -876,7 +876,7 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
|
|||||||
*/
|
*/
|
||||||
if (compRemaining > kSqBufferSize) {
|
if (compRemaining > kSqBufferSize) {
|
||||||
err = kNuErrBadData;
|
err = kNuErrBadData;
|
||||||
ReportError(err, "wow: found %ld bytes left over", compRemaining);
|
ReportError(err, "wow: found %u bytes left over", compRemaining);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
if (compRemaining) {
|
if (compRemaining) {
|
||||||
@ -1077,7 +1077,7 @@ BNYListVerbose(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag)
|
|||||||
printf("%c..%-25.25s ",
|
printf("%c..%-25.25s ",
|
||||||
isReadOnly ? '+' : ' ', pEntry->fileName + len - 25);
|
isReadOnly ? '+' : ' ', pEntry->fileName + len - 25);
|
||||||
}
|
}
|
||||||
printf("%s $%04lX ",
|
printf("%s $%04X ",
|
||||||
GetFileTypeString(pEntry->fileType), pEntry->auxType);
|
GetFileTypeString(pEntry->fileType), pEntry->auxType);
|
||||||
|
|
||||||
printf("%s ", FormatDateShort(&pEntry->modWhen, date1));
|
printf("%s ", FormatDateShort(&pEntry->modWhen, date1));
|
||||||
@ -1086,7 +1086,7 @@ BNYListVerbose(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag)
|
|||||||
else
|
else
|
||||||
printf("unc ");
|
printf("unc ");
|
||||||
|
|
||||||
printf("%8ld", pEntry->realEOF);
|
printf("%8u", pEntry->realEOF);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
@ -1123,9 +1123,9 @@ BNYListDebug(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag)
|
|||||||
pEntry->createWhen.year+1900, pEntry->createWhen.month,
|
pEntry->createWhen.year+1900, pEntry->createWhen.month,
|
||||||
pEntry->createWhen.day, pEntry->createWhen.hour,
|
pEntry->createWhen.day, pEntry->createWhen.hour,
|
||||||
pEntry->createWhen.minute);
|
pEntry->createWhen.minute);
|
||||||
printf(" FileType: 0x%04x AuxType: 0x%08lx StorageType: 0x%02x\n",
|
printf(" FileType: 0x%04x AuxType: 0x%08x StorageType: 0x%02x\n",
|
||||||
pEntry->fileType, pEntry->auxType, pEntry->storageType);
|
pEntry->fileType, pEntry->auxType, pEntry->storageType);
|
||||||
printf(" EOF: %ld FileSize: %ld blocks DiskSpace: %ld blocks\n",
|
printf(" EOF: %u FileSize: %u blocks DiskSpace: %u blocks\n",
|
||||||
pEntry->eof, pEntry->fileSize, pEntry->diskSpace);
|
pEntry->eof, pEntry->fileSize, pEntry->diskSpace);
|
||||||
printf(" Access: 0x%04x OSType: %d NativeFileType: 0x%04x\n",
|
printf(" Access: 0x%04x OSType: %d NativeFileType: 0x%04x\n",
|
||||||
pEntry->access, pEntry->osType, pEntry->nativeFileType);
|
pEntry->access, pEntry->osType, pEntry->nativeFileType);
|
||||||
|
@ -41,7 +41,7 @@ ExtractAllRecords(NulibState* pState, NuArchive* pArchive)
|
|||||||
|
|
||||||
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
err = NuGetRecord(pArchive, recordIdx, &pRecord);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
fprintf(stderr, "ERROR: unable to get recordIdx %ld\n", recordIdx);
|
fprintf(stderr, "ERROR: unable to get recordIdx %u\n", recordIdx);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ ExtractAllRecords(NulibState* pState, NuArchive* pArchive)
|
|||||||
/*
|
/*
|
||||||
* Look for a comment thread.
|
* Look for a comment thread.
|
||||||
*/
|
*/
|
||||||
for (threadIdx = 0; (ulong)threadIdx < pRecord->recTotalThreads;
|
for (threadIdx = 0; (uint32_t)threadIdx < pRecord->recTotalThreads;
|
||||||
threadIdx++)
|
threadIdx++)
|
||||||
{
|
{
|
||||||
pThread = NuGetThread(pRecord, threadIdx);
|
pThread = NuGetThread(pRecord, threadIdx);
|
||||||
|
@ -73,9 +73,9 @@ static const char gFileTypeNames[256][4] = {
|
|||||||
*/
|
*/
|
||||||
static const struct {
|
static const struct {
|
||||||
const char* label;
|
const char* label;
|
||||||
ushort fileType;
|
uint16_t fileType;
|
||||||
ulong auxType;
|
uint32_t auxType;
|
||||||
uchar flags;
|
uint8_t unused; // remove?
|
||||||
} gRecognizedExtensions[] = {
|
} gRecognizedExtensions[] = {
|
||||||
{ "ASM", 0xb0, 0x0003, 0 }, /* APW assembly source */
|
{ "ASM", 0xb0, 0x0003, 0 }, /* APW assembly source */
|
||||||
{ "C", 0xb0, 0x000a, 0 }, /* APW C source */
|
{ "C", 0xb0, 0x000a, 0 }, /* APW C source */
|
||||||
@ -96,7 +96,7 @@ static const struct {
|
|||||||
* Return a pointer to the three-letter representation of the file type name.
|
* Return a pointer to the three-letter representation of the file type name.
|
||||||
*/
|
*/
|
||||||
const char*
|
const char*
|
||||||
GetFileTypeString(ulong fileType)
|
GetFileTypeString(uint32_t fileType)
|
||||||
{
|
{
|
||||||
if (fileType < NELEM(gFileTypeNames))
|
if (fileType < NELEM(gFileTypeNames))
|
||||||
return gFileTypeNames[fileType];
|
return gFileTypeNames[fileType];
|
||||||
@ -144,11 +144,11 @@ AddPreservationString(NulibState* pState,
|
|||||||
* return the #of characters written, so we add it up manually.
|
* return the #of characters written, so we add it up manually.
|
||||||
*/
|
*/
|
||||||
if (pRecord->recFileType < 0x100 && pRecord->recExtraType < 0x10000) {
|
if (pRecord->recFileType < 0x100 && pRecord->recExtraType < 0x10000) {
|
||||||
sprintf(cp, "%c%02lx%04lx", kPreserveIndic, pRecord->recFileType,
|
sprintf(cp, "%c%02x%04x", kPreserveIndic, pRecord->recFileType,
|
||||||
pRecord->recExtraType);
|
pRecord->recExtraType);
|
||||||
cp += 7;
|
cp += 7;
|
||||||
} else {
|
} else {
|
||||||
sprintf(cp, "%c%08lx%08lx", kPreserveIndic, pRecord->recFileType,
|
sprintf(cp, "%c%08x%08x", kPreserveIndic, pRecord->recFileType,
|
||||||
pRecord->recExtraType);
|
pRecord->recExtraType);
|
||||||
cp += 17;
|
cp += 17;
|
||||||
}
|
}
|
||||||
@ -358,8 +358,8 @@ bail:
|
|||||||
* like "TXT" and "BIN") and the separate list of recognized extensions.
|
* like "TXT" and "BIN") and the separate list of recognized extensions.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
LookupExtension(NulibState* pState, const char* ext, ulong* pFileType,
|
LookupExtension(NulibState* pState, const char* ext, uint32_t* pFileType,
|
||||||
ulong* pAuxType)
|
uint32_t* pAuxType)
|
||||||
{
|
{
|
||||||
char uext3[4];
|
char uext3[4];
|
||||||
int i, extLen;
|
int i, extLen;
|
||||||
@ -410,8 +410,8 @@ bail:
|
|||||||
* Try to associate some meaning with the file extension.
|
* Try to associate some meaning with the file extension.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
InterpretExtension(NulibState* pState, const char* pathName, ulong* pFileType,
|
InterpretExtension(NulibState* pState, const char* pathName, uint32_t* pFileType,
|
||||||
ulong* pAuxType)
|
uint32_t* pAuxType)
|
||||||
{
|
{
|
||||||
const char* pExt;
|
const char* pExt;
|
||||||
|
|
||||||
@ -435,11 +435,11 @@ InterpretExtension(NulibState* pState, const char* pathName, ulong* pFileType,
|
|||||||
* in the filename.
|
* in the filename.
|
||||||
*/
|
*/
|
||||||
Boolean
|
Boolean
|
||||||
ExtractPreservationString(NulibState* pState, char* pathname, ulong* pFileType,
|
ExtractPreservationString(NulibState* pState, char* pathname, uint32_t* pFileType,
|
||||||
ulong* pAuxType, NuThreadID* pThreadID)
|
uint32_t* pAuxType, NuThreadID* pThreadID)
|
||||||
{
|
{
|
||||||
char numBuf[9];
|
char numBuf[9];
|
||||||
ulong fileType, auxType;
|
uint32_t fileType, auxType;
|
||||||
NuThreadID threadID;
|
NuThreadID threadID;
|
||||||
char* pPreserve;
|
char* pPreserve;
|
||||||
char* cp;
|
char* cp;
|
||||||
|
@ -41,7 +41,7 @@ static const char* gMonths[] = {
|
|||||||
* Compute a percentage.
|
* Compute a percentage.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ComputePercent(ulong totalSize, ulong size)
|
ComputePercent(uint32_t totalSize, uint32_t size)
|
||||||
{
|
{
|
||||||
int perc;
|
int perc;
|
||||||
|
|
||||||
@ -144,11 +144,11 @@ bail:
|
|||||||
*/
|
*/
|
||||||
static NuError
|
static NuError
|
||||||
AnalyzeRecord(const NuRecord* pRecord, enum RecordKind* pRecordKind,
|
AnalyzeRecord(const NuRecord* pRecord, enum RecordKind* pRecordKind,
|
||||||
ushort* pFormat, ulong* pTotalLen, ulong* pTotalCompLen)
|
uint16_t* pFormat, uint32_t* pTotalLen, uint32_t* pTotalCompLen)
|
||||||
{
|
{
|
||||||
const NuThread* pThread;
|
const NuThread* pThread;
|
||||||
NuThreadID threadID;
|
NuThreadID threadID;
|
||||||
ulong idx;
|
uint32_t idx;
|
||||||
|
|
||||||
*pRecordKind = kRecordKindUnknown;
|
*pRecordKind = kRecordKindUnknown;
|
||||||
*pTotalLen = *pTotalCompLen = 0;
|
*pTotalLen = *pTotalCompLen = 0;
|
||||||
@ -194,8 +194,8 @@ ShowContentsVerbose(NuArchive* pArchive, void* vpRecord)
|
|||||||
NuError err = kNuErrNone;
|
NuError err = kNuErrNone;
|
||||||
const NuRecord* pRecord = (NuRecord*) vpRecord;
|
const NuRecord* pRecord = (NuRecord*) vpRecord;
|
||||||
enum RecordKind recordKind;
|
enum RecordKind recordKind;
|
||||||
ulong totalLen, totalCompLen;
|
uint32_t totalLen, totalCompLen;
|
||||||
ushort format;
|
uint16_t format;
|
||||||
NulibState* pState;
|
NulibState* pState;
|
||||||
char date1[kDateOutputLen];
|
char date1[kDateOutputLen];
|
||||||
char tmpbuf[16];
|
char tmpbuf[16];
|
||||||
@ -223,17 +223,17 @@ ShowContentsVerbose(NuArchive* pArchive, void* vpRecord)
|
|||||||
}
|
}
|
||||||
switch (recordKind) {
|
switch (recordKind) {
|
||||||
case kRecordKindUnknown:
|
case kRecordKindUnknown:
|
||||||
printf("%s- $%04lX ",
|
printf("%s- $%04X ",
|
||||||
GetFileTypeString(pRecord->recFileType),
|
GetFileTypeString(pRecord->recFileType),
|
||||||
pRecord->recExtraType);
|
pRecord->recExtraType);
|
||||||
break;
|
break;
|
||||||
case kRecordKindDisk:
|
case kRecordKindDisk:
|
||||||
sprintf(tmpbuf, "%ldk", totalLen / 1024);
|
sprintf(tmpbuf, "%dk", totalLen / 1024);
|
||||||
printf("Disk %-6s ", tmpbuf);
|
printf("Disk %-6s ", tmpbuf);
|
||||||
break;
|
break;
|
||||||
case kRecordKindFile:
|
case kRecordKindFile:
|
||||||
case kRecordKindForkedFile:
|
case kRecordKindForkedFile:
|
||||||
printf("%s%c $%04lX ",
|
printf("%s%c $%04X ",
|
||||||
GetFileTypeString(pRecord->recFileType),
|
GetFileTypeString(pRecord->recFileType),
|
||||||
recordKind == kRecordKindForkedFile ? '+' : ' ',
|
recordKind == kRecordKindForkedFile ? '+' : ' ',
|
||||||
pRecord->recExtraType);
|
pRecord->recExtraType);
|
||||||
@ -262,7 +262,7 @@ ShowContentsVerbose(NuArchive* pArchive, void* vpRecord)
|
|||||||
if (!totalLen && totalCompLen)
|
if (!totalLen && totalCompLen)
|
||||||
printf(" ????"); /* weird */
|
printf(" ????"); /* weird */
|
||||||
else
|
else
|
||||||
printf("%8ld", totalLen);
|
printf("%8u", totalLen);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ DoListVerbose(NulibState* pState)
|
|||||||
if (err != kNuErrNone)
|
if (err != kNuErrNone)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
printf(" %-15.15s Created:%s Mod:%s Recs:%5lu\n\n",
|
printf(" %-15.15s Created:%s Mod:%s Recs:%5u\n\n",
|
||||||
cp,
|
cp,
|
||||||
FormatDateShort(&pHeader->mhArchiveCreateWhen, date1),
|
FormatDateShort(&pHeader->mhArchiveCreateWhen, date1),
|
||||||
FormatDateShort(&pHeader->mhArchiveModWhen, date2),
|
FormatDateShort(&pHeader->mhArchiveModWhen, date2),
|
||||||
|
@ -59,7 +59,7 @@ typedef unsigned char Boolean;
|
|||||||
(x) <= '9' ? (x) - '0' : toupper(x) +10 - 'A' )
|
(x) <= '9' ? (x) - '0' : toupper(x) +10 - 'A' )
|
||||||
|
|
||||||
/* convert number from 0-15 to hex digit */
|
/* convert number from 0-15 to hex digit */
|
||||||
#define HexConv(x) ( ((uint)(x)) <= 15 ? \
|
#define HexConv(x) ( ((unsigned int)(x)) <= 15 ? \
|
||||||
( (x) <= 9 ? (x) + '0' : (x) -10 + 'A') : -1 )
|
( (x) <= 9 ? (x) + '0' : (x) -10 + 'A') : -1 )
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ Malloc(size_t size)
|
|||||||
Assert(size > 0);
|
Assert(size > 0);
|
||||||
_result = malloc(size);
|
_result = malloc(size);
|
||||||
if (_result == NULL) {
|
if (_result == NULL) {
|
||||||
ReportError(kNuErrMalloc, "malloc(%u) failed", (uint) size);
|
ReportError(kNuErrMalloc, "malloc(%u) failed", (unsigned int) size);
|
||||||
DebugAbort(); /* leave a core dump if we're built for it */
|
DebugAbort(); /* leave a core dump if we're built for it */
|
||||||
}
|
}
|
||||||
DebugFill(_result, size);
|
DebugFill(_result, size);
|
||||||
@ -94,7 +94,7 @@ Realloc(void* ptr, size_t size)
|
|||||||
Assert(size > 0); /* disallow this usage */
|
Assert(size > 0); /* disallow this usage */
|
||||||
_result = realloc(ptr, size);
|
_result = realloc(ptr, size);
|
||||||
if (_result == NULL) {
|
if (_result == NULL) {
|
||||||
ReportError(kNuErrMalloc, "realloc(%u) failed", (uint) size);
|
ReportError(kNuErrMalloc, "realloc(%u) failed", (unsigned int) size);
|
||||||
DebugAbort(); /* leave a core dump if we're built for it */
|
DebugAbort(); /* leave a core dump if we're built for it */
|
||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
|
@ -42,7 +42,7 @@ Boolean IsFilenameStdin(const char* archiveName);
|
|||||||
Boolean IsSpecified(NulibState* pState, const NuRecord* pRecord);
|
Boolean IsSpecified(NulibState* pState, const NuRecord* pRecord);
|
||||||
NuError OpenArchiveReadOnly(NulibState* pState);
|
NuError OpenArchiveReadOnly(NulibState* pState);
|
||||||
NuError OpenArchiveReadWrite(NulibState* pState);
|
NuError OpenArchiveReadWrite(NulibState* pState);
|
||||||
const NuThread* GetThread(const NuRecord* pRecord, ulong idx);
|
const NuThread* GetThread(const NuRecord* pRecord, uint32_t idx);
|
||||||
Boolean IsRecordReadOnly(const NuRecord* pRecord);
|
Boolean IsRecordReadOnly(const NuRecord* pRecord);
|
||||||
|
|
||||||
/* Binary2.c */
|
/* Binary2.c */
|
||||||
@ -61,12 +61,12 @@ NuError DoExtractToPipe(NulibState* pState);
|
|||||||
NuError DoTest(NulibState* pState);
|
NuError DoTest(NulibState* pState);
|
||||||
|
|
||||||
/* Filename.c */
|
/* Filename.c */
|
||||||
const char* GetFileTypeString(ulong fileType);
|
const char* GetFileTypeString(uint32_t fileType);
|
||||||
const char* NormalizePath(NulibState* pState, NuPathnameProposal* pathProposal);
|
const char* NormalizePath(NulibState* pState, NuPathnameProposal* pathProposal);
|
||||||
void InterpretExtension(NulibState* pState, const char* pathName,
|
void InterpretExtension(NulibState* pState, const char* pathName,
|
||||||
ulong* pFileType, ulong* pAuxType);
|
uint32_t* pFileType, uint32_t* pAuxType);
|
||||||
Boolean ExtractPreservationString(NulibState* pState, char* pathname,
|
Boolean ExtractPreservationString(NulibState* pState, char* pathname,
|
||||||
ulong* pFileType, ulong* pAuxType, NuThreadID* pThreadID);
|
uint32_t* pFileType, uint32_t* pAuxType, NuThreadID* pThreadID);
|
||||||
void DenormalizePath(NulibState* pState, char* pathBuf);
|
void DenormalizePath(NulibState* pState, char* pathBuf);
|
||||||
const char* FilenameOnly(NulibState* pState, const char* pathname);
|
const char* FilenameOnly(NulibState* pState, const char* pathname);
|
||||||
const char* FindExtension(NulibState* pState, const char* pathname);
|
const char* FindExtension(NulibState* pState, const char* pathname);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* these should exist everywhere */
|
/* these should exist everywhere */
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -55,10 +56,6 @@
|
|||||||
# define SNPRINTF_DECLARED
|
# define SNPRINTF_DECLARED
|
||||||
# define VSNPRINTF_DECLARED
|
# define VSNPRINTF_DECLARED
|
||||||
# define SPRINTF_RETURNS_INT
|
# define SPRINTF_RETURNS_INT
|
||||||
# define uchar unsigned char
|
|
||||||
# define ushort unsigned short
|
|
||||||
# define uint unsigned int
|
|
||||||
# define ulong unsigned long
|
|
||||||
# define inline /*Visual C++6.0 can't inline ".c" files*/
|
# define inline /*Visual C++6.0 can't inline ".c" files*/
|
||||||
# define mode_t int
|
# define mode_t int
|
||||||
# endif
|
# endif
|
||||||
|
@ -669,7 +669,7 @@ DoAddFile(NulibState* pState, NuArchive* pArchive, const char* pathname,
|
|||||||
NuDataSource* pDataSource;
|
NuDataSource* pDataSource;
|
||||||
|
|
||||||
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
||||||
kDefaultCommentLen, (unsigned char*)comment, 0,
|
kDefaultCommentLen, (uint8_t*)comment, 0,
|
||||||
strlen(comment), FreeCallback, &pDataSource);
|
strlen(comment), FreeCallback, &pDataSource);
|
||||||
if (err != kNuErrNone) {
|
if (err != kNuErrNone) {
|
||||||
ReportError(err, "comment buffer create failed");
|
ReportError(err, "comment buffer create failed");
|
||||||
@ -878,7 +878,7 @@ OpenDir(const char* name)
|
|||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
strcpy(dir->d_name, fnd.cFileName);
|
strcpy(dir->d_name, fnd.cFileName);
|
||||||
dir->d_attr = (uchar) fnd.dwFileAttributes;
|
dir->d_attr = (uint8_t) fnd.dwFileAttributes;
|
||||||
dir->d_first = 1;
|
dir->d_first = 1;
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
@ -907,7 +907,7 @@ ReadDir(Win32dirent* dir)
|
|||||||
if (!FindNextFile(dir->d_hFindFile, &fnd))
|
if (!FindNextFile(dir->d_hFindFile, &fnd))
|
||||||
return NULL;
|
return NULL;
|
||||||
strcpy(dir->d_name, fnd.cFileName);
|
strcpy(dir->d_name, fnd.cFileName);
|
||||||
dir->d_attr = (uchar) fnd.dwFileAttributes;
|
dir->d_attr = (uint8_t) fnd.dwFileAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
|
@ -33,18 +33,6 @@
|
|||||||
/* Define if your <sys/time.h> declares struct tm. */
|
/* Define if your <sys/time.h> declares struct tm. */
|
||||||
#undef TM_IN_SYS_TIME
|
#undef TM_IN_SYS_TIME
|
||||||
|
|
||||||
/* Define to `unsigned char' if <sys/types.h> doesn't define. */
|
|
||||||
#undef uchar
|
|
||||||
|
|
||||||
/* Define to `unsigned short' if <sys/types.h> doesn't define. */
|
|
||||||
#undef ushort
|
|
||||||
|
|
||||||
/* Define to `unsigned int' if <sys/types.h> doesn't define. */
|
|
||||||
#undef uint
|
|
||||||
|
|
||||||
/* Define to `unsigned long' if <sys/types.h> doesn't define. */
|
|
||||||
#undef ulong
|
|
||||||
|
|
||||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||||
#undef mode_t
|
#undef mode_t
|
||||||
|
|
||||||
|
44
nulib2/configure
vendored
44
nulib2/configure
vendored
@ -4001,50 +4001,6 @@ $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "uchar" "ac_cv_type_uchar" "$ac_includes_default"
|
|
||||||
if test "x$ac_cv_type_uchar" = xyes; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define uchar unsigned char
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "ushort" "ac_cv_type_ushort" "$ac_includes_default"
|
|
||||||
if test "x$ac_cv_type_ushort" = xyes; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define ushort unsigned short
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "uint" "ac_cv_type_uint" "$ac_includes_default"
|
|
||||||
if test "x$ac_cv_type_uint" = xyes; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define uint unsigned int
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "ulong" "ac_cv_type_ulong" "$ac_includes_default"
|
|
||||||
if test "x$ac_cv_type_ulong" = xyes; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define ulong unsigned long
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,10 +79,6 @@ AC_TYPE_MODE_T
|
|||||||
AC_TYPE_OFF_T
|
AC_TYPE_OFF_T
|
||||||
AC_TYPE_SIZE_T
|
AC_TYPE_SIZE_T
|
||||||
AC_STRUCT_TM
|
AC_STRUCT_TM
|
||||||
AC_CHECK_TYPE(uchar, unsigned char)
|
|
||||||
AC_CHECK_TYPE(ushort, unsigned short)
|
|
||||||
AC_CHECK_TYPE(uint, unsigned int)
|
|
||||||
AC_CHECK_TYPE(ulong, unsigned long)
|
|
||||||
|
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
dnl AC_FUNC_SETVBUF_REVERSED
|
dnl AC_FUNC_SETVBUF_REVERSED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user