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/IcqOscarJ/src/capabilities.cpp | 4 ++-- protocols/IcqOscarJ/src/constants.cpp | 2 +- protocols/IcqOscarJ/src/db.cpp | 6 +++--- protocols/IcqOscarJ/src/dlgproc.cpp | 14 ++++++------- protocols/IcqOscarJ/src/editlist.cpp | 2 +- protocols/IcqOscarJ/src/editstring.cpp | 8 ++++---- protocols/IcqOscarJ/src/fam_01service.cpp | 2 +- protocols/IcqOscarJ/src/fam_04message.cpp | 4 ++-- protocols/IcqOscarJ/src/fam_13servclist.cpp | 10 ++++----- protocols/IcqOscarJ/src/fam_15icqserver.cpp | 16 +++++++-------- protocols/IcqOscarJ/src/icq_advsearch.cpp | 4 ++-- protocols/IcqOscarJ/src/icq_avatar.cpp | 8 ++++---- protocols/IcqOscarJ/src/icq_clients.cpp | 12 +++++------ protocols/IcqOscarJ/src/icq_firstrun.cpp | 6 +++--- protocols/IcqOscarJ/src/icq_http.cpp | 6 +++--- protocols/IcqOscarJ/src/icq_menu.cpp | 2 +- protocols/IcqOscarJ/src/icq_opts.cpp | 28 +++++++++++++------------- protocols/IcqOscarJ/src/icq_popups.cpp | 12 +++++------ protocols/IcqOscarJ/src/icq_proto.cpp | 16 +++++++-------- protocols/IcqOscarJ/src/icq_servlist.cpp | 18 ++++++++--------- protocols/IcqOscarJ/src/icq_uploadui.cpp | 4 ++-- protocols/IcqOscarJ/src/icq_xstatus.cpp | 12 +++++------ protocols/IcqOscarJ/src/icqosc_svcs.cpp | 4 ++-- protocols/IcqOscarJ/src/log.cpp | 6 +++--- protocols/IcqOscarJ/src/loginpassword.cpp | 4 ++-- protocols/IcqOscarJ/src/oscar_filetransfer.cpp | 4 ++-- protocols/IcqOscarJ/src/userinfotab.cpp | 2 +- 27 files changed, 108 insertions(+), 108 deletions(-) (limited to 'protocols/IcqOscarJ') diff --git a/protocols/IcqOscarJ/src/capabilities.cpp b/protocols/IcqOscarJ/src/capabilities.cpp index b6af33a09c..6e84fbd13f 100644 --- a/protocols/IcqOscarJ/src/capabilities.cpp +++ b/protocols/IcqOscarJ/src/capabilities.cpp @@ -84,7 +84,7 @@ void NetLog_CapabilityChange(CIcqProto *ppro, const char *szChange, DWORD fdwCap if (!fdwCapabilities) return; - for (int nIndex = 0; nIndex < SIZEOF(CapabilityNames); nIndex++) { + for (int nIndex = 0; nIndex < _countof(CapabilityNames); nIndex++) { // Check if the current capability is present if ((fdwCapabilities & CapabilityNames[nIndex].capID) == CapabilityNames[nIndex].capID) { if (mir_strlen(szBuffer)) @@ -182,7 +182,7 @@ DWORD GetCapabilitiesFromBuffer(BYTE *pBuffer, int nLength) DWORD fdwCaps = 0; // Calculate the number of records - int nRecordSize = SIZEOF(CapabilityRecord); + int nRecordSize = _countof(CapabilityRecord); // Loop over all capabilities in the buffer and // compare them to our own record of capabilities diff --git a/protocols/IcqOscarJ/src/constants.cpp b/protocols/IcqOscarJ/src/constants.cpp index f97298b955..a5543315ee 100644 --- a/protocols/IcqOscarJ/src/constants.cpp +++ b/protocols/IcqOscarJ/src/constants.cpp @@ -128,4 +128,4 @@ const SettingItem setting[] = { LPGEN("Interest areas 4"), LI_STRING, DBVT_UTF8, "Interest3Text" }, }; -const int settingCount = SIZEOF(setting); +const int settingCount = _countof(setting); diff --git a/protocols/IcqOscarJ/src/db.cpp b/protocols/IcqOscarJ/src/db.cpp index a17d929da8..cadfd7eab6 100644 --- a/protocols/IcqOscarJ/src/db.cpp +++ b/protocols/IcqOscarJ/src/db.cpp @@ -85,7 +85,7 @@ void ChangeInfoData::LoadSettingsFromDb(int keepChanged) char buf[MAX_PATH]; TCHAR tbuf[MAX_PATH]; - if (utf8_to_tchar_static(GetItemSettingText(i, buf, SIZEOF(buf)), tbuf, SIZEOF(tbuf))) + if (utf8_to_tchar_static(GetItemSettingText(i, buf, _countof(buf)), tbuf, _countof(tbuf))) ListView_SetItemText(hwndList, i, 1, tbuf); } } @@ -136,7 +136,7 @@ static INT_PTR CALLBACK PwConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, { char szTest[16]; - GetDlgItemTextA(hwndDlg, IDC_OLDPASS, szTest, SIZEOF(szTest)); + GetDlgItemTextA(hwndDlg, IDC_OLDPASS, szTest, _countof(szTest)); if (mir_strcmp(szTest, dat->ppro->GetUserPassword(TRUE))) { MessageBox(hwndDlg, TranslateT("The password does not match your current password. Check Caps Lock and try again."), TranslateT("Change ICQ Details"), MB_OK); @@ -145,7 +145,7 @@ static INT_PTR CALLBACK PwConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, break; } - GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szTest, SIZEOF(szTest)); + GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szTest, _countof(szTest)); if (mir_strcmp(szTest, dat->Pass)) { MessageBox(hwndDlg, TranslateT("The password does not match the password you originally entered. Check Caps Lock and try again."), TranslateT("Change ICQ Details"), MB_OK); SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_SETSEL, 0, (LPARAM)-1); diff --git a/protocols/IcqOscarJ/src/dlgproc.cpp b/protocols/IcqOscarJ/src/dlgproc.cpp index 704764c848..3b0cc7f6ab 100644 --- a/protocols/IcqOscarJ/src/dlgproc.cpp +++ b/protocols/IcqOscarJ/src/dlgproc.cpp @@ -125,7 +125,7 @@ char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize) void ChangeInfoData::PaintItemSetting(HDC hdc, RECT *rc, int i, UINT itemState) { char str[MAX_PATH]; - char *text = GetItemSettingText(i, str, SIZEOF(str)); + char *text = GetItemSettingText(i, str, _countof(str)); const SettingItem &si = setting[i]; SettingItemData &sid = settingData[i]; @@ -204,7 +204,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR text[MAX_PATH]; lvi.lParam = lvi.iItem; lvi.pszText = text; - utf8_to_tchar_static(setting[lvi.iItem].szDescription, text, SIZEOF(text)); + utf8_to_tchar_static(setting[lvi.iItem].szDescription, text, _countof(text)); ListView_InsertItem(dat->hwndList, &lvi); } } @@ -467,17 +467,17 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (ack->type != ACKTYPE_SETINFO) break; if (ack->result == ACKRESULT_SUCCESS) { - for (i = 0; i < SIZEOF(dat->hUpload); i++) + for (i = 0; i < _countof(dat->hUpload); i++) if (dat->hUpload[i] && ack->hProcess == dat->hUpload[i]) break; - if (i == SIZEOF(dat->hUpload)) break; + if (i == _countof(dat->hUpload)) break; dat->hUpload[i] = NULL; - for (done = 0, i = 0; i < SIZEOF(dat->hUpload); i++) + for (done = 0, i = 0; i < _countof(dat->hUpload); i++) done += dat->hUpload[i] == NULL; TCHAR buf[MAX_PATH]; - mir_sntprintf(buf, TranslateT("Upload in progress...%d%%"), 100 * done / (SIZEOF(dat->hUpload))); + mir_sntprintf(buf, TranslateT("Upload in progress...%d%%"), 100 * done / (_countof(dat->hUpload))); SetDlgItemText(hwndDlg, IDC_UPLOADING, buf); - if (done < SIZEOF(dat->hUpload)) break; + if (done < _countof(dat->hUpload)) break; dat->ClearChangeFlags(); UnhookEvent(dat->hAckHook); diff --git a/protocols/IcqOscarJ/src/editlist.cpp b/protocols/IcqOscarJ/src/editlist.cpp index df632256d5..dfaebb4c85 100644 --- a/protocols/IcqOscarJ/src/editlist.cpp +++ b/protocols/IcqOscarJ/src/editlist.cpp @@ -175,7 +175,7 @@ void ChangeInfoData::EndListEdit(int save) if (sid.changed) { char buf[MAX_PATH]; TCHAR tbuf[MAX_PATH]; - if (utf8_to_tchar_static(ICQTranslateUtfStatic(pItem.text, buf, SIZEOF(buf)), tbuf, SIZEOF(buf))) + if (utf8_to_tchar_static(ICQTranslateUtfStatic(pItem.text, buf, _countof(buf)), tbuf, _countof(buf))) ListView_SetItemText(hwndList, iEditItem, 1, tbuf); EnableDlgItem(GetParent(hwndList), IDC_SAVE, TRUE); diff --git a/protocols/IcqOscarJ/src/editstring.cpp b/protocols/IcqOscarJ/src/editstring.cpp index 2ea8f8eb1c..1cd3a2f805 100644 --- a/protocols/IcqOscarJ/src/editstring.cpp +++ b/protocols/IcqOscarJ/src/editstring.cpp @@ -79,7 +79,7 @@ static void EscapesToBinary(char *str) memmove(str+1,codeend,mir_strlen(codeend)+1); continue; } - for(int i=0;i=8) { @@ -325,7 +325,7 @@ void ChangeInfoData::EndStringEdit(int save) if (sid.changed) { TCHAR tbuf[MAX_PATH]; - GetWindowText(hwndEdit, tbuf, SIZEOF(tbuf)); + GetWindowText(hwndEdit, tbuf, _countof(tbuf)); ListView_SetItemText(hwndList, iEditItem, 1, tbuf); EnableDlgItem(hwndDlg, IDC_SAVE, TRUE); diff --git a/protocols/IcqOscarJ/src/fam_01service.cpp b/protocols/IcqOscarJ/src/fam_01service.cpp index 2f31a8a890..d1361cf9f3 100644 --- a/protocols/IcqOscarJ/src/fam_01service.cpp +++ b/protocols/IcqOscarJ/src/fam_01service.cpp @@ -735,7 +735,7 @@ void CIcqProto::handleServUINSettings(int nPort, serverthread_info *info) // prepare mood id if (m_bMoodsEnabled && bXStatus && moodXStatus[bXStatus - 1] != -1) - mir_snprintf(szMoodData, SIZEOF(szMoodData), "icqmood%d", moodXStatus[bXStatus - 1]); + mir_snprintf(szMoodData, _countof(szMoodData), "icqmood%d", moodXStatus[bXStatus - 1]); else szMoodData[0] = '\0'; diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index 9715065269..2b9c68bfca 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -1517,7 +1517,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, if ((BYTE)*pszMsg == 0xFE) { *pszMsg = '\0'; pszMsgField[nMsgFields++] = pszMsg + 1; - if (nMsgFields >= SIZEOF(pszMsgField)) + if (nMsgFields >= _countof(pszMsgField)) break; } } @@ -2605,7 +2605,7 @@ void CIcqProto::handleTypingNotification(BYTE *buf, size_t wLen) char szMsg[MAX_PATH]; char *nick = NickFromHandleUtf(hContact); - mir_snprintf(szMsg, SIZEOF(szMsg), ICQTranslateUtfStatic(LPGEN("Contact \"%s\" has closed the message window."), szFormat, MAX_PATH), nick); + mir_snprintf(szMsg, _countof(szMsg), ICQTranslateUtfStatic(LPGEN("Contact \"%s\" has closed the message window."), szFormat, MAX_PATH), nick); ShowPopupMsg(hContact, ICQTranslateUtfStatic(LPGEN("ICQ Note"), szFormat, MAX_PATH), szMsg, LOG_NOTE); SAFE_FREE((void**)&nick); diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp index 83e28ffa0f..4d52f6fc21 100644 --- a/protocols/IcqOscarJ/src/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp @@ -181,7 +181,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, size_t wBufferLength, snac_hea break; char szLogText[MAX_PATH]; - mir_snprintf(szLogText, SIZEOF(szLogText), szChange, nItems); + mir_snprintf(szLogText, _countof(szLogText), szChange, nItems); debugLogA("Server sent SNAC(x13,x%02x) - %s", pSnacHeader->wSubtype, szLogText); } break; @@ -288,7 +288,7 @@ void CIcqProto::handleServerCListRightsReply(BYTE *buf, size_t wLen) for (int i = 0; i < pTLV->wLen / 2; i++) { m_wServerListLimits[i] = (pLimits[i] & 0xFF) << 8 | (pLimits[i] >> 8); - if (i + 1 >= SIZEOF(m_wServerListLimits)) + if (i + 1 >= _countof(m_wServerListLimits)) break; } @@ -1248,7 +1248,7 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wItem char *nick = NickFromHandleUtf(hContact); setByte(hContact, "Auth", 0); - mir_snprintf(str, ICQTranslateUtfStatic(LPGEN("Contact \"%s\" was authorized in the server list."), msg, SIZEOF(msg)), nick); + mir_snprintf(str, ICQTranslateUtfStatic(LPGEN("Contact \"%s\" was authorized in the server list."), msg, _countof(msg)), nick); icq_LogMessage(LOG_WARNING, str); SAFE_FREE(&nick); } @@ -1258,7 +1258,7 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wItem char *nick = NickFromHandleUtf(hContact); setByte(hContact, "Auth", 1); - mir_snprintf(str, ICQTranslateUtfStatic(LPGEN("Contact \"%s\" lost its authorization in the server list."), msg, SIZEOF(msg)), nick); + mir_snprintf(str, ICQTranslateUtfStatic(LPGEN("Contact \"%s\" lost its authorization in the server list."), msg, _countof(msg)), nick); icq_LogMessage(LOG_WARNING, str); SAFE_FREE(&nick); } @@ -1348,7 +1348,7 @@ void CIcqProto::handleServerCListItemDelete(const char *szRecordName, WORD wItem char msg[MAX_PATH]; char *nick = NickFromHandleUtf(hContact); - mir_snprintf(str, ICQTranslateUtfStatic(LPGEN("User \"%s\" was removed from server list."), msg, SIZEOF(msg)), nick); + mir_snprintf(str, ICQTranslateUtfStatic(LPGEN("User \"%s\" was removed from server list."), msg, _countof(msg)), nick); icq_LogMessage(LOG_WARNING, str); SAFE_FREE(&nick); } diff --git a/protocols/IcqOscarJ/src/fam_15icqserver.cpp b/protocols/IcqOscarJ/src/fam_15icqserver.cpp index 7ecfae6408..7c6a406454 100644 --- a/protocols/IcqOscarJ/src/fam_15icqserver.cpp +++ b/protocols/IcqOscarJ/src/fam_15icqserver.cpp @@ -525,7 +525,7 @@ int CIcqProto::parseUserInfoRecord(MCONTACT hContact, oscar_tlv *pData, UserInfo for (int i = 0; i < nRecordDef; i++) { char szItemKey[MAX_PATH]; - mir_snprintf(szItemKey, SIZEOF(szItemKey), pRecordDef[i].szDbSetting, nRecords); + mir_snprintf(szItemKey, _countof(szItemKey), pRecordDef[i].szDbSetting, nRecords); switch (pRecordDef[i].dbType) { case DBVT_UTF8: @@ -550,7 +550,7 @@ int CIcqProto::parseUserInfoRecord(MCONTACT hContact, oscar_tlv *pData, UserInfo for (int i = nRecords; i <= nMaxRecords; i++) for (int j = 0; j < nRecordDef; j++) { char szItemKey[MAX_PATH]; - mir_snprintf(szItemKey, SIZEOF(szItemKey), pRecordDef[j].szDbSetting, i); + mir_snprintf(szItemKey, _countof(szItemKey), pRecordDef[j].szDbSetting, i); delSetting(hContact, szItemKey); } @@ -784,9 +784,9 @@ void CIcqProto::parseDirectoryUserDetailsData(MCONTACT hContact, oscar_tlv_chain writeDbInfoSettingTLVStringUtf(hContact, "LastName", cDetails, 0x6E); writeDbInfoSettingTLVStringUtf(hContact, "Nick", cDetails, 0x78); // Home Address - parseUserInfoRecord(hContact, cDetails->getTLV(0x96, 1), rAddress, SIZEOF(rAddress), 1); + parseUserInfoRecord(hContact, cDetails->getTLV(0x96, 1), rAddress, _countof(rAddress), 1); // Origin Address - parseUserInfoRecord(hContact, cDetails->getTLV(0xA0, 1), rOriginAddress, SIZEOF(rOriginAddress), 1); + parseUserInfoRecord(hContact, cDetails->getTLV(0xA0, 1), rOriginAddress, _countof(rOriginAddress), 1); // Phones pTLV = cDetails->getTLV(0xC8, 1); if (pTLV && pTLV->wLen >= 2) { @@ -825,13 +825,13 @@ void CIcqProto::parseDirectoryUserDetailsData(MCONTACT hContact, oscar_tlv_chain delSetting(hContact, "CompanyFax"); } // Emails - parseUserInfoRecord(hContact, cDetails->getTLV(0x8C, 1), rEmail, SIZEOF(rEmail), 4); + parseUserInfoRecord(hContact, cDetails->getTLV(0x8C, 1), rEmail, _countof(rEmail), 4); writeDbInfoSettingTLVByte(hContact, "Timezone", cDetails, 0x17C); // Company - parseUserInfoRecord(hContact, cDetails->getTLV(0x118, 1), rCompany, SIZEOF(rCompany), 1); + parseUserInfoRecord(hContact, cDetails->getTLV(0x118, 1), rCompany, _countof(rCompany), 1); // Education - parseUserInfoRecord(hContact, cDetails->getTLV(0x10E, 1), rEducation, SIZEOF(rEducation), 1); + parseUserInfoRecord(hContact, cDetails->getTLV(0x10E, 1), rEducation, _countof(rEducation), 1); switch (cDetails->getNumber(0x82, 1)) { case 1: @@ -853,7 +853,7 @@ void CIcqProto::parseDirectoryUserDetailsData(MCONTACT hContact, oscar_tlv_chain writeDbInfoSettingTLVByte(hContact, "MaritalStatus", cDetails, 0x12C); // Interests - parseUserInfoRecord(hContact, cDetails->getTLV(0x122, 1), rInterest, SIZEOF(rInterest), 4); + parseUserInfoRecord(hContact, cDetails->getTLV(0x122, 1), rInterest, _countof(rInterest), 4); writeDbInfoSettingTLVStringUtf(hContact, "About", cDetails, 0x186); diff --git a/protocols/IcqOscarJ/src/icq_advsearch.cpp b/protocols/IcqOscarJ/src/icq_advsearch.cpp index 647faf6392..1d69353995 100644 --- a/protocols/IcqOscarJ/src/icq_advsearch.cpp +++ b/protocols/IcqOscarJ/src/icq_advsearch.cpp @@ -72,7 +72,7 @@ static void searchPackTLVLNTS(PBYTE *buf, size_t *buflen, HWND hwndDlg, UINT idC { char str[512]; - GetDlgItemTextA(hwndDlg, idControl, str, SIZEOF(str)); + GetDlgItemTextA(hwndDlg, idControl, str, _countof(str)); ppackLETLVLNTS(buf, buflen, str, wType, 0); } @@ -81,7 +81,7 @@ static void searchPackTLVWordLNTS(PBYTE *buf, size_t *buflen, HWND hwndDlg, UINT { char str[512]; - GetDlgItemTextA(hwndDlg, idControl, str, SIZEOF(str)); + GetDlgItemTextA(hwndDlg, idControl, str, _countof(str)); ppackLETLVWordLNTS(buf, buflen, w, str, wType, 0); } diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index bf14253fca..53caf1b702 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -79,7 +79,7 @@ void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, mir_sntprintf(szPath, _T("%s\\%S\\"), VARST(_T("%miranda_avatarcache%")), m_szModuleName); FOLDERSGETDATA fgd = { sizeof(fgd) }; - fgd.nMaxPathSize = SIZEOF(szPath); + fgd.nMaxPathSize = _countof(szPath); fgd.szPathT = szPath; fgd.flags = FF_TCHAR; @@ -1158,7 +1158,7 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLen PROTO_AVATAR_INFORMATION ai = { 0 }; ai.format = PA_FORMAT_JPEG; // this is for error only ai.hContact = pCookieData->hContact; - mir_tstrncpy(ai.filename, pCookieData->szFile, SIZEOF(ai.filename)); + mir_tstrncpy(ai.filename, pCookieData->szFile, _countof(ai.filename)); AddAvatarExt(PA_FORMAT_JPEG, ai.filename); ppro->FreeCookie(pSnacHeader->dwRef); @@ -1211,11 +1211,11 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLen const TCHAR *ptszExt; int dwPaFormat = ProtoGetBufferFormat(pBuffer, &ptszExt); TCHAR tszImageFile[MAX_PATH]; - mir_sntprintf(tszImageFile, SIZEOF(tszImageFile), _T("%s%s"), pCookieData->szFile, ptszExt); + mir_sntprintf(tszImageFile, _countof(tszImageFile), _T("%s%s"), pCookieData->szFile, ptszExt); ppro->setByte(pCookieData->hContact, "AvatarType", (BYTE)dwPaFormat); ai.format = dwPaFormat; // set the format - mir_tstrncpy(ai.filename, tszImageFile, SIZEOF(ai.filename)); + mir_tstrncpy(ai.filename, tszImageFile, _countof(ai.filename)); int out = _topen(tszImageFile, _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _S_IREAD | _S_IWRITE); if (out != -1) { diff --git a/protocols/IcqOscarJ/src/icq_clients.cpp b/protocols/IcqOscarJ/src/icq_clients.cpp index 275dce0f04..0993175820 100644 --- a/protocols/IcqOscarJ/src/icq_clients.cpp +++ b/protocols/IcqOscarJ/src/icq_clients.cpp @@ -473,7 +473,7 @@ const char* CIcqProto::detectUserClient( else if (MatchCapability(caps, wLen, &capQipInfium)) { mir_strcpy(szClientBuf, "QIP Infium"); if (dwFT1) { - mir_snprintf(ver, SIZEOF(ver), " (%d)", dwFT1); + mir_snprintf(ver, _countof(ver), " (%d)", dwFT1); mir_strcat(szClientBuf, ver); } if (dwFT2 == 0x0B) @@ -484,7 +484,7 @@ const char* CIcqProto::detectUserClient( else if (MatchCapability(caps, wLen, &capQip2010, 12)) { mir_strcpy(szClientBuf, "QIP 2010"); if (dwFT1) { - mir_snprintf(ver, SIZEOF(ver), " (%d)", dwFT1); + mir_snprintf(ver, _countof(ver), " (%d)", dwFT1); mir_strcat(szClientBuf, ver); } @@ -493,7 +493,7 @@ const char* CIcqProto::detectUserClient( else if (MatchCapability(caps, wLen, &capQip2012, 12)) { mir_strcpy(szClientBuf, "QIP 2012"); if (dwFT1) { - mir_snprintf(ver, SIZEOF(ver), " (%d)", dwFT1); + mir_snprintf(ver, _countof(ver), " (%d)", dwFT1); mir_strcat(szClientBuf, ver); } @@ -507,7 +507,7 @@ const char* CIcqProto::detectUserClient( mir_snprintf(szClientBuf, 64, cliQip, ver); if (dwFT1 && dwFT2 == 0x0E) { - mir_snprintf(ver, SIZEOF(ver), " (%d%d%d%d)", dwFT1 >> 0x18, (dwFT1 >> 0x10) & 0xFF, (dwFT1 >> 0x08) & 0xFF, dwFT1 & 0xFF); + mir_snprintf(ver, _countof(ver), " (%d%d%d%d)", dwFT1 >> 0x18, (dwFT1 >> 0x10) & 0xFF, (dwFT1 >> 0x08) & 0xFF, dwFT1 & 0xFF); mir_strcat(szClientBuf, ver); } szClient = szClientBuf; @@ -528,7 +528,7 @@ const char* CIcqProto::detectUserClient( if (dwFT2 == 0x0FFFF0011 && dwFT3 == 0x1100FFFF && (dwFT1 >> 0x18)) { char ver[16]; - mir_snprintf(ver, SIZEOF(ver), " %d.%d", dwFT1 >> 0x18, (dwFT1 >> 0x10) & 0xFF); + mir_snprintf(ver, _countof(ver), " %d.%d", dwFT1 >> 0x18, (dwFT1 >> 0x10) & 0xFF); if ((dwFT1 & 0xFF) == 0x0B) mir_strcat(ver, " Beta"); mir_strcat(szClientBuf, ver); @@ -943,7 +943,7 @@ const char* CIcqProto::detectUserClient( capstr *capId = MatchCapability(caps, wLen, &capMimPack, 4); if (capId) { char szPack[16]; - mir_snprintf(szPack, SIZEOF(szPack), " [%.12s]", (*capId) + 4); + mir_snprintf(szPack, _countof(szPack), " [%.12s]", (*capId) + 4); // make sure client string is not constant if (szClient != szClientBuf) { diff --git a/protocols/IcqOscarJ/src/icq_firstrun.cpp b/protocols/IcqOscarJ/src/icq_firstrun.cpp index cf065c1664..571e4949de 100644 --- a/protocols/IcqOscarJ/src/icq_firstrun.cpp +++ b/protocols/IcqOscarJ/src/icq_firstrun.cpp @@ -30,7 +30,7 @@ static void accountLoadDetails(CIcqProto *ppro, HWND hwndDlg) char pszUIN[20]; DWORD dwUIN = ppro->getContactUin(NULL); if (dwUIN) { - mir_snprintf(pszUIN, SIZEOF(pszUIN), "%u", dwUIN); + mir_snprintf(pszUIN, _countof(pszUIN), "%u", dwUIN); SetDlgItemTextA(hwndDlg, IDC_UIN, pszUIN); } @@ -86,10 +86,10 @@ INT_PTR CALLBACK icq_FirstRunDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: char str[128]; - GetDlgItemTextA(hwndDlg, IDC_UIN, str, SIZEOF(str)); + GetDlgItemTextA(hwndDlg, IDC_UIN, str, _countof(str)); ppro->setDword(UNIQUEIDSETTING, atoi(str)); - GetDlgItemTextA(hwndDlg, IDC_PW, str, SIZEOF(ppro->m_szPassword)); + GetDlgItemTextA(hwndDlg, IDC_PW, str, _countof(ppro->m_szPassword)); mir_strcpy(ppro->m_szPassword, str); ppro->setString("Password", str); break; diff --git a/protocols/IcqOscarJ/src/icq_http.cpp b/protocols/IcqOscarJ/src/icq_http.cpp index 3620340f28..6a46f8e35b 100644 --- a/protocols/IcqOscarJ/src/icq_http.cpp +++ b/protocols/IcqOscarJ/src/icq_http.cpp @@ -54,7 +54,7 @@ int icq_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION*, NETLIBHTTPREQUEST * unpackDWord(&buf, &dwSid2); unpackDWord(&buf, &dwSid3); unpackDWord(&buf, &dwSid4); - mir_snprintf(szSid, SIZEOF(szSid), "%08x%08x%08x%08x", dwSid1, dwSid2, dwSid3, dwSid4); + mir_snprintf(szSid, _countof(szSid), "%08x%08x%08x%08x", dwSid1, dwSid2, dwSid3, dwSid4); unpackWord(&buf, &wIpLen); if(nlhr->dataLength < 30 + wIpLen || wIpLen == 0 || wIpLen > sizeof(szHttpServer) - 1) @@ -73,8 +73,8 @@ int icq_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION*, NETLIBHTTPREQUEST * nlhpi.szHttpGetUrl = szHttpGetUrl; nlhpi.szHttpPostUrl = szHttpPostUrl; nlhpi.firstPostSequence = 1; - mir_snprintf(szHttpGetUrl, SIZEOF(szHttpGetUrl), "http://%s/monitor?sid=%s", szHttpServer, szSid); - mir_snprintf(szHttpPostUrl, SIZEOF(szHttpPostUrl), "http://%s/data?sid=%s&seq=", szHttpServer, szSid); + mir_snprintf(szHttpGetUrl, _countof(szHttpGetUrl), "http://%s/monitor?sid=%s", szHttpServer, szSid); + mir_snprintf(szHttpPostUrl, _countof(szHttpPostUrl), "http://%s/data?sid=%s&seq=", szHttpServer, szSid); return CallService(MS_NETLIB_SETHTTPPROXYINFO, (WPARAM)hConn, (LPARAM)&nlhpi); } diff --git a/protocols/IcqOscarJ/src/icq_menu.cpp b/protocols/IcqOscarJ/src/icq_menu.cpp index afe7cfedfb..b9c66d361a 100644 --- a/protocols/IcqOscarJ/src/icq_menu.cpp +++ b/protocols/IcqOscarJ/src/icq_menu.cpp @@ -177,7 +177,7 @@ INT_PTR CIcqProto::OpenWebProfile(WPARAM hContact, LPARAM) { DWORD dwUin = getContactUin(hContact); char url[256]; - mir_snprintf(url, SIZEOF(url), "http://www.icq.com/people/%d",dwUin); + mir_snprintf(url, _countof(url), "http://www.icq.com/people/%d",dwUin); return CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)url); } diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp index 14d9e7b629..2559bdfb3b 100644 --- a/protocols/IcqOscarJ/src/icq_opts.cpp +++ b/protocols/IcqOscarJ/src/icq_opts.cpp @@ -146,7 +146,7 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP char str[128]; ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, NULL, FALSE)); - GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, SIZEOF(ppro->m_szPassword)); + GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, _countof(ppro->m_szPassword)); if (mir_strlen(str)) { mir_strcpy(ppro->m_szPassword, str); ppro->m_bRememberPwd = true; @@ -154,7 +154,7 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP else ppro->m_bRememberPwd = ppro->getByte("RememberPass", 0); ppro->setString("Password", str); - GetDlgItemTextA(hwndDlg, IDC_ICQSERVER, str, SIZEOF(str)); + GetDlgItemTextA(hwndDlg, IDC_ICQSERVER, str, _countof(str)); ppro->setString("OscarServer", str); ppro->setWord("OscarPort", (WORD)GetDlgItemInt(hwndDlg, IDC_ICQPORT, NULL, FALSE)); @@ -195,7 +195,7 @@ static INT_PTR CALLBACK DlgProcIcqPrivacyOpts(HWND hwndDlg, UINT msg, WPARAM wPa int nAddAuth = ppro->getByte("Auth", 1); if (!ppro->icqOnline()) { - icq_EnableMultipleControls(hwndDlg, icqPrivacyControls, SIZEOF(icqPrivacyControls), FALSE); + icq_EnableMultipleControls(hwndDlg, icqPrivacyControls, _countof(icqPrivacyControls), FALSE); ShowDlgItem(hwndDlg, IDC_STATIC_NOTONLINE, SW_SHOW); } else ShowDlgItem(hwndDlg, IDC_STATIC_NOTONLINE, SW_HIDE); @@ -352,18 +352,18 @@ static INT_PTR CALLBACK DlgProcIcqFeaturesOpts(HWND hwndDlg, UINT msg, WPARAM wP BOOL byData = ppro->getByte("DirectMessaging", DEFAULT_DCMSG_ENABLED); CheckDlgButton(hwndDlg, IDC_DCENABLE, byData ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DCPASSIVE, byData == 1 ? BST_CHECKED : BST_UNCHECKED); - icq_EnableMultipleControls(hwndDlg, icqDCMsgControls, SIZEOF(icqDCMsgControls), byData ? TRUE : FALSE); + icq_EnableMultipleControls(hwndDlg, icqDCMsgControls, _countof(icqDCMsgControls), byData ? TRUE : FALSE); BYTE byXStatusEnabled = ppro->getByte("XStatusEnabled", DEFAULT_XSTATUS_ENABLED); CheckDlgButton(hwndDlg, IDC_XSTATUSENABLE, byXStatusEnabled ? BST_CHECKED : BST_UNCHECKED); BYTE byMoodsEnabled = ppro->getByte("MoodsEnabled", DEFAULT_MOODS_ENABLED); CheckDlgButton(hwndDlg, IDC_MOODSENABLE, byMoodsEnabled ? BST_CHECKED : BST_UNCHECKED); - icq_EnableMultipleControls(hwndDlg, icqXStatusControls, SIZEOF(icqXStatusControls), byXStatusEnabled); - icq_EnableMultipleControls(hwndDlg, icqCustomStatusControls, SIZEOF(icqCustomStatusControls), byXStatusEnabled || byMoodsEnabled); + icq_EnableMultipleControls(hwndDlg, icqXStatusControls, _countof(icqXStatusControls), byXStatusEnabled); + icq_EnableMultipleControls(hwndDlg, icqCustomStatusControls, _countof(icqCustomStatusControls), byXStatusEnabled || byMoodsEnabled); LoadDBCheckState(ppro, hwndDlg, IDC_XSTATUSAUTO, "XStatusAuto", DEFAULT_XSTATUS_AUTO); LoadDBCheckState(ppro, hwndDlg, IDC_XSTATUSRESET, "XStatusReset", DEFAULT_XSTATUS_RESET); LoadDBCheckState(ppro, hwndDlg, IDC_KILLSPAMBOTS, "KillSpambots", DEFAULT_KILLSPAM_ENABLED); LoadDBCheckState(ppro, hwndDlg, IDC_AIMENABLE, "AimEnabled", DEFAULT_AIM_ENABLED); - icq_EnableMultipleControls(hwndDlg, icqAimControls, SIZEOF(icqAimControls), ppro->icqOnline() ? FALSE : TRUE); + icq_EnableMultipleControls(hwndDlg, icqAimControls, _countof(icqAimControls), ppro->icqOnline() ? FALSE : TRUE); hCpCombo = GetDlgItem(hwndDlg, IDC_UTFCODEPAGE); int sCodePage = ppro->getWord("AnsiCodePage", CP_ACP); @@ -389,13 +389,13 @@ static INT_PTR CALLBACK DlgProcIcqFeaturesOpts(HWND hwndDlg, UINT msg, WPARAM wP OptDlgChanged(hwndDlg); break; case IDC_DCENABLE: - icq_EnableMultipleControls(hwndDlg, icqDCMsgControls, SIZEOF(icqDCMsgControls), IsDlgButtonChecked(hwndDlg, IDC_DCENABLE)); + icq_EnableMultipleControls(hwndDlg, icqDCMsgControls, _countof(icqDCMsgControls), IsDlgButtonChecked(hwndDlg, IDC_DCENABLE)); OptDlgChanged(hwndDlg); break; case IDC_XSTATUSENABLE: - icq_EnableMultipleControls(hwndDlg, icqXStatusControls, SIZEOF(icqXStatusControls), IsDlgButtonChecked(hwndDlg, IDC_XSTATUSENABLE)); + icq_EnableMultipleControls(hwndDlg, icqXStatusControls, _countof(icqXStatusControls), IsDlgButtonChecked(hwndDlg, IDC_XSTATUSENABLE)); case IDC_MOODSENABLE: - icq_EnableMultipleControls(hwndDlg, icqCustomStatusControls, SIZEOF(icqCustomStatusControls), IsDlgButtonChecked(hwndDlg, IDC_XSTATUSENABLE) || IsDlgButtonChecked(hwndDlg, IDC_MOODSENABLE)); + icq_EnableMultipleControls(hwndDlg, icqCustomStatusControls, _countof(icqCustomStatusControls), IsDlgButtonChecked(hwndDlg, IDC_XSTATUSENABLE) || IsDlgButtonChecked(hwndDlg, IDC_MOODSENABLE)); default: OptDlgChanged(hwndDlg); break; @@ -454,8 +454,8 @@ static INT_PTR CALLBACK DlgProcIcqContactsOpts(HWND hwndDlg, UINT msg, WPARAM wP LoadDBCheckState(ppro, hwndDlg, IDC_AUTOLOADAVATARS, "AvatarsAutoLoad", DEFAULT_LOAD_AVATARS); LoadDBCheckState(ppro, hwndDlg, IDC_STRICTAVATARCHECK, "StrictAvatarCheck", DEFAULT_AVATARS_CHECK); - icq_EnableMultipleControls(hwndDlg, icqContactsControls, SIZEOF(icqContactsControls), ppro->getByte("UseServerCList", DEFAULT_SS_ENABLED) ? TRUE : FALSE); - icq_EnableMultipleControls(hwndDlg, icqAvatarControls, SIZEOF(icqAvatarControls), ppro->getByte("AvatarsEnabled", DEFAULT_AVATARS_ENABLED) ? TRUE : FALSE); + icq_EnableMultipleControls(hwndDlg, icqContactsControls, _countof(icqContactsControls), ppro->getByte("UseServerCList", DEFAULT_SS_ENABLED) ? TRUE : FALSE); + icq_EnableMultipleControls(hwndDlg, icqAvatarControls, _countof(icqAvatarControls), ppro->getByte("AvatarsEnabled", DEFAULT_AVATARS_ENABLED) ? TRUE : FALSE); if (ppro->icqOnline()) { ShowDlgItem(hwndDlg, IDC_OFFLINETOENABLE, SW_SHOW); @@ -473,14 +473,14 @@ static INT_PTR CALLBACK DlgProcIcqContactsOpts(HWND hwndDlg, UINT msg, WPARAM wP ppro->ShowUploadContactsDialog(); return TRUE; case IDC_ENABLE: - icq_EnableMultipleControls(hwndDlg, icqContactsControls, SIZEOF(icqContactsControls), IsDlgButtonChecked(hwndDlg, IDC_ENABLE)); + icq_EnableMultipleControls(hwndDlg, icqContactsControls, _countof(icqContactsControls), IsDlgButtonChecked(hwndDlg, IDC_ENABLE)); if (ppro->icqOnline()) ShowDlgItem(hwndDlg, IDC_RECONNECTREQD, SW_SHOW); else EnableDlgItem(hwndDlg, IDC_UPLOADNOW, FALSE); break; case IDC_ENABLEAVATARS: - icq_EnableMultipleControls(hwndDlg, icqAvatarControls, SIZEOF(icqAvatarControls), IsDlgButtonChecked(hwndDlg, IDC_ENABLEAVATARS)); + icq_EnableMultipleControls(hwndDlg, icqAvatarControls, _countof(icqAvatarControls), IsDlgButtonChecked(hwndDlg, IDC_ENABLEAVATARS)); break; } OptDlgChanged(hwndDlg); diff --git a/protocols/IcqOscarJ/src/icq_popups.cpp b/protocols/IcqOscarJ/src/icq_popups.cpp index 7c74c31169..8d3239c095 100644 --- a/protocols/IcqOscarJ/src/icq_popups.cpp +++ b/protocols/IcqOscarJ/src/icq_popups.cpp @@ -76,11 +76,11 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR CheckDlgButton(hwndDlg, IDC_USEWINCOLORS, bEnabled ? BST_CHECKED : BST_UNCHECKED); bEnabled |= ppro->getByte(NULL,"PopupsDefColors",DEFAULT_POPUPS_DEF_COLORS); CheckDlgButton(hwndDlg, IDC_USEDEFCOLORS, bEnabled ? BST_CHECKED : BST_UNCHECKED); - icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, SIZEOF(icqPopupColorControls), bEnabled); + icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), bEnabled); CheckDlgButton(hwndDlg, IDC_USESYSICONS, ppro->getByte(NULL,"PopupsSysIcons",DEFAULT_POPUPS_SYS_ICONS) ? BST_CHECKED : BST_UNCHECKED); bEnabled = ppro->getByte(NULL,"PopupsEnabled",DEFAULT_POPUPS_ENABLED); CheckDlgButton(hwndDlg, IDC_POPUPS_ENABLED, bEnabled ? BST_CHECKED : BST_UNCHECKED); - icq_EnableMultipleControls(hwndDlg, icqPopupsControls, SIZEOF(icqPopupsControls), bEnabled); + icq_EnableMultipleControls(hwndDlg, icqPopupsControls, _countof(icqPopupsControls), bEnabled); if (bEnabled) { if (IsDlgButtonChecked(hwndDlg, IDC_USEDEFCOLORS)) @@ -94,7 +94,7 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), !WM_ENABLE); } } - icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, SIZEOF(icqPopupColorControls), bEnabled & (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg,IDC_USEWINCOLORS) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg,IDC_USEDEFCOLORS))); + icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), bEnabled & (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg,IDC_USEWINCOLORS) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg,IDC_USEDEFCOLORS))); bInitDone = true; return TRUE; @@ -130,7 +130,7 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), !WM_ENABLE); EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), !WM_ENABLE); } - icq_EnableMultipleControls(hwndDlg, icqPopupsControls, SIZEOF(icqPopupsControls), bEnabled); + icq_EnableMultipleControls(hwndDlg, icqPopupsControls, _countof(icqPopupsControls), bEnabled); case IDC_USEWINCOLORS: bEnabled = IsDlgButtonChecked(hwndDlg,IDC_POPUPS_ENABLED); @@ -141,7 +141,7 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR else EnableWindow(GetDlgItem(hwndDlg, IDC_USEDEFCOLORS), WM_ENABLE); } - icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, SIZEOF(icqPopupColorControls), !IsDlgButtonChecked(hwndDlg,IDC_USEWINCOLORS)); + icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), !IsDlgButtonChecked(hwndDlg,IDC_USEWINCOLORS)); case IDC_USEDEFCOLORS: bEnabled = IsDlgButtonChecked(hwndDlg,IDC_POPUPS_ENABLED); @@ -152,7 +152,7 @@ INT_PTR CALLBACK DlgProcIcqPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR else EnableWindow(GetDlgItem(hwndDlg, IDC_USEWINCOLORS), WM_ENABLE); } - icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, SIZEOF(icqPopupColorControls), !IsDlgButtonChecked(hwndDlg,IDC_USEDEFCOLORS)); + icq_EnableMultipleControls(hwndDlg, icqPopupColorControls, _countof(icqPopupColorControls), !IsDlgButtonChecked(hwndDlg,IDC_USEDEFCOLORS)); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_POPUP_LOG0_TIMEOUT: diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 7b672381ea..f420108707 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -172,7 +172,7 @@ CIcqProto::CIcqProto(const char* aProtoName, const TCHAR* aUserName) : m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); char szP2PModuleName[MAX_PATH]; - mir_snprintf(szP2PModuleName, SIZEOF(szP2PModuleName), "%sP2P", m_szModuleName); + mir_snprintf(szP2PModuleName, _countof(szP2PModuleName), "%sP2P", m_szModuleName); mir_sntprintf(szBuffer, TranslateT("%s client-to-client connections"), m_tszUserName); nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_TCHAR; nlu.ptszDescriptiveName = szBuffer; @@ -241,9 +241,9 @@ int CIcqProto::OnModulesLoaded(WPARAM, LPARAM) char pszSrvGroupsName[MAX_PATH]; char* modules[5] = { 0, 0, 0, 0, 0 }; - mir_snprintf(pszP2PName, SIZEOF(pszP2PName), "%sP2P", m_szModuleName); - mir_snprintf(pszGroupsName, SIZEOF(pszGroupsName), "%sGroups", m_szModuleName); - mir_snprintf(pszSrvGroupsName, SIZEOF(pszSrvGroupsName), "%sSrvGroups", m_szModuleName); + mir_snprintf(pszP2PName, _countof(pszP2PName), "%sP2P", m_szModuleName); + mir_snprintf(pszGroupsName, _countof(pszGroupsName), "%sGroups", m_szModuleName); + mir_snprintf(pszSrvGroupsName, _countof(pszSrvGroupsName), "%sSrvGroups", m_szModuleName); modules[0] = m_szModuleName; modules[1] = pszP2PName; modules[2] = pszGroupsName; @@ -1215,7 +1215,7 @@ HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const TCHAR* szDescription } else { char tmp[64]; - mir_snprintf(szFiles, SIZEOF(szFiles), ICQTranslateUtfStatic("%d Files", tmp, SIZEOF(tmp)), ft->dwFileCount); + mir_snprintf(szFiles, _countof(szFiles), ICQTranslateUtfStatic("%d Files", tmp, _countof(tmp)), ft->dwFileCount); pszFiles = szFiles; } @@ -1857,11 +1857,11 @@ int __cdecl CIcqProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l case EV_PROTO_ONERASE: { char szDbSetting[MAX_PATH]; - mir_snprintf(szDbSetting, SIZEOF(szDbSetting), "%sP2P", m_szModuleName); + mir_snprintf(szDbSetting, _countof(szDbSetting), "%sP2P", m_szModuleName); CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbSetting); - mir_snprintf(szDbSetting, SIZEOF(szDbSetting), "%sSrvGroups", m_szModuleName); + mir_snprintf(szDbSetting, _countof(szDbSetting), "%sSrvGroups", m_szModuleName); CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbSetting); - mir_snprintf(szDbSetting, SIZEOF(szDbSetting), "%sGroups", m_szModuleName); + mir_snprintf(szDbSetting, _countof(szDbSetting), "%sGroups", m_szModuleName); CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szDbSetting); } break; diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index a361615d41..3b7745d7d0 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -850,7 +850,7 @@ void CIcqProto::LoadServerIDs() int nStart = nServerIDListCount; char szModule[MAX_PATH]; - mir_snprintf(szModule, SIZEOF(szModule), "%sSrvGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sSrvGroups", m_szModuleName); GroupReserveIdsEnumParam param = { this, szModule }; DBCONTACTENUMSETTINGS dbces = { 0 }; @@ -1178,7 +1178,7 @@ int CIcqProto::IsServerGroupsDefined() char szModule[MAX_PATH]; // flush obsolete linking data - mir_snprintf(szModule, SIZEOF(szModule), "%sGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sGroups", m_szModuleName); CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule); iRes = 0; // no groups defined, or older version @@ -1193,7 +1193,7 @@ void CIcqProto::FlushSrvGroupsCache() { char szModule[MAX_PATH]; - mir_snprintf(szModule, SIZEOF(szModule), "%sSrvGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sSrvGroups", m_szModuleName); CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule); } @@ -1273,7 +1273,7 @@ void CIcqProto::removeGroupPathLinks(WORD wGroupID) char szModule[MAX_PATH]; char* pars[3]; - mir_snprintf(szModule, SIZEOF(szModule), "%sGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sGroups", m_szModuleName); pars[0] = NULL; pars[1] = (char*)wGroupID; @@ -1308,7 +1308,7 @@ char* CIcqProto::getServListGroupName(WORD wGroupID) return NULL; } - mir_snprintf(szModule, SIZEOF(szModule), "%sSrvGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sSrvGroups", m_szModuleName); _itoa(wGroupID, szGroup, 0x10); if (!CheckServerID(wGroupID, 0)) { // check if valid id, if not give empty and remove @@ -1330,7 +1330,7 @@ void CIcqProto::setServListGroupName(WORD wGroupID, const char *szGroupName) return; } - mir_snprintf(szModule, SIZEOF(szModule), "%sSrvGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sSrvGroups", m_szModuleName); _itoa(wGroupID, szGroup, 0x10); if (szGroupName) @@ -1344,7 +1344,7 @@ void CIcqProto::setServListGroupName(WORD wGroupID, const char *szGroupName) WORD CIcqProto::getServListGroupLinkID(const char *szPath) { char szModule[MAX_PATH]; - mir_snprintf(szModule, SIZEOF(szModule), "%sGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sGroups", m_szModuleName); WORD wGroupId = db_get_w(NULL, szModule, szPath, 0); @@ -1360,7 +1360,7 @@ WORD CIcqProto::getServListGroupLinkID(const char *szPath) void CIcqProto::setServListGroupLinkID(const char *szPath, WORD wGroupID) { char szModule[MAX_PATH]; - mir_snprintf(szModule, SIZEOF(szModule), "%sGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sGroups", m_szModuleName); if (wGroupID) db_set_w(NULL, szModule, szPath, wGroupID); @@ -1530,7 +1530,7 @@ char* CIcqProto::getServListUniqueGroupName(const char *szGroupName, int bAlloce szGroupNameBase = null_strdup(szGroupName); null_strcut(szGroupNameBase, m_wServerListRecordNameMaxLength); - mir_snprintf(szModule, SIZEOF(szModule), "%sSrvGroups", m_szModuleName); + mir_snprintf(szModule, _countof(szModule), "%sSrvGroups", m_szModuleName); do { pars[0] = (char*)this; diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index d99f10f2bc..edb1b0075d 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -155,7 +155,7 @@ static int GroupEnumIdsEnumProc(const char *szSetting,LPARAM lParam) static void enumServerGroups(CIcqProto* ppro) { char szModule[MAX_PATH+9]; - mir_snprintf(szModule, SIZEOF(szModule), "%s%s", ppro->m_szModuleName, "SrvGroups"); + mir_snprintf(szModule, _countof(szModule), "%s%s", ppro->m_szModuleName, "SrvGroups"); DBCONTACTENUMSETTINGS dbces = { 0 }; dbces.pfnEnumProc = &GroupEnumIdsEnumProc; @@ -809,7 +809,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa hCurrentContact = NULL; currentState = STATE_REGROUP; currentAction = ACTION_NONE; - icq_ShowMultipleControls(hwndDlg, settingsControls, SIZEOF(settingsControls), SW_HIDE); + icq_ShowMultipleControls(hwndDlg, settingsControls, _countof(settingsControls), SW_HIDE); // SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0xFFFFFFFF, 0); // InvalidateRect(GetDlgItem(hwndDlg, IDC_CLIST), NULL, FALSE); EnableDlgItem(hwndDlg, IDC_CLIST, FALSE); diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp index 0e040ddb91..d9d87ad116 100644 --- a/protocols/IcqOscarJ/src/icq_xstatus.cpp +++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp @@ -418,7 +418,7 @@ void CIcqProto::handleXStatusCaps(DWORD dwUIN, char *szUID, MCONTACT hContact, B null_strcpy(szMoodData, moods, moodsize); if (moodXStatus[i] == -1) continue; - mir_snprintf(szMoodId, SIZEOF(szMoodId), "0icqmood%d", moodXStatus[i]); + mir_snprintf(szMoodId, _countof(szMoodId), "0icqmood%d", moodXStatus[i]); if (!mir_strcmp(szMoodId, szMoodData)) { BYTE bXStatusId = (BYTE)(i+1); char str[MAX_PATH]; @@ -510,7 +510,7 @@ void CIcqProto::updateServerCustomStatus(int fullUpdate) // prepare mood id if (m_bMoodsEnabled && bXStatus && moodXStatus[bXStatus-1] != -1) - mir_snprintf(szMoodData, SIZEOF(szMoodData), "0icqmood%d", moodXStatus[bXStatus-1]); + mir_snprintf(szMoodData, _countof(szMoodData), "0icqmood%d", moodXStatus[bXStatus-1]); else szMoodData[0] = '\0'; @@ -717,7 +717,7 @@ static INT_PTR CALLBACK SetXStatusDlgProc(HWND hwndDlg,UINT message,WPARAM wPara break; } - mir_snprintf(str,SIZEOF(str),dat->okButtonFormat,dat->countdown); + mir_snprintf(str,_countof(str),dat->okButtonFormat,dat->countdown); SetDlgItemTextUtf(hwndDlg,IDOK,str); dat->countdown--; break; @@ -857,7 +857,7 @@ void CIcqProto::InitXStatusItems(BOOL bAllowStatus) if (m_bHideXStatusUI || m_bHideXStatusMenu) return; - mir_snprintf(szItem, SIZEOF(szItem), Translate("%s Custom Status"), m_szModuleName); + mir_snprintf(szItem, _countof(szItem), Translate("%s Custom Status"), m_szModuleName); CLISTMENUITEM mi = { sizeof(mi) }; mi.pszPopupName = szItem; @@ -865,7 +865,7 @@ void CIcqProto::InitXStatusItems(BOOL bAllowStatus) mi.position = 2000040000; for (int i = 0; i <= XSTATUS_COUNT; i++) { - mir_snprintf(srvFce, SIZEOF(srvFce), "%s/menuXStatus%d", m_szModuleName, i); + mir_snprintf(srvFce, _countof(srvFce), "%s/menuXStatus%d", m_szModuleName, i); mi.position++; @@ -893,7 +893,7 @@ void InitXStatusIcons() SKINICONDESC sid = { 0 }; sid.section.a = "Protocols/" ICQ_PROTOCOL_NAME "/"LPGEN("Custom Status"); sid.flags = SIDF_PATH_TCHAR; - sid.defaultFile.t = InitXStatusIconLibrary(lib, SIZEOF(lib)); + sid.defaultFile.t = InitXStatusIconLibrary(lib, _countof(lib)); for (int i = 0; i < XSTATUS_COUNT; i++) { char szTemp[100]; diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index 6d4b130956..268904a0a1 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -352,7 +352,7 @@ INT_PTR CIcqProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) GetFullAvatarFileName(dwUIN, szUID, dwPaFormat, tszFile, MAX_PATH * 2); - mir_tstrncpy(pai->filename, tszFile, SIZEOF(pai->filename)); // Avatar API does not support unicode :-( + mir_tstrncpy(pai->filename, tszFile, _countof(pai->filename)); // Avatar API does not support unicode :-( pai->format = dwPaFormat; if (!IsAvatarChanged(pai->hContact, dbv.pbVal, dbv.cpbVal)) { // hashes are the same @@ -370,7 +370,7 @@ INT_PTR CIcqProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) GetAvatarFileName(dwUIN, szUID, tszFile, MAX_PATH * 2); GetAvatarData(pai->hContact, dwUIN, szUID, dbv.pbVal, dbv.cpbVal, tszFile); - mir_tstrncpy(pai->filename, tszFile, SIZEOF(pai->filename)); // Avatar API does not support unicode :-( + mir_tstrncpy(pai->filename, tszFile, _countof(pai->filename)); // Avatar API does not support unicode :-( db_free(&dbv); diff --git a/protocols/IcqOscarJ/src/log.cpp b/protocols/IcqOscarJ/src/log.cpp index cd3b3297de..644fef9e5c 100644 --- a/protocols/IcqOscarJ/src/log.cpp +++ b/protocols/IcqOscarJ/src/log.cpp @@ -119,14 +119,14 @@ void CIcqProto::icq_LogUsingErrorCode(int level, DWORD dwError, const char *szMs default: TCHAR err[512]; - if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, err, SIZEOF(err), NULL)) { + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, err, _countof(err), NULL)) { pszErrorMsg = make_utf8_string(err); bNeedFree = TRUE; } break; } - mir_snprintf(szBuf, SIZEOF(szBuf), "%s%s%s (%s %d)", + mir_snprintf(szBuf, _countof(szBuf), "%s%s%s (%s %d)", szMsg ? ICQTranslateUtfStatic(szMsg, str, 1024) : "", szMsg ? "\r\n\r\n" : "", ICQTranslateUtfStatic(pszErrorMsg, szErrorMsg, 512), @@ -144,6 +144,6 @@ void CIcqProto::icq_LogFatalParam(const char *szMsg, WORD wError) char str[MAX_PATH]; char buf[MAX_PATH]; - mir_snprintf(buf, ICQTranslateUtfStatic(szMsg, str, SIZEOF(str)), wError); + mir_snprintf(buf, ICQTranslateUtfStatic(szMsg, str, _countof(str)), wError); icq_LogMessage(LOG_FATAL, buf); } diff --git a/protocols/IcqOscarJ/src/loginpassword.cpp b/protocols/IcqOscarJ/src/loginpassword.cpp index c7a448b11f..2b19ad07eb 100644 --- a/protocols/IcqOscarJ/src/loginpassword.cpp +++ b/protocols/IcqOscarJ/src/loginpassword.cpp @@ -42,7 +42,7 @@ INT_PTR CALLBACK LoginPasswdDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA DWORD dwUin = ppro->getContactUin(NULL); TCHAR pszUIN[MAX_PATH]; - mir_sntprintf(pszUIN, SIZEOF(pszUIN), TranslateT("Enter a password for UIN %u:"), dwUin); + mir_sntprintf(pszUIN, _countof(pszUIN), TranslateT("Enter a password for UIN %u:"), dwUin); SetDlgItemText(hwndDlg, IDC_INSTRUCTION, pszUIN); SendDlgItemMessage(hwndDlg, IDC_LOGINPW, EM_LIMITTEXT, PASSWORDMAXLEN - 1, 0); @@ -66,7 +66,7 @@ INT_PTR CALLBACK LoginPasswdDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ppro->m_bRememberPwd = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SAVEPASS); ppro->setByte("RememberPass", ppro->m_bRememberPwd); - GetDlgItemTextA(hwndDlg, IDC_LOGINPW, ppro->m_szPassword, SIZEOF(ppro->m_szPassword)); + GetDlgItemTextA(hwndDlg, IDC_LOGINPW, ppro->m_szPassword, _countof(ppro->m_szPassword)); ppro->icq_login(ppro->m_szPassword); diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index cb070ec4bd..d378d71dba 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -474,7 +474,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char * pszFileName = (char*)_alloca(64); char tmp[64]; - mir_snprintf(pszFileName, 64, ICQTranslateUtfStatic(LPGEN("%d Files"), tmp, SIZEOF(tmp)), ft->wFilesCount); + mir_snprintf(pszFileName, 64, ICQTranslateUtfStatic(LPGEN("%d Files"), tmp, _countof(tmp)), ft->wFilesCount); } } // Total Size TLV (ICQ 6 and AIM 6) @@ -1586,7 +1586,7 @@ int CIcqProto::oft_handleFileData(oscar_connection *oc, BYTE *buf, size_t len) char *pszMsg = ICQTranslateUtf(LPGEN("The checksum of file \"%s\" does not match, the file is probably damaged.")); char szBuf[MAX_PATH]; - mir_snprintf(szBuf, SIZEOF(szBuf), pszMsg, ExtractFileName(ft->szThisFile)); + mir_snprintf(szBuf, _countof(szBuf), pszMsg, ExtractFileName(ft->szThisFile)); icq_LogMessage(LOG_ERROR, szBuf); SAFE_FREE(&pszMsg); diff --git a/protocols/IcqOscarJ/src/userinfotab.cpp b/protocols/IcqOscarJ/src/userinfotab.cpp index b286579faf..1b475a068b 100644 --- a/protocols/IcqOscarJ/src/userinfotab.cpp +++ b/protocols/IcqOscarJ/src/userinfotab.cpp @@ -97,7 +97,7 @@ static void SetValue(CIcqProto* ppro, HWND hwndDlg, int idCtrl, MCONTACT hContac pstr = str; if (hContact && ppro->IsDirectConnectionOpen(hContact, DIRECTCONN_STANDARD, 1)) { - ICQTranslateUtfStatic(LPGEN(" (DC Established)"), szExtra, SIZEOF(szExtra)); + ICQTranslateUtfStatic(LPGEN(" (DC Established)"), szExtra, _countof(szExtra)); mir_strcat(str, (char*)szExtra); bUtf = 1; } -- cgit v1.2.3