From 6e53dfca72b932c4bdcd7aa02ca62bf8b2630eac Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 26 Jul 2016 09:20:25 +0000 Subject: less TCHARs: - TCHAR is replaced with wchar_t everywhere; - LPGENT replaced with either LPGENW or LPGEN; - fixes for ANSI plugins that improperly used _t functions; - TCHAR *t removed from MAllStrings; - ptszGroup, ptszTitle & ptszTab in OPTIONSDIALOGPAGE replaced with pwsz* git-svn-id: http://svn.miranda-ng.org/main/trunk@17133 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db_autobackups/src/backup.cpp | 56 +++++++++++++++++----------------- plugins/Db_autobackups/src/main.cpp | 6 ++-- plugins/Db_autobackups/src/options.cpp | 40 ++++++++++++------------ plugins/Db_autobackups/src/options.h | 2 +- plugins/Db_autobackups/src/stdafx.h | 4 +-- 5 files changed, 54 insertions(+), 54 deletions(-) (limited to 'plugins/Db_autobackups') diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index 53a2dad93a..82d06ad4bb 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -9,7 +9,7 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) switch (msg) { case WM_COMMAND: { - TCHAR* ptszPath = (TCHAR*)PUGetPluginData(hWnd); + wchar_t* ptszPath = (wchar_t*)PUGetPluginData(hWnd); if (ptszPath != 0) ShellExecute(0, L"open", ptszPath, NULL, NULL, SW_SHOW); @@ -25,12 +25,12 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) } return DefWindowProc(hWnd, msg, wParam, lParam); } -void ShowPopup(TCHAR* ptszText, TCHAR* ptszHeader, TCHAR* ptszPath) +void ShowPopup(wchar_t* ptszText, wchar_t* ptszHeader, wchar_t* ptszPath) { POPUPDATAT ppd = { 0 }; - _tcsncpy_s(ppd.lptzText, ptszText, _TRUNCATE); - _tcsncpy_s(ppd.lptzContactName, ptszHeader, _TRUNCATE); + wcsncpy_s(ppd.lptzText, ptszText, _TRUNCATE); + wcsncpy_s(ppd.lptzContactName, ptszHeader, _TRUNCATE); if (ptszPath != NULL) ppd.PluginData = (void*)mir_tstrdup(ptszPath); ppd.PluginWindowProc = DlgProcPopup; @@ -57,20 +57,20 @@ INT_PTR CALLBACK DlgProcProgress(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) return FALSE; } -TCHAR* DoubleSlash(TCHAR *sorce) +wchar_t* DoubleSlash(wchar_t *sorce) { - TCHAR *ret, *r, *s; + wchar_t *ret, *r, *s; - ret = (TCHAR*)mir_alloc((MAX_PATH * sizeof(TCHAR))); + ret = (wchar_t*)mir_alloc((MAX_PATH * sizeof(wchar_t))); if (ret == NULL) return NULL; for (s = sorce, r = ret; *s && (r - ret) < (MAX_PATH - 1); s++, r++) { - if (*s != _T('\\')) + if (*s != '\\') *r = *s; else { - *r = _T('\\'); + *r = '\\'; r++; - *r = _T('\\'); + *r = '\\'; } } r[0] = 0; @@ -107,7 +107,7 @@ bool MakeZip_Dir(LPCSTR szDir, LPCTSTR szDest, LPCSTR /* szDbName */, HWND progr return 1; } -bool MakeZip(TCHAR *tszSource, TCHAR *tszDest, TCHAR *dbname, HWND progress_dialog) +bool MakeZip(wchar_t *tszSource, wchar_t *tszDest, wchar_t *dbname, HWND progress_dialog) { HWND hProgBar = GetDlgItem(progress_dialog, IDC_PROGRESS); @@ -124,7 +124,7 @@ bool MakeZip(TCHAR *tszSource, TCHAR *tszDest, TCHAR *dbname, HWND progress_dial struct backupFile { - TCHAR Name[MAX_PATH]; + wchar_t Name[MAX_PATH]; FILETIME CreationTime; }; @@ -140,11 +140,11 @@ int Comp(const void *i, const void *j) return 1; } -int RotateBackups(TCHAR *backupfolder, TCHAR *dbname) +int RotateBackups(wchar_t *backupfolder, wchar_t *dbname) { backupFile *bf = NULL, *bftmp; HANDLE hFind; - TCHAR backupfolderTmp[MAX_PATH]; + wchar_t backupfolderTmp[MAX_PATH]; WIN32_FIND_DATA FindFileData; if (options.num_backups == 0) @@ -162,7 +162,7 @@ int RotateBackups(TCHAR *backupfolder, TCHAR *dbname) if (bftmp == NULL) goto err_out; bf = bftmp; - _tcsncpy_s(bf[i].Name, FindFileData.cFileName, _TRUNCATE); + wcsncpy_s(bf[i].Name, FindFileData.cFileName, _TRUNCATE); bf[i].CreationTime = FindFileData.ftCreationTime; i ++; } while (FindNextFile(hFind, &FindFileData)); @@ -179,10 +179,10 @@ err_out: } -int Backup(TCHAR *backup_filename) +int Backup(wchar_t *backup_filename) { bool bZip = false; - TCHAR dbname[MAX_PATH], source_file[MAX_PATH] = { 0 }, dest_file[MAX_PATH]; + wchar_t dbname[MAX_PATH], source_file[MAX_PATH] = { 0 }, dest_file[MAX_PATH]; HWND progress_dialog = NULL; SYSTEMTIME st; @@ -190,7 +190,7 @@ int Backup(TCHAR *backup_filename) if (backup_filename == NULL) { int err; - TCHAR *backupfolder, buffer[MAX_COMPUTERNAME_LENGTH + 1]; + wchar_t *backupfolder, buffer[MAX_COMPUTERNAME_LENGTH + 1]; DWORD size = _countof(buffer); bZip = options.use_zip != 0; @@ -209,8 +209,8 @@ int Backup(TCHAR *backup_filename) mir_free(backupfolder); } else { - _tcsncpy_s(dest_file, backup_filename, _TRUNCATE); - if (!mir_tstrcmp(_tcsrchr(backup_filename, _T('.')), L".zip")) + wcsncpy_s(dest_file, backup_filename, _TRUNCATE); + if (!mir_tstrcmp(wcsrchr(backup_filename, '.'), L".zip")) bZip = true; } if (!options.disable_popups) @@ -222,7 +222,7 @@ int Backup(TCHAR *backup_filename) SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, TranslateT("Copying database file...")); mir_sntprintf(source_file, L"%s\\%s", profilePath, dbname); - TCHAR *pathtmp = Utils_ReplaceVarsT(source_file); + wchar_t *pathtmp = Utils_ReplaceVarsT(source_file); BOOL res = 0; if (bZip) { @@ -254,14 +254,14 @@ int Backup(TCHAR *backup_filename) if (!options.disable_popups) { size_t dest_file_len = mir_tstrlen(dest_file); - TCHAR *puText; + wchar_t *puText; if (dest_file_len > 50) { size_t i; - puText = (TCHAR*)mir_alloc(sizeof(TCHAR) * (dest_file_len + 2)); - for (i = (dest_file_len - 1); dest_file[i] != _T('\\'); i--) + puText = (wchar_t*)mir_alloc(sizeof(wchar_t) * (dest_file_len + 2)); + for (i = (dest_file_len - 1); dest_file[i] != '\\'; i--) ; - //_tcsncpy_s(dest_file, backup_filename, _TRUNCATE); + //wcsncpy_s(dest_file, backup_filename, _TRUNCATE); mir_tstrncpy(puText, dest_file, (i + 2)); mir_tstrcat(puText, L"\n"); mir_tstrcat(puText, (dest_file + i + 1)); @@ -287,14 +287,14 @@ int Backup(TCHAR *backup_filename) void BackupThread(void *backup_filename) { - Backup((TCHAR*)backup_filename); + Backup((wchar_t*)backup_filename); InterlockedExchange(&m_state, 0); /* Backup done. */ mir_free(backup_filename); } -void BackupStart(TCHAR *backup_filename) +void BackupStart(wchar_t *backup_filename) { - TCHAR *tm = NULL; + wchar_t *tm = NULL; LONG cur_state; cur_state = InterlockedCompareExchange(&m_state, 1, 0); diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index ea26811a07..52cc10aa91 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -2,7 +2,7 @@ int hLangpack; HINSTANCE g_hInstance; -TCHAR *profilePath; +wchar_t *profilePath; HANDLE hFolder; char g_szMirVer[100]; @@ -34,7 +34,7 @@ static INT_PTR ABService(WPARAM, LPARAM) static INT_PTR DBSaveAs(WPARAM, LPARAM) { - TCHAR fname_buff[MAX_PATH], tszFilter[200]; + wchar_t fname_buff[MAX_PATH], tszFilter[200]; OPENFILENAME ofn = { 0 }; CallService(MS_DB_GETPROFILENAMET, _countof(fname_buff), (LPARAM)fname_buff); @@ -65,7 +65,7 @@ static int FoldersGetBackupPath(WPARAM, LPARAM) static int ModulesLoad(WPARAM, LPARAM) { CMenuItem mi; - mi.root = Menu_CreateRoot(MO_MAIN, LPGENT("Database"), 500100000); + mi.root = Menu_CreateRoot(MO_MAIN, LPGENW("Database"), 500100000); SET_UID(mi, 0x1439b1db, 0x7d95, 0x495b, 0xbf, 0x5, 0x3d, 0x21, 0xc1, 0xeb, 0xf7, 0x58); mi.name.a = LPGEN("Backup profile"); diff --git a/plugins/Db_autobackups/src/options.cpp b/plugins/Db_autobackups/src/options.cpp index 7c7aacf482..046f777fd9 100644 --- a/plugins/Db_autobackups/src/options.cpp +++ b/plugins/Db_autobackups/src/options.cpp @@ -43,10 +43,10 @@ int LoadOptions(void) DBVARIANT dbv; if (!db_get_ts(0, "AutoBackups", "Folder", &dbv)) { - TCHAR *tmp = Utils_ReplaceVarsT(dbv.ptszVal); + wchar_t *tmp = Utils_ReplaceVarsT(dbv.ptszVal); if (mir_tstrlen(tmp) >= 2 && tmp[1] == ':') - _tcsncpy_s(options.folder, dbv.ptszVal, _TRUNCATE); + wcsncpy_s(options.folder, dbv.ptszVal, _TRUNCATE); else mir_sntprintf(options.folder, L"%s\\%s", profilePath, dbv.ptszVal); @@ -69,7 +69,7 @@ int LoadOptions(void) int SaveOptions(void) { - TCHAR prof_dir[MAX_PATH]; + wchar_t prof_dir[MAX_PATH]; db_set_b(0, "AutoBackups", "BackupType", (BYTE)options.backup_types); if (options.period < 1) @@ -81,15 +81,15 @@ int SaveOptions(void) size_t prof_len = mir_tstrlen(prof_dir); size_t opt_len = mir_tstrlen(options.folder); - if (opt_len > prof_len && _tcsncmp(options.folder, prof_dir, prof_len) == 0) { + if (opt_len > prof_len && wcsncmp(options.folder, prof_dir, prof_len) == 0) { db_set_ts(0, "AutoBackups", "Folder", (options.folder + prof_len)); } else db_set_ts(0, "AutoBackups", "Folder", options.folder); - TCHAR *tmp = Utils_ReplaceVarsT(options.folder); + wchar_t *tmp = Utils_ReplaceVarsT(options.folder); if (mir_tstrlen(tmp) < 2 || tmp[1] != ':') { - _tcsncpy_s(prof_dir, options.folder, _TRUNCATE); + wcsncpy_s(prof_dir, options.folder, _TRUNCATE); mir_sntprintf(options.folder, L"%s\\%s", profilePath, prof_dir); } mir_free(tmp); @@ -108,7 +108,7 @@ Options new_options; int SetDlgState(HWND hwndDlg) { - TCHAR buff[10]; + wchar_t buff[10]; if (new_options.backup_types == BT_DISABLED) { CheckDlgButton(hwndDlg, IDC_RAD_DISABLED, BST_CHECKED); @@ -148,10 +148,10 @@ int SetDlgState(HWND hwndDlg) } SendDlgItemMessage(hwndDlg, SPIN_PERIOD, UDM_SETRANGE32, 1, (LPARAM)60); - SetDlgItemText(hwndDlg, IDC_ED_PERIOD, _itot(new_options.period, buff, 10)); + SetDlgItemText(hwndDlg, IDC_ED_PERIOD, _itow(new_options.period, buff, 10)); SendDlgItemMessage(hwndDlg, SPIN_NUMBACKUPS, UDM_SETRANGE32, 1, (LPARAM)100); - SetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, _itot(new_options.num_backups, buff, 10)); + SetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, _itow(new_options.num_backups, buff, 10)); SetDlgItemText(hwndDlg, IDC_ED_FOLDER, new_options.folder); @@ -171,7 +171,7 @@ int CALLBACK BrowseProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM) switch (uMsg) { case BFFM_INITIALIZED: - TCHAR *folder = Utils_ReplaceVarsT(options.folder); + wchar_t *folder = Utils_ReplaceVarsT(options.folder); SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)folder); mir_free(folder); break; @@ -181,7 +181,7 @@ int CALLBACK BrowseProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM) INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - TCHAR folder_buff[MAX_PATH] = { 0 }; + wchar_t folder_buff[MAX_PATH] = { 0 }; switch (msg) { case WM_INITDIALOG: @@ -194,7 +194,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP ShowWindow(GetDlgItem(hwndDlg, IDC_LNK_FOLDERS), SW_SHOW); } else { - TCHAR tszTooltipText[4096]; + wchar_t tszTooltipText[4096]; mir_sntprintf(tszTooltipText, L"%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", L"%miranda_path%", TranslateT("path to Miranda root folder"), L"%miranda_profilesdir%", TranslateT("path to folder containing Miranda profiles"), @@ -341,11 +341,11 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { - TCHAR buff[10]; + wchar_t buff[10]; GetDlgItemText(hwndDlg, IDC_ED_PERIOD, buff, _countof(buff)); - new_options.period = _ttoi(buff); + new_options.period = _wtoi(buff); GetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, buff, _countof(buff)); - new_options.num_backups = _ttoi(buff); + new_options.num_backups = _wtoi(buff); switch (SendDlgItemMessage(hwndDlg, IDC_PT, CB_GETCURSEL, 0, 0)) { case 0: new_options.period_type = PT_DAYS; break; @@ -355,26 +355,26 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP GetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff, _countof(folder_buff)); { - TCHAR backupfolder[MAX_PATH] = { 0 }; + wchar_t backupfolder[MAX_PATH] = { 0 }; BOOL folder_ok = TRUE; - TCHAR *tmp = Utils_ReplaceVarsT(folder_buff); + wchar_t *tmp = Utils_ReplaceVarsT(folder_buff); if (mir_tstrlen(tmp) >= 2 && tmp[1] == ':') - _tcsncpy_s(backupfolder, tmp, _TRUNCATE); + wcsncpy_s(backupfolder, tmp, _TRUNCATE); else mir_sntprintf(backupfolder, L"%s\\%s", profilePath, tmp); mir_free(tmp); int err = CreateDirectoryTreeT(backupfolder); if (err != ERROR_ALREADY_EXISTS && err != 0) { - TCHAR msg_buff[512]; + wchar_t msg_buff[512]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, msg_buff, 512, 0); MessageBox(0, msg_buff, TranslateT("Error creating backup folder"), MB_OK | MB_ICONERROR); folder_ok = FALSE; } if (folder_ok) { - _tcsncpy_s(new_options.folder, folder_buff, _TRUNCATE); + wcsncpy_s(new_options.folder, folder_buff, _TRUNCATE); memcpy(&options, &new_options, sizeof(Options)); SaveOptions(); } diff --git a/plugins/Db_autobackups/src/options.h b/plugins/Db_autobackups/src/options.h index 991c109285..8cd2b4f1b2 100644 --- a/plugins/Db_autobackups/src/options.h +++ b/plugins/Db_autobackups/src/options.h @@ -29,7 +29,7 @@ typedef struct Options_tag { int backup_types; unsigned int period; PeriodType period_type; - TCHAR folder[MAX_PATH]; + wchar_t folder[MAX_PATH]; int num_backups; BOOL disable_progress; BOOL disable_popups; diff --git a/plugins/Db_autobackups/src/stdafx.h b/plugins/Db_autobackups/src/stdafx.h index e7f2d81b1d..55ed621497 100644 --- a/plugins/Db_autobackups/src/stdafx.h +++ b/plugins/Db_autobackups/src/stdafx.h @@ -39,7 +39,7 @@ int SetBackupTimer(void); int OptionsInit(WPARAM wParam, LPARAM lParam); int LoadOptions(void); -void BackupStart(TCHAR *backup_filename); +void BackupStart(wchar_t *backup_filename); struct ZipFile { @@ -51,7 +51,7 @@ struct ZipFile int CreateZipFile(const char *szDestPath, OBJLIST &lstFiles, const std::function &fnCallback); extern HINSTANCE g_hInstance; -extern TCHAR *profilePath; +extern wchar_t *profilePath; extern char g_szMirVer[]; static IconItem iconList[] = { -- cgit v1.2.3