From 4c814798c7bc7f6a0f92c21b027b26290622aa2f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jun 2015 19:35:42 +0000 Subject: SIZEOF replaced with more secure analog - _countof git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/UserInfoEx/src/Flags/svc_flags.cpp | 2 +- plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp | 12 +++--- plugins/UserInfoEx/src/classMAnnivDate.cpp | 22 +++++------ plugins/UserInfoEx/src/classPsTreeItem.cpp | 8 ++-- plugins/UserInfoEx/src/ctrl_annivedit.cpp | 6 +-- plugins/UserInfoEx/src/ctrl_button.cpp | 6 +-- plugins/UserInfoEx/src/ctrl_contact.cpp | 46 +++++++++++----------- plugins/UserInfoEx/src/ctrl_edit.cpp | 6 +-- plugins/UserInfoEx/src/dlg_anniversarylist.cpp | 14 +++---- plugins/UserInfoEx/src/dlg_msgbox.cpp | 10 ++--- plugins/UserInfoEx/src/dlg_propsheet.cpp | 28 ++++++------- .../src/ex_import/classExImContactXML.cpp | 4 +- .../UserInfoEx/src/ex_import/dlg_ExImModules.cpp | 12 +++--- .../src/ex_import/dlg_ExImOpenSaveFile.cpp | 8 ++-- .../UserInfoEx/src/ex_import/dlg_ExImProgress.cpp | 8 ++-- plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp | 2 +- plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp | 6 +-- plugins/UserInfoEx/src/mir_db.cpp | 2 +- plugins/UserInfoEx/src/mir_icolib.cpp | 4 +- plugins/UserInfoEx/src/mir_menuitems.cpp | 8 ++-- plugins/UserInfoEx/src/psp_anniversary.cpp | 2 +- plugins/UserInfoEx/src/psp_contact.cpp | 4 +- plugins/UserInfoEx/src/psp_general.cpp | 2 +- plugins/UserInfoEx/src/psp_options.cpp | 24 +++++------ plugins/UserInfoEx/src/psp_origin.cpp | 8 ++-- plugins/UserInfoEx/src/psp_profile.cpp | 22 +++++------ plugins/UserInfoEx/src/svc_avatar.cpp | 4 +- plugins/UserInfoEx/src/svc_constants.cpp | 28 ++++++------- plugins/UserInfoEx/src/svc_contactinfo.cpp | 4 +- plugins/UserInfoEx/src/svc_refreshci.cpp | 6 +-- plugins/UserInfoEx/src/svc_reminder.cpp | 32 +++++++-------- plugins/UserInfoEx/src/svc_timezone_old.cpp | 2 +- 32 files changed, 176 insertions(+), 176 deletions(-) (limited to 'plugins/UserInfoEx/src') diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index 31251d0c20..e8cd5ab68b 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -220,7 +220,7 @@ void SvcFlagsLoadModule() langid = 1; char szId[20]; - mir_snprintf(szId, SIZEOF(szId), (langid == 0xFFFF) ? "%s_0x%X" : "%s_%i", "flags", langid); /* buffer safe */ + mir_snprintf(szId, _countof(szId), (langid == 0xFFFF) ? "%s_0x%X" : "%s_%i", "flags", langid); /* buffer safe */ hExtraIconSvc = ExtraIcon_Register("Flags", LPGEN("Flags (uinfoex)"), szId); } diff --git a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp index efb5c18697..9710ee4f73 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp @@ -102,13 +102,13 @@ static int CountryNumberToBitmapIndex(int countryNumber) /* binary search in index array */ if (countryNumber > 0) { int i,high/*,low=0*/; - high=SIZEOF(BitmapIndexMap); + high=_countof(BitmapIndexMap); /*old code need sortet BitmapIndexMap*/ /*if (countryNumber<=BitmapIndexMap[high]) while(low<=high) { i=low+((high-low)/2); // never happens - if (i<0 || i>=SIZEOF(BitmapIndexMap)) DebugBreak(); + if (i<0 || i>=_countof(BitmapIndexMap)) DebugBreak(); if (BitmapIndexMap[i]==countryNumber) return i; if (countryNumber>BitmapIndexMap[i]) low=i+1; else high=i-1; @@ -133,7 +133,7 @@ HICON LoadFlag(int countryNumber) szCountry = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber=0xFFFF,0); char szId[20]; - mir_snprintf(szId, SIZEOF(szId), (countryNumber == 0xFFFF) ? "%s_0x%X" : "%s_%i", "flags", countryNumber); /* buffer safe */ + mir_snprintf(szId, _countof(szId), (countryNumber == 0xFFFF) ? "%s_0x%X" : "%s_%i", "flags", countryNumber); /* buffer safe */ return IcoLib_GetIcon(szId); } @@ -255,7 +255,7 @@ static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) memset(&aptTriangle, 0, sizeof(aptTriangle)); aptTriangle[1].y=bm.bmHeight-1; aptTriangle[2].x=bm.bmWidth-1; - HRGN hrgn=CreatePolygonRgn(aptTriangle,SIZEOF(aptTriangle),WINDING); + HRGN hrgn=CreatePolygonRgn(aptTriangle,_countof(aptTriangle),WINDING); if (hrgn!=NULL) { SelectClipRgn(hdc,hrgn); HBITMAP hbmPrev=(HBITMAP)SelectObject(hdc,icoi.hbmColor); @@ -397,7 +397,7 @@ void InitIcons() for (int i=0; i < nCountriesCount; i++) { sid.description.t = mir_a2t(LPGEN(countries[i].szName)); /* create identifier */ - mir_snprintf(szId, SIZEOF(szId), (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countries[i].id); /* buffer safe */ + mir_snprintf(szId, _countof(szId), (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countries[i].id); /* buffer safe */ int index = CountryNumberToBitmapIndex(countries[i].id); /* create icon */ sid.hDefaultIcon = ImageList_ExtractIcon(NULL, himl, index); @@ -421,7 +421,7 @@ void UninitIcons() for(int i=0;iDateFormat(szoldDate, SIZEOF(szoldDate)); - pNewProtoDate->DateFormat(szDate, SIZEOF(szDate)); + pOldCustomDate->DateFormat(szoldDate, _countof(szoldDate)); + pNewProtoDate->DateFormat(szDate, _countof(szDate)); - mir_sntprintf(szMsg, SIZEOF(szMsg), + mir_sntprintf(szMsg, _countof(szMsg), TranslateT("%s provides a new birthday via protocol.\nIt is %s. The old one was %s.\n\nDo you want to use this as the new birthday for this contact?"), DB::Contact::DisplayName(hContact), szDate, szoldDate); diff --git a/plugins/UserInfoEx/src/classPsTreeItem.cpp b/plugins/UserInfoEx/src/classPsTreeItem.cpp index f5d6d28d63..7a11d5ca3f 100644 --- a/plugins/UserInfoEx/src/classPsTreeItem.cpp +++ b/plugins/UserInfoEx/src/classPsTreeItem.cpp @@ -88,7 +88,7 @@ CPsTreeItem::~CPsTreeItem() LPCSTR CPsTreeItem::PropertyKey(LPCSTR pszProperty) { static CHAR pszSetting[MAXSETTING]; - mir_snprintf(pszSetting, SIZEOF(pszSetting), "{%s\\%s}_%s", _pszPrefix, _pszName, pszProperty); + mir_snprintf(pszSetting, _countof(pszSetting), "{%s\\%s}_%s", _pszPrefix, _pszName, pszProperty); return pszSetting; } @@ -121,7 +121,7 @@ LPCSTR CPsTreeItem::GlobalName() LPCSTR CPsTreeItem::GlobalPropertyKey(LPCSTR pszProperty) { static CHAR pszSetting[MAXSETTING]; - mir_snprintf(pszSetting, SIZEOF(pszSetting), "{Global\\%s}_%s", GlobalName(), pszProperty); + mir_snprintf(pszSetting, _countof(pszSetting), "{Global\\%s}_%s", GlobalName(), pszProperty); return pszSetting; } @@ -138,7 +138,7 @@ LPCSTR CPsTreeItem::IconKey() if (pszIconName) { static CHAR pszSetting[MAXSETTING]; - mir_snprintf(pszSetting, SIZEOF(pszSetting), MODNAME"_{%s}", pszIconName); + mir_snprintf(pszSetting, _countof(pszSetting), MODNAME"_{%s}", pszIconName); return pszSetting; } return NULL; @@ -283,7 +283,7 @@ HICON CPsTreeItem::ProtoIcon() for (int i = 0; i < ProtoCount; i++) { if (!mir_tcsnicmp(pa[i]->tszAccountName, _A2T(_pszName), mir_tstrlen(pa[i]->tszAccountName))) { CHAR szIconID[MAX_PATH]; - mir_snprintf(szIconID, SIZEOF(szIconID), "core_status_%s1", pa[i]->szModuleName); + mir_snprintf(szIconID, _countof(szIconID), "core_status_%s1", pa[i]->szModuleName); HICON hIco = IcoLib_GetIcon(szIconID); if (!hIco) hIco = (HICON)CallProtoService(pa[i]->szModuleName, PS_LOADICON, PLI_PROTOCOL, NULL); diff --git a/plugins/UserInfoEx/src/ctrl_annivedit.cpp b/plugins/UserInfoEx/src/ctrl_annivedit.cpp index 162f8f83e9..cf8a7ef0d7 100644 --- a/plugins/UserInfoEx/src/ctrl_annivedit.cpp +++ b/plugins/UserInfoEx/src/ctrl_annivedit.cpp @@ -364,10 +364,10 @@ INT_PTR CAnnivEditCtrl::DBWriteAnniversaries(MCONTACT hContact) } // delete reluctant items do { - ofs = mir_snprintf(szSet0, SIZEOF(szSet0), "Anniv%d", wIndex); + ofs = mir_snprintf(szSet0, _countof(szSet0), "Anniv%d", wIndex); ret = 1; - for (i = 0; i < SIZEOF(szPrefix); i++) { - mir_strncpy(szSet0 + ofs, szPrefix[i], SIZEOF(szSet0) - ofs); + for (i = 0; i < _countof(szPrefix); i++) { + mir_strncpy(szSet0 + ofs, szPrefix[i], _countof(szSet0) - ofs); ret &= db_unset(hContact, USERINFO, szSet0); } } diff --git a/plugins/UserInfoEx/src/ctrl_button.cpp b/plugins/UserInfoEx/src/ctrl_button.cpp index 50ff993163..5f7241341c 100644 --- a/plugins/UserInfoEx/src/ctrl_button.cpp +++ b/plugins/UserInfoEx/src/ctrl_button.cpp @@ -192,7 +192,7 @@ static void __fastcall PaintThemeButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClien RECT sizeText; HFONT hOldFont; - ccText = GetWindowTextW(ctl->hwnd, wszText, SIZEOF(wszText)); + ccText = GetWindowTextW(ctl->hwnd, wszText, _countof(wszText)); if (ccText > 0) { hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); @@ -301,7 +301,7 @@ static void __fastcall PaintButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClient) SIZE sizeText; HFONT hOldFont; - ccText = GetWindowText(ctl->hwnd, szText, SIZEOF(szText)); + ccText = GetWindowText(ctl->hwnd, szText, _countof(szText)); if (ccText > 0) { hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont); @@ -543,7 +543,7 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L case BUTTONTRANSLATE: { TCHAR szButton[MAX_PATH]; - GetWindowText(bct->hwnd, szButton, SIZEOF(szButton)); + GetWindowText(bct->hwnd, szButton, _countof(szButton)); SetWindowText(bct->hwnd, TranslateTS(szButton)); } break; diff --git a/plugins/UserInfoEx/src/ctrl_contact.cpp b/plugins/UserInfoEx/src/ctrl_contact.cpp index bf4e43afd5..7576bf10e6 100644 --- a/plugins/UserInfoEx/src/ctrl_contact.cpp +++ b/plugins/UserInfoEx/src/ctrl_contact.cpp @@ -171,11 +171,11 @@ static INT_PTR CALLBACK DlgProc_EMail(HWND hDlg, UINT msg, WPARAM wParam, LPARAM { TCHAR szButton[MAX_PATH]; HWND hBtn = GetDlgItem(hDlg, IDOK); - GetWindowText(hBtn, szButton, SIZEOF(szButton)); + GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); hBtn = GetDlgItem(hDlg, IDCANCEL); - GetWindowText(hBtn, szButton, SIZEOF(szButton)); + GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); } return TRUE; @@ -205,7 +205,7 @@ static INT_PTR CALLBACK DlgProc_EMail(HWND hDlg, UINT msg, WPARAM wParam, LPARAM TCHAR szText[MAXDATASIZE]; LPTSTR pszAdd, pszDot; if (PtrIsValid(cbi)) { - GetWindowText((HWND)lParam, szText, SIZEOF(szText)); + GetWindowText((HWND)lParam, szText, _countof(szText)); EnableWindow(GetDlgItem(hDlg, IDOK), ((pszAdd = _tcschr(szText, '@')) && *(pszAdd + 1) != '.' && @@ -255,10 +255,10 @@ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam HWND hBtn; hBtn = GetDlgItem(hDlg, IDOK); - GetWindowText(hBtn, szButton, SIZEOF(szButton)); + GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); hBtn = GetDlgItem(hDlg, IDCANCEL); - GetWindowText(hBtn, szButton, SIZEOF(szButton)); + GetWindowText(hBtn, szButton, _countof(szButton)); SetWindowText(hBtn, TranslateTS(szButton)); } if (*cbi->pszVal) SetWindowText(hDlg, LPGENT("Edit phone number")); @@ -295,7 +295,7 @@ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam TCHAR szText[MAXDATASIZE]; int errorPos; - if (!GetDlgItemText(hDlg, EDIT_PHONE, szText, SIZEOF(szText)) || !CheckPhoneSyntax(szText, cbi->pszVal, cbi->ccVal, errorPos) || errorPos > -1) { + if (!GetDlgItemText(hDlg, EDIT_PHONE, szText, _countof(szText)) || !CheckPhoneSyntax(szText, cbi->pszVal, cbi->ccVal, errorPos) || errorPos > -1) { MsgErr(hDlg, TranslateT("The phone number should start with a + and consist of\nnumbers, spaces, brackets and hyphens only.")); break; } @@ -326,9 +326,9 @@ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam int nCurSel = SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETCURSEL, 0, 0); UINT nCountry = (nCurSel != CB_ERR) ? SendDlgItemMessage(hDlg, EDIT_COUNTRY, CB_GETITEMDATA, nCurSel, 0) : 0; - GetDlgItemText(hDlg, EDIT_AREA, szArea, SIZEOF(szArea)); - GetDlgItemText(hDlg, EDIT_NUMBER, szData, SIZEOF(szData)); - mir_sntprintf(szPhone, SIZEOF(szPhone), _T("+%u (%s) %s"), nCountry, szArea, szData); + GetDlgItemText(hDlg, EDIT_AREA, szArea, _countof(szArea)); + GetDlgItemText(hDlg, EDIT_NUMBER, szData, _countof(szData)); + mir_sntprintf(szPhone, _countof(szPhone), _T("+%u (%s) %s"), nCountry, szArea, szData); noRecursion = 1; SetDlgItemText(hDlg, EDIT_PHONE, szPhone); noRecursion = 0; @@ -342,7 +342,7 @@ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam { TCHAR szText[MAXDATASIZE], *pText, *pArea, *pNumber; int isValid = 1; - GetDlgItemText(hDlg, EDIT_PHONE, szText, SIZEOF(szText)); + GetDlgItemText(hDlg, EDIT_PHONE, szText, _countof(szText)); if (szText[0] != '+') isValid = 0; if (isValid) { int i, country = _tcstol(szText + 1, &pText, 10); @@ -778,7 +778,7 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L !cbex->pItems || cbex->iSelectedItem < 0 || cbex->iSelectedItem >= cbex->numItems || - FAILED(mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("Do you really want to delete the current selected item?\n\t%s\n\t%s"), + FAILED(mir_sntprintf(szMsg, _countof(szMsg), TranslateT("Do you really want to delete the current selected item?\n\t%s\n\t%s"), cbex->pItems[cbex->iSelectedItem].szCat, cbex->pItems[cbex->iSelectedItem].pszVal)) ) { @@ -845,7 +845,7 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L int errorPos; TCHAR szEdit[MAXDATASIZE]; - if (ccVal = GetWindowText(cbex->hEdit, szEdit, SIZEOF(szEdit))) { + if (ccVal = GetWindowText(cbex->hEdit, szEdit, _countof(szEdit))) { if (!(ccVal = CheckPhoneSyntax(szEdit, szVal, MAXDATASIZE, errorPos)) || errorPos > -1) { SetWindowText(cbex->hEdit, szVal); SendMessage(cbex->hEdit, EM_SETSEL, errorPos, errorPos); @@ -854,10 +854,10 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L break; } case EDIT_EMAIL: - ccVal = GetWindowText(cbex->hEdit, szVal, SIZEOF(szVal)); + ccVal = GetWindowText(cbex->hEdit, szVal, _countof(szVal)); break; default: - ccVal = GetWindowText(cbex->hEdit, szVal, SIZEOF(szVal)); + ccVal = GetWindowText(cbex->hEdit, szVal, _countof(szVal)); break; } @@ -944,7 +944,7 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L // set category string if (!pItem->pszCat || !pItem->pszCat[0] || !mir_tstrncpy(cbex->pItems[cbex->numItems].szCat, pItem->pszCat, MAX_CAT)) { - mir_sntprintf(cbex->pItems[cbex->numItems].szCat, SIZEOF(cbex->pItems[cbex->numItems].szCat), _T("%s %d"), TranslateT("Other"), ++cbex->numOther); + mir_sntprintf(cbex->pItems[cbex->numItems].szCat, _countof(cbex->pItems[cbex->numItems].szCat), _T("%s %d"), TranslateT("Other"), ++cbex->numOther); } // set value string @@ -983,8 +983,8 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L // set new category string if (pItem->wMask & CBEXIM_CAT) { // set category string - if (!pItem->pszCat || !pItem->pszCat[0] || !mir_tstrncpy(cbex->pItems[pItem->iItem].szCat, pItem->pszCat, SIZEOF(cbex->pItems[pItem->iItem].szCat))) - mir_sntprintf(cbex->pItems[pItem->iItem].szCat, SIZEOF(cbex->pItems[pItem->iItem].szCat), _T("%s %d"), TranslateT("Other"), ++cbex->numOther); + if (!pItem->pszCat || !pItem->pszCat[0] || !mir_tstrncpy(cbex->pItems[pItem->iItem].szCat, pItem->pszCat, _countof(cbex->pItems[pItem->iItem].szCat))) + mir_sntprintf(cbex->pItems[pItem->iItem].szCat, _countof(cbex->pItems[pItem->iItem].szCat), _T("%s %d"), TranslateT("Other"), ++cbex->numOther); if (pItem->iItem == cbex->iSelectedItem) SetWindowText(cbex->hBtnEdit, cbex->pItems[pItem->iItem].szCat); } @@ -1347,7 +1347,7 @@ int CtrlContactAddMyItemsFromDB( cbi.pszIcon = szIcon; for (i = 0; - SUCCEEDED(mir_snprintf(pszSetting, SIZEOF(pszSetting), szFormatVal, i)) && + SUCCEEDED(mir_snprintf(pszSetting, _countof(pszSetting), szFormatVal, i)) && (cbi.wFlags = DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, pszSetting, &dbv)); i++) { @@ -1358,7 +1358,7 @@ int CtrlContactAddMyItemsFromDB( dbv.ptszVal = NULL; // read category - if (SUCCEEDED(mir_snprintf(pszSetting, SIZEOF(pszSetting), szFormatCat, i))) { + if (SUCCEEDED(mir_snprintf(pszSetting, _countof(pszSetting), szFormatCat, i))) { if (cbi.wFlags & CTRLF_HASCUSTOM) { if (DB::Setting::GetTString(hContact, pszModule, pszSetting, &dbv)) dbv.type = DBVT_DELETED; @@ -1426,7 +1426,7 @@ int CtrlContactWriteItemToDB( db_unset(hContact, pszModule, pszSetting); else { if (cbi.wFlags & CBEXIF_SMS) - mir_tstrncat(szVal, _T(" SMS"), SIZEOF(szVal) - mir_tstrlen(szVal)); + mir_tstrncat(szVal, _T(" SMS"), _countof(szVal) - mir_tstrlen(szVal)); if (db_set_ts(hContact, pszModule, pszSetting, szVal)) return 1; } @@ -1476,15 +1476,15 @@ int CtrlContactWriteMyItemsToDB( while (CtrlContactWndProc(hCtrl, CBEXM_GETITEM, NULL, (LPARAM)&cbi) && cbi.iItem < 50) { if (!(cbi.wFlags & CBEXIF_DELETED) && *szVal) { if (cbi.wFlags & CBEXIF_SMS) { - mir_tstrncat(szVal, _T(" SMS"), SIZEOF(szVal) - mir_tstrlen(szVal)); + mir_tstrncat(szVal, _T(" SMS"), _countof(szVal) - mir_tstrlen(szVal)); } - mir_snprintf(pszSetting, SIZEOF(pszSetting), szFormatCat, i); + mir_snprintf(pszSetting, _countof(pszSetting), szFormatCat, i); if (*szCat && _tcsncmp(szCat, pszOther, ccOther)) { if (db_set_ts(hContact, pszModule, pszSetting, szCat)) return 1; } else db_unset(hContact, pszModule, pszSetting); - mir_snprintf(pszSetting, SIZEOF(pszSetting), szFormatVal, i); + mir_snprintf(pszSetting, _countof(pszSetting), szFormatVal, i); if (db_set_ts(hContact, pszModule, pszSetting, szVal)) return 1; cbi.wFlags &= ~CTRLF_CHANGED; cbi.wMask = CBEXIM_FLAGS; diff --git a/plugins/UserInfoEx/src/ctrl_edit.cpp b/plugins/UserInfoEx/src/ctrl_edit.cpp index 01d6bb911c..1734518c17 100644 --- a/plugins/UserInfoEx/src/ctrl_edit.cpp +++ b/plugins/UserInfoEx/src/ctrl_edit.cpp @@ -122,19 +122,19 @@ BOOL CEditCtrl::OnInfoChanged(MCONTACT hContact, LPCSTR pszProto) switch (dbv.type) { case DBVT_BYTE: - _itot_s(dbv.bVal, szText, SIZEOF(szText), 10); + _itot_s(dbv.bVal, szText, _countof(szText), 10); SetWindowText(_hwnd, szText); _pszValue = mir_tstrdup(szText); break; case DBVT_WORD: - _itot_s(dbv.wVal, szText, SIZEOF(szText), 10); + _itot_s(dbv.wVal, szText, _countof(szText), 10); SetWindowText(_hwnd, szText); _pszValue = mir_tstrdup(szText); break; case DBVT_DWORD: - _itot_s(dbv.dVal, szText, SIZEOF(szText), 10); + _itot_s(dbv.dVal, szText, _countof(szText), 10); SetWindowText(_hwnd, szText); _pszValue = mir_tstrdup(szText); break; diff --git a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp index 23ef5396dd..880ce91789 100644 --- a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp +++ b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp @@ -242,15 +242,15 @@ class CAnnivList case COLUMN_CONTACT: case COLUMN_PROTO: case COLUMN_DESC: - ListView_GetItemText(pDlg->_hList, iItem1, pDlg->_sortHeader, szText1, SIZEOF(szText1)); - ListView_GetItemText(pDlg->_hList, iItem2, pDlg->_sortHeader, szText2, SIZEOF(szText2)); + ListView_GetItemText(pDlg->_hList, iItem1, pDlg->_sortHeader, szText1, _countof(szText1)); + ListView_GetItemText(pDlg->_hList, iItem2, pDlg->_sortHeader, szText2, _countof(szText2)); result = pDlg->_sortOrder * mir_tstrcmp(szText1, szText2); break; case COLUMN_AGE: case COLUMN_ETA: - ListView_GetItemText(pDlg->_hList, iItem1, pDlg->_sortHeader, szText1, SIZEOF(szText1)); - ListView_GetItemText(pDlg->_hList, iItem2, pDlg->_sortHeader, szText2, SIZEOF(szText2)); + ListView_GetItemText(pDlg->_hList, iItem1, pDlg->_sortHeader, szText1, _countof(szText1)); + ListView_GetItemText(pDlg->_hList, iItem2, pDlg->_sortHeader, szText2, _countof(szText2)); result = pDlg->_sortOrder * (_ttoi(szText1) - _ttoi(szText2)); break; @@ -598,7 +598,7 @@ class CAnnivList LVCOLUMN lvc; CHAR pszSetting[MAXSETTING]; - mir_snprintf(pszSetting, SIZEOF(pszSetting), "AnnivDlg_Col%d", iSubItem); + mir_snprintf(pszSetting, _countof(pszSetting), "AnnivDlg_Col%d", iSubItem); lvc.cx = db_get_w(NULL, MODNAME, pszSetting, defaultWidth); lvc.mask = LVCF_WIDTH | LVCF_TEXT; lvc.iSubItem = iSubItem; @@ -713,7 +713,7 @@ class CAnnivList AddSubItem(iItem, COLUMN_DESC, (LPTSTR)ad.Description()); // sixth line: date - ad.DateFormatAlt(szText, SIZEOF(szText)); + ad.DateFormatAlt(szText, _countof(szText)); AddSubItem(iItem, COLUMN_DATE, szText); _numRows++; @@ -877,7 +877,7 @@ public: int c, cc = Header_GetItemCount(ListView_GetHeader(_hList)); for (c = 0; c < cc; c++) { - mir_snprintf(pszSetting, SIZEOF(pszSetting), "AnnivDlg_Col%d", c); + mir_snprintf(pszSetting, _countof(pszSetting), "AnnivDlg_Col%d", c); db_set_w(NULL, MODNAME, pszSetting, (WORD)ListView_GetColumnWidth(_hList, c)); } DeleteAllItems(); diff --git a/plugins/UserInfoEx/src/dlg_msgbox.cpp b/plugins/UserInfoEx/src/dlg_msgbox.cpp index aa3793c929..d2a8f9baec 100644 --- a/plugins/UserInfoEx/src/dlg_msgbox.cpp +++ b/plugins/UserInfoEx/src/dlg_msgbox.cpp @@ -496,8 +496,8 @@ static INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP pd.lchContact = NULL; //(HANDLE)wParam; // icon pd.lchIcon = MsgLoadIcon(pMsgBox); - mir_tstrncpy(pd.lptzContactName, pMsgBox->ptszTitle, SIZEOF(pd.lptzContactName)); - mir_tstrncpy(pd.lptzText, pMsgBox->ptszMsg, SIZEOF(pd.lptzText)); + mir_tstrncpy(pd.lptzContactName, pMsgBox->ptszTitle, _countof(pd.lptzContactName)); + mir_tstrncpy(pd.lptzText, pMsgBox->ptszMsg, _countof(pd.lptzText)); // CALLBAC Proc pd.PluginWindowProc = PopupProc; @@ -665,7 +665,7 @@ INT_PTR CALLBACK MsgBox(HWND hParent, UINT uType, LPCTSTR pszTitle, LPCTSTR pszI va_list vl; va_start(vl, pszFormat); - mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl); + mir_vsntprintf(tszMsg, _countof(tszMsg), TranslateTS(pszFormat), vl); va_end(vl); MSGBOX mb = { 0 }; @@ -688,11 +688,11 @@ INT_PTR CALLBACK MsgBox(HWND hParent, UINT uType, LPCTSTR pszTitle, LPCTSTR pszI INT_PTR CALLBACK MsgErr(HWND hParent, LPCTSTR pszFormat, ...) { TCHAR tszTitle[MAX_SECONDLINE], tszMsg[MAX_SECONDLINE]; - mir_sntprintf(tszTitle, SIZEOF(tszMsg), _T("%s - %s"), _T(MODNAME), TranslateT("Error")); + mir_sntprintf(tszTitle, _countof(tszMsg), _T("%s - %s"), _T(MODNAME), TranslateT("Error")); va_list vl; va_start(vl, pszFormat); - mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl); + mir_vsntprintf(tszMsg, _countof(tszMsg), TranslateTS(pszFormat), vl); va_end(vl); MSGBOX mb = {0}; diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index e43577998e..3d9324da40 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -137,7 +137,7 @@ private: EnableWindow(GetDlgItem(_pPs->hDlg, IDOK), FALSE); EnableWindow(GetDlgItem(_pPs->hDlg, IDAPPLY), FALSE); - mir_snprintf(_pPs->szUpdating, SIZEOF(_pPs->szUpdating), "%s (%s)", Translate("Uploading"), (*_pPd)->szModuleName); + mir_snprintf(_pPs->szUpdating, _countof(_pPs->szUpdating), "%s (%s)", Translate("Uploading"), (*_pPd)->szModuleName); ShowWindow(GetDlgItem(_pPs->hDlg, TXT_UPDATING), SW_SHOW); SetTimer(_pPs->hDlg, TIMERID_UPDATING, 100, NULL); return 0; @@ -437,56 +437,56 @@ static int AddProtocolPages(OPTIONSDIALOGPAGE& odp, WPARAM wParam, LPSTR pszProt odp.position = 0x8000000; odp.pfnDlgProc = PSPProcGeneral; odp.hIcon = (HICON)ICONINDEX(IDI_TREE_GENERAL); - mir_tstrncpy(szTitle + ofs, LPGENT("General"), SIZEOF(szTitle) - ofs); + mir_tstrncpy(szTitle + ofs, LPGENT("General"), _countof(szTitle) - ofs); AddPage(wParam, (LPARAM)&odp); odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ADDRESS); odp.position = 0x8000001; odp.pfnDlgProc = PSPProcContactHome; odp.hIcon = (HICON)ICONINDEX(IDI_TREE_ADDRESS); - mir_tstrncpy(szTitle + ofs, LPGENT("General") _T("\\") LPGENT("Contact (private)"), SIZEOF(szTitle) - ofs); + mir_tstrncpy(szTitle + ofs, LPGENT("General") _T("\\") LPGENT("Contact (private)"), _countof(szTitle) - ofs); AddPage(wParam, (LPARAM)&odp); odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ORIGIN); odp.position = 0x8000002; odp.pfnDlgProc = PSPProcOrigin; odp.hIcon = (HICON)ICONINDEX(IDI_TREE_ADVANCED); - mir_tstrncpy(szTitle + ofs, LPGENT("General") _T("\\") LPGENT("Origin"), SIZEOF(szTitle) - ofs); + mir_tstrncpy(szTitle + ofs, LPGENT("General") _T("\\") LPGENT("Origin"), _countof(szTitle) - ofs); AddPage(wParam, (LPARAM)&odp); odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ANNIVERSARY); odp.position = 0x8000003; odp.pfnDlgProc = PSPProcAnniversary; odp.hIcon = (HICON)ICONINDEX(IDI_BIRTHDAY); - mir_tstrncpy(szTitle + ofs, LPGENT("General") _T("\\") LPGENT("Anniversaries"), SIZEOF(szTitle) - ofs); + mir_tstrncpy(szTitle + ofs, LPGENT("General") _T("\\") LPGENT("Anniversaries"), _countof(szTitle) - ofs); AddPage(wParam, (LPARAM)&odp); odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COMPANY); odp.position = 0x8000004; odp.pfnDlgProc = PSPProcCompany; odp.hIcon = (HICON)ICONINDEX(IDI_TREE_COMPANY); - mir_tstrncpy(szTitle + ofs, LPGENT("Work"), SIZEOF(szTitle) - ofs); + mir_tstrncpy(szTitle + ofs, LPGENT("Work"), _countof(szTitle) - ofs); AddPage(wParam, (LPARAM)&odp); odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ADDRESS); odp.position = 0x8000005; odp.pfnDlgProc = PSPProcContactWork; odp.hIcon = (HICON)ICONINDEX(IDI_TREE_ADDRESS); - mir_tstrncpy(szTitle + ofs, LPGENT("Work") _T("\\") LPGENT("Contact (work)"), SIZEOF(szTitle) - ofs); + mir_tstrncpy(szTitle + ofs, LPGENT("Work") _T("\\") LPGENT("Contact (work)"), _countof(szTitle) - ofs); AddPage(wParam, (LPARAM)&odp); odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ABOUT); odp.position = 0x8000006; odp.pfnDlgProc = PSPProcAbout; odp.hIcon = (HICON)ICONINDEX(IDI_TREE_ABOUT); - mir_tstrncpy(szTitle + ofs, LPGENT("About"), SIZEOF(szTitle) - ofs); + mir_tstrncpy(szTitle + ofs, LPGENT("About"), _countof(szTitle) - ofs); AddPage(wParam, (LPARAM)&odp); odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_PROFILE); odp.position = 0x8000007; odp.pfnDlgProc = PSPProcContactProfile; odp.hIcon = (HICON)ICONINDEX(IDI_TREE_PROFILE); - mir_tstrncpy(szTitle + ofs, LPGENT("About") _T("\\") LPGENT("Profile"), SIZEOF(szTitle) - ofs); + mir_tstrncpy(szTitle + ofs, LPGENT("About") _T("\\") LPGENT("Profile"), _countof(szTitle) - ofs); AddPage(wParam, (LPARAM)&odp); return 0; } @@ -794,14 +794,14 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar static const WORD idMove[] = { IDC_PAGETITLE, IDC_PAGETITLEBG, IDC_PAGETITLEBG2, IDOK, IDCANCEL, IDAPPLY }; HWND hCtrl; - for (int i = 0; i < SIZEOF(idResize); i++) { + for (int i = 0; i < _countof(idResize); i++) { if (hCtrl = GetDlgItem(hDlg, idResize[i])) { GetWindowRect(hCtrl, &rc); OffsetRect(&rc, -pt.x, -pt.y); MoveWindow(hCtrl, rc.left, rc.top, rc.right - rc.left + addWidth, rc.bottom - rc.top, FALSE); } } - for (int k = 0; k < SIZEOF(idMove); k++) { + for (int k = 0; k < _countof(idMove); k++) { if (hCtrl = GetDlgItem(hDlg, idMove[k])) { GetWindowRect(hCtrl, &rc); OffsetRect(&rc, -pt.x, -pt.y); @@ -828,7 +828,7 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar // pPs->updateAnimFrame = 0; if (pPs->hContact && *pPs->pszProto) { - GetDlgItemTextA(hDlg, TXT_UPDATING, pPs->szUpdating, SIZEOF(pPs->szUpdating)); + GetDlgItemTextA(hDlg, TXT_UPDATING, pPs->szUpdating, _countof(pPs->szUpdating)); ShowWindow(GetDlgItem(hDlg, TXT_UPDATING), SW_HIDE); if (DlgProc(hDlg, M_CHECKONLINE, NULL, NULL)) @@ -1135,7 +1135,7 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar { ICO_BTN_APPLY, BM_SETIMAGE, IDAPPLY } }; - const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? SIZEOF(idIcon) : 1; + const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 1; IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet); @@ -1541,7 +1541,7 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (pPs->hContact != NULL) { ResetUpdateInfo(pPs); - mir_snprintf(pPs->szUpdating, SIZEOF(pPs->szUpdating), "%s (%s)", Translate("updating"), pPs->pszProto); + mir_snprintf(pPs->szUpdating, _countof(pPs->szUpdating), "%s (%s)", Translate("updating"), pPs->pszProto); // need meta contact's subcontact information if (DB::Module::IsMetaAndScan(pPs->pszProto)) { diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp index e210d536a1..50e52a490f 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp @@ -83,8 +83,8 @@ BYTE CExImContactXML::IsContactInfo(LPCSTR pszKey) if (pszKey && *pszKey) { char buf[MAXSETTING]; // convert to hash and make bsearch as it is much faster then working with strings - const DWORD dwHash = hashSetting(_strlwr(mir_strncpy(buf, pszKey, SIZEOF(buf)))); - return bsearch(&dwHash, dwCiHash, SIZEOF(dwCiHash), sizeof(dwCiHash[0]), (int (*)(const void*, const void*))SortProc) != NULL; + const DWORD dwHash = hashSetting(_strlwr(mir_strncpy(buf, pszKey, _countof(buf)))); + return bsearch(&dwHash, dwCiHash, _countof(dwCiHash), sizeof(dwCiHash[0]), (int (*)(const void*, const void*))SortProc) != NULL; } return FALSE; } diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp index 374f296123..ddee777778 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp @@ -54,7 +54,7 @@ void ExportTree_AppendModuleList(HWND hTree, HTREEITEM hParent, DB::CEnumList* p tvi.mask = TVIF_STATE|TVIF_TEXT; tvi.stateMask = TVIS_STATEIMAGEMASK; tvi.pszText = szModule; - tvi.cchTextMax = SIZEOF(szModule); + tvi.cchTextMax = _countof(szModule); do { if ( @@ -89,7 +89,7 @@ HTREEITEM ExportTree_FindItem(HWND hTree, HTREEITEM hParent, LPSTR pszText) tvi.mask = TVIF_TEXT; tvi.pszText = szBuf; - tvi.cchTextMax = SIZEOF(szBuf); + tvi.cchTextMax = _countof(szBuf); for (tvi.hItem = TreeView_GetChild(hTree, hParent); tvi.hItem != NULL; @@ -171,7 +171,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar { ICO_BTN_EXPORT, BM_SETIMAGE, IDOK }, { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL } }; - const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? SIZEOF(idIcon) : 2; + const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 2; IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet); // create imagelist for treeview @@ -225,8 +225,8 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar break; } TranslateDialogDefault(hDlg); //to translate oldTitle - GetWindowText(hDlg, oldTitle, SIZEOF(oldTitle)); - mir_sntprintf(newTitle, SIZEOF(newTitle), _T("%s - %s"), name, oldTitle); + GetWindowText(hDlg, oldTitle, _countof(oldTitle)); + mir_sntprintf(newTitle, _countof(newTitle), _T("%s - %s"), name, oldTitle); SetWindowText(hDlg, newTitle); } @@ -394,7 +394,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar tvi.mask = TVIF_TEXT; tvi.pszText = szText; - tvi.cchTextMax = SIZEOF(szText); + tvi.cchTextMax = _countof(szText); // search the tree item of optional items for (tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_ROOT, NULL); diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp index 7093d5770f..4f35dc0b5d 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImOpenSaveFile.cpp @@ -61,7 +61,7 @@ static void InitAlteredPlacesBar() dwFolderID = 17; RegSetValueEx(hkPlacesBar, _T("Place2"), 0, REG_DWORD, (PBYTE)&dwFolderID, sizeof(DWORD)); // Miranda's installation path - GetModuleFileNameA(GetModuleHandleA("mir_app.dll"), szMirandaPath, SIZEOF(szMirandaPath)); + GetModuleFileNameA(GetModuleHandleA("mir_app.dll"), szMirandaPath, _countof(szMirandaPath)); p = mir_strrchr(szMirandaPath, '\\'); if (p) { @@ -69,7 +69,7 @@ static void InitAlteredPlacesBar() } // Miranda's profile path - if (!CallService(MS_DB_GETPROFILEPATH, SIZEOF(szProfilePath), (LPARAM)szProfilePath)) + if (!CallService(MS_DB_GETPROFILEPATH, _countof(szProfilePath), (LPARAM)szProfilePath)) { // only add if different from profile path RegSetValueExA(hkPlacesBar, "Place4", 0, REG_SZ, (PBYTE)szProfilePath, (DWORD)mir_strlen(szProfilePath) + 1); @@ -114,7 +114,7 @@ static LRESULT CALLBACK PlacesBarSubclassProc(HWND hWnd, UINT uMsg, WPARAM wPara // miranda button switch (tbb->idCommand) { case 41063: - mir_tstrncpy(szBtnText, TranslateT("Miranda NG"), SIZEOF(szBtnText)); + mir_tstrncpy(szBtnText, TranslateT("Miranda NG"), _countof(szBtnText)); iString = SendMessage(hWnd, TB_ADDSTRING, NULL, (LPARAM)szBtnText); if (iString != -1) tbb->iString = iString; // set tooltip @@ -204,7 +204,7 @@ static void GetInitialDir(LPSTR pszInitialDir) szRelative[0] = 0; // is some standard path defined - if (!db_get_static(0, MODNAME, "vCardPath", szRelative, SIZEOF(szRelative))) { + if (!db_get_static(0, MODNAME, "vCardPath", szRelative, _countof(szRelative))) { if (!PathToAbsolute(szRelative, pszInitialDir)) mir_strcpy(pszInitialDir, szRelative); } diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp index 16d26c73d9..f2d1f52d8d 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp @@ -42,7 +42,7 @@ INT_PTR CALLBACK DlgProcProgress(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPar { ICO_DLG_IMPORT, STM_SETIMAGE, ICO_DLGLOGO }, { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL } }; - const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? SIZEOF(idIcon) : 2; + const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 2; IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet); TranslateDialogDefault(hDlg); @@ -194,7 +194,7 @@ BYTE CProgress::UpdateContact(LPCTSTR pszFormat, ...) va_list vl; va_start(vl, pszFormat); - mir_vsntprintf(buf, SIZEOF(buf), TranslateTS(pszFormat), vl); + mir_vsntprintf(buf, _countof(buf), TranslateTS(pszFormat), vl); va_end(vl); SetDlgItemText(_hDlg, TXT_CONTACT, buf); } @@ -221,9 +221,9 @@ BYTE CProgress::UpdateSetting(LPCTSTR pszFormat, ...) va_list vl; va_start(vl, pszFormat); - mir_vsntprintf(buf, SIZEOF(buf), TranslateTS(pszFormat), vl); + mir_vsntprintf(buf, _countof(buf), TranslateTS(pszFormat), vl); va_end(vl); - GetDlgItemText(_hDlg, TXT_SETTING, tmp, SIZEOF(tmp)); + GetDlgItemText(_hDlg, TXT_SETTING, tmp, _countof(tmp)); if (mir_tstrcmpi(tmp,buf)) SetDlgItemText(_hDlg, TXT_SETTING, buf); } diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp index b2a0a1676f..7301d87175 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp @@ -35,7 +35,7 @@ INT_PTR CALLBACK DlgProc_DataHistory(HWND hDlg, UINT msg, WPARAM wParam, LPARAM { ICO_BTN_EXPORT, BM_SETIMAGE, IDOK }, { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL } }; - const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? SIZEOF(idIcon) : 2; + const int numIconsToSet = db_get_b(NULL, MODNAME, SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 2; IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet); TranslateDialogDefault(hDlg); diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp index 3b7fea78fe..e9898a9e50 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp @@ -115,7 +115,7 @@ INT_PTR SvcExImport_Export(lpExImParam ExImContact, HWND hwndParent) { CHAR szFileName[MAX_PATH] = { 0 }; // create the filename to suggest the user for the to export contact - DisplayNameToFileName(ExImContact, szFileName, SIZEOF(szFileName)); + DisplayNameToFileName(ExImContact, szFileName, _countof(szFileName)); int nIndex = DlgExIm_SaveFileName(hwndParent, Translate("Select a destination file..."), FilterString(ExImContact), @@ -158,7 +158,7 @@ INT_PTR SvcExImport_Import(lpExImParam ExImContact, HWND hwndParent) CHAR szFileName[MAX_PATH] = { 0 }; // create the filename to suggest the user for the to export contact - DisplayNameToFileName(ExImContact, szFileName, SIZEOF(szFileName)); + DisplayNameToFileName(ExImContact, szFileName, _countof(szFileName)); int nIndex = DlgExIm_OpenFileName(hwndParent, Translate("Import User Details from VCard"), @@ -280,7 +280,7 @@ INT_PTR svcExIm_Group_Service(WPARAM wParam, LPARAM lParam) if (SendMessage(hClist,CLM_GETITEMTYPE, (WPARAM)hItem, 0) == CLCIT_GROUP) { SendMessage(hClist,CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)ptszItem); LPTSTR temp = mir_tstrdup(ptszGroup); - mir_sntprintf(tszGroup, SIZEOF(tszGroup),_T("%s%s%s"), ptszItem, mir_tstrlen(temp)? _T("\\"):_T(""), temp); + mir_sntprintf(tszGroup, _countof(tszGroup),_T("%s%s%s"), ptszItem, mir_tstrlen(temp)? _T("\\"):_T(""), temp); mir_free (temp); } hParent = SendMessage(hClist,CLM_GETNEXTITEM, (WPARAM)CLGN_PARENT, (LPARAM)hItem); diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index 17fd80aa2e..2574bf1e8a 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -362,7 +362,7 @@ void DeleteArray(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszFormat, int iSta { char pszSetting[MAXSETTING]; do { - mir_snprintf(pszSetting, SIZEOF(pszSetting), pszFormat, iStart++); + mir_snprintf(pszSetting, _countof(pszSetting), pszFormat, iStart++); } while (!db_unset(hContact, pszModule, pszSetting)); } diff --git a/plugins/UserInfoEx/src/mir_icolib.cpp b/plugins/UserInfoEx/src/mir_icolib.cpp index ecdaafe2d1..86941be027 100644 --- a/plugins/UserInfoEx/src/mir_icolib.cpp +++ b/plugins/UserInfoEx/src/mir_icolib.cpp @@ -134,7 +134,7 @@ LPTSTR IcoLib_GetDefaultIconFileName() }; TCHAR absolute[MAX_PATH]; - for (int i = 0; i < SIZEOF(path); i++) { + for (int i = 0; i < _countof(path); i++) { PathToAbsoluteT(path[i], absolute); if (PathFileExists(absolute)) return path[i]; @@ -326,7 +326,7 @@ void IcoLib_LoadModule() // load default icon if required ghDefIcon = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_DEFAULT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); - for (int i = 0; i < SIZEOF(icoDesc); i++) + for (int i = 0; i < _countof(icoDesc); i++) IcoLib_RegisterIconHandleEx( icoDesc[i].pszName, icoDesc[i].pszDesc, icoDesc[i].pszSection, szDefaultFile, icoDesc[i].idResource, icoDesc[i].size, ghDefIcon); diff --git a/plugins/UserInfoEx/src/mir_menuitems.cpp b/plugins/UserInfoEx/src/mir_menuitems.cpp index 29ddc0cea9..1293c0aa2d 100644 --- a/plugins/UserInfoEx/src/mir_menuitems.cpp +++ b/plugins/UserInfoEx/src/mir_menuitems.cpp @@ -82,7 +82,7 @@ void RebuildContact() } // delete all MenuItems and set all bytes 0 to avoid problems - RemoveMenuItems (hMenuItem, SIZEOF(hMenuItem)); + RemoveMenuItems (hMenuItem, _countof(hMenuItem)); // support new genmenu style CLISTMENUITEM mi = { sizeof(mi) }; @@ -178,7 +178,7 @@ void RebuildMain() } // delete all MenuItems and set all bytes 0 to avoid problems - RemoveMenuItems (hMenuItem, SIZEOF(hMenuItem)); + RemoveMenuItems (hMenuItem, _countof(hMenuItem)); // support new genmenu style CLISTMENUITEM mi = { sizeof(mi) }; @@ -316,7 +316,7 @@ void RebuildGroup() } // delete all MenuItems and set all bytes 0 to avoid problems - RemoveMenuItems (hMenuItem, SIZEOF(hMenuItem)); + RemoveMenuItems (hMenuItem, _countof(hMenuItem)); // create service name main (prevent to generate {(Null)/Ex-/Import Group} in db) and set pointer to end it char text[200]; @@ -413,7 +413,7 @@ void RebuildSubGroup() } // delete all MenuItems and set all bytes 0 to avoid problems - RemoveMenuItems (hMenuItem, SIZEOF(hMenuItem)); + RemoveMenuItems (hMenuItem, _countof(hMenuItem)); // create service name main (prevent to generate {(Null)/Ex-/Import Group} in db) and set pointer to end it char text[200]; diff --git a/plugins/UserInfoEx/src/psp_anniversary.cpp b/plugins/UserInfoEx/src/psp_anniversary.cpp index b4b90ae57b..3c602c500c 100644 --- a/plugins/UserInfoEx/src/psp_anniversary.cpp +++ b/plugins/UserInfoEx/src/psp_anniversary.cpp @@ -148,7 +148,7 @@ INT_PTR CALLBACK PSPProcAnniversary(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM { ICO_BTN_ADD, BM_SETIMAGE, BTN_ADD }, { ICO_BTN_DELETE, BM_SETIMAGE, BTN_DELETE } }; - IcoLib_SetCtrlIcons(hDlg, idIcon, SIZEOF(idIcon)); + IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon)); } return FALSE; } diff --git a/plugins/UserInfoEx/src/psp_contact.cpp b/plugins/UserInfoEx/src/psp_contact.cpp index 089f4239c8..88f61ba4f9 100644 --- a/plugins/UserInfoEx/src/psp_contact.cpp +++ b/plugins/UserInfoEx/src/psp_contact.cpp @@ -47,7 +47,7 @@ INT_PTR CALLBACK PSPProcContactHome(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM PSGetBoldFont(hDlg, hBoldFont); SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0); - mir_sntprintf(szAddr, SIZEOF(szAddr), _T("%s (%s)"), TranslateT("Address"), TranslateT("home")); + mir_sntprintf(szAddr, _countof(szAddr), _T("%s (%s)"), TranslateT("Address"), TranslateT("home")); SetDlgItemText(hDlg, IDC_PAGETITLE, szAddr); SendDlgItemMessage(hDlg, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR); TranslateDialogDefault(hDlg); @@ -194,7 +194,7 @@ INT_PTR CALLBACK PSPProcContactWork(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM PSGetBoldFont(hDlg, hBoldFont); SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0); - mir_sntprintf(szAddr, SIZEOF(szAddr), _T("%s (%s)"), TranslateT("Address and contact"), TranslateT("company")); + mir_sntprintf(szAddr, _countof(szAddr), _T("%s (%s)"), TranslateT("Address and contact"), TranslateT("company")); SetDlgItemText(hDlg, IDC_PAGETITLE, szAddr); SendDlgItemMessage(hDlg, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR); TranslateDialogDefault(hDlg); diff --git a/plugins/UserInfoEx/src/psp_general.cpp b/plugins/UserInfoEx/src/psp_general.cpp index f5b5980617..946cd6ceb5 100644 --- a/plugins/UserInfoEx/src/psp_general.cpp +++ b/plugins/UserInfoEx/src/psp_general.cpp @@ -131,7 +131,7 @@ INT_PTR CALLBACK PSPProcGeneral(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar { ICO_COMMON_MALE, STM_SETIMAGE, ICO_MALE }, { ICO_COMMON_MARITAL, STM_SETIMAGE, ICO_MARITAL }, }; - IcoLib_SetCtrlIcons(hDlg, idIcon, SIZEOF(idIcon)); + IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon)); } } } diff --git a/plugins/UserInfoEx/src/psp_options.cpp b/plugins/UserInfoEx/src/psp_options.cpp index 4c71f2c8e2..f904adc813 100644 --- a/plugins/UserInfoEx/src/psp_options.cpp +++ b/plugins/UserInfoEx/src/psp_options.cpp @@ -278,11 +278,11 @@ static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam, bInitialized = 0; { // menu item settings - for (int i = 0; i < SIZEOF(ctrl_Menu); i++) { + for (int i = 0; i < _countof(ctrl_Menu); i++) { int flag = db_get_b(NULL, MODNAME, ctrl_Menu[i].pszKey, 2); // check button and enable / disable control int idEnable[] = { ctrl_Menu[i].idCheckbox + 1, ctrl_Menu[i].idNONE, ctrl_Menu[i].idALL, ctrl_Menu[i].idEXIMPORT }; - EnableControls(hDlg, idEnable, SIZEOF(idEnable), DBGetCheckBtn(hDlg, ctrl_Menu[i].idCheckbox, ctrl_Menu[i].pszKey, 0)); + EnableControls(hDlg, idEnable, _countof(idEnable), DBGetCheckBtn(hDlg, ctrl_Menu[i].idCheckbox, ctrl_Menu[i].pszKey, 0)); // set radio button state int id = ctrl_Menu[i].idNONE; //default if ((flag & 4) == 4) @@ -308,7 +308,7 @@ static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam, case PSN_APPLY: // menu item settings - for (int i = 0; i < SIZEOF(ctrl_Menu); i++) { + for (int i = 0; i < _countof(ctrl_Menu); i++) { int flag = IsDlgButtonChecked(hDlg, ctrl_Menu[i].idCheckbox); flag |= IsDlgButtonChecked(hDlg, ctrl_Menu[i].idNONE) ? 2 : 0; flag |= IsDlgButtonChecked(hDlg, ctrl_Menu[i].idALL) ? 4 : 0; @@ -359,10 +359,10 @@ static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam, case CHECK_OPT_MI_GROUP: case CHECK_OPT_MI_SUBGROUP: case CHECK_OPT_MI_ACCOUNT: - for (int i = 0; i < SIZEOF(ctrl_Menu); i++) { + for (int i = 0; i < _countof(ctrl_Menu); i++) { if (ctrl_Menu[i].idCheckbox == LOWORD(wParam)) { const int idMenuItems[] = { ctrl_Menu[i].idCheckbox + 1, ctrl_Menu[i].idNONE, ctrl_Menu[i].idALL, ctrl_Menu[i].idEXIMPORT }; - EnableControls(hDlg, idMenuItems, SIZEOF(idMenuItems), Button_GetCheck((HWND)lParam)); + EnableControls(hDlg, idMenuItems, _countof(idMenuItems), Button_GetCheck((HWND)lParam)); break; } } @@ -555,7 +555,7 @@ static INT_PTR CALLBACK DlgProc_DetailsDlgOpts(HWND hDlg, UINT uMsg, WPARAM wPar const int idCtrl[] = { CLR_NORMAL, CLR_USER, CLR_BOTH, CLR_CHANGED, CLR_META, TXT_OPT_CLR_NORMAL, TXT_OPT_CLR_USER, TXT_OPT_CLR_BOTH, TXT_OPT_CLR_CHANGED, TXT_OPT_CLR_META }; - EnableControls(hDlg, idCtrl, SIZEOF(idCtrl), bChecked); + EnableControls(hDlg, idCtrl, _countof(idCtrl), bChecked); } case CHECK_OPT_GROUPS: @@ -639,7 +639,7 @@ static INT_PTR CALLBACK DlgProc_ReminderOpts(HWND hDlg, UINT uMsg, WPARAM wParam mtLast.DBGetStamp(NULL, MODNAME, SET_REMIND_LASTCHECK); mtLast.UTCToLocal(); - mtLast.TimeFormat(szTime, SIZEOF(szTime)); + mtLast.TimeFormat(szTime, _countof(szTime)); SetDlgItemText(hDlg, TXT_REMIND_LASTCHECK, szTime); @@ -708,7 +708,7 @@ static INT_PTR CALLBACK DlgProc_ReminderOpts(HWND hDlg, UINT uMsg, WPARAM wParam CHECK_REMIND_SECURED, CHECK_REMIND_STARTUP, EDIT_REMIND_SOUNDOFFSET, SPIN_REMIND_SOUNDOFFSET }; - EnableControls(hDlg, idCtrl, SIZEOF(idCtrl), bEnabled); + EnableControls(hDlg, idCtrl, _countof(idCtrl), bEnabled); } case EDIT_BIRTHMODULE: @@ -869,7 +869,7 @@ static INT_PTR CALLBACK DlgProc_Popups(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR db_set_b(NULL, MODNAME, SET_POPUP_DELAY, 255); else if (IsDlgButtonChecked(hDlg, RADIO_OPT_POPUP_CUSTOM)) { TCHAR szDelay[4]; - GetDlgItemText(hDlg, EDIT_DELAY, szDelay, SIZEOF(szDelay)); + GetDlgItemText(hDlg, EDIT_DELAY, szDelay, _countof(szDelay)); db_set_b(NULL, MODNAME, SET_POPUP_DELAY, (BYTE)_tcstol(szDelay, NULL, 10)); } else @@ -886,7 +886,7 @@ static INT_PTR CALLBACK DlgProc_Popups(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR mir_tstrncpy(ppd.lptzText, TranslateT("This is the reminder message"), MAX_SECONDLINE); // Birthday - mir_tstrncpy(ppd.lptzContactName, TranslateT("Birthday"), SIZEOF(ppd.lptzContactName)); + mir_tstrncpy(ppd.lptzContactName, TranslateT("Birthday"), _countof(ppd.lptzContactName)); ppd.lchIcon = IcoLib_GetIcon(ICO_RMD_DTB0); if (IsDlgButtonChecked(hDlg, CHECK_OPT_POPUP_WINCLR)) { ppd.colorBack = GetSysColor(COLOR_BTNFACE); @@ -899,7 +899,7 @@ static INT_PTR CALLBACK DlgProc_Popups(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR PUAddPopupT(&ppd); // Anniversary - mir_tstrncpy(ppd.lptzContactName, TranslateT("Anniversary"), SIZEOF(ppd.lptzContactName)); + mir_tstrncpy(ppd.lptzContactName, TranslateT("Anniversary"), _countof(ppd.lptzContactName)); ppd.lchIcon = IcoLib_GetIcon(ICO_RMD_DTAX); if (IsDlgButtonChecked(hDlg, CHECK_OPT_POPUP_WINCLR)) { ppd.colorBack = GetSysColor(COLOR_BTNFACE); @@ -937,7 +937,7 @@ static INT_PTR CALLBACK DlgProc_Popups(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR RADIO_OPT_POPUP_PERMANENT, EDIT_DELAY }; - EnableControls(hDlg, idCtrl, SIZEOF(idCtrl), bEnabled); + EnableControls(hDlg, idCtrl, _countof(idCtrl), bEnabled); if (bInitialized) NotifyParentOfChange(hDlg); diff --git a/plugins/UserInfoEx/src/psp_origin.cpp b/plugins/UserInfoEx/src/psp_origin.cpp index 3badb81261..a3275fa436 100644 --- a/plugins/UserInfoEx/src/psp_origin.cpp +++ b/plugins/UserInfoEx/src/psp_origin.cpp @@ -90,11 +90,11 @@ INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara LPTSTR ptr; mt.UTCToLocal(); - mt.DateFormatLong(szTime, SIZEOF(szTime)); + mt.DateFormatLong(szTime, _countof(szTime)); mir_tstrcat(szTime, _T(" - ")); ptr = szTime + mir_tstrlen(szTime); - mt.TimeFormat(ptr, SIZEOF(szTime) - (ptr - szTime)); + mt.TimeFormat(ptr, _countof(szTime) - (ptr - szTime)); SetDlgItemText(hDlg, TXT_DATEADDED, szTime); } } @@ -110,7 +110,7 @@ INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara { ICO_COMMON_CLOCK, STM_SETIMAGE, ICO_CLOCK }, }; - IcoLib_SetCtrlIcons(hDlg, idIcon, SIZEOF(idIcon)); + IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon)); } } } @@ -134,7 +134,7 @@ INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara case WM_TIMER: { TCHAR szTime[32]; - CTzCombo::GetObj(hDlg, EDIT_TIMEZONE)->GetTime(szTime, SIZEOF(szTime)); + CTzCombo::GetObj(hDlg, EDIT_TIMEZONE)->GetTime(szTime, _countof(szTime)); SetDlgItemText(hDlg, TXT_TIME, szTime); break; } diff --git a/plugins/UserInfoEx/src/psp_profile.cpp b/plugins/UserInfoEx/src/psp_profile.cpp index 9ce4fd36ee..c8773a3419 100644 --- a/plugins/UserInfoEx/src/psp_profile.cpp +++ b/plugins/UserInfoEx/src/psp_profile.cpp @@ -487,12 +487,12 @@ static int ProfileList_AddItemlistFromDB( for (i = 0, lvi.iItem = iItem; ; i++) { // read the setting from db - mir_snprintf(pszSetting, SIZEOF(pszSetting), szValFormat, i); + mir_snprintf(pszSetting, _countof(pszSetting), szValFormat, i); if (DB::Setting::GetTString(hContact, pszModule, pszSetting, &dbvVal)) break; if (dbvVal.type != DBVT_TCHAR) continue; - mir_snprintf(pszSetting, SIZEOF(pszSetting), szCatFormat, i); + mir_snprintf(pszSetting, _countof(pszSetting), szCatFormat, i); DB::Setting::GetAString(hContact, pszModule, pszSetting, &dbvCat); // create the itemobject if (!(pItem = (LPLCITEM)mir_alloc(sizeof(LCITEM)))) { @@ -913,7 +913,7 @@ static LRESULT CALLBACK ProfileList_SubclassProc(HWND hwnd, UINT msg, WPARAM wPa if (!PtrIsValid(pList = (LPLISTCTRL)GetUserData(hwnd))) break; - GetWindowText(pList->labelEdit.hEdit, szEdit, SIZEOF(szEdit)); + GetWindowText(pList->labelEdit.hEdit, szEdit, _countof(szEdit)); // need to create the dropdown list? if (pList->labelEdit.dropDown.hDrop == NULL) { @@ -1193,36 +1193,36 @@ INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR *szGroup = 0; lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.pszText = szGroup; - lvi.cchTextMax = SIZEOF(szGroup); + lvi.cchTextMax = _countof(szGroup); for (iItem = lvi.iItem = lvi.iSubItem = 0; ListView_GetItem(hList, &lvi); lvi.iItem++) { if (!PtrIsValid(pItem = (LPLCITEM)lvi.lParam)) { // delete reluctant items - if (iFmt < SIZEOF(pFmt)) { + if (iFmt < _countof(pFmt)) { DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szCatFmt, iItem); DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szValFmt, iItem); } // find information about the group - for (iFmt = 0; iFmt < SIZEOF(pFmt); iFmt++) { + for (iFmt = 0; iFmt < _countof(pFmt); iFmt++) { if (!mir_tstrcmp(szGroup, pFmt[iFmt].szGroup)) break; } // indicate, no group was found. should not happen!! - if (iFmt == SIZEOF(pFmt)) { + if (iFmt == _countof(pFmt)) { *szGroup = 0; iFmt = -1; } iItem = 0; } - else if (iFmt >= 0 && iFmt < SIZEOF(pFmt)) { + else if (iFmt >= 0 && iFmt < _countof(pFmt)) { // save value if (!pItem->pszText[1] || !*pItem->pszText[1]) continue; if (!(pItem->wFlags & (CTRLF_HASPROTO|CTRLF_HASMETA))) { - mir_snprintf(pszSetting, SIZEOF(pszSetting), pFmt[iFmt].szValFmt, iItem); + mir_snprintf(pszSetting, _countof(pszSetting), pFmt[iFmt].szValFmt, iItem); db_set_ts(hContact, pszModule, pszSetting, pItem->pszText[1]); // save category - mir_snprintf(pszSetting, SIZEOF(pszSetting), pFmt[iFmt].szCatFmt, iItem); + mir_snprintf(pszSetting, _countof(pszSetting), pFmt[iFmt].szCatFmt, iItem); if (pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount) db_set_s(hContact, pszModule, pszSetting, (LPSTR)pItem->idstrList[pItem->iListItem].pszText); else if (pItem->pszText[0] && *pItem->pszText[0]) @@ -1239,7 +1239,7 @@ INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR } } // delete reluctant items - if (iFmt >= 0 && iFmt < SIZEOF(pFmt)) { + if (iFmt >= 0 && iFmt < _countof(pFmt)) { DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szCatFmt, iItem); DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szValFmt, iItem); } diff --git a/plugins/UserInfoEx/src/svc_avatar.cpp b/plugins/UserInfoEx/src/svc_avatar.cpp index b81a5022a6..3dde09a036 100644 --- a/plugins/UserInfoEx/src/svc_avatar.cpp +++ b/plugins/UserInfoEx/src/svc_avatar.cpp @@ -33,7 +33,7 @@ namespace NServices size_t len = mir_strlen(szFileName); CHAR tmp[64]; - if (WideCharToMultiByte(CP_ACP, 0, zodiac, 64, tmp, SIZEOF(tmp), 0, 0) > 0) + if (WideCharToMultiByte(CP_ACP, 0, zodiac, 64, tmp, _countof(tmp), 0, 0) > 0) mir_snprintf(szFileName + len, cchFileName - len, "\\avatars\\%s.png", tmp); return !PathFileExistsA(szFileName); @@ -54,7 +54,7 @@ namespace NServices // get zodiac for birthday zodiac = mtb.Zodiac(); - if (!GetContactAvatarFileName(zodiac.pszName, szFileName, SIZEOF(szFileName))) { + if (!GetContactAvatarFileName(zodiac.pszName, szFileName, _countof(szFileName))) { // extract the bitmap from the icon //GetIconInfo(zodiac.hIcon, &iinfo); diff --git a/plugins/UserInfoEx/src/svc_constants.cpp b/plugins/UserInfoEx/src/svc_constants.cpp index 12cd47c49d..0abc59b0fd 100644 --- a/plugins/UserInfoEx/src/svc_constants.cpp +++ b/plugins/UserInfoEx/src/svc_constants.cpp @@ -324,7 +324,7 @@ INT_PTR GetCountryList(LPUINT pnListSize, LPIDSTRLIST *pList) INT_PTR GetMaritalList(LPUINT pnListSize, LPIDSTRLIST *pList) { - *pnListSize = SIZEOF(TmplMarital); + *pnListSize = _countof(TmplMarital); *pList = TmplMarital; SvcConstantsTranslateList(TmplMarital, *pnListSize); return MIR_OK; @@ -332,7 +332,7 @@ INT_PTR GetMaritalList(LPUINT pnListSize, LPIDSTRLIST *pList) INT_PTR GetLanguageList(LPUINT pnListSize, LPIDSTRLIST *pList) { - *pnListSize = SIZEOF(TmplLanguages); + *pnListSize = _countof(TmplLanguages); *pList = TmplLanguages; SvcConstantsTranslateList(TmplLanguages, *pnListSize); return MIR_OK; @@ -340,7 +340,7 @@ INT_PTR GetLanguageList(LPUINT pnListSize, LPIDSTRLIST *pList) INT_PTR GetOccupationList(LPUINT pnListSize, LPIDSTRLIST *pList) { - *pnListSize = SIZEOF(TmplOccupations); + *pnListSize = _countof(TmplOccupations); *pList = TmplOccupations; SvcConstantsTranslateList(TmplOccupations, *pnListSize); return MIR_OK; @@ -348,7 +348,7 @@ INT_PTR GetOccupationList(LPUINT pnListSize, LPIDSTRLIST *pList) INT_PTR GetInterestsList(LPUINT pnListSize, LPIDSTRLIST *pList) { - *pnListSize = SIZEOF(TmplInterests); + *pnListSize = _countof(TmplInterests); *pList = TmplInterests; SvcConstantsTranslateList(TmplInterests, *pnListSize); return MIR_OK; @@ -356,7 +356,7 @@ INT_PTR GetInterestsList(LPUINT pnListSize, LPIDSTRLIST *pList) INT_PTR GetPastList(LPUINT pnListSize, LPIDSTRLIST *pList) { - *pnListSize = SIZEOF(TmplPast); + *pnListSize = _countof(TmplPast); *pList = TmplPast; SvcConstantsTranslateList(TmplPast, *pnListSize); return MIR_OK; @@ -364,7 +364,7 @@ INT_PTR GetPastList(LPUINT pnListSize, LPIDSTRLIST *pList) INT_PTR GetAffiliationsList(LPUINT pnListSize, LPIDSTRLIST *pList) { - *pnListSize = SIZEOF(TmplAffiliations); + *pnListSize = _countof(TmplAffiliations); *pList = TmplAffiliations; SvcConstantsTranslateList(TmplAffiliations, *pnListSize); return MIR_OK; @@ -372,7 +372,7 @@ INT_PTR GetAffiliationsList(LPUINT pnListSize, LPIDSTRLIST *pList) INT_PTR GetNamePrefixList(LPUINT pnListSize, LPIDSTRLIST *pList) { - *pnListSize = SIZEOF(TmplPrefixes); + *pnListSize = _countof(TmplPrefixes); *pList = TmplPrefixes; SvcConstantsTranslateList(TmplPrefixes, *pnListSize); return MIR_OK; @@ -403,13 +403,13 @@ static void FORCEINLINE SvcConstantsClearList(UINT pnListSize, LPIDSTRLIST pList void SvcConstantsUnloadModule(void) { - SvcConstantsClearList(SIZEOF(TmplMarital), TmplMarital); - SvcConstantsClearList(SIZEOF(TmplLanguages), TmplLanguages); - SvcConstantsClearList(SIZEOF(TmplOccupations), TmplOccupations); - SvcConstantsClearList(SIZEOF(TmplInterests), TmplInterests); - SvcConstantsClearList(SIZEOF(TmplPast), TmplPast); - SvcConstantsClearList(SIZEOF(TmplAffiliations), TmplAffiliations); - SvcConstantsClearList(SIZEOF(TmplPrefixes), TmplPrefixes); + SvcConstantsClearList(_countof(TmplMarital), TmplMarital); + SvcConstantsClearList(_countof(TmplLanguages), TmplLanguages); + SvcConstantsClearList(_countof(TmplOccupations), TmplOccupations); + SvcConstantsClearList(_countof(TmplInterests), TmplInterests); + SvcConstantsClearList(_countof(TmplPast), TmplPast); + SvcConstantsClearList(_countof(TmplAffiliations), TmplAffiliations); + SvcConstantsClearList(_countof(TmplPrefixes), TmplPrefixes); SvcConstantsClearList(MyCountriesCount, MyCountries); MIR_FREE(MyCountries); } diff --git a/plugins/UserInfoEx/src/svc_contactinfo.cpp b/plugins/UserInfoEx/src/svc_contactinfo.cpp index 662d300256..627d3c2794 100644 --- a/plugins/UserInfoEx/src/svc_contactinfo.cpp +++ b/plugins/UserInfoEx/src/svc_contactinfo.cpp @@ -548,12 +548,12 @@ INT_PTR GetContactInfo(WPARAM wParam, LPARAM lParam) ci->pszVal = NULL; if (ci->dwFlag & CNF_UNICODE) { WCHAR wszDate[80]; - if (GetDateFormatW(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, wszDate, SIZEOF(wszDate))) + if (GetDateFormatW(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, wszDate, _countof(wszDate))) ci->pszVal = (LPTSTR)mir_wstrdup(wszDate); } else { CHAR szDate[80]; - if (GetDateFormatA(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, szDate, SIZEOF(szDate))) + if (GetDateFormatA(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, szDate, _countof(szDate))) ci->pszVal = (LPTSTR)mir_strdup(szDate); } ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; diff --git a/plugins/UserInfoEx/src/svc_refreshci.cpp b/plugins/UserInfoEx/src/svc_refreshci.cpp index 6a99a2ac44..9d483e7654 100644 --- a/plugins/UserInfoEx/src/svc_refreshci.cpp +++ b/plugins/UserInfoEx/src/svc_refreshci.cpp @@ -119,7 +119,7 @@ public: va_list vl; va_start(vl, szText); - if (mir_vsntprintf(buf, SIZEOF(buf), szText, vl) != -1) + if (mir_vsntprintf(buf, _countof(buf), szText, vl) != -1) { SetTitle(buf); } @@ -179,7 +179,7 @@ public: } va_start(vl, szText); - if (mir_vsntprintf(buf, SIZEOF(buf), fmt, vl) != -1) + if (mir_vsntprintf(buf, _countof(buf), fmt, vl) != -1) { SetText(buf); } @@ -427,7 +427,7 @@ public: pd.iSeconds = -1; pd.PluginData = this; pd.PluginWindowProc = CPopupUpdProgress::WndProc; - pd.actionCount = SIZEOF(_popupButtons); + pd.actionCount = _countof(_popupButtons); pd.lpActions = _popupButtons; // dummy text diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp index 62b097bf4e..82936b60ab 100644 --- a/plugins/UserInfoEx/src/svc_reminder.cpp +++ b/plugins/UserInfoEx/src/svc_reminder.cpp @@ -148,7 +148,7 @@ static HICON GetAnnivIcon(const CEvent &evt) if (evt._wDaysLeft > 9) hIcon = IcoLib_GetIcon(ICO_RMD_DTBX); else { - mir_snprintf(szIcon, SIZEOF(szIcon), MODNAME"_rmd_dtb%u", evt._wDaysLeft); + mir_snprintf(szIcon, _countof(szIcon), MODNAME"_rmd_dtb%u", evt._wDaysLeft); hIcon = IcoLib_GetIcon(szIcon); } break; @@ -157,7 +157,7 @@ static HICON GetAnnivIcon(const CEvent &evt) if (evt._wDaysLeft > 9) hIcon = IcoLib_GetIcon(ICO_RMD_DTAX); else { - mir_snprintf(szIcon, SIZEOF(szIcon), MODNAME"_rmd_dta%u", evt._wDaysLeft); + mir_snprintf(szIcon, _countof(szIcon), MODNAME"_rmd_dta%u", evt._wDaysLeft); hIcon = IcoLib_GetIcon(szIcon); } } @@ -183,7 +183,7 @@ static void NotifyWithExtraIcon(MCONTACT hContact, const CEvent &evt) if (evt._wDaysLeft > 9) icoName = ICO_RMD_DTAX; else { - mir_snprintf(szIcon, SIZEOF(szIcon), MODNAME"_rmd_dtb%u", evt._wDaysLeft); + mir_snprintf(szIcon, _countof(szIcon), MODNAME"_rmd_dtb%u", evt._wDaysLeft); icoName = szIcon; } break; @@ -192,7 +192,7 @@ static void NotifyWithExtraIcon(MCONTACT hContact, const CEvent &evt) if (evt._wDaysLeft > 9) icoName = ICO_RMD_DTAX; else { - mir_snprintf(szIcon, SIZEOF(szIcon), MODNAME"_rmd_dta%u", evt._wDaysLeft); + mir_snprintf(szIcon, _countof(szIcon), MODNAME"_rmd_dta%u", evt._wDaysLeft); icoName = szIcon; } break; @@ -255,10 +255,10 @@ static int NotifyWithPopup(MCONTACT hContact, CEvent::EType eventType, int DaysT if (hContact) { ppd.lchContact = hContact; - mir_sntprintf(ppd.lptzContactName, SIZEOF(ppd.lptzContactName), + mir_sntprintf(ppd.lptzContactName, _countof(ppd.lptzContactName), _T("%s - %s"), TranslateTS(pszDesc), DB::Contact::DisplayName(hContact)); } - else mir_tstrncpy(ppd.lptzContactName, TranslateT("Reminder"), SIZEOF(ppd.lptzContactName)); + else mir_tstrncpy(ppd.lptzContactName, TranslateT("Reminder"), _countof(ppd.lptzContactName)); mir_tstrncpy(ppd.lptzText, pszMsg, MAX_SECONDLINE); @@ -318,12 +318,12 @@ static void NotifyFlashCListIcon(MCONTACT hContact, const CEvent &evt) switch (evt._eType) { case CEvent::BIRTHDAY: - mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has %s today."), DB::Contact::DisplayName(hContact), TranslateT("Birthday")); + mir_sntprintf(szMsg, _countof(szMsg), TranslateT("%s has %s today."), DB::Contact::DisplayName(hContact), TranslateT("Birthday")); cle.hIcon = IcoLib_GetIcon(ICO_COMMON_BIRTHDAY); break; case CEvent::ANNIVERSARY: - mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has %s today."), DB::Contact::DisplayName(hContact), TranslateT("an anniversary")); + mir_sntprintf(szMsg, _countof(szMsg), TranslateT("%s has %s today."), DB::Contact::DisplayName(hContact), TranslateT("an anniversary")); cle.hIcon = IcoLib_GetIcon(ICO_COMMON_ANNIVERSARY); break; @@ -483,29 +483,29 @@ static bool CheckBirthday(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE bNoti switch (Diff) { case 0: - cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has birthday today."), DB::Contact::DisplayName(hContact)); + cchMsg = mir_sntprintf(szMsg, _countof(szMsg), TranslateT("%s has birthday today."), DB::Contact::DisplayName(hContact)); break; case 1: - cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has birthday tomorrow."), DB::Contact::DisplayName(hContact)); + cchMsg = mir_sntprintf(szMsg, _countof(szMsg), TranslateT("%s has birthday tomorrow."), DB::Contact::DisplayName(hContact)); break; default: - cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has birthday in %d days."), DB::Contact::DisplayName(hContact), Diff); + cchMsg = mir_sntprintf(szMsg, _countof(szMsg), TranslateT("%s has birthday in %d days."), DB::Contact::DisplayName(hContact), Diff); } int age = mtb.Age(&Now); if (age > 0) switch (GenderOf(hContact)){ case 0: - mir_sntprintf(szMsg + cchMsg, SIZEOF(szMsg) - cchMsg, + mir_sntprintf(szMsg + cchMsg, _countof(szMsg) - cchMsg, TranslateT("\nHe/she becomes %d years old."), age + (Diff > 0)); break; case 'M': - mir_sntprintf(szMsg + cchMsg, SIZEOF(szMsg) - cchMsg, + mir_sntprintf(szMsg + cchMsg, _countof(szMsg) - cchMsg, TranslateT("\nHe becomes %d years old."), age + (Diff > 0)); break; case 'F': - mir_sntprintf(szMsg + cchMsg, SIZEOF(szMsg) - cchMsg, + mir_sntprintf(szMsg + cchMsg, _countof(szMsg) - cchMsg, TranslateT("\nShe becomes %d years old."), age + (Diff > 0)); break; @@ -600,10 +600,10 @@ void SvcReminderCheckAll(const ENotify notify) static int OnCListRebuildIcons(WPARAM, LPARAM) { - for (int i = 0; i < SIZEOF(ghCListAnnivIcons); i++) + for (int i = 0; i < _countof(ghCListAnnivIcons); i++) ghCListAnnivIcons[i] = INVALID_HANDLE_VALUE; - for (int k = 0; k < SIZEOF(ghCListBirthdayIcons); k++) + for (int k = 0; k < _countof(ghCListBirthdayIcons); k++) ghCListBirthdayIcons[k] = INVALID_HANDLE_VALUE; return 0; diff --git a/plugins/UserInfoEx/src/svc_timezone_old.cpp b/plugins/UserInfoEx/src/svc_timezone_old.cpp index 05809e970b..18da6a4739 100644 --- a/plugins/UserInfoEx/src/svc_timezone_old.cpp +++ b/plugins/UserInfoEx/src/svc_timezone_old.cpp @@ -185,7 +185,7 @@ public: if (result == ERROR_SUCCESS) { // clear out old list this->destroy(); _bias.destroy(); - for (i = 0; ERROR_SUCCESS == RegEnumKey(hKeyRoot, i, szName, SIZEOF(szName)); i++) { + for (i = 0; ERROR_SUCCESS == RegEnumKey(hKeyRoot, i, szName, _countof(szName)); i++) { result = RegOpenKey(hKeyRoot, szName, &hKeyTz); if (result == ERROR_SUCCESS) { pTimeZone = new CTimeZone(); -- cgit v1.2.3