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 /plugins/Clist_nicer/src/extBackg.cpp | |
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 'plugins/Clist_nicer/src/extBackg.cpp')
-rw-r--r-- | plugins/Clist_nicer/src/extBackg.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index 4349b1130d..937a550431 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -260,7 +260,7 @@ StatusItems_t *GetProtocolStatusItem(const char *szProto) if (szProto == NULL)
return NULL;
- for (int i = SIZEOF(_StatusItems); i < arStatusItems.getCount(); i++) {
+ for (int i = _countof(_StatusItems); i < arStatusItems.getCount(); i++) {
StatusItems_t *p = arStatusItems[i];
if (!mir_strcmp(p->szName[0] == '{' ? p->szName+3 : p->szName, szProto))
return p;
@@ -272,7 +272,7 @@ StatusItems_t *GetProtocolStatusItem(const char *szProto) void LoadExtBkSettingsFromDB()
{
int i, n;
- for (i = 0; i < SIZEOF(_StatusItems); i++) {
+ for (i = 0; i < _countof(_StatusItems); i++) {
StatusItems_t *p = (StatusItems_t*)mir_alloc(sizeof(StatusItems_t));
*p = _StatusItems[i];
arStatusItems.insert(p);
@@ -287,9 +287,9 @@ void LoadExtBkSettingsFromDB() *p = _StatusItems[0];
ID_EXTBK_LAST++;
- mir_snprintf(p->szDBname, SIZEOF(p->szDBname), "EXBK_%s", accs[i]->szModuleName);
+ mir_snprintf(p->szDBname, _countof(p->szDBname), "EXBK_%s", accs[i]->szModuleName);
if (i == 0)
- mir_snprintf(p->szName, SIZEOF(p->szName), "{-}%s", accs[i]->szModuleName);
+ mir_snprintf(p->szName, _countof(p->szName), "{-}%s", accs[i]->szModuleName);
else
strncpy_s(p->szName, accs[i]->szModuleName, _TRUNCATE);
p->statusID = ID_EXTBK_LAST;
@@ -487,34 +487,34 @@ void extbk_export(char *file) }
for (n = 0; n <= FONTID_LAST; n++) {
- mir_snprintf(szSection, SIZEOF(szSection), "Font%d", n);
+ mir_snprintf(szSection, _countof(szSection), "Font%d", n);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dName", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dName", n);
if (!cfg::getString(NULL, "CLC", szKey, &dbv)) {
WritePrivateProfileStringA(szSection, "Name", dbv.pszVal, file);
mir_free(dbv.pszVal);
}
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dSize", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dSize", n);
data = (DWORD)cfg::getByte("CLC", szKey, 8);
WritePrivateProfileStructA(szSection, "Size", &data, 1, file);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dSty", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dSty", n);
data = (DWORD)cfg::getByte("CLC", szKey, 8);
WritePrivateProfileStructA(szSection, "Style", &data, 1, file);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dSet", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dSet", n);
data = (DWORD)cfg::getByte("CLC", szKey, 8);
WritePrivateProfileStructA(szSection, "Set", &data, 1, file);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dCol", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dCol", n);
data = cfg::getDword("CLC", szKey, 8);
WritePrivateProfileStructA(szSection, "Color", &data, 4, file);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dFlags", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dFlags", n);
data = (DWORD)cfg::getDword("CLC", szKey, 8);
WritePrivateProfileStructA(szSection, "Flags", &data, 4, file);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dAs", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dAs", n);
data = (DWORD)cfg::getWord("CLC", szKey, 8);
WritePrivateProfileStructA(szSection, "SameAs", &data, 2, file);
}
@@ -700,12 +700,12 @@ static void ReadItem(StatusItems_t *this_item, char *szItem, char *file) this_item->ALPHA = min(this_item->ALPHA, 100);
clr = RGB(GetBValue(defaults->COLOR), GetGValue(defaults->COLOR), GetRValue(defaults->COLOR));
- mir_snprintf(def_color, SIZEOF(def_color), "%6.6x", clr);
+ mir_snprintf(def_color, _countof(def_color), "%6.6x", clr);
GetPrivateProfileStringA(szItem, "Color1", def_color, buffer, 400, file);
this_item->COLOR = HexStringToLong(buffer);
clr = RGB(GetBValue(defaults->COLOR2), GetGValue(defaults->COLOR2), GetRValue(defaults->COLOR2));
- mir_snprintf(def_color, SIZEOF(def_color), "%6.6x", clr);
+ mir_snprintf(def_color, _countof(def_color), "%6.6x", clr);
GetPrivateProfileStringA(szItem, "Color2", def_color, buffer, 400, file);
this_item->COLOR2 = HexStringToLong(buffer);
@@ -777,7 +777,7 @@ done_with_glyph: strncpy(tmpItem.szName, &itemname[1], sizeof(tmpItem.szName));
tmpItem.szName[sizeof(tmpItem.szName) - 1] = 0;
_splitpath(szFileName, szDrive, szPath, NULL, NULL);
- mir_snprintf(szFinalName, SIZEOF(szFinalName), "%s\\%s\\%s", szDrive, szPath, buffer);
+ mir_snprintf(szFinalName, _countof(szFinalName), "%s\\%s\\%s", szDrive, szPath, buffer);
tmpItem.alpha = GetPrivateProfileIntA(itemname, "Alpha", 100, szFileName);
tmpItem.alpha = min(tmpItem.alpha, 100);
tmpItem.alpha = (BYTE)((FLOAT)(((FLOAT)tmpItem.alpha) / 100) * 255);
@@ -853,7 +853,7 @@ done_with_glyph: goto imgread_done;
}
for (n = 0;; n++) {
- mir_snprintf(szItemNr, SIZEOF(szItemNr), "Item%d", n);
+ mir_snprintf(szItemNr, _countof(szItemNr), "Item%d", n);
GetPrivateProfileStringA(itemname, szItemNr, "None", buffer, 500, szFileName);
if (!mir_strcmp(buffer, "None"))
break;
@@ -1274,7 +1274,7 @@ void LoadPerContactSkins(TCHAR *tszFileName) char UIN[40];
switch (dbv.type) {
case DBVT_DWORD:
- mir_snprintf(UIN, SIZEOF(UIN), "%d", dbv.dVal);
+ mir_snprintf(UIN, _countof(UIN), "%d", dbv.dVal);
break;
case DBVT_ASCIIZ:
strncpy_s(UIN, dbv.pszVal, _TRUNCATE);
@@ -1363,38 +1363,38 @@ void extbk_import(char *file, HWND hwndDlg) GetPrivateProfileStructA("Global", "Version", &version, 4, file);
if (version >= 2) {
for (n = 0; n <= FONTID_LAST; n++) {
- mir_snprintf(szSection, SIZEOF(szSection), "Font%d", n);
+ mir_snprintf(szSection, _countof(szSection), "Font%d", n);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dName", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dName", n);
GetPrivateProfileStringA(szSection, "Name", "Arial", buffer, sizeof(buffer), file);
cfg::writeString(NULL, "CLC", szKey, buffer);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dSize", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dSize", n);
data = 0;
GetPrivateProfileStructA(szSection, "Size", &data, 1, file);
cfg::writeByte("CLC", szKey, (BYTE)data);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dSty", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dSty", n);
data = 0;
GetPrivateProfileStructA(szSection, "Style", &data, 1, file);
cfg::writeByte("CLC", szKey, (BYTE)data);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dSet", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dSet", n);
data = 0;
GetPrivateProfileStructA(szSection, "Set", &data, 1, file);
cfg::writeByte("CLC", szKey, (BYTE)data);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dCol", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dCol", n);
data = 0;
GetPrivateProfileStructA(szSection, "Color", &data, 4, file);
cfg::writeDword("CLC", szKey, data);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dFlags", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dFlags", n);
data = 0;
GetPrivateProfileStructA(szSection, "Flags", &data, 4, file);
cfg::writeDword("CLC", szKey, (WORD)data);
- mir_snprintf(szKey, SIZEOF(szKey), "Font%dAs", n);
+ mir_snprintf(szKey, _countof(szKey), "Font%dAs", n);
data = 0;
GetPrivateProfileStructA(szSection, "SameAs", &data, 2, file);
cfg::writeDword("CLC", szKey, (WORD)data);
@@ -1563,7 +1563,7 @@ static INT_PTR CALLBACK DlgProcSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L case IDC_RELOAD:
TCHAR tszFilename[MAX_PATH], tszFinalPath[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_SKINFILE, tszFilename, SIZEOF(tszFilename));
+ GetDlgItemText(hwndDlg, IDC_SKINFILE, tszFilename, _countof(tszFilename));
tszFilename[MAX_PATH - 1] = 0;
MY_pathToAbsolute(tszFilename, tszFinalPath);
if (PathFileExists(tszFinalPath)) {
@@ -1666,7 +1666,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara ofn.lpstrFilter = "*.clist";
ofn.lpstrFile = str;
ofn.Flags = OFN_HIDEREADONLY;
- ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFile = _countof(str);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = "clist";
if (!GetSaveFileNameA(&ofn))
@@ -1684,7 +1684,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara ofn.lpstrFilter = "*.clist";
ofn.lpstrFile = str;
ofn.Flags = OFN_FILEMUSTEXIST;
- ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFile = _countof(str);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = "";
if (!GetOpenFileNameA(&ofn))
|