diff options
Diffstat (limited to 'plugins')
23 files changed, 626 insertions, 712 deletions
diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp index 486132ee28..01b2d15ea0 100644 --- a/plugins/BossKeyPlus/src/BossKey.cpp +++ b/plugins/BossKeyPlus/src/BossKey.cpp @@ -662,8 +662,8 @@ static int MirandaLoaded(WPARAM, LPARAM) tr.memType = TR_MEM_OWNER;
tr.flags = TRF_FIELD | TRF_TCHAR | TRF_PARSEFUNC;
- tr.tszTokenString = L"bosskeyname";
- tr.parseFunctionT = VariablesBossKey;
+ tr.szTokenString.w = L"bosskeyname";
+ tr.parseFunctionW = VariablesBossKey;
tr.szHelpText = LPGEN("BossKey") "\t" LPGEN("get the BossKey name");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
}
diff --git a/plugins/ExternalAPI/m_variables.h b/plugins/ExternalAPI/m_variables.h index 0e015f7ce6..3a7605c118 100644 --- a/plugins/ExternalAPI/m_variables.h +++ b/plugins/ExternalAPI/m_variables.h @@ -1,39 +1,35 @@ /*
- Variables Plugin for Miranda-IM (www.miranda-im.org)
- Copyright 2003-2006 P. Boon
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Variables Plugin for Miranda-IM (www.miranda-im.org)
+ Copyright 2003-2006 P. Boon
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __M_VARS
#define __M_VARS
-#if !defined(_TCHAR_DEFINED)
- #include <tchar.h>
-#endif
-
#if !defined(M_CORE_H__)
- #include <m_core.h>
+#include <m_core.h>
#endif
#ifndef VARIABLES_NOHELPER
- #include <m_button.h>
+#include <m_button.h>
#endif
#ifndef _countof
- #include <win2k.h>
+#include <win2k.h>
#endif
// --------------------------------------------------------------------------
@@ -61,48 +57,27 @@ // Note: The returned pointer needs to be freed using mir_free().
-typedef struct {
- int cbSize; // Set this to sizeof(FORMATINFO).
- int flags; // Flags to use (see FIF_* below).
- union {
- char *szFormat; // Text in which the tokens will be replaced (can't be
- // NULL).
- WCHAR *wszFormat;
- TCHAR *tszFormat;
- };
- union {
- char *szExtraText; // Extra, context-specific string (can be NULL) ->
- // The field "extratext" will be replaced by this
- // string. (Previously szSource).
- WCHAR *wszExtraText;
- TCHAR *tszExtraText;
- };
- MCONTACT hContact; // Handle to contact (can be NULL) -> The field "subject"
- // represents this contact.
- int pCount; // (output) Number of succesful parsed tokens, needs to be set
- // to 0 before the call
- int eCount; // (output) Number of failed tokens, needs to be set to 0
- // before the call
- union {
- char **szaTemporaryVars; // Temporary variables valid only in the duration of the format call
- TCHAR **tszaTemporaryVars; // By pos: [i] is var name, [i + 1] is var value
- WCHAR **wszaTemporaryVars;
- };
- int cbTemporaryVarsSize; // Number of elements in szaTemporaryVars array
-
-} FORMATINFO;
-
-#define FORMATINFOV2_SIZE (sizeof(int)*4+sizeof(void*)*2 + sizeof(HANDLE))
+struct FORMATINFO
+{
+ int cbSize; // Set this to sizeof(FORMATINFO).
+ int flags; // Flags to use (see FIF_* below).
+ MAllStrings szFormat; // Text in which the tokens will be replaced (can't be NULL).
+ MAllStrings szExtraText; // Extra, context-specific string (can be NULL) ->
+ // The field "extratext" will be replaced by this
+ // string. (Previously szSource).
+ MCONTACT hContact; // Handle to contact (can be NULL) -> The field "subject"
+ // represents this contact.
+ int pCount; // (output) Number of succesful parsed tokens, needs to be set
+ // to 0 before the call
+ int eCount; // (output) Number of failed tokens, needs to be set to 0
+ // before the call
+ MAllStringArray szTemporaryVars; // Temporary variables valid only in the duration of the format call
+ int cbTemporaryVarsSize; // Number of elements in szaTemporaryVars array
+};
// Possible flags:
#define FIF_UNICODE 0x01 // Expects and returns unicode text (WCHAR*).
-#if defined(UNICODE) || defined(_UNICODE)
-#define FIF_TCHAR FIF_UNICODE // Strings in structure are TCHAR*.
-#else
-#define FIF_TCHAR 0
-#endif
-
// Helper functions for easy using:
// Helper #1: variables_parse
@@ -110,31 +85,29 @@ typedef struct { // The returned string needs to be freed using mir_free.
#ifndef VARIABLES_NOHELPER
-__inline static TCHAR *variables_parse(TCHAR *tszFormat, TCHAR *tszExtraText, MCONTACT hContact)
+__inline static wchar_t *variables_parse(wchar_t *tszFormat, wchar_t *tszExtraText, MCONTACT hContact)
{
FORMATINFO fi = { sizeof(fi) };
- fi.tszFormat = tszFormat;
- fi.tszExtraText = tszExtraText;
+ fi.szFormat.w = tszFormat;
+ fi.szExtraText.w = tszExtraText;
fi.hContact = hContact;
- fi.flags = FIF_TCHAR;
- return (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ fi.flags = FIF_UNICODE;
+ return (wchar_t *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
}
#endif
-__inline static TCHAR *variables_parse_ex(TCHAR *tszFormat, TCHAR *tszExtraText, MCONTACT hContact,
- TCHAR **tszaTemporaryVars, int cbTemporaryVarsSize) {
-
- FORMATINFO fi = { 0 };
-
- ZeroMemory(&fi, sizeof(fi));
+__inline static wchar_t *variables_parse_ex(wchar_t *tszFormat, wchar_t *tszExtraText, MCONTACT hContact,
+ wchar_t **tszaTemporaryVars, int cbTemporaryVarsSize)
+{
+ FORMATINFO fi = {};
fi.cbSize = sizeof(fi);
- fi.tszFormat = tszFormat;
- fi.tszExtraText = tszExtraText;
+ fi.szFormat.w = tszFormat;
+ fi.szExtraText.w = tszExtraText;
fi.hContact = hContact;
- fi.flags = FIF_TCHAR;
- fi.tszaTemporaryVars = tszaTemporaryVars;
+ fi.flags = FIF_UNICODE;
+ fi.szTemporaryVars.w = tszaTemporaryVars;
fi.cbTemporaryVarsSize = cbTemporaryVarsSize;
- return (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ return (wchar_t *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
}
// Helper #2: variables_parsedup
@@ -145,33 +118,33 @@ __inline static TCHAR *variables_parse_ex(TCHAR *tszFormat, TCHAR *tszExtraText, // Note: The returned pointer needs to be released using your own free().
#ifndef VARIABLES_NOHELPER
-__inline static TCHAR *variables_parsedup(TCHAR *tszFormat, TCHAR *tszExtraText, MCONTACT hContact)
+__inline static wchar_t *variables_parsedup(wchar_t *tszFormat, wchar_t *tszExtraText, MCONTACT hContact)
{
if (ServiceExists(MS_VARS_FORMATSTRING)) {
FORMATINFO fi = { sizeof(fi) };
- fi.tszFormat = tszFormat;
- fi.tszExtraText = tszExtraText;
+ fi.szFormat.w = tszFormat;
+ fi.szExtraText.w = tszExtraText;
fi.hContact = hContact;
- fi.flags |= FIF_TCHAR;
- TCHAR *tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ fi.flags |= FIF_UNICODE;
+ wchar_t *tszParsed = (wchar_t *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
if (tszParsed)
return tszParsed;
}
return tszFormat ? mir_wstrdup(tszFormat) : tszFormat;
}
-__inline static TCHAR *variables_parsedup_ex(TCHAR *tszFormat, TCHAR *tszExtraText, MCONTACT hContact,
- TCHAR **tszaTemporaryVars, int cbTemporaryVarsSize)
+__inline static wchar_t *variables_parsedup_ex(wchar_t *tszFormat, wchar_t *tszExtraText, MCONTACT hContact,
+ wchar_t **tszaTemporaryVars, int cbTemporaryVarsSize)
{
if (ServiceExists(MS_VARS_FORMATSTRING)) {
FORMATINFO fi = { sizeof(fi) };
- fi.tszFormat = tszFormat;
- fi.tszExtraText = tszExtraText;
+ fi.szFormat.w = tszFormat;
+ fi.szExtraText.w = tszExtraText;
fi.hContact = hContact;
- fi.flags |= FIF_TCHAR;
- fi.tszaTemporaryVars = tszaTemporaryVars;
+ fi.flags |= FIF_UNICODE;
+ fi.szTemporaryVars.w = tszaTemporaryVars;
fi.cbTemporaryVarsSize = cbTemporaryVarsSize;
- TCHAR *tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ wchar_t *tszParsed = (wchar_t *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
if (tszParsed)
return tszParsed;
}
@@ -179,8 +152,6 @@ __inline static TCHAR *variables_parsedup_ex(TCHAR *tszFormat, TCHAR *tszExtraTe }
#endif
-
-
// --------------------------------------------------------------------------
// Register tokens
// --------------------------------------------------------------------------
@@ -205,131 +176,119 @@ __inline static TCHAR *variables_parsedup_ex(TCHAR *tszFormat, TCHAR *tszExtraTe // 'overwritten' if registered twice.
// Needed for szService and parseFunction:
-typedef struct {
- int cbSize; // You need to check if this is >=sizeof(ARGUMENTSINFO)
- // (already filled in).
- FORMATINFO *fi; // Arguments passed to MS_VARS_FORMATSTRING.
- unsigned int argc; // Number of elements in the argv array.
- union {
- char **argv; // Argv[0] will be the token name, the following elements
- // are the additional arguments.
- WCHAR **wargv; // If the registered token was registered as a unicode
- // token, wargv should be accessed.
- TCHAR **targv;
- };
- int flags; // (output) You can set flags here (initially 0), use the
- // AIF_* flags (see below).
-} ARGUMENTSINFO;
+
+struct ARGUMENTSINFO
+{
+ int cbSize; // You need to check if this is >=sizeof(ARGUMENTSINFO)
+ // (already filled in).
+ FORMATINFO *fi; // Arguments passed to MS_VARS_FORMATSTRING.
+ unsigned int argc; // Number of elements in the argv array.
+ MAllStringArray argv; // Argv[0] will be the token name, the following elements
+ // are the additional arguments.
+
+ int flags; // (output) You can set flags here (initially 0), use the
+ // AIF_* flags (see below).
+};
// Available flags for ARGUMENTSINFO:
// Set the flags of the ARGUMENTSINFO struct to any of these to influence
// further parsing.
#define AIF_DONTPARSE 0x01 // Don't parse the result of this function,
- // usually the result of a token is parsed
- // again, if the `?` is used as a function
- // character.
+ // usually the result of a token is parsed
+ // again, if the `?` is used as a function
+ // character.
#define AIF_FALSE 0x02 // The function returned logical false.
// Definition of parse/cleanup functions:
typedef char* (*VARPARSEFUNCA)(ARGUMENTSINFO *ai);
typedef WCHAR* (*VARPARSEFUNCW)(ARGUMENTSINFO *ai);
+
typedef void (*VARCLEANUPFUNCA)(char *szReturn);
typedef void (*VARCLEANUPFUNCW)(WCHAR *wszReturn);
-#if defined(UNICODE) || defined(_UNICODE)
-#define VARPARSEFUNC VARPARSEFUNCW
-#define VARCLEANUPFUNC VARCLEANUPFUNCW
-#else
-#define VARPARSEFUNC VARPARSEFUNCA
-#define VARCLEANUPFUNC VARCLEANUPFUNCA
-#endif
-
-typedef struct {
- int cbSize; // Set this to sizeof(TOKENREGISTER).
- union {
- char *szTokenString; // Name of the new token to be created, without %,
- // ?, ! etc. signs (can't be NULL).
- WCHAR *wszTokenString;
- TCHAR *tszTokenString;
- };
- union {
- char *szService; // Name of a service that is used to request the
- // token's value, if no service is used, a function
- // and TRF_PARSEFUNC must be used.
- VARPARSEFUNCA parseFunction; // See above, use with TRF_PARSEFUNC.
- VARPARSEFUNCW parseFunctionW;
- VARPARSEFUNC parseFunctionT;
- };
- union {
- char *szCleanupService; // Name of a service to be called when the
- // memory allocated in szService can be freed
- // (only used when flag VRF_CLEANUP is set,
- // else set this to NULL).
- VARCLEANUPFUNCA cleanupFunction; // See above, use with TRF_CLEANUPFUNC.
- VARCLEANUPFUNCW cleanupFunctionW;
- VARCLEANUPFUNC cleanupFunctionT;
- };
- char *szHelpText; // Help info shown in help dialog (can be NULL). Has to
- // be in the following format:
- // "subject\targuments\tdescription"
- // (Example: "math\t(x, y ,...)\tx + y + ..."), or:
- // "subject\tdescription"
- // (Example: "miranda\tPath to the Miranda-IM
- // executable").
- // Note: subject and description are translated by
- // Variables.
- int memType; // Describes which method Varibale's plugin needs to use to
- // free the returned buffer, use one of the VR_MEM_* values
- // (see below). Only valid if the flag VRF_FREEMEM is set,
- // use TR_MEM_OWNER otherwise).
- int flags; // Flags to use (see below), one of TRF_* (see below).
-} TOKENREGISTER;
+struct TOKENREGISTER
+{
+ int cbSize; // Set this to sizeof(TOKENREGISTER).
+ MAllStrings szTokenString; // Name of the new token to be created, without %, ?, ! etc. signs (can't be NULL).
+
+ union
+ {
+ char *szService; // Name of a service that is used to request the
+ // token's value, if no service is used, a function
+ // and TRF_PARSEFUNC must be used.
+ VARPARSEFUNCA parseFunction; // See above, use with TRF_PARSEFUNC.
+ VARPARSEFUNCW parseFunctionW;
+ };
+ union
+ {
+ char *szCleanupService; // Name of a service to be called when the
+ // memory allocated in szService can be freed
+ // (only used when flag VRF_CLEANUP is set,
+ // else set this to NULL).
+ VARCLEANUPFUNCA cleanupFunction; // See above, use with TRF_CLEANUPFUNC.
+ VARCLEANUPFUNCW cleanupFunctionW;
+ };
+ char *szHelpText; // Help info shown in help dialog (can be NULL). Has to
+ // be in the following format:
+ // "subject\targuments\tdescription"
+ // (Example: "math\t(x, y ,...)\tx + y + ..."), or:
+ // "subject\tdescription"
+ // (Example: "miranda\tPath to the Miranda-IM
+ // executable").
+ // Note: subject and description are translated by
+ // Variables.
+ int memType; // Describes which method Varibale's plugin needs to use to
+ // free the returned buffer, use one of the VR_MEM_* values
+ // (see below). Only valid if the flag VRF_FREEMEM is set,
+ // use TR_MEM_OWNER otherwise).
+ int flags; // Flags to use (see below), one of TRF_* (see below).
+};
// Available Memory Storage Types:
// These values describe which method Variables Plugin will use to free the
// buffer returned by the parse function or service
#define TR_MEM_MIRANDA 2 // Memory is allocated using Miranda's Memory
- // Manager Interface (using the functions
- // returned by MS_SYSTEM_GET_MMI), if
- // VRF_FREEMEM is set, the memory will be
- // freed by Variables.
+ // Manager Interface (using the functions
+ // returned by MS_SYSTEM_GET_MMI), if
+ // VRF_FREEMEM is set, the memory will be
+ // freed by Variables.
#define TR_MEM_OWNER 3 // Memory is owned by the calling plugin
- // (can't be freed by Variables Plugin
- // automatically). This should be used if
- // VRF_FREEMEM is not specified in the flags.
+ // (can't be freed by Variables Plugin
+ // automatically). This should be used if
+ // VRF_FREEMEM is not specified in the flags.
// Available Flags for TOKENREGISTER:
#define TRF_FREEMEM 0x01 // Variables Plugin will automatically free the
- // pointer returned by the parse function or
- // service (which method it will us is
- // specified in memType -> see above).
+ // pointer returned by the parse function or
+ // service (which method it will us is
+ // specified in memType -> see above).
#define TRF_CLEANUP 0x02 // Call cleanup service or function, notifying
- // that the returned buffer can be freed.
- // Normally you should use either TRF_FREEMEM
- // or TRF_CLEANUP.
+ // that the returned buffer can be freed.
+ // Normally you should use either TRF_FREEMEM
+ // or TRF_CLEANUP.
#define TRF_PARSEFUNC 0x40 // parseFunction will be used instead of a
- // service.
+ // service.
#define TRF_CLEANUPFUNC 0x80 // cleanupFunction will be used instead of a
- // service.
+ // service.
#define TRF_USEFUNCS TRF_PARSEFUNC|TRF_CLEANUPFUNC
#define TRF_UNPARSEDARGS 0x04 // Provide the arguments for the parse
- // function in their raw (unparsed) form.
- // By default, arguments are parsed before
- // presenting them to the parse function.
+ // function in their raw (unparsed) form.
+ // By default, arguments are parsed before
+ // presenting them to the parse function.
#define TRF_FIELD 0x08 // The token can be used as a %field%.
#define TRF_FUNCTION 0x10 // The token can be used as a ?function().
- // Normally you should use either TRF_FIELD or
- // TRF_FUNCTION.
+ // Normally you should use either TRF_FIELD or
+ // TRF_FUNCTION.
#define TRF_UNICODE 0x20 // Strings in structure are unicode (WCHAR*).
- // In this case, the strings pointing to the
- // arguments in the ARGUMENTS struct are
- // unicode also. The returned buffer is
- // expected to be unicode also, and the
- // unicode parse and cleanup functions are
- // called.
+ // In this case, the strings pointing to the
+ // arguments in the ARGUMENTS struct are
+ // unicode also. The returned buffer is
+ // expected to be unicode also, and the
+ // unicode parse and cleanup functions are
+ // called.
#if defined(UNICODE) || defined(_UNICODE)
-#define TRF_TCHAR TRF_UNICODE // Strings in structure are TCHAR*.
+#define TRF_TCHAR TRF_UNICODE // Strings in structure are wchar_t*.
#else
#define TRF_TCHAR 0
#endif
@@ -391,52 +350,53 @@ typedef struct { // ------------------------
// Returns 0 on succes, any other value on error.
-typedef struct {
- int cbSize; // Set to sizeof(VARHELPINFO).
- FORMATINFO *fi; // Used for both input and output. If this pointer is not
- // NULL, the information is used as the initial values for
- // the dialog.
- HWND hwndCtrl; // Used for both input and output. The window text of this
- // window will be read and used as the initial input of the
- // input dialog. If the user presses the OK button the window
- // text of this window will be set to the text of the input
- // field and a EN_CHANGE message via WM_COMMAND is send to
- // this window. (Can be NULL).
- char *szSubjectDesc; // The description of the %subject% token will be set
- // to this text, if not NULL. This is translated
- // automatically.
- char *szExtraTextDesc; // The description of the %extratext% token will be
- // set to this text, if not NULL. This is translated
- // automatically.
- int flags; // Flags, see below.
-} VARHELPINFO;
+struct VARHELPINFO
+{
+ int cbSize; // Set to sizeof(VARHELPINFO).
+ FORMATINFO *fi; // Used for both input and output. If this pointer is not
+ // NULL, the information is used as the initial values for
+ // the dialog.
+ HWND hwndCtrl; // Used for both input and output. The window text of this
+ // window will be read and used as the initial input of the
+ // input dialog. If the user presses the OK button the window
+ // text of this window will be set to the text of the input
+ // field and a EN_CHANGE message via WM_COMMAND is send to
+ // this window. (Can be NULL).
+ char *szSubjectDesc; // The description of the %subject% token will be set
+ // to this text, if not NULL. This is translated
+ // automatically.
+ char *szExtraTextDesc; // The description of the %extratext% token will be
+ // set to this text, if not NULL. This is translated
+ // automatically.
+ int flags; // Flags, see below.
+};
// Flags for VARHELPINFO
#define VHF_TOKENS 0x00000001 // Create a dialog with the list of
- // tokens
+ // tokens
#define VHF_INPUT 0x00000002 // Create a dialog with an input
- // field (this contains the list of
- // tokens as well).
+ // field (this contains the list of
+ // tokens as well).
#define VHF_SUBJECT 0x00000004 // Create a dialog to select a
- // contact for the %subject% token.
+ // contact for the %subject% token.
#define VHF_EXTRATEXT 0x00000008 // Create a dialog to enter a text
- // for the %extratext% token.
+ // for the %extratext% token.
#define VHF_HELP 0x00000010 // Create a dialog with help info.
#define VHF_HIDESUBJECTTOKEN 0x00000020 // Hide the %subject% token in the
- // list of tokens.
+ // list of tokens.
#define VHF_HIDEEXTRATEXTTOKEN 0x00000040 // Hide the %extratext% token in
- // the list of tokens.
+ // the list of tokens.
#define VHF_DONTFILLSTRUCT 0x00000080 // Don't fill the struct with the
- // new information if OK is pressed
+ // new information if OK is pressed
#define VHF_FULLFILLSTRUCT 0x00000100 // Fill all members of the struct
- // when OK is pressed. By default
- // only szFormat is set. With this
- // flag on, hContact and
- // szExtraText are also set.
+ // when OK is pressed. By default
+ // only szFormat is set. With this
+ // flag on, hContact and
+ // szExtraText are also set.
#define VHF_SETLASTSUBJECT 0x00000200 // Set the last contact that was
- // used in the %subject% dialog in
- // case fi.hContact is NULL.
+ // used in the %subject% dialog in
+ // case fi.hContact is NULL.
// Predefined flags
#define VHF_FULLDLG VHF_INPUT|VHF_SUBJECT|VHF_EXTRATEXT|VHF_HELP
@@ -455,21 +415,22 @@ typedef struct { // Helper function for easy use in standard case:
#ifndef VARIABLES_NOHELPER
-__inline static int variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags, char *szSubjectDesc, char *szExtraDesc) {
+__inline static int variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags, char *szSubjectDesc, char *szExtraDesc)
+{
- VARHELPINFO vhi;
+ VARHELPINFO vhi;
- ZeroMemory(&vhi, sizeof(VARHELPINFO));
- vhi.cbSize = sizeof(VARHELPINFO);
- if (flags == 0) {
- flags = VHF_SIMPLEDLG;
- }
- vhi.flags = flags;
- vhi.hwndCtrl = GetDlgItem(hwndDlg, uIDEdit);
- vhi.szSubjectDesc = szSubjectDesc;
- vhi.szExtraTextDesc = szExtraDesc;
+ ZeroMemory(&vhi, sizeof(VARHELPINFO));
+ vhi.cbSize = sizeof(VARHELPINFO);
+ if (flags == 0) {
+ flags = VHF_SIMPLEDLG;
+ }
+ vhi.flags = flags;
+ vhi.hwndCtrl = GetDlgItem(hwndDlg, uIDEdit);
+ vhi.szSubjectDesc = szSubjectDesc;
+ vhi.szExtraTextDesc = szExtraDesc;
- return CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwndDlg, (LPARAM)&vhi);
+ return CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwndDlg, (LPARAM)&vhi);
}
#endif
@@ -492,12 +453,12 @@ __inline static int variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags, ch // VSI_ constants
#define VSI_HELPICON 1 // Can be used on the button accessing the
- // Variables help dialog. Returns (HICON)hIcon on
- // success or NULL on failure;
+ // Variables help dialog. Returns (HICON)hIcon on
+ // success or NULL on failure;
#define VSI_HELPTIPTEXT 2 // Returns the tooltip text you can use for the
- // help button. Returns (char *)szTipText, a
- // static, translated buffer containing the help
- // text or NULL on error.
+ // help button. Returns (char *)szTipText, a
+ // static, translated buffer containing the help
+ // text or NULL on error.
// Helper to set the icon on a button accessing the help dialog.
// Preferably a 16x14 MButtonClass control, but it works on a standard
@@ -505,9 +466,10 @@ __inline static int variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags, ch // Variables) the string "V" is shown on the button. If Variables is not
// available, the button will be hidden.
#ifndef VARIABLES_NOHELPER
-__inline static int variables_skin_helpbutton(HWND hwndDlg, UINT uIDButton) {
+__inline static int variables_skin_helpbutton(HWND hwndDlg, UINT uIDButton)
+{
- TCHAR tszClass[32];
+ wchar_t tszClass[32];
HICON hIcon = nullptr;
int res = 0;
@@ -517,7 +479,7 @@ __inline static int variables_skin_helpbutton(HWND hwndDlg, UINT uIDButton) { GetClassName(GetDlgItem(hwndDlg, uIDButton), tszClass, _countof(tszClass));
if (!mir_wstrcmp(tszClass, L"Button")) {
if (hIcon != nullptr) {
- SetWindowLongPtr(GetDlgItem(hwndDlg, uIDButton), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, uIDButton), GWL_STYLE)|BS_ICON);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, uIDButton), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, uIDButton), GWL_STYLE) | BS_ICON);
SendMessage(GetDlgItem(hwndDlg, uIDButton), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon);
}
else {
diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index f65198e41e..b8b7f0f02b 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -237,53 +237,53 @@ int ModulesLoaded(WPARAM, LPARAM) tr.memType = TR_MEM_MIRANDA;
tr.flags = TRF_FREEMEM | TRF_PARSEFUNC | TRF_FIELD | TRF_TCHAR;
- tr.tszTokenString = L"listening_info";
- tr.parseFunctionT = VariablesParseInfo;
+ tr.szTokenString.w = L"listening_info";
+ tr.parseFunctionW = VariablesParseInfo;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Listening info as set in the options");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_type";
- tr.parseFunctionT = VariablesParseType;
+ tr.szTokenString.w = L"listening_type";
+ tr.parseFunctionW = VariablesParseType;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Media type: Music, Video, etc.");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_artist";
- tr.parseFunctionT = VariablesParseArtist;
+ tr.szTokenString.w = L"listening_artist";
+ tr.parseFunctionW = VariablesParseArtist;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Artist name");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_album";
- tr.parseFunctionT = VariablesParseAlbum;
+ tr.szTokenString.w = L"listening_album";
+ tr.parseFunctionW = VariablesParseAlbum;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Album name");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_title";
- tr.parseFunctionT = VariablesParseTitle;
+ tr.szTokenString.w = L"listening_title";
+ tr.parseFunctionW = VariablesParseTitle;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Song name");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_track";
- tr.parseFunctionT = VariablesParseTrack;
+ tr.szTokenString.w = L"listening_track";
+ tr.parseFunctionW = VariablesParseTrack;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Track number");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_year";
- tr.parseFunctionT = VariablesParseYear;
+ tr.szTokenString.w = L"listening_year";
+ tr.parseFunctionW = VariablesParseYear;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Song year");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_genre";
- tr.parseFunctionT = VariablesParseGenre;
+ tr.szTokenString.w = L"listening_genre";
+ tr.parseFunctionW = VariablesParseGenre;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Song genre");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_length";
- tr.parseFunctionT = VariablesParseLength;
+ tr.szTokenString.w = L"listening_length";
+ tr.parseFunctionW = VariablesParseLength;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Song length");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- tr.tszTokenString = L"listening_player";
- tr.parseFunctionT = VariablesParsePlayer;
+ tr.szTokenString.w = L"listening_player";
+ tr.parseFunctionW = VariablesParsePlayer;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Player name");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
}
diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index 15777de903..7f0f2f3cf6 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -478,18 +478,18 @@ INT_PTR srvVariablesHandler(WPARAM, LPARAM lParam) ARGUMENTSINFO *ai = (ARGUMENTSINFO*)lParam;
ai->flags = AIF_DONTPARSE;
TCString Result;
- if (!mir_wstrcmp(ai->targv[0], VAR_AWAYSINCE_TIME)) {
- GetTimeFormat(LOCALE_USER_DEFAULT, 0, g_ProtoStates[VarParseData.szProto].m_awaySince, (ai->argc > 1 && *ai->targv[1]) ? ai->targv[1] : L"H:mm", Result.GetBuffer(256), 256);
+ if (!mir_wstrcmp(ai->argv.w[0], VAR_AWAYSINCE_TIME)) {
+ GetTimeFormat(LOCALE_USER_DEFAULT, 0, g_ProtoStates[VarParseData.szProto].m_awaySince, (ai->argc > 1 && *ai->argv.w[1]) ? ai->argv.w[1] : L"H:mm", Result.GetBuffer(256), 256);
Result.ReleaseBuffer();
}
- else if (!mir_wstrcmp(ai->targv[0], VAR_AWAYSINCE_DATE)) {
- GetDateFormat(LOCALE_USER_DEFAULT, 0, g_ProtoStates[VarParseData.szProto].m_awaySince, (ai->argc > 1 && *ai->targv[1]) ? ai->targv[1] : nullptr, Result.GetBuffer(256), 256);
+ else if (!mir_wstrcmp(ai->argv.w[0], VAR_AWAYSINCE_DATE)) {
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, g_ProtoStates[VarParseData.szProto].m_awaySince, (ai->argc > 1 && *ai->argv.w[1]) ? ai->argv.w[1] : nullptr, Result.GetBuffer(256), 256);
Result.ReleaseBuffer();
}
- else if (!mir_wstrcmp(ai->targv[0], VAR_STATDESC)) {
+ else if (!mir_wstrcmp(ai->argv.w[0], VAR_STATDESC)) {
Result = (VarParseData.Flags & VPF_XSTATUS) ? STR_XSTATUSDESC : Clist_GetStatusModeDescription(g_ProtoStates[VarParseData.szProto].m_status, 0);
}
- else if (!mir_wstrcmp(ai->targv[0], VAR_MYNICK)) {
+ else if (!mir_wstrcmp(ai->argv.w[0], VAR_MYNICK)) {
if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_MYNICKPERPROTO) && VarParseData.szProto)
Result = db_get_s(NULL, VarParseData.szProto, "Nick", (wchar_t*)nullptr);
@@ -499,15 +499,15 @@ INT_PTR srvVariablesHandler(WPARAM, LPARAM lParam) if (Result == nullptr)
Result = TranslateT("Stranger");
}
- else if (!mir_wstrcmp(ai->targv[0], VAR_REQUESTCOUNT)) {
+ else if (!mir_wstrcmp(ai->argv.w[0], VAR_REQUESTCOUNT)) {
mir_snwprintf(Result.GetBuffer(16), 16, L"%d", db_get_w(ai->fi->hContact, MODULENAME, DB_REQUESTCOUNT, 0));
Result.ReleaseBuffer();
}
- else if (!mir_wstrcmp(ai->targv[0], VAR_MESSAGENUM)) {
+ else if (!mir_wstrcmp(ai->argv.w[0], VAR_MESSAGENUM)) {
mir_snwprintf(Result.GetBuffer(16), 16, L"%d", db_get_w(ai->fi->hContact, MODULENAME, DB_MESSAGECOUNT, 0));
Result.ReleaseBuffer();
}
- else if (!mir_wstrcmp(ai->targv[0], VAR_TIMEPASSED)) {
+ else if (!mir_wstrcmp(ai->argv.w[0], VAR_TIMEPASSED)) {
ULARGE_INTEGER ul_AwaySince, ul_Now;
SYSTEMTIME st;
GetLocalTime(&st);
@@ -524,7 +524,7 @@ INT_PTR srvVariablesHandler(WPARAM, LPARAM lParam) mir_snwprintf(Result, 256, TranslateT("%d seconds"), ul_Now.LowPart);
Result.ReleaseBuffer();
}
- else if (!mir_wstrcmp(ai->targv[0], VAR_PREDEFINEDMESSAGE)) {
+ else if (!mir_wstrcmp(ai->argv.w[0], VAR_PREDEFINEDMESSAGE)) {
ai->flags = 0; // reset AIF_DONTPARSE flag
if (ai->argc != 2)
return NULL;
@@ -534,7 +534,7 @@ INT_PTR srvVariablesHandler(WPARAM, LPARAM lParam) TreeCtrl->DBToMem(CString(MODULENAME));
for (int i = 0; i < TreeCtrl->m_value.GetSize(); i++) {
- if (!(TreeCtrl->m_value[i].Flags & TIF_GROUP) && !mir_wstrcmpi(TreeCtrl->m_value[i].Title, ai->targv[1])) {
+ if (!(TreeCtrl->m_value[i].Flags & TIF_GROUP) && !mir_wstrcmpi(TreeCtrl->m_value[i].Title, ai->argv.w[1])) {
Result = TreeCtrl->m_value[i].User_Str1;
break;
}
@@ -542,7 +542,7 @@ INT_PTR srvVariablesHandler(WPARAM, LPARAM lParam) if (Result == nullptr) // if we didn't find a message with specified title
return NULL; // return it now, as later we change NULL to ""
}
- else if (!mir_wstrcmp(ai->targv[0], VAR_PROTOCOL)) {
+ else if (!mir_wstrcmp(ai->argv.w[0], VAR_PROTOCOL)) {
if (VarParseData.szProto) {
CString AnsiResult;
CallProtoService(VarParseData.szProto, PS_GETNAME, 256, (LPARAM)AnsiResult.GetBuffer(256));
@@ -690,7 +690,7 @@ int MirandaLoaded(WPARAM, LPARAM) tr.memType = TR_MEM_OWNER;
for (int i = 0; i < _countof(Variables); i++) {
tr.flags = Variables[i].Flags | TRF_CALLSVC | TRF_TCHAR;
- tr.tszTokenString = Variables[i].Name;
+ tr.szTokenString.w = Variables[i].Name;
tr.szHelpText = Variables[i].Descr;
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
}
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index 497ecdf157..13a65ce4ce 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1578,14 +1578,14 @@ static int OnModulesLoaded(WPARAM, LPARAM) tr.cbSize = sizeof(TOKENREGISTER);
tr.memType = TR_MEM_MIRANDA;
tr.flags = TRF_FREEMEM | TRF_FIELD | TRF_TCHAR | TRF_PARSEFUNC;
- tr.tszTokenString = L"winampsong";
- tr.parseFunctionT = ParseWinampSong;
+ tr.szTokenString.w = L"winampsong";
+ tr.parseFunctionW = ParseWinampSong;
tr.szHelpText = LPGEN("External Applications") "\t" LPGEN("retrieves song name of the song currently playing in Winamp (Simple Status Message compatible)");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
if (db_get_b(NULL, MODULENAME, "ExclDateToken", 0) != 0) {
- tr.tszTokenString = L"date";
- tr.parseFunctionT = ParseDate;
+ tr.szTokenString.w = L"date";
+ tr.parseFunctionW = ParseDate;
tr.szHelpText = LPGEN("Miranda Related") "\t" LPGEN("get the date (Simple Status Message compatible)");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
}
diff --git a/plugins/SpellChecker/src/autoreplace.cpp b/plugins/SpellChecker/src/autoreplace.cpp index e2db8efbae..921f105c7f 100644 --- a/plugins/SpellChecker/src/autoreplace.cpp +++ b/plugins/SpellChecker/src/autoreplace.cpp @@ -169,9 +169,9 @@ CMStringW AutoReplaceMap::autoReplace(const wchar_t * word) wchar_t* AutoReplaceMap::filterText(const wchar_t *find)
{
wchar_t *ret = mir_wstrdup(find);
- int len = mir_wstrlen(ret);
+ size_t len = mir_wstrlen(ret);
int pos = 0;
- for (int i = 0; i < len; i++)
+ for (size_t i = 0; i < len; i++)
if (isWordChar(find[i]))
ret[pos++] = ret[i];
ret[pos] = 0;
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index 9b3dddc380..e6ecdfb2ca 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -91,17 +91,15 @@ int RemoveTmp(WPARAM, LPARAM) wstring variables_parse(wstring const &tstrFormat, MCONTACT hContact)
{
if (gbVarsServiceExist) {
- FORMATINFO fi;
- wchar_t *tszParsed;
- wstring tstrResult;
-
- memset(&fi, 0, sizeof(fi));
+ FORMATINFO fi = {};
fi.cbSize = sizeof(fi);
- fi.tszFormat = wcsdup(tstrFormat.c_str());
+ fi.szFormat.w = wcsdup(tstrFormat.c_str());
fi.hContact = hContact;
- fi.flags |= FIF_TCHAR;
- tszParsed = (wchar_t *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- free(fi.tszFormat);
+ fi.flags = FIF_UNICODE;
+ wchar_t *tszParsed = (wchar_t*)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ free(fi.szFormat.w);
+
+ wstring tstrResult;
if (tszParsed) {
tstrResult = tszParsed;
mir_free(tszParsed);
@@ -112,14 +110,12 @@ wstring variables_parse(wstring const &tstrFormat, MCONTACT hContact) }
// case-insensitive mir_wstrcmp
-//by nullbie as i remember...
-#define NEWTSTR_MALLOC(A) (A==NULL) ? NULL : mir_wstrcpy((wchar_t*)mir_alloc(sizeof(wchar_t)*(mir_wstrlen(A)+1)),A)
const int Stricmp(const wchar_t *str, const wchar_t *substr)
{
int i = 0;
- wchar_t *str_up = NEWTSTR_MALLOC(str);
- wchar_t *substr_up = NEWTSTR_MALLOC(substr);
+ wchar_t *str_up = mir_wstrdup(str);
+ wchar_t *substr_up = mir_wstrdup(substr);
CharUpperBuff(str_up, (int)mir_wstrlen(str_up));
CharUpperBuff(substr_up, (int)mir_wstrlen(substr_up));
@@ -178,7 +174,7 @@ BOOL IsUrlContains(wchar_t * Str) };
if (Str && mir_wstrlen(Str) > 0) {
- wchar_t *StrLower = NEWTSTR_MALLOC(Str);
+ wchar_t *StrLower = mir_wstrdup(Str);
CharLowerBuff(StrLower, (int)mir_wstrlen(StrLower));
for (int i = 0; i < CountUrl; i++)
if (wcsstr(StrLower, URL[i])) {
diff --git a/plugins/StopSpamPlus/src/utils.cpp b/plugins/StopSpamPlus/src/utils.cpp index a71e829d24..6fb2233318 100644 --- a/plugins/StopSpamPlus/src/utils.cpp +++ b/plugins/StopSpamPlus/src/utils.cpp @@ -34,14 +34,13 @@ bool IsExistMyMessage(MCONTACT hContact) tstring variables_parse(const wchar_t *tstrFormat, MCONTACT hContact)
{
if (ServiceExists(MS_VARS_FORMATSTRING)) {
- FORMATINFO fi;
- memset(&fi, 0, sizeof(fi));
+ FORMATINFO fi = {};
fi.cbSize = sizeof(fi);
- fi.tszFormat = wcsdup(tstrFormat);
+ fi.szFormat.w = wcsdup(tstrFormat);
fi.hContact = hContact;
- fi.flags |= FIF_TCHAR;
- wchar_t *tszParsed = (wchar_t *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- free(fi.tszFormat);
+ fi.flags = FIF_UNICODE;
+ wchar_t *tszParsed = (wchar_t*)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ free(fi.szFormat.w);
if (tszParsed) {
tstring tstrResult = tszParsed;
mir_free(tszParsed);
diff --git a/plugins/TrafficCounter/src/vars.cpp b/plugins/TrafficCounter/src/vars.cpp index 54f28fc23f..1a9d3b4852 100644 --- a/plugins/TrafficCounter/src/vars.cpp +++ b/plugins/TrafficCounter/src/vars.cpp @@ -30,13 +30,13 @@ static wchar_t* GetTraffic(ARGUMENTSINFO *ai) if (ai->argc != 5) return nullptr;
- if (!mir_wstrcmp(ai->targv[1], L"overall")) {
+ if (!mir_wstrcmp(ai->argv.w[1], L"overall")) {
tmpsn = OverallInfo.CurrentSentTraffic;
tmprn = OverallInfo.CurrentRecvTraffic;
tmpst = OverallInfo.TotalSentTraffic;
tmprt = OverallInfo.TotalRecvTraffic;
}
- else if (!mir_wstrcmp(ai->targv[1], L"summary")) {
+ else if (!mir_wstrcmp(ai->argv.w[1], L"summary")) {
for (ed = 0; ed < NumberOfAccounts; ed++)
if (ProtoList[ed].Visible) {
tmpsn += ProtoList[ed].CurrentSentTraffic;
@@ -49,7 +49,7 @@ static wchar_t* GetTraffic(ARGUMENTSINFO *ai) for (tmp = ed = 0; ed < NumberOfAccounts; ed++) {
if (!ProtoList[ed].name) continue;
wchar_t *buf = mir_a2u(ProtoList[ed].name);
- if (!mir_wstrcmp(buf, ai->targv[1])) {
+ if (!mir_wstrcmp(buf, ai->argv.w[1])) {
tmpsn = ProtoList[ed].CurrentSentTraffic;
tmprn = ProtoList[ed].CurrentRecvTraffic;
tmpst = ProtoList[ed].TotalSentTraffic;
@@ -61,31 +61,31 @@ static wchar_t* GetTraffic(ARGUMENTSINFO *ai) if (tmp != 0xAA) return nullptr;
}
- if (!mir_wstrcmp(ai->targv[2], L"now")) {
- if (!mir_wstrcmp(ai->targv[3], L"sent")) tmp = tmpsn;
+ if (!mir_wstrcmp(ai->argv.w[2], L"now")) {
+ if (!mir_wstrcmp(ai->argv.w[3], L"sent")) tmp = tmpsn;
else
- if (!mir_wstrcmp(ai->targv[3], L"received")) tmp = tmprn;
+ if (!mir_wstrcmp(ai->argv.w[3], L"received")) tmp = tmprn;
else
- if (!mir_wstrcmp(ai->targv[3], L"both")) tmp = tmprn + tmpsn;
+ if (!mir_wstrcmp(ai->argv.w[3], L"both")) tmp = tmprn + tmpsn;
else return nullptr;
}
- else if (!mir_wstrcmp(ai->targv[2], L"total")) {
- if (!mir_wstrcmp(ai->targv[3], L"sent")) tmp = tmpst;
+ else if (!mir_wstrcmp(ai->argv.w[2], L"total")) {
+ if (!mir_wstrcmp(ai->argv.w[3], L"sent")) tmp = tmpst;
else
- if (!mir_wstrcmp(ai->targv[3], L"received")) tmp = tmprt;
+ if (!mir_wstrcmp(ai->argv.w[3], L"received")) tmp = tmprt;
else
- if (!mir_wstrcmp(ai->targv[3], L"both")) tmp = tmprt + tmpst;
+ if (!mir_wstrcmp(ai->argv.w[3], L"both")) tmp = tmprt + tmpst;
else return nullptr;
}
else return nullptr;
- if (!mir_wstrcmp(ai->targv[4], L"b"))
+ if (!mir_wstrcmp(ai->argv.w[4], L"b"))
ed = 0;
- else if (!mir_wstrcmp(ai->targv[4], L"k"))
+ else if (!mir_wstrcmp(ai->argv.w[4], L"k"))
ed = 1;
- else if (!mir_wstrcmp(ai->targv[4], L"m"))
+ else if (!mir_wstrcmp(ai->argv.w[4], L"m"))
ed = 2;
- else if (!mir_wstrcmp(ai->targv[4], L"d"))
+ else if (!mir_wstrcmp(ai->argv.w[4], L"d"))
ed = 3;
else
return nullptr;
@@ -114,11 +114,11 @@ static wchar_t* GetTime(ARGUMENTSINFO *ai) wchar_t *buf;
if (!ProtoList[ed].name) continue;
buf = mir_a2u(ProtoList[ed].name);
- if (!mir_wstrcmp(buf, ai->targv[1])) {
+ if (!mir_wstrcmp(buf, ai->argv.w[1])) {
flag = 0xAA;
- if (!mir_wstrcmp(ai->targv[2], L"now"))
+ if (!mir_wstrcmp(ai->argv.w[2], L"now"))
Duration = ProtoList[ed].Session.Timer;
- else if (!mir_wstrcmp(ai->targv[2], L"total"))
+ else if (!mir_wstrcmp(ai->argv.w[2], L"total"))
Duration = ProtoList[ed].Total.Timer;
else
flag = 0;
@@ -127,11 +127,11 @@ static wchar_t* GetTime(ARGUMENTSINFO *ai) mir_free(buf);
}
- if ((flag != 0xAA) && !mir_wstrcmp(ai->targv[1], L"summary")) {
+ if ((flag != 0xAA) && !mir_wstrcmp(ai->argv.w[1], L"summary")) {
flag = 0xAA;
- if (!mir_wstrcmp(ai->targv[2], L"now"))
+ if (!mir_wstrcmp(ai->argv.w[2], L"now"))
Duration = OverallInfo.Session.Timer;
- else if (!mir_wstrcmp(ai->targv[2], L"total"))
+ else if (!mir_wstrcmp(ai->argv.w[2], L"total"))
Duration = OverallInfo.Total.Timer;
else flag = 0;
}
@@ -141,12 +141,12 @@ static wchar_t* GetTime(ARGUMENTSINFO *ai) // Получаем форматированную строку и возвращаем указатель на неё.
// Сначала узнаем размер буфера.
- size_t l = GetDurationFormatM(Duration, ai->targv[3], nullptr, 0);
+ size_t l = GetDurationFormatM(Duration, ai->argv.w[3], nullptr, 0);
wchar_t *res = (wchar_t*)mir_alloc(l * sizeof(wchar_t));
if (!res)
return nullptr;
- GetDurationFormatM(Duration, ai->targv[3], res, l);
+ GetDurationFormatM(Duration, ai->argv.w[3], res, l);
return res;
}
@@ -160,15 +160,15 @@ void RegisterVariablesTokens(void) trs.cbSize = sizeof(TOKENREGISTER);
// Функция, возвращающая трафик
- trs.tszTokenString = L"tc_GetTraffic";
- trs.parseFunctionT = GetTraffic;
+ trs.szTokenString.w = L"tc_GetTraffic";
+ trs.parseFunctionW = GetTraffic;
trs.szHelpText = "Traffic counter\t(A,B,C,D)\tGet traffic counter value. A: <ProtocolName> OR overall OR summary; B: now OR total; C: sent OR received OR both; D: b - in bytes, k - in kilobytes, m - in megabytes, d - dynamic";
trs.flags = TRF_TCHAR | TRF_PARSEFUNC | TRF_FUNCTION | TRF_FREEMEM;
trs.memType = TR_MEM_MIRANDA;
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&trs);
// Функция, возвращающая время
- trs.tszTokenString = L"tc_GetTime";
- trs.parseFunctionT = GetTime;
+ trs.szTokenString.w = L"tc_GetTime";
+ trs.parseFunctionW = GetTime;
trs.szHelpText = "Traffic counter\t(A,B,C)\tGet time counter value. A: <ProtocolName> OR summary; B: now OR total; C: format";
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&trs);
}
diff --git a/plugins/Variables/src/help.cpp b/plugins/Variables/src/help.cpp index 3e1d5678bd..4b05a3476a 100644 --- a/plugins/Variables/src/help.cpp +++ b/plugins/Variables/src/help.cpp @@ -267,7 +267,7 @@ static wchar_t *getTokenDescription(TOKENREGISTEREX *tr) return nullptr; if (tr->szHelpText == nullptr) - return mir_wstrdup(tr->tszTokenString); + return mir_wstrdup(tr->szTokenString.w); char *helpText = mir_strdup(tr->szHelpText); if (helpText == nullptr) @@ -292,7 +292,7 @@ static wchar_t *getTokenDescription(TOKENREGISTEREX *tr) } else args = nullptr; - size_t len = mir_wstrlen(tr->tszTokenString) + (args!=nullptr?mir_strlen(args):0) + 3; + size_t len = mir_wstrlen(tr->szTokenString.w) + (args!=nullptr?mir_strlen(args):0) + 3; wchar_t *desc = (wchar_t*)mir_calloc(len * sizeof(wchar_t)); if (desc == nullptr) { mir_free(helpText); @@ -305,7 +305,7 @@ static wchar_t *getTokenDescription(TOKENREGISTEREX *tr) if (args != nullptr) tArgs = mir_a2u(args); - mir_snwprintf(desc, len, L"%c%s%s", FUNC_CHAR, tr->tszTokenString, (tArgs!=nullptr?tArgs:L"")); + mir_snwprintf(desc, len, L"%c%s%s", FUNC_CHAR, tr->szTokenString.w, (tArgs!=nullptr?tArgs:L"")); } mir_free(tArgs); @@ -329,10 +329,10 @@ static int CALLBACK compareTokenHelp(LPARAM lParam1, LPARAM lParam2, LPARAM) if (res != 0) return res; - if (tr1->tszTokenString == nullptr || tr2->tszTokenString == nullptr) + if (tr1->szTokenString.w == nullptr || tr2->szTokenString.w == nullptr) return 0; - return mir_wstrcmp(tr1->tszTokenString, tr2->tszTokenString); + return mir_wstrcmp(tr1->szTokenString.w, tr2->szTokenString.w); } static BOOL CALLBACK processTokenListMessage(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) @@ -361,18 +361,18 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg, UINT msg, WPARAM, LPA i++; tszHelpDesc = tszTokenDesc = nullptr; tr = getTokenRegister(i); - if ((tr == nullptr) || (tr->tszTokenString == nullptr)) + if ((tr == nullptr) || (tr->szTokenString.w == nullptr)) continue; else if (hdd != nullptr) { - if (!mir_wstrcmp(tr->tszTokenString, SUBJECT)) { + if (!mir_wstrcmp(tr->szTokenString.w, SUBJECT)) { if (hdd->vhs->flags&VHF_HIDESUBJECTTOKEN) continue; if (hdd->vhs->szSubjectDesc != nullptr) tszHelpDesc = mir_a2u(hdd->vhs->szSubjectDesc); } - if (!mir_wstrcmp(tr->tszTokenString, MIR_EXTRATEXT)) { + if (!mir_wstrcmp(tr->szTokenString.w, MIR_EXTRATEXT)) { if (hdd->vhs->flags & VHF_HIDEEXTRATEXTTOKEN) continue; @@ -462,13 +462,13 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg, UINT msg, WPARAM, LPA if (tr == nullptr) break; - size_t len = mir_wstrlen(tr->tszTokenString) + 2; + size_t len = mir_wstrlen(tr->szTokenString.w) + 2; wchar_t *tokenString = (wchar_t*)mir_alloc((len+1)*sizeof(wchar_t)); if (tokenString == nullptr) break; memset(tokenString, 0, ((len + 1) * sizeof(wchar_t))); - mir_snwprintf(tokenString, len + 1, L"%c%s%c", (tr->flags & TRF_FIELD) ? FIELD_CHAR : FUNC_CHAR, tr->tszTokenString, (tr->flags & TRF_FIELD) ? FIELD_CHAR : '('); + mir_snwprintf(tokenString, len + 1, L"%c%s%c", (tr->flags & TRF_FIELD) ? FIELD_CHAR : FUNC_CHAR, tr->szTokenString.w, (tr->flags & TRF_FIELD) ? FIELD_CHAR : '('); SendDlgItemMessage(hwndInputDlg, IDC_TESTSTRING, EM_REPLACESEL, TRUE, (LPARAM)tokenString); mir_free(tokenString); SetFocus(GetDlgItem(hwndInputDlg, IDC_TESTSTRING)); @@ -805,12 +805,12 @@ static INT_PTR CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l ShowWindow(hPage, SW_HIDE); TabCtrl_InsertItem(hTab, tabCount++, &tci); hShow = hShow == nullptr ? hPage : hShow; - if ((dat->vhs->fi != nullptr) && (dat->vhs->fi->szFormat != nullptr)) { + if ((dat->vhs->fi != nullptr) && (dat->vhs->fi->szFormat.w != nullptr)) { if (dat->vhs->fi->flags & FIF_UNICODE) - SendMessage(hwndDlg, VARM_SETINPUTTEXT, 0, (LPARAM)dat->vhs->fi->tszFormat); + SendMessage(hwndDlg, VARM_SETINPUTTEXT, 0, (LPARAM)dat->vhs->fi->szFormat.w); else { - WCHAR *wszFormatString = mir_a2u(dat->vhs->fi->szFormat); + wchar_t *wszFormatString = mir_a2u(dat->vhs->fi->szFormat.a); SendMessage(hwndDlg, VARM_SETINPUTTEXT, 0, (LPARAM)wszFormatString); mir_free(wszFormatString); @@ -852,19 +852,19 @@ static INT_PTR CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l } } if ((dat->vhs->flags&VHF_EXTRATEXT) || - ((dat->vhs->flags&VHF_INPUT) && (dat->vhs->fi != nullptr) && (dat->vhs->fi->tszExtraText != nullptr))) { + ((dat->vhs->flags&VHF_INPUT) && (dat->vhs->fi != nullptr) && (dat->vhs->fi->szExtraText.w != nullptr))) { // extratext window is created, but not necessarily shown dat->hwndExtraTextDlg = hPage = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EXTRATEXT_DIALOG), hwndDlg, extratextDlgProc, (LPARAM)GetParent(hwndDlg)); EnableThemeDialogTexture(hPage, ETDT_ENABLETAB); MoveWindow(hPage, (rcTabs.left - rcParent.left), (rcTabs.top - rcParent.top), (rcTabs.right - rcTabs.left) - 2 * iFrameX, (rcTabs.bottom - rcTabs.top) - 2 * iFrameY, TRUE); ShowWindow(hPage, SW_HIDE); - if ((dat->vhs->fi != nullptr) && (dat->vhs->fi->tszExtraText != nullptr)) { + if ((dat->vhs->fi != nullptr) && (dat->vhs->fi->szExtraText.w != nullptr)) { if (dat->vhs->fi->flags & FIF_UNICODE) - SendMessage(hwndDlg, VARM_SETEXTRATEXT, 0, (LPARAM)dat->vhs->fi->tszExtraText); + SendMessage(hwndDlg, VARM_SETEXTRATEXT, 0, (LPARAM)dat->vhs->fi->szExtraText.w); else { - WCHAR *wszSource = mir_a2u(dat->vhs->fi->szExtraText); + wchar_t *wszSource = mir_a2u(dat->vhs->fi->szExtraText.a); SendMessage(hwndDlg, VARM_SETEXTRATEXT, 0, (LPARAM)wszSource); mir_free(wszSource); @@ -906,12 +906,12 @@ static INT_PTR CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l if (len > 0) { if ((dat->vhs->fi != nullptr) && (!(dat->vhs->flags&VHF_DONTFILLSTRUCT))) { if (dat->vhs->fi->flags&FIF_UNICODE) { - dat->vhs->fi->tszFormat = (wchar_t*)mir_calloc((len + 1)*sizeof(WCHAR)); - SendMessage(hwndDlg, VARM_GETINPUTTEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->tszFormat); + dat->vhs->fi->szFormat.w = (wchar_t*)mir_calloc((len + 1)*sizeof(wchar_t)); + SendMessage(hwndDlg, VARM_GETINPUTTEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->szFormat.w); } else { - dat->vhs->fi->szFormat = (char*)mir_calloc(len + 1); - SendMessageA(hwndDlg, VARM_GETINPUTTEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->szFormat); + dat->vhs->fi->szFormat.a = (char*)mir_calloc(len + 1); + SendMessageA(hwndDlg, VARM_GETINPUTTEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->szFormat.a); } } } @@ -940,12 +940,12 @@ static INT_PTR CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l int len = SendMessage(hwndDlg, VARM_GETEXTRATEXTLENGTH, 0, 0); if (len > 0) { if (dat->vhs->fi->flags&FIF_UNICODE) { - dat->vhs->fi->tszExtraText = (wchar_t*)mir_calloc((len + 1)*sizeof(WCHAR)); - SendMessage(hwndDlg, VARM_GETEXTRATEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->tszExtraText); + dat->vhs->fi->szExtraText.w = (wchar_t*)mir_calloc((len + 1)*sizeof(wchar_t)); + SendMessage(hwndDlg, VARM_GETEXTRATEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->szExtraText.w); } else { - dat->vhs->fi->szExtraText = (char*)mir_calloc(len + 1); - SendMessageA(hwndDlg, VARM_GETEXTRATEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->szExtraText); + dat->vhs->fi->szExtraText.a = (char*)mir_calloc(len + 1); + SendMessageA(hwndDlg, VARM_GETEXTRATEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->szExtraText.a); } } dat->vhs->fi->hContact = (MCONTACT)SendMessage(hwndDlg, VARM_GETSUBJECT, 0, 0); @@ -1141,7 +1141,7 @@ INT_PTR showHelpService(WPARAM wParam, LPARAM lParam) memset(fi, 0, sizeof(FORMATINFO)); fi->cbSize = sizeof(FORMATINFO); - fi->szFormat = (char *)lParam; + fi->szFormat.a = (char *)lParam; if (vhs == nullptr) vhs = (VARHELPINFO*)mir_alloc(sizeof(VARHELPINFO)); diff --git a/plugins/Variables/src/parse_alias.cpp b/plugins/Variables/src/parse_alias.cpp index aff5f9251c..9fd2f4f6c0 100644 --- a/plugins/Variables/src/parse_alias.cpp +++ b/plugins/Variables/src/parse_alias.cpp @@ -73,13 +73,13 @@ static wchar_t *replaceArguments(wchar_t *res, wchar_t *tArg, wchar_t *rArg) static wchar_t *parseTranslateAlias(ARGUMENTSINFO *ai)
{
- ALIASREGISTER *areg = searchAliasRegister(ai->targv[0]);
+ ALIASREGISTER *areg = searchAliasRegister(ai->argv.w[0]);
if (areg == nullptr || areg->argc != ai->argc - 1)
return nullptr;
wchar_t *res = mir_wstrdup(areg->szTranslation);
for (unsigned i = 0; i < areg->argc; i++) {
- res = replaceArguments(res, areg->argv[i], ai->targv[i + 1]);
+ res = replaceArguments(res, areg->argv[i], ai->argv.w[i + 1]);
if (res == nullptr)
return nullptr;
}
@@ -141,17 +141,17 @@ static wchar_t *parseAddAlias(ARGUMENTSINFO *ai) return nullptr;
char *szHelp, *szArgsA;
- wchar_t *cur = ai->targv[1];
+ wchar_t *cur = ai->argv.w[1];
while (isValidTokenChar(*cur))
cur++;
- ptrW alias(mir_wstrndup(ai->targv[1], cur - ai->targv[1]));
+ ptrW alias(mir_wstrndup(ai->argv.w[1], cur - ai->argv.w[1]));
TArgList argv;
getArguments(cur, argv);
deRegisterToken(alias);
- addToAliasRegister(alias, argv.getCount(), argv.getArray(), ai->targv[2]);
+ addToAliasRegister(alias, argv.getCount(), argv.getArray(), ai->argv.w[2]);
wchar_t *szArgs = nullptr;
for (int i = 0; i < argv.getCount(); i++) {
if (i == 0)
diff --git a/plugins/Variables/src/parse_inet.cpp b/plugins/Variables/src/parse_inet.cpp index d4c00aad23..0480c52627 100644 --- a/plugins/Variables/src/parse_inet.cpp +++ b/plugins/Variables/src/parse_inet.cpp @@ -24,7 +24,7 @@ static wchar_t *parseUrlEnc(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- char *res = mir_u2a(ai->targv[1]);
+ char *res = mir_u2a(ai->argv.w[1]);
if (res == nullptr)
return nullptr;
@@ -55,7 +55,7 @@ static wchar_t *parseUrlDec(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- char *res = mir_u2a(ai->targv[1]);
+ char *res = mir_u2a(ai->argv.w[1]);
if (res == nullptr)
return nullptr;
@@ -83,7 +83,7 @@ static wchar_t *parseNToA(ARGUMENTSINFO *ai) return nullptr;
struct in_addr in;
- in.s_addr = ttoi(ai->targv[1]);
+ in.s_addr = ttoi(ai->argv.w[1]);
return mir_a2u(inet_ntoa(in));
}
@@ -93,7 +93,7 @@ static wchar_t *parseHToA(ARGUMENTSINFO *ai) return nullptr;
struct in_addr in;
- in.s_addr = htonl(ttoi(ai->targv[1]));
+ in.s_addr = htonl(ttoi(ai->argv.w[1]));
return mir_a2u(inet_ntoa(in));
}
diff --git a/plugins/Variables/src/parse_logic.cpp b/plugins/Variables/src/parse_logic.cpp index 2c234b9890..7a48c01931 100644 --- a/plugins/Variables/src/parse_logic.cpp +++ b/plugins/Variables/src/parse_logic.cpp @@ -27,7 +27,7 @@ static wchar_t *parseAnd(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
for (unsigned i = 1; i < ai->argc; i++) {
- fi.tszFormat = ai->targv[i];
+ fi.szFormat.w = ai->argv.w[i];
mir_free(formatString(&fi));
if (fi.eCount > 0) {
@@ -56,10 +56,10 @@ static wchar_t *parseIf(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
fi.eCount = fi.pCount = 0;
- fi.tszFormat = ai->targv[1];
+ fi.szFormat.w = ai->argv.w[1];
mir_free(formatString(&fi));
- return mir_wstrdup((fi.eCount == 0) ? ai->targv[2] : ai->targv[3]);
+ return mir_wstrdup((fi.eCount == 0) ? ai->argv.w[2] : ai->argv.w[3]);
}
static wchar_t *parseIf2(ARGUMENTSINFO *ai)
@@ -70,13 +70,13 @@ static wchar_t *parseIf2(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
fi.eCount = fi.pCount = 0;
- fi.tszFormat = ai->targv[1];
+ fi.szFormat.w = ai->argv.w[1];
wchar_t *szCondition = formatString(&fi);
if (fi.eCount == 0)
return szCondition;
mir_free(szCondition);
- return mir_wstrdup(ai->targv[2]);
+ return mir_wstrdup(ai->argv.w[2]);
}
static wchar_t *parseIf3(ARGUMENTSINFO *ai)
@@ -85,7 +85,7 @@ static wchar_t *parseIf3(ARGUMENTSINFO *ai) memcpy(&fi, ai->fi, sizeof(fi));
for (unsigned i = 1; i < ai->argc; i++) {
fi.eCount = fi.pCount = 0;
- fi.tszFormat = ai->targv[i];
+ fi.szFormat.w = ai->argv.w[i];
wchar_t *szCondition = formatString(&fi);
if (fi.eCount == 0)
return szCondition;
@@ -103,17 +103,17 @@ static wchar_t *parseIfequal(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
- fi.szFormat = ai->argv[1];
+ fi.szFormat.w = ai->argv.w[1];
ptrW tszFirst(formatString(&fi));
- fi.szFormat = ai->argv[2];
+ fi.szFormat.w = ai->argv.w[2];
ptrW tszSecond(formatString(&fi));
if (tszFirst == NULL || tszSecond == NULL)
return nullptr;
if (ttoi(tszFirst) == ttoi(tszSecond))
- return mir_wstrdup(ai->targv[3]);
+ return mir_wstrdup(ai->argv.w[3]);
- return mir_wstrdup(ai->targv[4]);
+ return mir_wstrdup(ai->argv.w[4]);
}
static wchar_t *parseIfgreater(ARGUMENTSINFO *ai)
@@ -123,17 +123,17 @@ static wchar_t *parseIfgreater(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
- fi.szFormat = ai->argv[1];
+ fi.szFormat.w = ai->argv.w[1];
ptrW tszFirst(formatString(&fi));
- fi.szFormat = ai->argv[2];
+ fi.szFormat.w = ai->argv.w[2];
ptrW tszSecond(formatString(&fi));
if (tszFirst == NULL || tszSecond == NULL)
return nullptr;
if (ttoi(tszFirst) > ttoi(tszSecond))
- return mir_wstrdup(ai->targv[3]);
+ return mir_wstrdup(ai->argv.w[3]);
- return mir_wstrdup(ai->targv[4]);
+ return mir_wstrdup(ai->argv.w[4]);
}
static wchar_t *parseIflonger(ARGUMENTSINFO *ai)
@@ -143,17 +143,17 @@ static wchar_t *parseIflonger(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
- fi.szFormat = ai->argv[1];
+ fi.szFormat.w = ai->argv.w[1];
ptrW tszFirst(formatString(&fi));
- fi.szFormat = ai->argv[2];
+ fi.szFormat.w = ai->argv.w[2];
ptrW tszSecond(formatString(&fi));
if (tszFirst == NULL || tszSecond == NULL)
return nullptr;
if (mir_wstrlen(tszFirst) > mir_wstrlen(tszSecond))
- return mir_wstrdup(ai->targv[3]);
+ return mir_wstrdup(ai->argv.w[3]);
- return mir_wstrdup(ai->targv[4]);
+ return mir_wstrdup(ai->argv.w[4]);
}
/*
@@ -171,12 +171,12 @@ static wchar_t *parseFor(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
fi.eCount = fi.pCount = 0;
- fi.tszFormat = ai->targv[1];
+ fi.szFormat.w = ai->argv.w[1];
mir_free(formatString(&fi));
- fi.tszFormat = ai->targv[2];
+ fi.szFormat.w = ai->argv.w[2];
mir_free(formatString(&fi));
while (fi.eCount == 0) {
- fi.tszFormat = ai->targv[4];
+ fi.szFormat.w = ai->argv.w[4];
wchar_t *parsed = formatString(&fi);
if (parsed != nullptr) {
if (res == nullptr) {
@@ -191,10 +191,10 @@ static wchar_t *parseFor(ARGUMENTSINFO *ai) mir_wstrcat(res, parsed);
mir_free(parsed);
}
- fi.tszFormat = ai->targv[3];
+ fi.szFormat.w = ai->argv.w[3];
mir_free(formatString(&fi));
fi.eCount = 0;
- fi.tszFormat = ai->targv[2];
+ fi.szFormat.w = ai->argv.w[2];
mir_free(formatString(&fi));
}
@@ -206,7 +206,7 @@ static wchar_t *parseEqual(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- if (ttoi(ai->targv[1]) != ttoi(ai->targv[2]))
+ if (ttoi(ai->argv.w[1]) != ttoi(ai->argv.w[2]))
ai->flags |= AIF_FALSE;
return mir_wstrdup(L"");
@@ -217,7 +217,7 @@ static wchar_t *parseGreater(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- if (ttoi(ai->targv[1]) <= ttoi(ai->targv[2]))
+ if (ttoi(ai->argv.w[1]) <= ttoi(ai->argv.w[2]))
ai->flags |= AIF_FALSE;
return mir_wstrdup(L"");
@@ -228,7 +228,7 @@ static wchar_t *parseLonger(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- if (mir_wstrlen(ai->targv[1]) <= mir_wstrlen(ai->targv[2]))
+ if (mir_wstrlen(ai->argv.w[1]) <= mir_wstrlen(ai->argv.w[2]))
ai->flags |= AIF_FALSE;
return mir_wstrdup(L"");
@@ -242,7 +242,7 @@ static wchar_t *parseNot(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
- fi.tszFormat = ai->targv[1];
+ fi.szFormat.w = ai->argv.w[1];
mir_free(formatString(&fi));
if (fi.eCount == 0)
@@ -260,7 +260,7 @@ static wchar_t *parseOr(ARGUMENTSINFO *ai) memcpy(&fi, ai->fi, sizeof(fi));
ai->flags |= AIF_FALSE;
for (unsigned i = 1; (i < ai->argc) && (ai->flags&AIF_FALSE); i++) {
- fi.tszFormat = ai->targv[i];
+ fi.szFormat.w = ai->argv.w[i];
fi.eCount = 0;
mir_free(formatString(&fi));
@@ -284,11 +284,11 @@ static wchar_t *parseXor(ARGUMENTSINFO *ai) FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
ai->flags = AIF_FALSE;
- fi.tszFormat = ai->targv[0];
+ fi.szFormat.w = ai->argv.w[0];
mir_free(formatString(&fi));
int val1 = fi.eCount == 0;
- fi.tszFormat = ai->targv[1];
+ fi.szFormat.w = ai->argv.w[1];
mir_free(formatString(&fi));
int val2 = fi.eCount == 0;
diff --git a/plugins/Variables/src/parse_math.cpp b/plugins/Variables/src/parse_math.cpp index 7bb12ada35..31937df423 100644 --- a/plugins/Variables/src/parse_math.cpp +++ b/plugins/Variables/src/parse_math.cpp @@ -26,7 +26,7 @@ static wchar_t *parseAdd(ARGUMENTSINFO *ai) int result = 0;
for (unsigned int i = 1; i < ai->argc; i++)
- result += ttoi(ai->targv[i]);
+ result += ttoi(ai->argv.w[i]);
return itot(result);
}
@@ -36,8 +36,8 @@ static wchar_t *parseDiv(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- int val1 = ttoi(ai->targv[1]);
- int val2 = ttoi(ai->targv[2]);
+ int val1 = ttoi(ai->argv.w[1]);
+ int val2 = ttoi(ai->argv.w[2]);
if (val2 == 0)
return nullptr;
@@ -52,8 +52,8 @@ static wchar_t *parseHex(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- int val = ttoi(ai->targv[1]);
- int padding = ttoi(ai->targv[2]);
+ int val = ttoi(ai->argv.w[1]);
+ int padding = ttoi(ai->argv.w[2]);
mir_snwprintf(szVal, L"%x", val);
unsigned int zeros = max(padding - (signed int)mir_wstrlen(szVal), 0);
wchar_t *res = (wchar_t*)mir_alloc((zeros + mir_wstrlen(szVal) + 3)*sizeof(wchar_t));
@@ -74,8 +74,8 @@ static wchar_t *parseMod(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- int val1 = ttoi(ai->targv[1]);
- int val2 = ttoi(ai->targv[2]);
+ int val1 = ttoi(ai->argv.w[1]);
+ int val2 = ttoi(ai->argv.w[2]);
if (val2 == 0)
return nullptr;
@@ -87,9 +87,9 @@ static wchar_t *parseMul(ARGUMENTSINFO *ai) if (ai->argc < 3)
return nullptr;
- int result = ttoi(ai->targv[1]);
+ int result = ttoi(ai->argv.w[1]);
for (unsigned i = 2; i < ai->argc; i++)
- result *= ttoi(ai->targv[i]);
+ result *= ttoi(ai->argv.w[i]);
return itot(result);
}
@@ -99,10 +99,10 @@ static wchar_t *parseMuldiv(ARGUMENTSINFO *ai) if (ai->argc != 4)
return nullptr;
- if (ttoi(ai->targv[3]) == 0)
+ if (ttoi(ai->argv.w[3]) == 0)
return nullptr;
- return itot((ttoi(ai->targv[1])*ttoi(ai->targv[2])) / ttoi(ai->targv[3]));
+ return itot((ttoi(ai->argv.w[1])*ttoi(ai->argv.w[2])) / ttoi(ai->argv.w[3]));
}
static wchar_t *parseMin(ARGUMENTSINFO *ai)
@@ -110,9 +110,9 @@ static wchar_t *parseMin(ARGUMENTSINFO *ai) if (ai->argc < 2)
return nullptr;
- int minVal = ttoi(ai->targv[1]);
+ int minVal = ttoi(ai->argv.w[1]);
for (unsigned i = 2; i < ai->argc; i++)
- minVal = min(ttoi(ai->targv[i]), minVal);
+ minVal = min(ttoi(ai->argv.w[i]), minVal);
return itot(minVal);
}
@@ -122,9 +122,9 @@ static wchar_t *parseMax(ARGUMENTSINFO *ai) if (ai->argc < 2)
return nullptr;
- int maxVal = ttoi(ai->targv[1]);
+ int maxVal = ttoi(ai->argv.w[1]);
for (unsigned i = 2; i < ai->argc; i++)
- maxVal = max(ttoi(ai->targv[i]), maxVal);
+ maxVal = max(ttoi(ai->argv.w[i]), maxVal);
return itot(maxVal);
}
@@ -134,8 +134,8 @@ static wchar_t *parseNum(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- int val = ttoi(ai->targv[1]);
- int padding = ttoi(ai->targv[2]);
+ int val = ttoi(ai->argv.w[1]);
+ int padding = ttoi(ai->argv.w[2]);
wchar_t *szVal = itot(val);
if (szVal == nullptr)
return nullptr;
@@ -168,9 +168,9 @@ static wchar_t *parseSub(ARGUMENTSINFO *ai) if (ai->argc < 3)
return nullptr;
- int result = ttoi(ai->targv[1]);
+ int result = ttoi(ai->argv.w[1]);
for (unsigned i = 2; i < ai->argc; i++)
- result -= ttoi(ai->targv[i]);
+ result -= ttoi(ai->argv.w[i]);
return itot(result);
}
diff --git a/plugins/Variables/src/parse_metacontacts.cpp b/plugins/Variables/src/parse_metacontacts.cpp index b071cd4c25..e208489e97 100644 --- a/plugins/Variables/src/parse_metacontacts.cpp +++ b/plugins/Variables/src/parse_metacontacts.cpp @@ -24,7 +24,7 @@ static wchar_t *parseGetParent(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- MCONTACT hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
@@ -52,7 +52,7 @@ static wchar_t *parseGetDefault(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- MCONTACT hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
@@ -80,7 +80,7 @@ static wchar_t *parseGetMostOnline(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- MCONTACT hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index d60c02cebf..3488fd8d28 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -24,7 +24,7 @@ static wchar_t* parseCodeToStatus(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- unsigned int status = ttoi(ai->targv[1]);
+ unsigned int status = ttoi(ai->argv.w[1]);
wchar_t *szStatus = Clist_GetStatusModeDescription(status, 0);
if (szStatus != nullptr)
return mir_wstrdup(szStatus);
@@ -81,13 +81,13 @@ static wchar_t* parseContact(ARGUMENTSINFO *ai) int n = 0;
if (ai->argc == 4) {
- if (*ai->targv[3] != 'r') // random contact
+ if (*ai->argv.w[3] != 'r') // random contact
n = -1;
else
- n = ttoi(ai->targv[3]) - 1;
+ n = ttoi(ai->argv.w[3]) - 1;
}
- MCONTACT hContact = getContactFromString(ai->targv[1], getContactInfoFlags(ai->targv[2]), n);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], getContactInfoFlags(ai->argv.w[2]), n);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
@@ -100,7 +100,7 @@ static wchar_t* parseContactCount(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- int count = getContactFromString(ai->targv[1], CI_NEEDCOUNT | getContactInfoFlags(ai->targv[2]));
+ int count = getContactFromString(ai->argv.w[1], CI_NEEDCOUNT | getContactInfoFlags(ai->argv.w[2]));
return itot(count);
}
@@ -109,11 +109,11 @@ static wchar_t* parseContactInfo(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- MCONTACT hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
- BYTE type = getContactInfoType(ai->targv[2]);
+ BYTE type = getContactInfoType(ai->argv.w[2]);
if (type == 0)
return nullptr;
@@ -180,23 +180,23 @@ static wchar_t* parseDBSetting(ARGUMENTSINFO *ai) return nullptr;
MCONTACT hContact = NULL;
- if (mir_wstrlen(ai->targv[1]) > 0) {
- hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ if (mir_wstrlen(ai->argv.w[1]) > 0) {
+ hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
}
- char *szModule = mir_u2a(ai->targv[2]);
+ char *szModule = mir_u2a(ai->argv.w[2]);
if (szModule == nullptr)
return nullptr;
- char *szSetting = mir_u2a(ai->targv[3]);
+ char *szSetting = mir_u2a(ai->argv.w[3]);
if (szSetting == nullptr) {
mir_free(szModule);
return nullptr;
}
- wchar_t *szDefaultValue = ((ai->argc > 4 && mir_wstrlen(ai->targv[4]) > 0) ? mir_wstrdup(ai->targv[4]) : nullptr);
+ wchar_t *szDefaultValue = ((ai->argc > 4 && mir_wstrlen(ai->argv.w[4]) > 0) ? mir_wstrdup(ai->argv.w[4]) : nullptr);
wchar_t *res = getDBSetting(hContact, szModule, szSetting, szDefaultValue);
mir_free(szDefaultValue);
mir_free(szSetting);
@@ -209,15 +209,15 @@ static wchar_t* parseLastSeenDate(ARGUMENTSINFO *ai) if (ai->argc <= 1)
return nullptr;
- MCONTACT hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
wchar_t *szFormat;
- if (ai->argc == 2 || (ai->argc > 2 && mir_wstrlen(ai->targv[2]) == 0))
+ if (ai->argc == 2 || (ai->argc > 2 && mir_wstrlen(ai->argv.w[2]) == 0))
szFormat = nullptr;
else
- szFormat = ai->targv[2];
+ szFormat = ai->argv.w[2];
SYSTEMTIME lsTime = { 0 };
char *szModule = SEEN_MODULE;
@@ -251,15 +251,15 @@ static wchar_t* parseLastSeenTime(ARGUMENTSINFO *ai) if (ai->argc <= 1)
return nullptr;
- MCONTACT hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
wchar_t *szFormat;
- if (ai->argc == 2 || (ai->argc > 2 && mir_wstrlen(ai->targv[2]) == 0))
+ if (ai->argc == 2 || (ai->argc > 2 && mir_wstrlen(ai->argv.w[2]) == 0))
szFormat = nullptr;
else
- szFormat = ai->targv[2];
+ szFormat = ai->argv.w[2];
SYSTEMTIME lsTime = { 0 };
char *szModule = SEEN_MODULE;
@@ -294,7 +294,7 @@ static wchar_t* parseLastSeenStatus(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- MCONTACT hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
@@ -329,10 +329,10 @@ static wchar_t* parseMyStatus(ARGUMENTSINFO *ai) return nullptr;
int status;
- if (ai->argc == 1 || mir_wstrlen(ai->targv[1]) == 0)
+ if (ai->argc == 1 || mir_wstrlen(ai->argv.w[1]) == 0)
status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
else
- status = Proto_GetStatus(_T2A(ai->targv[1]));
+ status = Proto_GetStatus(_T2A(ai->argv.w[1]));
wchar_t *szStatus = Clist_GetStatusModeDescription(status, 0);
return (szStatus != nullptr) ? mir_wstrdup(szStatus) : nullptr;
@@ -345,21 +345,21 @@ static wchar_t* parseProtoInfo(ARGUMENTSINFO *ai) const char *szRes = nullptr;
wchar_t *tszRes = nullptr;
- ptrA szProto(mir_u2a(ai->targv[1]));
+ ptrA szProto(mir_u2a(ai->argv.w[1]));
- if (!mir_wstrcmp(ai->targv[2], _A2W(STR_PINAME)))
+ if (!mir_wstrcmp(ai->argv.w[2], _A2W(STR_PINAME)))
tszRes = Hlp_GetProtocolName(szProto);
- else if (!mir_wstrcmp(ai->targv[2], _A2W(STR_PIUIDTEXT))) {
+ else if (!mir_wstrcmp(ai->argv.w[2], _A2W(STR_PIUIDTEXT))) {
szRes = (const char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDTEXT, 0);
if (INT_PTR(szRes) == CALLSERVICE_NOTFOUND || szRes == nullptr)
return nullptr;
}
- else if (!mir_wstrcmp(ai->targv[2], _A2W(STR_PIUIDSETTING))) {
+ else if (!mir_wstrcmp(ai->argv.w[2], _A2W(STR_PIUIDSETTING))) {
szRes = Proto_GetUniqueId(szProto);
if (szRes == nullptr)
return nullptr;
}
- else if (!mir_wstrcmp(ai->targv[2], _A2W(STR_PINICK)))
+ else if (!mir_wstrcmp(ai->argv.w[2], _A2W(STR_PINICK)))
tszRes = Contact_GetInfo(CNF_DISPLAY, NULL, szProto);
if (szRes == nullptr && tszRes == nullptr)
@@ -527,7 +527,7 @@ static wchar_t* parseDbEvent(ARGUMENTSINFO *ai) return nullptr;
int flags = DBE_MESSAGE;
- switch (*ai->targv[2]) {
+ switch (*ai->argv.w[2]) {
case 'f':
flags |= DBE_FIRST;
break;
@@ -535,7 +535,7 @@ static wchar_t* parseDbEvent(ARGUMENTSINFO *ai) flags |= DBE_LAST;
break;
}
- switch (*ai->targv[3]) {
+ switch (*ai->argv.w[3]) {
case 's':
flags |= DBE_SENT;
break;
@@ -546,7 +546,7 @@ static wchar_t* parseDbEvent(ARGUMENTSINFO *ai) flags |= DBE_RCVD | DBE_SENT;
break;
}
- switch (*ai->targv[4]) {
+ switch (*ai->argv.w[4]) {
case 'r':
flags |= DBE_READ;
break;
@@ -558,7 +558,7 @@ static wchar_t* parseDbEvent(ARGUMENTSINFO *ai) break;
}
- MCONTACT hContact = getContactFromString(ai->targv[1], CI_ALLFLAGS);
+ MCONTACT hContact = getContactFromString(ai->argv.w[1], CI_ALLFLAGS);
if (hContact == INVALID_CONTACT_ID)
return nullptr;
@@ -584,7 +584,7 @@ static wchar_t* parseTranslate(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- wchar_t *res = TranslateW(ai->targv[1]);
+ wchar_t *res = TranslateW(ai->argv.w[1]);
return (res == nullptr) ? nullptr : mir_wstrdup(res);
}
@@ -628,7 +628,7 @@ static wchar_t *parseMirandaCoreVar(ARGUMENTSINFO *ai) ai->flags |= AIF_DONTPARSE;
wchar_t corevar[MAX_PATH];
- mir_snwprintf(corevar, L"%%%s%%", ai->targv[0]);
+ mir_snwprintf(corevar, L"%%%s%%", ai->argv.w[0]);
return Utils_ReplaceVarsW(corevar);
}
@@ -637,7 +637,7 @@ static wchar_t *parseMirSrvExists(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- if (!ServiceExists(_T2A(ai->targv[1])))
+ if (!ServiceExists(_T2A(ai->argv.w[1])))
ai->flags |= AIF_FALSE;
return mir_wstrdup(L"");
diff --git a/plugins/Variables/src/parse_regexp.cpp b/plugins/Variables/src/parse_regexp.cpp index b401d15aae..c6fd4e6737 100644 --- a/plugins/Variables/src/parse_regexp.cpp +++ b/plugins/Variables/src/parse_regexp.cpp @@ -34,12 +34,12 @@ static wchar_t *parseRegExpCheck(ARGUMENTSINFO *ai) ai->flags = AIF_FALSE;
- pcre16 *ppat = pcre16_compile(ai->targv[1], 0, &err, &erroffset, nullptr);
+ pcre16 *ppat = pcre16_compile(ai->argv.w[1], 0, &err, &erroffset, nullptr);
if (ppat == nullptr)
return nullptr;
pcre16_extra *extra = pcre16_study(ppat, 0, &err);
- int nmat = pcre16_exec(ppat, extra, ai->targv[2], (int)mir_wstrlen(ai->targv[2]), 0, 0, offsets, 99);
+ int nmat = pcre16_exec(ppat, extra, ai->argv.w[2], (int)mir_wstrlen(ai->argv.w[2]), 0, 0, offsets, 99);
if (nmat > 0) {
ai->flags &= ~AIF_FALSE;
_ltoa(nmat, szVal, 10);
@@ -62,21 +62,21 @@ static wchar_t *parseRegExpSubstr(ARGUMENTSINFO *ai) if (ai->argc != 4)
return nullptr;
- number = _wtoi(ai->targv[3]);
+ number = _wtoi(ai->argv.w[3]);
if (number < 0)
return nullptr;
ai->flags = AIF_FALSE;
- pcre16 *ppat = pcre16_compile(ai->targv[1], 0, &err, &erroffset, nullptr);
+ pcre16 *ppat = pcre16_compile(ai->argv.w[1], 0, &err, &erroffset, nullptr);
if (ppat == nullptr)
return nullptr;
pcre16_extra *extra = pcre16_study(ppat, 0, &err);
- int nmat = pcre16_exec(ppat, extra, ai->targv[2], (int)mir_wstrlen(ai->targv[2]), 0, 0, offsets, 99);
+ int nmat = pcre16_exec(ppat, extra, ai->argv.w[2], (int)mir_wstrlen(ai->argv.w[2]), 0, 0, offsets, 99);
if (nmat >= 0)
ai->flags &= ~AIF_FALSE;
- if (pcre16_get_substring(ai->targv[2], offsets, nmat, number, &substring) < 0)
+ if (pcre16_get_substring(ai->argv.w[2], offsets, nmat, number, &substring) < 0)
ai->flags |= AIF_FALSE;
else {
wchar_t *tres = mir_wstrdup(substring);
diff --git a/plugins/Variables/src/parse_str.cpp b/plugins/Variables/src/parse_str.cpp index f13b4a0252..e335a36d69 100644 --- a/plugins/Variables/src/parse_str.cpp +++ b/plugins/Variables/src/parse_str.cpp @@ -24,7 +24,7 @@ static wchar_t *parseCaps(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- wchar_t *res = mir_wstrdup(ai->targv[1]);
+ wchar_t *res = mir_wstrdup(ai->argv.w[1]);
wchar_t *cur = res;
CharLower(res);
*cur = (wchar_t)CharUpper((LPTSTR)*cur);
@@ -49,7 +49,7 @@ static wchar_t *parseCaps2(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- wchar_t *res = mir_wstrdup(ai->targv[1]);
+ wchar_t *res = mir_wstrdup(ai->argv.w[1]);
wchar_t *cur = res;
*cur = (wchar_t)CharUpper((LPTSTR)*cur);
cur++;
@@ -75,7 +75,7 @@ static wchar_t *parseEolToCrlf(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- wchar_t *res = mir_wstrdup(ai->targv[1]);
+ wchar_t *res = mir_wstrdup(ai->argv.w[1]);
wchar_t *cur = res;
do {
cur = wcschr(cur, '\n');
@@ -101,24 +101,24 @@ static wchar_t *parseFixeol(ARGUMENTSINFO *ai) if (ai->argc == 2)
szReplacement = L"(...)";
else if (ai->argc == 3)
- szReplacement = ai->targv[2];
+ szReplacement = ai->argv.w[2];
else
return nullptr;
- wchar_t *cur = ai->targv[1];
+ wchar_t *cur = ai->argv.w[1];
while (mir_wstrcmp(cur, L"\r\n") && *cur != '\n' && *cur != 0)
cur++;
if (*cur == '\0')
- return mir_wstrdup(ai->targv[1]);
+ return mir_wstrdup(ai->argv.w[1]);
cur--;
- wchar_t *res = (wchar_t*)mir_alloc((cur - ai->targv[1] + mir_wstrlen(szReplacement) + 1)*sizeof(wchar_t));
+ wchar_t *res = (wchar_t*)mir_alloc((cur - ai->argv.w[1] + mir_wstrlen(szReplacement) + 1)*sizeof(wchar_t));
if (res == nullptr)
return res;
- memset(res, 0, (((cur - ai->targv[1]) + 1) * sizeof(wchar_t)));
- wcsncpy(res, ai->targv[1], cur - ai->targv[1]);
+ memset(res, 0, (((cur - ai->argv.w[1]) + 1) * sizeof(wchar_t)));
+ wcsncpy(res, ai->argv.w[1], cur - ai->argv.w[1]);
mir_wstrcat(res, szReplacement);
return res;
}
@@ -128,11 +128,11 @@ static wchar_t *parseFixeol2(ARGUMENTSINFO *ai) wchar_t *szReplacement;
switch (ai->argc) {
case 2: szReplacement = L" "; break;
- case 3: szReplacement = ai->targv[2]; break;
+ case 3: szReplacement = ai->argv.w[2]; break;
default: return nullptr;
}
- wchar_t *res = mir_wstrdup(ai->targv[1]);
+ wchar_t *res = mir_wstrdup(ai->argv.w[1]);
for (size_t pos = 0; pos < mir_wstrlen(res); pos++) {
wchar_t *cur = res + pos;
wchar_t *szEol = nullptr;
@@ -160,18 +160,18 @@ static wchar_t *parseInsert(ARGUMENTSINFO *ai) if (ai->argc != 4)
return nullptr;
- unsigned int pos = ttoi(ai->targv[3]);
- if (pos > mir_wstrlen(ai->targv[1]))
+ unsigned int pos = ttoi(ai->argv.w[3]);
+ if (pos > mir_wstrlen(ai->argv.w[1]))
return nullptr;
- wchar_t *res = (wchar_t*)mir_alloc((mir_wstrlen(ai->targv[1]) + mir_wstrlen(ai->targv[2]) + 1)*sizeof(wchar_t));
+ wchar_t *res = (wchar_t*)mir_alloc((mir_wstrlen(ai->argv.w[1]) + mir_wstrlen(ai->argv.w[2]) + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
- memset(res, 0, ((mir_wstrlen(ai->targv[1]) + mir_wstrlen(ai->targv[2]) + 1) * sizeof(wchar_t)));
- wcsncpy(res, ai->targv[1], pos);
- mir_wstrcpy(res + pos, ai->targv[2]);
- mir_wstrcpy(res + pos + mir_wstrlen(ai->targv[2]), ai->targv[1] + pos);
+ memset(res, 0, ((mir_wstrlen(ai->argv.w[1]) + mir_wstrlen(ai->argv.w[2]) + 1) * sizeof(wchar_t)));
+ wcsncpy(res, ai->argv.w[1], pos);
+ mir_wstrcpy(res + pos, ai->argv.w[2]);
+ mir_wstrcpy(res + pos + mir_wstrlen(ai->argv.w[2]), ai->argv.w[1] + pos);
return res;
}
@@ -180,17 +180,17 @@ static wchar_t *parseLeft(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- int len = ttoi(ai->targv[2]);
+ int len = ttoi(ai->argv.w[2]);
if (len < 0)
return nullptr;
- len = min(len, (signed int)mir_wstrlen(ai->targv[1]));
+ len = min(len, (signed int)mir_wstrlen(ai->argv.w[1]));
wchar_t *res = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
memset(res, 0, ((len + 1) * sizeof(wchar_t)));
- wcsncpy(res, ai->targv[1], len);
+ wcsncpy(res, ai->argv.w[1], len);
return res;
}
@@ -199,7 +199,7 @@ static wchar_t *parseLen(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- return itot((int)mir_wstrlen(ai->targv[1]));
+ return itot((int)mir_wstrlen(ai->argv.w[1]));
}
static wchar_t *parseLineCount(ARGUMENTSINFO *ai)
@@ -208,8 +208,8 @@ static wchar_t *parseLineCount(ARGUMENTSINFO *ai) return nullptr;
int count = 1;
- wchar_t *cur = ai->targv[1];
- while (cur < (ai->targv[1] + mir_wstrlen(ai->targv[1]))) {
+ wchar_t *cur = ai->argv.w[1];
+ while (cur < (ai->argv.w[1] + mir_wstrlen(ai->argv.w[1]))) {
if (!wcsncmp(cur, L"\r\n", 2)) {
count++;
cur++;
@@ -228,7 +228,7 @@ static wchar_t *parseLower(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- wchar_t *res = mir_wstrdup(ai->targv[1]);
+ wchar_t *res = mir_wstrdup(ai->argv.w[1]);
if (res == nullptr)
return nullptr;
@@ -242,10 +242,10 @@ static wchar_t *parseLongest(ARGUMENTSINFO *ai) unsigned int iLong = 1;
for (unsigned int i = 2; i < ai->argc; i++)
- if (mir_wstrlen(ai->targv[i]) > mir_wstrlen(ai->targv[iLong]))
+ if (mir_wstrlen(ai->argv.w[i]) > mir_wstrlen(ai->argv.w[iLong]))
iLong = i;
- return mir_wstrdup(ai->targv[iLong]);
+ return mir_wstrdup(ai->argv.w[iLong]);
}
static wchar_t *parseNoOp(ARGUMENTSINFO *ai)
@@ -253,7 +253,7 @@ static wchar_t *parseNoOp(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- return mir_wstrdup(ai->targv[1]);
+ return mir_wstrdup(ai->argv.w[1]);
}
static wchar_t *parsePad(ARGUMENTSINFO *ai)
@@ -261,25 +261,25 @@ static wchar_t *parsePad(ARGUMENTSINFO *ai) wchar_t padchar;
switch (ai->argc) {
case 3: padchar = ' '; break;
- case 4: padchar = *ai->targv[3]; break;
+ case 4: padchar = *ai->argv.w[3]; break;
default: return nullptr;
}
- int padding = ttoi(ai->targv[2]);
+ int padding = ttoi(ai->argv.w[2]);
if (padding < 0)
return nullptr;
- unsigned int addcount = max(padding - (signed int)mir_wstrlen(ai->targv[1]), 0);
- wchar_t *res = (wchar_t*)mir_alloc((addcount + mir_wstrlen(ai->targv[1]) + 1)*sizeof(wchar_t));
+ unsigned int addcount = max(padding - (signed int)mir_wstrlen(ai->argv.w[1]), 0);
+ wchar_t *res = (wchar_t*)mir_alloc((addcount + mir_wstrlen(ai->argv.w[1]) + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
- memset(res, 0, ((addcount + mir_wstrlen(ai->targv[1]) + 1) * sizeof(wchar_t)));
+ memset(res, 0, ((addcount + mir_wstrlen(ai->argv.w[1]) + 1) * sizeof(wchar_t)));
wchar_t *cur = res;
for (unsigned int i = 0; i < addcount; i++)
*cur++ = padchar;
- mir_wstrcat(res, ai->targv[1]);
+ mir_wstrcat(res, ai->argv.w[1]);
return res;
}
@@ -288,22 +288,22 @@ static wchar_t *parsePadright(ARGUMENTSINFO *ai) wchar_t padchar;
switch (ai->argc) {
case 3: padchar = ' '; break;
- case 4: padchar = *ai->targv[3]; break;
+ case 4: padchar = *ai->argv.w[3]; break;
default: return nullptr;
}
- int padding = ttoi(ai->targv[2]);
+ int padding = ttoi(ai->argv.w[2]);
if (padding < 0)
return nullptr;
- unsigned int addcount = max(padding - (signed int)mir_wstrlen(ai->targv[1]), 0);
- wchar_t *res = (wchar_t*)mir_alloc((addcount + mir_wstrlen(ai->targv[1]) + 1)*sizeof(wchar_t));
+ unsigned int addcount = max(padding - (signed int)mir_wstrlen(ai->argv.w[1]), 0);
+ wchar_t *res = (wchar_t*)mir_alloc((addcount + mir_wstrlen(ai->argv.w[1]) + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
- memset(res, 0, ((addcount + mir_wstrlen(ai->targv[1]) + 1) * sizeof(wchar_t)));
- mir_wstrcpy(res, ai->targv[1]);
- wchar_t *cur = res + mir_wstrlen(ai->targv[1]);
+ memset(res, 0, ((addcount + mir_wstrlen(ai->argv.w[1]) + 1) * sizeof(wchar_t)));
+ mir_wstrcpy(res, ai->argv.w[1]);
+ wchar_t *cur = res + mir_wstrlen(ai->argv.w[1]);
for (unsigned int i = 0; i < addcount; i++)
*cur++ = padchar;
@@ -315,15 +315,15 @@ static wchar_t *parsePadcut(ARGUMENTSINFO *ai) wchar_t padchar;
switch (ai->argc) {
case 3: padchar = ' '; break;
- case 4: padchar = *ai->targv[3]; break;
+ case 4: padchar = *ai->argv.w[3]; break;
default: return nullptr;
}
- int padding = ttoi(ai->targv[2]);
+ int padding = ttoi(ai->argv.w[2]);
if (padding < 0)
return nullptr;
- int addcount = max(padding - (signed int)mir_wstrlen(ai->targv[1]), 0);
+ int addcount = max(padding - (signed int)mir_wstrlen(ai->argv.w[1]), 0);
wchar_t *res = (wchar_t*)mir_alloc((padding + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
@@ -334,7 +334,7 @@ static wchar_t *parsePadcut(ARGUMENTSINFO *ai) *cur++ = padchar;
if (padding > addcount)
- wcsncpy(res + addcount, ai->targv[1], padding - addcount);
+ wcsncpy(res + addcount, ai->argv.w[1], padding - addcount);
return res;
}
@@ -344,15 +344,15 @@ static wchar_t *parsePadcutright(ARGUMENTSINFO *ai) wchar_t padchar;
switch (ai->argc) {
case 3: padchar = ' '; break;
- case 4: padchar = *ai->targv[3]; break;
+ case 4: padchar = *ai->argv.w[3]; break;
default: return nullptr;
}
- int padding = ttoi(ai->targv[2]);
+ int padding = ttoi(ai->argv.w[2]);
if (padding < 0)
return nullptr;
- int addcount = max(padding - (signed int)mir_wstrlen(ai->targv[1]), 0);
+ int addcount = max(padding - (signed int)mir_wstrlen(ai->argv.w[1]), 0);
wchar_t *res = (wchar_t*)mir_alloc((padding + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
@@ -363,7 +363,7 @@ static wchar_t *parsePadcutright(ARGUMENTSINFO *ai) *cur++ = padchar;
if (padding > addcount)
- wcsncpy(res, ai->targv[1], padding - addcount);
+ wcsncpy(res, ai->argv.w[1], padding - addcount);
return res;
}
@@ -373,17 +373,17 @@ static wchar_t *parseRepeat(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- int count = ttoi(ai->targv[2]);
+ int count = ttoi(ai->argv.w[2]);
if (count < 0)
return nullptr;
- wchar_t *res = (wchar_t*)mir_alloc((count * mir_wstrlen(ai->targv[1]) + 1)*sizeof(wchar_t));
+ wchar_t *res = (wchar_t*)mir_alloc((count * mir_wstrlen(ai->argv.w[1]) + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
- memset(res, 0, ((count * mir_wstrlen(ai->targv[1]) + 1) * sizeof(wchar_t)));
+ memset(res, 0, ((count * mir_wstrlen(ai->argv.w[1]) + 1) * sizeof(wchar_t)));
for (int i = 0; i < count; i++)
- mir_wstrcat(res, ai->targv[1]);
+ mir_wstrcat(res, ai->argv.w[1]);
return res;
}
@@ -396,21 +396,21 @@ static wchar_t *parseReplace(ARGUMENTSINFO *ai) wchar_t *cur;
size_t pos = 0;
- wchar_t *res = mir_wstrdup(ai->targv[1]);
+ wchar_t *res = mir_wstrdup(ai->argv.w[1]);
for (size_t i = 2; i < ai->argc; i += 2) {
- if (mir_wstrlen(ai->targv[i]) == 0)
+ if (mir_wstrlen(ai->argv.w[i]) == 0)
continue;
for (pos = 0; pos<mir_wstrlen(res); pos++) {
cur = res + pos;
- if (!wcsncmp(cur, ai->targv[i], mir_wstrlen(ai->targv[i]))) {
- if (mir_wstrlen(ai->targv[i + 1]) > mir_wstrlen(ai->targv[i])) {
- res = (wchar_t*)mir_realloc(res, (mir_wstrlen(res) + mir_wstrlen(ai->targv[i + 1]) - mir_wstrlen(ai->targv[i]) + 1)*sizeof(wchar_t));
+ if (!wcsncmp(cur, ai->argv.w[i], mir_wstrlen(ai->argv.w[i]))) {
+ if (mir_wstrlen(ai->argv.w[i + 1]) > mir_wstrlen(ai->argv.w[i])) {
+ res = (wchar_t*)mir_realloc(res, (mir_wstrlen(res) + mir_wstrlen(ai->argv.w[i + 1]) - mir_wstrlen(ai->argv.w[i]) + 1)*sizeof(wchar_t));
cur = res + pos;
}
- memmove(cur + mir_wstrlen(ai->targv[i + 1]), cur + mir_wstrlen(ai->targv[i]), (mir_wstrlen(cur + mir_wstrlen(ai->targv[i])) + 1)*sizeof(wchar_t));
- memcpy(cur, ai->targv[i + 1], mir_wstrlen(ai->targv[i + 1])*sizeof(wchar_t));
- pos += mir_wstrlen(ai->targv[i + 1]) - 1;
+ memmove(cur + mir_wstrlen(ai->argv.w[i + 1]), cur + mir_wstrlen(ai->argv.w[i]), (mir_wstrlen(cur + mir_wstrlen(ai->argv.w[i])) + 1)*sizeof(wchar_t));
+ memcpy(cur, ai->argv.w[i + 1], mir_wstrlen(ai->argv.w[i + 1])*sizeof(wchar_t));
+ pos += mir_wstrlen(ai->argv.w[i + 1]) - 1;
}
}
res = (wchar_t*)mir_realloc(res, (mir_wstrlen(res) + 1)*sizeof(wchar_t));
@@ -424,17 +424,17 @@ static wchar_t *parseRight(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- int len = ttoi(ai->targv[2]);
+ int len = ttoi(ai->argv.w[2]);
if (len < 0)
return nullptr;
- len = min(len, (signed int)mir_wstrlen(ai->targv[1]));
+ len = min(len, (signed int)mir_wstrlen(ai->argv.w[1]));
wchar_t *res = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
memset(res, 0, ((len + 1)*sizeof(wchar_t)));
- wcsncpy(res, ai->targv[1] + mir_wstrlen(ai->targv[1]) - len, len);
+ wcsncpy(res, ai->argv.w[1] + mir_wstrlen(ai->argv.w[1]) - len, len);
return res;
}
@@ -446,21 +446,21 @@ static wchar_t *parseScroll(ARGUMENTSINFO *ai) if (ai->argc != 4)
return nullptr;
- if (mir_wstrlen(ai->targv[1]) == 0)
- return mir_wstrdup(ai->targv[1]);
+ if (mir_wstrlen(ai->argv.w[1]) == 0)
+ return mir_wstrdup(ai->argv.w[1]);
- size_t move = ttoi(ai->targv[3]) % mir_wstrlen(ai->targv[1]);
- size_t display = ttoi(ai->targv[2]);
- if (display > mir_wstrlen(ai->targv[1]))
- display = (unsigned)mir_wstrlen(ai->targv[1]);
+ size_t move = ttoi(ai->argv.w[3]) % mir_wstrlen(ai->argv.w[1]);
+ size_t display = ttoi(ai->argv.w[2]);
+ if (display > mir_wstrlen(ai->argv.w[1]))
+ display = (unsigned)mir_wstrlen(ai->argv.w[1]);
- wchar_t *res = (wchar_t*)mir_alloc((2 * mir_wstrlen(ai->targv[1]) + 1)*sizeof(wchar_t));
+ wchar_t *res = (wchar_t*)mir_alloc((2 * mir_wstrlen(ai->argv.w[1]) + 1)*sizeof(wchar_t));
if (res == nullptr)
return nullptr;
- memset(res, 0, ((2 * mir_wstrlen(ai->targv[1]) + 1) * sizeof(wchar_t)));
- mir_wstrcpy(res, ai->targv[1]);
- mir_wstrcat(res, ai->targv[1]);
+ memset(res, 0, ((2 * mir_wstrlen(ai->argv.w[1]) + 1) * sizeof(wchar_t)));
+ mir_wstrcpy(res, ai->argv.w[1]);
+ mir_wstrcat(res, ai->argv.w[1]);
memmove(res, res + move, (mir_wstrlen(res + move) + 1)*sizeof(wchar_t));
*(res + display) = 0;
res = (wchar_t*)mir_realloc(res, (mir_wstrlen(res) + 1)*sizeof(wchar_t));
@@ -475,10 +475,10 @@ static wchar_t *parseShortest(ARGUMENTSINFO *ai) int iShort = 1;
for (unsigned i = 2; i < ai->argc; i++)
- if (mir_wstrlen(ai->targv[i]) < mir_wstrlen(ai->targv[iShort]))
+ if (mir_wstrlen(ai->argv.w[i]) < mir_wstrlen(ai->argv.w[iShort]))
iShort = i;
- return mir_wstrdup(ai->targv[iShort]);
+ return mir_wstrdup(ai->argv.w[iShort]);
}
static wchar_t *parseStrchr(ARGUMENTSINFO *ai)
@@ -486,11 +486,11 @@ static wchar_t *parseStrchr(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- wchar_t *c = wcschr(ai->targv[1], *ai->targv[2]);
+ wchar_t *c = wcschr(ai->argv.w[1], *ai->argv.w[2]);
if (c == nullptr || *c == 0)
return mir_wstrdup(L"0");
- return itot(c - ai->targv[1] + 1);
+ return itot(c - ai->argv.w[1] + 1);
}
static wchar_t *parseStrcmp(ARGUMENTSINFO *ai)
@@ -498,7 +498,7 @@ static wchar_t *parseStrcmp(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- if (mir_wstrcmp(ai->targv[1], ai->targv[2]))
+ if (mir_wstrcmp(ai->argv.w[1], ai->argv.w[2]))
ai->flags |= AIF_FALSE;
return mir_wstrdup(L"");
@@ -511,7 +511,7 @@ static wchar_t *parseStrmcmp(ARGUMENTSINFO *ai) ai->flags |= AIF_FALSE;
for (unsigned i = 2; i < ai->argc; i++) {
- if (!mir_wstrcmp(ai->targv[1], ai->targv[i])) {
+ if (!mir_wstrcmp(ai->argv.w[1], ai->argv.w[i])) {
ai->flags &= ~AIF_FALSE;
break;
}
@@ -525,11 +525,11 @@ static wchar_t *parseStrncmp(ARGUMENTSINFO *ai) if (ai->argc != 4)
return nullptr;
- int n = ttoi(ai->targv[3]);
+ int n = ttoi(ai->argv.w[3]);
if (n <= 0)
return nullptr;
- if (wcsncmp(ai->targv[1], ai->targv[2], n))
+ if (wcsncmp(ai->argv.w[1], ai->argv.w[2], n))
ai->flags |= AIF_FALSE;
return mir_wstrdup(L"");
@@ -540,7 +540,7 @@ static wchar_t *parseStricmp(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- if (mir_wstrcmpi(ai->targv[1], ai->targv[2]))
+ if (mir_wstrcmpi(ai->argv.w[1], ai->argv.w[2]))
ai->flags |= AIF_FALSE;
return mir_wstrdup(L"");
@@ -551,11 +551,11 @@ static wchar_t *parseStrnicmp(ARGUMENTSINFO *ai) if (ai->argc != 4)
return nullptr;
- int n = ttoi(ai->targv[3]);
+ int n = ttoi(ai->argv.w[3]);
if (n <= 0)
return nullptr;
- if (wcsnicmp(ai->targv[1], ai->targv[2], n))
+ if (wcsnicmp(ai->argv.w[1], ai->argv.w[2], n))
ai->flags |= AIF_FALSE;
return mir_wstrdup(L"");
@@ -566,11 +566,11 @@ static wchar_t *parseStrrchr(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- wchar_t *c = wcsrchr(ai->targv[1], *ai->targv[2]);
+ wchar_t *c = wcsrchr(ai->argv.w[1], *ai->argv.w[2]);
if ((c == nullptr) || (*c == 0))
return mir_wstrdup(L"0");
- return itot(c - ai->targv[1] + 1);
+ return itot(c - ai->argv.w[1] + 1);
}
static wchar_t *parseStrstr(ARGUMENTSINFO *ai)
@@ -578,11 +578,11 @@ static wchar_t *parseStrstr(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- wchar_t *c = wcsstr(ai->targv[1], ai->targv[2]);
+ wchar_t *c = wcsstr(ai->argv.w[1], ai->argv.w[2]);
if ((c == nullptr) || (*c == 0))
return mir_wstrdup(L"0");
- return itot(c - ai->targv[1] + 1);
+ return itot(c - ai->argv.w[1] + 1);
}
static wchar_t *parseSubstr(ARGUMENTSINFO *ai)
@@ -590,18 +590,18 @@ static wchar_t *parseSubstr(ARGUMENTSINFO *ai) if (ai->argc < 3)
return nullptr;
- int to, from = max(ttoi(ai->targv[2]) - 1, 0);
+ int to, from = max(ttoi(ai->argv.w[2]) - 1, 0);
if (ai->argc > 3)
- to = min(ttoi(ai->targv[3]), (int)mir_wstrlen(ai->targv[1]));
+ to = min(ttoi(ai->argv.w[3]), (int)mir_wstrlen(ai->argv.w[1]));
else
- to = (int)mir_wstrlen(ai->targv[1]);
+ to = (int)mir_wstrlen(ai->argv.w[1]);
if (to < from)
return nullptr;
wchar_t *res = (wchar_t*)mir_alloc((to - from + 1)*sizeof(wchar_t));
memset(res, 0, ((to - from + 1) * sizeof(wchar_t)));
- wcsncpy(res, ai->targv[1] + from, to - from);
+ wcsncpy(res, ai->argv.w[1] + from, to - from);
return res;
}
@@ -610,11 +610,11 @@ static wchar_t *parseSelect(ARGUMENTSINFO *ai) if (ai->argc <= 1)
return nullptr;
- int n = ttoi(ai->targv[1]);
+ int n = ttoi(ai->argv.w[1]);
if ((n > (signed int)ai->argc - 2) || n <= 0)
return nullptr;
- return mir_wstrdup(ai->targv[n + 1]);
+ return mir_wstrdup(ai->argv.w[n + 1]);
}
static wchar_t *parseSwitch(ARGUMENTSINFO *ai)
@@ -623,8 +623,8 @@ static wchar_t *parseSwitch(ARGUMENTSINFO *ai) return nullptr;
for (unsigned i = 2; i < ai->argc; i += 2)
- if (!mir_wstrcmp(ai->targv[1], ai->targv[i]))
- return mir_wstrdup(ai->targv[i + 1]);
+ if (!mir_wstrcmp(ai->argv.w[1], ai->argv.w[i]))
+ return mir_wstrdup(ai->argv.w[i + 1]);
return nullptr;
}
@@ -634,12 +634,12 @@ static wchar_t *parseTrim(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- wchar_t *scur = ai->targv[1];
+ wchar_t *scur = ai->argv.w[1];
while (*scur == ' ')
scur++;
- wchar_t *ecur = ai->targv[1] + mir_wstrlen(ai->targv[1]) - 1;
- while ((*ecur == ' ') && (ecur > ai->targv[1]))
+ wchar_t *ecur = ai->argv.w[1] + mir_wstrlen(ai->argv.w[1]) - 1;
+ while ((*ecur == ' ') && (ecur > ai->argv.w[1]))
ecur--;
if (scur >= ecur)
@@ -658,8 +658,8 @@ static wchar_t *parseTrim(ARGUMENTSINFO *ai) static wchar_t *parseTab(ARGUMENTSINFO *ai)
{
int count = 1;
- if ((ai->argc == 2) && (mir_wstrlen(ai->targv[1]) > 0))
- count = ttoi(ai->targv[1]);
+ if ((ai->argc == 2) && (mir_wstrlen(ai->argv.w[1]) > 0))
+ count = ttoi(ai->argv.w[1]);
if (count < 0)
return nullptr;
@@ -681,7 +681,7 @@ static wchar_t *parseUpper(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- wchar_t *res = mir_wstrdup(ai->targv[1]);
+ wchar_t *res = mir_wstrdup(ai->argv.w[1]);
if (res == nullptr)
return nullptr;
@@ -731,10 +731,10 @@ static wchar_t *parseWord(ARGUMENTSINFO *ai) return nullptr;
wchar_t *res = nullptr;
- int to, from = ttoi(ai->targv[2]);
+ int to, from = ttoi(ai->argv.w[2]);
if (ai->argc == 4) {
- if (mir_wstrlen(ai->targv[3]) > 0)
- to = ttoi(ai->targv[3]);
+ if (mir_wstrlen(ai->argv.w[3]) > 0)
+ to = ttoi(ai->argv.w[3]);
else
to = 100000; // rework
}
@@ -744,7 +744,7 @@ static wchar_t *parseWord(ARGUMENTSINFO *ai) return nullptr;
for (int i = from; i <= to; i++) {
- wchar_t *szWord = getNthWord(ai->targv[1], i);
+ wchar_t *szWord = getNthWord(ai->argv.w[1], i);
if (szWord == nullptr)
return res;
@@ -769,10 +769,7 @@ static wchar_t *parseExtratext(ARGUMENTSINFO *ai) return nullptr;
ai->flags |= AIF_DONTPARSE;
- if (ai->fi->szExtraText != nullptr)
- return mir_wstrdup(ai->fi->tszExtraText);
-
- return nullptr;
+ return mir_wstrdup(ai->fi->szExtraText.w);
}
void registerStrTokens()
diff --git a/plugins/Variables/src/parse_system.cpp b/plugins/Variables/src/parse_system.cpp index 02bfdd4407..ae1d72c3d9 100644 --- a/plugins/Variables/src/parse_system.cpp +++ b/plugins/Variables/src/parse_system.cpp @@ -51,15 +51,15 @@ static wchar_t *parseCpuLoad(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- if (mir_wstrlen(ai->targv[1]) == 0)
+ if (mir_wstrlen(ai->argv.w[1]) == 0)
szCounter = mir_wstrdup(L"\\Processor(_Total)\\% Processor Time");
else {
- int size = (int)mir_wstrlen(ai->targv[1]) + 32;
+ int size = (int)mir_wstrlen(ai->argv.w[1]) + 32;
szCounter = (wchar_t *)mir_alloc(size * sizeof(wchar_t));
if (szCounter == nullptr)
return nullptr;
- mir_snwprintf(szCounter, size, L"\\Process(%s)\\%% Processor Time", ai->targv[1]);
+ mir_snwprintf(szCounter, size, L"\\Process(%s)\\%% Processor Time", ai->argv.w[1]);
}
PDH_STATUS pdhStatus = PdhValidatePath(szCounter);
if (pdhStatus != ERROR_SUCCESS) {
@@ -116,10 +116,10 @@ static wchar_t *parseCpuLoad(ARGUMENTSINFO *ai) static wchar_t *parseCurrentDate(ARGUMENTSINFO *ai)
{
wchar_t *szFormat;
- if (ai->argc == 1 || (ai->argc > 1 && mir_wstrlen(ai->targv[1]) == 0))
+ if (ai->argc == 1 || (ai->argc > 1 && mir_wstrlen(ai->argv.w[1]) == 0))
szFormat = nullptr;
else
- szFormat = ai->targv[1];
+ szFormat = ai->argv.w[1];
int len = GetDateFormat(LOCALE_USER_DEFAULT, 0, nullptr, szFormat, nullptr, 0);
wchar_t *res = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t));
@@ -137,10 +137,10 @@ static wchar_t *parseCurrentDate(ARGUMENTSINFO *ai) static wchar_t *parseCurrentTime(ARGUMENTSINFO *ai)
{
wchar_t *szFormat;
- if (ai->argc == 1 || (ai->argc > 1) && (mir_wstrlen(ai->targv[1]) == 0))
+ if (ai->argc == 1 || (ai->argc > 1) && (mir_wstrlen(ai->argv.w[1]) == 0))
szFormat = nullptr;
else
- szFormat = ai->targv[1];
+ szFormat = ai->argv.w[1];
int len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, nullptr, szFormat, nullptr, 0);
wchar_t *res = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t));
@@ -162,27 +162,27 @@ static wchar_t *parseDirectory(ARGUMENTSINFO *ai) int depth = 0;
if (ai->argc == 3)
- depth = ttoi(ai->targv[2]);
+ depth = ttoi(ai->argv.w[2]);
if (depth <= 0)
- return mir_wstrdup(ai->targv[1]);
+ return mir_wstrdup(ai->argv.w[1]);
size_t bi, ei;
- for (ei = 0; ei < mir_wstrlen(ai->targv[1]); ei++) {
- if (ai->targv[1][ei] == '\\')
+ for (ei = 0; ei < mir_wstrlen(ai->argv.w[1]); ei++) {
+ if (ai->argv.w[1][ei] == '\\')
depth--;
if (!depth)
break;
}
- if (ei >= mir_wstrlen(ai->targv[1]))
- return ai->targv[1];
+ if (ei >= mir_wstrlen(ai->argv.w[1]))
+ return ai->argv.w[1];
for (bi = ei - 1; bi > 0; bi--)
- if (ai->targv[1][bi - 1] == '\\')
+ if (ai->argv.w[1][bi - 1] == '\\')
break;
wchar_t *res = (wchar_t*)mir_alloc((ei - bi + 1) * sizeof(wchar_t));
- wcsncpy(res, ai->targv[1] + bi, ei - bi);
+ wcsncpy(res, ai->argv.w[1] + bi, ei - bi);
res[ei - bi] = 0;
return res;
}
@@ -198,14 +198,14 @@ static wchar_t *parseDirectory2(ARGUMENTSINFO *ai) int depth = 1;
if (ai->argc == 3)
- depth = ttoi(ai->targv[2]);
+ depth = ttoi(ai->argv.w[2]);
if (depth <= 0)
return nullptr;
- wchar_t *ecur = ai->targv[1] + mir_wstrlen(ai->targv[1]);
+ wchar_t *ecur = ai->argv.w[1] + mir_wstrlen(ai->argv.w[1]);
while (depth > 0) {
- while ((*ecur != '\\') && (ecur > ai->targv[1]))
+ while ((*ecur != '\\') && (ecur > ai->argv.w[1]))
ecur--;
if (*ecur != '\\')
@@ -214,11 +214,11 @@ static wchar_t *parseDirectory2(ARGUMENTSINFO *ai) depth -= 1;
ecur--;
}
- wchar_t *res = (wchar_t*)mir_calloc((ecur - ai->targv[1] + 2) * sizeof(wchar_t));
+ wchar_t *res = (wchar_t*)mir_calloc((ecur - ai->argv.w[1] + 2) * sizeof(wchar_t));
if (res == nullptr)
return nullptr;
- wcsncpy(res, ai->targv[1], (ecur - ai->targv[1]) + 1);
+ wcsncpy(res, ai->argv.w[1], (ecur - ai->argv.w[1]) + 1);
return res;
}
@@ -275,10 +275,10 @@ static wchar_t *parseDiffTime(ARGUMENTSINFO *ai) memset(&t0, 0, sizeof(t0));
memset(&t1, 0, sizeof(t1));
- if (getTime(ai->targv[1], &t0) != 0)
+ if (getTime(ai->argv.w[1], &t0) != 0)
return nullptr;
- if (getTime(ai->targv[2], &t1) != 0)
+ if (getTime(ai->argv.w[2], &t1) != 0)
return nullptr;
diff = difftime(mktime(&t1), mktime(&t0));
@@ -292,7 +292,7 @@ static wchar_t *parseDirExists(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- HANDLE hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
+ HANDLE hFile = CreateFile(ai->argv.w[1], GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile == INVALID_HANDLE_VALUE)
ai->flags |= AIF_FALSE;
else
@@ -306,7 +306,7 @@ static wchar_t *parseEnvironmentVariable(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- DWORD len = ExpandEnvironmentStrings(ai->targv[1], nullptr, 0);
+ DWORD len = ExpandEnvironmentStrings(ai->argv.w[1], nullptr, 0);
if (len <= 0)
return nullptr;
@@ -315,7 +315,7 @@ static wchar_t *parseEnvironmentVariable(ARGUMENTSINFO *ai) return nullptr;
memset(res, 0, ((len + 1) * sizeof(wchar_t)));
- if (ExpandEnvironmentStrings(ai->targv[1], res, len) == 0) {
+ if (ExpandEnvironmentStrings(ai->argv.w[1], res, len) == 0) {
mir_free(res);
return nullptr;
}
@@ -327,7 +327,7 @@ static wchar_t *parseFileExists(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- HANDLE hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
+ HANDLE hFile = CreateFile(ai->argv.w[1], GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE)
ai->flags |= AIF_FALSE;
else
@@ -341,7 +341,7 @@ static wchar_t *parseFindWindow(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- HWND hWin = FindWindow(ai->targv[1], nullptr);
+ HWND hWin = FindWindow(ai->argv.w[1], nullptr);
if (hWin == nullptr)
return nullptr;
@@ -371,19 +371,19 @@ static wchar_t *parseListDir(ARGUMENTSINFO *ai) tszRes = nullptr;
if (ai->argc > 1)
- wcsncpy(tszFirst, ai->targv[1], _countof(tszFirst) - 1);
+ wcsncpy(tszFirst, ai->argv.w[1], _countof(tszFirst) - 1);
if (ai->argc > 2)
- tszFilter = ai->targv[2];
+ tszFilter = ai->argv.w[2];
if (ai->argc > 3)
- tszSeperator = ai->targv[3];
+ tszSeperator = ai->argv.w[3];
BOOL bFiles = TRUE, bDirs = TRUE;
if (ai->argc > 4) {
- if (*ai->targv[4] == 'f')
+ if (*ai->argv.w[4] == 'f')
bDirs = FALSE;
- if (*ai->targv[4] == 'd')
+ if (*ai->argv.w[4] == 'd')
bFiles = FALSE;
}
if (tszFirst[mir_wstrlen(tszFirst) - 1] == '\\')
@@ -436,7 +436,7 @@ static wchar_t *parseProcessRunning(ARGUMENTSINFO *ai) return nullptr;
char *szProc, *ref;
- szProc = ref = mir_u2a(ai->targv[1]);
+ szProc = ref = mir_u2a(ai->argv.w[1]);
EnumProcs(MyProcessEnumerator, (LPARAM)&szProc);
if (szProc != nullptr)
@@ -454,7 +454,7 @@ static wchar_t *parseRegistryValue(ARGUMENTSINFO *ai) DWORD len, type;
- wchar_t *key = mir_wstrdup(ai->targv[1]);
+ wchar_t *key = mir_wstrdup(ai->argv.w[1]);
if (key == nullptr)
return nullptr;
@@ -490,7 +490,7 @@ static wchar_t *parseRegistryValue(ARGUMENTSINFO *ai) return nullptr;
memset(res, 0, (len * sizeof(wchar_t)));
- int err = RegQueryValueEx(hKey, ai->targv[2], nullptr, &type, (BYTE*)res, &len);
+ int err = RegQueryValueEx(hKey, ai->argv.w[2], nullptr, &type, (BYTE*)res, &len);
if ((err != ERROR_SUCCESS) || (type != REG_SZ)) {
RegCloseKey(hKey);
mir_free(res);
@@ -526,14 +526,14 @@ static wchar_t *parseTimestamp2Date(ARGUMENTSINFO *ai) SYSTEMTIME sysTime;
wchar_t *szFormat;
- time_t timestamp = ttoi(ai->targv[1]);
+ time_t timestamp = ttoi(ai->argv.w[1]);
if (timestamp == 0)
return nullptr;
- if ((ai->argc == 2) || ((ai->argc > 2) && (mir_wstrlen(ai->targv[2]) == 0)))
+ if ((ai->argc == 2) || ((ai->argc > 2) && (mir_wstrlen(ai->argv.w[2]) == 0)))
szFormat = nullptr;
else
- szFormat = ai->targv[2];
+ szFormat = ai->argv.w[2];
if (TsToSystemTime(&sysTime, timestamp) != 0)
return nullptr;
@@ -557,15 +557,15 @@ static wchar_t *parseTimestamp2Time(ARGUMENTSINFO *ai) return nullptr;
SYSTEMTIME sysTime;
- time_t timestamp = ttoi(ai->targv[1]);
+ time_t timestamp = ttoi(ai->argv.w[1]);
if (timestamp == 0)
return nullptr;
wchar_t *szFormat;
- if ((ai->argc == 2) || ((ai->argc > 2) && (mir_wstrlen(ai->targv[2]) == 0)))
+ if ((ai->argc == 2) || ((ai->argc > 2) && (mir_wstrlen(ai->argv.w[2]) == 0)))
szFormat = nullptr;
else
- szFormat = ai->targv[2];
+ szFormat = ai->argv.w[2];
if (TsToSystemTime(&sysTime, timestamp) != 0)
return nullptr;
@@ -588,7 +588,7 @@ static wchar_t *parseTextFile(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- HANDLE hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
+ HANDLE hFile = CreateFile(ai->argv.w[1], GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
if (hFile == INVALID_HANDLE_VALUE)
return nullptr;
@@ -598,7 +598,7 @@ static wchar_t *parseTextFile(ARGUMENTSINFO *ai) return nullptr;
}
- int lineNo = ttoi(ai->targv[2]);
+ int lineNo = ttoi(ai->argv.w[2]);
int lineCount, csz;
unsigned int icur, bufSz;
DWORD readSz, totalReadSz;
@@ -615,7 +615,7 @@ static wchar_t *parseTextFile(ARGUMENTSINFO *ai) totalReadSz = 0;
lineCount = 1;
- if (*ai->targv[2] == '0') {
+ if (*ai->argv.w[2] == '0') {
// complete file
bufSz = fileSz + csz;
pBuf = (PBYTE)mir_calloc(bufSz);
@@ -680,7 +680,7 @@ static wchar_t *parseTextFile(ARGUMENTSINFO *ai) if (lineNo < 0)
lineNo = lineCount + lineNo + 1;
- else if (*ai->targv[2] == 'r')
+ else if (*ai->argv.w[2] == 'r')
lineNo = (rand() % lineCount) + 1;
totalReadSz = 0;
diff --git a/plugins/Variables/src/parse_variables.cpp b/plugins/Variables/src/parse_variables.cpp index 6fce6cd3fb..449352abd0 100644 --- a/plugins/Variables/src/parse_variables.cpp +++ b/plugins/Variables/src/parse_variables.cpp @@ -67,13 +67,13 @@ static wchar_t *parsePut(ARGUMENTSINFO *ai) return nullptr;
// ai->flags |= AIF_DONTPARSE;
- if (addToVariablesRegister(ai->targv[1], ai->targv[2]))
+ if (addToVariablesRegister(ai->argv.w[1], ai->argv.w[2]))
return nullptr;
FORMATINFO fi;
memcpy(&fi, ai->fi, sizeof(fi));
- fi.tszFormat = ai->targv[2];
- fi.flags |= FIF_TCHAR;
+ fi.szFormat.w = ai->argv.w[2];
+ fi.flags |= FIF_UNICODE;
return formatString(&fi);
}
@@ -82,7 +82,7 @@ static wchar_t *parsePuts(ARGUMENTSINFO *ai) if (ai->argc != 3)
return nullptr;
- if (addToVariablesRegister(ai->targv[1], ai->targv[2]))
+ if (addToVariablesRegister(ai->argv.w[1], ai->argv.w[2]))
return nullptr;
return mir_wstrdup(L"");
@@ -93,7 +93,7 @@ static wchar_t *parseGet(ARGUMENTSINFO *ai) if (ai->argc != 2)
return nullptr;
- return searchVariableRegister(ai->targv[1]);
+ return searchVariableRegister(ai->argv.w[1]);
}
void registerVariablesTokens()
diff --git a/plugins/Variables/src/stdafx.h b/plugins/Variables/src/stdafx.h index ee25d7bdbd..ef895be881 100644 --- a/plugins/Variables/src/stdafx.h +++ b/plugins/Variables/src/stdafx.h @@ -140,16 +140,6 @@ The contact function will return either a unique contact according to the argume // if a different struct internally is used, we can use TOKENREGISTEREX
#define TOKENREGISTEREX TOKENREGISTER
-// old struct
-typedef struct {
- int cbSize;
- char *szFormat;
- char *szSource;
- MCONTACT hContact;
- int pCount; // number of succesful parses
- int eCount; // number of failures
-} FORMATINFOV1;
-
struct ParseOptions {
BOOL bStripEOL;
BOOL bStripWS;
@@ -172,8 +162,7 @@ TOKENREGISTEREX *searchRegister(wchar_t *var, int type); wchar_t *parseFromRegister(ARGUMENTSINFO *ai);
TOKENREGISTEREX *getTokenRegister(int i);
int getTokenRegisterCount();
-TOKENREGISTER *getTokenRegisterByIndex(int i);
-void deRegisterTemporaryVariables();
+
int initTokenRegister();
int deinitTokenRegister();
// contact.c
diff --git a/plugins/Variables/src/tokenregister.cpp b/plugins/Variables/src/tokenregister.cpp index 77c6af4252..12838ec7fa 100644 --- a/plugins/Variables/src/tokenregister.cpp +++ b/plugins/Variables/src/tokenregister.cpp @@ -59,8 +59,8 @@ int registerIntToken(wchar_t *szToken, wchar_t *(*parseFunction)(ARGUMENTSINFO * //tr.memType = TR_MEM_VARIABLES;
tr.memType = TR_MEM_MIRANDA;
tr.szHelpText = szHelpText;
- tr.tszTokenString = szToken;
- tr.parseFunctionT = parseFunction;
+ tr.szTokenString.w = szToken;
+ tr.parseFunctionW = parseFunction;
return registerToken(0, (LPARAM)&tr);
}
@@ -83,8 +83,8 @@ int deRegisterToken(wchar_t *token) if (!(tre->tr.flags & TRF_PARSEFUNC) && tre->tr.szService != nullptr)
mir_free(tre->tr.szService);
- if (tre->tr.tszTokenString != nullptr)
- mir_free(tre->tr.tszTokenString);
+ if (tre->tr.szTokenString.w != nullptr)
+ mir_free(tre->tr.szTokenString.w);
if (tre->tr.szHelpText != nullptr)
mir_free(tre->tr.szHelpText);
@@ -101,15 +101,15 @@ INT_PTR registerToken(WPARAM, LPARAM lParam) DWORD hash;
TOKENREGISTEREX *newVr = (TOKENREGISTEREX*)lParam;
- if (newVr == nullptr || newVr->szTokenString == nullptr || newVr->cbSize <= 0)
+ if (newVr == nullptr || newVr->szTokenString.w == nullptr || newVr->cbSize <= 0)
return -1;
if (newVr->flags & TRF_TCHAR) {
- deRegisterToken(newVr->tszTokenString);
- hash = NameHashFunction(newVr->tszTokenString);
+ deRegisterToken(newVr->szTokenString.w);
+ hash = NameHashFunction(newVr->szTokenString.w);
}
else {
- WCHAR *wtoken = mir_a2u(newVr->szTokenString);
+ wchar_t *wtoken = mir_a2u(newVr->szTokenString.a);
deRegisterToken(wtoken);
hash = NameHashFunction(wtoken);
mir_free(wtoken);
@@ -121,16 +121,16 @@ INT_PTR registerToken(WPARAM, LPARAM lParam) memcpy(&tre->tr, newVr, newVr->cbSize);
tre->nameHash = hash;
- if (!mir_wstrcmp(newVr->tszTokenString, L"alias"))
+ if (!mir_wstrcmp(newVr->szTokenString.w, L"alias"))
log_debugA("alias");
if (!(newVr->flags & TRF_PARSEFUNC) && newVr->szService != nullptr)
tre->tr.szService = mir_strdup(newVr->szService);
if (newVr->flags & TRF_TCHAR)
- tre->tr.tszTokenString = mir_wstrdup(newVr->tszTokenString);
+ tre->tr.szTokenString.w = mir_wstrdup(newVr->szTokenString.w);
else
- tre->tr.tszTokenString = mir_a2u(newVr->szTokenString);
+ tre->tr.szTokenString.w = mir_a2u(newVr->szTokenString.a);
if (newVr->szHelpText != nullptr)
tre->tr.szHelpText = mir_strdup(newVr->szHelpText);
@@ -158,7 +158,7 @@ TOKENREGISTEREX *searchRegister(wchar_t *tvar, int type) wchar_t *parseFromRegister(ARGUMENTSINFO *ai)
{
- if (ai == nullptr || ai->argc == 0 || ai->targv[0] == nullptr)
+ if (ai == nullptr || ai->argc == 0 || ai->argv.w[0] == nullptr)
return nullptr;
INT_PTR callRes = 0;
@@ -167,7 +167,7 @@ wchar_t *parseFromRegister(ARGUMENTSINFO *ai) mir_cslock lck(csRegister);
/* note the following limitation: you cannot add/remove tokens during a call from a different thread */
- TOKENREGISTEREX *thisVr = searchRegister(ai->targv[0], 0);
+ TOKENREGISTEREX *thisVr = searchRegister(ai->argv.w[0], 0);
if (thisVr == nullptr)
return nullptr;
@@ -178,9 +178,9 @@ wchar_t *parseFromRegister(ARGUMENTSINFO *ai) // unicode variables calls a non-unicode plugin
ARGUMENTSINFO cAi;
memcpy(&cAi, ai, sizeof(ARGUMENTSINFO));
- cAi.argv = (char**)mir_alloc(ai->argc*sizeof(char *));
+ cAi.argv.a = (char**)mir_alloc(ai->argc*sizeof(char *));
for (unsigned j = 0; j < ai->argc; j++)
- cAi.argv[j] = mir_u2a(ai->targv[j]);
+ cAi.argv.a[j] = mir_u2a(ai->argv.w[j]);
if (thisVr->flags & TRF_PARSEFUNC)
callRes = (INT_PTR)thisVr->parseFunction(&cAi);
@@ -188,7 +188,7 @@ wchar_t *parseFromRegister(ARGUMENTSINFO *ai) callRes = CallService(thisVr->szService, 0, (LPARAM)&cAi);
for (unsigned j = 0; j < cAi.argc; j++)
- mir_free(cAi.argv[j]);
+ mir_free(cAi.argv.a[j]);
if ((char *)callRes != nullptr)
res = mir_a2u((char*)callRes);
@@ -196,7 +196,7 @@ wchar_t *parseFromRegister(ARGUMENTSINFO *ai) else {
// unicode variables calls unicode plugin
if (thisVr->flags & TRF_PARSEFUNC)
- callRes = (INT_PTR)thisVr->parseFunctionT(ai);
+ callRes = (INT_PTR)thisVr->parseFunctionW(ai);
else if (thisVr->szService != nullptr)
callRes = CallService(thisVr->szService, 0, (LPARAM)ai);
@@ -207,7 +207,7 @@ wchar_t *parseFromRegister(ARGUMENTSINFO *ai) if (callRes != NULL) {
if (trCopy.flags & TRF_CLEANUP) {
if (trCopy.flags & TRF_CLEANUPFUNC)
- trCopy.cleanupFunctionT((wchar_t*)callRes);
+ trCopy.cleanupFunctionW((wchar_t*)callRes);
else if (trCopy.szCleanupService != nullptr)
CallService(trCopy.szCleanupService, 0, (LPARAM)callRes);
}
@@ -242,8 +242,8 @@ int deinitTokenRegister() if (!(tre->tr.flags & TRF_PARSEFUNC) && tre->tr.szService != nullptr)
mir_free(tre->tr.szService);
- if (tre->tr.tszTokenString != nullptr)
- mir_free(tre->tr.tszTokenString);
+ if (tre->tr.szTokenString.w != nullptr)
+ mir_free(tre->tr.szTokenString.w);
if (tre->tr.szHelpText != nullptr)
mir_free(tre->tr.szHelpText);
diff --git a/plugins/Variables/src/variables.cpp b/plugins/Variables/src/variables.cpp index 76a6551c73..2db71497a4 100644 --- a/plugins/Variables/src/variables.cpp +++ b/plugins/Variables/src/variables.cpp @@ -105,12 +105,12 @@ int isValidTokenChar(wchar_t tc) /* pretty much the main loop */ static wchar_t* replaceDynVars(FORMATINFO *fi) { - if (fi->tszFormat == nullptr) + if (fi->szFormat.w == nullptr) return nullptr; int i, scurPos, curPos, tmpVarPos; - wchar_t *string = mir_wstrdup(fi->tszFormat); + wchar_t *string = mir_wstrdup(fi->szFormat.w); if (string == nullptr) return nullptr; @@ -187,7 +187,7 @@ static wchar_t* replaceDynVars(FORMATINFO *fi) tmpVarPos = -1; if (*cur == FIELD_CHAR) { for (i = 0; i < fi->cbTemporaryVarsSize; i += 2) { - if (!mir_wstrcmp(fi->tszaTemporaryVars[i], token)) { + if (!mir_wstrcmp(fi->szTemporaryVars.w[i], token)) { tmpVarPos = i; break; } @@ -206,7 +206,7 @@ static wchar_t* replaceDynVars(FORMATINFO *fi) scur = cur; // store this pointer for later use if (*cur == FIELD_CHAR) { - size_t len = mir_wstrlen(tr != nullptr ? tr->tszTokenString : fi->tszaTemporaryVars[tmpVarPos]); + size_t len = mir_wstrlen(tr != nullptr ? tr->szTokenString.w : fi->szTemporaryVars.w[tmpVarPos]); cur++; if (cur[len] != FIELD_CHAR) { // the next char after the token should be % fi->eCount++; @@ -215,7 +215,7 @@ static wchar_t* replaceDynVars(FORMATINFO *fi) cur += len + 1; } else if ((*cur == FUNC_CHAR) || (*cur == FUNC_ONCE_CHAR)) { - cur += mir_wstrlen(tr->tszTokenString) + 1; + cur += mir_wstrlen(tr->szTokenString.w) + 1; wchar_t *argcur = getArguments(cur, argv); if (argcur == cur || argcur == nullptr) { fi->eCount++; @@ -228,12 +228,12 @@ static wchar_t* replaceDynVars(FORMATINFO *fi) if (tr->flags & TRF_UNPARSEDARGS) continue; - afi.tszFormat = argv[i]; + afi.szFormat.w = argv[i]; afi.eCount = afi.pCount = 0; argv.put(i, formatString(&afi)); fi->eCount += afi.eCount; fi->pCount += afi.pCount; - mir_free(afi.szFormat); + mir_free(afi.szFormat.w); } } @@ -241,18 +241,18 @@ static wchar_t* replaceDynVars(FORMATINFO *fi) ARGUMENTSINFO ai = { 0 }; ptrW parsedToken; if (tr != nullptr) { - argv.insert(mir_wstrdup(tr->tszTokenString), 0); + argv.insert(mir_wstrdup(tr->szTokenString.w), 0); ai.cbSize = sizeof(ai); ai.argc = argv.getCount(); - ai.targv = argv.getArray(); + ai.argv.w = argv.getArray(); ai.fi = fi; if ((*scur == FUNC_ONCE_CHAR) || (*scur == FIELD_CHAR)) ai.flags |= AIF_DONTPARSE; parsedToken = parseFromRegister(&ai); } - else parsedToken = mir_wstrdup(fi->tszaTemporaryVars[tmpVarPos + 1]); + else parsedToken = mir_wstrdup(fi->szTemporaryVars.w[tmpVarPos + 1]); argv.destroy(); @@ -302,56 +302,34 @@ static wchar_t* replaceDynVars(FORMATINFO *fi) */ static INT_PTR formatStringService(WPARAM wParam, LPARAM) { - INT_PTR res; - int i; - BOOL copied; - FORMATINFO *fi, tempFi; - wchar_t *tszFormat, *orgFormat, *tszSource, *orgSource, *tRes; - - if (((FORMATINFO *)wParam)->cbSize >= sizeof(FORMATINFO)) { - memset(&tempFi, 0, sizeof(FORMATINFO)); - memcpy(&tempFi, (FORMATINFO *)wParam, sizeof(FORMATINFO)); - fi = &tempFi; - } - else if (((FORMATINFO *)wParam)->cbSize == FORMATINFOV2_SIZE) { - memset(&tempFi, 0, sizeof(FORMATINFO)); - memcpy(&tempFi, (FORMATINFO *)wParam, FORMATINFOV2_SIZE); - fi = &tempFi; - } - else { - // old struct, must be ANSI - FORMATINFOV1 *fiv1 = (FORMATINFOV1 *)wParam; - memset(&tempFi, 0, sizeof(FORMATINFO)); - tempFi.cbSize = sizeof(FORMATINFO); - tempFi.hContact = fiv1->hContact; - tempFi.szFormat = fiv1->szFormat; - tempFi.szExtraText = fiv1->szSource; - fi = &tempFi; - } - orgFormat = fi->tszFormat; - orgSource = fi->tszExtraText; - - if (!(fi->flags & FIF_TCHAR)) { - copied = TRUE; - log_debugA("mir_a2u (%s)", fi->szExtraText); - tszFormat = fi->szFormat != nullptr ? mir_a2u(fi->szFormat) : nullptr; - tszSource = fi->szExtraText != nullptr ? mir_a2u(fi->szExtraText) : nullptr; - for (i = 0; i < fi->cbTemporaryVarsSize; i++) { - fi->tszaTemporaryVars[i] = fi->szaTemporaryVars[i] != nullptr ? mir_a2u(fi->szaTemporaryVars[i]) : nullptr; - } + FORMATINFO *pfi = (FORMATINFO*)wParam; + if (pfi->cbSize != sizeof(FORMATINFO)) + return 0; + + // prevent the original structure from being altered + FORMATINFO tmpfi = *pfi; + bool copied; + wchar_t *tszFormat, *tszSource; + if (tmpfi.flags & FIF_UNICODE) { + copied = false; + tszFormat = tmpfi.szFormat.w; + tszSource = tmpfi.szExtraText.w; } else { - copied = FALSE; - tszFormat = fi->tszFormat; - tszSource = fi->tszExtraText; + copied = true; + tszFormat = mir_a2u(tmpfi.szFormat.a); + tszSource = mir_a2u(tmpfi.szExtraText.a); + for (int i = 0; i < tmpfi.cbTemporaryVarsSize; i++) + tmpfi.szTemporaryVars.w[i] = mir_a2u(tmpfi.szTemporaryVars.a[i]); } - fi->tszFormat = tszFormat; - fi->tszExtraText = tszSource; + tmpfi.szFormat.w = tszFormat; + tmpfi.szExtraText.w = tszSource; - tRes = formatString(fi); + wchar_t *tRes = formatString(&tmpfi); - if (!(fi->flags & FIF_TCHAR)) { + INT_PTR res; + if (!(tmpfi.flags & FIF_UNICODE)) { res = (INT_PTR)mir_u2a(tRes); mir_free(tRes); } @@ -360,19 +338,12 @@ static INT_PTR formatStringService(WPARAM wParam, LPARAM) if (copied) { mir_free(tszFormat); mir_free(tszSource); - for (i = 0; i < fi->cbTemporaryVarsSize; i++) - mir_free(fi->tszaTemporaryVars); - } - - if (((FORMATINFO *)wParam)->cbSize == sizeof(FORMATINFOV1)) { - ((FORMATINFOV1 *)wParam)->eCount = fi->eCount; - ((FORMATINFOV1 *)wParam)->pCount = fi->pCount; - } - else { - ((FORMATINFO *)wParam)->eCount = fi->eCount; - ((FORMATINFO *)wParam)->pCount = fi->pCount; + for (int i = 0; i < tmpfi.cbTemporaryVarsSize; i++) + mir_free(tmpfi.szTemporaryVars.w); } + ((FORMATINFO *)wParam)->eCount = tmpfi.eCount; + ((FORMATINFO *)wParam)->pCount = tmpfi.pCount; return res; } @@ -450,10 +421,10 @@ int LoadVarModule() if (db_get_b(NULL, MODULENAME, SETTING_PARSEATSTARTUP, 0)) { FORMATINFO fi = { 0 }; fi.cbSize = sizeof(fi); - fi.tszFormat = db_get_wsa(NULL, MODULENAME, SETTING_STARTUPTEXT); - if (fi.tszFormat != nullptr) { + fi.szFormat.w = db_get_wsa(NULL, MODULENAME, SETTING_STARTUPTEXT); + if (fi.szFormat.w != nullptr) { mir_free(formatString(&fi)); - mir_free(fi.tszFormat); + mir_free(fi.szFormat.w); } } log_debugA("Variables: Init done"); |