summaryrefslogtreecommitdiff
path: root/src/core/stdfile
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 /src/core/stdfile
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 'src/core/stdfile')
-rw-r--r--src/core/stdfile/src/file.cpp6
-rw-r--r--src/core/stdfile/src/fileexistsdlg.cpp30
-rw-r--r--src/core/stdfile/src/fileopts.cpp24
-rw-r--r--src/core/stdfile/src/filerecvdlg.cpp32
-rw-r--r--src/core/stdfile/src/filesenddlg.cpp16
-rw-r--r--src/core/stdfile/src/filexferdlg.cpp28
6 files changed, 68 insertions, 68 deletions
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp
index d6a28d2072..6be3bf587b 100644
--- a/src/core/stdfile/src/file.cpp
+++ b/src/core/stdfile/src/file.cpp
@@ -123,7 +123,7 @@ void PushFileEvent(MCONTACT hContact, MEVENT hdbe, LPARAM lParam)
SkinPlaySound("RecvFile");
TCHAR szTooltip[256];
- mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("File from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
+ mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("File from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
cle.ptszTooltip = szTooltip;
cle.flags |= CLEF_TCHAR;
@@ -356,7 +356,7 @@ INT_PTR FtMgrShowCommand(WPARAM, LPARAM)
INT_PTR openContRecDir(WPARAM hContact, LPARAM)
{
TCHAR szContRecDir[MAX_PATH];
- GetContactReceivedFilesDir(hContact, szContRecDir, SIZEOF(szContRecDir), TRUE);
+ GetContactReceivedFilesDir(hContact, szContRecDir, _countof(szContRecDir), TRUE);
ShellExecute(0, _T("open"), szContRecDir, 0, 0, SW_SHOW);
return 0;
}
@@ -364,7 +364,7 @@ INT_PTR openContRecDir(WPARAM hContact, LPARAM)
INT_PTR openRecDir(WPARAM, LPARAM)
{
TCHAR szContRecDir[MAX_PATH];
- GetReceivedFilesDir(szContRecDir, SIZEOF(szContRecDir));
+ GetReceivedFilesDir(szContRecDir, _countof(szContRecDir));
ShellExecute(0, _T("open"), szContRecDir, 0, 0, SW_SHOW);
return 0;
}
diff --git a/src/core/stdfile/src/fileexistsdlg.cpp b/src/core/stdfile/src/fileexistsdlg.cpp
index 81b1a220ba..23c888da3f 100644
--- a/src/core/stdfile/src/fileexistsdlg.cpp
+++ b/src/core/stdfile/src/fileexistsdlg.cpp
@@ -35,9 +35,9 @@ static void SetControlToUnixTime(HWND hwndDlg, UINT idCtrl, time_t unixTime)
filetime.dwHighDateTime = liFiletime.HighPart;
filetime.dwLowDateTime = liFiletime.LowPart;
FileTimeToSystemTime(&filetime, &st);
- GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, szTime, SIZEOF(szTime));
- GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, szDate, SIZEOF(szDate));
- mir_snprintf(szOutput, SIZEOF(szOutput), "%s %s", szDate, szTime);
+ GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, szTime, _countof(szTime));
+ GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, szDate, _countof(szDate));
+ mir_snprintf(szOutput, _countof(szOutput), "%s %s", szDate, szTime);
SetDlgItemTextA(hwndDlg, idCtrl, szOutput);
}
@@ -149,27 +149,27 @@ void __cdecl LoadIconsAndTypesThread(void* param)
TCHAR *pszExtension = _tcsrchr(pszFilename, '.');
if (pszExtension)
- mir_tstrncpy(szExtension, pszExtension + 1, SIZEOF(szExtension));
+ mir_tstrncpy(szExtension, pszExtension + 1, _countof(szExtension));
else {
pszExtension = _T(".");
szExtension[0] = '\0';
}
CharUpper(szExtension);
if (fileInfo.szTypeName[0] == '\0')
- mir_sntprintf(fileInfo.szTypeName, SIZEOF(fileInfo.szTypeName), TranslateT("%s file"), szExtension);
+ mir_sntprintf(fileInfo.szTypeName, _countof(fileInfo.szTypeName), TranslateT("%s file"), szExtension);
SetDlgItemText(info->hwndDlg, IDC_EXISTINGTYPE, fileInfo.szTypeName);
SetDlgItemText(info->hwndDlg, IDC_NEWTYPE, fileInfo.szTypeName);
SendDlgItemMessage(info->hwndDlg, IDC_EXISTINGICON, STM_SETICON, (WPARAM)fileInfo.hIcon, 0);
szIconFile[0] = '\0';
if (!mir_tstrcmp(szExtension, _T("EXE")))
- SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, SIZEOF(szIconFile));
+ SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, _countof(szIconFile));
else {
TCHAR szTypeName[MAX_PATH];
- if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, pszExtension, NULL, szTypeName, SIZEOF(szTypeName))) {
+ if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, pszExtension, NULL, szTypeName, _countof(szTypeName))) {
mir_tstrcat(szTypeName, _T("\\DefaultIcon"));
- if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, szTypeName, NULL, szIconFile, SIZEOF(szIconFile))) {
+ if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, szTypeName, NULL, szIconFile, _countof(szIconFile))) {
if (_tcsstr(szIconFile, _T("%1")))
- SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("0"), szIconFile, SIZEOF(szIconFile));
+ SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("0"), szIconFile, _countof(szIconFile));
else szIconFile[0] = '\0';
}
}
@@ -213,7 +213,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fts);
SetDlgItemText(hwndDlg, IDC_FILENAME, fts->tszCurrentFile);
SetControlToUnixTime(hwndDlg, IDC_NEWDATE, fts->currentFileTime);
- GetSensiblyFormattedSize(fts->currentFileSize, szSize, SIZEOF(szSize), 0, 1, NULL);
+ GetSensiblyFormattedSize(fts->currentFileSize, szSize, _countof(szSize), 0, 1, NULL);
SetDlgItemText(hwndDlg, IDC_NEWSIZE, szSize);
mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EXISTINGICON), IconCtrlSubclassProc);
@@ -221,7 +221,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
HWND hwndFocus = GetDlgItem(hwndDlg, IDC_RESUME);
if (_tstati64(fts->tszCurrentFile, &statbuf) == 0) {
SetControlToUnixTime(hwndDlg, IDC_EXISTINGDATE, statbuf.st_mtime);
- GetSensiblyFormattedSize(statbuf.st_size, szSize, SIZEOF(szSize), 0, 1, NULL);
+ GetSensiblyFormattedSize(statbuf.st_size, szSize, _countof(szSize), 0, 1, NULL);
SetDlgItemText(hwndDlg, IDC_EXISTINGSIZE, szSize);
if (statbuf.st_size > (int)fts->currentFileSize) {
EnableWindow(GetDlgItem(hwndDlg, IDC_RESUME), FALSE);
@@ -250,7 +250,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
case IDC_OPENFOLDER:
{
TCHAR szFile[MAX_PATH];
- mir_tstrncpy(szFile, fts->tszCurrentFile, SIZEOF(szFile));
+ mir_tstrncpy(szFile, fts->tszCurrentFile, _countof(szFile));
TCHAR *pszLastBackslash = _tcsrchr(szFile, '\\');
if (pszLastBackslash)
*pszLastBackslash = '\0';
@@ -283,11 +283,11 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
TCHAR filter[512], *pfilter;
TCHAR str[MAX_PATH];
- mir_tstrncpy(str, fts->tszCurrentFile, SIZEOF(str));
+ mir_tstrncpy(str, fts->tszCurrentFile, _countof(str));
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
- _tcsncpy(filter, TranslateT("All files"),SIZEOF(filter)-1);
+ _tcsncpy(filter, TranslateT("All files"),_countof(filter)-1);
mir_tstrcat(filter, _T(" (*)"));
pfilter = filter + mir_tstrlen(filter) + 1;
mir_tstrcpy(pfilter, _T("*"));
@@ -295,7 +295,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
*pfilter = '\0';
ofn.lpstrFilter = filter;
ofn.lpstrFile = str;
- ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFile = _countof(str);
ofn.nMaxFileTitle = MAX_PATH;
if (!GetSaveFileName(&ofn))
return FALSE;
diff --git a/src/core/stdfile/src/fileopts.cpp b/src/core/stdfile/src/fileopts.cpp
index 7b56f2bdb9..11566c05c8 100644
--- a/src/core/stdfile/src/fileopts.cpp
+++ b/src/core/stdfile/src/fileopts.cpp
@@ -63,7 +63,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILEDIR), SHACF_FILESYS_DIRS);
TCHAR str[MAX_PATH];
- GetContactReceivedFilesDir(NULL, str, SIZEOF(str), FALSE);
+ GetContactReceivedFilesDir(NULL, str, _countof(str), FALSE);
SetDlgItemText(hwndDlg, IDC_FILEDIR, str);
CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, db_get_b(NULL, "SRFile", "AutoAccept", 0) ? BST_CHECKED : BST_UNCHECKED);
@@ -77,9 +77,9 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
}
CheckDlgButton(hwndDlg, IDC_WARNBEFOREOPENING, db_get_b(NULL, "SRFile", "WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED);
- for (int i = 0; i < SIZEOF(virusScanners); i++) {
+ for (int i = 0; i < _countof(virusScanners); i++) {
TCHAR szScanExe[MAX_PATH];
- if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, SIZEOF(szScanExe))) {
+ if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, _countof(szScanExe))) {
int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName);
SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i);
}
@@ -124,10 +124,10 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
TCHAR str[512];
TCHAR szScanExe[MAX_PATH];
int iScanner = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0);
- if (iScanner >= SIZEOF(virusScanners) || iScanner < 0) break;
+ if (iScanner >= _countof(virusScanners) || iScanner < 0) break;
str[0] = '\0';
- if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, SIZEOF(szScanExe)))
- mir_sntprintf(str, SIZEOF(str), virusScanners[iScanner].szCommandLine, szScanExe);
+ if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, _countof(szScanExe)))
+ mir_sntprintf(str, _countof(str), virusScanners[iScanner].szCommandLine, szScanExe);
SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str);
}
break;
@@ -141,7 +141,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
case IDC_FILEDIRBROWSE:
{
TCHAR str[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str));
if (BrowseForFolder(hwndDlg, str))
SetDlgItemText(hwndDlg, IDC_FILEDIR, str);
}
@@ -163,7 +163,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
case IDC_SCANCMDLINEBROWSE:
TCHAR str[MAX_PATH + 2];
- GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str));
CMString tszFilter;
tszFilter.AppendFormat(_T("%s (*.exe)%c*.exe%c"), TranslateT("Executable files"), 0, 0);
@@ -175,7 +175,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
ofn.lpstrFilter = tszFilter;
ofn.lpstrFile = str;
- ofn.nMaxFile = SIZEOF(str) - 2;
+ ofn.nMaxFile = _countof(str) - 2;
if (str[0] == '"') {
TCHAR *pszQuote = _tcschr(str + 1, '"');
if (pszQuote)
@@ -189,7 +189,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
ofn.nMaxFileTitle = MAX_PATH;
if (!GetOpenFileName(&ofn)) break;
if (_tcschr(str, ' ') != NULL) {
- memmove(str + 1, str, ((SIZEOF(str) - 2) * sizeof(TCHAR)));
+ memmove(str + 1, str, ((_countof(str) - 2) * sizeof(TCHAR)));
str[0] = '"';
mir_tstrcat(str, _T("\""));
}
@@ -203,7 +203,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
TCHAR str[512];
- GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str));
RemoveInvalidPathChars(str);
db_set_ts(NULL, "SRFile", "RecvFilesDirAdv", str);
db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT));
@@ -211,7 +211,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
db_set_b(NULL, "SRFile", "AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE));
db_set_b(NULL, "SRFile", "AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR));
db_set_b(NULL, "SRFile", "UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL) ? VIRUSSCAN_AFTERDL : (IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL) ? VIRUSSCAN_DURINGDL : VIRUSSCAN_DISABLE)));
- GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str));
db_set_ts(NULL, "SRFile", "ScanCmdLine", str);
db_set_b(NULL, "SRFile", "WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING));
db_set_b(NULL, "SRFile", "IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK) ? FILERESUME_ASK : (IsDlgButtonChecked(hwndDlg, IDC_RESUME) ? FILERESUME_RESUMEALL : (IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE) ? FILERESUME_OVERWRITEALL : FILERESUME_RENAMEALL))));
diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp
index 16edf1c4a0..0b7cd4325b 100644
--- a/src/core/stdfile/src/filerecvdlg.cpp
+++ b/src/core/stdfile/src/filerecvdlg.cpp
@@ -134,7 +134,7 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO
if (tszRecvPath)
_tcsncpy_s(tszTemp, tszRecvPath, _TRUNCATE);
else
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
+ mir_sntprintf(tszTemp, _countof(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
if (hContact) {
hContact = db_mc_tryMeta(hContact);
@@ -149,7 +149,7 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO
rvaVarsToReplace[2].lptzValue = mir_a2t(GetContactProto(hContact));
rvaVarsToReplace[3].lptzKey = NULL;
rvaVarsToReplace[3].lptzValue = NULL;
- for (int i = 0; i < (SIZEOF(rvaVarsToReplace) - 1); i++)
+ for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++)
RemoveInvalidFilenameChars(rvaVarsToReplace[i].lptzValue);
dat.cbSize = sizeof(dat);
@@ -158,15 +158,15 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO
dat.hContact = hContact;
TCHAR *result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)tszTemp, (LPARAM)&dat);
if (result) {
- _tcsncpy(tszTemp, result, SIZEOF(tszTemp));
+ _tcsncpy(tszTemp, result, _countof(tszTemp));
mir_free(result);
- for (int i = 0; i < (SIZEOF(rvaVarsToReplace) - 1); i++)
+ for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++)
mir_free(rvaVarsToReplace[i].lptzValue);
}
}
if (patchVars)
- patchDir(tszTemp, SIZEOF(tszTemp));
+ patchDir(tszTemp, _countof(tszTemp));
RemoveInvalidPathChars(tszTemp);
mir_tstrncpy(szDir, tszTemp, cchDir);
}
@@ -179,9 +179,9 @@ void GetReceivedFilesDir(TCHAR *szDir, int cchDir)
if (tszRecvPath)
_tcsncpy_s(tszTemp, tszRecvPath, _TRUNCATE);
else
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
+ mir_sntprintf(tszTemp, _countof(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
- patchDir(tszTemp, SIZEOF(tszTemp));
+ patchDir(tszTemp, _countof(tszTemp));
RemoveInvalidPathChars(tszTemp);
mir_tstrncpy(szDir, tszTemp, cchDir);
}
@@ -215,7 +215,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
SetDlgItemText(hwndDlg, IDC_FROM, contactName);
- GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE);
+ GetContactReceivedFilesDir(dat->hContact, szPath, _countof(szPath), TRUE);
SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath);
SHAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1);
@@ -254,7 +254,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
else DestroyWindow(hwndDlg);
TCHAR datetimestr[64];
- TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, SIZEOF(datetimestr), 0);
+ TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, _countof(datetimestr), 0);
SetDlgItemText(hwndDlg, IDC_DATE, datetimestr);
char* szProto = GetContactProto(dat->hContact);
@@ -330,8 +330,8 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{
TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, SIZEOF(szDirName));
- GetLowestExistingDirName(szDirName, szExistingDirName, SIZEOF(szExistingDirName));
+ GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, _countof(szDirName));
+ GetLowestExistingDirName(szDirName, szExistingDirName, _countof(szExistingDirName));
if (BrowseForFolder(hwndDlg, szExistingDirName))
SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName);
}
@@ -340,9 +340,9 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
case IDOK:
{ //most recently used directories
TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, SIZEOF(szRecvDir));
+ GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, _countof(szRecvDir));
RemoveInvalidPathChars(szRecvDir);
- GetContactReceivedFilesDir(NULL, szDefaultRecvDir, SIZEOF(szDefaultRecvDir), TRUE);
+ GetContactReceivedFilesDir(NULL, szDefaultRecvDir, _countof(szDefaultRecvDir), TRUE);
if (_tcsnicmp(szRecvDir, szDefaultRecvDir, mir_tstrlen(szDefaultRecvDir))) {
char idstr[32];
int i;
@@ -362,9 +362,9 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE);
- GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath));
- GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames));
- GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg));
+ GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, _countof(dat->szSavePath));
+ GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, _countof(dat->szFilenames));
+ GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, _countof(dat->szMsg));
dat->hwndTransfer = FtMgr_AddTransfer(dat);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
//check for auto-minimize here to fix BUG#647620
diff --git a/src/core/stdfile/src/filesenddlg.cpp b/src/core/stdfile/src/filesenddlg.cpp
index 5516373588..aa9cbee487 100644
--- a/src/core/stdfile/src/filesenddlg.cpp
+++ b/src/core/stdfile/src/filesenddlg.cpp
@@ -44,21 +44,21 @@ static void SetFileListAndSizeControls(HWND hwndDlg, FileDlgData *dat)
}
}
- GetSensiblyFormattedSize(totalSize, str, SIZEOF(str), 0, 1, NULL);
+ GetSensiblyFormattedSize(totalSize, str, _countof(str), 0, 1, NULL);
SetDlgItemText(hwndDlg, IDC_TOTALSIZE, str);
if (i > 1) {
TCHAR szFormat[32];
if (fileCount && dirCount) {
- mir_sntprintf(szFormat, SIZEOF(szFormat), _T("%s, %s"), TranslateTS(fileCount == 1 ? _T("%d file") : _T("%d files")), TranslateTS(dirCount == 1 ? _T("%d directory") : _T("%d directories")));
- mir_sntprintf(str, SIZEOF(str), szFormat, fileCount, dirCount);
+ mir_sntprintf(szFormat, _countof(szFormat), _T("%s, %s"), TranslateTS(fileCount == 1 ? _T("%d file") : _T("%d files")), TranslateTS(dirCount == 1 ? _T("%d directory") : _T("%d directories")));
+ mir_sntprintf(str, _countof(str), szFormat, fileCount, dirCount);
}
else if (fileCount) {
mir_tstrcpy(szFormat, TranslateT("%d files"));
- mir_sntprintf(str, SIZEOF(str), szFormat, fileCount);
+ mir_sntprintf(str, _countof(str), szFormat, fileCount);
}
else {
mir_tstrcpy(szFormat, TranslateT("%d directories"));
- mir_sntprintf(str, SIZEOF(str), szFormat, dirCount);
+ mir_sntprintf(str, _countof(str), szFormat, dirCount);
}
SetDlgItemText(hwndDlg, IDC_FILE, str);
}
@@ -323,9 +323,9 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSE), FALSE);
- GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath));
- GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames));
- GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg));
+ GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, _countof(dat->szSavePath));
+ GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, _countof(dat->szFilenames));
+ GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, _countof(dat->szMsg));
dat->hwndTransfer = FtMgr_AddTransfer(dat);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
DestroyWindow(hwndDlg);
diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp
index ac01125118..3e5976e08a 100644
--- a/src/core/stdfile/src/filexferdlg.cpp
+++ b/src/core/stdfile/src/filexferdlg.cpp
@@ -105,7 +105,7 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info)
if (info->szFile[mir_tstrlen(info->szFile) - 1] == '\\')
info->szFile[mir_tstrlen(info->szFile) - 1] = '\0';
*pszReplace = 0;
- mir_sntprintf(szCmdLine, SIZEOF(szCmdLine), _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace + 2);
+ mir_sntprintf(szCmdLine, _countof(szCmdLine), _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace + 2);
} else
_tcsncpy_s(szCmdLine, dbv.ptszVal, _TRUNCATE);
@@ -139,7 +139,7 @@ static void SetFilenameControls(HWND hwndDlg, FileDlgData *dat, PROTOFILETRANSFE
if (dat->hIcon) DestroyIcon(dat->hIcon); dat->hIcon = NULL;
if (fn && (fts->totalFiles > 1)) {
- mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s (%d %s %d)"),
+ mir_sntprintf(msg, _countof(msg), _T("%s: %s (%d %s %d)"),
pcli->pfnGetContactDisplayName(fts->hContact, 0),
fn, fts->currentFileNumber + 1, TranslateT("of"), fts->totalFiles);
@@ -147,13 +147,13 @@ static void SetFilenameControls(HWND hwndDlg, FileDlgData *dat, PROTOFILETRANSFE
dat->hIcon = shfi.hIcon;
}
else if (fn) {
- mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s"), pcli->pfnGetContactDisplayName(fts->hContact, 0), fn);
+ mir_sntprintf(msg, _countof(msg), _T("%s: %s"), pcli->pfnGetContactDisplayName(fts->hContact, 0), fn);
SHGetFileInfo(fn, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(shfi), SHGFI_USEFILEATTRIBUTES | SHGFI_ICON | SHGFI_SMALLICON);
dat->hIcon = shfi.hIcon;
}
else {
- mir_tstrncpy(msg, pcli->pfnGetContactDisplayName(fts->hContact, 0), SIZEOF(msg));
+ mir_tstrncpy(msg, pcli->pfnGetContactDisplayName(fts->hContact, 0), _countof(msg));
HICON hIcon = Skin_LoadIcon(SKINICON_OTHER_DOWNARROW);
dat->hIcon = CopyIcon(hIcon);
IcoLib_ReleaseIcon(hIcon, NULL);
@@ -297,7 +297,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case WM_TIMER:
memmove(dat->bytesRecvedHistory + 1, dat->bytesRecvedHistory, sizeof(dat->bytesRecvedHistory) - sizeof(dat->bytesRecvedHistory[0]));
dat->bytesRecvedHistory[0] = dat->transferStatus.totalProgress;
- if (dat->bytesRecvedHistorySize < SIZEOF(dat->bytesRecvedHistory))
+ if (dat->bytesRecvedHistorySize < _countof(dat->bytesRecvedHistory))
dat->bytesRecvedHistorySize++;
{
@@ -306,23 +306,23 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
ULARGE_INTEGER li;
FILETIME ft;
- GetSensiblyFormattedSize((dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) / dat->bytesRecvedHistorySize, szSpeed, SIZEOF(szSpeed), 0, 1, NULL);
+ GetSensiblyFormattedSize((dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) / dat->bytesRecvedHistorySize, szSpeed, _countof(szSpeed), 0, 1, NULL);
if (dat->bytesRecvedHistory[0] == dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1])
mir_tstrcpy(szTime, _T("??:??:??"));
else {
li.QuadPart = BIGI(10000000)*(dat->transferStatus.currentFileSize - dat->transferStatus.currentFileProgress)*dat->bytesRecvedHistorySize / (dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]);
ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart;
FileTimeToSystemTime(&ft, &st);
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime));
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, _countof(szTime));
}
if (dat->bytesRecvedHistory[0] != dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) {
li.QuadPart = BIGI(10000000)*(dat->transferStatus.totalBytes - dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize / (dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]);
ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart;
FileTimeToSystemTime(&ft, &st);
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime));
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, _countof(szTime));
}
- mir_sntprintf(szDisplay, SIZEOF(szDisplay), _T("%s/%s (%s %s)"), szSpeed, TranslateT("sec"), szTime, TranslateT("remaining"));
+ mir_sntprintf(szDisplay, _countof(szDisplay), _T("%s/%s (%s %s)"), szSpeed, TranslateT("sec"), szTime, TranslateT("remaining"));
SetDlgItemText(hwndDlg, IDC_ALLSPEED, szDisplay);
}
break;
@@ -596,16 +596,16 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
const unsigned long nextPos = fts->totalBytes ? (BIGI(100) * fts->totalProgress / fts->totalBytes) : 0;
if (lastPos != nextPos || firstTime) {
SendDlgItemMessage(hwndDlg, IDC_ALLFILESPROGRESS, PBM_SETPOS, nextPos, 0);
- mir_sntprintf(str, SIZEOF(str), _T("%u%%"), nextPos);
+ mir_sntprintf(str, _countof(str), _T("%u%%"), nextPos);
SetDlgItemText(hwndDlg, IDC_ALLPRECENTS, str);
}
int units;
- GetSensiblyFormattedSize(fts->totalBytes, szSizeTotal, SIZEOF(szSizeTotal), 0, 1, &units);
- GetSensiblyFormattedSize(fts->totalProgress, szSizeDone, SIZEOF(szSizeDone), units, 0, NULL);
- mir_sntprintf(str, SIZEOF(str), _T("%s/%s"), szSizeDone, szSizeTotal);
+ GetSensiblyFormattedSize(fts->totalBytes, szSizeTotal, _countof(szSizeTotal), 0, 1, &units);
+ GetSensiblyFormattedSize(fts->totalProgress, szSizeDone, _countof(szSizeDone), units, 0, NULL);
+ mir_sntprintf(str, _countof(str), _T("%s/%s"), szSizeDone, szSizeTotal);
str2[0] = 0;
- GetDlgItemText(hwndDlg, IDC_ALLTRANSFERRED, str2, SIZEOF(str2));
+ GetDlgItemText(hwndDlg, IDC_ALLTRANSFERRED, str2, _countof(str2));
if (mir_tstrcmp(str, str2))
SetDlgItemText(hwndDlg, IDC_ALLTRANSFERRED, str);
}