gcc/linux updates

Many updates to format strings, largely as a result of changing
various "long" variables to uint32_t.

Fixed the diskimg debug macros for gcc, which requires an extra
"##" to remove the "," when there are no arguments.  (Apparently
Visual Studio just strips this away for you.)

Stripped out a couple of dead variables spotted by gcc.  Return
the actual error in a couple of HFS file functions.
This commit is contained in:
Andy McFadden 2014-12-11 16:04:35 -08:00
parent 4638d03d6c
commit 8e910b23ca
31 changed files with 163 additions and 131 deletions

8
.gitignore vendored
View File

@ -11,6 +11,14 @@ CP.opensdf
CP.v12.suo
*.aps
# linux binaries
*.o
diskimg/libdiskimg.a
diskimg/libhfs/libhfs.a
# ctags
tags
# generic
*~
*.swp

View File

@ -571,7 +571,7 @@ void A2FileCPM::Dump(void) const
*/
DIError A2FDCPM::Read(void* buf, size_t len, size_t* pActual)
{
LOGI(" CP/M reading %d bytes from '%s' (offset=%ld)",
LOGI(" CP/M reading %zd bytes from '%s' (offset=%ld)",
len, fpFile->GetPathName(), (long) fOffset);
A2FileCPM* pFile = (A2FileCPM*) fpFile;

View File

@ -514,12 +514,12 @@ static const uint8_t kFavoriteBitDec[kNumFavorites] = {
dierr = pGFD->Read(&sctBuf, sizeof(sctBuf), &actual);
if (dierr == kDIErrNone) {
if (actual > /*kMaxExcessByteCount*/ 256) {
LOGI(" DDD looks like too much data in input file (%d extra)",
LOGI(" DDD looks like too much data in input file (%zd extra)",
actual);
dierr = kDIErrBadCompressedData;
goto bail;
} else {
LOGI(" DDD excess bytes (%d) within normal parameters", actual);
LOGI(" DDD excess bytes (%zd) within normal parameters", actual);
}
}

View File

@ -386,8 +386,7 @@ DIError DiskFSDOS33::ScanVolBitmap(void)
LOGI(" map 0123456789abcdef");
int i;
for (i = 0; i < kMaxTracks; i++) {
for (int i = 0; i < kMaxTracks; i++) {
uint32_t val, origVal;
int bit;
@ -409,7 +408,7 @@ DIError DiskFSDOS33::ScanVolBitmap(void)
}
val <<= 1;
}
LOGI(" %2d: %s (0x%08lx)", i, freemap, origVal);
LOGI(" %2d: %s (0x%08x)", i, freemap, origVal);
}
/* we know the VTOC is used, so mark it now */
@ -2885,7 +2884,7 @@ bail:
*/
DIError A2FDDOS::Read(void* buf, size_t len, size_t* pActual)
{
LOGI(" DOS reading %d bytes from '%s' (offset=%ld)",
LOGI(" DOS reading %zd bytes from '%s' (offset=%ld)",
len, fpFile->GetPathName(), (long) fOffset);
A2FileDOS* pFile = (A2FileDOS*) fpFile;
@ -2977,7 +2976,7 @@ DIError A2FDDOS::Write(const void* buf, size_t len, size_t* pActual)
DiskFSDOS33* pDiskFS = (DiskFSDOS33*) fpFile->GetDiskFS();
uint8_t sctBuf[kSctSize];
LOGI(" DOS Write len=%u %s", len, pFile->GetPathName());
LOGI(" DOS Write len=%zd %s", len, pFile->GetPathName());
if (len >= 0x01000000) { // 16MB
assert(false);

View File

@ -2820,8 +2820,8 @@ DIError DiskImg::ValidateCreateFormat(void) const
return kDIErrInvalidCreateReq;
}
if ((GetHasBlocks() && GetNumBlocks() != 1600) ||
GetHasSectors() &&
(GetNumTracks() != 200 || GetNumSectPerTrack() != 16))
(GetHasSectors() &&
(GetNumTracks() != 200 || GetNumSectPerTrack() != 16)))
{
LOGI("CreateImage: DC42 only for 800K disks");
return kDIErrInvalidCreateReq;

View File

@ -144,7 +144,7 @@ DISKIMG_API const char* DIStrError(DIError dierr);
#endif
/* common definition of "whence" for seeks */
typedef enum DIWhence {
enum DIWhence {
kSeekSet = SEEK_SET,
kSeekCur = SEEK_CUR,
kSeekEnd = SEEK_END
@ -358,7 +358,7 @@ public:
* Should we define an enum to describe whether address and data
* headers are standard or some wacky variant?
*/
typedef enum {
enum {
kNibbleAddrPrologLen = 3, // d5 aa 96
kNibbleAddrEpilogLen = 3, // de aa eb
kNibbleDataPrologLen = 3, // d5 aa ad
@ -613,7 +613,7 @@ public:
}
/* this must match DiskImg::kStdNibbleDescrs table */
typedef enum StdNibbleDescr {
enum StdNibbleDescr {
kNibbleDescrDOS33Std = 0,
kNibbleDescrDOS33Patched,
kNibbleDescrDOS33IgnoreChecksum,

View File

@ -27,17 +27,17 @@ namespace DiskImgLib {
* support that in the callback interface, so it's not used.
*/
#define DLOG_BASE(file, line, format, ...) \
Global::PrintDebugMsg((file), (line), (format), __VA_ARGS__)
Global::PrintDebugMsg((file), (line), (format), ##__VA_ARGS__)
#ifdef SHOW_LOGV
# define LOGV(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), __VA_ARGS__)
#else
# define LOGV(format, ...) ((void) 0)
#endif
#define LOGD(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), __VA_ARGS__)
#define LOGI(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), __VA_ARGS__)
#define LOGW(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), __VA_ARGS__)
#define LOGE(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), __VA_ARGS__)
//#ifdef SHOW_LOGV
# define LOGV(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), ##__VA_ARGS__)
//#else
//# define LOGV(format, ...) ((void) 0)
//#endif
#define LOGD(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), ##__VA_ARGS__)
#define LOGI(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), ##__VA_ARGS__)
#define LOGW(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), ##__VA_ARGS__)
#define LOGE(format, ...) DLOG_BASE(__FILE__, __LINE__, (format), ##__VA_ARGS__)
/* put this in to break on interesting events when built debug */
#if defined(_DEBUG)

View File

@ -149,8 +149,8 @@ enum MediaType {
return false; // must be 0x00 or 0x80
}
// CFFA cards don't seem to set the "active" flag
//if (!foundActive)
// return false;
if (false && !foundActive)
return false;
return true;
}
@ -222,7 +222,7 @@ enum MediaType {
if (hasMBR) {
LOGI(" FAT partition table found:");
for (int i = 0; i < 4; i++) {
LOGI(" %d: type=0x%02x start LBA=%-9lu size=%lu",
LOGI(" %d: type=0x%02x start LBA=%-9u size=%u",
i, mbr.parTab[i].type,
mbr.parTab[i].startLBA, mbr.parTab[i].size);
}
@ -394,7 +394,7 @@ DIError A2FileFAT::Open(A2FileDescr** ppOpenFile, bool readOnly,
*/
DIError A2FDFAT::Read(void* buf, size_t len, size_t* pActual)
{
LOGD(" FAT reading %d bytes from '%s' (offset=%ld)",
LOGD(" FAT reading %zd bytes from '%s' (offset=%ld)",
len, fpFile->GetPathName(), (long) fOffset);
A2FileFAT* pFile = (A2FileFAT*) fpFile;

View File

@ -711,7 +711,7 @@ bool WrapperFDI::ExpandHuffman(const uint8_t* inputBuf, long inputLen,
}
if (inputBuf - origInputBuf != inputLen) {
LOGI(" FDI: warning: Huffman input %d vs. %ld",
LOGI(" FDI: warning: Huffman input %ld vs. %ld",
inputBuf - origInputBuf, inputLen);
return false;
}
@ -947,7 +947,7 @@ bool WrapperFDI::ConvertPulseStreamsToNibbles(PulseIndexHeader* pHdr, int bitRat
idxStream[i] = sum;
}
LOGI(" FDI: maxIndex=%lu indexOffset=%d totalAvg=%lu weakBits=%d",
LOGI(" FDI: maxIndex=%u indexOffset=%d totalAvg=%d weakBits=%d",
maxIndex, indexOffset, totalAvg, weakBits);
/*
@ -1133,7 +1133,7 @@ bool WrapperFDI::ConvertPulsesToBits(const uint32_t* avgStream,
/*
* Set up some variables.
*/
int nextI, endOfData, adjust, bitOffset, step;
int nextI, endOfData, adjust, /*bitOffset,*/ step;
uint32_t refPulse;
long jitter;
@ -1142,7 +1142,7 @@ bool WrapperFDI::ConvertPulsesToBits(const uint32_t* avgStream,
endOfData = i;
i--;
adjust = 0;
bitOffset = 0;
//bitOffset = 0;
refPulse = 0;
jitter = 0;
step = -1;
@ -1247,12 +1247,12 @@ bool WrapperFDI::ConvertPulsesToBits(const uint32_t* avgStream,
if (avgPulse < minPulse || avgPulse > maxPulse) {
/* this is bad -- we're out of bounds */
LOGI(" FDI: avgPulse out of bounds: avg=%lu min=%lu max=%lu",
LOGI(" FDI: avgPulse out of bounds: avg=%u min=%u max=%u",
avgPulse, minPulse, maxPulse);
}
if (avgPulse < refPulse) {
/* I guess this is also bad */
LOGI(" FDI: avgPulse < refPulse (%lu %lu)",
LOGI(" FDI: avgPulse < refPulse (%u %u)",
avgPulse, refPulse);
}
pulse += avgPulse - refPulse;

View File

@ -125,7 +125,7 @@ bail:
LOGI(" FocusDrive partition map (%d partitions):", pMap->partCount);
for (i = 0; i < pMap->partCount; i++) {
LOGI(" %2d: %8ld %8ld '%s'", i, pMap->entry[i].startBlock,
LOGI(" %2d: %8d %8d '%s'", i, pMap->entry[i].startBlock,
pMap->entry[i].blockCount, pMap->entry[i].name);
}
}

View File

@ -142,7 +142,7 @@ DIError GFDFile::Read(void* buf, size_t length, size_t* pActual)
if (pActual == NULL) {
if (actual != length) {
dierr = ErrnoOrGeneric();
LOGI(" GDFile Read failed on %d bytes (actual=%d, err=%d)",
LOGI(" GDFile Read failed on %zd bytes (actual=%zd, err=%d)",
length, actual, dierr);
return dierr;
}
@ -163,7 +163,7 @@ DIError GFDFile::Write(const void* buf, size_t length, size_t* pActual)
assert(pActual == NULL); // not handling this yet
if (::fwrite(buf, length, 1, fFp) != 1) {
dierr = ErrnoOrGeneric();
LOGI(" GDFile Write failed on %d bytes (err=%d)", length, dierr);
LOGI(" GDFile Write failed on %zd bytes (err=%d)", length, dierr);
return dierr;
}
return dierr;
@ -440,7 +440,7 @@ DIError GFDBuffer::Read(void* buf, size_t length, size_t* pActual)
if (fCurrentOffset + (long)length > fLength) {
if (pActual == NULL) {
LOGI(" GFDBuffer underrrun off=%ld len=%d flen=%ld",
LOGI(" GFDBuffer underrrun off=%ld len=%zd flen=%ld",
(long) fCurrentOffset, length, (long) fLength);
return kDIErrDataUnderrun;
} else {
@ -469,7 +469,7 @@ DIError GFDBuffer::Write(const void* buf, size_t length, size_t* pActual)
assert(pActual == NULL); // not handling this yet
if (fCurrentOffset + (long)length > fLength) {
if (!fDoExpand) {
LOGI(" GFDBuffer overrun off=%ld len=%d flen=%ld",
LOGI(" GFDBuffer overrun off=%ld len=%zd flen=%ld",
(long) fCurrentOffset, length, (long) fLength);
return kDIErrDataOverrun;
}

View File

@ -169,7 +169,7 @@ DIError DiskFSGutenberg::Initialize(InitMode initMode)
if (dierr != kDIErrNone)
goto bail;
sprintf(fDiskVolumeID, "Gutenberg: %s\0", fDiskVolumeName);
sprintf(fDiskVolumeID, "Gutenberg: %s", fDiskVolumeName);
fDiskIsGood = CheckDiskIsGood();
@ -523,7 +523,7 @@ void A2FileGutenberg::Dump(void) const
*/
DIError A2FDGutenberg::Read(void* buf, size_t len, size_t* pActual)
{
LOGI(" Gutenberg reading %d bytes from '%s' (offset=%ld)",
LOGI(" Gutenberg reading %zd bytes from '%s' (offset=%ld)",
len, fpFile->GetPathName(), (long) fOffset);
A2FileGutenberg* pFile = (A2FileGutenberg*) fpFile;
@ -531,7 +531,7 @@ DIError A2FDGutenberg::Read(void* buf, size_t len, size_t* pActual)
DIError dierr = kDIErrNone;
uint8_t sctBuf[kSctSize];
short currentTrack, currentSector;
di_off_t actualOffset = fOffset + pFile->fDataOffset; // adjust for embedded len
//di_off_t actualOffset = fOffset + pFile->fDataOffset; // adjust for embedded len
int bufOffset = 6;
size_t thisCount;

View File

@ -147,7 +147,7 @@ typedef struct DiskFSHFS::MasterDirBlock {
}
if ((mdb.drAlBlkSiz & 0x1ff) != 0) {
// allocation block size must be a multiple of 512
LOGI(" HFS: found allocation block size = %lu, rejecting",
LOGI(" HFS: found allocation block size = %u, rejecting",
mdb.drAlBlkSiz);
dierr = kDIErrFilesystemNotFound;
goto bail;
@ -345,16 +345,16 @@ void DiskFSHFS::DumpVolHeader(void)
{
LOGI("HFS volume header read:");
LOGI(" volume name = '%s'", fVolumeName);
LOGI(" total blocks = %ld (allocSize=%ld [x%lu], numAllocs=%lu)",
LOGI(" total blocks = %d (allocSize=%d [x%u], numAllocs=%u)",
fTotalBlocks, fAllocationBlockSize, fAllocationBlockSize / kBlkSize,
fNumAllocationBlocks);
LOGI(" num directories=%ld, num files=%ld",
LOGI(" num directories=%d, num files=%d",
fNumDirectories, fNumFiles);
time_t when;
when = (time_t) (fCreatedDateTime - kDateTimeOffset - fLocalTimeOffset);
LOGI(" cre date=0x%08lx %.24s", fCreatedDateTime, ctime(&when));
LOGI(" cre date=0x%08x %.24s", fCreatedDateTime, ctime(&when));
when = (time_t) (fModifiedDateTime - kDateTimeOffset - fLocalTimeOffset);
LOGI(" mod date=0x%08lx %.24s", fModifiedDateTime, ctime(&when));
LOGI(" mod date=0x%08x %.24s", fModifiedDateTime, ctime(&when));
}
@ -1331,7 +1331,7 @@ DIError DiskFSHFS::DeleteFile(A2File* pGenericFile)
bail:
hfs_flush(fHfsVol);
delete[] pathName;
return kDIErrNone;
return dierr;
}
/*
@ -1434,7 +1434,7 @@ bail:
delete[] colonOldName;
delete[] colonNewName;
hfs_flush(fHfsVol);
return kDIErrNone;
return dierr;
}
/*
@ -1855,7 +1855,7 @@ DIError A2FDHFS::Read(void* buf, size_t len, size_t* pActual)
{
long result;
LOGI(" HFS reading %d bytes from '%s' (offset=%ld)",
LOGI(" HFS reading %zd bytes from '%s' (offset=%ld)",
len, fpFile->GetPathName(), hfs_seek(fHfsFile, 0, HFS_SEEK_CUR));
//A2FileHFS* pFile = (A2FileHFS*) fpFile;
@ -1896,7 +1896,7 @@ DIError A2FDHFS::Write(const void* buf, size_t len, size_t* pActual)
{
long result;
LOGI(" HFS writing %d bytes to '%s' (offset=%ld)",
LOGI(" HFS writing %zd bytes to '%s' (offset=%ld)",
len, fpFile->GetPathName(), hfs_seek(fHfsFile, 0, HFS_SEEK_CUR));
fModified = true; // assume something gets changed

View File

@ -1044,8 +1044,8 @@ const int kDC42FakeTagLen = 19200; // add a "fake" tag to match Mac
typedef struct DiskImgLib::DC42Header {
char diskName[kDC42NameLen+1]; // from pascal string
long dataSize; // in bytes
long tagSize;
uint32_t dataSize; // in bytes
uint32_t tagSize;
uint32_t dataChecksum;
uint32_t tagChecksum;
uint8_t diskFormat; // should be 1 for 800K
@ -1062,11 +1062,11 @@ typedef struct DiskImgLib::DC42Header {
{
LOGI("--- header contents:");
LOGI("\tdiskName = '%s'", pHeader->diskName);
LOGI("\tdataSize = %ld (%ldK)", pHeader->dataSize,
LOGI("\tdataSize = %d (%dK)", pHeader->dataSize,
pHeader->dataSize / 1024);
LOGI("\ttagSize = %ld", pHeader->tagSize);
LOGI("\tdataChecksum = 0x%08lx", pHeader->dataChecksum);
LOGI("\ttagChecksum = 0x%08lx", pHeader->tagChecksum);
LOGI("\ttagSize = %d", pHeader->tagSize);
LOGI("\tdataChecksum = 0x%08x", pHeader->dataChecksum);
LOGI("\ttagChecksum = 0x%08x", pHeader->tagChecksum);
LOGI("\tdiskFormat = %d", pHeader->diskFormat);
LOGI("\tformatByte = 0x%02x", pHeader->formatByte);
LOGI("\tprivateWord = 0x%04x", pHeader->privateWord);
@ -1254,12 +1254,12 @@ DIError WrapperDiskCopy42::Prep(GenericFD* pGFD, di_off_t wrappedLength,
return dierr;
if (checksum != header.dataChecksum) {
LOGI(" DC42 checksum mismatch (got 0x%08lx, expected 0x%08lx)",
LOGW(" DC42 checksum mismatch (got 0x%08x, expected 0x%08x)",
checksum, header.dataChecksum);
fBadChecksum = true;
//return kDIErrBadChecksum;
} else {
LOGI(" DC42 checksum matches!");
LOGD(" DC42 checksum matches!");
}
@ -2424,7 +2424,7 @@ DIError WrapperUnadornedNibble::Flush(GenericFD* pWrapperGFD, GenericFD* pDataGF
*/
/*static*/ DIError WrapperUnadornedSector::Test(GenericFD* pGFD, di_off_t wrappedLength)
{
LOGI("Testing for unadorned sector (wrappedLength=%ld/%lu)",
LOGI("Testing for unadorned sector (wrappedLength=%ld/%u)",
(long) (wrappedLength >> 32), (uint32_t) wrappedLength);
if (wrappedLength >= 1536 && (wrappedLength % 512) == 0)
return kDIErrNone;

View File

@ -106,7 +106,7 @@ typedef struct DiskFSMacPart::PartitionMap {
*/
LOGI(" MacPart NOTE: found partially-zeroed-out DDR, continuing");
} else {
LOGI(" MacPart found 'ER' signature but blkSize=%d blkCount=%ld",
LOGI(" MacPart found 'ER' signature but blkSize=%d blkCount=%d",
ddr.sbBlkSize, ddr.sbBlkCount);
dierr = kDIErrFilesystemNotFound;
goto bail;
@ -174,11 +174,11 @@ bail:
/*static*/ void DiskFSMacPart::DumpDDR(const DriverDescriptorRecord* pDDR)
{
LOGI(" MacPart driver descriptor record");
LOGI(" sbSig=0x%04x sbBlkSize=%d sbBlkCount=%ld",
LOGI(" sbSig=0x%04x sbBlkSize=%d sbBlkCount=%d",
pDDR->sbSig, pDDR->sbBlkSize, pDDR->sbBlkCount);
LOGI(" sbDevType=%d sbDevId=%d sbData=%ld sbDrvrCount=%d",
LOGI(" sbDevType=%d sbDevId=%d sbData=%d sbDrvrCount=%d",
pDDR->sbDevType, pDDR->sbDevId, pDDR->sbData, pDDR->sbDrvrCount);
LOGI(" (pad=%d) ddBlock=%ld ddSize=%d ddType=%d",
LOGI(" (pad=%d) ddBlock=%d ddSize=%d ddType=%d",
pDDR->hiddenPad, pDDR->ddBlock, pDDR->ddSize, pDDR->ddType);
}
@ -223,22 +223,22 @@ bail:
/*static*/ void DiskFSMacPart::DumpPartitionMap(long block, const PartitionMap* pMap)
{
LOGI(" MacPart partition map: block=%ld", block);
LOGI(" pmSig=0x%04x (pad=0x%04x) pmMapBlkCnt=%ld",
LOGI(" pmSig=0x%04x (pad=0x%04x) pmMapBlkCnt=%d",
pMap->pmSig, pMap->pmSigPad, pMap->pmMapBlkCnt);
LOGI(" pmPartName='%s' pmParType='%s'",
pMap->pmPartName, pMap->pmParType);
LOGI(" pmPyPartStart=%ld pmPartBlkCnt=%ld",
LOGI(" pmPyPartStart=%d pmPartBlkCnt=%d",
pMap->pmPyPartStart, pMap->pmPartBlkCnt);
LOGI(" pmLgDataStart=%ld pmDataCnt=%ld",
LOGI(" pmLgDataStart=%d pmDataCnt=%d",
pMap->pmLgDataStart, pMap->pmDataCnt);
LOGI(" pmPartStatus=%ld",
LOGI(" pmPartStatus=%d",
pMap->pmPartStatus);
LOGI(" pmLgBootStart=%ld pmBootSize=%ld",
LOGI(" pmLgBootStart=%d pmBootSize=%d",
pMap->pmLgBootStart, pMap->pmBootSize);
LOGI(" pmBootAddr=%ld pmBootAddr2=%ld pmBootEntry=%ld pmBootEntry2=%ld",
LOGI(" pmBootAddr=%d pmBootAddr2=%d pmBootEntry=%d pmBootEntry2=%d",
pMap->pmBootAddr, pMap->pmBootAddr2,
pMap->pmBootEntry, pMap->pmBootEntry2);
LOGI(" pmBootCksum=%ld pmProcessor='%s'",
LOGI(" pmBootCksum=%d pmProcessor='%s'",
pMap->pmBootCksum, pMap->pmProcessor);
}
@ -294,6 +294,7 @@ DIError DiskFSMacPart::OpenSubVolume(const PartitionMap* pMap)
* Apple "develop" CD-ROM, which had a bad Apple_Extra partition on the
* end.
*/
(void) tweaked;
dierr = pNewImg->OpenImage(fpImg, startBlock, numBlocks);
if (dierr != kDIErrNone) {

View File

@ -14,13 +14,13 @@ CXXFLAGS = $(OPT) $(GCC_FLAGS) -D_FILE_OFFSET_BITS=64
SRCS = ASPI.cpp CFFA.cpp Container.cpp CPM.cpp DDD.cpp DiskFS.cpp \
DiskImg.cpp DIUtil.cpp DOS33.cpp DOSImage.cpp FAT.cpp FDI.cpp \
FocusDrive.cpp \GenericFD.cpp Global.cpp HFS.cpp \
FocusDrive.cpp \GenericFD.cpp Global.cpp Gutenberg.cpp HFS.cpp \
ImageWrapper.cpp MacPart.cpp MicroDrive.cpp Nibble.cpp \
Nibble35.cpp OuterWrapper.cpp OzDOS.cpp Pascal.cpp ProDOS.cpp \
RDOS.cpp TwoImg.cpp UNIDOS.cpp VolumeUsage.cpp Win32BlockIO.cpp
OBJS = ASPI.o CFFA.o Container.o CPM.o DDD.o DiskFS.o \
DiskImg.o DIUtil.o DOS33.o DOSImage.o FDI.o \
FocusDrive.o FAT.o GenericFD.o Global.o HFS.o \
FocusDrive.o FAT.o GenericFD.o Global.o Gutenberg.o HFS.o \
ImageWrapper.o MacPart.o MicroDrive.o Nibble.o \
Nibble35.o OuterWrapper.o OzDOS.o Pascal.o ProDOS.o \
RDOS.o TwoImg.o UNIDOS.o VolumeUsage.o Win32BlockIO.o

View File

@ -161,13 +161,13 @@ bail:
parts = pMap->numPart1;
assert(parts <= kMaxNumParts);
for (i = 0; i < parts; i++) {
LOGI(" %2d: startLBA=%8ld length=%ld",
LOGI(" %2d: startLBA=%8d length=%d",
i, pMap->partitionStart1[i], pMap->partitionLength1[i]);
}
parts = pMap->numPart2;
assert(parts <= kMaxNumParts);
for (i = 0; i < parts; i++) {
LOGI(" %2d: startLBA=%8ld length=%ld",
LOGI(" %2d: startLBA=%8d length=%d",
i+8, pMap->partitionStart2[i], pMap->partitionLength2[i]);
}
}

View File

@ -328,7 +328,7 @@ DIError OuterGzip::Save(GenericFD* pOuterGFD, GenericFD* pWrapperGFD,
written = gzwrite(gzfp, buf, actual);
if (written == 0) {
LOGI("Failed writing %d bytes to gzio", actual);
LOGI("Failed writing %zd bytes to gzio", actual);
dierr = kDIErrGeneric;
goto bail;
}
@ -389,7 +389,7 @@ bail:
if (cde.fUncompressedSize < 512 ||
cde.fUncompressedSize > kMaxUncompressedSize)
{
LOGI(" ZIP uncompressed size %lu is outside range",
LOGI(" ZIP uncompressed size %u is outside range",
cde.fUncompressedSize);
dierr = kDIErrGeneric;
goto bail;
@ -784,7 +784,7 @@ DIError OuterZip::ExtractZipEntry(GenericFD* pOuterGFD, CentralDirEntry* pCDE,
buf = new uint8_t[pCDE->fUncompressedSize];
if (buf == NULL) {
/* a very real possibility */
LOGI(" ZIP unable to allocate buffer of %lu bytes",
LOGI(" ZIP unable to allocate buffer of %u bytes",
pCDE->fUncompressedSize);
dierr = kDIErrMalloc;
goto bail;
@ -814,7 +814,7 @@ DIError OuterZip::ExtractZipEntry(GenericFD* pOuterGFD, CentralDirEntry* pCDE,
if (crc == pCDE->fCRC32) {
LOGI("+++ ZIP CRCs match");
} else {
LOGI("ZIP CRC mismatch: inflated crc32=0x%08lx, stored=0x%08lx",
LOGI("ZIP CRC mismatch: inflated crc32=0x%08x, stored=0x%08x",
crc, pCDE->fCRC32);
dierr = kDIErrBadChecksum;
goto bail;
@ -1043,7 +1043,7 @@ DIError OuterZip::DeflateGFDToGFD(GenericFD* pDst, GenericFD* pSrc,
/* only read if the input is empty */
if (zstream.avail_in == 0 && srcLen) {
getSize = (srcLen > kBufSize) ? kBufSize : (long) srcLen;
getSize = (srcLen > (long) kBufSize) ? kBufSize : (long) srcLen;
LOGI("+++ reading %ld bytes", getSize);
dierr = pSrc->Read(inBuf, getSize);
@ -1076,7 +1076,7 @@ DIError OuterZip::DeflateGFDToGFD(GenericFD* pDst, GenericFD* pSrc,
if (zstream.avail_out == 0 ||
(zerr == Z_STREAM_END && zstream.avail_out != kBufSize))
{
LOGI("+++ writing %d bytes", zstream.next_out - outBuf);
LOGI("+++ writing %ld bytes", zstream.next_out - outBuf);
dierr = pDst->Write(outBuf, zstream.next_out - outBuf);
if (dierr != kDIErrNone) {
LOGI("write failed in deflate");
@ -1242,9 +1242,9 @@ void OuterZip::LocalFileHeader::Dump(void) const
LOGI(" LocalFileHeader contents:");
LOGI(" versToExt=%u gpBits=0x%04x compression=%u",
fVersionToExtract, fGPBitFlag, fCompressionMethod);
LOGI(" modTime=0x%04x modDate=0x%04x crc32=0x%08lx",
LOGI(" modTime=0x%04x modDate=0x%04x crc32=0x%08x",
fLastModFileTime, fLastModFileDate, fCRC32);
LOGI(" compressedSize=%lu uncompressedSize=%lu",
LOGI(" compressedSize=%u uncompressedSize=%u",
fCompressedSize, fUncompressedSize);
LOGI(" filenameLen=%u extraLen=%u",
fFileNameLength, fExtraFieldLength);
@ -1410,13 +1410,13 @@ void OuterZip::CentralDirEntry::Dump(void) const
LOGI(" CentralDirEntry contents:");
LOGI(" versMadeBy=%u versToExt=%u gpBits=0x%04x compression=%u",
fVersionMadeBy, fVersionToExtract, fGPBitFlag, fCompressionMethod);
LOGI(" modTime=0x%04x modDate=0x%04x crc32=0x%08lx",
LOGI(" modTime=0x%04x modDate=0x%04x crc32=0x%08x",
fLastModFileTime, fLastModFileDate, fCRC32);
LOGI(" compressedSize=%lu uncompressedSize=%lu",
LOGI(" compressedSize=%u uncompressedSize=%u",
fCompressedSize, fUncompressedSize);
LOGI(" filenameLen=%u extraLen=%u commentLen=%u",
fFileNameLength, fExtraFieldLength, fFileCommentLength);
LOGI(" diskNumStart=%u intAttr=0x%04x extAttr=0x%08lx relOffset=%lu",
LOGI(" diskNumStart=%u intAttr=0x%04x extAttr=0x%08x relOffset=%u",
fDiskNumberStart, fInternalAttrs, fExternalAttrs,
fLocalHeaderRelOffset);
@ -1499,6 +1499,6 @@ OuterZip::EndOfCentralDir::Dump(void) const
LOGI(" EndOfCentralDir contents:");
LOGI(" diskNum=%u diskWCD=%u numEnt=%u totalNumEnt=%u",
fDiskNumber, fDiskWithCentralDir, fNumEntries, fTotalNumEntries);
LOGI(" centDirSize=%lu centDirOff=%lu commentLen=%u",
LOGI(" centDirSize=%u centDirOff=%u commentLen=%u",
fCentralDirSize, fCentralDirOffset, fCommentLen);
}

View File

@ -1507,7 +1507,7 @@ long A2FilePascal::GetFileType(void) const
if (year >= 100)
year -= 100;
if (year < 0 || year >= 100) {
LOGW("WHOOPS: got year %lu from %d", year, ptm->tm_year);
LOGW("WHOOPS: got year %u from %d", year, ptm->tm_year);
year = 70;
}
date = year << 9 | (ptm->tm_mon+1) | ptm->tm_mday << 4;
@ -1579,7 +1579,7 @@ DIError A2FilePascal::Open(A2FileDescr** ppOpenFile, bool readOnly,
*/
DIError A2FDPascal::Read(void* buf, size_t len, size_t* pActual)
{
LOGI(" Pascal reading %d bytes from '%s' (offset=%ld)",
LOGI(" Pascal reading %zd bytes from '%s' (offset=%ld)",
len, fpFile->GetPathName(), (long) fOffset);
A2FilePascal* pFile = (A2FilePascal*) fpFile;
@ -1644,7 +1644,7 @@ DIError A2FDPascal::Write(const void* buf, size_t len, size_t* pActual)
uint8_t blkBuf[kBlkSize];
size_t origLen = len;
LOGI(" DOS Write len=%u %s", len, pFile->GetPathName());
LOGI(" DOS Write len=%zd %s", len, pFile->GetPathName());
if (len >= 0x01000000) { // 16MB
assert(false);
@ -1669,7 +1669,7 @@ DIError A2FDPascal::Write(const void* buf, size_t len, size_t* pActual)
blocksAvail = pNextFile->fStartBlock - pFile->fStartBlock;
blocksNeeded = (len + kBlkSize -1) / kBlkSize;
LOGI("Pascal write '%s' %d bytes: avail=%ld needed=%ld",
LOGI("Pascal write '%s' %zd bytes: avail=%ld needed=%ld",
pFile->GetPathName(), len, blocksAvail, blocksNeeded);
if (blocksAvail < blocksNeeded)
return kDIErrDiskFull;

View File

@ -394,7 +394,7 @@ void DiskFSProDOS::SetVolumeID(void)
void DiskFSProDOS::DumpVolHeader(void)
{
LOGI(" ProDOS volume header for '%s'", fVolumeName);
LOGI(" CreateWhen=0x%08lx access=0x%02x bitmap=%d totalbl=%d",
LOGI(" CreateWhen=0x%08x access=0x%02x bitmap=%d totalbl=%d",
fCreateWhen, fAccess, fBitMapPointer, fTotalBlocks);
time_t when;
@ -3652,7 +3652,7 @@ DIError DiskFSProDOS::SetFileInfo(A2File* pGenericFile, long fileType,
goto bail;
}
if ((size_t) (*ptr & 0x0f) != strlen(pFile->fDirEntry.fileName)) {
LOGI("ProDOS GLITCH: wrong file? (len=%d vs %d)",
LOGI("ProDOS GLITCH: wrong file? (len=%d vs %zd)",
*ptr & 0x0f, strlen(pFile->fDirEntry.fileName));
assert(false);
dierr = kDIErrBadDirectory;
@ -4362,17 +4362,17 @@ void A2FileProDOS::Dump(void) const
fDirEntry.fileName, fPathName);
LOGI(" fileType=0x%02x auxType=0x%04x storage=%d",
fDirEntry.fileType, fDirEntry.auxType, fDirEntry.storageType);
LOGI(" keyPointer=%d blocksUsed=%d eof=%ld",
LOGI(" keyPointer=%d blocksUsed=%d eof=%d",
fDirEntry.keyPointer, fDirEntry.blocksUsed, fDirEntry.eof);
LOGI(" access=0x%02x create=0x%08lx mod=0x%08lx",
LOGI(" access=0x%02x create=0x%08x mod=0x%08x",
fDirEntry.access, fDirEntry.createWhen, fDirEntry.modWhen);
LOGI(" version=%d minVersion=%d headerPtr=%d",
fDirEntry.version, fDirEntry.minVersion, fDirEntry.headerPointer);
if (fDirEntry.storageType == kStorageExtended) {
LOGI(" DATA storage=%d keyBlk=%d blkUsed=%d eof=%ld",
LOGI(" DATA storage=%d keyBlk=%d blkUsed=%d eof=%d",
fExtData.storageType, fExtData.keyBlock, fExtData.blocksUsed,
fExtData.eof);
LOGI(" RSRC storage=%d keyBlk=%d blkUsed=%d eof=%ld",
LOGI(" RSRC storage=%d keyBlk=%d blkUsed=%d eof=%d",
fExtRsrc.storageType, fExtRsrc.keyBlock, fExtRsrc.blocksUsed,
fExtRsrc.eof);
}
@ -4392,7 +4392,7 @@ void A2FileProDOS::Dump(void) const
*/
DIError A2FDProDOS::Read(void* buf, size_t len, size_t* pActual)
{
LOGI(" ProDOS reading %d bytes from '%s' (offset=%ld)",
LOGI(" ProDOS reading %zd bytes from '%s' (offset=%ld)",
len, fpFile->GetPathName(), (long) fOffset);
//if (fBlockList == NULL)
// return kDIErrNotReady;
@ -4667,13 +4667,13 @@ DIError A2FDProDOS::Write(const void* buf, size_t len, size_t* pActual)
fBlockList[0] = keyBlock;
} else if (fBlockCount <= 256) {
/* sapling file, write an index block into the key block */
bool allzero = true;
//bool allzero = true; <-- should this be getting used?
assert(fBlockCount > 1);
memset(blkBuf, 0, sizeof(blkBuf));
int i;
for (i = 0; i < fBlockCount; i++) {
if (fBlockList[i] != 0)
allzero = false;
//if (fBlockList[i] != 0)
// allzero = false;
blkBuf[i] = fBlockList[i] & 0xff;
blkBuf[256 + i] = (fBlockList[i] >> 8) & 0xff;
}
@ -4772,7 +4772,7 @@ DIError A2FDProDOS::WriteDirectory(const void* buf, size_t len, size_t* pActual)
{
DIError dierr = kDIErrNone;
LOGI("ProDOS writing %d bytes to directory '%s'",
LOGI("ProDOS writing %zd bytes to directory '%s'",
len, fpFile->GetPathName());
assert(len >= (size_t)kBlkSize);

View File

@ -533,7 +533,7 @@ DIError A2FileRDOS::Open(A2FileDescr** ppOpenFile, bool readOnly,
*/
DIError A2FDRDOS::Read(void* buf, size_t len, size_t* pActual)
{
LOGI(" RDOS reading %d bytes from '%s' (offset=%ld)",
LOGI(" RDOS reading %zd bytes from '%s' (offset=%ld)",
len, fpFile->GetPathName(), (long) fOffset);
//if (!fOpen)
// return kDIErrNotReady;

View File

@ -29,6 +29,9 @@
#define HAVE_FSEEKO
#define HAVE_FTRUNCATE
// gcc wants special compile options; just ignore this for now
#define override
#else /*_WIN32*/
#if !defined(AFX_STDAFX_H__1CB7B33E_42BF_4A98_B814_4198EA8ACC58__INCLUDED_)

View File

@ -30,13 +30,13 @@ int TwoImgHeader::InitHeader(int imageFormat, uint32_t imageSize,
{
if (imageSize == 0)
return -1;
if (imageFormat < kImageFormatDOS || imageFormat > kImageFormatNibble)
if (imageFormat < kImageFormatDOS || imageFormat > (int) kImageFormatNibble)
return -1;
if (imageFormat != kImageFormatNibble &&
imageSize != imageBlockCount * 512)
{
LOGW("2MG InitHeader: bad sizes %d %ld %ld", imageFormat,
LOGW("2MG InitHeader: bad sizes %d %u %u", imageFormat,
imageSize, imageBlockCount);
return -1;
}
@ -383,7 +383,7 @@ int TwoImgHeader::UnpackHeader(const uint8_t* buf, uint32_t totalLength)
fImageFormat != kImageFormatNibble)
{
fDataLen = fNumBlocks * kBlockSize;
LOGI("NOTE: fixing zero dataLen in 'WOOF' image (set to %ld)",
LOGI("NOTE: fixing zero dataLen in 'WOOF' image (set to %u)",
fDataLen);
}
@ -393,22 +393,22 @@ int TwoImgHeader::UnpackHeader(const uint8_t* buf, uint32_t totalLength)
if (fImageFormat != kImageFormatNibble &&
fNumBlocks * kBlockSize != fDataLen)
{
LOGW("numBlocks/dataLen mismatch (%ld vs %ld)",
LOGW("numBlocks/dataLen mismatch (%u vs %u)",
fNumBlocks * kBlockSize, fDataLen);
return -1;
}
if (fDataLen + fDataOffset > totalLength) {
LOGW("Invalid dataLen/offset/fileLength (dl=%ld, off=%ld, tlen=%ld)",
LOGW("Invalid dataLen/offset/fileLength (dl=%u, off=%u, tlen=%u)",
fDataLen, fDataOffset, totalLength);
return -1;
}
if (fImageFormat < kImageFormatDOS || fImageFormat > kImageFormatNibble) {
LOGW("Invalid image format %ld", fImageFormat);
LOGW("Invalid image format %u", fImageFormat);
return -1;
}
if (fCmtOffset > 0 && fCmtOffset < fDataOffset + fDataLen) {
LOGW("2MG comment is inside the data section (off=%ld, data end=%ld)",
LOGW("2MG comment is inside the data section (off=%u, data end=%u)",
fCmtOffset, fDataOffset+fDataLen);
DebugBreak();
// ignore the comment
@ -419,7 +419,7 @@ int TwoImgHeader::UnpackHeader(const uint8_t* buf, uint32_t totalLength)
uint32_t prevEnd = fDataOffset + fDataLen + fCmtLen;
if (fCreatorOffset < prevEnd) {
LOGW("2MG creator chunk is inside prev data (off=%ld, data end=%ld)",
LOGW("2MG creator chunk is inside prev data (off=%u, data end=%u)",
fCreatorOffset, prevEnd);
DebugBreak();
// ignore the creator chunk
@ -545,23 +545,23 @@ void
TwoImgHeader::DumpHeader(void) const
{
LOGI("--- header contents:");
LOGI("\tmagic = '%s' (0x%08lx)", fMagicStr, fMagic);
LOGI("\tcreator = '%s' (0x%08lx)", fCreatorStr, fCreator);
LOGI("\theaderLen = %d", fHeaderLen);
LOGI("\tversion = %d", fVersion);
LOGI("\timageFormat = %ld", fImageFormat);
LOGI("\tflags = 0x%08lx", fFlags);
LOGI("\tmagic = '%s' (0x%08x)", fMagicStr, fMagic);
LOGI("\tcreator = '%s' (0x%08x)", fCreatorStr, fCreator);
LOGI("\theaderLen = %u", fHeaderLen);
LOGI("\tversion = %u", fVersion);
LOGI("\timageFormat = %u", fImageFormat);
LOGI("\tflags = 0x%08x", fFlags);
LOGI("\t locked = %s",
(fFlags & kFlagLocked) ? "true" : "false");
LOGI("\t DOS volume = %s (%ld)",
LOGI("\t DOS volume = %s (%d)",
(fFlags & kDOSVolumeSet) ? "true" : "false",
fFlags & kDOSVolumeMask);
LOGI("\tnumBlocks = %ld", fNumBlocks);
LOGI("\tdataOffset = %ld", fDataOffset);
LOGI("\tdataLen = %ld", fDataLen);
LOGI("\tcmtOffset = %ld", fCmtOffset);
LOGI("\tcmtLen = %ld", fCmtLen);
LOGI("\tcreatorOffset = %ld", fCreatorOffset);
LOGI("\tcreatorLen = %ld", fCreatorLen);
LOGI("");
LOGI("\tnumBlocks = %u", fNumBlocks);
LOGI("\tdataOffset = %u", fDataOffset);
LOGI("\tdataLen = %u", fDataLen);
LOGI("\tcmtOffset = %u", fCmtOffset);
LOGI("\tcmtLen = %u", fCmtLen);
LOGI("\tcreatorOffset = %u", fCreatorOffset);
LOGI("\tcreatorLen = %u", fCreatorLen);
LOGI("---");
}

6
linux/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
getfile
iconv
makedisk
mdc
packddd
sstasm

View File

@ -12,7 +12,7 @@
#include <memory.h>
#include <assert.h>
#include "../diskimg/DiskImg.h"
#include "../prebuilt/NufxLib.h"
#include "../nufxlib/NufxLib.h"
using namespace DiskImgLib;

View File

@ -17,7 +17,7 @@
#include <errno.h>
#include "zlib.h"
#include "../diskimg/DiskImg.h"
#include "../prebuilt/NufxLib.h"
#include "../nufxlib/NufxLib.h"
#include "StringArray.h"
using namespace DiskImgLib;

View File

@ -85,7 +85,7 @@ CopyFiles(DiskFS* pDiskFS, int argc, char** argv)
DiskFS::CreateParms parms;
A2File* pNewFile;
typedef struct CreateParms {
struct CreateParms {
const char* pathName; // full pathname
char fssep;
int storageType; // determines normal, subdir, or forked
@ -94,7 +94,7 @@ CopyFiles(DiskFS* pDiskFS, int argc, char** argv)
int access;
time_t createWhen;
time_t modWhen;
} CreateParms;
};
while (argc--) {

View File

@ -35,7 +35,7 @@ PRODUCT5 = makedisk
PRODUCT6 = getfile
DISKIMGLIB = ../diskimg/libdiskimg.a ../diskimg/libhfs/libhfs.a
NUFXLIB = ../prebuilt/libnufx.a
NUFXLIB = ../nufxlib/libnufx.a
all: $(PRODUCT1) $(PRODUCT2) $(PRODUCT3) $(PRODUCT4) $(PRODUCT5) $(PRODUCT6)
@true

View File

@ -63,7 +63,7 @@ Probably not worth the effort.
#include <unistd.h>
#include <assert.h>
#include "../diskimg/DiskImg.h"
#include "../prebuilt/NufxLib.h"
#include "../nufxlib/NufxLib.h"
using namespace DiskImgLib;

15
nufxlib/.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
# config-generated sources
Makefile
config.h
config.log
config.status
# generated binaries
libnufx.a
samples/exerciser
samples/imgconv
samples/launder
samples/test-basic
samples/test-extract
samples/test-simple
samples/test-twirl

0
nufxlib/configure vendored Normal file → Executable file
View File