summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-19 19:35:42 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-19 19:35:42 +0000
commit4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch)
tree9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /protocols/FacebookRM
parentf0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (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/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/avatars.cpp2
-rw-r--r--protocols/FacebookRM/src/captcha.cpp2
-rw-r--r--protocols/FacebookRM/src/chat.cpp8
-rw-r--r--protocols/FacebookRM/src/communication.cpp6
-rw-r--r--protocols/FacebookRM/src/contacts.cpp2
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp24
-rw-r--r--protocols/FacebookRM/src/json.cpp4
-rw-r--r--protocols/FacebookRM/src/proto.cpp12
-rw-r--r--protocols/FacebookRM/src/theme.cpp4
9 files changed, 32 insertions, 32 deletions
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp
index 9beaa10869..15abcdd60f 100644
--- a/protocols/FacebookRM/src/avatars.cpp
+++ b/protocols/FacebookRM/src/avatars.cpp
@@ -126,7 +126,7 @@ void FacebookProto::UpdateAvatarWorker(void *)
std::tstring FacebookProto::GetAvatarFolder()
{
TCHAR path[MAX_PATH];
- mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), VARST(_T("%miranda_avatarcache%")), m_tszUserName);
+ mir_sntprintf(path, _countof(path), _T("%s\\%s"), VARST(_T("%miranda_avatarcache%")), m_tszUserName);
return path;
}
diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp
index 4ff4a2faa9..98cc51bd1e 100644
--- a/protocols/FacebookRM/src/captcha.cpp
+++ b/protocols/FacebookRM/src/captcha.cpp
@@ -85,7 +85,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/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index 2b9af2ddcb..e6e29ddb90 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -365,7 +365,7 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{ LPGENT("&Invite user..."), 10, MENU_ITEM, FALSE },
{ LPGENT("&Leave chat session"), 20, MENU_ITEM, FALSE }
};
- gcmi->nItems = SIZEOF(Items);
+ gcmi->nItems = _countof(Items);
gcmi->Item = (gc_item*)Items;
}
else if (gcmi->Type == MENU_ON_NICKLIST)
@@ -379,7 +379,7 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{ _T(""), 100, MENU_SEPARATOR, FALSE },
{ LPGENT("&Leave chat session"), 110, MENU_ITEM, FALSE }
};
- gcmi->nItems = SIZEOF(Items);
+ gcmi->nItems = _countof(Items);
gcmi->Item = (gc_item*)Items;*/
gcmi->nItems = 0;
gcmi->Item = NULL;
@@ -391,7 +391,7 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{ LPGENT("User &details"), 10, MENU_ITEM, FALSE },
{ LPGENT("User &history"), 20, MENU_ITEM, FALSE }
};
- gcmi->nItems = SIZEOF(Items);
+ gcmi->nItems = _countof(Items);
gcmi->Item = (gc_item*)Items;
}
}
@@ -415,7 +415,7 @@ void FacebookProto::PrepareNotificationsChatRoom() {
MCONTACT hNotificationsChatRoom = ChatIDToHContact(FACEBOOK_NOTIFICATIONS_CHATROOM);
if (hNotificationsChatRoom == NULL || getDword(hNotificationsChatRoom, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE) {
TCHAR nameT[200];
- mir_sntprintf(nameT, SIZEOF(nameT), _T("%s: %s"), m_tszUserName, TranslateT("Notifications"));
+ mir_sntprintf(nameT, _countof(nameT), _T("%s: %s"), m_tszUserName, TranslateT("Notifications"));
// Create the group chat session
GCSESSION gcw = { sizeof(gcw) };
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 342845436f..2c50763622 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -546,7 +546,7 @@ NETLIBHTTPHEADER *facebook_client::get_request_headers(int request_type, int *he
std::string facebook_client::get_newsfeed_type()
{
BYTE feed_type = parent->getByte(FACEBOOK_KEY_FEED_TYPE, 0);
- if (feed_type >= SIZEOF(feed_types))
+ if (feed_type >= _countof(feed_types))
feed_type = 0;
std::string ret = "sk=";
@@ -559,7 +559,7 @@ std::string facebook_client::get_newsfeed_type()
std::string facebook_client::get_server_type()
{
BYTE server_type = parent->getByte(FACEBOOK_KEY_SERVER_TYPE, 0);
- if (server_type >= SIZEOF(server_types))
+ if (server_type >= _countof(server_types))
server_type = 0;
return server_types[server_type].id;
}
@@ -567,7 +567,7 @@ std::string facebook_client::get_server_type()
std::string facebook_client::get_privacy_type()
{
BYTE privacy_type = parent->getByte(FACEBOOK_KEY_PRIVACY_TYPE, 0);
- if (privacy_type >= SIZEOF(privacy_types))
+ if (privacy_type >= _countof(privacy_types))
privacy_type = 0;
return privacy_types[privacy_type].id;
}
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index d7b575f6ed..184713d917 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -313,7 +313,7 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc)
if (fbc->participants.size() > namesUsed) {
TCHAR more[200];
- mir_sntprintf(more, SIZEOF(more), TranslateT("%s and more (%d)"), fbc->chat_name.c_str(), fbc->participants.size() - namesUsed);
+ mir_sntprintf(more, _countof(more), TranslateT("%s and more (%d)"), fbc->chat_name.c_str(), fbc->participants.size() - namesUsed);
fbc->chat_name = more;
}
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 3610b5d19f..2cbcfff995 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -88,10 +88,10 @@ INT_PTR CALLBACK FBAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
{
char str[128];
- GetDlgItemTextA(hwnd, IDC_UN, str, SIZEOF(str));
+ GetDlgItemTextA(hwnd, IDC_UN, str, _countof(str));
db_set_s(NULL, proto->ModuleName(), FACEBOOK_KEY_LOGIN, str);
- GetDlgItemTextA(hwnd, IDC_PW, str, SIZEOF(str));
+ GetDlgItemTextA(hwnd, IDC_PW, str, _countof(str));
db_set_s(NULL, proto->ModuleName(), FACEBOOK_KEY_PASS, str);
return TRUE;
}
@@ -107,7 +107,7 @@ void RefreshPrivacy(HWND hwnd, post_status_data *data)
SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_RESETCONTENT, 0, 0);
int wall_id = SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCURSEL, 0, 0);
if (data->walls[wall_id]->user_id == data->proto->facy.self_.user_id) {
- for (size_t i = 0; i < SIZEOF(privacy_types); i++)
+ for (size_t i = 0; i < _countof(privacy_types); i++)
SendDlgItemMessageA(hwnd, IDC_PRIVACY, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(Translate(privacy_types[i].name)));
}
else {
@@ -219,7 +219,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
ptrA firstname(data->proto->getStringA(FACEBOOK_KEY_FIRST_NAME));
if (firstname != NULL) {
char title[100];
- mir_snprintf(title, SIZEOF(title), Translate("What's on your mind, %s?"), firstname);
+ mir_snprintf(title, _countof(title), Translate("What's on your mind, %s?"), firstname);
SetWindowTextA(hwnd, title);
}
}
@@ -276,9 +276,9 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
TCHAR urlT[1024];
TCHAR placeT[100];
- GetDlgItemText(hwnd, IDC_MINDMSG, mindMessageT, SIZEOF(mindMessageT));
- GetDlgItemText(hwnd, IDC_PLACE, placeT, SIZEOF(placeT));
- GetDlgItemText(hwnd, IDC_URL, urlT, SIZEOF(urlT));
+ GetDlgItemText(hwnd, IDC_MINDMSG, mindMessageT, _countof(mindMessageT));
+ GetDlgItemText(hwnd, IDC_PLACE, placeT, _countof(placeT));
+ GetDlgItemText(hwnd, IDC_URL, urlT, _countof(urlT));
ShowWindow(hwnd, SW_HIDE);
int wall_id = SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCURSEL, 0, 0);
@@ -395,13 +395,13 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
{
char str[128]; TCHAR tstr[128];
- GetDlgItemTextA(hwnd, IDC_UN, str, SIZEOF(str));
+ GetDlgItemTextA(hwnd, IDC_UN, str, _countof(str));
db_set_s(0, proto->ModuleName(), FACEBOOK_KEY_LOGIN, str);
- GetDlgItemTextA(hwnd, IDC_PW, str, SIZEOF(str));
+ GetDlgItemTextA(hwnd, IDC_PW, str, _countof(str));
proto->setString(FACEBOOK_KEY_PASS, str);
- GetDlgItemText(hwnd, IDC_GROUP, tstr, SIZEOF(tstr));
+ GetDlgItemText(hwnd, IDC_GROUP, tstr, _countof(tstr));
if (tstr[0] != '\0')
{
proto->m_tszDefaultGroup = mir_tstrdup(tstr);
@@ -496,11 +496,11 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
proto = reinterpret_cast<FacebookProto*>(lparam);
SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
- for (size_t i = 0; i < SIZEOF(feed_types); i++)
+ for (size_t i = 0; i < _countof(feed_types); i++)
SendDlgItemMessageA(hwnd, IDC_FEED_TYPE, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(Translate(feed_types[i].name)));
SendDlgItemMessage(hwnd, IDC_FEED_TYPE, CB_SETCURSEL, proto->getByte(FACEBOOK_KEY_FEED_TYPE, 0), 0);
- for (size_t i = 0; i < SIZEOF(server_types); i++)
+ for (size_t i = 0; i < _countof(server_types); i++)
SendDlgItemMessageA(hwnd, IDC_URL_SERVER, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(Translate(server_types[i].name)));
SendDlgItemMessage(hwnd, IDC_URL_SERVER, CB_SETCURSEL, proto->getByte(FACEBOOK_KEY_SERVER_TYPE, 0), 0);
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index df528d7cc9..d8a43f9255 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -391,7 +391,7 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, const JSO
newText = _A2T(type.c_str());
TCHAR title[200];
- mir_sntprintf(title, SIZEOF(title), TranslateT("User sent %s:"), newText.c_str());
+ mir_sntprintf(title, _countof(title), TranslateT("User sent %s:"), newText.c_str());
*message_text += T2Utf(title);
*message_text += attachments_text;
@@ -688,7 +688,7 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo
StatusTextData st = { 0 };
st.cbSize = sizeof(st);
- mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("%s is typing a message..."), name);
+ mir_sntprintf(st.tszText, _countof(st.tszText), TranslateT("%s is typing a message..."), name);
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)&st);
}
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 923a371f0a..b3bfdc93b3 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -277,7 +277,7 @@ HANDLE FacebookProto::SearchByEmail(const TCHAR* email)
HANDLE FacebookProto::SearchByName(const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName)
{
TCHAR arg[200];
- mir_sntprintf(arg, SIZEOF(arg), _T("%s %s %s"), nick, firstName, lastName);
+ mir_sntprintf(arg, _countof(arg), _T("%s %s %s"), nick, firstName, lastName);
return SearchByEmail(arg); // Facebook is using one search method for everything (except IDs)
}
@@ -531,7 +531,7 @@ int FacebookProto::OnToolbarInit(WPARAM, LPARAM)
ttb.dwFlags = TTBBF_SHOWTOOLTIP | TTBBF_VISIBLE;
char service[100];
- mir_snprintf(service, SIZEOF(service), "%s%s", m_szModuleName, "/Mind");
+ mir_snprintf(service, _countof(service), "%s%s", m_szModuleName, "/Mind");
ttb.pszService = service;
ttb.pszTooltipUp = ttb.name = LPGEN("Share status...");
@@ -772,7 +772,7 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam)
return 1;
TCHAR tstr[256];
- mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("Do you want to cancel your friendship with '%s'?"), tname);
+ mir_sntprintf(tstr, _countof(tstr), TranslateT("Do you want to cancel your friendship with '%s'?"), tname);
if (MessageBox(0, tstr, m_tszUserName, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
ptrA id(getStringA(hContact, FACEBOOK_KEY_ID));
@@ -1124,7 +1124,7 @@ void FacebookProto::MessageRead(MCONTACT hContact)
return;
TCHAR ttime[64];
- _tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(&time));
+ _tcsftime(ttime, _countof(ttime), _T("%X"), localtime(&time));
StatusTextData st = { 0 };
st.cbSize = sizeof(st);
@@ -1133,10 +1133,10 @@ void FacebookProto::MessageRead(MCONTACT hContact)
if (isChatRoom(hContact)) {
// Load readers names
ptrT treaders(getTStringA(hContact, FACEBOOK_KEY_MESSAGE_READERS));
- mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s by %s"), ttime, treaders ? treaders : _T("???"));
+ mir_sntprintf(st.tszText, _countof(st.tszText), TranslateT("Message read: %s by %s"), ttime, treaders ? treaders : _T("???"));
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
} else if (!ServiceExists("MessageState/DummyService")){
- 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);
}
}
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index 96d413b8c3..868593fad7 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -51,12 +51,12 @@ static IconItem icons[] =
void InitIcons(void)
{
- Icon_Register(g_hInstance, "Protocols/Facebook", icons, SIZEOF(icons), "Facebook");
+ Icon_Register(g_hInstance, "Protocols/Facebook", icons, _countof(icons), "Facebook");
}
HANDLE GetIconHandle(const char* name)
{
- for (size_t i = 0; i < SIZEOF(icons); i++)
+ for (size_t i = 0; i < _countof(icons); i++)
if (mir_strcmp(icons[i].szName, name) == 0)
return icons[i].hIcolib;