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] --- src/core/stdaway/src/awaymsg.cpp | 6 +- src/core/stdaway/src/sendmsg.cpp | 18 +++--- src/core/stdclist/src/clcfonts.cpp | 4 +- src/core/stdclist/src/clcopts.cpp | 8 +-- src/core/stdclist/src/clcpaint.cpp | 12 ++-- src/core/stdclist/src/clistopts.cpp | 4 +- src/core/stdclist/src/cluiopts.cpp | 14 ++-- src/core/stdclist/src/contact.cpp | 2 +- src/core/stdclist/src/init.cpp | 6 +- src/core/stdcrypt/src/Rijndael.cpp | 2 +- src/core/stdcrypt/src/encrypt.cpp | 20 +++--- src/core/stdcrypt/src/utils.cpp | 8 +-- src/core/stdemail/src/email.cpp | 6 +- src/core/stdfile/src/file.cpp | 36 +++++------ src/core/stdfile/src/fileexistsdlg.cpp | 12 ++-- src/core/stdfile/src/fileopts.cpp | 4 +- src/core/stdfile/src/filerecvdlg.cpp | 18 +++--- src/core/stdfile/src/filesenddlg.cpp | 20 +++--- src/core/stdfile/src/filexferdlg.cpp | 72 ++++++++++----------- src/core/stdfile/src/ftmanager.cpp | 28 ++++---- src/core/stdfile/src/main.cpp | 2 +- src/core/stdhelp/src/about.cpp | 2 +- src/core/stdhelp/src/help.cpp | 4 +- src/core/stdidle/src/idle.cpp | 8 +-- src/core/stdmsg/src/chat_options.cpp | 6 +- src/core/stdmsg/src/chat_window.cpp | 2 +- src/core/stdmsg/src/cmdlist.cpp | 2 +- src/core/stdmsg/src/msgdialog.cpp | 12 ++-- src/core/stdmsg/src/msgs.cpp | 2 +- src/core/stdmsg/src/msgtimedout.cpp | 2 +- src/core/stdmsg/src/statusicon.cpp | 2 +- src/core/stdmsg/src/tabs.cpp | 6 +- src/core/stdssl/src/netlibssl.cpp | 102 +++++++++++++++--------------- src/core/stduihist/src/history.cpp | 10 +-- src/core/stduserinfo/src/contactinfo.cpp | 14 ++-- src/core/stduserinfo/src/stdinfo.cpp | 26 ++++---- src/core/stduserinfo/src/userinfo.cpp | 40 ++++++------ src/core/stduseronline/src/useronline.cpp | 2 +- 38 files changed, 272 insertions(+), 272 deletions(-) (limited to 'src/core') diff --git a/src/core/stdaway/src/awaymsg.cpp b/src/core/stdaway/src/awaymsg.cpp index 8497cbb693..821b4bae55 100644 --- a/src/core/stdaway/src/awaymsg.cpp +++ b/src/core/stdaway/src/awaymsg.cpp @@ -71,7 +71,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP Window_SetProtoIcon_IcoLib(hwndDlg, szProto, dwStatus); } - if (dat->hSeq == NULL) { + if (dat->hSeq == nullptr) { ACKDATA ack = { 0 }; ack.cbSize = sizeof(ack); ack.hContact = dat->hContact; @@ -87,7 +87,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP ACKDATA *ack = (ACKDATA*)lParam; if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) break; if (ack->result != ACKRESULT_SUCCESS) break; - if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } + if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = nullptr; } SetDlgItemText(hwndDlg, IDC_MSG, (const wchar_t*)ack->lParam); @@ -134,7 +134,7 @@ static INT_PTR GetMessageCommand(WPARAM wParam, LPARAM) static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) { char *szProto = GetContactProto(hContact); - if (szProto != NULL) { + if (szProto != nullptr) { int chatRoom = db_get_b(hContact, szProto, "ChatRoom", 0); if (!chatRoom) { int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); diff --git a/src/core/stdaway/src/sendmsg.cpp b/src/core/stdaway/src/sendmsg.cpp index d3013ea14f..09a9ae9bf3 100644 --- a/src/core/stdaway/src/sendmsg.cpp +++ b/src/core/stdaway/src/sendmsg.cpp @@ -42,7 +42,7 @@ static const wchar_t *GetDefaultMessage(int status) case ID_STATUS_OUTTOLUNCH: return TranslateT("Mmm... food."); case ID_STATUS_IDLE: return TranslateT("idleeeeeeee"); } - return NULL; + return nullptr; } static const char *StatusModeToDbSetting(int status, const char *suffix) @@ -63,7 +63,7 @@ static const char *StatusModeToDbSetting(int status, const char *suffix) case ID_STATUS_ONTHEPHONE: prefix = "Otp"; break; case ID_STATUS_OUTTOLUNCH: prefix = "Otl"; break; case ID_STATUS_IDLE: prefix = "Idl"; break; - default: return NULL; + default: return nullptr; } mir_snprintf(str, "%s%s", prefix, suffix); return str; @@ -82,10 +82,10 @@ static void SetStatusModeByte(int status, const char *suffix, BYTE value) static wchar_t* GetAwayMessage(int statusMode, char *szProto) { if (szProto && !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode))) - return NULL; + return nullptr; if ( GetStatusModeByte(statusMode, "Ignore")) - return NULL; + return nullptr; DBVARIANT dbv; if ( GetStatusModeByte(statusMode, "UsePrev")) { @@ -173,7 +173,7 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar void ChangeAllProtoMessages(char *szProto, int statusMode, wchar_t *msg) { - if (szProto == NULL) { + if (szProto == nullptr) { int nAccounts; PROTOACCOUNT **accounts; Proto_EnumAccounts(&nAccounts, &accounts); @@ -239,7 +239,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa SendMessage(hwndDlg, WM_TIMER, 0, 0); Window_SetProtoIcon_IcoLib(hwndDlg, dat->szProto, dat->statusMode); Utils_RestoreWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg"); - SetTimer(hwndDlg, 1, 1000, 0); + SetTimer(hwndDlg, 1, 1000, nullptr); dat->hPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, DM_SRAWAY_SHUTDOWN); } return TRUE; @@ -298,7 +298,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa UnhookEvent(dat->hPreshutdown); Window_FreeIcon_IcoLib(hwndDlg); mir_free(dat); - hwndStatusMsg = NULL; + hwndStatusMsg = nullptr; break; } return FALSE; @@ -326,7 +326,7 @@ static int StatusModeChange(WPARAM wParam, LPARAM lParam) BOOL bScreenSaverRunning = IsScreenSaverRunning(); if (GetStatusModeByte(statusMode, "Ignore")) - ChangeAllProtoMessages(szProto, statusMode, NULL); + ChangeAllProtoMessages(szProto, statusMode, nullptr); else if (bScreenSaverRunning || GetStatusModeByte(statusMode, "NoDlg", true)) { wchar_t *msg = GetAwayMessage(statusMode, szProto); @@ -435,7 +435,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam } RECT rc = dis->rcItem; - DrawIconEx(dis->hDC, 3, (rc.top + rc.bottom - 16) / 2, Skin_LoadProtoIcon(NULL, dis->itemData), 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(dis->hDC, 3, (rc.top + rc.bottom - 16) / 2, Skin_LoadProtoIcon(nullptr, dis->itemData), 16, 16, 0, nullptr, DI_NORMAL); rc.left += 25; SetBkMode(dis->hDC, TRANSPARENT); DrawText(dis->hDC, buf, -1, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX); diff --git a/src/core/stdclist/src/clcfonts.cpp b/src/core/stdclist/src/clcfonts.cpp index a2fae81932..b1678d1ef9 100644 --- a/src/core/stdclist/src/clcfonts.cpp +++ b/src/core/stdclist/src/clcfonts.cpp @@ -56,7 +56,7 @@ void RegisterCListFonts() strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup)); wcsncpy(fontid.group, LPGENW("Contact list"), _countof(fontid.group)); - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); for (int i = 0; i < _countof(clistFontDescr); i++) { LOGFONT lf; pcli->pfnGetFontSetting(i, &lf, &fontid.deffontsettings.colour); @@ -78,7 +78,7 @@ void RegisterCListFonts() fontid.order = i; Font_RegisterW(&fontid); } - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); // and colours ColourIDW colourid = { 0 }; diff --git a/src/core/stdclist/src/clcopts.cpp b/src/core/stdclist/src/clcopts.cpp index 0beae07eec..c431534d3f 100644 --- a/src/core/stdclist/src/clcopts.cpp +++ b/src/core/stdclist/src/clcopts.cpp @@ -89,7 +89,7 @@ static const struct CheckBoxValues_t offlineValues[] = static void FillCheckBoxTree(HWND hwndTree, const struct CheckBoxValues_t *values, int nValues, DWORD style) { TVINSERTSTRUCT tvis; - tvis.hParent = NULL; + tvis.hParent = nullptr; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE; for (int i = 0; i < nValues; i++) { @@ -120,7 +120,7 @@ static DWORD MakeCheckBoxTreeFlags(HWND hwndTree) static LONG CalcMinRowHeight() { LONG minHeight = 16; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); for (int i = 0; i < FONTID_LAST; i++) { LOGFONT lf; COLORREF color; @@ -135,7 +135,7 @@ static LONG CalcMinRowHeight() hFont = (HFONT)SelectObject(hdc, hFont); DeleteObject(hFont); } - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); return minHeight; } @@ -346,7 +346,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; - ofn.hInstance = NULL; + ofn.hInstance = nullptr; Bitmap_GetFilter(filter, _countof(filter)); ofn.lpstrFilter = filter; ofn.lpstrFile = str; diff --git a/src/core/stdclist/src/clcpaint.cpp b/src/core/stdclist/src/clcpaint.cpp index 456497a34c..c5b13837ba 100644 --- a/src/core/stdclist/src/clcpaint.cpp +++ b/src/core/stdclist/src/clcpaint.cpp @@ -162,14 +162,14 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) RECT clRect; GetClientRect(hwnd, &clRect); - if (rcPaint == NULL) + if (rcPaint == nullptr) rcPaint = &clRect; if (IsRectEmpty(rcPaint)) return; int y = -dat->yScroll; HDC hdcMem = CreateCompatibleDC(hdc); - HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), NULL); + HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), nullptr); HBITMAP hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmpOsb); TEXTMETRIC tm; @@ -180,7 +180,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) GetTextMetrics(hdcMem, &tm); groupCountsFontTopShift -= tm.tmAscent; - HBRUSH hBrushAlternateGrey = NULL; + HBRUSH hBrushAlternateGrey = nullptr; if (style & CLS_GREYALTERNATE) hBrushAlternateGrey = CreateSolidBrush(GetNearestColor(hdcMem, RGB(GetRValue(tmpbkcolour) - 10, GetGValue(tmpbkcolour) - 10, GetBValue(tmpbkcolour) - 10))); @@ -266,7 +266,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) int indent = 0; for (int index = 0; y < rcPaint->bottom;) { if (group->scanIndex == group->cl.getCount()) { - if ((group = group->parent) == NULL) + if ((group = group->parent) == nullptr) break; group->scanIndex++; indent--; @@ -316,7 +316,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) GetTextExtentPoint32(hdcMem, cc->szText, (int)mir_wstrlen(cc->szText), &textSize); width = textSize.cx; - wchar_t *ptszGroupCount = NULL; + wchar_t *ptszGroupCount = nullptr; if (cc->type == CLCIT_GROUP) { ptszGroupCount = pcli->pfnGetGroupCountsText(dat, cc); if (*ptszGroupCount) { @@ -432,7 +432,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) else if (hottrack) SetHotTrackColour(hdcMem, dat); rc.right--; - ExtTextOut(hdcMem, rc.left, rc.top, ETO_CLIPPED, &rc, cc->szText, (int)mir_wstrlen(cc->szText), NULL); + ExtTextOut(hdcMem, rc.left, rc.top, ETO_CLIPPED, &rc, cc->szText, (int)mir_wstrlen(cc->szText), nullptr); } else TextOut(hdcMem, dat->leftMargin + indent * dat->groupIndent + checkboxWidth + dat->iconXSpace, y + ((dat->rowHeight - fontHeight) >> 1), cc->szText, (int)mir_wstrlen(cc->szText)); diff --git a/src/core/stdclist/src/clistopts.cpp b/src/core/stdclist/src/clistopts.cpp index 8a92ee1146..f9442fb5ce 100644 --- a/src/core/stdclist/src/clistopts.cpp +++ b/src/core/stdclist/src/clistopts.cpp @@ -31,7 +31,7 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP { MCONTACT hContact = wParam; DBCONTACTWRITESETTING *ws = (DBCONTACTWRITESETTING *)lParam; - if (hContact == NULL && ws != NULL && ws->szModule != NULL && ws->szSetting != NULL && + if (hContact == NULL && ws != nullptr && ws->szModule != nullptr && ws->szSetting != nullptr && strcmp(ws->szModule, "CList") == 0 && strcmp(ws->szSetting, "UseGroups") == 0 && IsWindowVisible(hwndDlg)) { CheckDlgButton(hwndDlg, IDC_DISABLEGROUPS, ws->value.bVal == 0 ? BST_CHECKED : BST_UNCHECKED); } @@ -176,7 +176,7 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP { int cur = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0); PROTOACCOUNT *pa = (PROTOACCOUNT*)SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETITEMDATA, cur, 0); - if (pa == NULL) + if (pa == nullptr) db_unset(NULL, "CList", "PrimaryStatus"); else db_set_s(NULL, "CList", "PrimaryStatus", pa->szModuleName); diff --git a/src/core/stdclist/src/cluiopts.cpp b/src/core/stdclist/src/cluiopts.cpp index e97dcc9667..df06e1d9e2 100644 --- a/src/core/stdclist/src/cluiopts.cpp +++ b/src/core/stdclist/src/cluiopts.cpp @@ -155,7 +155,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L db_set_b(NULL, "CList", "BringToFront", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_BRINGTOFRONT)); db_set_b(NULL, "CLUI", "FadeInOut", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FADEINOUT)); db_set_b(NULL, "CLUI", "AutoSize", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE)); - db_set_b(NULL, "CLUI", "MaxSizeHeight", (BYTE)GetDlgItemInt(hwndDlg, IDC_MAXSIZEHEIGHT, NULL, FALSE)); + db_set_b(NULL, "CLUI", "MaxSizeHeight", (BYTE)GetDlgItemInt(hwndDlg, IDC_MAXSIZEHEIGHT, nullptr, FALSE)); db_set_b(NULL, "CLUI", "AutoSizeUpward", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZEUPWARD)); db_set_b(NULL, "CList", "AutoHide", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); db_set_w(NULL, "CList", "HideTime", (WORD)SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_GETPOS, 0, 0)); @@ -195,12 +195,12 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) & ~WS_EX_TOOLWINDOW | WS_EX_APPWINDOW); if (IsDlgButtonChecked(hwndDlg, IDC_ONDESKTOP)) { - HWND hProgMan = FindWindow(L"Progman", NULL); + HWND hProgMan = FindWindow(L"Progman", nullptr); if (hProgMan) SetParent(pcli->hwndContactList, hProgMan); } else - SetParent(pcli->hwndContactList, NULL); + SetParent(pcli->hwndContactList, nullptr); if (IsDlgButtonChecked(hwndDlg, IDC_SHOWCAPTION)) { int style = GetWindowLongPtr(pcli->hwndContactList, GWL_STYLE) | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; @@ -212,12 +212,12 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L } if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SHOWMAINMENU)) - SetMenu(pcli->hwndContactList, NULL); + SetMenu(pcli->hwndContactList, nullptr); else SetMenu(pcli->hwndContactList, pcli->hMenuMain); - SetWindowPos(pcli->hwndContactList, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + SetWindowPos(pcli->hwndContactList, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + RedrawWindow(pcli->hwndContactList, nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE); if (IsIconic(pcli->hwndContactList) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_TOOLWND)) ShowWindow(pcli->hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_MIN2TRAY) ? SW_HIDE : SW_SHOW); @@ -297,7 +297,7 @@ static INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L DestroyWindow(pcli->hwndStatus); flags |= db_get_b(NULL, "CLUI", "ShowSBar", 1) ? WS_VISIBLE : 0; flags |= db_get_b(NULL, "CLUI", "ShowGrip", 1) ? SBARS_SIZEGRIP : 0; - pcli->hwndStatus = CreateWindow(STATUSCLASSNAME, NULL, flags, 0, 0, 0, 0, parent, NULL, g_hInst, NULL); + pcli->hwndStatus = CreateWindow(STATUSCLASSNAME, nullptr, flags, 0, 0, 0, 0, parent, nullptr, g_hInst, nullptr); } if (IsDlgButtonChecked(hwndDlg, IDC_SHOWSBAR)) ShowWindow(pcli->hwndStatus, SW_SHOW); diff --git a/src/core/stdclist/src/contact.cpp b/src/core/stdclist/src/contact.cpp index 56d7826474..f883bf1438 100644 --- a/src/core/stdclist/src/contact.cpp +++ b/src/core/stdclist/src/contact.cpp @@ -65,7 +65,7 @@ int CompareContacts(const ClcContact* c1, const ClcContact* c2) return 2 * (statusa == ID_STATUS_OFFLINE) - 1; } /* both are online, now check protocols */ - if (c1->proto != NULL && c2->proto != NULL) { + if (c1->proto != nullptr && c2->proto != nullptr) { int rc = mir_strcmp(c1->proto, c2->proto); if (rc != 0) return rc; diff --git a/src/core/stdclist/src/init.cpp b/src/core/stdclist/src/init.cpp index 4bd2f23e92..4c8c0bc39c 100644 --- a/src/core/stdclist/src/init.cpp +++ b/src/core/stdclist/src/init.cpp @@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -HINSTANCE g_hInst = 0; -CLIST_INTERFACE* pcli = NULL, coreCli; -HIMAGELIST himlCListClc = NULL; +HINSTANCE g_hInst = nullptr; +CLIST_INTERFACE* pcli = nullptr, coreCli; +HIMAGELIST himlCListClc = nullptr; int hLangpack; ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/stdcrypt/src/Rijndael.cpp b/src/core/stdcrypt/src/Rijndael.cpp index 3392d5022c..510af48871 100644 --- a/src/core/stdcrypt/src/Rijndael.cpp +++ b/src/core/stdcrypt/src/Rijndael.cpp @@ -933,7 +933,7 @@ CRijndael::~CRijndael() // blockSize - The block size in bytes of this Rijndael (16, 24 or 32 bytes). int CRijndael::MakeKey(BYTE const* key, char const* chain, int keylength, int blockSize) { - if (NULL == key) + if (nullptr == key) return 1; if (!(16 == keylength || 24 == keylength || 32 == keylength)) return 2; diff --git a/src/core/stdcrypt/src/encrypt.cpp b/src/core/stdcrypt/src/encrypt.cpp index 1ca04f4782..3439772592 100644 --- a/src/core/stdcrypt/src/encrypt.cpp +++ b/src/core/stdcrypt/src/encrypt.cpp @@ -119,10 +119,10 @@ void CStdCrypt::setPassword(const char *pszPassword) // result must be freed using mir_free or assigned to mir_ptr BYTE* CStdCrypt::encodeString(const char *src, size_t *cbResultLen) { - if (!m_valid || src == NULL) { + if (!m_valid || src == nullptr) { if (cbResultLen) *cbResultLen = 0; - return NULL; + return nullptr; } return encodeBuffer(src, mir_strlen(src)+1, cbResultLen); @@ -133,8 +133,8 @@ BYTE* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen if (cbResultLen) *cbResultLen = 0; - if (!m_valid || src == NULL || cbLen >= 0xFFFE) - return NULL; + if (!m_valid || src == nullptr || cbLen >= 0xFFFE) + return nullptr; BYTE *tmpBuf = (BYTE*)_alloca(cbLen + 2); *(PWORD)tmpBuf = (WORD)cbLen; @@ -148,7 +148,7 @@ BYTE* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen m_aes.ResetChain(); if (m_aes.Encrypt(tmpBuf, LPSTR(result), cbLen)) { mir_free(result); - return NULL; + return nullptr; } if (cbResultLen) @@ -163,7 +163,7 @@ char* CStdCrypt::decodeString(const BYTE *pBuf, size_t bufLen, size_t *cbResultL if (result) { if (result[resLen-1] != 0) { // smth went wrong mir_free(result); - return NULL; + return nullptr; } } @@ -177,21 +177,21 @@ void* CStdCrypt::decodeBuffer(const BYTE *pBuf, size_t bufLen, size_t *cbResultL if (cbResultLen) *cbResultLen = 0; - if (!m_valid || pBuf == NULL || (bufLen % BLOCK_SIZE) != 0) - return NULL; + if (!m_valid || pBuf == nullptr || (bufLen % BLOCK_SIZE) != 0) + return nullptr; char *result = (char*)mir_alloc(bufLen + 1); m_aes.ResetChain(); if (m_aes.Decrypt(LPCSTR(pBuf), result, bufLen)) { mir_free(result); - return NULL; + return nullptr; } result[bufLen] = 0; WORD cbLen = *(PWORD)result; if (cbLen > bufLen) { mir_free(result); - return NULL; + return nullptr; } memmove(result, result + 2, cbLen); diff --git a/src/core/stdcrypt/src/utils.cpp b/src/core/stdcrypt/src/utils.cpp index c7bf59fbfd..27e641d1cd 100644 --- a/src/core/stdcrypt/src/utils.cpp +++ b/src/core/stdcrypt/src/utils.cpp @@ -27,9 +27,9 @@ bool getRandomBytes(BYTE *buf, size_t bufLen) { // try to use Intel hardware randomizer first HCRYPTPROV hProvider = NULL; - if (::CryptAcquireContext(&hProvider, NULL, L"Intel Hardware Cryptographic Service Provider", PROV_INTEL_SEC, 0) || - ::CryptAcquireContext(&hProvider, NULL, MS_STRONG_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) || - ::CryptAcquireContext(&hProvider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + if (::CryptAcquireContext(&hProvider, nullptr, L"Intel Hardware Cryptographic Service Provider", PROV_INTEL_SEC, 0) || + ::CryptAcquireContext(&hProvider, nullptr, MS_STRONG_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) || + ::CryptAcquireContext(&hProvider, nullptr, nullptr, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { ::CryptGenRandom(hProvider, DWORD(bufLen), buf); ::CryptReleaseContext(hProvider, 0); @@ -38,7 +38,7 @@ bool getRandomBytes(BYTE *buf, size_t bufLen) else { typedef BOOL(WINAPI *pfnGetRandom)(PVOID RandomBuffer, ULONG RandomBufferLength); pfnGetRandom fnGetRandom = (pfnGetRandom)GetProcAddress(GetModuleHandleA("advapi32.dll"), "SystemFunction036"); - if (fnGetRandom == NULL) + if (fnGetRandom == nullptr) return false; fnGetRandom(buf, DWORD(bufLen)); diff --git a/src/core/stdemail/src/email.cpp b/src/core/stdemail/src/email.cpp index a5f36e95ea..66f42ce61d 100644 --- a/src/core/stdemail/src/email.cpp +++ b/src/core/stdemail/src/email.cpp @@ -27,7 +27,7 @@ static HGENMENU hEMailMenuItem; void SendEmailThread(void *szUrl) { - ShellExecuteA(NULL, "open", (char*)szUrl, "", "", SW_SHOW); + ShellExecuteA(nullptr, "open", (char*)szUrl, "", "", SW_SHOW); mir_free(szUrl); return; } @@ -36,7 +36,7 @@ static INT_PTR SendEMailCommand(WPARAM hContact, LPARAM lParam) { DBVARIANT dbv; char *szProto = GetContactProto(hContact); - if (szProto == NULL || db_get_s(hContact, szProto, "e-mail", &dbv)) { + if (szProto == nullptr || db_get_s(hContact, szProto, "e-mail", &dbv)) { if (db_get_s(hContact, "UserInfo", "Mye-mail0", &dbv)) { MessageBox((HWND)lParam, TranslateT("User has not registered an e-mail address"), TranslateT("Send e-mail"), MB_OK); return 1; @@ -55,7 +55,7 @@ static int EMailPreBuildMenu(WPARAM hContact, LPARAM) bool bEnabled = true; DBVARIANT dbv = { 0 }; char *szProto = GetContactProto(hContact); - if (szProto == NULL || db_get_s(hContact, szProto, "e-mail", &dbv)) + if (szProto == nullptr || db_get_s(hContact, szProto, "e-mail", &dbv)) if (db_get_s(hContact, "UserInfo", "Mye-mail0", &dbv)) bEnabled = false; diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index 3d391dd7a7..b2e5b04769 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -46,7 +46,7 @@ static INT_PTR SendFileCommand(WPARAM hContact, LPARAM) { struct FileSendData fsd; fsd.hContact = hContact; - fsd.ppFiles = NULL; + fsd.ppFiles = nullptr; return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); } @@ -57,13 +57,13 @@ static INT_PTR SendSpecificFiles(WPARAM hContact, LPARAM lParam) char** ppFiles = (char**)lParam; int count = 0; - while (ppFiles[count] != NULL) + while (ppFiles[count] != nullptr) count++; fsd.ppFiles = (const wchar_t**)alloca((count + 1) * sizeof(void*)); for (int i = 0; i < count; i++) fsd.ppFiles[i] = mir_a2u(ppFiles[i]); - fsd.ppFiles[count] = NULL; + fsd.ppFiles[count] = nullptr; HWND hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); for (int j = 0; j < count; j++) @@ -141,7 +141,7 @@ int SRFile_GetRegValue(HKEY hKeyBase, const wchar_t *szSubKey, const wchar_t *sz if (RegOpenKeyEx(hKeyBase, szSubKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) return 0; - if (RegQueryValueEx(hKey, szValue, NULL, NULL, (PBYTE)szOutput, &cbOut) != ERROR_SUCCESS) { + if (RegQueryValueEx(hKey, szValue, nullptr, nullptr, (PBYTE)szOutput, &cbOut) != ERROR_SUCCESS) { RegCloseKey(hKey); return 0; } @@ -175,20 +175,20 @@ void GetSensiblyFormattedSize(__int64 size, wchar_t *szOut, int cchOut, int unit // Tripple redirection sucks but is needed to nullify the array pointer void FreeFilesMatrix(wchar_t ***files) { - if (*files == NULL) + if (*files == nullptr) return; // Free each filename in the pointer array wchar_t **pFile = *files; - while (*pFile != NULL) { + while (*pFile != nullptr) { mir_free(*pFile); - *pFile = NULL; + *pFile = nullptr; pFile++; } // Free the array itself mir_free(*files); - *files = NULL; + *files = nullptr; } void FreeProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *fts) @@ -222,7 +222,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS if (dest->totalFiles != src->totalFiles) { for (int i = 0; i < dest->totalFiles; i++) mir_free(dest->ptszFiles[i]); mir_free(dest->ptszFiles); - dest->ptszFiles = NULL; + dest->ptszFiles = nullptr; dest->totalFiles = src->totalFiles; } if (src->ptszFiles) { @@ -234,14 +234,14 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS if (src->ptszFiles[i]) dest->ptszFiles[i] = PFTS_StringToTchar(src->flags, src->ptszFiles[i]); else - dest->ptszFiles[i] = NULL; + dest->ptszFiles[i] = nullptr; } } else if (dest->ptszFiles) { for (int i = 0; i < dest->totalFiles; i++) mir_free(dest->ptszFiles[i]); mir_free(dest->ptszFiles); - dest->ptszFiles = NULL; + dest->ptszFiles = nullptr; } dest->currentFileNumber = src->currentFileNumber; @@ -252,7 +252,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS if (src->tszWorkingDir) dest->tszWorkingDir = PFTS_StringToTchar(src->flags, src->tszWorkingDir); else - dest->tszWorkingDir = NULL; + dest->tszWorkingDir = nullptr; } if (!dest->tszCurrentFile || !src->tszCurrentFile || PFTS_CompareWithTchar(src, src->tszCurrentFile, dest->tszCurrentFile)) { @@ -260,7 +260,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS if (src->tszCurrentFile) dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile); else - dest->tszCurrentFile = NULL; + dest->tszCurrentFile = nullptr; } dest->currentFileSize = src->currentFileSize; dest->currentFileProgress = src->currentFileProgress; @@ -287,7 +287,7 @@ static int SRFilePreBuildMenu(WPARAM wParam, LPARAM) { bool bEnabled = false; char *szProto = GetContactProto(wParam); - if (szProto != NULL) { + if (szProto != nullptr) { bool isChat = db_get_b(wParam, szProto, "ChatRoom", false) != 0; if (CallProtoService(szProto, PS_GETCAPS, isChat ? PFLAGNUM_4 : PFLAGNUM_1, 0) & (isChat ? PF4_GROUPCHATFILES : PF1_FILESEND)) { if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_OFFLINEFILES) @@ -338,7 +338,7 @@ INT_PTR openContRecDir(WPARAM hContact, LPARAM) { wchar_t szContRecDir[MAX_PATH]; GetContactReceivedFilesDir(hContact, szContRecDir, _countof(szContRecDir), TRUE); - ShellExecute(0, L"open", szContRecDir, 0, 0, SW_SHOW); + ShellExecute(nullptr, L"open", szContRecDir, nullptr, nullptr, SW_SHOW); return 0; } @@ -346,7 +346,7 @@ INT_PTR openRecDir(WPARAM, LPARAM) { wchar_t szContRecDir[MAX_PATH]; GetReceivedFilesDir(szContRecDir, _countof(szContRecDir)); - ShellExecute(0, L"open", szContRecDir, 0, 0, SW_SHOW); + ShellExecute(nullptr, L"open", szContRecDir, nullptr, nullptr, SW_SHOW); return 0; } @@ -389,7 +389,7 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam) dbei.cbBlob += (int)mir_strlen(szDescr) + 1; - if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == 0) + if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == nullptr) return 0; *(DWORD*)dbei.pBlob = 0; @@ -401,7 +401,7 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam) mir_free(pszFiles[i]); } - mir_strcpy((char*)p, (szDescr == NULL) ? "" : szDescr); + mir_strcpy((char*)p, (szDescr == nullptr) ? "" : szDescr); if (bUnicode) mir_free(szDescr); diff --git a/src/core/stdfile/src/fileexistsdlg.cpp b/src/core/stdfile/src/fileexistsdlg.cpp index 13e2557e35..217d80fa82 100644 --- a/src/core/stdfile/src/fileexistsdlg.cpp +++ b/src/core/stdfile/src/fileexistsdlg.cpp @@ -54,7 +54,7 @@ static void DoAnnoyingShellCommand(HWND hwnd, const wchar_t *szFilename, int cmd ITEMIDLIST *pCurrentIdl; WCHAR* wszFilename = (LPWSTR)szFilename; - if (pDesktopFolder->ParseDisplayName(NULL, NULL, wszFilename, NULL, &pCurrentIdl, NULL) == NOERROR) { + if (pDesktopFolder->ParseDisplayName(nullptr, nullptr, wszFilename, nullptr, &pCurrentIdl, nullptr) == NOERROR) { if (pCurrentIdl->mkid.cb) { ITEMIDLIST *pidl, *pidlNext, *pidlFilename; IShellFolder *pFileFolder; @@ -69,9 +69,9 @@ static void DoAnnoyingShellCommand(HWND hwnd, const wchar_t *szFilename, int cmd } pidl = pidlNext; } - if (pDesktopFolder->BindToObject(pCurrentIdl, NULL, IID_IShellFolder, (void**)&pFileFolder) == NOERROR) { + if (pDesktopFolder->BindToObject(pCurrentIdl, nullptr, IID_IShellFolder, (void**)&pFileFolder) == NOERROR) { IContextMenu *pContextMenu; - if (pFileFolder->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&pidlFilename, IID_IContextMenu, NULL, (void**)&pContextMenu) == NOERROR) { + if (pFileFolder->GetUIObjectOf(nullptr, 1, (LPCITEMIDLIST*)&pidlFilename, IID_IContextMenu, nullptr, (void**)&pContextMenu) == NOERROR) { switch (cmd) { case C_PROPERTIES: { @@ -87,7 +87,7 @@ static void DoAnnoyingShellCommand(HWND hwnd, const wchar_t *szFilename, int cmd case C_CONTEXTMENU: HMENU hMenu = CreatePopupMenu(); if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1000, 65535, (GetKeyState(VK_SHIFT) & 0x8000 ? CMF_EXTENDEDVERBS : 0) | CMF_NORMAL))) { - int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL); + int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, nullptr); if (ret) { CMINVOKECOMMANDINFO ici = { 0 }; ici.cbSize = sizeof(ici); @@ -118,7 +118,7 @@ static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, switch (msg) { case WM_LBUTTONDBLCLK: - ShellExecute(hwnd, NULL, pft->tszCurrentFile, NULL, NULL, SW_SHOW); + ShellExecute(hwnd, nullptr, pft->tszCurrentFile, nullptr, nullptr, SW_SHOW); break; case WM_RBUTTONUP: POINT pt; @@ -144,7 +144,7 @@ void __cdecl LoadIconsAndTypesThread(void* param) wchar_t szExtension[64], szIconFile[MAX_PATH]; wchar_t *pszFilename = wcsrchr(info->szFilename, '\\'); - if (pszFilename == NULL) + if (pszFilename == nullptr) pszFilename = info->szFilename; wchar_t *pszExtension = wcsrchr(pszFilename, '.'); diff --git a/src/core/stdfile/src/fileopts.cpp b/src/core/stdfile/src/fileopts.cpp index d751fce211..1b30b39758 100644 --- a/src/core/stdfile/src/fileopts.cpp +++ b/src/core/stdfile/src/fileopts.cpp @@ -37,7 +37,7 @@ struct virusscannerinfo { } virusScanners[] = { {L"Network Associates/McAfee VirusScan", L"SOFTWARE\\McAfee\\VirusScan", L"Scan32EXE", L"\"%s\" %%f /nosplash /comp /autoscan /autoexit /noboot"}, {L"Dr Solomon's VirusScan (Network Associates)", L"SOFTWARE\\Network Associates\\TVD\\VirusScan\\AVConsol\\General", L"szScannerExe", L"\"%s\" %%f /uinone /noboot /comp /prompt /autoexit"}, - {L"Norton AntiVirus", L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe", NULL, L"\"%s\" %%f /b- /m- /s+ /noresults"}, + {L"Norton AntiVirus", L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe", nullptr, L"\"%s\" %%f /b- /m- /s+ /noresults"}, {L"Computer Associates/Inoculate IT", L"Software\\Antivirus", L"ImageFilename", L"\"%s\" %%f /display = progress /exit"}, {L"Computer Associates eTrust", L"SOFTWARE\\ComputerAssociates\\Anti-Virus\\Resident", L"VetPath", L"\"%s\" %%f /display = progress /exit"}, {L"Kaspersky Anti-Virus", L"SOFTWARE\\KasperskyLab\\Components\\101", L"EXEName", L"\"%s\" /S /Q %%f"}, @@ -188,7 +188,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L } ofn.nMaxFileTitle = MAX_PATH; if (!GetOpenFileName(&ofn)) break; - if (wcschr(str, ' ') != NULL) { + if (wcschr(str, ' ') != nullptr) { memmove(str + 1, str, ((_countof(str) - 2) * sizeof(wchar_t))); str[0] = '"'; mir_wstrcat(str, L"\""); diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index 5f6baa2e04..baf12e60ec 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -41,7 +41,7 @@ static void GetLowestExistingDirName(const wchar_t *szTestDir, wchar_t *szExisti mir_wstrncpy(szExistingDir, szTestDir, cchExistingDir); while ((dwAttributes = GetFileAttributes(szExistingDir)) != INVALID_FILE_ATTRIBUTES && !(dwAttributes&FILE_ATTRIBUTE_DIRECTORY)) { pszLastBackslash = wcsrchr(szExistingDir, '\\'); - if (pszLastBackslash == NULL) { *szExistingDir = '\0'; break; } + if (pszLastBackslash == nullptr) { *szExistingDir = '\0'; break; } *pszLastBackslash = '\0'; } if (szExistingDir[0] == '\0') @@ -83,7 +83,7 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p int BrowseForFolder(HWND hwnd, wchar_t *szPath) { - BROWSEINFO bi = { 0 }; + BROWSEINFO bi = {}; bi.hwndOwner = hwnd; bi.pszDisplayName = szPath; bi.lpszTitle = TranslateT("Select folder"); @@ -97,7 +97,7 @@ int BrowseForFolder(HWND hwnd, wchar_t *szPath) mir_wstrcat(szPath, L"\\"); CoTaskMemFree(pidlResult); } - return pidlResult != NULL; + return pidlResult != nullptr; } static REPLACEVARSARRAY sttVarsToReplace[] = @@ -105,7 +105,7 @@ static REPLACEVARSARRAY sttVarsToReplace[] = { "///", "//" }, { "//", "/" }, { "()", "" }, - { NULL, NULL } + { nullptr, nullptr } }; static void patchDir(wchar_t *str, size_t strSize) @@ -141,8 +141,8 @@ void GetContactReceivedFilesDir(MCONTACT hContact, wchar_t *szDir, int cchDir, B rvaVarsToReplace[1].value.w = GetContactID(hContact); rvaVarsToReplace[2].key.w = L"proto"; rvaVarsToReplace[2].value.w = mir_a2u(GetContactProto(hContact)); - rvaVarsToReplace[3].key.w = NULL; - rvaVarsToReplace[3].value.w = NULL; + rvaVarsToReplace[3].key.w = nullptr; + rvaVarsToReplace[3].value.w = nullptr; for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++) RemoveInvalidFilenameChars(rvaVarsToReplace[i].value.w); @@ -277,7 +277,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { - DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); + DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, nullptr, DI_NORMAL); DestroyIcon(hIcon); } } @@ -341,7 +341,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDCANCEL: if (dat->fs) ProtoChainSend(dat->hContact, PSS_FILEDENY, (WPARAM)dat->fs, (LPARAM)TranslateT("Canceled")); - dat->fs = NULL; /* the protocol will free the handle */ + dat->fs = nullptr; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; @@ -380,7 +380,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case HM_RECVEVENT: { ACKDATA *ack = (ACKDATA*)lParam; - if ((ack == NULL) || (ack->hProcess != dat->fs) || (ack->type != ACKTYPE_FILE) || (ack->hContact != dat->hContact)) + if ((ack == nullptr) || (ack->hProcess != dat->fs) || (ack->type != ACKTYPE_FILE) || (ack->hContact != dat->hContact)) break; if (ack->result == ACKRESULT_DENIED || ack->result == ACKRESULT_FAILED) { diff --git a/src/core/stdfile/src/filesenddlg.cpp b/src/core/stdfile/src/filesenddlg.cpp index 1e2741f1d2..c8c6fb4a3d 100644 --- a/src/core/stdfile/src/filesenddlg.cpp +++ b/src/core/stdfile/src/filesenddlg.cpp @@ -97,7 +97,7 @@ static void FilenameToFileList(HWND hwndDlg, FileDlgData* dat, const wchar_t *bu } // Allocate memory for a pointer array - if ((dat->files = (wchar_t**)mir_alloc((nNumberOfFiles + 1) * sizeof(wchar_t*))) == NULL) + if ((dat->files = (wchar_t**)mir_alloc((nNumberOfFiles + 1) * sizeof(wchar_t*))) == nullptr) return; // Fill the array @@ -118,15 +118,15 @@ static void FilenameToFileList(HWND hwndDlg, FileDlgData* dat, const wchar_t *bu nTemp++; } // Terminate array - dat->files[nNumberOfFiles] = NULL; + dat->files[nNumberOfFiles] = nullptr; } // ...the selection is a single file else { - if ((dat->files = (wchar_t **)mir_alloc(2 * sizeof(wchar_t*))) == NULL) // Leaks when aborted + if ((dat->files = (wchar_t **)mir_alloc(2 * sizeof(wchar_t*))) == nullptr) // Leaks when aborted return; dat->files[0] = mir_wstrdup(buf); - dat->files[1] = NULL; + dat->files[1] = nullptr; } // Update dialog text with new file selection @@ -140,7 +140,7 @@ void __cdecl ChooseFilesThread(void* param) FileDlgData *dat = (FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); wchar_t *buf = (wchar_t*)mir_alloc(sizeof(wchar_t) * 32767); - if (buf == NULL) { + if (buf == nullptr) { PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, NULL); return; } @@ -212,7 +212,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l dat->hContact = fsd->hContact; dat->send = 1; dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); - dat->fs = NULL; + dat->fs = nullptr; dat->dwTicks = GetTickCount(); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); @@ -225,13 +225,13 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); - if (fsd->ppFiles != NULL && fsd->ppFiles[0] != NULL) { + if (fsd->ppFiles != nullptr && fsd->ppFiles[0] != nullptr) { int totalCount, i; for (totalCount = 0; fsd->ppFiles[totalCount]; totalCount++); dat->files = (wchar_t**)mir_alloc(sizeof(wchar_t*)*(totalCount + 1)); // Leaks for (i = 0; i < totalCount; i++) dat->files[i] = mir_wstrdup(fsd->ppFiles[i]); - dat->files[totalCount] = NULL; + dat->files[totalCount] = nullptr; SetFileListAndSizeControls(hwndDlg, dat); } @@ -241,7 +241,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l ptrW id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact)); SetDlgItemText(hwndDlg, IDC_NAME, (id) ? id : contactName); - if (fsd->ppFiles == NULL) { + if (fsd->ppFiles == nullptr) { EnableWindow(hwndDlg, FALSE); dat->closeIfFileChooseCancelled = 1; PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_CHOOSE, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDC_CHOOSE)); @@ -260,7 +260,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); if (hIcon) { - DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); + DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, nullptr, DI_NORMAL); DestroyIcon(hIcon); } } diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp index d3499bfcb8..37a22a1dcf 100644 --- a/src/core/stdfile/src/filexferdlg.cpp +++ b/src/core/stdfile/src/filexferdlg.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static int CheckVirusScanned(HWND hwnd, FileDlgData *dat, int i) { if (dat->send) return 1; - if (dat->fileVirusScanned == NULL) return 0; + if (dat->fileVirusScanned == nullptr) return 0; if (dat->fileVirusScanned[i]) return 1; if (db_get_b(NULL, "SRFile", "WarnBeforeOpening", 1) == 0) return 1; return IDYES == MessageBox(hwnd, TranslateT("This file has not yet been scanned for viruses. Are you certain you want to open it?"), TranslateT("File received"), MB_YESNO|MB_DEFBUTTON2); @@ -78,7 +78,7 @@ void FillSendData(FileDlgData *dat, DBEVENTINFO& dbei) dbei.szModule = GetContactProto(dat->hContact); dbei.eventType = EVENTTYPE_FILE; dbei.flags = DBEF_SENT; - dbei.timestamp = time(NULL); + dbei.timestamp = time(nullptr); char *szFileNames = Utf8EncodeW(dat->szFilenames), *szMsg = Utf8EncodeW(dat->szMsg); dbei.flags |= DBEF_UTF; @@ -109,7 +109,7 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) wcsncpy_s(szCmdLine, dbv.ptszVal, _TRUNCATE); PROCESS_INFORMATION pi; - if (CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + if (CreateProcess(nullptr, szCmdLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) { if (WaitForSingleObject(pi.hProcess, 3600 * 1000) == WAIT_OBJECT_0) PostMessage(info->hwndReply, M_VIRUSSCANDONE, info->returnCode, 0); CloseHandle(pi.hProcess); @@ -125,17 +125,17 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) static void SetFilenameControls(HWND hwndDlg, FileDlgData *dat, PROTOFILETRANSFERSTATUS *fts) { wchar_t msg[MAX_PATH]; - wchar_t *fnbuf = NULL, *fn = NULL; - SHFILEINFO shfi = { 0 }; + wchar_t *fnbuf = nullptr, *fn = nullptr; + SHFILEINFO shfi = {}; if (fts->tszCurrentFile) { fnbuf = mir_wstrdup(fts->tszCurrentFile); - if ((fn = wcsrchr(fnbuf, '\\')) == NULL) + if ((fn = wcsrchr(fnbuf, '\\')) == nullptr) fn = fnbuf; else fn++; } - if (dat->hIcon) DestroyIcon(dat->hIcon); dat->hIcon = NULL; + if (dat->hIcon) DestroyIcon(dat->hIcon); dat->hIcon = nullptr; if (fn && (fts->totalFiles > 1)) { mir_snwprintf(msg, L"%s: %s (%d %s %d)", @@ -182,8 +182,8 @@ static void HideProgressControls(HWND hwndDlg) char buf[64]; GetWindowRect(GetDlgItem(hwndDlg, IDC_ALLPRECENTS), &rc); - MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc, 2); - SetWindowPos(hwndDlg, NULL, 0, 0, 100, rc.bottom + 3, SWP_NOMOVE | SWP_NOZORDER); + MapWindowPoints(nullptr, hwndDlg, (LPPOINT)&rc, 2); + SetWindowPos(hwndDlg, nullptr, 0, 0, 100, rc.bottom + 3, SWP_NOMOVE | SWP_NOZORDER); ShowWindow(GetDlgItem(hwndDlg, IDC_ALLTRANSFERRED), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_ALLSPEED), SW_HIDE); @@ -265,11 +265,11 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR hFont = CreateFontIndirect(&lf); SendDlgItemMessage(hwndDlg, IDC_CONTACTNAME, WM_SETFONT, (WPARAM)hFont, 0); - SHFILEINFO shfi = { 0 }; + SHFILEINFO shfi = {}; SHGetFileInfo(L"", FILE_ATTRIBUTE_DIRECTORY, &shfi, sizeof(shfi), SHGFI_USEFILEATTRIBUTES | SHGFI_ICON | SHGFI_SMALLICON); dat->hIconFolder = shfi.hIcon; } - dat->hIcon = NULL; + dat->hIcon = nullptr; { char *szProto = GetContactProto(dat->hContact); WORD status = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_ONLINE); @@ -290,7 +290,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hwndDlg, IDC_CONTACTNAME, pcli->pfnGetContactDisplayName(dat->hContact, 0)); - if (!dat->waitingForAcceptance) SetTimer(hwndDlg, 1, 1000, NULL); + if (!dat->waitingForAcceptance) SetTimer(hwndDlg, 1, 1000, nullptr); return TRUE; case WM_TIMER: @@ -384,7 +384,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case IDC_OPENFILE: wchar_t **files; if (dat->send) { - if (dat->files == NULL) + if (dat->files == nullptr) files = dat->transferStatus.ptszFiles; else files = dat->files; @@ -393,7 +393,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, 1, TranslateT("Open folder")); - AppendMenu(hMenu, MF_SEPARATOR, 0, 0); + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); if (files && *files) { int limit; @@ -407,7 +407,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR // Loop over all transfered files and add them to the menu for (int i = 0; i < limit; i++) { pszFilename = wcsrchr(files[i], '\\'); - if (pszFilename == NULL) + if (pszFilename == nullptr) pszFilename = files[i]; else pszFilename++; @@ -432,7 +432,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR RECT rc; GetWindowRect((HWND)lParam, &rc); CheckDlgButton(hwndDlg, IDC_OPENFILE, BST_CHECKED); - int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_RIGHTALIGN, rc.right, rc.bottom, 0, hwndDlg, NULL); + int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_RIGHTALIGN, rc.right, rc.bottom, 0, hwndDlg, nullptr); CheckDlgButton(hwndDlg, IDC_OPENFILE, BST_UNCHECKED); DestroyMenu(hMenu); @@ -445,10 +445,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR *p = 0; } - if (path) ShellExecute(NULL, L"open", path, NULL, NULL, SW_SHOW); + if (path) ShellExecute(nullptr, L"open", path, nullptr, nullptr, SW_SHOW); } else if (ret && CheckVirusScanned(hwndDlg, dat, ret)) - ShellExecute(NULL, NULL, files[ret - 10], NULL, NULL, SW_SHOW); + ShellExecute(nullptr, nullptr, files[ret - 10], nullptr, nullptr, SW_SHOW); } break; @@ -462,7 +462,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR switch (pfr->action) { case FILERESUME_CANCEL: if (dat->fs) ProtoChainSend(dat->hContact, PSS_FILECANCEL, (WPARAM)dat->fs, 0); - dat->fs = NULL; + dat->fs = nullptr; mir_free(szOriginalFilename); if (pfr->szFilename) mir_free((char*)pfr->szFilename); mir_free(pfr); @@ -476,8 +476,8 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR pfr->action = FILERESUME_RENAME; { wchar_t *pszExtension, *pszFilename; - if ((pszFilename = wcsrchr(szOriginalFilename, '\\')) == NULL) pszFilename = szOriginalFilename; - if ((pszExtension = wcsrchr(pszFilename + 1, '.')) == NULL) pszExtension = pszFilename + mir_wstrlen(pszFilename); + if ((pszFilename = wcsrchr(szOriginalFilename, '\\')) == nullptr) pszFilename = szOriginalFilename; + if ((pszExtension = wcsrchr(pszFilename + 1, '.')) == nullptr) pszExtension = pszFilename + mir_wstrlen(pszFilename); if (pfr->szFilename) mir_free((wchar_t*)pfr->szFilename); size_t size = (pszExtension - szOriginalFilename) + 21 + mir_wstrlen(pszExtension); pfr->szFilename = (wchar_t*)mir_alloc(sizeof(wchar_t)*size); @@ -504,7 +504,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (ack->hContact != dat->hContact) break; if (dat->waitingForAcceptance) { - SetTimer(hwndDlg, 1, 1000, NULL); + SetTimer(hwndDlg, 1, 1000, nullptr); dat->waitingForAcceptance = 0; } @@ -552,7 +552,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR else { PROTOFILERESUME *pfr = (PROTOFILERESUME*)mir_alloc(sizeof(PROTOFILERESUME)); pfr->action = dat->resumeBehaviour; - pfr->szFilename = NULL; + pfr->szFilename = nullptr; PostMessage(hwndDlg, M_FILEEXISTSDLGREPLY, (WPARAM)mir_wstrdup(fts->tszCurrentFile), (LPARAM)pfr); } } @@ -564,14 +564,14 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR PROTOFILETRANSFERSTATUS *fts = (PROTOFILETRANSFERSTATUS*)ack->lParam; wchar_t str[64], str2[64], szSizeDone[32], szSizeTotal[32];//, *contactName; - if (dat->fileVirusScanned == NULL) + if (dat->fileVirusScanned == nullptr) dat->fileVirusScanned = (int*)mir_calloc(sizeof(int) * fts->totalFiles); // This needs to be here - otherwise we get holes in the files array if (!dat->send) { - if (dat->files == NULL) + if (dat->files == nullptr) dat->files = (wchar_t**)mir_calloc((fts->totalFiles + 1) * sizeof(wchar_t*)); - if (fts->currentFileNumber < fts->totalFiles && dat->files[fts->currentFileNumber] == NULL) + if (fts->currentFileNumber < fts->totalFiles && dat->files[fts->currentFileNumber] == nullptr) dat->files[fts->currentFileNumber] = PFTS_StringToTchar(fts->flags, fts->tszCurrentFile); } @@ -620,30 +620,30 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Close")); if (dat->hNotifyEvent) UnhookEvent(dat->hNotifyEvent); - dat->hNotifyEvent = NULL; + dat->hNotifyEvent = nullptr; if (ack->result == ACKRESULT_DENIED) { - dat->fs = NULL; /* protocol will free structure */ + dat->fs = nullptr; /* protocol will free structure */ Skin_PlaySound("FileDenied"); SetFtStatus(hwndDlg, LPGENW("File transfer denied"), FTS_TEXT); } else if (ack->result == ACKRESULT_FAILED) { - dat->fs = NULL; /* protocol will free structure */ + dat->fs = nullptr; /* protocol will free structure */ Skin_PlaySound("FileFailed"); SetFtStatus(hwndDlg, LPGENW("File transfer failed"), FTS_TEXT); } else { Skin_PlaySound("FileDone"); if (dat->send) { - dat->fs = NULL; /* protocol will free structure */ + dat->fs = nullptr; /* protocol will free structure */ SetFtStatus(hwndDlg, LPGENW("Transfer completed."), FTS_TEXT); - DBEVENTINFO dbei = { 0 }; + DBEVENTINFO dbei = {}; FillSendData(dat, dbei); db_event_add(dat->hContact, &dbei); if (dbei.pBlob) mir_free(dbei.pBlob); - dat->files = NULL; //protocol library frees this + dat->files = nullptr; //protocol library frees this } else { SetFtStatus(hwndDlg, @@ -662,7 +662,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) { PostMessage(hwndDlg, M_VIRUSSCANDONE, vstsi->returnCode, 0); mir_free(vstsi); - vstsi = NULL; + vstsi = nullptr; } else vstsi->szFile = mir_wstrdup(dat->files[dat->transferStatus.currentFileNumber]); } @@ -674,7 +674,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (vstsi) mir_forkthread((void(*)(void*))RunVirusScannerThread, vstsi); } - else dat->fs = NULL; /* protocol will free structure */ + else dat->fs = nullptr; /* protocol will free structure */ dat->transferStatus.currentFileNumber = dat->transferStatus.totalFiles; } // else dat->send @@ -703,7 +703,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } } if (done) { - dat->fs = NULL; /* protocol will free structure */ + dat->fs = nullptr; /* protocol will free structure */ SetFtStatus(hwndDlg, LPGENW("Transfer and virus scan complete"), FTS_TEXT); } } @@ -737,7 +737,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR void FreeFileDlgData(FileDlgData* dat) { - if (dat == NULL) + if (dat == nullptr) return; if (dat->fs) diff --git a/src/core/stdfile/src/ftmanager.cpp b/src/core/stdfile/src/ftmanager.cpp index fa749d503e..a70a26d2eb 100644 --- a/src/core/stdfile/src/ftmanager.cpp +++ b/src/core/stdfile/src/ftmanager.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include "file.h" -static HWND hwndFtMgr = NULL; +static HWND hwndFtMgr = nullptr; struct TFtMgrData { @@ -78,8 +78,8 @@ static void LayoutTransfers(HWND hwnd, struct TFtPageData *dat) top -= dat->scrollPos; for (int i = 0; i < dat->wnds->realCount; ++i) { int height = dat->wnds->items[i]->rc.bottom - dat->wnds->items[i]->rc.top; - if (NULL != dat->wnds->items[i]->hwnd) /* Wine fix. */ - hdwp = DeferWindowPos(hdwp, dat->wnds->items[i]->hwnd, NULL, 0, top, rc.right, height, SWP_NOZORDER); + if (nullptr != dat->wnds->items[i]->hwnd) /* Wine fix. */ + hdwp = DeferWindowPos(hdwp, dat->wnds->items[i]->hwnd, nullptr, 0, top, rc.right, height, SWP_NOZORDER); top += height; } top += dat->scrollPos; @@ -215,7 +215,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA if (pos < 0) pos = 0; if (dat->scrollPos != pos) { - ScrollWindow(hwnd, 0, dat->scrollPos - pos, NULL, NULL); + ScrollWindow(hwnd, 0, dat->scrollPos - pos, nullptr, nullptr); SetScrollPos(hwnd, SB_VERT, pos, TRUE); dat->scrollPos = pos; } @@ -306,25 +306,25 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM hdwp = BeginDeferWindowPos(3); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_CLEAR), NULL, rc.left, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), NULL, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); + hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), nullptr, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); rc.bottom -= rcButton.bottom + 5; - if (NULL != hwndTab) /* Wine fix. */ - hdwp = DeferWindowPos(hdwp, hwndTab, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); + if (nullptr != hwndTab) /* Wine fix. */ + hdwp = DeferWindowPos(hdwp, hwndTab, nullptr, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); EndDeferWindowPos(hdwp); GetWindowRect(hwndTab, &rc); - MapWindowPoints(NULL, hwnd, (LPPOINT)&rc, 2); + MapWindowPoints(nullptr, hwnd, (LPPOINT)&rc, 2); TabCtrl_AdjustRect(hwndTab, FALSE, &rc); InflateRect(&rc, -5, -5); hdwp = BeginDeferWindowPos(2); - if (NULL != dat->hwndIncoming) /* Wine fix. */ + if (nullptr != dat->hwndIncoming) /* Wine fix. */ hdwp = DeferWindowPos(hdwp, dat->hwndIncoming, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); - if (NULL != dat->hwndOutgoing) /* Wine fix. */ + if (nullptr != dat->hwndOutgoing) /* Wine fix. */ hdwp = DeferWindowPos(hdwp, dat->hwndOutgoing, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); EndDeferWindowPos(hdwp); @@ -444,7 +444,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case WM_TIMER: if (pTaskbarInterface) { - SetTimer(hwnd, 1, 400, NULL); + SetTimer(hwnd, 1, 400, nullptr); if ((lParam == ACKRESULT_FAILED) || (lParam == ACKRESULT_DENIED)) dat->errorState = TBPF_ERROR; @@ -478,7 +478,7 @@ HWND FtMgr_Show(bool bForceActivate, bool bFromMenu) { bool bAutoMin = db_get_b(NULL, "SRFile", "AutoMin", 0) != 0; /* lqbe */ - bool bJustCreated = (hwndFtMgr == NULL); + bool bJustCreated = (hwndFtMgr == nullptr); if (bJustCreated) hwndFtMgr = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTMGR), NULL, FtMgrDlgProc); @@ -522,8 +522,8 @@ HWND FtMgr_AddTransfer(FileDlgData *fdd) { bool bForceActivate = fdd->send || !db_get_b(NULL, "SRFile", "AutoAccept", 0); TFtMgrData *dat = (TFtMgrData*)GetWindowLongPtr(FtMgr_Show(bForceActivate, false), GWLP_USERDATA); - if (dat == NULL) - return NULL; + if (dat == nullptr) + return nullptr; HWND hwndBox = fdd->send ? dat->hwndOutgoing : dat->hwndIncoming; HWND hwndFt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILETRANSFERINFO), hwndBox, DlgProcFileTransfer, (LPARAM)fdd); diff --git a/src/core/stdfile/src/main.cpp b/src/core/stdfile/src/main.cpp index 82815089e7..6fd42be78e 100644 --- a/src/core/stdfile/src/main.cpp +++ b/src/core/stdfile/src/main.cpp @@ -62,7 +62,7 @@ extern "C" int __declspec(dllexport) Load(void) pcli = Clist_GetInterface(); if ( IsWinVer7Plus()) - CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&pTaskbarInterface); + CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_ALL, IID_ITaskbarList3, (void**)&pTaskbarInterface); LoadSendRecvFileModule(); return 0; diff --git a/src/core/stdhelp/src/about.cpp b/src/core/stdhelp/src/about.cpp index f638e7276f..3b74c287e7 100644 --- a/src/core/stdhelp/src/about.cpp +++ b/src/core/stdhelp/src/about.cpp @@ -38,7 +38,7 @@ INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar UINT blockSize; PVOID pVerInfo; - GetModuleFileName(NULL, filename, _countof(filename)); + GetModuleFileName(nullptr, filename, _countof(filename)); verInfoSize = GetFileVersionInfoSize(filename, &unused); pVerInfo = mir_alloc(verInfoSize); GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); diff --git a/src/core/stdhelp/src/help.cpp b/src/core/stdhelp/src/help.cpp index 42c679a2dc..2b9ce456e0 100644 --- a/src/core/stdhelp/src/help.cpp +++ b/src/core/stdhelp/src/help.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -HWND hAboutDlg = NULL; +HWND hAboutDlg = nullptr; static INT_PTR AboutCommand(WPARAM wParam, LPARAM) { @@ -60,7 +60,7 @@ static INT_PTR BugCommand(WPARAM, LPARAM) int ShutdownHelpModule(WPARAM, LPARAM) { if (IsWindow(hAboutDlg)) DestroyWindow(hAboutDlg); - hAboutDlg = NULL; + hAboutDlg = nullptr; return 0; } diff --git a/src/core/stdidle/src/idle.cpp b/src/core/stdidle/src/idle.cpp index 6176f7baa2..78661c1eb2 100644 --- a/src/core/stdidle/src/idle.cpp +++ b/src/core/stdidle/src/idle.cpp @@ -110,7 +110,7 @@ static BOOL bModuleInitialized = FALSE; BOOL IsTerminalDisconnected() { - PVOID pBuffer = NULL; + PVOID pBuffer = nullptr; DWORD pBytesReturned = 0; BOOL result = FALSE; @@ -166,7 +166,7 @@ static void IdleObject_ReadSettings(IdleObject * obj) static void IdleObject_Create(IdleObject * obj) { memset(obj, 0, sizeof(IdleObject)); - obj->hTimer = SetTimer(NULL, 0, 2000, IdleTimer); + obj->hTimer = SetTimer(nullptr, 0, 2000, IdleTimer); IdleObject_ReadSettings(obj); } @@ -175,7 +175,7 @@ static void IdleObject_Destroy(IdleObject * obj) if (IdleObject_IsIdle(obj)) NotifyEventHooks(hIdleEvent, 0, 0); IdleObject_ClearIdle(obj); - KillTimer(NULL, obj->hTimer); + KillTimer(nullptr, obj->hTimer); } static int IdleObject_IsUserIdle(IdleObject * obj) @@ -386,5 +386,5 @@ void UnloadIdleModule() IdleObject_Destroy(&gIdleObject); DestroyHookableEvent(hIdleEvent); - hIdleEvent = NULL; + hIdleEvent = nullptr; } diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp index e3d9e2dc9c..d907977a32 100644 --- a/src/core/stdmsg/src/chat_options.cpp +++ b/src/core/stdmsg/src/chat_options.cpp @@ -137,7 +137,7 @@ static void FillBranch(HWND hwndTree, HTREEITEM hParent, struct branch_t *branch { int iState; - if (hParent == 0) + if (hParent == nullptr) return; TVINSERTSTRUCT tvis; @@ -181,7 +181,7 @@ static void CheckHeading(HWND hwndTree, HTREEITEM hHeading) { BOOL bChecked = TRUE; - if (hHeading == 0) + if (hHeading == nullptr) return; TVITEM tvi; @@ -205,7 +205,7 @@ static void CheckBranches(HWND hwndTree, HTREEITEM hHeading) { BOOL bChecked = TRUE; - if (hHeading == 0) + if (hHeading == nullptr) return; TVITEM tvi; diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 3c130511ed..859fe50a79 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -1186,7 +1186,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) GetWindowRect((HWND)wParam, &rcNew); if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) { int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME); - SetWindowPos((HWND)wParam, 0, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); + SetWindowPos((HWND)wParam, nullptr, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); *(int *)lParam = 1; } } diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index a63430bf1c..10213d8018 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -96,7 +96,7 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char *sz dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF | (p->flags & PREF_RTL ? DBEF_RTL : 0); dbei.szModule = GetContactProto(hContact); - dbei.timestamp = time(0); + dbei.timestamp = time(nullptr); dbei.cbBlob = (DWORD)(mir_strlen(p->szMsg) + 1); dbei.pBlob = (PBYTE)p->szMsg; diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 77c69e8316..104b5fff31 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -103,7 +103,7 @@ void CSrmmWindow::OnInitDialog() CSuper::OnInitDialog(); m_bIsMeta = db_mc_isMeta(m_hContact) != 0; - m_hTimeZone = TimeZone_CreateByContact(m_hContact, 0, TZF_KNOWNONLY); + m_hTimeZone = TimeZone_CreateByContact(m_hContact, nullptr, TZF_KNOWNONLY); m_wMinute = 61; NotifyEvent(MSG_WINDOW_EVT_OPENING); @@ -239,9 +239,9 @@ void CSrmmWindow::OnInitDialog() if (Utils_RestoreWindowPosition(m_hwnd, g_dat.bSavePerContact ? m_hContact : 0, SRMMMOD, "", flag)) { if (g_dat.bSavePerContact) { if (Utils_RestoreWindowPosition(m_hwnd, 0, SRMMMOD, "", flag | RWPF_NOMOVE)) - SetWindowPos(m_hwnd, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); + SetWindowPos(m_hwnd, nullptr, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); } - else SetWindowPos(m_hwnd, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); + else SetWindowPos(m_hwnd, nullptr, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); } if (m_bNoActivate) { @@ -1051,7 +1051,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case DM_NEWTIMEZONE: - m_hTimeZone = TimeZone_CreateByContact(m_hContact, 0, TZF_KNOWNONLY); + m_hTimeZone = TimeZone_CreateByContact(m_hContact, nullptr, TZF_KNOWNONLY); m_wMinute = 61; Resize(); break; @@ -1063,7 +1063,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) GetWindowRect((HWND)wParam, &rcNew); if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) { int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME); - SetWindowPos((HWND)wParam, 0, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); + SetWindowPos((HWND)wParam, nullptr, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); *(int *)lParam = 1; } } @@ -1295,7 +1295,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) ADDCONTACTSTRUCT acs = {}; acs.hContact = m_hContact; acs.handleType = HANDLE_CONTACT; - acs.szProto = 0; + acs.szProto = nullptr; CallService(MS_ADDCONTACT_SHOW, (WPARAM)m_hwnd, (LPARAM)&acs); } if (!db_get_b(m_hContact, "CList", "NotOnList", 0)) diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 32f51cd7c7..ae36b73a40 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -490,7 +490,7 @@ static wchar_t tszError[] = LPGENW("Miranda could not load the built-in message int LoadSendRecvMessageModule(void) { if ((hMsftEdit = LoadLibrary(L"Msftedit.dll")) == nullptr) { - if (IDYES != MessageBox(0, TranslateW(tszError), TranslateT("Information"), MB_YESNO | MB_ICONINFORMATION)) + if (IDYES != MessageBox(nullptr, TranslateW(tszError), TranslateT("Information"), MB_YESNO | MB_ICONINFORMATION)) return 1; return 0; } diff --git a/src/core/stdmsg/src/msgtimedout.cpp b/src/core/stdmsg/src/msgtimedout.cpp index e0ce1ad97c..40a871e80b 100644 --- a/src/core/stdmsg/src/msgtimedout.cpp +++ b/src/core/stdmsg/src/msgtimedout.cpp @@ -53,7 +53,7 @@ INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar RECT rc, rcParent; if (GetWindowRect(hwndDlg, &rc)) if (GetWindowRect(hwndParent, &rcParent)) - SetWindowPos(hwndDlg, 0, (rcParent.left + rcParent.right - (rc.right - rc.left)) / 2, + SetWindowPos(hwndDlg, nullptr, (rcParent.left + rcParent.right - (rc.right - rc.left)) / 2, (rcParent.top + rcParent.bottom - (rc.bottom - rc.top)) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE); } diff --git a/src/core/stdmsg/src/statusicon.cpp b/src/core/stdmsg/src/statusicon.cpp index f467720907..ccd69b46ce 100644 --- a/src/core/stdmsg/src/statusicon.cpp +++ b/src/core/stdmsg/src/statusicon.cpp @@ -44,7 +44,7 @@ void DrawStatusIcons(MCONTACT hContact, HDC hDC, const RECT &rc, int gap) int nIcon = 0; StatusIconData *sid; - while ((sid = Srmm_GetNthIcon(hContact, nIcon++)) != 0 && x < rc.right) { + while ((sid = Srmm_GetNthIcon(hContact, nIcon++)) != nullptr && x < rc.right) { HICON hIcon = ((sid->flags & MBF_DISABLED) && sid->hIconDisabled) ? sid->hIconDisabled : sid->hIcon; SetBkMode(hDC, TRANSPARENT); diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 56b226614e..87b1e94670 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -282,9 +282,9 @@ void CTabbedWindow::SetWindowPosition() if (Utils_RestoreWindowPosition(m_hwnd, g_dat.bSavePerContact ? m_pEmbed->m_hContact : 0, CHAT_MODULE, "room")) { if (g_dat.bSavePerContact) { if (Utils_RestoreWindowPosition(m_hwnd, 0, CHAT_MODULE, "room", RWPF_NOMOVE)) - SetWindowPos(m_hwnd, 0, 0, 0, 550, 400, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); + SetWindowPos(m_hwnd, nullptr, 0, 0, 550, 400, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); } - else SetWindowPos(m_hwnd, 0, 0, 0, 550, 400, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); + else SetWindowPos(m_hwnd, nullptr, 0, 0, 550, 400, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); } if (!g_dat.bSavePerContact && g_dat.bCascade) @@ -622,7 +622,7 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; case ID_LOCKPOSITION: - if (si != 0) { + if (si != nullptr) { if (!(GetMenuState(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND)&MF_CHECKED)) { if (si->hContact) db_set_w(si->hContact, si->pszModule, "TabPosition", (WORD)(i + 1)); diff --git a/src/core/stdssl/src/netlibssl.cpp b/src/core/stdssl/src/netlibssl.cpp index 2b4dd3ccb4..9bd1316c06 100644 --- a/src/core/stdssl/src/netlibssl.cpp +++ b/src/core/stdssl/src/netlibssl.cpp @@ -76,14 +76,14 @@ static void ReportSslError(SECURITY_STATUS scRet, int line, bool = false) break; default: - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, scRet, LANG_USER_DEFAULT, szMsgBuf, _countof(szMsgBuf), NULL); + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, scRet, LANG_USER_DEFAULT, szMsgBuf, _countof(szMsgBuf), nullptr); } wchar_t szMsgBuf2[512]; mir_snwprintf(szMsgBuf2, L"SSL connection failure (%x %u): %s", scRet, line, szMsgBuf); char* szMsg = Utf8EncodeW(szMsgBuf2); - Netlib_Logf(NULL, szMsg); + Netlib_Logf(nullptr, szMsg); mir_free(szMsg); SetLastError(scRet); @@ -104,13 +104,13 @@ static bool AcquireCredentials(void) // Create an SSPI credential. scRet = g_pSSPI->AcquireCredentialsHandle( - NULL, // Name of principal + nullptr, // Name of principal UNISP_NAME, // Name of package SECPKG_CRED_OUTBOUND, // Flags indicating use - NULL, // Pointer to logon ID + nullptr, // Pointer to logon ID &SchannelCred, // Package specific data - NULL, // Pointer to GetKey() func - NULL, // Value to pass to GetKey() + nullptr, // Pointer to GetKey() func + nullptr, // Value to pass to GetKey() &hCreds, // (out) Cred Handle &tsExpiry); // (out) Lifetime (optional) @@ -140,7 +140,7 @@ static bool SSL_library_init(void) void NetlibSslFree(SslHandle *ssl) { - if (ssl == NULL) return; + if (ssl == nullptr) return; g_pSSPI->DeleteSecurityContext(&ssl->hContext); @@ -152,7 +152,7 @@ void NetlibSslFree(SslHandle *ssl) BOOL NetlibSslPending(SslHandle *ssl) { - return ssl != NULL && (ssl->cbRecDataBuf != 0 || ssl->cbIoBuffer != 0); + return ssl != nullptr && (ssl->cbRecDataBuf != 0 || ssl->cbIoBuffer != 0); } static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertFlags) @@ -168,8 +168,8 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF HTTPSPolicyCallbackData polHttps = { 0 }; CERT_CHAIN_POLICY_PARA PolicyPara = { 0 }; CERT_CHAIN_POLICY_STATUS PolicyStatus = { 0 }; - PCCERT_CHAIN_CONTEXT pChainContext = NULL; - PCCERT_CONTEXT pServerCert = NULL; + PCCERT_CHAIN_CONTEXT pChainContext = nullptr; + PCCERT_CONTEXT pServerCert = nullptr; DWORD scRet; PWSTR pwszServerName = mir_a2u(pszServerName); @@ -178,7 +178,7 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF if (scRet != SEC_E_OK) goto cleanup; - if (pServerCert == NULL) { + if (pServerCert == nullptr) { scRet = SEC_E_WRONG_PRINCIPAL; goto cleanup; } @@ -188,7 +188,7 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF ChainPara.RequestedUsage.Usage.cUsageIdentifier = _countof(rgszUsages); ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = rgszUsages; - if (!CertGetCertificateChain(NULL, pServerCert, NULL, pServerCert->hCertStore, &ChainPara, 0, NULL, &pChainContext)) { + if (!CertGetCertificateChain(nullptr, pServerCert, nullptr, pServerCert->hCertStore, &ChainPara, 0, nullptr, &pChainContext)) { scRet = GetLastError(); goto cleanup; } @@ -258,20 +258,20 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead) FD_ZERO(&fd); FD_SET(ssl->s, &fd); - if (select(1, &fd, NULL, NULL, &tv) != 1) { - Netlib_Logf(NULL, "SSL Negotiation failure recieving data (timeout) (bytes %u)", ssl->cbIoBuffer); + if (select(1, &fd, nullptr, nullptr, &tv) != 1) { + Netlib_Logf(nullptr, "SSL Negotiation failure recieving data (timeout) (bytes %u)", ssl->cbIoBuffer); scRet = ERROR_NOT_READY; break; } DWORD cbData = recv(ssl->s, (char*)ssl->pbIoBuffer + ssl->cbIoBuffer, ssl->sbIoBuffer - ssl->cbIoBuffer, 0); if (cbData == SOCKET_ERROR) { - Netlib_Logf(NULL, "SSL Negotiation failure recieving data (%d)", WSAGetLastError()); + Netlib_Logf(nullptr, "SSL Negotiation failure recieving data (%d)", WSAGetLastError()); scRet = ERROR_NOT_READY; break; } if (cbData == 0) { - Netlib_Logf(NULL, "SSL Negotiation connection gracefully closed"); + Netlib_Logf(nullptr, "SSL Negotiation connection gracefully closed"); scRet = ERROR_NOT_READY; break; } @@ -291,7 +291,7 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead) InBuffers[0].cbBuffer = ssl->cbIoBuffer; InBuffers[0].BufferType = SECBUFFER_TOKEN; - InBuffers[1].pvBuffer = NULL; + InBuffers[1].pvBuffer = nullptr; InBuffers[1].cbBuffer = 0; InBuffers[1].BufferType = SECBUFFER_EMPTY; @@ -305,7 +305,7 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead) // garbage later. SecBuffer OutBuffers[1]; - OutBuffers[0].pvBuffer = NULL; + OutBuffers[0].pvBuffer = nullptr; OutBuffers[0].BufferType = SECBUFFER_TOKEN; OutBuffers[0].cbBuffer = 0; @@ -316,23 +316,23 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead) TimeStamp tsExpiry; DWORD dwSSPIOutFlags; - scRet = g_pSSPI->InitializeSecurityContext(&hCreds, &ssl->hContext, NULL, dwSSPIFlags, 0, 0, - &InBuffer, 0, NULL, &OutBuffer, &dwSSPIOutFlags, &tsExpiry); + scRet = g_pSSPI->InitializeSecurityContext(&hCreds, &ssl->hContext, nullptr, dwSSPIFlags, 0, 0, + &InBuffer, 0, nullptr, &OutBuffer, &dwSSPIOutFlags, &tsExpiry); // If success (or if the error was one of the special extended ones), // send the contents of the output buffer to the server. if (scRet == SEC_E_OK || scRet == SEC_I_CONTINUE_NEEDED || (FAILED(scRet) && (dwSSPIOutFlags & ISC_RET_EXTENDED_ERROR))) { - if (OutBuffers[0].cbBuffer != 0 && OutBuffers[0].pvBuffer != NULL) { + if (OutBuffers[0].cbBuffer != 0 && OutBuffers[0].pvBuffer != nullptr) { DWORD cbData = send(ssl->s, (char*)OutBuffers[0].pvBuffer, OutBuffers[0].cbBuffer, 0); if (cbData == SOCKET_ERROR || cbData == 0) { - Netlib_Logf(NULL, "SSL Negotiation failure sending data (%d)", WSAGetLastError()); + Netlib_Logf(nullptr, "SSL Negotiation failure sending data (%d)", WSAGetLastError()); g_pSSPI->FreeContextBuffer(OutBuffers[0].pvBuffer); return SEC_E_INTERNAL_ERROR; } // Free output buffer. g_pSSPI->FreeContextBuffer(OutBuffers[0].pvBuffer); - OutBuffers[0].pvBuffer = NULL; + OutBuffers[0].pvBuffer = nullptr; } } @@ -378,7 +378,7 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead) if (ssl->cbIoBuffer == 0) { mir_free(ssl->pbIoBuffer); - ssl->pbIoBuffer = NULL; + ssl->pbIoBuffer = nullptr; ssl->sbIoBuffer = 0; } @@ -403,7 +403,7 @@ static bool ClientConnect(SslHandle *ssl, const char *host) // Initiate a ClientHello message and generate a token. SecBuffer OutBuffers[1]; - OutBuffers[0].pvBuffer = NULL; + OutBuffers[0].pvBuffer = nullptr; OutBuffers[0].BufferType = SECBUFFER_TOKEN; OutBuffers[0].cbBuffer = 0; @@ -414,7 +414,7 @@ static bool ClientConnect(SslHandle *ssl, const char *host) TimeStamp tsExpiry; DWORD dwSSPIOutFlags; - SECURITY_STATUS scRet = g_pSSPI->InitializeSecurityContext(&hCreds, NULL, _A2T(host), dwSSPIFlags, 0, 0, NULL, 0, + SECURITY_STATUS scRet = g_pSSPI->InitializeSecurityContext(&hCreds, nullptr, _A2T(host), dwSSPIFlags, 0, 0, nullptr, 0, &ssl->hContext, &OutBuffer, &dwSSPIOutFlags, &tsExpiry); if (scRet != SEC_I_CONTINUE_NEEDED) { ReportSslError(scRet, __LINE__); @@ -422,17 +422,17 @@ static bool ClientConnect(SslHandle *ssl, const char *host) } // Send response to server if there is one. - if (OutBuffers[0].cbBuffer != 0 && OutBuffers[0].pvBuffer != NULL) { + if (OutBuffers[0].cbBuffer != 0 && OutBuffers[0].pvBuffer != nullptr) { DWORD cbData = send(ssl->s, (char*)OutBuffers[0].pvBuffer, OutBuffers[0].cbBuffer, 0); if (cbData == SOCKET_ERROR || cbData == 0) { - Netlib_Logf(NULL, "SSL failure sending connection data (%d %d)", ssl->s, WSAGetLastError()); + Netlib_Logf(nullptr, "SSL failure sending connection data (%d %d)", ssl->s, WSAGetLastError()); g_pSSPI->FreeContextBuffer(OutBuffers[0].pvBuffer); return 0; } // Free output buffer. g_pSSPI->FreeContextBuffer(OutBuffers[0].pvBuffer); - OutBuffers[0].pvBuffer = NULL; + OutBuffers[0].pvBuffer = nullptr; } return ClientHandshakeLoop(ssl, TRUE) == SEC_E_OK; @@ -457,14 +457,14 @@ SslHandle* NetlibSslConnect(SOCKET s, const char* host, int verify) if (!res) { NetlibSslFree(ssl); - ssl = NULL; + ssl = nullptr; } return ssl; } void NetlibSslShutdown(SslHandle *ssl) { - if (ssl == NULL || !SecIsValidHandle(&ssl->hContext)) + if (ssl == nullptr || !SecIsValidHandle(&ssl->hContext)) return; DWORD dwType = SCHANNEL_SHUTDOWN; @@ -492,7 +492,7 @@ void NetlibSslShutdown(SslHandle *ssl) ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_STREAM; - OutBuffers[0].pvBuffer = NULL; + OutBuffers[0].pvBuffer = nullptr; OutBuffers[0].BufferType = SECBUFFER_TOKEN; OutBuffers[0].cbBuffer = 0; @@ -502,13 +502,13 @@ void NetlibSslShutdown(SslHandle *ssl) TimeStamp tsExpiry; DWORD dwSSPIOutFlags; - scRet = g_pSSPI->InitializeSecurityContext(&hCreds, &ssl->hContext, NULL, dwSSPIFlags, 0, 0, NULL, 0, + scRet = g_pSSPI->InitializeSecurityContext(&hCreds, &ssl->hContext, nullptr, dwSSPIFlags, 0, 0, nullptr, 0, &ssl->hContext, &OutBuffer, &dwSSPIOutFlags, &tsExpiry); if (FAILED(scRet)) return; // Send the close notify message to the server. - if (OutBuffers[0].pvBuffer != NULL && OutBuffers[0].cbBuffer != 0) { + if (OutBuffers[0].pvBuffer != nullptr && OutBuffers[0].cbBuffer != 0) { send(ssl->s, (char*)OutBuffers[0].pvBuffer, OutBuffers[0].cbBuffer, 0); g_pSSPI->FreeContextBuffer(OutBuffers[0].pvBuffer); } @@ -533,7 +533,7 @@ static int NetlibSslReadSetResult(SslHandle *ssl, char *buf, int num, int peek) int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) { - if (ssl == NULL) return SOCKET_ERROR; + if (ssl == nullptr) return SOCKET_ERROR; if (num <= 0) return 0; @@ -555,7 +555,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) FD_ZERO(&fd); FD_SET(ssl->s, &fd); - DWORD cbData = select(1, &fd, NULL, NULL, &tv); + DWORD cbData = select(1, &fd, nullptr, nullptr, &tv); if (cbData == SOCKET_ERROR) { ssl->state = sockError; return NetlibSslReadSetResult(ssl, buf, num, peek); @@ -567,13 +567,13 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) DWORD cbData = recv(ssl->s, (char*)ssl->pbIoBuffer + ssl->cbIoBuffer, ssl->sbIoBuffer - ssl->cbIoBuffer, 0); if (cbData == SOCKET_ERROR) { - Netlib_Logf(NULL, "SSL failure recieving data (%d)", WSAGetLastError()); + Netlib_Logf(nullptr, "SSL failure recieving data (%d)", WSAGetLastError()); ssl->state = sockError; return NetlibSslReadSetResult(ssl, buf, num, peek); } if (cbData == 0) { - Netlib_Logf(NULL, "SSL connection gracefully closed"); + Netlib_Logf(nullptr, "SSL connection gracefully closed"); if (peek && ssl->cbRecDataBuf) { ssl->state = sockClosed; return NetlibSslReadSetResult(ssl, buf, num, peek); @@ -605,10 +605,10 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) Message.cBuffers = _countof(Buffers); Message.pBuffers = Buffers; - if (g_pSSPI->DecryptMessage != NULL && g_pSSPI->DecryptMessage != PVOID(0x80000000)) - scRet = g_pSSPI->DecryptMessage(&ssl->hContext, &Message, 0, NULL); + if (g_pSSPI->DecryptMessage != nullptr && g_pSSPI->DecryptMessage != PVOID(0x80000000)) + scRet = g_pSSPI->DecryptMessage(&ssl->hContext, &Message, 0, nullptr); else - scRet = ((DECRYPT_MESSAGE_FN)g_pSSPI->Reserved4)(&ssl->hContext, &Message, 0, NULL); + scRet = ((DECRYPT_MESSAGE_FN)g_pSSPI->Reserved4)(&ssl->hContext, &Message, 0, nullptr); // The input buffer contains only a fragment of an // encrypted record. Loop around and read some more @@ -623,13 +623,13 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) } // Locate data and (optional) extra buffers. - SecBuffer *pDataBuffer = NULL; - SecBuffer *pExtraBuffer = NULL; + SecBuffer *pDataBuffer = nullptr; + SecBuffer *pExtraBuffer = nullptr; for (int i = 1; i < _countof(Buffers); i++) { - if (pDataBuffer == NULL && Buffers[i].BufferType == SECBUFFER_DATA) + if (pDataBuffer == nullptr && Buffers[i].BufferType == SECBUFFER_DATA) pDataBuffer = &Buffers[i]; - if (pExtraBuffer == NULL && Buffers[i].BufferType == SECBUFFER_EXTRA) + if (pExtraBuffer == nullptr && Buffers[i].BufferType == SECBUFFER_EXTRA) pExtraBuffer = &Buffers[i]; } @@ -670,7 +670,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) // Server signaled end of session if (scRet == SEC_I_CONTEXT_EXPIRED) { - Netlib_Logf(NULL, "SSL Server signaled SSL Shutdown"); + Netlib_Logf(nullptr, "SSL Server signaled SSL Shutdown"); ssl->state = sockClosed; return NetlibSslReadSetResult(ssl, buf, num, peek); } @@ -690,7 +690,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) int NetlibSslWrite(SslHandle *ssl, const char *buf, int num) { - if (ssl == NULL) return SOCKET_ERROR; + if (ssl == nullptr) return SOCKET_ERROR; SecPkgContext_StreamSizes Sizes; SECURITY_STATUS scRet = g_pSSPI->QueryContextAttributes(&ssl->hContext, SECPKG_ATTR_STREAM_SIZES, &Sizes); @@ -726,7 +726,7 @@ int NetlibSslWrite(SslHandle *ssl, const char *buf, int num) Message.cBuffers = _countof(Buffers); Message.pBuffers = Buffers; - if (g_pSSPI->EncryptMessage != NULL) + if (g_pSSPI->EncryptMessage != nullptr) scRet = g_pSSPI->EncryptMessage(&ssl->hContext, 0, &Message, 0); else scRet = ((ENCRYPT_MESSAGE_FN)g_pSSPI->Reserved3)(&ssl->hContext, 0, &Message, 0); @@ -739,7 +739,7 @@ int NetlibSslWrite(SslHandle *ssl, const char *buf, int num) // Send the encrypted data to the server. cbData = send(ssl->s, (char*)pbDataBuffer, cbData, 0); if (cbData == SOCKET_ERROR || cbData == 0) { - Netlib_Logf(NULL, "SSL failure sending data (%d)", WSAGetLastError()); + Netlib_Logf(nullptr, "SSL failure sending data (%d)", WSAGetLastError()); scRet = SEC_E_INTERNAL_ERROR; break; } @@ -754,7 +754,7 @@ int NetlibSslWrite(SslHandle *ssl, const char *buf, int num) static INT_PTR GetSslApi(WPARAM, LPARAM lParam) { SSL_API *si = (SSL_API*)lParam; - if (si == NULL) + if (si == nullptr) return FALSE; if (si->cbSize != sizeof(SSL_API)) @@ -772,7 +772,7 @@ static INT_PTR GetSslApi(WPARAM, LPARAM lParam) int LoadSslModule(void) { CreateServiceFunction(MS_SYSTEM_GET_SI, GetSslApi); - g_hSslMutex = CreateMutex(NULL, FALSE, NULL); + g_hSslMutex = CreateMutex(nullptr, FALSE, nullptr); SecInvalidateHandle(&hCreds); return 0; } diff --git a/src/core/stduihist/src/history.cpp b/src/core/stduihist/src/history.cpp index cdffaa1c57..60843731a0 100644 --- a/src/core/stduihist/src/history.cpp +++ b/src/core/stduihist/src/history.cpp @@ -31,8 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static MWindowList hWindowList = 0; -static HGENMENU hContactMenu = 0; +static MWindowList hWindowList = nullptr; +static HGENMENU hContactMenu = nullptr; ///////////////////////////////////////////////////////////////////////////////////////// // Fills the events list @@ -96,7 +96,7 @@ static void GetObjectDescription(DBEVENTINFO *dbei, wchar_t* str, int cbStr) static void GetObjectSummary(DBEVENTINFO *dbei, wchar_t* str, int cbStr) { - wchar_t* pszSrc, *pszTmp = NULL; + wchar_t* pszSrc, *pszTmp = nullptr; switch(dbei->eventType) { case EVENTTYPE_MESSAGE: @@ -320,7 +320,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetObjectDescription(&dbei, str, _countof(str)); if (str[0]) { CharUpperBuff(str, (int)mir_wstrlen(str)); - if (wcsstr(str, (const wchar_t*)lParam) != NULL) { + if (wcsstr(str, (const wchar_t*)lParam) != nullptr) { SendDlgItemMessage(hwndDlg, IDC_LIST, LB_SETCURSEL, index, 0); SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); break; @@ -378,7 +378,7 @@ static INT_PTR UserHistoryCommand(WPARAM wParam, LPARAM) static int HistoryContactDelete(WPARAM wParam, LPARAM) { HWND hwnd = WindowList_Find(hWindowList, wParam); - if (hwnd != NULL) + if (hwnd != nullptr) DestroyWindow(hwnd); return 0; } diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp index a8df0ebeb5..2d9caa7525 100644 --- a/src/core/stduserinfo/src/contactinfo.cpp +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -static HFONT hEmailFont = NULL; -static HCURSOR hHandCursor = NULL; +static HFONT hEmailFont = nullptr; +static HCURSOR hHandCursor = nullptr; static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -126,7 +126,7 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar if (noRecursion) break; noRecursion = 1; { - char szText[256], *pText = NULL, *pArea, *pNumber; + char szText[256], *pText = nullptr, *pArea, *pNumber; int i, isValid = 1; GetDlgItemTextA(hwndDlg, IDC_PHONE, szText, _countof(szText)); if (szText[0] != '+') @@ -224,8 +224,8 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP lf.lfUnderline = 1; hEmailFont = CreateFontIndirect(&lf); } - if (hHandCursor == NULL) - hHandCursor = LoadCursor(NULL, IDC_HAND); + if (hHandCursor == nullptr) + hHandCursor = LoadCursor(nullptr, IDC_HAND); { RECT rc; GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc); @@ -257,7 +257,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (hContact != NULL) { char *szProto = GetContactProto(hContact); - if (szProto == NULL) + if (szProto == nullptr) break; //e-mails @@ -516,7 +516,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP GetCursorPos(&pt); ScreenToClient(hwndDlg, &pt); } - if (IsOverEmail(hwndDlg, NULL, 0)) { + if (IsOverEmail(hwndDlg, nullptr, 0)) { SetCursor(hHandCursor); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); return TRUE; diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp index af0e8acc97..e158eae615 100644 --- a/src/core/stduserinfo/src/stdinfo.cpp +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -53,22 +53,22 @@ static wchar_t* Proto_GetContactInfoSettingStr(bool proto_service, MCONTACT hCon DBCONTACTGETSETTING cgs = { szModule, szSetting, &dbv }; dbv.type = DBVT_WCHAR; if (CallProtoService(szModule, PS_GETINFOSETTING, hContact, (LPARAM)&cgs)) - return NULL; + return nullptr; return dbv.ptszVal; } static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special) { - char str[80], *pstr = NULL; - wchar_t *ptstr = NULL; + char str[80], *pstr = nullptr; + wchar_t *ptstr = nullptr; char *szProto = GetContactProto(hContact); bool proto_service = szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC); DBVARIANT dbv = { DBVT_DELETED }; int unspecified; - if (szModule == NULL) + if (szModule == nullptr) unspecified = 1; else if (proto_service) unspecified = Proto_GetContactInfoSetting(hContact, szProto, szModule, szSetting, &dbv, 0); @@ -159,7 +159,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule } pstr = Translate((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, wSave, 0)); - unspecified = pstr == NULL; + unspecified = pstr == nullptr; } else { unspecified = (special == SVS_ZEROISUNSPEC && dbv.wVal == 0); @@ -194,7 +194,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule } pstr = dbv.pszVal; - Utf8Decode(dbv.pszVal, NULL); + Utf8Decode(dbv.pszVal, nullptr); break; default: @@ -206,7 +206,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule if (unspecified) SetDlgItemText(hwndDlg, idCtrl, TranslateT("")); - else if (ptstr != NULL) + else if (ptstr != nullptr) SetDlgItemText(hwndDlg, idCtrl, ptstr); else SetDlgItemTextA(hwndDlg, idCtrl, pstr); @@ -230,7 +230,7 @@ static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; if (hContact != NULL) { char *szProto = GetContactProto(hContact); - if (szProto == NULL) + if (szProto == nullptr) break; SetValue(hwndDlg, IDC_NICK, hContact, szProto, "Nick", 0); @@ -275,7 +275,7 @@ static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); TranslateDialogDefault(hwndDlg); - SetTimer(hwndDlg, 1, 1000, NULL); + SetTimer(hwndDlg, 1, 1000, nullptr); TimeZone_PrepareList(lParam, NULL, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); SendMessage(hwndDlg, WM_TIMER, 0, 0); @@ -305,7 +305,7 @@ static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; if (hContact != NULL) { char *szProto = GetContactProto(hContact); - if (szProto == NULL) + if (szProto == nullptr) break; SetValue(hwndDlg, IDC_STREET, hContact, szProto, "Street", SVS_ZEROISUNSPEC); @@ -355,7 +355,7 @@ static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; if (hContact != NULL) { char *szProto = GetContactProto(hContact); - if (szProto == NULL) break; + if (szProto == nullptr) break; SetValue(hwndDlg, IDC_COMPANY, hContact, szProto, "Company", SVS_ZEROISUNSPEC); SetValue(hwndDlg, IDC_DEPARTMENT, hContact, szProto, "CompanyDepartment", SVS_ZEROISUNSPEC); SetValue(hwndDlg, IDC_POSITION, hContact, szProto, "CompanyPosition", SVS_ZEROISUNSPEC); @@ -432,7 +432,7 @@ static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; if (hContact != NULL) { char *szProto = GetContactProto(hContact); - if (szProto == NULL) + if (szProto == nullptr) break; bool proto_service = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) == PF4_INFOSETTINGSVC; @@ -604,7 +604,7 @@ int DetailsInit(WPARAM wParam, LPARAM lParam) if (lParam == NULL) return 0; - if (GetContactProto(lParam) == 0) + if (GetContactProto(lParam) == nullptr) return 0; OPTIONSDIALOGPAGE odp = { 0 }; diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp index 916a89f4f8..ce59b8864d 100644 --- a/src/core/stduserinfo/src/userinfo.cpp +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int DetailsInit(WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static MWindowList hWindowList = NULL; +static MWindowList hWindowList = nullptr; static HANDLE hDetailsInitEvent; struct DetailsPageInit @@ -103,7 +103,7 @@ static INT_PTR ShowDetailsDialogCommand(WPARAM wParam, LPARAM) DetailsPageInit opi = { 0 }; opi.pageCount = 0; - opi.odp = NULL; + opi.odp = nullptr; NotifyEventHooks(hDetailsInitEvent, (WPARAM)&opi, wParam); if (opi.pageCount == 0) return 0; @@ -112,16 +112,16 @@ static INT_PTR ShowDetailsDialogCommand(WPARAM wParam, LPARAM) PROPSHEETHEADER psh = { sizeof(psh) }; psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; - psh.hwndParent = NULL; + psh.hwndParent = nullptr; psh.nPages = opi.pageCount; - psh.pStartPage = 0; + psh.pStartPage = nullptr; psh.pszCaption = (wchar_t*)wParam; //more abuses of structure: this is hContact psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DETAILS), NULL, DlgProcDetails, (LPARAM)&psh); for (int i = 0; i < opi.pageCount; i++) { //cleanup moved to WM_DESTROY - if (opi.odp[i].szGroup.w != NULL) + if (opi.odp[i].szGroup.w != nullptr) mir_free(opi.odp[i].szGroup.a); if ((DWORD_PTR)opi.odp[i].pszTemplate & 0xFFFF0000) mir_free((char*)opi.odp[i].pszTemplate); @@ -135,7 +135,7 @@ static INT_PTR AddDetailsPage(WPARAM wParam, LPARAM lParam) OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)lParam; struct DetailsPageInit *opi = (struct DetailsPageInit*)wParam; - if (odp == NULL || opi == NULL) + if (odp == nullptr || opi == nullptr) return 1; opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount + 1)); @@ -147,12 +147,12 @@ static INT_PTR AddDetailsPage(WPARAM wParam, LPARAM lParam) dst->pszTemplate = ((DWORD_PTR)odp->pszTemplate & 0xFFFF0000) ? mir_strdup(odp->pszTemplate) : odp->pszTemplate; if (odp->flags & ODPF_UNICODE) { - dst->szTitle.w = (odp->szTitle.w == 0) ? NULL : mir_wstrdup(odp->szTitle.w); - dst->szTab.w = (odp->flags & ODPF_USERINFOTAB) ? mir_wstrdup(odp->szTab.w) : NULL; + dst->szTitle.w = (odp->szTitle.w == nullptr) ? nullptr : mir_wstrdup(odp->szTitle.w); + dst->szTab.w = (odp->flags & ODPF_USERINFOTAB) ? mir_wstrdup(odp->szTab.w) : nullptr; } else { dst->szTitle.w = mir_a2u(odp->szTitle.a); - dst->szTab.w = (odp->flags & ODPF_USERINFOTAB) ? mir_a2u(odp->szTab.a) : NULL; + dst->szTab.w = (odp->flags & ODPF_USERINFOTAB) ? mir_a2u(odp->szTab.a) : nullptr; } dst->hLangpack = odp->hLangpack; @@ -218,7 +218,7 @@ static void CreateDetailsPageWindow(HWND hwndDlg, DetailsData *dat, DetailsPageD static int UserInfoContactDelete(WPARAM wParam, LPARAM) { HWND hwnd = WindowList_Find(hWindowList, wParam); - if (hwnd != NULL) + if (hwnd != nullptr) DestroyWindow(hwnd); return 0; } @@ -269,7 +269,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP ptszLastTab = NEWWSTR_ALLOCA(dbv.ptszVal); db_free(&dbv); } - else ptszLastTab = NULL; + else ptszLastTab = nullptr; dat->currentPage = 0; dat->pageCount = psh->nPages; @@ -296,7 +296,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP } TVINSERTSTRUCT tvis; - tvis.hParent = NULL; + tvis.hParent = nullptr; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_TEXT | TVIF_PARAM; tvis.item.lParam = (LPARAM)i; @@ -342,7 +342,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); if (!ProtoChainSend(dat->hContact, PSS_GETINFO, SGIF_ONOPEN, 0)) { EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); - SetTimer(hwndDlg, 1, 100, NULL); + SetTimer(hwndDlg, 1, 100, nullptr); } else ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); @@ -394,7 +394,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP for (i = 0; i < dat->pageCount; i++) { DetailsPageData &odp = dat->opd[i]; pshn.hdr.hwndFrom = odp.hwnd; - if (odp.hwnd != NULL) + if (odp.hwnd != nullptr) SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); } break; @@ -402,7 +402,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP case M_CHECKONLINE: if (dat->hContact != NULL) { char *szProto = GetContactProto(dat->hContact); - if (szProto == NULL) + if (szProto == nullptr) EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); else { if (CallProtoService(szProto, PS_GETSTATUS, 0, 0) < ID_STATUS_ONLINE) @@ -431,7 +431,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); break; } //if - if (dat->infosUpdated == NULL) + if (dat->infosUpdated == nullptr) dat->infosUpdated = (int*)mir_calloc(sizeof(int)*(INT_PTR)ack->hProcess); if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED) dat->infosUpdated[ack->lParam] = 1; @@ -521,7 +521,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP for (i = 0; i < dat->pageCount; i++) { DetailsPageData &odp = dat->opd[i]; - if (odp.hwnd == NULL || !odp.changed) + if (odp.hwnd == nullptr || !odp.changed) continue; pshn.hdr.hwndFrom = odp.hwnd; SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); @@ -542,7 +542,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP pshn.hdr.code = PSN_APPLY; for (i = 0; i < dat->pageCount; i++) { DetailsPageData &odp = dat->opd[i]; - if (odp.hwnd == NULL || !odp.changed) + if (odp.hwnd == nullptr || !odp.changed) continue; pshn.hdr.hwndFrom = odp.hwnd; if (SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn) == PSNRET_INVALID_NOCHANGEPAGE) { @@ -565,7 +565,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (!ProtoChainSend(dat->hContact, PSS_GETINFO, 0, 0)) { EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_SHOW); - SetTimer(hwndDlg, 1, 100, NULL); + SetTimer(hwndDlg, 1, 100, nullptr); } } break; @@ -594,7 +594,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP for (i = 0; i < dat->pageCount; i++) { DetailsPageData &odp = dat->opd[i]; - if (odp.hwnd != NULL) + if (odp.hwnd != nullptr) DestroyWindow(odp.hwnd); mir_free(odp.ptszTitle); mir_free(odp.ptszTab); diff --git a/src/core/stduseronline/src/useronline.cpp b/src/core/stduseronline/src/useronline.cpp index b7ff2473b0..38fc00426c 100644 --- a/src/core/stduseronline/src/useronline.cpp +++ b/src/core/stduseronline/src/useronline.cpp @@ -75,7 +75,7 @@ static int UserOnlineSettingChanged(WPARAM hContact, LPARAM lParam) static int UserOnlineAck(WPARAM, LPARAM lParam) { ACKDATA * ack = (ACKDATA*) lParam; - if (ack != 0 && ack->szModule && ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS && ack->hProcess == (HANDLE)ID_STATUS_OFFLINE) { + if (ack != nullptr && ack->szModule && ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS && ack->hProcess == (HANDLE)ID_STATUS_OFFLINE) { // if going from offline to any other mode, remember when it happened. db_set_dw(NULL, "UserOnline", ack->szModule, GetTickCount()); } -- cgit v1.2.3