summaryrefslogtreecommitdiff
path: root/plugins/Variables
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Variables')
-rw-r--r--plugins/Variables/src/help.cpp52
-rw-r--r--plugins/Variables/src/parse_alias.cpp10
-rw-r--r--plugins/Variables/src/parse_inet.cpp8
-rw-r--r--plugins/Variables/src/parse_logic.cpp60
-rw-r--r--plugins/Variables/src/parse_math.cpp38
-rw-r--r--plugins/Variables/src/parse_metacontacts.cpp6
-rw-r--r--plugins/Variables/src/parse_miranda.cpp66
-rw-r--r--plugins/Variables/src/parse_regexp.cpp12
-rw-r--r--plugins/Variables/src/parse_str.cpp219
-rw-r--r--plugins/Variables/src/parse_system.cpp90
-rw-r--r--plugins/Variables/src/parse_variables.cpp10
-rw-r--r--plugins/Variables/src/stdafx.h13
-rw-r--r--plugins/Variables/src/tokenregister.cpp40
-rw-r--r--plugins/Variables/src/variables.cpp107
14 files changed, 344 insertions, 387 deletions
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");