summaryrefslogtreecommitdiff
path: root/plugins/AvatarHistory
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/AvatarHistory
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/AvatarHistory')
-rw-r--r--plugins/AvatarHistory/src/AvatarDlg.cpp18
-rw-r--r--plugins/AvatarHistory/src/AvatarHistory.cpp10
-rw-r--r--plugins/AvatarHistory/src/icolib.cpp2
-rw-r--r--plugins/AvatarHistory/src/options.cpp10
-rw-r--r--plugins/AvatarHistory/src/popup.cpp6
-rw-r--r--plugins/AvatarHistory/src/utils.cpp10
6 files changed, 28 insertions, 28 deletions
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp
index 3a791498cc..76184a0a7c 100644
--- a/plugins/AvatarHistory/src/AvatarDlg.cpp
+++ b/plugins/AvatarHistory/src/AvatarDlg.cpp
@@ -84,7 +84,7 @@ int OpenAvatarDialog(MCONTACT hContact, char* fn)
}
else
{
- MultiByteToWideChar(CP_ACP, 0, fn, -1, avdlg->fn, SIZEOF(avdlg->fn));
+ MultiByteToWideChar(CP_ACP, 0, fn, -1, avdlg->fn, _countof(avdlg->fn));
}
CloseHandle(mir_forkthread(AvatarDialogThread, (void*)avdlg));
@@ -138,7 +138,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM l
{
TCHAR title[MAX_PATH];
- mir_sntprintf(title, SIZEOF(title), TranslateT("Avatar History for %s"), displayName);
+ mir_sntprintf(title, _countof(title), TranslateT("Avatar History for %s"), displayName);
SetWindowText(hwnd, title);
}
@@ -376,7 +376,7 @@ int FillAvatarListFromFiles(HWND list, MCONTACT hContact)
WIN32_FIND_DATA finddata;
GetContactFolder(dir, hContact);
- mir_sntprintf(path, SIZEOF(path), _T("%s\\*.*"), dir);
+ mir_sntprintf(path, _countof(path), _T("%s\\*.*"), dir);
HANDLE hFind = FindFirstFile(path, &finddata);
if (hFind == INVALID_HANDLE_VALUE)
@@ -386,7 +386,7 @@ int FillAvatarListFromFiles(HWND list, MCONTACT hContact)
{
if (finddata.cFileName[0] != '.')
{
- mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), dir, finddata.cFileName);
+ mir_sntprintf(path, _countof(path), _T("%s\\%s"), dir, finddata.cFileName);
max_pos = AddFileToList(path,finddata.cFileName,finddata.cFileName,list);
}
}
@@ -403,7 +403,7 @@ int FillAvatarListFromFolder(HWND list, MCONTACT hContact)
WIN32_FIND_DATA finddata;
GetContactFolder(dir, hContact);
- mir_sntprintf(path, SIZEOF(path), _T("%s\\*.lnk"), dir);
+ mir_sntprintf(path, _countof(path), _T("%s\\*.lnk"), dir);
HANDLE hFind = FindFirstFile(path, &finddata);
if (hFind == INVALID_HANDLE_VALUE)
@@ -414,7 +414,7 @@ int FillAvatarListFromFolder(HWND list, MCONTACT hContact)
if (finddata.cFileName[0] != '.')
{
TCHAR lnk[MAX_PATH];
- mir_sntprintf(lnk, SIZEOF(lnk), _T("%s\\%s"), dir, finddata.cFileName);
+ mir_sntprintf(lnk, _countof(lnk), _T("%s\\%s"), dir, finddata.cFileName);
if (ResolveShortcut(lnk, path))
max_pos = AddFileToList(path,lnk,finddata.cFileName,list);
}
@@ -438,7 +438,7 @@ int FillAvatarListFromDB(HWND list, MCONTACT hContact)
// Get time
TCHAR date[64];
- TimeZone_ToStringT(dbei.timestamp, _T("d s"), date, SIZEOF(date));
+ TimeZone_ToStringT(dbei.timestamp, _T("d s"), date, _countof(date));
// Get file in disk
TCHAR path[MAX_PATH];
@@ -534,7 +534,7 @@ static INT_PTR ShowDialogSvc(WPARAM wParam, LPARAM lParam)
int ShowSaveDialog(HWND hwnd, TCHAR* fn, MCONTACT hContact)
{
TCHAR filter[MAX_PATH], file[MAX_PATH];
- Bitmap_GetFilter(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, _countof(filter));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
@@ -551,7 +551,7 @@ int ShowSaveDialog(HWND hwnd, TCHAR* fn, MCONTACT hContact)
TCHAR title[MAX_PATH];
if (displayName)
{
- mir_sntprintf(title, SIZEOF(title), TranslateT("Save Avatar for %s"), displayName);
+ mir_sntprintf(title, _countof(title), TranslateT("Save Avatar for %s"), displayName);
ofn.lpstrTitle = title;
}
else
diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp
index ff105f96d1..04b88b5942 100644
--- a/plugins/AvatarHistory/src/AvatarHistory.cpp
+++ b/plugins/AvatarHistory/src/AvatarHistory.cpp
@@ -77,7 +77,7 @@ static INT_PTR GetCachedAvatar(WPARAM wParam, LPARAM lParam)
TCHAR hash[128];
_tcsncpy_s(hash, (TCHAR*)lParam, _TRUNCATE);
- ConvertToFilename(hash, SIZEOF(hash));
+ ConvertToFilename(hash, _countof(hash));
return (INT_PTR)GetCachedAvatar((char*)wParam, hash);
}
@@ -172,12 +172,12 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam)
TCHAR hash[128];
_tcsncpy_s(hash, avatar->hash, _TRUNCATE);
- ConvertToFilename(hash, SIZEOF(hash));
+ ConvertToFilename(hash, _countof(hash));
TCHAR *file = GetCachedAvatar(proto, hash);
if (file != NULL) {
- mir_tstrncpy(history_filename, file, SIZEOF(history_filename));
+ mir_tstrncpy(history_filename, file, _countof(history_filename));
mir_free(file);
}
else {
@@ -186,7 +186,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam)
else
GetProtocolFolder(history_filename, proto);
- mir_sntprintf(history_filename, SIZEOF(history_filename),
+ mir_sntprintf(history_filename, _countof(history_filename),
_T("%s\\%s"), history_filename, hash);
if (CopyImageFile(avatar->filename, history_filename))
@@ -235,7 +235,7 @@ static int PreShutdown(WPARAM, LPARAM)
static int ModulesLoaded(WPARAM, LPARAM)
{
- mir_sntprintf(basedir, SIZEOF(basedir), _T("%s\\Avatars History"), profilePath);
+ mir_sntprintf(basedir, _countof(basedir), _T("%s\\Avatars History"), profilePath);
hFolder = FoldersRegisterCustomPathT( LPGEN("Avatars"), LPGEN("Avatar History"),
PROFILE_PATHT _T("\\") CURRENT_PROFILET _T("\\Avatars History"));
diff --git a/plugins/AvatarHistory/src/icolib.cpp b/plugins/AvatarHistory/src/icolib.cpp
index 2db9d4b5a5..d20629af6f 100644
--- a/plugins/AvatarHistory/src/icolib.cpp
+++ b/plugins/AvatarHistory/src/icolib.cpp
@@ -40,7 +40,7 @@ int IcoLibIconsChanged(WPARAM, LPARAM)
void SetupIcoLib()
{
iconList[0].hIcolib = Skin_GetIconHandle(SKINICON_OTHER_HISTORY);
- Icon_Register(hInst, LPGEN("Avatar History"), iconList+1, SIZEOF(iconList)-1);
+ Icon_Register(hInst, LPGEN("Avatar History"), iconList+1, _countof(iconList)-1);
IcoLibUpdateMenus();
}
diff --git a/plugins/AvatarHistory/src/options.cpp b/plugins/AvatarHistory/src/options.cpp
index 1bf2536dae..5a30baeacf 100644
--- a/plugins/AvatarHistory/src/options.cpp
+++ b/plugins/AvatarHistory/src/options.cpp
@@ -50,7 +50,7 @@ static OptPageControl popupsControls[] = {
static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- return SaveOptsDlgProc(optionsControls, SIZEOF(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+ return SaveOptsDlgProc(optionsControls, _countof(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
// Popup options dialog procedure /////////////////////////////////////////////////////////////////
@@ -100,7 +100,7 @@ static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Show contact history"));
// Needs to be called here in this case
- SaveOptsDlgProc(popupsControls, SIZEOF(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+ SaveOptsDlgProc(popupsControls, _countof(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
PopupsEnableDisableCtrls(hwndDlg);
return TRUE;
@@ -139,7 +139,7 @@ static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
}
}
- return SaveOptsDlgProc(popupsControls, SIZEOF(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+ return SaveOptsDlgProc(popupsControls, _countof(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
// Functions //////////////////////////////////////////////////////////////////////////////////////
@@ -168,8 +168,8 @@ int OptInit(WPARAM wParam, LPARAM)
void LoadOptions()
{
- LoadOpts(optionsControls, SIZEOF(optionsControls), MODULE_NAME);
- LoadOpts(popupsControls, SIZEOF(popupsControls), MODULE_NAME);
+ LoadOpts(optionsControls, _countof(optionsControls), MODULE_NAME);
+ LoadOpts(popupsControls, _countof(popupsControls), MODULE_NAME);
opts.log_per_contact_folders = db_get_b(NULL, MODULE_NAME, "LogPerContactFolders", 0);
opts.log_keep_same_folder = db_get_b(NULL, MODULE_NAME, "LogKeepSameFolder", 0);
diff --git a/plugins/AvatarHistory/src/popup.cpp b/plugins/AvatarHistory/src/popup.cpp
index a43da24ef1..fc332ca8b7 100644
--- a/plugins/AvatarHistory/src/popup.cpp
+++ b/plugins/AvatarHistory/src/popup.cpp
@@ -105,13 +105,13 @@ void ShowPopupEx(MCONTACT hContact, const TCHAR *title, const TCHAR *description
((PopupDataType*)ppd.PluginData)->hIcon = ppd.lchIcon;
if (title != NULL)
- mir_tstrncpy(ppd.lptzContactName, title, SIZEOF(ppd.lptzContactName));
+ mir_tstrncpy(ppd.lptzContactName, title, _countof(ppd.lptzContactName));
else if (hContact != NULL)
mir_tstrncpy(ppd.lptzContactName, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR),
- SIZEOF(ppd.lptzContactName));
+ _countof(ppd.lptzContactName));
if (description != NULL)
- mir_tstrncpy(ppd.lptzText, description, SIZEOF(ppd.lptzText));
+ mir_tstrncpy(ppd.lptzText, description, _countof(ppd.lptzText));
if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST)
{
diff --git a/plugins/AvatarHistory/src/utils.cpp b/plugins/AvatarHistory/src/utils.cpp
index 21ae8a38dc..88b00b3dfb 100644
--- a/plugins/AvatarHistory/src/utils.cpp
+++ b/plugins/AvatarHistory/src/utils.cpp
@@ -144,14 +144,14 @@ TCHAR* GetContactFolder(TCHAR *fn, MCONTACT hContact)
GetProtocolFolder(fn, proto);
TCHAR uin[MAX_PATH];
- GetUIDFromHContact(hContact, uin, SIZEOF(uin));
+ GetUIDFromHContact(hContact, uin, _countof(uin));
ConvertToFilename(uin, MAX_PATH); //added so that weather id's like "yw/CI0000" work
mir_sntprintf(fn, MAX_PATH, _T("%s\\%s"), fn, uin);
CreateDirectoryTreeT(fn);
#ifdef DBGPOPUPS
TCHAR log[1024];
- mir_sntprintf(log, SIZEOF(log), _T("Path: %s\nProto: %S\nUIN: %s"), fn, proto, uin);
+ mir_sntprintf(log, _countof(log), _T("Path: %s\nProto: %S\nUIN: %s"), fn, proto, uin);
ShowPopup(hContact, _T("AVH Debug: GetContactFolder"), log);
#endif
@@ -178,7 +178,7 @@ void CreateOldStyleShortcut(MCONTACT hContact, TCHAR *history_filename)
GetOldStyleAvatarName(shortcut, hContact);
- mir_sntprintf(shortcut, SIZEOF(shortcut), _T("%s.%s.lnk"), shortcut,
+ mir_sntprintf(shortcut, _countof(shortcut), _T("%s.%s.lnk"), shortcut,
GetExtension(history_filename));
if (!CreateShortcut(history_filename, shortcut))
@@ -208,7 +208,7 @@ TCHAR * GetCachedAvatar(char *proto, TCHAR *hash)
else
GetProtocolFolder(file, proto);
- mir_sntprintf(search, SIZEOF(search), _T("%s\\%s.*"), file, hash);
+ mir_sntprintf(search, _countof(search), _T("%s\\%s.*"), file, hash);
WIN32_FIND_DATA finddata;
HANDLE hFind = FindFirstFile(search, &finddata);
@@ -225,7 +225,7 @@ TCHAR * GetCachedAvatar(char *proto, TCHAR *hash)
|| !mir_tstrcmpi(&finddata.cFileName[len-4], _T(".jpg"))
|| !mir_tstrcmpi(&finddata.cFileName[len-5], _T(".jpeg"))))
{
- mir_sntprintf(file, SIZEOF(file), _T("%s\\%s"), file, finddata.cFileName);
+ mir_sntprintf(file, _countof(file), _T("%s\\%s"), file, finddata.cFileName);
ret = mir_tstrdup(file);
break;
}