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 --- src/core/stdauth/src/auth.cpp | 10 ++++---- src/core/stdauth/src/authdialogs.cpp | 30 +++++++++++----------- src/core/stdaway/src/awaymsg.cpp | 10 ++++---- src/core/stdaway/src/sendmsg.cpp | 22 ++++++++-------- src/core/stdchat/src/main.cpp | 26 +++++++++---------- src/core/stdchat/src/options.cpp | 42 +++++++++++++++---------------- src/core/stdchat/src/tools.cpp | 6 ++--- src/core/stdchat/src/window.cpp | 18 ++++++------- src/core/stdclist/src/clcfonts.cpp | 18 ++++++------- src/core/stdclist/src/clcopts.cpp | 18 ++++++------- src/core/stdclist/src/clcpaint.cpp | 4 +-- src/core/stdclist/src/cluiopts.cpp | 2 +- src/core/stdfile/src/file.cpp | 6 ++--- src/core/stdfile/src/fileexistsdlg.cpp | 30 +++++++++++----------- src/core/stdfile/src/fileopts.cpp | 24 +++++++++--------- src/core/stdfile/src/filerecvdlg.cpp | 32 +++++++++++------------ src/core/stdfile/src/filesenddlg.cpp | 16 ++++++------ src/core/stdfile/src/filexferdlg.cpp | 28 ++++++++++----------- src/core/stdhelp/src/about.cpp | 6 ++--- src/core/stdidle/src/idle.cpp | 4 +-- src/core/stdmsg/src/globals.cpp | 2 +- src/core/stdmsg/src/msgdialog.cpp | 34 ++++++++++++------------- src/core/stdmsg/src/msglog.cpp | 12 ++++----- src/core/stdmsg/src/msgoptions.cpp | 10 ++++---- src/core/stdmsg/src/msgs.cpp | 10 ++++---- src/core/stdssl/src/netlibssl.cpp | 20 +++++++-------- src/core/stduihist/src/history.cpp | 14 +++++------ src/core/stdurl/url.cpp | 4 +-- src/core/stdurl/urldialogs.cpp | 26 +++++++++---------- src/core/stduserinfo/src/contactinfo.cpp | 26 +++++++++---------- src/core/stduserinfo/src/stdinfo.cpp | 16 ++++++------ src/core/stduserinfo/src/userinfo.cpp | 10 ++++---- src/core/stduseronline/src/useronline.cpp | 2 +- 33 files changed, 269 insertions(+), 269 deletions(-) (limited to 'src/core') diff --git a/src/core/stdauth/src/auth.cpp b/src/core/stdauth/src/auth.cpp index e2a4148e67..5d5d158d18 100644 --- a/src/core/stdauth/src/auth.cpp +++ b/src/core/stdauth/src/auth.cpp @@ -80,7 +80,7 @@ static int AuthEventAdded(WPARAM, LPARAM lParam) break; case CNFT_DWORD: - mir_sntprintf(szUid, SIZEOF(szUid), _T("%u"), ci.dVal); + mir_sntprintf(szUid, _countof(szUid), _T("%u"), ci.dVal); break; } } @@ -88,9 +88,9 @@ static int AuthEventAdded(WPARAM, LPARAM lParam) if (dbei.eventType == EVENTTYPE_AUTHREQUEST) { SkinPlaySound("AuthRequest"); if (szUid[0]) - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%s requests authorization"), szUid); + mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("%s requests authorization"), szUid); else - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob); + mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob); cli.hIcon = Skin_LoadIcon(SKINICON_AUTH_REQUEST); cli.pszService = MS_AUTH_SHOWREQUEST; @@ -99,9 +99,9 @@ static int AuthEventAdded(WPARAM, LPARAM lParam) else if (dbei.eventType == EVENTTYPE_ADDED) { SkinPlaySound("AddedEvent"); if (szUid[0]) - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%s added you to their contact list"), szUid); + mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("%s added you to their contact list"), szUid); else - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob); + mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob); cli.hIcon = Skin_LoadIcon(SKINICON_AUTH_ADD); cli.pszService = MS_AUTH_SHOWADDED; diff --git a/src/core/stdauth/src/authdialogs.cpp b/src/core/stdauth/src/authdialogs.cpp index 4d4674d81c..ddf2fdc738 100644 --- a/src/core/stdauth/src/authdialogs.cpp +++ b/src/core/stdauth/src/authdialogs.cpp @@ -63,14 +63,14 @@ INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar TCHAR name[128] = _T(""); int off = 0; if (firstT[0] && lastT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s %s"), firstT, lastT); + off = mir_sntprintf(name, _countof(name), _T("%s %s"), firstT, lastT); else if (firstT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s"), firstT); + off = mir_sntprintf(name, _countof(name), _T("%s"), firstT); else if (lastT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s"), lastT); + off = mir_sntprintf(name, _countof(name), _T("%s"), lastT); if (nickT[0]) { if (off) - mir_sntprintf(name + off, SIZEOF(name) - off, _T(" (%s)"), nickT); + mir_sntprintf(name + off, _countof(name) - off, _T(" (%s)"), nickT); else _tcsncpy_s(name, nickT, _TRUNCATE); } @@ -79,11 +79,11 @@ INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar TCHAR hdr[256]; if (uin && emailT[0]) - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s added you to the contact list\n%u (%s) on %s"), name, uin, emailT, acc->tszAccountName); + mir_sntprintf(hdr, _countof(hdr), TranslateT("%s added you to the contact list\n%u (%s) on %s"), name, uin, emailT, acc->tszAccountName); else if (uin) - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s added you to the contact list\n%u on %s"), name, uin, acc->tszAccountName); + mir_sntprintf(hdr, _countof(hdr), TranslateT("%s added you to the contact list\n%u on %s"), name, uin, acc->tszAccountName); else - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s added you to the contact list\n%s on %s"), name, emailT[0] ? emailT : TranslateT("(Unknown)"), acc->tszAccountName); + mir_sntprintf(hdr, _countof(hdr), TranslateT("%s added you to the contact list\n%s on %s"), name, emailT[0] ? emailT : TranslateT("(Unknown)"), acc->tszAccountName); SetDlgItemText(hwndDlg, IDC_HEADERBAR, hdr); @@ -188,14 +188,14 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TCHAR name[128] = _T(""); int off = 0; if (firstT[0] && lastT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s %s"), (TCHAR*)firstT, (TCHAR*)lastT); + off = mir_sntprintf(name, _countof(name), _T("%s %s"), (TCHAR*)firstT, (TCHAR*)lastT); else if (firstT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s"), (TCHAR*)firstT); + off = mir_sntprintf(name, _countof(name), _T("%s"), (TCHAR*)firstT); else if (lastT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s"), (TCHAR*)lastT); + off = mir_sntprintf(name, _countof(name), _T("%s"), (TCHAR*)lastT); if (mir_tstrlen(nickT)) { if (off) - mir_sntprintf(name + off, SIZEOF(name) - off, _T(" (%s)"), (TCHAR*)nickT); + mir_sntprintf(name + off, _countof(name) - off, _T(" (%s)"), (TCHAR*)nickT); else _tcsncpy_s(name, nickT, _TRUNCATE); } @@ -204,11 +204,11 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TCHAR hdr[256]; if (uin && emailT[0]) - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%u (%s) on %s"), name, uin, (TCHAR*)emailT, acc->tszAccountName); + mir_sntprintf(hdr, _countof(hdr), TranslateT("%s requested authorization\n%u (%s) on %s"), name, uin, (TCHAR*)emailT, acc->tszAccountName); else if (uin) - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%u on %s"), name, uin, acc->tszAccountName); + mir_sntprintf(hdr, _countof(hdr), TranslateT("%s requested authorization\n%u on %s"), name, uin, acc->tszAccountName); else - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%s on %s"), name, emailT[0] ? (TCHAR*)emailT : TranslateT("(Unknown)"), acc->tszAccountName); + mir_sntprintf(hdr, _countof(hdr), TranslateT("%s requested authorization\n%s on %s"), name, emailT[0] ? (TCHAR*)emailT : TranslateT("(Unknown)"), acc->tszAccountName); SetDlgItemText(hwndDlg, IDC_HEADERBAR, hdr); SetDlgItemText(hwndDlg, IDC_REASON, reasonT); @@ -265,7 +265,7 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_DENYREASON))) { TCHAR tszReason[256]; - GetDlgItemText(hwndDlg, IDC_DENYREASON, tszReason, SIZEOF(tszReason)); + GetDlgItemText(hwndDlg, IDC_DENYREASON, tszReason, _countof(tszReason)); CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, (LPARAM)tszReason); } else CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, 0); diff --git a/src/core/stdaway/src/awaymsg.cpp b/src/core/stdaway/src/awaymsg.cpp index 7cee287dd1..caaed0f169 100644 --- a/src/core/stdaway/src/awaymsg.cpp +++ b/src/core/stdaway/src/awaymsg.cpp @@ -60,12 +60,12 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP WORD dwStatus = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE); TCHAR *status = pcli->pfnGetStatusModeDescription(dwStatus, 0); - GetWindowText(hwndDlg, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, status, contactName); + GetWindowText(hwndDlg, format, _countof(format)); + mir_sntprintf(str, _countof(str), format, status, contactName); SetWindowText(hwndDlg, str); - GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, status); + GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, _countof(format)); + mir_sntprintf(str, _countof(str), format, status); SetDlgItemText(hwndDlg, IDC_RETRIEVING, str); Window_SetProtoIcon_IcoLib(hwndDlg, szProto, dwStatus); @@ -143,7 +143,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) int chatRoom = db_get_b(hContact, szProto, "ChatRoom", 0); if (!chatRoom) { int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); - mir_sntprintf(str, SIZEOF(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(status, 0)); + mir_sntprintf(str, _countof(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(status, 0)); mi.ptszName = str; if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV) { if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(status)) { diff --git a/src/core/stdaway/src/sendmsg.cpp b/src/core/stdaway/src/sendmsg.cpp index 68db851844..dc36c8d8cc 100644 --- a/src/core/stdaway/src/sendmsg.cpp +++ b/src/core/stdaway/src/sendmsg.cpp @@ -113,12 +113,12 @@ static TCHAR* GetAwayMessage(int statusMode, char *szProto) if (mm < 0) mm += 60 * 24; t.wMinute = mm % 60; t.wHour = mm / 60; - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, SIZEOF(substituteStr)); + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, _countof(substituteStr)); } - else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, SIZEOF(substituteStr)); + else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, _countof(substituteStr)); } else if ( !_tcsnicmp(dbv.ptszVal + i, _T("%date%"), 6)) - GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, SIZEOF(substituteStr)); + GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, _countof(substituteStr)); else continue; if (mir_tstrlen(substituteStr) > 6) @@ -225,11 +225,11 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc); { TCHAR str[256], format[128]; - GetWindowText(hwndDlg, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, pcli->pfnGetStatusModeDescription(dat->statusMode, 0)); + GetWindowText(hwndDlg, format, _countof(format)); + mir_sntprintf(str, _countof(str), format, pcli->pfnGetStatusModeDescription(dat->statusMode, 0)); SetWindowText(hwndDlg, str); } - GetDlgItemText(hwndDlg, IDOK, dat->okButtonFormat, SIZEOF(dat->okButtonFormat)); + GetDlgItemText(hwndDlg, IDOK, dat->okButtonFormat, _countof(dat->okButtonFormat)); { TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto); SetDlgItemText(hwndDlg, IDC_MSG, msg); @@ -247,7 +247,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case WM_TIMER: if (--dat->countdown >= 0) { TCHAR str[64]; - mir_sntprintf(str, SIZEOF(str), dat->okButtonFormat, dat->countdown); + mir_sntprintf(str, _countof(str), dat->okButtonFormat, dat->countdown); SetDlgItemText(hwndDlg, IDOK, str); } else { @@ -270,7 +270,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case IDOK: if (dat->countdown < 0) { TCHAR str[1024]; - GetDlgItemText(hwndDlg, IDC_MSG, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_MSG, str, _countof(str)); ChangeAllProtoMessages(dat->szProto, dat->statusMode, str); db_set_ts(NULL, "SRAway", StatusModeToDbSetting(dat->statusMode, "Msg"), str); DestroyWindow(hwndDlg); @@ -360,7 +360,7 @@ struct AwayMsgInfo struct AwayMsgDlgData { - struct AwayMsgInfo info[SIZEOF(statusModes)]; + struct AwayMsgInfo info[_countof(statusModes)]; int oldPage; }; @@ -376,7 +376,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->oldPage = -1; - for (int i = 0; i < SIZEOF(statusModes); i++) { + for (int i = 0; i < _countof(statusModes); i++) { if (!(protoModeMsgFlags & Proto_Status2Flag(statusModes[i]))) continue; @@ -454,7 +454,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam dat->info[dat->oldPage].ignore = IsDlgButtonChecked(hwndDlg, IDC_DONTREPLY); dat->info[dat->oldPage].noDialog = IsDlgButtonChecked(hwndDlg, IDC_NODIALOG); dat->info[dat->oldPage].usePrevious = IsDlgButtonChecked(hwndDlg, IDC_USEPREVIOUS); - GetDlgItemText(hwndDlg, IDC_MSG, dat->info[dat->oldPage].msg, SIZEOF(dat->info[dat->oldPage].msg)); + GetDlgItemText(hwndDlg, IDC_MSG, dat->info[dat->oldPage].msg, _countof(dat->info[dat->oldPage].msg)); } CheckDlgButton(hwndDlg, IDC_DONTREPLY, (i < 0 ? 0 : dat->info[i].ignore) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_NODIALOG, (i < 0 ? 0 : dat->info[i].noDialog) ? BST_CHECKED : BST_UNCHECKED); diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp index 0528908ae0..f849446347 100644 --- a/src/core/stdchat/src/main.cpp +++ b/src/core/stdchat/src/main.cpp @@ -287,30 +287,30 @@ static void RegisterFonts() { ColourIDT colourid = { sizeof(colourid) }; strncpy(colourid.dbSettingsGroup, CHAT_MODULE, sizeof(colourid.dbSettingsGroup)); - _tcsncpy(colourid.group, LPGENT("Chat module"), SIZEOF(colourid.group)); + _tcsncpy(colourid.group, LPGENT("Chat module"), _countof(colourid.group)); - strncpy(colourid.setting, "ColorLogBG", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Group chat log background"), SIZEOF(colourid.name)); + strncpy(colourid.setting, "ColorLogBG", _countof(colourid.setting)); + _tcsncpy(colourid.name, LPGENT("Group chat log background"), _countof(colourid.name)); colourid.defcolour = GetSysColor(COLOR_WINDOW); ColourRegisterT(&colourid); - strncpy(colourid.setting, "ColorMessageBG", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Message background"), SIZEOF(colourid.name)); + strncpy(colourid.setting, "ColorMessageBG", _countof(colourid.setting)); + _tcsncpy(colourid.name, LPGENT("Message background"), _countof(colourid.name)); colourid.defcolour = GetSysColor(COLOR_WINDOW); ColourRegisterT(&colourid); - strncpy(colourid.setting, "ColorNicklistBG", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Nick list background"), SIZEOF(colourid.name)); + strncpy(colourid.setting, "ColorNicklistBG", _countof(colourid.setting)); + _tcsncpy(colourid.name, LPGENT("Nick list background"), _countof(colourid.name)); colourid.defcolour = GetSysColor(COLOR_WINDOW); ColourRegisterT(&colourid); - strncpy(colourid.setting, "ColorNicklistLines", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Nick list lines"), SIZEOF(colourid.name)); + strncpy(colourid.setting, "ColorNicklistLines", _countof(colourid.setting)); + _tcsncpy(colourid.name, LPGENT("Nick list lines"), _countof(colourid.name)); colourid.defcolour = GetSysColor(COLOR_INACTIVEBORDER); ColourRegisterT(&colourid); - strncpy(colourid.setting, "ColorNicklistSelectedBG", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Nick list background (selected)"), SIZEOF(colourid.name)); + strncpy(colourid.setting, "ColorNicklistSelectedBG", _countof(colourid.setting)); + _tcsncpy(colourid.name, LPGENT("Nick list background (selected)"), _countof(colourid.name)); colourid.defcolour = GetSysColor(COLOR_HIGHLIGHT); ColourRegisterT(&colourid); } @@ -471,8 +471,8 @@ STDMETHODIMP CREOleCallback::GetNewStorage(LPSTORAGE * lplpstg) { WCHAR szwName[64]; char szName[64]; - mir_snprintf(szName, SIZEOF(szName), "s%u", nextStgId++); - MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, SIZEOF(szwName)); + mir_snprintf(szName, _countof(szName), "s%u", nextStgId++); + MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, _countof(szwName)); if (pictStg == NULL) return STG_E_MEDIUMFULL; return pictStg->CreateStorage(szwName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg); diff --git a/src/core/stdchat/src/options.cpp b/src/core/stdchat/src/options.cpp index eccfa9ac3f..e75482a151 100644 --- a/src/core/stdchat/src/options.cpp +++ b/src/core/stdchat/src/options.cpp @@ -128,13 +128,13 @@ static const struct branch_t branch6[] = { { LPGENT("Show popup for status changes"), "PopupFlags", GC_EVENT_ADDSTATUS, 0 }, }; -HTREEITEM hItemB0[SIZEOF(branch0)]; -HTREEITEM hItemB1[SIZEOF(branch1)]; -HTREEITEM hItemB2[SIZEOF(branch2)]; -HTREEITEM hItemB3[SIZEOF(branch3)]; -HTREEITEM hItemB4[SIZEOF(branch4)]; -HTREEITEM hItemB5[SIZEOF(branch5)]; -HTREEITEM hItemB6[SIZEOF(branch6)]; +HTREEITEM hItemB0[_countof(branch0)]; +HTREEITEM hItemB1[_countof(branch1)]; +HTREEITEM hItemB2[_countof(branch2)]; +HTREEITEM hItemB3[_countof(branch3)]; +HTREEITEM hItemB4[_countof(branch4)]; +HTREEITEM hItemB5[_countof(branch5)]; +HTREEITEM hItemB6[_countof(branch6)]; static HTREEITEM InsertBranch(HWND hwndTree, char* pszDescr, BOOL bExpanded) { @@ -344,13 +344,13 @@ static INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, hListHeading5 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), LPGEN("Icons to display in the tray"), db_get_b(NULL, CHAT_MODULE, "Branch5Exp", 0) ? TRUE : FALSE); if (PopupInstalled) hListHeading6 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), LPGEN("Popups to display"), db_get_b(NULL, CHAT_MODULE, "Branch6Exp", 0) ? TRUE : FALSE); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading0, branch0, hItemB0, SIZEOF(branch0), 0); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, branch1, hItemB1, SIZEOF(branch1), 0); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, branch2, hItemB2, SIZEOF(branch2), 0); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading3, branch3, hItemB3, SIZEOF(branch3), 0x03E0); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading4, branch4, hItemB4, SIZEOF(branch4), 0x0000); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading5, branch5, hItemB5, SIZEOF(branch5), 0x1000); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading6, branch6, hItemB6, SIZEOF(branch6), 0x0000); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading0, branch0, hItemB0, _countof(branch0), 0); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, branch1, hItemB1, _countof(branch1), 0); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, branch2, hItemB2, _countof(branch2), 0); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading3, branch3, hItemB3, _countof(branch3), 0x03E0); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading4, branch4, hItemB4, _countof(branch4), 0x0000); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading5, branch5, hItemB5, _countof(branch5), 0x1000); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading6, branch6, hItemB6, _countof(branch6), 0x0000); SendMessage(hwndDlg, OPT_FIXHEADINGS, 0, 0); break; @@ -413,14 +413,14 @@ static INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: BYTE b = db_get_b(NULL, CHAT_MODULE, "Tabs", 1); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch0, hItemB0, SIZEOF(branch0)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, hItemB1, SIZEOF(branch1)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, hItemB2, SIZEOF(branch2)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch3, hItemB3, SIZEOF(branch3)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch4, hItemB4, SIZEOF(branch4)); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch5, hItemB5, SIZEOF(branch5)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch0, hItemB0, _countof(branch0)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, hItemB1, _countof(branch1)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, hItemB2, _countof(branch2)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch3, hItemB3, _countof(branch3)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch4, hItemB4, _countof(branch4)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch5, hItemB5, _countof(branch5)); if (PopupInstalled) - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch6, hItemB6, SIZEOF(branch6)); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch6, hItemB6, _countof(branch6)); g_Settings.dwIconFlags = db_get_dw(NULL, CHAT_MODULE, "IconFlags", 0x0000); g_Settings.dwTrayIconFlags = db_get_dw(NULL, CHAT_MODULE, "TrayIconFlags", 0x1000); g_Settings.dwPopupFlags = db_get_dw(NULL, CHAT_MODULE, "PopupFlags", 0x0000); diff --git a/src/core/stdchat/src/tools.cpp b/src/core/stdchat/src/tools.cpp index 3537b61689..33f2988432 100644 --- a/src/core/stdchat/src/tools.cpp +++ b/src/core/stdchat/src/tools.cpp @@ -53,7 +53,7 @@ bool LoadMessageFont(LOGFONT *lf, COLORREF *colour) if (db_get_ts(NULL, "SRMM", str, &dbv)) mir_tstrcpy(lf->lfFaceName, _T("Arial")); else { - mir_tstrncpy(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName)); + mir_tstrncpy(lf->lfFaceName, dbv.ptszVal, _countof(lf->lfFaceName)); db_free(&dbv); } mir_snprintf(str, "SRMFont%dSet", i); @@ -135,7 +135,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO if (pszWordText && pszWordText[0]) { TCHAR szMenuText[4096]; - mir_sntprintf(szMenuText, SIZEOF(szMenuText), TranslateT("Look up '%s':"), pszWordText); + mir_sntprintf(szMenuText, _countof(szMenuText), TranslateT("Look up '%s':"), pszWordText); ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText); } else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up")); @@ -146,7 +146,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO if (pszWordText) mir_sntprintf(szTemp, TranslateT("&Message %s"), pszWordText); else - mir_tstrncpy(szTemp, TranslateT("&Message"), SIZEOF(szTemp) - 1); + mir_tstrncpy(szTemp, TranslateT("&Message"), _countof(szTemp) - 1); if (mir_tstrlen(szTemp) > 40) mir_tstrcpy(szTemp + 40, _T("...")); diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index 3e8edd8030..8bc99cbc52 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -997,7 +997,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *si } if (tszBuf[0] == 0) - mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"), + mir_sntprintf(tszBuf, _countof(tszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"), TranslateT("Nickname"), ui->pszNick, TranslateT("Unique ID"), ui->pszUID, TranslateT("Status"), pci->TM_WordToString(si->pStatuses, ui->Status)); @@ -1149,13 +1149,13 @@ static int RestoreWindowPosition(HWND hwnd, MCONTACT hContact, char * szModule, GetWindowPlacement(hwnd, &wp); char szSettingName[64]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%sx", szNamePrefix); int x = db_get_dw(hContact, szModule, szSettingName, -1); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%sy", szNamePrefix); int y = (int)db_get_dw(hContact, szModule, szSettingName, -1); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%swidth", szNamePrefix); int width = db_get_dw(hContact, szModule, szSettingName, -1); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%sheight", szNamePrefix); int height = db_get_dw(hContact, szModule, szSettingName, -1); if (x == -1) @@ -2230,7 +2230,7 @@ LABEL_SHOWWINDOW: case ID_SEARCH_WIKIPEDIA: if (pszWord[0]) { TCHAR szURL[1024]; - mir_sntprintf(szURL, SIZEOF(szURL), _T("http://en.wikipedia.org/wiki/%s"), pszWord); + mir_sntprintf(szURL, _countof(szURL), _T("http://en.wikipedia.org/wiki/%s"), pszWord); CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)szURL); } PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0); @@ -2316,7 +2316,7 @@ LABEL_SHOWWINDOW: USERINFO *ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item); if (ui != NULL) { static TCHAR ptszBuf[1024]; - mir_sntprintf(ptszBuf, SIZEOF(ptszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"), + mir_sntprintf(ptszBuf, _countof(ptszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"), TranslateT("Nickname"), ui->pszNick, TranslateT("Unique ID"), ui->pszUID, TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui->Status)); @@ -2435,11 +2435,11 @@ LABEL_SHOWWINDOW: _tcsncpy_s(szName, (pInfo->ptszModDispName ? pInfo->ptszModDispName : _A2T(si->pszModule)), _TRUNCATE); ValidateFilename(szName); - mir_sntprintf(szFolder, SIZEOF(szFolder), _T("%s\\%s"), g_Settings.pszLogDir, szName); + mir_sntprintf(szFolder, _countof(szFolder), _T("%s\\%s"), g_Settings.pszLogDir, szName); mir_sntprintf(szName, _T("%s.log"), si->ptszID); ValidateFilename(szName); - mir_sntprintf(szFile, SIZEOF(szFile), _T("%s\\%s"), szFolder, szName); + mir_sntprintf(szFile, _countof(szFile), _T("%s\\%s"), szFolder, szName); ShellExecute(hwndDlg, _T("open"), szFile, NULL, NULL, SW_SHOW); } } diff --git a/src/core/stdclist/src/clcfonts.cpp b/src/core/stdclist/src/clcfonts.cpp index 873fb00d56..560a3a6363 100644 --- a/src/core/stdclist/src/clcfonts.cpp +++ b/src/core/stdclist/src/clcfonts.cpp @@ -54,10 +54,10 @@ void RegisterCListFonts() FontIDT fontid = { sizeof(fontid) }; fontid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWREREGISTER | FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS; strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup)); - _tcsncpy(fontid.group, LPGENT("Contact list"), SIZEOF(fontid.group)); + _tcsncpy(fontid.group, LPGENT("Contact list"), _countof(fontid.group)); HDC hdc = GetDC(NULL); - for (int i = 0; i < SIZEOF(clistFontDescr); i++) { + for (int i = 0; i < _countof(clistFontDescr); i++) { LOGFONT lf; pcli->pfnGetFontSetting(i, &lf, &fontid.deffontsettings.colour); lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72); @@ -70,11 +70,11 @@ void RegisterCListFonts() fontid.flags &= ~FIDF_CLASSMASK; fontid.flags |= clistFontDescr[i].iMask; - _tcsncpy(fontid.name, clistFontDescr[i].tszName, SIZEOF(fontid.name)); + _tcsncpy(fontid.name, clistFontDescr[i].tszName, _countof(fontid.name)); char idstr[10]; mir_snprintf(idstr, "Font%d", i); - strncpy(fontid.prefix, idstr, SIZEOF(fontid.prefix)); + strncpy(fontid.prefix, idstr, _countof(fontid.prefix)); fontid.order = i; FontRegisterT(&fontid); } @@ -87,25 +87,25 @@ void RegisterCListFonts() strncpy(colourid.dbSettingsGroup, "CLC", sizeof(colourid.dbSettingsGroup)); strncpy(colourid.setting, "BkColour", sizeof(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Background"), SIZEOF(colourid.name)); - _tcsncpy(colourid.group, LPGENT("Contact list"), SIZEOF(colourid.group)); + _tcsncpy(colourid.name, LPGENT("Background"), _countof(colourid.name)); + _tcsncpy(colourid.group, LPGENT("Contact list"), _countof(colourid.group)); colourid.defcolour = CLCDEFAULT_BKCOLOUR; ColourRegisterT(&colourid); strncpy(colourid.setting, "SelTextColour", sizeof(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Selected text"), SIZEOF(colourid.name)); + _tcsncpy(colourid.name, LPGENT("Selected text"), _countof(colourid.name)); colourid.order = 1; colourid.defcolour = CLCDEFAULT_SELTEXTCOLOUR; ColourRegisterT(&colourid); strncpy(colourid.setting, "HotTextColour", sizeof(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Hottrack text"), SIZEOF(colourid.name)); + _tcsncpy(colourid.name, LPGENT("Hottrack text"), _countof(colourid.name)); colourid.order = 1; colourid.defcolour = CLCDEFAULT_HOTTEXTCOLOUR; ColourRegisterT(&colourid); strncpy(colourid.setting, "QuickSearchColour", sizeof(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Quicksearch text"), SIZEOF(colourid.name)); + _tcsncpy(colourid.name, LPGENT("Quicksearch text"), _countof(colourid.name)); colourid.order = 1; colourid.defcolour = CLCDEFAULT_QUICKSEARCHCOLOUR; ColourRegisterT(&colourid); diff --git a/src/core/stdclist/src/clcopts.cpp b/src/core/stdclist/src/clcopts.cpp index 3312357c5b..f54350b67c 100644 --- a/src/core/stdclist/src/clcopts.cpp +++ b/src/core/stdclist/src/clcopts.cpp @@ -150,7 +150,7 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam { int i; DWORD exStyle = db_get_dw(NULL, "CLC", "ExStyle", pcli->pfnGetDefaultExStyle()); - for (i = 0; i < SIZEOF(checkBoxToStyleEx); i++) + for (i = 0; i < _countof(checkBoxToStyleEx); i++) CheckDlgButton(hwndDlg, checkBoxToStyleEx[i].id, (exStyle & checkBoxToStyleEx[i].flag) ^ (checkBoxToStyleEx[i].flag * checkBoxToStyleEx[i].not) ? BST_CHECKED : BST_UNCHECKED); @@ -158,7 +158,7 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam { UDACCEL accel[2] = { {0, 10} , {2, 50} }; SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETRANGE, 0, MAKELONG(999, 0)); - SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETACCEL, SIZEOF(accel), (LPARAM) & accel); + SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETACCEL, _countof(accel), (LPARAM) & accel); SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME), 0)); } @@ -173,9 +173,9 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam db_get_dw(NULL, "CLC", "GreyoutFlags", CLCDEFAULT_GREYOUTFLAGS) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_SMOOTHTIME), IsDlgButtonChecked(hwndDlg, IDC_NOTNOSMOOTHSCROLLING)); EnableWindow(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), IsDlgButtonChecked(hwndDlg, IDC_GREYOUT)); - FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), greyoutValues, SIZEOF(greyoutValues), + FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), greyoutValues, _countof(greyoutValues), db_get_dw(NULL, "CLC", "FullGreyoutFlags", CLCDEFAULT_FULLGREYOUTFLAGS)); - FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), offlineValues, SIZEOF(offlineValues), + FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), offlineValues, _countof(offlineValues), db_get_dw(NULL, "CLC", "OfflineModes", CLCDEFAULT_OFFLINEMODES)); CheckDlgButton(hwndDlg, IDC_NOSCROLLBAR, db_get_b(NULL, "CLC", "NoVScrollBar", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_GAMMACORRECT, db_get_b(NULL, "CLC", "GammaCorrect", CLCDEFAULT_GAMMACORRECT) ? BST_CHECKED : BST_UNCHECKED); @@ -239,7 +239,7 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam if (((LPNMHDR) lParam)->code == PSN_APPLY ) { int i; DWORD exStyle = 0; - for (i = 0; i < SIZEOF(checkBoxToStyleEx); i++) + for (i = 0; i < _countof(checkBoxToStyleEx); i++) if ((IsDlgButtonChecked(hwndDlg, checkBoxToStyleEx[i].id) == 0) == checkBoxToStyleEx[i].not) exStyle |= checkBoxToStyleEx[i].flag; @@ -335,17 +335,17 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_COMMAND: if (LOWORD(wParam) == IDC_BROWSE) { TCHAR str[MAX_PATH], filter[512]; - GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_FILENAME, str, _countof(str)); OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.hInstance = NULL; - Bitmap_GetFilter(filter, SIZEOF(filter)); + Bitmap_GetFilter(filter, _countof(filter)); ofn.lpstrFilter = filter; ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - ofn.nMaxFile = SIZEOF(str); + ofn.nMaxFile = _countof(str); ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrDefExt = _T("bmp"); if (!GetOpenFileName(&ofn)) @@ -384,7 +384,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } { char str[MAX_PATH], strrel[MAX_PATH]; - GetDlgItemTextA(hwndDlg, IDC_FILENAME, str, SIZEOF(str)); + GetDlgItemTextA(hwndDlg, IDC_FILENAME, str, _countof(str)); if ( PathToRelative(str, strrel)) db_set_s(NULL, "CLC", "BkBitmap", strrel); else diff --git a/src/core/stdclist/src/clcpaint.cpp b/src/core/stdclist/src/clcpaint.cpp index 36e5918a35..c81daf2932 100644 --- a/src/core/stdclist/src/clcpaint.cpp +++ b/src/core/stdclist/src/clcpaint.cpp @@ -513,7 +513,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) pts[6].y = pts[5].y; pts[7].x = pts[0].x; pts[7].y = pts[4].y; - HRGN hRgn = CreatePolygonRgn(pts, SIZEOF(pts), ALTERNATE); + HRGN hRgn = CreatePolygonRgn(pts, _countof(pts), ALTERNATE); HBRUSH hBrush = CreateSolidBrush(dat->fontInfo[FONTID_CONTACTS].colour); FillRgn(hdcMem, hRgn, hBrush); DeleteObject(hBrush); @@ -543,7 +543,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) int greyGreen = GetGValue(greyColour) * 2; int greyBlue = GetBValue(greyColour) * 2; if (divide3[0] == 255) { - for (i = 0; i < SIZEOF(divide3); i++) + for (i = 0; i < _countof(divide3); i++) divide3[i] = (i + 1) / 3; } for (int i = 4 * clRect.right * clRect.bottom - 4; i >= 0; i -= 4) { diff --git a/src/core/stdclist/src/cluiopts.cpp b/src/core/stdclist/src/cluiopts.cpp index af5fe02bee..76dacac9c2 100644 --- a/src/core/stdclist/src/cluiopts.cpp +++ b/src/core/stdclist/src/cluiopts.cpp @@ -172,7 +172,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L db_set_b(NULL, "CList", "Min2Tray", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_MIN2TRAY)); { TCHAR title[256]; - GetDlgItemText(hwndDlg, IDC_TITLETEXT, title, SIZEOF(title)); + GetDlgItemText(hwndDlg, IDC_TITLETEXT, title, _countof(title)); db_set_ts(NULL, "CList", "TitleText", title); SetWindowText(pcli->hwndContactList, title); } diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index d6a28d2072..6be3bf587b 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -123,7 +123,7 @@ void PushFileEvent(MCONTACT hContact, MEVENT hdbe, LPARAM lParam) SkinPlaySound("RecvFile"); TCHAR szTooltip[256]; - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("File from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("File from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); cle.ptszTooltip = szTooltip; cle.flags |= CLEF_TCHAR; @@ -356,7 +356,7 @@ INT_PTR FtMgrShowCommand(WPARAM, LPARAM) INT_PTR openContRecDir(WPARAM hContact, LPARAM) { TCHAR szContRecDir[MAX_PATH]; - GetContactReceivedFilesDir(hContact, szContRecDir, SIZEOF(szContRecDir), TRUE); + GetContactReceivedFilesDir(hContact, szContRecDir, _countof(szContRecDir), TRUE); ShellExecute(0, _T("open"), szContRecDir, 0, 0, SW_SHOW); return 0; } @@ -364,7 +364,7 @@ INT_PTR openContRecDir(WPARAM hContact, LPARAM) INT_PTR openRecDir(WPARAM, LPARAM) { TCHAR szContRecDir[MAX_PATH]; - GetReceivedFilesDir(szContRecDir, SIZEOF(szContRecDir)); + GetReceivedFilesDir(szContRecDir, _countof(szContRecDir)); ShellExecute(0, _T("open"), szContRecDir, 0, 0, SW_SHOW); return 0; } diff --git a/src/core/stdfile/src/fileexistsdlg.cpp b/src/core/stdfile/src/fileexistsdlg.cpp index 81b1a220ba..23c888da3f 100644 --- a/src/core/stdfile/src/fileexistsdlg.cpp +++ b/src/core/stdfile/src/fileexistsdlg.cpp @@ -35,9 +35,9 @@ static void SetControlToUnixTime(HWND hwndDlg, UINT idCtrl, time_t unixTime) filetime.dwHighDateTime = liFiletime.HighPart; filetime.dwLowDateTime = liFiletime.LowPart; FileTimeToSystemTime(&filetime, &st); - GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, szTime, SIZEOF(szTime)); - GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, szDate, SIZEOF(szDate)); - mir_snprintf(szOutput, SIZEOF(szOutput), "%s %s", szDate, szTime); + GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, szTime, _countof(szTime)); + GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, szDate, _countof(szDate)); + mir_snprintf(szOutput, _countof(szOutput), "%s %s", szDate, szTime); SetDlgItemTextA(hwndDlg, idCtrl, szOutput); } @@ -149,27 +149,27 @@ void __cdecl LoadIconsAndTypesThread(void* param) TCHAR *pszExtension = _tcsrchr(pszFilename, '.'); if (pszExtension) - mir_tstrncpy(szExtension, pszExtension + 1, SIZEOF(szExtension)); + mir_tstrncpy(szExtension, pszExtension + 1, _countof(szExtension)); else { pszExtension = _T("."); szExtension[0] = '\0'; } CharUpper(szExtension); if (fileInfo.szTypeName[0] == '\0') - mir_sntprintf(fileInfo.szTypeName, SIZEOF(fileInfo.szTypeName), TranslateT("%s file"), szExtension); + mir_sntprintf(fileInfo.szTypeName, _countof(fileInfo.szTypeName), TranslateT("%s file"), szExtension); SetDlgItemText(info->hwndDlg, IDC_EXISTINGTYPE, fileInfo.szTypeName); SetDlgItemText(info->hwndDlg, IDC_NEWTYPE, fileInfo.szTypeName); SendDlgItemMessage(info->hwndDlg, IDC_EXISTINGICON, STM_SETICON, (WPARAM)fileInfo.hIcon, 0); szIconFile[0] = '\0'; if (!mir_tstrcmp(szExtension, _T("EXE"))) - SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, SIZEOF(szIconFile)); + SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, _countof(szIconFile)); else { TCHAR szTypeName[MAX_PATH]; - if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, pszExtension, NULL, szTypeName, SIZEOF(szTypeName))) { + if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, pszExtension, NULL, szTypeName, _countof(szTypeName))) { mir_tstrcat(szTypeName, _T("\\DefaultIcon")); - if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, szTypeName, NULL, szIconFile, SIZEOF(szIconFile))) { + if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, szTypeName, NULL, szIconFile, _countof(szIconFile))) { if (_tcsstr(szIconFile, _T("%1"))) - SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("0"), szIconFile, SIZEOF(szIconFile)); + SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("0"), szIconFile, _countof(szIconFile)); else szIconFile[0] = '\0'; } } @@ -213,7 +213,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fts); SetDlgItemText(hwndDlg, IDC_FILENAME, fts->tszCurrentFile); SetControlToUnixTime(hwndDlg, IDC_NEWDATE, fts->currentFileTime); - GetSensiblyFormattedSize(fts->currentFileSize, szSize, SIZEOF(szSize), 0, 1, NULL); + GetSensiblyFormattedSize(fts->currentFileSize, szSize, _countof(szSize), 0, 1, NULL); SetDlgItemText(hwndDlg, IDC_NEWSIZE, szSize); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EXISTINGICON), IconCtrlSubclassProc); @@ -221,7 +221,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM HWND hwndFocus = GetDlgItem(hwndDlg, IDC_RESUME); if (_tstati64(fts->tszCurrentFile, &statbuf) == 0) { SetControlToUnixTime(hwndDlg, IDC_EXISTINGDATE, statbuf.st_mtime); - GetSensiblyFormattedSize(statbuf.st_size, szSize, SIZEOF(szSize), 0, 1, NULL); + GetSensiblyFormattedSize(statbuf.st_size, szSize, _countof(szSize), 0, 1, NULL); SetDlgItemText(hwndDlg, IDC_EXISTINGSIZE, szSize); if (statbuf.st_size > (int)fts->currentFileSize) { EnableWindow(GetDlgItem(hwndDlg, IDC_RESUME), FALSE); @@ -250,7 +250,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case IDC_OPENFOLDER: { TCHAR szFile[MAX_PATH]; - mir_tstrncpy(szFile, fts->tszCurrentFile, SIZEOF(szFile)); + mir_tstrncpy(szFile, fts->tszCurrentFile, _countof(szFile)); TCHAR *pszLastBackslash = _tcsrchr(szFile, '\\'); if (pszLastBackslash) *pszLastBackslash = '\0'; @@ -283,11 +283,11 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR filter[512], *pfilter; TCHAR str[MAX_PATH]; - mir_tstrncpy(str, fts->tszCurrentFile, SIZEOF(str)); + mir_tstrncpy(str, fts->tszCurrentFile, _countof(str)); ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; - _tcsncpy(filter, TranslateT("All files"),SIZEOF(filter)-1); + _tcsncpy(filter, TranslateT("All files"),_countof(filter)-1); mir_tstrcat(filter, _T(" (*)")); pfilter = filter + mir_tstrlen(filter) + 1; mir_tstrcpy(pfilter, _T("*")); @@ -295,7 +295,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM *pfilter = '\0'; ofn.lpstrFilter = filter; ofn.lpstrFile = str; - ofn.nMaxFile = SIZEOF(str); + ofn.nMaxFile = _countof(str); ofn.nMaxFileTitle = MAX_PATH; if (!GetSaveFileName(&ofn)) return FALSE; diff --git a/src/core/stdfile/src/fileopts.cpp b/src/core/stdfile/src/fileopts.cpp index 7b56f2bdb9..11566c05c8 100644 --- a/src/core/stdfile/src/fileopts.cpp +++ b/src/core/stdfile/src/fileopts.cpp @@ -63,7 +63,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILEDIR), SHACF_FILESYS_DIRS); TCHAR str[MAX_PATH]; - GetContactReceivedFilesDir(NULL, str, SIZEOF(str), FALSE); + GetContactReceivedFilesDir(NULL, str, _countof(str), FALSE); SetDlgItemText(hwndDlg, IDC_FILEDIR, str); CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, db_get_b(NULL, "SRFile", "AutoAccept", 0) ? BST_CHECKED : BST_UNCHECKED); @@ -77,9 +77,9 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L } CheckDlgButton(hwndDlg, IDC_WARNBEFOREOPENING, db_get_b(NULL, "SRFile", "WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED); - for (int i = 0; i < SIZEOF(virusScanners); i++) { + for (int i = 0; i < _countof(virusScanners); i++) { TCHAR szScanExe[MAX_PATH]; - if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, SIZEOF(szScanExe))) { + if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, _countof(szScanExe))) { int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i); } @@ -124,10 +124,10 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L TCHAR str[512]; TCHAR szScanExe[MAX_PATH]; int iScanner = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0); - if (iScanner >= SIZEOF(virusScanners) || iScanner < 0) break; + if (iScanner >= _countof(virusScanners) || iScanner < 0) break; str[0] = '\0'; - if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, SIZEOF(szScanExe))) - mir_sntprintf(str, SIZEOF(str), virusScanners[iScanner].szCommandLine, szScanExe); + if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, _countof(szScanExe))) + mir_sntprintf(str, _countof(str), virusScanners[iScanner].szCommandLine, szScanExe); SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); } break; @@ -141,7 +141,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L case IDC_FILEDIRBROWSE: { TCHAR str[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str)); if (BrowseForFolder(hwndDlg, str)) SetDlgItemText(hwndDlg, IDC_FILEDIR, str); } @@ -163,7 +163,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L case IDC_SCANCMDLINEBROWSE: TCHAR str[MAX_PATH + 2]; - GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str)); CMString tszFilter; tszFilter.AppendFormat(_T("%s (*.exe)%c*.exe%c"), TranslateT("Executable files"), 0, 0); @@ -175,7 +175,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; ofn.lpstrFilter = tszFilter; ofn.lpstrFile = str; - ofn.nMaxFile = SIZEOF(str) - 2; + ofn.nMaxFile = _countof(str) - 2; if (str[0] == '"') { TCHAR *pszQuote = _tcschr(str + 1, '"'); if (pszQuote) @@ -189,7 +189,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L ofn.nMaxFileTitle = MAX_PATH; if (!GetOpenFileName(&ofn)) break; if (_tcschr(str, ' ') != NULL) { - memmove(str + 1, str, ((SIZEOF(str) - 2) * sizeof(TCHAR))); + memmove(str + 1, str, ((_countof(str) - 2) * sizeof(TCHAR))); str[0] = '"'; mir_tstrcat(str, _T("\"")); } @@ -203,7 +203,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: TCHAR str[512]; - GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str)); RemoveInvalidPathChars(str); db_set_ts(NULL, "SRFile", "RecvFilesDirAdv", str); db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); @@ -211,7 +211,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L db_set_b(NULL, "SRFile", "AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE)); db_set_b(NULL, "SRFile", "AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR)); db_set_b(NULL, "SRFile", "UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL) ? VIRUSSCAN_AFTERDL : (IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL) ? VIRUSSCAN_DURINGDL : VIRUSSCAN_DISABLE))); - GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str)); db_set_ts(NULL, "SRFile", "ScanCmdLine", str); db_set_b(NULL, "SRFile", "WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING)); db_set_b(NULL, "SRFile", "IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK) ? FILERESUME_ASK : (IsDlgButtonChecked(hwndDlg, IDC_RESUME) ? FILERESUME_RESUMEALL : (IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE) ? FILERESUME_OVERWRITEALL : FILERESUME_RENAMEALL)))); diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index 16edf1c4a0..0b7cd4325b 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -134,7 +134,7 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO if (tszRecvPath) _tcsncpy_s(tszTemp, tszRecvPath, _TRUNCATE); else - mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files")); + mir_sntprintf(tszTemp, _countof(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files")); if (hContact) { hContact = db_mc_tryMeta(hContact); @@ -149,7 +149,7 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO rvaVarsToReplace[2].lptzValue = mir_a2t(GetContactProto(hContact)); rvaVarsToReplace[3].lptzKey = NULL; rvaVarsToReplace[3].lptzValue = NULL; - for (int i = 0; i < (SIZEOF(rvaVarsToReplace) - 1); i++) + for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++) RemoveInvalidFilenameChars(rvaVarsToReplace[i].lptzValue); dat.cbSize = sizeof(dat); @@ -158,15 +158,15 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO dat.hContact = hContact; TCHAR *result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)tszTemp, (LPARAM)&dat); if (result) { - _tcsncpy(tszTemp, result, SIZEOF(tszTemp)); + _tcsncpy(tszTemp, result, _countof(tszTemp)); mir_free(result); - for (int i = 0; i < (SIZEOF(rvaVarsToReplace) - 1); i++) + for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++) mir_free(rvaVarsToReplace[i].lptzValue); } } if (patchVars) - patchDir(tszTemp, SIZEOF(tszTemp)); + patchDir(tszTemp, _countof(tszTemp)); RemoveInvalidPathChars(tszTemp); mir_tstrncpy(szDir, tszTemp, cchDir); } @@ -179,9 +179,9 @@ void GetReceivedFilesDir(TCHAR *szDir, int cchDir) if (tszRecvPath) _tcsncpy_s(tszTemp, tszRecvPath, _TRUNCATE); else - mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files")); + mir_sntprintf(tszTemp, _countof(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files")); - patchDir(tszTemp, SIZEOF(tszTemp)); + patchDir(tszTemp, _countof(tszTemp)); RemoveInvalidPathChars(tszTemp); mir_tstrncpy(szDir, tszTemp, cchDir); } @@ -215,7 +215,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_FROM, contactName); - GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE); + GetContactReceivedFilesDir(dat->hContact, szPath, _countof(szPath), TRUE); SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath); SHAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1); @@ -254,7 +254,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l else DestroyWindow(hwndDlg); TCHAR datetimestr[64]; - TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, SIZEOF(datetimestr), 0); + TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, _countof(datetimestr), 0); SetDlgItemText(hwndDlg, IDC_DATE, datetimestr); char* szProto = GetContactProto(dat->hContact); @@ -330,8 +330,8 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l { TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, SIZEOF(szDirName)); - GetLowestExistingDirName(szDirName, szExistingDirName, SIZEOF(szExistingDirName)); + GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, _countof(szDirName)); + GetLowestExistingDirName(szDirName, szExistingDirName, _countof(szExistingDirName)); if (BrowseForFolder(hwndDlg, szExistingDirName)) SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName); } @@ -340,9 +340,9 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDOK: { //most recently used directories TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, SIZEOF(szRecvDir)); + GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, _countof(szRecvDir)); RemoveInvalidPathChars(szRecvDir); - GetContactReceivedFilesDir(NULL, szDefaultRecvDir, SIZEOF(szDefaultRecvDir), TRUE); + GetContactReceivedFilesDir(NULL, szDefaultRecvDir, _countof(szDefaultRecvDir), TRUE); if (_tcsnicmp(szRecvDir, szDefaultRecvDir, mir_tstrlen(szDefaultRecvDir))) { char idstr[32]; int i; @@ -362,9 +362,9 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE); - GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath)); - GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames)); - GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg)); + GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, _countof(dat->szSavePath)); + GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, _countof(dat->szFilenames)); + GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, _countof(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); //check for auto-minimize here to fix BUG#647620 diff --git a/src/core/stdfile/src/filesenddlg.cpp b/src/core/stdfile/src/filesenddlg.cpp index 5516373588..aa9cbee487 100644 --- a/src/core/stdfile/src/filesenddlg.cpp +++ b/src/core/stdfile/src/filesenddlg.cpp @@ -44,21 +44,21 @@ static void SetFileListAndSizeControls(HWND hwndDlg, FileDlgData *dat) } } - GetSensiblyFormattedSize(totalSize, str, SIZEOF(str), 0, 1, NULL); + GetSensiblyFormattedSize(totalSize, str, _countof(str), 0, 1, NULL); SetDlgItemText(hwndDlg, IDC_TOTALSIZE, str); if (i > 1) { TCHAR szFormat[32]; if (fileCount && dirCount) { - mir_sntprintf(szFormat, SIZEOF(szFormat), _T("%s, %s"), TranslateTS(fileCount == 1 ? _T("%d file") : _T("%d files")), TranslateTS(dirCount == 1 ? _T("%d directory") : _T("%d directories"))); - mir_sntprintf(str, SIZEOF(str), szFormat, fileCount, dirCount); + mir_sntprintf(szFormat, _countof(szFormat), _T("%s, %s"), TranslateTS(fileCount == 1 ? _T("%d file") : _T("%d files")), TranslateTS(dirCount == 1 ? _T("%d directory") : _T("%d directories"))); + mir_sntprintf(str, _countof(str), szFormat, fileCount, dirCount); } else if (fileCount) { mir_tstrcpy(szFormat, TranslateT("%d files")); - mir_sntprintf(str, SIZEOF(str), szFormat, fileCount); + mir_sntprintf(str, _countof(str), szFormat, fileCount); } else { mir_tstrcpy(szFormat, TranslateT("%d directories")); - mir_sntprintf(str, SIZEOF(str), szFormat, dirCount); + mir_sntprintf(str, _countof(str), szFormat, dirCount); } SetDlgItemText(hwndDlg, IDC_FILE, str); } @@ -323,9 +323,9 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSE), FALSE); - GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath)); - GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames)); - GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg)); + GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, _countof(dat->szSavePath)); + GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, _countof(dat->szFilenames)); + GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, _countof(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); DestroyWindow(hwndDlg); diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp index ac01125118..3e5976e08a 100644 --- a/src/core/stdfile/src/filexferdlg.cpp +++ b/src/core/stdfile/src/filexferdlg.cpp @@ -105,7 +105,7 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) if (info->szFile[mir_tstrlen(info->szFile) - 1] == '\\') info->szFile[mir_tstrlen(info->szFile) - 1] = '\0'; *pszReplace = 0; - mir_sntprintf(szCmdLine, SIZEOF(szCmdLine), _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace + 2); + mir_sntprintf(szCmdLine, _countof(szCmdLine), _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace + 2); } else _tcsncpy_s(szCmdLine, dbv.ptszVal, _TRUNCATE); @@ -139,7 +139,7 @@ static void SetFilenameControls(HWND hwndDlg, FileDlgData *dat, PROTOFILETRANSFE if (dat->hIcon) DestroyIcon(dat->hIcon); dat->hIcon = NULL; if (fn && (fts->totalFiles > 1)) { - mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s (%d %s %d)"), + mir_sntprintf(msg, _countof(msg), _T("%s: %s (%d %s %d)"), pcli->pfnGetContactDisplayName(fts->hContact, 0), fn, fts->currentFileNumber + 1, TranslateT("of"), fts->totalFiles); @@ -147,13 +147,13 @@ static void SetFilenameControls(HWND hwndDlg, FileDlgData *dat, PROTOFILETRANSFE dat->hIcon = shfi.hIcon; } else if (fn) { - mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s"), pcli->pfnGetContactDisplayName(fts->hContact, 0), fn); + mir_sntprintf(msg, _countof(msg), _T("%s: %s"), pcli->pfnGetContactDisplayName(fts->hContact, 0), fn); SHGetFileInfo(fn, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(shfi), SHGFI_USEFILEATTRIBUTES | SHGFI_ICON | SHGFI_SMALLICON); dat->hIcon = shfi.hIcon; } else { - mir_tstrncpy(msg, pcli->pfnGetContactDisplayName(fts->hContact, 0), SIZEOF(msg)); + mir_tstrncpy(msg, pcli->pfnGetContactDisplayName(fts->hContact, 0), _countof(msg)); HICON hIcon = Skin_LoadIcon(SKINICON_OTHER_DOWNARROW); dat->hIcon = CopyIcon(hIcon); IcoLib_ReleaseIcon(hIcon, NULL); @@ -297,7 +297,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_TIMER: memmove(dat->bytesRecvedHistory + 1, dat->bytesRecvedHistory, sizeof(dat->bytesRecvedHistory) - sizeof(dat->bytesRecvedHistory[0])); dat->bytesRecvedHistory[0] = dat->transferStatus.totalProgress; - if (dat->bytesRecvedHistorySize < SIZEOF(dat->bytesRecvedHistory)) + if (dat->bytesRecvedHistorySize < _countof(dat->bytesRecvedHistory)) dat->bytesRecvedHistorySize++; { @@ -306,23 +306,23 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ULARGE_INTEGER li; FILETIME ft; - GetSensiblyFormattedSize((dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) / dat->bytesRecvedHistorySize, szSpeed, SIZEOF(szSpeed), 0, 1, NULL); + GetSensiblyFormattedSize((dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) / dat->bytesRecvedHistorySize, szSpeed, _countof(szSpeed), 0, 1, NULL); if (dat->bytesRecvedHistory[0] == dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) mir_tstrcpy(szTime, _T("??:??:??")); else { li.QuadPart = BIGI(10000000)*(dat->transferStatus.currentFileSize - dat->transferStatus.currentFileProgress)*dat->bytesRecvedHistorySize / (dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]); ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart; FileTimeToSystemTime(&ft, &st); - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime)); + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, _countof(szTime)); } if (dat->bytesRecvedHistory[0] != dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) { li.QuadPart = BIGI(10000000)*(dat->transferStatus.totalBytes - dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize / (dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]); ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart; FileTimeToSystemTime(&ft, &st); - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime)); + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, _countof(szTime)); } - mir_sntprintf(szDisplay, SIZEOF(szDisplay), _T("%s/%s (%s %s)"), szSpeed, TranslateT("sec"), szTime, TranslateT("remaining")); + mir_sntprintf(szDisplay, _countof(szDisplay), _T("%s/%s (%s %s)"), szSpeed, TranslateT("sec"), szTime, TranslateT("remaining")); SetDlgItemText(hwndDlg, IDC_ALLSPEED, szDisplay); } break; @@ -596,16 +596,16 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR const unsigned long nextPos = fts->totalBytes ? (BIGI(100) * fts->totalProgress / fts->totalBytes) : 0; if (lastPos != nextPos || firstTime) { SendDlgItemMessage(hwndDlg, IDC_ALLFILESPROGRESS, PBM_SETPOS, nextPos, 0); - mir_sntprintf(str, SIZEOF(str), _T("%u%%"), nextPos); + mir_sntprintf(str, _countof(str), _T("%u%%"), nextPos); SetDlgItemText(hwndDlg, IDC_ALLPRECENTS, str); } int units; - GetSensiblyFormattedSize(fts->totalBytes, szSizeTotal, SIZEOF(szSizeTotal), 0, 1, &units); - GetSensiblyFormattedSize(fts->totalProgress, szSizeDone, SIZEOF(szSizeDone), units, 0, NULL); - mir_sntprintf(str, SIZEOF(str), _T("%s/%s"), szSizeDone, szSizeTotal); + GetSensiblyFormattedSize(fts->totalBytes, szSizeTotal, _countof(szSizeTotal), 0, 1, &units); + GetSensiblyFormattedSize(fts->totalProgress, szSizeDone, _countof(szSizeDone), units, 0, NULL); + mir_sntprintf(str, _countof(str), _T("%s/%s"), szSizeDone, szSizeTotal); str2[0] = 0; - GetDlgItemText(hwndDlg, IDC_ALLTRANSFERRED, str2, SIZEOF(str2)); + GetDlgItemText(hwndDlg, IDC_ALLTRANSFERRED, str2, _countof(str2)); if (mir_tstrcmp(str, str2)) SetDlgItemText(hwndDlg, IDC_ALLTRANSFERRED, str); } diff --git a/src/core/stdhelp/src/about.cpp b/src/core/stdhelp/src/about.cpp index 362fb8f5f3..5b238c167b 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, SIZEOF(filename)); + GetModuleFileName(NULL, filename, _countof(filename)); verInfoSize = GetFileVersionInfoSize(filename, &unused); pVerInfo = mir_alloc(verInfoSize); GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); @@ -48,10 +48,10 @@ INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar } { char productVersion[56]; - CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(productVersion), (LPARAM)productVersion); + CallService(MS_SYSTEM_GETVERSIONTEXT, _countof(productVersion), (LPARAM)productVersion); TCHAR str[64]; - mir_sntprintf(str, SIZEOF(str), STR_VERSION_FORMAT, productVersion); + mir_sntprintf(str, _countof(str), STR_VERSION_FORMAT, productVersion); SetDlgItemText(hwndDlg, IDC_HEADERBAR, str); } ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); diff --git a/src/core/stdidle/src/idle.cpp b/src/core/stdidle/src/idle.cpp index 169d95148c..5a536dabc9 100644 --- a/src/core/stdidle/src/idle.cpp +++ b/src/core/stdidle/src/idle.cpp @@ -236,7 +236,7 @@ void CALLBACK IdleTimer(HWND, UINT, UINT_PTR idEvent, DWORD) int IdleGetStatusIndex(WORD status) { - for (int j = 0; j < SIZEOF(aa_Status); j++) + for (int j = 0; j < _countof(aa_Status); j++) if (aa_Status[j] == status) return j; @@ -267,7 +267,7 @@ static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L SendDlgItemMessage(hwndDlg, IDC_IDLE1STTIME, EM_LIMITTEXT, (WPARAM)2, 0); CheckDlgButton(hwndDlg, IDC_AASHORTIDLE, db_get_b(NULL, IDLEMOD, IDL_AAENABLE, 0) ? BST_CHECKED : BST_UNCHECKED); - for (j = 0; j < SIZEOF(aa_Status); j++) + for (j = 0; j < _countof(aa_Status); j++) SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(aa_Status[j], 0)); j = IdleGetStatusIndex((WORD)(db_get_w(NULL, IDLEMOD, IDL_AASTATUS, 0))); diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp index 62fe7fa5e8..30576920cf 100644 --- a/src/core/stdmsg/src/globals.cpp +++ b/src/core/stdmsg/src/globals.cpp @@ -32,7 +32,7 @@ IconItem iconList[] = static void InitIcons(void) { - Icon_Register(g_hInst, LPGEN("Messaging"), iconList, SIZEOF(iconList), "SRMM"); + Icon_Register(g_hInst, LPGEN("Messaging"), iconList, _countof(iconList), "SRMM"); } static int IconsChanged(WPARAM, LPARAM) diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index c4ca134216..eaa26e309d 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -136,7 +136,7 @@ static void ShowTime(SrmmWindowData *dat) TCHAR buf[32]; unsigned i = (g_dat.flags & SMF_SHOWREADCHAR) ? 2 : 1; - TimeZone_PrintDateTime(dat->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); + TimeZone_PrintDateTime(dat->hTimeZone, _T("t"), buf, _countof(buf), 0); SendMessage(dat->hwndStatus, SB_SETTEXT, i, (LPARAM)buf); dat->wMinute = st.wMinute; } @@ -173,18 +173,18 @@ static void SetDialogToType(HWND hwndDlg) { SrmmWindowData *dat = (SrmmWindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (dat->hContact) - ShowMultipleControls(hwndDlg, infoLineControls, SIZEOF(infoLineControls), (g_dat.flags&SMF_SHOWINFO) ? SW_SHOW : SW_HIDE); + ShowMultipleControls(hwndDlg, infoLineControls, _countof(infoLineControls), (g_dat.flags&SMF_SHOWINFO) ? SW_SHOW : SW_HIDE); else - ShowMultipleControls(hwndDlg, infoLineControls, SIZEOF(infoLineControls), SW_HIDE); + ShowMultipleControls(hwndDlg, infoLineControls, _countof(infoLineControls), SW_HIDE); if (dat->hContact) { - ShowMultipleControls(hwndDlg, buttonLineControls, SIZEOF(buttonLineControls), (g_dat.flags&SMF_SHOWBTNS) ? SW_SHOW : SW_HIDE); + ShowMultipleControls(hwndDlg, buttonLineControls, _countof(buttonLineControls), (g_dat.flags&SMF_SHOWBTNS) ? SW_SHOW : SW_HIDE); if (!db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } - else ShowMultipleControls(hwndDlg, buttonLineControls, SIZEOF(buttonLineControls), SW_HIDE); + else ShowMultipleControls(hwndDlg, buttonLineControls, _countof(buttonLineControls), SW_HIDE); - ShowMultipleControls(hwndDlg, sendControls, SIZEOF(sendControls), SW_SHOW); + ShowMultipleControls(hwndDlg, sendControls, _countof(sendControls), SW_SHOW); if (!dat->hwndStatus) { int grip = (GetWindowLongPtr(hwndDlg, GWL_STYLE) & WS_THICKFRAME) ? SBARS_SIZEGRIP : 0; dat->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | grip, 0, 0, 0, 0, hwndDlg, NULL, g_hInst, NULL); @@ -479,7 +479,7 @@ static int MessageDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * SrmmWindowData *dat = (SrmmWindowData *)lParam; if (!(g_dat.flags & SMF_SHOWINFO) && !(g_dat.flags & SMF_SHOWBTNS)) { - for (int i = 0; i < SIZEOF(buttonLineControls); i++) + for (int i = 0; i < _countof(buttonLineControls); i++) if (buttonLineControls[i] == urc->wId) OffsetRect(&urc->rcItem, 0, -dat->lineHeight); } @@ -491,7 +491,7 @@ static int MessageDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * int len = GetWindowTextLength(h); if (len > 0) { TCHAR buf[256]; - GetWindowText(h, buf, SIZEOF(buf)); + GetWindowText(h, buf, _countof(buf)); HDC hdc = GetDC(h); HFONT hFont = (HFONT)SelectObject(hdc, (HFONT)SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0)); @@ -836,7 +836,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP int fileCount = DragQueryFile(hDrop, -1, NULL, 0), totalCount = 0, i; TCHAR** ppFiles = NULL; for (i = 0; i < fileCount; i++) { - DragQueryFile(hDrop, i, szFilename, SIZEOF(szFilename)); + DragQueryFile(hDrop, i, szFilename, _countof(szFilename)); AddToFileList(&ppFiles, &totalCount, szFilename); } CallServiceSync(MS_FILE_SENDSPECIFICFILEST, (WPARAM)dat->hContact, (LPARAM)ppFiles); @@ -957,9 +957,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (dat->lastMessage) { TCHAR date[64], time[64], fmt[128]; - TimeZone_PrintTimeStamp(NULL, dat->lastMessage, _T("d"), date, SIZEOF(date), 0); - TimeZone_PrintTimeStamp(NULL, dat->lastMessage, _T("t"), time, SIZEOF(time), 0); - mir_sntprintf(fmt, SIZEOF(fmt), TranslateT("Last message received on %s at %s."), date, time); + TimeZone_PrintTimeStamp(NULL, dat->lastMessage, _T("d"), date, _countof(date), 0); + TimeZone_PrintTimeStamp(NULL, dat->lastMessage, _T("t"), time, _countof(time), 0); + mir_sntprintf(fmt, _countof(fmt), TranslateT("Last message received on %s at %s."), date, time); SendMessage(dat->hwndStatus, SB_SETTEXT, 0, (LPARAM)fmt); } else SendMessage(dat->hwndStatus, SB_SETTEXT, 0, (LPARAM)_T("")); @@ -1054,9 +1054,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TCHAR *szStatus = pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE), 0); if (statusIcon) - mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s - %s"), contactName, TranslateT("Message session")); + mir_sntprintf(newtitle, _countof(newtitle), _T("%s - %s"), contactName, TranslateT("Message session")); else - mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s (%s): %s"), contactName, szStatus, TranslateT("Message session")); + mir_sntprintf(newtitle, _countof(newtitle), _T("%s (%s): %s"), contactName, szStatus, TranslateT("Message session")); DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)wParam; if (!cws || (!mir_strcmp(cws->szModule, dat->szProto) && !mir_strcmp(cws->szSetting, "Status"))) { @@ -1068,10 +1068,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->wOldStatus = dat->wStatus; } else - mir_tstrncpy(newtitle, TranslateT("Message session"), SIZEOF(newtitle)); + mir_tstrncpy(newtitle, TranslateT("Message session"), _countof(newtitle)); TCHAR oldtitle[256]; - GetWindowText(hwndDlg, oldtitle, SIZEOF(oldtitle)); + GetWindowText(hwndDlg, oldtitle, _countof(oldtitle)); if (mir_tstrcmp(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed SetWindowText(hwndDlg, newtitle); SendMessage(hwndDlg, WM_SIZE, 0, 0); @@ -1306,7 +1306,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TCHAR* szContactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); HICON hTyping = Skin_LoadIcon(SKINICON_OTHER_TYPING); - mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("%s is typing a message..."), szContactName); + mir_sntprintf(szBuf, _countof(szBuf), TranslateT("%s is typing a message..."), szContactName); dat->nTypeSecs--; SendMessage(dat->hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf); diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index aa214357fc..a56f85e5b9 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -28,7 +28,7 @@ extern IconItem iconList[]; #define LOGICON_MSG_NOTICE 2 static char *pLogIconBmpBits[3]; -static size_t logIconBmpSize[ SIZEOF(pLogIconBmpBits) ]; +static size_t logIconBmpSize[ _countof(pLogIconBmpBits) ]; #define STREAMSTAGE_HEADER 0 #define STREAMSTAGE_EVENTS 1 @@ -108,7 +108,7 @@ static int AppendToBufferWithRTF(char *&buffer, size_t &cbBufferEnd, size_t &cbB } else if (*line == '[' && (g_dat.flags & SMF_SHOWFORMAT)) { int i, found = 0; - for (i = 0; i < SIZEOF(bbcodes); ++i) { + for (i = 0; i < _countof(bbcodes); ++i) { if (line[1] == bbcodes[i][1]) { size_t lenb = mir_tstrlen(bbcodes[i]); if (!_tcsnicmp(line, bbcodes[i], lenb)) { @@ -212,7 +212,7 @@ static char *SetToStyle(int style) LOGFONT lf; LoadMsgDlgFont(style, &lf, NULL); - mir_snprintf(szStyle, SIZEOF(szStyle), "\\f%u\\cf%u\\b%d\\i%d\\fs%u", style, style, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY); + mir_snprintf(szStyle, _countof(szStyle), "\\f%u\\cf%u\\b%d\\i%d\\fs%u", style, style, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY); return szStyle; } @@ -293,7 +293,7 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT else szFormat = g_dat.flags & SMF_SHOWDATE ? _T("d t") : _T("t"); - TimeZone_PrintTimeStamp(NULL, dbei.timestamp, szFormat, str, SIZEOF(str), 0); + TimeZone_PrintTimeStamp(NULL, dbei.timestamp, szFormat, str, _countof(str), 0); AppendToBuffer(buffer, bufferEnd, bufferAlloced, " %s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME)); AppendToBufferWithRTF(buffer, bufferEnd, bufferAlloced, str); @@ -529,7 +529,7 @@ void LoadMsgLogIcons(void) HDC hdcMem = CreateCompatibleDC(hdc); PBYTE pBmpBits = (PBYTE)mir_alloc(widthBytes * bih.biHeight); - for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) { + for (int i = 0; i < _countof(pLogIconBmpBits); i++) { HICON hIcon = IcoLib_GetIconByHandle(iconList[i].hIcolib); size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2; pLogIconBmpBits[i] = (char*)mir_alloc(size); @@ -558,6 +558,6 @@ void LoadMsgLogIcons(void) void FreeMsgLogIcons(void) { - for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) + for (int i = 0; i < _countof(pLogIconBmpBits); i++) mir_free(pLogIconBmpBits[i]); } diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index a5d8c93c2a..a05d36fe1a 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -53,7 +53,7 @@ static BYTE MsgDlgGetFontDefaultCharset(const TCHAR* szFont) bool LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour) { - if (i >= SIZEOF(fontOptionsList)) + if (i >= _countof(fontOptionsList)) return false; char str[32]; @@ -82,9 +82,9 @@ bool LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour) DBVARIANT dbv; if (db_get_ts(NULL, SRMMMOD, str, &dbv)) - _tcsncpy(lf->lfFaceName, fontOptionsList[i].szDefFace, SIZEOF(lf->lfFaceName)-1); + _tcsncpy(lf->lfFaceName, fontOptionsList[i].szDefFace, _countof(lf->lfFaceName)-1); else { - mir_tstrncpy(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName)); + mir_tstrncpy(lf->lfFaceName, dbv.ptszVal, _countof(lf->lfFaceName)); db_free(&dbv); } mir_snprintf(str, "SRMFont%dSet", i); @@ -99,7 +99,7 @@ void RegisterSRMMFonts(void) FontIDT fontid = { sizeof(fontid) }; fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID; - for (int i = 0; i < SIZEOF(fontOptionsList); i++) { + for (int i = 0; i < _countof(fontOptionsList); i++) { strncpy_s(fontid.dbSettingsGroup, SRMMMOD, _TRUNCATE); _tcsncpy_s(fontid.group, LPGENT("Message log"), _TRUNCATE); _tcsncpy_s(fontid.name, fontOptionsList[i].szDescr, _TRUNCATE); @@ -190,7 +190,7 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LP DWORD avatarHeight, msgTimeout; SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_POPLIST), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_POPLIST), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); - FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_POPLIST), statusValues, SIZEOF(statusValues), db_get_dw(NULL, SRMMMOD, SRMSGSET_POPFLAGS, SRMSGDEFSET_POPFLAGS)); + FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_POPLIST), statusValues, _countof(statusValues), db_get_dw(NULL, SRMMMOD, SRMSGSET_POPFLAGS, SRMSGDEFSET_POPFLAGS)); CheckDlgButton(hwndDlg, IDC_DONOTSTEALFOCUS, db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS) ? BST_CHECKED : BST_UNCHECKED); SetDlgItemInt(hwndDlg, IDC_NFLASHES, db_get_b(NULL, SRMMMOD, SRMSGSET_FLASHCOUNT, SRMSGDEFSET_FLASHCOUNT), FALSE); CheckDlgButton(hwndDlg, IDC_SHOWBUTTONLINE, g_dat.flags&SMF_SHOWBTNS ? BST_CHECKED : BST_UNCHECKED); diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 9d8a6befd8..b11c854b13 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -94,7 +94,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; TCHAR toolTip[256]; - mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(toolTip, _countof(toolTip), TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); cle.ptszTooltip = toolTip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); return 0; @@ -165,7 +165,7 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam) SendMessage(hwnd, DM_TYPING, 0, lParam); else if (lParam && (g_dat.flags & SMF_SHOWTYPINGTRAY)) { TCHAR szTip[256]; - mir_sntprintf(szTip, SIZEOF(szTip), TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(szTip, _countof(szTip), TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags & SMF_SHOWTYPINGCLIST)) { MIRANDASYSTRAYNOTIFY tn = { sizeof(tn) }; @@ -257,7 +257,7 @@ static void RestoreUnreadMessageAlerts(void) else { cle.hContact = hContact; cle.hDbEvent = hDbEvent; - mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(toolTip, _countof(toolTip), TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); } } @@ -516,8 +516,8 @@ STDMETHODIMP CREOleCallback::GetNewStorage(LPSTORAGE * lplpstg) { WCHAR szwName[64]; char szName[64]; - mir_snprintf(szName, SIZEOF(szName), "s%u", nextStgId++); - MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, SIZEOF(szwName)); + mir_snprintf(szName, _countof(szName), "s%u", nextStgId++); + MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, _countof(szwName)); if (pictStg == NULL) return STG_E_MEDIUMFULL; return pictStg->CreateStorage(szwName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg); diff --git a/src/core/stdssl/src/netlibssl.cpp b/src/core/stdssl/src/netlibssl.cpp index 9da09b7b0b..1a4cdafa31 100644 --- a/src/core/stdssl/src/netlibssl.cpp +++ b/src/core/stdssl/src/netlibssl.cpp @@ -80,11 +80,11 @@ static void ReportSslError(SECURITY_STATUS scRet, int line, bool showPopup = fal break; default: - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, scRet, LANG_USER_DEFAULT, szMsgBuf, SIZEOF(szMsgBuf), NULL); + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, scRet, LANG_USER_DEFAULT, szMsgBuf, _countof(szMsgBuf), NULL); } TCHAR szMsgBuf2[512]; - mir_sntprintf(szMsgBuf2, SIZEOF(szMsgBuf2), _T("SSL connection failure (%x %u): %s"), scRet, line, szMsgBuf); + mir_sntprintf(szMsgBuf2, _countof(szMsgBuf2), _T("SSL connection failure (%x %u): %s"), scRet, line, szMsgBuf); char* szMsg = Utf8EncodeT(szMsgBuf2); Netlib_Logf(NULL, szMsg); @@ -189,7 +189,7 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF ChainPara.cbSize = sizeof(ChainPara); ChainPara.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR; - ChainPara.RequestedUsage.Usage.cUsageIdentifier = SIZEOF(rgszUsages); + ChainPara.RequestedUsage.Usage.cUsageIdentifier = _countof(rgszUsages); ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = rgszUsages; if (!CertGetCertificateChain(NULL, pServerCert, NULL, pServerCert->hCertStore, &ChainPara, 0, NULL, &pChainContext)) { @@ -300,7 +300,7 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead) InBuffers[1].BufferType = SECBUFFER_EMPTY; SecBufferDesc InBuffer; - InBuffer.cBuffers = SIZEOF(InBuffers); + InBuffer.cBuffers = _countof(InBuffers); InBuffer.pBuffers = InBuffers; InBuffer.ulVersion = SECBUFFER_VERSION; @@ -314,7 +314,7 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead) OutBuffers[0].cbBuffer = 0; SecBufferDesc OutBuffer; - OutBuffer.cBuffers = SIZEOF(OutBuffers); + OutBuffer.cBuffers = _countof(OutBuffers); OutBuffer.pBuffers = OutBuffers; OutBuffer.ulVersion = SECBUFFER_VERSION; @@ -412,7 +412,7 @@ static bool ClientConnect(SslHandle *ssl, const char *host) OutBuffers[0].cbBuffer = 0; SecBufferDesc OutBuffer; - OutBuffer.cBuffers = SIZEOF(OutBuffers); + OutBuffer.cBuffers = _countof(OutBuffers); OutBuffer.pBuffers = OutBuffers; OutBuffer.ulVersion = SECBUFFER_VERSION; @@ -479,7 +479,7 @@ void NetlibSslShutdown(SslHandle *ssl) OutBuffers[0].cbBuffer = sizeof(dwType); SecBufferDesc OutBuffer; - OutBuffer.cBuffers = SIZEOF(OutBuffers); + OutBuffer.cBuffers = _countof(OutBuffers); OutBuffer.pBuffers = OutBuffers; OutBuffer.ulVersion = SECBUFFER_VERSION; @@ -606,7 +606,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) SecBufferDesc Message; Message.ulVersion = SECBUFFER_VERSION; - Message.cBuffers = SIZEOF(Buffers); + Message.cBuffers = _countof(Buffers); Message.pBuffers = Buffers; if (g_pSSPI->DecryptMessage != NULL && g_pSSPI->DecryptMessage != PVOID(0x80000000)) @@ -629,7 +629,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) // Locate data and (optional) extra buffers. SecBuffer *pDataBuffer = NULL; SecBuffer *pExtraBuffer = NULL; - for (int i = 1; i < SIZEOF(Buffers); i++) { + for (int i = 1; i < _countof(Buffers); i++) { if (pDataBuffer == NULL && Buffers[i].BufferType == SECBUFFER_DATA) pDataBuffer = &Buffers[i]; @@ -727,7 +727,7 @@ int NetlibSslWrite(SslHandle *ssl, const char *buf, int num) SecBufferDesc Message; Message.ulVersion = SECBUFFER_VERSION; - Message.cBuffers = SIZEOF(Buffers); + Message.cBuffers = _countof(Buffers); Message.pBuffers = Buffers; if (g_pSSPI->EncryptMessage != NULL) diff --git a/src/core/stduihist/src/history.cpp b/src/core/stduihist/src/history.cpp index 0748d76e54..78ed1a68e8 100644 --- a/src/core/stduihist/src/history.cpp +++ b/src/core/stduihist/src/history.cpp @@ -162,10 +162,10 @@ static void FillHistoryThread(void* param) db_event_get(hDbEvent, &dbei); TCHAR str[200], eventText[256], strdatetime[64]; - GetObjectSummary(&dbei, str, SIZEOF(str)); + GetObjectSummary(&dbei, str, _countof(str)); if (str[0]) { - TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, SIZEOF(strdatetime), 0); - mir_sntprintf(eventText, SIZEOF(eventText), _T("%s: %s"), strdatetime, str); + TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, _countof(strdatetime), 0); + mir_sntprintf(eventText, _countof(eventText), _T("%s: %s"), strdatetime, str); i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText); SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent); } @@ -208,7 +208,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP { TCHAR* contactName, str[200]; contactName = pcli->pfnGetContactDisplayName(hContact, 0); - mir_sntprintf(str, SIZEOF(str), TranslateT("History for %s"), contactName); + mir_sntprintf(str, _countof(str), TranslateT("History for %s"), contactName); SetWindowText(hwndDlg, str); } Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_HISTORY); @@ -289,7 +289,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); if (db_event_get(hDbEvent, &dbei) == 0) { TCHAR str[8192]; - GetObjectDescription(&dbei, str, SIZEOF(str)); + GetObjectDescription(&dbei, str, _countof(str)); if (str[0]) SetDlgItemText(hwndDlg, IDC_EDIT, str); } @@ -327,7 +327,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP db_event_get(hDbEvent, &dbei); TCHAR str[1024]; - GetObjectDescription(&dbei, str, SIZEOF(str)); + GetObjectDescription(&dbei, str, _countof(str)); if (str[0]) { CharUpperBuff(str, (int)mir_tstrlen(str)); if (_tcsstr(str, (const TCHAR*)lParam) != NULL) { @@ -361,7 +361,7 @@ static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam case IDOK://find Next TCHAR str[128]; HWND hwndParent = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - GetDlgItemText(hwndDlg, IDC_FINDWHAT, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_FINDWHAT, str, _countof(str)); CharUpperBuff(str, (int)mir_tstrlen(str)); SendMessage(hwndParent, DM_FINDNEXT, 0, (LPARAM)str); return TRUE; diff --git a/src/core/stdurl/url.cpp b/src/core/stdurl/url.cpp index 1dfdfa894b..bd467f3d49 100644 --- a/src/core/stdurl/url.cpp +++ b/src/core/stdurl/url.cpp @@ -49,7 +49,7 @@ static int UrlEventAdded(WPARAM hContact, LPARAM lParam) SkinPlaySound("RecvUrl"); TCHAR szTooltip[256]; - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); CLISTEVENT cle = { sizeof(cle) }; cle.flags = CLEF_TCHAR; @@ -82,7 +82,7 @@ static void RestoreUnreadUrlAlerts(void) db_event_get(hDbEvent, &dbei); if ( !(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType == EVENTTYPE_URL) { TCHAR toolTip[256]; - mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(toolTip, _countof(toolTip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); cle.hContact = hContact; cle.hDbEvent = hDbEvent; diff --git a/src/core/stdurl/urldialogs.cpp b/src/core/stdurl/urldialogs.cpp index 157725362b..f654cae874 100644 --- a/src/core/stdurl/urldialogs.cpp +++ b/src/core/stdurl/urldialogs.cpp @@ -35,11 +35,10 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact) if (hContact) { szProto = GetContactProto(hContact); if (szProto) { - CONTACTINFO ci; + CONTACTINFO ci = { 0 }; int hasName = 0; char buf[128]; memset(&ci, 0, sizeof(ci)); - ci.cbSize = sizeof(ci); ci.hContact = hContact; ci.szProto = szProto; @@ -53,7 +52,7 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact) break; case CNFT_DWORD: hasName = 1; - mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); + mir_snprintf(buf, _countof(buf), "%u", ci.dVal); break; } } @@ -65,12 +64,12 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact) SetDlgItemText(hwndDlg, IDC_NAME, contactName); szStatus = pcli->pfnGetStatusModeDescription(db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); - mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s %s (%s)"), pszNewTitleStart, contactName, szStatus); + mir_sntprintf(newtitle, _countof(newtitle), _T("%s %s (%s)"), pszNewTitleStart, contactName, szStatus); } } - else mir_tstrncpy(newtitle, pszNewTitleStart, SIZEOF(newtitle)); + else mir_tstrncpy(newtitle, pszNewTitleStart, _countof(newtitle)); - GetWindowText(hwndDlg, oldtitle, SIZEOF(oldtitle)); + GetWindowText(hwndDlg, oldtitle, _countof(oldtitle)); if (mir_tstrcmp(newtitle, oldtitle)) //swt() flickers even if the title hasn't actually changed SetWindowText(hwndDlg, newtitle); @@ -108,13 +107,13 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP db_event_markRead(dat->hContact, dat->hDbEvent); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0), msg[128]; - mir_sntprintf(msg, SIZEOF(msg), TranslateT("URL from %s"), contactName); + mir_sntprintf(msg, _countof(msg), TranslateT("URL from %s"), contactName); SetWindowText(hwndDlg, msg); SetDlgItemText(hwndDlg, IDC_FROM, contactName); SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETARROW, 1, 0); TCHAR str[128]; - TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), str, SIZEOF(str), 0); + TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), str, _countof(str), 0); SetDlgItemText(hwndDlg, IDC_DATE, str); } @@ -166,7 +165,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP HMENU hSubMenu = GetSubMenu(hMenu, 6); TranslateMenu(hSubMenu); GetWindowRect((HWND)lParam, &rc); - GetDlgItemTextA(hwndDlg, IDC_URL, url, SIZEOF(url)); + GetDlgItemTextA(hwndDlg, IDC_URL, url, _countof(url)); switch(TrackPopupMenu(hSubMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, NULL)) { case IDM_OPENNEW: CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)url); @@ -346,7 +345,7 @@ static void AddBrowserPageToCombo(char *url, HWND hwndCombo) char szExistingUrl[1024]; for (i = SendMessage(hwndCombo, CB_GETCOUNT, 0, 0)-1;i>=0;i--) { - if (SendMessage(hwndCombo, CB_GETLBTEXTLEN, i, 0) >= SIZEOF(szExistingUrl)) + if (SendMessage(hwndCombo, CB_GETLBTEXTLEN, i, 0) >= _countof(szExistingUrl)) continue; SendMessageA(hwndCombo, CB_GETLBTEXT, i, (LPARAM)szExistingUrl); if ( !mir_strcmp(szExistingUrl, url)) return; @@ -382,7 +381,7 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HW } int dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); DDEDATA *data = (DDEDATA*)GlobalLock(hData); - windowCount = dataLength/sizeof(DWORD); + windowCount = dataLength / sizeof(DWORD); windowId = (PDWORD)mir_alloc(sizeof(DWORD)*windowCount); memcpy(windowId, data->Value, windowCount*sizeof(DWORD)); GlobalUnlock(hData); @@ -402,7 +401,7 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HW for (i=0;ihContact != dat->hContact) break; if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break; - DBEVENTINFO dbei = { sizeof(dbei) }; + DBEVENTINFO dbei = { 0 }; + dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_URL; dbei.flags = DBEF_SENT; dbei.szModule = GetContactProto(dat->hContact); diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp index 7636f6b231..88e41465dd 100644 --- a/src/core/stduserinfo/src/contactinfo.cpp +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -112,9 +112,9 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE); { char szPhone[96], szArea[32], szNumber[64]; - GetDlgItemTextA(hwndDlg, IDC_AREA, szArea, SIZEOF(szArea)); - GetDlgItemTextA(hwndDlg, IDC_NUMBER, szNumber, SIZEOF(szNumber)); - mir_snprintf(szPhone, SIZEOF(szPhone), "+%u (%s) %s", SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCURSEL, 0, 0), 0), szArea, szNumber); + GetDlgItemTextA(hwndDlg, IDC_AREA, szArea, _countof(szArea)); + GetDlgItemTextA(hwndDlg, IDC_NUMBER, szNumber, _countof(szNumber)); + mir_snprintf(szPhone, _countof(szPhone), "+%u (%s) %s", SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCURSEL, 0, 0), 0), szArea, szNumber); noRecursion = 1; SetDlgItemTextA(hwndDlg, IDC_PHONE, szPhone); noRecursion = 0; @@ -127,7 +127,7 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar { char szText[256], *pText = NULL, *pArea, *pNumber; int i, isValid = 1; - GetDlgItemTextA(hwndDlg, IDC_PHONE, szText, SIZEOF(szText)); + GetDlgItemTextA(hwndDlg, IDC_PHONE, szText, _countof(szText)); if (szText[0] != '+') isValid = 0; @@ -190,7 +190,7 @@ static int IsOverEmail(HWND hwndDlg, TCHAR* szEmail, int cchEmail) ListView_GetSubItemRect(hwndEmails, hti.iItem, 1, LVIR_LABEL, &rc); TCHAR szText[256]; szText[0] = 0; - ListView_GetItemText(hwndEmails, hti.iItem, 1, szText, SIZEOF(szText)); + ListView_GetItemText(hwndEmails, hti.iItem, 1, szText, _countof(szText)); HDC hdc = GetDC(hwndEmails); SelectObject(hdc, hEmailFont); @@ -282,7 +282,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; lvi.pszText = idstr2; - mir_sntprintf(idstr2, SIZEOF(idstr2), _T("%d"), i+2); + mir_sntprintf(idstr2, _countof(idstr2), _T("%d"), i+2); } ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal); @@ -296,7 +296,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (db_get_ts(hContact, "UserInfo", idstr, &dbv)) break; lvi.pszText = idstr2; - mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1); + mir_sntprintf(idstr2, _countof(idstr2), TranslateT("Custom %d"), i+1); ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal); db_free(&dbv); @@ -357,7 +357,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (db_get_ts(hContact, "UserInfo", idstr, &dbv)) break; lvi.pszText = idstr2; - mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1); + mir_sntprintf(idstr2, _countof(idstr2), TranslateT("Custom %d"), i+1); ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); if (mir_tstrlen(dbv.ptszVal)>4 && !mir_tstrcmp(dbv.ptszVal+mir_tstrlen(dbv.ptszVal)-4, _T(" SMS"))) { ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); @@ -400,7 +400,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) { HFONT hoFont; TCHAR szText[256] = {0}; - ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); + ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText)); hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont); SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255)); DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP); @@ -416,7 +416,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP static int iconResources[3] = {SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE}; if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) { TCHAR szText[2]; - ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); + ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText)); if (szText[0]) hIcon = Skin_LoadIcon(SKINICON_OTHER_SMS); } else hIcon = Skin_LoadIcon(iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom == IDC_EMAILS)]); @@ -440,9 +440,9 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d"; LVHITTESTINFO hti; - if (IsOverEmail(hwndDlg, szEmail, SIZEOF(szEmail))) { + if (IsOverEmail(hwndDlg, szEmail, _countof(szEmail))) { TCHAR szExec[264]; - mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); + mir_sntprintf(szExec, _countof(szExec), _T("mailto:%s"), szEmail); ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); break; } @@ -493,7 +493,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP DBVARIANT dbv; mir_snprintf(idstr, szIdTemplate, lvi.lParam); if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break; - mir_strncpy(szText, dbv.pszVal, SIZEOF(szText)); + mir_strncpy(szText, dbv.pszVal, _countof(szText)); db_free(&dbv); if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText)) break; diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp index 3ad3f9432c..0ac9910f84 100644 --- a/src/core/stduserinfo/src/stdinfo.cpp +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -89,7 +89,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule else if (special == SVS_MONTH) { if (dbv.bVal > 0 && dbv.bVal <= 12) { pstr = str; - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1-1 + dbv.bVal, str, SIZEOF(str)); + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1-1 + dbv.bVal, str, _countof(str)); } else unspecified = 1; } @@ -111,7 +111,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule WORD wSave = dbv.wVal; if (wSave == (WORD)-1) { char szSettingName[100]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sName", szSetting); + mir_snprintf(szSettingName, _countof(szSettingName), "%sName", szSetting); if (!db_get_ts(hContact, szModule, szSettingName, &dbv)) { ptstr = dbv.ptszVal; unspecified = false; @@ -221,8 +221,8 @@ static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDC_EMAIL: if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EMAIL))) { TCHAR szExec[264], szEmail[256]; - GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, SIZEOF(szEmail)); - mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); + GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, _countof(szEmail)); + mir_sntprintf(szExec, _countof(szExec), _T("mailto:%s"), szEmail); ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); } break; @@ -250,7 +250,7 @@ static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (hContact != NULL) { TCHAR szTime[80]; - if (printDateTimeByContact(hContact, _T("s"), szTime, SIZEOF(szTime), TZF_KNOWNONLY)) { + if (printDateTimeByContact(hContact, _T("s"), szTime, _countof(szTime), TZF_KNOWNONLY)) { EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), FALSE); SetDlgItemText(hwndDlg, IDC_LOCALTIME, TranslateT("")); } @@ -344,7 +344,7 @@ static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_WEBPAGE: if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { char szPage[256]; - GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); + GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, _countof(szPage)); CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szPage); } } @@ -482,7 +482,7 @@ static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, case IDC_WEBPAGE: if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { char szPage[256]; - GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); + GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, _countof(szPage)); CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szPage); } break; @@ -545,7 +545,7 @@ static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MYNOTES))) { char text[2048]; - GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, _countof(text)); db_set_s(hContact, "UserInfo", "MyNotes", text); } else db_unset(hContact, "UserInfo", "MyNotes"); diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp index b195b5bb05..872312f824 100644 --- a/src/core/stduserinfo/src/userinfo.cpp +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -254,8 +254,8 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP else name = pcli->pfnGetContactDisplayName(dat->hContact, 0); - GetWindowText(hwndDlg, oldTitle, SIZEOF(oldTitle)); - mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); + GetWindowText(hwndDlg, oldTitle, _countof(oldTitle)); + mir_sntprintf(newTitle, _countof(newTitle), oldTitle, name); SetWindowText(hwndDlg, newTitle); ////////////////////////////////////////////////////////////////////// @@ -341,7 +341,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP ////////////////////////////////////////////////////////////////////// dat->updateAnimFrame = 0; - GetDlgItemText(hwndDlg, IDC_UPDATING, dat->szUpdating, SIZEOF(dat->szUpdating)); + GetDlgItemText(hwndDlg, IDC_UPDATING, dat->szUpdating, _countof(dat->szUpdating)); SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); if (!CallContactService(dat->hContact, PSS_GETINFO, SGIF_ONOPEN, 0)) { EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); @@ -355,7 +355,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_TIMER: TCHAR str[128]; - mir_sntprintf(str, SIZEOF(str), _T("%.*s%s%.*s"), dat->updateAnimFrame % 10, _T("........."), dat->szUpdating, dat->updateAnimFrame % 10, _T(".........")); + mir_sntprintf(str, _countof(str), _T("%.*s%s%.*s"), dat->updateAnimFrame % 10, _T("........."), dat->szUpdating, dat->updateAnimFrame % 10, _T(".........")); SetDlgItemText(hwndDlg, IDC_UPDATING, str); if (++dat->updateAnimFrame == UPDATEANIMFRAMES) dat->updateAnimFrame = 0; @@ -584,7 +584,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP tvi.mask = TVIF_TEXT; tvi.hItem = dat->opd[dat->currentPage].hItem; tvi.pszText = name; - tvi.cchTextMax = SIZEOF(name); + tvi.cchTextMax = _countof(name); TreeView_GetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); db_set_ts(NULL, "UserInfo", "LastTab", name); diff --git a/src/core/stduseronline/src/useronline.cpp b/src/core/stduseronline/src/useronline.cpp index 32e5bcb2b8..f9117bc809 100644 --- a/src/core/stduseronline/src/useronline.cpp +++ b/src/core/stduseronline/src/useronline.cpp @@ -67,7 +67,7 @@ static int UserOnlineSettingChanged(WPARAM hContact, LPARAM lParam) cle.hDbEvent = uniqueEventId++; cle.hIcon = Skin_LoadIcon(SKINICON_OTHER_USERONLINE, false); cle.pszService = "UserOnline/Description"; - mir_sntprintf(tooltip, SIZEOF(tooltip), TranslateT("%s is online"), pcli->pfnGetContactDisplayName(hContact, 0)); + mir_sntprintf(tooltip, _countof(tooltip), TranslateT("%s is online"), pcli->pfnGetContactDisplayName(hContact, 0)); cle.ptszTooltip = tooltip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); IcoLib_ReleaseIcon(cle.hIcon, 0); -- cgit v1.2.3