summaryrefslogtreecommitdiff
path: root/plugins/MyDetails
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 /plugins/MyDetails
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 'plugins/MyDetails')
-rw-r--r--plugins/MyDetails/src/data.cpp34
-rw-r--r--plugins/MyDetails/src/frame.cpp34
-rw-r--r--plugins/MyDetails/src/mydetails.cpp2
-rw-r--r--plugins/MyDetails/src/options.cpp4
-rw-r--r--plugins/MyDetails/src/services.cpp10
5 files changed, 42 insertions, 42 deletions
diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp
index 8f570a717b..7b286f837b 100644
--- a/plugins/MyDetails/src/data.cpp
+++ b/plugins/MyDetails/src/data.cpp
@@ -54,8 +54,8 @@ void DeInitProtocolData()
Protocol::Protocol(const char *aName, const TCHAR *descr)
{
- mir_strncpy(name, aName, SIZEOF(name));
- mir_tstrncpy(description, descr, SIZEOF(description));
+ mir_strncpy(name, aName, _countof(name));
+ mir_tstrncpy(description, descr, _countof(description));
data_changed = true;
@@ -129,14 +129,14 @@ int Protocol::GetStatus()
if (custom_status == 0) {
TCHAR *tmp = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, GSMDF_TCHAR);
- lcopystr(status_name, tmp, SIZEOF(status_name));
+ lcopystr(status_name, tmp, _countof(status_name));
}
else {
TCHAR *p = (tszXStatusName[0] != 0) ? TranslateTS(tszXStatusName) : TranslateT("<no status name>");
if (tszXStatusMessage[0])
- mir_sntprintf(status_name, SIZEOF(status_name), _T("%s: %s"), p, tszXStatusMessage);
+ mir_sntprintf(status_name, _countof(status_name), _T("%s: %s"), p, tszXStatusMessage);
else
- lcopystr(status_name, p, SIZEOF(status_name));
+ lcopystr(status_name, p, _countof(status_name));
}
return status;
@@ -170,7 +170,7 @@ void Protocol::SetStatus(int aStatus)
pse[0]->status = aStatus;
pse[0]->szName = name;
- GetStatusMsg(aStatus, status_msg, SIZEOF(status_msg));
+ GetStatusMsg(aStatus, status_msg, _countof(status_msg));
pse[0]->szMsg = status_msg;
CallService(MS_CS_SETSTATUSEX, (WPARAM)&pse, 0);
@@ -184,7 +184,7 @@ void Protocol::SetStatus(int aStatus)
if (CanSetStatusMsg(aStatus)) {
TCHAR status_msg[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE];
- GetStatusMsg(aStatus, status_msg, SIZEOF(status_msg));
+ GetStatusMsg(aStatus, status_msg, _countof(status_msg));
SetStatusMsg(aStatus, status_msg);
}
}
@@ -226,7 +226,7 @@ void Protocol::GetStatusMsg(int aStatus, TCHAR *msg, size_t msg_size)
TCHAR* Protocol::GetStatusMsg()
{
- GetStatusMsg(status, status_message, SIZEOF(status_message));
+ GetStatusMsg(status, status_message, _countof(status_message));
return status_message;
}
@@ -309,11 +309,11 @@ TCHAR *Protocol::GetNick()
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
// CNF_DISPLAY always returns a string type
- lcopystr(nickname, ci.pszVal, SIZEOF(nickname));
+ lcopystr(nickname, ci.pszVal, _countof(nickname));
mir_free(ci.pszVal);
}
else
- lcopystr(nickname, _T(""), SIZEOF(nickname));
+ lcopystr(nickname, _T(""), _countof(nickname));
return nickname;
}
@@ -365,17 +365,17 @@ bool Protocol::ListeningToEnabled()
TCHAR *Protocol::GetListeningTo()
{
if (!CanGetListeningTo()) {
- lcopystr(listening_to, _T(""), SIZEOF(listening_to));
+ lcopystr(listening_to, _T(""), _countof(listening_to));
return listening_to;
}
DBVARIANT dbv = { 0 };
if (db_get_ts(NULL, name, "ListeningTo", &dbv)) {
- lcopystr(listening_to, _T(""), SIZEOF(listening_to));
+ lcopystr(listening_to, _T(""), _countof(listening_to));
return listening_to;
}
- lcopystr(listening_to, dbv.ptszVal, SIZEOF(listening_to));
+ lcopystr(listening_to, dbv.ptszVal, _countof(listening_to));
db_free(&dbv);
return listening_to;
}
@@ -485,7 +485,7 @@ void ProtocolArray::SetNicks(const TCHAR *nick)
if (nick == NULL || nick[0] == '\0')
return;
- mir_tstrncpy(default_nick, nick, SIZEOF(default_nick));
+ mir_tstrncpy(default_nick, nick, _countof(default_nick));
db_set_ts(0, MODULE_NAME, SETTING_DEFAULT_NICK, nick);
@@ -522,7 +522,7 @@ void ProtocolArray::GetDefaultNick()
{
ptrT tszNick(db_get_tsa(0, MODULE_NAME, SETTING_DEFAULT_NICK));
if (tszNick)
- mir_tstrncpy(default_nick, tszNick, SIZEOF(default_nick));
+ mir_tstrncpy(default_nick, tszNick, _countof(default_nick));
else
default_nick[0] = '\0';
}
@@ -531,7 +531,7 @@ void ProtocolArray::GetDefaultAvatar()
{
ptrT tszFile(db_get_tsa(0, "ContactPhoto", "File"));
if (tszFile)
- mir_tstrncpy(default_avatar_file, tszFile, SIZEOF(default_avatar_file));
+ mir_tstrncpy(default_avatar_file, tszFile, _countof(default_avatar_file));
else
default_avatar_file[0] = '\0';
}
@@ -550,7 +550,7 @@ TCHAR *ProtocolArray::GetDefaultStatusMsg(int status)
TCHAR *tmp = (TCHAR *)CallService(MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)status, 0);
if (tmp != NULL) {
- mir_tstrncpy(default_status_message, tmp, SIZEOF(default_status_message));
+ mir_tstrncpy(default_status_message, tmp, _countof(default_status_message));
mir_free(tmp);
}
diff --git a/plugins/MyDetails/src/frame.cpp b/plugins/MyDetails/src/frame.cpp
index 924a9fc2e2..83f26077c1 100644
--- a/plugins/MyDetails/src/frame.cpp
+++ b/plugins/MyDetails/src/frame.cpp
@@ -234,19 +234,19 @@ int CreateFrame()
memset(&font_id[i], 0, sizeof(font_id[i]));
font_id[i].cbSize = sizeof(FontIDT);
- mir_tstrncpy(font_id[i].group, LPGENT("My details"), SIZEOF(font_id[i].group));
- mir_tstrncpy(font_id[i].name, font_names[i], SIZEOF(font_id[i].name));
- mir_strncpy(font_id[i].dbSettingsGroup, MODULE_NAME, SIZEOF(font_id[i].dbSettingsGroup));
- mir_tstrncpy(font_id[i].backgroundName, LPGENT("Background"), SIZEOF(font_id[i].backgroundName));
- mir_tstrncpy(font_id[i].backgroundGroup, LPGENT("My details"), SIZEOF(font_id[i].backgroundGroup));
+ mir_tstrncpy(font_id[i].group, LPGENT("My details"), _countof(font_id[i].group));
+ mir_tstrncpy(font_id[i].name, font_names[i], _countof(font_id[i].name));
+ mir_strncpy(font_id[i].dbSettingsGroup, MODULE_NAME, _countof(font_id[i].dbSettingsGroup));
+ mir_tstrncpy(font_id[i].backgroundName, LPGENT("Background"), _countof(font_id[i].backgroundName));
+ mir_tstrncpy(font_id[i].backgroundGroup, LPGENT("My details"), _countof(font_id[i].backgroundGroup));
- mir_strncpy(font_id[i].prefix, font_settings[i], SIZEOF(font_id[i].prefix));
+ mir_strncpy(font_id[i].prefix, font_settings[i], _countof(font_id[i].prefix));
font_id[i].deffontsettings.colour = font_colors[i];
font_id[i].deffontsettings.size = -MulDiv(font_sizes[i], GetDeviceCaps(hdc, LOGPIXELSY), 72);
font_id[i].deffontsettings.style = font_styles[i];
font_id[i].deffontsettings.charset = DEFAULT_CHARSET;
- mir_tstrncpy(font_id[i].deffontsettings.szFace, _T("Tahoma"), SIZEOF(font_id[i].deffontsettings.szFace));
+ mir_tstrncpy(font_id[i].deffontsettings.szFace, _T("Tahoma"), _countof(font_id[i].deffontsettings.szFace));
font_id[i].order = i;
font_id[i].flags = FIDF_DEFAULTVALID;
FontRegisterT(&font_id[i]);
@@ -1475,7 +1475,7 @@ void ShowListeningToMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, P
// Add this proto to menu
TCHAR tmp[128];
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Enable listening to for %s"), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Enable listening to for %s"), proto->description);
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
@@ -1715,7 +1715,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
// Add this proto to menu
TCHAR tmp[128];
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my avatar for %s..."), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my avatar for %s..."), proto->description);
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
@@ -1755,7 +1755,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
// Add this proto to menu
TCHAR tmp[128];
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my nickname for %s..."), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my nickname for %s..."), proto->description);
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
@@ -1803,7 +1803,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
if (protocols->CanSetStatusMsgPerProtocol()) {
// Add this proto to menu
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my status message for %s..."), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my status message for %s..."), proto->description);
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
@@ -1822,7 +1822,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
}
// Add this to menu
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my status message for %s..."),
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my status message for %s..."),
CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, proto->status, GSMDF_TCHAR));
MENUITEMINFO mii = { 0 };
@@ -1888,7 +1888,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
TCHAR tmp[128];
MENUITEMINFO mii = { 0 };
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Enable listening to for %s"), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Enable listening to for %s"), proto->description);
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
@@ -1904,7 +1904,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
InsertMenuItem(submenu, 0, TRUE, &mii);
// Add this to menu
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my status message for %s..."),
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my status message for %s..."),
CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, proto->status, GSMDF_TCHAR));
memset(&mii, 0, sizeof(mii));
@@ -1924,7 +1924,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
if (protocols->CanSetStatusMsgPerProtocol()) {
// Add this proto to menu
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my status message for %s..."), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my status message for %s..."), proto->description);
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
@@ -1942,7 +1942,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
InsertMenuItem(submenu, 0, TRUE, &mii);
}
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my nickname for %s..."), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my nickname for %s..."), proto->description);
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
@@ -1959,7 +1959,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
InsertMenuItem(submenu, 0, TRUE, &mii);
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my avatar for %s..."), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my avatar for %s..."), proto->description);
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
diff --git a/plugins/MyDetails/src/mydetails.cpp b/plugins/MyDetails/src/mydetails.cpp
index 9b7d0742f0..a2a6d38cae 100644
--- a/plugins/MyDetails/src/mydetails.cpp
+++ b/plugins/MyDetails/src/mydetails.cpp
@@ -150,7 +150,7 @@ extern "C" __declspec(dllexport) int Load()
if (IcoLib_GetIcon("LISTENING_TO_ICON") == NULL)
Icon_Register(hInst, LPGEN("Contact list"), iconList, 1);
- Icon_Register(hInst, LPGEN("My details"), iconList + 1, SIZEOF(iconList) - 1);
+ Icon_Register(hInst, LPGEN("My details"), iconList + 1, _countof(iconList) - 1);
// Register services
CreateServiceFunction(MS_MYDETAILS_SETMYNICKNAME, PluginCommand_SetMyNickname);
diff --git a/plugins/MyDetails/src/options.cpp b/plugins/MyDetails/src/options.cpp
index 139b3160b5..826454adc1 100644
--- a/plugins/MyDetails/src/options.cpp
+++ b/plugins/MyDetails/src/options.cpp
@@ -60,7 +60,7 @@ static OptPageControl pageControls[] = {
// Initializations needed by options
void LoadOptions()
{
- LoadOpts(pageControls, SIZEOF(pageControls), MODULE_NAME);
+ LoadOpts(pageControls, _countof(pageControls), MODULE_NAME);
// This is created here to assert that this key always exists
opts.refresh_status_message_timer = db_get_w(NULL, "MyDetails", "RefreshStatusMessageTimer", 12);
@@ -72,7 +72,7 @@ void LoadOptions()
static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- BOOL ret = SaveOptsDlgProc(pageControls, SIZEOF(pageControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+ BOOL ret = SaveOptsDlgProc(pageControls, _countof(pageControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
switch (msg) {
case WM_INITDIALOG:
diff --git a/plugins/MyDetails/src/services.cpp b/plugins/MyDetails/src/services.cpp
index 3c2e515bcc..bddb20c124 100644
--- a/plugins/MyDetails/src/services.cpp
+++ b/plugins/MyDetails/src/services.cpp
@@ -70,7 +70,7 @@ static INT_PTR CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam
Protocol *proto = protocols->Get(proto_num);
TCHAR tmp[128];
- mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set my nickname for %s"), proto->description);
+ mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my nickname for %s"), proto->description);
SetWindowText(hwndDlg, tmp);
@@ -93,7 +93,7 @@ static INT_PTR CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam
case IDOK:
{
TCHAR tmp[MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE];
- GetDlgItemText(hwndDlg, IDC_NICKNAME, tmp, SIZEOF(tmp));
+ GetDlgItemText(hwndDlg, IDC_NICKNAME, tmp, _countof(tmp));
LONG_PTR proto_num = GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (proto_num == -1)
@@ -332,7 +332,7 @@ static INT_PTR CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM w
}
TCHAR title[256];
- mir_sntprintf(title, SIZEOF(title), TranslateT("Set my status message for %s"), proto->description);
+ mir_sntprintf(title, _countof(title), TranslateT("Set my status message for %s"), proto->description);
SetWindowText(hwndDlg, title);
SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, proto->GetStatusMsg());
@@ -341,7 +341,7 @@ static INT_PTR CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM w
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadProtoIcon(NULL, data->status));
TCHAR title[256];
- mir_sntprintf(title, SIZEOF(title), TranslateT("Set my status message for %s"),
+ mir_sntprintf(title, _countof(title), TranslateT("Set my status message for %s"),
CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, data->status, GSMDF_TCHAR));
SetWindowText(hwndDlg, title);
@@ -360,7 +360,7 @@ static INT_PTR CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM w
case IDOK:
{
TCHAR tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE];
- GetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, tmp, SIZEOF(tmp));
+ GetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, tmp, _countof(tmp));
SetStatusMessageData *data = (SetStatusMessageData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);