From b81ce648978e75bc7db4cc3b8aa7d1b9fcb9239b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 21 Jun 2015 22:00:16 +0000 Subject: MS_UTILS_REPLACEVARS -> Utils_ReplaceVars git-svn-id: http://svn.miranda-ng.org/main/trunk@14316 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/lib/mir_app.lib | Bin 55902 -> 56376 bytes bin10/lib/mir_app64.lib | Bin 54694 -> 55120 bytes bin12/lib/mir_app.lib | Bin 55902 -> 56376 bytes bin12/lib/mir_app64.lib | Bin 54694 -> 55120 bytes include/delphi/m_utils.inc | 23 +++------ include/m_utils.h | 58 ++++++----------------- plugins/Exchange/src/emails.cpp | 3 +- plugins/PluginUpdater/src/Utils.cpp | 13 ++--- plugins/Quotes/src/SettingsDlg.cpp | 9 +--- plugins/Scriver/src/chat/options.cpp | 79 +++++++++++++++---------------- plugins/TabSRMM/src/chat/options.cpp | 70 +++++++++++++-------------- plugins/UserGuide/src/main.cpp | 8 +--- plugins/Utils.pas/mirutils.pas | 25 ++-------- plugins/Variables/src/parse_system.cpp | 8 +--- plugins/mRadio/rglobal.pas | 6 +-- src/core/stdfile/src/filerecvdlg.cpp | 40 ++++++---------- src/mir_app/src/chat_tools.cpp | 52 ++++++++++---------- src/mir_app/src/mir_app.def | 2 + src/mir_app/src/mir_app64.def | 2 + src/mir_app/src/path.cpp | 84 +++++++++++++++------------------ src/mir_app/src/utils.cpp | 3 -- 21 files changed, 193 insertions(+), 292 deletions(-) diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib index 4cf033532b..b0fcc7fc69 100644 Binary files a/bin10/lib/mir_app.lib and b/bin10/lib/mir_app.lib differ diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib index 4c74871892..92c318596d 100644 Binary files a/bin10/lib/mir_app64.lib and b/bin10/lib/mir_app64.lib differ diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib index 4cf033532b..b0fcc7fc69 100644 Binary files a/bin12/lib/mir_app.lib and b/bin12/lib/mir_app.lib differ diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib index 4c74871892..92c318596d 100644 Binary files a/bin12/lib/mir_app64.lib and b/bin12/lib/mir_app64.lib differ diff --git a/include/delphi/m_utils.inc b/include/delphi/m_utils.inc index f71dfedd65..1a313cea7e 100644 --- a/include/delphi/m_utils.inc +++ b/include/delphi/m_utils.inc @@ -309,10 +309,9 @@ function PathIsAbsoluteW(const pSrc:PWideChar):int; stdcall; procedure Utils_GetRandom(pSrc:pointer; size:size_t); stdcall; external CoreDLL name 'Utils_GetRandom'; -//Replace variables in text -//wParam=(char*/TCHAR*/WCHAR*)string (depends on RVF_UNICODE/RVF_TCHAR flag) -//lParam=(REPLACEVARSDATA *) data about variables, item with key=0 terminates the list -//returns new string, use mir_free to destroy +// Replace variables in text +// returns new string, use mir_free to destroy + type PREPLACEVARSARRAY = ^TREPLACEVARSARRAY; TREPLACEVARSARRAY = record @@ -320,18 +319,10 @@ type szValue:TCHAR; end; -type - TREPLACEVARSDATA = record - cbSize :int; - dwFlags :dword; - hContact :TMCONTACT; - variables:PREPLACEVARSARRAY; - end; - -const - RVF_UNICODE = 1; - - MS_UTILS_REPLACEVARS:PAnsiChar = 'Utils/ReplaceVars'; +function Utils_ReplaceVars(const pSrc:PAnsiChar; hContact:TMCONTACT = 0; vars:PREPLACEVARSARRAY = nil):PAnsiChar; stdcall; + external CoreDLL name 'Utils_ReplaceVars'; +function Utils_ReplaceVarsW(const pSrc:PWideChar; hContact:TMCONTACT = 0; vars:PREPLACEVARSARRAY = nil):PWideChar; stdcall; + external CoreDLL name 'Utils_ReplaceVarsW'; { variables known by the core: diff --git a/include/m_utils.h b/include/m_utils.h index 96e7cbe783..02e7d994d3 100644 --- a/include/m_utils.h +++ b/include/m_utils.h @@ -356,47 +356,15 @@ EXTERN_C MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen); // %destkop% -> location of the desktop folder in a user's profile. // %mydocuments% -> location of the "My Documents" shell folder. -typedef struct +struct REPLACEVARSARRAY { - union - { - TCHAR *lptzKey; - char *lpszKey; - WCHAR *lpwzKey; - }; - union - { - TCHAR *lptzValue; - char *lpszValue; - WCHAR *lpwzValue; - }; -} REPLACEVARSARRAY; - -typedef struct -{ - int cbSize; - DWORD dwFlags; - MCONTACT hContact; - REPLACEVARSARRAY *variables; -} REPLACEVARSDATA; - -#define RVF_UNICODE 1 -#ifdef _UNICODE - #define RVF_TCHAR RVF_UNICODE -#else - #define RVF_TCHAR 0 -#endif + MAllStrings key, value; +}; -#define MS_UTILS_REPLACEVARS "Utils/ReplaceVars" +EXTERN_C MIR_APP_DLL(char*) Utils_ReplaceVars(const char *szData, MCONTACT hContact = 0, REPLACEVARSARRAY *vars = NULL); +EXTERN_C MIR_APP_DLL(wchar_t*) Utils_ReplaceVarsW(const wchar_t *szData, MCONTACT hContact = 0, REPLACEVARSARRAY *vars = NULL); -__forceinline char* Utils_ReplaceVars(const char *szData) { - REPLACEVARSDATA dat = { sizeof(dat) }; - return (char*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szData, (LPARAM)&dat); -} -__forceinline TCHAR* Utils_ReplaceVarsT(const TCHAR *szData) { - REPLACEVARSDATA dat = { sizeof(dat), RVF_TCHAR }; - return (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szData, (LPARAM)&dat); -} +#define Utils_ReplaceVarsT Utils_ReplaceVarsW #if defined(__cplusplus) #if !defined(M_SYSTEM_CPP_H__) @@ -406,16 +374,18 @@ __forceinline TCHAR* Utils_ReplaceVarsT(const TCHAR *szData) { struct VARS : public ptrA { __forceinline VARS(const char *str) : - ptrA( Utils_ReplaceVars(str)) - {} + ptrA(Utils_ReplaceVars(str)) + {} }; - struct VARST : public ptrT + struct VARSW : public ptrW { - __forceinline VARST(const TCHAR *str) : - ptrT( Utils_ReplaceVarsT(str)) - {} + __forceinline VARSW(const wchar_t *str) : + ptrW(Utils_ReplaceVarsW(str)) + {} }; + + typedef VARSW VARST; #endif ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/Exchange/src/emails.cpp b/plugins/Exchange/src/emails.cpp index c362ac3852..a2669f7abb 100644 --- a/plugins/Exchange/src/emails.cpp +++ b/plugins/Exchange/src/emails.cpp @@ -62,8 +62,7 @@ int CExchangeServer::Connect(int bForceConnect) TCHAR server[1024]; GetStringFromDatabase("Username", _T(""), user, _countof(user)); - if (ServiceExists(MS_UTILS_REPLACEVARS)) - _tcsncpy_s(user, VARST(user), _TRUNCATE); + _tcsncpy_s(user, VARST(user), _TRUNCATE); GetStringFromDatabase("Password", _T(""), password, _countof(password)); GetStringFromDatabase("Server", _T(""), server, _countof(server)); diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 1ea04d468d..296fe7ffb6 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -113,18 +113,15 @@ int CompareHashes(const ServListEntry *p1, const ServListEntry *p2) bool ParseHashes(const TCHAR *ptszUrl, ptrT &baseUrl, SERVLIST &arHashes) { REPLACEVARSARRAY vars[2]; - vars[0].lptzKey = _T("platform"); + vars[0].key.t = _T("platform"); #ifdef _WIN64 - vars[0].lptzValue = _T("64"); + vars[0].value.t = _T("64"); #else - vars[0].lptzValue = _T("32"); + vars[0].value.t = _T("32"); #endif - vars[1].lptzKey = vars[1].lptzValue = 0; + vars[1].key.t = vars[1].value.t = 0; - REPLACEVARSDATA dat = { sizeof(REPLACEVARSDATA) }; - dat.dwFlags = RVF_TCHAR; - dat.variables = vars; - baseUrl = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)ptszUrl, (LPARAM)&dat); + baseUrl = Utils_ReplaceVarsT(ptszUrl, 0, vars); // Download version info FILEURL pFileUrl; diff --git a/plugins/Quotes/src/SettingsDlg.cpp b/plugins/Quotes/src/SettingsDlg.cpp index 268b9a1c1b..501b3b7aef 100644 --- a/plugins/Quotes/src/SettingsDlg.cpp +++ b/plugins/Quotes/src/SettingsDlg.cpp @@ -1070,14 +1070,9 @@ tstring GenerateLogFileName(const tstring& rsLogFilePattern, } } - if (nFlags&glfnResolveUserProfile) + if (nFlags & glfnResolveUserProfile) { - REPLACEVARSDATA dat = { 0 }; - dat.cbSize = sizeof(dat); - dat.dwFlags = RVF_TCHAR; - - TCHAR* ptszParsedName = reinterpret_cast(CallService(MS_UTILS_REPLACEVARS, - reinterpret_cast(sPath.c_str()), reinterpret_cast(&dat))); + TCHAR* ptszParsedName = Utils_ReplaceVarsT(sPath.c_str()); if (ptszParsedName) { sPath = ptszParsedName; diff --git a/plugins/Scriver/src/chat/options.cpp b/plugins/Scriver/src/chat/options.cpp index 3005ae0dd6..57dccf89b9 100644 --- a/plugins/Scriver/src/chat/options.cpp +++ b/plugins/Scriver/src/chat/options.cpp @@ -361,46 +361,45 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa PathToRelativeT(g_Settings.pszLogDir, tszTemp); SetDlgItemText(hwndDlg, IDC_CHAT_LOGDIRECTORY, tszTemp); } - if (ServiceExists(MS_UTILS_REPLACEVARS)) { - TCHAR tszTooltipText[2048]; - RECT rect; - - mir_sntprintf(tszTooltipText, _countof(tszTooltipText), - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") - _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\n%s - %s\n\n") - _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\n%s - %s"), - // contact vars - _T("%nick%"), TranslateT("nick of current contact (if defined)"), - _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"), - _T("%accountname%"), TranslateT("user-defined account name of current contact (if defined)."), - _T("%userid%"), TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."), - // global vars - _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)"), - _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"), - _T("%miranda_logpath%"), TranslateT("will return parsed string %miranda_userdata%\\Logs"), - _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), - _T("%username%"), TranslateT("username for currently logged-on Windows user"), - _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), - _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), - _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), - // date/time vars - _T("%d%"), TranslateT("day of month, 1-31"), - _T("%dd%"), TranslateT("day of month, 01-31"), - _T("%m%"), TranslateT("month number, 1-12"), - _T("%mm%"), TranslateT("month number, 01-12"), - _T("%mon%"), TranslateT("abbreviated month name"), - _T("%month%"), TranslateT("full month name"), - _T("%yy%"), TranslateT("year without century, 01-99"), - _T("%yyyy%"), TranslateT("year with century, 1901-9999"), - _T("%wday%"), TranslateT("abbreviated weekday name"), - _T("%weekday%"), TranslateT("full weekday name")); - GetClientRect (GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY), &rect); - rect.left = -85; - hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY), tszTooltipText, TranslateT("Variables"), &rect); - SetTimer(hwndDlg, 0, 3000, NULL); - } + + TCHAR tszTooltipText[2048]; + RECT rect; + + mir_sntprintf(tszTooltipText, _countof(tszTooltipText), + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") + _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\n%s - %s\n\n") + _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\n%s - %s"), + // contact vars + _T("%nick%"), TranslateT("nick of current contact (if defined)"), + _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"), + _T("%accountname%"), TranslateT("user-defined account name of current contact (if defined)."), + _T("%userid%"), TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."), + // global vars + _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)"), + _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"), + _T("%miranda_logpath%"), TranslateT("will return parsed string %miranda_userdata%\\Logs"), + _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), + _T("%username%"), TranslateT("username for currently logged-on Windows user"), + _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), + _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), + _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), + // date/time vars + _T("%d%"), TranslateT("day of month, 1-31"), + _T("%dd%"), TranslateT("day of month, 01-31"), + _T("%m%"), TranslateT("month number, 1-12"), + _T("%mm%"), TranslateT("month number, 01-12"), + _T("%mon%"), TranslateT("abbreviated month name"), + _T("%month%"), TranslateT("full month name"), + _T("%yy%"), TranslateT("year without century, 01-99"), + _T("%yyyy%"), TranslateT("year with century, 1901-9999"), + _T("%wday%"), TranslateT("abbreviated weekday name"), + _T("%weekday%"), TranslateT("full weekday name")); + GetClientRect(GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY), &rect); + rect.left = -85; + hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY), tszTooltipText, TranslateT("Variables"), &rect); + SetTimer(hwndDlg, 0, 3000, NULL); SetDlgItemText(hwndDlg, IDC_CHAT_HIGHLIGHTWORDS, g_Settings.pszHighlightWords); SetDlgItemText(hwndDlg, IDC_CHAT_LOGTIMESTAMP, g_Settings.pszTimeStampLog); diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 791b695f5b..6aee911b79 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -689,42 +689,40 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, CHAT_MODULE, "LoggingLimit", 100), 0)); Utils::enableDlgControl(hwndDlg, IDC_LIMIT, g_Settings.bLoggingEnabled); - if (ServiceExists(MS_UTILS_REPLACEVARS)) { - TCHAR tszTooltipText[2048]; - - mir_sntprintf(tszTooltipText, _countof(tszTooltipText), - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") - _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\n%s - %s\n\n") - _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\n%s - %s"), - // contact vars - _T("%nick%"), TranslateT("nick of current contact (if defined)"), - _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"), - _T("%accountname%"), TranslateT("user-defined account name of current contact (if defined)."), - _T("%userid%"), TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."), - // global vars - _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)"), - _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"), - _T("%miranda_logpath%"), TranslateT("will return parsed string %miranda_userdata%\\Logs"), - _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), - _T("%username%"), TranslateT("username for currently logged-on Windows user"), - _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), - _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), - _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), - // date/time vars - _T("%d%"), TranslateT("day of month, 1-31"), - _T("%dd%"), TranslateT("day of month, 01-31"), - _T("%m%"), TranslateT("month number, 1-12"), - _T("%mm%"), TranslateT("month number, 01-12"), - _T("%mon%"), TranslateT("abbreviated month name"), - _T("%month%"), TranslateT("full month name"), - _T("%yy%"), TranslateT("year without century, 01-99"), - _T("%yyyy%"), TranslateT("year with century, 1901-9999"), - _T("%wday%"), TranslateT("abbreviated weekday name"), - _T("%weekday%"), TranslateT("full weekday name")); - hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), tszTooltipText, TranslateT("Variables")); - } + TCHAR tszTooltipText[2048]; + + mir_sntprintf(tszTooltipText, _countof(tszTooltipText), + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") + _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\n%s - %s\n\n") + _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\n%s - %s"), + // contact vars + _T("%nick%"), TranslateT("nick of current contact (if defined)"), + _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"), + _T("%accountname%"), TranslateT("user-defined account name of current contact (if defined)."), + _T("%userid%"), TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."), + // global vars + _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)"), + _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"), + _T("%miranda_logpath%"), TranslateT("will return parsed string %miranda_userdata%\\Logs"), + _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), + _T("%username%"), TranslateT("username for currently logged-on Windows user"), + _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), + _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), + _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), + // date/time vars + _T("%d%"), TranslateT("day of month, 1-31"), + _T("%dd%"), TranslateT("day of month, 01-31"), + _T("%m%"), TranslateT("month number, 1-12"), + _T("%mm%"), TranslateT("month number, 01-12"), + _T("%mon%"), TranslateT("abbreviated month name"), + _T("%month%"), TranslateT("full month name"), + _T("%yy%"), TranslateT("year without century, 01-99"), + _T("%yyyy%"), TranslateT("year with century, 1901-9999"), + _T("%wday%"), TranslateT("abbreviated weekday name"), + _T("%weekday%"), TranslateT("full weekday name")); + hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), tszTooltipText, TranslateT("Variables")); } if (hPathTip) SetTimer(hwndDlg, 0, 3000, NULL); diff --git a/plugins/UserGuide/src/main.cpp b/plugins/UserGuide/src/main.cpp index d47ffad71d..4ca983f323 100644 --- a/plugins/UserGuide/src/main.cpp +++ b/plugins/UserGuide/src/main.cpp @@ -57,12 +57,8 @@ static INT_PTR ShowGuideFile(WPARAM, LPARAM) mir_free(ptszHelpFile); } LPTSTR pszDirNameEx; - if (ServiceExists(MS_UTILS_REPLACEVARS)) { - pszDirNameEx = Utils_ReplaceVarsT(pszDirName); - mir_free(pszDirName); - } - else - pszDirNameEx = pszDirName; + pszDirNameEx = Utils_ReplaceVarsT(pszDirName); + mir_free(pszDirName); ShellExecute(NULL, _T("open"), pszFileName, NULL, pszDirNameEx, SW_SHOW); mir_free(pszFileName); diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index 16d92a3cec..0b5fe5be68 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -146,19 +146,11 @@ function ParseVarString(astr:PAnsiChar;aContact:TMCONTACT=0;extra:PAnsiChar=nil) var tfi:TFORMATINFO; tmp,pc:PAnsiChar; - dat:TREPLACEVARSDATA; begin if (astr=nil) or (astr^=#0) then exit; - if ServiceExists(MS_UTILS_REPLACEVARS)<>0 then - begin - FillChar(dat,SizeOf(TREPLACEVARSDATA),0); - dat.cbSize :=SizeOf(TREPLACEVARSDATA); - pc:=PAnsiChar(CallService(MS_UTILS_REPLACEVARS,wparam(astr),lparam(@dat))); - astr:=pc; - end - else - pc:=nil; + pc:=Utils_ReplaceVars(astr); + astr:=pc; if isVarsInstalled then begin @@ -185,20 +177,11 @@ function ParseVarString(astr:PWideChar;aContact:TMCONTACT=0;extra:PWideChar=nil) var tfi:TFORMATINFO; tmp,pc:PWideChar; - dat:TREPLACEVARSDATA; begin if (astr=nil) or (astr^=#0) then exit; - if ServiceExists(MS_UTILS_REPLACEVARS)<>0 then - begin - FillChar(dat,SizeOf(TREPLACEVARSDATA),0); - dat.cbSize :=SizeOf(TREPLACEVARSDATA); - dat.dwflags:=RVF_UNICODE; - pc:=PWideChar(CallService(MS_UTILS_REPLACEVARS,wparam(astr),lparam(@dat))); - astr:=pc; - end - else - pc:=nil; + pc:=Utils_ReplaceVarsW(astr); + astr:=pc; if isVarsInstalled then begin diff --git a/plugins/Variables/src/parse_system.cpp b/plugins/Variables/src/parse_system.cpp index 5b63678750..0f13c1f926 100644 --- a/plugins/Variables/src/parse_system.cpp +++ b/plugins/Variables/src/parse_system.cpp @@ -894,12 +894,8 @@ void registerSystemTokens() registerIntToken(TXTFILE, parseTextFile, TRF_FUNCTION, LPGEN("System Functions")"\t(x,y)\t"LPGEN("y > 0: line number y from file x, y = 0: the whole file, y < 0: line y counted from the end, y = r: random line")); registerIntToken(UPTIME, parseUpTime, TRF_FIELD, LPGEN("System Functions")"\t"LPGEN("uptime in seconds")); - if (!ServiceExists(MS_UTILS_REPLACEVARS)) - registerIntToken(ENVIRONMENTVARIABLE, parseEnvironmentVariable, TRF_FUNCTION, LPGEN("Miranda Core OS")"\t(%xxxxxxx%)\t"LPGEN("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)")); - else { - registerIntToken(ENVIRONMENTVARIABLE, parseEnvironmentVariable, TRF_FUNCTION, LPGEN("System Functions")"\t(x)\t"LPGEN("expand environment variable x")); - registerIntToken(USERNAME, parseUserName, TRF_FIELD, LPGEN("System Functions")"\t"LPGEN("user name")); - } + registerIntToken(ENVIRONMENTVARIABLE, parseEnvironmentVariable, TRF_FUNCTION, LPGEN("System Functions")"\t(x)\t"LPGEN("expand environment variable x")); + registerIntToken(USERNAME, parseUserName, TRF_FIELD, LPGEN("System Functions")"\t"LPGEN("user name")); srand((unsigned int)GetTickCount()); diff --git a/plugins/mRadio/rglobal.pas b/plugins/mRadio/rglobal.pas index 07f3978dda..a6bccaa98f 100644 --- a/plugins/mRadio/rglobal.pas +++ b/plugins/mRadio/rglobal.pas @@ -226,15 +226,11 @@ end; function GetDefaultRecPath:pWideChar; var - dat:TREPLACEVARSDATA; mstr,szData:pWideChar; buf:array [0..MAX_PATH-1] of WideChar; begin - FillChar(dat,SizeOf(dat),0); - dat.cbSize :=SizeOf(TREPLACEVARSDATA); - dat.dwFlags:=RVF_UNICODE; szData:='%miranda_userdata%'+'\'+cPluginName; - mstr:=pWideChar(CallService(MS_UTILS_REPLACEVARS, WPARAM(szData), LPARAM(@dat))); + mstr:=Utils_ReplaceVarsW(szData); PathToRelativeW(mstr,buf); StrDupW(result,buf); mir_free(mstr); diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index 0b7cd4325b..591cf78834 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -102,20 +102,15 @@ int BrowseForFolder(HWND hwnd, TCHAR *szPath) static REPLACEVARSARRAY sttVarsToReplace[] = { - { (TCHAR*)"///", (TCHAR*)"//" }, - { (TCHAR*)"//", (TCHAR*)"/" }, - { (TCHAR*)"()", (TCHAR*)"" }, + { "///", "//" }, + { "//", "/" }, + { "()", "" }, { NULL, NULL } }; static void patchDir(TCHAR *str, size_t strSize) { - REPLACEVARSDATA dat = { 0 }; - dat.cbSize = sizeof(dat); - dat.dwFlags = RVF_TCHAR; - dat.variables = sttVarsToReplace; - - TCHAR *result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)str, (LPARAM)&dat); + TCHAR *result = Utils_ReplaceVarsT(str, 0, sttVarsToReplace); if (result) { _tcsncpy(str, result, strSize); mir_free(result); @@ -139,29 +134,24 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO if (hContact) { hContact = db_mc_tryMeta(hContact); - REPLACEVARSDATA dat = { 0 }; REPLACEVARSARRAY rvaVarsToReplace[4]; - rvaVarsToReplace[0].lptzKey = _T("nick"); - rvaVarsToReplace[0].lptzValue = mir_tstrdup((TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)); - rvaVarsToReplace[1].lptzKey = _T("userid"); - rvaVarsToReplace[1].lptzValue = GetContactID(hContact); - rvaVarsToReplace[2].lptzKey = _T("proto"); - rvaVarsToReplace[2].lptzValue = mir_a2t(GetContactProto(hContact)); - rvaVarsToReplace[3].lptzKey = NULL; - rvaVarsToReplace[3].lptzValue = NULL; + rvaVarsToReplace[0].key.t = _T("nick"); + rvaVarsToReplace[0].value.t = mir_tstrdup((TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)); + rvaVarsToReplace[1].key.t = _T("userid"); + rvaVarsToReplace[1].value.t = GetContactID(hContact); + rvaVarsToReplace[2].key.t = _T("proto"); + rvaVarsToReplace[2].value.t = mir_a2t(GetContactProto(hContact)); + rvaVarsToReplace[3].key.t = NULL; + rvaVarsToReplace[3].value.t = NULL; for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++) - RemoveInvalidFilenameChars(rvaVarsToReplace[i].lptzValue); + RemoveInvalidFilenameChars(rvaVarsToReplace[i].value.t); - dat.cbSize = sizeof(dat); - dat.dwFlags = RVF_TCHAR; - dat.variables = rvaVarsToReplace; - dat.hContact = hContact; - TCHAR *result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)tszTemp, (LPARAM)&dat); + TCHAR *result = Utils_ReplaceVarsT(tszTemp, hContact, rvaVarsToReplace); if (result) { _tcsncpy(tszTemp, result, _countof(tszTemp)); mir_free(result); for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++) - mir_free(rvaVarsToReplace[i].lptzValue); + mir_free(rvaVarsToReplace[i].value.t); } } diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index fd72ed1ea1..6d2c7f0a66 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -707,38 +707,38 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) if (si->pszLogFileName[0] == 0) { REPLACEVARSARRAY rva[11]; - rva[0].lptzKey = _T("d"); - rva[0].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%#d"), tTime)); + rva[0].key.t = _T("d"); + rva[0].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%#d"), tTime)); // day 01-31 - rva[1].lptzKey = _T("dd"); - rva[1].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%d"), tTime)); + rva[1].key.t = _T("dd"); + rva[1].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%d"), tTime)); // month 1-12 - rva[2].lptzKey = _T("m"); - rva[2].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%#m"), tTime)); + rva[2].key.t = _T("m"); + rva[2].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%#m"), tTime)); // month 01-12 - rva[3].lptzKey = _T("mm"); - rva[3].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%m"), tTime)); + rva[3].key.t = _T("mm"); + rva[3].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%m"), tTime)); // month text short - rva[4].lptzKey = _T("mon"); - rva[4].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%b"), tTime)); + rva[4].key.t = _T("mon"); + rva[4].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%b"), tTime)); // month text - rva[5].lptzKey = _T("month"); - rva[5].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%B"), tTime)); + rva[5].key.t = _T("month"); + rva[5].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%B"), tTime)); // year 01-99 - rva[6].lptzKey = _T("yy"); - rva[6].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%y"), tTime)); + rva[6].key.t = _T("yy"); + rva[6].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%y"), tTime)); // year 1901-9999 - rva[7].lptzKey = _T("yyyy"); - rva[7].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%Y"), tTime)); + rva[7].key.t = _T("yyyy"); + rva[7].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%Y"), tTime)); // weekday short - rva[8].lptzKey = _T("wday"); - rva[8].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%a"), tTime)); + rva[8].key.t = _T("wday"); + rva[8].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%a"), tTime)); // weekday - rva[9].lptzKey = _T("weekday"); - rva[9].lptzValue = mir_tstrdup(ci.MakeTimeStamp(_T("%A"), tTime)); + rva[9].key.t = _T("weekday"); + rva[9].value.t = mir_tstrdup(ci.MakeTimeStamp(_T("%A"), tTime)); // end of array - rva[10].lptzKey = NULL; - rva[10].lptzValue = NULL; + rva[10].key.t = NULL; + rva[10].value.t = NULL; TCHAR tszTemp[MAX_PATH], *ptszVarPath; if (g_Settings->pszLogDir[mir_tstrlen(g_Settings->pszLogDir) - 1] == '\\') { @@ -747,11 +747,7 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) } else ptszVarPath = g_Settings->pszLogDir; - REPLACEVARSDATA dat = { sizeof(dat) }; - dat.dwFlags = RVF_TCHAR; - dat.hContact = si->hContact; - dat.variables = rva; - TCHAR *tszParsedName = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)ptszVarPath, (LPARAM)&dat); + TCHAR *tszParsedName = Utils_ReplaceVarsT(ptszVarPath, si->hContact, rva); if (ci.OnGetLogName) ci.OnGetLogName(si, tszParsedName); else @@ -759,7 +755,7 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) mir_free(tszParsedName); for (int i = 0; i < _countof(rva); i++) - mir_free(rva[i].lptzValue); + mir_free(rva[i].value.t); for (TCHAR *p = si->pszLogFileName + 2; *p; ++p) if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || *p == '<' || *p == '>' || *p == '|') diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 705b522454..0668cf9561 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -198,3 +198,5 @@ xmlToFile @195 xmlToString @196 xmlToStringWithFormatting @197 KillModuleMenus @198 +Utils_ReplaceVars @199 +Utils_ReplaceVarsW @200 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 414562cd74..69d189d5f2 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -198,3 +198,5 @@ xmlToFile @195 xmlToString @196 xmlToStringWithFormatting @197 KillModuleMenus @198 +Utils_ReplaceVars @199 +Utils_ReplaceVarsW @200 diff --git a/src/mir_app/src/path.cpp b/src/mir_app/src/path.cpp index ce9e92e4c8..058d9b4284 100644 --- a/src/mir_app/src/path.cpp +++ b/src/mir_app/src/path.cpp @@ -74,16 +74,16 @@ static __forceinline int _xcsncmp(const char *s1, const char *s2, size_t n) { re static __forceinline size_t _xcslen(const char *s1) { return strlen(s1); } static __forceinline char *_xcscpy(char *s1, const char *s2) { return strcpy(s1, s2); } static __forceinline char *_xcsncpy(char *s1, const char *s2, size_t n) { return strncpy(s1, s2, n); } -static __forceinline char *_xstrselect(char *, char *s1, TCHAR*) { return s1; } -static __forceinline char *_itox(char *, int a) { return itoa(a, (char *)mir_alloc(sizeof(char)*20), 10); } -static __forceinline char *mir_a2x(char *, char *s) { return mir_strdup(s); } +static __forceinline const char *_xstrselect(const char*, const char *s1, TCHAR*) { return s1; } +static __forceinline char *_itox(char*, int a) { return itoa(a, (char *)mir_alloc(sizeof(char)*20), 10); } +static __forceinline char *mir_a2x(const char*, const char *s) { return mir_strdup(s); } -static __forceinline char *GetContactNickX(char *, MCONTACT hContact) +static __forceinline char *GetContactNickX(const char*, MCONTACT hContact) { return mir_strdup((char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, 0)); } -static __forceinline char *GetContactIDX(char *, MCONTACT hContact) +static __forceinline char *GetContactIDX(const char*, MCONTACT hContact) { TCHAR *id = GetContactID(hContact); char* res = mir_t2a(id); @@ -91,7 +91,7 @@ static __forceinline char *GetContactIDX(char *, MCONTACT hContact) return res; } -static __forceinline char *GetEnvironmentVariableX(char *variable) +static __forceinline char *GetEnvironmentVariableX(const char *variable) { char result[512]; if (GetEnvironmentVariableA(variable, result, _countof(result))) @@ -99,7 +99,7 @@ static __forceinline char *GetEnvironmentVariableX(char *variable) return NULL; } -static __forceinline char *GetProfileDirX(char*) +static __forceinline char *GetProfileDirX(const char*) { return mir_t2a(g_profileDir); } @@ -112,7 +112,7 @@ static __forceinline char *SHGetSpecialFolderPathX(int iCSIDL, char*) return NULL; } -static __forceinline char *GetModulePathX(char *, HMODULE hModule) +static __forceinline char *GetModulePathX(const char*, HMODULE hModule) { char result[MAX_PATH]; GetModuleFileNameA(hModule, result, sizeof(result)); @@ -121,7 +121,7 @@ static __forceinline char *GetModulePathX(char *, HMODULE hModule) return mir_strdup(result); } -static __forceinline char *GetUserNameX(char *) +static __forceinline char *GetUserNameX(const char*) { char result[128]; DWORD size = _countof(result); @@ -130,12 +130,12 @@ static __forceinline char *GetUserNameX(char *) return NULL; } -static __forceinline char *GetProfileNameX(char *) +static __forceinline char *GetProfileNameX(const char*) { return mir_t2a(g_shortProfileName); } -static __forceinline char *GetPathVarX(char *, int code) +static __forceinline char* GetPathVarX(const char*, int code) { TCHAR szFullPath[MAX_PATH]; @@ -159,23 +159,23 @@ static __forceinline char *GetPathVarX(char *, int code) static __forceinline int _xcscmp(const TCHAR *s1, const TCHAR *s2) { return _tcscmp(s1, s2); } static __forceinline int _xcsncmp(const TCHAR *s1, const TCHAR *s2, size_t n) { return _tcsncmp(s1, s2, n); } static __forceinline size_t _xcslen(const TCHAR *s1) { return _tcslen(s1); } -static __forceinline TCHAR *_xcscpy(TCHAR *s1, const TCHAR *s2) { return _tcscpy(s1, s2); } -static __forceinline TCHAR *_xcsncpy(TCHAR *s1, const TCHAR *s2, size_t n) { return _tcsncpy(s1, s2, n); } -static __forceinline TCHAR *_xstrselect(TCHAR*, char*, TCHAR *s2) { return s2; } -static __forceinline TCHAR *_itox(TCHAR *, int a) { return _itot(a, (TCHAR *)mir_alloc(sizeof(TCHAR)*20), 10); } -static __forceinline TCHAR *mir_a2x(TCHAR *, char *s) { return mir_a2t(s); } +static __forceinline TCHAR* _xcscpy(TCHAR *s1, const TCHAR *s2) { return _tcscpy(s1, s2); } +static __forceinline TCHAR* _xcsncpy(TCHAR *s1, const TCHAR *s2, size_t n) { return _tcsncpy(s1, s2, n); } +static __forceinline const TCHAR* _xstrselect(const TCHAR*, const char*, const TCHAR *s2) { return s2; } +static __forceinline TCHAR* _itox(TCHAR *, int a) { return _itot(a, (TCHAR *)mir_alloc(sizeof(TCHAR)*20), 10); } +static __forceinline TCHAR* mir_a2x(const TCHAR *, const char *s) { return mir_a2t(s); } -static __forceinline TCHAR *GetContactNickX(TCHAR *, MCONTACT hContact) +static __forceinline TCHAR* GetContactNickX(const TCHAR*, MCONTACT hContact) { - return mir_tstrdup((TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)); + return mir_tstrdup((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)); } -static __forceinline TCHAR *GetContactIDX(TCHAR *, MCONTACT hContact) +static __forceinline TCHAR* GetContactIDX(const TCHAR*, MCONTACT hContact) { return GetContactID(hContact); } -static __forceinline TCHAR *GetEnvironmentVariableX(TCHAR *variable) +static __forceinline TCHAR* GetEnvironmentVariableX(const TCHAR *variable) { TCHAR result[512]; if (GetEnvironmentVariable(variable, result, _countof(result))) @@ -183,7 +183,7 @@ static __forceinline TCHAR *GetEnvironmentVariableX(TCHAR *variable) return NULL; } -static __forceinline TCHAR *SHGetSpecialFolderPathX(int iCSIDL, TCHAR*) +static __forceinline TCHAR* SHGetSpecialFolderPathX(int iCSIDL, TCHAR*) { TCHAR result[512]; if (SHGetSpecialFolderPath(NULL, result, iCSIDL, FALSE)) @@ -191,12 +191,12 @@ static __forceinline TCHAR *SHGetSpecialFolderPathX(int iCSIDL, TCHAR*) return NULL; } -static __forceinline TCHAR *GetProfileDirX(TCHAR*) +static __forceinline TCHAR* GetProfileDirX(const TCHAR*) { return mir_tstrdup(g_profileDir); } -static __forceinline TCHAR *GetModulePathX(TCHAR *, HMODULE hModule) +static __forceinline TCHAR* GetModulePathX(const TCHAR*, HMODULE hModule) { TCHAR result[MAX_PATH]; GetModuleFileName(hModule, result, _countof(result)); @@ -205,7 +205,7 @@ static __forceinline TCHAR *GetModulePathX(TCHAR *, HMODULE hModule) return mir_tstrdup(result); } -static __forceinline TCHAR *GetUserNameX(TCHAR *) +static __forceinline TCHAR* GetUserNameX(const TCHAR*) { TCHAR result[128]; DWORD size = _countof(result); @@ -214,12 +214,12 @@ static __forceinline TCHAR *GetUserNameX(TCHAR *) return NULL; } -static __forceinline TCHAR *GetProfileNameX(TCHAR *) +static __forceinline TCHAR* GetProfileNameX(const TCHAR*) { return mir_tstrdup(g_shortProfileName); } -static __forceinline TCHAR *GetPathVarX(TCHAR *, int code) +static __forceinline TCHAR* GetPathVarX(const TCHAR*, int code) { TCHAR szFullPath[MAX_PATH]; @@ -241,7 +241,7 @@ static __forceinline TCHAR *GetPathVarX(TCHAR *, int code) } template -XCHAR *GetInternalVariable(XCHAR *key, size_t keyLength, MCONTACT hContact) +XCHAR *GetInternalVariable(const XCHAR *key, size_t keyLength, MCONTACT hContact) { XCHAR *theValue = NULL; XCHAR *theKey = (XCHAR *)_alloca(sizeof(XCHAR) * (keyLength + 1)); @@ -292,25 +292,24 @@ XCHAR *GetInternalVariable(XCHAR *key, size_t keyLength, MCONTACT hContact) } template -XCHAR *GetVariableFromArray(REPLACEVARSARRAY *vars, XCHAR *key, size_t keyLength, MCONTACT hContact, bool *bFree) +XCHAR *GetVariableFromArray(REPLACEVARSARRAY *vars, const XCHAR *key, size_t keyLength, MCONTACT hContact, bool *bFree) { *bFree = false; - for (REPLACEVARSARRAY *var = vars; var && var->lptzKey; ++var) - if ((_xcslen((XCHAR *)var->lptzKey) == keyLength) && !_xcsncmp(key, (XCHAR *)var->lptzKey, keyLength)) - return (XCHAR *)var->lptzValue; + for (REPLACEVARSARRAY *var = vars; var && var->key.a; ++var) + if ((_xcslen((XCHAR *)var->key.a) == keyLength) && !_xcsncmp(key, (XCHAR *)var->key.a, keyLength)) + return (XCHAR *)var->value.a; *bFree = true; return GetInternalVariable(key, keyLength, hContact); } template -XCHAR *ReplaceVariables(XCHAR *str, REPLACEVARSDATA *data) +XCHAR *ReplaceVariables(const XCHAR *str, MCONTACT hContact, REPLACEVARSARRAY *variables) { if (!str) return NULL; - XCHAR *p; - XCHAR *varStart = 0; + const XCHAR *varStart = 0, *p; size_t length = 0; bool bFree; @@ -319,7 +318,7 @@ XCHAR *ReplaceVariables(XCHAR *str, REPLACEVARSDATA *data) if (varStart) { if (p == varStart) length++; - else if (XCHAR *value = GetVariableFromArray(data->variables, varStart, p-varStart, data->hContact, &bFree)) { + else if (XCHAR *value = GetVariableFromArray(variables, varStart, p-varStart, hContact, &bFree)) { length += _xcslen(value); if (bFree) mir_free(value); } @@ -345,7 +344,7 @@ XCHAR *ReplaceVariables(XCHAR *str, REPLACEVARSDATA *data) if (varStart) { if (p == varStart) *q++='%'; - else if (XCHAR *value = GetVariableFromArray(data->variables, varStart, p-varStart, data->hContact, &bFree)) { + else if (XCHAR *value = GetVariableFromArray(variables, varStart, p-varStart, hContact, &bFree)) { _xcscpy(q, value); q += _xcslen(value); if (bFree) mir_free(value); @@ -374,19 +373,14 @@ XCHAR *ReplaceVariables(XCHAR *str, REPLACEVARSDATA *data) return result; } -static INT_PTR replaceVars(WPARAM wParam, LPARAM lParam) +MIR_APP_DLL(char*) Utils_ReplaceVars(const char *szData, MCONTACT hContact, REPLACEVARSARRAY *vars) { - REPLACEVARSDATA *data = (REPLACEVARSDATA *)lParam; - if (data->dwFlags & RVF_UNICODE) - return (INT_PTR)ReplaceVariables((WCHAR *)wParam, data); - - return (INT_PTR)ReplaceVariables((char *)wParam, data); + return ReplaceVariables(szData, hContact, vars); } -int InitPathUtils(void) +MIR_APP_DLL(wchar_t*) Utils_ReplaceVarsW(const wchar_t *wszData, MCONTACT hContact, REPLACEVARSARRAY *vars) { - CreateServiceFunction(MS_UTILS_REPLACEVARS, replaceVars); - return 0; + return ReplaceVariables(wszData, hContact, vars); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp index f62f41f574..666fcf5be5 100644 --- a/src/mir_app/src/utils.cpp +++ b/src/mir_app/src/utils.cpp @@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR ResizeDialog(WPARAM wParam, LPARAM lParam); -int InitPathUtils(void); - int InitCrypt(void); void UninitCrypt(void); @@ -329,7 +327,6 @@ int LoadUtilsModule(void) CreateServiceFunction(MS_UTILS_ENTERSTRING, svcEnterString); - InitPathUtils(); InitCrypt(); return 0; } -- cgit v1.2.3