diff --git a/app/ContentList.cpp b/app/ContentList.cpp index b054a8b..ceee904 100644 --- a/app/ContentList.cpp +++ b/app/ContentList.cpp @@ -445,7 +445,7 @@ void ContentList::OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult) { CString modDate; FormatDate(pEntry->GetModWhen(), &modDate); - ::lstrcpy(plvdi->item.pszText, (LPCTSTR) modDate); + ::lstrcpy(plvdi->item.pszText, (LPCWSTR) modDate); } break; case 4: // format diff --git a/app/ExtractOptionsDialog.cpp b/app/ExtractOptionsDialog.cpp index 3661591..5d81921 100644 --- a/app/ExtractOptionsDialog.cpp +++ b/app/ExtractOptionsDialog.cpp @@ -43,7 +43,7 @@ BOOL ExtractOptionsDialog::OnInitDialog(void) pWnd->SetWindowText(countFmt); } else { countFmt.LoadString(IDS_EXT_SELECTED_COUNTS_FMT); - selStr.Format((LPCTSTR) countFmt, fSelectedCount); + selStr.Format((LPCWSTR) countFmt, fSelectedCount); pWnd->SetWindowText(selStr); if (fSelectedCount == 0) diff --git a/app/Registry.cpp b/app/Registry.cpp index 1a34507..1397f2b 100644 --- a/app/Registry.cpp +++ b/app/Registry.cpp @@ -241,7 +241,7 @@ void MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr, iconStr.Format(L"%ls,%d", exeName, iconIdx); if (RegSetValueEx(hIconKey, L"", 0, REG_SZ, - (const BYTE*)(LPCTSTR) iconStr, + (const BYTE*)(LPCWSTR) iconStr, wcslen(iconStr) * sizeof(WCHAR)) == ERROR_SUCCESS) { LOGI(" Set icon for '%ls' to '%ls'", appID, diff --git a/app/Registry.h b/app/Registry.h index db45d41..50a35d3 100644 --- a/app/Registry.h +++ b/app/Registry.h @@ -149,7 +149,7 @@ private: */ int OwnExtension(const WCHAR* ext, const WCHAR* appID) const; - DWORD RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const; + DWORD RegDeleteKeyNT(HKEY hStartKey, LPCWSTR pKeyName) const; /* key validation */ //static uint16_t CalcCRC16(uint16_t seed, diff --git a/app/UseSelectionDialog.cpp b/app/UseSelectionDialog.cpp index 23dc97e..8f0a2cf 100644 --- a/app/UseSelectionDialog.cpp +++ b/app/UseSelectionDialog.cpp @@ -31,7 +31,7 @@ BOOL UseSelectionDialog::OnInitDialog(void) pWnd->SetWindowText(str); } else { str.LoadString(fSelCountsID); - selStr.Format((LPCTSTR) str, fSelectedCount); + selStr.Format((LPCWSTR) str, fSelectedCount); pWnd->SetWindowText(selStr); if (fSelectedCount == 0) diff --git a/mdc/AboutDlg.cpp b/mdc/AboutDlg.cpp index 25d4722..433407d 100644 --- a/mdc/AboutDlg.cpp +++ b/mdc/AboutDlg.cpp @@ -49,7 +49,7 @@ BOOL AboutDlg::OnInitDialog() pWnd->GetWindowText(fmt); newText.Format(fmt, kAppMajorVersion, kAppMinorVersion, kAppBugVersion); pWnd->SetWindowText(newText); - LOGI("STR is '%ls'", (LPCWSTR) newText); + LOGD("STR is '%ls'", (LPCWSTR) newText); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/mdc/ChooseFilesDlg.cpp b/mdc/ChooseFilesDlg.cpp index f5e3ee3..f6d58f7 100644 --- a/mdc/ChooseFilesDlg.cpp +++ b/mdc/ChooseFilesDlg.cpp @@ -10,14 +10,7 @@ #include "ChooseFilesDlg.h" -/* - * Override base class version so we can move our stuff around. - * - * It's important that the base class be called last, because it calls - * Invalidate to redraw the dialog. - */ -void -ChooseFilesDlg::ShiftControls(int deltaX, int deltaY) +void ChooseFilesDlg::ShiftControls(int deltaX, int deltaY) { /* * These only need to be here so that the initial move puts them diff --git a/mdc/ChooseFilesDlg.h b/mdc/ChooseFilesDlg.h index d673804..43f4550 100644 --- a/mdc/ChooseFilesDlg.h +++ b/mdc/ChooseFilesDlg.h @@ -24,14 +24,13 @@ public: virtual ~ChooseFilesDlg(void) {} private: - //virtual bool MyDataExchange(bool saveAndValidate); - virtual void ShiftControls(int deltaX, int deltaY); - //virtual UINT MyOnCommand(WPARAM wParam, LPARAM lParam); - - //void OnIDHelp(void); - - //int GetButtonCheck(int id); - //void SetButtonCheck(int id, int checkVal); + /* + * Override base class version so we can move our stuff around. + * + * It's important that the base class be called last, because it calls + * Invalidate to redraw the dialog. + */ + virtual void ShiftControls(int deltaX, int deltaY) override; //DECLARE_MESSAGE_MAP() }; diff --git a/mdc/Main.cpp b/mdc/Main.cpp index 418115b..138238d 100644 --- a/mdc/Main.cpp +++ b/mdc/Main.cpp @@ -27,10 +27,6 @@ BEGIN_MESSAGE_MAP(MainWindow, CFrameWnd) END_MESSAGE_MAP() -/* - * MainWindow constructor. Creates the main window and sets - * its properties. - */ MainWindow::MainWindow() { static const WCHAR* kAppName = L"MDC"; @@ -61,11 +57,6 @@ MainWindow::MainWindow() fCancelFlag = false; } -/* - * MainWindow destructor. Close the archive if one is open, but don't try - * to shut down any controls in child windows. By this point, Windows has - * already snuffed them. - */ MainWindow::~MainWindow() { // int cc; @@ -75,21 +66,15 @@ MainWindow::~MainWindow() DiskImgLib::Global::AppCleanup(); } -/* - * Handle Exit item by sending a close request. - */ -void -MainWindow::OnFileExit(void) +void MainWindow::OnFileExit(void) { + // Handle Exit item by sending a close request. SendMessage(WM_CLOSE, 0, 0); } -/* - * Go to the faddenSoft web site. - */ -void -MainWindow::OnHelpWebSite(void) +void MainWindow::OnHelpWebSite(void) { + // Go to the faddenSoft web site. int err; err = (int) ::ShellExecute(m_hWnd, L"open", kWebSiteURL, NULL, NULL, @@ -101,11 +86,7 @@ MainWindow::OnHelpWebSite(void) } } -/* - * Pop up the About box. - */ -void -MainWindow::OnHelpAbout(void) +void MainWindow::OnHelpAbout(void) { int result; @@ -116,11 +97,7 @@ MainWindow::OnHelpAbout(void) } -/* - * Handle "scan" item. - */ -void -MainWindow::OnFileScan(void) +void MainWindow::OnFileScan(void) { if (0) { CString msg; @@ -131,19 +108,7 @@ MainWindow::OnFileScan(void) } } -/* - * Allow events to flow through the message queue whenever the - * progress meter gets updated. This will allow us to redraw with - * reasonable frequency. - * - * Calling this can result in other code being called, such as Windows - * message handlers, which can lead to reentrancy problems. Make sure - * you're adequately semaphored before calling here. - * - * Returns TRUE if all is well, FALSE if we're trying to quit. - */ -BOOL -MainWindow::PeekAndPump(void) +BOOL MainWindow::PeekAndPump(void) { MSG msg; @@ -167,9 +132,6 @@ MainWindow::PeekAndPump(void) * ========================================================================== */ -/* - * Handle a debug message from the DiskImg library. - */ /*static*/ void MainWindow::DebugMsgHandler(const char* file, int line, const char* msg) { @@ -179,11 +141,9 @@ MainWindow::DebugMsgHandler(const char* file, int line, const char* msg) LOG_BASE(DebugLog::LOG_INFO, file, line, " %hs", msg); } -/* - * Handle a global error message from the NufxLib library. - */ -/*static*/ NuResult -MainWindow::NufxErrorMsgHandler(NuArchive* /*pArchive*/, void* vErrorMessage) + +/*static*/ NuResult MainWindow::NufxErrorMsgHandler(NuArchive* /*pArchive*/, + void* vErrorMessage) { const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage; @@ -201,11 +161,7 @@ typedef struct ScanOpts { ProgressDlg* pProgress; } ScanOpts; -/* - * Scan a set of files. - */ -void -MainWindow::ScanFiles(void) +void MainWindow::ScanFiles(void) { ChooseFilesDlg chooseFiles; ScanOpts scanOpts; @@ -361,13 +317,7 @@ typedef struct Win32dirent { static const WCHAR kWildMatchAll[] = L"*.*"; -/* - * Prepare a directory for reading. - * - * Allocates a Win32dirent struct that must be freed by the caller. - */ -Win32dirent* -MainWindow::OpenDir(const WCHAR* name) +Win32dirent* MainWindow::OpenDir(const WCHAR* name) { Win32dirent* dir = NULL; WCHAR* tmpStr = NULL; @@ -411,13 +361,7 @@ failed: goto bail; } -/* - * Get an entry from an open directory. - * - * Returns a NULL pointer after the last entry has been read. - */ -Win32dirent* -MainWindow::ReadDir(Win32dirent* dir) +Win32dirent* MainWindow::ReadDir(Win32dirent* dir) { if (dir->d_first) dir->d_first = 0; @@ -433,11 +377,7 @@ MainWindow::ReadDir(Win32dirent* dir) return dir; } -/* - * Close a directory. - */ -void -MainWindow::CloseDir(Win32dirent* dir) +void MainWindow::CloseDir(Win32dirent* dir) { if (dir == NULL) return; @@ -446,14 +386,7 @@ MainWindow::CloseDir(Win32dirent* dir) free(dir); } -/* - * Process a file or directory. These are expected to be names of files in - * the current directory. - * - * Returns 0 on success, nonzero on error with a message in "*pErrMsg". - */ -int -MainWindow::Process(const WCHAR* pathname, ScanOpts* pScanOpts, +int MainWindow::Process(const WCHAR* pathname, ScanOpts* pScanOpts, CString* pErrMsg) { bool exists, isDir, isReadable; @@ -498,13 +431,7 @@ bail: return result; } -/* - * Win32 recursive directory descent. Scan the contents of a directory. - * If a subdirectory is found, follow it; otherwise, call Win32AddFile to - * add the file. - */ -int -MainWindow::ProcessDirectory(const WCHAR* dirName, ScanOpts* pScanOpts, +int MainWindow::ProcessDirectory(const WCHAR* dirName, ScanOpts* pScanOpts, CString* pErrMsg) { Win32dirent* dirp = NULL; @@ -560,14 +487,7 @@ bail: return result; } - -/* - * Open a disk image and dump the contents. - * - * Returns 0 on success, nonzero on failure. - */ -int -MainWindow::ScanDiskImage(const WCHAR* pathName, ScanOpts* pScanOpts) +int MainWindow::ScanDiskImage(const WCHAR* pathName, ScanOpts* pScanOpts) { ASSERT(pathName != NULL); ASSERT(pScanOpts != NULL); @@ -677,11 +597,7 @@ bail: } } -/* - * Analyze a file's characteristics. - */ -void -MainWindow::AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind, +void MainWindow::AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind, LONGLONG* pTotalLen, LONGLONG* pTotalCompLen) { if (pFile->IsVolumeDirectory()) { @@ -710,14 +626,7 @@ MainWindow::AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind, } } -/* - * Determine whether the access bits on the record make it a read-only - * file or not. - * - * Uses a simplified view of the access flags. - */ -bool -MainWindow::IsRecordReadOnly(int access) +bool MainWindow::IsRecordReadOnly(int access) { if (access == 0x21L || access == 0x01L) return true; @@ -761,13 +670,7 @@ static const char gFileTypeNames[256][4] = { "$F8", "OS ", "INT", "IVR", "BAS", "VAR", "REL", "SYS" }; -/* - * Return a pointer to the three-letter representation of the file type name. - * - * Note to self: code down below tests first char for '?'. - */ -/*static*/ const char* -MainWindow::GetFileTypeString(unsigned long fileType) +/*static*/ const char* MainWindow::GetFileTypeString(unsigned long fileType) { if (fileType < NELEM(gFileTypeNames)) return gFileTypeNames[fileType]; @@ -778,9 +681,10 @@ MainWindow::GetFileTypeString(unsigned long fileType) /* * Sanitize a string. The Mac likes to stick control characters into * things, e.g. ^C and ^M, and uses high ASCII for special characters. + * + * TODO: use Mac Roman unicode translation instead */ -static void -MacSanitize(char* str) +static void MacSanitize(char* str) { while (*str != '\0') { *str = DiskImg::MacToASCII(*str); @@ -788,13 +692,7 @@ MacSanitize(char* str) } } -/* - * Load the contents of a DiskFS. - * - * Recursively handle sub-volumes. - */ -int -MainWindow::LoadDiskFSContents(DiskFS* pDiskFS, const char* volName, +int MainWindow::LoadDiskFSContents(DiskFS* pDiskFS, const char* volName, ScanOpts* pScanOpts) { static const char* kBlankFileName = ""; diff --git a/mdc/Main.h b/mdc/Main.h index 6c6fd89..369cbc8 100644 --- a/mdc/Main.h +++ b/mdc/Main.h @@ -31,7 +31,17 @@ typedef enum RecordKind { */ class MainWindow : public CFrameWnd { public: + /* + * MainWindow constructor. Creates the main window and sets + * its properties. + */ MainWindow(void); + + /* + * MainWindow destructor. Close the archive if one is open, but don't try + * to shut down any controls in child windows. By this point, Windows has + * already snuffed them. + */ ~MainWindow(void); private: @@ -40,29 +50,104 @@ private: afx_msg void OnHelpWebSite(void); afx_msg void OnHelpAbout(void); + /* + * Allow events to flow through the message queue whenever the + * progress meter gets updated. This will allow us to redraw with + * reasonable frequency. + * + * Calling this can result in other code being called, such as Windows + * message handlers, which can lead to reentrancy problems. Make sure + * you're adequately semaphored before calling here. + * + * Returns TRUE if all is well, FALSE if we're trying to quit. + */ BOOL PeekAndPump(void); + /* + * Handle a debug message from the DiskImg library. + */ static void DebugMsgHandler(const char* file, int line, const char* msg); static NuResult NufxErrorMsgHandler(NuArchive* /*pArchive*/, void* vErrorMessage); + /* + * Scan a set of files. + */ void ScanFiles(void); + + /* + * Prepare a directory for reading. + * + * Allocates a Win32dirent struct that must be freed by the caller. + */ Win32dirent* OpenDir(const WCHAR* name); + + /* + * Get an entry from an open directory. + * + * Returns a NULL pointer after the last entry has been read. + */ Win32dirent* ReadDir(Win32dirent* dir); + + /* + * Close a directory. + */ void CloseDir(Win32dirent* dir); + + /* + * Process a file or directory. These are expected to be names of files in + * the current directory. + * + * Returns 0 on success, nonzero on error with a message in "*pErrMsg". + */ int Process(const WCHAR* pathname, ScanOpts* pScanOpts, CString* pErrMsg); + + /* + * Win32 recursive directory descent. Scan the contents of a directory. + * If a subdirectory is found, follow it; otherwise, call Win32AddFile to + * add the file. + */ int ProcessDirectory(const WCHAR* dirName, ScanOpts* pScanOpts, CString* pErrMsg); + + /* + * Open a disk image and dump the contents. + * + * Returns 0 on success, nonzero on failure. + */ int ScanDiskImage(const WCHAR* pathName, ScanOpts* pScanOpts); - int LoadDiskFSContents(DiskFS* pDiskFS, const char* volName, - ScanOpts* pScanOpts); + + /* + * Analyze a file's characteristics. + */ void AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind, LONGLONG* pTotalLen, LONGLONG* pTotalCompLen); + + /* + * Determine whether the access bits on the record make it a read-only + * file or not. + * + * Uses a simplified view of the access flags. + */ bool IsRecordReadOnly(int access); + + /* + * Return a pointer to the three-letter representation of the file type name. + * + * Note to self: code down below tests first char for '?'. + */ static const char* GetFileTypeString(unsigned long fileType); + /* + * Load the contents of a DiskFS. + * + * Recursively handle sub-volumes. + */ + int LoadDiskFSContents(DiskFS* pDiskFS, const char* volName, + ScanOpts* pScanOpts); + bool fCancelFlag; //int fTitleAnimation; diff --git a/reformat/AWGS.cpp b/reformat/AWGS.cpp index 489af63..06fdfcb 100644 --- a/reformat/AWGS.cpp +++ b/reformat/AWGS.cpp @@ -12,8 +12,7 @@ /* * Decide whether or not we want to handle this file. */ -void -ReformatAWGS_WP::Examine(ReformatHolder* pHolder) +void ReformatAWGS_WP::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -27,8 +26,7 @@ ReformatAWGS_WP::Examine(ReformatHolder* pHolder) /* * Convert AWGS into formatted text. */ -int -ReformatAWGS_WP::Process(const ReformatHolder* pHolder, +int ReformatAWGS_WP::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -148,8 +146,7 @@ ReformatAWGS_WP::Process(const ReformatHolder* pHolder, /* * Read one of the chunks of the file. */ -bool -ReformatAWGS_WP::ReadChunk(const uint8_t** pSrcBuf, long* pSrcLen, +bool ReformatAWGS_WP::ReadChunk(const uint8_t** pSrcBuf, long* pSrcLen, Chunk* pChunk) { /* starts with the saveArray count */ @@ -205,8 +202,7 @@ ReformatAWGS_WP::ReadChunk(const uint8_t** pSrcBuf, long* pSrcLen, /* * Output a single chunk. We do this by walking down the saveArray. */ -void -ReformatAWGS_WP::PrintChunk(const Chunk* pChunk) +void ReformatAWGS_WP::PrintChunk(const Chunk* pChunk) { const int kDefaultStatusBits = kAWGSJustifyLeft | kAWGSSingleSpace; SaveArrayEntry sae; @@ -291,8 +287,7 @@ 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 uint8_t* -ReformatAWGS_WP::FindTextBlock(const Chunk* pChunk, int blockNum) +const uint8_t* ReformatAWGS_WP::FindTextBlock(const Chunk* pChunk, int blockNum) { const uint8_t* blockPtr = pChunk->textBlocks; uint32_t blockSize; @@ -313,8 +308,7 @@ ReformatAWGS_WP::FindTextBlock(const Chunk* pChunk, int blockNum) * * Returns the #of bytes consumed. */ -int -ReformatAWGS_WP::PrintParagraph(const uint8_t* ptr, long maxLen) +int ReformatAWGS_WP::PrintParagraph(const uint8_t* ptr, long maxLen) { const uint8_t* startPtr = ptr; uint16_t firstFont; @@ -407,8 +401,7 @@ ReformatAWGS_WP::PrintParagraph(const uint8_t* ptr, long maxLen) /* * Run through the SaveArray and find the highest-numbered ruler index. */ -uint16_t -ReformatAWGS_WP::GetNumRulers(const uint8_t* pSaveArray, +uint16_t ReformatAWGS_WP::GetNumRulers(const uint8_t* pSaveArray, uint16_t saveArrayCount) { SaveArrayEntry sa; @@ -438,8 +431,7 @@ ReformatAWGS_WP::GetNumRulers(const uint8_t* pSaveArray, * * These are stored linearly, so we just need to look at the last entry. */ -uint16_t -ReformatAWGS_WP::GetNumTextBlocks(const uint8_t* pSaveArray, +uint16_t ReformatAWGS_WP::GetNumTextBlocks(const uint8_t* pSaveArray, uint16_t saveArrayCount) { SaveArrayEntry sa; @@ -480,8 +472,7 @@ ReformatAWGS_WP::GetNumTextBlocks(const uint8_t* pSaveArray, /* * Unpack a SaveArray entry. */ -void -ReformatAWGS_WP::UnpackSaveArrayEntry(const uint8_t* pSaveArray, +void ReformatAWGS_WP::UnpackSaveArrayEntry(const uint8_t* pSaveArray, SaveArrayEntry* pSAE) { pSAE->textBlock = Get16LE(pSaveArray + 0); @@ -501,8 +492,7 @@ ReformatAWGS_WP::UnpackSaveArrayEntry(const uint8_t* pSaveArray, * * Returns "true" on success, "false" on failure. */ -bool -ReformatAWGS_WP::SkipTextBlocks(const uint8_t** pSrcBuf, +bool ReformatAWGS_WP::SkipTextBlocks(const uint8_t** pSrcBuf, long* pSrcLen, int textBlockCount) { uint32_t blockSize; diff --git a/reformat/AWGS.h b/reformat/AWGS.h index 1bfe8ab..15e10c6 100644 --- a/reformat/AWGS.h +++ b/reformat/AWGS.h @@ -19,10 +19,10 @@ public: ReformatAWGS_WP(void) {} virtual ~ReformatAWGS_WP(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: /* diff --git a/reformat/AppleWorks.cpp b/reformat/AppleWorks.cpp index 552c13e..756ccde 100644 --- a/reformat/AppleWorks.cpp +++ b/reformat/AppleWorks.cpp @@ -29,8 +29,7 @@ /* * Decide whether or not we want to handle this file. */ -void -ReformatAWP::Examine(ReformatHolder* pHolder) +void ReformatAWP::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -44,8 +43,7 @@ ReformatAWP::Examine(ReformatHolder* pHolder) /* * Reformat an AppleWorks WP document. */ -int -ReformatAWP::Process(const ReformatHolder* pHolder, +int ReformatAWP::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -157,8 +155,7 @@ bail: /* * Initialize the DocState structure. */ -void -ReformatAWP::InitDocState(void) +void ReformatAWP::InitDocState(void) { memset(&fDocState, 0, sizeof(fDocState)); fDocState.line = 1; @@ -167,8 +164,7 @@ ReformatAWP::InitDocState(void) /* * Process a line record. */ -int -ReformatAWP::ProcessLineRecord(uint8_t lineRecData, uint8_t lineRecCode, +int ReformatAWP::ProcessLineRecord(uint8_t lineRecData, uint8_t lineRecCode, const uint8_t** pSrcPtr, long* pLength) { int err = 0; @@ -304,8 +300,7 @@ ReformatAWP::ProcessLineRecord(uint8_t lineRecData, uint8_t lineRecCode, * * "lineRecData" has the number of bytes of input that we have yet to read. */ -int -ReformatAWP::HandleTextRecord(uint8_t lineRecData, +int ReformatAWP::HandleTextRecord(uint8_t lineRecData, const uint8_t** pSrcPtr, long* pLength) { int err = 0; @@ -473,8 +468,7 @@ bail: /* * Decide whether or not we want to handle this file. */ -void -ReformatADB::Examine(ReformatHolder* pHolder) +void ReformatADB::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -488,8 +482,7 @@ ReformatADB::Examine(ReformatHolder* pHolder) /* * Reformat an AppleWorks DB document. */ -int -ReformatADB::Process(const ReformatHolder* pHolder, +int ReformatADB::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -731,8 +724,7 @@ bail: /* * Decide whether or not we want to handle this file. */ -void -ReformatASP::Examine(ReformatHolder* pHolder) +void ReformatASP::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -746,8 +738,7 @@ ReformatASP::Examine(ReformatHolder* pHolder) /* * Reformat an AppleWorks SS document. */ -int -ReformatASP::Process(const ReformatHolder* pHolder, +int ReformatASP::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -842,8 +833,7 @@ bail: /* * Process one row of spreadsheet data. */ -int -ReformatASP::ProcessRow(int rowNum, const uint8_t** pSrcPtr, long* pLength) +int ReformatASP::ProcessRow(int rowNum, const uint8_t** pSrcPtr, long* pLength) { uint8_t ctrl; bool first = true; @@ -898,8 +888,7 @@ ReformatASP::ProcessRow(int rowNum, const uint8_t** pSrcPtr, long* pLength) /* * Process the contents of a single cell. */ -void -ReformatASP::ProcessCell(const uint8_t* srcPtr, long cellLength) +void ReformatASP::ProcessCell(const uint8_t* srcPtr, long cellLength) { uint8_t flag1, flag2; double dval; @@ -969,8 +958,7 @@ ReformatASP::ProcessCell(const uint8_t* srcPtr, long cellLength) * Print the AppleWorks SS token pointed to by srcPtr. Some tokens require * several bytes to express. */ -void -ReformatASP::PrintToken(const uint8_t** pSrcPtr, long* pLength) +void ReformatASP::PrintToken(const uint8_t** pSrcPtr, long* pLength) { /* string constants; note these must NOT contain '"' chars */ const int kTokenStart = 0xc0; @@ -1048,8 +1036,7 @@ ReformatASP::PrintToken(const uint8_t** pSrcPtr, long* pLength) * Format the current column number into something like 'A' or 'BA'. This * stores the value in fPrintColBuf and returns a pointer to it. */ -const char* -ReformatASP::PrintCol(int col) +const char* ReformatASP::PrintCol(int col) { if (col < 0 || col >= 702) { LOGI(" ASP can't PrintCol(%d)", col); @@ -1100,8 +1087,7 @@ ReformatASP::PrintCol(int col) * 3F847AE147AE147A * ----- */ -double -ReformatASP::ConvertSANEDouble(const uint8_t* srcPtr) +double ReformatASP::ConvertSANEDouble(const uint8_t* srcPtr) { double newVal; uint8_t* dptr; diff --git a/reformat/AppleWorks.h b/reformat/AppleWorks.h index 67bade0..a596e6e 100644 --- a/reformat/AppleWorks.h +++ b/reformat/AppleWorks.h @@ -19,10 +19,10 @@ public: ReformatAWP(void) { fShowEmbeds = true; } virtual ~ReformatAWP(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: @@ -156,10 +156,10 @@ public: ReformatADB(void) {} virtual ~ReformatADB(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: enum { @@ -179,10 +179,10 @@ public: ReformatASP(void) { fCurrentRow = fCurrentCol = 1; } virtual ~ReformatASP(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: enum { diff --git a/reformat/Asm.cpp b/reformat/Asm.cpp index 86be78a..984f760 100644 --- a/reformat/Asm.cpp +++ b/reformat/Asm.cpp @@ -45,8 +45,7 @@ /* * Decide whether or not we want to handle this file. */ -void -ReformatSCAssem::Examine(ReformatHolder* pHolder) +void ReformatSCAssem::Examine(ReformatHolder* pHolder) { if (pHolder->GetFileType() == kTypeINT && pHolder->GetAuxType() == 0) { if (ReformatSCAssem::IsSCAssem(pHolder)) { @@ -76,8 +75,7 @@ ReformatSCAssem::Examine(ReformatHolder* pHolder) * for marking the end of a line, and have different sets of valid chars. We * don't need to fully validate the file, just test the first line. */ -/*static*/ bool -ReformatSCAssem::IsSCAssem(const ReformatHolder* pHolder) +/*static*/ bool ReformatSCAssem::IsSCAssem(const ReformatHolder* pHolder) { const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData); long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData); @@ -103,8 +101,7 @@ ReformatSCAssem::IsSCAssem(const ReformatHolder* pHolder) * Reformat an S-C Assembler listing into text. I don't know exactly what the * original listings looked like, so I'm just doing what A2FID.C does. */ -int -ReformatSCAssem::Process(const ReformatHolder* pHolder, +int ReformatSCAssem::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -222,8 +219,7 @@ done: * since the text file contents will match. However, it's probably useful * to support DOS ED/ASM sources with this. */ -void -ReformatMerlin::Examine(ReformatHolder* pHolder) +void ReformatMerlin::Examine(ReformatHolder* pHolder) { if (pHolder->GetFileType() == kTypeTXT) { bool isAsm = ReformatMerlin::IsMerlin(pHolder); @@ -271,8 +267,7 @@ ReformatMerlin::Examine(ReformatHolder* pHolder) * * This will also return "true" for DOS ED/ASM files. */ -/*static*/ bool -ReformatMerlin::IsMerlin(const ReformatHolder* pHolder) +/*static*/ bool ReformatMerlin::IsMerlin(const ReformatHolder* pHolder) { const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData); long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData); @@ -329,8 +324,7 @@ ReformatMerlin::IsMerlin(const ReformatHolder* pHolder) * has been "washed" through a converter or if this is actually a DOS ED/ASM * file, tracking quotes is almost always beneficial. */ -int -ReformatMerlin::Process(const ReformatHolder* pHolder, +int ReformatMerlin::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -430,8 +424,7 @@ ReformatMerlin::Process(const ReformatHolder* pHolder, /* * Decide whether or not we want to handle this file. */ -void -ReformatLISA2::Examine(ReformatHolder* pHolder) +void ReformatLISA2::Examine(ReformatHolder* pHolder) { if (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS && pHolder->GetFileType() == kTypeDOS_B) @@ -458,8 +451,7 @@ ReformatLISA2::Examine(ReformatHolder* pHolder) /* * Quick sanity check on the file contents. */ -bool -ReformatLISA2::IsLISA(const ReformatHolder* pHolder) +bool ReformatLISA2::IsLISA(const ReformatHolder* pHolder) { const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData); long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData); @@ -518,8 +510,7 @@ static const char gOpcodes[] = /* * Parse a file. */ -int -ReformatLISA2::Process(const ReformatHolder* pHolder, +int ReformatLISA2::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -579,8 +570,7 @@ bail: return retval; } -void -ReformatLISA2::ProcessLine(const uint8_t* buf) +void ReformatLISA2::ProcessLine(const uint8_t* buf) { int len = *buf; uint8_t uch; @@ -663,7 +653,7 @@ ReformatLISA2::ProcessLine(const uint8_t* buf) /* * =========================================================================== - * LISA Assembler - v4 and v5 + * LISA Assembler - v3 * =========================================================================== */ @@ -747,8 +737,7 @@ static const char gMnemonics3[256*3 +1] = /* * Determine whether this is one of our files. */ -void -ReformatLISA3::Examine(ReformatHolder* pHolder) +void ReformatLISA3::Examine(ReformatHolder* pHolder) { /* * Note we cannot false-positive on an INT file on a DOS disk, because @@ -780,8 +769,7 @@ ReformatLISA3::Examine(ReformatHolder* pHolder) * Decide if this is one of ours or perhaps an Integer BASIC or S-C * assembler source. */ -/*static*/ bool -ReformatLISA3::IsLISA(const ReformatHolder* pHolder) +/*static*/ bool ReformatLISA3::IsLISA(const ReformatHolder* pHolder) { bool dosStructure = (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS); const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData); @@ -817,8 +805,7 @@ ReformatLISA3::IsLISA(const ReformatHolder* pHolder) /* * Parse a file. */ -int -ReformatLISA3::Process(const ReformatHolder* pHolder, +int ReformatLISA3::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -966,8 +953,7 @@ bail: /* * BIGONE */ -void -ReformatLISA3::ProcessLine(const uint8_t* codePtr, int len) +void ReformatLISA3::ProcessLine(const uint8_t* codePtr, int len) { uint8_t mnemonic = 0; @@ -1054,8 +1040,7 @@ bail: /* * CNVOPRND */ -void -ReformatLISA3::ConvertOperand(uint8_t mnemonic, +void ReformatLISA3::ConvertOperand(uint8_t mnemonic, const uint8_t** pCodePtr, int* pLen) { static const char kOPRTRST1[] = "+-*/&|^=<>%<><"; @@ -1163,8 +1148,7 @@ bail: /* * Output a single byte as a binary string. */ -void -ReformatLISA3::PrintBin(uint8_t val) +void ReformatLISA3::PrintBin(uint8_t val) { char buf[9]; buf[8] = '\0'; @@ -1177,9 +1161,8 @@ ReformatLISA3::PrintBin(uint8_t val) /* * OUTNUM */ -ReformatLISA3::OperandResult -ReformatLISA3::PrintNum(int adrsMode, uint8_t val, -const uint8_t** pCodePtr, int* pLen) +ReformatLISA3::OperandResult ReformatLISA3::PrintNum(int adrsMode, uint8_t val, + const uint8_t** pCodePtr, int* pLen) { const uint8_t* codePtr = *pCodePtr; int len = *pLen; @@ -1315,8 +1298,7 @@ bail: * Print symbol table entry. Each entry is an 8-byte label packed into * 6 bytes. */ -void -ReformatLISA3::PrintSymEntry(int ent) +void ReformatLISA3::PrintSymEntry(int ent) { if (ent < 0 || ent >= fSymCount) { Output("!BAD SYM!"); @@ -1349,8 +1331,7 @@ ReformatLISA3::PrintSymEntry(int ent) } } -void -ReformatLISA3::PrintMnemonic(uint8_t val) +void ReformatLISA3::PrintMnemonic(uint8_t val) { const char* ptr = &gMnemonics3[val * 3]; Output(ptr[0]); @@ -1363,8 +1344,7 @@ ReformatLISA3::PrintMnemonic(uint8_t val) * * Prints the comment. Finishes off the operand if necessary. */ -void -ReformatLISA3::PrintComment(int adrsMode, const uint8_t* codePtr, int len) +void ReformatLISA3::PrintComment(int adrsMode, const uint8_t* codePtr, int len) { assert(len >= 0); @@ -1411,8 +1391,7 @@ ReformatLISA3::PrintComment(int adrsMode, const uint8_t* codePtr, int len) /* * Determine whether this is one of our files. */ -void -ReformatLISA4::Examine(ReformatHolder* pHolder) +void ReformatLISA4::Examine(ReformatHolder* pHolder) { /* * Note we cannot false-positive on an INT file on a DOS disk, because @@ -1444,8 +1423,7 @@ ReformatLISA4::Examine(ReformatHolder* pHolder) * Decide if this is one of ours or perhaps an Integer BASIC or S-C * assembler source. */ -/*static*/ bool -ReformatLISA4::IsLISA(const ReformatHolder* pHolder) +/*static*/ bool ReformatLISA4::IsLISA(const ReformatHolder* pHolder) { bool dosStructure = (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS); const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData); @@ -1558,8 +1536,7 @@ static const char* gMnemonics4[] = { /* * Parse a file. */ -int -ReformatLISA4::Process(const ReformatHolder* pHolder, +int ReformatLISA4::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -1585,9 +1562,9 @@ ReformatLISA4::Process(const ReformatHolder* pHolder, fComTab = srcPtr[0x08]; fCpuType = srcPtr[0x09]; - LOGI(" LISA4 version = 0x%04x symEnd=%d symCount=%d", + LOGD(" LISA4 version = 0x%04x symEnd=%d symCount=%d", version, symEnd, fSymCount); - LOGI(" LISA4 opTab=%d adTab=%d comTab=%d cpuType=%d", + LOGD(" LISA4 opTab=%d adTab=%d comTab=%d cpuType=%d", fOpTab, fAdTab, fComTab, fCpuType); if (symEnd > srcLen) { @@ -1731,8 +1708,7 @@ bail: return retval; } -void -ReformatLISA4::ProcessLine(const uint8_t* codePtr, int len) +void ReformatLISA4::ProcessLine(const uint8_t* codePtr, int len) { uint8_t mnemonic = 0; @@ -1835,8 +1811,7 @@ bail: /* * ConvtOperand */ -void -ReformatLISA4::ConvertOperand(uint8_t mnemonic, +void ReformatLISA4::ConvertOperand(uint8_t mnemonic, const uint8_t** pCodePtr, int* pLen) { /* @@ -2095,8 +2070,7 @@ not_operator: /* * CnvrtDec - convert to decimal output. */ -void -ReformatLISA4::PrintDec(int count, const uint8_t** pCodePtr, +void ReformatLISA4::PrintDec(int count, const uint8_t** pCodePtr, int* pLen) { const uint8_t* codePtr = *pCodePtr; @@ -2118,8 +2092,7 @@ ReformatLISA4::PrintDec(int count, const uint8_t** pCodePtr, /* * CnvrtHex - convert to hex output. */ -void -ReformatLISA4::PrintHex(int count, const uint8_t** pCodePtr, +void ReformatLISA4::PrintHex(int count, const uint8_t** pCodePtr, int* pLen) { const uint8_t* codePtr = *pCodePtr; @@ -2142,8 +2115,7 @@ ReformatLISA4::PrintHex(int count, const uint8_t** pCodePtr, /* * CnvrtBin - convert to binary output. */ -void -ReformatLISA4::PrintBin(int count, const uint8_t** pCodePtr, +void ReformatLISA4::PrintBin(int count, const uint8_t** pCodePtr, int* pLen) { const uint8_t* codePtr = *pCodePtr; @@ -2171,9 +2143,8 @@ ReformatLISA4::PrintBin(int count, const uint8_t** pCodePtr, /* * OUTNUM */ -ReformatLISA4::OperandResult -ReformatLISA4::PrintNum(uint8_t opr, const uint8_t** pCodePtr, - int* pLen) +ReformatLISA4::OperandResult ReformatLISA4::PrintNum(uint8_t opr, + const uint8_t** pCodePtr, int* pLen) { OperandResult result = kResultUnknown; const uint8_t* codePtr = *pCodePtr; @@ -2295,9 +2266,8 @@ ReformatLISA4::PrintNum(uint8_t opr, const uint8_t** pCodePtr, /* * OutOprComp */ -ReformatLISA4::OperandResult -ReformatLISA4::PrintComplexOperand(uint8_t opr, -const uint8_t** pCodePtr, int* pLen) +ReformatLISA4::OperandResult ReformatLISA4::PrintComplexOperand(uint8_t opr, + const uint8_t** pCodePtr, int* pLen) { if (opr != kBign_tkn) return PrintNum(opr, pCodePtr, pLen); @@ -2360,8 +2330,7 @@ const uint8_t** pCodePtr, int* pLen) /* * Print symbol table entry. */ -void -ReformatLISA4::PrintSymEntry(int ent) +void ReformatLISA4::PrintSymEntry(int ent) { if (ent < 0 || ent >= fSymCount) { Output("!BAD SYM!"); diff --git a/reformat/Asm.h b/reformat/Asm.h index 0272c83..dc5bb21 100644 --- a/reformat/Asm.h +++ b/reformat/Asm.h @@ -71,10 +71,10 @@ public: ReformatSCAssem(void) {} virtual ~ReformatSCAssem(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; /* this gets called by Integer BASIC converter */ static bool IsSCAssem(const ReformatHolder* pHolder); @@ -89,10 +89,10 @@ public: ReformatMerlin(void) {} virtual ~ReformatMerlin(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: static bool IsMerlin(const ReformatHolder* pHolder); @@ -107,10 +107,10 @@ public: ReformatLISA2(void) {} virtual ~ReformatLISA2(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: bool IsLISA(const ReformatHolder* pHolder); @@ -132,10 +132,10 @@ public: ReformatLISA3(void) : fSymTab(NULL) {} virtual ~ReformatLISA3(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; static bool IsLISA(const ReformatHolder* pHolder); @@ -200,10 +200,10 @@ public: ReformatLISA4(void) : fSymTab(NULL) {} virtual ~ReformatLISA4(void) { delete[] fSymTab; } - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; static bool IsLISA(const ReformatHolder* pHolder); diff --git a/reformat/BASIC.cpp b/reformat/BASIC.cpp index b66322b..edd85fd 100644 --- a/reformat/BASIC.cpp +++ b/reformat/BASIC.cpp @@ -44,8 +44,7 @@ const ReformatText::TextColor kColonColor = ReformatText::kColorRed; /* * Decide whether or not we want to handle this file. */ -void -ReformatApplesoft::Examine(ReformatHolder* pHolder) +void ReformatApplesoft::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -101,8 +100,7 @@ static const char gApplesoftTokens[128 * ReformatApplesoft::kTokenLen] = { * Reformat an Applesoft BASIC program into a text format that mimics the * output of the "LIST" command (with POKE 33,73 to suppress CRs). */ -int -ReformatApplesoft::Process(const ReformatHolder* pHolder, +int ReformatApplesoft::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -306,8 +304,7 @@ static const char* const gIntegerTokens[128] = { /* * Decide whether or not we want to handle this file. */ -void -ReformatInteger::Examine(ReformatHolder* pHolder) +void ReformatInteger::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies apply = ReformatHolder::kApplicNot; if (pHolder->GetFileType() == kTypeINT) { @@ -346,8 +343,7 @@ ReformatInteger::Examine(ReformatHolder* pHolder) * Reformat an Integer BASIC program into a text format that mimics the * output of the "LIST" command. */ -int -ReformatInteger::Process(const ReformatHolder* pHolder, +int ReformatInteger::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -550,8 +546,7 @@ bail: /* * Decide whether or not we want to handle this file. */ -void -ReformatBusiness::Examine(ReformatHolder* pHolder) +void ReformatBusiness::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -574,7 +569,7 @@ ReformatBusiness::Examine(ReformatHolder* pHolder) * show up as error messages. The goal here is to produce values that are * human-readable and/or EXECable, so no attempt has been made to display * the error values. - * TODO: replace this with something accurate -- looks like copy & paste leftover + * TODO: verify this comment -- looks like copy & paste from BAS token table */ static const char gBusinessTokens[128*10] = { /* 0x80 */ "END\0 FOR\0 NEXT\0 INPUT\0 OUTPUT\0 DIM\0 READ\0 WRITE\0 " @@ -618,8 +613,7 @@ static const char gExtendedBusinessTokens[128*10] = { * Reformat an Apple /// Business BASIC program into a text format that * mimics the output of the "LIST" command. */ -int -ReformatBusiness::Process(const ReformatHolder* pHolder, +int ReformatBusiness::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { diff --git a/reformat/BASIC.h b/reformat/BASIC.h index c03b84d..552664f 100644 --- a/reformat/BASIC.h +++ b/reformat/BASIC.h @@ -19,10 +19,10 @@ public: ReformatApplesoft(void) {} virtual ~ReformatApplesoft(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; /* share our token list with others */ // TODO: this is a hack; find a better way to do this @@ -38,10 +38,10 @@ public: ReformatInteger(void) {} virtual ~ReformatInteger(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; /* @@ -52,10 +52,10 @@ public: ReformatBusiness(void) {} virtual ~ReformatBusiness(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; #endif /*REFORMAT_BASIC_H*/ diff --git a/reformat/CPMFiles.cpp b/reformat/CPMFiles.cpp index e122ba2..69b6716 100644 --- a/reformat/CPMFiles.cpp +++ b/reformat/CPMFiles.cpp @@ -58,8 +58,7 @@ static const char gIsBinary[256] = { * End-of-file is at the first Ctrl-Z, but we can't stop there because it * could be a binary file with a leading Ctrl-Z (e.g. PNG). */ -void -ReformatCPMText::Examine(ReformatHolder* pHolder) +void ReformatCPMText::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData); @@ -118,8 +117,7 @@ done: * Generally speaking, CP/M text files should already be in CRLF format, so * this will go quickly. */ -int -ReformatCPMText::Process(const ReformatHolder* pHolder, +int ReformatCPMText::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { diff --git a/reformat/CPMFiles.h b/reformat/CPMFiles.h index a8b2112..da2dd5d 100644 --- a/reformat/CPMFiles.h +++ b/reformat/CPMFiles.h @@ -19,10 +19,10 @@ public: ReformatCPMText(void) {} virtual ~ReformatCPMText(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; #endif /*REFORMAT_CPMFILES_H*/ diff --git a/reformat/Directory.cpp b/reformat/Directory.cpp index 0860546..b98e8b6 100644 --- a/reformat/Directory.cpp +++ b/reformat/Directory.cpp @@ -16,8 +16,7 @@ using namespace DiskImgLib; /* * Decide whether or not we want to handle this file. */ -void -ReformatDirectory::Examine(ReformatHolder* pHolder) +void ReformatDirectory::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -33,8 +32,7 @@ ReformatDirectory::Examine(ReformatHolder* pHolder) * Convert a ProDOS directory into a format resembling BASIC.System's * 80-column "catalog" command. */ -int -ReformatDirectory::Process(const ReformatHolder* pHolder, +int ReformatDirectory::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -70,8 +68,7 @@ ReformatDirectory::Process(const ReformatHolder* pHolder, * The "showDeleted" flag determines whether we show active entries or * deleted entries. */ -void -ReformatDirectory::PrintDirEntries(const uint8_t* srcBuf, +void ReformatDirectory::PrintDirEntries(const uint8_t* srcBuf, long srcLen, bool showDeleted) { const int kEntriesPerBlock = 0x0d; // expected value for entries per blk diff --git a/reformat/Directory.h b/reformat/Directory.h index 61e7f88..c576887 100644 --- a/reformat/Directory.h +++ b/reformat/Directory.h @@ -19,10 +19,10 @@ public: ReformatDirectory(void) {} virtual ~ReformatDirectory(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: void PrintDirEntries(const uint8_t* srcBuf, diff --git a/reformat/Disasm.cpp b/reformat/Disasm.cpp index 5d305f8..c04e066 100644 --- a/reformat/Disasm.cpp +++ b/reformat/Disasm.cpp @@ -42,8 +42,7 @@ * Width is always > 0. This guarantees that we don't loop forever even if * we hit stuff we don't recognize. */ -int -ReformatDisasm65xxx::GetOpWidth(OpCode opCode, AddrMode addrMode, CPU cpu, +int ReformatDisasm65xxx::GetOpWidth(OpCode opCode, AddrMode addrMode, CPU cpu, bool emul, bool shortM, bool shortX) { int width = 0; @@ -148,8 +147,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 uint8_t* srcBuf, long srcLen) +bool ReformatDisasm65xxx::IsP8Call(const uint8_t* srcBuf, long srcLen) { if (srcLen >= 6 && srcBuf[0] == 0x20 && srcBuf[1] == 0x00 && srcBuf[2] == 0xbf) @@ -162,8 +160,7 @@ ReformatDisasm65xxx::IsP8Call(const uint8_t* srcBuf, long srcLen) /* * Returns "true" if it looks like we're pointing at a IIgs toolbox call. */ -bool -ReformatDisasm65xxx::IsToolboxCall(const uint8_t* srcBuf, long srcLen, +bool ReformatDisasm65xxx::IsToolboxCall(const uint8_t* srcBuf, long srcLen, long backState) { if (srcLen >= 4 && backState >= 3 && @@ -178,8 +175,7 @@ ReformatDisasm65xxx::IsToolboxCall(const uint8_t* srcBuf, long srcLen, /* * Returns "true" if it looks like we're pointing at an inline GS/OS call. */ -bool -ReformatDisasm65xxx::IsInlineGSOS(const uint8_t* srcBuf, long srcLen) +bool ReformatDisasm65xxx::IsInlineGSOS(const uint8_t* srcBuf, long srcLen) { if (srcLen >= 10 && srcBuf[0] == 0x22 && srcBuf[1] == 0xa8 && srcBuf[2] == 0x00 && @@ -193,8 +189,7 @@ ReformatDisasm65xxx::IsInlineGSOS(const uint8_t* srcBuf, long srcLen) /* * Returns "true" if it looks like we're pointing at a stack GS/OS call. */ -bool -ReformatDisasm65xxx::IsStackGSOS(const uint8_t* srcBuf, long srcLen, +bool ReformatDisasm65xxx::IsStackGSOS(const uint8_t* srcBuf, long srcLen, long backState) { if (srcLen >= 4 && backState >= 3 && @@ -213,8 +208,7 @@ ReformatDisasm65xxx::IsStackGSOS(const uint8_t* srcBuf, long srcLen, * * Returns the number of bytes consumed. */ -int -ReformatDisasm65xxx::OutputMonitor8(const uint8_t* srcBuf, long srcLen, +int ReformatDisasm65xxx::OutputMonitor8(const uint8_t* srcBuf, long srcLen, long backState, uint16_t addr) { const CPU kCPU = kCPU65C02; // 6502 or 65C02 @@ -265,10 +259,8 @@ ReformatDisasm65xxx::OutputMonitor8(const uint8_t* srcBuf, long srcLen, /* * Output one line of 8-bit monitor stuff. */ -void -ReformatDisasm65xxx::PrintMonitor8Line(OpCode opCode, AddrMode addrMode, - uint16_t addr, const uint8_t* srcBuf, long srcLen, - const char* comment) +void ReformatDisasm65xxx::PrintMonitor8Line(OpCode opCode, AddrMode addrMode, + 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; @@ -393,15 +385,13 @@ ReformatDisasm65xxx::PrintMonitor8Line(OpCode opCode, AddrMode addrMode, RTFNewPara(); } - /* * Output one or more lines of text similar to what the monitor would output * on an 8-bit Apple II. * * Returns the number of bytes consumed. */ -int -ReformatDisasm65xxx::OutputMonitor16(const uint8_t* srcBuf, long srcLen, +int ReformatDisasm65xxx::OutputMonitor16(const uint8_t* srcBuf, long srcLen, long backState, uint32_t addr, bool shortRegs) { const CPU kCPU = kCPU65816; @@ -472,10 +462,8 @@ ReformatDisasm65xxx::OutputMonitor16(const uint8_t* srcBuf, long srcLen, /* * Output one line of 16-bit monitor stuff. */ -void -ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode, - uint32_t addr, const uint8_t* srcBuf, long srcLen, - const char* comment) +void ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode, + 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; @@ -671,8 +659,7 @@ ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode, * file is code or, say, a hi-res graphic. We use "maybe" level to put * disassembly below other formats. */ -void -ReformatDisasm8::Examine(ReformatHolder* pHolder) +void ReformatDisasm8::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; int fileType = pHolder->GetFileType(); @@ -703,8 +690,7 @@ ReformatDisasm8::Examine(ReformatHolder* pHolder) /* * Create a monitor listing or disassembly of a file. */ -int -ReformatDisasm8::Process(const ReformatHolder* pHolder, +int ReformatDisasm8::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -757,8 +743,7 @@ ReformatDisasm8::Process(const ReformatHolder* pHolder, * want to keep 16-bit disassembly available but prioritized below "raw" for * BIN files. */ -void -ReformatDisasm16::Examine(ReformatHolder* pHolder) +void ReformatDisasm16::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -812,8 +797,7 @@ ReformatDisasm16::Examine(ReformatHolder* pHolder) /* * Disassemble or show monitor listing for 16-bit code. */ -int -ReformatDisasm16::Process(const ReformatHolder* pHolder, +int ReformatDisasm16::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -861,8 +845,7 @@ ReformatDisasm16::Process(const ReformatHolder* pHolder, /* * Output one section of a file. */ -void -ReformatDisasm16::OutputSection(const uint8_t* srcBuf, long srcLen, +void ReformatDisasm16::OutputSection(const uint8_t* srcBuf, long srcLen, uint32_t addr, bool shortRegs) { long backState = 0; @@ -882,8 +865,7 @@ ReformatDisasm16::OutputSection(const uint8_t* srcBuf, long srcLen, /* * Break an OMF file into sections, and output each individually. */ -bool -ReformatDisasm16::OutputOMF(const uint8_t* srcBuf, long srcLen, +bool ReformatDisasm16::OutputOMF(const uint8_t* srcBuf, long srcLen, long fileType, bool shortRegs) { const uint8_t* origBuf = srcBuf; @@ -948,8 +930,7 @@ ReformatDisasm16::OutputOMF(const uint8_t* srcBuf, long srcLen, /* * Print the interesting bits of the header. */ -void -ReformatDisasm16::PrintHeader(const OMFSegmentHeader* pSegHdr, +void ReformatDisasm16::PrintHeader(const OMFSegmentHeader* pSegHdr, int segmentNumber, bool longFmt) { //pSegHdr->Dump(); @@ -1004,8 +985,7 @@ ReformatDisasm16::PrintHeader(const OMFSegmentHeader* pSegHdr, /* * Print the contents of the segment. */ -void -ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr, +void ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr, const uint8_t* srcBuf, long srcLen, bool shortRegs) { uint32_t subLen; @@ -1065,9 +1045,7 @@ ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr, * * Returns "true" on success, "false" on failure. */ -bool -OMFSegmentHeader::Unpack(const uint8_t* srcBuf, long srcLen, - int fileType) +bool OMFSegmentHeader::Unpack(const uint8_t* srcBuf, long srcLen, int fileType) { if (srcLen < kHdrMinSize) { LOGI("OMF: Too short to be segment (%ld)", srcLen); @@ -1238,8 +1216,7 @@ OMFSegmentHeader::Unpack(const uint8_t* srcBuf, long srcLen, /* * Pry the segment type out of the "type" or "kind" field. */ -OMFSegmentHeader::SegmentType -OMFSegmentHeader::GetSegmentType(void) const +OMFSegmentHeader::SegmentType OMFSegmentHeader::GetSegmentType(void) const { assert(fReady); @@ -1252,8 +1229,7 @@ OMFSegmentHeader::GetSegmentType(void) const /* * Return the value of one of the segment header flags. */ -bool -OMFSegmentHeader::GetSegmentFlag(SegmentFlag flag) const +bool OMFSegmentHeader::GetSegmentFlag(SegmentFlag flag) const { if (fVersion < 2) { switch (flag) { @@ -1291,12 +1267,10 @@ OMFSegmentHeader::GetSegmentFlag(SegmentFlag flag) const } } - /* * Dump the contents of the segment header struct. */ -void -OMFSegmentHeader::Dump(void) const +void OMFSegmentHeader::Dump(void) const { LOGI("OMF segment header:"); LOGI(" segNum=%d loadName='%hs' segName='%hs'", diff --git a/reformat/Disasm.h b/reformat/Disasm.h index 8522418..eda5aae 100644 --- a/reformat/Disasm.h +++ b/reformat/Disasm.h @@ -202,10 +202,10 @@ public: ReformatDisasm8(void) {} virtual ~ReformatDisasm8(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; /* @@ -434,10 +434,10 @@ public: ReformatDisasm16(void) {} virtual ~ReformatDisasm16(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: void OutputSection(const uint8_t* srcBuf, long srcLen, diff --git a/reformat/DisasmTable.cpp b/reformat/DisasmTable.cpp index 2ae4442..e2e6c88 100644 --- a/reformat/DisasmTable.cpp +++ b/reformat/DisasmTable.cpp @@ -598,8 +598,7 @@ const int kOpXCE_Implied = OPMODE(kOpXCE, kAddrImplied); // 0 * * Returns "true" on success, "false" on failure. */ -bool -ReformatDisasm65xxx::ValidateOpMap(void) +bool ReformatDisasm65xxx::ValidateOpMap(void) { if (NELEM(kOpMap) != 256) { ASSERT(false); @@ -754,8 +753,7 @@ ReformatDisasm65xxx::ValidateOpMap(void) * * Returns "true" on success, "false" on failure. */ -bool -ReformatDisasm65xxx::ValidateOpCodeDetails(void) +bool ReformatDisasm65xxx::ValidateOpCodeDetails(void) { if (NELEM(kOpCodeDetails) != kOpCodeMAX) { LOGI("Found %d entries in details, max=%d", diff --git a/reformat/DoubleHiRes.cpp b/reformat/DoubleHiRes.cpp index db47e5b..5a1ad2b 100644 --- a/reformat/DoubleHiRes.cpp +++ b/reformat/DoubleHiRes.cpp @@ -26,8 +26,7 @@ /* * Decide whether or not we want to handle this file. */ -void -ReformatDHR::Examine(ReformatHolder* pHolder) +void ReformatDHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileLen = pHolder->GetSourceLen(ReformatHolder::kPartData); @@ -86,8 +85,7 @@ ReformatDHR::Examine(ReformatHolder* pHolder) /* * Convert a Double-Hi-Res image to a bitmap. */ -int -ReformatDHR::Process(const ReformatHolder* pHolder, +int ReformatDHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -139,8 +137,7 @@ bail: /* * Initialize the 4-bit-window color lookup table. */ -void -ReformatDHR::InitColorLookup(void) +void ReformatDHR::InitColorLookup(void) { for (int ii = 0; ii < 4; ii++) { for (int jj = 0; jj < kNumDHRColors; jj++) { @@ -161,8 +158,7 @@ ReformatDHR::InitColorLookup(void) /* * Convert a buffer of double-hires data to a 16-color DIB. */ -MyDIBitmap* -ReformatDHR::DHRScreenToBitmap(const uint8_t* buf) +MyDIBitmap* ReformatDHR::DHRScreenToBitmap(const uint8_t* buf) { MyDIBitmap* pDib = new MyDIBitmap; uint8_t* outBuf; diff --git a/reformat/DoubleHiRes.h b/reformat/DoubleHiRes.h index c53091a..a33e52b 100644 --- a/reformat/DoubleHiRes.h +++ b/reformat/DoubleHiRes.h @@ -19,10 +19,10 @@ public: ReformatDHR(void) {} virtual ~ReformatDHR(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; enum { kPixelsPerLine = 560, diff --git a/reformat/DreamGrafix.cpp b/reformat/DreamGrafix.cpp index 0f142e9..4337171 100644 --- a/reformat/DreamGrafix.cpp +++ b/reformat/DreamGrafix.cpp @@ -21,8 +21,7 @@ /* * Decide whether or not we want to handle this file. */ -void -ReformatDG256SHR::Examine(ReformatHolder* pHolder) +void ReformatDG256SHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -36,8 +35,7 @@ ReformatDG256SHR::Examine(ReformatHolder* pHolder) /* * Convert a 256-color DreamGrafix Super Hi-Res Image. */ -int -ReformatDG256SHR::Process(const ReformatHolder* pHolder, +int ReformatDG256SHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -66,8 +64,7 @@ ReformatDG256SHR::Process(const ReformatHolder* pHolder, /* * Decide whether or not we want to handle this file. */ -void -ReformatDG3200SHR::Examine(ReformatHolder* pHolder) +void ReformatDG3200SHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -81,8 +78,7 @@ ReformatDG3200SHR::Examine(ReformatHolder* pHolder) /* * Convert a 3200-color DreamGrafix Super Hi-Res Image. */ -int -ReformatDG3200SHR::Process(const ReformatHolder* pHolder, +int ReformatDG3200SHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -102,8 +98,6 @@ ReformatDG3200SHR::Process(const ReformatHolder* pHolder, } - - /* * ========================================================================== * ReformatDreamGrafix @@ -114,8 +108,7 @@ ReformatDG3200SHR::Process(const ReformatHolder* pHolder, * Examine a DreamGrafix file. This figures out if its any of the * DreamGrafix formats, i.e. 256-color, 3200-color, packed, or unpacked. */ -bool -DreamGrafix::ScanDreamGrafix(ReformatHolder* pHolder) +bool DreamGrafix::ScanDreamGrafix(ReformatHolder* pHolder) { long fileType = pHolder->GetFileType(); long auxType = pHolder->GetAuxType(); @@ -163,8 +156,7 @@ DreamGrafix::ScanDreamGrafix(ReformatHolder* pHolder) * Returns true on success, false if the uncompress step failed to produce * exactly 32768+32*200 bytes. */ -bool -DreamGrafix::UnpackDG(const uint8_t* srcBuf, long srcLen, +bool DreamGrafix::UnpackDG(const uint8_t* srcBuf, long srcLen, ReformatSHR::SHRScreen* pScreen, uint8_t* extColorTable) { int expectedLen; @@ -195,7 +187,7 @@ ReformatSHR::SHRScreen* pScreen, uint8_t* extColorTable) actual = UnpackLZW(srcBuf, srcLen, tmpBuf, expectedLen); if (actual != expectedLen && actual != (expectedLen-512)) { - LOGI("UnpackLZW expected %d, got %d", expectedLen, actual); + LOGW("UnpackLZW expected %d, got %d", expectedLen, actual); delete[] tmpBuf; return false; } @@ -266,8 +258,7 @@ static const unsigned int bitMasks[] = { bitOffset += nBitMod1; \ }; -/*static*/ int -DreamGrafix::UnpackLZW(const uint8_t* srcBuf, long srcLen, +/*static*/ int DreamGrafix::UnpackLZW(const uint8_t* srcBuf, long srcLen, uint8_t* dstBuf, long dstLen) { uint16_t finChar, oldCode, inCode, freeCode, maxCode, k; diff --git a/reformat/HiRes.cpp b/reformat/HiRes.cpp index 0075e09..77a0f8c 100644 --- a/reformat/HiRes.cpp +++ b/reformat/HiRes.cpp @@ -174,8 +174,7 @@ The Apple values seem to be good. * $4001 is a compressed DHR image. In practice, nobody uses these, so * any FOT file with a correct-looking length is treated as hi-res. */ -void -ReformatHiRes::Examine(ReformatHolder* pHolder) +void ReformatHiRes::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileLen = pHolder->GetSourceLen(ReformatHolder::kPartData); @@ -222,8 +221,7 @@ ReformatHiRes::Examine(ReformatHolder* pHolder) /* * Convert a Hi-Res image to a bitmap. */ -int -ReformatHiRes::Process(const ReformatHolder* pHolder, +int ReformatHiRes::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -259,8 +257,7 @@ bail: * * Table must be able to hold kNumLines values. */ -/*static*/ void -ReformatHiRes::InitLineOffset(int* pOffsetBuf) +/*static*/ void ReformatHiRes::InitLineOffset(int* pOffsetBuf) { long offset; int line; @@ -275,12 +272,10 @@ ReformatHiRes::InitLineOffset(int* pOffsetBuf) } } - /* * Convert a buffer of hires data to a 16-color DIB. */ -MyDIBitmap* -ReformatHiRes::HiResScreenToBitmap(const uint8_t* buf) +MyDIBitmap* ReformatHiRes::HiResScreenToBitmap(const uint8_t* buf) { MyDIBitmap* pDib = new MyDIBitmap; uint8_t* outBuf; diff --git a/reformat/HiRes.h b/reformat/HiRes.h index 718cf6e..30dccc1 100644 --- a/reformat/HiRes.h +++ b/reformat/HiRes.h @@ -19,10 +19,10 @@ public: ReformatHiRes(void) { fBlackWhite = false; } virtual ~ReformatHiRes(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; enum { kPixelsPerLine = 280, diff --git a/reformat/MacPaint.cpp b/reformat/MacPaint.cpp index 127b2b2..d4e3586 100644 --- a/reformat/MacPaint.cpp +++ b/reformat/MacPaint.cpp @@ -39,8 +39,7 @@ * If the file ends in ".mac", we accept it if it has a MacBinary header or * if it begins with 00000002 and exceeds the minimum size required. */ -void -ReformatMacPaint::Examine(ReformatHolder* pHolder) +void ReformatMacPaint::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData); @@ -78,8 +77,7 @@ done: /* * Convert the image to a monochrome bitmap. */ -int -ReformatMacPaint::Process(const ReformatHolder* pHolder, +int ReformatMacPaint::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -110,8 +108,7 @@ bail: * 576 pixels per line == 72 bytes per line, which is a multiple of 4 bytes * (required for windows BMP). */ -MyDIBitmap* -ReformatMacPaint::ConvertMacPaint(const uint8_t* srcBuf, long length) +MyDIBitmap* ReformatMacPaint::ConvertMacPaint(const uint8_t* srcBuf, long length) { MyDIBitmap* pDib = NULL; uint8_t* outBuf; diff --git a/reformat/MacPaint.h b/reformat/MacPaint.h index 5919106..97ef873 100644 --- a/reformat/MacPaint.h +++ b/reformat/MacPaint.h @@ -19,10 +19,10 @@ public: ReformatMacPaint(void) {} virtual ~ReformatMacPaint(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: MyDIBitmap* ConvertMacPaint(const uint8_t* srcBuf, long length); diff --git a/reformat/NiftyList.cpp b/reformat/NiftyList.cpp index 8267a0a..0a2e24c 100644 --- a/reformat/NiftyList.cpp +++ b/reformat/NiftyList.cpp @@ -50,8 +50,7 @@ /* * Load the NiftyList data file. */ -/*static*/ bool -NiftyList::AppInit(const WCHAR* fileName) +/*static*/ bool NiftyList::AppInit(const WCHAR* fileName) { FILE* fp = NULL; long fileLen; @@ -124,8 +123,7 @@ bail: /* * Discard all allocated storage. */ -/*static*/ bool -NiftyList::AppCleanup(void) +/*static*/ bool NiftyList::AppCleanup(void) { delete[] fP8MLI.pEntries; delete[] fGSOS.pEntries; @@ -148,9 +146,8 @@ NiftyList::AppCleanup(void) * Leaves "*ppData" pointing at the start of the next section. "*pRemLen" * is updated appropriately. */ -/*static*/ bool -NiftyList::ReadSection(char** ppData, long* pRemLen, DataSet* pSet, - LoadMode mode) +/*static*/ bool NiftyList::ReadSection(char** ppData, long* pRemLen, + DataSet* pSet, LoadMode mode) { assert(ppData != NULL); assert(pRemLen != NULL); @@ -265,8 +262,7 @@ NiftyList::ReadSection(char** ppData, long* pRemLen, DataSet* pSet, * Returns 0 if there's no data, which can only happen if "remLen" is zero * (i.e. we hit EOF). */ -/*static*/ int -NiftyList::ScanLine(const char* pData, long remLen) +/*static*/ int NiftyList::ScanLine(const char* pData, long remLen) { bool atEOL = false; int lineLen = 0; @@ -286,8 +282,7 @@ NiftyList::ScanLine(const char* pData, long remLen) /* * qsort() sort function. */ -/*static*/ int -NiftyList::SortNameValue(const void* v1, const void* v2) +/*static*/ int NiftyList::SortNameValue(const void* v1, const void* v2) { const NameValue* pnv1 = (const NameValue*) v1; const NameValue* pnv2 = (const NameValue*) v2; @@ -305,8 +300,7 @@ NiftyList::SortNameValue(const void* v1, const void* v2) /* * Hex digit converter. */ -static inline int -HexValue(char ch) +static inline int HexValue(char ch) { if (ch >= '0' && ch <= '9') return ch - '0'; @@ -321,8 +315,7 @@ HexValue(char ch) /* * Convert a 4-char hexadecimal value to an unsigned 16-bit value. */ -/*static*/ uint16_t -NiftyList::ConvHexFour(const char* data) +/*static*/ uint16_t NiftyList::ConvHexFour(const char* data) { return HexValue(data[0]) << 12 | HexValue(data[1]) << 8 | @@ -333,8 +326,7 @@ NiftyList::ConvHexFour(const char* data) /* * Dump the contents of a section. */ -/*static*/ void -NiftyList::DumpSection(const DataSet& dataSet) +/*static*/ void NiftyList::DumpSection(const DataSet& dataSet) { long ent; @@ -346,15 +338,13 @@ NiftyList::DumpSection(const DataSet& dataSet) } } - /* * Look up a value in the specified table. Returns the name, or NULL if * not found. * * This uses a binary search, so the entries must be in sorted order. */ -/*static*/ const char* -NiftyList::Lookup(const DataSet& dataSet, uint16_t key) +/*static*/ const char* NiftyList::Lookup(const DataSet& dataSet, uint16_t key) { if (!fDataReady) { return NULL; diff --git a/reformat/PascalFiles.cpp b/reformat/PascalFiles.cpp index 1126c49..7f99c4f 100644 --- a/reformat/PascalFiles.cpp +++ b/reformat/PascalFiles.cpp @@ -4,7 +4,9 @@ * See the file LICENSE for distribution terms. */ /* - * Process UCSD Pascal text and code files. + * Process UCSD Pascal text and code files. Files with this format, but + * usually containing 6502 assembly rather than p-code, can appear on + * Apple /// SOS disks. */ #include "StdAfx.h" #include "PascalFiles.h" @@ -18,8 +20,7 @@ /* * Decide whether or not we want to handle this file. */ -void -ReformatPascalCode::Examine(ReformatHolder* pHolder) +void ReformatPascalCode::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -40,8 +41,7 @@ ReformatPascalCode::Examine(ReformatHolder* pHolder) * Rather than dump the header and follow it with bits and pieces, we gather * up all the header data and present it with the contents of the block. */ -int -ReformatPascalCode::Process(const ReformatHolder* pHolder, +int ReformatPascalCode::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -141,8 +141,7 @@ bail: /* * Print information about and the contents of one segment. */ -void -ReformatPascalCode::PrintSegment(PCDSegment* pSegment, int segNum, +void ReformatPascalCode::PrintSegment(PCDSegment* pSegment, int segNum, const uint8_t* srcBuf, long srcLen) { const char* segKindStr; @@ -210,8 +209,7 @@ ReformatPascalCode::PrintSegment(PCDSegment* pSegment, int segNum, /* * Decide whether or not we want to handle this file. */ -void -ReformatPascalText::Examine(ReformatHolder* pHolder) +void ReformatPascalText::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -231,8 +229,7 @@ ReformatPascalText::Examine(ReformatHolder* pHolder) * that the next value is 32+indent. Lines end with a CR. If the next line * won't fit in the block, the remainder of the block is filled with zeroes. */ -int -ReformatPascalText::Process(const ReformatHolder* pHolder, +int ReformatPascalText::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -277,8 +274,7 @@ bail: * I'm not sure if the format mandates full 1024-byte blocks -- it * appears to -- but I'm not going to assume it. */ -void -ReformatPascalText::ProcessBlock(const uint8_t* srcBuf, long length) +void ReformatPascalText::ProcessBlock(const uint8_t* srcBuf, long length) { ASSERT(srcBuf != NULL); ASSERT(length > 0 && length <= kPTXBlockSize); diff --git a/reformat/PascalFiles.h b/reformat/PascalFiles.h index 1bf2217..e2491a2 100644 --- a/reformat/PascalFiles.h +++ b/reformat/PascalFiles.h @@ -19,10 +19,10 @@ public: ReformatPascalCode(void) {} virtual ~ReformatPascalCode(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; enum { // VC++6.0 demands this be public, probably because it's used to @@ -84,10 +84,10 @@ public: ReformatPascalText(void) {} virtual ~ReformatPascalText(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: enum { diff --git a/reformat/PrintShop.cpp b/reformat/PrintShop.cpp index 7f597aa..23025e6 100644 --- a/reformat/PrintShop.cpp +++ b/reformat/PrintShop.cpp @@ -18,8 +18,7 @@ /* * Decide whether or not we want to handle this file. */ -void -ReformatPrintShop::Examine(ReformatHolder* pHolder) +void ReformatPrintShop::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -58,8 +57,7 @@ ReformatPrintShop::Examine(ReformatHolder* pHolder) /* * Convert Print Shop clip art into a DIB. */ -int -ReformatPrintShop::Process(const ReformatHolder* pHolder, +int ReformatPrintShop::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -94,8 +92,7 @@ ReformatPrintShop::Process(const ReformatHolder* pHolder, * The file is a linear 1-bit 88x52 image, with four extra bytes of data * at the end. */ -MyDIBitmap* -ReformatPrintShop::ConvertBW(const uint8_t* srcBuf) +MyDIBitmap* ReformatPrintShop::ConvertBW(const uint8_t* srcBuf) { MyDIBitmap* pDib = new MyDIBitmap; uint8_t* outBuf; @@ -145,8 +142,7 @@ bail: * is actually 100% blue and "magenta" is 100% red. The values in the color * table below come from a screen capture of KEGS. */ -MyDIBitmap* -ReformatPrintShop::ConvertColor(const uint8_t* srcBuf) +MyDIBitmap* ReformatPrintShop::ConvertColor(const uint8_t* srcBuf) { MyDIBitmap* pDib = new MyDIBitmap; uint8_t* outBuf; diff --git a/reformat/PrintShop.h b/reformat/PrintShop.h index 191776f..69d3eb8 100644 --- a/reformat/PrintShop.h +++ b/reformat/PrintShop.h @@ -20,10 +20,10 @@ public: ReformatPrintShop(void) {} virtual ~ReformatPrintShop(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: enum { kWidth=88, kHeight=52 }; diff --git a/reformat/Reformat.cpp b/reformat/Reformat.cpp index ccda6cb..01223bb 100644 --- a/reformat/Reformat.cpp +++ b/reformat/Reformat.cpp @@ -31,8 +31,7 @@ /* * Create an instance of the class identified by "id". */ -/*static*/ Reformat* -ReformatHolder::GetReformatInstance(ReformatID id) +/*static*/ Reformat* ReformatHolder::GetReformatInstance(ReformatID id) { Reformat* pReformat = NULL; @@ -102,8 +101,7 @@ ReformatHolder::GetReformatInstance(ReformatID id) * Would have been nice to embed these in the individual classes, but that's * harder to maintain. */ -/*static*/ const WCHAR* -ReformatHolder::GetReformatName(ReformatID id) +/*static*/ const WCHAR* ReformatHolder::GetReformatName(ReformatID id) { const WCHAR* descr = NULL; @@ -266,13 +264,11 @@ ReformatHolder::GetReformatName(ReformatID id) return descr; } - /* * Set the file attributes. These are used by TestApplicability tests to * decide what it is we're looking at. */ -void -ReformatHolder::SetSourceAttributes(long fileType, long auxType, +void ReformatHolder::SetSourceAttributes(long fileType, long auxType, SourceFormat sourceFormat, const char* nameExt) { fFileType = fileType; @@ -300,8 +296,7 @@ ReformatHolder::SetSourceAttributes(long fileType, long auxType, * Before calling here, the file data and file attributes (e.g. file type) * should be stored in "ReformatHolder". */ -void -ReformatHolder::TestApplicability(void) +void ReformatHolder::TestApplicability(void) { Reformat* pReformat; int i; @@ -344,8 +339,8 @@ ReformatHolder::TestApplicability(void) /* * Return the appropriate applicability level. */ -ReformatHolder::ReformatApplies -ReformatHolder::GetApplic(ReformatPart part, ReformatID id) const +ReformatHolder::ReformatApplies ReformatHolder::GetApplic(ReformatPart part, + ReformatID id) const { if (id < kReformatUnknown || id >= kReformatMAX) { assert(false); @@ -362,8 +357,7 @@ ReformatHolder::GetApplic(ReformatPart part, ReformatID id) const /* * Set the appropriate applicability level. */ -void -ReformatHolder::SetApplic(ReformatID id, ReformatApplies applyData, +void ReformatHolder::SetApplic(ReformatID id, ReformatApplies applyData, ReformatApplies applyRsrc, ReformatApplies applyCmmt) { if (id <= kReformatUnknown || id >= kReformatMAX) { @@ -385,8 +379,7 @@ ReformatHolder::SetApplic(ReformatID id, ReformatApplies applyData, * a BASIC program or choosing a double-hi-res algorithm. The preference * indicates the default choice, but does not exclude others. */ -void -ReformatHolder::SetApplicPreferred(ReformatID id, ReformatPart part) +void ReformatHolder::SetApplicPreferred(ReformatID id, ReformatPart part) { for (int i = 0; i < kPartMAX; i++) { if (i == kPartUnknown) @@ -403,13 +396,11 @@ ReformatHolder::SetApplicPreferred(ReformatID id, ReformatPart part) } } - /* * Returns <0, 0, or >0 depending on whether app1 is worse, equal to, * or better than app2. */ -int -ReformatHolder::CompareApplies(ReformatApplies app1, ReformatApplies app2) +int ReformatHolder::CompareApplies(ReformatApplies app1, ReformatApplies app2) { if ((app1 & kApplicPrefMask) < (app2 & kApplicPrefMask)) return -1; @@ -421,8 +412,7 @@ ReformatHolder::CompareApplies(ReformatApplies app1, ReformatApplies app2) /* * Find the best reformatter for the specified part of the loaded file. */ -ReformatHolder::ReformatID -ReformatHolder::FindBest(ReformatPart part) +ReformatHolder::ReformatID ReformatHolder::FindBest(ReformatPart part) { ReformatID bestID = kReformatUnknown; ReformatApplies bestApply = kApplicNot; @@ -446,7 +436,7 @@ ReformatHolder::FindBest(ReformatPart part) } if (bestID == kReformatUnknown || bestApply == kApplicNot) { - LOGI("Did you forget to call TestApplicability?"); + LOGW("Did you forget to call TestApplicability?"); assert(false); return kReformatRaw; } @@ -459,8 +449,7 @@ ReformatHolder::FindBest(ReformatPart part) /* * Apply the requested formatter to the specified part. */ -ReformatOutput* -ReformatHolder::Apply(ReformatPart part, ReformatID id) +ReformatOutput* ReformatHolder::Apply(ReformatPart part, ReformatID id) { ReformatOutput* pOutput; Reformat* pReformat; @@ -469,7 +458,7 @@ ReformatHolder::Apply(ReformatPart part, ReformatID id) if (id <= kReformatUnknown || id >= kReformatMAX || part <= kPartUnknown || part >= kPartMAX) { - LOGI("Invalid reformat request (part=%d id=%d)", part, id); + LOGW("Invalid reformat request (part=%d id=%d)", part, id); assert(false); return NULL; } @@ -524,12 +513,10 @@ ReformatHolder::Apply(ReformatPart part, ReformatID id) return pOutput; } - /* * Get the appropriate input buffer. */ -const uint8_t* -ReformatHolder::GetSourceBuf(ReformatPart part) const +const uint8_t* ReformatHolder::GetSourceBuf(ReformatPart part) const { if (part <= kPartUnknown || part >= kPartMAX) { assert(false); @@ -542,8 +529,7 @@ ReformatHolder::GetSourceBuf(ReformatPart part) const /* * Get the length of the appropriate input buffer. */ -long -ReformatHolder::GetSourceLen(ReformatPart part) const +long ReformatHolder::GetSourceLen(ReformatPart part) const { if (part <= kPartUnknown || part >= kPartMAX) { assert(false); @@ -562,9 +548,7 @@ ReformatHolder::GetSourceLen(ReformatPart part) const * The ReformatHolder "owns" the buffer afterward, so the caller should * discard its pointer. */ -void -ReformatHolder::SetSourceBuf(ReformatPart part, uint8_t* buf, - long len) +void ReformatHolder::SetSourceBuf(ReformatPart part, uint8_t* buf, long len) { if (part <= kPartUnknown || part >= kPartMAX) { assert(false); @@ -577,13 +561,11 @@ ReformatHolder::SetSourceBuf(ReformatPart part, uint8_t* buf, fSourceLen[part] = len; } - /* * Specify an error message to return instead of reformatted text for a * given part. */ -void -ReformatHolder::SetErrorMsg(ReformatPart part, const char* msg) +void ReformatHolder::SetErrorMsg(ReformatPart part, const char* msg) { assert(msg != NULL && *msg != '\0'); assert(part > kPartUnknown && part < kPartMAX); @@ -593,8 +575,7 @@ ReformatHolder::SetErrorMsg(ReformatPart part, const char* msg) LOGI("+++ set error message for part %d to '%hs'", part, msg); } -void -ReformatHolder::SetErrorMsg(ReformatPart part, const CString& str) +void ReformatHolder::SetErrorMsg(ReformatPart part, const CString& str) { CStringA stra(str); SetErrorMsg(part, (LPCSTR) stra); diff --git a/reformat/Reformat.h b/reformat/Reformat.h index d38ed03..0d8e355 100644 --- a/reformat/Reformat.h +++ b/reformat/Reformat.h @@ -15,6 +15,7 @@ #define REFORMAT_REFORMAT_H #include "../util/UtilLib.h" +#include class Reformat; class ReformatOutput; diff --git a/reformat/ReformatBase.cpp b/reformat/ReformatBase.cpp index 2f53982..d5b81ee 100644 --- a/reformat/ReformatBase.cpp +++ b/reformat/ReformatBase.cpp @@ -166,8 +166,7 @@ const int kUnk = 0x3f; // for unmappable chars, use '?' * if we want to have a reversible transformation someday, it'll make our * lives easier then. */ -void -ReformatText::CheckGSCharConv(void) +void ReformatText::CheckGSCharConv(void) { #ifdef _DEBUG bool test[256]; @@ -185,14 +184,12 @@ ReformatText::CheckGSCharConv(void) #endif } - /* * Set the output format and buffer. * * Clears our work buffer pointer so we don't free it. */ -void -ReformatText::SetResultBuffer(ReformatOutput* pOutput, bool multiFont) +void ReformatText::SetResultBuffer(ReformatOutput* pOutput, bool multiFont) { char* buf; long len; @@ -225,7 +222,6 @@ ReformatText::SetResultBuffer(ReformatOutput* pOutput, bool multiFont) pOutput->SetMultipleFontsFlag(true); } - /* * Output the RTF header. * @@ -235,8 +231,7 @@ ReformatText::SetResultBuffer(ReformatOutput* pOutput, bool multiFont) * * The default font is Courier New (\f0) at 10 points (\fs20). */ -void -ReformatText::RTFBegin(int flags) +void ReformatText::RTFBegin(int flags) { // static const char* rtfHdr = //"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0 Courier New;}}\r\n" @@ -274,15 +269,16 @@ ReformatText::RTFBegin(int flags) /* * Output the RTF footer. */ -void -ReformatText::RTFEnd(void) { if (fUseRTF) BufPrintf("}\r\n%c", '\0'); } +void ReformatText::RTFEnd(void) +{ + if (fUseRTF) BufPrintf("}\r\n%c", '\0'); +} /* * Output RTF paragraph definition marker. Do this every time we change some * aspect of paragraph formatting, such as margins or justification. */ -void -ReformatText::RTFSetPara(void) +void ReformatText::RTFSetPara(void) { if (!fUseRTF) return; @@ -320,8 +316,7 @@ ReformatText::RTFSetPara(void) * If you're producing RTF output, this is the right way to output an * end-of-line character. */ -void -ReformatText::RTFNewPara(void) +void ReformatText::RTFNewPara(void) { if (fUseRTF) BufPrintf("\\par\r\n"); @@ -335,8 +330,7 @@ ReformatText::RTFNewPara(void) * so it won't appear in CiderPress or WordPad, but it will come out in * Microsoft Word if you extract to a file. */ -void -ReformatText::RTFPageBreak(void) +void ReformatText::RTFPageBreak(void) { if (fUseRTF) BufPrintf("\\page "); @@ -345,8 +339,7 @@ ReformatText::RTFPageBreak(void) /* * RTF tab character. */ -void -ReformatText::RTFTab(void) +void ReformatText::RTFTab(void) { if (fUseRTF) BufPrintf("\\tab "); @@ -355,8 +348,7 @@ ReformatText::RTFTab(void) /* * Minor formatting. */ -void -ReformatText::RTFBoldOn(void) +void ReformatText::RTFBoldOn(void) { if (fBoldEnabled) return; @@ -365,8 +357,8 @@ ReformatText::RTFBoldOn(void) fBoldEnabled = true; } } -void -ReformatText::RTFBoldOff(void) + +void ReformatText::RTFBoldOff(void) { if (!fBoldEnabled) return; @@ -375,8 +367,8 @@ ReformatText::RTFBoldOff(void) fBoldEnabled = false; } } -void -ReformatText::RTFItalicOn(void) + +void ReformatText::RTFItalicOn(void) { if (fItalicEnabled) return; @@ -385,8 +377,8 @@ ReformatText::RTFItalicOn(void) fItalicEnabled = true; } } -void -ReformatText::RTFItalicOff(void) + +void ReformatText::RTFItalicOff(void) { if (!fItalicEnabled) return; @@ -395,8 +387,8 @@ ReformatText::RTFItalicOff(void) fItalicEnabled = false; } } -void -ReformatText::RTFUnderlineOn(void) + +void ReformatText::RTFUnderlineOn(void) { if (fUnderlineEnabled) return; @@ -405,8 +397,8 @@ ReformatText::RTFUnderlineOn(void) fUnderlineEnabled = true; } } -void -ReformatText::RTFUnderlineOff(void) + +void ReformatText::RTFUnderlineOff(void) { if (!fUnderlineEnabled) return; @@ -415,8 +407,8 @@ ReformatText::RTFUnderlineOff(void) fUnderlineEnabled = false; } } -void -ReformatText::RTFSubscriptOn(void) + +void ReformatText::RTFSubscriptOn(void) { if (fSubscriptEnabled) return; @@ -425,8 +417,8 @@ ReformatText::RTFSubscriptOn(void) fSubscriptEnabled = true; } } -void -ReformatText::RTFSubscriptOff(void) + +void ReformatText::RTFSubscriptOff(void) { if (!fSubscriptEnabled) return; @@ -435,8 +427,8 @@ ReformatText::RTFSubscriptOff(void) fSubscriptEnabled = false; } } -void -ReformatText::RTFSuperscriptOn(void) + +void ReformatText::RTFSuperscriptOn(void) { if (fSuperscriptEnabled) return; @@ -445,8 +437,8 @@ ReformatText::RTFSuperscriptOn(void) fSuperscriptEnabled = true; } } -void -ReformatText::RTFSuperscriptOff(void) + +void ReformatText::RTFSuperscriptOff(void) { if (!fSuperscriptEnabled) return; @@ -455,8 +447,8 @@ ReformatText::RTFSuperscriptOff(void) fSuperscriptEnabled = false; } } -void -ReformatText::RTFSetColor(TextColor color) + +void ReformatText::RTFSetColor(TextColor color) { if (color == fTextColor) return; @@ -469,32 +461,31 @@ ReformatText::RTFSetColor(TextColor color) /* * Change paragraph formatting. */ -void -ReformatText::RTFParaLeft(void) +void ReformatText::RTFParaLeft(void) { if (fJustified != kJustifyLeft) { fJustified = kJustifyLeft; RTFSetPara(); } } -void -ReformatText::RTFParaRight(void) + +void ReformatText::RTFParaRight(void) { if (fJustified != kJustifyRight) { fJustified = kJustifyRight; RTFSetPara(); } } -void -ReformatText::RTFParaCenter(void) + +void ReformatText::RTFParaCenter(void) { if (fJustified != kJustifyCenter) { fJustified = kJustifyCenter; RTFSetPara(); } } -void -ReformatText::RTFParaJustify(void) + +void ReformatText::RTFParaJustify(void) { if (fJustified != kJustifyFull) { fJustified = kJustifyFull; @@ -505,27 +496,24 @@ ReformatText::RTFParaJustify(void) /* * Page margins, in 1/10th inches. */ -void -ReformatText::RTFLeftMargin(int margin) +void ReformatText::RTFLeftMargin(int margin) { //LOGI("+++ Left margin now %d", margin); fLeftMargin = margin; RTFSetPara(); } -void -ReformatText::RTFRightMargin(int margin) + +void ReformatText::RTFRightMargin(int margin) { //LOGI("+++ Right margin now %d", margin); fRightMargin = margin; RTFSetPara(); } - /* * Switch to a different font size. */ -void -ReformatText::RTFSetFontSize(int points) +void ReformatText::RTFSetFontSize(int points) { if (fUseRTF && fPointSize != points) BufPrintf("\\fs%d ", points * 2); @@ -534,8 +522,7 @@ ReformatText::RTFSetFontSize(int points) /* * Switch to a different font. */ -void -ReformatText::RTFSetFont(RTFFont font) +void ReformatText::RTFSetFont(RTFFont font) { if (fUseRTF) BufPrintf("\\f%d ", font); @@ -544,8 +531,7 @@ ReformatText::RTFSetFont(RTFFont font) /* * Set the font by specifying a IIgs QuickDraw II font family number. */ -void -ReformatText::RTFSetGSFont(uint16_t family) +void ReformatText::RTFSetGSFont(uint16_t family) { float newMult; @@ -629,8 +615,7 @@ ReformatText::RTFSetGSFont(uint16_t family) * BUG: we should track the state of the "underline" mode, and turn it * on and off based on the font size (8-point fonts aren't underlined). */ -void -ReformatText::RTFSetGSFontSize(int points) +void ReformatText::RTFSetGSFontSize(int points) { RTFSetFontSize((int) roundf(points * fGSFontSizeMult)); @@ -650,8 +635,7 @@ ReformatText::RTFSetGSFontSize(int points) * bold as they do in plain. This doesn't hold true for Windows * fonts, so we're going to look different in some circumstances. */ -void -ReformatText::RTFSetGSFontStyle(uint8_t qdStyle) +void ReformatText::RTFSetGSFontStyle(uint8_t qdStyle) { if (!fUseRTF) return; @@ -701,8 +685,7 @@ ReformatText::RTFProportionalOff(void) { * If "stripHiBits" is set, the high bit of each character is cleared before * the value is considered. */ -void -ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen, +void ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen, bool stripHiBits) { /* Compatibility - assume we're not stripping nulls */ @@ -715,11 +698,10 @@ ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen, * * If "stripHiBits" is set, the high bit of each character is cleared before * the value is considered. - * + *2 * If "stripNulls" is true, no null values will make it through. */ -void -ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen, +void ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen, bool stripHiBits, bool stripNulls) { uint8_t ch; @@ -760,8 +742,7 @@ ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen, /* * Write a hex dump into the buffer. */ -void -ReformatText::BufHexDump(const uint8_t* srcBuf, long srcLen) +void ReformatText::BufHexDump(const uint8_t* srcBuf, long srcLen) { const uint8_t* origSrcBuf = srcBuf; char chBuf[17]; @@ -863,8 +844,7 @@ ReformatText::BufHexDump(const uint8_t* srcBuf, long srcLen) * Initialize the Apple II color palette, used for Hi-Res and DHR * conversions. Could also be used for lo-res mode. */ -void -ReformatGraphics::InitPalette(void) +void ReformatGraphics::InitPalette(void) { ASSERT(kPaletteSize == 16); @@ -894,8 +874,7 @@ ReformatGraphics::InitPalette(void) /* * Stuff out DIB into the output fields, and set the appropriate flags. */ -void -ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib) +void ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib) { ASSERT(pOutput != NULL); ASSERT(pDib != NULL); @@ -903,7 +882,6 @@ ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib) pOutput->SetDIB(pDib); } - /* * Unpack the Apple PackBytes format. * @@ -922,8 +900,7 @@ ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib) * * Returns 0 on success, nonzero if the buffer is overfilled or underfilled. */ -int -ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src, +int ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src, long dstRem, long srcLen) { while (srcLen > 0) { @@ -1028,7 +1005,6 @@ ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src, return 0; } - /* * Unpack Macintosh PackBits format. See Technical Note TN1023. * @@ -1047,8 +1023,7 @@ ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src, * * We have to watch for underruns on the input and overruns on the output. */ -void -ReformatGraphics::UnPackBits(const uint8_t** pSrcBuf, long* pSrcLen, +void ReformatGraphics::UnPackBits(const uint8_t** pSrcBuf, long* pSrcLen, uint8_t** pOutPtr, long dstLen, uint8_t xorVal) { const uint8_t* srcBuf = *pSrcBuf; diff --git a/reformat/ResourceFork.cpp b/reformat/ResourceFork.cpp index a1d3aba..614eda4 100644 --- a/reformat/ResourceFork.cpp +++ b/reformat/ResourceFork.cpp @@ -55,8 +55,7 @@ static const char* kRsrcC000[0x04] = { /* * We handle all files, but only the resource fork. */ -void -ReformatResourceFork::Examine(ReformatHolder* pHolder) +void ReformatResourceFork::Examine(ReformatHolder* pHolder) { pHolder->SetApplic(ReformatHolder::kReformatResourceFork, ReformatHolder::kApplicNot, @@ -66,8 +65,7 @@ ReformatResourceFork::Examine(ReformatHolder* pHolder) /* * Split a resource fork into its individual resources, and display them. */ -int -ReformatResourceFork::Process(const ReformatHolder* pHolder, +int ReformatResourceFork::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -166,9 +164,8 @@ done: /* * Extract and verify the header of a resource fork. */ -/*static*/ bool -ReformatResourceFork::ReadHeader(const uint8_t* srcBuf, long srcLen, - long* pFileVersion, long* pFileToMap, long* pFileMapSize, +/*static*/ bool ReformatResourceFork::ReadHeader(const uint8_t* srcBuf, + long srcLen, long* pFileVersion, long* pFileToMap, long* pFileMapSize, bool* pLittleEndian) { if (srcLen < 128) { @@ -197,15 +194,13 @@ ReformatResourceFork::ReadHeader(const uint8_t* srcBuf, long srcLen, return true; } - /* * For use by other reformatters: find a specific resource. * * Returns "true" on success, "false" on failure. */ -/*static*/ bool -ReformatResourceFork::GetResource(const uint8_t* srcBuf, long srcLen, - uint16_t resourceType, uint32_t resourceID, +/*static*/ bool ReformatResourceFork::GetResource(const uint8_t* srcBuf, + long srcLen, uint16_t resourceType, uint32_t resourceID, const uint8_t** pResource, long* pResourceLen) { /* read the file header */ diff --git a/reformat/ResourceFork.h b/reformat/ResourceFork.h index ab62e80..24d0a89 100644 --- a/reformat/ResourceFork.h +++ b/reformat/ResourceFork.h @@ -19,10 +19,10 @@ public: ReformatResourceFork(void) {} virtual ~ReformatResourceFork(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; static bool GetResource(const uint8_t* srcBuf, long srcLen, uint16_t resourceType, uint32_t resourceID, diff --git a/reformat/Simple.cpp b/reformat/Simple.cpp index aa38998..86cce14 100644 --- a/reformat/Simple.cpp +++ b/reformat/Simple.cpp @@ -13,8 +13,7 @@ /* * Indicate that we handle all parts of all files. */ -void -ReformatRaw::Examine(ReformatHolder* pHolder) +void ReformatRaw::Examine(ReformatHolder* pHolder) { pHolder->SetApplic(ReformatHolder::kReformatRaw, ReformatHolder::kApplicAlways, @@ -37,20 +36,17 @@ ReformatRaw::Examine(ReformatHolder* pHolder) * This should inspire whoever is calling us to present the data without * reformatting it first. */ -int -ReformatRaw::Process(const ReformatHolder* pHolder, +int ReformatRaw::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { return -1; } - /* * Indicate that we handle all parts of all files. */ -void -ReformatHexDump::Examine(ReformatHolder* pHolder) +void ReformatHexDump::Examine(ReformatHolder* pHolder) { pHolder->SetApplic(ReformatHolder::kReformatHexDump, ReformatHolder::kApplicAlways, @@ -60,8 +56,7 @@ ReformatHexDump::Examine(ReformatHolder* pHolder) /* * Convert a file to a hex dump. */ -int -ReformatHexDump::Process(const ReformatHolder* pHolder, +int ReformatHexDump::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -91,12 +86,10 @@ ReformatHexDump::Process(const ReformatHolder* pHolder, return 0; } - /* * Indicate that we handle all parts of all files. */ -void -ReformatEOL_HA::Examine(ReformatHolder* pHolder) +void ReformatEOL_HA::Examine(ReformatHolder* pHolder) { pHolder->SetApplic(ReformatHolder::kReformatTextEOL_HA, ReformatHolder::kApplicAlways, @@ -109,8 +102,7 @@ ReformatEOL_HA::Examine(ReformatHolder* pHolder) * * Sadly, this most likely requires expanding the original. */ -int -ReformatEOL_HA::Process(const ReformatHolder* pHolder, +int ReformatEOL_HA::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { diff --git a/reformat/Simple.h b/reformat/Simple.h index a079278..1bb458a 100644 --- a/reformat/Simple.h +++ b/reformat/Simple.h @@ -19,10 +19,10 @@ public: ReformatEOL_HA(void) {} virtual ~ReformatEOL_HA(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; /* @@ -33,10 +33,10 @@ public: ReformatRaw(void) {} virtual ~ReformatRaw(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; /* @@ -47,10 +47,10 @@ public: ReformatHexDump(void) {} virtual ~ReformatHexDump(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; #endif /*REFORMAT_SIMPLE_H*/ diff --git a/reformat/SuperHiRes.cpp b/reformat/SuperHiRes.cpp index 9ebe95f..1dedfd2 100644 --- a/reformat/SuperHiRes.cpp +++ b/reformat/SuperHiRes.cpp @@ -46,16 +46,14 @@ * * This is a reasonably generic routine shared by SHR functions. */ -MyDIBitmap* -ReformatSHR::SHRScreenToBitmap8(const SHRScreen* pScreen) +MyDIBitmap* ReformatSHR::SHRScreenToBitmap8(const SHRScreen* pScreen) { return SHRDataToBitmap8(pScreen->pixels, pScreen->scb, pScreen->colorTable, kPixelBytesPerLine, kNumLines, kOutputWidth, kOutputHeight); } -MyDIBitmap* -ReformatSHR::SHRDataToBitmap8(const uint8_t* pPixels, +MyDIBitmap* ReformatSHR::SHRDataToBitmap8(const uint8_t* pPixels, const uint8_t* pSCB, const uint8_t* pColorTable, int pixelBytesPerLine, int numScanLines, int outputWidth, int outputHeight) @@ -223,8 +221,7 @@ bail: * Occasionally somebody slaps the wrong aux type on, so if we're in * "relaxed" mode we accept just about anything that's the right size. */ -void -ReformatUnpackedSHR::Examine(ReformatHolder* pHolder) +void ReformatUnpackedSHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -255,8 +252,7 @@ ReformatUnpackedSHR::Examine(ReformatHolder* pHolder) /* * Convert an unpacked Super Hi-Res image. */ -int -ReformatUnpackedSHR::Process(const ReformatHolder* pHolder, +int ReformatUnpackedSHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -283,6 +279,7 @@ bail: return retval; } + /* * ========================================================================== * ReformatAppSHR @@ -295,8 +292,7 @@ bail: * This file type seems exclusive to the IIgs version of "John Elway * Quarterback". */ -void -ReformatJEQSHR::Examine(ReformatHolder* pHolder) +void ReformatJEQSHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -324,8 +320,7 @@ ReformatJEQSHR::Examine(ReformatHolder* pHolder) * and only one color table is stored. Total savings of 480 bytes -- less * than a ProDOS block. Sorta dumb. */ -int -ReformatJEQSHR::Process(const ReformatHolder* pHolder, +int ReformatJEQSHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -366,8 +361,7 @@ bail: /* * Decide whether or not we want to handle this file. */ -void -ReformatPaintworksSHR::Examine(ReformatHolder* pHolder) +void ReformatPaintworksSHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -386,7 +380,6 @@ ReformatPaintworksSHR::Examine(ReformatHolder* pHolder) ReformatHolder::kApplicNot, ReformatHolder::kApplicNot); } - /* * Convert a PaintWorks format Super Hi-Res image. * @@ -405,8 +398,7 @@ ReformatPaintworksSHR::Examine(ReformatHolder* pHolder) * Sometimes it runs a few bytes over. If it runs significantly under, it's * probably a generic packed image (PNT/0001) with the wrong auxtype. */ -int -ReformatPaintworksSHR::Process(const ReformatHolder* pHolder, +int ReformatPaintworksSHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -493,8 +485,7 @@ bail: /* * Decide whether or not we want to handle this file. */ -void -ReformatPackedSHR::Examine(ReformatHolder* pHolder) +void ReformatPackedSHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -516,8 +507,7 @@ ReformatPackedSHR::Examine(ReformatHolder* pHolder) /* * Convert a packed Super Hi-Res image (PNT/$0001). */ -int -ReformatPackedSHR::Process(const ReformatHolder* pHolder, +int ReformatPackedSHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -560,8 +550,7 @@ bail: /* * Decide whether or not we want to handle this file. */ -void -ReformatAPFSHR::Examine(ReformatHolder* pHolder) +void ReformatAPFSHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -590,8 +579,7 @@ ReformatAPFSHR::Examine(ReformatHolder* pHolder) * All we're really interested in is the "MAIN" block, though we need * to handle MULTIPAL as well for 3200-color images. */ -int -ReformatAPFSHR::Process(const ReformatHolder* pHolder, +int ReformatAPFSHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -707,8 +695,7 @@ bail: * that happens to be 640 pixels wide? Did all //gs applications set this * correctly? Can the format be different on every line? */ -int -ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen) +int ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen) { const int kColorTableSize = kNumEntriesPerColorTable * kColorTableEntrySize; uint16_t masterMode; @@ -733,7 +720,7 @@ ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen) goto bail; } - LOGI(" APFSHR masterMode=0x%04x, ppsl=%d, nct=%d", + LOGD(" APFSHR masterMode=0x%04x, ppsl=%d, nct=%d", masterMode, fPixelsPerScanLine, numColorTables); if (numColorTables <= 0 || numColorTables > kNumColorTables) { LOGI(" APFSHR unexpected numColorTables %d", numColorTables); @@ -773,7 +760,7 @@ ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen) { /* standard-sized image, use fScreen */ ASSERT(!fNonStandard); - LOGI(" Assuming this is a standard, full-width SHR image"); + LOGD(" Assuming this is a standard, full-width SHR image"); fPixelBytesPerLine = kPixelBytesPerLine; // 160 fPixelStore = fScreen.pixels; fSCBStore = fScreen.scb; @@ -820,7 +807,7 @@ ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen) goto bail; } } - LOGI(" APFSHR numScanLines=%d, outputWidth=%d, pixelBytesPerLine=%d", + LOGD(" APFSHR numScanLines=%d, outputWidth=%d, pixelBytesPerLine=%d", fNumScanLines, fOutputWidth, fPixelBytesPerLine); /* @@ -881,8 +868,7 @@ bail: * Brooks format by stuffing them into the file the wrong way. We could * fix it here, but we can't reliably detect the files. */ -int -ReformatAPFSHR::UnpackMultipal(uint8_t* dstPtr, +int ReformatAPFSHR::UnpackMultipal(uint8_t* dstPtr, const uint8_t* srcPtr, long srcLen) { const int kMultipalSize = kNumLines * @@ -934,8 +920,7 @@ ReformatAPFSHR::UnpackMultipal(uint8_t* dstPtr, * Unpack a "NOTE" chunk. This seems to be a 16-bit count followed by * ASCII data. */ -void -ReformatAPFSHR::UnpackNote(const uint8_t* srcPtr, long srcLen) +void ReformatAPFSHR::UnpackNote(const uint8_t* srcPtr, long srcLen) { int numChars; @@ -965,8 +950,7 @@ ReformatAPFSHR::UnpackNote(const uint8_t* srcPtr, long srcLen) /* * Decide whether or not we want to handle this file. */ -void -Reformat3200SHR::Examine(ReformatHolder* pHolder) +void Reformat3200SHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -997,8 +981,7 @@ Reformat3200SHR::Examine(ReformatHolder* pHolder) /* * Convert a 3200-color Super Hi-Res Image. */ -int -Reformat3200SHR::Process(const ReformatHolder* pHolder, +int Reformat3200SHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -1049,8 +1032,7 @@ bail: * * This is shared among the 3200-color SHR formats. */ -MyDIBitmap* -Reformat3200SHR::SHR3200ToBitmap24(void) +MyDIBitmap* Reformat3200SHR::SHR3200ToBitmap24(void) { MyDIBitmap* pDib = new MyDIBitmap; RGBTRIPLE colorLookup[kExtNumColorTables][kNumEntriesPerColorTable]; @@ -1139,8 +1121,7 @@ bail: * This *might* also be $c0/0004, but there's no file type note * for that. */ -void -Reformat3201SHR::Examine(ReformatHolder* pHolder) +void Reformat3201SHR::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; long fileType = pHolder->GetFileType(); @@ -1159,12 +1140,10 @@ Reformat3201SHR::Examine(ReformatHolder* pHolder) ReformatHolder::kApplicNot, ReformatHolder::kApplicNot); } - /* * Convert a 3201-format packed 3200-color Super Hi-Res Image. */ -int -Reformat3201SHR::Process(const ReformatHolder* pHolder, +int Reformat3201SHR::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { diff --git a/reformat/SuperHiRes.h b/reformat/SuperHiRes.h index 28224fd..37b376d 100644 --- a/reformat/SuperHiRes.h +++ b/reformat/SuperHiRes.h @@ -84,10 +84,10 @@ public: ReformatUnpackedSHR(void) {} virtual ~ReformatUnpackedSHR(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: SHRScreen fScreen; @@ -102,10 +102,10 @@ public: ReformatJEQSHR(void) {} virtual ~ReformatJEQSHR(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: enum { kExpectedLen = 32288 }; @@ -121,10 +121,10 @@ public: ReformatPaintworksSHR(void) {} virtual ~ReformatPaintworksSHR(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: enum { kMinSize = 223 }; @@ -140,10 +140,10 @@ public: ReformatPackedSHR(void) {} virtual ~ReformatPackedSHR(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: SHRScreen fScreen; @@ -166,10 +166,10 @@ public: delete[] fSCBStore; } - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: int UnpackMain(const uint8_t* srcPtr, long srcLen); @@ -206,10 +206,10 @@ public: memcpy(fExtColorTable, multiPal, sizeof(fExtColorTable)); } - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; MyDIBitmap* SHR3200ToBitmap24(void); @@ -234,10 +234,10 @@ public: Reformat3201SHR(void) {} virtual ~Reformat3201SHR(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; @@ -279,10 +279,10 @@ public: ReformatDG256SHR(void) {} virtual ~ReformatDG256SHR(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: DreamGrafix fDG; @@ -297,10 +297,10 @@ public: ReformatDG3200SHR(void) {} virtual ~ReformatDG3200SHR(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: DreamGrafix fDG; diff --git a/reformat/Teach.cpp b/reformat/Teach.cpp index 56547a6..695495d 100644 --- a/reformat/Teach.cpp +++ b/reformat/Teach.cpp @@ -22,8 +22,7 @@ * document. Possibly useful for converting the special characters. We'll * activate it for any GWP file other than the two known types. */ -void -ReformatGWP::Examine(ReformatHolder* pHolder) +void ReformatGWP::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -40,8 +39,7 @@ ReformatGWP::Examine(ReformatHolder* pHolder) /* * Convert GWP into formatted text. */ -int -ReformatGWP::Process(const ReformatHolder* pHolder, +int ReformatGWP::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -89,8 +87,7 @@ ReformatGWP::Process(const ReformatHolder* pHolder, /* * Decide whether or not we want to handle this file. */ -void -ReformatTeach::Examine(ReformatHolder* pHolder) +void ReformatTeach::Examine(ReformatHolder* pHolder) { ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot; @@ -106,8 +103,7 @@ ReformatTeach::Examine(ReformatHolder* pHolder) * * The text is in the data fork and the formatting is in the resource fork. */ -int -ReformatTeach::Process(const ReformatHolder* pHolder, +int ReformatTeach::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -238,8 +234,7 @@ ReformatTeach::Process(const ReformatHolder* pHolder, /* * Unpack an rStyleBlock resource. */ -bool -RStyleBlock::Create(const uint8_t* buf, long len) +bool RStyleBlock::Create(const uint8_t* buf, long len) { uint16_t version; uint32_t partLen; @@ -326,14 +321,12 @@ RStyleBlock::Create(const uint8_t* buf, long len) return true; } - /* * Construct a TERuler from a chunk of data. * * Returns the #of bytes consumed, or -1 on failure. */ -int -RStyleBlock::TERuler::Create(const uint8_t* buf, long len) +int RStyleBlock::TERuler::Create(const uint8_t* buf, long len) { long origLen = len; @@ -395,8 +388,7 @@ RStyleBlock::TERuler::Create(const uint8_t* buf, long len) /* * Extract a TEStyle object from the buffer. */ -void -RStyleBlock::TEStyle::Create(const uint8_t* buf) +void RStyleBlock::TEStyle::Create(const uint8_t* buf) { fFontID = Reformat::Get32LE(buf); fForeColor = Reformat::Get16LE(buf + 4); @@ -410,8 +402,7 @@ RStyleBlock::TEStyle::Create(const uint8_t* buf) /* * Extract a StyleItem object from the buffer. */ -void -RStyleBlock::StyleItem::Create(const uint8_t* buf) +void RStyleBlock::StyleItem::Create(const uint8_t* buf) { fLength = Reformat::Get32LE(buf); fOffset = Reformat::Get32LE(buf + 4); diff --git a/reformat/Teach.h b/reformat/Teach.h index 209ac41..4562dc0 100644 --- a/reformat/Teach.h +++ b/reformat/Teach.h @@ -10,6 +10,7 @@ #define REFORMAT_TEACH_H #include "ReformatBase.h" +#include /* * Reformat a generic IIgs text file. @@ -19,10 +20,10 @@ public: ReformatGWP(void) {} virtual ~ReformatGWP(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; /* @@ -33,10 +34,10 @@ public: ReformatTeach(void) {} virtual ~ReformatTeach(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: }; @@ -207,5 +208,4 @@ private: StyleItem* fpStyleItems; }; - #endif /*REFORMAT_TEACH_H*/ diff --git a/reformat/Text8.cpp b/reformat/Text8.cpp index c9364fa..f5e0f36 100644 --- a/reformat/Text8.cpp +++ b/reformat/Text8.cpp @@ -37,8 +37,7 @@ /* * Decide whether or not we want to handle this file. */ -void -ReformatMagicWindow::Examine(ReformatHolder* pHolder) +void ReformatMagicWindow::Examine(ReformatHolder* pHolder) { if (pHolder->GetFileType() == kTypeBIN) { bool isMW = ReformatMagicWindow::IsFormatted(pHolder); @@ -79,8 +78,7 @@ ReformatMagicWindow::Examine(ReformatHolder* pHolder) * I don't know much about the format, so this is based on the similarities * observed between half a dozen documents from different sources. */ -/*static*/ bool -ReformatMagicWindow::IsFormatted(const ReformatHolder* pHolder) +/*static*/ bool ReformatMagicWindow::IsFormatted(const ReformatHolder* pHolder) { const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData); long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData); @@ -145,8 +143,7 @@ ReformatMagicWindow::IsFormatted(const ReformatHolder* pHolder) /* * Skip the header and text-convert the rest. */ -int -ReformatMagicWindow::Process(const ReformatHolder* pHolder, +int ReformatMagicWindow::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { @@ -184,10 +181,9 @@ bail: /* * Decide whether or not we want to handle this file. */ -void -ReformatGutenberg::Examine(ReformatHolder* pHolder) +void ReformatGutenberg::Examine(ReformatHolder* pHolder) { - if ((pHolder->GetFileType() == kTypeTXT) && + if ((pHolder->GetFileType() == kTypeTXT) && (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatGutenberg)) { pHolder->SetApplic(ReformatHolder::kReformatGutenberg, @@ -196,12 +192,10 @@ ReformatGutenberg::Examine(ReformatHolder* pHolder) } } - /* * Convert the text. */ -int -ReformatGutenberg::Process(const ReformatHolder* pHolder, +int ReformatGutenberg::Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, ReformatOutput* pOutput) { diff --git a/reformat/Text8.h b/reformat/Text8.h index a2330c9..340e057 100644 --- a/reformat/Text8.h +++ b/reformat/Text8.h @@ -20,10 +20,10 @@ public: ReformatMagicWindow(void) {} virtual ~ReformatMagicWindow(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; private: static bool IsFormatted(const ReformatHolder* pHolder); @@ -39,10 +39,10 @@ public: ReformatGutenberg(void) {} virtual ~ReformatGutenberg(void) {} - virtual void Examine(ReformatHolder* pHolder); + virtual void Examine(ReformatHolder* pHolder) override; virtual int Process(const ReformatHolder* pHolder, ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part, - ReformatOutput* pOutput); + ReformatOutput* pOutput) override; }; diff --git a/util/CancelDialog.h b/util/CancelDialog.h index c601cc4..bca2ddb 100644 --- a/util/CancelDialog.h +++ b/util/CancelDialog.h @@ -37,11 +37,11 @@ protected: private: /* override Cancel button to just raise the flag */ - virtual void OnCancel(void) { + virtual void OnCancel(void) override { /* "cancel" button or escape hit */ *fpCancelFlag = true; } - //void PostNcDestroy(void) { delete this; } + //void PostNcDestroy(void) override { delete this; } }; diff --git a/util/ImageDataObject.cpp b/util/ImageDataObject.cpp index 622bb8b..5bb97ec 100644 --- a/util/ImageDataObject.cpp +++ b/util/ImageDataObject.cpp @@ -135,4 +135,4 @@ IOleObject *CImageDataObject::GetOleObject(IOleClientSite *pOleClientSite, IStor if (sc != S_OK) AfxThrowOleException(sc); return pOleObject; -} \ No newline at end of file +} diff --git a/util/Modeless.h b/util/Modeless.h index fa5b203..fb65c2b 100644 --- a/util/Modeless.h +++ b/util/Modeless.h @@ -33,7 +33,7 @@ public: * OK button clicked. Must override to prevent standard EndDialog * behavior. */ - virtual void OnOK(void) { + virtual void OnOK(void) override { if (UpdateData() != FALSE) // try the DDX/DDV stuff, if any DestroyWindow(); } @@ -41,12 +41,12 @@ public: * ESC key hit or Cancel button clicked. Must override to prevent * standard EndDialog behavior. */ - virtual void OnCancel(void) { + virtual void OnCancel(void) override { DestroyWindow(); } protected: - void PostNcDestroy(void) { + void PostNcDestroy(void) override { // this may not arrive immediately fOkayToDelete = true; delete this; @@ -77,7 +77,7 @@ public: } /* enable the parent window before we're destroyed */ - virtual BOOL DestroyWindow(void) { + virtual BOOL DestroyWindow(void) override { if (fpParentWnd != NULL) fpParentWnd->EnableWindow(TRUE); return ModelessDialog::DestroyWindow(); diff --git a/util/MyBitmapButton.cpp b/util/MyBitmapButton.cpp index 95af688..5b0170c 100644 --- a/util/MyBitmapButton.cpp +++ b/util/MyBitmapButton.cpp @@ -15,13 +15,7 @@ BEGIN_MESSAGE_MAP(MyBitmapButton, CButton) END_MESSAGE_MAP() -/* - * Replace a button control in a dialog with ourselves. - * - * Returns TRUE on success, FALSE on failure. - */ -BOOL -MyBitmapButton::ReplaceDlgCtrl(CDialog* pDialog, int buttonID) +BOOL MyBitmapButton::ReplaceDlgCtrl(CDialog* pDialog, int buttonID) { CWnd* pWnd = pDialog->GetDlgItem(buttonID); if (pWnd == NULL) @@ -50,27 +44,19 @@ MyBitmapButton::ReplaceDlgCtrl(CDialog* pDialog, int buttonID) return TRUE; } -/* - * Set the bitmap ID, and update the button appropriately. - */ -BOOL -MyBitmapButton::SetBitmapID(int id) +BOOL MyBitmapButton::SetBitmapID(int id) { fBitmapID = id; UpdateBitmap(); return TRUE; } -/* - * (Re-)load the bitmap and attach it to the button. - */ -void -MyBitmapButton::UpdateBitmap(void) +void MyBitmapButton::UpdateBitmap(void) { HBITMAP hNewBits; if (fBitmapID == -1) { - LOGI("ERROR: UpdateBitmap called before bitmap set"); + LOGE("ERROR: UpdateBitmap called before bitmap set"); ASSERT(false); return; } @@ -78,7 +64,7 @@ MyBitmapButton::UpdateBitmap(void) hNewBits = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(fBitmapID), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); if (hNewBits == NULL) { - LOGI("WARNING: LoadImage failed (bitID=%d)", fBitmapID); + LOGW("WARNING: LoadImage failed (bitID=%d)", fBitmapID); ASSERT(false); return; } @@ -89,11 +75,7 @@ MyBitmapButton::UpdateBitmap(void) fhBitmap = hNewBits; } -/* - * If the system colors have changed, reload the bitmap. - */ -void -MyBitmapButton::OnSysColorChange(void) +void MyBitmapButton::OnSysColorChange(void) { LOGD("MyBitmapButton 0x%p tracking color change", this); UpdateBitmap(); diff --git a/util/MyBitmapButton.h b/util/MyBitmapButton.h index 7d01ca9..7765d59 100644 --- a/util/MyBitmapButton.h +++ b/util/MyBitmapButton.h @@ -34,13 +34,29 @@ public: return FALSE; } - virtual BOOL SetBitmapID(int id); + /* + * Replace a button control in a dialog with ourselves. + * + * Returns TRUE on success, FALSE on failure. + */ virtual BOOL ReplaceDlgCtrl(CDialog* pDialog, int buttonID); + /* + * Set the bitmap ID, and update the button appropriately. + */ + virtual BOOL SetBitmapID(int id); + protected: - virtual void UpdateBitmap(void); + /* + * If the system colors have changed, reload the bitmap. + */ afx_msg void OnSysColorChange(void); + /* + * (Re-)load the bitmap and attach it to the button. + */ + virtual void UpdateBitmap(void); + private: HBITMAP fhBitmap; int fBitmapID; diff --git a/util/MyDIBitmap.cpp b/util/MyDIBitmap.cpp index 8eb4c61..559dff2 100644 --- a/util/MyDIBitmap.cpp +++ b/util/MyDIBitmap.cpp @@ -30,9 +30,6 @@ //using namespace libfadden; -/* - * Destroy allocated memory and delete the DIB object. - */ MyDIBitmap::~MyDIBitmap(void) { if (mhBitmap != NULL) @@ -43,18 +40,12 @@ MyDIBitmap::~MyDIBitmap(void) /* fpPixels point to system-allocated memory inside fhBitmap */ } -/* - * Create a blank DIB with the requested dimensions. - * - * We probably don't need to allocate DIB storage here. We can do most - * operations ourselves, in local memory, and only convert when needed. - * - * Returns a pointer to the pixel storage on success, or NULL on failure. - */ -void* -MyDIBitmap::Create(int width, int height, int bitsPerPixel, int colorsUsed, +void* MyDIBitmap::Create(int width, int height, int bitsPerPixel, int colorsUsed, bool dibSection /*=false*/) { + // We probably don't need to allocate DIB storage here. We can do most + // operations ourselves, in local memory, and only convert when needed. + if (mhBitmap != NULL || mpPixels != NULL || mpFileBuffer != NULL) { LOGI(" DIB GLITCH: already created"); assert(false); @@ -146,11 +137,7 @@ MyDIBitmap::Create(int width, int height, int bitsPerPixel, int colorsUsed, return mpPixels; } -/* - * Open the file and call the FILE* version. - */ -int -MyDIBitmap::CreateFromFile(const WCHAR* fileName) +int MyDIBitmap::CreateFromFile(const WCHAR* fileName) { FILE* fp = NULL; int err; @@ -173,11 +160,7 @@ MyDIBitmap::CreateFromFile(const WCHAR* fileName) return err; } -/* - * Create a DIB by reading a BMP or TGA file into memory. - */ -int -MyDIBitmap::CreateFromFile(FILE* fp, long len) +int MyDIBitmap::CreateFromFile(FILE* fp, long len) { void* buf = NULL; int err = -1; @@ -198,14 +181,7 @@ bail: return err; } -/* - * Create object from a copy of the file in memory. - * - * We want to hang on to the data buffer, but if we don't own it then we - * have to make a copy. - */ -int -MyDIBitmap::CreateFromBuffer(void* buf, long len, bool doDelete) +int MyDIBitmap::CreateFromBuffer(void* buf, long len, bool doDelete) { assert(len > 0); @@ -221,18 +197,7 @@ MyDIBitmap::CreateFromBuffer(void* buf, long len, bool doDelete) } } -/* - * Create object from a buffer of new[]-created memory that we own. - * - * The memory will be discarded if this function fails. - * - * We don't want to create a DIB section if the eventual user of this data - * doesn't need it (e.g. it's just getting converted into a 3D texture - * without using any GDI calls), so we just leave the pixels in the file - * buffer for now. - */ -int -MyDIBitmap::CreateFromNewBuffer(void* vbuf, long len) +int MyDIBitmap::CreateFromNewBuffer(void* vbuf, long len) { BITMAPFILEHEADER* pHeader = (BITMAPFILEHEADER*) vbuf; unsigned char* buf = (unsigned char*) vbuf; @@ -256,13 +221,7 @@ MyDIBitmap::CreateFromNewBuffer(void* vbuf, long len) } } -/* - * Set up internal structures for the BMP file. - * - * On error, "vbuf" is discarded. - */ -int -MyDIBitmap::ImportBMP(void* vbuf, long len) +int MyDIBitmap::ImportBMP(void* vbuf, long len) { BITMAPFILEHEADER* pHeader = (BITMAPFILEHEADER*) vbuf; BITMAPINFO* pInfo; @@ -328,18 +287,7 @@ bail: return err; } -/* - * Set up internal structures for the TGA file. - * - * We handle 16-, 24-, and 32-bit .TGA files only. They happen to use the - * same byte layout as BMP files, so we do very little work here. If we - * tried to write the raw data to a BMP file we could end up in trouble, - * because we don't force the "pitch must be multiple of 4 bytes" rule. - * - * On error, "vbuf" is discarded. - */ -int -MyDIBitmap::ImportTGA(void* vbuf, long len) +int MyDIBitmap::ImportTGA(void* vbuf, long len) { TargaHeader targaHdr; unsigned char* hdr = (unsigned char*) vbuf; @@ -422,15 +370,7 @@ MyDIBitmap::ImportTGA(void* vbuf, long len) return err; } - -/* - * If the bitmap wasn't initially created as a DIB section, transform it now - * so the application can use it in GDI calls. - * - * Returns 0 on success, -1 on error. - */ -int -MyDIBitmap::ConvertBufToDIBSection(void) +int MyDIBitmap::ConvertBufToDIBSection(void) { void* oldPixels = mpPixels; @@ -478,13 +418,7 @@ MyDIBitmap::ConvertBufToDIBSection(void) return 0; } -/* - * Create the object from a resource embedded in the application. - * - * Use MAKEINTRESOURCE to load a resource by ordinal. - */ -void* -MyDIBitmap::CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc) +void* MyDIBitmap::CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc) { mhBitmap = (HBITMAP) ::LoadImage(hInstance, rsrc, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_CREATEDIBSECTION); @@ -539,7 +473,7 @@ MyDIBitmap::CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc) DWORD err = ::GetLastError(); CString buf; GetWin32ErrorString(err, &buf); - LOGI(" DIB GetDIBColorTable failed (err=0x%x '%ls')", + LOGW(" DIB GetDIBColorTable failed (err=0x%x '%ls')", err, (LPCWSTR) buf); } SelectObject(memDC, oldBits); @@ -587,12 +521,7 @@ bail: memcpy( m_pResourceBuffer, pvRes, dwSize ); #endif - -/* - * Zero out a bitmap's pixels. Does not touch the color table. - */ -void -MyDIBitmap::ClearPixels(void) +void MyDIBitmap::ClearPixels(void) { assert(mpPixels != NULL); @@ -600,12 +529,7 @@ MyDIBitmap::ClearPixels(void) memset(mpPixels, 0, mPitchBytes * mHeight); } - -/* - * Set the values in the color table. - */ -void -MyDIBitmap::SetColorTable(const RGBQUAD* pColorTable) +void MyDIBitmap::SetColorTable(const RGBQUAD* pColorTable) { assert(pColorTable != NULL); @@ -627,14 +551,7 @@ MyDIBitmap::SetColorTable(const RGBQUAD* pColorTable) mColorTableInitialized = true; } - -/* - * Retrieve the transparency color key, if any. - * - * Returns "false" if no color key has been set. - */ -bool -MyDIBitmap::GetTransparentColor(RGBQUAD* pColor) const +bool MyDIBitmap::GetTransparentColor(RGBQUAD* pColor) const { if (mAlphaType != kAlphaTransparency) return false; @@ -642,11 +559,7 @@ MyDIBitmap::GetTransparentColor(RGBQUAD* pColor) const return true; } -/* - * Set the transparent color. Changes the alpha mode to kAlphaTransparency. - */ -void -MyDIBitmap::SetTransparentColor(const RGBQUAD* pColor) +void MyDIBitmap::SetTransparentColor(const RGBQUAD* pColor) { if (mAlphaType == kAlphaFull) { LOGI(" NOTE: switching from full alpha to transparent-color alpha"); @@ -656,15 +569,7 @@ MyDIBitmap::SetTransparentColor(const RGBQUAD* pColor) mAlphaType = kAlphaTransparency; } - -/* - * Look up an RGB color in an indexed color table. - * - * Returns the index of the color, or -1 if not found (-2 on error, e.g. this - * isn't an indexed-color bitmap or the color table hasn't been created). - */ -int -MyDIBitmap::LookupColor(const RGBQUAD* pRgbQuad) +int MyDIBitmap::LookupColor(const RGBQUAD* pRgbQuad) { if (mBpp > 8) { LOGI(" DIB LookupColor on %d-bit image", mBpp); @@ -688,14 +593,12 @@ MyDIBitmap::LookupColor(const RGBQUAD* pRgbQuad) return -1; } - /* * Return the RGB value of a single pixel in a bitmap. * * "rgbReserved" is always set to zero. */ -void -MyDIBitmap::GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const +void MyDIBitmap::GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const { GetPixelRGBA(x, y, pRgbQuad); pRgbQuad->rgbReserved = 0; @@ -706,8 +609,7 @@ MyDIBitmap::GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const * * This sets rgbReserved appropriately for the current alpha mode. */ -void -MyDIBitmap::GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const +void MyDIBitmap::GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const { assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight); y = mHeight - y -1; // upside-down @@ -799,8 +701,7 @@ MyDIBitmap::GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const * * The "rgbReserved" channel is forced to zero. */ -void -MyDIBitmap::SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad) +void MyDIBitmap::SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad) { if (pRgbQuad->rgbReserved == 0) { SetPixelRGBA(x, y, pRgbQuad); @@ -816,8 +717,7 @@ MyDIBitmap::SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad) * * For index-color bitmaps, this requires a (slow) table lookup. */ -void -MyDIBitmap::SetPixelRGBA(int x, int y, const RGBQUAD* pRgbQuad) +void MyDIBitmap::SetPixelRGBA(int x, int y, const RGBQUAD* pRgbQuad) { assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight); y = mHeight - y -1; // upside-down @@ -854,8 +754,7 @@ MyDIBitmap::SetPixelRGBA(int x, int y, const RGBQUAD* pRgbQuad) * * Only works on indexed-color formats (8bpp or less). */ -void -MyDIBitmap::GetPixelIndex(int x, int y, int* pIdx) const +void MyDIBitmap::GetPixelIndex(int x, int y, int* pIdx) const { assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight); y = mHeight - y -1; // upside-down @@ -881,8 +780,7 @@ MyDIBitmap::GetPixelIndex(int x, int y, int* pIdx) const /* * Set the index value of a pixel in an indexed-color bitmap (8bpp or less). */ -void -MyDIBitmap::SetPixelIndex(int x, int y, int idx) +void MyDIBitmap::SetPixelIndex(int x, int y, int idx) { if (x < 0 || x >= mWidth || y < 0 || y >= mHeight) { LOGI("BAD x=%d y=%d idx=%d", x, y, idx); @@ -911,38 +809,29 @@ MyDIBitmap::SetPixelIndex(int x, int y, int idx) } } - -/* - * Blit a block of pixels from one bitmap to another. - * - * The bitmaps must share a common format, and the rectangles must be the - * same size. We could implement color conversion and resizing here, but - * for now let's not. - */ -/*static*/ bool -MyDIBitmap::Blit(MyDIBitmap* pDstBits, const RECT* pDstRect, +/*static*/ bool MyDIBitmap::Blit(MyDIBitmap* pDstBits, const RECT* pDstRect, const MyDIBitmap* pSrcBits, const RECT* pSrcRect) { if (pDstRect->right - pDstRect->left != pSrcRect->right - pSrcRect->left) { - LOGI("DIB blit: widths differ"); + LOGW("DIB blit: widths differ"); return false; } if (pDstRect->bottom - pDstRect->top != pSrcRect->bottom - pSrcRect->top) { - LOGI("DIB blit: heights differ"); + LOGW("DIB blit: heights differ"); return false; } if (pSrcBits->mBpp != pDstBits->mBpp) { - LOGI("DIB blit: different formats"); + LOGW("DIB blit: different formats"); return false; } if (pDstRect->right <= pDstRect->left || pDstRect->bottom <= pDstRect->top) { - LOGI("DIB blit: poorly formed rect"); + LOGW("DIB blit: poorly formed rect"); return false; } @@ -988,18 +877,7 @@ MyDIBitmap::Blit(MyDIBitmap* pDstBits, const RECT* pDstRect, return true; } - -/* - * Create a DDB from the current bitmap in the specified DC, and return its - * handle. The returned handle must eventually be disposed with DeleteObject. - * - * Since we're just supplying pointers to various pieces of data, there's no - * need for us to have a DIB section. - * - * Returns NULL on failure. - */ -HBITMAP -MyDIBitmap::ConvertToDDB(HDC dc) const +HBITMAP MyDIBitmap::ConvertToDDB(HDC dc) const { HBITMAP hBitmap = NULL; @@ -1079,13 +957,7 @@ MyDIBitmap::ConvertToDDB(HDC dc) const return hBitmap; } - -/* - * Write the bitmap to the named file. Opens the file and calls the FILE* - * function. - */ -int -MyDIBitmap::WriteToFile(const WCHAR* fileName) const +int MyDIBitmap::WriteToFile(const WCHAR* fileName) const { FILE* fp = NULL; int err; @@ -1104,15 +976,7 @@ MyDIBitmap::WriteToFile(const WCHAR* fileName) const return err; } -/* - * Write the bitmap to a file. - * - * Pass in an open, seeked file pointer (make sure to use "wb" mode). - * - * Returns 0 on success, or nonzero (errno) on failure. - */ -int -MyDIBitmap::WriteToFile(FILE* fp) const +int MyDIBitmap::WriteToFile(FILE* fp) const { BITMAPFILEHEADER fileHeader; long pixelBufSize; diff --git a/util/MyDIBitmap.h b/util/MyDIBitmap.h index 0f77740..60d8719 100644 --- a/util/MyDIBitmap.h +++ b/util/MyDIBitmap.h @@ -58,33 +58,84 @@ public: { memset(&mBitmapInfoHdr, 0, sizeof(mBitmapInfoHdr)); } + + /* + * Destroys allocated memory and delete the DIB object. + */ virtual ~MyDIBitmap(void); - // create an empty bitmap with the specified characteristics; returns a - // pointer to the pixel storage + /* + * Creates a blank DIB with the requested dimensions. + * + * Returns a pointer to the pixel storage on success, or NULL on failure. + */ void* Create(int width, int height, int bitsPerPixel, int colorsUsed, bool dibSection = false); + + /* + * Set the values in the color table. + */ void SetColorTable(const RGBQUAD* pColorTable); + const RGBQUAD* GetColorTable(void) const { return mpColorTable; } - // zero out the pixels + /* + * Zero out a bitmap's pixels. Does not touch the color table. + */ void ClearPixels(void); + /* + * Create a DDB from the current bitmap in the specified DC, and return its + * handle. The returned handle must eventually be disposed with DeleteObject. + * + * Since we're just supplying pointers to various pieces of data, there's no + * need for us to have a DIB section. + * + * Returns NULL on failure. + */ HBITMAP ConvertToDDB(HDC dc) const; - // create a DIB from a file on disk + /* + * Opens the file and call the FILE* version. + */ int CreateFromFile(const WCHAR* fileName); + + /* + * Create a DIB by reading a BMP or TGA file into memory. + */ int CreateFromFile(FILE* fp, long len); - // create from memory buffer; set "doDelete" if object should own mem - // (if "doDelete" is set, memory will be deleted if function fails) - // contents of buffer will be analyzed to determine file type + + /* + * Creates object from a copy of the file in memory. Set "doDelete" to + * transfer ownership of object. + * + * We want to hang on to the data buffer, but if we don't own it then we + * have to make a copy. + * + * If "doDelete" is set, memory will be deleted if function fails. + */ int CreateFromBuffer(void* buffer, long len, bool doDelete); - // create a DIB from an embedded resource + /* + * Creates the object from a resource embedded in the application. + * + * Use MAKEINTRESOURCE to load a resource by ordinal. + */ void* CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc); - // write bitmap to file (for FILE*, make sure it's open in "wb" mode) + /* + * Write the bitmap to the named file. Opens the file and calls the FILE* + * function. + */ int WriteToFile(const WCHAR* fileName) const; + + /* + * Write the bitmap to a file. + * + * Pass in an open, seeked file pointer (make sure to use "wb" mode). + * + * Returns 0 on success, or nonzero (errno) on failure. + */ int WriteToFile(FILE* fp) const; // simple getters @@ -95,16 +146,30 @@ public: // retrieve current alpha mode AlphaType GetAlphaType(void) const { return mAlphaType; } - // get transparent color; returns "false" if none has been set + + /* + * Retrieve the transparency color key, if any. + * + * Returns "false" if no color key has been set. + */ bool GetTransparentColor(RGBQUAD* pColor) const; - // set transparent color and change alpha to kAlphaTransparency + + /* + * Set the transparent color. Changes the alpha mode to kAlphaTransparency. + */ void SetTransparentColor(const RGBQUAD* pColor); - // return the index of the specified color (-1 if not found, -2 on err) + /* + * Look up an RGB color in an indexed color table. + * + * Returns the index of the color, or -1 if not found (-2 on error, e.g. this + * isn't an indexed-color bitmap or the color table hasn't been created). + */ int LookupColor(const RGBQUAD* pRgbQuad); // set/get individual pixel values; the "RGB" functions always set // alpha to zero, while "RGBA" follow the current alpha mode + void FASTCALL GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const; void FASTCALL SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad); void FASTCALL GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const; @@ -125,7 +190,13 @@ public: int GetPitch(void) const { return mPitchBytes; } - // Blit pixels from one bitmap to another. + /* + * Blit a block of pixels from one bitmap to another. + * + * The bitmaps must share a common format, and the rectangles must be the + * same size. We could implement color conversion and resizing here, but + * for now let's not. + */ static bool Blit(MyDIBitmap* pDstBits, const RECT* pDstRect, const MyDIBitmap* pSrcBits, const RECT* pSrcRect); @@ -152,9 +223,43 @@ private: kTargaUnmappedRGB = 2, // for imageType field }; + /* + * Set up internal structures for the BMP file. + * + * On error, "vbuf" is discarded. + */ int ImportBMP(void* vbuf, long len); + + /* + * Set up internal structures for the TGA file. + * + * We handle 16-, 24-, and 32-bit .TGA files only. They happen to use the + * same byte layout as BMP files, so we do very little work here. If we + * tried to write the raw data to a BMP file we could end up in trouble, + * because we don't force the "pitch must be multiple of 4 bytes" rule. + * + * On error, "vbuf" is discarded. + */ int ImportTGA(void* vbuf, long len); + + /* + * If the bitmap wasn't initially created as a DIB section, transform it now + * so the application can use it in GDI calls. + * + * Returns 0 on success, -1 on error. + */ int ConvertBufToDIBSection(void); + + /* + * Create object from a buffer of new[]-created memory that we own. + * + * The memory will be discarded if this function fails. + * + * We don't want to create a DIB section if the eventual user of this data + * doesn't need it (e.g. it's just getting converted into a 3D texture + * without using any GDI calls), so we just leave the pixels in the file + * buffer for now. + */ int CreateFromNewBuffer(void* vbuf, long len); BITMAPINFOHEADER mBitmapInfoHdr; diff --git a/util/MyEdit.cpp b/util/MyEdit.cpp index a0bee2c..40098fd 100644 --- a/util/MyEdit.cpp +++ b/util/MyEdit.cpp @@ -18,8 +18,7 @@ * * Returns TRUE on success, FALSE on failure. */ -BOOL -MyEdit::ReplaceDlgCtrl(CDialog* pDialog, int editID) +BOOL MyEdit::ReplaceDlgCtrl(CDialog* pDialog, int editID) { CWnd* pWnd = pDialog->GetDlgItem(editID); if (pWnd == NULL) @@ -34,20 +33,17 @@ MyEdit::ReplaceDlgCtrl(CDialog* pDialog, int editID) /* * Set the properties that make us special. */ -void -MyEdit::SetProperties(int props) +void MyEdit::SetProperties(int props) { fCapsOnly = (props & kCapsOnly) != 0; fHexOnly = (props & kHexOnly) != 0; fNoWhiteSpace = (props & kNoWhiteSpace) != 0; } - /* * Special keypress handling. */ -BOOL -MyEdit::PreTranslateMessage(MSG* pMsg) +BOOL MyEdit::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_CHAR) { if (fCapsOnly) diff --git a/util/MyEdit.h b/util/MyEdit.h index fc0f2cb..d591cd7 100644 --- a/util/MyEdit.h +++ b/util/MyEdit.h @@ -43,7 +43,7 @@ public: virtual BOOL ReplaceDlgCtrl(CDialog* pDialog, int editID); private: - virtual BOOL PreTranslateMessage(MSG* pMsg); + virtual BOOL PreTranslateMessage(MSG* pMsg) override; bool fCapsOnly; bool fHexOnly; diff --git a/util/MySpinCtrl.cpp b/util/MySpinCtrl.cpp index 4fb5d4a..6ebc0c6 100644 --- a/util/MySpinCtrl.cpp +++ b/util/MySpinCtrl.cpp @@ -37,13 +37,7 @@ void MySpinCtrl::PreSubclassWindow() } #endif -/* - * Convert a decimal or hex string to a long. - * - * Returns "true" on success, "false" on error. - */ -bool -MySpinCtrl::ConvLong(const WCHAR* str, long* pVal) const +bool MySpinCtrl::ConvLong(const WCHAR* str, long* pVal) const { WCHAR* endp; @@ -57,8 +51,7 @@ MySpinCtrl::ConvLong(const WCHAR* str, long* pVal) const /* * Handle UDN_DELTAPOS notification. */ -void -MySpinCtrl::OnDeltaPos(NMHDR* pNMHDR, LRESULT* pResult) +void MySpinCtrl::OnDeltaPos(NMHDR* pNMHDR, LRESULT* pResult) { _ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked"); // _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked"); @@ -101,8 +94,7 @@ bail: * * Returns the previous position. */ -int -MySpinCtrl::SetPos(int nPos) +int MySpinCtrl::SetPos(int nPos) { _ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked"); // _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked"); @@ -129,8 +121,7 @@ MySpinCtrl::SetPos(int nPos) * * Returns -1 on error. Yes, that's bogus, but it's good enough for now. */ -int -MySpinCtrl::GetPos() const +int MySpinCtrl::GetPos() const { _ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked"); // _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked"); @@ -158,8 +149,7 @@ MySpinCtrl::GetPos() const return val; } -DWORD -MySpinCtrl::GetRange(void) const +DWORD MySpinCtrl::GetRange(void) const { _ASSERTE(! "Do NOT use this method!"); return 0; @@ -168,8 +158,7 @@ MySpinCtrl::GetRange(void) const /* * Get 32-bit ranges. */ -void -MySpinCtrl::GetRange32(int& lower, int& upper) const +void MySpinCtrl::GetRange32(int& lower, int& upper) const { lower = fLow; upper = fHigh; @@ -179,8 +168,7 @@ MySpinCtrl::GetRange32(int& lower, int& upper) const /* * Set 32-bit ranges. */ -void -MySpinCtrl::SetRange32(int nLo, int nHi) +void MySpinCtrl::SetRange32(int nLo, int nHi) { _ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked"); // _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked"); diff --git a/util/MySpinCtrl.h b/util/MySpinCtrl.h index 3b0ce69..c193fdf 100644 --- a/util/MySpinCtrl.h +++ b/util/MySpinCtrl.h @@ -26,7 +26,7 @@ public: MySpinCtrl(void) : fLow(0), fHigh(100) {} virtual ~MySpinCtrl(void) {} - // override original methods (AFXCMN.H) + // replacements for superclass methods (AFXCMN.H) int SetPos(int nPos); int GetPos() const; void SetRange(int nLower, int nUpper) { SetRange32(nLower, nUpper); } @@ -42,6 +42,11 @@ protected: private: int fLow, fHigh; + /* + * Convert a decimal or hex string to a long. + * + * Returns "true" on success, "false" on error. + */ bool ConvLong(const WCHAR* str, long* pVal) const; DECLARE_MESSAGE_MAP() diff --git a/util/PathName.cpp b/util/PathName.cpp index 8ba42f7..079e2d9 100644 --- a/util/PathName.cpp +++ b/util/PathName.cpp @@ -38,15 +38,7 @@ #define kFilenameExtDelim '.' /* separates extension from filename */ -/* - * Find the filename component of a local pathname. Uses the fssep passed - * in. If the fssep is '\0' (as is the case for DOS 3.3), then the entire - * pathname is returned. - * - * Always returns a pointer to a string; never returns NULL. - */ -const WCHAR* -PathName::FilenameOnly(const WCHAR* pathname, WCHAR fssep) +const WCHAR* PathName::FilenameOnly(const WCHAR* pathname, WCHAR fssep) { const WCHAR* retstr; const WCHAR* pSlash; @@ -99,19 +91,7 @@ bail: return retstr; } -/* - * Return the filename extension found in a full pathname. - * - * An extension is the stuff following the last '.' in the filename. If - * there is nothing following the last '.', then there is no extension. - * - * Returns a pointer to the '.' preceding the extension, or NULL if no - * extension was found. - * - * We guarantee that there is at least one character after the '.'. - */ -const WCHAR* -PathName::FindExtension(const WCHAR* pathname, WCHAR fssep) +const WCHAR* PathName::FindExtension(const WCHAR* pathname, WCHAR fssep) { const WCHAR* pFilename; const WCHAR* pExt; @@ -131,13 +111,7 @@ PathName::FindExtension(const WCHAR* pathname, WCHAR fssep) return NULL; } - - -/* - * Get just the file name. - */ -CString -PathName::GetFileName(void) +CString PathName::GetFileName(void) { CString str; @@ -157,22 +131,14 @@ PathName::GetFileName(void) return str; } -/* - * Get just the drive name. - */ -CString -PathName::GetDriveOnly(void) +CString PathName::GetDriveOnly(void) { SplitIFN(); return fDrive; } -/* - * Get directory names, prefixed with the drive. - */ -CString -PathName::GetDriveAndPath(void) +CString PathName::GetDriveAndPath(void) { CString str; @@ -183,22 +149,14 @@ PathName::GetDriveAndPath(void) return str; } -/* - * Get just the directory names. - */ -CString -PathName::GetPathOnly(void) +CString PathName::GetPathOnly(void) { SplitIFN(); return fDir; } -/* - * Get just the extension. - */ -CString -PathName::GetExtension(void) +CString PathName::GetExtension(void) { SplitIFN(); @@ -216,13 +174,7 @@ PathName::GetExtension(void) return fExt; } -/* - * Expand the short file name of an existing file into its long form. - * - * Returns 0 on success, -1 on failure. - */ -int -PathName::SFNToLFN(void) +int PathName::SFNToLFN(void) { WCHAR buf[MAX_PATH]; WIN32_FIND_DATA findFileData; @@ -310,11 +262,7 @@ PathName::SFNToLFN(void) return 0; } -/* - * Return the description of the file type. - */ -CString -PathName::GetDescription() +CString PathName::GetDescription() { CString szTypeName; SHFILEINFO sfi = { 0 }; @@ -326,21 +274,14 @@ PathName::GetDescription() return szTypeName; } -/* - * Check to see if the file exists. - * - * If we use something simple like access(), we will catch all files including - * the ones in Network Neighborhood. Using the FindFirstFile stuff avoids - * the problem, but raises the difficulty of being unable to find simple - * things like "D:\". - */ -bool -PathName::Exists(void) +bool PathName::Exists(void) { -// if (strncmp(fPathName, "\\\\", 2) == 0) { -// LOGI("Refusing to check for network path '%ls'", fPathName); -// return false; -// } + /* + * If we use something simple like access(), we will catch all files including + * the ones in Network Neighborhood. Using the FindFirstFile stuff avoids + * the problem, but raises the difficulty of being unable to find simple + * things like "D:\". + */ return (::_waccess(fPathName, 0) != -1); @@ -409,11 +350,7 @@ with ---------------------- */ -/* - * Invoke the system-dependent directory creation function. - */ -int -PathName::Mkdir(const WCHAR* dir) +int PathName::Mkdir(const WCHAR* dir) { int err = 0; @@ -425,16 +362,7 @@ PathName::Mkdir(const WCHAR* dir) return err; } -/* - * Determine if a file exists, and if so whether or not it's a directory. - * - * Set fields you're not interested in to NULL. - * - * On success, returns 0 and fields are set appropriately. On failure, - * returns nonzero and result values are undefined. - */ -int -PathName::GetFileInfo(const WCHAR* pathname, struct _stat* psb, +int PathName::GetFileInfo(const WCHAR* pathname, struct _stat* psb, time_t* pModWhen, bool* pExists, bool* pIsReadable, bool* pIsDirectory) { struct _stat sbuf; @@ -494,21 +422,13 @@ PathName::GetFileInfo(const WCHAR* pathname, struct _stat* psb, return 0; } -/* - * Check the status of a file. - */ -int -PathName::CheckFileStatus(struct _stat* psb, bool* pExists, bool* pIsReadable, +int PathName::CheckFileStatus(struct _stat* psb, bool* pExists, bool* pIsReadable, bool* pIsDir) { return GetFileInfo(fPathName, psb, NULL, pExists, pIsReadable, pIsDir); } -/* - * Get the modification date of a file. - */ -time_t -PathName::GetModWhen(void) +time_t PathName::GetModWhen(void) { time_t when; @@ -518,11 +438,7 @@ PathName::GetModWhen(void) return when; } -/* - * Set the modification date on a file. - */ -int -PathName::SetModWhen(time_t when) +int PathName::SetModWhen(time_t when) { struct _utimbuf utbuf; @@ -539,16 +455,7 @@ PathName::SetModWhen(time_t when) return 0; } -/* - * Create a single subdirectory if it doesn't exist. If the next-highest - * subdirectory level doesn't exist either, cut down the pathname and - * recurse. - * - * "pathEnd" points at the last valid character. The length of the valid - * path component is therefore (pathEnd-pathStart+1). - */ -int -PathName::CreateSubdirIFN(const WCHAR* pathStart, const WCHAR* pathEnd, +int PathName::CreateSubdirIFN(const WCHAR* pathStart, const WCHAR* pathEnd, WCHAR fssep) { int err = 0; @@ -597,17 +504,7 @@ bail: return err; } -/* - * Create subdirectories, if needed. The paths leading up to the filename - * in "pathname" will be created. - * - * If "pathname" is just a filename, or the set of directories matches - * the last directory we created, we don't do anything. - * - * Returns 0 on success, or a Windows error code on failure. - */ -int -PathName::CreatePathIFN(void) +int PathName::CreatePathIFN(void) { int err = 0; CString pathName(fPathName); diff --git a/util/PathName.h b/util/PathName.h index 557369d..6ebdd4f 100644 --- a/util/PathName.h +++ b/util/PathName.h @@ -72,12 +72,13 @@ public: CString GetDriveAndPath(void); CString GetPathOnly(void); - // try to normalize a short name into a long name + /* + * Expand the short file name of an existing file into its long form. + * + * Returns 0 on success, -1 on failure. + */ int SFNToLFN(void); - /* - * File manipulations. - */ // returns the description of the file type (as seen in explorer) CString GetDescription(void); @@ -93,12 +94,38 @@ public: // set the modification date int SetModWhen(time_t when); - // create the path, if necessary + /* + * Create subdirectories, if needed. The paths leading up to the filename + * in "pathname" will be created. + * + * If "pathname" is just a filename, or the set of directories matches + * the last directory we created, we don't do anything. + * + * Returns 0 on success, or a Windows error code on failure. + */ int CreatePathIFN(void); + /* + * Return the filename extension found in a full pathname. + * + * An extension is the stuff following the last '.' in the filename. If + * there is nothing following the last '.', then there is no extension. + * + * Returns a pointer to the '.' preceding the extension, or NULL if no + * extension was found. + * + * We guarantee that there is at least one character after the '.'. + */ static const WCHAR* FindExtension(const WCHAR* pathname, WCHAR fssep); + + /* + * Find the filename component of a local pathname. Uses the fssep passed + * in. If the fssep is '\0' (as is the case for DOS 3.3), then the entire + * pathname is returned. + * + * Always returns a pointer to a string; never returns NULL. + */ static const WCHAR* FilenameOnly(const WCHAR* pathname, WCHAR fssep); - //int SFNToLFN(const char* sfn, CString* pLfn); private: void SplitIFN(void) { @@ -107,9 +134,31 @@ private: fSplit = true; } } + + /* + * Invoke the system-dependent directory creation function. + */ int Mkdir(const WCHAR* dir); + + /* + * Determine if a file exists, and if so whether or not it's a directory. + * + * Set fields you're not interested in to NULL. + * + * On success, returns 0 and fields are set appropriately. On failure, + * returns nonzero and result values are undefined. + */ int GetFileInfo(const WCHAR* pathname, struct _stat* psb, time_t* pModWhen, bool* pExists, bool* pIsReadable, bool* pIsDirectory); + + /* + * Create a single subdirectory if it doesn't exist. If the next-highest + * subdirectory level doesn't exist either, cut down the pathname and + * recurse. + * + * "pathEnd" points at the last valid character. The length of the valid + * path component is therefore (pathEnd-pathStart+1). + */ int CreateSubdirIFN(const WCHAR* pathStart, const WCHAR* pathEnd, WCHAR fssep); diff --git a/util/Pidl.cpp b/util/Pidl.cpp index 59aca07..68e848a 100644 --- a/util/Pidl.cpp +++ b/util/Pidl.cpp @@ -15,13 +15,7 @@ * ========================================================================== */ -/* - * Return the next item in the PIDL. - * - * "pidl->mkid.cb" will be zero at the end of the list. - */ -LPITEMIDLIST -Pidl::Next(LPCITEMIDLIST pidl) +LPITEMIDLIST Pidl::Next(LPCITEMIDLIST pidl) { LPSTR lpMem = (LPSTR)pidl; @@ -30,11 +24,7 @@ Pidl::Next(LPCITEMIDLIST pidl) return (LPITEMIDLIST)lpMem; } -/* - * Compute the size in bytes of a PIDL. - */ -UINT -Pidl::GetSize(LPCITEMIDLIST pidl) +UINT Pidl::GetSize(LPCITEMIDLIST pidl) { UINT cbTotal = 0; @@ -49,11 +39,7 @@ Pidl::GetSize(LPCITEMIDLIST pidl) return cbTotal; } -/* - * Allocate a PIDL of the specified size. - */ -LPITEMIDLIST -Pidl::CreatePidl(UINT cbSize) +LPITEMIDLIST Pidl::CreatePidl(UINT cbSize) { LPMALLOC lpMalloc; HRESULT hr; @@ -74,13 +60,7 @@ Pidl::CreatePidl(UINT cbSize) return pidl; } -/* - * Concatenates two PIDLs. The PIDL returned is newly-allocated storage. - * - * "pidl1" may be NULL. - */ -LPITEMIDLIST -Pidl::ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) +LPITEMIDLIST Pidl::ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) { LPITEMIDLIST pidlNew; UINT cb1; @@ -102,13 +82,7 @@ Pidl::ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) return pidlNew; } -/* - * Make a copy of a PIDL. - * - * The PIDL returned is newly-allocated storage. - */ -LPITEMIDLIST -Pidl::CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi) +LPITEMIDLIST Pidl::CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi) { LPITEMIDLIST lpiTemp; @@ -119,16 +93,7 @@ Pidl::CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi) return lpiTemp; } -/* - * Get the display name of a file in a ShellFolder. - * - * "lpsf" is the ShellFolder that contains the file, "lpi" is the PIDL for - * the file, "dwFlags" is passed to GetDisplayNameOf and affects which - * name is returned, and "lpFriendlyName" is a buffer of at least MAX_PATH - * bytes. - */ -BOOL -Pidl::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, +BOOL Pidl::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, CString* pFriendlyName) { BOOL bSuccess=TRUE; @@ -176,20 +141,7 @@ Pidl::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, return bSuccess; } - - -/* - * Get a fully qualified PIDL for a ShellFolder. - * - * This is a rather roundabout way of doing things (converting to a full - * display name and then converting that to a PIDL). However, there doesn't - * seem to be a way to just ask a ShellFolder for its fully qualified PIDL. - * TODO: see if there's a better way now. - * - * Pass in the parent ShellFolder and the item's partial PIDL. - */ -LPITEMIDLIST -Pidl::GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi) +LPITEMIDLIST Pidl::GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi) { //char szBuff[MAX_PATH]; //OLECHAR szOleChar[MAX_PATH]; @@ -223,13 +175,7 @@ Pidl::GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi) return lpifq; } -/* - * Convert a PIDL to a filesystem path. - * - * Returns TRUE on success, FALSE on failure. - */ -BOOL -Pidl::GetPath(LPCITEMIDLIST pidl, CString* pPath) +BOOL Pidl::GetPath(LPCITEMIDLIST pidl, CString* pPath) { BOOL result; WCHAR buf[MAX_PATH]; @@ -336,14 +282,7 @@ Pidl::DoTheMenuThing(HWND hwnd, LPSHELLFOLDER lpsfParent, } #endif -/* - * Get the index for an icon for a ShellFolder object. - * - * "lpi" is the fully-qualified PIDL for the object in question. "uFlags" - * specifies which of the object's icons to retrieve. - */ -int -Pidl::GetItemIcon(LPITEMIDLIST lpi, UINT uFlags) +int Pidl::GetItemIcon(LPITEMIDLIST lpi, UINT uFlags) { SHFILEINFO sfi = { 0 }; diff --git a/util/Pidl.h b/util/Pidl.h index 475cd8d..214a560 100644 --- a/util/Pidl.h +++ b/util/Pidl.h @@ -15,20 +15,73 @@ */ class Pidl { public: - // Functions that deal with PIDLs + /* + * Concatenates two PIDLs. The PIDL returned is newly-allocated storage. + * + * "pidl1" may be NULL. + */ static LPITEMIDLIST ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2); + + /* + * Get a fully qualified PIDL for a ShellFolder. + * + * This is a rather roundabout way of doing things (converting to a full + * display name and then converting that to a PIDL). However, there doesn't + * seem to be a way to just ask a ShellFolder for its fully qualified PIDL. + * TODO: see if there's a better way now. + * + * Pass in the parent ShellFolder and the item's partial PIDL. + */ static LPITEMIDLIST GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi); + + /* + * Make a copy of a PIDL. + * + * The PIDL returned is newly-allocated storage. + */ static LPITEMIDLIST CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi); + + /* + * Get the display name of a file in a ShellFolder. + * + * "lpsf" is the ShellFolder that contains the file, "lpi" is the PIDL for + * the file, "dwFlags" is passed to GetDisplayNameOf and affects which + * name is returned, and "lpFriendlyName" is a buffer of at least MAX_PATH + * bytes. + */ static BOOL GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, CString* pFriendlyName); + + /* + * Allocate a PIDL of the specified size. + */ static LPITEMIDLIST CreatePidl(UINT cbSize); + + /* + * Compute the size in bytes of a PIDL. + */ static UINT GetSize(LPCITEMIDLIST pidl); + + /* + * Return the next item in the PIDL. + * + * "pidl->mkid.cb" will be zero at the end of the list. + */ static LPITEMIDLIST Next(LPCITEMIDLIST pidl); + + /* + * Convert a PIDL to a filesystem path. + * + * Returns TRUE on success, FALSE on failure. + */ static BOOL GetPath(LPCITEMIDLIST pidl, CString* pPath); - // Utility Functions - //static BOOL DoTheMenuThing(HWND hwnd, LPSHELLFOLDER lpsfParent, - // LPITEMIDLIST lpi, LPPOINT lppt); + /* + * Get the index for an icon for a ShellFolder object. + * + * "lpi" is the fully-qualified PIDL for the object in question. "uFlags" + * specifies which of the object's icons to retrieve. + */ static int GetItemIcon(LPITEMIDLIST lpi, UINT uFlags); }; diff --git a/util/SelectFilesDialog.cpp b/util/SelectFilesDialog.cpp index 7b9bd92..51bdc74 100644 --- a/util/SelectFilesDialog.cpp +++ b/util/SelectFilesDialog.cpp @@ -69,9 +69,8 @@ * Return zero to enable standard processing, nonzero to claim ownership of * the message. */ -/*static*/ UINT CALLBACK -SelectFilesDialog::OFNHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, - LPARAM lParam) +/*static*/ UINT CALLBACK SelectFilesDialog::OFNHookProc(HWND hDlg, UINT uiMsg, + WPARAM wParam, LPARAM lParam) { OPENFILENAME* pOfn; SelectFilesDialog* pSFD = NULL; @@ -117,8 +116,7 @@ SelectFilesDialog::OFNHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, * You can indicate displeasure with the CDN_* messages by using SetWindowLong * to alter the DWL_MSGRESULT value. */ -UINT -SelectFilesDialog::HandleNotify(HWND hDlg, LPOFNOTIFY pofn) +UINT SelectFilesDialog::HandleNotify(HWND hDlg, LPOFNOTIFY pofn) { // int count; @@ -173,8 +171,7 @@ SelectFilesDialog::HandleNotify(HWND hDlg, LPOFNOTIFY pofn) /* * Handle WM_COMMAND messages. */ -UINT -SelectFilesDialog::HandleCommand(HWND hDlg, WPARAM wParam, LPARAM lParam) +UINT SelectFilesDialog::HandleCommand(HWND hDlg, WPARAM wParam, LPARAM lParam) { LOGI(" HandleCommand wParam=%d lParam=0x%08lx", wParam, lParam); @@ -192,8 +189,7 @@ SelectFilesDialog::HandleCommand(HWND hDlg, WPARAM wParam, LPARAM lParam) /* * Handle WM_SIZE. */ -UINT -SelectFilesDialog::HandleSize(HWND hDlg, UINT nType, int cx, int cy) +UINT SelectFilesDialog::HandleSize(HWND hDlg, UINT nType, int cx, int cy) { //LOGI("Dialog: old size %d,%d (ready=%d)", // fLastWinSize.Width(), fLastWinSize.Height(), fReady); @@ -219,8 +215,7 @@ SelectFilesDialog::HandleSize(HWND hDlg, UINT nType, int cx, int cy) * User hit F1 or applied the '?' button to something. Our heritage is * dubious, so use global functions to access the help file. */ -UINT -SelectFilesDialog::HandleHelp(HWND hDlg, LPHELPINFO lpHelpInfo) +UINT SelectFilesDialog::HandleHelp(HWND hDlg, LPHELPINFO lpHelpInfo) { CWnd* pWndMain = ::AfxGetMainWnd(); CWinApp* pAppMain = ::AfxGetApp(); @@ -243,8 +238,7 @@ SelectFilesDialog::HandleHelp(HWND hDlg, LPHELPINFO lpHelpInfo) * We need to shift everything up by the difference between the IDOK button * and our "accept" button. */ -void -SelectFilesDialog::MyOnInitDone(void) +void SelectFilesDialog::MyOnInitDone(void) { LOGI("OnInitDone!"); CWnd* pParent = GetParent(); @@ -293,8 +287,7 @@ SelectFilesDialog::MyOnInitDone(void) * because the CFileDialog is also moving the controls, though it doesn't * move them in quite the way we want. */ -void -SelectFilesDialog::ShiftControls(int deltaX, int deltaY) +void SelectFilesDialog::ShiftControls(int deltaX, int deltaY) { if (deltaX == 0 && deltaY == 0) { LOGI("SFD OnSize: no meaningful change"); @@ -316,8 +309,7 @@ SelectFilesDialog::ShiftControls(int deltaX, int deltaY) * * Returns "NULL" if it can't find it. */ -CWnd* -SelectFilesDialog::GetListCtrl(void) +CWnd* SelectFilesDialog::GetListCtrl(void) { CWnd* pItem; CWnd* pList; @@ -338,8 +330,7 @@ SelectFilesDialog::GetListCtrl(void) /* * When the selection changes, update our dialog. */ -void -SelectFilesDialog::MyOnFileNameChange(void) +void SelectFilesDialog::MyOnFileNameChange(void) { //LOGI("OnFileNameChange"); @@ -364,8 +355,7 @@ SelectFilesDialog::MyOnFileNameChange(void) /* * The user hit the "Accept" button. Package up the file selection. */ -void -SelectFilesDialog::MyOnAccept(void) +void SelectFilesDialog::MyOnAccept(void) { //LOGI("OnAccept!"); PrepEndDialog(); @@ -378,8 +368,7 @@ SelectFilesDialog::MyOnAccept(void) * Returns "true" if all went well, "false" if it failed (e.g. because the * user hasn't selected any files). */ -bool -SelectFilesDialog::PrepEndDialog(void) +bool SelectFilesDialog::PrepEndDialog(void) { CListCtrl* pList; int nextSpot = 0; @@ -569,8 +558,7 @@ SelectFilesDialog::PrepEndDialog(void) /* * User hit our cancel button. */ -void -SelectFilesDialog::MyOnCancel(void) +void SelectFilesDialog::MyOnCancel(void) { fExitStatus = IDCANCEL; CDialog* pDialog = (CDialog*) GetParent(); @@ -580,8 +568,7 @@ SelectFilesDialog::MyOnCancel(void) /* * Clear the filename field. */ -void -SelectFilesDialog::ClearFileName(void) +void SelectFilesDialog::ClearFileName(void) { CWnd* pWnd = GetParent()->GetDlgItem(edt1); if (pWnd != NULL) diff --git a/util/ShellTree.cpp b/util/ShellTree.cpp index feb0b2f..ae4a7d8 100644 --- a/util/ShellTree.cpp +++ b/util/ShellTree.cpp @@ -25,14 +25,7 @@ BEGIN_MESSAGE_MAP(ShellTree, CTreeCtrl) END_MESSAGE_MAP() -/* - * Replace a CTreeCtrl in a dialog box with us. All of the styles are - * copied from the original dialog window. - * - * Returns TRUE on success, FALSE on failure. - */ -BOOL -ShellTree::ReplaceDlgCtrl(CDialog* pDialog, int treeID) +BOOL ShellTree::ReplaceDlgCtrl(CDialog* pDialog, int treeID) { CWnd* pWnd = pDialog->GetDlgItem(treeID); if (pWnd == NULL) @@ -55,13 +48,7 @@ ShellTree::ReplaceDlgCtrl(CDialog* pDialog, int treeID) return TRUE; } -/* - * Populate the tree, starting from "nFolder". - * - * Returns TRUE on success, FALSE on failure. - */ -BOOL -ShellTree::PopulateTree(int nFolder) +BOOL ShellTree::PopulateTree(int nFolder) { LPSHELLFOLDER lpsf = NULL, lpsf2 = NULL; LPITEMIDLIST lpi = NULL; @@ -121,11 +108,7 @@ bail: return retval; } -/* - * Open up and select My Computer. - */ -void -ShellTree::ExpandMyComputer(void) +void ShellTree::ExpandMyComputer(void) { HTREEITEM hItem; hItem = FindMyComputer(); @@ -135,17 +118,7 @@ ShellTree::ExpandMyComputer(void) Select(hItem, TVGN_CARET); } - -/* - * Fills a branch of the TreeView control. Given the shell folder (both as - * a shell folder and the fully-qualified item ID list to it) and the parent - * item in the tree (TVI_ROOT to start off), add all the kids to the tree. - * - * Does not try to add the current entry, as a result of which we don't - * have a root "Desktop" node that everything is a child of. This is okay. - */ -void -ShellTree::FillTreeView(LPSHELLFOLDER lpsf, LPITEMIDLIST lpifq, +void ShellTree::FillTreeView(LPSHELLFOLDER lpsf, LPITEMIDLIST lpifq, HTREEITEM hParent) { CWaitCursor wait; @@ -323,13 +296,7 @@ Done: //LOGI("FillTreeView DONE"); } -/* - * Add a node to the tree. - * - * Returns TRUE on success, FALSE on failure. - */ -BOOL -ShellTree::AddNode(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, LPITEMIDLIST lpifq, +BOOL ShellTree::AddNode(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, LPITEMIDLIST lpifq, unsigned long ulAttrs, HTREEITEM hParent, HTREEITEM* phPrev) { TVITEM tvi; @@ -411,14 +378,7 @@ bail: return result; } -/* - * Set the TreeView normal and selected icons for the specified entry. - * - * "lpifq" is the fully-qualified PIDL, LPTV_ITEM is an item in the tree. - */ -void -ShellTree::GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, - LPTV_ITEM lptvitem) +void ShellTree::GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTV_ITEM lptvitem) { //Note that we don't check the return value here because if GetIcon() //fails, then we're in big trouble... @@ -435,13 +395,8 @@ ShellTree::GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, return; } - - -/* - * Sort function callback for TreeView SortChildrenCB. - */ -int CALLBACK -ShellTree::TreeViewCompareProc(LPARAM lparam1, LPARAM lparam2, LPARAM) +/*static*/ int CALLBACK ShellTree::TreeViewCompareProc(LPARAM lparam1, + LPARAM lparam2, LPARAM) { TVItemData* lptvid1 = (TVItemData*)lparam1; TVItemData* lptvid2 = (TVItemData*)lparam2; @@ -473,16 +428,7 @@ ShellTree::TreeViewCompareProc(LPARAM lparam1, LPARAM lparam2, LPARAM) return (short) HRESULT_CODE(hr); } - -/* - * Add a new folder to the tree at the currently-selected node. This may - * not actually add a folder if the new folder is at a point in the tree - * below where we have already expanded. - * - * Returns TRUE on success, or FALSE on failure. - */ -BOOL -ShellTree::AddFolderAtSelection(const CString& name) +BOOL ShellTree::AddFolderAtSelection(const CString& name) { LPSHELLFOLDER lpsf = NULL; LPITEMIDLIST lpi = NULL; @@ -607,12 +553,6 @@ bail: return result; } - -/* - * Respond to TVN_ITEMEXPANDING message. - * - * If the subtree hasn't been expanded yet, dig in. - */ void ShellTree::OnFolderExpanding(NMHDR* pNMHDR, LRESULT* pResult) { TVItemData* lptvid; //Long pointer to TreeView item data @@ -691,24 +631,14 @@ void ShellTree::GetContextMenu(NMHDR*, LRESULT* pResult) } #endif -/* - * Respond to TVN_SELCHANGED notification. - */ -BOOL -ShellTree::OnSelectionChange(NMHDR* pnmh, LRESULT* pResult) +BOOL ShellTree::OnSelectionChange(NMHDR* pnmh, LRESULT* pResult) { fFolderPathValid = OnFolderSelected(pnmh, pResult, fFolderPath); *pResult = 0; return FALSE; // allow window parent to handle notification } -/* - * This does the bulk of the work when the selection changes. - * - * The filesystem path (if any) to the object is placed in "szFolderPath". - */ -BOOL -ShellTree::OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult, +BOOL ShellTree::OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult, CString &szFolderPath) { TVItemData* lptvid; @@ -780,11 +710,7 @@ ShellTree::OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult, return bRet; } -/* - * Handle TVN_DELETEITEM notification by cleaning up our stuff. - */ -void -ShellTree::OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult) +void ShellTree::OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult) { TVItemData* lptvid=NULL; HRESULT hr; @@ -809,14 +735,7 @@ ShellTree::OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult) *pResult = 0; } -/* - * Gets a handle to the system image list (by just grabbing whatever is - * in place for C:\) and makes it available to the tree control. - * - * The image list should NOT be deleted. - */ -void -ShellTree::EnableImages() +void ShellTree::EnableImages() { // Get the handle to the system image list, for our icons HIMAGELIST hImageList; @@ -832,18 +751,6 @@ ShellTree::EnableImages() (LPARAM)hImageList); } -/**************************************************************************** -* -* FUNCTION: GetSelectedFolderPath(CString &szFolderPath) -* -* PURPOSE: Retrieves the path of the currently selected string. -* Pass a CString object that will hold the folder path. -* If the path is not in the filesystem(eg MyComputer) -* or none is selected it returns false. -* -* MESSAGEMAP: NONE -* -****************************************************************************/ BOOL ShellTree::GetSelectedFolderPath(CString &szFolderPath) { TVItemData* lptvid; //Long pointer to TreeView item data @@ -887,16 +794,6 @@ BOOL ShellTree::GetSelectedFolderPath(CString &szFolderPath) return bRet; } -/**************************************************************************** -* -* FUNCTION: GetParentShellFolder(HTREEITEM folderNode) -* -* PURPOSE: Retrieves the pointer to the ISHELLFOLDER interface -* of the tree node passed as the paramter. -* -* MESSAGEMAP: NONE -* -****************************************************************************/ LPSHELLFOLDER ShellTree::GetParentShellFolder(HTREEITEM folderNode) { TVItemData* lptvid; //Long pointer to TreeView item data @@ -908,17 +805,6 @@ LPSHELLFOLDER ShellTree::GetParentShellFolder(HTREEITEM folderNode) return NULL; } -/**************************************************************************** -* -* FUNCTION: GetRelativeIDLIST(HTREEITEM folderNode) -* -* PURPOSE: Retrieves the Pointer to an ITEMIDLIST structure that -* identifies the subfolder relative to its parent folder. -* see GetParentShellFolder(); -* -* MESSAGEMAP: NONE -* -****************************************************************************/ LPITEMIDLIST ShellTree::GetRelativeIDLIST(HTREEITEM folderNode) { TVItemData* lptvid; //Long pointer to TreeView item data @@ -930,17 +816,6 @@ LPITEMIDLIST ShellTree::GetRelativeIDLIST(HTREEITEM folderNode) return NULL; } -/**************************************************************************** -* -* FUNCTION: GetFullyQualifiedIDLIST(HTREEITEM folderNode) -* -* PURPOSE: Retrieves the Pointer to an ITEMIDLIST -* structure that identifies the subfolder relative to the -* desktop. This is a fully qualified Item Identifier -* -* MESSAGEMAP: NONE -* -****************************************************************************/ LPITEMIDLIST ShellTree::GetFullyQualifiedID(HTREEITEM folderNode) { TVItemData* lptvid; //Long pointer to TreeView item data @@ -952,26 +827,18 @@ LPITEMIDLIST ShellTree::GetFullyQualifiedID(HTREEITEM folderNode) return NULL; } - -/* - * Tunnel into the tree, finding the node that corresponds to the - * requested pathname. - * - * Sets "resultMsg" to a non-empty string on error. - */ -void -ShellTree::TunnelTree(CString path, CString* pResultStr) +void ShellTree::TunnelTree(CString path, CString* pResultStr) { const WCHAR* str = path; int len; if (str[0] == '\\' && str[1] == '\\') { - *pResultStr = "Can't expand network locations directly."; + *pResultStr = L"Can't expand network locations directly."; return; } len = path.GetLength(); if (len < 1) { - *pResultStr = "You must enter a folder name."; + *pResultStr = L"You must enter a folder name."; return; } @@ -1023,24 +890,21 @@ ShellTree::TunnelTree(CString path, CString* pResultStr) } } -/* - * Find the tree entry that corresponds to "My Computer". - * - * This is hampered somewhat by the absence of a way to compare two - * shell folders for equality. The PIDL compare function is meant for - * sorting only (at least as far as it has been documented), and the My - * Computer "folder" has no path to examine. - * - * It helps greatly to assume that My Computer is right under Desktop. - * If it moved, or if we started the tree somewhere other than right at - * the desktop, we'd have to recursively search the tree. - * - * Returns a handle to the tree item, or NULL if My Computer wasn't found - * or didn't have any children. - */ -HTREEITEM -ShellTree::FindMyComputer(void) +HTREEITEM ShellTree::FindMyComputer(void) { + /* + * Find the tree entry that corresponds to "My Computer". + * + * This is hampered somewhat by the absence of a way to compare two + * shell folders for equality. The PIDL compare function is meant for + * sorting only (at least as far as it has been documented), and the My + * Computer "folder" has no path to examine. + * + * It helps greatly to assume that My Computer is right under Desktop. + * If it moved, or if we started the tree somewhere other than right at + * the desktop, we'd have to recursively search the tree. + */ + LPSHELLFOLDER desktop = NULL; LPITEMIDLIST myComputerPidl = NULL; LPMALLOC lpMalloc = NULL; @@ -1088,15 +952,7 @@ bail: return result; } -/* - * Given a pointer to the My Computer node in the tree, find the node - * corresponding to the requested drive (which should be of the form - * "C:"). - * - * Returns a pointer to the drive's node on success, or NULL on failure. - */ -HTREEITEM -ShellTree::FindDrive(HTREEITEM myComputer, const CString& drive) +HTREEITEM ShellTree::FindDrive(HTREEITEM myComputer, const CString& drive) { CString udrive; @@ -1135,17 +991,9 @@ ShellTree::FindDrive(HTREEITEM myComputer, const CString& drive) return node; } -/* - * Given a path, search a subtree following the components. - * - * Pass in the tree's root (it's children will be searched for a - * match with the first path component) and the path to look for - * (which must start and end with '\\'). - */ -HTREEITEM -ShellTree::SearchTree(HTREEITEM treeNode, const CString& path) +HTREEITEM ShellTree::SearchTree(HTREEITEM treeNode, const CString& path) { - LOGI("SearchTree node=0x%p path='%ls'", treeNode, (LPCWSTR) path); + LOGD("SearchTree node=0x%p path='%ls'", treeNode, (LPCWSTR) path); HTREEITEM node; CString mangle(path); diff --git a/util/ShellTree.h b/util/ShellTree.h index ea1dcef..3603d39 100644 --- a/util/ShellTree.h +++ b/util/ShellTree.h @@ -28,17 +28,80 @@ public: Detach(); // we don't own the window handle } + /* + * Replace a CTreeCtrl in a dialog box with us. All of the styles are + * copied from the original dialog window. + * + * Returns TRUE on success, FALSE on failure. + */ BOOL ReplaceDlgCtrl(CDialog* pDialog, int treeID); + + /* + * Populate the tree, starting from "nFolder". + * + * Returns TRUE on success, FALSE on failure. + */ BOOL PopulateTree(int nFolder = CSIDL_DESKTOP); + + /* + * Open up and select My Computer. + */ void ExpandMyComputer(void); + + /* + * Add a new folder to the tree at the currently-selected node. This may + * not actually add a folder if the new folder is at a point in the tree + * below where we have already expanded. + * + * Returns TRUE on success, or FALSE on failure. + */ BOOL AddFolderAtSelection(const CString& name); + void GetContextMenu(NMHDR* pNMHDR, LRESULT* pResult); + + /* + * Gets a handle to the system image list (by just grabbing whatever is + * in place for C:\) and makes it available to the tree control. + * + * The image list should NOT be deleted. + */ void EnableImages(); + + /* + * Retrieves the path of the currently selected string. + * Pass a CString object that will hold the folder path. + * If the path is not in the filesystem(eg MyComputer) + * or none is selected it returns false. + */ BOOL GetSelectedFolderPath(CString &szFolderPath); + + /* + * Retrieves the pointer to the ISHELLFOLDER interface + * of the tree node passed as the parameter. + */ + LPSHELLFOLDER GetParentShellFolder(HTREEITEM folderNode); + + /* + * Retrieves the Pointer to an ITEMIDLIST structure that + * identifies the subfolder relative to its parent folder. + * see GetParentShellFolder(); + */ + LPITEMIDLIST GetRelativeIDLIST(HTREEITEM folderNode); + + /* + * Retrieves the Pointer to an ITEMIDLIST + * structure that identifies the subfolder relative to the + * desktop. This is a fully qualified Item Identifier + */ + LPITEMIDLIST GetFullyQualifiedID(HTREEITEM folderNode); + + /* + * Tunnel into the tree, finding the node that corresponds to the + * requested pathname. + * + * Sets "resultMsg" to a non-empty string on error. + */ void TunnelTree(CString path, CString* pResultStr); - LPSHELLFOLDER GetParentShellFolder(HTREEITEM folderNode); - LPITEMIDLIST GetRelativeIDLIST(HTREEITEM folderNode); - LPITEMIDLIST GetFullyQualifiedID(HTREEITEM folderNode); // Get the most-recently-set folder path. This will be updated on // every TVN_SELCHANGED, so add an ON_NOTIFY handler to the parent. @@ -48,19 +111,85 @@ public: } protected: + /* + * Respond to TVN_ITEMEXPANDING message. + * + * If the subtree hasn't been expanded yet, dig in. + */ void OnFolderExpanding(NMHDR* pNMHDR, LRESULT* pResult); + + /* + * Handle TVN_DELETEITEM notification by cleaning up our stuff. + */ void OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult); - BOOL OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult, - CString& szFolderPath); + + /* + * Respond to TVN_SELCHANGED notification. + */ BOOL OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult); + /* + * This does the bulk of the work when the selection changes. + * + * The filesystem path (if any) to the object is placed in "szFolderPath". + */ + BOOL OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult, + CString& szFolderPath); + + /* + * Fills a branch of the TreeView control. Given the shell folder (both as + * a shell folder and the fully-qualified item ID list to it) and the parent + * item in the tree (TVI_ROOT to start off), add all the kids to the tree. + * + * Does not try to add the current entry, as a result of which we don't + * have a root "Desktop" node that everything is a child of. This is okay. + */ void FillTreeView(LPSHELLFOLDER lpsf,LPITEMIDLIST lpifq, HTREEITEM hParent); + + /* + * Add a node to the tree. + * + * Returns TRUE on success, FALSE on failure. + */ BOOL AddNode(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, LPITEMIDLIST lpifq, unsigned long ulAttrs, HTREEITEM hParent, HTREEITEM* phPrev); + + /* + * Sort function callback for TreeView SortChildrenCB. + */ static int CALLBACK TreeViewCompareProc(LPARAM, LPARAM, LPARAM); + + /* + * Set the TreeView normal and selected icons for the specified entry. + * + * "lpifq" is the fully-qualified PIDL, LPTV_ITEM is an item in the tree. + */ void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTV_ITEM lptvitem); + + /* + * Find the tree entry that corresponds to "My Computer". + * + * Returns a handle to the tree item, or NULL if My Computer wasn't found + * or didn't have any children. + */ HTREEITEM FindMyComputer(void); + + /* + * Given a pointer to the My Computer node in the tree, find the node + * corresponding to the requested drive (which should be of the form + * "C:"). + * + * Returns a pointer to the drive's node on success, or NULL on failure. + */ HTREEITEM FindDrive(HTREEITEM myComputer, const CString& drive); + + /* + * Given a path, search a subtree following the components. + * + * Pass in the tree's root (it's children will be searched for a + * match with the first path component) and the path to look for + * (which must start and end with '\\'). + */ HTREEITEM SearchTree(HTREEITEM treeNode, const CString& path); /* diff --git a/util/SoundFile.cpp b/util/SoundFile.cpp index 0fc5de9..a7bbe47 100644 --- a/util/SoundFile.cpp +++ b/util/SoundFile.cpp @@ -21,13 +21,12 @@ * The constant is expected to match 4-character values read from a binary * file, so the value is endian-dependent. */ -static inline unsigned long -MakeFourCC(unsigned char c0, unsigned char c1, unsigned char c2, - unsigned char c3) +static inline uint32_t MakeFourCC(uint8_t c0, uint8_t c1, uint8_t c2, + uint8_t c3) { /* little-endian */ - return ((unsigned long)c0) | ((unsigned long)c1 << 8) | - ((unsigned long)c2 << 16) | ((unsigned long)c3 << 24); + return ((uint32_t)c0) | ((uint32_t)c1 << 8) | + ((uint32_t)c2 << 16) | ((uint32_t)c3 << 24); } /* @@ -35,8 +34,7 @@ MakeFourCC(unsigned char c0, unsigned char c1, unsigned char c2, * * Returns 0 on success. */ -int -SoundFile::Create(const WCHAR* fileName, CString* pErrMsg) +int SoundFile::Create(const WCHAR* fileName, CString* pErrMsg) { FILE* fp = NULL; long fileLen; @@ -61,19 +59,18 @@ SoundFile::Create(const WCHAR* fileName, CString* pErrMsg) * * Returns 0 on success. */ -int -SoundFile::Create(FILE* fp, long len, bool doClose, CString* pErrMsg) +int SoundFile::Create(FILE* fp, long len, bool doClose, CString* pErrMsg) { struct { - unsigned long riff; - unsigned long fileLen; - unsigned long wav; + uint32_t riff; + uint32_t fileLen; + uint32_t wav; } fileHeader; - unsigned long chunkLen; + uint32_t chunkLen; int err = 0; if (mFP != NULL) { - LOGI("SoundFile object already created"); + LOGW("SoundFile object already created"); assert(false); return -1; } @@ -99,7 +96,7 @@ SoundFile::Create(FILE* fp, long len, bool doClose, CString* pErrMsg) } if (fileHeader.riff != MakeFourCC('R','I','F','F') || fileHeader.wav != MakeFourCC('W','A','V','E') || - fileHeader.fileLen > (unsigned long) len) + fileHeader.fileLen > (uint32_t) len) { *pErrMsg = L"File is not a WAV file"; LOGI("Not a valid WAV header (0x%08lx %d 0x%08lx)", @@ -154,10 +151,10 @@ SoundFile::Create(FILE* fp, long len, bool doClose, CString* pErrMsg) mSampleStart = ftell(mFP); mSampleLen = chunkLen; - LOGI("WAV: chan=%d samples/sec=%d avgBPS=%d block=%d", + LOGD("WAV: chan=%d samples/sec=%d avgBPS=%d block=%d", mFormat.nChannels, mFormat.nSamplesPerSec, mFormat.nAvgBytesPerSec, mFormat.nBlockAlign); - LOGI(" bits/sample=%d [start=%d len=%d]", mFormat.wBitsPerSample, + LOGD(" bits/sample=%d [start=%d len=%d]", mFormat.wBitsPerSample, mSampleStart, mSampleLen); bail: @@ -168,12 +165,11 @@ bail: * Skip forward until we find the named chunk. The file should be * positioned immediately before the first chunk. */ -int -SoundFile::SkipToHeader(unsigned long hdrID, unsigned long* pChunkLen) +int SoundFile::SkipToHeader(uint32_t hdrID, uint32_t* pChunkLen) { struct { - unsigned long fourcc; - unsigned long chunkLen; + uint32_t fourcc; + uint32_t chunkLen; } chunkHeader; int err = 0; @@ -205,10 +201,9 @@ SoundFile::SkipToHeader(unsigned long hdrID, unsigned long* pChunkLen) /* * Read a block of data from the specified offset. */ -int -SoundFile::ReadData(void* buf, long sampleOffset, long len) const +int SoundFile::ReadData(void* buf, long sampleOffset, long len) const { - if ((unsigned long)(sampleOffset+len) > mSampleLen) { + if ((uint32_t)(sampleOffset+len) > mSampleLen) { LOGI("ERROR: invalid read request (%d bytes, %d into %d)", len, sampleOffset, mSampleLen); return -1; diff --git a/util/SoundFile.h b/util/SoundFile.h index 95e6727..c78f03b 100644 --- a/util/SoundFile.h +++ b/util/SoundFile.h @@ -16,7 +16,7 @@ /* * Class providing read-only access to uncompressed sound samples and - * associated meta-data. The sound is assumed to fit in main memory. + * associated meta-data. The sound file is assumed to fit in main memory. * * Because game sound effects are generally loaded into "secondary sound * buffers" allocated by DirectX, this class doesn't load the sound data @@ -56,7 +56,7 @@ public: int SeekAbs(long offset) { return fseek(mFP, offset, SEEK_SET); } long GetDataOffset(void) const { return mSampleStart; } - unsigned long GetDataLen(void) const { return mSampleLen; } + uint32_t GetDataLen(void) const { return mSampleLen; } const WAVEFORMATEX* GetWaveFormat(void) { return &mFormat; } /* returns the #of bytes per sample (all channels) */ @@ -66,7 +66,7 @@ public: } private: - int SkipToHeader(unsigned long hdrID, unsigned long* pChunkLen); + int SkipToHeader(uint32_t hdrID, uint32_t* pChunkLen); enum { kWAVMinSize = 40 }; @@ -76,7 +76,7 @@ private: long mFileStart; // so we can rewind the sound file long mSampleStart; // offset in mem or file to sound samples - unsigned long mSampleLen; // length in bytes of audio sample section + uint32_t mSampleLen; // length in bytes of audio sample section WAVEFORMATEX mFormat; // WAV parameters (from mmsystem.h/mmreg.h) }; diff --git a/util/Util.cpp b/util/Util.cpp index ca35573..560c286 100644 --- a/util/Util.cpp +++ b/util/Util.cpp @@ -25,8 +25,7 @@ BEGIN_MESSAGE_MAP(CGripper, CScrollBar) ON_WM_NCHITTEST() END_MESSAGE_MAP() -LRESULT -CGripper::OnNcHitTest(CPoint point) +LRESULT CGripper::OnNcHitTest(CPoint point) { UINT ht = CScrollBar::OnNcHitTest(point); if (ht == HTCLIENT) { @@ -50,8 +49,8 @@ CGripper::OnNcHitTest(CPoint point) * * Returns 0 on success, nonzero on error. */ -DWORD -RichEditXfer::EditStreamCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG* pcb) +DWORD RichEditXfer::EditStreamCallback(DWORD dwCookie, LPBYTE pbBuff, + LONG cb, LONG* pcb) { RichEditXfer* pThis = (RichEditXfer*) dwCookie; @@ -87,11 +86,7 @@ bail: * =========================================================================== */ -/* - * Allocate the initial buffer. - */ -int -ExpandBuffer::CreateWorkBuf(void) +int ExpandBuffer::CreateWorkBuf(void) { if (fWorkBuf != NULL) { ASSERT(fWorkMax > 0); @@ -110,36 +105,24 @@ ExpandBuffer::CreateWorkBuf(void) return 0; } -/* - * Let the caller seize control of our buffer. We throw away our pointer to - * the buffer so we don't free it. - */ -void -ExpandBuffer::SeizeBuffer(char** ppBuf, long* pLen) +void ExpandBuffer::SeizeBuffer(char** ppBuf, long* pLen) { *ppBuf = fWorkBuf; *pLen = fWorkCount; - fWorkBuf = NULL; + fWorkBuf = NULL; // discard pointer so we don't free it fWorkCount = 0; fWorkMax = 0; } -/* - * Grow the buffer to the next incremental size. We keep doubling it until - * we reach out maximum rate of expansion. - * - * Returns 0 on success, -1 on failure. - */ -int -ExpandBuffer::GrowWorkBuf(void) +int ExpandBuffer::GrowWorkBuf(void) { int newIncr = fWorkMax; if (newIncr > kWorkBufMaxIncrement) newIncr = kWorkBufMaxIncrement; - //LOGI("Extending buffer by %d (count=%d, max=%d)", - // newIncr, fWorkCount, fWorkMax); + LOGV("Extending buffer by %d (count=%d, max=%d)", + newIncr, fWorkCount, fWorkMax); fWorkMax += newIncr; @@ -148,7 +131,7 @@ ExpandBuffer::GrowWorkBuf(void) char* newBuf = new char[fWorkMax]; if (newBuf == NULL) { - LOGI("ALLOC FAILURE (%ld)", fWorkMax); + LOGE("ALLOC FAILURE (%ld)", fWorkMax); ASSERT(false); fWorkMax -= newIncr; // put it back so we don't overrun return -1; @@ -161,11 +144,7 @@ ExpandBuffer::GrowWorkBuf(void) return 0; } -/* - * Write binary data to the buffer. - */ -void -ExpandBuffer::Write(const unsigned char* buf, long len) +void ExpandBuffer::Write(const unsigned char* buf, long len) { if (fWorkBuf == NULL) CreateWorkBuf(); @@ -178,20 +157,12 @@ ExpandBuffer::Write(const unsigned char* buf, long len) fWorkCount += len; } -/* - * Write one character into the buffer. - */ -void -ExpandBuffer::Putc(char ch) +void ExpandBuffer::Putc(char ch) { Write((const unsigned char*) &ch, 1); } -/* - * Print a formatted string into the buffer. - */ -void -ExpandBuffer::Printf(const char* format, ...) +void ExpandBuffer::Printf(_Printf_format_string_ const char* format, ...) { va_list args; @@ -232,11 +203,7 @@ ExpandBuffer::Printf(const char* format, ...) * =========================================================================== */ -/* - * Enable or disable a control. - */ -void -EnableControl(CDialog* pDlg, int id, bool enable) +void EnableControl(CDialog* pDlg, int id, bool enable) { CWnd* pWnd = pDlg->GetDlgItem(id); if (pWnd == NULL) { @@ -247,12 +214,7 @@ EnableControl(CDialog* pDlg, int id, bool enable) } } -/* - * Move a control so it maintains its same position relative to the bottom - * and right edges. - */ -void -MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw) +void MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw) { CWnd* pWnd; CRect rect; @@ -271,11 +233,7 @@ MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw) pWnd->MoveWindow(&rect, redraw); } -/* - * Make a control larger by the same delta as the parent window. - */ -void -StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw) +void StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw) { CWnd* pWnd; CRect rect; @@ -292,9 +250,6 @@ StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw) pWnd->MoveWindow(&rect, redraw); } -/* - * Stretch and move a control. - */ void MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY, int stretchX, int stretchY, bool redraw) @@ -303,12 +258,7 @@ MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY, StretchControl(pDlg, id, stretchX, stretchY, redraw); } -/* - * Move a control so it maintains its same position relative to the bottom - * and right edges. - */ -HDWP -MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, +HDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw) { CWnd* pWnd; @@ -331,11 +281,7 @@ MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, return hdwp; } -/* - * Make a control larger by the same delta as the parent window. - */ -HDWP -StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, +HDWP StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw) { CWnd* pWnd; @@ -356,11 +302,7 @@ StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, return hdwp; } -/* - * Stretch and move a control. - */ -HDWP -MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY, +HDWP MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY, int stretchX, int stretchY, bool redraw) { CWnd* pWnd; @@ -385,11 +327,7 @@ MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY, return hdwp; } -/* - * Get/set the check state of a button in a dialog. - */ -int -GetDlgButtonCheck(CWnd* pWnd, int id) +int GetDlgButtonCheck(CWnd* pWnd, int id) { CButton* pButton; pButton = (CButton*) pWnd->GetDlgItem(id); @@ -398,8 +336,8 @@ GetDlgButtonCheck(CWnd* pWnd, int id) return -1; return pButton->GetCheck(); } -void -SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal) + +void SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal) { CButton* pButton; pButton = (CButton*) pWnd->GetDlgItem(id); @@ -409,12 +347,7 @@ SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal) pButton->SetCheck(checkVal); } - -/* - * Create a font, using defaults for most things. - */ -void -CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace, +void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace, int pointSize) { CClientDC dc(pWnd); @@ -426,11 +359,7 @@ CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, typeFace); } -/* - * Get a Win32 error string for an error code returned by GetLastError. - */ -void -GetWin32ErrorString(DWORD err, CString* pStr) +void GetWin32ErrorString(DWORD err, CString* pStr) { DWORD count; LPVOID lpMsgBuf; @@ -457,11 +386,7 @@ GetWin32ErrorString(DWORD err, CString* pStr) } } -/* - * Post a failure message. - */ -void -ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID) +void ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID) { CString failed; @@ -469,22 +394,13 @@ ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID) pWnd->MessageBox(msg, failed, MB_OK | MB_ICONERROR); } -/* - * Show context help, based on the control ID. - */ -BOOL -ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo) +BOOL ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo) { pWnd->WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); return TRUE; } -/* - * Returns "true" if we're running on Win9x (Win95, Win98, WinME), "false" - * if not (could be WinNT/2K/XP or even Win31 with Win32s). - */ -bool -IsWin9x(void) +bool IsWin9x(void) { OSVERSIONINFO osvers; BOOL result; @@ -506,13 +422,7 @@ IsWin9x(void) * =========================================================================== */ -/* - * Pull a pascal string out of a buffer and stuff it into "*pStr". - * - * Returns the length of the string found, or -1 on error. - */ -int -GetPascalString(const uint8_t* buf, long maxLen, CString* pStr) +int GetPascalString(const uint8_t* buf, long maxLen, CString* pStr) { int len = *buf++; int retLen = len; @@ -537,11 +447,7 @@ GetPascalString(const uint8_t* buf, long maxLen, CString* pStr) return retLen; } -/* - * Dump a block of stuff to the log file. - */ -void -LogHexDump(const void* vbuf, long len) +void LogHexDump(const void* vbuf, long len) { const unsigned char* buf = (const unsigned char*) vbuf; char outBuf[10 + 16*3 +1 +8]; // addr: 00 11 22 ... + 8 bytes slop @@ -586,11 +492,7 @@ LogHexDump(const void* vbuf, long len) LOGI(" %hs", outBuf); } -/* - * Compute a percentage. - */ -int -ComputePercent(LONGLONG part, LONGLONG full) +int ComputePercent(LONGLONG part, LONGLONG full) { LONGLONG perc; @@ -609,14 +511,7 @@ ComputePercent(LONGLONG part, LONGLONG full) return (int) perc; } -/* - * Format a time_t into a string. - * - * (Should take format as an argument, so we can use global format set by - * user preferences.) - */ -void -FormatDate(time_t when, CString* pStr) +void FormatDate(time_t when, CString* pStr) { if (when == kDateNone) { *pStr = L"[No Date]"; @@ -628,15 +523,7 @@ FormatDate(time_t when, CString* pStr) } } -/* - * Case-insensitive version of strstr(), pulled from the MSDN stuff that - * comes with VC++6.0. - * - * The isalpha() stuff is an optimization, so they can skip the tolower() - * in the outer loop comparison. - */ -const WCHAR* -Stristr(const WCHAR* string1, const WCHAR* string2) +const WCHAR* Stristr(const WCHAR* string1, const WCHAR* string2) { WCHAR *cp1 = (WCHAR*)string1, *cp2, *cp1a; WCHAR first; // get the first char in string to find @@ -679,20 +566,7 @@ Stristr(const WCHAR* string1, const WCHAR* string2) return NULL; } - -/* - * Break a string down into its component parts. - * - * "mangle" will be mangled (various bits stomped by '\0'), "argv" will - * receive pointers to the strings, and "*pArgc" will hold the number of - * arguments in the vector. The initial value of "*pArgc" should hold the - * maximum "argv" capacity (including program name in argv[0]). - * - * The argv pointers will point into "mangle"; no new storage will be - * allocated. - */ -void -VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc) +void VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc) { bool inWhiteSpace = true; bool inQuote = false; @@ -737,13 +611,11 @@ VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc) *pArgc = idx; } - /* * Convert a sub-string to lower case according to rules for English book * titles. Assumes the initial string is in all caps. */ -static void -DowncaseSubstring(CString* pStr, int startPos, int endPos, +static void DowncaseSubstring(CString* pStr, int startPos, int endPos, bool prevWasSpace) { static const WCHAR* shortWords[] = { @@ -806,13 +678,7 @@ DowncaseSubstring(CString* pStr, int startPos, int endPos, } } -/* - * Convert parts of the filename to lower case. - * - * If the name already has lowercase characters, do nothing. - */ -void -InjectLowercase(CString* pStr) +void InjectLowercase(CString* pStr) { int len = pStr->GetLength(); static const WCHAR* kGapChars = L" .:&-+/\\()<>@*"; @@ -865,13 +731,7 @@ InjectLowercase(CString* pStr) } } - -/* - * Test to see if a sub-string matches a value in a set of strings. The set - * comes from a semicolon-delimited string. - */ -bool -MatchSemicolonList(const CString set, const CString match) +bool MatchSemicolonList(const CString set, const CString match) { const WCHAR* cp; CString mangle(set); @@ -899,14 +759,7 @@ MatchSemicolonList(const CString set, const CString match) return false; } - -/* - * Like strcpy(), but allocate with new[] instead. - * - * If "str" is NULL, or "new" fails, this returns NULL. - */ -char* -StrcpyNew(const char* str) +char* StrcpyNew(const char* str) { char* newStr; diff --git a/util/Util.h b/util/Util.h index 6dab8fb..105b90b 100644 --- a/util/Util.h +++ b/util/Util.h @@ -9,6 +9,8 @@ #ifndef UTIL_UTIL_H #define UTIL_UTIL_H +#include + /* * Gripper for a resizable window. */ @@ -53,6 +55,10 @@ public: delete[] fWorkBuf; } } + + /* + * Allocate the initial buffer. + */ virtual int CreateWorkBuf(void); void Reset(void) { @@ -62,7 +68,7 @@ public: } // Copy printf-formatted output into the output buffer. - void Printf(const char* format, ...); + void Printf(_Printf_format_string_ const char* format, ...); // Write binary data to the buffer. void Write(const unsigned char* buf, long len); @@ -75,6 +81,12 @@ public: virtual void SeizeBuffer(char** ppBuf, long* pLen); protected: + /* + * Grow the buffer to the next incremental size. We keep doubling it until + * we reach out maximum rate of expansion. + * + * Returns 0 on success, -1 on failure. + */ virtual int GrowWorkBuf(void); enum { @@ -89,41 +101,165 @@ protected: /* - * Windows helpers. + * ==================================== + * Windows helpers + * ==================================== */ -void EnableControl(CDialog* pDlg, int id, bool enable=true); -void MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, - bool redraw = true); -void StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, - bool redraw = true); -void MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY, - int stretchX, int stretchY, bool redraw = true); -HDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, - bool redraw = true); -HDWP StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, - bool redraw = true); -HDWP MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY, - int stretchX, int stretchY, bool redraw = true); -int GetDlgButtonCheck(CWnd* pWnd, int id); -void SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal); -void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace, - int pointSize); -void GetWin32ErrorString(DWORD err, CString* pStr); -void ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID); -BOOL ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo); -bool IsWin9x(void); /* - * Miscellaneous functions. + * Enable or disable a control. + */ +void EnableControl(CDialog* pDlg, int id, bool enable=true); + +/* + * Move a control so it maintains its same position relative to the bottom + * and right edges. + */ +void MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, + bool redraw = true); + +/* + * Make a control larger by the same delta as the parent window. + */ +void StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, + bool redraw = true); + +/* + * Stretch and move a control. + */ +void MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY, + int stretchX, int stretchY, bool redraw = true); + +/* + * Move a control so it maintains its same position relative to the bottom + * and right edges. + */ +HDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, + bool redraw = true); + +/* + * Make a control larger by the same delta as the parent window. + */ +HDWP StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY, + bool redraw = true); + +/* + * Stretch and move a control. + */ +HDWP MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY, + int stretchX, int stretchY, bool redraw = true); + +/* + * Get the check state of a button in a dialog. + */ +int GetDlgButtonCheck(CWnd* pWnd, int id); + +/* + * Set the check state of a button in a dialog. + */ +void SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal); + +/* + * Create a font, using defaults for most things. + */ +void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace, + int pointSize); + +/* + * Get a Win32 error string for an error code returned by GetLastError. + */ +void GetWin32ErrorString(DWORD err, CString* pStr); + +/* + * Post a failure message in a message box. + */ +void ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID); + +/* + * Show context help, based on the control ID. + */ +BOOL ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo); + +/* + * Returns "true" if we're running on Win9x (Win95, Win98, WinME), "false" + * if not (could be WinNT/2K/XP or even Win31 with Win32s). + */ +bool IsWin9x(void); + + +/* + * ==================================== + * Miscellaneous functions + * ==================================== + */ + +/* + * Pull a pascal string out of a buffer and stuff it into "*pStr". + * + * Returns the length of the string found, or -1 on error. */ int GetPascalString(const uint8_t* buf, long maxLen, CString* pStr); + +/* + * Dump a block of stuff to the log file. + */ void LogHexDump(const void* buf, long len); + +/* + * Compute a percentage. + */ int ComputePercent(LONGLONG part, LONGLONG full); + +/* + * Format a time_t into a string. + * + * (Should take format as an argument, so we can use global format set by + * user preferences.) + */ void FormatDate(time_t when, CString* pStr); + +/* + * Case-insensitive version of strstr(), pulled from the MSDN stuff that + * comes with VC++6.0. + * + * The isalpha() stuff is an optimization, so they can skip the tolower() + * in the outer loop comparison. + */ const WCHAR* Stristr(const WCHAR* string1, const WCHAR* string2); + +/* + * Break a string down into its component parts. + * + * "mangle" will be mangled (various bits stomped by '\0'), "argv" will + * receive pointers to the strings, and "*pArgc" will hold the number of + * arguments in the vector. The initial value of "*pArgc" should hold the + * maximum "argv" capacity (including program name in argv[0]). + * + * The argv pointers will point into "mangle"; no new storage will be + * allocated. + */ void VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc); + +/* + * Convert parts of the filename to lower case. + * + * If the name already has lowercase characters, do nothing. + */ void InjectLowercase(CString* pStr); + +/* + * Test to see if a sub-string matches a value in a set of strings. The set + * comes from a semicolon-delimited string. + */ bool MatchSemicolonList(const CString set, const CString match); + +/* + * Like strcpy(), but allocate with new[] instead. + * + * If "str" is NULL, or "new" fails, this returns NULL. + * + * TODO: this should be "StrdupNew()". + */ char* StrcpyNew(const char* str); /* time_t values for bad dates */