diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
commit | 4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch) | |
tree | 9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /protocols/VKontakte | |
parent | f0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (diff) |
SIZEOF replaced with more secure analog - _countof
git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 26 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_avatars.cpp | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_captcha.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 16 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_search.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_wallpost.cpp | 4 |
8 files changed, 34 insertions, 34 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 85c2c6cbb0..39bc02044a 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -55,9 +55,9 @@ bool tlstrstr(TCHAR* _s1, TCHAR* _s2) TCHAR s1[1024], s2[1024];
_tcsncpy_s(s1, _s1, _TRUNCATE);
- CharLowerBuff(s1, SIZEOF(s1));
+ CharLowerBuff(s1, _countof(s1));
_tcsncpy_s(s2, _s2, _TRUNCATE);
- CharLowerBuff(s2, SIZEOF(s2));
+ CharLowerBuff(s2, _countof(s2));
return _tcsstr(s1, s2) != NULL;
}
@@ -82,12 +82,12 @@ static IconItem iconList[] = void InitIcons()
{
- Icon_Register(hInst, LPGEN("Protocols")"/"LPGEN("VKontakte"), iconList, SIZEOF(iconList), "VKontakte");
+ Icon_Register(hInst, LPGEN("Protocols")"/"LPGEN("VKontakte"), iconList, _countof(iconList), "VKontakte");
}
HANDLE GetIconHandle(int iCommand)
{
- for (int i = 0; i < SIZEOF(iconList); i++)
+ for (int i = 0; i < _countof(iconList); i++)
if (iconList[i].defIconID == iCommand)
return iconList[i].hIcolib;
@@ -735,13 +735,13 @@ void CVkProto::SetSrmmReadStatus(MCONTACT hContact) TCHAR ttime[64];
_locale_t locale = _create_locale(LC_ALL, "");
- _tcsftime_l(ttime, SIZEOF(ttime), _T("%X - %x"), localtime(&time), locale);
+ _tcsftime_l(ttime, _countof(ttime), _T("%X - %x"), localtime(&time), locale);
_free_locale(locale);
StatusTextData st = { 0 };
st.cbSize = sizeof(st);
st.hIcon = IcoLib_GetIconByHandle(GetIconHandle(IDI_READMSG));
- mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s"), ttime);
+ mir_sntprintf(st.tszText, _countof(st.tszText), TranslateT("Message read: %s"), ttime);
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
}
@@ -756,7 +756,7 @@ char* CVkProto::GetStickerId(const char* Msg, int &stickerid) if (tmpMsg)
iRes = sscanf(tmpMsg, "[sticker:%d]", &stickerid);
if (iRes == 1) {
- mir_snprintf(HeadMsg, SIZEOF(HeadMsg), "[sticker:%d]", stickerid);
+ mir_snprintf(HeadMsg, _countof(HeadMsg), "[sticker:%d]", stickerid);
size_t retLen = mir_strlen(HeadMsg);
if (retLen < mir_strlen(Msg)) {
CMStringA szMsg(Msg, int(mir_strlen(Msg) - mir_strlen(tmpMsg)));
@@ -834,7 +834,7 @@ CMString CVkProto::SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedba CMString tszRes;
vkFeedback = vkParent = vkNull;
- for (int i = 0; i < SIZEOF(vkNotification); i++)
+ for (int i = 0; i < _countof(vkNotification); i++)
if (tszType == vkNotification[i].ptszType) {
vkFeedback = vkNotification[i].vkFeedback;
vkParent = vkNotification[i].vkParent;
@@ -852,7 +852,7 @@ CMString CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC) return tszRes;
CMString tszLink, tszPreviewLink;
- for (int i = 0; i < SIZEOF(szImageTypes); i++) {
+ for (int i = 0; i < _countof(szImageTypes); i++) {
const JSONNode &n = jnPhoto[szImageTypes[i]];
if (!n.isnull()) {
tszLink = n.as_mstring();
@@ -922,7 +922,7 @@ CMString CVkProto::SetBBCString(LPCTSTR ptszString, BBCSupport iBBC, VKBBCType b return CMString();
TCHAR *ptszFormat = NULL;
- for (int i = 0; i < SIZEOF(bbcItem); i++)
+ for (int i = 0; i < _countof(bbcItem); i++)
if (bbcItem[i].vkBBCType == bbcType && bbcItem[i].vkBBCSettings == iBBC) {
ptszFormat = bbcItem[i].ptszTempate;
break;
@@ -1059,7 +1059,7 @@ CMString CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport }
else {
CMString tszLink;
- for (int i = 0; i < SIZEOF(szImageTypes); i++) {
+ for (int i = 0; i < _countof(szImageTypes); i++) {
const JSONNode &n = jnSticker[szImageTypes[i]];
if (!n.isnull()) {
tszLink = n.as_mstring();
@@ -1097,7 +1097,7 @@ CMString CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport continue;
CMString tszLink;
- for (int i = 0; i < SIZEOF(szGiftTypes); i++) {
+ for (int i = 0; i < _countof(szGiftTypes); i++) {
const JSONNode &n = jnGift[szGiftTypes[i]];
if (!n.isnull()) {
tszLink = n.as_mstring();
@@ -1146,7 +1146,7 @@ CMString CVkProto::GetFwdMessages(const JSONNode &jnMessages, BBCSupport iBBC) time_t datetime = (time_t)jnMsg["date"].as_int();
TCHAR ttime[64];
_locale_t locale = _create_locale(LC_ALL, "");
- _tcsftime_l(ttime, SIZEOF(ttime), _T("%x %X"), localtime(&datetime), locale);
+ _tcsftime_l(ttime, _countof(ttime), _T("%x %X"), localtime(&datetime), locale);
_free_locale(locale);
CMString tszBody(jnMsg["body"].as_mstring());
diff --git a/protocols/VKontakte/src/vk_avatars.cpp b/protocols/VKontakte/src/vk_avatars.cpp index ef54de209f..85e97f9906 100644 --- a/protocols/VKontakte/src/vk_avatars.cpp +++ b/protocols/VKontakte/src/vk_avatars.cpp @@ -23,7 +23,7 @@ void CVkProto::OnReceiveAvatar(NETLIBHTTPREQUEST *reply, AsyncHttpRequest* pReq) return;
PROTO_AVATAR_INFORMATION ai = { 0 };
- GetAvatarFileName((MCONTACT)pReq->pUserInfo, ai.filename, SIZEOF(ai.filename));
+ GetAvatarFileName((MCONTACT)pReq->pUserInfo, ai.filename, _countof(ai.filename));
ai.format = ProtoGetBufferFormat(reply->pData);
FILE *out = _tfopen(ai.filename, _T("wb"));
@@ -80,8 +80,8 @@ INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM, LPARAM lParam) return GAIR_NOAVATAR;
TCHAR tszFileName[MAX_PATH];
- GetAvatarFileName(pai->hContact, tszFileName, SIZEOF(tszFileName));
- _tcsncpy(pai->filename, tszFileName, SIZEOF(pai->filename));
+ GetAvatarFileName(pai->hContact, tszFileName, _countof(tszFileName));
+ _tcsncpy(pai->filename, tszFileName, _countof(pai->filename));
pai->format = ProtoGetAvatarFormat(pai->filename);
@@ -160,7 +160,7 @@ void CVkProto::SetAvatarUrl(MCONTACT hContact, CMString &tszUrl) setByte(hContact,"NeedNewAvatar", 1);
PROTO_AVATAR_INFORMATION ai = { 0 };
ai.hContact = hContact;
- GetAvatarFileName(ai.hContact, ai.filename, SIZEOF(ai.filename));
+ GetAvatarFileName(ai.hContact, ai.filename, _countof(ai.filename));
ai.format = ProtoGetAvatarFormat(ai.filename);
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, 0);
}
diff --git a/protocols/VKontakte/src/vk_captcha.cpp b/protocols/VKontakte/src/vk_captcha.cpp index 0c0699900a..ede03c51e2 100644 --- a/protocols/VKontakte/src/vk_captcha.cpp +++ b/protocols/VKontakte/src/vk_captcha.cpp @@ -80,7 +80,7 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam return TRUE;
case IDOK:
- GetDlgItemTextA(hwndDlg, IDC_VALUE, params->Result, SIZEOF(params->Result));
+ GetDlgItemTextA(hwndDlg, IDC_VALUE, params->Result, _countof(params->Result));
EndDialog(hwndDlg, 1);
return TRUE;
}
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 2021f0ee12..5b8b7f7b0f 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -73,7 +73,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg) GCDEST gcd = { m_szModuleName, sid, GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
- for (int i = SIZEOF(sttStatuses)-1; i >= 0; i--) {
+ for (int i = _countof(sttStatuses)-1; i >= 0; i--) {
gce.ptszStatus = TranslateTS(sttStatuses[i]);
CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
@@ -839,11 +839,11 @@ int CVkProto::OnGcMenuHook(WPARAM, LPARAM lParam) return 0;
if (gcmi->Type == MENU_ON_LOG) {
- gcmi->nItems = SIZEOF(sttLogListItems);
+ gcmi->nItems = _countof(sttLogListItems);
gcmi->Item = sttLogListItems;
}
else if (gcmi->Type == MENU_ON_NICKLIST) {
- gcmi->nItems = SIZEOF(sttListItems);
+ gcmi->nItems = _countof(sttListItems);
gcmi->Item = sttListItems;
}
return 0;
@@ -922,7 +922,7 @@ static INT_PTR CALLBACK GcCreateDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L }
TCHAR tszTitle[1024];
- GetDlgItemText(hwndDlg, IDC_TITLE, tszTitle, SIZEOF(tszTitle));
+ GetDlgItemText(hwndDlg, IDC_TITLE, tszTitle, _countof(tszTitle));
ppro->CreateNewChat(uids, tszTitle);
EndDialog(hwndDlg, 0);
return TRUE;
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 960dfe70d5..98a7e633aa 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -63,10 +63,10 @@ INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
TCHAR str[1025];
- GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, _countof(str));
ppro->setTString("Login", str);
- GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, _countof(str));
T2Utf szRawPasswd(str);
if (szRawPasswd != NULL)
ppro->setString("Password", szRawPasswd);
@@ -170,16 +170,16 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
TCHAR str[1025];
- GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, _countof(str));
ppro->setTString("Login", str);
- GetDlgItemText(hwndDlg, IDC_GROUPNAME, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_GROUPNAME, str, _countof(str));
if (mir_tstrcmp(ppro->getGroup(), str)) {
ppro->setGroup(str);
ppro->setTString("ProtoGroup", str);
}
- GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, _countof(str));
T2Utf szRawPasswd(str);
if (szRawPasswd != NULL)
ppro->setString("Password", szRawPasswd);
@@ -330,7 +330,7 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam db_set_b(NULL, "ListeningTo", szListeningTo, ppro->m_iMusicSendMetod == 0 ? 0 : 1);
TCHAR buffer[5] = { 0 };
- GetDlgItemText(hwndDlg, IDC_ED_INT_INVIS, buffer, SIZEOF(buffer));
+ GetDlgItemText(hwndDlg, IDC_ED_INT_INVIS, buffer, _countof(buffer));
ppro->setDword("InvisibleInterval", ppro->m_iInvisibleInterval = _ttoi(buffer));
}
break;
@@ -494,10 +494,10 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar ppro->setByte("NotificationFilterInvites", ppro->m_bNotificationFilterInvites);
TCHAR buffer[5] = { 0 };
- GetDlgItemText(hwndDlg, IDC_ED_INT_NEWS, buffer, SIZEOF(buffer));
+ GetDlgItemText(hwndDlg, IDC_ED_INT_NEWS, buffer, _countof(buffer));
ppro->setDword("NewsInterval", ppro->m_iNewsInterval = _ttoi(buffer));
- GetDlgItemText(hwndDlg, IDC_ED_INT_NOTIF, buffer, SIZEOF(buffer));
+ GetDlgItemText(hwndDlg, IDC_ED_INT_NOTIF, buffer, _countof(buffer));
ppro->setDword("NotificationsInterval", ppro->m_iNotificationsInterval = _ttoi(buffer));
}
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 45b1bc47cf..b0945d5525 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -148,7 +148,7 @@ int CVkProto::OnModulesLoaded(WPARAM, LPARAM) GCREGISTER gcr = { sizeof(gcr) };
gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
- gcr.nColors = SIZEOF(sttColors);
+ gcr.nColors = _countof(sttColors);
gcr.pColors = sttColors;
CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr);
CreateProtoService(PS_LEAVECHAT, &CVkProto::OnLeaveChat);
diff --git a/protocols/VKontakte/src/vk_search.cpp b/protocols/VKontakte/src/vk_search.cpp index 82b806c287..957da57c42 100644 --- a/protocols/VKontakte/src/vk_search.cpp +++ b/protocols/VKontakte/src/vk_search.cpp @@ -71,7 +71,7 @@ void __cdecl CVkProto::SearchThread(void* p) PROTOSEARCHBYNAME *pParam = (PROTOSEARCHBYNAME *)p;
TCHAR arg[200];
- mir_sntprintf(arg, SIZEOF(arg), _T("%s %s %s"), pParam->pszFirstName, pParam->pszNick, pParam->pszLastName);
+ mir_sntprintf(arg, _countof(arg), _T("%s %s %s"), pParam->pszFirstName, pParam->pszNick, pParam->pszLastName);
debugLog(_T("CVkProto::SearchThread %s"), arg);
if (!IsOnline())
return;
diff --git a/protocols/VKontakte/src/vk_wallpost.cpp b/protocols/VKontakte/src/vk_wallpost.cpp index 585cf1738d..e46aec3d77 100644 --- a/protocols/VKontakte/src/vk_wallpost.cpp +++ b/protocols/VKontakte/src/vk_wallpost.cpp @@ -63,8 +63,8 @@ static INT_PTR CALLBACK WallPostFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara case IDOK:
TCHAR tszMsg[4096], tszUrl[4096];
- GetDlgItemText(hwndDlg, IDC_ED_MSG, tszMsg, SIZEOF(tszMsg));
- GetDlgItemText(hwndDlg, IDC_ED_URL, tszUrl, SIZEOF(tszUrl));
+ GetDlgItemText(hwndDlg, IDC_ED_MSG, tszMsg, _countof(tszMsg));
+ GetDlgItemText(hwndDlg, IDC_ED_URL, tszUrl, _countof(tszUrl));
if (IsEmpty(tszMsg) && IsEmpty(tszUrl)) {
SetDlgItemText(hwndDlg, IDC_ST_WARNING, TranslateT("Attention! Message body or url should not be empty!"));
|