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 --- plugins/YAMN/src/account.cpp | 30 +++++++++++----------- plugins/YAMN/src/browser/badconnect.cpp | 2 +- plugins/YAMN/src/browser/mailbrowser.cpp | 44 ++++++++++++++++---------------- plugins/YAMN/src/debug.cpp | 10 ++++---- plugins/YAMN/src/mails/decode.cpp | 2 +- plugins/YAMN/src/mails/mime.cpp | 14 +++++----- plugins/YAMN/src/main.cpp | 16 ++++++------ plugins/YAMN/src/proto/netlib.cpp | 2 +- plugins/YAMN/src/proto/pop3/pop3.cpp | 18 ++++++------- plugins/YAMN/src/proto/pop3/pop3comm.cpp | 6 ++--- plugins/YAMN/src/proto/pop3/pop3opt.cpp | 36 +++++++++++++------------- 11 files changed, 90 insertions(+), 90 deletions(-) (limited to 'plugins/YAMN') diff --git a/plugins/YAMN/src/account.cpp b/plugins/YAMN/src/account.cpp index f240832bee..4f15b8549c 100644 --- a/plugins/YAMN/src/account.cpp +++ b/plugins/YAMN/src/account.cpp @@ -227,7 +227,7 @@ DWORD ReadStringFromMemory(char **Parser,TCHAR *End,char **StoreTo,TCHAR *DebugS Finder=*Parser; while((*Finder != (TCHAR)0) && (Finder<=End)) Finder++; - mir_sntprintf(Debug, SIZEOF(Debug), _T("%s: %s,length is %d, remaining %d chars"), DebugString, *Parser, Finder-*Parser, End-Finder); + mir_sntprintf(Debug, _countof(Debug), _T("%s: %s,length is %d, remaining %d chars"), DebugString, *Parser, Finder-*Parser, End-Finder); MessageBox(NULL,Debug,_T("debug"),MB_OK); if (Finder>=End) return EACC_FILECOMPATIBILITY; @@ -282,7 +282,7 @@ DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo,WCHAR *Deb Finder=*Parser; while((*Finder != (WCHAR)0) && (Finder<=(WCHAR *)End)) Finder++; - mir_sntprintf(Debug, SIZEOF(Debug), L"%s: %s,length is %d, remaining %d chars", DebugString, *Parser, Finder-*Parser, (WCHAR *)End-Finder); + mir_sntprintf(Debug, _countof(Debug), L"%s: %s,length is %d, remaining %d chars", DebugString, *Parser, Finder-*Parser, (WCHAR *)End-Finder); MessageBoxW(NULL,Debug,L"debug",MB_OK); if (Finder>=(WCHAR *)End) return EACC_FILECOMPATIBILITY; @@ -338,7 +338,7 @@ static DWORD ReadNotificationFromMemory(char **Parser, char *End, YAMN_NOTIFICAT if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("NFlags: %04x, remaining %d chars"), Which->Flags, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("NFlags: %04x, remaining %d chars"), Which->Flags, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif @@ -347,7 +347,7 @@ static DWORD ReadNotificationFromMemory(char **Parser, char *End, YAMN_NOTIFICAT if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("PopupB: %04x, remaining %d chars"), Which->PopupB, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("PopupB: %04x, remaining %d chars"), Which->PopupB, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif Which->PopupT = *(COLORREF *)(*Parser); @@ -355,7 +355,7 @@ static DWORD ReadNotificationFromMemory(char **Parser, char *End, YAMN_NOTIFICAT if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("PopupT: %04x, remaining %d chars"), Which->PopupT, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("PopupT: %04x, remaining %d chars"), Which->PopupT, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif Which->PopupTime = *(DWORD *)(*Parser); @@ -363,7 +363,7 @@ static DWORD ReadNotificationFromMemory(char **Parser, char *End, YAMN_NOTIFICAT if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("PopupTime: %04x, remaining %d chars"), Which->PopupTime, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("PopupTime: %04x, remaining %d chars"), Which->PopupTime, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif @@ -513,7 +513,7 @@ DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, char *End) if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("Port: %d, remaining %d chars"), Which->Server->Port, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("Port: %d, remaining %d chars"), Which->Server->Port, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif #ifdef DEBUG_FILEREAD @@ -536,19 +536,19 @@ DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, char *End) if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("Flags: %04x, remaining %d chars"), Which->Flags, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("Flags: %04x, remaining %d chars"), Which->Flags, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif Which->StatusFlags = *(DWORD *)(*Parser); (*Parser) += sizeof(DWORD); #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("STFlags: %04x, remaining %d chars"), Which->StatusFlags, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("STFlags: %04x, remaining %d chars"), Which->StatusFlags, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif Which->PluginFlags = *(DWORD *)(*Parser); (*Parser) += sizeof(DWORD); #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("PFlags: %04x, remaining %d chars"), Which->PluginFlags, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("PFlags: %04x, remaining %d chars"), Which->PluginFlags, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif @@ -559,7 +559,7 @@ DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, char *End) if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("Interval: %d, remaining %d chars"), Which->Interval, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("Interval: %d, remaining %d chars"), Which->Interval, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif @@ -602,7 +602,7 @@ DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, char *End) if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("LastChecked: %04x, remaining %d chars"), Which->LastChecked, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("LastChecked: %04x, remaining %d chars"), Which->LastChecked, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif Which->LastSChecked = *(SYSTEMTIME *)(*Parser); @@ -610,7 +610,7 @@ DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, char *End) if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("LastSChecked: %04x, remaining %d chars"), Which->LastSChecked, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("LastSChecked: %04x, remaining %d chars"), Which->LastSChecked, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif Which->LastSynchronised = *(SYSTEMTIME *)(*Parser); @@ -618,7 +618,7 @@ DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, char *End) if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("LastSynchronised: %04x, remaining %d chars"), Which->LastSynchronised, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("LastSynchronised: %04x, remaining %d chars"), Which->LastSynchronised, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif Which->LastMail = *(SYSTEMTIME *)(*Parser); @@ -626,7 +626,7 @@ DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, char *End) if (*Parser > End) //WARNING! There's only > at the end of testing return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("LastMail: %04x, remaining %d chars"), Which->LastMail, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("LastMail: %04x, remaining %d chars"), Which->LastMail, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif if (*Parser == End) diff --git a/plugins/YAMN/src/browser/badconnect.cpp b/plugins/YAMN/src/browser/badconnect.cpp index 3de6b12064..87acfa97ac 100644 --- a/plugins/YAMN/src/browser/badconnect.cpp +++ b/plugins/YAMN/src/browser/badconnect.cpp @@ -119,7 +119,7 @@ INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg, UINT msg, WPARAM wParam, LP BadConnectPopup.PluginWindowProc = BadConnectPopupProc; BadConnectPopup.PluginData = ActualAccount; - mir_tstrncpy(BadConnectPopup.lptzContactName, _A2T(ActualAccount->Name), SIZEOF(BadConnectPopup.lptzContactName)); + mir_tstrncpy(BadConnectPopup.lptzContactName, _A2T(ActualAccount->Name), _countof(BadConnectPopup.lptzContactName)); } if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr != NULL) { diff --git a/plugins/YAMN/src/browser/mailbrowser.cpp b/plugins/YAMN/src/browser/mailbrowser.cpp index 5aeb0eda6c..1e4ba0ea3d 100644 --- a/plugins/YAMN/src/browser/mailbrowser.cpp +++ b/plugins/YAMN/src/browser/mailbrowser.cpp @@ -583,7 +583,7 @@ int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, struct CMailNu SendMessageW(hListView, LVM_SETITEMTEXTW, (WPARAM)item.iItem, (LPARAM)&item); item.iSubItem = 2; - mir_sntprintf(SizeStr, SIZEOF(SizeStr), L"%d kB", msgq->MailData->Size / 1024); + mir_sntprintf(SizeStr, _countof(SizeStr), L"%d kB", msgq->MailData->Size / 1024); item.pszText = SizeStr; SendMessageW(hListView, LVM_SETITEMTEXTW, (WPARAM)item.iItem, (LPARAM)&item); @@ -601,8 +601,8 @@ int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, struct CMailNu } if ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && (msgq->Flags & YAMN_MSG_POPUP) && (msgq->Flags & YAMN_MSG_NEW)) { - mir_tstrncpy(NewMailPopup.lptzContactName, FromStr, SIZEOF(NewMailPopup.lptzContactName)); - mir_tstrncpy(NewMailPopup.lptzText, UnicodeHeader.Subject, SIZEOF(NewMailPopup.lptzText)); + mir_tstrncpy(NewMailPopup.lptzContactName, FromStr, _countof(NewMailPopup.lptzContactName)); + mir_tstrncpy(NewMailPopup.lptzText, UnicodeHeader.Subject, _countof(NewMailPopup.lptzText)); PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)malloc(sizeof(YAMN_MAILSHOWPARAM)); if (MailParam) { @@ -654,7 +654,7 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun + MN->Virtual.PopupRun)) { char sMsg[250]; - mir_snprintf(sMsg, SIZEOF(sMsg), Translate("%s : %d new mail message(s), %d total"), ActualAccount->Name, MN->Real.PopupNC + MN->Virtual.PopupNC, MN->Real.PopupTC + MN->Virtual.PopupTC); + mir_snprintf(sMsg, _countof(sMsg), Translate("%s : %d new mail message(s), %d total"), ActualAccount->Name, MN->Real.PopupNC + MN->Virtual.PopupNC, MN->Real.PopupTC + MN->Virtual.PopupTC); if (!(nflags & YAMN_ACC_CONTNOEVENT)) { CLISTEVENT cEvent; cEvent.cbSize = sizeof(CLISTEVENT); @@ -690,8 +690,8 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D NewMailPopup.PluginWindowProc = NewMailPopupProc; NewMailPopup.PluginData = (void *)0; //multiple popups - mir_tstrncpy(NewMailPopup.lptzContactName, _A2T(ActualAccount->Name), SIZEOF(NewMailPopup.lptzContactName)); - mir_sntprintf(NewMailPopup.lptzText, SIZEOF(NewMailPopup.lptzText), TranslateT("%d new mail message(s), %d total"), MN->Real.PopupNC + MN->Virtual.PopupNC, MN->Real.PopupTC + MN->Virtual.PopupTC); + mir_tstrncpy(NewMailPopup.lptzContactName, _A2T(ActualAccount->Name), _countof(NewMailPopup.lptzContactName)); + mir_sntprintf(NewMailPopup.lptzText, _countof(NewMailPopup.lptzText), TranslateT("%d new mail message(s), %d total"), MN->Real.PopupNC + MN->Virtual.PopupNC, MN->Real.PopupTC + MN->Virtual.PopupTC); PUAddPopupT(&NewMailPopup); } @@ -793,11 +793,11 @@ void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, D NoNewMailPopup.PluginWindowProc = NoNewMailPopupProc; NoNewMailPopup.PluginData = (void *)0; //it's not new mail popup - mir_tstrncpy(NoNewMailPopup.lptzContactName, _A2T(ActualAccount->Name), SIZEOF(NoNewMailPopup.lptzContactName)); + mir_tstrncpy(NoNewMailPopup.lptzContactName, _A2T(ActualAccount->Name), _countof(NoNewMailPopup.lptzContactName)); if (MN->Real.PopupSL2NC + MN->Virtual.PopupSL2NC) - mir_sntprintf(NoNewMailPopup.lptzText, SIZEOF(NoNewMailPopup.lptzText), TranslateT("No new mail message, %d spam(s)"), MN->Real.PopupSL2NC + MN->Virtual.PopupSL2NC); + mir_sntprintf(NoNewMailPopup.lptzText, _countof(NoNewMailPopup.lptzText), TranslateT("No new mail message, %d spam(s)"), MN->Real.PopupSL2NC + MN->Virtual.PopupSL2NC); else - mir_tstrncpy(NoNewMailPopup.lptzText, TranslateT("No new mail message"), SIZEOF(NoNewMailPopup.lptzText)); + mir_tstrncpy(NoNewMailPopup.lptzText, TranslateT("No new mail message"), _countof(NoNewMailPopup.lptzText)); PUAddPopupT(&NoNewMailPopup); } @@ -1616,8 +1616,8 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg, UINT msg, WPARAM wParam, LPAR TCHAR headname[64] = { 0 }, headvalue[256] = { 0 }; for (courRow = 0; courRow < numRows; courRow++) { if ((nReturnCmd == 1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED) == 0)) continue; - ListView_GetItemText(hList, courRow, 0, headname, SIZEOF(headname)); - ListView_GetItemText(hList, courRow, 1, headvalue, SIZEOF(headvalue)); + ListView_GetItemText(hList, courRow, 0, headname, _countof(headname)); + ListView_GetItemText(hList, courRow, 1, headvalue, _countof(headvalue)); size_t headnamelen = mir_tstrlen(headname); if (headnamelen) sizeNeeded += 1 + headnamelen; sizeNeeded += 3 + mir_tstrlen(headvalue); @@ -1629,8 +1629,8 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg, UINT msg, WPARAM wParam, LPAR int courPos = 0; for (courRow = 0; courRow < numRows; courRow++) { if ((nReturnCmd == 1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED) == 0)) continue; - ListView_GetItemText(hList, courRow, 0, headname, SIZEOF(headname)); - ListView_GetItemText(hList, courRow, 1, headvalue, SIZEOF(headvalue)); + ListView_GetItemText(hList, courRow, 0, headname, _countof(headname)); + ListView_GetItemText(hList, courRow, 1, headvalue, _countof(headvalue)); if (mir_tstrlen(headname)) courPos += mir_sntprintf(&buff[courPos], sizeNeeded + 1, _T("%s:\t%s\r\n"), headname, headvalue); else courPos += mir_sntprintf(&buff[courPos], sizeNeeded + 1, _T("\t%s\r\n"), headvalue); } @@ -2162,7 +2162,7 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR { TCHAR DeleteMsg[1024]; - mir_sntprintf(DeleteMsg, SIZEOF(DeleteMsg), TranslateT("Do you really want to delete %d selected mails?"), Total); + mir_sntprintf(DeleteMsg, _countof(DeleteMsg), TranslateT("Do you really want to delete %d selected mails?"), Total); if (IDOK == MessageBox(hDlg, DeleteMsg, TranslateT("Delete confirmation"), MB_OKCANCEL | MB_ICONWARNING)) { struct DeleteParam ParamToDeleteMails = { YAMN_DELETEVERSION, ThreadRunningEV, ActualAccount, NULL }; @@ -2401,10 +2401,10 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR TCHAR from[128] = { 0 }, subject[256] = { 0 }, size[16] = { 0 }, date[64] = { 0 }; for (courRow = 0; courRow < numRows; courRow++) { if ((nReturnCmd == 1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED) == 0)) continue; - ListView_GetItemText(hList, courRow, 0, from, SIZEOF(from)); - ListView_GetItemText(hList, courRow, 1, subject, SIZEOF(subject)); - ListView_GetItemText(hList, courRow, 2, size, SIZEOF(size)); - ListView_GetItemText(hList, courRow, 3, date, SIZEOF(date)); + ListView_GetItemText(hList, courRow, 0, from, _countof(from)); + ListView_GetItemText(hList, courRow, 1, subject, _countof(subject)); + ListView_GetItemText(hList, courRow, 2, size, _countof(size)); + ListView_GetItemText(hList, courRow, 3, date, _countof(date)); sizeNeeded += 5 + mir_tstrlen(from) + mir_tstrlen(subject) + mir_tstrlen(size) + mir_tstrlen(date); } if (sizeNeeded && OpenClipboard(hDlg)) { @@ -2414,10 +2414,10 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR int courPos = 0; for (courRow = 0; courRow < numRows; courRow++) { if ((nReturnCmd == 1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED) == 0)) continue; - ListView_GetItemText(hList, courRow, 0, from, SIZEOF(from)); - ListView_GetItemText(hList, courRow, 1, subject, SIZEOF(subject)); - ListView_GetItemText(hList, courRow, 2, size, SIZEOF(size)); - ListView_GetItemText(hList, courRow, 3, date, SIZEOF(date)); + ListView_GetItemText(hList, courRow, 0, from, _countof(from)); + ListView_GetItemText(hList, courRow, 1, subject, _countof(subject)); + ListView_GetItemText(hList, courRow, 2, size, _countof(size)); + ListView_GetItemText(hList, courRow, 3, date, _countof(date)); courPos += mir_sntprintf(&buff[courPos], sizeNeeded + 1, _T("%s\t%s\t%s\t%s\r\n"), from, subject, size, date); } GlobalUnlock(hData); diff --git a/plugins/YAMN/src/debug.cpp b/plugins/YAMN/src/debug.cpp index e952e77256..99053b5c49 100644 --- a/plugins/YAMN/src/debug.cpp +++ b/plugins/YAMN/src/debug.cpp @@ -43,21 +43,21 @@ void InitDebug() InitializeCriticalSection(&FileAccessCS); #ifdef DEBUG_SYNCHRO - mir_sntprintf(DebugFileName, SIZEOF(DebugFileName), DebugSynchroFileName2, DebugUserDirectory); + mir_sntprintf(DebugFileName, _countof(DebugFileName), DebugSynchroFileName2, DebugUserDirectory); SynchroFile=CreateFile(DebugFileName,GENERIC_WRITE,FILE_SHARE_WRITE|FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL); DebugLog(SynchroFile,"Synchro debug file created by %s\n",YAMN_VER); #endif #ifdef DEBUG_COMM - mir_sntprintf(DebugFileName, SIZEOF(DebugFileName), DebugCommFileName2, DebugUserDirectory); + mir_sntprintf(DebugFileName, _countof(DebugFileName), DebugCommFileName2, DebugUserDirectory); CommFile=CreateFile(DebugFileName,GENERIC_WRITE,FILE_SHARE_WRITE|FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL); DebugLog(CommFile,"Communication debug file created by %s\n",YAMN_VER); #endif #ifdef DEBUG_DECODE - mir_sntprintf(DebugFileName, SIZEOF(DebugFileName), DebugDecodeFileName2, DebugUserDirectory); + mir_sntprintf(DebugFileName, _countof(DebugFileName), DebugDecodeFileName2, DebugUserDirectory); DecodeFile=CreateFile(DebugFileName,GENERIC_WRITE,FILE_SHARE_WRITE|FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL); DebugLog(DecodeFile,"Decoding kernel debug file created by %s\n",YAMN_VER); @@ -92,7 +92,7 @@ void DebugLog(HANDLE File,const char *fmt,...) va_start(vararg,fmt); str=(char *)malloc(strsize=65536); - mir_snprintf(tids, SIZEOF(tids), "[%x]",GetCurrentThreadId()); + mir_snprintf(tids, _countof(tids), "[%x]",GetCurrentThreadId()); while(mir_vsnprintf(str, strsize, fmt, vararg)==-1) str=(char *)realloc(str,strsize+=65536); va_end(vararg); @@ -113,7 +113,7 @@ void DebugLogW(HANDLE File,const WCHAR *fmt,...) va_start(vararg,fmt); str=(WCHAR *)malloc((strsize=65536)*sizeof(WCHAR)); - mir_snprintf(tids, SIZEOF(tids), "[%x]",GetCurrentThreadId()); + mir_snprintf(tids, _countof(tids), "[%x]",GetCurrentThreadId()); while(mir_vsnwprintf(str, strsize, fmt, vararg)==-1) str=(WCHAR *)realloc(str,(strsize+=65536)*sizeof(WCHAR)); va_end(vararg); diff --git a/plugins/YAMN/src/mails/decode.cpp b/plugins/YAMN/src/mails/decode.cpp index 320cda63ff..96c561808d 100644 --- a/plugins/YAMN/src/mails/decode.cpp +++ b/plugins/YAMN/src/mails/decode.cpp @@ -151,7 +151,7 @@ struct _tcptable CodePageNamesAll[]= { "MAC-", "CR",0,10082} }; -int CPLENALL = SIZEOF(CodePageNamesAll); +int CPLENALL = _countof(CodePageNamesAll); struct _tcptable *CodePageNamesSupp; int CPLENSUPP = 1; diff --git a/plugins/YAMN/src/mails/mime.cpp b/plugins/YAMN/src/mails/mime.cpp index aa0d0b0782..4dc0c5aefc 100644 --- a/plugins/YAMN/src/mails/mime.cpp +++ b/plugins/YAMN/src/mails/mime.cpp @@ -661,36 +661,36 @@ FailBackRaw: for (i=0;i= SIZEOF(iconList)) + if ( idx >= _countof(iconList)) return NULL; return iconList[idx].hIcolib; } HICON WINAPI g_LoadIconEx( int idx, bool big ) { - if ( idx >= SIZEOF(iconList)) + if ( idx >= _countof(iconList)) return NULL; return IcoLib_GetIcon(iconList[idx].szName, big); } @@ -206,7 +206,7 @@ void WINAPI g_ReleaseIcon( HICON hIcon ) static void LoadPlugins() { TCHAR szSearchPath[MAX_PATH]; - mir_sntprintf(szSearchPath, SIZEOF(szSearchPath), _T("%s\\Plugins\\YAMN\\*.dll"), szMirandaDir); + mir_sntprintf(szSearchPath, _countof(szSearchPath), _T("%s\\Plugins\\YAMN\\*.dll"), szMirandaDir); hDllPlugins = NULL; @@ -228,7 +228,7 @@ static void LoadPlugins() continue; TCHAR szPluginPath[MAX_PATH]; - mir_sntprintf(szPluginPath, SIZEOF(szPluginPath),_T("%s\\Plugins\\YAMN\\%s"), szMirandaDir, fd.cFileName); + mir_sntprintf(szPluginPath, _countof(szPluginPath),_T("%s\\Plugins\\YAMN\\%s"), szMirandaDir, fd.cFileName); HINSTANCE hDll = LoadLibrary(szPluginPath); if (hDll == NULL) continue; @@ -266,12 +266,12 @@ extern "C" int __declspec(dllexport) Load(void) PathToAbsoluteT( _T("."), szMirandaDir); // retrieve the current profile name - CallService(MS_DB_GETPROFILENAMET, (WPARAM)SIZEOF(ProfileName), (LPARAM)ProfileName); //not to pass entire array to fcn + CallService(MS_DB_GETPROFILENAMET, (WPARAM)_countof(ProfileName), (LPARAM)ProfileName); //not to pass entire array to fcn TCHAR *fc = _tcsrchr(ProfileName, '.'); if ( fc != NULL ) *fc = 0; // we get the user path where our yamn-account.book.ini is stored from mirandaboot.ini file - GetProfileDirectory(UserDirectory, SIZEOF(UserDirectory)); + GetProfileDirectory(UserDirectory, _countof(UserDirectory)); // Enumerate all the code pages available for the System Locale EnumSystemCodePages(EnumSystemCodePagesProc, CP_INSTALLED); diff --git a/plugins/YAMN/src/proto/netlib.cpp b/plugins/YAMN/src/proto/netlib.cpp index 221fbc2aaf..327b08b0c4 100644 --- a/plugins/YAMN/src/proto/netlib.cpp +++ b/plugins/YAMN/src/proto/netlib.cpp @@ -18,7 +18,7 @@ void __stdcall SSL_DebugLog(const char *fmt, ...) va_list vararg; va_start( vararg, fmt ); - int tBytes = mir_vsnprintf(str, SIZEOF(str), fmt, vararg); + int tBytes = mir_vsnprintf(str, _countof(str), fmt, vararg); if ( tBytes == 0 ) return; diff --git a/plugins/YAMN/src/proto/pop3/pop3.cpp b/plugins/YAMN/src/proto/pop3/pop3.cpp index f03a7d8a99..f75ad174c6 100644 --- a/plugins/YAMN/src/proto/pop3/pop3.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3.cpp @@ -201,7 +201,7 @@ char* CPop3Client::User(char* name) char query[128]; char *Result; - mir_snprintf(query, SIZEOF(query), "USER %s\r\n", name); + mir_snprintf(query, _countof(query), "USER %s\r\n", name); NetClient->Send(query); Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); if (AckFlag==POP3_FERR) @@ -220,7 +220,7 @@ char* CPop3Client::Pass(char* pw) char query[128]; char *Result; - mir_snprintf(query, SIZEOF(query), "PASS %s\r\n", pw); + mir_snprintf(query, _countof(query), "PASS %s\r\n", pw); NetClient->Send(query); Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); if (AckFlag==POP3_FERR) @@ -246,9 +246,9 @@ char* CPop3Client::APOP(char* name, char* pw, char* timestamp) mir_md5_append(&ctx,(const unsigned char *)timestamp,(unsigned int)mir_strlen(timestamp)); mir_md5_append(&ctx,(const unsigned char *)pw,(unsigned int)mir_strlen(pw)); mir_md5_finish(&ctx, digest); - + char hexdigest[40]; - mir_snprintf(query, SIZEOF(query), "APOP %s %s\r\n", name, bin2hex(digest, sizeof(digest), hexdigest)); + mir_snprintf(query, _countof(query), "APOP %s %s\r\n", name, bin2hex(digest, sizeof(digest), hexdigest)); NetClient->Send(query); Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); @@ -302,7 +302,7 @@ char* CPop3Client::Top(int nr, int lines) char query[128]; - mir_snprintf(query, SIZEOF(query), "TOP %d %d\r\n", nr, lines); + mir_snprintf(query, _countof(query), "TOP %d %d\r\n", nr, lines); NetClient->Send(query); return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); } @@ -318,11 +318,11 @@ char* CPop3Client::Uidl(int nr) if (nr) { - mir_snprintf(query, SIZEOF(query), "UIDL %d\r\n", nr); + mir_snprintf(query, _countof(query), "UIDL %d\r\n", nr); NetClient->Send(query); return RecvRest(NetClient->Recv(),POP3_SEARCHACK); } - mir_snprintf(query, SIZEOF(query), "UIDL\r\n"); + mir_snprintf(query, _countof(query), "UIDL\r\n"); NetClient->Send(query); return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); } @@ -336,7 +336,7 @@ char* CPop3Client::Dele(int nr) char query[128]; - mir_snprintf(query, SIZEOF(query), "DELE %d\r\n", nr); + mir_snprintf(query, _countof(query), "DELE %d\r\n", nr); NetClient->Send(query); return RecvRest(NetClient->Recv(),POP3_SEARCHACK); } @@ -349,7 +349,7 @@ char* CPop3Client::Retr(int nr) char query[128]; - mir_snprintf(query, SIZEOF(query), "RETR %d\r\n", nr); + mir_snprintf(query, _countof(query), "RETR %d\r\n", nr); NetClient->Send(query); RecvRest(NetClient->Recv(),POP3_SEARCHACK); return NetClient->Recv(); diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp index 90d9cd5fbf..edfcca0942 100644 --- a/plugins/YAMN/src/proto/pop3/pop3comm.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp @@ -380,7 +380,7 @@ DWORD WINAPI ReadPOP3Options(HACCOUNT Which, char **Parser, char *End) if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD - mir_sntprintf(Debug, SIZEOF(Debug), _T("CodePage: %d, remaining %d chars"), ((HPOP3ACCOUNT)Which)->CP, End-*Parser); + mir_sntprintf(Debug, _countof(Debug), _T("CodePage: %d, remaining %d chars"), ((HPOP3ACCOUNT)Which)->CP, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif return 0; @@ -713,7 +713,7 @@ DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp) for (NewMsgsPtr = (HYAMNMAIL)NewMails; NewMsgsPtr != NULL; NewMsgsPtr = NewMsgsPtr->Next) { if (!mir_strcmp(MsgQueuePtr->ID, NewMsgsPtr->ID)) { TCHAR accstatus[512]; - mir_sntprintf(accstatus, SIZEOF(accstatus), TranslateT("Reading body %s"), NewMsgsPtr->ID); + mir_sntprintf(accstatus, _countof(accstatus), TranslateT("Reading body %s"), NewMsgsPtr->ID); SetAccountStatus(ActualAccount, accstatus); DataRX = MyClient->Top(MsgQueuePtr->Number, 100); #ifdef DEBUG_DECODE @@ -786,7 +786,7 @@ DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp) { BOOL autoretr = (ActualAccount->Flags & YAMN_ACC_BODY) != 0; DataRX = MyClient->Top(MsgQueuePtr->Number, autoretr ? 100 : 0); - mir_sntprintf(accstatus, SIZEOF(accstatus), TranslateT("Reading new mail messages (%d%% done)"), 100 * i / msgs); + mir_sntprintf(accstatus, _countof(accstatus), TranslateT("Reading new mail messages (%d%% done)"), 100 * i / msgs); SetAccountStatus(ActualAccount, accstatus); #ifdef DEBUG_DECODE diff --git a/plugins/YAMN/src/proto/pop3/pop3opt.cpp b/plugins/YAMN/src/proto/pop3/pop3opt.cpp index 76d45d294a..4aaf1db2c1 100644 --- a/plugins/YAMN/src/proto/pop3/pop3opt.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3opt.cpp @@ -119,7 +119,7 @@ INT_PTR CALLBACK DlgProcPluginOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam case IDC_STWWW: { char str[1024]; - GetDlgItemTextA(hDlg,IDC_STWWW,str,SIZEOF(str)); + GetDlgItemTextA(hDlg,IDC_STWWW,str,_countof(str)); CallService(MS_UTILS_OPENURL,OUF_NEWWINDOW,(LPARAM)str); break; } @@ -721,7 +721,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara case WM_YAMN_CHANGETIME: if ((HPOP3ACCOUNT)wParam == ActualAccount) { TCHAR Text[256]; - mir_sntprintf(Text,SIZEOF(Text),TranslateT("Time left to next check [s]: %d"),(DWORD)lParam); + mir_sntprintf(Text,_countof(Text),TranslateT("Time left to next check [s]: %d"),(DWORD)lParam); SetDlgItemText(hDlg,IDC_STTIMELEFT,Text); } return TRUE; @@ -734,14 +734,14 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara ActualAccount=NULL; DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0); - if (GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,SIZEOF(DlgInput))) + if (GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,_countof(DlgInput))) DlgEnableAccount(hDlg,TRUE,FALSE); else DlgEnableAccount(hDlg,FALSE,FALSE); break; case CBN_KILLFOCUS: - GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,SIZEOF(DlgInput)); + GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,_countof(DlgInput)); if (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput))) { DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0); EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),FALSE); @@ -864,7 +864,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara case IDC_BTNAPP: { TCHAR filter[MAX_PATH]; - mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.exe;*.bat;*.cmd;*.com)%c*.exe;*.bat;*.cmd;*.com%c%s (*.*)%c*.*%c"), + mir_sntprintf(filter, _countof(filter), _T("%s (*.exe;*.bat;*.cmd;*.com)%c*.exe;*.bat;*.cmd;*.com%c%s (*.*)%c*.*%c"), TranslateT("Executables"), 0, 0, TranslateT("All Files"), 0, 0); OPENFILENAME OFNStruct = { 0 }; @@ -892,7 +892,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara break; case IDC_BTNDEL: - GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,SIZEOF(DlgInput)); + GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,_countof(DlgInput)); EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),FALSE); if ((CB_ERR==(Result=SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_GETCURSEL,0,0))) || (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput)))) @@ -939,7 +939,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara size_t Length,index; UINT Port,Interval; - if ( GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT, Text, SIZEOF(Text))) { + if ( GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT, Text, _countof(Text))) { Check = (IsDlgButtonChecked(hDlg,IDC_CHECK)==BST_CHECKED); CheckSSL = (IsDlgButtonChecked(hDlg,IDC_CHECKSSL)==BST_CHECKED); CheckNoTLS = (IsDlgButtonChecked(hDlg,IDC_CHECKNOTLS)==BST_CHECKED); @@ -975,15 +975,15 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara break; } - GetDlgItemTextA(hDlg, IDC_EDITAPP, Text, SIZEOF(Text)); + GetDlgItemTextA(hDlg, IDC_EDITAPP, Text, _countof(Text)); if (CheckApp && !(Length = mir_strlen(Text))) { MessageBox(hDlg,TranslateT("Please select application to run"),TranslateT("Input error"),MB_OK); break; } - GetDlgItemTextA(hDlg, IDC_COMBOACCOUNT, Text, SIZEOF(Text)); + GetDlgItemTextA(hDlg, IDC_COMBOACCOUNT, Text, _countof(Text)); if ( !( Length = mir_strlen(Text))) { - GetDlgItemTextA(hDlg,IDC_EDITNAME, Text, SIZEOF(Text)); + GetDlgItemTextA(hDlg,IDC_EDITNAME, Text, _countof(Text)); if ( !(Length = mir_strlen( Text ))) break; } @@ -1036,7 +1036,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara DebugLog(SynchroFile,"Options:APPLY:ActualAccountSO-write enter\n"); #endif - GetDlgItemTextA(hDlg, IDC_EDITNAME, Text, SIZEOF(Text)); + GetDlgItemTextA(hDlg, IDC_EDITNAME, Text, _countof(Text)); if ( !(Length = mir_strlen( Text ))) break; if (NULL != ActualAccount->Name) @@ -1044,31 +1044,31 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara ActualAccount->Name = new char[ mir_strlen(Text)+1]; mir_strcpy(ActualAccount->Name,Text); - GetDlgItemTextA(hDlg,IDC_EDITSERVER,Text,SIZEOF(Text)); + GetDlgItemTextA(hDlg,IDC_EDITSERVER,Text,_countof(Text)); if (NULL != ActualAccount->Server->Name) delete[] ActualAccount->Server->Name; ActualAccount->Server->Name=new char[ mir_strlen(Text)+1]; mir_strcpy(ActualAccount->Server->Name,Text); - GetDlgItemTextA(hDlg,IDC_EDITLOGIN,Text,SIZEOF(Text)); + GetDlgItemTextA(hDlg,IDC_EDITLOGIN,Text,_countof(Text)); if (NULL != ActualAccount->Server->Login) delete[] ActualAccount->Server->Login; ActualAccount->Server->Login=new char[ mir_strlen(Text)+1]; mir_strcpy(ActualAccount->Server->Login,Text); - GetDlgItemTextA(hDlg,IDC_EDITPASS,Text,SIZEOF(Text)); + GetDlgItemTextA(hDlg,IDC_EDITPASS,Text,_countof(Text)); if (NULL != ActualAccount->Server->Passwd) delete[] ActualAccount->Server->Passwd; ActualAccount->Server->Passwd=new char[ mir_strlen(Text)+1]; mir_strcpy(ActualAccount->Server->Passwd,Text); - GetDlgItemTextW(hDlg,IDC_EDITAPP,TextW,SIZEOF(TextW)); + GetDlgItemTextW(hDlg,IDC_EDITAPP,TextW,_countof(TextW)); if (NULL != ActualAccount->NewMailN.App) delete[] ActualAccount->NewMailN.App; ActualAccount->NewMailN.App=new WCHAR[mir_wstrlen(TextW)+1]; mir_wstrcpy(ActualAccount->NewMailN.App,TextW); - GetDlgItemTextW(hDlg,IDC_EDITAPPPARAM,TextW,SIZEOF(TextW)); + GetDlgItemTextW(hDlg,IDC_EDITAPPPARAM,TextW,_countof(TextW)); if (NULL != ActualAccount->NewMailN.AppParam) delete[] ActualAccount->NewMailN.AppParam; ActualAccount->NewMailN.AppParam=new WCHAR[mir_wstrlen(TextW)+1]; @@ -1258,7 +1258,7 @@ INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPa { case CBN_KILLFOCUS: - GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,SIZEOF(DlgInput)); + GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,_countof(DlgInput)); if (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput))) { DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0); @@ -1434,7 +1434,7 @@ INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPa BOOL CheckPopN; UINT Time,TimeN,TimeF; - if (GetDlgItemText(hDlg,IDC_COMBOACCOUNT,Text,SIZEOF(Text))) + if (GetDlgItemText(hDlg,IDC_COMBOACCOUNT,Text,_countof(Text))) { CheckPopup = (IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED); CheckPopupW = (IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED); -- cgit v1.2.3