diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
commit | 4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch) | |
tree | 9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /plugins/Db_autobackups/src | |
parent | f0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (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/Db_autobackups/src')
-rw-r--r-- | plugins/Db_autobackups/src/backup.cpp | 12 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/main.cpp | 10 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/options.cpp | 18 |
3 files changed, 20 insertions, 20 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index e54c7fdecb..07d4a13a97 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -181,7 +181,7 @@ int RotateBackups(TCHAR *backupfolder, TCHAR *dbname) if (options.num_backups == 0)
return 0; /* Roration disabled. */
- mir_sntprintf(backupfolderTmp, SIZEOF(backupfolderTmp), _T("%s\\%s*"), backupfolder, dbname);
+ mir_sntprintf(backupfolderTmp, _countof(backupfolderTmp), _T("%s\\%s*"), backupfolder, dbname);
hFind = FindFirstFile(backupfolderTmp, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
return 0;
@@ -201,7 +201,7 @@ int RotateBackups(TCHAR *backupfolder, TCHAR *dbname) if (i > 0)
qsort(bf, i, sizeof(backupFile), Comp); /* Sort the list of found files by date in descending order. */
for (; i >= options.num_backups; i --) {
- mir_sntprintf(backupfolderTmp, SIZEOF(backupfolderTmp), _T("%s\\%s"), backupfolder, bf[(i - 1)].Name);
+ mir_sntprintf(backupfolderTmp, _countof(backupfolderTmp), _T("%s\\%s"), backupfolder, bf[(i - 1)].Name);
DeleteFile(backupfolderTmp);
}
err_out:
@@ -218,12 +218,12 @@ int Backup(TCHAR *backup_filename) HWND progress_dialog = NULL;
SYSTEMTIME st;
- CallService(MS_DB_GETPROFILENAMET, SIZEOF(dbname), (LPARAM)dbname);
+ CallService(MS_DB_GETPROFILENAMET, _countof(dbname), (LPARAM)dbname);
if (backup_filename == NULL) {
int err;
TCHAR *backupfolder, buffer[MAX_COMPUTERNAME_LENGTH + 1];
- DWORD size = SIZEOF(buffer);
+ DWORD size = _countof(buffer);
bZip = options.use_zip != 0;
backupfolder = Utils_ReplaceVarsT(options.folder);
@@ -237,7 +237,7 @@ int Backup(TCHAR *backup_filename) GetLocalTime(&st);
GetComputerName(buffer, &size);
- mir_sntprintf(dest_file, SIZEOF(dest_file), _T("%s\\%s_%02d.%02d.%02d@%02d-%02d-%02d_%s.%s"), backupfolder, dbname, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, buffer, bZip ? _T("zip") : _T("dat"));
+ mir_sntprintf(dest_file, _countof(dest_file), _T("%s\\%s_%02d.%02d.%02d@%02d-%02d-%02d_%s.%s"), backupfolder, dbname, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, buffer, bZip ? _T("zip") : _T("dat"));
mir_free(backupfolder);
}
else {
@@ -253,7 +253,7 @@ int Backup(TCHAR *backup_filename) SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, TranslateT("Copying database file..."));
- mir_sntprintf(source_file, SIZEOF(source_file), _T("%s\\%s"), profilePath, dbname);
+ mir_sntprintf(source_file, _countof(source_file), _T("%s\\%s"), profilePath, dbname);
TCHAR *pathtmp = Utils_ReplaceVarsT(source_file);
BOOL res = 0;
if (bZip)
diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index 3488432561..5392ab2d9e 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -41,7 +41,7 @@ extern "C" __declspec(dllexport) int Load(void) HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoad);
- Icon_Register(g_hInstance, LPGEN("Database")"/"LPGEN("Database backups"), iconList, SIZEOF(iconList));
+ Icon_Register(g_hInstance, LPGEN("Database")"/"LPGEN("Database backups"), iconList, _countof(iconList));
return 0;
}
@@ -55,7 +55,7 @@ extern "C" __declspec(dllexport) int Unload(void) static int FoldersGetBackupPath(WPARAM, LPARAM)
{
- FoldersGetCustomPathT(hFolder, options.folder, SIZEOF(options.folder), DIR SUB_DIR);
+ FoldersGetCustomPathT(hFolder, options.folder, _countof(options.folder), DIR SUB_DIR);
return 0;
}
INT_PTR ABService(WPARAM, LPARAM)
@@ -67,16 +67,16 @@ INT_PTR DBSaveAs(WPARAM, LPARAM) {
TCHAR fname_buff[MAX_PATH], tszFilter[200];
OPENFILENAME ofn = { 0 };
- CallService(MS_DB_GETPROFILENAMET, SIZEOF(fname_buff), (LPARAM)fname_buff);
+ CallService(MS_DB_GETPROFILENAMET, _countof(fname_buff), (LPARAM)fname_buff);
- mir_sntprintf(tszFilter, SIZEOF(tszFilter), _T("%s (*.dat)%c*.dat%c%s (*.zip)%c*.zip%c%s (*.*)%c*%c"),
+ mir_sntprintf(tszFilter, _countof(tszFilter), _T("%s (*.dat)%c*.dat%c%s (*.zip)%c*.zip%c%s (*.*)%c*%c"),
TranslateT("Miranda NG databases"), 0, 0,
TranslateT("Compressed Miranda NG databases"), 0, 0,
TranslateT("All files"), 0, 0);
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = fname_buff;
- ofn.nMaxFile = SIZEOF(fname_buff);
+ ofn.nMaxFile = _countof(fname_buff);
ofn.Flags = OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT;
ofn.lpstrFilter = tszFilter;
ofn.nFilterIndex = 1;
diff --git a/plugins/Db_autobackups/src/options.cpp b/plugins/Db_autobackups/src/options.cpp index d02bb47032..4be09cbf23 100644 --- a/plugins/Db_autobackups/src/options.cpp +++ b/plugins/Db_autobackups/src/options.cpp @@ -48,13 +48,13 @@ int LoadOptions(void) if (mir_tstrlen(tmp) >= 2 && tmp[1] == ':')
_tcsncpy_s(options.folder, dbv.ptszVal, _TRUNCATE);
else
- mir_sntprintf(options.folder, SIZEOF(options.folder), _T("%s\\%s"), profilePath, dbv.ptszVal);
+ mir_sntprintf(options.folder, _countof(options.folder), _T("%s\\%s"), profilePath, dbv.ptszVal);
db_free(&dbv);
mir_free(tmp);
}
else
- mir_sntprintf(options.folder, SIZEOF(options.folder), _T("%s%s"), DIR, SUB_DIR);
+ mir_sntprintf(options.folder, _countof(options.folder), _T("%s%s"), DIR, SUB_DIR);
}
options.num_backups = db_get_w(0, "AutoBackups", "NumBackups", 3);
@@ -76,7 +76,7 @@ int SaveOptions(void) db_set_w(0, "AutoBackups", "Period", (WORD)options.period);
db_set_b(0, "AutoBackups", "PeriodType", (BYTE)options.period_type);
- mir_sntprintf(prof_dir, SIZEOF(prof_dir), _T("%s\\"), profilePath);
+ mir_sntprintf(prof_dir, _countof(prof_dir), _T("%s\\"), profilePath);
size_t prof_len = mir_tstrlen(prof_dir);
size_t opt_len = mir_tstrlen(options.folder);
@@ -89,7 +89,7 @@ int SaveOptions(void) TCHAR *tmp = Utils_ReplaceVarsT(options.folder);
if (mir_tstrlen(tmp) < 2 || tmp[1] != ':') {
_tcsncpy_s(prof_dir, options.folder, _TRUNCATE);
- mir_sntprintf(options.folder, SIZEOF(options.folder), _T("%s\\%s"), profilePath, prof_dir);
+ mir_sntprintf(options.folder, _countof(options.folder), _T("%s\\%s"), profilePath, prof_dir);
}
mir_free(tmp);
db_set_w(0, "AutoBackups", "NumBackups", options.num_backups);
@@ -188,7 +188,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP }
else {
TCHAR tszTooltipText[4096];
- mir_sntprintf(tszTooltipText, SIZEOF(tszTooltipText), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"),
+ mir_sntprintf(tszTooltipText, _countof(tszTooltipText), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"),
_T("%miranda_path%"), TranslateT("path to Miranda root folder"),
_T("%miranda_profilesdir%"), TranslateT("path to folder containing Miranda profiles"),
_T("%miranda_profilename%"), TranslateT("name of current Miranda profile (filename, without extension)"),
@@ -326,9 +326,9 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
TCHAR buff[10];
- GetDlgItemText(hwndDlg, IDC_ED_PERIOD, buff, SIZEOF(buff));
+ GetDlgItemText(hwndDlg, IDC_ED_PERIOD, buff, _countof(buff));
new_options.period = _ttoi(buff);
- GetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, buff, SIZEOF(buff));
+ GetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, buff, _countof(buff));
new_options.num_backups = _ttoi(buff);
switch (SendDlgItemMessage(hwndDlg, IDC_PT, CB_GETCURSEL, 0, 0)) {
@@ -337,7 +337,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case 2: new_options.period_type = PT_MINUTES; break;
}
- GetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff, SIZEOF(folder_buff));
+ GetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff, _countof(folder_buff));
{
TCHAR backupfolder[MAX_PATH] = { 0 };
BOOL folder_ok = TRUE;
@@ -346,7 +346,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (mir_tstrlen(tmp) >= 2 && tmp[1] == ':')
_tcsncpy_s(backupfolder, tmp, _TRUNCATE);
else
- mir_sntprintf(backupfolder, SIZEOF(backupfolder), _T("%s\\%s"), profilePath, tmp);
+ mir_sntprintf(backupfolder, _countof(backupfolder), _T("%s\\%s"), profilePath, tmp);
mir_free(tmp);
int err = CreateDirectoryTreeT(backupfolder);
|