From a7c24ca48995cf2bf436156302f96b91bf135409 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Mon, 13 Nov 2017 15:03:31 +0100 Subject: Code modernize ... * replace 0/NULL with nullptr [using clang-tidy] --- plugins/PluginUpdater/src/DlgListNew.cpp | 38 +++++----- plugins/PluginUpdater/src/DlgUpdate.cpp | 112 ++++++++++++++-------------- plugins/PluginUpdater/src/Events.cpp | 4 +- plugins/PluginUpdater/src/Notifications.cpp | 6 +- plugins/PluginUpdater/src/Options.cpp | 4 +- plugins/PluginUpdater/src/PluginUpdater.cpp | 2 +- plugins/PluginUpdater/src/Services.cpp | 6 +- plugins/PluginUpdater/src/Utils.cpp | 78 +++++++++---------- plugins/PluginUpdater/src/checksum.cpp | 10 +-- plugins/PluginUpdater/src/unzipfile.cpp | 10 +-- 10 files changed, 135 insertions(+), 135 deletions(-) (limited to 'plugins/PluginUpdater/src') diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index 5ac1a40eb1..12c4853002 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -63,7 +63,7 @@ static void ApplyDownloads(void *param) VARSW tszMirandaPath(L"%miranda_path%"); - HNETLIBCONN nlc = NULL; + HNETLIBCONN nlc = nullptr; for (int i=0; i < todo.getCount(); ++i) { ListView_EnsureVisible(hwndList, i, FALSE); if (todo[i].bEnabled) { @@ -88,14 +88,14 @@ static void ApplyDownloads(void *param) int rc = MessageBox(hDlg, TranslateT("Download complete. Do you want to go to plugins option page?"), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION); if (rc == IDYES) - CallFunctionAsync(OpenPluginOptions, 0); + CallFunctionAsync(OpenPluginOptions, nullptr); PostMessage(hDlg, WM_CLOSE, 0, 0); } ///////////////////////////////////////////////////////////////////////////////////////// -static WNDPROC oldWndProc = NULL; +static WNDPROC oldWndProc = nullptr; static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -164,12 +164,12 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) OSVERSIONINFO osver = { sizeof(osver) }; if (GetVersionEx(&osver) && osver.dwMajorVersion >= 6) { wchar_t szPath[MAX_PATH]; - GetModuleFileName(NULL, szPath, _countof(szPath)); + GetModuleFileName(nullptr, szPath, _countof(szPath)); wchar_t *ext = wcsrchr(szPath, '.'); - if (ext != NULL) + if (ext != nullptr) *ext = '\0'; wcscat(szPath, L".test"); - HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) // Running Windows Vista or later (major version >= 6). Button_SetElevationRequiredState(GetDlgItem(hDlg, IDOK), !IsProcessElevated()); @@ -229,8 +229,8 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) lvi.mask = LVIF_PARAM | LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE; int groupId = 4; - if (wcschr(todo[i].tszOldName, L'\\') != NULL) - groupId = (wcsstr(todo[i].tszOldName, L"Plugins") != NULL) ? 1 : ((wcsstr(todo[i].tszOldName, L"Languages") != NULL) ? 3 : 2); + if (wcschr(todo[i].tszOldName, L'\\') != nullptr) + groupId = (wcsstr(todo[i].tszOldName, L"Plugins") != nullptr) ? 1 : ((wcsstr(todo[i].tszOldName, L"Languages") != nullptr) ? 3 : 2); lvi.iItem = i; lvi.lParam = (LPARAM)&todo[i]; @@ -330,7 +330,7 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_DESTROY: Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ListWindow"); Window_FreeIcon_IcoLib(hDlg); - hwndDialog = NULL; + hwndDialog = nullptr; delete (OBJLIST *)GetWindowLongPtr(hDlg, GWLP_USERDATA); SetWindowLongPtr(hDlg, GWLP_USERDATA, 0); break; @@ -364,7 +364,7 @@ static FILEINFO* ServerEntryToFileInfo(const ServListEntry &hash, const wchar_t* mir_snwprintf(FileInfo->File.tszDiskPath, L"%s\\Temp\\%s.zip", g_tszRoot, tszFileName); mir_snwprintf(FileInfo->File.tszDownloadURL, L"%s/%s.zip", tszBaseUrl, tszRelFileName); - for (tp = wcschr(FileInfo->File.tszDownloadURL, '\\'); tp != 0; tp = wcschr(tp, '\\')) + for (tp = wcschr(FileInfo->File.tszDownloadURL, '\\'); tp != nullptr; tp = wcschr(tp, '\\')) *tp++ = '/'; FileInfo->File.CRCsum = hash.m_crc; // Load list of checked Plugins from database @@ -388,7 +388,7 @@ static void GetList(void *) ptrW updateUrl( GetDefaultUrl()), baseUrl; SERVLIST hashes(50, CompareHashes); if (!ParseHashes(updateUrl, baseUrl, hashes)) { - hListThread = NULL; + hListThread = nullptr; return; } @@ -414,7 +414,7 @@ static void GetList(void *) } else CallFunctionAsync(LaunchListDialog, UpdateFiles); - hListThread = NULL; + hListThread = nullptr; } static void DoGetList() @@ -427,12 +427,12 @@ static void DoGetList() SetFocus(hwndDialog); } else - hListThread = mir_forkthread(GetList, 0); + hListThread = mir_forkthread(GetList, nullptr); } void UninitListNew() { - if (hwndDialog != NULL) + if (hwndDialog != nullptr) DestroyWindow(hwndDialog); } @@ -445,20 +445,20 @@ static INT_PTR ShowListCommand(WPARAM,LPARAM) void UnloadListNew() { if (hListThread) - hListThread = NULL; + hListThread = nullptr; } static INT_PTR ParseUriService(WPARAM, LPARAM lParam) { wchar_t *arg = (wchar_t *)lParam; - if (arg == NULL) + if (arg == nullptr) return 1; wchar_t uri[1024]; wcsncpy_s(uri, arg, _TRUNCATE); wchar_t *p = wcschr(uri, ':'); - if (p == NULL) + if (p == nullptr) return 1; wchar_t pluginPath[MAX_PATH]; @@ -472,12 +472,12 @@ static INT_PTR ParseUriService(WPARAM, LPARAM lParam) ptrW updateUrl(GetDefaultUrl()), baseUrl; SERVLIST hashes(50, CompareHashes); if (!ParseHashes(updateUrl, baseUrl, hashes)) { - hListThread = NULL; + hListThread = nullptr; return 1; } ServListEntry *hash = hashes.find((ServListEntry*)&pluginPath); - if (hash == NULL) + if (hash == nullptr) return 0; VARSW dirName(L"%miranda_path%"); diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 71f7a3c1e7..d228d9a239 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -67,7 +67,7 @@ static void ApplyUpdates(void *param) SafeCreateDirectory(tszFileTemp); // 2) Download all plugins - HNETLIBCONN nlc = NULL; + HNETLIBCONN nlc = nullptr; for (int i=0; i < todo.getCount(); i++) { ListView_EnsureVisible(hwndList, i, FALSE); if (!todo[i].bEnabled) { @@ -139,7 +139,7 @@ static void ApplyUpdates(void *param) if (opts.bChangePlatform) { wchar_t mirandaPath[MAX_PATH]; - GetModuleFileName(NULL, mirandaPath, _countof(mirandaPath)); + GetModuleFileName(nullptr, mirandaPath, _countof(mirandaPath)); db_set_ws(NULL, MODNAME, "OldBin2", mirandaPath); db_unset(NULL, MODNAME, DB_SETTING_CHANGEPLATFORM); @@ -186,7 +186,7 @@ static void ResizeVert(HWND hDlg, int yy) RECT r = { 0, 0, 244, yy }; MapDialogRect(hDlg, &r); r.bottom += GetSystemMetrics(SM_CYSMCAPTION); - SetWindowPos(hDlg, 0, 0, 0, r.right, r.bottom, SWP_NOMOVE | SWP_NOZORDER); + SetWindowPos(hDlg, nullptr, 0, 0, r.right, r.bottom, SWP_NOMOVE | SWP_NOZORDER); } static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) @@ -208,12 +208,12 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (GetVersionEx(&osver) && osver.dwMajorVersion >= 6) { wchar_t szPath[MAX_PATH]; - GetModuleFileName(NULL, szPath, _countof(szPath)); + GetModuleFileName(nullptr, szPath, _countof(szPath)); wchar_t *ext = wcsrchr(szPath, '.'); - if (ext != NULL) + if (ext != nullptr) *ext = '\0'; wcscat(szPath, L".test"); - HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) // Running Windows Vista or later (major version >= 6). Button_SetElevationRequiredState(GetDlgItem(hDlg, IDOK), !IsProcessElevated()); @@ -270,9 +270,9 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM for (int i = 0; i < todo.getCount(); ++i) { LVITEM lvI = {0}; lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_GROUPID | LVIF_NORECOMPUTE; - lvI.iGroupId = (wcsstr(todo[i].tszOldName, L"Plugins") != NULL) ? 1 : - ((wcsstr(todo[i].tszOldName, L"Languages") != NULL) ? 3 : - ((wcsstr(todo[i].tszOldName, L"Icons") != NULL) ? 4 : 2)); + lvI.iGroupId = (wcsstr(todo[i].tszOldName, L"Plugins") != nullptr) ? 1 : + ((wcsstr(todo[i].tszOldName, L"Languages") != nullptr) ? 3 : + ((wcsstr(todo[i].tszOldName, L"Icons") != nullptr) ? 4 : 2)); lvI.iSubItem = 0; lvI.lParam = (LPARAM)&todo[i]; lvI.pszText = todo[i].tszOldName; @@ -381,13 +381,13 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM case WM_DESTROY: Window_FreeIcon_IcoLib(hDlg); Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow"); - hwndDialog = NULL; + hwndDialog = nullptr; delete (OBJLIST *)GetWindowLongPtr(hDlg, GWLP_USERDATA); SetWindowLongPtr(hDlg, GWLP_USERDATA, 0); #if MIRANDA_VER >= 0x0A00 - db_set_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, time(NULL)); + db_set_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, time(nullptr)); #endif - mir_forkthread(InitTimer, 0); + mir_forkthread(InitTimer, nullptr); break; } @@ -421,7 +421,7 @@ static void DlgUpdateSilent(void *param) SafeCreateDirectory(tszFileTemp); // 2) Download all plugins - HNETLIBCONN nlc = NULL; + HNETLIBCONN nlc = nullptr; // Count all updates that have been enabled int count = 0; for (int i = 0; i < UpdateFiles.getCount(); i++) { @@ -505,7 +505,7 @@ static void DlgUpdateSilent(void *param) wchar_t tszText[200]; mir_snwprintf(tszText, L"%s\n\n%s", TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?")); - if (MessageBox(NULL, tszText, tszTitle, MB_ICONINFORMATION | MB_YESNO) == IDYES) + if (MessageBox(nullptr, tszText, tszTitle, MB_ICONINFORMATION | MB_YESNO) == IDYES) #if MIRANDA_VER >= 0x0A00 CallServiceSync(MS_SYSTEM_RESTART, db_get_b(NULL, MODNAME, "RestartCurrentProfile", 1) ? 1 : 0, 0); #else @@ -563,12 +563,12 @@ static renameTable[] = #if MIRANDA_VER >= 0x0A00 { L"dbx_mmap_sa.dll", L"Plugins\\dbx_mmap.dll" }, { L"dbx_tree.dll", L"Plugins\\dbx_mmap.dll" }, - { L"rc4.dll", NULL }, - { L"athena.dll", NULL }, - { L"skypekit.exe", NULL }, - { L"mir_app.dll", NULL }, - { L"mir_core.dll", NULL }, - { L"zlib.dll", NULL }, + { L"rc4.dll", nullptr }, + { L"athena.dll", nullptr }, + { L"skypekit.exe", nullptr }, + { L"mir_app.dll", nullptr }, + { L"mir_core.dll", nullptr }, + { L"zlib.dll", nullptr }, #endif { L"proto_newsaggr.dll", L"Icons\\proto_newsaggregator.dll" }, @@ -577,26 +577,26 @@ static renameTable[] = { L"langpack_*.txt", L"Languages\\*" }, - { L"pcre16.dll", NULL }, - { L"clist_classic.dll", NULL }, - { L"chat.dll", NULL }, - { L"srmm.dll", NULL }, - { L"stdchat.dll", NULL }, - { L"stdurl.dll", NULL }, - { L"extraicons.dll", NULL }, - { L"firstrun.dll", NULL }, - { L"flashavatars.dll", NULL }, - { L"gender.dll", NULL }, - { L"gtalkext.dll", NULL }, - { L"langman.dll", NULL }, - { L"metacontacts.dll", NULL }, - { L"modernopt.dll", NULL }, - { L"msvcp100.dll", NULL }, - { L"msvcr100.dll", NULL }, - { L"xfire.dll", NULL }, - { L"yahoo.dll", NULL }, - { L"yahoogroups.dll", NULL }, - { L"WART-*.exe", NULL }, + { L"pcre16.dll", nullptr }, + { L"clist_classic.dll", nullptr }, + { L"chat.dll", nullptr }, + { L"srmm.dll", nullptr }, + { L"stdchat.dll", nullptr }, + { L"stdurl.dll", nullptr }, + { L"extraicons.dll", nullptr }, + { L"firstrun.dll", nullptr }, + { L"flashavatars.dll", nullptr }, + { L"gender.dll", nullptr }, + { L"gtalkext.dll", nullptr }, + { L"langman.dll", nullptr }, + { L"metacontacts.dll", nullptr }, + { L"modernopt.dll", nullptr }, + { L"msvcp100.dll", nullptr }, + { L"msvcr100.dll", nullptr }, + { L"xfire.dll", nullptr }, + { L"yahoo.dll", nullptr }, + { L"yahoogroups.dll", nullptr }, + { L"WART-*.exe", nullptr }, }; // Checks if file needs to be renamed and copies it in pNewName @@ -606,7 +606,7 @@ static bool CheckFileRename(const wchar_t *ptszOldName, wchar_t *pNewName) for (int i = 0; i < _countof(renameTable); i++) { if (wildcmpiw(ptszOldName, renameTable[i].oldName)) { wchar_t *ptszDest = renameTable[i].newName; - if (ptszDest == NULL) + if (ptszDest == nullptr) *pNewName = 0; else { wcsncpy_s(pNewName, MAX_PATH, ptszDest, _TRUNCATE); @@ -627,7 +627,7 @@ static bool isValidExtension(const wchar_t *ptszFileName) { const wchar_t *pExt = wcsrchr(ptszFileName, '.'); - return (pExt != NULL) && (!_wcsicmp(pExt, L".dll") || !_wcsicmp(pExt, L".exe") || !_wcsicmp(pExt, L".txt")); + return (pExt != nullptr) && (!_wcsicmp(pExt, L".dll") || !_wcsicmp(pExt, L".exe") || !_wcsicmp(pExt, L".txt")); } // We only scan subfolders "Plugins", "Icons", "Languages", "Libs", "Core" @@ -687,7 +687,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t wchar_t *pName = tszNewName; ServListEntry *item = hashes.find((ServListEntry*)&pName); // Not in list? Check for trailing 'W' or 'w' - if (item == NULL) { + if (item == nullptr) { wchar_t *p = wcsrchr(tszNewName, '.'); if (p[-1] != 'w' && p[-1] != 'W') { Netlib_LogfW(hNetlibUser, L"File %s: Not found on server, skipping", ffd.cFileName); @@ -697,7 +697,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t // remove trailing w or W and try again int iPos = int(p - tszNewName) - 1; strdelw(p - 1, 1); - if ((item = hashes.find((ServListEntry*)&pName)) == NULL) { + if ((item = hashes.find((ServListEntry*)&pName)) == nullptr) { Netlib_LogfW(hNetlibUser, L"File %s: Not found on server, skipping", ffd.cFileName); continue; } @@ -761,7 +761,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t mir_snwprintf(FileInfo->File.tszDiskPath, L"%s\\Temp\\%s.zip", g_tszRoot, p); mir_snwprintf(FileInfo->File.tszDownloadURL, L"%s/%s.zip", tszBaseUrl, tszBuf); - for (p = wcschr(FileInfo->File.tszDownloadURL, '\\'); p != 0; p = wcschr(p, '\\')) + for (p = wcschr(FileInfo->File.tszDownloadURL, '\\'); p != nullptr; p = wcschr(p, '\\')) *p++ = '/'; // remember whether the user has decided not to update this component with this particular new version @@ -812,10 +812,10 @@ static void CheckUpdates(void *) else CallFunctionAsync(LaunchDialog, UpdateFiles); } - mir_forkthread(InitTimer, (success ? 0 : (void*)2)); + mir_forkthread(InitTimer, (success ? nullptr : (void*)2)); hashes.destroy(); - hCheckThread = NULL; + hCheckThread = nullptr; } static void DoCheck(bool bSilent = true) @@ -830,9 +830,9 @@ static void DoCheck(bool bSilent = true) else { opts.bSilent = bSilent; #if MIRANDA_VER >= 0x0A00 - db_set_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, time(NULL)); + db_set_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, time(nullptr)); #endif - hCheckThread = mir_forkthread(CheckUpdates, 0); + hCheckThread = mir_forkthread(CheckUpdates, nullptr); } } @@ -840,7 +840,7 @@ void UninitCheck() { CancelWaitableTimer(hTimer); CloseHandle(hTimer); - if (hwndDialog != NULL) + if (hwndDialog != nullptr) DestroyWindow(hwndDialog); } @@ -860,14 +860,14 @@ void InitCheck() void UnloadCheck() { if (hCheckThread) - hCheckThread = NULL; + hCheckThread = nullptr; } void CheckUpdateOnStartup() { if (opts.bUpdateOnStartup) { if (opts.bOnlyOnceADay) { - time_t now = time(NULL), + time_t now = time(nullptr), was = db_get_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, 0); if ((now - was) < 86400) @@ -914,7 +914,7 @@ void InitTimer(void *type) switch ((INT_PTR)type) { case 0: // default, plan next check relative to last check { - time_t now = time(NULL); + time_t now = time(nullptr); time_t was = db_get_dw(NULL, MODNAME, DB_SETTING_LAST_UPDATE, 0); interval = PeriodToMilliseconds(opts.Period, opts.bPeriodMeasure); @@ -939,13 +939,13 @@ void InitTimer(void *type) li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; li.QuadPart += interval * 10000LL; - SetWaitableTimer(hTimer, &li, 0, TimerAPCProc, NULL, 0); + SetWaitableTimer(hTimer, &li, 0, TimerAPCProc, nullptr, 0); // Wait in an alertable state for the timer to go off. SleepEx(INFINITE, TRUE); } void CreateTimer() { - hTimer = CreateWaitableTimer(NULL, FALSE, NULL); - mir_forkthread(InitTimer, 0); + hTimer = CreateWaitableTimer(nullptr, FALSE, nullptr); + mir_forkthread(InitTimer, nullptr); } \ No newline at end of file diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp index f048d10a5a..fa215c6a3b 100644 --- a/plugins/PluginUpdater/src/Events.cpp +++ b/plugins/PluginUpdater/src/Events.cpp @@ -33,13 +33,13 @@ int OnFoldersChanged(WPARAM, LPARAM) void EmptyFolder() { SHFILEOPSTRUCT file_op = { - NULL, + nullptr, FO_DELETE, g_tszRoot, L"", FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION, false, - 0, + nullptr, L"" }; SHFileOperation(&file_op); } diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp index 819cf521e3..c8057276b7 100644 --- a/plugins/PluginUpdater/src/Notifications.cpp +++ b/plugins/PluginUpdater/src/Notifications.cpp @@ -73,7 +73,7 @@ static void _stdcall RestartPrompt(void *) wchar_t tszText[200]; mir_snwprintf(tszText, L"%s\n\n%s", TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?")); - if (MessageBox(0, tszText, TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION | MB_TOPMOST) == IDYES) + if (MessageBox(nullptr, tszText, TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION | MB_TOPMOST) == IDYES) CallService(MS_SYSTEM_RESTART, db_get_b(NULL, MODNAME, "RestartCurrentProfile", 1) ? 1 : 0, 0); } @@ -85,7 +85,7 @@ static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wPara break; case WM_COMMAND: PUDeletePopup(hPopup); - CallFunctionAsync(RestartPrompt, 0); + CallFunctionAsync(RestartPrompt, nullptr); break; } @@ -141,5 +141,5 @@ void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number) } if (Number == POPUP_TYPE_ERROR) - MessageBox(0, ptszText, ptszTitle, MB_ICONINFORMATION); + MessageBox(nullptr, ptszText, ptszTitle, MB_ICONINFORMATION); } diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index 536e018471..8d5d4d2830 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -45,7 +45,7 @@ static int GetUpdateMode() // Missing or unknown mode, determine correct from version of running core char coreVersion[512]; Miranda_GetVersionText(coreVersion, _countof(coreVersion)); - UpdateMode = (strstr(coreVersion, "alpha") == NULL) ? UPDATE_MODE_STABLE : UPDATE_MODE_TRUNK; + UpdateMode = (strstr(coreVersion, "alpha") == nullptr) ? UPDATE_MODE_STABLE : UPDATE_MODE_TRUNK; } return UpdateMode; @@ -479,7 +479,7 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM //Colors db_set_b(NULL, MODNAME, "DefColors", PopupOptions.DefColors); //Timeout - PopupOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE); + PopupOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, nullptr, TRUE); db_set_dw(NULL, MODNAME, "Timeout", PopupOptions.Timeout); //Left mouse click db_set_b(NULL, MODNAME, "LeftClickAction", PopupOptions.LeftClickAction); diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp index fdc39c3695..863a93ac7b 100644 --- a/plugins/PluginUpdater/src/PluginUpdater.cpp +++ b/plugins/PluginUpdater/src/PluginUpdater.cpp @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. #include "stdafx.h" -HINSTANCE hInst = NULL; +HINSTANCE hInst = nullptr; wchar_t g_tszRoot[MAX_PATH] = {0}, g_tszTempPath[MAX_PATH]; int hLangpack; DWORD g_mirandaVersion; diff --git a/plugins/PluginUpdater/src/Services.cpp b/plugins/PluginUpdater/src/Services.cpp index 698fac6021..ab8c744c9f 100644 --- a/plugins/PluginUpdater/src/Services.cpp +++ b/plugins/PluginUpdater/src/Services.cpp @@ -23,7 +23,7 @@ static INT_PTR srvParseHashes(WPARAM wParam, LPARAM lParam) { LPCTSTR ptszUrl = (LPCTSTR)wParam; LPTSTR ptszBaseUrl = (LPTSTR)lParam; - if (ptszUrl == NULL || ptszBaseUrl == NULL) + if (ptszUrl == nullptr || ptszBaseUrl == nullptr) return NULL; SERVLIST *pList = new SERVLIST(50, CompareHashes); @@ -48,13 +48,13 @@ static INT_PTR srvFreeHashes(WPARAM, LPARAM lParam) static INT_PTR srvGetHashCount(WPARAM, LPARAM lParam) { SERVLIST *pList = (SERVLIST*)lParam; - return (pList == NULL) ? 0 : pList->getCount(); + return (pList == nullptr) ? 0 : pList->getCount(); } static INT_PTR srvGetNthHash(WPARAM wParam, LPARAM lParam) { SERVLIST *pList = (SERVLIST*)lParam; - return (pList == NULL) ? 0 : INT_PTR(&(*pList)[wParam]); + return (pList == nullptr) ? 0 : INT_PTR(&(*pList)[wParam]); } void InitServices() diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index ba52be0285..aea147a0f1 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -19,8 +19,8 @@ Boston, MA 02111-1307, USA. #include "stdafx.h" -HNETLIBUSER hNetlibUser = NULL; -HANDLE hPipe = NULL; +HNETLIBUSER hNetlibUser = nullptr; +HANDLE hPipe = nullptr; ///////////////////////////////////////////////////////////////////////////////////// void LoadOptions() @@ -72,7 +72,7 @@ void InitNetlib() void UnloadNetlib() { Netlib_CloseHandle(hNetlibUser); - hNetlibUser = NULL; + hNetlibUser = nullptr; } ULONG crc32_table[256]; @@ -143,7 +143,7 @@ bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes) #else vars[0].value.w = L"32"; #endif - vars[1].key.w = vars[1].value.w = 0; + vars[1].key.w = vars[1].value.w = nullptr; #else vars[0].lptzKey = L"platform"; #ifdef _WIN64 @@ -172,7 +172,7 @@ bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes) return false; } - if(!unzip(pFileUrl.tszDiskPath, g_tszTempPath, NULL,true)) { + if(!unzip(pFileUrl.tszDiskPath, g_tszTempPath, nullptr,true)) { Netlib_LogfW(hNetlibUser,L"Unzipping list of available updates from %s failed",baseUrl); ShowPopup(TranslateT("Plugin Updater"), TranslateT("An error occurred while checking for new updates."), POPUP_TYPE_ERROR); Skin_PlaySound("updatefailed"); @@ -192,7 +192,7 @@ bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes) bool bDoNotSwitchToStable = false; char str[200]; - while(fgets(str, _countof(str), fp) != NULL) { + while(fgets(str, _countof(str), fp) != nullptr) { rtrim(str); // Do not allow the user to switch back to stable if (!strcmp(str, "DoNotSwitchToStable")) { @@ -201,13 +201,13 @@ bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes) else if (str[0] != ';') { // ';' marks a comment Netlib_Logf(hNetlibUser, "Update: %s", str); char *p = strchr(str, ' '); - if (p != NULL) { + if (p != nullptr) { *p++ = 0; _strlwr(p); int dwCrc32; char *p1 = strchr(p, ' '); - if (p1 == NULL) + if (p1 == nullptr) dwCrc32 = 0; else { *p1++ = 0; @@ -280,21 +280,21 @@ bool DownloadFile(FILEURL *pFileURL, HNETLIBCONN &nlc) } } - HANDLE hFile = CreateFile(pFileURL->tszDiskPath, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(pFileURL->tszDiskPath, GENERIC_READ | GENERIC_WRITE, NULL, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { DWORD dwBytes; // write the downloaded file directly - WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL); + WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, nullptr); CloseHandle(hFile); } else { // try to write it via PU stub wchar_t tszTempFile[MAX_PATH]; mir_snwprintf(tszTempFile, L"%s\\pulocal.tmp", g_tszTempPath); - hFile = CreateFile(tszTempFile, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFile(tszTempFile, GENERIC_READ | GENERIC_WRITE, NULL, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { DWORD dwBytes; - WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL); + WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, nullptr); CloseHandle(hFile); SafeMoveFile(tszTempFile, pFileURL->tszDiskPath); } @@ -307,7 +307,7 @@ bool DownloadFile(FILEURL *pFileURL, HNETLIBCONN &nlc) } else { Netlib_LogfW(hNetlibUser,L"Downloading file %s failed, host is propably temporary down.",pFileURL->tszDownloadURL); - nlc = NULL; + nlc = nullptr; } } if(!ret) @@ -322,7 +322,7 @@ bool DownloadFile(FILEURL *pFileURL, HNETLIBCONN &nlc) void __stdcall OpenPluginOptions(void*) { #if MIRANDA_VER >= 0x0A00 - Options_Open(NULL, L"Plugins"); + Options_Open(nullptr, L"Plugins"); #endif } @@ -357,7 +357,7 @@ BOOL IsRunAsAdmin() { BOOL fIsRunAsAdmin = FALSE; DWORD dwError = ERROR_SUCCESS; - PSID pAdministratorsGroup = NULL; + PSID pAdministratorsGroup = nullptr; // Allocate and initialize a SID of the administrators group. SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; @@ -375,7 +375,7 @@ BOOL IsRunAsAdmin() // Determine whether the SID of administrators group is bEnabled in // the primary access token of the process. - if (!CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin)) + if (!CheckTokenMembership(nullptr, pAdministratorsGroup, &fIsRunAsAdmin)) { dwError = GetLastError(); goto Cleanup; @@ -386,7 +386,7 @@ Cleanup: if (pAdministratorsGroup) { FreeSid(pAdministratorsGroup); - pAdministratorsGroup = NULL; + pAdministratorsGroup = nullptr; } // Throw the error if something failed in the function. @@ -442,7 +442,7 @@ BOOL IsProcessElevated() { BOOL fIsElevated = FALSE; DWORD dwError = ERROR_SUCCESS; - HANDLE hToken = NULL; + HANDLE hToken = nullptr; // Open the primary access token of the process with TOKEN_QUERY. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) @@ -471,7 +471,7 @@ Cleanup: if (hToken) { CloseHandle(hToken); - hToken = NULL; + hToken = nullptr; } // Throw the error if something failed in the function. @@ -487,12 +487,12 @@ bool PrepareEscalation() { // First try to create a file near Miranda32.exe wchar_t szPath[MAX_PATH]; - GetModuleFileName(NULL, szPath, _countof(szPath)); + GetModuleFileName(nullptr, szPath, _countof(szPath)); wchar_t *ext = wcsrchr(szPath, '.'); - if (ext != NULL) + if (ext != nullptr) *ext = '\0'; wcscat(szPath, L".test"); - HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { // we are admins or UAC is disable, cool CloseHandle(hFile); @@ -507,14 +507,14 @@ bool PrepareEscalation() // Elevate the process. Create a pipe for a stub first wchar_t tszPipeName[MAX_PATH]; mir_snwprintf(tszPipeName, L"\\\\.\\pipe\\Miranda_Pu_%d", GetCurrentProcessId()); - hPipe = CreateNamedPipe(tszPipeName, PIPE_ACCESS_DUPLEX, PIPE_READMODE_BYTE | PIPE_WAIT, 1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL); + hPipe = CreateNamedPipe(tszPipeName, PIPE_ACCESS_DUPLEX, PIPE_READMODE_BYTE | PIPE_WAIT, 1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, nullptr); if (hPipe == INVALID_HANDLE_VALUE) { - hPipe = NULL; + hPipe = nullptr; } else { wchar_t cmdLine[100], *p; - GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)); - if ((p = wcsrchr(szPath, '\\')) != 0) + GetModuleFileName(nullptr, szPath, ARRAYSIZE(szPath)); + if ((p = wcsrchr(szPath, '\\')) != nullptr) wcscpy(p+1, L"pu_stub.exe"); mir_snwprintf(cmdLine, L"%d", GetCurrentProcessId()); @@ -523,11 +523,11 @@ bool PrepareEscalation() sei.lpVerb = L"runas"; sei.lpFile = szPath; sei.lpParameters = cmdLine; - sei.hwnd = NULL; + sei.hwnd = nullptr; sei.nShow = SW_NORMAL; if (ShellExecuteEx(&sei)) { - if (hPipe != NULL) - ConnectNamedPipe(hPipe, NULL); + if (hPipe != nullptr) + ConnectNamedPipe(hPipe, nullptr); return true; } @@ -562,11 +562,11 @@ int TransactPipe(int opcode, const wchar_t *p1, const wchar_t *p2) else *dst++ = 0; DWORD dwBytes = 0, dwError; - if ( WriteFile(hPipe, buf, (DWORD)((BYTE*)dst - buf), &dwBytes, NULL) == 0) + if ( WriteFile(hPipe, buf, (DWORD)((BYTE*)dst - buf), &dwBytes, nullptr) == 0) return 0; dwError = 0; - if ( ReadFile(hPipe, &dwError, sizeof(DWORD), &dwBytes, NULL) == 0) return 0; + if ( ReadFile(hPipe, &dwError, sizeof(DWORD), &dwBytes, nullptr) == 0) return 0; if (dwBytes != sizeof(DWORD)) return 0; return dwError == ERROR_SUCCESS; @@ -574,7 +574,7 @@ int TransactPipe(int opcode, const wchar_t *p1, const wchar_t *p2) int SafeCopyFile(const wchar_t *pSrc, const wchar_t *pDst) { - if (hPipe == NULL) + if (hPipe == nullptr) return CopyFile(pSrc, pDst, FALSE); return TransactPipe(1, pSrc, pDst); @@ -582,7 +582,7 @@ int SafeCopyFile(const wchar_t *pSrc, const wchar_t *pDst) int SafeMoveFile(const wchar_t *pSrc, const wchar_t *pDst) { - if (hPipe == NULL) { + if (hPipe == nullptr) { DeleteFile(pDst); if ( MoveFile(pSrc, pDst) == 0) // use copy on error CopyFile(pSrc, pDst, FALSE); @@ -594,28 +594,28 @@ int SafeMoveFile(const wchar_t *pSrc, const wchar_t *pDst) int SafeDeleteFile(const wchar_t *pFile) { - if (hPipe == NULL) + if (hPipe == nullptr) return DeleteFile(pFile); - return TransactPipe(3, pFile, NULL); + return TransactPipe(3, pFile, nullptr); } int SafeCreateDirectory(const wchar_t *pFolder) { - if (hPipe == NULL) + if (hPipe == nullptr) return CreateDirectoryTreeW(pFolder); - return TransactPipe(4, pFolder, NULL); + return TransactPipe(4, pFolder, nullptr); } int SafeCreateFilePath(wchar_t *pFolder) { - if (hPipe == NULL) { + if (hPipe == nullptr) { CreatePathToFileW(pFolder); return 0; } - return TransactPipe(5, pFolder, NULL); + return TransactPipe(5, pFolder, nullptr); } void BackupFile(wchar_t *ptszSrcFileName, wchar_t *ptszBackFileName) diff --git a/plugins/PluginUpdater/src/checksum.cpp b/plugins/PluginUpdater/src/checksum.cpp index 67f2493611..889696c4b0 100644 --- a/plugins/PluginUpdater/src/checksum.cpp +++ b/plugins/PluginUpdater/src/checksum.cpp @@ -25,12 +25,12 @@ struct MFileMapping MFileMapping(const wchar_t* ptszFileName) { - ptr = NULL; - hMap = NULL; + ptr = nullptr; + hMap = nullptr; - hFile = CreateFile(ptszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + hFile = CreateFile(ptszFileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (hFile != INVALID_HANDLE_VALUE) - hMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL); + hMap = CreateFileMapping(hFile, nullptr, PAGE_WRITECOPY, 0, 0, nullptr); if (hMap) ptr = (PBYTE)MapViewOfFile(hMap, FILE_MAP_COPY, 0, 0, 0); } @@ -79,7 +79,7 @@ int CalculateModuleHash(const wchar_t *filename, char *szDest) if (map.hFile == INVALID_HANDLE_VALUE) return RESULT_NOTFOUND; - if (map.ptr == NULL) + if (map.ptr == nullptr) return RESULT_READERROR; // check minimum and maximum size diff --git a/plugins/PluginUpdater/src/unzipfile.cpp b/plugins/PluginUpdater/src/unzipfile.cpp index 7698e056a0..95aa1bf009 100644 --- a/plugins/PluginUpdater/src/unzipfile.cpp +++ b/plugins/PluginUpdater/src/unzipfile.cpp @@ -44,7 +44,7 @@ bool extractCurrentFile(unzFile uf, wchar_t *ptszDestPath, wchar_t *ptszBackPath unz_file_info64 file_info; char filename[MAX_PATH], buf[8192]; - int err = unzGetCurrentFileInfo64(uf, &file_info, filename, sizeof(filename), buf, sizeof(buf), NULL, 0); + int err = unzGetCurrentFileInfo64(uf, &file_info, filename, sizeof(filename), buf, sizeof(buf), nullptr, 0); if (err != UNZ_OK) return false; @@ -58,7 +58,7 @@ bool extractCurrentFile(unzFile uf, wchar_t *ptszDestPath, wchar_t *ptszBackPath wchar_t tszDestFile[MAX_PATH], tszBackFile[MAX_PATH]; wchar_t *ptszNewName = mir_utf8decodeW(filename); - if (ptszNewName == NULL) + if (ptszNewName == nullptr) ptszNewName = mir_a2u(filename); if (!(file_info.external_fa & FILE_ATTRIBUTE_DIRECTORY)) { @@ -68,7 +68,7 @@ bool extractCurrentFile(unzFile uf, wchar_t *ptszDestPath, wchar_t *ptszBackPath return false; } - if (ptszBackPath != NULL) { + if (ptszBackPath != nullptr) { PrepareFileName(tszDestFile, _countof(tszDestFile), ptszDestPath, ptszNewName); PrepareFileName(tszBackFile, _countof(tszBackFile), ptszBackPath, ptszNewName); BackupFile(tszDestFile, tszBackFile); @@ -78,7 +78,7 @@ bool extractCurrentFile(unzFile uf, wchar_t *ptszDestPath, wchar_t *ptszBackPath SafeCreateFilePath(tszDestFile); wchar_t *ptszFile2unzip; - if (hPipe == NULL) // direct mode + if (hPipe == nullptr) // direct mode ptszFile2unzip = tszDestFile; else { wchar_t tszTempPath[MAX_PATH]; @@ -87,7 +87,7 @@ bool extractCurrentFile(unzFile uf, wchar_t *ptszDestPath, wchar_t *ptszBackPath ptszFile2unzip = tszBackFile; } - HANDLE hFile = CreateFile(ptszFile2unzip, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, file_info.external_fa, 0); + HANDLE hFile = CreateFile(ptszFile2unzip, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, file_info.external_fa, nullptr); if (hFile == INVALID_HANDLE_VALUE) { mir_free(ptszNewName); return false; -- cgit v1.2.3