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 +- src/mir_app/src/DefaultExtraIcons.cpp | 14 +++++----- src/mir_app/src/FontOptions.cpp | 8 +++--- src/mir_app/src/FontService.cpp | 6 ++--- src/mir_app/src/button.cpp | 2 +- src/mir_app/src/chat_clist.cpp | 2 +- src/mir_app/src/chat_log.cpp | 12 ++++----- src/mir_app/src/chat_opts.cpp | 4 +-- src/mir_app/src/chat_tools.cpp | 20 +++++++------- src/mir_app/src/clc.cpp | 12 ++++----- src/mir_app/src/clcfiledrop.cpp | 4 +-- src/mir_app/src/clcitems.cpp | 12 ++++----- src/mir_app/src/clcmsgs.cpp | 2 +- src/mir_app/src/clcutils.cpp | 4 +-- src/mir_app/src/clistmenus.cpp | 36 ++++++++++++------------- src/mir_app/src/clistmod.cpp | 16 +++++------ src/mir_app/src/clisttray.cpp | 14 +++++----- src/mir_app/src/clui.cpp | 16 +++++------ src/mir_app/src/cluiservices.cpp | 6 ++--- src/mir_app/src/contact.cpp | 4 +-- src/mir_app/src/contacts.cpp | 6 ++--- src/mir_app/src/database.cpp | 30 ++++++++++----------- src/mir_app/src/dbini.cpp | 28 ++++++++++---------- src/mir_app/src/dbutils.cpp | 6 ++--- src/mir_app/src/extraicons.cpp | 2 +- src/mir_app/src/filter.cpp | 12 ++++----- src/mir_app/src/findadd.cpp | 16 +++++------ src/mir_app/src/genmenu.cpp | 16 +++++------ src/mir_app/src/genmenuopt.cpp | 12 ++++----- src/mir_app/src/groups.cpp | 34 ++++++++++++------------ src/mir_app/src/hotkey_opts.cpp | 18 ++++++------- src/mir_app/src/hotkeys.cpp | 6 ++--- src/mir_app/src/hyperlink.cpp | 4 +-- src/mir_app/src/icolib.cpp | 4 +-- src/mir_app/src/ignore.cpp | 10 +++---- src/mir_app/src/langpack.cpp | 2 +- src/mir_app/src/lpopts.cpp | 14 +++++----- src/mir_app/src/meta_main.cpp | 2 +- src/mir_app/src/meta_menu.cpp | 2 +- src/mir_app/src/meta_services.cpp | 4 +-- src/mir_app/src/meta_utils.cpp | 6 ++--- src/mir_app/src/miranda.cpp | 6 ++--- src/mir_app/src/netlib.cpp | 4 +-- src/mir_app/src/netlibautoproxy.cpp | 6 ++--- src/mir_app/src/netlibbind.cpp | 2 +- src/mir_app/src/netlibhttp.cpp | 12 ++++----- src/mir_app/src/netliblog.cpp | 32 +++++++++++----------- src/mir_app/src/netlibopts.cpp | 14 +++++----- src/mir_app/src/netlibsecurity.cpp | 2 +- src/mir_app/src/netlibsock.cpp | 2 +- src/mir_app/src/netlibupnp.cpp | 6 ++--- src/mir_app/src/newplugins.cpp | 30 ++++++++++----------- src/mir_app/src/options.cpp | 24 ++++++++--------- src/mir_app/src/path.cpp | 30 ++++++++++----------- src/mir_app/src/pluginopts.cpp | 16 +++++------ src/mir_app/src/profilemanager.cpp | 26 +++++++++--------- src/mir_app/src/proto_accs.cpp | 2 +- src/mir_app/src/proto_opts.cpp | 18 ++++++------- src/mir_app/src/proto_utils.cpp | 6 ++--- src/mir_app/src/searchresults.cpp | 6 ++--- src/mir_app/src/services.cpp | 6 ++--- src/mir_app/src/skin2opts.cpp | 18 ++++++------- src/mir_app/src/skinicons.cpp | 44 +++++++++++++++---------------- src/mir_app/src/sounds.cpp | 6 ++--- src/mir_app/src/utils.cpp | 12 ++++----- src/mir_app/src/visibility.cpp | 6 ++--- src/mir_app/src/xmlParser.cpp | 2 +- src/mir_core/src/langpack.cpp | 22 ++++++++-------- src/mir_core/src/path.cpp | 10 +++---- src/mir_core/src/timezones.cpp | 16 +++++------ src/mir_core/src/ui_utils.cpp | 6 ++--- src/mir_core/src/winutil.cpp | 16 +++++------ src/mir_core/src/winver.cpp | 4 +-- 105 files changed, 689 insertions(+), 689 deletions(-) (limited to 'src') 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); diff --git a/src/mir_app/src/DefaultExtraIcons.cpp b/src/mir_app/src/DefaultExtraIcons.cpp index 09ff82aa72..e5fa87d324 100644 --- a/src/mir_app/src/DefaultExtraIcons.cpp +++ b/src/mir_app/src/DefaultExtraIcons.cpp @@ -112,7 +112,7 @@ struct Info static void EmailOnClick(Info*, const char *text) { char cmd[1024]; - mir_snprintf(cmd, SIZEOF(cmd), "mailto:%s", text); + mir_snprintf(cmd, _countof(cmd), "mailto:%s", text); ShellExecuteA(NULL, "open", cmd, NULL, NULL, SW_SHOW); } @@ -143,10 +143,10 @@ static void SetExtraIcons(MCONTACT hContact) if ( IsEmpty(proto)) return; - for (unsigned int i = 0; i < SIZEOF(infos); i++) { + for (unsigned int i = 0; i < _countof(infos); i++) { Info &p = infos[i]; - for (unsigned int j = 0; j < SIZEOF(p.db); j += 2) { + for (unsigned int j = 0; j < _countof(p.db); j += 2) { if (p.db[j + 1] == NULL) break; @@ -180,10 +180,10 @@ static int SettingChanged(WPARAM hContact, LPARAM lParam) return 0; } - for (int i = 0; i < SIZEOF(infos); i++) { + for (int i = 0; i < _countof(infos); i++) { Info &p = infos[i]; - for (int j = 0; j < SIZEOF(p.db); j += 2) { + for (int j = 0; j < _countof(p.db); j += 2) { if (p.db[j + 1] == NULL) break; if (p.db[j] == NULL && !isProto) @@ -216,7 +216,7 @@ static int DefaultOnClick(WPARAM hContact, LPARAM, LPARAM param) return 0; bool found = false; - for (int j = 0; !found && j < SIZEOF(p->db); j += 2) { + for (int j = 0; !found && j < _countof(p->db); j += 2) { if (p->db[j + 1] == NULL) break; @@ -307,7 +307,7 @@ void DefaultExtraIcons_Load() hExtraProto = ExtraIcon_Register("protocol", "Account", Skin_GetIconName(SKINICON_OTHER_ACCMGR), &ProtocolRebuildIcons, &ProtocolApplyIcon, &ProtocolOnClick); - for (int i = 0; i < SIZEOF(infos); i++) { + for (int i = 0; i < _countof(infos); i++) { Info &p = infos[i]; p.hIcolib = Skin_GetIconHandle(p.iSkinIcon); if (p.OnClick) diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp index 32d76d2db8..9bea94cc87 100644 --- a/src/mir_app/src/FontOptions.cpp +++ b/src/mir_app/src/FontOptions.cpp @@ -149,7 +149,7 @@ static BOOL ExportSettings(HWND hwndDlg, const TCHAR *filename, OBJLISThwnd, szText, SIZEOF(szText)); + GetWindowText(ctl->hwnd, szText, _countof(szText)); GetTextExtentPoint32(hdcMem, szText, (int)mir_tstrlen(szText), &sz); int xOffset = (rcClient.right - rcClient.left - sz.cx)/2; int yOffset = (rcClient.bottom - rcClient.top - sz.cy)/2; diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index cd633f600b..9a2c1991b8 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -212,7 +212,7 @@ BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, TCHAR* fm va_list marker; va_start(marker, fmt); - mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker); + mir_vsntprintf(szBuf, _countof(szBuf), fmt, marker); va_end(marker); CLISTEVENT cle = { 0 }; diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index 79b608953c..f3ac0e6a4b 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // the srmm module and then modified to fit the chat module. char* pLogIconBmpBits[14]; -size_t logIconBmpSize[ SIZEOF(pLogIconBmpBits) ]; +size_t logIconBmpSize[ _countof(pLogIconBmpBits) ]; #define RTFCACHELINESIZE 128 static char CHAT_rtfFontsGlobal[OPTIONS_FONTCOUNT][RTFCACHELINESIZE]; @@ -315,7 +315,7 @@ static void AddEventToBuffer(char *&buffer, size_t &bufferEnd, size_t &bufferAll TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time) { static TCHAR szTime[30]; - if (!_tcsftime(szTime, SIZEOF(szTime)-1, pszStamp, localtime(&time))) + if (!_tcsftime(szTime, _countof(szTime)-1, pszStamp, localtime(&time))) _tcsncpy_s(szTime, TranslateT(""), _TRUNCATE); return szTime; } @@ -364,12 +364,12 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData) static char szStyle[256]; if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) { int iii = lin->bIsHighlighted ? 16 : (lin->bIsMe ? 2 : 1); - mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY); + mir_snprintf(szStyle, _countof(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY); Log_Append(buffer, bufferEnd, bufferAlloced, "%s ", szStyle); } else { int iii = lin->bIsHighlighted ? 16 : EventToIndex(lin); - mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY); + mir_snprintf(szStyle, _countof(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY); Log_Append(buffer, bufferEnd, bufferAlloced, "%s ", szStyle); } } @@ -494,7 +494,7 @@ void LoadMsgLogBitmaps(void) HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight); 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++) { size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2; pLogIconBmpBits[i] = (char*)mir_alloc(size); size_t rtfHeaderSize = mir_snprintf((char *)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight); @@ -537,6 +537,6 @@ void LoadMsgLogBitmaps(void) void FreeMsgLogBitmaps(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/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp index 3a5252e959..ffb6e0d74e 100644 --- a/src/mir_app/src/chat_opts.cpp +++ b/src/mir_app/src/chat_opts.cpp @@ -139,12 +139,12 @@ void RegisterFonts(void) _tcsncpy_s(fontid.backgroundGroup, g_szFontGroup, _TRUNCATE); _tcsncpy_s(fontid.group, g_szFontGroup, _TRUNCATE); - for (int i = 0; i < SIZEOF(fontOptionsList); i++, index++) { + for (int i = 0; i < _countof(fontOptionsList); i++, index++) { FontOptionsList &FO = fontOptionsList[i]; strncpy_s(fontid.dbSettingsGroup, CHATFONT_MODULE, _TRUNCATE); _tcsncpy_s(fontid.name, FO.szDescr, _TRUNCATE); - mir_snprintf(fontid.prefix, SIZEOF(fontid.prefix), "Font%d", index); + mir_snprintf(fontid.prefix, _countof(fontid.prefix), "Font%d", index); fontid.order = index; switch (i) { diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 00b3f90e5d..fd72ed1ea1 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -45,8 +45,8 @@ TCHAR* RemoveFormatting(const TCHAR *pszWord) TCHAR *d = szTemp; size_t cbLen = mir_tstrlen(pszWord); - if (cbLen > SIZEOF(szTemp)) - cbLen = SIZEOF(szTemp)-1; + if (cbLen > _countof(szTemp)) + cbLen = _countof(szTemp)-1; for (size_t i = 0; i < cbLen;) { if (pszWord[i] == '%') { @@ -184,11 +184,11 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char *pszProtoNa pd.lchIcon = LoadIconEx("window", FALSE); PROTOACCOUNT *pa = Proto_GetAccount(pszProtoName); - mir_sntprintf(pd.lptzContactName, SIZEOF(pd.lptzContactName), _T("%s - %s"), + mir_sntprintf(pd.lptzContactName, _countof(pd.lptzContactName), _T("%s - %s"), (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName, cli.pfnGetContactDisplayName(hContact, 0)); - mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), SIZEOF(pd.lptzText)); + mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), _countof(pd.lptzText)); pd.iSeconds = g_Settings->iPopupTimeout; if (g_Settings->iPopupStyle == 2) { @@ -563,9 +563,9 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) // formatting strings don't need to be translatable - changing them via language pack would // only screw up the log format. if (p) - mir_sntprintf(szLine, SIZEOF(szLine), _T("%s %c %s\r\n"), szTime, p, szBuffer); + mir_sntprintf(szLine, _countof(szLine), _T("%s %c %s\r\n"), szTime, p, szBuffer); else - mir_sntprintf(szLine, SIZEOF(szLine), _T("%s %s\r\n"), szTime, szBuffer); + mir_sntprintf(szLine, _countof(szLine), _T("%s %s\r\n"), szTime, szBuffer); if (szLine[0]) { _fputts(szLine, hFile); @@ -590,11 +590,11 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) _tsplitpath(si->pszLogFileName, tszDrive, tszDir, tszName, tszExt); TCHAR tszNewPath[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20]; - mir_sntprintf(tszNewPath, SIZEOF(tszNewPath), _T("%s%sarchived\\"), tszDrive, tszDir); + mir_sntprintf(tszNewPath, _countof(tszNewPath), _T("%s%sarchived\\"), tszDrive, tszDir); CreateDirectoryTreeT(tszNewPath); TCHAR tszNewName[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20]; - mir_sntprintf(tszNewName, SIZEOF(tszNewName), _T("%s%s-%s%s"), tszNewPath, tszName, tszTimestamp, tszExt); + mir_sntprintf(tszNewName, _countof(tszNewName), _T("%s%s-%s%s"), tszNewPath, tszName, tszTimestamp, tszExt); fclose(hFile); hFile = 0; if (!PathFileExists(tszNewName)) @@ -742,7 +742,7 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) TCHAR tszTemp[MAX_PATH], *ptszVarPath; if (g_Settings->pszLogDir[mir_tstrlen(g_Settings->pszLogDir) - 1] == '\\') { - mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%s%s"), g_Settings->pszLogDir, _T("%userid%.log")); + mir_sntprintf(tszTemp, _countof(tszTemp), _T("%s%s"), g_Settings->pszLogDir, _T("%userid%.log")); ptszVarPath = tszTemp; } else ptszVarPath = g_Settings->pszLogDir; @@ -758,7 +758,7 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) PathToAbsoluteT(tszParsedName, si->pszLogFileName); mir_free(tszParsedName); - for (int i = 0; i < SIZEOF(rva); i++) + for (int i = 0; i < _countof(rva); i++) mir_free(rva[i].lptzValue); for (TCHAR *p = si->pszLogFileName + 2; *p; ++p) diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 75e0496fce..517aaceac5 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -421,7 +421,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } group = group->parent; size_t nameLen = mir_tstrlen(group->cl.items[i]->szText); - if (mir_tstrlen(szFullName) + 1 + nameLen > SIZEOF(szFullName)) { + if (mir_tstrlen(szFullName) + 1 + nameLen > _countof(szFullName)) { szFullName[0] = '\0'; break; } @@ -581,7 +581,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; - mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText)); + mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), _countof(contact->szText)); dat->needsResort = 1; SortClcByTimer(hwnd); break; @@ -592,7 +592,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, contact->proto = GetContactProto(wParam); cli.pfnInvalidateDisplayNameCacheEntry(wParam); - mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText)); + mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), _countof(contact->szText)); SortClcByTimer(hwnd); break; @@ -828,7 +828,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, TCHAR szNew[2]; szNew[0] = (TCHAR) wParam; szNew[1] = '\0'; - if (mir_tstrlen(dat->szQuickSearch) >= SIZEOF(dat->szQuickSearch) - 1) { + if (mir_tstrlen(dat->szQuickSearch) >= _countof(dat->szQuickSearch) - 1) { MessageBeep(MB_OK); break; } @@ -1150,7 +1150,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)contacto->hContact, contactn->groupId); else if (contacto->type == CLCIT_GROUP) { //dropee is a group TCHAR szNewName[120]; - mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s\\%s"), cli.pfnGetGroupName(contactn->groupId, NULL), contacto->szText); + mir_sntprintf(szNewName, _countof(szNewName), _T("%s\\%s"), cli.pfnGetGroupName(contactn->groupId, NULL), contacto->szText); cli.pfnRenameGroup(contacto->groupId, szNewName); } } @@ -1189,7 +1189,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, break; if (contact->type == CLCIT_GROUP) { //dropee is a group TCHAR szNewName[120]; - mir_tstrncpy(szNewName, contact->szText, SIZEOF(szNewName)); + mir_tstrncpy(szNewName, contact->szText, _countof(szNewName)); cli.pfnRenameGroup(contact->groupId, szNewName); } else if (contact->type == CLCIT_CONTACT) //dropee is a contact diff --git a/src/mir_app/src/clcfiledrop.cpp b/src/mir_app/src/clcfiledrop.cpp index da3ab82e47..a7aca08f78 100644 --- a/src/mir_app/src/clcfiledrop.cpp +++ b/src/mir_app/src/clcfiledrop.cpp @@ -147,7 +147,7 @@ HRESULT CDropTarget::DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL shortPt.x = pt.x; shortPt.y = pt.y; hwnd = WindowFromPoint(shortPt); - GetClassName(hwnd, szWindowClass, SIZEOF(szWindowClass)); + GetClassName(hwnd, szWindowClass, _countof(szWindowClass)); if (!mir_tstrcmp(szWindowClass, _T(CLISTCONTROL_CLASS))) { struct ClcData *dat; hwndCurrentDrag = hwnd; @@ -229,7 +229,7 @@ HRESULT CDropTarget::Drop(IDataObject * pDataObj, DWORD /*fKeyState*/, POINTL pt fileCount = DragQueryFile(hDrop, -1, NULL, 0); ppFiles = NULL; for (i=0; i < fileCount; i++) { - DragQueryFile(hDrop, i, szFilename, SIZEOF(szFilename)); + DragQueryFile(hDrop, i, szFilename, _countof(szFilename)); AddToFileList(&ppFiles, &totalCount, szFilename); } diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index 533c45aa8b..bff9d4dc67 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -41,7 +41,7 @@ int fnAddItemToGroup(ClcGroup *group, int iAboveItem) ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers) { - TCHAR *pBackslash, *pNextField, szThisField[ SIZEOF(dat->list.cl.items[0]->szText) ]; + TCHAR *pBackslash, *pNextField, szThisField[ _countof(dat->list.cl.items[0]->szText) ]; ClcGroup *group = &dat->list; int i, compareResult; @@ -53,11 +53,11 @@ ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD do { pBackslash = _tcschr(pNextField, '\\'); if (pBackslash == NULL) { - mir_tstrncpy(szThisField, pNextField, SIZEOF(szThisField)); + mir_tstrncpy(szThisField, pNextField, _countof(szThisField)); pNextField = NULL; } else { - mir_tstrncpy(szThisField, pNextField, min(SIZEOF(szThisField), pBackslash - pNextField + 1)); + mir_tstrncpy(szThisField, pNextField, min(_countof(szThisField), pBackslash - pNextField + 1)); pNextField = pBackslash + 1; } compareResult = 1; @@ -89,7 +89,7 @@ ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD return NULL; i = cli.pfnAddItemToGroup(group, i); group->cl.items[i]->type = CLCIT_GROUP; - mir_tstrncpy(group->cl.items[i]->szText, szThisField, SIZEOF(group->cl.items[i]->szText)); + mir_tstrncpy(group->cl.items[i]->szText, szThisField, _countof(group->cl.items[i]->szText)); group->cl.items[i]->groupId = (WORD) (pNextField ? 0 : groupId); group->cl.items[i]->group = (ClcGroup *) mir_alloc(sizeof(ClcGroup)); group->cl.items[i]->group->parent = group; @@ -167,7 +167,7 @@ int fnAddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText) group->cl.items[i]->type = CLCIT_INFO; group->cl.items[i]->flags = (BYTE) flags; group->cl.items[i]->hContact = (MCONTACT)++iInfoItemUniqueHandle; - mir_tstrncpy(group->cl.items[i]->szText, pszText, SIZEOF(group->cl.items[i]->szText)); + mir_tstrncpy(group->cl.items[i]->szText, pszText, _countof(group->cl.items[i]->szText)); return i; } @@ -205,7 +205,7 @@ int fnAddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hContact) DWORD idleMode = szProto != NULL ? db_get_dw(hContact, szProto, "IdleTS", 0) : 0; if (idleMode) group->cl.items[i]->flags |= CONTACTF_IDLE; - mir_tstrncpy(group->cl.items[i]->szText, cli.pfnGetContactDisplayName(hContact, 0), SIZEOF(group->cl.items[i]->szText)); + mir_tstrncpy(group->cl.items[i]->szText, cli.pfnGetContactDisplayName(hContact, 0), _countof(group->cl.items[i]->szText)); ClcCacheEntry *p = cli.pfnGetCacheEntry(hContact); if (p != NULL) diff --git a/src/mir_app/src/clcmsgs.cpp b/src/mir_app/src/clcmsgs.cpp index 822644b6f6..785877cb73 100644 --- a/src/mir_app/src/clcmsgs.cpp +++ b/src/mir_app/src/clcmsgs.cpp @@ -399,7 +399,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPAR case CLM_SETITEMTEXT: if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; - mir_tstrncpy(contact->szText, (TCHAR*)lParam, SIZEOF(contact->szText)); + mir_tstrncpy(contact->szText, (TCHAR*)lParam, _countof(contact->szText)); cli.pfnSortCLC(hwnd, dat, 1); cli.pfnInvalidateRect(hwnd, NULL, FALSE); break; diff --git a/src/mir_app/src/clcutils.cpp b/src/mir_app/src/clcutils.cpp index fa0c1ad919..378fd7f809 100644 --- a/src/mir_app/src/clcutils.cpp +++ b/src/mir_app/src/clcutils.cpp @@ -403,7 +403,7 @@ void fnEndRename(HWND, struct ClcData *dat, int save) dat->hwndRenameEdit = NULL; if (save) { TCHAR text[120]; text[0] = 0; - GetWindowText(hwndEdit, text, SIZEOF(text)); + GetWindowText(hwndEdit, text, _countof(text)); ClcContact *contact; if (cli.pfnGetRowByIndex(dat, dat->selection, &contact, NULL) != -1) { @@ -411,7 +411,7 @@ void fnEndRename(HWND, struct ClcData *dat, int save) if (contact->type == CLCIT_GROUP) { if (contact->group->parent && contact->group->parent->parent) { TCHAR szFullName[256]; - mir_sntprintf(szFullName, SIZEOF(szFullName), _T("%s\\%s"), + mir_sntprintf(szFullName, _countof(szFullName), _T("%s\\%s"), cli.pfnGetGroupName(contact->group->parent->groupId, NULL), text); cli.pfnRenameGroup(contact->groupId, szFullName); } diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index a69c594fdf..4cf60f4414 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -450,7 +450,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) if (FindMenuHandleByGlobalID(hStatusMenu, timiParent, &it)) { MENUITEMINFO mi = { 0 }; TCHAR d[100]; - GetMenuString(it.OwnerMenu, it.position, d, SIZEOF(d), MF_BYPOSITION); + GetMenuString(it.OwnerMenu, it.position, d, _countof(d), MF_BYPOSITION); mi.cbSize = sizeof(mi); mi.fMask = MIIM_STRING | MIIM_STATE; @@ -544,7 +544,7 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) bool bIsLocked = !Proto_IsAccountLocked(acc); db_set_b(NULL, prot, "LockMainStatus", bIsLocked); - CallProtoServiceInt(NULL, smep->proto, PS_GETNAME, (WPARAM)SIZEOF(szHumanName), (LPARAM)szHumanName); + CallProtoServiceInt(NULL, smep->proto, PS_GETNAME, (WPARAM)_countof(szHumanName), (LPARAM)szHumanName); PMO_IntMenuItem pimi = MO_GetIntMenuItem((HGENMENU)smep->protoindex); if (pimi == NULL) @@ -827,8 +827,8 @@ void RebuildMenuOrder(void) hStatusMenuObject = MO_CreateMenuObject("StatusMenu", LPGEN("Status menu"), "StatusMenuCheckService", "StatusMenuExecService"); MO_SetOptionsMenuObject(hStatusMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataStatusMenu"); - hStatusMainMenuHandles = (PMO_IntMenuItem*)mir_calloc(SIZEOF(statusModeList) * sizeof(PMO_IntMenuItem)); - hStatusMainMenuHandlesCnt = SIZEOF(statusModeList); + hStatusMainMenuHandles = (PMO_IntMenuItem*)mir_calloc(_countof(statusModeList) * sizeof(PMO_IntMenuItem)); + hStatusMainMenuHandlesCnt = _countof(statusModeList); hStatusMenuHandles = (tStatusMenuHandles*)mir_calloc(sizeof(tStatusMenuHandles)*accounts.getCount()); hStatusMenuHandlesCnt = accounts.getCount(); @@ -857,7 +857,7 @@ void RebuildMenuOrder(void) tmi.hIcon = ic = (HICON)CallProtoServiceInt(NULL, pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); if (Proto_IsAccountLocked(pa) && cli.bDisplayLocked) { - mir_sntprintf(tbuf, SIZEOF(tbuf), TranslateT("%s (locked)"), pa->tszAccountName); + mir_sntprintf(tbuf, _countof(tbuf), TranslateT("%s (locked)"), pa->tszAccountName); tmi.ptszName = tbuf; } else tmi.ptszName = pa->tszAccountName; @@ -885,7 +885,7 @@ void RebuildMenuOrder(void) tmi.flags |= CMIF_CHECKED; if ((tmi.flags & CMIF_CHECKED) && cli.bDisplayLocked) { - mir_sntprintf(tbuf, SIZEOF(tbuf), TranslateT("%s (locked)"), pa->tszAccountName); + mir_sntprintf(tbuf, _countof(tbuf), TranslateT("%s (locked)"), pa->tszAccountName); tmi.ptszName = tbuf; } else tmi.ptszName = pa->tszAccountName; @@ -908,7 +908,7 @@ void RebuildMenuOrder(void) DestroyIcon(ic); pos += 500000; - for (int j = 0; j < SIZEOF(statusModeList); j++) { + for (int j = 0; j < _countof(statusModeList); j++) { if (!(flags & statusModePf2List[j])) continue; @@ -947,7 +947,7 @@ void RebuildMenuOrder(void) int pos = 200000; // add to root menu - for (int j = 0; j < SIZEOF(statusModeList); j++) { + for (int j = 0; j < _countof(statusModeList); j++) { for (int i = 0; i < accounts.getCount(); i++) { PROTOACCOUNT *pa = accounts[i]; if (!bHideStatusMenu && !cli.pfnGetProtocolVisibility(pa->szModuleName)) @@ -973,7 +973,7 @@ void RebuildMenuOrder(void) { TCHAR buf[256], hotkeyName[100]; WORD hotKey = GetHotkeyValue(statusHotkeys[j]); - HotkeyToName(hotkeyName, SIZEOF(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey)); + HotkeyToName(hotkeyName, _countof(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey)); mir_sntprintf(buf, _T("%s\t%s"), cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName); tmi.ptszName = buf; @@ -1000,10 +1000,10 @@ static int sttRebuildHotkeys(WPARAM, LPARAM) TMO_MenuItem tmi = { sizeof(tmi) }; tmi.flags = CMIM_HOTKEY | CMIM_NAME | CMIF_TCHAR; - for (int j = 0; j < SIZEOF(statusModeList); j++) { + for (int j = 0; j < _countof(statusModeList); j++) { TCHAR buf[256], hotkeyName[100]; WORD hotKey = GetHotkeyValue(statusHotkeys[j]); - HotkeyToName(hotkeyName, SIZEOF(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey)); + HotkeyToName(hotkeyName, _countof(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey)); mir_sntprintf(buf, _T("%s\t%s"), cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName); tmi.ptszName = buf; tmi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey)); @@ -1017,7 +1017,7 @@ static int sttRebuildHotkeys(WPARAM, LPARAM) int statustopos(int status) { - for (int j = 0; j < SIZEOF(statusModeList); j++) + for (int j = 0; j < _countof(statusModeList); j++) if (status == statusModeList[j]) return j; @@ -1070,19 +1070,19 @@ static int MenuProtoAck(WPARAM, LPARAM lParam) for (int i = 0; i < accounts.getCount(); i++) { if (!mir_strcmp(accounts[i]->szModuleName, ack->szModule)) { - if (((int)ack->hProcess >= ID_STATUS_OFFLINE || (int)ack->hProcess == 0) && (int)ack->hProcess < ID_STATUS_OFFLINE + SIZEOF(statusModeList)) { + if (((int)ack->hProcess >= ID_STATUS_OFFLINE || (int)ack->hProcess == 0) && (int)ack->hProcess < ID_STATUS_OFFLINE + _countof(statusModeList)) { int pos = statustopos((int)ack->hProcess); if (pos == -1) pos = 0; - for (pos = 0; pos < SIZEOF(statusModeList); pos++) { + for (pos = 0; pos < _countof(statusModeList); pos++) { tmi.flags = CMIM_FLAGS | CMIF_ROOTHANDLE; MO_ModifyMenuItem(hStatusMenuHandles[i].menuhandle[pos], &tmi); } } - if (ack->lParam >= ID_STATUS_OFFLINE && ack->lParam < ID_STATUS_OFFLINE + SIZEOF(statusModeList)) { + if (ack->lParam >= ID_STATUS_OFFLINE && ack->lParam < ID_STATUS_OFFLINE + _countof(statusModeList)) { int pos = statustopos((int)ack->lParam); - if (pos >= 0 && pos < SIZEOF(statusModeList)) { + if (pos >= 0 && pos < _countof(statusModeList)) { tmi.flags = CMIM_FLAGS | CMIF_ROOTHANDLE | CMIF_CHECKED; MO_ModifyMenuItem(hStatusMenuHandles[i].menuhandle[pos], &tmi); } @@ -1304,9 +1304,9 @@ void InitCustomMenus(void) HOTKEYDESC hkd = { sizeof(hkd) }; hkd.ptszSection = _T("Status"); hkd.dwFlags = HKD_TCHAR; - for (int i = 0; i < SIZEOF(statusHotkeys); i++) { + for (int i = 0; i < _countof(statusHotkeys); i++) { char szName[30]; - mir_snprintf(szName, SIZEOF(szName), "StatusHotKey_%d", i); + mir_snprintf(szName, _countof(szName), "StatusHotKey_%d", i); hkd.pszName = szName; hkd.lParam = statusModeList[i]; hkd.ptszDescription = fnGetStatusModeDescription(hkd.lParam, 0); diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index 1b11108836..e1b20354f8 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -100,7 +100,7 @@ TCHAR* fnGetStatusModeDescription(int mode, int flags) default: if (IsStatusConnecting(mode)) { const TCHAR* connFmt = LPGENT("Connecting (attempt %d)"); - mir_sntprintf(szMode, SIZEOF(szMode), (flags & GSMDF_UNTRANSLATED) ? connFmt : TranslateTS(connFmt), mode - ID_STATUS_CONNECTING + 1); + mir_sntprintf(szMode, _countof(szMode), (flags & GSMDF_UNTRANSLATED) ? connFmt : TranslateTS(connFmt), mode - ID_STATUS_CONNECTING + 1); return szMode; } return NULL; @@ -157,11 +157,11 @@ int fnIconFromStatusMode(const char *szProto, int status, MCONTACT) { int index, i; - for (index = 0; index < SIZEOF(statusModeList); index++) + for (index = 0; index < _countof(statusModeList); index++) if (status == statusModeList[index]) break; - if (index == SIZEOF(statusModeList)) + if (index == _countof(statusModeList)) index = 0; if (szProto == NULL) return index + 1; @@ -188,7 +188,7 @@ static void AddProtoIconIndex(PROTOACCOUNT *pa) { ProtoIconIndex *pii = new ProtoIconIndex; pii->szProto = pa->szModuleName; - for (int i=0; i < SIZEOF(statusModeList); i++) { + for (int i=0; i < _countof(statusModeList); i++) { int iImg = ImageList_AddIcon_ProtoIconLibLoaded(hCListImages, pa->szModuleName, statusModeList[i]); if (i == 0) pii->iIconBase = iImg; @@ -268,12 +268,12 @@ static int CListIconsChanged(WPARAM, LPARAM) { int i, j; - for (i=0; i < SIZEOF(statusModeList); i++) + for (i=0; i < _countof(statusModeList); i++) ImageList_ReplaceIcon_IconLibLoaded(hCListImages, i + 1, Skin_LoadIcon(skinIconStatusList[i])); ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPOPEN, Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN)); ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPSHUT, Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT)); for (i=0; i < protoIconIndex.getCount(); i++) - for (j = 0; j < SIZEOF(statusModeList); j++) + for (j = 0; j < _countof(statusModeList); j++) ImageList_ReplaceIcon_IconLibLoaded(hCListImages, protoIconIndex[i].iIconBase + j, Skin_LoadProtoIcon(protoIconIndex[i].szProto, statusModeList[j])); cli.pfnTrayIconIconsChanged(); cli.pfnInvalidateRect(cli.hwndContactList, NULL, TRUE); @@ -460,7 +460,7 @@ static INT_PTR CompareContacts(WPARAM wParam, LPARAM lParam) nameb = cli.pfnGetContactDisplayName(a, 0); _tcsncpy_s(namea, nameb, _TRUNCATE); - namea[ SIZEOF(namea)-1 ] = 0; + namea[ _countof(namea)-1 ] = 0; nameb = cli.pfnGetContactDisplayName(b, 0); //otherwise just compare names @@ -513,7 +513,7 @@ int LoadContactListModule2(void) ImageList_AddIcon_NotShared(hCListImages, MAKEINTRESOURCE(IDI_BLANK)); //now all core skin icons are loaded via icon lib. so lets release them - for (int i=0; i < SIZEOF(statusModeList); i++) + for (int i=0; i < _countof(statusModeList); i++) ImageList_AddIcon_IconLibLoaded(hCListImages, skinIconStatusList[i]); //see IMAGE_GROUP... in clist.h if you add more images above here diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp index 93bde38516..556b4dc30d 100644 --- a/src/mir_app/src/clisttray.cpp +++ b/src/mir_app/src/clisttray.cpp @@ -186,7 +186,7 @@ int fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int s cli.pfnTrayIconMakeTooltip(NULL, p.szProto); if (!hasTips()) - mir_tstrncpy(nid.szTip, cli.szTip, SIZEOF(nid.szTip)); + mir_tstrncpy(nid.szTip, cli.szTip, _countof(nid.szTip)); replaceStrT(p.ptszToolTip, cli.szTip); Shell_NotifyIcon(NIM_ADD, &nid); @@ -343,7 +343,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer mir_free(cli.trayIcon[i].ptszToolTip); cli.trayIcon[i].ptszToolTip = mir_tstrdup(cli.szTip); if (!hasTips()) - mir_tstrncpy(nid.szTip, cli.szTip, SIZEOF(nid.szTip)); + mir_tstrncpy(nid.szTip, cli.szTip, _countof(nid.szTip)); Shell_NotifyIcon(NIM_MODIFY, &nid); if (cli.trayIconCount == 1) @@ -365,7 +365,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer mir_free(cli.trayIcon[i].ptszToolTip); cli.trayIcon[i].ptszToolTip = mir_tstrdup(cli.szTip); if (!hasTips()) - mir_tstrncpy(nid.szTip, cli.szTip, SIZEOF(nid.szTip)); + mir_tstrncpy(nid.szTip, cli.szTip, _countof(nid.szTip)); Shell_NotifyIcon(NIM_MODIFY, &nid); if (cli.trayIconCount == 1) @@ -819,10 +819,10 @@ int fnCListTrayNotify(MIRANDASYSTRAYNOTIFY* msn) nid.hWnd = cli.hwndContactList; nid.uID = iconId; nid.uFlags = NIF_INFO; - mir_wstrncpy(nid.szInfo, msn->tszInfo, SIZEOF(nid.szInfo)); - mir_wstrncpy(nid.szInfoTitle, msn->tszInfoTitle, SIZEOF(nid.szInfoTitle)); - nid.szInfo[SIZEOF(nid.szInfo) - 1] = 0; - nid.szInfoTitle[SIZEOF(nid.szInfoTitle) - 1] = 0; + mir_wstrncpy(nid.szInfo, msn->tszInfo, _countof(nid.szInfo)); + mir_wstrncpy(nid.szInfoTitle, msn->tszInfoTitle, _countof(nid.szInfoTitle)); + nid.szInfo[_countof(nid.szInfo) - 1] = 0; + nid.szInfoTitle[_countof(nid.szInfoTitle) - 1] = 0; nid.uTimeout = msn->uTimeout; nid.dwInfoFlags = (msn->dwInfoFlags & ~NIIF_INTERN_UNICODE); return Shell_NotifyIconW(NIM_MODIFY, &nid) == 0; diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index 773e68fb5b..fc8381b0e0 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -89,7 +89,7 @@ static int MenuItem_PreBuild(WPARAM, LPARAM) { TCHAR cls[128]; HWND hwndClist = GetFocus(); - GetClassName(hwndClist, cls, SIZEOF(cls)); + GetClassName(hwndClist, cls, _countof(cls)); hwndClist = (!mir_tstrcmp( _T(CLISTCONTROL_CLASS), cls)) ? hwndClist : cli.hwndContactList; HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_GETSELECTION, 0, 0); Menu_ShowItem(hRenameMenuItem, hItem != 0); @@ -100,7 +100,7 @@ static INT_PTR MenuItem_RenameContact(WPARAM, LPARAM) { TCHAR cls[128]; HWND hwndClist = GetFocus(); - GetClassName(hwndClist, cls, SIZEOF(cls)); + GetClassName(hwndClist, cls, _countof(cls)); // worst case scenario, the rename is sent to the main contact list hwndClist = (!mir_tstrcmp( _T(CLISTCONTROL_CLASS), cls)) ? hwndClist : cli.hwndContactList; HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_GETSELECTION, 0, 0); @@ -124,8 +124,8 @@ static INT_PTR CALLBACK AskForConfirmationDlgProc(HWND hWnd, UINT msg, WPARAM wP SendDlgItemMessage(hWnd, IDC_TOPLINE, WM_SETFONT, (WPARAM) CreateFontIndirect(&lf), 0); TCHAR szFormat[256], szFinal[256]; - GetDlgItemText(hWnd, IDC_TOPLINE, szFormat, SIZEOF(szFormat)); - mir_sntprintf(szFinal, SIZEOF(szFinal), szFormat, cli.pfnGetContactDisplayName(lParam, 0)); + GetDlgItemText(hWnd, IDC_TOPLINE, szFormat, _countof(szFormat)); + mir_sntprintf(szFinal, _countof(szFinal), szFormat, cli.pfnGetContactDisplayName(lParam, 0)); SetDlgItemText(hWnd, IDC_TOPLINE, szFinal); } SetFocus( GetDlgItem(hWnd, IDNO)); @@ -279,9 +279,9 @@ int LoadCLUIModule(void) RegisterClassEx(&wndclass); if (db_get_ts(NULL, "CList", "TitleText", &dbv)) - mir_tstrncpy(titleText, _T(MIRANDANAME), SIZEOF(titleText)); + mir_tstrncpy(titleText, _T(MIRANDANAME), _countof(titleText)); else { - mir_tstrncpy(titleText, dbv.ptszVal, SIZEOF(titleText)); + mir_tstrncpy(titleText, dbv.ptszVal, _countof(titleText)); db_free(&dbv); } @@ -412,7 +412,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM TCHAR profile[MAX_PATH]; int rc; // wParam = (ATOM)hProfileAtom, lParam = 0 - if (GlobalGetAtomName((ATOM) wParam, profile, SIZEOF(profile))) { + if (GlobalGetAtomName((ATOM) wParam, profile, _countof(profile))) { rc = mir_tstrcmpi(profile, VARST(_T("%miranda_userdata%\\%miranda_profilename%.dat"))) == 0; ReplyMessage(rc); if (rc) { @@ -1003,7 +1003,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM PROTOACCOUNT *pa; TCHAR tszName[64]; if ((pa = Proto_GetAccount(szProto)) != NULL) - mir_sntprintf(tszName, SIZEOF(tszName), _T("%s "), pa->tszAccountName); + mir_sntprintf(tszName, _countof(tszName), _T("%s "), pa->tszAccountName); else tszName[0] = 0; diff --git a/src/mir_app/src/cluiservices.cpp b/src/mir_app/src/cluiservices.cpp index e5f08af088..cdb2577093 100644 --- a/src/mir_app/src/cluiservices.cpp +++ b/src/mir_app/src/cluiservices.cpp @@ -43,7 +43,7 @@ static INT_PTR GroupAdded(WPARAM wParam, LPARAM lParam) TCHAR szFocusClass[64]; HWND hwndFocus = GetFocus(); - GetClassName(hwndFocus, szFocusClass, SIZEOF(szFocusClass)); + GetClassName(hwndFocus, szFocusClass, _countof(szFocusClass)); if (!mir_tstrcmp(szFocusClass, _T(CLISTCONTROL_CLASS))) { hItem = (HANDLE) SendMessage(hwndFocus, CLM_FINDGROUP, wParam, 0); if (hItem) @@ -179,11 +179,11 @@ void fnCluiProtocolStatusChanged(int, const char*) TCHAR tszName[64]; PROTOACCOUNT *pa = Proto_GetAccount(cli.menuProtos[i].szProto); if (pa) - mir_sntprintf(tszName, SIZEOF(tszName), _T("%s "), pa->tszAccountName); + mir_sntprintf(tszName, _countof(tszName), _T("%s "), pa->tszAccountName); else tszName[0] = 0; - if (showOpts & 4 && mir_tstrlen(tszName) < SIZEOF(tszName)-1) + if (showOpts & 4 && mir_tstrlen(tszName) < _countof(tszName)-1) mir_tstrcat(tszName, _T(" ")); GetTextExtentPoint32(hdc, tszName, (int)mir_tstrlen(tszName), &textSize); x += textSize.cx; diff --git a/src/mir_app/src/contact.cpp b/src/mir_app/src/contact.cpp index f4f9296c63..560eb60d5a 100644 --- a/src/mir_app/src/contact.cpp +++ b/src/mir_app/src/contact.cpp @@ -62,7 +62,7 @@ void fnChangeContactIcon(MCONTACT hContact, int iIcon, int add) int GetStatusModeOrdering(int statusMode) { int i; - for (i=0; i < SIZEOF(statusModeOrder); i++) + for (i=0; i < _countof(statusModeOrder); i++) if (statusModeOrder[i].status == statusMode) return statusModeOrder[i].order; return 1000; @@ -126,7 +126,7 @@ int fnCompareContacts(const ClcContact* c1, const ClcContact* c2) nameb = cli.pfnGetContactDisplayName(a, 0); _tcsncpy_s(namea, nameb, _TRUNCATE); - namea[ SIZEOF(namea)-1 ] = 0; + namea[ _countof(namea)-1 ] = 0; nameb = cli.pfnGetContactDisplayName(b, 0); //otherwise just compare names diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index b20b201228..170ffdf9e4 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -393,7 +393,7 @@ public: tvis.hParent = NULL; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_TEXT | TVIF_PARAM; - for (int i = 0; i < SIZEOF(nameOrderDescr); i++) { + for (int i = 0; i < _countof(nameOrderDescr); i++) { tvis.item.lParam = nameOrder[i]; tvis.item.pszText = TranslateTS(nameOrderDescr[nameOrder[i]]); m_nameOrder.InsertItem(&tvis); @@ -411,14 +411,14 @@ public: nameOrder[i++] = (BYTE)tvi.lParam; tvi.hItem = m_nameOrder.GetNextSibling(tvi.hItem); } - db_set_blob(NULL, "Contact", "NameOrder", nameOrder, SIZEOF(nameOrderDescr)); + db_set_blob(NULL, "Contact", "NameOrder", nameOrder, _countof(nameOrderDescr)); CallService(MS_CLIST_INVALIDATEDISPLAYNAME, (WPARAM)INVALID_HANDLE_VALUE, 0); } void OnBeginDrag(CCtrlTreeView::TEventInfo *evt) { LPNMTREEVIEW pNotify = evt->nmtv; - if (pNotify->itemNew.lParam == 0 || pNotify->itemNew.lParam == SIZEOF(nameOrderDescr) - 1) + if (pNotify->itemNew.lParam == 0 || pNotify->itemNew.lParam == _countof(nameOrderDescr) - 1) pNotify->hdr.code = 0; // deny dragging } }; diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp index 802840cb5e..286a8f4793 100644 --- a/src/mir_app/src/database.cpp +++ b/src/mir_app/src/database.cpp @@ -73,7 +73,7 @@ bool IsInsideRootDir(TCHAR* profiledir, bool exact) int getProfilePath(TCHAR *buf, size_t) { TCHAR profiledir[MAX_PATH]; - GetPrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), profiledir, SIZEOF(profiledir), mirandabootini); + GetPrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), profiledir, _countof(profiledir), mirandabootini); if (profiledir[0] == 0) mir_tstrcpy(profiledir, _T("%miranda_path%\\Profiles")); @@ -102,7 +102,7 @@ static bool showProfileManager(void) return 1; // wanna show it? - GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T("never"), Mgr, SIZEOF(Mgr), mirandabootini); + GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T("never"), Mgr, _countof(Mgr), mirandabootini); return (mir_tstrcmpi(Mgr, _T("yes")) == 0); } @@ -112,14 +112,14 @@ bool shouldAutoCreate(TCHAR *szProfile) return false; TCHAR ac[32]; - GetPrivateProfileString(_T("Database"), _T("AutoCreate"), _T(""), ac, SIZEOF(ac), mirandabootini); + GetPrivateProfileString(_T("Database"), _T("AutoCreate"), _T(""), ac, _countof(ac), mirandabootini); return mir_tstrcmpi(ac, _T("yes")) == 0; } static void getDefaultProfile(TCHAR *szProfile, size_t cch) { TCHAR defaultProfile[MAX_PATH]; - GetPrivateProfileString(_T("Database"), _T("DefaultProfile"), _T(""), defaultProfile, SIZEOF(defaultProfile), mirandabootini); + GetPrivateProfileString(_T("Database"), _T("DefaultProfile"), _T(""), defaultProfile, _countof(defaultProfile), mirandabootini); if (defaultProfile[0] == 0) return; @@ -186,7 +186,7 @@ static void moveProfileDirProfiles(TCHAR *profiledir, BOOL isRootDir = TRUE) if (isRootDir) _tcsncpy_s(pfd, VARST(_T("%miranda_path%\\*.dat")), _TRUNCATE); else - mir_sntprintf(pfd, SIZEOF(pfd), _T("%s\\*.dat"), profiledir); + mir_sntprintf(pfd, _countof(pfd), _T("%s\\*.dat"), profiledir); WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(pfd, &ffd); @@ -196,10 +196,10 @@ static void moveProfileDirProfiles(TCHAR *profiledir, BOOL isRootDir = TRUE) TCHAR path[MAX_PATH], path2[MAX_PATH]; TCHAR* profile = mir_tstrdup(ffd.cFileName); TCHAR *c = _tcsrchr(profile, '.'); if (c) *c = 0; - mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), pfd, ffd.cFileName); - mir_sntprintf(path2, SIZEOF(path2), _T("%s\\%s"), profiledir, profile); + mir_sntprintf(path, _countof(path), _T("%s\\%s"), pfd, ffd.cFileName); + mir_sntprintf(path2, _countof(path2), _T("%s\\%s"), profiledir, profile); CreateDirectoryTreeT(path2); - mir_sntprintf(path2, SIZEOF(path2), _T("%s\\%s\\%s"), profiledir, profile, ffd.cFileName); + mir_sntprintf(path2, _countof(path2), _T("%s\\%s\\%s"), profiledir, profile, ffd.cFileName); if (_taccess(path2, 0) == 0) { TCHAR buf[512]; mir_sntprintf(buf, @@ -241,7 +241,7 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n if (bShowProfileManager || !reqfd) { TCHAR searchspec[MAX_PATH]; - mir_sntprintf(searchspec, SIZEOF(searchspec), _T("%s\\*.*"), profiledir); + mir_sntprintf(searchspec, _countof(searchspec), _T("%s\\*.*"), profiledir); WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(searchspec, &ffd); @@ -252,7 +252,7 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n continue; TCHAR newProfile[MAX_PATH]; - mir_sntprintf(newProfile, SIZEOF(newProfile), _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName); + mir_sntprintf(newProfile, _countof(newProfile), _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName); if (_taccess(newProfile, 0) != 0) continue; @@ -287,7 +287,7 @@ static int getProfileAutoRun(TCHAR *szProfile) return false; TCHAR Mgr[32]; - GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T(""), Mgr, SIZEOF(Mgr), mirandabootini); + GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T(""), Mgr, _countof(Mgr), mirandabootini); if (mir_tstrcmpi(Mgr, _T("never"))) return 0; @@ -297,10 +297,10 @@ static int getProfileAutoRun(TCHAR *szProfile) // returns 1 if a profile was selected static int getProfile(TCHAR *szProfile, size_t cch) { - getProfilePath(g_profileDir, SIZEOF(g_profileDir)); + getProfilePath(g_profileDir, _countof(g_profileDir)); if (IsInsideRootDir(g_profileDir, true)) if (WritePrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), mirandabootini)) - getProfilePath(g_profileDir, SIZEOF(g_profileDir)); + getProfilePath(g_profileDir, _countof(g_profileDir)); getDefaultProfile(szProfile, cch); getProfileCmdLine(szProfile, cch); @@ -458,7 +458,7 @@ static BOOL CALLBACK EnumMirandaWindows(HWND hwnd, LPARAM lParam) TCHAR classname[256]; ENUMMIRANDAWINDOW *x = (ENUMMIRANDAWINDOW *)lParam; DWORD_PTR res = 0; - if (GetClassName(hwnd, classname, SIZEOF(classname)) && mir_tstrcmp(_T("Miranda"), classname) == 0) { + if (GetClassName(hwnd, classname, _countof(classname)) && mir_tstrcmp(_T("Miranda"), classname) == 0) { if (SendMessageTimeout(hwnd, x->msg, (WPARAM)x->aPath, 0, SMTO_ABORTIFHUNG, 100, &res) && res) { x->found++; return FALSE; @@ -488,7 +488,7 @@ int LoadDatabaseModule(void) LoadDatabaseServices(); // find out which profile to load - if (!getProfile(szProfile, SIZEOF(szProfile))) + if (!getProfile(szProfile, _countof(szProfile))) return 1; if (arDbPlugins.getCount() == 0) { diff --git a/src/mir_app/src/dbini.cpp b/src/mir_app/src/dbini.cpp index 50f10dfee6..b876f89c16 100644 --- a/src/mir_app/src/dbini.cpp +++ b/src/mir_app/src/dbini.cpp @@ -38,7 +38,7 @@ static INT_PTR CALLBACK InstallIniDlgProc(HWND hwndDlg, UINT message, WPARAM wPa TCHAR szSecurity[11]; const TCHAR *pszSecurityInfo; - GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, _countof(szSecurity), mirandabootini); if (!mir_tstrcmpi(szSecurity, _T("all"))) pszSecurityInfo = LPGENT("Security systems to prevent malicious changes are in place and you will be warned before every change that is made."); else if (!mir_tstrcmpi(szSecurity, _T("onlyunsafe"))) @@ -55,7 +55,7 @@ static INT_PTR CALLBACK InstallIniDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case IDC_VIEWINI: { TCHAR szPath[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_ININAME, szPath, SIZEOF(szPath)); + GetDlgItemText(hwndDlg, IDC_ININAME, szPath, _countof(szPath)); ShellExecute(hwndDlg, _T("open"), szPath, NULL, NULL, SW_SHOW); } break; @@ -154,7 +154,7 @@ static INT_PTR CALLBACK IniImportDoneDlgProc(HWND hwndDlg, UINT message, WPARAM return TRUE; case WM_COMMAND: - GetDlgItemText(hwndDlg, IDC_ININAME, szIniPath, SIZEOF(szIniPath)); + GetDlgItemText(hwndDlg, IDC_ININAME, szIniPath, _countof(szIniPath)); switch (LOWORD(wParam)) { case IDC_DELETE: DeleteFile(szIniPath); @@ -174,7 +174,7 @@ static INT_PTR CALLBACK IniImportDoneDlgProc(HWND hwndDlg, UINT message, WPARAM break; case IDC_MOVE: TCHAR szNewPath[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_NEWNAME, szNewPath, SIZEOF(szNewPath)); + GetDlgItemText(hwndDlg, IDC_NEWNAME, szNewPath, _countof(szNewPath)); MoveFile(szIniPath, szNewPath); EndDialog(hwndDlg, LOWORD(wParam)); break; @@ -409,22 +409,22 @@ static void DoAutoExec(void) TCHAR szUse[7], szIniPath[MAX_PATH], szFindPath[MAX_PATH]; TCHAR buf[2048], szSecurity[11], szOverrideSecurityFilename[MAX_PATH], szOnCreateFilename[MAX_PATH]; - GetPrivateProfileString(_T("AutoExec"), _T("Use"), _T("prompt"), szUse, SIZEOF(szUse), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("Use"), _T("prompt"), szUse, _countof(szUse), mirandabootini); if (!mir_tstrcmpi(szUse, _T("no"))) return; - GetPrivateProfileString(_T("AutoExec"), _T("Safe"), _T("CLC Icons CLUI CList SkinSounds"), buf, SIZEOF(buf), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("Safe"), _T("CLC Icons CLUI CList SkinSounds"), buf, _countof(buf), mirandabootini); ptrA szSafeSections(mir_t2a(buf)); - GetPrivateProfileString(_T("AutoExec"), _T("Unsafe"), _T("AIM Facebook GG ICQ IRC JABBER MRA MSN SKYPE Tlen TWITTER VKontakte XFire"), buf, SIZEOF(buf), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("Unsafe"), _T("AIM Facebook GG ICQ IRC JABBER MRA MSN SKYPE Tlen TWITTER VKontakte XFire"), buf, _countof(buf), mirandabootini); ptrA szUnsafeSections(mir_t2a(buf)); - GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, _countof(szSecurity), mirandabootini); int secur = 0; if (!mir_tstrcmpi(szSecurity, _T("none"))) secur = 0; else if (!mir_tstrcmpi(szSecurity, _T("notsafe"))) secur = 1; else if (!mir_tstrcmpi(szSecurity, _T("onlyunsafe"))) secur = 2; - GetPrivateProfileString(_T("AutoExec"), _T("OverrideSecurityFilename"), _T(""), szOverrideSecurityFilename, SIZEOF(szOverrideSecurityFilename), mirandabootini); - GetPrivateProfileString(_T("AutoExec"), _T("OnCreateFilename"), _T(""), szOnCreateFilename, SIZEOF(szOnCreateFilename), mirandabootini); - GetPrivateProfileString(_T("AutoExec"), _T("Glob"), _T("autoexec_*.ini"), szFindPath, SIZEOF(szFindPath), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("OverrideSecurityFilename"), _T(""), szOverrideSecurityFilename, _countof(szOverrideSecurityFilename), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("OnCreateFilename"), _T(""), szOnCreateFilename, _countof(szOnCreateFilename), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("Glob"), _T("autoexec_*.ini"), szFindPath, _countof(szFindPath), mirandabootini); if (g_bDbCreated && szOnCreateFilename[0]) { PathToAbsoluteT(VARST(szOnCreateFilename), szIniPath); @@ -447,7 +447,7 @@ static void DoAutoExec(void) do { bool secFN = mir_tstrcmpi(fd.cFileName, szOverrideSecurityFilename) == 0; - mir_sntprintf(szIniPath, SIZEOF(szIniPath), _T("%s%s"), szFindPath, fd.cFileName); + mir_sntprintf(szIniPath, _countof(szIniPath), _T("%s%s"), szFindPath, fd.cFileName); if (!mir_tstrcmpi(szUse, _T("prompt")) && !secFN) { int result = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_INSTALLINI), NULL, InstallIniDlgProc, (LPARAM)szIniPath); if (result == IDC_NOTOALL) break; @@ -460,7 +460,7 @@ static void DoAutoExec(void) DeleteFile(szIniPath); else { TCHAR szOnCompletion[8]; - GetPrivateProfileString(_T("AutoExec"), _T("OnCompletion"), _T("recycle"), szOnCompletion, SIZEOF(szOnCompletion), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("OnCompletion"), _T("recycle"), szOnCompletion, _countof(szOnCompletion), mirandabootini); if (!mir_tstrcmpi(szOnCompletion, _T("delete"))) DeleteFile(szIniPath); else if (!mir_tstrcmpi(szOnCompletion, _T("recycle"))) { @@ -473,7 +473,7 @@ static void DoAutoExec(void) } else if (!mir_tstrcmpi(szOnCompletion, _T("rename"))) { TCHAR szRenamePrefix[MAX_PATH], szNewPath[MAX_PATH]; - GetPrivateProfileString(_T("AutoExec"), _T("RenamePrefix"), _T("done_"), szRenamePrefix, SIZEOF(szRenamePrefix), mirandabootini); + GetPrivateProfileString(_T("AutoExec"), _T("RenamePrefix"), _T("done_"), szRenamePrefix, _countof(szRenamePrefix), mirandabootini); mir_tstrcpy(szNewPath, szFindPath); mir_tstrcat(szNewPath, szRenamePrefix); mir_tstrcat(szNewPath, fd.cFileName); diff --git a/src/mir_app/src/dbutils.cpp b/src/mir_app/src/dbutils.cpp index 18e6bac54f..c8a9e9dbea 100644 --- a/src/mir_app/src/dbutils.cpp +++ b/src/mir_app/src/dbutils.cpp @@ -61,12 +61,12 @@ static INT_PTR DbEventTypeRegister(WPARAM, LPARAM lParam) if (!p->textService) { char szServiceName[100]; - mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s/GetEventText%d", p->module, p->eventType); + mir_snprintf(szServiceName, _countof(szServiceName), "%s/GetEventText%d", p->module, p->eventType); p->textService = mir_strdup(szServiceName); } if (!p->iconService) { char szServiceName[100]; - mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s/GetEventIcon%d", p->module, p->eventType); + mir_snprintf(szServiceName, _countof(szServiceName), "%s/GetEventIcon%d", p->module, p->eventType); p->iconService = mir_strdup(szServiceName); } eventTypes.insert(p); @@ -216,7 +216,7 @@ static INT_PTR DbEventGetIcon(WPARAM wParam, LPARAM lParam) icon = IcoLib_GetIconByHandle(et->eventIcon); if (!icon) { char szName[100]; - mir_snprintf(szName, SIZEOF(szName), "eventicon_%s%d", dbei->szModule, dbei->eventType); + mir_snprintf(szName, _countof(szName), "eventicon_%s%d", dbei->szModule, dbei->eventType); icon = IcoLib_GetIcon(szName); } diff --git a/src/mir_app/src/extraicons.cpp b/src/mir_app/src/extraicons.cpp index 820ee03900..ff11fbfed4 100644 --- a/src/mir_app/src/extraicons.cpp +++ b/src/mir_app/src/extraicons.cpp @@ -520,7 +520,7 @@ void LoadExtraIconsModule() hEventExtraImageListRebuilding = CreateHookableEvent(ME_CLIST_EXTRA_LIST_REBUILD); // Icons - Icon_Register(g_hInst, LPGEN("Contact list"), iconList, SIZEOF(iconList)); + Icon_Register(g_hInst, LPGEN("Contact list"), iconList, _countof(iconList)); // Hooks HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); diff --git a/src/mir_app/src/filter.cpp b/src/mir_app/src/filter.cpp index 83f91c407c..9a99e7eac7 100644 --- a/src/mir_app/src/filter.cpp +++ b/src/mir_app/src/filter.cpp @@ -59,7 +59,7 @@ void AddTreeViewNodes(HWND hWndDlg, PageHash key, HTREEITEM root) item.mask = TVIF_TEXT; item.hItem = root; item.pszText = title; - item.cchTextMax = SIZEOF(title); + item.cchTextMax = _countof(title); if (TreeView_GetItem(hWndDlg, &item)) if (mir_tstrlen(title) > 0) @@ -78,12 +78,12 @@ void AddTreeViewNodes(HWND hWndDlg, PageHash key, HTREEITEM root) void AddDialogString(HWND hWndDlg, const PageHash key) { TCHAR title[2048]; - GetWindowText(hWndDlg, title, SIZEOF(title)); + GetWindowText(hWndDlg, title, _countof(title)); if (mir_tstrlen(title) > 0) AddFilterString(key, title); TCHAR szClass[64]; - GetClassName(hWndDlg, szClass, SIZEOF(szClass)); + GetClassName(hWndDlg, szClass, _countof(szClass)); if (mir_tstrcmpi(szClass, _T("SysTreeView32")) == 0) { HTREEITEM hItem = TreeView_GetRoot(hWndDlg); @@ -98,7 +98,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) title[0] = 0; //safety int res = ListBox_GetText(hWndDlg, i, title); if (res != LB_ERR) { - title[SIZEOF(title) - 1] = 0; + title[_countof(title) - 1] = 0; if (mir_tstrlen(title) > 0) AddFilterString(key, title); } @@ -111,7 +111,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) int count = ListView_GetItemCount(hWndDlg); for (int i=0; i < count; i++) { title[0] = 0; //safety - ListView_GetItemText(hWndDlg, i, 0, title, SIZEOF(title)); + ListView_GetItemText(hWndDlg, i, 0, title, _countof(title)); if (mir_tstrlen(title) > 0) AddFilterString(key, title); @@ -126,7 +126,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) title[0] = 0; //safety int res = ComboBox_GetLBText(hWndDlg, i, title); if (res != CB_ERR) { - title[SIZEOF(title) - 1] = 0; + title[_countof(title) - 1] = 0; if (mir_tstrlen(title) > 0) AddFilterString(key, title); diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp index b1d470eacd..db81e02da2 100644 --- a/src/mir_app/src/findadd.cpp +++ b/src/mir_app/src/findadd.cpp @@ -284,7 +284,7 @@ static const int controls[] = { IDC_BYPROTOID, IDC_BYEMAIL, IDC_BYNAME, IDC_BYAD static void CheckSearchTypeRadioButton(HWND hwndDlg, int idControl) { - for (int i = 0; i < SIZEOF(controls); i++) + for (int i = 0; i < _countof(controls); i++) CheckDlgButton(hwndDlg, controls[i], idControl == controls[i] ? BST_CHECKED : BST_UNCHECKED); } @@ -359,7 +359,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc); partWidth[1] = partWidth[0] + 150; partWidth[2] = -1; - SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, SIZEOF(partWidth), (LPARAM)partWidth); + SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, _countof(partWidth), (LPARAM)partWidth); SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0); SetStatusBarSearchInfo(GetDlgItem(hwndDlg, IDC_STATUSBAR), dat); @@ -703,7 +703,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP BeginSearch(hwndDlg, dat, szProto, PS_SEARCHBYADVANCED, PF1_EXTSEARCHUI, dat->hwndTinySearch); else if (IsDlgButtonChecked(hwndDlg, IDC_BYPROTOID)) { TCHAR str[256]; - GetDlgItemText(hwndDlg, IDC_PROTOID, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_PROTOID, str, _countof(str)); rtrimt(str); if (str[0] == 0) MessageBox(hwndDlg, sttErrMsg, sttErrTitle, MB_ICONERROR | MB_OK); @@ -712,7 +712,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } else if (IsDlgButtonChecked(hwndDlg, IDC_BYEMAIL)) { TCHAR str[256]; - GetDlgItemText(hwndDlg, IDC_EMAIL, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_EMAIL, str, _countof(str)); rtrimt(str); if (str[0] == 0) MessageBox(hwndDlg, sttErrMsg, sttErrTitle, MB_ICONERROR | MB_OK); @@ -722,9 +722,9 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP else if (IsDlgButtonChecked(hwndDlg, IDC_BYNAME)) { TCHAR nick[256], first[256], last[256]; PROTOSEARCHBYNAME psbn; - GetDlgItemText(hwndDlg, IDC_NAMENICK, nick, SIZEOF(nick)); - GetDlgItemText(hwndDlg, IDC_NAMEFIRST, first, SIZEOF(first)); - GetDlgItemText(hwndDlg, IDC_NAMELAST, last, SIZEOF(last)); + GetDlgItemText(hwndDlg, IDC_NAMENICK, nick, _countof(nick)); + GetDlgItemText(hwndDlg, IDC_NAMEFIRST, first, _countof(first)); + GetDlgItemText(hwndDlg, IDC_NAMELAST, last, _countof(last)); psbn.pszFirstName = first; psbn.pszLastName = last; psbn.pszNick = nick; @@ -774,7 +774,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } else { TCHAR str[256]; - GetDlgItemText(hwndDlg, IDC_PROTOID, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_PROTOID, str, _countof(str)); if (*rtrimt(str) == 0) break; diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp index 3246544f40..6e87b6f397 100644 --- a/src/mir_app/src/genmenu.cpp +++ b/src/mir_app/src/genmenu.cpp @@ -917,13 +917,13 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para DBVARIANT dbv = { 0 }; int pos; char MenuNameItems[256]; - mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pmo->pszName); + mir_snprintf(MenuNameItems, _countof(MenuNameItems), "%s_Items", pmo->pszName); char menuItemName[256]; GetMenuItemName(pmi, menuItemName, sizeof(menuItemName)); // check if it visible - mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_visible", menuItemName); if (db_get_b(NULL, MenuNameItems, DBString, -1) == -1) db_set_b(NULL, MenuNameItems, DBString, 1); @@ -934,14 +934,14 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para } // mi.pszName - mir_snprintf(DBString, SIZEOF(DBString), "%s_name", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_name", menuItemName); if (!db_get_ts(NULL, MenuNameItems, DBString, &dbv)) { if (mir_tstrlen(dbv.ptszVal) > 0) replaceStrT(pmi->CustomName, dbv.ptszVal); db_free(&dbv); } - mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_pos", menuItemName); if ((pos = db_get_dw(NULL, MenuNameItems, DBString, -1)) == -1) { db_set_dw(NULL, MenuNameItems, DBString, mi->position); if (pmi->submenu.first) @@ -986,7 +986,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para #ifdef PUTPOSITIONSONMENU if (GetKeyState(VK_CONTROL) & 0x8000) { TCHAR str[256]; - mir_sntprintf(str, SIZEOF(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData); + mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData); mii.dwTypeData = str; } #endif @@ -1001,7 +1001,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para #ifdef PUTPOSITIONSONMENU if (GetKeyState(VK_CONTROL) & 0x8000) { TCHAR str[256]; - mir_sntprintf(str, SIZEOF(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData); + mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData); mii.dwTypeData = str; } #endif @@ -1060,10 +1060,10 @@ static int MO_RegisterIcon(PMO_IntMenuItem pmi, void*) HICON hIcon = ImageList_GetIcon(pmi->parent->m_hMenuIcons, pmi->iconId, 0); TCHAR sectionName[256]; - mir_sntprintf(sectionName, SIZEOF(sectionName), LPGENT("Menu icons") _T("/%s"), TranslateTS(pmi->parent->ptszDisplayName)); + mir_sntprintf(sectionName, _countof(sectionName), LPGENT("Menu icons") _T("/%s"), TranslateTS(pmi->parent->ptszDisplayName)); char iconame[256]; - mir_snprintf(iconame, SIZEOF(iconame), "genmenu_%s_%s", pmi->parent->pszName, uname && *uname ? uname : descr); + mir_snprintf(iconame, _countof(iconame), "genmenu_%s_%s", pmi->parent->pszName, uname && *uname ? uname : descr); // remove '&' if (descr) { diff --git a/src/mir_app/src/genmenuopt.cpp b/src/mir_app/src/genmenuopt.cpp index 424488d4ea..db302e59da 100644 --- a/src/mir_app/src/genmenuopt.cpp +++ b/src/mir_app/src/genmenuopt.cpp @@ -73,7 +73,7 @@ class CGenMenuOptionsPage : public CDlgBase TVITEMEX tvi; tvi.hItem = m_menuItems.GetRoot(); - tvi.cchTextMax = SIZEOF(idstr); + tvi.cchTextMax = _countof(idstr); tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE; tvi.pszText = idstr; @@ -85,7 +85,7 @@ class CGenMenuOptionsPage : public CDlgBase TIntMenuObject *pimo = g_menus[menupos]; char MenuNameItems[256]; - mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName); + mir_snprintf(MenuNameItems, _countof(MenuNameItems), "%s_Items", pimo->pszName); int runtimepos = 100; while (tvi.hItem != NULL) { @@ -95,13 +95,13 @@ class CGenMenuOptionsPage : public CDlgBase char menuItemName[256], DBString[300]; GetMenuItemName(iod->pimi, menuItemName, sizeof(menuItemName)); - mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_visible", menuItemName); db_set_b(NULL, MenuNameItems, DBString, tvi.iImage != 0); - mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_pos", menuItemName); db_set_dw(NULL, MenuNameItems, DBString, runtimepos); - mir_snprintf(DBString, SIZEOF(DBString), "%s_name", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_name", menuItemName); if (iod->name != NULL && iod->defname != NULL && mir_tstrcmp(iod->name, iod->defname) != 0) db_set_ts(NULL, MenuNameItems, DBString, iod->name); @@ -156,7 +156,7 @@ class CGenMenuOptionsPage : public CDlgBase return false; char menuItemName[256], MenuNameItems[256]; - mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName); + mir_snprintf(MenuNameItems, _countof(MenuNameItems), "%s_Items", pimo->pszName); LIST arItems(10, SortMenuItems); diff --git a/src/mir_app/src/groups.cpp b/src/mir_app/src/groups.cpp index 8ad218df03..9775eb39ba 100644 --- a/src/mir_app/src/groups.cpp +++ b/src/mir_app/src/groups.cpp @@ -81,13 +81,13 @@ static INT_PTR CreateGroupInternal(INT_PTR iParent, const TCHAR *ptszName) if (db_get_ts(NULL, "CListGroups", str, &dbv)) return 0; - mir_sntprintf(newBaseName, SIZEOF(newBaseName), _T("%s\\%s"), dbv.ptszVal + 1, grpName); + mir_sntprintf(newBaseName, _countof(newBaseName), _T("%s\\%s"), dbv.ptszVal + 1, grpName); mir_free(dbv.pszVal); } - else mir_tstrncpy(newBaseName, grpName, SIZEOF(newBaseName)); + else mir_tstrncpy(newBaseName, grpName, _countof(newBaseName)); _itoa(newId, str, 10); - mir_tstrncpy(newName + 1, newBaseName, SIZEOF(newName) - 1); + mir_tstrncpy(newName + 1, newBaseName, _countof(newName) - 1); if (ptszName) { i = GroupNameExists(newBaseName, -1); if (i) newId = i - 1; @@ -96,7 +96,7 @@ static INT_PTR CreateGroupInternal(INT_PTR iParent, const TCHAR *ptszName) else { i = 1; while (GroupNameExists(newName + 1, -1)) - mir_sntprintf(newName + 1, SIZEOF(newName) - 1, _T("%s (%d)"), newBaseName, i++); + mir_sntprintf(newName + 1, _countof(newName) - 1, _T("%s (%d)"), newBaseName, i++); } if (i) { const CLISTGROUPCHANGE grpChg = { sizeof(CLISTGROUPCHANGE), NULL, newName }; @@ -140,7 +140,7 @@ static INT_PTR GetGroupName2(WPARAM wParam, LPARAM lParam) _itoa(wParam - 1, idstr, 10); if (db_get_s(NULL, "CListGroups", idstr, &dbv)) return (INT_PTR) (char *) NULL; - mir_strncpy(name, dbv.pszVal + 1, SIZEOF(name)); + mir_strncpy(name, dbv.pszVal + 1, _countof(name)); if ((DWORD *) lParam != NULL) *(DWORD *) lParam = dbv.pszVal[0]; db_free(&dbv); @@ -157,7 +157,7 @@ TCHAR* fnGetGroupName(int idx, DWORD* pdwFlags) if (db_get_ts(NULL, "CListGroups", idstr, &dbv)) return NULL; - mir_tstrncpy(name, dbv.ptszVal + 1, SIZEOF(name)); + mir_tstrncpy(name, dbv.ptszVal + 1, _countof(name)); if (pdwFlags != NULL) *pdwFlags = dbv.ptszVal[0]; db_free(&dbv); @@ -185,12 +185,12 @@ static INT_PTR DeleteGroup(WPARAM wParam, LPARAM) _itoa(wParam - 1, str, 10); if (db_get_ts(NULL, "CListGroups", str, &dbv)) return 1; - mir_tstrncpy(name, dbv.ptszVal + 1, SIZEOF(name)); + mir_tstrncpy(name, dbv.ptszVal + 1, _countof(name)); db_free(&dbv); if (db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT)) { TCHAR szQuestion[256+100]; - mir_sntprintf(szQuestion, SIZEOF(szQuestion), TranslateT("Are you sure you want to delete group '%s'? This operation cannot be undone."), name); + mir_sntprintf(szQuestion, _countof(szQuestion), TranslateT("Are you sure you want to delete group '%s'? This operation cannot be undone."), name); if (MessageBox(cli.hwndContactList, szQuestion, TranslateT("Delete group"), MB_YESNO|MB_ICONQUESTION) == IDNO) return 1; } @@ -250,9 +250,9 @@ static INT_PTR DeleteGroup(WPARAM wParam, LPARAM) break; if (!_tcsncmp(dbv.ptszVal + 1, name, len) && dbv.pszVal[len + 1] == '\\' && _tcschr(dbv.ptszVal + len + 2, '\\') == NULL) { if (szNewParent[0]) - mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s\\%s"), szNewParent, dbv.ptszVal + len + 2); + mir_sntprintf(szNewName, _countof(szNewName), _T("%s\\%s"), szNewParent, dbv.ptszVal + len + 2); else - mir_tstrncpy(szNewName, dbv.ptszVal + len + 2, SIZEOF(szNewName)); + mir_tstrncpy(szNewName, dbv.ptszVal + len + 2, _countof(szNewName)); cli.pfnRenameGroup(i + 1, szNewName); } db_free(&dbv); @@ -284,9 +284,9 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) if (db_get_ts(NULL, "CListGroups", idstr, &dbv)) return 1; str[0] = dbv.pszVal[0] & 0x7F; - mir_tstrncpy(oldName, dbv.ptszVal + 1, SIZEOF(oldName)); + mir_tstrncpy(oldName, dbv.ptszVal + 1, _countof(oldName)); db_free(&dbv); - mir_tstrncpy(str + 1, szName, SIZEOF(str) - 1); + mir_tstrncpy(str + 1, szName, _countof(str) - 1); db_set_ts(NULL, "CListGroups", idstr, str); //must rename setting in all child contacts too @@ -311,7 +311,7 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) if (db_get_ts(NULL, "CListGroups", idstr, &dbv)) break; if (!_tcsncmp(dbv.ptszVal + 1, oldName, len) && dbv.ptszVal[len + 1] == '\\' && _tcschr(dbv.ptszVal + len + 2, '\\') == NULL) { - mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s\\%s"), szName, dbv.ptszVal + len + 2); + mir_sntprintf(szNewName, _countof(szNewName), _T("%s\\%s"), szName, dbv.ptszVal + len + 2); RenameGroupWithMove(i, szNewName, 0); //luckily, child groups will never need reordering } db_free(&dbv); @@ -323,7 +323,7 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) TCHAR *pszLastBackslash; int i; - mir_tstrncpy(str, szName, SIZEOF(str)); + mir_tstrncpy(str, szName, _countof(str)); pszLastBackslash = _tcsrchr(str, '\\'); if (pszLastBackslash != NULL) { *pszLastBackslash = '\0'; @@ -484,18 +484,18 @@ static INT_PTR BuildGroupMenu(WPARAM, LPARAM) do { pBackslash = _tcschr(pNextField, '\\'); if (pBackslash == NULL) { - mir_tstrncpy(szThisField, pNextField, SIZEOF(szThisField)); + mir_tstrncpy(szThisField, pNextField, _countof(szThisField)); pNextField = NULL; } else { - mir_tstrncpy(szThisField, pNextField, min(SIZEOF(szThisField), pBackslash - pNextField + 1)); + mir_tstrncpy(szThisField, pNextField, min(_countof(szThisField), pBackslash - pNextField + 1)); pNextField = pBackslash + 1; } compareResult = 1; menuItemCount = GetMenuItemCount(hThisMenu); for (menuId = 0; menuId < menuItemCount; menuId++) { mii.fMask = MIIM_TYPE | MIIM_SUBMENU | MIIM_DATA; - mii.cch = SIZEOF(szThisMenuItem); + mii.cch = _countof(szThisMenuItem); mii.dwTypeData = szThisMenuItem; GetMenuItemInfo(hThisMenu, menuId, TRUE, &mii); compareResult = mir_tstrcmp(szThisField, szThisMenuItem); diff --git a/src/mir_app/src/hotkey_opts.cpp b/src/mir_app/src/hotkey_opts.cpp index cd7d542a7e..015c0830cc 100644 --- a/src/mir_app/src/hotkey_opts.cpp +++ b/src/mir_app/src/hotkey_opts.cpp @@ -127,7 +127,7 @@ static LRESULT CALLBACK sttHotkeyEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP TCHAR buf[256] = { 0 }; data->key = (BYTE)LOWORD(wParam); data->shift = (BYTE)HIWORD(wParam); - HotkeyToName(buf, SIZEOF(buf), data->shift, data->key); + HotkeyToName(buf, _countof(buf), data->shift, data->key); SetWindowText(hwnd, buf); } return 0; @@ -169,7 +169,7 @@ static LRESULT CALLBACK sttHotkeyEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP data->key = key; } - HotkeyToName(buf, SIZEOF(buf), data->shift, data->key); + HotkeyToName(buf, _countof(buf), data->shift, data->key); SetWindowText(hwnd, buf); if (bKeyDown && data->key) @@ -222,7 +222,7 @@ static void sttOptionsSetupItem(HWND hwndList, int idx, THotkeyItem *item) lvi.mask = LVIF_TEXT; lvi.iSubItem = COL_KEY; - HotkeyToName(buf, SIZEOF(buf), HIBYTE(item->OptHotkey), LOBYTE(item->OptHotkey)); + HotkeyToName(buf, _countof(buf), HIBYTE(item->OptHotkey), LOBYTE(item->OptHotkey)); lvi.pszText = buf; ListView_SetItem(hwndList, &lvi); @@ -269,14 +269,14 @@ static int CALLBACK sttOptionsSortList(LPARAM lParam1, LPARAM lParam2, LPARAM lP lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iItem = lParam1; lvi.pszText = title1; - lvi.cchTextMax = SIZEOF(title1); + lvi.cchTextMax = _countof(title1); if (ListView_GetItem((HWND)lParamSort, &lvi)) item1 = (THotkeyItem *)lvi.lParam; lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iItem = lParam2; lvi.pszText = title2; - lvi.cchTextMax = SIZEOF(title2); + lvi.cchTextMax = _countof(title2); if (ListView_GetItem((HWND)lParamSort, &lvi)) item2 = (THotkeyItem *)lvi.lParam; @@ -523,7 +523,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, TCHAR buf[128]; LVITEM lvi = { 0 }; lvi.pszText = buf; - lvi.cchTextMax = SIZEOF(buf); + lvi.cchTextMax = _countof(buf); for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) { char *szSetting; @@ -896,7 +896,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, lvi.mask = LVIF_TEXT; lvi.iItem = param->iItem; lvi.pszText = buf; - lvi.cchTextMax = SIZEOF(buf); + lvi.cchTextMax = _countof(buf); ListView_GetItem(lpnmhdr->hwndFrom, &lvi); if (param->uNewState >> 12 == 1) { @@ -957,7 +957,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iItem = param->nmcd.dwItemSpec; lvi.pszText = buf; - lvi.cchTextMax = SIZEOF(buf); + lvi.cchTextMax = _countof(buf); ListView_GetItem(lpnmhdr->hwndFrom, &lvi); item = (THotkeyItem *)lvi.lParam; @@ -1014,7 +1014,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, TCHAR buf[128]; LVITEM lvi = { 0 }; lvi.pszText = buf; - lvi.cchTextMax = SIZEOF(buf); + lvi.cchTextMax = _countof(buf); for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) { lvi.mask = LVIF_PARAM; lvi.iSubItem = 0; diff --git a/src/mir_app/src/hotkeys.cpp b/src/mir_app/src/hotkeys.cpp index edc92b10dd..0e91b12775 100644 --- a/src/mir_app/src/hotkeys.cpp +++ b/src/mir_app/src/hotkeys.cpp @@ -154,7 +154,7 @@ static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam) if (item->rootHotkey = hotkeys.find(item)) { if (item->rootHotkey->allowSubHotkeys) { char nameBuf[MAXMODULELABELLENGTH]; - mir_snprintf(nameBuf, SIZEOF(nameBuf), "%s$%d", item->rootHotkey->pszName, item->rootHotkey->nSubHotkeys); + mir_snprintf(nameBuf, _countof(nameBuf), "%s$%d", item->rootHotkey->pszName, item->rootHotkey->nSubHotkeys); item->pszName = mir_strdup(nameBuf); item->Enabled = TRUE; @@ -221,7 +221,7 @@ static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam) char *pszName = (char *)lParam; char pszNamePrefix[MAXMODULELABELLENGTH]; size_t cbNamePrefix; - mir_snprintf(pszNamePrefix, SIZEOF(pszNamePrefix), "%s$", pszName); + mir_snprintf(pszNamePrefix, _countof(pszNamePrefix), "%s$", pszName); cbNamePrefix = mir_strlen(pszNamePrefix); for (i = 0; i < hotkeys.getCount(); i++) { @@ -377,7 +377,7 @@ int LoadSkinHotkeys(void) HookEvent(ME_SYSTEM_MODULESLOADED, sttModulesLoaded); - for (int i = 0; i < SIZEOF(oldSettings); i++) { + for (int i = 0; i < _countof(oldSettings); i++) { char szSetting[100]; mir_snprintf(szSetting, "HK%s", oldSettings[i]); diff --git a/src/mir_app/src/hyperlink.cpp b/src/mir_app/src/hyperlink.cpp index bb62808f44..10121b2ee8 100644 --- a/src/mir_app/src/hyperlink.cpp +++ b/src/mir_app/src/hyperlink.cpp @@ -151,7 +151,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_CREATE: case HLK_MEASURETEXT: { TCHAR szText[256]; - if (!GetWindowText(hwnd, szText, SIZEOF(szText))) return 0; + if (!GetWindowText(hwnd, szText, _countof(szText))) return 0; lParam = (LPARAM)szText; /* fall thru */ case WM_SETTEXT: @@ -228,7 +228,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA hPrevFont = (HFONT)SelectObject(hdc, dat->hDisableFont); textColor = dat->disableColor; } - if (GetClientRect(hwnd, &rc) && GetWindowText(hwnd, szText, SIZEOF(szText))) { + if (GetClientRect(hwnd, &rc) && GetWindowText(hwnd, szText, _countof(szText))) { BOOL fSmoothing; UINT fSmoothingType; SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &fSmoothing, 0); diff --git a/src/mir_app/src/icolib.cpp b/src/mir_app/src/icolib.cpp index ad35eb3509..f5db3be974 100644 --- a/src/mir_app/src/icolib.cpp +++ b/src/mir_app/src/icolib.cpp @@ -348,7 +348,7 @@ IconSourceItem* GetIconSourceItemFromPath(const TCHAR* path, int cxIcon, int cyI return NULL; TCHAR file[MAX_PATH]; - mir_tstrncpy(file, path, SIZEOF(file)); + mir_tstrncpy(file, path, _countof(file)); TCHAR *comma = _tcsrchr(file, ','); int n; @@ -368,7 +368,7 @@ IconSourceItem* CreateStaticIconSourceItem(int cxIcon, int cyIcon) int i = 0; do { // find new unique name - mir_sntprintf(sourceName, SIZEOF(sourceName), _T("*StaticIcon_%d"), i++); + mir_sntprintf(sourceName, _countof(sourceName), _T("*StaticIcon_%d"), i++); } while (iconSourceFileList.getIndex(&key) != -1); IconSourceItem* newItem = (IconSourceItem*)mir_calloc(sizeof(IconSourceItem)); diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp index 5fc8208104..00d0384d74 100644 --- a/src/mir_app/src/ignore.cpp +++ b/src/mir_app/src/ignore.cpp @@ -58,7 +58,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt while (hItem) { hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem, childCount); - for (i=0; i < SIZEOF(iconOn); i++) + for (i=0; i < _countof(iconOn); i++) if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i] = 0; hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } @@ -66,7 +66,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem; else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { - for (i=0; i < SIZEOF(iconOn); i++) { + for (i=0; i < _countof(iconOn); i++) { iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i); if (iconOn[i] && iImage == 0) iconOn[i] = 0; if (iImage != EMPTY_EXTRA_ICON) @@ -75,7 +75,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } //set icons - for (i=0; i < SIZEOF(iconOn); i++) { + for (i=0; i < _countof(iconOn); i++) { SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+3:0) : EMPTY_EXTRA_ICON)); if (groupChildCount) groupChildCount[i]+=childCount[i]; } @@ -200,7 +200,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_TYPING); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); - for (int i=0; i < SIZEOF(hIcons); i++) + for (int i=0; i < _countof(hIcons); i++) hIcons[i] = ImageList_GetIcon(hIml, 1+i, ILD_NORMAL); } @@ -305,7 +305,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM break; case WM_DESTROY: - for (int i=0; i < SIZEOF(hIcons); i++) + for (int i=0; i < _countof(hIcons); i++) DestroyIcon(hIcons[i]); HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); ImageList_Destroy(hIml); diff --git a/src/mir_app/src/langpack.cpp b/src/mir_app/src/langpack.cpp index 692dfa7634..848eb81fee 100644 --- a/src/mir_app/src/langpack.cpp +++ b/src/mir_app/src/langpack.cpp @@ -75,7 +75,7 @@ BOOL EnumLangpacks(ENUM_PACKS_CALLBACK callback, WPARAM wParam, LPARAM lParam) DWORD v = CallService(MS_SYSTEM_GETVERSION, 0, 0); pack.szLastModifiedUsing.Format("%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF)); /* file date */ - if (GetModuleFileName(NULL, pack.tszFullPath, SIZEOF(pack.tszFullPath))) { + if (GetModuleFileName(NULL, pack.tszFullPath, _countof(pack.tszFullPath))) { mir_tstrcpy(pack.tszFileName, _T("default")); HANDLE hFile = CreateFile(pack.tszFileName, 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (hFile != INVALID_HANDLE_VALUE) { diff --git a/src/mir_app/src/lpopts.cpp b/src/mir_app/src/lpopts.cpp index a0f8812d41..735d4ab1bf 100644 --- a/src/mir_app/src/lpopts.cpp +++ b/src/mir_app/src/lpopts.cpp @@ -36,18 +36,18 @@ static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack) if (!(pack->flags & LPF_NOLOCALE)) { TCHAR szLocaleName[256], szLanguageName[128], szContryName[128]; - if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHLANGUAGENAME : LOCALE_SENGLANGUAGE, szLanguageName, SIZEOF(szLanguageName))) + if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHLANGUAGENAME : LOCALE_SENGLANGUAGE, szLanguageName, _countof(szLanguageName))) szLanguageName[0] = _T('\0'); - if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHCOUNTRYNAME : LOCALE_SENGCOUNTRY, szContryName, SIZEOF(szContryName))) + if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHCOUNTRYNAME : LOCALE_SENGCOUNTRY, szContryName, _countof(szContryName))) szContryName[0] = _T('\0'); /* add some note if its incompatible */ if (szLanguageName[0] && szContryName[0]) { - mir_sntprintf(szLocaleName, SIZEOF(szLocaleName), _T("%s (%s)"), TranslateTS(szLanguageName), TranslateTS(szContryName)); + mir_sntprintf(szLocaleName, _countof(szLocaleName), _T("%s (%s)"), TranslateTS(szLanguageName), TranslateTS(szContryName)); if (!IsValidLocale(pack->Locale, LCID_INSTALLED)) { TCHAR *pszIncompat; pszIncompat = TranslateT("(incompatible)"); - szLocaleName[SIZEOF(szLocaleName) - mir_tstrlen(pszIncompat) - 1] = 0; + szLocaleName[_countof(szLocaleName) - mir_tstrlen(pszIncompat) - 1] = 0; mir_tstrcat(mir_tstrcat(szLocaleName, _T(" ")), pszIncompat); } SetDlgItemText(hwndDlg, IDC_LANGLOCALE, szLocaleName); @@ -60,7 +60,7 @@ static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack) SYSTEMTIME stFileDate; TCHAR szDate[128]; szDate[0] = 0; if (FileTimeToSystemTime(&pack->ftFileDate, &stFileDate)) - GetDateFormat(Langpack_GetDefaultLocale(), DATE_SHORTDATE, &stFileDate, NULL, szDate, SIZEOF(szDate)); + GetDateFormat(Langpack_GetDefaultLocale(), DATE_SHORTDATE, &stFileDate, NULL, szDate, _countof(szDate)); SetDlgItemText(hwndDlg, IDC_LANGDATE, szDate); /* general */ @@ -77,7 +77,7 @@ static BOOL InsertPackItemEnumProc(LANGPACK_INFO *pack, WPARAM wParam, LPARAM) /* insert */ TCHAR tszName[512]; - mir_sntprintf(tszName, SIZEOF(tszName), _T("%s [%s]"), + mir_sntprintf(tszName, _countof(tszName), _T("%s [%s]"), TranslateTS(pack->tszLanguage), pack->flags & LPF_DEFAULT ? TranslateT("built-in") : pack->tszFileName); UINT message = pack->flags & LPF_DEFAULT ? CB_INSERTSTRING : CB_ADDSTRING; @@ -125,7 +125,7 @@ INT_PTR CALLBACK DlgLangpackOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP { char buf[512]; mir_strcpy(buf, "mailto:"); - if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), &buf[7], SIZEOF(buf) - 7)) + if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), &buf[7], _countof(buf) - 7)) CallService(MS_UTILS_OPENURL, 0, (LPARAM)buf); } break; diff --git a/src/mir_app/src/meta_main.cpp b/src/mir_app/src/meta_main.cpp index 3c18940afe..2b49613832 100644 --- a/src/mir_app/src/meta_main.cpp +++ b/src/mir_app/src/meta_main.cpp @@ -56,7 +56,7 @@ void UnloadMetacontacts(void) // Called when the plugin is loaded into Miranda int LoadMetacontacts(void) { - Icon_Register(g_hInst, LPGEN("MetaContacts"), iconList, SIZEOF(iconList), "mc"); + Icon_Register(g_hInst, LPGEN("MetaContacts"), iconList, _countof(iconList), "mc"); db_set_resident(META_PROTO, "Status"); db_set_resident(META_PROTO, "IdleTS"); diff --git a/src/mir_app/src/meta_menu.cpp b/src/mir_app/src/meta_menu.cpp index 49901c6412..1dce9747d4 100644 --- a/src/mir_app/src/meta_menu.cpp +++ b/src/mir_app/src/meta_menu.cpp @@ -296,7 +296,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM) // show hide nudge menu item char serviceFunc[256]; - mir_snprintf(serviceFunc, SIZEOF(serviceFunc), "%s%s", GetContactProto(Meta_GetMostOnline(cc)), PS_SEND_NUDGE); + mir_snprintf(serviceFunc, _countof(serviceFunc), "%s%s", GetContactProto(Meta_GetMostOnline(cc)), PS_SEND_NUDGE); CallService(MS_NUDGE_SHOWMENU, (WPARAM)META_PROTO, ServiceExists(serviceFunc)); return 0; } diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp index 5c6962f8cd..2379458374 100644 --- a/src/mir_app/src/meta_services.cpp +++ b/src/mir_app/src/meta_services.cpp @@ -243,7 +243,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam, LPARAM lParam) tfap->hContact = ccs->hContact; tfap->hEvent = hEvent; tfap->id = 10; - strncpy(tfap->msg, Translate("No online contacts found."), SIZEOF(tfap->msg) - 1); + strncpy(tfap->msg, Translate("No online contacts found."), _countof(tfap->msg) - 1); CloseHandle(mir_forkthread(sttFakeAckFail, (void*)tfap)); SetEvent(hEvent); @@ -852,7 +852,7 @@ void Meta_InitServices() // hidden contact menu items...ho hum for (int i = 0; i < MAX_CONTACTS; i++) { char szServiceName[100]; - mir_snprintf(szServiceName, SIZEOF(szServiceName), "MetaContacts/MenuFunc%d", i); + mir_snprintf(szServiceName, _countof(szServiceName), "MetaContacts/MenuFunc%d", i); CreateServiceFunctionParam(szServiceName, MenuFunc, i); } diff --git a/src/mir_app/src/meta_utils.cpp b/src/mir_app/src/meta_utils.cpp index fc32d1a929..3be2190071 100644 --- a/src/mir_app/src/meta_utils.cpp +++ b/src/mir_app/src/meta_utils.cpp @@ -489,8 +489,8 @@ int Meta_SetAllNicks() static void SwapValues(MCONTACT hContact, LPCSTR szSetting, int n1, int n2) { char buf1[100], buf2[100]; - mir_snprintf(buf1, SIZEOF(buf1), "%s%d", szSetting, n1); - mir_snprintf(buf2, SIZEOF(buf2), "%s%d", szSetting, n2); + mir_snprintf(buf1, _countof(buf1), "%s%d", szSetting, n1); + mir_snprintf(buf2, _countof(buf2), "%s%d", szSetting, n2); DBVARIANT dbv1, dbv2; int ok1 = !db_get(hContact, META_PROTO, buf1, &dbv1); @@ -526,7 +526,7 @@ int Meta_SwapContacts(DBCachedContact *cc, int n1, int n2) void Meta_GetSubNick(MCONTACT hMeta, int i, CMString &tszDest) { char idStr[50]; - mir_snprintf(idStr, SIZEOF(idStr), "Login%d", i); + mir_snprintf(idStr, _countof(idStr), "Login%d", i); DBVARIANT dbv; if(db_get(hMeta, META_PROTO, idStr, &dbv)) diff --git a/src/mir_app/src/miranda.cpp b/src/mir_app/src/miranda.cpp index a76fc46adc..6c908228ba 100644 --- a/src/mir_app/src/miranda.cpp +++ b/src/mir_app/src/miranda.cpp @@ -325,7 +325,7 @@ static INT_PTR OkToExit(WPARAM, LPARAM) static INT_PTR GetMirandaVersion(WPARAM, LPARAM) { TCHAR filename[MAX_PATH]; - GetModuleFileName(g_hInst, filename, SIZEOF(filename)); + GetModuleFileName(g_hInst, filename, _countof(filename)); DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); PVOID pVerInfo = _alloca(verInfoSize); @@ -344,7 +344,7 @@ static INT_PTR GetMirandaVersion(WPARAM, LPARAM) static INT_PTR GetMirandaFileVersion(WPARAM, LPARAM lParam) { TCHAR filename[MAX_PATH]; - GetModuleFileName(g_hInst, filename, SIZEOF(filename)); + GetModuleFileName(g_hInst, filename, _countof(filename)); DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); PVOID pVerInfo = _alloca(verInfoSize); @@ -365,7 +365,7 @@ static INT_PTR GetMirandaFileVersion(WPARAM, LPARAM lParam) static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam) { TCHAR filename[MAX_PATH], *productVersion; - GetModuleFileName(g_hInst, filename, SIZEOF(filename)); + GetModuleFileName(g_hInst, filename, _countof(filename)); DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused); PVOID pVerInfo = _alloca(verInfoSize); diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp index 7453fe5c0a..5cd39c0e68 100644 --- a/src/mir_app/src/netlib.cpp +++ b/src/mir_app/src/netlib.cpp @@ -289,8 +289,8 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) waitHandles[1] = nlc->hOkToCloseEvent; waitHandles[2] = nlc->ncsRecv.hMutex; waitHandles[3] = nlc->ncsSend.hMutex; - waitResult = WaitForMultipleObjects(SIZEOF(waitHandles), waitHandles, TRUE, INFINITE); - if (waitResult >= WAIT_OBJECT_0 + SIZEOF(waitHandles)) { + waitResult = WaitForMultipleObjects(_countof(waitHandles), waitHandles, TRUE, INFINITE); + if (waitResult >= WAIT_OBJECT_0 + _countof(waitHandles)) { ReleaseMutex(hConnectionHeaderMutex); SetLastError(ERROR_INVALID_PARAMETER); //already been closed return 0; diff --git a/src/mir_app/src/netlibautoproxy.cpp b/src/mir_app/src/netlibautoproxy.cpp index 92982a9999..f9572d4cb9 100644 --- a/src/mir_app/src/netlibautoproxy.cpp +++ b/src/mir_app/src/netlibautoproxy.cpp @@ -370,14 +370,14 @@ void NetlibLoadIeProxy(void) int tResult = RegQueryValueExA(hSettings, "ProxyEnable", NULL, NULL, (BYTE*)&enabled, &tValueLen); bEnabled = enabled && tResult == ERROR_SUCCESS; - tValueLen = SIZEOF(szHostStr); + tValueLen = _countof(szHostStr); tResult = RegQueryValueExA(hSettings, "ProxyServer", NULL, NULL, (BYTE*)szHostStr, &tValueLen); bEnabled = bEnabled && tResult == ERROR_SUCCESS; - tValueLen = SIZEOF(szAutoUrlStr); + tValueLen = _countof(szAutoUrlStr); RegQueryValueExA(hSettings, "AutoConfigUrl", NULL, NULL, (BYTE*)szAutoUrlStr, &tValueLen); - tValueLen = SIZEOF(szProxyBypassStr); + tValueLen = _countof(szProxyBypassStr); RegQueryValueExA(hSettings, "ProxyOverride", NULL, NULL, (BYTE*)szProxyBypassStr, &tValueLen); RegCloseKey(hSettings); diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp index 77fb25fd97..2627b0fc96 100644 --- a/src/mir_app/src/netlibbind.cpp +++ b/src/mir_app/src/netlibbind.cpp @@ -279,7 +279,7 @@ LBL_Error: if (nlb->dwInternalIP == 0) { char hostname[64] = ""; - gethostname(hostname, SIZEOF(hostname)); + gethostname(hostname, _countof(hostname)); PHOSTENT he = gethostbyname(hostname); if (he && he->h_addr) diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index d18139d69e..c1d154bc1c 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -264,7 +264,7 @@ struct HttpSecurityContext if (szHost && _stricmp(szProvider, "Basic")) { unsigned long ip = inet_addr(szHost); PHOSTENT host = (ip == INADDR_NONE) ? gethostbyname(szHost) : gethostbyaddr((char*)&ip, 4, AF_INET); - mir_snprintf(szSpnStr, SIZEOF(szSpnStr), "HTTP/%s", host && host->h_name ? host->h_name : szHost); + mir_snprintf(szSpnStr, _countof(szSpnStr), "HTTP/%s", host && host->h_name ? host->h_name : szHost); _strlwr(szSpnStr + 5); NetlibLogf(nlc->nlu, "Host SPN: %s", szSpnStr); } @@ -311,7 +311,7 @@ static int HttpPeekFirstResponseLine(NetlibConnection *nlc, DWORD dwTimeoutTime, char *peol; while(true) { - bytesPeeked = RecvWithTimeoutTime(nlc, dwTimeoutTime, buffer, SIZEOF(buffer) - 1, MSG_PEEK | recvFlags); + bytesPeeked = RecvWithTimeoutTime(nlc, dwTimeoutTime, buffer, _countof(buffer) - 1, MSG_PEEK | recvFlags); if (bytesPeeked == 0) { SetLastError(ERROR_HANDLE_EOF); @@ -328,7 +328,7 @@ static int HttpPeekFirstResponseLine(NetlibConnection *nlc, DWORD dwTimeoutTime, SetLastError(ERROR_BAD_FORMAT); return 0; } - if (bytesPeeked == SIZEOF(buffer) - 1) { + if (bytesPeeked == _countof(buffer) - 1) { SetLastError(ERROR_BUFFER_OVERFLOW); return 0; } @@ -868,13 +868,13 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) ++nlhrSend.headersCount; char szMirandaVer[64]; - CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(szMirandaVer), (LPARAM)szMirandaVer); + CallService(MS_SYSTEM_GETVERSIONTEXT, _countof(szMirandaVer), (LPARAM)szMirandaVer); char *pspace = strchr(szMirandaVer, ' '); if (pspace) { *pspace++='\0'; - mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s (%s)", szMirandaVer, pspace); + mir_snprintf(szUserAgent, _countof(szUserAgent), "Miranda/%s (%s)", szMirandaVer, pspace); } - else mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s", szMirandaVer); + else mir_snprintf(szUserAgent, _countof(szUserAgent), "Miranda/%s", szMirandaVer); } if (!doneAcceptEncoding) { nlhrSend.headers[nlhrSend.headersCount].szName = "Accept-Encoding"; diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index 3ac72264d8..7c9ae6e08d 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -104,7 +104,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa CheckDlgButton(hwndDlg, IDC_TEXTDUMPS, logOptions.textDumps ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTODETECTTEXT, logOptions.autoDetectText ? BST_CHECKED : BST_UNCHECKED); { - for (int i=0; i < SIZEOF(szTimeFormats); i++) + for (int i=0; i < _countof(szTimeFormats); i++) SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szTimeFormats[i])); } SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_SETCURSEL, logOptions.timeFormat, 0); @@ -148,7 +148,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa CheckDlgButton(hwndDlg, IDC_TOFILE, BST_CHECKED); TCHAR path[MAX_PATH]; - GetWindowText((HWND)lParam, path, SIZEOF(path)); + GetWindowText((HWND)lParam, path, _countof(path)); PathToAbsoluteT(VARST(path), path); SetDlgItemText(hwndDlg, IDC_PATH, path); @@ -157,10 +157,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case IDC_FILENAMEBROWSE: case IDC_RUNATSTARTBROWSE: - GetWindowText(GetWindow((HWND)lParam, GW_HWNDPREV), str, SIZEOF(str)); + GetWindowText(GetWindow((HWND)lParam, GW_HWNDPREV), str, _countof(str)); { TCHAR filter[200]; - mir_sntprintf(filter, SIZEOF(filter), _T("%s (*)%c*%c"), TranslateT("All files"), 0, 0); + mir_sntprintf(filter, _countof(filter), _T("%s (*)%c*%c"), TranslateT("All files"), 0, 0); OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; @@ -174,7 +174,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa } ofn.lpstrFilter = filter; ofn.lpstrFile = str; - ofn.nMaxFile = SIZEOF(str) - 2; + ofn.nMaxFile = _countof(str) - 2; ofn.nMaxFileTitle = MAX_PATH; if (LOWORD(wParam) == IDC_FILENAMEBROWSE) { if (!GetSaveFileName(&ofn)) return 1; @@ -183,7 +183,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa return 1; if (LOWORD(wParam) == IDC_RUNATSTARTBROWSE && _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("\"")); } @@ -192,7 +192,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa break; case IDC_RUNNOW: - GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, _countof(str)); if (str[0]) { STARTUPINFO si = { sizeof(si) }; PROCESS_INFORMATION pi; @@ -201,15 +201,15 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa break; case IDOK: - GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, _countof(str)); db_set_ts(NULL, "Netlib", "RunAtStart", str); db_set_b(NULL, "Netlib", "ShowLogOptsAtStart", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWTHISDLGATSTART)); - GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_FILENAME, str, _countof(str)); logOptions.tszUserFile = rtrimt(str); db_set_ts(NULL, "Netlib", "File", str); - GetDlgItemText(hwndDlg, IDC_PATH, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_PATH, str, _countof(str)); logOptions.tszFile = rtrimt(str); db_set_b(NULL, "Netlib", "DumpRecv", logOptions.dumpRecv = IsDlgButtonChecked(hwndDlg, IDC_DUMPRECV)); @@ -300,21 +300,21 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) char szTime[32], szHead[128]; switch (logOptions.timeFormat) { case TIMEFORMAT_HHMMSS: - GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, NULL, NULL, szTime, SIZEOF(szTime)); + GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, NULL, NULL, szTime, _countof(szTime)); mir_strcat(szTime, " "); break; case TIMEFORMAT_MILLISECONDS: QueryPerformanceCounter(&liTimeNow); liTimeNow.QuadPart -= mirandaStartTime; - mir_snprintf(szTime, SIZEOF(szTime), "%I64u.%03I64u ", liTimeNow.QuadPart / perfCounterFreq, + mir_snprintf(szTime, _countof(szTime), "%I64u.%03I64u ", liTimeNow.QuadPart / perfCounterFreq, 1000 * (liTimeNow.QuadPart % perfCounterFreq) / perfCounterFreq); break; case TIMEFORMAT_MICROSECONDS: QueryPerformanceCounter(&liTimeNow); liTimeNow.QuadPart -= mirandaStartTime; - mir_snprintf(szTime, SIZEOF(szTime), "%I64u.%06I64u ", liTimeNow.QuadPart / perfCounterFreq, + mir_snprintf(szTime, _countof(szTime), "%I64u.%06I64u ", liTimeNow.QuadPart / perfCounterFreq, 1000000 * (liTimeNow.QuadPart % perfCounterFreq) / perfCounterFreq); break; @@ -325,9 +325,9 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) char *szUser = (logOptions.showUser) ? (nlu == NULL ? NULL : nlu->user.szSettingsModule) : NULL; if (szUser) - mir_snprintf(szHead, SIZEOF(szHead), "[%s%04X] [%s] ", szTime, GetCurrentThreadId(), szUser); + mir_snprintf(szHead, _countof(szHead), "[%s%04X] [%s] ", szTime, GetCurrentThreadId(), szUser); else - mir_snprintf(szHead, SIZEOF(szHead), "[%s%04X] ", szTime, GetCurrentThreadId()); + mir_snprintf(szHead, _countof(szHead), "[%s%04X] ", szTime, GetCurrentThreadId()); if (logOptions.toOutputDebugString) { if (szHead[0]) @@ -401,7 +401,7 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla WaitForSingleObject(hConnectionHeaderMutex, INFINITE); NetlibUser *nlu = nlc ? nlc->nlu : NULL; - int titleLineLen = mir_snprintf(szTitleLine, SIZEOF(szTitleLine), "(%p:%u) Data %s%s\r\n", + int titleLineLen = mir_snprintf(szTitleLine, _countof(szTitleLine), "(%p:%u) Data %s%s\r\n", nlc, nlc ? nlc->s : 0, sent ? "sent" : "received", flags & MSG_DUMPPROXY ? " (proxy)" : ""); ReleaseMutex(hConnectionHeaderMutex); diff --git a/src/mir_app/src/netlibopts.cpp b/src/mir_app/src/netlibopts.cpp index 85d17fcee8..90e6a5a555 100644 --- a/src/mir_app/src/netlibopts.cpp +++ b/src/mir_app/src/netlibopts.cpp @@ -304,7 +304,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, CopySettingsStruct(&settings, &tempSettings[iUser]->settings); flags = tempSettings[iUser]->flags; } - ShowMultipleControls(hwndDlg, outgoingConnectionsControls, SIZEOF(outgoingConnectionsControls), flags&NUF_OUTGOING ? SW_SHOW : SW_HIDE); + ShowMultipleControls(hwndDlg, outgoingConnectionsControls, _countof(outgoingConnectionsControls), flags&NUF_OUTGOING ? SW_SHOW : SW_HIDE); CheckDlgButton(hwndDlg, IDC_USEPROXY, settings.useProxy ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_RESETCONTENT, 0, 0); if (settings.proxyType == 0) AddProxyTypeItem(hwndDlg, 0, settings.proxyType); @@ -323,7 +323,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, CheckDlgButton(hwndDlg, IDC_PROXYDNS, settings.dnsThroughProxy ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_VALIDATESSL, settings.validateSSL ? BST_CHECKED : BST_UNCHECKED); - ShowMultipleControls(hwndDlg, incomingConnectionsControls, SIZEOF(incomingConnectionsControls), flags&NUF_INCOMING ? SW_SHOW : SW_HIDE); + ShowMultipleControls(hwndDlg, incomingConnectionsControls, _countof(incomingConnectionsControls), flags&NUF_INCOMING ? SW_SHOW : SW_HIDE); CheckDlgButton(hwndDlg, IDC_SPECIFYPORTS, settings.specifyIncomingPorts ? BST_CHECKED : BST_UNCHECKED); SetDlgItemTextA(hwndDlg, IDC_PORTSRANGE, settings.szIncomingPorts ? settings.szIncomingPorts : ""); @@ -341,11 +341,11 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, TCHAR str[80]; { int selectedProxyType = SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETCURSEL, 0, 0), 0); - mir_sntprintf(str, SIZEOF(str), TranslateT("(often %d)"), oftenProxyPorts[selectedProxyType]); + mir_sntprintf(str, _countof(str), TranslateT("(often %d)"), oftenProxyPorts[selectedProxyType]); SetDlgItemText(hwndDlg, IDC_STOFTENPORT, str); if (IsDlgButtonChecked(hwndDlg, IDC_USEPROXY) != BST_UNCHECKED) { int enableAuth = 0, enableUser = 0, enablePass = 0, enableServer = 1; - EnableMultipleControls(hwndDlg, useProxyControls, SIZEOF(useProxyControls), TRUE); + EnableMultipleControls(hwndDlg, useProxyControls, _countof(useProxyControls), TRUE); if (selectedProxyType == 0) { for (int i = 0; i < tempSettings.getCount(); i++) { NetlibTempSettings *p = tempSettings[i]; @@ -378,9 +378,9 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYHOST), enableServer); EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYPORT), enableServer); } - else EnableMultipleControls(hwndDlg, useProxyControls, SIZEOF(useProxyControls), FALSE); - EnableMultipleControls(hwndDlg, specifyPortsControls, SIZEOF(specifyPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTS) != BST_UNCHECKED); - EnableMultipleControls(hwndDlg, specifyOPortsControls, SIZEOF(specifyOPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTSO) != BST_UNCHECKED); + else EnableMultipleControls(hwndDlg, useProxyControls, _countof(useProxyControls), FALSE); + EnableMultipleControls(hwndDlg, specifyPortsControls, _countof(specifyPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTS) != BST_UNCHECKED); + EnableMultipleControls(hwndDlg, specifyOPortsControls, _countof(specifyOPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTSO) != BST_UNCHECKED); } break; diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp index 1471d611b9..eae0b5a5ac 100644 --- a/src/mir_app/src/netlibsecurity.cpp +++ b/src/mir_app/src/netlibsecurity.cpp @@ -66,7 +66,7 @@ static void ReportSecError(SECURITY_STATUS scRet, int line) { char szMsgBuf[256]; FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, scRet, LANG_USER_DEFAULT, szMsgBuf, SIZEOF(szMsgBuf), NULL); + NULL, scRet, LANG_USER_DEFAULT, szMsgBuf, _countof(szMsgBuf), NULL); char *p = strchr(szMsgBuf, 13); if (p) *p = 0; diff --git a/src/mir_app/src/netlibsock.cpp b/src/mir_app/src/netlibsock.cpp index ee1cfde144..88c089d73f 100644 --- a/src/mir_app/src/netlibsock.cpp +++ b/src/mir_app/src/netlibsock.cpp @@ -218,7 +218,7 @@ char* NetlibAddressToString(SOCKADDR_INET_M* addr) if (addr->si_family == AF_INET) { char *szIp = inet_ntoa(addr->Ipv4.sin_addr); if (addr->Ipv4.sin_port != 0) { - mir_snprintf(saddr, SIZEOF(saddr), "%s:%d", szIp, htons(addr->Ipv4.sin_port)); + mir_snprintf(saddr, _countof(saddr), "%s:%d", szIp, htons(addr->Ipv4.sin_port)); return mir_strdup(saddr); } return mir_strdup(szIp); diff --git a/src/mir_app/src/netlibupnp.cpp b/src/mir_app/src/netlibupnp.cpp index 55fe46152a..63654ea4f5 100644 --- a/src/mir_app/src/netlibupnp.cpp +++ b/src/mir_app/src/netlibupnp.cpp @@ -261,7 +261,7 @@ static int httpTransact(char* szUrl, char* szResult, int resSize, char* szAction char szData1[1024]; szReq = mir_strdup(szResult); - sz = mir_snprintf(szData1, SIZEOF(szData1), + sz = mir_snprintf(szData1, _countof(szData1), soap_action, szActionName, szDev, szReq, szActionName); sz = mir_snprintf(szData, 4096, @@ -274,7 +274,7 @@ static int httpTransact(char* szUrl, char* szResult, int resSize, char* szAction { char szData1[1024]; - sz = mir_snprintf(szData1, SIZEOF(szData1), + sz = mir_snprintf(szData1, _countof(szData1), soap_query, szActionName); sz = mir_snprintf(szData, 4096, @@ -787,7 +787,7 @@ void NetlibUPnPCleanup(void*) if (txtParseParam(szData, "", "<", buf, sizeof(buf))) { WORD mport = (WORD)atol(buf); - if (j >= SIZEOF(ports)) + if (j >= _countof(ports)) break; for (k = 0; k < numports; ++k) diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index e3263906aa..8c6d7de124 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -118,7 +118,7 @@ static const MUUID pluginBannedList[] = static bool isPluginBanned(const MUUID& u1) { - for (int i = 0; i < SIZEOF(pluginBannedList); i++) + for (int i = 0; i < _countof(pluginBannedList); i++) if (equalUUID(pluginBannedList[i], u1)) return true; @@ -148,7 +148,7 @@ static MuuidReplacement pluginDefault[] = int getDefaultPluginIdx(const MUUID &muuid) { - for (int i = 0; i < SIZEOF(pluginDefault); i++) + for (int i = 0; i < _countof(pluginDefault); i++) if (equalUUID(muuid, pluginDefault[i].uuid)) return i; @@ -157,7 +157,7 @@ int getDefaultPluginIdx(const MUUID &muuid) int LoadStdPlugins() { - for (int i = 0; i < SIZEOF(pluginDefault); i++) { + for (int i = 0; i < _countof(pluginDefault); i++) { if (pluginDefault[i].pImpl) continue; @@ -352,7 +352,7 @@ int Plugin_UnloadDyn(pluginEntry *p) // mark default plugins to be loaded if (!(p->pclass & PCLASS_CORE)) - for (int i = 0; i < SIZEOF(pluginDefault); i++) + for (int i = 0; i < _countof(pluginDefault); i++) if (pluginDefault[i].pImpl == p) pluginDefault[i].pImpl = NULL; @@ -374,12 +374,12 @@ void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam) { // get miranda's exe path TCHAR exe[MAX_PATH]; - GetModuleFileName(NULL, exe, SIZEOF(exe)); + GetModuleFileName(NULL, exe, _countof(exe)); TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0; // create the search filter TCHAR search[MAX_PATH]; - mir_sntprintf(search, SIZEOF(search), _T("%s\\Plugins\\*.dll"), exe); + mir_sntprintf(search, _countof(search), _T("%s\\Plugins\\*.dll"), exe); // FFFN will return filenames for things like dot dll+ or dot dllx WIN32_FIND_DATA ffd; @@ -403,7 +403,7 @@ pluginEntry* OpenPlugin(TCHAR *tszFileName, TCHAR *dir, TCHAR *path) pluginList.insert(p); TCHAR tszFullPath[MAX_PATH]; - mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\%s\\%s"), path, dir, tszFileName); + mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\%s\\%s"), path, dir, tszFileName); // map dll into the memory and check its exports bool bIsPlugin = false; @@ -485,7 +485,7 @@ int isPluginOnWhiteList(const TCHAR* pluginname) bool TryLoadPlugin(pluginEntry *p, bool bDynamic) { TCHAR exe[MAX_PATH], tszFullPath[MAX_PATH]; - GetModuleFileName(NULL, exe, SIZEOF(exe)); + GetModuleFileName(NULL, exe, _countof(exe)); TCHAR* slice = _tcsrchr(exe, '\\'); if (slice) *slice = 0; @@ -496,7 +496,7 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) if (!(p->pclass & PCLASS_BASICAPI)) { BASIC_PLUGIN_INFO bpi; - mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\%s\\%s"), exe, (p->pclass & PCLASS_CORE) ? _T("Core") : _T("Plugins"), p->pluginname); + mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\%s\\%s"), exe, (p->pclass & PCLASS_CORE) ? _T("Core") : _T("Plugins"), p->pluginname); if (!checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) { p->pclass |= PCLASS_FAILED; return false; @@ -552,10 +552,10 @@ static TCHAR tszCoreErr[] = LPGENT("Core plugin '%s' cannot be loaded or missing bool LoadCorePlugin(MuuidReplacement &mr) { TCHAR exe[MAX_PATH], tszPlugName[MAX_PATH]; - GetModuleFileName(NULL, exe, SIZEOF(exe)); + GetModuleFileName(NULL, exe, _countof(exe)); TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0; - mir_sntprintf(tszPlugName, SIZEOF(tszPlugName), _T("%s.dll"), mr.stdplugname); + mir_sntprintf(tszPlugName, _countof(tszPlugName), _T("%s.dll"), mr.stdplugname); pluginEntry* pPlug = OpenPlugin(tszPlugName, _T("Core"), exe); if (pPlug->pclass & PCLASS_FAILED) { LBL_Error: @@ -613,14 +613,14 @@ static pluginEntry* getCListModule(TCHAR *exe) if (!isPluginOnWhiteList(p->pluginname)) continue; - mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\Plugins\\%s"), exe, p->pluginname); + mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\Plugins\\%s"), exe, p->pluginname); if (loadClistModule(tszFullPath, p)) return p; } MuuidReplacement& stdClist = pluginDefault[11]; if (LoadCorePlugin(stdClist)) { - mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\Core\\%s.dll"), exe, stdClist.stdplugname); + mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\Core\\%s.dll"), exe, stdClist.stdplugname); if (loadClistModule(tszFullPath, stdClist.pImpl)) return stdClist.pImpl; } @@ -758,7 +758,7 @@ int LoadNewPluginsModule(void) { // make full path to the plugin TCHAR exe[MAX_PATH], fullPath[MAX_PATH]; - GetModuleFileName(NULL, exe, SIZEOF(exe)); + GetModuleFileName(NULL, exe, _countof(exe)); TCHAR *slice = _tcsrchr(exe, '\\'); if (slice) *slice = 0; @@ -774,7 +774,7 @@ int LoadNewPluginsModule(void) // if freeimage is present, load it to provide the basic core functions if (plugin_freeimg != NULL) { BASIC_PLUGIN_INFO bpi; - mir_sntprintf(fullPath, SIZEOF(fullPath), _T("%s\\Plugins\\%s"), exe, plugin_freeimg->pluginname); + mir_sntprintf(fullPath, _countof(fullPath), _T("%s\\Plugins\\%s"), exe, plugin_freeimg->pluginname); if (checkAPI(fullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) { plugin_freeimg->bpi = bpi; plugin_freeimg->pclass |= PCLASS_OK | PCLASS_BASICAPI; diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index faf822d515..28ddc75529 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -160,7 +160,7 @@ HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name) TVITEM tvi; tvi.mask = TVIF_TEXT; tvi.pszText = str; - tvi.cchTextMax = SIZEOF(str); + tvi.cchTextMax = _countof(str); tvi.hItem = TreeView_GetRoot(hwndTree); while (tvi.hItem != NULL) { SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi); @@ -178,7 +178,7 @@ static HTREEITEM FindNamedTreeItemAtChildren(HWND hwndTree, HTREEITEM hItem, con TVITEM tvi; tvi.mask = TVIF_TEXT; tvi.pszText = str; - tvi.cchTextMax = SIZEOF(str); + tvi.cchTextMax = _countof(str); tvi.hItem = TreeView_GetChild(hwndTree, hItem); while (tvi.hItem != NULL) { SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi); @@ -193,7 +193,7 @@ static HTREEITEM FindNamedTreeItemAtChildren(HWND hwndTree, HTREEITEM hItem, con static BOOL CALLBACK BoldGroupTitlesEnumChildren(HWND hwnd, LPARAM lParam) { TCHAR szClass[64]; - GetClassName(hwnd, szClass, SIZEOF(szClass)); + GetClassName(hwnd, szClass, _countof(szClass)); if (!mir_tstrcmp(szClass, _T("Button")) && (GetWindowLongPtr(hwnd, GWL_STYLE) & 0x0F) == BS_GROUPBOX) SendMessage(hwnd, WM_SETFONT, lParam, 0); @@ -208,7 +208,7 @@ static void SaveOptionsTreeState(HWND hdlg) char buf[130], str[128]; tvi.mask = TVIF_TEXT | TVIF_STATE; tvi.pszText = str; - tvi.cchTextMax = SIZEOF(str); + tvi.cchTextMax = _countof(str); tvi.hItem = TreeView_GetRoot(GetDlgItem(hdlg, IDC_PAGETREE)); while (tvi.hItem != NULL) { if (SendDlgItemMessageA(hdlg, IDC_PAGETREE, TVM_GETITEMA, 0, (LPARAM)&tvi)) { @@ -233,7 +233,7 @@ static void ThemeDialogBackground(HWND hwnd, BOOL tabbed) static TCHAR* GetPluginName(HINSTANCE hInstance, TCHAR *buffer, int size) { TCHAR tszModuleName[MAX_PATH]; - GetModuleFileName(hInstance, tszModuleName, SIZEOF(tszModuleName)); + GetModuleFileName(hInstance, tszModuleName, _countof(tszModuleName)); TCHAR *dllName = _tcsrchr(tszModuleName, '\\'); if (!dllName) dllName = tszModuleName; @@ -272,7 +272,7 @@ static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWnd TCHAR pluginName[MAX_PATH]; char *temp = GetPluginNameByInstance(page->getInst()); - GetDialogStrings(enableKeywordFiltering, key, GetPluginName(page->getInst(), pluginName, SIZEOF(pluginName)), hWnd, page->ptszGroup, page->ptszTitle, page->ptszTab, _A2T(temp)); + GetDialogStrings(enableKeywordFiltering, key, GetPluginName(page->getInst(), pluginName, _countof(pluginName)), hWnd, page->ptszGroup, page->ptszTitle, page->ptszTab, _A2T(temp)); if (enableKeywordFiltering && !current) DestroyWindow(hWnd); // destroy the page, we're done with it @@ -508,7 +508,7 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat) countKnownInst++; TCHAR tszModuleName[MAX_PATH]; - GetModuleFileName(inst, tszModuleName, SIZEOF(tszModuleName)); + GetModuleFileName(inst, tszModuleName, _countof(tszModuleName)); TCHAR *dllName = mir_a2t(GetPluginNameByInstance(inst)); if (!dllName) dllName = mir_tstrdup(_tcsrchr(tszModuleName, _T('\\'))); @@ -526,7 +526,7 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat) static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat) { LPARAM oldSel = SendDlgItemMessage(hdlg, IDC_KEYWORD_FILTER, CB_GETEDITSEL, 0, 0); - GetDlgItemText(hdlg, IDC_KEYWORD_FILTER, dat->szFilterString, SIZEOF(dat->szFilterString)); + GetDlgItemText(hdlg, IDC_KEYWORD_FILTER, dat->szFilterString, _countof(dat->szFilterString)); // if filter string is set to all modules then make the filter string empty (this will return all modules) BOOL bRemoveFocusFromFilter = FALSE; @@ -538,7 +538,7 @@ static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat) else if (mir_tstrcmp(dat->szFilterString, TranslateT(CORE_MODULES_FILTER)) == 0) { // replace string with process name - that will show core settings TCHAR szFileName[300]; - GetModuleFileName(g_hInst, szFileName, SIZEOF(szFileName)); + GetModuleFileName(g_hInst, szFileName, _countof(szFileName)); TCHAR *pos = _tcsrchr(szFileName, _T('\\')); if (pos) pos++; @@ -552,7 +552,7 @@ static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat) if (sel != -1) { HINSTANCE hinst = (HINSTANCE)SendDlgItemMessage(hdlg, IDC_KEYWORD_FILTER, (UINT)CB_GETITEMDATA, sel, 0); TCHAR szFileName[300]; - GetModuleFileName(hinst, szFileName, SIZEOF(szFileName)); + GetModuleFileName(hinst, szFileName, _countof(szFileName)); TCHAR *pos = _tcsrchr(szFileName, _T('\\')); if (pos) pos++; else pos = szFileName; @@ -651,7 +651,7 @@ static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat) TVITEMA tvi; tvi.mask = TVIF_TEXT | TVIF_STATE; tvi.pszText = str; - tvi.cchTextMax = SIZEOF(str); + tvi.cchTextMax = _countof(str); tvi.hItem = TreeView_GetRoot(hwndTree); while (tvi.hItem != NULL) { if (SendMessageA(hwndTree, TVM_GETITEMA, 0, (LPARAM)&tvi)) { @@ -1151,7 +1151,7 @@ void OpenAccountOptions(PROTOACCOUNT *pa) return; TCHAR tszTitle[100]; - mir_sntprintf(tszTitle, SIZEOF(tszTitle), TranslateT("%s options"), pa->tszAccountName); + mir_sntprintf(tszTitle, _countof(tszTitle), TranslateT("%s options"), pa->tszAccountName); OPENOPTIONSDIALOG ood = { sizeof(ood) }; ood.pszGroup = LPGEN("Network"); diff --git a/src/mir_app/src/path.cpp b/src/mir_app/src/path.cpp index 8e6ea249a9..ce9e92e4c8 100644 --- a/src/mir_app/src/path.cpp +++ b/src/mir_app/src/path.cpp @@ -94,7 +94,7 @@ static __forceinline char *GetContactIDX(char *, MCONTACT hContact) static __forceinline char *GetEnvironmentVariableX(char *variable) { char result[512]; - if (GetEnvironmentVariableA(variable, result, SIZEOF(result))) + if (GetEnvironmentVariableA(variable, result, _countof(result))) return mir_strdup(result); return NULL; } @@ -124,7 +124,7 @@ static __forceinline char *GetModulePathX(char *, HMODULE hModule) static __forceinline char *GetUserNameX(char *) { char result[128]; - DWORD size = SIZEOF(result); + DWORD size = _countof(result); if (GetUserNameA(result, &size)) return mir_strdup(result); return NULL; @@ -144,13 +144,13 @@ static __forceinline char *GetPathVarX(char *, int code) if (hAvatarFolder != NULL) _tcsncpy_s(szFullPath, tszAvatarRoot, _TRUNCATE); else - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); break; case 2: - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName); break; case 3: - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s"), g_profileDir, g_shortProfileName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s"), g_profileDir, g_shortProfileName); break; } return makeFileName(szFullPath); @@ -178,7 +178,7 @@ static __forceinline TCHAR *GetContactIDX(TCHAR *, MCONTACT hContact) static __forceinline TCHAR *GetEnvironmentVariableX(TCHAR *variable) { TCHAR result[512]; - if (GetEnvironmentVariable(variable, result, SIZEOF(result))) + if (GetEnvironmentVariable(variable, result, _countof(result))) return mir_tstrdup(result); return NULL; } @@ -199,7 +199,7 @@ static __forceinline TCHAR *GetProfileDirX(TCHAR*) static __forceinline TCHAR *GetModulePathX(TCHAR *, HMODULE hModule) { TCHAR result[MAX_PATH]; - GetModuleFileName(hModule, result, SIZEOF(result)); + GetModuleFileName(hModule, result, _countof(result)); TCHAR* str = _tcsrchr(result, '\\'); if (str) *str = 0; return mir_tstrdup(result); @@ -208,7 +208,7 @@ static __forceinline TCHAR *GetModulePathX(TCHAR *, HMODULE hModule) static __forceinline TCHAR *GetUserNameX(TCHAR *) { TCHAR result[128]; - DWORD size = SIZEOF(result); + DWORD size = _countof(result); if (GetUserName(result, &size)) return mir_tstrdup(result); return NULL; @@ -228,13 +228,13 @@ static __forceinline TCHAR *GetPathVarX(TCHAR *, int code) if (hAvatarFolder != NULL) _tcsncpy_s(szFullPath, tszAvatarRoot, _TRUNCATE); else - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); break; case 2: - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName); break; case 3: - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s"), g_profileDir, g_shortProfileName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s"), g_profileDir, g_shortProfileName); break; } return mir_tstrdup(szFullPath); @@ -393,20 +393,20 @@ int InitPathUtils(void) static int OnFoldersChanged(WPARAM, LPARAM) { - mir_sntprintf(tszAvatarRoot, SIZEOF(tszAvatarRoot), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); + mir_sntprintf(tszAvatarRoot, _countof(tszAvatarRoot), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); TCHAR tmpVar[MAX_PATH]; - if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, SIZEOF(tmpVar), tszAvatarRoot)) + if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, _countof(tmpVar), tszAvatarRoot)) _tcsncpy_s(tszAvatarRoot, tmpVar, _TRUNCATE); return 0; } void InitPathVar() { - mir_sntprintf(tszAvatarRoot, SIZEOF(tszAvatarRoot), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); + mir_sntprintf(tszAvatarRoot, _countof(tszAvatarRoot), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); if (hAvatarFolder = FoldersRegisterCustomPathT( LPGEN("Avatars"), LPGEN("Avatars root folder"), tszAvatarRoot)) { TCHAR tmpVar[MAX_PATH]; - if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, SIZEOF(tmpVar), tszAvatarRoot)) + if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, _countof(tmpVar), tszAvatarRoot)) _tcsncpy_s(tszAvatarRoot, tmpVar, _TRUNCATE); HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged); } diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp index 9f62b32c6e..278050a96d 100644 --- a/src/mir_app/src/pluginopts.cpp +++ b/src/mir_app/src/pluginopts.cpp @@ -184,7 +184,7 @@ static void RemoveAllItems(HWND hwnd) static bool LoadPluginDynamically(PluginListItemData *dat) { TCHAR exe[MAX_PATH]; - GetModuleFileName(NULL, exe, SIZEOF(exe)); + GetModuleFileName(NULL, exe, _countof(exe)); TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0; pluginEntry* pPlug = OpenPlugin(dat->fileName, _T("Plugins"), exe); @@ -424,7 +424,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar PluginListItemData *dat = (PluginListItemData*)lvi.lParam; TCHAR buf[1024]; - ListView_GetItemText(hwndList, hdr->iItem, 2, buf, SIZEOF(buf)); + ListView_GetItemText(hwndList, hdr->iItem, 2, buf, _countof(buf)); SetDlgItemText(hwndDlg, IDC_PLUGININFOFRAME, sel ? buf : _T("")); ptrT tszAuthor(latin2t(sel ? dat->author : NULL)); @@ -456,12 +456,12 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar if (hdr->hdr.code == PSN_APPLY) { bool needRestart = false; TCHAR bufRestart[1024]; - int bufLen = mir_sntprintf(bufRestart, SIZEOF(bufRestart), _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:")); + int bufLen = mir_sntprintf(bufRestart, _countof(bufRestart), _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:")); HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); for (int iRow = 0; iRow != -1;) { TCHAR buf[1024]; - ListView_GetItemText(hwndList, iRow, 1, buf, SIZEOF(buf)); + ListView_GetItemText(hwndList, iRow, 1, buf, _countof(buf)); int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0); @@ -483,7 +483,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar ListView_SetItem(hwndList, &lvi); } else { - bufLen += mir_sntprintf(bufRestart + bufLen, SIZEOF(bufRestart) - bufLen, _T(" - %s\n"), buf); + bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } @@ -496,7 +496,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar ListView_SetItem(hwndList, &lvi); } else { - bufLen += mir_sntprintf(bufRestart + bufLen, SIZEOF(bufRestart) - bufLen, _T(" - %s\n"), buf); + bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } @@ -510,7 +510,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), needRestart); if (needRestart) { - mir_sntprintf(bufRestart + bufLen, SIZEOF(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?")); + mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?")); if (MessageBox(NULL, bufRestart, _T("Miranda NG"), MB_ICONWARNING | MB_YESNO) == IDYES) CallService(MS_SYSTEM_RESTART, 1, 0); } @@ -530,7 +530,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar char buf[512]; char *p = &buf[7]; mir_strcpy(buf, "mailto:"); - if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, SIZEOF(buf) - 7)) + if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, _countof(buf) - 7)) CallService(MS_UTILS_OPENURL, 0, (LPARAM)(LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p)); break; } diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp index e2ffc37f79..bda73395a4 100644 --- a/src/mir_app/src/profilemanager.cpp +++ b/src/mir_app/src/profilemanager.cpp @@ -46,7 +46,7 @@ static int findProfiles(TCHAR *szProfileDir, ENUMPROFILECALLBACK callback, LPARA { // find in Miranda NG profile subfolders TCHAR searchspec[MAX_PATH]; - mir_sntprintf(searchspec, SIZEOF(searchspec), _T("%s\\*.*"), szProfileDir); + mir_sntprintf(searchspec, _countof(searchspec), _T("%s\\*.*"), szProfileDir); WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(searchspec, &ffd); @@ -59,7 +59,7 @@ static int findProfiles(TCHAR *szProfileDir, ENUMPROFILECALLBACK callback, LPARA TCHAR buf[MAX_PATH], profile[MAX_PATH]; mir_sntprintf(buf, _T("%s\\%s\\%s.dat"), szProfileDir, ffd.cFileName, ffd.cFileName); if (_taccess(buf, 0) == 0) { - mir_sntprintf(profile, SIZEOF(profile), _T("%s.dat"), ffd.cFileName); + mir_sntprintf(profile, _countof(profile), _T("%s.dat"), ffd.cFileName); if (!callback(buf, profile, lParam)) break; } @@ -264,11 +264,11 @@ class CChooseProfileDlg : public CDlgBase struct _stat statbuf; if (_tstat(tszFullPath, &statbuf) == 0) { if (statbuf.st_size > 1000000) { - mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0); + mir_sntprintf(sizeBuf, _countof(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0); mir_tstrcpy(sizeBuf + 5, _T(" MB")); } else { - mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0); + mir_sntprintf(sizeBuf, _countof(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0); mir_tstrcpy(sizeBuf + 5, _T(" KB")); } bFileLocked = !fileExist(tszFullPath); @@ -315,11 +315,11 @@ class CChooseProfileDlg : public CDlgBase item.mask = LVIF_TEXT | LVIF_IMAGE; item.iItem = iItem; item.pszText = profile; - item.cchTextMax = SIZEOF(profile); + item.cchTextMax = _countof(profile); if (!m_profileList.GetItem(&item)) return; - mir_sntprintf(fullName, SIZEOF(fullName), _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profile, profile); + mir_sntprintf(fullName, _countof(fullName), _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profile, profile); CallService(MS_DB_CHECKPROFILE, (WPARAM)fullName, item.iImage == 2); } @@ -334,15 +334,15 @@ class CChooseProfileDlg : public CDlgBase item.mask = LVIF_TEXT; item.iItem = iItem; item.pszText = profile; - item.cchTextMax = SIZEOF(profile); + item.cchTextMax = _countof(profile); if (!m_profileList.GetItem(&item)) return; - mir_sntprintf(profilef, SIZEOF(profilef), TranslateT("Are you sure you want to remove profile \"%s\"?"), profile); + mir_sntprintf(profilef, _countof(profilef), TranslateT("Are you sure you want to remove profile \"%s\"?"), profile); if (IDYES != MessageBox(NULL, profilef, _T("Miranda NG"), MB_YESNO | MB_TASKMODAL | MB_ICONWARNING)) return; - mir_sntprintf(profilef, SIZEOF(profilef), _T("%s\\%s%c"), m_pd->ptszProfileDir, profile, 0); + mir_sntprintf(profilef, _countof(profilef), _T("%s\\%s%c"), m_pd->ptszProfileDir, profile, 0); SHFILEOPSTRUCT sf = { 0 }; sf.wFunc = FO_DELETE; @@ -361,7 +361,7 @@ class CChooseProfileDlg : public CDlgBase item.mask = LVIF_TEXT | LVIF_IMAGE; item.iItem = m_profileList.GetNextItem(-1, LVNI_SELECTED | LVNI_ALL); item.pszText = profile; - item.cchTextMax = SIZEOF(profile); + item.cchTextMax = _countof(profile); if (!m_profileList.GetItem(&item)) return; @@ -383,7 +383,7 @@ class CChooseProfileDlg : public CDlgBase // profile is placed in "profile_name" subfolder TCHAR tmpPath[MAX_PATH]; - mir_sntprintf(tmpPath, SIZEOF(tmpPath), _T("%s\\%s.dat"), m_pd->ptszProfileDir, profile); + mir_sntprintf(tmpPath, _countof(tmpPath), _T("%s\\%s.dat"), m_pd->ptszProfileDir, profile); if (_taccess(tmpPath, 2)) mir_sntprintf(m_pd->ptszProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profile, profile); else @@ -519,8 +519,8 @@ public: if (auto pTip = evt->nmlvit) { TCHAR profilename[MAX_PATH], tszFullPath[MAX_PATH]; struct _stat statbuf; - m_profileList.GetItemText(pTip->iItem, 0, profilename, SIZEOF(profilename)); - mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profilename, profilename); + m_profileList.GetItemText(pTip->iItem, 0, profilename, _countof(profilename)); + mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profilename, profilename); _tstat(tszFullPath, &statbuf); mir_sntprintf(pTip->pszText, pTip->cchTextMax, _T("%s\n%s: %s\n%s: %s"), tszFullPath, TranslateT("Created"), rtrimt(NEWTSTR_ALLOCA(_tctime(&statbuf.st_ctime))), TranslateT("Modified"), rtrimt(NEWTSTR_ALLOCA(_tctime(&statbuf.st_mtime)))); } diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 6aa601dfbf..86fbbf713f 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -428,7 +428,7 @@ void UnloadAccountsModule() } accounts.destroy(); - for (int i = 0; i < SIZEOF(hHooks); i++) + for (int i = 0; i < _countof(hHooks); i++) UnhookEvent(hHooks[i]); } diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index c34ffdc6d0..ce4c986679 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -124,7 +124,7 @@ static bool OnCreateAccount(HWND hwndDlg) PROTOACCOUNT *pa = param->pa; TCHAR tszAccName[256]; - GetDlgItemText(hwndDlg, IDC_ACCNAME, tszAccName, SIZEOF(tszAccName)); + GetDlgItemText(hwndDlg, IDC_ACCNAME, tszAccName, _countof(tszAccName)); rtrimt(tszAccName); if (tszAccName[0] == 0) { MessageBox(hwndDlg, TranslateT("Account name must be filled."), TranslateT("Account error"), MB_ICONERROR | MB_OK); @@ -133,7 +133,7 @@ static bool OnCreateAccount(HWND hwndDlg) if (param->action == PRAC_ADDED) { char buf[200]; - GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF(buf)); + GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, _countof(buf)); if (FindAccountByName(rtrim(buf))) { MessageBox(hwndDlg, TranslateT("Account name has to be unique. Please enter unique name."), TranslateT("Account error"), MB_ICONERROR | MB_OK); return false; @@ -143,13 +143,13 @@ static bool OnCreateAccount(HWND hwndDlg) if (param->action == PRAC_UPGRADED) { BOOL oldProto = pa->bOldProto; TCHAR szPlugin[MAX_PATH]; - mir_sntprintf(szPlugin, SIZEOF(szPlugin), _T("%s.dll"), _A2T(pa->szProtoName)); + mir_sntprintf(szPlugin, _countof(szPlugin), _T("%s.dll"), _A2T(pa->szProtoName)); int idx = accounts.getIndex(pa); UnloadAccount(pa, false, false); accounts.remove(idx); - if (oldProto && UnloadPlugin(szPlugin, SIZEOF(szPlugin))) { + if (oldProto && UnloadPlugin(szPlugin, _countof(szPlugin))) { TCHAR szNewName[MAX_PATH]; - mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s~"), szPlugin); + mir_sntprintf(szNewName, _countof(szNewName), _T("%s~"), szPlugin); MoveFile(szPlugin, szNewName); } param->action = PRAC_ADDED; @@ -157,10 +157,10 @@ static bool OnCreateAccount(HWND hwndDlg) if (param->action == PRAC_ADDED) { char buf[200]; - GetDlgItemTextA(hwndDlg, IDC_PROTOTYPECOMBO, buf, SIZEOF(buf)); + GetDlgItemTextA(hwndDlg, IDC_PROTOTYPECOMBO, buf, _countof(buf)); char *szBaseProto = NEWSTR_ALLOCA(buf); - GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF(buf)); + GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, _countof(buf)); rtrim(buf); pa = Proto_CreateAccount(buf, szBaseProto, tszAccName); @@ -202,9 +202,9 @@ static INT_PTR CALLBACK AccFormDlgProc(HWND hwndDlg, UINT message, WPARAM wParam TCHAR str[200]; if (param->action == PRAC_CHANGED) { // update EnableWindow(GetDlgItem(hwndDlg, IDC_PROTOTYPECOMBO), FALSE); - mir_sntprintf(str, SIZEOF(str), _T("%s: %s"), TranslateT("Editing account"), param->pa->tszAccountName); + mir_sntprintf(str, _countof(str), _T("%s: %s"), TranslateT("Editing account"), param->pa->tszAccountName); } - else mir_sntprintf(str, SIZEOF(str), _T("%s: %s"), TranslateT("Upgrading account"), param->pa->tszAccountName); + else mir_sntprintf(str, _countof(str), _T("%s: %s"), TranslateT("Upgrading account"), param->pa->tszAccountName); SetWindowText(hwndDlg, str); SetDlgItemText(hwndDlg, IDC_ACCNAME, param->pa->tszAccountName); diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index 0c2f053f8e..d00fbd27a8 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -64,7 +64,7 @@ MIR_APP_DLL(void) ProtoLogA(struct PROTO_INTERFACE *pThis, LPCSTR szFormat, va_l MIR_APP_DLL(void) ProtoLogW(struct PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args) { WCHAR buf[4096]; - int res = _vsnwprintf(buf, SIZEOF(buf), wszFormat, args); + int res = _vsnwprintf(buf, _countof(buf), wszFormat, args); CallService(MS_NETLIB_LOGW, (WPARAM)(pThis ? pThis->m_hNetlibUser : NULL), (LPARAM)((res != -1) ? buf : CMStringW().FormatV(wszFormat, args))); } @@ -244,10 +244,10 @@ MIR_APP_DLL(int) ProtoGetAvatarFileFormat(const TCHAR *ptszFileName) DWORD dwBytes; char buf[32]; - BOOL res = ReadFile(hFile, buf, SIZEOF(buf), &dwBytes, NULL); + BOOL res = ReadFile(hFile, buf, _countof(buf), &dwBytes, NULL); CloseHandle(hFile); - return (res && dwBytes == SIZEOF(buf)) ? ProtoGetBufferFormat(buf) : PA_FORMAT_UNKNOWN; + return (res && dwBytes == _countof(buf)) ? ProtoGetBufferFormat(buf) : PA_FORMAT_UNKNOWN; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/searchresults.cpp b/src/mir_app/src/searchresults.cpp index 8a8ae3ea8f..b75ca7746d 100644 --- a/src/mir_app/src/searchresults.cpp +++ b/src/mir_app/src/searchresults.cpp @@ -150,8 +150,8 @@ int CALLBACK SearchResultsCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPa else { TCHAR szText1[100]; TCHAR szText2[100]; - ListView_GetItemText(hList, (int)lParam1, sortCol, szText1, SIZEOF(szText1)); - ListView_GetItemText(hList, (int)lParam2, sortCol, szText2, SIZEOF(szText2)); + ListView_GetItemText(hList, (int)lParam1, sortCol, szText1, _countof(szText1)); + ListView_GetItemText(hList, (int)lParam2, sortCol, szText2, _countof(szText2)); return mir_tstrcmpi(szText1, szText2)*sortMultiplier; } return 0; @@ -187,7 +187,7 @@ static void BeginSearchFailed(void * arg) protoName, protoName); mir_free((char*)arg); } - else mir_tstrncpy(buf, TranslateT("Could not search on any of the protocols, are you online?"), SIZEOF(buf)); + else mir_tstrncpy(buf, TranslateT("Could not search on any of the protocols, are you online?"), _countof(buf)); MessageBox(0, buf, TranslateT("Problem with search"), MB_OK | MB_ICONERROR); } diff --git a/src/mir_app/src/services.cpp b/src/mir_app/src/services.cpp index 85f6837853..3d1fdaf5c2 100644 --- a/src/mir_app/src/services.cpp +++ b/src/mir_app/src/services.cpp @@ -261,7 +261,7 @@ static int sttRegisterFontWorker(FontIDW *font_id, int hLangpack) if (!mir_tstrcmp(newItem->deffontsettings.szFace, _T("MS Shell Dlg"))) { LOGFONT lf; SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE); - mir_tstrncpy(newItem->deffontsettings.szFace, lf.lfFaceName, SIZEOF(newItem->deffontsettings.szFace)); + mir_tstrncpy(newItem->deffontsettings.szFace, lf.lfFaceName, _countof(newItem->deffontsettings.szFace)); if (!newItem->deffontsettings.size) newItem->deffontsettings.size = lf.lfHeight; } @@ -292,7 +292,7 @@ static INT_PTR sttGetFontWorker(FontIDW *font_id, LOGFONT *lf) for (int i = 0; i < font_id_list.getCount(); i++) { FontInternal& F = font_id_list[i]; - if (!_tcsncmp(F.name, font_id->name, SIZEOF(F.name)) && !_tcsncmp(F.group, font_id->group, SIZEOF(F.group))) { + if (!_tcsncmp(F.name, font_id->name, _countof(F.name)) && !_tcsncmp(F.group, font_id->group, _countof(F.group))) { if (GetFontSettingFromDB(F.dbSettingsGroup, F.prefix, lf, &colour, F.flags) && (F.flags & FIDF_DEFAULTVALID)) { CreateFromFontSettings(&F.deffontsettings, lf); colour = F.deffontsettings.colour; @@ -465,7 +465,7 @@ static INT_PTR sttGetEffectWorker(EffectIDW *effect_id, FONTEFFECT *effect) { for (int i = 0; i < effect_id_list.getCount(); i++) { EffectInternal& E = effect_id_list[i]; - if (!_tcsncmp(E.name, effect_id->name, SIZEOF(E.name)) && !_tcsncmp(E.group, effect_id->group, SIZEOF(E.group))) { + if (!_tcsncmp(E.name, effect_id->name, _countof(E.name)) && !_tcsncmp(E.group, effect_id->group, _countof(E.group))) { FONTEFFECT temp; UpdateEffectSettings(effect_id, &temp); diff --git a/src/mir_app/src/skin2opts.cpp b/src/mir_app/src/skin2opts.cpp index 4c9e7ede0e..b33c2fc876 100644 --- a/src/mir_app/src/skin2opts.cpp +++ b/src/mir_app/src/skin2opts.cpp @@ -49,7 +49,7 @@ static HICON ExtractIconFromPath(const TCHAR *path, int cxIcon, int cyIcon) if (!path) return (HICON)NULL; - mir_tstrncpy(file, path, SIZEOF(file)); + mir_tstrncpy(file, path, _countof(file)); comma = _tcsrchr(file, ','); if (!comma) n = 0; @@ -118,7 +118,7 @@ static void __fastcall MySetCursor(TCHAR* nCursor) static void LoadSectionIcons(TCHAR *filename, SectionItem* sectionActive) { TCHAR path[MAX_PATH]; - mir_sntprintf(path, SIZEOF(path), _T("%s,"), filename); + mir_sntprintf(path, _countof(path), _T("%s,"), filename); size_t suffIndx = mir_tstrlen(path); mir_cslock lck(csIconList); @@ -250,7 +250,7 @@ static TCHAR* OpenFileDlg(HWND hParent, const TCHAR* szFile, BOOL bAll) ofn.lpstrFilter = filter; ofn.lpstrDefExt = _T("dll"); - mir_tstrncpy(file, szFile, SIZEOF(file)); + mir_tstrncpy(file, szFile, _countof(file)); ofn.lpstrFile = file; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; ofn.nMaxFile = MAX_PATH * 2; @@ -317,7 +317,7 @@ static HTREEITEM FindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TCHAR tvi.mask = TVIF_TEXT; tvi.pszText = str; - tvi.cchTextMax = SIZEOF(str); + tvi.cchTextMax = _countof(str); while (tvi.hItem) { TreeView_GetItem(hwndTree, &tvi); @@ -398,7 +398,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ImageList_RemoveAll(hIml); TCHAR filename[MAX_PATH], caption[64]; - GetDlgItemText(hwndDlg, IDC_ICONSET, filename, SIZEOF(filename)); + GetDlgItemText(hwndDlg, IDC_ICONSET, filename, _countof(filename)); { RECT rcPreview, rcGroup; @@ -418,7 +418,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lvi.iItem = 0; int count = (int)_ExtractIconEx(filename, -1, 16, 16, NULL, LR_DEFAULTCOLOR); for (int i = 0; i < count; lvi.iItem++, i++) { - mir_sntprintf(caption, SIZEOF(caption), _T("%d"), i + 1); + mir_sntprintf(caption, _countof(caption), _T("%d"), i + 1); lvi.pszText = caption; HICON hIcon = NULL; @@ -438,7 +438,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case IDC_BROWSE: { TCHAR str[MAX_PATH], *file; - GetDlgItemText(hwndDlg, IDC_ICONSET, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_ICONSET, str, _countof(str)); if (!(file = OpenFileDlg(GetParent(hwndDlg), str, TRUE))) break; SetDlgItemText(hwndDlg, IDC_ICONSET, file); @@ -515,12 +515,12 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR path[MAX_PATH], fullPath[MAX_PATH], filename[MAX_PATH]; LVITEM lvi; - GetDlgItemText(hwndDlg, IDC_ICONSET, fullPath, SIZEOF(fullPath)); + GetDlgItemText(hwndDlg, IDC_ICONSET, fullPath, _countof(fullPath)); PathToRelativeT(fullPath, filename); lvi.mask = LVIF_PARAM; lvi.iItem = dragItem; lvi.iSubItem = 0; ListView_GetItem(hPreview, &lvi); - mir_sntprintf(path, SIZEOF(path), _T("%s,%d"), filename, (int)lvi.lParam); + mir_sntprintf(path, _countof(path), _T("%s,%d"), filename, (int)lvi.lParam); SendMessage(hwndParent, DM_CHANGEICON, dropHiLite, (LPARAM)path); ListView_SetItemState(GetDlgItem(hwndParent, IDC_PREVIEW), dropHiLite, 0, LVIS_DROPHILITED); } diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp index 410b30a1d9..ccf499ef6b 100644 --- a/src/mir_app/src/skinicons.cpp +++ b/src/mir_app/src/skinicons.cpp @@ -229,12 +229,12 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) caps2 = 0; if (IsStatusConnecting(status)) { - mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, 7); + mir_snprintf(iconName, _countof(iconName), "%s%d", mainIconsFmt, 7); return IcoLib_GetIcon(iconName, big); } int statusIndx = -1; - for (int i = 0; i < SIZEOF(statusIcons); i++) + for (int i = 0; i < _countof(statusIcons); i++) if (statusIcons[i].id == status) { statusIndx = i; break; @@ -248,7 +248,7 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) // Otherwise return the global icon. This affects the global status menu mainly. if (accounts.getCount() == 1) { // format: core_status_%proto%statusindex - mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); + mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); HICON hIcon = IcoLib_GetIcon(iconName, big); if (hIcon) @@ -256,24 +256,24 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) } // format: core_status_%s%d - mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx); + mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx); return IcoLib_GetIcon(iconName, big); } // format: core_status_%s%d - mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); + mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); HICON hIcon = IcoLib_GetIcon(iconName, big); if (hIcon == NULL && (caps2 == 0 || (caps2 & statusIcons[statusIndx].pf2))) { PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa) { TCHAR szPath[MAX_PATH], szFullPath[MAX_PATH], *str; - GetModuleFileName(NULL, szPath, SIZEOF(szPath)); + GetModuleFileName(NULL, szPath, _countof(szPath)); // // Queried protocol isn't in list, adding // TCHAR tszSection[MAX_PATH]; - mir_sntprintf(tszSection, SIZEOF(tszSection), _T(PROTOCOLS_PREFIX)_T("/%s"), pa->tszAccountName); + mir_sntprintf(tszSection, _countof(tszSection), _T(PROTOCOLS_PREFIX)_T("/%s"), pa->tszAccountName); SKINICONDESC sid = { 0 }; sid.section.t = tszSection; @@ -282,11 +282,11 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) str = _tcsrchr(szPath, '\\'); if (str != NULL) *str = 0; - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Icons\\proto_%S.dll"), szPath, pa->szProtoName); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\Icons\\proto_%S.dll"), szPath, pa->szProtoName); if (GetFileAttributes(szFullPath) != INVALID_FILE_ATTRIBUTES) sid.defaultFile.t = szFullPath; else { - mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Plugins\\%S.dll"), szPath, szProto); + mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\Plugins\\%S.dll"), szPath, szProto); if (int(ExtractIconEx(szFullPath, statusIcons[statusIndx].resource_id, NULL, &hIcon, 1)) > 0) { DestroyIcon(hIcon); sid.defaultFile.t = szFullPath; @@ -308,12 +308,12 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) if (caps2 == 0) lowidx = statusIndx, highidx = statusIndx + 1; else - lowidx = 0, highidx = SIZEOF(statusIcons); + lowidx = 0, highidx = _countof(statusIcons); for (int i = lowidx; i < highidx; i++) if (caps2 == 0 || (caps2 & statusIcons[i].pf2)) { // format: core_%s%d - mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, i); + mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, szProto, i); sid.pszName = iconName; sid.description.t = cli.pfnGetStatusModeDescription(statusIcons[i].id, 0); sid.iDefaultIndex = statusIcons[i].resource_id; @@ -322,14 +322,14 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) } // format: core_status_%s%d - mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); + mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx); hIcon = IcoLib_GetIcon(iconName, big); if (hIcon) return hIcon; } if (hIcon == NULL) { - mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx); + mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx); hIcon = IcoLib_GetIcon(iconName, big); } @@ -338,7 +338,7 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) MIR_APP_DLL(HANDLE) Skin_GetIconHandle(int idx) { - for (int i = 0; i < SIZEOF(mainIcons); i++) + for (int i = 0; i < _countof(mainIcons); i++) if (idx == mainIcons[i].id) return mainIcons[i].hIcolib; @@ -349,9 +349,9 @@ MIR_APP_DLL(char*) Skin_GetIconName(int idx) { static char szIconName[100]; - for (int i = 0; i < SIZEOF(mainIcons); i++) { + for (int i = 0; i < _countof(mainIcons); i++) { if (idx == mainIcons[i].id) { - mir_snprintf(szIconName, SIZEOF(szIconName), "%s%d", mainIconsFmt, i); + mir_snprintf(szIconName, _countof(szIconName), "%s%d", mainIconsFmt, i); return szIconName; } } @@ -362,7 +362,7 @@ MIR_APP_DLL(HICON) Skin_LoadIcon(int idx, bool big) { // Query for global status icons if (idx < SKINICON_EVENT_MESSAGE) { - if (idx >= SIZEOF(statusIcons)) + if (idx >= _countof(statusIcons)) return NULL; return Skin_LoadProtoIcon(NULL, statusIcons[idx].id, big); @@ -377,7 +377,7 @@ MIR_APP_DLL(HICON) Skin_LoadIcon(int idx, bool big) int LoadSkinIcons(void) { TCHAR modulePath[MAX_PATH]; - GetModuleFileName(g_hInst, modulePath, SIZEOF(modulePath)); + GetModuleFileName(g_hInst, modulePath, _countof(modulePath)); char iconName[MAX_PATH]; SKINICONDESC sid = { 0 }; @@ -386,8 +386,8 @@ int LoadSkinIcons(void) sid.pszName = iconName; // Add main icons to list - for (int i = 0; i < SIZEOF(mainIcons); i++) { - mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, i); + for (int i = 0; i < _countof(mainIcons); i++) { + mir_snprintf(iconName, _countof(iconName), "%s%d", mainIconsFmt, i); sid.section.a = mainIcons[i].section == NULL ? LPGEN("Main icons") : (char*)mainIcons[i].section; sid.description.a = (char*)mainIcons[i].description; sid.iDefaultIndex = mainIcons[i].resource_id; @@ -399,8 +399,8 @@ int LoadSkinIcons(void) // Asterisk is used, to avoid conflict with proto-plugins // 'coz users can't rename it to name with '*' - for (int i = 0; i < SIZEOF(statusIcons); i++) { - mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, i); + for (int i = 0; i < _countof(statusIcons); i++) { + mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, i); sid.pszName = iconName; sid.description.a = (char*)statusIcons[i].description; sid.iDefaultIndex = statusIcons[i].resource_id; diff --git a/src/mir_app/src/sounds.cpp b/src/mir_app/src/sounds.cpp index 712a39441f..0fb366e812 100644 --- a/src/mir_app/src/sounds.cpp +++ b/src/mir_app/src/sounds.cpp @@ -307,9 +307,9 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); if (GetModuleHandle(_T("bass_interface.dll"))) - mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%s (*)%c*%c"), TranslateT("Sound files"), 0, 0, TranslateT("All files"), 0, 0); + mir_sntprintf(filter, _countof(filter), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%s (*)%c*%c"), TranslateT("Sound files"), 0, 0, TranslateT("All files"), 0, 0); else - mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav)%c*.wav%c%s (*)%c*%c"), TranslateT("WAV files"), 0, 0, TranslateT("All files"), 0, 0); + mir_sntprintf(filter, _countof(filter), _T("%s (*.wav)%c*.wav%c%s (*)%c*%c"), TranslateT("WAV files"), 0, 0, TranslateT("All files"), 0, 0); ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = GetParent(hwndDlg); ofn.hInstance = NULL; @@ -324,7 +324,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM str[0] = 0; ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER|OFN_LONGNAMES|OFN_NOCHANGEDIR; - ofn.nMaxFile = SIZEOF(str); + ofn.nMaxFile = _countof(str); ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrDefExt = _T("wav"); if (!GetOpenFileName(&ofn)) diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp index cba82ce12d..c78dcf7af0 100644 --- a/src/mir_app/src/utils.cpp +++ b/src/mir_app/src/utils.cpp @@ -298,7 +298,7 @@ static CountryListEntry countries[] = { static INT_PTR GetCountryByNumber(WPARAM wParam, LPARAM) { - for (int i = 0; i < SIZEOF(countries); i++) + for (int i = 0; i < _countof(countries); i++) if ((int)wParam == countries[i].id) return (INT_PTR)countries[i].szName; @@ -307,7 +307,7 @@ static INT_PTR GetCountryByNumber(WPARAM wParam, LPARAM) static INT_PTR GetCountryByISOCode(WPARAM wParam, LPARAM) { - for (int i = 0; i < SIZEOF(countries); i++) + for (int i = 0; i < _countof(countries); i++) if ( mir_strcmpi((char*)wParam, countries[i].ISOcode) == 0) return (INT_PTR)countries[i].szName; @@ -316,7 +316,7 @@ static INT_PTR GetCountryByISOCode(WPARAM wParam, LPARAM) static INT_PTR GetCountryList(WPARAM wParam, LPARAM lParam) { - *(int*)wParam = SIZEOF(countries); + *(int*)wParam = _countof(countries); *(CountryListEntry**)lParam = countries; return 0; } @@ -329,12 +329,12 @@ static INT_PTR RestartMiranda(WPARAM wParam, LPARAM) PROCESS_INFORMATION pi; STARTUPINFO si = {0}; si.cb = sizeof(si); - GetModuleFileName(NULL, mirandaPath, SIZEOF(mirandaPath)); + GetModuleFileName(NULL, mirandaPath, _countof(mirandaPath)); if (wParam) { VARST profilename( _T("%miranda_profilename%")); - mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), (TCHAR*)profilename); + mir_sntprintf(cmdLine, _countof(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), (TCHAR*)profilename); } - else mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d"), mirandaPath, GetCurrentProcessId()); + else mir_sntprintf(cmdLine, _countof(cmdLine), _T("\"%s\" /restart:%d"), mirandaPath, GetCurrentProcessId()); CallService("CloseAction", 0, 0); CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); diff --git a/src/mir_app/src/visibility.cpp b/src/mir_app/src/visibility.cpp index 447bac6beb..212434ec7d 100644 --- a/src/mir_app/src/visibility.cpp +++ b/src/mir_app/src/visibility.cpp @@ -40,7 +40,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt while (hItem) { HANDLE hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem, childCount); - for (int i=0; i < SIZEOF(iconOn); i++) + for (int i=0; i < _countof(iconOn); i++) if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i] = 0; hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } @@ -50,7 +50,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { - for (int i=0; i < SIZEOF(iconOn); i++) { + for (int i=0; i < _countof(iconOn); i++) { int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i); if (iconOn[i] && iImage == 0) iconOn[i] = 0; if (iImage != EMPTY_EXTRA_ICON) @@ -59,7 +59,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } //set icons - for (int i=0; i < SIZEOF(iconOn); i++) { + for (int i=0; i < _countof(iconOn); i++) { SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+1:0):EMPTY_EXTRA_ICON)); if (groupChildCount) groupChildCount[i]+=childCount[i]; } diff --git a/src/mir_app/src/xmlParser.cpp b/src/mir_app/src/xmlParser.cpp index be360ea40f..8911efec03 100644 --- a/src/mir_app/src/xmlParser.cpp +++ b/src/mir_app/src/xmlParser.cpp @@ -402,7 +402,7 @@ XMLNode XMLNode::openFileHelper(XMLCSTR filename, XMLCSTR tag) // create message char message[2000], *s1 = (char*)"", *s3 = (char*)""; XMLCSTR s2 = _CXML(""); if (pResults.error == eXMLErrorFirstTagNotFound) { s1 = (char*)"First Tag should be '"; s2 = tag; s3 = (char*)"'.\n"; } - mir_snprintf(message, SIZEOF(message), + mir_snprintf(message, _countof(message), #ifdef _XMLWIDECHAR "XML Parsing error inside file '%S'.\n%S\nAt line %i, column %i.\n%s%S%s" #else diff --git a/src/mir_core/src/langpack.cpp b/src/mir_core/src/langpack.cpp index cfc656afd2..9f048b21ec 100644 --- a/src/mir_core/src/langpack.cpp +++ b/src/mir_core/src/langpack.cpp @@ -219,7 +219,7 @@ static void LoadLangPackFile(FILE *fp, char *line) TCHAR *p = _tcsrchr(langPack.tszFullPath, '\\'); if (p) *p = 0; - mir_sntprintf(tszFileName, SIZEOF(tszFileName), _T("%s\\%S"), langPack.tszFullPath, ltrim(line + 9)); + mir_sntprintf(tszFileName, _countof(tszFileName), _T("%s\\%S"), langPack.tszFullPath, ltrim(line + 9)); if (p) *p = '\\'; @@ -361,9 +361,9 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start lpinfo.szAuthors = szAuthors; - MultiByteToWideChar(lpinfo.codepage, 0, szLanguage, -1, lpinfo.tszLanguage, SIZEOF(lpinfo.tszLanguage)); + MultiByteToWideChar(lpinfo.codepage, 0, szLanguage, -1, lpinfo.tszLanguage, _countof(lpinfo.tszLanguage)); - if (!lpinfo.tszLanguage[0] && (lpinfo.Locale == 0) || !GetLocaleInfo(lpinfo.Locale, LOCALE_SENGLANGUAGE, lpinfo.tszLanguage, SIZEOF(lpinfo.tszLanguage))) { + if (!lpinfo.tszLanguage[0] && (lpinfo.Locale == 0) || !GetLocaleInfo(lpinfo.Locale, LOCALE_SENGLANGUAGE, lpinfo.tszLanguage, _countof(lpinfo.tszLanguage))) { TCHAR *p = _tcschr(lpinfo.tszFileName, '_'); _tcsncpy_s(lpinfo.tszLanguage, ((p != NULL) ? (p + 1) : lpinfo.tszFileName), _TRUNCATE); p = _tcsrchr(lpinfo.tszLanguage, _T('.')); @@ -380,7 +380,7 @@ MIR_CORE_DLL(int) LoadLangPack(const TCHAR *ptszLangPack) // ensure that a lang's name is a full file name TCHAR tszFullPath[MAX_PATH]; if (!PathIsAbsoluteT(ptszLangPack)) - mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\%s"), g_tszRoot, ptszLangPack); + mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\%s"), g_tszRoot, ptszLangPack); else _tcsncpy_s(tszFullPath, ptszLangPack, _TRUNCATE); @@ -527,7 +527,7 @@ MIR_CORE_DLL(void) TranslateMenu_LP(HMENU hMenu, int hLangpack) TCHAR str[256]; mii.fMask = MIIM_TYPE | MIIM_SUBMENU; mii.dwTypeData = (TCHAR*)str; - mii.cch = SIZEOF(str); + mii.cch = _countof(str); GetMenuItemInfo(hMenu, i, TRUE, &mii); if (mii.cch && mii.dwTypeData) { @@ -547,7 +547,7 @@ MIR_CORE_DLL(void) TranslateMenu_LP(HMENU hMenu, int hLangpack) static void TranslateWindow(MUUID *pUuid, HWND hwnd) { TCHAR title[2048]; - GetWindowText(hwnd, title, SIZEOF(title)); + GetWindowText(hwnd, title, _countof(title)); TCHAR *result = (TCHAR*)LangPackTranslateString(pUuid, (const char*)title, TRUE); if (result != title) @@ -566,7 +566,7 @@ static BOOL CALLBACK TranslateDialogEnumProc(HWND hwnd, LPARAM lParam) MUUID *uuid = Langpack_LookupUuid(hLangpack); TCHAR szClass[32]; - GetClassName(hwnd, szClass, SIZEOF(szClass)); + GetClassName(hwnd, szClass, _countof(szClass)); if (!mir_tstrcmpi(szClass, _T("static")) || !mir_tstrcmpi(szClass, _T("hyperlink")) || !mir_tstrcmpi(szClass, _T("button")) || !mir_tstrcmpi(szClass, _T("MButtonClass")) || !mir_tstrcmpi(szClass, _T("MHeaderbarCtrl"))) TranslateWindow(uuid, hwnd); else if (!mir_tstrcmpi(szClass, _T("edit"))) { @@ -643,7 +643,7 @@ void GetDefaultLang() // look into mirandaboot.ini TCHAR tszPath[MAX_PATH], tszLangName[256]; PathToAbsoluteT(_T("\\mirandaboot.ini"), tszPath); - GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszLangName, SIZEOF(tszLangName), tszPath); + GetPrivateProfileString(_T("Language"), _T("DefaultLanguage"), _T(""), tszLangName, _countof(tszLangName), tszPath); if (tszLangName[0]) { if (!mir_tstrcmpi(tszLangName, _T("default"))) { db_set_ts(NULL, "Langpack", "Current", _T("default")); @@ -656,8 +656,8 @@ void GetDefaultLang() } // try to load langpack that matches UserDefaultUILanguage - if (GetLocaleInfo(MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, tszLangName, SIZEOF(tszLangName))) { - mir_sntprintf(tszPath, SIZEOF(tszPath), _T("langpack_%s.txt"), _tcslwr(tszLangName)); + if (GetLocaleInfo(MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, tszLangName, _countof(tszLangName))) { + mir_sntprintf(tszPath, _countof(tszPath), _T("langpack_%s.txt"), _tcslwr(tszLangName)); if (!LoadLangPack(tszPath)) { db_set_ts(NULL, "Langpack", "Current", tszPath); return; @@ -665,7 +665,7 @@ void GetDefaultLang() } // finally try to load first file - mir_sntprintf(tszPath, SIZEOF(tszPath), _T("%s\\langpack_*.txt"), g_tszRoot); + mir_sntprintf(tszPath, _countof(tszPath), _T("%s\\langpack_*.txt"), g_tszRoot); WIN32_FIND_DATA fd; HANDLE hFind = FindFirstFile(tszPath, &fd); diff --git a/src/mir_core/src/path.cpp b/src/mir_core/src/path.cpp index e9fb81c672..051295984b 100644 --- a/src/mir_core/src/path.cpp +++ b/src/mir_core/src/path.cpp @@ -78,7 +78,7 @@ MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, const char *base) if (pSrc[0] == '\\') pSrc++; mir_snprintf(buf, "%s%s", base, pSrc); - return GetFullPathNameA(buf, SIZEOF(buf), pOut, NULL); + return GetFullPathNameA(buf, _countof(buf), pOut, NULL); } MIR_CORE_DLL(void) CreatePathToFile(char *szFilePath) @@ -101,7 +101,7 @@ MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir) return 1; char szTestDir[MAX_PATH]; - mir_strncpy(szTestDir, szDir, SIZEOF(szTestDir)); + mir_strncpy(szTestDir, szDir, _countof(szTestDir)); DWORD dwAttributes = GetFileAttributesA(szTestDir); if (dwAttributes != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) @@ -191,7 +191,7 @@ MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR *szDir) return 1; WCHAR szTestDir[MAX_PATH]; - mir_wstrncpy(szTestDir, szDir, SIZEOF(szTestDir)); + mir_wstrncpy(szTestDir, szDir, _countof(szTestDir)); DWORD dwAttributes = GetFileAttributesW(szTestDir); if (dwAttributes != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) @@ -209,12 +209,12 @@ MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR *szDir) int InitPathUtils(void) { - GetModuleFileNameA(NULL, szMirandaPath, SIZEOF(szMirandaPath)); + GetModuleFileNameA(NULL, szMirandaPath, _countof(szMirandaPath)); char *p = strrchr(szMirandaPath, '\\'); if (p) p[1] = 0; - GetModuleFileNameW(NULL, szMirandaPathW, SIZEOF(szMirandaPathW)); + GetModuleFileNameW(NULL, szMirandaPathW, _countof(szMirandaPathW)); WCHAR *tp = wcsrchr(szMirandaPathW, '\\'); if (tp) tp[1] = 0; diff --git a/src/mir_core/src/timezones.cpp b/src/mir_core/src/timezones.cpp index b9510f2a71..df5958fe7b 100644 --- a/src/mir_core/src/timezones.cpp +++ b/src/mir_core/src/timezones.cpp @@ -130,11 +130,11 @@ void FormatTime(const SYSTEMTIME *st, const TCHAR *szFormat, TCHAR *szDest, size if (iso) tszTemp.AppendFormat(_T("%d-%02d-%02dT%02d:%02d:%02dZ"), st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond); else if (date) { - GetDateFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, SIZEOF(dateTimeStr)); + GetDateFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, _countof(dateTimeStr)); tszTemp.Append(dateTimeStr); } else { - GetTimeFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, SIZEOF(dateTimeStr)); + GetTimeFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, _countof(dateTimeStr)); tszTemp.Append(dateTimeStr); } } @@ -382,7 +382,7 @@ static const ListMessages* GetListMessages(HWND hWnd, DWORD dwFlags) if (!(dwFlags & (TZF_PLF_CB | TZF_PLF_LB))) { TCHAR tszClassName[128]; - GetClassName(hWnd, tszClassName, SIZEOF(tszClassName)); + GetClassName(hWnd, tszClassName, _countof(tszClassName)); if (!mir_tstrcmpi(tszClassName, _T("COMBOBOX"))) dwFlags |= TZF_PLF_CB; else if (!mir_tstrcmpi(tszClassName, _T("LISTBOX"))) @@ -548,7 +548,7 @@ void InitTimeZones(void) HKEY hSubKey; TCHAR tszName[MIM_TZ_NAMELEN]; - DWORD dwSize = SIZEOF(tszName); + DWORD dwSize = _countof(tszName); while (ERROR_NO_MORE_ITEMS != RegEnumKeyEx(hKey, dwIndex++, tszName, &dwSize, NULL, NULL, 0, NULL)) { if (ERROR_SUCCESS == RegOpenKeyEx(hKey, tszName, 0, KEY_QUERY_VALUE, &hSubKey)) { dwSize = sizeof(tszName); @@ -569,16 +569,16 @@ void InitTimeZones(void) tz->hash = mir_hashstrT(tszName); tz->offset = INT_MIN; - GetLocalizedString(hSubKey, _T("Display"), tz->szDisplay, SIZEOF(tz->szDisplay)); - GetLocalizedString(hSubKey, _T("Std"), tz->tzi.StandardName, SIZEOF(tz->tzi.StandardName)); - GetLocalizedString(hSubKey, _T("Dlt"), tz->tzi.DaylightName, SIZEOF(tz->tzi.DaylightName)); + GetLocalizedString(hSubKey, _T("Display"), tz->szDisplay, _countof(tz->szDisplay)); + GetLocalizedString(hSubKey, _T("Std"), tz->tzi.StandardName, _countof(tz->tzi.StandardName)); + GetLocalizedString(hSubKey, _T("Dlt"), tz->tzi.DaylightName, _countof(tz->tzi.DaylightName)); g_timezones.insert(tz); g_timezonesBias.insert(tz); RegCloseKey(hSubKey); } - dwSize = SIZEOF(tszName); + dwSize = _countof(tszName); } RegCloseKey(hKey); } diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index be5e6df89d..f786afe73a 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -1403,7 +1403,7 @@ HTREEITEM CCtrlTreeView::MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter) TVINSERTSTRUCT tvis = { 0 }; tvis.itemex.mask = (UINT)-1; tvis.itemex.pszText = name; - tvis.itemex.cchTextMax = SIZEOF(name); + tvis.itemex.cchTextMax = _countof(name); tvis.itemex.hItem = hItem; if (!GetItem(&tvis.itemex)) return NULL; @@ -1628,7 +1628,7 @@ void CCtrlTreeView::TranslateItem(HTREEITEM hItem) { TVITEMEX tvi; TCHAR buf[128]; - GetItem(hItem, &tvi, buf, SIZEOF(buf)); + GetItem(hItem, &tvi, buf, _countof(buf)); tvi.pszText = TranslateTS(tvi.pszText); SetItem(&tvi); } @@ -1672,7 +1672,7 @@ HTREEITEM CCtrlTreeView::FindNamedItem(HTREEITEM hItem, const TCHAR *name) tvi.mask = TVIF_TEXT; tvi.pszText = str; - tvi.cchTextMax = SIZEOF(str); + tvi.cchTextMax = _countof(str); while (tvi.hItem) { GetItem(&tvi); diff --git a/src/mir_core/src/winutil.cpp b/src/mir_core/src/winutil.cpp index 0dd0a2e897..e0aeb7c803 100644 --- a/src/mir_core/src/winutil.cpp +++ b/src/mir_core/src/winutil.cpp @@ -31,16 +31,16 @@ MIR_CORE_DLL(int) Utils_SaveWindowPosition(HWND hwnd, MCONTACT hContact, const c GetWindowPlacement(hwnd, &wp); char szSettingName[64]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%sx", szNamePrefix); db_set_dw(hContact, szModule, szSettingName, wp.rcNormalPosition.left); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%sy", szNamePrefix); db_set_dw(hContact, szModule, szSettingName, wp.rcNormalPosition.top); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%swidth", szNamePrefix); db_set_dw(hContact, szModule, szSettingName, wp.rcNormalPosition.right-wp.rcNormalPosition.left); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%sheight", szNamePrefix); db_set_dw(hContact, szModule, szSettingName, wp.rcNormalPosition.bottom-wp.rcNormalPosition.top); return 0; } @@ -54,12 +54,12 @@ EXTERN_C MIR_CORE_DLL(int) Utils_RestoreWindowPosition(HWND hwnd, MCONTACT hCont 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); if (x == -1) return 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); if (flags & RWPF_NOSIZE) @@ -68,10 +68,10 @@ EXTERN_C MIR_CORE_DLL(int) Utils_RestoreWindowPosition(HWND hwnd, MCONTACT hCont wp.rcNormalPosition.left = x; wp.rcNormalPosition.top = y; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%swidth", szNamePrefix); wp.rcNormalPosition.right = wp.rcNormalPosition.left+db_get_dw(hContact, szModule, szSettingName, -1); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", szNamePrefix); + mir_snprintf(szSettingName, _countof(szSettingName), "%sheight", szNamePrefix); wp.rcNormalPosition.bottom = wp.rcNormalPosition.top+db_get_dw(hContact, szModule, szSettingName, -1); } wp.flags = 0; diff --git a/src/mir_core/src/winver.cpp b/src/mir_core/src/winver.cpp index ffe68b114c..bf40d2a2fa 100644 --- a/src/mir_core/src/winver.cpp +++ b/src/mir_core/src/winver.cpp @@ -55,7 +55,7 @@ MIR_CORE_DLL(BOOL) IsFullScreen() HWND hWnd = GetForegroundWindow(); if (hWnd && hWnd != hWndDesktop && hWnd != hWndShell) { TCHAR tszClassName[128] = _T(""); - GetClassName(hWnd, tszClassName, SIZEOF(tszClassName)); + GetClassName(hWnd, tszClassName, _countof(tszClassName)); if (_tcscmp(tszClassName, _T("WorkerW"))) { RECT rect, rectw, recti; GetWindowRect(hWnd, &rectw); @@ -80,7 +80,7 @@ MIR_CORE_DLL(BOOL) IsWorkstationLocked(void) TCHAR tszName[100]; DWORD cbName; - BOOL bLocked = (!GetUserObjectInformation(hDesk, UOI_NAME, tszName, SIZEOF(tszName), &cbName) || mir_tstrcmpi(tszName, _T("default")) != 0); + BOOL bLocked = (!GetUserObjectInformation(hDesk, UOI_NAME, tszName, _countof(tszName), &cbName) || mir_tstrcmpi(tszName, _T("default")) != 0); CloseDesktop(hDesk); return bLocked; } -- cgit v1.2.3