diff options
Diffstat (limited to 'tipper/translations.cpp')
-rw-r--r-- | tipper/translations.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/tipper/translations.cpp b/tipper/translations.cpp index f22e726..4e5dbd8 100644 --- a/tipper/translations.cpp +++ b/tipper/translations.cpp @@ -2,6 +2,7 @@ #include "translations.h" #include <winsock.h> #include <time.h> +#include "str_utils.h" int num_tfuncs = 0; DBVTranslation *translations = 0; @@ -21,7 +22,7 @@ void AddTranslation(DBVTranslation *new_trans) { #ifdef _UNICODE WideCharToMultiByte(code_page, 0, new_trans->name, -1, setting, 256, 0, 0); #else - strncpy(setting, new_trans.name, 256); + strncpy(setting, new_trans->name, 256); #endif if(_tcscmp(new_trans->name, _T("[No translation]")) == 0) @@ -56,20 +57,20 @@ TCHAR *null_translation(HANDLE hContact, const char *module_name, const char *se DBFreeVariant(&dbv); return 0; case DBVT_BYTE: - _itow(dbv.bVal, buff, 10); + _itot(dbv.bVal, buff, 10); break; case DBVT_WORD: - _ltow(dbv.wVal, buff, 10); + _ltot(dbv.wVal, buff, 10); break; case DBVT_DWORD: - _ltow(dbv.dVal, buff, 10); + _ltot(dbv.dVal, buff, 10); break; case DBVT_ASCIIZ: - MultiByteToWideChar(code_page, 0, dbv.pszVal, -1, buff, bufflen); + a2t(dbv.pszVal, buff, bufflen); buff[bufflen - 1] = 0; break; case DBVT_UTF8: - MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, buff, bufflen); + u2t(dbv.pszVal, buff, bufflen); buff[bufflen - 1] = 0; break; //case DBVT_WCHAR: @@ -85,7 +86,7 @@ TCHAR *null_translation(HANDLE hContact, const char *module_name, const char *se } DBFreeVariant(&dbv); - if(wcslen(buff) == 0) + if(_tcslen(buff) == 0) return 0; return buff; } @@ -107,7 +108,7 @@ TCHAR *timestamp_to_short_date(HANDLE hContact, const char *module_name, const c dbt.szDest = buffA; dbt.szFormat = "d"; CallService(MS_DB_TIME_TIMESTAMPTOSTRING, (WPARAM)ts, (LPARAM)&dbt); - MultiByteToWideChar(code_page, 0, buffA, -1, buff, bufflen); + a2t(buffA, buff, bufflen); } buff[bufflen - 1] = 0; @@ -131,7 +132,7 @@ TCHAR *timestamp_to_long_date(HANDLE hContact, const char *module_name, const ch dbt.szDest = buffA; dbt.szFormat = "D"; CallService(MS_DB_TIME_TIMESTAMPTOSTRING, (WPARAM)ts, (LPARAM)&dbt); - MultiByteToWideChar(code_page, 0, buffA, -1, buff, bufflen); + a2t(buffA, buff, bufflen); } buff[bufflen - 1] = 0; @@ -155,7 +156,7 @@ TCHAR *timestamp_to_time(HANDLE hContact, const char *module_name, const char *s dbt.szDest = buffA; dbt.szFormat = "s"; CallService(MS_DB_TIME_TIMESTAMPTOSTRING, (WPARAM)ts, (LPARAM)&dbt); - MultiByteToWideChar(code_page, 0, buffA, -1, buff, bufflen); + a2t(buffA, buff, bufflen); } buff[bufflen - 1] = 0; @@ -179,7 +180,7 @@ TCHAR *timestamp_to_time_no_secs(HANDLE hContact, const char *module_name, const dbt.szDest = buffA; dbt.szFormat = "t"; CallService(MS_DB_TIME_TIMESTAMPTOSTRING, (WPARAM)ts, (LPARAM)&dbt); - MultiByteToWideChar(code_page, 0, buffA, -1, buff, bufflen); + a2t(buffA, buff, bufflen); } return buff; @@ -223,7 +224,7 @@ TCHAR *seconds_to_time_difference(HANDLE hContact, const char *module_name, cons TCHAR *word_to_status_desc(HANDLE hContact, const char *module_name, const char *setting_name, TCHAR *buff, int bufflen) { int status = DBGetContactSettingWord(hContact, module_name, setting_name, ID_STATUS_OFFLINE); char *strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, (LPARAM)0); - MultiByteToWideChar(code_page, 0, strptr, -1, buff, bufflen); + a2t(strptr, buff, bufflen); buff[bufflen - 1] = 0; return buff; } @@ -246,7 +247,7 @@ TCHAR *byte_to_yesno(HANDLE hContact, const char *module_name, const char *setti } TCHAR *byte_to_mf(HANDLE hContact, const char *module_name, const char *setting_name, TCHAR *buff, int bufflen) { - BYTE val = DBGetContactSettingByte(hContact, module_name, setting_name, 0); + BYTE val = (BYTE)DBGetContactSettingByte(hContact, module_name, setting_name, 0); if(val == 'F') _tcsncpy(buff, TranslateT("Female"), bufflen); else if(val == 'M') @@ -260,11 +261,11 @@ TCHAR *byte_to_mf(HANDLE hContact, const char *module_name, const char *setting_ TCHAR *word_to_country(HANDLE hContact, const char *module_name, const char *setting_name, TCHAR *buff, int bufflen) { char *cname = 0; - WORD cid = DBGetContactSettingWord(hContact, module_name, setting_name, (WORD)-1); + WORD cid = (WORD)DBGetContactSettingWord(hContact, module_name, setting_name, (WORD)-1); if(cid != (WORD)-1 && ServiceExists(MS_UTILS_GETCOUNTRYBYNUMBER) && (cname = (char *)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, cid, 0)) != 0) { if(strcmp(cname, "Unknown") == 0) return 0; - MultiByteToWideChar(code_page, 0, Translate(cname), -1, buff, bufflen); + a2t(cname, buff, bufflen); buff[bufflen - 1] = 0; return buff; } @@ -276,7 +277,7 @@ TCHAR *dword_to_ip(HANDLE hContact, const char *module_name, const char *setting if(ip) { in_addr in; in.S_un.S_addr = htonl(ip); - MultiByteToWideChar(code_page, 0, inet_ntoa(in), -1, buff, bufflen); + a2t(inet_ntoa(in), buff, bufflen); buff[bufflen - 1] = 0; return buff; } |