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 --- plugins/NewXstatusNotify/src/main.cpp | 40 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'plugins/NewXstatusNotify/src/main.cpp') diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index d8de67a965..69b6dc751e 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -88,7 +88,7 @@ BYTE GetGender(MCONTACT hContact) HANDLE GetIconHandle(char *szIcon) { char szSettingName[64]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, szIcon); + mir_snprintf(szSettingName, _countof(szSettingName), "%s_%s", MODULE, szIcon); return IcoLib_GetIconHandle(szSettingName); } @@ -328,7 +328,7 @@ void PlayChangeSound(MCONTACT hContact, const char *name) DBVARIANT dbv; TCHAR stzSoundFile[MAX_PATH] = { 0 }; if (!db_get_ts(hContact, MODULE, name, &dbv)) { - _tcsncpy(stzSoundFile, dbv.ptszVal, SIZEOF(stzSoundFile)-1); + _tcsncpy(stzSoundFile, dbv.ptszVal, _countof(stzSoundFile)-1); db_free(&dbv); } @@ -416,8 +416,8 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) // check if that proto from which we received statuschange notification, isn't in autodisable list if (opt.AutoDisable) { char statusIDs[12], statusIDp[12]; - mir_snprintf(statusIDs, SIZEOF(statusIDs), "s%d", myStatus); - mir_snprintf(statusIDp, SIZEOF(statusIDp), "p%d", myStatus); + mir_snprintf(statusIDs, _countof(statusIDs), "s%d", myStatus); + mir_snprintf(statusIDp, _countof(statusIDp), "p%d", myStatus); bEnableSound = db_get_b(0, MODULE, statusIDs, 1) ? FALSE : TRUE; bEnablePopup = db_get_b(0, MODULE, statusIDp, 1) ? FALSE : TRUE; } @@ -443,7 +443,7 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) if (opt.BlinkIcon && !opt.TempDisabled) { HICON hIcon = opt.BlinkIcon_Status ? Skin_LoadProtoIcon(szProto, newStatus) : Skin_LoadIcon(SKINICON_OTHER_USERONLINE); TCHAR str[256]; - mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now %s"), pcli->pfnGetContactDisplayName(hContact, 0), StatusList[Index(newStatus)].lpzStandardText); + mir_sntprintf(str, _countof(str), TranslateT("%s is now %s"), pcli->pfnGetContactDisplayName(hContact, 0), StatusList[Index(newStatus)].lpzStandardText); BlinkIcon(hContact, hIcon, str); } @@ -457,9 +457,9 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) if (opt.LogToFile) { TCHAR stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT], stzText[MAX_TEXT_LEN]; - GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm"), stzTime, SIZEOF(stzTime)); - GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("dd/MM/yyyy"), stzDate, SIZEOF(stzDate)); - mir_sntprintf(stzText, SIZEOF(stzText), TranslateT("%s, %s. %s changed status to %s (was %s)\r\n"), + GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm"), stzTime, _countof(stzTime)); + GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("dd/MM/yyyy"), stzDate, _countof(stzDate)); + mir_sntprintf(stzText, _countof(stzText), TranslateT("%s, %s. %s changed status to %s (was %s)\r\n"), stzDate, stzTime, pcli->pfnGetContactDisplayName(hContact, 0), StatusList[Index(newStatus)].lpzStandardText, StatusList[Index(oldStatus)].lpzStandardText); LogToFile(stzText); @@ -553,7 +553,7 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) } else if (strstr(cws->szSetting, "text")) { char dbSetting[128]; - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%s", szSetting, "Msg"); + mir_snprintf(dbSetting, _countof(dbSetting), "%s%s", szSetting, "Msg"); smi.compare = CompareStatusMsg(&smi, cws, dbSetting); if (smi.compare == COMPARE_SAME) { replaceStrT(smi.newstatusmsg, 0); @@ -651,11 +651,11 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) goto skip_notify; char dbSetting[64]; - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_enabled", szProto); + mir_snprintf(dbSetting, _countof(dbSetting), "%s_enabled", szProto); // this proto is not set for status message notifications if (db_get_b(NULL, MODULE, dbSetting, 1) == 0) goto skip_notify; - mir_snprintf(dbSetting, SIZEOF(dbSetting), "%d", IDC_CHK_STATUS_MESSAGE); + mir_snprintf(dbSetting, _countof(dbSetting), "%d", IDC_CHK_STATUS_MESSAGE); // status message change notifications are disabled if (db_get_b(NULL, MODULE, dbSetting, 1) == 0) goto skip_notify; @@ -666,8 +666,8 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) // check if our status isn't on autodisable list if (opt.AutoDisable) { char statusIDs[12], statusIDp[12]; - mir_snprintf(statusIDs, SIZEOF(statusIDs), "s%d", myStatus); - mir_snprintf(statusIDp, SIZEOF(statusIDp), "p%d", myStatus); + mir_snprintf(statusIDs, _countof(statusIDs), "s%d", myStatus); + mir_snprintf(statusIDp, _countof(statusIDp), "p%d", myStatus); bEnableSound = db_get_b(0, MODULE, statusIDs, 1) ? FALSE : bEnableSound; bEnablePopup = db_get_b(0, MODULE, statusIDp, 1) ? FALSE : bEnablePopup; } @@ -695,7 +695,7 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) TCHAR *str; if (smi.compare == COMPARE_DEL) { char protoname[MAX_PATH]; - mir_snprintf(protoname, SIZEOF(protoname), "%s_TPopupSMsgRemoved", szProto); + mir_snprintf(protoname, _countof(protoname), "%s_TPopupSMsgRemoved", szProto); DBVARIANT dbVar = { 0 }; if (db_get_ts(NULL, MODULE, protoname, &dbVar)) { str = GetStr(&smi, DEFAULT_POPUP_SMSGREMOVED); @@ -707,7 +707,7 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) } else { char protoname[MAX_PATH]; - mir_snprintf(protoname, SIZEOF(protoname), "%s_TPopupSMsgChanged", szProto); + mir_snprintf(protoname, _countof(protoname), "%s_TPopupSMsgChanged", szProto); DBVARIANT dbVar = { 0 }; if (db_get_ts(NULL, MODULE, protoname, &dbVar)) { str = GetStr(&smi, DEFAULT_POPUP_SMSGCHANGED); @@ -733,7 +733,7 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (opt.BlinkIcon && opt.BlinkIcon_ForMsgs && !opt.TempDisabled) { HICON hIcon = opt.BlinkIcon_Status ? Skin_LoadProtoIcon(szProto, db_get_w(hContact, szProto, "Status", ID_STATUS_ONLINE)) : Skin_LoadIcon(SKINICON_OTHER_USERONLINE); TCHAR str[256]; - mir_sntprintf(str, SIZEOF(str), TranslateT("%s changed status message to %s"), pcli->pfnGetContactDisplayName(hContact, 0), smi.newstatusmsg); + mir_sntprintf(str, _countof(str), TranslateT("%s changed status message to %s"), pcli->pfnGetContactDisplayName(hContact, 0), smi.newstatusmsg); BlinkIcon(hContact, hIcon, str); } @@ -751,8 +751,8 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (opt.SMsgLogToFile && db_get_b(hContact, MODULE, "EnableSMsgLogging", 1)) { TCHAR stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT], stzText[MAX_TEXT_LEN]; - GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm"), stzTime, SIZEOF(stzTime)); - GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("dd/MM/yyyy"), stzDate, SIZEOF(stzDate)); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm"), stzTime, _countof(stzTime)); + GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("dd/MM/yyyy"), stzDate, _countof(stzDate)); TCHAR *str; if (smi.compare == COMPARE_DEL) @@ -760,7 +760,7 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) else str = GetStr(&smi, templates.LogSMsgChanged); - mir_sntprintf(stzText, SIZEOF(stzText), _T("%s, %s. %s %s\r\n"), stzDate, stzTime, pcli->pfnGetContactDisplayName(hContact, 0), str); + mir_sntprintf(stzText, _countof(stzText), _T("%s, %s. %s %s\r\n"), stzDate, stzTime, pcli->pfnGetContactDisplayName(hContact, 0), str); LogToFile(stzText); mir_free(str); @@ -1098,7 +1098,7 @@ static IconItem iconList[] = void InitIcolib() { - Icon_Register(hInst, LPGEN("New Status Notify"), iconList, SIZEOF(iconList), MODULE); + Icon_Register(hInst, LPGEN("New Status Notify"), iconList, _countof(iconList), MODULE); } void InitSound() -- cgit v1.2.3