summaryrefslogtreecommitdiff
path: root/plugins/Nudge/src
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/Nudge/src
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/Nudge/src')
-rw-r--r--plugins/Nudge/src/main.cpp12
-rw-r--r--plugins/Nudge/src/nudge.cpp64
-rw-r--r--plugins/Nudge/src/options.cpp10
3 files changed, 43 insertions, 43 deletions
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp
index 8f627acfa2..b6d2a36aa4 100644
--- a/plugins/Nudge/src/main.cpp
+++ b/plugins/Nudge/src/main.cpp
@@ -50,7 +50,7 @@ INT_PTR NudgeSend(WPARAM hContact, LPARAM lParam)
int diff = time(NULL) - db_get_dw(hContact, "Nudge", "LastSent", time(NULL) - 30);
if (diff < GlobalNudge.sendTimeSec) {
TCHAR msg[500];
- mir_sntprintf(msg, SIZEOF(msg), TranslateT("You are not allowed to send too much nudge (only 1 each %d sec, %d sec left)"), GlobalNudge.sendTimeSec, 30 - diff);
+ mir_sntprintf(msg, _countof(msg), TranslateT("You are not allowed to send too much nudge (only 1 each %d sec, %d sec left)"), GlobalNudge.sendTimeSec, 30 - diff);
if (GlobalNudge.useByProtocol) {
for (int i = 0; i < arNudges.getCount(); i++) {
CNudgeElement &p = arNudges[i];
@@ -207,8 +207,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
void LoadProtocols(void)
{
//Load the default nudge
- mir_snprintf(DefaultNudge.ProtocolName, SIZEOF(DefaultNudge.ProtocolName), "Default");
- mir_snprintf(DefaultNudge.NudgeSoundname, SIZEOF(DefaultNudge.NudgeSoundname), "Nudge : Default");
+ mir_snprintf(DefaultNudge.ProtocolName, _countof(DefaultNudge.ProtocolName), "Default");
+ mir_snprintf(DefaultNudge.NudgeSoundname, _countof(DefaultNudge.NudgeSoundname), "Nudge : Default");
SkinAddNewSoundEx(DefaultNudge.NudgeSoundname, LPGEN("Nudge"), LPGEN("Default Nudge"));
DefaultNudge.Load();
@@ -231,7 +231,7 @@ static IconItem iconList[] =
// Load icons
void LoadIcons(void)
{
- Icon_Register(hInst, LPGEN("Nudge"), iconList, SIZEOF(iconList));
+ Icon_Register(hInst, LPGEN("Nudge"), iconList, _countof(iconList));
}
// Nudge support
@@ -513,7 +513,7 @@ void Nudge_AddAccount(PROTOACCOUNT *proto)
// Add a specific sound per protocol
CNudgeElement *p = new CNudgeElement();
- mir_snprintf(p->NudgeSoundname, SIZEOF(p->NudgeSoundname), "%s: Nudge", proto->szModuleName);
+ mir_snprintf(p->NudgeSoundname, _countof(p->NudgeSoundname), "%s: Nudge", proto->szModuleName);
strcpy_s(p->ProtocolName, proto->szModuleName);
_tcscpy_s(p->AccountName, proto->tszAccountName);
@@ -522,7 +522,7 @@ void Nudge_AddAccount(PROTOACCOUNT *proto)
p->hEvent = hevent;
TCHAR soundDesc[MAXMODULELABELLENGTH + 10];
- mir_sntprintf(soundDesc, SIZEOF(soundDesc), LPGENT("Nudge for %s"), proto->tszAccountName);
+ mir_sntprintf(soundDesc, _countof(soundDesc), LPGENT("Nudge for %s"), proto->tszAccountName);
SkinAddNewSoundExT(p->NudgeSoundname, LPGENT("Nudge"), soundDesc);
arNudges.insert(p);
diff --git a/plugins/Nudge/src/nudge.cpp b/plugins/Nudge/src/nudge.cpp
index 75dc07b063..f2817152ef 100644
--- a/plugins/Nudge/src/nudge.cpp
+++ b/plugins/Nudge/src/nudge.cpp
@@ -3,55 +3,55 @@
void CNudge::Save(void)
{
char SectionName[512];
- mir_snprintf(SectionName, SIZEOF(SectionName), "useByProtocol");
+ mir_snprintf(SectionName, _countof(SectionName), "useByProtocol");
db_set_b(NULL, MODULENAME, SectionName, this->useByProtocol);
- mir_snprintf(SectionName, SIZEOF(SectionName), "RecvTimeSec");
+ mir_snprintf(SectionName, _countof(SectionName), "RecvTimeSec");
db_set_dw(NULL, MODULENAME, SectionName, this->recvTimeSec);
- mir_snprintf(SectionName, SIZEOF(SectionName), "SendTimeSec");
+ mir_snprintf(SectionName, _countof(SectionName), "SendTimeSec");
db_set_dw(NULL, MODULENAME, SectionName, this->sendTimeSec);
- mir_snprintf(SectionName, SIZEOF(SectionName), "ResendDelaySec");
+ mir_snprintf(SectionName, _countof(SectionName), "ResendDelaySec");
db_set_dw(NULL, MODULENAME, SectionName, this->resendDelaySec);
}
void CNudge::Load(void)
{
char SectionName[512];
- mir_snprintf(SectionName, SIZEOF(SectionName), "useByProtocol");
+ mir_snprintf(SectionName, _countof(SectionName), "useByProtocol");
this->useByProtocol = db_get_b(NULL, MODULENAME, SectionName, FALSE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "RecvTimeSec");
+ mir_snprintf(SectionName, _countof(SectionName), "RecvTimeSec");
this->recvTimeSec = db_get_dw(NULL, MODULENAME, SectionName, 30);
- mir_snprintf(SectionName, SIZEOF(SectionName), "SendTimeSec");
+ mir_snprintf(SectionName, _countof(SectionName), "SendTimeSec");
this->sendTimeSec = db_get_dw(NULL, MODULENAME, SectionName, 30);
- mir_snprintf(SectionName, SIZEOF(SectionName), "ResendDelaySec");
+ mir_snprintf(SectionName, _countof(SectionName), "ResendDelaySec");
this->resendDelaySec = db_get_dw(NULL, MODULENAME, SectionName, 3);
}
void CNudgeElement::Save(void)
{
char SectionName[512];
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-openMessageWindow", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-openMessageWindow", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->openMessageWindow);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-openContactList", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-openContactList", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->openContactList);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-useIgnore", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-useIgnore", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->useIgnoreSettings);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-showStatus", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-showStatus", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->showStatus);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-showPopup", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-showPopup", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->showPopup);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-shakeClist", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-shakeClist", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->shakeClist);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-shakeChat", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-shakeChat", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->shakeChat);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-enabled", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-enabled", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->enabled);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-autoResend", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-autoResend", ProtocolName);
db_set_b(NULL, MODULENAME, SectionName, this->autoResend);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-statusFlags", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-statusFlags", ProtocolName);
db_set_dw(NULL, MODULENAME, SectionName, this->statusFlags);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-recText", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-recText", ProtocolName);
db_set_ts(NULL, MODULENAME, SectionName, this->recText);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-senText", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-senText", ProtocolName);
db_set_ts(NULL, MODULENAME, SectionName, this->senText);
}
@@ -59,28 +59,28 @@ void CNudgeElement::Load(void)
{
DBVARIANT dbv;
char SectionName[512];
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-openMessageWindow", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-openMessageWindow", ProtocolName);
this->openMessageWindow = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-openContactList", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-openContactList", ProtocolName);
this->openContactList = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-useIgnore", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-useIgnore", ProtocolName);
this->useIgnoreSettings = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-showStatus", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-showStatus", ProtocolName);
this->showStatus = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-showPopup", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-showPopup", ProtocolName);
this->showPopup = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-shakeClist", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-shakeClist", ProtocolName);
this->shakeClist = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-shakeChat", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-shakeChat", ProtocolName);
this->shakeChat = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-enabled", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-enabled", ProtocolName);
this->enabled = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-autoResend", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-autoResend", ProtocolName);
this->autoResend = db_get_b(NULL, MODULENAME, SectionName, FALSE) != 0;
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-statusFlags", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-statusFlags", ProtocolName);
this->statusFlags = db_get_dw(NULL, MODULENAME, SectionName, 967);
- mir_snprintf(SectionName,SIZEOF(SectionName),"%s-recText", ProtocolName);
+ mir_snprintf(SectionName,_countof(SectionName),"%s-recText", ProtocolName);
if (!db_get_ts(NULL, MODULENAME, SectionName, &dbv)) {
_tcsncpy(this->recText, dbv.ptszVal, TEXT_LEN);
if (_tcsclen(this->recText) < 1)
@@ -89,7 +89,7 @@ void CNudgeElement::Load(void)
}
else _tcsncpy(this->recText, TranslateT("You received a nudge"), TEXT_LEN);
- mir_snprintf(SectionName, SIZEOF(SectionName), "%s-senText", ProtocolName);
+ mir_snprintf(SectionName, _countof(SectionName), "%s-senText", ProtocolName);
if (!db_get_ts(NULL, MODULENAME, SectionName, &dbv)) {
_tcsncpy(this->senText, dbv.ptszVal, TEXT_LEN);
if (_tcsclen(this->senText) < 1)
diff --git a/plugins/Nudge/src/options.cpp b/plugins/Nudge/src/options.cpp
index fb5f98a8ad..4d428e92b7 100644
--- a/plugins/Nudge/src/options.cpp
+++ b/plugins/Nudge/src/options.cpp
@@ -94,14 +94,14 @@ static INT_PTR CALLBACK DlgProcShakeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
TranslateDialogDefault(hwnd);
{
TCHAR szBuf[20];
- mir_sntprintf(szBuf, SIZEOF(szBuf), _T("%d"), shake.nMoveClist);
+ mir_sntprintf(szBuf, _countof(szBuf), _T("%d"), shake.nMoveClist);
SetDlgItemText(hwnd, IDC_LNUMBER_CLIST, szBuf);
- mir_sntprintf(szBuf, SIZEOF(szBuf), _T("%d"), shake.nMoveChat);
+ mir_sntprintf(szBuf, _countof(szBuf), _T("%d"), shake.nMoveChat);
SetDlgItemText(hwnd, IDC_LNUMBER_CHAT, szBuf);
- mir_sntprintf(szBuf, SIZEOF(szBuf), _T("%d"), shake.nScaleClist);
+ mir_sntprintf(szBuf, _countof(szBuf), _T("%d"), shake.nScaleClist);
SetDlgItemText(hwnd, IDC_LSCALE_CLIST, szBuf);
- mir_sntprintf(szBuf, SIZEOF(szBuf), _T("%d"), shake.nScaleChat);
+ mir_sntprintf(szBuf, _countof(szBuf), _T("%d"), shake.nScaleChat);
SetDlgItemText(hwnd, IDC_LSCALE_CHAT, szBuf);
}
@@ -132,7 +132,7 @@ static INT_PTR CALLBACK DlgProcShakeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
{
TCHAR szBuf[20];
DWORD dwPos = SendMessage((HWND)lParam, TBM_GETPOS, 0, 0);
- mir_sntprintf(szBuf, SIZEOF(szBuf), _T("%d"), dwPos);
+ mir_sntprintf(szBuf, _countof(szBuf), _T("%d"), dwPos);
if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CLIST))
SetDlgItemText(hwnd, IDC_LNUMBER_CLIST, szBuf);
if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CHAT))