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/SimpleStatusMsg | |
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/SimpleStatusMsg')
-rw-r--r-- | plugins/SimpleStatusMsg/src/awaymsg.cpp | 22 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/main.cpp | 28 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/msgbox.cpp | 68 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/options.cpp | 6 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/utils.cpp | 10 |
5 files changed, 67 insertions, 67 deletions
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp index 178dc5206b..30d89eeb56 100644 --- a/plugins/SimpleStatusMsg/src/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp @@ -110,15 +110,15 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP WORD dwStatus = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE);
TCHAR *status = pcli->pfnGetStatusModeDescription(dwStatus, 0);
- GetWindowText(hwndDlg, format, SIZEOF(format));
- mir_sntprintf(str, SIZEOF(str), format, status, contactName);
+ GetWindowText(hwndDlg, format, _countof(format));
+ mir_sntprintf(str, _countof(str), format, status, contactName);
SetWindowText(hwndDlg, str);
if (dat->hSeq) {
- GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, SIZEOF(format));
- mir_sntprintf(str, SIZEOF(str), format, status);
+ GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, _countof(format));
+ mir_sntprintf(str, _countof(str), format, status);
}
else {
- mir_sntprintf(str, SIZEOF(str), TranslateT("Failed to retrieve %s message."), status);
+ mir_sntprintf(str, _countof(str), TranslateT("Failed to retrieve %s message."), status);
SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close"));
}
SetDlgItemText(hwndDlg, IDC_RETRIEVING, str);
@@ -165,7 +165,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP break;
if (EmptyClipboard()) {
TCHAR msg[1024];
- int len = GetDlgItemText(hwndDlg, IDC_MSG, msg, SIZEOF(msg));
+ int len = GetDlgItemText(hwndDlg, IDC_MSG, msg, _countof(msg));
if (len) {
LPTSTR lptstrCopy;
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR));
@@ -234,8 +234,8 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP dat->hAwayMsgEvent = dat->hSeq ? HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG) : NULL;
WindowList_Add(hWindowList2, hwndDlg, dat->hContact);
contactName = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)dat->hContact, GCDNF_TCHAR);
- GetWindowText(hwndDlg, format, SIZEOF(format));
- mir_sntprintf(str, SIZEOF(str), format, contactName);
+ GetWindowText(hwndDlg, format, _countof(format));
+ mir_sntprintf(str, _countof(str), format, contactName);
SetWindowText(hwndDlg, str);
if (!dat->hSeq)
DestroyWindow(hwndDlg);
@@ -377,7 +377,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM lParam) iHidden = 0;
clmi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON | CMIF_TCHAR;
clmi.hIcon = Skin_LoadProtoIcon(szProto, iStatus);
- mir_sntprintf(str, SIZEOF(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0));
+ mir_sntprintf(str, _countof(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0));
clmi.ptszName = str;
}
}
@@ -390,7 +390,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM lParam) clmi.flags = CMIM_FLAGS | CMIF_HIDDEN | CMIF_TCHAR;
if (!iHidden && szMsg != NULL) {
clmi.flags = CMIM_FLAGS | CMIM_NAME | CMIF_TCHAR;
- mir_sntprintf(str, SIZEOF(str), TranslateT("Copy %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0));
+ mir_sntprintf(str, _countof(str), TranslateT("Copy %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0));
clmi.ptszName = str;
}
Menu_ModifyItem(hCopyMsgMenuItem, &clmi);
@@ -398,7 +398,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM lParam) clmi.flags = CMIM_FLAGS | CMIF_HIDDEN | CMIF_TCHAR;
if (!iHidden && szMsg != NULL && StrFindURL(szMsg) != NULL) {
clmi.flags = CMIM_FLAGS | CMIM_NAME | CMIF_TCHAR;
- mir_sntprintf(str, SIZEOF(str), TranslateT("&Go to URL in %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0));
+ mir_sntprintf(str, _countof(str), TranslateT("&Go to URL in %s message"), pcli->pfnGetStatusModeDescription(iStatus, 0));
clmi.ptszName = str;
}
Menu_ModifyItem(hGoToURLMenuItem, &clmi);
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index 1e2fa45748..b577217bf0 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -69,21 +69,21 @@ void log2file(const char *fmt, ...) HANDLE hFile = CreateFileA("simplestatusmsg.log", GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
SetFilePointer(hFile, 0, 0, FILE_END);
- strncpy(szText, "[\0", SIZEOF(szText));
+ strncpy(szText, "[\0", _countof(szText));
WriteFile(hFile, szText, (DWORD)mir_strlen(szText), &dwBytesWritten, NULL);
- GetTimeFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, szText, SIZEOF(szText));
+ GetTimeFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, szText, _countof(szText));
WriteFile(hFile, szText, (DWORD)mir_strlen(szText), &dwBytesWritten, NULL);
- strncpy(szText, "] \0", SIZEOF(szText));
+ strncpy(szText, "] \0", _countof(szText));
va_start(va, fmt);
- mir_vsnprintf(szText + mir_strlen(szText), SIZEOF(szText) - mir_strlen(szText), fmt, va);
+ mir_vsnprintf(szText + mir_strlen(szText), _countof(szText) - mir_strlen(szText), fmt, va);
va_end(va);
WriteFile(hFile, szText, (DWORD)mir_strlen(szText), &dwBytesWritten, NULL);
- strncpy(szText, "\n\0", SIZEOF(szText));
+ strncpy(szText, "\n\0", _countof(szText));
WriteFile(hFile, szText, (DWORD)mir_strlen(szText), &dwBytesWritten, NULL);
CloseHandle(hFile);
@@ -225,9 +225,9 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) }
t.wMinute = mm % 60;
t.wHour = mm / 60;
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, SIZEOF(substituteStr));
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, _countof(substituteStr));
}
- else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, SIZEOF(substituteStr));
+ else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, _countof(substituteStr));
if (mir_tstrlen(substituteStr) > 6)
msg = (TCHAR *)mir_realloc(msg, (mir_tstrlen(msg) + 1 + mir_tstrlen(substituteStr) - 6) * sizeof(TCHAR));
@@ -237,7 +237,7 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) }
else if (!_tcsnicmp(msg + i, _T("%date%"), 6))
{
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, SIZEOF(substituteStr));
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, _countof(substituteStr));
if (mir_tstrlen(substituteStr) > 6)
msg = (TCHAR *)mir_realloc(msg, (mir_tstrlen(msg) + 1 + mir_tstrlen(substituteStr) - 6) * sizeof(TCHAR));
@@ -258,7 +258,7 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) if (ran_to > ran_from)
{
- mir_sntprintf(substituteStr, SIZEOF(substituteStr), _T("%d"), GetRandom(ran_from, ran_to));
+ mir_sntprintf(substituteStr, _countof(substituteStr), _T("%d"), GetRandom(ran_from, ran_to));
for (k = i + 1; msg[k]; k++) if (msg[k] == '%') { k++; break; }
if (mir_tstrlen(substituteStr) > k - i)
@@ -276,7 +276,7 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) DBVARIANT dbv;
BOOL rmark[25];
- for (k = 0; k < SIZEOF(rmark); k++) rmark[k] = FALSE;
+ for (k = 0; k < _countof(rmark); k++) rmark[k] = FALSE;
maxk = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
if (maxk == 0) rmark[0] = TRUE;
@@ -324,7 +324,7 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) DBVARIANT dbv;
BOOL rmark[25];
- for (k = 0; k < SIZEOF(rmark); k++) rmark[k] = FALSE;
+ for (k = 0; k < _countof(rmark); k++) rmark[k] = FALSE;
maxk = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
if (maxk == 0) rmark[0] = TRUE;
@@ -1366,14 +1366,14 @@ VOID CALLBACK UpdateMsgTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD d if (iCurrentStatus < ID_STATUS_ONLINE)
continue;
- mir_snprintf(szBuffer, SIZEOF(szBuffer), "FCur%sMsg", accounts->pa[i]->szModuleName);
+ mir_snprintf(szBuffer, _countof(szBuffer), "FCur%sMsg", accounts->pa[i]->szModuleName);
if (db_get_ts(NULL, "SimpleStatusMsg", szBuffer, &dbv))
continue;
tszMsg = InsertVarsIntoMsg(dbv.ptszVal, accounts->pa[i]->szModuleName, iCurrentStatus, NULL);
db_free(&dbv);
- mir_snprintf(szBuffer, SIZEOF(szBuffer), "Cur%sMsg", accounts->pa[i]->szModuleName);
+ mir_snprintf(szBuffer, _countof(szBuffer), "Cur%sMsg", accounts->pa[i]->szModuleName);
if (!db_get_ts(NULL, "SimpleStatusMsg", szBuffer, &dbv))
{
if (tszMsg && dbv.ptszVal && !mir_tstrcmp(tszMsg, dbv.ptszVal) || !tszMsg && !dbv.ptszVal)
@@ -1663,7 +1663,7 @@ static TCHAR *ParseDate(ARGUMENTSINFO *ai) TCHAR szStr[128] = {0};
ai->flags |= AIF_DONTPARSE;
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, szStr, SIZEOF(szStr));
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, szStr, _countof(szStr));
return mir_tstrdup(szStr);
}
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp index 083a0aa7e1..0ce63d8e39 100644 --- a/plugins/SimpleStatusMsg/src/msgbox.cpp +++ b/plugins/SimpleStatusMsg/src/msgbox.cpp @@ -285,7 +285,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) } cbei.iItem = -1; cbei.pszText = (LPTSTR)text; - cbei.cchTextMax = SIZEOF(text); + cbei.cchTextMax = _countof(text); cbei.lParam = MAKELPARAM(CLEAR_HISTORY, 0); SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei); } @@ -301,7 +301,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) cbei.iIndent = 1; } cbei.pszText = (LPTSTR)text; - cbei.cchTextMax = SIZEOF(text); + cbei.cchTextMax = _countof(text); cbei.lParam = MAKELPARAM(ADD_MSG, 0); SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei); @@ -316,7 +316,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) } cbei.iItem = -1; cbei.pszText = (LPTSTR)text; - cbei.cchTextMax = SIZEOF(text); + cbei.cchTextMax = _countof(text); cbei.lParam = MAKELPARAM(DELETE_SELECTED, 0); SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei); } @@ -600,7 +600,7 @@ int AddToPredefined(HWND hwndDlg, struct MsgBoxData *data) TCHAR msg[1024], text[1024]; if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) - len = GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg)); + len = GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg)); if (!len) return -1; @@ -609,7 +609,7 @@ int AddToPredefined(HWND hwndDlg, struct MsgBoxData *data) for (int i = 1; i <= data->num_def_msgs; i++, num_items--) { newitem.mask = CBEIF_LPARAM | CBEIF_TEXT; newitem.iItem = num_items; - newitem.cchTextMax = SIZEOF(text); + newitem.cchTextMax = _countof(text); newitem.pszText = text; SendMessage(data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&newitem); @@ -622,7 +622,7 @@ int AddToPredefined(HWND hwndDlg, struct MsgBoxData *data) newitem.iItem = -1; newitem.pszText = (LPTSTR)msg; - newitem.cchTextMax = SIZEOF(msg); + newitem.cchTextMax = _countof(msg); if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) { newitem.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE; newitem.iImage = I_ICON_MSG; @@ -643,7 +643,7 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel) char text[16], buff2[80]; for (i = 1; i <= data->max_hist_msgs; i++) { - mir_snprintf(text, SIZEOF(text), "SMsg%d", i); + mir_snprintf(text, _countof(text), "SMsg%d", i); db_set_ts(NULL, "SimpleStatusMsg", text, _T("")); } db_set_s(NULL, "SimpleStatusMsg", "LastMsg", ""); @@ -657,7 +657,7 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel) if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(buff2, SIZEOF(buff2), "Last%sMsg", accounts->pa[i]->szModuleName); + mir_snprintf(buff2, _countof(buff2), "Last%sMsg", accounts->pa[i]->szModuleName); db_set_s(NULL, "SimpleStatusMsg", buff2, ""); } db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)data->max_hist_msgs); @@ -687,7 +687,7 @@ void DisplayCharsCount(struct MsgBoxData *dlg_data, HWND hwndDlg) if (dlg_data->m_iCountdown != -2) return; - len = GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg)); + len = GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg)); if (db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0)) { int index, num_lines = SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_GETLINECOUNT, 0, 0); for (int i = 1; i < num_lines; ++i) { @@ -696,7 +696,7 @@ void DisplayCharsCount(struct MsgBoxData *dlg_data, HWND hwndDlg) lines++; } } - mir_sntprintf(status_text, SIZEOF(status_text), TranslateT("OK (%d)"), len - (lines - 1)); + mir_sntprintf(status_text, _countof(status_text), TranslateT("OK (%d)"), len - (lines - 1)); SetDlgItemText(hwndDlg, IDC_OK, status_text); } @@ -780,7 +780,7 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) TCHAR szTitle[256], szProtoName[128]; BOOL bDisabled = msgbox_data->m_szProto && !(CallProtoService(msgbox_data->m_szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND); - mir_sntprintf(szProtoName, SIZEOF(szProtoName), msgbox_data->m_szProto ? Proto_GetAccount(msgbox_data->m_szProto)->tszAccountName : TranslateT("global")); + mir_sntprintf(szProtoName, _countof(szProtoName), msgbox_data->m_szProto ? Proto_GetAccount(msgbox_data->m_szProto)->tszAccountName : TranslateT("global")); if (iStatus == ID_STATUS_CURRENT) { if (msgbox_data->m_bOnStartup) mir_sntprintf(szTitle, TranslateT("%s message (%s)"), TranslateT("<startup>"), szProtoName); @@ -822,7 +822,7 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) EnableWindow(msgbox_data->recent_cbex, TRUE); // TODO what if num_start <= 0 ? - if (GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg))) + if (GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg))) fcursel = SendMessage(msgbox_data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)msg); if (fcursel != CB_ERR) { SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, fcursel, 0); @@ -830,7 +830,7 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) } if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) { - if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg))) { + if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg))) { if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); } @@ -845,7 +845,7 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) COMBOBOXEXITEM cbitem = {0}; cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT; cbitem.iItem = msgbox_data->curr_sel_msg; - cbitem.cchTextMax = SIZEOF(msg); + cbitem.cchTextMax = _countof(msg); cbitem.pszText = msg; SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem); if (LOWORD(cbitem.lParam) == PREDEFINED_MSG) { @@ -904,8 +904,8 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA TranslateDialogDefault(hwndDlg); init_data = (struct MsgBoxInitData *)lParam; - GetWindowText(hwndDlg, szFormat, SIZEOF(szFormat)); - mir_sntprintf(szProtoName, SIZEOF(szProtoName), init_data->m_szProto ? Proto_GetAccount(init_data->m_szProto)->tszAccountName : TranslateT("global")); + GetWindowText(hwndDlg, szFormat, _countof(szFormat)); + mir_sntprintf(szProtoName, _countof(szProtoName), init_data->m_szProto ? Proto_GetAccount(init_data->m_szProto)->tszAccountName : TranslateT("global")); if (init_data->m_iStatus == ID_STATUS_CURRENT) { if (init_data->m_bOnStartup) @@ -1001,7 +1001,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if ((copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) { TCHAR msg[1024]; - if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg))) + if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg))) EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); if (copy_init_data->curr_sel_msg == -1) { @@ -1012,7 +1012,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA COMBOBOXEXITEM cbitem = {0}; cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT; cbitem.iItem = copy_init_data->curr_sel_msg; - cbitem.cchTextMax = SIZEOF(msg); + cbitem.cchTextMax = _countof(msg); cbitem.pszText = msg; SendMessage(copy_init_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem); @@ -1099,7 +1099,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA } else { TCHAR str[64]; - mir_sntprintf(str, SIZEOF(str), TranslateT("Closing in %d"), msgbox_data->m_iCountdown); + mir_sntprintf(str, _countof(str), TranslateT("Closing in %d"), msgbox_data->m_iCountdown); SetDlgItemText(hwndDlg, IDC_OK, str); } msgbox_data->m_iCountdown--; @@ -1124,7 +1124,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA } if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) - iMsgLen = GetDlgItemText(hwndDlg, IDC_EDIT1, tszMsg, SIZEOF(tszMsg)); + iMsgLen = GetDlgItemText(hwndDlg, IDC_EDIT1, tszMsg, _countof(tszMsg)); if (iMsgLen == 0) { char szSetting[80]; @@ -1179,10 +1179,10 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (!mir_tstrcmp(dbv.ptszVal, tszMsg)) { found = TRUE; if (msgbox_data->m_szProto) { - mir_snprintf(buff2, SIZEOF(buff2), "Last%sMsg", msgbox_data->m_szProto); + mir_snprintf(buff2, _countof(buff2), "Last%sMsg", msgbox_data->m_szProto); db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - mir_snprintf(buff2, SIZEOF(buff2), "%sMsg", msgbox_data->m_szProto); + mir_snprintf(buff2, _countof(buff2), "%sMsg", msgbox_data->m_szProto); db_set_ts(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg); } else { @@ -1200,10 +1200,10 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (!(CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(buff2, SIZEOF(buff2), "Last%sMsg", accounts->pa[j]->szModuleName); + mir_snprintf(buff2, _countof(buff2), "Last%sMsg", accounts->pa[j]->szModuleName); db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - mir_snprintf(buff2, SIZEOF(buff2), "%sMsg", accounts->pa[j]->szModuleName); + mir_snprintf(buff2, _countof(buff2), "%sMsg", accounts->pa[j]->szModuleName); iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(accounts->pa[j]->szModuleName) : GetCurrentStatus(accounts->pa[j]->szModuleName); db_set_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); } @@ -1227,10 +1227,10 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA db_set_ts(NULL, "SimpleStatusMsg", buff, tszMsg); if (msgbox_data->m_szProto) { - mir_snprintf(buff2, SIZEOF(buff2), "Last%sMsg", msgbox_data->m_szProto); + mir_snprintf(buff2, _countof(buff2), "Last%sMsg", msgbox_data->m_szProto); db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - mir_snprintf(buff2, SIZEOF(buff2), "%sMsg", msgbox_data->m_szProto); + mir_snprintf(buff2, _countof(buff2), "%sMsg", msgbox_data->m_szProto); db_set_ts(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg); } else { @@ -1248,10 +1248,10 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (!(CallProtoService(accounts->pa[j]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(buff2, SIZEOF(buff2), "Last%sMsg", accounts->pa[j]->szModuleName); + mir_snprintf(buff2, _countof(buff2), "Last%sMsg", accounts->pa[j]->szModuleName); db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - mir_snprintf(buff2, SIZEOF(buff2), "%sMsg", accounts->pa[j]->szModuleName); + mir_snprintf(buff2, _countof(buff2), "%sMsg", accounts->pa[j]->szModuleName); iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(accounts->pa[j]->szModuleName) : GetCurrentStatus(accounts->pa[j]->szModuleName); db_set_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); } @@ -1292,7 +1292,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL))) EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); - if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg))) { + if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg))) { if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); } @@ -1345,7 +1345,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT; cbitem.iItem = cur_sel; - cbitem.cchTextMax = SIZEOF(text); + cbitem.cchTextMax = _countof(text); cbitem.pszText = text; SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem); @@ -1372,7 +1372,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA int fcursel = CB_ERR, num_start; num_start = SendMessage(msgbox_data->recent_cbex, CB_GETCOUNT, 0, 0); num_start -= msgbox_data->num_def_msgs + 1; - GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg)); + GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg)); fcursel = SendMessage(msgbox_data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)msg); SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, fcursel, 0); } @@ -1416,7 +1416,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA histitem.mask = CBEIF_LPARAM | CBEIF_TEXT; histitem.iItem = cur_sel; - histitem.cchTextMax = SIZEOF(text); + histitem.cchTextMax = _countof(text); histitem.pszText = text; SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); @@ -1529,7 +1529,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA histitem.mask = CBEIF_LPARAM | CBEIF_TEXT; histitem.iItem = cur_sel; - histitem.cchTextMax = SIZEOF(text); + histitem.cchTextMax = _countof(text); histitem.pszText = text; SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); @@ -1593,7 +1593,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA for (i = 1; i <= msgbox_data->num_def_msgs; i++) { cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT; cbitem.iItem = num_items; - cbitem.cchTextMax = SIZEOF(text); + cbitem.cchTextMax = _countof(text); cbitem.pszText = text; SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem); diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp index 931ceaa6bf..8710df7052 100644 --- a/plugins/SimpleStatusMsg/src/options.cpp +++ b/plugins/SimpleStatusMsg/src/options.cpp @@ -878,7 +878,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (data->proto_msg[j].flags & PROTO_THIS_MSG)
{
- int len = GetDlgItemText(hwndDlg, IDC_OPTEDIT1, msg, SIZEOF(msg));
+ int len = GetDlgItemText(hwndDlg, IDC_OPTEDIT1, msg, _countof(msg));
if (len > 0)
{
if (data->proto_msg[j].msg == NULL)
@@ -900,7 +900,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
else
{
- GetDlgItemText(hwndDlg, IDC_OPTEDIT1, msg, SIZEOF(msg));
+ GetDlgItemText(hwndDlg, IDC_OPTEDIT1, msg, _countof(msg));
mir_tstrcpy(data->status_msg[j].msg[i], msg);
}
}
@@ -1346,7 +1346,7 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
for (i = 1; i <= max_hist_msgs; i++) {
- mir_snprintf(text, SIZEOF(text), "SMsg%d", i);
+ mir_snprintf(text, _countof(text), "SMsg%d", i);
db_set_ts(NULL, "SimpleStatusMsg", text, _T(""));
}
db_set_s(NULL, "SimpleStatusMsg", "LastMsg", "");
diff --git a/plugins/SimpleStatusMsg/src/utils.cpp b/plugins/SimpleStatusMsg/src/utils.cpp index cff6593801..486bf5481d 100644 --- a/plugins/SimpleStatusMsg/src/utils.cpp +++ b/plugins/SimpleStatusMsg/src/utils.cpp @@ -36,19 +36,19 @@ static IconItem iconList[] = void IconsInit(void)
{
- Icon_Register(g_hInst, LPGEN("Simple Status Message"), iconList, SIZEOF(iconList), "SimpleStatusMsg");
+ Icon_Register(g_hInst, LPGEN("Simple Status Message"), iconList, _countof(iconList), "SimpleStatusMsg");
}
HICON LoadIconEx(const char *name)
{
char szSettingName[100];
- mir_snprintf(szSettingName, SIZEOF(szSettingName), "SimpleStatusMsg_%s", name);
+ mir_snprintf(szSettingName, _countof(szSettingName), "SimpleStatusMsg_%s", name);
return IcoLib_GetIcon(szSettingName);
}
HANDLE GetIconHandle(int iconId)
{
- for(int i = 0; i < SIZEOF(iconList); i++)
+ for(int i = 0; i < _countof(iconList); i++)
if (iconList[i].defIconID == iconId)
return iconList[i].hIcolib;
@@ -58,14 +58,14 @@ HANDLE GetIconHandle(int iconId) void ReleaseIconEx(const char *name)
{
char szSettingName[100];
- mir_snprintf(szSettingName, SIZEOF(szSettingName), "SimpleStatusMsg_%s", name);
+ mir_snprintf(szSettingName, _countof(szSettingName), "SimpleStatusMsg_%s", name);
IcoLib_Release(szSettingName);
}
HANDLE HookProtoEvent(const char *szModule, const char *szEvent, MIRANDAHOOKPARAM hookProc)
{
char szProtoEvent[MAXMODULELABELLENGTH];
- mir_snprintf(szProtoEvent, SIZEOF(szProtoEvent), "%s%s", szModule, szEvent);
+ mir_snprintf(szProtoEvent, _countof(szProtoEvent), "%s%s", szModule, szEvent);
HANDLE res = HookEventParam(szProtoEvent, hookProc, (LPARAM)szModule);
arProtoHooks.insert(res);
return res;
|