From f18d37c4c90bc39f295fea9fedbfae0e806d9f61 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 7 Feb 2017 00:24:03 +0300 Subject: rest of ANSI macros removed --- protocols/IcqOscarJ/src/db.cpp | 2 +- protocols/IcqOscarJ/src/dlgproc.cpp | 2 +- protocols/IcqOscarJ/src/editlist.cpp | 2 +- protocols/IcqOscarJ/src/fam_04message.cpp | 8 ++--- protocols/IcqOscarJ/src/fam_0alookup.cpp | 4 +-- protocols/IcqOscarJ/src/i18n.h | 42 +++++++++++--------------- protocols/IcqOscarJ/src/icq_proto.cpp | 22 +++++++------- protocols/IcqOscarJ/src/icq_servlist.cpp | 10 +++--- protocols/IcqOscarJ/src/oscar_filetransfer.cpp | 6 ++-- protocols/IcqOscarJ/src/stdpackets.cpp | 2 +- protocols/IcqOscarJ/src/utilities.cpp | 16 +++++----- 11 files changed, 55 insertions(+), 61 deletions(-) diff --git a/protocols/IcqOscarJ/src/db.cpp b/protocols/IcqOscarJ/src/db.cpp index 8cc0736bc0..47e6138728 100644 --- a/protocols/IcqOscarJ/src/db.cpp +++ b/protocols/IcqOscarJ/src/db.cpp @@ -85,7 +85,7 @@ void ChangeInfoData::LoadSettingsFromDb(int keepChanged) char buf[MAX_PATH]; wchar_t tbuf[MAX_PATH]; - if (utf8_to_tchar_static(GetItemSettingText(i, buf, _countof(buf)), tbuf, _countof(tbuf))) + if (make_unicode_string_static(GetItemSettingText(i, buf, _countof(buf)), tbuf, _countof(tbuf))) ListView_SetItemText(hwndList, i, 1, tbuf); } } diff --git a/protocols/IcqOscarJ/src/dlgproc.cpp b/protocols/IcqOscarJ/src/dlgproc.cpp index cf1a1a8f1c..d14a2a2658 100644 --- a/protocols/IcqOscarJ/src/dlgproc.cpp +++ b/protocols/IcqOscarJ/src/dlgproc.cpp @@ -204,7 +204,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM wchar_t text[MAX_PATH]; lvi.lParam = lvi.iItem; lvi.pszText = text; - utf8_to_tchar_static(setting[lvi.iItem].szDescription, text, _countof(text)); + make_unicode_string_static(setting[lvi.iItem].szDescription, text, _countof(text)); ListView_InsertItem(dat->hwndList, &lvi); } } diff --git a/protocols/IcqOscarJ/src/editlist.cpp b/protocols/IcqOscarJ/src/editlist.cpp index 90b24c5daa..f9b354dcbd 100644 --- a/protocols/IcqOscarJ/src/editlist.cpp +++ b/protocols/IcqOscarJ/src/editlist.cpp @@ -175,7 +175,7 @@ void ChangeInfoData::EndListEdit(int save) if (sid.changed) { char buf[MAX_PATH]; wchar_t tbuf[MAX_PATH]; - if (utf8_to_tchar_static(ICQTranslateUtfStatic(pItem.text, buf, _countof(buf)), tbuf, _countof(buf))) + if (make_unicode_string_static(ICQTranslateUtfStatic(pItem.text, buf, _countof(buf)), tbuf, _countof(buf))) ListView_SetItemText(hwndList, iEditItem, 1, tbuf); EnableDlgItem(GetParent(hwndList), IDC_SAVE, TRUE); diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index 020c07db0a..8a5c5c76f3 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -949,7 +949,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, c contacts[iContact]->hdr.cbSize = sizeof(ICQSEARCHRESULT); contacts[iContact]->hdr.flags = PSR_UNICODE; contacts[iContact]->hdr.nick.w = null_strdup(L""); - contacts[iContact]->hdr.id.w = ansi_to_tchar(szUid); + contacts[iContact]->hdr.id.w = ansi_to_unicode(szUid); if (IsStringUIN(szUid)) { // icq contact contacts[iContact]->uin = atoi(szUid); @@ -1016,7 +1016,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, c unpackTypedTLV(pBuffer, wNickLen, 0x01, &wNickTLV, &wNickTLVLen, (LPBYTE*)&pNick); if (wNickTLV == 0x01) { SAFE_FREE(&contacts[iContact]->hdr.nick.w); - contacts[iContact]->hdr.nick.w = utf8_to_tchar(pNick); + contacts[iContact]->hdr.nick.w = make_unicode_string(pNick); } else SAFE_FREE(&pNick); @@ -1685,8 +1685,8 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, if (!mir_strlen(pszMsgField[1 + i * 2])) valid = 0; } - isrList[i]->hdr.id.w = ansi_to_tchar(pszMsgField[1 + i * 2]); - isrList[i]->hdr.nick.w = ansi_to_tchar(pszMsgField[2 + i * 2]); + isrList[i]->hdr.id.w = ansi_to_unicode(pszMsgField[1 + i * 2]); + isrList[i]->hdr.nick.w = ansi_to_unicode(pszMsgField[2 + i * 2]); } if (!valid) diff --git a/protocols/IcqOscarJ/src/fam_0alookup.cpp b/protocols/IcqOscarJ/src/fam_0alookup.cpp index 909ae75838..64bdf872f3 100644 --- a/protocols/IcqOscarJ/src/fam_0alookup.cpp +++ b/protocols/IcqOscarJ/src/fam_0alookup.cpp @@ -93,14 +93,14 @@ void CIcqProto::handleLookupEmailReply(BYTE* buf, size_t wLen, DWORD dwCookie) sr.hdr.cbSize = sizeof(sr); sr.hdr.flags = PSR_UNICODE; - sr.hdr.email.w = ansi_to_tchar(pCookie->szObject); + sr.hdr.email.w = ansi_to_unicode(pCookie->szObject); // Syntax check, read chain if (wLen >= 4 && (pChain = readIntoTLVChain(&buf, wLen, 0))) { for (WORD i = 1; TRUE; i++) { // collect the results char *szUid = pChain->getString(0x01, i); if (!szUid) break; - sr.hdr.id.w = ansi_to_tchar(szUid); + sr.hdr.id.w = ansi_to_unicode(szUid); sr.hdr.nick.w = sr.hdr.id.w; // broadcast the result if (pCookie->dwMainId) diff --git a/protocols/IcqOscarJ/src/i18n.h b/protocols/IcqOscarJ/src/i18n.h index 923609c8a2..56533e95f8 100644 --- a/protocols/IcqOscarJ/src/i18n.h +++ b/protocols/IcqOscarJ/src/i18n.h @@ -30,37 +30,31 @@ #ifndef __I18N_H #define __I18N_H -BOOL __stdcall IsUSASCII(const char *pBuffer, size_t nSize); -BOOL __stdcall IsUnicodeAscii(const WCHAR *pBuffer, size_t nSize); -int __stdcall UTF8_IsValid(const char *pszInput); +BOOL CALLBACK IsUSASCII(const char *pBuffer, size_t nSize); +BOOL CALLBACK IsUnicodeAscii(const WCHAR *pBuffer, size_t nSize); +int CALLBACK UTF8_IsValid(const char *pszInput); -int __stdcall get_utf8_size(const WCHAR *unicode); +int CALLBACK get_utf8_size(const WCHAR *unicode); -char* __stdcall detect_decode_utf8(const char *from); +char* CALLBACK detect_decode_utf8(const char *from); -WCHAR* __stdcall make_unicode_string(const char *utf8); -WCHAR* __stdcall make_unicode_string_static(const char *utf8, WCHAR *unicode, size_t unicode_size); +WCHAR* CALLBACK make_unicode_string(const char *utf8); +WCHAR* CALLBACK make_unicode_string_static(const char *utf8, WCHAR *unicode, size_t unicode_size); -char* __stdcall make_utf8_string(const WCHAR *unicode); -char* __stdcall make_utf8_string_static(const WCHAR *unicode, char *utf8, size_t utf_size); +char* CALLBACK make_utf8_string(const WCHAR *unicode); +char* CALLBACK make_utf8_string_static(const WCHAR *unicode, char *utf8, size_t utf_size); -char* __stdcall ansi_to_utf8(const char *ansi); -char* __stdcall ansi_to_utf8_codepage(const char *ansi, WORD wCp); +char* CALLBACK ansi_to_utf8(const char *ansi); +char* CALLBACK ansi_to_utf8_codepage(const char *ansi, WORD wCp); -WCHAR* __stdcall ansi_to_unicode(const char *ansi); -char* __stdcall unicode_to_ansi(const WCHAR *unicode); -char* __stdcall unicode_to_ansi_static(const WCHAR *unicode, char *ansi, size_t ansi_size); +WCHAR* CALLBACK ansi_to_unicode(const char *ansi); +char* CALLBACK unicode_to_ansi(const WCHAR *unicode); +char* CALLBACK unicode_to_ansi_static(const WCHAR *unicode, char *ansi, size_t ansi_size); -int __stdcall utf8_encode(const char *from, char **to); -int __stdcall utf8_decode(const char *from, char **to); -int __stdcall utf8_decode_codepage(const char *from, char **to, WORD wCp); -int __stdcall utf8_decode_static(const char *from, char *to, size_t to_size); - -#define tchar_to_utf8 make_utf8_string -#define utf8_to_tchar_static make_unicode_string_static -#define utf8_to_tchar make_unicode_string -#define ansi_to_tchar ansi_to_unicode -#define tchar_to_ansi unicode_to_ansi +int CALLBACK utf8_encode(const char *from, char **to); +int CALLBACK utf8_decode(const char *from, char **to); +int CALLBACK utf8_decode_codepage(const char *from, char **to, WORD wCp); +int CALLBACK utf8_decode_static(const char *from, char *to, size_t to_size); void InitI18N(void); diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 7e9971925b..b12c000631 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -450,7 +450,7 @@ int __cdecl CIcqProto::AuthRequest(MCONTACT hContact, const wchar_t* szMessage) return 1; // Invalid contact if (dwUin) { - char *utf = tchar_to_utf8(szMessage); + char *utf = make_utf8_string(szMessage); icq_sendAuthReqServ(dwUin, szUid, utf); SAFE_FREE(&utf); return 0; // Success @@ -479,7 +479,7 @@ HANDLE __cdecl CIcqProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const w if (dwUin && bft->ft_magic == FT_MAGIC_ICQ) { filetransfer *ft = (filetransfer *)hTransfer; - ft->szSavePath = tchar_to_utf8(szPath); + ft->szSavePath = make_utf8_string(szPath); { mir_cslock l(expectedFileRecvMutex); expectedFileRecvs.insert(ft); @@ -550,7 +550,7 @@ int __cdecl CIcqProto::FileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar if (dwUin && bft->ft_magic == FT_MAGIC_ICQ) { // deny old fashioned file transfer filetransfer *ft = (filetransfer*)hTransfer; - char *szReasonUtf = tchar_to_utf8(szReason); + char *szReasonUtf = make_utf8_string(szReason); // Was request received thru DC and have we a open DC, send through that if (ft->bDC && IsDirectConnectionOpen(hContact, DIRECTCONN_STANDARD, 0)) icq_sendFileDenyDirect(hContact, ft, szReasonUtf); @@ -583,7 +583,7 @@ int __cdecl CIcqProto::FileResume(HANDLE hTransfer, int* action, const wchar_t** return 1; // Invalid transfer if (ft->ft_magic == FT_MAGIC_ICQ) { - char *szFileNameUtf = tchar_to_utf8(*szFilename); + char *szFileNameUtf = make_utf8_string(*szFilename); icq_sendFileResume((filetransfer *)hTransfer, *action, szFileNameUtf); SAFE_FREE(&szFileNameUtf); } @@ -795,7 +795,7 @@ HANDLE __cdecl CIcqProto::SearchBasic(const wchar_t *pszSearch) HANDLE __cdecl CIcqProto::SearchByEmail(const wchar_t *email) { if (email && icqOnline() && mir_wstrlen(email) > 0) { - char *szEmail = tchar_to_ansi(email); + char *szEmail = unicode_to_ansi(email); // Success DWORD dwSearchId = SearchByMail(szEmail); @@ -819,9 +819,9 @@ HANDLE __cdecl CIcqProto::SearchByName(const wchar_t *nick, const wchar_t *first { if (icqOnline()) { if (nick || firstName || lastName) { - char *nickUtf = tchar_to_utf8(nick); - char *firstNameUtf = tchar_to_utf8(firstName); - char *lastNameUtf = tchar_to_utf8(lastName); + char *nickUtf = make_utf8_string(nick); + char *firstNameUtf = make_utf8_string(firstName); + char *lastNameUtf = make_utf8_string(lastName); // Success HANDLE dwCookie = (HANDLE)SearchByNames(nickUtf, firstNameUtf, lastNameUtf, 0); @@ -1190,14 +1190,14 @@ HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const wchar_t* szDescripti ft->pszFiles = (char **)SAFE_MALLOC(sizeof(char *)* ft->dwFileCount); ft->dwTotalSize = 0; for (i = 0; i < (int)ft->dwFileCount; i++) { - ft->pszFiles[i] = (ppszFiles[i]) ? tchar_to_utf8(ppszFiles[i]) : NULL; + ft->pszFiles[i] = (ppszFiles[i]) ? make_utf8_string(ppszFiles[i]) : NULL; if (_wstat(ppszFiles[i], &statbuf)) debugLogA("IcqSendFile() was passed invalid filename(s)"); else ft->dwTotalSize += statbuf.st_size; } - ft->szDescription = tchar_to_utf8(szDescription); + ft->szDescription = make_utf8_string(szDescription); ft->dwTransferSpeed = 100; ft->sending = 1; ft->fileId = -1; @@ -1763,7 +1763,7 @@ int __cdecl CIcqProto::SetAwayMsg(int status, const wchar_t* msg) return 1; // Failure // Prepare UTF-8 status message - char *szNewUtf = tchar_to_utf8(msg); + char *szNewUtf = make_utf8_string(msg); if (mir_strcmp(szNewUtf, *ppszMsg)) { // Free old message diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index 2a031977e5..b4d8100f19 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -1369,7 +1369,7 @@ int CIcqProto::getCListGroupExists(const char *szGroup) size_t size = mir_strlen(szGroup) + 2; wchar_t *tszGroup = (wchar_t*)_alloca(size * sizeof(wchar_t)); - if (utf8_to_tchar_static(szGroup, tszGroup, size)) + if (make_unicode_string_static(szGroup, tszGroup, size)) for (int i = 1; TRUE; i++) { wchar_t *tszGroupName = (wchar_t*)Clist_GroupGetName(i, NULL); if (!tszGroupName) @@ -2331,7 +2331,7 @@ int CIcqProto::ServListCListGroupChange(WPARAM hContact, LPARAM lParam) if (hContact == NULL) { // change made to group if (grpchg->pszNewName == NULL && grpchg->pszOldName != NULL) { // group removed - char *szOldName = tchar_to_utf8(grpchg->pszOldName); + char *szOldName = make_utf8_string(grpchg->pszOldName); WORD wGroupId = getServListGroupLinkID(szOldName); if (wGroupId) { // the group is known, remove from server @@ -2341,8 +2341,8 @@ int CIcqProto::ServListCListGroupChange(WPARAM hContact, LPARAM lParam) SAFE_FREE(&szOldName); } else if (grpchg->pszNewName != NULL && grpchg->pszOldName != NULL) { // group renamed - char *szNewName = tchar_to_utf8(grpchg->pszNewName); - char *szOldName = tchar_to_utf8(grpchg->pszOldName); + char *szNewName = make_utf8_string(grpchg->pszNewName); + char *szOldName = make_utf8_string(grpchg->pszOldName); WORD wGroupId = getServListGroupLinkID(szOldName); if (wGroupId) { // group is known, rename on server @@ -2354,7 +2354,7 @@ int CIcqProto::ServListCListGroupChange(WPARAM hContact, LPARAM lParam) } else { // change to contact if (IsICQContact(hContact)) { // our contact, fine move on the server as well - char *szNewName = grpchg->pszNewName ? tchar_to_utf8(grpchg->pszNewName) : NULL; + char *szNewName = grpchg->pszNewName ? make_utf8_string(grpchg->pszNewName) : NULL; servlistMoveContact(hContact, szNewName); SAFE_FREE(&szNewName); } diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index ae5cbcb8af..b5b43800d2 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -756,7 +756,7 @@ HANDLE CIcqProto::oftInitTransfer(MCONTACT hContact, DWORD dwUin, char* szUid, c debugLogA("OFT: Found %d files.", ft->wFilesCount); - ft->szDescription = tchar_to_utf8(pszDesc); + ft->szDescription = make_utf8_string(pszDesc); ft->flags = OFTF_SENDING; ft->fileId = -1; ft->iCurrentFile = 0; @@ -843,7 +843,7 @@ HANDLE CIcqProto::oftFileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_ if (!IsValidOscarTransfer(ft)) return 0; // Invalid transfer - ft->szSavePath = tchar_to_utf8(szPath); + ft->szSavePath = make_utf8_string(szPath); if (ft->szThisPath) { // Append Directory name to the save path, when transfering a directory ft->szSavePath = (char*)SAFE_REALLOC(ft->szSavePath, mir_strlen(ft->szSavePath) + mir_strlen(ft->szThisPath) + 4); @@ -941,7 +941,7 @@ void CIcqProto::oftFileResume(oscar_filetransfer *ft, int action, const wchar_t case FILERESUME_RENAME: openFlags = _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY; SAFE_FREE(&ft->szThisFile); - ft->szThisFile = tchar_to_utf8(szFilename); + ft->szThisFile = make_utf8_string(szFilename); ft->qwFileBytesDone = 0; break; diff --git a/protocols/IcqOscarJ/src/stdpackets.cpp b/protocols/IcqOscarJ/src/stdpackets.cpp index 835cd5e26f..24c422c894 100644 --- a/protocols/IcqOscarJ/src/stdpackets.cpp +++ b/protocols/IcqOscarJ/src/stdpackets.cpp @@ -1552,7 +1552,7 @@ void CIcqProto::icq_sendAuthResponseServ(DWORD dwUin, char* szUid, int auth, con BYTE nUinLen = getUIDLen(dwUin, szUid); // Prepare custom utf-8 reason - char *szUtfReason = tchar_to_utf8(szReason); + char *szUtfReason = make_utf8_string(szReason); size_t nReasonLen = mir_strlen(szUtfReason); icq_packet packet; diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 85ef2b029d..5f0a2d6bb7 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -207,7 +207,7 @@ int MirandaStatusToSupported(int nMirandaStatus) char* MirandaStatusToStringUtf(int mirandaStatus) { // return miranda status description in utf-8, use unicode service is possible - return tchar_to_utf8(pcli->pfnGetStatusModeDescription(mirandaStatus, 0)); + return make_utf8_string(pcli->pfnGetStatusModeDescription(mirandaStatus, 0)); } char** CIcqProto::MirandaStatusToAwayMsg(int nStatus) @@ -570,7 +570,7 @@ char* NickFromHandleUtf(MCONTACT hContact) if (hContact == INVALID_CONTACT_ID) return ICQTranslateUtf(LPGEN("")); - return tchar_to_utf8(pcli->pfnGetContactDisplayName(hContact, 0)); + return make_utf8_string(pcli->pfnGetContactDisplayName(hContact, 0)); } char* strUID(DWORD dwUIN, char *pszUID) @@ -1556,7 +1556,7 @@ int FileAccessUtf(const char *path, int mode) size_t size = mir_strlen(path) + 2; wchar_t *szPath = (wchar_t*)_alloca(size * sizeof(wchar_t)); - if (utf8_to_tchar_static(path, szPath, size)) + if (make_unicode_string_static(path, szPath, size)) return _waccess(szPath, mode); return -1; @@ -1568,7 +1568,7 @@ int FileStatUtf(const char *path, struct _stati64 *buffer) size_t size = mir_strlen(path) + 2; wchar_t *szPath = (wchar_t*)_alloca(size * sizeof(wchar_t)); - if (utf8_to_tchar_static(path, szPath, size)) + if (make_unicode_string_static(path, szPath, size)) return _wstat64(szPath, buffer); return -1; @@ -1581,7 +1581,7 @@ int MakeDirUtf(const char *dir) size_t size = mir_strlen(dir) + 2; wchar_t *szDir = (wchar_t*)_alloca(size * sizeof(wchar_t)); - if (utf8_to_tchar_static(dir, szDir, size)) { // _wmkdir can created only one dir at once + if (make_unicode_string_static(dir, szDir, size)) { // _wmkdir can created only one dir at once wRes = _wmkdir(szDir); // check if dir not already existed - return success if yes if (wRes == -1 && errno == 17 /* EEXIST */) @@ -1610,7 +1610,7 @@ int OpenFileUtf(const char *filename, int oflag, int pmode) size_t size = mir_strlen(filename) + 2; wchar_t *szFile = (wchar_t*)_alloca(size * sizeof(wchar_t)); - if (utf8_to_tchar_static(filename, szFile, size)) + if (make_unicode_string_static(filename, szFile, size)) return _wopen(szFile, oflag, pmode); return -1; @@ -1639,7 +1639,7 @@ char* GetWindowTextUtf(HWND hWnd) GetWindowText(hWnd, szText, nLen + 1); - return tchar_to_utf8(szText); + return make_utf8_string(szText); } @@ -1654,7 +1654,7 @@ void SetWindowTextUtf(HWND hWnd, const char *szText) size_t size = mir_strlen(szText) + 2; wchar_t *tszText = (wchar_t*)_alloca(size * sizeof(wchar_t)); - if (utf8_to_tchar_static(szText, tszText, size)) + if (make_unicode_string_static(szText, tszText, size)) SetWindowText(hWnd, tszText); } -- cgit v1.2.3