diff --git a/nufxlib-0/ChangeLog.txt b/nufxlib-0/ChangeLog.txt index 8da1b61..de33d19 100644 --- a/nufxlib-0/ChangeLog.txt +++ b/nufxlib-0/ChangeLog.txt @@ -1,3 +1,6 @@ +2002/09/27 fadden + - added support for 12-bit and 16-bit LZC (UNIX compress) + 2002/09/26 fadden - added support for SQueezed files (both compress and expand) diff --git a/nufxlib-0/Compress.c b/nufxlib-0/Compress.c index 83e249c..56c1b3d 100644 --- a/nufxlib-0/Compress.c +++ b/nufxlib-0/Compress.c @@ -195,7 +195,16 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource, err = Nu_CompressLZW2(pArchive, pStraw, dstFp, srcLen, &dstLen, &threadCrc); break; + case kNuThreadFormatLZC12: + err = Nu_CompressLZC12(pArchive, pStraw, dstFp, srcLen, &dstLen, + &threadCrc); + break; + case kNuThreadFormatLZC16: + err = Nu_CompressLZC16(pArchive, pStraw, dstFp, srcLen, &dstLen, + &threadCrc); + break; default: + /* should've been blocked in Value.c */ Assert(0); err = kNuErrInternal; goto bail; diff --git a/nufxlib-0/Expand.c b/nufxlib-0/Expand.c index a59bb42..011743e 100644 --- a/nufxlib-0/Expand.c +++ b/nufxlib-0/Expand.c @@ -171,9 +171,7 @@ Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord, break; case kNuThreadFormatLZC12: case kNuThreadFormatLZC16: - err = kNuErrBadFormat; - Nu_ReportError(NU_BLOB, kNuErrNone, - "LZC-compressed threads not supported"); + err = Nu_ExpandLZC(pArchive, pRecord, pThread, infp, pFunnel, pCalcCrc); break; default: err = kNuErrBadFormat; @@ -190,7 +188,7 @@ Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord, if (pCalcCrc != nil) { if (calcCrc != pThread->thThreadCRC) { if (!Nu_ShouldIgnoreBadCRC(pArchive, pRecord, kNuErrBadThreadCRC)) { - err = kNuErrBadThreadCRC; + err = kNuErrBadDataCRC; Nu_ReportError(NU_BLOB, err, "expected 0x%04x, got 0x%04x", pThread->thThreadCRC, calcCrc); goto bail; diff --git a/nufxlib-0/Makefile.in b/nufxlib-0/Makefile.in index b91f90d..b85086a 100644 --- a/nufxlib-0/Makefile.in +++ b/nufxlib-0/Makefile.in @@ -27,11 +27,13 @@ GCC_FLAGS = -Wall -Wwrite-strings -Wstrict-prototypes -Wpointer-arith -Wshadow CFLAGS = @BUILD_FLAGS@ -I. @DEFS@ SRCS = Archive.c ArchiveIO.c Compress.c Crc16.c Debug.c Deferred.c \ - Entry.c Expand.c FileIO.c Funnel.c Lzw.c MiscStuff.c MiscUtils.c \ - Record.c SourceSink.c Squeeze.c Thread.c Value.c Version.c + Entry.c Expand.c FileIO.c Funnel.c Lzc.c Lzw.c MiscStuff.c \ + MiscUtils.c Record.c SourceSink.c Squeeze.c Thread.c Value.c \ + Version.c OBJS = Archive.o ArchiveIO.o Compress.o Crc16.o Debug.o Deferred.o \ - Entry.o Expand.o FileIO.o Funnel.o Lzw.o MiscStuff.o MiscUtils.o \ - Record.o SourceSink.o Squeeze.o Thread.o Value.o Version.o + Entry.o Expand.o FileIO.o Funnel.o Lzc.o Lzw.o MiscStuff.o \ + MiscUtils.o Record.o SourceSink.o Squeeze.o Thread.o Value.o \ + Version.o STATIC_PRODUCT = libnufx.a SHARED_PRODUCT = libnufx.so diff --git a/nufxlib-0/NufxLibPriv.h b/nufxlib-0/NufxLibPriv.h index a23dbb5..77ba660 100644 --- a/nufxlib-0/NufxLibPriv.h +++ b/nufxlib-0/NufxLibPriv.h @@ -631,13 +631,21 @@ NuError Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uchar* buffer, long len); NuError Nu_StrawRewind(NuArchive* pArchive, NuStraw* pStraw); +/* Lzc.c */ +NuError Nu_CompressLZC12(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, + ulong srcLen, ulong* pDstLen, ushort* pCrc); +NuError Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, + ulong srcLen, ulong* pDstLen, ushort* pCrc); +NuError Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord, + const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pThreadCrc); + /* Lzw.c */ NuError Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, ulong srcLen, ulong* pDstLen, ushort* pCrc); NuError Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, ulong srcLen, ulong* pDstLen, ushort* pCrc); NuError Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord, - const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc); + const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pThreadCrc); /* MiscUtils.c */ extern const char* kNufxLibName; diff --git a/nufxlib-0/Value.c b/nufxlib-0/Value.c index 7d4b9ad..0621a0c 100644 --- a/nufxlib-0/Value.c +++ b/nufxlib-0/Value.c @@ -208,10 +208,8 @@ Nu_ConvertCompressValToFormat(NuArchive* pArchive, NuValue compValue) case kNuCompressLZW1: threadFormat = kNuThreadFormatLZW1; break; case kNuCompressLZW2: threadFormat = kNuThreadFormatLZW2; break; case kNuCompressSQ: threadFormat = kNuThreadFormatHuffmanSQ; break; - case kNuCompressLZC12: threadFormat = kNuThreadFormatLZC12; - unsup = true; break; - case kNuCompressLZC16: threadFormat = kNuThreadFormatLZC16; - unsup = true; break; + case kNuCompressLZC12: threadFormat = kNuThreadFormatLZC12; break; + case kNuCompressLZC16: threadFormat = kNuThreadFormatLZC16; break; default: Assert(false); Nu_ReportError(NU_BLOB, kNuErrInvalidArg, @@ -221,7 +219,7 @@ Nu_ConvertCompressValToFormat(NuArchive* pArchive, NuValue compValue) if (unsup) { Nu_ReportError(NU_BLOB, kNuErrNone, - "Unsupported compression type 0x%04x requested (%ld)", + "Unsupported compression type 0x%04x requested (%ld), using none", threadFormat, compValue); return kNuThreadFormatUncompressed; }