summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/IcqOscarJ/src/UI/userinfotab.cpp2
-rw-r--r--protocols/IcqOscarJ/src/capabilities.cpp6
-rw-r--r--protocols/IcqOscarJ/src/capabilities.h4
-rw-r--r--protocols/IcqOscarJ/src/chan_01login.cpp8
-rw-r--r--protocols/IcqOscarJ/src/chan_02data.cpp4
-rw-r--r--protocols/IcqOscarJ/src/chan_03error.cpp2
-rw-r--r--protocols/IcqOscarJ/src/chan_04close.cpp4
-rw-r--r--protocols/IcqOscarJ/src/chan_05ping.cpp2
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/db.cpp3
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp2
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/editstring.cpp14
-rw-r--r--protocols/IcqOscarJ/src/changeinfo/upload.cpp2
-rw-r--r--protocols/IcqOscarJ/src/channels.h2
-rw-r--r--protocols/IcqOscarJ/src/cookies.h14
-rw-r--r--protocols/IcqOscarJ/src/directpackets.cpp122
-rw-r--r--protocols/IcqOscarJ/src/fam_01service.cpp36
-rw-r--r--protocols/IcqOscarJ/src/fam_02location.cpp4
-rw-r--r--protocols/IcqOscarJ/src/fam_03buddy.cpp12
-rw-r--r--protocols/IcqOscarJ/src/fam_04message.cpp142
-rw-r--r--protocols/IcqOscarJ/src/fam_09bos.cpp4
-rw-r--r--protocols/IcqOscarJ/src/fam_0alookup.cpp4
-rw-r--r--protocols/IcqOscarJ/src/fam_0bstatus.cpp2
-rw-r--r--protocols/IcqOscarJ/src/fam_13servclist.cpp55
-rw-r--r--protocols/IcqOscarJ/src/fam_15icqserver.cpp30
-rw-r--r--protocols/IcqOscarJ/src/fam_17signon.cpp27
-rw-r--r--protocols/IcqOscarJ/src/i18n.cpp174
-rw-r--r--protocols/IcqOscarJ/src/i18n.h8
-rw-r--r--protocols/IcqOscarJ/src/icq_advsearch.cpp10
-rw-r--r--protocols/IcqOscarJ/src/icq_advsearch.h4
-rw-r--r--protocols/IcqOscarJ/src/icq_avatar.cpp41
-rw-r--r--protocols/IcqOscarJ/src/icq_avatar.h46
-rw-r--r--protocols/IcqOscarJ/src/icq_clients.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_db.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_direct.cpp40
-rw-r--r--protocols/IcqOscarJ/src/icq_direct.h2
-rw-r--r--protocols/IcqOscarJ/src/icq_directmsg.cpp30
-rw-r--r--protocols/IcqOscarJ/src/icq_filerequests.cpp10
-rw-r--r--protocols/IcqOscarJ/src/icq_filetransfer.cpp69
-rw-r--r--protocols/IcqOscarJ/src/icq_http.cpp19
-rw-r--r--protocols/IcqOscarJ/src/icq_infoupdate.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_opts.cpp6
-rw-r--r--protocols/IcqOscarJ/src/icq_packet.cpp494
-rw-r--r--protocols/IcqOscarJ/src/icq_packet.h64
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.cpp291
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.h204
-rw-r--r--protocols/IcqOscarJ/src/icq_rates.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_rates.h2
-rw-r--r--protocols/IcqOscarJ/src/icq_server.cpp5
-rw-r--r--protocols/IcqOscarJ/src/icq_server.h4
-rw-r--r--protocols/IcqOscarJ/src/icq_servlist.cpp94
-rw-r--r--protocols/IcqOscarJ/src/icq_servlist.h12
-rw-r--r--protocols/IcqOscarJ/src/icq_uploadui.cpp6
-rw-r--r--protocols/IcqOscarJ/src/icq_xstatus.cpp8
-rw-r--r--protocols/IcqOscarJ/src/icq_xtraz.cpp50
-rw-r--r--protocols/IcqOscarJ/src/icqosc_svcs.cpp25
-rw-r--r--protocols/IcqOscarJ/src/oscar_filetransfer.cpp61
-rw-r--r--protocols/IcqOscarJ/src/oscar_filetransfer.h2
-rw-r--r--protocols/IcqOscarJ/src/stdpackets.cpp372
-rw-r--r--protocols/IcqOscarJ/src/tlv.cpp10
-rw-r--r--protocols/IcqOscarJ/src/tlv.h6
-rw-r--r--protocols/IcqOscarJ/src/utilities.cpp211
-rw-r--r--protocols/IcqOscarJ/src/utilities.h10
-rw-r--r--protocols/IcqOscarJ/src/version.h2
63 files changed, 1333 insertions, 1580 deletions
diff --git a/protocols/IcqOscarJ/src/UI/userinfotab.cpp b/protocols/IcqOscarJ/src/UI/userinfotab.cpp
index 8485f7489a..ee0c1da434 100644
--- a/protocols/IcqOscarJ/src/UI/userinfotab.cpp
+++ b/protocols/IcqOscarJ/src/UI/userinfotab.cpp
@@ -112,7 +112,7 @@ static void SetValue(CIcqProto* ppro, HWND hwndDlg, int idCtrl, MCONTACT hContac
if (bXStatus) {
pXName = ppro->getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, NULL);
- if (!strlennull(pXName)) { // give default name
+ if (!mir_strlen(pXName)) { // give default name
pXName = ICQTranslateUtf(nameXStatus[bXStatus - 1]);
}
mir_snprintf(str, sizeof(str), "%s (%s)", pszStatus, pXName);
diff --git a/protocols/IcqOscarJ/src/capabilities.cpp b/protocols/IcqOscarJ/src/capabilities.cpp
index e8b75b960f..814b531582 100644
--- a/protocols/IcqOscarJ/src/capabilities.cpp
+++ b/protocols/IcqOscarJ/src/capabilities.cpp
@@ -87,7 +87,7 @@ void NetLog_CapabilityChange(CIcqProto *ppro, const char *szChange, DWORD fdwCap
for (int nIndex = 0; nIndex < SIZEOF(CapabilityNames); nIndex++) {
// Check if the current capability is present
if ((fdwCapabilities & CapabilityNames[nIndex].capID) == CapabilityNames[nIndex].capID) {
- if (strlennull(szBuffer))
+ if (mir_strlen(szBuffer))
strcat(szBuffer, ", ");
strcat(szBuffer, CapabilityNames[nIndex].capName);
}
@@ -152,7 +152,7 @@ BOOL CIcqProto::CheckContactCapabilities(MCONTACT hContact, DWORD fdwCapabilitie
// Scan capability against the capability buffer
-capstr* MatchCapability(BYTE *buf, int bufsize, const capstr *cap, int capsize)
+capstr* MatchCapability(BYTE *buf, size_t bufsize, const capstr *cap, size_t capsize)
{
while (bufsize >= BINARY_CAP_SIZE) { // search the buffer for a capability
if (!memcmp(buf, cap, capsize))
@@ -166,7 +166,7 @@ capstr* MatchCapability(BYTE *buf, int bufsize, const capstr *cap, int capsize)
// Scan short capability against the capability buffer
-capstr* MatchShortCapability(BYTE *buf, int bufsize, const shortcapstr *cap)
+capstr* MatchShortCapability(BYTE *buf, size_t bufsize, const shortcapstr *cap)
{
capstr fullCap;
memcpy(fullCap, capShortCaps, BINARY_CAP_SIZE);
diff --git a/protocols/IcqOscarJ/src/capabilities.h b/protocols/IcqOscarJ/src/capabilities.h
index cff5ab9f04..c0b7f082f4 100644
--- a/protocols/IcqOscarJ/src/capabilities.h
+++ b/protocols/IcqOscarJ/src/capabilities.h
@@ -36,8 +36,8 @@ typedef BYTE shortcapstr[BINARY_SHORT_CAP_SIZE];
extern const capstr capShortCaps;
-capstr* MatchCapability(BYTE *buf, int bufsize, const capstr *cap, int capsize = BINARY_CAP_SIZE);
-capstr* MatchShortCapability(BYTE *buf, int bufsize, const shortcapstr *cap);
+capstr* MatchCapability(BYTE *buf, size_t bufsize, const capstr *cap, size_t capsize = BINARY_CAP_SIZE);
+capstr* MatchShortCapability(BYTE *buf, size_t bufsize, const shortcapstr *cap);
#endif /* __CAPABILITIES_H */
diff --git a/protocols/IcqOscarJ/src/chan_01login.cpp b/protocols/IcqOscarJ/src/chan_01login.cpp
index 48fc85dfcc..061212d70a 100644
--- a/protocols/IcqOscarJ/src/chan_01login.cpp
+++ b/protocols/IcqOscarJ/src/chan_01login.cpp
@@ -25,7 +25,7 @@
#include "icqoscar.h"
-void CIcqProto::handleLoginChannel(BYTE *buf, WORD datalen, serverthread_info *info)
+void CIcqProto::handleLoginChannel(BYTE *buf, size_t datalen, serverthread_info *info)
{
icq_packet packet;
@@ -43,11 +43,11 @@ void CIcqProto::handleLoginChannel(BYTE *buf, WORD datalen, serverthread_info *i
sendServPacket(&packet); // greet login server
char szUin[UINMAXLEN];
- WORD wUinLen = strlennull(strUID(m_dwLocalUIN, szUin));
+ size_t wUinLen = mir_strlen(strUID(m_dwLocalUIN, szUin));
debugLogA("Sending %s to %s", "ICQ_SIGNON_AUTH_REQUEST", "login server");
- serverPacketInit(&packet, (WORD)(14 + wUinLen));
+ serverPacketInit(&packet, 14 + wUinLen);
packFNACHeader(&packet, ICQ_AUTHORIZATION_FAMILY, ICQ_SIGNON_AUTH_REQUEST, 0, 0);
packTLV(&packet, 0x0001, wUinLen, (LPBYTE)szUin);
sendServPacket(&packet); // request login digest
@@ -67,7 +67,7 @@ void CIcqProto::handleLoginChannel(BYTE *buf, WORD datalen, serverthread_info *i
if (info->cookieDataLen) {
wLocalSequence = generate_flap_sequence();
- serverCookieInit(&packet, info->cookieData, (WORD)info->cookieDataLen);
+ serverCookieInit(&packet, info->cookieData, info->cookieDataLen);
sendServPacket(&packet);
debugLogA("Sent CLI_IDENT to %s", "communication server");
diff --git a/protocols/IcqOscarJ/src/chan_02data.cpp b/protocols/IcqOscarJ/src/chan_02data.cpp
index 37b8617465..3a14ef1efd 100644
--- a/protocols/IcqOscarJ/src/chan_02data.cpp
+++ b/protocols/IcqOscarJ/src/chan_02data.cpp
@@ -29,7 +29,7 @@
#include "icqoscar.h"
-void CIcqProto::handleDataChannel(BYTE *pBuffer, WORD wBufferLength, serverthread_info *info)
+void CIcqProto::handleDataChannel(BYTE *pBuffer, size_t wBufferLength, serverthread_info *info)
{
snac_header snacHeader = {0};
@@ -91,7 +91,7 @@ void CIcqProto::handleDataChannel(BYTE *pBuffer, WORD wBufferLength, serverthrea
}
-int unpackSnacHeader(snac_header *pSnacHeader, BYTE **pBuffer, WORD *pwBufferLength)
+int unpackSnacHeader(snac_header *pSnacHeader, BYTE **pBuffer, size_t *pwBufferLength)
{
WORD wRef1, wRef2;
diff --git a/protocols/IcqOscarJ/src/chan_03error.cpp b/protocols/IcqOscarJ/src/chan_03error.cpp
index a44ae3af3b..2e73d6eb07 100644
--- a/protocols/IcqOscarJ/src/chan_03error.cpp
+++ b/protocols/IcqOscarJ/src/chan_03error.cpp
@@ -24,7 +24,7 @@
#include "icqoscar.h"
-void CIcqProto::handleErrorChannel(unsigned char* buf, WORD datalen)
+void CIcqProto::handleErrorChannel(unsigned char* buf, size_t datalen)
{
debugLogA("Ignoring server packet on ERROR channel");
}
diff --git a/protocols/IcqOscarJ/src/chan_04close.cpp b/protocols/IcqOscarJ/src/chan_04close.cpp
index d7f6548f82..12eef821ba 100644
--- a/protocols/IcqOscarJ/src/chan_04close.cpp
+++ b/protocols/IcqOscarJ/src/chan_04close.cpp
@@ -24,7 +24,7 @@
#include "icqoscar.h"
-void CIcqProto::handleCloseChannel(BYTE *buf, WORD datalen, serverthread_info *info)
+void CIcqProto::handleCloseChannel(BYTE *buf, size_t datalen, serverthread_info *info)
{
oscar_tlv_chain *chain = NULL;
@@ -65,7 +65,7 @@ void CIcqProto::handleCloseChannel(BYTE *buf, WORD datalen, serverthread_info *i
NetLib_CloseConnection(&hServerConn, TRUE);
}
-void CIcqProto::handleLoginReply(BYTE *buf, WORD datalen, serverthread_info *info)
+void CIcqProto::handleLoginReply(BYTE *buf, size_t datalen, serverthread_info *info)
{
oscar_tlv_chain *chain = NULL;
diff --git a/protocols/IcqOscarJ/src/chan_05ping.cpp b/protocols/IcqOscarJ/src/chan_05ping.cpp
index 8e735337e8..c3bc72c62d 100644
--- a/protocols/IcqOscarJ/src/chan_05ping.cpp
+++ b/protocols/IcqOscarJ/src/chan_05ping.cpp
@@ -24,7 +24,7 @@
#include "icqoscar.h"
-void CIcqProto::handlePingChannel(BYTE *buf, WORD datalen)
+void CIcqProto::handlePingChannel(BYTE *buf, size_t datalen)
{
debugLogA("Warning: Ignoring server packet on PING channel");
}
diff --git a/protocols/IcqOscarJ/src/changeinfo/db.cpp b/protocols/IcqOscarJ/src/changeinfo/db.cpp
index 31f88db502..d4d8d6881c 100644
--- a/protocols/IcqOscarJ/src/changeinfo/db.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/db.cpp
@@ -179,8 +179,7 @@ int ChangeInfoData::SaveSettingsToDb(HWND hwndDlg)
switch (si.dbType) {
case DBVT_ASCIIZ:
if (si.displayType & LIF_PASSWORD) {
- int nSettingLen = strlennull((char*)sid.value);
-
+ size_t nSettingLen = mir_strlen((char*)sid.value);
if (nSettingLen > 8 || nSettingLen < 1) {
MessageBox(hwndDlg, TranslateT("The ICQ server does not support passwords longer than 8 characters. Please use a shorter password."), TranslateT("Change ICQ Details"), MB_OK);
ret = 0;
diff --git a/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp b/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp
index 0edfa48fcb..dff436cf78 100644
--- a/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/dlgproc.cpp
@@ -36,7 +36,7 @@ static int DrawTextUtf(HDC hDC, char *text, LPRECT lpRect, UINT uFormat, LPSIZE
WCHAR *tmp = make_unicode_string(text);
res = DrawTextW(hDC, tmp, -1, lpRect, uFormat);
if (lpSize)
- GetTextExtentPoint32W(hDC, tmp, strlennull(tmp), lpSize);
+ GetTextExtentPoint32W(hDC, tmp, (int)mir_wstrlen(tmp), lpSize);
SAFE_FREE((void**)&tmp);
return res;
diff --git a/protocols/IcqOscarJ/src/changeinfo/editstring.cpp b/protocols/IcqOscarJ/src/changeinfo/editstring.cpp
index 19fdd4c2b7..528f73eaea 100644
--- a/protocols/IcqOscarJ/src/changeinfo/editstring.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/editstring.cpp
@@ -55,7 +55,7 @@ static void EscapesToMultiline(WCHAR *str,PDWORD selStart,PDWORD selEnd)
else if (str[1] == 't')
{
*str = '\t';
- memmove(str+1, str+2, sizeof(WCHAR)*(strlennull(str)-1));
+ memmove(str+1, str+2, sizeof(WCHAR)*(mir_wstrlen(str)-1));
if (*selStart>i) --*selStart;
if (*selEnd>i) --*selEnd;
@@ -76,14 +76,14 @@ static void EscapesToBinary(char *str)
char *codeend;
*str=(char)strtol(str+1,&codeend,8);
if (*str==0) {*str='\\'; continue;}
- memmove(str+1,codeend,strlennull(codeend)+1);
+ memmove(str+1,codeend,mir_strlen(codeend)+1);
continue;
}
for(int i=0;i<SIZEOF(escapes);i+=2)
if(str[1]==escapes[i])
{
*str=escapes[i+1];
- memmove(str+1,str+2,strlennull(str)-1);
+ memmove(str+1,str+2,mir_strlen(str)-1);
break;
}
}
@@ -93,8 +93,8 @@ static void EscapesToBinary(char *str)
char *BinaryToEscapes(char *str)
{
- int extra=10,len=strlennull(str)+11,i;
- char *out,*pout;
+ int extra = 10, len = (int)mir_strlen(str) + 11, i;
+ char *out, *pout;
out=pout=(char*)SAFE_MALLOC(len);
for (;*str;str++)
@@ -310,9 +310,9 @@ void ChangeInfoData::EndStringEdit(int save)
EscapesToBinary(text);
}
if ((si.displayType & LIF_PASSWORD && strcmpnull(text, " ")) ||
- (!(si.displayType & LIF_PASSWORD) && strcmpnull(text, (char*)sid.value) && (strlennull(text) + strlennull((char*)sid.value)))) {
+ (!(si.displayType & LIF_PASSWORD) && strcmpnull(text, (char*)sid.value) && (mir_strlen(text) + mir_strlen((char*)sid.value)))) {
SAFE_FREE((void**)&sid.value);
- if (strlennull(text))
+ if (mir_strlen(text))
sid.value = (LPARAM)text;
else {
sid.value = 0;
diff --git a/protocols/IcqOscarJ/src/changeinfo/upload.cpp b/protocols/IcqOscarJ/src/changeinfo/upload.cpp
index 6ff49b54f3..c8c515c950 100644
--- a/protocols/IcqOscarJ/src/changeinfo/upload.cpp
+++ b/protocols/IcqOscarJ/src/changeinfo/upload.cpp
@@ -67,7 +67,7 @@ int ChangeInfoData::UploadSettings(void)
//password
char* tmp = ppro->GetUserPassword(TRUE);
if (tmp) {
- if (strlennull(Password) > 0 && strcmpnull(Password, tmp)) {
+ if (mir_strlen(Password) > 0 && strcmpnull(Password, tmp)) {
// update password in user info dialog (still open)
strcpy(Password, tmp);
// update password in protocol
diff --git a/protocols/IcqOscarJ/src/channels.h b/protocols/IcqOscarJ/src/channels.h
index 5d7c73489b..864be6d4aa 100644
--- a/protocols/IcqOscarJ/src/channels.h
+++ b/protocols/IcqOscarJ/src/channels.h
@@ -40,6 +40,6 @@ struct snac_header
WORD wVersion;
};
-int unpackSnacHeader(snac_header *pSnacHeader, BYTE **pBuffer, WORD *pwBufferLength);
+int unpackSnacHeader(snac_header *pSnacHeader, BYTE **pBuffer, size_t *pwBufferLength);
#endif /* __CHANNELS_H */
diff --git a/protocols/IcqOscarJ/src/cookies.h b/protocols/IcqOscarJ/src/cookies.h
index d8233f71c2..82178f9b01 100644
--- a/protocols/IcqOscarJ/src/cookies.h
+++ b/protocols/IcqOscarJ/src/cookies.h
@@ -1,23 +1,23 @@
// ---------------------------------------------------------------------------80
// ICQ plugin for Miranda Instant Messenger
// ________________________________________
-//
+//
// Copyright © 2000-2001 Richard Hughes, Roland Rabien, Tristan Van de Vreede
// Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
// Copyright © 2012-2014 Miranda NG Team
-//
+//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -56,7 +56,7 @@ struct icq_cookie_info
struct cookie_family_request
{
WORD wFamily;
- void (CIcqProto::*familyHandler)(HANDLE hConn, char* cookie, WORD cookieLen);
+ void (CIcqProto::*familyHandler)(HANDLE hConn, char* cookie, size_t cookieLen);
};
@@ -110,9 +110,9 @@ struct cookie_avatar
{
DWORD dwUin;
MCONTACT hContact;
- unsigned int hashlen;
+ size_t hashlen;
BYTE *hash;
- unsigned int cbData;
+ size_t cbData;
TCHAR *szFile;
};
diff --git a/protocols/IcqOscarJ/src/directpackets.cpp b/protocols/IcqOscarJ/src/directpackets.cpp
index 9e24b25c89..0e91b4fd2f 100644
--- a/protocols/IcqOscarJ/src/directpackets.cpp
+++ b/protocols/IcqOscarJ/src/directpackets.cpp
@@ -29,7 +29,7 @@ void EncryptDirectPacket(directconnect* dc, icq_packet* p);
void packEmptyMsg(icq_packet *packet);
-static void packDirectMsgHeader(icq_packet* packet, WORD wDataLen, WORD wCommand, DWORD dwCookie, BYTE bMsgType, BYTE bMsgFlags, WORD wX1, WORD wX2)
+static void packDirectMsgHeader(icq_packet* packet, size_t wDataLen, WORD wCommand, DWORD dwCookie, BYTE bMsgType, BYTE bMsgFlags, WORD wX1, WORD wX2)
{
directPacketInit(packet, 29 + wDataLen);
packByte(packet, 2); /* channel */
@@ -50,16 +50,13 @@ static void packDirectMsgHeader(icq_packet* packet, WORD wDataLen, WORD wCommand
void CIcqProto::icq_sendDirectMsgAck(directconnect* dc, WORD wCookie, BYTE bMsgType, BYTE bMsgFlags, char* szCap)
{
icq_packet packet;
-
- packDirectMsgHeader(&packet, (WORD)(bMsgType==MTYPE_PLAIN ? (szCap ? 53 : 11) : 3), DIRECT_ACK, wCookie, bMsgType, bMsgFlags, 0, 0);
+ packDirectMsgHeader(&packet, bMsgType == MTYPE_PLAIN ? (szCap ? 53 : 11) : 3, DIRECT_ACK, wCookie, bMsgType, bMsgFlags, 0, 0);
packEmptyMsg(&packet); /* empty message */
- if (bMsgType == MTYPE_PLAIN)
- {
+ if (bMsgType == MTYPE_PLAIN) {
packMsgColorInfo(&packet);
- if (szCap)
- {
+ if (szCap) {
packLEDWord(&packet, 0x26); /* CLSID length */
packBuffer(&packet, (LPBYTE)szCap, 0x26); /* GUID */
}
@@ -73,16 +70,13 @@ void CIcqProto::icq_sendDirectMsgAck(directconnect* dc, WORD wCookie, BYTE bMsgT
DWORD CIcqProto::icq_sendGetAwayMsgDirect(MCONTACT hContact, int type)
{
- icq_packet packet;
- DWORD dwCookie;
- cookie_message_data *pCookieData;
-
if (getWord(hContact, "Version", 0) >= 9)
return 0; // v9 DC protocol does not support this message
- pCookieData = CreateMessageCookie(MTYPE_AUTOAWAY, (BYTE)type);
- dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
+ cookie_message_data *pCookieData = CreateMessageCookie(MTYPE_AUTOAWAY, (BYTE)type);
+ DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
+ icq_packet packet;
packDirectMsgHeader(&packet, 3, DIRECT_MESSAGE, dwCookie, (BYTE)type, 3, 1, 0);
packEmptyMsg(&packet); // message
@@ -92,25 +86,23 @@ DWORD CIcqProto::icq_sendGetAwayMsgDirect(MCONTACT hContact, int type)
void CIcqProto::icq_sendAwayMsgReplyDirect(directconnect* dc, WORD wCookie, BYTE msgType, const char** szMsg)
{
- icq_packet packet;
-
- if (validateStatusMessageRequest(dc->hContact, msgType))
- {
+ if (validateStatusMessageRequest(dc->hContact, msgType)) {
NotifyEventHooks(m_modeMsgsEvent, (WPARAM)msgType, (LPARAM)dc->dwRemoteUin);
icq_lock l(m_modeMsgsMutex);
- if (szMsg && *szMsg)
- {
+ if (szMsg && *szMsg) {
// prepare Ansi message - only Ansi supported
- WORD wMsgLen = strlennull(*szMsg) + 1;
+ size_t wMsgLen = mir_strlen(*szMsg) + 1;
char *szAnsiMsg = (char*)_alloca(wMsgLen);
utf8_decode_static(*szMsg, szAnsiMsg, wMsgLen);
- wMsgLen = strlennull(szAnsiMsg);
- packDirectMsgHeader(&packet, (WORD)(3 + wMsgLen), DIRECT_ACK, wCookie, msgType, 3, 0, 0);
- packLEWord(&packet, (WORD)(wMsgLen + 1));
- packBuffer(&packet, (LPBYTE)szAnsiMsg, (WORD)(wMsgLen + 1));
+ wMsgLen = mir_strlen(szAnsiMsg);
+
+ icq_packet packet;
+ packDirectMsgHeader(&packet, 3 + wMsgLen, DIRECT_ACK, wCookie, msgType, 3, 0, 0);
+ packLEWord(&packet, WORD(wMsgLen + 1));
+ packBuffer(&packet, (LPBYTE)szAnsiMsg, wMsgLen + 1);
EncryptDirectPacket(dc, &packet);
sendDirectPacket(dc, &packet);
@@ -123,7 +115,6 @@ void CIcqProto::icq_sendFileAcceptDirect(MCONTACT hContact, filetransfer* ft)
{
// v7 packet
icq_packet packet;
-
packDirectMsgHeader(&packet, 18, DIRECT_ACK, ft->dwCookie, MTYPE_FILEREQ, 0, 0, 0);
packLEWord(&packet, 1); // description
packByte(&packet, 0);
@@ -144,25 +135,24 @@ void CIcqProto::icq_sendFileDenyDirect(MCONTACT hContact, filetransfer *ft, cons
{
// v7 packet
icq_packet packet;
- char *szReasonAnsi = NULL;
- int cbReasonAnsi = 0;
-
+ char *szReasonAnsi = NULL;
if (!utf8_decode(szReason, &szReasonAnsi))
szReasonAnsi = _strdup(szReason); // Legacy fix
- cbReasonAnsi = strlennull(szReasonAnsi);
+ size_t cbReasonAnsi = mir_strlen(szReasonAnsi);
- packDirectMsgHeader(&packet, (WORD)(18 + cbReasonAnsi), DIRECT_ACK, ft->dwCookie, MTYPE_FILEREQ, 0, 1, 0);
- packLEWord(&packet, (WORD)(1 + cbReasonAnsi)); // description
- if (szReasonAnsi) packBuffer(&packet, (LPBYTE)szReasonAnsi, (WORD)cbReasonAnsi);
+ packDirectMsgHeader(&packet, 18 + cbReasonAnsi, DIRECT_ACK, ft->dwCookie, MTYPE_FILEREQ, 0, 1, 0);
+ packLEWord(&packet, WORD(1 + cbReasonAnsi)); // description
+ if (szReasonAnsi)
+ packBuffer(&packet, (LPBYTE)szReasonAnsi, cbReasonAnsi);
packByte(&packet, 0);
packWord(&packet, 0);
packLEWord(&packet, 0);
packLEWord(&packet, 1); // filename
packByte(&packet, 0); // TODO: really send filename
packLEDWord(&packet, 0); // file size
- packLEDWord(&packet, 0);
+ packLEDWord(&packet, 0);
- SAFE_FREE(&szReasonAnsi);
+ SAFE_FREE(&szReasonAnsi);
SendDirectMessage(hContact, &packet);
@@ -172,20 +162,20 @@ void CIcqProto::icq_sendFileDenyDirect(MCONTACT hContact, filetransfer *ft, cons
int CIcqProto::icq_sendFileSendDirectv7(filetransfer *ft, const char *pszFiles)
{
- icq_packet packet;
char *szFilesAnsi = NULL;
- WORD wDescrLen = strlennull(ft->szDescription), wFilesLen = 0;
+ size_t wDescrLen = mir_strlen(ft->szDescription);
if (!utf8_decode(pszFiles, &szFilesAnsi))
szFilesAnsi = _strdup(pszFiles); // Legacy fix
- wFilesLen = strlennull(szFilesAnsi);
+ size_t wFilesLen = mir_strlen(szFilesAnsi);
- packDirectMsgHeader(&packet, (WORD)(18 + wDescrLen + wFilesLen), DIRECT_MESSAGE, (WORD)ft->dwCookie, MTYPE_FILEREQ, 0, 0, 0);
- packLEWord(&packet, (WORD)(wDescrLen + 1));
- packBuffer(&packet, (LPBYTE)ft->szDescription, (WORD)(wDescrLen + 1));
+ icq_packet packet;
+ packDirectMsgHeader(&packet, 18 + wDescrLen + wFilesLen, DIRECT_MESSAGE, (WORD)ft->dwCookie, MTYPE_FILEREQ, 0, 0, 0);
+ packLEWord(&packet, WORD(wDescrLen + 1));
+ packBuffer(&packet, (LPBYTE)ft->szDescription, wDescrLen + 1);
packLEDWord(&packet, 0); // listen port
- packLEWord(&packet, (WORD)(wFilesLen + 1));
- packBuffer(&packet, (LPBYTE)szFilesAnsi, (WORD)(wFilesLen + 1));
+ packLEWord(&packet, WORD(wFilesLen + 1));
+ packBuffer(&packet, (LPBYTE)szFilesAnsi, wFilesLen + 1);
packLEDWord(&packet, ft->dwTotalSize);
packLEDWord(&packet, 0); // listen port (again)
@@ -199,25 +189,25 @@ int CIcqProto::icq_sendFileSendDirectv7(filetransfer *ft, const char *pszFiles)
int CIcqProto::icq_sendFileSendDirectv8(filetransfer *ft, const char *pszFiles)
{
- icq_packet packet;
char *szFilesAnsi = NULL;
- WORD wDescrLen = strlennull(ft->szDescription), wFilesLen = 0;
+ size_t wDescrLen = mir_strlen(ft->szDescription);
if (!utf8_decode(pszFiles, &szFilesAnsi))
szFilesAnsi = _strdup(pszFiles); // Legacy fix
- wFilesLen = strlennull(szFilesAnsi);
+ size_t wFilesLen = mir_strlen(szFilesAnsi)+1;
- packDirectMsgHeader(&packet, (WORD)(0x2E + 22 + wDescrLen + wFilesLen + 1), DIRECT_MESSAGE, (WORD)ft->dwCookie, MTYPE_PLUGIN, 0, 0, 0);
+ icq_packet packet;
+ packDirectMsgHeader(&packet, 0x2E + 22 + wDescrLen + wFilesLen, DIRECT_MESSAGE, (WORD)ft->dwCookie, MTYPE_PLUGIN, 0, 0, 0);
packEmptyMsg(&packet); // message
packPluginTypeId(&packet, MTYPE_FILEREQ);
- packLEDWord(&packet, (WORD)(18 + wDescrLen + wFilesLen + 1)); // Remaining length
- packLEDWord(&packet, wDescrLen); // Description
+ packLEDWord(&packet, WORD(18 + wDescrLen + wFilesLen)); // Remaining length
+ packLEDWord(&packet, DWORD(wDescrLen)); // Description
packBuffer(&packet, (LPBYTE)ft->szDescription, wDescrLen);
packWord(&packet, 0x8c82); // Unknown (port?), seen 0x80F6
packWord(&packet, 0x0222); // Unknown, seen 0x2e01
- packLEWord(&packet, (WORD)(wFilesLen + 1));
- packBuffer(&packet, (LPBYTE)szFilesAnsi, (WORD)(wFilesLen + 1));
+ packLEWord(&packet, WORD(wFilesLen));
+ packBuffer(&packet, (LPBYTE)szFilesAnsi, wFilesLen);
packLEDWord(&packet, ft->dwTotalSize);
packLEDWord(&packet, 0x0008c82); // Unknown, (seen 0xf680 ~33000)
@@ -229,16 +219,16 @@ int CIcqProto::icq_sendFileSendDirectv8(filetransfer *ft, const char *pszFiles)
}
-DWORD CIcqProto::icq_SendDirectMessage(MCONTACT hContact, const char *szMessage, int nBodyLength, WORD wPriority, cookie_message_data *pCookieData, char *szCap)
+DWORD CIcqProto::icq_SendDirectMessage(MCONTACT hContact, const char *szMessage, size_t nBodyLength, WORD wPriority, cookie_message_data *pCookieData, char *szCap)
{
- icq_packet packet;
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
// Pack the standard header
- packDirectMsgHeader(&packet, (WORD)(nBodyLength + (szCap ? 53:11)), DIRECT_MESSAGE, dwCookie, (BYTE)pCookieData->bMessageType, 0, 0, 0);
+ icq_packet packet;
+ packDirectMsgHeader(&packet, nBodyLength + (szCap ? 53 : 11), DIRECT_MESSAGE, dwCookie, (BYTE)pCookieData->bMessageType, 0, 0, 0);
- packLEWord(&packet, (WORD)(nBodyLength+1)); // Length of message
- packBuffer(&packet, (LPBYTE)szMessage, (WORD)(nBodyLength+1)); // Message
+ packLEWord(&packet, WORD(nBodyLength+1)); // Length of message
+ packBuffer(&packet, (LPBYTE)szMessage, nBodyLength+1); // Message
packMsgColorInfo(&packet);
if (szCap)
{
@@ -253,34 +243,32 @@ DWORD CIcqProto::icq_SendDirectMessage(MCONTACT hContact, const char *szMessage,
return 0; // Failure
}
-void CIcqProto::icq_sendXtrazRequestDirect(MCONTACT hContact, DWORD dwCookie, char* szBody, int nBodyLen, WORD wType)
+void CIcqProto::icq_sendXtrazRequestDirect(MCONTACT hContact, DWORD dwCookie, char* szBody, size_t nBodyLen, WORD wType)
{
icq_packet packet;
-
- packDirectMsgHeader(&packet, (WORD)(11 + getPluginTypeIdLen(wType) + nBodyLen), DIRECT_MESSAGE, dwCookie, MTYPE_PLUGIN, 0, 0, 1);
+ packDirectMsgHeader(&packet, 11 + getPluginTypeIdLen(wType) + nBodyLen, DIRECT_MESSAGE, dwCookie, MTYPE_PLUGIN, 0, 0, 1);
packEmptyMsg(&packet); // message (unused)
packPluginTypeId(&packet, wType);
- packLEDWord(&packet, nBodyLen + 4);
- packLEDWord(&packet, nBodyLen);
- packBuffer(&packet, (LPBYTE)szBody, (WORD)nBodyLen);
+ packLEDWord(&packet, DWORD(nBodyLen + 4));
+ packLEDWord(&packet, DWORD(nBodyLen));
+ packBuffer(&packet, (LPBYTE)szBody, nBodyLen);
SendDirectMessage(hContact, &packet);
}
-void CIcqProto::icq_sendXtrazResponseDirect(MCONTACT hContact, WORD wCookie, char* szBody, int nBodyLen, WORD wType)
+void CIcqProto::icq_sendXtrazResponseDirect(MCONTACT hContact, WORD wCookie, char* szBody, size_t nBodyLen, WORD wType)
{
icq_packet packet;
+ packDirectMsgHeader(&packet, getPluginTypeIdLen(wType) + 11 + nBodyLen, DIRECT_ACK, wCookie, MTYPE_PLUGIN, 0, 0, 0);
- packDirectMsgHeader(&packet, (WORD)(getPluginTypeIdLen(wType) + 11 + nBodyLen), DIRECT_ACK, wCookie, MTYPE_PLUGIN, 0, 0, 0);
- //
packEmptyMsg(&packet); // Message (unused)
packPluginTypeId(&packet, wType);
- packLEDWord(&packet, nBodyLen + 4);
- packLEDWord(&packet, nBodyLen);
- packBuffer(&packet, (LPBYTE)szBody, (WORD)nBodyLen);
+ packLEDWord(&packet, DWORD(nBodyLen + 4));
+ packLEDWord(&packet, DWORD(nBodyLen));
+ packBuffer(&packet, (LPBYTE)szBody, nBodyLen);
SendDirectMessage(hContact, &packet);
}
diff --git a/protocols/IcqOscarJ/src/fam_01service.cpp b/protocols/IcqOscarJ/src/fam_01service.cpp
index 57247e33d3..e756f8c2f0 100644
--- a/protocols/IcqOscarJ/src/fam_01service.cpp
+++ b/protocols/IcqOscarJ/src/fam_01service.cpp
@@ -31,7 +31,7 @@
extern capstr capXStatus[];
-void CIcqProto::handleServiceFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader, serverthread_info *info)
+void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader, serverthread_info *info)
{
icq_packet packet;
@@ -464,7 +464,7 @@ void CIcqProto::handleServiceFam(BYTE *pBuffer, WORD wBufferLength, snac_header
}
-char* CIcqProto::buildUinList(int subtype, WORD wMaxLen, MCONTACT *hContactResume)
+char* CIcqProto::buildUinList(int subtype, size_t wMaxLen, MCONTACT *hContactResume)
{
MCONTACT hContact;
WORD wCurrentLen = 0;
@@ -484,7 +484,7 @@ char* CIcqProto::buildUinList(int subtype, WORD wMaxLen, MCONTACT *hContactResum
while (hContact != NULL) {
if (!getContactUid(hContact, &dwUIN, &szUID)) {
- szLen[0] = strlennull(strUID(dwUIN, szUID));
+ szLen[0] = (char)mir_strlen(strUID(dwUIN, szUID));
switch (subtype) {
case BUL_VISIBLE:
@@ -546,12 +546,12 @@ void CIcqProto::sendEntireListServ(WORD wFamily, WORD wSubtype, int listType)
// send only about 100contacts per packet
char *szList = buildUinList(listType, 0x3E8, &hResumeContact);
- int nListLen = strlennull(szList);
+ size_t nListLen = mir_strlen(szList);
if (nListLen) {
icq_packet packet;
- serverPacketInit(&packet, (WORD)(nListLen + 10));
+ serverPacketInit(&packet, nListLen + 10);
packFNACHeader(&packet, wFamily, wSubtype);
- packBuffer(&packet, (LPBYTE)szList, (WORD)nListLen);
+ packBuffer(&packet, (LPBYTE)szList, nListLen);
sendServPacket(&packet);
}
@@ -576,7 +576,7 @@ static void packShortCapability(icq_packet *packet, WORD wCapability)
void CIcqProto::setUserInfo()
{
icq_packet packet;
- WORD wAdditionalData = 0;
+ size_t wAdditionalData = 0;
BYTE bXStatus = getContactXStatus(NULL);
if (m_bAimEnabled)
@@ -606,7 +606,7 @@ void CIcqProto::setUserInfo()
wAdditionalData += 16;
#endif
- wAdditionalData += (WORD)CustomCapList.getCount() * 16;
+ wAdditionalData += CustomCapList.getCount() * 16;
//MIM/PackName
bool bHasPackName = false;
@@ -617,12 +617,12 @@ void CIcqProto::setUserInfo()
wAdditionalData += 16;
}
- serverPacketInit(&packet, (WORD)(62 + wAdditionalData));
+ serverPacketInit(&packet, 62 + wAdditionalData);
packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_SET_USER_INFO);
/* TLV(5): capability data */
packWord(&packet, 0x0005);
- packWord(&packet, (WORD)(48 + wAdditionalData));
+ packWord(&packet, WORD(48 + wAdditionalData));
#ifdef DBG_CAPMTN
packDWord(&packet, 0x563FC809); // CAP_TYPING
@@ -744,11 +744,11 @@ void CIcqProto::handleServUINSettings(int nPort, serverthread_info *info)
//! Tricky code, this ensures that the status note will be saved to the directory
SetStatusNote(szStatusNote, m_bGatewayMode ? 5000 : 2500, TRUE);
- WORD wStatusNoteLen = strlennull(szStatusNote);
- WORD wStatusMoodLen = strlennull(szMoodData);
- WORD wSessionDataLen = (wStatusNoteLen ? wStatusNoteLen + 4 : 0) + 4 + wStatusMoodLen + 4;
+ size_t wStatusNoteLen = mir_strlen(szStatusNote);
+ size_t wStatusMoodLen = mir_strlen(szMoodData);
+ size_t wSessionDataLen = (wStatusNoteLen ? wStatusNoteLen + 4 : 0) + 4 + wStatusMoodLen + 4;
- serverPacketInit(&packet, (WORD)(71 + (wSessionDataLen ? wSessionDataLen + 4 : 0)));
+ serverPacketInit(&packet, 71 + (wSessionDataLen ? wSessionDataLen + 4 : 0));
packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_SET_STATUS);
packDWord(&packet, 0x00060004); // TLV 6: Status mode and security flags
packWord(&packet, GetMyStatusFlags()); // Status flags
@@ -773,18 +773,18 @@ void CIcqProto::handleServUINSettings(int nPort, serverthread_info *info)
if (wSessionDataLen) { // Pack session data
packWord(&packet, 0x1D); // TLV 1D
- packWord(&packet, wSessionDataLen); // TLV length
+ packWord(&packet, WORD(wSessionDataLen)); // TLV length
packWord(&packet, 0x02); // Item Type
if (wStatusNoteLen) {
- packWord(&packet, 0x400 | (WORD)(wStatusNoteLen + 4)); // Flags + Item Length
- packWord(&packet, wStatusNoteLen); // Text Length
+ packWord(&packet, 0x400 | WORD(wStatusNoteLen + 4)); // Flags + Item Length
+ packWord(&packet, WORD(wStatusNoteLen)); // Text Length
packBuffer(&packet, (LPBYTE)szStatusNote, wStatusNoteLen);
packWord(&packet, 0); // Encoding not specified (utf-8 is default)
}
else
packWord(&packet, 0); // Flags + Item Length
packWord(&packet, 0x0E); // Item Type
- packWord(&packet, wStatusMoodLen); // Flags + Item Length
+ packWord(&packet, WORD(wStatusMoodLen)); // Flags + Item Length
if (wStatusMoodLen)
packBuffer(&packet, (LPBYTE)szMoodData, wStatusMoodLen); // Mood
diff --git a/protocols/IcqOscarJ/src/fam_02location.cpp b/protocols/IcqOscarJ/src/fam_02location.cpp
index 73c8923288..1a3953c717 100644
--- a/protocols/IcqOscarJ/src/fam_02location.cpp
+++ b/protocols/IcqOscarJ/src/fam_02location.cpp
@@ -31,7 +31,7 @@
extern const char* cliSpamBot;
-void CIcqProto::handleLocationFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader)
+void CIcqProto::handleLocationFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader)
{
switch (pSnacHeader->wSubtype) {
case ICQ_LOCATION_RIGHTS_REPLY: // Reply to CLI_REQLOCATION
@@ -90,7 +90,7 @@ static char* AimApplyEncoding(char* pszStr, const char* pszEncoding)
return pszStr;
}
-void CIcqProto::handleLocationUserInfoReply(BYTE* buf, WORD wLen, DWORD dwCookie)
+void CIcqProto::handleLocationUserInfoReply(BYTE* buf, size_t wLen, DWORD dwCookie)
{
DWORD dwUIN;
uid_str szUID;
diff --git a/protocols/IcqOscarJ/src/fam_03buddy.cpp b/protocols/IcqOscarJ/src/fam_03buddy.cpp
index 4679ca82c5..8b20642221 100644
--- a/protocols/IcqOscarJ/src/fam_03buddy.cpp
+++ b/protocols/IcqOscarJ/src/fam_03buddy.cpp
@@ -31,7 +31,7 @@
extern const char* cliSpamBot;
-void CIcqProto::handleBuddyFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader, serverthread_info *info)
+void CIcqProto::handleBuddyFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader, serverthread_info *info)
{
switch (pSnacHeader->wSubtype) {
case ICQ_USER_ONLINE:
@@ -69,7 +69,7 @@ void CIcqProto::handleBuddyFam(BYTE *pBuffer, WORD wBufferLength, snac_header *p
}
}
-void CIcqProto::handleReplyBuddy(BYTE *buf, WORD wPackLen)
+void CIcqProto::handleReplyBuddy(BYTE *buf, size_t wPackLen)
{
oscar_tlv_chain *pChain = readIntoTLVChain(&buf, wPackLen, 0);
if (pChain) {
@@ -150,7 +150,7 @@ int unpackSessionDataItem(oscar_tlv_chain *pChain, WORD wItemType, BYTE **ppItem
// TLV(2F) unknown key
// TLV(30) unknown timestamp
-void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info)
+void CIcqProto::handleUserOnline(BYTE *buf, size_t wLen, serverthread_info *info)
{
DWORD dwPort = 0;
DWORD dwRealIP = 0;
@@ -519,7 +519,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info)
}
}
-void CIcqProto::handleUserOffline(BYTE *buf, WORD wLen)
+void CIcqProto::handleUserOffline(BYTE *buf, size_t wLen)
{
DWORD dwUIN;
uid_str szUID;
@@ -671,7 +671,7 @@ void CIcqProto::parseStatusNote(DWORD dwUin, char *szUid, MCONTACT hContact, osc
if (dwStatusNoteTS > getDword(hContact, DBSETTING_STATUS_NOTE_TIME, 0)) {
DBVARIANT dbv = {DBVT_DELETED};
- if (strlennull(szStatusNote) || (!getString(hContact, DBSETTING_STATUS_NOTE, &dbv) && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) && strlennull(dbv.pszVal)))
+ if (mir_strlen(szStatusNote) || (!getString(hContact, DBSETTING_STATUS_NOTE, &dbv) && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) && mir_strlen(dbv.pszVal)))
debugLogA("%s changed status note to \"%s\"", strUID(dwUin, szUid), szStatusNote ? szStatusNote : "");
db_free(&dbv);
@@ -699,7 +699,7 @@ void CIcqProto::parseStatusNote(DWORD dwUin, char *szUid, MCONTACT hContact, osc
}
}
-void CIcqProto::handleNotifyRejected(BYTE *buf, WORD wPackLen)
+void CIcqProto::handleNotifyRejected(BYTE *buf, size_t wPackLen)
{
DWORD dwUIN;
uid_str szUID;
diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp
index 203ac55b95..2e50ee5b62 100644
--- a/protocols/IcqOscarJ/src/fam_04message.cpp
+++ b/protocols/IcqOscarJ/src/fam_04message.cpp
@@ -29,7 +29,7 @@
#include "icqoscar.h"
-void CIcqProto::handleMsgFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader)
+void CIcqProto::handleMsgFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader)
{
switch (pSnacHeader->wSubtype) {
case ICQ_MSG_SRV_ERROR: // SNAC(4, 0x01)
@@ -87,7 +87,7 @@ static void setMsgChannelParams(CIcqProto *ppro, WORD wChan, DWORD dwFlags)
ppro->sendServPacket(&packet);
}
-void CIcqProto::handleReplyICBM(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
+void CIcqProto::handleReplyICBM(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef)
{ // we don't care about the stuff, just change the params
DWORD dwFlags = 0x00000303;
@@ -101,7 +101,7 @@ void CIcqProto::handleReplyICBM(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
setMsgChannelParams(this, 0x0000, dwFlags);
}
-void CIcqProto::handleRecvServMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
+void CIcqProto::handleRecvServMsg(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef)
{
DWORD dwUin;
DWORD dwMsgID1;
@@ -200,10 +200,10 @@ char* CIcqProto::convertMsgToUserSpecificUtf(MCONTACT hContact, const char *szMs
return usMsg;
}
-void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
+void CIcqProto::handleRecvServMsgType1(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
{
WORD wTLVType;
- WORD wTLVLen;
+ size_t wTLVLen;
BYTE* pMsgTLV;
if (wLen < 4) { // just perform basic structure check
@@ -278,7 +278,7 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char *
usMsgPart[wMsgLen / sizeof(WCHAR)] = 0;
szMsgPart = make_utf8_string(usMsgPart);
- if (!IsUSASCII(szMsgPart, strlennull(szMsgPart)))
+ if (!IsUSASCII(szMsgPart, mir_strlen(szMsgPart)))
bMsgPartUnicode = TRUE;
SAFE_FREE(&usMsgPart);
}
@@ -311,18 +311,18 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char *
szMsgPart = szUtfPart;
}
// Append the new message part
- szMsg = (char*)SAFE_REALLOC(szMsg, strlennull(szMsg) + strlennull(szMsgPart) + 1);
+ szMsg = (char*)SAFE_REALLOC(szMsg, mir_strlen(szMsg) + mir_strlen(szMsgPart) + 1);
strcat(szMsg, szMsgPart);
SAFE_FREE(&szMsgPart);
}
wMsgPart++;
}
- if (strlennull(szMsg)) {
+ if (mir_strlen(szMsg)) {
if (_strnicmp(szMsg, "<html>", 6) == 0) // strip HTML formating from AIM message
- szMsg = EliminateHtml(szMsg, strlennull(szMsg));
+ szMsg = EliminateHtml(szMsg, mir_strlen(szMsg));
- if (!pre.flags && !IsUSASCII(szMsg, strlennull(szMsg))) { // message is Ansi and contains national characters, create Unicode part by codepage
+ if (!pre.flags && !IsUSASCII(szMsg, mir_strlen(szMsg))) { // message is Ansi and contains national characters, create Unicode part by codepage
char *usMsg = convertMsgToUserSpecificUtf(hContact, szMsg);
if (usMsg) {
SAFE_FREE(&szMsg);
@@ -338,7 +338,8 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char *
if (!(dwRef & 0x80000000) && FindCookie(dwRef, NULL, (void**)&cookie)) {
cookie->nMessages++;
- WORD wTimeTLVType, wTimeTLVLen;
+ WORD wTimeTLVType;
+ size_t wTimeTLVLen;
BYTE *pTimeTLV;
unpackTypedTLV(buf, wLen, 0x16, &wTimeTLVType, &wTimeTLVLen, &pTimeTLV);
if (pTimeTLV && wTimeTLVType == 0x16 && wTimeTLVLen == 4) { // found Offline timestamp
@@ -375,10 +376,10 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char *
SAFE_FREE((void**)&pMsgTLV);
}
-void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
+void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
{
WORD wTLVType;
- WORD wTLVLen;
+ size_t wTLVLen;
BYTE *pDataBuf = NULL;
if (wLen < 4) {
@@ -571,7 +572,7 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char *
}
-void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType)
+void CIcqProto::parseServRelayData(BYTE *pDataBuf, size_t wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType)
{
WORD wId;
@@ -775,7 +776,7 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact,
else debugLogA("Unknown wId1 (%u) in message (format 2)", wId);
}
-void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType, BYTE bFlags, WORD wStatus, WORD wCookie, WORD wVersion)
+void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, size_t wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType, BYTE bFlags, WORD wStatus, WORD wCookie, WORD wVersion)
{
int nTypeId;
WORD wFunction;
@@ -786,8 +787,7 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo
if (!unpackPluginTypeId(&pDataBuf, &wLen, &nTypeId, &wFunction, FALSE)) return;
if (wLen > 8) {
- DWORD dwLengthToEnd;
- DWORD dwDataLen;
+ size_t dwLengthToEnd, dwDataLen;
// Length of remaining data
unpackLEDWord(&pDataBuf, &dwLengthToEnd);
@@ -810,7 +810,7 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo
memcpy(szMsg, pDataBuf, dwDataLen);
szMsg[dwDataLen] = '\0';
pDataBuf += dwDataLen;
- wLen -= (WORD)dwDataLen;
+ wLen -= dwDataLen;
handleFileAck(pDataBuf, wLen, dwUin, wCookie, wStatus, szMsg);
}
@@ -825,7 +825,7 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo
memcpy(szMsg, pDataBuf, dwDataLen);
szMsg[dwDataLen] = '\0';
pDataBuf += dwDataLen;
- wLen -= (WORD)dwDataLen;
+ wLen -= dwDataLen;
handleFileRequest(pDataBuf, wLen, dwUin, wCookie, dwMsgID1, dwMsgID2, szMsg, 8, FALSE);
}
@@ -840,7 +840,7 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo
memcpy(szMsg, pDataBuf, dwDataLen);
szMsg[dwDataLen] = '\0';
pDataBuf += dwDataLen;
- wLen -= (WORD)dwDataLen;
+ wLen -= dwDataLen;
// handleChatRequest(pDataBuf, wLen, dwUin, wCookie, dwMsgID1, dwMsgID2, szMsg, 8);
}
@@ -884,14 +884,14 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo
pMsgAck.wCookie = wCookie;
pMsgAck.msgType = nTypeId;
pMsgAck.bFlags = bFlags;
- handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, nTypeId, bFlags, wAckType, dwLengthToEnd, (WORD)dwDataLen, (char*)pDataBuf, MTF_PLUGIN, &pMsgAck);
+ handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, nTypeId, bFlags, wAckType, dwLengthToEnd, dwDataLen, (char*)pDataBuf, MTF_PLUGIN, &pMsgAck);
}
else debugLogA("Unsupported plugin message type %d", nTypeId);
}
else debugLogA("Error: Malformed server plugin message");
}
-void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand)
+void CIcqProto::handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand)
{
MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL);
@@ -964,7 +964,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha
valid = 0;
}
else { // aim contact
- if (!strlennull(szUid))
+ if (!mir_strlen(szUid))
valid = 0;
}
iContact++;
@@ -1016,7 +1016,8 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha
unpackWord(&pBuffer, &wNickLen);
nLen -= 2;
if (nLen >= wNickLen) {
- WORD wNickTLV, wNickTLVLen;
+ WORD wNickTLV;
+ size_t wNickTLVLen;
char *pNick = NULL;
unpackTypedTLV(pBuffer, wNickLen, 0x01, &wNickTLV, &wNickTLVLen, (LPBYTE*)&pNick);
@@ -1087,10 +1088,10 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha
}
}
-void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
+void CIcqProto::handleRecvServMsgType4(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
{
WORD wTLVType;
- WORD wTLVLen;
+ size_t wTLVLen;
BYTE* pDataBuf;
DWORD dwUin2;
@@ -1108,8 +1109,7 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char *
BYTE bMsgType;
BYTE bFlags;
BYTE* pmsg = pDataBuf;
- WORD wMsgLen;
-
+ size_t wMsgLen;
unpackLEDWord(&pmsg, &dwUin2);
@@ -1125,7 +1125,8 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char *
DWORD dwRecvTime = (DWORD)time(NULL);
if (!(dwRef & 0x80000000) && FindCookie(dwRef, NULL, (void**)&cookie)) {
- WORD wTimeTLVType, wTimeTLVLen;
+ WORD wTimeTLVType;
+ size_t wTimeTLVLen;
BYTE *pTimeTLV = NULL;
cookie->nMessages++;
@@ -1140,7 +1141,7 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char *
}
if (bMsgType == MTYPE_PLUGIN) {
- WORD wLen = wTLVLen - 8;
+ size_t wLen = wTLVLen - 8;
int typeId;
debugLogA("Parsing Greeting message through server");
@@ -1149,8 +1150,7 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char *
wLen -= wMsgLen;
if (unpackPluginTypeId(&pmsg, &wLen, &typeId, NULL, FALSE) && wLen > 8) {
- DWORD dwLengthToEnd;
- DWORD dwDataLen;
+ size_t dwLengthToEnd, dwDataLen;
// Length of remaining data
unpackLEDWord(&pmsg, &dwLengthToEnd);
@@ -1164,7 +1164,7 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char *
if (typeId) {
uid_str szUID;
- handleMessageTypes(dwUin, szUID, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, typeId, bFlags, 0, dwLengthToEnd, (WORD)dwDataLen, (char*)pmsg, MTF_PLUGIN, NULL);
+ handleMessageTypes(dwUin, szUID, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, typeId, bFlags, 0, dwLengthToEnd, dwDataLen, (char*)pmsg, MTF_PLUGIN, NULL);
}
else debugLogA("Unsupported plugin message type %d", typeId);
}
@@ -1243,11 +1243,9 @@ static int TypeGUIDToTypeId(DWORD dwGuid1, DWORD dwGuid2, DWORD dwGuid3, DWORD d
}
-int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WORD *pFunctionId, BOOL bThruDC)
+int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, size_t *pwLen, int *pTypeId, WORD *pFunctionId, BOOL bThruDC)
{
- WORD wLen = *pwLen;
- WORD wInfoLen;
- DWORD dwPluginNameLen;
+ size_t wLen = *pwLen, wInfoLen, dwPluginNameLen;
DWORD q1, q2, q3, q4;
WORD qt;
@@ -1275,7 +1273,7 @@ int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WOR
char *szPluginName = (char *)_alloca(dwPluginNameLen + 1);
memcpy(szPluginName, *pBuffer, dwPluginNameLen);
szPluginName[dwPluginNameLen] = '\0';
- wLen -= (WORD)dwPluginNameLen;
+ wLen -= dwPluginNameLen;
*pBuffer += dwPluginNameLen;
@@ -1284,7 +1282,7 @@ int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WOR
NetLog_Uni(bThruDC, "Error: Unknown type {%08x-%08x-%08x-%08x:%04x}: %s", q1, q2, q3, q4, qt, szPluginName);
if (wInfoLen >= 22 + dwPluginNameLen) { // sanity checking
- wInfoLen -= (WORD)(22 + dwPluginNameLen);
+ wInfoLen -= 22 + dwPluginNameLen;
// check if enough data is available - skip remaining bytes of info block
if (wLen >= wInfoLen) {
@@ -1443,7 +1441,7 @@ void CIcqProto::handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DW
}
-HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD wVersion, int type, WORD wMsgLen, PBYTE buf, BYTE bFlags, int nMsgFlags)
+HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD wVersion, int type, size_t wMsgLen, PBYTE buf, BYTE bFlags, int nMsgFlags)
{
if (bFlags == 3) {
MCONTACT hCookieContact;
@@ -1495,7 +1493,7 @@ void CIcqProto::sendMessageTypesAck(MCONTACT hContact, int bUnicode, message_ack
/* this function also processes direct packets, so it should be bulletproof */
/* pMsg points to the beginning of the message */
-void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, DWORD dwMsgID, DWORD dwMsgID2, WORD wCookie, WORD wVersion, int type, int flags, WORD wAckType, DWORD dwDataLen, WORD wMsgLen, char *pMsg, int nMsgFlags, message_ack_params *pAckParams)
+void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, DWORD dwMsgID, DWORD dwMsgID2, WORD wCookie, WORD wVersion, int type, int flags, WORD wAckType, size_t dwDataLen, size_t wMsgLen, char *pMsg, int nMsgFlags, message_ack_params *pAckParams)
{
MCONTACT hContact = INVALID_CONTACT_ID;
BOOL bThruDC = (nMsgFlags & MTF_DIRECT) == MTF_DIRECT;
@@ -1588,7 +1586,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
hContact = HContactFromUIN(dwUin, &bAdded);
sendMessageTypesAck(hContact, pre.flags & PREF_UTF, pAckParams);
- if (!pre.flags && !IsUSASCII(szMsg, strlennull(szMsg))) { // message is Ansi and contains national characters, create Unicode part by codepage
+ if (!pre.flags && !IsUSASCII(szMsg, mir_strlen(szMsg))) { // message is Ansi and contains national characters, create Unicode part by codepage
char *usMsg = convertMsgToUserSpecificUtf(hContact, szMsg);
if (usMsg) {
SAFE_FREE(&szMsg);
@@ -1615,7 +1613,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
char *szTitle = ICQTranslateUtf(LPGEN("Incoming URL:"));
char *szDataDescr = ansi_to_utf8(pszMsgField[0]);
char *szDataUrl = ansi_to_utf8(pszMsgField[1]);
- char *szBlob = (char *)SAFE_MALLOC(strlennull(szTitle) + strlennull(szDataDescr) + strlennull(szDataUrl) + 8);
+ char *szBlob = (char *)SAFE_MALLOC(mir_strlen(szTitle) + mir_strlen(szDataDescr) + mir_strlen(szDataUrl) + 8);
strcpy(szBlob, szTitle);
strcat(szBlob, " ");
strcat(szBlob, szDataDescr); // Description
@@ -1644,16 +1642,16 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
{
PROTORECVEVENT pre = { 0 };
pre.timestamp = dwTimestamp;
- pre.lParam = sizeof(DWORD) * 2 + strlennull(pszMsgField[0]) + strlennull(pszMsgField[1]) + strlennull(pszMsgField[2]) + strlennull(pszMsgField[3]) + strlennull(pszMsgField[5]) + 5;
+ pre.lParam = sizeof(DWORD) * 2 + mir_strlen(pszMsgField[0]) + mir_strlen(pszMsgField[1]) + mir_strlen(pszMsgField[2]) + mir_strlen(pszMsgField[3]) + mir_strlen(pszMsgField[5]) + 5;
// blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
char *szBlob, *pCurBlob = szBlob = (char *)_alloca(pre.lParam);
*(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD);
*(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD);
- strcpy((char*)pCurBlob, pszMsgField[0]); pCurBlob += strlennull((char*)pCurBlob) + 1;
- strcpy((char*)pCurBlob, pszMsgField[1]); pCurBlob += strlennull((char*)pCurBlob) + 1;
- strcpy((char*)pCurBlob, pszMsgField[2]); pCurBlob += strlennull((char*)pCurBlob) + 1;
- strcpy((char*)pCurBlob, pszMsgField[3]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[0]); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[1]); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[2]); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[3]); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
strcpy((char*)pCurBlob, pszMsgField[5]);
pre.szMessage = (char *)szBlob;
ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
@@ -1669,13 +1667,13 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
hContact = HContactFromUIN(dwUin, &bAdded);
{
// blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
- DWORD cbBlob = sizeof(DWORD) * 2 + strlennull(pszMsgField[0]) + strlennull(pszMsgField[1]) + strlennull(pszMsgField[2]) + strlennull(pszMsgField[3]) + 4;
+ size_t cbBlob = sizeof(DWORD) * 2 + mir_strlen(pszMsgField[0]) + mir_strlen(pszMsgField[1]) + mir_strlen(pszMsgField[2]) + mir_strlen(pszMsgField[3]) + 4;
PBYTE pBlob, pCurBlob = pBlob = (PBYTE)_alloca(cbBlob);
*(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD);
*(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD);
- strcpy((char*)pCurBlob, pszMsgField[0]); pCurBlob += strlennull((char*)pCurBlob) + 1;
- strcpy((char*)pCurBlob, pszMsgField[1]); pCurBlob += strlennull((char*)pCurBlob) + 1;
- strcpy((char*)pCurBlob, pszMsgField[2]); pCurBlob += strlennull((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[0]); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[1]); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ strcpy((char*)pCurBlob, pszMsgField[2]); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
strcpy((char*)pCurBlob, pszMsgField[3]);
AddEvent(NULL, EVENTTYPE_ADDED, dwTimestamp, 0, cbBlob, pBlob);
}
@@ -1687,7 +1685,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
int nContacts;
if (nMsgFields < 3 ||
(nContacts = strtol(pszMsgField[0], &pszNContactsEnd, 10)) == 0 ||
- pszNContactsEnd - pszMsgField[0] != (int)strlennull(pszMsgField[0]) ||
+ pszNContactsEnd - pszMsgField[0] != (int)mir_strlen(pszMsgField[0]) ||
nMsgFields < nContacts * 2 + 1)
{
NetLog_Uni(bThruDC, "Malformed '%s' message", "contacts");
@@ -1705,7 +1703,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
valid = 0;
}
else { // aim contact
- if (!strlennull(pszMsgField[1 + i * 2]))
+ if (!mir_strlen(pszMsgField[1 + i * 2]))
valid = 0;
}
isrList[i]->hdr.id = ansi_to_tchar(pszMsgField[1 + i * 2]);
@@ -1767,10 +1765,10 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
debugLogA("Malformed '%s' message", "web pager");
else {
// blob is: body(ASCIIZ), name(ASCIIZ), email(ASCIIZ)
- DWORD cbBlob = strlennull(pszMsgField[0]) + strlennull(pszMsgField[3]) + strlennull(pszMsgField[5]) + 3;
+ size_t cbBlob = mir_strlen(pszMsgField[0]) + mir_strlen(pszMsgField[3]) + mir_strlen(pszMsgField[5]) + 3;
PBYTE pBlob, pCurBlob = pBlob = (PBYTE)_alloca(cbBlob);
- strcpy((char *)pCurBlob, pszMsgField[5]); pCurBlob += strlennull((char *)pCurBlob) + 1;
- strcpy((char *)pCurBlob, pszMsgField[0]); pCurBlob += strlennull((char *)pCurBlob) + 1;
+ strcpy((char *)pCurBlob, pszMsgField[5]); pCurBlob += mir_strlen((char *)pCurBlob) + 1;
+ strcpy((char *)pCurBlob, pszMsgField[0]); pCurBlob += mir_strlen((char *)pCurBlob) + 1;
strcpy((char *)pCurBlob, pszMsgField[3]);
AddEvent(NULL, ICQEVENTTYPE_WEBPAGER, dwTimestamp, 0, cbBlob, pBlob);
@@ -1783,10 +1781,10 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
debugLogA("Malformed '%s' message", "e-mail express");
else {
// blob is: body(ASCIIZ), name(ASCIIZ), email(ASCIIZ)
- DWORD cbBlob = strlennull(pszMsgField[0]) + strlennull(pszMsgField[3]) + strlennull(pszMsgField[5]) + 3;
+ size_t cbBlob = mir_strlen(pszMsgField[0]) + mir_strlen(pszMsgField[3]) + mir_strlen(pszMsgField[5]) + 3;
PBYTE pBlob, pCurBlob = pBlob = (PBYTE)_alloca(cbBlob);
- strcpy((char *)pCurBlob, pszMsgField[5]); pCurBlob += strlennull((char *)pCurBlob) + 1;
- strcpy((char *)pCurBlob, pszMsgField[0]); pCurBlob += strlennull((char *)pCurBlob) + 1;
+ strcpy((char *)pCurBlob, pszMsgField[5]); pCurBlob += mir_strlen((char *)pCurBlob) + 1;
+ strcpy((char *)pCurBlob, pszMsgField[0]); pCurBlob += mir_strlen((char *)pCurBlob) + 1;
strcpy((char *)pCurBlob, pszMsgField[3]);
AddEvent(NULL, ICQEVENTTYPE_EMAILEXPRESS, dwTimestamp, 0, cbBlob, pBlob);
@@ -1903,7 +1901,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp,
}
-void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
+void CIcqProto::handleRecvMsgResponse(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef)
{
DWORD dwUin;
uid_str szUid;
@@ -2027,7 +2025,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d
}
if (bFlags == 3) // A status message reply
- handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, bMsgType, (WORD)dwCookie, (char*)(buf + 2), 0);
+ handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, bMsgType, dwCookie, (char*)(buf + 2), 0);
else {
// An ack of some kind
int ackType;
@@ -2119,7 +2117,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d
if (dwDataLen > 0)
memcpy(szMsg, buf, dwDataLen);
szMsg[dwDataLen] = '\0';
- handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, pCookieData->nAckType, (WORD)dwCookie, szMsg, 0);
+ handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, pCookieData->nAckType, dwCookie, szMsg, 0);
ReleaseCookie(dwCookie);
return;
@@ -2144,7 +2142,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d
memcpy(szMsg, buf, dwDataLen);
szMsg[dwDataLen] = '\0';
buf += dwDataLen;
- wLen -= (WORD)dwDataLen;
+ wLen -= dwDataLen;
handleFileAck(buf, wLen, dwUin, dwCookie, wStatus, szMsg);
// No success protoack will be sent here, since all file requests
@@ -2242,7 +2240,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d
}
// A response to a CLI_SENDMSG
-void CIcqProto::handleRecvServMsgError(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwSequence)
+void CIcqProto::handleRecvServMsgError(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwSequence)
{
WORD wError;
char *pszErrorMessage;
@@ -2272,7 +2270,7 @@ void CIcqProto::handleRecvServMsgError(BYTE *buf, WORD wLen, WORD wFlags, DWORD
// we failed to request away message the normal way, try it AIM way
icq_packet packet;
- serverPacketInit(&packet, (WORD)(13 + getUINLen(dwUin)));
+ serverPacketInit(&packet, 13 + getUINLen(dwUin));
packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_REQ_USER_INFO, 0, (WORD)dwSequence);
packWord(&packet, 0x03);
packUIN(&packet, dwUin);
@@ -2392,7 +2390,7 @@ void CIcqProto::handleRecvServMsgError(BYTE *buf, WORD wLen, WORD wFlags, DWORD
}
-void CIcqProto::handleServerAck(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwSequence)
+void CIcqProto::handleServerAck(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwSequence)
{
DWORD dwUin;
uid_str szUID;
@@ -2467,7 +2465,7 @@ void CIcqProto::handleServerAck(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwSeque
}
-void CIcqProto::handleMissedMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
+void CIcqProto::handleMissedMsg(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef)
{
DWORD dwUin;
uid_str szUid;
@@ -2499,7 +2497,7 @@ void CIcqProto::handleMissedMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
wLen -= 2;
// Read past user info TLVs
- oscar_tlv_chain *pChain = readIntoTLVChain(&buf, (WORD)(wLen - 4), wTLVCount);
+ oscar_tlv_chain *pChain = readIntoTLVChain(&buf, wLen - 4, wTLVCount);
if (pChain)
disposeChain(&pChain);
@@ -2542,7 +2540,7 @@ void CIcqProto::handleMissedMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
}
-void CIcqProto::handleOffineMessagesReply(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
+void CIcqProto::handleOffineMessagesReply(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef)
{
cookie_offline_messages *cookie;
@@ -2576,7 +2574,7 @@ void CIcqProto::handleOffineMessagesReply(BYTE *buf, WORD wLen, WORD wFlags, DWO
}
-void CIcqProto::handleTypingNotification(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
+void CIcqProto::handleTypingNotification(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef)
{
DWORD dwUin;
uid_str szUid;
@@ -2653,7 +2651,7 @@ void CIcqProto::sendTypingNotification(MCONTACT hContact, WORD wMTNCode)
if (getContactUid(hContact, &dwUin, &szUid))
return; // Invalid contact
- WORD wLen = getUIDLen(dwUin, szUid);
+ size_t wLen = getUIDLen(dwUin, szUid);
icq_packet packet;
serverPacketInit(&packet, 23 + wLen);
diff --git a/protocols/IcqOscarJ/src/fam_09bos.cpp b/protocols/IcqOscarJ/src/fam_09bos.cpp
index 9b486ff60b..a8b84290be 100644
--- a/protocols/IcqOscarJ/src/fam_09bos.cpp
+++ b/protocols/IcqOscarJ/src/fam_09bos.cpp
@@ -25,7 +25,7 @@
#include "icqoscar.h"
-void CIcqProto::handleBosFam(unsigned char *pBuffer, WORD wBufferLength, snac_header* pSnacHeader)
+void CIcqProto::handleBosFam(unsigned char *pBuffer, size_t wBufferLength, snac_header* pSnacHeader)
{
switch (pSnacHeader->wSubtype) {
case ICQ_PRIVACY_RIGHTS_REPLY: // Reply to CLI_REQBOS
@@ -51,7 +51,7 @@ void CIcqProto::handleBosFam(unsigned char *pBuffer, WORD wBufferLength, snac_he
}
}
-void CIcqProto::handlePrivacyRightsReply(unsigned char *pBuffer, WORD wBufferLength)
+void CIcqProto::handlePrivacyRightsReply(unsigned char *pBuffer, size_t wBufferLength)
{
if (wBufferLength >= 12) {
oscar_tlv_chain* pChain = readIntoTLVChain(&pBuffer, wBufferLength, 0);
diff --git a/protocols/IcqOscarJ/src/fam_0alookup.cpp b/protocols/IcqOscarJ/src/fam_0alookup.cpp
index 0f25e47b06..c05833eb92 100644
--- a/protocols/IcqOscarJ/src/fam_0alookup.cpp
+++ b/protocols/IcqOscarJ/src/fam_0alookup.cpp
@@ -25,7 +25,7 @@
#include "icqoscar.h"
-void CIcqProto::handleLookupFam(BYTE *pBuffer, WORD wBufferLength, snac_header* pSnacHeader)
+void CIcqProto::handleLookupFam(BYTE *pBuffer, size_t wBufferLength, snac_header* pSnacHeader)
{
switch (pSnacHeader->wSubtype) {
@@ -78,7 +78,7 @@ void CIcqProto::ReleaseLookupCookie(DWORD dwCookie, cookie_search *pCookie)
}
}
-void CIcqProto::handleLookupEmailReply(BYTE* buf, WORD wLen, DWORD dwCookie)
+void CIcqProto::handleLookupEmailReply(BYTE* buf, size_t wLen, DWORD dwCookie)
{
ICQSEARCHRESULT sr = { 0 };
oscar_tlv_chain *pChain;
diff --git a/protocols/IcqOscarJ/src/fam_0bstatus.cpp b/protocols/IcqOscarJ/src/fam_0bstatus.cpp
index 3cf16f39ed..f56661315e 100644
--- a/protocols/IcqOscarJ/src/fam_0bstatus.cpp
+++ b/protocols/IcqOscarJ/src/fam_0bstatus.cpp
@@ -25,7 +25,7 @@
#include "icqoscar.h"
-void CIcqProto::handleStatusFam(unsigned char *pBuffer, WORD wBufferLength, snac_header* pSnacHeader)
+void CIcqProto::handleStatusFam(unsigned char *pBuffer, size_t wBufferLength, snac_header* pSnacHeader)
{
switch (pSnacHeader->wSubtype) {
diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp
index 13d3958ec8..7ff96e0b9a 100644
--- a/protocols/IcqOscarJ/src/fam_13servclist.cpp
+++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp
@@ -25,10 +25,9 @@
#include "icqoscar.h"
-static int unpackServerListItem(BYTE **pbuf, WORD *pwLen, char *pszRecordName, WORD *pwGroupId, WORD *pwItemId, WORD *pwItemType, WORD *pwTlvLength);
+static int unpackServerListItem(BYTE **pbuf, size_t *pwLen, char *pszRecordName, WORD *pwGroupId, WORD *pwItemId, WORD *pwItemType, size_t *pwTlvLength);
-
-void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_header* pSnacHeader, serverthread_info *info)
+void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_header* pSnacHeader, serverthread_info *info)
{
switch (pSnacHeader->wSubtype) {
case ICQ_LISTS_ACK: // UPDATE_ACK
@@ -137,7 +136,8 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_heade
int nItems = 0;
while (wBufferLength >= 10) {
- WORD wGroupId, wItemId, wItemType, wTlvLen;
+ WORD wGroupId, wItemId, wItemType;
+ size_t wTlvLen;
uid_str szRecordName;
if (unpackServerListItem(&pBuffer, &wBufferLength, szRecordName, &wGroupId, &wItemId, &wItemType, &wTlvLen)) {
@@ -231,9 +231,9 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_heade
}
-static int unpackServerListItem(BYTE **pbuf, WORD *pwLen, char *pszRecordName, WORD *pwGroupId, WORD *pwItemId, WORD *pwItemType, WORD *pwTlvLength)
+static int unpackServerListItem(BYTE **pbuf, size_t *pwLen, char *pszRecordName, WORD *pwGroupId, WORD *pwItemId, WORD *pwItemType, size_t *pwTlvLength)
{
- WORD wRecordNameLen;
+ size_t wRecordNameLen;
// The name of the entry. If this is a group header, then this
// is the name of the group. If it is a plain contact list entry,
@@ -267,7 +267,7 @@ static int unpackServerListItem(BYTE **pbuf, WORD *pwLen, char *pszRecordName, W
}
-void CIcqProto::handleServerCListRightsReply(BYTE *buf, WORD wLen)
+void CIcqProto::handleServerCListRightsReply(BYTE *buf, size_t wLen)
{
/* received list rights, store the item limits for future use */
oscar_tlv_chain* chain;
@@ -694,7 +694,7 @@ int CIcqProto::getServerDataFromItemTLV(oscar_tlv_chain* pChain, unsigned char *
return datalen;
}
-void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, serverthread_info *info)
+void CIcqProto::handleServerCListReply(BYTE *buf, size_t wLen, WORD wFlags, serverthread_info *info)
{
BYTE bySSIVersion;
WORD wRecordCount;
@@ -702,7 +702,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server
WORD wGroupId;
WORD wItemId;
WORD wTlvType;
- WORD wTlvLength;
+ size_t wTlvLength;
BOOL bIsLastPacket;
uid_str szRecordName;
oscar_tlv_chain* pChain = NULL;
@@ -710,7 +710,6 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server
char *szActiveSrvGroup = NULL;
WORD wActiveSrvGroupId = -1;
-
// If flag bit 1 is set, this is not the last
// packet. If it is 0, this is the last packet
// and there will be a timestamp at the end.
@@ -804,14 +803,14 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server
}
char *szLocalGroup = getContactCListGroup(hContact);
- if (!strlennull(szLocalGroup)) { // no CListGroup
+ if (!mir_strlen(szLocalGroup)) { // no CListGroup
SAFE_FREE(&szLocalGroup);
szLocalGroup = null_strdup(DEFAULT_SS_GROUP);
}
if (strcmpnull(szActiveSrvGroup, szLocalGroup) &&
- (strlennull(szActiveSrvGroup) >= strlennull(szLocalGroup) || (szActiveSrvGroup && _strnicmp(szActiveSrvGroup, szLocalGroup, strlennull(szLocalGroup))))) { // contact moved to new group or sub-group or not to master group
+ (mir_strlen(szActiveSrvGroup) >= mir_strlen(szLocalGroup) || (szActiveSrvGroup && _strnicmp(szActiveSrvGroup, szLocalGroup, mir_strlen(szLocalGroup))))) { // contact moved to new group or sub-group or not to master group
bRegroup = 1;
}
if (bRegroup && !stricmpnull(DEFAULT_SS_GROUP, szActiveSrvGroup)) /// TODO: invent something more clever for "root" group
@@ -855,8 +854,8 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server
char *szOldNick;
if (szOldNick = getSettingStringUtf(hContact, "CList", "MyHandle", NULL)) {
- if ((strcmpnull(szOldNick, pszNick)) && (strlennull(pszNick) > 0)) { // check if the truncated nick changed, i.e. do not overwrite locally stored longer nick
- if (strlennull(szOldNick) <= strlennull(pszNick) || strncmp(szOldNick, pszNick, null_strcut(szOldNick, MAX_SSI_TLV_NAME_SIZE))) {
+ if ((strcmpnull(szOldNick, pszNick)) && (mir_strlen(pszNick) > 0)) { // check if the truncated nick changed, i.e. do not overwrite locally stored longer nick
+ if (mir_strlen(szOldNick) <= mir_strlen(pszNick) || strncmp(szOldNick, pszNick, null_strcut(szOldNick, MAX_SSI_TLV_NAME_SIZE))) {
// Yes, we really do need to delete it first. Otherwise the CLUI nick
// cache isn't updated (I'll look into it)
db_unset(hContact, "CList", "MyHandle");
@@ -865,7 +864,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server
}
SAFE_FREE(&szOldNick);
}
- else if (strlennull(pszNick) > 0) {
+ else if (mir_strlen(pszNick) > 0) {
db_unset(hContact, "CList", "MyHandle");
db_set_utf(hContact, "CList", "MyHandle", pszNick);
}
@@ -898,13 +897,13 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server
char *szOldComment;
if (szOldComment = getSettingStringUtf(hContact, "UserInfo", "MyNotes", NULL)) {
- if ((strcmpnull(szOldComment, pszComment)) && (strlennull(pszComment) > 0)) // check if the truncated comment changed, i.e. do not overwrite locally stored longer comment
- if (strlennull(szOldComment) <= strlennull(pszComment) || strncmp((char*)szOldComment, (char*)pszComment, null_strcut(szOldComment, MAX_SSI_TLV_COMMENT_SIZE)))
+ if ((strcmpnull(szOldComment, pszComment)) && (mir_strlen(pszComment) > 0)) // check if the truncated comment changed, i.e. do not overwrite locally stored longer comment
+ if (mir_strlen(szOldComment) <= mir_strlen(pszComment) || strncmp((char*)szOldComment, (char*)pszComment, null_strcut(szOldComment, MAX_SSI_TLV_COMMENT_SIZE)))
db_set_utf(hContact, "UserInfo", "MyNotes", pszComment);
SAFE_FREE((void**)&szOldComment);
}
- else if (strlennull(pszComment) > 0)
+ else if (mir_strlen(pszComment) > 0)
db_set_utf(hContact, "UserInfo", "MyNotes", pszComment);
}
SAFE_FREE((void**)&pszComment);
@@ -1357,7 +1356,7 @@ void CIcqProto::handleServerCListItemDelete(const char *szRecordName, WORD wGrou
FreeServerID(wItemId, wItemType == SSI_ITEM_GROUP ? SSIT_GROUP : SSIT_ITEM);
}
-void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen)
+void CIcqProto::handleRecvAuthRequest(unsigned char *buf, size_t wLen)
{
DWORD dwUin;
uid_str szUid;
@@ -1387,7 +1386,7 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen)
if (szReason) {
memcpy(szReason, buf, wReasonLen);
szReason[wReasonLen] = '\0';
- nReasonLen = strlennull(szReason);
+ nReasonLen = (int)mir_strlen(szReason);
char *temp = (char*)_alloca(nReasonLen + 2);
if (!IsUSASCII(szReason, nReasonLen) && UTF8_IsValid(szReason) && utf8_decode_static(szReason, temp, nReasonLen + 1))
@@ -1407,7 +1406,7 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen)
}
else szNick = null_strdup(szUid);
- int nNickLen = strlennull(szNick);
+ size_t nNickLen = mir_strlen(szNick);
pre.lParam += nNickLen + nReasonLen;
@@ -1441,15 +1440,13 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen)
SAFE_FREE(&szReason);
}
-void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen)
+void CIcqProto::handleRecvAdded(unsigned char *buf, size_t wLen)
{
DWORD dwUin;
uid_str szUid;
- DWORD cbBlob;
PBYTE pBlob, pCurBlob;
int bAdded;
char* szNick;
- int nNickLen;
DBVARIANT dbv = { 0 };
if (!unpackUID(&buf, &wLen, &dwUin, &szUid)) return;
@@ -1461,17 +1458,17 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen)
MCONTACT hContact = HContactFromUID(dwUin, szUid, &bAdded);
- cbBlob = sizeof(DWORD) * 2 + 4;
+ size_t nNickLen, cbBlob = sizeof(DWORD) * 2 + 4;
if (dwUin) {
if (getString(hContact, "Nick", &dbv))
nNickLen = 0;
else {
szNick = dbv.pszVal;
- nNickLen = strlennull(szNick);
+ nNickLen = mir_strlen(szNick);
}
}
- else nNickLen = strlennull(szUid);
+ else nNickLen = mir_strlen(szUid);
cbBlob += nNickLen;
@@ -1496,7 +1493,7 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen)
AddEvent(NULL, EVENTTYPE_ADDED, time(NULL), 0, cbBlob, pBlob);
}
-void CIcqProto::handleRecvAuthResponse(unsigned char *buf, WORD wLen)
+void CIcqProto::handleRecvAuthResponse(unsigned char *buf, size_t wLen)
{
DWORD dwUin;
uid_str szUid;
@@ -1725,7 +1722,7 @@ void CIcqProto::icq_sendServerBeginOperation(int bImport)
}
icq_packet packet;
- serverPacketInit(&packet, (WORD)(bImport ? 14 : 10));
+ serverPacketInit(&packet, bImport ? 14 : 10);
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_MODIFYSTART);
if (bImport)
packDWord(&packet, 1 << 0x10);
diff --git a/protocols/IcqOscarJ/src/fam_15icqserver.cpp b/protocols/IcqOscarJ/src/fam_15icqserver.cpp
index eb33033129..901b126891 100644
--- a/protocols/IcqOscarJ/src/fam_15icqserver.cpp
+++ b/protocols/IcqOscarJ/src/fam_15icqserver.cpp
@@ -25,7 +25,7 @@
#include "icqoscar.h"
-void CIcqProto::handleIcqExtensionsFam(BYTE *pBuffer, WORD wBufferLength, snac_header* pSnacHeader)
+void CIcqProto::handleIcqExtensionsFam(BYTE *pBuffer, size_t wBufferLength, snac_header* pSnacHeader)
{
switch (pSnacHeader->wSubtype) {
case ICQ_META_ERROR:
@@ -43,7 +43,7 @@ void CIcqProto::handleIcqExtensionsFam(BYTE *pBuffer, WORD wBufferLength, snac_h
}
-void CIcqProto::handleExtensionError(BYTE *buf, WORD wPackLen)
+void CIcqProto::handleExtensionError(BYTE *buf, size_t wPackLen)
{
WORD wErrorCode;
@@ -112,7 +112,7 @@ void CIcqProto::handleExtensionError(BYTE *buf, WORD wPackLen)
LogFamilyError(ICQ_EXTENSIONS_FAMILY, wErrorCode);
}
-void CIcqProto::handleExtensionServerInfo(BYTE *buf, WORD wPackLen, WORD wFlags)
+void CIcqProto::handleExtensionServerInfo(BYTE *buf, size_t wPackLen, WORD wFlags)
{
// The entire packet is encapsulated in a TLV type 1
oscar_tlv_chain *chain = readIntoTLVChain(&buf, wPackLen, 0);
@@ -163,7 +163,7 @@ void CIcqProto::handleExtensionServerInfo(BYTE *buf, WORD wPackLen, WORD wFlags)
}
-void CIcqProto::handleExtensionMetaResponse(BYTE *databuf, WORD wPacketLen, WORD wCookie, WORD wFlags)
+void CIcqProto::handleExtensionMetaResponse(BYTE *databuf, size_t wPacketLen, WORD wCookie, WORD wFlags)
{
WORD wReplySubtype;
BYTE bResultCode;
@@ -298,7 +298,7 @@ void CIcqProto::ReleaseSearchCookie(DWORD dwCookie, cookie_search *pCookie)
else ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)dwCookie, 0);
}
-void CIcqProto::parseSearchReplies(unsigned char *databuf, WORD wPacketLen, WORD wCookie, WORD wReplySubtype, BYTE bResultCode)
+void CIcqProto::parseSearchReplies(unsigned char *databuf, size_t wPacketLen, WORD wCookie, WORD wReplySubtype, BYTE bResultCode)
{
BYTE bParsingOK = FALSE; // For debugging purposes only
BOOL bLastUser = FALSE;
@@ -323,7 +323,7 @@ void CIcqProto::parseSearchReplies(unsigned char *databuf, WORD wPacketLen, WORD
ICQSEARCHRESULT sr = { 0 };
DWORD dwUin;
char szUin[UINMAXLEN];
- WORD wLen;
+ size_t wLen;
sr.hdr.cbSize = sizeof(sr);
@@ -446,7 +446,7 @@ void CIcqProto::parseSearchReplies(unsigned char *databuf, WORD wPacketLen, WORD
}
}
-void CIcqProto::parseUserInfoUpdateAck(unsigned char *databuf, WORD wPacketLen, WORD wCookie, WORD wReplySubtype, BYTE bResultCode)
+void CIcqProto::parseUserInfoUpdateAck(unsigned char *databuf, size_t wPacketLen, WORD wCookie, WORD wReplySubtype, BYTE bResultCode)
{
switch (wReplySubtype) {
case META_SET_PASSWORD_ACK: // Set user password server ack
@@ -562,7 +562,7 @@ int CIcqProto::parseUserInfoRecord(MCONTACT hContact, oscar_tlv *pData, UserInfo
}
-void CIcqProto::handleDirectoryQueryResponse(BYTE *databuf, WORD wPacketLen, WORD wCookie, WORD wReplySubtype, WORD wFlags)
+void CIcqProto::handleDirectoryQueryResponse(BYTE *databuf, size_t wPacketLen, WORD wCookie, WORD wReplySubtype, WORD wFlags)
{
WORD wBytesRemaining = 0;
snac_header requestSnac = { 0 };
@@ -614,7 +614,7 @@ void CIcqProto::handleDirectoryQueryResponse(BYTE *databuf, WORD wPacketLen, WOR
return;
}
- WORD wLen;
+ size_t wLen;
unpackWord(&databuf, &wLen);
wPacketLen -= 3;
if (wLen)
@@ -953,22 +953,22 @@ void CIcqProto::parseDirectorySearchData(oscar_tlv_chain *cDetails, DWORD dwCook
szData = cDetails->getString(0x50, 1); // Verified e-mail
else
szData = cDetails->getString(0x55, 1); // Pending e-mail
- if (strlennull(szData))
+ if (mir_strlen(szData))
isr.hdr.email = ansi_to_tchar(szData);
SAFE_FREE(&szData);
szData = cDetails->getString(0x64, 1); // First Name
- if (strlennull(szData))
+ if (mir_strlen(szData))
isr.hdr.firstName = utf8_to_tchar(szData);
SAFE_FREE(&szData);
szData = cDetails->getString(0x6E, 1); // Last Name
- if (strlennull(szData))
+ if (mir_strlen(szData))
isr.hdr.lastName = utf8_to_tchar(szData);
SAFE_FREE(&szData);
szData = cDetails->getString(0x78, 1); // Nick
- if (strlennull(szData))
+ if (mir_strlen(szData))
isr.hdr.nick = utf8_to_tchar(szData);
SAFE_FREE(&szData);
@@ -1013,7 +1013,7 @@ void CIcqProto::parseDirectorySearchData(oscar_tlv_chain *cDetails, DWORD dwCook
}
-void CIcqProto::handleDirectoryUpdateResponse(BYTE *databuf, WORD wPacketLen, WORD wCookie, WORD wReplySubtype)
+void CIcqProto::handleDirectoryUpdateResponse(BYTE *databuf, size_t wPacketLen, WORD wCookie, WORD wReplySubtype)
{
WORD wBytesRemaining = 0;
snac_header requestSnac = { 0 };
@@ -1056,7 +1056,7 @@ void CIcqProto::handleDirectoryUpdateResponse(BYTE *databuf, WORD wPacketLen, WO
ReleaseCookie(wCookie);
return;
}
- WORD wLen;
+ size_t wLen;
unpackWord(&databuf, &wLen);
wPacketLen -= 3;
diff --git a/protocols/IcqOscarJ/src/fam_17signon.cpp b/protocols/IcqOscarJ/src/fam_17signon.cpp
index d5251199d7..4018aa85a7 100644
--- a/protocols/IcqOscarJ/src/fam_17signon.cpp
+++ b/protocols/IcqOscarJ/src/fam_17signon.cpp
@@ -25,7 +25,7 @@
#include "icqoscar.h"
-void CIcqProto::handleAuthorizationFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader, serverthread_info *info)
+void CIcqProto::handleAuthorizationFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader, serverthread_info *info)
{
switch (pSnacHeader->wSubtype) {
@@ -70,35 +70,30 @@ static void icq_encryptPassword(const char *szPassword, BYTE *encrypted)
encrypted[i] = (szPassword[i] ^ table[i % 16]);
}
-void CIcqProto::sendClientAuth(const char *szKey, WORD wKeyLen, BOOL bSecure)
+void CIcqProto::sendClientAuth(const char *szKey, size_t wKeyLen, BOOL bSecure)
{
char szUin[UINMAXLEN];
- WORD wUinLen;
icq_packet packet;
- wUinLen = strlennull(strUID(m_dwLocalUIN, szUin));
+ size_t wUinLen = mir_strlen(strUID(m_dwLocalUIN, szUin));
- packet.wLen = (m_bLegacyFix ? 65 : 70) + sizeof(CLIENT_ID_STRING) + wUinLen + wKeyLen + (m_bSecureConnection ? 4 : 0);
+ packet.wLen = WORD((m_bLegacyFix ? 65 : 70) + sizeof(CLIENT_ID_STRING) + wUinLen + wKeyLen + (m_bSecureConnection ? 4 : 0));
- if (bSecure)
- {
- serverPacketInit(&packet, (WORD)(packet.wLen + 10));
+ if (bSecure) {
+ serverPacketInit(&packet, packet.wLen + 10);
packFNACHeader(&packet, ICQ_AUTHORIZATION_FAMILY, ICQ_SIGNON_LOGIN_REQUEST, 0, 0);
}
- else
- {
+ else {
write_flap(&packet, ICQ_LOGIN_CHAN);
packDWord(&packet, 0x00000001);
}
packTLV(&packet, 0x0001, wUinLen, (LPBYTE)szUin);
- if (bSecure)
- { // Pack MD5 auth digest
+ if (bSecure) { // Pack MD5 auth digest
packTLV(&packet, 0x0025, wKeyLen, (BYTE*)szKey);
packDWord(&packet, 0x004C0000); // empty TLV(0x4C): unknown
}
- else
- { // Pack old style password hash
+ else { // Pack old style password hash
BYTE hash[20];
icq_encryptPassword(szKey, hash);
@@ -123,7 +118,7 @@ void CIcqProto::sendClientAuth(const char *szKey, WORD wKeyLen, BOOL bSecure)
sendServPacket(&packet);
}
-void CIcqProto::handleAuthKeyResponse(BYTE *buf, WORD wPacketLen, serverthread_info *info)
+void CIcqProto::handleAuthKeyResponse(BYTE *buf, size_t wPacketLen, serverthread_info *info)
{
WORD wKeyLen;
char szKey[64] = {0};
@@ -152,7 +147,7 @@ void CIcqProto::handleAuthKeyResponse(BYTE *buf, WORD wPacketLen, serverthread_i
unpackString(&buf, szKey, wKeyLen);
mir_md5_init(&state);
- mir_md5_append(&state, info->szAuthKey, info->wAuthKeyLen);
+ mir_md5_append(&state, info->szAuthKey, (int)info->wAuthKeyLen);
mir_md5_finish(&state, digest);
mir_md5_init(&state);
diff --git a/protocols/IcqOscarJ/src/i18n.cpp b/protocols/IcqOscarJ/src/i18n.cpp
index 102c695e09..5f2c1f4f2a 100644
--- a/protocols/IcqOscarJ/src/i18n.cpp
+++ b/protocols/IcqOscarJ/src/i18n.cpp
@@ -39,9 +39,9 @@ void InitI18N(void)
}
// Returns true if the buffer only contains 7-bit characters.
-BOOL __stdcall IsUSASCII(const char *pBuffer, int nSize)
+BOOL __stdcall IsUSASCII(const char *pBuffer, size_t nSize)
{
- for (int nIndex = 0; nIndex < nSize; nIndex++)
+ for (size_t nIndex = 0; nIndex < nSize; nIndex++)
if (BYTE(pBuffer[nIndex]) > 0x7F)
return FALSE;
@@ -49,9 +49,9 @@ BOOL __stdcall IsUSASCII(const char *pBuffer, int nSize)
}
// Returns true if the unicode buffer only contains 7-bit characters.
-BOOL __stdcall IsUnicodeAscii(const WCHAR *pBuffer, int nSize)
+BOOL __stdcall IsUnicodeAscii(const WCHAR *pBuffer, size_t nSize)
{
- for (int nIndex = 0; nIndex < nSize; nIndex++)
+ for (size_t nIndex = 0; nIndex < nSize; nIndex++)
if (WORD(pBuffer[nIndex]) > 0x7F)
return FALSE;
@@ -69,8 +69,7 @@ int __stdcall UTF8_IsValid(const char *pszInput)
if (!pszInput)
return 0;
- for ( BYTE* c = ( BYTE*)pszInput; *c; c += (nb + 1))
- {
+ for (BYTE* c = (BYTE*)pszInput; *c; c += (nb + 1)) {
if (!(*c & 0x80))
nb = 0;
else if ((*c & 0xc0) == 0x80) return 0;
@@ -81,7 +80,7 @@ int __stdcall UTF8_IsValid(const char *pszInput)
else if ((*c & 0xfe) == 0xfc) nb = 5;
else nb = 0;
- for (int i = 1; i<=nb; i++) // we this forward, do not cross end of string
+ for (int i = 1; i <= nb; i++) // we this forward, do not cross end of string
if ((*(c + i) & 0xc0) != 0x80)
return 0;
}
@@ -96,13 +95,12 @@ int __stdcall get_utf8_size(const WCHAR *unicode)
int index = 0;
/* calculate the size of the utf-8 string */
WCHAR c = unicode[index++];
- while (c)
- {
- if (c < 0x0080)
+ while (c) {
+ if (c < 0x0080)
size += 1;
- else if (c < 0x0800)
+ else if (c < 0x0800)
size += 2;
- else
+ else
size += 3;
c = unicode[index++];
}
@@ -115,7 +113,7 @@ char* __stdcall detect_decode_utf8(const char *from)
{
char *temp = NULL;
- if (IsUSASCII(from, strlennull(from)) || !UTF8_IsValid(from) || !utf8_decode(from, &temp)) return (char*)from;
+ if (IsUSASCII(from, mir_strlen(from)) || !UTF8_IsValid(from) || !utf8_decode(from, &temp)) return (char*)from;
SAFE_FREE((void**)&from);
return temp;
@@ -160,21 +158,17 @@ char* __stdcall make_utf8_string_static(const WCHAR *unicode, char *utf8, size_t
unsigned short c;
c = unicode[index++];
- while (c)
- {
- if (c < 0x080)
- {
+ while (c) {
+ if (c < 0x080) {
if (out_index + 1 >= utf_size) break;
utf8[out_index++] = (unsigned char)c;
}
- else if (c < 0x800)
- {
+ else if (c < 0x800) {
if (out_index + 2 >= utf_size) break;
utf8[out_index++] = 0xc0 | (c >> 6);
utf8[out_index++] = 0x80 | (c & 0x3f);
}
- else
- {
+ else {
if (out_index + 3 >= utf_size) break;
utf8[out_index++] = 0xe0 | (c >> 12);
utf8[out_index++] = 0x80 | ((c >> 6) & 0x3f);
@@ -207,28 +201,23 @@ WCHAR* __stdcall make_unicode_string_static(const char *utf8, WCHAR *unicode, si
{
unsigned int out_index = 0;
- if (utf8)
- {
+ if (utf8) {
unsigned int index = 0;
unsigned char c = utf8[index++];
- while (c)
- {
+ while (c) {
if (out_index + 1 >= unicode_size) break;
- if ((c & 0x80) == 0)
- {
+ if ((c & 0x80) == 0) {
unicode[out_index++] = c;
- }
- else if ((c & 0xe0) == 0xe0)
- {
+ }
+ else if ((c & 0xe0) == 0xe0) {
unicode[out_index] = (c & 0x1F) << 12;
c = utf8[index++];
unicode[out_index] |= (c & 0x3F) << 6;
c = utf8[index++];
unicode[out_index++] |= (c & 0x3F);
}
- else
- {
+ else {
unicode[out_index] = (c & 0x3F) << 6;
c = utf8[index++];
unicode[out_index++] |= (c & 0x3F);
@@ -250,18 +239,14 @@ WCHAR* __stdcall make_unicode_string(const char *utf8)
/* first calculate the size of the target string */
unsigned char c = utf8[index++];
- while (c)
- {
- if ((c & 0x80) == 0)
- {
+ while (c) {
+ if ((c & 0x80) == 0) {
index += 0;
}
- else if ((c & 0xe0) == 0xe0)
- {
+ else if ((c & 0xe0) == 0xe0) {
index += 2;
}
- else
- {
+ else {
index += 1;
}
size += 1;
@@ -278,10 +263,9 @@ WCHAR* __stdcall make_unicode_string(const char *utf8)
int __stdcall utf8_encode(const char *from, char **to)
{
- int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, strlennull(from), NULL, 0);
+ int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, (int)mir_strlen(from), NULL, 0);
- if (wchars == 0)
- {
+ if (wchars == 0) {
#ifdef _DEBUG
fprintf(stderr, "Unicode translation error %d\n", GetLastError());
#endif
@@ -291,9 +275,8 @@ int __stdcall utf8_encode(const char *from, char **to)
WCHAR *unicode = (WCHAR*)_alloca((wchars + 1) * sizeof(WCHAR));
ZeroMemory(unicode, (wchars + 1) * sizeof(WCHAR));
- int err = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, strlennull(from), unicode, wchars);
- if (err != wchars)
- {
+ int err = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, (int)mir_strlen(from), unicode, wchars);
+ if (err != wchars) {
#ifdef _DEBUG
fprintf(stderr, "Unicode translation error %d\n", GetLastError());
#endif
@@ -312,8 +295,7 @@ char* __stdcall ansi_to_utf8(const char *ansi)
{
char *szUtf = NULL;
- if (strlennull(ansi))
- {
+ if (mir_strlen(ansi)) {
utf8_encode(ansi, &szUtf);
return szUtf;
}
@@ -324,11 +306,11 @@ char* __stdcall ansi_to_utf8(const char *ansi)
char* __stdcall ansi_to_utf8_codepage(const char *ansi, WORD wCp)
{
- int wchars = strlennull(ansi);
+ size_t wchars = mir_strlen(ansi);
WCHAR *unicode = (WCHAR*)_alloca((wchars + 1) * sizeof(WCHAR));
ZeroMemory(unicode, (wchars + 1) * sizeof(WCHAR));
- MultiByteToWideChar(wCp, MB_PRECOMPOSED, ansi, wchars, unicode, wchars);
+ MultiByteToWideChar(wCp, MB_PRECOMPOSED, ansi, (int)wchars, unicode, (int)wchars);
return make_utf8_string(unicode);
}
@@ -346,37 +328,31 @@ int __stdcall utf8_decode_codepage(const char *from, char **to, WORD wCp)
return 0;
// Use the native conversion routines when available
- if (bHasCP_UTF8)
- {
- int inlen = strlennull(from) + 1;
+ if (bHasCP_UTF8) {
+ size_t inlen = mir_strlen(from) + 1;
WCHAR *wszTemp = (WCHAR *)_alloca(inlen * sizeof(WCHAR));
- ZeroMemory(wszTemp, inlen * sizeof(WCHAR));
+ ZeroMemory(wszTemp, inlen * sizeof(WCHAR));
// Convert the UTF-8 string to UCS
- if (MultiByteToWideChar(CP_UTF8, 0, from, -1, wszTemp, inlen))
- {
+ if (MultiByteToWideChar(CP_UTF8, 0, from, -1, wszTemp, (int)inlen)) {
// Convert the UCS string to local ANSI codepage
*to = (char*)SAFE_MALLOC(inlen);
- if (WideCharToMultiByte(wCp, 0, wszTemp, -1, *to, inlen, NULL, NULL))
- {
+ if (WideCharToMultiByte(wCp, 0, wszTemp, -1, *to, (int)inlen, NULL, NULL)) {
nResult = 1;
}
- else
- {
+ else {
SAFE_FREE(to);
}
}
}
- else
- {
- int chars = strlennull(from) + 1;
+ else {
+ size_t chars = mir_strlen(from) + 1;
WCHAR *unicode = (WCHAR*)_alloca(chars * sizeof(WCHAR));
make_unicode_string_static(from, unicode, chars);
chars = WideCharToMultiByte(wCp, WC_COMPOSITECHECK, unicode, -1, NULL, 0, NULL, NULL);
- if (chars == 0)
- {
+ if (chars == 0) {
#ifdef _DEBUG
fprintf(stderr, "Unicode translation error %d\n", GetLastError());
#endif
@@ -384,17 +360,15 @@ int __stdcall utf8_decode_codepage(const char *from, char **to, WORD wCp)
}
*to = (char*)SAFE_MALLOC((chars + 1)*sizeof(char));
- if (*to == NULL)
- {
+ if (*to == NULL) {
#ifdef _DEBUG
fprintf(stderr, "Out of memory processing string to local charset\n");
#endif
return 0;
}
- int err = WideCharToMultiByte(wCp, WC_COMPOSITECHECK, unicode, -1, *to, chars, NULL, NULL);
- if (err != chars)
- {
+ int err = WideCharToMultiByte(wCp, WC_COMPOSITECHECK, unicode, -1, *to, (int)chars, NULL, NULL);
+ if (err != chars) {
#ifdef _DEBUG
fprintf(stderr, "Unicode translation error %d\n", GetLastError());
#endif
@@ -417,7 +391,7 @@ int __stdcall utf8_decode(const char *from, char **to)
// Returns 0 on error, 1 on success
-int __stdcall utf8_decode_static(const char *from, char *to, int to_size)
+int __stdcall utf8_decode_static(const char *from, char *to, size_t to_size)
{
int nResult = 0;
@@ -427,34 +401,30 @@ int __stdcall utf8_decode_static(const char *from, char *to, int to_size)
if (!UTF8_IsValid(from))
return 0;
- // Clear target
- ZeroMemory(to, to_size);
+ // Clear target
+ ZeroMemory(to, to_size);
// Use the native conversion routines when available
- if (bHasCP_UTF8)
- {
- int inlen = strlennull(from) + 1;
+ if (bHasCP_UTF8) {
+ size_t inlen = mir_strlen(from) + 1;
WCHAR *wszTemp = (WCHAR*)_alloca(inlen * sizeof(WCHAR));
ZeroMemory(wszTemp, inlen * sizeof(WCHAR));
// Convert the UTF-8 string to UCS
- if (MultiByteToWideChar(CP_UTF8, 0, from, -1, wszTemp, inlen))
- {
+ if (MultiByteToWideChar(CP_UTF8, 0, from, -1, wszTemp, (int)inlen)) {
// Convert the UCS string to local ANSI codepage
- if (WideCharToMultiByte(CP_ACP, 0, wszTemp, -1, to, to_size, NULL, NULL))
- {
+ if (WideCharToMultiByte(CP_ACP, 0, wszTemp, -1, to, (int)to_size, NULL, NULL)) {
nResult = 1;
}
}
}
- else
- {
- size_t chars = strlennull(from) + 1;
+ else {
+ size_t chars = mir_strlen(from) + 1;
WCHAR *unicode = (WCHAR*)_alloca(chars * sizeof(WCHAR));
make_unicode_string_static(from, unicode, chars);
- WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, -1, to, to_size, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, -1, to, (int)to_size, NULL, NULL);
nResult = 1;
}
@@ -465,10 +435,9 @@ int __stdcall utf8_decode_static(const char *from, char *to, int to_size)
WCHAR* __stdcall ansi_to_unicode(const char *ansi)
{
- int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ansi, strlennull(ansi), NULL, 0);
+ int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ansi, (int)mir_strlen(ansi), NULL, 0);
- if (wchars == 0)
- {
+ if (wchars == 0) {
#ifdef _DEBUG
fprintf(stderr, "Unicode translation error %d\n", GetLastError());
#endif
@@ -477,36 +446,33 @@ WCHAR* __stdcall ansi_to_unicode(const char *ansi)
WCHAR *unicode = (WCHAR*)SAFE_MALLOC((wchars + 1) * sizeof(WCHAR));
- int err = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ansi, strlennull(ansi), unicode, wchars);
- if (err != wchars)
- {
+ int err = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, ansi, (int)mir_strlen(ansi), unicode, wchars);
+ if (err != wchars) {
#ifdef _DEBUG
fprintf(stderr, "Unicode translation error %d\n", GetLastError());
#endif
- SAFE_FREE(&unicode);
+ SAFE_FREE(&unicode);
return NULL;
}
- return unicode;
+ return unicode;
}
-char* __stdcall unicode_to_ansi_static(const WCHAR *unicode, char *ansi, int ansi_size)
+char* __stdcall unicode_to_ansi_static(const WCHAR *unicode, char *ansi, size_t ansi_size)
{
- ZeroMemory(ansi, ansi_size);
+ ZeroMemory(ansi, ansi_size);
- if (WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, strlennull(unicode), ansi, ansi_size, NULL, NULL) > 1)
+ if (WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), ansi, (int)ansi_size, NULL, NULL) > 1)
return ansi;
- return NULL;
+ return NULL;
}
-
char* __stdcall unicode_to_ansi(const WCHAR *unicode)
{
- int chars = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, strlennull(unicode), NULL, 0, NULL, NULL);
+ int chars = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), NULL, 0, NULL, NULL);
- if (chars == 0)
- {
+ if (chars == 0) {
#ifdef _DEBUG
fprintf(stderr, "Unicode translation error %d\n", GetLastError());
#endif
@@ -514,17 +480,15 @@ char* __stdcall unicode_to_ansi(const WCHAR *unicode)
}
char* ansi = (char*)SAFE_MALLOC((chars + 1)*sizeof(char));
- if (ansi == NULL)
- {
+ if (ansi == NULL) {
#ifdef _DEBUG
fprintf(stderr, "Out of memory processing string to local charset\n");
#endif
return NULL;
}
- int err = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, strlennull(unicode), ansi, chars, NULL, NULL);
- if (err != chars)
- {
+ int err = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, (int)mir_wstrlen(unicode), ansi, chars, NULL, NULL);
+ if (err != chars) {
#ifdef _DEBUG
fprintf(stderr, "Unicode translation error %d\n", GetLastError());
#endif
diff --git a/protocols/IcqOscarJ/src/i18n.h b/protocols/IcqOscarJ/src/i18n.h
index e00719718d..923609c8a2 100644
--- a/protocols/IcqOscarJ/src/i18n.h
+++ b/protocols/IcqOscarJ/src/i18n.h
@@ -30,8 +30,8 @@
#ifndef __I18N_H
#define __I18N_H
-BOOL __stdcall IsUSASCII(const char *pBuffer, int nSize);
-BOOL __stdcall IsUnicodeAscii(const WCHAR *pBuffer, int nSize);
+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);
int __stdcall get_utf8_size(const WCHAR *unicode);
@@ -49,12 +49,12 @@ char* __stdcall 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, int ansi_size);
+char* __stdcall 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, int to_size);
+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
diff --git a/protocols/IcqOscarJ/src/icq_advsearch.cpp b/protocols/IcqOscarJ/src/icq_advsearch.cpp
index e7e60fc58b..510c1bc03b 100644
--- a/protocols/IcqOscarJ/src/icq_advsearch.cpp
+++ b/protocols/IcqOscarJ/src/icq_advsearch.cpp
@@ -68,7 +68,7 @@ static DWORD getCurItemData(HWND hwndDlg, UINT iCtrl)
return SendDlgItemMessage(hwndDlg, iCtrl, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, iCtrl, CB_GETCURSEL, 0, 0), 0);
}
-static void searchPackTLVLNTS(PBYTE *buf, int *buflen, HWND hwndDlg, UINT idControl, WORD wType)
+static void searchPackTLVLNTS(PBYTE *buf, size_t *buflen, HWND hwndDlg, UINT idControl, WORD wType)
{
char str[512];
@@ -77,7 +77,7 @@ static void searchPackTLVLNTS(PBYTE *buf, int *buflen, HWND hwndDlg, UINT idCont
ppackLETLVLNTS(buf, buflen, str, wType, 0);
}
-static void searchPackTLVWordLNTS(PBYTE *buf, int *buflen, HWND hwndDlg, UINT idControl, WORD w, WORD wType)
+static void searchPackTLVWordLNTS(PBYTE *buf, size_t *buflen, HWND hwndDlg, UINT idControl, WORD w, WORD wType)
{
char str[512];
@@ -86,10 +86,10 @@ static void searchPackTLVWordLNTS(PBYTE *buf, int *buflen, HWND hwndDlg, UINT id
ppackLETLVWordLNTS(buf, buflen, w, str, wType, 0);
}
-static PBYTE createAdvancedSearchStructureTLV(HWND hwndDlg, int *length)
+static PBYTE createAdvancedSearchStructureTLV(HWND hwndDlg, size_t *length)
{
PBYTE buf = NULL;
- int buflen = 0;
+ size_t buflen = 0;
ppackLEWord(&buf, &buflen, META_SEARCH_GENERIC); /* subtype: full search */
@@ -140,7 +140,7 @@ static PBYTE createAdvancedSearchStructureTLV(HWND hwndDlg, int *length)
return buf;
}
-PBYTE createAdvancedSearchStructure(HWND hwndDlg, int *length)
+PBYTE createAdvancedSearchStructure(HWND hwndDlg, size_t *length)
{
if (!hwndDlg)
return NULL;
diff --git a/protocols/IcqOscarJ/src/icq_advsearch.h b/protocols/IcqOscarJ/src/icq_advsearch.h
index e82625aa65..063dbf28dc 100644
--- a/protocols/IcqOscarJ/src/icq_advsearch.h
+++ b/protocols/IcqOscarJ/src/icq_advsearch.h
@@ -22,5 +22,5 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// -----------------------------------------------------------------------------
-INT_PTR CALLBACK AdvancedSearchDlgProc(HWND hwndDlg,UINT message,WPARAM wParam,LPARAM lParam);
-PBYTE createAdvancedSearchStructure(HWND hwndDlg,int *length);
+INT_PTR CALLBACK AdvancedSearchDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
+PBYTE createAdvancedSearchStructure(HWND hwndDlg, size_t *length);
diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp
index 6a9f733296..7d2a5573bf 100644
--- a/protocols/IcqOscarJ/src/icq_avatar.cpp
+++ b/protocols/IcqOscarJ/src/icq_avatar.cpp
@@ -104,7 +104,7 @@ void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest,
// fill the destination
lstrcpyn(pszDest, szPath, cbLen - 1);
- int tPathLen = strlennull(pszDest);
+ size_t tPathLen = mir_tstrlen(pszDest);
// make sure the avatar cache directory exists
CreateDirectoryTreeT(szPath);
@@ -188,7 +188,7 @@ int CIcqProto::IsAvatarChanged(MCONTACT hContact, const BYTE *pHash, int nHashLe
return ret;
}
-void CIcqProto::StartAvatarThread(HANDLE hConn, char *cookie, WORD cookieLen) // called from event
+void CIcqProto::StartAvatarThread(HANDLE hConn, char *cookie, size_t cookieLen) // called from event
{
if (!hConn) {
icq_lock l(m_avatarsMutex); // place avatars lock
@@ -734,7 +734,7 @@ void __cdecl CIcqProto::AvatarThread(avatars_server_connection *pInfo)
debugLogA("%s thread ended.", "Avatar");
}
-avatars_server_connection::avatars_server_connection(CIcqProto *_ppro, HANDLE _hConnection, char *_pCookie, WORD _wCookieLen) :
+avatars_server_connection::avatars_server_connection(CIcqProto *_ppro, HANDLE _hConnection, char *_pCookie, size_t _wCookieLen) :
isLoggedIn(false), stopThread(false), isActive(false),
ppro(_ppro),
pCookie(_pCookie),
@@ -777,7 +777,7 @@ void avatars_server_connection::shutdownConnection()
Netlib_Shutdown(hConnection);
}
-DWORD avatars_server_connection::sendGetAvatarRequest(MCONTACT hContact, DWORD dwUin, char *szUid, const BYTE *hash, unsigned int hashlen, const TCHAR *file)
+DWORD avatars_server_connection::sendGetAvatarRequest(MCONTACT hContact, DWORD dwUin, char *szUid, const BYTE *hash, size_t hashlen, const TCHAR *file)
{
int i;
DWORD dwNow = GetTickCount();
@@ -837,11 +837,11 @@ DWORD avatars_server_connection::sendGetAvatarRequest(MCONTACT hContact, DWORD d
DWORD dwCookie = ppro->AllocateCookie(CKT_AVATAR, ICQ_AVATAR_GET_REQUEST, hContact, ack);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(12 + nUinLen + hashlen));
+ serverPacketInit(&packet, 12 + nUinLen + hashlen);
packFNACHeader(&packet, ICQ_AVATAR_FAMILY, ICQ_AVATAR_GET_REQUEST, 0, dwCookie);
packUID(&packet, dwUin, szUid);
packByte(&packet, 1); // unknown, probably type of request: 1 = get icon :)
- packBuffer(&packet, hash, (WORD)hashlen);
+ packBuffer(&packet, hash, hashlen);
if (sendServerPacket(&packet)) {
ppro->debugLogA("Request to get %s image sent.", strUID(dwUin, szUid));
@@ -859,7 +859,7 @@ DWORD avatars_server_connection::sendGetAvatarRequest(MCONTACT hContact, DWORD d
return 0; // Failure
}
-DWORD avatars_server_connection::sendUploadAvatarRequest(MCONTACT hContact, WORD wRef, const BYTE *data, unsigned int datalen)
+DWORD avatars_server_connection::sendUploadAvatarRequest(MCONTACT hContact, WORD wRef, const BYTE *data, size_t datalen)
{
cookie_avatar *ack = (cookie_avatar*)SAFE_MALLOC(sizeof(cookie_avatar));
if (!ack)
@@ -870,11 +870,11 @@ DWORD avatars_server_connection::sendUploadAvatarRequest(MCONTACT hContact, WORD
DWORD dwCookie = ppro->AllocateCookie(CKT_AVATAR, ICQ_AVATAR_UPLOAD_REQUEST, 0, ack);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(14 + datalen));
+ serverPacketInit(&packet, 14 + datalen);
packFNACHeader(&packet, ICQ_AVATAR_FAMILY, ICQ_AVATAR_UPLOAD_REQUEST, 0, dwCookie);
packWord(&packet, wRef); // unknown, probably reference
packWord(&packet, (WORD)datalen);
- packBuffer(&packet, data, (WORD)datalen);
+ packBuffer(&packet, data, datalen);
if (sendServerPacket(&packet)) {
ppro->debugLogA("Upload image packet sent.");
@@ -1020,7 +1020,7 @@ int avatars_server_connection::sendServerPacket(icq_packet *pPacket)
int nSendResult;
for (int nRetries = 3; nRetries >= 0; nRetries--) {
- nSendResult = Netlib_Send(hConnection, (const char *)pPacket->pData, pPacket->wLen, 0);
+ nSendResult = Netlib_Send(hConnection, (const char*)pPacket->pData, (int)pPacket->wLen, 0);
if (nSendResult != SOCKET_ERROR)
break;
@@ -1047,7 +1047,7 @@ int avatars_server_connection::sendServerPacket(icq_packet *pPacket)
return lResult;
}
-int avatars_server_connection::handleServerPackets(BYTE *buf, int buflen)
+int avatars_server_connection::handleServerPackets(BYTE *buf, size_t buflen)
{
BYTE channel;
WORD sequence;
@@ -1094,7 +1094,7 @@ int avatars_server_connection::handleServerPackets(BYTE *buf, int buflen)
return bytesUsed;
}
-void avatars_server_connection::handleLoginChannel(BYTE *buf, WORD datalen)
+void avatars_server_connection::handleLoginChannel(BYTE *buf, size_t datalen)
{
if (*(DWORD*)buf == 0x1000000) { // here check if we received SRV_HELLO
wLocalSequence = generate_flap_sequence();
@@ -1111,7 +1111,7 @@ void avatars_server_connection::handleLoginChannel(BYTE *buf, WORD datalen)
else ppro->debugLogA("Invalid Server response, Channel 1.");
}
-void avatars_server_connection::handleDataChannel(BYTE *buf, WORD datalen)
+void avatars_server_connection::handleDataChannel(BYTE *buf, size_t datalen)
{
snac_header snacHeader = {0};
if (!unpackSnacHeader(&snacHeader, &buf, &datalen) || !snacHeader.bValid)
@@ -1138,7 +1138,7 @@ void avatars_server_connection::handleDataChannel(BYTE *buf, WORD datalen)
}
}
-void avatars_server_connection::handleServiceFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader)
+void avatars_server_connection::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader)
{
icq_packet packet;
@@ -1199,7 +1199,7 @@ void avatars_server_connection::handleServiceFam(BYTE *pBuffer, WORD wBufferLeng
}
}
-void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader)
+void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader)
{
cookie_avatar *pCookieData;
@@ -1230,7 +1230,6 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, WORD wBufferLengt
ppro->FreeCookie(pSnacHeader->dwRef);
BYTE len;
- WORD datalen;
unpackByte(&pBuffer, &len);
if (wBufferLength < ((pCookieData->hashlen) << 1) + 4 + len) {
@@ -1248,6 +1247,8 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, WORD wBufferLengt
pBuffer += pCookieData->hashlen;
unpackByte(&pBuffer, &bResult);
pBuffer += pCookieData->hashlen;
+
+ size_t datalen;
unpackWord(&pBuffer, &datalen);
wBufferLength -= 4 + len + (pCookieData->hashlen << 1);
@@ -1264,7 +1265,7 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, WORD wBufferLengt
BYTE digest[16];
mir_md5_init(&state);
- mir_md5_append(&state, (const BYTE *)pBuffer, datalen);
+ mir_md5_append(&state, (const BYTE *)pBuffer, (int)datalen);
mir_md5_finish(&state, digest);
// check if received data corresponds to specified hash
if (memcmp(pCookieData->hash + 4, digest, 0x10)) aValid = 0;
@@ -1284,7 +1285,7 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, WORD wBufferLengt
int out = _topen(tszImageFile, _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _S_IREAD | _S_IWRITE);
if (out != -1) {
- _write(out, pBuffer, datalen);
+ _write(out, pBuffer, (int)datalen);
_close(out);
if (!pCookieData->hContact) { // our avatar, set filename
@@ -1303,8 +1304,8 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, WORD wBufferLengt
else {
ppro->debugLogA("Warning: DB error (no hash in DB).");
// the hash was lost, try to fix that
- if (ppro->setSettingBlob(pCookieData->hContact, "AvatarSaved", pCookieData->hash, pCookieData->hashlen) ||
- ppro->setSettingBlob(pCookieData->hContact, "AvatarHash", pCookieData->hash, pCookieData->hashlen))
+ if (ppro->setSettingBlob(pCookieData->hContact, "AvatarSaved", pCookieData->hash, (int)pCookieData->hashlen) ||
+ ppro->setSettingBlob(pCookieData->hContact, "AvatarHash", pCookieData->hash, (int)pCookieData->hashlen))
{
ppro->debugLogA("Failed to save avatar hash to DB");
}
diff --git a/protocols/IcqOscarJ/src/icq_avatar.h b/protocols/IcqOscarJ/src/icq_avatar.h
index b67230fb0d..f776b0f3b9 100644
--- a/protocols/IcqOscarJ/src/icq_avatar.h
+++ b/protocols/IcqOscarJ/src/icq_avatar.h
@@ -1,23 +1,23 @@
// ---------------------------------------------------------------------------80
// ICQ plugin for Miranda Instant Messenger
// ________________________________________
-//
+//
// Copyright © 2000-2001 Richard Hughes, Roland Rabien, Tristan Van de Vreede
// Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
// Copyright © 2012-2014 Miranda NG Team
-//
+//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -53,17 +53,17 @@ protected:
BOOL stopThread; // horrible, but simple - signal for thread to stop
char *pCookie; // auth to server
- WORD wCookieLen;
+ size_t wCookieLen;
int sendServerPacket(icq_packet *pPacket);
- int handleServerPackets(BYTE *buf, int buflen);
+ int handleServerPackets(BYTE *buf, size_t buflen);
- void handleLoginChannel(BYTE *buf, WORD datalen);
- void handleDataChannel(BYTE *buf, WORD datalen);
+ void handleLoginChannel(BYTE *buf, size_t datalen);
+ void handleDataChannel(BYTE *buf, size_t datalen);
- void handleServiceFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader);
- void handleAvatarFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader);
+ void handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader);
+ void handleAvatarFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader);
rates *m_rates;
icq_critical_section *m_ratesMutex;
@@ -74,7 +74,7 @@ protected:
void checkRequestQueue();
public:
- avatars_server_connection(CIcqProto *ppro, HANDLE hConnection, char *pCookie, WORD wCookieLen);
+ avatars_server_connection(CIcqProto *ppro, HANDLE hConnection, char *pCookie, size_t wCookieLen);
virtual ~avatars_server_connection();
void connectionThread();
@@ -84,25 +84,25 @@ public:
__inline BOOL isPending() { return !isLoggedIn; };
__inline BOOL isReady() { return isLoggedIn && isActive && !stopThread; };
- DWORD sendGetAvatarRequest(MCONTACT hContact, DWORD dwUin, char *szUid, const BYTE *hash, unsigned int hashlen, const TCHAR *file);
- DWORD sendUploadAvatarRequest(MCONTACT hContact, WORD wRef, const BYTE *data, unsigned int datalen);
+ DWORD sendGetAvatarRequest(MCONTACT hContact, DWORD dwUin, char *szUid, const BYTE *hash, size_t hashlen, const TCHAR *file);
+ DWORD sendUploadAvatarRequest(MCONTACT hContact, WORD wRef, const BYTE *data, size_t datalen);
};
__inline static void SAFE_DELETE(avatars_server_connection **p) { SAFE_DELETE((lockable_struct**)p); };
struct avatars_request : public MZeroedObject
{
- int type;
+ int type;
MCONTACT hContact;
- DWORD dwUin;
- uid_str szUid;
- BYTE *hash;
- unsigned int hashlen;
- TCHAR *szFile;
- BYTE *pData;
- unsigned int cbData;
- WORD wRef;
- DWORD timeOut;
+ DWORD dwUin;
+ uid_str szUid;
+ BYTE *hash;
+ size_t hashlen;
+ TCHAR *szFile;
+ BYTE *pData;
+ size_t cbData;
+ WORD wRef;
+ DWORD timeOut;
avatars_request *pNext;
public:
diff --git a/protocols/IcqOscarJ/src/icq_clients.cpp b/protocols/IcqOscarJ/src/icq_clients.cpp
index 6b0a046c91..e70066b9ca 100644
--- a/protocols/IcqOscarJ/src/icq_clients.cpp
+++ b/protocols/IcqOscarJ/src/icq_clients.cpp
@@ -188,7 +188,7 @@ const char* cliSpamBot = "Spam Bot";
const char* CIcqProto::detectUserClient(MCONTACT hContact, int nIsICQ, WORD wUserClass, DWORD dwOnlineSince, const char *szCurrentClient,
WORD wVersion, DWORD dwFT1, DWORD dwFT2, DWORD dwFT3, BYTE bDirectFlag, DWORD dwDirectCookie, DWORD dwWebPort, /* ICQ specific */
- BYTE *caps, WORD wLen, /* Client capabilities */
+ BYTE *caps, size_t wLen, /* Client capabilities */
BYTE *bClientId, /* Output: detected client-type */
char *szClientBuf)
{
diff --git a/protocols/IcqOscarJ/src/icq_db.cpp b/protocols/IcqOscarJ/src/icq_db.cpp
index 35fabbe38c..e121b6d0d8 100644
--- a/protocols/IcqOscarJ/src/icq_db.cpp
+++ b/protocols/IcqOscarJ/src/icq_db.cpp
@@ -189,14 +189,14 @@ int CIcqProto::IsICQContact(MCONTACT hContact)
return !strcmpnull(szProto, m_szModuleName);
}
-HANDLE CIcqProto::AddEvent(MCONTACT hContact, WORD wType, DWORD dwTime, DWORD flags, DWORD cbBlob, PBYTE pBlob)
+HANDLE CIcqProto::AddEvent(MCONTACT hContact, WORD wType, DWORD dwTime, DWORD flags, size_t cbBlob, PBYTE pBlob)
{
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = dwTime;
dbei.flags = flags;
dbei.eventType = wType;
- dbei.cbBlob = cbBlob;
+ dbei.cbBlob = (DWORD)cbBlob;
dbei.pBlob = pBlob;
return db_event_add(hContact, &dbei);
}
diff --git a/protocols/IcqOscarJ/src/icq_direct.cpp b/protocols/IcqOscarJ/src/icq_direct.cpp
index 391ccf16dd..f1834c6776 100644
--- a/protocols/IcqOscarJ/src/icq_direct.cpp
+++ b/protocols/IcqOscarJ/src/icq_direct.cpp
@@ -196,7 +196,7 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi)
NETLIBPACKETRECVER packetRecv = { 0 };
HANDLE hPacketRecver;
BOOL bFirstPacket = TRUE;
- int nSkipPacketBytes = 0;
+ size_t nSkipPacketBytes = 0;
DWORD dwReqMsgID1;
DWORD dwReqMsgID2;
@@ -377,10 +377,9 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi)
packetRecv.bytesUsed = packetRecv.bytesAvailable;
}
else {
- int i;
-
+ size_t i;
for (i = nSkipPacketBytes, nSkipPacketBytes = 0; i + 2 <= packetRecv.bytesAvailable;) {
- WORD wLen = *(WORD*)(packetRecv.buffer + i);
+ size_t wLen = *(WORD*)(packetRecv.buffer + i);
if (bFirstPacket) {
if (wLen > 64) { // roughly check first packet size
@@ -394,7 +393,7 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi)
if (packetRecv.bytesAvailable >= i + 2 && wLen > 8190) { // check for too big packages
NetLog_Direct("Error: Package too big: %d bytes, skipping.");
nSkipPacketBytes = wLen;
- packetRecv.bytesUsed = i + 2;
+ packetRecv.bytesUsed = int(i + 2);
break;
}
}
@@ -403,7 +402,7 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi)
break;
if (dc.type == DIRECTCONN_STANDARD && wLen && packetRecv.buffer[i + 2] == 2) {
- if (!DecryptDirectPacket(&dc, packetRecv.buffer + i + 3, (WORD)(wLen - 1))) {
+ if (!DecryptDirectPacket(&dc, packetRecv.buffer + i + 3, wLen - 1)) {
NetLog_Direct("Error: Corrupted packet encryption, ignoring packet");
i += wLen + 2;
continue;
@@ -417,7 +416,7 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi)
i += wLen + 2;
}
- packetRecv.bytesUsed = i;
+ packetRecv.bytesUsed = (int)i;
}
}
@@ -443,7 +442,7 @@ LBL_Exit:
directConns.remove(&dc);
}
-void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, WORD wLen)
+void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, size_t wLen)
{
if (wLen < 1)
return;
@@ -633,7 +632,7 @@ void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, WORD wLen)
NetLog_Direct("Received PEER_MSG from %u", dc->dwRemoteUin);
if (dc->initialised)
- handleDirectMessage(dc, buf + 1, (WORD)(wLen - 1));
+ handleDirectMessage(dc, buf+1, wLen-1);
else
NetLog_Direct("Received %s on uninitialised DC, ignoring.", "PEER_MSG");
@@ -758,7 +757,7 @@ void EncryptDirectPacket(directconnect* dc, icq_packet* p)
*(PDWORD)(buf + offset) = check;
}
-int DecryptDirectPacket(directconnect* dc, PBYTE buf, WORD wLen)
+int DecryptDirectPacket(directconnect* dc, PBYTE buf, size_t wLen)
{
unsigned long hex;
unsigned long B1;
@@ -768,7 +767,7 @@ int DecryptDirectPacket(directconnect* dc, PBYTE buf, WORD wLen)
unsigned char X2;
unsigned char X3;
unsigned char bak[6];
- unsigned long size = wLen;
+ unsigned long size = (unsigned long)wLen;
if (dc->wVersion < 4)
return 1; // no decryption necessary.
@@ -944,28 +943,21 @@ void CIcqProto::sendPeerMsgInit(directconnect* dc, DWORD dwSeq)
void CIcqProto::sendPeerFileInit(directconnect* dc)
{
- DBVARIANT dbv;
- char* szNick;
-
- dbv.type = DBVT_DELETED;
- if (getString("Nick", &dbv))
- szNick = "";
- else
- szNick = dbv.pszVal;
- int nNickLen = strlennull(szNick);
+ ptrA tmp(getStringA("Nick"));
+ char *szNick = NEWSTR_ALLOCA((tmp == NULL) ? "" : tmp);
+ size_t nNickLen = mir_strlen(szNick);
icq_packet packet;
- directPacketInit(&packet, (WORD)(20 + nNickLen));
+ directPacketInit(&packet, 20 + nNickLen);
packByte(&packet, PEER_FILE_INIT); /* packet type */
packLEDWord(&packet, 0); /* unknown */
packLEDWord(&packet, dc->ft->dwFileCount);
packLEDWord(&packet, dc->ft->dwTotalSize);
packLEDWord(&packet, dc->ft->dwTransferSpeed);
- packLEWord(&packet, (WORD)(nNickLen + 1));
- packBuffer(&packet, (LPBYTE)szNick, (WORD)(nNickLen + 1));
+ packLEWord(&packet, WORD(nNickLen + 1));
+ packBuffer(&packet, (LPBYTE)szNick, nNickLen + 1);
sendDirectPacket(dc, &packet);
- db_free(&dbv);
NetLog_Direct("Sent PEER_FILE_INIT to %u on %s DC", dc->dwRemoteUin, dc->incoming ? "incoming" : "outgoing");
}
diff --git a/protocols/IcqOscarJ/src/icq_direct.h b/protocols/IcqOscarJ/src/icq_direct.h
index 370bde19f3..7a412ced11 100644
--- a/protocols/IcqOscarJ/src/icq_direct.h
+++ b/protocols/IcqOscarJ/src/icq_direct.h
@@ -85,6 +85,6 @@ struct directconnect
DWORD dwReqId; // Reverse Connect request cookie
};
-int DecryptDirectPacket(directconnect* dc, PBYTE buf, WORD wLen);
+int DecryptDirectPacket(directconnect* dc, PBYTE buf, size_t wLen);
#endif /* __ICQ_DIRECT_H */
diff --git a/protocols/IcqOscarJ/src/icq_directmsg.cpp b/protocols/IcqOscarJ/src/icq_directmsg.cpp
index 8010f31870..26206cf6d3 100644
--- a/protocols/IcqOscarJ/src/icq_directmsg.cpp
+++ b/protocols/IcqOscarJ/src/icq_directmsg.cpp
@@ -25,7 +25,7 @@
#include "icqoscar.h"
-void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, WORD wLen)
+void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen)
{
WORD wCommand;
WORD wCookie;
@@ -198,20 +198,17 @@ void CIcqProto::handleDirectMessage(directconnect* dc, PBYTE buf, WORD wLen)
NetLog_Direct("Unknown wCommand, packet skipped");
}
-void CIcqProto::handleDirectGreetingMessage(directconnect* dc, PBYTE buf, WORD wLen, WORD wCommand, WORD wCookie, BYTE bMsgType, BYTE bMsgFlags, WORD wStatus, WORD wFlags, char* pszText)
+void CIcqProto::handleDirectGreetingMessage(directconnect* dc, PBYTE buf, size_t wLen, WORD wCommand, WORD wCookie, BYTE bMsgType, BYTE bMsgFlags, WORD wStatus, WORD wFlags, char* pszText)
{
- DWORD dwLengthToEnd;
- DWORD dwDataLength;
- char* pszFileName = NULL;
- int typeId;
- WORD qt;
-
NetLog_Direct("Handling PEER_MSG_GREETING, command %u, cookie %u, messagetype %u, messageflags %u, status %u, flags %u", wCommand, wCookie, bMsgType, bMsgFlags, wStatus, wFlags);
+ int typeId;
+ WORD qt;
if (!unpackPluginTypeId(&buf, &wLen, &typeId, &qt, TRUE))
return;
// Length of remaining data
+ size_t dwLengthToEnd;
unpackLEDWord(&buf, &dwLengthToEnd);
if (dwLengthToEnd < 4 || dwLengthToEnd > wLen) {
NetLog_Direct("Error: Sanity checking failed (%d) in handleDirectGreetingMessage, datalen %u wLen %u", 2, dwLengthToEnd, wLen);
@@ -219,6 +216,7 @@ void CIcqProto::handleDirectGreetingMessage(directconnect* dc, PBYTE buf, WORD w
}
// Length of message/reason
+ size_t dwDataLength;
unpackLEDWord(&buf, &dwDataLength);
wLen -= 4;
if (dwDataLength > wLen) {
@@ -229,18 +227,18 @@ void CIcqProto::handleDirectGreetingMessage(directconnect* dc, PBYTE buf, WORD w
if (typeId == MTYPE_FILEREQ && wCommand == DIRECT_MESSAGE) {
NetLog_Direct("This is file request");
char *szMsg = (char*)_alloca(dwDataLength + 1);
- unpackString(&buf, szMsg, (WORD)dwDataLength);
+ unpackString(&buf, szMsg, dwDataLength);
szMsg[dwDataLength] = '\0';
- wLen = wLen - (WORD)dwDataLength;
+ wLen -= dwDataLength;
handleFileRequest(buf, wLen, dc->dwRemoteUin, wCookie, 0, 0, szMsg, 8, TRUE);
}
else if (typeId == MTYPE_FILEREQ && wCommand == DIRECT_ACK) {
NetLog_Direct("This is file ack");
char *szMsg = (char*)_alloca(dwDataLength + 1);
- unpackString(&buf, szMsg, (WORD)dwDataLength);
+ unpackString(&buf, szMsg, dwDataLength);
szMsg[dwDataLength] = '\0';
- wLen = wLen - (WORD)dwDataLength;
+ wLen -= dwDataLength;
// 50 - file request granted/refused
handleFileAck(buf, wLen, dc->dwRemoteUin, wCookie, wStatus, szMsg);
@@ -253,17 +251,17 @@ void CIcqProto::handleDirectGreetingMessage(directconnect* dc, PBYTE buf, WORD w
pMsgAck.pDC = dc;
pMsgAck.wCookie = wCookie;
pMsgAck.msgType = typeId;
- handleMessageTypes(dc->dwRemoteUin, szUID, time(NULL), 0, 0, wCookie, dc->wVersion, typeId, 0, 0, dwLengthToEnd, (WORD)dwDataLength, (char*)buf, MTF_PLUGIN | MTF_DIRECT, &pMsgAck);
+ handleMessageTypes(dc->dwRemoteUin, szUID, time(NULL), 0, 0, wCookie, dc->wVersion, typeId, 0, 0, dwLengthToEnd, dwDataLength, (char*)buf, MTF_PLUGIN | MTF_DIRECT, &pMsgAck);
}
else if (typeId == MTYPE_STATUSMSGEXT && wCommand == DIRECT_ACK) { // especially for icq2003b
NetLog_Direct("This is extended status reply");
char *szMsg = (char*)_alloca(dwDataLength + 1);
- uid_str szUID;
- unpackString(&buf, szMsg, (WORD)dwDataLength);
+ unpackString(&buf, szMsg, dwDataLength);
szMsg[dwDataLength] = '\0';
- handleMessageTypes(dc->dwRemoteUin, szUID, time(NULL), 0, 0, wCookie, dc->wVersion, (int)(qt + 0xE7), 3, 2, (DWORD)wLen, (WORD)dwDataLength, szMsg, MTF_PLUGIN | MTF_DIRECT, NULL);
+ uid_str szUID;
+ handleMessageTypes(dc->dwRemoteUin, szUID, time(NULL), 0, 0, wCookie, dc->wVersion, (int)(qt + 0xE7), 3, 2, wLen, dwDataLength, szMsg, MTF_PLUGIN | MTF_DIRECT, NULL);
}
else if (typeId && wCommand == DIRECT_ACK) {
MCONTACT hCookieContact;
diff --git a/protocols/IcqOscarJ/src/icq_filerequests.cpp b/protocols/IcqOscarJ/src/icq_filerequests.cpp
index afb4d94bcc..86b48eeb27 100644
--- a/protocols/IcqOscarJ/src/icq_filerequests.cpp
+++ b/protocols/IcqOscarJ/src/icq_filerequests.cpp
@@ -25,13 +25,12 @@
#include "icqoscar.h"
-void CIcqProto::handleFileAck(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCookie, WORD wStatus, char* pszText)
+void CIcqProto::handleFileAck(PBYTE buf, size_t wLen, DWORD dwUin, DWORD dwCookie, WORD wStatus, char* pszText)
{
char* pszFileName = NULL;
DWORD dwFileSize;
MCONTACT hCookieContact;
WORD wPort;
- WORD wFilenameLength;
filetransfer* ft;
// Find the filetransfer that belongs to this response
@@ -72,6 +71,7 @@ void CIcqProto::handleFileAck(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCookie,
wLen -= 2;
// Filename
+ size_t wFilenameLength;
unpackLEWord(&buf, &wFilenameLength);
if (wFilenameLength > 0) {
if (wFilenameLength > wLen - 2)
@@ -111,10 +111,10 @@ filetransfer* CIcqProto::CreateFileTransfer(MCONTACT hContact, DWORD dwUin, int
// pszDescription points to a string with the reason
// buf points to the first data after the string
-void CIcqProto::handleFileRequest(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCookie, DWORD dwID1, DWORD dwID2, char* pszDescription, int nVersion, BOOL bDC)
+void CIcqProto::handleFileRequest(PBYTE buf, size_t wLen, DWORD dwUin, DWORD dwCookie, DWORD dwID1, DWORD dwID2, char* pszDescription, int nVersion, BOOL bDC)
{
BOOL bEmptyDesc = FALSE;
- if (strlennull(pszDescription) == 0) {
+ if (mir_strlen(pszDescription) == 0) {
pszDescription = Translate("No description given");
bEmptyDesc = TRUE;
}
@@ -173,7 +173,7 @@ void CIcqProto::handleFileRequest(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCoo
mir_free(ptszFileName);
}
-void CIcqProto::handleDirectCancel(directconnect *dc, PBYTE buf, WORD wLen, WORD wCommand, DWORD dwCookie, WORD wMessageType, WORD wStatus, WORD wFlags, char* pszText)
+void CIcqProto::handleDirectCancel(directconnect *dc, PBYTE buf, size_t wLen, WORD wCommand, DWORD dwCookie, WORD wMessageType, WORD wStatus, WORD wFlags, char* pszText)
{
NetLog_Direct("handleDirectCancel: Unhandled cancel");
}
diff --git a/protocols/IcqOscarJ/src/icq_filetransfer.cpp b/protocols/IcqOscarJ/src/icq_filetransfer.cpp
index b1cc948705..df3ffa8c20 100644
--- a/protocols/IcqOscarJ/src/icq_filetransfer.cpp
+++ b/protocols/IcqOscarJ/src/icq_filetransfer.cpp
@@ -50,7 +50,6 @@ static void file_buildProtoFileTransferStatus(filetransfer* ft, PROTOFILETRANSFE
static void file_sendTransferSpeed(CIcqProto* ppro, directconnect* dc)
{
icq_packet packet;
-
directPacketInit(&packet, 5);
packByte(&packet, PEER_FILE_SPEED); /* Ident */
packLEDWord(&packet, dc->ft->dwTransferSpeed);
@@ -60,31 +59,22 @@ static void file_sendTransferSpeed(CIcqProto* ppro, directconnect* dc)
static void file_sendNick(CIcqProto* ppro, directconnect* dc)
{
- icq_packet packet;
- char* szNick;
- WORD wNickLen;
- DBVARIANT dbv = { DBVT_DELETED };
-
- if (ppro->getString("Nick", &dbv))
- szNick = "";
- else
- szNick = dbv.pszVal;
+ ptrA tmp(ppro->getStringA("Nick"));
+ char *szNick = NEWSTR_ALLOCA((tmp == NULL) ? "" : tmp);
+ size_t nNickLen = mir_strlen(szNick);
- wNickLen = strlennull(szNick);
-
- directPacketInit(&packet, (WORD)(8 + wNickLen));
+ icq_packet packet;
+ directPacketInit(&packet, 8 + nNickLen);
packByte(&packet, PEER_FILE_INIT_ACK); /* Ident */
packLEDWord(&packet, dc->ft->dwTransferSpeed);
- packLEWord(&packet, (WORD)(wNickLen + 1));
- packBuffer(&packet, (LPBYTE)szNick, (WORD)(wNickLen + 1));
+ packLEWord(&packet, WORD(nNickLen + 1));
+ packBuffer(&packet, (LPBYTE)szNick, nNickLen + 1);
ppro->sendDirectPacket(dc, &packet);
- db_free(&dbv);
}
static void file_sendNextFile(CIcqProto* ppro, directconnect* dc)
{
- icq_packet packet;
struct _stati64 statbuf;
char szThisSubDir[MAX_PATH];
@@ -105,9 +95,8 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc)
char *pszThisFileName = FindFilePathContainer((LPCSTR*)dc->ft->pszFiles, dc->ft->iCurrentFile, szThisSubDir);
- if (statbuf.st_mode&_S_IFDIR) {
+ if (statbuf.st_mode & _S_IFDIR)
dc->ft->currentIsDir = 1;
- }
else {
dc->ft->currentIsDir = 0;
dc->ft->fileId = OpenFileUtf(dc->ft->szThisFile, _O_BINARY | _O_RDONLY, _S_IREAD);
@@ -117,8 +106,8 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc)
dc->ft->hConnection = NULL;
return;
}
-
}
+
dc->ft->dwThisFileSize = statbuf.st_size;
dc->ft->dwThisFileDate = statbuf.st_mtime;
dc->ft->dwFileBytesDone = 0;
@@ -128,16 +117,18 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc)
szThisFileNameAnsi = _strdup(pszThisFileName); // Legacy fix
if (!utf8_decode(szThisSubDir, &szThisSubDirAnsi))
szThisSubDirAnsi = _strdup(szThisSubDir); // Legacy fix
- WORD wThisFileNameLen = strlennull(szThisFileNameAnsi);
- WORD wThisSubDirLen = strlennull(szThisSubDirAnsi);
+
+ size_t wThisFileNameLen = mir_strlen(szThisFileNameAnsi);
+ size_t wThisSubDirLen = mir_strlen(szThisSubDirAnsi);
- directPacketInit(&packet, (WORD)(20 + wThisFileNameLen + wThisSubDirLen));
+ icq_packet packet;
+ directPacketInit(&packet, 20 + wThisFileNameLen + wThisSubDirLen);
packByte(&packet, PEER_FILE_NEXTFILE); /* Ident */
packByte(&packet, (BYTE)((statbuf.st_mode & _S_IFDIR) != 0)); // Is subdir
- packLEWord(&packet, (WORD)(wThisFileNameLen + 1));
- packBuffer(&packet, (LPBYTE)szThisFileNameAnsi, (WORD)(wThisFileNameLen + 1));
- packLEWord(&packet, (WORD)(wThisSubDirLen + 1));
- packBuffer(&packet, (LPBYTE)szThisSubDirAnsi, (WORD)(wThisSubDirLen + 1));
+ packLEWord(&packet, WORD(wThisFileNameLen + 1));
+ packBuffer(&packet, (LPBYTE)szThisFileNameAnsi, wThisFileNameLen + 1);
+ packLEWord(&packet, WORD(wThisSubDirLen + 1));
+ packBuffer(&packet, (LPBYTE)szThisSubDirAnsi, wThisSubDirLen + 1);
packLEDWord(&packet, dc->ft->dwThisFileSize);
packLEDWord(&packet, statbuf.st_mtime);
packLEDWord(&packet, dc->ft->dwTransferSpeed);
@@ -152,7 +143,6 @@ static void file_sendNextFile(CIcqProto* ppro, directconnect* dc)
static void file_sendResume(CIcqProto* ppro, directconnect* dc)
{
icq_packet packet;
-
directPacketInit(&packet, 17);
packByte(&packet, PEER_FILE_RESUME); /* Ident */
packLEDWord(&packet, dc->ft->dwFileBytesDone); /* file resume */
@@ -177,9 +167,9 @@ static void file_sendData(CIcqProto* ppro, directconnect* dc)
if (bytesRead == -1)
return;
- directPacketInit(&packet, (WORD)(1 + bytesRead));
+ directPacketInit(&packet, 1 + bytesRead);
packByte(&packet, PEER_FILE_DATA); /* Ident */
- packBuffer(&packet, buf, (WORD)bytesRead);
+ packBuffer(&packet, buf, bytesRead);
ppro->sendDirectPacket(dc, &packet);
}
@@ -217,7 +207,8 @@ void CIcqProto::icq_sendFileResume(filetransfer *ft, int action, const char *szF
return;
directconnect *dc = FindFileTransferDC(ft);
- if (!dc) return; // something is broken...
+ if (!dc)
+ return; // something is broken...
int openFlags;
@@ -267,9 +258,9 @@ void CIcqProto::icq_sendFileResume(filetransfer *ft, int action, const char *szF
// small utility function
void NormalizeBackslash(char* path)
{
- int len = strlennull(path);
-
- if (len && path[len - 1] != '\\') strcat(path, "\\");
+ size_t len = mir_strlen(path);
+ if (len && path[len-1] != '\\')
+ strcat(path, "\\");
}
/* a file transfer looks like this:
@@ -282,7 +273,7 @@ S: 6 * many
(for more files, send 2, 3, 6*many)
*/
-void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, WORD wLen)
+void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, size_t wLen)
{
if (wLen < 1)
return;
@@ -381,7 +372,7 @@ void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, WORD wLen
break;
}
- char *szFullPath = (char*)SAFE_MALLOC(strlennull(dc->ft->szSavePath) + strlennull(dc->ft->szThisSubdir) + strlennull(dc->ft->szThisFile) + 3);
+ char *szFullPath = (char*)SAFE_MALLOC(mir_strlen(dc->ft->szSavePath) + mir_strlen(dc->ft->szThisSubdir) + mir_strlen(dc->ft->szThisFile) + 3);
strcpy(szFullPath, dc->ft->szSavePath);
NormalizeBackslash(szFullPath);
strcat(szFullPath, dc->ft->szThisSubdir);
@@ -458,12 +449,12 @@ void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, WORD wLen
if (dc->ft->fileId == -1)
break;
buf++; wLen--;
- _write(dc->ft->fileId, buf, wLen);
+ _write(dc->ft->fileId, buf, (unsigned)wLen);
}
else
wLen = 0;
- dc->ft->dwBytesDone += wLen;
- dc->ft->dwFileBytesDone += wLen;
+ dc->ft->dwBytesDone += (DWORD)wLen;
+ dc->ft->dwFileBytesDone += (DWORD)wLen;
if (GetTickCount() > dc->ft->dwLastNotify + 500 || wLen < 2048) {
PROTOFILETRANSFERSTATUS pfts;
diff --git a/protocols/IcqOscarJ/src/icq_http.cpp b/protocols/IcqOscarJ/src/icq_http.cpp
index d5926b902a..1d0283456a 100644
--- a/protocols/IcqOscarJ/src/icq_http.cpp
+++ b/protocols/IcqOscarJ/src/icq_http.cpp
@@ -32,7 +32,7 @@
int icq_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr)
{
// initial response from ICQ http gateway
- WORD wLen, wVersion, wType;
+ size_t wLen, wVersion, wType;
WORD wIpLen;
DWORD dwSid1, dwSid2, dwSid3, dwSid4;
BYTE *buf;
@@ -86,12 +86,12 @@ int icq_httpGatewayBegin(HANDLE hConn, NETLIBOPENCONNECTION* nloc)
icq_packet packet;
size_t serverNameLen;
- serverNameLen = strlennull(nloc->szHost);
+ serverNameLen = mir_strlen(nloc->szHost);
packet.wLen = (WORD)(serverNameLen + 4);
write_httphdr(&packet, HTTP_PACKETTYPE_LOGIN, GetGatewayIndex(hConn));
packWord(&packet, (WORD)serverNameLen);
- packBuffer(&packet, (LPBYTE)nloc->szHost, (WORD)serverNameLen);
+ packBuffer(&packet, (LPBYTE)nloc->szHost, serverNameLen);
packWord(&packet, nloc->wPort);
INT_PTR res = Netlib_Send(hConn, (char*)packet.pData, packet.wLen, MSG_DUMPPROXY|MSG_NOHTTPGATEWAYWRAP);
SAFE_FREE((void**)&packet.pData);
@@ -117,7 +117,7 @@ int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDA
// send wrapped data
packet.wLen = curLen;
write_httphdr(&packet, HTTP_PACKETTYPE_FLAP, GetGatewayIndex(hConn));
- packBuffer(&packet, sendBuf, (WORD)curLen);
+ packBuffer(&packet, sendBuf, curLen);
NETLIBBUFFER nlb={ (char*)packet.pData, packet.wLen, flags };
curResult = pfnNetlibSend((WPARAM)hConn, (LPARAM)&nlb);
@@ -141,14 +141,13 @@ int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDA
PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST* nlhr, PBYTE buf, int len, int* outBufLen, void *(*NetlibRealloc)(void *, size_t))
{
- WORD wLen, wType;
+ size_t wLen, wType;
DWORD dwPackSeq;
PBYTE tbuf;
- int i, copyBytes;
-
+ size_t i = 0;
tbuf = buf;
- for(i = 0;;)
+ for(;;)
{
if (tbuf - buf + 2 > len)
break;
@@ -163,7 +162,7 @@ PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST* nlhr, PBYTE buf, int len, int
unpackDWord(&tbuf, &dwPackSeq);
if (wType == HTTP_PACKETTYPE_FLAP)
{ // it is normal data packet
- copyBytes = wLen - 12;
+ size_t copyBytes = wLen - 12;
if (copyBytes > len - i)
{
/* invalid data - do our best to get something out of it */
@@ -189,7 +188,7 @@ PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST* nlhr, PBYTE buf, int len, int
}
tbuf += wLen - 12;
}
- *outBufLen = i;
+ *outBufLen = (int)i;
return buf;
}
diff --git a/protocols/IcqOscarJ/src/icq_infoupdate.cpp b/protocols/IcqOscarJ/src/icq_infoupdate.cpp
index 7d1bfba072..be305be872 100644
--- a/protocols/IcqOscarJ/src/icq_infoupdate.cpp
+++ b/protocols/IcqOscarJ/src/icq_infoupdate.cpp
@@ -262,7 +262,7 @@ void __cdecl CIcqProto::InfoUpdateThread( void* )
userinfo *hContactList[LISTSIZE];
int nListIndex = 0;
BYTE *pRequestData = NULL;
- int nRequestSize = 0;
+ size_t nRequestSize = 0;
infoUpdateMutex->Enter();
for (i = 0; i < LISTSIZE; i++) {
@@ -271,7 +271,7 @@ void __cdecl CIcqProto::InfoUpdateThread( void* )
if (IsMetaInfoChanged(m_infoUpdateList[i].hContact)) {
if (m_infoUpdateList[i].queued + 5 < now) {
BYTE *pItem = NULL;
- int nItemSize = 0;
+ size_t nItemSize = 0;
DBVARIANT dbv = { DBVT_DELETED };
if (!getSetting(m_infoUpdateList[i].hContact, DBSETTING_METAINFO_TOKEN, &dbv)) { // retrieve user details using privacy token
diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp
index be0a3b5ed5..d3466c6770 100644
--- a/protocols/IcqOscarJ/src/icq_opts.cpp
+++ b/protocols/IcqOscarJ/src/icq_opts.cpp
@@ -147,7 +147,7 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, NULL, FALSE));
GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(ppro->m_szPassword));
- if (strlennull(str)) {
+ if (mir_strlen(str)) {
strcpy(ppro->m_szPassword, str);
ppro->m_bRememberPwd = true;
}
@@ -259,13 +259,13 @@ static INT_PTR CALLBACK DlgProcIcqPrivacyOpts(HWND hwndDlg, UINT msg, WPARAM wPa
if (ppro->icqOnline()) {
PBYTE buf = NULL;
- int buflen = 0;
+ size_t buflen = 0;
ppackTLVWord(&buf, &buflen, 0x19A, !ppro->getByte("Auth", 1));
ppackTLVByte(&buf, &buflen, 0x212, ppro->getByte("WebAware", 0));
ppackTLVWord(&buf, &buflen, 0x1F9, ppro->getByte("PrivacyLevel", 1));
- ppro->icq_changeUserDirectoryInfoServ(buf, (WORD)buflen, DIRECTORYREQUEST_UPDATEPRIVACY);
+ ppro->icq_changeUserDirectoryInfoServ(buf, buflen, DIRECTORYREQUEST_UPDATEPRIVACY);
SAFE_FREE((void**)&buf);
diff --git a/protocols/IcqOscarJ/src/icq_packet.cpp b/protocols/IcqOscarJ/src/icq_packet.cpp
index 70852bb534..0211b9528a 100644
--- a/protocols/IcqOscarJ/src/icq_packet.cpp
+++ b/protocols/IcqOscarJ/src/icq_packet.cpp
@@ -64,22 +64,22 @@ void __fastcall write_flap(icq_packet *pPacket, BYTE byFlapChannel)
packWord(pPacket, (WORD)(pPacket->wLen - 6)); // This counter should not include the flap header (thus the -6)
}
-void __fastcall serverPacketInit(icq_packet *pPacket, WORD wSize)
+void __fastcall serverPacketInit(icq_packet *pPacket, size_t wSize)
{
- pPacket->wLen = wSize;
+ pPacket->wLen = (WORD)wSize;
write_flap(pPacket, ICQ_DATA_CHAN);
}
-void __fastcall directPacketInit(icq_packet *pPacket, DWORD dwSize)
+void __fastcall directPacketInit(icq_packet *pPacket, size_t dwSize)
{
pPacket->wPlace = 0;
- pPacket->wLen = (WORD)dwSize;
- pPacket->pData = (BYTE *)SAFE_MALLOC(dwSize + 2);
+ pPacket->wLen = (WORD)dwSize;
+ pPacket->pData = (BYTE *)SAFE_MALLOC(dwSize + 2);
packLEWord(pPacket, pPacket->wLen);
}
-void __fastcall serverCookieInit(icq_packet *pPacket, BYTE *pCookie, WORD wCookieSize)
+void __fastcall serverCookieInit(icq_packet *pPacket, BYTE *pCookie, size_t wCookieSize)
{
pPacket->wLen = (WORD)(wCookieSize + 8 + sizeof(CLIENT_ID_STRING) + 66);
@@ -88,7 +88,7 @@ void __fastcall serverCookieInit(icq_packet *pPacket, BYTE *pCookie, WORD wCooki
packTLV(pPacket, 0x06, wCookieSize, pCookie);
// Pack client identification details.
- packTLV(pPacket, 0x0003, (WORD)sizeof(CLIENT_ID_STRING)-1, (LPBYTE)CLIENT_ID_STRING);
+ packTLV(pPacket, 0x0003, (WORD)sizeof(CLIENT_ID_STRING) - 1, (LPBYTE)CLIENT_ID_STRING);
packTLVWord(pPacket, 0x0017, CLIENT_VERSION_MAJOR);
packTLVWord(pPacket, 0x0018, CLIENT_VERSION_MINOR);
packTLVWord(pPacket, 0x0019, CLIENT_VERSION_LESSER);
@@ -118,7 +118,7 @@ void __fastcall packDWord(icq_packet *pPacket, DWORD dwValue)
pPacket->pData[pPacket->wPlace++] = (BYTE)((dwValue & 0xff000000) >> 24);
pPacket->pData[pPacket->wPlace++] = (BYTE)((dwValue & 0x00ff0000) >> 16);
pPacket->pData[pPacket->wPlace++] = (BYTE)((dwValue & 0x0000ff00) >> 8);
- pPacket->pData[pPacket->wPlace++] = (BYTE) (dwValue & 0x000000ff);
+ pPacket->pData[pPacket->wPlace++] = (BYTE)(dwValue & 0x000000ff);
}
void __fastcall packQWord(icq_packet *pPacket, DWORD64 qwValue)
@@ -127,10 +127,10 @@ void __fastcall packQWord(icq_packet *pPacket, DWORD64 qwValue)
packDWord(pPacket, (DWORD)(qwValue & 0xffffffff));
}
-void packTLV(icq_packet *pPacket, WORD wType, WORD wLength, const BYTE *pbyValue)
+void packTLV(icq_packet *pPacket, WORD wType, size_t wLength, const BYTE *pbyValue)
{
packWord(pPacket, wType);
- packWord(pPacket, wLength);
+ packWord(pPacket, (WORD)wLength);
packBuffer(pPacket, pbyValue, wLength);
}
@@ -151,57 +151,45 @@ void packTLVDWord(icq_packet *pPacket, WORD wType, DWORD dwValue)
void packTLVUID(icq_packet *pPacket, WORD wType, DWORD dwUin, const char *szUid)
{
- if (dwUin)
- {
- char szUin[UINMAXLEN];
+ if (dwUin) {
+ char szUin[UINMAXLEN];
- _ltoa(dwUin, szUin, 10);
+ _ltoa(dwUin, szUin, 10);
- packTLV(pPacket, wType, getUINLen(dwUin), (BYTE*)szUin);
- }
- else if (szUid)
- packTLV(pPacket, wType, strlennull(szUid), (BYTE*)szUid);
+ packTLV(pPacket, wType, getUINLen(dwUin), (BYTE*)szUin);
+ }
+ else if (szUid)
+ packTLV(pPacket, wType, mir_strlen(szUid), (BYTE*)szUid);
}
// Pack a preformatted buffer.
// This can be used to pack strings or any type of raw data.
-void packBuffer(icq_packet *pPacket, const BYTE* pbyBuffer, WORD wLength)
+void packBuffer(icq_packet *pPacket, const BYTE* pbyBuffer, size_t wLength)
{
- while (wLength)
- {
+ while (wLength) {
pPacket->pData[pPacket->wPlace++] = *pbyBuffer++;
wLength--;
}
}
-// Pack a buffer and prepend it with the size as a LE WORD.
-// Commented out since its not actually used anywhere right now.
-//void packLEWordSizedBuffer(icq_packet* pPacket, const BYTE* pbyBuffer, WORD wLength)
-//{
-//
-// packLEWord(pPacket, wLength);
-// packBuffer(pPacket, pbyBuffer, wLength);
-//
-//}
-
int __fastcall getUINLen(DWORD dwUin)
{
- BYTE dwUinLen = 0;
+ BYTE dwUinLen = 0;
- while(dwUin) {
- dwUin /= 10;
- dwUinLen += 1;
- }
- return dwUinLen;
+ while (dwUin) {
+ dwUin /= 10;
+ dwUinLen += 1;
+ }
+ return dwUinLen;
}
int __fastcall getUIDLen(DWORD dwUin, const char *szUid)
{
if (dwUin)
return getUINLen(dwUin);
- else
- return strlennull(szUid);
+
+ return (int)mir_strlen(szUid);
}
void __fastcall packUIN(icq_packet *pPacket, DWORD dwUin)
@@ -219,9 +207,8 @@ void __fastcall packUID(icq_packet *pPacket, DWORD dwUin, const char *szUid)
{
if (dwUin)
packUIN(pPacket, dwUin);
- else
- {
- BYTE nLen = strlennull(szUid);
+ else {
+ BYTE nLen = (BYTE)mir_strlen(szUid);
packByte(pPacket, nLen);
packBuffer(pPacket, (LPBYTE)szUid, nLen);
}
@@ -230,7 +217,7 @@ void __fastcall packUID(icq_packet *pPacket, DWORD dwUin, const char *szUid)
void packFNACHeader(icq_packet *pPacket, WORD wFamily, WORD wSubtype)
{
- packFNACHeader(pPacket, wFamily, wSubtype, 0, wSubtype << 0x10);
+ packFNACHeader(pPacket, wFamily, wSubtype, 0, wSubtype << 0x10);
}
@@ -248,21 +235,21 @@ void packFNACHeader(icq_packet *pPacket, WORD wFamily, WORD wSubtype, WORD wFlag
void packFNACHeader(icq_packet *pPacket, WORD wFamily, WORD wSubtype, WORD wFlags, DWORD dwSequence, WORD wVersion)
{
- packFNACHeader(pPacket, wFamily, wSubtype, wFlags | 0x8000, dwSequence);
- packWord(pPacket, 0x06);
- packTLVWord(pPacket, 0x01, wVersion);
+ packFNACHeader(pPacket, wFamily, wSubtype, wFlags | 0x8000, dwSequence);
+ packWord(pPacket, 0x06);
+ packTLVWord(pPacket, 0x01, wVersion);
}
void __fastcall packLEWord(icq_packet *pPacket, WORD wValue)
{
- pPacket->pData[pPacket->wPlace++] = (wValue & 0x00ff);
+ pPacket->pData[pPacket->wPlace++] = (wValue & 0x00ff);
pPacket->pData[pPacket->wPlace++] = ((wValue & 0xff00) >> 8);
}
void __fastcall packLEDWord(icq_packet *pPacket, DWORD dwValue)
{
- pPacket->pData[pPacket->wPlace++] = (BYTE) (dwValue & 0x000000ff);
+ pPacket->pData[pPacket->wPlace++] = (BYTE)(dwValue & 0x000000ff);
pPacket->pData[pPacket->wPlace++] = (BYTE)((dwValue & 0x0000ff00) >> 8);
pPacket->pData[pPacket->wPlace++] = (BYTE)((dwValue & 0x00ff0000) >> 16);
pPacket->pData[pPacket->wPlace++] = (BYTE)((dwValue & 0xff000000) >> 24);
@@ -272,17 +259,17 @@ void __fastcall packLEDWord(icq_packet *pPacket, DWORD dwValue)
/* helper function to place numerics to buffer */
static void packWord(PBYTE buf, WORD wValue)
{
- *(buf) = ((wValue & 0xff00) >> 8);
- *(buf + 1) = (wValue & 0x00ff);
+ *(buf) = ((wValue & 0xff00) >> 8);
+ *(buf + 1) = (wValue & 0x00ff);
}
static void packDWord(PBYTE buf, DWORD dwValue)
{
- *(buf) = (BYTE)((dwValue & 0xff000000) >> 24);
- *(buf + 1) = (BYTE)((dwValue & 0x00ff0000) >> 16);
- *(buf + 2) = (BYTE)((dwValue & 0x0000ff00) >> 8);
- *(buf + 3) = (BYTE) (dwValue & 0x000000ff);
+ *(buf) = (BYTE)((dwValue & 0xff000000) >> 24);
+ *(buf + 1) = (BYTE)((dwValue & 0x00ff0000) >> 16);
+ *(buf + 2) = (BYTE)((dwValue & 0x0000ff00) >> 8);
+ *(buf + 3) = (BYTE)(dwValue & 0x000000ff);
}
@@ -293,7 +280,7 @@ static void packQWord(PBYTE buf, DWORD64 qwValue)
}
-void ppackByte(PBYTE *buf, int *buflen, BYTE byValue)
+void ppackByte(PBYTE *buf, size_t *buflen, BYTE byValue)
{
*buf = (PBYTE)SAFE_REALLOC(*buf, 1 + *buflen);
*(*buf + *buflen) = byValue;
@@ -301,23 +288,23 @@ void ppackByte(PBYTE *buf, int *buflen, BYTE byValue)
}
-void ppackWord(PBYTE *buf, int *buflen, WORD wValue)
+void ppackWord(PBYTE *buf, size_t *buflen, WORD wValue)
{
*buf = (PBYTE)SAFE_REALLOC(*buf, 2 + *buflen);
- packWord(*buf + *buflen, wValue);
+ packWord(*buf + *buflen, wValue);
*buflen += 2;
}
-void ppackLEWord(PBYTE *buf, int *buflen, WORD wValue)
+void ppackLEWord(PBYTE *buf, size_t *buflen, WORD wValue)
{
- *buf=(PBYTE)SAFE_REALLOC(*buf, 2 + *buflen);
+ *buf = (PBYTE)SAFE_REALLOC(*buf, 2 + *buflen);
*(PWORD)(*buf + *buflen) = wValue;
- *buflen+=2;
+ *buflen += 2;
}
-void ppackLEDWord(PBYTE *buf, int *buflen, DWORD dwValue)
+void ppackLEDWord(PBYTE *buf, size_t *buflen, DWORD dwValue)
{
*buf = (PBYTE)SAFE_REALLOC(*buf, 4 + *buflen);
*(PDWORD)(*buf + *buflen) = dwValue;
@@ -325,99 +312,97 @@ void ppackLEDWord(PBYTE *buf, int *buflen, DWORD dwValue)
}
-void ppackLELNTS(PBYTE *buf, int *buflen, const char *str)
+void ppackLELNTS(PBYTE *buf, size_t *buflen, const char *str)
{
- WORD len = strlennull(str);
- ppackLEWord(buf, buflen, len);
+ size_t len = mir_strlen(str);
+ ppackLEWord(buf, buflen, (WORD)len);
*buf = (PBYTE)SAFE_REALLOC(*buf, *buflen + len);
memcpy(*buf + *buflen, str, len);
- *buflen += len;
+ *buflen += (WORD)len;
}
-void ppackBuffer(PBYTE *buf, int *buflen, WORD wLength, const BYTE *pbyValue)
+void ppackBuffer(PBYTE *buf, size_t *buflen, size_t wLength, const BYTE *pbyValue)
{
- if (wLength)
- {
- *buf = (PBYTE)SAFE_REALLOC(*buf, wLength + *buflen);
- memcpy(*buf + *buflen, pbyValue, wLength);
- *buflen += wLength;
- }
+ if (wLength) {
+ *buf = (PBYTE)SAFE_REALLOC(*buf, wLength + *buflen);
+ memcpy(*buf + *buflen, pbyValue, wLength);
+ *buflen += wLength;
+ }
}
-void ppackTLV(PBYTE *buf, int *buflen, WORD wType, WORD wLength, const BYTE *pbyValue)
+void ppackTLV(PBYTE *buf, size_t *buflen, WORD wType, size_t wLength, const BYTE *pbyValue)
{
*buf = (PBYTE)SAFE_REALLOC(*buf, 4 + wLength + *buflen);
packWord(*buf + *buflen, wType);
- packWord(*buf + *buflen + 2, wLength);
- if (wLength)
- memcpy(*buf + *buflen + 4, pbyValue, wLength);
+ packWord(*buf + *buflen + 2, (WORD)wLength);
+ if (wLength)
+ memcpy(*buf + *buflen + 4, pbyValue, wLength);
*buflen += 4 + wLength;
}
-void ppackTLVByte(PBYTE *buf, int *buflen, WORD wType, BYTE byValue)
+void ppackTLVByte(PBYTE *buf, size_t *buflen, WORD wType, BYTE byValue)
{
*buf = (PBYTE)SAFE_REALLOC(*buf, 5 + *buflen);
packWord(*buf + *buflen, wType);
packWord(*buf + *buflen + 2, 1);
- *(*buf + *buflen + 4) = byValue;
+ *(*buf + *buflen + 4) = byValue;
*buflen += 5;
}
-void ppackTLVWord(PBYTE *buf, int *buflen, WORD wType, WORD wValue)
+void ppackTLVWord(PBYTE *buf, size_t *buflen, WORD wType, WORD wValue)
{
*buf = (PBYTE)SAFE_REALLOC(*buf, 6 + *buflen);
packWord(*buf + *buflen, wType);
packWord(*buf + *buflen + 2, 2);
- packWord(*buf + *buflen + 4, wValue);
+ packWord(*buf + *buflen + 4, wValue);
*buflen += 6;
}
-void ppackTLVDWord(PBYTE *buf, int *buflen, WORD wType, DWORD dwValue)
+void ppackTLVDWord(PBYTE *buf, size_t *buflen, WORD wType, DWORD dwValue)
{
*buf = (PBYTE)SAFE_REALLOC(*buf, 8 + *buflen);
packWord(*buf + *buflen, wType);
packWord(*buf + *buflen + 2, 4);
- packDWord(*buf + *buflen + 4, dwValue);
+ packDWord(*buf + *buflen + 4, dwValue);
*buflen += 8;
}
-void ppackTLVDouble(PBYTE *buf, int *buflen, WORD wType, double dValue)
+void ppackTLVDouble(PBYTE *buf, size_t *buflen, WORD wType, double dValue)
{
- DWORD64 qwValue;
+ DWORD64 qwValue;
- memcpy(&qwValue, &dValue, 8);
+ memcpy(&qwValue, &dValue, 8);
*buf = (PBYTE)SAFE_REALLOC(*buf, 12 + *buflen);
packWord(*buf + *buflen, wType);
packWord(*buf + *buflen + 2, 8);
- packQWord(*buf + *buflen + 4, qwValue);
+ packQWord(*buf + *buflen + 4, qwValue);
*buflen += 12;
}
-void ppackTLVUID(PBYTE *buf, int *buflen, WORD wType, DWORD dwUin, const char *szUid)
+void ppackTLVUID(PBYTE *buf, size_t *buflen, WORD wType, DWORD dwUin, const char *szUid)
{
- if (dwUin)
- {
- char szUin[UINMAXLEN];
+ if (dwUin) {
+ char szUin[UINMAXLEN];
- _ltoa(dwUin, szUin, 10);
+ _ltoa(dwUin, szUin, 10);
- ppackTLV(buf, buflen, wType, getUINLen(dwUin), (BYTE*)szUin);
- }
- else if (szUid)
- ppackTLV(buf, buflen, wType, strlennull(szUid), (BYTE*)szUid);
+ ppackTLV(buf, buflen, wType, getUINLen(dwUin), (BYTE*)szUin);
+ }
+ else if (szUid)
+ ppackTLV(buf, buflen, wType, mir_strlen(szUid), (BYTE*)szUid);
}
// *** TLV based (!!! WORDs and DWORDs are LE !!!)
-void ppackLETLVByte(PBYTE *buf, int *buflen, BYTE byValue, WORD wType, BYTE always)
+void ppackLETLVByte(PBYTE *buf, size_t *buflen, BYTE byValue, WORD wType, BYTE always)
{
if (!always && !byValue) return;
@@ -429,7 +414,7 @@ void ppackLETLVByte(PBYTE *buf, int *buflen, BYTE byValue, WORD wType, BYTE alwa
}
-void ppackLETLVWord(PBYTE *buf, int *buflen, WORD wValue, WORD wType, BYTE always)
+void ppackLETLVWord(PBYTE *buf, size_t *buflen, WORD wValue, WORD wType, BYTE always)
{
if (!always && !wValue) return;
@@ -441,7 +426,7 @@ void ppackLETLVWord(PBYTE *buf, int *buflen, WORD wValue, WORD wType, BYTE alway
}
-void ppackLETLVDWord(PBYTE *buf, int *buflen, DWORD dwValue, WORD wType, BYTE always)
+void ppackLETLVDWord(PBYTE *buf, size_t *buflen, DWORD dwValue, WORD wType, BYTE always)
{
if (!always && !dwValue) return;
@@ -453,21 +438,21 @@ void ppackLETLVDWord(PBYTE *buf, int *buflen, DWORD dwValue, WORD wType, BYTE al
}
-void packLETLVLNTS(PBYTE *buf, int *bufpos, const char *str, WORD wType)
+void packLETLVLNTS(PBYTE *buf, size_t *bufpos, const char *str, WORD wType)
{
- int len = strlennull(str) + 1;
+ size_t len = mir_strlen(str) + 1;
*(PWORD)(*buf + *bufpos) = wType;
- *(PWORD)(*buf + *bufpos + 2) = len + 2;
- *(PWORD)(*buf + *bufpos + 4) = len;
+ *(PWORD)(*buf + *bufpos + 2) = DWORD(len + 2);
+ *(PWORD)(*buf + *bufpos + 4) = DWORD(len);
memcpy(*buf + *bufpos + 6, str, len);
*bufpos += len + 6;
}
-void ppackLETLVLNTS(PBYTE *buf, int *buflen, const char *str, WORD wType, BYTE always)
+void ppackLETLVLNTS(PBYTE *buf, size_t *buflen, const char *str, WORD wType, BYTE always)
{
- int len = strlennull(str) + 1;
+ size_t len = mir_strlen(str) + 1;
if (!always && len < 2) return;
@@ -476,37 +461,37 @@ void ppackLETLVLNTS(PBYTE *buf, int *buflen, const char *str, WORD wType, BYTE a
}
-void ppackLETLVWordLNTS(PBYTE *buf, int *buflen, WORD w, const char *str, WORD wType, BYTE always)
+void ppackLETLVWordLNTS(PBYTE *buf, size_t *buflen, WORD w, const char *str, WORD wType, BYTE always)
{
- int len = strlennull(str) + 1;
+ size_t len = mir_strlen(str) + 1;
if (!always && len < 2 && !w) return;
*buf = (PBYTE)SAFE_REALLOC(*buf, 8 + *buflen + len);
*(PWORD)(*buf + *buflen) = wType;
- *(PWORD)(*buf + *buflen + 2) = len + 4;
+ *(PWORD)(*buf + *buflen + 2) = DWORD(len + 4);
*(PWORD)(*buf + *buflen + 4) = w;
- *(PWORD)(*buf + *buflen + 6) = len;
+ *(PWORD)(*buf + *buflen + 6) = DWORD(len);
memcpy(*buf + *buflen + 8, str, len);
*buflen += len + 8;
}
-void ppackLETLVLNTSByte(PBYTE *buf, int *buflen, const char *str, BYTE b, WORD wType)
+void ppackLETLVLNTSByte(PBYTE *buf, size_t *buflen, const char *str, BYTE b, WORD wType)
{
- int len = strlennull(str) + 1;
+ size_t len = mir_strlen(str) + 1;
*buf = (PBYTE)SAFE_REALLOC(*buf, 7 + *buflen + len);
*(PWORD)(*buf + *buflen) = wType;
- *(PWORD)(*buf + *buflen + 2) = len + 3;
- *(PWORD)(*buf + *buflen + 4) = len;
+ *(PWORD)(*buf + *buflen + 2) = DWORD(len + 3);
+ *(PWORD)(*buf + *buflen + 4) = DWORD(len);
memcpy(*buf + *buflen + 6, str, len);
*(*buf + *buflen + 6 + len) = b;
*buflen += len + 7;
}
-void CIcqProto::ppackLETLVLNTSfromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wType)
+void CIcqProto::ppackLETLVLNTSfromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wType)
{
char szTmp[1024];
char *str = "";
@@ -517,7 +502,7 @@ void CIcqProto::ppackLETLVLNTSfromDB(PBYTE *buf, int *buflen, const char *szSett
ppackLETLVLNTS(buf, buflen, str, wType, 1);
}
-void CIcqProto::ppackLETLVWordLNTSfromDB(PBYTE *buf, int *buflen, WORD w, const char *szSetting, WORD wType)
+void CIcqProto::ppackLETLVWordLNTSfromDB(PBYTE *buf, size_t *buflen, WORD w, const char *szSetting, WORD wType)
{
char szTmp[1024];
char *str = "";
@@ -528,7 +513,7 @@ void CIcqProto::ppackLETLVWordLNTSfromDB(PBYTE *buf, int *buflen, WORD w, const
ppackLETLVWordLNTS(buf, buflen, w, str, wType, 1);
}
-void CIcqProto::ppackLETLVLNTSBytefromDB(PBYTE *buf, int *buflen, const char *szSetting, BYTE b, WORD wType)
+void CIcqProto::ppackLETLVLNTSBytefromDB(PBYTE *buf, size_t *buflen, const char *szSetting, BYTE b, WORD wType)
{
char szTmp[1024];
char *str = "";
@@ -540,7 +525,7 @@ void CIcqProto::ppackLETLVLNTSBytefromDB(PBYTE *buf, int *buflen, const char *sz
}
-void CIcqProto::ppackTLVStringFromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wType)
+void CIcqProto::ppackTLVStringFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wType)
{
char szTmp[1024];
char *str = "";
@@ -548,123 +533,118 @@ void CIcqProto::ppackTLVStringFromDB(PBYTE *buf, int *buflen, const char *szSett
if (!getSettingStringStatic(NULL, szSetting, szTmp, sizeof(szTmp)))
str = szTmp;
- ppackTLV(buf, buflen, wType, strlennull(str), (PBYTE)str);
+ ppackTLV(buf, buflen, wType, mir_strlen(str), (PBYTE)str);
}
-void CIcqProto::ppackTLVStringUtfFromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wType)
+void CIcqProto::ppackTLVStringUtfFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wType)
{
char *str = getSettingStringUtf(NULL, szSetting, NULL);
- ppackTLV(buf, buflen, wType, strlennull(str), (PBYTE)str);
+ ppackTLV(buf, buflen, wType, mir_strlen(str), (PBYTE)str);
- SAFE_FREE((void**)&str);
+ SAFE_FREE((void**)&str);
}
-void CIcqProto::ppackTLVDateFromDB(PBYTE *buf, int *buflen, const char *szSettingYear, const char *szSettingMonth, const char *szSettingDay, WORD wType)
+void CIcqProto::ppackTLVDateFromDB(PBYTE *buf, size_t *buflen, const char *szSettingYear, const char *szSettingMonth, const char *szSettingDay, WORD wType)
{
- SYSTEMTIME sTime = {0};
- double time = 0;
+ SYSTEMTIME sTime = { 0 };
+ double time = 0;
- sTime.wYear = getWord(szSettingYear, 0);
- sTime.wMonth = getByte(szSettingMonth, 0);
- sTime.wDay = getByte(szSettingDay, 0);
- if (sTime.wYear || sTime.wMonth || sTime.wDay)
- {
- SystemTimeToVariantTime(&sTime, &time);
- time -= 2;
- }
+ sTime.wYear = getWord(szSettingYear, 0);
+ sTime.wMonth = getByte(szSettingMonth, 0);
+ sTime.wDay = getByte(szSettingDay, 0);
+ if (sTime.wYear || sTime.wMonth || sTime.wDay) {
+ SystemTimeToVariantTime(&sTime, &time);
+ time -= 2;
+ }
- ppackTLVDouble(buf, buflen, wType, time);
+ ppackTLVDouble(buf, buflen, wType, time);
}
-int CIcqProto::ppackTLVWordStringItemFromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID)
+int CIcqProto::ppackTLVWordStringItemFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID)
{
- char szTmp[1024];
- char *str = NULL;
+ char szTmp[1024];
+ char *str = NULL;
- if (!getSettingStringStatic(NULL, szSetting, szTmp, sizeof(szTmp)))
- str = szTmp;
+ if (!getSettingStringStatic(NULL, szSetting, szTmp, sizeof(szTmp)))
+ str = szTmp;
- if (str)
- {
- WORD wLen = strlennull(str);
+ if (str) {
+ size_t wLen = mir_strlen(str);
- ppackWord(buf, buflen, wLen + 0x0A);
- ppackTLVWord(buf, buflen, wTypeID, wID);
- ppackTLV(buf, buflen, wTypeData, wLen, (PBYTE)str);
+ ppackWord(buf, buflen, WORD(wLen + 0x0A));
+ ppackTLVWord(buf, buflen, wTypeID, wID);
+ ppackTLV(buf, buflen, wTypeData, wLen, (PBYTE)str);
- return 1; // Success
- }
+ return 1; // Success
+ }
- return 0; // No data
+ return 0; // No data
}
-int CIcqProto::ppackTLVWordStringUtfItemFromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID)
+int CIcqProto::ppackTLVWordStringUtfItemFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID)
{
- char *str = getSettingStringUtf(NULL, szSetting, NULL);
-
- if (str)
- {
- WORD wLen = strlennull(str);
-
- ppackWord(buf, buflen, wLen + 0x0A);
- ppackTLVWord(buf, buflen, wTypeID, wID);
- ppackTLV(buf, buflen, wTypeData, wLen, (PBYTE)str);
-
- SAFE_FREE(&str);
+ char *str = getSettingStringUtf(NULL, szSetting, NULL);
- return 1; // Success
- }
+ if (str) {
+ size_t wLen = mir_strlen(str);
- return 0; // No data
-}
+ ppackWord(buf, buflen, WORD(wLen + 0x0A));
+ ppackTLVWord(buf, buflen, wTypeID, wID);
+ ppackTLV(buf, buflen, wTypeData, wLen, (PBYTE)str);
+ SAFE_FREE(&str);
-void ppackTLVBlockItems(PBYTE *buf, int *buflen, WORD wType, int *nItems, PBYTE *pBlock, WORD *wLength, BOOL bSingleItem)
-{
- *buf = (PBYTE)SAFE_REALLOC(*buf, 8 + *buflen + *wLength);
- packWord(*buf + *buflen, wType);
- packWord(*buf + *buflen + 2, (bSingleItem ? 4 : 2) + *wLength);
- packWord(*buf + *buflen + 4, *nItems);
- if (bSingleItem)
- packWord(*buf + *buflen + 6, *wLength);
- if (*wLength)
- memcpy(*buf + *buflen + (bSingleItem ? 8 : 6), *pBlock, *wLength);
- *buflen += (bSingleItem ? 8 : 6) + *wLength;
+ return 1; // Success
+ }
- SAFE_FREE((void**)pBlock);
- *wLength = 0;
- *nItems = 0;
+ return 0; // No data
}
-void ppackTLVBlockItem(PBYTE *buf, int *buflen, WORD wType, PBYTE *pItem, WORD *wLength)
+void ppackTLVBlockItems(PBYTE *buf, size_t *buflen, WORD wType, int *nItems, PBYTE *pBlock, WORD *wLength, BOOL bSingleItem)
{
- if (wLength)
- {
- *buf = (PBYTE)SAFE_REALLOC(*buf, 8 + *buflen + *wLength);
- packWord(*buf + *buflen, wType);
- packWord(*buf + *buflen + 2, 4 + *wLength);
- packWord(*buf + *buflen + 4, 1);
- packWord(*buf + *buflen + 6, *wLength);
- memcpy(*buf + *buflen + 8, *pItem, *wLength);
- *buflen += 8 + *wLength;
- }
- else
- {
- *buf = (PBYTE)SAFE_REALLOC(*buf, 6 + *buflen);
- packWord(*buf + *buflen, wType);
- packWord(*buf + *buflen + 2, 0x02);
- packWord(*buf + *buflen + 4, 0);
- *buflen += 6;
- }
+ *buf = (PBYTE)SAFE_REALLOC(*buf, 8 + *buflen + *wLength);
+ packWord(*buf + *buflen, wType);
+ packWord(*buf + *buflen + 2, (bSingleItem ? 4 : 2) + *wLength);
+ packWord(*buf + *buflen + 4, *nItems);
+ if (bSingleItem)
+ packWord(*buf + *buflen + 6, *wLength);
+ if (*wLength)
+ memcpy(*buf + *buflen + (bSingleItem ? 8 : 6), *pBlock, *wLength);
+ *buflen += (bSingleItem ? 8 : 6) + *wLength;
+
+ SAFE_FREE((void**)pBlock);
+ *wLength = 0;
+ *nItems = 0;
+}
+
+
+void ppackTLVBlockItem(PBYTE *buf, size_t *buflen, WORD wType, PBYTE *pItem, WORD *wLength)
+{
+ if (wLength) {
+ *buf = (PBYTE)SAFE_REALLOC(*buf, 8 + *buflen + *wLength);
+ packWord(*buf + *buflen, wType);
+ packWord(*buf + *buflen + 2, 4 + *wLength);
+ packWord(*buf + *buflen + 4, 1);
+ packWord(*buf + *buflen + 6, *wLength);
+ memcpy(*buf + *buflen + 8, *pItem, *wLength);
+ *buflen += 8 + *wLength;
+ }
+ else {
+ *buf = (PBYTE)SAFE_REALLOC(*buf, 6 + *buflen);
+ packWord(*buf + *buflen, wType);
+ packWord(*buf + *buflen + 2, 0x02);
+ packWord(*buf + *buflen + 4, 0);
+ *buflen += 6;
+ }
- SAFE_FREE((void**)pItem);
- *wLength = 0;
+ SAFE_FREE((void**)pItem);
+ *wLength = 0;
}
@@ -680,40 +660,48 @@ void __fastcall unpackWord(BYTE **pSource, WORD *wDestination)
{
BYTE *tmp = *pSource;
- if (wDestination)
- {
- *wDestination = *tmp++ << 8;
+ if (wDestination) {
+ *wDestination = *tmp++ << 8;
*wDestination |= *tmp++;
*pSource = tmp;
}
- else
- *pSource += 2;
+ else *pSource += 2;
+}
+
+void __fastcall unpackWord(BYTE **pSource, size_t *wDestination)
+{
+ BYTE *tmp = *pSource;
+
+ if (wDestination) {
+ *wDestination = *tmp++ << 8;
+ *wDestination |= *tmp++;
+
+ *pSource = tmp;
+ }
+ else *pSource += 2;
}
void __fastcall unpackDWord(BYTE **pSource, DWORD *dwDestination)
{
BYTE *tmp = *pSource;
- if (dwDestination)
- {
- *dwDestination = *tmp++ << 24;
+ if (dwDestination) {
+ *dwDestination = *tmp++ << 24;
*dwDestination |= *tmp++ << 16;
*dwDestination |= *tmp++ << 8;
*dwDestination |= *tmp++;
*pSource = tmp;
}
- else
- *pSource += 4;
+ else *pSource += 4;
}
void __fastcall unpackQWord(BYTE **pSource, DWORD64 *qwDestination)
{
DWORD dwData;
- if (qwDestination)
- {
+ if (qwDestination) {
unpackDWord(pSource, &dwData);
*qwDestination = ((DWORD64)dwData) << 32;
unpackDWord(pSource, &dwData);
@@ -727,13 +715,24 @@ void __fastcall unpackLEWord(BYTE **buf, WORD *w)
{
BYTE *tmp = *buf;
- if (w)
- {
+ if (w) {
*w = (*tmp++);
*w |= ((*tmp++) << 8);
}
- else
- tmp += 2;
+ else tmp += 2;
+
+ *buf = tmp;
+}
+
+void __fastcall unpackLEWord(BYTE **buf, size_t *w)
+{
+ BYTE *tmp = *buf;
+
+ if (w) {
+ *w = (*tmp++);
+ *w |= ((*tmp++) << 8);
+ }
+ else tmp += 2;
*buf = tmp;
}
@@ -742,25 +741,37 @@ void __fastcall unpackLEDWord(BYTE **buf, DWORD *dw)
{
BYTE *tmp = *buf;
- if (dw)
- {
+ if (dw) {
*dw = (*tmp++);
*dw |= ((*tmp++) << 8);
*dw |= ((*tmp++) << 16);
*dw |= ((*tmp++) << 24);
}
- else
- tmp += 4;
+ else tmp += 4;
*buf = tmp;
}
-void unpackString(BYTE **buf, char *string, WORD len)
+void __fastcall unpackLEDWord(BYTE **buf, size_t *dw)
{
BYTE *tmp = *buf;
- if (string)
- {
+ if (dw) {
+ *dw = (*tmp++);
+ *dw |= ((*tmp++) << 8);
+ *dw |= ((*tmp++) << 16);
+ *dw |= ((*tmp++) << 24);
+ }
+ else tmp += 4;
+
+ *buf = tmp;
+}
+
+void unpackString(BYTE **buf, char *string, size_t len)
+{
+ BYTE *tmp = *buf;
+
+ if (string) {
while (len) /* Can have 0x00 so go by len */
{
*string++ = *tmp++;
@@ -773,12 +784,11 @@ void unpackString(BYTE **buf, char *string, WORD len)
*buf = tmp;
}
-void unpackWideString(BYTE **buf, WCHAR *string, WORD len)
+void unpackWideString(BYTE **buf, WCHAR *string, size_t len)
{
BYTE *tmp = *buf;
- while (len > 1)
- {
+ while (len > 1) {
*string = (*tmp++ << 8);
*string |= *tmp++;
@@ -789,20 +799,20 @@ void unpackWideString(BYTE **buf, WCHAR *string, WORD len)
// We have a stray byte at the end, this means that the buffer had an odd length
// which indicates an error.
_ASSERTE(len == 0);
- if (len != 0)
- {
+ if (len != 0) {
// We dont copy the last byte but we still need to increase the buffer pointer
// (we assume that 'len' was correct) since the calling function expects
// that it is increased 'len' bytes.
- *tmp += len;
+ *tmp += (BYTE)len;
}
*buf = tmp;
}
-void unpackTypedTLV(BYTE *buf, int buflen, WORD type, WORD *ttype, WORD *tlen, BYTE **ttlv)
+void unpackTypedTLV(BYTE *buf, size_t buflen, WORD type, WORD *ttype, size_t *tlen, BYTE **ttlv)
{
- WORD wType, wLen;
+ WORD wType;
+ size_t wLen;
NextTLV:
// Unpack type and length
@@ -810,8 +820,7 @@ NextTLV:
unpackWord(&buf, &wLen);
buflen -= 4;
- if (wType != type && buflen >= wLen + 4)
- { // Not the right TLV, try next
+ if (wType != type && buflen >= wLen + 4) { // Not the right TLV, try next
buflen -= wLen;
buf += wLen;
goto NextTLV;
@@ -820,10 +829,8 @@ NextTLV:
if (wLen > buflen) wLen = buflen;
// Make sure we have a good pointer
- if (ttlv)
- {
- if (wLen)
- { // Unpack and save value
+ if (ttlv) {
+ if (wLen) { // Unpack and save value
*ttlv = (BYTE*)SAFE_MALLOC(wLen + 1); // Add 1 for \0
unpackString(&buf, (char*)*ttlv, wLen);
*(*ttlv + wLen) = '\0';
@@ -840,42 +847,37 @@ NextTLV:
}
-BOOL CIcqProto::unpackUID(BYTE **ppBuf, WORD *pwLen, DWORD *pdwUIN, uid_str *ppszUID)
+BOOL CIcqProto::unpackUID(BYTE **ppBuf, size_t *pwLen, DWORD *pdwUIN, uid_str *ppszUID)
{
- BYTE nUIDLen;
-
// sanity check
if (!ppBuf || !pwLen || *pwLen < 1)
return FALSE;
// Sender UIN
+ BYTE nUIDLen;
unpackByte(ppBuf, &nUIDLen);
*pwLen -= 1;
if ((nUIDLen > *pwLen) || (nUIDLen == 0))
return FALSE;
- if (nUIDLen <= UINMAXLEN)
- { // it can be uin, check
- char szUIN[UINMAXLEN+1];
+ if (nUIDLen <= UINMAXLEN) { // it can be uin, check
+ char szUIN[UINMAXLEN + 1];
unpackString(ppBuf, szUIN, nUIDLen);
szUIN[nUIDLen] = '\0';
*pwLen -= nUIDLen;
- if (IsStringUIN(szUIN))
- {
+ if (IsStringUIN(szUIN)) {
*pdwUIN = atoi(szUIN);
return TRUE;
}
- else
- { // go back
+ else { // go back
*ppBuf -= nUIDLen;
*pwLen += nUIDLen;
}
}
- if (!m_bAimEnabled || !ppszUID || !(*ppszUID))
- { // skip the UID data
+ if (!m_bAimEnabled || !ppszUID || !(*ppszUID)) { // skip the UID data
*ppBuf += nUIDLen;
*pwLen -= nUIDLen;
diff --git a/protocols/IcqOscarJ/src/icq_packet.h b/protocols/IcqOscarJ/src/icq_packet.h
index fde2b8551a..90c8bcff30 100644
--- a/protocols/IcqOscarJ/src/icq_packet.h
+++ b/protocols/IcqOscarJ/src/icq_packet.h
@@ -47,22 +47,22 @@ WORD generate_flap_sequence();
void __fastcall init_generic_packet(icq_packet *pPacket, WORD wHeaderLen);
void write_httphdr(icq_packet *pPacket, WORD wType, DWORD dwSeq);
void __fastcall write_flap(icq_packet *pPacket, BYTE byFlapChannel);
-void __fastcall serverPacketInit(icq_packet *pPacket, WORD wSize);
-void __fastcall directPacketInit(icq_packet *pPacket, DWORD dwSize);
+void __fastcall serverPacketInit(icq_packet *pPacket, size_t cbSize);
+void __fastcall directPacketInit(icq_packet *pPacket, size_t cbSize);
-void __fastcall serverCookieInit(icq_packet *pPacket, BYTE *pCookie, WORD wCookieSize);
+void __fastcall serverCookieInit(icq_packet *pPacket, BYTE *pCookie, size_t wCookieSize);
void __fastcall packByte(icq_packet *pPacket, BYTE byValue);
void __fastcall packWord(icq_packet *pPacket, WORD wValue);
void __fastcall packDWord(icq_packet *pPacket, DWORD dwValue);
void __fastcall packQWord(icq_packet *pPacket, DWORD64 qwValue);
-void packTLV(icq_packet *pPacket, WORD wType, WORD wLength, const BYTE *pbyValue);
+void packTLV(icq_packet *pPacket, WORD wType, size_t wLength, const BYTE *pbyValue);
void packTLVWord(icq_packet *pPacket, WORD wType, WORD wData);
void packTLVDWord(icq_packet *pPacket, WORD wType, DWORD dwData);
void packTLVUID(icq_packet *pPacket, WORD wType, DWORD dwUin, const char *szUid);
-void packBuffer(icq_packet *pPacket, const BYTE *pbyBuffer, WORD wLength);
-//void packLEWordSizedBuffer(icq_packet* pPacket, const BYTE* pbyBuffer, WORD wLength);
+void packBuffer(icq_packet *pPacket, const BYTE *pbyBuffer, size_t wLength);
+
int __fastcall getUINLen(DWORD dwUin);
int __fastcall getUIDLen(DWORD dwUin, const char *szUid);
void __fastcall packUIN(icq_packet *pPacket, DWORD dwUin);
@@ -75,42 +75,46 @@ void packFNACHeader(icq_packet *pPacket, WORD wFamily, WORD wSubtype, WORD wFlag
void __fastcall packLEWord(icq_packet *pPacket, WORD wValue);
void __fastcall packLEDWord(icq_packet *pPacket, DWORD dwValue);
-void packLETLVLNTS(PBYTE *buf, int *bufpos, const char *str, WORD wType);
+void packLETLVLNTS(PBYTE *buf, size_t *bufpos, const char *str, WORD wType);
-void ppackByte(PBYTE *buf, int *buflen, BYTE byValue);
-void ppackWord(PBYTE *buf, int *buflen, WORD wValue);
-void ppackLEWord(PBYTE *buf, int *buflen, WORD wValue);
-void ppackLEDWord(PBYTE *buf, int *buflen, DWORD dwValue);
-void ppackLELNTS(PBYTE *buf, int *buflen, const char *str);
-void ppackBuffer(PBYTE *buf, int *buflen, WORD wLength, const BYTE *pbyValue);
+void ppackByte(PBYTE *buf, size_t *buflen, BYTE byValue);
+void ppackWord(PBYTE *buf, size_t *buflen, WORD wValue);
+void ppackLEWord(PBYTE *buf, size_t *buflen, WORD wValue);
+void ppackLEDWord(PBYTE *buf, size_t *buflen, DWORD dwValue);
+void ppackLELNTS(PBYTE *buf, size_t *buflen, const char *str);
+void ppackBuffer(PBYTE *buf, size_t *buflen, size_t wLength, const BYTE *pbyValue);
-void ppackTLV(PBYTE *buf, int *buflen, WORD wType, WORD wLength, const BYTE *pbyValue);
-void ppackTLVByte(PBYTE *buf, int *buflen, WORD wType, BYTE byValue);
-void ppackTLVWord(PBYTE *buf, int *buflen, WORD wType, WORD wValue);
-void ppackTLVDWord(PBYTE *buf, int *buflen, WORD wType, DWORD dwValue);
-void ppackTLVDouble(PBYTE *buf, int *buflen, WORD wType, double dValue);
-void ppackTLVUID(PBYTE *buf, int *buflen, WORD wType, DWORD dwUin, const char *szUid);
+void ppackTLV(PBYTE *buf, size_t *buflen, WORD wType, size_t wLength, const BYTE *pbyValue);
+void ppackTLVByte(PBYTE *buf, size_t *buflen, WORD wType, BYTE byValue);
+void ppackTLVWord(PBYTE *buf, size_t *buflen, WORD wType, WORD wValue);
+void ppackTLVDWord(PBYTE *buf, size_t *buflen, WORD wType, DWORD dwValue);
+void ppackTLVDouble(PBYTE *buf, size_t *buflen, WORD wType, double dValue);
+void ppackTLVUID(PBYTE *buf, size_t *buflen, WORD wType, DWORD dwUin, const char *szUid);
-void ppackLETLVByte(PBYTE *buf, int *buflen, BYTE byValue, WORD wType, BYTE always);
-void ppackLETLVWord(PBYTE *buf, int *buflen, WORD wValue, WORD wType, BYTE always);
-void ppackLETLVDWord(PBYTE *buf, int *buflen, DWORD dwValue, WORD wType, BYTE always);
-void ppackLETLVLNTS(PBYTE *buf, int *buflen, const char *str, WORD wType, BYTE always);
-void ppackLETLVWordLNTS(PBYTE *buf, int *buflen, WORD w, const char *str, WORD wType, BYTE always);
-void ppackLETLVLNTSByte(PBYTE *buf, int *buflen, const char *str, BYTE b, WORD wType);
+void ppackLETLVByte(PBYTE *buf, size_t *buflen, BYTE byValue, WORD wType, BYTE always);
+void ppackLETLVWord(PBYTE *buf, size_t *buflen, WORD wValue, WORD wType, BYTE always);
+void ppackLETLVDWord(PBYTE *buf, size_t *buflen, DWORD dwValue, WORD wType, BYTE always);
+void ppackLETLVLNTS(PBYTE *buf, size_t *buflen, const char *str, WORD wType, BYTE always);
+void ppackLETLVWordLNTS(PBYTE *buf, size_t *buflen, WORD w, const char *str, WORD wType, BYTE always);
+void ppackLETLVLNTSByte(PBYTE *buf, size_t *buflen, const char *str, BYTE b, WORD wType);
-void ppackTLVBlockItems(PBYTE *buf, int *buflen, WORD wType, int *nItems, PBYTE *pBlock, WORD *wLength, BOOL bSingleItem);
-void ppackTLVBlockItem(PBYTE *buf, int *buflen, WORD wType, PBYTE *pItem, WORD *wLength);
+void ppackTLVBlockItems(PBYTE *buf, size_t *buflen, WORD wType, int *nItems, PBYTE *pBlock, WORD *wLength, BOOL bSingleItem);
+void ppackTLVBlockItem(PBYTE *buf, size_t *buflen, WORD wType, PBYTE *pItem, WORD *wLength);
void __fastcall unpackByte(BYTE **pSource, BYTE *byDestination);
void __fastcall unpackWord(BYTE **pSource, WORD *wDestination);
+void __fastcall unpackWord(BYTE **pSource, size_t *wDestination);
void __fastcall unpackDWord(BYTE **pSource, DWORD *dwDestination);
void __fastcall unpackQWord(BYTE **pSource, DWORD64 *qwDestination);
-void unpackString(BYTE **buf, char *string, WORD len);
-void unpackWideString(BYTE **buf, WCHAR *string, WORD len);
-void unpackTypedTLV(BYTE *buf, int buflen, WORD type, WORD *ttype, WORD *tlen, BYTE **ttlv);
+void unpackString(BYTE **buf, char *string, size_t len);
+void unpackWideString(BYTE **buf, WCHAR *string, size_t len);
+void unpackTypedTLV(BYTE *buf, size_t buflen, WORD type, WORD *ttype, size_t *tlen, BYTE **ttlv);
BOOL unpackUID(BYTE **ppBuf, WORD *pwLen, DWORD *pdwUIN, uid_str *ppszUID);
void __fastcall unpackLEWord(BYTE **buf, WORD *w);
+void __fastcall unpackLEWord(BYTE **buf, size_t *w);
+
void __fastcall unpackLEDWord(BYTE **buf, DWORD *dw);
+void __fastcall unpackLEDWord(BYTE **buf, size_t *dw);
#endif /* __ICQ_PACKET_H */
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp
index c24ea8bfcf..2e4f3045de 100644
--- a/protocols/IcqOscarJ/src/icq_proto.cpp
+++ b/protocols/IcqOscarJ/src/icq_proto.cpp
@@ -366,7 +366,7 @@ MCONTACT __cdecl CIcqProto::AddToListByEvent(int flags, int iContact, HANDLE hDb
char *pbOffset = (char*)dbei.pBlob;
char *pbEnd = pbOffset + dbei.cbBlob;
for (int i = 0; i <= iContact; i++) {
- pbOffset += strlennull(pbOffset) + 1; // Nick
+ pbOffset += mir_strlen(pbOffset) + 1; // Nick
if (pbOffset >= pbEnd) break;
if (i == iContact) { // we found the contact, get uid
if (IsStringUIN((char*)pbOffset))
@@ -376,7 +376,7 @@ MCONTACT __cdecl CIcqProto::AddToListByEvent(int flags, int iContact, HANDLE hDb
strcpy(uid, (char*)pbOffset);
}
}
- pbOffset += strlennull(pbOffset) + 1; // Uin
+ pbOffset += mir_strlen(pbOffset) + 1; // Uin
if (pbOffset >= pbEnd) break;
}
}
@@ -395,7 +395,7 @@ MCONTACT __cdecl CIcqProto::AddToListByEvent(int flags, int iContact, HANDLE hDb
return AddToListByUIN(uin, flags); // Success
// add aim contact
- if (strlennull(uid))
+ if (mir_strlen(uid))
return AddToListByUID(uid, flags); // Success
return NULL; // Failure
@@ -768,7 +768,7 @@ void CIcqProto::CheekySearchThread(void*)
HANDLE __cdecl CIcqProto::SearchBasic(const PROTOCHAR *pszSearch)
{
- if (strlennull(pszSearch) == 0)
+ if (mir_wstrlen(pszSearch) == 0)
return 0;
char pszUIN[255];
@@ -776,7 +776,7 @@ HANDLE __cdecl CIcqProto::SearchBasic(const PROTOCHAR *pszSearch)
int i, j;
if (!m_bAimEnabled) {
- for (i = j = 0; (i < strlennull(pszSearch)) && (j < 255); i++) { // we take only numbers
+ for (i = j = 0; (i < mir_wstrlen(pszSearch)) && (j < 255); i++) { // we take only numbers
if ((pszSearch[i] >= 0x30) && (pszSearch[i] <= 0x39)) {
pszUIN[j] = pszSearch[i];
j++;
@@ -784,7 +784,7 @@ HANDLE __cdecl CIcqProto::SearchBasic(const PROTOCHAR *pszSearch)
}
}
else {
- for (i = j = 0; (i < strlennull(pszSearch)) && (j < 255); i++) { // we remove spaces and slashes
+ for (i = j = 0; (i < mir_wstrlen(pszSearch)) && (j < 255); i++) { // we remove spaces and slashes
if ((pszSearch[i] != 0x20) && (pszSearch[i] != '-')) {
if (pszSearch[i] >= 0x80) continue;
pszUIN[j] = pszSearch[i];
@@ -794,7 +794,7 @@ HANDLE __cdecl CIcqProto::SearchBasic(const PROTOCHAR *pszSearch)
}
pszUIN[j] = 0;
- if (strlennull(pszUIN)) {
+ if (mir_strlen(pszUIN)) {
DWORD dwUin;
if (IsStringUIN(pszUIN))
dwUin = atoi(pszUIN);
@@ -826,7 +826,7 @@ HANDLE __cdecl CIcqProto::SearchBasic(const PROTOCHAR *pszSearch)
HANDLE __cdecl CIcqProto::SearchByEmail(const PROTOCHAR *email)
{
- if (email && icqOnline() && strlennull(email) > 0) {
+ if (email && icqOnline() && mir_wstrlen(email) > 0) {
char *szEmail = tchar_to_ansi(email);
// Success
@@ -881,7 +881,7 @@ HWND __cdecl CIcqProto::CreateExtendedSearchUI(HWND parent)
HWND __cdecl CIcqProto::SearchAdvanced(HWND hwndDlg)
{
if (icqOnline() && IsWindow(hwndDlg)) {
- int nDataLen;
+ size_t nDataLen;
BYTE* bySearchData;
if (bySearchData = createAdvancedSearchStructure(hwndDlg, &nDataLen)) {
@@ -902,7 +902,7 @@ int __cdecl CIcqProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
{
ICQSEARCHRESULT **isrList = (ICQSEARCHRESULT**)pre->szMessage;
int i;
- DWORD cbBlob = 0;
+ size_t cbBlob = 0;
DWORD flags = 0;
if (pre->flags & PREF_UTF || pre->flags & PREF_UNICODE)
@@ -912,13 +912,13 @@ int __cdecl CIcqProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
if (pre->flags & PREF_UNICODE)
cbBlob += get_utf8_size((WCHAR*)isrList[i]->hdr.nick) + 2;
else
- cbBlob += strlennull((char*)isrList[i]->hdr.nick) + 2; // both trailing zeros
+ cbBlob += mir_strlen((char*)isrList[i]->hdr.nick) + 2; // both trailing zeros
if (isrList[i]->uin)
cbBlob += getUINLen(isrList[i]->uin);
else if (pre->flags & PREF_UNICODE)
- cbBlob += strlennull((WCHAR*)isrList[i]->hdr.id);
+ cbBlob += mir_wstrlen((WCHAR*)isrList[i]->hdr.id);
else
- cbBlob += strlennull((char*)isrList[i]->hdr.id);
+ cbBlob += mir_strlen((char*)isrList[i]->hdr.id);
}
PBYTE pBlob = (PBYTE)_alloca(cbBlob), pCurBlob;
for (i = 0, pCurBlob = pBlob; i < pre->lParam; i++) {
@@ -926,7 +926,7 @@ int __cdecl CIcqProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
make_utf8_string_static((WCHAR*)isrList[i]->hdr.nick, (char*)pCurBlob, cbBlob - (pCurBlob - pBlob));
else
strcpy((char*)pCurBlob, (char*)isrList[i]->hdr.nick);
- pCurBlob += strlennull((char*)pCurBlob) + 1;
+ pCurBlob += mir_strlen((char*)pCurBlob) + 1;
if (isrList[i]->uin) {
char szUin[UINMAXLEN];
_itoa(isrList[i]->uin, szUin, 10);
@@ -938,7 +938,7 @@ int __cdecl CIcqProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
else
strcpy((char*)pCurBlob, (char*)isrList[i]->hdr.id);
}
- pCurBlob += strlennull((char*)pCurBlob) + 1;
+ pCurBlob += mir_strlen((char*)pCurBlob) + 1;
}
ICQAddRecvEvent(hContact, EVENTTYPE_CONTACTS, pre, cbBlob, pBlob, flags);
@@ -960,15 +960,14 @@ int __cdecl CIcqProto::RecvFile(MCONTACT hContact, PROTORECVFILET* evt)
int __cdecl CIcqProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre)
{
- DWORD cbBlob;
DWORD flags = 0;
- cbBlob = strlennull(pre->szMessage) + 1;
+ size_t cbBlob = mir_strlen(pre->szMessage) + 1;
// process utf-8 encoded messages
- if ((pre->flags & PREF_UTF) && !IsUSASCII(pre->szMessage, strlennull(pre->szMessage)))
+ if ((pre->flags & PREF_UTF) && !IsUSASCII(pre->szMessage, mir_strlen(pre->szMessage)))
flags |= DBEF_UTF;
// process unicode ucs-2 messages
- if ((pre->flags & PREF_UNICODE) && !IsUnicodeAscii((WCHAR*)(pre->szMessage + cbBlob), strlennull((WCHAR*)(pre->szMessage + cbBlob))))
+ if ((pre->flags & PREF_UNICODE) && !IsUnicodeAscii((WCHAR*)(pre->szMessage + cbBlob), mir_wstrlen((WCHAR*)(pre->szMessage + cbBlob))))
cbBlob *= (sizeof(WCHAR)+1);
ICQAddRecvEvent(hContact, EVENTTYPE_MESSAGE, pre, cbBlob, (PBYTE)pre->szMessage, flags);
@@ -1018,7 +1017,6 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int flags, int nContacts,
// OK
else {
if (CheckContactCapabilities(hContact, CAPF_CONTACTS) && wRecipientStatus != ID_STATUS_OFFLINE) { // Use the new format if possible
- int nDataLen, nNamesLen;
struct icq_contactsend_s* contacts = NULL;
// Format the data part and the names part
@@ -1026,114 +1024,110 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int flags, int nContacts,
// we need to calculate the length of the packet.
contacts = (struct icq_contactsend_s*)_alloca(sizeof(struct icq_contactsend_s)*nContacts);
ZeroMemory(contacts, sizeof(struct icq_contactsend_s)*nContacts);
- {
- nDataLen = 0; nNamesLen = 0;
- for (i = 0; i < nContacts; i++) {
- uid_str szContactUid;
-
- if (!IsICQContact(hContactsList[i]))
- break; // Abort if a non icq contact is found
- if (getContactUid(hContactsList[i], &contacts[i].uin, &szContactUid))
- break; // Abort if invalid contact
- contacts[i].uid = contacts[i].uin ? NULL : null_strdup(szContactUid);
- contacts[i].szNick = NickFromHandleUtf(hContactsList[i]);
- nDataLen += getUIDLen(contacts[i].uin, contacts[i].uid) + 4;
- nNamesLen += strlennull(contacts[i].szNick) + 8;
- }
-
- if (i == nContacts) {
- debugLogA("Sending contacts to %s.", strUID(dwUin, szUid));
-
- // Do not calculate the exact size of the data packet - only the maximal size (easier)
- // Sumarize size of group information
- // - we do not utilize the full power of the protocol and send all contacts with group "General"
- // just like ICQ6 does
- nDataLen += 9;
- nNamesLen += 9;
-
- // Create data structures
- icq_packet mData, mNames;
- mData.wPlace = 0;
- mData.pData = (LPBYTE)SAFE_MALLOC(nDataLen);
- mData.wLen = nDataLen;
- mNames.wPlace = 0;
- mNames.pData = (LPBYTE)SAFE_MALLOC(nNamesLen);
-
- // pack Group Name
- packWord(&mData, 7);
- packBuffer(&mData, (LPBYTE)"General", 7);
- packWord(&mNames, 7);
- packBuffer(&mNames, (LPBYTE)"General", 7);
-
- // all contacts in one group
- packWord(&mData, (WORD)nContacts);
- packWord(&mNames, (WORD)nContacts);
- for (i = 0; i < nContacts; i++) {
- uid_str szContactUid;
- WORD wLen;
-
- if (contacts[i].uin)
- strUID(contacts[i].uin, szContactUid);
- else
- strcpy(szContactUid, contacts[i].uid);
-
- // prepare UID
- wLen = strlennull(szContactUid);
- packWord(&mData, wLen);
- packBuffer(&mData, (LPBYTE)szContactUid, wLen);
- // prepare Nick
- wLen = strlennull(contacts[i].szNick);
- packWord(&mNames, (WORD)(wLen + 4));
- packTLV(&mNames, 0x01, wLen, (LPBYTE)contacts[i].szNick);
- }
-
- // Cleanup temporary list
- for (i = 0; i < nContacts; i++) {
- SAFE_FREE(&contacts[i].szNick);
- SAFE_FREE(&contacts[i].uid);
- }
+ size_t nDataLen = 0, nNamesLen = 0;
+ for (i = 0; i < nContacts; i++) {
+ uid_str szContactUid;
+
+ if (!IsICQContact(hContactsList[i]))
+ break; // Abort if a non icq contact is found
+ if (getContactUid(hContactsList[i], &contacts[i].uin, &szContactUid))
+ break; // Abort if invalid contact
+ contacts[i].uid = contacts[i].uin ? NULL : null_strdup(szContactUid);
+ contacts[i].szNick = NickFromHandleUtf(hContactsList[i]);
+ nDataLen += getUIDLen(contacts[i].uin, contacts[i].uid) + 4;
+ nNamesLen += mir_strlen(contacts[i].szNick) + 8;
+ }
- // Rate check
- if (IsServerOverRate(ICQ_MSG_FAMILY, ICQ_MSG_SRV_SEND, RML_LIMIT)) { // rate is too high, the message will not go thru...
- SAFE_FREE((void**)&mData.pData);
- SAFE_FREE((void**)&mNames.pData);
+ if (i == nContacts) {
+ debugLogA("Sending contacts to %s.", strUID(dwUin, szUid));
+
+ // Do not calculate the exact size of the data packet - only the maximal size (easier)
+ // Sumarize size of group information
+ // - we do not utilize the full power of the protocol and send all contacts with group "General"
+ // just like ICQ6 does
+ nDataLen += 9;
+ nNamesLen += 9;
+
+ // Create data structures
+ icq_packet mData, mNames;
+ mData.wPlace = 0;
+ mData.pData = (LPBYTE)SAFE_MALLOC(nDataLen);
+ mData.wLen = WORD(nDataLen);
+ mNames.wPlace = 0;
+ mNames.pData = (LPBYTE)SAFE_MALLOC(nNamesLen);
+
+ // pack Group Name
+ packWord(&mData, 7);
+ packBuffer(&mData, (LPBYTE)"General", 7);
+ packWord(&mNames, 7);
+ packBuffer(&mNames, (LPBYTE)"General", 7);
+
+ // all contacts in one group
+ packWord(&mData, WORD(nContacts));
+ packWord(&mNames, WORD(nContacts));
+ for (i = 0; i < nContacts; i++) {
+ uid_str szContactUid;
+ if (contacts[i].uin)
+ strUID(contacts[i].uin, szContactUid);
+ else
+ strcpy(szContactUid, contacts[i].uid);
- return ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "The message could not be delivered. You are sending too fast. Wait a while and try again.");
- }
+ // prepare UID
+ size_t wLen = mir_strlen(szContactUid);
+ packWord(&mData, WORD(wLen));
+ packBuffer(&mData, (LPBYTE)szContactUid, wLen);
- // Set up the ack type
- cookie_message_data *pCookieData = CreateMessageCookieData(MTYPE_CONTACTS, hContact, dwUin, FALSE);
+ // prepare Nick
+ wLen = mir_strlen(contacts[i].szNick);
+ packWord(&mNames, WORD(wLen + 4));
+ packTLV(&mNames, 0x01, wLen, (LPBYTE)contacts[i].szNick);
+ }
- // AIM clients do not send acknowledgement
- if (!dwUin && pCookieData->nAckType == ACKTYPE_CLIENT)
- pCookieData->nAckType = ACKTYPE_SERVER;
- // Send the message
- dwCookie = icq_SendChannel2Contacts(dwUin, szUid, hContact, (char*)mData.pData, mData.wPlace, (char*)mNames.pData, mNames.wPlace, pCookieData);
+ // Cleanup temporary list
+ for (i = 0; i < nContacts; i++) {
+ SAFE_FREE(&contacts[i].szNick);
+ SAFE_FREE(&contacts[i].uid);
+ }
- // This will stop the message dialog from waiting for the real message delivery ack
- if (pCookieData->nAckType == ACKTYPE_NONE) {
- SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_CONTACTS, NULL);
- // We need to free this here since we will never see the real ack
- // The actual cookie value will still have to be returned to the message dialog though
- ReleaseCookie(dwCookie);
- }
- // Release our buffers
+ // Rate check
+ if (IsServerOverRate(ICQ_MSG_FAMILY, ICQ_MSG_SRV_SEND, RML_LIMIT)) { // rate is too high, the message will not go thru...
SAFE_FREE((void**)&mData.pData);
SAFE_FREE((void**)&mNames.pData);
- }
- else {
- dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "Bad data (internal error #2)");
+
+ return ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "The message could not be delivered. You are sending too fast. Wait a while and try again.");
}
- for (i = 0; i < nContacts; i++) {
- SAFE_FREE(&contacts[i].szNick);
- SAFE_FREE(&contacts[i].uid);
+ // Set up the ack type
+ cookie_message_data *pCookieData = CreateMessageCookieData(MTYPE_CONTACTS, hContact, dwUin, FALSE);
+
+ // AIM clients do not send acknowledgement
+ if (!dwUin && pCookieData->nAckType == ACKTYPE_CLIENT)
+ pCookieData->nAckType = ACKTYPE_SERVER;
+ // Send the message
+ dwCookie = icq_SendChannel2Contacts(dwUin, szUid, hContact, (char*)mData.pData, mData.wPlace, (char*)mNames.pData, mNames.wPlace, pCookieData);
+
+ // This will stop the message dialog from waiting for the real message delivery ack
+ if (pCookieData->nAckType == ACKTYPE_NONE) {
+ SendProtoAck(hContact, dwCookie, ACKRESULT_SUCCESS, ACKTYPE_CONTACTS, NULL);
+ // We need to free this here since we will never see the real ack
+ // The actual cookie value will still have to be returned to the message dialog though
+ ReleaseCookie(dwCookie);
}
+ // Release our buffers
+ SAFE_FREE((void**)&mData.pData);
+ SAFE_FREE((void**)&mNames.pData);
+ }
+ else {
+ dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "Bad data (internal error #2)");
+ }
+
+ for (i = 0; i < nContacts; i++) {
+ SAFE_FREE(&contacts[i].szNick);
+ SAFE_FREE(&contacts[i].uid);
}
}
else if (dwUin) { // old format is only understood by ICQ clients
- int nBodyLength;
char szContactUin[UINMAXLEN];
char szCount[17];
struct icq_contactsend_s* contacts = NULL;
@@ -1146,7 +1140,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int flags, int nContacts,
contacts = (struct icq_contactsend_s*)_alloca(sizeof(struct icq_contactsend_s)*nContacts);
ZeroMemory(contacts, sizeof(struct icq_contactsend_s)*nContacts);
{
- nBodyLength = 0;
+ size_t nBodyLength = 0;
for (i = 0; i < nContacts; i++) {
if (!IsICQContact(hContactsList[i]))
break; // Abort if a non icq contact is found
@@ -1156,7 +1150,7 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int flags, int nContacts,
contacts[i].szNick = NickFromHandle(hContactsList[i]);
// Compute this contact's length
nBodyLength += getUIDLen(contacts[i].uin, contacts[i].uid) + 1;
- nBodyLength += strlennull(contacts[i].szNick) + 1;
+ nBodyLength += mir_strlen(contacts[i].szNick) + 1;
}
if (i == nContacts) {
@@ -1164,12 +1158,12 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int flags, int nContacts,
// Compute count record's length
_itoa(nContacts, szCount, 10);
- nBodyLength += strlennull(szCount) + 1;
+ nBodyLength += mir_strlen(szCount) + 1;
// Finally we need to copy the contact data into the packet body
char *pBody, *pBuffer = pBody = (char *)SAFE_MALLOC(nBodyLength);
null_strcpy(pBuffer, szCount, nBodyLength - 1);
- pBuffer += strlennull(pBuffer);
+ pBuffer += mir_strlen(pBuffer);
*pBuffer++ = (char)0xFE;
for (i = 0; i < nContacts; i++) {
if (contacts[i].uin) {
@@ -1178,10 +1172,10 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int flags, int nContacts,
}
else
strcpy(pBuffer, contacts[i].uid);
- pBuffer += strlennull(pBuffer);
+ pBuffer += mir_strlen(pBuffer);
*pBuffer++ = (char)0xFE;
strcpy(pBuffer, contacts[i].szNick);
- pBuffer += strlennull(pBuffer);
+ pBuffer += mir_strlen(pBuffer);
*pBuffer++ = (char)0xFE;
}
@@ -1210,24 +1204,15 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int flags, int nContacts,
return ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "The message could not be delivered. You are sending too fast. Wait a while and try again.");
}
+
// Select channel and send
- /*
- if (!CheckContactCapabilities(hContact, CAPF_SRV_RELAY) || wRecipientStatus == ID_STATUS_OFFLINE)
- {
- dwCookie = icq_SendChannel4Message(dwUin, hContact, MTYPE_CONTACTS, (WORD)nBodyLength, pBody, pCookieData);
- }
- else
- */
- {
- WORD wPriority;
-
- if (wRecipientStatus == ID_STATUS_ONLINE || wRecipientStatus == ID_STATUS_FREECHAT)
- wPriority = 0x0001;
- else
- wPriority = 0x0021;
+ WORD wPriority;
+ if (wRecipientStatus == ID_STATUS_ONLINE || wRecipientStatus == ID_STATUS_FREECHAT)
+ wPriority = 0x0001;
+ else
+ wPriority = 0x0021;
- dwCookie = icq_SendChannel2Message(dwUin, hContact, pBody, nBodyLength, wPriority, pCookieData, NULL);
- }
+ dwCookie = icq_SendChannel2Message(dwUin, hContact, pBody, nBodyLength, wPriority, pCookieData, NULL);
// This will stop the message dialog from waiting for the real message delivery ack
if (pCookieData->nAckType == ACKTYPE_NONE) {
@@ -1238,14 +1223,10 @@ int __cdecl CIcqProto::SendContacts(MCONTACT hContact, int flags, int nContacts,
}
SAFE_FREE((void**)&pBody);
}
- else {
- dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "Bad data (internal error #2)");
- }
+ else dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "Bad data (internal error #2)");
}
}
- else {
- dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "The reciever does not support receiving of contacts.");
- }
+ else dwCookie = ReportGenericSendError(hContact, ACKTYPE_CONTACTS, "The reciever does not support receiving of contacts.");
}
return dwCookie;
}
@@ -1372,7 +1353,7 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
return ReportGenericSendError(hContact, ACKTYPE_MESSAGE, "The receiver has an invalid user ID.");
if (flags & PREF_UNICODE) {
- puszText = make_utf8_string((WCHAR*)(pszSrc + strlennull(pszSrc) + 1)); // get the UTF-16 part
+ puszText = make_utf8_string((WCHAR*)(pszSrc + mir_strlen(pszSrc) + 1)); // get the UTF-16 part
bNeedFreeU = 1;
}
else if (flags & PREF_UTF)
@@ -1384,7 +1365,7 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
WORD wRecipientStatus = getContactStatus(hContact);
- BOOL plain_ascii = IsUSASCII(puszText, strlennull(puszText));
+ BOOL plain_ascii = IsUSASCII(puszText, mir_strlen(puszText));
BOOL oldAnsi = plain_ascii || !m_bUtfEnabled ||
(!(flags & (PREF_UTF | PREF_UNICODE)) && m_bUtfEnabled == 1) ||
@@ -1397,7 +1378,7 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
// Failure scenarios
if (!icqOnline())
dwCookie = ReportGenericSendError(hContact, ACKTYPE_MESSAGE, "You cannot send messages when you are offline.");
- else if ((wRecipientStatus == ID_STATUS_OFFLINE) && (strlennull(puszText) > 4096))
+ else if ((wRecipientStatus == ID_STATUS_OFFLINE) && (mir_strlen(puszText) > 4096))
dwCookie = ReportGenericSendError(hContact, ACKTYPE_MESSAGE, "Messages to offline contacts must be shorter than 4096 characters.");
// Looks OK
else {
@@ -1420,7 +1401,7 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
// Set up the ack type
pCookieData = CreateMessageCookieData(MTYPE_PLAIN, hContact, dwUin, TRUE);
pCookieData->nAckType = ACKTYPE_CLIENT;
- dwCookie = icq_SendDirectMessage(hContact, dc_msg, strlennull(dc_msg), 1, pCookieData, dc_cap);
+ dwCookie = icq_SendDirectMessage(hContact, dc_msg, mir_strlen(dc_msg), 1, pCookieData, dc_cap);
SAFE_FREE(&szUserAnsi);
if (dwCookie) { // free the buffers if alloced
@@ -1433,8 +1414,8 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
/// TODO: add support for RTL & user customizable font
{
- char *mng = MangleXml(puszText, strlennull(puszText));
- int len = strlennull(mng);
+ char *mng = MangleXml(puszText, mir_strlen(puszText));
+ size_t len = mir_strlen(mng);
mng = (char*)SAFE_REALLOC(mng, len + 28);
memmove(mng + 12, mng, len + 1);
memcpy(mng, "<HTML><BODY>", 12);
@@ -1445,7 +1426,7 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
}
WCHAR *pwszText = plain_ascii ? NULL : make_unicode_string(puszText);
- if ((plain_ascii ? strlennull(puszText) : strlennull(pwszText) * sizeof(WCHAR)) > MAX_MESSAGESNACSIZE) { // max length check // TLV(2) is currently limited to 0xA00 bytes in online mode
+ if ((plain_ascii ? mir_strlen(puszText) : mir_wstrlen(pwszText) * sizeof(WCHAR)) > MAX_MESSAGESNACSIZE) { // max length check // TLV(2) is currently limited to 0xA00 bytes in online mode
// only limit to not get disconnected, all other will be handled by error 0x0A
dwCookie = ReportGenericSendError(hContact, ACKTYPE_MESSAGE, "The message could not be delivered, it is too long.");
@@ -1514,10 +1495,10 @@ int __cdecl CIcqProto::SendUrl(MCONTACT hContact, int flags, const char* url)
cookie_message_data *pCookieData = CreateMessageCookieData(MTYPE_URL, hContact, dwUin, TRUE);
// Format the body
- int nUrlLen = strlennull(url);
+ size_t nUrlLen = mir_strlen(url);
char *szDesc = (char *)url + nUrlLen + 1;
- int nDescLen = strlennull(szDesc);
- int nBodyLen = nUrlLen + nDescLen + 2;
+ size_t nDescLen = mir_strlen(szDesc);
+ size_t nBodyLen = nUrlLen + nDescLen + 2;
char *szBody = (char *)_alloca(nBodyLen);
strcpy(szBody, szDesc);
szBody[nDescLen] = (char)0xFE; // Separator
@@ -1573,7 +1554,7 @@ int __cdecl CIcqProto::SetApparentMode(MCONTACT hContact, int mode)
// Don't send redundant updates
if (mode != oldMode) {
- setWord(hContact, "ApparentMode", (WORD)mode);
+ setWord(hContact, "ApparentMode", WORD(mode));
// Not being online is only an error when in SS mode. This is not handled
// yet so we just ignore this for now.
@@ -1786,7 +1767,7 @@ HANDLE __cdecl CIcqProto::GetAwayMsg(MCONTACT hContact)
if (!dwUin || !CheckContactCapabilities(hContact, CAPF_STATUS_MESSAGES)) { // No individual status messages, check if the contact has Status Note, if yes give it
char *szStatusNote = getSettingStringUtf(hContact, DBSETTING_STATUS_NOTE, NULL);
- if (strlennull(szStatusNote) > 0) { // Give Status Note
+ if (mir_strlen(szStatusNote) > 0) { // Give Status Note
status_message_thread_data *pThreadData = (status_message_thread_data*)SAFE_MALLOC(sizeof(status_message_thread_data));
pThreadData->hContact = hContact;
@@ -1927,7 +1908,7 @@ INT_PTR CIcqProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
if (!ppszMsg || !*ppszMsg)
return 0;
- int nMsgLen = strlennull(*ppszMsg) + 1;
+ size_t nMsgLen = mir_strlen(*ppszMsg) + 1;
if (lParam & SGMA_UNICODE) {
WCHAR *szMsg = (WCHAR*)_alloca(nMsgLen * sizeof(WCHAR));
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h
index 4f89e303e8..d8cea3ae36 100644
--- a/protocols/IcqOscarJ/src/icq_proto.h
+++ b/protocols/IcqOscarJ/src/icq_proto.h
@@ -197,26 +197,26 @@ struct CIcqProto : public PROTO<CIcqProto>
void SetCapabilitiesFromBuffer(MCONTACT hContact, BYTE *pBuffer, int nLength, BOOL bReset);
//----| chan_01login.cpp |------------------------------------------------------------
- void handleLoginChannel(BYTE *buf, WORD datalen, serverthread_info *info);
+ void handleLoginChannel(BYTE *buf, size_t datalen, serverthread_info *info);
//----| chan_02data.cpp |-------------------------------------------------------------
- void handleDataChannel(BYTE *buf, WORD wLen, serverthread_info *info);
+ void handleDataChannel(BYTE *buf, size_t wLen, serverthread_info *info);
void LogFamilyError(WORD wFamily, WORD wError);
//----| chan_03error.cpp |------------------------------------------------------------
- void handleErrorChannel(unsigned char *buf, WORD datalen);
+ void handleErrorChannel(unsigned char *buf, size_t datalen);
//----| chan_04close.cpp |------------------------------------------------------------
- void handleCloseChannel(BYTE *buf, WORD datalen, serverthread_info *info);
- void handleLoginReply(BYTE *buf, WORD datalen, serverthread_info *info);
+ void handleCloseChannel(BYTE *buf, size_t datalen, serverthread_info *info);
+ void handleLoginReply(BYTE *buf, size_t datalen, serverthread_info *info);
void handleMigration(serverthread_info *info);
void handleSignonError(WORD wError);
int connectNewServer(serverthread_info *info);
//----| chan_05ping.cpp |-------------------------------------------------------------
- void handlePingChannel(BYTE *buf, WORD wLen);
+ void handlePingChannel(BYTE *buf, size_t wLen);
void StartKeepAlive(serverthread_info *info);
void StopKeepAlive(serverthread_info *info);
@@ -254,76 +254,76 @@ struct CIcqProto : public PROTO<CIcqProto>
void icq_sendFileDenyDirect(MCONTACT hContact, filetransfer *ft, const char *szReason);
int icq_sendFileSendDirectv7(filetransfer *ft, const char *pszFiles);
int icq_sendFileSendDirectv8(filetransfer *ft, const char *pszFiles);
- DWORD icq_SendDirectMessage(MCONTACT hContact, const char *szMessage, int nBodyLength, WORD wPriority, cookie_message_data *pCookieData, char *szCap);
- void icq_sendXtrazRequestDirect(MCONTACT hContact, DWORD dwCookie, char* szBody, int nBodyLen, WORD wType);
- void icq_sendXtrazResponseDirect(MCONTACT hContact, WORD wCookie, char* szBody, int nBodyLen, WORD wType);
+ DWORD icq_SendDirectMessage(MCONTACT hContact, const char *szMessage, size_t nBodyLength, WORD wPriority, cookie_message_data *pCookieData, char *szCap);
+ void icq_sendXtrazRequestDirect(MCONTACT hContact, DWORD dwCookie, char* szBody, size_t nBodyLen, WORD wType);
+ void icq_sendXtrazResponseDirect(MCONTACT hContact, WORD wCookie, char* szBody, size_t nBodyLen, WORD wType);
//----| fam_01service.cpp |-----------------------------------------------------------
- void handleServiceFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader, serverthread_info *info);
- char* buildUinList(int subtype, WORD wMaxLen, MCONTACT *hContactResume);
+ void handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader, serverthread_info *info);
+ char* buildUinList(int subtype, size_t wMaxLen, MCONTACT *hContactResume);
void sendEntireListServ(WORD wFamily, WORD wSubtype, int listType);
void setUserInfo(void);
void handleServUINSettings(int nPort, serverthread_info *info);
//----| fam_02location.cpp |----------------------------------------------------------
- void handleLocationFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader);
- void handleLocationUserInfoReply(BYTE* buf, WORD wLen, DWORD dwCookie);
+ void handleLocationFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader);
+ void handleLocationUserInfoReply(BYTE* buf, size_t wLen, DWORD dwCookie);
//----| fam_03buddy.cpp |-------------------------------------------------------------
- void handleBuddyFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader, serverthread_info *info);
- void handleReplyBuddy(BYTE *buf, WORD wPackLen);
- void handleUserOffline(BYTE *buf, WORD wPackLen);
- void handleUserOnline(BYTE *buf, WORD wPackLen, serverthread_info *info);
+ void handleBuddyFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader, serverthread_info *info);
+ void handleReplyBuddy(BYTE *buf, size_t wPackLen);
+ void handleUserOffline(BYTE *buf, size_t wPackLen);
+ void handleUserOnline(BYTE *buf, size_t wPackLen, serverthread_info *info);
void parseStatusNote(DWORD dwUin, char *szUid, MCONTACT hContact, oscar_tlv_chain *pChain);
- void handleNotifyRejected(BYTE *buf, WORD wPackLen);
+ void handleNotifyRejected(BYTE *buf, size_t wPackLen);
//----| fam_04message.cpp |-----------------------------------------------------------
icq_mode_messages m_modeMsgs;
icq_critical_section *m_modeMsgsMutex;
HANDLE m_modeMsgsEvent;
- void handleMsgFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader);
+ void handleMsgFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader);
- void handleReplyICBM(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef);
- void handleRecvServMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef);
- void handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef);
- void handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef);
- void handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef);
- void handleRecvServMsgError(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef);
- void handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef);
- void handleServerAck(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef);
+ void handleReplyICBM(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef);
+ void handleRecvServMsg(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef);
+ void handleRecvServMsgType1(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef);
+ void handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef);
+ void handleRecvServMsgType4(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef);
+ void handleRecvServMsgError(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef);
+ void handleRecvMsgResponse(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef);
+ void handleServerAck(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef);
void handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DWORD dwUin, WORD wVersion, int bMsgType, WORD wCookie, const char *szMsg, int nMsgFlags);
- void handleTypingNotification(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef);
- void handleMissedMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef);
- void handleOffineMessagesReply(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef);
- void handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand);
+ void handleTypingNotification(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef);
+ void handleMissedMsg(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef);
+ void handleOffineMessagesReply(BYTE *buf, size_t wLen, WORD wFlags, DWORD dwRef);
+ void handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand);
void handleRuntimeError(WORD wError);
- void parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType);
- void parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType, BYTE bFlags, WORD wStatus, WORD wCookie, WORD wVersion);
+ void parseServRelayData(BYTE *pDataBuf, size_t wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType);
+ void parseServRelayPluginData(BYTE *pDataBuf, size_t wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType, BYTE bFlags, WORD wStatus, WORD wCookie, WORD wVersion);
- HANDLE handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD wVersion, int type, WORD wMsgLen, PBYTE buf, BYTE bFlags, int nMsgFlags);
- void handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, DWORD dwMsgID, DWORD dwMsgID2, WORD wCookie, WORD wVersion, int type, int flags, WORD wAckType, DWORD dwDataLen, WORD wMsgLen, char *pMsg, int nMsgFlags, message_ack_params *pAckParams);
+ HANDLE handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD wVersion, int type, size_t wMsgLen, PBYTE buf, BYTE bFlags, int nMsgFlags);
+ void handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, DWORD dwMsgID, DWORD dwMsgID2, WORD wCookie, WORD wVersion, int type, int flags, WORD wAckType, size_t dwDataLen, size_t wMsgLen, char *pMsg, int nMsgFlags, message_ack_params *pAckParams);
void sendMessageTypesAck(MCONTACT hContact, int bUnicode, message_ack_params *pArgs);
void sendTypingNotification(MCONTACT hContact, WORD wMTNCode);
- int unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WORD *pFunctionId, BOOL bThruDC);
+ int unpackPluginTypeId(BYTE **pBuffer, size_t *pwLen, int *pTypeId, WORD *pFunctionId, BOOL bThruDC);
char* convertMsgToUserSpecificUtf(MCONTACT hContact, const char *szMsg);
//----| fam_09bos.cpp |---------------------------------------------------------------
- void handleBosFam(unsigned char *pBuffer, WORD wBufferLength, snac_header* pSnacHeader);
- void handlePrivacyRightsReply(unsigned char *pBuffer, WORD wBufferLength);
+ void handleBosFam(unsigned char *pBuffer, size_t wBufferLength, snac_header* pSnacHeader);
+ void handlePrivacyRightsReply(unsigned char *pBuffer, size_t wBufferLength);
void makeContactTemporaryVisible(MCONTACT hContact);
//----| fam_0alookup.cpp |------------------------------------------------------------
- void handleLookupFam(unsigned char *pBuffer, WORD wBufferLength, snac_header* pSnacHeader);
+ void handleLookupFam(unsigned char *pBuffer, size_t wBufferLength, snac_header* pSnacHeader);
- void handleLookupEmailReply(BYTE* buf, WORD wLen, DWORD dwCookie);
+ void handleLookupEmailReply(BYTE* buf, size_t wLen, DWORD dwCookie);
void ReleaseLookupCookie(DWORD dwCookie, cookie_search *pCookie);
//----| fam_0bstatus.cpp |------------------------------------------------------------
- void handleStatusFam(unsigned char *pBuffer, WORD wBufferLength, snac_header* pSnacHeader);
+ void handleStatusFam(unsigned char *pBuffer, size_t wBufferLength, snac_header* pSnacHeader);
//----| fam_13servclist.cpp |---------------------------------------------------------
BOOL bIsSyncingCL;
@@ -332,16 +332,16 @@ struct CIcqProto : public PROTO<CIcqProto>
WORD m_wServerListGroupMaxContacts;
WORD m_wServerListRecordNameMaxLength;
- void handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_header* pSnacHeader, serverthread_info *info);
- void handleServerCListRightsReply(BYTE *buf, WORD wLen);
+ void handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_header* pSnacHeader, serverthread_info *info);
+ void handleServerCListRightsReply(BYTE *buf, size_t wLen);
void handleServerCListAck(cookie_servlist_action* sc, WORD wError);
- void handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, serverthread_info *info);
+ void handleServerCListReply(BYTE *buf, size_t wLen, WORD wFlags, serverthread_info *info);
void handleServerCListItemAdd(const char *szRecordName, WORD wGroupId, WORD wItemId, WORD wItemType, oscar_tlv_chain *pItemData);
void handleServerCListItemUpdate(const char *szRecordName, WORD wGroupId, WORD wItemId, WORD wItemType, oscar_tlv_chain *pItemData);
void handleServerCListItemDelete(const char *szRecordName, WORD wGroupId, WORD wItemId, WORD wItemType, oscar_tlv_chain *pItemData);
- void handleRecvAuthRequest(BYTE *buf, WORD wLen);
- void handleRecvAuthResponse(BYTE *buf, WORD wLen);
- void handleRecvAdded(BYTE *buf, WORD wLen);
+ void handleRecvAuthRequest(BYTE *buf, size_t wLen);
+ void handleRecvAuthResponse(BYTE *buf, size_t wLen);
+ void handleRecvAdded(BYTE *buf, size_t wLen);
MCONTACT HContactFromRecordName(const char *szRecordName, int *bAdded);
@@ -357,30 +357,30 @@ struct CIcqProto : public PROTO<CIcqProto>
void updateServVisibilityCode(BYTE bCode);
//----| fam_15icqserver.cpp |---------------------------------------------------------
- void handleIcqExtensionsFam(BYTE *pBuffer, WORD wBufferLength, snac_header* pSnacHeader);
+ void handleIcqExtensionsFam(BYTE *pBuffer, size_t wBufferLength, snac_header* pSnacHeader);
- void handleExtensionError(BYTE *buf, WORD wPackLen);
- void handleExtensionServerInfo(BYTE *buf, WORD wPackLen, WORD wFlags);
- void handleExtensionMetaResponse(BYTE *databuf, WORD wPacketLen, WORD wCookie, WORD wFlags);
+ void handleExtensionError(BYTE *buf, size_t wPackLen);
+ void handleExtensionServerInfo(BYTE *buf, size_t wPackLen, WORD wFlags);
+ void handleExtensionMetaResponse(BYTE *databuf, size_t wPacketLen, WORD wCookie, WORD wFlags);
int parseUserInfoRecord(MCONTACT hContact, oscar_tlv *pData, UserInfoRecordItem pRecordDef[], int nRecordDef, int nMaxRecords);
- void handleDirectoryQueryResponse(BYTE *databuf, WORD wPacketLen, WORD wCookie, WORD wReplySubtype, WORD wFlags);
- void handleDirectoryUpdateResponse(BYTE *databuf, WORD wPacketLen, WORD wCookie, WORD wReplySubtype);
+ void handleDirectoryQueryResponse(BYTE *databuf, size_t wPacketLen, WORD wCookie, WORD wReplySubtype, WORD wFlags);
+ void handleDirectoryUpdateResponse(BYTE *databuf, size_t wPacketLen, WORD wCookie, WORD wReplySubtype);
void parseDirectoryUserDetailsData(MCONTACT hContact, oscar_tlv_chain *cDetails, DWORD dwCookie, cookie_directory_data *pCookieData, WORD wReplySubType);
void parseDirectorySearchData(oscar_tlv_chain *cDetails, DWORD dwCookie, cookie_directory_data *pCookieData, WORD wReplySubType);
- void parseSearchReplies(unsigned char *databuf, WORD wPacketLen, WORD wCookie, WORD wReplySubtype, BYTE bResultCode);
- void parseUserInfoUpdateAck(unsigned char *databuf, WORD wPacketLen, WORD wCookie, WORD wReplySubtype, BYTE bResultCode);
+ void parseSearchReplies(unsigned char *databuf, size_t wPacketLen, WORD wCookie, WORD wReplySubtype, BYTE bResultCode);
+ void parseUserInfoUpdateAck(unsigned char *databuf, size_t wPacketLen, WORD wCookie, WORD wReplySubtype, BYTE bResultCode);
void ReleaseSearchCookie(DWORD dwCookie, cookie_search *pCookie);
//----| fam_17signon.cpp |------------------------------------------------------------
- void handleAuthorizationFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader, serverthread_info *info);
- void handleAuthKeyResponse(BYTE *buf, WORD wPacketLen, serverthread_info *info);
+ void handleAuthorizationFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader, serverthread_info *info);
+ void handleAuthKeyResponse(BYTE *buf, size_t wPacketLen, serverthread_info *info);
- void sendClientAuth(const char *szKey, WORD wKeyLen, BOOL bSecure);
+ void sendClientAuth(const char *szKey, size_t wKeyLen, BOOL bSecure);
//----| icq_avatars.cpp |-------------------------------------------------------------
icq_critical_section *m_avatarsMutex;
@@ -405,14 +405,14 @@ struct CIcqProto : public PROTO<CIcqProto>
int GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, const BYTE *hash, unsigned int hashlen, const TCHAR *file);
int SetAvatarData(MCONTACT hContact, WORD wRef, const BYTE *data, unsigned int datalen);
- void StartAvatarThread(HANDLE hConn, char* cookie, WORD cookieLen);
+ void StartAvatarThread(HANDLE hConn, char* cookie, size_t cookieLen);
void StopAvatarThread();
//----| icq_clients.cpp |-------------------------------------------------------------
- const char* detectUserClient(MCONTACT hContact, int nIsICQ, WORD wUserClass, DWORD dwOnlineSince, const char *szCurrentClient, WORD wVersion, DWORD dwFT1, DWORD dwFT2, DWORD dwFT3, BYTE bDirectFlag, DWORD dwDirectCookie, DWORD dwWebPort, BYTE *caps, WORD wLen, BYTE *bClientId, char *szClientBuf);
+ const char* detectUserClient(MCONTACT hContact, int nIsICQ, WORD wUserClass, DWORD dwOnlineSince, const char *szCurrentClient, WORD wVersion, DWORD dwFT1, DWORD dwFT2, DWORD dwFT3, BYTE bDirectFlag, DWORD dwDirectCookie, DWORD dwWebPort, BYTE *caps, size_t wLen, BYTE *bClientId, char *szClientBuf);
//----| icq_db.cpp |------------------------------------------------------------------
- HANDLE AddEvent(MCONTACT hContact, WORD wType, DWORD dwTime, DWORD flags, DWORD cbBlob, PBYTE pBlob);
+ HANDLE AddEvent(MCONTACT hContact, WORD wType, DWORD dwTime, DWORD flags, size_t cbBlob, PBYTE pBlob);
int IsICQContact(MCONTACT hContact);
int getSetting(MCONTACT hContact, const char *szSetting, DBVARIANT *dbv);
@@ -439,7 +439,7 @@ struct CIcqProto : public PROTO<CIcqProto>
void __cdecl icq_directThread(struct directthreadstartinfo* dtsi);
- void handleDirectPacket(directconnect* dc, PBYTE buf, WORD wLen);
+ void handleDirectPacket(directconnect* dc, PBYTE buf, size_t wLen);
void sendPeerInit_v78(directconnect* dc);
void sendPeerInitAck(directconnect* dc);
void sendPeerMsgInit(directconnect* dc, DWORD dwSeq);
@@ -455,15 +455,15 @@ struct CIcqProto : public PROTO<CIcqProto>
int SendDirectMessage(MCONTACT hContact, icq_packet *pkt);
//----| icq_directmsg.cpp |-----------------------------------------------------------
- void handleDirectMessage(directconnect* dc, PBYTE buf, WORD wLen);
- void handleDirectGreetingMessage(directconnect* dc, PBYTE buf, WORD wLen, WORD wCommand, WORD wCookie, BYTE bMsgType, BYTE bMsgFlags, WORD wStatus, WORD wFlags, char* pszText);
+ void handleDirectMessage(directconnect* dc, PBYTE buf, size_t wLen);
+ void handleDirectGreetingMessage(directconnect* dc, PBYTE buf, size_t wLen, WORD wCommand, WORD wCookie, BYTE bMsgType, BYTE bMsgFlags, WORD wStatus, WORD wFlags, char* pszText);
//----| icq_filerequests.cpp |--------------------------------------------------------
filetransfer* CreateFileTransfer(MCONTACT hContact, DWORD dwUin, int nVersion);
- void handleFileAck(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCookie, WORD wStatus, char* pszText);
- void handleFileRequest(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCookie, DWORD dwID1, DWORD dwID2, char* pszDescription, int nVersion, BOOL bDC);
- void handleDirectCancel(directconnect *dc, PBYTE buf, WORD wLen, WORD wCommand, DWORD dwCookie, WORD wMessageType, WORD wStatus, WORD wFlags, char* pszText);
+ void handleFileAck(PBYTE buf, size_t wLen, DWORD dwUin, DWORD dwCookie, WORD wStatus, char* pszText);
+ void handleFileRequest(PBYTE buf, size_t wLen, DWORD dwUin, DWORD dwCookie, DWORD dwID1, DWORD dwID2, char* pszDescription, int nVersion, BOOL bDC);
+ void handleDirectCancel(directconnect *dc, PBYTE buf, size_t wLen, WORD wCommand, DWORD dwCookie, WORD wMessageType, WORD wStatus, WORD wFlags, char* pszText);
void icq_CancelFileTransfer(MCONTACT hContact, filetransfer* ft);
@@ -472,7 +472,7 @@ struct CIcqProto : public PROTO<CIcqProto>
void icq_sendFileResume(filetransfer *ft, int action, const char *szFilename);
void icq_InitFileSend(filetransfer *ft);
- void handleFileTransferPacket(directconnect *dc, PBYTE buf, WORD wLen);
+ void handleFileTransferPacket(directconnect *dc, PBYTE buf, size_t wLen);
void handleFileTransferIdle(directconnect *dc);
//----| icq_infoupdate.cpp |----------------------------------------------------------
@@ -505,18 +505,18 @@ struct CIcqProto : public PROTO<CIcqProto>
void icq_LogFatalParam(const char *szMsg, WORD wError);
//----| icq_packet.cpp |--------------------------------------------------------------
- void ppackLETLVLNTSfromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wType);
- void ppackLETLVWordLNTSfromDB(PBYTE *buf, int *buflen, WORD w, const char *szSetting, WORD wType);
- void ppackLETLVLNTSBytefromDB(PBYTE *buf, int *buflen, const char *szSetting, BYTE b, WORD wType);
+ void ppackLETLVLNTSfromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wType);
+ void ppackLETLVWordLNTSfromDB(PBYTE *buf, size_t *buflen, WORD w, const char *szSetting, WORD wType);
+ void ppackLETLVLNTSBytefromDB(PBYTE *buf, size_t *buflen, const char *szSetting, BYTE b, WORD wType);
- void ppackTLVStringFromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wType);
- void ppackTLVStringUtfFromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wType);
- void ppackTLVDateFromDB(PBYTE *buf, int *buflen, const char *szSettingYear, const char *szSettingMonth, const char *szSettingDay, WORD wType);
+ void ppackTLVStringFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wType);
+ void ppackTLVStringUtfFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wType);
+ void ppackTLVDateFromDB(PBYTE *buf, size_t *buflen, const char *szSettingYear, const char *szSettingMonth, const char *szSettingDay, WORD wType);
- int ppackTLVWordStringItemFromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID);
- int ppackTLVWordStringUtfItemFromDB(PBYTE *buf, int *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID);
+ int ppackTLVWordStringItemFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID);
+ int ppackTLVWordStringUtfItemFromDB(PBYTE *buf, size_t *buflen, const char *szSetting, WORD wTypeID, WORD wTypeData, WORD wID);
- BOOL unpackUID(BYTE **ppBuf, WORD *pwLen, DWORD *pdwUIN, uid_str *ppszUID);
+ BOOL unpackUID(BYTE **ppBuf, size_t *pwLen, DWORD *pdwUIN, uid_str *ppszUID);
//----| icq_popups.cpp |--------------------------------------------------------------
int ShowPopupMsg(MCONTACT hContact, const char *szTitle, const char *szMsg, BYTE bType);
@@ -670,7 +670,7 @@ struct CIcqProto : public PROTO<CIcqProto>
int getCListGroupExists(const char *szGroup);
int moveContactToCListGroup(MCONTACT hContact, const char *szGroup); /// TODO: this should be DB function
- DWORD icq_sendServerItem(DWORD dwCookie, WORD wAction, WORD wGroupId, WORD wItemId, const char *szName, BYTE *pTLVs, int nTlvLength, WORD wItemType, DWORD dwOperation, DWORD dwTimeout, void **doubleObject);
+ DWORD icq_sendServerItem(DWORD dwCookie, WORD wAction, WORD wGroupId, WORD wItemId, const char *szName, BYTE *pTLVs, size_t nTlvLength, WORD wItemType, DWORD dwOperation, DWORD dwTimeout, void **doubleObject);
DWORD icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD wAction, WORD wGroupId, WORD wContactId, DWORD dwOperation, DWORD dwTimeout, void **doubleObject);
DWORD icq_sendSimpleItem(DWORD dwCookie, WORD wAction, DWORD dwUin, char* szUID, WORD wGroupId, WORD wItemId, WORD wItemType, DWORD dwOperation, DWORD dwTimeout);
DWORD icq_sendServerGroup(DWORD dwCookie, WORD wAction, WORD wGroupId, const char *szName, void *pContent, int cbContent, DWORD dwOperationFlags);
@@ -686,7 +686,7 @@ struct CIcqProto : public PROTO<CIcqProto>
//----| stdpackets.cpp |----------------------------------------------------------
void icq_sendCloseConnection();
- void icq_requestnewfamily(WORD wFamily, void (CIcqProto::*familyhandler)(HANDLE hConn, char* cookie, WORD cookieLen));
+ void icq_requestnewfamily(WORD wFamily, void (CIcqProto::*familyhandler)(HANDLE hConn, char* cookie, size_t cookieLen));
void icq_setidle(int bAllow);
void icq_setstatus(WORD wStatus, const char *szStatusNote = NULL);
@@ -706,9 +706,9 @@ struct CIcqProto : public PROTO<CIcqProto>
void icq_sendFileDenyServ(DWORD dwUin, filetransfer *ft, const char *szReason, int nAckType);
- DWORD icq_sendAdvancedSearchServ(BYTE *fieldsBuffer,int bufferLen);
+ DWORD icq_sendAdvancedSearchServ(BYTE *fieldsBuffer, size_t bufferLen);
DWORD icq_changeUserPasswordServ(const char *szPassword);
- DWORD icq_changeUserDirectoryInfoServ(const BYTE *pData, WORD wDataLen, BYTE bRequestType);
+ DWORD icq_changeUserDirectoryInfoServ(const BYTE *pData, size_t wDataLen, BYTE bRequestType);
void icq_sendGenericContact(DWORD dwUin, const char *szUid, WORD wFamily, WORD wSubType);
void icq_sendNewContact(DWORD dwUin, const char *szUid);
void icq_sendRemoveContact(DWORD dwUin, const char *szUid);
@@ -725,16 +725,16 @@ struct CIcqProto : public PROTO<CIcqProto>
void icq_sendAuthResponseServ(DWORD dwUin, char* szUid,int auth,const TCHAR *szReason);
void icq_sendYouWereAddedServ(DWORD,DWORD);
- DWORD sendDirectorySearchPacket(const BYTE *pSearchData, WORD wDataLen, WORD wPage, BOOL bOnlineUsersOnly);
- DWORD sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSearchType, WORD wInfoLen, BOOL bOnlineUsersOnly);
+ DWORD sendDirectorySearchPacket(const BYTE *pSearchData, size_t wDataLen, WORD wPage, BOOL bOnlineUsersOnly);
+ DWORD sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSearchType, size_t wInfoLen, BOOL bOnlineUsersOnly);
void sendOwnerInfoRequest(void);
- DWORD sendUserInfoMultiRequest(BYTE *pRequestData, WORD wDataLen, int nItems);
+ DWORD sendUserInfoMultiRequest(BYTE *pRequestData, size_t dataLen, int nItems);
DWORD icq_SendChannel1Message(DWORD dwUin, char *szUID, MCONTACT hContact, char *pszText, cookie_message_data *pCookieData);
DWORD icq_SendChannel1MessageW(DWORD dwUin, char *szUID, MCONTACT hContact, WCHAR *pszText, cookie_message_data *pCookieData); // UTF-16
- DWORD icq_SendChannel2Message(DWORD dwUin, MCONTACT hContact, const char *szMessage, int nBodyLength, WORD wPriority, cookie_message_data *pCookieData, char *szCap);
- DWORD icq_SendChannel2Contacts(DWORD dwUin, char *szUid, MCONTACT hContact, const char *pData, WORD wDataLen, const char *pNames, WORD wNamesLen, cookie_message_data *pCookieData);
- DWORD icq_SendChannel4Message(DWORD dwUin, MCONTACT hContact, BYTE bMsgType, WORD wMsgLen, const char *szMsg, cookie_message_data *pCookieData);
+ DWORD icq_SendChannel2Message(DWORD dwUin, MCONTACT hContact, const char *szMessage, size_t nBodyLength, WORD wPriority, cookie_message_data *pCookieData, char *szCap);
+ DWORD icq_SendChannel2Contacts(DWORD dwUin, char *szUid, MCONTACT hContact, const char *pData, size_t wDataLen, const char *pNames, size_t wNamesLen, cookie_message_data *pCookieData);
+ DWORD icq_SendChannel4Message(DWORD dwUin, MCONTACT hContact, BYTE bMsgType, size_t wMsgLen, const char *szMsg, cookie_message_data *pCookieData);
void icq_sendAdvancedMsgAck(DWORD, DWORD, DWORD, WORD, BYTE, BYTE);
void icq_sendContactsAck(DWORD dwUin, char *szUid, DWORD dwMsgID1, DWORD dwMsgID2);
@@ -742,8 +742,8 @@ struct CIcqProto : public PROTO<CIcqProto>
void icq_sendReverseReq(directconnect *dc, DWORD dwCookie, cookie_message_data *pCookie);
void icq_sendReverseFailed(directconnect* dc, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwCookie);
- void icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBody, int nBodyLen, cookie_message_data *pCookieData);
- void icq_sendXtrazResponseServ(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szBody, int nBodyLen, int nType);
+ void icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBody, size_t nBodyLen, cookie_message_data *pCookieData);
+ void icq_sendXtrazResponseServ(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szBody, size_t nBodyLen, int nType);
DWORD SearchByUin(DWORD dwUin);
DWORD SearchByNames(const char *pszNick, const char *pszFirstName, const char *pszLastName, WORD wPage);
@@ -762,7 +762,7 @@ struct CIcqProto : public PROTO<CIcqProto>
MCONTACT AddToListByUIN(DWORD dwUin, DWORD dwFlags);
MCONTACT AddToListByUID(const char *szUID, DWORD dwFlags);
- void ICQAddRecvEvent(MCONTACT hContact, WORD wType, PROTORECVEVENT* pre, DWORD cbBlob, PBYTE pBlob, DWORD flags);
+ void ICQAddRecvEvent(MCONTACT hContact, WORD wType, PROTORECVEVENT* pre, size_t cbBlob, PBYTE pBlob, DWORD flags);
INT_PTR __cdecl IcqAddCapability(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl IcqCheckCapability(WPARAM wParam, LPARAM lParam);
@@ -790,14 +790,14 @@ struct CIcqProto : public PROTO<CIcqProto>
void updateServerCustomStatus(int fullUpdate);
//----| icq_xtraz.cpp |---------------------------------------------------------------
- void handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, int nMsgLen, BOOL bThruDC);
- void handleXtrazNotifyResponse(DWORD dwUin, MCONTACT hContact, WORD wCookie, char* szMsg, int nMsgLen);
+ void handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, size_t nMsgLen, BOOL bThruDC);
+ void handleXtrazNotifyResponse(DWORD dwUin, MCONTACT hContact, WORD wCookie, char* szMsg, size_t nMsgLen);
- void handleXtrazInvitation(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, int nMsgLen, BOOL bThruDC);
- void handleXtrazData(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, int nMsgLen, BOOL bThruDC);
+ void handleXtrazInvitation(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, size_t nMsgLen, BOOL bThruDC);
+ void handleXtrazData(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, size_t nMsgLen, BOOL bThruDC);
DWORD SendXtrazNotifyRequest(MCONTACT hContact, char* szQuery, char* szNotify, int bForced);
- void SendXtrazNotifyResponse(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szResponse, int nResponseLen, BOOL bThruDC);
+ void SendXtrazNotifyResponse(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szResponse, size_t nResponseLen, BOOL bThruDC);
//----| init.cpp |--------------------------------------------------------------------
void UpdateGlobalSettings();
@@ -827,8 +827,8 @@ struct CIcqProto : public PROTO<CIcqProto>
int IsValidFileTransfer(void *ft);
int IsValidOscarTransfer(void *ft);
- void handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand);
- void handleRecvServResponseOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, void* ft);
+ void handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand);
+ void handleRecvServResponseOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, void* ft);
HANDLE oftInitTransfer(MCONTACT hContact, DWORD dwUin, char *szUid, const TCHAR **pszFiles, const TCHAR *szDescription);
HANDLE oftFileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR *szPath);
@@ -837,7 +837,7 @@ struct CIcqProto : public PROTO<CIcqProto>
void oftFileResume(oscar_filetransfer *ft, int action, const TCHAR *szFilename);
void sendOscarPacket(oscar_connection *oc, icq_packet *packet);
- void handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE *pBuffer, WORD wLen);
+ void handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE *pBuffer, size_t wLen);
void sendOFT2FramePacket(oscar_connection *oc, WORD datatype);
void proxy_sendInitTunnel(oscar_connection *oc);
@@ -883,7 +883,7 @@ struct CIcqProto : public PROTO<CIcqProto>
void AddToSpammerList(DWORD dwUIN);
BOOL IsOnSpammerList(DWORD dwUIN);
- HANDLE NetLib_BindPort(NETLIBNEWCONNECTIONPROC_V2 pFunc, void* lParam, WORD* pwPort, DWORD* pdwIntIP);
+ HANDLE NetLib_BindPort(NETLIBNEWCONNECTIONPROC_V2 pFunc, void* lParam, WORD *pwPort, DWORD *pdwIntIP);
MCONTACT HandleFromCacheByUid(DWORD dwUin, const char *szUid);
MCONTACT HContactFromUIN(DWORD dwUin, int *Added);
@@ -901,12 +901,6 @@ struct CIcqProto : public PROTO<CIcqProto>
int SetStatusNote(const char *szStatusNote, DWORD dwDelay, int bForced);
int SetStatusMood(const char *szMoodData, DWORD dwDelay);
- BOOL writeDbInfoSettingString(MCONTACT hContact, const char* szSetting, char** buf, WORD* pwLength);
- BOOL writeDbInfoSettingWord(MCONTACT hContact, const char *szSetting, char **buf, WORD* pwLength);
- BOOL writeDbInfoSettingWordWithTable(MCONTACT hContact, const char *szSetting, const FieldNamesItem *table, char **buf, WORD* pwLength);
- BOOL writeDbInfoSettingByte(MCONTACT hContact, const char *pszSetting, char **buf, WORD* pwLength);
- BOOL writeDbInfoSettingByteWithTable(MCONTACT hContact, const char *szSetting, const FieldNamesItem *table, char **buf, WORD* pwLength);
-
void writeDbInfoSettingTLVStringUtf(MCONTACT hContact, const char *szSetting, oscar_tlv_chain *chain, WORD wTlv);
void writeDbInfoSettingTLVWord(MCONTACT hContact, const char *szSetting, oscar_tlv_chain *chain, WORD wTlv);
void writeDbInfoSettingTLVByte(MCONTACT hContact, const char *szSetting, oscar_tlv_chain *chain, WORD wTlv);
diff --git a/protocols/IcqOscarJ/src/icq_rates.cpp b/protocols/IcqOscarJ/src/icq_rates.cpp
index 9ea1e9c70c..5c2f857bbd 100644
--- a/protocols/IcqOscarJ/src/icq_rates.cpp
+++ b/protocols/IcqOscarJ/src/icq_rates.cpp
@@ -33,7 +33,7 @@
// Rate Level 1 Management
/////////////////////////////
-rates::rates(CIcqProto *ppro, BYTE *pBuffer, WORD wLen)
+rates::rates(CIcqProto *ppro, BYTE *pBuffer, size_t wLen)
{
nGroups = 0;
memset(&groups, 0, MAX_RATES_GROUP_COUNT * sizeof(rates_group));
@@ -223,7 +223,7 @@ int rates::getLimitLevel(WORD wGroup, int nLevel)
void rates::initAckPacket(icq_packet *pPacket)
{
- serverPacketInit(pPacket, 10 + WORD(nGroups * sizeof(WORD)));
+ serverPacketInit(pPacket, 10 + nGroups * sizeof(WORD));
packFNACHeader(pPacket, ICQ_SERVICE_FAMILY, ICQ_CLIENT_RATE_ACK);
for (WORD wGroup = 1; wGroup <= nGroups; wGroup++)
packWord(pPacket, wGroup);
diff --git a/protocols/IcqOscarJ/src/icq_rates.h b/protocols/IcqOscarJ/src/icq_rates.h
index b314b9f803..e8445fb44b 100644
--- a/protocols/IcqOscarJ/src/icq_rates.h
+++ b/protocols/IcqOscarJ/src/icq_rates.h
@@ -56,7 +56,7 @@ private:
rates_group *getGroup(WORD wGroup);
public:
- rates(CIcqProto *ppro, BYTE *pBuffer, WORD wLen);
+ rates(CIcqProto *ppro, BYTE *pBuffer, size_t wLen);
~rates();
WORD getGroupFromSNAC(WORD wFamily, WORD wCommand);
diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp
index 3f7e5166e1..94356f5602 100644
--- a/protocols/IcqOscarJ/src/icq_server.cpp
+++ b/protocols/IcqOscarJ/src/icq_server.cpp
@@ -388,8 +388,9 @@ void CIcqProto::icq_login(const char* szPassword)
stsi->nloc.wPort = RandRange(1024, 65535);
// User password
- stsi->wPassLen = strlennull(szPassword);
- if (stsi->wPassLen > 8) stsi->wPassLen = 8;
+ stsi->wPassLen = mir_strlen(szPassword);
+ if (stsi->wPassLen > 8)
+ stsi->wPassLen = 8;
null_strcpy(stsi->szPass, szPassword, stsi->wPassLen);
// Randomize sequence
diff --git a/protocols/IcqOscarJ/src/icq_server.h b/protocols/IcqOscarJ/src/icq_server.h
index 99b545b14e..c3b18d3b8c 100644
--- a/protocols/IcqOscarJ/src/icq_server.h
+++ b/protocols/IcqOscarJ/src/icq_server.h
@@ -33,14 +33,14 @@
struct serverthread_start_info
{
NETLIBOPENCONNECTION nloc;
- WORD wPassLen;
+ size_t wPassLen;
char szPass[128];
};
struct serverthread_info
{
BYTE szAuthKey[20];
- WORD wAuthKeyLen;
+ size_t wAuthKeyLen;
WORD wServerPort;
char *newServer;
BYTE *cookieData;
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp
index 233c0d07d8..93bf040dee 100644
--- a/protocols/IcqOscarJ/src/icq_servlist.cpp
+++ b/protocols/IcqOscarJ/src/icq_servlist.cpp
@@ -178,10 +178,10 @@ void __cdecl CIcqProto::servlistQueueThread(void *param)
// allocate cookie id
dwGroupCookie = AllocateCookie(CKT_SERVERLIST, wItemAction, 0, pGroupCookie);
// prepare packet data
- serverPacketInit(&groupPacket, (WORD)(totalSize + 0x0A)); // FLAP size added inside
+ serverPacketInit(&groupPacket, totalSize + 0x0A); // FLAP size added inside
packFNACHeader(&groupPacket, ICQ_LISTS_FAMILY, wItemAction, 0, dwGroupCookie);
for (i = 0; i < pItem->nItems; i++)
- packBuffer(&groupPacket, pItem->pItems[i]->packet.pData + 0x10, (WORD)(pItem->pItems[i]->packet.wLen - 0x10));
+ packBuffer(&groupPacket, pItem->pItems[i]->packet.pData + 0x10, pItem->pItems[i]->packet.wLen - 0x10);
if (bItemDouble) { // prepare second packet
wItemAction = ((servlistgroupitemdouble*)(pItem->pItems[0]))->wAction2;
@@ -199,10 +199,10 @@ void __cdecl CIcqProto::servlistQueueThread(void *param)
// allocate cookie id
dwGroupCookie = AllocateCookie(CKT_SERVERLIST, wItemAction, 0, pGroupCookie);
// prepare packet data
- serverPacketInit(&groupPacket2, (WORD)(totalSize + 0x0A)); // FLAP size added inside
+ serverPacketInit(&groupPacket2, totalSize + 0x0A); // FLAP size added inside
packFNACHeader(&groupPacket2, ICQ_LISTS_FAMILY, wItemAction, 0, dwGroupCookie);
for (i = 0; i < pItem->nItems; i++)
- packBuffer(&groupPacket2, ((servlistgroupitemdouble*)(pItem->pItems[i]))->packet2.pData + 0x10, (WORD)(((servlistgroupitemdouble*)(pItem->pItems[i]))->packet2.wLen - 0x10));
+ packBuffer(&groupPacket2, ((servlistgroupitemdouble*)(pItem->pItems[i]))->packet2.pData + 0x10, ((servlistgroupitemdouble*)(pItem->pItems[i]))->packet2.wLen - 0x10);
}
}
else { // just send the one packet, do not create action group
@@ -815,7 +815,7 @@ struct GroupReserveIdsEnumParam
static int GroupReserveIdsEnumProc(const char *szSetting, LPARAM lParam)
{
- if (szSetting && strlennull(szSetting) < 5) {
+ if (szSetting && mir_strlen(szSetting) < 5) {
// it is probably server group
GroupReserveIdsEnumParam *param = (GroupReserveIdsEnumParam*)lParam;
char val[MAX_PATH + 2]; // dummy
@@ -914,7 +914,7 @@ void CIcqProto::LoadServerIDs()
void CIcqProto::StoreServerIDs() /// TODO: allow delayed
{
BYTE *pUnhandled = NULL;
- int cbUnhandled = 0;
+ size_t cbUnhandled = 0;
servlistMutex->Enter();
if (pdwServerIDList)
@@ -928,7 +928,7 @@ void CIcqProto::StoreServerIDs() /// TODO: allow delayed
servlistMutex->Leave();
if (pUnhandled)
- setSettingBlob(NULL, DBSETTING_SERVLIST_UNHANDLED, pUnhandled, cbUnhandled);
+ setSettingBlob(NULL, DBSETTING_SERVLIST_UNHANDLED, pUnhandled, (int)cbUnhandled);
else
delSetting(DBSETTING_SERVLIST_UNHANDLED);
@@ -966,28 +966,24 @@ struct doubleServerItemObject
icq_packet packet;
};
-DWORD CIcqProto::icq_sendServerItem(DWORD dwCookie, WORD wAction, WORD wGroupId, WORD wItemId, const char *szName, BYTE *pTLVs, int nTlvLength, WORD wItemType, DWORD dwOperation, DWORD dwTimeout, void **doubleObject)
+DWORD CIcqProto::icq_sendServerItem(DWORD dwCookie, WORD wAction, WORD wGroupId, WORD wItemId, const char *szName, BYTE *pTLVs, size_t nTlvLength, WORD wItemType, DWORD dwOperation, DWORD dwTimeout, void **doubleObject)
{
- // generic packet
- icq_packet packet;
- int nNameLen;
- WORD wTLVlen = (WORD)nTlvLength;
-
// Prepare item name length
- nNameLen = strlennull(szName);
+ size_t nNameLen = mir_strlen(szName);
// Build the packet
- serverPacketInit(&packet, (WORD)(nNameLen + 20 + wTLVlen));
+ icq_packet packet;
+ serverPacketInit(&packet, nNameLen + 20 + nTlvLength);
packFNACHeader(&packet, ICQ_LISTS_FAMILY, wAction, 0, dwCookie);
- packWord(&packet, (WORD)nNameLen);
+ packWord(&packet, WORD(nNameLen));
if (nNameLen)
- packBuffer(&packet, (LPBYTE)szName, (WORD)nNameLen);
+ packBuffer(&packet, (LPBYTE)szName, nNameLen);
packWord(&packet, wGroupId);
packWord(&packet, wItemId);
packWord(&packet, wItemType);
- packWord(&packet, wTLVlen);
- if (wTLVlen)
- packBuffer(&packet, pTLVs, wTLVlen);
+ packWord(&packet, WORD(nTlvLength));
+ if (nTlvLength)
+ packBuffer(&packet, pTLVs, nTlvLength);
if (!doubleObject) // Send the packet and return the cookie
servlistPostPacket(&packet, dwCookie, dwOperation | wAction, dwTimeout);
@@ -1024,8 +1020,7 @@ DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD w
icq_packet pBuffer;
char *szNick = NULL, *szNote = NULL;
BYTE *pData = NULL, *pMetaToken = NULL, *pMetaTime = NULL;
- int nNickLen, nNoteLen, nDataLen = 0, nMetaTokenLen = 0, nMetaTimeLen = 0;
- WORD wTLVlen;
+ int nDataLen = 0, nMetaTokenLen = 0, nMetaTimeLen = 0;
BYTE bAuth;
int bDataTooLong = FALSE;
@@ -1065,8 +1060,8 @@ DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD w
db_free(&dbv);
}
- nNickLen = strlennull(szNick);
- nNoteLen = strlennull(szNote);
+ size_t nNickLen = mir_strlen(szNick);
+ size_t nNoteLen = mir_strlen(szNote);
// Limit the strings
if (nNickLen > MAX_SSI_TLV_NAME_SIZE) {
@@ -1084,27 +1079,27 @@ DWORD CIcqProto::icq_sendServerContact(MCONTACT hContact, DWORD dwCookie, WORD w
}
// Build the packet
- wTLVlen = (nNickLen ? 4 + nNickLen : 0) + (nNoteLen ? 4 + nNoteLen : 0) + (bAuth ? 4 : 0) + nDataLen + (nMetaTokenLen ? 4 + nMetaTokenLen : 0) + (nMetaTimeLen ? 4 + nMetaTimeLen : 0);
+ size_t wTLVlen = (nNickLen ? 4 + nNickLen : 0) + (nNoteLen ? 4 + nNoteLen : 0) + (bAuth ? 4 : 0) + nDataLen + (nMetaTokenLen ? 4 + nMetaTokenLen : 0) + (nMetaTimeLen ? 4 + nMetaTimeLen : 0);
// Initialize our handy data buffer
pBuffer.wPlace = 0;
pBuffer.pData = (BYTE *)_alloca(wTLVlen);
- pBuffer.wLen = wTLVlen;
+ pBuffer.wLen = (WORD)wTLVlen;
if (nNickLen)
- packTLV(&pBuffer, SSI_TLV_NAME, (WORD)nNickLen, (LPBYTE)szNick); // Nickname TLV
+ packTLV(&pBuffer, SSI_TLV_NAME, nNickLen, (LPBYTE)szNick); // Nickname TLV
if (nNoteLen)
- packTLV(&pBuffer, SSI_TLV_COMMENT, (WORD)nNoteLen, (LPBYTE)szNote); // Comment TLV
+ packTLV(&pBuffer, SSI_TLV_COMMENT, nNoteLen, (LPBYTE)szNote); // Comment TLV
if (nMetaTokenLen)
- packTLV(&pBuffer, SSI_TLV_METAINFO_TOKEN, (WORD)nMetaTokenLen, pMetaToken);
+ packTLV(&pBuffer, SSI_TLV_METAINFO_TOKEN, nMetaTokenLen, pMetaToken);
if (nMetaTimeLen)
- packTLV(&pBuffer, SSI_TLV_METAINFO_TIME, (WORD)nMetaTimeLen, pMetaTime);
+ packTLV(&pBuffer, SSI_TLV_METAINFO_TIME, nMetaTimeLen, pMetaTime);
if (pData)
- packBuffer(&pBuffer, pData, (WORD)nDataLen);
+ packBuffer(&pBuffer, pData, nDataLen);
if (bAuth) // icq5 gives this as last TLV
packDWord(&pBuffer, 0x00660000); // "Still waiting for auth" TLV
@@ -1126,7 +1121,7 @@ DWORD CIcqProto::icq_sendServerGroup(DWORD dwCookie, WORD wAction, WORD wGroupId
icq_packet pBuffer; // I reuse the ICQ packet type as a generic buffer
// I should be ashamed! ;)
- if (strlennull(szName) == 0 && wGroupId != 0) {
+ if (mir_strlen(szName) == 0 && wGroupId != 0) {
debugLogA("Group upload failed (GroupName missing).");
return 0; // without name we could not change the group
}
@@ -1140,7 +1135,7 @@ DWORD CIcqProto::icq_sendServerGroup(DWORD dwCookie, WORD wAction, WORD wGroupId
pBuffer.wLen = wTLVlen;
if (wTLVlen)
- packTLV(&pBuffer, SSI_TLV_SUBITEMS, (WORD)cbContent, (LPBYTE)pContent); // Groups TLV
+ packTLV(&pBuffer, SSI_TLV_SUBITEMS, cbContent, (LPBYTE)pContent); // Groups TLV
return icq_sendServerItem(dwCookie, wAction, wGroupId, 0, szName, pBuffer.pData, wTLVlen, SSI_ITEM_GROUP, SSOP_GROUP_ACTION | dwOperationFlags, 400, NULL);
}
@@ -1385,7 +1380,7 @@ int CIcqProto::getCListGroupExists(const char *szGroup)
if (!szGroup)
return 0;
- int size = strlennull(szGroup) + 2;
+ size_t size = mir_strlen(szGroup) + 2;
TCHAR *tszGroup = (TCHAR*)_alloca(size * sizeof(TCHAR));
if (utf8_to_tchar_static(szGroup, tszGroup, size))
@@ -1417,24 +1412,21 @@ int CIcqProto::moveContactToCListGroup(MCONTACT hContact, const char *szGroup)
// utility function which counts > on start of a server group name
static int countGroupNameLevel(const char *szGroupName)
{
- int nNameLen = strlennull(szGroupName);
- int i = 0;
+ size_t nNameLen = mir_strlen(szGroupName);
- while (i < nNameLen) {
+ for (size_t i=0; i < nNameLen; i++)
if (szGroupName[i] != '>')
- return i;
+ return (int)i;
- i++;
- }
return -1;
}
static int countCListGroupLevel(const char *szClistName)
{
- int nNameLen = strlennull(szClistName);
- int i, level = 0;
+ size_t nNameLen = mir_strlen(szClistName);
+ int level = 0;
- for (i = 0; i < nNameLen; i++)
+ for (size_t i = 0; i < nNameLen; i++)
if (szClistName[i] == '\\') level++;
return level;
@@ -1496,7 +1488,7 @@ char *CIcqProto::getServListGroupCListPath(WORD wGroupId)
char *szParentGroup = getServListGroupCListPath(wParentGroupId);
/// FIXME: properly handle ~N suffixes
- szParentGroup = (char*)SAFE_REALLOC(szParentGroup, strlennull(szGroup) + strlennull(szParentGroup) + 2);
+ szParentGroup = (char*)SAFE_REALLOC(szParentGroup, mir_strlen(szGroup) + mir_strlen(szParentGroup) + 2);
strcat(szParentGroup, "\\");
strcat(szParentGroup, (char*)szGroup + nGroupLevel);
@@ -1561,8 +1553,8 @@ char* CIcqProto::getServListUniqueGroupName(const char *szGroupName, int bAlloce
char szUnique[10];
_itoa(uniqueID++, szUnique, 10);
- null_strcut(szGroupNameBase, m_wServerListRecordNameMaxLength - strlennull(szUnique) - 1);
- szNewGroupName = (char*)SAFE_MALLOC(strlennull(szUnique) + strlennull(szGroupNameBase) + 2);
+ null_strcut(szGroupNameBase, m_wServerListRecordNameMaxLength - mir_strlen(szUnique) - 1);
+ szNewGroupName = (char*)SAFE_MALLOC(mir_strlen(szUnique) + mir_strlen(szGroupNameBase) + 2);
if (szNewGroupName) {
strcpy(szNewGroupName, szGroupNameBase);
strcat(szNewGroupName, "~");
@@ -1597,7 +1589,7 @@ int CIcqProto::servlistCreateGroup_gotParentGroup(const char *szGroup, WORD wGro
if (nResult == PENDING_RESULT_PURGE) // only cleanup
return CALLBACK_RESULT_CONTINUE;
- szSubGroup = (char*)SAFE_MALLOC(strlennull(szGroup) + strlennull(szSubGroupName) + 2);
+ szSubGroup = (char*)SAFE_MALLOC(mir_strlen(szGroup) + mir_strlen(szSubGroupName) + 2);
if (szSubGroup) {
strcpy(szSubGroup, szGroup);
strcat(szSubGroup, "\\");
@@ -1624,7 +1616,7 @@ int CIcqProto::servlistCreateGroup_gotParentGroup(const char *szGroup, WORD wGro
if (!CheckServerID(wSubGroupID, 0)) { // the next id is free, so create our group with that id
cookie_servlist_action *ack;
DWORD dwCookie;
- char *szSubGroupItem = (char*)SAFE_MALLOC(strlennull(szSubGroupName) + wSubGroupLevel + 1);
+ char *szSubGroupItem = (char*)SAFE_MALLOC(mir_strlen(szSubGroupName) + wSubGroupLevel + 1);
if (szSubGroupItem) {
int i;
@@ -1633,7 +1625,7 @@ int CIcqProto::servlistCreateGroup_gotParentGroup(const char *szGroup, WORD wGro
szSubGroupItem[i] = '>';
strcpy(szSubGroupItem + wSubGroupLevel, szSubGroupName);
- szSubGroupItem[strlennull(szSubGroupName) + wSubGroupLevel] = '\0';
+ szSubGroupItem[mir_strlen(szSubGroupName) + wSubGroupLevel] = '\0';
SAFE_FREE((void**)&szSubGroupName);
// check and create unique group name (Miranda does allow more subgroups with the same name!)
szSubGroupItem = getServListUniqueGroupName(szSubGroupItem, TRUE);
@@ -1730,7 +1722,7 @@ void CIcqProto::servlistCreateGroup(const char *szGroupPath, LPARAM param, PENDI
{
char *szGroup = (char*)szGroupPath;
- if (!strlennull(szGroup)) szGroup = DEFAULT_SS_GROUP;
+ if (!mir_strlen(szGroup)) szGroup = DEFAULT_SS_GROUP;
servlistPendingAddGroup(szGroup, 0, 0, &CIcqProto::servlistCreateGroup_Ready, TRUE, param, callback);
}
@@ -2162,7 +2154,7 @@ void CIcqProto::servlistRenameGroup(char *szGroup, WORD wGroupId, char *szNewGro
if (!strcmpnull(szGroupName, szNewGroupName)) return;
szGroupName = szNewGroupName;
- szNewGroupName = (char*)SAFE_MALLOC(strlennull(szGroupName) + 1 + nGroupLevel);
+ szNewGroupName = (char*)SAFE_MALLOC(mir_strlen(szGroupName) + 1 + nGroupLevel);
if (!szNewGroupName) return; // Failure
for (i = 0; i < nGroupLevel; i++) { // create level prefix
diff --git a/protocols/IcqOscarJ/src/icq_servlist.h b/protocols/IcqOscarJ/src/icq_servlist.h
index e94472ba1e..ceda6b82cd 100644
--- a/protocols/IcqOscarJ/src/icq_servlist.h
+++ b/protocols/IcqOscarJ/src/icq_servlist.h
@@ -1,23 +1,23 @@
// ---------------------------------------------------------------------------80
// ICQ plugin for Miranda Instant Messenger
// ________________________________________
-//
+//
// Copyright © 2000-2001 Richard Hughes, Roland Rabien, Tristan Van de Vreede
// Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
// Copyright © 2012-2014 Miranda NG Team
-//
+//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -55,13 +55,13 @@ typedef int (__cdecl CIcqProto::*PENDING_CONTACT_CALLBACK)(MCONTACT hContact, WO
struct cookie_servlist_action
{
MCONTACT hContact;
- char *szGroup;
+ char *szGroup;
WORD wContactId;
WORD wGroupId;
char *szGroupName;
WORD wNewContactId;
WORD wNewGroupId;
- int dwAction;
+ int dwAction;
LPARAM lParam;
int dwGroupCount;
cookie_servlist_action **pGroupItems;
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp
index 652462d060..bbbb5c00d6 100644
--- a/protocols/IcqOscarJ/src/icq_uploadui.cpp
+++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp
@@ -140,7 +140,7 @@ static void GetLastUploadLogLine(HWND hwndDlg, char *szBuf, size_t cbBuf)
static int GroupEnumIdsEnumProc(const char *szSetting,LPARAM lParam)
{
// it is probably server group
- if (szSetting && strlennull(szSetting) < 5) {
+ if (szSetting && mir_strlen(szSetting) < 5) {
char val[MAX_PATH+2]; // dummy
if (db_get_static(NULL, (char*)lParam, szSetting, val, MAX_PATH))
return 0; // this converts all string types to DBVT_ASCIIZ
@@ -537,7 +537,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
if (isChecked) { // Queue for uploading
pszGroup = ppro->getContactCListGroup(hContact);
- if (!strlennull(pszGroup))
+ if (!mir_strlen(pszGroup))
pszGroup = null_strdup(DEFAULT_SS_GROUP);
// Get group ID from cache, if not ready use parent group, if still not ready create one
@@ -602,7 +602,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
WORD wCurrentGroupId = ppro->getWord(hContact, DBSETTING_SERVLIST_GROUP, 0);
pszGroup = ppro->getContactCListGroup(hContact);
- if (!strlennull(pszGroup))
+ if (!mir_strlen(pszGroup))
pszGroup = null_strdup(DEFAULT_SS_GROUP);
wNewGroupId = ppro->getServListGroupLinkID(pszGroup);
if (!wNewGroupId && strstrnull(pszGroup, "\\") != NULL) { // if it is sub-group, take master parent
diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp
index b60eb7cd60..fef0ede1c6 100644
--- a/protocols/IcqOscarJ/src/icq_xstatus.cpp
+++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp
@@ -561,7 +561,7 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam
SendMessage(hwnd, WM_KEYDOWN, VK_LEFT, 0);
SendMessage(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM) (PDWORD) NULL);
WCHAR *text = GetWindowTextUcs(hwnd);
- MoveMemory(text + start, text + end, sizeof(WCHAR) * (strlennull(text) + 1 - end));
+ MoveMemory(text + start, text + end, sizeof(WCHAR) * (mir_wstrlen(text) + 1 - end));
SetWindowTextUcs(hwnd, text);
SAFE_FREE(&text);
SendMessage(hwnd, EM_SETSEL, start, start);
@@ -837,7 +837,7 @@ INT_PTR CIcqProto::menuXStatus(WPARAM wParam,LPARAM lParam,LPARAM fParam)
void CIcqProto::InitXStatusItems(BOOL bAllowStatus)
{
- int len = strlennull(m_szModuleName);
+ size_t len = mir_strlen(m_szModuleName);
char srvFce[MAX_PATH + 64];
char szItem[MAX_PATH + 64];
int bXStatusMenuBuilt = 0;
@@ -1053,7 +1053,7 @@ INT_PTR CIcqProto::GetXStatusEx(WPARAM hContact, LPARAM lParam)
if (pData->wParam) {
if (m_bXStatusEnabled && !getString(hContact, DBSETTING_XSTATUS_NAME, &dbv))
- *pData->wParam = strlennull(dbv.pszVal);
+ *pData->wParam = mir_strlen(dbv.pszVal);
else
*pData->wParam = 0;
db_free(&dbv);
@@ -1061,7 +1061,7 @@ INT_PTR CIcqProto::GetXStatusEx(WPARAM hContact, LPARAM lParam)
if (pData->lParam) {
if (!getString(hContact, CheckContactCapabilities(hContact, CAPF_STATUS_MOOD) ? DBSETTING_STATUS_NOTE : DBSETTING_XSTATUS_MSG, &dbv))
- *pData->lParam = strlennull(dbv.pszVal);
+ *pData->lParam = mir_strlen(dbv.pszVal);
else
*pData->lParam = 0;
db_free(&dbv);
diff --git a/protocols/IcqOscarJ/src/icq_xtraz.cpp b/protocols/IcqOscarJ/src/icq_xtraz.cpp
index ef7f84a154..0e2d4199e4 100644
--- a/protocols/IcqOscarJ/src/icq_xtraz.cpp
+++ b/protocols/IcqOscarJ/src/icq_xtraz.cpp
@@ -29,7 +29,7 @@
#include "icqoscar.h"
-void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, int nMsgLen, BOOL bThruDC)
+void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, size_t nMsgLen, BOOL bThruDC)
{
char *szNotify = strstrnull(szMsg, "<NOTIFY>");
char *szQuery = strstrnull(szMsg, "<QUERY>");
@@ -77,14 +77,14 @@ void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD w
NotifyEventHooks(m_modeMsgsEvent, (WPARAM)MTYPE_SCRIPT_NOTIFY, (LPARAM)dwUin);
char *tmp = getSettingStringUtf(NULL, DBSETTING_XSTATUS_NAME, "");
- char *szXName = MangleXml(tmp, strlennull(tmp));
+ char *szXName = MangleXml(tmp, mir_strlen(tmp));
SAFE_FREE(&tmp);
tmp = getSettingStringUtf(NULL, DBSETTING_XSTATUS_MSG, "");
- char *szXMsg = MangleXml(tmp, strlennull(tmp));
+ char *szXMsg = MangleXml(tmp, mir_strlen(tmp));
SAFE_FREE(&tmp);
- int nResponseLen = 212 + strlennull(szXName) + strlennull(szXMsg) + UINMAXLEN + 2;
+ size_t nResponseLen = 212 + mir_strlen(szXName) + mir_strlen(szXMsg) + UINMAXLEN + 2;
char *szResponse = (char*)_alloca(nResponseLen + 1);
// send response
mir_snprintf(szResponse, nResponseLen,
@@ -123,7 +123,7 @@ void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD w
virtual void execute()
{
- ppro->SendXtrazNotifyResponse(dwUin, dwMsgID1, dwMsgID2, wCookie, szResponse, strlennull(szResponse), bThruDC);
+ ppro->SendXtrazNotifyResponse(dwUin, dwMsgID1, dwMsgID2, wCookie, szResponse, mir_strlen(szResponse), bThruDC);
};
BOOL bThruDC;
@@ -167,10 +167,10 @@ void CIcqProto::handleXtrazNotify(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD w
else debugLogA("Error: Invalid Xtraz Notify message");
}
-void CIcqProto::handleXtrazNotifyResponse(DWORD dwUin, MCONTACT hContact, WORD wCookie, char* szMsg, int nMsgLen)
+void CIcqProto::handleXtrazNotifyResponse(DWORD dwUin, MCONTACT hContact, WORD wCookie, char* szMsg, size_t nMsgLen)
{
char *szMem, *szRes, *szEnd;
- int nResLen;
+ size_t nResLen;
debugLogA("Received Xtraz Notify Response");
@@ -218,7 +218,7 @@ void CIcqProto::handleXtrazNotifyResponse(DWORD dwUin, MCONTACT hContact, WORD w
char *szXName, *szOldXName;
szNode += 7;
*szEnd = '\0';
- szXName = DemangleXml(szNode, strlennull(szNode));
+ szXName = DemangleXml(szNode, mir_strlen(szNode));
// check if the name changed
szOldXName = getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, NULL);
if (strcmpnull(szOldXName, szXName))
@@ -234,7 +234,7 @@ void CIcqProto::handleXtrazNotifyResponse(DWORD dwUin, MCONTACT hContact, WORD w
char *szXMsg, *szOldXMsg;
szNode += 6;
*szEnd = '\0';
- szXMsg = DemangleXml(szNode, strlennull(szNode));
+ szXMsg = DemangleXml(szNode, mir_strlen(szNode));
// check if the decription changed
szOldXMsg = getSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, NULL);
if (strcmpnull(szOldXMsg, szXMsg))
@@ -263,12 +263,10 @@ void CIcqProto::handleXtrazNotifyResponse(DWORD dwUin, MCONTACT hContact, WORD w
else debugLogA("Error: Invalid Xtraz Notify response");
}
-static char* getXmlPidItem(const char* szData, int nLen)
+static char* getXmlPidItem(const char* szData, size_t nLen)
{
- const char *szPid, *szEnd;
-
- szPid = strstrnull(szData, "<PID>");
- szEnd = strstrnull(szData, "</PID>");
+ const char *szPid = strstrnull(szData, "<PID>");
+ const char *szEnd = strstrnull(szData, "</PID>");
if (szPid && szEnd) {
szPid += 5;
@@ -278,7 +276,7 @@ static char* getXmlPidItem(const char* szData, int nLen)
}
-void CIcqProto::handleXtrazInvitation(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, int nMsgLen, BOOL bThruDC)
+void CIcqProto::handleXtrazInvitation(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, size_t nMsgLen, BOOL bThruDC)
{
MCONTACT hContact = HContactFromUIN(dwUin, NULL);
if (hContact) // user sent us xtraz, he supports it
@@ -294,7 +292,7 @@ void CIcqProto::handleXtrazInvitation(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WO
}
-void CIcqProto::handleXtrazData(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, int nMsgLen, BOOL bThruDC)
+void CIcqProto::handleXtrazData(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szMsg, size_t nMsgLen, BOOL bThruDC)
{
MCONTACT hContact;
char* szPluginID;
@@ -355,30 +353,24 @@ void CIcqProto::handleXtrazData(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCo
// Functions really sending Xtraz stuff
DWORD CIcqProto::SendXtrazNotifyRequest(MCONTACT hContact, char* szQuery, char* szNotify, int bForced)
{
- char *szQueryBody;
- char *szNotifyBody;
DWORD dwUin;
- int nBodyLen;
- char *szBody;
- DWORD dwCookie;
-
if (getContactUid(hContact, &dwUin, NULL))
return 0; // Invalid contact
if (!CheckContactCapabilities(hContact, CAPF_XTRAZ) && !bForced)
return 0; // Contact does not support xtraz, do not send anything
- szQueryBody = MangleXml(szQuery, strlennull(szQuery));
- szNotifyBody = MangleXml(szNotify, strlennull(szNotify));
- nBodyLen = strlennull(szQueryBody) + strlennull(szNotifyBody) + 41;
- szBody = (char*)_alloca(nBodyLen);
+ char *szQueryBody = MangleXml(szQuery, mir_strlen(szQuery));
+ char *szNotifyBody = MangleXml(szNotify, mir_strlen(szNotify));
+ size_t nBodyLen = mir_strlen(szQueryBody) + mir_strlen(szNotifyBody) + 41;
+ char *szBody = (char*)_alloca(nBodyLen);
nBodyLen = mir_snprintf(szBody, nBodyLen, "<N><QUERY>%s</QUERY><NOTIFY>%s</NOTIFY></N>", szQueryBody, szNotifyBody);
SAFE_FREE((void**)&szQueryBody);
SAFE_FREE((void**)&szNotifyBody);
// Set up the ack type
cookie_message_data *pCookieData = CreateMessageCookie(MTYPE_SCRIPT_NOTIFY, ACKTYPE_CLIENT);
- dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
+ DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
// have we a open DC, send through that
if (m_bDCMsgEnabled && IsDirectConnectionOpen(hContact, DIRECTCONN_STANDARD, 0))
@@ -390,10 +382,10 @@ DWORD CIcqProto::SendXtrazNotifyRequest(MCONTACT hContact, char* szQuery, char*
}
-void CIcqProto::SendXtrazNotifyResponse(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szResponse, int nResponseLen, BOOL bThruDC)
+void CIcqProto::SendXtrazNotifyResponse(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szResponse, size_t nResponseLen, BOOL bThruDC)
{
char *szResBody = MangleXml(szResponse, nResponseLen);
- int nBodyLen = strlennull(szResBody) + 21;
+ size_t nBodyLen = mir_strlen(szResBody) + 21;
char *szBody = (char*)_alloca(nBodyLen);
MCONTACT hContact = HContactFromUIN(dwUin, NULL);
diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp
index 52ff1339da..4e1f00b779 100644
--- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp
+++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp
@@ -107,7 +107,7 @@ INT_PTR CIcqProto::GetInfoSetting(WPARAM hContact, LPARAM lParam)
}
}
else {
- char *savePtr = dbv.pszVal ? strcpy((char*)_alloca(strlennull(dbv.pszVal) + 1), dbv.pszVal) : NULL;
+ char *savePtr = dbv.pszVal ? strcpy((char*)_alloca(mir_strlen(dbv.pszVal) + 1), dbv.pszVal) : NULL;
if (!mir_utf8decode(savePtr, &cgs->pValue->pwszVal))
rc = 1;
}
@@ -157,15 +157,14 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM lParam)
return 0;
PBYTE buf = NULL;
- int buflen = 0;
- BYTE b;
+ size_t buflen = 0;
// userinfo
ppackTLVWord(&buf, &buflen, 0x1C2, (WORD)GetACP());
if (wParam & CIXT_CONTACT) { // contact information
BYTE *pBlock = NULL;
- int cbBlock = 0;
+ size_t cbBlock = 0;
int nItems = 0;
// Emails
@@ -193,7 +192,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM lParam)
}
if (wParam & CIXT_MORE) {
- b = getByte("Gender", 0);
+ BYTE b = getByte("Gender", 0);
ppackTLVByte(&buf, &buflen, 0x82, (BYTE)(b ? (b == 'M' ? 2 : 1) : 0));
ppackTLVDateFromDB(&buf, &buflen, "BirthYear", "BirthMonth", "BirthDay", 0x1A4);
@@ -207,7 +206,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM lParam)
if (wParam & CIXT_WORK) {
BYTE *pBlock = NULL;
- int cbBlock = 0;
+ size_t cbBlock = 0;
int nItems = 1;
// Jobs
@@ -229,7 +228,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM lParam)
if (wParam & CIXT_EDUCATION) {
BYTE *pBlock = NULL;
- int cbBlock = 0;
+ size_t cbBlock = 0;
int nItems = 1;
// Studies
@@ -242,7 +241,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM lParam)
if (wParam & CIXT_LOCATION) {
BYTE *pBlock = NULL;
- int cbBlock = 0;
+ size_t cbBlock = 0;
int nItems = 1;
// Home Address
@@ -271,7 +270,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM lParam)
if (wParam & CIXT_BACKGROUND) {
BYTE *pBlock = NULL;
- int cbBlock = 0;
+ size_t cbBlock = 0;
int nItems = 0;
// Interests
@@ -282,7 +281,7 @@ INT_PTR CIcqProto::ChangeInfoEx(WPARAM wParam, LPARAM lParam)
ppackTLVBlockItems(&buf, &buflen, 0x122, &nItems, &pBlock, (WORD*)&cbBlock, FALSE);
}
- DWORD dwCookie = icq_changeUserDirectoryInfoServ(buf, (WORD)buflen, DIRECTORYREQUEST_UPDATEOWNER);
+ DWORD dwCookie = icq_changeUserDirectoryInfoServ(buf, buflen, DIRECTORYREQUEST_UPDATEOWNER);
SAFE_FREE((void**)&buf);
@@ -587,7 +586,7 @@ MCONTACT CIcqProto::AddToListByUID(const char *szUID, DWORD dwFlags)
/////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::ICQAddRecvEvent(MCONTACT hContact, WORD wType, PROTORECVEVENT* pre, DWORD cbBlob, PBYTE pBlob, DWORD flags)
+void CIcqProto::ICQAddRecvEvent(MCONTACT hContact, WORD wType, PROTORECVEVENT* pre, size_t cbBlob, PBYTE pBlob, DWORD flags)
{
if (pre->flags & PREF_CREATEREAD)
flags |= DBEF_READ;
@@ -670,12 +669,12 @@ INT_PTR icq_getEventTextMissedMessage(WPARAM wParam, LPARAM lParam)
}
if (pEvent->datatype == DBVT_WCHAR) {
WCHAR *pwszText;
- int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, strlennull(pszText), NULL, 0);
+ int wchars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, (int)mir_strlen(pszText), NULL, 0);
pwszText = (WCHAR*)_alloca((wchars + 1) * sizeof(WCHAR));
pwszText[wchars] = 0;
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, strlennull(pszText), pwszText, wchars);
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszText, (int)mir_strlen(pszText), pwszText, wchars);
nRetVal = (INT_PTR)mir_wstrdup(TranslateW(pwszText));
}
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
index b1f5cb1af2..9cc7a54354 100644
--- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
+++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
@@ -56,8 +56,7 @@ char* FindFilePathContainer(const char **files, int iFile, char *szContainer)
if (szThisFile != szFileName) { // find an earlier subdirectory to be used as a container
for (int i = iFile - 1; i >= 0; i--) {
- int len = strlennull(files[i]);
-
+ size_t len = mir_strlen(files[i]);
if (!_strnicmp(files[i], szThisFile, len) && (szThisFile[len] == '\\' || szThisFile[len] == '/')) {
const char *pszLastBackslash;
@@ -323,7 +322,7 @@ void CIcqProto::ReleaseOscarListener(oscar_listener **pListener)
// Miranda FT interface handlers & services
/////////////////////////////
-void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand)
+void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand)
{
MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL);
@@ -392,7 +391,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *sz
else
str = null_strdup(str);
// eliminate HTML tags
- pszDescription = EliminateHtml(str, strlennull(str));
+ pszDescription = EliminateHtml(str, mir_strlen(str));
bTag = strstrnull(pszDescription, "<DESC>");
if (bTag) { // take special Description - ICQJ's extension
@@ -418,7 +417,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *sz
}
}
}
- if (!strlennull(pszDescription)) {
+ if (!mir_strlen(pszDescription)) {
SAFE_FREE(&pszDescription);
pszDescription = ICQTranslateUtf(LPGEN("No description given"));
}
@@ -465,7 +464,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *sz
else pszFileName = ansi_to_utf8(pszFileName);
if (ft->wFilesCount == 1) { // Filename - use for DB event
- char *szFileName = (char*)_alloca(strlennull(pszFileName) + 1);
+ char *szFileName = (char*)_alloca(mir_strlen(pszFileName) + 1);
strcpy(szFileName, pszFileName);
SAFE_FREE(&pszFileName);
@@ -497,10 +496,10 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *sz
ft->fileId = -1;
// Send chain event
- char *szBlob = (char*)_alloca(sizeof(DWORD) + strlennull(pszFileName) + strlennull(pszDescription) + 2);
+ char *szBlob = (char*)_alloca(sizeof(DWORD) + mir_strlen(pszFileName) + mir_strlen(pszDescription) + 2);
*(PDWORD)szBlob = 0;
strcpy(szBlob + sizeof(DWORD), pszFileName);
- strcpy(szBlob + sizeof(DWORD) + strlennull(pszFileName) + 1, pszDescription);
+ strcpy(szBlob + sizeof(DWORD) + mir_strlen(pszFileName) + 1, pszDescription);
TCHAR* ptszFileName = mir_utf8decodeT(pszFileName);
@@ -621,7 +620,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *sz
else debugLogA("Error: Unknown wCommand=0x%x in OFT request", wCommand);
}
-void CIcqProto::handleRecvServResponseOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, void* ft)
+void CIcqProto::handleRecvServResponseOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, void* ft)
{
WORD wDataLen;
@@ -814,7 +813,7 @@ HANDLE CIcqProto::oftInitTransfer(MCONTACT hContact, DWORD dwUin, char* szUid, c
}
else { // check if transfering one directory
char *szFirstDiv, *szFirstDir = ft->file_containers[0];
- int nFirstDirLen;
+ size_t nFirstDirLen;
// default is no root dir
pszFiles = "";
@@ -822,7 +821,7 @@ HANDLE CIcqProto::oftInitTransfer(MCONTACT hContact, DWORD dwUin, char* szUid, c
if ((szFirstDiv = strstrnull(szFirstDir, "\\")) || (szFirstDiv = strstrnull(szFirstDir, "/")))
nFirstDirLen = szFirstDiv - szFirstDir;
else
- nFirstDirLen = strlennull(szFirstDir);
+ nFirstDirLen = mir_strlen(szFirstDir);
if (nFirstDirLen) { // got root dir from first container, check if others are only sub-dirs
for (i = 0; i < ft->containerCount; i++) {
@@ -874,7 +873,7 @@ HANDLE CIcqProto::oftFileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR
ft->szSavePath = tchar_to_utf8(szPath);
if (ft->szThisPath) { // Append Directory name to the save path, when transfering a directory
- ft->szSavePath = (char*)SAFE_REALLOC(ft->szSavePath, strlennull(ft->szSavePath) + strlennull(ft->szThisPath) + 4);
+ ft->szSavePath = (char*)SAFE_REALLOC(ft->szSavePath, mir_strlen(ft->szSavePath) + mir_strlen(ft->szThisPath) + 4);
NormalizeBackslash(ft->szSavePath);
strcat(ft->szSavePath, ft->szThisPath);
NormalizeBackslash(ft->szSavePath);
@@ -1420,7 +1419,7 @@ int CIcqProto::oft_handlePackets(oscar_connection *oc, BYTE *buf, int len)
#ifdef _DEBUG
NetLog_Direct("OFT2: Type %u, Length %u bytes", datatype, datalen);
#endif
- handleOFT2FramePacket(oc, datatype, pBuf, (WORD)(datalen - 8));
+ handleOFT2FramePacket(oc, datatype, pBuf, datalen-8);
/* Increase pointers so we can check for more data */
buf += datalen;
@@ -1623,7 +1622,7 @@ int CIcqProto::oft_handleFileData(oscar_connection *oc, BYTE *buf, int len)
return bytesUsed;
}
-void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE *pBuffer, WORD wLen)
+void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE *pBuffer, size_t wLen)
{
oscar_filetransfer *ft = oc->ft;
DWORD dwID1;
@@ -1729,7 +1728,7 @@ void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE
ft->szThisFile = ansi_to_utf8(ft->rawFileName);
// convert dir markings to normal backslashes
- for (int i = 0; i < strlennull(ft->szThisFile); i++)
+ for (int i = 0; i < mir_strlen(ft->szThisFile); i++)
if (ft->szThisFile[i] == 0x01)
ft->szThisFile[i] = '\\';
@@ -1760,7 +1759,7 @@ void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE
break;
}
- char *szFullPath = (char*)SAFE_MALLOC(strlennull(ft->szSavePath) + strlennull(ft->szThisPath) + strlennull(ft->szThisFile) + 3);
+ char *szFullPath = (char*)SAFE_MALLOC(mir_strlen(ft->szSavePath) + mir_strlen(ft->szThisPath) + mir_strlen(ft->szThisFile) + 3);
strcpy(szFullPath, ft->szSavePath);
NormalizeBackslash(szFullPath);
strcat(szFullPath, ft->szThisPath);
@@ -1929,12 +1928,12 @@ void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE
void CIcqProto::proxy_sendInitTunnel(oscar_connection *oc)
{
icq_packet packet;
- WORD wLen = 39 + getUINLen(m_dwLocalUIN);
+ size_t wLen = 39 + getUINLen(m_dwLocalUIN);
- packet.wLen = wLen;
+ packet.wLen = WORD(wLen);
init_generic_packet(&packet, 2);
- packWord(&packet, wLen);
+ packWord(&packet, WORD(wLen));
packWord(&packet, OSCAR_PROXY_VERSION);
packWord(&packet, 0x02); // wCommand
packDWord(&packet, 0); // Unknown
@@ -1951,12 +1950,12 @@ void CIcqProto::proxy_sendInitTunnel(oscar_connection *oc)
void CIcqProto::proxy_sendJoinTunnel(oscar_connection *oc, WORD wPort)
{
icq_packet packet;
- WORD wLen = 41 + getUINLen(m_dwLocalUIN);
+ size_t wLen = 41 + getUINLen(m_dwLocalUIN);
- packet.wLen = wLen;
+ packet.wLen = WORD(wLen);
init_generic_packet(&packet, 2);
- packWord(&packet, wLen);
+ packWord(&packet, WORD(wLen));
packWord(&packet, OSCAR_PROXY_VERSION);
packWord(&packet, 0x04); // wCommand
packDWord(&packet, 0); // Unknown
@@ -2001,7 +2000,7 @@ void CIcqProto::oft_sendFileData(oscar_connection *oc)
icq_packet packet;
packet.wLen = bytesRead;
init_generic_packet(&packet, 0);
- packBuffer(&packet, buf, (WORD)bytesRead); // we are sending raw data
+ packBuffer(&packet, buf, bytesRead); // we are sending raw data
sendOscarPacket(oc, &packet);
ft->qwBytesDone += bytesRead;
@@ -2045,13 +2044,13 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc)
// create full relative filename
char* szThisContainer = ft->files[ft->iCurrentFile].szContainer;
- char *pszThisFileName = (char*)SAFE_MALLOC(strlennull(ft->szThisFile) + strlennull(szThisContainer) + 4);
+ char *pszThisFileName = (char*)SAFE_MALLOC(mir_strlen(ft->szThisFile) + mir_strlen(szThisContainer) + 4);
strcpy(pszThisFileName, szThisContainer);
NormalizeBackslash(pszThisFileName);
strcat(pszThisFileName, ExtractFileName(ft->szThisFile));
// convert backslashes to dir markings
- for (int i = 0; i < strlennull(pszThisFileName); i++)
+ for (int i = 0; i < mir_strlen(pszThisFileName); i++)
if (pszThisFileName[i] == '\\' || pszThisFileName[i] == '/')
pszThisFileName[i] = 0x01;
@@ -2077,9 +2076,9 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc)
ft->dwRecvFileCheck = 0xFFFF0000;
SAFE_FREE((void**)&ft->rawFileName);
- if (IsUSASCII(pszThisFileName, strlennull(pszThisFileName))) {
+ if (IsUSASCII(pszThisFileName, mir_strlen(pszThisFileName))) {
ft->wEncoding = 0; // ascii
- ft->cbRawFileName = strlennull(pszThisFileName) + 1;
+ ft->cbRawFileName = WORD(mir_strlen(pszThisFileName) + 1);
if (ft->cbRawFileName < 64)
ft->cbRawFileName = 64;
ft->rawFileName = (char*)SAFE_MALLOC(ft->cbRawFileName);
@@ -2090,16 +2089,16 @@ void CIcqProto::oft_sendPeerInit(oscar_connection *oc)
ft->wEncoding = 2; // ucs-2
WCHAR *pwsThisFile = make_unicode_string(pszThisFileName);
SAFE_FREE((void**)&pszThisFileName);
- ft->cbRawFileName = WORD(strlennull(pwsThisFile) * sizeof(WCHAR)) + 2;
+ ft->cbRawFileName = WORD(mir_wstrlen(pwsThisFile) * sizeof(WCHAR)) + 2;
if (ft->cbRawFileName < 64)
ft->cbRawFileName = 64;
ft->rawFileName = (char*)SAFE_MALLOC(ft->cbRawFileName);
// convert to LE ordered string
BYTE *pwsThisFileBuf = (BYTE*)pwsThisFile; // need this - unpackWideString moves the address!
- unpackWideString(&pwsThisFileBuf, (WCHAR*)ft->rawFileName, (WORD)(strlennull(pwsThisFile) * sizeof(WCHAR)));
+ unpackWideString(&pwsThisFileBuf, (WCHAR*)ft->rawFileName, mir_wstrlen(pwsThisFile) * sizeof(WCHAR));
SAFE_FREE((void**)&pwsThisFile);
}
- ft->wFilesLeft = (WORD)(ft->wFilesCount - ft->iCurrentFile);
+ ft->wFilesLeft = WORD(ft->wFilesCount - ft->iCurrentFile);
sendOFT2FramePacket(oc, OFT_TYPE_REQUEST);
}
@@ -2109,7 +2108,7 @@ void CIcqProto::sendOFT2FramePacket(oscar_connection *oc, WORD datatype)
oscar_filetransfer *ft = oc->ft;
icq_packet packet;
- packet.wLen = 192 + ft->cbRawFileName;
+ packet.wLen = WORD(192 + ft->cbRawFileName);
init_generic_packet(&packet, 0);
// Basic Oscar Frame
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.h b/protocols/IcqOscarJ/src/oscar_filetransfer.h
index 7ebc76e776..948bc1714d 100644
--- a/protocols/IcqOscarJ/src/oscar_filetransfer.h
+++ b/protocols/IcqOscarJ/src/oscar_filetransfer.h
@@ -100,7 +100,7 @@ struct oscar_filetransfer: public basic_filetransfer
BYTE rawDummy[69];
BYTE rawMacInfo[16];
WORD wEncoding, wSubEncoding;
- WORD cbRawFileName;
+ size_t cbRawFileName;
char *rawFileName;
// helper data
DWORD64 qwFileBytesDone;
diff --git a/protocols/IcqOscarJ/src/stdpackets.cpp b/protocols/IcqOscarJ/src/stdpackets.cpp
index e8f884a222..b8295252dd 100644
--- a/protocols/IcqOscarJ/src/stdpackets.cpp
+++ b/protocols/IcqOscarJ/src/stdpackets.cpp
@@ -34,9 +34,9 @@ extern const int moodXStatus[];
*/
// This is the part of the message header that is common for all message channels
-static void packServMsgSendHeader(icq_packet *p, DWORD dwSequence, DWORD dwID1, DWORD dwID2, DWORD dwUin, const char *szUID, WORD wFmt, WORD wLen)
+static void packServMsgSendHeader(icq_packet *p, DWORD dwSequence, DWORD dwID1, DWORD dwID2, DWORD dwUin, const char *szUID, WORD wFmt, size_t wLen)
{
- serverPacketInit(p, (WORD)(21 + getUIDLen(dwUin, szUID) + wLen));
+ serverPacketInit(p, 21 + getUIDLen(dwUin, szUID) + wLen);
packFNACHeader(p, ICQ_MSG_FAMILY, ICQ_MSG_SRV_SEND, 0, dwSequence | ICQ_MSG_SRV_SEND << 0x10);
packLEDWord(p, dwID1); // Msg ID part 1
packLEDWord(p, dwID2); // Msg ID part 2
@@ -44,34 +44,34 @@ static void packServMsgSendHeader(icq_packet *p, DWORD dwSequence, DWORD dwID1,
packUID(p, dwUin, szUID); // User ID
}
-static void packServIcqExtensionHeader(icq_packet *p, CIcqProto *ppro, WORD wLen, WORD wType, WORD wSeq, WORD wCmd = ICQ_META_CLI_REQUEST)
+static void packServIcqExtensionHeader(icq_packet *p, CIcqProto *ppro, size_t wLen, WORD wType, WORD wSeq, WORD wCmd = ICQ_META_CLI_REQUEST)
{
- serverPacketInit(p, (WORD)(24 + wLen));
+ serverPacketInit(p, 24 + wLen);
packFNACHeader(p, ICQ_EXTENSIONS_FAMILY, ICQ_META_CLI_REQUEST, 0, wSeq | (wCmd << 0x10));
- packWord(p, 0x01); // TLV type 1
- packWord(p, (WORD)(10 + wLen)); // TLV len
- packLEWord(p, (WORD)(8 + wLen)); // Data chunk size (TLV.Length-2)
+ packWord(p, 0x01); // TLV type 1
+ packWord(p, WORD(10 + wLen)); // TLV len
+ packLEWord(p, WORD(8 + wLen)); // Data chunk size (TLV.Length-2)
packLEDWord(p, ppro->m_dwLocalUIN); // My UIN
- packLEWord(p, wType); // Request type
+ packLEWord(p, wType); // Request type
packWord(p, wSeq);
}
-static void packServIcqDirectoryHeader(icq_packet *p, CIcqProto *ppro, WORD wLen, WORD wType, WORD wCommand, WORD wSeq, WORD wSubCommand = ICQ_META_CLI_REQUEST)
+static void packServIcqDirectoryHeader(icq_packet *p, CIcqProto *ppro, size_t wLen, WORD wType, WORD wCommand, WORD wSeq, WORD wSubCommand = ICQ_META_CLI_REQUEST)
{
packServIcqExtensionHeader(p, ppro, wLen + 0x1E, CLI_META_INFO_REQ, wSeq, wSubCommand);
packLEWord(p, wType);
- packLEWord(p, wLen + 0x1A);
+ packLEWord(p, WORD(wLen + 0x1A));
packFNACHeader(p, 0x5b9, wCommand, 0, 0, 2);
packWord(p, 0);
packWord(p, (WORD)GetACP());
packDWord(p, 2);
}
-static void packServTLV5HeaderBasic(icq_packet *p, WORD wLen, DWORD ID1, DWORD ID2, WORD wCommand, const plugin_guid pGuid)
+static void packServTLV5HeaderBasic(icq_packet *p, size_t wLen, DWORD ID1, DWORD ID2, WORD wCommand, const plugin_guid pGuid)
{
// TLV(5) header
packWord(p, 0x05); // Type
- packWord(p, (WORD)(26 + wLen)); // Len
+ packWord(p, WORD(26 + wLen)); // Len
// TLV(5) data
packWord(p, wCommand); // Command
packLEDWord(p, ID1); // msgid1
@@ -79,18 +79,18 @@ static void packServTLV5HeaderBasic(icq_packet *p, WORD wLen, DWORD ID1, DWORD I
packGUID(p, pGuid); // capabilities (4 dwords)
}
-static void packServTLV5HeaderMsg(icq_packet *p, WORD wLen, DWORD ID1, DWORD ID2, WORD wAckType)
+static void packServTLV5HeaderMsg(icq_packet *p, size_t wLen, DWORD ID1, DWORD ID2, WORD wAckType)
{
- packServTLV5HeaderBasic(p, (WORD)(wLen + 10), ID1, ID2, 0, MCAP_SRV_RELAY_FMT);
+ packServTLV5HeaderBasic(p, wLen + 10, ID1, ID2, 0, MCAP_SRV_RELAY_FMT);
packTLVWord(p, 0x0A, wAckType); // TLV: 0x0A Acktype: 1 for normal, 2 for ack
packDWord(p, 0x000F0000); // TLV: 0x0F empty
}
-static void packServTLV2711Header(icq_packet *packet, WORD wCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD X1, WORD X2, int nLen)
+static void packServTLV2711Header(icq_packet *packet, WORD wCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD X1, WORD X2, size_t nLen)
{
packWord(packet, 0x2711); // Type
- packWord(packet, (WORD)(51 + nLen)); // Len
+ packWord(packet, WORD(51 + nLen)); // Len
// TLV(0x2711) data
packLEWord(packet, 0x1B); // Unknown
packByte(packet, (BYTE)wVersion); // Client (message) version
@@ -112,21 +112,21 @@ static void packServTLV2711Header(icq_packet *packet, WORD wCookie, WORD wVersio
static void packServDCInfo(icq_packet *p, CIcqProto* ppro, BOOL bEmpty)
{
packTLVDWord(p, 0x03, bEmpty ? 0 : ppro->getDword("RealIP", 0)); // TLV: 0x03 DWORD IP
- packTLVWord(p, 0x05, (WORD)(bEmpty ? 0 : ppro->wListenPort)); // TLV: 0x05 Listen port
+ packTLVWord(p, 0x05, WORD(bEmpty ? 0 : ppro->wListenPort)); // TLV: 0x05 Listen port
}
-static void packServChannel2Header(icq_packet *p, CIcqProto* ppro, DWORD dwUin, WORD wLen, DWORD dwID1, DWORD dwID2, DWORD dwCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD wPriority, int isAck, int includeDcInfo, BYTE bRequestServerAck)
+static void packServChannel2Header(icq_packet *p, CIcqProto* ppro, DWORD dwUin, size_t wLen, DWORD dwID1, DWORD dwID2, DWORD dwCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD wPriority, int isAck, int includeDcInfo, BYTE bRequestServerAck)
{
- packServMsgSendHeader(p, dwCookie, dwID1, dwID2, dwUin, NULL, 0x0002, (WORD)(wLen + 95 + (bRequestServerAck ? 4 : 0) + (includeDcInfo ? 14 : 0)));
+ packServMsgSendHeader(p, dwCookie, dwID1, dwID2, dwUin, NULL, 0x0002, wLen + 95 + (bRequestServerAck ? 4 : 0) + (includeDcInfo ? 14 : 0));
packWord(p, 0x05); // TLV type
- packWord(p, (WORD)(wLen + 91 + (includeDcInfo ? 14 : 0))); /* TLV len */
- packWord(p, (WORD)(isAck ? 2 : 0)); /* not aborting anything */
+ packWord(p, WORD(wLen + 91 + (includeDcInfo ? 14 : 0))); /* TLV len */
+ packWord(p, WORD(isAck ? 2 : 0)); /* not aborting anything */
packLEDWord(p, dwID1); // Msg ID part 1
packLEDWord(p, dwID2); // Msg ID part 2
packGUID(p, MCAP_SRV_RELAY_FMT); /* capability (4 dwords) */
packDWord(p, 0x000A0002); // TLV: 0x0A WORD: 1 for normal, 2 for ack
- packWord(p, (WORD)(isAck ? 2 : 1));
+ packWord(p, isAck ? 2 : 1);
if (includeDcInfo)
packServDCInfo(p, ppro, FALSE);
@@ -136,9 +136,9 @@ static void packServChannel2Header(icq_packet *p, CIcqProto* ppro, DWORD dwUin,
packServTLV2711Header(p, (WORD)dwCookie, wVersion, bMsgType, bMsgFlags, (WORD)MirandaStatusToIcq(ppro->m_iStatus), wPriority, wLen);
}
-static void packServAdvancedReply(icq_packet *p, DWORD dwUin, const char *szUid, DWORD dwID1, DWORD dwID2, WORD wCookie, WORD wLen)
+static void packServAdvancedReply(icq_packet *p, DWORD dwUin, const char *szUid, DWORD dwID1, DWORD dwID2, WORD wCookie, size_t wLen)
{
- serverPacketInit(p, (WORD)(getUIDLen(dwUin, szUid) + 23 + wLen));
+ serverPacketInit(p, getUIDLen(dwUin, szUid) + 23 + wLen);
packFNACHeader(p, ICQ_MSG_FAMILY, ICQ_MSG_RESPONSE, 0, ICQ_MSG_RESPONSE << 0x10 | (wCookie & 0x7FFF));
packLEDWord(p, dwID1); // Msg ID part 1
packLEDWord(p, dwID2); // Msg ID part 2
@@ -147,9 +147,9 @@ static void packServAdvancedReply(icq_packet *p, DWORD dwUin, const char *szUid,
packWord(p, 0x03); // Msg specific formating
}
-static void packServAdvancedMsgReply(icq_packet *p, DWORD dwUin, const char *szUid, DWORD dwID1, DWORD dwID2, WORD wCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, WORD wLen)
+static void packServAdvancedMsgReply(icq_packet *p, DWORD dwUin, const char *szUid, DWORD dwID1, DWORD dwID2, WORD wCookie, WORD wVersion, BYTE bMsgType, BYTE bMsgFlags, size_t wLen)
{
- packServAdvancedReply(p, dwUin, szUid, dwID1, dwID2, wCookie, (WORD)(wLen + 51));
+ packServAdvancedReply(p, dwUin, szUid, dwID1, dwID2, wCookie, wLen + 51);
packLEWord(p, 0x1B); // Unknown
packByte(p, (BYTE)wVersion); // Protocol version
@@ -196,7 +196,7 @@ void CIcqProto::icq_sendCloseConnection()
sendServPacket(&packet);
}
-void CIcqProto::icq_requestnewfamily(WORD wFamily, void (CIcqProto::*familyhandler)(HANDLE hConn, char* cookie, WORD cookieLen))
+void CIcqProto::icq_requestnewfamily(WORD wFamily, void (CIcqProto::*familyhandler)(HANDLE hConn, char* cookie, size_t cookieLen))
{
int bRequestSSL = m_bSecureConnection && (wFamily != ICQ_AVATAR_FAMILY); // Avatar servers does not support SSL
@@ -237,7 +237,7 @@ void CIcqProto::icq_setidle(int bAllow)
void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote)
{
char *szCurrentStatusNote = szStatusNote ? getSettingStringUtf(NULL, DBSETTING_STATUS_NOTE, NULL) : NULL;
- WORD wStatusMoodLen = 0, wStatusNoteLen = 0, wSessionDataLen = 0;
+ size_t wStatusMoodLen = 0, wStatusNoteLen = 0, wSessionDataLen = 0;
char *szMoodData = NULL;
if (szStatusNote && strcmpnull(szCurrentStatusNote, szStatusNote)) { // status note was changed, update now
@@ -247,8 +247,8 @@ void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote)
db_free(&dbv);
- wStatusNoteLen = strlennull(szStatusNote);
- wStatusMoodLen = strlennull(szMoodData);
+ wStatusNoteLen = mir_strlen(szStatusNote);
+ wStatusMoodLen = mir_strlen(szMoodData);
wSessionDataLen = (wStatusNoteLen ? wStatusNoteLen + 4 : 0) + 4 + wStatusMoodLen + 4;
}
@@ -256,7 +256,7 @@ void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote)
// Pack data in packet
icq_packet packet;
- serverPacketInit(&packet, (WORD)(18 + (wSessionDataLen ? wSessionDataLen + 4 : 0)));
+ serverPacketInit(&packet, 18 + (wSessionDataLen ? wSessionDataLen + 4 : 0));
packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_SET_STATUS);
packWord(&packet, 0x06); // TLV 6
packWord(&packet, 0x04); // TLV length
@@ -264,18 +264,18 @@ void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote)
packWord(&packet, wStatus); // Status
if (wSessionDataLen) {
packWord(&packet, 0x1D); // TLV 1D
- packWord(&packet, wSessionDataLen); // TLV length
+ packWord(&packet, WORD(wSessionDataLen)); // TLV length
packWord(&packet, 0x02); // Item Type
if (wStatusNoteLen) {
packWord(&packet, 0x400 | (WORD)(wStatusNoteLen + 4)); // Flags + Item Length
- packWord(&packet, wStatusNoteLen); // Text Length
+ packWord(&packet, WORD(wStatusNoteLen)); // Text Length
packBuffer(&packet, (LPBYTE)szStatusNote, wStatusNoteLen);
packWord(&packet, 0); // Encoding not specified (utf-8 is default)
}
else packWord(&packet, 0); // Flags + Item Length
packWord(&packet, 0x0E); // Item Type
- packWord(&packet, wStatusMoodLen); // Flags + Item Length
+ packWord(&packet, WORD(wStatusMoodLen)); // Flags + Item Length
if (wStatusMoodLen)
packBuffer(&packet, (LPBYTE)szMoodData, wStatusMoodLen); // Mood
@@ -291,17 +291,17 @@ void CIcqProto::icq_setstatus(WORD wStatus, const char *szStatusNote)
DWORD CIcqProto::icq_SendChannel1Message(DWORD dwUin, char *szUID, MCONTACT hContact, char *pszText, cookie_message_data *pCookieData)
{
- WORD wMessageLen = strlennull(pszText);
+ size_t wMessageLen = mir_strlen(pszText);
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
- WORD wPacketLength = (pCookieData->nAckType == ACKTYPE_SERVER) ? 25 : 21;
+ size_t wPacketLength = (pCookieData->nAckType == ACKTYPE_SERVER) ? 25 : 21;
// Pack the standard header
icq_packet packet;
- packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUID, 1, (WORD)(wPacketLength + wMessageLen));
+ packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUID, 1, wPacketLength + wMessageLen);
// Pack first TLV
packWord(&packet, 0x0002); // TLV(2)
- packWord(&packet, (WORD)(wMessageLen + 13)); // TLV len
+ packWord(&packet, WORD(wMessageLen + 13)); // TLV len
// Pack client features
packWord(&packet, 0x0501); // TLV(501)
@@ -310,10 +310,10 @@ DWORD CIcqProto::icq_SendChannel1Message(DWORD dwUin, char *szUID, MCONTACT hCon
// Pack text TLV
packWord(&packet, 0x0101); // TLV(2)
- packWord(&packet, (WORD)(wMessageLen + 4)); // TLV len
+ packWord(&packet, WORD(wMessageLen + 4)); // TLV len
packWord(&packet, 0x0003); // Message charset number, again copied from ICQ Lite
packWord(&packet, 0x0000); // Message charset subset
- packBuffer(&packet, (LPBYTE)pszText, (WORD)(wMessageLen)); // Message text
+ packBuffer(&packet, (LPBYTE)pszText, wMessageLen); // Message text
// Pack request server ack TLV
if (pCookieData->nAckType == ACKTYPE_SERVER)
@@ -330,18 +330,18 @@ DWORD CIcqProto::icq_SendChannel1Message(DWORD dwUin, char *szUID, MCONTACT hCon
DWORD CIcqProto::icq_SendChannel1MessageW(DWORD dwUin, char *szUID, MCONTACT hContact, WCHAR *pszText, cookie_message_data *pCookieData)
{
- WORD wMessageLen = WORD(strlennull(pszText) * sizeof(WCHAR));
+ WORD wMessageLen = WORD(mir_wstrlen(pszText) * sizeof(WCHAR));
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
WORD wPacketLength = (pCookieData->nAckType == ACKTYPE_SERVER) ? 26 : 22;
// Pack the standard header
icq_packet packet;
- packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUID, 1, (WORD)(wPacketLength + wMessageLen));
+ packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUID, 1, wPacketLength + wMessageLen);
// Pack first TLV
packWord(&packet, 0x0002); // TLV(2)
- packWord(&packet, (WORD)(wMessageLen + 14)); // TLV len
+ packWord(&packet, WORD(wMessageLen + 14)); // TLV len
// Pack client features
packWord(&packet, 0x0501); // TLV(501)
@@ -350,7 +350,7 @@ DWORD CIcqProto::icq_SendChannel1MessageW(DWORD dwUin, char *szUID, MCONTACT hCo
// Pack text TLV
packWord(&packet, 0x0101); // TLV(2)
- packWord(&packet, (WORD)(wMessageLen + 4)); // TLV len
+ packWord(&packet, WORD(wMessageLen + 4)); // TLV len
packWord(&packet, 0x0002); // Message charset number, again copied from ICQ 2003b
packWord(&packet, 0x0000); // Message charset subset
WCHAR *ppText = pszText; // we must convert the widestring
@@ -368,17 +368,17 @@ DWORD CIcqProto::icq_SendChannel1MessageW(DWORD dwUin, char *szUID, MCONTACT hCo
return dwCookie;
}
-DWORD CIcqProto::icq_SendChannel2Message(DWORD dwUin, MCONTACT hContact, const char *szMessage, int nBodyLen, WORD wPriority, cookie_message_data *pCookieData, char *szCap)
+DWORD CIcqProto::icq_SendChannel2Message(DWORD dwUin, MCONTACT hContact, const char *szMessage, size_t nBodyLen, WORD wPriority, cookie_message_data *pCookieData, char *szCap)
{
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
// Pack the standard header
icq_packet packet;
- packServChannel2Header(&packet, this, dwUin, (WORD)(nBodyLen + (szCap ? 53 : 11)), pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwCookie, ICQ_VERSION, (BYTE)pCookieData->bMessageType, 0,
+ packServChannel2Header(&packet, this, dwUin, nBodyLen + (szCap ? 53 : 11), pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwCookie, ICQ_VERSION, (BYTE)pCookieData->bMessageType, 0,
wPriority, 0, 0, (BYTE)((pCookieData->nAckType == ACKTYPE_SERVER) ? 1 : 0));
- packLEWord(&packet, (WORD)(nBodyLen + 1)); // Length of message
- packBuffer(&packet, (LPBYTE)szMessage, (WORD)(nBodyLen + 1)); // Message
+ packLEWord(&packet, WORD(nBodyLen + 1)); // Length of message
+ packBuffer(&packet, (LPBYTE)szMessage, nBodyLen + 1); // Message
packMsgColorInfo(&packet);
if (szCap) {
@@ -394,15 +394,15 @@ DWORD CIcqProto::icq_SendChannel2Message(DWORD dwUin, MCONTACT hContact, const c
return dwCookie;
}
-DWORD CIcqProto::icq_SendChannel2Contacts(DWORD dwUin, char *szUid, MCONTACT hContact, const char *pData, WORD wDataLen, const char *pNames, WORD wNamesLen, cookie_message_data *pCookieData)
+DWORD CIcqProto::icq_SendChannel2Contacts(DWORD dwUin, char *szUid, MCONTACT hContact, const char *pData, size_t wDataLen, const char *pNames, size_t wNamesLen, cookie_message_data *pCookieData)
{
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, pCookieData);
- WORD wPacketLength = wDataLen + wNamesLen + 0x12;
+ size_t wPacketLength = wDataLen + wNamesLen + 0x12;
// Pack the standard header
icq_packet packet;
- packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUid, 2, (WORD)(wPacketLength + ((pCookieData->nAckType == ACKTYPE_SERVER) ? 0x22 : 0x1E)));
+ packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, szUid, 2, wPacketLength + ((pCookieData->nAckType == ACKTYPE_SERVER) ? 0x22 : 0x1E));
packServTLV5HeaderBasic(&packet, wPacketLength, pCookieData->dwMsgID1, pCookieData->dwMsgID2, 0, MCAP_CONTACTS);
@@ -420,22 +420,22 @@ DWORD CIcqProto::icq_SendChannel2Contacts(DWORD dwUin, char *szUid, MCONTACT hCo
return dwCookie;
}
-DWORD CIcqProto::icq_SendChannel4Message(DWORD dwUin, MCONTACT hContact, BYTE bMsgType, WORD wMsgLen, const char *szMsg, cookie_message_data *pCookieData)
+DWORD CIcqProto::icq_SendChannel4Message(DWORD dwUin, MCONTACT hContact, BYTE bMsgType, size_t wMsgLen, const char *szMsg, cookie_message_data *pCookieData)
{
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
- WORD wPacketLength = (pCookieData->nAckType == ACKTYPE_SERVER) ? 28 : 24;
+ size_t wPacketLength = (pCookieData->nAckType == ACKTYPE_SERVER) ? 28 : 24;
// Pack the standard header
icq_packet packet;
- packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, NULL, 4, (WORD)(wPacketLength + wMsgLen));
+ packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, NULL, 4, wPacketLength + wMsgLen);
// Pack first TLV
packWord(&packet, 0x05); // TLV(5)
- packWord(&packet, (WORD)(wMsgLen + 16)); // TLV len
+ packWord(&packet, WORD(wMsgLen + 16)); // TLV len
packLEDWord(&packet, m_dwLocalUIN); // My UIN
packByte(&packet, bMsgType); // Message type
packByte(&packet, 0); // Message flags
- packLEWord(&packet, wMsgLen); // Message length
+ packLEWord(&packet, WORD(wMsgLen)); // Message length
packBuffer(&packet, (LPBYTE)szMsg, wMsgLen); // Message text
packMsgColorInfo(&packet);
@@ -483,18 +483,19 @@ void CIcqProto::sendOwnerInfoRequest(void)
sendServPacket(&packet);
}
-DWORD CIcqProto::sendUserInfoMultiRequest(BYTE *pRequestData, WORD wDataLen, int nItems)
+DWORD CIcqProto::sendUserInfoMultiRequest(BYTE *pRequestData, size_t dataLen, int nItems)
{
cookie_directory_data *pCookieData = (cookie_directory_data*)SAFE_MALLOC(sizeof(cookie_directory_data));
- if (!pCookieData) return 0; // Failure
- pCookieData->bRequestType = DIRECTORYREQUEST_INFOMULTI;
+ if (!pCookieData)
+ return 0; // Failure
+ pCookieData->bRequestType = DIRECTORYREQUEST_INFOMULTI;
DWORD dwCookie = AllocateCookie(CKT_DIRECTORY_QUERY, 0, NULL, (void*)pCookieData);
icq_packet packet;
- packServIcqDirectoryHeader(&packet, this, wDataLen + 2, META_DIRECTORY_QUERY, DIRECTORY_QUERY_MULTI_INFO, (WORD)dwCookie);
+ packServIcqDirectoryHeader(&packet, this, dataLen + 2, META_DIRECTORY_QUERY, DIRECTORY_QUERY_MULTI_INFO, (WORD)dwCookie);
packWord(&packet, nItems);
- packBuffer(&packet, pRequestData, wDataLen);
+ packBuffer(&packet, pRequestData, dataLen);
sendServPacket(&packet);
@@ -562,10 +563,10 @@ DWORD CIcqProto::icq_sendGetAimProfileServ(MCONTACT hContact, char* szUid)
pCookieData->bRequestType = REQUESTTYPE_PROFILE;
DWORD dwCookie = AllocateCookie(CKT_FAMILYSPECIAL, ICQ_LOCATION_REQ_USER_INFO, hContact, (void*)pCookieData);
- BYTE bUIDlen = strlennull(szUid);
+ BYTE bUIDlen = (BYTE)mir_strlen(szUid);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(13 + bUIDlen));
+ serverPacketInit(&packet, 13 + bUIDlen);
packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_REQ_USER_INFO, 0, dwCookie);
packWord(&packet, 0x01); // request profile info
packByte(&packet, bUIDlen);
@@ -629,13 +630,13 @@ DWORD CIcqProto::icq_sendGetAwayMsgServExt(MCONTACT hContact, DWORD dwUin, char
DWORD CIcqProto::icq_sendGetAimAwayMsgServ(MCONTACT hContact, char *szUID, int type)
{
- BYTE bUIDlen = strlennull(szUID);
+ BYTE bUIDlen = (BYTE)mir_strlen(szUID);
cookie_message_data *pCookieData = CreateMessageCookie(MTYPE_AUTOAWAY, (byte)type);
DWORD dwCookie = AllocateCookie(CKT_MESSAGE, 0, hContact, (void*)pCookieData);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(13 + bUIDlen));
+ serverPacketInit(&packet, 13 + bUIDlen);
packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_REQ_USER_INFO, 0, dwCookie);
packWord(&packet, 0x03);
packUID(&packet, 0, szUID);
@@ -649,7 +650,7 @@ DWORD CIcqProto::icq_sendGetAimAwayMsgServ(MCONTACT hContact, char *szUID, int t
void CIcqProto::icq_sendSetAimAwayMsgServ(const char *szMsg)
{
icq_packet packet;
- WORD wMsgLen = strlennull(szMsg);
+ size_t wMsgLen = mir_strlen(szMsg);
DWORD dwCookie = GenerateCookie(ICQ_LOCATION_SET_USER_INFO);
@@ -658,7 +659,7 @@ void CIcqProto::icq_sendSetAimAwayMsgServ(const char *szMsg)
if (IsUSASCII(szMsg, wMsgLen)) {
const char* fmt = "text/x-aolrtf; charset=\"us-ascii\"";
- const WORD fmtlen = (WORD)strlen(fmt);
+ size_t fmtlen = strlen(fmt);
serverPacketInit(&packet, 23 + wMsgLen + fmtlen);
packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_SET_USER_INFO, 0, dwCookie);
@@ -668,10 +669,10 @@ void CIcqProto::icq_sendSetAimAwayMsgServ(const char *szMsg)
}
else {
const char* fmt = "text/x-aolrtf; charset=\"unicode-2-0\"";
- const WORD fmtlen = (WORD)strlen(fmt);
+ size_t fmtlen = strlen(fmt);
WCHAR *szMsgW = make_unicode_string(szMsg);
- wMsgLen = (WORD)strlennull(szMsgW) * sizeof(WCHAR);
+ wMsgLen = mir_wstrlen(szMsgW) * sizeof(WCHAR);
WCHAR *szMsgW2 = (WCHAR*)alloca(wMsgLen), *szMsgW3 = szMsgW;
unpackWideString((BYTE**)&szMsgW3, szMsgW2, wMsgLen);
@@ -696,8 +697,6 @@ void CIcqProto::icq_sendSetAimAwayMsgServ(const char *szMsg)
void CIcqProto::icq_sendFileSendServv7(filetransfer* ft, const char *szFiles)
{
- icq_packet packet;
- WORD wDescrLen = 0, wFilesLen = 0;
char *szFilesAnsi = NULL, *szDescrAnsi = NULL;
if (!utf8_decode(szFiles, &szFilesAnsi))
@@ -706,16 +705,17 @@ void CIcqProto::icq_sendFileSendServv7(filetransfer* ft, const char *szFiles)
if (!utf8_decode(ft->szDescription, &szDescrAnsi))
szDescrAnsi = _strdup(ft->szDescription); // Legacy fix
- wFilesLen = strlennull(szFilesAnsi);
- wDescrLen = strlennull(szDescrAnsi);
+ size_t wFilesLen = mir_strlen(szFilesAnsi);
+ size_t wDescrLen = mir_strlen(szDescrAnsi);
- packServChannel2Header(&packet, this, ft->dwUin, (WORD)(18 + wDescrLen + wFilesLen), ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, ft->dwCookie, ICQ_VERSION, MTYPE_FILEREQ, 0, 1, 0, 1, 1);
+ icq_packet packet;
+ packServChannel2Header(&packet, this, ft->dwUin, 18 + wDescrLen + wFilesLen, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, ft->dwCookie, ICQ_VERSION, MTYPE_FILEREQ, 0, 1, 0, 1, 1);
- packLEWord(&packet, (WORD)(wDescrLen + 1));
- packBuffer(&packet, (LPBYTE)szDescrAnsi, (WORD)(wDescrLen + 1));
+ packLEWord(&packet, WORD(wDescrLen + 1));
+ packBuffer(&packet, (LPBYTE)szDescrAnsi, wDescrLen + 1);
packLEDWord(&packet, 0); // unknown
- packLEWord(&packet, (WORD)(wFilesLen + 1));
- packBuffer(&packet, (LPBYTE)szFilesAnsi, (WORD)(wFilesLen + 1));
+ packLEWord(&packet, WORD(wFilesLen + 1));
+ packBuffer(&packet, (LPBYTE)szFilesAnsi, wFilesLen + 1);
packLEDWord(&packet, ft->dwTotalSize);
packLEDWord(&packet, 0); // unknown
@@ -728,7 +728,6 @@ void CIcqProto::icq_sendFileSendServv7(filetransfer* ft, const char *szFiles)
void CIcqProto::icq_sendFileSendServv8(filetransfer* ft, const char *szFiles, int nAckType)
{
icq_packet packet;
- WORD wDescrLen = 0, wFilesLen = 0;
char *szFilesAnsi = NULL, *szDescrAnsi = NULL;
if (!utf8_decode(szFiles, &szFilesAnsi))
@@ -737,34 +736,34 @@ void CIcqProto::icq_sendFileSendServv8(filetransfer* ft, const char *szFiles, in
if (!utf8_decode(ft->szDescription, &szDescrAnsi))
szDescrAnsi = _strdup(ft->szDescription); // Legacy fix
- wFilesLen = strlennull(szFilesAnsi);
- wDescrLen = strlennull(szDescrAnsi);
+ size_t wFilesLen = mir_strlen(szFilesAnsi);
+ size_t wDescrLen = mir_strlen(szDescrAnsi);
// 202 + UIN len + file description (no null) + file name (null included)
// Packet size = Flap length + 4
- WORD wFlapLen = 178 + wDescrLen + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0);
+ size_t wFlapLen = 178 + wDescrLen + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0);
packServMsgSendHeader(&packet, ft->dwCookie, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, ft->dwUin, NULL, 2, wFlapLen);
// TLV(5) header
- packServTLV5HeaderMsg(&packet, (WORD)(138 + wDescrLen + wFilesLen), ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 1);
+ packServTLV5HeaderMsg(&packet, 138 + wDescrLen + wFilesLen, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 1);
// Port & IP information
packServDCInfo(&packet, this, FALSE);
// TLV(0x2711) header
- packServTLV2711Header(&packet, (WORD)ft->dwCookie, ICQ_VERSION, MTYPE_PLUGIN, 0, (WORD)MirandaStatusToIcq(m_iStatus), 0x100, 69 + wDescrLen + wFilesLen);
+ packServTLV2711Header(&packet, (WORD)ft->dwCookie, ICQ_VERSION, MTYPE_PLUGIN, 0, MirandaStatusToIcq(m_iStatus), 0x100, 69 + wDescrLen + wFilesLen);
packEmptyMsg(&packet); // Message (unused)
packPluginTypeId(&packet, MTYPE_FILEREQ);
- packLEDWord(&packet, (WORD)(18 + wDescrLen + wFilesLen + 1)); // Remaining length
- packLEDWord(&packet, wDescrLen); // Description
+ packLEDWord(&packet, WORD(18 + wDescrLen + wFilesLen + 1)); // Remaining length
+ packLEDWord(&packet, DWORD(wDescrLen)); // Description
packBuffer(&packet, (LPBYTE)szDescrAnsi, wDescrLen);
packWord(&packet, 0x8c82); // Unknown (port?), seen 0x80F6
packWord(&packet, 0x0222); // Unknown, seen 0x2e01
- packLEWord(&packet, (WORD)(wFilesLen + 1));
- packBuffer(&packet, (LPBYTE)szFilesAnsi, (WORD)(wFilesLen + 1));
+ packLEWord(&packet, WORD(wFilesLen + 1));
+ packBuffer(&packet, (LPBYTE)szFilesAnsi, wFilesLen + 1);
packLEDWord(&packet, ft->dwTotalSize);
packLEDWord(&packet, 0x0008c82); // Unknown, (seen 0xf680 ~33000)
@@ -796,16 +795,16 @@ void CIcqProto::icq_sendFileAcceptServv8(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR
if (!utf8_decode(szDescr, &szDescrAnsi))
szDescrAnsi = _strdup(szDescr); // Legacy fix
- WORD wDescrLen = strlennull(szDescrAnsi);
- WORD wFilesLen = strlennull(szFilesAnsi);
+ size_t wDescrLen = mir_strlen(szDescrAnsi);
+ size_t wFilesLen = mir_strlen(szFilesAnsi);
// 202 + UIN len + file description (no null) + file name (null included)
// Packet size = Flap length + 4
- WORD wFlapLen = 178 + wDescrLen + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0);
+ size_t wFlapLen = 178 + wDescrLen + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0);
packServMsgSendHeader(&packet, dwCookie, TS1, TS2, dwUin, NULL, 2, wFlapLen);
// TLV(5) header
- packServTLV5HeaderMsg(&packet, (WORD)(138 + wDescrLen + wFilesLen), TS1, TS2, 2);
+ packServTLV5HeaderMsg(&packet, 138 + wDescrLen + wFilesLen, TS1, TS2, 2);
// Port & IP information
packServDCInfo(&packet, this, !accepted);
@@ -817,13 +816,13 @@ void CIcqProto::icq_sendFileAcceptServv8(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR
packPluginTypeId(&packet, MTYPE_FILEREQ);
- packLEDWord(&packet, (WORD)(18 + wDescrLen + wFilesLen + 1)); // Remaining length
- packLEDWord(&packet, wDescrLen); // Description
+ packLEDWord(&packet, DWORD(18 + wDescrLen + wFilesLen + 1)); // Remaining length
+ packLEDWord(&packet, DWORD(wDescrLen)); // Description
packBuffer(&packet, (LPBYTE)szDescrAnsi, wDescrLen);
packWord(&packet, wPort); // Port
packWord(&packet, 0x00); // Unknown
- packLEWord(&packet, (WORD)(wFilesLen + 1));
- packBuffer(&packet, (LPBYTE)szFilesAnsi, (WORD)(wFilesLen + 1));
+ packLEWord(&packet, WORD(wFilesLen + 1));
+ packBuffer(&packet, (LPBYTE)szFilesAnsi, wFilesLen + 1);
packLEDWord(&packet, dwTotalSize);
packLEDWord(&packet, (DWORD)wPort); // Unknown
@@ -855,16 +854,16 @@ void CIcqProto::icq_sendFileAcceptServv7(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR
if (!utf8_decode(szDescr, &szDescrAnsi))
szDescrAnsi = _strdup(szDescr); // Legacy fix
- WORD wDescrLen = strlennull(szDescrAnsi);
- WORD wFilesLen = strlennull(szFilesAnsi);
+ size_t wDescrLen = mir_strlen(szDescrAnsi);
+ size_t wFilesLen = mir_strlen(szFilesAnsi);
// 150 + UIN len + file description (with null) + file name (2 nulls)
// Packet size = Flap length + 4
- WORD wFlapLen = 127 + wDescrLen + 1 + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0);
+ size_t wFlapLen = 127 + wDescrLen + 1 + wFilesLen + (nAckType == ACKTYPE_SERVER ? 4 : 0);
packServMsgSendHeader(&packet, dwCookie, TS1, TS2, dwUin, NULL, 2, wFlapLen);
// TLV(5) header
- packServTLV5HeaderMsg(&packet, (WORD)(88 + wDescrLen + wFilesLen), TS1, TS2, 2);
+ packServTLV5HeaderMsg(&packet, 88 + wDescrLen + wFilesLen, TS1, TS2, 2);
// Port & IP information
packServDCInfo(&packet, this, !accepted);
@@ -872,12 +871,12 @@ void CIcqProto::icq_sendFileAcceptServv7(DWORD dwUin, DWORD TS1, DWORD TS2, DWOR
// TLV(0x2711) header
packServTLV2711Header(&packet, (WORD)dwCookie, ICQ_VERSION, MTYPE_FILEREQ, 0, (WORD)(accepted ? 0 : 1), 0, 19 + wDescrLen + wFilesLen);
//
- packLEWord(&packet, (WORD)(wDescrLen + 1)); // Description
- packBuffer(&packet, (LPBYTE)szDescrAnsi, (WORD)(wDescrLen + 1));
+ packLEWord(&packet, WORD(wDescrLen + 1)); // Description
+ packBuffer(&packet, (LPBYTE)szDescrAnsi, wDescrLen + 1);
packWord(&packet, wPort); // Port
packWord(&packet, 0x00); // Unknown
- packLEWord(&packet, (WORD)(wFilesLen + 2));
- packBuffer(&packet, (LPBYTE)szFilesAnsi, (WORD)(wFilesLen + 1));
+ packLEWord(&packet, WORD(wFilesLen + 2));
+ packBuffer(&packet, (LPBYTE)szFilesAnsi, wFilesLen + 1);
packByte(&packet, 0);
packLEDWord(&packet, dwTotalSize);
packLEDWord(&packet, (DWORD)wPort); // Unknown
@@ -939,23 +938,21 @@ void CIcqProto::icq_sendAwayMsgReplyServ(DWORD dwUin, DWORD dwMsgID1, DWORD dwMs
wReplyVersion = 9;
}
else { // only v9 protocol supports UTF-8 mode messagees
- WORD wMsgLen = strlennull(*szMsg) + 1;
+ size_t wMsgLen = mir_strlen(*szMsg) + 1;
char *szAnsiMsg = (char*)_alloca(wMsgLen);
utf8_decode_static(*szMsg, szAnsiMsg, wMsgLen);
pszMsg = szAnsiMsg;
}
- WORD wMsgLen = strlennull(pszMsg);
-
// limit msg len to max snac size - we get disconnected if exceeded
+ size_t wMsgLen = mir_strlen(pszMsg);
if (wMsgLen > MAX_MESSAGESNACSIZE)
wMsgLen = MAX_MESSAGESNACSIZE;
icq_packet packet;
-
- packServAdvancedMsgReply(&packet, dwUin, NULL, dwMsgID1, dwMsgID2, wCookie, wReplyVersion, msgType, 3, (WORD)(wMsgLen + 3));
- packLEWord(&packet, (WORD)(wMsgLen + 1));
+ packServAdvancedMsgReply(&packet, dwUin, NULL, dwMsgID1, dwMsgID2, wCookie, wReplyVersion, msgType, 3, wMsgLen + 3);
+ packLEWord(&packet, WORD(wMsgLen + 1));
packBuffer(&packet, (LPBYTE)pszMsg, wMsgLen);
packByte(&packet, 0);
@@ -983,34 +980,32 @@ void CIcqProto::icq_sendAwayMsgReplyServExt(DWORD dwUin, char *szUID, DWORD dwMs
else { // only v9 protocol supports UTF-8 mode messagees
wReplyVersion = 8;
- WORD wMsgLen = strlennull(*szMsg) + 1;
+ size_t wMsgLen = mir_strlen(*szMsg) + 1;
char *szAnsiMsg = (char*)_alloca(wMsgLen);
utf8_decode_static(*szMsg, szAnsiMsg, wMsgLen);
pszMsg = szAnsiMsg;
}
// convert to HTML
- char *mng = MangleXml(pszMsg, strlennull(pszMsg));
- pszMsg = (char*)SAFE_MALLOC(strlennull(mng) + 28);
+ char *mng = MangleXml(pszMsg, mir_strlen(pszMsg));
+ pszMsg = (char*)SAFE_MALLOC(mir_strlen(mng) + 28);
strcpy(pszMsg, "<HTML><BODY>"); /// TODO: add support for RTL & user customizable font
strcat(pszMsg, mng);
SAFE_FREE(&mng);
strcat(pszMsg, "</BODY></HTML>");
- WORD wMsgLen = strlennull(pszMsg);
-
// limit msg len to max snac size - we get disconnected if exceeded /// FIXME: correct HTML cutting
+ size_t wMsgLen = mir_strlen(pszMsg);
if (wMsgLen > MAX_MESSAGESNACSIZE)
wMsgLen = MAX_MESSAGESNACSIZE;
icq_packet packet;
-
packServAdvancedMsgReply(&packet, dwUin, szUID, dwMsgID1, dwMsgID2, wCookie, wReplyVersion, MTYPE_PLUGIN, 0, wMsgLen + 27 + getPluginTypeIdLen(msgType));
packLEWord(&packet, 0); // Message size
packPluginTypeId(&packet, msgType);
- packLEDWord(&packet, wMsgLen + 21);
- packLEDWord(&packet, wMsgLen);
+ packLEDWord(&packet, DWORD(wMsgLen + 21));
+ packLEDWord(&packet, DWORD(wMsgLen));
packBuffer(&packet, (LPBYTE)pszMsg, wMsgLen);
packLEDWord(&packet, 0x0D);
@@ -1087,7 +1082,7 @@ DWORD CIcqProto::SearchByUin(DWORD dwUin)
DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, const char *pszLastName, WORD wPage)
{ // use directory search like ICQ6 does
- WORD wInfoLen = 0;
+ size_t wInfoLen = 0;
icq_packet pBuffer; // I reuse the ICQ packet type as a generic buffer
// I should be ashamed! ;)
if (m_bLegacyFix) {
@@ -1105,9 +1100,9 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co
if (!utf8_decode(pszLastName, &pszLastNameAnsi))
pszLastNameAnsi = _strdup(pszLastName);
- WORD wNickLen = strlennull(pszNickAnsi);
- WORD wFirstLen = strlennull(pszFirstNameAnsi);
- WORD wLastLen = strlennull(pszLastNameAnsi);
+ size_t wNickLen = mir_strlen(pszNickAnsi);
+ size_t wFirstLen = mir_strlen(pszFirstNameAnsi);
+ size_t wLastLen = mir_strlen(pszLastNameAnsi);
_ASSERTE(wFirstLen || wLastLen || wNickLen);
@@ -1122,9 +1117,9 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co
// Initialize our handy data buffer
pBuffer.wPlace = 0;
pBuffer.pData = (BYTE *)_alloca(wInfoLen);
- pBuffer.wLen = wInfoLen;
+ pBuffer.wLen = WORD(wInfoLen);
- int pBufferPos = 0;
+ size_t pBufferPos = 0;
// Pack the search details
if (wFirstLen > 0)
@@ -1144,9 +1139,9 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co
return sendTLVSearchPacket(SEARCHTYPE_NAMES, (char*)pBuffer.pData, META_SEARCH_GENERIC, wInfoLen, FALSE);
}
- WORD wNickLen = strlennull(pszNick);
- WORD wFirstLen = strlennull(pszFirstName);
- WORD wLastLen = strlennull(pszLastName);
+ size_t wNickLen = mir_strlen(pszNick);
+ size_t wFirstLen = mir_strlen(pszFirstName);
+ size_t wLastLen = mir_strlen(pszLastName);
_ASSERTE(wFirstLen || wLastLen || wNickLen);
@@ -1161,7 +1156,7 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co
// Initialize our handy data buffer
pBuffer.wPlace = 0;
pBuffer.pData = (BYTE *)_alloca(wInfoLen);
- pBuffer.wLen = wInfoLen;
+ pBuffer.wLen = WORD(wInfoLen);
// Pack the search details
if (wNickLen)
@@ -1182,17 +1177,17 @@ DWORD CIcqProto::SearchByNames(const char *pszNick, const char *pszFirstName, co
DWORD CIcqProto::SearchByMail(const char* pszEmail)
{
- WORD wEmailLen = strlennull(pszEmail);
+ size_t wEmailLen = mir_strlen(pszEmail);
_ASSERTE(wEmailLen);
if (wEmailLen <= 0)
return 0;
// Calculate data size
- WORD wInfoLen = wEmailLen + 7;
+ size_t wInfoLen = wEmailLen + 7;
// Initialize our handy data buffer
BYTE *pBuffer = (BYTE *)_alloca(wInfoLen);
- int pBufferPos = 0;
+ size_t pBufferPos = 0;
// Pack the search details
packLETLVLNTS(&pBuffer, &pBufferPos, pszEmail, TLV_EMAIL);
@@ -1201,7 +1196,7 @@ DWORD CIcqProto::SearchByMail(const char* pszEmail)
return sendTLVSearchPacket(SEARCHTYPE_EMAIL, (char*)pBuffer, META_SEARCH_EMAIL, wInfoLen, FALSE);
}
-DWORD CIcqProto::sendDirectorySearchPacket(const BYTE *pSearchData, WORD wDataLen, WORD wPage, BOOL bOnlineUsersOnly)
+DWORD CIcqProto::sendDirectorySearchPacket(const BYTE *pSearchData, size_t wDataLen, WORD wPage, BOOL bOnlineUsersOnly)
{
_ASSERTE(pSearchData);
_ASSERTE(wDataLen >= 4);
@@ -1223,7 +1218,7 @@ DWORD CIcqProto::sendDirectorySearchPacket(const BYTE *pSearchData, WORD wDataLe
// Pack search data
packWord(&packet, 0x0001);
- packWord(&packet, wDataLen + (bOnlineUsersOnly ? 6 : 0));
+ packWord(&packet, WORD(wDataLen + (bOnlineUsersOnly ? 6 : 0)));
packBuffer(&packet, pSearchData, wDataLen);
if (bOnlineUsersOnly) // Pack "Online users only" flag
@@ -1234,7 +1229,7 @@ DWORD CIcqProto::sendDirectorySearchPacket(const BYTE *pSearchData, WORD wDataLe
return dwCookie;
}
-DWORD CIcqProto::sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSearchType, WORD wInfoLen, BOOL bOnlineUsersOnly)
+DWORD CIcqProto::sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSearchType, size_t wInfoLen, BOOL bOnlineUsersOnly)
{
_ASSERTE(pSearchDataBuf);
_ASSERTE(wInfoLen >= 4);
@@ -1248,7 +1243,7 @@ DWORD CIcqProto::sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSea
// Pack headers
icq_packet packet;
- packServIcqExtensionHeader(&packet, this, (WORD)(wInfoLen + (wSearchType == META_SEARCH_GENERIC ? 7 : 2)), CLI_META_INFO_REQ, (WORD)dwCookie);
+ packServIcqExtensionHeader(&packet, this, wInfoLen + (wSearchType == META_SEARCH_GENERIC ? 7 : 2), CLI_META_INFO_REQ, (WORD)dwCookie);
// Pack search type
packLEWord(&packet, wSearchType);
@@ -1266,7 +1261,7 @@ DWORD CIcqProto::sendTLVSearchPacket(BYTE bType, char* pSearchDataBuf, WORD wSea
return dwCookie;
}
-DWORD CIcqProto::icq_sendAdvancedSearchServ(BYTE* fieldsBuffer, int bufferLen)
+DWORD CIcqProto::icq_sendAdvancedSearchServ(BYTE* fieldsBuffer, size_t bufferLen)
{
cookie_search *pCookie = (cookie_search*)SAFE_MALLOC(sizeof(cookie_search));
if (pCookie == 0)
@@ -1276,8 +1271,8 @@ DWORD CIcqProto::icq_sendAdvancedSearchServ(BYTE* fieldsBuffer, int bufferLen)
DWORD dwCookie = AllocateCookie(CKT_SEARCH, 0, 0, pCookie);
icq_packet packet;
- packServIcqExtensionHeader(&packet, this, (WORD)bufferLen, CLI_META_INFO_REQ, (WORD)dwCookie);
- packBuffer(&packet, (LPBYTE)fieldsBuffer, (WORD)bufferLen);
+ packServIcqExtensionHeader(&packet, this, bufferLen, CLI_META_INFO_REQ, (WORD)dwCookie);
+ packBuffer(&packet, (LPBYTE)fieldsBuffer, bufferLen);
sendServPacket(&packet);
return dwCookie;
@@ -1299,9 +1294,9 @@ DWORD CIcqProto::icq_searchAimByEmail(const char* pszEmail, DWORD dwSearchId)
pCookie->szObject = null_strdup(pszEmail);
DWORD dwCookie = AllocateCookie(CKT_SEARCH, ICQ_LOOKUP_REQUEST, 0, pCookie);
- WORD wEmailLen = strlennull(pszEmail);
+ size_t wEmailLen = mir_strlen(pszEmail);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(10 + wEmailLen));
+ serverPacketInit(&packet, 10 + wEmailLen);
packFNACHeader(&packet, ICQ_LOOKUP_FAMILY, ICQ_LOOKUP_REQUEST, 0, dwCookie);
packBuffer(&packet, (LPBYTE)pszEmail, wEmailLen);
@@ -1312,20 +1307,20 @@ DWORD CIcqProto::icq_searchAimByEmail(const char* pszEmail, DWORD dwSearchId)
DWORD CIcqProto::icq_changeUserPasswordServ(const char *szPassword)
{
- WORD wPasswordLen = strlennull(szPassword);
+ size_t wPasswordLen = mir_strlen(szPassword);
DWORD dwCookie = GenerateCookie(0);
icq_packet packet;
- packServIcqExtensionHeader(&packet, this, (WORD)(wPasswordLen + 4), CLI_META_INFO_REQ, (WORD)dwCookie, ICQ_META_SRV_UPDATE);
+ packServIcqExtensionHeader(&packet, this, wPasswordLen + 4, CLI_META_INFO_REQ, (WORD)dwCookie, ICQ_META_SRV_UPDATE);
packLEWord(&packet, META_SET_PASSWORD_REQ);
- packLEWord(&packet, wPasswordLen);
+ packLEWord(&packet, WORD(wPasswordLen));
packBuffer(&packet, (BYTE*)szPassword, wPasswordLen);
sendServPacket(&packet);
return dwCookie;
}
-DWORD CIcqProto::icq_changeUserDirectoryInfoServ(const BYTE *pData, WORD wDataLen, BYTE bRequestType)
+DWORD CIcqProto::icq_changeUserDirectoryInfoServ(const BYTE *pData, size_t wDataLen, BYTE bRequestType)
{
cookie_directory_data *pCookieData = (cookie_directory_data*)SAFE_MALLOC(sizeof(cookie_directory_data));
pCookieData->bRequestType = bRequestType;
@@ -1334,7 +1329,7 @@ DWORD CIcqProto::icq_changeUserDirectoryInfoServ(const BYTE *pData, WORD wDataLe
icq_packet packet;
packServIcqDirectoryHeader(&packet, this, wDataLen + 4, META_DIRECTORY_UPDATE, DIRECTORY_SET_INFO, (WORD)dwCookie, ICQ_META_SRV_UPDATE);
packWord(&packet, 0x0003);
- packWord(&packet, wDataLen);
+ packWord(&packet, WORD(wDataLen));
packBuffer(&packet, pData, wDataLen);
sendServPacket(&packet);
@@ -1347,15 +1342,12 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg)
WORD wBufferLen;
char *szBuffer = NULL;
char szTime[30];
- time_t now;
- int nBufferSize;
-
- now = time(NULL);
+ time_t now = time(NULL);
strftime(szTime, sizeof(szTime), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
/* Sun, 00 Jan 0000 00:00:00 GMT */
char *szMyNick = null_strdup((char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)(HANDLE)NULL, 0));
- nBufferSize = 1 + strlennull(szMyNick) + strlennull(szPhoneNumber) + strlennull(szMsg) + sizeof("<icq_sms_message><destination></destination><text></text><codepage>1252</codepage><encoding>utf8</encoding><senders_UIN>0000000000</senders_UIN><senders_name></senders_name><delivery_receipt>Yes</delivery_receipt><time>Sun, 00 Jan 0000 00:00:00 GMT</time></icq_sms_message>");
+ size_t nBufferSize = 1 + mir_strlen(szMyNick) + mir_strlen(szPhoneNumber) + mir_strlen(szMsg) + sizeof("<icq_sms_message><destination></destination><text></text><codepage>1252</codepage><encoding>utf8</encoding><senders_UIN>0000000000</senders_UIN><senders_name></senders_name><delivery_receipt>Yes</delivery_receipt><time>Sun, 00 Jan 0000 00:00:00 GMT</time></icq_sms_message>");
if (szBuffer = (char *)_alloca(nBufferSize)) {
wBufferLen = mir_snprintf(szBuffer, nBufferSize,
@@ -1390,7 +1382,7 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg)
dwCookie = GenerateCookie(0);
icq_packet packet;
- packServIcqExtensionHeader(&packet, this, (WORD)(wBufferLen + 27), CLI_META_INFO_REQ, (WORD)dwCookie);
+ packServIcqExtensionHeader(&packet, this, wBufferLen + 27, CLI_META_INFO_REQ, (WORD)dwCookie);
packWord(&packet, 0x8214); /* send sms */
packWord(&packet, 1);
packWord(&packet, 0x16);
@@ -1399,8 +1391,8 @@ DWORD CIcqProto::icq_sendSMSServ(const char *szPhoneNumber, const char *szMsg)
packDWord(&packet, 0);
packDWord(&packet, 0);
packWord(&packet, 0);
- packWord(&packet, (WORD)(wBufferLen + 1));
- packBuffer(&packet, (LPBYTE)szBuffer, (WORD)(1 + wBufferLen));
+ packWord(&packet, WORD(wBufferLen + 1));
+ packBuffer(&packet, (LPBYTE)szBuffer, wBufferLen+1);
sendServPacket(&packet);
}
@@ -1415,7 +1407,7 @@ void CIcqProto::icq_sendGenericContact(DWORD dwUin, const char *szUid, WORD wFam
int nUinLen = getUIDLen(dwUin, szUid);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(nUinLen + 11));
+ serverPacketInit(&packet, nUinLen + 11);
packFNACHeader(&packet, wFamily, wSubType);
packUID(&packet, dwUin, szUid);
@@ -1499,7 +1491,7 @@ void CIcqProto::icq_sendChangeVisInvis(MCONTACT hContact, DWORD dwUin, char* szU
int nUinLen = getUIDLen(dwUin, szUID);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(nUinLen + 11));
+ serverPacketInit(&packet, nUinLen + 11);
packFNACHeader(&packet, ICQ_BOS_FAMILY, wSnac);
packUID(&packet, dwUin, szUID);
sendServPacket(&packet);
@@ -1524,13 +1516,13 @@ void CIcqProto::icq_sendGrantAuthServ(DWORD dwUin, const char *szUid, const char
// Prepare custom utf-8 message
char *szUtfMsg = ansi_to_utf8(szMsg);
- WORD nMsglen = strlennull(szUtfMsg);
+ size_t nMsglen = mir_strlen(szUtfMsg);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(15 + nUinlen + nMsglen));
+ serverPacketInit(&packet, 15 + nUinlen + nMsglen);
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_GRANTAUTH);
packUID(&packet, dwUin, szUid);
- packWord(&packet, nMsglen);
+ packWord(&packet, WORD(nMsglen));
packBuffer(&packet, (LPBYTE)szUtfMsg, nMsglen);
packWord(&packet, 0);
@@ -1542,13 +1534,13 @@ void CIcqProto::icq_sendGrantAuthServ(DWORD dwUin, const char *szUid, const char
void CIcqProto::icq_sendAuthReqServ(DWORD dwUin, char *szUid, const char *szMsg)
{
BYTE nUinlen = getUIDLen(dwUin, szUid);
- WORD nMsglen = strlennull(szMsg);
+ size_t nMsglen = mir_strlen(szMsg);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(15 + nUinlen + nMsglen));
+ serverPacketInit(&packet, 15 + nUinlen + nMsglen);
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_REQUESTAUTH);
packUID(&packet, dwUin, szUid);
- packWord(&packet, nMsglen);
+ packWord(&packet, WORD(nMsglen));
packBuffer(&packet, (LPBYTE)szMsg, nMsglen);
packWord(&packet, 0);
@@ -1561,14 +1553,14 @@ void CIcqProto::icq_sendAuthResponseServ(DWORD dwUin, char* szUid, int auth, con
// Prepare custom utf-8 reason
char *szUtfReason = tchar_to_utf8(szReason);
- WORD nReasonLen = strlennull(szUtfReason);
+ size_t nReasonLen = mir_strlen(szUtfReason);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(16 + nUinLen + nReasonLen));
+ serverPacketInit(&packet, 16 + nUinLen + nReasonLen);
packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_AUTHRESPONSE);
packUID(&packet, dwUin, szUid);
packByte(&packet, (BYTE)auth);
- packWord(&packet, nReasonLen);
+ packWord(&packet, WORD(nReasonLen));
packBuffer(&packet, (LPBYTE)szUtfReason, nReasonLen);
packWord(&packet, 0);
@@ -1594,15 +1586,15 @@ void CIcqProto::icq_sendYouWereAddedServ(DWORD dwUin, DWORD dwMyUin)
sendServPacket(&packet);
}
-void CIcqProto::icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBody, int nBodyLen, cookie_message_data *pCookieData)
+void CIcqProto::icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBody, size_t nBodyLen, cookie_message_data *pCookieData)
{
- WORD wCoreLen = 11 + getPluginTypeIdLen(pCookieData->bMessageType) + nBodyLen;
+ size_t wCoreLen = 11 + getPluginTypeIdLen(pCookieData->bMessageType) + nBodyLen;
icq_packet packet;
- packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, NULL, 2, (WORD)(99 + wCoreLen));
+ packServMsgSendHeader(&packet, dwCookie, pCookieData->dwMsgID1, pCookieData->dwMsgID2, dwUin, NULL, 2, 99 + wCoreLen);
// TLV(5) header
- packServTLV5HeaderMsg(&packet, (WORD)(55 + wCoreLen), pCookieData->dwMsgID1, pCookieData->dwMsgID2, 1);
+ packServTLV5HeaderMsg(&packet, 55 + wCoreLen, pCookieData->dwMsgID1, pCookieData->dwMsgID2, 1);
// TLV(0x2711) header
packServTLV2711Header(&packet, (WORD)dwCookie, ICQ_VERSION, MTYPE_PLUGIN, 0, 0, 0x100, wCoreLen);
@@ -1611,9 +1603,9 @@ void CIcqProto::icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBo
packPluginTypeId(&packet, pCookieData->bMessageType);
- packLEDWord(&packet, nBodyLen + 4);
- packLEDWord(&packet, nBodyLen);
- packBuffer(&packet, (LPBYTE)szBody, (WORD)nBodyLen);
+ packLEDWord(&packet, DWORD(nBodyLen + 4));
+ packLEDWord(&packet, DWORD(nBodyLen));
+ packBuffer(&packet, (LPBYTE)szBody, nBodyLen);
// Pack request server ack TLV
packDWord(&packet, 0x00030000); // TLV(3)
@@ -1622,18 +1614,18 @@ void CIcqProto::icq_sendXtrazRequestServ(DWORD dwUin, DWORD dwCookie, char* szBo
sendServPacket(&packet);
}
-void CIcqProto::icq_sendXtrazResponseServ(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szBody, int nBodyLen, int nType)
+void CIcqProto::icq_sendXtrazResponseServ(DWORD dwUin, DWORD dwMID, DWORD dwMID2, WORD wCookie, char* szBody, size_t nBodyLen, int nType)
{
icq_packet packet;
- packServAdvancedMsgReply(&packet, dwUin, NULL, dwMID, dwMID2, wCookie, ICQ_VERSION, MTYPE_PLUGIN, 0, (WORD)(getPluginTypeIdLen(nType) + 11 + nBodyLen));
+ packServAdvancedMsgReply(&packet, dwUin, NULL, dwMID, dwMID2, wCookie, ICQ_VERSION, MTYPE_PLUGIN, 0, getPluginTypeIdLen(nType) + 11 + nBodyLen);
packEmptyMsg(&packet);
packPluginTypeId(&packet, nType);
- packLEDWord(&packet, nBodyLen + 4);
- packLEDWord(&packet, nBodyLen);
- packBuffer(&packet, (LPBYTE)szBody, (WORD)nBodyLen);
+ packLEDWord(&packet, DWORD(nBodyLen + 4));
+ packLEDWord(&packet, DWORD(nBodyLen));
+ packBuffer(&packet, (LPBYTE)szBody, nBodyLen);
// Send the monster
sendServPacket(&packet);
@@ -1668,7 +1660,7 @@ void CIcqProto::icq_sendReverseFailed(directconnect* dc, DWORD dwMsgID1, DWORD d
int nUinLen = getUINLen(dc->dwRemoteUin);
icq_packet packet;
- serverPacketInit(&packet, (WORD)(nUinLen + 74));
+ serverPacketInit(&packet, nUinLen + 74);
packFNACHeader(&packet, ICQ_MSG_FAMILY, ICQ_MSG_RESPONSE, 0, ICQ_MSG_RESPONSE << 0x10 | (dwCookie & 0x7FFF));
packLEDWord(&packet, dwMsgID1); // Msg ID part 1
packLEDWord(&packet, dwMsgID2); // Msg ID part 2
@@ -1688,23 +1680,23 @@ void CIcqProto::icq_sendReverseFailed(directconnect* dc, DWORD dwMsgID1, DWORD d
//
void CIcqProto::oft_sendFileRequest(DWORD dwUin, char *szUid, oscar_filetransfer *ft, const char *pszFiles, DWORD dwLocalInternalIP)
{
- size_t size = strlennull(ft->szDescription) + strlennull(pszFiles) + 160;
+ size_t size = mir_strlen(ft->szDescription) + mir_strlen(pszFiles) + 160;
char *szCoolStr = (char *)_alloca(size);
mir_snprintf(szCoolStr, size, "<ICQ_COOL_FT><FS>%s</FS><S>%I64u</S><SID>1</SID><DESC>%s</DESC></ICQ_COOL_FT>", pszFiles, ft->qwTotalSize, ft->szDescription);
- szCoolStr = MangleXml(szCoolStr, strlennull(szCoolStr));
+ szCoolStr = MangleXml(szCoolStr, mir_strlen(szCoolStr));
- WORD wDataLen = 93 + strlennull(szCoolStr) + strlennull(pszFiles);
+ size_t wDataLen = 93 + mir_strlen(szCoolStr) + mir_strlen(pszFiles);
if (ft->bUseProxy)
wDataLen += 4;
icq_packet packet;
- packServMsgSendHeader(&packet, ft->dwCookie, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, dwUin, szUid, 2, (WORD)(wDataLen + 0x1E));
+ packServMsgSendHeader(&packet, ft->dwCookie, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, dwUin, szUid, 2, wDataLen + 0x1E);
packServTLV5HeaderBasic(&packet, wDataLen, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 0, MCAP_FILE_TRANSFER);
packTLVWord(&packet, 0x0A, ++ft->wReqNum); // Request sequence
packDWord(&packet, 0x000F0000); // Unknown
packTLV(&packet, 0x0D, 5, (LPBYTE)"utf-8"); // Charset
- packTLV(&packet, 0x0C, (WORD)strlennull(szCoolStr), (LPBYTE)szCoolStr); // User message (CoolData XML)
+ packTLV(&packet, 0x0C, mir_strlen(szCoolStr), (LPBYTE)szCoolStr); // User message (CoolData XML)
SAFE_FREE(&szCoolStr);
if (ft->bUseProxy) {
packTLVDWord(&packet, 0x02, ft->dwProxyIP); // Proxy IP
@@ -1717,22 +1709,22 @@ void CIcqProto::oft_sendFileRequest(DWORD dwUin, char *szUid, oscar_filetransfer
packTLVDWord(&packet, 0x03, dwLocalInternalIP); // Client IP
if (ft->bUseProxy) {
packTLVWord(&packet, 0x05, ft->wRemotePort);
- packTLVWord(&packet, 0x17, (WORD)(ft->wRemotePort ^ 0x0FFFF));
+ packTLVWord(&packet, 0x17, WORD(ft->wRemotePort ^ 0x0FFFF));
packDWord(&packet, 0x00100000); // Proxy flag
}
else {
oscar_listener *pListener = (oscar_listener*)ft->listener;
packTLVWord(&packet, 0x05, pListener->wPort);
- packTLVWord(&packet, 0x15, (WORD)((pListener->wPort) ^ 0x0FFFF));
+ packTLVWord(&packet, 0x15, WORD((pListener->wPort) ^ 0x0FFFF));
}
// TLV(0x2711)
packWord(&packet, 0x2711);
- packWord(&packet, (WORD)(9 + strlennull(pszFiles)));
- packWord(&packet, (WORD)(ft->wFilesCount == 1 ? 1 : 2));
+ packWord(&packet, WORD(9 + mir_strlen(pszFiles)));
+ packWord(&packet, WORD(ft->wFilesCount == 1 ? 1 : 2));
packWord(&packet, ft->wFilesCount);
packDWord(&packet, (DWORD)ft->qwTotalSize);
- packBuffer(&packet, (LPBYTE)pszFiles, (WORD)(strlennull(pszFiles) + 1));
+ packBuffer(&packet, (LPBYTE)pszFiles, mir_strlen(pszFiles) + 1);
packTLV(&packet, 0x2712, 5, (LPBYTE)"utf-8");
@@ -1784,8 +1776,8 @@ void CIcqProto::oft_sendFileCancel(DWORD dwUin, char *szUid, oscar_filetransfer
void CIcqProto::oft_sendFileRedirect(DWORD dwUin, char *szUid, oscar_filetransfer *ft, DWORD dwIP, WORD wPort, int bProxy)
{
icq_packet packet;
- packServMsgSendHeader(&packet, 0, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, dwUin, szUid, 2, (WORD)(bProxy ? 0x4a : 0x4e));
- packServTLV5HeaderBasic(&packet, (WORD)(bProxy ? 0x2C : 0x30), ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 0, MCAP_FILE_TRANSFER);
+ packServMsgSendHeader(&packet, 0, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, dwUin, szUid, 2, bProxy ? 0x4a : 0x4e);
+ packServTLV5HeaderBasic(&packet, bProxy ? 0x2C : 0x30, ft->pMessage.dwMsgID1, ft->pMessage.dwMsgID2, 0, MCAP_FILE_TRANSFER);
// Connection point data
packTLVWord(&packet, 0x0A, ++ft->wReqNum); // Ack Type
packTLVWord(&packet, 0x14, 0x0A); // Unknown ?
@@ -1794,7 +1786,7 @@ void CIcqProto::oft_sendFileRedirect(DWORD dwUin, char *szUid, oscar_filetransfe
if (!bProxy)
packTLVDWord(&packet, 0x03, dwIP);
packTLVWord(&packet, 0x05, wPort); // Listening Port
- packTLVWord(&packet, 0x17, (WORD)(wPort ^ 0x0FFFF)); // Port Check ?
+ packTLVWord(&packet, 0x17, WORD(wPort ^ 0x0FFFF)); // Port Check ?
if (bProxy)
packDWord(&packet, 0x00100000); // Proxy Flag
diff --git a/protocols/IcqOscarJ/src/tlv.cpp b/protocols/IcqOscarJ/src/tlv.cpp
index ad1846e167..33fe38f7cd 100644
--- a/protocols/IcqOscarJ/src/tlv.cpp
+++ b/protocols/IcqOscarJ/src/tlv.cpp
@@ -30,15 +30,15 @@
#include "icqoscar.h"
/* set maxTlvs<=0 to get all TLVs in length, or a positive integer to get at most the first n */
-oscar_tlv_chain* readIntoTLVChain(BYTE **buf, WORD wLen, int maxTlvs)
+oscar_tlv_chain* readIntoTLVChain(BYTE **buf, size_t wLen, int maxTlvs)
{
oscar_tlv_chain *now, *last, *chain = NULL;
WORD now_tlv_len;
- int len = wLen;
if (!buf || !wLen)
return NULL;
+ intptr_t len = wLen;
while (len > 0) { /* don't use unsigned variable for this check */
now = (oscar_tlv_chain *)SAFE_MALLOC(sizeof(oscar_tlv_chain));
@@ -113,7 +113,7 @@ WORD oscar_tlv_chain::getChainLength()
return len;
}
-oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, WORD wLen, BYTE *pData, BOOL bReplace)
+oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bReplace)
{
oscar_tlv *tlv = getTLV(wType, 1);
@@ -132,7 +132,7 @@ oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, WORD wLen, BYTE *pData, BOOL bRep
}
}
if (tlv) {
- tlv->wLen = wLen;
+ tlv->wLen = WORD(wLen);
tlv->pData = (PBYTE)SAFE_MALLOC(wLen);
memcpy(tlv->pData, pData, wLen);
}
@@ -278,7 +278,7 @@ void disposeChain(oscar_tlv_chain **chain)
*chain = NULL;
}
-oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, WORD wLen, int nCount)
+oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, size_t wLen, int nCount)
{
oscar_tlv_record_list *list = NULL, *last;
diff --git a/protocols/IcqOscarJ/src/tlv.h b/protocols/IcqOscarJ/src/tlv.h
index ea04362ea9..6e08fd0e5d 100644
--- a/protocols/IcqOscarJ/src/tlv.h
+++ b/protocols/IcqOscarJ/src/tlv.h
@@ -44,7 +44,7 @@ struct oscar_tlv_chain
WORD getChainLength();
oscar_tlv* getTLV(WORD wType, WORD wIndex);
- oscar_tlv* putTLV(WORD wType, WORD wLen, BYTE *pData, BOOL bReplace);
+ oscar_tlv* putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bReplace);
oscar_tlv_chain* removeTLV(oscar_tlv *tlv);
WORD getLength(WORD wType, WORD wIndex);
@@ -67,10 +67,10 @@ struct oscar_tlv_record_list
/*---------* Functions *---------------*/
-oscar_tlv_chain* readIntoTLVChain(BYTE **buf, WORD wLen, int maxTlvs);
+oscar_tlv_chain* readIntoTLVChain(BYTE **buf, size_t wLen, int maxTlvs);
void disposeChain(oscar_tlv_chain** chain);
-oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, WORD wLen, int nCount);
+oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, size_t wLen, int nCount);
void disposeRecordList(oscar_tlv_record_list** list);
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp
index f97e185b1d..3fd17d71b7 100644
--- a/protocols/IcqOscarJ/src/utilities.cpp
+++ b/protocols/IcqOscarJ/src/utilities.cpp
@@ -597,26 +597,6 @@ char* strUID(DWORD dwUIN, char *pszUID)
}
-/* a strlen() that likes NULL */
-int __fastcall strlennull(const char *string)
-{
- if (string)
- return (int)strlen(string);
-
- return 0;
-}
-
-
-/* a wcslen() that likes NULL */
-int __fastcall strlennull(const WCHAR *string)
-{
- if (string)
- return (int)wcslen(string);
-
- return 0;
-}
-
-
/* a strcmp() that likes NULL */
int __fastcall strcmpnull(const char *str1, const char *str2)
{
@@ -699,10 +679,9 @@ WCHAR* __fastcall null_strcpy(WCHAR *dest, const WCHAR *src, size_t maxlen)
}
-int __fastcall null_strcut(char *string, int maxlen)
+size_t __fastcall null_strcut(char *string, size_t maxlen)
{ // limit the string to max length (null & utf-8 strings ready)
- int len = (int)strlennull(string);
-
+ size_t len = mir_strlen(string);
if (len < maxlen)
return len;
@@ -712,9 +691,9 @@ int __fastcall null_strcut(char *string, int maxlen)
{ // find the first byte of possible multi-byte character
while ((string[len] & 0xc0) == 0x80) len--;
}
+
// simply cut the string
string[len] = '\0';
-
return len;
}
@@ -731,12 +710,11 @@ void parseServerAddress(char* szServer, WORD* wPort)
szServer[i] = '\0';
}
-char* DemangleXml(const char *string, int len)
+char* DemangleXml(const char *string, size_t len)
{
char *szWork = (char*)SAFE_MALLOC(len + 1), *szChar = szWork;
- int i;
- for (i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
if (!_strnicmp(string + i, "&gt;", 4)) {
*szChar = '>';
szChar++;
@@ -767,16 +745,22 @@ char* DemangleXml(const char *string, int len)
return szWork;
}
-char* MangleXml(const char *string, int len)
+char* MangleXml(const char *string, size_t len)
{
- int i, l = 1;
+ size_t l = 1;
char *szWork, *szChar;
- for (i = 0; i < len; i++) {
- if (string[i] == '<' || string[i] == '>') l += 4; else if (string[i] == '&') l += 5; else if (string[i] == '"') l += 6; else l++;
+ for (size_t i = 0; i < len; i++) {
+ if (string[i] == '<' || string[i] == '>')
+ l += 4;
+ else if (string[i] == '&')
+ l += 5;
+ else if (string[i] == '"')
+ l += 6;
+ else l++;
}
szChar = szWork = (char*)SAFE_MALLOC(l + 1);
- for (i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
if (string[i] == '<') {
*(DWORD*)szChar = ';tl&';
szChar += 4;
@@ -807,14 +791,13 @@ char* MangleXml(const char *string, int len)
return szWork;
}
-char* EliminateHtml(const char *string, int len)
+char* EliminateHtml(const char *string, size_t len)
{
char *tmp = (char*)SAFE_MALLOC(len + 1);
- int i, j;
BOOL tag = FALSE;
char *res;
- for (i = 0, j = 0; i < len; i++) {
+ for (size_t i = 0, j = 0; i < len; i++) {
if (!tag && string[i] == '<') {
if ((i + 4 <= len) && (!_strnicmp(string + i, "<br>", 4) || !_strnicmp(string + i, "<br/>", 5))) { // insert newline
tmp[j] = '\r';
@@ -834,7 +817,7 @@ char* EliminateHtml(const char *string, int len)
tmp[j] = '\0';
}
SAFE_FREE((void**)&string);
- res = DemangleXml(tmp, strlennull(tmp));
+ res = DemangleXml(tmp, mir_strlen(tmp));
SAFE_FREE((void**)&tmp);
return res;
@@ -848,11 +831,11 @@ char* ApplyEncoding(const char *string, const char *pszEncoding)
return null_strdup(string);
if (!_strnicmp(pszEncoding, "unicode-2-0", 11)) { // it is UCS-2 encoded
- int wLen = strlennull((WCHAR*)string) + 1;
- WCHAR *szStr = (WCHAR*)_alloca(wLen * 2);
+ size_t wLen = mir_wstrlen((WCHAR*)string) + 1;
+ WCHAR *szStr = (WCHAR*)_alloca(wLen*2);
BYTE *tmp = (BYTE*)string;
- unpackWideString(&tmp, szStr, (WORD)(wLen * 2));
+ unpackWideString(&tmp, szStr, wLen*2);
return make_utf8_string(szStr);
}
@@ -947,10 +930,10 @@ int RandRange(int nLow, int nHigh)
bool IsStringUIN(const char *pszString)
{
- int nLen = strlennull(pszString);
+ size_t nLen = mir_strlen(pszString);
if (nLen > 0 && pszString[0] != '0') {
- for (int i = 0; i < nLen; i++)
+ for (size_t i = 0; i < nLen; i++)
if ((pszString[i] < '0') || (pszString[i] > '9'))
return FALSE;
@@ -1075,9 +1058,9 @@ void __cdecl CIcqProto::SetStatusNoteThread(void *pDelay)
m_ratesMutex->Leave();
BYTE *pBuffer = NULL;
- int cbBuffer = 0;
+ size_t cbBuffer = 0;
- ppackTLV(&pBuffer, &cbBuffer, 0x226, strlennull(setStatusNoteText), (BYTE*)setStatusNoteText);
+ ppackTLV(&pBuffer, &cbBuffer, 0x226, mir_strlen(setStatusNoteText), (BYTE*)setStatusNoteText);
icq_changeUserDirectoryInfoServ(pBuffer, cbBuffer, DIRECTORYREQUEST_UPDATENOTE);
SAFE_FREE((void**)&pBuffer);
@@ -1123,27 +1106,27 @@ void __cdecl CIcqProto::SetStatusNoteThread(void *pDelay)
if (m_bMoodsEnabled)
setString(DBSETTING_STATUS_MOOD, setStatusMoodData);
- WORD wStatusNoteLen = strlennull(setStatusNoteText);
- WORD wStatusMoodLen = m_bMoodsEnabled ? strlennull(setStatusMoodData) : 0;
- icq_packet packet;
- WORD wDataLen = (wStatusNoteLen ? wStatusNoteLen + 4 : 0) + 4 + wStatusMoodLen + 4;
+ size_t wStatusNoteLen = mir_strlen(setStatusNoteText);
+ size_t wStatusMoodLen = m_bMoodsEnabled ? mir_strlen(setStatusMoodData) : 0;
+ size_t wDataLen = (wStatusNoteLen ? wStatusNoteLen + 4 : 0) + 4 + wStatusMoodLen + 4;
+ icq_packet packet;
serverPacketInit(&packet, wDataLen + 14);
packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_SET_STATUS);
// Change only session data
packWord(&packet, 0x1D); // TLV 1D
- packWord(&packet, wDataLen); // TLV length
+ packWord(&packet, WORD(wDataLen)); // TLV length
packWord(&packet, 0x02); // Item Type
if (wStatusNoteLen) {
- packWord(&packet, 0x400 | (WORD)(wStatusNoteLen + 4)); // Flags + Item Length
- packWord(&packet, wStatusNoteLen); // Text Length
+ packWord(&packet, 0x400 | WORD(wStatusNoteLen + 4)); // Flags + Item Length
+ packWord(&packet, WORD(wStatusNoteLen)); // Text Length
packBuffer(&packet, (LPBYTE)setStatusNoteText, wStatusNoteLen);
packWord(&packet, 0); // Encoding not specified (utf-8 is default)
}
- else
- packWord(&packet, 0); // Flags + Item Length
+ else packWord(&packet, 0); // Flags + Item Length
+
packWord(&packet, 0x0E); // Item Type
- packWord(&packet, wStatusMoodLen); // Flags + Item Length
+ packWord(&packet, WORD(wStatusMoodLen)); // Flags + Item Length
if (wStatusMoodLen)
packBuffer(&packet, (LPBYTE)setStatusMoodData, wStatusMoodLen); // Mood
@@ -1317,112 +1300,6 @@ void CIcqProto::writeDbInfoSettingTLVBlob(MCONTACT hContact, const char *szSetti
delSetting(hContact, szSetting);
}
-
-BOOL CIcqProto::writeDbInfoSettingString(MCONTACT hContact, const char* szSetting, char** buf, WORD* pwLength)
-{
- if (*pwLength < 2)
- return FALSE;
-
- WORD wLen;
- unpackLEWord((LPBYTE*)buf, &wLen);
- *pwLength -= 2;
-
- if (*pwLength < wLen)
- return FALSE;
-
- if ((wLen > 0) && (**buf) && ((*buf)[wLen - 1] == 0)) { // Make sure we have a proper string
- WORD wCp = getWord(hContact, "InfoCodePage", getWord(hContact, "InfoCP", CP_ACP));
- if (wCp != CP_ACP) {
- char *szUtf = ansi_to_utf8_codepage(*buf, wCp);
-
- if (szUtf) {
- db_set_utf(hContact, m_szModuleName, szSetting, szUtf);
- SAFE_FREE((void**)&szUtf);
- }
- else setString(hContact, szSetting, *buf);
- }
- else setString(hContact, szSetting, *buf);
- }
- else delSetting(hContact, szSetting);
-
- *buf += wLen;
- *pwLength -= wLen;
-
- return TRUE;
-}
-
-BOOL CIcqProto::writeDbInfoSettingWord(MCONTACT hContact, const char *szSetting, char **buf, WORD* pwLength)
-{
- if (*pwLength < 2)
- return FALSE;
-
- WORD wVal;
- unpackLEWord((LPBYTE*)buf, &wVal);
- *pwLength -= 2;
-
- if (wVal != 0)
- setWord(hContact, szSetting, wVal);
- else
- delSetting(hContact, szSetting);
-
- return TRUE;
-}
-
-BOOL CIcqProto::writeDbInfoSettingWordWithTable(MCONTACT hContact, const char *szSetting, const FieldNamesItem *table, char **buf, WORD* pwLength)
-{
- if (*pwLength < 2)
- return FALSE;
-
- WORD wVal;
- unpackLEWord((LPBYTE*)buf, &wVal);
- *pwLength -= 2;
-
- char sbuf[MAX_PATH];
- char *text = LookupFieldNameUtf(table, wVal, sbuf, MAX_PATH);
- if (text)
- db_set_utf(hContact, m_szModuleName, szSetting, text);
- else
- delSetting(hContact, szSetting);
-
- return TRUE;
-}
-
-BOOL CIcqProto::writeDbInfoSettingByte(MCONTACT hContact, const char *pszSetting, char **buf, WORD* pwLength)
-{
- if (*pwLength < 1)
- return FALSE;
-
- BYTE byVal;
- unpackByte((LPBYTE*)buf, &byVal);
- *pwLength -= 1;
-
- if (byVal != 0)
- setByte(hContact, pszSetting, byVal);
- else
- delSetting(hContact, pszSetting);
-
- return TRUE;
-}
-
-BOOL CIcqProto::writeDbInfoSettingByteWithTable(MCONTACT hContact, const char *szSetting, const FieldNamesItem *table, char **buf, WORD* pwLength)
-{
- if (*pwLength < 1)
- return FALSE;
-
- BYTE byVal;
- unpackByte((LPBYTE*)buf, &byVal);
- *pwLength -= 1;
-
- char sbuf[MAX_PATH];
- char *text = LookupFieldNameUtf(table, byVal, sbuf, MAX_PATH);
- if (text)
- db_set_utf(hContact, m_szModuleName, szSetting, text);
- else
- delSetting(hContact, szSetting);
-
- return TRUE;
-}
-
char* time2text(time_t time)
{
tm *local = localtime(&time);
@@ -1623,7 +1500,7 @@ char* __fastcall ICQTranslateUtf(const char *src)
{ // this takes UTF-8 strings only!!!
char *szRes = NULL;
- if (!strlennull(src)) { // for the case of empty strings
+ if (!mir_strlen(src)) { // for the case of empty strings
return null_strdup(src);
}
@@ -1639,7 +1516,7 @@ char* __fastcall ICQTranslateUtf(const char *src)
char* __fastcall ICQTranslateUtfStatic(const char *src, char *buf, size_t bufsize)
{ // this takes UTF-8 strings only!!!
- if (strlennull(src)) { // we can use unicode translate (0.5+)
+ if (mir_strlen(src)) { // we can use unicode translate (0.5+)
WCHAR *usrc = make_unicode_string(src);
make_utf8_string_static(TranslateW(usrc), buf, bufsize);
@@ -1655,7 +1532,7 @@ char* __fastcall ICQTranslateUtfStatic(const char *src, char *buf, size_t bufsiz
char* CIcqProto::GetUserStoredPassword(char *szBuffer, int cbSize)
{
if (!getSettingStringStatic(NULL, "Password", szBuffer, cbSize))
- if (strlennull(szBuffer))
+ if (mir_strlen(szBuffer))
return szBuffer;
return NULL;
@@ -1741,7 +1618,7 @@ char* FileNameToUtf(const TCHAR *filename)
int FileAccessUtf(const char *path, int mode)
{
- int size = strlennull(path) + 2;
+ size_t size = mir_strlen(path) + 2;
TCHAR *szPath = (TCHAR*)_alloca(size * sizeof(TCHAR));
if (utf8_to_tchar_static(path, szPath, size))
@@ -1753,7 +1630,7 @@ int FileAccessUtf(const char *path, int mode)
int FileStatUtf(const char *path, struct _stati64 *buffer)
{
- int size = strlennull(path) + 2;
+ size_t size = mir_strlen(path) + 2;
TCHAR *szPath = (TCHAR*)_alloca(size * sizeof(TCHAR));
if (utf8_to_tchar_static(path, szPath, size))
@@ -1766,7 +1643,7 @@ int FileStatUtf(const char *path, struct _stati64 *buffer)
int MakeDirUtf(const char *dir)
{
int wRes = -1;
- int size = strlennull(dir) + 2;
+ size_t size = mir_strlen(dir) + 2;
TCHAR *szDir = (TCHAR*)_alloca(size * sizeof(TCHAR));
if (utf8_to_tchar_static(dir, szDir, size)) { // _tmkdir can created only one dir at once
@@ -1795,7 +1672,7 @@ int MakeDirUtf(const char *dir)
int OpenFileUtf(const char *filename, int oflag, int pmode)
{
- int size = strlennull(filename) + 2;
+ size_t size = mir_strlen(filename) + 2;
TCHAR *szFile = (TCHAR*)_alloca(size * sizeof(TCHAR));
if (utf8_to_tchar_static(filename, szFile, size))
@@ -1839,7 +1716,7 @@ char* GetDlgItemTextUtf(HWND hwndDlg, int iItem)
void SetWindowTextUtf(HWND hWnd, const char *szText)
{
- int size = strlennull(szText) + 2;
+ size_t size = mir_strlen(szText) + 2;
TCHAR *tszText = (TCHAR*)_alloca(size * sizeof(TCHAR));
if (utf8_to_tchar_static(szText, tszText, size))
diff --git a/protocols/IcqOscarJ/src/utilities.h b/protocols/IcqOscarJ/src/utilities.h
index b2016f4802..ce1763039c 100644
--- a/protocols/IcqOscarJ/src/utilities.h
+++ b/protocols/IcqOscarJ/src/utilities.h
@@ -65,23 +65,21 @@ char *NickFromHandle(MCONTACT hContact);
char *NickFromHandleUtf(MCONTACT hContact);
char *strUID(DWORD dwUIN, char *pszUID);
-int __fastcall strlennull(const char *string);
int __fastcall strcmpnull(const char *str1, const char *str2);
int __fastcall stricmpnull(const char *str1, const char *str2);
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);
-int __fastcall null_strcut(char *string, int maxlen);
+size_t __fastcall null_strcut(char *string, size_t maxlen);
-int __fastcall strlennull(const WCHAR *string);
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);
-char *DemangleXml(const char *string, int len);
-char *MangleXml(const char *string, int len);
-char *EliminateHtml(const char *string, int len);
+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);
diff --git a/protocols/IcqOscarJ/src/version.h b/protocols/IcqOscarJ/src/version.h
index 5f7bdf2dec..c3cf0026fb 100644
--- a/protocols/IcqOscarJ/src/version.h
+++ b/protocols/IcqOscarJ/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 2
-#define __BUILD_NUM 5
+#define __BUILD_NUM 6
#include <stdver.h>