mirror of https://github.com/fadden/nulib2.git
Compare commits
23 Commits
Author | SHA1 | Date |
---|---|---|
Andy McFadden | 811ebe9ba3 | |
Florian Weimer | 6eb33543cb | |
Andy McFadden | 0f957f9e83 | |
Andy McFadden | 918f318ca4 | |
Andy McFadden | ca8605c403 | |
Andy McFadden | 2a5e5bc299 | |
Kelvin Sherlock | ae66fba7bc | |
Andy McFadden | 0619ef3fe7 | |
Stephen Kitt | 7ec4eb46c7 | |
Stephen Kitt | 21a10ad266 | |
Stephen Kitt | f6ff60420b | |
Stephen Kitt | ea89644bfa | |
Andy McFadden | 9fdc77a108 | |
Andy McFadden | 137cafa05b | |
Andy McFadden | 20fe7efb4d | |
Andy McFadden | 51af83986c | |
Andy McFadden | bbeb9eaf90 | |
Andy McFadden | 7f158dd206 | |
Andy McFadden | eb40d65f1d | |
Andy McFadden | f37b387cc6 | |
Andy McFadden | bc96aa420b | |
Andy McFadden | 508531fb54 | |
Andy McFadden | ae8eec5d1b |
|
@ -11,5 +11,4 @@ A pre-built NuLib2 binary is available for x86 Windows. For Linux and
|
|||
Mac OS X systems, you can download the source code and build it.
|
||||
|
||||
More information, including full documentation for NuLib2 and NufxLib,
|
||||
can be found on http://www.nulib.com/.
|
||||
|
||||
can be found on https://nulib.com/ (or https://fadden.github.io/nulib2).
|
||||
|
|
|
@ -3,6 +3,7 @@ Makefile
|
|||
config.h
|
||||
config.log
|
||||
config.status
|
||||
nufxlib.pc
|
||||
|
||||
# generated binaries
|
||||
libnufx.a
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
2005/01/09 ***** v3.0.0 shipped *****
|
||||
2017/09/21 ***** v3.1.0 shipped *****
|
||||
|
||||
2016/01/11 fadden
|
||||
- Fix handling of disk images (broken by previous change).
|
||||
|
||||
2015/12/26 fadden
|
||||
- Fix handling of entries with missing threads.
|
||||
- Improve handling of Mac OS X file type attributes.
|
||||
|
||||
2015/01/09 ***** v3.0.0 shipped *****
|
||||
|
||||
2015/01/03 fadden
|
||||
- Mac OS X: replace Carbon FinderInfo calls with BSD xattr.
|
||||
|
|
|
@ -228,6 +228,13 @@ typedef struct NuFileInfo {
|
|||
|
||||
/*
|
||||
* Determine whether the record has both data and resource forks.
|
||||
*
|
||||
* TODO: if we're not using "mask dataless", scanning threads may not
|
||||
* get the right answer, because GSHK omits theads for zero-length forks.
|
||||
* We could check pRecord->recStorageType, though we have to be careful
|
||||
* because that's overloaded for disk images. In any event, the result
|
||||
* from this method isn't relevant unless we're trying to use forked
|
||||
* files on the native filesystem.
|
||||
*/
|
||||
static Boolean Nu_IsForkedFile(NuArchive* pArchive, const NuRecord* pRecord)
|
||||
{
|
||||
|
@ -320,20 +327,44 @@ static NuError Nu_SetFinderInfo(NuArchive* pArchive, const NuRecord* pRecord,
|
|||
return kNuErrFile;
|
||||
}
|
||||
|
||||
/* build type and creator from 8-bit type and 16-bit aux type */
|
||||
uint32_t fileType, creator;
|
||||
fileType = ('p' << 24) | ((pRecord->recFileType & 0xff) << 16) |
|
||||
(pRecord->recExtraType & 0xffff);
|
||||
creator = 'pdos';
|
||||
uint8_t proType = (uint8_t) pRecord->recFileType;
|
||||
uint16_t proAux = (uint16_t) pRecord->recExtraType;
|
||||
|
||||
fiBuf[0] = fileType >> 24;
|
||||
fiBuf[1] = fileType >> 16;
|
||||
fiBuf[2] = fileType >> 8;
|
||||
fiBuf[3] = fileType;
|
||||
fiBuf[4] = creator >> 24;
|
||||
fiBuf[5] = creator >> 16;
|
||||
fiBuf[6] = creator >> 8;
|
||||
fiBuf[7] = creator;
|
||||
/*
|
||||
* Attempt to use one of the convenience types. If nothing matches,
|
||||
* use the generic pdos/pXYZ approach. Note that PSYS/PS16 will
|
||||
* lose the file's aux type.
|
||||
*
|
||||
* I'm told this is from page 336 of _Programmer's Reference for
|
||||
* System 6.0_.
|
||||
*/
|
||||
uint8_t* fileTypeBuf = fiBuf;
|
||||
uint8_t* creatorBuf = fiBuf + 4;
|
||||
|
||||
memcpy(creatorBuf, "pdos", 4);
|
||||
if (proType == 0x00 && proAux == 0x0000) {
|
||||
memcpy(fileTypeBuf, "BINA", 4);
|
||||
} else if (proType == 0x04 && proAux == 0x0000) {
|
||||
memcpy(fileTypeBuf, "TEXT", 4);
|
||||
} else if (proType == 0xff) {
|
||||
memcpy(fileTypeBuf, "PSYS", 4);
|
||||
} else if (proType == 0xb3 && (proAux & 0xff00) != 0xdb00) {
|
||||
memcpy(fileTypeBuf, "PS16", 4);
|
||||
} else if (proType == 0xd7 && proAux == 0x0000) {
|
||||
memcpy(fileTypeBuf, "MIDI", 4);
|
||||
} else if (proType == 0xd8 && proAux == 0x0000) {
|
||||
memcpy(fileTypeBuf, "AIFF", 4);
|
||||
} else if (proType == 0xd8 && proAux == 0x0001) {
|
||||
memcpy(fileTypeBuf, "AIFC", 4);
|
||||
} else if (proType == 0xe0 && proAux == 0x0005) {
|
||||
memcpy(creatorBuf, "dCpy", 4);
|
||||
memcpy(fileTypeBuf, "dImg", 4);
|
||||
} else {
|
||||
fileTypeBuf[0] = 'p';
|
||||
fileTypeBuf[1] = proType;
|
||||
fileTypeBuf[2] = (uint8_t) (proAux >> 8);
|
||||
fileTypeBuf[3] = (uint8_t) proAux;
|
||||
}
|
||||
|
||||
if (setxattr(pathnameUNI, XATTR_FINDERINFO_NAME, fiBuf, sizeof(fiBuf),
|
||||
0, 0) != 0)
|
||||
|
|
|
@ -34,7 +34,7 @@ OPT = @CFLAGS@
|
|||
#OPT = @CFLAGS@ -DDEBUG_MSGS
|
||||
#OPT = @CFLAGS@ -DDEBUG_VERBOSE
|
||||
GCC_FLAGS = -Wall -Wwrite-strings -Wstrict-prototypes -Wpointer-arith -Wshadow
|
||||
CFLAGS = @BUILD_FLAGS@ -I. @DEFS@ -DOPTFLAGSTR="\"$(OPT)\""
|
||||
CFLAGS = @BUILD_FLAGS@ -I. @DEFS@ -fPIC -DOPTFLAGSTR="\"$(OPT)\""
|
||||
|
||||
SRCS = Archive.c ArchiveIO.c Bzip2.c Charset.c Compress.c Crc16.c \
|
||||
Debug.c Deferred.c Deflate.c Entry.c Expand.c FileIO.c Funnel.c \
|
||||
|
@ -60,16 +60,18 @@ all: $(PRODUCT) samples
|
|||
install: $(STATIC_PRODUCT)
|
||||
$(srcdir)/mkinstalldirs $(libdir)
|
||||
$(INSTALL_DATA) $(STATIC_PRODUCT) $(libdir)
|
||||
$(srcdir)/mkinstalldirs $(includedir)
|
||||
$(srcdir)/mkinstalldirs $(includedir) $(libdir)/pkgconfig
|
||||
$(INSTALL_DATA) NufxLib.h $(includedir)
|
||||
$(INSTALL_DATA) nufxlib.pc $(libdir)/pkgconfig
|
||||
|
||||
install-shared: $(SHARED_PRODUCT)
|
||||
$(srcdir)/mkinstalldirs $(libdir)
|
||||
$(INSTALL_DATA) $(SHARED_PRODUCT) $(libdir)
|
||||
$(srcdir)/mkinstalldirs $(includedir)
|
||||
$(srcdir)/mkinstalldirs $(includedir) $(libdir)/pkgconfig
|
||||
$(INSTALL_DATA) NufxLib.h $(includedir)
|
||||
$(INSTALL_DATA) nufxlib.pc $(libdir)/pkgconfig
|
||||
|
||||
samples::
|
||||
samples:: $(STATIC_PRODUCT)
|
||||
@echo "Building samples..."
|
||||
@(cd samples; set +e; unset CFLAGS OBJS; set -e; \
|
||||
@SET_MAKE@ LIB_PRODUCT="../$(PRODUCT)" $(MAKE))
|
||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
* fixes. Unless, of course, your code depends upon that fix.
|
||||
*/
|
||||
#define kNuVersionMajor 3
|
||||
#define kNuVersionMinor 0
|
||||
#define kNuVersionMinor 1
|
||||
#define kNuVersionBug 0
|
||||
|
||||
|
||||
|
@ -201,13 +201,16 @@ typedef uint32_t NuThreadID;
|
|||
#define kNuThreadClassControl 0x0001
|
||||
#define kNuThreadClassData 0x0002
|
||||
#define kNuThreadClassFilename 0x0003
|
||||
#define kNuThreadKindDataFork 0x0000 /* when class=data */
|
||||
#define kNuThreadKindDiskImage 0x0001 /* when class=data */
|
||||
#define kNuThreadKindRsrcFork 0x0002 /* when class=data */
|
||||
#define kNuThreadIDOldComment NuMakeThreadID(kNuThreadClassMessage, 0x0000)
|
||||
#define kNuThreadIDComment NuMakeThreadID(kNuThreadClassMessage, 0x0001)
|
||||
#define kNuThreadIDIcon NuMakeThreadID(kNuThreadClassMessage, 0x0002)
|
||||
#define kNuThreadIDMkdir NuMakeThreadID(kNuThreadClassControl, 0x0000)
|
||||
#define kNuThreadIDDataFork NuMakeThreadID(kNuThreadClassData, 0x0000)
|
||||
#define kNuThreadIDDiskImage NuMakeThreadID(kNuThreadClassData, 0x0001)
|
||||
#define kNuThreadIDRsrcFork NuMakeThreadID(kNuThreadClassData, 0x0002)
|
||||
#define kNuThreadIDDataFork NuMakeThreadID(kNuThreadClassData, kNuThreadKindDataFork)
|
||||
#define kNuThreadIDDiskImage NuMakeThreadID(kNuThreadClassData, kNuThreadKindDiskImage)
|
||||
#define kNuThreadIDRsrcFork NuMakeThreadID(kNuThreadClassData, kNuThreadKindRsrcFork)
|
||||
#define kNuThreadIDFilename NuMakeThreadID(kNuThreadClassFilename, 0x0000)
|
||||
#define kNuThreadIDWildcard NuMakeThreadID(0xffff, 0xffff)
|
||||
|
||||
|
|
|
@ -1524,7 +1524,7 @@ NuError Nu_StreamExtract(NuArchive* pArchive)
|
|||
{
|
||||
NuError err = kNuErrNone;
|
||||
NuRecord tmpRecord;
|
||||
Boolean hasInterestingThread;
|
||||
Boolean needFakeData, needFakeRsrc;
|
||||
uint32_t count;
|
||||
long idx;
|
||||
|
||||
|
@ -1573,7 +1573,8 @@ NuError Nu_StreamExtract(NuArchive* pArchive)
|
|||
/*Nu_DebugDumpRecord(&tmpRecord);
|
||||
printf("\n");*/
|
||||
|
||||
hasInterestingThread = false;
|
||||
needFakeData = true;
|
||||
needFakeRsrc = (tmpRecord.recStorageType == kNuStorageExtended);
|
||||
|
||||
/* extract all relevant (remaining) threads */
|
||||
pArchive->lastFileCreatedUNI = NULL;
|
||||
|
@ -1581,7 +1582,14 @@ NuError Nu_StreamExtract(NuArchive* pArchive)
|
|||
const NuThread* pThread = Nu_GetThread(&tmpRecord, idx);
|
||||
|
||||
if (pThread->thThreadClass == kNuThreadClassData) {
|
||||
hasInterestingThread = true;
|
||||
if (pThread->thThreadKind == kNuThreadKindDataFork) {
|
||||
needFakeData = false;
|
||||
} else if (pThread->thThreadKind == kNuThreadKindRsrcFork) {
|
||||
needFakeRsrc = false;
|
||||
} else if (pThread->thThreadKind == kNuThreadKindDiskImage) {
|
||||
/* needFakeRsrc shouldn't be set, but clear anyway */
|
||||
needFakeData = needFakeRsrc = false;
|
||||
}
|
||||
err = Nu_ExtractThreadBulk(pArchive, &tmpRecord, pThread);
|
||||
if (err == kNuErrSkipped) {
|
||||
err = Nu_SkipThread(pArchive, &tmpRecord, pThread);
|
||||
|
@ -1595,7 +1603,8 @@ NuError Nu_StreamExtract(NuArchive* pArchive)
|
|||
if (NuGetThreadID(pThread) != kNuThreadIDComment &&
|
||||
NuGetThreadID(pThread) != kNuThreadIDFilename)
|
||||
{
|
||||
hasInterestingThread = true;
|
||||
/* unknown stuff in record, skip thread fakery */
|
||||
needFakeData = needFakeRsrc = false;
|
||||
}
|
||||
err = Nu_SkipThread(pArchive, &tmpRecord, pThread);
|
||||
BailError(err);
|
||||
|
@ -1603,19 +1612,19 @@ NuError Nu_StreamExtract(NuArchive* pArchive)
|
|||
}
|
||||
|
||||
/*
|
||||
* If we're trying to be compatible with ShrinkIt, and the record
|
||||
* had nothing in it but comments and filenames, then we need to
|
||||
* create a zero-byte data file (and possibly a resource fork).
|
||||
*
|
||||
* See notes in previous instance, above.
|
||||
* As in Nu_ExtractRecordByPtr, we need to synthesize empty forks for
|
||||
* cases where GSHK omitted the data thread entirely.
|
||||
*/
|
||||
if (/*pArchive->valMaskDataless &&*/ !hasInterestingThread) {
|
||||
err = Nu_FakeZeroExtract(pArchive, &tmpRecord, 0x0000);
|
||||
Assert(!pArchive->valMaskDataless || (!needFakeData && !needFakeRsrc));
|
||||
if (needFakeData) {
|
||||
err = Nu_FakeZeroExtract(pArchive, &tmpRecord,
|
||||
kNuThreadKindDataFork);
|
||||
BailError(err);
|
||||
}
|
||||
if (needFakeRsrc) {
|
||||
err = Nu_FakeZeroExtract(pArchive, &tmpRecord,
|
||||
kNuThreadKindRsrcFork);
|
||||
BailError(err);
|
||||
if (tmpRecord.recStorageType == kNuStorageExtended) {
|
||||
err = Nu_FakeZeroExtract(pArchive, &tmpRecord, 0x0002);
|
||||
BailError(err);
|
||||
}
|
||||
}
|
||||
|
||||
/* dispose of the entry */
|
||||
|
@ -1698,20 +1707,29 @@ bail:
|
|||
static NuError Nu_ExtractRecordByPtr(NuArchive* pArchive, NuRecord* pRecord)
|
||||
{
|
||||
NuError err = kNuErrNone;
|
||||
Boolean hasInterestingThread;
|
||||
Boolean needFakeData, needFakeRsrc;
|
||||
uint32_t idx;
|
||||
|
||||
needFakeData = true;
|
||||
needFakeRsrc = (pRecord->recStorageType == kNuStorageExtended);
|
||||
|
||||
Assert(!Nu_IsStreaming(pArchive)); /* we don't skip things we don't read */
|
||||
Assert(pRecord != NULL);
|
||||
|
||||
/* extract all relevant threads */
|
||||
hasInterestingThread = false;
|
||||
pArchive->lastFileCreatedUNI = NULL;
|
||||
for (idx = 0; idx < pRecord->recTotalThreads; idx++) {
|
||||
const NuThread* pThread = Nu_GetThread(pRecord, idx);
|
||||
|
||||
if (pThread->thThreadClass == kNuThreadClassData) {
|
||||
hasInterestingThread = true;
|
||||
if (pThread->thThreadKind == kNuThreadKindDataFork) {
|
||||
needFakeData = false;
|
||||
} else if (pThread->thThreadKind == kNuThreadKindRsrcFork) {
|
||||
needFakeRsrc = false;
|
||||
} else if (pThread->thThreadKind == kNuThreadKindDiskImage) {
|
||||
/* needFakeRsrc shouldn't be set, but clear anyway */
|
||||
needFakeData = needFakeRsrc = false;
|
||||
}
|
||||
err = Nu_ExtractThreadBulk(pArchive, pRecord, pThread);
|
||||
if (err == kNuErrSkipped) {
|
||||
err = Nu_SkipThread(pArchive, pRecord, pThread);
|
||||
|
@ -1722,7 +1740,13 @@ static NuError Nu_ExtractRecordByPtr(NuArchive* pArchive, NuRecord* pRecord)
|
|||
if (NuGetThreadID(pThread) != kNuThreadIDComment &&
|
||||
NuGetThreadID(pThread) != kNuThreadIDFilename)
|
||||
{
|
||||
hasInterestingThread = true;
|
||||
/*
|
||||
* This record has a thread we don't recognize. Disable
|
||||
* the thread fakery to avoid doing anything weird -- we
|
||||
* should only need to create zero-length files for
|
||||
* simple file records.
|
||||
*/
|
||||
needFakeData = needFakeRsrc = false;
|
||||
}
|
||||
DBUG(("IGNORING 0x%08lx from '%s'\n",
|
||||
NuMakeThreadID(pThread->thThreadClass, pThread->thThreadKind),
|
||||
|
@ -1731,28 +1755,27 @@ static NuError Nu_ExtractRecordByPtr(NuArchive* pArchive, NuRecord* pRecord)
|
|||
}
|
||||
|
||||
/*
|
||||
* If we're trying to be compatible with ShrinkIt, and the record
|
||||
* had nothing in it but comments and filenames, then we need to
|
||||
* create a zero-byte file.
|
||||
* GSHK creates empty threads for zero-length forks. It doesn't always
|
||||
* handle them correctly when extracting, so it appears this behavior
|
||||
* may not be intentional.
|
||||
*
|
||||
* (GSHK handles empty data and resource forks by not storing a
|
||||
* thread at all. It doesn't correctly deal with them when extracting
|
||||
* though, so it appears this behavior wasn't entirely expected.)
|
||||
* We need to create an empty file for whichever forks are missing.
|
||||
* Could be the data fork, resource fork, or both. The only way to
|
||||
* know what's expected is to examine the file's storage type.
|
||||
*
|
||||
* If it's a forked file, we also need to create an empty rsrc file.
|
||||
*
|
||||
* If valMaskDataless is enabled, this won't fire, because we "forge"
|
||||
* appropriate threads.
|
||||
* If valMaskDataless is enabled, this won't fire, because we will have
|
||||
* "forged" the appropriate threads.
|
||||
*
|
||||
* Note there's another one of these below, in Nu_StreamExtract.
|
||||
*/
|
||||
if (/*pArchive->valMaskDataless &&*/ !hasInterestingThread) {
|
||||
err = Nu_FakeZeroExtract(pArchive, pRecord, 0x0000 /*data*/);
|
||||
Assert(!pArchive->valMaskDataless || (!needFakeData && !needFakeRsrc));
|
||||
if (needFakeData) {
|
||||
err = Nu_FakeZeroExtract(pArchive, pRecord, kNuThreadKindDataFork);
|
||||
BailError(err);
|
||||
}
|
||||
if (needFakeRsrc) {
|
||||
err = Nu_FakeZeroExtract(pArchive, pRecord, kNuThreadKindRsrcFork);
|
||||
BailError(err);
|
||||
if (pRecord->recStorageType == kNuStorageExtended) {
|
||||
err = Nu_FakeZeroExtract(pArchive, pRecord, 0x0002 /*rsrc*/);
|
||||
BailError(err);
|
||||
}
|
||||
}
|
||||
|
||||
bail:
|
||||
|
|
|
@ -67,8 +67,10 @@
|
|||
# include <direct.h>
|
||||
# define FOPEN_WANTS_B
|
||||
# define HAVE_CHSIZE
|
||||
# define snprintf _snprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
# if _MSC_VER < 1900 /* no snprintf until Visual Studio 2015 */
|
||||
# define snprintf _snprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -193,7 +193,10 @@ NuError Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord,
|
|||
NuError err = kNuErrNone;
|
||||
NuThread* pThread;
|
||||
long count;
|
||||
Boolean hasData = false;
|
||||
Boolean needFakeData, needFakeRsrc;
|
||||
|
||||
needFakeData = true;
|
||||
needFakeRsrc = (pRecord->recStorageType == kNuStorageExtended);
|
||||
|
||||
Assert(pArchive != NULL);
|
||||
Assert(pRecord != NULL);
|
||||
|
@ -215,8 +218,16 @@ NuError Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord,
|
|||
err = Nu_ReadThreadHeader(pArchive, pThread, pCrc);
|
||||
BailError(err);
|
||||
|
||||
if (pThread->thThreadClass == kNuThreadClassData)
|
||||
hasData = true;
|
||||
if (pThread->thThreadClass == kNuThreadClassData) {
|
||||
if (pThread->thThreadKind == kNuThreadKindDataFork) {
|
||||
needFakeData = false;
|
||||
} else if (pThread->thThreadKind == kNuThreadKindRsrcFork) {
|
||||
needFakeRsrc = false;
|
||||
} else if (pThread->thThreadKind == kNuThreadKindDiskImage) {
|
||||
/* needFakeRsrc shouldn't be set, but clear anyway */
|
||||
needFakeData = needFakeRsrc = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Some versions of ShrinkIt write an invalid thThreadEOF for disks,
|
||||
|
@ -258,13 +269,14 @@ NuError Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord,
|
|||
* If "mask threadless" is set, create "fake" threads with empty
|
||||
* data and resource forks as needed.
|
||||
*/
|
||||
if (!hasData && pArchive->valMaskDataless) {
|
||||
Boolean needRsrc = (pRecord->recStorageType == kNuStorageExtended);
|
||||
if ((needFakeData || needFakeRsrc) && pArchive->valMaskDataless) {
|
||||
int firstNewThread = pRecord->recTotalThreads;
|
||||
|
||||
pRecord->recTotalThreads++;
|
||||
pRecord->fakeThreads++;
|
||||
if (needRsrc) {
|
||||
if (needFakeData) {
|
||||
pRecord->recTotalThreads++;
|
||||
pRecord->fakeThreads++;
|
||||
}
|
||||
if (needFakeRsrc) {
|
||||
pRecord->recTotalThreads++;
|
||||
pRecord->fakeThreads++;
|
||||
}
|
||||
|
@ -275,22 +287,23 @@ NuError Nu_ReadThreadHeaders(NuArchive* pArchive, NuRecord* pRecord,
|
|||
|
||||
pThread = pRecord->pThreads + firstNewThread;
|
||||
|
||||
pThread->thThreadClass = kNuThreadClassData;
|
||||
pThread->thThreadFormat = kNuThreadFormatUncompressed;
|
||||
pThread->thThreadKind = 0x0000; /* data fork */
|
||||
pThread->thThreadCRC = kNuInitialThreadCRC;
|
||||
pThread->thThreadEOF = 0;
|
||||
pThread->thCompThreadEOF = 0;
|
||||
pThread->threadIdx = Nu_GetNextThreadIdx(pArchive);
|
||||
pThread->actualThreadEOF = 0;
|
||||
pThread->fileOffset = -99999999;
|
||||
pThread->used = false;
|
||||
|
||||
if (needRsrc) {
|
||||
pThread++;
|
||||
if (needFakeData) {
|
||||
pThread->thThreadClass = kNuThreadClassData;
|
||||
pThread->thThreadFormat = kNuThreadFormatUncompressed;
|
||||
pThread->thThreadKind = 0x0002; /* rsrc fork */
|
||||
pThread->thThreadKind = kNuThreadKindDataFork;
|
||||
pThread->thThreadCRC = kNuInitialThreadCRC;
|
||||
pThread->thThreadEOF = 0;
|
||||
pThread->thCompThreadEOF = 0;
|
||||
pThread->threadIdx = Nu_GetNextThreadIdx(pArchive);
|
||||
pThread->actualThreadEOF = 0;
|
||||
pThread->fileOffset = -99999999;
|
||||
pThread->used = false;
|
||||
pThread++;
|
||||
}
|
||||
if (needFakeRsrc) {
|
||||
pThread->thThreadClass = kNuThreadClassData;
|
||||
pThread->thThreadFormat = kNuThreadFormatUncompressed;
|
||||
pThread->thThreadKind = kNuThreadKindRsrcFork;
|
||||
pThread->thThreadCRC = kNuInitialThreadCRC;
|
||||
pThread->thThreadEOF = 0;
|
||||
pThread->thCompThreadEOF = 0;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -626,6 +626,7 @@ BUILD_FLAGS
|
|||
EGREP
|
||||
GREP
|
||||
CPP
|
||||
NUFX_VERSION
|
||||
RANLIB
|
||||
SET_MAKE
|
||||
INSTALL_DATA
|
||||
|
@ -665,6 +666,7 @@ infodir
|
|||
docdir
|
||||
oldincludedir
|
||||
includedir
|
||||
runstatedir
|
||||
localstatedir
|
||||
sharedstatedir
|
||||
sysconfdir
|
||||
|
@ -741,6 +743,7 @@ datadir='${datarootdir}'
|
|||
sysconfdir='${prefix}/etc'
|
||||
sharedstatedir='${prefix}/com'
|
||||
localstatedir='${prefix}/var'
|
||||
runstatedir='${localstatedir}/run'
|
||||
includedir='${prefix}/include'
|
||||
oldincludedir='/usr/include'
|
||||
docdir='${datarootdir}/doc/${PACKAGE}'
|
||||
|
@ -993,6 +996,15 @@ do
|
|||
| -silent | --silent | --silen | --sile | --sil)
|
||||
silent=yes ;;
|
||||
|
||||
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
||||
| --runstate | --runstat | --runsta | --runst | --runs \
|
||||
| --run | --ru | --r)
|
||||
ac_prev=runstatedir ;;
|
||||
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
||||
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
||||
| --run=* | --ru=* | --r=*)
|
||||
runstatedir=$ac_optarg ;;
|
||||
|
||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||
ac_prev=sbindir ;;
|
||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||
|
@ -1130,7 +1142,7 @@ fi
|
|||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||
libdir localedir mandir
|
||||
libdir localedir mandir runstatedir
|
||||
do
|
||||
eval ac_val=\$$ac_var
|
||||
# Remove trailing slashes.
|
||||
|
@ -1283,6 +1295,7 @@ Fine tuning of the installation directories:
|
|||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||
--includedir=DIR C header files [PREFIX/include]
|
||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||
|
@ -3273,6 +3286,10 @@ else
|
|||
fi
|
||||
|
||||
|
||||
NUFX_VERSION=3.1.0
|
||||
|
||||
|
||||
|
||||
|
||||
ac_ext=c
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
|
@ -3917,7 +3934,8 @@ rm -f conftest*
|
|||
fi
|
||||
|
||||
if test $nufxlib_cv_snprintf_in_header = "yes"; then
|
||||
$as_echo "#define SNPRINTF_DECLARED 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define SNPRINTF_DECLARED /**/" >>confdefs.h
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nufxlib_cv_snprintf_in_header" >&5
|
||||
|
@ -3946,7 +3964,8 @@ rm -f conftest*
|
|||
fi
|
||||
|
||||
if test $nufxlib_cv_vsnprintf_in_header = "yes"; then
|
||||
$as_echo "#define VSNPRINTF_DECLARED 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define VSNPRINTF_DECLARED /**/" >>confdefs.h
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nufxlib_cv_vsnprintf_in_header" >&5
|
||||
|
@ -4014,7 +4033,7 @@ else
|
|||
int count;
|
||||
char buf[8];
|
||||
count = sprintf(buf, "123"); /* should return three */
|
||||
exit(count != 3);
|
||||
return count != 3;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
|
@ -4032,7 +4051,8 @@ fi
|
|||
|
||||
|
||||
if test $nufxlib_cv_sprintf_returns_int = "yes"; then
|
||||
$as_echo "#define SPRINTF_RETURNS_INT 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define SPRINTF_RETURNS_INT /**/" >>confdefs.h
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nufxlib_cv_sprintf_returns_int" >&5
|
||||
|
@ -4047,7 +4067,8 @@ else
|
|||
fi
|
||||
|
||||
if test $enable_sq = "yes"; then
|
||||
$as_echo "#define ENABLE_SQ 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define ENABLE_SQ /**/" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
|
@ -4059,7 +4080,8 @@ else
|
|||
fi
|
||||
|
||||
if test $enable_lzw = "yes"; then
|
||||
$as_echo "#define ENABLE_LZW 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define ENABLE_LZW /**/" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
|
@ -4071,7 +4093,8 @@ else
|
|||
fi
|
||||
|
||||
if test $enable_lzc = "yes"; then
|
||||
$as_echo "#define ENABLE_LZC 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define ENABLE_LZC /**/" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
|
@ -4136,7 +4159,8 @@ fi
|
|||
fi
|
||||
if $got_zlibh; then
|
||||
echo " (found libz and zlib.h, enabling deflate)"
|
||||
$as_echo "#define ENABLE_DEFLATE 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define ENABLE_DEFLATE /**/" >>confdefs.h
|
||||
|
||||
else
|
||||
echo " (couldn't find libz and zlib.h, not enabling deflate)"
|
||||
|
@ -4204,7 +4228,8 @@ fi
|
|||
fi
|
||||
if $got_bzlibh; then
|
||||
echo " (found libbz2 and bzlib.h, enabling bzip2)"
|
||||
$as_echo "#define ENABLE_BZIP2 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define ENABLE_BZIP2 /**/" >>confdefs.h
|
||||
|
||||
else
|
||||
echo " (couldn't find libbz2 and bzlib.h, not enabling bzip2)"
|
||||
|
@ -4215,12 +4240,13 @@ fi
|
|||
# Check whether --enable-dmalloc was given.
|
||||
if test "${enable_dmalloc+set}" = set; then :
|
||||
enableval=$enable_dmalloc; echo "--- enabling dmalloc";
|
||||
LIBS="$LIBS -L/usr/local/lib -ldmalloc"; $as_echo "#define USE_DMALLOC 1" >>confdefs.h
|
||||
LIBS="$LIBS -L/usr/local/lib -ldmalloc";
|
||||
$as_echo "#define USE_DMALLOC /**/" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile samples/Makefile"
|
||||
ac_config_files="$ac_config_files Makefile samples/Makefile nufxlib.pc"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
|
@ -4915,6 +4941,7 @@ do
|
|||
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
|
||||
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
||||
"samples/Makefile") CONFIG_FILES="$CONFIG_FILES samples/Makefile" ;;
|
||||
"nufxlib.pc") CONFIG_FILES="$CONFIG_FILES nufxlib.pc" ;;
|
||||
|
||||
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
|
||||
esac
|
||||
|
|
|
@ -16,6 +16,10 @@ AC_PROG_INSTALL
|
|||
AC_PROG_MAKE_SET
|
||||
AC_PROG_RANLIB
|
||||
|
||||
NUFX_VERSION=3.1.0
|
||||
AC_SUBST(NUFX_VERSION)
|
||||
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_CHECK_HEADERS(fcntl.h malloc.h stdlib.h sys/stat.h sys/time.h sys/types.h \
|
||||
sys/utime.h unistd.h utime.h)
|
||||
|
@ -42,7 +46,7 @@ AC_CACHE_VAL(nufxlib_cv_snprintf_in_header, [
|
|||
[nufxlib_cv_snprintf_in_header=no])
|
||||
])
|
||||
if test $nufxlib_cv_snprintf_in_header = "yes"; then
|
||||
AC_DEFINE(SNPRINTF_DECLARED)
|
||||
AC_DEFINE(SNPRINTF_DECLARED, [], [Define it SNPRINTF is declared in stdio.h.])
|
||||
fi
|
||||
AC_MSG_RESULT($nufxlib_cv_snprintf_in_header)
|
||||
|
||||
|
@ -54,7 +58,7 @@ AC_CACHE_VAL(nufxlib_cv_vsnprintf_in_header, [
|
|||
[nufxlib_cv_vsnprintf_in_header=no])
|
||||
])
|
||||
if test $nufxlib_cv_vsnprintf_in_header = "yes"; then
|
||||
AC_DEFINE(VSNPRINTF_DECLARED)
|
||||
AC_DEFINE(VSNPRINTF_DECLARED, [], [Define if VSNPRINTF is declared in stdio.h.])
|
||||
fi
|
||||
AC_MSG_RESULT($nufxlib_cv_vsnprintf_in_header)
|
||||
|
||||
|
@ -130,7 +134,7 @@ AC_CACHE_VAL(nufxlib_cv_sprintf_returns_int, [
|
|||
int count;
|
||||
char buf[8];
|
||||
count = sprintf(buf, "123"); /* should return three */
|
||||
exit(count != 3);
|
||||
return count != 3;
|
||||
}
|
||||
],
|
||||
[nufxlib_cv_sprintf_returns_int=yes], [nufxlib_cv_sprintf_returns_int=no],
|
||||
|
@ -138,7 +142,7 @@ AC_CACHE_VAL(nufxlib_cv_sprintf_returns_int, [
|
|||
])
|
||||
|
||||
if test $nufxlib_cv_sprintf_returns_int = "yes"; then
|
||||
AC_DEFINE(SPRINTF_RETURNS_INT)
|
||||
AC_DEFINE(SPRINTF_RETURNS_INT, [], [Define if sprintf returns an int.])
|
||||
fi
|
||||
AC_MSG_RESULT($nufxlib_cv_sprintf_returns_int)
|
||||
|
||||
|
@ -155,21 +159,21 @@ AC_ARG_ENABLE(sq,
|
|||
[ --disable-sq disable SQ compression],
|
||||
[ ], [ enable_sq=yes ])
|
||||
if test $enable_sq = "yes"; then
|
||||
AC_DEFINE(ENABLE_SQ)
|
||||
AC_DEFINE(ENABLE_SQ, [], [Define to include SQ (Huffman+RLE) compression.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(lzw,
|
||||
[ --disable-lzw disable LZW/1 and LZW/2 compression],
|
||||
[ ], [ enable_lzw=yes ])
|
||||
if test $enable_lzw = "yes"; then
|
||||
AC_DEFINE(ENABLE_LZW)
|
||||
AC_DEFINE(ENABLE_LZW, [], [Define to include LZW (ShrinkIt LZW/1 and LZW/2) compression.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(lzc,
|
||||
[ --disable-lzc disable 12- and 16-bit LZC compression],
|
||||
[ ], [ enable_lzc=yes ])
|
||||
if test $enable_lzc = "yes"; then
|
||||
AC_DEFINE(ENABLE_LZC)
|
||||
AC_DEFINE(ENABLE_LZC, [], [Define to include LZC (12-bit and 16-bit UNIX "compress") compression.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(deflate,
|
||||
|
@ -184,7 +188,7 @@ if test $enable_deflate = "yes"; then
|
|||
fi
|
||||
if $got_zlibh; then
|
||||
echo " (found libz and zlib.h, enabling deflate)"
|
||||
AC_DEFINE(ENABLE_DEFLATE)
|
||||
AC_DEFINE(ENABLE_DEFLATE, [], [Define to include deflate (zlib) compression (also need -l in Makefile).])
|
||||
else
|
||||
echo " (couldn't find libz and zlib.h, not enabling deflate)"
|
||||
fi
|
||||
|
@ -204,7 +208,7 @@ if test $enable_bzip2 = "yes"; then
|
|||
fi
|
||||
if $got_bzlibh; then
|
||||
echo " (found libbz2 and bzlib.h, enabling bzip2)"
|
||||
AC_DEFINE(ENABLE_BZIP2)
|
||||
AC_DEFINE(ENABLE_BZIP2, [], [Define to include bzip2 (libbz2) compression (also need -l in Makefile).])
|
||||
else
|
||||
echo " (couldn't find libbz2 and bzlib.h, not enabling bzip2)"
|
||||
fi
|
||||
|
@ -213,6 +217,6 @@ fi
|
|||
|
||||
AC_ARG_ENABLE(dmalloc, [ --enable-dmalloc do dmalloc stuff],
|
||||
[ echo "--- enabling dmalloc";
|
||||
LIBS="$LIBS -L/usr/local/lib -ldmalloc"; AC_DEFINE(USE_DMALLOC) ])
|
||||
LIBS="$LIBS -L/usr/local/lib -ldmalloc"; AC_DEFINE(USE_DMALLOC, [], [Define if we want to use the dmalloc library (also need -l in Makefile).]) ])
|
||||
|
||||
AC_OUTPUT(Makefile samples/Makefile)
|
||||
AC_OUTPUT(Makefile samples/Makefile nufxlib.pc)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: nufxlib
|
||||
Description: NuFX archive manipulation library.
|
||||
Version: @NUFX_VERSION@
|
||||
Libs: -L${libdir} -lnufx @LIBS@
|
||||
Cflags: -I${includedir}
|
|
@ -24,6 +24,15 @@ static const char kFssep = PATH_SEP;
|
|||
|
||||
#define kTempFile "exer-temp"
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
static int strcasecmp(const char *str1, const char *str2)
|
||||
{
|
||||
while (*str1 && *str2 && toupper(*str1) == toupper(*str2))
|
||||
str1++, str2++;
|
||||
return (toupper(*str1) - toupper(*str2));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* ===========================================================================
|
||||
|
@ -364,13 +373,25 @@ static NuError AbortFunc(ExerciserState* pState, int argc, char** argv)
|
|||
static NuError AddFileFunc(ExerciserState* pState, int argc, char** argv)
|
||||
{
|
||||
NuFileDetails nuFileDetails;
|
||||
int fromRsrc = false;
|
||||
|
||||
(void) pState, (void) argc, (void) argv; /* shut up, gcc */
|
||||
assert(ExerciserState_GetNuArchive(pState) != NULL);
|
||||
assert(argc == 2);
|
||||
assert(argc == 3);
|
||||
|
||||
if (strcasecmp(argv[2], "true") == 0) {
|
||||
fromRsrc = true;
|
||||
} else if (strcasecmp(argv[2], "false") != 0) {
|
||||
fprintf(stderr, "WARNING: fromRsrc should be 'true' or 'false'\n");
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
memset(&nuFileDetails, 0, sizeof(nuFileDetails));
|
||||
nuFileDetails.threadID = kNuThreadIDDataFork;
|
||||
if (fromRsrc) {
|
||||
nuFileDetails.threadID = kNuThreadIDRsrcFork;
|
||||
} else {
|
||||
nuFileDetails.threadID = kNuThreadIDDataFork;
|
||||
}
|
||||
nuFileDetails.storageNameMOR = argv[1];
|
||||
nuFileDetails.fileSysID = kNuFileSysUnknown;
|
||||
nuFileDetails.fileSysInfo = (short) kFssep;
|
||||
|
@ -378,7 +399,7 @@ static NuError AddFileFunc(ExerciserState* pState, int argc, char** argv)
|
|||
/* fileType, extraType, storageType, dates */
|
||||
|
||||
return NuAddFile(ExerciserState_GetNuArchive(pState), argv[1],
|
||||
&nuFileDetails, false, NULL);
|
||||
&nuFileDetails, fromRsrc, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1039,7 +1060,7 @@ static const struct {
|
|||
|
||||
{ "ab", AbortFunc, 0, "", kFlagArchiveReq,
|
||||
"Abort current changes" },
|
||||
{ "af", AddFileFunc, 1, "filename", kFlagArchiveReq,
|
||||
{ "af", AddFileFunc, 2, "filename fromRsrc", kFlagArchiveReq,
|
||||
"Add file" },
|
||||
{ "ar", AddRecordFunc, 1, "storageName", kFlagArchiveReq,
|
||||
"Add record" },
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
#include "Common.h"
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
static int
|
||||
strcasecmp(const char *str1, const char *str2)
|
||||
static int strcasecmp(const char *str1, const char *str2)
|
||||
{
|
||||
while (*str1 && *str2 && toupper(*str1) == toupper(*str2))
|
||||
str1++, str2++;
|
||||
|
|
|
@ -298,7 +298,8 @@ int Test_AddStuff(NuArchive* pArchive)
|
|||
|
||||
|
||||
/*
|
||||
* Create an empty file with a rather non-empty name.
|
||||
* Create an empty file with a rather non-empty name. Add it as
|
||||
* a resource fork.
|
||||
*/
|
||||
printf("... add 'long' record\n");
|
||||
err = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
||||
|
@ -454,7 +455,8 @@ failed:
|
|||
|
||||
|
||||
/*
|
||||
* Selection callback filter for "test". This gets called once per record.
|
||||
* Selection callback filter for "test". This gets called once per record,
|
||||
* twice per record for forked files.
|
||||
*/
|
||||
NuResult VerifySelectionCallback(NuArchive* pArchive, void* vpProposal)
|
||||
{
|
||||
|
@ -523,7 +525,9 @@ int Test_Verify(NuArchive* pArchive)
|
|||
goto failed;
|
||||
}
|
||||
|
||||
if (count != kNumEntries) {
|
||||
/* the count will be one higher than the number of records because
|
||||
the last entry is forked, and each fork is tested separately */
|
||||
if (count != kNumEntries + 1) {
|
||||
fprintf(stderr, "ERROR: verified %ld when expecting %d\n", count,
|
||||
kNumEntries);
|
||||
goto failed;
|
||||
|
|
|
@ -184,6 +184,7 @@ CRCList* GatherCRCs(NuArchive* pArchive)
|
|||
goto bail;
|
||||
}
|
||||
|
||||
int rsrcCrcIdx = -1;
|
||||
for (i = 0; i < (int)NuRecordGetNumThreads(pRecord); i++) {
|
||||
pThread = NuGetThread(pRecord, i);
|
||||
if (pThread->thThreadClass == kNuThreadClassData) {
|
||||
|
@ -194,7 +195,30 @@ CRCList* GatherCRCs(NuArchive* pArchive)
|
|||
goto bail;
|
||||
}
|
||||
|
||||
pEntries[crcIdx++] = pThread->thThreadCRC;
|
||||
/*
|
||||
* Ensure that the data fork CRC comes first. Otherwise
|
||||
* we can fail if it gets rearranged. This is only a
|
||||
* problem for GSHK-created archives that don't have
|
||||
* threads for every fork, so "mask dataless" is create
|
||||
* fake entries.
|
||||
*
|
||||
* The correct way to do this is to store a tuple
|
||||
* { thread-kind, crc }, but that's more work.
|
||||
*/
|
||||
if (pThread->thThreadKind == kNuThreadKindRsrcFork) {
|
||||
rsrcCrcIdx = crcIdx;
|
||||
}
|
||||
|
||||
if (pThread->thThreadKind == kNuThreadKindDataFork &&
|
||||
rsrcCrcIdx != -1)
|
||||
{
|
||||
/* this is the data fork, we've already seen the
|
||||
resource fork; swap entries */
|
||||
pEntries[crcIdx++] = pEntries[rsrcCrcIdx];
|
||||
pEntries[rsrcCrcIdx] = pThread->thThreadCRC;
|
||||
} else {
|
||||
pEntries[crcIdx++] = pThread->thThreadCRC;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
2005/01/09 ***** v3.0.0 shipped *****
|
||||
2017/09/21 ***** v3.1.0 shipped *****
|
||||
|
||||
2015/12/26 fadden
|
||||
- Fix handling of entries with missing threads.
|
||||
- Improve handling of Mac OS X file type attributes.
|
||||
- Updated "recognized extensions" table.
|
||||
|
||||
2015/01/09 ***** v3.0.0 shipped *****
|
||||
|
||||
2015/01/03 fadden
|
||||
- Mac OS X: get file/aux type from FinderInfo when adding files.
|
||||
|
|
|
@ -72,23 +72,24 @@ static const char gFileTypeNames[256][4] = {
|
|||
* file rather than a hard-coded table. Ought to fix that someday.
|
||||
*/
|
||||
static const struct {
|
||||
const char* label;
|
||||
uint16_t fileType;
|
||||
uint32_t auxType;
|
||||
uint8_t unused; // remove?
|
||||
const char* label;
|
||||
uint8_t fileType;
|
||||
uint16_t auxType;
|
||||
} gRecognizedExtensions[] = {
|
||||
{ "ASM", 0xb0, 0x0003, 0 }, /* APW assembly source */
|
||||
{ "C", 0xb0, 0x000a, 0 }, /* APW C source */
|
||||
{ "H", 0xb0, 0x000a, 0 }, /* APW C header */
|
||||
{ "BNY", 0xe0, 0x8000, 0 }, /* Binary II lib */
|
||||
{ "BQY", 0xe0, 0x8000, 0 }, /* Binary II lib, w/ compress */
|
||||
{ "BXY", 0xe0, 0x8000, 0 }, /* Binary II wrap around SHK */
|
||||
{ "BSE", 0xe0, 0x8000, 0 }, /* Binary II wrap around SEA */
|
||||
{ "SEA", 0xb3, 0xdb07, 0 }, /* GSHK SEA */
|
||||
{ "GIF", 0xc0, 0x8006, 0 }, /* GIF image */
|
||||
{ "JPG", 0x06, 0x0000, 0 }, /* JPEG (nicer than 'NON') */
|
||||
{ "JPEG", 0x06, 0x0000, 0 }, /* JPEG (nicer than 'NON') */
|
||||
{ "SHK", 0xe0, 0x8002, 0 }, /* ShrinkIt archive */
|
||||
{ "ASM", 0xb0, 0x0003 }, /* APW assembly source */
|
||||
{ "C", 0xb0, 0x000a }, /* APW C source */
|
||||
{ "H", 0xb0, 0x000a }, /* APW C header */
|
||||
{ "CPP", 0xb0, 0x0000 }, /* generic source file */
|
||||
{ "BNY", 0xe0, 0x8000 }, /* Binary II lib */
|
||||
{ "BQY", 0xe0, 0x8000 }, /* Binary II lib, w/ compress */
|
||||
{ "BXY", 0xe0, 0x8000 }, /* Binary II wrap around SHK */
|
||||
{ "BSE", 0xe0, 0x8000 }, /* Binary II wrap around SEA */
|
||||
{ "SEA", 0xb3, 0xdb07 }, /* GSHK SEA */
|
||||
{ "TEXT", 0x04, 0x0000 }, /* ASCII text */
|
||||
{ "GIF", 0xc0, 0x8006 }, /* GIF image */
|
||||
{ "JPG", 0x06, 0x0000 }, /* JPEG (nicer than 'NON') */
|
||||
{ "JPEG", 0x06, 0x0000 }, /* JPEG (nicer than 'NON') */
|
||||
{ "SHK", 0xe0, 0x8002 }, /* ShrinkIt archive */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -135,10 +135,14 @@ bail:
|
|||
* a disk image thread, but it's a fair bet ShrinkIt would ignore one
|
||||
* or the other.
|
||||
*
|
||||
* NOTE: we don't currently work around the GSHK zero-length file bug.
|
||||
* Such records, which have a filename thread but no data threads at all,
|
||||
* 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.
|
||||
* NOTE: GSHK likes to omit the data threads for zero-length data and
|
||||
* resource forks. That screws up analysis by scanning for threads. We
|
||||
* can work around missing resource forks by simply checking the record's
|
||||
* storage type. We could be clever and detect records that have no
|
||||
* data-class threads at all, and no additional threads other than a
|
||||
* comment and filename, but this is just for display. ShrinkIt doesn't
|
||||
* handle these records correctly in all cases, so flagging them in a
|
||||
* user-visible way seems reasonable.
|
||||
*/
|
||||
static NuError AnalyzeRecord(const NuRecord* pRecord,
|
||||
enum RecordKind* pRecordKind, uint16_t* pFormat, uint32_t* pTotalLen,
|
||||
|
@ -177,6 +181,16 @@ static NuError AnalyzeRecord(const NuRecord* pRecord,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fix up the case where we have a forked file, but GSHK decided not
|
||||
* to include a resource fork in the record.
|
||||
*/
|
||||
if (pRecord->recStorageType == kNuStorageExtended &&
|
||||
*pRecordKind != kRecordKindForkedFile)
|
||||
{
|
||||
*pRecordKind = kRecordKindForkedFile;
|
||||
}
|
||||
|
||||
return kNuErrNone;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ static void Usage(const NulibState* pState)
|
|||
printf("\nNuLib2 v%s, linked with NufxLib v%d.%d.%d [%s]\n",
|
||||
NState_GetProgramVersion(pState),
|
||||
majorVersion, minorVersion, bugVersion, nufxLibFlags);
|
||||
printf("Copyright (C) 2000-2014, Andy McFadden. All Rights Reserved.\n");
|
||||
printf("Copyright (C) 2000-2017, Andy McFadden. All Rights Reserved.\n");
|
||||
printf("This software is distributed under terms of the BSD License.\n");
|
||||
printf("Visit http://www.nulib.com/ for source code and documentation.\n\n");
|
||||
printf("Usage: %s -command[modifiers] archive [filename-list]\n\n",
|
||||
|
|
|
@ -63,10 +63,10 @@ all: $(PRODUCT)
|
|||
@true
|
||||
|
||||
install: $(PRODUCT)
|
||||
$(srcdir)/mkinstalldirs $(bindir)
|
||||
$(INSTALL_PROGRAM) $(PRODUCT) $(bindir)
|
||||
$(srcdir)/mkinstalldirs $(mandir)/man1
|
||||
$(INSTALL_DATA) nulib2.1 $(mandir)/man1/
|
||||
$(srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
|
||||
$(INSTALL_PROGRAM) $(PRODUCT) $(DESTDIR)$(bindir)
|
||||
$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/man1
|
||||
$(INSTALL_DATA) nulib2.1 $(DESTDIR)$(mandir)/man1/
|
||||
|
||||
install-shared:
|
||||
LIB_PRODUCT="libnufx.so" $(MAKE) -e install
|
||||
|
@ -79,7 +79,7 @@ shared::
|
|||
LIB_PRODUCT="libnufx.so" $(MAKE) -e
|
||||
|
||||
$(PRODUCT): $(OBJS) $(NUFXLIB)
|
||||
$(CC) -o $@ $(OBJS) -L$(NUFXSRCDIR) -L$(libdir) -lnufx @LIBS@
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJS) -L$(NUFXSRCDIR) -L$(libdir) -lnufx @LIBS@
|
||||
|
||||
clean:
|
||||
-rm -f *.o core
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "NuLib2.h"
|
||||
|
||||
|
||||
static const char* gProgramVersion = "3.0.0";
|
||||
static const char* gProgramVersion = "3.1.0";
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -64,8 +64,10 @@
|
|||
# include <direct.h>
|
||||
# define FOPEN_WANTS_B
|
||||
# define HAVE_CHSIZE
|
||||
# define snprintf _snprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
# if _MSC_VER < 1900 /* no snprintf until Visual Studio 2015 */
|
||||
# define snprintf _snprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -454,6 +454,7 @@ static NuError GetTypesFromFinder(const char* pathnameUNI, uint32_t* pFileType,
|
|||
creator = (fiBuf[4] << 24) | (fiBuf[5] << 16) | (fiBuf[6] << 8) |
|
||||
fiBuf[7];
|
||||
|
||||
Boolean found = false;
|
||||
uint8_t proType;
|
||||
uint16_t proAux;
|
||||
|
||||
|
@ -461,31 +462,36 @@ static NuError GetTypesFromFinder(const char* pathnameUNI, uint32_t* pFileType,
|
|||
* Convert to ProDOS file/aux type.
|
||||
*/
|
||||
if (creator == 'pdos') {
|
||||
/*
|
||||
* TODO: handle conversion from 'pdos'/'XY ' to $XY/$0000.
|
||||
* I think this conversion was deprecated and not widely used;
|
||||
* the inability to retain the aux type renders it inapplicable
|
||||
* to many files.
|
||||
*/
|
||||
if (fileType == 'PSYS') {
|
||||
proType = 0xFF; // SYS
|
||||
proAux = 0x0000;
|
||||
found = true;
|
||||
} else if (fileType == 'PS16') {
|
||||
proType = 0xB3; // S16
|
||||
proAux = 0x0000;
|
||||
found = true;
|
||||
} else {
|
||||
if (((fileType >> 24) & 0xFF) == 'p') {
|
||||
proType = (fileType >> 16) & 0xFF;
|
||||
proAux = (uint16_t) fileType;
|
||||
} else {
|
||||
proType = 0x00; // NON
|
||||
proAux = 0x0000;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
} else if (creator == 'dCpy') {
|
||||
if (fileType == 'dImg') {
|
||||
proType = 0xE0; // LBR
|
||||
proAux = 0x0005;
|
||||
} else {
|
||||
proType = 0x00; // NON
|
||||
proAux = 0x0000;
|
||||
found = true;
|
||||
}
|
||||
} else {
|
||||
switch(fileType) {
|
||||
}
|
||||
if (!found) {
|
||||
switch (fileType) {
|
||||
case 'BINA':
|
||||
proType = 0x06; // BIN
|
||||
proAux = 0x0000;
|
||||
|
@ -519,7 +525,11 @@ static NuError GetTypesFromFinder(const char* pathnameUNI, uint32_t* pFileType,
|
|||
}
|
||||
|
||||
/*
|
||||
* Set the file type and creator type.
|
||||
* Set the file type and creator type, based on the ProDOS file type
|
||||
* and aux type.
|
||||
*
|
||||
* This is a clone of the function in NufxLib; it exists for the
|
||||
* benefit of the Binary ][ code.
|
||||
*/
|
||||
NuError SetFinderInfo(int fd, uint8_t proType, uint16_t proAux)
|
||||
{
|
||||
|
@ -534,19 +544,41 @@ NuError SetFinderInfo(int fd, uint8_t proType, uint16_t proAux)
|
|||
return kNuErrFile;
|
||||
}
|
||||
|
||||
/* build type and creator from 8-bit type and 16-bit aux type */
|
||||
uint32_t fileType, creator;
|
||||
fileType = ('p' << 24) | (proType << 16) | proAux;
|
||||
creator = 'pdos';
|
||||
/*
|
||||
* Attempt to use one of the convenience types. If nothing matches,
|
||||
* use the generic pdos/pXYZ approach. Note that PSYS/PS16 will
|
||||
* lose the file's aux type.
|
||||
*
|
||||
* I'm told this is from page 336 of _Programmer's Reference for
|
||||
* System 6.0_.
|
||||
*/
|
||||
uint8_t* fileTypeBuf = fiBuf;
|
||||
uint8_t* creatorBuf = fiBuf + 4;
|
||||
|
||||
fiBuf[0] = fileType >> 24;
|
||||
fiBuf[1] = fileType >> 16;
|
||||
fiBuf[2] = fileType >> 8;
|
||||
fiBuf[3] = fileType;
|
||||
fiBuf[4] = creator >> 24;
|
||||
fiBuf[5] = creator >> 16;
|
||||
fiBuf[6] = creator >> 8;
|
||||
fiBuf[7] = creator;
|
||||
memcpy(creatorBuf, "pdos", 4);
|
||||
if (proType == 0x00 && proAux == 0x0000) {
|
||||
memcpy(fileTypeBuf, "BINA", 4);
|
||||
} else if (proType == 0x04 && proAux == 0x0000) {
|
||||
memcpy(fileTypeBuf, "TEXT", 4);
|
||||
} else if (proType == 0xff) {
|
||||
memcpy(fileTypeBuf, "PSYS", 4);
|
||||
} else if (proType == 0xb3 && (proAux & 0xff00) != 0xdb00) {
|
||||
memcpy(fileTypeBuf, "PS16", 4);
|
||||
} else if (proType == 0xd7 && proAux == 0x0000) {
|
||||
memcpy(fileTypeBuf, "MIDI", 4);
|
||||
} else if (proType == 0xd8 && proAux == 0x0000) {
|
||||
memcpy(fileTypeBuf, "AIFF", 4);
|
||||
} else if (proType == 0xd8 && proAux == 0x0001) {
|
||||
memcpy(fileTypeBuf, "AIFC", 4);
|
||||
} else if (proType == 0xe0 && proAux == 0x0005) {
|
||||
memcpy(creatorBuf, "dCpy", 4);
|
||||
memcpy(fileTypeBuf, "dImg", 4);
|
||||
} else {
|
||||
fileTypeBuf[0] = 'p';
|
||||
fileTypeBuf[1] = proType;
|
||||
fileTypeBuf[2] = (uint8_t) (proAux >> 8);
|
||||
fileTypeBuf[3] = (uint8_t) proAux;
|
||||
}
|
||||
|
||||
if (fsetxattr(fd, XATTR_FINDERINFO_NAME, fiBuf, sizeof(fiBuf),
|
||||
0, 0) != 0)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -47,7 +47,7 @@ if test $enable_deflate = "yes"; then
|
|||
fi
|
||||
if $got_zlibh; then
|
||||
echo " (found libz and zlib.h, enabling deflate)"
|
||||
AC_DEFINE(ENABLE_DEFLATE)
|
||||
AC_DEFINE(ENABLE_DEFLATE, [], [Define to include deflate (zlib) compresion (also need -l in Makefile).])
|
||||
else
|
||||
echo " (couldn't find libz and zlib.h, not enabling deflate)"
|
||||
fi
|
||||
|
@ -67,7 +67,7 @@ if test $enable_bzip2 = "yes"; then
|
|||
fi
|
||||
if $got_bzlibh; then
|
||||
echo " (found libbz2 and bzlib.h, enabling bzip2)"
|
||||
AC_DEFINE(ENABLE_BZIP2)
|
||||
AC_DEFINE(ENABLE_BZIP2, [], [Define to include bzip2 (libbz2) compression (also need -l in Makefile).])
|
||||
else
|
||||
echo " (couldn't find libbz2 and bzlib.h, not enabling bzip2)"
|
||||
fi
|
||||
|
@ -138,6 +138,6 @@ AC_SUBST(BUILD_FLAGS)
|
|||
|
||||
AC_ARG_ENABLE(dmalloc, [ --enable-dmalloc do dmalloc stuff], \
|
||||
[ echo "--- enabling dmalloc";
|
||||
LIBS="$LIBS -L/usr/local/lib -ldmalloc"; AC_DEFINE(USE_DMALLOC) ])
|
||||
LIBS="$LIBS -L/usr/local/lib -ldmalloc"; AC_DEFINE(USE_DMALLOC, [], [Define if we want to use the dmalloc library (also need -l in Makefile).]) ])
|
||||
|
||||
AC_OUTPUT(Makefile)
|
||||
|
|
Loading…
Reference in New Issue