diff --git a/nufxlib/Archive.c b/nufxlib/Archive.c index 4dd544c..57a6baa 100644 --- a/nufxlib/Archive.c +++ b/nufxlib/Archive.c @@ -56,7 +56,7 @@ static void Nu_CloseAndFree(NuArchive* pArchive); static NuError Nu_NuArchiveNew(NuArchive** ppArchive) { - Assert(ppArchive != nil); + Assert(ppArchive != NULL); /* validate some assumptions we make throughout the code */ Assert(sizeof(int) >= 2); @@ -64,8 +64,8 @@ Nu_NuArchiveNew(NuArchive** ppArchive) Assert(sizeof(ulong) >= 4); Assert(sizeof(void*) >= sizeof(NuArchive*)); - *ppArchive = Nu_Calloc(nil, sizeof(**ppArchive)); - if (*ppArchive == nil) + *ppArchive = Nu_Calloc(NULL, sizeof(**ppArchive)); + if (*ppArchive == NULL) return kNuErrMalloc; (*ppArchive)->structMagic = kNuArchiveStructMagic; @@ -110,7 +110,7 @@ Nu_NuArchiveNew(NuArchive** ppArchive) static NuError Nu_NuArchiveFree(NuArchive* pArchive) { - Assert(pArchive != nil); + Assert(pArchive != NULL); Assert(pArchive->structMagic == kNuArchiveStructMagic); (void) Nu_RecordSet_FreeAllRecords(pArchive, &pArchive->origRecordSet); @@ -118,15 +118,15 @@ Nu_NuArchiveFree(NuArchive* pArchive) (void) Nu_RecordSet_FreeAllRecords(pArchive, &pArchive->copyRecordSet); (void) Nu_RecordSet_FreeAllRecords(pArchive, &pArchive->newRecordSet); - Nu_Free(nil, pArchive->archivePathname); - Nu_Free(nil, pArchive->tmpPathname); - Nu_Free(nil, pArchive->compBuf); - Nu_Free(nil, pArchive->lzwCompressState); - Nu_Free(nil, pArchive->lzwExpandState); + Nu_Free(NULL, pArchive->archivePathname); + Nu_Free(NULL, pArchive->tmpPathname); + Nu_Free(NULL, pArchive->compBuf); + Nu_Free(NULL, pArchive->lzwCompressState); + Nu_Free(NULL, pArchive->lzwExpandState); /* mark it as deceased to prevent further use, then free it */ pArchive->structMagic = kNuArchiveStructMagic ^ 0xffffffff; - Nu_Free(nil, pArchive); + Nu_Free(NULL, pArchive); return kNuErrNone; } @@ -139,9 +139,9 @@ void Nu_MasterHeaderCopy(NuArchive* pArchive, NuMasterHeader* pDstHeader, const NuMasterHeader* pSrcHeader) { - Assert(pArchive != nil); - Assert(pDstHeader != nil); - Assert(pSrcHeader != nil); + Assert(pArchive != NULL); + Assert(pDstHeader != NULL); + Assert(pSrcHeader != NULL); *pDstHeader = *pSrcHeader; } @@ -152,7 +152,7 @@ Nu_MasterHeaderCopy(NuArchive* pArchive, NuMasterHeader* pDstHeader, NuError Nu_GetMasterHeader(NuArchive* pArchive, const NuMasterHeader** ppMasterHeader) { - if (ppMasterHeader == nil) + if (ppMasterHeader == NULL) return kNuErrInvalidArg; *ppMasterHeader = &pArchive->masterHeader; @@ -167,13 +167,13 @@ Nu_GetMasterHeader(NuArchive* pArchive, const NuMasterHeader** ppMasterHeader) NuError Nu_AllocCompressionBufferIFN(NuArchive* pArchive) { - Assert(pArchive != nil); + Assert(pArchive != NULL); - if (pArchive->compBuf != nil) + if (pArchive->compBuf != NULL) return kNuErrNone; pArchive->compBuf = Nu_Malloc(pArchive, kNuGenCompBufSize); - if (pArchive->compBuf == nil) + if (pArchive->compBuf == NULL) return kNuErrMalloc; return kNuErrNone; @@ -505,7 +505,7 @@ Nu_ReadMasterHeader(NuArchive* pArchive) Boolean isBinary2 = false; Boolean isSea = false; - Assert(pArchive != nil); + Assert(pArchive != NULL); fp = pArchive->archiveFp; /* saves typing */ pHeader = &pArchive->masterHeader; @@ -640,7 +640,7 @@ retry: /* compare the CRC */ if (!pArchive->valIgnoreCRC && crc != pHeader->mhMasterCRC) { - if (!Nu_ShouldIgnoreBadCRC(pArchive, nil, kNuErrBadMHCRC)) { + if (!Nu_ShouldIgnoreBadCRC(pArchive, NULL, kNuErrBadMHCRC)) { err = kNuErrBadMHCRC; Nu_ReportError(NU_BLOB, err, "Stored MH CRC=0x%04x, calc=0x%04x", pHeader->mhMasterCRC, crc); @@ -717,7 +717,7 @@ Nu_InitNewArchive(NuArchive* pArchive) { NuMasterHeader* pHeader; - Assert(pArchive != nil); + Assert(pArchive != NULL); pHeader = &pArchive->masterHeader; @@ -745,10 +745,10 @@ NuError Nu_StreamOpenRO(FILE* infp, NuArchive** ppArchive) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; - Assert(infp != nil); - Assert(ppArchive != nil); + Assert(infp != NULL); + Assert(ppArchive != NULL); err = Nu_NuArchiveNew(ppArchive); if (err != kNuErrNone) @@ -764,9 +764,9 @@ Nu_StreamOpenRO(FILE* infp, NuArchive** ppArchive) bail: if (err != kNuErrNone) { - if (pArchive != nil) + if (pArchive != NULL) (void) Nu_NuArchiveFree(pArchive); - *ppArchive = nil; + *ppArchive = NULL; } return err; } @@ -779,16 +779,16 @@ NuError Nu_OpenRO(const char* archivePathname, NuArchive** ppArchive) { NuError err; - NuArchive* pArchive = nil; - FILE* fp = nil; + NuArchive* pArchive = NULL; + FILE* fp = NULL; - if (archivePathname == nil || !strlen(archivePathname) || ppArchive == nil) + if (archivePathname == NULL || !strlen(archivePathname) || ppArchive == NULL) return kNuErrInvalidArg; - *ppArchive = nil; + *ppArchive = NULL; fp = fopen(archivePathname, kNuFileOpenReadOnly); - if (fp == nil) { + if (fp == NULL) { Nu_ReportError(NU_BLOB, errno, "Unable to open '%s'", archivePathname); err = kNuErrFileOpen; goto bail; @@ -801,7 +801,7 @@ Nu_OpenRO(const char* archivePathname, NuArchive** ppArchive) pArchive->openMode = kNuOpenRO; pArchive->archiveFp = fp; - fp = nil; + fp = NULL; pArchive->archivePathname = strdup(archivePathname); err = Nu_ReadMasterHeader(pArchive); @@ -809,11 +809,11 @@ Nu_OpenRO(const char* archivePathname, NuArchive** ppArchive) bail: if (err != kNuErrNone) { - if (pArchive != nil) { + if (pArchive != NULL) { (void) Nu_CloseAndFree(pArchive); - *ppArchive = nil; + *ppArchive = NULL; } - if (fp != nil) + if (fp != NULL) fclose(fp); } return err; @@ -830,7 +830,7 @@ bail: static NuError Nu_OpenTempFile(char* fileName, FILE** pFp) { - NuArchive* pArchive = nil; /* dummy for NU_BLOB */ + NuArchive* pArchive = NULL; /* dummy for NU_BLOB */ NuError err = kNuErrNone; int len; @@ -861,7 +861,7 @@ Nu_OpenTempFile(char* fileName, FILE** pFp) DBUG(("--- Fd-opening temp file '%s'\n", fileName)); *pFp = fdopen(fd, kNuFileOpenReadWriteCreat); - if (*pFp == nil) { + if (*pFp == NULL) { close(fd); err = errno ? errno : kNuErrFileOpen; goto bail; @@ -875,7 +875,7 @@ Nu_OpenTempFile(char* fileName, FILE** pFp) DBUG(("+++ Using mktemp\n")); result = mktemp(fileName); - if (result == nil) { + if (result == NULL) { Nu_ReportError(NU_BLOB, kNuErrNone, "mktemp failed on '%s'", fileName); err = kNuErrInternal; @@ -899,7 +899,7 @@ Nu_OpenTempFile(char* fileName, FILE** pFp) } *pFp = fdopen(fd, kNuFileOpenReadWriteCreat); - if (*pFp == nil) { + if (*pFp == NULL) { close(fd); err = errno ? errno : kNuErrFileOpen; goto bail; @@ -913,7 +913,7 @@ Nu_OpenTempFile(char* fileName, FILE** pFp) } *pFp = fopen(fileName, kNuFileOpenReadWriteCreat); - if (*pFp == nil) { + if (*pFp == NULL) { err = errno ? errno : kNuErrFileOpen; goto bail; } @@ -933,15 +933,15 @@ Nu_OpenRW(const char* archivePathname, const char* tmpPathname, ulong flags, NuArchive** ppArchive) { NuError err; - FILE* fp = nil; - FILE* tmpFp = nil; - NuArchive* pArchive = nil; - char* tmpPathDup = nil; + FILE* fp = NULL; + FILE* tmpFp = NULL; + NuArchive* pArchive = NULL; + char* tmpPathDup = NULL; Boolean archiveExists; Boolean newlyCreated; - if (archivePathname == nil || !strlen(archivePathname) || - tmpPathname == nil || !strlen(tmpPathname) || ppArchive == nil || + if (archivePathname == NULL || !strlen(archivePathname) || + tmpPathname == NULL || !strlen(tmpPathname) || ppArchive == NULL || (flags & ~(kNuOpenCreat|kNuOpenExcl)) != 0) { return kNuErrInvalidArg; @@ -970,7 +970,7 @@ Nu_OpenRW(const char* archivePathname, const char* tmpPathname, ulong flags, newlyCreated = true; } - if (fp == nil) { + if (fp == NULL) { if (errno == EACCES) err = kNuErrFileAccessDenied; else @@ -985,7 +985,7 @@ Nu_OpenRW(const char* archivePathname, const char* tmpPathname, ulong flags, if (archiveExists && !newlyCreated) { long length; - err = Nu_GetFileLength(nil, fp, &length); + err = Nu_GetFileLength(NULL, fp, &length); BailError(err); if (!length) { @@ -1021,11 +1021,11 @@ Nu_OpenRW(const char* archivePathname, const char* tmpPathname, ulong flags, pArchive->newlyCreated = newlyCreated; pArchive->archivePathname = strdup(archivePathname); pArchive->archiveFp = fp; - fp = nil; + fp = NULL; pArchive->tmpFp = tmpFp; - tmpFp = nil; + tmpFp = NULL; pArchive->tmpPathname = tmpPathDup; - tmpPathDup = nil; + tmpPathDup = NULL; if (archiveExists && !newlyCreated) { err = Nu_ReadMasterHeader(pArchive); @@ -1036,15 +1036,15 @@ Nu_OpenRW(const char* archivePathname, const char* tmpPathname, ulong flags, bail: if (err != kNuErrNone) { - if (pArchive != nil) { + if (pArchive != NULL) { (void) Nu_CloseAndFree(pArchive); - *ppArchive = nil; + *ppArchive = NULL; } - if (fp != nil) + if (fp != NULL) fclose(fp); - if (tmpFp != nil) + if (tmpFp != NULL) fclose(tmpFp); - if (tmpPathDup != nil) + if (tmpPathDup != NULL) Nu_Free(pArchive, tmpPathDup); } return err; @@ -1068,9 +1068,9 @@ Nu_WriteMasterHeader(NuArchive* pArchive, FILE* fp, long crcOffset; ushort crc; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pHeader != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pHeader != NULL); Assert(pHeader->isValid); Assert(pHeader->mhMasterVersion == kNuOurMHVersion); @@ -1125,17 +1125,17 @@ bail: static void Nu_CloseAndFree(NuArchive* pArchive) { - if (pArchive->archiveFp != nil) { + if (pArchive->archiveFp != NULL) { DBUG(("--- Closing archive\n")); fclose(pArchive->archiveFp); - pArchive->archiveFp = nil; + pArchive->archiveFp = NULL; } - if (pArchive->tmpFp != nil) { + if (pArchive->tmpFp != NULL) { DBUG(("--- Closing and removing temp file\n")); fclose(pArchive->tmpFp); - pArchive->tmpFp = nil; - Assert(pArchive->tmpPathname != nil); + pArchive->tmpFp = NULL; + Assert(pArchive->tmpPathname != NULL); if (remove(pArchive->tmpPathname) != 0) { Nu_ReportError(NU_BLOB, errno, "Unable to remove temp file '%s'", pArchive->tmpPathname); @@ -1164,7 +1164,7 @@ Nu_Close(NuArchive* pArchive) NuError err = kNuErrNone; long flushStatus; - Assert(pArchive != nil); + Assert(pArchive != NULL); if (!Nu_IsReadOnly(pArchive)) err = Nu_Flush(pArchive, &flushStatus); @@ -1193,9 +1193,9 @@ Nu_Close(NuArchive* pArchive) NuError Nu_DeleteArchiveFile(NuArchive* pArchive) { - Assert(pArchive != nil); - Assert(pArchive->archiveFp == nil); - Assert(pArchive->archivePathname != nil); + Assert(pArchive != NULL); + Assert(pArchive->archiveFp == NULL); + Assert(pArchive->archivePathname != NULL); return Nu_DeleteFile(pArchive->archivePathname); } @@ -1207,11 +1207,11 @@ Nu_DeleteArchiveFile(NuArchive* pArchive) NuError Nu_RenameTempToArchive(NuArchive* pArchive) { - Assert(pArchive != nil); - Assert(pArchive->archiveFp == nil); - Assert(pArchive->tmpFp == nil); - Assert(pArchive->archivePathname != nil); - Assert(pArchive->tmpPathname != nil); + Assert(pArchive != NULL); + Assert(pArchive->archiveFp == NULL); + Assert(pArchive->tmpFp == NULL); + Assert(pArchive->archivePathname != NULL); + Assert(pArchive->tmpPathname != NULL); return Nu_RenameFile(pArchive->tmpPathname, pArchive->archivePathname); } diff --git a/nufxlib/ArchiveIO.c b/nufxlib/ArchiveIO.c index 5f71486..056b879 100644 --- a/nufxlib/ArchiveIO.c +++ b/nufxlib/ArchiveIO.c @@ -31,9 +31,9 @@ Nu_ReadOneC(NuArchive* pArchive, FILE* fp, ushort* pCrc) { int ic; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); ic = getc(fp); *pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc); @@ -54,9 +54,9 @@ Nu_ReadOne(NuArchive* pArchive, FILE* fp) void Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uchar val, ushort* pCrc) { - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); putc(val, fp); } @@ -77,9 +77,9 @@ Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, ushort* pCrc) { int ic1, ic2; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); ic1 = getc(fp); *pCrc = Nu_UpdateCRC16((uchar)ic1, *pCrc); @@ -105,9 +105,9 @@ Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, ushort val, ushort* pCrc) { int ic1, ic2; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); ic1 = val & 0xff; *pCrc = Nu_UpdateCRC16((uchar)ic1, *pCrc); @@ -134,9 +134,9 @@ Nu_ReadFourC(NuArchive* pArchive, FILE* fp, ushort* pCrc) { int ic1, ic2, ic3, ic4; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); ic1 = getc(fp); *pCrc = Nu_UpdateCRC16((uchar)ic1, *pCrc); @@ -166,9 +166,9 @@ Nu_WriteFourC(NuArchive* pArchive, FILE* fp, ulong val, ushort* pCrc) { int ic1, ic2, ic3, ic4; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); ic1 = val & 0xff; *pCrc = Nu_UpdateCRC16((uchar)ic1, *pCrc); @@ -206,9 +206,9 @@ Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, ushort* pCrc) NuDateTime temp; int ic; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); ic = getc(fp); *pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc); @@ -255,9 +255,9 @@ Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime, { int ic; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); ic = dateTime.second; *pCrc = Nu_UpdateCRC16((uchar)ic, *pCrc); @@ -303,10 +303,10 @@ Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count, uchar* buffer = vbuffer; int ic; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); - Assert(buffer != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); + Assert(buffer != NULL); Assert(count > 0); while (count--) { @@ -334,10 +334,10 @@ Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count, const uchar* buffer = vbuffer; int ic; - Assert(pArchive != nil); - Assert(fp != nil); - Assert(pCrc != nil); - Assert(buffer != nil); + Assert(pArchive != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); + Assert(buffer != NULL); Assert(count > 0); while (count--) { @@ -411,7 +411,7 @@ Nu_SeekArchive(NuArchive* pArchive, FILE* fp, long offset, int ptrname) NuError Nu_RewindArchive(NuArchive* pArchive) { - Assert(pArchive != nil); + Assert(pArchive != NULL); Assert(!Nu_IsStreaming(pArchive)); if (Nu_SeekArchive(pArchive, pArchive->archiveFp, diff --git a/nufxlib/Bzip2.c b/nufxlib/Bzip2.c index 8fde0b6..7e45dc9 100644 --- a/nufxlib/Bzip2.c +++ b/nufxlib/Bzip2.c @@ -53,14 +53,14 @@ Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, NuError err = kNuErrNone; bz_stream bzstream; int bzerr; - uchar* outbuf = nil; + uchar* outbuf = NULL; - Assert(pArchive != nil); - Assert(pStraw != nil); - Assert(fp != nil); + Assert(pArchive != NULL); + Assert(pStraw != NULL); + Assert(fp != NULL); Assert(srcLen > 0); - Assert(pDstLen != nil); - Assert(pCrc != nil); + Assert(pDstLen != NULL); + Assert(pCrc != NULL); err = Nu_AllocCompressionBufferIFN(pArchive); if (err != kNuErrNone) @@ -76,7 +76,7 @@ Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, bzstream.bzalloc = Nu_bzalloc; bzstream.bzfree = Nu_bzfree; bzstream.opaque = pArchive; - bzstream.next_in = nil; + bzstream.next_in = NULL; bzstream.avail_in = 0; bzstream.next_out = outbuf; bzstream.avail_out = kNuGenCompBufSize; @@ -158,7 +158,7 @@ bz_bail: BZ2_bzCompressEnd(&bzstream); /* free up any allocated structures */ bail: - if (outbuf != nil) + if (outbuf != NULL) free(outbuf); return err; } @@ -183,10 +183,10 @@ Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord, ulong compRemaining; uchar* outbuf; - Assert(pArchive != nil); - Assert(pThread != nil); - Assert(infp != nil); - Assert(pFunnel != nil); + Assert(pArchive != NULL); + Assert(pThread != NULL); + Assert(infp != NULL); + Assert(pFunnel != NULL); err = Nu_AllocCompressionBufferIFN(pArchive); if (err != kNuErrNone) @@ -204,7 +204,7 @@ Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord, bzstream.bzalloc = Nu_bzalloc; bzstream.bzfree = Nu_bzfree; bzstream.opaque = pArchive; - bzstream.next_in = nil; + bzstream.next_in = NULL; bzstream.avail_in = 0; bzstream.next_out = outbuf; bzstream.avail_out = kNuGenCompBufSize; @@ -266,7 +266,7 @@ Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord, goto bz_bail; } - if (pCrc != nil) + if (pCrc != NULL) *pCrc = Nu_CalcCRC16(*pCrc, outbuf, (uchar*) bzstream.next_out - outbuf); @@ -291,7 +291,7 @@ bz_bail: BZ2_bzDecompressEnd(&bzstream); /* free up any allocated structures */ bail: - if (outbuf != nil) + if (outbuf != NULL) free(outbuf); return err; } diff --git a/nufxlib/Compress.c b/nufxlib/Compress.c index c8f4cc3..96b569a 100644 --- a/nufxlib/Compress.c +++ b/nufxlib/Compress.c @@ -20,12 +20,12 @@ Nu_CompressUncompressed(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, ulong srcLen, ulong* pDstLen, ushort *pCrc) { NuError err = kNuErrNone; - /*uchar* buffer = nil;*/ + /*uchar* buffer = NULL;*/ ulong count, getsize; - Assert(pArchive != nil); - Assert(pStraw != nil); - Assert(fp != nil); + Assert(pArchive != NULL); + Assert(pStraw != NULL); + Assert(fp != NULL); Assert(srcLen > 0); *pDstLen = srcLen; /* get this over with */ @@ -33,7 +33,7 @@ Nu_CompressUncompressed(NuArchive* pArchive, NuStraw* pStraw, err = Nu_AllocCompressionBufferIFN(pArchive); BailError(err); - if (pCrc != nil) + if (pCrc != NULL) *pCrc = kNuInitialThreadCRC; count = srcLen; @@ -42,7 +42,7 @@ Nu_CompressUncompressed(NuArchive* pArchive, NuStraw* pStraw, err = Nu_StrawRead(pArchive, pStraw, pArchive->compBuf, getsize); BailError(err); - if (pCrc != nil) + if (pCrc != NULL) *pCrc = Nu_CalcCRC16(*pCrc, pArchive->compBuf, getsize); err = Nu_FWrite(fp, pArchive->compBuf, getsize); BailError(err); @@ -95,16 +95,16 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource, { NuError err; long origOffset; - NuStraw* pStraw = nil; - NuDataSink* pDataSink = nil; + NuStraw* pStraw = NULL; + NuDataSink* pDataSink = NULL; ulong srcLen = 0, dstLen = 0; ushort threadCrc; - Assert(pArchive != nil); - Assert(pDataSource != nil); - /* okay if pProgressData is nil */ - Assert(dstFp != nil); - Assert(pThread != nil); + Assert(pArchive != NULL); + Assert(pDataSource != NULL); + /* okay if pProgressData is NULL */ + Assert(dstFp != NULL); + Assert(pThread != NULL); /* remember file offset, so we can back up if compression fails */ err = Nu_FTell(dstFp, &origOffset); @@ -168,7 +168,7 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource, if (pArchive->valMimicSHK && srcLen < kNuSHKLZWThreshold) targetFormat = kNuThreadFormatUncompressed; - if (pProgressData != nil) { + if (pProgressData != NULL) { if (targetFormat != kNuThreadFormatUncompressed) Nu_StrawSetProgressState(pStraw, kNuProgressCompressing); else @@ -245,7 +245,7 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource, BailError(err); err = Nu_StrawRewind(pArchive, pStraw); BailError(err); - if (pProgressData != nil) + if (pProgressData != NULL) Nu_StrawSetProgressState(pStraw, kNuProgressStoring); err = Nu_ProgressDataCompressPrep(pArchive, pStraw, kNuThreadFormatUncompressed, srcLen); @@ -262,7 +262,7 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource, * computed a CRC on the entire file (i.e. didn't stop early * when it noticed the output was larger than the input). If * this is always the case, then we can change "&threadCrc" - * a few lines back to "nil" and avoid re-computing the CRC. + * a few lines back to "NULL" and avoid re-computing the CRC. * If this is not always the case, remove this assert. */ Assert(threadCrc == pThread->thThreadCRC); @@ -276,14 +276,14 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource, /* * Copy the already-compressed input. */ - if (pProgressData != nil) + if (pProgressData != NULL) Nu_StrawSetProgressState(pStraw, kNuProgressCopying); err = Nu_ProgressDataCompressPrep(pArchive, pStraw, kNuThreadFormatUncompressed, srcLen); BailError(err); err = Nu_CompressUncompressed(pArchive, pStraw, dstFp, srcLen, - &dstLen, nil); + &dstLen, NULL); BailError(err); pThread->thThreadEOF = Nu_DataSourceGetOtherLen(pDataSource); @@ -298,7 +298,7 @@ done: srcLen, dstLen, pThread->actualThreadEOF)); /* make sure we send a final "success" progress message at 100% */ - if (pProgressData != nil) { + if (pProgressData != NULL) { (void) Nu_StrawSetProgressState(pStraw, kNuProgressDone); err = Nu_StrawSendProgressUpdate(pArchive, pStraw); BailError(err); @@ -327,7 +327,7 @@ Nu_CopyPresizedToArchive(NuArchive* pArchive, NuDataSource* pDataSource, NuThreadID threadID, FILE* dstFp, NuThread* pThread, char** ppSavedCopy) { NuError err = kNuErrNone; - NuStraw* pStraw = nil; + NuStraw* pStraw = NULL; ulong srcLen, bufferLen; ulong count, getsize; @@ -355,7 +355,7 @@ Nu_CopyPresizedToArchive(NuArchive* pArchive, NuDataSource* pDataSource, * is a convenient way to deal with the dataSource, even though we * don't have a progress updater. */ - err = Nu_StrawNew(pArchive, pDataSource, nil, &pStraw); + err = Nu_StrawNew(pArchive, pDataSource, NULL, &pStraw); BailError(err); count = srcLen; @@ -370,7 +370,7 @@ Nu_CopyPresizedToArchive(NuArchive* pArchive, NuDataSource* pDataSource, err = Nu_FWrite(dstFp, pArchive->compBuf, getsize); BailError(err); - if (ppSavedCopy != nil && *ppSavedCopy == nil) { + if (ppSavedCopy != NULL && *ppSavedCopy == NULL) { /* * Grab a copy of the filename for our own use. This assumes * that the filename fits in kNuGenCompBufSize, which is a diff --git a/nufxlib/Debug.c b/nufxlib/Debug.c index eeb1daa..c90adac 100644 --- a/nufxlib/Debug.c +++ b/nufxlib/Debug.c @@ -140,7 +140,7 @@ Nu_DebugDumpThread(const NuThread* pThread) NuThreadID threadID; const char* descr; - Assert(pThread != nil); + Assert(pThread != NULL); printf("%sThreadClass: 0x%04x (%s)\n", kInd, pThread->thThreadClass, @@ -188,15 +188,15 @@ Nu_DebugDumpRecord(NuArchive* pArchive, const NuRecord* pRecord, const NuThread* pThread; ulong idx; - Assert(pRecord != nil); + Assert(pRecord != NULL); /*printf("PTR: pRecord=0x%08lx pXrefRecord=0x%08lx\n", (long) pRecord, (long) pXrefRecord);*/ printf("%s%s%sFilename: '%s' (idx=%lu)\n", kInd, isDeleted ? "[DEL] " : "", - pXrefRecord != nil && pXrefRecord->pThreadMods != nil ? "[MOD] " : "", - pRecord->filename == nil ? "" : pRecord->filename, + pXrefRecord != NULL && pXrefRecord->pThreadMods != NULL ? "[MOD] " : "", + pRecord->filename == NULL ? "" : pRecord->filename, pRecord->recordIdx); printf("%sHeaderID: '%.4s' VersionNumber: 0x%04x HeaderCRC: 0x%04x\n", kInd, @@ -223,7 +223,7 @@ Nu_DebugDumpRecord(NuArchive* pArchive, const NuRecord* pRecord, if (pRecord->recOptionSize) { char* outBuf = Nu_Malloc(pArchive, pRecord->recOptionSize * 2 +1); BailAlloc(outBuf); - Assert(pRecord->recOptionList != nil); + Assert(pRecord->recOptionList != NULL); ConvertToHexStr(pRecord->recOptionList, pRecord->recOptionSize, outBuf); printf("%sOptionList: [%s]\n", kInd, outBuf); Nu_Free(pArchive, outBuf); @@ -238,21 +238,21 @@ Nu_DebugDumpRecord(NuArchive* pArchive, const NuRecord* pRecord, isFake = (idx >= pRecord->recTotalThreads - pRecord->fakeThreads); pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); printf("%s--Thread #%lu (idx=%lu)%s\n", kInd, idx, pThread->threadIdx, isFake ? " [FAKE]" : ""); Nu_DebugDumpThread(pThread); } - if (pXrefRecord != nil) + if (pXrefRecord != NULL) pThreadMod = pXrefRecord->pThreadMods; else pThreadMod = pRecord->pThreadMods; /* probably empty */ - if (pThreadMod != nil) + if (pThreadMod != NULL) printf("%s*ThreadMods -----\n", kInd); - while (pThreadMod != nil) { + while (pThreadMod != NULL) { switch (pThreadMod->entry.kind) { case kNuThreadModAdd: printf("%s *-ThreadMod ADD 0x%08lx 0x%04x (sourceType=%d)\n", kInd, @@ -300,8 +300,8 @@ Nu_DebugDumpRecordSet(NuArchive* pArchive, const NuRecordSet* pRecordSet, long count; doXref = false; - pXrefRecord = nil; - if (pXrefSet != nil && Nu_RecordSet_GetLoaded(pXrefSet)) { + pXrefRecord = NULL; + if (pXrefSet != NULL && Nu_RecordSet_GetLoaded(pXrefSet)) { pXrefRecord = Nu_RecordSet_GetListHead(pXrefSet); doXref = true; } @@ -309,18 +309,18 @@ Nu_DebugDumpRecordSet(NuArchive* pArchive, const NuRecordSet* pRecordSet, /* dump every record, if we've loaded them */ count = Nu_RecordSet_GetNumRecords(pRecordSet); pRecord = Nu_RecordSet_GetListHead(pRecordSet); - if (pRecord != nil) { + if (pRecord != NULL) { Assert(count != 0); while (count--) { - Assert(pRecord != nil); + Assert(pRecord != NULL); - if (pXrefRecord != nil && + if (pXrefRecord != NULL && pRecord->recordIdx == pXrefRecord->recordIdx) { Nu_DebugDumpRecord(pArchive, pRecord, pXrefRecord, false); pXrefRecord = pXrefRecord->pNext; } else { - Nu_DebugDumpRecord(pArchive, pRecord, nil, doXref); + Nu_DebugDumpRecord(pArchive, pRecord, NULL, doXref); } pRecord = pRecord->pNext; } @@ -338,7 +338,7 @@ Nu_DebugDumpMH(const NuMasterHeader* pMasterHeader) static const char* kInd = " "; char dateBuf1[kNuDateOutputLen]; - Assert(pMasterHeader != nil); + Assert(pMasterHeader != NULL); printf("%sNufileID: '%.6s' MasterCRC: 0x%04x TotalRecords: %lu\n", kInd, pMasterHeader->mhNufileID, pMasterHeader->mhMasterCRC, @@ -362,7 +362,7 @@ Nu_DebugDumpMH(const NuMasterHeader* pMasterHeader) void Nu_DebugDumpAll(NuArchive* pArchive) { - Assert(pArchive != nil); + Assert(pArchive != NULL); printf("*Archive pathname: '%s'\n", pArchive->archivePathname); printf("*Archive type: %d\n", pArchive->archiveType); @@ -382,7 +382,7 @@ Nu_DebugDumpAll(NuArchive* pArchive) Nu_DebugDumpRecordSet(pArchive, &pArchive->origRecordSet, &pArchive->copyRecordSet); printf(" *NEW record set:\n"); - Nu_DebugDumpRecordSet(pArchive, &pArchive->newRecordSet, nil); + Nu_DebugDumpRecordSet(pArchive, &pArchive->newRecordSet, NULL); if (!Nu_RecordSet_GetLoaded(&pArchive->origRecordSet) && !Nu_RecordSet_GetLoaded(&pArchive->newRecordSet)) diff --git a/nufxlib/Deferred.c b/nufxlib/Deferred.c index fface90..26c5b56 100644 --- a/nufxlib/Deferred.c +++ b/nufxlib/Deferred.c @@ -28,11 +28,11 @@ Nu_ThreadModAdd_New(NuArchive* pArchive, NuThreadID threadID, NuThreadFormat threadFormat, NuDataSource* pDataSource, NuThreadMod** ppThreadMod) { - Assert(ppThreadMod != nil); - Assert(pDataSource != nil); + Assert(ppThreadMod != NULL); + Assert(pDataSource != NULL); *ppThreadMod = Nu_Calloc(pArchive, sizeof(**ppThreadMod)); - if (*ppThreadMod == nil) + if (*ppThreadMod == NULL) return kNuErrMalloc; (*ppThreadMod)->entry.kind = kNuThreadModAdd; @@ -57,11 +57,11 @@ NuError Nu_ThreadModUpdate_New(NuArchive* pArchive, NuThreadIdx threadIdx, NuDataSource* pDataSource, NuThreadMod** ppThreadMod) { - Assert(ppThreadMod != nil); - Assert(pDataSource != nil); + Assert(ppThreadMod != NULL); + Assert(pDataSource != NULL); *ppThreadMod = Nu_Calloc(pArchive, sizeof(**ppThreadMod)); - if (*ppThreadMod == nil) + if (*ppThreadMod == NULL) return kNuErrMalloc; (*ppThreadMod)->entry.kind = kNuThreadModUpdate; @@ -82,10 +82,10 @@ NuError Nu_ThreadModDelete_New(NuArchive* pArchive, NuThreadIdx threadIdx, NuThreadID threadID, NuThreadMod** ppThreadMod) { - Assert(ppThreadMod != nil); + Assert(ppThreadMod != NULL); *ppThreadMod = Nu_Calloc(pArchive, sizeof(**ppThreadMod)); - if (*ppThreadMod == nil) + if (*ppThreadMod == NULL) return kNuErrMalloc; (*ppThreadMod)->entry.kind = kNuThreadModDelete; @@ -102,7 +102,7 @@ Nu_ThreadModDelete_New(NuArchive* pArchive, NuThreadIdx threadIdx, void Nu_ThreadModFree(NuArchive* pArchive, NuThreadMod* pThreadMod) { - if (pThreadMod == nil) + if (pThreadMod == NULL) return; switch (pThreadMod->entry.kind) { @@ -131,13 +131,13 @@ Nu_ThreadModFree(NuArchive* pArchive, NuThreadMod* pThreadMod) * be more than three or four threads per record, so the extra search * isn't costly.) * - * Returns "nil" if nothing found. + * Returns "NULL" if nothing found. */ NuThreadMod* Nu_ThreadMod_FindByThreadIdx(const NuRecord* pRecord, NuThreadIdx threadIdx) { NuThreadMod* pThreadMod; - NuThreadMod* pMatch = nil; + NuThreadMod* pMatch = NULL; pThreadMod = pRecord->pThreadMods; while (pThreadMod) { @@ -148,13 +148,13 @@ Nu_ThreadMod_FindByThreadIdx(const NuRecord* pRecord, NuThreadIdx threadIdx) break; case kNuThreadModUpdate: if (pThreadMod->entry.update.threadIdx == threadIdx) { - Assert(pMatch == nil); + Assert(pMatch == NULL); pMatch = pThreadMod; } break; case kNuThreadModDelete: if (pThreadMod->entry.delete.threadIdx == threadIdx) { - Assert(pMatch == nil); + Assert(pMatch == NULL); pMatch = pThreadMod; } break; @@ -184,11 +184,11 @@ Nu_ThreadModAdd_FindByThreadID(const NuRecord* pRecord, NuThreadID threadID, { NuThreadMod* pThreadMod; - Assert(pRecord != nil); - Assert(ppThreadMod != nil); + Assert(pRecord != NULL); + Assert(ppThreadMod != NULL); pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { if (pThreadMod->entry.kind != kNuThreadModAdd) continue; @@ -213,20 +213,20 @@ Nu_FreeThreadMods(NuArchive* pArchive, NuRecord* pRecord) NuThreadMod* pThreadMod; NuThreadMod* pNext; - Assert(pRecord != nil); + Assert(pRecord != NULL); pThreadMod = pRecord->pThreadMods; - if (pThreadMod == nil) + if (pThreadMod == NULL) return; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { pNext = pThreadMod->pNext; Nu_ThreadModFree(pArchive, pThreadMod); pThreadMod = pNext; } - pRecord->pThreadMods = nil; + pRecord->pThreadMods = NULL; } @@ -269,7 +269,7 @@ bail: static void Nu_NewThreads_Free(NuArchive* pArchive, NuNewThreads* pNewThreads) { - if (pNewThreads != nil) { + if (pNewThreads != NULL) { Nu_Free(pArchive, pNewThreads->pThreads); Nu_Free(pArchive, pNewThreads); } @@ -316,7 +316,7 @@ Nu_NewThreads_GetNext(NuNewThreads* pNewThreads, NuArchive* pArchive) static int Nu_NewThreads_GetNumThreads(const NuNewThreads* pNewThreads) { - Assert(pNewThreads != nil); + Assert(pNewThreads != NULL); return pNewThreads->numThreads; } @@ -331,7 +331,7 @@ Nu_NewThreads_TotalCompThreadEOF(NuNewThreads* pNewThreads) int i; /* we should be all full up at this point; if not, we have a bug */ - Assert(pNewThreads != nil); + Assert(pNewThreads != NULL); Assert(pNewThreads->numThreads == pNewThreads->nextSlot); compThreadEOF = 0; @@ -352,7 +352,7 @@ Nu_NewThreads_DonateThreads(NuNewThreads* pNewThreads) { NuThread* pThreads = pNewThreads->pThreads; - pNewThreads->pThreads = nil; + pNewThreads->pThreads = NULL; return pThreads; } @@ -433,7 +433,7 @@ Nu_CountEventualThreads(const NuRecord* pRecord, long* pTotalThreads, numFilenameThreads = 0; pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { switch (pThreadMod->entry.kind) { case kNuThreadModAdd: numThreads++; @@ -463,7 +463,7 @@ Nu_CountEventualThreads(const NuRecord* pRecord, long* pTotalThreads, */ for (idx = 0; idx < (long)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); if (NuGetThreadID(pThread) == kNuThreadIDFilename) numFilenameThreads++; @@ -504,11 +504,11 @@ Nu_VerifyAllTouched(NuArchive* pArchive, const NuRecord* pRecord) const NuThread* pThread; long idx; - Assert(pArchive != nil); - Assert(pRecord != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { Assert(pThreadMod->entry.generic.used == false || pThreadMod->entry.generic.used == true); if (!pThreadMod->entry.generic.used) @@ -518,7 +518,7 @@ Nu_VerifyAllTouched(NuArchive* pArchive, const NuRecord* pRecord) for (idx = 0; idx < (long)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); Assert(pThread->used == false || pThread->used == true); if (!pThread->used) @@ -541,8 +541,8 @@ Nu_VerifyAllTouched(NuArchive* pArchive, const NuRecord* pRecord) static void Nu_SetNewThreadFilename(NuArchive* pArchive, NuRecord* pRecord, char* newName) { - Assert(pRecord != nil); - Assert(newName != nil); + Assert(pRecord != NULL); + Assert(newName != NULL); Nu_Free(pArchive, pRecord->threadFilename); pRecord->threadFilename = newName; @@ -604,7 +604,7 @@ Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp, NuRecord* pRecord, NuThread* pThread, const NuThreadMod* pThreadMod) { NuError err; - NuDataSource* pDataSource = nil; + NuDataSource* pDataSource = NULL; ulong sourceLen; ulong threadBufSize; @@ -621,7 +621,7 @@ Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp, NuRecord* pRecord, Assert(pThread->thCompThreadEOF >= pThread->thThreadEOF); threadBufSize = pThread->thCompThreadEOF; pDataSource = pThreadMod->entry.update.pDataSource; - Assert(pDataSource != nil); + Assert(pDataSource != NULL); err = Nu_DataSourcePrepareInput(pArchive, pDataSource); if (err == kNuErrSkipped) { @@ -662,7 +662,7 @@ Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp, NuRecord* pRecord, if (NuGetThreadID(pThread) == kNuThreadIDFilename) { /* special handling for filename updates */ - char* savedCopy = nil; + char* savedCopy = NULL; err = Nu_CopyPresizedToArchive(pArchive, pDataSource, NuGetThreadID(pThread), fp, pThread, &savedCopy); if (err != kNuErrNone) { @@ -673,7 +673,7 @@ Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp, NuRecord* pRecord, } else { err = Nu_CopyPresizedToArchive(pArchive, pDataSource, - NuGetThreadID(pThread), fp, pThread, nil); + NuGetThreadID(pThread), fp, pThread, NULL); if (err != kNuErrNone) { Nu_ReportError(NU_BLOB, err, "thread update failed"); goto bail; @@ -723,7 +723,7 @@ Nu_HandleAddThreadMods(NuArchive* pArchive, NuRecord* pRecord, * matching by wildcards, but don't re-use "used" entries. */ pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { if (pThreadMod->entry.kind == kNuThreadModAdd && !pThreadMod->entry.generic.used && (pThreadMod->entry.add.threadID == threadID || @@ -747,7 +747,7 @@ Nu_HandleAddThreadMods(NuArchive* pArchive, NuRecord* pRecord, } /* if this is a data thread, prepare the progress message */ - pProgressData = nil; + pProgressData = NULL; if (NuThreadIDGetClass(pThreadMod->entry.add.threadID) == kNuThreadClassData) { @@ -836,7 +836,7 @@ Nu_HandleAddThreadMods(NuArchive* pArchive, NuRecord* pRecord, if (pThreadMod->entry.add.threadID == kNuThreadIDFilename) { /* filenames are special */ - char* savedCopy = nil; + char* savedCopy = NULL; Assert(pThreadMod->entry.add.threadFormat == kNuThreadFormatUncompressed); @@ -863,7 +863,7 @@ Nu_HandleAddThreadMods(NuArchive* pArchive, NuRecord* pRecord, err = Nu_CopyPresizedToArchive(pArchive, pThreadMod->entry.add.pDataSource, pThreadMod->entry.add.threadID, - dstFp, pNewThread, nil); + dstFp, pNewThread, NULL); /* fall through with err */ } else { @@ -929,7 +929,7 @@ Nu_ConstructArchiveThreads(NuArchive* pArchive, NuRecord* pRecord, */ for (idx = 0; idx < (int)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); DBUG(("+++ THREAD #%d (used=%d)\n", idx, pThread->used)); if (threadID == kNuThreadIDWildcard || @@ -944,7 +944,7 @@ Nu_ConstructArchiveThreads(NuArchive* pArchive, NuRecord* pRecord, pThreadMod = Nu_ThreadMod_FindByThreadIdx(pRecord, pThread->threadIdx); - if (pThreadMod != nil) { + if (pThreadMod != NULL) { /* * The thread has a related ThreadMod. Deal with it. */ @@ -1060,14 +1060,14 @@ static NuError Nu_ConstructArchiveRecord(NuArchive* pArchive, NuRecord* pRecord) { NuError err; - NuNewThreads* pNewThreads = nil; + NuNewThreads* pNewThreads = NULL; long threadDisp; long initialOffset, finalOffset; long numThreads, numFilenameThreads; int newHeaderSize; - Assert(pArchive != nil); - Assert(pRecord != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); DBUG(("--- Reconstructing '%s'\n", pRecord->filename)); @@ -1102,19 +1102,19 @@ Nu_ConstructArchiveRecord(NuArchive* pArchive, NuRecord* pRecord) /* looks like a previously existing filename thread got removed */ DBUG(("--- Dropping thread filename '%s'\n", pRecord->threadFilename)); if (pRecord->filename == pRecord->threadFilename) - pRecord->filename = nil; /* don't point at freed memory! */ + pRecord->filename = NULL; /* don't point at freed memory! */ Nu_Free(pArchive, pRecord->threadFilename); - pRecord->threadFilename = nil; + pRecord->threadFilename = NULL; /* I don't think this is possible, but check it anyway */ - if (pRecord->filename == nil && pRecord->recFilename != nil && + if (pRecord->filename == NULL && pRecord->recFilename != NULL && !pRecord->dropRecFilename) { DBUG(("--- HEY, how did this happen?\n")); pRecord->filename = pRecord->recFilename; } } - if (pRecord->filename == nil) + if (pRecord->filename == NULL) pRecord->filename = kNuDefaultRecordName; /* @@ -1265,15 +1265,15 @@ static NuError Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord, FILE* fp) { NuError err; - NuNewThreads* pNewThreads = nil; + NuNewThreads* pNewThreads = NULL; NuThreadMod* pThreadMod; long threadDisp; long initialOffset, finalOffset; long numThreadMods, numFilenameThreads; int newHeaderSize; - Assert(pArchive != nil); - Assert(pRecord != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); DBUG(("--- Constructing '%s'\n", pRecord->filename)); @@ -1287,7 +1287,7 @@ Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord, FILE* fp) * make ourselves useful by counting up the number of eventual * threads, and verify that there is exactly one filename thread. */ - Assert(pRecord->pThreads == nil); + Assert(pRecord->pThreads == NULL); numThreadMods = 0; numFilenameThreads = 0; @@ -1312,15 +1312,15 @@ Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord, FILE* fp) * records when the application doesn't explicitly add a thread. */ if (!numFilenameThreads) { - NuDataSource* pTmpDataSource = nil; - NuThreadMod* pNewThreadMod = nil; + NuDataSource* pTmpDataSource = NULL; + NuThreadMod* pNewThreadMod = NULL; int len, maxLen; /* * Generally speaking, the "add file" call should set the * filename. If somehow it didn't, assign a default. */ - if (pRecord->filename == nil) { + if (pRecord->filename == NULL) { pRecord->newFilename = strdup(kNuDefaultRecordName); pRecord->filename = pRecord->newFilename; } @@ -1340,7 +1340,7 @@ Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord, FILE* fp) len : kNuDefaultFilenameThreadSize; err = Nu_DataSourceBuffer_New(kNuThreadFormatUncompressed, maxLen, (const uchar*)pRecord->filename, 0, - strlen(pRecord->filename), nil, &pTmpDataSource); + strlen(pRecord->filename), NULL, &pTmpDataSource); BailError(err); /* put in a new "add" threadMod (which copies the data source) */ @@ -1351,7 +1351,7 @@ Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord, FILE* fp) /* add it to the list */ Nu_RecordAddThreadMod(pRecord, pNewThreadMod); - pNewThreadMod = nil; + pNewThreadMod = NULL; numFilenameThreads++; numThreadMods++; @@ -1431,7 +1431,7 @@ Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord, FILE* fp) /* * Install pNewThreads as the thread list. */ - Assert(pRecord->pThreads == nil && pRecord->recTotalThreads == 0); + Assert(pRecord->pThreads == NULL && pRecord->recTotalThreads == 0); pRecord->pThreads = Nu_NewThreads_DonateThreads(pNewThreads); pRecord->recTotalThreads = Nu_NewThreads_GetNumThreads(pNewThreads); @@ -1501,7 +1501,7 @@ Nu_UpdateRecordInOriginal(NuArchive* pArchive, NuRecord* pRecord) * Loop through all threadMods. */ pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { Assert(pThreadMod->entry.kind == kNuThreadModUpdate); /* find the thread associated with this threadMod */ @@ -1547,7 +1547,7 @@ Nu_UpdateRecordInOriginal(NuArchive* pArchive, NuRecord* pRecord) DBUG(("--- record header wrote %ld bytes\n", pArchive->currentOffset - pRecord->fileOffset)); pThread = pRecord->pThreads; - if (pThread != nil && pArchive->currentOffset != pThread->fileOffset) { + if (pThread != NULL && pArchive->currentOffset != pThread->fileOffset) { /* guess what, we just trashed the archive */ err = kNuErrDamaged; Nu_ReportError(NU_BLOB, err, @@ -1631,8 +1631,8 @@ Nu_CreateTempFromOriginal(NuArchive* pArchive) * record header, but since all we do is copy the data anyway, * it's not much slower. */ - while (pRecord != nil) { - if (!pRecord->dirtyHeader && pRecord->pThreadMods == nil) { + while (pRecord != NULL) { + if (!pRecord->dirtyHeader && pRecord->pThreadMods == NULL) { err = Nu_CopyArchiveRecord(pArchive, pRecord); BailError(err); } else { @@ -1690,8 +1690,8 @@ Nu_UpdateInOriginal(NuArchive* pArchive) * Run through and process all the updates. */ pRecord = Nu_RecordSet_GetListHead(&pArchive->copyRecordSet); - while (pRecord != nil) { - if (pRecord->dirtyHeader || pRecord->pThreadMods != nil) { + while (pRecord != NULL) { + if (pRecord->dirtyHeader || pRecord->pThreadMods != NULL) { err = Nu_UpdateRecordInOriginal(pArchive, pRecord); BailError(err); } @@ -1724,7 +1724,7 @@ Nu_CreateNewRecords(NuArchive* pArchive, FILE* fp) NuRecord* pRecord; pRecord = Nu_RecordSet_GetListHead(&pArchive->newRecordSet); - while (pRecord != nil) { + while (pRecord != NULL) { err = Nu_ConstructNewRecord(pArchive, pRecord, fp); if (err == kNuErrSkipped) { /* @@ -1801,10 +1801,10 @@ Nu_NoHeavyUpdates(NuArchive* pArchive) while (count--) { const NuThreadMod* pThreadMod; - Assert(pRecord != nil); + Assert(pRecord != NULL); pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { /* the only acceptable kind is "update" */ if (pThreadMod->entry.kind != kNuThreadModUpdate) return false; @@ -1835,18 +1835,18 @@ Nu_PurgeEmptyRecords(NuArchive* pArchive, NuRecordSet* pRecordSet) NuRecord* pRecord; NuRecord** ppRecord; - Assert(pArchive != nil); - Assert(pRecordSet != nil); + Assert(pArchive != NULL); + Assert(pRecordSet != NULL); if (Nu_RecordSet_IsEmpty(pRecordSet)) return kNuErrNone; ppRecord = Nu_RecordSet_GetListHeadPtr(pRecordSet); - Assert(ppRecord != nil); - Assert(*ppRecord != nil); + Assert(ppRecord != NULL); + Assert(*ppRecord != NULL); /* maintain a pointer to the pointer, so we can delete easily */ - while (*ppRecord != nil) { + while (*ppRecord != NULL) { pRecord = *ppRecord; if (Nu_RecordIsEmpty(pArchive, pRecord)) { @@ -1923,11 +1923,11 @@ Nu_ResetTempFile(NuArchive* pArchive) if (Nu_IsReadOnly(pArchive)) return kNuErrNone; /* or kNuErrArchiveRO? */ - Assert(pArchive != nil); - Assert(pArchive->tmpPathname != nil); + Assert(pArchive != NULL); + Assert(pArchive->tmpPathname != NULL); #if 0 /* keep the temp file around for examination */ -if (pArchive->tmpFp != nil) { +if (pArchive->tmpFp != NULL) { DBUG(("--- NOT Resetting temp file\n")); fflush(pArchive->tmpFp); goto bail; @@ -1937,9 +1937,9 @@ if (pArchive->tmpFp != nil) { DBUG(("--- Resetting temp file\n")); /* if we renamed the temp over the original, we need to open a new temp */ - if (pArchive->tmpFp == nil) { + if (pArchive->tmpFp == NULL) { pArchive->tmpFp = fopen(pArchive->tmpPathname, kNuFileOpenReadWriteCreat); - if (pArchive->tmpFp == nil) { + if (pArchive->tmpFp == NULL) { err = errno ? errno : kNuErrFileOpen; Nu_ReportError(NU_BLOB, errno, "Unable to open temp file '%s'", pArchive->tmpPathname); @@ -1957,7 +1957,7 @@ if (pArchive->tmpFp != nil) { err = kNuErrNone; fclose(pArchive->tmpFp); pArchive->tmpFp = fopen(pArchive->tmpPathname, kNuFileOpenWriteTrunc); - if (pArchive->tmpFp == nil) { + if (pArchive->tmpFp == NULL) { err = errno ? errno : kNuErrFileOpen; Nu_ReportError(NU_BLOB, err, "failed truncating tmp file"); goto bail; @@ -1965,7 +1965,7 @@ if (pArchive->tmpFp != nil) { fclose(pArchive->tmpFp); pArchive->tmpFp = fopen(pArchive->tmpPathname, kNuFileOpenReadWriteCreat); - if (pArchive->tmpFp == nil) { + if (pArchive->tmpFp == NULL) { err = errno ? errno : kNuErrFileOpen; Nu_ReportError(NU_BLOB, err, "Unable to open temp file '%s'", pArchive->tmpPathname); @@ -1990,8 +1990,8 @@ Nu_RecordResetUsedFlags(NuArchive* pArchive, NuRecord* pRecord) NuThread* pThread; long idx; - Assert(pArchive != nil); - Assert(pRecord != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); /* these should already be clear */ if (pRecord->pThreadMods) { @@ -2002,7 +2002,7 @@ Nu_RecordResetUsedFlags(NuArchive* pArchive, NuRecord* pRecord) /* these might still be set */ for (idx = 0; idx < (long)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); pThread->used = false; } @@ -2023,7 +2023,7 @@ Nu_ResetUsedFlags(NuArchive* pArchive, NuRecordSet* pRecordSet) NuRecord* pRecord; pRecord = Nu_RecordSet_GetListHead(pRecordSet); - while (pRecord != nil) { + while (pRecord != NULL) { err = Nu_RecordResetUsedFlags(pArchive, pRecord); if (err != kNuErrNone) { Assert(0); @@ -2054,8 +2054,8 @@ Nu_ResetCopySetIfUntouched(NuArchive* pArchive) /* do we have any thread mods or dirty record headers? */ pRecord = Nu_RecordSet_GetListHead(&pArchive->copyRecordSet); - while (pRecord != nil) { - if (pRecord->pThreadMods != nil || pRecord->dirtyHeader) + while (pRecord != NULL) { + if (pRecord->pThreadMods != NULL || pRecord->dirtyHeader) return; pRecord = pRecord->pNext; @@ -2076,9 +2076,9 @@ Nu_AddCommentToFirstNewRecord(NuArchive* pArchive) { NuError err = kNuErrNone; NuRecord* pRecord; - NuThreadMod* pThreadMod = nil; - NuThreadMod* pExistingThreadMod = nil; - NuDataSource* pDataSource = nil; + NuThreadMod* pThreadMod = NULL; + NuThreadMod* pExistingThreadMod = NULL; + NuDataSource* pDataSource = NULL; /* if there aren't any records there, skip this */ if (Nu_RecordSet_IsEmpty(&pArchive->newRecordSet)) @@ -2100,20 +2100,20 @@ Nu_AddCommentToFirstNewRecord(NuArchive* pArchive) /* create a new data source with nothing in it */ err = Nu_DataSourceBuffer_New(kNuThreadFormatUncompressed, - kNuDefaultCommentSize, nil, 0, 0, nil, &pDataSource); + kNuDefaultCommentSize, NULL, 0, 0, NULL, &pDataSource); BailError(err); - Assert(pDataSource != nil); + Assert(pDataSource != NULL); /* create a new ThreadMod */ err = Nu_ThreadModAdd_New(pArchive, kNuThreadIDComment, kNuThreadFormatUncompressed, pDataSource, &pThreadMod); BailError(err); - Assert(pThreadMod != nil); - /*pDataSource = nil;*/ /* ThreadModAdd_New makes a copy */ + Assert(pThreadMod != NULL); + /*pDataSource = NULL;*/ /* ThreadModAdd_New makes a copy */ /* add the thread mod to the record */ Nu_RecordAddThreadMod(pRecord, pThreadMod); - pThreadMod = nil; /* don't free on exit */ + pThreadMod = NULL; /* don't free on exit */ bail: Nu_ThreadModFree(pArchive, pThreadMod); @@ -2148,7 +2148,7 @@ Nu_Flush(NuArchive* pArchive, long* pStatusFlags) DBUG(("--- FLUSH\n")); - if (pStatusFlags == nil) + if (pStatusFlags == NULL) return kNuErrInvalidArg; /* these do get set on error, so clear them no matter what */ *pStatusFlags = 0; @@ -2410,7 +2410,7 @@ Nu_Flush(NuArchive* pArchive, long* pStatusFlags) *pStatusFlags |= kNuFlushSucceeded; /* temp file is fully valid */ fclose(pArchive->archiveFp); - pArchive->archiveFp = nil; + pArchive->archiveFp = NULL; err = Nu_DeleteArchiveFile(pArchive); if (err != kNuErrNone) { @@ -2422,7 +2422,7 @@ Nu_Flush(NuArchive* pArchive, long* pStatusFlags) } fclose(pArchive->tmpFp); - pArchive->tmpFp = nil; + pArchive->tmpFp = NULL; err = Nu_RenameTempToArchive(pArchive); if (err != kNuErrNone) { @@ -2431,9 +2431,9 @@ Nu_Flush(NuArchive* pArchive, long* pStatusFlags) "NOTE: only copy of archive is in '%s'", pArchive->tmpPathname); /* maintain Entry.c semantics (and keep them from removing temp) */ Nu_Free(pArchive, pArchive->archivePathname); - pArchive->archivePathname = nil; + pArchive->archivePathname = NULL; Nu_Free(pArchive, pArchive->tmpPathname); - pArchive->tmpPathname = nil; + pArchive->tmpPathname = NULL; /* bail will put us into read-only mode, which is what we want */ goto bail; } @@ -2441,7 +2441,7 @@ Nu_Flush(NuArchive* pArchive, long* pStatusFlags) bail_reopen: pArchive->archiveFp = fopen(pArchive->archivePathname, kNuFileOpenReadWrite); - if (pArchive->archiveFp == nil) { + if (pArchive->archiveFp == NULL) { err = errno ? errno : -1; Nu_ReportError(NU_BLOB, err, "unable to reopen archive file '%s' after rename", @@ -2545,8 +2545,8 @@ bail: /* last-minute sanity check */ Assert(pArchive->origRecordSet.numRecords == 0 || - (pArchive->origRecordSet.nuRecordHead != nil && - pArchive->origRecordSet.nuRecordTail != nil)); + (pArchive->origRecordSet.nuRecordHead != NULL && + pArchive->origRecordSet.nuRecordTail != NULL)); return err; } @@ -2558,7 +2558,7 @@ bail: NuError Nu_Abort(NuArchive* pArchive) { - Assert(pArchive != nil); + Assert(pArchive != NULL); if (Nu_IsReadOnly(pArchive)) return kNuErrArchiveRO; diff --git a/nufxlib/Deflate.c b/nufxlib/Deflate.c index c5050ec..e9f325b 100644 --- a/nufxlib/Deflate.c +++ b/nufxlib/Deflate.c @@ -53,14 +53,14 @@ Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, NuError err = kNuErrNone; z_stream zstream; int zerr; - Bytef* outbuf = nil; + Bytef* outbuf = NULL; - Assert(pArchive != nil); - Assert(pStraw != nil); - Assert(fp != nil); + Assert(pArchive != NULL); + Assert(pStraw != NULL); + Assert(fp != NULL); Assert(srcLen > 0); - Assert(pDstLen != nil); - Assert(pCrc != nil); + Assert(pDstLen != NULL); + Assert(pCrc != NULL); err = Nu_AllocCompressionBufferIFN(pArchive); if (err != kNuErrNone) @@ -76,7 +76,7 @@ Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, zstream.zalloc = Nu_zalloc; zstream.zfree = Nu_zfree; zstream.opaque = pArchive; - zstream.next_in = nil; + zstream.next_in = NULL; zstream.avail_in = 0; zstream.next_out = outbuf; zstream.avail_out = kNuGenCompBufSize; @@ -159,7 +159,7 @@ z_bail: deflateEnd(&zstream); /* free up any allocated structures */ bail: - if (outbuf != nil) + if (outbuf != NULL) free(outbuf); return err; } @@ -184,10 +184,10 @@ Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord, ulong compRemaining; Bytef* outbuf; - Assert(pArchive != nil); - Assert(pThread != nil); - Assert(infp != nil); - Assert(pFunnel != nil); + Assert(pArchive != NULL); + Assert(pThread != NULL); + Assert(infp != NULL); + Assert(pFunnel != NULL); err = Nu_AllocCompressionBufferIFN(pArchive); if (err != kNuErrNone) @@ -205,7 +205,7 @@ Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord, zstream.zalloc = Nu_zalloc; zstream.zfree = Nu_zfree; zstream.opaque = pArchive; - zstream.next_in = nil; + zstream.next_in = NULL; zstream.avail_in = 0; zstream.next_out = outbuf; zstream.avail_out = kNuGenCompBufSize; @@ -269,7 +269,7 @@ Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord, goto z_bail; } - if (pCrc != nil) + if (pCrc != NULL) *pCrc = Nu_CalcCRC16(*pCrc, outbuf, zstream.next_out - outbuf); zstream.next_out = outbuf; @@ -291,7 +291,7 @@ z_bail: inflateEnd(&zstream); /* free up any allocated structures */ bail: - if (outbuf != nil) + if (outbuf != NULL) free(outbuf); return err; } diff --git a/nufxlib/Entry.c b/nufxlib/Entry.c index f068e30..35baa70 100644 --- a/nufxlib/Entry.c +++ b/nufxlib/Entry.c @@ -48,7 +48,7 @@ Nu_ClearBusy(NuArchive* pArchive) static NuError Nu_PartiallyValidateNuArchive(const NuArchive* pArchive) { - if (pArchive == nil) + if (pArchive == NULL) return kNuErrInvalidArg; pArchive = pArchive; @@ -77,19 +77,19 @@ Nu_ValidateNuArchive(const NuArchive* pArchive) /* make sure the TOC state is consistent */ if (pArchive->haveToc) { if (pArchive->masterHeader.mhTotalRecords != 0) - Assert(Nu_RecordSet_GetListHead(&pArchive->origRecordSet) != nil); + Assert(Nu_RecordSet_GetListHead(&pArchive->origRecordSet) != NULL); Assert(Nu_RecordSet_GetNumRecords(&pArchive->origRecordSet) == pArchive->masterHeader.mhTotalRecords); } else { - Assert(Nu_RecordSet_GetListHead(&pArchive->origRecordSet) == nil); + Assert(Nu_RecordSet_GetListHead(&pArchive->origRecordSet) == NULL); } /* make sure we have open files to work with */ - Assert(pArchive->archivePathname == nil || pArchive->archiveFp != nil); - if (pArchive->archivePathname != nil && pArchive->archiveFp == nil) + Assert(pArchive->archivePathname == NULL || pArchive->archiveFp != NULL); + if (pArchive->archivePathname != NULL && pArchive->archiveFp == NULL) return kNuErrInternal; - Assert(pArchive->tmpPathname == nil || pArchive->tmpFp != nil); - if (pArchive->tmpPathname != nil && pArchive->tmpFp == nil) + Assert(pArchive->tmpPathname == NULL || pArchive->tmpFp != NULL); + if (pArchive->tmpPathname != NULL && pArchive->tmpFp == NULL) return kNuErrInternal; /* further validations */ @@ -109,7 +109,7 @@ NuStreamOpenRO(FILE* infp, NuArchive** ppArchive) { NuError err; - if (infp == nil || ppArchive == nil) + if (infp == NULL || ppArchive == NULL) return kNuErrInvalidArg; err = Nu_StreamOpenRO(infp, (NuArchive**) ppArchive); @@ -328,7 +328,7 @@ NuAddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails, if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) { Nu_SetBusy(pArchive); - err = Nu_AddRecord(pArchive, pFileDetails, pRecordIdx, nil); + err = Nu_AddRecord(pArchive, pFileDetails, pRecordIdx, NULL); Nu_ClearBusy(pArchive); } @@ -496,7 +496,7 @@ NuGetExtraData(NuArchive* pArchive, void** ppData) { NuError err; - if (ppData == nil) + if (ppData == NULL) return kNuErrInvalidArg; if ((err = Nu_PartiallyValidateNuArchive(pArchive)) == kNuErrNone) *ppData = pArchive->extraData; @@ -604,7 +604,7 @@ NuFreeDataSource(NuDataSource* pDataSource) NUFXLIB_API NuError NuDataSourceSetRawCrc(NuDataSource* pDataSource, unsigned short crc) { - if (pDataSource == nil) + if (pDataSource == NULL) return kNuErrInvalidArg; Nu_DataSourceSetRawCrc(pDataSource, crc); return kNuErrNone; @@ -643,7 +643,7 @@ NuFreeDataSink(NuDataSink* pDataSink) NUFXLIB_API NuError NuDataSinkGetOutCount(NuDataSink* pDataSink, ulong* pOutCount) { - if (pDataSink == nil || pOutCount == nil) + if (pDataSink == NULL || pOutCount == NULL) return kNuErrInvalidArg; *pOutCount = Nu_DataSinkGetOutCount(pDataSink); @@ -726,13 +726,13 @@ NuRecordCopyAttr(NuRecordAttr* pRecordAttr, const NuRecord* pRecord) NUFXLIB_API NuError NuRecordCopyThreads(const NuRecord* pNuRecord, NuThread** ppThreads) { - if (pNuRecord == nil || ppThreads == nil) + if (pNuRecord == NULL || ppThreads == NULL) return kNuErrInvalidArg; - Assert(pNuRecord->pThreads != nil); + Assert(pNuRecord->pThreads != NULL); - *ppThreads = Nu_Malloc(nil, pNuRecord->recTotalThreads * sizeof(NuThread)); - if (*ppThreads == nil) + *ppThreads = Nu_Malloc(NULL, pNuRecord->recTotalThreads * sizeof(NuThread)); + if (*ppThreads == NULL) return kNuErrMalloc; memcpy(*ppThreads, pNuRecord->pThreads, @@ -744,7 +744,7 @@ NuRecordCopyThreads(const NuRecord* pNuRecord, NuThread** ppThreads) NUFXLIB_API unsigned long NuRecordGetNumThreads(const NuRecord* pNuRecord) { - if (pNuRecord == nil) + if (pNuRecord == NULL) return -1; return pNuRecord->recTotalThreads; @@ -753,8 +753,8 @@ NuRecordGetNumThreads(const NuRecord* pNuRecord) NUFXLIB_API const NuThread* NuThreadGetByIdx(const NuThread* pNuThread, long idx) { - if (pNuThread == nil) - return nil; + if (pNuThread == NULL) + return NULL; return &pNuThread[idx]; /* can't range-check here */ } diff --git a/nufxlib/Expand.c b/nufxlib/Expand.c index ecf901b..7f44751 100644 --- a/nufxlib/Expand.c +++ b/nufxlib/Expand.c @@ -17,13 +17,13 @@ Nu_ExpandUncompressed(NuArchive* pArchive, const NuRecord* pRecord, const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc) { NuError err; - /*uchar* buffer = nil;*/ + /*uchar* buffer = NULL;*/ ulong count, getsize; - Assert(pArchive != nil); - Assert(pThread != nil); - Assert(infp != nil); - Assert(pFunnel != nil); + Assert(pArchive != NULL); + Assert(pThread != NULL); + Assert(infp != NULL); + Assert(pFunnel != NULL); /* doesn't have to be same size as funnel, but it's not a bad idea */ /*buffer = Nu_Malloc(pArchive, kNuFunnelBufSize);*/ @@ -43,7 +43,7 @@ Nu_ExpandUncompressed(NuArchive* pArchive, const NuRecord* pRecord, err = Nu_FRead(infp, pArchive->compBuf, getsize); BailError(err); - if (pCrc != nil) + if (pCrc != NULL) *pCrc = Nu_CalcCRC16(*pCrc, pArchive->compBuf, getsize); err = Nu_FunnelWrite(pArchive, pFunnel, pArchive->compBuf, getsize); BailError(err); @@ -68,13 +68,13 @@ Nu_ExpandRaw(NuArchive* pArchive, const NuThread* pThread, FILE* infp, NuFunnel* pFunnel) { NuError err; - /*uchar* buffer = nil;*/ + /*uchar* buffer = NULL;*/ ulong count, getsize; - Assert(pArchive != nil); - Assert(pThread != nil); - Assert(infp != nil); - Assert(pFunnel != nil); + Assert(pArchive != NULL); + Assert(pThread != NULL); + Assert(infp != NULL); + Assert(pFunnel != NULL); /* doesn't have to be same size as funnel, but it's not a bad idea */ /*buffer = Nu_Malloc(pArchive, kNuFunnelBufSize);*/ @@ -134,7 +134,7 @@ Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord, * unfortunately, unprotected before v3. */ calcCrc = kNuInitialThreadCRC; - pCalcCrc = nil; + pCalcCrc = NULL; if (Nu_ThreadHasCRC(pRecord->recVersionNumber, NuGetThreadID(pThread)) && !pArchive->valIgnoreCRC) { @@ -205,7 +205,7 @@ Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord, /* * If we have a CRC to check, check it. */ - if (pCalcCrc != nil) { + if (pCalcCrc != NULL) { if (calcCrc != pThread->thThreadCRC) { if (!Nu_ShouldIgnoreBadCRC(pArchive, pRecord, kNuErrBadThreadCRC)) { err = kNuErrBadDataCRC; diff --git a/nufxlib/FileIO.c b/nufxlib/FileIO.c index aa5cc46..107f016 100644 --- a/nufxlib/FileIO.c +++ b/nufxlib/FileIO.c @@ -87,8 +87,8 @@ Nu_DateTimeToGMTSeconds(const NuDateTime* pDateTime, time_t* pWhen) struct tm tmbuf; time_t when; - Assert(pDateTime != nil); - Assert(pWhen != nil); + Assert(pDateTime != NULL); + Assert(pWhen != NULL); tmbuf.tm_sec = pDateTime->second; tmbuf.tm_min = pDateTime->minute; @@ -124,8 +124,8 @@ Nu_GMTSecondsToDateTime(const time_t* pWhen, NuDateTime *pDateTime) { struct tm* ptm; - Assert(pWhen != nil); - Assert(pDateTime != nil); + Assert(pWhen != NULL); + Assert(pDateTime != NULL); #if defined(HAVE_LOCALTIME_R) && defined(USE_REENTRANT_CALLS) struct tm res; @@ -152,11 +152,11 @@ Nu_GMTSecondsToDateTime(const time_t* pWhen, NuDateTime *pDateTime) void Nu_SetCurrentDateTime(NuDateTime* pDateTime) { - Assert(pDateTime != nil); + Assert(pDateTime != NULL); #if defined(UNIX_LIKE) || defined(WINDOWS_LIKE) { - time_t now = time(nil); + time_t now = time(NULL); Nu_GMTSecondsToDateTime(&now, pDateTime); } #else @@ -247,7 +247,7 @@ Nu_IsForkedFile(NuArchive* pArchive, const NuRecord* pRecord) for (i = 0; i < (int)pRecord->recTotalThreads; i++) { pThread = Nu_GetThread(pRecord, i); - Assert(pThread != nil); + Assert(pThread != NULL); threadID = NuMakeThreadID(pThread->thThreadClass,pThread->thThreadKind); if (threadID == kNuThreadIDDataFork) @@ -272,9 +272,9 @@ Nu_GetFileInfo(NuArchive* pArchive, const char* pathname, NuFileInfo* pFileInfo) { NuError err = kNuErrNone; - Assert(pArchive != nil); - Assert(pathname != nil); - Assert(pFileInfo != nil); + Assert(pArchive != NULL); + Assert(pathname != NULL); + Assert(pFileInfo != NULL); pFileInfo->isValid = false; @@ -424,11 +424,11 @@ Nu_FileForkExists(NuArchive* pArchive, const char* pathname, { NuError err = kNuErrNone; - Assert(pArchive != nil); - Assert(pathname != nil); + Assert(pArchive != NULL); + Assert(pathname != NULL); Assert(checkRsrcFork == true || checkRsrcFork == false); - Assert(pExists != nil); - Assert(pFileInfo != nil); + Assert(pExists != NULL); + Assert(pFileInfo != NULL); #if defined(MAC_LIKE) /* @@ -440,7 +440,7 @@ Nu_FileForkExists(NuArchive* pArchive, const char* pathname, /* * Check the data fork. */ - Assert(pArchive->lastFileCreated == nil); + Assert(pArchive->lastFileCreated == NULL); err = Nu_GetFileInfo(pArchive, pathname, pFileInfo); if (err == kNuErrFileNotFound) { err = kNuErrNone; @@ -470,7 +470,7 @@ Nu_FileForkExists(NuArchive* pArchive, const char* pathname, * On Unix and Windows we ignore "isForkedFile" and "checkRsrcFork". * The file must not exist at all. */ - Assert(pArchive->lastFileCreated == nil); + Assert(pArchive->lastFileCreated == NULL); *pExists = true; err = Nu_GetFileInfo(pArchive, pathname, pFileInfo); @@ -515,9 +515,9 @@ Nu_SetFileDates(NuArchive* pArchive, const NuRecord* pRecord, { NuError err = kNuErrNone; - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(pathname != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(pathname != NULL); #if defined(UNIX_LIKE) || defined(WINDOWS_LIKE) { @@ -584,9 +584,9 @@ Nu_SetFileAccess(NuArchive* pArchive, const NuRecord* pRecord, { NuError err = kNuErrNone; - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(pathname != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(pathname != NULL); #if defined(UNIX_LIKE) || defined(WINDOWS_LIKE) /* only need to do something if the file was "locked" */ @@ -636,10 +636,10 @@ Nu_PrepareForWriting(NuArchive* pArchive, const char* pathname, char path[4096]; #endif - Assert(pArchive != nil); - Assert(pathname != nil); + Assert(pArchive != NULL); + Assert(pathname != NULL); Assert(prepRsrc == true || prepRsrc == false); - Assert(pFileInfo != nil); + Assert(pFileInfo != NULL); Assert(pFileInfo->isValid == true); @@ -684,8 +684,8 @@ Nu_Mkdir(NuArchive* pArchive, const char* dir) { NuError err = kNuErrNone; - Assert(pArchive != nil); - Assert(dir != nil); + Assert(pArchive != NULL); + Assert(dir != NULL); #if defined(UNIX_LIKE) if (mkdir(dir, S_IRWXU | S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH) < 0) { @@ -721,11 +721,11 @@ Nu_CreateSubdirIFN(NuArchive* pArchive, const char* pathStart, { NuError err = kNuErrNone; NuFileInfo fileInfo; - char* tmpBuf = nil; + char* tmpBuf = NULL; - Assert(pArchive != nil); - Assert(pathStart != nil); - Assert(pathEnd != nil); + Assert(pArchive != NULL); + Assert(pathStart != NULL); + Assert(pathEnd != NULL); Assert(fssep != '\0'); /* pathStart might have whole path, but we only want up to "pathEnd" */ @@ -736,7 +736,7 @@ Nu_CreateSubdirIFN(NuArchive* pArchive, const char* pathStart, if (err == kNuErrFileNotFound) { /* dir doesn't exist; move up a level and check parent */ pathEnd = strrchr(tmpBuf, fssep); - if (pathEnd != nil) { + if (pathEnd != NULL) { pathEnd--; Assert(pathEnd >= tmpBuf); err = Nu_CreateSubdirIFN(pArchive, tmpBuf, pathEnd, fssep); @@ -777,8 +777,8 @@ Nu_CreatePathIFN(NuArchive* pArchive, const char* pathname, char fssep) const char* pathStart; const char* pathEnd; - Assert(pArchive != nil); - Assert(pathname != nil); + Assert(pArchive != NULL); + Assert(pathname != NULL); Assert(fssep != '\0'); pathStart = pathname; @@ -790,7 +790,7 @@ Nu_CreatePathIFN(NuArchive* pArchive, const char* pathname, char fssep) /* NOTE: not expecting names like "foo/bar/ack/", with terminating fssep */ pathEnd = strrchr(pathStart, fssep); - if (pathEnd == nil) { + if (pathEnd == NULL) { /* no subdirectory components found */ goto bail; } @@ -841,7 +841,7 @@ Nu_OpenFileForWrite(NuArchive* pArchive, const char* pathname, } #endif *pFp = fopen(pathname, kNuFileOpenWriteTrunc); - if (*pFp == nil) + if (*pFp == NULL) return errno ? errno : -1; return kNuErrNone; } @@ -867,20 +867,20 @@ Nu_OpenOutputFile(NuArchive* pArchive, const NuRecord* pRecord, NuErrorStatus errorStatus; NuResult result; - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(pThread != nil); - Assert(newPathname != nil); - Assert(pFp != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(pThread != NULL); + Assert(newPathname != NULL); + Assert(pFp != NULL); /* set up some defaults, in case something goes wrong */ errorStatus.operation = kNuOpExtract; errorStatus.err = kNuErrInternal; errorStatus.sysErr = 0; - errorStatus.message = nil; + errorStatus.message = NULL; errorStatus.pRecord = pRecord; errorStatus.pathname = newPathname; - errorStatus.origPathname = nil; + errorStatus.origPathname = NULL; errorStatus.filenameSeparator = newFssep; /*errorStatus.origArchiveTouched = false;*/ errorStatus.canAbort = true; @@ -926,7 +926,7 @@ Nu_OpenOutputFile(NuArchive* pArchive, const NuRecord* pRecord, if ((pArchive->valOnlyUpdateOlder) && !Nu_IsOlder(&fileInfo.modWhen, &pRecord->recModWhen)) { - if (pArchive->errorHandlerFunc != nil) { + if (pArchive->errorHandlerFunc != NULL) { errorStatus.err = kNuErrNotNewer; result = (*pArchive->errorHandlerFunc)(pArchive, &errorStatus); @@ -962,7 +962,7 @@ Nu_OpenOutputFile(NuArchive* pArchive, const NuRecord* pRecord, * and extracting to a different file. */ if (pArchive->valHandleExisting == kNuMaybeOverwrite) { - if (pArchive->errorHandlerFunc != nil) { + if (pArchive->errorHandlerFunc != NULL) { errorStatus.err = kNuErrFileExists; result = (*pArchive->errorHandlerFunc)(pArchive, &errorStatus); @@ -1005,7 +1005,7 @@ Nu_OpenOutputFile(NuArchive* pArchive, const NuRecord* pRecord, */ if (pArchive->valHandleExisting == kNuMustOverwrite) { DBUG(("+++ can't freshen nonexistent file '%s'\n", newPathname)); - if (pArchive->errorHandlerFunc != nil) { + if (pArchive->errorHandlerFunc != NULL) { errorStatus.err = kNuErrDuplicateNotFound; /* give them a chance to rename */ @@ -1110,9 +1110,9 @@ Nu_CloseOutputFile(NuArchive* pArchive, const NuRecord* pRecord, FILE* fp, { NuError err; - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(fp != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(fp != NULL); fclose(fp); @@ -1169,7 +1169,7 @@ Nu_OpenFileForRead(NuArchive* pArchive, const char* pathname, Boolean openRsrc, FILE** pFp) { *pFp = fopen(pathname, kNuFileOpenReadOnly); - if (*pFp == nil) + if (*pFp == NULL) return errno ? errno : -1; return kNuErrNone; } @@ -1190,9 +1190,9 @@ Nu_OpenInputFile(NuArchive* pArchive, const char* pathname, NuErrorStatus errorStatus; NuResult result; - Assert(pArchive != nil); - Assert(pathname != nil); - Assert(pFp != nil); + Assert(pArchive != NULL); + Assert(pathname != NULL); + Assert(pFp != NULL); #if defined(MAC_LIKE) char path[4096]; @@ -1214,14 +1214,14 @@ retry: if (err == ENOENT) openErr = kNuErrFileNotFound; - if (pArchive->errorHandlerFunc != nil) { + if (pArchive->errorHandlerFunc != NULL) { errorStatus.operation = kNuOpAdd; errorStatus.err = openErr; errorStatus.sysErr = 0; - errorStatus.message = nil; - errorStatus.pRecord = nil; + errorStatus.message = NULL; + errorStatus.pRecord = NULL; errorStatus.pathname = pathname; - errorStatus.origPathname = nil; + errorStatus.origPathname = NULL; errorStatus.filenameSeparator = '\0'; /*errorStatus.origArchiveTouched = false;*/ errorStatus.canAbort = true; @@ -1258,7 +1258,7 @@ retry: bail: if (err == kNuErrNone) { - Assert(*pFp != nil); + Assert(*pFp != NULL); } else { if (err != kNuErrSkipped && err != kNuErrRename && err != kNuErrFileExists) @@ -1332,8 +1332,8 @@ Nu_RenameFile(const char* fromPath, const char* toPath) NuError Nu_FTell(FILE* fp, long* pOffset) { - Assert(fp != nil); - Assert(pOffset != nil); + Assert(fp != NULL); + Assert(pOffset != NULL); errno = 0; *pOffset = ftell(fp); @@ -1350,7 +1350,7 @@ Nu_FTell(FILE* fp, long* pOffset) NuError Nu_FSeek(FILE* fp, long offset, int ptrname) { - Assert(fp != nil); + Assert(fp != NULL); Assert(ptrname == SEEK_SET || ptrname == SEEK_CUR || ptrname == SEEK_END); errno = 0; @@ -1409,9 +1409,9 @@ Nu_CopyFileSection(NuArchive* pArchive, FILE* dstFp, FILE* srcFp, long length) NuError err; long readLen; - Assert(pArchive != nil); - Assert(dstFp != nil); - Assert(srcFp != nil); + Assert(pArchive != NULL); + Assert(dstFp != NULL); + Assert(srcFp != NULL); Assert(length >= 0); /* can be == 0, e.g. empty data fork from HFS */ /* nice big buffer, for speed... could use getc/putc for simplicity */ @@ -1450,7 +1450,7 @@ bail: * Only useful for files < 2GB in size. * * (pArchive is only used for BailError message reporting, so it's okay - * to call here with a nil pointer if the archive isn't open yet.) + * to call here with a NULL pointer if the archive isn't open yet.) */ NuError Nu_GetFileLength(NuArchive* pArchive, FILE* fp, long* pLength) @@ -1458,8 +1458,8 @@ Nu_GetFileLength(NuArchive* pArchive, FILE* fp, long* pLength) NuError err; long oldpos; - Assert(fp != nil); - Assert(pLength != nil); + Assert(fp != NULL); + Assert(pLength != NULL); err = Nu_FTell(fp, &oldpos); BailError(err); diff --git a/nufxlib/Funnel.c b/nufxlib/Funnel.c index 4762d96..c8e86d4 100644 --- a/nufxlib/Funnel.c +++ b/nufxlib/Funnel.c @@ -28,10 +28,10 @@ Nu_ProgressDataInit_Compress(NuArchive* pArchive, NuProgressData* pProgressData, { const char* cp; - Assert(pProgressData != nil); - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(origPathname != nil); + Assert(pProgressData != NULL); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(origPathname != NULL); pProgressData->pRecord = pRecord; @@ -39,7 +39,7 @@ Nu_ProgressDataInit_Compress(NuArchive* pArchive, NuProgressData* pProgressData, pProgressData->pathname = pRecord->filename; cp = strrchr(pRecord->filename, NuGetSepFromSysInfo(pRecord->recFileSysInfo)); - if (cp == nil || *(cp+1) == '\0') + if (cp == NULL || *(cp+1) == '\0') pProgressData->filename = pProgressData->pathname; else pProgressData->filename = cp+1; @@ -53,7 +53,7 @@ Nu_ProgressDataInit_Compress(NuArchive* pArchive, NuProgressData* pProgressData, pProgressData->compress.threadFormat = (NuThreadFormat)-1; - /* ya know... if this is nil, none of the above matters much */ + /* ya know... if this is NULL, none of the above matters much */ pProgressData->progressFunc = pArchive->progressUpdaterFunc; return kNuErrNone; @@ -76,19 +76,19 @@ Nu_ProgressDataInit_Expand(NuArchive* pArchive, NuProgressData* pProgressData, const char* cp; int i; - Assert(pProgressData != nil); - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(newPathname != nil); + Assert(pProgressData != NULL); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(newPathname != NULL); Assert(newFssep != 0); pProgressData->pRecord = pRecord; - pProgressData->expand.pThread = nil; + pProgressData->expand.pThread = NULL; pProgressData->origPathname = pRecord->filename; pProgressData->pathname = newPathname; cp = strrchr(newPathname, newFssep); - if (cp == nil || *(cp+1) == '\0') + if (cp == NULL || *(cp+1) == '\0') pProgressData->filename = newPathname; else pProgressData->filename = cp+1; @@ -116,7 +116,7 @@ Nu_ProgressDataInit_Expand(NuArchive* pArchive, NuProgressData* pProgressData, pProgressData->uncompressedLength = 0; pProgressData->uncompressedProgress = 0; - /* ya know... if this is nil, none of the above matters much */ + /* ya know... if this is NULL, none of the above matters much */ pProgressData->progressFunc = pArchive->progressUpdaterFunc; return kNuErrNone; @@ -132,12 +132,12 @@ Nu_ProgressDataCompressPrep(NuArchive* pArchive, NuStraw* pStraw, { NuProgressData* pProgressData; - Assert(pArchive != nil); - Assert(pStraw != nil); + Assert(pArchive != NULL); + Assert(pStraw != NULL); Assert(sourceLen < 32767*65536); pProgressData = pStraw->pProgress; - if (pProgressData == nil) + if (pProgressData == NULL) return kNuErrNone; pProgressData->uncompressedLength = sourceLen; @@ -157,12 +157,12 @@ Nu_ProgressDataExpandPrep(NuArchive* pArchive, NuFunnel* pFunnel, { NuProgressData* pProgressData; - Assert(pArchive != nil); - Assert(pFunnel != nil); - Assert(pThread != nil); + Assert(pArchive != NULL); + Assert(pFunnel != NULL); + Assert(pThread != NULL); pProgressData = pFunnel->pProgress; - if (pProgressData == nil) + if (pProgressData == NULL) return kNuErrNone; /*pProgressData->compressedLength = pThread->thCompThreadEOF;*/ @@ -205,10 +205,10 @@ Nu_SendInitialProgress(NuArchive* pArchive, NuProgressData* pProgress) { NuResult result; - Assert(pArchive != nil); - Assert(pProgress != nil); + Assert(pArchive != NULL); + Assert(pProgress != NULL); - if (pProgress->progressFunc == nil) + if (pProgress->progressFunc == NULL) return kNuErrNone; pProgress->percentComplete = Nu_ComputePercent( @@ -239,10 +239,10 @@ Nu_FunnelNew(NuArchive* pArchive, NuDataSink* pDataSink, NuValue convertEOL, NuValue convertEOLTo, NuProgressData* pProgress, NuFunnel** ppFunnel) { NuError err = kNuErrNone; - NuFunnel* pFunnel = nil; + NuFunnel* pFunnel = NULL; - Assert(ppFunnel != nil); - Assert(pDataSink != nil); + Assert(ppFunnel != NULL); + Assert(pDataSink != NULL); Assert(convertEOL == kNuConvertOff || convertEOL == kNuConvertOn || convertEOL == kNuConvertAuto); @@ -281,7 +281,7 @@ bail: NuError Nu_FunnelFree(NuArchive* pArchive, NuFunnel* pFunnel) { - if (pFunnel == nil) + if (pFunnel == NULL) return kNuErrNone; #ifdef DEBUG_MSGS @@ -307,7 +307,7 @@ Nu_FunnelFree(NuArchive* pArchive, NuFunnel* pFunnel) void Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, ulong maxBytes) { - Assert(pFunnel != nil); + Assert(pFunnel != NULL); Assert(maxBytes > 0); pFunnel->outMax = maxBytes; @@ -330,7 +330,7 @@ Nu_CheckHighASCII(const NuFunnel* pFunnel, const unsigned char* buffer, { Boolean isHighASCII; - Assert(buffer != nil); + Assert(buffer != NULL); Assert(count != 0); Assert(pFunnel->checkStripHighASCII); @@ -487,9 +487,9 @@ Nu_DetermineConversion(NuFunnel* pFunnel, const uchar* buffer, ulong count) static inline void Nu_FunnelPutBlock(NuFunnel* pFunnel, const uchar* buf, ulong len) { - Assert(pFunnel != nil); - Assert(pFunnel->pDataSink != nil); - Assert(buf != nil); + Assert(pFunnel != NULL); + Assert(pFunnel->pDataSink != NULL); + Assert(buf != NULL); Assert(len > 0); #if 0 @@ -566,7 +566,7 @@ Nu_FunnelWriteConvert(NuFunnel* pFunnel, const uchar* buffer, ulong count) pFunnel->convertEOL = kNuConvertOff; } /* put it where the progress meter can see it */ - if (pFunnel->pProgress != nil) + if (pFunnel->pProgress != NULL) pFunnel->pProgress->expand.convertEOL = pFunnel->convertEOL; } else if (pFunnel->convertEOL == kNuConvertOn) { if (pFunnel->checkStripHighASCII) { @@ -627,7 +627,7 @@ Nu_FunnelWriteConvert(NuFunnel* pFunnel, const uchar* buffer, ulong count) err = Nu_DataSinkGetError(pFunnel->pDataSink); /* update progress counter with pre-LFCR count */ - if (err == kNuErrNone && pFunnel->pProgress != nil) + if (err == kNuErrNone && pFunnel->pProgress != NULL) pFunnel->pProgress->uncompressedProgress += progressCount; return err; @@ -717,9 +717,9 @@ bail: NuError Nu_FunnelSetProgressState(NuFunnel* pFunnel, NuProgressState state) { - Assert(pFunnel != nil); + Assert(pFunnel != NULL); - if (pFunnel->pProgress == nil) + if (pFunnel->pProgress == NULL) return kNuErrNone; pFunnel->pProgress->state = state; @@ -736,15 +736,15 @@ Nu_FunnelSendProgressUpdate(NuArchive* pArchive, NuFunnel* pFunnel) { NuProgressData* pProgress; - Assert(pArchive != nil); - Assert(pFunnel != nil); + Assert(pArchive != NULL); + Assert(pFunnel != NULL); pProgress = pFunnel->pProgress; - if (pProgress == nil) + if (pProgress == NULL) return kNuErrNone; /* no progress meter attached */ /* don't continue if they're not accepting progress messages */ - if (pProgress->progressFunc == nil) + if (pProgress->progressFunc == NULL) return kNuErrNone; /* other than the choice of arguments, it's pretty much the same story */ @@ -758,8 +758,8 @@ Nu_FunnelSendProgressUpdate(NuArchive* pArchive, NuFunnel* pFunnel) Boolean Nu_FunnelGetDoExpand(NuFunnel* pFunnel) { - Assert(pFunnel != nil); - Assert(pFunnel->pDataSink != nil); + Assert(pFunnel != NULL); + Assert(pFunnel->pDataSink != NULL); return Nu_DataSinkGetDoExpand(pFunnel->pDataSink); } @@ -779,10 +779,10 @@ Nu_StrawNew(NuArchive* pArchive, NuDataSource* pDataSource, NuProgressData* pProgress, NuStraw** ppStraw) { NuError err = kNuErrNone; - NuStraw* pStraw = nil; + NuStraw* pStraw = NULL; - Assert(ppStraw != nil); - Assert(pDataSource != nil); + Assert(ppStraw != NULL); + Assert(pDataSource != NULL); pStraw = Nu_Calloc(pArchive, sizeof(*pStraw)); BailAlloc(pStraw); @@ -805,7 +805,7 @@ bail: NuError Nu_StrawFree(NuArchive* pArchive, NuStraw* pStraw) { - if (pStraw == nil) + if (pStraw == NULL) return kNuErrNone; /* we don't own the data source or progress meter */ @@ -821,8 +821,8 @@ Nu_StrawFree(NuArchive* pArchive, NuStraw* pStraw) NuError Nu_StrawSetProgressState(NuStraw* pStraw, NuProgressState state) { - Assert(pStraw != nil); - Assert(pStraw->pProgress != nil); + Assert(pStraw != NULL); + Assert(pStraw->pProgress != NULL); pStraw->pProgress->state = state; @@ -837,15 +837,15 @@ Nu_StrawSendProgressUpdate(NuArchive* pArchive, NuStraw* pStraw) { NuProgressData* pProgress; - Assert(pArchive != nil); - Assert(pStraw != nil); + Assert(pArchive != NULL); + Assert(pStraw != NULL); pProgress = pStraw->pProgress; - if (pProgress == nil) + if (pProgress == NULL) return kNuErrNone; /* no progress meter attached */ /* don't continue if they're not accepting progress messages */ - if (pProgress->progressFunc == nil) + if (pProgress->progressFunc == NULL) return kNuErrNone; /* other than the choice of arguments, it's pretty much the same story */ @@ -861,9 +861,9 @@ Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uchar* buffer, long len) { NuError err; - Assert(pArchive != nil); - Assert(pStraw != nil); - Assert(buffer != nil); + Assert(pArchive != NULL); + Assert(pStraw != NULL); + Assert(buffer != NULL); Assert(len > 0); /* @@ -887,7 +887,7 @@ Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uchar* buffer, long len) * on the previous call. (This assumes that whatever they asked for * last time has already been fully processed.) */ - if (pStraw->pProgress != nil) { + if (pStraw->pProgress != NULL) { pStraw->pProgress->uncompressedProgress = pStraw->lastProgress; pStraw->lastProgress += len; @@ -914,8 +914,8 @@ bail: NuError Nu_StrawRewind(NuArchive* pArchive, NuStraw* pStraw) { - Assert(pStraw != nil); - Assert(pStraw->pDataSource != nil); + Assert(pStraw != NULL); + Assert(pStraw->pDataSource != NULL); pStraw->lastProgress = 0; pStraw->lastDisplayed = 0; diff --git a/nufxlib/Lzc.c b/nufxlib/Lzc.c index ded5168..1db9c72 100644 --- a/nufxlib/Lzc.c +++ b/nufxlib/Lzc.c @@ -587,7 +587,7 @@ Nu_LZC_compress(LZCState* pLzcState, ulong* pDstLen) register INTCODE code; HASH hashf[256]; - Assert(pLzcState->outfp != nil); + Assert(pLzcState->outfp != NULL); pLzcState->maxcode = Maxcode(pLzcState->maxbits); pLzcState->hashsize = Hashsize(pLzcState->maxbits); @@ -771,7 +771,7 @@ Nu_CompressLZC(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, lzcState.outfp = fp; lzcState.uncompRemaining = srcLen; - if (pCrc == nil) { + if (pCrc == NULL) { lzcState.doCalcCRC = false; } else { lzcState.doCalcCRC = true; @@ -800,7 +800,7 @@ Nu_CompressLZC(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, #endif free_array(char,lzcState.sfx, 256); - if (pCrc != nil) + if (pCrc != NULL) *pCrc = lzcState.crc; return err; @@ -911,7 +911,7 @@ Nu_LZC_decompress(LZCState* pLzcState, ulong compressedLen) /*static*/ int maxtoklen = MAXTOKLEN; int flags; - Assert(pLzcState->infp != nil); + Assert(pLzcState->infp != NULL); pLzcState->exit_stat = OK; @@ -1072,7 +1072,7 @@ Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord, lzcState.infp = infp; lzcState.pFunnel = pFunnel; - if (pCrc == nil) { + if (pCrc == NULL) { lzcState.doCalcCRC = false; } else { lzcState.doCalcCRC = true; @@ -1098,7 +1098,7 @@ Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord, #endif free_array(char,lzcState.sfx, 256); - if (pCrc != nil) + if (pCrc != NULL) *pCrc = lzcState.crc; return err; } diff --git a/nufxlib/Lzw.c b/nufxlib/Lzw.c index 14934a9..2b0cb35 100644 --- a/nufxlib/Lzw.c +++ b/nufxlib/Lzw.c @@ -153,8 +153,8 @@ Nu_AllocLZWCompressState(NuArchive* pArchive) LZWCompressState* lzwState; int ic; - Assert(pArchive != nil); - Assert(pArchive->lzwCompressState == nil); + Assert(pArchive != NULL); + Assert(pArchive->lzwCompressState == NULL); /* allocate the general-purpose compression buffer, if needed */ err = Nu_AllocCompressionBufferIFN(pArchive); @@ -162,7 +162,7 @@ Nu_AllocLZWCompressState(NuArchive* pArchive) return err; pArchive->lzwCompressState = Nu_Malloc(pArchive, sizeof(LZWCompressState)); - if (pArchive->lzwCompressState == nil) + if (pArchive->lzwCompressState == NULL) return kNuErrMalloc; /* @@ -261,7 +261,7 @@ Nu_CompressBlockRLE(LZWCompressState* lzwState, int* pRLESize) static void Nu_ClearLZWTable(LZWCompressState* lzwState) { - Assert(lzwState != nil); + Assert(lzwState != NULL); /*DBUG_LZW(("### clear table\n"));*/ @@ -368,8 +368,8 @@ Nu_CompressLZWBlock(LZWCompressState* lzwState, const uchar* inputBuf, uchar* pSuffix = lzwState->suffix; uchar* outBuf = lzwState->lzwBuf; - Assert(lzwState != nil); - Assert(inputBuf != nil); + Assert(lzwState != NULL); + Assert(inputBuf != NULL); Assert(inputCount > 0 && inputCount <= kNuLZWBlockSize); /* make sure nobody has been messing with the types */ Assert(sizeof(pHashFunc[0]) == sizeof(lzwState->hashFunc[0])); @@ -567,23 +567,23 @@ Nu_CompressLZW(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, long compressedLen; Boolean keepLzw; - Assert(pArchive != nil); - Assert(pStraw != nil); - Assert(fp != nil); + Assert(pArchive != NULL); + Assert(pStraw != NULL); + Assert(fp != NULL); Assert(srcLen > 0); - Assert(pDstLen != nil); - Assert(pThreadCrc != nil); + Assert(pDstLen != NULL); + Assert(pThreadCrc != NULL); Assert(isType2 == true || isType2 == false); /* * Do some initialization and set-up. */ - if (pArchive->lzwCompressState == nil) { + if (pArchive->lzwCompressState == NULL) { err = Nu_AllocLZWCompressState(pArchive); BailError(err); } - Assert(pArchive->lzwCompressState != nil); - Assert(pArchive->compBuf != nil); + Assert(pArchive->lzwCompressState != NULL); + Assert(pArchive->compBuf != NULL); lzwState = pArchive->lzwCompressState; lzwState->pArchive = pArchive; @@ -869,8 +869,8 @@ Nu_AllocLZWExpandState(NuArchive* pArchive) { NuError err; - Assert(pArchive != nil); - Assert(pArchive->lzwExpandState == nil); + Assert(pArchive != NULL); + Assert(pArchive->lzwExpandState == NULL); /* allocate the general-purpose compression buffer, if needed */ err = Nu_AllocCompressionBufferIFN(pArchive); @@ -878,7 +878,7 @@ Nu_AllocLZWExpandState(NuArchive* pArchive) return err; pArchive->lzwExpandState = Nu_Malloc(pArchive, sizeof(LZWExpandState)); - if (pArchive->lzwExpandState == nil) + if (pArchive->lzwExpandState == NULL) return kNuErrMalloc; return kNuErrNone; } @@ -990,7 +990,7 @@ Nu_ExpandLZW1(LZWExpandState* lzwState, uint expectedLen) uchar* outbufend; uchar* stackPtr; - Assert(lzwState != nil); + Assert(lzwState != NULL); Assert(expectedLen > 0 && expectedLen <= kNuLZWBlockSize); inbuf = lzwState->dataPtr; @@ -1094,7 +1094,7 @@ Nu_ExpandLZW2(LZWExpandState* lzwState, uint expectedLen, /*DBUG_LZW(("### LZW/2 block start (compIn=%d, rleOut=%d, entry=0x%04x)\n", expectedInputUsed, expectedLen, lzwState->entry));*/ - Assert(lzwState != nil); + Assert(lzwState != NULL); Assert(expectedLen > 0 && expectedLen <= kNuLZWBlockSize); inbuf = lzwState->dataPtr; @@ -1298,7 +1298,7 @@ Nu_GetHeaderByte(LZWExpandState* lzwState) * This manages the input data buffer, passing chunks of compressed data * into the appropriate expansion function. * - * Pass in nil for "pThreadCrc" if no thread CRC is desired. Otherwise, + * Pass in NULL for "pThreadCrc" if no thread CRC is desired. Otherwise, * "*pThreadCrc" should already be set to its initial value. On exit it * will contain the CRC of the uncompressed data. */ @@ -1311,20 +1311,20 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord, LZWExpandState* lzwState; ulong compRemaining, uncompRemaining, minSize; - Assert(pArchive != nil); - Assert(pThread != nil); - Assert(infp != nil); - Assert(pFunnel != nil); + Assert(pArchive != NULL); + Assert(pThread != NULL); + Assert(infp != NULL); + Assert(pFunnel != NULL); /* * Do some initialization and set-up. */ - if (pArchive->lzwExpandState == nil) { + if (pArchive->lzwExpandState == NULL) { err = Nu_AllocLZWExpandState(pArchive); BailError(err); } - Assert(pArchive->lzwExpandState != nil); - Assert(pArchive->compBuf != nil); + Assert(pArchive->lzwExpandState != NULL); + Assert(pArchive->compBuf != NULL); lzwState = pArchive->lzwExpandState; lzwState->pArchive = pArchive; @@ -1368,7 +1368,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord, compRemaining -= 2; lzwState->dataInBuffer = 0; - lzwState->dataPtr = nil; + lzwState->dataPtr = NULL; /* reset pointers */ lzwState->entry = kNuLZWFirstCode; /* 0x0101 */ @@ -1409,7 +1409,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord, * the buffer. */ if (lzwState->dataInBuffer) { - Assert(lzwState->dataPtr != nil); + Assert(lzwState->dataPtr != NULL); Assert(pArchive->compBuf != lzwState->dataPtr); memmove(pArchive->compBuf, lzwState->dataPtr, lzwState->dataInBuffer); @@ -1476,7 +1476,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord, writeLen = kNuLZWBlockSize; #ifndef NDEBUG - writeBuf = nil; + writeBuf = NULL; #endif /* @@ -1537,7 +1537,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord, lzwState->resetFix = false; } - Assert(writeBuf != nil); + Assert(writeBuf != NULL); /* * Compute the CRC of the uncompressed data, and write it. For @@ -1547,7 +1547,7 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord, * See commentary in the compression code for why we have to * compute two CRCs for LZW/1. */ - if (pThreadCrc != nil) { + if (pThreadCrc != NULL) { *pThreadCrc = Nu_CalcCRC16(*pThreadCrc, writeBuf, writeLen); } if (!isType2) { diff --git a/nufxlib/MiscStuff.h b/nufxlib/MiscStuff.h index 2e8a376..c6d5a11 100644 --- a/nufxlib/MiscStuff.h +++ b/nufxlib/MiscStuff.h @@ -42,11 +42,7 @@ int Nu_strncasecmp(const char *s1, const char *s2, size_t n); * Misc types. */ -#include - -#define nil NULL /* I can't seem to stop typing 'nil' now */ - -typedef uchar Boolean; +typedef unsigned char Boolean; #define false (0) #define true (!false) diff --git a/nufxlib/MiscUtils.c b/nufxlib/MiscUtils.c index 9d6a7c6..9f56c04 100644 --- a/nufxlib/MiscUtils.c +++ b/nufxlib/MiscUtils.c @@ -12,7 +12,7 @@ /* * Big fat hairy global. Unfortunately this is unavoidable. */ -NuCallback gNuGlobalErrorMessageHandler = nil; +NuCallback gNuGlobalErrorMessageHandler = NULL; static const char* kNufxLibName = "nufxlib"; @@ -32,7 +32,7 @@ Nu_StrError(NuError err) * to return this. * * An easier solution, should this present a problem for someone, would - * be to have the function return nil or "unknown error" when the + * be to have the function return NULL or "unknown error" when the * error value isn't recognized. I'd recommend leaving it as-is for * debug builds, though, as it's helpful to know *which* error is not * recognized. @@ -200,11 +200,11 @@ Nu_StrError(NuError err) * Similar to perror(), but takes the error as an argument, and knows * about NufxLib errors as well as system errors. * - * Depending on the compiler, "file", "line", and "function" may be nil/zero. + * Depending on the compiler, "file", "line", and "function" may be NULL/zero. * - * Calling here with "pArchive"==nil is allowed, but should only be done + * Calling here with "pArchive"==NULL is allowed, but should only be done * if the archive is inaccessible (perhaps because it failed to open). We - * can't invoke the error message callback if the pointer is nil. + * can't invoke the error message callback if the pointer is NULL. */ void Nu_ReportError(NuArchive* pArchive, const char* file, int line, @@ -219,7 +219,7 @@ Nu_ReportError(NuArchive* pArchive, const char* file, int line, int cc; #endif - Assert(format != nil); + Assert(format != NULL); va_start(args, format); @@ -247,28 +247,28 @@ Nu_ReportError(NuArchive* pArchive, const char* file, int line, strcpy(buf+count, ": "); count += 2; - msg = nil; + msg = NULL; if (err >= 0) msg = strerror(err); - if (msg == nil) + if (msg == NULL) msg = Nu_StrError(err); #if defined(HAVE_SNPRINTF) && defined(SNPRINTF_DECLARED) - if (msg == nil) + if (msg == NULL) snprintf(buf+count, sizeof(buf) - count, "(unknown err=%d)", err); else snprintf(buf+count, sizeof(buf) - count, "%s", msg); #else #ifdef SPRINTF_RETURNS_INT - if (msg == nil) + if (msg == NULL) cc = sprintf(buf+count, "(unknown err=%d)", err); else cc = sprintf(buf+count, "%s", msg); Assert(cc > 0); count += cc; #else - if (msg == nil) + if (msg == NULL) sprintf(buf+count, "(unknown err=%d)", err); else sprintf(buf+count, "%s", msg); @@ -284,8 +284,8 @@ Nu_ReportError(NuArchive* pArchive, const char* file, int line, Assert(count <= kNuHeftyBufSize); #endif - if ((pArchive != nil && pArchive->messageHandlerFunc == nil) || - (pArchive == nil && gNuGlobalErrorMessageHandler == nil)) + if ((pArchive != NULL && pArchive->messageHandlerFunc == NULL) || + (pArchive == NULL && gNuGlobalErrorMessageHandler == NULL)) { if (isDebug) { fprintf(stderr, "%s: [%s:%d %s] %s\n", kNufxLibName, @@ -301,7 +301,7 @@ Nu_ReportError(NuArchive* pArchive, const char* file, int line, errorMessage.line = line; errorMessage.function = function; - if (pArchive == nil) + if (pArchive == NULL) (void) (*gNuGlobalErrorMessageHandler)(pArchive, &errorMessage); else (void) (*pArchive->messageHandlerFunc)(pArchive, &errorMessage); @@ -329,7 +329,7 @@ Nu_Malloc(NuArchive* pArchive, size_t size) Assert(size > 0); _result = malloc(size); - if (_result == nil) { + if (_result == NULL) { Nu_ReportError(NU_BLOB, kNuErrMalloc, "malloc(%u) failed", (uint) size); DebugAbort(); /* leave a core dump if we're built for it */ } @@ -350,10 +350,10 @@ Nu_Realloc(NuArchive* pArchive, void* ptr, size_t size) { void* _result; - Assert(ptr != nil); /* disallow this usage */ + Assert(ptr != NULL); /* disallow this usage */ Assert(size > 0); /* disallow this usage */ _result = realloc(ptr, size); - if (_result == nil) { + if (_result == NULL) { Nu_ReportError(NU_BLOB, kNuErrMalloc, "realloc(%u) failed",(uint) size); DebugAbort(); /* leave a core dump if we're built for it */ } @@ -363,7 +363,7 @@ Nu_Realloc(NuArchive* pArchive, void* ptr, size_t size) void Nu_Free(NuArchive* pArchive, void* ptr) { - if (ptr != nil) + if (ptr != NULL) free(ptr); } #endif @@ -376,7 +376,7 @@ NuResult Nu_InternalFreeCallback(NuArchive* pArchive, void* args) { DBUG(("+++ internal free callback 0x%08lx\n", (long) args)); - Nu_Free(nil, args); + Nu_Free(NULL, args); return kNuOK; } diff --git a/nufxlib/NufxLib.h b/nufxlib/NufxLib.h index 0dc4dbc..eb16f44 100644 --- a/nufxlib/NufxLib.h +++ b/nufxlib/NufxLib.h @@ -676,7 +676,7 @@ typedef struct NuErrorMessage { /* these identify where the message originated if lib built w/debug set */ const char* file; /* source file */ int line; /* line number */ - const char* function; /* function name (might be nil) */ + const char* function; /* function name (might be NULL) */ } NuErrorMessage; diff --git a/nufxlib/NufxLibPriv.h b/nufxlib/NufxLibPriv.h index 3e59030..928b6c5 100644 --- a/nufxlib/NufxLibPriv.h +++ b/nufxlib/NufxLibPriv.h @@ -400,7 +400,7 @@ union NuDataSink { char* pathname; /* file to open */ char fssep; - /* temp storage; must be nil except when processing in library */ + /* temp storage; must be NULL except when processing in library */ FILE* fp; } toFile; @@ -469,13 +469,13 @@ union NuDataSink { goto bail; \ } #define BailNil(val) { \ - if ((val) == nil) { \ + if ((val) == NULL) { \ err = kNuErrUnexpectedNil; \ BailError(err); \ } \ } #define BailAlloc(val) { \ - if ((val) == nil) { \ + if ((val) == NULL) { \ err = kNuErrMalloc; \ BailError(err); \ } \ @@ -688,7 +688,7 @@ void Nu_ReportError(NuArchive* pArchive, const char* file, int line, # define Nu_Malloc(archive, size) malloc(size) # define Nu_Calloc(archive, size) calloc(1, size) # define Nu_Realloc(archive, ptr, size) realloc(ptr, size) -# define Nu_Free(archive, ptr) (ptr != nil ? free(ptr) : (void)0) +# define Nu_Free(archive, ptr) (ptr != NULL ? free(ptr) : (void)0) #else void* Nu_Malloc(NuArchive* pArchive, size_t size); void* Nu_Calloc(NuArchive* pArchive, size_t size); @@ -822,7 +822,7 @@ THREAD_INLINE NuThread* Nu_GetThread(const NuRecord* pRecord, int idx) { if (idx >= (int)pRecord->recTotalThreads) - return nil; + return NULL; else return &pRecord->pThreads[idx]; } diff --git a/nufxlib/Record.c b/nufxlib/Record.c index 300cf2d..aa09f24 100644 --- a/nufxlib/Record.c +++ b/nufxlib/Record.c @@ -29,18 +29,18 @@ static const uchar kNufxID[kNufxIDLen] = { 0x4e, 0xf5, 0x46, 0xd8 }; static NuError Nu_InitRecordContents(NuArchive* pArchive, NuRecord* pRecord) { - Assert(pRecord != nil); + Assert(pRecord != NULL); DebugFill(pRecord, sizeof(*pRecord)); - pRecord->recOptionList = nil; - pRecord->extraBytes = nil; - pRecord->recFilename = nil; - pRecord->threadFilename = nil; - pRecord->newFilename = nil; - pRecord->pThreads = nil; - pRecord->pNext = nil; - pRecord->pThreadMods = nil; + pRecord->recOptionList = NULL; + pRecord->extraBytes = NULL; + pRecord->recFilename = NULL; + pRecord->threadFilename = NULL; + pRecord->newFilename = NULL; + pRecord->pThreads = NULL; + pRecord->pNext = NULL; + pRecord->pThreadMods = NULL; pRecord->dirtyHeader = false; pRecord->dropRecFilename = false; pRecord->isBadMac = false; @@ -54,10 +54,10 @@ Nu_InitRecordContents(NuArchive* pArchive, NuRecord* pRecord) static NuError Nu_RecordNew(NuArchive* pArchive, NuRecord** ppRecord) { - Assert(ppRecord != nil); + Assert(ppRecord != NULL); *ppRecord = Nu_Malloc(pArchive, sizeof(**ppRecord)); - if (*ppRecord == nil) + if (*ppRecord == NULL) return kNuErrMalloc; return Nu_InitRecordContents(pArchive, *ppRecord); @@ -70,7 +70,7 @@ Nu_RecordNew(NuArchive* pArchive, NuRecord** ppRecord) static NuError Nu_FreeRecordContents(NuArchive* pArchive, NuRecord* pRecord) { - Assert(pRecord != nil); + Assert(pRecord != NULL); Nu_Free(pArchive, pRecord->recOptionList); Nu_Free(pArchive, pRecord->extraBytes); @@ -92,7 +92,7 @@ Nu_FreeRecordContents(NuArchive* pArchive, NuRecord* pRecord) static NuError Nu_RecordFree(NuArchive* pArchive, NuRecord* pRecord) { - if (pRecord == nil) + if (pRecord == NULL) return kNuErrNone; (void) Nu_FreeRecordContents(pArchive, pRecord); @@ -112,16 +112,16 @@ CopySizedField(NuArchive* pArchive, void* vppDst, const void* vpSrc, uint len) uchar** ppDst = vppDst; const uchar* pSrc = vpSrc; - Assert(ppDst != nil); + Assert(ppDst != NULL); if (len) { - Assert(pSrc != nil); + Assert(pSrc != NULL); *ppDst = Nu_Malloc(pArchive, len); BailAlloc(*ppDst); memcpy(*ppDst, pSrc, len); } else { - Assert(pSrc == nil); - *ppDst = nil; + Assert(pSrc == NULL); + *ppDst = NULL; } bail: @@ -150,9 +150,9 @@ Nu_RecordCopy(NuArchive* pArchive, NuRecord** ppDst, const NuRecord* pSrc) CopySizedField(pArchive, &pDst->recFilename, pSrc->recFilename, pSrc->recFilenameLength == 0 ? 0 : pSrc->recFilenameLength+1); CopySizedField(pArchive, &pDst->threadFilename, pSrc->threadFilename, - pSrc->threadFilename == nil ? 0 : strlen(pSrc->threadFilename) +1); + pSrc->threadFilename == NULL ? 0 : strlen(pSrc->threadFilename) +1); CopySizedField(pArchive, &pDst->newFilename, pSrc->newFilename, - pSrc->newFilename == nil ? 0 : strlen(pSrc->newFilename) +1); + pSrc->newFilename == NULL ? 0 : strlen(pSrc->newFilename) +1); CopySizedField(pArchive, &pDst->pThreads, pSrc->pThreads, pSrc->recTotalThreads * sizeof(*pDst->pThreads)); @@ -166,10 +166,10 @@ Nu_RecordCopy(NuArchive* pArchive, NuRecord** ppDst, const NuRecord* pSrc) else pDst->filename = pSrc->filename; /* probably static kDefault value */ - pDst->pNext = nil; + pDst->pNext = NULL; /* these only hold for copy from orig... may need to remove */ - Assert(pSrc->pThreadMods == nil); + Assert(pSrc->pThreadMods == NULL); Assert(!pSrc->dirtyHeader); bail: @@ -194,20 +194,20 @@ Nu_RecordAddThreadMod(NuRecord* pRecord, NuThreadMod* pThreadMod) { NuThreadMod* pScanThreadMod; - Assert(pRecord != nil); - Assert(pThreadMod != nil); + Assert(pRecord != NULL); + Assert(pThreadMod != NULL); - if (pRecord->pThreadMods == nil) { + if (pRecord->pThreadMods == NULL) { pRecord->pThreadMods = pThreadMod; } else { pScanThreadMod = pRecord->pThreadMods; - while (pScanThreadMod->pNext != nil) + while (pScanThreadMod->pNext != NULL) pScanThreadMod = pScanThreadMod->pNext; pScanThreadMod->pNext = pThreadMod; } - pThreadMod->pNext = nil; + pThreadMod->pNext = NULL; } @@ -230,12 +230,12 @@ Nu_RecordIsEmpty(NuArchive* pArchive, const NuRecord* pRecord) const NuThreadMod* pThreadMod; int numThreads; - Assert(pRecord != nil); + Assert(pRecord != NULL); numThreads = pRecord->recTotalThreads; pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { switch (pThreadMod->entry.kind) { case kNuThreadModAdd: case kNuThreadModUpdate: @@ -278,7 +278,7 @@ Nu_RecordIsEmpty(NuArchive* pArchive, const NuRecord* pRecord) Boolean Nu_RecordSet_GetLoaded(const NuRecordSet* pRecordSet) { - Assert(pRecordSet != nil); + Assert(pRecordSet != NULL); return pRecordSet->loaded; } @@ -349,15 +349,15 @@ Nu_RecordSet_FreeAllRecords(NuArchive* pArchive, NuRecordSet* pRecordSet) NuRecord* pNextRecord; if (!pRecordSet->loaded) { - Assert(pRecordSet->nuRecordHead == nil); - Assert(pRecordSet->nuRecordTail == nil); + Assert(pRecordSet->nuRecordHead == NULL); + Assert(pRecordSet->nuRecordTail == NULL); Assert(pRecordSet->numRecords == 0); return kNuErrNone; } DBUG(("+++ FreeAllRecords\n")); pRecord = pRecordSet->nuRecordHead; - while (pRecord != nil) { + while (pRecord != NULL) { pNextRecord = pRecord->pNext; err = Nu_RecordFree(pArchive, pRecord); @@ -366,7 +366,7 @@ Nu_RecordSet_FreeAllRecords(NuArchive* pArchive, NuRecordSet* pRecordSet) pRecord = pNextRecord; } - pRecordSet->nuRecordHead = pRecordSet->nuRecordTail = nil; + pRecordSet->nuRecordHead = pRecordSet->nuRecordTail = NULL; pRecordSet->numRecords = 0; pRecordSet->loaded = false; @@ -381,20 +381,20 @@ bail: static NuError Nu_RecordSet_AddRecord(NuRecordSet* pRecordSet, NuRecord* pRecord) { - Assert(pRecordSet != nil); - Assert(pRecord != nil); + Assert(pRecordSet != NULL); + Assert(pRecord != NULL); - /* if one is nil, both must be nil */ - Assert(pRecordSet->nuRecordHead == nil || pRecordSet->nuRecordTail != nil); - Assert(pRecordSet->nuRecordTail == nil || pRecordSet->nuRecordHead != nil); + /* if one is NULL, both must be NULL */ + Assert(pRecordSet->nuRecordHead == NULL || pRecordSet->nuRecordTail != NULL); + Assert(pRecordSet->nuRecordTail == NULL || pRecordSet->nuRecordHead != NULL); - if (pRecordSet->nuRecordHead == nil) { + if (pRecordSet->nuRecordHead == NULL) { /* empty list */ pRecordSet->nuRecordHead = pRecordSet->nuRecordTail = pRecord; pRecordSet->loaded = true; Assert(!pRecordSet->numRecords); } else { - pRecord->pNext = nil; + pRecord->pNext = NULL; pRecordSet->nuRecordTail->pNext = pRecord; pRecordSet->nuRecordTail = pRecord; } @@ -420,9 +420,9 @@ Nu_RecordSet_DeleteRecordPtr(NuArchive* pArchive, NuRecordSet* pRecordSet, NuError err; NuRecord* pRecord; - Assert(pRecordSet != nil); - Assert(ppRecord != nil); - Assert(*ppRecord != nil); + Assert(pRecordSet != NULL); + Assert(ppRecord != NULL); + Assert(*ppRecord != NULL); /* save a copy of the record we're freeing */ pRecord = *ppRecord; @@ -433,21 +433,21 @@ Nu_RecordSet_DeleteRecordPtr(NuArchive* pArchive, NuRecordSet* pRecordSet, /* if we're deleting the tail, we have to find the "new" last entry */ if (pRecord == pRecordSet->nuRecordTail) { - if (pRecordSet->nuRecordHead == nil) { + if (pRecordSet->nuRecordHead == NULL) { /* this was the last entry; we're done */ - pRecordSet->nuRecordTail = nil; + pRecordSet->nuRecordTail = NULL; } else { /* walk through the list... delete bottom-up will be slow! */ pRecordSet->nuRecordTail = pRecordSet->nuRecordHead; - while (pRecordSet->nuRecordTail->pNext != nil) + while (pRecordSet->nuRecordTail->pNext != NULL) pRecordSet->nuRecordTail = pRecordSet->nuRecordTail->pNext; } } if (pRecordSet->numRecords) - Assert(pRecordSet->nuRecordHead!=nil && pRecordSet->nuRecordTail!=nil); + Assert(pRecordSet->nuRecordHead!=NULL && pRecordSet->nuRecordTail!=NULL); else - Assert(pRecordSet->nuRecordHead==nil && pRecordSet->nuRecordTail==nil); + Assert(pRecordSet->nuRecordHead==NULL && pRecordSet->nuRecordTail==NULL); err = Nu_RecordFree(pArchive, pRecord); return err; @@ -464,8 +464,8 @@ Nu_RecordSet_DeleteRecord(NuArchive* pArchive, NuRecordSet* pRecordSet, NuRecord** ppRecord; ppRecord = Nu_RecordSet_GetListHeadPtr(pRecordSet); - Assert(ppRecord != nil); - Assert(*ppRecord != nil); + Assert(ppRecord != NULL); + Assert(*ppRecord != NULL); /* look for the record, so we can update his neighbors */ /* (this also ensures that the record really is in the set we think it is)*/ @@ -498,8 +498,8 @@ Nu_RecordSet_Clone(NuArchive* pArchive, NuRecordSet* pDstSet, const NuRecord* pSrcRecord; NuRecord* pDstRecord; - Assert(pDstSet != nil); - Assert(pSrcSet != nil); + Assert(pDstSet != NULL); + Assert(pSrcSet != NULL); Assert(Nu_RecordSet_GetLoaded(pDstSet) == false); Assert(Nu_RecordSet_GetLoaded(pSrcSet) == true); @@ -509,7 +509,7 @@ Nu_RecordSet_Clone(NuArchive* pArchive, NuRecordSet* pDstSet, /* copy each record over */ pSrcRecord = pSrcSet->nuRecordHead; - while (pSrcRecord != nil) { + while (pSrcRecord != NULL) { err = Nu_RecordCopy(pArchive, &pDstRecord, pSrcRecord); BailError(err); err = Nu_RecordSet_AddRecord(pDstSet, pDstRecord); @@ -539,17 +539,17 @@ Nu_RecordSet_MoveAllRecords(NuArchive* pArchive, NuRecordSet* pDstSet, { NuError err = kNuErrNone; - Assert(pDstSet != nil); - Assert(pSrcSet != nil); + Assert(pDstSet != NULL); + Assert(pSrcSet != NULL); /* move records over */ if (Nu_RecordSet_GetNumRecords(pSrcSet)) { Assert(pSrcSet->loaded); - Assert(pSrcSet->nuRecordHead != nil); - Assert(pSrcSet->nuRecordTail != nil); - if (pDstSet->nuRecordHead == nil) { + Assert(pSrcSet->nuRecordHead != NULL); + Assert(pSrcSet->nuRecordTail != NULL); + if (pDstSet->nuRecordHead == NULL) { /* empty dst list */ - Assert(pDstSet->nuRecordTail == nil); + Assert(pDstSet->nuRecordTail == NULL); pDstSet->nuRecordHead = pSrcSet->nuRecordHead; pDstSet->nuRecordTail = pSrcSet->nuRecordTail; pDstSet->numRecords = pSrcSet->numRecords; @@ -557,22 +557,22 @@ Nu_RecordSet_MoveAllRecords(NuArchive* pArchive, NuRecordSet* pDstSet, } else { /* append to dst list */ Assert(pDstSet->loaded); - Assert(pDstSet->nuRecordTail != nil); + Assert(pDstSet->nuRecordTail != NULL); pDstSet->nuRecordTail->pNext = pSrcSet->nuRecordHead; pDstSet->nuRecordTail = pSrcSet->nuRecordTail; pDstSet->numRecords += pSrcSet->numRecords; } } else { /* no records in src set */ - Assert(pSrcSet->nuRecordHead == nil); - Assert(pSrcSet->nuRecordTail == nil); + Assert(pSrcSet->nuRecordHead == NULL); + Assert(pSrcSet->nuRecordTail == NULL); if (pSrcSet->loaded) pDstSet->loaded = true; } /* nuke all pointers in original list */ - pSrcSet->nuRecordHead = pSrcSet->nuRecordTail = nil; + pSrcSet->nuRecordHead = pSrcSet->nuRecordTail = NULL; pSrcSet->numRecords = 0; pSrcSet->loaded = false; @@ -590,7 +590,7 @@ Nu_RecordSet_FindByIdx(const NuRecordSet* pRecordSet, NuRecordIdx recIdx, NuRecord* pRecord; pRecord = pRecordSet->nuRecordHead; - while (pRecord != nil) { + while (pRecord != NULL) { if (pRecord->recordIdx == recIdx) { *ppRecord = pRecord; return kNuErrNone; @@ -614,7 +614,7 @@ Nu_RecordSet_FindByThreadIdx(NuRecordSet* pRecordSet, NuThreadIdx threadIdx, NuRecord* pRecord; pRecord = Nu_RecordSet_GetListHead(pRecordSet); - while (pRecord != nil) { + while (pRecord != NULL) { err = Nu_FindThreadByIdx(pRecord, threadIdx, ppThread); if (err == kNuErrNone) { *ppRecord = pRecord; @@ -623,7 +623,7 @@ Nu_RecordSet_FindByThreadIdx(NuRecordSet* pRecordSet, NuThreadIdx threadIdx, pRecord = pRecord->pNext; } - Assert(err != kNuErrNone || (*ppRecord != nil && *ppThread != nil)); + Assert(err != kNuErrNone || (*ppRecord != NULL && *ppThread != NULL)); return err; } @@ -670,13 +670,13 @@ Nu_RecordSet_FindByName(const NuRecordSet* pRecordSet, const char* name, { NuRecord* pRecord; - Assert(pRecordSet != nil); + Assert(pRecordSet != NULL); Assert(pRecordSet->loaded); - Assert(name != nil); - Assert(ppRecord != nil); + Assert(name != NULL); + Assert(ppRecord != NULL); pRecord = pRecordSet->nuRecordHead; - while (pRecord != nil) { + while (pRecord != NULL) { if (Nu_CompareRecordNames(pRecord->filename, name) == 0) { *ppRecord = pRecord; return kNuErrNone; @@ -701,22 +701,22 @@ Nu_RecordSet_ReverseFindByName(const NuRecordSet* pRecordSet, const char* name, NuRecord** ppRecord) { NuRecord* pRecord; - NuRecord* pFoundRecord = nil; + NuRecord* pFoundRecord = NULL; - Assert(pRecordSet != nil); + Assert(pRecordSet != NULL); Assert(pRecordSet->loaded); - Assert(name != nil); - Assert(ppRecord != nil); + Assert(name != NULL); + Assert(ppRecord != NULL); pRecord = pRecordSet->nuRecordHead; - while (pRecord != nil) { + while (pRecord != NULL) { if (Nu_CompareRecordNames(pRecord->filename, name) == 0) pFoundRecord = pRecord; pRecord = pRecord->pNext; } - if (pFoundRecord != nil) { + if (pFoundRecord != NULL) { *ppRecord = pFoundRecord; return kNuErrNone; } @@ -741,13 +741,13 @@ Nu_RecordSet_ReplaceRecord(NuArchive* pArchive, NuRecordSet* pBadSet, NuError err; NuRecord* pGoodRecord; NuRecord* pSiblingRecord; - NuRecord* pNewRecord = nil; + NuRecord* pNewRecord = NULL; - Assert(pArchive != nil); - Assert(pBadSet != nil); - Assert(pBadRecord != nil); - Assert(pGoodSet != nil); - Assert(ppNewRecord != nil); + Assert(pArchive != NULL); + Assert(pBadSet != NULL); + Assert(pBadRecord != NULL); + Assert(pGoodSet != NULL); + Assert(ppNewRecord != NULL); /* * Find a record in "pGoodSet" that has the same record index as @@ -775,10 +775,10 @@ Nu_RecordSet_ReplaceRecord(NuArchive* pArchive, NuRecordSet* pBadSet, else { /* find the record that points to pBadRecord */ pSiblingRecord = pBadSet->nuRecordHead; - while (pSiblingRecord->pNext != pBadRecord && pSiblingRecord != nil) + while (pSiblingRecord->pNext != pBadRecord && pSiblingRecord != NULL) pSiblingRecord = pSiblingRecord->pNext; - if (pSiblingRecord == nil) { + if (pSiblingRecord == NULL) { /* looks like "pBadRecord" wasn't part of "pBadSet" after all */ Assert(0); err = kNuErrInternal; @@ -792,10 +792,10 @@ Nu_RecordSet_ReplaceRecord(NuArchive* pArchive, NuRecordSet* pBadSet, BailError(err); *ppNewRecord = pNewRecord; - pNewRecord = nil; /* don't free */ + pNewRecord = NULL; /* don't free */ bail: - if (pNewRecord != nil) + if (pNewRecord != NULL) Nu_RecordFree(pArchive, pNewRecord); return err; } @@ -820,16 +820,16 @@ Nu_ShouldIgnoreBadCRC(NuArchive* pArchive, const NuRecord* pRecord, NuError err) Assert(pArchive->valIgnoreCRC == false); - if (pArchive->errorHandlerFunc != nil) { + if (pArchive->errorHandlerFunc != NULL) { errorStatus.operation = kNuOpTest; /* mostly accurate */ errorStatus.err = err; errorStatus.sysErr = 0; - errorStatus.message = nil; + errorStatus.message = NULL; errorStatus.pRecord = pRecord; - errorStatus.pathname = nil; - errorStatus.origPathname = nil; + errorStatus.pathname = NULL; + errorStatus.origPathname = NULL; errorStatus.filenameSeparator = 0; - if (pRecord != nil) { + if (pRecord != NULL) { errorStatus.pathname = pRecord->filename; errorStatus.filenameSeparator = NuGetSepFromSysInfo(pRecord->recFileSysInfo); @@ -880,17 +880,17 @@ Nu_ReadRecordHeader(NuArchive* pArchive, NuRecord* pRecord) FILE* fp; int bytesRead; - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(pRecord->pThreads == nil); - Assert(pRecord->pNext == nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(pRecord->pThreads == NULL); + Assert(pRecord->pNext == NULL); fp = pArchive->archiveFp; pRecord->recordIdx = Nu_GetNextRecordIdx(pArchive); /* points to whichever filename storage we like best */ - pRecord->filename = nil; + pRecord->filename = NULL; pRecord->fileOffset = pArchive->currentOffset; (void) Nu_ReadBytes(pArchive, fp, pRecord->recNufxID, kNufxIDLen); @@ -988,7 +988,7 @@ Nu_ReadRecordHeader(NuArchive* pArchive, NuRecord* pRecord) } } else { pRecord->recOptionSize = 0; - pRecord->recOptionList = nil; + pRecord->recOptionList = NULL; } /* last two bytes are the filename len; all else is "extra" */ @@ -1175,9 +1175,9 @@ Nu_WriteRecordHeader(NuArchive* pArchive, NuRecord* pRecord, FILE* fp) long crcOffset; int bytesWritten; - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(fp != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(fp != NULL); /* * Before we get started, let's make sure the storageType makes sense @@ -1317,12 +1317,12 @@ Nu_RecordWalkPrepare(NuArchive* pArchive, NuRecord** ppRecord) { NuError err = kNuErrNone; - Assert(pArchive != nil); - Assert(ppRecord != nil); + Assert(pArchive != NULL); + Assert(ppRecord != NULL); DBUG(("--- walk prep\n")); - *ppRecord = nil; + *ppRecord = NULL; if (!pArchive->haveToc) { /* might have tried and aborted earlier, rewind to start of records */ @@ -1350,18 +1350,18 @@ Nu_RecordWalkGetNext(NuArchive* pArchive, NuRecord** ppRecord) { NuError err = kNuErrNone; - Assert(pArchive != nil); - Assert(ppRecord != nil); + Assert(pArchive != NULL); + Assert(ppRecord != NULL); /*DBUG(("--- walk toc=%d\n", pArchive->haveToc));*/ if (pArchive->haveToc) { - if (*ppRecord == nil) + if (*ppRecord == NULL) *ppRecord = Nu_RecordSet_GetListHead(&pArchive->origRecordSet); else *ppRecord = (*ppRecord)->pNext; } else { - *ppRecord = nil; /* so we don't try to free it on exit */ + *ppRecord = NULL; /* so we don't try to free it on exit */ /* allocate and fill in a new record */ err = Nu_RecordNew(pArchive, ppRecord); @@ -1384,7 +1384,7 @@ bail: if (err != kNuErrNone && !pArchive->haveToc) { /* on failure, free whatever we allocated */ Nu_RecordFree(pArchive, *ppRecord); - *ppRecord = nil; + *ppRecord = NULL; } return err; } @@ -1425,7 +1425,7 @@ Nu_GetTOCIfNeeded(NuArchive* pArchive) NuRecord* pRecord; ulong count; - Assert(pArchive != nil); + Assert(pArchive != NULL); if (pArchive->haveToc) goto bail; @@ -1466,7 +1466,7 @@ Nu_StreamContents(NuArchive* pArchive, NuCallback contentFunc) NuResult result; ulong count; - if (contentFunc == nil) { + if (contentFunc == NULL) { err = kNuErrInvalidArg; goto bail; } @@ -1522,7 +1522,7 @@ Nu_FakeZeroExtract(NuArchive* pArchive, NuRecord* pRecord, int threadKind) NuError err; NuThread fakeThread; - Assert(pRecord != nil); + Assert(pRecord != NULL); DBUG(("--- found empty record, creating zero-byte file (kind=0x%04x)\n", threadKind)); @@ -1559,7 +1559,7 @@ Nu_StreamExtract(NuArchive* pArchive) long idx; /* reset this just to be safe */ - pArchive->lastDirCreated = nil; + pArchive->lastDirCreated = NULL; Nu_InitRecordContents(pArchive, &tmpRecord); count = pArchive->masterHeader.mhTotalRecords; @@ -1593,7 +1593,7 @@ Nu_StreamExtract(NuArchive* pArchive) BailError(err); } else idx = 0; - if (tmpRecord.filename == nil) { + if (tmpRecord.filename == NULL) { Nu_ReportError(NU_BLOB, kNuErrNone, "Couldn't find filename in record"); err = kNuErrBadRecord; @@ -1606,7 +1606,7 @@ Nu_StreamExtract(NuArchive* pArchive) hasInterestingThread = false; /* extract all relevant (remaining) threads */ - pArchive->lastFileCreated = nil; + pArchive->lastFileCreated = NULL; for ( ; idx < (long)tmpRecord.recTotalThreads; idx++) { const NuThread* pThread = Nu_GetThread(&tmpRecord, idx); @@ -1694,7 +1694,7 @@ Nu_Contents(NuArchive* pArchive, NuCallback contentFunc) NuResult result; ulong count; - if (contentFunc == nil) { + if (contentFunc == NULL) { err = kNuErrInvalidArg; goto bail; } @@ -1707,7 +1707,7 @@ Nu_Contents(NuArchive* pArchive, NuCallback contentFunc) err = Nu_RecordWalkGetNext(pArchive, &pRecord); BailError(err); - Assert(pRecord->filename != nil); + Assert(pRecord->filename != NULL); result = (*contentFunc)(pArchive, pRecord); if (result == kNuAbort) { err = kNuErrAborted; @@ -1735,11 +1735,11 @@ Nu_ExtractRecordByPtr(NuArchive* pArchive, NuRecord* pRecord) ulong idx; Assert(!Nu_IsStreaming(pArchive)); /* we don't skip things we don't read */ - Assert(pRecord != nil); + Assert(pRecord != NULL); /* extract all relevant threads */ hasInterestingThread = false; - pArchive->lastFileCreated = nil; + pArchive->lastFileCreated = NULL; for (idx = 0; idx < pRecord->recTotalThreads; idx++) { const NuThread* pThread = Nu_GetThread(pRecord, idx); @@ -1800,12 +1800,12 @@ NuError Nu_Extract(NuArchive* pArchive) { NuError err; - NuRecord* pRecord = nil; + NuRecord* pRecord = NULL; ulong count; long offset; /* reset this just to be safe */ - pArchive->lastDirCreated = nil; + pArchive->lastDirCreated = NULL; err = Nu_RecordWalkPrepare(pArchive, &pRecord); BailError(err); @@ -1856,7 +1856,7 @@ Nu_ExtractRecord(NuArchive* pArchive, NuRecordIdx recIdx) /* find the correct record by index */ err = Nu_RecordSet_FindByIdx(&pArchive->origRecordSet, recIdx, &pRecord); BailError(err); - Assert(pRecord != nil); + Assert(pRecord != NULL); /* extract whatever looks promising */ err = Nu_ExtractRecordByPtr(pArchive, pRecord); @@ -1899,7 +1899,7 @@ Nu_TestRecord(NuArchive* pArchive, NuRecordIdx recIdx) /* find the correct record by index */ err = Nu_RecordSet_FindByIdx(&pArchive->origRecordSet, recIdx, &pRecord); BailError(err); - Assert(pRecord != nil); + Assert(pRecord != NULL); /* extract whatever looks promising */ pArchive->testMode = true; @@ -1925,7 +1925,7 @@ Nu_GetRecord(NuArchive* pArchive, NuRecordIdx recordIdx, { NuError err; - if (recordIdx == 0 || ppRecord == nil) + if (recordIdx == 0 || ppRecord == NULL) return kNuErrInvalidArg; if (Nu_IsStreaming(pArchive)) @@ -1936,7 +1936,7 @@ Nu_GetRecord(NuArchive* pArchive, NuRecordIdx recordIdx, err = Nu_RecordSet_FindByIdx(&pArchive->origRecordSet, recordIdx, (NuRecord**)ppRecord); if (err == kNuErrNone) { - Assert(*ppRecord != nil); + Assert(*ppRecord != NULL); } /* fall through with error */ @@ -1952,9 +1952,9 @@ Nu_GetRecordIdxByName(NuArchive* pArchive, const char* name, NuRecordIdx* pRecordIdx) { NuError err; - NuRecord* pRecord = nil; + NuRecord* pRecord = NULL; - if (pRecordIdx == nil) + if (pRecordIdx == NULL) return kNuErrInvalidArg; if (Nu_IsStreaming(pArchive)) @@ -1964,7 +1964,7 @@ Nu_GetRecordIdxByName(NuArchive* pArchive, const char* name, err = Nu_RecordSet_FindByName(&pArchive->origRecordSet, name, &pRecord); if (err == kNuErrNone) { - Assert(pRecord != nil); + Assert(pRecord != NULL); *pRecordIdx = pRecord->recordIdx; } /* fall through with error */ @@ -1983,7 +1983,7 @@ Nu_GetRecordIdxByPosition(NuArchive* pArchive, ulong position, NuError err; const NuRecord* pRecord; - if (pRecordIdx == nil) + if (pRecordIdx == NULL) return kNuErrInvalidArg; if (Nu_IsStreaming(pArchive)) @@ -1998,7 +1998,7 @@ Nu_GetRecordIdxByPosition(NuArchive* pArchive, ulong position, pRecord = Nu_RecordSet_GetListHead(&pArchive->origRecordSet); while (position--) { - Assert(pRecord->pNext != nil); + Assert(pRecord->pNext != NULL); pRecord = pRecord->pNext; } @@ -2034,8 +2034,8 @@ Nu_FindRecordForWriteByIdx(NuArchive* pArchive, NuRecordIdx recIdx, { NuError err; - Assert(pArchive != nil); - Assert(ppFoundRecord != nil); + Assert(pArchive != NULL); + Assert(ppFoundRecord != NULL); if (Nu_RecordSet_GetLoaded(&pArchive->copyRecordSet)) { err = Nu_RecordSet_FindByIdx(&pArchive->copyRecordSet, recIdx, @@ -2044,7 +2044,7 @@ Nu_FindRecordForWriteByIdx(NuArchive* pArchive, NuRecordIdx recIdx, Assert(Nu_RecordSet_GetLoaded(&pArchive->origRecordSet)); err = Nu_RecordSet_FindByIdx(&pArchive->origRecordSet, recIdx, ppFoundRecord); - *ppFoundRecord = nil; /* can't delete from here */ + *ppFoundRecord = NULL; /* can't delete from here */ } BailErrorQuiet(err); @@ -2052,13 +2052,13 @@ Nu_FindRecordForWriteByIdx(NuArchive* pArchive, NuRecordIdx recIdx, * The record exists. If we were looking in the "orig" set, we have * to create a "copy" set and return it from there. */ - if (*ppFoundRecord == nil) { + if (*ppFoundRecord == NULL) { err = Nu_RecordSet_Clone(pArchive, &pArchive->copyRecordSet, &pArchive->origRecordSet); BailError(err); err = Nu_RecordSet_FindByIdx(&pArchive->copyRecordSet, recIdx, ppFoundRecord); - Assert(err == kNuErrNone && *ppFoundRecord != nil); /* must succeed */ + Assert(err == kNuErrNone && *ppFoundRecord != NULL); /* must succeed */ BailError(err); } @@ -2089,8 +2089,8 @@ Nu_HandleAddDuplicateRecord(NuArchive* pArchive, NuRecordSet* pRecordSet, Assert(pRecordSet == &pArchive->origRecordSet || pRecordSet == &pArchive->copyRecordSet); - Assert(pRecord != nil); - Assert(pFileDetails != nil); + Assert(pRecord != NULL); + Assert(pFileDetails != NULL); Assert(pArchive->valAllowDuplicates == false); /* @@ -2117,11 +2117,11 @@ Nu_HandleAddDuplicateRecord(NuArchive* pArchive, NuRecordSet* pRecordSet, */ switch (pArchive->valHandleExisting) { case kNuMaybeOverwrite: - if (pArchive->errorHandlerFunc != nil) { + if (pArchive->errorHandlerFunc != NULL) { errorStatus.operation = kNuOpAdd; errorStatus.err = kNuErrRecordExists; errorStatus.sysErr = 0; - errorStatus.message = nil; + errorStatus.message = NULL; errorStatus.pRecord = pRecord; errorStatus.pathname = pFileDetails->storageName; errorStatus.origPathname = pFileDetails->origName; @@ -2191,7 +2191,7 @@ Nu_HandleAddDuplicateRecord(NuArchive* pArchive, NuRecordSet* pRecordSet, err = Nu_RecordSet_FindByIdx(&pArchive->copyRecordSet, pRecord->recordIdx, &pRecord); - Assert(err == kNuErrNone && pRecord != nil); /* must succeed */ + Assert(err == kNuErrNone && pRecord != NULL); /* must succeed */ BailError(err); } @@ -2215,7 +2215,7 @@ bail: * * On success, the NuRecordIdx of the newly-created record will be placed * in "*pRecordIdx", and the NuThreadIdx of the filename thread will be - * placed in "*pThreadIdx". If "*ppNewRecord" is non-nil, it gets a pointer + * placed in "*pThreadIdx". If "*ppNewRecord" is non-NULL, it gets a pointer * to the newly-created record (this isn't part of the external interface). */ NuError @@ -2223,13 +2223,13 @@ Nu_AddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails, NuRecordIdx* pRecordIdx, NuRecord** ppNewRecord) { NuError err; - NuRecord* pNewRecord = nil; + NuRecord* pNewRecord = NULL; - if (pFileDetails == nil || pFileDetails->storageName == nil || + if (pFileDetails == NULL || pFileDetails->storageName == NULL || pFileDetails->storageName[0] == '\0' || NuGetSepFromSysInfo(pFileDetails->fileSysInfo) == 0) - /* pRecordIdx may be nil */ - /* ppNewRecord may be nil */ + /* pRecordIdx may be NULL */ + /* ppNewRecord may be NULL */ { err = kNuErrInvalidArg; goto bail; @@ -2327,7 +2327,7 @@ Nu_AddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails, pNewRecord->recFilenameLength = 0; pNewRecord->recordIdx = Nu_GetNextRecordIdx(pArchive); - pNewRecord->threadFilename = nil; + pNewRecord->threadFilename = NULL; pNewRecord->newFilename = strdup(pFileDetails->storageName); pNewRecord->filename = pNewRecord->newFilename; pNewRecord->recHeaderLength = -1; @@ -2342,9 +2342,9 @@ Nu_AddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails, BailError(err); /* return values */ - if (pRecordIdx != nil) + if (pRecordIdx != NULL) *pRecordIdx = pNewRecord->recordIdx; - if (ppNewRecord != nil) + if (ppNewRecord != NULL) *ppNewRecord = pNewRecord; bail: @@ -2365,13 +2365,13 @@ Nu_AddFileThreadMod(NuArchive* pArchive, NuRecord* pRecord, { NuError err; NuThreadFormat threadFormat; - NuDataSource* pDataSource = nil; - NuThreadMod* pThreadMod = nil; + NuDataSource* pDataSource = NULL; + NuThreadMod* pThreadMod = NULL; - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(pathname != nil); - Assert(pFileDetails != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(pathname != NULL); + Assert(pFileDetails != NULL); Assert(fromRsrcFork == true || fromRsrcFork == false); if (Nu_IsReadOnly(pArchive)) @@ -2393,17 +2393,17 @@ Nu_AddFileThreadMod(NuArchive* pArchive, NuRecord* pRecord, err = Nu_ThreadModAdd_New(pArchive, pFileDetails->threadID, threadFormat, pDataSource, &pThreadMod); BailError(err); - Assert(pThreadMod != nil); - /*pDataSource = nil;*/ /* ThreadModAdd_New makes a copy */ + Assert(pThreadMod != NULL); + /*pDataSource = NULL;*/ /* ThreadModAdd_New makes a copy */ /* add the thread mod to the record */ Nu_RecordAddThreadMod(pRecord, pThreadMod); - pThreadMod = nil; /* don't free on exit */ + pThreadMod = NULL; /* don't free on exit */ bail: - if (pDataSource != nil) + if (pDataSource != NULL) Nu_DataSourceFree(pDataSource); - if (pThreadMod != nil) + if (pThreadMod != NULL) Nu_ThreadModFree(pArchive, pThreadMod); return err; } @@ -2417,7 +2417,7 @@ bail: * "fromRsrcFork" tells us how to open the source file, not what type * of thread the file should be stored as. * - * If "pRecordIdx" is non-nil, it will receive the newly assigned recordID. + * If "pRecordIdx" is non-NULL, it will receive the newly assigned recordID. */ NuError Nu_AddFile(NuArchive* pArchive, const char* pathname, @@ -2428,7 +2428,7 @@ Nu_AddFile(NuArchive* pArchive, const char* pathname, NuRecordIdx recordIdx = 0; NuRecord* pRecord; - if (pathname == nil || pFileDetails == nil || + if (pathname == NULL || pFileDetails == NULL || !(fromRsrcFork == true || fromRsrcFork == false)) { return kNuErrInvalidArg; @@ -2439,7 +2439,7 @@ Nu_AddFile(NuArchive* pArchive, const char* pathname, err = Nu_GetTOCIfNeeded(pArchive); BailError(err); - if (pFileDetails->storageName == nil) { + if (pFileDetails->storageName == NULL) { err = kNuErrInvalidArg; Nu_ReportError(NU_BLOB, err, "Must specify storageName"); goto bail; @@ -2530,7 +2530,7 @@ Nu_AddFile(NuArchive* pArchive, const char* pathname, BailError(err); bail: - if (err == kNuErrNone && pRecordIdx != nil) + if (err == kNuErrNone && pRecordIdx != NULL) *pRecordIdx = recordIdx; return err; @@ -2569,12 +2569,12 @@ Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname, NuRecord* pRecord; NuThread* pFilenameThread; const NuThreadMod* pThreadMod; - NuThreadMod* pNewThreadMod = nil; - NuDataSource* pDataSource = nil; + NuThreadMod* pNewThreadMod = NULL; + NuDataSource* pDataSource = NULL; long requiredCapacity, existingCapacity, newCapacity; Boolean doDelete, doAdd, doUpdate; - if (recIdx == 0 || pathname == nil || pathname[0] == '\0' || fssep == '\0') + if (recIdx == 0 || pathname == NULL || pathname[0] == '\0' || fssep == '\0') return kNuErrInvalidArg; if (pathname[0] == fssep) { @@ -2591,19 +2591,19 @@ Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname, /* find the record in the "copy" set */ err = Nu_FindRecordForWriteByIdx(pArchive, recIdx, &pRecord); BailError(err); - Assert(pRecord != nil); + Assert(pRecord != NULL); /* look for a filename thread */ err = Nu_FindThreadByID(pRecord, kNuThreadIDFilename, &pFilenameThread); if (err != kNuErrNone) - pFilenameThread = nil; + pFilenameThread = NULL; else if (err == kNuErrNone && pRecord->pThreadMods) { /* found a thread, check to see if it has been deleted (or modifed) */ - Assert(pFilenameThread != nil); + Assert(pFilenameThread != NULL); pThreadMod = Nu_ThreadMod_FindByThreadIdx(pRecord, pFilenameThread->threadIdx); - if (pThreadMod != nil) { + if (pThreadMod != NULL) { DBUG(("--- tried to modify threadIdx %ld, which has already been\n", pFilenameThread->threadIdx)); err = kNuErrModThreadChange; @@ -2618,7 +2618,7 @@ Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname, newCapacity = existingCapacity = 0; requiredCapacity = strlen(pathname); - if (pFilenameThread != nil) { + if (pFilenameThread != NULL) { existingCapacity = pFilenameThread->thCompThreadEOF; if (existingCapacity >= requiredCapacity) { doUpdate = true; @@ -2655,25 +2655,25 @@ Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname, kNuThreadIDFilename, &pNewThreadMod); BailError(err); Nu_RecordAddThreadMod(pRecord, pNewThreadMod); - pNewThreadMod = nil; /* successful, don't free */ + pNewThreadMod = NULL; /* successful, don't free */ } if (doAdd) { err = Nu_ThreadModAdd_New(pArchive, kNuThreadIDFilename, kNuThreadFormatUncompressed, pDataSource, &pNewThreadMod); BailError(err); - /*pDataSource = nil;*/ /* ThreadModAdd_New makes a copy */ + /*pDataSource = NULL;*/ /* ThreadModAdd_New makes a copy */ Nu_RecordAddThreadMod(pRecord, pNewThreadMod); - pNewThreadMod = nil; /* successful, don't free */ + pNewThreadMod = NULL; /* successful, don't free */ } if (doUpdate) { err = Nu_ThreadModUpdate_New(pArchive, pFilenameThread->threadIdx, pDataSource, &pNewThreadMod); BailError(err); - /*pDataSource = nil;*/ /* ThreadModAdd_New makes a copy */ + /*pDataSource = NULL;*/ /* ThreadModAdd_New makes a copy */ Nu_RecordAddThreadMod(pRecord, pNewThreadMod); - pNewThreadMod = nil; /* successful, don't free */ + pNewThreadMod = NULL; /* successful, don't free */ } DBUG(("--- renaming '%s' to '%s' with delete=%d add=%d update=%d\n", @@ -2692,7 +2692,7 @@ Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname, } /* if we had a header filename, mark it for oblivion */ - if (pFilenameThread == nil) { + if (pFilenameThread == NULL) { DBUG(("+++ rename gonna drop the filename\n")); pRecord->dropRecFilename = true; } @@ -2714,7 +2714,7 @@ Nu_SetRecordAttr(NuArchive* pArchive, NuRecordIdx recordIdx, NuError err; NuRecord* pRecord; - if (pRecordAttr == nil) + if (pRecordAttr == NULL) return kNuErrInvalidArg; if (Nu_IsReadOnly(pArchive)) @@ -2726,7 +2726,7 @@ Nu_SetRecordAttr(NuArchive* pArchive, NuRecordIdx recordIdx, err = Nu_FindRecordForWriteByIdx(pArchive, recordIdx, &pRecord); BailError(err); - Assert(pRecord != nil); + Assert(pRecord != NULL); pRecord->recFileSysID = pRecordAttr->fileSysID; /*pRecord->recFileSysInfo = pRecordAttr->fileSysInfo;*/ pRecord->recAccess = pRecordAttr->access; @@ -2775,7 +2775,7 @@ Nu_Delete(NuArchive* pArchive) * have already been deleted, we might as well use this set. */ pNextRecord = Nu_RecordSet_GetListHead(&pArchive->copyRecordSet); - while (pNextRecord != nil) { + while (pNextRecord != NULL) { pRecord = pNextRecord; pNextRecord = pRecord->pNext; @@ -2784,7 +2784,7 @@ Nu_Delete(NuArchive* pArchive) * isn't allowed. There's no point in showing the record to the * user. */ - if (pRecord->pThreadMods != nil) { + if (pRecord->pThreadMods != NULL) { DBUG(("+++ Skipping delete on a modified record\n")); continue; } @@ -2794,7 +2794,7 @@ Nu_Delete(NuArchive* pArchive) * to select which files will be deleted, or abort the entire * operation. */ - if (pArchive->selectionFilterFunc != nil) { + if (pArchive->selectionFilterFunc != NULL) { selProposal.pRecord = pRecord; selProposal.pThread = pRecord->pThreads; /* doesn't matter */ result = (*pArchive->selectionFilterFunc)(pArchive, &selProposal); @@ -2810,7 +2810,7 @@ Nu_Delete(NuArchive* pArchive) /* * Do we want to allow this? (Same test as for DeleteRecord.) */ - if (pRecord->pThreadMods != nil || pRecord->dirtyHeader) { + if (pRecord->pThreadMods != NULL || pRecord->dirtyHeader) { DBUG(("--- Tried to delete a modified record\n")); err = kNuErrModRecChange; goto bail; @@ -2852,7 +2852,7 @@ Nu_DeleteRecord(NuArchive* pArchive, NuRecordIdx recIdx) * record's filetype). This isn't necessary for correct operation, * but again it maintains the semantics. */ - if (pRecord->pThreadMods != nil || pRecord->dirtyHeader) { + if (pRecord->pThreadMods != NULL || pRecord->dirtyHeader) { DBUG(("--- Tried to delete a modified record\n")); err = kNuErrModRecChange; goto bail; diff --git a/nufxlib/SourceSink.c b/nufxlib/SourceSink.c index 1c13778..7c4117c 100644 --- a/nufxlib/SourceSink.c +++ b/nufxlib/SourceSink.c @@ -22,10 +22,10 @@ static NuError Nu_DataSourceNew(NuDataSource** ppDataSource) { - Assert(ppDataSource != nil); + Assert(ppDataSource != NULL); - *ppDataSource = Nu_Malloc(nil, sizeof(**ppDataSource)); - if (*ppDataSource == nil) + *ppDataSource = Nu_Malloc(NULL, sizeof(**ppDataSource)); + if (*ppDataSource == NULL) return kNuErrMalloc; (*ppDataSource)->sourceType = kNuDataSourceUnknown; @@ -47,7 +47,7 @@ Nu_DataSourceNew(NuDataSource** ppDataSource) * needed in the first place.) Buffer sources are a little scary since * they include a "curOffset" value. * - * Returns nil on error. + * Returns NULL on error. */ NuDataSource* Nu_DataSourceCopy(NuDataSource* pDataSource) @@ -59,18 +59,18 @@ Nu_DataSourceCopy(NuDataSource* pDataSource) #if 0 /* we used to copy them -- very bad idea */ NuDataSource* pNewDataSource; - Assert(pDataSource != nil); + Assert(pDataSource != NULL); if (Nu_DataSourceNew(&pNewDataSource) != kNuErrNone) - return nil; - Assert(pNewDataSource != nil); + return NULL; + Assert(pNewDataSource != NULL); /* this gets most of it */ memcpy(pNewDataSource, pDataSource, sizeof(*pNewDataSource)); /* copy anything we're sure to free up */ if (pDataSource->sourceType == kNuDataSourceFromFile) { - Assert(pDataSource->fromFile.fp == nil); /* does this matter? */ + Assert(pDataSource->fromFile.fp == NULL); /* does this matter? */ pNewDataSource->fromFile.pathname = strdup(pDataSource->fromFile.pathname); } @@ -92,7 +92,7 @@ Nu_DataSourceCopy(NuDataSource* pDataSource) NuError Nu_DataSourceFree(NuDataSource* pDataSource) { - if (pDataSource == nil) + if (pDataSource == NULL) return kNuErrNone; Assert(pDataSource->common.refCount > 0); @@ -103,25 +103,25 @@ Nu_DataSourceFree(NuDataSource* pDataSource) switch (pDataSource->sourceType) { case kNuDataSourceFromFile: - Nu_Free(nil, pDataSource->fromFile.pathname); - if (pDataSource->fromFile.fp != nil) { + Nu_Free(NULL, pDataSource->fromFile.pathname); + if (pDataSource->fromFile.fp != NULL) { fclose(pDataSource->fromFile.fp); - pDataSource->fromFile.fp = nil; + pDataSource->fromFile.fp = NULL; } break; case kNuDataSourceFromFP: - if (pDataSource->fromFP.fcloseFunc != nil && - pDataSource->fromFP.fp != nil) + if (pDataSource->fromFP.fcloseFunc != NULL && + pDataSource->fromFP.fp != NULL) { - (*pDataSource->fromFP.fcloseFunc)(nil, pDataSource->fromFP.fp); - pDataSource->fromFP.fp = nil; + (*pDataSource->fromFP.fcloseFunc)(NULL, pDataSource->fromFP.fp); + pDataSource->fromFP.fp = NULL; } break; case kNuDataSourceFromBuffer: - if (pDataSource->fromBuffer.freeFunc != nil) { - (*pDataSource->fromBuffer.freeFunc)(nil, + if (pDataSource->fromBuffer.freeFunc != NULL) { + (*pDataSource->fromBuffer.freeFunc)(NULL, (void*)pDataSource->fromBuffer.buffer); - pDataSource->fromBuffer.buffer = nil; + pDataSource->fromBuffer.buffer = NULL; } break; case kNuDataSourceUnknown: @@ -131,7 +131,7 @@ Nu_DataSourceFree(NuDataSource* pDataSource) return kNuErrInternal; } - Nu_Free(nil, pDataSource); + Nu_Free(NULL, pDataSource); return kNuErrNone; } @@ -145,9 +145,9 @@ Nu_DataSourceFile_New(NuThreadFormat threadFormat, ulong otherLen, { NuError err; - if (pathname == nil || + if (pathname == NULL || !(isFromRsrcFork == true || isFromRsrcFork == false) || - ppDataSource == nil) + ppDataSource == NULL) { return kNuErrInvalidArg; } @@ -164,7 +164,7 @@ Nu_DataSourceFile_New(NuThreadFormat threadFormat, ulong otherLen, (*ppDataSource)->fromFile.pathname = strdup(pathname); (*ppDataSource)->fromFile.fromRsrcFork = isFromRsrcFork; - (*ppDataSource)->fromFile.fp = nil; /* to be filled in later */ + (*ppDataSource)->fromFile.fp = NULL; /* to be filled in later */ bail: return err; @@ -182,8 +182,8 @@ Nu_DataSourceFP_New(NuThreadFormat threadFormat, ulong otherLen, { NuError err; - if (fp == nil || offset < 0 || length < 0 || - ppDataSource == nil) + if (fp == NULL || offset < 0 || length < 0 || + ppDataSource == NULL) { return kNuErrInvalidArg; } @@ -216,8 +216,8 @@ bail: /* * Create a data source for a buffer. * - * We allow "buffer" to be nil so long as "offset" and "length" are also - * nil. This is useful for creating empty pre-sized buffers, such as + * We allow "buffer" to be NULL so long as "offset" and "length" are also + * NULL. This is useful for creating empty pre-sized buffers, such as * blank comment fields. */ NuError @@ -227,14 +227,14 @@ Nu_DataSourceBuffer_New(NuThreadFormat threadFormat, ulong otherLen, { NuError err; - if (offset < 0 || length < 0 || ppDataSource == nil) + if (offset < 0 || length < 0 || ppDataSource == NULL) return kNuErrInvalidArg; - if (buffer == nil && (offset != 0 || length != 0)) + if (buffer == NULL && (offset != 0 || length != 0)) return kNuErrInvalidArg; - if (buffer == nil) { + if (buffer == NULL) { DBUG(("+++ zeroing freeFunc for empty-buffer DataSource\n")); - freeFunc = nil; + freeFunc = NULL; } if (otherLen && otherLen < (ulong)length) { @@ -270,7 +270,7 @@ bail: NuDataSourceType Nu_DataSourceGetType(const NuDataSource* pDataSource) { - Assert(pDataSource != nil); + Assert(pDataSource != NULL); return pDataSource->sourceType; } @@ -280,7 +280,7 @@ Nu_DataSourceGetType(const NuDataSource* pDataSource) NuThreadFormat Nu_DataSourceGetThreadFormat(const NuDataSource* pDataSource) { - Assert(pDataSource != nil); + Assert(pDataSource != NULL); return pDataSource->common.threadFormat; } @@ -290,11 +290,11 @@ Nu_DataSourceGetThreadFormat(const NuDataSource* pDataSource) ulong Nu_DataSourceGetDataLen(const NuDataSource* pDataSource) { - Assert(pDataSource != nil); + Assert(pDataSource != NULL); if (pDataSource->sourceType == kNuDataSourceFromFile) { /* dataLen can only be valid if file has been opened */ - Assert(pDataSource->fromFile.fp != nil); + Assert(pDataSource->fromFile.fp != NULL); } return pDataSource->common.dataLen; @@ -306,7 +306,7 @@ Nu_DataSourceGetDataLen(const NuDataSource* pDataSource) ulong Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource) { - Assert(pDataSource != nil); + Assert(pDataSource != NULL); return pDataSource->common.otherLen; } @@ -316,7 +316,7 @@ Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource) void Nu_DataSourceSetOtherLen(NuDataSource* pDataSource, long otherLen) { - Assert(pDataSource != nil && otherLen > 0); + Assert(pDataSource != NULL && otherLen > 0); pDataSource->common.otherLen = otherLen; } @@ -327,7 +327,7 @@ Nu_DataSourceSetOtherLen(NuDataSource* pDataSource, long otherLen) ushort Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource) { - Assert(pDataSource != nil); + Assert(pDataSource != NULL); return pDataSource->common.rawCrc; } @@ -338,7 +338,7 @@ Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource) void Nu_DataSourceSetRawCrc(NuDataSource* pDataSource, ushort crc) { - Assert(pDataSource != nil); + Assert(pDataSource != NULL); pDataSource->common.rawCrc = crc; } @@ -350,7 +350,7 @@ NuError Nu_DataSourcePrepareInput(NuArchive* pArchive, NuDataSource* pDataSource) { NuError err = kNuErrNone; - FILE* fileFp = nil; + FILE* fileFp = NULL; /* * Doesn't apply to buffer sources. @@ -376,7 +376,7 @@ Nu_DataSourcePrepareInput(NuArchive* pArchive, NuDataSource* pDataSource) &fileFp); BailError(err); - Assert(fileFp != nil); + Assert(fileFp != NULL); pDataSource->fromFile.fp = fileFp; err = Nu_GetFileLength(pArchive, fileFp, (long*)&pDataSource->common.dataLen); @@ -409,9 +409,9 @@ Nu_DataSourceUnPrepareInput(NuArchive* pArchive, NuDataSource* pDataSource) if (Nu_DataSourceGetType(pDataSource) != kNuDataSourceFromFile) return; - if (pDataSource->fromFile.fp != nil) { + if (pDataSource->fromFile.fp != NULL) { fclose(pDataSource->fromFile.fp); - pDataSource->fromFile.fp = nil; + pDataSource->fromFile.fp = NULL; pDataSource->common.dataLen = 0; } } @@ -423,9 +423,9 @@ Nu_DataSourceUnPrepareInput(NuArchive* pArchive, NuDataSource* pDataSource) const char* Nu_DataSourceFile_GetPathname(NuDataSource* pDataSource) { - Assert(pDataSource != nil); + Assert(pDataSource != NULL); Assert(pDataSource->sourceType == kNuDataSourceFromFile); - Assert(pDataSource->fromFile.pathname != nil); + Assert(pDataSource->fromFile.pathname != NULL); return pDataSource->fromFile.pathname; } @@ -439,13 +439,13 @@ Nu_DataSourceGetBlock(NuDataSource* pDataSource, uchar* buf, ulong len) { NuError err; - Assert(pDataSource != nil); - Assert(buf != nil); + Assert(pDataSource != NULL); + Assert(buf != NULL); Assert(len > 0); switch (pDataSource->sourceType) { case kNuDataSourceFromFile: - Assert(pDataSource->fromFile.fp != nil); + Assert(pDataSource->fromFile.fp != NULL); err = Nu_FRead(pDataSource->fromFile.fp, buf, len); if (feof(pDataSource->fromFile.fp)) Nu_ReportError(NU_NILBLOB, err, "EOF hit unexpectedly"); @@ -484,11 +484,11 @@ Nu_DataSourceRewind(NuDataSource* pDataSource) { NuError err; - Assert(pDataSource != nil); + Assert(pDataSource != NULL); switch (pDataSource->sourceType) { case kNuDataSourceFromFile: - Assert(pDataSource->fromFile.fp != nil); + Assert(pDataSource->fromFile.fp != NULL); err = Nu_FSeek(pDataSource->fromFile.fp, 0, SEEK_SET); break; /* fall through with error */ case kNuDataSourceFromFP: @@ -521,10 +521,10 @@ Nu_DataSourceRewind(NuDataSource* pDataSource) static NuError Nu_DataSinkNew(NuDataSink** ppDataSink) { - Assert(ppDataSink != nil); + Assert(ppDataSink != NULL); - *ppDataSink = Nu_Malloc(nil, sizeof(**ppDataSink)); - if (*ppDataSink == nil) + *ppDataSink = Nu_Malloc(NULL, sizeof(**ppDataSink)); + if (*ppDataSink == NULL) return kNuErrMalloc; (*ppDataSink)->sinkType = kNuDataSinkUnknown; @@ -539,13 +539,13 @@ Nu_DataSinkNew(NuDataSink** ppDataSink) NuError Nu_DataSinkFree(NuDataSink* pDataSink) { - if (pDataSink == nil) + if (pDataSink == NULL) return kNuErrNone; switch (pDataSink->sinkType) { case kNuDataSinkToFile: Nu_DataSinkFile_Close(pDataSink); - Nu_Free(nil, pDataSink->toFile.pathname); + Nu_Free(NULL, pDataSink->toFile.pathname); break; case kNuDataSinkToFP: break; @@ -560,7 +560,7 @@ Nu_DataSinkFree(NuDataSink* pDataSink) return kNuErrInternal; } - Nu_Free(nil, pDataSink); + Nu_Free(NULL, pDataSink); return kNuErrNone; } @@ -577,9 +577,9 @@ Nu_DataSinkFile_New(Boolean doExpand, NuValue convertEOL, const char* pathname, if ((doExpand != true && doExpand != false) || (convertEOL != kNuConvertOff && convertEOL != kNuConvertOn && convertEOL != kNuConvertAuto) || - pathname == nil || + pathname == NULL || fssep == 0 || - ppDataSink == nil) + ppDataSink == NULL) { return kNuErrInvalidArg; } @@ -597,7 +597,7 @@ Nu_DataSinkFile_New(Boolean doExpand, NuValue convertEOL, const char* pathname, (*ppDataSink)->toFile.pathname = strdup(pathname); (*ppDataSink)->toFile.fssep = fssep; - (*ppDataSink)->toFile.fp = nil; + (*ppDataSink)->toFile.fp = NULL; bail: return err; @@ -616,8 +616,8 @@ Nu_DataSinkFP_New(Boolean doExpand, NuValue convertEOL, FILE* fp, if ((doExpand != true && doExpand != false) || (convertEOL != kNuConvertOff && convertEOL != kNuConvertOn && convertEOL != kNuConvertAuto) || - fp == nil || - ppDataSink == nil) + fp == NULL || + ppDataSink == NULL) { return kNuErrInvalidArg; } @@ -651,9 +651,9 @@ Nu_DataSinkBuffer_New(Boolean doExpand, NuValue convertEOL, uchar* buffer, if ((doExpand != true && doExpand != false) || (convertEOL != kNuConvertOff && convertEOL != kNuConvertOn && convertEOL != kNuConvertAuto) || - buffer == nil || + buffer == NULL || bufLen == 0 || - ppDataSink == nil) + ppDataSink == NULL) { return kNuErrInvalidArg; } @@ -688,7 +688,7 @@ Nu_DataSinkVoid_New(Boolean doExpand, NuValue convertEOL, NuError err; Assert(doExpand == true || doExpand == false); - Assert(ppDataSink != nil); + Assert(ppDataSink != NULL); err = Nu_DataSinkNew(ppDataSink); BailErrorQuiet(err); @@ -709,7 +709,7 @@ bail: NuDataSinkType Nu_DataSinkGetType(const NuDataSink* pDataSink) { - Assert(pDataSink != nil); + Assert(pDataSink != NULL); return pDataSink->sinkType; } @@ -748,7 +748,7 @@ Nu_DataSinkGetOutCount(const NuDataSink* pDataSink) const char* Nu_DataSinkFile_GetPathname(const NuDataSink* pDataSink) { - Assert(pDataSink != nil); + Assert(pDataSink != NULL); Assert(pDataSink->sinkType == kNuDataSinkToFile); return pDataSink->toFile.pathname; @@ -760,7 +760,7 @@ Nu_DataSinkFile_GetPathname(const NuDataSink* pDataSink) char Nu_DataSinkFile_GetFssep(const NuDataSink* pDataSink) { - Assert(pDataSink != nil); + Assert(pDataSink != NULL); Assert(pDataSink->sinkType == kNuDataSinkToFile); return pDataSink->toFile.fssep; @@ -772,7 +772,7 @@ Nu_DataSinkFile_GetFssep(const NuDataSink* pDataSink) FILE* Nu_DataSinkFile_GetFP(const NuDataSink* pDataSink) { - Assert(pDataSink != nil); + Assert(pDataSink != NULL); Assert(pDataSink->sinkType == kNuDataSinkToFile); return pDataSink->toFile.fp; @@ -784,7 +784,7 @@ Nu_DataSinkFile_GetFP(const NuDataSink* pDataSink) void Nu_DataSinkFile_SetFP(NuDataSink* pDataSink, FILE* fp) { - Assert(pDataSink != nil); + Assert(pDataSink != NULL); Assert(pDataSink->sinkType == kNuDataSinkToFile); pDataSink->toFile.fp = fp; @@ -796,11 +796,11 @@ Nu_DataSinkFile_SetFP(NuDataSink* pDataSink, FILE* fp) void Nu_DataSinkFile_Close(NuDataSink* pDataSink) { - Assert(pDataSink != nil); + Assert(pDataSink != NULL); - if (pDataSink->toFile.fp != nil) { + if (pDataSink->toFile.fp != NULL) { fclose(pDataSink->toFile.fp); - pDataSink->toFile.fp = nil; + pDataSink->toFile.fp = NULL; } } @@ -813,19 +813,19 @@ Nu_DataSinkPutBlock(NuDataSink* pDataSink, const uchar* buf, ulong len) { NuError err; - Assert(pDataSink != nil); - Assert(buf != nil); + Assert(pDataSink != NULL); + Assert(buf != NULL); Assert(len > 0); switch (pDataSink->sinkType) { case kNuDataSinkToFile: - Assert(pDataSink->toFile.fp != nil); + Assert(pDataSink->toFile.fp != NULL); err = Nu_FWrite(pDataSink->toFile.fp, buf, len); if (err != kNuErrNone) return err; break; case kNuDataSinkToFP: - Assert(pDataSink->toFP.fp != nil); + Assert(pDataSink->toFP.fp != NULL); err = Nu_FWrite(pDataSink->toFP.fp, buf, len); if (err != kNuErrNone) return err; @@ -861,7 +861,7 @@ Nu_DataSinkGetError(NuDataSink* pDataSink) { NuError err = kNuErrNone; - Assert(pDataSink != nil); + Assert(pDataSink != NULL); switch (pDataSink->sinkType) { case kNuDataSinkToFile: diff --git a/nufxlib/Squeeze.c b/nufxlib/Squeeze.c index f28b3c4..e77eece 100644 --- a/nufxlib/Squeeze.c +++ b/nufxlib/Squeeze.c @@ -704,7 +704,7 @@ Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, sqState.pArchive = pArchive; sqState.crc = 0; - if (pCrc == nil) { + if (pCrc == NULL) { sqState.doCalcCRC = false; } else { sqState.doCalcCRC = true; @@ -727,7 +727,7 @@ Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, err = Nu_SQComputeHuffTree(&sqState); BailError(err); - if (pCrc != nil) + if (pCrc != NULL) *pCrc = sqState.crc; /* @@ -915,7 +915,7 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord, err = Nu_AllocCompressionBufferIFN(pArchive); if (err != kNuErrNone) return err; - Assert(pArchive->compBuf != nil); + Assert(pArchive->compBuf != NULL); usqState.dataInBuffer = 0; usqState.dataPtr = pArchive->compBuf; @@ -1080,7 +1080,7 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord, val = 2; } while (--val) { - if (pCrc != nil) + if (pCrc != NULL) *pCrc = Nu_CalcCRC16(*pCrc, &lastc, 1); err = Nu_FunnelWrite(pArchive, pFunnel, &lastc, 1); #ifdef FULL_SQ_HEADER @@ -1095,7 +1095,7 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord, inrep = true; } else { lastc = val; - if (pCrc != nil) + if (pCrc != NULL) *pCrc = Nu_CalcCRC16(*pCrc, &lastc, 1); err = Nu_FunnelWrite(pArchive, pFunnel, &lastc, 1); #ifdef FULL_SQ_HEADER diff --git a/nufxlib/Thread.c b/nufxlib/Thread.c index 99480f2..e12d3fa 100644 --- a/nufxlib/Thread.c +++ b/nufxlib/Thread.c @@ -92,7 +92,7 @@ Nu_FindThreadByIdx(const NuRecord* pRecord, NuThreadIdx thread, for (idx = 0; idx < (int)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); if (pThread->threadIdx == thread) { *ppThread = pThread; @@ -117,7 +117,7 @@ Nu_FindThreadByID(const NuRecord* pRecord, NuThreadID threadID, for (idx = 0; idx < (int)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); if (NuGetThreadID(pThread) == threadID) { *ppThread = pThread; @@ -135,8 +135,8 @@ Nu_FindThreadByID(const NuRecord* pRecord, NuThreadID threadID, void Nu_CopyThreadContents(NuThread* pDstThread, const NuThread* pSrcThread) { - Assert(pDstThread != nil); - Assert(pSrcThread != nil); + Assert(pDstThread != NULL); + Assert(pSrcThread != NULL); memcpy(pDstThread, pSrcThread, sizeof(*pDstThread)); } @@ -156,9 +156,9 @@ Nu_ReadThreadHeader(NuArchive* pArchive, NuThread* pThread, ushort* pCrc) { FILE* fp; - Assert(pArchive != nil); - Assert(pThread != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(pThread != NULL); + Assert(pCrc != NULL); fp = pArchive->archiveFp; @@ -192,9 +192,9 @@ Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, ushort* pCrc) long count; Boolean hasData = false; - Assert(pArchive != nil); - Assert(pRecord != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); + Assert(pCrc != NULL); if (!pRecord->recTotalThreads) { /* not sure if this is reasonable, but we can handle it */ @@ -310,10 +310,10 @@ static NuError Nu_WriteThreadHeader(NuArchive* pArchive, const NuThread* pThread, FILE* fp, ushort* pCrc) { - Assert(pArchive != nil); - Assert(pThread != nil); - Assert(fp != nil); - Assert(pCrc != nil); + Assert(pArchive != NULL); + Assert(pThread != NULL); + Assert(fp != NULL); + Assert(pCrc != NULL); Nu_WriteTwoC(pArchive, fp, pThread->thThreadClass, pCrc); Nu_WriteTwoC(pArchive, fp, (ushort)pThread->thThreadFormat, pCrc); @@ -342,7 +342,7 @@ Nu_WriteThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, FILE* fp, for (idx = 0; idx < (int)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); err = Nu_WriteThreadHeader(pArchive, pThread, fp, pCrc); BailError(err); @@ -372,8 +372,8 @@ Nu_ComputeThreadData(NuArchive* pArchive, NuRecord* pRecord) NuThread* pThread; long fileOffset, count; - Assert(pArchive != nil); - Assert(pRecord != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); /*pRecord->totalLength = 0;*/ pRecord->totalCompLength = 0; @@ -414,8 +414,8 @@ Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord, long numThreads) NuThread* pThread; FILE* fp; - Assert(pArchive != nil); - Assert(pRecord != nil); + Assert(pArchive != NULL); + Assert(pRecord != NULL); fp = pArchive->archiveFp; @@ -423,7 +423,7 @@ Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord, long numThreads) pThread = pRecord->pThreads; while (numThreads--) { - if (pRecord->threadFilename == nil && + if (pRecord->threadFilename == NULL && NuMakeThreadID(pThread->thThreadClass, pThread->thThreadKind) == kNuThreadIDFilename) { @@ -452,7 +452,7 @@ Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord, long numThreads) Nu_StripHiIfAllSet(pRecord->threadFilename); /* prefer this one over the record one, but only one should exist */ - if (pRecord->filename != nil) { + if (pRecord->filename != NULL) { DBUG(("--- HEY: got record filename and thread filename\n")); } pRecord->filename = pRecord->threadFilename; @@ -473,7 +473,7 @@ Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord, long numThreads) * end up with a disk image that had no name attached. This will tend * to confuse things, so we go ahead and give it a name. */ - if (pRecord->filename == nil) { + if (pRecord->filename == NULL) { DBUG(("+++ no filename found, using default record name\n")); pRecord->filename = kNuDefaultRecordName; } @@ -527,7 +527,7 @@ Nu_ExtractThreadToDataSink(NuArchive* pArchive, const NuRecord* pRecord, const NuThread* pThread, NuProgressData* pProgress, NuDataSink* pDataSink) { NuError err; - NuFunnel* pFunnel = nil; + NuFunnel* pFunnel = NULL; /* if it's not a stream, seek to the appropriate spot in the file */ if (!Nu_IsStreaming(pArchive)) { @@ -586,18 +586,18 @@ Nu_ExtractThreadCommon(NuArchive* pArchive, const NuRecord* pRecord, NuProgressData progressData; NuProgressData* pProgressData; NuDataSink* pOrigDataSink; - char* newPathStorage = nil; + char* newPathStorage = NULL; const char* newPathname; NuResult result; uchar newFssep; Boolean doFreeSink = false; - Assert(pRecord != nil); - Assert(pThread != nil); - Assert(pDataSink != nil); + Assert(pRecord != NULL); + Assert(pThread != NULL); + Assert(pDataSink != NULL); memset(&progressData, 0, sizeof(progressData)); - pProgressData = nil; + pProgressData = NULL; /* * If we're just trying to verify the archive contents, create a @@ -619,7 +619,7 @@ Nu_ExtractThreadCommon(NuArchive* pArchive, const NuRecord* pRecord, * use by the "bulk" extract, not the per-thread extract, but it * still applies if they so desire. */ - if (pArchive->selectionFilterFunc != nil) { + if (pArchive->selectionFilterFunc != NULL) { selProposal.pRecord = pRecord; selProposal.pThread = pThread; result = (*pArchive->selectionFilterFunc)(pArchive, &selProposal); @@ -632,7 +632,7 @@ Nu_ExtractThreadCommon(NuArchive* pArchive, const NuRecord* pRecord, } } - newPathname = nil; + newPathname = NULL; newFssep = 0; retry_name: @@ -650,16 +650,16 @@ retry_name: pDataSink = pOrigDataSink; /* if they don't have a pathname func defined, we just use default */ - if (pArchive->outputPathnameFunc != nil) { + if (pArchive->outputPathnameFunc != NULL) { pathProposal.pathname = pRecord->filename; pathProposal.filenameSeparator = NuGetSepFromSysInfo(pRecord->recFileSysInfo); pathProposal.pRecord = pRecord; pathProposal.pThread = pThread; - pathProposal.newPathname = nil; + pathProposal.newPathname = NULL; pathProposal.newFilenameSeparator = '\0'; /*pathProposal.newStorage = (NuThreadID)-1;*/ - pathProposal.newDataSink = nil; + pathProposal.newDataSink = NULL; result = (*pArchive->outputPathnameFunc)(pArchive, &pathProposal); @@ -671,27 +671,27 @@ retry_name: } /* we don't own this string, so make a copy */ - if (pathProposal.newPathname != nil) { + if (pathProposal.newPathname != NULL) { newPathStorage = strdup(pathProposal.newPathname); newPathname = newPathStorage; } else - newPathname = nil; + newPathname = NULL; if (pathProposal.newFilenameSeparator != '\0') newFssep = pathProposal.newFilenameSeparator; /* if they want to send this somewhere else, let them */ - if (pathProposal.newDataSink != nil) + if (pathProposal.newDataSink != NULL) pDataSink = pathProposal.newDataSink; } /* at least one of these must be set */ - Assert(!(newPathname == nil && pathProposal.newDataSink == nil)); + Assert(!(newPathname == NULL && pathProposal.newDataSink == NULL)); } /* * Prepare the progress data if this is a data thread. */ - if (newPathname == nil) { + if (newPathname == NULL) { /* using a data sink; get the pathname out of the record */ newPathname = pRecord->filename; newFssep = NuGetSepFromSysInfo(pRecord->recFileSysInfo); @@ -713,23 +713,23 @@ retry_name: * We're extracting to a file. Open it, creating it if necessary and * allowed. */ - FILE* fileFp = nil; + FILE* fileFp = NULL; err = Nu_OpenOutputFile(pArchive, pRecord, pThread, newPathname, newFssep, &fileFp); if (err == kNuErrRename) { /* they want to rename; the OutputPathname callback handles this */ Nu_Free(pArchive, newPathStorage); - newPathStorage = nil; + newPathStorage = NULL; /* reset these just to be careful */ - newPathname = nil; - fileFp = nil; + newPathname = NULL; + fileFp = NULL; goto retry_name; } else if (err != kNuErrNone) { goto bail; } - Assert(fileFp != nil); + Assert(fileFp != NULL); (void) Nu_DataSinkFile_SetFP(pDataSink, fileFp); DBUG(("+++ EXTRACTING 0x%08lx from '%s' at offset %0ld to '%s'\n", @@ -753,12 +753,12 @@ retry_name: */ err = Nu_CloseOutputFile(pArchive, pRecord, Nu_DataSinkFile_GetFP(pDataSink), newPathname); - Nu_DataSinkFile_SetFP(pDataSink, nil); + Nu_DataSinkFile_SetFP(pDataSink, NULL); BailError(err); } bail: - if (err != kNuErrNone && pProgressData != nil) { + if (err != kNuErrNone && pProgressData != NULL) { /* send a final progress message, indicating failure */ if (err == kNuErrSkipped) pProgressData->state = kNuProgressSkipped; @@ -790,7 +790,7 @@ Nu_ExtractThreadBulk(NuArchive* pArchive, const NuRecord* pRecord, const NuThread* pThread) { NuError err; - NuDataSink* pDataSink = nil; + NuDataSink* pDataSink = NULL; NuValue eolConv; /* @@ -814,7 +814,7 @@ Nu_ExtractThreadBulk(NuArchive* pArchive, const NuRecord* pRecord, BailError(err); bail: - if (pDataSink != nil) { + if (pDataSink != NULL) { NuError err2 = Nu_DataSinkFree(pDataSink); if (err == kNuErrNone) err = err2; @@ -837,7 +837,7 @@ Nu_ExtractThread(NuArchive* pArchive, NuThreadIdx threadIdx, if (Nu_IsStreaming(pArchive)) return kNuErrUsage; - if (threadIdx == 0 || pDataSink == nil) + if (threadIdx == 0 || pDataSink == NULL) return kNuErrInvalidArg; err = Nu_GetTOCIfNeeded(pArchive); BailError(err); @@ -846,7 +846,7 @@ Nu_ExtractThread(NuArchive* pArchive, NuThreadIdx threadIdx, err = Nu_RecordSet_FindByThreadIdx(&pArchive->origRecordSet, threadIdx, &pRecord, &pThread); BailError(err); - Assert(pRecord != nil); + Assert(pRecord != NULL); /* extract away */ err = Nu_ExtractThreadCommon(pArchive, pRecord, pThread, pDataSink); @@ -886,13 +886,13 @@ Nu_FindNoFutureThread(NuArchive* pArchive, const NuRecord* pRecord, */ for (idx = 0; idx < (int)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); if (NuGetThreadID(pThread) == threadID) { /* found a match, see if it has been deleted */ pThreadMod = Nu_ThreadMod_FindByThreadIdx(pRecord, pThread->threadIdx); - if (pThreadMod != nil && + if (pThreadMod != NULL && pThreadMod->entry.kind == kNuThreadModDelete) { /* it's deleted, ignore it */ @@ -908,7 +908,7 @@ Nu_FindNoFutureThread(NuArchive* pArchive, const NuRecord* pRecord, * Now look for "add" threadMods with a matching threadID. */ pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { if (pThreadMod->entry.kind == kNuThreadModAdd && pThreadMod->entry.add.threadID == threadID) { @@ -941,13 +941,13 @@ Nu_FindNoFutureThreadClass(NuArchive* pArchive, const NuRecord* pRecord, */ for (idx = 0; idx < (int)pRecord->recTotalThreads; idx++) { pThread = Nu_GetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); if (pThread->thThreadClass == threadClass) { /* found a match, see if it has been deleted */ pThreadMod = Nu_ThreadMod_FindByThreadIdx(pRecord, pThread->threadIdx); - if (pThreadMod != nil && + if (pThreadMod != NULL && pThreadMod->entry.kind == kNuThreadModDelete) { /* it's deleted, ignore it */ @@ -963,7 +963,7 @@ Nu_FindNoFutureThreadClass(NuArchive* pArchive, const NuRecord* pRecord, * Now look for "add" threadMods with a matching threadClass. */ pThreadMod = pRecord->pThreadMods; - while (pThreadMod != nil) { + while (pThreadMod != NULL) { if (pThreadMod->entry.kind == kNuThreadModAdd && NuThreadIDGetClass(pThreadMod->entry.add.threadID) == threadClass) { @@ -1001,7 +1001,7 @@ Nu_FindThreadForWriteByIdx(NuArchive* pArchive, NuThreadIdx threadIdx, Assert(Nu_RecordSet_GetLoaded(&pArchive->origRecordSet)); err = Nu_RecordSet_FindByThreadIdx(&pArchive->origRecordSet, threadIdx, ppFoundRecord, ppFoundThread); - *ppFoundThread = nil; /* can't delete from here, wipe ptr */ + *ppFoundThread = NULL; /* can't delete from here, wipe ptr */ } BailError(err); @@ -1009,13 +1009,13 @@ Nu_FindThreadForWriteByIdx(NuArchive* pArchive, NuThreadIdx threadIdx, * The thread exists. If we were looking in the "orig" set, we have * to create a "copy" set, and delete it from that. */ - if (*ppFoundThread == nil) { + if (*ppFoundThread == NULL) { err = Nu_RecordSet_Clone(pArchive, &pArchive->copyRecordSet, &pArchive->origRecordSet); BailError(err); err = Nu_RecordSet_FindByThreadIdx(&pArchive->copyRecordSet, threadIdx, ppFoundRecord, ppFoundThread); - Assert(err == kNuErrNone && *ppFoundThread != nil); /* must succeed */ + Assert(err == kNuErrNone && *ppFoundThread != NULL); /* must succeed */ BailError(err); } @@ -1100,11 +1100,11 @@ Nu_AddThread(NuArchive* pArchive, NuRecordIdx recIdx, NuThreadID threadID, { NuError err; NuRecord* pRecord; - NuThreadMod* pThreadMod = nil; + NuThreadMod* pThreadMod = NULL; NuThreadFormat threadFormat; - /* okay for pThreadIdx to be nil */ - if (recIdx == 0 || pDataSource == nil) + /* okay for pThreadIdx to be NULL */ + if (recIdx == 0 || pDataSource == NULL) return kNuErrInvalidArg; if (Nu_IsReadOnly(pArchive)) @@ -1123,7 +1123,7 @@ Nu_AddThread(NuArchive* pArchive, NuRecordIdx recIdx, NuThreadID threadID, err = Nu_RecordSet_FindByIdx(&pArchive->newRecordSet, recIdx, &pRecord); } BailError(err); - Assert(pRecord != nil); + Assert(pRecord != NULL); /* * Do some tests, looking for specific types of threads that conflict @@ -1153,13 +1153,13 @@ Nu_AddThread(NuArchive* pArchive, NuRecordIdx recIdx, NuThreadID threadID, err = Nu_ThreadModAdd_New(pArchive, threadID, threadFormat, pDataSource, &pThreadMod); BailError(err); - Assert(pThreadMod != nil); + Assert(pThreadMod != NULL); /* add the thread mod to the record */ Nu_RecordAddThreadMod(pRecord, pThreadMod); - if (pThreadIdx != nil) + if (pThreadIdx != NULL) *pThreadIdx = pThreadMod->entry.add.threadIdx; - pThreadMod = nil; /* successful, don't free */ + pThreadMod = NULL; /* successful, don't free */ /* * If we've got a header filename and we're adding a filename thread, @@ -1172,9 +1172,9 @@ Nu_AddThread(NuArchive* pArchive, NuRecordIdx recIdx, NuThreadID threadID, } bail: - if (pThreadMod != nil) + if (pThreadMod != NULL) Nu_ThreadModFree(pArchive, pThreadMod); - if (err == kNuErrNone && pDataSource != nil) { + if (err == kNuErrNone && pDataSource != NULL) { /* on success, we have ownership of the data source. ThreadMod made its own copy, so get rid of this one */ Nu_DataSourceFree(pDataSource); @@ -1199,11 +1199,11 @@ Nu_UpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx, NuDataSource* pDataSource, long* pMaxLen) { NuError err; - NuThreadMod* pThreadMod = nil; + NuThreadMod* pThreadMod = NULL; NuRecord* pFoundRecord; NuThread* pFoundThread; - if (pDataSource == nil) { + if (pDataSource == NULL) { err = kNuErrInvalidArg; goto bail; } @@ -1239,14 +1239,14 @@ Nu_UpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx, goto bail; } - if (pMaxLen != nil) + if (pMaxLen != NULL) *pMaxLen = pFoundThread->thCompThreadEOF; /* * Check to see if somebody is trying to delete this, or has already * updated it. */ - if (Nu_ThreadMod_FindByThreadIdx(pFoundRecord, threadIdx) != nil) { + if (Nu_ThreadMod_FindByThreadIdx(pFoundRecord, threadIdx) != NULL) { DBUG(("--- Tried to modify a deleted or modified thread\n")); err = kNuErrModThreadChange; goto bail; @@ -1294,7 +1294,7 @@ Nu_UpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx, Assert(pFoundThread->thThreadFormat == kNuThreadFormatUncompressed); err = Nu_ThreadModUpdate_New(pArchive, threadIdx, pDataSource, &pThreadMod); BailError(err); - Assert(pThreadMod != nil); + Assert(pThreadMod != NULL); /* add the thread mod to the record */ Nu_RecordAddThreadMod(pFoundRecord, pThreadMod); @@ -1326,7 +1326,7 @@ NuError Nu_DeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx) { NuError err; - NuThreadMod* pThreadMod = nil; + NuThreadMod* pThreadMod = NULL; NuRecord* pFoundRecord; NuThread* pFoundThread; @@ -1348,7 +1348,7 @@ Nu_DeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx) * allowed. Deletion of threads from deleted records can't happen, * because deleted records are completely removed from the "copy" set. */ - if (Nu_ThreadMod_FindByThreadIdx(pFoundRecord, threadIdx) != nil) { + if (Nu_ThreadMod_FindByThreadIdx(pFoundRecord, threadIdx) != NULL) { DBUG(("--- Tried to delete a deleted or modified thread\n")); err = kNuErrModThreadChange; goto bail; @@ -1361,7 +1361,7 @@ Nu_DeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx) NuGetThreadID(pFoundThread), &pThreadMod); BailError(err); Nu_RecordAddThreadMod(pFoundRecord, pThreadMod); - pThreadMod = nil; /* successful, don't free */ + pThreadMod = NULL; /* successful, don't free */ bail: Nu_ThreadModFree(pArchive, pThreadMod); diff --git a/nufxlib/Value.c b/nufxlib/Value.c index d6465f7..aec0b0d 100644 --- a/nufxlib/Value.c +++ b/nufxlib/Value.c @@ -19,7 +19,7 @@ Nu_GetValue(NuArchive* pArchive, NuValueID ident, NuValue* pValue) { NuError err = kNuErrNone; - if (pValue == nil) + if (pValue == NULL) return kNuErrInvalidArg; switch (ident) { @@ -229,7 +229,7 @@ NuError Nu_GetAttr(NuArchive* pArchive, NuAttrID ident, NuAttr* pAttr) { NuError err = kNuErrNone; - if (pAttr == nil) + if (pAttr == NULL) return kNuErrInvalidArg; switch (ident) { diff --git a/nufxlib/Version.c b/nufxlib/Version.c index 7eec7c2..869a228 100644 --- a/nufxlib/Version.c +++ b/nufxlib/Version.c @@ -27,15 +27,15 @@ NuError Nu_GetVersion(long* pMajorVersion, long* pMinorVersion, long* pBugVersion, const char** ppBuildDate, const char** ppBuildFlags) { - if (pMajorVersion != nil) + if (pMajorVersion != NULL) *pMajorVersion = kNuVersionMajor; - if (pMinorVersion != nil) + if (pMinorVersion != NULL) *pMinorVersion = kNuVersionMinor; - if (pBugVersion != nil) + if (pBugVersion != NULL) *pBugVersion = kNuVersionBug; - if (ppBuildDate != nil) + if (ppBuildDate != NULL) *ppBuildDate = gNuBuildDate; - if (ppBuildFlags != nil) + if (ppBuildFlags != NULL) *ppBuildFlags = gNuBuildFlags; return kNuErrNone; } diff --git a/nufxlib/samples/Common.h b/nufxlib/samples/Common.h index 0f377b8..a8c1aa2 100644 --- a/nufxlib/samples/Common.h +++ b/nufxlib/samples/Common.h @@ -16,8 +16,6 @@ # include "dmalloc.h" #endif -#define nil NULL /* this is seriously habit-forming */ - #define NELEM(x) (sizeof(x) / sizeof((x)[0])) #ifndef __cplusplus diff --git a/nufxlib/samples/Exerciser.c b/nufxlib/samples/Exerciser.c index e3be72d..f18cb1b 100644 --- a/nufxlib/samples/Exerciser.c +++ b/nufxlib/samples/Exerciser.c @@ -50,12 +50,12 @@ ExerciserState_New(void) ExerciserState* pExerState; pExerState = (ExerciserState*) malloc(sizeof(*pExerState)); - if (pExerState == nil) - return nil; + if (pExerState == NULL) + return NULL; - pExerState->pArchive = nil; - pExerState->archivePath = nil; - pExerState->archiveFile = nil; + pExerState->pArchive = NULL; + pExerState->archivePath = NULL; + pExerState->archiveFile = NULL; return pExerState; } @@ -63,15 +63,15 @@ ExerciserState_New(void) void ExerciserState_Free(ExerciserState* pExerState) { - if (pExerState == nil) + if (pExerState == NULL) return; - if (pExerState->pArchive != nil) { + if (pExerState->pArchive != NULL) { printf("Exerciser: aborting open archive\n"); (void) NuAbort(pExerState->pArchive); (void) NuClose(pExerState->pArchive); } - if (pExerState->archivePath != nil) + if (pExerState->archivePath != NULL) free(pExerState->archivePath); free(pExerState); @@ -98,19 +98,19 @@ ExerciserState_GetArchivePath(const ExerciserState* pExerState) inline void ExerciserState_SetArchivePath(ExerciserState* pExerState, char* newPath) { - if (pExerState->archivePath != nil) + if (pExerState->archivePath != NULL) free(pExerState->archivePath); - if (newPath == nil) { - pExerState->archivePath = nil; - pExerState->archiveFile = nil; + if (newPath == NULL) { + pExerState->archivePath = NULL; + pExerState->archiveFile = NULL; } else { pExerState->archivePath = strdup(newPath); pExerState->archiveFile = strrchr(newPath, kFssep); - if (pExerState->archiveFile != nil) + if (pExerState->archiveFile != NULL) pExerState->archiveFile++; - if (pExerState->archiveFile == nil || *pExerState->archiveFile == '\0') + if (pExerState->archiveFile == NULL || *pExerState->archiveFile == '\0') pExerState->archiveFile = pExerState->archivePath; } } @@ -118,7 +118,7 @@ ExerciserState_SetArchivePath(ExerciserState* pExerState, char* newPath) inline const char* ExerciserState_GetArchiveFile(const ExerciserState* pExerState) { - if (pExerState->archiveFile == nil) + if (pExerState->archiveFile == NULL) return "[no archive open]"; else return pExerState->archiveFile; @@ -151,7 +151,7 @@ PrintEntry(NuArchive* pArchive, void* vpRecord) const char* threadLabel; pThread = NuGetThread(pRecord, idx); - assert(pThread != nil); + assert(pThread != NULL); threadID = NuGetThreadID(pThread); switch (NuThreadIDGetClass(threadID)) { @@ -217,7 +217,7 @@ GetLine(const char* prompt, char* buffer, int bufferSize) printf("%s> ", prompt); fflush(stdout); - if (fgets(buffer, bufferSize, stdin) == nil) + if (fgets(buffer, bufferSize, stdin) == NULL) return kNuErrGeneric; if (buffer[strlen(buffer)-1] == '\n') @@ -239,7 +239,7 @@ SelectionFilter(NuArchive* pArchive, void* vselFilt) printf("%s (N/y)? ", selProposal->pRecord->filename); fflush(stdout); - if (fgets(buffer, sizeof(buffer), stdin) == nil) + if (fgets(buffer, sizeof(buffer), stdin) == NULL) return kNuAbort; if (tolower(buffer[0]) == 'y') @@ -262,7 +262,7 @@ ErrorHandler(NuArchive* pArchive, void* vErrorStatus) printf("Exerciser: error handler op=%d err=%d sysErr=%d message='%s'\n" "\tfilename='%s' '%c'(0x%02x)\n", pErrorStatus->operation, pErrorStatus->err, pErrorStatus->sysErr, - pErrorStatus->message == nil ? "(nil)" : pErrorStatus->message, + pErrorStatus->message == NULL ? "(NULL)" : pErrorStatus->message, pErrorStatus->pathname, pErrorStatus->filenameSeparator, pErrorStatus->filenameSeparator); printf("\tValid options are:"); @@ -283,7 +283,7 @@ ErrorHandler(NuArchive* pArchive, void* vErrorStatus) printf("Return what (a/r/i/s/e/o)? "); fflush(stdout); - if (fgets(buffer, sizeof(buffer), stdin) == nil) { + if (fgets(buffer, sizeof(buffer), stdin) == NULL) { printf("Returning kNuSkip\n"); } else switch (buffer[0]) { case 'a': result = kNuAbort; break; @@ -365,7 +365,7 @@ static NuError AbortFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); return NuAbort(ExerciserState_GetNuArchive(pState)); @@ -380,7 +380,7 @@ AddFileFunc(ExerciserState* pState, int argc, char** argv) NuFileDetails nuFileDetails; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); memset(&nuFileDetails, 0, sizeof(nuFileDetails)); @@ -392,7 +392,7 @@ AddFileFunc(ExerciserState* pState, int argc, char** argv) /* fileType, extraType, storageType, dates */ return NuAddFile(ExerciserState_GetNuArchive(pState), argv[1], - &nuFileDetails, false, nil); + &nuFileDetails, false, NULL); } /* @@ -406,7 +406,7 @@ AddRecordFunc(ExerciserState* pState, int argc, char** argv) NuFileDetails nuFileDetails; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); memset(&nuFileDetails, 0, sizeof(nuFileDetails)); @@ -431,20 +431,20 @@ static NuError AddThreadFunc(ExerciserState* pState, int argc, char** argv) { NuError err; - NuDataSource* pDataSource = nil; - char* lineBuf = nil; + NuDataSource* pDataSource = NULL; + char* lineBuf = NULL; long ourLen, maxLen; NuThreadID threadID; NuThreadIdx threadIdx; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 3); lineBuf = (char*)malloc(kNiceLineLen); - assert(lineBuf != nil); + assert(lineBuf != NULL); - threadID = strtol(argv[2], nil, 0); + threadID = strtol(argv[2], NULL, 0); if (NuThreadIDGetClass(threadID) == kNuThreadClassData) { /* load data from a file on disk */ maxLen = 0; @@ -470,7 +470,7 @@ AddThreadFunc(ExerciserState* pState, int argc, char** argv) err = GetLine("Enter max buffer size", lineBuf, kNiceLineLen); if (err != kNuErrNone) goto bail; - maxLen = strtol(lineBuf, nil, 0); + maxLen = strtol(lineBuf, NULL, 0); if (maxLen <= 0) { fprintf(stderr, "Bad length\n"); err = kNuErrInvalidArg; @@ -494,21 +494,21 @@ AddThreadFunc(ExerciserState* pState, int argc, char** argv) "Exerciser: buffer data source create failed (err=%d)\n", err); goto bail; } - lineBuf = nil; /* now owned by the library */ + lineBuf = NULL; /* now owned by the library */ } err = NuAddThread(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0), threadID, pDataSource, &threadIdx); + strtol(argv[1], NULL, 0), threadID, pDataSource, &threadIdx); if (err == kNuErrNone) { - pDataSource = nil; /* library owns it now */ + pDataSource = NULL; /* library owns it now */ printf("Exerciser: success; function returned threadIdx=%ld\n", threadIdx); } bail: NuFreeDataSource(pDataSource); - if (lineBuf != nil) + if (lineBuf != NULL) free(lineBuf); return err; } @@ -522,13 +522,13 @@ CloseFunc(ExerciserState* pState, int argc, char** argv) NuError err; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); err = NuClose(ExerciserState_GetNuArchive(pState)); if (err == kNuErrNone) { - ExerciserState_SetNuArchive(pState, nil); - ExerciserState_SetArchivePath(pState, nil); + ExerciserState_SetNuArchive(pState, NULL); + ExerciserState_SetArchivePath(pState, NULL); } return err; @@ -541,7 +541,7 @@ static NuError DeleteFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); NuSetSelectionFilter(ExerciserState_GetNuArchive(pState), SelectionFilter); @@ -556,11 +556,11 @@ static NuError DeleteRecordFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); return NuDeleteRecord(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0)); + strtol(argv[1], NULL, 0)); } /* @@ -570,11 +570,11 @@ static NuError DeleteThreadFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); return NuDeleteThread(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0)); + strtol(argv[1], NULL, 0)); } /* @@ -584,7 +584,7 @@ static NuError ExtractFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); NuSetSelectionFilter(ExerciserState_GetNuArchive(pState), SelectionFilter); @@ -599,11 +599,11 @@ static NuError ExtractRecordFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); return NuExtractRecord(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0)); + strtol(argv[1], NULL, 0)); } /* @@ -613,10 +613,10 @@ static NuError ExtractThreadFunc(ExerciserState* pState, int argc, char** argv) { NuError err; - NuDataSink* pDataSink = nil; + NuDataSink* pDataSink = NULL; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 3); err = NuCreateDataSinkForFile(true, kNuConvertOff, argv[2], kFssep, @@ -627,7 +627,7 @@ ExtractThreadFunc(ExerciserState* pState, int argc, char** argv) } err = NuExtractThread(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0), pDataSink); + strtol(argv[1], NULL, 0), pDataSink); /* fall through with err */ bail: @@ -645,7 +645,7 @@ FlushFunc(ExerciserState* pState, int argc, char** argv) long flushStatus; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); err = NuFlush(ExerciserState_GetNuArchive(pState), &flushStatus); @@ -667,11 +667,11 @@ GetValueFunc(ExerciserState* pState, int argc, char** argv) NuValue value; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); err = NuGetValue(ExerciserState_GetNuArchive(pState), - (NuValueID) strtol(argv[1], nil, 0), &value); + (NuValueID) strtol(argv[1], NULL, 0), &value); if (err == kNuErrNone) printf(" --> %ld\n", value); return err; @@ -687,7 +687,7 @@ GetMasterHeaderFunc(ExerciserState* pState, int argc, char** argv) const NuMasterHeader* pMasterHeader; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); err = NuGetMasterHeader(ExerciserState_GetNuArchive(pState), @@ -710,11 +710,11 @@ GetRecordFunc(ExerciserState* pState, int argc, char** argv) const NuRecord* pRecord; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); err = NuGetRecord(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0), &pRecord); + strtol(argv[1], NULL, 0), &pRecord); if (err == kNuErrNone) { printf("Exerciser: success, call returned:\n"); printf("\tfileSysID : %d\n", pRecord->recFileSysID); @@ -740,7 +740,7 @@ GetRecordIdxByNameFunc(ExerciserState* pState, int argc, char** argv) NuRecordIdx recIdx; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); err = NuGetRecordIdxByName(ExerciserState_GetNuArchive(pState), @@ -760,11 +760,11 @@ GetRecordIdxByPositionFunc(ExerciserState* pState, int argc, char** argv) NuRecordIdx recIdx; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); err = NuGetRecordIdxByPosition(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0), &recIdx); + strtol(argv[1], NULL, 0), &recIdx); if (err == kNuErrNone) printf("Exerciser: success, returned recordIdx=%ld\n", recIdx); return err; @@ -779,7 +779,7 @@ OpenCreateReadWriteFunc(ExerciserState* pState, int argc, char** argv) NuError err; NuArchive* pArchive; - assert(ExerciserState_GetNuArchive(pState) == nil); + assert(ExerciserState_GetNuArchive(pState) == NULL); assert(argc == 2); err = NuOpenRW(argv[1], kTempFile, kNuOpenCreat|kNuOpenExcl, &pArchive); @@ -800,7 +800,7 @@ OpenReadOnlyFunc(ExerciserState* pState, int argc, char** argv) NuError err; NuArchive* pArchive; - assert(ExerciserState_GetNuArchive(pState) == nil); + assert(ExerciserState_GetNuArchive(pState) == NULL); assert(argc == 2); err = NuOpenRO(argv[1], &pArchive); @@ -820,12 +820,12 @@ OpenStreamingReadOnlyFunc(ExerciserState* pState, int argc, char** argv) { NuError err; NuArchive* pArchive; - FILE* fp = nil; + FILE* fp = NULL; - assert(ExerciserState_GetNuArchive(pState) == nil); + assert(ExerciserState_GetNuArchive(pState) == NULL); assert(argc == 2); - if ((fp = fopen(argv[1], kNuFileOpenReadOnly)) == nil) { + if ((fp = fopen(argv[1], kNuFileOpenReadOnly)) == NULL) { err = errno ? (NuError)errno : kNuErrGeneric; fprintf(stderr, "Exerciser: unable to open '%s'\n", argv[1]); } else { @@ -833,11 +833,11 @@ OpenStreamingReadOnlyFunc(ExerciserState* pState, int argc, char** argv) if (err == kNuErrNone) { ExerciserState_SetNuArchive(pState, pArchive); ExerciserState_SetArchivePath(pState, argv[1]); - fp = nil; + fp = NULL; } } - if (fp != nil) + if (fp != NULL) fclose(fp); return err; @@ -852,7 +852,7 @@ OpenReadWriteFunc(ExerciserState* pState, int argc, char** argv) NuError err; NuArchive* pArchive; - assert(ExerciserState_GetNuArchive(pState) == nil); + assert(ExerciserState_GetNuArchive(pState) == NULL); assert(argc == 2); err = NuOpenRW(argv[1], kTempFile, 0, &pArchive); @@ -871,7 +871,7 @@ static NuError PrintFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); return NuContents(ExerciserState_GetNuArchive(pState), PrintEntry); @@ -884,7 +884,7 @@ static NuError PrintDebugFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); return NuDebugDumpArchive(ExerciserState_GetNuArchive(pState)); @@ -897,11 +897,11 @@ static NuError RenameFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 4); return NuRename(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0), argv[2], argv[3][0]); + strtol(argv[1], NULL, 0), argv[2], argv[3][0]); } /* @@ -913,7 +913,7 @@ static NuError SetErrorCallbackFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); NuSetErrorHandler(ExerciserState_GetNuArchive(pState), ErrorHandler); @@ -929,11 +929,11 @@ static NuError SetValueFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 3); return NuSetValue(ExerciserState_GetNuArchive(pState), - (NuValueID) strtol(argv[1], nil, 0), strtol(argv[2], nil, 0)); + (NuValueID) strtol(argv[1], NULL, 0), strtol(argv[2], NULL, 0)); } /* @@ -952,20 +952,20 @@ SetRecordAttrFunc(ExerciserState* pState, int argc, char** argv) NuRecordAttr recordAttr; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 4); err = NuGetRecord(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0), &pRecord); + strtol(argv[1], NULL, 0), &pRecord); if (err != kNuErrNone) return err; printf("Exerciser: NuGetRecord succeeded, calling NuSetRecordAttr\n"); NuRecordCopyAttr(&recordAttr, pRecord); - recordAttr.fileType = strtol(argv[2], nil, 0); - recordAttr.extraType = strtol(argv[3], nil, 0); + recordAttr.fileType = strtol(argv[2], NULL, 0); + recordAttr.extraType = strtol(argv[3], NULL, 0); /*recordAttr.fileSysInfo = ':';*/ return NuSetRecordAttr(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0), &recordAttr); + strtol(argv[1], NULL, 0), &recordAttr); } /* @@ -975,7 +975,7 @@ static NuError TestFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 1); return NuTest(ExerciserState_GetNuArchive(pState)); @@ -988,11 +988,11 @@ static NuError TestRecordFunc(ExerciserState* pState, int argc, char** argv) { (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); return NuTestRecord(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0)); + strtol(argv[1], NULL, 0)); } /* @@ -1002,16 +1002,16 @@ static NuError UpdatePresizedThreadFunc(ExerciserState* pState, int argc, char** argv) { NuError err; - NuDataSource* pDataSource = nil; - char* lineBuf = nil; + NuDataSource* pDataSource = NULL; + char* lineBuf = NULL; long ourLen, maxLen; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ - assert(ExerciserState_GetNuArchive(pState) != nil); + assert(ExerciserState_GetNuArchive(pState) != NULL); assert(argc == 2); lineBuf = (char*)malloc(kNiceLineLen); - assert(lineBuf != nil); + assert(lineBuf != NULL); err = GetLine("Enter data for thread", lineBuf, kNiceLineLen); if (err != kNuErrNone) goto bail; @@ -1027,16 +1027,16 @@ UpdatePresizedThreadFunc(ExerciserState* pState, int argc, char** argv) err); goto bail; } - lineBuf = nil; /* now owned by the library */ + lineBuf = NULL; /* now owned by the library */ err = NuUpdatePresizedThread(ExerciserState_GetNuArchive(pState), - strtol(argv[1], nil, 0), pDataSource, &maxLen); + strtol(argv[1], NULL, 0), pDataSource, &maxLen); if (err == kNuErrNone) printf("Exerciser: success; function returned maxLen=%ld\n", maxLen); bail: NuFreeDataSource(pDataSource); - if (lineBuf != nil) + if (lineBuf != NULL) free(lineBuf); return err; } @@ -1185,22 +1185,22 @@ ParseLine(char* lineBuf, ExerciserState* pState, CommandFunc* pFunc, int* pArgc, */ command = strtok(lineBuf, kWhitespace); - if (command == nil) { + if (command == NULL) { /* no command; the user probably just hit "enter" on a blank line */ *pFunc = NothingFunc; *pArgc = 0; - *pArgv = nil; + *pArgv = NULL; err = kNuErrNone; goto bail; } - /* no real need to be flexible; add 1 for command and one for nil */ + /* no real need to be flexible; add 1 for command and one for NULL */ *pArgv = (char**) malloc(sizeof(char*) * (kMaxArgs+2)); (*pArgv)[0] = command; *pArgc = 1; - cp = strtok(nil, kWhitespace); - while (cp != nil) { + cp = strtok(NULL, kWhitespace); + while (cp != NULL) { if (*pArgc >= kMaxArgs+1) { printf("ERROR: too many arguments\n"); goto bail; @@ -1208,10 +1208,10 @@ ParseLine(char* lineBuf, ExerciserState* pState, CommandFunc* pFunc, int* pArgc, (*pArgv)[*pArgc] = cp; (*pArgc)++; - cp = strtok(nil, kWhitespace); + cp = strtok(NULL, kWhitespace); } assert(*pArgc < kMaxArgs+2); - (*pArgv)[*pArgc] = nil; + (*pArgv)[*pArgc] = NULL; /* * Look up the command. @@ -1237,13 +1237,13 @@ ParseLine(char* lineBuf, ExerciserState* pState, CommandFunc* pFunc, int* pArgc, } if (gCommandTable[i].flags & kFlagArchiveReq) { - if (ExerciserState_GetNuArchive(pState) == nil) { + if (ExerciserState_GetNuArchive(pState) == NULL) { printf("ERROR: must have an archive open\n"); goto bail; } } if (gCommandTable[i].flags & kFlagNoArchiveReq) { - if (ExerciserState_GetNuArchive(pState) != nil) { + if (ExerciserState_GetNuArchive(pState) != NULL) { printf("ERROR: an archive is already open\n"); goto bail; } @@ -1271,29 +1271,29 @@ CommandLoop(void) CommandFunc func; char lineBuf[128]; int argc; - char** argv = nil; + char** argv = NULL; while (1) { printf("\nEnter command (%s)> ", ExerciserState_GetArchiveFile(pState)); fflush(stdout); - if (fgets(lineBuf, sizeof(lineBuf), stdin) == nil) { + if (fgets(lineBuf, sizeof(lineBuf), stdin) == NULL) { printf("\n"); break; } - if (argv != nil) { + if (argv != NULL) { free(argv); - argv = nil; + argv = NULL; } - func = nil; /* sanity check */ + func = NULL; /* sanity check */ err = ParseLine(lineBuf, pState, &func, &argc, &argv); if (err != kNuErrNone) continue; - assert(func != nil); + assert(func != NULL); if (func == QuitFunc) break; @@ -1304,13 +1304,13 @@ CommandLoop(void) else if (err > 0) printf("Exerciser: received error %d\n", err); - if (argv != nil) { + if (argv != NULL) { free(argv); - argv = nil; + argv = NULL; } } - if (ExerciserState_GetNuArchive(pState) != nil) { + if (ExerciserState_GetNuArchive(pState) != NULL) { /* ought to query the archive before saying something like this... */ printf("Exerciser: aborting any un-flushed changes in archive %s\n", ExerciserState_GetArchivePath(pState)); @@ -1318,12 +1318,12 @@ CommandLoop(void) err = NuClose(ExerciserState_GetNuArchive(pState)); if (err != kNuErrNone) printf("Exerciser: got error %d closing archive\n", err); - ExerciserState_SetNuArchive(pState, nil); + ExerciserState_SetNuArchive(pState, NULL); } - if (pState != nil) + if (pState != NULL) ExerciserState_Free(pState); - if (argv != nil) + if (argv != NULL) free(argv); return kNuErrNone; } @@ -1371,7 +1371,7 @@ main(void) */ { char* debugSet = getenv("MALLOC_CHECK_"); - if (debugSet == nil) + if (debugSet == NULL) printf("WARNING: MALLOC_CHECK_ not enabled\n\n"); } #endif diff --git a/nufxlib/samples/ImgConv.c b/nufxlib/samples/ImgConv.c index a697b60..d765bb5 100644 --- a/nufxlib/samples/ImgConv.c +++ b/nufxlib/samples/ImgConv.c @@ -259,7 +259,7 @@ CreateDosSource(const ImgHeader* pHeader, FILE* fp, NuDataSource** ppDataSource) { NuError err; - char* diskBuffer = nil; + char* diskBuffer = NULL; long offset; if (pHeader->dataLen % 4096) { @@ -277,7 +277,7 @@ CreateDosSource(const ImgHeader* pHeader, FILE* fp, } diskBuffer = malloc(pHeader->dataLen); - if (diskBuffer == nil) { + if (diskBuffer == NULL) { fprintf(stderr, "ERROR: malloc(%ld) failed\n", pHeader->dataLen); err = kNuErrMalloc; goto bail; @@ -322,10 +322,10 @@ CreateDosSource(const ImgHeader* pHeader, FILE* fp, (const unsigned char*) diskBuffer, 0, pHeader->dataLen, FreeCallback, ppDataSource); if (err == kNuErrNone) - diskBuffer = nil; + diskBuffer = NULL; bail: - if (diskBuffer != nil) + if (diskBuffer != NULL) free(diskBuffer); return err; } @@ -342,14 +342,14 @@ int ConvertFromImgToShk(const char* srcName, const char* dstName) { NuError err; - NuArchive* pArchive = nil; - NuDataSource* pDataSource = nil; + NuArchive* pArchive = NULL; + NuDataSource* pDataSource = NULL; NuRecordIdx recordIdx; NuFileDetails fileDetails; ImgHeader header; - FILE* fp = nil; + FILE* fp = NULL; long flushStatus; - char* storageName = nil; + char* storageName = NULL; char* cp; printf("Converting 2IMG file '%s' to ShrinkIt archive '%s'\n\n", @@ -394,10 +394,10 @@ ConvertFromImgToShk(const char* srcName, const char* dstName) /* create the name that will be stored in the archive */ storageName = strdup(dstName); cp = strrchr(storageName, '.'); - if (cp != nil) + if (cp != NULL) *cp = '\0'; cp = strrchr(storageName, kLocalFssep); - if (cp != nil && *(cp+1) != '\0') + if (cp != NULL && *(cp+1) != '\0') cp++; else cp = storageName; @@ -433,11 +433,11 @@ ConvertFromImgToShk(const char* srcName, const char* dstName) switch (header.imageFormat) { case kImageFormatDOS: err = CreateDosSource(&header, fp, &pDataSource); - fp = nil; + fp = NULL; break; case kImageFormatProDOS: err = CreateProdosSource(&header, fp, &pDataSource); - fp = nil; + fp = NULL; break; default: fprintf(stderr, "How the heck did I get here?"); @@ -451,12 +451,12 @@ ConvertFromImgToShk(const char* srcName, const char* dstName) /* add a disk image thread */ err = NuAddThread(pArchive, recordIdx, kNuThreadIDDiskImage, pDataSource, - nil); + NULL); if (err != kNuErrNone) { fprintf(stderr, "ERROR: unable to create thread (err=%d)\n", err); goto bail; } - pDataSource = nil; /* library owns it now */ + pDataSource = NULL; /* library owns it now */ /* nothing happens until we Flush */ err = NuFlush(pArchive, &flushStatus); @@ -470,17 +470,17 @@ ConvertFromImgToShk(const char* srcName, const char* dstName) fprintf(stderr, "ERROR: close failed (err=%d)\n", err); goto bail; } - pArchive = nil; + pArchive = NULL; bail: - if (pArchive != nil) { + if (pArchive != NULL) { (void)NuAbort(pArchive); (void)NuClose(pArchive); } NuFreeDataSource(pDataSource); - if (storageName != nil) + if (storageName != NULL) free(storageName); - if (fp != nil) + if (fp != NULL) fclose(fp); return (err == kNuErrNone) ? 0 : -1; } @@ -496,13 +496,13 @@ int ConvertFromShkToImg(const char* srcName, const char* dstName) { NuError err; - NuArchive* pArchive = nil; - NuDataSink* pDataSink = nil; + NuArchive* pArchive = NULL; + NuDataSink* pDataSink = NULL; NuRecordIdx recordIdx; const NuRecord* pRecord; - const NuThread* pThread = nil; + const NuThread* pThread = NULL; ImgHeader header; - FILE* fp = nil; + FILE* fp = NULL; int idx; printf("Converting ShrinkIt archive '%s' to 2IMG file '%s'\n\n", @@ -592,10 +592,10 @@ ConvertFromShkToImg(const char* srcName, const char* dstName) } bail: - if (pArchive != nil) + if (pArchive != NULL) NuClose(pArchive); NuFreeDataSink(pDataSink); - if (fp != nil) + if (fp != NULL) fclose(fp); return (err == kNuErrNone) ? 0 : -1; } @@ -610,7 +610,7 @@ DetermineKind(const char* filename) const char* dot; dot = strrchr(filename, '.'); - if (dot == nil) + if (dot == NULL) return kKindUnknown; if (strcasecmp(dot, ".shk") == 0 || strcasecmp(dot, ".sdk") == 0) diff --git a/nufxlib/samples/Launder.c b/nufxlib/samples/Launder.c index bc0f525..dc485fc 100644 --- a/nufxlib/samples/Launder.c +++ b/nufxlib/samples/Launder.c @@ -65,9 +65,9 @@ CopyThreadRecompressed(NuArchive* pInArchive, NuArchive* pOutArchive, long flags, const NuThread* pThread, long newRecordIdx) { NuError err = kNuErrNone; - NuDataSource* pDataSource = nil; - NuDataSink* pDataSink = nil; - uchar* buffer = nil; + NuDataSource* pDataSource = NULL; + NuDataSink* pDataSink = NULL; + uchar* buffer = NULL; /* * Allocate a buffer large enough to hold all the uncompressed data, and @@ -77,7 +77,7 @@ CopyThreadRecompressed(NuArchive* pInArchive, NuArchive* pOutArchive, */ if (pThread->actualThreadEOF) { buffer = malloc(pThread->actualThreadEOF); - if (buffer == nil) { + if (buffer == NULL) { err = kNuErrMalloc; goto bail; } @@ -111,7 +111,7 @@ CopyThreadRecompressed(NuArchive* pInArchive, NuArchive* pOutArchive, * We always use "actualThreadEOF" because "thThreadEOF" is broken * for disk archives created by certain versions of ShrinkIt. * - * It's okay to pass in a nil value for "buffer", so long as the + * It's okay to pass in a NULL value for "buffer", so long as the * amount of data in the buffer is also zero. The library will do * the right thing. */ @@ -134,25 +134,25 @@ CopyThreadRecompressed(NuArchive* pInArchive, NuArchive* pOutArchive, goto bail; } } - buffer = nil; /* doClose was set, so it's owned by the data source */ + buffer = NULL; /* doClose was set, so it's owned by the data source */ /* * Schedule the data for addition to the record. */ err = NuAddThread(pOutArchive, newRecordIdx, NuGetThreadID(pThread), - pDataSource, nil); + pDataSource, NULL); if (err != kNuErrNone) { fprintf(stderr, "ERROR: unable to add thread (err=%d)\n", err); goto bail; } - pDataSource = nil; /* library owns it now */ + pDataSource = NULL; /* library owns it now */ bail: - if (pDataSource != nil) + if (pDataSource != NULL) NuFreeDataSource(pDataSource); - if (pDataSink != nil) + if (pDataSink != NULL) NuFreeDataSink(pDataSink); - if (buffer != nil) + if (buffer != NULL) free(buffer); return err; } @@ -179,9 +179,9 @@ CopyThreadUncompressed(NuArchive* pInArchive, NuArchive* pOutArchive, long flags, const NuThread* pThread, long newRecordIdx) { NuError err = kNuErrNone; - NuDataSource* pDataSource = nil; - NuDataSink* pDataSink = nil; - uchar* buffer = nil; + NuDataSource* pDataSource = NULL; + NuDataSink* pDataSink = NULL; + uchar* buffer = NULL; /* * If we have some data files that were left uncompressed, perhaps @@ -207,7 +207,7 @@ CopyThreadUncompressed(NuArchive* pInArchive, NuArchive* pOutArchive, * wrap a data sink around it. */ buffer = malloc(pThread->thCompThreadEOF); - if (buffer == nil) { + if (buffer == NULL) { err = kNuErrMalloc; goto bail; } @@ -265,7 +265,7 @@ CopyThreadUncompressed(NuArchive* pInArchive, NuArchive* pOutArchive, goto bail; } } - buffer = nil; /* doClose was set, so it's owned by the data source */ + buffer = NULL; /* doClose was set, so it's owned by the data source */ /* yes, this is a kluge... sigh */ err = NuDataSourceSetRawCrc(pDataSource, pThread->thThreadCRC); @@ -281,19 +281,19 @@ CopyThreadUncompressed(NuArchive* pInArchive, NuArchive* pOutArchive, * "doClose" on our copy, so we are free to dispose of pDataSource. */ err = NuAddThread(pOutArchive, newRecordIdx, NuGetThreadID(pThread), - pDataSource, nil); + pDataSource, NULL); if (err != kNuErrNone) { fprintf(stderr, "ERROR: unable to add thread (err=%d)\n", err); goto bail; } - pDataSource = nil; /* library owns it now */ + pDataSource = NULL; /* library owns it now */ bail: - if (pDataSource != nil) + if (pDataSource != NULL) NuFreeDataSource(pDataSource); - if (pDataSink != nil) + if (pDataSink != NULL) NuFreeDataSink(pDataSink); - if (buffer != nil) + if (buffer != NULL) free(buffer); return err; } @@ -393,7 +393,7 @@ CopyRecord(NuArchive* pInArchive, NuArchive* pOutArchive, long flags, if (flags & kFlagReverseThreads) { for (idx = numThreads-1; idx >= 0; idx--) { pThread = NuGetThread(pRecord, idx); - assert(pThread != nil); + assert(pThread != NULL); err = CopyThread(pInArchive, pOutArchive, flags, pThread, newRecordIdx); @@ -403,7 +403,7 @@ CopyRecord(NuArchive* pInArchive, NuArchive* pOutArchive, long flags, } else { for (idx = 0; idx < numThreads; idx++) { pThread = NuGetThread(pRecord, idx); - assert(pThread != nil); + assert(pThread != NULL); err = CopyThread(pInArchive, pOutArchive, flags, pThread, newRecordIdx); @@ -427,8 +427,8 @@ LaunderArchive(const char* inFile, const char* outFile, NuValue compressMethod, long flags) { NuError err = kNuErrNone; - NuArchive* pInArchive = nil; - NuArchive* pOutArchive = nil; + NuArchive* pInArchive = NULL; + NuArchive* pOutArchive = NULL; const NuMasterHeader* pMasterHeader; NuRecordIdx recordIdx; long idx, flushStatus; @@ -541,9 +541,9 @@ LaunderArchive(const char* inFile, const char* outFile, NuValue compressMethod, } bail: - if (pInArchive != nil) + if (pInArchive != NULL) NuClose(pInArchive); - if (pOutArchive != nil) { + if (pOutArchive != NULL) { if (err != kNuErrNone) NuAbort(pOutArchive); NuClose(pOutArchive); /* flush pending changes and close */ @@ -559,8 +559,8 @@ bail: * does everything we need here. */ int myoptind = 0; -char* myoptarg = nil; -const char* curchar = nil; +char* myoptarg = NULL; +const char* curchar = NULL; int skipnext = false; int @@ -638,7 +638,7 @@ main(int argc, char** argv) int ic; int cc; - (void) NuGetVersion(&major, &minor, &bug, &pBuildDate, nil); + (void) NuGetVersion(&major, &minor, &bug, &pBuildDate, NULL); printf("Using NuFX lib %ld.%ld.%ld built on or after %s\n", major, minor, bug, pBuildDate); diff --git a/nufxlib/samples/TestBasic.c b/nufxlib/samples/TestBasic.c index 44c85c3..f576737 100644 --- a/nufxlib/samples/TestBasic.c +++ b/nufxlib/samples/TestBasic.c @@ -44,7 +44,7 @@ TGetReplyChar(char defaultReply) { char tmpBuf[32]; - if (fgets(tmpBuf, sizeof(tmpBuf), stdin) == nil) + if (fgets(tmpBuf, sizeof(tmpBuf), stdin) == NULL) return defaultReply; if (tmpBuf[0] == '\n' || tmpBuf[0] == '\r') return defaultReply; @@ -80,12 +80,12 @@ ErrorMessageHandler(NuArchive* pArchive, void* vErrorMessage) if (pErrorMessage->isDebug) { fprintf(stderr, "%sNufxLib says: [%s:%d %s] %s\n", - pArchive == nil ? "GLOBAL>" : "", + pArchive == NULL ? "GLOBAL>" : "", pErrorMessage->file, pErrorMessage->line, pErrorMessage->function, pErrorMessage->message); } else { fprintf(stderr, "%sNufxLib says: %s\n", - pArchive == nil ? "GLOBAL>" : "", + pArchive == NULL ? "GLOBAL>" : "", pErrorMessage->message); } @@ -117,17 +117,17 @@ int Test_OpenFlags(void) { NuError err; - FILE* fp = nil; - NuArchive* pArchive = nil; + FILE* fp = NULL; + NuArchive* pArchive = NULL; printf("... open zero-byte existing\n"); fp = fopen(kTestArchive, kNuFileOpenWriteTrunc); - if (fp == nil) { + if (fp == NULL) { perror("fopen kTestArchive"); goto failed; } fclose(fp); - fp = nil; + fp = NULL; FAIL_OK; err = NuOpenRW(kTestArchive, kTestTempFile, kNuOpenCreat|kNuOpenExcl, @@ -149,7 +149,7 @@ Test_OpenFlags(void) fprintf(stderr, "ERROR: close failed\n"); goto failed; } - pArchive = nil; + pArchive = NULL; if (access(kTestArchive, F_OK) == 0) { fprintf(stderr, "ERROR: archive should have been removed but wasn't\n"); @@ -159,7 +159,7 @@ Test_OpenFlags(void) return 0; failed: - if (pArchive != nil) { + if (pArchive != NULL) { NuAbort(pArchive); NuClose(pArchive); } @@ -174,8 +174,8 @@ int Test_AddStuff(NuArchive* pArchive) { NuError err; - uchar* buf = nil; - NuDataSource* pDataSource = nil; + uchar* buf = NULL; + NuDataSource* pDataSource = NULL; NuRecordIdx recordIdx; long status; int i; @@ -191,14 +191,14 @@ Test_AddStuff(NuArchive* pArchive) printf("... add 'bytes' record\n"); buf = malloc(131072); - if (buf == nil) + if (buf == NULL) goto failed; for (i = 0; i < 131072; i++) *(buf+i) = i & 0xff; FAIL_OK; err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, - 0, nil, 0, 131072, FreeCallback, &pDataSource); + 0, NULL, 0, 131072, FreeCallback, &pDataSource); FAIL_BAD; if (err == kNuErrNone) { fprintf(stderr, "ERROR: that should've failed!\n"); @@ -215,7 +215,7 @@ Test_AddStuff(NuArchive* pArchive) "ERROR: 'bytes' data source create failed (err=%d)\n", err); goto failed; } - buf = nil; /* now owned by library */ + buf = NULL; /* now owned by library */ err = AddSimpleRecord(pArchive, kTestEntryBytes, &recordIdx); if (err != kNuErrNone) { @@ -224,12 +224,12 @@ Test_AddStuff(NuArchive* pArchive) } err = NuAddThread(pArchive, recordIdx, kNuThreadIDDataFork, pDataSource, - nil); + NULL); if (err != kNuErrNone) { fprintf(stderr, "ERROR: 'bytes' thread add failed (err=%d)\n", err); goto failed; } - pDataSource = nil; /* now owned by library */ + pDataSource = NULL; /* now owned by library */ /* @@ -237,7 +237,7 @@ Test_AddStuff(NuArchive* pArchive) */ printf("... add 'English' record\n"); err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, - 0, (const uchar*)testMsg, 0, strlen(testMsg), nil, &pDataSource); + 0, (const uchar*)testMsg, 0, strlen(testMsg), NULL, &pDataSource); if (err != kNuErrNone) { fprintf(stderr, "ERROR: 'English' source create failed (err=%d)\n", err); @@ -246,7 +246,7 @@ Test_AddStuff(NuArchive* pArchive) FAIL_OK; err = NuAddThread(pArchive, recordIdx, kNuThreadIDDataFork, pDataSource, - nil); + NULL); FAIL_BAD; if (err == kNuErrNone) { fprintf(stderr, "ERROR: 'English' add should've conflicted!\n"); @@ -268,12 +268,12 @@ Test_AddStuff(NuArchive* pArchive) } err = NuAddThread(pArchive, recordIdx, kNuThreadIDDataFork, pDataSource, - nil); + NULL); if (err != kNuErrNone) { fprintf(stderr, "ERROR: 'English' thread add failed (err=%d)\n", err); goto failed; } - pDataSource = nil; /* now owned by library */ + pDataSource = NULL; /* now owned by library */ /* @@ -281,7 +281,7 @@ Test_AddStuff(NuArchive* pArchive) */ printf("... add 'long' record\n"); err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, - 0, nil, 0, 0, nil, &pDataSource); + 0, NULL, 0, 0, NULL, &pDataSource); if (err != kNuErrNone) { fprintf(stderr, "ERROR: 'English' source create failed (err=%d)\n", err); @@ -295,12 +295,12 @@ Test_AddStuff(NuArchive* pArchive) } err = NuAddThread(pArchive, recordIdx, kNuThreadIDRsrcFork, pDataSource, - nil); + NULL); if (err != kNuErrNone) { fprintf(stderr, "ERROR: 'long' thread add failed (err=%d)\n", err); goto failed; } - pDataSource = nil; /* now owned by library */ + pDataSource = NULL; /* now owned by library */ /* @@ -325,9 +325,9 @@ Test_AddStuff(NuArchive* pArchive) return 0; failed: - if (pDataSource != nil) + if (pDataSource != NULL) NuFreeDataSource(pDataSource); - if (buf != nil) + if (buf != NULL) free(buf); return -1; } @@ -390,7 +390,7 @@ Test_Contents(NuArchive* pArchive) recordIdx, err); goto failed; } - assert(pRecord != nil); + assert(pRecord != NULL); switch (posn) { case 0: @@ -444,10 +444,10 @@ VerifySelectionCallback(NuArchive* pArchive, void* vpProposal) const NuSelectionProposal* pProposal = vpProposal; long count; - if (pProposal->pRecord == nil || pProposal->pThread == nil || - pProposal->pRecord->filename == nil) + if (pProposal->pRecord == NULL || pProposal->pThread == NULL || + pProposal->pRecord->filename == NULL) { - fprintf(stderr, "ERROR: unexpected nil in proposal\n"); + fprintf(stderr, "ERROR: unexpected NULL in proposal\n"); goto failed; } @@ -527,8 +527,8 @@ Test_Extract(NuArchive* pArchive) NuRecordIdx recordIdx; const NuRecord* pRecord; const NuThread* pThread; - NuDataSink* pDataSink = nil; - uchar* buf = nil; + NuDataSink* pDataSink = NULL; + uchar* buf = NULL; printf("... extracting files\n"); @@ -553,11 +553,11 @@ Test_Extract(NuArchive* pArchive) recordIdx, err); goto failed; } - assert(pRecord != nil); + assert(pRecord != NULL); /* we're not using ShrinkIt compat mode, so there should not be a comment */ pThread = NuGetThread(pRecord, 1); - assert(pThread != nil); + assert(pThread != NULL); if (NuGetThreadID(pThread) != kNuThreadIDDataFork) { fprintf(stderr, "ERROR: 'bytes' had unexpected threadID 0x%08lx\n", NuGetThreadID(pThread)); @@ -565,7 +565,7 @@ Test_Extract(NuArchive* pArchive) } buf = malloc(pThread->actualThreadEOF); - if (buf == nil) { + if (buf == NULL) { fprintf(stderr, "ERROR: malloc(%ld) failed\n",pThread->actualThreadEOF); goto failed; } @@ -587,7 +587,7 @@ Test_Extract(NuArchive* pArchive) goto failed; } NuFreeDataSink(pDataSink); - pDataSink = nil; + pDataSink = NULL; /* * Try to extract with "on" conversion, which should fail because the @@ -608,7 +608,7 @@ Test_Extract(NuArchive* pArchive) goto failed; } NuFreeDataSink(pDataSink); - pDataSink = nil; + pDataSink = NULL; /* * Try to extract with "auto" conversion, which should conclude that @@ -628,12 +628,12 @@ Test_Extract(NuArchive* pArchive) goto failed; } NuFreeDataSink(pDataSink); - pDataSink = nil; + pDataSink = NULL; free(buf); - buf = nil; + buf = NULL; @@ -652,11 +652,11 @@ Test_Extract(NuArchive* pArchive) recordIdx, err); goto failed; } - assert(pRecord != nil); + assert(pRecord != NULL); /* we're not using ShrinkIt compat mode, so there should not be a comment */ pThread = NuGetThread(pRecord, 1); - assert(pThread != nil); + assert(pThread != NULL); if (NuGetThreadID(pThread) != kNuThreadIDDataFork) { fprintf(stderr, "ERROR: 'English' had unexpected threadID 0x%08lx\n", NuGetThreadID(pThread)); @@ -664,7 +664,7 @@ Test_Extract(NuArchive* pArchive) } buf = malloc(pThread->actualThreadEOF); - if (buf == nil) { + if (buf == NULL) { fprintf(stderr, "ERROR: malloc(%ld) failed\n",pThread->actualThreadEOF); goto failed; } @@ -686,7 +686,7 @@ Test_Extract(NuArchive* pArchive) goto failed; } NuFreeDataSink(pDataSink); - pDataSink = nil; + pDataSink = NULL; /* * Try to extract with "auto" conversion, which should fail because the @@ -707,12 +707,12 @@ Test_Extract(NuArchive* pArchive) goto failed; } NuFreeDataSink(pDataSink); - pDataSink = nil; + pDataSink = NULL; /*Free(buf);*/ - /*buf = nil;*/ + /*buf = NULL;*/ @@ -731,11 +731,11 @@ Test_Extract(NuArchive* pArchive) recordIdx, err); goto failed; } - assert(pRecord != nil); + assert(pRecord != NULL); /* we're not using ShrinkIt compat mode, so there should not be a comment */ pThread = NuGetThread(pRecord, 1); - assert(pThread != nil); + assert(pThread != NULL); if (NuGetThreadID(pThread) != kNuThreadIDRsrcFork) { fprintf(stderr, "ERROR: 'Long' had unexpected threadID 0x%08lx\n", NuGetThreadID(pThread)); @@ -759,20 +759,20 @@ Test_Extract(NuArchive* pArchive) goto failed; } NuFreeDataSink(pDataSink); - pDataSink = nil; + pDataSink = NULL; free(buf); - buf = nil; + buf = NULL; return 0; failed: - if (buf != nil) + if (buf != NULL) free(buf); - if (pDataSink != nil) + if (pDataSink != NULL) (void) NuFreeDataSink(pDataSink); return -1; } @@ -786,7 +786,7 @@ Test_Delete(NuArchive* pArchive) NuError err; NuRecordIdx recordIdx; const NuRecord* pRecord; - const NuThread* pThread = nil; + const NuThread* pThread = NULL; long count; int idx; @@ -806,12 +806,12 @@ Test_Delete(NuArchive* pArchive) recordIdx, err); goto failed; } - assert(pRecord != nil); + assert(pRecord != NULL); assert(pRecord->recTotalThreads > 0); for (idx = 0; idx < (int)pRecord->recTotalThreads; idx++) { pThread = NuGetThread(pRecord, idx); - assert(pThread != nil); + assert(pThread != NULL); err = NuDeleteThread(pArchive, pThread->threadIdx); if (err != kNuErrNone) { @@ -823,7 +823,7 @@ Test_Delete(NuArchive* pArchive) } /* try to re-delete the same thread */ - assert(pThread != nil); + assert(pThread != NULL); FAIL_OK; err = NuDeleteThread(pArchive, pThread->threadIdx); FAIL_BAD; @@ -868,11 +868,11 @@ Test_Delete(NuArchive* pArchive) recordIdx, err); goto failed; } - assert(pRecord != nil); + assert(pRecord != NULL); /* grab the first thread before we whack the record */ pThread = NuGetThread(pRecord, 0); - assert(pThread != nil); + assert(pThread != NULL); err = NuDeleteRecord(pArchive, recordIdx); if (err != kNuErrNone) { @@ -936,7 +936,7 @@ int DoTests(void) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; long status; int cc, result = 0; char answer; @@ -1013,7 +1013,7 @@ DoTests(void) fprintf(stderr, "ERROR: mid NuClose failed (err=%d)\n", err); goto failed; } - pArchive = nil; + pArchive = NULL; err = NuOpenRO(kTestArchive, &pArchive); if (err != kNuErrNone) { @@ -1055,7 +1055,7 @@ DoTests(void) fprintf(stderr, "ERROR: late NuClose failed (err=%d)\n", err); goto failed; } - pArchive = nil; + pArchive = NULL; err = NuOpenRW(kTestArchive, kTestTempFile, 0, &pArchive); if (err != kNuErrNone) { @@ -1122,7 +1122,7 @@ DoTests(void) * That's all, folks... */ NuClose(pArchive); - pArchive = nil; + pArchive = NULL; printf("... removing '%s'\n", kTestArchive); cc = unlink(kTestArchive); @@ -1133,7 +1133,7 @@ DoTests(void) leave: - if (pArchive != nil) { + if (pArchive != NULL) { NuAbort(pArchive); NuClose(pArchive); } diff --git a/nufxlib/samples/TestExtract.c b/nufxlib/samples/TestExtract.c index 302c631..fea6261 100644 --- a/nufxlib/samples/TestExtract.c +++ b/nufxlib/samples/TestExtract.c @@ -53,13 +53,13 @@ typedef struct ArchiveRecord { ArchiveRecord* ArchiveRecord_New(const NuRecord* pRecord) { - ArchiveRecord* pArcRec = nil; + ArchiveRecord* pArcRec = NULL; pArcRec = malloc(sizeof(*pArcRec)); - if (pArcRec == nil) - return nil; + if (pArcRec == NULL) + return NULL; - if (pRecord->filename == nil) + if (pRecord->filename == NULL) pArcRec->filename = strdup(""); else pArcRec->filename = strdup((char*)pRecord->filename); @@ -68,7 +68,7 @@ ArchiveRecord_New(const NuRecord* pRecord) pArcRec->numThreads = NuRecordGetNumThreads(pRecord); (void) NuRecordCopyThreads(pRecord, &pArcRec->pThreads); - pArcRec->pNext = nil; + pArcRec->pNext = NULL; return pArcRec; } @@ -79,12 +79,12 @@ ArchiveRecord_New(const NuRecord* pRecord) void ArchiveRecord_Free(ArchiveRecord* pArcRec) { - if (pArcRec == nil) + if (pArcRec == NULL) return; - if (pArcRec->filename != nil) + if (pArcRec->filename != NULL) free(pArcRec->filename); - if (pArcRec->pThreads != nil) + if (pArcRec->pThreads != NULL) free(pArcRec->pThreads); free(pArcRec); } @@ -104,7 +104,7 @@ ArchiveRecord_FindThreadByID(const ArchiveRecord* pArcRec, NuThreadID threadID) return pThread; } - return nil; + return NULL; } @@ -130,7 +130,7 @@ const NuThread* ArchiveRecord_GetThread(const ArchiveRecord* pArcRec, int idx) { if (idx < 0 || idx >= pArcRec->numThreads) - return nil; + return NULL; return NuThreadGetByIdx(pArcRec->pThreads, idx); } @@ -169,11 +169,11 @@ ArchiveData_New(void) ArchiveData* pArcData; pArcData = malloc(sizeof(*pArcData)); - if (pArcData == nil) - return nil; + if (pArcData == NULL) + return NULL; pArcData->numRecords = 0; - pArcData->pRecordHead = pArcData->pRecordTail = nil; + pArcData->pRecordHead = pArcData->pRecordTail = NULL; return pArcData; } @@ -183,11 +183,11 @@ ArchiveData_Free(ArchiveData* pArcData) { ArchiveRecord* pNext; - if (pArcData == nil) + if (pArcData == NULL) return; printf("*** Deleting %ld records!\n", pArcData->numRecords); - while (pArcData->pRecordHead != nil) { + while (pArcData->pRecordHead != NULL) { pNext = ArchiveRecord_GetNext(pArcData->pRecordHead); ArchiveRecord_Free(pArcData->pRecordHead); pArcData->pRecordHead = pNext; @@ -208,11 +208,11 @@ ArchiveData_GetRecordHead(const ArchiveData* pArcData) void ArchiveData_AddRecord(ArchiveData* pArcData, ArchiveRecord* pRecord) { - assert(pRecord != nil); - assert((pArcData->pRecordHead == nil && pArcData->pRecordTail == nil) || - (pArcData->pRecordHead != nil && pArcData->pRecordTail != nil)); + assert(pRecord != NULL); + assert((pArcData->pRecordHead == NULL && pArcData->pRecordTail == NULL) || + (pArcData->pRecordHead != NULL && pArcData->pRecordTail != NULL)); - if (pArcData->pRecordHead == nil) { + if (pArcData->pRecordHead == NULL) { /* first */ pArcData->pRecordHead = pArcData->pRecordTail = pRecord; } else { @@ -231,7 +231,7 @@ ArchiveData_DumpContents(const ArchiveData* pArcData) ArchiveRecord* pArcRec; pArcRec = pArcData->pRecordHead; - while (pArcRec != nil) { + while (pArcRec != NULL) { const NuThread* pThread; int i, count; @@ -264,14 +264,14 @@ NuResult GatherContents(NuArchive* pArchive, void* vpRecord) { NuRecord* pRecord = (NuRecord*) vpRecord; - ArchiveData* pArchiveData = nil; + ArchiveData* pArchiveData = NULL; ArchiveRecord* pArchiveRecord = ArchiveRecord_New(pRecord); NuGetExtraData(pArchive, (void**)&pArchiveData); - assert(pArchiveData != nil); + assert(pArchiveData != NULL); printf("*** Filename = '%s'\n", - pRecord->filename == nil ? "":(const char*)pRecord->filename); + pRecord->filename == NULL ? "":(const char*)pRecord->filename); ArchiveData_AddRecord(pArchiveData, pArchiveRecord); @@ -291,10 +291,10 @@ ReadAllFilenameThreads(NuArchive* pArchive, ArchiveData* pArchiveData, const NuThread* pThread; pArchiveRecord = ArchiveData_GetRecordHead(pArchiveData); - while (pArchiveRecord != nil) { + while (pArchiveRecord != NULL) { pThread = ArchiveRecord_FindThreadByID(pArchiveRecord, kNuThreadIDFilename); - if (pThread != nil) { + if (pThread != NULL) { err = NuExtractThread(pArchive, pThread->threadIdx, pDataSink); if (err != kNuErrNone) { fprintf(stderr, "*** Extract failed (%d)\n", err); @@ -314,7 +314,7 @@ NuError ExtractToFile(NuArchive* pArchive, ArchiveData* pArchiveData) { NuError err; - NuDataSink* pDataSink = nil; + NuDataSink* pDataSink = NULL; err = NuCreateDataSinkForFile(true, kNuConvertOff, "out.file", PATH_SEP, &pDataSink); @@ -341,10 +341,10 @@ NuError ExtractToFP(NuArchive* pArchive, ArchiveData* pArchiveData) { NuError err; - FILE* fp = nil; - NuDataSink* pDataSink = nil; + FILE* fp = NULL; + NuDataSink* pDataSink = NULL; - if ((fp = fopen("out.fp", kNuFileOpenWriteTrunc)) == nil) + if ((fp = fopen("out.fp", kNuFileOpenWriteTrunc)) == NULL) return kNuErrFileOpen; err = NuCreateDataSinkForFP(true, kNuConvertOff, fp, &pDataSink); @@ -357,7 +357,7 @@ ExtractToFP(NuArchive* pArchive, ArchiveData* pArchiveData) bail: (void) NuFreeDataSink(pDataSink); - if (fp != nil) + if (fp != NULL) fclose(fp); if (err == kNuErrNone) printf("*** FP write complete\n"); @@ -370,7 +370,7 @@ ExtractToBuffer(NuArchive* pArchive, ArchiveData* pArchiveData) { NuError err; unsigned char buffer[kHappySize]; - NuDataSink* pDataSink = nil; + NuDataSink* pDataSink = NULL; unsigned long count; err = NuCreateDataSinkForBuffer(true, kNuConvertOff, buffer, kHappySize, @@ -389,7 +389,7 @@ ExtractToBuffer(NuArchive* pArchive, ArchiveData* pArchiveData) (void) NuDataSinkGetOutCount(pDataSink, &count); if (count > 0) { FILE* fp; - if ((fp = fopen("out.buf", kNuFileOpenWriteTrunc)) != nil) { + if ((fp = fopen("out.buf", kNuFileOpenWriteTrunc)) != NULL) { printf("*** Writing %ld bytes\n", count); if (fwrite(buffer, count, 1, fp) != 1) @@ -413,7 +413,7 @@ int DoFileStuff(const char* filename) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; ArchiveData* pArchiveData = ArchiveData_New(); err = NuOpenRO(filename, &pArchive); @@ -444,7 +444,7 @@ bail: if (err != kNuErrNone) fprintf(stderr, "*** ERROR: got error %d\n", err); - if (pArchive != nil) { + if (pArchive != NULL) { NuError err2 = NuClose(pArchive); if (err == kNuErrNone && err2 != kNuErrNone) err = err2; @@ -464,16 +464,16 @@ main(int argc, char** argv) { long major, minor, bug; const char* pBuildDate; - FILE* infp = nil; + FILE* infp = NULL; int cc; - (void) NuGetVersion(&major, &minor, &bug, &pBuildDate, nil); + (void) NuGetVersion(&major, &minor, &bug, &pBuildDate, NULL); printf("Using NuFX lib %ld.%ld.%ld built on or after %s\n", major, minor, bug, pBuildDate); if (argc == 2) { infp = fopen(argv[1], kNuFileOpenReadOnly); - if (infp == nil) { + if (infp == NULL) { perror("fopen failed"); exit(1); } @@ -484,7 +484,7 @@ main(int argc, char** argv) cc = DoFileStuff(argv[1]); - if (infp != nil) + if (infp != NULL) fclose(infp); exit(cc != 0); diff --git a/nufxlib/samples/TestSimple.c b/nufxlib/samples/TestSimple.c index 45e51df..2b6e1ca 100644 --- a/nufxlib/samples/TestSimple.c +++ b/nufxlib/samples/TestSimple.c @@ -42,7 +42,7 @@ int DoStreamStuff(FILE* fp) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; err = NuStreamOpenRO(fp, &pArchive); if (err != kNuErrNone) { @@ -59,7 +59,7 @@ DoStreamStuff(FILE* fp) } bail: - if (pArchive != nil) { + if (pArchive != NULL) { NuError err2 = NuClose(pArchive); if (err == kNuErrNone) err = err2; @@ -77,10 +77,10 @@ main(int argc, char** argv) { long major, minor, bug; const char* pBuildDate; - FILE* infp = nil; + FILE* infp = NULL; int cc; - (void) NuGetVersion(&major, &minor, &bug, &pBuildDate, nil); + (void) NuGetVersion(&major, &minor, &bug, &pBuildDate, NULL); printf("Using NuFX lib %ld.%ld.%ld built on or after %s\n", major, minor, bug, pBuildDate); @@ -93,7 +93,7 @@ main(int argc, char** argv) infp = stdin; else { infp = fopen(argv[1], kNuFileOpenReadOnly); - if (infp == nil) { + if (infp == NULL) { fprintf(stderr, "ERROR: unable to open '%s'\n", argv[1]); exit(1); } diff --git a/nufxlib/samples/TestTwirl.c b/nufxlib/samples/TestTwirl.c index be996a1..fc41eec 100644 --- a/nufxlib/samples/TestTwirl.c +++ b/nufxlib/samples/TestTwirl.c @@ -104,7 +104,7 @@ DumpCRCs(const CRCList* pCRCList) void FreeCRCs(CRCList* pCRCList) { - if (pCRCList == nil) + if (pCRCList == NULL) return; free(pCRCList->entries); @@ -117,21 +117,21 @@ FreeCRCs(CRCList* pCRCList) * We assume there are at most two data threads (e.g. data fork and rsrc * fork) in a record. * - * Returns the list on success, nil on failure. + * Returns the list on success, NULL on failure. */ CRCList* GatherCRCs(NuArchive* pArchive) { NuError err = kNuErrNone; const NuMasterHeader* pMasterHeader; - CRCList* pCRCList = nil; - unsigned short* pEntries = nil; + CRCList* pCRCList = NULL; + unsigned short* pEntries = NULL; long recCount, maxCRCs; long recIdx, crcIdx; int i; pCRCList = malloc(sizeof(*pCRCList)); - if (pCRCList == nil) { + if (pCRCList == NULL) { fprintf(stderr, "ERROR: couldn't alloc CRC list\n"); err = kNuErrGeneric; goto bail; @@ -148,7 +148,7 @@ GatherCRCs(NuArchive* pArchive) maxCRCs = recCount * 2; pEntries = malloc(sizeof(*pEntries) * maxCRCs); - if (pEntries == nil) { + if (pEntries == NULL) { fprintf(stderr, "ERROR: unable to alloc CRC list (%ld entries)\n", maxCRCs); err = kNuErrGeneric; @@ -211,7 +211,7 @@ GatherCRCs(NuArchive* pArchive) bail: if (err != kNuErrNone) { FreeCRCs(pCRCList); - pCRCList = nil; + pCRCList = NULL; } return pCRCList; } @@ -231,13 +231,13 @@ bail: int CompareCRCs(NuArchive* pArchive, const CRCList* pOldCRCList) { - CRCList* pNewCRCList = nil; + CRCList* pNewCRCList = NULL; int result = -1; int badCrc = 0; int i; pNewCRCList = GatherCRCs(pArchive); - if (pNewCRCList == nil) { + if (pNewCRCList == NULL) { fprintf(stderr, "ERROR: unable to gather new list\n"); goto bail; } @@ -279,13 +279,13 @@ RecompressThread(NuArchive* pArchive, const NuRecord* pRecord, const NuThread* pThread) { NuError err = kNuErrNone; - NuDataSource* pDataSource = nil; - NuDataSink* pDataSink = nil; - unsigned char* buf = nil; + NuDataSource* pDataSource = NULL; + NuDataSink* pDataSink = NULL; + unsigned char* buf = NULL; if (pThread->actualThreadEOF == 0) { buf = malloc(1); - if (buf == nil) { + if (buf == NULL) { fprintf(stderr, "ERROR: failed allocating trivial buffer\n"); err = kNuErrGeneric; goto bail; @@ -295,7 +295,7 @@ RecompressThread(NuArchive* pArchive, const NuRecord* pRecord, * Create a buffer and data sink to hold the data. */ buf = malloc(pThread->actualThreadEOF); - if (buf == nil) { + if (buf == NULL) { fprintf(stderr, "ERROR: failed allocating %ld bytes\n", pThread->actualThreadEOF); err = kNuErrGeneric; @@ -340,19 +340,19 @@ RecompressThread(NuArchive* pArchive, const NuRecord* pRecord, fprintf(stderr, "ERROR: unable to create data source (err=%d)\n", err); goto bail; } - buf = nil; + buf = NULL; /* * Create replacement thread. */ err = NuAddThread(pArchive, pRecord->recordIdx, NuGetThreadID(pThread), - pDataSource, nil); + pDataSource, NULL); if (err != kNuErrNone) { fprintf(stderr, "ERROR: unable to add new thread ID=0x%08lx (err=%d)\n", NuGetThreadID(pThread), err); goto bail; } - pDataSource = nil; /* now owned by NufxLib */ + pDataSource = NULL; /* now owned by NufxLib */ bail: NuFreeDataSink(pDataSink); @@ -416,7 +416,7 @@ NuError RecompressArchive(NuArchive* pArchive, NuValue compression) { NuError err = kNuErrNone; - NuRecordIdx* pIndices = nil; + NuRecordIdx* pIndices = NULL; NuAttr countAttr; long heldLen; long idx; @@ -446,7 +446,7 @@ RecompressArchive(NuArchive* pArchive, NuValue compression) * record to "disappear" during processing, we will know about it. */ pIndices = malloc(countAttr * sizeof(*pIndices)); - if (pIndices == nil) { + if (pIndices == NULL) { fprintf(stderr, "ERROR: malloc on %ld indices failed\n", countAttr); err = kNuErrGeneric; goto bail; @@ -504,8 +504,8 @@ int TwirlArchive(const char* filename) { NuError err = kNuErrNone; - NuArchive* pArchive = nil; - CRCList* pCRCList = nil; + NuArchive* pArchive = NULL; + CRCList* pCRCList = NULL; int compression; int cc; @@ -534,7 +534,7 @@ TwirlArchive(const char* filename) } pCRCList = GatherCRCs(pArchive); - if (pCRCList == nil) { + if (pCRCList == NULL) { fprintf(stderr, "ERROR: unable to get CRC list\n"); goto bail; } @@ -599,7 +599,7 @@ TwirlArchive(const char* filename) bail: FreeCRCs(pCRCList); - if (pArchive != nil) { + if (pArchive != NULL) { NuAbort(pArchive); NuClose(pArchive); } @@ -611,7 +611,7 @@ bail: /* * Copy from the current offset in "srcfp" to a new file called * "outFileName". Returns a writable file descriptor for the new file - * on success, or nil on error. + * on success, or NULL on error. * * (Note "CopyFile()" exists under Win32.) */ @@ -623,10 +623,10 @@ MyCopyFile(const char* outFileName, FILE* srcfp) size_t count; outfp = fopen(outFileName, kNuFileOpenWriteTrunc); - if (outfp == nil) { + if (outfp == NULL) { fprintf(stderr, "ERROR: unable to open '%s' (err=%d)\n", outFileName, errno); - return nil; + return NULL; } while (!feof(srcfp)) { @@ -636,14 +636,14 @@ MyCopyFile(const char* outFileName, FILE* srcfp) if (fwrite(buf, 1, count, outfp) != count) { fprintf(stderr, "ERROR: failed writing outfp (err=%d)\n", errno); fclose(outfp); - return nil; + return NULL; } } if (ferror(srcfp)) { fprintf(stderr, "ERROR: failed reading srcfp (err=%d)\n", errno); fclose(outfp); - return nil; + return NULL; } return outfp; @@ -657,21 +657,21 @@ main(int argc, char** argv) { long major, minor, bug; const char* pBuildDate; - FILE* srcfp = nil; - FILE* infp = nil; + FILE* srcfp = NULL; + FILE* infp = NULL; int cc; /* don't buffer output */ - setvbuf(stdout, nil, _IONBF, 0); - setvbuf(stderr, nil, _IONBF, 0); + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); - (void) NuGetVersion(&major, &minor, &bug, &pBuildDate, nil); + (void) NuGetVersion(&major, &minor, &bug, &pBuildDate, NULL); printf("Using NuFX lib %ld.%ld.%ld built on or after %s\n\n", major, minor, bug, pBuildDate); if (argc == 2) { srcfp = fopen(argv[1], kNuFileOpenReadOnly); - if (srcfp == nil) { + if (srcfp == NULL) { perror("fopen failed"); exit(1); } @@ -683,7 +683,7 @@ main(int argc, char** argv) printf("Copying '%s' to '%s'\n", argv[1], kWorkFileName); infp = MyCopyFile(kWorkFileName, srcfp); - if (infp == nil) { + if (infp == NULL) { fprintf(stderr, "Copy failed, bailing.\n"); exit(1); } diff --git a/nulib2/Add.c b/nulib2/Add.c index f24183a..11d139a 100644 --- a/nulib2/Add.c +++ b/nulib2/Add.c @@ -18,17 +18,17 @@ NuError DoAdd(NulibState* pState) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; long flushStatus; - Assert(pState != nil); + Assert(pState != NULL); err = OpenArchiveReadWrite(pState); if (err != kNuErrNone) goto bail; pArchive = NState_GetNuArchive(pState); - Assert(pArchive != nil); + Assert(pArchive != NULL); NState_SetMatchCount(pState, 0); @@ -43,7 +43,7 @@ DoAdd(NulibState* pState) printf("%s: no records matched\n", gProgName); bail: - if (pArchive != nil) { + if (pArchive != NULL) { NuError err2; #if 0 @@ -91,8 +91,8 @@ AddToArchive(NulibState* pState, NuArchive* pArchive) char* const* pSpec; int i; - Assert(pState != nil); - Assert(pArchive != nil); + Assert(pState != NULL); + Assert(pArchive != NULL); if (!NState_GetFilespecCount(pState)) { err = kNuErrSyntax; diff --git a/nulib2/ArcUtils.c b/nulib2/ArcUtils.c index 7f12ce8..6e2bf43 100644 --- a/nulib2/ArcUtils.c +++ b/nulib2/ArcUtils.c @@ -34,9 +34,9 @@ OutputPathnameFilter(NuArchive* pArchive, void* vproposal) char* renameToStr; char* resultBuf; - Assert(pArchive != nil); + Assert(pArchive != NULL); (void) NuGetExtraData(pArchive, (void**) &pState); - Assert(pState != nil); + Assert(pState != NULL); /* handle extract-to-pipe */ if (NState_GetCommand(pState) == kCommandExtractToPipe) { @@ -51,21 +51,21 @@ OutputPathnameFilter(NuArchive* pArchive, void* vproposal) * that it's okay (and let the OS tell them if it isn't). */ renameToStr = NState_GetRenameToStr(pState); - if (renameToStr != nil) { + if (renameToStr != NULL) { renameFromIdx = NState_GetRenameFromIdx(pState); if (renameFromIdx == pathProposal->pRecord->recordIdx) { /* right source file, proceed with the rename */ NState_SetTempPathnameLen(pState, strlen(renameToStr) +1); resultBuf = NState_GetTempPathnameBuf(pState); - Assert(resultBuf != nil); + Assert(resultBuf != NULL); strcpy(resultBuf, renameToStr); pathProposal->newPathname = resultBuf; } /* free up renameToStr */ - NState_SetRenameToStr(pState, nil); + NState_SetRenameToStr(pState, NULL); goto bail; } @@ -74,7 +74,7 @@ OutputPathnameFilter(NuArchive* pArchive, void* vproposal) * Convert the pathname into something suitable for the current OS. */ newPathname = NormalizePath(pState, pathProposal); - if (newPathname == nil) { + if (newPathname == NULL) { ReportError(kNuErrNone, "unable to convert pathname"); return kNuAbort; } @@ -104,7 +104,7 @@ GetReplyChar(char defaultReply) { char tmpBuf[32]; - if (fgets(tmpBuf, sizeof(tmpBuf), stdin) == nil) + if (fgets(tmpBuf, sizeof(tmpBuf), stdin) == NULL) return defaultReply; if (tmpBuf[0] == '\n' || tmpBuf[0] == '\r') return defaultReply; @@ -130,10 +130,10 @@ GetReplyString(const char* prompt) printf("%s", prompt); fflush(stdout); result = fgets(buf, sizeof(buf), stdin); - if (result == nil || feof(stdin) || ferror(stdin) || buf[0] == '\0' || + if (result == NULL || feof(stdin) || ferror(stdin) || buf[0] == '\0' || buf[0] == '\n') { - return nil; + return NULL; } /* nuke the terminating '\n', which is lots of fun in filenames */ @@ -148,30 +148,30 @@ GetReplyString(const char* prompt) /* * Get a one-line comment from the user, of at most "maxLen" bytes. * - * If the user enters a blank line, return "nil". + * If the user enters a blank line, return "NULL". * * A pointer to a newly-allocated buffer is returned. */ char* GetSimpleComment(NulibState* pState, const char* pathname, int maxLen) { - char* buf = nil; + char* buf = NULL; char* result; int len; buf = Malloc(maxLen); - if (buf == nil) - return nil; + if (buf == NULL) + return NULL; printf("Enter one-line comment for '%s'\n: ", pathname); fflush(stdout); result = fgets(buf, maxLen, stdin); - if (result == nil || feof(stdin) || ferror(stdin) || buf[0] == '\0' || + if (result == NULL || feof(stdin) || ferror(stdin) || buf[0] == '\0' || buf[0] == '\n') { Free(buf); - return nil; + return NULL; } /* nuke the terminating '\n', which we don't need */ @@ -251,9 +251,9 @@ SelectionFilter(NuArchive* pArchive, void* vproposal) const NuSelectionProposal* selProposal = vproposal; NulibState* pState; - Assert(pArchive != nil); + Assert(pArchive != NULL); (void) NuGetExtraData(pArchive, (void**) &pState); - Assert(pState != nil); + Assert(pState != NULL); if (IsSpecified(pState, selProposal->pRecord)) { NState_IncMatchCount(pState); @@ -309,14 +309,14 @@ ProgressUpdater(NuArchive* pArchive, void* vProgress) char nameBuf[kMaxDisplayLen+1]; Boolean showName, eolConv; - Assert(pArchive != nil); + Assert(pArchive != NULL); (void) NuGetExtraData(pArchive, (void**) &pState); - Assert(pState != nil); + Assert(pState != NULL); if (NState_GetSuppressOutput(pState)) return kNuOK; - percStr = nil; + percStr = NULL; showName = false; eolConv = false; @@ -384,19 +384,19 @@ ProgressUpdater(NuArchive* pArchive, void* vProgress) switch (pProgress->state) { case kNuProgressDone: - actionStr = nil; + actionStr = NULL; percStr = "DONE\n"; break; case kNuProgressSkipped: - actionStr = nil; + actionStr = NULL; percStr = "SKIP\n"; break; case kNuProgressAborted: /* not currently possible in NuLib2 */ - actionStr = nil; + actionStr = NULL; percStr = "CNCL\n"; break; case kNuProgressFailed: - actionStr = nil; + actionStr = NULL; percStr = "FAIL\n"; break; default: @@ -420,10 +420,10 @@ ProgressUpdater(NuArchive* pArchive, void* vProgress) } } - if (actionStr == nil && percStr != nil) { + if (actionStr == NULL && percStr != NULL) { printf("\r%s", percStr); - } else if (actionStr != nil && percStr == nil) { - if (percStr == nil) { + } else if (actionStr != NULL && percStr == NULL) { + if (percStr == NULL) { putc('\r', stdout); PrintPercentage(pProgress->uncompressedLength, pProgress->uncompressedProgress); @@ -457,9 +457,9 @@ HandleReplaceExisting(NulibState* pState, NuArchive* pArchive, char* renameName; char reply; - Assert(pState != nil); - Assert(pErrorStatus != nil); - Assert(pErrorStatus->pathname != nil); + Assert(pState != NULL); + Assert(pErrorStatus != NULL); + Assert(pErrorStatus->pathname != NULL); Assert(pErrorStatus->canOverwrite); Assert(pErrorStatus->canSkip); @@ -506,10 +506,10 @@ HandleReplaceExisting(NulibState* pState, NuArchive* pArchive, break; /* continue in "while" loop */ } renameName = GetReplyString("New name: "); - if (renameName == nil) + if (renameName == NULL) break; /* continue in "while" loop */ - if (pErrorStatus->pRecord == nil) { - ReportError(kNuErrNone, "Unexpected nil record"); + if (pErrorStatus->pRecord == NULL) { + ReportError(kNuErrNone, "Unexpected NULL record"); break; /* continue in "while" loop */ } NState_SetRenameFromIdx(pState, @@ -534,7 +534,7 @@ bail: /* * Found a bad CRC... should we press onward? * - * Note pErrorStatus->pathname may be nil if the error was found in the + * Note pErrorStatus->pathname may be NULL if the error was found in the * master header or in the record header. */ static NuResult @@ -544,8 +544,8 @@ HandleBadCRC(NulibState* pState, NuArchive* pArchive, NuResult result = kNuOK; char reply; - Assert(pState != nil); - Assert(pErrorStatus != nil); + Assert(pState != NULL); + Assert(pErrorStatus != NULL); if (NState_GetInputUnavailable(pState)) { putc('\n', stderr); @@ -555,7 +555,7 @@ HandleBadCRC(NulibState* pState, NuArchive* pArchive, } while (1) { - if (pErrorStatus->pathname != nil) + if (pErrorStatus->pathname != NULL) fprintf(stderr, "\n Found a bad CRC in %s\n", pErrorStatus->pathname); else @@ -604,9 +604,9 @@ HandleAddNotFound(NulibState* pState, NuArchive* pArchive, NuResult result = kNuOK; char reply; - Assert(pState != nil); - Assert(pErrorStatus != nil); - Assert(pErrorStatus->pathname != nil); + Assert(pState != NULL); + Assert(pErrorStatus != NULL); + Assert(pErrorStatus->pathname != NULL); if (NState_GetInputUnavailable(pState)) { putc('\n', stdout); @@ -651,9 +651,9 @@ ErrorHandler(NuArchive* pArchive, void* vErrorStatus) NulibState* pState; NuResult result; - Assert(pArchive != nil); + Assert(pArchive != NULL); (void) NuGetExtraData(pArchive, (void**) &pState); - Assert(pState != nil); + Assert(pState != NULL); /* default action is to abort the current operation */ result = kNuAbort; @@ -728,7 +728,7 @@ ErrorMessageHandler(NuArchive* pArchive, void* vErrorMessage) const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage; fprintf(stderr, "%s%d %3d %s:%d %s %s\n", - pArchive == nil ? "(GLOBAL)" : "", + pArchive == NULL ? "(GLOBAL)" : "", pErrorMessage->isDebug, pErrorMessage->err, pErrorMessage->file, pErrorMessage->line, pErrorMessage->function, pErrorMessage->message); return kNuOK; @@ -768,7 +768,7 @@ IsRecordReadOnly(const NuRecord* pRecord) Boolean IsFilenameStdin(const char* archiveName) { - Assert(archiveName != nil); + Assert(archiveName != NULL); return (strcmp(archiveName, kStdinArchive) == 0); } @@ -783,9 +783,9 @@ NuError OpenArchiveReadOnly(NulibState* pState) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; - Assert(pState != nil); + Assert(pState != NULL); if (IsFilenameStdin(NState_GetArchiveFilename(pState))) { err = NuStreamOpenRO(stdin, &pArchive); @@ -881,10 +881,10 @@ OpenArchiveReadOnly(NulibState* pState) BailError(err); bail: - if (err != kNuErrNone && pArchive != nil) { + if (err != kNuErrNone && pArchive != NULL) { /* clean up */ (void) NuClose(pArchive); - NState_SetNuArchive(pState, nil); + NState_SetNuArchive(pState, NULL); } return err; } @@ -900,14 +900,14 @@ NuError OpenArchiveReadWrite(NulibState* pState) { NuError err = kNuErrNone; - NuArchive* pArchive = nil; - char* tempName = nil; + NuArchive* pArchive = NULL; + char* tempName = NULL; - Assert(pState != nil); + Assert(pState != NULL); Assert(IsFilenameStdin(NState_GetArchiveFilename(pState)) == false); tempName = MakeTempArchiveName(pState); - if (tempName == nil) + if (tempName == NULL) goto bail; DBUG(("TEMP NAME = '%s'\n", tempName)); @@ -979,11 +979,11 @@ OpenArchiveReadWrite(NulibState* pState) bail: Free(tempName); - if (err != kNuErrNone && pArchive != nil) { + if (err != kNuErrNone && pArchive != NULL) { /* clean up */ NuAbort(pArchive); (void) NuClose(pArchive); - NState_SetNuArchive(pState, nil); + NState_SetNuArchive(pState, NULL); } return err; } diff --git a/nulib2/Binary2.c b/nulib2/Binary2.c index b54885b..f6fec16 100644 --- a/nulib2/Binary2.c +++ b/nulib2/Binary2.c @@ -50,7 +50,7 @@ OpenFileReadOnly(const char* filename, FILE** pFp) NuError err = kNuErrNone; *pFp = fopen(filename, kFileOpenReadOnly); - if (*pFp == nil) + if (*pFp == NULL) err = errno ? errno : kNuErrFileOpen; return err; @@ -198,7 +198,7 @@ static void BNYFree(BNYArchive* pBny) { /* don't need to do this on stdin, but won't really hurt */ - if (pBny->fp != nil) + if (pBny->fp != NULL) fclose(pBny->fp); Free(pBny); @@ -215,9 +215,9 @@ BNYOpenReadOnly(BNYArchive* pBny) NuError err = kNuErrNone; NulibState* pState; - Assert(pBny != nil); - Assert(pBny->pState != nil); - Assert(pBny->fp == nil); + Assert(pBny != NULL); + Assert(pBny->pState != NULL); + Assert(pBny->fp == NULL); pState = pBny->pState; @@ -253,10 +253,10 @@ BNYRead(BNYArchive* pBny, void* buf, size_t nbyte) { size_t result; - Assert(pBny != nil); - Assert(buf != nil); + Assert(pBny != NULL); + Assert(buf != NULL); Assert(nbyte > 0); - Assert(pBny->fp != nil); + Assert(pBny->fp != NULL); errno = 0; result = fread(buf, 1, nbyte, pBny->fp); @@ -273,9 +273,9 @@ BNYRead(BNYArchive* pBny, void* buf, size_t nbyte) static NuError BNYSeek(BNYArchive* pBny, long offset) { - Assert(pBny != nil); - Assert(pBny->fp != nil); - Assert(pBny->pState != nil); + Assert(pBny != NULL); + Assert(pBny->fp != NULL); + Assert(pBny->pState != NULL); Assert(offset > 0); /*DBUG(("--- seeking forward %ld bytes\n", offset));*/ @@ -327,8 +327,8 @@ BNYDecodeHeader(BNYArchive* pBny, BNYEntry* pEntry) uchar* raw; int len; - Assert(pBny != nil); - Assert(pEntry != nil); + Assert(pBny != NULL); + Assert(pEntry != NULL); raw = pEntry->blockBuf; @@ -422,9 +422,9 @@ BNYNormalizePath(BNYArchive* pBny, BNYEntry* pEntry) pathProposal.pRecord = &fakeRecord; pathProposal.pThread = &fakeThread; - pathProposal.newPathname = nil; + pathProposal.newPathname = NULL; pathProposal.newFilenameSeparator = '\0'; - pathProposal.newDataSink = nil; + pathProposal.newDataSink = NULL; /* need the filetype and auxtype for -e/-ee */ fakeRecord.recFileType = pEntry->fileType; @@ -464,7 +464,7 @@ BNYCopyBlocks(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp) if (toWrite > kBNYBlockSize) toWrite = kBNYBlockSize; - if (outfp != nil) { + if (outfp != NULL) { if (fwrite(pEntry->blockBuf, toWrite, 1, outfp) != 1) { err = errno ? errno : kNuErrFileWrite; ReportError(err, "BNY write failed"); @@ -609,11 +609,11 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp) #endif short nodeCount; int i, inrep; - uchar* tmpBuf = nil; + uchar* tmpBuf = NULL; uchar lastc = 0; tmpBuf = Malloc(kSqBufferSize); - if (tmpBuf == nil) { + if (tmpBuf == NULL) { err = kNuErrMalloc; goto bail; } @@ -824,9 +824,9 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp) val = 2; } while (--val) { - /*if (pCrc != nil) + /*if (pCrc != NULL) *pCrc = Nu_CalcCRC16(*pCrc, &lastc, 1);*/ - if (outfp != nil) + if (outfp != NULL) putc(lastc, outfp); #ifdef FULL_SQ_HEADER checksum += lastc; @@ -840,9 +840,9 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp) inrep = true; } else { lastc = val; - /*if (pCrc != nil) + /*if (pCrc != NULL) *pCrc = Nu_CalcCRC16(*pCrc, &lastc, 1);*/ - if (outfp != nil) + if (outfp != NULL) putc(lastc, outfp); #ifdef FULL_SQ_HEADER checksum += lastc; @@ -889,7 +889,7 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp) } bail: - if (outfp != nil) + if (outfp != NULL) fflush(outfp); Free(tmpBuf); return err; @@ -913,19 +913,19 @@ static NuError BNYIterate(NulibState* pState, BNYIteratorFunc func) { NuError err = kNuErrNone; - BNYArchive* pBny = nil; + BNYArchive* pBny = NULL; BNYEntry entry; Boolean consumed; int first = true; int toFollow; - Assert(pState != nil); - Assert(func != nil); + Assert(pState != NULL); + Assert(func != NULL); NState_SetMatchCount(pState, 0); pBny = BNYInit(pState); - if (pBny == nil) { + if (pBny == NULL) { err = kNuErrMalloc; goto bail; } @@ -1012,7 +1012,7 @@ BNYIterate(NulibState* pState, BNYIteratorFunc func) printf("%s: no records match\n", gProgName); bail: - if (pBny != nil) + if (pBny != NULL) BNYFree(pBny); if (err != kNuErrNone) { DBUG(("--- Iterator returning failure %d\n", err)); @@ -1173,7 +1173,7 @@ BNYExtractDirectory(BNYArchive* pBny, BNYEntry* pEntry, ExtMode extMode) */ /*newName = BNYNormalizePath(pBny, pEntry);*/ newName = pEntry->fileName; - if (newName == nil) + if (newName == NULL) goto bail; err = TestFileExistence(newName, &isDir); @@ -1216,7 +1216,7 @@ BNYExtract(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag) NulibState* pState; ExtMode extMode; const char* actionStr = "HOSED"; - FILE* outfp = nil; + FILE* outfp = NULL; Boolean eolConv; pState = pBny->pState; @@ -1275,7 +1275,7 @@ BNYExtract(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag) } newName = BNYNormalizePath(pBny, pEntry); - if (newName == nil) + if (newName == NULL) goto bail; err = TestFileExistence(newName, &isDir); @@ -1303,13 +1303,13 @@ BNYExtract(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag) /* open it, overwriting anything present */ outfp = fopen(newName, "w"); - if (outfp == nil) { + if (outfp == NULL) { err = kNuErrFileOpen; goto bail; } } else { - /* outfp == nil means we're in test mode */ - Assert(outfp == nil); + /* outfp == NULL means we're in test mode */ + Assert(outfp == NULL); } /* @@ -1358,7 +1358,7 @@ BNYExtract(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag) *pConsumedFlag = true; bail: - if (outfp != nil && outfp != stdout) + if (outfp != NULL && outfp != stdout) fclose(outfp); return err; } diff --git a/nulib2/Delete.c b/nulib2/Delete.c index 729feac..54f21ae 100644 --- a/nulib2/Delete.c +++ b/nulib2/Delete.c @@ -19,15 +19,15 @@ NuError DoDelete(NulibState* pState) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; - Assert(pState != nil); + Assert(pState != NULL); err = OpenArchiveReadWrite(pState); if (err != kNuErrNone) goto bail; pArchive = NState_GetNuArchive(pState); - Assert(pArchive != nil); + Assert(pArchive != NULL); NState_SetMatchCount(pState, 0); @@ -39,7 +39,7 @@ DoDelete(NulibState* pState) printf("%s: no records matched\n", gProgName); bail: - if (pArchive != nil) + if (pArchive != NULL) (void) NuClose(pArchive); return err; } diff --git a/nulib2/Extract.c b/nulib2/Extract.c index 869a4a2..bf356b0 100644 --- a/nulib2/Extract.c +++ b/nulib2/Extract.c @@ -57,7 +57,7 @@ ExtractAllRecords(NulibState* pState, NuArchive* pArchive) threadIdx++) { pThread = NuGetThread(pRecord, threadIdx); - Assert(pThread != nil); + Assert(pThread != NULL); if (NuGetThreadID(pThread) == kNuThreadIDComment && pThread->actualThreadEOF > 0) @@ -91,9 +91,9 @@ NuError DoExtract(NulibState* pState) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; - Assert(pState != nil); + Assert(pState != NULL); if (NState_GetModBinaryII(pState)) return BNYDoExtract(pState); @@ -104,7 +104,7 @@ DoExtract(NulibState* pState) if (err != kNuErrNone) goto bail; pArchive = NState_GetNuArchive(pState); - Assert(pArchive != nil); + Assert(pArchive != NULL); NState_SetMatchCount(pState, 0); @@ -126,7 +126,7 @@ DoExtract(NulibState* pState) printf("%s: no records match\n", gProgName); bail: - if (pArchive != nil) + if (pArchive != NULL) (void) NuClose(pArchive); return err; } @@ -150,9 +150,9 @@ NuError DoTest(NulibState* pState) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; - Assert(pState != nil); + Assert(pState != NULL); if (NState_GetModBinaryII(pState)) return BNYDoTest(pState); @@ -163,7 +163,7 @@ DoTest(NulibState* pState) if (err != kNuErrNone) goto bail; pArchive = NState_GetNuArchive(pState); - Assert(pArchive != nil); + Assert(pArchive != NULL); NState_SetMatchCount(pState, 0); @@ -175,7 +175,7 @@ DoTest(NulibState* pState) printf("%s: no records match\n", gProgName); bail: - if (pArchive != nil) + if (pArchive != NULL) (void) NuClose(pArchive); return err; } diff --git a/nulib2/Filename.c b/nulib2/Filename.c index 10f5948..fdcc102 100644 --- a/nulib2/Filename.c +++ b/nulib2/Filename.c @@ -127,15 +127,15 @@ AddPreservationString(NulibState* pState, NuThreadID threadID; char* cp; - Assert(pState != nil); - Assert(pPathProposal != nil); - Assert(pathBuf != nil); + Assert(pState != NULL); + Assert(pPathProposal != NULL); + Assert(pathBuf != NULL); Assert(NState_GetModPreserveType(pState)); pRecord = pPathProposal->pRecord; pThread = pPathProposal->pThread; - Assert(pRecord != nil); - Assert(pThread != nil); + Assert(pRecord != NULL); + Assert(pThread != NULL); cp = extBuf; @@ -179,26 +179,26 @@ AddPreservationString(NulibState* pState, * to be ".txt", and perhaps do something clever for some others. */ if (pRecord->recFileType == 0x04 || threadID == kNuThreadIDDiskImage) - pExt = nil; + pExt = NULL; else pExt = FindExtension(pState, pathBuf); - if (pExt != nil) { + if (pExt != NULL) { pExt++; /* skip past the '.' */ if (strlen(pExt) >= kMaxExtLen) { /* too long, forget it */ - pExt = nil; + pExt = NULL; } else { /* if strictly decimal-numeric, don't use it (.1, .2, etc) */ (void) strtoul(pExt, &end, 10); if (*end == '\0') { - pExt = nil; + pExt = NULL; } else { /* if '#' appears in it, don't use it -- it'll confuse us */ const char* ccp = pExt; while (*ccp != '\0') { if (*ccp == '#') { - pExt = nil; + pExt = NULL; break; } ccp++; @@ -217,11 +217,11 @@ AddPreservationString(NulibState* pState, else if (pRecord->recFileType) { pExt = GetFileTypeString(pRecord->recFileType); if (pExt[0] == '?' || pExt[0] == '$') - pExt = nil; + pExt = NULL; } } - if (pExt != nil) { + if (pExt != NULL) { *cp++ = kFilenameExtDelim; strcpy(cp, pExt); cp += strlen(pExt); @@ -259,9 +259,9 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) char localFssep; int newBufLen; - Assert(pState != nil); - Assert(pPathProposal != nil); - Assert(pPathProposal->pathname != nil); + Assert(pState != NULL); + Assert(pPathProposal != NULL); + Assert(pPathProposal->pathname != NULL); localFssep = NState_GetSystemPathSeparator(pState); @@ -273,9 +273,9 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) newBufLen = strlen(pPathProposal->pathname)*3 + kMaxPathGrowth +1; NState_SetTempPathnameLen(pState, newBufLen); pathBuf = NState_GetTempPathnameBuf(pState); - Assert(pathBuf != nil); - if (pathBuf == nil) - return nil; + Assert(pathBuf != NULL); + if (pathBuf == NULL) + return NULL; startp = pPathProposal->pathname; dstp = pathBuf; @@ -285,9 +285,9 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) } /* normalize all directory components and the filename component */ - while (startp != nil) { + while (startp != NULL) { endp = strchr(startp, pPathProposal->filenameSeparator); - if (endp != nil) { + if (endp != NULL) { /* normalize directory component */ err = NormalizeDirectoryName(pState, startp, endp - startp, pPathProposal->filenameSeparator, &dstp, @@ -316,7 +316,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) strcat(pathBuf, kResourceStr); } - startp = nil; /* we're done */ + startp = NULL; /* we're done */ } } @@ -332,7 +332,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) if (NState_GetModJunkPaths(pState)) { char* lastFssep; lastFssep = strrchr(pathBuf, localFssep); - if (lastFssep != nil) { + if (lastFssep != NULL) { Assert(*(lastFssep+1) != '\0'); /* should already have been caught*/ memmove(pathBuf, lastFssep+1, strlen(lastFssep+1)+1); } @@ -340,7 +340,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) bail: if (err != kNuErrNone) - return nil; + return NULL; return pathBuf; } @@ -415,13 +415,13 @@ InterpretExtension(NulibState* pState, const char* pathName, ulong* pFileType, { const char* pExt; - Assert(pState != nil); - Assert(pathName != nil); - Assert(pFileType != nil); - Assert(pAuxType != nil); + Assert(pState != NULL); + Assert(pathName != NULL); + Assert(pFileType != NULL); + Assert(pAuxType != NULL); pExt = FindExtension(pState, pathName); - if (pExt != nil) + if (pExt != NULL) LookupExtension(pState, pExt+1, pFileType, pAuxType); } @@ -445,14 +445,14 @@ ExtractPreservationString(NulibState* pState, char* pathname, ulong* pFileType, char* cp; int digitCount; - Assert(pState != nil); - Assert(pathname != nil); - Assert(pFileType != nil); - Assert(pAuxType != nil); - Assert(pThreadID != nil); + Assert(pState != NULL); + Assert(pathname != NULL); + Assert(pFileType != NULL); + Assert(pAuxType != NULL); + Assert(pThreadID != NULL); pPreserve = strrchr(pathname, kPreserveIndic); - if (pPreserve == nil) + if (pPreserve == NULL) return false; /* count up the #of hex digits */ @@ -583,20 +583,20 @@ DenormalizePath(NulibState* pState, char* pathBuf) * Find the filename component of a local pathname. Uses the fssep defined * in pState. * - * Always returns a pointer to a string; never returns nil. + * Always returns a pointer to a string; never returns NULL. */ const char* FilenameOnly(NulibState* pState, const char* pathname) { const char* retstr; const char* pSlash; - char* tmpStr = nil; + char* tmpStr = NULL; - Assert(pState != nil); - Assert(pathname != nil); + Assert(pState != NULL); + Assert(pathname != NULL); pSlash = strrchr(pathname, NState_GetSystemPathSeparator(pState)); - if (pSlash == nil) { + if (pSlash == NULL) { retstr = pathname; /* whole thing is the filename */ goto bail; } @@ -614,7 +614,7 @@ FilenameOnly(NulibState* pState, const char* pathname) tmpStr[strlen(pathname)-1] = '\0'; pSlash = strrchr(tmpStr, NState_GetSystemPathSeparator(pState)); - if (pSlash == nil) { + if (pSlash == NULL) { retstr = pathname; /* just a filename with a '/' after it */ goto bail; } @@ -642,7 +642,7 @@ bail: * An extension is the stuff following the last '.' in the filename. If * there is nothing following the last '.', then there is no extension. * - * Returns a pointer to the '.' preceding the extension, or nil if no + * Returns a pointer to the '.' preceding the extension, or NULL if no * extension was found. */ const char* @@ -656,13 +656,13 @@ FindExtension(NulibState* pState, const char* pathname) * about "/foo.bar/file". */ pFilename = FilenameOnly(pState, pathname); - Assert(pFilename != nil); + Assert(pFilename != NULL); pExt = strrchr(pFilename, kFilenameExtDelim); /* also check for "/blah/foo.", which doesn't count */ - if (pExt != nil && *(pExt+1) != '\0') + if (pExt != NULL && *(pExt+1) != '\0') return pExt; - return nil; + return NULL; } diff --git a/nulib2/List.c b/nulib2/List.c index 14822d4..089349c 100644 --- a/nulib2/List.c +++ b/nulib2/List.c @@ -107,15 +107,15 @@ ShowContentsShort(NuArchive* pArchive, void* vpRecord) const NuRecord* pRecord = (NuRecord*) vpRecord; NulibState* pState; - Assert(pArchive != nil); + Assert(pArchive != NULL); (void) NuGetExtraData(pArchive, (void**) &pState); - Assert(pState != nil); + Assert(pState != NULL); if (!IsSpecified(pState, pRecord)) goto bail; printf("%s\n", - pRecord->filename == nil ? "":(const char*)pRecord->filename); + pRecord->filename == NULL ? "":(const char*)pRecord->filename); bail: return kNuOK; @@ -156,7 +156,7 @@ AnalyzeRecord(const NuRecord* pRecord, enum RecordKind* pRecordKind, for (idx = 0; idx < pRecord->recTotalThreads; idx++) { pThread = NuGetThread(pRecord, idx); - Assert(pThread != nil); + Assert(pThread != NULL); if (pThread->thThreadClass == kNuThreadClassData) { /* replace what's there if this might be more interesting */ @@ -201,9 +201,9 @@ ShowContentsVerbose(NuArchive* pArchive, void* vpRecord) char tmpbuf[16]; int len; - Assert(pArchive != nil); + Assert(pArchive != NULL); (void) NuGetExtraData(pArchive, (void**) &pState); - Assert(pState != nil); + Assert(pState != NULL); if (!IsSpecified(pState, pRecord)) goto bail; @@ -270,7 +270,7 @@ ShowContentsVerbose(NuArchive* pArchive, void* vpRecord) bail: if (err != kNuErrNone) { - printf("(ERROR on '%s')\n", pRecord->filename == nil ? + printf("(ERROR on '%s')\n", pRecord->filename == NULL ? "" : (const char*)pRecord->filename); } return kNuOK; @@ -283,9 +283,9 @@ NuError DoListShort(NulibState* pState) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; - Assert(pState != nil); + Assert(pState != NULL); if (NState_GetModBinaryII(pState)) return BNYDoListShort(pState); @@ -296,13 +296,13 @@ DoListShort(NulibState* pState) if (err != kNuErrNone) goto bail; pArchive = NState_GetNuArchive(pState); - Assert(pArchive != nil); + Assert(pArchive != NULL); err = NuContents(pArchive, ShowContentsShort); /* fall through with err */ bail: - if (pArchive != nil) + if (pArchive != NULL) (void) NuClose(pArchive); return err; } @@ -315,14 +315,14 @@ NuError DoListVerbose(NulibState* pState) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; const NuMasterHeader* pHeader; char date1[kDateOutputLen]; char date2[kDateOutputLen]; long totalLen, totalCompLen; const char* cp; - Assert(pState != nil); + Assert(pState != NULL); if (NState_GetModBinaryII(pState)) return BNYDoListVerbose(pState); @@ -333,7 +333,7 @@ DoListVerbose(NulibState* pState) if (err != kNuErrNone) goto bail; pArchive = NState_GetNuArchive(pState); - Assert(pArchive != nil); + Assert(pArchive != NULL); /* * Try to get just the filename. @@ -384,7 +384,7 @@ DoListVerbose(NulibState* pState) /*(void) NuDebugDumpArchive(pArchive);*/ bail: - if (pArchive != nil) + if (pArchive != NULL) (void) NuClose(pArchive); return err; } @@ -408,9 +408,9 @@ NuError DoListDebug(NulibState* pState) { NuError err; - NuArchive* pArchive = nil; + NuArchive* pArchive = NULL; - Assert(pState != nil); + Assert(pState != NULL); if (NState_GetModBinaryII(pState)) return BNYDoListDebug(pState); @@ -421,7 +421,7 @@ DoListDebug(NulibState* pState) if (err != kNuErrNone) goto bail; pArchive = NState_GetNuArchive(pState); - Assert(pArchive != nil); + Assert(pArchive != NULL); /* have to do something to force the library to scan the archive */ err = NuContents(pArchive, NullCallback); @@ -434,7 +434,7 @@ DoListDebug(NulibState* pState) /* fall through with err */ bail: - if (pArchive != nil) + if (pArchive != NULL) (void) NuClose(pArchive); return err; } diff --git a/nulib2/Main.c b/nulib2/Main.c index 439c668..8d3b116 100644 --- a/nulib2/Main.c +++ b/nulib2/Main.c @@ -42,7 +42,7 @@ static const ValidCombo gValidCombos[] = { /* * Find an entry in the gValidCombos table matching the specified command. * - * Returns nil if not found. + * Returns NULL if not found. */ static const ValidCombo* FindValidComboEntry(Command cmd) @@ -54,7 +54,7 @@ FindValidComboEntry(Command cmd) return &gValidCombos[i]; } - return nil; + return NULL; } /* @@ -67,8 +67,8 @@ IsValidModifier(Command cmd, char modifier) const ValidCombo* pvc; pvc = FindValidComboEntry(cmd); - if (pvc != nil) { - if (strchr(pvc->modifiers, modifier) == nil) + if (pvc != NULL) { + if (strchr(pvc->modifiers, modifier) == NULL) return false; else return true; @@ -85,7 +85,7 @@ IsValidOnPipe(Command cmd) const ValidCombo* pvc; pvc = FindValidComboEntry(cmd); - if (pvc != nil) { + if (pvc != NULL) { return pvc->okayForPipe; } else return false; @@ -100,7 +100,7 @@ IsFilespecRequired(Command cmd) const ValidCombo* pvc; pvc = FindValidComboEntry(cmd); - if (pvc != nil) { + if (pvc != NULL) { return pvc->filespecRequired; } else { /* command not found? warn about it here... */ @@ -124,7 +124,7 @@ GetProgName(const NulibState* pState, const char* argv0) sep = NState_GetSystemPathSeparator(pState); result = strrchr(argv0, sep); - if (result == nil) + if (result == NULL) result = argv0; else result++; /* advance past the separator */ @@ -273,7 +273,7 @@ DoHelp(const NulibState* pState) int j; pvc = FindValidComboEntry(help[i].cmd); - if (pvc == nil) { + if (pvc == NULL) { fprintf(stderr, "%s: internal error: couldn't find vc for %d\n", gProgName, help[i].cmd); continue; @@ -328,7 +328,7 @@ ProcessOptions(NulibState* pState, int argc, char* const* argv) if (argc == 2 && (tolower(argv[1][0]) == 'h' || (argv[1][0] == '-' && tolower(argv[1][1] == 'h')) ) ) { - DoHelp(nil); + DoHelp(NULL); return -1; } @@ -486,7 +486,7 @@ ProcessOptions(NulibState* pState, int argc, char* const* argv) gProgName); goto fail; } - NState_SetFilespecPointer(pState, nil); + NState_SetFilespecPointer(pState, NULL); NState_SetFilespecCount(pState, 0); } @@ -561,11 +561,11 @@ DoWork(NulibState* pState) int main(int argc, char** argv) { - NulibState* pState = nil; + NulibState* pState = NULL; long majorVersion, minorVersion, bugVersion; int result = 0; - (void) NuGetVersion(&majorVersion, &minorVersion, &bugVersion, nil, nil); + (void) NuGetVersion(&majorVersion, &minorVersion, &bugVersion, NULL, NULL); if (majorVersion != kNuVersionMajor || minorVersion < kNuVersionMinor) { fprintf(stderr, "ERROR: wrong version of NufxLib --" " wanted %d.%d.x, got %ld.%ld.%ld.\n", diff --git a/nulib2/MiscStuff.h b/nulib2/MiscStuff.h index 2e8a376..c6d5a11 100644 --- a/nulib2/MiscStuff.h +++ b/nulib2/MiscStuff.h @@ -42,11 +42,7 @@ int Nu_strncasecmp(const char *s1, const char *s2, size_t n); * Misc types. */ -#include - -#define nil NULL /* I can't seem to stop typing 'nil' now */ - -typedef uchar Boolean; +typedef unsigned char Boolean; #define false (0) #define true (!false) diff --git a/nulib2/MiscUtils.c b/nulib2/MiscUtils.c index 867ab39..00743bf 100644 --- a/nulib2/MiscUtils.c +++ b/nulib2/MiscUtils.c @@ -14,7 +14,7 @@ * Similar to perror(), but takes the error as an argument, and knows * about NufxLib errors as well as system errors. * - * If "format" is nil, just the error message itself is printed. + * If "format" is NULL, just the error message itself is printed. */ void ReportError(NuError err, const char* format, ...) @@ -22,12 +22,12 @@ ReportError(NuError err, const char* format, ...) const char* msg; va_list args; - Assert(format != nil); + Assert(format != NULL); va_start(args, format); /* print the message, if any */ - if (format != nil) { + if (format != NULL) { fprintf(stderr, "%s: ERROR: ", gProgName); vfprintf(stderr, format, args); } @@ -36,16 +36,16 @@ ReportError(NuError err, const char* format, ...) if (err == kNuErrNone) fprintf(stderr, "\n"); else { - if (format != nil) + if (format != NULL) fprintf(stderr, ": "); - msg = nil; + msg = NULL; if (err >= 0) msg = strerror(err); - if (msg == nil) + if (msg == NULL) msg = NuStrError(err); - if (msg == nil) + if (msg == NULL) fprintf(stderr, "(unknown err=%d)\n", err); else fprintf(stderr, "%s\n", msg); @@ -69,7 +69,7 @@ Malloc(size_t size) Assert(size > 0); _result = malloc(size); - if (_result == nil) { + if (_result == NULL) { ReportError(kNuErrMalloc, "malloc(%u) failed", (uint) size); DebugAbort(); /* leave a core dump if we're built for it */ } @@ -90,10 +90,10 @@ Realloc(void* ptr, size_t size) { void* _result; - Assert(ptr != nil); /* disallow this usage */ + Assert(ptr != NULL); /* disallow this usage */ Assert(size > 0); /* disallow this usage */ _result = realloc(ptr, size); - if (_result == nil) { + if (_result == NULL) { ReportError(kNuErrMalloc, "realloc(%u) failed", (uint) size); DebugAbort(); /* leave a core dump if we're built for it */ } @@ -103,7 +103,7 @@ Realloc(void* ptr, size_t size) void Free(void* ptr) { - if (ptr != nil) + if (ptr != NULL) free(ptr); } #endif diff --git a/nulib2/Nulib2.h b/nulib2/Nulib2.h index e78b437..a50c506 100644 --- a/nulib2/Nulib2.h +++ b/nulib2/Nulib2.h @@ -90,7 +90,7 @@ void ReportError(NuError err, const char* format, ...) # define Malloc(size) malloc(size) # define Calloc(size) calloc(1, size) # define Realloc(ptr, size) realloc(ptr, size) -# define Free(ptr) (ptr != nil ? free(ptr) : (void)0) +# define Free(ptr) (ptr != NULL ? free(ptr) : (void)0) #else void* Malloc(size_t size); void* Calloc(size_t size); diff --git a/nulib2/State.c b/nulib2/State.c index 046cbca..a89035f 100644 --- a/nulib2/State.c +++ b/nulib2/State.c @@ -18,10 +18,10 @@ static const char* gProgramVersion = "2.2.2"; NuError NState_Init(NulibState** ppState) { - Assert(ppState != nil); + Assert(ppState != NULL); *ppState = Calloc(sizeof(**ppState)); - if (*ppState == nil) + if (*ppState == NULL) return kNuErrMalloc; /* @@ -77,14 +77,14 @@ NState_ExtraInit(NulibState* pState) void NState_Free(NulibState* pState) { - if (pState == nil) + if (pState == NULL) return; Free(pState->renameToStr); /* ?? */ Free(pState->tempPathnameBuf); - if (pState->pPipeSink != nil) + if (pState->pPipeSink != NULL) NuFreeDataSink(pState->pPipeSink); - if (pState->pCommentSink != nil) + if (pState->pCommentSink != NULL) NuFreeDataSink(pState->pCommentSink); Free(pState); } @@ -108,7 +108,7 @@ NState_DebugDump(const NulibState* pState) "help", }; - Assert(pState != nil); + Assert(pState != NULL); printf("NState:\n"); printf(" programVersion: '%s'\n", pState->programVersion); @@ -301,14 +301,14 @@ NState_SetTempPathnameLen(NulibState* pState, long len) len++; /* add one for the '\0' */ if (pState->tempPathnameAlloc < len) { - if (pState->tempPathnameBuf == nil) + if (pState->tempPathnameBuf == NULL) newBuf = Malloc(len); else newBuf = Realloc(pState->tempPathnameBuf, len); - Assert(newBuf != nil); - if (newBuf == nil) { + Assert(newBuf != NULL); + if (newBuf == NULL) { Free(pState->tempPathnameBuf); - pState->tempPathnameBuf = nil; + pState->tempPathnameBuf = NULL; pState->tempPathnameAlloc = 0; ReportError(kNuErrMalloc, "buf realloc failed (%ld)", len); return; diff --git a/nulib2/SysUtils.c b/nulib2/SysUtils.c index af38635..1a90b1b 100644 --- a/nulib2/SysUtils.c +++ b/nulib2/SysUtils.c @@ -121,10 +121,10 @@ UNIXNormalizeFileName(NulibState* pState, const char* srcp, long srcLen, * The list comes from the Linux kernel's fs/msdos/namei.c. */ static const char* fatReservedNames3[] = { - "CON", "PRN", "NUL", "AUX", nil + "CON", "PRN", "NUL", "AUX", NULL }; static const char* fatReservedNames4[] = { - "LPT1", "LPT2", "LPT3", "LPT4", "COM1", "COM2", "COM3", "COM4", nil + "LPT1", "LPT2", "LPT3", "LPT4", "COM1", "COM2", "COM3", "COM4", NULL }; /* @@ -142,7 +142,7 @@ Win32NormalizeFileName(NulibState* pState, const char* srcp, long srcLen, if (srcLen >= 3) { const char** ppcch; - for (ppcch = fatReservedNames3; *ppcch != nil; ppcch++) { + for (ppcch = fatReservedNames3; *ppcch != NULL; ppcch++) { if (strncasecmp(srcp, *ppcch, 3) == 0 && srcp[3] == '.' || srcLen == 3) { @@ -160,7 +160,7 @@ Win32NormalizeFileName(NulibState* pState, const char* srcp, long srcLen, if (srcLen >= 4) { const char** ppcch; - for (ppcch = fatReservedNames4; *ppcch != nil; ppcch++) { + for (ppcch = fatReservedNames4; *ppcch != NULL; ppcch++) { if (strncasecmp(srcp, *ppcch, 4) == 0 && srcp[4] == '.' || srcLen == 4) { @@ -185,7 +185,7 @@ Win32NormalizeFileName(NulibState* pState, const char* srcp, long srcLen, if (NState_GetModPreserveType(pState)) *dstp++ = *srcp; *dstp++ = *srcp++; - } else if (strchr(kInvalid, *srcp) != nil) { + } else if (strchr(kInvalid, *srcp) != NULL) { /* change invalid char to "%2f" or '_' */ if (NState_GetModPreserveType(pState)) { *dstp++ = kForeignIndic; @@ -225,11 +225,11 @@ NormalizeFileName(NulibState* pState, const char* srcp, long srcLen, { NuError err; - Assert(srcp != nil); + Assert(srcp != NULL); Assert(srcLen > 0); Assert(dstLen > srcLen); - Assert(pDstp != nil); - Assert(*pDstp != nil); + Assert(pDstp != NULL); + Assert(*pDstp != NULL); Assert(fssep > ' ' && fssep < 0x7f); #if defined(UNIX_LIKE) @@ -271,13 +271,13 @@ MakeTempArchiveName(NulibState* pState) const char* archivePathname; char fssep; const char* nameStart; - char* newName = nil; + char* newName = NULL; char* namePtr; - char* resultName = nil; + char* resultName = NULL; long len; archivePathname = NState_GetArchiveFilename(pState); - Assert(archivePathname != nil); + Assert(archivePathname != NULL); fssep = NState_GetSystemPathSeparator(pState); Assert(fssep != 0); @@ -292,7 +292,7 @@ MakeTempArchiveName(NulibState* pState) /* figure out where the filename ends */ nameStart = strrchr(archivePathname, fssep); - if (nameStart == nil) { + if (nameStart == NULL) { /* nothing but a filename */ newName = Malloc(kTempFileNameLen +1); namePtr = newName; @@ -302,7 +302,7 @@ MakeTempArchiveName(NulibState* pState) strcpy(newName, archivePathname); namePtr = newName + (nameStart - archivePathname); } - if (newName == nil) + if (newName == NULL) goto bail; /* @@ -313,7 +313,7 @@ MakeTempArchiveName(NulibState* pState) resultName = newName; bail: - if (resultName == nil) + if (resultName == NULL) Free(newName); return resultName; } @@ -360,10 +360,10 @@ CheckFileStatus(const char* pathname, struct stat* psb, Boolean* pExists, NuError err = kNuErrNone; int cc; - Assert(pathname != nil); - Assert(pExists != nil); - Assert(pIsReadable != nil); - Assert(pIsDir != nil); + Assert(pathname != NULL); + Assert(pExists != NULL); + Assert(pIsReadable != NULL); + Assert(pIsDir != NULL); *pExists = true; *pIsReadable = true; @@ -403,8 +403,8 @@ UNIXTimeToDateTime(const time_t* pWhen, NuDateTime *pDateTime) { struct tm* ptm; - Assert(pWhen != nil); - Assert(pDateTime != nil); + Assert(pWhen != NULL); + Assert(pDateTime != NULL); ptm = localtime(pWhen); pDateTime->second = ptm->tm_sec; @@ -450,14 +450,14 @@ GetFileDetails(NulibState* pState, const char* pathname, struct stat* psb, char slashDotDotSlash[5] = "_.._"; time_t now; - Assert(pState != nil); - Assert(pathname != nil); - Assert(pDetails != nil); + Assert(pState != NULL); + Assert(pathname != NULL); + Assert(pDetails != NULL); /* set up the pathname buffer; note pDetails->storageName is const */ NState_SetTempPathnameLen(pState, strlen(pathname) +1); livePathStr = NState_GetTempPathnameBuf(pState); - Assert(livePathStr != nil); + Assert(livePathStr != NULL); strcpy(livePathStr, pathname); /* under Win32, both '/' and '\' work... we want to settle on one */ @@ -472,7 +472,7 @@ GetFileDetails(NulibState* pState, const char* pathname, struct stat* psb, memset(pDetails, 0, sizeof(*pDetails)); pDetails->threadID = kNuThreadIDDataFork; pDetails->storageName = livePathStr; /* point at temp buffer */ - pDetails->origName = nil; + pDetails->origName = NULL; pDetails->fileSysID = kNuFileSysUnknown; pDetails->fileSysInfo = kStorageFssep; pDetails->fileType = 0; @@ -497,7 +497,7 @@ GetFileDetails(NulibState* pState, const char* pathname, struct stat* psb, } } - now = time(nil); + now = time(NULL); UNIXTimeToDateTime(&now, &pDetails->archiveWhen); UNIXTimeToDateTime(&psb->st_mtime, &pDetails->modWhen); UNIXTimeToDateTime(&psb->st_mtime, &pDetails->createWhen); @@ -576,7 +576,7 @@ GetFileDetails(NulibState* pState, const char* pathname, struct stat* psb, slashDotDotSlash[0] = NState_GetSystemPathSeparator(pState); slashDotDotSlash[3] = NState_GetSystemPathSeparator(pState); if ((livePathStr[0] == '.' && livePathStr[1] == '.') || - (strstr(livePathStr, slashDotDotSlash) != nil)) + (strstr(livePathStr, slashDotDotSlash) != NULL)) { DBUG(("Found dot dot in '%s', keeping only filename\n", livePathStr)); doJunk = true; @@ -595,7 +595,7 @@ GetFileDetails(NulibState* pState, const char* pathname, struct stat* psb, if (NState_GetModJunkPaths(pState) || doJunk) { char* lastFssep; lastFssep = strrchr(livePathStr, NState_GetSystemPathSeparator(pState)); - if (lastFssep != nil) { + if (lastFssep != NULL) { Assert(*(lastFssep+1) != '\0'); /* should already have been caught*/ memmove(livePathStr, lastFssep+1, strlen(lastFssep+1)+1); } @@ -665,7 +665,7 @@ DoAddFile(NulibState* pState, NuArchive* pArchive, const char* pathname, DBUG(("Preparing comment for recordIdx=%ld\n", recordIdx)); Assert(recordIdx != 0); comment = GetSimpleComment(pState, pathname, kDefaultCommentLen); - if (comment != nil) { + if (comment != NULL) { NuDataSource* pDataSource; err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, @@ -676,15 +676,15 @@ DoAddFile(NulibState* pState, NuArchive* pArchive, const char* pathname, Free(comment); err = kNuErrNone; /* oh well */ } else { - comment = nil; /* now owned by the data source */ + comment = NULL; /* now owned by the data source */ err = NuAddThread(pArchive, recordIdx, kNuThreadIDComment, - pDataSource, nil); + pDataSource, NULL); if (err != kNuErrNone) { ReportError(err, "comment thread add failed"); NuFreeDataSource(pDataSource); err = kNuErrNone; /* oh well */ } else { - pDataSource = nil; /* now owned by NufxLib */ + pDataSource = NULL; /* now owned by NufxLib */ } } } @@ -711,20 +711,20 @@ static NuError UNIXAddDirectory(NulibState* pState, NuArchive* pArchive, const char* dirName) { NuError err = kNuErrNone; - DIR* dirp = nil; + DIR* dirp = NULL; DIR_TYPE* entry; char nbuf[MAX_PATH_LEN]; /* malloc might be better; this soaks stack */ char fssep; int len; - Assert(pState != nil); - Assert(pArchive != nil); - Assert(dirName != nil); + Assert(pState != NULL); + Assert(pArchive != NULL); + Assert(dirName != NULL); DBUG(("+++ DESCEND: '%s'\n", dirName)); dirp = opendir(dirName); - if (dirp == nil) { + if (dirp == NULL) { if (errno == ENOTDIR) err = kNuErrNotDir; else @@ -736,7 +736,7 @@ UNIXAddDirectory(NulibState* pState, NuArchive* pArchive, const char* dirName) fssep = NState_GetSystemPathSeparator(pState); /* could use readdir_r, but we don't care about reentrancy here */ - while ((entry = readdir(dirp)) != nil) { + while ((entry = readdir(dirp)) != NULL) { /* skip the dotsies */ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue; @@ -761,7 +761,7 @@ UNIXAddDirectory(NulibState* pState, NuArchive* pArchive, const char* dirName) } bail: - if (dirp != nil) + if (dirp != NULL) (void)closedir(dirp); return err; } @@ -783,9 +783,9 @@ UNIXAddFile(NulibState* pState, NuArchive* pArchive, const char* pathname) NuFileDetails details; struct stat sb; - Assert(pState != nil); - Assert(pArchive != nil); - Assert(pathname != nil); + Assert(pState != NULL); + Assert(pArchive != NULL); + Assert(pathname != NULL); err = CheckFileStatus(pathname, &sb, &exists, &isReadable, &isDir); if (err != kNuErrNone) { @@ -851,14 +851,14 @@ static const char* kWildMatchAll = "*.*"; static Win32dirent* OpenDir(const char* name) { - Win32dirent* dir = nil; - char* tmpStr = nil; + Win32dirent* dir = NULL; + char* tmpStr = NULL; char* cp; WIN32_FIND_DATA fnd; dir = Malloc(sizeof(*dir)); tmpStr = Malloc(strlen(name) + (2 + sizeof(kWildMatchAll))); - if (dir == nil || tmpStr == nil) + if (dir == NULL || tmpStr == NULL) goto failed; strcpy(tmpStr, name); @@ -887,14 +887,14 @@ bail: failed: Free(dir); - dir = nil; + dir = NULL; goto bail; } /* * Get an entry from an open directory. * - * Returns a nil pointer after the last entry has been read. + * Returns a NULL pointer after the last entry has been read. */ static Win32dirent* ReadDir(Win32dirent* dir) @@ -905,7 +905,7 @@ ReadDir(Win32dirent* dir) WIN32_FIND_DATA fnd; if (!FindNextFile(dir->d_hFindFile, &fnd)) - return nil; + return NULL; strcpy(dir->d_name, fnd.cFileName); dir->d_attr = (uchar) fnd.dwFileAttributes; } @@ -919,7 +919,7 @@ ReadDir(Win32dirent* dir) static void CloseDir(Win32dirent* dir) { - if (dir == nil) + if (dir == NULL) return; FindClose(dir->d_hFindFile); @@ -943,20 +943,20 @@ static NuError Win32AddDirectory(NulibState* pState, NuArchive* pArchive, const char* dirName) { NuError err = kNuErrNone; - Win32dirent* dirp = nil; + Win32dirent* dirp = NULL; Win32dirent* entry; char nbuf[MAX_PATH_LEN]; /* malloc might be better; this soaks stack */ char fssep; int len; - Assert(pState != nil); - Assert(pArchive != nil); - Assert(dirName != nil); + Assert(pState != NULL); + Assert(pArchive != NULL); + Assert(dirName != NULL); DBUG(("+++ DESCEND: '%s'\n", dirName)); dirp = OpenDir(dirName); - if (dirp == nil) { + if (dirp == NULL) { if (errno == ENOTDIR) err = kNuErrNotDir; else @@ -968,7 +968,7 @@ Win32AddDirectory(NulibState* pState, NuArchive* pArchive, const char* dirName) fssep = NState_GetSystemPathSeparator(pState); /* could use readdir_r, but we don't care about reentrancy here */ - while ((entry = ReadDir(dirp)) != nil) { + while ((entry = ReadDir(dirp)) != NULL) { /* skip the dotsies */ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue; @@ -993,7 +993,7 @@ Win32AddDirectory(NulibState* pState, NuArchive* pArchive, const char* dirName) } bail: - if (dirp != nil) + if (dirp != NULL) (void)CloseDir(dirp); return err; } @@ -1013,9 +1013,9 @@ Win32AddFile(NulibState* pState, NuArchive* pArchive, const char* pathname) NuFileDetails details; struct stat sb; - Assert(pState != nil); - Assert(pArchive != nil); - Assert(pathname != nil); + Assert(pState != NULL); + Assert(pArchive != NULL); + Assert(pathname != NULL); err = CheckFileStatus(pathname, &sb, &exists, &isReadable, &isDir); if (err != kNuErrNone) { @@ -1071,7 +1071,7 @@ bail_quiet: * * [ I figure the GS/OS version will want to pass a copy of the file * info from the GSOSAddDirectory function back into GSOSAddFile, so we'd - * want to call it from here with a nil pointer indicating that we + * want to call it from here with a NULL pointer indicating that we * don't yet have the file info. That way we can get the file info * from the directory read call and won't have to check it again in * GSOSAddFile. ] @@ -1099,7 +1099,7 @@ Mkdir(const char* dir) { NuError err = kNuErrNone; - Assert(dir != nil); + Assert(dir != NULL); #if defined(UNIX_LIKE) if (mkdir(dir, S_IRWXU | S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH) < 0) { @@ -1130,8 +1130,8 @@ NuError TestFileExistence(const char* fileName, Boolean* pIsDir) { NuError err = kNuErrNone; - Assert(fileName != nil); - Assert(pIsDir != nil); + Assert(fileName != NULL); + Assert(pIsDir != NULL); #if defined(UNIX_LIKE) || defined(WINDOWS_LIKE) {