From 41a7300678e4bb3cd703e2c236e57af4a31962c7 Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Mon, 1 Dec 2014 04:50:22 +0000 Subject: mir_snprintf(..., sizeof() -> SIZEOF(), ...) small fixs cleanups git-svn-id: http://svn.miranda-ng.org/main/trunk@11188 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tlen/src/tlen.cpp | 2 +- protocols/Tlen/src/tlen_file.cpp | 8 ++++---- protocols/Tlen/src/tlen_iqid.cpp | 12 ++++++------ protocols/Tlen/src/tlen_muc.cpp | 10 +++++----- protocols/Tlen/src/tlen_p2p_new.cpp | 4 ++-- protocols/Tlen/src/tlen_p2p_old.cpp | 11 ++++++----- protocols/Tlen/src/tlen_picture.cpp | 16 ++++++++-------- protocols/Tlen/src/tlen_svc.cpp | 2 +- protocols/Tlen/src/tlen_thread.cpp | 6 +++--- protocols/Tlen/src/tlen_voice.cpp | 6 +++--- 10 files changed, 39 insertions(+), 38 deletions(-) (limited to 'protocols/Tlen') diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp index a872d20484..38249081ca 100644 --- a/protocols/Tlen/src/tlen.cpp +++ b/protocols/Tlen/src/tlen.cpp @@ -225,7 +225,7 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM wParam, LPARAM lParam) } mir_free(login); mir_free(password); - mir_snprintf(szFileName, sizeof(szFileName), "http://poczta.o2.pl/login.html?sid=%s", cookie); + mir_snprintf(szFileName, SIZEOF(szFileName), "http://poczta.o2.pl/login.html?sid=%s", cookie); CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) szFileName); return 0; } diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp index 9aa2095994..b0460c24a6 100644 --- a/protocols/Tlen/src/tlen_file.cpp +++ b/protocols/Tlen/src/tlen_file.cpp @@ -276,7 +276,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) t++; else t = ft->files[i]; - mir_snprintf(filename, sizeof(filename)-1, t); + mir_snprintf(filename, (SIZEOF(filename) - 1), "%s", t); TlenP2PPacketPackBuffer(packet, filename, sizeof(filename)); } TlenP2PPacketSend(ft->s, packet); @@ -570,9 +570,9 @@ void TlenProcessF(XmlNode *node, ThreadData *info) if ((from=TlenXmlGetAttrValue(node, "f")) != NULL) { if (strchr(from, '@') == NULL) { - mir_snprintf(jid, sizeof(jid), "%s@%s", from, info->server); + mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, info->server); } else { - mir_snprintf(jid, sizeof(jid), "%s", from); + mir_snprintf(jid, SIZEOF(jid), "%s", from); } if ((e=TlenXmlGetAttrValue(node, "e")) != NULL) { @@ -597,7 +597,7 @@ void TlenProcessF(XmlNode *node, ThreadData *info) } } else if (numFiles > 1) { - mir_snprintf(szFilename, sizeof(szFilename), Translate("%d Files"), numFiles); + mir_snprintf(szFilename, SIZEOF(szFilename), Translate("%d Files"), numFiles); } } diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp index fe6784d5e0..f041d712ca 100644 --- a/protocols/Tlen/src/tlen_iqid.cpp +++ b/protocols/Tlen/src/tlen_iqid.cpp @@ -54,7 +54,7 @@ void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) char text[128]; TlenSend(proto, ""); - mir_snprintf(text, sizeof(text), Translate("Authentication failed for %s@%s."), proto->threadData->username, proto->threadData->server); + mir_snprintf(text, SIZEOF(text), Translate("Authentication failed for %s@%s."), proto->threadData->username, proto->threadData->server); MessageBoxA(NULL, text, Translate("Tlen Authentication"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND); ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD); proto->threadData = NULL; // To disallow auto reconnect @@ -419,9 +419,9 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) if (!strcmp(itemNode->name, "item")) { if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { if (strchr(jid, '@') != NULL) { - mir_snprintf(jsr.jid, sizeof(jsr.jid), "%s", jid); + mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s", jid); } else { - mir_snprintf(jsr.jid, sizeof(jsr.jid), "%s@%s", jid, dbv.pszVal); + mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s@%s", jid, dbv.pszVal); } jsr.jid[sizeof(jsr.jid)-1] = '\0'; jsr.hdr.id = mir_a2t(jid); @@ -467,9 +467,9 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) if (proto->searchJID != NULL) { if (!found) { if (strchr(proto->searchJID, '@') != NULL) { - mir_snprintf(jsr.jid, sizeof(jsr.jid), "%s", proto->searchJID); + mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s", proto->searchJID); } else { - mir_snprintf(jsr.jid, sizeof(jsr.jid), "%s@%s", proto->searchJID, dbv.pszVal); + mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s@%s", proto->searchJID, dbv.pszVal); } jsr.jid[sizeof(jsr.jid)-1] = '\0'; jsr.hdr.nick = mir_tstrdup(TEXT("")); @@ -604,7 +604,7 @@ void TlenIqResultInfo(TlenProtocol *proto, XmlNode *iqNode) if (( hContact=TlenHContactFromJID(proto, item->jid )) != NULL ) { if (item->software == NULL) { char str[128]; - mir_snprintf(str, sizeof(str), "Tlen Protocol %s", item->protocolVersion); + mir_snprintf(str, SIZEOF(str), "Tlen Protocol %s", item->protocolVersion); db_set_s(hContact, proto->m_szModuleName, "MirVer", str); } } diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp index 035f22243a..0f406d9c77 100644 --- a/protocols/Tlen/src/tlen_muc.cpp +++ b/protocols/Tlen/src/tlen_muc.cpp @@ -70,7 +70,7 @@ static char *getDisplayName(TlenProtocol *proto, const char *id) MCONTACT hContact; DBVARIANT dbv; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { - mir_snprintf(jid, sizeof(jid), "%s@%s", id, dbv.pszVal); + mir_snprintf(jid, SIZEOF(jid), "%s@%s", id, dbv.pszVal); db_free(&dbv); if (((hContact=TlenHContactFromJID(proto, jid)) != NULL) || !strcmp(id, proto->threadData->username)) { CONTACTINFO ci = { sizeof(ci) }; @@ -107,7 +107,7 @@ int TlenMUCRecvInvitation(TlenProtocol *proto, const char *roomId, const char *r char jid[256]; DBVARIANT dbv; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { - mir_snprintf(jid, sizeof(jid), "%s@%s", from, dbv.pszVal); + mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, dbv.pszVal); db_free(&dbv); } else { strcpy(jid, from); @@ -119,7 +119,7 @@ int TlenMUCRecvInvitation(TlenProtocol *proto, const char *roomId, const char *r TLEN_LIST_ITEM *item; DBVARIANT dbv; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { - mir_snprintf(jid, sizeof(jid), "%s@%s", from, dbv.pszVal); + mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, dbv.pszVal); db_free(&dbv); } else { strcpy(jid, from); @@ -152,9 +152,9 @@ static int TlenMUCSendPresence(TlenProtocol *proto, const char *roomID, const ch return 1; } if (nick != NULL) { - mir_snprintf(str, sizeof(str), "%s/%s", roomID, nick); + mir_snprintf(str, SIZEOF(str), "%s/%s", roomID, nick); } else { - mir_snprintf(str, sizeof(str), "%s", roomID); + mir_snprintf(str, SIZEOF(str), "%s", roomID); } if ((jid = TlenTextEncode(str)) != NULL) { switch (desiredStatus) { diff --git a/protocols/Tlen/src/tlen_p2p_new.cpp b/protocols/Tlen/src/tlen_p2p_new.cpp index 128bde099d..1591e93c99 100644 --- a/protocols/Tlen/src/tlen_p2p_new.cpp +++ b/protocols/Tlen/src/tlen_p2p_new.cpp @@ -185,7 +185,7 @@ void TlenBindUDPSocket(TLEN_FILE_TRANSFER *ft) char host_name[256]; gethostname(host_name, sizeof(host_name)); hp = gethostbyname(host_name); - mir_snprintf(host_name, sizeof(host_name), "%u.%u.%u.%u", (unsigned char)hp->h_addr_list[0][0], + mir_snprintf(host_name, SIZEOF(host_name), "%u.%u.%u.%u", (unsigned char)hp->h_addr_list[0][0], (unsigned char)hp->h_addr_list[0][1], (unsigned char)hp->h_addr_list[0][2], (unsigned char)hp->h_addr_list[0][3]); @@ -260,7 +260,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { if ((item=TlenListAdd(ft->proto, LIST_FILE, ft->iqId)) != NULL) { char fileInfo[128]; item->ft = ft; - mir_snprintf(fileInfo, sizeof(fileInfo), "%s file(s), %s bytes", c, s); + mir_snprintf(fileInfo, SIZEOF(fileInfo), "%s file(s), %s bytes", c, s); TCHAR* filenameT = mir_utf8decodeT((char*)fileInfo); PROTORECVFILET pre = {0}; pre.flags = PREF_TCHAR; diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp index c8ca8df1dd..e8bea6e2cb 100644 --- a/protocols/Tlen/src/tlen_p2p_old.cpp +++ b/protocols/Tlen/src/tlen_p2p_old.cpp @@ -155,6 +155,7 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck) { char *hash; char str[300]; + size_t srt_len; TLEN_FILE_PACKET *packet; TlenProtocol *proto = ft->proto; @@ -164,8 +165,8 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck) TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_CONNECTION_REQUEST); TlenP2PPacketPackDword(packet, 1); TlenP2PPacketPackDword(packet, (DWORD) atoi(ft->iqId)); - mir_snprintf(str, sizeof(str), "%08X%s%d", atoi(ft->iqId), proto->threadData->username, atoi(ft->iqId)); - hash = TlenSha1(str, (int)strlen(str)); + srt_len = mir_snprintf(str, SIZEOF(str), "%08X%s%d", atoi(ft->iqId), proto->threadData->username, atoi(ft->iqId)); + hash = TlenSha1(str, (int)srt_len); TlenP2PPacketPackBuffer(packet, hash, 20); mir_free(hash); TlenP2PPacketSend(ft->s, packet); @@ -208,14 +209,14 @@ TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HAND i = 0; while ((i=TlenListFindNext(proto, list, i)) >= 0) { if ((item=TlenListGetItemPtrFromIndex(proto, i)) != NULL) { - mir_snprintf(str, sizeof(str), "%d", iqId); + mir_snprintf(str, SIZEOF(str), "%d", iqId); if (!strcmp(item->ft->iqId, str)) { char *hash, *nick; int j; nick = TlenNickFromJID(item->ft->jid); - mir_snprintf(str, sizeof(str), "%08X%s%d", iqId, nick, iqId); + j = mir_snprintf(str, SIZEOF(str), "%08X%s%d", iqId, nick, iqId); mir_free(nick); - hash = TlenSha1(str, (int)strlen(str)); + hash = TlenSha1(str, j); for (j=0;j<20;j++) { if (hash[j] != packet->packet[2*sizeof(DWORD)+j]) break; } diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp index f97cc1fb78..0d39b3db7f 100644 --- a/protocols/Tlen/src/tlen_picture.cpp +++ b/protocols/Tlen/src/tlen_picture.cpp @@ -34,7 +34,7 @@ static void LogPictureMessage(TlenProtocol *proto, const char *jid, const char * { char message[1024]; const char *msg = isSent ? LPGEN("Image sent file://%s") : LPGEN("Image received file://%s"); - mir_snprintf(message, sizeof(message), Translate(msg), filename); + mir_snprintf(message, SIZEOF(message), Translate(msg), filename); TlenLogMessage(proto, TlenHContactFromJID(proto, jid), isSent ? DBEF_SENT : 0, message); } @@ -49,8 +49,8 @@ static void TlenPsPostThread(void *ptr) { DWORD ret; item->ft->s = socket; item->ft->hFileEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - mir_snprintf(header, sizeof(header), "", proto->threadData->username, item->ft->jid, item->ft->fileTotalSize, item->jid); - TlenWsSend(proto, socket, header, (int)strlen(header)); + ret = mir_snprintf(header, SIZEOF(header), "", proto->threadData->username, item->ft->jid, item->ft->fileTotalSize, item->jid); + TlenWsSend(proto, socket, header, (int)ret); ret = WaitForSingleObject(item->ft->hFileEvent, 1000 * 60 * 5); if (ret == WAIT_OBJECT_0) { FILE *fp = fopen( item->ft->files[0], "rb" ); @@ -58,8 +58,8 @@ static void TlenPsPostThread(void *ptr) { int i; char header[512]; char fileBuffer[2048]; - mir_snprintf(header, sizeof(header), "", item->ft->iqId, item->jid); - TlenWsSend(proto, socket, header, (int)strlen(header)); + i = mir_snprintf(header, SIZEOF(header), "", item->ft->iqId, item->jid); + TlenWsSend(proto, socket, header, i); proto->debugLogA("Sending picture data..."); for (i = item->ft->filesSize[0]; i > 0; ) { int toread = min(2048, i); @@ -114,8 +114,8 @@ static void TlenPsGetThread(void *ptr) { char header[512]; char fileBuffer[2048]; TlenXmlInitState(&xmlState); - mir_snprintf(header, sizeof(header), "", proto->threadData->username, item->ft->jid, item->jid, item->ft->id2); - TlenWsSend(proto, socket, header, (int)strlen(header)); + int header_len = mir_snprintf(header, SIZEOF(header), "", proto->threadData->username, item->ft->jid, item->jid, item->ft->id2); + TlenWsSend(proto, socket, header, header_len); proto->debugLogA("Reveiving picture data..."); { int totalcount = 0; @@ -284,7 +284,7 @@ BOOL SendPicture(TlenProtocol *proto, MCONTACT hContact) { char idStr[10]; char fileBuffer[2048]; int id = TlenSerialNext(proto); - mir_snprintf(idStr, sizeof(idStr), "%d", id); + mir_snprintf(idStr, SIZEOF(idStr), "%d", id); item = TlenListAdd(proto, LIST_PICTURE, idStr); item->ft = TlenFileCreateFT(proto, jid); item->ft->files = (char **) mir_alloc(sizeof(char *)); diff --git a/protocols/Tlen/src/tlen_svc.cpp b/protocols/Tlen/src/tlen_svc.cpp index 9cbe6eb764..63520406de 100644 --- a/protocols/Tlen/src/tlen_svc.cpp +++ b/protocols/Tlen/src/tlen_svc.cpp @@ -829,7 +829,7 @@ HANDLE TlenProtocol::SendFile(MCONTACT hContact, const PROTOCHAR* szDescription, db_free(&dbv); id = TlenSerialNext(this); - mir_snprintf(idStr, sizeof(idStr), "%d", id); + mir_snprintf(idStr, SIZEOF(idStr), "%d", id); if ((item=TlenListAdd(this, LIST_FILE, idStr)) != NULL) { ft->iqId = mir_strdup(idStr); nick = TlenNickFromJID(ft->jid); diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp index 0f634b6cff..c243fa11ec 100644 --- a/protocols/Tlen/src/tlen_thread.cpp +++ b/protocols/Tlen/src/tlen_thread.cpp @@ -206,7 +206,7 @@ void __cdecl TlenServerThread(ThreadData *info) return; } - mir_snprintf(jidStr, sizeof(jidStr), "%s@%s", info->username, info->server); + mir_snprintf(jidStr, SIZEOF(jidStr), "%s@%s", info->username, info->server); db_set_s(NULL, info->proto->m_szModuleName, "jid", jidStr); if (!db_get(NULL, info->proto->m_szModuleName, "ManualHost", &dbv)) { @@ -1188,9 +1188,9 @@ static void TlenProcessV(XmlNode *node, ThreadData *info) if ((from=TlenXmlGetAttrValue(node, "f")) != NULL) { if (strchr(from, '@') == NULL) { - mir_snprintf(jid, sizeof(jid), "%s@%s", from, info->server); + mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, info->server); } else { - mir_snprintf(jid, sizeof(jid), "%s", from); + mir_snprintf(jid, SIZEOF(jid), "%s", from); } if ((e=TlenXmlGetAttrValue(node, "e")) != NULL) { if (!strcmp(e, "1")) { diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp index dff4305394..a6c2ab91cb 100644 --- a/protocols/Tlen/src/tlen_voice.cpp +++ b/protocols/Tlen/src/tlen_voice.cpp @@ -932,7 +932,7 @@ static char *getDisplayName(TlenProtocol *proto, const char *id) MCONTACT hContact; DBVARIANT dbv; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { - mir_snprintf(jid, sizeof(jid), "%s@%s", id, dbv.pszVal); + mir_snprintf(jid, SIZEOF(jid), "%s@%s", id, dbv.pszVal); db_free(&dbv); if ((hContact=TlenHContactFromJID(proto, jid)) != NULL) return mir_strdup((char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, 0)); @@ -1012,7 +1012,7 @@ int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from) char jid[256]; DBVARIANT dbv; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { - mir_snprintf(jid, sizeof(jid), "%s@%s", from, dbv.pszVal); + mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, dbv.pszVal); db_free(&dbv); } else { strcpy(jid, from); @@ -1023,7 +1023,7 @@ int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from) char jid[256]; DBVARIANT dbv; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { - mir_snprintf(jid, sizeof(jid), "%s@%s", from, dbv.pszVal); + mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, dbv.pszVal); db_free(&dbv); } else { strcpy(jid, from); -- cgit v1.2.3