From 01de930753fd7a5d47c0350a4361949d770b93cf Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Mon, 22 Jul 2013 13:38:03 +0000 Subject: replace sprintf to mir_snprintf (part 1) git-svn-id: http://svn.miranda-ng.org/main/trunk@5446 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/clist.cpp | 2 +- plugins/TabSRMM/src/chat/log.cpp | 10 ++++---- plugins/TabSRMM/src/chat/options.cpp | 10 ++++---- plugins/TabSRMM/src/chat/services.cpp | 2 +- plugins/TabSRMM/src/chat/tools.cpp | 2 +- plugins/TabSRMM/src/chat/window.cpp | 4 ++-- plugins/TabSRMM/src/container.cpp | 34 +++++++++++++-------------- plugins/TabSRMM/src/msgdialog.cpp | 10 ++++---- plugins/TabSRMM/src/msgdlgutils.cpp | 44 +++++++++++++++++------------------ plugins/TabSRMM/src/srmm.cpp | 6 ++--- plugins/TabSRMM/src/themeio.cpp | 38 +++++++++++++++--------------- 11 files changed, 81 insertions(+), 81 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp index 2c0db1e44c..363e815947 100644 --- a/plugins/TabSRMM/src/chat/clist.cpp +++ b/plugins/TabSRMM/src/chat/clist.cpp @@ -267,7 +267,7 @@ BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, const T return FALSE; va_start(marker, fmt); - _vstprintf(szBuf, fmt, marker); + mir_vsntprintf(szBuf, _tcslen(szBuf), fmt, marker); va_end(marker); cle.cbSize = sizeof(cle); diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index 551bacb1ca..6b02b68d5d 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -522,7 +522,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff char* d; va_start(va, fmt); - lineLen = _vsntprintf(line, 8000, fmt, va); + lineLen = mir_vsntprintf(line, 8000, fmt, va); if (lineLen < 0) lineLen = 8000; line[lineLen] = 0; va_end(va); @@ -621,7 +621,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff } else if (*line > 0 && *line < 128) { *d++ = (char) * line; } - else d += sprintf(d, "\\u%u ?", (WORD) * line); + else d += mir_snprintf(d, strlen(d), "\\u%u ?", (WORD) * line); } *cbBufferEnd = (int)(d - *buffer); @@ -1284,7 +1284,7 @@ void LoadMsgLogBitmaps(void) for (i=0; i < SIZEOF(pLogIconBmpBits); i++) { hIcon = hIcons[i]; pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2); - rtfHeaderSize = sprintf((char *)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight); + rtfHeaderSize = mir_snprintf((char *)pLogIconBmpBits[i], strlen((char *)pLogIconBmpBits[i]), "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight); hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp); FillRect(hdcMem, &rc, hBkgBrush); DrawIconEx(hdcMem, 0, 1, hIcon, iIconSize, iIconSize, 0, NULL, DI_NORMAL); @@ -1294,9 +1294,9 @@ void LoadMsgLogBitmaps(void) { int n; for (n = 0; n < sizeof(BITMAPINFOHEADER); n++) - sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); + sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); //!!!!!!!!!!! for (n = 0; n < widthBytes * bih.biHeight; n += 4) - sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); + sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!! } logIconBmpSize[i] = rtfHeaderSize + (bih.biSize + widthBytes * bih.biHeight) * 2 + 1; pLogIconBmpBits[i][logIconBmpSize[i] - 1] = '}'; diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index e905eef4a0..6ab2614586 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -230,16 +230,16 @@ void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szM } if (colour) { - wsprintfA(str, "Font%dCol", i); + mir_snprintf(str, SIZEOF(str), "Font%dCol", i); *colour = M.GetDword(szMod, str, fol[j].defColour); } if (lf) { - wsprintfA(str, "Font%dSize", i); + mir_snprintf(str, SIZEOF(str), "Font%dSize", i); lf->lfHeight = (char) M.GetByte(szMod, str, fol[j].defSize); lf->lfWidth = 0; lf->lfEscapement = 0; lf->lfOrientation = 0; - wsprintfA(str, "Font%dSty", i); + mir_snprintf(str, SIZEOF(str), "Font%dSty", i); style = M.GetByte(szMod, str, fol[j].defStyle); if (i == MSGFONTID_MESSAGEAREA && section == FONTSECTION_IM && M.GetByte("inputFontFix", 1) == 1) { lf->lfWeight = FW_NORMAL; @@ -253,13 +253,13 @@ void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szM lf->lfUnderline = style & FONTF_UNDERLINE ? 1 : 0; lf->lfStrikeOut = style & FONTF_STRIKEOUT ? 1 : 0; } - wsprintfA(str, "Font%dSet", i); + mir_snprintf(str, SIZEOF(str), "Font%dSet", i); lf->lfCharSet = M.GetByte(szMod, str, fol[j].defCharset); lf->lfOutPrecision = OUT_DEFAULT_PRECIS; lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; lf->lfQuality = DEFAULT_QUALITY; lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - wsprintfA(str, "Font%d", i); + mir_snprintf(str, SIZEOF(str), "Font%d", i); if ((i == 17 && !strcmp(szMod, CHAT_FONTMODULE)) || ((i == 20 || i == 21) && !strcmp(szMod, FONTMODULE))) { lf->lfCharSet = SYMBOL_CHARSET; lstrcpyn(lf->lfFaceName, _T("Webdings"), SIZEOF(lf->lfFaceName)); diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index 231f466da9..a29ad7e27a 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -417,7 +417,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT if ((pContainer = FindMatchingContainer(_T("default"), hContact)) == NULL) { TCHAR szName[CONTAINER_NAMELEN + 1]; - _sntprintf(szName, CONTAINER_NAMELEN, _T("default")); + mir_sntprintf(szName, CONTAINER_NAMELEN, _T("default")); pContainer = CreateContainer(szName, CNT_CREATEFLAG_CLONED, hContact); } } diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index dcb335c157..22aaf0611f 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -198,7 +198,7 @@ static int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszP return 0; va_start(marker, fmt); - _vstprintf(szBuf, fmt, marker); + mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker); va_end(marker); pd.lchContact = hContact; diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 32e796d74e..5e47773b02 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2979,7 +2979,7 @@ LABEL_SHOWWINDOW: } else /* in the beginning of the message window */ - _stprintf(tszAppeal, tszAplTmpl, tr.lpstrText); + mir_sntprintf(tszAppeal, SIZEOF(tszAppeal), tszAplTmpl, tr.lpstrText); st = lstrlen(tszAppeal); if (chr.cpMax != -1) { tr2.chrg.cpMin = chr.cpMax; @@ -3444,7 +3444,7 @@ LABEL_SHOWWINDOW: DBVARIANT dbv = {0}; char szIndex[10]; char *szKey = "TAB_ContainersW"; - _snprintf(szIndex, 8, "%d", iSelection - IDM_CONTAINERMENU); + mir_snprintf(szIndex, SIZEOF(szIndex), "%d", iSelection - IDM_CONTAINERMENU); if (iSelection - IDM_CONTAINERMENU >= 0) { if (!db_get_ts(NULL, szKey, szIndex, &dbv)) { SendMessage(hwndDlg, DM_CONTAINERSELECTED, 0, (LPARAM)dbv.ptszVal); diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index b40276d6fa..366f68534f 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -155,13 +155,13 @@ TContainerData* TSAPI CreateContainer(const TCHAR *name, int iTemp, HANDLE hCont if (!M.GetByte("singlewinmode", 0)) { do { char szCounter[10]; - _snprintf(szCounter, 8, "%d", i); + mir_snprintf(szCounter, 8, "%d", i); DBVARIANT dbv; if (db_get_ts(NULL, szKey, szCounter, &dbv)) { if (iFirstFree != -1) { pContainer->iContainerIndex = iFirstFree; - _snprintf(szCounter, 8, "%d", iFirstFree); + mir_snprintf(szCounter, 8, "%d", iFirstFree); } else pContainer->iContainerIndex = i; @@ -2004,13 +2004,13 @@ panel_found: } } else { - _snprintf(szCName, 40, "%s%dx", szSetting, pContainer->iContainerIndex); + mir_snprintf(szCName, 40, "%s%dx", szSetting, pContainer->iContainerIndex); db_set_dw(0, SRMSGMOD_T, szCName, wp.rcNormalPosition.left); - _snprintf(szCName, 40, "%s%dy", szSetting, pContainer->iContainerIndex); + mir_snprintf(szCName, 40, "%s%dy", szSetting, pContainer->iContainerIndex); db_set_dw(0, SRMSGMOD_T, szCName, wp.rcNormalPosition.top); - _snprintf(szCName, 40, "%s%dwidth", szSetting, pContainer->iContainerIndex); + mir_snprintf(szCName, 40, "%s%dwidth", szSetting, pContainer->iContainerIndex); db_set_dw(0, SRMSGMOD_T, szCName, wp.rcNormalPosition.right - wp.rcNormalPosition.left); - _snprintf(szCName, 40, "%s%dheight", szSetting, pContainer->iContainerIndex); + mir_snprintf(szCName, 40, "%s%dheight", szSetting, pContainer->iContainerIndex); db_set_dw(0, SRMSGMOD_T, szCName, wp.rcNormalPosition.bottom - wp.rcNormalPosition.top); db_set_b(0, SRMSGMOD_T, "splitmax", (BYTE)((wp.showCmd==SW_SHOWMAXIMIZED)?1:0)); @@ -2193,8 +2193,8 @@ int TSAPI CutContactName(const TCHAR *oldname, TCHAR *newname, unsigned int size } else { TCHAR fmt[20]; - _sntprintf(fmt, 18, _T("%%%d.%ds..."), cutMax, cutMax); - _sntprintf(newname, size, fmt, oldname); + mir_sntprintf(fmt, 18, _T("%%%d.%ds..."), cutMax, cutMax); + mir_sntprintf(newname, size, fmt, oldname); newname[size - 1] = 0; } return 0; @@ -2373,7 +2373,7 @@ void TSAPI DeleteContainer(int iIndex) char *szKey = "TAB_ContainersW"; char *szSettingP = "CNTW_"; char *szSubKey = "containerW"; - _snprintf(szIndex, 8, "%d", iIndex); + mir_snprintf(szIndex, 8, "%d", iIndex); DBVARIANT dbv; if (!db_get_ts(NULL, szKey, szIndex, &dbv)) { @@ -2390,17 +2390,17 @@ void TSAPI DeleteContainer(int iIndex) db_free(&dbv_c); } } - _snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%d_Flags", szSettingP, iIndex); + mir_snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%d_Flags", szSettingP, iIndex); db_unset(NULL, SRMSGMOD_T, szSetting); - _snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%d_Trans", szSettingP, iIndex); + mir_snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%d_Trans", szSettingP, iIndex); db_unset(NULL, SRMSGMOD_T, szSetting); - _snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%dwidth", szSettingP, iIndex); + mir_snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%dwidth", szSettingP, iIndex); db_unset(NULL, SRMSGMOD_T, szSetting); - _snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%dheight", szSettingP, iIndex); + mir_snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%dheight", szSettingP, iIndex); db_unset(NULL, SRMSGMOD_T, szSetting); - _snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%dx", szSettingP, iIndex); + mir_snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%dx", szSettingP, iIndex); db_unset(NULL, SRMSGMOD_T, szSetting); - _snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%dy", szSettingP, iIndex); + mir_snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%dy", szSettingP, iIndex); db_unset(NULL, SRMSGMOD_T, szSetting); } db_free(&dbv); @@ -2415,7 +2415,7 @@ void TSAPI RenameContainer(int iIndex, const TCHAR *szNew) char *szSubKey = "containerW"; char szIndex[10]; - _snprintf(szIndex, 8, "%d", iIndex); + mir_snprintf(szIndex, 8, "%d", iIndex); if (!db_get_ts(NULL, szKey, szIndex, &dbv)) { if (szNew != NULL) if (lstrlen(szNew) != 0) @@ -2459,7 +2459,7 @@ HMENU TSAPI BuildContainerMenu() hMenu = CreateMenu(); do { - _snprintf(szCounter, 8, "%d", i); + mir_snprintf(szCounter, 8, "%d", i); if (db_get_ts(NULL, szKey, szCounter, &dbv)) break; diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 9eaa6cec47..53d9445103 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -687,9 +687,9 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar if (lstrlenA((char *)hClip) > mwdat->nMax) { TCHAR szBuffer[512]; if (M.GetByte("autosplit", 0)) - _sntprintf(szBuffer, 512, TranslateT("WARNING: The message you are trying to paste exceeds the message size limit for the active protocol. It will be sent in chunks of max %d characters"), mwdat->nMax - 10); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("WARNING: The message you are trying to paste exceeds the message size limit for the active protocol. It will be sent in chunks of max %d characters"), mwdat->nMax - 10); else - _sntprintf(szBuffer, 512, TranslateT("The message you are trying to paste exceeds the message size limit for the active protocol. Only the first %d characters will be sent."), mwdat->nMax); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The message you are trying to paste exceeds the message size limit for the active protocol. Only the first %d characters will be sent."), mwdat->nMax); SendMessage(hwndParent, DM_ACTIVATETOOLTIP, IDC_MESSAGE, (LPARAM)szBuffer); } } @@ -1320,7 +1320,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (dat->hContact && dat->szProto != NULL) { dat->wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE); - mir_sntprintf(dat->szStatus, SIZEOF(dat->szStatus), _T("%s"), (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, dat->szProto == NULL ? ID_STATUS_OFFLINE : dat->wStatus, GSMDF_TCHAR)); + mir_sntprintf(dat->szStatus, SIZEOF(dat->szStatus), _T("%s"), (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, dat->szProto == NULL ? ID_STATUS_OFFLINE : dat->wStatus, GSMDF_TCHAR)); } else dat->wStatus = ID_STATUS_OFFLINE; @@ -2882,7 +2882,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP char szIndex[10]; char *szKey = "TAB_ContainersW"; - _snprintf(szIndex, 8, "%d", iSelection - IDM_CONTAINERMENU); + mir_snprintf(szIndex, SIZEOF(szIndex), "%d", iSelection - IDM_CONTAINERMENU); if (iSelection - IDM_CONTAINERMENU >= 0) { if (!db_get_ts(NULL, szKey, szIndex, &dbv)) { SendMessage(hwndDlg, DM_CONTAINERSELECTED, 0, (LPARAM)dbv.ptszVal); @@ -3477,7 +3477,7 @@ quote_from_last: if (!(pcaps & PF4_OFFLINEFILES)) { TCHAR szBuffer[256]; - _sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("Contact is offline and this protocol does not support sending files to offline users.")); + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("Contact is offline and this protocol does not support sending files to offline users.")); SendMessage(hwndDlg, DM_ACTIVATETOOLTIP, IDC_MESSAGE, (LPARAM)szBuffer); break; } diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index bab958ae85..2dac49be97 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -153,11 +153,11 @@ static void SaveAvatarToFile(TWindowData *dat, HBITMAP hbm, int isOwnPic) struct tm *lt = localtime(&t); DWORD setView = 1; - mir_sntprintf(szTimestamp, 100, _T("%04u %02u %02u_%02u%02u"), lt->tm_year + 1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min); + mir_sntprintf(szTimestamp, SIZEOF(szTimestamp), _T("%04u %02u %02u_%02u%02u"), lt->tm_year + 1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min); TCHAR *szProto = mir_a2t(dat->cache->getActiveProto()); - mir_sntprintf(szFinalPath, MAX_PATH, _T("%s\\%s"), M.getSavedAvatarPath(), szProto); + mir_sntprintf(szFinalPath, SIZEOF(szFinalPath), _T("%s\\%s"), M.getSavedAvatarPath(), szProto); mir_free(szProto); if (CreateDirectory(szFinalPath, 0) == 0) { @@ -1015,7 +1015,7 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat) p1 = pszText; // iterate through all characters, if rtf control character found then take action while (*p1 != (TCHAR) '\0') { - _sntprintf(InsertThis, 50, _T("")); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("")); iRemoveChars = 0; switch (*p1) { @@ -1026,17 +1026,17 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat) int iInd = Utils::RTFColorToIndex(iCol); bJustRemovedRTF = TRUE; - _sntprintf(szTemp, 20, _T("%d"), iCol); + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), iCol); iRemoveChars = 3 + lstrlen(szTemp); if (bTextHasStarted || iCol) - _sntprintf(InsertThis, sizeof(InsertThis) / sizeof(TCHAR), (iInd > 0) ? (inColor ? _T("[/color][color=%s]") : _T("[color=%s]")) : (inColor ? _T("[/color]") : _T("")), Utils::rtf_ctable[iInd - 1].szName); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), (iInd > 0) ? (inColor ? _T("[/color][color=%s]") : _T("[color=%s]")) : (inColor ? _T("[/color]") : _T("")), Utils::rtf_ctable[iInd - 1].szName); inColor = iInd > 0 ? 1 : 0; } else if (p1 == _tcsstr(p1, _T("\\highlight"))) { //background color TCHAR szTemp[20]; int iCol = _ttoi(p1 + 10); bJustRemovedRTF = TRUE; - _sntprintf(szTemp, 20, _T("%d"), iCol); + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), iCol); iRemoveChars = 10 + lstrlen(szTemp); } else if (p1 == _tcsstr(p1, _T("\\par"))) { // newline bTextHasStarted = TRUE; @@ -1046,48 +1046,48 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat) bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 5; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("\n")); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("\n")); } else if (p1 == _tcsstr(p1, _T("\\endash"))) { bTextHasStarted = bJustRemovedRTF = TRUE; iRemoveChars = 7; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2013); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2013); } else if (p1 == _tcsstr(p1, _T("\\emdash"))) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2014); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2014); } else if (p1 == _tcsstr(p1, _T("\\bullet"))) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2022); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2022); } else if (p1 == _tcsstr(p1, _T("\\ldblquote"))) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 10; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x201C); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x201C); } else if (p1 == _tcsstr(p1, _T("\\rdblquote"))) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 10; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x201D); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x201D); } else if (p1 == _tcsstr(p1, _T("\\lquote"))) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2018); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2018); } else if (p1 == _tcsstr(p1, _T("\\rquote"))) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2019); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2019); } else if (p1 == _tcsstr(p1, _T("\\b"))) { //bold bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = (p1[2] != (TCHAR) '0') ? 2 : 3; if (!(lf.lfWeight == FW_BOLD)) { // only allow bold if the font itself isn't a bold one, otherwise just strip it.. if (dat->SendFormat) - _sntprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != (TCHAR) '0') ? _T("[b]") : _T("[/b]")); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != (TCHAR) '0') ? _T("[b]") : _T("[/b]")); } } else if (p1 == _tcsstr(p1, _T("\\i"))) { // italics @@ -1096,7 +1096,7 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat) iRemoveChars = (p1[2] != (TCHAR) '0') ? 2 : 3; if (!lf.lfItalic) { // same as for bold if (dat->SendFormat) - _sntprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != (TCHAR) '0') ? _T("[i]") : _T("[/i]")); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != (TCHAR) '0') ? _T("[i]") : _T("[/i]")); } } else if (p1 == _tcsstr(p1, _T("\\strike"))) { // strike-out @@ -1105,7 +1105,7 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat) iRemoveChars = (p1[7] != (TCHAR) '0') ? 7 : 8; if (!lf.lfStrikeOut) { // same as for bold if (dat->SendFormat) - _sntprintf(InsertThis, SIZEOF(InsertThis), (p1[7] != (TCHAR) '0') ? _T("[s]") : _T("[/s]")); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[7] != (TCHAR) '0') ? _T("[s]") : _T("[/s]")); } } else if (p1 == _tcsstr(p1, _T("\\ul"))) { // underlined @@ -1119,19 +1119,19 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat) iRemoveChars = 3; if (!lf.lfUnderline) { // same as for bold if (dat->SendFormat) - _sntprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != (TCHAR) '0' && p1[3] != (TCHAR) 'n') ? _T("[u]") : _T("[/u]")); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != (TCHAR) '0' && p1[3] != (TCHAR) 'n') ? _T("[u]") : _T("[/u]")); } } else if (p1 == _tcsstr(p1, _T("\\tab"))) { // tab bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 4; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x09); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x09); } else if (p1[1] == (TCHAR) '\\' || p1[1] == (TCHAR) '{' || p1[1] == (TCHAR) '}') { // escaped characters bTextHasStarted = TRUE; //bJustRemovedRTF = TRUE; iRemoveChars = 2; - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), p1[1]); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), p1[1]); } else if (p1[1] == (TCHAR) '\'') { // special character bTextHasStarted = TRUE; bJustRemovedRTF = FALSE; @@ -1152,7 +1152,7 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat) // convert string containing char in hex format to int. p3 = InsertThis; iLame = _tcstol(p3, &stoppedHere, 16); - _sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), (TCHAR) iLame); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), (TCHAR) iLame); } else iRemoveChars = 2; @@ -2074,7 +2074,7 @@ void TSAPI LoadThemeDefaults(TContainerData *pContainer) pContainer->theme.inputbg = M.GetDword(FONTMODULE, "inputbg", SRMSGDEFSET_BKGCOLOUR); for (i = 1; i <= 5; i++) { - _snprintf(szTemp, 10, "cc%d", i); + mir_snprintf(szTemp, SIZEOF(szTemp), "cc%d", i); colour = M.GetDword(szTemp, RGB(224, 224, 224)); if (colour == 0) colour = RGB(1, 1, 1); diff --git a/plugins/TabSRMM/src/srmm.cpp b/plugins/TabSRMM/src/srmm.cpp index d52c9543ca..b1b87cce68 100644 --- a/plugins/TabSRMM/src/srmm.cpp +++ b/plugins/TabSRMM/src/srmm.cpp @@ -125,7 +125,7 @@ int _DebugTraceW(const wchar_t *fmt, ...) mir_snprintf(tszTime, 50, "%02d.%02d.%04d - %02d:%02d:%02d.%04d: ", st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); - _vsnwprintf(debug, ibsize - 10, fmt, va); + mir_vsntprintf(debug, ibsize - 10, fmt, va); //#ifdef _DEBUG OutputDebugStringW(debug); //#else @@ -158,7 +158,7 @@ int _DebugTraceA(const char *fmt, ...) va_start(va, fmt); lstrcpyA(debug, "TABSRMM: "); - _vsnprintf(&debug[9], ibsize - 10, fmt, va); + mir_vsnprintf(&debug[9], ibsize - 10, fmt, va); #ifdef _DEBUG OutputDebugStringA(debug); #else @@ -195,7 +195,7 @@ int _DebugPopup(HANDLE hContact, const TCHAR *fmt, ...) int ibsize = 1023; va_start(va, fmt); - _vsntprintf(debug, ibsize, fmt, va); + mir_vsntprintf(debug, ibsize, fmt, va); if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { MIRANDASYSTRAYNOTIFY tn; diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp index e03e09a5df..da61c3bea8 100644 --- a/plugins/TabSRMM/src/themeio.cpp +++ b/plugins/TabSRMM/src/themeio.cpp @@ -192,19 +192,19 @@ void TSAPI WriteThemeToINI(const TCHAR *szIniFilenameT, struct TWindowData *dat) char *szModule = fontBlocks[n].szModule; WritePrivateProfileStringA(fontBlocks[n].szBLockname, "Valid", "1", szIniFilename); for (i=0; i < fontBlocks[n].iCount; i++) { - sprintf(szTemp, "Font%d", firstIndex + i); - sprintf(szAppname, fontBlocks[n].szIniTemp, firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%d", firstIndex + i); + mir_snprintf(szAppname, SIZEOF(szAppname), fontBlocks[n].szIniTemp, firstIndex + i); if (!db_get_s(NULL, szModule, szTemp, &dbv)) { WritePrivateProfileStringA(szAppname, "Face", dbv.pszVal, szIniFilename); db_free(&dbv); } - sprintf(szTemp, "Font%dCol", firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%dCol", firstIndex + i); WritePrivateProfileStringA(szAppname, "Color", _itoa(M.GetDword(szModule, szTemp, 0), szBuf, 10), szIniFilename); - sprintf(szTemp, "Font%dSty", firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%dSty", firstIndex + i); WritePrivateProfileStringA(szAppname, "Style", _itoa(M.GetByte(szModule, szTemp, 0), szBuf, 10), szIniFilename); - sprintf(szTemp, "Font%dSize", firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%dSize", firstIndex + i); WritePrivateProfileStringA(szAppname, "Size", _itoa(M.GetByte(szModule, szTemp, 0), szBuf, 10), szIniFilename); - sprintf(szTemp, "Font%dSet", firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%dSet", firstIndex + i); WritePrivateProfileStringA(szAppname, "Set", _itoa(M.GetByte(szModule, szTemp, 0), szBuf, 10), szIniFilename); } n++; @@ -240,7 +240,7 @@ void TSAPI WriteThemeToINI(const TCHAR *szIniFilenameT, struct TWindowData *dat) mir_free(encoded); } for (i=0; i < CUSTOM_COLORS; i++) { - sprintf(szTemp, "cc%d", i + 1); + mir_snprintf(szTemp, SIZEOF(szTemp), "cc%d", i + 1); if (dat == 0) WritePrivateProfileStringA("Custom Colors", szTemp, _itoa(M.GetDword(szTemp, 0), szBuf, 10), szIniFilename); else @@ -283,27 +283,27 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in continue; } for (i=0; i < fontBlocks[n].iCount; i++) { - sprintf(szTemp, "Font%d", firstIndex + i); - sprintf(szAppname, fontBlocks[n].szIniTemp, firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%d", firstIndex + i); + mir_snprintf(szAppname, SIZEOF(szAppname), fontBlocks[n].szIniTemp, firstIndex + i); if (GetPrivateProfileStringA(szAppname, "Face", "Verdana", szBuf, sizeof(szBuf), szIniFilename) != 0) { if (i == MSGFONTID_SYMBOLS_IN || i == MSGFONTID_SYMBOLS_OUT) lstrcpynA(szBuf, "Arial", sizeof(szBuf)); db_set_s(NULL, szModule, szTemp, szBuf); } - sprintf(szTemp, "Font%dCol", firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%dCol", firstIndex + i); db_set_dw(0, szModule, szTemp, GetPrivateProfileIntA(szAppname, "Color", GetSysColor(COLOR_WINDOWTEXT), szIniFilename)); - sprintf(szTemp, "Font%dSty", firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%dSty", firstIndex + i); db_set_b(0, szModule, szTemp, (BYTE)(GetPrivateProfileIntA(szAppname, "Style", 0, szIniFilename))); - sprintf(szTemp, "Font%dSize", firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%dSize", firstIndex + i); bSize = (char)GetPrivateProfileIntA(szAppname, "Size", -10, szIniFilename); if (bSize > 0) bSize = -MulDiv(bSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); db_set_b(0, szModule, szTemp, bSize); - sprintf(szTemp, "Font%dSet", firstIndex + i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%dSet", firstIndex + i); charset = GetPrivateProfileIntA(szAppname, "Set", 0, szIniFilename); if (i == MSGFONTID_SYMBOLS_IN || i == MSGFONTID_SYMBOLS_OUT) charset = 0; @@ -333,7 +333,7 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in db_set_b(0, SRMSGMOD_T, "extramicrolf", (BYTE)(GetPrivateProfileIntA("Message Log", "ExtraMicroLF", 0, szIniFilename))); for (i=0; i < CUSTOM_COLORS; i++) { - sprintf(szTemp, "cc%d", i + 1); + mir_snprintf(szTemp, SIZEOF(szTemp), "cc%d", i + 1); if (dat == 0) db_set_dw(0, SRMSGMOD_T, szTemp, GetPrivateProfileIntA("Custom Colors", szTemp, RGB(224, 224, 224), szIniFilename)); else @@ -347,7 +347,7 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in else defclr = g_Settings.UserListColors[CHAT_STATUS_NORMAL]; g_Settings.nickColors[i] = GetPrivateProfileIntA("Nick Colors", _itoa(i, szTemp, 10), defclr, szIniFilename); - sprintf(szTemp, "NickColor%d", i); + mir_snprintf(szTemp, SIZEOF(szTemp), "NickColor%d", i); db_set_dw(0, "Chat", szTemp, g_Settings.nickColors[i]); } } @@ -357,11 +357,11 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in ReleaseDC(NULL, hdc); if (!noAdvanced) { for (i=0; i < MSGDLGFONTCOUNT; i++) { - _snprintf(szTemp, 20, "Font%d", i); + mir_snprintf(szTemp, SIZEOF(szTemp), "Font%d", i); LoadLogfontFromINI(i, szTemp, &dat->theme.logFonts[i], &dat->theme.fontColors[i], szIniFilename); - wsprintfA(dat->theme.rtfFonts + (i * RTFCACHELINESIZE), "\\f%u\\cf%u\\b%d\\i%d\\ul%d\\fs%u", i, i, dat->theme.logFonts[i].lfWeight >= FW_BOLD ? 1 : 0, dat->theme.logFonts[i].lfItalic, dat->theme.logFonts[i].lfUnderline, 2 * abs(dat->theme.logFonts[i].lfHeight) * 74 / SY); + wsprintfA(dat->theme.rtfFonts + (i * RTFCACHELINESIZE), "\\f%u\\cf%u\\b%d\\i%d\\ul%d\\fs%u", i, i, dat->theme.logFonts[i].lfWeight >= FW_BOLD ? 1 : 0, dat->theme.logFonts[i].lfItalic, dat->theme.logFonts[i].lfUnderline, 2 * abs(dat->theme.logFonts[i].lfHeight) * 74 / SY); //!!!!!!!! } - wsprintfA(dat->theme.rtfFonts + (MSGDLGFONTCOUNT * RTFCACHELINESIZE), "\\f%u\\cf%u\\b%d\\i%d\\ul%d\\fs%u", MSGDLGFONTCOUNT, MSGDLGFONTCOUNT, 0, 0, 0, 0); + wsprintfA(dat->theme.rtfFonts + (MSGDLGFONTCOUNT * RTFCACHELINESIZE), "\\f%u\\cf%u\\b%d\\i%d\\ul%d\\fs%u", MSGDLGFONTCOUNT, MSGDLGFONTCOUNT, 0, 0, 0, 0); //!!!!!!!!! } dat->theme.bg = GetPrivateProfileIntA("Message Log", "BackgroundColor", RGB(224, 224, 224), szIniFilename); dat->theme.inbg = GetPrivateProfileIntA("Message Log", "IncomingBG", RGB(224, 224, 224), szIniFilename); @@ -381,7 +381,7 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in dat->theme.right_indent = GetPrivateProfileIntA("Message Log", "RightIndent", 0, szIniFilename); for (i=0; i < CUSTOM_COLORS; i++) { - sprintf(szTemp, "cc%d", i + 1); + mir_snprintf(szTemp, SIZEOF(szTemp), "cc%d", i + 1); if (dat == 0) db_set_dw(0, SRMSGMOD_T, szTemp, GetPrivateProfileIntA("Custom Colors", szTemp, RGB(224, 224, 224), szIniFilename)); else -- cgit v1.2.3