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