Move method return type to declaration line

Having the method name up against the left edge used to be common
practice, because you could jump to a method quickly by searching
for "^name".  Now we have "ctags" and IDEs.
This commit is contained in:
Andy McFadden 2014-12-22 16:00:33 -08:00
parent 20c9ac1195
commit 9666ebd97a
34 changed files with 691 additions and 1200 deletions

View File

@ -53,8 +53,7 @@ static void Nu_CloseAndFree(NuArchive* pArchive);
/* /*
* Allocate and initialize a new NuArchive structure. * Allocate and initialize a new NuArchive structure.
*/ */
static NuError static NuError Nu_NuArchiveNew(NuArchive** ppArchive)
Nu_NuArchiveNew(NuArchive** ppArchive)
{ {
Assert(ppArchive != NULL); Assert(ppArchive != NULL);
@ -105,8 +104,7 @@ Nu_NuArchiveNew(NuArchive** ppArchive)
/* /*
* Free up a NuArchive structure and its contents. * Free up a NuArchive structure and its contents.
*/ */
static NuError static NuError Nu_NuArchiveFree(NuArchive* pArchive)
Nu_NuArchiveFree(NuArchive* pArchive)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);
Assert(pArchive->structMagic == kNuArchiveStructMagic); Assert(pArchive->structMagic == kNuArchiveStructMagic);
@ -133,8 +131,7 @@ Nu_NuArchiveFree(NuArchive* pArchive)
/* /*
* Copy a NuMasterHeader struct. * Copy a NuMasterHeader struct.
*/ */
void void Nu_MasterHeaderCopy(NuArchive* pArchive, NuMasterHeader* pDstHeader,
Nu_MasterHeaderCopy(NuArchive* pArchive, NuMasterHeader* pDstHeader,
const NuMasterHeader* pSrcHeader) const NuMasterHeader* pSrcHeader)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);
@ -147,8 +144,8 @@ Nu_MasterHeaderCopy(NuArchive* pArchive, NuMasterHeader* pDstHeader,
/* /*
* Get a pointer to the archive master header (this is an API call). * Get a pointer to the archive master header (this is an API call).
*/ */
NuError NuError Nu_GetMasterHeader(NuArchive* pArchive,
Nu_GetMasterHeader(NuArchive* pArchive, const NuMasterHeader** ppMasterHeader) const NuMasterHeader** ppMasterHeader)
{ {
if (ppMasterHeader == NULL) if (ppMasterHeader == NULL)
return kNuErrInvalidArg; return kNuErrInvalidArg;
@ -162,8 +159,7 @@ Nu_GetMasterHeader(NuArchive* pArchive, const NuMasterHeader** ppMasterHeader)
/* /*
* Allocate the general-purpose compression buffer, if needed. * Allocate the general-purpose compression buffer, if needed.
*/ */
NuError NuError Nu_AllocCompressionBufferIFN(NuArchive* pArchive)
Nu_AllocCompressionBufferIFN(NuArchive* pArchive)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);
@ -181,8 +177,7 @@ Nu_AllocCompressionBufferIFN(NuArchive* pArchive)
/* /*
* Return a unique value. * Return a unique value.
*/ */
NuRecordIdx NuRecordIdx Nu_GetNextRecordIdx(NuArchive* pArchive)
Nu_GetNextRecordIdx(NuArchive* pArchive)
{ {
return pArchive->nextRecordIdx++; return pArchive->nextRecordIdx++;
} }
@ -190,8 +185,7 @@ Nu_GetNextRecordIdx(NuArchive* pArchive)
/* /*
* Return a unique value. * Return a unique value.
*/ */
NuThreadIdx NuThreadIdx Nu_GetNextThreadIdx(NuArchive* pArchive)
Nu_GetNextThreadIdx(NuArchive* pArchive)
{ {
return pArchive->nextRecordIdx++; /* just use the record counter */ return pArchive->nextRecordIdx++; /* just use the record counter */
} }
@ -206,8 +200,7 @@ Nu_GetNextThreadIdx(NuArchive* pArchive)
/* /*
* Copy the wrapper from the archive file to the temp file. * Copy the wrapper from the archive file to the temp file.
*/ */
NuError NuError Nu_CopyWrapperToTemp(NuArchive* pArchive)
Nu_CopyWrapperToTemp(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -245,8 +238,7 @@ bail:
* guess some of the SEA weirdness stems from some far-sighted support * guess some of the SEA weirdness stems from some far-sighted support
* for multiple archives within a single SEA wrapper. * for multiple archives within a single SEA wrapper.
*/ */
NuError NuError Nu_UpdateWrapper(NuArchive* pArchive, FILE* fp)
Nu_UpdateWrapper(NuArchive* pArchive, FILE* fp)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Boolean hasBinary2, hasSea; Boolean hasBinary2, hasSea;
@ -397,8 +389,7 @@ bail:
* require additional disk space to be used, assuming a filesystem block * require additional disk space to be used, assuming a filesystem block
* size of at least 128 bytes. * size of at least 128 bytes.
*/ */
NuError NuError Nu_AdjustWrapperPadding(NuArchive* pArchive, FILE* fp)
Nu_AdjustWrapperPadding(NuArchive* pArchive, FILE* fp)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Boolean hasBinary2, hasSea; Boolean hasBinary2, hasSea;
@ -493,8 +484,7 @@ bail:
* *
* On exit, the stream will be positioned just past the master header. * On exit, the stream will be positioned just past the master header.
*/ */
static NuError static NuError Nu_ReadMasterHeader(NuArchive* pArchive)
Nu_ReadMasterHeader(NuArchive* pArchive)
{ {
NuError err; NuError err;
uint16_t crc; uint16_t crc;
@ -710,8 +700,7 @@ bail:
* Prepare the NuArchive and NuMasterHeader structures for use with a * Prepare the NuArchive and NuMasterHeader structures for use with a
* newly-created archive. * newly-created archive.
*/ */
static void static void Nu_InitNewArchive(NuArchive* pArchive)
Nu_InitNewArchive(NuArchive* pArchive)
{ {
NuMasterHeader* pHeader; NuMasterHeader* pHeader;
@ -739,8 +728,7 @@ Nu_InitNewArchive(NuArchive* pArchive)
/* /*
* Open an archive in streaming read-only mode. * Open an archive in streaming read-only mode.
*/ */
NuError NuError Nu_StreamOpenRO(FILE* infp, NuArchive** ppArchive)
Nu_StreamOpenRO(FILE* infp, NuArchive** ppArchive)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;
@ -773,8 +761,7 @@ bail:
/* /*
* Open an archive in non-streaming read-only mode. * Open an archive in non-streaming read-only mode.
*/ */
NuError NuError Nu_OpenRO(const char* archivePathname, NuArchive** ppArchive)
Nu_OpenRO(const char* archivePathname, NuArchive** ppArchive)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;
@ -825,8 +812,7 @@ bail:
* Thought for the day: consider using Win32 SetFileAttributes() to make * Thought for the day: consider using Win32 SetFileAttributes() to make
* temp files hidden. We will need to un-hide it before rolling it over. * temp files hidden. We will need to un-hide it before rolling it over.
*/ */
static NuError static NuError Nu_OpenTempFile(char* fileName, FILE** pFp)
Nu_OpenTempFile(char* fileName, FILE** pFp)
{ {
NuArchive* pArchive = NULL; /* dummy for NU_BLOB */ NuArchive* pArchive = NULL; /* dummy for NU_BLOB */
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -926,9 +912,8 @@ bail:
* Open an archive in read-write mode, optionally creating it if it doesn't * Open an archive in read-write mode, optionally creating it if it doesn't
* exist. * exist.
*/ */
NuError NuError Nu_OpenRW(const char* archivePathname, const char* tmpPathname,
Nu_OpenRW(const char* archivePathname, const char* tmpPathname, uint32_t flags, uint32_t flags, NuArchive** ppArchive)
NuArchive** ppArchive)
{ {
NuError err; NuError err;
FILE* fp = NULL; FILE* fp = NULL;
@ -1058,8 +1043,7 @@ bail:
/* /*
* Write the NuFX master header at the current offset. * Write the NuFX master header at the current offset.
*/ */
NuError NuError Nu_WriteMasterHeader(NuArchive* pArchive, FILE* fp,
Nu_WriteMasterHeader(NuArchive* pArchive, FILE* fp,
NuMasterHeader* pHeader) NuMasterHeader* pHeader)
{ {
NuError err; NuError err;
@ -1120,8 +1104,7 @@ bail:
* If it's a brand-new archive, and we didn't add anything to it, then we * If it's a brand-new archive, and we didn't add anything to it, then we
* want to remove the stub archive file. * want to remove the stub archive file.
*/ */
static void static void Nu_CloseAndFree(NuArchive* pArchive)
Nu_CloseAndFree(NuArchive* pArchive)
{ {
if (pArchive->archiveFp != NULL) { if (pArchive->archiveFp != NULL) {
DBUG(("--- Closing archive\n")); DBUG(("--- Closing archive\n"));
@ -1156,8 +1139,7 @@ Nu_CloseAndFree(NuArchive* pArchive)
/* /*
* Flush pending changes to the archive, then close it. * Flush pending changes to the archive, then close it.
*/ */
NuError NuError Nu_Close(NuArchive* pArchive)
Nu_Close(NuArchive* pArchive)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
long flushStatus; long flushStatus;
@ -1188,8 +1170,7 @@ Nu_Close(NuArchive* pArchive)
/* /*
* Delete the archive file, which should already have been closed. * Delete the archive file, which should already have been closed.
*/ */
NuError NuError Nu_DeleteArchiveFile(NuArchive* pArchive)
Nu_DeleteArchiveFile(NuArchive* pArchive)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);
Assert(pArchive->archiveFp == NULL); Assert(pArchive->archiveFp == NULL);
@ -1202,8 +1183,7 @@ Nu_DeleteArchiveFile(NuArchive* pArchive)
* Rename the temp file on top of the original archive. The temp file * Rename the temp file on top of the original archive. The temp file
* should be closed, and the archive file should be deleted. * should be closed, and the archive file should be deleted.
*/ */
NuError NuError Nu_RenameTempToArchive(NuArchive* pArchive)
Nu_RenameTempToArchive(NuArchive* pArchive)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);
Assert(pArchive->archiveFp == NULL); Assert(pArchive->archiveFp == NULL);

View File

@ -26,8 +26,7 @@
/* /*
* Read one byte, optionally computing a CRC. * Read one byte, optionally computing a CRC.
*/ */
uint8_t uint8_t Nu_ReadOneC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
Nu_ReadOneC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
{ {
int ic; int ic;
@ -41,8 +40,7 @@ Nu_ReadOneC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
return (uint8_t) ic; return (uint8_t) ic;
} }
uint8_t uint8_t Nu_ReadOne(NuArchive* pArchive, FILE* fp)
Nu_ReadOne(NuArchive* pArchive, FILE* fp)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
return Nu_ReadOneC(pArchive, fp, &dummyCrc); return Nu_ReadOneC(pArchive, fp, &dummyCrc);
@ -51,8 +49,7 @@ Nu_ReadOne(NuArchive* pArchive, FILE* fp)
/* /*
* Write one byte, optionally computing a CRC. * Write one byte, optionally computing a CRC.
*/ */
void void Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uint8_t val, uint16_t* pCrc)
Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uint8_t val, uint16_t* pCrc)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);
Assert(fp != NULL); Assert(fp != NULL);
@ -61,8 +58,7 @@ Nu_WriteOneC(NuArchive* pArchive, FILE* fp, uint8_t val, uint16_t* pCrc)
putc(val, fp); putc(val, fp);
} }
void void Nu_WriteOne(NuArchive* pArchive, FILE* fp, uint8_t val)
Nu_WriteOne(NuArchive* pArchive, FILE* fp, uint8_t val)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
Nu_WriteOneC(pArchive, fp, val, &dummyCrc); Nu_WriteOneC(pArchive, fp, val, &dummyCrc);
@ -72,8 +68,7 @@ Nu_WriteOne(NuArchive* pArchive, FILE* fp, uint8_t val)
/* /*
* Read two little-endian bytes, optionally computing a CRC. * Read two little-endian bytes, optionally computing a CRC.
*/ */
uint16_t uint16_t Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
{ {
int ic1, ic2; int ic1, ic2;
@ -89,8 +84,7 @@ Nu_ReadTwoC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
return ic1 | ic2 << 8; return ic1 | ic2 << 8;
} }
uint16_t uint16_t Nu_ReadTwo(NuArchive* pArchive, FILE* fp)
Nu_ReadTwo(NuArchive* pArchive, FILE* fp)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
return Nu_ReadTwoC(pArchive, fp, &dummyCrc); return Nu_ReadTwoC(pArchive, fp, &dummyCrc);
@ -100,8 +94,7 @@ Nu_ReadTwo(NuArchive* pArchive, FILE* fp)
/* /*
* Write two little-endian bytes, optionally computing a CRC. * Write two little-endian bytes, optionally computing a CRC.
*/ */
void void Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, uint16_t val, uint16_t* pCrc)
Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, uint16_t val, uint16_t* pCrc)
{ {
int ic1, ic2; int ic1, ic2;
@ -118,8 +111,7 @@ Nu_WriteTwoC(NuArchive* pArchive, FILE* fp, uint16_t val, uint16_t* pCrc)
putc(ic2, fp); putc(ic2, fp);
} }
void void Nu_WriteTwo(NuArchive* pArchive, FILE* fp, uint16_t val)
Nu_WriteTwo(NuArchive* pArchive, FILE* fp, uint16_t val)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
Nu_WriteTwoC(pArchive, fp, val, &dummyCrc); Nu_WriteTwoC(pArchive, fp, val, &dummyCrc);
@ -129,8 +121,7 @@ Nu_WriteTwo(NuArchive* pArchive, FILE* fp, uint16_t val)
/* /*
* Read four little-endian bytes, optionally computing a CRC. * Read four little-endian bytes, optionally computing a CRC.
*/ */
uint32_t uint32_t Nu_ReadFourC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
Nu_ReadFourC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
{ {
int ic1, ic2, ic3, ic4; int ic1, ic2, ic3, ic4;
@ -150,8 +141,7 @@ Nu_ReadFourC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
return ic1 | ic2 << 8 | (uint32_t)ic3 << 16 | (uint32_t)ic4 << 24; return ic1 | ic2 << 8 | (uint32_t)ic3 << 16 | (uint32_t)ic4 << 24;
} }
uint32_t uint32_t Nu_ReadFour(NuArchive* pArchive, FILE* fp)
Nu_ReadFour(NuArchive* pArchive, FILE* fp)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
return Nu_ReadFourC(pArchive, fp, &dummyCrc); return Nu_ReadFourC(pArchive, fp, &dummyCrc);
@ -161,8 +151,7 @@ Nu_ReadFour(NuArchive* pArchive, FILE* fp)
/* /*
* Write four little-endian bytes, optionally computing a CRC. * Write four little-endian bytes, optionally computing a CRC.
*/ */
void void Nu_WriteFourC(NuArchive* pArchive, FILE* fp, uint32_t val, uint16_t* pCrc)
Nu_WriteFourC(NuArchive* pArchive, FILE* fp, uint32_t val, uint16_t* pCrc)
{ {
int ic1, ic2, ic3, ic4; int ic1, ic2, ic3, ic4;
@ -185,8 +174,7 @@ Nu_WriteFourC(NuArchive* pArchive, FILE* fp, uint32_t val, uint16_t* pCrc)
putc(ic4, fp); putc(ic4, fp);
} }
void void Nu_WriteFour(NuArchive* pArchive, FILE* fp, uint32_t val)
Nu_WriteFour(NuArchive* pArchive, FILE* fp, uint32_t val)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
Nu_WriteFourC(pArchive, fp, val, &dummyCrc); Nu_WriteFourC(pArchive, fp, val, &dummyCrc);
@ -200,8 +188,7 @@ Nu_WriteFour(NuArchive* pArchive, FILE* fp, uint32_t val)
* and GS/ShrinkIt. It's easy enough to deal with, and I figure the less * and GS/ShrinkIt. It's easy enough to deal with, and I figure the less
* messing-with, the better. * messing-with, the better.
*/ */
NuDateTime NuDateTime Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
{ {
NuDateTime temp; NuDateTime temp;
int ic; int ic;
@ -238,8 +225,7 @@ Nu_ReadDateTimeC(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
return temp; return temp;
} }
NuDateTime NuDateTime Nu_ReadDateTime(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
Nu_ReadDateTime(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
return Nu_ReadDateTimeC(pArchive, fp, &dummyCrc); return Nu_ReadDateTimeC(pArchive, fp, &dummyCrc);
@ -249,8 +235,7 @@ Nu_ReadDateTime(NuArchive* pArchive, FILE* fp, uint16_t* pCrc)
/* /*
* Write an 8-byte NuFX Date/Time structure. * Write an 8-byte NuFX Date/Time structure.
*/ */
void void Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime,
Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime,
uint16_t* pCrc) uint16_t* pCrc)
{ {
int ic; int ic;
@ -285,8 +270,7 @@ Nu_WriteDateTimeC(NuArchive* pArchive, FILE* fp, NuDateTime dateTime,
putc(ic, fp); putc(ic, fp);
} }
void void Nu_WriteDateTime(NuArchive* pArchive, FILE* fp, NuDateTime dateTime)
Nu_WriteDateTime(NuArchive* pArchive, FILE* fp, NuDateTime dateTime)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
Nu_WriteDateTimeC(pArchive, fp, dateTime, &dummyCrc); Nu_WriteDateTimeC(pArchive, fp, dateTime, &dummyCrc);
@ -296,8 +280,7 @@ Nu_WriteDateTime(NuArchive* pArchive, FILE* fp, NuDateTime dateTime)
/* /*
* Read N bytes from the stream, optionally computing a CRC. * Read N bytes from the stream, optionally computing a CRC.
*/ */
void void Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
uint16_t* pCrc) uint16_t* pCrc)
{ {
uint8_t* buffer = vbuffer; uint8_t* buffer = vbuffer;
@ -316,8 +299,7 @@ Nu_ReadBytesC(NuArchive* pArchive, FILE* fp, void* vbuffer, long count,
} }
} }
void void Nu_ReadBytes(NuArchive* pArchive, FILE* fp, void* vbuffer, long count)
Nu_ReadBytes(NuArchive* pArchive, FILE* fp, void* vbuffer, long count)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
Nu_ReadBytesC(pArchive, fp, vbuffer, count, &dummyCrc); Nu_ReadBytesC(pArchive, fp, vbuffer, count, &dummyCrc);
@ -327,9 +309,8 @@ Nu_ReadBytes(NuArchive* pArchive, FILE* fp, void* vbuffer, long count)
/* /*
* Write N bytes to the stream, optionally computing a CRC. * Write N bytes to the stream, optionally computing a CRC.
*/ */
void void Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer,
Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count, long count, uint16_t* pCrc)
uint16_t* pCrc)
{ {
const uint8_t* buffer = vbuffer; const uint8_t* buffer = vbuffer;
int ic; int ic;
@ -347,8 +328,8 @@ Nu_WriteBytesC(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count,
} }
} }
void void Nu_WriteBytes(NuArchive* pArchive, FILE* fp, const void* vbuffer,
Nu_WriteBytes(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count) long count)
{ {
uint16_t dummyCrc CLEAN_INIT; uint16_t dummyCrc CLEAN_INIT;
Nu_WriteBytesC(pArchive, fp, vbuffer, count, &dummyCrc); Nu_WriteBytesC(pArchive, fp, vbuffer, count, &dummyCrc);
@ -365,8 +346,7 @@ Nu_WriteBytes(NuArchive* pArchive, FILE* fp, const void* vbuffer, long count)
* Determine whether the stream completed the last set of operations * Determine whether the stream completed the last set of operations
* successfully. * successfully.
*/ */
NuError NuError Nu_HeaderIOFailed(NuArchive* pArchive, FILE* fp)
Nu_HeaderIOFailed(NuArchive* pArchive, FILE* fp)
{ {
if (feof(fp) || ferror(fp)) if (feof(fp) || ferror(fp))
return kNuErrFile; return kNuErrFile;
@ -381,8 +361,7 @@ Nu_HeaderIOFailed(NuArchive* pArchive, FILE* fp)
* *
* The values for "ptrname" are the same as for fseek(). * The values for "ptrname" are the same as for fseek().
*/ */
NuError NuError Nu_SeekArchive(NuArchive* pArchive, FILE* fp, long offset, int ptrname)
Nu_SeekArchive(NuArchive* pArchive, FILE* fp, long offset, int ptrname)
{ {
if (Nu_IsStreaming(pArchive)) { if (Nu_IsStreaming(pArchive)) {
Assert(ptrname == SEEK_CUR); Assert(ptrname == SEEK_CUR);
@ -408,8 +387,7 @@ Nu_SeekArchive(NuArchive* pArchive, FILE* fp, long offset, int ptrname)
* *
* Note that rewind(3S) resets the error indication, but this doesn't. * Note that rewind(3S) resets the error indication, but this doesn't.
*/ */
NuError NuError Nu_RewindArchive(NuArchive* pArchive)
Nu_RewindArchive(NuArchive* pArchive)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);
Assert(!Nu_IsStreaming(pArchive)); Assert(!Nu_IsStreaming(pArchive));

View File

@ -25,13 +25,11 @@
/* /*
* Alloc and free functions provided to libbz2. * Alloc and free functions provided to libbz2.
*/ */
static void* static void* Nu_bzalloc(void* opaque, int items, int size)
Nu_bzalloc(void* opaque, int items, int size)
{ {
return Nu_Malloc(opaque, items * size); return Nu_Malloc(opaque, items * size);
} }
static void static void Nu_bzfree(void* opaque, void* address)
Nu_bzfree(void* opaque, void* address)
{ {
Nu_Free(opaque, address); Nu_Free(opaque, address);
} }
@ -46,8 +44,7 @@ Nu_bzfree(void* opaque, void* address)
/* /*
* Compress "srcLen" bytes from "pStraw" to "fp". * Compress "srcLen" bytes from "pStraw" to "fp".
*/ */
NuError NuError Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressBzip2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -173,8 +170,7 @@ bail:
/* /*
* Expand from "infp" to "pFunnel". * Expand from "infp" to "pFunnel".
*/ */
NuError NuError Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
Nu_ExpandBzip2(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc) const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;

View File

@ -15,8 +15,7 @@
/* /*
* "Compress" an uncompressed thread. * "Compress" an uncompressed thread.
*/ */
static NuError static NuError Nu_CompressUncompressed(NuArchive* pArchive, NuStraw* pStraw,
Nu_CompressUncompressed(NuArchive* pArchive, NuStraw* pStraw,
FILE* fp, uint32_t srcLen, uint32_t* pDstLen, uint16_t *pCrc) FILE* fp, uint32_t srcLen, uint32_t* pDstLen, uint16_t *pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -87,8 +86,7 @@ bail:
* On exit, the output file will be positioned after the last byte of the * On exit, the output file will be positioned after the last byte of the
* output. (For a pre-sized buffer, this may not be the desired result.) * output. (For a pre-sized buffer, this may not be the desired result.)
*/ */
NuError NuError Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
NuThreadID threadID, NuThreadFormat sourceFormat, NuThreadID threadID, NuThreadFormat sourceFormat,
NuThreadFormat targetFormat, NuProgressData* pProgressData, FILE* dstFp, NuThreadFormat targetFormat, NuProgressData* pProgressData, FILE* dstFp,
NuThread* pThread) NuThread* pThread)
@ -322,8 +320,7 @@ bail:
* will copy the data, and then continue writing zeros to fill out the rest * will copy the data, and then continue writing zeros to fill out the rest
* of the pre-sized buffer. * of the pre-sized buffer.
*/ */
NuError NuError Nu_CopyPresizedToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
Nu_CopyPresizedToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
NuThreadID threadID, FILE* dstFp, NuThread* pThread, char** ppSavedCopy) NuThreadID threadID, FILE* dstFp, NuThread* pThread, char** ppSavedCopy)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;

View File

@ -83,8 +83,7 @@ const uint16_t gNuCrc16Table[256] = {
* Depending on CPU architecture, one may be dramatically faster than * Depending on CPU architecture, one may be dramatically faster than
* the other. * the other.
*/ */
uint16_t uint16_t Nu_CalcCRC16(uint16_t seed, const uint8_t* ptr, int count)
Nu_CalcCRC16(uint16_t seed, const uint8_t* ptr, int count)
{ {
uint16_t CRC = seed; uint16_t CRC = seed;
#ifndef CRC_TAB #ifndef CRC_TAB

View File

@ -65,8 +65,7 @@ static const char* gFileSysIDs[] = {
* *
* Returns "buffer" for the benefit of printf() calls. * Returns "buffer" for the benefit of printf() calls.
*/ */
static char* static char* Nu_DebugDumpDate(const NuDateTime* pDateTime, char* buffer)
Nu_DebugDumpDate(const NuDateTime* pDateTime, char* buffer)
{ {
char* cp; char* cp;
@ -118,8 +117,7 @@ bail:
* *
* The result will be 2x the size of the original, +1 for a null byte. * The result will be 2x the size of the original, +1 for a null byte.
*/ */
static void static void ConvertToHexStr(const uint8_t* inBuf, int inLen, char* outBuf)
ConvertToHexStr(const uint8_t* inBuf, int inLen, char* outBuf)
{ {
while (inLen--) { while (inLen--) {
*outBuf++ = HexConv((*inBuf >> 4) & 0x0f); *outBuf++ = HexConv((*inBuf >> 4) & 0x0f);
@ -133,8 +131,7 @@ ConvertToHexStr(const uint8_t* inBuf, int inLen, char* outBuf)
/* /*
* Dump everything we know about pThread. * Dump everything we know about pThread.
*/ */
void void Nu_DebugDumpThread(const NuThread* pThread)
Nu_DebugDumpThread(const NuThread* pThread)
{ {
static const char* kInd = " "; static const char* kInd = " ";
NuThreadID threadID; NuThreadID threadID;
@ -177,8 +174,7 @@ Nu_DebugDumpThread(const NuThread* pThread)
* set. Pass in the "orig" copy in "pRecord", and optionally pass in the * set. Pass in the "orig" copy in "pRecord", and optionally pass in the
* "copy" set in "pXrefRecord" to glean data from both. * "copy" set in "pXrefRecord" to glean data from both.
*/ */
static void static void Nu_DebugDumpRecord(NuArchive* pArchive, const NuRecord* pRecord,
Nu_DebugDumpRecord(NuArchive* pArchive, const NuRecord* pRecord,
const NuRecord* pXrefRecord, Boolean isDeleted) const NuRecord* pXrefRecord, Boolean isDeleted)
{ {
NuError err; /* dummy */ NuError err; /* dummy */
@ -290,9 +286,8 @@ bail:
/* /*
* Dump the records in a RecordSet. * Dump the records in a RecordSet.
*/ */
static void static void Nu_DebugDumpRecordSet(NuArchive* pArchive,
Nu_DebugDumpRecordSet(NuArchive* pArchive, const NuRecordSet* pRecordSet, const NuRecordSet* pRecordSet, const NuRecordSet* pXrefSet)
const NuRecordSet* pXrefSet)
{ {
const NuRecord* pRecord; const NuRecord* pRecord;
const NuRecord* pXrefRecord; const NuRecord* pXrefRecord;
@ -332,8 +327,7 @@ Nu_DebugDumpRecordSet(NuArchive* pArchive, const NuRecordSet* pRecordSet,
/* /*
* Dump the master header block. * Dump the master header block.
*/ */
static void static void Nu_DebugDumpMH(const NuMasterHeader* pMasterHeader)
Nu_DebugDumpMH(const NuMasterHeader* pMasterHeader)
{ {
static const char* kInd = " "; static const char* kInd = " ";
char dateBuf1[kNuDateOutputLen]; char dateBuf1[kNuDateOutputLen];
@ -359,8 +353,7 @@ Nu_DebugDumpMH(const NuMasterHeader* pMasterHeader)
* the archive, then this won't be very interesting. This will never * the archive, then this won't be very interesting. This will never
* show any records for streaming-mode archives. * show any records for streaming-mode archives.
*/ */
void void Nu_DebugDumpAll(NuArchive* pArchive)
Nu_DebugDumpAll(NuArchive* pArchive)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);

View File

@ -23,8 +23,7 @@
* NOTE: threadFormat is how you want the data to be compressed. The * NOTE: threadFormat is how you want the data to be compressed. The
* threadFormat passed to DataSource describes the source data. * threadFormat passed to DataSource describes the source data.
*/ */
NuError NuError Nu_ThreadModAdd_New(NuArchive* pArchive, NuThreadID threadID,
Nu_ThreadModAdd_New(NuArchive* pArchive, NuThreadID threadID,
NuThreadFormat threadFormat, NuDataSource* pDataSource, NuThreadFormat threadFormat, NuDataSource* pDataSource,
NuThreadMod** ppThreadMod) NuThreadMod** ppThreadMod)
{ {
@ -53,8 +52,7 @@ Nu_ThreadModAdd_New(NuArchive* pArchive, NuThreadID threadID,
* *
* Caller is allowed to dispose of the data source. * Caller is allowed to dispose of the data source.
*/ */
NuError NuError Nu_ThreadModUpdate_New(NuArchive* pArchive, NuThreadIdx threadIdx,
Nu_ThreadModUpdate_New(NuArchive* pArchive, NuThreadIdx threadIdx,
NuDataSource* pDataSource, NuThreadMod** ppThreadMod) NuDataSource* pDataSource, NuThreadMod** ppThreadMod)
{ {
Assert(ppThreadMod != NULL); Assert(ppThreadMod != NULL);
@ -78,8 +76,7 @@ Nu_ThreadModUpdate_New(NuArchive* pArchive, NuThreadIdx threadIdx,
* The "threadID" argument is really only needed for filename threads. We * The "threadID" argument is really only needed for filename threads. We
* use it when trying to track how many filename threads we really have. * use it when trying to track how many filename threads we really have.
*/ */
NuError NuError Nu_ThreadModDelete_New(NuArchive* pArchive, NuThreadIdx threadIdx,
Nu_ThreadModDelete_New(NuArchive* pArchive, NuThreadIdx threadIdx,
NuThreadID threadID, NuThreadMod** ppThreadMod) NuThreadID threadID, NuThreadMod** ppThreadMod)
{ {
Assert(ppThreadMod != NULL); Assert(ppThreadMod != NULL);
@ -99,8 +96,7 @@ Nu_ThreadModDelete_New(NuArchive* pArchive, NuThreadIdx threadIdx,
/* /*
* Free a single NuThreadMod. * Free a single NuThreadMod.
*/ */
void void Nu_ThreadModFree(NuArchive* pArchive, NuThreadMod* pThreadMod)
Nu_ThreadModFree(NuArchive* pArchive, NuThreadMod* pThreadMod)
{ {
if (pThreadMod == NULL) if (pThreadMod == NULL)
return; return;
@ -133,8 +129,8 @@ Nu_ThreadModFree(NuArchive* pArchive, NuThreadMod* pThreadMod)
* *
* Returns "NULL" if nothing found. * Returns "NULL" if nothing found.
*/ */
NuThreadMod* NuThreadMod* Nu_ThreadMod_FindByThreadIdx(const NuRecord* pRecord,
Nu_ThreadMod_FindByThreadIdx(const NuRecord* pRecord, NuThreadIdx threadIdx) NuThreadIdx threadIdx)
{ {
NuThreadMod* pThreadMod; NuThreadMod* pThreadMod;
NuThreadMod* pMatch = NULL; NuThreadMod* pMatch = NULL;
@ -178,9 +174,8 @@ Nu_ThreadMod_FindByThreadIdx(const NuRecord* pRecord, NuThreadIdx threadIdx)
/* /*
* Search for an "add" ThreadMod, by threadID. * Search for an "add" ThreadMod, by threadID.
*/ */
NuError NuError Nu_ThreadModAdd_FindByThreadID(const NuRecord* pRecord,
Nu_ThreadModAdd_FindByThreadID(const NuRecord* pRecord, NuThreadID threadID, NuThreadID threadID, NuThreadMod** ppThreadMod)
NuThreadMod** ppThreadMod)
{ {
NuThreadMod* pThreadMod; NuThreadMod* pThreadMod;
@ -207,8 +202,7 @@ Nu_ThreadModAdd_FindByThreadID(const NuRecord* pRecord, NuThreadID threadID,
/* /*
* Free up the list of NuThreadMods in this record. * Free up the list of NuThreadMods in this record.
*/ */
void void Nu_FreeThreadMods(NuArchive* pArchive, NuRecord* pRecord)
Nu_FreeThreadMods(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuThreadMod* pThreadMod; NuThreadMod* pThreadMod;
NuThreadMod* pNext; NuThreadMod* pNext;
@ -246,9 +240,8 @@ typedef struct {
/* /*
* Allocate and initialize a NuNewThreads struct. * Allocate and initialize a NuNewThreads struct.
*/ */
static NuError static NuError Nu_NewThreads_New(NuArchive* pArchive,
Nu_NewThreads_New(NuArchive* pArchive, NuNewThreads** ppNewThreads, NuNewThreads** ppNewThreads, long numThreads)
long numThreads)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -256,7 +249,8 @@ Nu_NewThreads_New(NuArchive* pArchive, NuNewThreads** ppNewThreads,
BailAlloc(*ppNewThreads); BailAlloc(*ppNewThreads);
(*ppNewThreads)->numThreads = numThreads; (*ppNewThreads)->numThreads = numThreads;
(*ppNewThreads)->nextSlot = 0; (*ppNewThreads)->nextSlot = 0;
(*ppNewThreads)->pThreads = Nu_Malloc(pArchive, numThreads * sizeof(NuThread)); (*ppNewThreads)->pThreads =
Nu_Malloc(pArchive, numThreads * sizeof(NuThread));
BailAlloc((*ppNewThreads)->pThreads); BailAlloc((*ppNewThreads)->pThreads);
bail: bail:
@ -266,8 +260,7 @@ bail:
/* /*
* Free a NuNewThreads struct. * Free a NuNewThreads struct.
*/ */
static void static void Nu_NewThreads_Free(NuArchive* pArchive, NuNewThreads* pNewThreads)
Nu_NewThreads_Free(NuArchive* pArchive, NuNewThreads* pNewThreads)
{ {
if (pNewThreads != NULL) { if (pNewThreads != NULL) {
Nu_Free(pArchive, pNewThreads->pThreads); Nu_Free(pArchive, pNewThreads->pThreads);
@ -278,8 +271,7 @@ Nu_NewThreads_Free(NuArchive* pArchive, NuNewThreads* pNewThreads)
/* /*
* Returns true if "pNewThreads" has room for another entry, false otherwise. * Returns true if "pNewThreads" has room for another entry, false otherwise.
*/ */
static Boolean static Boolean Nu_NewThreads_HasRoom(const NuNewThreads* pNewThreads)
Nu_NewThreads_HasRoom(const NuNewThreads* pNewThreads)
{ {
if (pNewThreads->nextSlot < pNewThreads->numThreads) if (pNewThreads->nextSlot < pNewThreads->numThreads)
return true; return true;
@ -293,8 +285,8 @@ Nu_NewThreads_HasRoom(const NuNewThreads* pNewThreads)
* *
* The "next slot" marker is automatically advanced. * The "next slot" marker is automatically advanced.
*/ */
static NuThread* static NuThread* Nu_NewThreads_GetNext(NuNewThreads* pNewThreads,
Nu_NewThreads_GetNext(NuNewThreads* pNewThreads, NuArchive* pArchive) NuArchive* pArchive)
{ {
NuThread* pThread; NuThread* pThread;
@ -313,8 +305,7 @@ Nu_NewThreads_GetNext(NuNewThreads* pNewThreads, NuArchive* pArchive)
/* /*
* Return the #of threads we're meant to hold. * Return the #of threads we're meant to hold.
*/ */
static int static int Nu_NewThreads_GetNumThreads(const NuNewThreads* pNewThreads)
Nu_NewThreads_GetNumThreads(const NuNewThreads* pNewThreads)
{ {
Assert(pNewThreads != NULL); Assert(pNewThreads != NULL);
@ -324,8 +315,7 @@ Nu_NewThreads_GetNumThreads(const NuNewThreads* pNewThreads)
/* /*
* Total up the compressed EOFs of all threads. * Total up the compressed EOFs of all threads.
*/ */
static uint32_t static uint32_t Nu_NewThreads_TotalCompThreadEOF(NuNewThreads* pNewThreads)
Nu_NewThreads_TotalCompThreadEOF(NuNewThreads* pNewThreads)
{ {
uint32_t compThreadEOF; uint32_t compThreadEOF;
int i; int i;
@ -347,8 +337,7 @@ Nu_NewThreads_TotalCompThreadEOF(NuNewThreads* pNewThreads)
* to the thread array, and then nukes our copy of the pointer. This * to the thread array, and then nukes our copy of the pointer. This
* allows us to transfer ownership of the storage to the caller. * allows us to transfer ownership of the storage to the caller.
*/ */
static NuThread* static NuThread* Nu_NewThreads_DonateThreads(NuNewThreads* pNewThreads)
Nu_NewThreads_DonateThreads(NuNewThreads* pNewThreads)
{ {
NuThread* pThreads = pNewThreads->pThreads; NuThread* pThreads = pNewThreads->pThreads;
@ -369,8 +358,7 @@ Nu_NewThreads_DonateThreads(NuNewThreads* pNewThreads)
* *
* Pass in the record from the *copy* set, not the original. * Pass in the record from the *copy* set, not the original.
*/ */
static NuError static NuError Nu_CopyArchiveRecord(NuArchive* pArchive, NuRecord* pRecord)
Nu_CopyArchiveRecord(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
long offsetAdjust; long offsetAdjust;
@ -414,9 +402,8 @@ bail:
* *
* Returns -1 on error. * Returns -1 on error.
*/ */
static NuError static NuError Nu_CountEventualThreads(const NuRecord* pRecord,
Nu_CountEventualThreads(const NuRecord* pRecord, long* pTotalThreads, long* pTotalThreads, long* pFilenameThreads)
long* pFilenameThreads)
{ {
const NuThreadMod* pThreadMod; const NuThreadMod* pThreadMod;
const NuThread* pThread; const NuThread* pThread;
@ -497,8 +484,7 @@ Nu_CountEventualThreads(const NuRecord* pRecord, long* pTotalThreads,
* we ignore, are marked "used" during processing, so we don't need * we ignore, are marked "used" during processing, so we don't need
* to be terribly bright here. * to be terribly bright here.
*/ */
static Boolean static Boolean Nu_VerifyAllTouched(NuArchive* pArchive, const NuRecord* pRecord)
Nu_VerifyAllTouched(NuArchive* pArchive, const NuRecord* pRecord)
{ {
const NuThreadMod* pThreadMod; const NuThreadMod* pThreadMod;
const NuThread* pThread; const NuThread* pThread;
@ -538,8 +524,8 @@ Nu_VerifyAllTouched(NuArchive* pArchive, const NuRecord* pRecord)
* *
* "newName" must be allocated storage. * "newName" must be allocated storage.
*/ */
static void static void Nu_SetNewThreadFilename(NuArchive* pArchive, NuRecord* pRecord,
Nu_SetNewThreadFilename(NuArchive* pArchive, NuRecord* pRecord, char* newName) char* newName)
{ {
Assert(pRecord != NULL); Assert(pRecord != NULL);
Assert(newName != NULL); Assert(newName != NULL);
@ -556,8 +542,8 @@ Nu_SetNewThreadFilename(NuArchive* pArchive, NuRecord* pRecord, char* newName)
* appropriate values, we'll set them on their behalf, so long as * appropriate values, we'll set them on their behalf, so long as
* the uncompressed size is a multiple of 512. * the uncompressed size is a multiple of 512.
*/ */
static NuError static NuError Nu_UpdateDiskImageFields(NuArchive* pArchive, NuRecord* pRecord,
Nu_UpdateDiskImageFields(NuArchive* pArchive, NuRecord* pRecord, long sourceLen) long sourceLen)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
long actualLen; long actualLen;
@ -599,9 +585,8 @@ Nu_UpdateDiskImageFields(NuArchive* pArchive, NuRecord* pRecord, long sourceLen)
* *
* Possible side-effects on "pRecord": threadFilename may be updated. * Possible side-effects on "pRecord": threadFilename may be updated.
*/ */
static NuError static NuError Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp,
Nu_ConstructArchiveUpdate(NuArchive* pArchive, FILE* fp, NuRecord* pRecord, NuRecord* pRecord, NuThread* pThread, const NuThreadMod* pThreadMod)
NuThread* pThread, const NuThreadMod* pThreadMod)
{ {
NuError err; NuError err;
NuDataSource* pDataSource = NULL; NuDataSource* pDataSource = NULL;
@ -705,8 +690,7 @@ bail:
* Possible side-effects on "pRecord": disk image fields may be revised * Possible side-effects on "pRecord": disk image fields may be revised
* (storage type, extra type), and threadFilename may be updated. * (storage type, extra type), and threadFilename may be updated.
*/ */
static NuError static NuError Nu_HandleAddThreadMods(NuArchive* pArchive, NuRecord* pRecord,
Nu_HandleAddThreadMods(NuArchive* pArchive, NuRecord* pRecord,
NuThreadID threadID, Boolean doKeepFirstOnly, NuNewThreads* pNewThreads, NuThreadID threadID, Boolean doKeepFirstOnly, NuNewThreads* pNewThreads,
FILE* dstFp) FILE* dstFp)
{ {
@ -911,9 +895,9 @@ bail:
* *
* "pRecord" must be from the "copy" data set. * "pRecord" must be from the "copy" data set.
*/ */
static NuError static NuError Nu_ConstructArchiveThreads(NuArchive* pArchive,
Nu_ConstructArchiveThreads(NuArchive* pArchive, NuRecord* pRecord, NuRecord* pRecord, NuThreadID threadID, Boolean doKeepFirstOnly,
NuThreadID threadID, Boolean doKeepFirstOnly, NuNewThreads* pNewThreads) NuNewThreads* pNewThreads)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuThread* pThread; NuThread* pThread;
@ -1056,8 +1040,7 @@ bail:
* kNuErrSkipped, which should cause the caller to simply copy the * kNuErrSkipped, which should cause the caller to simply copy the
* previous record. * previous record.
*/ */
static NuError static NuError Nu_ConstructArchiveRecord(NuArchive* pArchive, NuRecord* pRecord)
Nu_ConstructArchiveRecord(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuError err; NuError err;
NuNewThreads* pNewThreads = NULL; NuNewThreads* pNewThreads = NULL;
@ -1261,8 +1244,8 @@ bail:
* not the entire operation, we rewind the temp file to the initial * not the entire operation, we rewind the temp file to the initial
* position and return kNuErrSkipped. * position and return kNuErrSkipped.
*/ */
static NuError static NuError Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord,
Nu_ConstructNewRecord(NuArchive* pArchive, NuRecord* pRecord, FILE* fp) FILE* fp)
{ {
NuError err; NuError err;
NuNewThreads* pNewThreads = NULL; NuNewThreads* pNewThreads = NULL;
@ -1490,8 +1473,7 @@ bail:
* The position of pArchive->archiveFp on entry and on exit is not * The position of pArchive->archiveFp on entry and on exit is not
* defined. * defined.
*/ */
static NuError static NuError Nu_UpdateRecordInOriginal(NuArchive* pArchive, NuRecord* pRecord)
Nu_UpdateRecordInOriginal(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuThread* pThread; NuThread* pThread;
@ -1583,8 +1565,7 @@ bail:
* *
* On exit, pArchive->tmpFp will point at the archive EOF. * On exit, pArchive->tmpFp will point at the archive EOF.
*/ */
static NuError static NuError Nu_CreateTempFromOriginal(NuArchive* pArchive)
Nu_CreateTempFromOriginal(NuArchive* pArchive)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -1671,8 +1652,7 @@ bail:
* *
* On exit, pArchive->archiveFp will point at the archive EOF. * On exit, pArchive->archiveFp will point at the archive EOF.
*/ */
static NuError static NuError Nu_UpdateInOriginal(NuArchive* pArchive)
Nu_UpdateInOriginal(NuArchive* pArchive)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -1717,8 +1697,7 @@ bail:
* *
* On completion, "fp" will point at the end of the archive. * On completion, "fp" will point at the end of the archive.
*/ */
static NuError static NuError Nu_CreateNewRecords(NuArchive* pArchive, FILE* fp)
Nu_CreateNewRecords(NuArchive* pArchive, FILE* fp)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -1770,8 +1749,7 @@ bail:
* At present, a "dirtyHeader" flag is not of itself cause to rebuild * At present, a "dirtyHeader" flag is not of itself cause to rebuild
* the archive, so we don't test for it here. * the archive, so we don't test for it here.
*/ */
static Boolean static Boolean Nu_NoHeavyUpdates(NuArchive* pArchive)
Nu_NoHeavyUpdates(NuArchive* pArchive)
{ {
const NuRecord* pRecord; const NuRecord* pRecord;
long count; long count;
@ -1828,8 +1806,8 @@ Nu_NoHeavyUpdates(NuArchive* pArchive)
* it from the number of threads, skipping on if the record has any * it from the number of threads, skipping on if the record has any
* "add" thread mods. * "add" thread mods.
*/ */
static NuError static NuError Nu_PurgeEmptyRecords(NuArchive* pArchive,
Nu_PurgeEmptyRecords(NuArchive* pArchive, NuRecordSet* pRecordSet) NuRecordSet* pRecordSet)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -1873,8 +1851,8 @@ bail:
* Pass in a correctly positioned "fp" and the total length of the archive * Pass in a correctly positioned "fp" and the total length of the archive
* file. * file.
*/ */
static NuError static NuError Nu_UpdateMasterHeader(NuArchive* pArchive, FILE* fp,
Nu_UpdateMasterHeader(NuArchive* pArchive, FILE* fp, long archiveEOF) long archiveEOF)
{ {
NuError err; NuError err;
long numRecords; long numRecords;
@ -1914,8 +1892,7 @@ bail:
/* /*
* Reset the temp file to a known (empty) state. * Reset the temp file to a known (empty) state.
*/ */
static NuError static NuError Nu_ResetTempFile(NuArchive* pArchive)
Nu_ResetTempFile(NuArchive* pArchive)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1984,8 +1961,7 @@ bail:
* don't even exist. This is done as we are cleaning up the record sets * don't even exist. This is done as we are cleaning up the record sets
* after a successful (or aborted) update. * after a successful (or aborted) update.
*/ */
static NuError static NuError Nu_RecordResetUsedFlags(NuArchive* pArchive, NuRecord* pRecord)
Nu_RecordResetUsedFlags(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuThread* pThread; NuThread* pThread;
long idx; long idx;
@ -2016,8 +1992,7 @@ Nu_RecordResetUsedFlags(NuArchive* pArchive, NuRecord* pRecord)
/* /*
* Invoke Nu_RecordResetUsedFlags on all records in a record set. * Invoke Nu_RecordResetUsedFlags on all records in a record set.
*/ */
static NuError static NuError Nu_ResetUsedFlags(NuArchive* pArchive, NuRecordSet* pRecordSet)
Nu_ResetUsedFlags(NuArchive* pArchive, NuRecordSet* pRecordSet)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -2040,8 +2015,7 @@ Nu_ResetUsedFlags(NuArchive* pArchive, NuRecordSet* pRecordSet)
/* /*
* If nothing in the "copy" set has actually been disturbed, throw it out. * If nothing in the "copy" set has actually been disturbed, throw it out.
*/ */
static void static void Nu_ResetCopySetIfUntouched(NuArchive* pArchive)
Nu_ResetCopySetIfUntouched(NuArchive* pArchive)
{ {
const NuRecord* pRecord; const NuRecord* pRecord;
@ -2071,8 +2045,7 @@ Nu_ResetCopySetIfUntouched(NuArchive* pArchive)
* GSHK always adds a comment to the first new record added to an archive. * GSHK always adds a comment to the first new record added to an archive.
* Imitate this behavior. * Imitate this behavior.
*/ */
static NuError static NuError Nu_AddCommentToFirstNewRecord(NuArchive* pArchive)
Nu_AddCommentToFirstNewRecord(NuArchive* pArchive)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -2137,8 +2110,7 @@ bail:
* If the things this function is doing aren't making any sense at all, * If the things this function is doing aren't making any sense at all,
* read "NOTES.txt" for an introduction. * read "NOTES.txt" for an introduction.
*/ */
NuError NuError Nu_Flush(NuArchive* pArchive, long* pStatusFlags)
Nu_Flush(NuArchive* pArchive, long* pStatusFlags)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Boolean canAbort = true; Boolean canAbort = true;
@ -2555,8 +2527,7 @@ bail:
/* /*
* Abort any pending changes. * Abort any pending changes.
*/ */
NuError NuError Nu_Abort(NuArchive* pArchive)
Nu_Abort(NuArchive* pArchive)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);

View File

@ -25,13 +25,11 @@
/* /*
* Alloc and free functions provided to zlib. * Alloc and free functions provided to zlib.
*/ */
static voidpf static voidpf Nu_zalloc(voidpf opaque, uInt items, uInt size)
Nu_zalloc(voidpf opaque, uInt items, uInt size)
{ {
return Nu_Malloc(opaque, items * size); return Nu_Malloc(opaque, items * size);
} }
static void static void Nu_zfree(voidpf opaque, voidpf address)
Nu_zfree(voidpf opaque, voidpf address)
{ {
Nu_Free(opaque, address); Nu_Free(opaque, address);
} }
@ -46,8 +44,7 @@ Nu_zfree(voidpf opaque, voidpf address)
/* /*
* Compress "srcLen" bytes from "pStraw" to "fp". * Compress "srcLen" bytes from "pStraw" to "fp".
*/ */
NuError NuError Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressDeflate(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -174,8 +171,7 @@ bail:
/* /*
* Expand from "infp" to "pFunnel". * Expand from "infp" to "pFunnel".
*/ */
NuError NuError Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord,
Nu_ExpandDeflate(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc) const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;

View File

@ -24,8 +24,7 @@
* it does not follow all sorts of crazy semaphore semantics. If you * it does not follow all sorts of crazy semaphore semantics. If you
* have the need, go ahead and fix it. * have the need, go ahead and fix it.
*/ */
static inline void static inline void Nu_SetBusy(NuArchive* pArchive)
Nu_SetBusy(NuArchive* pArchive)
{ {
pArchive->busy = true; pArchive->busy = true;
} }
@ -33,8 +32,7 @@ Nu_SetBusy(NuArchive* pArchive)
/* /*
* Clear the busy flag. * Clear the busy flag.
*/ */
static inline void static inline void Nu_ClearBusy(NuArchive* pArchive)
Nu_ClearBusy(NuArchive* pArchive)
{ {
pArchive->busy = false; pArchive->busy = false;
} }
@ -45,8 +43,7 @@ Nu_ClearBusy(NuArchive* pArchive)
* can be made during callback functions when the archive isn't fully * can be made during callback functions when the archive isn't fully
* consistent. * consistent.
*/ */
static NuError static NuError Nu_PartiallyValidateNuArchive(const NuArchive* pArchive)
Nu_PartiallyValidateNuArchive(const NuArchive* pArchive)
{ {
if (pArchive == NULL) if (pArchive == NULL)
return kNuErrInvalidArg; return kNuErrInvalidArg;
@ -61,8 +58,7 @@ Nu_PartiallyValidateNuArchive(const NuArchive* pArchive)
/* /*
* Validate the NuArchive* argument passed in to us. * Validate the NuArchive* argument passed in to us.
*/ */
static NuError static NuError Nu_ValidateNuArchive(const NuArchive* pArchive)
Nu_ValidateNuArchive(const NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -104,8 +100,7 @@ Nu_ValidateNuArchive(const NuArchive* pArchive)
* =========================================================================== * ===========================================================================
*/ */
NUFXLIB_API NuError NUFXLIB_API NuError NuStreamOpenRO(FILE* infp, NuArchive** ppArchive)
NuStreamOpenRO(FILE* infp, NuArchive** ppArchive)
{ {
NuError err; NuError err;
@ -117,8 +112,7 @@ NuStreamOpenRO(FILE* infp, NuArchive** ppArchive)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuContents(NuArchive* pArchive, NuCallback contentFunc)
NuContents(NuArchive* pArchive, NuCallback contentFunc)
{ {
NuError err; NuError err;
@ -134,8 +128,7 @@ NuContents(NuArchive* pArchive, NuCallback contentFunc)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuExtract(NuArchive* pArchive)
NuExtract(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -151,8 +144,7 @@ NuExtract(NuArchive* pArchive)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuTest(NuArchive* pArchive)
NuTest(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -168,8 +160,7 @@ NuTest(NuArchive* pArchive)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuTestRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
NuTestRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
{ {
NuError err; NuError err;
@ -189,8 +180,7 @@ NuTestRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
* =========================================================================== * ===========================================================================
*/ */
NUFXLIB_API NuError NUFXLIB_API NuError NuOpenRO(const char* filename, NuArchive** ppArchive)
NuOpenRO(const char* filename, NuArchive** ppArchive)
{ {
NuError err; NuError err;
@ -199,8 +189,7 @@ NuOpenRO(const char* filename, NuArchive** ppArchive)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuExtractRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
NuExtractRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
{ {
NuError err; NuError err;
@ -213,8 +202,7 @@ NuExtractRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuExtractThread(NuArchive* pArchive, NuThreadIdx threadIdx,
NuExtractThread(NuArchive* pArchive, NuThreadIdx threadIdx,
NuDataSink* pDataSink) NuDataSink* pDataSink)
{ {
NuError err; NuError err;
@ -228,8 +216,7 @@ NuExtractThread(NuArchive* pArchive, NuThreadIdx threadIdx,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuGetRecord(NuArchive* pArchive, NuRecordIdx recordIdx,
NuGetRecord(NuArchive* pArchive, NuRecordIdx recordIdx,
const NuRecord** ppRecord) const NuRecord** ppRecord)
{ {
NuError err; NuError err;
@ -243,8 +230,7 @@ NuGetRecord(NuArchive* pArchive, NuRecordIdx recordIdx,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuGetRecordIdxByName(NuArchive* pArchive, const char* name,
NuGetRecordIdxByName(NuArchive* pArchive, const char* name,
NuRecordIdx* pRecordIdx) NuRecordIdx* pRecordIdx)
{ {
NuError err; NuError err;
@ -258,8 +244,7 @@ NuGetRecordIdxByName(NuArchive* pArchive, const char* name,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuGetRecordIdxByPosition(NuArchive* pArchive, uint32_t position,
NuGetRecordIdxByPosition(NuArchive* pArchive, uint32_t position,
NuRecordIdx* pRecordIdx) NuRecordIdx* pRecordIdx)
{ {
NuError err; NuError err;
@ -280,9 +265,8 @@ NuGetRecordIdxByPosition(NuArchive* pArchive, uint32_t position,
* =========================================================================== * ===========================================================================
*/ */
NUFXLIB_API NuError NUFXLIB_API NuError NuOpenRW(const char* archivePathname,
NuOpenRW(const char* archivePathname, const char* tmpPathname, const char* tmpPathname, uint32_t flags, NuArchive** ppArchive)
uint32_t flags, NuArchive** ppArchive)
{ {
NuError err; NuError err;
@ -292,8 +276,7 @@ NuOpenRW(const char* archivePathname, const char* tmpPathname,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuFlush(NuArchive* pArchive, long* pStatusFlags)
NuFlush(NuArchive* pArchive, long* pStatusFlags)
{ {
NuError err; NuError err;
@ -306,8 +289,7 @@ NuFlush(NuArchive* pArchive, long* pStatusFlags)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuAbort(NuArchive* pArchive)
NuAbort(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -320,9 +302,8 @@ NuAbort(NuArchive* pArchive)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuAddRecord(NuArchive* pArchive,
NuAddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails, const NuFileDetails* pFileDetails, NuRecordIdx* pRecordIdx)
NuRecordIdx* pRecordIdx)
{ {
NuError err; NuError err;
@ -335,9 +316,8 @@ NuAddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuAddThread(NuArchive* pArchive, NuRecordIdx recordIdx,
NuAddThread(NuArchive* pArchive, NuRecordIdx recordIdx, NuThreadID threadID, NuThreadID threadID, NuDataSource* pDataSource, NuThreadIdx* pThreadIdx)
NuDataSource* pDataSource, NuThreadIdx* pThreadIdx)
{ {
NuError err; NuError err;
@ -351,8 +331,7 @@ NuAddThread(NuArchive* pArchive, NuRecordIdx recordIdx, NuThreadID threadID,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuAddFile(NuArchive* pArchive, const char* pathname,
NuAddFile(NuArchive* pArchive, const char* pathname,
const NuFileDetails* pFileDetails, short isFromRsrcFork, const NuFileDetails* pFileDetails, short isFromRsrcFork,
NuRecordIdx* pRecordIdx) NuRecordIdx* pRecordIdx)
{ {
@ -368,9 +347,8 @@ NuAddFile(NuArchive* pArchive, const char* pathname,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuRename(NuArchive* pArchive, NuRecordIdx recordIdx,
NuRename(NuArchive* pArchive, NuRecordIdx recordIdx, const char* pathname, const char* pathname, char fssep)
char fssep)
{ {
NuError err; NuError err;
@ -384,8 +362,7 @@ NuRename(NuArchive* pArchive, NuRecordIdx recordIdx, const char* pathname,
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuSetRecordAttr(NuArchive* pArchive, NuRecordIdx recordIdx,
NuSetRecordAttr(NuArchive* pArchive, NuRecordIdx recordIdx,
const NuRecordAttr* pRecordAttr) const NuRecordAttr* pRecordAttr)
{ {
NuError err; NuError err;
@ -399,9 +376,8 @@ NuSetRecordAttr(NuArchive* pArchive, NuRecordIdx recordIdx,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuUpdatePresizedThread(NuArchive* pArchive,
NuUpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx, NuThreadIdx threadIdx, NuDataSource* pDataSource, long* pMaxLen)
NuDataSource* pDataSource, long* pMaxLen)
{ {
NuError err; NuError err;
@ -415,8 +391,7 @@ NuUpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx,
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuDelete(NuArchive* pArchive)
NuDelete(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -429,8 +404,7 @@ NuDelete(NuArchive* pArchive)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuDeleteRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
NuDeleteRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
{ {
NuError err; NuError err;
@ -443,8 +417,7 @@ NuDeleteRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuDeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx)
NuDeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx)
{ {
NuError err; NuError err;
@ -464,8 +437,7 @@ NuDeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx)
* =========================================================================== * ===========================================================================
*/ */
NUFXLIB_API NuError NUFXLIB_API NuError NuClose(NuArchive* pArchive)
NuClose(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -480,8 +452,8 @@ NuClose(NuArchive* pArchive)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuGetMasterHeader(NuArchive* pArchive,
NuGetMasterHeader(NuArchive* pArchive, const NuMasterHeader** ppMasterHeader) const NuMasterHeader** ppMasterHeader)
{ {
NuError err; NuError err;
@ -491,8 +463,7 @@ NuGetMasterHeader(NuArchive* pArchive, const NuMasterHeader** ppMasterHeader)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuGetExtraData(NuArchive* pArchive, void** ppData)
NuGetExtraData(NuArchive* pArchive, void** ppData)
{ {
NuError err; NuError err;
@ -504,8 +475,7 @@ NuGetExtraData(NuArchive* pArchive, void** ppData)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuSetExtraData(NuArchive* pArchive, void* pData)
NuSetExtraData(NuArchive* pArchive, void* pData)
{ {
NuError err; NuError err;
@ -515,8 +485,8 @@ NuSetExtraData(NuArchive* pArchive, void* pData)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuGetValue(NuArchive* pArchive, NuValueID ident,
NuGetValue(NuArchive* pArchive, NuValueID ident, NuValue* pValue) NuValue* pValue)
{ {
NuError err; NuError err;
@ -526,8 +496,8 @@ NuGetValue(NuArchive* pArchive, NuValueID ident, NuValue* pValue)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuSetValue(NuArchive* pArchive, NuValueID ident,
NuSetValue(NuArchive* pArchive, NuValueID ident, NuValue value) NuValue value)
{ {
NuError err; NuError err;
@ -537,8 +507,8 @@ NuSetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuGetAttr(NuArchive* pArchive, NuAttrID ident,
NuGetAttr(NuArchive* pArchive, NuAttrID ident, NuAttr* pAttr) NuAttr* pAttr)
{ {
NuError err; NuError err;
@ -548,8 +518,7 @@ NuGetAttr(NuArchive* pArchive, NuAttrID ident, NuAttr* pAttr)
return err; return err;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuDebugDumpArchive(NuArchive* pArchive)
NuDebugDumpArchive(NuArchive* pArchive)
{ {
#if defined(DEBUG_MSGS) #if defined(DEBUG_MSGS)
/* skip validation checks for this one */ /* skip validation checks for this one */
@ -568,8 +537,7 @@ NuDebugDumpArchive(NuArchive* pArchive)
* =========================================================================== * ===========================================================================
*/ */
NUFXLIB_API NuError NUFXLIB_API NuError NuCreateDataSourceForFile(NuThreadFormat threadFormat,
NuCreateDataSourceForFile(NuThreadFormat threadFormat,
uint32_t otherLen, const char* pathname, short isFromRsrcFork, uint32_t otherLen, const char* pathname, short isFromRsrcFork,
NuDataSource** ppDataSource) NuDataSource** ppDataSource)
{ {
@ -577,8 +545,7 @@ NuCreateDataSourceForFile(NuThreadFormat threadFormat,
pathname, (Boolean)(isFromRsrcFork != 0), ppDataSource); pathname, (Boolean)(isFromRsrcFork != 0), ppDataSource);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuCreateDataSourceForFP(NuThreadFormat threadFormat,
NuCreateDataSourceForFP(NuThreadFormat threadFormat,
uint32_t otherLen, FILE* fp, long offset, long length, uint32_t otherLen, FILE* fp, long offset, long length,
NuCallback fcloseFunc, NuDataSource** ppDataSource) NuCallback fcloseFunc, NuDataSource** ppDataSource)
{ {
@ -586,8 +553,7 @@ NuCreateDataSourceForFP(NuThreadFormat threadFormat,
fp, offset, length, fcloseFunc, ppDataSource); fp, offset, length, fcloseFunc, ppDataSource);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuCreateDataSourceForBuffer(NuThreadFormat threadFormat,
NuCreateDataSourceForBuffer(NuThreadFormat threadFormat,
uint32_t otherLen, const uint8_t* buffer, long offset, uint32_t otherLen, const uint8_t* buffer, long offset,
long length, NuCallback freeFunc, NuDataSource** ppDataSource) long length, NuCallback freeFunc, NuDataSource** ppDataSource)
{ {
@ -595,14 +561,13 @@ NuCreateDataSourceForBuffer(NuThreadFormat threadFormat,
buffer, offset, length, freeFunc, ppDataSource); buffer, offset, length, freeFunc, ppDataSource);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuFreeDataSource(NuDataSource* pDataSource)
NuFreeDataSource(NuDataSource* pDataSource)
{ {
return Nu_DataSourceFree(pDataSource); return Nu_DataSourceFree(pDataSource);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuDataSourceSetRawCrc(NuDataSource* pDataSource,
NuDataSourceSetRawCrc(NuDataSource* pDataSource, uint16_t crc) uint16_t crc)
{ {
if (pDataSource == NULL) if (pDataSource == NULL)
return kNuErrInvalidArg; return kNuErrInvalidArg;
@ -610,38 +575,35 @@ NuDataSourceSetRawCrc(NuDataSource* pDataSource, uint16_t crc)
return kNuErrNone; return kNuErrNone;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuCreateDataSinkForFile(short doExpand, NuValue convertEOL,
NuCreateDataSinkForFile(short doExpand, NuValue convertEOL,
const char* pathname, char fssep, NuDataSink** ppDataSink) const char* pathname, char fssep, NuDataSink** ppDataSink)
{ {
return Nu_DataSinkFile_New((Boolean)(doExpand != 0), convertEOL, pathname, return Nu_DataSinkFile_New((Boolean)(doExpand != 0), convertEOL, pathname,
fssep, ppDataSink); fssep, ppDataSink);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuCreateDataSinkForFP(short doExpand, NuValue convertEOL,
NuCreateDataSinkForFP(short doExpand, NuValue convertEOL, FILE* fp, FILE* fp, NuDataSink** ppDataSink)
NuDataSink** ppDataSink)
{ {
return Nu_DataSinkFP_New((Boolean)(doExpand != 0), convertEOL, fp, return Nu_DataSinkFP_New((Boolean)(doExpand != 0), convertEOL, fp,
ppDataSink); ppDataSink);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuCreateDataSinkForBuffer(short doExpand,
NuCreateDataSinkForBuffer(short doExpand, NuValue convertEOL, NuValue convertEOL, uint8_t* buffer, uint32_t bufLen,
uint8_t* buffer, uint32_t bufLen, NuDataSink** ppDataSink) NuDataSink** ppDataSink)
{ {
return Nu_DataSinkBuffer_New((Boolean)(doExpand != 0), convertEOL, buffer, return Nu_DataSinkBuffer_New((Boolean)(doExpand != 0), convertEOL, buffer,
bufLen, ppDataSink); bufLen, ppDataSink);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuFreeDataSink(NuDataSink* pDataSink)
NuFreeDataSink(NuDataSink* pDataSink)
{ {
return Nu_DataSinkFree(pDataSink); return Nu_DataSinkFree(pDataSink);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuDataSinkGetOutCount(NuDataSink* pDataSink,
NuDataSinkGetOutCount(NuDataSink* pDataSink, uint32_t* pOutCount) uint32_t* pOutCount)
{ {
if (pDataSink == NULL || pOutCount == NULL) if (pDataSink == NULL || pOutCount == NULL)
return kNuErrInvalidArg; return kNuErrInvalidArg;
@ -657,22 +619,19 @@ NuDataSinkGetOutCount(NuDataSink* pDataSink, uint32_t* pOutCount)
* =========================================================================== * ===========================================================================
*/ */
NUFXLIB_API const char* NUFXLIB_API const char* NuStrError(NuError err)
NuStrError(NuError err)
{ {
return Nu_StrError(err); return Nu_StrError(err);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuGetVersion(long* pMajorVersion, long* pMinorVersion,
NuGetVersion(long* pMajorVersion, long* pMinorVersion, long* pBugVersion, long* pBugVersion, const char** ppBuildDate, const char** ppBuildFlags)
const char** ppBuildDate, const char** ppBuildFlags)
{ {
return Nu_GetVersion(pMajorVersion, pMinorVersion, pBugVersion, return Nu_GetVersion(pMajorVersion, pMinorVersion, pBugVersion,
ppBuildDate, ppBuildFlags); ppBuildDate, ppBuildFlags);
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuTestFeature(NuFeature feature)
NuTestFeature(NuFeature feature)
{ {
NuError err = kNuErrUnsupFeature; NuError err = kNuErrUnsupFeature;
@ -710,8 +669,8 @@ NuTestFeature(NuFeature feature)
return err; return err;
} }
NUFXLIB_API void NUFXLIB_API void NuRecordCopyAttr(NuRecordAttr* pRecordAttr,
NuRecordCopyAttr(NuRecordAttr* pRecordAttr, const NuRecord* pRecord) const NuRecord* pRecord)
{ {
pRecordAttr->fileSysID = pRecord->recFileSysID; pRecordAttr->fileSysID = pRecord->recFileSysID;
/*pRecordAttr->fileSysInfo = pRecord->recFileSysInfo;*/ /*pRecordAttr->fileSysInfo = pRecord->recFileSysInfo;*/
@ -723,8 +682,8 @@ NuRecordCopyAttr(NuRecordAttr* pRecordAttr, const NuRecord* pRecord)
pRecordAttr->archiveWhen = pRecord->recArchiveWhen; pRecordAttr->archiveWhen = pRecord->recArchiveWhen;
} }
NUFXLIB_API NuError NUFXLIB_API NuError NuRecordCopyThreads(const NuRecord* pNuRecord,
NuRecordCopyThreads(const NuRecord* pNuRecord, NuThread** ppThreads) NuThread** ppThreads)
{ {
if (pNuRecord == NULL || ppThreads == NULL) if (pNuRecord == NULL || ppThreads == NULL)
return kNuErrInvalidArg; return kNuErrInvalidArg;
@ -741,8 +700,7 @@ NuRecordCopyThreads(const NuRecord* pNuRecord, NuThread** ppThreads)
return kNuErrNone; return kNuErrNone;
} }
NUFXLIB_API uint32_t NUFXLIB_API uint32_t NuRecordGetNumThreads(const NuRecord* pNuRecord)
NuRecordGetNumThreads(const NuRecord* pNuRecord)
{ {
if (pNuRecord == NULL) if (pNuRecord == NULL)
return -1; return -1;
@ -750,16 +708,15 @@ NuRecordGetNumThreads(const NuRecord* pNuRecord)
return pNuRecord->recTotalThreads; return pNuRecord->recTotalThreads;
} }
NUFXLIB_API const NuThread* NUFXLIB_API const NuThread* NuThreadGetByIdx(const NuThread* pNuThread,
NuThreadGetByIdx(const NuThread* pNuThread, long idx) long idx)
{ {
if (pNuThread == NULL) if (pNuThread == NULL)
return NULL; return NULL;
return &pNuThread[idx]; /* can't range-check here */ return &pNuThread[idx]; /* can't range-check here */
} }
NUFXLIB_API short NUFXLIB_API short NuIsPresizedThreadID(NuThreadID threadID)
NuIsPresizedThreadID(NuThreadID threadID)
{ {
return Nu_IsPresizedThreadID(threadID); return Nu_IsPresizedThreadID(threadID);
} }
@ -771,8 +728,8 @@ NuIsPresizedThreadID(NuThreadID threadID)
* =========================================================================== * ===========================================================================
*/ */
NUFXLIB_API NuCallback NUFXLIB_API NuCallback NuSetSelectionFilter(NuArchive* pArchive,
NuSetSelectionFilter(NuArchive* pArchive, NuCallback filterFunc) NuCallback filterFunc)
{ {
NuError err; NuError err;
NuCallback oldFunc = kNuInvalidCallback; NuCallback oldFunc = kNuInvalidCallback;
@ -787,8 +744,8 @@ NuSetSelectionFilter(NuArchive* pArchive, NuCallback filterFunc)
return oldFunc; return oldFunc;
} }
NUFXLIB_API NuCallback NUFXLIB_API NuCallback NuSetOutputPathnameFilter(NuArchive* pArchive,
NuSetOutputPathnameFilter(NuArchive* pArchive, NuCallback filterFunc) NuCallback filterFunc)
{ {
NuError err; NuError err;
NuCallback oldFunc = kNuInvalidCallback; NuCallback oldFunc = kNuInvalidCallback;
@ -803,8 +760,8 @@ NuSetOutputPathnameFilter(NuArchive* pArchive, NuCallback filterFunc)
return oldFunc; return oldFunc;
} }
NUFXLIB_API NuCallback NUFXLIB_API NuCallback NuSetProgressUpdater(NuArchive* pArchive,
NuSetProgressUpdater(NuArchive* pArchive, NuCallback updateFunc) NuCallback updateFunc)
{ {
NuError err; NuError err;
NuCallback oldFunc = kNuInvalidCallback; NuCallback oldFunc = kNuInvalidCallback;
@ -819,8 +776,8 @@ NuSetProgressUpdater(NuArchive* pArchive, NuCallback updateFunc)
return oldFunc; return oldFunc;
} }
NUFXLIB_API NuCallback NUFXLIB_API NuCallback NuSetErrorHandler(NuArchive* pArchive,
NuSetErrorHandler(NuArchive* pArchive, NuCallback errorFunc) NuCallback errorFunc)
{ {
NuError err; NuError err;
NuCallback oldFunc = kNuInvalidCallback; NuCallback oldFunc = kNuInvalidCallback;
@ -835,8 +792,8 @@ NuSetErrorHandler(NuArchive* pArchive, NuCallback errorFunc)
return oldFunc; return oldFunc;
} }
NUFXLIB_API NuCallback NUFXLIB_API NuCallback NuSetErrorMessageHandler(NuArchive* pArchive,
NuSetErrorMessageHandler(NuArchive* pArchive, NuCallback messageHandlerFunc) NuCallback messageHandlerFunc)
{ {
NuError err; NuError err;
NuCallback oldFunc = kNuInvalidCallback; NuCallback oldFunc = kNuInvalidCallback;
@ -851,8 +808,7 @@ NuSetErrorMessageHandler(NuArchive* pArchive, NuCallback messageHandlerFunc)
return oldFunc; return oldFunc;
} }
NUFXLIB_API NuCallback NUFXLIB_API NuCallback NuSetGlobalErrorMessageHandler(NuCallback messageHandlerFunc)
NuSetGlobalErrorMessageHandler(NuCallback messageHandlerFunc)
{ {
NuCallback oldFunc = kNuInvalidCallback; NuCallback oldFunc = kNuInvalidCallback;
/*Assert(!((uint32_t)messageHandlerFunc % 4));*/ /*Assert(!((uint32_t)messageHandlerFunc % 4));*/

View File

@ -12,9 +12,9 @@
/* /*
* "Expand" an uncompressed thread. * "Expand" an uncompressed thread.
*/ */
static NuError static NuError Nu_ExpandUncompressed(NuArchive* pArchive,
Nu_ExpandUncompressed(NuArchive* pArchive, const NuRecord* pRecord, const NuRecord* pRecord, const NuThread* pThread, FILE* infp,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc) NuFunnel* pFunnel, uint16_t* pCrc)
{ {
NuError err; NuError err;
/*uint8_t* buffer = NULL;*/ /*uint8_t* buffer = NULL;*/
@ -63,9 +63,8 @@ bail:
* Copy the "raw" data out of the thread. Unlike the preceeding function, * Copy the "raw" data out of the thread. Unlike the preceeding function,
* this reads up to "thCompThreadEOF", and doesn't even try to compute a CRC. * this reads up to "thCompThreadEOF", and doesn't even try to compute a CRC.
*/ */
static NuError static NuError Nu_ExpandRaw(NuArchive* pArchive, const NuThread* pThread,
Nu_ExpandRaw(NuArchive* pArchive, const NuThread* pThread, FILE* infp, FILE* infp, NuFunnel* pFunnel)
NuFunnel* pFunnel)
{ {
NuError err; NuError err;
/*uint8_t* buffer = NULL;*/ /*uint8_t* buffer = NULL;*/
@ -108,8 +107,7 @@ bail:
* Expand a thread from "infp" to "pFunnel", using the compression * Expand a thread from "infp" to "pFunnel", using the compression
* and stream length specified by "pThread". * and stream length specified by "pThread".
*/ */
NuError NuError Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord,
Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel) const NuThread* pThread, FILE* infp, NuFunnel* pFunnel)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;

View File

@ -81,8 +81,7 @@
* *
* If the conversion is invalid, "*pWhen" is set to zero. * If the conversion is invalid, "*pWhen" is set to zero.
*/ */
static void static void Nu_DateTimeToGMTSeconds(const NuDateTime* pDateTime, time_t* pWhen)
Nu_DateTimeToGMTSeconds(const NuDateTime* pDateTime, time_t* pWhen)
{ {
struct tm tmbuf; struct tm tmbuf;
time_t when; time_t when;
@ -119,8 +118,7 @@ Nu_DateTimeToGMTSeconds(const NuDateTime* pDateTime, time_t* pWhen)
/* /*
* Convert from GMT seconds since 1970 to local time in a NuDateTime struct. * Convert from GMT seconds since 1970 to local time in a NuDateTime struct.
*/ */
static void static void Nu_GMTSecondsToDateTime(const time_t* pWhen, NuDateTime *pDateTime)
Nu_GMTSecondsToDateTime(const time_t* pWhen, NuDateTime *pDateTime)
{ {
struct tm* ptm; struct tm* ptm;
@ -149,8 +147,7 @@ Nu_GMTSecondsToDateTime(const time_t* pWhen, NuDateTime *pDateTime)
/* /*
* Fill in the current time. * Fill in the current time.
*/ */
void void Nu_SetCurrentDateTime(NuDateTime* pDateTime)
Nu_SetCurrentDateTime(NuDateTime* pDateTime)
{ {
Assert(pDateTime != NULL); Assert(pDateTime != NULL);
@ -173,8 +170,7 @@ Nu_SetCurrentDateTime(NuDateTime* pDateTime)
* to time in seconds, and compare them that way. However, I don't want * to time in seconds, and compare them that way. However, I don't want
* to rely on that function too heavily, so we just compare fields. * to rely on that function too heavily, so we just compare fields.
*/ */
Boolean Boolean Nu_IsOlder(const NuDateTime* pWhen1, const NuDateTime* pWhen2)
Nu_IsOlder(const NuDateTime* pWhen1, const NuDateTime* pWhen2)
{ {
long result, year1, year2; long result, year1, year2;
@ -235,8 +231,7 @@ typedef struct NuFileInfo {
/* /*
* Determine whether the record has both data and resource forks. * Determine whether the record has both data and resource forks.
*/ */
static Boolean static Boolean Nu_IsForkedFile(NuArchive* pArchive, const NuRecord* pRecord)
Nu_IsForkedFile(NuArchive* pArchive, const NuRecord* pRecord)
{ {
const NuThread* pThread; const NuThread* pThread;
NuThreadID threadID; NuThreadID threadID;
@ -267,8 +262,7 @@ Nu_IsForkedFile(NuArchive* pArchive, const NuRecord* pRecord)
* Get the file info into a NuFileInfo struct. Fields which are * Get the file info into a NuFileInfo struct. Fields which are
* inappropriate for the current system are set to default values. * inappropriate for the current system are set to default values.
*/ */
static NuError static NuError Nu_GetFileInfo(NuArchive* pArchive, const char* pathname,
Nu_GetFileInfo(NuArchive* pArchive, const char* pathname,
NuFileInfo* pFileInfo) NuFileInfo* pFileInfo)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -417,8 +411,7 @@ bail:
* file with data and resource forks, we only claim it exists if it has * file with data and resource forks, we only claim it exists if it has
* nonzero length. * nonzero length.
*/ */
static NuError static NuError Nu_FileForkExists(NuArchive* pArchive, const char* pathname,
Nu_FileForkExists(NuArchive* pArchive, const char* pathname,
Boolean isForkedFile, Boolean checkRsrcFork, Boolean* pExists, Boolean isForkedFile, Boolean checkRsrcFork, Boolean* pExists,
NuFileInfo* pFileInfo) NuFileInfo* pFileInfo)
{ {
@ -509,8 +502,7 @@ Nu_FileForkExists(NuArchive* pArchive, const char* pathname,
/* /*
* Set the dates on a file according to what's in the record. * Set the dates on a file according to what's in the record.
*/ */
static NuError static NuError Nu_SetFileDates(NuArchive* pArchive, const NuRecord* pRecord,
Nu_SetFileDates(NuArchive* pArchive, const NuRecord* pRecord,
const char* pathname) const char* pathname)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -563,8 +555,7 @@ bail:
* possible variations. For our purposes, we treat all files as unlocked * possible variations. For our purposes, we treat all files as unlocked
* unless they match the classic "locked" bit pattern. * unless they match the classic "locked" bit pattern.
*/ */
static Boolean static Boolean Nu_IsRecordLocked(const NuRecord* pRecord)
Nu_IsRecordLocked(const NuRecord* pRecord)
{ {
if (pRecord->recAccess == 0x21L || pRecord->recAccess == 0x01L) if (pRecord->recAccess == 0x21L || pRecord->recAccess == 0x01L)
return true; return true;
@ -578,8 +569,7 @@ Nu_IsRecordLocked(const NuRecord* pRecord)
* This assumes that the file is currently writable, so we only need * This assumes that the file is currently writable, so we only need
* to do something if the original file was "locked". * to do something if the original file was "locked".
*/ */
static NuError static NuError Nu_SetFileAccess(NuArchive* pArchive, const NuRecord* pRecord,
Nu_SetFileAccess(NuArchive* pArchive, const NuRecord* pRecord,
const char* pathname) const char* pathname)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -627,8 +617,7 @@ bail:
* Generally this just involves ensuring that the file is writable. If * Generally this just involves ensuring that the file is writable. If
* this is a convenient place to truncate it, we should do that too. * this is a convenient place to truncate it, we should do that too.
*/ */
static NuError static NuError Nu_PrepareForWriting(NuArchive* pArchive, const char* pathname,
Nu_PrepareForWriting(NuArchive* pArchive, const char* pathname,
Boolean prepRsrc, NuFileInfo* pFileInfo) Boolean prepRsrc, NuFileInfo* pFileInfo)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -679,8 +668,7 @@ bail:
/* /*
* Invoke the system-dependent directory creation function. * Invoke the system-dependent directory creation function.
*/ */
static NuError static NuError Nu_Mkdir(NuArchive* pArchive, const char* dir)
Nu_Mkdir(NuArchive* pArchive, const char* dir)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -715,8 +703,7 @@ bail:
* subdirectory level doesn't exist either, cut down the pathname and * subdirectory level doesn't exist either, cut down the pathname and
* recurse. * recurse.
*/ */
static NuError static NuError Nu_CreateSubdirIFN(NuArchive* pArchive, const char* pathStart,
Nu_CreateSubdirIFN(NuArchive* pArchive, const char* pathStart,
const char* pathEnd, char fssep) const char* pathEnd, char fssep)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -770,8 +757,8 @@ bail:
* If "pathname" is just a filename, or the set of directories matches * If "pathname" is just a filename, or the set of directories matches
* the last directory we created, we don't do anything. * the last directory we created, we don't do anything.
*/ */
static NuError static NuError Nu_CreatePathIFN(NuArchive* pArchive, const char* pathname,
Nu_CreatePathIFN(NuArchive* pArchive, const char* pathname, char fssep) char fssep)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
const char* pathStart; const char* pathStart;
@ -828,8 +815,7 @@ bail:
/* /*
* Open the file for writing, possibly truncating it. * Open the file for writing, possibly truncating it.
*/ */
static NuError static NuError Nu_OpenFileForWrite(NuArchive* pArchive, const char* pathname,
Nu_OpenFileForWrite(NuArchive* pArchive, const char* pathname,
Boolean openRsrc, FILE** pFp) Boolean openRsrc, FILE** pFp)
{ {
#if defined(MAC_LIKE) #if defined(MAC_LIKE)
@ -856,8 +842,7 @@ Nu_OpenFileForWrite(NuArchive* pArchive, const char* pathname,
* "freshen" option that requires us to only update files that are * "freshen" option that requires us to only update files that are
* older than what we have. * older than what we have.
*/ */
NuError NuError Nu_OpenOutputFile(NuArchive* pArchive, const NuRecord* pRecord,
Nu_OpenOutputFile(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, const char* newPathname, char newFssep, const NuThread* pThread, const char* newPathname, char newFssep,
FILE** pFp) FILE** pFp)
{ {
@ -1104,9 +1089,8 @@ bail:
* when writing a rsrc fork to a file with just a data fork. This isn't * when writing a rsrc fork to a file with just a data fork. This isn't
* quite right, but it's close enough. * quite right, but it's close enough.
*/ */
NuError NuError Nu_CloseOutputFile(NuArchive* pArchive, const NuRecord* pRecord,
Nu_CloseOutputFile(NuArchive* pArchive, const NuRecord* pRecord, FILE* fp, FILE* fp, const char* pathname)
const char* pathname)
{ {
NuError err; NuError err;
@ -1164,8 +1148,7 @@ bail:
/* /*
* Open the file for reading, in "binary" mode when necessary. * Open the file for reading, in "binary" mode when necessary.
*/ */
static NuError static NuError Nu_OpenFileForRead(NuArchive* pArchive, const char* pathname,
Nu_OpenFileForRead(NuArchive* pArchive, const char* pathname,
Boolean openRsrc, FILE** pFp) Boolean openRsrc, FILE** pFp)
{ {
*pFp = fopen(pathname, kNuFileOpenReadOnly); *pFp = fopen(pathname, kNuFileOpenReadOnly);
@ -1181,8 +1164,7 @@ Nu_OpenFileForRead(NuArchive* pArchive, const char* pathname,
* If the file can't be found, we give the application an opportunity to * If the file can't be found, we give the application an opportunity to
* skip the absent file, retry, or abort the whole thing. * skip the absent file, retry, or abort the whole thing.
*/ */
NuError NuError Nu_OpenInputFile(NuArchive* pArchive, const char* pathname,
Nu_OpenInputFile(NuArchive* pArchive, const char* pathname,
Boolean openRsrc, FILE** pFp) Boolean openRsrc, FILE** pFp)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1280,8 +1262,7 @@ bail:
/* /*
* Delete a file. * Delete a file.
*/ */
NuError NuError Nu_DeleteFile(const char* pathname)
Nu_DeleteFile(const char* pathname)
{ {
#if defined(UNIX_LIKE) || defined(WINDOWS_LIKE) #if defined(UNIX_LIKE) || defined(WINDOWS_LIKE)
int cc; int cc;
@ -1301,8 +1282,7 @@ Nu_DeleteFile(const char* pathname)
/* /*
* Rename a file from "fromPath" to "toPath". * Rename a file from "fromPath" to "toPath".
*/ */
NuError NuError Nu_RenameFile(const char* fromPath, const char* toPath)
Nu_RenameFile(const char* fromPath, const char* toPath)
{ {
#if defined(UNIX_LIKE) || defined(WINDOWS_LIKE) #if defined(UNIX_LIKE) || defined(WINDOWS_LIKE)
int cc; int cc;
@ -1329,8 +1309,7 @@ Nu_RenameFile(const char* fromPath, const char* toPath)
/* /*
* Wrapper for ftell(). * Wrapper for ftell().
*/ */
NuError NuError Nu_FTell(FILE* fp, long* pOffset)
Nu_FTell(FILE* fp, long* pOffset)
{ {
Assert(fp != NULL); Assert(fp != NULL);
Assert(pOffset != NULL); Assert(pOffset != NULL);
@ -1347,8 +1326,7 @@ Nu_FTell(FILE* fp, long* pOffset)
/* /*
* Wrapper for fseek(). * Wrapper for fseek().
*/ */
NuError NuError Nu_FSeek(FILE* fp, long offset, int ptrname)
Nu_FSeek(FILE* fp, long offset, int ptrname)
{ {
Assert(fp != NULL); Assert(fp != NULL);
Assert(ptrname == SEEK_SET || ptrname == SEEK_CUR || ptrname == SEEK_END); Assert(ptrname == SEEK_SET || ptrname == SEEK_CUR || ptrname == SEEK_END);
@ -1366,8 +1344,7 @@ Nu_FSeek(FILE* fp, long offset, int ptrname)
* Wrapper for fread(). Note the arguments resemble read(2) rather than the * Wrapper for fread(). Note the arguments resemble read(2) rather than the
* slightly silly ones used by fread(3S). * slightly silly ones used by fread(3S).
*/ */
NuError NuError Nu_FRead(FILE* fp, void* buf, size_t nbyte)
Nu_FRead(FILE* fp, void* buf, size_t nbyte)
{ {
size_t result; size_t result;
@ -1382,8 +1359,7 @@ Nu_FRead(FILE* fp, void* buf, size_t nbyte)
* Wrapper for fwrite(). Note the arguments resemble write(2) rather than the * Wrapper for fwrite(). Note the arguments resemble write(2) rather than the
* slightly silly ones used by fwrite(3S). * slightly silly ones used by fwrite(3S).
*/ */
NuError NuError Nu_FWrite(FILE* fp, const void* buf, size_t nbyte)
Nu_FWrite(FILE* fp, const void* buf, size_t nbyte)
{ {
size_t result; size_t result;
@ -1403,8 +1379,8 @@ Nu_FWrite(FILE* fp, const void* buf, size_t nbyte)
/* /*
* Copy a section from one file to another. * Copy a section from one file to another.
*/ */
NuError NuError Nu_CopyFileSection(NuArchive* pArchive, FILE* dstFp, FILE* srcFp,
Nu_CopyFileSection(NuArchive* pArchive, FILE* dstFp, FILE* srcFp, long length) long length)
{ {
NuError err; NuError err;
long readLen; long readLen;
@ -1452,8 +1428,7 @@ bail:
* (pArchive is only used for BailError message reporting, so it's okay * (pArchive is only used for BailError message reporting, so it's okay
* to call here with a NULL pointer if the archive isn't open yet.) * to call here with a NULL pointer if the archive isn't open yet.)
*/ */
NuError NuError Nu_GetFileLength(NuArchive* pArchive, FILE* fp, long* pLength)
Nu_GetFileLength(NuArchive* pArchive, FILE* fp, long* pLength)
{ {
NuError err; NuError err;
long oldpos; long oldpos;
@ -1482,8 +1457,7 @@ bail:
* Truncate an open file. This differs from ftruncate() in that it takes * Truncate an open file. This differs from ftruncate() in that it takes
* a FILE* instead of an fd, and the length is a long instead of off_t. * a FILE* instead of an fd, and the length is a long instead of off_t.
*/ */
NuError NuError Nu_TruncateOpenFile(FILE* fp, long length)
Nu_TruncateOpenFile(FILE* fp, long length)
{ {
#if defined(HAVE_FTRUNCATE) #if defined(HAVE_FTRUNCATE)
if (ftruncate(fileno(fp), length) < 0) if (ftruncate(fileno(fp), length) < 0)

View File

@ -22,9 +22,9 @@
* The same structure will be used when expanding all threads in a given * The same structure will be used when expanding all threads in a given
* record. * record.
*/ */
NuError NuError Nu_ProgressDataInit_Compress(NuArchive* pArchive,
Nu_ProgressDataInit_Compress(NuArchive* pArchive, NuProgressData* pProgressData, NuProgressData* pProgressData, const NuRecord* pRecord,
const NuRecord* pRecord, const char* origPathname) const char* origPathname)
{ {
const char* cp; const char* cp;
@ -67,10 +67,9 @@ Nu_ProgressDataInit_Compress(NuArchive* pArchive, NuProgressData* pProgressData,
* The same structure will be used when expanding all threads in a given * The same structure will be used when expanding all threads in a given
* record. * record.
*/ */
NuError NuError Nu_ProgressDataInit_Expand(NuArchive* pArchive,
Nu_ProgressDataInit_Expand(NuArchive* pArchive, NuProgressData* pProgressData, NuProgressData* pProgressData, const NuRecord* pRecord,
const NuRecord* pRecord, const char* newPathname, char newFssep, const char* newPathname, char newFssep, NuValue convertEOL)
NuValue convertEOL)
{ {
const NuThread* pThreadIter; const NuThread* pThreadIter;
const char* cp; const char* cp;
@ -126,8 +125,7 @@ Nu_ProgressDataInit_Expand(NuArchive* pArchive, NuProgressData* pProgressData,
/* /*
* Do the setup on a ProgressData prior to compressing a thread. * Do the setup on a ProgressData prior to compressing a thread.
*/ */
NuError NuError Nu_ProgressDataCompressPrep(NuArchive* pArchive, NuStraw* pStraw,
Nu_ProgressDataCompressPrep(NuArchive* pArchive, NuStraw* pStraw,
NuThreadFormat threadFormat, uint32_t sourceLen) NuThreadFormat threadFormat, uint32_t sourceLen)
{ {
NuProgressData* pProgressData; NuProgressData* pProgressData;
@ -151,8 +149,7 @@ Nu_ProgressDataCompressPrep(NuArchive* pArchive, NuStraw* pStraw,
* *
* "pThread" is the thread being expanded. * "pThread" is the thread being expanded.
*/ */
NuError NuError Nu_ProgressDataExpandPrep(NuArchive* pArchive, NuFunnel* pFunnel,
Nu_ProgressDataExpandPrep(NuArchive* pArchive, NuFunnel* pFunnel,
const NuThread* pThread) const NuThread* pThread)
{ {
NuProgressData* pProgressData; NuProgressData* pProgressData;
@ -175,8 +172,7 @@ Nu_ProgressDataExpandPrep(NuArchive* pArchive, NuFunnel* pFunnel,
/* /*
* Compute a completion percentage. * Compute a completion percentage.
*/ */
static int static int Nu_ComputePercent(uint32_t total, uint32_t progress)
Nu_ComputePercent(uint32_t total, uint32_t progress)
{ {
uint32_t perc; uint32_t perc;
@ -200,8 +196,7 @@ Nu_ComputePercent(uint32_t total, uint32_t progress)
* Send the initial progress message, before the output file is opened * Send the initial progress message, before the output file is opened
* (when extracting) or the input file is opened (when adding). * (when extracting) or the input file is opened (when adding).
*/ */
NuError NuError Nu_SendInitialProgress(NuArchive* pArchive, NuProgressData* pProgress)
Nu_SendInitialProgress(NuArchive* pArchive, NuProgressData* pProgress)
{ {
NuResult result; NuResult result;
@ -234,9 +229,9 @@ Nu_SendInitialProgress(NuArchive* pArchive, NuProgressData* pProgress)
/* /*
* Allocate and initialize a Funnel. * Allocate and initialize a Funnel.
*/ */
NuError NuError Nu_FunnelNew(NuArchive* pArchive, NuDataSink* pDataSink,
Nu_FunnelNew(NuArchive* pArchive, NuDataSink* pDataSink, NuValue convertEOL, NuValue convertEOL, NuValue convertEOLTo, NuProgressData* pProgress,
NuValue convertEOLTo, NuProgressData* pProgress, NuFunnel** ppFunnel) NuFunnel** ppFunnel)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuFunnel* pFunnel = NULL; NuFunnel* pFunnel = NULL;
@ -278,8 +273,7 @@ bail:
* The data should already have been written; it's not the duty of a * The data should already have been written; it's not the duty of a
* "free" function to flush data out. * "free" function to flush data out.
*/ */
NuError NuError Nu_FunnelFree(NuArchive* pArchive, NuFunnel* pFunnel)
Nu_FunnelFree(NuArchive* pArchive, NuFunnel* pFunnel)
{ {
if (pFunnel == NULL) if (pFunnel == NULL)
return kNuErrNone; return kNuErrNone;
@ -304,8 +298,7 @@ Nu_FunnelFree(NuArchive* pArchive, NuFunnel* pFunnel)
* allows us to bail out as soon as it's apparent that compression is * allows us to bail out as soon as it's apparent that compression is
* failing and is actually resulting in a larger file. * failing and is actually resulting in a larger file.
*/ */
void void Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, uint32_t maxBytes)
Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, uint32_t maxBytes)
{ {
Assert(pFunnel != NULL); Assert(pFunnel != NULL);
Assert(maxBytes > 0); Assert(maxBytes > 0);
@ -324,8 +317,7 @@ Nu_FunnelSetMaxOutput(NuFunnel* pFunnel, uint32_t maxBytes)
* character must have its high bit set, except for spaces (0x20). * character must have its high bit set, except for spaces (0x20).
* (The exception is courtesy Glen Bredon's "Merlin".) * (The exception is courtesy Glen Bredon's "Merlin".)
*/ */
static Boolean static Boolean Nu_CheckHighASCII(const NuFunnel* pFunnel, const uint8_t* buffer,
Nu_CheckHighASCII(const NuFunnel* pFunnel, const uint8_t* buffer,
uint32_t count) uint32_t count)
{ {
Boolean isHighASCII; Boolean isHighASCII;
@ -405,8 +397,8 @@ static const char gNuIsBinary[256] = {
* Returns kConvEOLOff or kConvEOLOn, and sets pFunnel->doStripHighASCII * Returns kConvEOLOff or kConvEOLOn, and sets pFunnel->doStripHighASCII
* if pFunnel->CheckStripHighASCII is set. * if pFunnel->CheckStripHighASCII is set.
*/ */
static NuValue static NuValue Nu_DetermineConversion(NuFunnel* pFunnel, const uint8_t* buffer,
Nu_DetermineConversion(NuFunnel* pFunnel, const uint8_t* buffer, uint32_t count) uint32_t count)
{ {
uint32_t bufCount, numBinary, numLF, numCR; uint32_t bufCount, numBinary, numLF, numCR;
Boolean isHighASCII; Boolean isHighASCII;
@ -484,8 +476,8 @@ Nu_DetermineConversion(NuFunnel* pFunnel, const uint8_t* buffer, uint32_t count)
* This is either a Funnel function or a DataSink function, depending on * This is either a Funnel function or a DataSink function, depending on
* your perspective. * your perspective.
*/ */
static inline void static inline void Nu_FunnelPutBlock(NuFunnel* pFunnel, const uint8_t* buf,
Nu_FunnelPutBlock(NuFunnel* pFunnel, const uint8_t* buf, uint32_t len) uint32_t len)
{ {
Assert(pFunnel != NULL); Assert(pFunnel != NULL);
Assert(pFunnel->pDataSink != NULL); Assert(pFunnel->pDataSink != NULL);
@ -511,8 +503,7 @@ Nu_FunnelPutBlock(NuFunnel* pFunnel, const uint8_t* buf, uint32_t len)
/* /*
* Output the EOL marker requested for this system. * Output the EOL marker requested for this system.
*/ */
static inline void static inline void Nu_PutEOL(NuFunnel* pFunnel)
Nu_PutEOL(NuFunnel* pFunnel)
{ {
uint8_t ch; uint8_t ch;
@ -540,8 +531,8 @@ Nu_PutEOL(NuFunnel* pFunnel)
* that looks like an EOL mark and convert it. Doesn't matter if it's * that looks like an EOL mark and convert it. Doesn't matter if it's
* CR, LF, or CRLF; all three get converted to whatever the system uses. * CR, LF, or CRLF; all three get converted to whatever the system uses.
*/ */
static NuError static NuError Nu_FunnelWriteConvert(NuFunnel* pFunnel, const uint8_t* buffer,
Nu_FunnelWriteConvert(NuFunnel* pFunnel, const uint8_t* buffer, uint32_t count) uint32_t count)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
uint32_t progressCount = count; uint32_t progressCount = count;
@ -637,8 +628,7 @@ Nu_FunnelWriteConvert(NuFunnel* pFunnel, const uint8_t* buffer, uint32_t count)
/* /*
* Flush any data currently in the funnel. * Flush any data currently in the funnel.
*/ */
NuError NuError Nu_FunnelFlush(NuArchive* pArchive, NuFunnel* pFunnel)
Nu_FunnelFlush(NuArchive* pArchive, NuFunnel* pFunnel)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -661,9 +651,8 @@ bail:
* Write a bunch of bytes into a funnel. They will be held in the buffer * Write a bunch of bytes into a funnel. They will be held in the buffer
* if they fit, or flushed out the bottom if not. * if they fit, or flushed out the bottom if not.
*/ */
NuError NuError Nu_FunnelWrite(NuArchive* pArchive, NuFunnel* pFunnel,
Nu_FunnelWrite(NuArchive* pArchive, NuFunnel* pFunnel, const uint8_t* buffer, const uint8_t* buffer, uint32_t count)
uint32_t count)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -714,8 +703,7 @@ bail:
/* /*
* Set the Funnel's progress state. * Set the Funnel's progress state.
*/ */
NuError NuError Nu_FunnelSetProgressState(NuFunnel* pFunnel, NuProgressState state)
Nu_FunnelSetProgressState(NuFunnel* pFunnel, NuProgressState state)
{ {
Assert(pFunnel != NULL); Assert(pFunnel != NULL);
@ -731,8 +719,7 @@ Nu_FunnelSetProgressState(NuFunnel* pFunnel, NuProgressState state)
/* /*
* Send a progress update to the application, if they're interested. * Send a progress update to the application, if they're interested.
*/ */
NuError NuError Nu_FunnelSendProgressUpdate(NuArchive* pArchive, NuFunnel* pFunnel)
Nu_FunnelSendProgressUpdate(NuArchive* pArchive, NuFunnel* pFunnel)
{ {
NuProgressData* pProgress; NuProgressData* pProgress;
@ -755,8 +742,7 @@ Nu_FunnelSendProgressUpdate(NuArchive* pArchive, NuFunnel* pFunnel)
/* /*
* Pull the "doExpand" parameter out of the data source. * Pull the "doExpand" parameter out of the data source.
*/ */
Boolean Boolean Nu_FunnelGetDoExpand(NuFunnel* pFunnel)
Nu_FunnelGetDoExpand(NuFunnel* pFunnel)
{ {
Assert(pFunnel != NULL); Assert(pFunnel != NULL);
Assert(pFunnel->pDataSink != NULL); Assert(pFunnel->pDataSink != NULL);
@ -774,8 +760,7 @@ Nu_FunnelGetDoExpand(NuFunnel* pFunnel)
/* /*
* Allocate and initialize a Straw. * Allocate and initialize a Straw.
*/ */
NuError NuError Nu_StrawNew(NuArchive* pArchive, NuDataSource* pDataSource,
Nu_StrawNew(NuArchive* pArchive, NuDataSource* pDataSource,
NuProgressData* pProgress, NuStraw** ppStraw) NuProgressData* pProgress, NuStraw** ppStraw)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -802,8 +787,7 @@ bail:
/* /*
* Free a Straw. * Free a Straw.
*/ */
NuError NuError Nu_StrawFree(NuArchive* pArchive, NuStraw* pStraw)
Nu_StrawFree(NuArchive* pArchive, NuStraw* pStraw)
{ {
if (pStraw == NULL) if (pStraw == NULL)
return kNuErrNone; return kNuErrNone;
@ -818,8 +802,7 @@ Nu_StrawFree(NuArchive* pArchive, NuStraw* pStraw)
/* /*
* Set the Straw's progress state. * Set the Straw's progress state.
*/ */
NuError NuError Nu_StrawSetProgressState(NuStraw* pStraw, NuProgressState state)
Nu_StrawSetProgressState(NuStraw* pStraw, NuProgressState state)
{ {
Assert(pStraw != NULL); Assert(pStraw != NULL);
Assert(pStraw->pProgress != NULL); Assert(pStraw->pProgress != NULL);
@ -832,8 +815,7 @@ Nu_StrawSetProgressState(NuStraw* pStraw, NuProgressState state)
/* /*
* Send a progress update to the application, if they're interested. * Send a progress update to the application, if they're interested.
*/ */
NuError NuError Nu_StrawSendProgressUpdate(NuArchive* pArchive, NuStraw* pStraw)
Nu_StrawSendProgressUpdate(NuArchive* pArchive, NuStraw* pStraw)
{ {
NuProgressData* pProgress; NuProgressData* pProgress;
@ -856,8 +838,8 @@ Nu_StrawSendProgressUpdate(NuArchive* pArchive, NuStraw* pStraw)
/* /*
* Read data from a straw. * Read data from a straw.
*/ */
NuError NuError Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uint8_t* buffer,
Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uint8_t* buffer, long len) long len)
{ {
NuError err; NuError err;
@ -911,8 +893,7 @@ bail:
* Rewind a straw. This rewinds the underlying data source, and resets * Rewind a straw. This rewinds the underlying data source, and resets
* some progress counters. * some progress counters.
*/ */
NuError NuError Nu_StrawRewind(NuArchive* pArchive, NuStraw* pStraw)
Nu_StrawRewind(NuArchive* pArchive, NuStraw* pStraw)
{ {
Assert(pStraw != NULL); Assert(pStraw != NULL);
Assert(pStraw->pDataSource != NULL); Assert(pStraw->pDataSource != NULL);

View File

@ -300,8 +300,8 @@ static CONST INTCODE gNu_mc[] = {
#endif #endif
static int static int Nu_LZC_alloc_tables(LZCState* pLzcState, INTCODE newmaxcode,
Nu_LZC_alloc_tables(LZCState* pLzcState, INTCODE newmaxcode, HASH newhashsize) HASH newhashsize)
{ {
NuArchive* pArchive = pLzcState->pArchive; NuArchive* pArchive = pLzcState->pArchive;
/*static INTCODE oldmaxcode = 0;*/ /*static INTCODE oldmaxcode = 0;*/
@ -421,8 +421,7 @@ Nu_LZC_alloc_tables(LZCState* pLzcState, INTCODE newmaxcode, HASH newhashsize)
* =========================================================================== * ===========================================================================
*/ */
static void static void Nu_prratio(long int num, long int den)
Nu_prratio(long int num, long int den)
{ {
register int q; /* Doesn't need to be long */ register int q; /* Doesn't need to be long */
@ -443,8 +442,7 @@ Nu_prratio(long int num, long int den)
/* table clear for block compress */ /* table clear for block compress */
/* this is for adaptive reset present in version 4.0 joe release */ /* this is for adaptive reset present in version 4.0 joe release */
/* DjG, sets it up and returns TRUE to compress and FALSE to not compress */ /* DjG, sets it up and returns TRUE to compress and FALSE to not compress */
static int static int Nu_LZC_cl_block(LZCState* pLzcState)
Nu_LZC_cl_block(LZCState* pLzcState)
{ {
register long int rat; register long int rat;
@ -486,8 +484,7 @@ Nu_LZC_cl_block(LZCState* pLzcState)
static CONST UCHAR gNu_rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; static CONST UCHAR gNu_rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
static void static void Nu_LZC_putcode(LZCState* pLzcState, INTCODE code, register int bits)
Nu_LZC_putcode(LZCState* pLzcState, INTCODE code, register int bits)
{ {
/*static int oldbits = 0;*/ /*static int oldbits = 0;*/
/*static UCHAR outbuf[MAXBITS];*/ /*static UCHAR outbuf[MAXBITS];*/
@ -554,8 +551,7 @@ Nu_LZC_putcode(LZCState* pLzcState, INTCODE code, register int bits)
* *
* Returns kNuLZCEOF as the value when we're out of data. * Returns kNuLZCEOF as the value when we're out of data.
*/ */
static NuError static NuError Nu_LZCGetcCRC(LZCState* pLzcState, int* pSym)
Nu_LZCGetcCRC(LZCState* pLzcState, int* pSym)
{ {
NuError err; NuError err;
uint8_t c; uint8_t c;
@ -579,8 +575,7 @@ Nu_LZCGetcCRC(LZCState* pLzcState, int* pSym)
/* /*
* compress stdin to stdout * compress stdin to stdout
*/ */
static void static void Nu_LZC_compress(LZCState* pLzcState, uint32_t* pDstLen)
Nu_LZC_compress(LZCState* pLzcState, uint32_t* pDstLen)
{ {
int c,adjbits; int c,adjbits;
register HASH hash; register HASH hash;
@ -758,8 +753,7 @@ Nu_LZC_compress(LZCState* pLzcState, uint32_t* pDstLen)
/* /*
* NufxLib interface to LZC compression. * NufxLib interface to LZC compression.
*/ */
static NuError static NuError Nu_CompressLZC(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressLZC(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc, int maxbits) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc, int maxbits)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -806,15 +800,13 @@ Nu_CompressLZC(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
return err; return err;
} }
NuError NuError Nu_CompressLZC12(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressLZC12(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
{ {
return Nu_CompressLZC(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, 12); return Nu_CompressLZC(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, 12);
} }
NuError NuError Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
{ {
return Nu_CompressLZC(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, 16); return Nu_CompressLZC(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, 16);
@ -833,8 +825,7 @@ Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
* *
* Returns kNuLZCEOF as the value when we're out of data. * Returns kNuLZCEOF as the value when we're out of data.
*/ */
static NuError static NuError Nu_LZCPutcCRC(LZCState* pLzcState, char c)
Nu_LZCPutcCRC(LZCState* pLzcState, char c)
{ {
NuError err; NuError err;
@ -847,8 +838,7 @@ Nu_LZCPutcCRC(LZCState* pLzcState, char c)
} }
static int static int Nu_LZC_nextcode(LZCState* pLzcState, INTCODE* codeptr)
Nu_LZC_nextcode(LZCState* pLzcState, INTCODE* codeptr)
/* Get the next code from input and put it in *codeptr. /* Get the next code from input and put it in *codeptr.
* Return (TRUE) on success, or return (FALSE) on end-of-file. * Return (TRUE) on success, or return (FALSE) on end-of-file.
* Adapted from COMPRESS V4.0. * Adapted from COMPRESS V4.0.
@ -898,8 +888,7 @@ Nu_LZC_nextcode(LZCState* pLzcState, INTCODE* codeptr)
return (TRUE); return (TRUE);
} }
static void static void Nu_LZC_decompress(LZCState* pLzcState, uint32_t compressedLen)
Nu_LZC_decompress(LZCState* pLzcState, uint32_t compressedLen)
{ {
NuArchive* pArchive = pLzcState->pArchive; NuArchive* pArchive = pLzcState->pArchive;
register int i; register int i;
@ -1060,8 +1049,7 @@ Nu_LZC_decompress(LZCState* pLzcState, uint32_t compressedLen)
/* /*
* NufxLib interface to LZC expansion. * NufxLib interface to LZC expansion.
*/ */
NuError NuError Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord,
Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc) const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;

View File

@ -146,8 +146,7 @@ typedef struct LZWCompressState {
* the hash function. This way we don't have to re-create it for * the hash function. This way we don't have to re-create it for
* every file, or store it statically in the binary. * every file, or store it statically in the binary.
*/ */
static NuError static NuError Nu_AllocLZWCompressState(NuArchive* pArchive)
Nu_AllocLZWCompressState(NuArchive* pArchive)
{ {
NuError err; NuError err;
LZWCompressState* lzwState; LZWCompressState* lzwState;
@ -191,8 +190,7 @@ Nu_AllocLZWCompressState(NuArchive* pArchive)
* The RLE format is "<delim> <char> <count>", where count is zero-based * The RLE format is "<delim> <char> <count>", where count is zero-based
* (i.e. for three bytes we encode "2", allowing us to express 1-256). * (i.e. for three bytes we encode "2", allowing us to express 1-256).
*/ */
static NuError static NuError Nu_CompressBlockRLE(LZWCompressState* lzwState, int* pRLESize)
Nu_CompressBlockRLE(LZWCompressState* lzwState, int* pRLESize)
{ {
const uint8_t* inPtr = lzwState->inputBuf; const uint8_t* inPtr = lzwState->inputBuf;
const uint8_t* endPtr = inPtr + kNuLZWBlockSize; const uint8_t* endPtr = inPtr + kNuLZWBlockSize;
@ -258,8 +256,7 @@ Nu_CompressBlockRLE(LZWCompressState* lzwState, int* pRLESize)
/* /*
* Clear the LZW table. Also resets the LZW/2 state. * Clear the LZW table. Also resets the LZW/2 state.
*/ */
static void static void Nu_ClearLZWTable(LZWCompressState* lzwState)
Nu_ClearLZWTable(LZWCompressState* lzwState)
{ {
Assert(lzwState != NULL); Assert(lzwState != NULL);
@ -296,8 +293,8 @@ Nu_ClearLZWTable(LZWCompressState* lzwState)
* *
* (Turning this into a macro might speed things up.) * (Turning this into a macro might speed things up.)
*/ */
static inline void static inline void Nu_LZWPutCode(uint8_t** pOutBuf, uint32_t prefixCode,
Nu_LZWPutCode(uint8_t** pOutBuf, uint32_t prefixCode, int codeBits, int* pAtBit) int codeBits, int* pAtBit)
{ {
int atBit = *pAtBit; int atBit = *pAtBit;
uint8_t* outBuf = *pOutBuf; uint8_t* outBuf = *pOutBuf;
@ -353,9 +350,8 @@ Nu_LZWPutCode(uint8_t** pOutBuf, uint32_t prefixCode, int codeBits, int* pAtBit)
* "resetFix" logic in the expansion functions. Code 0x0101 is essentially * "resetFix" logic in the expansion functions. Code 0x0101 is essentially
* lost in this situation. * lost in this situation.
*/ */
static NuError static NuError Nu_CompressLZWBlock(LZWCompressState* lzwState,
Nu_CompressLZWBlock(LZWCompressState* lzwState, const uint8_t* inputBuf, const uint8_t* inputBuf, int inputCount, int* pOutputCount)
int inputCount, int* pOutputCount)
{ {
int nextFree, ic, atBit, codeBits; int nextFree, ic, atBit, codeBits;
int hash, hashDelta; int hash, hashDelta;
@ -555,8 +551,7 @@ Nu_CompressLZWBlock(LZWCompressState* lzwState, const uint8_t* inputBuf,
* *
* On exit, the output file will be positioned past the last byte written. * On exit, the output file will be positioned past the last byte written.
*/ */
static NuError static NuError Nu_CompressLZW(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressLZW(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pThreadCrc, Boolean isType2) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pThreadCrc, Boolean isType2)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -782,8 +777,7 @@ bail:
/* /*
* Compress ShrinkIt-style "LZW/1". * Compress ShrinkIt-style "LZW/1".
*/ */
NuError NuError Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
{ {
return Nu_CompressLZW(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, false); return Nu_CompressLZW(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, false);
@ -792,8 +786,7 @@ Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
/* /*
* Compress ShrinkIt-style "LZW/2". * Compress ShrinkIt-style "LZW/2".
*/ */
NuError NuError Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
{ {
return Nu_CompressLZW(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, true); return Nu_CompressLZW(pArchive, pStraw, fp, srcLen, pDstLen, pCrc, true);
@ -865,8 +858,7 @@ typedef struct LZWExpandState {
/* /*
* Allocate some "reusable" state for LZW expansion. * Allocate some "reusable" state for LZW expansion.
*/ */
static NuError static NuError Nu_AllocLZWExpandState(NuArchive* pArchive)
Nu_AllocLZWExpandState(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -897,8 +889,7 @@ Nu_AllocLZWExpandState(NuArchive* pArchive)
( Nu_LZWPopCheck(lzwState, stackPtr), *(--stackPtr) ) ( Nu_LZWPopCheck(lzwState, stackPtr), *(--stackPtr) )
# define Nu_LZWStackEmpty() ( stackPtr == lzwState->stack ) # define Nu_LZWStackEmpty() ( stackPtr == lzwState->stack )
static inline void static inline void Nu_LZWPushCheck(uint8_t uch, const LZWExpandState* lzwState,
Nu_LZWPushCheck(uint8_t uch, const LZWExpandState* lzwState,
const uint8_t* stackPtr) const uint8_t* stackPtr)
{ {
if (stackPtr >= lzwState->stack + sizeof(lzwState->stack)) { if (stackPtr >= lzwState->stack + sizeof(lzwState->stack)) {
@ -907,8 +898,8 @@ Nu_LZWPushCheck(uint8_t uch, const LZWExpandState* lzwState,
} }
} }
static inline void static inline void Nu_LZWPopCheck(const LZWExpandState* lzwState,
Nu_LZWPopCheck(const LZWExpandState* lzwState, const uint8_t* stackPtr) const uint8_t* stackPtr)
{ {
if (stackPtr == lzwState->stack) { if (stackPtr == lzwState->stack) {
Nu_ReportError(lzwState->NU_BLOB, kNuErrBadData, "stack underflow"); Nu_ReportError(lzwState->NU_BLOB, kNuErrBadData, "stack underflow");
@ -929,8 +920,8 @@ Nu_LZWPopCheck(const LZWExpandState* lzwState, const uint8_t* stackPtr)
* *
* (Turning this into a macro might speed things up.) * (Turning this into a macro might speed things up.)
*/ */
static inline uint static inline uint Nu_LZWGetCode(const uint8_t** pInBuf, uint32_t entry,
Nu_LZWGetCode(const uint8_t** pInBuf, uint32_t entry, int* pAtBit, uint* pLastByte) int* pAtBit, uint* pLastByte)
{ {
uint32_t numBits, startBit, lastBit; uint32_t numBits, startBit, lastBit;
uint32_t value; uint32_t value;
@ -977,8 +968,7 @@ Nu_LZWGetCode(const uint8_t** pInBuf, uint32_t entry, int* pAtBit, uint* pLastBy
* *
* Reads from lzwState->dataPtr, writes to lzwState->lzwOutBuf. * Reads from lzwState->dataPtr, writes to lzwState->lzwOutBuf.
*/ */
static NuError static NuError Nu_ExpandLZW1(LZWExpandState* lzwState, uint32_t expectedLen)
Nu_ExpandLZW1(LZWExpandState* lzwState, uint32_t expectedLen)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
TableEntry* tablePtr; TableEntry* tablePtr;
@ -1077,8 +1067,7 @@ bail:
* In some cases, "expectedInputUsed" will be -1 to indicate that the * In some cases, "expectedInputUsed" will be -1 to indicate that the
* value is not known. * value is not known.
*/ */
static NuError static NuError Nu_ExpandLZW2(LZWExpandState* lzwState, uint32_t expectedLen,
Nu_ExpandLZW2(LZWExpandState* lzwState, uint32_t expectedLen,
uint32_t expectedInputUsed) uint32_t expectedInputUsed)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1230,8 +1219,7 @@ bail:
/* /*
* Expands a chunk of RLEd data into 4K of output. * Expands a chunk of RLEd data into 4K of output.
*/ */
static NuError static NuError Nu_ExpandRLE(LZWExpandState* lzwState, const uint8_t* inbuf,
Nu_ExpandRLE(LZWExpandState* lzwState, const uint8_t* inbuf,
uint32_t expectedInputUsed) uint32_t expectedInputUsed)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1284,8 +1272,7 @@ bail:
/* /*
* Utility function to get a byte from the input buffer. * Utility function to get a byte from the input buffer.
*/ */
static inline uint8_t static inline uint8_t Nu_GetHeaderByte(LZWExpandState* lzwState)
Nu_GetHeaderByte(LZWExpandState* lzwState)
{ {
lzwState->dataInBuffer--; lzwState->dataInBuffer--;
Assert(lzwState->dataInBuffer > 0); Assert(lzwState->dataInBuffer > 0);
@ -1302,8 +1289,7 @@ Nu_GetHeaderByte(LZWExpandState* lzwState)
* "*pThreadCrc" should already be set to its initial value. On exit it * "*pThreadCrc" should already be set to its initial value. On exit it
* will contain the CRC of the uncompressed data. * will contain the CRC of the uncompressed data.
*/ */
NuError NuError Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, const NuThread* pThread, FILE* infp, NuFunnel* pFunnel,
uint16_t* pThreadCrc) uint16_t* pThreadCrc)
{ {

View File

@ -16,8 +16,7 @@
* Return a pointer to the appropriate string in the system table, or NULL * Return a pointer to the appropriate string in the system table, or NULL
* if the value is out of bounds. * if the value is out of bounds.
*/ */
const char* const char* Nu_strerror(int errnum)
Nu_strerror(int errnum)
{ {
extern int sys_nerr; extern int sys_nerr;
extern char *sys_errlist[]; extern char *sys_errlist[];
@ -38,8 +37,7 @@ Nu_strerror(int errnum)
* from BSD, is available in the PGP 2.6.2 distribution, but this should * from BSD, is available in the PGP 2.6.2 distribution, but this should
* suffice for those few systems that don't have memmove. * suffice for those few systems that don't have memmove.
*/ */
void* void* Nu_memmove(void* dst, const void* src, size_t n)
Nu_memmove(void* dst, const void* src, size_t n)
{ {
void* retval = dst; void* retval = dst;
char* srcp = (char*)src; char* srcp = (char*)src;
@ -80,8 +78,7 @@ Nu_memmove(void* dst, const void* src, size_t n)
* For our purposes here, strtol does all we need it to. Someday * For our purposes here, strtol does all we need it to. Someday
* we should replace this with a "real" version. * we should replace this with a "real" version.
*/ */
unsigned long unsigned long Nu_strtoul(const char *nptr, char **endptr, int base)
Nu_strtoul(const char *nptr, char **endptr, int base)
{ {
return strtol(nptr, endptr, base); return strtol(nptr, endptr, base);
} }
@ -91,8 +88,7 @@ Nu_strtoul(const char *nptr, char **endptr, int base)
/* /*
* Compare two strings, case-insensitive. * Compare two strings, case-insensitive.
*/ */
int int Nu_strcasecmp(const char *str1, const char *str2)
Nu_strcasecmp(const char *str1, const char *str2)
{ {
while (*str1 && *str2 && toupper(*str1) == toupper(*str2)) while (*str1 && *str2 && toupper(*str1) == toupper(*str2))
str1++, str2++; str1++, str2++;
@ -105,8 +101,7 @@ Nu_strcasecmp(const char *str1, const char *str2)
/* /*
* Compare two strings, case-insensitive, stopping after "n" chars. * Compare two strings, case-insensitive, stopping after "n" chars.
*/ */
int int Nu_strncasecmp(const char *str1, const char *str2, size_t n)
Nu_strncasecmp(const char *str1, const char *str2, size_t n)
{ {
while (n && *str1 && *str2 && toupper(*str1) == toupper(*str2)) while (n && *str1 && *str2 && toupper(*str1) == toupper(*str2))
str1++, str2++, n--; str1++, str2++, n--;

View File

@ -21,8 +21,7 @@ static const char* kNufxLibName = "nufxlib";
/* /*
* strerror() equivalent for NufxLib errors. * strerror() equivalent for NufxLib errors.
*/ */
const char* const char* Nu_StrError(NuError err)
Nu_StrError(NuError err)
{ {
/* /*
* BUG: this should be set up as per-thread storage in an MT environment. * BUG: this should be set up as per-thread storage in an MT environment.
@ -206,8 +205,7 @@ Nu_StrError(NuError err)
* if the archive is inaccessible (perhaps because it failed to open). We * if the archive is inaccessible (perhaps because it failed to open). We
* can't invoke the error message callback if the pointer is NULL. * can't invoke the error message callback if the pointer is NULL.
*/ */
void void Nu_ReportError(NuArchive* pArchive, const char* file, int line,
Nu_ReportError(NuArchive* pArchive, const char* file, int line,
const char* function, Boolean isDebug, NuError err, const char* format, ...) const char* function, Boolean isDebug, NuError err, const char* format, ...)
{ {
NuErrorMessage errorMessage; NuErrorMessage errorMessage;
@ -322,8 +320,7 @@ bail:
*/ */
#ifndef USE_DMALLOC #ifndef USE_DMALLOC
void* void* Nu_Malloc(NuArchive* pArchive, size_t size)
Nu_Malloc(NuArchive* pArchive, size_t size)
{ {
void* _result; void* _result;
@ -338,16 +335,14 @@ Nu_Malloc(NuArchive* pArchive, size_t size)
return _result; return _result;
} }
void* void* Nu_Calloc(NuArchive* pArchive, size_t size)
Nu_Calloc(NuArchive* pArchive, size_t size)
{ {
void* _cresult = Nu_Malloc(pArchive, size); void* _cresult = Nu_Malloc(pArchive, size);
memset(_cresult, 0, size); memset(_cresult, 0, size);
return _cresult; return _cresult;
} }
void* void* Nu_Realloc(NuArchive* pArchive, void* ptr, size_t size)
Nu_Realloc(NuArchive* pArchive, void* ptr, size_t size)
{ {
void* _result; void* _result;
@ -362,8 +357,7 @@ Nu_Realloc(NuArchive* pArchive, void* ptr, size_t size)
return _result; return _result;
} }
void void Nu_Free(NuArchive* pArchive, void* ptr)
Nu_Free(NuArchive* pArchive, void* ptr)
{ {
if (ptr != NULL) if (ptr != NULL)
free(ptr); free(ptr);
@ -374,8 +368,7 @@ Nu_Free(NuArchive* pArchive, void* ptr)
* If somebody internal wants to set doClose on a buffer DataSource * If somebody internal wants to set doClose on a buffer DataSource
* (looks like "Rename" does), we need to supply a "free" callback. * (looks like "Rename" does), we need to supply a "free" callback.
*/ */
NuResult NuResult Nu_InternalFreeCallback(NuArchive* pArchive, void* args)
Nu_InternalFreeCallback(NuArchive* pArchive, void* args)
{ {
DBUG(("+++ internal free callback 0x%08lx\n", (long) args)); DBUG(("+++ internal free callback 0x%08lx\n", (long) args));
Nu_Free(NULL, args); Nu_Free(NULL, args);

View File

@ -26,8 +26,7 @@ static const uint8_t kNufxID[kNufxIDLen] = { 0x4e, 0xf5, 0x46, 0xd8 };
* things that a Nu_FreeRecordContents call will check, so that we don't * things that a Nu_FreeRecordContents call will check, so that we don't
* end up trying to free garbage. No need to memset() the whole thing. * end up trying to free garbage. No need to memset() the whole thing.
*/ */
static NuError static NuError Nu_InitRecordContents(NuArchive* pArchive, NuRecord* pRecord)
Nu_InitRecordContents(NuArchive* pArchive, NuRecord* pRecord)
{ {
Assert(pRecord != NULL); Assert(pRecord != NULL);
@ -51,8 +50,7 @@ Nu_InitRecordContents(NuArchive* pArchive, NuRecord* pRecord)
/* /*
* Allocate and initialize a new NuRecord struct. * Allocate and initialize a new NuRecord struct.
*/ */
static NuError static NuError Nu_RecordNew(NuArchive* pArchive, NuRecord** ppRecord)
Nu_RecordNew(NuArchive* pArchive, NuRecord** ppRecord)
{ {
Assert(ppRecord != NULL); Assert(ppRecord != NULL);
@ -67,8 +65,7 @@ Nu_RecordNew(NuArchive* pArchive, NuRecord** ppRecord)
* Free anything allocated within a record. Doesn't try to free the record * Free anything allocated within a record. Doesn't try to free the record
* itself. * itself.
*/ */
static NuError static NuError Nu_FreeRecordContents(NuArchive* pArchive, NuRecord* pRecord)
Nu_FreeRecordContents(NuArchive* pArchive, NuRecord* pRecord)
{ {
Assert(pRecord != NULL); Assert(pRecord != NULL);
@ -89,8 +86,7 @@ Nu_FreeRecordContents(NuArchive* pArchive, NuRecord* pRecord)
/* /*
* Free up a NuRecord struct. * Free up a NuRecord struct.
*/ */
static NuError static NuError Nu_RecordFree(NuArchive* pArchive, NuRecord* pRecord)
Nu_RecordFree(NuArchive* pArchive, NuRecord* pRecord)
{ {
if (pRecord == NULL) if (pRecord == NULL)
return kNuErrNone; return kNuErrNone;
@ -105,8 +101,8 @@ Nu_RecordFree(NuArchive* pArchive, NuRecord* pRecord)
* Copy a field comprised of a buffer and a length from one structure to * Copy a field comprised of a buffer and a length from one structure to
* another. It is assumed that the length value has already been copied. * another. It is assumed that the length value has already been copied.
*/ */
static NuError static NuError CopySizedField(NuArchive* pArchive, void* vppDst,
CopySizedField(NuArchive* pArchive, void* vppDst, const void* vpSrc, uint32_t len) const void* vpSrc, uint32_t len)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
uint8_t** ppDst = vppDst; uint8_t** ppDst = vppDst;
@ -131,8 +127,8 @@ bail:
/* /*
* Make a copy of a record. * Make a copy of a record.
*/ */
static NuError static NuError Nu_RecordCopy(NuArchive* pArchive, NuRecord** ppDst,
Nu_RecordCopy(NuArchive* pArchive, NuRecord** ppDst, const NuRecord* pSrc) const NuRecord* pSrc)
{ {
NuError err; NuError err;
NuRecord* pDst; NuRecord* pDst;
@ -189,8 +185,7 @@ bail:
* acceptable. We could do simple optimizations, like only preserving * acceptable. We could do simple optimizations, like only preserving
* ordering for "add" threadMods, but even that seems silly. * ordering for "add" threadMods, but even that seems silly.
*/ */
void void Nu_RecordAddThreadMod(NuRecord* pRecord, NuThreadMod* pThreadMod)
Nu_RecordAddThreadMod(NuRecord* pRecord, NuThreadMod* pThreadMod)
{ {
NuThreadMod* pScanThreadMod; NuThreadMod* pScanThreadMod;
@ -224,8 +219,7 @@ Nu_RecordAddThreadMod(NuRecord* pRecord, NuThreadMod* pThreadMod)
* threads, subtract the number of deletes, and return "true" if the net * threads, subtract the number of deletes, and return "true" if the net
* result is zero. * result is zero.
*/ */
Boolean Boolean Nu_RecordIsEmpty(NuArchive* pArchive, const NuRecord* pRecord)
Nu_RecordIsEmpty(NuArchive* pArchive, const NuRecord* pRecord)
{ {
const NuThreadMod* pThreadMod; const NuThreadMod* pThreadMod;
int numThreads; int numThreads;
@ -275,51 +269,43 @@ Nu_RecordIsEmpty(NuArchive* pArchive, const NuRecord* pRecord)
* Trivial getters and setters * Trivial getters and setters
*/ */
Boolean Boolean Nu_RecordSet_GetLoaded(const NuRecordSet* pRecordSet)
Nu_RecordSet_GetLoaded(const NuRecordSet* pRecordSet)
{ {
Assert(pRecordSet != NULL); Assert(pRecordSet != NULL);
return pRecordSet->loaded; return pRecordSet->loaded;
} }
void void Nu_RecordSet_SetLoaded(NuRecordSet* pRecordSet, Boolean val)
Nu_RecordSet_SetLoaded(NuRecordSet* pRecordSet, Boolean val)
{ {
pRecordSet->loaded = val; pRecordSet->loaded = val;
} }
uint32_t uint32_t Nu_RecordSet_GetNumRecords(const NuRecordSet* pRecordSet)
Nu_RecordSet_GetNumRecords(const NuRecordSet* pRecordSet)
{ {
return pRecordSet->numRecords; return pRecordSet->numRecords;
} }
void void Nu_RecordSet_SetNumRecords(NuRecordSet* pRecordSet, uint32_t val)
Nu_RecordSet_SetNumRecords(NuRecordSet* pRecordSet, uint32_t val)
{ {
pRecordSet->numRecords = val; pRecordSet->numRecords = val;
} }
void void Nu_RecordSet_IncNumRecords(NuRecordSet* pRecordSet)
Nu_RecordSet_IncNumRecords(NuRecordSet* pRecordSet)
{ {
pRecordSet->numRecords++; pRecordSet->numRecords++;
} }
NuRecord* NuRecord* Nu_RecordSet_GetListHead(const NuRecordSet* pRecordSet)
Nu_RecordSet_GetListHead(const NuRecordSet* pRecordSet)
{ {
return pRecordSet->nuRecordHead; return pRecordSet->nuRecordHead;
} }
NuRecord** NuRecord** Nu_RecordSet_GetListHeadPtr(NuRecordSet* pRecordSet)
Nu_RecordSet_GetListHeadPtr(NuRecordSet* pRecordSet)
{ {
return &pRecordSet->nuRecordHead; return &pRecordSet->nuRecordHead;
} }
NuRecord* NuRecord* Nu_RecordSet_GetListTail(const NuRecordSet* pRecordSet)
Nu_RecordSet_GetListTail(const NuRecordSet* pRecordSet)
{ {
return pRecordSet->nuRecordTail; return pRecordSet->nuRecordTail;
} }
@ -329,8 +315,7 @@ Nu_RecordSet_GetListTail(const NuRecordSet* pRecordSet)
* Returns "true" if the record set has no records or hasn't ever been * Returns "true" if the record set has no records or hasn't ever been
* used. * used.
*/ */
Boolean Boolean Nu_RecordSet_IsEmpty(const NuRecordSet* pRecordSet)
Nu_RecordSet_IsEmpty(const NuRecordSet* pRecordSet)
{ {
if (!pRecordSet->loaded || pRecordSet->numRecords == 0) if (!pRecordSet->loaded || pRecordSet->numRecords == 0)
return true; return true;
@ -341,8 +326,8 @@ Nu_RecordSet_IsEmpty(const NuRecordSet* pRecordSet)
/* /*
* Free the list of records, and reset the record sets to initial state. * Free the list of records, and reset the record sets to initial state.
*/ */
NuError NuError Nu_RecordSet_FreeAllRecords(NuArchive* pArchive,
Nu_RecordSet_FreeAllRecords(NuArchive* pArchive, NuRecordSet* pRecordSet) NuRecordSet* pRecordSet)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -378,8 +363,8 @@ bail:
/* /*
* Add a new record to the end of the list. * Add a new record to the end of the list.
*/ */
static NuError static NuError Nu_RecordSet_AddRecord(NuRecordSet* pRecordSet,
Nu_RecordSet_AddRecord(NuRecordSet* pRecordSet, NuRecord* pRecord) NuRecord* pRecord)
{ {
Assert(pRecordSet != NULL); Assert(pRecordSet != NULL);
Assert(pRecord != NULL); Assert(pRecord != NULL);
@ -413,9 +398,8 @@ Nu_RecordSet_AddRecord(NuRecordSet* pRecordSet, NuRecord* pRecord)
* (Should have a "heavy assert" mode where we verify that "ppRecord" * (Should have a "heavy assert" mode where we verify that "ppRecord"
* actually has something to do with pRecordSet.) * actually has something to do with pRecordSet.)
*/ */
NuError NuError Nu_RecordSet_DeleteRecordPtr(NuArchive* pArchive,
Nu_RecordSet_DeleteRecordPtr(NuArchive* pArchive, NuRecordSet* pRecordSet, NuRecordSet* pRecordSet, NuRecord** ppRecord)
NuRecord** ppRecord)
{ {
NuError err; NuError err;
NuRecord* pRecord; NuRecord* pRecord;
@ -456,8 +440,7 @@ Nu_RecordSet_DeleteRecordPtr(NuArchive* pArchive, NuRecordSet* pRecordSet,
/* /*
* Delete a record from the record set. * Delete a record from the record set.
*/ */
NuError NuError Nu_RecordSet_DeleteRecord(NuArchive* pArchive, NuRecordSet* pRecordSet,
Nu_RecordSet_DeleteRecord(NuArchive* pArchive, NuRecordSet* pRecordSet,
NuRecord* pRecord) NuRecord* pRecord)
{ {
NuError err; NuError err;
@ -490,8 +473,7 @@ bail:
* Make a clone of a record set. This is used to create the "copy" record * Make a clone of a record set. This is used to create the "copy" record
* set out of the "orig" set. * set out of the "orig" set.
*/ */
NuError NuError Nu_RecordSet_Clone(NuArchive* pArchive, NuRecordSet* pDstSet,
Nu_RecordSet_Clone(NuArchive* pArchive, NuRecordSet* pDstSet,
const NuRecordSet* pSrcSet) const NuRecordSet* pSrcSet)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -533,8 +515,7 @@ bail:
* *
* On completion, "pSrcSet" will be empty and "unloaded". * On completion, "pSrcSet" will be empty and "unloaded".
*/ */
NuError NuError Nu_RecordSet_MoveAllRecords(NuArchive* pArchive, NuRecordSet* pDstSet,
Nu_RecordSet_MoveAllRecords(NuArchive* pArchive, NuRecordSet* pDstSet,
NuRecordSet* pSrcSet) NuRecordSet* pSrcSet)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -583,9 +564,8 @@ Nu_RecordSet_MoveAllRecords(NuArchive* pArchive, NuRecordSet* pDstSet,
/* /*
* Find a record in the list by index. * Find a record in the list by index.
*/ */
NuError NuError Nu_RecordSet_FindByIdx(const NuRecordSet* pRecordSet,
Nu_RecordSet_FindByIdx(const NuRecordSet* pRecordSet, NuRecordIdx recIdx, NuRecordIdx recIdx, NuRecord** ppRecord)
NuRecord** ppRecord)
{ {
NuRecord* pRecord; NuRecord* pRecord;
@ -606,9 +586,8 @@ Nu_RecordSet_FindByIdx(const NuRecordSet* pRecordSet, NuRecordIdx recIdx,
/* /*
* Search for a specific thread in all records in the specified record set. * Search for a specific thread in all records in the specified record set.
*/ */
NuError NuError Nu_RecordSet_FindByThreadIdx(NuRecordSet* pRecordSet,
Nu_RecordSet_FindByThreadIdx(NuRecordSet* pRecordSet, NuThreadIdx threadIdx, NuThreadIdx threadIdx, NuRecord** ppRecord, NuThread** ppThread)
NuRecord** ppRecord, NuThread** ppThread)
{ {
NuError err = kNuErrThreadIdxNotFound; NuError err = kNuErrThreadIdxNotFound;
NuRecord* pRecord; NuRecord* pRecord;
@ -650,8 +629,7 @@ Nu_RecordSet_FindByThreadIdx(NuRecordSet* pRecordSet, NuThreadIdx threadIdx,
* string pointed to by name1 is greater than, equal to, or less than * string pointed to by name1 is greater than, equal to, or less than
* the string pointed to by s2, respectively (i.e. same as strcmp). * the string pointed to by s2, respectively (i.e. same as strcmp).
*/ */
static int static int Nu_CompareRecordNames(const char* name1, const char* name2)
Nu_CompareRecordNames(const char* name1, const char* name2)
{ {
#ifdef NU_CASE_SENSITIVE #ifdef NU_CASE_SENSITIVE
return strcmp(name1, name2); return strcmp(name1, name2);
@ -664,9 +642,8 @@ Nu_CompareRecordNames(const char* name1, const char* name2)
/* /*
* Find a record in the list by storageName. * Find a record in the list by storageName.
*/ */
static NuError static NuError Nu_RecordSet_FindByName(const NuRecordSet* pRecordSet,
Nu_RecordSet_FindByName(const NuRecordSet* pRecordSet, const char* name, const char* name, NuRecord** ppRecord)
NuRecord** ppRecord)
{ {
NuRecord* pRecord; NuRecord* pRecord;
@ -696,9 +673,8 @@ Nu_RecordSet_FindByName(const NuRecordSet* pRecordSet, const char* name,
* up scanning the entire list and keeping the last match. If this * up scanning the entire list and keeping the last match. If this
* causes a notable reduction in efficiency we'll have to fix this. * causes a notable reduction in efficiency we'll have to fix this.
*/ */
static NuError static NuError Nu_RecordSet_ReverseFindByName(const NuRecordSet* pRecordSet,
Nu_RecordSet_ReverseFindByName(const NuRecordSet* pRecordSet, const char* name, const char* name, NuRecord** ppRecord)
NuRecord** ppRecord)
{ {
NuRecord* pRecord; NuRecord* pRecord;
NuRecord* pFoundRecord = NULL; NuRecord* pFoundRecord = NULL;
@ -734,8 +710,7 @@ Nu_RecordSet_ReverseFindByName(const NuRecordSet* pRecordSet, const char* name,
* *
* "ppNewRecord" will get a pointer to the newly-created clone. * "ppNewRecord" will get a pointer to the newly-created clone.
*/ */
NuError NuError Nu_RecordSet_ReplaceRecord(NuArchive* pArchive, NuRecordSet* pBadSet,
Nu_RecordSet_ReplaceRecord(NuArchive* pArchive, NuRecordSet* pBadSet,
NuRecord* pBadRecord, NuRecordSet* pGoodSet, NuRecord** ppNewRecord) NuRecord* pBadRecord, NuRecordSet* pGoodSet, NuRecord** ppNewRecord)
{ {
NuError err; NuError err;
@ -811,8 +786,8 @@ bail:
* Ask the user if it's okay to ignore a bad CRC. If we can't ask the * Ask the user if it's okay to ignore a bad CRC. If we can't ask the
* user, return "false". * user, return "false".
*/ */
Boolean Boolean Nu_ShouldIgnoreBadCRC(NuArchive* pArchive, const NuRecord* pRecord,
Nu_ShouldIgnoreBadCRC(NuArchive* pArchive, const NuRecord* pRecord, NuError err) NuError err)
{ {
NuErrorStatus errorStatus; NuErrorStatus errorStatus;
NuResult result; NuResult result;
@ -872,8 +847,7 @@ bail:
* *
* Pass in a NuRecord structure that will hold the data we read. * Pass in a NuRecord structure that will hold the data we read.
*/ */
static NuError static NuError Nu_ReadRecordHeader(NuArchive* pArchive, NuRecord* pRecord)
Nu_ReadRecordHeader(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
uint16_t crc; uint16_t crc;
@ -1113,8 +1087,7 @@ bail:
* NOTE: for data files (types 1, 2, and 3), the actual value may not match * NOTE: for data files (types 1, 2, and 3), the actual value may not match
* up what ProDOS would use, because this doesn't test for sparseness. * up what ProDOS would use, because this doesn't test for sparseness.
*/ */
static void static void Nu_UpdateStorageType(NuArchive* pArchive, NuRecord* pRecord)
Nu_UpdateStorageType(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuError err; NuError err;
NuThread* pThread; NuThread* pThread;
@ -1167,8 +1140,7 @@ bail:
* The position of the file pointer on exit is undefined. The position * The position of the file pointer on exit is undefined. The position
* past the end of the record will be stored in pArchive->currentOffset. * past the end of the record will be stored in pArchive->currentOffset.
*/ */
NuError NuError Nu_WriteRecordHeader(NuArchive* pArchive, NuRecord* pRecord, FILE* fp)
Nu_WriteRecordHeader(NuArchive* pArchive, NuRecord* pRecord, FILE* fp)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
uint16_t crc; uint16_t crc;
@ -1312,8 +1284,7 @@ bail:
* Prepare for a "walk" through the records. This is useful for the * Prepare for a "walk" through the records. This is useful for the
* "read the TOC as you go" method of archive use. * "read the TOC as you go" method of archive use.
*/ */
static NuError static NuError Nu_RecordWalkPrepare(NuArchive* pArchive, NuRecord** ppRecord)
Nu_RecordWalkPrepare(NuArchive* pArchive, NuRecord** ppRecord)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1345,8 +1316,7 @@ bail:
* we read it from the archive file, and add it to the TOC being * we read it from the archive file, and add it to the TOC being
* constructed. * constructed.
*/ */
static NuError static NuError Nu_RecordWalkGetNext(NuArchive* pArchive, NuRecord** ppRecord)
Nu_RecordWalkGetNext(NuArchive* pArchive, NuRecord** ppRecord)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1394,8 +1364,7 @@ bail:
* full table of contents. On an unsuccessful walk, blow away the TOC * full table of contents. On an unsuccessful walk, blow away the TOC
* if we don't have all of it. * if we don't have all of it.
*/ */
static NuError static NuError Nu_RecordWalkFinish(NuArchive* pArchive, NuError walkErr)
Nu_RecordWalkFinish(NuArchive* pArchive, NuError walkErr)
{ {
if (pArchive->haveToc) if (pArchive->haveToc)
return kNuErrNone; return kNuErrNone;
@ -1418,8 +1387,7 @@ Nu_RecordWalkFinish(NuArchive* pArchive, NuError walkErr)
* *
* Uses the "record walk" functions, because they're there. * Uses the "record walk" functions, because they're there.
*/ */
NuError NuError Nu_GetTOCIfNeeded(NuArchive* pArchive)
Nu_GetTOCIfNeeded(NuArchive* pArchive)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -1458,8 +1426,7 @@ bail:
* Run through the entire archive, pulling out the header bits, skipping * Run through the entire archive, pulling out the header bits, skipping
* over the data bits, and calling "contentFunc" for each record. * over the data bits, and calling "contentFunc" for each record.
*/ */
NuError NuError Nu_StreamContents(NuArchive* pArchive, NuCallback contentFunc)
Nu_StreamContents(NuArchive* pArchive, NuCallback contentFunc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord tmpRecord; NuRecord tmpRecord;
@ -1516,8 +1483,8 @@ bail:
* to recreate the original we need to re-add the resource fork so * to recreate the original we need to re-add the resource fork so
* NufxLib knows to make it an extended file. * NufxLib knows to make it an extended file.
*/ */
static NuError static NuError Nu_FakeZeroExtract(NuArchive* pArchive, NuRecord* pRecord,
Nu_FakeZeroExtract(NuArchive* pArchive, NuRecord* pRecord, int threadKind) int threadKind)
{ {
NuError err; NuError err;
NuThread fakeThread; NuThread fakeThread;
@ -1549,8 +1516,7 @@ Nu_FakeZeroExtract(NuArchive* pArchive, NuRecord* pRecord, int threadKind)
/* /*
* Run through the entire archive, extracting the contents. * Run through the entire archive, extracting the contents.
*/ */
NuError NuError Nu_StreamExtract(NuArchive* pArchive)
Nu_StreamExtract(NuArchive* pArchive)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord tmpRecord; NuRecord tmpRecord;
@ -1662,8 +1628,7 @@ bail:
* Test the contents of an archive. Works just like extraction, but we * Test the contents of an archive. Works just like extraction, but we
* don't store anything. * don't store anything.
*/ */
NuError NuError Nu_StreamTest(NuArchive* pArchive)
Nu_StreamTest(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -1686,8 +1651,7 @@ Nu_StreamTest(NuArchive* pArchive)
* This only walks through the "orig" list, so it does not reflect the * This only walks through the "orig" list, so it does not reflect the
* results of un-flushed changes. * results of un-flushed changes.
*/ */
NuError NuError Nu_Contents(NuArchive* pArchive, NuCallback contentFunc)
Nu_Contents(NuArchive* pArchive, NuCallback contentFunc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuRecord* pRecord; NuRecord* pRecord;
@ -1727,8 +1691,7 @@ bail:
* *
* This assumes random access, so it can't be used in streaming mode. * This assumes random access, so it can't be used in streaming mode.
*/ */
static NuError static NuError Nu_ExtractRecordByPtr(NuArchive* pArchive, NuRecord* pRecord)
Nu_ExtractRecordByPtr(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Boolean hasInterestingThread; Boolean hasInterestingThread;
@ -1796,8 +1759,7 @@ bail:
/* /*
* Extract a big buncha files. * Extract a big buncha files.
*/ */
NuError NuError Nu_Extract(NuArchive* pArchive)
Nu_Extract(NuArchive* pArchive)
{ {
NuError err; NuError err;
NuRecord* pRecord = NULL; NuRecord* pRecord = NULL;
@ -1842,8 +1804,7 @@ bail:
/* /*
* Extract a single record. * Extract a single record.
*/ */
NuError NuError Nu_ExtractRecord(NuArchive* pArchive, NuRecordIdx recIdx)
Nu_ExtractRecord(NuArchive* pArchive, NuRecordIdx recIdx)
{ {
NuError err; NuError err;
NuRecord* pRecord; NuRecord* pRecord;
@ -1871,8 +1832,7 @@ bail:
* Test the contents of an archive. Works just like extraction, but we * Test the contents of an archive. Works just like extraction, but we
* don't store anything. * don't store anything.
*/ */
NuError NuError Nu_Test(NuArchive* pArchive)
Nu_Test(NuArchive* pArchive)
{ {
NuError err; NuError err;
@ -1885,8 +1845,7 @@ Nu_Test(NuArchive* pArchive)
/* /*
* Test a single record. * Test a single record.
*/ */
NuError NuError Nu_TestRecord(NuArchive* pArchive, NuRecordIdx recIdx)
Nu_TestRecord(NuArchive* pArchive, NuRecordIdx recIdx)
{ {
NuError err; NuError err;
NuRecord* pRecord; NuRecord* pRecord;
@ -1919,8 +1878,7 @@ bail:
* for records that have been deleted. It will not reflect changes * for records that have been deleted. It will not reflect changes
* made by previous "write" calls, not even SetRecordAttr. * made by previous "write" calls, not even SetRecordAttr.
*/ */
NuError NuError Nu_GetRecord(NuArchive* pArchive, NuRecordIdx recordIdx,
Nu_GetRecord(NuArchive* pArchive, NuRecordIdx recordIdx,
const NuRecord** ppRecord) const NuRecord** ppRecord)
{ {
NuError err; NuError err;
@ -1947,8 +1905,7 @@ bail:
/* /*
* Find the recordIdx of a record by storage name. * Find the recordIdx of a record by storage name.
*/ */
NuError NuError Nu_GetRecordIdxByName(NuArchive* pArchive, const char* name,
Nu_GetRecordIdxByName(NuArchive* pArchive, const char* name,
NuRecordIdx* pRecordIdx) NuRecordIdx* pRecordIdx)
{ {
NuError err; NuError err;
@ -1976,8 +1933,7 @@ bail:
/* /*
* Find the recordIdx of a record by zero-based position. * Find the recordIdx of a record by zero-based position.
*/ */
NuError NuError Nu_GetRecordIdxByPosition(NuArchive* pArchive, uint32_t position,
Nu_GetRecordIdxByPosition(NuArchive* pArchive, uint32_t position,
NuRecordIdx* pRecordIdx) NuRecordIdx* pRecordIdx)
{ {
NuError err; NuError err;
@ -2028,8 +1984,7 @@ bail:
* The record returned will always be from the "copy" set. An error result * The record returned will always be from the "copy" set. An error result
* is returned if the record isn't found. * is returned if the record isn't found.
*/ */
NuError NuError Nu_FindRecordForWriteByIdx(NuArchive* pArchive, NuRecordIdx recIdx,
Nu_FindRecordForWriteByIdx(NuArchive* pArchive, NuRecordIdx recIdx,
NuRecord** ppFoundRecord) NuRecord** ppFoundRecord)
{ {
NuError err; NuError err;
@ -2079,9 +2034,9 @@ bail:
* passed in, then the record will be deleted from the "copy" set (which * passed in, then the record will be deleted from the "copy" set (which
* will be created only if necessary). * will be created only if necessary).
*/ */
static NuError static NuError Nu_HandleAddDuplicateRecord(NuArchive* pArchive,
Nu_HandleAddDuplicateRecord(NuArchive* pArchive, NuRecordSet* pRecordSet, NuRecordSet* pRecordSet, NuRecord* pRecord,
NuRecord* pRecord, const NuFileDetails* pFileDetails) const NuFileDetails* pFileDetails)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuErrorStatus errorStatus; NuErrorStatus errorStatus;
@ -2218,8 +2173,7 @@ bail:
* placed in "*pThreadIdx". If "*ppNewRecord" is non-NULL, 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). * to the newly-created record (this isn't part of the external interface).
*/ */
NuError NuError Nu_AddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails,
Nu_AddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails,
NuRecordIdx* pRecordIdx, NuRecord** ppNewRecord) NuRecordIdx* pRecordIdx, NuRecord** ppNewRecord)
{ {
NuError err; NuError err;
@ -2358,8 +2312,7 @@ bail:
* The caller should have already verified that there isn't another * The caller should have already verified that there isn't another
* "add file" thread mod with the same ThreadID. * "add file" thread mod with the same ThreadID.
*/ */
static NuError static NuError Nu_AddFileThreadMod(NuArchive* pArchive, NuRecord* pRecord,
Nu_AddFileThreadMod(NuArchive* pArchive, NuRecord* pRecord,
const char* pathname, const NuFileDetails* pFileDetails, const char* pathname, const NuFileDetails* pFileDetails,
Boolean fromRsrcFork) Boolean fromRsrcFork)
{ {
@ -2419,8 +2372,7 @@ bail:
* *
* If "pRecordIdx" is non-NULL, it will receive the newly assigned recordID. * If "pRecordIdx" is non-NULL, it will receive the newly assigned recordID.
*/ */
NuError NuError Nu_AddFile(NuArchive* pArchive, const char* pathname,
Nu_AddFile(NuArchive* pArchive, const char* pathname,
const NuFileDetails* pFileDetails, Boolean fromRsrcFork, const NuFileDetails* pFileDetails, Boolean fromRsrcFork,
NuRecordIdx* pRecordIdx) NuRecordIdx* pRecordIdx)
{ {
@ -2561,8 +2513,7 @@ bail:
* We might also want to screen out trailing fssep chars, though the NuFX * We might also want to screen out trailing fssep chars, though the NuFX
* spec doesn't say they're illegal. * spec doesn't say they're illegal.
*/ */
NuError NuError Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname,
Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname,
char fssep) char fssep)
{ {
NuError err; NuError err;
@ -2707,8 +2658,7 @@ bail:
/* /*
* Update a record's attributes with the contents of pRecordAttr. * Update a record's attributes with the contents of pRecordAttr.
*/ */
NuError NuError Nu_SetRecordAttr(NuArchive* pArchive, NuRecordIdx recordIdx,
Nu_SetRecordAttr(NuArchive* pArchive, NuRecordIdx recordIdx,
const NuRecordAttr* pRecordAttr) const NuRecordAttr* pRecordAttr)
{ {
NuError err; NuError err;
@ -2745,8 +2695,7 @@ bail:
/* /*
* Bulk-delete several records, using the selection filter callback. * Bulk-delete several records, using the selection filter callback.
*/ */
NuError NuError Nu_Delete(NuArchive* pArchive)
Nu_Delete(NuArchive* pArchive)
{ {
NuError err; NuError err;
NuSelectionProposal selProposal; NuSelectionProposal selProposal;
@ -2828,8 +2777,7 @@ bail:
/* /*
* Delete an entire record. * Delete an entire record.
*/ */
NuError NuError Nu_DeleteRecord(NuArchive* pArchive, NuRecordIdx recIdx)
Nu_DeleteRecord(NuArchive* pArchive, NuRecordIdx recIdx)
{ {
NuError err; NuError err;
NuRecord* pRecord; NuRecord* pRecord;

View File

@ -19,8 +19,7 @@
/* /*
* Allocate a new DataSource structure. * Allocate a new DataSource structure.
*/ */
static NuError static NuError Nu_DataSourceNew(NuDataSource** ppDataSource)
Nu_DataSourceNew(NuDataSource** ppDataSource)
{ {
Assert(ppDataSource != NULL); Assert(ppDataSource != NULL);
@ -49,8 +48,7 @@ Nu_DataSourceNew(NuDataSource** ppDataSource)
* *
* Returns NULL on error. * Returns NULL on error.
*/ */
NuDataSource* NuDataSource* Nu_DataSourceCopy(NuDataSource* pDataSource)
Nu_DataSourceCopy(NuDataSource* pDataSource)
{ {
Assert(pDataSource->common.refCount >= 1); Assert(pDataSource->common.refCount >= 1);
pDataSource->common.refCount++; pDataSource->common.refCount++;
@ -89,8 +87,7 @@ Nu_DataSourceCopy(NuDataSource* pDataSource)
/* /*
* Free a data source structure, and any type-specific elements. * Free a data source structure, and any type-specific elements.
*/ */
NuError NuError Nu_DataSourceFree(NuDataSource* pDataSource)
Nu_DataSourceFree(NuDataSource* pDataSource)
{ {
if (pDataSource == NULL) if (pDataSource == NULL)
return kNuErrNone; return kNuErrNone;
@ -139,8 +136,7 @@ Nu_DataSourceFree(NuDataSource* pDataSource)
/* /*
* Create a data source for an unopened file. * Create a data source for an unopened file.
*/ */
NuError NuError Nu_DataSourceFile_New(NuThreadFormat threadFormat, uint32_t otherLen,
Nu_DataSourceFile_New(NuThreadFormat threadFormat, uint32_t otherLen,
const char* pathname, Boolean isFromRsrcFork, NuDataSource** ppDataSource) const char* pathname, Boolean isFromRsrcFork, NuDataSource** ppDataSource)
{ {
NuError err; NuError err;
@ -175,8 +171,7 @@ bail:
* Create a data source for an open file at a specific offset. The FILE* * Create a data source for an open file at a specific offset. The FILE*
* must be seekable. * must be seekable.
*/ */
NuError NuError Nu_DataSourceFP_New(NuThreadFormat threadFormat, uint32_t otherLen,
Nu_DataSourceFP_New(NuThreadFormat threadFormat, uint32_t otherLen,
FILE* fp, long offset, long length, NuCallback fcloseFunc, FILE* fp, long offset, long length, NuCallback fcloseFunc,
NuDataSource** ppDataSource) NuDataSource** ppDataSource)
{ {
@ -220,8 +215,7 @@ bail:
* NULL. This is useful for creating empty pre-sized buffers, such as * NULL. This is useful for creating empty pre-sized buffers, such as
* blank comment fields. * blank comment fields.
*/ */
NuError NuError Nu_DataSourceBuffer_New(NuThreadFormat threadFormat, uint32_t otherLen,
Nu_DataSourceBuffer_New(NuThreadFormat threadFormat, uint32_t otherLen,
const uint8_t* buffer, long offset, long length, NuCallback freeFunc, const uint8_t* buffer, long offset, long length, NuCallback freeFunc,
NuDataSource** ppDataSource) NuDataSource** ppDataSource)
{ {
@ -267,8 +261,7 @@ bail:
/* /*
* Get the type of a NuDataSource. * Get the type of a NuDataSource.
*/ */
NuDataSourceType NuDataSourceType Nu_DataSourceGetType(const NuDataSource* pDataSource)
Nu_DataSourceGetType(const NuDataSource* pDataSource)
{ {
Assert(pDataSource != NULL); Assert(pDataSource != NULL);
return pDataSource->sourceType; return pDataSource->sourceType;
@ -277,8 +270,7 @@ Nu_DataSourceGetType(const NuDataSource* pDataSource)
/* /*
* Get the threadFormat for a data source. * Get the threadFormat for a data source.
*/ */
NuThreadFormat NuThreadFormat Nu_DataSourceGetThreadFormat(const NuDataSource* pDataSource)
Nu_DataSourceGetThreadFormat(const NuDataSource* pDataSource)
{ {
Assert(pDataSource != NULL); Assert(pDataSource != NULL);
return pDataSource->common.threadFormat; return pDataSource->common.threadFormat;
@ -287,8 +279,7 @@ Nu_DataSourceGetThreadFormat(const NuDataSource* pDataSource)
/* /*
* Get "dataLen" from a dataSource. * Get "dataLen" from a dataSource.
*/ */
uint32_t uint32_t Nu_DataSourceGetDataLen(const NuDataSource* pDataSource)
Nu_DataSourceGetDataLen(const NuDataSource* pDataSource)
{ {
Assert(pDataSource != NULL); Assert(pDataSource != NULL);
@ -303,8 +294,7 @@ Nu_DataSourceGetDataLen(const NuDataSource* pDataSource)
/* /*
* Get "otherLen" from a dataSource. * Get "otherLen" from a dataSource.
*/ */
uint32_t uint32_t Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource)
Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource)
{ {
Assert(pDataSource != NULL); Assert(pDataSource != NULL);
return pDataSource->common.otherLen; return pDataSource->common.otherLen;
@ -313,8 +303,7 @@ Nu_DataSourceGetOtherLen(const NuDataSource* pDataSource)
/* /*
* Change the "otherLen" value. * Change the "otherLen" value.
*/ */
void void Nu_DataSourceSetOtherLen(NuDataSource* pDataSource, long otherLen)
Nu_DataSourceSetOtherLen(NuDataSource* pDataSource, long otherLen)
{ {
Assert(pDataSource != NULL && otherLen > 0); Assert(pDataSource != NULL && otherLen > 0);
pDataSource->common.otherLen = otherLen; pDataSource->common.otherLen = otherLen;
@ -324,8 +313,7 @@ Nu_DataSourceSetOtherLen(NuDataSource* pDataSource, long otherLen)
/* /*
* Get the "raw CRC" value. * Get the "raw CRC" value.
*/ */
uint16_t uint16_t Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource)
Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource)
{ {
Assert(pDataSource != NULL); Assert(pDataSource != NULL);
return pDataSource->common.rawCrc; return pDataSource->common.rawCrc;
@ -335,8 +323,7 @@ Nu_DataSourceGetRawCrc(const NuDataSource* pDataSource)
* Set the "raw CRC" value. You would want to do this if the input was * Set the "raw CRC" value. You would want to do this if the input was
* already-compressed data, and you wanted to propagate the thread CRC. * already-compressed data, and you wanted to propagate the thread CRC.
*/ */
void void Nu_DataSourceSetRawCrc(NuDataSource* pDataSource, uint16_t crc)
Nu_DataSourceSetRawCrc(NuDataSource* pDataSource, uint16_t crc)
{ {
Assert(pDataSource != NULL); Assert(pDataSource != NULL);
pDataSource->common.rawCrc = crc; pDataSource->common.rawCrc = crc;
@ -346,8 +333,8 @@ Nu_DataSourceSetRawCrc(NuDataSource* pDataSource, uint16_t crc)
/* /*
* Prepare a data source for action. * Prepare a data source for action.
*/ */
NuError NuError Nu_DataSourcePrepareInput(NuArchive* pArchive,
Nu_DataSourcePrepareInput(NuArchive* pArchive, NuDataSource* pDataSource) NuDataSource* pDataSource)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
FILE* fileFp = NULL; FILE* fileFp = NULL;
@ -403,8 +390,7 @@ bail:
* call will take care of this eventually -- but for normal operation on * call will take care of this eventually -- but for normal operation on
* a large number of files, it's vital. * a large number of files, it's vital.
*/ */
void void Nu_DataSourceUnPrepareInput(NuArchive* pArchive, NuDataSource* pDataSource)
Nu_DataSourceUnPrepareInput(NuArchive* pArchive, NuDataSource* pDataSource)
{ {
if (Nu_DataSourceGetType(pDataSource) != kNuDataSourceFromFile) if (Nu_DataSourceGetType(pDataSource) != kNuDataSourceFromFile)
return; return;
@ -420,8 +406,7 @@ Nu_DataSourceUnPrepareInput(NuArchive* pArchive, NuDataSource* pDataSource)
/* /*
* Get the pathname from a "from-file" dataSource. * Get the pathname from a "from-file" dataSource.
*/ */
const char* const char* Nu_DataSourceFile_GetPathname(NuDataSource* pDataSource)
Nu_DataSourceFile_GetPathname(NuDataSource* pDataSource)
{ {
Assert(pDataSource != NULL); Assert(pDataSource != NULL);
Assert(pDataSource->sourceType == kNuDataSourceFromFile); Assert(pDataSource->sourceType == kNuDataSourceFromFile);
@ -434,8 +419,8 @@ Nu_DataSourceFile_GetPathname(NuDataSource* pDataSource)
/* /*
* Read a block of data from a dataSource. * Read a block of data from a dataSource.
*/ */
NuError NuError Nu_DataSourceGetBlock(NuDataSource* pDataSource, uint8_t* buf,
Nu_DataSourceGetBlock(NuDataSource* pDataSource, uint8_t* buf, uint32_t len) uint32_t len)
{ {
NuError err; NuError err;
@ -479,8 +464,7 @@ Nu_DataSourceGetBlock(NuDataSource* pDataSource, uint8_t* buf, uint32_t len)
/* /*
* Rewind a data source to the start of its input. * Rewind a data source to the start of its input.
*/ */
NuError NuError Nu_DataSourceRewind(NuDataSource* pDataSource)
Nu_DataSourceRewind(NuDataSource* pDataSource)
{ {
NuError err; NuError err;
@ -518,8 +502,7 @@ Nu_DataSourceRewind(NuDataSource* pDataSource)
/* /*
* Allocate a new DataSink structure. * Allocate a new DataSink structure.
*/ */
static NuError static NuError Nu_DataSinkNew(NuDataSink** ppDataSink)
Nu_DataSinkNew(NuDataSink** ppDataSink)
{ {
Assert(ppDataSink != NULL); Assert(ppDataSink != NULL);
@ -536,8 +519,7 @@ Nu_DataSinkNew(NuDataSink** ppDataSink)
/* /*
* Free a data sink structure, and any type-specific elements. * Free a data sink structure, and any type-specific elements.
*/ */
NuError NuError Nu_DataSinkFree(NuDataSink* pDataSink)
Nu_DataSinkFree(NuDataSink* pDataSink)
{ {
if (pDataSink == NULL) if (pDataSink == NULL)
return kNuErrNone; return kNuErrNone;
@ -568,9 +550,8 @@ Nu_DataSinkFree(NuDataSink* pDataSink)
/* /*
* Create a data sink for an unopened file. * Create a data sink for an unopened file.
*/ */
NuError NuError Nu_DataSinkFile_New(Boolean doExpand, NuValue convertEOL,
Nu_DataSinkFile_New(Boolean doExpand, NuValue convertEOL, const char* pathname, const char* pathname, char fssep, NuDataSink** ppDataSink)
char fssep, NuDataSink** ppDataSink)
{ {
NuError err; NuError err;
@ -607,8 +588,7 @@ bail:
/* /*
* Create a data sink based on a file pointer. * Create a data sink based on a file pointer.
*/ */
NuError NuError Nu_DataSinkFP_New(Boolean doExpand, NuValue convertEOL, FILE* fp,
Nu_DataSinkFP_New(Boolean doExpand, NuValue convertEOL, FILE* fp,
NuDataSink** ppDataSink) NuDataSink** ppDataSink)
{ {
NuError err; NuError err;
@ -642,9 +622,8 @@ bail:
/* /*
* Create a data sink for a buffer in memory. * Create a data sink for a buffer in memory.
*/ */
NuError NuError Nu_DataSinkBuffer_New(Boolean doExpand, NuValue convertEOL,
Nu_DataSinkBuffer_New(Boolean doExpand, NuValue convertEOL, uint8_t* buffer, uint8_t* buffer, uint32_t bufLen, NuDataSink** ppDataSink)
uint32_t bufLen, NuDataSink** ppDataSink)
{ {
NuError err; NuError err;
@ -681,8 +660,7 @@ bail:
/* /*
* Create a data sink that goes nowhere. * Create a data sink that goes nowhere.
*/ */
NuError NuError Nu_DataSinkVoid_New(Boolean doExpand, NuValue convertEOL,
Nu_DataSinkVoid_New(Boolean doExpand, NuValue convertEOL,
NuDataSink** ppDataSink) NuDataSink** ppDataSink)
{ {
NuError err; NuError err;
@ -706,8 +684,7 @@ bail:
/* /*
* Get the type of a NuDataSink. * Get the type of a NuDataSink.
*/ */
NuDataSinkType NuDataSinkType Nu_DataSinkGetType(const NuDataSink* pDataSink)
Nu_DataSinkGetType(const NuDataSink* pDataSink)
{ {
Assert(pDataSink != NULL); Assert(pDataSink != NULL);
return pDataSink->sinkType; return pDataSink->sinkType;
@ -717,8 +694,7 @@ Nu_DataSinkGetType(const NuDataSink* pDataSink)
/* /*
* Return the "doExpand" parameter from any kind of sink. * Return the "doExpand" parameter from any kind of sink.
*/ */
Boolean Boolean Nu_DataSinkGetDoExpand(const NuDataSink* pDataSink)
Nu_DataSinkGetDoExpand(const NuDataSink* pDataSink)
{ {
return pDataSink->common.doExpand; return pDataSink->common.doExpand;
} }
@ -726,8 +702,7 @@ Nu_DataSinkGetDoExpand(const NuDataSink* pDataSink)
/* /*
* Return the "convertEOL" parameter from any kind of sink. * Return the "convertEOL" parameter from any kind of sink.
*/ */
NuValue NuValue Nu_DataSinkGetConvertEOL(const NuDataSink* pDataSink)
Nu_DataSinkGetConvertEOL(const NuDataSink* pDataSink)
{ {
return pDataSink->common.convertEOL; return pDataSink->common.convertEOL;
} }
@ -735,8 +710,7 @@ Nu_DataSinkGetConvertEOL(const NuDataSink* pDataSink)
/* /*
* Return the #of bytes written to the sink. * Return the #of bytes written to the sink.
*/ */
uint32_t uint32_t Nu_DataSinkGetOutCount(const NuDataSink* pDataSink)
Nu_DataSinkGetOutCount(const NuDataSink* pDataSink)
{ {
return pDataSink->common.outCount; return pDataSink->common.outCount;
} }
@ -745,8 +719,7 @@ Nu_DataSinkGetOutCount(const NuDataSink* pDataSink)
/* /*
* Get "pathname" from a to-file sink. * Get "pathname" from a to-file sink.
*/ */
const char* const char* Nu_DataSinkFile_GetPathname(const NuDataSink* pDataSink)
Nu_DataSinkFile_GetPathname(const NuDataSink* pDataSink)
{ {
Assert(pDataSink != NULL); Assert(pDataSink != NULL);
Assert(pDataSink->sinkType == kNuDataSinkToFile); Assert(pDataSink->sinkType == kNuDataSinkToFile);
@ -757,8 +730,7 @@ Nu_DataSinkFile_GetPathname(const NuDataSink* pDataSink)
/* /*
* Get "fssep" from a to-file sink. * Get "fssep" from a to-file sink.
*/ */
char char Nu_DataSinkFile_GetFssep(const NuDataSink* pDataSink)
Nu_DataSinkFile_GetFssep(const NuDataSink* pDataSink)
{ {
Assert(pDataSink != NULL); Assert(pDataSink != NULL);
Assert(pDataSink->sinkType == kNuDataSinkToFile); Assert(pDataSink->sinkType == kNuDataSinkToFile);
@ -769,8 +741,7 @@ Nu_DataSinkFile_GetFssep(const NuDataSink* pDataSink)
/* /*
* Get the "fp" for a file sink. * Get the "fp" for a file sink.
*/ */
FILE* FILE* Nu_DataSinkFile_GetFP(const NuDataSink* pDataSink)
Nu_DataSinkFile_GetFP(const NuDataSink* pDataSink)
{ {
Assert(pDataSink != NULL); Assert(pDataSink != NULL);
Assert(pDataSink->sinkType == kNuDataSinkToFile); Assert(pDataSink->sinkType == kNuDataSinkToFile);
@ -781,8 +752,7 @@ Nu_DataSinkFile_GetFP(const NuDataSink* pDataSink)
/* /*
* Set the "fp" for a file sink. * Set the "fp" for a file sink.
*/ */
void void Nu_DataSinkFile_SetFP(NuDataSink* pDataSink, FILE* fp)
Nu_DataSinkFile_SetFP(NuDataSink* pDataSink, FILE* fp)
{ {
Assert(pDataSink != NULL); Assert(pDataSink != NULL);
Assert(pDataSink->sinkType == kNuDataSinkToFile); Assert(pDataSink->sinkType == kNuDataSinkToFile);
@ -793,8 +763,7 @@ Nu_DataSinkFile_SetFP(NuDataSink* pDataSink, FILE* fp)
/* /*
* Close a to-file sink. * Close a to-file sink.
*/ */
void void Nu_DataSinkFile_Close(NuDataSink* pDataSink)
Nu_DataSinkFile_Close(NuDataSink* pDataSink)
{ {
Assert(pDataSink != NULL); Assert(pDataSink != NULL);
@ -808,8 +777,8 @@ Nu_DataSinkFile_Close(NuDataSink* pDataSink)
/* /*
* Write a block of data to a DataSink. * Write a block of data to a DataSink.
*/ */
NuError NuError Nu_DataSinkPutBlock(NuDataSink* pDataSink, const uint8_t* buf,
Nu_DataSinkPutBlock(NuDataSink* pDataSink, const uint8_t* buf, uint32_t len) uint32_t len)
{ {
NuError err; NuError err;
@ -856,8 +825,7 @@ Nu_DataSinkPutBlock(NuDataSink* pDataSink, const uint8_t* buf, uint32_t len)
/* /*
* Figure out if one of our earlier writes has failed. * Figure out if one of our earlier writes has failed.
*/ */
NuError NuError Nu_DataSinkGetError(NuDataSink* pDataSink)
Nu_DataSinkGetError(NuDataSink* pDataSink)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;

View File

@ -117,8 +117,7 @@ typedef struct SQState {
* *
* Returns kNuSQEOFToken as the value when we're out of data. * Returns kNuSQEOFToken as the value when we're out of data.
*/ */
static NuError static NuError Nu_SQGetcCRC(SQState* pSqState, int* pSym)
Nu_SQGetcCRC(SQState* pSqState, int* pSym)
{ {
NuError err; NuError err;
uint8_t c; uint8_t c;
@ -148,8 +147,7 @@ Nu_SQGetcCRC(SQState* pSqState, int* pSym)
* *
* Returns kNuSQEOFToken in "*pSum" when we reach the end of the input. * Returns kNuSQEOFToken in "*pSum" when we reach the end of the input.
*/ */
static NuError static NuError Nu_SQGetcRLE(SQState* pSqState, int* pSym)
Nu_SQGetcRLE(SQState* pSqState, int* pSym)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
int likeCount, newSym; int likeCount, newSym;
@ -275,8 +273,7 @@ bail:
/* /*
* Return the greater of two integers. * Return the greater of two integers.
*/ */
static int static int Nu_SQMax(int a, int b)
Nu_SQMax(int a, int b)
{ {
if (a > b) if (a > b)
return a; return a;
@ -289,8 +286,7 @@ Nu_SQMax(int a, int b)
* Priority is given to weight, then depth. "a" and "b" are heaps, * Priority is given to weight, then depth. "a" and "b" are heaps,
* so we only need to look at the root element. * so we only need to look at the root element.
*/ */
static int static int Nu_SQCmpTrees(SQState* pSqState, int a, int b)
Nu_SQCmpTrees(SQState* pSqState, int a, int b)
{ {
if (pSqState->node[a].weight > pSqState->node[b].weight) if (pSqState->node[a].weight > pSqState->node[b].weight)
return true; return true;
@ -312,8 +308,7 @@ Nu_SQCmpTrees(SQState* pSqState, int a, int b)
/* /*
* Recursively make a heap from a heap with a new top. * Recursively make a heap from a heap with a new top.
*/ */
static void static void Nu_SQHeapAdjust(SQState* pSqState, int list[], int top, int bottom)
Nu_SQHeapAdjust(SQState* pSqState, int list[], int top, int bottom)
{ {
int k, temp; int k, temp;
@ -337,8 +332,7 @@ Nu_SQHeapAdjust(SQState* pSqState, int list[], int top, int bottom)
/* /*
* Create a heap. * Create a heap.
*/ */
static void static void Nu_SQHeap(SQState* pSqState, int list[], int length)
Nu_SQHeap(SQState* pSqState, int list[], int length)
{ {
int i; int i;
@ -365,8 +359,7 @@ Nu_SQHeap(SQState* pSqState, int list[], int length)
* moving the last element over the top element and * moving the last element over the top element and
* reheaping the shorter list. * reheaping the shorter list.
*/ */
static void static void Nu_SQBuildTree(SQState* pSqState, int list[], int len)
Nu_SQBuildTree(SQState* pSqState, int list[], int len)
{ {
int freenode; /* next free node in tree */ int freenode; /* next free node in tree */
EncTreeNode* frnp; /* free node pointer */ EncTreeNode* frnp; /* free node pointer */
@ -422,8 +415,7 @@ Nu_SQBuildTree(SQState* pSqState, int list[], int len)
* *
* Returns zero on success, nonzero if codes are too long. * Returns zero on success, nonzero if codes are too long.
*/ */
static int static int Nu_SQBuildEncTable(SQState* pSqState, int level, int root)
Nu_SQBuildEncTable(SQState* pSqState, int level, int root)
{ {
int l, r; int l, r;
@ -470,8 +462,7 @@ Nu_SQBuildEncTable(SQState* pSqState, int level, int root)
* the codes will fit in an unsigned integer. Rescaling is * the codes will fit in an unsigned integer. Rescaling is
* used if necessary to limit the code length. * used if necessary to limit the code length.
*/ */
static void static void Nu_SQScale(SQState* pSqState, int ceiling)
Nu_SQScale(SQState* pSqState, int ceiling)
{ {
int i; int i;
int wt, ovflw, divisor; int wt, ovflw, divisor;
@ -510,8 +501,7 @@ Nu_SQScale(SQState* pSqState, int ceiling)
* Build a frequency table from the post-RLE input stream, then generate * Build a frequency table from the post-RLE input stream, then generate
* an encoding tree from the results. * an encoding tree from the results.
*/ */
static NuError static NuError Nu_SQComputeHuffTree(SQState* pSqState)
Nu_SQComputeHuffTree(SQState* pSqState)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
int btreeList[kNuSQNumVals]; /* list of intermediate binary trees */ int btreeList[kNuSQNumVals]; /* list of intermediate binary trees */
@ -610,8 +600,8 @@ bail:
* Compress data from input to output, using the values in the "code" * Compress data from input to output, using the values in the "code"
* and "codeLen" arrays. * and "codeLen" arrays.
*/ */
static NuError static NuError Nu_SQCompressInput(SQState* pSqState, FILE* fp,
Nu_SQCompressInput(SQState* pSqState, FILE* fp, long* pCompressedLen) long* pCompressedLen)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
int sym = kNuSQEOFToken-1; int sym = kNuSQEOFToken-1;
@ -661,8 +651,7 @@ bail:
/* /*
* Write a 16-bit value in little-endian order. * Write a 16-bit value in little-endian order.
*/ */
static NuError static NuError Nu_SQWriteShort(FILE* outfp, short val)
Nu_SQWriteShort(FILE* outfp, short val)
{ {
NuError err; NuError err;
uint8_t tmpc; uint8_t tmpc;
@ -689,8 +678,7 @@ bail:
* it an empty file. "xsq" works fine, creating an empty tree that * it an empty file. "xsq" works fine, creating an empty tree that
* "xusq" unpacks. * "xusq" unpacks.
*/ */
NuError NuError Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc) uint32_t srcLen, uint32_t* pDstLen, uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -842,8 +830,7 @@ typedef struct USQState {
/* /*
* Decode the next symbol from the Huffman stream. * Decode the next symbol from the Huffman stream.
*/ */
static NuError static NuError Nu_USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
Nu_USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
{ {
short val = 0; short val = 0;
int bits, bitPosn; int bits, bitPosn;
@ -879,8 +866,7 @@ Nu_USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
/* /*
* Read two bytes of signed data out of the buffer. * Read two bytes of signed data out of the buffer.
*/ */
static inline NuError static inline NuError Nu_USQReadShort(USQState* pUsqState, short* pShort)
Nu_USQReadShort(USQState* pUsqState, short* pShort)
{ {
if (pUsqState->dataInBuffer < 2) if (pUsqState->dataInBuffer < 2)
return kNuErrBufferUnderrun; return kNuErrBufferUnderrun;
@ -898,8 +884,7 @@ Nu_USQReadShort(USQState* pUsqState, short* pShort)
* Because we have a stop symbol, knowing the uncompressed length of * Because we have a stop symbol, knowing the uncompressed length of
* the file is not essential. * the file is not essential.
*/ */
NuError NuError Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc) const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;

View File

@ -26,8 +26,7 @@
* This high-bit-ism was also done for disk archives by most older versions * This high-bit-ism was also done for disk archives by most older versions
* of ShrinkIt. * of ShrinkIt.
*/ */
void void Nu_StripHiIfAllSet(char* str)
Nu_StripHiIfAllSet(char* str)
{ {
uint8_t* cp; uint8_t* cp;
@ -44,8 +43,7 @@ Nu_StripHiIfAllSet(char* str)
* Decide if a thread is pre-sized (i.e. has a fixed maximum size with a * Decide if a thread is pre-sized (i.e. has a fixed maximum size with a
* lesser amount of uncompressed data within) based on the threadID. * lesser amount of uncompressed data within) based on the threadID.
*/ */
Boolean Boolean Nu_IsPresizedThreadID(NuThreadID threadID)
Nu_IsPresizedThreadID(NuThreadID threadID)
{ {
if (threadID == kNuThreadIDFilename || threadID == kNuThreadIDComment) if (threadID == kNuThreadIDFilename || threadID == kNuThreadIDComment)
return true; return true;
@ -58,8 +56,7 @@ Nu_IsPresizedThreadID(NuThreadID threadID)
* Return an indication of whether the type of thread specified by ThreadID * Return an indication of whether the type of thread specified by ThreadID
* should ever be compressed. Right now, that's only data-class threads. * should ever be compressed. Right now, that's only data-class threads.
*/ */
Boolean Boolean Nu_IsCompressibleThreadID(NuThreadID threadID)
Nu_IsCompressibleThreadID(NuThreadID threadID)
{ {
if (NuThreadIDGetClass(threadID) == kNuThreadClassData) if (NuThreadIDGetClass(threadID) == kNuThreadClassData)
return true; return true;
@ -72,8 +69,7 @@ Nu_IsCompressibleThreadID(NuThreadID threadID)
* Decide if the thread has a CRC, based on the record version and the * Decide if the thread has a CRC, based on the record version and the
* threadID. * threadID.
*/ */
Boolean Boolean Nu_ThreadHasCRC(long recordVersion, NuThreadID threadID)
Nu_ThreadHasCRC(long recordVersion, NuThreadID threadID)
{ {
return recordVersion >= 3 && return recordVersion >= 3 &&
NuThreadIDGetClass(threadID) == kNuThreadClassData; NuThreadIDGetClass(threadID) == kNuThreadClassData;
@ -83,8 +79,7 @@ Nu_ThreadHasCRC(long recordVersion, NuThreadID threadID)
/* /*
* Search through a given NuRecord for the specified thread. * Search through a given NuRecord for the specified thread.
*/ */
NuError NuError Nu_FindThreadByIdx(const NuRecord* pRecord, NuThreadIdx thread,
Nu_FindThreadByIdx(const NuRecord* pRecord, NuThreadIdx thread,
NuThread** ppThread) NuThread** ppThread)
{ {
NuThread* pThread; NuThread* pThread;
@ -108,8 +103,7 @@ Nu_FindThreadByIdx(const NuRecord* pRecord, NuThreadIdx thread,
* Search through a given NuRecord for the first thread with a matching * Search through a given NuRecord for the first thread with a matching
* threadID. * threadID.
*/ */
NuError NuError Nu_FindThreadByID(const NuRecord* pRecord, NuThreadID threadID,
Nu_FindThreadByID(const NuRecord* pRecord, NuThreadID threadID,
NuThread** ppThread) NuThread** ppThread)
{ {
NuThread* pThread; NuThread* pThread;
@ -132,8 +126,7 @@ Nu_FindThreadByID(const NuRecord* pRecord, NuThreadID threadID,
/* /*
* Copy the contents of a NuThread. * Copy the contents of a NuThread.
*/ */
void void Nu_CopyThreadContents(NuThread* pDstThread, const NuThread* pSrcThread)
Nu_CopyThreadContents(NuThread* pDstThread, const NuThread* pSrcThread)
{ {
Assert(pDstThread != NULL); Assert(pDstThread != NULL);
Assert(pSrcThread != NULL); Assert(pSrcThread != NULL);
@ -151,8 +144,8 @@ Nu_CopyThreadContents(NuThread* pDstThread, const NuThread* pSrcThread)
/* /*
* Read a single thread header from the archive. * Read a single thread header from the archive.
*/ */
static NuError static NuError Nu_ReadThreadHeader(NuArchive* pArchive, NuThread* pThread,
Nu_ReadThreadHeader(NuArchive* pArchive, NuThread* pThread, uint16_t* pCrc) uint16_t* pCrc)
{ {
FILE* fp; FILE* fp;
@ -184,8 +177,8 @@ Nu_ReadThreadHeader(NuArchive* pArchive, NuThread* pThread, uint16_t* pCrc)
* have used a linked list like NuLib, but that doesn't really provide any * have used a linked list like NuLib, but that doesn't really provide any
* benefit for us, and adds complexity. * benefit for us, and adds complexity.
*/ */
NuError NuError Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord,
Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, uint16_t* pCrc) uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuThread* pThread; NuThread* pThread;
@ -306,9 +299,8 @@ bail:
/* /*
* Write a single thread header to the archive. * Write a single thread header to the archive.
*/ */
static NuError static NuError Nu_WriteThreadHeader(NuArchive* pArchive,
Nu_WriteThreadHeader(NuArchive* pArchive, const NuThread* pThread, FILE* fp, const NuThread* pThread, FILE* fp, uint16_t* pCrc)
uint16_t* pCrc)
{ {
Assert(pArchive != NULL); Assert(pArchive != NULL);
Assert(pThread != NULL); Assert(pThread != NULL);
@ -332,8 +324,7 @@ Nu_WriteThreadHeader(NuArchive* pArchive, const NuThread* pThread, FILE* fp,
* effect, we promote all threads to "real" status. We update the * effect, we promote all threads to "real" status. We update the
* "fake" count in pRecord accordingly. * "fake" count in pRecord accordingly.
*/ */
NuError NuError Nu_WriteThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, FILE* fp,
Nu_WriteThreadHeaders(NuArchive* pArchive, NuRecord* pRecord, FILE* fp,
uint16_t* pCrc) uint16_t* pCrc)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -366,8 +357,7 @@ bail:
* Requires that the pArchive->currentOffset be set to the offset * Requires that the pArchive->currentOffset be set to the offset
* immediately after the last of the thread headers. * immediately after the last of the thread headers.
*/ */
NuError NuError Nu_ComputeThreadData(NuArchive* pArchive, NuRecord* pRecord)
Nu_ComputeThreadData(NuArchive* pArchive, NuRecord* pRecord)
{ {
NuThread* pThread; NuThread* pThread;
long fileOffset, count; long fileOffset, count;
@ -407,8 +397,7 @@ Nu_ComputeThreadData(NuArchive* pArchive, NuRecord* pRecord)
* show to the application. (Someday I'll get AndyN for putting me * show to the application. (Someday I'll get AndyN for putting me
* through this...) * through this...)
*/ */
NuError NuError Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord, long numThreads)
Nu_ScanThreads(NuArchive* pArchive, NuRecord* pRecord, long numThreads)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuThread* pThread; NuThread* pThread;
@ -494,8 +483,7 @@ bail:
* assumes that the file pointer is set to the start of the thread's data * assumes that the file pointer is set to the start of the thread's data
* already. * already.
*/ */
NuError NuError Nu_SkipThread(NuArchive* pArchive, const NuRecord* pRecord,
Nu_SkipThread(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread) const NuThread* pThread)
{ {
NuError err; NuError err;
@ -522,9 +510,9 @@ Nu_SkipThread(NuArchive* pArchive, const NuRecord* pRecord,
* If the archive is a stream, the stream must be positioned at the * If the archive is a stream, the stream must be positioned at the
* start of pThread's data. If not, it will be seeked first. * start of pThread's data. If not, it will be seeked first.
*/ */
static NuError static NuError Nu_ExtractThreadToDataSink(NuArchive* pArchive,
Nu_ExtractThreadToDataSink(NuArchive* pArchive, const NuRecord* pRecord, const NuRecord* pRecord, const NuThread* pThread,
const NuThread* pThread, NuProgressData* pProgress, NuDataSink* pDataSink) NuProgressData* pProgress, NuDataSink* pDataSink)
{ {
NuError err; NuError err;
NuFunnel* pFunnel = NULL; NuFunnel* pFunnel = NULL;
@ -576,9 +564,8 @@ bail:
* filters for every thread, which means we can reject specific kinds * filters for every thread, which means we can reject specific kinds
* of forks and/or give them different names. This is a good thing. * of forks and/or give them different names. This is a good thing.
*/ */
static NuError static NuError Nu_ExtractThreadCommon(NuArchive* pArchive,
Nu_ExtractThreadCommon(NuArchive* pArchive, const NuRecord* pRecord, const NuRecord* pRecord, const NuThread* pThread, NuDataSink* pDataSink)
const NuThread* pThread, NuDataSink* pDataSink)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuSelectionProposal selProposal; NuSelectionProposal selProposal;
@ -785,8 +772,7 @@ bail:
* *
* Streaming archives must be properly positioned. * Streaming archives must be properly positioned.
*/ */
NuError NuError Nu_ExtractThreadBulk(NuArchive* pArchive, const NuRecord* pRecord,
Nu_ExtractThreadBulk(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread) const NuThread* pThread)
{ {
NuError err; NuError err;
@ -827,8 +813,7 @@ bail:
/* /*
* Extract a thread, given the IDs and a data sink. * Extract a thread, given the IDs and a data sink.
*/ */
NuError NuError Nu_ExtractThread(NuArchive* pArchive, NuThreadIdx threadIdx,
Nu_ExtractThread(NuArchive* pArchive, NuThreadIdx threadIdx,
NuDataSink* pDataSink) NuDataSink* pDataSink)
{ {
NuError err; NuError err;
@ -872,9 +857,8 @@ bail:
* *
* If a matching threadID is found, this returns an error. * If a matching threadID is found, this returns an error.
*/ */
static NuError static NuError Nu_FindNoFutureThread(NuArchive* pArchive,
Nu_FindNoFutureThread(NuArchive* pArchive, const NuRecord* pRecord, const NuRecord* pRecord, NuThreadID threadID)
NuThreadID threadID)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
const NuThread* pThread; const NuThread* pThread;
@ -927,9 +911,8 @@ bail:
/* /*
* Like Nu_FindNoFutureThread, but tests against a whole class. * Like Nu_FindNoFutureThread, but tests against a whole class.
*/ */
static NuError static NuError Nu_FindNoFutureThreadClass(NuArchive* pArchive,
Nu_FindNoFutureThreadClass(NuArchive* pArchive, const NuRecord* pRecord, const NuRecord* pRecord, long threadClass)
long threadClass)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
const NuThread* pThread; const NuThread* pThread;
@ -988,9 +971,8 @@ bail:
* The record and thread returned will always be from the "copy" set. An * The record and thread returned will always be from the "copy" set. An
* error result is returned if the record and thread aren't found. * error result is returned if the record and thread aren't found.
*/ */
static NuError static NuError Nu_FindThreadForWriteByIdx(NuArchive* pArchive,
Nu_FindThreadForWriteByIdx(NuArchive* pArchive, NuThreadIdx threadIdx, NuThreadIdx threadIdx, NuRecord** ppFoundRecord, NuThread** ppFoundThread)
NuRecord** ppFoundRecord, NuThread** ppFoundThread)
{ {
NuError err; NuError err;
@ -1029,8 +1011,7 @@ bail:
* *
* Returns with an error (kNuErrThreadAdd) if it's not okay. * Returns with an error (kNuErrThreadAdd) if it's not okay.
*/ */
NuError NuError Nu_OkayToAddThread(NuArchive* pArchive, const NuRecord* pRecord,
Nu_OkayToAddThread(NuArchive* pArchive, const NuRecord* pRecord,
NuThreadID threadID) NuThreadID threadID)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1094,9 +1075,8 @@ bail:
* On success, the NuThreadIdx of the newly-created record will be placed * On success, the NuThreadIdx of the newly-created record will be placed
* in "*pThreadIdx", and "pDataSource" will be owned by NufxLib. * in "*pThreadIdx", and "pDataSource" will be owned by NufxLib.
*/ */
NuError NuError Nu_AddThread(NuArchive* pArchive, NuRecordIdx recIdx,
Nu_AddThread(NuArchive* pArchive, NuRecordIdx recIdx, NuThreadID threadID, NuThreadID threadID, NuDataSource* pDataSource, NuThreadIdx* pThreadIdx)
NuDataSource* pDataSource, NuThreadIdx* pThreadIdx)
{ {
NuError err; NuError err;
NuRecord* pRecord; NuRecord* pRecord;
@ -1194,8 +1174,7 @@ bail:
* You aren't allowed to update threads that have been deleted. Updating * You aren't allowed to update threads that have been deleted. Updating
* newly-added threads isn't possible, since they aren't really threads yet. * newly-added threads isn't possible, since they aren't really threads yet.
*/ */
NuError NuError Nu_UpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx,
Nu_UpdatePresizedThread(NuArchive* pArchive, NuThreadIdx threadIdx,
NuDataSource* pDataSource, long* pMaxLen) NuDataSource* pDataSource, long* pMaxLen)
{ {
NuError err; NuError err;
@ -1322,8 +1301,7 @@ bail:
* later on. Besides, it's sort of handy to hang on to the filename for * later on. Besides, it's sort of handy to hang on to the filename for
* as long as possible. * as long as possible.
*/ */
NuError NuError Nu_DeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx)
Nu_DeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx)
{ {
NuError err; NuError err;
NuThreadMod* pThreadMod = NULL; NuThreadMod* pThreadMod = NULL;

View File

@ -14,8 +14,7 @@
/* /*
* Get a configurable parameter. * Get a configurable parameter.
*/ */
NuError NuError Nu_GetValue(NuArchive* pArchive, NuValueID ident, NuValue* pValue)
Nu_GetValue(NuArchive* pArchive, NuValueID ident, NuValue* pValue)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -82,8 +81,7 @@ bail:
/* /*
* Set a configurable parameter. * Set a configurable parameter.
*/ */
NuError NuError Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
Nu_SetValue(NuArchive* pArchive, NuValueID ident, NuValue value)
{ {
NuError err = kNuErrInvalidArg; NuError err = kNuErrInvalidArg;
@ -225,8 +223,7 @@ bail:
* pry into pArchive to get at (like the archive type) or get the master * pry into pArchive to get at (like the archive type) or get the master
* header (like the number of records). * header (like the number of records).
*/ */
NuError NuError Nu_GetAttr(NuArchive* pArchive, NuAttrID ident, NuAttr* pAttr)
Nu_GetAttr(NuArchive* pArchive, NuAttrID ident, NuAttr* pAttr)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
if (pAttr == NULL) if (pAttr == NULL)
@ -260,8 +257,8 @@ bail:
* *
* Unsupported compression types cause a warning to be flagged. * Unsupported compression types cause a warning to be flagged.
*/ */
NuThreadFormat NuThreadFormat Nu_ConvertCompressValToFormat(NuArchive* pArchive,
Nu_ConvertCompressValToFormat(NuArchive* pArchive, NuValue compValue) NuValue compValue)
{ {
NuThreadFormat threadFormat; NuThreadFormat threadFormat;
Boolean unsup = false; Boolean unsup = false;

View File

@ -23,9 +23,8 @@ static const char gNuBuildFlags[] = "-";
/* /*
* Return the version number, date built, and build flags. * Return the version number, date built, and build flags.
*/ */
NuError NuError Nu_GetVersion(long* pMajorVersion, long* pMinorVersion,
Nu_GetVersion(long* pMajorVersion, long* pMinorVersion, long* pBugVersion, long* pBugVersion, const char** ppBuildDate, const char** ppBuildFlags)
const char** ppBuildDate, const char** ppBuildFlags)
{ {
if (pMajorVersion != NULL) if (pMajorVersion != NULL)
*pMajorVersion = kNuVersionMajor; *pMajorVersion = kNuVersionMajor;

View File

@ -14,8 +14,7 @@ static NuError AddToArchive(NulibState* pState, NuArchive* pArchive);
/* /*
* Add the specified files to a new or existing archive. * Add the specified files to a new or existing archive.
*/ */
NuError NuError DoAdd(NulibState* pState)
DoAdd(NulibState* pState)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;
@ -84,8 +83,7 @@ bail:
* This just results in NuAddFile calls; the deferred write operation * This just results in NuAddFile calls; the deferred write operation
* isn't initiated. * isn't initiated.
*/ */
static NuError static NuError AddToArchive(NulibState* pState, NuArchive* pArchive)
AddToArchive(NulibState* pState, NuArchive* pArchive)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
char* const* pSpec; char* const* pSpec;

View File

@ -24,8 +24,7 @@
* The buffer we return to the archive library will be overwritten the * The buffer we return to the archive library will be overwritten the
* next time this function gets called. This is expected. * next time this function gets called. This is expected.
*/ */
static NuResult static NuResult OutputPathnameFilter(NuArchive* pArchive, void* vproposal)
OutputPathnameFilter(NuArchive* pArchive, void* vproposal)
{ {
NuPathnameProposal* pathProposal = vproposal; NuPathnameProposal* pathProposal = vproposal;
NulibState* pState; NulibState* pState;
@ -99,8 +98,7 @@ bail:
* first character. A fancier version would play with line disciplines * first character. A fancier version would play with line disciplines
* so you wouldn't have to hit "return". * so you wouldn't have to hit "return".
*/ */
static char static char GetReplyChar(char defaultReply)
GetReplyChar(char defaultReply)
{ {
char tmpBuf[32]; char tmpBuf[32];
@ -120,8 +118,7 @@ GetReplyChar(char defaultReply)
* *
* String returned should be freed by the caller. * String returned should be freed by the caller.
*/ */
static char* static char* GetReplyString(const char* prompt)
GetReplyString(const char* prompt)
{ {
char buf[kMaxInputLen]; char buf[kMaxInputLen];
char* result; char* result;
@ -152,8 +149,7 @@ GetReplyString(const char* prompt)
* *
* A pointer to a newly-allocated buffer is returned. * A pointer to a newly-allocated buffer is returned.
*/ */
char* char* GetSimpleComment(NulibState* pState, const char* pathname, int maxLen)
GetSimpleComment(NulibState* pState, const char* pathname, int maxLen)
{ {
char* buf = NULL; char* buf = NULL;
char* result; char* result;
@ -196,8 +192,8 @@ GetSimpleComment(NulibState* pState, const char* pathname, int maxLen)
* *
* (Someday "spec" might be a regexp.) * (Someday "spec" might be a regexp.)
*/ */
static Boolean static Boolean SpecMatchesRecord(NulibState* pState, const char* spec,
SpecMatchesRecord(NulibState* pState, const char* spec, const NuRecord* pRecord) const NuRecord* pRecord)
{ {
#ifdef NU_CASE_SENSITIVE #ifdef NU_CASE_SENSITIVE
if (NState_GetModRecurse(pState)) if (NState_GetModRecurse(pState))
@ -222,8 +218,7 @@ SpecMatchesRecord(NulibState* pState, const char* spec, const NuRecord* pRecord)
* extraction by criteria other than name, e.g. all text files or all * extraction by criteria other than name, e.g. all text files or all
* files archived before a certain date. * files archived before a certain date.
*/ */
Boolean Boolean IsSpecified(NulibState* pState, const NuRecord* pRecord)
IsSpecified(NulibState* pState, const NuRecord* pRecord)
{ {
char* const* pSpec; char* const* pSpec;
int i; int i;
@ -245,8 +240,7 @@ IsSpecified(NulibState* pState, const NuRecord* pRecord)
* General-purpose selection filter, invoked as a callback. Compares the * General-purpose selection filter, invoked as a callback. Compares the
* selection proposal with the filenames in "filespec". * selection proposal with the filenames in "filespec".
*/ */
NuResult NuResult SelectionFilter(NuArchive* pArchive, void* vproposal)
SelectionFilter(NuArchive* pArchive, void* vproposal)
{ {
const NuSelectionProposal* selProposal = vproposal; const NuSelectionProposal* selProposal = vproposal;
NulibState* pState; NulibState* pState;
@ -271,8 +265,7 @@ SelectionFilter(NuArchive* pArchive, void* vproposal)
/* /*
* Print a three-digit progress percentage; range is 0% to 100%. * Print a three-digit progress percentage; range is 0% to 100%.
*/ */
void void PrintPercentage(uint32_t total, uint32_t progress)
PrintPercentage(uint32_t total, uint32_t progress)
{ {
uint32_t perc; uint32_t perc;
@ -299,8 +292,7 @@ PrintPercentage(uint32_t total, uint32_t progress)
* Show our progress, unless we're expanding to a pipe. Invoked as a * Show our progress, unless we're expanding to a pipe. Invoked as a
* callback by nufxlib. * callback by nufxlib.
*/ */
NuResult NuResult ProgressUpdater(NuArchive* pArchive, void* vProgress)
ProgressUpdater(NuArchive* pArchive, void* vProgress)
{ {
const NuProgressData* pProgress = vProgress; const NuProgressData* pProgress = vProgress;
NulibState* pState; NulibState* pState;
@ -449,8 +441,7 @@ ProgressUpdater(NuArchive* pArchive, void* vProgress)
* Decide whether or not to replace an existing file (during extract) * Decide whether or not to replace an existing file (during extract)
* or record (during add). * or record (during add).
*/ */
static NuResult static NuResult HandleReplaceExisting(NulibState* pState, NuArchive* pArchive,
HandleReplaceExisting(NulibState* pState, NuArchive* pArchive,
const NuErrorStatus* pErrorStatus) const NuErrorStatus* pErrorStatus)
{ {
NuResult result = kNuOK; NuResult result = kNuOK;
@ -537,8 +528,7 @@ bail:
* Note pErrorStatus->pathname may be NULL 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. * master header or in the record header.
*/ */
static NuResult static NuResult HandleBadCRC(NulibState* pState, NuArchive* pArchive,
HandleBadCRC(NulibState* pState, NuArchive* pArchive,
const NuErrorStatus* pErrorStatus) const NuErrorStatus* pErrorStatus)
{ {
NuResult result = kNuOK; NuResult result = kNuOK;
@ -597,8 +587,7 @@ bail:
* the system equivalent of readdir to scan a directory, so deleting a * the system equivalent of readdir to scan a directory, so deleting a
* file just means it won't get added. * file just means it won't get added.
*/ */
static NuResult static NuResult HandleAddNotFound(NulibState* pState, NuArchive* pArchive,
HandleAddNotFound(NulibState* pState, NuArchive* pArchive,
const NuErrorStatus* pErrorStatus) const NuErrorStatus* pErrorStatus)
{ {
NuResult result = kNuOK; NuResult result = kNuOK;
@ -644,8 +633,7 @@ bail:
* Something failed, and the user may want to choose how to handle it. * Something failed, and the user may want to choose how to handle it.
* Invoked as a callback. * Invoked as a callback.
*/ */
NuResult NuResult ErrorHandler(NuArchive* pArchive, void* vErrorStatus)
ErrorHandler(NuArchive* pArchive, void* vErrorStatus)
{ {
const NuErrorStatus* pErrorStatus = vErrorStatus; const NuErrorStatus* pErrorStatus = vErrorStatus;
NulibState* pState; NulibState* pState;
@ -722,8 +710,7 @@ ErrorHandler(NuArchive* pArchive, void* vErrorStatus)
* (This was just a test to see if it worked... NufxLib's default behavior * (This was just a test to see if it worked... NufxLib's default behavior
* is fine for NuLib2.) * is fine for NuLib2.)
*/ */
NuResult NuResult ErrorMessageHandler(NuArchive* pArchive, void* vErrorMessage)
ErrorMessageHandler(NuArchive* pArchive, void* vErrorMessage)
{ {
const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage; const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage;
@ -752,8 +739,7 @@ static const char* kStdinArchive = "-";
* *
* Uses a simplified view of the access flags. * Uses a simplified view of the access flags.
*/ */
Boolean Boolean IsRecordReadOnly(const NuRecord* pRecord)
IsRecordReadOnly(const NuRecord* pRecord)
{ {
if (pRecord->recAccess == 0x21L || pRecord->recAccess == 0x01L) if (pRecord->recAccess == 0x21L || pRecord->recAccess == 0x01L)
return true; return true;
@ -765,8 +751,7 @@ IsRecordReadOnly(const NuRecord* pRecord)
/* /*
* Returns "true" if "archiveName" is the name we use to represent stdin. * Returns "true" if "archiveName" is the name we use to represent stdin.
*/ */
Boolean Boolean IsFilenameStdin(const char* archiveName)
IsFilenameStdin(const char* archiveName)
{ {
Assert(archiveName != NULL); Assert(archiveName != NULL);
return (strcmp(archiveName, kStdinArchive) == 0); return (strcmp(archiveName, kStdinArchive) == 0);
@ -779,8 +764,7 @@ IsFilenameStdin(const char* archiveName)
* Open the archive in read-only mode. We use "file mode" for a file, or * Open the archive in read-only mode. We use "file mode" for a file, or
* "streaming mode" for stdin. * "streaming mode" for stdin.
*/ */
NuError NuError OpenArchiveReadOnly(NulibState* pState)
OpenArchiveReadOnly(NulibState* pState)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;
@ -896,8 +880,7 @@ bail:
* *
* "Streaming mode" isn't allowed. * "Streaming mode" isn't allowed.
*/ */
NuError NuError OpenArchiveReadWrite(NulibState* pState)
OpenArchiveReadWrite(NulibState* pState)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;

View File

@ -44,8 +44,7 @@
* Open a file read-only. We abstract this so we get "r" vs "rb" right. * Open a file read-only. We abstract this so we get "r" vs "rb" right.
* (Moves this to SysUtils.c if anybody else needs it.) * (Moves this to SysUtils.c if anybody else needs it.)
*/ */
NuError NuError OpenFileReadOnly(const char* filename, FILE** pFp)
OpenFileReadOnly(const char* filename, FILE** pFp)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -62,8 +61,7 @@ OpenFileReadOnly(const char* filename, FILE** pFp)
* *
* If no filespec was provided, then all records are "specified". * If no filespec was provided, then all records are "specified".
*/ */
Boolean Boolean NameIsSpecified(NulibState* pState, const char* filename)
NameIsSpecified(NulibState* pState, const char* filename)
{ {
char* const* pSpec; char* const* pSpec;
int i; int i;
@ -154,8 +152,7 @@ typedef struct BNYEntry {
/* /*
* Test for the magic number on a file in SQueezed format. * Test for the magic number on a file in SQueezed format.
*/ */
static inline Boolean static inline Boolean IsSqueezed(uint8_t one, uint8_t two)
IsSqueezed(uint8_t one, uint8_t two)
{ {
return (one == 0x76 && two == 0xff); return (one == 0x76 && two == 0xff);
} }
@ -163,8 +160,7 @@ IsSqueezed(uint8_t one, uint8_t two)
/* /*
* Test if this entry is a directory. * Test if this entry is a directory.
*/ */
static inline Boolean static inline Boolean IsDir(BNYEntry* pEntry)
IsDir(BNYEntry* pEntry)
{ {
/* /*
* NuLib and "unblu.c" compared against file type 15 (DIR), so I'm * NuLib and "unblu.c" compared against file type 15 (DIR), so I'm
@ -178,8 +174,7 @@ IsDir(BNYEntry* pEntry)
/* /*
* Initialize a BNYArchive structure. * Initialize a BNYArchive structure.
*/ */
static BNYArchive* static BNYArchive* BNYInit(NulibState* pState)
BNYInit(NulibState* pState)
{ {
BNYArchive* pBny; BNYArchive* pBny;
@ -194,8 +189,7 @@ BNYInit(NulibState* pState)
/* /*
* Free up a BNYArchive, disposing of anything inside it. * Free up a BNYArchive, disposing of anything inside it.
*/ */
static void static void BNYFree(BNYArchive* pBny)
BNYFree(BNYArchive* pBny)
{ {
/* don't need to do this on stdin, but won't really hurt */ /* don't need to do this on stdin, but won't really hurt */
if (pBny->fp != NULL) if (pBny->fp != NULL)
@ -209,8 +203,7 @@ BNYFree(BNYArchive* pBny)
* Open a Binary II archive read-only. Might be a file on disk or a * Open a Binary II archive read-only. Might be a file on disk or a
* stream on stdin. * stream on stdin.
*/ */
static NuError static NuError BNYOpenReadOnly(BNYArchive* pBny)
BNYOpenReadOnly(BNYArchive* pBny)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NulibState* pState; NulibState* pState;
@ -248,8 +241,7 @@ bail:
* Wrapper for fread(). Note the arguments resemble read(2) rather * Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S). * than fread(3S).
*/ */
static NuError static NuError BNYRead(BNYArchive* pBny, void* buf, size_t nbyte)
BNYRead(BNYArchive* pBny, void* buf, size_t nbyte)
{ {
size_t result; size_t result;
@ -270,8 +262,7 @@ BNYRead(BNYArchive* pBny, void* buf, size_t nbyte)
* and don't need to special-case anything, we only allow relative * and don't need to special-case anything, we only allow relative
* forward seeks. * forward seeks.
*/ */
static NuError static NuError BNYSeek(BNYArchive* pBny, long offset)
BNYSeek(BNYArchive* pBny, long offset)
{ {
Assert(pBny != NULL); Assert(pBny != NULL);
Assert(pBny->fp != NULL); Assert(pBny->fp != NULL);
@ -299,8 +290,8 @@ BNYSeek(BNYArchive* pBny, long offset)
/* /*
* Convert from ProDOS compact date format to the expanded DateTime format. * Convert from ProDOS compact date format to the expanded DateTime format.
*/ */
static void static void BNYConvertDateTime(uint16_t prodosDate, uint16_t prodosTime,
BNYConvertDateTime(uint16_t prodosDate, uint16_t prodosTime, NuDateTime* pWhen) NuDateTime* pWhen)
{ {
pWhen->second = 0; pWhen->second = 0;
pWhen->minute = prodosTime & 0x3f; pWhen->minute = prodosTime & 0x3f;
@ -320,8 +311,7 @@ BNYConvertDateTime(uint16_t prodosDate, uint16_t prodosTime, NuDateTime* pWhen)
* See the File Type Note for $e0/8000 to decipher the buffer offsets * See the File Type Note for $e0/8000 to decipher the buffer offsets
* and meanings. * and meanings.
*/ */
static NuError static NuError BNYDecodeHeader(BNYArchive* pBny, BNYEntry* pEntry)
BNYDecodeHeader(BNYArchive* pBny, BNYEntry* pEntry)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
uint8_t* raw; uint8_t* raw;
@ -406,8 +396,7 @@ bail:
* We return the new path, which is stored in NulibState's temporary * We return the new path, which is stored in NulibState's temporary
* filename buffer. * filename buffer.
*/ */
const char* const char* BNYNormalizePath(BNYArchive* pBny, BNYEntry* pEntry)
BNYNormalizePath(BNYArchive* pBny, BNYEntry* pEntry)
{ {
NuPathnameProposal pathProposal; NuPathnameProposal pathProposal;
NuRecord fakeRecord; NuRecord fakeRecord;
@ -448,8 +437,7 @@ BNYNormalizePath(BNYArchive* pBny, BNYEntry* pEntry)
* *
* Uses pEntry->blockBuf, which already has the first 128 bytes in it. * Uses pEntry->blockBuf, which already has the first 128 bytes in it.
*/ */
static NuError static NuError BNYCopyBlocks(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
BNYCopyBlocks(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
long bytesLeft; long bytesLeft;
@ -542,8 +530,7 @@ typedef struct USQState {
/* /*
* Decode the next symbol from the Huffman stream. * Decode the next symbol from the Huffman stream.
*/ */
static NuError static NuError USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
{ {
short val = 0; short val = 0;
int bits, bitPosn; int bits, bitPosn;
@ -579,8 +566,7 @@ USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
/* /*
* Read two bytes of signed data out of the buffer. * Read two bytes of signed data out of the buffer.
*/ */
static inline NuError static inline NuError USQReadShort(USQState* pUsqState, short* pShort)
USQReadShort(USQState* pUsqState, short* pShort)
{ {
if (pUsqState->dataInBuffer < 2) if (pUsqState->dataInBuffer < 2)
return kNuErrBufferUnderrun; return kNuErrBufferUnderrun;
@ -598,8 +584,7 @@ USQReadShort(USQState* pUsqState, short* pShort)
* Because we have a stop symbol, knowing the uncompressed length of * Because we have a stop symbol, knowing the uncompressed length of
* the file is not essential. * the file is not essential.
*/ */
static NuError static NuError BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
USQState usqState; USQState usqState;
@ -909,8 +894,7 @@ typedef NuError (*BNYIteratorFunc)(BNYArchive* pBny, BNYEntry* pEntry,
* Iterate through a Binary II archive, calling "func" to perform * Iterate through a Binary II archive, calling "func" to perform
* operations on the file. * operations on the file.
*/ */
static NuError static NuError BNYIterate(NulibState* pState, BNYIteratorFunc func)
BNYIterate(NulibState* pState, BNYIteratorFunc func)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
BNYArchive* pBny = NULL; BNYArchive* pBny = NULL;
@ -1023,8 +1007,8 @@ bail:
/* /*
* Get a quick table of contents. * Get a quick table of contents.
*/ */
static NuError static NuError BNYListShort(BNYArchive* pBny, BNYEntry* pEntry,
BNYListShort(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag) Boolean* pConsumedFlag)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1036,8 +1020,8 @@ BNYListShort(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag)
/* /*
* Get a verbose listing of contents. * Get a verbose listing of contents.
*/ */
static NuError static NuError BNYListVerbose(BNYArchive* pBny, BNYEntry* pEntry,
BNYListVerbose(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag) Boolean* pConsumedFlag)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Boolean isSqueezed, isReadOnly; Boolean isSqueezed, isReadOnly;
@ -1102,8 +1086,8 @@ BNYListVerbose(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag)
/* /*
* Get a verbose table of contents. * Get a verbose table of contents.
*/ */
static NuError static NuError BNYListDebug(BNYArchive* pBny, BNYEntry* pEntry,
BNYListDebug(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag) Boolean* pConsumedFlag)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1146,8 +1130,8 @@ typedef enum { kBNYExtNormal, kBNYExtPipe, kBNYExtTest } ExtMode;
/* /*
* Handle "extraction" of a directory. * Handle "extraction" of a directory.
*/ */
static NuError static NuError BNYExtractDirectory(BNYArchive* pBny, BNYEntry* pEntry,
BNYExtractDirectory(BNYArchive* pBny, BNYEntry* pEntry, ExtMode extMode) ExtMode extMode)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
const char* newName; const char* newName;
@ -1209,8 +1193,8 @@ bail:
/* /*
* Handle "extract", "extract to pipe", and "test". * Handle "extract", "extract to pipe", and "test".
*/ */
static NuError static NuError BNYExtract(BNYArchive* pBny, BNYEntry* pEntry,
BNYExtract(BNYArchive* pBny, BNYEntry* pEntry, Boolean* pConsumedFlag) Boolean* pConsumedFlag)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
NulibState* pState; NulibState* pState;
@ -1370,8 +1354,7 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
NuError NuError BNYDoExtract(NulibState* pState)
BNYDoExtract(NulibState* pState)
{ {
if (NState_GetModConvertText(pState) || if (NState_GetModConvertText(pState) ||
NState_GetModConvertAll(pState)) NState_GetModConvertAll(pState))
@ -1402,26 +1385,22 @@ BNYDoExtract(NulibState* pState)
return BNYIterate(pState, BNYExtract); return BNYIterate(pState, BNYExtract);
} }
NuError NuError BNYDoTest(NulibState* pState)
BNYDoTest(NulibState* pState)
{ {
return BNYIterate(pState, BNYExtract); return BNYIterate(pState, BNYExtract);
} }
NuError NuError BNYDoListShort(NulibState* pState)
BNYDoListShort(NulibState* pState)
{ {
return BNYIterate(pState, BNYListShort); return BNYIterate(pState, BNYListShort);
} }
NuError NuError BNYDoListVerbose(NulibState* pState)
BNYDoListVerbose(NulibState* pState)
{ {
return BNYIterate(pState, BNYListVerbose); return BNYIterate(pState, BNYListVerbose);
} }
NuError NuError BNYDoListDebug(NulibState* pState)
BNYDoListDebug(NulibState* pState)
{ {
return BNYIterate(pState, BNYListDebug); return BNYIterate(pState, BNYListDebug);
} }

View File

@ -15,8 +15,7 @@
* This uses the "bulk" delete call, allowing the SelectionFilter callback * This uses the "bulk" delete call, allowing the SelectionFilter callback
* to do the matching against specified filenames. * to do the matching against specified filenames.
*/ */
NuError NuError DoDelete(NulibState* pState)
DoDelete(NulibState* pState)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;

View File

@ -17,8 +17,7 @@
* show them while we're extracting the files, we have to manually find * show them while we're extracting the files, we have to manually find
* and extract them. * and extract them.
*/ */
static NuError static NuError ExtractAllRecords(NulibState* pState, NuArchive* pArchive)
ExtractAllRecords(NulibState* pState, NuArchive* pArchive)
{ {
NuError err; NuError err;
const NuRecord* pRecord; const NuRecord* pRecord;
@ -87,8 +86,7 @@ bail:
/* /*
* Extract the specified files. * Extract the specified files.
*/ */
NuError NuError DoExtract(NulibState* pState)
DoExtract(NulibState* pState)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;
@ -135,8 +133,7 @@ bail:
/* /*
* Extract the specified files to stdout. * Extract the specified files to stdout.
*/ */
NuError NuError DoExtractToPipe(NulibState* pState)
DoExtractToPipe(NulibState* pState)
{ {
/* we handle the "to pipe" part farther down */ /* we handle the "to pipe" part farther down */
return DoExtract(pState); return DoExtract(pState);
@ -146,8 +143,7 @@ DoExtractToPipe(NulibState* pState)
/* /*
* Do an integrity check on one or more records in the archive. * Do an integrity check on one or more records in the archive.
*/ */
NuError NuError DoTest(NulibState* pState)
DoTest(NulibState* pState)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;

View File

@ -95,8 +95,7 @@ static const struct {
/* /*
* Return a pointer to the three-letter representation of the file type name. * Return a pointer to the three-letter representation of the file type name.
*/ */
const char* const char* GetFileTypeString(uint32_t fileType)
GetFileTypeString(uint32_t fileType)
{ {
if (fileType < NELEM(gFileTypeNames)) if (fileType < NELEM(gFileTypeNames))
return gFileTypeNames[fileType]; return gFileTypeNames[fileType];
@ -117,8 +116,7 @@ GetFileTypeString(uint32_t fileType)
* "pathBuf" is assumed to have enough space to hold the current path * "pathBuf" is assumed to have enough space to hold the current path
* plus kMaxPathGrowth more. It will be modified in place. * plus kMaxPathGrowth more. It will be modified in place.
*/ */
static void static void AddPreservationString(NulibState* pState,
AddPreservationString(NulibState* pState,
const NuPathnameProposal* pPathProposal, char* pathBuf) const NuPathnameProposal* pPathProposal, char* pathBuf)
{ {
char extBuf[kMaxPathGrowth +1]; char extBuf[kMaxPathGrowth +1];
@ -248,8 +246,7 @@ AddPreservationString(NulibState* pState,
* This returns the new pathname, which is held in NulibState's temporary * This returns the new pathname, which is held in NulibState's temporary
* pathname buffer. * pathname buffer.
*/ */
const char* const char* NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal)
NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
char* pathBuf; char* pathBuf;
@ -357,9 +354,8 @@ bail:
* This checks the standard list of ProDOS types (which should catch things * This checks the standard list of ProDOS types (which should catch things
* like "TXT" and "BIN") and the separate list of recognized extensions. * like "TXT" and "BIN") and the separate list of recognized extensions.
*/ */
static void static void LookupExtension(NulibState* pState, const char* ext,
LookupExtension(NulibState* pState, const char* ext, uint32_t* pFileType, uint32_t* pFileType, uint32_t* pAuxType)
uint32_t* pAuxType)
{ {
char uext3[4]; char uext3[4];
int i, extLen; int i, extLen;
@ -409,9 +405,8 @@ bail:
/* /*
* Try to associate some meaning with the file extension. * Try to associate some meaning with the file extension.
*/ */
void void InterpretExtension(NulibState* pState, const char* pathName,
InterpretExtension(NulibState* pState, const char* pathName, uint32_t* pFileType, uint32_t* pFileType, uint32_t* pAuxType)
uint32_t* pAuxType)
{ {
const char* pExt; const char* pExt;
@ -434,9 +429,8 @@ InterpretExtension(NulibState* pState, const char* pathName, uint32_t* pFileType
* We have to be careful not to trip on false-positive occurrences of '#' * We have to be careful not to trip on false-positive occurrences of '#'
* in the filename. * in the filename.
*/ */
Boolean Boolean ExtractPreservationString(NulibState* pState, char* pathname,
ExtractPreservationString(NulibState* pState, char* pathname, uint32_t* pFileType, uint32_t* pFileType, uint32_t* pAuxType, NuThreadID* pThreadID)
uint32_t* pAuxType, NuThreadID* pThreadID)
{ {
char numBuf[9]; char numBuf[9];
uint32_t fileType, auxType; uint32_t fileType, auxType;
@ -528,8 +522,7 @@ ExtractPreservationString(NulibState* pState, char* pathname, uint32_t* pFileTyp
* This always results in the filename staying the same length or getting * This always results in the filename staying the same length or getting
* smaller, so we can do it in place in the buffer. * smaller, so we can do it in place in the buffer.
*/ */
void void DenormalizePath(NulibState* pState, char* pathBuf)
DenormalizePath(NulibState* pState, char* pathBuf)
{ {
const char* srcp; const char* srcp;
char* dstp; char* dstp;
@ -585,8 +578,7 @@ DenormalizePath(NulibState* pState, char* pathBuf)
* *
* Always returns a pointer to a string; never returns NULL. * Always returns a pointer to a string; never returns NULL.
*/ */
const char* const char* FilenameOnly(NulibState* pState, const char* pathname)
FilenameOnly(NulibState* pState, const char* pathname)
{ {
const char* retstr; const char* retstr;
const char* pSlash; const char* pSlash;
@ -645,8 +637,7 @@ bail:
* Returns a pointer to the '.' preceding the extension, or NULL if no * Returns a pointer to the '.' preceding the extension, or NULL if no
* extension was found. * extension was found.
*/ */
const char* const char* FindExtension(NulibState* pState, const char* pathname)
FindExtension(NulibState* pState, const char* pathname)
{ {
const char* pFilename; const char* pFilename;
const char* pExt; const char* pExt;

View File

@ -40,8 +40,7 @@ static const char* gMonths[] = {
/* /*
* Compute a percentage. * Compute a percentage.
*/ */
int int ComputePercent(uint32_t totalSize, uint32_t size)
ComputePercent(uint32_t totalSize, uint32_t size)
{ {
int perc; int perc;
@ -69,8 +68,7 @@ ComputePercent(uint32_t totalSize, uint32_t size)
* *
* Returns "buffer" for the benefit of printf() calls. * Returns "buffer" for the benefit of printf() calls.
*/ */
char* char* FormatDateShort(const NuDateTime* pDateTime, char* buffer)
FormatDateShort(const NuDateTime* pDateTime, char* buffer)
{ {
/* is it valid? */ /* is it valid? */
if (pDateTime->day > 30 || pDateTime->month > 11 || pDateTime->hour > 24 || if (pDateTime->day > 30 || pDateTime->month > 11 || pDateTime->hour > 24 ||
@ -101,8 +99,7 @@ bail:
/* /*
* NuStream callback function. Displays the filename. * NuStream callback function. Displays the filename.
*/ */
static NuResult static NuResult ShowContentsShort(NuArchive* pArchive, void* vpRecord)
ShowContentsShort(NuArchive* pArchive, void* vpRecord)
{ {
const NuRecord* pRecord = (NuRecord*) vpRecord; const NuRecord* pRecord = (NuRecord*) vpRecord;
NulibState* pState; NulibState* pState;
@ -142,9 +139,9 @@ bail:
* will be categorized as "unknown". We could detect the situation and * will be categorized as "unknown". We could detect the situation and
* correct it, but we might as well flag it in a user-visible way. * correct it, but we might as well flag it in a user-visible way.
*/ */
static NuError static NuError AnalyzeRecord(const NuRecord* pRecord,
AnalyzeRecord(const NuRecord* pRecord, enum RecordKind* pRecordKind, enum RecordKind* pRecordKind, uint16_t* pFormat, uint32_t* pTotalLen,
uint16_t* pFormat, uint32_t* pTotalLen, uint32_t* pTotalCompLen) uint32_t* pTotalCompLen)
{ {
const NuThread* pThread; const NuThread* pThread;
NuThreadID threadID; NuThreadID threadID;
@ -188,8 +185,7 @@ AnalyzeRecord(const NuRecord* pRecord, enum RecordKind* pRecordKind,
* This is intended to mimic the output of some old version of ProDOS 8 * This is intended to mimic the output of some old version of ProDOS 8
* ShrinkIt. * ShrinkIt.
*/ */
static NuResult static NuResult ShowContentsVerbose(NuArchive* pArchive, void* vpRecord)
ShowContentsVerbose(NuArchive* pArchive, void* vpRecord)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
const NuRecord* pRecord = (NuRecord*) vpRecord; const NuRecord* pRecord = (NuRecord*) vpRecord;
@ -279,8 +275,7 @@ bail:
/* /*
* Print a short listing of the contents of an archive. * Print a short listing of the contents of an archive.
*/ */
NuError NuError DoListShort(NulibState* pState)
DoListShort(NulibState* pState)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;
@ -311,8 +306,7 @@ bail:
/* /*
* Print a more verbose listing of the contents of an archive. * Print a more verbose listing of the contents of an archive.
*/ */
NuError NuError DoListVerbose(NulibState* pState)
DoListVerbose(NulibState* pState)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;
@ -394,8 +388,7 @@ bail:
/* /*
* Null callback, for those times when you don't really want to do anything. * Null callback, for those times when you don't really want to do anything.
*/ */
static NuResult static NuResult NullCallback(NuArchive* pArchive, void* vpRecord)
NullCallback(NuArchive* pArchive, void* vpRecord)
{ {
return kNuOK; return kNuOK;
} }
@ -404,8 +397,7 @@ NullCallback(NuArchive* pArchive, void* vpRecord)
* Print very detailed output, suitable for debugging (requires that * Print very detailed output, suitable for debugging (requires that
* debug messages be enabled in nufxlib). * debug messages be enabled in nufxlib).
*/ */
NuError NuError DoListDebug(NulibState* pState)
DoListDebug(NulibState* pState)
{ {
NuError err; NuError err;
NuArchive* pArchive = NULL; NuArchive* pArchive = NULL;

View File

@ -44,8 +44,7 @@ static const ValidCombo gValidCombos[] = {
* *
* Returns NULL if not found. * Returns NULL if not found.
*/ */
static const ValidCombo* static const ValidCombo* FindValidComboEntry(Command cmd)
FindValidComboEntry(Command cmd)
{ {
int i; int i;
@ -61,8 +60,7 @@ FindValidComboEntry(Command cmd)
* Determine whether the specified modifier is valid when used with the * Determine whether the specified modifier is valid when used with the
* current command. * current command.
*/ */
static Boolean static Boolean IsValidModifier(Command cmd, char modifier)
IsValidModifier(Command cmd, char modifier)
{ {
const ValidCombo* pvc; const ValidCombo* pvc;
@ -79,8 +77,7 @@ IsValidModifier(Command cmd, char modifier)
/* /*
* Determine whether the specified command can be used with stdin as input. * Determine whether the specified command can be used with stdin as input.
*/ */
static Boolean static Boolean IsValidOnPipe(Command cmd)
IsValidOnPipe(Command cmd)
{ {
const ValidCombo* pvc; const ValidCombo* pvc;
@ -94,8 +91,7 @@ IsValidOnPipe(Command cmd)
/* /*
* Determine whether the specified command can be used with stdin as input. * Determine whether the specified command can be used with stdin as input.
*/ */
static Boolean static Boolean IsFilespecRequired(Command cmd)
IsFilespecRequired(Command cmd)
{ {
const ValidCombo* pvc; const ValidCombo* pvc;
@ -114,8 +110,7 @@ IsFilespecRequired(Command cmd)
/* /*
* Separate the program name out of argv[0]. * Separate the program name out of argv[0].
*/ */
static const char* static const char* GetProgName(const NulibState* pState, const char* argv0)
GetProgName(const NulibState* pState, const char* argv0)
{ {
const char* result; const char* result;
char sep; char sep;
@ -136,8 +131,7 @@ GetProgName(const NulibState* pState, const char* argv0)
/* /*
* Print program usage. * Print program usage.
*/ */
static void static void Usage(const NulibState* pState)
Usage(const NulibState* pState)
{ {
long majorVersion, minorVersion, bugVersion; long majorVersion, minorVersion, bugVersion;
const char* nufxLibDate; const char* nufxLibDate;
@ -184,8 +178,7 @@ Usage(const NulibState* pState)
/* /*
* Handle the "-h" command. * Handle the "-h" command.
*/ */
NuError NuError DoHelp(const NulibState* pState)
DoHelp(const NulibState* pState)
{ {
static const struct { static const struct {
Command cmd; Command cmd;
@ -315,8 +308,7 @@ DoHelp(const NulibState* pState)
/* /*
* Process the command-line options. The results are placed into "pState". * Process the command-line options. The results are placed into "pState".
*/ */
static int static int ProcessOptions(NulibState* pState, int argc, char* const* argv)
ProcessOptions(NulibState* pState, int argc, char* const* argv)
{ {
const char* cp; const char* cp;
int idx; int idx;
@ -511,8 +503,7 @@ fail:
* *
* Returns 0 on success, 1 on error. * Returns 0 on success, 1 on error.
*/ */
int int DoWork(NulibState* pState)
DoWork(NulibState* pState)
{ {
NuError err; NuError err;
@ -558,8 +549,7 @@ DoWork(NulibState* pState)
/* /*
* Entry point. * Entry point.
*/ */
int int main(int argc, char** argv)
main(int argc, char** argv)
{ {
NulibState* pState = NULL; NulibState* pState = NULL;
long majorVersion, minorVersion, bugVersion; long majorVersion, minorVersion, bugVersion;

View File

@ -16,8 +16,7 @@
* Return a pointer to the appropriate string in the system table, or NULL * Return a pointer to the appropriate string in the system table, or NULL
* if the value is out of bounds. * if the value is out of bounds.
*/ */
const char* const char* Nu_strerror(int errnum)
Nu_strerror(int errnum)
{ {
extern int sys_nerr; extern int sys_nerr;
extern char *sys_errlist[]; extern char *sys_errlist[];
@ -38,8 +37,7 @@ Nu_strerror(int errnum)
* from BSD, is available in the PGP 2.6.2 distribution, but this should * from BSD, is available in the PGP 2.6.2 distribution, but this should
* suffice for those few systems that don't have memmove. * suffice for those few systems that don't have memmove.
*/ */
void* void* Nu_memmove(void* dst, const void* src, size_t n)
Nu_memmove(void* dst, const void* src, size_t n)
{ {
void* retval = dst; void* retval = dst;
char* srcp = (char*)src; char* srcp = (char*)src;
@ -80,8 +78,7 @@ Nu_memmove(void* dst, const void* src, size_t n)
* For our purposes here, strtol does all we need it to. Someday * For our purposes here, strtol does all we need it to. Someday
* we should replace this with a "real" version. * we should replace this with a "real" version.
*/ */
unsigned long unsigned long Nu_strtoul(const char *nptr, char **endptr, int base)
Nu_strtoul(const char *nptr, char **endptr, int base)
{ {
return strtol(nptr, endptr, base); return strtol(nptr, endptr, base);
} }
@ -91,8 +88,7 @@ Nu_strtoul(const char *nptr, char **endptr, int base)
/* /*
* Compare two strings, case-insensitive. * Compare two strings, case-insensitive.
*/ */
int int Nu_strcasecmp(const char *str1, const char *str2)
Nu_strcasecmp(const char *str1, const char *str2)
{ {
while (*str1 && *str2 && toupper(*str1) == toupper(*str2)) while (*str1 && *str2 && toupper(*str1) == toupper(*str2))
str1++, str2++; str1++, str2++;
@ -105,8 +101,7 @@ Nu_strcasecmp(const char *str1, const char *str2)
/* /*
* Compare two strings, case-insensitive, stopping after "n" chars. * Compare two strings, case-insensitive, stopping after "n" chars.
*/ */
int int Nu_strncasecmp(const char *str1, const char *str2, size_t n)
Nu_strncasecmp(const char *str1, const char *str2, size_t n)
{ {
while (n && *str1 && *str2 && toupper(*str1) == toupper(*str2)) while (n && *str1 && *str2 && toupper(*str1) == toupper(*str2))
str1++, str2++, n--; str1++, str2++, n--;

View File

@ -16,8 +16,7 @@
* *
* If "format" is NULL, just the error message itself is printed. * If "format" is NULL, just the error message itself is printed.
*/ */
void void ReportError(NuError err, const char* format, ...)
ReportError(NuError err, const char* format, ...)
{ {
const char* msg; const char* msg;
va_list args; va_list args;
@ -62,8 +61,7 @@ ReportError(NuError err, const char* format, ...)
*/ */
#ifndef USE_DMALLOC #ifndef USE_DMALLOC
void* void* Malloc(size_t size)
Malloc(size_t size)
{ {
void* _result; void* _result;
@ -77,16 +75,14 @@ Malloc(size_t size)
return _result; return _result;
} }
void* void* Calloc(size_t size)
Calloc(size_t size)
{ {
void* _cresult = Malloc(size); void* _cresult = Malloc(size);
memset(_cresult, 0, size); memset(_cresult, 0, size);
return _cresult; return _cresult;
} }
void* void* Realloc(void* ptr, size_t size)
Realloc(void* ptr, size_t size)
{ {
void* _result; void* _result;
@ -100,8 +96,7 @@ Realloc(void* ptr, size_t size)
return _result; return _result;
} }
void void Free(void* ptr)
Free(void* ptr)
{ {
if (ptr != NULL) if (ptr != NULL)
free(ptr); free(ptr);
@ -111,8 +106,7 @@ Free(void* ptr)
/* /*
* This gets called when a buffer DataSource is no longer needed. * This gets called when a buffer DataSource is no longer needed.
*/ */
NuResult NuResult FreeCallback(NuArchive* pArchive, void* args)
FreeCallback(NuArchive* pArchive, void* args)
{ {
DBUG(("+++ free callback 0x%08lx\n", (long) args)); DBUG(("+++ free callback 0x%08lx\n", (long) args));
Free(args); Free(args);

View File

@ -15,8 +15,7 @@ static const char* gProgramVersion = "2.2.2";
/* /*
* Allocate and initialize the semi-global Nulib2 state object. * Allocate and initialize the semi-global Nulib2 state object.
*/ */
NuError NuError NState_Init(NulibState** ppState)
NState_Init(NulibState** ppState)
{ {
Assert(ppState != NULL); Assert(ppState != NULL);
@ -41,8 +40,7 @@ NState_Init(NulibState** ppState)
/* /*
* A little extra initialization, performed after arguments are parsed. * A little extra initialization, performed after arguments are parsed.
*/ */
NuError NuError NState_ExtraInit(NulibState* pState)
NState_ExtraInit(NulibState* pState)
{ {
NuError err; NuError err;
NuValue convertEOL; NuValue convertEOL;
@ -74,8 +72,7 @@ NState_ExtraInit(NulibState* pState)
/* /*
* Free up the state structure and its contents. * Free up the state structure and its contents.
*/ */
void void NState_Free(NulibState* pState)
NState_Free(NulibState* pState)
{ {
if (pState == NULL) if (pState == NULL)
return; return;
@ -91,8 +88,7 @@ NState_Free(NulibState* pState)
#ifdef DEBUG_MSGS #ifdef DEBUG_MSGS
void void NState_DebugDump(const NulibState* pState)
NState_DebugDump(const NulibState* pState)
{ {
/* this table will break if the code changes, but it's just for debugging */ /* this table will break if the code changes, but it's just for debugging */
static const char* kCommandNames[] = { static const char* kCommandNames[] = {
@ -162,139 +158,117 @@ NState_DebugDump(const NulibState* pState)
* =========================================================================== * ===========================================================================
*/ */
char char NState_GetSystemPathSeparator(const NulibState* pState)
NState_GetSystemPathSeparator(const NulibState* pState)
{ {
return pState->systemPathSeparator; return pState->systemPathSeparator;
} }
char char NState_GetAltSystemPathSeparator(const NulibState* pState)
NState_GetAltSystemPathSeparator(const NulibState* pState)
{ {
return pState->altSystemPathSeparator; return pState->altSystemPathSeparator;
} }
const char* const char* NState_GetProgramVersion(const NulibState* pState)
NState_GetProgramVersion(const NulibState* pState)
{ {
return pState->programVersion; return pState->programVersion;
} }
NuArchive* NuArchive* NState_GetNuArchive(const NulibState* pState)
NState_GetNuArchive(const NulibState* pState)
{ {
return pState->pArchive; return pState->pArchive;
} }
void void NState_SetNuArchive(NulibState* pState, NuArchive* pArchive)
NState_SetNuArchive(NulibState* pState, NuArchive* pArchive)
{ {
pState->pArchive = pArchive; pState->pArchive = pArchive;
} }
Boolean Boolean NState_GetSuppressOutput(const NulibState* pState)
NState_GetSuppressOutput(const NulibState* pState)
{ {
return pState->suppressOutput; return pState->suppressOutput;
} }
void void NState_SetSuppressOutput(NulibState* pState, Boolean doSuppress)
NState_SetSuppressOutput(NulibState* pState, Boolean doSuppress)
{ {
pState->suppressOutput = doSuppress; pState->suppressOutput = doSuppress;
} }
Boolean Boolean NState_GetInputUnavailable(const NulibState* pState)
NState_GetInputUnavailable(const NulibState* pState)
{ {
return pState->inputUnavailable; return pState->inputUnavailable;
} }
void void NState_SetInputUnavailable(NulibState* pState, Boolean isUnavailable)
NState_SetInputUnavailable(NulibState* pState, Boolean isUnavailable)
{ {
pState->inputUnavailable = isUnavailable; pState->inputUnavailable = isUnavailable;
} }
NuRecordIdx NuRecordIdx NState_GetRenameFromIdx(const NulibState* pState)
NState_GetRenameFromIdx(const NulibState* pState)
{ {
return pState->renameFromIdx; return pState->renameFromIdx;
} }
void void NState_SetRenameFromIdx(NulibState* pState, NuRecordIdx recordIdx)
NState_SetRenameFromIdx(NulibState* pState, NuRecordIdx recordIdx)
{ {
pState->renameFromIdx = recordIdx; pState->renameFromIdx = recordIdx;
} }
char* char* NState_GetRenameToStr(const NulibState* pState)
NState_GetRenameToStr(const NulibState* pState)
{ {
return pState->renameToStr; return pState->renameToStr;
} }
void void NState_SetRenameToStr(NulibState* pState, char* str)
NState_SetRenameToStr(NulibState* pState, char* str)
{ {
Free(pState->renameToStr); Free(pState->renameToStr);
pState->renameToStr = str; pState->renameToStr = str;
} }
NuDataSink* NuDataSink* NState_GetPipeSink(const NulibState* pState)
NState_GetPipeSink(const NulibState* pState)
{ {
return pState->pPipeSink; return pState->pPipeSink;
} }
NuDataSink* NuDataSink* NState_GetCommentSink(const NulibState* pState)
NState_GetCommentSink(const NulibState* pState)
{ {
return pState->pCommentSink; return pState->pCommentSink;
} }
long long NState_GetMatchCount(const NulibState* pState)
NState_GetMatchCount(const NulibState* pState)
{ {
return pState->matchCount; return pState->matchCount;
} }
void void NState_SetMatchCount(NulibState* pState, long count)
NState_SetMatchCount(NulibState* pState, long count)
{ {
pState->matchCount = count; pState->matchCount = count;
} }
void void NState_IncMatchCount(NulibState* pState)
NState_IncMatchCount(NulibState* pState)
{ {
pState->matchCount++; pState->matchCount++;
} }
void void NState_AddToTotals(NulibState* pState, long len, long compLen)
NState_AddToTotals(NulibState* pState, long len, long compLen)
{ {
pState->totalLen += len; pState->totalLen += len;
pState->totalCompLen += compLen; pState->totalCompLen += compLen;
} }
void void NState_GetTotals(NulibState* pState, long* pTotalLen, long* pTotalCompLen)
NState_GetTotals(NulibState* pState, long* pTotalLen, long* pTotalCompLen)
{ {
*pTotalLen = pState->totalLen; *pTotalLen = pState->totalLen;
*pTotalCompLen = pState->totalCompLen; *pTotalCompLen = pState->totalCompLen;
} }
long long NState_GetTempPathnameLen(NulibState* pState)
NState_GetTempPathnameLen(NulibState* pState)
{ {
return pState->tempPathnameAlloc; return pState->tempPathnameAlloc;
} }
void void NState_SetTempPathnameLen(NulibState* pState, long len)
NState_SetTempPathnameLen(NulibState* pState, long len)
{ {
char* newBuf; char* newBuf;
@ -319,237 +293,198 @@ NState_SetTempPathnameLen(NulibState* pState, long len)
} }
} }
char* char* NState_GetTempPathnameBuf(NulibState* pState)
NState_GetTempPathnameBuf(NulibState* pState)
{ {
return pState->tempPathnameBuf; return pState->tempPathnameBuf;
} }
Command Command NState_GetCommand(const NulibState* pState)
NState_GetCommand(const NulibState* pState)
{ {
return pState->command; return pState->command;
} }
void void NState_SetCommand(NulibState* pState, Command cmd)
NState_SetCommand(NulibState* pState, Command cmd)
{ {
pState->command = cmd; pState->command = cmd;
} }
const char* const char* NState_GetArchiveFilename(const NulibState* pState)
NState_GetArchiveFilename(const NulibState* pState)
{ {
return pState->archiveFilename; return pState->archiveFilename;
} }
void void NState_SetArchiveFilename(NulibState* pState, const char* archiveFilename)
NState_SetArchiveFilename(NulibState* pState, const char* archiveFilename)
{ {
pState->archiveFilename = archiveFilename; pState->archiveFilename = archiveFilename;
} }
char* const* char* const* NState_GetFilespecPointer(const NulibState* pState)
NState_GetFilespecPointer(const NulibState* pState)
{ {
return pState->filespecPointer; return pState->filespecPointer;
} }
void void NState_SetFilespecPointer(NulibState* pState, char* const* filespecPointer)
NState_SetFilespecPointer(NulibState* pState, char* const* filespecPointer)
{ {
pState->filespecPointer = filespecPointer; pState->filespecPointer = filespecPointer;
} }
long long NState_GetFilespecCount(const NulibState* pState)
NState_GetFilespecCount(const NulibState* pState)
{ {
return pState->filespecCount; return pState->filespecCount;
} }
void void NState_SetFilespecCount(NulibState* pState, long filespecCount)
NState_SetFilespecCount(NulibState* pState, long filespecCount)
{ {
pState->filespecCount = filespecCount; pState->filespecCount = filespecCount;
} }
Boolean Boolean NState_GetModUpdate(const NulibState* pState)
NState_GetModUpdate(const NulibState* pState)
{ {
return pState->modUpdate; return pState->modUpdate;
} }
void void NState_SetModUpdate(NulibState* pState, Boolean val)
NState_SetModUpdate(NulibState* pState, Boolean val)
{ {
pState->modUpdate = val; pState->modUpdate = val;
} }
Boolean Boolean NState_GetModFreshen(const NulibState* pState)
NState_GetModFreshen(const NulibState* pState)
{ {
return pState->modFreshen; return pState->modFreshen;
} }
void void NState_SetModFreshen(NulibState* pState, Boolean val)
NState_SetModFreshen(NulibState* pState, Boolean val)
{ {
pState->modFreshen = val; pState->modFreshen = val;
} }
Boolean Boolean NState_GetModRecurse(const NulibState* pState)
NState_GetModRecurse(const NulibState* pState)
{ {
return pState->modRecurse; return pState->modRecurse;
} }
void void NState_SetModRecurse(NulibState* pState, Boolean val)
NState_SetModRecurse(NulibState* pState, Boolean val)
{ {
pState->modRecurse = val; pState->modRecurse = val;
} }
Boolean Boolean NState_GetModJunkPaths(const NulibState* pState)
NState_GetModJunkPaths(const NulibState* pState)
{ {
return pState->modJunkPaths; return pState->modJunkPaths;
} }
void void NState_SetModJunkPaths(NulibState* pState, Boolean val)
NState_SetModJunkPaths(NulibState* pState, Boolean val)
{ {
pState->modJunkPaths = val; pState->modJunkPaths = val;
} }
Boolean Boolean NState_GetModNoCompression(const NulibState* pState)
NState_GetModNoCompression(const NulibState* pState)
{ {
return pState->modNoCompression; return pState->modNoCompression;
} }
void void NState_SetModNoCompression(NulibState* pState, Boolean val)
NState_SetModNoCompression(NulibState* pState, Boolean val)
{ {
pState->modNoCompression = val; pState->modNoCompression = val;
} }
Boolean Boolean NState_GetModCompressDeflate(const NulibState* pState)
NState_GetModCompressDeflate(const NulibState* pState)
{ {
return pState->modCompressDeflate; return pState->modCompressDeflate;
} }
void void NState_SetModCompressDeflate(NulibState* pState, Boolean val)
NState_SetModCompressDeflate(NulibState* pState, Boolean val)
{ {
pState->modCompressDeflate = val; pState->modCompressDeflate = val;
} }
Boolean Boolean NState_GetModCompressBzip2(const NulibState* pState)
NState_GetModCompressBzip2(const NulibState* pState)
{ {
return pState->modCompressBzip2; return pState->modCompressBzip2;
} }
void void NState_SetModCompressBzip2(NulibState* pState, Boolean val)
NState_SetModCompressBzip2(NulibState* pState, Boolean val)
{ {
pState->modCompressBzip2 = val; pState->modCompressBzip2 = val;
} }
Boolean Boolean NState_GetModComments(const NulibState* pState)
NState_GetModComments(const NulibState* pState)
{ {
return pState->modComments; return pState->modComments;
} }
void void NState_SetModComments(NulibState* pState, Boolean val)
NState_SetModComments(NulibState* pState, Boolean val)
{ {
pState->modComments = val; pState->modComments = val;
} }
Boolean Boolean NState_GetModBinaryII(const NulibState* pState)
NState_GetModBinaryII(const NulibState* pState)
{ {
return pState->modBinaryII; return pState->modBinaryII;
} }
void void NState_SetModBinaryII(NulibState* pState, Boolean val)
NState_SetModBinaryII(NulibState* pState, Boolean val)
{ {
pState->modBinaryII = val; pState->modBinaryII = val;
} }
Boolean Boolean NState_GetModConvertText(const NulibState* pState)
NState_GetModConvertText(const NulibState* pState)
{ {
return pState->modConvertText; return pState->modConvertText;
} }
void void NState_SetModConvertText(NulibState* pState, Boolean val)
NState_SetModConvertText(NulibState* pState, Boolean val)
{ {
pState->modConvertText = val; pState->modConvertText = val;
} }
Boolean Boolean NState_GetModConvertAll(const NulibState* pState)
NState_GetModConvertAll(const NulibState* pState)
{ {
return pState->modConvertAll; return pState->modConvertAll;
} }
void void NState_SetModConvertAll(NulibState* pState, Boolean val)
NState_SetModConvertAll(NulibState* pState, Boolean val)
{ {
pState->modConvertAll = val; pState->modConvertAll = val;
} }
Boolean Boolean NState_GetModOverwriteExisting(const NulibState* pState)
NState_GetModOverwriteExisting(const NulibState* pState)
{ {
return pState->modOverwriteExisting; return pState->modOverwriteExisting;
} }
void void NState_SetModOverwriteExisting(NulibState* pState, Boolean val)
NState_SetModOverwriteExisting(NulibState* pState, Boolean val)
{ {
pState->modOverwriteExisting = val; pState->modOverwriteExisting = val;
} }
Boolean Boolean NState_GetModAddAsDisk(const NulibState* pState)
NState_GetModAddAsDisk(const NulibState* pState)
{ {
return pState->modAddAsDisk; return pState->modAddAsDisk;
} }
void void NState_SetModAddAsDisk(NulibState* pState, Boolean val)
NState_SetModAddAsDisk(NulibState* pState, Boolean val)
{ {
pState->modAddAsDisk = val; pState->modAddAsDisk = val;
} }
Boolean Boolean NState_GetModPreserveType(const NulibState* pState)
NState_GetModPreserveType(const NulibState* pState)
{ {
return pState->modPreserveType; return pState->modPreserveType;
} }
void void NState_SetModPreserveType(NulibState* pState, Boolean val)
NState_SetModPreserveType(NulibState* pState, Boolean val)
{ {
pState->modPreserveType = val; pState->modPreserveType = val;
} }
Boolean Boolean NState_GetModPreserveTypeExtended(const NulibState* pState)
NState_GetModPreserveTypeExtended(const NulibState* pState)
{ {
return pState->modPreserveTypeExtended; return pState->modPreserveTypeExtended;
} }
void void NState_SetModPreserveTypeExtended(NulibState* pState, Boolean val)
NState_SetModPreserveTypeExtended(NulibState* pState, Boolean val)
{ {
pState->modPreserveTypeExtended = val; pState->modPreserveTypeExtended = val;
} }

View File

@ -71,9 +71,8 @@
* as well just let the filesystem truncate if it gets too long, rather * as well just let the filesystem truncate if it gets too long, rather
* than worry about truncating it cleverly. * than worry about truncating it cleverly.
*/ */
static NuError static NuError UNIXNormalizeFileName(NulibState* pState, const char* srcp,
UNIXNormalizeFileName(NulibState* pState, const char* srcp, long srcLen, long srcLen, char fssep, char** pDstp, long dstLen)
char fssep, char** pDstp, long dstLen)
{ {
char* dstp = *pDstp; char* dstp = *pDstp;
@ -130,9 +129,8 @@ static const char* fatReservedNames4[] = {
/* /*
* Filename normalization for Win32 filesystems. You can't use [ \/:*?"<>| ]. * Filename normalization for Win32 filesystems. You can't use [ \/:*?"<>| ].
*/ */
static NuError static NuError Win32NormalizeFileName(NulibState* pState, const char* srcp,
Win32NormalizeFileName(NulibState* pState, const char* srcp, long srcLen, long srcLen, char fssep, char** pDstp, long dstLen)
char fssep, char** pDstp, long dstLen)
{ {
char* dstp = *pDstp; char* dstp = *pDstp;
const char* startp = srcp; const char* startp = srcp;
@ -219,8 +217,7 @@ Win32NormalizeFileName(NulibState* pState, const char* srcp, long srcLen,
* *
* The output buffer must be able to hold 3x the original string length. * The output buffer must be able to hold 3x the original string length.
*/ */
NuError NuError NormalizeFileName(NulibState* pState, const char* srcp, long srcLen,
NormalizeFileName(NulibState* pState, const char* srcp, long srcLen,
char fssep, char** pDstp, long dstLen) char fssep, char** pDstp, long dstLen)
{ {
NuError err; NuError err;
@ -247,9 +244,8 @@ NormalizeFileName(NulibState* pState, const char* srcp, long srcLen,
/* /*
* Normalize a directory name to local filesystem conventions. * Normalize a directory name to local filesystem conventions.
*/ */
NuError NuError NormalizeDirectoryName(NulibState* pState, const char* srcp,
NormalizeDirectoryName(NulibState* pState, const char* srcp, long srcLen, long srcLen, char fssep, char** pDstp, long dstLen)
char fssep, char** pDstp, long dstLen)
{ {
/* in general, directories and filenames are the same */ /* in general, directories and filenames are the same */
return NormalizeFileName(pState, srcp, srcLen, fssep, pDstp, dstLen); return NormalizeFileName(pState, srcp, srcLen, fssep, pDstp, dstLen);
@ -265,8 +261,7 @@ NormalizeDirectoryName(NulibState* pState, const char* srcp, long srcLen,
* under GS/OS it has to be in the same directory. Not sure what Mac OS * under GS/OS it has to be in the same directory. Not sure what Mac OS
* or Windows requires, so it's safest to just put it in the same dir. * or Windows requires, so it's safest to just put it in the same dir.
*/ */
char* char* MakeTempArchiveName(NulibState* pState)
MakeTempArchiveName(NulibState* pState)
{ {
const char* archivePathname; const char* archivePathname;
char fssep; char fssep;
@ -353,9 +348,8 @@ bail:
* *
* [ Someday we may want to modify this to handle symbolic links. ] * [ Someday we may want to modify this to handle symbolic links. ]
*/ */
NuError NuError CheckFileStatus(const char* pathname, struct stat* psb,
CheckFileStatus(const char* pathname, struct stat* psb, Boolean* pExists, Boolean* pExists, Boolean* pIsReadable, Boolean* pIsDir)
Boolean* pIsReadable, Boolean* pIsDir)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
int cc; int cc;
@ -398,8 +392,7 @@ bail:
/* /*
* Convert from time in seconds to DateTime format. * Convert from time in seconds to DateTime format.
*/ */
static void static void UNIXTimeToDateTime(const time_t* pWhen, NuDateTime *pDateTime)
UNIXTimeToDateTime(const time_t* pWhen, NuDateTime *pDateTime)
{ {
struct tm* ptm; struct tm* ptm;
@ -423,8 +416,7 @@ UNIXTimeToDateTime(const time_t* pWhen, NuDateTime *pDateTime)
* Replace "oldc" with "newc". If we find an instance of "newc" already * Replace "oldc" with "newc". If we find an instance of "newc" already
* in the string, replace it with "newSubst". * in the string, replace it with "newSubst".
*/ */
static void static void ReplaceFssep(char* str, char oldc, char newc, char newSubst)
ReplaceFssep(char* str, char oldc, char newc, char newSubst)
{ {
while (*str != '\0') { while (*str != '\0') {
if (*str == oldc) if (*str == oldc)
@ -439,9 +431,8 @@ ReplaceFssep(char* str, char oldc, char newc, char newSubst)
* Set the contents of a NuFileDetails structure, based on the pathname * Set the contents of a NuFileDetails structure, based on the pathname
* and characteristics of the file. * and characteristics of the file.
*/ */
static NuError static NuError GetFileDetails(NulibState* pState, const char* pathname,
GetFileDetails(NulibState* pState, const char* pathname, struct stat* psb, struct stat* psb, NuFileDetails* pDetails)
NuFileDetails* pDetails)
{ {
Boolean wasPreserved; Boolean wasPreserved;
Boolean doJunk = false; Boolean doJunk = false;
@ -621,8 +612,7 @@ GetFileDetails(NulibState* pState, const char* pathname, struct stat* psb,
* Do the system-independent part of the file add, including things like * Do the system-independent part of the file add, including things like
* adding comments. * adding comments.
*/ */
NuError NuError DoAddFile(NulibState* pState, NuArchive* pArchive, const char* pathname,
DoAddFile(NulibState* pState, NuArchive* pArchive, const char* pathname,
const NuFileDetails* pDetails) const NuFileDetails* pDetails)
{ {
NuError err; NuError err;
@ -707,8 +697,8 @@ static NuError UNIXAddFile(NulibState* pState, NuArchive* pArchive,
* If a subdirectory is found, follow it; otherwise, call UNIXAddFile to * If a subdirectory is found, follow it; otherwise, call UNIXAddFile to
* add the file. * add the file.
*/ */
static NuError static NuError UNIXAddDirectory(NulibState* pState, NuArchive* pArchive,
UNIXAddDirectory(NulibState* pState, NuArchive* pArchive, const char* dirName) const char* dirName)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
DIR* dirp = NULL; DIR* dirp = NULL;
@ -775,8 +765,8 @@ bail:
* *
* Returns with an error if the file doesn't exist or isn't readable. * Returns with an error if the file doesn't exist or isn't readable.
*/ */
static NuError static NuError UNIXAddFile(NulibState* pState, NuArchive* pArchive,
UNIXAddFile(NulibState* pState, NuArchive* pArchive, const char* pathname) const char* pathname)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Boolean exists, isDir, isReadable; Boolean exists, isDir, isReadable;
@ -848,8 +838,7 @@ static const char* kWildMatchAll = "*.*";
/* /*
* Prepare a directory for reading. * Prepare a directory for reading.
*/ */
static Win32dirent* static Win32dirent* OpenDir(const char* name)
OpenDir(const char* name)
{ {
Win32dirent* dir = NULL; Win32dirent* dir = NULL;
char* tmpStr = NULL; char* tmpStr = NULL;
@ -896,8 +885,7 @@ failed:
* *
* Returns a NULL pointer after the last entry has been read. * Returns a NULL pointer after the last entry has been read.
*/ */
static Win32dirent* static Win32dirent* ReadDir(Win32dirent* dir)
ReadDir(Win32dirent* dir)
{ {
if (dir->d_first) if (dir->d_first)
dir->d_first = 0; dir->d_first = 0;
@ -916,8 +904,7 @@ ReadDir(Win32dirent* dir)
/* /*
* Close a directory. * Close a directory.
*/ */
static void static void CloseDir(Win32dirent* dir)
CloseDir(Win32dirent* dir)
{ {
if (dir == NULL) if (dir == NULL)
return; return;
@ -939,8 +926,8 @@ static NuError Win32AddFile(NulibState* pState, NuArchive* pArchive,
* If a subdirectory is found, follow it; otherwise, call Win32AddFile to * If a subdirectory is found, follow it; otherwise, call Win32AddFile to
* add the file. * add the file.
*/ */
static NuError static NuError Win32AddDirectory(NulibState* pState, NuArchive* pArchive,
Win32AddDirectory(NulibState* pState, NuArchive* pArchive, const char* dirName) const char* dirName)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Win32dirent* dirp = NULL; Win32dirent* dirp = NULL;
@ -1005,8 +992,8 @@ bail:
* *
* Returns with an error if the file doesn't exist or isn't readable. * Returns with an error if the file doesn't exist or isn't readable.
*/ */
static NuError static NuError Win32AddFile(NulibState* pState, NuArchive* pArchive,
Win32AddFile(NulibState* pState, NuArchive* pArchive, const char* pathname) const char* pathname)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Boolean exists, isDir, isReadable; Boolean exists, isDir, isReadable;
@ -1076,8 +1063,7 @@ bail_quiet:
* from the directory read call and won't have to check it again in * from the directory read call and won't have to check it again in
* GSOSAddFile. ] * GSOSAddFile. ]
*/ */
NuError NuError AddFile(NulibState* pState, NuArchive* pArchive, const char* pathname)
AddFile(NulibState* pState, NuArchive* pArchive, const char* pathname)
{ {
#if defined(UNIX_LIKE) #if defined(UNIX_LIKE)
return UNIXAddFile(pState, pArchive, pathname); return UNIXAddFile(pState, pArchive, pathname);
@ -1094,8 +1080,7 @@ AddFile(NulibState* pState, NuArchive* pArchive, const char* pathname)
* *
* Currently only used by Binary2.c. * Currently only used by Binary2.c.
*/ */
NuError NuError Mkdir(const char* dir)
Mkdir(const char* dir)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1126,8 +1111,7 @@ bail:
* *
* Currently only used by Binary2.c. * Currently only used by Binary2.c.
*/ */
NuError NuError TestFileExistence(const char* fileName, Boolean* pIsDir)
TestFileExistence(const char* fileName, Boolean* pIsDir)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
Assert(fileName != NULL); Assert(fileName != NULL);
@ -1160,4 +1144,3 @@ bail:
return err; return err;
} }