From 4c814798c7bc7f6a0f92c21b027b26290622aa2f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jun 2015 19:35:42 +0000 Subject: SIZEOF replaced with more secure analog - _countof git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tlen/src/tlen.cpp | 8 ++++---- protocols/Tlen/src/tlen_advsearch.cpp | 2 +- protocols/Tlen/src/tlen_avatar.cpp | 8 ++++---- protocols/Tlen/src/tlen_file.cpp | 4 ++-- protocols/Tlen/src/tlen_iqid.cpp | 8 ++++---- protocols/Tlen/src/tlen_muc.cpp | 10 +++++----- protocols/Tlen/src/tlen_opt.cpp | 22 +++++++++++----------- protocols/Tlen/src/tlen_p2p_new.cpp | 4 ++-- protocols/Tlen/src/tlen_picture.cpp | 16 ++++++++-------- protocols/Tlen/src/tlen_svc.cpp | 4 ++-- protocols/Tlen/src/tlen_thread.cpp | 12 ++++++------ protocols/Tlen/src/tlen_userinfo.cpp | 2 +- protocols/Tlen/src/tlen_voice.cpp | 14 +++++++------- protocols/Tlen/src/tlen_ws.cpp | 4 ++-- 14 files changed, 59 insertions(+), 59 deletions(-) (limited to 'protocols/Tlen') diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp index 8ae89022a8..5667c73c3c 100644 --- a/protocols/Tlen/src/tlen.cpp +++ b/protocols/Tlen/src/tlen.cpp @@ -86,7 +86,7 @@ static IconItem iconList[] = static HANDLE GetIconHandle(int iconId) { - for (int i = 0; i < SIZEOF(iconList); i++) + for (int i = 0; i < _countof(iconList); i++) if (iconList[i].defIconID == iconId) return iconList[i].hIcolib; @@ -108,7 +108,7 @@ void ReleaseIcolibIcon(HICON hIcon) { static void TlenRegisterIcons() { - Icon_Register(hInst, "Protocols/Tlen", iconList, SIZEOF(iconList), "TLEN"); + Icon_Register(hInst, "Protocols/Tlen", iconList, _countof(iconList), "TLEN"); } int TlenProtocol::PrebuildContactMenu(WPARAM hContact, LPARAM lParam) @@ -189,7 +189,7 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM wParam, LPARAM lParam) memset(&cookie, 0, sizeof(cookie)); if (login != NULL && password != NULL) { - mir_snprintf( form, SIZEOF(form), "username=%s&password=%s", login, password); + mir_snprintf( form, _countof(form), "username=%s&password=%s", login, password); headers[0].szName = "Content-Type"; headers[0].szValue = "application/x-www-form-urlencoded"; memset(&req, 0, sizeof(req)); @@ -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, _countof(szFileName), "http://poczta.o2.pl/login.html?sid=%s", cookie); CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szFileName); return 0; } diff --git a/protocols/Tlen/src/tlen_advsearch.cpp b/protocols/Tlen/src/tlen_advsearch.cpp index 1689a93173..aea0a806d0 100644 --- a/protocols/Tlen/src/tlen_advsearch.cpp +++ b/protocols/Tlen/src/tlen_advsearch.cpp @@ -61,7 +61,7 @@ static void FetchField(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i if (hwndDlg == NULL || fieldName == NULL || str == NULL || strSize == NULL) return; - GetDlgItemTextA(hwndDlg, idCtrl, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, idCtrl, text, _countof(text)); if (text[0]) { if ((localFieldName=TlenTextEncode(fieldName)) != NULL) { if ((localText=TlenTextEncode(text)) != NULL) { diff --git a/protocols/Tlen/src/tlen_avatar.cpp b/protocols/Tlen/src/tlen_avatar.cpp index e0722447a9..d548dc3c31 100644 --- a/protocols/Tlen/src/tlen_avatar.cpp +++ b/protocols/Tlen/src/tlen_avatar.cpp @@ -42,7 +42,7 @@ void TlenGetAvatarFileName(TlenProtocol *proto, TLEN_LIST_ITEM *item, TCHAR* pts else { proto->debugLog(_T("getAvatarFilename(): Can not create directory for avatar cache: %s. errno=%d: %s"), ptszDest, errno, strerror(errno)); TCHAR buffer[512]; - mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Cannot create avatars cache directory. ERROR: %d: %s\n%s"), errno, _tcserror(errno), ptszDest); + mir_sntprintf(buffer, _countof(buffer), TranslateT("Cannot create avatars cache directory. ERROR: %d: %s\n%s"), errno, _tcserror(errno), ptszDest); PUShowMessageT(buffer, SM_WARNING); } } @@ -69,7 +69,7 @@ static void RemoveAvatar(TlenProtocol *proto, MCONTACT hContact) { if (hContact == NULL) { proto->threadData->avatarHash[0] = '\0'; } - TlenGetAvatarFileName( proto, NULL, tFileName, SIZEOF(tFileName)-1); + TlenGetAvatarFileName( proto, NULL, tFileName, _countof(tFileName)-1); DeleteFile(tFileName); db_unset(hContact, "ContactPhoto", "File"); db_unset(hContact, proto->m_szModuleName, "AvatarHash"); @@ -100,7 +100,7 @@ static void SetAvatar(TlenProtocol *proto, MCONTACT hContact, TLEN_LIST_ITEM *it proto->threadData->avatarFormat = format; mir_strcpy(proto->threadData->avatarHash, md5); } - TlenGetAvatarFileName(proto, item, filename, SIZEOF(filename)-1); + TlenGetAvatarFileName(proto, item, filename, _countof(filename)-1); DeleteFile(filename); FILE *out = _tfopen(filename, TEXT("wb") ); if (out != NULL) { @@ -111,7 +111,7 @@ static void SetAvatar(TlenProtocol *proto, MCONTACT hContact, TLEN_LIST_ITEM *it db_set_dw(hContact, proto->m_szModuleName, "AvatarFormat", format); } else { TCHAR buffer[128]; - mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Cannot save new avatar file \"%s\" Error:\n\t%s (Error: %d)"), filename, _tcserror(errno), errno); + mir_sntprintf(buffer, _countof(buffer), TranslateT("Cannot save new avatar file \"%s\" Error:\n\t%s (Error: %d)"), filename, _tcserror(errno), errno); PUShowMessageT(buffer, SM_WARNING); proto->debugLog(buffer); return; diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp index 4ab81e9819..2ed6d32e7e 100644 --- a/protocols/Tlen/src/tlen_file.cpp +++ b/protocols/Tlen/src/tlen_file.cpp @@ -558,7 +558,7 @@ void TlenProcessF(XmlNode *node, ThreadData *info) char *from=TlenXmlGetAttrValue(node, "f"); if (from != NULL) { if (strchr(from, '@') == NULL) { - mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, info->server); + mir_snprintf(jid, _countof(jid), "%s@%s", from, info->server); } else { strncpy_s(jid, from, _TRUNCATE); } @@ -585,7 +585,7 @@ void TlenProcessF(XmlNode *node, ThreadData *info) } } else if (numFiles > 1) { - mir_snprintf(szFilename, SIZEOF(szFilename), Translate("%d Files"), numFiles); + mir_snprintf(szFilename, _countof(szFilename), Translate("%d Files"), numFiles); } } diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp index a6a7f39bd4..96b925d0b2 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, _countof(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 @@ -260,7 +260,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) if (strchr(jid, '@') != NULL) { strncpy_s(text, jid, _TRUNCATE); } else { - mir_snprintf(text, SIZEOF(text), "%s@%s", jid, dbv.pszVal); // Add @tlen.pl + mir_snprintf(text, _countof(text), "%s@%s", jid, dbv.pszVal); // Add @tlen.pl } db_free(&dbv); if ((hContact=TlenHContactFromJID(proto, text)) == NULL) { @@ -421,7 +421,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) if (strchr(jid, '@') != NULL) { strncpy_s(jsr.jid, jid, _TRUNCATE); } else { - mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s@%s", jid, dbv.pszVal); + mir_snprintf(jsr.jid, _countof(jsr.jid), "%s@%s", jid, dbv.pszVal); } jsr.jid[sizeof(jsr.jid)-1] = '\0'; jsr.hdr.id.t = mir_a2t(jid); @@ -469,7 +469,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) if (strchr(proto->searchJID, '@') != NULL) strncpy_s(jsr.jid, proto->searchJID, _TRUNCATE); else - mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s@%s", proto->searchJID, dbv.pszVal); + mir_snprintf(jsr.jid, _countof(jsr.jid), "%s@%s", proto->searchJID, dbv.pszVal); jsr.hdr.nick.t = jsr.hdr.firstName.t = jsr.hdr.lastName.t = jsr.hdr.email.t = jsr.hdr.id.t = TEXT(""); ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) id, (LPARAM) &jsr); diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp index 2b733f6285..1571b0d843 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, _countof(jid), "%s@%s", id, dbv.pszVal); db_free(&dbv); if (((hContact=TlenHContactFromJID(proto, jid)) != NULL) || !mir_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, _countof(jid), "%s@%s", from, dbv.pszVal); db_free(&dbv); } else { mir_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, _countof(jid), "%s@%s", from, dbv.pszVal); db_free(&dbv); } else { mir_strcpy(jid, from); @@ -190,7 +190,7 @@ static int TlenMUCSendQuery(TlenProtocol *proto, int type, const char *parent, i if (type == 3) { // find chat room by name char serialId[32]; TLEN_LIST_ITEM *item; - mir_snprintf(serialId, SIZEOF(serialId), TLEN_IQID"%d", TlenSerialNext(proto)); + mir_snprintf(serialId, _countof(serialId), TLEN_IQID"%d", TlenSerialNext(proto)); item = TlenListAdd(proto, LIST_SEARCH, serialId); item->roomName = mir_strdup(parent); TlenSend(proto, "", parent, serialId); @@ -236,7 +236,7 @@ INT_PTR TlenProtocol::MUCContactMenuHandleMUC(WPARAM wParam, LPARAM lParam) if ((hContact=wParam) != NULL && isOnline) { if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { char serialId[32]; - mir_snprintf(serialId, SIZEOF(serialId), TLEN_IQID"%d", TlenSerialNext(this)); + mir_snprintf(serialId, _countof(serialId), TLEN_IQID"%d", TlenSerialNext(this)); item = TlenListAdd(this, LIST_INVITATIONS, serialId); item->nick = mir_strdup(dbv.pszVal); TlenSend(this, "

", serialId); diff --git a/protocols/Tlen/src/tlen_opt.cpp b/protocols/Tlen/src/tlen_opt.cpp index 6442ecf019..42a58970fb 100644 --- a/protocols/Tlen/src/tlen_opt.cpp +++ b/protocols/Tlen/src/tlen_opt.cpp @@ -90,7 +90,7 @@ int TlenProtocol::OptionsInit(WPARAM wParam, LPARAM) odp.ptszTitle = m_tszUserName; odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR; odp.dwInitParam = (LPARAM)this; - for (int i = 0; i < SIZEOF(tabPages); i++) { + for (int i = 0; i < _countof(tabPages); i++) { odp.pszTemplate = MAKEINTRESOURCEA(tabPages[i].dlgId); odp.pfnDlgProc = tabPages[i].dlgProc; odp.ptszTab = tabPages[i].tabName; @@ -158,7 +158,7 @@ INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR bool reconnectRequired = false; DBVARIANT dbv; - GetDlgItemTextA(hwndDlg, IDC_EDIT_USERNAME, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_EDIT_USERNAME, text, _countof(text)); if (db_get(NULL, proto->m_szModuleName, "LoginName", &dbv)) { reconnectRequired = true; } @@ -170,7 +170,7 @@ INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR db_set_s(NULL, proto->m_szModuleName, "LoginName", strlwr(text)); if (IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD)) { - GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, _countof(text)); if (db_get(NULL, proto->m_szModuleName, "Password", &dbv)) { reconnectRequired = true; } @@ -302,7 +302,7 @@ static INT_PTR CALLBACK TlenBasicOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara bool reconnectRequired = false; DBVARIANT dbv; - GetDlgItemTextA(hwndDlg, IDC_EDIT_USERNAME, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_EDIT_USERNAME, text, _countof(text)); if (db_get(NULL, proto->m_szModuleName, "LoginName", &dbv)) { reconnectRequired = true; } @@ -314,7 +314,7 @@ static INT_PTR CALLBACK TlenBasicOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara db_set_s(NULL, proto->m_szModuleName, "LoginName", strlwr(text)); if (IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD)) { - GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, _countof(text)); if (db_get(NULL, proto->m_szModuleName, "Password", &dbv)) { reconnectRequired = true; } @@ -527,7 +527,7 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, bool reconnectRequired = false; DBVARIANT dbv; - GetDlgItemTextA(hwndDlg, IDC_EDIT_LOGIN_SERVER, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_EDIT_LOGIN_SERVER, text, _countof(text)); if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { reconnectRequired = true; } @@ -538,7 +538,7 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, } db_set_s(NULL, proto->m_szModuleName, "LoginServer", strlwr(text)); - GetDlgItemTextA(hwndDlg, IDC_HOST, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_HOST, text, _countof(text)); if (db_get(NULL, proto->m_szModuleName, "ManualHost", &dbv)) { reconnectRequired = true; } @@ -568,16 +568,16 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, db_set_b(NULL, proto->m_szModuleName, "UseFileProxy", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_USE_PROXY)); db_set_w(NULL, proto->m_szModuleName, "FileProxyType", (WORD) SendDlgItemMessage(hwndDlg, IDC_FILE_PROXY_TYPE, CB_GETCURSEL, 0, 0)); - GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_HOST, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_HOST, text, _countof(text)); db_set_s(NULL, proto->m_szModuleName, "FileProxyHost", text); db_set_w(NULL, proto->m_szModuleName, "FileProxyPort", (WORD) GetDlgItemInt(hwndDlg, IDC_FILE_PROXY_PORT, NULL, FALSE)); db_set_b(NULL, proto->m_szModuleName, "FileProxyAuth", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_PROXY_USE_AUTH)); - GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_USER, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_USER, text, _countof(text)); db_set_s(NULL, proto->m_szModuleName, "FileProxyUsername", text); - GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_PASSWORD, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_PASSWORD, text, _countof(text)); db_set_s(NULL, proto->m_szModuleName, "FileProxyPassword", text); if (reconnectRequired && proto->isConnected) @@ -656,7 +656,7 @@ static INT_PTR CALLBACK TlenPopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, } else { delay=GetDlgItemInt(hwndDlg, IDC_DELAY, NULL, FALSE); } - mir_sntprintf(title, SIZEOF(title), TranslateT("%S mail"), proto->m_szModuleName); + mir_sntprintf(title, _countof(title), TranslateT("%S mail"), proto->m_szModuleName); MailPopupPreview((DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORBKG,CPM_GETCOLOUR,0,0), (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORTXT,CPM_GETCOLOUR,0,0), title, diff --git a/protocols/Tlen/src/tlen_p2p_new.cpp b/protocols/Tlen/src/tlen_p2p_new.cpp index 3234fa47f0..1313ee2521 100644 --- a/protocols/Tlen/src/tlen_p2p_new.cpp +++ b/protocols/Tlen/src/tlen_p2p_new.cpp @@ -183,7 +183,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, _countof(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]); @@ -257,7 +257,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, _countof(fileInfo), "%s file(s), %s bytes", c, s); TCHAR* filenameT = mir_utf8decodeT((char*)fileInfo); PROTORECVFILET pre = { 0 }; pre.dwFlags = PRFF_TCHAR; diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp index ea3fb7e2bb..255c1b8e03 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, _countof(message), Translate(msg), filename); TlenLogMessage(proto, TlenHContactFromJID(proto, jid), isSent ? DBEF_SENT : 0, message); } @@ -49,7 +49,7 @@ static void TlenPsPostThread(void *ptr) { DWORD ret; item->ft->s = socket; item->ft->hFileEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - ret = mir_snprintf(header, SIZEOF(header), "", proto->threadData->username, item->ft->jid, item->ft->fileTotalSize, item->jid); + ret = mir_snprintf(header, _countof(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) { @@ -58,7 +58,7 @@ static void TlenPsPostThread(void *ptr) { int i; char header[512]; char fileBuffer[2048]; - i = mir_snprintf(header, SIZEOF(header), "", item->ft->iqId, item->jid); + i = mir_snprintf(header, _countof(header), "", item->ft->iqId, item->jid); TlenWsSend(proto, socket, header, i); proto->debugLogA("Sending picture data..."); for (i = item->ft->filesSize[0]; i > 0; ) { @@ -114,7 +114,7 @@ static void TlenPsGetThread(void *ptr) { char header[512]; char fileBuffer[2048]; TlenXmlInitState(&xmlState); - int header_len = mir_snprintf(header, SIZEOF(header), "", proto->threadData->username, item->ft->jid, item->jid, item->ft->id2); + int header_len = mir_snprintf(header, _countof(header), "", proto->threadData->username, item->ft->jid, item->jid, item->ft->id2); TlenWsSend(proto, socket, header, header_len); proto->debugLogA("Reveiving picture data..."); { @@ -221,7 +221,7 @@ void TlenProcessPic(XmlNode *node, TlenProtocol *proto) { char fileName[MAX_PATH]; char *ext = TlenXmlGetAttrValue(node, "ext"); char *tmpPath = Utils_ReplaceVars( "%miranda_userdata%" ); - int tPathLen = mir_snprintf(fileName, SIZEOF(fileName), "%s\\Images\\Tlen", tmpPath); + int tPathLen = mir_snprintf(fileName, _countof(fileName), "%s\\Images\\Tlen", tmpPath); long oldSize = 0, lSize = atol(size); DWORD dwAttributes = GetFileAttributesA( fileName ); if ( dwAttributes == 0xffffffff || ( dwAttributes & FILE_ATTRIBUTE_DIRECTORY ) == 0 ) @@ -229,7 +229,7 @@ void TlenProcessPic(XmlNode *node, TlenProtocol *proto) { mir_free(tmpPath); fileName[ tPathLen++ ] = '\\'; - mir_snprintf( fileName + tPathLen, SIZEOF(fileName) - tPathLen, "%s.%s", crc, ext ); + mir_snprintf( fileName + tPathLen, _countof(fileName) - tPathLen, "%s.%s", crc, ext ); fp = fopen( fileName, "rb" ); if (fp) { fseek(fp, 0, SEEK_END); @@ -260,7 +260,7 @@ BOOL SendPicture(TlenProtocol *proto, MCONTACT hContact) { char *jid = dbv.pszVal; TCHAR tszFilter[512], tszFileName[MAX_PATH]; - Bitmap_GetFilter(tszFilter, SIZEOF(tszFilter)); + Bitmap_GetFilter(tszFilter, _countof(tszFilter)); tszFileName[0] = '\0'; OPENFILENAME ofn = {0}; @@ -285,7 +285,7 @@ BOOL SendPicture(TlenProtocol *proto, MCONTACT hContact) { char fileBuffer[2048]; int id = TlenSerialNext(proto); T2Utf szFileName(tszFileName); - mir_snprintf(idStr, SIZEOF(idStr), "%d", id); + mir_snprintf(idStr, _countof(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 75dfe31c80..8fd1cb213d 100644 --- a/protocols/Tlen/src/tlen_svc.cpp +++ b/protocols/Tlen/src/tlen_svc.cpp @@ -684,7 +684,7 @@ INT_PTR TlenProtocol::GetAvatarInfo(WPARAM wParam, LPARAM lParam) return GAIR_NOAVATAR; if (avatarHash != NULL && !downloadingAvatar) { - TlenGetAvatarFileName(this, item, pai->filename, SIZEOF(pai->filename)-1); + TlenGetAvatarFileName(this, item, pai->filename, _countof(pai->filename)-1); pai->format = ( pai->hContact == NULL ) ? threadData->avatarFormat : item->avatarFormat; return GAIR_SUCCESS; } @@ -800,7 +800,7 @@ HANDLE TlenProtocol::SendFile(MCONTACT hContact, const TCHAR* szDescription, TCH db_free(&dbv); int id = TlenSerialNext(this); - mir_snprintf(idStr, SIZEOF(idStr), "%d", id); + mir_snprintf(idStr, _countof(idStr), "%d", id); TLEN_LIST_ITEM *item = TlenListAdd(this, LIST_FILE, idStr); if (item != NULL) { ft->iqId = mir_strdup(idStr); diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp index f6c86885b8..4c3c43769f 100644 --- a/protocols/Tlen/src/tlen_thread.cpp +++ b/protocols/Tlen/src/tlen_thread.cpp @@ -72,13 +72,13 @@ static INT_PTR CALLBACK TlenPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - mir_snprintf(text, SIZEOF(text), Translate("Enter password for %s"), (char *) lParam); + mir_snprintf(text, _countof(text), Translate("Enter password for %s"), (char *) lParam); SetDlgItemTextA(hwndDlg, IDC_JID, text); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: - GetDlgItemTextA(hwndDlg, IDC_PASSWORD, onlinePassword, SIZEOF(onlinePassword)); + GetDlgItemTextA(hwndDlg, IDC_PASSWORD, onlinePassword, _countof(onlinePassword)); //EndDialog(hwndDlg, (int) onlinePassword); //return TRUE; // Fall through @@ -207,7 +207,7 @@ void __cdecl TlenServerThread(ThreadData *info) return; } - mir_snprintf(jidStr, SIZEOF(jidStr), "%s@%s", info->username, info->server); + mir_snprintf(jidStr, _countof(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)) { @@ -402,7 +402,7 @@ static void TlenSendAuth(TlenProtocol *proto) { int iqId; char text[128]; char *str = TlenPasswordHash(proto->threadData->password); - mir_snprintf(text, SIZEOF(text), "%s%s", proto->threadData->streamId, str); + mir_snprintf(text, _countof(text), "%s%s", proto->threadData->streamId, str); mir_free(str); str = TlenSha1(text); char *p=TlenTextEncode(proto->threadData->username); @@ -912,7 +912,7 @@ static void TlenProcessW(XmlNode *node, ThreadData *info) char *f = TlenXmlGetAttrValue(node, "f"); if (f != NULL) { char webContactName[128]; - mir_snprintf(webContactName, SIZEOF(webContactName), Translate("%s Web Messages"), info->proto->m_szModuleName); + mir_snprintf(webContactName, _countof(webContactName), Translate("%s Web Messages"), info->proto->m_szModuleName); MCONTACT hContact = TlenHContactFromJID(info->proto, webContactName); if (hContact == NULL) { hContact = TlenDBCreateContact(info->proto, webContactName, webContactName, TRUE); @@ -1198,7 +1198,7 @@ static void TlenProcessV(XmlNode *node, ThreadData *info) char *from=TlenXmlGetAttrValue(node, "f"); if (from != NULL) { if (strchr(from, '@') == NULL) { - mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, info->server); + mir_snprintf(jid, _countof(jid), "%s@%s", from, info->server); } else { strncpy_s(jid, from, _TRUNCATE); } diff --git a/protocols/Tlen/src/tlen_userinfo.cpp b/protocols/Tlen/src/tlen_userinfo.cpp index 161bb926ae..3d1dc7c4e4 100644 --- a/protocols/Tlen/src/tlen_userinfo.cpp +++ b/protocols/Tlen/src/tlen_userinfo.cpp @@ -99,7 +99,7 @@ static void FetchField(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i if (hwndDlg == NULL || fieldName == NULL || str == NULL || strSize == NULL) return; - GetDlgItemTextA(hwndDlg, idCtrl, text, SIZEOF(text)); + GetDlgItemTextA(hwndDlg, idCtrl, text, _countof(text)); if (text[0]) { if ((localFieldName=TlenTextEncode(fieldName)) != NULL) { if ((localText=TlenTextEncode(text)) != NULL) { diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp index a08e906761..3842268777 100644 --- a/protocols/Tlen/src/tlen_voice.cpp +++ b/protocols/Tlen/src/tlen_voice.cpp @@ -493,7 +493,7 @@ static void TlenVoiceReceiveParse(TLEN_FILE_TRANSFER *ft) } { char ttt[2048]; - mir_snprintf(ttt, SIZEOF(ttt), "%s %d %d ", statusTxt, ft->proto->framesAvailableForPlayback, ft->proto->availOverrunValue); + mir_snprintf(ttt, _countof(ttt), "%s %d %d ", statusTxt, ft->proto->framesAvailableForPlayback, ft->proto->availOverrunValue); SetDlgItemTextA(ft->proto->voiceDlgHWND, IDC_STATUS, ttt); } TlenP2PPacketFree(packet); @@ -683,7 +683,7 @@ INT_PTR TlenProtocol::VoiceContactMenuHandleVoice(WPARAM wParam, LPARAM lParam) DBVARIANT dbv; if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { char serialId[32]; - mir_snprintf(serialId, SIZEOF(serialId), "%d", TlenSerialNext(this)); + mir_snprintf(serialId, _countof(serialId), "%d", TlenSerialNext(this)); TLEN_LIST_ITEM *item = TlenListAdd(this, LIST_VOICE, serialId); if (item != NULL) { TLEN_FILE_TRANSFER *ft = TlenFileCreateFT(this, dbv.pszVal); @@ -931,7 +931,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, _countof(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,11 +1012,11 @@ 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, _countof(jid), "%s@%s", from, dbv.pszVal); db_free(&dbv); } else { - strncpy(jid, from, SIZEOF(jid) - 1); + strncpy(jid, from, _countof(jid) - 1); } ignore = !IsAuthorized(proto, jid); ask = true; @@ -1025,11 +1025,11 @@ 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, _countof(jid), "%s@%s", from, dbv.pszVal); db_free(&dbv); } else { - strncpy(jid, from, SIZEOF(jid) - 1); + strncpy(jid, from, _countof(jid) - 1); } ask = !IsAuthorized(proto, jid); ignore = false; diff --git a/protocols/Tlen/src/tlen_ws.cpp b/protocols/Tlen/src/tlen_ws.cpp index 7e31aedd37..7db8152810 100644 --- a/protocols/Tlen/src/tlen_ws.cpp +++ b/protocols/Tlen/src/tlen_ws.cpp @@ -32,13 +32,13 @@ BOOL TlenWsInit(TlenProtocol *proto) nlu.cbSize = sizeof(nlu); nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR; // | NUF_HTTPGATEWAY; - mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), proto->m_tszUserName); + mir_sntprintf(name, _countof(name), TranslateT("%s connection"), proto->m_tszUserName); nlu.ptszDescriptiveName = name; nlu.szSettingsModule = proto->m_szModuleName; proto->m_hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) &nlu); nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_NOOPTIONS | NUF_TCHAR; - mir_sntprintf(name, SIZEOF(name), TranslateT("%s SOCKS connection"), proto->m_tszUserName); + mir_sntprintf(name, _countof(name), TranslateT("%s SOCKS connection"), proto->m_tszUserName); nlu.ptszDescriptiveName = name; proto->hFileNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) &nlu); nlus.cbSize = sizeof(nlus); -- cgit v1.2.3