From 690f3c5828685ffc3c2a11d8d68e4c0b1cf5f0ba Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 13 May 2016 20:27:01 +0000 Subject: major memory leak in ICQ cookie module git-svn-id: http://svn.miranda-ng.org/main/trunk@16829 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/src/cookies.cpp | 86 ++++++++++------------ protocols/IcqOscarJ/src/cookies.h | 73 +++++++++---------- protocols/IcqOscarJ/src/fam_13servclist.cpp | 5 +- protocols/IcqOscarJ/src/i18n.cpp | 2 +- protocols/IcqOscarJ/src/icq_avatar.cpp | 2 +- protocols/IcqOscarJ/src/icq_avatar.h | 2 - protocols/IcqOscarJ/src/icq_proto.h | 2 +- protocols/IcqOscarJ/src/utilities.cpp | 42 ++++------- protocols/IcqOscarJ/src/utilities.h | 106 ++++++++++++++-------------- 9 files changed, 142 insertions(+), 178 deletions(-) (limited to 'protocols/IcqOscarJ') diff --git a/protocols/IcqOscarJ/src/cookies.cpp b/protocols/IcqOscarJ/src/cookies.cpp index a18fdc7f87..77aaa6b001 100644 --- a/protocols/IcqOscarJ/src/cookies.cpp +++ b/protocols/IcqOscarJ/src/cookies.cpp @@ -29,19 +29,13 @@ #include "stdafx.h" -#define INVALID_COOKIE_INDEX -1 - void CIcqProto::RemoveExpiredCookies() { time_t tNow = time(NULL); - for (int i = cookies.getCount() - 1; i >= 0; i--) { - icq_cookie_info *cookie = cookies[i]; - if ((cookie->dwTime + COOKIE_TIMEOUT) < tNow) { + for (int i = cookies.getCount() - 1; i >= 0; i--) + if ((cookies[i].dwTime + COOKIE_TIMEOUT) < tNow) cookies.remove(i); - SAFE_FREE((void**)&cookie); - } - } } // Generate and allocate cookie @@ -53,15 +47,14 @@ DWORD CIcqProto::AllocateCookie(BYTE bType, WORD wIdent, MCONTACT hContact, void dwThisSeq &= 0x7FFF; dwThisSeq |= wIdent << 0x10; - icq_cookie_info* p = (icq_cookie_info*)SAFE_MALLOC(sizeof(icq_cookie_info)); - if (p) { - p->bType = bType; - p->dwCookie = dwThisSeq; - p->hContact = hContact; - p->pvExtra = pvExtra; - p->dwTime = time(NULL); - cookies.insert(p); - } + icq_cookie_info *p = new icq_cookie_info(); + p->bType = bType; + p->dwCookie = dwThisSeq; + p->hContact = hContact; + p->pvExtra = pvExtra; + p->dwTime = time(NULL); + cookies.insert(p); + return dwThisSeq; } @@ -80,8 +73,8 @@ int CIcqProto::GetCookieType(DWORD dwCookie) mir_cslock l(cookieMutex); int i = cookies.getIndex((icq_cookie_info*)&dwCookie); - if (i != INVALID_COOKIE_INDEX) - i = cookies[i]->bType; + if (i != -1) + i = cookies[i].bType; return i; } @@ -91,11 +84,11 @@ int CIcqProto::FindCookie(DWORD dwCookie, MCONTACT *phContact, void **ppvExtra) mir_cslock l(cookieMutex); int i = cookies.getIndex((icq_cookie_info*)&dwCookie); - if (i != INVALID_COOKIE_INDEX) { + if (i != -1) { if (phContact) - *phContact = cookies[i]->hContact; + *phContact = cookies[i].hContact; if (ppvExtra) - *ppvExtra = cookies[i]->pvExtra; + *ppvExtra = cookies[i].pvExtra; // Cookie found return 1; @@ -109,11 +102,12 @@ int CIcqProto::FindCookieByData(void *pvExtra, DWORD *pdwCookie, MCONTACT *phCon mir_cslock l(cookieMutex); for (int i = 0; i < cookies.getCount(); i++) { - if (pvExtra == cookies[i]->pvExtra) { + icq_cookie_info &cookie = cookies[i]; + if (pvExtra == cookie.pvExtra) { if (phContact) - *phContact = cookies[i]->hContact; + *phContact = cookie.hContact; if (pdwCookie) - *pdwCookie = cookies[i]->dwCookie; + *pdwCookie = cookie.dwCookie; // Cookie found return 1; @@ -123,18 +117,20 @@ int CIcqProto::FindCookieByData(void *pvExtra, DWORD *pdwCookie, MCONTACT *phCon return 0; } -int CIcqProto::FindCookieByType(BYTE bType, DWORD *pdwCookie, MCONTACT *phContact, void** ppvExtra) +int CIcqProto::FindCookieByType(BYTE bType, DWORD *pdwCookie, MCONTACT *phContact, void **ppvExtra) { mir_cslock l(cookieMutex); for (int i = 0; i < cookies.getCount(); i++) { - if (bType == cookies[i]->bType) { + icq_cookie_info &cookie = cookies[i]; + + if (bType == cookie.bType) { if (pdwCookie) - *pdwCookie = cookies[i]->dwCookie; + *pdwCookie = cookie.dwCookie; if (phContact) - *phContact = cookies[i]->hContact; + *phContact = cookie.hContact; if (ppvExtra) - *ppvExtra = cookies[i]->pvExtra; + *ppvExtra = cookie.pvExtra; // Cookie found return 1; @@ -149,15 +145,16 @@ int CIcqProto::FindMessageCookie(DWORD dwMsgID1, DWORD dwMsgID2, DWORD *pdwCooki mir_cslock l(cookieMutex); for (int i = 0; i < cookies.getCount(); i++) { - if (cookies[i]->bType == CKT_MESSAGE || cookies[i]->bType == CKT_FILE || cookies[i]->bType == CKT_REVERSEDIRECT) { + icq_cookie_info &cookie = cookies[i]; + if (cookie.bType == CKT_MESSAGE || cookie.bType == CKT_FILE || cookie.bType == CKT_REVERSEDIRECT) { // message cookie found - cookie_message_data *pCookie = (cookie_message_data*)cookies[i]->pvExtra; + cookie_message_data *pCookie = (cookie_message_data*)cookie.pvExtra; if (pCookie->dwMsgID1 == dwMsgID1 && pCookie->dwMsgID2 == dwMsgID2) { if (phContact) - *phContact = cookies[i]->hContact; + *phContact = cookie.hContact; if (pdwCookie) - *pdwCookie = cookies[i]->dwCookie; + *pdwCookie = cookie.dwCookie; if (ppvExtra) *ppvExtra = pCookie; @@ -175,13 +172,8 @@ void CIcqProto::FreeCookie(DWORD dwCookie) mir_cslock l(cookieMutex); int i = cookies.getIndex((icq_cookie_info*)&dwCookie); - if (i != INVALID_COOKIE_INDEX) { - // Cookie found, remove from list - icq_cookie_info *cookie = cookies[i]; - + if (i != -1) // Cookie found, remove from list cookies.remove(i); - SAFE_FREE((void**)&cookie); - } RemoveExpiredCookies(); } @@ -191,11 +183,10 @@ void CIcqProto::FreeCookieByData(BYTE bType, void *pvExtra) mir_cslock l(cookieMutex); for (int i = 0; i < cookies.getCount(); i++) { - icq_cookie_info *cookie = cookies[i]; - if (bType == cookie->bType && pvExtra == cookie->pvExtra) { + icq_cookie_info &cookie = cookies[i]; + if (bType == cookie.bType && pvExtra == cookie.pvExtra) { // Cookie found, remove from list cookies.remove(i); - SAFE_FREE((void**)&cookie); break; } } @@ -208,14 +199,11 @@ void CIcqProto::ReleaseCookie(DWORD dwCookie) mir_cslock l(cookieMutex); int i = cookies.getIndex(( icq_cookie_info* )&dwCookie ); - if (i != INVALID_COOKIE_INDEX) { - // Cookie found, remove from list - icq_cookie_info *cookie = cookies[i]; - + if (i != -1) { // Cookie found, remove from list + SAFE_FREE((void**)&cookies[i].pvExtra); cookies.remove(i); - SAFE_FREE((void**)&cookie->pvExtra); - SAFE_FREE((void**)&cookie); } + RemoveExpiredCookies(); } diff --git a/protocols/IcqOscarJ/src/cookies.h b/protocols/IcqOscarJ/src/cookies.h index 82178f9b01..843cc404ad 100644 --- a/protocols/IcqOscarJ/src/cookies.h +++ b/protocols/IcqOscarJ/src/cookies.h @@ -41,43 +41,41 @@ struct CIcqProto; /* Basic structure used to hold operation cookies list */ -struct icq_cookie_info + +struct icq_cookie_info : public MZeroedObject { - DWORD dwCookie; - MCONTACT hContact; - void *pvExtra; - time_t dwTime; - BYTE bType; + DWORD dwCookie; + MCONTACT hContact; + void *pvExtra; + time_t dwTime; + BYTE bType; }; - /* Specific structures to hold request specific data - pvExtra */ struct cookie_family_request { - WORD wFamily; - void (CIcqProto::*familyHandler)(HANDLE hConn, char* cookie, size_t cookieLen); + WORD wFamily; + void (CIcqProto::*familyHandler)(HANDLE hConn, char* cookie, size_t cookieLen); }; - struct cookie_offline_messages { - int nMessages; - int nMissed; + int nMessages; + int nMissed; }; - #define ACKTYPE_NONE 0 #define ACKTYPE_SERVER 1 #define ACKTYPE_CLIENT 2 struct cookie_message_data { - DWORD dwMsgID1; - DWORD dwMsgID2; - WORD bMessageType; - BYTE nAckType; - BYTE isOffline; + DWORD dwMsgID1; + DWORD dwMsgID2; + WORD bMessageType; + BYTE nAckType; + BYTE isOffline; }; #define REQUESTTYPE_OWNER 0 @@ -88,10 +86,9 @@ struct cookie_message_data struct cookie_fam15_data { - BYTE bRequestType; + BYTE bRequestType; }; - #define SEARCHTYPE_UID 0 #define SEARCHTYPE_EMAIL 1 #define SEARCHTYPE_NAMES 2 @@ -99,33 +96,30 @@ struct cookie_fam15_data struct cookie_search { - BYTE bSearchType; - char* szObject; - DWORD dwMainId; - DWORD dwStatus; + BYTE bSearchType; + char* szObject; + DWORD dwMainId; + DWORD dwStatus; }; - struct cookie_avatar { - DWORD dwUin; - MCONTACT hContact; - size_t hashlen; - BYTE *hash; - size_t cbData; - TCHAR *szFile; + DWORD dwUin; + MCONTACT hContact; + size_t hashlen; + BYTE *hash; + size_t cbData; + TCHAR *szFile; }; - -struct cookie_reverse_connect: public cookie_message_data +struct cookie_reverse_connect : public cookie_message_data { - MCONTACT hContact; - DWORD dwUin; - int type; - void *ft; + MCONTACT hContact; + DWORD dwUin; + int type; + void *ft; }; - #define DIRECTORYREQUEST_INFOUSER 0x01 #define DIRECTORYREQUEST_INFOOWNER 0x02 #define DIRECTORYREQUEST_INFOMULTI 0x03 @@ -136,8 +130,7 @@ struct cookie_reverse_connect: public cookie_message_data struct cookie_directory_data { - BYTE bRequestType; + BYTE bRequestType; }; - #endif /* __COOKIES_H */ diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp index a447dfe7dc..3c11e20a7f 100644 --- a/protocols/IcqOscarJ/src/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp @@ -33,10 +33,9 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_hea case ICQ_LISTS_ACK: // UPDATE_ACK if (wBufferLength >= 2) { WORD wError; - cookie_servlist_action* sc; - unpackWord(&pBuffer, &wError); + cookie_servlist_action *sc; if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // look for action cookie debugLogA("Received expected server list ack, action: %d, result: %d", sc->dwAction, wError); FreeCookie(pSnacHeader->dwRef); // release cookie @@ -47,7 +46,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_hea debugLogA("Server-List: Grouped action contains %d actions.", sc->dwGroupCount); pBuffer -= 2; // revoke unpack - if (wBufferLength != 2 * sc->dwGroupCount) + if ((int)wBufferLength != 2 * sc->dwGroupCount) debugLogA("Error: Server list ack does not contain expected amount of result codes (%u != %u)", wBufferLength / 2, sc->dwGroupCount); for (i = 0; i < sc->dwGroupCount; i++) { diff --git a/protocols/IcqOscarJ/src/i18n.cpp b/protocols/IcqOscarJ/src/i18n.cpp index 2dfc79d17a..fa855d55ee 100644 --- a/protocols/IcqOscarJ/src/i18n.cpp +++ b/protocols/IcqOscarJ/src/i18n.cpp @@ -368,7 +368,7 @@ int __stdcall utf8_decode_codepage(const char *from, char **to, WORD wCp) } int err = WideCharToMultiByte(wCp, WC_COMPOSITECHECK, unicode, -1, *to, (int)chars, NULL, NULL); - if (err != chars) { + if (err != (int)chars) { #ifdef _DEBUG fprintf(stderr, "Unicode translation error %d\n", GetLastError()); #endif diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index 284ccf03d4..a48ba14ee5 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -932,7 +932,7 @@ void avatars_server_connection::connectionThread() { // release rates mir_cslock l(m_ratesMutex); - SAFE_DELETE((MZeroedObject**)&m_rates); + delete m_rates; m_rates = NULL; } SAFE_FREE((void**)&pCookie); diff --git a/protocols/IcqOscarJ/src/icq_avatar.h b/protocols/IcqOscarJ/src/icq_avatar.h index 240a7f076a..5ba1e03c79 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.h +++ b/protocols/IcqOscarJ/src/icq_avatar.h @@ -107,8 +107,6 @@ public: virtual ~avatars_request(); }; -__inline static void SAFE_DELETE(avatars_request **p) { SAFE_DELETE((MZeroedObject**)p); }; - #define ART_GET 1 #define ART_UPLOAD 2 #define ART_BLOCK 4 diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h index d1d8d677c8..97ca496006 100644 --- a/protocols/IcqOscarJ/src/icq_proto.h +++ b/protocols/IcqOscarJ/src/icq_proto.h @@ -221,7 +221,7 @@ struct CIcqProto : public PROTO //----| cookies.cpp |----------------------------------------------------------------- mir_cs cookieMutex; // we want this in avatar thread, used as queue lock - LIST cookies; + OBJLIST cookies; WORD wCookieSeq; DWORD AllocateCookie(BYTE bType, WORD wIdent, MCONTACT hContact, void *pvExtra); diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 6ad5193126..26ffc7ed66 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -370,18 +370,17 @@ void CIcqProto::InitContactsCache() void CIcqProto::UninitContactsCache(void) { - { mir_cslock l(contactsCacheMutex); - - // cleanup the cache - for (int i = 0; i < contactsCache.getCount(); i++) { - icq_contacts_cache *cache_item = contactsCache[i]; + mir_cslock l(contactsCacheMutex); - SAFE_FREE((void**)&cache_item->szUid); - SAFE_FREE((void**)&cache_item); - } + // cleanup the cache + for (int i = 0; i < contactsCache.getCount(); i++) { + icq_contacts_cache *cache_item = contactsCache[i]; - contactsCache.destroy(); + SAFE_FREE((void**)&cache_item->szUid); + SAFE_FREE((void**)&cache_item); } + + contactsCache.destroy(); } @@ -419,7 +418,8 @@ MCONTACT CIcqProto::HandleFromCacheByUid(DWORD dwUin, const char *szUid) MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added) { - if (Added) *Added = 0; + if (Added) + *Added = 0; MCONTACT hContact = HandleFromCacheByUid(dwUin, NULL); if (hContact) @@ -438,7 +438,7 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added) hContact = db_find_next(hContact, m_szModuleName); } - //not present: add + // not present: add if (Added) { debugLogA("Attempt to create ICQ contact %u", dwUin); @@ -486,13 +486,15 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added) if (dwUin) return HContactFromUIN(dwUin, Added); - if (Added) *Added = 0; + if (Added) + *Added = 0; if (!m_bAimEnabled) return INVALID_CONTACT_ID; MCONTACT hContact = HandleFromCacheByUid(dwUin, szUid); - if (hContact) return hContact; + if (hContact) + return hContact; hContact = db_find_first(m_szModuleName); while (hContact) { @@ -529,7 +531,6 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added) } AddToContactsCache(hContact, 0, szUid); *Added = 1; - return hContact; } @@ -1317,16 +1318,6 @@ bool CIcqProto::validateStatusMessageRequest(MCONTACT hContact, WORD byMessageTy return true; } - -void __fastcall SAFE_DELETE(MZeroedObject **p) -{ - if (*p) { - delete *p; - *p = NULL; - } -} - - void __fastcall SAFE_FREE(void** p) { if (*p) { @@ -1335,7 +1326,6 @@ void __fastcall SAFE_FREE(void** p) } } - void* __fastcall SAFE_MALLOC(size_t size) { void* p = NULL; @@ -1348,7 +1338,6 @@ void* __fastcall SAFE_MALLOC(size_t size) return p; } - void* __fastcall SAFE_REALLOC(void* p, size_t size) { if (p) @@ -1357,7 +1346,6 @@ void* __fastcall SAFE_REALLOC(void* p, size_t size) return SAFE_MALLOC(size); } - DWORD ICQWaitForSingleObject(HANDLE hObject, DWORD dwMilliseconds, int bWaitAlways) { DWORD dwResult; diff --git a/protocols/IcqOscarJ/src/utilities.h b/protocols/IcqOscarJ/src/utilities.h index c807a804c3..783ff2fea7 100644 --- a/protocols/IcqOscarJ/src/utilities.h +++ b/protocols/IcqOscarJ/src/utilities.h @@ -45,93 +45,91 @@ struct icq_contacts_cache /*---------* Functions *---------------*/ -void MoveDlgItem(HWND hwndDlg, int iItem, int left, int top, int width, int height); -void EnableDlgItem(HWND hwndDlg, UINT control, int state); -void ShowDlgItem(HWND hwndDlg, UINT control, int state); -void icq_EnableMultipleControls(HWND hwndDlg, const UINT* controls, int cControls, int state); -void icq_ShowMultipleControls(HWND hwndDlg, const UINT* controls, int cControls, int state); -int IcqStatusToMiranda(WORD wStatus); -WORD MirandaStatusToIcq(int nStatus); -int MirandaStatusToSupported(int nMirandaStatus); -char *MirandaStatusToStringUtf(int); - -int AwayMsgTypeToStatus(int nMsgType); +void MoveDlgItem(HWND hwndDlg, int iItem, int left, int top, int width, int height); +void EnableDlgItem(HWND hwndDlg, UINT control, int state); +void ShowDlgItem(HWND hwndDlg, UINT control, int state); +void icq_EnableMultipleControls(HWND hwndDlg, const UINT* controls, int cControls, int state); +void icq_ShowMultipleControls(HWND hwndDlg, const UINT* controls, int cControls, int state); +int IcqStatusToMiranda(WORD wStatus); +WORD MirandaStatusToIcq(int nStatus); +int MirandaStatusToSupported(int nMirandaStatus); +char* MirandaStatusToStringUtf(int); + +int AwayMsgTypeToStatus(int nMsgType); void SetGatewayIndex(HANDLE hConn, DWORD dwIndex); DWORD GetGatewayIndex(HANDLE hConn); void FreeGatewayIndex(HANDLE hConn); -char *NickFromHandle(MCONTACT hContact); -char *NickFromHandleUtf(MCONTACT hContact); -char *strUID(DWORD dwUIN, char *pszUID); +char* NickFromHandle(MCONTACT hContact); +char* NickFromHandleUtf(MCONTACT hContact); +char* strUID(DWORD dwUIN, char *pszUID); -char* __fastcall strstrnull(const char *str, const char *substr); -char* __fastcall null_strdup(const char *string); -char* __fastcall null_strcpy(char *dest, const char *src, size_t maxlen); +char* __fastcall strstrnull(const char *str, const char *substr); +char* __fastcall null_strdup(const char *string); +char* __fastcall null_strcpy(char *dest, const char *src, size_t maxlen); size_t __fastcall null_strcut(char *string, size_t maxlen); WCHAR* __fastcall null_strdup(const WCHAR *string); WCHAR* __fastcall null_strcpy(WCHAR *dest, const WCHAR *src, size_t maxlen); -void parseServerAddress(char *szServer, WORD* wPort); +void parseServerAddress(char *szServer, WORD* wPort); -char *DemangleXml(const char *string, size_t len); -char *MangleXml(const char *string, size_t len); -char *EliminateHtml(const char *string, size_t len); -char *ApplyEncoding(const char *string, const char *pszEncoding); +char* DemangleXml(const char *string, size_t len); +char* MangleXml(const char *string, size_t len); +char* EliminateHtml(const char *string, size_t len); +char* ApplyEncoding(const char *string, const char *pszEncoding); -int RandRange(int nLow, int nHigh); +int RandRange(int nLow, int nHigh); -bool IsStringUIN(const char *pszString); +bool IsStringUIN(const char *pszString); -char* time2text(time_t time); +char* time2text(time_t time); -void __fastcall SAFE_FREE(void** p); -void* __fastcall SAFE_MALLOC(size_t size); -void* __fastcall SAFE_REALLOC(void* p, size_t size); +void __fastcall SAFE_FREE(void** p); +void* __fastcall SAFE_MALLOC(size_t size); +void* __fastcall SAFE_REALLOC(void* p, size_t size); __inline static void SAFE_FREE(char** str) { SAFE_FREE((void**)str); } __inline static void SAFE_FREE(WCHAR** str) { SAFE_FREE((void**)str); } -void __fastcall SAFE_DELETE(MZeroedObject **p); - -DWORD ICQWaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds, int bWaitAlways = FALSE); +DWORD ICQWaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds, int bWaitAlways = FALSE); HANDLE NetLib_OpenConnection(HANDLE hUser, const char* szIdent, NETLIBOPENCONNECTION* nloc); -void NetLib_CloseConnection(HANDLE *hConnection, int bServerConn); -void NetLib_SafeCloseHandle(HANDLE *hConnection); +void NetLib_CloseConnection(HANDLE *hConnection, int bServerConn); +void NetLib_SafeCloseHandle(HANDLE *hConnection); -char* __fastcall ICQTranslateUtf(const char *src); -char* __fastcall ICQTranslateUtfStatic(const char *src, char *buf, size_t bufsize); +char* __fastcall ICQTranslateUtf(const char *src); +char* __fastcall ICQTranslateUtfStatic(const char *src, char *buf, size_t bufsize); -WORD GetMyStatusFlags(); +WORD GetMyStatusFlags(); /* Unicode FS utility functions */ -int IsValidRelativePath(const char *filename); -const char* ExtractFileName(const char *fullname); -char* FileNameToUtf(const TCHAR *filename); +int IsValidRelativePath(const char *filename); +LPCSTR ExtractFileName(const char *fullname); +char* FileNameToUtf(const TCHAR *filename); -int FileAccessUtf(const char *path, int mode); -int FileStatUtf(const char *path, struct _stati64 *buffer); -int MakeDirUtf(const char *dir); -int OpenFileUtf(const char *filename, int oflag, int pmode); +int FileAccessUtf(const char *path, int mode); +int FileStatUtf(const char *path, struct _stati64 *buffer); +int MakeDirUtf(const char *dir); +int OpenFileUtf(const char *filename, int oflag, int pmode); /* Unicode UI utility functions */ WCHAR* GetWindowTextUcs(HWND hWnd); -void SetWindowTextUcs(HWND hWnd, WCHAR *text); -char *GetWindowTextUtf(HWND hWnd); -char *GetDlgItemTextUtf(HWND hwndDlg, int iItem); -void SetWindowTextUtf(HWND hWnd, const char *szText); -void SetDlgItemTextUtf(HWND hwndDlg, int iItem, const char *szText); +void SetWindowTextUcs(HWND hWnd, WCHAR *text); +char* GetWindowTextUtf(HWND hWnd); +char* GetDlgItemTextUtf(HWND hwndDlg, int iItem); +void SetWindowTextUtf(HWND hWnd, const char *szText); +void SetDlgItemTextUtf(HWND hwndDlg, int iItem, const char *szText); -int ComboBoxAddStringUtf(HWND hCombo, const char *szString, DWORD data); -int ListBoxAddStringUtf(HWND hList, const char *szString); +int ComboBoxAddStringUtf(HWND hCombo, const char *szString, DWORD data); +int ListBoxAddStringUtf(HWND hList, const char *szString); -int MessageBoxUtf(HWND hWnd, const char *szText, const char *szCaption, UINT uType); +int MessageBoxUtf(HWND hWnd, const char *szText, const char *szCaption, UINT uType); -void InitXStatusIcons(); -void setContactExtraIcon(MCONTACT hContact, int xstatus); -int OnReloadIcons(WPARAM wParam, LPARAM lParam); +void InitXStatusIcons(); +void setContactExtraIcon(MCONTACT hContact, int xstatus); +int OnReloadIcons(WPARAM wParam, LPARAM lParam); #endif /* __UTILITIES_H */ -- cgit v1.2.3