summaryrefslogtreecommitdiff
path: root/plugins/Spamotron
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-07-26 09:20:25 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-07-26 09:20:25 +0000
commit6e53dfca72b932c4bdcd7aa02ca62bf8b2630eac (patch)
tree2e8bb660c908b54914abd562af8aafa4a486c846 /plugins/Spamotron
parenta61c8728b379057fe7f0a0d86fe0b037598229dd (diff)
less TCHARs:
- TCHAR is replaced with wchar_t everywhere; - LPGENT replaced with either LPGENW or LPGEN; - fixes for ANSI plugins that improperly used _t functions; - TCHAR *t removed from MAllStrings; - ptszGroup, ptszTitle & ptszTab in OPTIONSDIALOGPAGE replaced with pwsz* git-svn-id: http://svn.miranda-ng.org/main/trunk@17133 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Spamotron')
-rw-r--r--plugins/Spamotron/src/bayes.cpp14
-rw-r--r--plugins/Spamotron/src/options.cpp76
-rw-r--r--plugins/Spamotron/src/popups.cpp12
-rw-r--r--plugins/Spamotron/src/spamotron.cpp26
-rw-r--r--plugins/Spamotron/src/stdafx.h42
-rw-r--r--plugins/Spamotron/src/utils.cpp120
6 files changed, 145 insertions, 145 deletions
diff --git a/plugins/Spamotron/src/bayes.cpp b/plugins/Spamotron/src/bayes.cpp
index d6d582a59b..aa377760a7 100644
--- a/plugins/Spamotron/src/bayes.cpp
+++ b/plugins/Spamotron/src/bayes.cpp
@@ -177,7 +177,7 @@ int get_token_score(int type, char *token)
return score;
}
-double get_msg_score(TCHAR *msg)
+double get_msg_score(wchar_t *msg)
{
char *message, *token;
double spam_prob, ham_prob, tmp1 = 1, tmp2 = 1;
@@ -220,7 +220,7 @@ double get_msg_score(TCHAR *msg)
return tmp1 / (tmp1 + tmp2);
}
-void queue_message(MCONTACT hContact, DWORD msgtime, TCHAR *message)
+void queue_message(MCONTACT hContact, DWORD msgtime, wchar_t *message)
{
char *tmp;
sqlite3_stmt *stmt;
@@ -247,7 +247,7 @@ void queue_message(MCONTACT hContact, DWORD msgtime, TCHAR *message)
void bayes_approve_contact(MCONTACT hContact)
{
const char *message;
- TCHAR *messageW;
+ wchar_t *messageW;
int d = 0;
sqlite3_stmt *stmt;
@@ -279,7 +279,7 @@ void dequeue_messages()
time_t t = time(NULL);
sqlite3_stmt *stmt;
const char *message;
- TCHAR *messageW;
+ wchar_t *messageW;
int d = 0;
if (bayesdb == NULL)
@@ -306,7 +306,7 @@ void dequeue_messages()
}
/* Learn one message as either SPAM or HAM as specified in type parameter */
-void learn(int type, TCHAR *msg)
+void learn(int type, wchar_t *msg)
{
char *tok, *message;
BYTE digest[16];
@@ -375,12 +375,12 @@ void learn(int type, TCHAR *msg)
mir_free(message);
}
-void learn_ham(TCHAR *msg)
+void learn_ham(wchar_t *msg)
{
learn(0, msg);
}
-void learn_spam(TCHAR *msg)
+void learn_spam(wchar_t *msg)
{
learn(1, msg);
} \ No newline at end of file
diff --git a/plugins/Spamotron/src/options.cpp b/plugins/Spamotron/src/options.cpp
index 5bf7c8a4d6..7f20587abc 100644
--- a/plugins/Spamotron/src/options.cpp
+++ b/plugins/Spamotron/src/options.cpp
@@ -1,31 +1,31 @@
#include "stdafx.h"
-TCHAR currentResponse[256] = {0};
+wchar_t currentResponse[256] = {0};
-TCHAR* _getCOptS(TCHAR *buf, unsigned int buflen, MCONTACT hContact, const char* option, const TCHAR *def)
+wchar_t* _getCOptS(wchar_t *buf, unsigned int buflen, MCONTACT hContact, const char* option, const wchar_t *def)
{
DBVARIANT dbv = {0};
_tcsnset(buf, 0, buflen);
if (db_get_ts(hContact, PLUGIN_NAME, option, &dbv) != 0)
- _tcsncpy(buf, def, min(buflen, mir_tstrlen(def)+1));
+ wcsncpy(buf, def, min(buflen, mir_tstrlen(def)+1));
else if (dbv.type == DBVT_TCHAR) {
- _tcsncpy(buf, dbv.ptszVal, min(buflen, mir_tstrlen(dbv.ptszVal)+1));
+ wcsncpy(buf, dbv.ptszVal, min(buflen, mir_tstrlen(dbv.ptszVal)+1));
}
db_free(&dbv);
return buf;
}
-TCHAR* _getMOptS(TCHAR *buf, unsigned int buflen, const char* module, const char* option, const TCHAR *def)
+wchar_t* _getMOptS(wchar_t *buf, unsigned int buflen, const char* module, const char* option, const wchar_t *def)
{
- TCHAR* tmp;
+ wchar_t* tmp;
DBVARIANT dbv = {0};
_tcsnset(buf, 0, buflen);
if (db_get_s(NULL, module, option, &dbv) != 0)
- _tcsncpy(buf, def, min(buflen, mir_tstrlen(def)+1));
+ wcsncpy(buf, def, min(buflen, mir_tstrlen(def)+1));
else if (dbv.type == DBVT_TCHAR) {
- _tcsncpy(buf, dbv.ptszVal, min(buflen, mir_tstrlen(dbv.ptszVal)+1));
+ wcsncpy(buf, dbv.ptszVal, min(buflen, mir_tstrlen(dbv.ptszVal)+1));
} else {
tmp = mir_a2u(dbv.pszVal);
- _tcsncpy(buf, tmp, min(buflen, mir_tstrlen(tmp)+1));
+ wcsncpy(buf, tmp, min(buflen, mir_tstrlen(tmp)+1));
mir_free(tmp);
}
db_free(&dbv);
@@ -36,9 +36,9 @@ TCHAR* _getMOptS(TCHAR *buf, unsigned int buflen, const char* module, const char
BOOL _saveDlgItemText(HWND hDialog, int controlID, char* option)
{
int len;
- TCHAR *tmp;
+ wchar_t *tmp;
len = GetWindowTextLength(GetDlgItem(hDialog, controlID));
- tmp = (TCHAR *)malloc((len + 1)*sizeof(TCHAR));
+ tmp = (wchar_t *)malloc((len + 1)*sizeof(wchar_t));
GetDlgItemText(hDialog, controlID, tmp, len + 1);
_setOptTS(option, tmp);
free(tmp);
@@ -49,9 +49,9 @@ int _saveDlgItemResponse(HWND hDialog, int controlID, char* option)
int ret = 0;
int isRegex = 0;
int len;
- TCHAR *tmp;
+ wchar_t *tmp;
len = GetWindowTextLength(GetDlgItem(hDialog, controlID));
- tmp = (TCHAR*)malloc((len+1)*sizeof(TCHAR));
+ tmp = (wchar_t*)malloc((len+1)*sizeof(wchar_t));
GetDlgItemText(hDialog, controlID, tmp, len+1);
isRegex = _isregex(tmp);
if (!isRegex)
@@ -68,20 +68,20 @@ int _saveDlgItemResponse(HWND hDialog, int controlID, char* option)
BOOL _saveDlgItemInt(HWND hDialog, int controlID, char* option)
{
int len;
- TCHAR *tmp;
+ wchar_t *tmp;
len = GetWindowTextLength(GetDlgItem(hDialog, controlID));
- tmp = (TCHAR *)malloc((len + 1)*sizeof(TCHAR));
+ tmp = (wchar_t *)malloc((len + 1)*sizeof(wchar_t));
GetDlgItemText(hDialog, controlID, tmp, len + 1);
- _setOptD(option, _ttoi(tmp));
+ _setOptD(option, _wtoi(tmp));
free(tmp);
return TRUE;
}
BOOL _saveDlgItemScore(HWND hDialog, int controlID, char* option)
{
int len;
- TCHAR *tmp;
+ wchar_t *tmp;
len = GetWindowTextLength(GetDlgItem(hDialog, controlID));
- tmp = (TCHAR *)malloc((len + 1)*sizeof(TCHAR));
+ tmp = (wchar_t *)malloc((len + 1)*sizeof(wchar_t));
GetDlgItemText(hDialog, controlID, tmp, len + 1);
_setOptD(option, _tcstod(tmp, NULL)/SCORE_C);
return TRUE;
@@ -93,12 +93,12 @@ INT_PTR CALLBACK DlgProcOptionsMain(HWND optDlg, UINT msg, WPARAM wParam, LPARAM
{
static int bInitializing = 0, i, j, numProtocols;
PROTOACCOUNT **pd;
- TCHAR pName[256] = {0};
+ wchar_t pName[256] = {0};
char protoOption[256] = {0};
HWND hProtocolsList = GetDlgItem(optDlg, IDC_OPT_PROTOCOLS);
LVITEM lvi = {0};
LVCOLUMN lvc = {0};
- TCHAR buf[512];
+ wchar_t buf[512];
switch (msg) {
case WM_INITDIALOG:
@@ -115,8 +115,8 @@ INT_PTR CALLBACK DlgProcOptionsMain(HWND optDlg, UINT msg, WPARAM wParam, LPARAM
CheckDlgButton(optDlg, IDC_OPT_LOG_ACTIONS, _getOptB("LogActions", defaultLogActions) ? BST_CHECKED : BST_UNCHECKED);
SetDlgItemText(optDlg, IDC_OPT_IN_MSG_APPROVE_WORDLIST, _getOptS(buf, _countof(buf), "ApproveOnMsgInWordlist", defaultApproveOnMsgInWordlist));
- SetDlgItemText(optDlg, IDC_OPT_MAX_MSG_CONTACT, _itot((unsigned int)_getOptD("MaxMsgContactCountPerDay", defaultMaxMsgContactCountPerDay), buf, 10));
- SetDlgItemText(optDlg, IDC_OPT_MAX_SAME_MSG, _itot((unsigned int)_getOptD("MaxSameMsgCountPerDay", defaultMaxSameMsgCountPerDay), buf, 10));
+ SetDlgItemText(optDlg, IDC_OPT_MAX_MSG_CONTACT, _itow((unsigned int)_getOptD("MaxMsgContactCountPerDay", defaultMaxMsgContactCountPerDay), buf, 10));
+ SetDlgItemText(optDlg, IDC_OPT_MAX_SAME_MSG, _itow((unsigned int)_getOptD("MaxSameMsgCountPerDay", defaultMaxSameMsgCountPerDay), buf, 10));
SetDlgItemText(optDlg, IDC_OPT_DONT_REPLY_MSG_WORDLIST, _getOptS(buf, _countof(buf), "DontReplyMsgWordlist", defaultDontReplyMsgWordlist));
///Individual protocols list
@@ -129,7 +129,7 @@ INT_PTR CALLBACK DlgProcOptionsMain(HWND optDlg, UINT msg, WPARAM wParam, LPARAM
for (i = 0, j = 0; i < numProtocols; i++)
{
lvi.iItem = i;
- _getMOptS(pName, 200*sizeof(TCHAR), pd[i]->szModuleName, "AM_BaseProto", L"");
+ _getMOptS(pName, 200*sizeof(wchar_t), pd[i]->szModuleName, "AM_BaseProto", L"");
if (mir_tstrcmp(pName, L"ICQ") != 0)
continue;
lvi.pszText = mir_a2u(pd[i]->szModuleName);
@@ -217,7 +217,7 @@ INT_PTR CALLBACK DlgProcOptionsQuestion(HWND optDlg, UINT msg, WPARAM wParam, LP
static int bInitializing = 0;
int i, selectedMode;
HWND ht;
- TCHAR *buf;
+ wchar_t *buf;
unsigned int buflen = 500;
switch (msg) {
@@ -243,7 +243,7 @@ INT_PTR CALLBACK DlgProcOptionsQuestion(HWND optDlg, UINT msg, WPARAM wParam, LP
}
}
SetDlgItemText(optDlg, IDC_OPT_MATH_RESPONSE, TranslateT("Will be automatically evaluated from %mathexpr%"));
- buf = (TCHAR *)malloc(buflen*sizeof(TCHAR));
+ buf = (wchar_t *)malloc(buflen*sizeof(wchar_t));
switch (selectedMode) {
case SPAMOTRON_MODE_PLAIN:
case SPAMOTRON_MODE_ROTATE:
@@ -289,7 +289,7 @@ INT_PTR CALLBACK DlgProcOptionsQuestion(HWND optDlg, UINT msg, WPARAM wParam, LP
return FALSE;
i = SendDlgItemMessage(optDlg, IDC_OPT_MODE, CB_GETCURSEL, 0, 0);
selectedMode = SendDlgItemMessage(optDlg, IDC_OPT_MODE, CB_GETITEMDATA, i, 0);
- buf = (TCHAR*)malloc(buflen*sizeof(TCHAR));
+ buf = (wchar_t*)malloc(buflen*sizeof(wchar_t));
switch (selectedMode) {
case SPAMOTRON_MODE_PLAIN:
case SPAMOTRON_MODE_ROTATE:
@@ -418,8 +418,8 @@ INT_PTR CALLBACK DlgProcOptionsBayes(HWND optDlg, UINT msg, WPARAM wParam, LPARA
{
static int bInitializing = 0, len;
BOOL bEnabled;
- TCHAR *dbuf;
- TCHAR buf[MAX_BUFFER_LENGTH];
+ wchar_t *dbuf;
+ wchar_t buf[MAX_BUFFER_LENGTH];
char cbuf[MAX_BUFFER_LENGTH];
switch (msg) {
case WM_INITDIALOG:
@@ -482,7 +482,7 @@ INT_PTR CALLBACK DlgProcOptionsBayes(HWND optDlg, UINT msg, WPARAM wParam, LPARA
case IDC_OPT_BAYES_HAM:
// Learn ham from learnbox
len = GetWindowTextLength(GetDlgItem(optDlg, IDC_OPT_BAYES_LEARNBOX))+1;
- dbuf = (TCHAR *)malloc(len*sizeof(TCHAR));
+ dbuf = (wchar_t *)malloc(len*sizeof(wchar_t));
if (!dbuf)
return FALSE;
GetDlgItemText(optDlg, IDC_OPT_BAYES_LEARNBOX, dbuf, len);
@@ -499,7 +499,7 @@ INT_PTR CALLBACK DlgProcOptionsBayes(HWND optDlg, UINT msg, WPARAM wParam, LPARA
case IDC_OPT_BAYES_SPAM:
// Learn spam from learnbox
len = GetWindowTextLength(GetDlgItem(optDlg, IDC_OPT_BAYES_LEARNBOX))+1;
- dbuf = (TCHAR *)malloc(len*sizeof(TCHAR));
+ dbuf = (wchar_t *)malloc(len*sizeof(wchar_t));
if (!dbuf)
return FALSE;
GetDlgItemText(optDlg, IDC_OPT_BAYES_LEARNBOX, dbuf, len);
@@ -515,7 +515,7 @@ INT_PTR CALLBACK DlgProcOptionsBayes(HWND optDlg, UINT msg, WPARAM wParam, LPARA
case IDC_CHECK_MSG:
len = GetWindowTextLength(GetDlgItem(optDlg, IDC_OPT_BAYES_LEARNBOX))+1;
- dbuf = (TCHAR *)malloc((len)*sizeof(TCHAR));
+ dbuf = (wchar_t *)malloc((len)*sizeof(wchar_t));
if (!dbuf)
return FALSE;
GetDlgItemText(optDlg, IDC_OPT_BAYES_LEARNBOX, dbuf, len);
@@ -556,21 +556,21 @@ int OnOptInitialize(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
- odp.ptszGroup = LPGENT("Message sessions");
- odp.ptszTitle = _T(PLUGIN_NAME);
+ odp.pwszGroup = LPGENW("Message sessions");
+ odp.pwszTitle = _T(PLUGIN_NAME);
odp.flags = ODPF_TCHAR | ODPF_BOLDGROUPS;
- odp.ptszTab = LPGENT("Settings");
+ odp.pwszTab = LPGENW("Settings");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_SPAMOTRON_MAIN);
odp.pfnDlgProc = DlgProcOptionsMain;
Options_AddPage(wParam, &odp);
- odp.ptszTab = LPGENT("Messages");
+ odp.pwszTab = LPGENW("Messages");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_SPAMOTRON_Q);
odp.pfnDlgProc = DlgProcOptionsQuestion;
Options_AddPage(wParam, &odp);
- odp.ptszTab = LPGENT("Bayes");
+ odp.pwszTab = LPGENW("Bayes");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_SPAMOTRON_BAYES);
odp.pfnDlgProc = DlgProcOptionsBayes;
Options_AddPage(wParam, &odp);
@@ -578,8 +578,8 @@ int OnOptInitialize(WPARAM wParam, LPARAM)
if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
odp.pszTemplate = MAKEINTRESOURCEA(IDD_SPAMOTRON_POPUPS);
odp.pfnDlgProc = DlgProcOptionsPopups;
- odp.ptszGroup = LPGENT("Popups");
- odp.ptszTab = NULL;
+ odp.pwszGroup = LPGENW("Popups");
+ odp.pwszTab = NULL;
Options_AddPage(wParam, &odp);
}
return 0;
diff --git a/plugins/Spamotron/src/popups.cpp b/plugins/Spamotron/src/popups.cpp
index 46289ac9af..0d81268d04 100644
--- a/plugins/Spamotron/src/popups.cpp
+++ b/plugins/Spamotron/src/popups.cpp
@@ -143,7 +143,7 @@ INT_PTR CALLBACK DlgProcOptionsPopups(HWND optDlg, UINT msg, WPARAM wParam, LPAR
return FALSE;
}
-int ShowPopupPreview(HWND optDlg, BYTE popupType, TCHAR *line1, TCHAR *line2)
+int ShowPopupPreview(HWND optDlg, BYTE popupType, wchar_t *line1, wchar_t *line2)
{
POPUPDATAT ppdp = {0};
switch (popupType)
@@ -185,14 +185,14 @@ int ShowPopupPreview(HWND optDlg, BYTE popupType, TCHAR *line1, TCHAR *line2)
ppdp.iSeconds = 0;
ppdp.lchContact = NULL;
- _tcsncpy_s(ppdp.lptzContactName, (line1 ? line1 : _T(PLUGIN_NAME)), _TRUNCATE);
+ wcsncpy_s(ppdp.lptzContactName, (line1 ? line1 : _T(PLUGIN_NAME)), _TRUNCATE);
if (line2)
- _tcsncpy_s(ppdp.lptzText, line2, _TRUNCATE);
+ wcsncpy_s(ppdp.lptzText, line2, _TRUNCATE);
return PUAddPopupT(&ppdp);
}
-int ShowPopup(MCONTACT hContact, BYTE popupType, TCHAR *line1, TCHAR *line2)
+int ShowPopup(MCONTACT hContact, BYTE popupType, wchar_t *line1, wchar_t *line2)
{
POPUPDATAT ppdp = {0};
switch (popupType)
@@ -234,8 +234,8 @@ int ShowPopup(MCONTACT hContact, BYTE popupType, TCHAR *line1, TCHAR *line2)
ppdp.iSeconds = 0;
ppdp.lchContact = hContact;
- _tcsncpy_s(ppdp.lptzContactName, (line1 ? line1 : _T(PLUGIN_NAME)), _TRUNCATE);
+ wcsncpy_s(ppdp.lptzContactName, (line1 ? line1 : _T(PLUGIN_NAME)), _TRUNCATE);
if (line2)
- _tcsncpy_s(ppdp.lptzText, line2, _TRUNCATE);
+ wcsncpy_s(ppdp.lptzText, line2, _TRUNCATE);
return PUAddPopupT(&ppdp);
} \ No newline at end of file
diff --git a/plugins/Spamotron/src/spamotron.cpp b/plugins/Spamotron/src/spamotron.cpp
index dceac13a6e..a96cc0551b 100644
--- a/plugins/Spamotron/src/spamotron.cpp
+++ b/plugins/Spamotron/src/spamotron.cpp
@@ -42,10 +42,10 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
char *msgblob;
char protoOption[256] = {0};
int buflen = MAX_BUFFER_LENGTH;
- TCHAR buf[MAX_BUFFER_LENGTH];
- TCHAR *message = NULL, *challengeW = NULL, *tmpW = NULL;
- TCHAR *whitelist = NULL, *ptok;
- TCHAR mexpr[64];
+ wchar_t buf[MAX_BUFFER_LENGTH];
+ wchar_t *message = NULL, *challengeW = NULL, *tmpW = NULL;
+ wchar_t *whitelist = NULL, *ptok;
+ wchar_t mexpr[64];
int maxmsglen = 0, a, b, i;
BOOL bayesEnabled = _getOptB("BayesEnabled", defaultBayesEnabled);
BOOL bCorrectResponse = FALSE;
@@ -132,20 +132,20 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
/*** Check for words in white-list ***/
if (_getOptB("ApproveOnMsgIn", defaultApproveOnMsgIn)) {
- whitelist = (TCHAR*)malloc(2048 * sizeof(TCHAR));
+ whitelist = (wchar_t*)malloc(2048 * sizeof(wchar_t));
if (whitelist != NULL) {
_getOptS(whitelist, 2048, "ApproveOnMsgInWordlist", defaultApproveOnMsgInWordlist);
if (_isregex(whitelist)) {
if (_regmatch(message, whitelist))
bCorrectResponse = TRUE;
} else {
- ptok = _tcstok(whitelist, L" ");
+ ptok = wcstok(whitelist, L" ");
while (ptok != NULL) {
- if (_tcsstr(message, ptok)) {
+ if (wcsstr(message, ptok)) {
bCorrectResponse = TRUE;
break;
}
- ptok = _tcstok(NULL, L" ");
+ ptok = wcstok(NULL, L" ");
}
}
free(whitelist);
@@ -207,8 +207,8 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
case SPAMOTRON_MODE_MATH:
if (message == NULL)
break;
- _itot(_getCOptD(hContact, "ResponseMath", -1), buf, 10);
- if (_tcsstr(message, buf) && (mir_tstrlen(buf) == mir_tstrlen(message))) {
+ _itow(_getCOptD(hContact, "ResponseMath", -1), buf, 10);
+ if (wcsstr(message, buf) && (mir_tstrlen(buf) == mir_tstrlen(message))) {
bCorrectResponse = TRUE;
}
break;
@@ -232,7 +232,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
// Resubmit pending authorization request
if (_getCOptB(hContact, "AuthEventPending", FALSE)) {
DBVARIANT _dbv;
- TCHAR AuthEventModule[100];
+ wchar_t AuthEventModule[100];
char* szAuthEventModule;
if (db_get(hContact, PLUGIN_NAME, "AuthEvent", &_dbv) == 0) {
DBEVENTINFO *_dbei = (DBEVENTINFO *)malloc(sizeof(DBEVENTINFO));
@@ -344,8 +344,8 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
/*** Send Challenge ***/
- challengeW = (TCHAR *)malloc(maxmsglen*sizeof(TCHAR));
- tmpW = (TCHAR *)malloc(maxmsglen*sizeof(TCHAR));
+ challengeW = (wchar_t *)malloc(maxmsglen*sizeof(wchar_t));
+ tmpW = (wchar_t *)malloc(maxmsglen*sizeof(wchar_t));
switch (_getOptB("Mode", defaultMode)) {
case SPAMOTRON_MODE_PLAIN:
if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
diff --git a/plugins/Spamotron/src/stdafx.h b/plugins/Spamotron/src/stdafx.h
index 2d584589ba..1be69abae9 100644
--- a/plugins/Spamotron/src/stdafx.h
+++ b/plugins/Spamotron/src/stdafx.h
@@ -40,7 +40,7 @@
#define _getOptD(a,b) _getCOptD(NULL, a, b)
#define _setOptD(a,b) _setCOptD(NULL, a, b)
-TCHAR* _getCOptS(TCHAR *buf, unsigned int buflen, MCONTACT hContact, const char* option, const TCHAR *def);
+wchar_t* _getCOptS(wchar_t *buf, unsigned int buflen, MCONTACT hContact, const char* option, const wchar_t *def);
#define _getOptS(a,b,c,d) _getCOptS(a, b, NULL, c, d)
#define _setCOptTS(a,b,c) db_set_ts(a, PLUGIN_NAME, b, c)
#define _setCOptS(a,b,c) db_set_s(a, PLUGIN_NAME, b, c)
@@ -90,24 +90,24 @@ TCHAR* _getCOptS(TCHAR *buf, unsigned int buflen, MCONTACT hContact, const char*
#define _NOTIFYP _getOptB("NotifyPopup", defaultNotifyPopup)
-TCHAR* ReplaceVars(TCHAR *dst, unsigned int len);
-TCHAR* ReplaceVarsNum(TCHAR *dst, unsigned int len, int num);
-TCHAR* ReplaceVar(TCHAR *dst, unsigned int len, const TCHAR *var, const TCHAR *rvar);
-int get_response_id(const TCHAR *strvar);
-int get_response_num(const TCHAR *str);
-TCHAR* get_response(TCHAR* dst, unsigned int dstlen, int num);
-
-TCHAR* _tcsstr_cc(TCHAR* str, TCHAR* strSearch, BOOL cc);
-BOOL _isregex(TCHAR* strSearch);
-BOOL _isvalidregex(TCHAR* strSearch);
-BOOL _regmatch(TCHAR* str, TCHAR* strSearch);
-BOOL Contains(TCHAR* dst, TCHAR* src);
+wchar_t* ReplaceVars(wchar_t *dst, unsigned int len);
+wchar_t* ReplaceVarsNum(wchar_t *dst, unsigned int len, int num);
+wchar_t* ReplaceVar(wchar_t *dst, unsigned int len, const wchar_t *var, const wchar_t *rvar);
+int get_response_id(const wchar_t *strvar);
+int get_response_num(const wchar_t *str);
+wchar_t* get_response(wchar_t* dst, unsigned int dstlen, int num);
+
+wchar_t* _tcsstr_cc(wchar_t* str, wchar_t* strSearch, BOOL cc);
+BOOL _isregex(wchar_t* strSearch);
+BOOL _isvalidregex(wchar_t* strSearch);
+BOOL _regmatch(wchar_t* str, wchar_t* strSearch);
+BOOL Contains(wchar_t* dst, wchar_t* src);
BOOL isOneDay(DWORD timestamp1, DWORD timestamp2);
void MarkUnread(MCONTACT hContact);
-int ShowPopup(MCONTACT hContact, BYTE popupType, TCHAR *line1, TCHAR *line2);
-int ShowPopupPreview(HWND optDlg, BYTE popupType, TCHAR *line1, TCHAR *line2);
-int _notify(MCONTACT hContact, BYTE type, TCHAR *message, TCHAR *origmessage);
+int ShowPopup(MCONTACT hContact, BYTE popupType, wchar_t *line1, wchar_t *line2);
+int ShowPopupPreview(HWND optDlg, BYTE popupType, wchar_t *line1, wchar_t *line2);
+int _notify(MCONTACT hContact, BYTE type, wchar_t *message, wchar_t *origmessage);
int LogToSystemHistory(char *message, char *origmessage);
#define POPUP_DEFAULT 0
#define POPUP_BLOCKED 1
@@ -136,13 +136,13 @@ extern sqlite3 *bayesdb;
int OpenBayes();
int CheckBayes();
-void learn(int type, TCHAR *msg);
-void learn_ham(TCHAR *msg);
-void learn_spam(TCHAR *msg);
+void learn(int type, wchar_t *msg);
+void learn_ham(wchar_t *msg);
+void learn_spam(wchar_t *msg);
int get_token_count(int type);
int get_msg_count(int type);
-double get_msg_score(TCHAR *msg);
-void queue_message(MCONTACT hContact, DWORD msgtime, TCHAR *message);
+double get_msg_score(wchar_t *msg);
+void queue_message(MCONTACT hContact, DWORD msgtime, wchar_t *message);
void bayes_approve_contact(MCONTACT hContact);
void dequeue_messages();
diff --git a/plugins/Spamotron/src/utils.cpp b/plugins/Spamotron/src/utils.cpp
index 7a9bf2fe3e..4d5ca64280 100644
--- a/plugins/Spamotron/src/utils.cpp
+++ b/plugins/Spamotron/src/utils.cpp
@@ -2,36 +2,36 @@
#include <locale.h>
-TCHAR *_tcstolower(TCHAR *dst)
+wchar_t *_tcstolower(wchar_t *dst)
{
if (dst == NULL)
return NULL;
SIZE_T dst_len = mir_tstrlen(dst);
for (SIZE_T i = 0; i < dst_len; i ++)
- dst[i] = _totlower(dst[i]);
+ dst[i] = towlower(dst[i]);
return dst;
}
-TCHAR *_tcstoupper(TCHAR *dst)
+wchar_t *_tcstoupper(wchar_t *dst)
{
if (dst == NULL)
return NULL;
SIZE_T dst_len = mir_tstrlen(dst);
for (SIZE_T i = 0; i < dst_len; i ++)
- dst[i] = _totupper(dst[i]);
+ dst[i] = towupper(dst[i]);
return dst;
}
-BOOL _isregex(TCHAR* strSearch)
+BOOL _isregex(wchar_t* strSearch)
{
BOOL ret = FALSE;
pcre16 *re;
const char *error;
int erroroffs, rc;
- TCHAR *regex;
- TCHAR regex_parse[] = L"/(.*)/([igsm]*)";
+ wchar_t *regex;
+ wchar_t regex_parse[] = L"/(.*)/([igsm]*)";
int ovector[9];
if (strSearch == NULL)
@@ -52,15 +52,15 @@ err_out:
return ret;
}
-BOOL _isvalidregex(TCHAR* strSearch)
+BOOL _isvalidregex(wchar_t* strSearch)
{
BOOL ret = FALSE;
pcre16 *re;
const char *error;
int erroroffs, rc;
- TCHAR *regex, *regexp, *mod;
+ wchar_t *regex, *regexp, *mod;
int opts = 0;
- TCHAR regex_parse[] = L"/(.*)/([igsm]*)";
+ wchar_t regex_parse[] = L"/(.*)/([igsm]*)";
int ovector[9];
if (strSearch == NULL)
@@ -82,11 +82,11 @@ BOOL _isvalidregex(TCHAR* strSearch)
mod = regex + ovector[4];
mod[ovector[5] - ovector[4]] = 0;
- if (_tcsstr(mod, L"i"))
+ if (wcsstr(mod, L"i"))
opts |= PCRE_CASELESS;
- if (_tcsstr(mod, L"m"))
+ if (wcsstr(mod, L"m"))
opts |= PCRE_MULTILINE;
- if (_tcsstr(mod, L"s"))
+ if (wcsstr(mod, L"s"))
opts |= PCRE_DOTALL;
re = pcre16_compile(regexp, opts, &error, &erroroffs, NULL);
@@ -100,15 +100,15 @@ err_out:
return ret;
}
-BOOL _regmatch(TCHAR* str, TCHAR* strSearch)
+BOOL _regmatch(wchar_t* str, wchar_t* strSearch)
{
BOOL ret = FALSE;
pcre16 *re;
const char *error;
int erroroffs, rc;
- TCHAR *regex, *regexp, *data = NULL, *mod;
+ wchar_t *regex, *regexp, *data = NULL, *mod;
int opts = 0;
- TCHAR regex_parse[] = L"^/(.*)/([igsm]*)";
+ wchar_t regex_parse[] = L"^/(.*)/([igsm]*)";
int ovector[9];
if (str == NULL || strSearch == NULL)
@@ -133,11 +133,11 @@ BOOL _regmatch(TCHAR* str, TCHAR* strSearch)
data = mir_tstrdup(str);
if (data == NULL)
goto err_out;
- if (_tcsstr(mod, L"i"))
+ if (wcsstr(mod, L"i"))
opts |= PCRE_CASELESS;
- if (_tcsstr(mod, L"m"))
+ if (wcsstr(mod, L"m"))
opts |= PCRE_MULTILINE;
- if (_tcsstr(mod, L"s"))
+ if (wcsstr(mod, L"s"))
opts |= PCRE_DOTALL;
re = pcre16_compile(regexp, opts, &error, &erroroffs, NULL);
@@ -154,14 +154,14 @@ err_out:
return ret;
}
-int get_response_id(const TCHAR* strvar)
+int get_response_id(const wchar_t* strvar)
{
int ret = 0;
pcre16 *re;
const char *error;
int erroroffs, rc;
- TCHAR *_str, *_strvar;
- TCHAR regex[] = L"^%response([#-_]([0-9]+))?%$";
+ wchar_t *_str, *_strvar;
+ wchar_t regex[] = L"^%response([#-_]([0-9]+))?%$";
int ovector[9];
if (strvar == NULL)
@@ -181,45 +181,45 @@ int get_response_id(const TCHAR* strvar)
} else if (rc == 3) {
_str = _strvar + ovector[4];
_str[ovector[5] - ovector[4]] = 0;
- ret = _ttoi(_str);
+ ret = _wtoi(_str);
}
mir_free(_strvar);
return ret;
}
-int get_response_num(const TCHAR *str)
+int get_response_num(const wchar_t *str)
{
int i = 0;
- TCHAR *tmp, *strc;
+ wchar_t *tmp, *strc;
if (str == NULL)
return 0;
strc = mir_tstrdup(str);
if (strc == NULL)
return 0;
- tmp = _tcstok(strc, L"\r\n");
+ tmp = wcstok(strc, L"\r\n");
while (tmp) {
i ++;
- tmp = _tcstok(NULL, L"\r\n"); /* Move next. */
+ tmp = wcstok(NULL, L"\r\n"); /* Move next. */
}
mir_free(strc);
return i;
}
-TCHAR* get_response(TCHAR* dst, unsigned int dstlen, int num)
+wchar_t* get_response(wchar_t* dst, unsigned int dstlen, int num)
{
int i = 0;
- TCHAR *tmp, *src;
+ wchar_t *tmp, *src;
if (dst == NULL || dstlen == 0 || num < 0)
return dst;
- src = (TCHAR*)mir_alloc(MAX_BUFFER_LENGTH * sizeof(TCHAR));
+ src = (wchar_t*)mir_alloc(MAX_BUFFER_LENGTH * sizeof(wchar_t));
if (src == NULL)
goto err_out;
_getOptS(src, MAX_BUFFER_LENGTH, "Response", defaultResponse);
- tmp = _tcstok(src, L"\r\n");
+ tmp = wcstok(src, L"\r\n");
while (tmp) {
if (i == num) {
mir_tstrcpy(dst, tmp);
@@ -227,7 +227,7 @@ TCHAR* get_response(TCHAR* dst, unsigned int dstlen, int num)
return dst;
}
i ++;
- tmp = _tcstok(NULL, L"\r\n"); /* Move next. */
+ tmp = wcstok(NULL, L"\r\n"); /* Move next. */
}
mir_free(src);
err_out:
@@ -235,12 +235,12 @@ err_out:
return dst;
}
-TCHAR* _tcsstr_cc(TCHAR* str, TCHAR* strSearch, BOOL cc)
+wchar_t* _tcsstr_cc(wchar_t* str, wchar_t* strSearch, BOOL cc)
{
- TCHAR *ret = NULL, *_str = NULL, *_strSearch = NULL;
+ wchar_t *ret = NULL, *_str = NULL, *_strSearch = NULL;
if (cc)
- return _tcsstr(str, strSearch);
+ return wcsstr(str, strSearch);
_str = mir_tstrdup(str);
if (_str == NULL)
@@ -248,7 +248,7 @@ TCHAR* _tcsstr_cc(TCHAR* str, TCHAR* strSearch, BOOL cc)
_strSearch = mir_tstrdup(strSearch);
if (_strSearch == NULL)
goto err_out;
- ret = _tcsstr(_tcstolower(_str), _tcstolower(_strSearch));
+ ret = wcsstr(_tcstolower(_str), _tcstolower(_strSearch));
if (ret != NULL)
ret = ((ret - _str) + str);
err_out:
@@ -258,10 +258,10 @@ err_out:
return ret;
}
-BOOL Contains(TCHAR* dst, TCHAR* src) // Checks for occurence of substring from src in dst
+BOOL Contains(wchar_t* dst, wchar_t* src) // Checks for occurence of substring from src in dst
{
BOOL ret = FALSE;
- TCHAR *tsrc = NULL, *tdst = NULL, *token, *token_end;
+ wchar_t *tsrc = NULL, *tdst = NULL, *token, *token_end;
SIZE_T dst_len;
if (dst == NULL || src == NULL)
@@ -274,24 +274,24 @@ BOOL Contains(TCHAR* dst, TCHAR* src) // Checks for occurence of substring from
goto err_out;
tdst = _tcstoupper(tdst);
dst_len = mir_tstrlen(tdst);
- token = _tcstok(tsrc, L",");
+ token = wcstok(tsrc, L",");
while (token) {
token_end = (token + mir_tstrlen(token));
- while (!_tcsncmp(token, L" ", 1)) { /* Skeep spaces at start. */
+ while (!wcsncmp(token, L" ", 1)) { /* Skeep spaces at start. */
token ++;
}
/* Skeep spaces at end. */
- while (token > token_end && _tcschr((token_end - 1), _T(' '))) {
+ while (token > token_end && wcschr((token_end - 1), ' ')) {
token_end --;
token_end[0] = 0;
}
/* Compare. */
if (dst_len == (token_end - token) &&
- 0 == memcmp(tdst, _tcstoupper(token), (dst_len * sizeof(TCHAR)))) {
+ 0 == memcmp(tdst, _tcstoupper(token), (dst_len * sizeof(wchar_t)))) {
ret = TRUE;
break;
}
- token = _tcstok(NULL, L","); /* Move next. */
+ token = wcstok(NULL, L","); /* Move next. */
}
err_out:
mir_free(tsrc);
@@ -321,9 +321,9 @@ BOOL isOneDay(DWORD timestamp1, DWORD timestamp2)
return FALSE;
}
-TCHAR* ReplaceVar(TCHAR *dst, unsigned int len, const TCHAR *var, const TCHAR *rvar)
+wchar_t* ReplaceVar(wchar_t *dst, unsigned int len, const wchar_t *var, const wchar_t *rvar)
{
- TCHAR *var_start;
+ wchar_t *var_start;
SIZE_T dst_len, var_len, rvar_len;
if (dst == NULL || var == NULL || rvar == NULL)
@@ -331,39 +331,39 @@ TCHAR* ReplaceVar(TCHAR *dst, unsigned int len, const TCHAR *var, const TCHAR *r
dst_len = mir_tstrlen(dst);
var_len = mir_tstrlen(var);
rvar_len = mir_tstrlen(rvar);
- var_start = _tcsstr(dst, var);
+ var_start = wcsstr(dst, var);
while (var_start) {
if (len < (dst_len + rvar_len - var_len + 1))
return NULL; /* Out of buf space. */
memmove((var_start + rvar_len),
(var_start + var_len),
- (((dst + dst_len + 1) - (var_start + var_len)) * sizeof(TCHAR)));
+ (((dst + dst_len + 1) - (var_start + var_len)) * sizeof(wchar_t)));
if (var_len >= rvar_len) { /* Buf data size not changed or decreased. */
dst_len -= (var_len - rvar_len);
} else { /* Buf data size increased. */
dst_len += (rvar_len - var_len);
}
- memcpy(var_start, rvar, (rvar_len * sizeof(TCHAR)));
- var_start = _tcsstr(dst, var); /* Move next. */
+ memcpy(var_start, rvar, (rvar_len * sizeof(wchar_t)));
+ var_start = wcsstr(dst, var); /* Move next. */
}
return dst;
}
-TCHAR* ReplaceVars(TCHAR *dst, unsigned int len)
+wchar_t* ReplaceVars(wchar_t *dst, unsigned int len)
{
return ReplaceVarsNum(dst, len, -1);
}
-TCHAR* ReplaceVarsNum(TCHAR *dst, unsigned int len, int num)
+wchar_t* ReplaceVarsNum(wchar_t *dst, unsigned int len, int num)
{
- TCHAR response[MAX_BUFFER_LENGTH];
+ wchar_t response[MAX_BUFFER_LENGTH];
int ret, i;
pcre16 *re;
const char *error;
int erroroffs, rc;
- TCHAR *_str, *tmp, **r = NULL, **tr, *ttmp, *dstcopy;
- TCHAR regex[] = L"%response([#-_]([0-9]+))?%";
+ wchar_t *_str, *tmp, **r = NULL, **tr, *ttmp, *dstcopy;
+ wchar_t regex[] = L"%response([#-_]([0-9]+))?%";
int ovector[9];
re = pcre16_compile(regex, 0, &error, &erroroffs, NULL);
@@ -371,14 +371,14 @@ TCHAR* ReplaceVarsNum(TCHAR *dst, unsigned int len, int num)
return FALSE; // [TODO] and log some error
_getOptS(response, _countof(response), "Response", defaultResponse);
- ttmp = _tcstok(response, L"\r\n");
+ ttmp = wcstok(response, L"\r\n");
for (i = 0; ttmp != NULL; i ++) {
- tr = (TCHAR**)mir_realloc(r, ((i + 1) * sizeof(TCHAR*)));
+ tr = (wchar_t**)mir_realloc(r, ((i + 1) * sizeof(wchar_t*)));
if (tr == NULL)
goto err_out;
r = tr;
r[i] = ttmp;
- ttmp = _tcstok(NULL, L"\r\n"); /* Move next. */
+ ttmp = wcstok(NULL, L"\r\n"); /* Move next. */
}
do {
@@ -397,7 +397,7 @@ TCHAR* ReplaceVarsNum(TCHAR *dst, unsigned int len, int num)
ttmp[ovector[1] - ovector[0]] = 0;
tmp = _str + ovector[4];
tmp[ovector[5] - ovector[4]] = 0;
- ret = _ttoi(tmp);
+ ret = _wtoi(tmp);
} else {
ttmp = dstcopy + ovector[0];
ttmp[ovector[1] - ovector[0]] = 0;
@@ -423,10 +423,10 @@ err_out:
return dst;
}
-int _notify(MCONTACT hContact, BYTE type, TCHAR *message, TCHAR *origmessage)
+int _notify(MCONTACT hContact, BYTE type, wchar_t *message, wchar_t *origmessage)
{
char *tmp, *tmporig;
- TCHAR msg[MAX_BUFFER_LENGTH];
+ wchar_t msg[MAX_BUFFER_LENGTH];
mir_sntprintf(msg, message, pcli->pfnGetContactDisplayName(hContact, 0));
if (_getOptB("LogActions", defaultLogActions)) {