Use types with explicit sizes

Much of what the "reformat" code does involves processing data that is
8, 16, or 32 bits.  We want to use size-specific types from stdint.h
(e.g. uint16_t) rather than "unsigned short".

This was a quick pass to replace the various "unsigned" declarations.
More can be done here and elsewhere.
This commit is contained in:
Andy McFadden 2014-11-20 18:10:18 -08:00
parent 0deecec87c
commit 8f61f84585
52 changed files with 679 additions and 689 deletions

View File

@ -1791,7 +1791,7 @@ bail:
* really large files.
*/
CString
DiskArchive::LoadFile(const WCHAR* pathName, BYTE** pBuf, long* pLen,
DiskArchive::LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen,
GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const
{
CString errMsg;
@ -1836,7 +1836,7 @@ DiskArchive::LoadFile(const WCHAR* pathName, BYTE** pBuf, long* pLen,
goto bail;
}
*pBuf = new BYTE[fileLen];
*pBuf = new uint8_t[fileLen];
if (*pBuf == NULL) {
errMsg.Format(L"Unable to allocate %ld bytes for '%ls'.",
fileLen, pathName);
@ -3056,8 +3056,8 @@ DiskArchive::XferPrepare(const XferFileOptions* pXferOpts)
* version just tucks the pointers into NufxLib structures.)
*/
CString
DiskArchive::XferFile(FileDetails* pDetails, BYTE** pDataBuf,
long dataLen, BYTE** pRsrcBuf, long rsrcLen)
DiskArchive::XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen)
{
//const int kFileTypeTXT = 0x04;
DiskFS::CreateParms createParms;

View File

@ -153,8 +153,8 @@ public:
private:
virtual CString Close(void);
virtual void XferPrepare(const XferFileOptions* pXferOpts);
virtual CString XferFile(FileDetails* pDetails, BYTE** pDataBuf,
long dataLen, BYTE** pRsrcBuf, long rsrcLen);
virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen);
virtual void XferAbort(CWnd* pMsgWnd);
virtual void XferFinish(CWnd* pMsgWnd);
@ -222,11 +222,11 @@ private:
NuResult HandleReplaceExisting(const A2File* pExisting,
FileDetails* pDetails);
CString ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL);
CString LoadFile(const WCHAR* pathName, BYTE** pBuf, long* pLen,
CString LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen,
GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const;
DIError AddForksToDisk(DiskFS* pDiskFS, const DiskFS::CreateParms* pParms,
const BYTE* dataBuf, long dataLen,
const BYTE* rsrcBuf, long rsrcLen) const;
const uint8_t* dataBuf, long dataLen,
const uint8_t* rsrcBuf, long rsrcLen) const;
void AddToAddDataList(FileAddData* pData);
void FreeAddDataList(void);
void ConvertFDToCP(const FileDetails* pDetails,

View File

@ -440,7 +440,7 @@ DiskEditDialog::SetSpinner(int id, long val)
* Convert a chunk of data into a hex dump, and stuff it into the edit control.
*/
void
DiskEditDialog::DisplayData(const BYTE* srcBuf, int size)
DiskEditDialog::DisplayData(const uint8_t* srcBuf, int size)
{
WCHAR textBuf[80 * 16 * 2];
WCHAR* cp;

View File

@ -49,8 +49,8 @@ public:
virtual int LoadData(void) = 0;
virtual void DisplayData(void) = 0;
virtual void DisplayData(const BYTE* buf, int size);
virtual void DisplayNibbleData(const BYTE* srcBuf, int size);
virtual void DisplayData(const uint8_t* buf, int size);
virtual void DisplayNibbleData(const uint8_t* srcBuf, int size);
bool GetReadOnly(void) const { return fReadOnly; }
void SetReadOnly(bool val) { fReadOnly = val; }
@ -149,7 +149,7 @@ protected:
long fTrack;
long fSector;
BYTE fSectorData[kSectorSize];
uint8_t fSectorData[kSectorSize];
};
/*
@ -229,7 +229,7 @@ protected:
afx_msg virtual void OnOpenFile(void);
long fBlock;
BYTE fBlockData[kBlockSize];
uint8_t fBlockData[kBlockSize];
};
@ -308,7 +308,7 @@ protected:
afx_msg virtual void OnNibbleParms(void) { ASSERT(false); }
long fTrack;
BYTE fNibbleData[DiskImgLib::kTrackAllocSize];
uint8_t fNibbleData[DiskImgLib::kTrackAllocSize];
long fNibbleDataLen;
};

View File

@ -228,10 +228,10 @@ public:
// Utility functions.
const WCHAR* GetFileTypeString(void) const;
static bool CheckHighASCII(const BYTE* buffer,
static bool CheckHighASCII(const uint8_t* buffer,
unsigned long count);
static ConvertEOL DetermineConversion(const BYTE* buffer,
static ConvertEOL DetermineConversion(const uint8_t* buffer,
long count, EOLType* pSourceType, ConvertHighASCII* pConvHA);
static int GenericEntry::WriteConvert(FILE* fp, const char* buf,
size_t len, ConvertEOL* pConv, ConvertHighASCII* pConvHA,
@ -520,8 +520,8 @@ public:
// Transfer files, one at a time, into this archive from another.
virtual void XferPrepare(const XferFileOptions* pXferOpts) = 0;
virtual CString XferFile(FileDetails* pDetails, BYTE** pDataBuf,
long dataLen, BYTE** pRsrcBuf, long rsrcLen) = 0;
virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen) = 0;
virtual void XferAbort(CWnd* pMsgWnd) = 0;
virtual void XferFinish(CWnd* pMsgWnd) = 0;
static void UNIXTimeToDateTime(const time_t* pWhen, NuDateTime *pDateTime);

View File

@ -139,8 +139,8 @@ public:
// save a buffer of data as a file in a disk image or file archive
static bool SaveToArchive(GenericArchive::FileDetails* pDetails,
const BYTE* dataBuf, long dataLen,
const BYTE* rsrcBuf, long rsrcLen,
const uint8_t* dataBuf, long dataLen,
const uint8_t* rsrcBuf, long rsrcLen,
CString& errMsg, CWnd* pDialog);
static const WCHAR kOpenNuFX[];
@ -317,11 +317,11 @@ private:
void BulkConvertImage(const WCHAR* pathName, const WCHAR* targetDir,
const DiskConvertDialog& convDlg, CString* pErrMsg);
int SSTOpenImage(int seqNum, DiskImg* pDiskImg);
int SSTLoadData(int seqNum, DiskImg* pDiskImg, BYTE* trackBuf,
int SSTLoadData(int seqNum, DiskImg* pDiskImg, uint8_t* trackBuf,
long* pBadCount);
long SSTGetBufOffset(int track);
long SSTCountBadBytes(const BYTE* sctBuf, int count);
void SSTProcessTrackData(BYTE* trackBuf);
long SSTCountBadBytes(const uint8_t* sctBuf, int count);
void SSTProcessTrackData(uint8_t* trackBuf);
void VolumeCopier(bool openFile);
bool EditTwoImgProps(const WCHAR* fileName);

View File

@ -1134,7 +1134,7 @@ NufxArchive::AddDisk(ActionProgressDialog* pActionProgress,
ASSERT(pDiskImg != NULL);
/* allocate storage for the entire disk */
diskData = new BYTE[pDiskImg->GetNumBlocks() * kBlockSize];
diskData = new uint8_t[pDiskImg->GetNumBlocks() * kBlockSize];
if (diskData == NULL) {
errMsg.Format(L"Unable to allocate %d bytes.",
pDiskImg->GetNumBlocks() * kBlockSize);
@ -1988,7 +1988,7 @@ NufxArchive::RecompressThread(NufxEntry* pEntry, int threadKind,
/* create a data source for it */
nerr = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
0, (const BYTE*)buf, 0, len, ArrayDeleteHandler,
0, (const uint8_t*) buf, 0, len, ArrayDeleteHandler,
&pSource);
if (nerr != kNuErrNone) {
pErrMsg->Format(L"Unable to create NufxLib data source (len=%d).",
@ -2538,7 +2538,7 @@ NufxArchive::SetComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
/* create a data source to write from */
nerr = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
maxLen, (const BYTE*)(LPCSTR)newStr, 0,
maxLen, (const uint8_t*)(LPCSTR) newStr, 0,
newStr.GetLength(), NULL, &pSource);
if (nerr != kNuErrNone) {
errMsg.Format(L"Unable to create NufxLib data source (len=%d, maxLen=%d).",

View File

@ -29,6 +29,7 @@
#include <shlobj.h>
#include <mmsystem.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <string.h>

View File

@ -1552,7 +1552,7 @@ MainWindow::OnToolsSSTMerge(void)
const int kBadCountThreshold = 3072;
DiskImg srcImg0, srcImg1;
CString appName, saveName, saveFolder, errMsg;
BYTE* trackBuf = NULL;
uint8_t* trackBuf = NULL;
long badCount;
// no need to flush -- can't really open raw SST images
@ -1563,7 +1563,7 @@ MainWindow::OnToolsSSTMerge(void)
appName.LoadString(IDS_MB_APP_NAME);
trackBuf = new BYTE[kSSTNumTracks * kSSTTrackLen];
trackBuf = new uint8_t[kSSTNumTracks * kSSTTrackLen];
if (trackBuf == NULL)
goto bail;
@ -1774,11 +1774,11 @@ bail:
* Returns 0 on success, -1 on failure.
*/
int
MainWindow::SSTLoadData(int seqNum, DiskImg* pDiskImg, BYTE* trackBuf,
MainWindow::SSTLoadData(int seqNum, DiskImg* pDiskImg, uint8_t* trackBuf,
long* pBadCount)
{
DIError dierr;
BYTE sctBuf[256];
uint8_t sctBuf[256];
int track, sector;
long bufOffset;

View File

@ -8,15 +8,17 @@
// are changed infrequently
//
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#ifndef _WIN32
/* UNIX includes */
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <fcntl.h>
#include <ctype.h>
@ -47,9 +49,6 @@
#include <windows.h>
#include <atlstr.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <io.h>
#include <fcntl.h>
@ -65,7 +64,6 @@ typedef unsigned int ssize_t;
#define HAVE__VSNPRINTF
#define strcasecmp stricmp
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

View File

@ -23,15 +23,16 @@
//#include <windows.h>
// C RunTime Header Files
#include <stdint.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#include <assert.h>
//#include <tchar.h>
#include <afxwin.h>
#include <afxcmn.h>
#include <afxdlgs.h>

View File

@ -32,11 +32,11 @@ ReformatAWGS_WP::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
fUseRTF = true;
Chunk doc, header, footer;
unsigned short val;
uint16_t val;
CheckGSCharConv();
@ -149,7 +149,7 @@ ReformatAWGS_WP::Process(const ReformatHolder* pHolder,
* Read one of the chunks of the file.
*/
bool
ReformatAWGS_WP::ReadChunk(const unsigned char** pSrcBuf, long* pSrcLen,
ReformatAWGS_WP::ReadChunk(const uint8_t** pSrcBuf, long* pSrcLen,
Chunk* pChunk)
{
/* starts with the saveArray count */
@ -210,12 +210,12 @@ ReformatAWGS_WP::PrintChunk(const Chunk* pChunk)
{
const int kDefaultStatusBits = kAWGSJustifyLeft | kAWGSSingleSpace;
SaveArrayEntry sae;
const unsigned char* saveArray;
const uint8_t* saveArray;
int saCount;
const unsigned char* blockPtr;
const uint8_t* blockPtr;
long blockLen;
const unsigned char* pRuler;
unsigned short rulerStatusBits;
const uint8_t* pRuler;
uint16_t rulerStatusBits;
saveArray = pChunk->saveArray;
saCount = pChunk->saveArrayCount;
@ -291,12 +291,11 @@ ReformatAWGS_WP::PrintChunk(const Chunk* pChunk)
* skip through them earlier. We don't really need to worry about running
* off the end due to a bad file.
*/
const unsigned char*
const uint8_t*
ReformatAWGS_WP::FindTextBlock(const Chunk* pChunk, int blockNum)
{
const unsigned char* blockPtr = pChunk->textBlocks;
long count = pChunk->numTextBlocks;
unsigned long blockSize;
const uint8_t* blockPtr = pChunk->textBlocks;
uint32_t blockSize;
while (blockNum--) {
blockSize = Get32LE(blockPtr);
@ -315,12 +314,12 @@ ReformatAWGS_WP::FindTextBlock(const Chunk* pChunk, int blockNum)
* Returns the #of bytes consumed.
*/
int
ReformatAWGS_WP::PrintParagraph(const unsigned char* ptr, long maxLen)
ReformatAWGS_WP::PrintParagraph(const uint8_t* ptr, long maxLen)
{
const unsigned char* startPtr = ptr;
unsigned short firstFont;
unsigned char firstStyle, firstSize, firstColor;
unsigned char uch;
const uint8_t* startPtr = ptr;
uint16_t firstFont;
uint8_t firstStyle, firstSize, firstColor;
uint8_t uch;
if (maxLen < 7) {
LOGI("AWGS_WP GLITCH: not enough storage for para header (%d)",
@ -408,9 +407,9 @@ ReformatAWGS_WP::PrintParagraph(const unsigned char* ptr, long maxLen)
/*
* Run through the SaveArray and find the highest-numbered ruler index.
*/
unsigned short
ReformatAWGS_WP::GetNumRulers(const unsigned char* pSaveArray,
unsigned short saveArrayCount)
uint16_t
ReformatAWGS_WP::GetNumRulers(const uint8_t* pSaveArray,
uint16_t saveArrayCount)
{
SaveArrayEntry sa;
int maxRuler = -1;
@ -430,7 +429,7 @@ ReformatAWGS_WP::GetNumRulers(const unsigned char* pSaveArray,
/* there must be at least one paragraph, so this must hold */
assert(maxRuler >= 0);
return (unsigned short) (maxRuler+1);
return (uint16_t) (maxRuler+1);
}
/*
@ -439,12 +438,12 @@ ReformatAWGS_WP::GetNumRulers(const unsigned char* pSaveArray,
*
* These are stored linearly, so we just need to look at the last entry.
*/
unsigned short
ReformatAWGS_WP::GetNumTextBlocks(const unsigned char* pSaveArray,
unsigned short saveArrayCount)
uint16_t
ReformatAWGS_WP::GetNumTextBlocks(const uint8_t* pSaveArray,
uint16_t saveArrayCount)
{
SaveArrayEntry sa;
unsigned short maxTextBlock;
uint16_t maxTextBlock;
assert(saveArrayCount > 0);
UnpackSaveArrayEntry(pSaveArray + (saveArrayCount-1) * kSaveArrayEntryLen,
@ -475,14 +474,14 @@ ReformatAWGS_WP::GetNumTextBlocks(const unsigned char* pSaveArray,
}
#endif
return (unsigned short) (maxTextBlock+1);
return (uint16_t) (maxTextBlock+1);
}
/*
* Unpack a SaveArray entry.
*/
void
ReformatAWGS_WP::UnpackSaveArrayEntry(const unsigned char* pSaveArray,
ReformatAWGS_WP::UnpackSaveArrayEntry(const uint8_t* pSaveArray,
SaveArrayEntry* pSAE)
{
pSAE->textBlock = Get16LE(pSaveArray + 0);
@ -503,11 +502,11 @@ ReformatAWGS_WP::UnpackSaveArrayEntry(const unsigned char* pSaveArray,
* Returns "true" on success, "false" on failure.
*/
bool
ReformatAWGS_WP::SkipTextBlocks(const unsigned char** pSrcBuf,
ReformatAWGS_WP::SkipTextBlocks(const uint8_t** pSrcBuf,
long* pSrcLen, int textBlockCount)
{
unsigned long blockSize;
const unsigned char* srcBuf = *pSrcBuf;
uint32_t blockSize;
const uint8_t* srcBuf = *pSrcBuf;
long srcLen = *pSrcLen;
LOGI("Scanning %d text blocks", textBlockCount);

View File

@ -29,12 +29,12 @@ private:
* Definition of a "SaveArray" entry.
*/
typedef struct SaveArrayEntry {
unsigned short textBlock; // Text Block number
unsigned short offset; // add to offset of text block
unsigned short attributes; // 0=normal text, 1=page break para
unsigned short rulerNum; // number of ruler for this para
unsigned short pixelHeight; // height of para in pixels
unsigned short numLines; // number of lines in this para
uint16_t textBlock; // Text Block number
uint16_t offset; // add to offset of text block
uint16_t attributes; // 0=normal text, 1=page break para
uint16_t rulerNum; // number of ruler for this para
uint16_t pixelHeight; // height of para in pixels
uint16_t numLines; // number of lines in this para
} SaveArrayEntry;
/*
@ -42,12 +42,12 @@ private:
* has the same general structure.
*/
typedef struct Chunk {
const unsigned char* saveArray;
const unsigned char* rulers;
const unsigned char* textBlocks;
unsigned short saveArrayCount;
unsigned short numRulers;
unsigned short numTextBlocks;
const uint8_t* saveArray;
const uint8_t* rulers;
const uint8_t* textBlocks;
uint16_t saveArrayCount;
uint16_t numRulers;
uint16_t numTextBlocks;
} Chunk;
enum {
@ -74,18 +74,18 @@ private:
kAWGSSingleSpace = 0x01
};
bool ReadChunk(const unsigned char** pSrcBuf, long* pSrcLen,
bool ReadChunk(const uint8_t** pSrcBuf, long* pSrcLen,
Chunk* pChunk);
void PrintChunk(const Chunk* pChunk);
const unsigned char* FindTextBlock(const Chunk* pChunk, int blockNum);
int PrintParagraph(const unsigned char* ptr, long maxLen);
unsigned short GetNumRulers(const unsigned char* pSaveArray,
unsigned short saveArrayCount);
unsigned short GetNumTextBlocks(const unsigned char* pSaveArray,
unsigned short saveArrayCount);
void UnpackSaveArrayEntry(const unsigned char* pSaveArray,
const uint8_t* FindTextBlock(const Chunk* pChunk, int blockNum);
int PrintParagraph(const uint8_t* ptr, long maxLen);
uint16_t GetNumRulers(const uint8_t* pSaveArray,
uint16_t saveArrayCount);
uint16_t GetNumTextBlocks(const uint8_t* pSaveArray,
uint16_t saveArrayCount);
void UnpackSaveArrayEntry(const uint8_t* pSaveArray,
SaveArrayEntry* pSAE);
bool SkipTextBlocks(const unsigned char** pSrcBuf,
bool SkipTextBlocks(const uint8_t** pSrcBuf,
long* pSrcLen, int blockCount);
};

View File

@ -49,13 +49,13 @@ ReformatAWP::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;
bool skipRecord;
uchar lineRecCode, lineRecData;
uint8_t lineRecCode, lineRecData;
if (srcLen > 65536)
fUseRTF = false;
@ -168,8 +168,8 @@ ReformatAWP::InitDocState(void)
* Process a line record.
*/
int
ReformatAWP::ProcessLineRecord(uchar lineRecData, uchar lineRecCode,
const unsigned char** pSrcPtr, long* pLength)
ReformatAWP::ProcessLineRecord(uint8_t lineRecData, uint8_t lineRecCode,
const uint8_t** pSrcPtr, long* pLength)
{
int err = 0;
@ -305,12 +305,12 @@ ReformatAWP::ProcessLineRecord(uchar lineRecData, uchar lineRecCode,
* "lineRecData" has the number of bytes of input that we have yet to read.
*/
int
ReformatAWP::HandleTextRecord(uchar lineRecData,
const unsigned char** pSrcPtr, long* pLength)
ReformatAWP::HandleTextRecord(uint8_t lineRecData,
const uint8_t** pSrcPtr, long* pLength)
{
int err = 0;
uchar tabFlags;
uchar byteCountPlusCR;
uint8_t tabFlags;
uint8_t byteCountPlusCR;
int byteCount = lineRecData;
bool noOutput = false;
int ic;
@ -493,7 +493,7 @@ ReformatADB::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;
@ -533,7 +533,7 @@ ReformatADB::Process(const ReformatHolder* pHolder,
LOGI(" ADB should be %d reports", numReports);
/* dump category names as first record */
const unsigned char* catPtr;
const uint8_t* catPtr;
int catCount;
catPtr = srcPtr + 357;
catCount = numCats;
@ -544,7 +544,7 @@ ReformatADB::Process(const ReformatHolder* pHolder,
BufPrintf(",\"");
int nameLen = *catPtr;
const unsigned char* namePtr = catPtr + 1;
const uint8_t* namePtr = catPtr + 1;
while (nameLen--) {
if (*namePtr == '"')
BufPrintf("\"\"");
@ -650,7 +650,7 @@ ReformatADB::Process(const ReformatHolder* pHolder,
}
} else {
while (ctrl--) {
unsigned char ch = Read8(&srcPtr, &length);
uint8_t ch = Read8(&srcPtr, &length);
BufPrintf("%c", ch);
if (ch == '"')
BufPrintf("%c", ch);
@ -751,7 +751,7 @@ ReformatASP::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;
@ -798,7 +798,7 @@ ReformatASP::Process(const ReformatHolder* pHolder,
*/
fCurrentRow = 1;
while (length > 0) {
unsigned short rowLen;
uint16_t rowLen;
int rowNum;
/* row length or EOF marker */
@ -843,10 +843,9 @@ bail:
* Process one row of spreadsheet data.
*/
int
ReformatASP::ProcessRow(int rowNum, const unsigned char** pSrcPtr,
long* pLength)
ReformatASP::ProcessRow(int rowNum, const uint8_t** pSrcPtr, long* pLength)
{
uchar ctrl;
uint8_t ctrl;
bool first = true;
fCurrentCol = 0;
@ -900,9 +899,9 @@ ReformatASP::ProcessRow(int rowNum, const unsigned char** pSrcPtr,
* Process the contents of a single cell.
*/
void
ReformatASP::ProcessCell(const unsigned char* srcPtr, long cellLength)
ReformatASP::ProcessCell(const uint8_t* srcPtr, long cellLength)
{
uchar flag1, flag2;
uint8_t flag1, flag2;
double dval;
int i;
@ -971,7 +970,7 @@ ReformatASP::ProcessCell(const unsigned char* srcPtr, long cellLength)
* several bytes to express.
*/
void
ReformatASP::PrintToken(const unsigned char** pSrcPtr, long* pLength)
ReformatASP::PrintToken(const uint8_t** pSrcPtr, long* pLength)
{
/* string constants; note these must NOT contain '"' chars */
const int kTokenStart = 0xc0;
@ -993,7 +992,7 @@ ReformatASP::PrintToken(const unsigned char** pSrcPtr, long* pLength)
/*0xf8*/ "*", "(", "-" /*unary*/, "+" /*unary*/,
/*0xfc*/ "...", "", "", ""
};
uchar token;
uint8_t token;
token = Read8(pSrcPtr, pLength);
if (token < kTokenStart) {
@ -1039,7 +1038,7 @@ ReformatASP::PrintToken(const unsigned char** pSrcPtr, long* pLength)
return;
}
while (i--) {
unsigned char ch = Read8(pSrcPtr, pLength);
uint8_t ch = Read8(pSrcPtr, pLength);
BufPrintQChar(ch);
}
}
@ -1102,15 +1101,15 @@ ReformatASP::PrintCol(int col)
* -----
*/
double
ReformatASP::ConvertSANEDouble(const unsigned char* srcPtr)
ReformatASP::ConvertSANEDouble(const uint8_t* srcPtr)
{
double newVal;
unsigned char* dptr;
uint8_t* dptr;
int i;
ASSERT(sizeof(newVal) == kSANELen);
dptr = (unsigned char*) &newVal;
dptr = (uint8_t*) &newVal;
for (i = 0; i < kSANELen; i++)
*dptr++ = *srcPtr++;

View File

@ -25,7 +25,6 @@ public:
ReformatOutput* pOutput);
private:
typedef unsigned char uchar;
/*
* Constants.
@ -110,20 +109,20 @@ private:
* be exactly 300 bytes.
*/
typedef struct FileHeader {
uchar unused1[4]; /* 000 - 003: not used */
uchar seventyNine; /* 004 : $4f (79) */
uchar tabStops[80]; /* 005 - 084: tab stops, one of "=<^>.|" */
uchar zoomFlag; /* 085 : boolean Zoom flag */
uchar unused2[4]; /* 086 - 089: not used */
uchar paginatedFlag; /* 090 : boolean Paginated flag */
uchar minLeftMargin; /* 091 : minimum "unseen" left margin */
uchar mailMergeFlag; /* 092 : boolean - file has merge cmds */
uchar unused3[83]; /* 093 - 175: not used, reserved */
uchar multiRulerFlag; /* 176 : (3.0) boolean Multiple Rulers */
uchar tabRulers[6]; /* 177 - 182: (3.0) used internally */
uchar sfMinVers; /* 183 : (3.0) min version of AW req */
uchar unused4[66]; /* 184 - 249: reserved */
uchar unused5[50]; /* 250 - 299: available */
uint8_t unused1[4]; /* 000 - 003: not used */
uint8_t seventyNine; /* 004 : $4f (79) */
uint8_t tabStops[80]; /* 005 - 084: tab stops, one of "=<^>.|" */
uint8_t zoomFlag; /* 085 : boolean Zoom flag */
uint8_t unused2[4]; /* 086 - 089: not used */
uint8_t paginatedFlag; /* 090 : boolean Paginated flag */
uint8_t minLeftMargin; /* 091 : minimum "unseen" left margin */
uint8_t mailMergeFlag; /* 092 : boolean - file has merge cmds */
uint8_t unused3[83]; /* 093 - 175: not used, reserved */
uint8_t multiRulerFlag; /* 176 : (3.0) boolean Multiple Rulers */
uint8_t tabRulers[6]; /* 177 - 182: (3.0) used internally */
uint8_t sfMinVers; /* 183 : (3.0) min version of AW req */
uint8_t unused4[66]; /* 184 - 249: reserved */
uint8_t unused5[50]; /* 250 - 299: available */
} FileHeader;
/*
@ -139,10 +138,10 @@ private:
void InitDocState(void);
int ProcessLineRecord(uchar lineRecData, uchar lineRecCode,
const unsigned char** pSrcPtr, long* pLength);
int HandleTextRecord(uchar lineRecData,
const unsigned char** pSrcPtr, long* pLength);
int ProcessLineRecord(uint8_t lineRecData, uint8_t lineRecCode,
const uint8_t** pSrcPtr, long* pLength);
int HandleTextRecord(uint8_t lineRecData,
const uint8_t** pSrcPtr, long* pLength);
FileHeader fFileHeader;
DocState fDocState;
@ -192,54 +191,52 @@ private:
kSANELen = 8,
};
typedef unsigned char uchar;
/*
* File header, mapped directly on top of the input. This structure must
* be exactly 300 bytes.
*/
typedef struct FileHeader {
uchar unused1[4]; /* 000-003: not used */
uchar colWidth[127]; /* 004-130: column width for each column */
uchar recalcOrder; /* 131 : recalc order ('R' or 'C') */
uchar recalcFreq; /* 132 : recalc frequency ('A' or 'M') */
uchar lastRowRef[2]; /* 133-134: last row referenced */
uchar lastColRef; /* 135 : last column referenced */
uchar numWindows; /* 136 : '1'/'S'/'T' */
uchar windowSync; /* 137 : if two windows, are sync'ed? */
uchar winInfo1[24]; /* 138-161: struct with info for 1st window */
uchar winInfo2[24]; /* 162-185: struct with info for 2nd window */
uchar unused2[27]; /* 186-212: not used */
uchar cellProt; /* 213 : cell protection on/off */
uchar unused3; /* 214 : not used */
uchar platenWidth; /* 215 : platen width */
uchar leftMargin; /* 216 : left margin, in 1/10th inches */
uchar rightMargin; /* 217 : right margin */
uchar cpi; /* 218 : characters per inch */
uchar paperLength; /* 219 : paper length, 1/10th inches */
uchar topMargin; /* 220 : top margin */
uchar bottomMargin; /* 221 : bottom margin */
uchar lpi; /* 222 : lines per inch (6 or 8) */
uchar spacing; /* 223 : 'S'ingle, 'D'ouble, or 'T'riple */
uchar printerCodes[14];/*224-237: "special codes" for printer */
uchar printDash; /* 238 : print dash when entry is blank */
uchar reportHeader; /* 239 : print report header */
uchar zoomed; /* 240 : zoomed to show formulas */
uchar reserved1; /* 241 : used internally (v2.1) */
uchar ssMinVers; /* 242 : holds 0 for AW2.x, 0x1e for AW3.x */
uchar reserved2[7]; /* 243-249: reserved */
uchar available[50]; /* 250-299: available for non-AW app use */
uint8_t unused1[4]; /* 000-003: not used */
uint8_t colWidth[127]; /* 004-130: column width for each column */
uint8_t recalcOrder; /* 131 : recalc order ('R' or 'C') */
uint8_t recalcFreq; /* 132 : recalc frequency ('A' or 'M') */
uint8_t lastRowRef[2]; /* 133-134: last row referenced */
uint8_t lastColRef; /* 135 : last column referenced */
uint8_t numWindows; /* 136 : '1'/'S'/'T' */
uint8_t windowSync; /* 137 : if two windows, are sync'ed? */
uint8_t winInfo1[24]; /* 138-161: struct with info for 1st window */
uint8_t winInfo2[24]; /* 162-185: struct with info for 2nd window */
uint8_t unused2[27]; /* 186-212: not used */
uint8_t cellProt; /* 213 : cell protection on/off */
uint8_t unused3; /* 214 : not used */
uint8_t platenWidth; /* 215 : platen width */
uint8_t leftMargin; /* 216 : left margin, in 1/10th inches */
uint8_t rightMargin; /* 217 : right margin */
uint8_t cpi; /* 218 : characters per inch */
uint8_t paperLength; /* 219 : paper length, 1/10th inches */
uint8_t topMargin; /* 220 : top margin */
uint8_t bottomMargin; /* 221 : bottom margin */
uint8_t lpi; /* 222 : lines per inch (6 or 8) */
uint8_t spacing; /* 223 : 'S'ingle, 'D'ouble, or 'T'riple */
uint8_t printerCodes[14];/*224-237: "special codes" for printer */
uint8_t printDash; /* 238 : print dash when entry is blank */
uint8_t reportHeader; /* 239 : print report header */
uint8_t zoomed; /* 240 : zoomed to show formulas */
uint8_t reserved1; /* 241 : used internally (v2.1) */
uint8_t ssMinVers; /* 242 : holds 0 for AW2.x, 0x1e for AW3.x */
uint8_t reserved2[7]; /* 243-249: reserved */
uint8_t available[50]; /* 250-299: available for non-AW app use */
} FileHeader;
int fCurrentRow, fCurrentCol;
char fPrintColBuf[3];
int ProcessRow(int rowNum, const unsigned char** pSrcPtr,
int ProcessRow(int rowNum, const uint8_t** pSrcPtr,
long* pLength);
void ProcessCell(const unsigned char* srcPtr, long cellLength);
void PrintToken(const unsigned char** pSrcPtr, long* pLength);
void ProcessCell(const uint8_t* srcPtr, long cellLength);
void PrintToken(const uint8_t** pSrcPtr, long* pLength);
const char* PrintCol(int col);
double ConvertSANEDouble(const unsigned char* srcPtr);
double ConvertSANEDouble(const uint8_t* srcPtr);
};
#endif /*REFORMAT_APPLEWORKS_H*/

View File

@ -79,7 +79,7 @@ ReformatSCAssem::Examine(ReformatHolder* pHolder)
/*static*/ bool
ReformatSCAssem::IsSCAssem(const ReformatHolder* pHolder)
{
const unsigned char* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
int len;
@ -108,7 +108,7 @@ ReformatSCAssem::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
// (this was written before tab stuff in ReformatAsm class existed)
@ -132,8 +132,8 @@ ReformatSCAssem::Process(const ReformatHolder* pHolder,
}
while (length > 0) {
unsigned char lineLen;
unsigned short lineNum;
uint8_t lineLen;
uint16_t lineNum;
/* pull the length byte, which we sanity-check */
lineLen = *srcPtr++;
@ -155,7 +155,7 @@ ReformatSCAssem::Process(const ReformatHolder* pHolder,
} else if (*srcPtr == 0xc0) {
if (length > 2) {
int count = *(srcPtr+1);
unsigned char ch = *(srcPtr+2);
uint8_t ch = *(srcPtr + 2);
srcPtr += 2;
length -= 2;
@ -274,7 +274,7 @@ ReformatMerlin::Examine(ReformatHolder* pHolder)
/*static*/ bool
ReformatMerlin::IsMerlin(const ReformatHolder* pHolder)
{
const unsigned char* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
bool isLineStart = true;
@ -334,14 +334,14 @@ ReformatMerlin::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;
enum { kStateLabel, kStateMnemonic, kStateOperand, kStateComment };
int tabStop[] = { 0, 9, 15, 26 }; // 1:1 map with state enum
int state;
unsigned char quoteChar = '\0';
uint8_t quoteChar = '\0';
fUseRTF = false;
@ -461,9 +461,9 @@ ReformatLISA2::Examine(ReformatHolder* pHolder)
bool
ReformatLISA2::IsLISA(const ReformatHolder* pHolder)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
unsigned short version, len;
uint16_t version, len;
if (srcLen < 8)
return false;
@ -523,7 +523,7 @@ ReformatLISA2::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long actualLen;
int retval = -1;
@ -535,7 +535,7 @@ ReformatLISA2::Process(const ReformatHolder* pHolder,
goto bail;
}
unsigned short version;
uint16_t version;
version = Read16(&srcPtr, &srcLen); // usually 0x1800; maybe "2.4"?
actualLen = Read16(&srcPtr, &srcLen);
@ -580,10 +580,10 @@ bail:
}
void
ReformatLISA2::ProcessLine(const unsigned char* buf)
ReformatLISA2::ProcessLine(const uint8_t* buf)
{
int len = *buf;
unsigned char uch;
uint8_t uch;
// consume length byte
buf++;
@ -784,7 +784,7 @@ ReformatLISA3::Examine(ReformatHolder* pHolder)
ReformatLISA3::IsLISA(const ReformatHolder* pHolder)
{
bool dosStructure = (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS);
const unsigned char* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
if (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS)
@ -793,7 +793,7 @@ ReformatLISA3::IsLISA(const ReformatHolder* pHolder)
if (srcLen < kHeaderLen+2)
return false; // too short
unsigned short codeLen, symLen;
uint16_t codeLen, symLen;
codeLen = srcPtr[0x00] | srcPtr[0x01] << 8;
symLen = srcPtr[0x02] | srcPtr[0x03] << 8;
@ -822,7 +822,7 @@ ReformatLISA3::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
int retval = -1;
@ -833,7 +833,7 @@ ReformatLISA3::Process(const ReformatHolder* pHolder,
fUseRTF = false;
unsigned short codeLen, symLen;
uint16_t codeLen, symLen;
codeLen = srcPtr[0x00] | srcPtr[0x01] << 8;
symLen = srcPtr[0x02] | srcPtr[0x03] << 8;
@ -868,8 +868,8 @@ ReformatLISA3::Process(const ReformatHolder* pHolder,
/*
* Do stuff with source lines.
*/
const unsigned char* codePtr;
const unsigned char* endPtr;
const uint8_t* codePtr;
const uint8_t* endPtr;
int lineNum;
codePtr = srcPtr + kHeaderLen + symLen;
@ -878,7 +878,7 @@ ReformatLISA3::Process(const ReformatHolder* pHolder,
lineNum = 0;
while (codePtr < endPtr) {
unsigned char flagByte;
uint8_t flagByte;
int lineLen;
OutputStart();
@ -967,9 +967,9 @@ bail:
* BIGONE
*/
void
ReformatLISA3::ProcessLine(const unsigned char* codePtr, int len)
ReformatLISA3::ProcessLine(const uint8_t* codePtr, int len)
{
unsigned char mnemonic = 0;
uint8_t mnemonic = 0;
//printf("{code=0x%02x len=%d}", *codePtr, len);
if (*codePtr == kCMNTTKN+1 || *codePtr == kCMNTTKN) {
@ -987,7 +987,7 @@ ReformatLISA3::ProcessLine(const unsigned char* codePtr, int len)
goto bail;
} else if (*codePtr == kMACTKN || *codePtr == kMACTKN+1) {
/* CHKMACRO - handle macro */
unsigned short idx;
uint16_t idx;
mnemonic = *codePtr;
idx = (*codePtr & 0x01) << 8;
idx |= *++codePtr;
@ -999,7 +999,7 @@ ReformatLISA3::ProcessLine(const unsigned char* codePtr, int len)
goto ConvtOperand;
} else if (*codePtr == kLBLTKN || *codePtr == kLBLTKN+1) {
/* CHKCLBL - handle label at start of line */
unsigned short idx;
uint16_t idx;
idx = (*codePtr & 0x01) << 8;
idx |= *++codePtr;
PrintSymEntry(idx);
@ -1055,17 +1055,17 @@ bail:
* CNVOPRND
*/
void
ReformatLISA3::ConvertOperand(unsigned char mnemonic,
const unsigned char** pCodePtr, int* pLen)
ReformatLISA3::ConvertOperand(uint8_t mnemonic,
const uint8_t** pCodePtr, int* pLen)
{
static const char kOPRTRST1[] = "+-*/&|^=<>%<><";
static const char kOPRTRST2[] = "\0\0\0\0\0\0\0\0\0\0\0==>";
const unsigned char* codePtr = *pCodePtr;
const uint8_t* codePtr = *pCodePtr;
int len = *pLen;
OperandResult result;
unsigned char adrsMode = 0;
unsigned char val;
uint8_t adrsMode = 0;
uint8_t val;
//printf("{opr len=%d}", len);
@ -1116,7 +1116,7 @@ ReformatLISA3::ConvertOperand(unsigned char mnemonic,
}
OutOprtr:
unsigned char opr;
uint8_t opr;
if (!len)
break;
@ -1164,7 +1164,7 @@ bail:
* Output a single byte as a binary string.
*/
void
ReformatLISA3::PrintBin(unsigned char val)
ReformatLISA3::PrintBin(uint8_t val)
{
char buf[9];
buf[8] = '\0';
@ -1178,10 +1178,10 @@ ReformatLISA3::PrintBin(unsigned char val)
* OUTNUM
*/
ReformatLISA3::OperandResult
ReformatLISA3::PrintNum(int adrsMode, unsigned char val,
const unsigned char** pCodePtr, int* pLen)
ReformatLISA3::PrintNum(int adrsMode, uint8_t val,
const uint8_t** pCodePtr, int* pLen)
{
const unsigned char* codePtr = *pCodePtr;
const uint8_t* codePtr = *pCodePtr;
int len = *pLen;
OperandResult result = kResultUnknown;
char numBuf[12];
@ -1196,7 +1196,7 @@ ReformatLISA3::PrintNum(int adrsMode, unsigned char val,
len--;
} else if (val == 0x1b) {
// 2-byte decimal
unsigned short num;
uint16_t num;
num = *codePtr++;
num |= *codePtr++ << 8;
len -= 2;
@ -1211,7 +1211,7 @@ ReformatLISA3::PrintNum(int adrsMode, unsigned char val,
} else if (val == 0x1d) {
// 2-byte hex
Output('$');
unsigned short num;
uint16_t num;
num = *codePtr++;
num |= *codePtr++ << 8;
sprintf(numBuf, "%04X", num);
@ -1252,7 +1252,7 @@ ReformatLISA3::PrintNum(int adrsMode, unsigned char val,
Output(val - 0x20);
} else if (val < 0x60) {
// ?6..?9 tokens (+0x5c)
unsigned char newVal = val - 0x24;
uint8_t newVal = val - 0x24;
Output('?');
if (newVal == ';')
Output('#');
@ -1325,8 +1325,8 @@ ReformatLISA3::PrintSymEntry(int ent)
return;
}
const unsigned char* packed = &fSymTab[ent * 8];
unsigned char tmp[8];
const uint8_t* packed = &fSymTab[ent * 8];
uint8_t tmp[8];
int i;
tmp[0] = packed[0] >> 2;
@ -1350,7 +1350,7 @@ ReformatLISA3::PrintSymEntry(int ent)
}
void
ReformatLISA3::PrintMnemonic(unsigned char val)
ReformatLISA3::PrintMnemonic(uint8_t val)
{
const char* ptr = &gMnemonics3[val * 3];
Output(ptr[0]);
@ -1364,7 +1364,7 @@ ReformatLISA3::PrintMnemonic(unsigned char val)
* Prints the comment. Finishes off the operand if necessary.
*/
void
ReformatLISA3::PrintComment(int adrsMode, const unsigned char* codePtr, int len)
ReformatLISA3::PrintComment(int adrsMode, const uint8_t* codePtr, int len)
{
assert(len >= 0);
@ -1448,7 +1448,7 @@ ReformatLISA4::Examine(ReformatHolder* pHolder)
ReformatLISA4::IsLISA(const ReformatHolder* pHolder)
{
bool dosStructure = (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS);
const unsigned char* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
if (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS)
@ -1457,9 +1457,9 @@ ReformatLISA4::IsLISA(const ReformatHolder* pHolder)
if (srcLen < kHeaderLen+2)
return false; // too short
unsigned short version;
unsigned short symEnd;
unsigned short symCount;
uint16_t version;
uint16_t symEnd;
uint16_t symCount;
version = srcPtr[0x00] | srcPtr[0x01] << 8;
symEnd = srcPtr[0x02] | srcPtr[0x03] << 8;
@ -1475,7 +1475,7 @@ ReformatLISA4::IsLISA(const ReformatHolder* pHolder)
return false;;
}
unsigned char opTab, adTab, comTab;
uint8_t opTab, adTab, comTab;
opTab = srcPtr[0x06];
adTab = srcPtr[0x07];
comTab = srcPtr[0x08];
@ -1492,7 +1492,7 @@ ReformatLISA4::IsLISA(const ReformatHolder* pHolder)
return true;
}
static const char* gHexDigit = "0123456789ABCDEF";
static const char gHexDigit[] = "0123456789ABCDEF";
/*
@ -1563,7 +1563,7 @@ ReformatLISA4::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
int retval = -1;
@ -1574,8 +1574,8 @@ ReformatLISA4::Process(const ReformatHolder* pHolder,
fUseRTF = false;
unsigned short version;
unsigned short symEnd;
uint16_t version;
uint16_t symEnd;
version = srcPtr[0x00] | srcPtr[0x01] << 8;
symEnd = srcPtr[0x02] | srcPtr[0x03] << 8;
@ -1599,13 +1599,13 @@ ReformatLISA4::Process(const ReformatHolder* pHolder,
goto bail;
}
if (fSymCount > 0) {
fSymTab = new const unsigned char*[fSymCount];
fSymTab = new const uint8_t*[fSymCount];
if (fSymTab == NULL)
goto bail;
}
const unsigned char* symPtr;
const unsigned char* endPtr;
const uint8_t* symPtr;
const uint8_t* endPtr;
int symIdx;
symPtr = srcPtr + kHeaderLen;
@ -1636,7 +1636,7 @@ ReformatLISA4::Process(const ReformatHolder* pHolder,
/*
* Process source lines.
*/
const unsigned char* codePtr;
const uint8_t* codePtr;
int lineNum;
codePtr = srcPtr + symEnd;
@ -1645,7 +1645,7 @@ ReformatLISA4::Process(const ReformatHolder* pHolder,
lineNum = 0;
while (codePtr < endPtr) {
unsigned char flagByte;
uint8_t flagByte;
int lineLen;
lineNum++;
@ -1732,9 +1732,9 @@ bail:
}
void
ReformatLISA4::ProcessLine(const unsigned char* codePtr, int len)
ReformatLISA4::ProcessLine(const uint8_t* codePtr, int len)
{
unsigned char mnemonic = 0;
uint8_t mnemonic = 0;
if (*codePtr == kComntSemiTKN || *codePtr == kComntStarTKN ||
*codePtr == kErrlnTKN)
@ -1765,7 +1765,7 @@ ReformatLISA4::ProcessLine(const unsigned char* codePtr, int len)
goto ConvtOperand;
} else if (*codePtr == kLabelTKN) {
/* handle label at start of line */
unsigned short idx;
uint16_t idx;
idx = *++codePtr;
idx |= *++codePtr << 8;
PrintSymEntry(idx);
@ -1836,8 +1836,8 @@ bail:
* ConvtOperand
*/
void
ReformatLISA4::ConvertOperand(unsigned char mnemonic,
const unsigned char** pCodePtr, int* pLen)
ReformatLISA4::ConvertOperand(uint8_t mnemonic,
const uint8_t** pCodePtr, int* pLen)
{
/*
* Address header char.
@ -1937,11 +1937,11 @@ ReformatLISA4::ConvertOperand(unsigned char mnemonic,
};
const unsigned char* codePtr = *pCodePtr;
const uint8_t* codePtr = *pCodePtr;
int len = *pLen;
OperandResult result;
unsigned char adrsMode = 0;
unsigned char val;
uint8_t adrsMode = 0;
uint8_t val;
char ch;
if (mnemonic == kMacroTKN || mnemonic < kSS) {
@ -2015,7 +2015,7 @@ ReformatLISA4::ConvertOperand(unsigned char mnemonic,
if (doOutOprtr) {
OutOprtr:
unsigned char opr;
uint8_t opr;
if (!len)
break;
@ -2096,10 +2096,10 @@ not_operator:
* CnvrtDec - convert to decimal output.
*/
void
ReformatLISA4::PrintDec(int count, const unsigned char** pCodePtr,
ReformatLISA4::PrintDec(int count, const uint8_t** pCodePtr,
int* pLen)
{
const unsigned char* codePtr = *pCodePtr;
const uint8_t* codePtr = *pCodePtr;
int len = *pLen;
long val = 0;
char buf[12]; // 4 bytes, max 10 chars + sign + nul
@ -2119,12 +2119,12 @@ ReformatLISA4::PrintDec(int count, const unsigned char** pCodePtr,
* CnvrtHex - convert to hex output.
*/
void
ReformatLISA4::PrintHex(int count, const unsigned char** pCodePtr,
ReformatLISA4::PrintHex(int count, const uint8_t** pCodePtr,
int* pLen)
{
const unsigned char* codePtr = *pCodePtr;
const uint8_t* codePtr = *pCodePtr;
int len = *pLen;
unsigned char val;
uint8_t val;
Output('$');
for (int i = count-1; i >= 0; i--) {
@ -2143,12 +2143,12 @@ ReformatLISA4::PrintHex(int count, const unsigned char** pCodePtr,
* CnvrtBin - convert to binary output.
*/
void
ReformatLISA4::PrintBin(int count, const unsigned char** pCodePtr,
ReformatLISA4::PrintBin(int count, const uint8_t** pCodePtr,
int* pLen)
{
const unsigned char* codePtr = *pCodePtr;
const uint8_t* codePtr = *pCodePtr;
int len = *pLen;
unsigned char val;
uint8_t val;
char buf[9];
buf[8] = '\0';
@ -2172,11 +2172,11 @@ ReformatLISA4::PrintBin(int count, const unsigned char** pCodePtr,
* OUTNUM
*/
ReformatLISA4::OperandResult
ReformatLISA4::PrintNum(unsigned char opr, const unsigned char** pCodePtr,
ReformatLISA4::PrintNum(uint8_t opr, const uint8_t** pCodePtr,
int* pLen)
{
OperandResult result = kResultUnknown;
const unsigned char* codePtr = *pCodePtr;
const uint8_t* codePtr = *pCodePtr;
int len = *pLen;
int idx;
@ -2247,9 +2247,9 @@ ReformatLISA4::PrintNum(unsigned char opr, const unsigned char** pCodePtr,
Output("{CheckMoreOprnd}");
} else {
/* CheckStrings */
unsigned char strLen;
unsigned char val;
unsigned char delimit;
uint8_t strLen;
uint8_t val;
uint8_t delimit;
if ((opr & 0x1f) == 0) {
strLen = *codePtr++;
@ -2296,20 +2296,20 @@ ReformatLISA4::PrintNum(unsigned char opr, const unsigned char** pCodePtr,
* OutOprComp
*/
ReformatLISA4::OperandResult
ReformatLISA4::PrintComplexOperand(unsigned char opr,
const unsigned char** pCodePtr, int* pLen)
ReformatLISA4::PrintComplexOperand(uint8_t opr,
const uint8_t** pCodePtr, int* pLen)
{
if (opr != kBign_tkn)
return PrintNum(opr, pCodePtr, pLen);
/*
const unsigned char* codePtr = *pCodePtr;
const uint8_t* codePtr = *pCodePtr;
int len = *pLen;
*pCodePtr = codePtr;
*pLen = len;
*/
unsigned char subClass;
uint8_t subClass;
/* OutOprComp */
subClass = *(*pCodePtr)++;
@ -2322,28 +2322,28 @@ ReformatLISA4::PrintComplexOperand(unsigned char opr,
PrintBin(4, pCodePtr, pLen);
} else if (subClass == kBignhexs_tkn) {
/* hex string, for HEX pseudo-op */
unsigned char hexLen = *(*pCodePtr)++;
uint8_t hexLen = *(*pCodePtr)++;
(*pLen)--;
if (hexLen > *pLen) {
Output("!BAD HEX!");
return kResultFailed;
}
while (hexLen--) {
unsigned char val = *(*pCodePtr)++;
uint8_t val = *(*pCodePtr)++;
(*pLen)--;
Output(gHexDigit[(val & 0xf0) >> 4]);
Output(gHexDigit[val & 0x0f]);
}
} else if (subClass == kBignstring_tkn) {
/* undelimited string */
unsigned char strLen = *(*pCodePtr)++;
uint8_t strLen = *(*pCodePtr)++;
(*pLen)--;
if (strLen > *pLen) {
Output("!BAD USTR!");
return kResultFailed;
}
while (strLen--) {
unsigned char val = *(*pCodePtr)++;
uint8_t val = *(*pCodePtr)++;
(*pLen)--;
Output(val & 0x7f);
}
@ -2368,9 +2368,9 @@ ReformatLISA4::PrintSymEntry(int ent)
return;
}
const unsigned char* str = fSymTab[ent];
const uint8_t* str = fSymTab[ent];
unsigned char uc;
uint8_t uc;
str++;
while (1) {
uc = *str++;

View File

@ -121,7 +121,7 @@ private:
kComTab = 39,
};
void ProcessLine(const unsigned char* buf);
void ProcessLine(const uint8_t* buf);
};
/*
@ -147,17 +147,17 @@ private:
kResultGotoOutOprnd,
} OperandResult;
void ProcessLine(const unsigned char* codePtr, int len);
void ConvertOperand(unsigned char mnemonic, const unsigned char** pCodePtr,
void ProcessLine(const uint8_t* codePtr, int len);
void ConvertOperand(uint8_t mnemonic, const uint8_t** pCodePtr,
int* pLen);
OperandResult PrintNum(int adrsMode, unsigned char val,
const unsigned char** pCodePtr, int* pLen);
OperandResult PrintComplexOperand(unsigned char opr,
const unsigned char** pCodePtr, int* pLen);
OperandResult PrintNum(int adrsMode, uint8_t val,
const uint8_t** pCodePtr, int* pLen);
OperandResult PrintComplexOperand(uint8_t opr,
const uint8_t** pCodePtr, int* pLen);
void PrintSymEntry(int ent);
void PrintMnemonic(unsigned char val);
void PrintBin(unsigned char val);
void PrintComment(int adrsMode, const unsigned char* ptr, int len);
void PrintMnemonic(uint8_t val);
void PrintBin(uint8_t val);
void PrintComment(int adrsMode, const uint8_t* ptr, int len);
enum {
kHeaderLen = 4,
@ -187,8 +187,8 @@ private:
kGROUP9 = 0x4a,
};
const unsigned char* fSymTab;
unsigned short fSymCount;
const uint8_t* fSymTab;
uint16_t fSymCount;
};
@ -265,28 +265,25 @@ private:
kResultGotoOutOprnd,
} OperandResult;
void ProcessLine(const unsigned char* codePtr, int len);
void ConvertOperand(unsigned char mnemonic, const unsigned char** pCodePtr,
void ProcessLine(const uint8_t* codePtr, int len);
void ConvertOperand(uint8_t mnemonic, const uint8_t** pCodePtr,
int* pLen);
void PrintSymEntry(int ent);
OperandResult PrintNum(unsigned char opr, const unsigned char** pCodePtr,
int* pLen);
OperandResult PrintComplexOperand(unsigned char opr,
const unsigned char** pCodePtr, int* pLen);
void PrintDec(int count, const unsigned char** pCodePtr,
int* pLen);
void PrintHex(int count, const unsigned char** pCodePtr,
int* pLen);
void PrintBin(int count, const unsigned char** pCodePtr,
OperandResult PrintNum(uint8_t opr, const uint8_t** pCodePtr,
int* pLen);
OperandResult PrintComplexOperand(uint8_t opr,
const uint8_t** pCodePtr, int* pLen);
void PrintDec(int count, const uint8_t** pCodePtr, int* pLen);
void PrintHex(int count, const uint8_t** pCodePtr, int* pLen);
void PrintBin(int count, const uint8_t** pCodePtr, int* pLen);
const unsigned char** fSymTab;
unsigned short fSymCount;
const uint8_t** fSymTab;
uint16_t fSymCount;
unsigned char fOpTab;
unsigned char fAdTab;
unsigned char fComTab;
unsigned char fCpuType;
uint8_t fOpTab;
uint8_t fAdTab;
uint8_t fComTab;
uint8_t fCpuType;
};
#endif /*REFORMAT_ASM_H*/

View File

@ -106,7 +106,7 @@ ReformatApplesoft::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;
@ -133,8 +133,8 @@ ReformatApplesoft::Process(const ReformatHolder* pHolder,
}
while (length > 0) {
unsigned short nextAddr;
unsigned short lineNum;
uint16_t nextAddr;
uint16_t lineNum;
bool inQuote = false;
bool inRem = false;
@ -349,10 +349,9 @@ ReformatInteger::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
//unsigned short val16;
int retval = -1;
//srcPtr += 0xff0; //0x228e;
@ -379,8 +378,8 @@ ReformatInteger::Process(const ReformatHolder* pHolder,
}
while (length > 0) {
unsigned char lineLen;
unsigned short lineNum;
uint8_t lineLen;
uint16_t lineNum;
bool trailingSpace;
bool newTrailingSpace = false;
@ -622,7 +621,7 @@ ReformatBusiness::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;
@ -649,14 +648,14 @@ ReformatBusiness::Process(const ReformatHolder* pHolder,
goto done;
}
unsigned short fileLength;
uint16_t fileLength;
fileLength = Read16(&srcPtr, &length);
LOGI(" BA3 internal file length is: %d", fileLength);
while (length > 0) {
unsigned short increment;
unsigned short extendedToken;
unsigned short lineNum;
uint16_t increment;
uint16_t extendedToken;
uint16_t lineNum;
bool inQuote = false;
bool inRem = false;
bool firstData = true;

View File

@ -62,7 +62,7 @@ void
ReformatCPMText::Examine(ReformatHolder* pHolder)
{
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
const unsigned char* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
long fileLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
const char* nameExt = pHolder->GetNameExt();
bool foundCtrlZ = false;
@ -123,7 +123,7 @@ ReformatCPMText::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
fUseRTF = false;

View File

@ -38,7 +38,7 @@ ReformatDirectory::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
fUseRTF = false;
@ -71,13 +71,13 @@ ReformatDirectory::Process(const ReformatHolder* pHolder,
* deleted entries.
*/
void
ReformatDirectory::PrintDirEntries(const unsigned char* srcBuf,
ReformatDirectory::PrintDirEntries(const uint8_t* srcBuf,
long srcLen, bool showDeleted)
{
const int kEntriesPerBlock = 0x0d; // expected value for entries per blk
const int kEntryLength = 0x27; // expected value for dir entry len
const int kMaxFileName = 15;
const unsigned char* pDirEntry;
const uint8_t* pDirEntry;
int blockIdx;
int entryIdx;
@ -125,7 +125,7 @@ ReformatDirectory::PrintDirEntries(const unsigned char* srcBuf,
lockedFlag = ' ';
CStringA auxTypeStr;
unsigned short auxType = pDirEntry[0x1f] | pDirEntry[0x20] << 8;
uint16_t auxType = pDirEntry[0x1f] | pDirEntry[0x20] << 8;
if (pDirEntry[0x10] == 0x06) // bin
auxTypeStr.Format("A=$%04X", auxType);
else if (pDirEntry[0x10] == 0x04) // txt

View File

@ -25,7 +25,7 @@ public:
ReformatOutput* pOutput);
private:
void PrintDirEntries(const unsigned char* srcBuf,
void PrintDirEntries(const uint8_t* srcBuf,
long srcLen, bool showDeleted);
};

View File

@ -149,7 +149,7 @@ ReformatDisasm65xxx::GetOpWidth(OpCode opCode, AddrMode addrMode, CPU cpu,
* The caller is expected to check to see if we're in bank 0.
*/
bool
ReformatDisasm65xxx::IsP8Call(const unsigned char* srcBuf, long srcLen)
ReformatDisasm65xxx::IsP8Call(const uint8_t* srcBuf, long srcLen)
{
if (srcLen >= 6 &&
srcBuf[0] == 0x20 && srcBuf[1] == 0x00 && srcBuf[2] == 0xbf)
@ -163,7 +163,7 @@ ReformatDisasm65xxx::IsP8Call(const unsigned char* srcBuf, long srcLen)
* Returns "true" if it looks like we're pointing at a IIgs toolbox call.
*/
bool
ReformatDisasm65xxx::IsToolboxCall(const unsigned char* srcBuf, long srcLen,
ReformatDisasm65xxx::IsToolboxCall(const uint8_t* srcBuf, long srcLen,
long backState)
{
if (srcLen >= 4 && backState >= 3 &&
@ -179,7 +179,7 @@ ReformatDisasm65xxx::IsToolboxCall(const unsigned char* srcBuf, long srcLen,
* Returns "true" if it looks like we're pointing at an inline GS/OS call.
*/
bool
ReformatDisasm65xxx::IsInlineGSOS(const unsigned char* srcBuf, long srcLen)
ReformatDisasm65xxx::IsInlineGSOS(const uint8_t* srcBuf, long srcLen)
{
if (srcLen >= 10 &&
srcBuf[0] == 0x22 && srcBuf[1] == 0xa8 && srcBuf[2] == 0x00 &&
@ -194,7 +194,7 @@ ReformatDisasm65xxx::IsInlineGSOS(const unsigned char* srcBuf, long srcLen)
* Returns "true" if it looks like we're pointing at a stack GS/OS call.
*/
bool
ReformatDisasm65xxx::IsStackGSOS(const unsigned char* srcBuf, long srcLen,
ReformatDisasm65xxx::IsStackGSOS(const uint8_t* srcBuf, long srcLen,
long backState)
{
if (srcLen >= 4 && backState >= 3 &&
@ -214,8 +214,8 @@ ReformatDisasm65xxx::IsStackGSOS(const unsigned char* srcBuf, long srcLen,
* Returns the number of bytes consumed.
*/
int
ReformatDisasm65xxx::OutputMonitor8(const unsigned char* srcBuf, long srcLen,
long backState, unsigned short addr)
ReformatDisasm65xxx::OutputMonitor8(const uint8_t* srcBuf, long srcLen,
long backState, uint16_t addr)
{
const CPU kCPU = kCPU65C02; // 6502 or 65C02
OpCode opCode;
@ -249,7 +249,7 @@ ReformatDisasm65xxx::OutputMonitor8(const unsigned char* srcBuf, long srcLen,
} else
if (srcLen < bytesUsed) {
assert(bytesUsed <= kMaxByteConsumption);
unsigned char tmpBuf[kMaxByteConsumption];
uint8_t tmpBuf[kMaxByteConsumption];
memset(tmpBuf, 0, kMaxByteConsumption);
memcpy(tmpBuf, srcBuf, srcLen);
@ -267,13 +267,13 @@ ReformatDisasm65xxx::OutputMonitor8(const unsigned char* srcBuf, long srcLen,
*/
void
ReformatDisasm65xxx::PrintMonitor8Line(OpCode opCode, AddrMode addrMode,
unsigned short addr, const unsigned char* srcBuf, long srcLen,
uint16_t addr, const uint8_t* srcBuf, long srcLen,
const char* comment)
{
char lineBuf[64]; // actual length is about 30 -- does not hold comment
char* cp;
const char* mnemonic = kOpCodeDetails[opCode].mnemonic;
unsigned char byte0, byte1, byte2;
uint8_t byte0, byte1, byte2;
cp = lineBuf;
@ -401,15 +401,15 @@ ReformatDisasm65xxx::PrintMonitor8Line(OpCode opCode, AddrMode addrMode,
* Returns the number of bytes consumed.
*/
int
ReformatDisasm65xxx::OutputMonitor16(const unsigned char* srcBuf, long srcLen,
long backState, unsigned long addr, bool shortRegs)
ReformatDisasm65xxx::OutputMonitor16(const uint8_t* srcBuf, long srcLen,
long backState, uint32_t addr, bool shortRegs)
{
const CPU kCPU = kCPU65816;
OpCode opCode;
AddrMode addrMode;
int bytesUsed;
int opAndAddr;
const char* callName;
const char* callName;
opAndAddr = kOpMap[*srcBuf].opAndAddr[kCPU];
opCode = (OpCode) (opAndAddr & 0xff);
@ -457,7 +457,7 @@ ReformatDisasm65xxx::OutputMonitor16(const unsigned char* srcBuf, long srcLen,
} else
if (srcLen < bytesUsed) {
assert(bytesUsed <= kMaxByteConsumption);
unsigned char tmpBuf[kMaxByteConsumption];
uint8_t tmpBuf[kMaxByteConsumption];
memset(tmpBuf, 0, kMaxByteConsumption);
memcpy(tmpBuf, srcBuf, srcLen);
@ -474,14 +474,14 @@ ReformatDisasm65xxx::OutputMonitor16(const unsigned char* srcBuf, long srcLen,
*/
void
ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode,
unsigned long addr, const unsigned char* srcBuf, long srcLen,
uint32_t addr, const uint8_t* srcBuf, long srcLen,
const char* comment)
{
char lineBuf[64]; // actual length is about 30 -- does not hold comment
char* cp;
const char* mnemonic = kOpCodeDetails[opCode].mnemonic;
unsigned char byte0, byte1, byte2, byte3;
short offset;
uint8_t byte0, byte1, byte2, byte3;
int16_t offset;
cp = lineBuf;
@ -560,10 +560,10 @@ ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode,
offset = (char) byte1;
if (offset < 0)
cp += sprintf(cp, " %04X {-%02X}",
RelOffset((unsigned short) addr, byte1), -offset);
RelOffset((uint16_t) addr, byte1), -offset);
else
cp += sprintf(cp, " %04X {+%02X}",
RelOffset((unsigned short) addr, byte1), offset);
RelOffset((uint16_t) addr, byte1), offset);
break;
case kAddrAbs:
@ -622,10 +622,10 @@ ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode,
offset = (short) (byte1 | byte2 << 8);
if (offset < 0)
cp += sprintf(cp, " %04X {-%02X}",
RelLongOffset((unsigned short) addr, offset), -offset);
RelLongOffset((uint16_t) addr, offset), -offset);
else
cp += sprintf(cp, " %04X {+%02X}",
RelLongOffset((unsigned short) addr, offset), offset);
RelLongOffset((uint16_t) addr, offset), offset);
break;
case kAddrStackAbs: // PEA
cp += sprintf(cp, " %02X%02X", byte2, byte1);
@ -708,11 +708,11 @@ ReformatDisasm8::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long fileType = pHolder->GetFileType();
long backState = 0;
unsigned short addr;
uint16_t addr;
fUseRTF = false;
if (!srcLen)
@ -724,7 +724,7 @@ ReformatDisasm8::Process(const ReformatHolder* pHolder,
if (fileType == kTypeSYS || fileType == kTypeP8C || fileType == kType8OB)
addr = 0x2000;
else if (fileType == kTypeBIN || fileType == kTypeCMD)
addr = (unsigned short) pHolder->GetAuxType();
addr = (uint16_t) pHolder->GetAuxType();
else
addr = 0x0000;
@ -817,10 +817,10 @@ ReformatDisasm16::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long fileType = pHolder->GetFileType();
unsigned long addr = 0;
uint32_t addr = 0;
bool shortRegs;
fUseRTF = false;
@ -849,7 +849,7 @@ ReformatDisasm16::Process(const ReformatHolder* pHolder,
if (fileType == kTypeSYS)
addr = 0x2000;
else if (fileType == kTypeBIN || fileType == kTypeCMD)
addr = (unsigned short) pHolder->GetAuxType();
addr = (uint16_t) pHolder->GetAuxType();
OutputSection(srcBuf, srcLen, addr, shortRegs);
}
@ -862,8 +862,8 @@ ReformatDisasm16::Process(const ReformatHolder* pHolder,
* Output one section of a file.
*/
void
ReformatDisasm16::OutputSection(const unsigned char* srcBuf, long srcLen,
unsigned long addr, bool shortRegs)
ReformatDisasm16::OutputSection(const uint8_t* srcBuf, long srcLen,
uint32_t addr, bool shortRegs)
{
long backState = 0;
@ -883,10 +883,10 @@ ReformatDisasm16::OutputSection(const unsigned char* srcBuf, long srcLen,
* Break an OMF file into sections, and output each individually.
*/
bool
ReformatDisasm16::OutputOMF(const unsigned char* srcBuf, long srcLen,
ReformatDisasm16::OutputOMF(const uint8_t* srcBuf, long srcLen,
long fileType, bool shortRegs)
{
const unsigned char* origBuf = srcBuf;
const uint8_t* origBuf = srcBuf;
long origLen = srcLen;
OMFSegmentHeader segHdr;
int segmentNumber = 1;
@ -1006,9 +1006,9 @@ ReformatDisasm16::PrintHeader(const OMFSegmentHeader* pSegHdr,
*/
void
ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr,
const unsigned char* srcBuf, long srcLen, bool shortRegs)
const uint8_t* srcBuf, long srcLen, bool shortRegs)
{
unsigned long subLen;
uint32_t subLen;
int offset = 0;
assert(pSegHdr != NULL);
@ -1035,7 +1035,7 @@ ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr,
#if 0
OMFSegment seg;
seg.Setup(pSegHdr, srcBuf, srcLen);
const unsigned char* ptr;
const uint8_t* ptr;
do {
ptr = seg.ProcessNextChunk();
@ -1066,7 +1066,7 @@ ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr,
* Returns "true" on success, "false" on failure.
*/
bool
OMFSegmentHeader::Unpack(const unsigned char* srcBuf, long srcLen,
OMFSegmentHeader::Unpack(const uint8_t* srcBuf, long srcLen,
int fileType)
{
if (srcLen < kHdrMinSize) {
@ -1175,7 +1175,7 @@ OMFSegmentHeader::Unpack(const unsigned char* srcBuf, long srcLen,
/* validate fields */
if (fByteCnt < kHdrMinSize || fByteCnt > (unsigned long) srcLen) {
if (fByteCnt < kHdrMinSize || fByteCnt > (uint32_t) srcLen) {
LOGI("OMF: Bad value for byteCnt (%ld, srcLen=%ld min=%d)",
fByteCnt, srcLen, kHdrMinSize);
return false;
@ -1204,7 +1204,7 @@ OMFSegmentHeader::Unpack(const unsigned char* srcBuf, long srcLen,
/* big endian odd-sized numbers?? keep going, I guess */
}
const unsigned char* segName;
const uint8_t* segName;
int segLabelLen;
/* copy the label entries over */
@ -1324,7 +1324,7 @@ OMFSegmentHeader::Dump(void) const
* Prepare to roll through a segment.
*/
void
OMFSegment::Setup(const OMFSegmentHeader* pSegHdr, const unsigned char* srcBuf,
OMFSegment::Setup(const OMFSegmentHeader* pSegHdr, const uint8_t* srcBuf,
long srcLen)
{
fSegBuf = fCurPtr = srcBuf + pSegHdr->GetDispData();
@ -1340,12 +1340,12 @@ OMFSegment::Setup(const OMFSegmentHeader* pSegHdr, const unsigned char* srcBuf,
* Returns a pointer to the start of the chunk, or "NULL" if we've encountered
* some bogus condition (e.g. running off the end).
*/
const unsigned char*
const uint8_t*
OMFSegment::ProcessNextChunk(void)
{
const unsigned char* prevPtr = fCurPtr;
const uint8_t* prevPtr = fCurPtr;
long remLen = fSegLen - (fCurPtr - fSegBuf);
unsigned long subLen;
uint32_t subLen;
int len = 1; // one byte at least (for the opcode)
assert(fLabLen >= 0);
@ -1433,7 +1433,7 @@ OMFSegment::ProcessNextChunk(void)
case kSegOpExperimental4:
subLen = Get32LE(fCurPtr+1); // assumes fNumLen==4
LOGI(" OMF found 'reserved' len=%lu (remLen=%ld)", subLen, remLen);
if (subLen > (unsigned long) remLen)
if (subLen > (uint32_t) remLen)
return NULL;
len += subLen + fNumLen;
break;
@ -1455,7 +1455,7 @@ OMFSegment::ProcessNextChunk(void)
* Pass a pointer to the start of the expression.
*/
int
OMFSegment::ExpressionLength(const unsigned char* ptr)
OMFSegment::ExpressionLength(const uint8_t* ptr)
{
// do this someday
return 1;

View File

@ -142,10 +142,10 @@ protected:
* Output one or more lines of code in a manner appropriate for a
* monitor listing on an 8-bit machine. Returns the #of bytes consumed.
*/
int OutputMonitor8(const unsigned char* srcBuf, long srcLen,
long backState, unsigned short addr);
int OutputMonitor16(const unsigned char* srcBuf, long srcLen,
long backState, unsigned long addr, bool shortRegs);
int OutputMonitor8(const uint8_t* srcBuf, long srcLen,
long backState, uint16_t addr);
int OutputMonitor16(const uint8_t* srcBuf, long srcLen,
long backState, uint32_t addr, bool shortRegs);
private:
bool ValidateOpMap(void);
@ -154,12 +154,12 @@ private:
bool ValidateOpCodeDetails(void);
static const OpCodeDetails kOpCodeDetails[];
inline unsigned short RelOffset(unsigned short addr, unsigned char off) {
char shift = (char) off;
inline uint16_t RelOffset(uint16_t addr, uint8_t off) {
int8_t shift = (int8_t) off; // offset is signed
return addr +2 + shift;
}
inline unsigned short RelLongOffset(unsigned short addr, unsigned short off) {
short shift = (short) off;
inline uint16_t RelLongOffset(uint16_t addr, uint16_t off) {
int16_t shift = (int16_t) off; // offset is signed
return addr +3 + shift;
}
@ -169,26 +169,26 @@ private:
int GetOpWidth(OpCode opCode, AddrMode addrMode, CPU cpu,
bool emul, bool shortM, bool shortX);
bool IsP8Call(const unsigned char* srcBuf, long srcLen);
bool IsToolboxCall(const unsigned char* srcBuf, long srcLen,
bool IsP8Call(const uint8_t* srcBuf, long srcLen);
bool IsToolboxCall(const uint8_t* srcBuf, long srcLen,
long backState);
bool IsInlineGSOS(const unsigned char* srcBuf, long srcLen);
bool IsStackGSOS(const unsigned char* srcBuf, long srcLen,
bool IsInlineGSOS(const uint8_t* srcBuf, long srcLen);
bool IsStackGSOS(const uint8_t* srcBuf, long srcLen,
long backState);
void PrintMonitor8Line(OpCode opCode, AddrMode addrMode,
unsigned short addr, const unsigned char* srcBuf, long srcLen,
uint16_t addr, const uint8_t* srcBuf, long srcLen,
const char* comment);
void PrintMonitor16Line(OpCode opCode, AddrMode addrMode,
unsigned long addr, const unsigned char* srcBuf, long srcLen,
uint32_t addr, const uint8_t* srcBuf, long srcLen,
const char* comment);
/* 24-bit address helpers */
inline unsigned char Bank(unsigned long addr) {
return (unsigned char) ((addr >> 16) & 0xff);
inline uint8_t Bank(uint32_t addr) {
return (uint8_t) ((addr >> 16) & 0xff);
}
inline unsigned short Offset(unsigned long addr) {
return (unsigned short) (addr & 0xffff);
inline uint16_t Offset(uint32_t addr) {
return (uint16_t) (addr & 0xffff);
}
};
@ -217,7 +217,7 @@ public:
OMFSegmentHeader(void) : fReady(false) {}
virtual ~OMFSegmentHeader(void) {}
bool Unpack(const unsigned char* srcBuf, long srcLen, int fileType);
bool Unpack(const uint8_t* srcBuf, long srcLen, int fileType);
void Dump(void) const;
typedef enum SegmentType {
@ -241,14 +241,14 @@ public:
kFlagDynamic,
} SegmentFlag;
int GetVersion(void) const { return fVersion; }
unsigned long GetSegmentLen(void) const { return fByteCnt; }
uint8_t GetVersion(void) const { return fVersion; }
uint32_t GetSegmentLen(void) const { return fByteCnt; }
SegmentType GetSegmentType(void) const;
bool GetSegmentFlag(SegmentFlag flag) const;
int GetSegNum(void) const { return fSegNum; }
int GetLabLen(void) const { return fLabLen; }
int GetNumLen(void) const { return fNumLen; }
int GetDispData(void) const { return fDispData; }
uint16_t GetSegNum(void) const { return fSegNum; }
uint8_t GetLabLen(void) const { return fLabLen; }
uint8_t GetNumLen(void) const { return fNumLen; }
uint16_t GetDispData(void) const { return fDispData; }
const char* GetLoadName(void) const { return (const char*) fLoadName; }
const char* GetSegName(void) const { return (const char*) fSegName; }
@ -269,34 +269,34 @@ public:
private:
bool fReady;
inline unsigned short Get16LE(const unsigned char* buf) {
inline uint16_t Get16LE(const uint8_t* buf) {
return *buf | *(buf+1) << 8;
}
inline unsigned long Get32LE(const unsigned char* buf) {
inline uint32_t Get32LE(const uint8_t* buf) {
return *buf | *(buf+1) << 8 | *(buf+2) << 16 | *(buf+3) << 24;
}
unsigned long fBlockCnt; // v0/v1
unsigned long fByteCnt; // v2
unsigned long fResSpc;
unsigned long fLength;
unsigned char fType; // v0/v1
unsigned char fLabLen;
unsigned char fNumLen; // (always 4)
unsigned char fVersion; // (0, 1, or 2)
unsigned long fBankSize; // (always 65536)
unsigned short fKind; // v2
unsigned long fOrg;
unsigned long fAlign;
unsigned char fNumSex;
unsigned char fLCBank; // v1
unsigned short fSegNum; // v1/v2
unsigned long fEntry; // v1/v2
unsigned short fDispName; // v1/v2
unsigned short fDispData; // v1/v2
unsigned long fTempOrg; // v2
unsigned char fLoadName[kLoadNameLen+1]; // 10 chars, space-padded
unsigned char fSegName[kSegNameLen+1]; // 1-255 chars
uint32_t fBlockCnt; // v0/v1
uint32_t fByteCnt; // v2
uint32_t fResSpc;
uint32_t fLength;
uint8_t fType; // v0/v1
uint8_t fLabLen;
uint8_t fNumLen; // (always 4)
uint8_t fVersion; // (0, 1, or 2)
uint32_t fBankSize; // (always 65536)
uint16_t fKind; // v2
uint32_t fOrg;
uint32_t fAlign;
uint8_t fNumSex;
uint8_t fLCBank; // v1
uint16_t fSegNum; // v1/v2
uint32_t fEntry; // v1/v2
uint16_t fDispName; // v1/v2
uint16_t fDispData; // v1/v2
uint32_t fTempOrg; // v2
uint8_t fLoadName[kLoadNameLen + 1]; // 10 chars, space-padded
uint8_t fSegName[kSegNameLen + 1]; // 1-255 chars
};
#if 0
@ -310,9 +310,9 @@ public:
{}
virtual ~OMFSegment(void) {}
void Setup(const OMFSegmentHeader* pSegHdr, const unsigned char* srcBuf,
void Setup(const OMFSegmentHeader* pSegHdr, const uint8_t* srcBuf,
long srcLen);
const unsigned char* ProcessNextChunk(void);
const uint8_t* ProcessNextChunk(void);
/*
* Segment op codes.
@ -390,10 +390,10 @@ public:
} ExprOp;
private:
// inline unsigned short Get16LE(const unsigned char* buf) {
// inline uint16_t Get16LE(const uint8_t* buf) {
// return *buf | *(buf+1) << 8;
// }
inline unsigned long Get32LE(const unsigned char* buf) {
inline uint32_t Get32LE(const uint8_t* buf) {
return *buf | *(buf+1) << 8 | *(buf+2) << 16 | *(buf+3) << 24;
}
@ -401,7 +401,7 @@ private:
* Given a pointer to the start of a label, return the label's len.
* The length returned includes the length byte (if present).
*/
int LabelLength(const unsigned char* ptr) {
int LabelLength(const uint8_t* ptr) {
if (fLabLen != 0)
return fLabLen;
else
@ -409,12 +409,12 @@ private:
}
/* determine the length of an expression */
int ExpressionLength(const unsigned char* ptr);
int ExpressionLength(const uint8_t* ptr);
const unsigned char* fSegBuf;
const uint8_t* fSegBuf;
long fSegLen;
const unsigned char* fCurPtr;
const uint8_t* fCurPtr;
int fNumLen;
int fLabLen;
};
@ -440,14 +440,14 @@ public:
ReformatOutput* pOutput);
private:
void OutputSection(const unsigned char* srcBuf, long srcLen,
unsigned long addr, bool shortRegs);
bool OutputOMF(const unsigned char* srcBuf, long srcLen,
void OutputSection(const uint8_t* srcBuf, long srcLen,
uint32_t addr, bool shortRegs);
bool OutputOMF(const uint8_t* srcBuf, long srcLen,
long fileType, bool shortRegs);
void PrintHeader(const OMFSegmentHeader* pSegHdr,
int segmentNumber, bool longFmt);
void PrintSegment(const OMFSegmentHeader* pSegHdr,
const unsigned char* srcBuf, long srcLen, bool shortRegs);
const uint8_t* srcBuf, long srcLen, bool shortRegs);
};
#endif /*REFORMAT_DISASM_H*/

View File

@ -92,7 +92,7 @@ ReformatDHR::Process(const ReformatHolder* pHolder,
ReformatOutput* pOutput)
{
MyDIBitmap* pDib;
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
int retval = -1;
@ -162,10 +162,10 @@ ReformatDHR::InitColorLookup(void)
* Convert a buffer of double-hires data to a 16-color DIB.
*/
MyDIBitmap*
ReformatDHR::DHRScreenToBitmap(const unsigned char* buf)
ReformatDHR::DHRScreenToBitmap(const uint8_t* buf)
{
MyDIBitmap* pDib = new MyDIBitmap;
unsigned char* outBuf;
uint8_t* outBuf;
const int kMaxLook = 4; // padding to adjust for lookbehind/lookahead
int pixelBits[kMaxLook+kPixelsPerLine+kMaxLook]; // 560 mono pixels
unsigned int colorBuf[kOutputWidth]; // 560 color pixels
@ -217,7 +217,7 @@ ReformatDHR::DHRScreenToBitmap(const unsigned char* buf)
if (pDib == NULL)
goto bail;
outBuf = (unsigned char*) pDib->Create(kOutputWidth, kOutputHeight,
outBuf = (uint8_t*) pDib->Create(kOutputWidth, kOutputHeight,
4, kNumColors);
if (outBuf == NULL) {
delete pDib;
@ -236,7 +236,7 @@ ReformatDHR::DHRScreenToBitmap(const unsigned char* buf)
* be optimized.
*/
for (line = 0; line < kNumLines; line++) {
const unsigned char* lineData = buf + fLineOffset[line];
const uint8_t* lineData = buf + fLineOffset[line];
int* bitPtr = pixelBits + kMaxLook;
/* this is really just to clear the fore and aft MaxLook bits */
@ -244,7 +244,7 @@ ReformatDHR::DHRScreenToBitmap(const unsigned char* buf)
/* unravel the bits */
for (int byt = 0; byt < kPixelsPerLine / 7; byt++) {
unsigned char val;
uint8_t val;
if (byt & 0x01) {
/* odd pixels come from main memory */
@ -498,7 +498,7 @@ ReformatDHR::DHRScreenToBitmap(const unsigned char* buf)
* Can't explain it, but that's how it works...
* usually.
*/
unsigned char mergePix;
uint8_t mergePix;
mergePix = colorBuf1[idx] & 0x03;
mergePix |= colorBuf1[idx+1] & 0x0c;
@ -520,7 +520,7 @@ ReformatDHR::DHRScreenToBitmap(const unsigned char* buf)
#define SetPix(x, y, twoval) \
outBuf[((kOutputHeight-1) - (y)) * (kOutputWidth/2) + (x)] = twoval
unsigned char pix4;
uint8_t pix4;
for (int pix = 0; pix < kPixelsPerLine/2; pix++) {
int bufPosn = pix * 2;
ASSERT(colorBuf[bufPosn] < kNumColors);

View File

@ -44,7 +44,7 @@ public:
} Algorithms;
void InitColorLookup(void);
MyDIBitmap* DHRScreenToBitmap(const unsigned char* buf);
MyDIBitmap* DHRScreenToBitmap(const uint8_t* buf);
Algorithms fAlgorithm;
int fLineOffset[kNumLines];

View File

@ -41,7 +41,7 @@ ReformatDG256SHR::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
int retval = -1;
@ -86,7 +86,7 @@ ReformatDG3200SHR::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
int retval = -1;
@ -139,7 +139,7 @@ DreamGrafix::ScanDreamGrafix(ReformatHolder* pHolder)
if (!couldBe)
return false;
const unsigned char* ptr;
const uint8_t* ptr;
ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData)
+ fileLen - kHeaderOffset;
@ -164,11 +164,11 @@ DreamGrafix::ScanDreamGrafix(ReformatHolder* pHolder)
* exactly 32768+32*200 bytes.
*/
bool
DreamGrafix::UnpackDG(const unsigned char* srcBuf, long srcLen,
ReformatSHR::SHRScreen* pScreen, unsigned char* extColorTable)
DreamGrafix::UnpackDG(const uint8_t* srcBuf, long srcLen,
ReformatSHR::SHRScreen* pScreen, uint8_t* extColorTable)
{
int expectedLen;
unsigned char* tmpBuf;
uint8_t* tmpBuf;
int actual;
if (extColorTable == NULL) {
@ -189,7 +189,7 @@ DreamGrafix::UnpackDG(const unsigned char* srcBuf, long srcLen,
}
/* over-alloc -- our LZW decoder doesn't check often */
tmpBuf = new unsigned char[expectedLen + 1024];
tmpBuf = new uint8_t[expectedLen + 1024];
if (tmpBuf == NULL)
return false;
@ -205,11 +205,11 @@ DreamGrafix::UnpackDG(const unsigned char* srcBuf, long srcLen,
memcpy(pScreen->scb, tmpBuf + 32000, 256);
memcpy(pScreen->colorTable, tmpBuf + 32256, 512);
} else {
const unsigned short* pSrcTable;
unsigned short* pDstTable;
const uint16_t* pSrcTable;
uint16_t* pDstTable;
pSrcTable = (const unsigned short*) (tmpBuf + 32000);
pDstTable = (unsigned short*) extColorTable;
pSrcTable = (const uint16_t*) (tmpBuf + 32000);
pDstTable = (uint16_t*) extColorTable;
int table;
for (table = 0; table < ReformatSHR::kNumLines; table++) {
int entry;
@ -267,18 +267,18 @@ static const unsigned int bitMasks[] = {
};
/*static*/ int
DreamGrafix::UnpackLZW(const unsigned char* srcBuf, long srcLen,
unsigned char* dstBuf, long dstLen)
DreamGrafix::UnpackLZW(const uint8_t* srcBuf, long srcLen,
uint8_t* dstBuf, long dstLen)
{
unsigned short finChar, oldCode, inCode, freeCode, maxCode, k;
unsigned short nBitMod1, nBitMask;
uint16_t finChar, oldCode, inCode, freeCode, maxCode, k;
uint16_t nBitMod1, nBitMask;
int bitOffset;
unsigned short hashNext[4096];
unsigned short hashChar[4096];
uint16_t hashNext[4096];
uint16_t hashChar[4096];
unsigned char* pOrigDst = dstBuf;
uint8_t* pOrigDst = dstBuf;
int iCode;
short stack[32768];
uint16_t stack[32768];
int stackIdx = 0;
/* initialize table and code reader */
@ -305,7 +305,7 @@ DreamGrafix::UnpackLZW(const unsigned char* srcBuf, long srcLen,
oldCode = iCode;
k = iCode;
finChar = iCode;
*dstBuf++ = (unsigned char)iCode;
*dstBuf++ = (uint8_t) iCode;
continue;
}

View File

@ -228,7 +228,7 @@ ReformatHiRes::Process(const ReformatHolder* pHolder,
ReformatOutput* pOutput)
{
MyDIBitmap* pDib;
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
int retval = -1;
@ -280,10 +280,10 @@ ReformatHiRes::InitLineOffset(int* pOffsetBuf)
* Convert a buffer of hires data to a 16-color DIB.
*/
MyDIBitmap*
ReformatHiRes::HiResScreenToBitmap(const unsigned char* buf)
ReformatHiRes::HiResScreenToBitmap(const uint8_t* buf)
{
MyDIBitmap* pDib = new MyDIBitmap;
unsigned char* outBuf;
uint8_t* outBuf;
const int kLeadIn = 4;
unsigned int colorBuf[kLeadIn+kOutputWidth +1]; // 560 half-pixels
int pixelBits[kPixelsPerLine];
@ -319,7 +319,7 @@ ReformatHiRes::HiResScreenToBitmap(const unsigned char* buf)
if (pDib == NULL)
goto bail;
outBuf = (unsigned char*) pDib->Create(kOutputWidth, kOutputHeight,
outBuf = (uint8_t*) pDib->Create(kOutputWidth, kOutputHeight,
4, kNumColors);
if (outBuf == NULL) {
delete pDib;
@ -332,13 +332,13 @@ ReformatHiRes::HiResScreenToBitmap(const unsigned char* buf)
* Run through the lines.
*/
for (line = 0; line < kNumLines; line++) {
const unsigned char* lineData = buf + fLineOffset[line];
const uint8_t* lineData = buf + fLineOffset[line];
int* bitPtr = pixelBits;
int* shiftPtr = shiftBits;
/* unravel the bits */
for (int byt = 0; byt < kPixelsPerLine / 7; byt++) {
unsigned char val = *lineData;
uint8_t val = *lineData;
int shifted = (val & 0x80) != 0;
for (int bit = 0; bit < 7; bit++) {
@ -430,7 +430,7 @@ ReformatHiRes::HiResScreenToBitmap(const unsigned char* buf)
#define SetPix(x, y, twoval) \
outBuf[((kOutputHeight-1) - (y)) * (kOutputWidth/2) + (x)] = twoval
unsigned char pix4;
uint8_t pix4;
for (int pix = 0; pix < kPixelsPerLine; pix++) {
int bufPosn = kLeadIn + pix * 2;
ASSERT(colorBuf[bufPosn] < kNumColors);

View File

@ -35,7 +35,7 @@ public:
static void InitLineOffset(int* pOffsetBuf);
MyDIBitmap* HiResScreenToBitmap(const unsigned char* buf);
MyDIBitmap* HiResScreenToBitmap(const uint8_t* buf);
int fLineOffset[kNumLines];
bool fBlackWhite;

View File

@ -43,7 +43,7 @@ void
ReformatMacPaint::Examine(ReformatHolder* pHolder)
{
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
const unsigned char* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
long fileLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
const char* nameExt = pHolder->GetNameExt();
long version;
@ -84,7 +84,7 @@ ReformatMacPaint::Process(const ReformatHolder* pHolder,
ReformatOutput* pOutput)
{
MyDIBitmap* pDib;
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
int retval = -1;
@ -111,10 +111,10 @@ bail:
* (required for windows BMP).
*/
MyDIBitmap*
ReformatMacPaint::ConvertMacPaint(const unsigned char* srcBuf, long length)
ReformatMacPaint::ConvertMacPaint(const uint8_t* srcBuf, long length)
{
MyDIBitmap* pDib = NULL;
unsigned char* outBuf;
uint8_t* outBuf;
static const RGBQUAD colorConv[2] = {
/* blue, green, red, reserved */
{ 0x00, 0x00, 0x00 }, // black
@ -146,7 +146,7 @@ ReformatMacPaint::ConvertMacPaint(const unsigned char* srcBuf, long length)
length -= kLeadingJunkCount;
LOGI("Adjusted len is %d", length);
outBuf = (unsigned char*) pDib->Create(kOutputWidth, kOutputHeight,
outBuf = (uint8_t*) pDib->Create(kOutputWidth, kOutputHeight,
1, kNumColors);
if (outBuf == NULL) {
delete pDib;
@ -155,7 +155,7 @@ ReformatMacPaint::ConvertMacPaint(const unsigned char* srcBuf, long length)
}
pDib->SetColorTable(colorConv);
unsigned char* outPtr;
uint8_t* outPtr;
int line;
/* top row goes at the bottom of the buffer */

View File

@ -25,7 +25,7 @@ public:
ReformatOutput* pOutput);
private:
MyDIBitmap* ConvertMacPaint(const unsigned char* srcBuf, long length);
MyDIBitmap* ConvertMacPaint(const uint8_t* srcBuf, long length);
enum {
kLeadingJunkCount = 512,

View File

@ -319,9 +319,9 @@ HexValue(char ch)
}
/*
* Convert a 4-char hexadecimal value to an unsigned short.
* Convert a 4-char hexadecimal value to an unsigned 16-bit value.
*/
/*static*/ unsigned short
/*static*/ uint16_t
NiftyList::ConvHexFour(const char* data)
{
return HexValue(data[0]) << 12 |
@ -354,7 +354,7 @@ NiftyList::DumpSection(const DataSet& dataSet)
* This uses a binary search, so the entries must be in sorted order.
*/
/*static*/ const char*
NiftyList::Lookup(const DataSet& dataSet, unsigned short key)
NiftyList::Lookup(const DataSet& dataSet, uint16_t key)
{
if (!fDataReady) {
return NULL;
@ -367,7 +367,7 @@ NiftyList::Lookup(const DataSet& dataSet, unsigned short key)
while (low <= high) {
mid = (high + low)/2;
unsigned short midVal = dataSet.pEntries[mid].value;
uint16_t midVal = dataSet.pEntries[mid].value;
if (key > midVal)
low = mid +1;

View File

@ -45,12 +45,12 @@ ReformatPascalCode::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
fUseRTF = false;
int retval = -1;
PCDSegment segments[kNumSegments];
unsigned long intrinsSegs;
uint32_t intrinsSegs;
int i;
if (srcLen < kSegmentHeaderLen) {
@ -64,7 +64,7 @@ ReformatPascalCode::Process(const ReformatHolder* pHolder,
* Pull the data fields out of srcBuf.
*/
for (i = 0; i < kNumSegments; i++) {
unsigned short segInfo;
uint16_t segInfo;
segments[i].codeAddr = Get16LE(srcBuf + 0x00 + i*4);
segments[i].codeLeng = Get16LE(srcBuf + 0x02 + i*4);
@ -143,7 +143,7 @@ bail:
*/
void
ReformatPascalCode::PrintSegment(PCDSegment* pSegment, int segNum,
const unsigned char* srcBuf, long srcLen)
const uint8_t* srcBuf, long srcLen)
{
const char* segKindStr;
const char* mTypeStr;
@ -236,7 +236,7 @@ ReformatPascalText::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
fUseRTF = false;
@ -278,7 +278,7 @@ bail:
* appears to -- but I'm not going to assume it.
*/
void
ReformatPascalText::ProcessBlock(const unsigned char* srcBuf, long length)
ReformatPascalText::ProcessBlock(const uint8_t* srcBuf, long length)
{
ASSERT(srcBuf != NULL);
ASSERT(length > 0 && length <= kPTXBlockSize);

View File

@ -58,22 +58,22 @@ private:
kMTPAsm9 = 9,
} MachineType;
typedef struct SegInfo {
unsigned char segNum;
MachineType mType;
unsigned char unused;
unsigned char version;
uint8_t segNum;
MachineType mType;
uint8_t unused;
uint8_t version;
} SegInfo;
typedef struct PCDSegment {
unsigned short codeLeng;
unsigned short codeAddr;
uint16_t codeLeng;
uint16_t codeAddr;
char name[kSegmentNameLen+1];
SegmentKind segmentKind;
unsigned short textAddr;
uint16_t textAddr;
SegInfo segInfo;
} PCDSegment;
void PrintSegment(PCDSegment* pSegment, int segNum,
const unsigned char* srcBuf, long srcLen);
const uint8_t* srcBuf, long srcLen);
};
/*
@ -97,7 +97,7 @@ private:
};
private:
void ProcessBlock(const unsigned char* srcBuf, long length);
void ProcessBlock(const uint8_t* srcBuf, long length);
};
#endif /*REFORMAT_PASCALFILES_H*/

View File

@ -64,7 +64,7 @@ ReformatPrintShop::Process(const ReformatHolder* pHolder,
ReformatOutput* pOutput)
{
MyDIBitmap* pDib = NULL;
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
if (srcLen == 572 || srcLen == 576) {
@ -95,11 +95,11 @@ ReformatPrintShop::Process(const ReformatHolder* pHolder,
* at the end.
*/
MyDIBitmap*
ReformatPrintShop::ConvertBW(const unsigned char* srcBuf)
ReformatPrintShop::ConvertBW(const uint8_t* srcBuf)
{
MyDIBitmap* pDib = new MyDIBitmap;
unsigned char* outBuf;
unsigned char* ptr;
uint8_t* outBuf;
uint8_t* ptr;
int pitch;
int x, y;
@ -111,7 +111,7 @@ ReformatPrintShop::ConvertBW(const unsigned char* srcBuf)
colorConv[1].rgbRed = colorConv[1].rgbGreen = colorConv[1].rgbBlue = 0;
colorConv[0].rgbReserved = colorConv[1].rgbReserved = 0;
outBuf = (unsigned char*) pDib->Create(kWidth, kHeight, 1, 2);
outBuf = (uint8_t*) pDib->Create(kWidth, kHeight, 1, 2);
if (outBuf == NULL) {
delete pDib;
pDib = NULL;
@ -146,13 +146,13 @@ bail:
* table below come from a screen capture of KEGS.
*/
MyDIBitmap*
ReformatPrintShop::ConvertColor(const unsigned char* srcBuf)
ReformatPrintShop::ConvertColor(const uint8_t* srcBuf)
{
MyDIBitmap* pDib = new MyDIBitmap;
unsigned char* outBuf;
unsigned char* ptr;
unsigned char outVal;
unsigned short yellow, magenta, cyan;
uint8_t* outBuf;
uint8_t* ptr;
uint8_t outVal;
uint16_t yellow, magenta, cyan;
int pitch;
int x, y, bit;
static const RGBQUAD kColorConv[8] = {
@ -170,7 +170,7 @@ ReformatPrintShop::ConvertColor(const unsigned char* srcBuf)
if (pDib == NULL)
return NULL;
outBuf = (unsigned char*) pDib->Create(kWidth, kHeight, 4, 8);
outBuf = (uint8_t*) pDib->Create(kWidth, kHeight, 4, 8);
if (outBuf == NULL) {
delete pDib;
pDib = NULL;

View File

@ -28,8 +28,8 @@ public:
private:
enum { kWidth=88, kHeight=52 };
MyDIBitmap* ConvertBW(const unsigned char* srcBuf);
MyDIBitmap* ConvertColor(const unsigned char* srcBuf);
MyDIBitmap* ConvertBW(const uint8_t* srcBuf);
MyDIBitmap* ConvertColor(const uint8_t* srcBuf);
};
#endif /*REFORMAT_PRINTSHOP_H*/

View File

@ -528,7 +528,7 @@ ReformatHolder::Apply(ReformatPart part, ReformatID id)
/*
* Get the appropriate input buffer.
*/
const unsigned char*
const uint8_t*
ReformatHolder::GetSourceBuf(ReformatPart part) const
{
if (part <= kPartUnknown || part >= kPartMAX) {
@ -563,7 +563,7 @@ ReformatHolder::GetSourceLen(ReformatPart part) const
* discard its pointer.
*/
void
ReformatHolder::SetSourceBuf(ReformatPart part, unsigned char* buf,
ReformatHolder::SetSourceBuf(ReformatPart part, uint8_t* buf,
long len)
{
if (part <= kPartUnknown || part >= kPartMAX) {

View File

@ -263,8 +263,7 @@ public:
void SetErrorMsg(ReformatPart part, const CString& str);
/* give a pointer (allocated with new[]) for one of the inputs */
void SetSourceBuf(ReformatPart part, unsigned char* buf,
long len);
void SetSourceBuf(ReformatPart part, uint8_t* buf, long len);
static const WCHAR* GetReformatName(ReformatID id);
@ -323,7 +322,7 @@ protected:
/* set the "preferred" flag on all non-"not" entries */
void SetApplicPreferred(ReformatID id, ReformatPart part = kPartUnknown);
const unsigned char* GetSourceBuf(ReformatPart part) const;
const uint8_t* GetSourceBuf(ReformatPart part) const;
long GetSourceLen(ReformatPart part) const;
long GetFileType(void) const { return fFileType; }
@ -353,7 +352,7 @@ private:
char* fNameExt; // guaranteed non-NULL
/* input goes here */
unsigned char* fSourceBuf[kPartMAX];
uint8_t* fSourceBuf[kPartMAX];
long fSourceLen[kPartMAX];
char* fErrorBuf[kPartMAX];
@ -457,27 +456,27 @@ public:
// one-time cleanup
static bool AppCleanup(void);
static const char* LookupP8MLI(unsigned char code) {
static const char* LookupP8MLI(uint8_t code) {
return Lookup(fP8MLI, code);
}
static const char* LookupGSOS(unsigned short code) {
static const char* LookupGSOS(uint16_t code) {
return Lookup(fGSOS, code);
}
static const char* LookupToolbox(unsigned short req) {
static const char* LookupToolbox(uint16_t req) {
return Lookup(fSystemTools, req);
}
static const char* LookupE1Vector(unsigned short addr) {
static const char* LookupE1Vector(uint16_t addr) {
return Lookup(fE1Vectors, addr);
}
static const char* LookupE0Vector(unsigned short addr) {
static const char* LookupE0Vector(uint16_t addr) {
return Lookup(fE0Vectors, addr);
}
static const char* Lookup00Addr(unsigned short addr) {
static const char* Lookup00Addr(uint16_t addr) {
//if (addr < 0xc000)
// return NULL; // ignore Davex Bxxx values
return Lookup(f00Addrs, addr);
}
static const char* Lookup01Vector(unsigned short addr) {
static const char* Lookup01Vector(uint16_t addr) {
return Lookup(f01Vectors, addr);
}
@ -490,7 +489,7 @@ private:
*/
typedef struct NameValue {
const char* name;
unsigned short value;
uint16_t value;
} NameValue;
typedef struct DataSet {
long numEntries;
@ -515,10 +514,10 @@ private:
LoadMode mode);
static int ScanLine(const char* pData, long remLen);
static int SortNameValue(const void *, const void *);
static unsigned short ConvHexFour(const char* data);
static uint16_t ConvHexFour(const char* data);
static void DumpSection(const DataSet& dataSet);
static const char* Lookup(const DataSet& dataSet, unsigned short key);
static const char* Lookup(const DataSet& dataSet, uint16_t key);
/* we sit on a copy of the entire file */
static char* fFileData;

View File

@ -26,7 +26,7 @@
*/
const int kUnk = 0x3f; // for unmappable chars, use '?'
/*static*/ const unsigned char ReformatText::kGSCharConv[128] = {
/*static*/ const uint8_t ReformatText::kGSCharConv[128] = {
0xc4, // 0x80 A + umlaut (diaeresis?)
0xc5, // 0x81 A + overcircle
0xc7, // 0x82 C + cedilla
@ -545,7 +545,7 @@ ReformatText::RTFSetFont(RTFFont font)
* Set the font by specifying a IIgs QuickDraw II font family number.
*/
void
ReformatText::RTFSetGSFont(unsigned short family)
ReformatText::RTFSetGSFont(uint16_t family)
{
float newMult;
@ -651,7 +651,7 @@ ReformatText::RTFSetGSFontSize(int points)
* fonts, so we're going to look different in some circumstances.
*/
void
ReformatText::RTFSetGSFontStyle(unsigned char qdStyle)
ReformatText::RTFSetGSFontStyle(uint8_t qdStyle)
{
if (!fUseRTF)
return;
@ -702,7 +702,7 @@ ReformatText::RTFProportionalOff(void) {
* the value is considered.
*/
void
ReformatText::ConvertEOL(const unsigned char* srcBuf, long srcLen,
ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
bool stripHiBits)
{
/* Compatibility - assume we're not stripping nulls */
@ -719,10 +719,10 @@ ReformatText::ConvertEOL(const unsigned char* srcBuf, long srcLen,
* If "stripNulls" is true, no null values will make it through.
*/
void
ReformatText::ConvertEOL(const unsigned char* srcBuf, long srcLen,
ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
bool stripHiBits, bool stripNulls)
{
unsigned char ch;
uint8_t ch;
int mask;
assert(!fUseRTF); // else we have to use RTFPrintChar
@ -761,9 +761,9 @@ ReformatText::ConvertEOL(const unsigned char* srcBuf, long srcLen,
* Write a hex dump into the buffer.
*/
void
ReformatText::BufHexDump(const unsigned char* srcBuf, long srcLen)
ReformatText::BufHexDump(const uint8_t* srcBuf, long srcLen)
{
const unsigned char* origSrcBuf = srcBuf;
const uint8_t* origSrcBuf = srcBuf;
char chBuf[17];
int i, remLen;
@ -923,14 +923,14 @@ ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib)
* Returns 0 on success, nonzero if the buffer is overfilled or underfilled.
*/
int
ReformatGraphics::UnpackBytes(unsigned char* dst, const unsigned char* src,
ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src,
long dstRem, long srcLen)
{
while (srcLen > 0) {
unsigned char flag = *src++;
uint8_t flag = *src++;
int count = (flag & 0x3f) +1;
unsigned char val;
unsigned char valSet[4];
uint8_t val;
uint8_t valSet[4];
int i;
srcLen--;
@ -1048,23 +1048,23 @@ ReformatGraphics::UnpackBytes(unsigned char* dst, const unsigned char* src,
* We have to watch for underruns on the input and overruns on the output.
*/
void
ReformatGraphics::UnPackBits(const unsigned char** pSrcBuf, long* pSrcLen,
unsigned char** pOutPtr, long dstLen, unsigned char xorVal)
ReformatGraphics::UnPackBits(const uint8_t** pSrcBuf, long* pSrcLen,
uint8_t** pOutPtr, long dstLen, uint8_t xorVal)
{
const unsigned char* srcBuf = *pSrcBuf;
const uint8_t* srcBuf = *pSrcBuf;
long length = *pSrcLen;
unsigned char* outPtr = *pOutPtr;
uint8_t* outPtr = *pOutPtr;
int pixByte = 0;
while (pixByte < dstLen && length > 0) {
unsigned char countByte;
uint8_t countByte;
int count;
countByte = *srcBuf++;
length--;
if (countByte & 0x80) {
/* RLE string */
unsigned char ch;
uint8_t ch;
count = (countByte ^ 0xff)+1 +1;
ch = *srcBuf++;
length--;
@ -1073,7 +1073,7 @@ ReformatGraphics::UnPackBits(const unsigned char** pSrcBuf, long* pSrcLen,
pixByte++;
}
} else {
/* series of bytse */
/* series of bytes */
count = countByte +1;
while (count && pixByte < dstLen && length > 0) {
*outPtr++ = *srcBuf++ ^ xorVal;

View File

@ -66,19 +66,19 @@ public:
ReformatOutput* pOutput) = 0;
// grab the next 8 bits
static inline unsigned char Read8(const unsigned char** pBuf, long* pLength) {
static inline uint8_t Read8(const uint8_t** pBuf, long* pLength) {
if (*pLength > 0) {
(*pLength)--;
return *(*pBuf)++;
} else {
// ought to throw an exception here
ASSERT(false);
return (unsigned char) -1;
return (uint8_t) -1;
}
}
// grab a 16-bit little-endian value
static inline unsigned short Read16(const unsigned char** pBuf, long* pLength) {
unsigned short val;
static inline uint16_t Read16(const uint8_t** pBuf, long* pLength) {
uint16_t val;
if (*pLength >= 2) {
val = *(*pBuf)++;
val |= *(*pBuf)++ << 8;
@ -86,13 +86,13 @@ public:
} else {
// ought to throw an exception here
ASSERT(false);
val = (unsigned short) -1;
val = (uint16_t) -1;
}
return val;
}
// grab a 16-bit little-endian value
static inline unsigned long Read32(const unsigned char** pBuf, long* pLength) {
unsigned long val;
// grab a 32-bit little-endian value
static inline uint32_t Read32(const uint8_t** pBuf, long* pLength) {
uint32_t val;
if (*pLength >= 4) {
val = *(*pBuf)++;
val |= *(*pBuf)++ << 8;
@ -102,30 +102,30 @@ public:
} else {
// ought to throw an exception here
ASSERT(false);
val = (unsigned long) -1;
val = (uint32_t) -1;
}
return val;
}
static inline unsigned short Get16LE(const unsigned char* buf) {
static inline uint16_t Get16LE(const uint8_t* buf) {
return *buf | *(buf+1) << 8;
}
static inline unsigned long Get32LE(const unsigned char* buf) {
static inline uint32_t Get32LE(const uint8_t* buf) {
return *buf | *(buf+1) << 8 | *(buf+2) << 16 | *(buf+3) << 24;
}
static inline unsigned short Get16BE(const unsigned char* buf) {
static inline uint16_t Get16BE(const uint8_t* buf) {
return *buf << 8 | *(buf+1);
}
static inline unsigned long Get32BE(const unsigned char* buf) {
static inline uint32_t Get32BE(const uint8_t* buf) {
return *buf << 24 | *(buf+1) << 16 | *(buf+2) << 8 | *(buf+3);
}
static inline unsigned short Get16(const unsigned char* buf, bool littleEndian) {
static inline uint16_t Get16(const uint8_t* buf, bool littleEndian) {
if (littleEndian)
return Get16LE(buf);
else
return Get16BE(buf);
}
static inline unsigned long Get32(const unsigned char* buf, bool littleEndian) {
static inline uint32_t Get32(const uint8_t* buf, bool littleEndian) {
if (littleEndian)
return Get32LE(buf);
else
@ -158,10 +158,10 @@ protected:
kPaletteWhite, kPaletteSize };
RGBQUAD fPalette[kPaletteSize];
int UnpackBytes(unsigned char* dst, const unsigned char* src,
int UnpackBytes(uint8_t* dst, const uint8_t* src,
long dstRem, long srcLen);
void UnPackBits(const unsigned char** pSrcBuf, long* pSrcLen,
unsigned char** pOutPtr, long dstLen, unsigned char xorVal);
void UnPackBits(const uint8_t** pSrcBuf, long* pSrcLen,
uint8_t** pOutPtr, long dstLen, uint8_t xorVal);
private:
void InitPalette();
@ -306,24 +306,24 @@ protected:
void RTFSetColor(TextColor color);
void RTFSetFont(RTFFont font);
void RTFSetFontSize(int points);
void RTFSetGSFont(unsigned short family);
void RTFSetGSFont(uint16_t family);
void RTFSetGSFontSize(int points);
void RTFSetGSFontStyle(unsigned char qdStyle);
void RTFSetGSFontStyle(uint8_t qdStyle);
// void RTFProportionalOn(void);
// void RTFProportionalOff(void);
void ConvertEOL(const unsigned char* srcBuf, long srcLen,
void ConvertEOL(const uint8_t* srcBuf, long srcLen,
bool stripHiBits);
void ConvertEOL(const unsigned char* srcBuf, long srcLen,
void ConvertEOL(const uint8_t* srcBuf, long srcLen,
bool stripHiBits, bool stripNulls);
void BufHexDump(const unsigned char* srcBuf, long srcLen);
void BufHexDump(const uint8_t* srcBuf, long srcLen);
void SetResultBuffer(ReformatOutput* pOutput, bool multiFont = false);
ExpandBuffer fExpBuf;
bool fUseRTF;
// return a low-ASCII character so we can read high-ASCII files
inline char PrintableChar(unsigned char ch) {
inline char PrintableChar(uint8_t ch) {
if (ch < 0x20)
return '.';
else if (ch < 0x7f)
@ -335,13 +335,13 @@ protected:
}
// output an RTF-escaped char (do we want to trap Ctrl-Z?)
// (only use this if we're in RTF mode)
inline void RTFPrintChar(unsigned char ch) {
ch = PrintableChar(ch);
RTFPrintExtChar(ch);
inline void RTFPrintChar(uint8_t ch) {
char pch = PrintableChar(ch);
RTFPrintExtChar(pch);
}
// output an RTF-escaped char, allowing high ASCII
// (only use this if we're in RTF mode)
inline void RTFPrintExtChar(unsigned char ch) {
inline void RTFPrintExtChar(uint8_t ch) {
if (ch == '\\')
fExpBuf.Printf("\\\\");
else if (ch == '{')
@ -352,7 +352,7 @@ protected:
fExpBuf.Printf("%c", ch);
}
// output a char, doubling up double quotes (for .CSV)
inline void BufPrintQChar(unsigned char ch) {
inline void BufPrintQChar(uint8_t ch) {
if (ch == '"')
fExpBuf.Printf("\"\"");
else
@ -360,7 +360,7 @@ protected:
}
// convert IIgs documents
unsigned char ConvertGSChar(unsigned char ch) {
uint8_t ConvertGSChar(uint8_t ch) {
if (ch < 128)
return ch;
else
@ -372,7 +372,7 @@ private:
int CreateWorkBuf(void);
enum { kRTFUnitsPerInch = 1440 }; // TWIPS
static const unsigned char kGSCharConv[];
static const uint8_t kGSCharConv[];
int fLeftMargin, fRightMargin; // for documents, in 1/10th inch
int fPointSize;

View File

@ -71,7 +71,7 @@ ReformatResourceFork::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
fUseRTF = false;
@ -101,7 +101,7 @@ ReformatResourceFork::Process(const ReformatHolder* pHolder,
}
/* move to start of resource map */
const unsigned char* mapPtr;
const uint8_t* mapPtr;
long mapToIndex, mapIndexSize, mapIndexUsed;
mapPtr = srcBuf + rFileToMap;
@ -118,14 +118,14 @@ ReformatResourceFork::Process(const ReformatHolder* pHolder,
BufPrintf(" mapFreeListUsed = %ld\r\n", Get16(mapPtr + 0x1e, littleEndian));
/* dump contents of resource reference records */
const unsigned char* indexPtr;
const uint8_t* indexPtr;
BufPrintf("\r\nResources:");
indexPtr = mapPtr + mapToIndex;
int i;
for (i = 0; i < mapIndexSize; i++) {
unsigned short resType = Get16(indexPtr + 0x00, littleEndian);
uint16_t resType = Get16(indexPtr + 0x00, littleEndian);
if (resType == 0)
break; // should happen when i == mapIndexUsed
@ -167,7 +167,7 @@ done:
* Extract and verify the header of a resource fork.
*/
/*static*/ bool
ReformatResourceFork::ReadHeader(const unsigned char* srcBuf, long srcLen,
ReformatResourceFork::ReadHeader(const uint8_t* srcBuf, long srcLen,
long* pFileVersion, long* pFileToMap, long* pFileMapSize,
bool* pLittleEndian)
{
@ -204,9 +204,9 @@ ReformatResourceFork::ReadHeader(const unsigned char* srcBuf, long srcLen,
* Returns "true" on success, "false" on failure.
*/
/*static*/ bool
ReformatResourceFork::GetResource(const unsigned char* srcBuf, long srcLen,
unsigned short resourceType, unsigned long resourceID,
const unsigned char** pResource, long* pResourceLen)
ReformatResourceFork::GetResource(const uint8_t* srcBuf, long srcLen,
uint16_t resourceType, uint32_t resourceID,
const uint8_t** pResource, long* pResourceLen)
{
/* read the file header */
long rFileVersion, rFileToMap, rFileMapSize;
@ -219,7 +219,7 @@ ReformatResourceFork::GetResource(const unsigned char* srcBuf, long srcLen,
return false;
/* move to start of resource map */
const unsigned char* mapPtr;
const uint8_t* mapPtr;
long mapToIndex, mapIndexSize, mapIndexUsed;
mapPtr = srcBuf + rFileToMap;
@ -228,12 +228,12 @@ ReformatResourceFork::GetResource(const unsigned char* srcBuf, long srcLen,
mapIndexUsed = Get32(mapPtr + 0x18, littleEndian);
/* find the appropriate entry */
const unsigned char* indexPtr = mapPtr + mapToIndex;
const uint8_t* indexPtr = mapPtr + mapToIndex;
int i;
for (i = 0; i < mapIndexSize; i++) {
unsigned short resType;
unsigned long resID;
uint16_t resType;
uint32_t resID;
resType = Get16(indexPtr + 0x00, littleEndian);
if (resType == 0)

View File

@ -24,14 +24,14 @@ public:
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput);
static bool GetResource(const unsigned char* srcBuf, long srcLen,
unsigned short resourceType, unsigned long resourceID,
const unsigned char** pResource, long* pResourceLen);
static bool GetResource(const uint8_t* srcBuf, long srcLen,
uint16_t resourceType, uint32_t resourceID,
const uint8_t** pResource, long* pResourceLen);
private:
enum { kRsrcMapEntryLen = 0x14 };
static bool ReadHeader(const unsigned char* srcBuf, long srcLen,
static bool ReadHeader(const uint8_t* srcBuf, long srcLen,
long* pFileVersion, long* pFileToMap, long* pFileMapSize,
bool* pLittleEndian);
};

View File

@ -65,7 +65,7 @@ ReformatHexDump::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
/*
@ -124,7 +124,7 @@ ReformatEOL_HA::Process(const ReformatHolder* pHolder,
return -1;
//isHighASCII = GenericEntry::CheckHighASCII(
// (const unsigned char*) pHolder->fSourceBuf, pHolder->fSourceLen);
// (const uint8_t*) pHolder->fSourceBuf, pHolder->fSourceLen);
ConvertEOL(pHolder->GetSourceBuf(part), pHolder->GetSourceLen(part), true);

View File

@ -23,6 +23,7 @@
#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <afxwin.h>
#include <afxcmn.h> // for some stuff in util lib

View File

@ -55,14 +55,14 @@ ReformatSHR::SHRScreenToBitmap8(const SHRScreen* pScreen)
}
MyDIBitmap*
ReformatSHR::SHRDataToBitmap8(const unsigned char* pPixels,
const unsigned char* pSCB, const unsigned char* pColorTable,
ReformatSHR::SHRDataToBitmap8(const uint8_t* pPixels,
const uint8_t* pSCB, const uint8_t* pColorTable,
int pixelBytesPerLine, int numScanLines,
int outputWidth, int outputHeight)
{
MyDIBitmap* pDib = new MyDIBitmap;
const unsigned char* pSCBStart = pSCB; // sanity check only
unsigned char* outBuf;
const uint8_t* pSCBStart = pSCB; // sanity check only
uint8_t* outBuf;
int line;
if (pDib == NULL)
@ -72,7 +72,7 @@ ReformatSHR::SHRDataToBitmap8(const unsigned char* pPixels,
* Set up a DIB to hold the data. "Create" returns a pointer to the
* pixel storage.
*/
outBuf = (unsigned char*) pDib->Create(outputWidth, outputHeight, 8,
outBuf = (uint8_t*) pDib->Create(outputWidth, outputHeight, 8,
kNumColorTables * kNumEntriesPerColorTable);
if (outBuf == NULL) {
delete pDib;
@ -83,8 +83,8 @@ ReformatSHR::SHRDataToBitmap8(const unsigned char* pPixels,
/*
* Convert color palette.
*/
const unsigned short* pClrTable;
pClrTable = (const unsigned short*) pColorTable;
const uint16_t* pClrTable;
pClrTable = (const uint16_t*) pColorTable;
int table;
for (table = 0; table < kNumColorTables; table++) {
for (int entry = 0; entry < kNumEntriesPerColorTable; entry++) {
@ -112,9 +112,8 @@ ReformatSHR::SHRDataToBitmap8(const unsigned char* pPixels,
bool mode640, fillMode;
int colorTableOffset;
int byteCount, pixelByte;
unsigned char pixelVal;
// RGBTRIPLE rgbval;
unsigned char colorIndex;
uint8_t pixelVal;
uint8_t colorIndex;
int x = 0;
mode640 = (*pSCB & kSCBNumPixels) != 0;
@ -331,7 +330,7 @@ ReformatJEQSHR::Process(const ReformatHolder* pHolder,
ReformatOutput* pOutput)
{
MyDIBitmap* pDib;
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
int retval = -1;
@ -415,9 +414,9 @@ ReformatPaintworksSHR::Process(const ReformatHolder* pHolder,
const int kPWOutputLines = 396;
const int kPWOutputSize = kPWOutputLines * kPixelBytesPerLine;
const int kPWDataOffset = 0x222;
unsigned char scb[kPWOutputLines];
unsigned char colorTable[kNumEntriesPerColorTable * kColorTableEntrySize];
unsigned char* unpackBuf = NULL;
uint8_t scb[kPWOutputLines];
uint8_t colorTable[kNumEntriesPerColorTable * kColorTableEntrySize];
uint8_t* unpackBuf = NULL;
int retval = -1;
int i, result;
@ -441,7 +440,7 @@ ReformatPaintworksSHR::Process(const ReformatHolder* pHolder,
* than PaintWorks wrote these, because SuperConvert expects them to
* have 396 lines and only recognizes that many.
*/
unpackBuf = new unsigned char[kPWOutputSize];
unpackBuf = new uint8_t[kPWOutputSize];
if (unpackBuf == NULL)
goto bail;
memset(unpackBuf, 0, sizeof(unpackBuf)); // in case we fall short
@ -455,7 +454,7 @@ ReformatPaintworksSHR::Process(const ReformatHolder* pHolder,
#if 0
/* thd282.shk (rev76.2) has a large collection of these */
if (UnpackBytes((unsigned char*) &fScreen,
if (UnpackBytes((uint8_t*) &fScreen,
pHolder->GetSourceBuf(part),
kTotalSize,
pHolder->GetSourceLen(part)) == 0)
@ -532,7 +531,7 @@ ReformatPackedSHR::Process(const ReformatHolder* pHolder,
ASSERT(sizeof(SHRScreen) == kTotalSize);
if (UnpackBytes((unsigned char*) &fScreen,
if (UnpackBytes((uint8_t*) &fScreen,
pHolder->GetSourceBuf(part), kTotalSize,
pHolder->GetSourceLen(part)) != 0)
{
@ -597,9 +596,9 @@ ReformatAPFSHR::Process(const ReformatHolder* pHolder,
ReformatOutput* pOutput)
{
MyDIBitmap* pDib;
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
unsigned char multiPal[kNumLines *
uint8_t multiPal[kNumLines *
kNumEntriesPerColorTable * kColorTableEntrySize];
bool is3200 = false;
bool haveGraphics = false;
@ -614,7 +613,7 @@ ReformatAPFSHR::Process(const ReformatHolder* pHolder,
while (srcLen > 0) {
CString blockName;
const unsigned char* nextBlock;
const uint8_t* nextBlock;
long blockLen, dataLen, nextLen;
int nameLen;
@ -628,7 +627,7 @@ ReformatAPFSHR::Process(const ReformatHolder* pHolder,
nextBlock = srcPtr + (blockLen-4);
nextLen = srcLen - (blockLen-4);
nameLen = ::GetPascalString((const char*)srcPtr, srcLen, &blockName);
nameLen = ::GetPascalString(srcPtr, srcLen, &blockName);
if (nameLen < 0) {
LOGI(" APFSHR failed getting pascal name, bailing");
goto bail;
@ -709,10 +708,10 @@ bail:
* correctly? Can the format be different on every line?
*/
int
ReformatAPFSHR::UnpackMain(const unsigned char* srcPtr, long srcLen)
ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen)
{
const int kColorTableSize = kNumEntriesPerColorTable * kColorTableEntrySize;
unsigned short masterMode;
uint16_t masterMode;
int numColorTables;
int* packedDataLen = NULL;
int retval = -1;
@ -808,13 +807,13 @@ ReformatAPFSHR::UnpackMain(const unsigned char* srcPtr, long srcLen)
* Figure this out someday.
*/
fPixelBytesPerLine = ((fPixelBytesPerLine + 7) / 8) * 8;
fPixelStore = new unsigned char[fPixelBytesPerLine * fNumScanLines];
fPixelStore = new uint8_t[fPixelBytesPerLine * fNumScanLines];
if (fPixelStore == NULL) {
LOGI(" APFSHR ERROR: alloc of %d bytes fPixelStore failed",
fPixelBytesPerLine * fNumScanLines);
goto bail;
}
fSCBStore = new unsigned char[fNumScanLines];
fSCBStore = new uint8_t[fNumScanLines];
if (fSCBStore == NULL) {
LOGI(" APFSHR ERROR: alloc of %d bytes fSCBStore failed",
fNumScanLines);
@ -831,7 +830,7 @@ ReformatAPFSHR::UnpackMain(const unsigned char* srcPtr, long srcLen)
if (packedDataLen == NULL)
goto bail;
for (i = 0; i < fNumScanLines; i++) {
unsigned short mode;
uint16_t mode;
packedDataLen[i] = Read16(&srcPtr, &srcLen);
if (packedDataLen[i] > fPixelsPerScanLine) {
@ -843,7 +842,7 @@ ReformatAPFSHR::UnpackMain(const unsigned char* srcPtr, long srcLen)
mode = Read16(&srcPtr, &srcLen);
if (mode >> 8 == 0)
fSCBStore[i] = (unsigned char)mode;
fSCBStore[i] = (uint8_t) mode;
else {
LOGI(" APFSHR odd mode 0x%04x on line %d", mode, i);
}
@ -883,8 +882,8 @@ bail:
* fix it here, but we can't reliably detect the files.
*/
int
ReformatAPFSHR::UnpackMultipal(unsigned char* dstPtr,
const unsigned char* srcPtr, long srcLen)
ReformatAPFSHR::UnpackMultipal(uint8_t* dstPtr,
const uint8_t* srcPtr, long srcLen)
{
const int kMultipalSize = kNumLines *
kNumEntriesPerColorTable * kColorTableEntrySize;
@ -914,11 +913,11 @@ ReformatAPFSHR::UnpackMultipal(unsigned char* dstPtr,
} else {
#if 0
/* swap entries */
const unsigned short* pSrcTable;
unsigned short* pDstTable = (unsigned short*) dst;
const uint16_t* pSrcTable;
uint16_t* pDstTable = (uint16_t*) dst;
int table, entry;
for (table = 0; table < kNumLines; table++) {
pSrcTable = (const unsigned short*)src +
pSrcTable = (const uint16_t*)src +
(kNumLines - table) * kNumEntriesPerColorTable;
for (entry = 0; entry < kNumEntriesPerColorTable; entry++) {
pDstTable[entry] = *pSrcTable++;
@ -936,7 +935,7 @@ ReformatAPFSHR::UnpackMultipal(unsigned char* dstPtr,
* ASCII data.
*/
void
ReformatAPFSHR::UnpackNote(const unsigned char* srcPtr, long srcLen)
ReformatAPFSHR::UnpackNote(const uint8_t* srcPtr, long srcLen)
{
int numChars;
@ -1021,9 +1020,9 @@ Reformat3200SHR::Process(const ReformatHolder* pHolder,
// sizeof(fExtColorTable));
/* "Brooks" format color tables are stored in reverse order */
const unsigned short* pSrcTable = (const unsigned short*)
const uint16_t* pSrcTable = (const uint16_t*)
(pHolder->GetSourceBuf(part) + sizeof(fScreen.pixels));
unsigned short* pDstTable = (unsigned short*) fExtColorTable;
uint16_t* pDstTable = (uint16_t*) fExtColorTable;
int table;
for (table = 0; table < kExtNumColorTables; table++) {
int entry;
@ -1056,7 +1055,7 @@ Reformat3200SHR::SHR3200ToBitmap24(void)
MyDIBitmap* pDib = new MyDIBitmap;
RGBTRIPLE colorLookup[kExtNumColorTables][kNumEntriesPerColorTable];
RGBTRIPLE* rgbBuf;
const unsigned char* pPixels = fScreen.pixels;
const uint8_t* pPixels = fScreen.pixels;
if (pDib == NULL)
goto bail;
@ -1074,8 +1073,8 @@ Reformat3200SHR::SHR3200ToBitmap24(void)
/*
* Convert color palette data to RGBTRIPLE form.
*/
const unsigned short* pClrTable;
pClrTable = (const unsigned short*) fExtColorTable;
const uint16_t* pClrTable;
pClrTable = (const uint16_t*) fExtColorTable;
int table;
for (table = 0; table < kExtNumColorTables; table++) {
for (int entry = 0; entry < kNumEntriesPerColorTable; entry++) {
@ -1093,7 +1092,7 @@ Reformat3200SHR::SHR3200ToBitmap24(void)
int line;
for (line = 0; line < kNumLines; line++) {
int byteCount, pixelByte;
unsigned char pixelVal;
uint8_t pixelVal;
RGBTRIPLE rgbval;
int x = 0;
@ -1170,10 +1169,10 @@ Reformat3201SHR::Process(const ReformatHolder* pHolder,
ReformatOutput* pOutput)
{
MyDIBitmap* pDib;
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
unsigned char* tmpBuf = NULL;
uint8_t* tmpBuf = NULL;
int retval = -1;
if (srcLen < 16 || srcLen > kExtTotalSize) {
@ -1193,10 +1192,10 @@ Reformat3201SHR::Process(const ReformatHolder* pHolder,
ASSERT(sizeof(fScreen.pixels) + sizeof(fExtColorTable) == kExtTotalSize);
/* "Brooks" format color tables are stored in reverse order */
const unsigned short* pSrcTable;
unsigned short* pDstTable;
pSrcTable = (const unsigned short*) srcBuf;
pDstTable = (unsigned short*) fExtColorTable;
const uint16_t* pSrcTable;
uint16_t* pDstTable;
pSrcTable = (const uint16_t*) srcBuf;
pDstTable = (uint16_t*) fExtColorTable;
int table;
for (table = 0; table < kExtNumColorTables; table++) {
int entry;
@ -1206,7 +1205,7 @@ Reformat3201SHR::Process(const ReformatHolder* pHolder,
pDstTable += kNumEntriesPerColorTable;
}
srcBuf = (const unsigned char*) pSrcTable;
srcBuf = (const uint8_t*) pSrcTable;
length -= srcBuf - (pHolder->GetSourceBuf(part) +4);
/* now unpack the PackBytes-format pixels */

View File

@ -46,10 +46,10 @@ public:
* This holds one SHR screen; the size must be 32768 bytes.
*/
typedef struct SHRScreen {
unsigned char pixels[kNumLines * kPixelBytesPerLine];
unsigned char scb[kNumLines];
unsigned char reserved[256-kNumLines];
unsigned char colorTable[kNumColorTables * kNumEntriesPerColorTable *
uint8_t pixels[kNumLines * kPixelBytesPerLine];
uint8_t scb[kNumLines];
uint8_t reserved[256 - kNumLines];
uint8_t colorTable[kNumColorTables * kNumEntriesPerColorTable *
kColorTableEntrySize];
} SHRScreen;
@ -70,8 +70,8 @@ public:
RGBQUAD fColorTables[kNumColorTables][kNumEntriesPerColorTable];
MyDIBitmap* SHRScreenToBitmap8(const SHRScreen* pScreen);
MyDIBitmap* SHRDataToBitmap8(const unsigned char* pPixels,
const unsigned char* pSCB, const unsigned char* pColorTable,
MyDIBitmap* SHRDataToBitmap8(const uint8_t* pPixels,
const uint8_t* pSCB, const uint8_t* pColorTable,
int pixelBytesPerLine, int numScanLines,
int outputWidth, int outputHeight);
};
@ -172,10 +172,9 @@ public:
ReformatOutput* pOutput);
private:
int UnpackMain(const unsigned char* srcPtr, long srcLen);
int UnpackMultipal(unsigned char* dstPtr,
const unsigned char* srcPtr, long srcLen);
void UnpackNote(const unsigned char* srcPtr, long srcLen);
int UnpackMain(const uint8_t* srcPtr, long srcLen);
int UnpackMultipal(uint8_t* dstPtr, const uint8_t* srcPtr, long srcLen);
void UnpackNote(const uint8_t* srcPtr, long srcLen);
/* use this for standard-sized images */
SHRScreen fScreen;
@ -184,8 +183,8 @@ private:
bool fNonStandard;
/* use this for non-standard-sized images */
unsigned char* fPixelStore;
unsigned char* fSCBStore;
uint8_t* fPixelStore;
uint8_t* fSCBStore;
int fNumScanLines; // #of scan lines in image
int fPixelsPerScanLine;
int fPixelBytesPerLine;
@ -202,7 +201,7 @@ public:
virtual ~Reformat3200SHR(void) {}
// alternate construction, used by APFSHR
Reformat3200SHR(SHRScreen* pScreen, unsigned char* multiPal) {
Reformat3200SHR(SHRScreen* pScreen, uint8_t* multiPal) {
memcpy(&fScreen, pScreen, sizeof(fScreen));
memcpy(fExtColorTable, multiPal, sizeof(fExtColorTable));
}
@ -223,7 +222,7 @@ protected:
SHRScreen fScreen; // only "pixels" is valid
/* this holds the 200 color tables, with the entries switched to normal */
unsigned char fExtColorTable[kExtNumColorTables *
uint8_t fExtColorTable[kExtNumColorTables *
kNumEntriesPerColorTable * kColorTableEntrySize];
};
@ -259,16 +258,16 @@ public:
/*
* Unpack a DreamGrafix SHR image compressed with LZW.
*/
bool UnpackDG(const unsigned char* srcBuf, long srcLen,
ReformatSHR::SHRScreen* pScreen, unsigned char* extColorTable);
bool UnpackDG(const uint8_t* srcBuf, long srcLen,
ReformatSHR::SHRScreen* pScreen, uint8_t* extColorTable);
int fWidth;
int fHeight;
int fNumColors;
private:
static int UnpackLZW(const unsigned char* srcBuf, long srcLen,
unsigned char* dstBuf, long dstLen);
static int UnpackLZW(const uint8_t* srcBuf, long srcLen,
uint8_t* dstBuf, long dstLen);
enum { kHeaderOffset = 17 };
};

View File

@ -45,7 +45,7 @@ ReformatGWP::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcBuf = pHolder->GetSourceBuf(part);
const uint8_t* srcBuf = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
fUseRTF = false;
@ -53,7 +53,7 @@ ReformatGWP::Process(const ReformatHolder* pHolder,
RTFBegin();
/* convert EOL markers and IIgs characters */
unsigned char ch;
uint8_t ch;
while (srcLen) {
ch = *srcBuf++;
srcLen--;
@ -111,10 +111,10 @@ ReformatTeach::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* dataBuf;
const unsigned char* rsrcBuf;
const uint8_t* dataBuf;
const uint8_t* rsrcBuf;
long dataLen, rsrcLen;
const unsigned char* styleBlock;
const uint8_t* styleBlock;
long styleLen;
if (part != ReformatHolder::kPartData)
@ -198,7 +198,7 @@ ReformatTeach::Process(const ReformatHolder* pHolder,
}
/* output the characters */
unsigned char uch;
uint8_t uch;
while (numBytes--) {
if (!dataLen) {
LOGI("WARNING: Teach underrun (%ld wanted)", numBytes);
@ -239,10 +239,10 @@ ReformatTeach::Process(const ReformatHolder* pHolder,
* Unpack an rStyleBlock resource.
*/
bool
RStyleBlock::Create(const unsigned char* buf, long len)
RStyleBlock::Create(const uint8_t* buf, long len)
{
unsigned short version;
unsigned long partLen;
uint16_t version;
uint32_t partLen;
int i;
assert(buf != NULL);
@ -259,7 +259,7 @@ RStyleBlock::Create(const unsigned char* buf, long len)
/* extract ruler(s) */
partLen = Reformat::Read32(&buf, &len);
if (partLen > (unsigned long) (len+8)) {
if (partLen > (uint32_t) (len+8)) {
/* not enough to satisfy data + two more counts */
LOGI("Invalid part1 length (%d vs %d)", partLen, len);
return false;
@ -277,7 +277,7 @@ RStyleBlock::Create(const unsigned char* buf, long len)
/* extract TEStyles */
partLen = Reformat::Read32(&buf, &len);
if (partLen > (unsigned long) (len+4)) {
if (partLen > (uint32_t) (len + 4)) {
LOGI("Invalid part2 length (%d vs %d)", partLen, len);
return false;
}
@ -299,8 +299,8 @@ RStyleBlock::Create(const unsigned char* buf, long len)
/* extract StyleItems */
fNumStyleItems = (int) Reformat::Read32(&buf, &len);
partLen = fNumStyleItems * StyleItem::kDataLen;
if (partLen > (unsigned long) len) {
partLen = fNumStyleItems * StyleItem::kItemDataLen;
if (partLen > (uint32_t) len) {
LOGI("Invalid part3 length (%d vs %d)", partLen, len);
return false;
}
@ -315,8 +315,8 @@ RStyleBlock::Create(const unsigned char* buf, long len)
fpStyleItems[i].GetOffset(), TEStyle::kDataLen);
return false;
}
buf += StyleItem::kDataLen;
len -= StyleItem::kDataLen;
buf += StyleItem::kItemDataLen;
len -= StyleItem::kItemDataLen;
}
if (len != 0) {
@ -333,7 +333,7 @@ RStyleBlock::Create(const unsigned char* buf, long len)
* Returns the #of bytes consumed, or -1 on failure.
*/
int
RStyleBlock::TERuler::Create(const unsigned char* buf, long len)
RStyleBlock::TERuler::Create(const uint8_t* buf, long len)
{
long origLen = len;
@ -396,7 +396,7 @@ RStyleBlock::TERuler::Create(const unsigned char* buf, long len)
* Extract a TEStyle object from the buffer.
*/
void
RStyleBlock::TEStyle::Create(const unsigned char* buf)
RStyleBlock::TEStyle::Create(const uint8_t* buf)
{
fFontID = Reformat::Get32LE(buf);
fForeColor = Reformat::Get16LE(buf + 4);
@ -411,7 +411,7 @@ RStyleBlock::TEStyle::Create(const unsigned char* buf)
* Extract a StyleItem object from the buffer.
*/
void
RStyleBlock::StyleItem::Create(const unsigned char* buf)
RStyleBlock::StyleItem::Create(const uint8_t* buf)
{
fLength = Reformat::Get32LE(buf);
fOffset = Reformat::Get32LE(buf + 4);

View File

@ -59,7 +59,7 @@ public:
}
/* unpack the resource; returns false on failure */
bool Create(const unsigned char* buf, long len);
bool Create(const uint8_t* buf, long len);
/*
* Class representing a IIgs TERuler object.
@ -70,7 +70,7 @@ public:
virtual ~TERuler(void) {}
/* unpack the ruler; returns the #of bytes consumed */
int Create(const unsigned char* buf, long len);
int Create(const uint8_t* buf, long len);
typedef enum Justification {
kJustLeft = 0x0000,
@ -90,20 +90,20 @@ public:
};
typedef struct TabItem {
unsigned short tabKind; // must be $0000
unsigned short tabData; // tab location, in pixels from left
uint16_t tabKind; // must be $0000
uint16_t tabData; // tab location, in pixels from left
} TabItem;
unsigned short fLeftMargin; // pixel indent, except para start
unsigned short fLeftIndent; // pixel indent, for para start
unsigned short fRightMargin; // maximum line len, in pixels
unsigned short fJust; // enum Justification
unsigned short fExtraLS; // extra line spacing, in pixels
unsigned short fFlags; // reserved
unsigned long fUserData;
unsigned short fTabType; // 0=none, 1=interval, 2=irregular
uint16_t fLeftMargin; // pixel indent, except para start
uint16_t fLeftIndent; // pixel indent, for para start
uint16_t fRightMargin; // maximum line len, in pixels
uint16_t fJust; // enum Justification
uint16_t fExtraLS; // extra line spacing, in pixels
uint16_t fFlags; // reserved
uint32_t fUserData;
uint16_t fTabType; // 0=none, 1=interval, 2=irregular
// array of TabItem appears here for fTabType==2
unsigned short fTabTerminator; // present for fTabType==1 or 2
uint16_t fTabTerminator; // present for fTabType==1 or 2
};
/*
@ -115,22 +115,22 @@ public:
virtual ~TEStyle(void) {}
/* unpack the style; returns the #of bytes consumed */
void Create(const unsigned char* buf);
void Create(const uint8_t* buf);
/* Apple IIgs font family number */
unsigned short GetFontFamily(void) const {
return (unsigned short) fFontID;
uint16_t GetFontFamily(void) const {
return (uint16_t) fFontID;
}
/* font size, in points */
int GetFontSize(void) const {
uint8_t GetFontSize(void) const {
return (fFontID >> 24) & 0xff;
}
/* return QDII text style */
unsigned char GetTextStyle(void) const {
return (unsigned char) ((fFontID >> 16) & 0xff);
uint8_t GetTextStyle(void) const {
return (fFontID >> 16) & 0xff;
}
/* return QDII text color */
unsigned short GetTextColor(void) const { return fForeColor; }
uint16_t GetTextColor(void) const { return fForeColor; }
/* individual text style getters */
//bool IsBold(void) const { return (GetTextStyle() & kBold) != 0; }
@ -140,10 +140,11 @@ public:
enum { kDataLen = 12 };
private:
unsigned long fFontID;
unsigned short fForeColor;
unsigned short fBackColor;
unsigned long fUserData;
/* font ID has family, size, and style */
uint32_t fFontID;
uint16_t fForeColor;
uint16_t fBackColor;
uint32_t fUserData;
};
/*
@ -155,23 +156,22 @@ public:
virtual ~StyleItem(void) {}
/* unpack the item */
void Create(const unsigned char* buf);
void Create(const uint8_t* buf);
unsigned long GetLength(void) const { return fLength; }
unsigned long GetOffset(void) const { return fOffset; }
int GetStyleIndex(void) const {
/* MSVC++6.0 won't let me use TEStyle::kDataLen here */
return fOffset / 12;
uint32_t GetLength(void) const { return fLength; }
uint32_t GetOffset(void) const { return fOffset; }
uint32_t GetStyleIndex(void) const {
return fOffset / TEStyle::kDataLen;
}
enum {
kDataLen = 8,
kItemDataLen = 8,
kUnusedItem = 0xffffffff, // in fLength field
};
private:
unsigned long fLength; // #of characters affected by this style
unsigned long fOffset; // offset in bytes into TEStyle list
uint32_t fLength; // #of characters affected by this style
uint32_t fOffset; // offset in bytes into TEStyle list
};
enum {

View File

@ -82,7 +82,7 @@ ReformatMagicWindow::Examine(ReformatHolder* pHolder)
/*static*/ bool
ReformatMagicWindow::IsFormatted(const ReformatHolder* pHolder)
{
const unsigned char* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
int i, count00, count20;
@ -150,7 +150,7 @@ ReformatMagicWindow::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;
@ -205,7 +205,7 @@ ReformatGutenberg::Process(const ReformatHolder* pHolder,
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
ReformatOutput* pOutput)
{
const unsigned char* srcPtr = pHolder->GetSourceBuf(part);
const uint8_t* srcPtr = pHolder->GetSourceBuf(part);
long srcLen = pHolder->GetSourceLen(part);
long length = srcLen;
int retval = -1;

View File

@ -32,7 +32,7 @@ private:
};
/*
* Guterberg Word Processor
* Gutenberg Word Processor
*/
class ReformatGutenberg : public ReformatText {
public:

View File

@ -19,6 +19,7 @@
#include "../app/targetver.h"
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <afxwin.h>

View File

@ -512,7 +512,7 @@ IsWin9x(void)
* Returns the length of the string found, or -1 on error.
*/
int
GetPascalString(const char* buf, long maxLen, CString* pStr)
GetPascalString(const uint8_t* buf, long maxLen, CString* pStr)
{
int len = *buf++;
int retLen = len;

View File

@ -116,7 +116,7 @@ bool IsWin9x(void);
/*
* Miscellaneous functions.
*/
int GetPascalString(const char* buf, long maxLen, CString* pStr);
int GetPascalString(const uint8_t* buf, long maxLen, CString* pStr);
void LogHexDump(const void* buf, long len);
int ComputePercent(LONGLONG part, LONGLONG full);
void FormatDate(time_t when, CString* pStr);