diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
commit | 4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch) | |
tree | 9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /src/mir_app | |
parent | f0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (diff) |
SIZEOF replaced with more secure analog - _countof
git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
66 files changed, 383 insertions, 383 deletions
diff --git a/src/mir_app/src/DefaultExtraIcons.cpp b/src/mir_app/src/DefaultExtraIcons.cpp index 09ff82aa72..e5fa87d324 100644 --- a/src/mir_app/src/DefaultExtraIcons.cpp +++ b/src/mir_app/src/DefaultExtraIcons.cpp @@ -112,7 +112,7 @@ struct Info static void EmailOnClick(Info*, const char *text)
{
char cmd[1024];
- mir_snprintf(cmd, SIZEOF(cmd), "mailto:%s", text);
+ mir_snprintf(cmd, _countof(cmd), "mailto:%s", text);
ShellExecuteA(NULL, "open", cmd, NULL, NULL, SW_SHOW);
}
@@ -143,10 +143,10 @@ static void SetExtraIcons(MCONTACT hContact) if ( IsEmpty(proto))
return;
- for (unsigned int i = 0; i < SIZEOF(infos); i++) {
+ for (unsigned int i = 0; i < _countof(infos); i++) {
Info &p = infos[i];
- for (unsigned int j = 0; j < SIZEOF(p.db); j += 2) {
+ for (unsigned int j = 0; j < _countof(p.db); j += 2) {
if (p.db[j + 1] == NULL)
break;
@@ -180,10 +180,10 @@ static int SettingChanged(WPARAM hContact, LPARAM lParam) return 0;
}
- for (int i = 0; i < SIZEOF(infos); i++) {
+ for (int i = 0; i < _countof(infos); i++) {
Info &p = infos[i];
- for (int j = 0; j < SIZEOF(p.db); j += 2) {
+ for (int j = 0; j < _countof(p.db); j += 2) {
if (p.db[j + 1] == NULL)
break;
if (p.db[j] == NULL && !isProto)
@@ -216,7 +216,7 @@ static int DefaultOnClick(WPARAM hContact, LPARAM, LPARAM param) return 0;
bool found = false;
- for (int j = 0; !found && j < SIZEOF(p->db); j += 2) {
+ for (int j = 0; !found && j < _countof(p->db); j += 2) {
if (p->db[j + 1] == NULL)
break;
@@ -307,7 +307,7 @@ void DefaultExtraIcons_Load() hExtraProto = ExtraIcon_Register("protocol", "Account", Skin_GetIconName(SKINICON_OTHER_ACCMGR),
&ProtocolRebuildIcons, &ProtocolApplyIcon, &ProtocolOnClick);
- for (int i = 0; i < SIZEOF(infos); i++) {
+ for (int i = 0; i < _countof(infos); i++) {
Info &p = infos[i];
p.hIcolib = Skin_GetIconHandle(p.iSkinIcon);
if (p.OnClick)
diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp index 32d76d2db8..9bea94cc87 100644 --- a/src/mir_app/src/FontOptions.cpp +++ b/src/mir_app/src/FontOptions.cpp @@ -149,7 +149,7 @@ static BOOL ExportSettings(HWND hwndDlg, const TCHAR *filename, OBJLIST<FontInte mir_snprintf(buff, "\n[%s]", F.dbSettingsGroup);
if (mir_strcmp(buff, header) != 0) {
- strncpy(header, buff, SIZEOF(header));
+ strncpy(header, buff, _countof(header));
WriteLine(out, buff);
}
@@ -311,7 +311,7 @@ static HTREEITEM sttFindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TC tvi.mask = TVIF_TEXT;
tvi.pszText = str;
- tvi.cchTextMax = SIZEOF(str);
+ tvi.cchTextMax = _countof(str);
while (tvi.hItem) {
TreeView_GetItem(hwndTree, &tvi);
@@ -450,7 +450,7 @@ static INT_PTR CALLBACK ChooseEffectDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wPar TranslateDialogDefault(hwndDlg);
pEffect = (FONTEFFECT*)lParam;
{
- for (int i = 0; i < SIZEOF(ModernEffectNames); i++) {
+ for (int i = 0; i < _countof(ModernEffectNames); i++) {
int itemid = SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_ADDSTRING, 0, (LPARAM)TranslateTS(ModernEffectNames[i]));
SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_SETITEMDATA, itemid, i);
SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_SETCURSEL, 0, 0);
@@ -1078,7 +1078,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, case IDC_BTN_EXPORT:
{
TCHAR fname_buff[MAX_PATH], filter[MAX_PATH];
- mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.ini)%c*.ini%c%s (*.txt)%c*.TXT%c%s (*.*)%c*.*%c"), TranslateT("Configuration files"), 0, 0, TranslateT("Text files"), 0, 0, TranslateT("All files"), 0, 0);
+ mir_sntprintf(filter, _countof(filter), _T("%s (*.ini)%c*.ini%c%s (*.txt)%c*.TXT%c%s (*.*)%c*.*%c"), TranslateT("Configuration files"), 0, 0, TranslateT("Text files"), 0, 0, TranslateT("All files"), 0, 0);
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
diff --git a/src/mir_app/src/FontService.cpp b/src/mir_app/src/FontService.cpp index 417597d8de..51ce2981c0 100644 --- a/src/mir_app/src/FontService.cpp +++ b/src/mir_app/src/FontService.cpp @@ -95,17 +95,17 @@ int LoadFontserviceModule(void) _tcsncpy_s(fontid.name, LPGENT("Headers"), _TRUNCATE);
fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSHEADER;
- strncpy(fontid.prefix, "Header", SIZEOF(fontid.prefix));
+ strncpy(fontid.prefix, "Header", _countof(fontid.prefix));
FontRegisterT(&fontid);
_tcsncpy_s(fontid.name, LPGENT("Generic text"), _TRUNCATE);
fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSGENERAL;
- strncpy(fontid.prefix, "Generic", SIZEOF(fontid.prefix));
+ strncpy(fontid.prefix, "Generic", _countof(fontid.prefix));
FontRegisterT(&fontid);
_tcsncpy_s(fontid.name, LPGENT("Small text"), _TRUNCATE);
fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSSMALL;
- strncpy(fontid.prefix, "Small", SIZEOF(fontid.prefix));
+ strncpy(fontid.prefix, "Small", _countof(fontid.prefix));
FontRegisterT(&fontid);
// do last for silly dyna plugin
diff --git a/src/mir_app/src/button.cpp b/src/mir_app/src/button.cpp index b17e29d751..54a72c1c98 100644 --- a/src/mir_app/src/button.cpp +++ b/src/mir_app/src/button.cpp @@ -204,7 +204,7 @@ static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) SIZE sz;
TCHAR szText[MAX_PATH];
- GetWindowText(ctl->hwnd, szText, SIZEOF(szText));
+ GetWindowText(ctl->hwnd, szText, _countof(szText));
GetTextExtentPoint32(hdcMem, szText, (int)mir_tstrlen(szText), &sz);
int xOffset = (rcClient.right - rcClient.left - sz.cx)/2;
int yOffset = (rcClient.bottom - rcClient.top - sz.cy)/2;
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index cd633f600b..9a2c1991b8 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -212,7 +212,7 @@ BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, TCHAR* fm va_list marker;
va_start(marker, fmt);
- mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
+ mir_vsntprintf(szBuf, _countof(szBuf), fmt, marker);
va_end(marker);
CLISTEVENT cle = { 0 };
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index 79b608953c..f3ac0e6a4b 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // the srmm module and then modified to fit the chat module.
char* pLogIconBmpBits[14];
-size_t logIconBmpSize[ SIZEOF(pLogIconBmpBits) ];
+size_t logIconBmpSize[ _countof(pLogIconBmpBits) ];
#define RTFCACHELINESIZE 128
static char CHAT_rtfFontsGlobal[OPTIONS_FONTCOUNT][RTFCACHELINESIZE];
@@ -315,7 +315,7 @@ static void AddEventToBuffer(char *&buffer, size_t &bufferEnd, size_t &bufferAll TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time)
{
static TCHAR szTime[30];
- if (!_tcsftime(szTime, SIZEOF(szTime)-1, pszStamp, localtime(&time)))
+ if (!_tcsftime(szTime, _countof(szTime)-1, pszStamp, localtime(&time)))
_tcsncpy_s(szTime, TranslateT("<invalid>"), _TRUNCATE);
return szTime;
}
@@ -364,12 +364,12 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData) static char szStyle[256];
if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) {
int iii = lin->bIsHighlighted ? 16 : (lin->bIsMe ? 2 : 1);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
+ mir_snprintf(szStyle, _countof(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
Log_Append(buffer, bufferEnd, bufferAlloced, "%s ", szStyle);
}
else {
int iii = lin->bIsHighlighted ? 16 : EventToIndex(lin);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
+ mir_snprintf(szStyle, _countof(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
Log_Append(buffer, bufferEnd, bufferAlloced, "%s ", szStyle);
}
}
@@ -494,7 +494,7 @@ void LoadMsgLogBitmaps(void) HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
HDC hdcMem = CreateCompatibleDC(hdc);
PBYTE pBmpBits = (PBYTE)mir_alloc(widthBytes * bih.biHeight);
- for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
+ for (int i = 0; i < _countof(pLogIconBmpBits); i++) {
size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2;
pLogIconBmpBits[i] = (char*)mir_alloc(size);
size_t rtfHeaderSize = mir_snprintf((char *)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
@@ -537,6 +537,6 @@ void LoadMsgLogBitmaps(void) void FreeMsgLogBitmaps(void)
{
- for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++)
+ for (int i = 0; i < _countof(pLogIconBmpBits); i++)
mir_free(pLogIconBmpBits[i]);
}
diff --git a/src/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp index 3a5252e959..ffb6e0d74e 100644 --- a/src/mir_app/src/chat_opts.cpp +++ b/src/mir_app/src/chat_opts.cpp @@ -139,12 +139,12 @@ void RegisterFonts(void) _tcsncpy_s(fontid.backgroundGroup, g_szFontGroup, _TRUNCATE);
_tcsncpy_s(fontid.group, g_szFontGroup, _TRUNCATE);
- for (int i = 0; i < SIZEOF(fontOptionsList); i++, index++) {
+ for (int i = 0; i < _countof(fontOptionsList); i++, index++) {
FontOptionsList &FO = fontOptionsList[i];
strncpy_s(fontid.dbSettingsGroup, CHATFONT_MODULE, _TRUNCATE);
_tcsncpy_s(fontid.name, FO.szDescr, _TRUNCATE);
- mir_snprintf(fontid.prefix, SIZEOF(fontid.prefix), "Font%d", index);
+ mir_snprintf(fontid.prefix, _countof(fontid.prefix), "Font%d", index);
fontid.order = index;
switch (i) {
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 00b3f90e5d..fd72ed1ea1 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -45,8 +45,8 @@ TCHAR* RemoveFormatting(const TCHAR *pszWord) TCHAR *d = szTemp;
size_t cbLen = mir_tstrlen(pszWord);
- if (cbLen > SIZEOF(szTemp))
- cbLen = SIZEOF(szTemp)-1;
+ if (cbLen > _countof(szTemp))
+ cbLen = _countof(szTemp)-1;
for (size_t i = 0; i < cbLen;) {
if (pszWord[i] == '%') {
@@ -184,11 +184,11 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char *pszProtoNa pd.lchIcon = LoadIconEx("window", FALSE);
PROTOACCOUNT *pa = Proto_GetAccount(pszProtoName);
- mir_sntprintf(pd.lptzContactName, SIZEOF(pd.lptzContactName), _T("%s - %s"),
+ mir_sntprintf(pd.lptzContactName, _countof(pd.lptzContactName), _T("%s - %s"),
(pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
cli.pfnGetContactDisplayName(hContact, 0));
- mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), SIZEOF(pd.lptzText));
+ mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), _countof(pd.lptzText));
pd.iSeconds = g_Settings->iPopupTimeout;
if (g_Settings->iPopupStyle == 2) {
@@ -563,9 +563,9 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) // formatting strings don't need to be translatable - changing them via language pack would
// only screw up the log format.
if (p)
- mir_sntprintf(szLine, SIZEOF(szLine), _T("%s %c %s\r\n"), szTime, p, szBuffer);
+ mir_sntprintf(szLine, _countof(szLine), _T("%s %c %s\r\n"), szTime, p, szBuffer);
else
- mir_sntprintf(szLine, SIZEOF(szLine), _T("%s %s\r\n"), szTime, szBuffer);
+ mir_sntprintf(szLine, _countof(szLine), _T("%s %s\r\n"), szTime, szBuffer);
if (szLine[0]) {
_fputts(szLine, hFile);
@@ -590,11 +590,11 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) _tsplitpath(si->pszLogFileName, tszDrive, tszDir, tszName, tszExt);
TCHAR tszNewPath[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
- mir_sntprintf(tszNewPath, SIZEOF(tszNewPath), _T("%s%sarchived\\"), tszDrive, tszDir);
+ mir_sntprintf(tszNewPath, _countof(tszNewPath), _T("%s%sarchived\\"), tszDrive, tszDir);
CreateDirectoryTreeT(tszNewPath);
TCHAR tszNewName[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
- mir_sntprintf(tszNewName, SIZEOF(tszNewName), _T("%s%s-%s%s"), tszNewPath, tszName, tszTimestamp, tszExt);
+ mir_sntprintf(tszNewName, _countof(tszNewName), _T("%s%s-%s%s"), tszNewPath, tszName, tszTimestamp, tszExt);
fclose(hFile);
hFile = 0;
if (!PathFileExists(tszNewName))
@@ -742,7 +742,7 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) TCHAR tszTemp[MAX_PATH], *ptszVarPath;
if (g_Settings->pszLogDir[mir_tstrlen(g_Settings->pszLogDir) - 1] == '\\') {
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%s%s"), g_Settings->pszLogDir, _T("%userid%.log"));
+ mir_sntprintf(tszTemp, _countof(tszTemp), _T("%s%s"), g_Settings->pszLogDir, _T("%userid%.log"));
ptszVarPath = tszTemp;
}
else ptszVarPath = g_Settings->pszLogDir;
@@ -758,7 +758,7 @@ TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) PathToAbsoluteT(tszParsedName, si->pszLogFileName);
mir_free(tszParsedName);
- for (int i = 0; i < SIZEOF(rva); i++)
+ for (int i = 0; i < _countof(rva); i++)
mir_free(rva[i].lptzValue);
for (TCHAR *p = si->pszLogFileName + 2; *p; ++p)
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 75e0496fce..517aaceac5 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -421,7 +421,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, }
group = group->parent;
size_t nameLen = mir_tstrlen(group->cl.items[i]->szText);
- if (mir_tstrlen(szFullName) + 1 + nameLen > SIZEOF(szFullName)) {
+ if (mir_tstrlen(szFullName) + 1 + nameLen > _countof(szFullName)) {
szFullName[0] = '\0';
break;
}
@@ -581,7 +581,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
break;
- mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText));
+ mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), _countof(contact->szText));
dat->needsResort = 1;
SortClcByTimer(hwnd);
break;
@@ -592,7 +592,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, contact->proto = GetContactProto(wParam);
cli.pfnInvalidateDisplayNameCacheEntry(wParam);
- mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText));
+ mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), _countof(contact->szText));
SortClcByTimer(hwnd);
break;
@@ -828,7 +828,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, TCHAR szNew[2];
szNew[0] = (TCHAR) wParam;
szNew[1] = '\0';
- if (mir_tstrlen(dat->szQuickSearch) >= SIZEOF(dat->szQuickSearch) - 1) {
+ if (mir_tstrlen(dat->szQuickSearch) >= _countof(dat->szQuickSearch) - 1) {
MessageBeep(MB_OK);
break;
}
@@ -1150,7 +1150,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)contacto->hContact, contactn->groupId);
else if (contacto->type == CLCIT_GROUP) { //dropee is a group
TCHAR szNewName[120];
- mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s\\%s"), cli.pfnGetGroupName(contactn->groupId, NULL), contacto->szText);
+ mir_sntprintf(szNewName, _countof(szNewName), _T("%s\\%s"), cli.pfnGetGroupName(contactn->groupId, NULL), contacto->szText);
cli.pfnRenameGroup(contacto->groupId, szNewName);
}
}
@@ -1189,7 +1189,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, break;
if (contact->type == CLCIT_GROUP) { //dropee is a group
TCHAR szNewName[120];
- mir_tstrncpy(szNewName, contact->szText, SIZEOF(szNewName));
+ mir_tstrncpy(szNewName, contact->szText, _countof(szNewName));
cli.pfnRenameGroup(contact->groupId, szNewName);
}
else if (contact->type == CLCIT_CONTACT) //dropee is a contact
diff --git a/src/mir_app/src/clcfiledrop.cpp b/src/mir_app/src/clcfiledrop.cpp index da3ab82e47..a7aca08f78 100644 --- a/src/mir_app/src/clcfiledrop.cpp +++ b/src/mir_app/src/clcfiledrop.cpp @@ -147,7 +147,7 @@ HRESULT CDropTarget::DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL shortPt.x = pt.x;
shortPt.y = pt.y;
hwnd = WindowFromPoint(shortPt);
- GetClassName(hwnd, szWindowClass, SIZEOF(szWindowClass));
+ GetClassName(hwnd, szWindowClass, _countof(szWindowClass));
if (!mir_tstrcmp(szWindowClass, _T(CLISTCONTROL_CLASS))) {
struct ClcData *dat;
hwndCurrentDrag = hwnd;
@@ -229,7 +229,7 @@ HRESULT CDropTarget::Drop(IDataObject * pDataObj, DWORD /*fKeyState*/, POINTL pt fileCount = DragQueryFile(hDrop, -1, NULL, 0);
ppFiles = NULL;
for (i=0; i < fileCount; i++) {
- DragQueryFile(hDrop, i, szFilename, SIZEOF(szFilename));
+ DragQueryFile(hDrop, i, szFilename, _countof(szFilename));
AddToFileList(&ppFiles, &totalCount, szFilename);
}
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index 533c45aa8b..bff9d4dc67 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -41,7 +41,7 @@ int fnAddItemToGroup(ClcGroup *group, int iAboveItem) ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers) { - TCHAR *pBackslash, *pNextField, szThisField[ SIZEOF(dat->list.cl.items[0]->szText) ]; + TCHAR *pBackslash, *pNextField, szThisField[ _countof(dat->list.cl.items[0]->szText) ]; ClcGroup *group = &dat->list; int i, compareResult; @@ -53,11 +53,11 @@ ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD do { pBackslash = _tcschr(pNextField, '\\'); if (pBackslash == NULL) { - mir_tstrncpy(szThisField, pNextField, SIZEOF(szThisField)); + mir_tstrncpy(szThisField, pNextField, _countof(szThisField)); pNextField = NULL; } else { - mir_tstrncpy(szThisField, pNextField, min(SIZEOF(szThisField), pBackslash - pNextField + 1)); + mir_tstrncpy(szThisField, pNextField, min(_countof(szThisField), pBackslash - pNextField + 1)); pNextField = pBackslash + 1; } compareResult = 1; @@ -89,7 +89,7 @@ ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD return NULL; i = cli.pfnAddItemToGroup(group, i); group->cl.items[i]->type = CLCIT_GROUP; - mir_tstrncpy(group->cl.items[i]->szText, szThisField, SIZEOF(group->cl.items[i]->szText)); + mir_tstrncpy(group->cl.items[i]->szText, szThisField, _countof(group->cl.items[i]->szText)); group->cl.items[i]->groupId = (WORD) (pNextField ? 0 : groupId); group->cl.items[i]->group = (ClcGroup *) mir_alloc(sizeof(ClcGroup)); group->cl.items[i]->group->parent = group; @@ -167,7 +167,7 @@ int fnAddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText) group->cl.items[i]->type = CLCIT_INFO; group->cl.items[i]->flags = (BYTE) flags; group->cl.items[i]->hContact = (MCONTACT)++iInfoItemUniqueHandle; - mir_tstrncpy(group->cl.items[i]->szText, pszText, SIZEOF(group->cl.items[i]->szText)); + mir_tstrncpy(group->cl.items[i]->szText, pszText, _countof(group->cl.items[i]->szText)); return i; } @@ -205,7 +205,7 @@ int fnAddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hContact) DWORD idleMode = szProto != NULL ? db_get_dw(hContact, szProto, "IdleTS", 0) : 0; if (idleMode) group->cl.items[i]->flags |= CONTACTF_IDLE; - mir_tstrncpy(group->cl.items[i]->szText, cli.pfnGetContactDisplayName(hContact, 0), SIZEOF(group->cl.items[i]->szText)); + mir_tstrncpy(group->cl.items[i]->szText, cli.pfnGetContactDisplayName(hContact, 0), _countof(group->cl.items[i]->szText)); ClcCacheEntry *p = cli.pfnGetCacheEntry(hContact); if (p != NULL) diff --git a/src/mir_app/src/clcmsgs.cpp b/src/mir_app/src/clcmsgs.cpp index 822644b6f6..785877cb73 100644 --- a/src/mir_app/src/clcmsgs.cpp +++ b/src/mir_app/src/clcmsgs.cpp @@ -399,7 +399,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPAR case CLM_SETITEMTEXT:
if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
break;
- mir_tstrncpy(contact->szText, (TCHAR*)lParam, SIZEOF(contact->szText));
+ mir_tstrncpy(contact->szText, (TCHAR*)lParam, _countof(contact->szText));
cli.pfnSortCLC(hwnd, dat, 1);
cli.pfnInvalidateRect(hwnd, NULL, FALSE);
break;
diff --git a/src/mir_app/src/clcutils.cpp b/src/mir_app/src/clcutils.cpp index fa0c1ad919..378fd7f809 100644 --- a/src/mir_app/src/clcutils.cpp +++ b/src/mir_app/src/clcutils.cpp @@ -403,7 +403,7 @@ void fnEndRename(HWND, struct ClcData *dat, int save) dat->hwndRenameEdit = NULL;
if (save) {
TCHAR text[120]; text[0] = 0;
- GetWindowText(hwndEdit, text, SIZEOF(text));
+ GetWindowText(hwndEdit, text, _countof(text));
ClcContact *contact;
if (cli.pfnGetRowByIndex(dat, dat->selection, &contact, NULL) != -1) {
@@ -411,7 +411,7 @@ void fnEndRename(HWND, struct ClcData *dat, int save) if (contact->type == CLCIT_GROUP) {
if (contact->group->parent && contact->group->parent->parent) {
TCHAR szFullName[256];
- mir_sntprintf(szFullName, SIZEOF(szFullName), _T("%s\\%s"),
+ mir_sntprintf(szFullName, _countof(szFullName), _T("%s\\%s"),
cli.pfnGetGroupName(contact->group->parent->groupId, NULL), text);
cli.pfnRenameGroup(contact->groupId, szFullName);
}
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index a69c594fdf..4cf60f4414 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -450,7 +450,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) if (FindMenuHandleByGlobalID(hStatusMenu, timiParent, &it)) {
MENUITEMINFO mi = { 0 };
TCHAR d[100];
- GetMenuString(it.OwnerMenu, it.position, d, SIZEOF(d), MF_BYPOSITION);
+ GetMenuString(it.OwnerMenu, it.position, d, _countof(d), MF_BYPOSITION);
mi.cbSize = sizeof(mi);
mi.fMask = MIIM_STRING | MIIM_STATE;
@@ -544,7 +544,7 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) bool bIsLocked = !Proto_IsAccountLocked(acc);
db_set_b(NULL, prot, "LockMainStatus", bIsLocked);
- CallProtoServiceInt(NULL, smep->proto, PS_GETNAME, (WPARAM)SIZEOF(szHumanName), (LPARAM)szHumanName);
+ CallProtoServiceInt(NULL, smep->proto, PS_GETNAME, (WPARAM)_countof(szHumanName), (LPARAM)szHumanName);
PMO_IntMenuItem pimi = MO_GetIntMenuItem((HGENMENU)smep->protoindex);
if (pimi == NULL)
@@ -827,8 +827,8 @@ void RebuildMenuOrder(void) hStatusMenuObject = MO_CreateMenuObject("StatusMenu", LPGEN("Status menu"), "StatusMenuCheckService", "StatusMenuExecService");
MO_SetOptionsMenuObject(hStatusMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataStatusMenu");
- hStatusMainMenuHandles = (PMO_IntMenuItem*)mir_calloc(SIZEOF(statusModeList) * sizeof(PMO_IntMenuItem));
- hStatusMainMenuHandlesCnt = SIZEOF(statusModeList);
+ hStatusMainMenuHandles = (PMO_IntMenuItem*)mir_calloc(_countof(statusModeList) * sizeof(PMO_IntMenuItem));
+ hStatusMainMenuHandlesCnt = _countof(statusModeList);
hStatusMenuHandles = (tStatusMenuHandles*)mir_calloc(sizeof(tStatusMenuHandles)*accounts.getCount());
hStatusMenuHandlesCnt = accounts.getCount();
@@ -857,7 +857,7 @@ void RebuildMenuOrder(void) tmi.hIcon = ic = (HICON)CallProtoServiceInt(NULL, pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
if (Proto_IsAccountLocked(pa) && cli.bDisplayLocked) {
- mir_sntprintf(tbuf, SIZEOF(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
+ mir_sntprintf(tbuf, _countof(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
tmi.ptszName = tbuf;
}
else tmi.ptszName = pa->tszAccountName;
@@ -885,7 +885,7 @@ void RebuildMenuOrder(void) tmi.flags |= CMIF_CHECKED;
if ((tmi.flags & CMIF_CHECKED) && cli.bDisplayLocked) {
- mir_sntprintf(tbuf, SIZEOF(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
+ mir_sntprintf(tbuf, _countof(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
tmi.ptszName = tbuf;
}
else tmi.ptszName = pa->tszAccountName;
@@ -908,7 +908,7 @@ void RebuildMenuOrder(void) DestroyIcon(ic);
pos += 500000;
- for (int j = 0; j < SIZEOF(statusModeList); j++) {
+ for (int j = 0; j < _countof(statusModeList); j++) {
if (!(flags & statusModePf2List[j]))
continue;
@@ -947,7 +947,7 @@ void RebuildMenuOrder(void) int pos = 200000;
// add to root menu
- for (int j = 0; j < SIZEOF(statusModeList); j++) {
+ for (int j = 0; j < _countof(statusModeList); j++) {
for (int i = 0; i < accounts.getCount(); i++) {
PROTOACCOUNT *pa = accounts[i];
if (!bHideStatusMenu && !cli.pfnGetProtocolVisibility(pa->szModuleName))
@@ -973,7 +973,7 @@ void RebuildMenuOrder(void) {
TCHAR buf[256], hotkeyName[100];
WORD hotKey = GetHotkeyValue(statusHotkeys[j]);
- HotkeyToName(hotkeyName, SIZEOF(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
+ HotkeyToName(hotkeyName, _countof(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
mir_sntprintf(buf, _T("%s\t%s"),
cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
tmi.ptszName = buf;
@@ -1000,10 +1000,10 @@ static int sttRebuildHotkeys(WPARAM, LPARAM) TMO_MenuItem tmi = { sizeof(tmi) };
tmi.flags = CMIM_HOTKEY | CMIM_NAME | CMIF_TCHAR;
- for (int j = 0; j < SIZEOF(statusModeList); j++) {
+ for (int j = 0; j < _countof(statusModeList); j++) {
TCHAR buf[256], hotkeyName[100];
WORD hotKey = GetHotkeyValue(statusHotkeys[j]);
- HotkeyToName(hotkeyName, SIZEOF(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
+ HotkeyToName(hotkeyName, _countof(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
mir_sntprintf(buf, _T("%s\t%s"), cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
tmi.ptszName = buf;
tmi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
@@ -1017,7 +1017,7 @@ static int sttRebuildHotkeys(WPARAM, LPARAM) int statustopos(int status)
{
- for (int j = 0; j < SIZEOF(statusModeList); j++)
+ for (int j = 0; j < _countof(statusModeList); j++)
if (status == statusModeList[j])
return j;
@@ -1070,19 +1070,19 @@ static int MenuProtoAck(WPARAM, LPARAM lParam) for (int i = 0; i < accounts.getCount(); i++) {
if (!mir_strcmp(accounts[i]->szModuleName, ack->szModule)) {
- if (((int)ack->hProcess >= ID_STATUS_OFFLINE || (int)ack->hProcess == 0) && (int)ack->hProcess < ID_STATUS_OFFLINE + SIZEOF(statusModeList)) {
+ if (((int)ack->hProcess >= ID_STATUS_OFFLINE || (int)ack->hProcess == 0) && (int)ack->hProcess < ID_STATUS_OFFLINE + _countof(statusModeList)) {
int pos = statustopos((int)ack->hProcess);
if (pos == -1)
pos = 0;
- for (pos = 0; pos < SIZEOF(statusModeList); pos++) {
+ for (pos = 0; pos < _countof(statusModeList); pos++) {
tmi.flags = CMIM_FLAGS | CMIF_ROOTHANDLE;
MO_ModifyMenuItem(hStatusMenuHandles[i].menuhandle[pos], &tmi);
}
}
- if (ack->lParam >= ID_STATUS_OFFLINE && ack->lParam < ID_STATUS_OFFLINE + SIZEOF(statusModeList)) {
+ if (ack->lParam >= ID_STATUS_OFFLINE && ack->lParam < ID_STATUS_OFFLINE + _countof(statusModeList)) {
int pos = statustopos((int)ack->lParam);
- if (pos >= 0 && pos < SIZEOF(statusModeList)) {
+ if (pos >= 0 && pos < _countof(statusModeList)) {
tmi.flags = CMIM_FLAGS | CMIF_ROOTHANDLE | CMIF_CHECKED;
MO_ModifyMenuItem(hStatusMenuHandles[i].menuhandle[pos], &tmi);
}
@@ -1304,9 +1304,9 @@ void InitCustomMenus(void) HOTKEYDESC hkd = { sizeof(hkd) };
hkd.ptszSection = _T("Status");
hkd.dwFlags = HKD_TCHAR;
- for (int i = 0; i < SIZEOF(statusHotkeys); i++) {
+ for (int i = 0; i < _countof(statusHotkeys); i++) {
char szName[30];
- mir_snprintf(szName, SIZEOF(szName), "StatusHotKey_%d", i);
+ mir_snprintf(szName, _countof(szName), "StatusHotKey_%d", i);
hkd.pszName = szName;
hkd.lParam = statusModeList[i];
hkd.ptszDescription = fnGetStatusModeDescription(hkd.lParam, 0);
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index 1b11108836..e1b20354f8 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -100,7 +100,7 @@ TCHAR* fnGetStatusModeDescription(int mode, int flags) default:
if (IsStatusConnecting(mode)) {
const TCHAR* connFmt = LPGENT("Connecting (attempt %d)");
- mir_sntprintf(szMode, SIZEOF(szMode), (flags & GSMDF_UNTRANSLATED) ? connFmt : TranslateTS(connFmt), mode - ID_STATUS_CONNECTING + 1);
+ mir_sntprintf(szMode, _countof(szMode), (flags & GSMDF_UNTRANSLATED) ? connFmt : TranslateTS(connFmt), mode - ID_STATUS_CONNECTING + 1);
return szMode;
}
return NULL;
@@ -157,11 +157,11 @@ int fnIconFromStatusMode(const char *szProto, int status, MCONTACT) {
int index, i;
- for (index = 0; index < SIZEOF(statusModeList); index++)
+ for (index = 0; index < _countof(statusModeList); index++)
if (status == statusModeList[index])
break;
- if (index == SIZEOF(statusModeList))
+ if (index == _countof(statusModeList))
index = 0;
if (szProto == NULL)
return index + 1;
@@ -188,7 +188,7 @@ static void AddProtoIconIndex(PROTOACCOUNT *pa) {
ProtoIconIndex *pii = new ProtoIconIndex;
pii->szProto = pa->szModuleName;
- for (int i=0; i < SIZEOF(statusModeList); i++) {
+ for (int i=0; i < _countof(statusModeList); i++) {
int iImg = ImageList_AddIcon_ProtoIconLibLoaded(hCListImages, pa->szModuleName, statusModeList[i]);
if (i == 0)
pii->iIconBase = iImg;
@@ -268,12 +268,12 @@ static int CListIconsChanged(WPARAM, LPARAM) {
int i, j;
- for (i=0; i < SIZEOF(statusModeList); i++)
+ for (i=0; i < _countof(statusModeList); i++)
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, i + 1, Skin_LoadIcon(skinIconStatusList[i]));
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPOPEN, Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN));
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPSHUT, Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT));
for (i=0; i < protoIconIndex.getCount(); i++)
- for (j = 0; j < SIZEOF(statusModeList); j++)
+ for (j = 0; j < _countof(statusModeList); j++)
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, protoIconIndex[i].iIconBase + j, Skin_LoadProtoIcon(protoIconIndex[i].szProto, statusModeList[j]));
cli.pfnTrayIconIconsChanged();
cli.pfnInvalidateRect(cli.hwndContactList, NULL, TRUE);
@@ -460,7 +460,7 @@ static INT_PTR CompareContacts(WPARAM wParam, LPARAM lParam) nameb = cli.pfnGetContactDisplayName(a, 0);
_tcsncpy_s(namea, nameb, _TRUNCATE);
- namea[ SIZEOF(namea)-1 ] = 0;
+ namea[ _countof(namea)-1 ] = 0;
nameb = cli.pfnGetContactDisplayName(b, 0);
//otherwise just compare names
@@ -513,7 +513,7 @@ int LoadContactListModule2(void) ImageList_AddIcon_NotShared(hCListImages, MAKEINTRESOURCE(IDI_BLANK));
//now all core skin icons are loaded via icon lib. so lets release them
- for (int i=0; i < SIZEOF(statusModeList); i++)
+ for (int i=0; i < _countof(statusModeList); i++)
ImageList_AddIcon_IconLibLoaded(hCListImages, skinIconStatusList[i]);
//see IMAGE_GROUP... in clist.h if you add more images above here
diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp index 93bde38516..556b4dc30d 100644 --- a/src/mir_app/src/clisttray.cpp +++ b/src/mir_app/src/clisttray.cpp @@ -186,7 +186,7 @@ int fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int s cli.pfnTrayIconMakeTooltip(NULL, p.szProto);
if (!hasTips())
- mir_tstrncpy(nid.szTip, cli.szTip, SIZEOF(nid.szTip));
+ mir_tstrncpy(nid.szTip, cli.szTip, _countof(nid.szTip));
replaceStrT(p.ptszToolTip, cli.szTip);
Shell_NotifyIcon(NIM_ADD, &nid);
@@ -343,7 +343,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer mir_free(cli.trayIcon[i].ptszToolTip);
cli.trayIcon[i].ptszToolTip = mir_tstrdup(cli.szTip);
if (!hasTips())
- mir_tstrncpy(nid.szTip, cli.szTip, SIZEOF(nid.szTip));
+ mir_tstrncpy(nid.szTip, cli.szTip, _countof(nid.szTip));
Shell_NotifyIcon(NIM_MODIFY, &nid);
if (cli.trayIconCount == 1)
@@ -365,7 +365,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer mir_free(cli.trayIcon[i].ptszToolTip);
cli.trayIcon[i].ptszToolTip = mir_tstrdup(cli.szTip);
if (!hasTips())
- mir_tstrncpy(nid.szTip, cli.szTip, SIZEOF(nid.szTip));
+ mir_tstrncpy(nid.szTip, cli.szTip, _countof(nid.szTip));
Shell_NotifyIcon(NIM_MODIFY, &nid);
if (cli.trayIconCount == 1)
@@ -819,10 +819,10 @@ int fnCListTrayNotify(MIRANDASYSTRAYNOTIFY* msn) nid.hWnd = cli.hwndContactList;
nid.uID = iconId;
nid.uFlags = NIF_INFO;
- mir_wstrncpy(nid.szInfo, msn->tszInfo, SIZEOF(nid.szInfo));
- mir_wstrncpy(nid.szInfoTitle, msn->tszInfoTitle, SIZEOF(nid.szInfoTitle));
- nid.szInfo[SIZEOF(nid.szInfo) - 1] = 0;
- nid.szInfoTitle[SIZEOF(nid.szInfoTitle) - 1] = 0;
+ mir_wstrncpy(nid.szInfo, msn->tszInfo, _countof(nid.szInfo));
+ mir_wstrncpy(nid.szInfoTitle, msn->tszInfoTitle, _countof(nid.szInfoTitle));
+ nid.szInfo[_countof(nid.szInfo) - 1] = 0;
+ nid.szInfoTitle[_countof(nid.szInfoTitle) - 1] = 0;
nid.uTimeout = msn->uTimeout;
nid.dwInfoFlags = (msn->dwInfoFlags & ~NIIF_INTERN_UNICODE);
return Shell_NotifyIconW(NIM_MODIFY, &nid) == 0;
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index 773e68fb5b..fc8381b0e0 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -89,7 +89,7 @@ static int MenuItem_PreBuild(WPARAM, LPARAM) {
TCHAR cls[128];
HWND hwndClist = GetFocus();
- GetClassName(hwndClist, cls, SIZEOF(cls));
+ GetClassName(hwndClist, cls, _countof(cls));
hwndClist = (!mir_tstrcmp( _T(CLISTCONTROL_CLASS), cls)) ? hwndClist : cli.hwndContactList;
HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_GETSELECTION, 0, 0);
Menu_ShowItem(hRenameMenuItem, hItem != 0);
@@ -100,7 +100,7 @@ static INT_PTR MenuItem_RenameContact(WPARAM, LPARAM) {
TCHAR cls[128];
HWND hwndClist = GetFocus();
- GetClassName(hwndClist, cls, SIZEOF(cls));
+ GetClassName(hwndClist, cls, _countof(cls));
// worst case scenario, the rename is sent to the main contact list
hwndClist = (!mir_tstrcmp( _T(CLISTCONTROL_CLASS), cls)) ? hwndClist : cli.hwndContactList;
HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_GETSELECTION, 0, 0);
@@ -124,8 +124,8 @@ static INT_PTR CALLBACK AskForConfirmationDlgProc(HWND hWnd, UINT msg, WPARAM wP SendDlgItemMessage(hWnd, IDC_TOPLINE, WM_SETFONT, (WPARAM) CreateFontIndirect(&lf), 0);
TCHAR szFormat[256], szFinal[256];
- GetDlgItemText(hWnd, IDC_TOPLINE, szFormat, SIZEOF(szFormat));
- mir_sntprintf(szFinal, SIZEOF(szFinal), szFormat, cli.pfnGetContactDisplayName(lParam, 0));
+ GetDlgItemText(hWnd, IDC_TOPLINE, szFormat, _countof(szFormat));
+ mir_sntprintf(szFinal, _countof(szFinal), szFormat, cli.pfnGetContactDisplayName(lParam, 0));
SetDlgItemText(hWnd, IDC_TOPLINE, szFinal);
}
SetFocus( GetDlgItem(hWnd, IDNO));
@@ -279,9 +279,9 @@ int LoadCLUIModule(void) RegisterClassEx(&wndclass);
if (db_get_ts(NULL, "CList", "TitleText", &dbv))
- mir_tstrncpy(titleText, _T(MIRANDANAME), SIZEOF(titleText));
+ mir_tstrncpy(titleText, _T(MIRANDANAME), _countof(titleText));
else {
- mir_tstrncpy(titleText, dbv.ptszVal, SIZEOF(titleText));
+ mir_tstrncpy(titleText, dbv.ptszVal, _countof(titleText));
db_free(&dbv);
}
@@ -412,7 +412,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM TCHAR profile[MAX_PATH];
int rc;
// wParam = (ATOM)hProfileAtom, lParam = 0
- if (GlobalGetAtomName((ATOM) wParam, profile, SIZEOF(profile))) {
+ if (GlobalGetAtomName((ATOM) wParam, profile, _countof(profile))) {
rc = mir_tstrcmpi(profile, VARST(_T("%miranda_userdata%\\%miranda_profilename%.dat"))) == 0;
ReplyMessage(rc);
if (rc) {
@@ -1003,7 +1003,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM PROTOACCOUNT *pa;
TCHAR tszName[64];
if ((pa = Proto_GetAccount(szProto)) != NULL)
- mir_sntprintf(tszName, SIZEOF(tszName), _T("%s "), pa->tszAccountName);
+ mir_sntprintf(tszName, _countof(tszName), _T("%s "), pa->tszAccountName);
else
tszName[0] = 0;
diff --git a/src/mir_app/src/cluiservices.cpp b/src/mir_app/src/cluiservices.cpp index e5f08af088..cdb2577093 100644 --- a/src/mir_app/src/cluiservices.cpp +++ b/src/mir_app/src/cluiservices.cpp @@ -43,7 +43,7 @@ static INT_PTR GroupAdded(WPARAM wParam, LPARAM lParam) TCHAR szFocusClass[64];
HWND hwndFocus = GetFocus();
- GetClassName(hwndFocus, szFocusClass, SIZEOF(szFocusClass));
+ GetClassName(hwndFocus, szFocusClass, _countof(szFocusClass));
if (!mir_tstrcmp(szFocusClass, _T(CLISTCONTROL_CLASS))) {
hItem = (HANDLE) SendMessage(hwndFocus, CLM_FINDGROUP, wParam, 0);
if (hItem)
@@ -179,11 +179,11 @@ void fnCluiProtocolStatusChanged(int, const char*) TCHAR tszName[64];
PROTOACCOUNT *pa = Proto_GetAccount(cli.menuProtos[i].szProto);
if (pa)
- mir_sntprintf(tszName, SIZEOF(tszName), _T("%s "), pa->tszAccountName);
+ mir_sntprintf(tszName, _countof(tszName), _T("%s "), pa->tszAccountName);
else
tszName[0] = 0;
- if (showOpts & 4 && mir_tstrlen(tszName) < SIZEOF(tszName)-1)
+ if (showOpts & 4 && mir_tstrlen(tszName) < _countof(tszName)-1)
mir_tstrcat(tszName, _T(" "));
GetTextExtentPoint32(hdc, tszName, (int)mir_tstrlen(tszName), &textSize);
x += textSize.cx;
diff --git a/src/mir_app/src/contact.cpp b/src/mir_app/src/contact.cpp index f4f9296c63..560eb60d5a 100644 --- a/src/mir_app/src/contact.cpp +++ b/src/mir_app/src/contact.cpp @@ -62,7 +62,7 @@ void fnChangeContactIcon(MCONTACT hContact, int iIcon, int add) int GetStatusModeOrdering(int statusMode) { int i; - for (i=0; i < SIZEOF(statusModeOrder); i++) + for (i=0; i < _countof(statusModeOrder); i++) if (statusModeOrder[i].status == statusMode) return statusModeOrder[i].order; return 1000; @@ -126,7 +126,7 @@ int fnCompareContacts(const ClcContact* c1, const ClcContact* c2) nameb = cli.pfnGetContactDisplayName(a, 0); _tcsncpy_s(namea, nameb, _TRUNCATE); - namea[ SIZEOF(namea)-1 ] = 0; + namea[ _countof(namea)-1 ] = 0; nameb = cli.pfnGetContactDisplayName(b, 0); //otherwise just compare names diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index b20b201228..170ffdf9e4 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -393,7 +393,7 @@ public: tvis.hParent = NULL;
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_TEXT | TVIF_PARAM;
- for (int i = 0; i < SIZEOF(nameOrderDescr); i++) {
+ for (int i = 0; i < _countof(nameOrderDescr); i++) {
tvis.item.lParam = nameOrder[i];
tvis.item.pszText = TranslateTS(nameOrderDescr[nameOrder[i]]);
m_nameOrder.InsertItem(&tvis);
@@ -411,14 +411,14 @@ public: nameOrder[i++] = (BYTE)tvi.lParam;
tvi.hItem = m_nameOrder.GetNextSibling(tvi.hItem);
}
- db_set_blob(NULL, "Contact", "NameOrder", nameOrder, SIZEOF(nameOrderDescr));
+ db_set_blob(NULL, "Contact", "NameOrder", nameOrder, _countof(nameOrderDescr));
CallService(MS_CLIST_INVALIDATEDISPLAYNAME, (WPARAM)INVALID_HANDLE_VALUE, 0);
}
void OnBeginDrag(CCtrlTreeView::TEventInfo *evt)
{
LPNMTREEVIEW pNotify = evt->nmtv;
- if (pNotify->itemNew.lParam == 0 || pNotify->itemNew.lParam == SIZEOF(nameOrderDescr) - 1)
+ if (pNotify->itemNew.lParam == 0 || pNotify->itemNew.lParam == _countof(nameOrderDescr) - 1)
pNotify->hdr.code = 0; // deny dragging
}
};
diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp index 802840cb5e..286a8f4793 100644 --- a/src/mir_app/src/database.cpp +++ b/src/mir_app/src/database.cpp @@ -73,7 +73,7 @@ bool IsInsideRootDir(TCHAR* profiledir, bool exact) int getProfilePath(TCHAR *buf, size_t)
{
TCHAR profiledir[MAX_PATH];
- GetPrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), profiledir, SIZEOF(profiledir), mirandabootini);
+ GetPrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), profiledir, _countof(profiledir), mirandabootini);
if (profiledir[0] == 0)
mir_tstrcpy(profiledir, _T("%miranda_path%\\Profiles"));
@@ -102,7 +102,7 @@ static bool showProfileManager(void) return 1;
// wanna show it?
- GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T("never"), Mgr, SIZEOF(Mgr), mirandabootini);
+ GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T("never"), Mgr, _countof(Mgr), mirandabootini);
return (mir_tstrcmpi(Mgr, _T("yes")) == 0);
}
@@ -112,14 +112,14 @@ bool shouldAutoCreate(TCHAR *szProfile) return false;
TCHAR ac[32];
- GetPrivateProfileString(_T("Database"), _T("AutoCreate"), _T(""), ac, SIZEOF(ac), mirandabootini);
+ GetPrivateProfileString(_T("Database"), _T("AutoCreate"), _T(""), ac, _countof(ac), mirandabootini);
return mir_tstrcmpi(ac, _T("yes")) == 0;
}
static void getDefaultProfile(TCHAR *szProfile, size_t cch)
{
TCHAR defaultProfile[MAX_PATH];
- GetPrivateProfileString(_T("Database"), _T("DefaultProfile"), _T(""), defaultProfile, SIZEOF(defaultProfile), mirandabootini);
+ GetPrivateProfileString(_T("Database"), _T("DefaultProfile"), _T(""), defaultProfile, _countof(defaultProfile), mirandabootini);
if (defaultProfile[0] == 0)
return;
@@ -186,7 +186,7 @@ static void moveProfileDirProfiles(TCHAR *profiledir, BOOL isRootDir = TRUE) if (isRootDir)
_tcsncpy_s(pfd, VARST(_T("%miranda_path%\\*.dat")), _TRUNCATE);
else
- mir_sntprintf(pfd, SIZEOF(pfd), _T("%s\\*.dat"), profiledir);
+ mir_sntprintf(pfd, _countof(pfd), _T("%s\\*.dat"), profiledir);
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile(pfd, &ffd);
@@ -196,10 +196,10 @@ static void moveProfileDirProfiles(TCHAR *profiledir, BOOL isRootDir = TRUE) TCHAR path[MAX_PATH], path2[MAX_PATH];
TCHAR* profile = mir_tstrdup(ffd.cFileName);
TCHAR *c = _tcsrchr(profile, '.'); if (c) *c = 0;
- mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), pfd, ffd.cFileName);
- mir_sntprintf(path2, SIZEOF(path2), _T("%s\\%s"), profiledir, profile);
+ mir_sntprintf(path, _countof(path), _T("%s\\%s"), pfd, ffd.cFileName);
+ mir_sntprintf(path2, _countof(path2), _T("%s\\%s"), profiledir, profile);
CreateDirectoryTreeT(path2);
- mir_sntprintf(path2, SIZEOF(path2), _T("%s\\%s\\%s"), profiledir, profile, ffd.cFileName);
+ mir_sntprintf(path2, _countof(path2), _T("%s\\%s\\%s"), profiledir, profile, ffd.cFileName);
if (_taccess(path2, 0) == 0) {
TCHAR buf[512];
mir_sntprintf(buf,
@@ -241,7 +241,7 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n if (bShowProfileManager || !reqfd) {
TCHAR searchspec[MAX_PATH];
- mir_sntprintf(searchspec, SIZEOF(searchspec), _T("%s\\*.*"), profiledir);
+ mir_sntprintf(searchspec, _countof(searchspec), _T("%s\\*.*"), profiledir);
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile(searchspec, &ffd);
@@ -252,7 +252,7 @@ static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * n continue;
TCHAR newProfile[MAX_PATH];
- mir_sntprintf(newProfile, SIZEOF(newProfile), _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName);
+ mir_sntprintf(newProfile, _countof(newProfile), _T("%s\\%s\\%s.dat"), profiledir, ffd.cFileName, ffd.cFileName);
if (_taccess(newProfile, 0) != 0)
continue;
@@ -287,7 +287,7 @@ static int getProfileAutoRun(TCHAR *szProfile) return false;
TCHAR Mgr[32];
- GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T(""), Mgr, SIZEOF(Mgr), mirandabootini);
+ GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T(""), Mgr, _countof(Mgr), mirandabootini);
if (mir_tstrcmpi(Mgr, _T("never")))
return 0;
@@ -297,10 +297,10 @@ static int getProfileAutoRun(TCHAR *szProfile) // returns 1 if a profile was selected
static int getProfile(TCHAR *szProfile, size_t cch)
{
- getProfilePath(g_profileDir, SIZEOF(g_profileDir));
+ getProfilePath(g_profileDir, _countof(g_profileDir));
if (IsInsideRootDir(g_profileDir, true))
if (WritePrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), mirandabootini))
- getProfilePath(g_profileDir, SIZEOF(g_profileDir));
+ getProfilePath(g_profileDir, _countof(g_profileDir));
getDefaultProfile(szProfile, cch);
getProfileCmdLine(szProfile, cch);
@@ -458,7 +458,7 @@ static BOOL CALLBACK EnumMirandaWindows(HWND hwnd, LPARAM lParam) TCHAR classname[256];
ENUMMIRANDAWINDOW *x = (ENUMMIRANDAWINDOW *)lParam;
DWORD_PTR res = 0;
- if (GetClassName(hwnd, classname, SIZEOF(classname)) && mir_tstrcmp(_T("Miranda"), classname) == 0) {
+ if (GetClassName(hwnd, classname, _countof(classname)) && mir_tstrcmp(_T("Miranda"), classname) == 0) {
if (SendMessageTimeout(hwnd, x->msg, (WPARAM)x->aPath, 0, SMTO_ABORTIFHUNG, 100, &res) && res) {
x->found++;
return FALSE;
@@ -488,7 +488,7 @@ int LoadDatabaseModule(void) LoadDatabaseServices();
// find out which profile to load
- if (!getProfile(szProfile, SIZEOF(szProfile)))
+ if (!getProfile(szProfile, _countof(szProfile)))
return 1;
if (arDbPlugins.getCount() == 0) {
diff --git a/src/mir_app/src/dbini.cpp b/src/mir_app/src/dbini.cpp index 50f10dfee6..b876f89c16 100644 --- a/src/mir_app/src/dbini.cpp +++ b/src/mir_app/src/dbini.cpp @@ -38,7 +38,7 @@ static INT_PTR CALLBACK InstallIniDlgProc(HWND hwndDlg, UINT message, WPARAM wPa TCHAR szSecurity[11];
const TCHAR *pszSecurityInfo;
- GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, _countof(szSecurity), mirandabootini);
if (!mir_tstrcmpi(szSecurity, _T("all")))
pszSecurityInfo = LPGENT("Security systems to prevent malicious changes are in place and you will be warned before every change that is made.");
else if (!mir_tstrcmpi(szSecurity, _T("onlyunsafe")))
@@ -55,7 +55,7 @@ static INT_PTR CALLBACK InstallIniDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case IDC_VIEWINI:
{
TCHAR szPath[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_ININAME, szPath, SIZEOF(szPath));
+ GetDlgItemText(hwndDlg, IDC_ININAME, szPath, _countof(szPath));
ShellExecute(hwndDlg, _T("open"), szPath, NULL, NULL, SW_SHOW);
}
break;
@@ -154,7 +154,7 @@ static INT_PTR CALLBACK IniImportDoneDlgProc(HWND hwndDlg, UINT message, WPARAM return TRUE;
case WM_COMMAND:
- GetDlgItemText(hwndDlg, IDC_ININAME, szIniPath, SIZEOF(szIniPath));
+ GetDlgItemText(hwndDlg, IDC_ININAME, szIniPath, _countof(szIniPath));
switch (LOWORD(wParam)) {
case IDC_DELETE:
DeleteFile(szIniPath);
@@ -174,7 +174,7 @@ static INT_PTR CALLBACK IniImportDoneDlgProc(HWND hwndDlg, UINT message, WPARAM break;
case IDC_MOVE:
TCHAR szNewPath[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_NEWNAME, szNewPath, SIZEOF(szNewPath));
+ GetDlgItemText(hwndDlg, IDC_NEWNAME, szNewPath, _countof(szNewPath));
MoveFile(szIniPath, szNewPath);
EndDialog(hwndDlg, LOWORD(wParam));
break;
@@ -409,22 +409,22 @@ static void DoAutoExec(void) TCHAR szUse[7], szIniPath[MAX_PATH], szFindPath[MAX_PATH];
TCHAR buf[2048], szSecurity[11], szOverrideSecurityFilename[MAX_PATH], szOnCreateFilename[MAX_PATH];
- GetPrivateProfileString(_T("AutoExec"), _T("Use"), _T("prompt"), szUse, SIZEOF(szUse), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("Use"), _T("prompt"), szUse, _countof(szUse), mirandabootini);
if (!mir_tstrcmpi(szUse, _T("no"))) return;
- GetPrivateProfileString(_T("AutoExec"), _T("Safe"), _T("CLC Icons CLUI CList SkinSounds"), buf, SIZEOF(buf), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("Safe"), _T("CLC Icons CLUI CList SkinSounds"), buf, _countof(buf), mirandabootini);
ptrA szSafeSections(mir_t2a(buf));
- GetPrivateProfileString(_T("AutoExec"), _T("Unsafe"), _T("AIM Facebook GG ICQ IRC JABBER MRA MSN SKYPE Tlen TWITTER VKontakte XFire"), buf, SIZEOF(buf), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("Unsafe"), _T("AIM Facebook GG ICQ IRC JABBER MRA MSN SKYPE Tlen TWITTER VKontakte XFire"), buf, _countof(buf), mirandabootini);
ptrA szUnsafeSections(mir_t2a(buf));
- GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, _countof(szSecurity), mirandabootini);
int secur = 0;
if (!mir_tstrcmpi(szSecurity, _T("none"))) secur = 0;
else if (!mir_tstrcmpi(szSecurity, _T("notsafe"))) secur = 1;
else if (!mir_tstrcmpi(szSecurity, _T("onlyunsafe"))) secur = 2;
- GetPrivateProfileString(_T("AutoExec"), _T("OverrideSecurityFilename"), _T(""), szOverrideSecurityFilename, SIZEOF(szOverrideSecurityFilename), mirandabootini);
- GetPrivateProfileString(_T("AutoExec"), _T("OnCreateFilename"), _T(""), szOnCreateFilename, SIZEOF(szOnCreateFilename), mirandabootini);
- GetPrivateProfileString(_T("AutoExec"), _T("Glob"), _T("autoexec_*.ini"), szFindPath, SIZEOF(szFindPath), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("OverrideSecurityFilename"), _T(""), szOverrideSecurityFilename, _countof(szOverrideSecurityFilename), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("OnCreateFilename"), _T(""), szOnCreateFilename, _countof(szOnCreateFilename), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("Glob"), _T("autoexec_*.ini"), szFindPath, _countof(szFindPath), mirandabootini);
if (g_bDbCreated && szOnCreateFilename[0]) {
PathToAbsoluteT(VARST(szOnCreateFilename), szIniPath);
@@ -447,7 +447,7 @@ static void DoAutoExec(void) do {
bool secFN = mir_tstrcmpi(fd.cFileName, szOverrideSecurityFilename) == 0;
- mir_sntprintf(szIniPath, SIZEOF(szIniPath), _T("%s%s"), szFindPath, fd.cFileName);
+ mir_sntprintf(szIniPath, _countof(szIniPath), _T("%s%s"), szFindPath, fd.cFileName);
if (!mir_tstrcmpi(szUse, _T("prompt")) && !secFN) {
int result = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_INSTALLINI), NULL, InstallIniDlgProc, (LPARAM)szIniPath);
if (result == IDC_NOTOALL) break;
@@ -460,7 +460,7 @@ static void DoAutoExec(void) DeleteFile(szIniPath);
else {
TCHAR szOnCompletion[8];
- GetPrivateProfileString(_T("AutoExec"), _T("OnCompletion"), _T("recycle"), szOnCompletion, SIZEOF(szOnCompletion), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("OnCompletion"), _T("recycle"), szOnCompletion, _countof(szOnCompletion), mirandabootini);
if (!mir_tstrcmpi(szOnCompletion, _T("delete")))
DeleteFile(szIniPath);
else if (!mir_tstrcmpi(szOnCompletion, _T("recycle"))) {
@@ -473,7 +473,7 @@ static void DoAutoExec(void) }
else if (!mir_tstrcmpi(szOnCompletion, _T("rename"))) {
TCHAR szRenamePrefix[MAX_PATH], szNewPath[MAX_PATH];
- GetPrivateProfileString(_T("AutoExec"), _T("RenamePrefix"), _T("done_"), szRenamePrefix, SIZEOF(szRenamePrefix), mirandabootini);
+ GetPrivateProfileString(_T("AutoExec"), _T("RenamePrefix"), _T("done_"), szRenamePrefix, _countof(szRenamePrefix), mirandabootini);
mir_tstrcpy(szNewPath, szFindPath);
mir_tstrcat(szNewPath, szRenamePrefix);
mir_tstrcat(szNewPath, fd.cFileName);
diff --git a/src/mir_app/src/dbutils.cpp b/src/mir_app/src/dbutils.cpp index 18e6bac54f..c8a9e9dbea 100644 --- a/src/mir_app/src/dbutils.cpp +++ b/src/mir_app/src/dbutils.cpp @@ -61,12 +61,12 @@ static INT_PTR DbEventTypeRegister(WPARAM, LPARAM lParam) if (!p->textService) {
char szServiceName[100];
- mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s/GetEventText%d", p->module, p->eventType);
+ mir_snprintf(szServiceName, _countof(szServiceName), "%s/GetEventText%d", p->module, p->eventType);
p->textService = mir_strdup(szServiceName);
}
if (!p->iconService) {
char szServiceName[100];
- mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s/GetEventIcon%d", p->module, p->eventType);
+ mir_snprintf(szServiceName, _countof(szServiceName), "%s/GetEventIcon%d", p->module, p->eventType);
p->iconService = mir_strdup(szServiceName);
}
eventTypes.insert(p);
@@ -216,7 +216,7 @@ static INT_PTR DbEventGetIcon(WPARAM wParam, LPARAM lParam) icon = IcoLib_GetIconByHandle(et->eventIcon);
if (!icon) {
char szName[100];
- mir_snprintf(szName, SIZEOF(szName), "eventicon_%s%d", dbei->szModule, dbei->eventType);
+ mir_snprintf(szName, _countof(szName), "eventicon_%s%d", dbei->szModule, dbei->eventType);
icon = IcoLib_GetIcon(szName);
}
diff --git a/src/mir_app/src/extraicons.cpp b/src/mir_app/src/extraicons.cpp index 820ee03900..ff11fbfed4 100644 --- a/src/mir_app/src/extraicons.cpp +++ b/src/mir_app/src/extraicons.cpp @@ -520,7 +520,7 @@ void LoadExtraIconsModule() hEventExtraImageListRebuilding = CreateHookableEvent(ME_CLIST_EXTRA_LIST_REBUILD);
// Icons
- Icon_Register(g_hInst, LPGEN("Contact list"), iconList, SIZEOF(iconList));
+ Icon_Register(g_hInst, LPGEN("Contact list"), iconList, _countof(iconList));
// Hooks
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
diff --git a/src/mir_app/src/filter.cpp b/src/mir_app/src/filter.cpp index 83f91c407c..9a99e7eac7 100644 --- a/src/mir_app/src/filter.cpp +++ b/src/mir_app/src/filter.cpp @@ -59,7 +59,7 @@ void AddTreeViewNodes(HWND hWndDlg, PageHash key, HTREEITEM root) item.mask = TVIF_TEXT;
item.hItem = root;
item.pszText = title;
- item.cchTextMax = SIZEOF(title);
+ item.cchTextMax = _countof(title);
if (TreeView_GetItem(hWndDlg, &item))
if (mir_tstrlen(title) > 0)
@@ -78,12 +78,12 @@ void AddTreeViewNodes(HWND hWndDlg, PageHash key, HTREEITEM root) void AddDialogString(HWND hWndDlg, const PageHash key)
{
TCHAR title[2048];
- GetWindowText(hWndDlg, title, SIZEOF(title));
+ GetWindowText(hWndDlg, title, _countof(title));
if (mir_tstrlen(title) > 0)
AddFilterString(key, title);
TCHAR szClass[64];
- GetClassName(hWndDlg, szClass, SIZEOF(szClass));
+ GetClassName(hWndDlg, szClass, _countof(szClass));
if (mir_tstrcmpi(szClass, _T("SysTreeView32")) == 0) {
HTREEITEM hItem = TreeView_GetRoot(hWndDlg);
@@ -98,7 +98,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) title[0] = 0; //safety
int res = ListBox_GetText(hWndDlg, i, title);
if (res != LB_ERR) {
- title[SIZEOF(title) - 1] = 0;
+ title[_countof(title) - 1] = 0;
if (mir_tstrlen(title) > 0)
AddFilterString(key, title);
}
@@ -111,7 +111,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) int count = ListView_GetItemCount(hWndDlg);
for (int i=0; i < count; i++) {
title[0] = 0; //safety
- ListView_GetItemText(hWndDlg, i, 0, title, SIZEOF(title));
+ ListView_GetItemText(hWndDlg, i, 0, title, _countof(title));
if (mir_tstrlen(title) > 0)
AddFilterString(key, title);
@@ -126,7 +126,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) title[0] = 0; //safety
int res = ComboBox_GetLBText(hWndDlg, i, title);
if (res != CB_ERR) {
- title[SIZEOF(title) - 1] = 0;
+ title[_countof(title) - 1] = 0;
if (mir_tstrlen(title) > 0)
AddFilterString(key, title);
diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp index b1d470eacd..db81e02da2 100644 --- a/src/mir_app/src/findadd.cpp +++ b/src/mir_app/src/findadd.cpp @@ -284,7 +284,7 @@ static const int controls[] = { IDC_BYPROTOID, IDC_BYEMAIL, IDC_BYNAME, IDC_BYAD static void CheckSearchTypeRadioButton(HWND hwndDlg, int idControl) { - for (int i = 0; i < SIZEOF(controls); i++) + for (int i = 0; i < _countof(controls); i++) CheckDlgButton(hwndDlg, controls[i], idControl == controls[i] ? BST_CHECKED : BST_UNCHECKED); } @@ -359,7 +359,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc); partWidth[1] = partWidth[0] + 150; partWidth[2] = -1; - SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, SIZEOF(partWidth), (LPARAM)partWidth); + SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, _countof(partWidth), (LPARAM)partWidth); SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0); SetStatusBarSearchInfo(GetDlgItem(hwndDlg, IDC_STATUSBAR), dat); @@ -703,7 +703,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP BeginSearch(hwndDlg, dat, szProto, PS_SEARCHBYADVANCED, PF1_EXTSEARCHUI, dat->hwndTinySearch); else if (IsDlgButtonChecked(hwndDlg, IDC_BYPROTOID)) { TCHAR str[256]; - GetDlgItemText(hwndDlg, IDC_PROTOID, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_PROTOID, str, _countof(str)); rtrimt(str); if (str[0] == 0) MessageBox(hwndDlg, sttErrMsg, sttErrTitle, MB_ICONERROR | MB_OK); @@ -712,7 +712,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } else if (IsDlgButtonChecked(hwndDlg, IDC_BYEMAIL)) { TCHAR str[256]; - GetDlgItemText(hwndDlg, IDC_EMAIL, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_EMAIL, str, _countof(str)); rtrimt(str); if (str[0] == 0) MessageBox(hwndDlg, sttErrMsg, sttErrTitle, MB_ICONERROR | MB_OK); @@ -722,9 +722,9 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP else if (IsDlgButtonChecked(hwndDlg, IDC_BYNAME)) { TCHAR nick[256], first[256], last[256]; PROTOSEARCHBYNAME psbn; - GetDlgItemText(hwndDlg, IDC_NAMENICK, nick, SIZEOF(nick)); - GetDlgItemText(hwndDlg, IDC_NAMEFIRST, first, SIZEOF(first)); - GetDlgItemText(hwndDlg, IDC_NAMELAST, last, SIZEOF(last)); + GetDlgItemText(hwndDlg, IDC_NAMENICK, nick, _countof(nick)); + GetDlgItemText(hwndDlg, IDC_NAMEFIRST, first, _countof(first)); + GetDlgItemText(hwndDlg, IDC_NAMELAST, last, _countof(last)); psbn.pszFirstName = first; psbn.pszLastName = last; psbn.pszNick = nick; @@ -774,7 +774,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } else { TCHAR str[256]; - GetDlgItemText(hwndDlg, IDC_PROTOID, str, SIZEOF(str)); + GetDlgItemText(hwndDlg, IDC_PROTOID, str, _countof(str)); if (*rtrimt(str) == 0) break; diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp index 3246544f40..6e87b6f397 100644 --- a/src/mir_app/src/genmenu.cpp +++ b/src/mir_app/src/genmenu.cpp @@ -917,13 +917,13 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para DBVARIANT dbv = { 0 };
int pos;
char MenuNameItems[256];
- mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pmo->pszName);
+ mir_snprintf(MenuNameItems, _countof(MenuNameItems), "%s_Items", pmo->pszName);
char menuItemName[256];
GetMenuItemName(pmi, menuItemName, sizeof(menuItemName));
// check if it visible
- mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName);
+ mir_snprintf(DBString, _countof(DBString), "%s_visible", menuItemName);
if (db_get_b(NULL, MenuNameItems, DBString, -1) == -1)
db_set_b(NULL, MenuNameItems, DBString, 1);
@@ -934,14 +934,14 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para }
// mi.pszName
- mir_snprintf(DBString, SIZEOF(DBString), "%s_name", menuItemName);
+ mir_snprintf(DBString, _countof(DBString), "%s_name", menuItemName);
if (!db_get_ts(NULL, MenuNameItems, DBString, &dbv)) {
if (mir_tstrlen(dbv.ptszVal) > 0)
replaceStrT(pmi->CustomName, dbv.ptszVal);
db_free(&dbv);
}
- mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName);
+ mir_snprintf(DBString, _countof(DBString), "%s_pos", menuItemName);
if ((pos = db_get_dw(NULL, MenuNameItems, DBString, -1)) == -1) {
db_set_dw(NULL, MenuNameItems, DBString, mi->position);
if (pmi->submenu.first)
@@ -986,7 +986,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para #ifdef PUTPOSITIONSONMENU
if (GetKeyState(VK_CONTROL) & 0x8000) {
TCHAR str[256];
- mir_sntprintf(str, SIZEOF(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData);
+ mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData);
mii.dwTypeData = str;
}
#endif
@@ -1001,7 +1001,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para #ifdef PUTPOSITIONSONMENU
if (GetKeyState(VK_CONTROL) & 0x8000) {
TCHAR str[256];
- mir_sntprintf(str, SIZEOF(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData);
+ mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData);
mii.dwTypeData = str;
}
#endif
@@ -1060,10 +1060,10 @@ static int MO_RegisterIcon(PMO_IntMenuItem pmi, void*) HICON hIcon = ImageList_GetIcon(pmi->parent->m_hMenuIcons, pmi->iconId, 0);
TCHAR sectionName[256];
- mir_sntprintf(sectionName, SIZEOF(sectionName), LPGENT("Menu icons") _T("/%s"), TranslateTS(pmi->parent->ptszDisplayName));
+ mir_sntprintf(sectionName, _countof(sectionName), LPGENT("Menu icons") _T("/%s"), TranslateTS(pmi->parent->ptszDisplayName));
char iconame[256];
- mir_snprintf(iconame, SIZEOF(iconame), "genmenu_%s_%s", pmi->parent->pszName, uname && *uname ? uname : descr);
+ mir_snprintf(iconame, _countof(iconame), "genmenu_%s_%s", pmi->parent->pszName, uname && *uname ? uname : descr);
// remove '&'
if (descr) {
diff --git a/src/mir_app/src/genmenuopt.cpp b/src/mir_app/src/genmenuopt.cpp index 424488d4ea..db302e59da 100644 --- a/src/mir_app/src/genmenuopt.cpp +++ b/src/mir_app/src/genmenuopt.cpp @@ -73,7 +73,7 @@ class CGenMenuOptionsPage : public CDlgBase TVITEMEX tvi; tvi.hItem = m_menuItems.GetRoot(); - tvi.cchTextMax = SIZEOF(idstr); + tvi.cchTextMax = _countof(idstr); tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE; tvi.pszText = idstr; @@ -85,7 +85,7 @@ class CGenMenuOptionsPage : public CDlgBase TIntMenuObject *pimo = g_menus[menupos]; char MenuNameItems[256]; - mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName); + mir_snprintf(MenuNameItems, _countof(MenuNameItems), "%s_Items", pimo->pszName); int runtimepos = 100; while (tvi.hItem != NULL) { @@ -95,13 +95,13 @@ class CGenMenuOptionsPage : public CDlgBase char menuItemName[256], DBString[300]; GetMenuItemName(iod->pimi, menuItemName, sizeof(menuItemName)); - mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_visible", menuItemName); db_set_b(NULL, MenuNameItems, DBString, tvi.iImage != 0); - mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_pos", menuItemName); db_set_dw(NULL, MenuNameItems, DBString, runtimepos); - mir_snprintf(DBString, SIZEOF(DBString), "%s_name", menuItemName); + mir_snprintf(DBString, _countof(DBString), "%s_name", menuItemName); if (iod->name != NULL && iod->defname != NULL && mir_tstrcmp(iod->name, iod->defname) != 0) db_set_ts(NULL, MenuNameItems, DBString, iod->name); @@ -156,7 +156,7 @@ class CGenMenuOptionsPage : public CDlgBase return false; char menuItemName[256], MenuNameItems[256]; - mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName); + mir_snprintf(MenuNameItems, _countof(MenuNameItems), "%s_Items", pimo->pszName); LIST<MenuItemOptData> arItems(10, SortMenuItems); diff --git a/src/mir_app/src/groups.cpp b/src/mir_app/src/groups.cpp index 8ad218df03..9775eb39ba 100644 --- a/src/mir_app/src/groups.cpp +++ b/src/mir_app/src/groups.cpp @@ -81,13 +81,13 @@ static INT_PTR CreateGroupInternal(INT_PTR iParent, const TCHAR *ptszName) if (db_get_ts(NULL, "CListGroups", str, &dbv))
return 0;
- mir_sntprintf(newBaseName, SIZEOF(newBaseName), _T("%s\\%s"), dbv.ptszVal + 1, grpName);
+ mir_sntprintf(newBaseName, _countof(newBaseName), _T("%s\\%s"), dbv.ptszVal + 1, grpName);
mir_free(dbv.pszVal);
}
- else mir_tstrncpy(newBaseName, grpName, SIZEOF(newBaseName));
+ else mir_tstrncpy(newBaseName, grpName, _countof(newBaseName));
_itoa(newId, str, 10);
- mir_tstrncpy(newName + 1, newBaseName, SIZEOF(newName) - 1);
+ mir_tstrncpy(newName + 1, newBaseName, _countof(newName) - 1);
if (ptszName) {
i = GroupNameExists(newBaseName, -1);
if (i) newId = i - 1;
@@ -96,7 +96,7 @@ static INT_PTR CreateGroupInternal(INT_PTR iParent, const TCHAR *ptszName) else {
i = 1;
while (GroupNameExists(newName + 1, -1))
- mir_sntprintf(newName + 1, SIZEOF(newName) - 1, _T("%s (%d)"), newBaseName, i++);
+ mir_sntprintf(newName + 1, _countof(newName) - 1, _T("%s (%d)"), newBaseName, i++);
}
if (i) {
const CLISTGROUPCHANGE grpChg = { sizeof(CLISTGROUPCHANGE), NULL, newName };
@@ -140,7 +140,7 @@ static INT_PTR GetGroupName2(WPARAM wParam, LPARAM lParam) _itoa(wParam - 1, idstr, 10);
if (db_get_s(NULL, "CListGroups", idstr, &dbv))
return (INT_PTR) (char *) NULL;
- mir_strncpy(name, dbv.pszVal + 1, SIZEOF(name));
+ mir_strncpy(name, dbv.pszVal + 1, _countof(name));
if ((DWORD *) lParam != NULL)
*(DWORD *) lParam = dbv.pszVal[0];
db_free(&dbv);
@@ -157,7 +157,7 @@ TCHAR* fnGetGroupName(int idx, DWORD* pdwFlags) if (db_get_ts(NULL, "CListGroups", idstr, &dbv))
return NULL;
- mir_tstrncpy(name, dbv.ptszVal + 1, SIZEOF(name));
+ mir_tstrncpy(name, dbv.ptszVal + 1, _countof(name));
if (pdwFlags != NULL)
*pdwFlags = dbv.ptszVal[0];
db_free(&dbv);
@@ -185,12 +185,12 @@ static INT_PTR DeleteGroup(WPARAM wParam, LPARAM) _itoa(wParam - 1, str, 10);
if (db_get_ts(NULL, "CListGroups", str, &dbv))
return 1;
- mir_tstrncpy(name, dbv.ptszVal + 1, SIZEOF(name));
+ mir_tstrncpy(name, dbv.ptszVal + 1, _countof(name));
db_free(&dbv);
if (db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT))
{
TCHAR szQuestion[256+100];
- mir_sntprintf(szQuestion, SIZEOF(szQuestion), TranslateT("Are you sure you want to delete group '%s'? This operation cannot be undone."), name);
+ mir_sntprintf(szQuestion, _countof(szQuestion), TranslateT("Are you sure you want to delete group '%s'? This operation cannot be undone."), name);
if (MessageBox(cli.hwndContactList, szQuestion, TranslateT("Delete group"), MB_YESNO|MB_ICONQUESTION) == IDNO)
return 1;
}
@@ -250,9 +250,9 @@ static INT_PTR DeleteGroup(WPARAM wParam, LPARAM) break;
if (!_tcsncmp(dbv.ptszVal + 1, name, len) && dbv.pszVal[len + 1] == '\\' && _tcschr(dbv.ptszVal + len + 2, '\\') == NULL) {
if (szNewParent[0])
- mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s\\%s"), szNewParent, dbv.ptszVal + len + 2);
+ mir_sntprintf(szNewName, _countof(szNewName), _T("%s\\%s"), szNewParent, dbv.ptszVal + len + 2);
else
- mir_tstrncpy(szNewName, dbv.ptszVal + len + 2, SIZEOF(szNewName));
+ mir_tstrncpy(szNewName, dbv.ptszVal + len + 2, _countof(szNewName));
cli.pfnRenameGroup(i + 1, szNewName);
}
db_free(&dbv);
@@ -284,9 +284,9 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) if (db_get_ts(NULL, "CListGroups", idstr, &dbv))
return 1;
str[0] = dbv.pszVal[0] & 0x7F;
- mir_tstrncpy(oldName, dbv.ptszVal + 1, SIZEOF(oldName));
+ mir_tstrncpy(oldName, dbv.ptszVal + 1, _countof(oldName));
db_free(&dbv);
- mir_tstrncpy(str + 1, szName, SIZEOF(str) - 1);
+ mir_tstrncpy(str + 1, szName, _countof(str) - 1);
db_set_ts(NULL, "CListGroups", idstr, str);
//must rename setting in all child contacts too
@@ -311,7 +311,7 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) if (db_get_ts(NULL, "CListGroups", idstr, &dbv))
break;
if (!_tcsncmp(dbv.ptszVal + 1, oldName, len) && dbv.ptszVal[len + 1] == '\\' && _tcschr(dbv.ptszVal + len + 2, '\\') == NULL) {
- mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s\\%s"), szName, dbv.ptszVal + len + 2);
+ mir_sntprintf(szNewName, _countof(szNewName), _T("%s\\%s"), szName, dbv.ptszVal + len + 2);
RenameGroupWithMove(i, szNewName, 0); //luckily, child groups will never need reordering
}
db_free(&dbv);
@@ -323,7 +323,7 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) TCHAR *pszLastBackslash;
int i;
- mir_tstrncpy(str, szName, SIZEOF(str));
+ mir_tstrncpy(str, szName, _countof(str));
pszLastBackslash = _tcsrchr(str, '\\');
if (pszLastBackslash != NULL) {
*pszLastBackslash = '\0';
@@ -484,18 +484,18 @@ static INT_PTR BuildGroupMenu(WPARAM, LPARAM) do {
pBackslash = _tcschr(pNextField, '\\');
if (pBackslash == NULL) {
- mir_tstrncpy(szThisField, pNextField, SIZEOF(szThisField));
+ mir_tstrncpy(szThisField, pNextField, _countof(szThisField));
pNextField = NULL;
}
else {
- mir_tstrncpy(szThisField, pNextField, min(SIZEOF(szThisField), pBackslash - pNextField + 1));
+ mir_tstrncpy(szThisField, pNextField, min(_countof(szThisField), pBackslash - pNextField + 1));
pNextField = pBackslash + 1;
}
compareResult = 1;
menuItemCount = GetMenuItemCount(hThisMenu);
for (menuId = 0; menuId < menuItemCount; menuId++) {
mii.fMask = MIIM_TYPE | MIIM_SUBMENU | MIIM_DATA;
- mii.cch = SIZEOF(szThisMenuItem);
+ mii.cch = _countof(szThisMenuItem);
mii.dwTypeData = szThisMenuItem;
GetMenuItemInfo(hThisMenu, menuId, TRUE, &mii);
compareResult = mir_tstrcmp(szThisField, szThisMenuItem);
diff --git a/src/mir_app/src/hotkey_opts.cpp b/src/mir_app/src/hotkey_opts.cpp index cd7d542a7e..015c0830cc 100644 --- a/src/mir_app/src/hotkey_opts.cpp +++ b/src/mir_app/src/hotkey_opts.cpp @@ -127,7 +127,7 @@ static LRESULT CALLBACK sttHotkeyEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP TCHAR buf[256] = { 0 }; data->key = (BYTE)LOWORD(wParam); data->shift = (BYTE)HIWORD(wParam); - HotkeyToName(buf, SIZEOF(buf), data->shift, data->key); + HotkeyToName(buf, _countof(buf), data->shift, data->key); SetWindowText(hwnd, buf); } return 0; @@ -169,7 +169,7 @@ static LRESULT CALLBACK sttHotkeyEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP data->key = key; } - HotkeyToName(buf, SIZEOF(buf), data->shift, data->key); + HotkeyToName(buf, _countof(buf), data->shift, data->key); SetWindowText(hwnd, buf); if (bKeyDown && data->key) @@ -222,7 +222,7 @@ static void sttOptionsSetupItem(HWND hwndList, int idx, THotkeyItem *item) lvi.mask = LVIF_TEXT; lvi.iSubItem = COL_KEY; - HotkeyToName(buf, SIZEOF(buf), HIBYTE(item->OptHotkey), LOBYTE(item->OptHotkey)); + HotkeyToName(buf, _countof(buf), HIBYTE(item->OptHotkey), LOBYTE(item->OptHotkey)); lvi.pszText = buf; ListView_SetItem(hwndList, &lvi); @@ -269,14 +269,14 @@ static int CALLBACK sttOptionsSortList(LPARAM lParam1, LPARAM lParam2, LPARAM lP lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iItem = lParam1; lvi.pszText = title1; - lvi.cchTextMax = SIZEOF(title1); + lvi.cchTextMax = _countof(title1); if (ListView_GetItem((HWND)lParamSort, &lvi)) item1 = (THotkeyItem *)lvi.lParam; lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iItem = lParam2; lvi.pszText = title2; - lvi.cchTextMax = SIZEOF(title2); + lvi.cchTextMax = _countof(title2); if (ListView_GetItem((HWND)lParamSort, &lvi)) item2 = (THotkeyItem *)lvi.lParam; @@ -523,7 +523,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, TCHAR buf[128]; LVITEM lvi = { 0 }; lvi.pszText = buf; - lvi.cchTextMax = SIZEOF(buf); + lvi.cchTextMax = _countof(buf); for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) { char *szSetting; @@ -896,7 +896,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, lvi.mask = LVIF_TEXT; lvi.iItem = param->iItem; lvi.pszText = buf; - lvi.cchTextMax = SIZEOF(buf); + lvi.cchTextMax = _countof(buf); ListView_GetItem(lpnmhdr->hwndFrom, &lvi); if (param->uNewState >> 12 == 1) { @@ -957,7 +957,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iItem = param->nmcd.dwItemSpec; lvi.pszText = buf; - lvi.cchTextMax = SIZEOF(buf); + lvi.cchTextMax = _countof(buf); ListView_GetItem(lpnmhdr->hwndFrom, &lvi); item = (THotkeyItem *)lvi.lParam; @@ -1014,7 +1014,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, TCHAR buf[128]; LVITEM lvi = { 0 }; lvi.pszText = buf; - lvi.cchTextMax = SIZEOF(buf); + lvi.cchTextMax = _countof(buf); for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) { lvi.mask = LVIF_PARAM; lvi.iSubItem = 0; diff --git a/src/mir_app/src/hotkeys.cpp b/src/mir_app/src/hotkeys.cpp index edc92b10dd..0e91b12775 100644 --- a/src/mir_app/src/hotkeys.cpp +++ b/src/mir_app/src/hotkeys.cpp @@ -154,7 +154,7 @@ static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam) if (item->rootHotkey = hotkeys.find(item)) {
if (item->rootHotkey->allowSubHotkeys) {
char nameBuf[MAXMODULELABELLENGTH];
- mir_snprintf(nameBuf, SIZEOF(nameBuf), "%s$%d", item->rootHotkey->pszName, item->rootHotkey->nSubHotkeys);
+ mir_snprintf(nameBuf, _countof(nameBuf), "%s$%d", item->rootHotkey->pszName, item->rootHotkey->nSubHotkeys);
item->pszName = mir_strdup(nameBuf);
item->Enabled = TRUE;
@@ -221,7 +221,7 @@ static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam) char *pszName = (char *)lParam;
char pszNamePrefix[MAXMODULELABELLENGTH];
size_t cbNamePrefix;
- mir_snprintf(pszNamePrefix, SIZEOF(pszNamePrefix), "%s$", pszName);
+ mir_snprintf(pszNamePrefix, _countof(pszNamePrefix), "%s$", pszName);
cbNamePrefix = mir_strlen(pszNamePrefix);
for (i = 0; i < hotkeys.getCount(); i++) {
@@ -377,7 +377,7 @@ int LoadSkinHotkeys(void) HookEvent(ME_SYSTEM_MODULESLOADED, sttModulesLoaded);
- for (int i = 0; i < SIZEOF(oldSettings); i++) {
+ for (int i = 0; i < _countof(oldSettings); i++) {
char szSetting[100];
mir_snprintf(szSetting, "HK%s", oldSettings[i]);
diff --git a/src/mir_app/src/hyperlink.cpp b/src/mir_app/src/hyperlink.cpp index bb62808f44..10121b2ee8 100644 --- a/src/mir_app/src/hyperlink.cpp +++ b/src/mir_app/src/hyperlink.cpp @@ -151,7 +151,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_CREATE:
case HLK_MEASURETEXT:
{ TCHAR szText[256];
- if (!GetWindowText(hwnd, szText, SIZEOF(szText))) return 0;
+ if (!GetWindowText(hwnd, szText, _countof(szText))) return 0;
lParam = (LPARAM)szText;
/* fall thru */
case WM_SETTEXT:
@@ -228,7 +228,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA hPrevFont = (HFONT)SelectObject(hdc, dat->hDisableFont);
textColor = dat->disableColor;
}
- if (GetClientRect(hwnd, &rc) && GetWindowText(hwnd, szText, SIZEOF(szText))) {
+ if (GetClientRect(hwnd, &rc) && GetWindowText(hwnd, szText, _countof(szText))) {
BOOL fSmoothing;
UINT fSmoothingType;
SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &fSmoothing, 0);
diff --git a/src/mir_app/src/icolib.cpp b/src/mir_app/src/icolib.cpp index ad35eb3509..f5db3be974 100644 --- a/src/mir_app/src/icolib.cpp +++ b/src/mir_app/src/icolib.cpp @@ -348,7 +348,7 @@ IconSourceItem* GetIconSourceItemFromPath(const TCHAR* path, int cxIcon, int cyI return NULL;
TCHAR file[MAX_PATH];
- mir_tstrncpy(file, path, SIZEOF(file));
+ mir_tstrncpy(file, path, _countof(file));
TCHAR *comma = _tcsrchr(file, ',');
int n;
@@ -368,7 +368,7 @@ IconSourceItem* CreateStaticIconSourceItem(int cxIcon, int cyIcon) int i = 0;
do { // find new unique name
- mir_sntprintf(sourceName, SIZEOF(sourceName), _T("*StaticIcon_%d"), i++);
+ mir_sntprintf(sourceName, _countof(sourceName), _T("*StaticIcon_%d"), i++);
} while (iconSourceFileList.getIndex(&key) != -1);
IconSourceItem* newItem = (IconSourceItem*)mir_calloc(sizeof(IconSourceItem));
diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp index 5fc8208104..00d0384d74 100644 --- a/src/mir_app/src/ignore.cpp +++ b/src/mir_app/src/ignore.cpp @@ -58,7 +58,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt while (hItem) {
hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem, childCount);
- for (i=0; i < SIZEOF(iconOn); i++)
+ for (i=0; i < _countof(iconOn); i++)
if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i] = 0;
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
@@ -66,7 +66,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem;
else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while (hItem) {
- for (i=0; i < SIZEOF(iconOn); i++) {
+ for (i=0; i < _countof(iconOn); i++) {
iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i);
if (iconOn[i] && iImage == 0) iconOn[i] = 0;
if (iImage != EMPTY_EXTRA_ICON)
@@ -75,7 +75,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- for (i=0; i < SIZEOF(iconOn); i++) {
+ for (i=0; i < _countof(iconOn); i++) {
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+3:0) : EMPTY_EXTRA_ICON));
if (groupChildCount) groupChildCount[i]+=childCount[i];
}
@@ -200,7 +200,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_TYPING);
SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
- for (int i=0; i < SIZEOF(hIcons); i++)
+ for (int i=0; i < _countof(hIcons); i++)
hIcons[i] = ImageList_GetIcon(hIml, 1+i, ILD_NORMAL);
}
@@ -305,7 +305,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM break;
case WM_DESTROY:
- for (int i=0; i < SIZEOF(hIcons); i++)
+ for (int i=0; i < _countof(hIcons); i++)
DestroyIcon(hIcons[i]);
HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
ImageList_Destroy(hIml);
diff --git a/src/mir_app/src/langpack.cpp b/src/mir_app/src/langpack.cpp index 692dfa7634..848eb81fee 100644 --- a/src/mir_app/src/langpack.cpp +++ b/src/mir_app/src/langpack.cpp @@ -75,7 +75,7 @@ BOOL EnumLangpacks(ENUM_PACKS_CALLBACK callback, WPARAM wParam, LPARAM lParam) DWORD v = CallService(MS_SYSTEM_GETVERSION, 0, 0);
pack.szLastModifiedUsing.Format("%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF));
/* file date */
- if (GetModuleFileName(NULL, pack.tszFullPath, SIZEOF(pack.tszFullPath))) {
+ if (GetModuleFileName(NULL, pack.tszFullPath, _countof(pack.tszFullPath))) {
mir_tstrcpy(pack.tszFileName, _T("default"));
HANDLE hFile = CreateFile(pack.tszFileName, 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (hFile != INVALID_HANDLE_VALUE) {
diff --git a/src/mir_app/src/lpopts.cpp b/src/mir_app/src/lpopts.cpp index a0f8812d41..735d4ab1bf 100644 --- a/src/mir_app/src/lpopts.cpp +++ b/src/mir_app/src/lpopts.cpp @@ -36,18 +36,18 @@ static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack) if (!(pack->flags & LPF_NOLOCALE)) {
TCHAR szLocaleName[256], szLanguageName[128], szContryName[128];
- if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHLANGUAGENAME : LOCALE_SENGLANGUAGE, szLanguageName, SIZEOF(szLanguageName)))
+ if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHLANGUAGENAME : LOCALE_SENGLANGUAGE, szLanguageName, _countof(szLanguageName)))
szLanguageName[0] = _T('\0');
- if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHCOUNTRYNAME : LOCALE_SENGCOUNTRY, szContryName, SIZEOF(szContryName)))
+ if (!GetLocaleInfo(pack->Locale, WINVER >= _WIN32_WINNT_WIN7 ? LOCALE_SENGLISHCOUNTRYNAME : LOCALE_SENGCOUNTRY, szContryName, _countof(szContryName)))
szContryName[0] = _T('\0');
/* add some note if its incompatible */
if (szLanguageName[0] && szContryName[0]) {
- mir_sntprintf(szLocaleName, SIZEOF(szLocaleName), _T("%s (%s)"), TranslateTS(szLanguageName), TranslateTS(szContryName));
+ mir_sntprintf(szLocaleName, _countof(szLocaleName), _T("%s (%s)"), TranslateTS(szLanguageName), TranslateTS(szContryName));
if (!IsValidLocale(pack->Locale, LCID_INSTALLED)) {
TCHAR *pszIncompat;
pszIncompat = TranslateT("(incompatible)");
- szLocaleName[SIZEOF(szLocaleName) - mir_tstrlen(pszIncompat) - 1] = 0;
+ szLocaleName[_countof(szLocaleName) - mir_tstrlen(pszIncompat) - 1] = 0;
mir_tstrcat(mir_tstrcat(szLocaleName, _T(" ")), pszIncompat);
}
SetDlgItemText(hwndDlg, IDC_LANGLOCALE, szLocaleName);
@@ -60,7 +60,7 @@ static void DisplayPackInfo(HWND hwndDlg, const LANGPACK_INFO *pack) SYSTEMTIME stFileDate;
TCHAR szDate[128]; szDate[0] = 0;
if (FileTimeToSystemTime(&pack->ftFileDate, &stFileDate))
- GetDateFormat(Langpack_GetDefaultLocale(), DATE_SHORTDATE, &stFileDate, NULL, szDate, SIZEOF(szDate));
+ GetDateFormat(Langpack_GetDefaultLocale(), DATE_SHORTDATE, &stFileDate, NULL, szDate, _countof(szDate));
SetDlgItemText(hwndDlg, IDC_LANGDATE, szDate);
/* general */
@@ -77,7 +77,7 @@ static BOOL InsertPackItemEnumProc(LANGPACK_INFO *pack, WPARAM wParam, LPARAM) /* insert */
TCHAR tszName[512];
- mir_sntprintf(tszName, SIZEOF(tszName), _T("%s [%s]"),
+ mir_sntprintf(tszName, _countof(tszName), _T("%s [%s]"),
TranslateTS(pack->tszLanguage),
pack->flags & LPF_DEFAULT ? TranslateT("built-in") : pack->tszFileName);
UINT message = pack->flags & LPF_DEFAULT ? CB_INSERTSTRING : CB_ADDSTRING;
@@ -125,7 +125,7 @@ INT_PTR CALLBACK DlgLangpackOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP {
char buf[512];
mir_strcpy(buf, "mailto:");
- if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), &buf[7], SIZEOF(buf) - 7))
+ if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), &buf[7], _countof(buf) - 7))
CallService(MS_UTILS_OPENURL, 0, (LPARAM)buf);
}
break;
diff --git a/src/mir_app/src/meta_main.cpp b/src/mir_app/src/meta_main.cpp index 3c18940afe..2b49613832 100644 --- a/src/mir_app/src/meta_main.cpp +++ b/src/mir_app/src/meta_main.cpp @@ -56,7 +56,7 @@ void UnloadMetacontacts(void) // Called when the plugin is loaded into Miranda
int LoadMetacontacts(void)
{
- Icon_Register(g_hInst, LPGEN("MetaContacts"), iconList, SIZEOF(iconList), "mc");
+ Icon_Register(g_hInst, LPGEN("MetaContacts"), iconList, _countof(iconList), "mc");
db_set_resident(META_PROTO, "Status");
db_set_resident(META_PROTO, "IdleTS");
diff --git a/src/mir_app/src/meta_menu.cpp b/src/mir_app/src/meta_menu.cpp index 49901c6412..1dce9747d4 100644 --- a/src/mir_app/src/meta_menu.cpp +++ b/src/mir_app/src/meta_menu.cpp @@ -296,7 +296,7 @@ int Meta_ModifyMenu(WPARAM hMeta, LPARAM) // show hide nudge menu item
char serviceFunc[256];
- mir_snprintf(serviceFunc, SIZEOF(serviceFunc), "%s%s", GetContactProto(Meta_GetMostOnline(cc)), PS_SEND_NUDGE);
+ mir_snprintf(serviceFunc, _countof(serviceFunc), "%s%s", GetContactProto(Meta_GetMostOnline(cc)), PS_SEND_NUDGE);
CallService(MS_NUDGE_SHOWMENU, (WPARAM)META_PROTO, ServiceExists(serviceFunc));
return 0;
}
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp index 5c6962f8cd..2379458374 100644 --- a/src/mir_app/src/meta_services.cpp +++ b/src/mir_app/src/meta_services.cpp @@ -243,7 +243,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam, LPARAM lParam) tfap->hContact = ccs->hContact;
tfap->hEvent = hEvent;
tfap->id = 10;
- strncpy(tfap->msg, Translate("No online contacts found."), SIZEOF(tfap->msg) - 1);
+ strncpy(tfap->msg, Translate("No online contacts found."), _countof(tfap->msg) - 1);
CloseHandle(mir_forkthread(sttFakeAckFail, (void*)tfap));
SetEvent(hEvent);
@@ -852,7 +852,7 @@ void Meta_InitServices() // hidden contact menu items...ho hum
for (int i = 0; i < MAX_CONTACTS; i++) {
char szServiceName[100];
- mir_snprintf(szServiceName, SIZEOF(szServiceName), "MetaContacts/MenuFunc%d", i);
+ mir_snprintf(szServiceName, _countof(szServiceName), "MetaContacts/MenuFunc%d", i);
CreateServiceFunctionParam(szServiceName, MenuFunc, i);
}
diff --git a/src/mir_app/src/meta_utils.cpp b/src/mir_app/src/meta_utils.cpp index fc32d1a929..3be2190071 100644 --- a/src/mir_app/src/meta_utils.cpp +++ b/src/mir_app/src/meta_utils.cpp @@ -489,8 +489,8 @@ int Meta_SetAllNicks() static void SwapValues(MCONTACT hContact, LPCSTR szSetting, int n1, int n2)
{
char buf1[100], buf2[100];
- mir_snprintf(buf1, SIZEOF(buf1), "%s%d", szSetting, n1);
- mir_snprintf(buf2, SIZEOF(buf2), "%s%d", szSetting, n2);
+ mir_snprintf(buf1, _countof(buf1), "%s%d", szSetting, n1);
+ mir_snprintf(buf2, _countof(buf2), "%s%d", szSetting, n2);
DBVARIANT dbv1, dbv2;
int ok1 = !db_get(hContact, META_PROTO, buf1, &dbv1);
@@ -526,7 +526,7 @@ int Meta_SwapContacts(DBCachedContact *cc, int n1, int n2) void Meta_GetSubNick(MCONTACT hMeta, int i, CMString &tszDest)
{
char idStr[50];
- mir_snprintf(idStr, SIZEOF(idStr), "Login%d", i);
+ mir_snprintf(idStr, _countof(idStr), "Login%d", i);
DBVARIANT dbv;
if(db_get(hMeta, META_PROTO, idStr, &dbv))
diff --git a/src/mir_app/src/miranda.cpp b/src/mir_app/src/miranda.cpp index a76fc46adc..6c908228ba 100644 --- a/src/mir_app/src/miranda.cpp +++ b/src/mir_app/src/miranda.cpp @@ -325,7 +325,7 @@ static INT_PTR OkToExit(WPARAM, LPARAM) static INT_PTR GetMirandaVersion(WPARAM, LPARAM)
{
TCHAR filename[MAX_PATH];
- GetModuleFileName(g_hInst, filename, SIZEOF(filename));
+ GetModuleFileName(g_hInst, filename, _countof(filename));
DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
PVOID pVerInfo = _alloca(verInfoSize);
@@ -344,7 +344,7 @@ static INT_PTR GetMirandaVersion(WPARAM, LPARAM) static INT_PTR GetMirandaFileVersion(WPARAM, LPARAM lParam)
{
TCHAR filename[MAX_PATH];
- GetModuleFileName(g_hInst, filename, SIZEOF(filename));
+ GetModuleFileName(g_hInst, filename, _countof(filename));
DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
PVOID pVerInfo = _alloca(verInfoSize);
@@ -365,7 +365,7 @@ static INT_PTR GetMirandaFileVersion(WPARAM, LPARAM lParam) static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam)
{
TCHAR filename[MAX_PATH], *productVersion;
- GetModuleFileName(g_hInst, filename, SIZEOF(filename));
+ GetModuleFileName(g_hInst, filename, _countof(filename));
DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
PVOID pVerInfo = _alloca(verInfoSize);
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp index 7453fe5c0a..5cd39c0e68 100644 --- a/src/mir_app/src/netlib.cpp +++ b/src/mir_app/src/netlib.cpp @@ -289,8 +289,8 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) waitHandles[1] = nlc->hOkToCloseEvent;
waitHandles[2] = nlc->ncsRecv.hMutex;
waitHandles[3] = nlc->ncsSend.hMutex;
- waitResult = WaitForMultipleObjects(SIZEOF(waitHandles), waitHandles, TRUE, INFINITE);
- if (waitResult >= WAIT_OBJECT_0 + SIZEOF(waitHandles)) {
+ waitResult = WaitForMultipleObjects(_countof(waitHandles), waitHandles, TRUE, INFINITE);
+ if (waitResult >= WAIT_OBJECT_0 + _countof(waitHandles)) {
ReleaseMutex(hConnectionHeaderMutex);
SetLastError(ERROR_INVALID_PARAMETER); //already been closed
return 0;
diff --git a/src/mir_app/src/netlibautoproxy.cpp b/src/mir_app/src/netlibautoproxy.cpp index 92982a9999..f9572d4cb9 100644 --- a/src/mir_app/src/netlibautoproxy.cpp +++ b/src/mir_app/src/netlibautoproxy.cpp @@ -370,14 +370,14 @@ void NetlibLoadIeProxy(void) int tResult = RegQueryValueExA(hSettings, "ProxyEnable", NULL, NULL, (BYTE*)&enabled, &tValueLen);
bEnabled = enabled && tResult == ERROR_SUCCESS;
- tValueLen = SIZEOF(szHostStr);
+ tValueLen = _countof(szHostStr);
tResult = RegQueryValueExA(hSettings, "ProxyServer", NULL, NULL, (BYTE*)szHostStr, &tValueLen);
bEnabled = bEnabled && tResult == ERROR_SUCCESS;
- tValueLen = SIZEOF(szAutoUrlStr);
+ tValueLen = _countof(szAutoUrlStr);
RegQueryValueExA(hSettings, "AutoConfigUrl", NULL, NULL, (BYTE*)szAutoUrlStr, &tValueLen);
- tValueLen = SIZEOF(szProxyBypassStr);
+ tValueLen = _countof(szProxyBypassStr);
RegQueryValueExA(hSettings, "ProxyOverride", NULL, NULL, (BYTE*)szProxyBypassStr, &tValueLen);
RegCloseKey(hSettings);
diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp index 77fb25fd97..2627b0fc96 100644 --- a/src/mir_app/src/netlibbind.cpp +++ b/src/mir_app/src/netlibbind.cpp @@ -279,7 +279,7 @@ LBL_Error: if (nlb->dwInternalIP == 0) {
char hostname[64] = "";
- gethostname(hostname, SIZEOF(hostname));
+ gethostname(hostname, _countof(hostname));
PHOSTENT he = gethostbyname(hostname);
if (he && he->h_addr)
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index d18139d69e..c1d154bc1c 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -264,7 +264,7 @@ struct HttpSecurityContext if (szHost && _stricmp(szProvider, "Basic")) {
unsigned long ip = inet_addr(szHost);
PHOSTENT host = (ip == INADDR_NONE) ? gethostbyname(szHost) : gethostbyaddr((char*)&ip, 4, AF_INET);
- mir_snprintf(szSpnStr, SIZEOF(szSpnStr), "HTTP/%s", host && host->h_name ? host->h_name : szHost);
+ mir_snprintf(szSpnStr, _countof(szSpnStr), "HTTP/%s", host && host->h_name ? host->h_name : szHost);
_strlwr(szSpnStr + 5);
NetlibLogf(nlc->nlu, "Host SPN: %s", szSpnStr);
}
@@ -311,7 +311,7 @@ static int HttpPeekFirstResponseLine(NetlibConnection *nlc, DWORD dwTimeoutTime, char *peol;
while(true) {
- bytesPeeked = RecvWithTimeoutTime(nlc, dwTimeoutTime, buffer, SIZEOF(buffer) - 1, MSG_PEEK | recvFlags);
+ bytesPeeked = RecvWithTimeoutTime(nlc, dwTimeoutTime, buffer, _countof(buffer) - 1, MSG_PEEK | recvFlags);
if (bytesPeeked == 0) {
SetLastError(ERROR_HANDLE_EOF);
@@ -328,7 +328,7 @@ static int HttpPeekFirstResponseLine(NetlibConnection *nlc, DWORD dwTimeoutTime, SetLastError(ERROR_BAD_FORMAT);
return 0;
}
- if (bytesPeeked == SIZEOF(buffer) - 1) {
+ if (bytesPeeked == _countof(buffer) - 1) {
SetLastError(ERROR_BUFFER_OVERFLOW);
return 0;
}
@@ -868,13 +868,13 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) ++nlhrSend.headersCount;
char szMirandaVer[64];
- CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(szMirandaVer), (LPARAM)szMirandaVer);
+ CallService(MS_SYSTEM_GETVERSIONTEXT, _countof(szMirandaVer), (LPARAM)szMirandaVer);
char *pspace = strchr(szMirandaVer, ' ');
if (pspace) {
*pspace++='\0';
- mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s (%s)", szMirandaVer, pspace);
+ mir_snprintf(szUserAgent, _countof(szUserAgent), "Miranda/%s (%s)", szMirandaVer, pspace);
}
- else mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s", szMirandaVer);
+ else mir_snprintf(szUserAgent, _countof(szUserAgent), "Miranda/%s", szMirandaVer);
}
if (!doneAcceptEncoding) {
nlhrSend.headers[nlhrSend.headersCount].szName = "Accept-Encoding";
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index 3ac72264d8..7c9ae6e08d 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -104,7 +104,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa CheckDlgButton(hwndDlg, IDC_TEXTDUMPS, logOptions.textDumps ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTODETECTTEXT, logOptions.autoDetectText ? BST_CHECKED : BST_UNCHECKED);
{
- for (int i=0; i < SIZEOF(szTimeFormats); i++)
+ for (int i=0; i < _countof(szTimeFormats); i++)
SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szTimeFormats[i]));
}
SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_SETCURSEL, logOptions.timeFormat, 0);
@@ -148,7 +148,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa CheckDlgButton(hwndDlg, IDC_TOFILE, BST_CHECKED);
TCHAR path[MAX_PATH];
- GetWindowText((HWND)lParam, path, SIZEOF(path));
+ GetWindowText((HWND)lParam, path, _countof(path));
PathToAbsoluteT(VARST(path), path);
SetDlgItemText(hwndDlg, IDC_PATH, path);
@@ -157,10 +157,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case IDC_FILENAMEBROWSE:
case IDC_RUNATSTARTBROWSE:
- GetWindowText(GetWindow((HWND)lParam, GW_HWNDPREV), str, SIZEOF(str));
+ GetWindowText(GetWindow((HWND)lParam, GW_HWNDPREV), str, _countof(str));
{
TCHAR filter[200];
- mir_sntprintf(filter, SIZEOF(filter), _T("%s (*)%c*%c"), TranslateT("All files"), 0, 0);
+ mir_sntprintf(filter, _countof(filter), _T("%s (*)%c*%c"), TranslateT("All files"), 0, 0);
OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
@@ -174,7 +174,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa }
ofn.lpstrFilter = filter;
ofn.lpstrFile = str;
- ofn.nMaxFile = SIZEOF(str) - 2;
+ ofn.nMaxFile = _countof(str) - 2;
ofn.nMaxFileTitle = MAX_PATH;
if (LOWORD(wParam) == IDC_FILENAMEBROWSE) {
if (!GetSaveFileName(&ofn)) return 1;
@@ -183,7 +183,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa return 1;
if (LOWORD(wParam) == IDC_RUNATSTARTBROWSE && _tcschr(str, ' ') != NULL) {
- memmove(str + 1, str, ((SIZEOF(str) - 2) * sizeof(TCHAR)));
+ memmove(str + 1, str, ((_countof(str) - 2) * sizeof(TCHAR)));
str[0] = '"';
mir_tstrcat(str, _T("\""));
}
@@ -192,7 +192,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa break;
case IDC_RUNNOW:
- GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, _countof(str));
if (str[0]) {
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
@@ -201,15 +201,15 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa break;
case IDOK:
- GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, _countof(str));
db_set_ts(NULL, "Netlib", "RunAtStart", str);
db_set_b(NULL, "Netlib", "ShowLogOptsAtStart", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWTHISDLGATSTART));
- GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_FILENAME, str, _countof(str));
logOptions.tszUserFile = rtrimt(str);
db_set_ts(NULL, "Netlib", "File", str);
- GetDlgItemText(hwndDlg, IDC_PATH, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_PATH, str, _countof(str));
logOptions.tszFile = rtrimt(str);
db_set_b(NULL, "Netlib", "DumpRecv", logOptions.dumpRecv = IsDlgButtonChecked(hwndDlg, IDC_DUMPRECV));
@@ -300,21 +300,21 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) char szTime[32], szHead[128];
switch (logOptions.timeFormat) {
case TIMEFORMAT_HHMMSS:
- GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, NULL, NULL, szTime, SIZEOF(szTime));
+ GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, NULL, NULL, szTime, _countof(szTime));
mir_strcat(szTime, " ");
break;
case TIMEFORMAT_MILLISECONDS:
QueryPerformanceCounter(&liTimeNow);
liTimeNow.QuadPart -= mirandaStartTime;
- mir_snprintf(szTime, SIZEOF(szTime), "%I64u.%03I64u ", liTimeNow.QuadPart / perfCounterFreq,
+ mir_snprintf(szTime, _countof(szTime), "%I64u.%03I64u ", liTimeNow.QuadPart / perfCounterFreq,
1000 * (liTimeNow.QuadPart % perfCounterFreq) / perfCounterFreq);
break;
case TIMEFORMAT_MICROSECONDS:
QueryPerformanceCounter(&liTimeNow);
liTimeNow.QuadPart -= mirandaStartTime;
- mir_snprintf(szTime, SIZEOF(szTime), "%I64u.%06I64u ", liTimeNow.QuadPart / perfCounterFreq,
+ mir_snprintf(szTime, _countof(szTime), "%I64u.%06I64u ", liTimeNow.QuadPart / perfCounterFreq,
1000000 * (liTimeNow.QuadPart % perfCounterFreq) / perfCounterFreq);
break;
@@ -325,9 +325,9 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) char *szUser = (logOptions.showUser) ? (nlu == NULL ? NULL : nlu->user.szSettingsModule) : NULL;
if (szUser)
- mir_snprintf(szHead, SIZEOF(szHead), "[%s%04X] [%s] ", szTime, GetCurrentThreadId(), szUser);
+ mir_snprintf(szHead, _countof(szHead), "[%s%04X] [%s] ", szTime, GetCurrentThreadId(), szUser);
else
- mir_snprintf(szHead, SIZEOF(szHead), "[%s%04X] ", szTime, GetCurrentThreadId());
+ mir_snprintf(szHead, _countof(szHead), "[%s%04X] ", szTime, GetCurrentThreadId());
if (logOptions.toOutputDebugString) {
if (szHead[0])
@@ -401,7 +401,7 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
NetlibUser *nlu = nlc ? nlc->nlu : NULL;
- int titleLineLen = mir_snprintf(szTitleLine, SIZEOF(szTitleLine), "(%p:%u) Data %s%s\r\n",
+ int titleLineLen = mir_snprintf(szTitleLine, _countof(szTitleLine), "(%p:%u) Data %s%s\r\n",
nlc, nlc ? nlc->s : 0, sent ? "sent" : "received", flags & MSG_DUMPPROXY ? " (proxy)" : "");
ReleaseMutex(hConnectionHeaderMutex);
diff --git a/src/mir_app/src/netlibopts.cpp b/src/mir_app/src/netlibopts.cpp index 85d17fcee8..90e6a5a555 100644 --- a/src/mir_app/src/netlibopts.cpp +++ b/src/mir_app/src/netlibopts.cpp @@ -304,7 +304,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, CopySettingsStruct(&settings, &tempSettings[iUser]->settings);
flags = tempSettings[iUser]->flags;
}
- ShowMultipleControls(hwndDlg, outgoingConnectionsControls, SIZEOF(outgoingConnectionsControls), flags&NUF_OUTGOING ? SW_SHOW : SW_HIDE);
+ ShowMultipleControls(hwndDlg, outgoingConnectionsControls, _countof(outgoingConnectionsControls), flags&NUF_OUTGOING ? SW_SHOW : SW_HIDE);
CheckDlgButton(hwndDlg, IDC_USEPROXY, settings.useProxy ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_RESETCONTENT, 0, 0);
if (settings.proxyType == 0) AddProxyTypeItem(hwndDlg, 0, settings.proxyType);
@@ -323,7 +323,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, CheckDlgButton(hwndDlg, IDC_PROXYDNS, settings.dnsThroughProxy ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_VALIDATESSL, settings.validateSSL ? BST_CHECKED : BST_UNCHECKED);
- ShowMultipleControls(hwndDlg, incomingConnectionsControls, SIZEOF(incomingConnectionsControls), flags&NUF_INCOMING ? SW_SHOW : SW_HIDE);
+ ShowMultipleControls(hwndDlg, incomingConnectionsControls, _countof(incomingConnectionsControls), flags&NUF_INCOMING ? SW_SHOW : SW_HIDE);
CheckDlgButton(hwndDlg, IDC_SPECIFYPORTS, settings.specifyIncomingPorts ? BST_CHECKED : BST_UNCHECKED);
SetDlgItemTextA(hwndDlg, IDC_PORTSRANGE, settings.szIncomingPorts ? settings.szIncomingPorts : "");
@@ -341,11 +341,11 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, TCHAR str[80];
{
int selectedProxyType = SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETCURSEL, 0, 0), 0);
- mir_sntprintf(str, SIZEOF(str), TranslateT("(often %d)"), oftenProxyPorts[selectedProxyType]);
+ mir_sntprintf(str, _countof(str), TranslateT("(often %d)"), oftenProxyPorts[selectedProxyType]);
SetDlgItemText(hwndDlg, IDC_STOFTENPORT, str);
if (IsDlgButtonChecked(hwndDlg, IDC_USEPROXY) != BST_UNCHECKED) {
int enableAuth = 0, enableUser = 0, enablePass = 0, enableServer = 1;
- EnableMultipleControls(hwndDlg, useProxyControls, SIZEOF(useProxyControls), TRUE);
+ EnableMultipleControls(hwndDlg, useProxyControls, _countof(useProxyControls), TRUE);
if (selectedProxyType == 0) {
for (int i = 0; i < tempSettings.getCount(); i++) {
NetlibTempSettings *p = tempSettings[i];
@@ -378,9 +378,9 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYHOST), enableServer);
EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYPORT), enableServer);
}
- else EnableMultipleControls(hwndDlg, useProxyControls, SIZEOF(useProxyControls), FALSE);
- EnableMultipleControls(hwndDlg, specifyPortsControls, SIZEOF(specifyPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTS) != BST_UNCHECKED);
- EnableMultipleControls(hwndDlg, specifyOPortsControls, SIZEOF(specifyOPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTSO) != BST_UNCHECKED);
+ else EnableMultipleControls(hwndDlg, useProxyControls, _countof(useProxyControls), FALSE);
+ EnableMultipleControls(hwndDlg, specifyPortsControls, _countof(specifyPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTS) != BST_UNCHECKED);
+ EnableMultipleControls(hwndDlg, specifyOPortsControls, _countof(specifyOPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTSO) != BST_UNCHECKED);
}
break;
diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp index 1471d611b9..eae0b5a5ac 100644 --- a/src/mir_app/src/netlibsecurity.cpp +++ b/src/mir_app/src/netlibsecurity.cpp @@ -66,7 +66,7 @@ static void ReportSecError(SECURITY_STATUS scRet, int line) {
char szMsgBuf[256];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, scRet, LANG_USER_DEFAULT, szMsgBuf, SIZEOF(szMsgBuf), NULL);
+ NULL, scRet, LANG_USER_DEFAULT, szMsgBuf, _countof(szMsgBuf), NULL);
char *p = strchr(szMsgBuf, 13); if (p) *p = 0;
diff --git a/src/mir_app/src/netlibsock.cpp b/src/mir_app/src/netlibsock.cpp index ee1cfde144..88c089d73f 100644 --- a/src/mir_app/src/netlibsock.cpp +++ b/src/mir_app/src/netlibsock.cpp @@ -218,7 +218,7 @@ char* NetlibAddressToString(SOCKADDR_INET_M* addr) if (addr->si_family == AF_INET) {
char *szIp = inet_ntoa(addr->Ipv4.sin_addr);
if (addr->Ipv4.sin_port != 0) {
- mir_snprintf(saddr, SIZEOF(saddr), "%s:%d", szIp, htons(addr->Ipv4.sin_port));
+ mir_snprintf(saddr, _countof(saddr), "%s:%d", szIp, htons(addr->Ipv4.sin_port));
return mir_strdup(saddr);
}
return mir_strdup(szIp);
diff --git a/src/mir_app/src/netlibupnp.cpp b/src/mir_app/src/netlibupnp.cpp index 55fe46152a..63654ea4f5 100644 --- a/src/mir_app/src/netlibupnp.cpp +++ b/src/mir_app/src/netlibupnp.cpp @@ -261,7 +261,7 @@ static int httpTransact(char* szUrl, char* szResult, int resSize, char* szAction char szData1[1024];
szReq = mir_strdup(szResult);
- sz = mir_snprintf(szData1, SIZEOF(szData1),
+ sz = mir_snprintf(szData1, _countof(szData1),
soap_action, szActionName, szDev, szReq, szActionName);
sz = mir_snprintf(szData, 4096,
@@ -274,7 +274,7 @@ static int httpTransact(char* szUrl, char* szResult, int resSize, char* szAction {
char szData1[1024];
- sz = mir_snprintf(szData1, SIZEOF(szData1),
+ sz = mir_snprintf(szData1, _countof(szData1),
soap_query, szActionName);
sz = mir_snprintf(szData, 4096,
@@ -787,7 +787,7 @@ void NetlibUPnPCleanup(void*) if (txtParseParam(szData, "<NewExternalPort", ">", "<", buf, sizeof(buf))) {
WORD mport = (WORD)atol(buf);
- if (j >= SIZEOF(ports))
+ if (j >= _countof(ports))
break;
for (k = 0; k < numports; ++k)
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index e3263906aa..8c6d7de124 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -118,7 +118,7 @@ static const MUUID pluginBannedList[] = static bool isPluginBanned(const MUUID& u1)
{
- for (int i = 0; i < SIZEOF(pluginBannedList); i++)
+ for (int i = 0; i < _countof(pluginBannedList); i++)
if (equalUUID(pluginBannedList[i], u1))
return true;
@@ -148,7 +148,7 @@ static MuuidReplacement pluginDefault[] = int getDefaultPluginIdx(const MUUID &muuid)
{
- for (int i = 0; i < SIZEOF(pluginDefault); i++)
+ for (int i = 0; i < _countof(pluginDefault); i++)
if (equalUUID(muuid, pluginDefault[i].uuid))
return i;
@@ -157,7 +157,7 @@ int getDefaultPluginIdx(const MUUID &muuid) int LoadStdPlugins()
{
- for (int i = 0; i < SIZEOF(pluginDefault); i++) {
+ for (int i = 0; i < _countof(pluginDefault); i++) {
if (pluginDefault[i].pImpl)
continue;
@@ -352,7 +352,7 @@ int Plugin_UnloadDyn(pluginEntry *p) // mark default plugins to be loaded
if (!(p->pclass & PCLASS_CORE))
- for (int i = 0; i < SIZEOF(pluginDefault); i++)
+ for (int i = 0; i < _countof(pluginDefault); i++)
if (pluginDefault[i].pImpl == p)
pluginDefault[i].pImpl = NULL;
@@ -374,12 +374,12 @@ void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam) {
// get miranda's exe path
TCHAR exe[MAX_PATH];
- GetModuleFileName(NULL, exe, SIZEOF(exe));
+ GetModuleFileName(NULL, exe, _countof(exe));
TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0;
// create the search filter
TCHAR search[MAX_PATH];
- mir_sntprintf(search, SIZEOF(search), _T("%s\\Plugins\\*.dll"), exe);
+ mir_sntprintf(search, _countof(search), _T("%s\\Plugins\\*.dll"), exe);
// FFFN will return filenames for things like dot dll+ or dot dllx
WIN32_FIND_DATA ffd;
@@ -403,7 +403,7 @@ pluginEntry* OpenPlugin(TCHAR *tszFileName, TCHAR *dir, TCHAR *path) pluginList.insert(p);
TCHAR tszFullPath[MAX_PATH];
- mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\%s\\%s"), path, dir, tszFileName);
+ mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\%s\\%s"), path, dir, tszFileName);
// map dll into the memory and check its exports
bool bIsPlugin = false;
@@ -485,7 +485,7 @@ int isPluginOnWhiteList(const TCHAR* pluginname) bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
{
TCHAR exe[MAX_PATH], tszFullPath[MAX_PATH];
- GetModuleFileName(NULL, exe, SIZEOF(exe));
+ GetModuleFileName(NULL, exe, _countof(exe));
TCHAR* slice = _tcsrchr(exe, '\\');
if (slice)
*slice = 0;
@@ -496,7 +496,7 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) if (!(p->pclass & PCLASS_BASICAPI)) {
BASIC_PLUGIN_INFO bpi;
- mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\%s\\%s"), exe, (p->pclass & PCLASS_CORE) ? _T("Core") : _T("Plugins"), p->pluginname);
+ mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\%s\\%s"), exe, (p->pclass & PCLASS_CORE) ? _T("Core") : _T("Plugins"), p->pluginname);
if (!checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
p->pclass |= PCLASS_FAILED;
return false;
@@ -552,10 +552,10 @@ static TCHAR tszCoreErr[] = LPGENT("Core plugin '%s' cannot be loaded or missing bool LoadCorePlugin(MuuidReplacement &mr)
{
TCHAR exe[MAX_PATH], tszPlugName[MAX_PATH];
- GetModuleFileName(NULL, exe, SIZEOF(exe));
+ GetModuleFileName(NULL, exe, _countof(exe));
TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0;
- mir_sntprintf(tszPlugName, SIZEOF(tszPlugName), _T("%s.dll"), mr.stdplugname);
+ mir_sntprintf(tszPlugName, _countof(tszPlugName), _T("%s.dll"), mr.stdplugname);
pluginEntry* pPlug = OpenPlugin(tszPlugName, _T("Core"), exe);
if (pPlug->pclass & PCLASS_FAILED) {
LBL_Error:
@@ -613,14 +613,14 @@ static pluginEntry* getCListModule(TCHAR *exe) if (!isPluginOnWhiteList(p->pluginname))
continue;
- mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\Plugins\\%s"), exe, p->pluginname);
+ mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\Plugins\\%s"), exe, p->pluginname);
if (loadClistModule(tszFullPath, p))
return p;
}
MuuidReplacement& stdClist = pluginDefault[11];
if (LoadCorePlugin(stdClist)) {
- mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\Core\\%s.dll"), exe, stdClist.stdplugname);
+ mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\Core\\%s.dll"), exe, stdClist.stdplugname);
if (loadClistModule(tszFullPath, stdClist.pImpl))
return stdClist.pImpl;
}
@@ -758,7 +758,7 @@ int LoadNewPluginsModule(void) {
// make full path to the plugin
TCHAR exe[MAX_PATH], fullPath[MAX_PATH];
- GetModuleFileName(NULL, exe, SIZEOF(exe));
+ GetModuleFileName(NULL, exe, _countof(exe));
TCHAR *slice = _tcsrchr(exe, '\\');
if (slice)
*slice = 0;
@@ -774,7 +774,7 @@ int LoadNewPluginsModule(void) // if freeimage is present, load it to provide the basic core functions
if (plugin_freeimg != NULL) {
BASIC_PLUGIN_INFO bpi;
- mir_sntprintf(fullPath, SIZEOF(fullPath), _T("%s\\Plugins\\%s"), exe, plugin_freeimg->pluginname);
+ mir_sntprintf(fullPath, _countof(fullPath), _T("%s\\Plugins\\%s"), exe, plugin_freeimg->pluginname);
if (checkAPI(fullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
plugin_freeimg->bpi = bpi;
plugin_freeimg->pclass |= PCLASS_OK | PCLASS_BASICAPI;
diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index faf822d515..28ddc75529 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -160,7 +160,7 @@ HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name) TVITEM tvi;
tvi.mask = TVIF_TEXT;
tvi.pszText = str;
- tvi.cchTextMax = SIZEOF(str);
+ tvi.cchTextMax = _countof(str);
tvi.hItem = TreeView_GetRoot(hwndTree);
while (tvi.hItem != NULL) {
SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi);
@@ -178,7 +178,7 @@ static HTREEITEM FindNamedTreeItemAtChildren(HWND hwndTree, HTREEITEM hItem, con TVITEM tvi;
tvi.mask = TVIF_TEXT;
tvi.pszText = str;
- tvi.cchTextMax = SIZEOF(str);
+ tvi.cchTextMax = _countof(str);
tvi.hItem = TreeView_GetChild(hwndTree, hItem);
while (tvi.hItem != NULL) {
SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi);
@@ -193,7 +193,7 @@ static HTREEITEM FindNamedTreeItemAtChildren(HWND hwndTree, HTREEITEM hItem, con static BOOL CALLBACK BoldGroupTitlesEnumChildren(HWND hwnd, LPARAM lParam)
{
TCHAR szClass[64];
- GetClassName(hwnd, szClass, SIZEOF(szClass));
+ GetClassName(hwnd, szClass, _countof(szClass));
if (!mir_tstrcmp(szClass, _T("Button")) && (GetWindowLongPtr(hwnd, GWL_STYLE) & 0x0F) == BS_GROUPBOX)
SendMessage(hwnd, WM_SETFONT, lParam, 0);
@@ -208,7 +208,7 @@ static void SaveOptionsTreeState(HWND hdlg) char buf[130], str[128];
tvi.mask = TVIF_TEXT | TVIF_STATE;
tvi.pszText = str;
- tvi.cchTextMax = SIZEOF(str);
+ tvi.cchTextMax = _countof(str);
tvi.hItem = TreeView_GetRoot(GetDlgItem(hdlg, IDC_PAGETREE));
while (tvi.hItem != NULL) {
if (SendDlgItemMessageA(hdlg, IDC_PAGETREE, TVM_GETITEMA, 0, (LPARAM)&tvi)) {
@@ -233,7 +233,7 @@ static void ThemeDialogBackground(HWND hwnd, BOOL tabbed) static TCHAR* GetPluginName(HINSTANCE hInstance, TCHAR *buffer, int size)
{
TCHAR tszModuleName[MAX_PATH];
- GetModuleFileName(hInstance, tszModuleName, SIZEOF(tszModuleName));
+ GetModuleFileName(hInstance, tszModuleName, _countof(tszModuleName));
TCHAR *dllName = _tcsrchr(tszModuleName, '\\');
if (!dllName)
dllName = tszModuleName;
@@ -272,7 +272,7 @@ static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWnd TCHAR pluginName[MAX_PATH];
char *temp = GetPluginNameByInstance(page->getInst());
- GetDialogStrings(enableKeywordFiltering, key, GetPluginName(page->getInst(), pluginName, SIZEOF(pluginName)), hWnd, page->ptszGroup, page->ptszTitle, page->ptszTab, _A2T(temp));
+ GetDialogStrings(enableKeywordFiltering, key, GetPluginName(page->getInst(), pluginName, _countof(pluginName)), hWnd, page->ptszGroup, page->ptszTitle, page->ptszTab, _A2T(temp));
if (enableKeywordFiltering && !current)
DestroyWindow(hWnd); // destroy the page, we're done with it
@@ -508,7 +508,7 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat) countKnownInst++;
TCHAR tszModuleName[MAX_PATH];
- GetModuleFileName(inst, tszModuleName, SIZEOF(tszModuleName));
+ GetModuleFileName(inst, tszModuleName, _countof(tszModuleName));
TCHAR *dllName = mir_a2t(GetPluginNameByInstance(inst));
if (!dllName) dllName = mir_tstrdup(_tcsrchr(tszModuleName, _T('\\')));
@@ -526,7 +526,7 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat) static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat)
{
LPARAM oldSel = SendDlgItemMessage(hdlg, IDC_KEYWORD_FILTER, CB_GETEDITSEL, 0, 0);
- GetDlgItemText(hdlg, IDC_KEYWORD_FILTER, dat->szFilterString, SIZEOF(dat->szFilterString));
+ GetDlgItemText(hdlg, IDC_KEYWORD_FILTER, dat->szFilterString, _countof(dat->szFilterString));
// if filter string is set to all modules then make the filter string empty (this will return all modules)
BOOL bRemoveFocusFromFilter = FALSE;
@@ -538,7 +538,7 @@ static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat) else if (mir_tstrcmp(dat->szFilterString, TranslateT(CORE_MODULES_FILTER)) == 0) {
// replace string with process name - that will show core settings
TCHAR szFileName[300];
- GetModuleFileName(g_hInst, szFileName, SIZEOF(szFileName));
+ GetModuleFileName(g_hInst, szFileName, _countof(szFileName));
TCHAR *pos = _tcsrchr(szFileName, _T('\\'));
if (pos)
pos++;
@@ -552,7 +552,7 @@ static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat) if (sel != -1) {
HINSTANCE hinst = (HINSTANCE)SendDlgItemMessage(hdlg, IDC_KEYWORD_FILTER, (UINT)CB_GETITEMDATA, sel, 0);
TCHAR szFileName[300];
- GetModuleFileName(hinst, szFileName, SIZEOF(szFileName));
+ GetModuleFileName(hinst, szFileName, _countof(szFileName));
TCHAR *pos = _tcsrchr(szFileName, _T('\\'));
if (pos) pos++;
else pos = szFileName;
@@ -651,7 +651,7 @@ static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat) TVITEMA tvi;
tvi.mask = TVIF_TEXT | TVIF_STATE;
tvi.pszText = str;
- tvi.cchTextMax = SIZEOF(str);
+ tvi.cchTextMax = _countof(str);
tvi.hItem = TreeView_GetRoot(hwndTree);
while (tvi.hItem != NULL) {
if (SendMessageA(hwndTree, TVM_GETITEMA, 0, (LPARAM)&tvi)) {
@@ -1151,7 +1151,7 @@ void OpenAccountOptions(PROTOACCOUNT *pa) return;
TCHAR tszTitle[100];
- mir_sntprintf(tszTitle, SIZEOF(tszTitle), TranslateT("%s options"), pa->tszAccountName);
+ mir_sntprintf(tszTitle, _countof(tszTitle), TranslateT("%s options"), pa->tszAccountName);
OPENOPTIONSDIALOG ood = { sizeof(ood) };
ood.pszGroup = LPGEN("Network");
diff --git a/src/mir_app/src/path.cpp b/src/mir_app/src/path.cpp index 8e6ea249a9..ce9e92e4c8 100644 --- a/src/mir_app/src/path.cpp +++ b/src/mir_app/src/path.cpp @@ -94,7 +94,7 @@ static __forceinline char *GetContactIDX(char *, MCONTACT hContact) static __forceinline char *GetEnvironmentVariableX(char *variable)
{
char result[512];
- if (GetEnvironmentVariableA(variable, result, SIZEOF(result)))
+ if (GetEnvironmentVariableA(variable, result, _countof(result)))
return mir_strdup(result);
return NULL;
}
@@ -124,7 +124,7 @@ static __forceinline char *GetModulePathX(char *, HMODULE hModule) static __forceinline char *GetUserNameX(char *)
{
char result[128];
- DWORD size = SIZEOF(result);
+ DWORD size = _countof(result);
if (GetUserNameA(result, &size))
return mir_strdup(result);
return NULL;
@@ -144,13 +144,13 @@ static __forceinline char *GetPathVarX(char *, int code) if (hAvatarFolder != NULL)
_tcsncpy_s(szFullPath, tszAvatarRoot, _TRUNCATE);
else
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
+ mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
break;
case 2:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName);
+ mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName);
break;
case 3:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s"), g_profileDir, g_shortProfileName);
+ mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s"), g_profileDir, g_shortProfileName);
break;
}
return makeFileName(szFullPath);
@@ -178,7 +178,7 @@ static __forceinline TCHAR *GetContactIDX(TCHAR *, MCONTACT hContact) static __forceinline TCHAR *GetEnvironmentVariableX(TCHAR *variable)
{
TCHAR result[512];
- if (GetEnvironmentVariable(variable, result, SIZEOF(result)))
+ if (GetEnvironmentVariable(variable, result, _countof(result)))
return mir_tstrdup(result);
return NULL;
}
@@ -199,7 +199,7 @@ static __forceinline TCHAR *GetProfileDirX(TCHAR*) static __forceinline TCHAR *GetModulePathX(TCHAR *, HMODULE hModule)
{
TCHAR result[MAX_PATH];
- GetModuleFileName(hModule, result, SIZEOF(result));
+ GetModuleFileName(hModule, result, _countof(result));
TCHAR* str = _tcsrchr(result, '\\');
if (str) *str = 0;
return mir_tstrdup(result);
@@ -208,7 +208,7 @@ static __forceinline TCHAR *GetModulePathX(TCHAR *, HMODULE hModule) static __forceinline TCHAR *GetUserNameX(TCHAR *)
{
TCHAR result[128];
- DWORD size = SIZEOF(result);
+ DWORD size = _countof(result);
if (GetUserName(result, &size))
return mir_tstrdup(result);
return NULL;
@@ -228,13 +228,13 @@ static __forceinline TCHAR *GetPathVarX(TCHAR *, int code) if (hAvatarFolder != NULL)
_tcsncpy_s(szFullPath, tszAvatarRoot, _TRUNCATE);
else
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
+ mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
break;
case 2:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName);
+ mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s\\Logs"), g_profileDir, g_shortProfileName);
break;
case 3:
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\%s"), g_profileDir, g_shortProfileName);
+ mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\%s"), g_profileDir, g_shortProfileName);
break;
}
return mir_tstrdup(szFullPath);
@@ -393,20 +393,20 @@ int InitPathUtils(void) static int OnFoldersChanged(WPARAM, LPARAM)
{
- mir_sntprintf(tszAvatarRoot, SIZEOF(tszAvatarRoot), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
+ mir_sntprintf(tszAvatarRoot, _countof(tszAvatarRoot), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
TCHAR tmpVar[MAX_PATH];
- if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, SIZEOF(tmpVar), tszAvatarRoot))
+ if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, _countof(tmpVar), tszAvatarRoot))
_tcsncpy_s(tszAvatarRoot, tmpVar, _TRUNCATE);
return 0;
}
void InitPathVar()
{
- mir_sntprintf(tszAvatarRoot, SIZEOF(tszAvatarRoot), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
+ mir_sntprintf(tszAvatarRoot, _countof(tszAvatarRoot), _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName);
if (hAvatarFolder = FoldersRegisterCustomPathT( LPGEN("Avatars"), LPGEN("Avatars root folder"), tszAvatarRoot)) {
TCHAR tmpVar[MAX_PATH];
- if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, SIZEOF(tmpVar), tszAvatarRoot))
+ if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, _countof(tmpVar), tszAvatarRoot))
_tcsncpy_s(tszAvatarRoot, tmpVar, _TRUNCATE);
HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged);
}
diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp index 9f62b32c6e..278050a96d 100644 --- a/src/mir_app/src/pluginopts.cpp +++ b/src/mir_app/src/pluginopts.cpp @@ -184,7 +184,7 @@ static void RemoveAllItems(HWND hwnd) static bool LoadPluginDynamically(PluginListItemData *dat)
{
TCHAR exe[MAX_PATH];
- GetModuleFileName(NULL, exe, SIZEOF(exe));
+ GetModuleFileName(NULL, exe, _countof(exe));
TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0;
pluginEntry* pPlug = OpenPlugin(dat->fileName, _T("Plugins"), exe);
@@ -424,7 +424,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar PluginListItemData *dat = (PluginListItemData*)lvi.lParam;
TCHAR buf[1024];
- ListView_GetItemText(hwndList, hdr->iItem, 2, buf, SIZEOF(buf));
+ ListView_GetItemText(hwndList, hdr->iItem, 2, buf, _countof(buf));
SetDlgItemText(hwndDlg, IDC_PLUGININFOFRAME, sel ? buf : _T(""));
ptrT tszAuthor(latin2t(sel ? dat->author : NULL));
@@ -456,12 +456,12 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar if (hdr->hdr.code == PSN_APPLY) {
bool needRestart = false;
TCHAR bufRestart[1024];
- int bufLen = mir_sntprintf(bufRestart, SIZEOF(bufRestart), _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:"));
+ int bufLen = mir_sntprintf(bufRestart, _countof(bufRestart), _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:"));
HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
for (int iRow = 0; iRow != -1;) {
TCHAR buf[1024];
- ListView_GetItemText(hwndList, iRow, 1, buf, SIZEOF(buf));
+ ListView_GetItemText(hwndList, iRow, 1, buf, _countof(buf));
int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK);
SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0);
@@ -483,7 +483,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar ListView_SetItem(hwndList, &lvi);
}
else {
- bufLen += mir_sntprintf(bufRestart + bufLen, SIZEOF(bufRestart) - bufLen, _T(" - %s\n"), buf);
+ bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf);
needRestart = true;
}
}
@@ -496,7 +496,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar ListView_SetItem(hwndList, &lvi);
}
else {
- bufLen += mir_sntprintf(bufRestart + bufLen, SIZEOF(bufRestart) - bufLen, _T(" - %s\n"), buf);
+ bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf);
needRestart = true;
}
}
@@ -510,7 +510,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), needRestart);
if (needRestart) {
- mir_sntprintf(bufRestart + bufLen, SIZEOF(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?"));
+ mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?"));
if (MessageBox(NULL, bufRestart, _T("Miranda NG"), MB_ICONWARNING | MB_YESNO) == IDYES)
CallService(MS_SYSTEM_RESTART, 1, 0);
}
@@ -530,7 +530,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar char buf[512];
char *p = &buf[7];
mir_strcpy(buf, "mailto:");
- if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, SIZEOF(buf) - 7))
+ if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, _countof(buf) - 7))
CallService(MS_UTILS_OPENURL, 0, (LPARAM)(LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p));
break;
}
diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp index e2ffc37f79..bda73395a4 100644 --- a/src/mir_app/src/profilemanager.cpp +++ b/src/mir_app/src/profilemanager.cpp @@ -46,7 +46,7 @@ static int findProfiles(TCHAR *szProfileDir, ENUMPROFILECALLBACK callback, LPARA { // find in Miranda NG profile subfolders TCHAR searchspec[MAX_PATH]; - mir_sntprintf(searchspec, SIZEOF(searchspec), _T("%s\\*.*"), szProfileDir); + mir_sntprintf(searchspec, _countof(searchspec), _T("%s\\*.*"), szProfileDir); WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(searchspec, &ffd); @@ -59,7 +59,7 @@ static int findProfiles(TCHAR *szProfileDir, ENUMPROFILECALLBACK callback, LPARA TCHAR buf[MAX_PATH], profile[MAX_PATH]; mir_sntprintf(buf, _T("%s\\%s\\%s.dat"), szProfileDir, ffd.cFileName, ffd.cFileName); if (_taccess(buf, 0) == 0) { - mir_sntprintf(profile, SIZEOF(profile), _T("%s.dat"), ffd.cFileName); + mir_sntprintf(profile, _countof(profile), _T("%s.dat"), ffd.cFileName); if (!callback(buf, profile, lParam)) break; } @@ -264,11 +264,11 @@ class CChooseProfileDlg : public CDlgBase struct _stat statbuf; if (_tstat(tszFullPath, &statbuf) == 0) { if (statbuf.st_size > 1000000) { - mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0); + mir_sntprintf(sizeBuf, _countof(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0); mir_tstrcpy(sizeBuf + 5, _T(" MB")); } else { - mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0); + mir_sntprintf(sizeBuf, _countof(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0); mir_tstrcpy(sizeBuf + 5, _T(" KB")); } bFileLocked = !fileExist(tszFullPath); @@ -315,11 +315,11 @@ class CChooseProfileDlg : public CDlgBase item.mask = LVIF_TEXT | LVIF_IMAGE; item.iItem = iItem; item.pszText = profile; - item.cchTextMax = SIZEOF(profile); + item.cchTextMax = _countof(profile); if (!m_profileList.GetItem(&item)) return; - mir_sntprintf(fullName, SIZEOF(fullName), _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profile, profile); + mir_sntprintf(fullName, _countof(fullName), _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profile, profile); CallService(MS_DB_CHECKPROFILE, (WPARAM)fullName, item.iImage == 2); } @@ -334,15 +334,15 @@ class CChooseProfileDlg : public CDlgBase item.mask = LVIF_TEXT; item.iItem = iItem; item.pszText = profile; - item.cchTextMax = SIZEOF(profile); + item.cchTextMax = _countof(profile); if (!m_profileList.GetItem(&item)) return; - mir_sntprintf(profilef, SIZEOF(profilef), TranslateT("Are you sure you want to remove profile \"%s\"?"), profile); + mir_sntprintf(profilef, _countof(profilef), TranslateT("Are you sure you want to remove profile \"%s\"?"), profile); if (IDYES != MessageBox(NULL, profilef, _T("Miranda NG"), MB_YESNO | MB_TASKMODAL | MB_ICONWARNING)) return; - mir_sntprintf(profilef, SIZEOF(profilef), _T("%s\\%s%c"), m_pd->ptszProfileDir, profile, 0); + mir_sntprintf(profilef, _countof(profilef), _T("%s\\%s%c"), m_pd->ptszProfileDir, profile, 0); SHFILEOPSTRUCT sf = { 0 }; sf.wFunc = FO_DELETE; @@ -361,7 +361,7 @@ class CChooseProfileDlg : public CDlgBase item.mask = LVIF_TEXT | LVIF_IMAGE; item.iItem = m_profileList.GetNextItem(-1, LVNI_SELECTED | LVNI_ALL); item.pszText = profile; - item.cchTextMax = SIZEOF(profile); + item.cchTextMax = _countof(profile); if (!m_profileList.GetItem(&item)) return; @@ -383,7 +383,7 @@ class CChooseProfileDlg : public CDlgBase // profile is placed in "profile_name" subfolder TCHAR tmpPath[MAX_PATH]; - mir_sntprintf(tmpPath, SIZEOF(tmpPath), _T("%s\\%s.dat"), m_pd->ptszProfileDir, profile); + mir_sntprintf(tmpPath, _countof(tmpPath), _T("%s\\%s.dat"), m_pd->ptszProfileDir, profile); if (_taccess(tmpPath, 2)) mir_sntprintf(m_pd->ptszProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profile, profile); else @@ -519,8 +519,8 @@ public: if (auto pTip = evt->nmlvit) { TCHAR profilename[MAX_PATH], tszFullPath[MAX_PATH]; struct _stat statbuf; - m_profileList.GetItemText(pTip->iItem, 0, profilename, SIZEOF(profilename)); - mir_sntprintf(tszFullPath, SIZEOF(tszFullPath), _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profilename, profilename); + m_profileList.GetItemText(pTip->iItem, 0, profilename, _countof(profilename)); + mir_sntprintf(tszFullPath, _countof(tszFullPath), _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, profilename, profilename); _tstat(tszFullPath, &statbuf); mir_sntprintf(pTip->pszText, pTip->cchTextMax, _T("%s\n%s: %s\n%s: %s"), tszFullPath, TranslateT("Created"), rtrimt(NEWTSTR_ALLOCA(_tctime(&statbuf.st_ctime))), TranslateT("Modified"), rtrimt(NEWTSTR_ALLOCA(_tctime(&statbuf.st_mtime)))); } diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 6aa601dfbf..86fbbf713f 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -428,7 +428,7 @@ void UnloadAccountsModule() }
accounts.destroy();
- for (int i = 0; i < SIZEOF(hHooks); i++)
+ for (int i = 0; i < _countof(hHooks); i++)
UnhookEvent(hHooks[i]);
}
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index c34ffdc6d0..ce4c986679 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -124,7 +124,7 @@ static bool OnCreateAccount(HWND hwndDlg) PROTOACCOUNT *pa = param->pa;
TCHAR tszAccName[256];
- GetDlgItemText(hwndDlg, IDC_ACCNAME, tszAccName, SIZEOF(tszAccName));
+ GetDlgItemText(hwndDlg, IDC_ACCNAME, tszAccName, _countof(tszAccName));
rtrimt(tszAccName);
if (tszAccName[0] == 0) {
MessageBox(hwndDlg, TranslateT("Account name must be filled."), TranslateT("Account error"), MB_ICONERROR | MB_OK);
@@ -133,7 +133,7 @@ static bool OnCreateAccount(HWND hwndDlg) if (param->action == PRAC_ADDED) {
char buf[200];
- GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF(buf));
+ GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, _countof(buf));
if (FindAccountByName(rtrim(buf))) {
MessageBox(hwndDlg, TranslateT("Account name has to be unique. Please enter unique name."), TranslateT("Account error"), MB_ICONERROR | MB_OK);
return false;
@@ -143,13 +143,13 @@ static bool OnCreateAccount(HWND hwndDlg) if (param->action == PRAC_UPGRADED) {
BOOL oldProto = pa->bOldProto;
TCHAR szPlugin[MAX_PATH];
- mir_sntprintf(szPlugin, SIZEOF(szPlugin), _T("%s.dll"), _A2T(pa->szProtoName));
+ mir_sntprintf(szPlugin, _countof(szPlugin), _T("%s.dll"), _A2T(pa->szProtoName));
int idx = accounts.getIndex(pa);
UnloadAccount(pa, false, false);
accounts.remove(idx);
- if (oldProto && UnloadPlugin(szPlugin, SIZEOF(szPlugin))) {
+ if (oldProto && UnloadPlugin(szPlugin, _countof(szPlugin))) {
TCHAR szNewName[MAX_PATH];
- mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s~"), szPlugin);
+ mir_sntprintf(szNewName, _countof(szNewName), _T("%s~"), szPlugin);
MoveFile(szPlugin, szNewName);
}
param->action = PRAC_ADDED;
@@ -157,10 +157,10 @@ static bool OnCreateAccount(HWND hwndDlg) if (param->action == PRAC_ADDED) {
char buf[200];
- GetDlgItemTextA(hwndDlg, IDC_PROTOTYPECOMBO, buf, SIZEOF(buf));
+ GetDlgItemTextA(hwndDlg, IDC_PROTOTYPECOMBO, buf, _countof(buf));
char *szBaseProto = NEWSTR_ALLOCA(buf);
- GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF(buf));
+ GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, _countof(buf));
rtrim(buf);
pa = Proto_CreateAccount(buf, szBaseProto, tszAccName);
@@ -202,9 +202,9 @@ static INT_PTR CALLBACK AccFormDlgProc(HWND hwndDlg, UINT message, WPARAM wParam TCHAR str[200];
if (param->action == PRAC_CHANGED) { // update
EnableWindow(GetDlgItem(hwndDlg, IDC_PROTOTYPECOMBO), FALSE);
- mir_sntprintf(str, SIZEOF(str), _T("%s: %s"), TranslateT("Editing account"), param->pa->tszAccountName);
+ mir_sntprintf(str, _countof(str), _T("%s: %s"), TranslateT("Editing account"), param->pa->tszAccountName);
}
- else mir_sntprintf(str, SIZEOF(str), _T("%s: %s"), TranslateT("Upgrading account"), param->pa->tszAccountName);
+ else mir_sntprintf(str, _countof(str), _T("%s: %s"), TranslateT("Upgrading account"), param->pa->tszAccountName);
SetWindowText(hwndDlg, str);
SetDlgItemText(hwndDlg, IDC_ACCNAME, param->pa->tszAccountName);
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index 0c2f053f8e..d00fbd27a8 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -64,7 +64,7 @@ MIR_APP_DLL(void) ProtoLogA(struct PROTO_INTERFACE *pThis, LPCSTR szFormat, va_l MIR_APP_DLL(void) ProtoLogW(struct PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args)
{
WCHAR buf[4096];
- int res = _vsnwprintf(buf, SIZEOF(buf), wszFormat, args);
+ int res = _vsnwprintf(buf, _countof(buf), wszFormat, args);
CallService(MS_NETLIB_LOGW, (WPARAM)(pThis ? pThis->m_hNetlibUser : NULL), (LPARAM)((res != -1) ? buf : CMStringW().FormatV(wszFormat, args)));
}
@@ -244,10 +244,10 @@ MIR_APP_DLL(int) ProtoGetAvatarFileFormat(const TCHAR *ptszFileName) DWORD dwBytes;
char buf[32];
- BOOL res = ReadFile(hFile, buf, SIZEOF(buf), &dwBytes, NULL);
+ BOOL res = ReadFile(hFile, buf, _countof(buf), &dwBytes, NULL);
CloseHandle(hFile);
- return (res && dwBytes == SIZEOF(buf)) ? ProtoGetBufferFormat(buf) : PA_FORMAT_UNKNOWN;
+ return (res && dwBytes == _countof(buf)) ? ProtoGetBufferFormat(buf) : PA_FORMAT_UNKNOWN;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/searchresults.cpp b/src/mir_app/src/searchresults.cpp index 8a8ae3ea8f..b75ca7746d 100644 --- a/src/mir_app/src/searchresults.cpp +++ b/src/mir_app/src/searchresults.cpp @@ -150,8 +150,8 @@ int CALLBACK SearchResultsCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPa else {
TCHAR szText1[100];
TCHAR szText2[100];
- ListView_GetItemText(hList, (int)lParam1, sortCol, szText1, SIZEOF(szText1));
- ListView_GetItemText(hList, (int)lParam2, sortCol, szText2, SIZEOF(szText2));
+ ListView_GetItemText(hList, (int)lParam1, sortCol, szText1, _countof(szText1));
+ ListView_GetItemText(hList, (int)lParam2, sortCol, szText2, _countof(szText2));
return mir_tstrcmpi(szText1, szText2)*sortMultiplier;
}
return 0;
@@ -187,7 +187,7 @@ static void BeginSearchFailed(void * arg) protoName, protoName);
mir_free((char*)arg);
}
- else mir_tstrncpy(buf, TranslateT("Could not search on any of the protocols, are you online?"), SIZEOF(buf));
+ else mir_tstrncpy(buf, TranslateT("Could not search on any of the protocols, are you online?"), _countof(buf));
MessageBox(0, buf, TranslateT("Problem with search"), MB_OK | MB_ICONERROR);
}
diff --git a/src/mir_app/src/services.cpp b/src/mir_app/src/services.cpp index 85f6837853..3d1fdaf5c2 100644 --- a/src/mir_app/src/services.cpp +++ b/src/mir_app/src/services.cpp @@ -261,7 +261,7 @@ static int sttRegisterFontWorker(FontIDW *font_id, int hLangpack) if (!mir_tstrcmp(newItem->deffontsettings.szFace, _T("MS Shell Dlg"))) {
LOGFONT lf;
SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE);
- mir_tstrncpy(newItem->deffontsettings.szFace, lf.lfFaceName, SIZEOF(newItem->deffontsettings.szFace));
+ mir_tstrncpy(newItem->deffontsettings.szFace, lf.lfFaceName, _countof(newItem->deffontsettings.szFace));
if (!newItem->deffontsettings.size)
newItem->deffontsettings.size = lf.lfHeight;
}
@@ -292,7 +292,7 @@ static INT_PTR sttGetFontWorker(FontIDW *font_id, LOGFONT *lf) for (int i = 0; i < font_id_list.getCount(); i++) {
FontInternal& F = font_id_list[i];
- if (!_tcsncmp(F.name, font_id->name, SIZEOF(F.name)) && !_tcsncmp(F.group, font_id->group, SIZEOF(F.group))) {
+ if (!_tcsncmp(F.name, font_id->name, _countof(F.name)) && !_tcsncmp(F.group, font_id->group, _countof(F.group))) {
if (GetFontSettingFromDB(F.dbSettingsGroup, F.prefix, lf, &colour, F.flags) && (F.flags & FIDF_DEFAULTVALID)) {
CreateFromFontSettings(&F.deffontsettings, lf);
colour = F.deffontsettings.colour;
@@ -465,7 +465,7 @@ static INT_PTR sttGetEffectWorker(EffectIDW *effect_id, FONTEFFECT *effect) {
for (int i = 0; i < effect_id_list.getCount(); i++) {
EffectInternal& E = effect_id_list[i];
- if (!_tcsncmp(E.name, effect_id->name, SIZEOF(E.name)) && !_tcsncmp(E.group, effect_id->group, SIZEOF(E.group))) {
+ if (!_tcsncmp(E.name, effect_id->name, _countof(E.name)) && !_tcsncmp(E.group, effect_id->group, _countof(E.group))) {
FONTEFFECT temp;
UpdateEffectSettings(effect_id, &temp);
diff --git a/src/mir_app/src/skin2opts.cpp b/src/mir_app/src/skin2opts.cpp index 4c9e7ede0e..b33c2fc876 100644 --- a/src/mir_app/src/skin2opts.cpp +++ b/src/mir_app/src/skin2opts.cpp @@ -49,7 +49,7 @@ static HICON ExtractIconFromPath(const TCHAR *path, int cxIcon, int cyIcon) if (!path)
return (HICON)NULL;
- mir_tstrncpy(file, path, SIZEOF(file));
+ mir_tstrncpy(file, path, _countof(file));
comma = _tcsrchr(file, ',');
if (!comma)
n = 0;
@@ -118,7 +118,7 @@ static void __fastcall MySetCursor(TCHAR* nCursor) static void LoadSectionIcons(TCHAR *filename, SectionItem* sectionActive)
{
TCHAR path[MAX_PATH];
- mir_sntprintf(path, SIZEOF(path), _T("%s,"), filename);
+ mir_sntprintf(path, _countof(path), _T("%s,"), filename);
size_t suffIndx = mir_tstrlen(path);
mir_cslock lck(csIconList);
@@ -250,7 +250,7 @@ static TCHAR* OpenFileDlg(HWND hParent, const TCHAR* szFile, BOOL bAll) ofn.lpstrFilter = filter;
ofn.lpstrDefExt = _T("dll");
- mir_tstrncpy(file, szFile, SIZEOF(file));
+ mir_tstrncpy(file, szFile, _countof(file));
ofn.lpstrFile = file;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
ofn.nMaxFile = MAX_PATH * 2;
@@ -317,7 +317,7 @@ static HTREEITEM FindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TCHAR tvi.mask = TVIF_TEXT;
tvi.pszText = str;
- tvi.cchTextMax = SIZEOF(str);
+ tvi.cchTextMax = _countof(str);
while (tvi.hItem) {
TreeView_GetItem(hwndTree, &tvi);
@@ -398,7 +398,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ImageList_RemoveAll(hIml);
TCHAR filename[MAX_PATH], caption[64];
- GetDlgItemText(hwndDlg, IDC_ICONSET, filename, SIZEOF(filename));
+ GetDlgItemText(hwndDlg, IDC_ICONSET, filename, _countof(filename));
{
RECT rcPreview, rcGroup;
@@ -418,7 +418,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lvi.iItem = 0;
int count = (int)_ExtractIconEx(filename, -1, 16, 16, NULL, LR_DEFAULTCOLOR);
for (int i = 0; i < count; lvi.iItem++, i++) {
- mir_sntprintf(caption, SIZEOF(caption), _T("%d"), i + 1);
+ mir_sntprintf(caption, _countof(caption), _T("%d"), i + 1);
lvi.pszText = caption;
HICON hIcon = NULL;
@@ -438,7 +438,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case IDC_BROWSE:
{
TCHAR str[MAX_PATH], *file;
- GetDlgItemText(hwndDlg, IDC_ICONSET, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_ICONSET, str, _countof(str));
if (!(file = OpenFileDlg(GetParent(hwndDlg), str, TRUE)))
break;
SetDlgItemText(hwndDlg, IDC_ICONSET, file);
@@ -515,12 +515,12 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR path[MAX_PATH], fullPath[MAX_PATH], filename[MAX_PATH];
LVITEM lvi;
- GetDlgItemText(hwndDlg, IDC_ICONSET, fullPath, SIZEOF(fullPath));
+ GetDlgItemText(hwndDlg, IDC_ICONSET, fullPath, _countof(fullPath));
PathToRelativeT(fullPath, filename);
lvi.mask = LVIF_PARAM;
lvi.iItem = dragItem; lvi.iSubItem = 0;
ListView_GetItem(hPreview, &lvi);
- mir_sntprintf(path, SIZEOF(path), _T("%s,%d"), filename, (int)lvi.lParam);
+ mir_sntprintf(path, _countof(path), _T("%s,%d"), filename, (int)lvi.lParam);
SendMessage(hwndParent, DM_CHANGEICON, dropHiLite, (LPARAM)path);
ListView_SetItemState(GetDlgItem(hwndParent, IDC_PREVIEW), dropHiLite, 0, LVIS_DROPHILITED);
}
diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp index 410b30a1d9..ccf499ef6b 100644 --- a/src/mir_app/src/skinicons.cpp +++ b/src/mir_app/src/skinicons.cpp @@ -229,12 +229,12 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) caps2 = 0;
if (IsStatusConnecting(status)) {
- mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, 7);
+ mir_snprintf(iconName, _countof(iconName), "%s%d", mainIconsFmt, 7);
return IcoLib_GetIcon(iconName, big);
}
int statusIndx = -1;
- for (int i = 0; i < SIZEOF(statusIcons); i++)
+ for (int i = 0; i < _countof(statusIcons); i++)
if (statusIcons[i].id == status) {
statusIndx = i;
break;
@@ -248,7 +248,7 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) // Otherwise return the global icon. This affects the global status menu mainly.
if (accounts.getCount() == 1) {
// format: core_status_%proto%statusindex
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
+ mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
HICON hIcon = IcoLib_GetIcon(iconName, big);
if (hIcon)
@@ -256,24 +256,24 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) }
// format: core_status_%s%d
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx);
+ mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx);
return IcoLib_GetIcon(iconName, big);
}
// format: core_status_%s%d
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
+ mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
HICON hIcon = IcoLib_GetIcon(iconName, big);
if (hIcon == NULL && (caps2 == 0 || (caps2 & statusIcons[statusIndx].pf2))) {
PROTOACCOUNT *pa = Proto_GetAccount(szProto);
if (pa) {
TCHAR szPath[MAX_PATH], szFullPath[MAX_PATH], *str;
- GetModuleFileName(NULL, szPath, SIZEOF(szPath));
+ GetModuleFileName(NULL, szPath, _countof(szPath));
//
// Queried protocol isn't in list, adding
//
TCHAR tszSection[MAX_PATH];
- mir_sntprintf(tszSection, SIZEOF(tszSection), _T(PROTOCOLS_PREFIX)_T("/%s"), pa->tszAccountName);
+ mir_sntprintf(tszSection, _countof(tszSection), _T(PROTOCOLS_PREFIX)_T("/%s"), pa->tszAccountName);
SKINICONDESC sid = { 0 };
sid.section.t = tszSection;
@@ -282,11 +282,11 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) str = _tcsrchr(szPath, '\\');
if (str != NULL)
*str = 0;
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Icons\\proto_%S.dll"), szPath, pa->szProtoName);
+ mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\Icons\\proto_%S.dll"), szPath, pa->szProtoName);
if (GetFileAttributes(szFullPath) != INVALID_FILE_ATTRIBUTES)
sid.defaultFile.t = szFullPath;
else {
- mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Plugins\\%S.dll"), szPath, szProto);
+ mir_sntprintf(szFullPath, _countof(szFullPath), _T("%s\\Plugins\\%S.dll"), szPath, szProto);
if (int(ExtractIconEx(szFullPath, statusIcons[statusIndx].resource_id, NULL, &hIcon, 1)) > 0) {
DestroyIcon(hIcon);
sid.defaultFile.t = szFullPath;
@@ -308,12 +308,12 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) if (caps2 == 0)
lowidx = statusIndx, highidx = statusIndx + 1;
else
- lowidx = 0, highidx = SIZEOF(statusIcons);
+ lowidx = 0, highidx = _countof(statusIcons);
for (int i = lowidx; i < highidx; i++)
if (caps2 == 0 || (caps2 & statusIcons[i].pf2)) {
// format: core_%s%d
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, i);
+ mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, szProto, i);
sid.pszName = iconName;
sid.description.t = cli.pfnGetStatusModeDescription(statusIcons[i].id, 0);
sid.iDefaultIndex = statusIcons[i].resource_id;
@@ -322,14 +322,14 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) }
// format: core_status_%s%d
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
+ mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, szProto, statusIndx);
hIcon = IcoLib_GetIcon(iconName, big);
if (hIcon)
return hIcon;
}
if (hIcon == NULL) {
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx);
+ mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx);
hIcon = IcoLib_GetIcon(iconName, big);
}
@@ -338,7 +338,7 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big) MIR_APP_DLL(HANDLE) Skin_GetIconHandle(int idx)
{
- for (int i = 0; i < SIZEOF(mainIcons); i++)
+ for (int i = 0; i < _countof(mainIcons); i++)
if (idx == mainIcons[i].id)
return mainIcons[i].hIcolib;
@@ -349,9 +349,9 @@ MIR_APP_DLL(char*) Skin_GetIconName(int idx) {
static char szIconName[100];
- for (int i = 0; i < SIZEOF(mainIcons); i++) {
+ for (int i = 0; i < _countof(mainIcons); i++) {
if (idx == mainIcons[i].id) {
- mir_snprintf(szIconName, SIZEOF(szIconName), "%s%d", mainIconsFmt, i);
+ mir_snprintf(szIconName, _countof(szIconName), "%s%d", mainIconsFmt, i);
return szIconName;
}
}
@@ -362,7 +362,7 @@ MIR_APP_DLL(HICON) Skin_LoadIcon(int idx, bool big) {
// Query for global status icons
if (idx < SKINICON_EVENT_MESSAGE) {
- if (idx >= SIZEOF(statusIcons))
+ if (idx >= _countof(statusIcons))
return NULL;
return Skin_LoadProtoIcon(NULL, statusIcons[idx].id, big);
@@ -377,7 +377,7 @@ MIR_APP_DLL(HICON) Skin_LoadIcon(int idx, bool big) int LoadSkinIcons(void)
{
TCHAR modulePath[MAX_PATH];
- GetModuleFileName(g_hInst, modulePath, SIZEOF(modulePath));
+ GetModuleFileName(g_hInst, modulePath, _countof(modulePath));
char iconName[MAX_PATH];
SKINICONDESC sid = { 0 };
@@ -386,8 +386,8 @@ int LoadSkinIcons(void) sid.pszName = iconName;
// Add main icons to list
- for (int i = 0; i < SIZEOF(mainIcons); i++) {
- mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, i);
+ for (int i = 0; i < _countof(mainIcons); i++) {
+ mir_snprintf(iconName, _countof(iconName), "%s%d", mainIconsFmt, i);
sid.section.a = mainIcons[i].section == NULL ? LPGEN("Main icons") : (char*)mainIcons[i].section;
sid.description.a = (char*)mainIcons[i].description;
sid.iDefaultIndex = mainIcons[i].resource_id;
@@ -399,8 +399,8 @@ int LoadSkinIcons(void) // Asterisk is used, to avoid conflict with proto-plugins
// 'coz users can't rename it to name with '*'
- for (int i = 0; i < SIZEOF(statusIcons); i++) {
- mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, i);
+ for (int i = 0; i < _countof(statusIcons); i++) {
+ mir_snprintf(iconName, _countof(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, i);
sid.pszName = iconName;
sid.description.a = (char*)statusIcons[i].description;
sid.iDefaultIndex = statusIcons[i].resource_id;
diff --git a/src/mir_app/src/sounds.cpp b/src/mir_app/src/sounds.cpp index 712a39441f..0fb366e812 100644 --- a/src/mir_app/src/sounds.cpp +++ b/src/mir_app/src/sounds.cpp @@ -307,9 +307,9 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
if (GetModuleHandle(_T("bass_interface.dll")))
- mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%s (*)%c*%c"), TranslateT("Sound files"), 0, 0, TranslateT("All files"), 0, 0);
+ mir_sntprintf(filter, _countof(filter), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%s (*)%c*%c"), TranslateT("Sound files"), 0, 0, TranslateT("All files"), 0, 0);
else
- mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav)%c*.wav%c%s (*)%c*%c"), TranslateT("WAV files"), 0, 0, TranslateT("All files"), 0, 0);
+ mir_sntprintf(filter, _countof(filter), _T("%s (*.wav)%c*.wav%c%s (*)%c*%c"), TranslateT("WAV files"), 0, 0, TranslateT("All files"), 0, 0);
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = GetParent(hwndDlg);
ofn.hInstance = NULL;
@@ -324,7 +324,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM str[0] = 0;
ofn.lpstrFile = str;
ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER|OFN_LONGNAMES|OFN_NOCHANGEDIR;
- ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFile = _countof(str);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = _T("wav");
if (!GetOpenFileName(&ofn))
diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp index cba82ce12d..c78dcf7af0 100644 --- a/src/mir_app/src/utils.cpp +++ b/src/mir_app/src/utils.cpp @@ -298,7 +298,7 @@ static CountryListEntry countries[] = { static INT_PTR GetCountryByNumber(WPARAM wParam, LPARAM)
{
- for (int i = 0; i < SIZEOF(countries); i++)
+ for (int i = 0; i < _countof(countries); i++)
if ((int)wParam == countries[i].id)
return (INT_PTR)countries[i].szName;
@@ -307,7 +307,7 @@ static INT_PTR GetCountryByNumber(WPARAM wParam, LPARAM) static INT_PTR GetCountryByISOCode(WPARAM wParam, LPARAM)
{
- for (int i = 0; i < SIZEOF(countries); i++)
+ for (int i = 0; i < _countof(countries); i++)
if ( mir_strcmpi((char*)wParam, countries[i].ISOcode) == 0)
return (INT_PTR)countries[i].szName;
@@ -316,7 +316,7 @@ static INT_PTR GetCountryByISOCode(WPARAM wParam, LPARAM) static INT_PTR GetCountryList(WPARAM wParam, LPARAM lParam)
{
- *(int*)wParam = SIZEOF(countries);
+ *(int*)wParam = _countof(countries);
*(CountryListEntry**)lParam = countries;
return 0;
}
@@ -329,12 +329,12 @@ static INT_PTR RestartMiranda(WPARAM wParam, LPARAM) PROCESS_INFORMATION pi;
STARTUPINFO si = {0};
si.cb = sizeof(si);
- GetModuleFileName(NULL, mirandaPath, SIZEOF(mirandaPath));
+ GetModuleFileName(NULL, mirandaPath, _countof(mirandaPath));
if (wParam) {
VARST profilename( _T("%miranda_profilename%"));
- mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), (TCHAR*)profilename);
+ mir_sntprintf(cmdLine, _countof(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), (TCHAR*)profilename);
}
- else mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d"), mirandaPath, GetCurrentProcessId());
+ else mir_sntprintf(cmdLine, _countof(cmdLine), _T("\"%s\" /restart:%d"), mirandaPath, GetCurrentProcessId());
CallService("CloseAction", 0, 0);
CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
diff --git a/src/mir_app/src/visibility.cpp b/src/mir_app/src/visibility.cpp index 447bac6beb..212434ec7d 100644 --- a/src/mir_app/src/visibility.cpp +++ b/src/mir_app/src/visibility.cpp @@ -40,7 +40,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt while (hItem) {
HANDLE hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem, childCount);
- for (int i=0; i < SIZEOF(iconOn); i++)
+ for (int i=0; i < _countof(iconOn); i++)
if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i] = 0;
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
@@ -50,7 +50,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while (hItem) {
- for (int i=0; i < SIZEOF(iconOn); i++) {
+ for (int i=0; i < _countof(iconOn); i++) {
int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i);
if (iconOn[i] && iImage == 0) iconOn[i] = 0;
if (iImage != EMPTY_EXTRA_ICON)
@@ -59,7 +59,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- for (int i=0; i < SIZEOF(iconOn); i++) {
+ for (int i=0; i < _countof(iconOn); i++) {
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+1:0):EMPTY_EXTRA_ICON));
if (groupChildCount) groupChildCount[i]+=childCount[i];
}
diff --git a/src/mir_app/src/xmlParser.cpp b/src/mir_app/src/xmlParser.cpp index be360ea40f..8911efec03 100644 --- a/src/mir_app/src/xmlParser.cpp +++ b/src/mir_app/src/xmlParser.cpp @@ -402,7 +402,7 @@ XMLNode XMLNode::openFileHelper(XMLCSTR filename, XMLCSTR tag) // create message char message[2000], *s1 = (char*)"", *s3 = (char*)""; XMLCSTR s2 = _CXML(""); if (pResults.error == eXMLErrorFirstTagNotFound) { s1 = (char*)"First Tag should be '"; s2 = tag; s3 = (char*)"'.\n"; } - mir_snprintf(message, SIZEOF(message), + mir_snprintf(message, _countof(message), #ifdef _XMLWIDECHAR "XML Parsing error inside file '%S'.\n%S\nAt line %i, column %i.\n%s%S%s" #else |