diff options
| author | George Hazan <george.hazan@gmail.com> | 2016-07-27 14:23:31 +0000 | 
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2016-07-27 14:23:31 +0000 | 
| commit | 2f261839b60692e33d0e160344d0d636d49c90ba (patch) | |
| tree | 187921722698b681d29df3f6e60fb18394a5e9d5 /plugins/Spamotron/src | |
| parent | 2e931a0b2780587d85f3902468c935f5adba70c8 (diff) | |
less TCHARs
git-svn-id: http://svn.miranda-ng.org/main/trunk@17138 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Spamotron/src')
| -rw-r--r-- | plugins/Spamotron/src/options.cpp | 30 | ||||
| -rw-r--r-- | plugins/Spamotron/src/spamotron.cpp | 12 | ||||
| -rw-r--r-- | plugins/Spamotron/src/utils.cpp | 54 | 
3 files changed, 48 insertions, 48 deletions
| diff --git a/plugins/Spamotron/src/options.cpp b/plugins/Spamotron/src/options.cpp index 550c9143e6..6cdaf66110 100644 --- a/plugins/Spamotron/src/options.cpp +++ b/plugins/Spamotron/src/options.cpp @@ -7,9 +7,9 @@ wchar_t* _getCOptS(wchar_t *buf, unsigned int buflen, MCONTACT hContact, const c  	DBVARIANT dbv = {0};
  	wcsnset(buf, 0, buflen);
  	if (db_get_ts(hContact, PLUGIN_NAME, option, &dbv) != 0)
 -		wcsncpy(buf, def, min(buflen, mir_tstrlen(def)+1));
 +		wcsncpy(buf, def, min(buflen, mir_wstrlen(def)+1));
  	else if (dbv.type == DBVT_TCHAR) {
 -		wcsncpy(buf, dbv.ptszVal, min(buflen, mir_tstrlen(dbv.ptszVal)+1));
 +		wcsncpy(buf, dbv.ptszVal, min(buflen, mir_wstrlen(dbv.ptszVal)+1));
  	}
  	db_free(&dbv);
  	return buf;
 @@ -20,12 +20,12 @@ wchar_t* _getMOptS(wchar_t *buf, unsigned int buflen, const char* module, const  	DBVARIANT dbv = {0};
  	wcsnset(buf, 0, buflen);
  	if (db_get_s(NULL, module, option, &dbv) != 0)
 -		wcsncpy(buf, def, min(buflen, mir_tstrlen(def)+1));
 +		wcsncpy(buf, def, min(buflen, mir_wstrlen(def)+1));
  	else if (dbv.type == DBVT_TCHAR) {
 -		wcsncpy(buf, dbv.ptszVal, min(buflen, mir_tstrlen(dbv.ptszVal)+1));
 +		wcsncpy(buf, dbv.ptszVal, min(buflen, mir_wstrlen(dbv.ptszVal)+1));
  	} else {
  		tmp = mir_a2u(dbv.pszVal);
 -		wcsncpy(buf, tmp, min(buflen, mir_tstrlen(tmp)+1));
 +		wcsncpy(buf, tmp, min(buflen, mir_wstrlen(tmp)+1));
  		mir_free(tmp);
  	}
  	db_free(&dbv);
 @@ -130,7 +130,7 @@ INT_PTR CALLBACK DlgProcOptionsMain(HWND optDlg, UINT msg, WPARAM wParam, LPARAM  		{
  			lvi.iItem = i;
  			_getMOptS(pName, 200*sizeof(wchar_t), pd[i]->szModuleName, "AM_BaseProto", L"");
 -			if (mir_tstrcmp(pName, L"ICQ") != 0)
 +			if (mir_wstrcmp(pName, L"ICQ") != 0)
  				continue;
  			lvi.pszText = mir_a2u(pd[i]->szModuleName);
  			ListView_InsertItem(hProtocolsList, &lvi);
 @@ -436,17 +436,17 @@ INT_PTR CALLBACK DlgProcOptionsBayes(HWND optDlg, UINT msg, WPARAM wParam, LPARA  			EnableControlsBayes(optDlg, bEnabled);
 -			mir_sntprintf(buf, L"%0.02f", (double)_getOptD("BayesSpamScore", defaultBayesSpamScore)*SCORE_C);
 +			mir_snwprintf(buf, L"%0.02f", (double)_getOptD("BayesSpamScore", defaultBayesSpamScore)*SCORE_C);
  			SetDlgItemText(optDlg, IDC_OPT_BAYES_SPAM_SCORE, buf);
 -			mir_sntprintf(buf, L"%.02f", (double)_getOptD("BayesHamScore", defaultBayesHamScore)*SCORE_C);
 +			mir_snwprintf(buf, L"%.02f", (double)_getOptD("BayesHamScore", defaultBayesHamScore)*SCORE_C);
  			SetDlgItemText(optDlg, IDC_OPT_BAYES_HAM_SCORE, buf);
 -			mir_sntprintf(buf, L"%d", _getOptD("BayesWaitApprove", defaultBayesWaitApprove));
 +			mir_snwprintf(buf, L"%d", _getOptD("BayesWaitApprove", defaultBayesWaitApprove));
  			SetDlgItemText(optDlg, IDC_OPT_BAYES_WAIT_APPROVE, buf);
  			if (bEnabled) {
 -				mir_sntprintf(buf, L"%d", get_msg_count(SPAM));
 +				mir_snwprintf(buf, L"%d", get_msg_count(SPAM));
  				SetDlgItemText(optDlg, IDC_STATIC_SPAM_COUNT, buf);
 -				mir_sntprintf(buf, L"%d", get_msg_count(HAM));
 +				mir_snwprintf(buf, L"%d", get_msg_count(HAM));
  				SetDlgItemText(optDlg, IDC_STATIC_HAM_COUNT, buf);
  			}
 @@ -490,9 +490,9 @@ INT_PTR CALLBACK DlgProcOptionsBayes(HWND optDlg, UINT msg, WPARAM wParam, LPARA  					SetDlgItemText(optDlg, IDC_OPT_BAYES_LEARNBOX, L"");
  					free(dbuf);
 -					mir_sntprintf(buf, L"%d", get_msg_count(SPAM));
 +					mir_snwprintf(buf, L"%d", get_msg_count(SPAM));
  					SetDlgItemText(optDlg, IDC_STATIC_SPAM_COUNT, buf);
 -					mir_sntprintf(buf, L"%d", get_msg_count(HAM));
 +					mir_snwprintf(buf, L"%d", get_msg_count(HAM));
  					SetDlgItemText(optDlg, IDC_STATIC_HAM_COUNT, buf);
  					return FALSE;
 @@ -507,9 +507,9 @@ INT_PTR CALLBACK DlgProcOptionsBayes(HWND optDlg, UINT msg, WPARAM wParam, LPARA  					SetDlgItemText(optDlg, IDC_OPT_BAYES_LEARNBOX, L"");
  					free(dbuf);
 -					mir_sntprintf(buf, L"%d", get_msg_count(SPAM));
 +					mir_snwprintf(buf, L"%d", get_msg_count(SPAM));
  					SetDlgItemText(optDlg, IDC_STATIC_SPAM_COUNT, buf);
 -					mir_sntprintf(buf, L"%d", get_msg_count(HAM));
 +					mir_snwprintf(buf, L"%d", get_msg_count(HAM));
  					SetDlgItemText(optDlg, IDC_STATIC_HAM_COUNT, buf);
  					return FALSE;
 diff --git a/plugins/Spamotron/src/spamotron.cpp b/plugins/Spamotron/src/spamotron.cpp index a96cc0551b..4951bac756 100644 --- a/plugins/Spamotron/src/spamotron.cpp +++ b/plugins/Spamotron/src/spamotron.cpp @@ -179,7 +179,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)  					bCorrectResponse = TRUE;
  			} else {
  				if (_tcsstr_cc(message, buf, _getOptB("ResponseCC", defaultResponseCC)) &&
 -					(mir_tstrlen(message) == mir_tstrlen(buf)))
 +					(mir_wstrlen(message) == mir_wstrlen(buf)))
  					bCorrectResponse = TRUE;
  			}
  			break;
 @@ -196,7 +196,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)  					}
  				} else {
  					if (_tcsstr_cc(message, buf, _getOptB("ResponseCC", defaultResponseCC)) &&
 -						(mir_tstrlen(message) == mir_tstrlen(buf))) {
 +						(mir_wstrlen(message) == mir_wstrlen(buf))) {
  						bCorrectResponse = TRUE;
  						break;
  					}
 @@ -208,7 +208,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)  			if (message == NULL)
  				break;
  			_itow(_getCOptD(hContact, "ResponseMath", -1), buf, 10);
 -			if (wcsstr(message, buf) && (mir_tstrlen(buf) == mir_tstrlen(message))) {
 +			if (wcsstr(message, buf) && (mir_wstrlen(buf) == mir_wstrlen(message))) {
  				bCorrectResponse = TRUE;
  			}
  			break;
 @@ -290,7 +290,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)  	// Completely reject if duplicate incoming message found
  	if (_getOptD("MaxSameMsgCountPerDay", defaultMaxSameMsgCountPerDay) > 0 &&
  		_getCOptD(hContact, "SameMsgCount", 0) >= _getOptD("MaxSameMsgCountPerDay", defaultMaxSameMsgCountPerDay) &&
 -		mir_tstrcmp(message, _getCOptS(buf, buflen, hContact, "LastInMsg", L"")) == 0) {
 +		mir_wstrcmp(message, _getCOptS(buf, buflen, hContact, "LastInMsg", L"")) == 0) {
  			_notify(hContact, POPUP_BLOCKED, TranslateT("Message from %s rejected because it reached a maximum for same responses per day."), message);
  			if (bayesEnabled)
  				queue_message(hContact, dbei->timestamp, message);
 @@ -388,7 +388,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)  	case SPAMOTRON_MODE_MATH:
  		a = (rand() % 10) + 1;
  		b = (rand() % 10) + 1;
 -		mir_sntprintf(mexpr, L"%d + %d", a, b);
 +		mir_snwprintf(mexpr, L"%d + %d", a, b);
  		if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
  			_getOptS(challengeW, maxmsglen, "AuthChallengeMath", defaultAuthChallengeMath);
  		else
 @@ -423,7 +423,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)  	// Save Last Msg and update SameMsgCount
  	if (message != NULL) {
 -		if (mir_tstrcmp(_getCOptS(buf, buflen, hContact, "LastInMsg", L""), message) == 0)
 +		if (mir_wstrcmp(_getCOptS(buf, buflen, hContact, "LastInMsg", L""), message) == 0)
  			_setCOptD(hContact, "SameMsgCount", 1+_getCOptD(hContact, "SameMsgCount", 0));
  		else 
  			_setCOptD(hContact, "SameMsgCount", 1);
 diff --git a/plugins/Spamotron/src/utils.cpp b/plugins/Spamotron/src/utils.cpp index 4d5ca64280..a95f2a976f 100644 --- a/plugins/Spamotron/src/utils.cpp +++ b/plugins/Spamotron/src/utils.cpp @@ -7,7 +7,7 @@ wchar_t *_tcstolower(wchar_t *dst)  	if (dst == NULL)  		return NULL; -	SIZE_T dst_len = mir_tstrlen(dst); +	SIZE_T dst_len = mir_wstrlen(dst);  	for (SIZE_T i = 0; i < dst_len; i ++)  		dst[i] = towlower(dst[i]);  	return dst; @@ -18,7 +18,7 @@ wchar_t *_tcstoupper(wchar_t *dst)  	if (dst == NULL)  		return NULL; -	SIZE_T dst_len = mir_tstrlen(dst); +	SIZE_T dst_len = mir_wstrlen(dst);  	for (SIZE_T i = 0; i < dst_len; i ++)  		dst[i] = towupper(dst[i]);  	return dst; @@ -39,10 +39,10 @@ BOOL _isregex(wchar_t* strSearch)  	re = pcre16_compile(regex_parse, 0, &error, &erroroffs, NULL);  	if (re == NULL)  		return FALSE; -	regex = mir_tstrdup(strSearch); +	regex = mir_wstrdup(strSearch);  	if (regex == NULL)  		goto err_out; -	rc = pcre16_exec(re, NULL, regex, (int)mir_tstrlen(regex), 0, 0, ovector, 9); +	rc = pcre16_exec(re, NULL, regex, (int)mir_wstrlen(regex), 0, 0, ovector, 9);  	if (rc == 3)  		ret = TRUE;  	mir_free(regex); @@ -68,12 +68,12 @@ BOOL _isvalidregex(wchar_t* strSearch)  	re = pcre16_compile(regex_parse, 0, &error, &erroroffs, NULL);  	if (re == NULL)  		return FALSE; -	regex = mir_tstrdup(strSearch); +	regex = mir_wstrdup(strSearch);  	if (regex == NULL) {  		pcre16_free(re);  		return FALSE;  	} -	rc = pcre16_exec(re, NULL, regex, (int)mir_tstrlen(regex), 0, 0, ovector, 9); +	rc = pcre16_exec(re, NULL, regex, (int)mir_wstrlen(regex), 0, 0, ovector, 9);  	pcre16_free(re);  	if (rc != 3)  		goto err_out; @@ -116,12 +116,12 @@ BOOL _regmatch(wchar_t* str, wchar_t* strSearch)  	re = pcre16_compile(regex_parse, 0, &error, &erroroffs, NULL);  	if (re == NULL)  		return FALSE; // [TODO] and log some error -	regex = mir_tstrdup(strSearch); +	regex = mir_wstrdup(strSearch);  	if (regex == NULL) {  		pcre16_free(re);  		return FALSE;  	} -	rc = pcre16_exec(re, NULL, regex, (int)mir_tstrlen(regex), 0, 0, ovector, 9); +	rc = pcre16_exec(re, NULL, regex, (int)mir_wstrlen(regex), 0, 0, ovector, 9);  	pcre16_free(re);  	if (rc != 3)  		goto err_out; // [TODO] and log some error (better check for valid regex on options save) @@ -130,7 +130,7 @@ BOOL _regmatch(wchar_t* str, wchar_t* strSearch)  	mod = regex + ovector[4];  	mod[ovector[5] - ovector[4]] = 0; -	data = mir_tstrdup(str); +	data = mir_wstrdup(str);  	if (data == NULL)  		goto err_out;  	if (wcsstr(mod, L"i")) @@ -143,7 +143,7 @@ BOOL _regmatch(wchar_t* str, wchar_t* strSearch)  	re = pcre16_compile(regexp, opts, &error, &erroroffs, NULL);  	if (re == NULL)  		goto err_out; -	rc = pcre16_exec(re, NULL, data, (int)mir_tstrlen(data), 0, 0, NULL, 0); +	rc = pcre16_exec(re, NULL, data, (int)mir_wstrlen(data), 0, 0, NULL, 0);  	pcre16_free(re);  	if (rc >= 0)  		ret = TRUE; @@ -169,12 +169,12 @@ int get_response_id(const wchar_t* strvar)  	re = pcre16_compile(regex, 0, &error, &erroroffs, NULL);  	if (re == NULL)  		return 0; // [TODO] and log some error -	_strvar = mir_tstrdup(strvar); +	_strvar = mir_wstrdup(strvar);  	if (_strvar == NULL) {  		pcre16_free(re);  		return 0;  	} -	rc = pcre16_exec(re, NULL, _strvar, (int)mir_tstrlen(_strvar), 0, 0, ovector, 9); +	rc = pcre16_exec(re, NULL, _strvar, (int)mir_wstrlen(_strvar), 0, 0, ovector, 9);  	pcre16_free(re);  	if (rc < 0) {  		ret = -1; @@ -195,7 +195,7 @@ int get_response_num(const wchar_t *str)  	if (str == NULL)  		return 0; -	strc = mir_tstrdup(str); +	strc = mir_wstrdup(str);  	if (strc == NULL)  		return 0;  	tmp = wcstok(strc, L"\r\n"); @@ -222,7 +222,7 @@ wchar_t* get_response(wchar_t* dst, unsigned int dstlen, int num)  	tmp = wcstok(src, L"\r\n");  	while (tmp) {  		if (i == num) { -			mir_tstrcpy(dst, tmp); +			mir_wstrcpy(dst, tmp);  			mir_free(src);  			return dst;  		} @@ -242,10 +242,10 @@ wchar_t* _tcsstr_cc(wchar_t* str, wchar_t* strSearch, BOOL cc)  	if (cc)  		return wcsstr(str, strSearch); -	_str = mir_tstrdup(str); +	_str = mir_wstrdup(str);  	if (_str == NULL)  		goto err_out; -	_strSearch = mir_tstrdup(strSearch); +	_strSearch = mir_wstrdup(strSearch);  	if (_strSearch == NULL)  		goto err_out;  	ret = wcsstr(_tcstolower(_str), _tcstolower(_strSearch)); @@ -266,17 +266,17 @@ BOOL Contains(wchar_t* dst, wchar_t* src) // Checks for occurence of substring f  	if (dst == NULL || src == NULL)  		return FALSE; -	tsrc = mir_tstrdup(src); +	tsrc = mir_wstrdup(src);  	if (tsrc == NULL)  		goto err_out; -	tdst = mir_tstrdup(dst); +	tdst = mir_wstrdup(dst);  	if (tdst == NULL)  		goto err_out;  	tdst = _tcstoupper(tdst); -	dst_len = mir_tstrlen(tdst); +	dst_len = mir_wstrlen(tdst);  	token = wcstok(tsrc, L",");  	while (token) { -		token_end = (token + mir_tstrlen(token)); +		token_end = (token + mir_wstrlen(token));  		while (!wcsncmp(token, L" ", 1)) { /* Skeep spaces at start. */  			token ++;  		} @@ -328,9 +328,9 @@ wchar_t* ReplaceVar(wchar_t *dst, unsigned int len, const wchar_t *var, const wc  	if (dst == NULL || var == NULL || rvar == NULL)  		return NULL; -	dst_len = mir_tstrlen(dst); -	var_len = mir_tstrlen(var); -	rvar_len = mir_tstrlen(rvar); +	dst_len = mir_wstrlen(dst); +	var_len = mir_wstrlen(var); +	rvar_len = mir_wstrlen(rvar);  	var_start = wcsstr(dst, var);  	while (var_start) {  		if (len < (dst_len + rvar_len - var_len + 1)) @@ -382,14 +382,14 @@ wchar_t* ReplaceVarsNum(wchar_t *dst, unsigned int len, int num)  	}  	do { -		_str = mir_tstrdup(dst); -		dstcopy = mir_tstrdup(dst); +		_str = mir_wstrdup(dst); +		dstcopy = mir_wstrdup(dst);  		if (_str == NULL || dstcopy == NULL) {  			mir_free(_str);  			mir_free(dstcopy);  			goto err_out;  		} -		rc = pcre16_exec(re, NULL, _str, (int)mir_tstrlen(_str), 0, 0, ovector, 9); +		rc = pcre16_exec(re, NULL, _str, (int)mir_wstrlen(_str), 0, 0, ovector, 9);  		if (rc < 0) {  			ret = -1;  		} else if (rc == 3) { @@ -427,7 +427,7 @@ int _notify(MCONTACT hContact, BYTE type, wchar_t *message, wchar_t *origmessage  {  	char *tmp, *tmporig;  	wchar_t msg[MAX_BUFFER_LENGTH]; -	mir_sntprintf(msg, message, pcli->pfnGetContactDisplayName(hContact, 0)); +	mir_snwprintf(msg, message, pcli->pfnGetContactDisplayName(hContact, 0));  	if (_getOptB("LogActions", defaultLogActions)) {  		tmp = mir_u2a(msg); | 
