diff options
-rw-r--r-- | include/m_system_cpp.h | 2 | ||||
-rw-r--r-- | include/m_utils.h | 28 | ||||
-rw-r--r-- | plugins/YAMN/src/main.cpp | 3 | ||||
-rw-r--r-- | src/modules/clist/clui.cpp | 4 | ||||
-rw-r--r-- | src/modules/database/database.cpp | 84 | ||||
-rw-r--r-- | src/modules/database/dbini.cpp | 20 | ||||
-rw-r--r-- | src/modules/database/profilemanager.cpp | 60 | ||||
-rw-r--r-- | src/modules/database/profilemanager.h | 2 | ||||
-rw-r--r-- | src/modules/netlib/netliblog.cpp | 15 | ||||
-rw-r--r-- | src/modules/utils/path.cpp | 7 | ||||
-rw-r--r-- | src/modules/utils/utils.cpp | 10 |
11 files changed, 113 insertions, 122 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index 67b5a243d5..2cb5a5af5e 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_SYSTEM_CPP_H__
#define M_SYSTEM_CPP_H__ 1
+#include <stdlib.h>
+
#include "m_system.h"
#if defined(_UNICODE)
diff --git a/include/m_utils.h b/include/m_utils.h index 64d0e2a2e3..bd9f21d887 100644 --- a/include/m_utils.h +++ b/include/m_utils.h @@ -414,16 +414,34 @@ typedef struct #define MS_UTILS_REPLACEVARS "Utils/ReplaceVars"
__forceinline char* Utils_ReplaceVars(const char *szData) {
- REPLACEVARSDATA dat = {0};
- dat.cbSize = sizeof(dat);
+ REPLACEVARSDATA dat = { sizeof(dat) };
return (char*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szData, (LPARAM)&dat);
}
__forceinline TCHAR* Utils_ReplaceVarsT(const TCHAR *szData) {
- REPLACEVARSDATA dat = {0};
- dat.cbSize = sizeof(dat);
- dat.dwFlags = RVF_TCHAR;
+ REPLACEVARSDATA dat = { sizeof(dat), RVF_TCHAR };
return (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szData, (LPARAM)&dat);
}
+
+#if defined(__cplusplus)
+ #if !defined(M_SYSTEM_CPP_H__)
+ #include "m_system_cpp.h"
+ #endif
+
+ struct VARS : public mir_ptr<char>
+ {
+ __forceinline VARS(const char *str) :
+ mir_ptr<char>( Utils_ReplaceVars(str))
+ {}
+ };
+
+ struct VARST : public mir_ptr<TCHAR>
+ {
+ __forceinline VARST(const TCHAR *str) :
+ mir_ptr<TCHAR>( Utils_ReplaceVarsT(str))
+ {}
+ };
+#endif
+
#ifdef _UNICODE
#define MS_UTILS_PATHTORELATIVEW "Utils/PathToRelativeW"
#define MS_UTILS_PATHTOABSOLUTEW "Utils/PathToAbsoluteW"
diff --git a/plugins/YAMN/src/main.cpp b/plugins/YAMN/src/main.cpp index 1743199ba2..07a6ce0e85 100644 --- a/plugins/YAMN/src/main.cpp +++ b/plugins/YAMN/src/main.cpp @@ -123,7 +123,7 @@ static void GetProfileDirectory(TCHAR *szPath, int cbPath) CallService(MS_DB_GETPROFILEPATHT, SIZEOF(tszOldPath), (LPARAM)tszOldPath);
_tcscat(tszOldPath, _T("\\*.book"));
- TCHAR* ptszNewPath = Utils_ReplaceVarsT( _T("%miranda_userdata%"));
+ VARST ptszNewPath( _T("%miranda_userdata%"));
SHFILEOPSTRUCT file_op = {
NULL,
@@ -137,7 +137,6 @@ static void GetProfileDirectory(TCHAR *szPath, int cbPath) SHFileOperation(&file_op);
_tcsncpy(szPath, ptszNewPath, cbPath);
- mir_free(ptszNewPath);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/modules/clist/clui.cpp b/src/modules/clist/clui.cpp index ab4b7db76a..26e9894606 100644 --- a/src/modules/clist/clui.cpp +++ b/src/modules/clist/clui.cpp @@ -460,9 +460,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM int rc;
// wParam = (ATOM)hProfileAtom, lParam = 0
if (GlobalGetAtomName((ATOM) wParam, profile, SIZEOF(profile))) {
- TCHAR *pfd = Utils_ReplaceVarsT(_T("%miranda_userdata%\\%miranda_profilename%.dat"));
- rc = lstrcmpi(profile, pfd) == 0;
- mir_free(pfd);
+ rc = lstrcmpi(profile, VARST(_T("%miranda_userdata%\\%miranda_profilename%.dat"))) == 0;
ReplyMessage(rc);
if (rc) {
ShowWindow(hwnd, SW_RESTORE);
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index 168a6d5f27..adea9e0caa 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // contains the location of mirandaboot.ini
extern TCHAR mirandabootini[MAX_PATH];
-bool dbCreated;
+bool g_bDbCreated;
TCHAR g_profileDir[MAX_PATH], g_profileName[MAX_PATH];
TCHAR* g_defaultProfile;
void EnsureCheckerLoaded(bool);
@@ -55,15 +55,11 @@ static void fillProfileName(const TCHAR* ptszFileName) bool IsInsideRootDir(TCHAR* profiledir, bool exact)
{
- int res;
- TCHAR* pfd = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ VARST pfd( _T("%miranda_path%"));
if (exact)
- res = _tcsicmp(profiledir, pfd);
- else
- res = _tcsnicmp(profiledir, pfd, _tcslen(pfd));
-
- mir_free(pfd);
- return res == 0;
+ return _tcsicmp(profiledir, pfd) == 0;
+
+ return _tcsnicmp(profiledir, pfd, _tcslen(pfd)) == 0;
}
// returns 1 if the profile path was returned, without trailing slash
@@ -75,9 +71,7 @@ int getProfilePath(TCHAR *buf, size_t cch) if (profiledir[0] == 0)
_tcscpy(profiledir, _T("%miranda_path%\\Profiles"));
- TCHAR* exprofiledir = Utils_ReplaceVarsT(profiledir);
- size_t len = PathToAbsoluteT(exprofiledir, buf, NULL);
- mir_free(exprofiledir);
+ size_t len = PathToAbsoluteT( VARST(profiledir), buf, NULL);
if (buf[len-1] == '/' || buf[len-1] == '\\')
buf[len-1] = 0;
@@ -123,12 +117,11 @@ static void getDefaultProfile(TCHAR *szProfile, size_t cch, TCHAR *profiledir) if (defaultProfile[0] == 0)
return;
- TCHAR* res = Utils_ReplaceVarsT(defaultProfile);
- if (res) {
- mir_sntprintf(szProfile, cch, _T("%s\\%s\\%s%s"), profiledir, res, res, isValidProfileName(res) ? _T("") : _T(".dat"));
- mir_free(res);
- }
- else szProfile[0] = 0;
+ VARST res(defaultProfile);
+ if (res)
+ mir_sntprintf(szProfile, cch, _T("%s\\%s\\%s%s"), profiledir, (TCHAR*)res, (TCHAR*)res, isValidProfileName(res) ? _T("") : _T(".dat"));
+ else
+ szProfile[0] = 0;
}
// returns 1 if something that looks like a profile is there
@@ -183,12 +176,10 @@ void getProfileDefault(TCHAR *szProfile, size_t cch, TCHAR *profiledir) static void moveProfileDirProfiles(TCHAR *profiledir, BOOL isRootDir = TRUE)
{
TCHAR pfd[MAX_PATH];
- if (isRootDir) {
- TCHAR *path = Utils_ReplaceVarsT(_T("%miranda_path%\\*.dat"));
- mir_sntprintf(pfd, SIZEOF(pfd), _T("%s"), path);
- mir_free(path);
- }
- else mir_sntprintf(pfd, SIZEOF(pfd), _T("%s\\*.dat"), profiledir);
+ if (isRootDir)
+ _tcsncpy(pfd, VARST( _T("%miranda_path%\\*.dat")), SIZEOF(pfd));
+ else
+ mir_sntprintf(pfd, SIZEOF(pfd), _T("%s\\*.dat"), profiledir);
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile(pfd, &ffd);
@@ -288,7 +279,6 @@ static int getProfileAutoRun(TCHAR *szProfile) // returns 1 if a profile was selected
static int getProfile(TCHAR *szProfile, size_t cch)
{
- PROFILEMANAGERDATA pd = {0};
getProfilePath(g_profileDir, SIZEOF(g_profileDir));
if (IsInsideRootDir(g_profileDir, true))
if (WritePrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), mirandabootini))
@@ -304,6 +294,7 @@ static int getProfile(TCHAR *szProfile, size_t cch) return 0;
}
+ PROFILEMANAGERDATA pd = {0};
if ( CmdLine_GetOption( _T("ForceShowPM"))) {
LBL_Show:
pd.szProfile = szProfile;
@@ -341,47 +332,6 @@ char* makeFileName(const TCHAR* tszOriginalName) return szResult;
}
-// called by the UI, return 1 on success, use link to create profile, set error if any
-int makeDatabase(TCHAR *profile, DATABASELINK * link, HWND hwndDlg)
-{
- TCHAR buf[256];
- int err = 0;
- // check if the file already exists
- TCHAR *file = _tcsrchr(profile, '\\');
- if (file) file++;
- if (_taccess(profile, 0) == 0) {
- // file already exists!
- mir_sntprintf(buf, SIZEOF(buf),
- TranslateT("The profile '%s' already exists. Do you want to move it to the Recycle Bin?\n\nWARNING: The profile will be deleted if Recycle Bin is disabled.\nWARNING: A profile may contain confidential information and should be properly deleted."),
- file);
- if (MessageBox(hwndDlg, buf, TranslateT("The profile already exists"), MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES)
- return 0;
-
- // move the file
- SHFILEOPSTRUCT sf = {0};
- sf.wFunc = FO_DELETE;
- sf.pFrom = buf;
- sf.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
- mir_sntprintf(buf, SIZEOF(buf), _T("%s\0"), profile);
- if (SHFileOperation(&sf) != 0) {
- mir_sntprintf(buf, SIZEOF(buf), TranslateT("Couldn't move '%s' to the Recycle Bin, Please select another profile name."), file);
- MessageBox(0, buf, TranslateT("Problem moving profile"), MB_ICONINFORMATION|MB_OK);
- return 0;
- }
- // now the file should be gone!
- }
- // ask the database to create the profile
- CreatePathToFileT(profile);
- if ((err = link->makeDatabase(profile)) != ERROR_SUCCESS) {
- mir_sntprintf(buf, SIZEOF(buf), TranslateT("Unable to create the profile '%s', the error was %x"), file, err);
- MessageBox(hwndDlg, buf, TranslateT("Problem creating profile"), MB_ICONERROR|MB_OK);
- return 0;
- }
- dbCreated = true;
- // the profile has been created! woot
- return 1;
-}
-
// enumerate all plugins that had valid DatabasePluginInfo()
int tryOpenDatabase(const TCHAR *tszProfile)
{
@@ -428,7 +378,7 @@ static int tryCreateDatabase(const TCHAR* ptszProfile) int err = p->makeDatabase(tszProfile);
if (err == ERROR_SUCCESS) {
- dbCreated = true;
+ g_bDbCreated = true;
MIDatabase *pDb = p->Load(tszProfile);
if (pDb != NULL) {
fillProfileName(tszProfile);
diff --git a/src/modules/database/dbini.cpp b/src/modules/database/dbini.cpp index 8a15b3eb08..0445da160e 100644 --- a/src/modules/database/dbini.cpp +++ b/src/modules/database/dbini.cpp @@ -22,12 +22,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "..\..\core\commonheaders.h"
+#include "profilemanager.h"
static bool bModuleInitialized = false;
static HANDLE hIniChangeNotification;
extern TCHAR mirandabootini[MAX_PATH];
-extern bool dbCreated;
static INT_PTR CALLBACK InstallIniDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -395,7 +395,6 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf static void DoAutoExec(void)
{
TCHAR szUse[7], szIniPath[MAX_PATH], szFindPath[MAX_PATH];
- TCHAR *str2;
TCHAR buf[2048], szSecurity[11], szOverrideSecurityFilename[MAX_PATH], szOnCreateFilename[MAX_PATH];
char *szSafeSections, *szUnsafeSections;
int secur;
@@ -415,17 +414,12 @@ static void DoAutoExec(void) GetPrivateProfileString(_T("AutoExec"), _T("OnCreateFilename"), _T(""), szOnCreateFilename, SIZEOF(szOnCreateFilename), mirandabootini);
GetPrivateProfileString(_T("AutoExec"), _T("Glob"), _T("autoexec_*.ini"), szFindPath, SIZEOF(szFindPath), mirandabootini);
- if (dbCreated && szOnCreateFilename[0]) {
- str2 = Utils_ReplaceVarsT(szOnCreateFilename);
- PathToAbsoluteT(str2, szIniPath, NULL);
- mir_free(str2);
-
+ if (g_bDbCreated && szOnCreateFilename[0]) {
+ PathToAbsoluteT( VARST(szOnCreateFilename), szIniPath, NULL);
ProcessIniFile(szIniPath, szSafeSections, szUnsafeSections, 0, 1);
}
- str2 = Utils_ReplaceVarsT(szFindPath);
- PathToAbsoluteT(str2, szFindPath, NULL);
- mir_free(str2);
+ PathToAbsoluteT( VARST(szFindPath), szFindPath, NULL);
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(szFindPath, &fd);
@@ -435,7 +429,7 @@ static void DoAutoExec(void) return;
}
- str2 = _tcsrchr(szFindPath, '\\');
+ TCHAR *str2 = _tcsrchr(szFindPath, '\\');
if (str2 == NULL) szFindPath[0] = 0;
else str2[1] = 0;
@@ -478,7 +472,9 @@ static void DoAutoExec(void) else if ( !lstrcmpi(szOnCompletion, _T("ask")))
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INIIMPORTDONE), NULL, IniImportDoneDlgProc, (LPARAM)szIniPath);
}
- } while (FindNextFile(hFind, &fd));
+ }
+ while (FindNextFile(hFind, &fd));
+
FindClose(hFind);
mir_free(szSafeSections);
mir_free(szUnsafeSections);
diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 19f219a463..d597d50a3f 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -107,6 +107,47 @@ static int findProfiles(TCHAR *szProfileDir, ENUMPROFILECALLBACK callback, LPARA return 1;
}
+static int CreateProfile(TCHAR *profile, DATABASELINK * link, HWND hwndDlg)
+{
+ TCHAR buf[256];
+ int err = 0;
+ // check if the file already exists
+ TCHAR *file = _tcsrchr(profile, '\\');
+ if (file) file++;
+ if (_taccess(profile, 0) == 0) {
+ // file already exists!
+ mir_sntprintf(buf, SIZEOF(buf),
+ TranslateT("The profile '%s' already exists. Do you want to move it to the Recycle Bin?\n\nWARNING: The profile will be deleted if Recycle Bin is disabled.\nWARNING: A profile may contain confidential information and should be properly deleted."),
+ file);
+ if (MessageBox(hwndDlg, buf, TranslateT("The profile already exists"), MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES)
+ return 0;
+
+ // move the file
+ SHFILEOPSTRUCT sf = {0};
+ sf.wFunc = FO_DELETE;
+ sf.pFrom = buf;
+ sf.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s\0"), profile);
+ if (SHFileOperation(&sf) != 0) {
+ mir_sntprintf(buf, SIZEOF(buf), TranslateT("Couldn't move '%s' to the Recycle Bin, Please select another profile name."), file);
+ MessageBox(0, buf, TranslateT("Problem moving profile"), MB_ICONINFORMATION|MB_OK);
+ return 0;
+ }
+ // now the file should be gone!
+ }
+ // ask the database to create the profile
+ CreatePathToFileT(profile);
+ if ((err = link->makeDatabase(profile)) != ERROR_SUCCESS) {
+ mir_sntprintf(buf, SIZEOF(buf), TranslateT("Unable to create the profile '%s', the error was %x"), file, err);
+ MessageBox(hwndDlg, buf, TranslateT("Problem creating profile"), MB_ICONERROR|MB_OK);
+ return 0;
+ }
+
+ // the profile has been created!
+ g_bDbCreated = true;
+ return 1;
+}
+
static LRESULT CALLBACK ProfileNameValidate(HWND edit, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_CHAR) {
@@ -119,7 +160,7 @@ static LRESULT CALLBACK ProfileNameValidate(HWND edit, UINT msg, WPARAM wParam, static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- struct DlgProfData * dat = (struct DlgProfData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ struct DlgProfData *dat = (struct DlgProfData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -189,7 +230,7 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case WM_NOTIFY:
{
- NMHDR* hdr = (NMHDR*)lParam;
+ NMHDR *hdr = (NMHDR*)lParam;
if (hdr && hdr->code == PSN_APPLY && dat && IsWindowVisible(hwndDlg)) {
TCHAR szName[MAX_PATH];
LRESULT curSel = SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETCURSEL, 0, 0);
@@ -203,9 +244,8 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA dat->pd->newProfile = 1;
dat->pd->dblink = (DATABASELINK *)SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETITEMDATA, (WPARAM)curSel, 0);
- if (makeDatabase(dat->pd->szProfile, dat->pd->dblink, hwndDlg) == 0) {
+ if ( CreateProfile(dat->pd->szProfile, dat->pd->dblink, hwndDlg) == 0)
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
- }
}
}
break;
@@ -751,7 +791,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, return FALSE;
}
-static int AddProfileManagerPage(struct DetailsPageInit * opi, OPTIONSDIALOGPAGE * odp)
+static int AddProfileManagerPage(struct DetailsPageInit *opi, OPTIONSDIALOGPAGE *odp)
{
if (odp->cbSize != sizeof(OPTIONSDIALOGPAGE))
return 1;
@@ -777,12 +817,9 @@ static int AddProfileManagerPage(struct DetailsPageInit * opi, OPTIONSDIALOGPAGE int getProfileManager(PROFILEMANAGERDATA * pd)
{
- DetailsPageInit opi;
- opi.pageCount = 0;
- opi.odp = NULL;
+ DetailsPageInit opi = { 0 };
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.cbSize = sizeof(odp);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.pszTitle = LPGEN("My Profiles");
odp.pfnDlgProc = DlgProfileSelect;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROFILE_SELECTION);
@@ -797,16 +834,13 @@ int getProfileManager(PROFILEMANAGERDATA * pd) PROPSHEETHEADER psh = { 0 };
psh.dwSize = sizeof(psh);
psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW;
- psh.hwndParent = NULL;
psh.nPages = opi.pageCount;
- psh.pStartPage = 0;
psh.ppsp = (PROPSHEETPAGE*)opi.odp;
DlgProfData prof;
prof.pd = pd;
prof.psh = &psh;
int rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PROFILEMANAGER), NULL, DlgProfileManager, (LPARAM)&prof);
-
if (rc != -1)
for (int i=0; i < opi.pageCount; i++) {
mir_free((char*)opi.odp[i].pszTitle);
diff --git a/src/modules/database/profilemanager.h b/src/modules/database/profilemanager.h index ae68e20388..f289a77ef8 100644 --- a/src/modules/database/profilemanager.h +++ b/src/modules/database/profilemanager.h @@ -31,7 +31,6 @@ struct PROFILEMANAGERDATA };
char* makeFileName(const TCHAR* tszOriginalName);
-int makeDatabase(TCHAR *profile, DATABASELINK * link, HWND hwndDlg);
int getProfileManager(PROFILEMANAGERDATA * pd);
int getProfilePath(TCHAR *buf, size_t cch);
int isValidProfileName(const TCHAR *name);
@@ -40,3 +39,4 @@ bool shouldAutoCreate(TCHAR *szProfile); extern TCHAR g_profileDir[MAX_PATH];
extern TCHAR g_profileName[MAX_PATH];
+extern bool g_bDbCreated;
diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp index 4b2272932c..81ae80c604 100644 --- a/src/modules/netlib/netliblog.cpp +++ b/src/modules/netlib/netliblog.cpp @@ -138,18 +138,15 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa break;
*/
case IDC_FILENAME:
- if (HIWORD(wParam) != EN_CHANGE) break;
- if ((HWND)lParam == GetFocus())
- CheckDlgButton(hwndDlg, IDC_TOFILE, BST_CHECKED);
+ if (HIWORD(wParam) == EN_CHANGE) {
+ if ((HWND)lParam == GetFocus())
+ CheckDlgButton(hwndDlg, IDC_TOFILE, BST_CHECKED);
- {
TCHAR path[MAX_PATH];
GetWindowText((HWND)lParam, path, MAX_PATH);
- TCHAR *pszNewPath = Utils_ReplaceVarsT(path);
- PathToAbsoluteT(pszNewPath, path, NULL);
+ PathToAbsoluteT( VARST(path), path, NULL);
SetDlgItemText(hwndDlg, IDC_PATH, path);
- mir_free(pszNewPath);
}
break;
case IDC_FILENAMEBROWSE:
@@ -568,13 +565,11 @@ void NetlibLogInit(void) if ( !DBGetContactSettingTString(NULL, "Netlib", "File", &dbv)) {
logOptions.szUserFile = mir_tstrdup(dbv.ptszVal);
- TCHAR *pszNewPath = Utils_ReplaceVarsT(dbv.ptszVal);
TCHAR path[MAX_PATH];
- PathToAbsoluteT(pszNewPath, path, NULL);
+ PathToAbsoluteT( VARST(dbv.ptszVal), path, NULL);
logOptions.szFile = mir_tstrdup(path);
- mir_free(pszNewPath);
db_free(&dbv);
}
else {
diff --git a/src/modules/utils/path.cpp b/src/modules/utils/path.cpp index 8c9cfbc6fe..0e9f38eb42 100644 --- a/src/modules/utils/path.cpp +++ b/src/modules/utils/path.cpp @@ -388,11 +388,10 @@ XCHAR *ReplaceVariables(XCHAR *str, REPLACEVARSDATA *data) static INT_PTR replaceVars(WPARAM wParam, LPARAM lParam)
{
REPLACEVARSDATA *data = (REPLACEVARSDATA *)lParam;
- if ( !(data->dwFlags & RVF_UNICODE))
- return (INT_PTR)ReplaceVariables<char>((char *)wParam, data);
+ if (data->dwFlags & RVF_UNICODE)
+ return (INT_PTR)ReplaceVariables<WCHAR>((WCHAR *)wParam, data);
-
- return (INT_PTR)ReplaceVariables<WCHAR>((WCHAR *)wParam, data);
+ return (INT_PTR)ReplaceVariables<char>((char *)wParam, data);
}
int InitPathUtils(void)
diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp index 18d5e88973..8c577679c5 100644 --- a/src/modules/utils/utils.cpp +++ b/src/modules/utils/utils.cpp @@ -429,11 +429,11 @@ static INT_PTR RestartMiranda(WPARAM wParam, LPARAM) si.cb = sizeof(si);
GetModuleFileName(NULL, mirandaPath, SIZEOF(mirandaPath));
if (wParam) {
- TCHAR *profilename = Utils_ReplaceVarsT(_T("%miranda_profilename%"));
- mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), profilename);
- mir_free(profilename);
- } else
- mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d"), mirandaPath, GetCurrentProcessId());
+ VARST profilename( _T("%miranda_profilename%"));
+ mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), (TCHAR*)profilename);
+ }
+ else mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d"), mirandaPath, GetCurrentProcessId());
+
CallService("CloseAction", 0, 0);
CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
return 0;
|