diff options
58 files changed, 2194 insertions, 2234 deletions
diff --git a/plugins/Alarms/src/alarm_win.cpp b/plugins/Alarms/src/alarm_win.cpp index 8b913d3d00..b46758cbc1 100644 --- a/plugins/Alarms/src/alarm_win.cpp +++ b/plugins/Alarms/src/alarm_win.cpp @@ -191,7 +191,7 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar if (data && data->action & AAF_SOUND) {
if (data->sound_num <= 3) {
char buff[128];
- sprintf(buff, "Triggered%d", data->sound_num);
+ mir_snprintf(buff, SIZEOF(buff), "Triggered%d", data->sound_num);
SkinPlaySound(buff);
}
else if (data->sound_num == 4) {
diff --git a/plugins/Boltun/src/boltun.cpp b/plugins/Boltun/src/boltun.cpp index cfc03855a2..c4670138a8 100644 --- a/plugins/Boltun/src/boltun.cpp +++ b/plugins/Boltun/src/boltun.cpp @@ -117,7 +117,7 @@ static bool LoadMind(const TCHAR* filename, int &line) #ifdef DEBUG_LOAD_TIME
t = __rdtsc() - t;
char dest[101];
- sprintf_s(dest, 100, "%I64d ticks\n", t / 3200000);
+ mir_snprintf(dest, 100, "%I64d ticks\n", t / 3200000);
MessageBoxA(NULL, dest, NULL, 0);
//exit(0);
#endif
@@ -396,7 +396,7 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP size_t l = _tcslen(MIND_DIALOG_FILTER)
+ _tcslen(mind) + _tcslen(anyfile);
TCHAR *filt = new TCHAR[l];
- wsprintf(filt, MIND_DIALOG_FILTER, mind, anyfile);
+ mir_sntprintf(filt, l, MIND_DIALOG_FILTER, mind, anyfile);
for (size_t i = 0; i < l; i++)
if (filt[i] == '\1')
filt[i] = '\0';
@@ -437,7 +437,7 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP if (!bTranslated)
{
TCHAR* message = new TCHAR[5000];
- wsprintf(message, TranslateTS(FAILED_TO_LOAD_BASE), line, c);
+ mir_sntprintf(message, 5000, TranslateTS(FAILED_TO_LOAD_BASE), line, c);
MessageBox(NULL, message, TranslateTS(BOLTUN_ERROR), MB_ICONERROR|MB_TASKMODAL|MB_OK);
delete[] message;
}
@@ -638,7 +638,7 @@ extern "C" int __declspec(dllexport) Load(void) if (!blInit)
{
TCHAR path[2000];
- wsprintf(path, TranslateTS(FAILED_TO_LOAD_BASE), line, (const TCHAR*)Config.MindFileName);
+ mir_sntprintf(path, SIZEOF(path), TranslateTS(FAILED_TO_LOAD_BASE), line, (const TCHAR*)Config.MindFileName);
MessageBox(NULL, path, TranslateTS(BOLTUN_ERROR), MB_ICONERROR|MB_TASKMODAL|MB_OK);
}
/*record for Uninstall plugin*/
@@ -660,7 +660,7 @@ extern "C" int __declspec(dllexport) Unload(void) //So in case of saving error we will remain silent
#if 0
TCHAR path[MAX_PATH];
- wsprintf(path, TranslateTS(FAILED_TO_SAVE_BASE), (const TCHAR*)Config.MindFileName);
+ mir_sntprintf(path, SIZEOF(path), TranslateTS(FAILED_TO_SAVE_BASE), (const TCHAR*)Config.MindFileName);
TCHAR* err = TranslateTS(BOLTUN_ERROR);
MessageBox(NULL, path, err, MB_ICONERROR|MB_TASKMODAL|MB_OK);*/
#endif
diff --git a/plugins/ChangeKeyboardLayout/src/text_operations.cpp b/plugins/ChangeKeyboardLayout/src/text_operations.cpp index 440840781d..567df72e3f 100644 --- a/plugins/ChangeKeyboardLayout/src/text_operations.cpp +++ b/plugins/ChangeKeyboardLayout/src/text_operations.cpp @@ -69,8 +69,8 @@ BOOL CopyTextToClipboard(LPTSTR ptszText) LPSTR GetNameOfLayout(HKL hklLayout)
{
- LPSTR ptszLayName = (LPSTR)mir_alloc(KL_NAMELENGTH+1);
- sprintf(ptszLayName, "%08x", hklLayout);
+ LPSTR ptszLayName = (LPSTR)mir_alloc(KL_NAMELENGTH + 1);
+ mir_snprintf(ptszLayName, KL_NAMELENGTH + 1, "%08x", hklLayout);
return ptszLayName;
}
diff --git a/plugins/Clist_modern/src/modern_groupmenu.cpp b/plugins/Clist_modern/src/modern_groupmenu.cpp index 5f6ac01363..74dc4383a5 100644 --- a/plugins/Clist_modern/src/modern_groupmenu.cpp +++ b/plugins/Clist_modern/src/modern_groupmenu.cpp @@ -103,7 +103,7 @@ static INT_PTR AddGroupMenuItem(WPARAM wParam,LPARAM lParam) tmi.ownerdata = mmep;
char buf[1024];
- sprintf(buf,"%s/%s",mi->pszService,mi->pszName);
+ mir_snprintf(buf, SIZEOF(buf), "%s/%s", mi->pszService, mi->pszName);
OptParam op;
op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hGroupMenuObject,(LPARAM)&tmi);
@@ -468,7 +468,7 @@ static INT_PTR AddSubGroupMenuItem(WPARAM wParam,LPARAM lParam) tmi.ownerdata = mmep;
char buf[1024];
- sprintf(buf,"%s/%s",mi->pszService,mi->pszName);
+ mir_snprintf(buf, SIZEOF(buf), "%s/%s", mi->pszService, mi->pszName);
OptParam op;
op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hSubGroupMenuObject,(LPARAM)&tmi);
diff --git a/plugins/Clist_mw/src/CLUIFrames/statusbar.cpp b/plugins/Clist_mw/src/CLUIFrames/statusbar.cpp index 10a0ad3b4b..1b03281334 100644 --- a/plugins/Clist_mw/src/CLUIFrames/statusbar.cpp +++ b/plugins/Clist_mw/src/CLUIFrames/statusbar.cpp @@ -65,14 +65,6 @@ void DrawDataForStatusBar(LPDRAWITEMSTRUCT dis) SelectClipRgn(dis->hDC, hrgn);
char *szProto = PD->RealName;
-#ifdef _DEBUG
- {
- //char buf[512];
- //sprintf(buf,"proto: %s draw at pos: %d\r\n",szProto,dis->rcItem.left);
- //OutputDebugStringA(buf);
- }
-#endif
-
int status = CallProtoService(szProto,PS_GETSTATUS,0,0);
SetBkMode(dis->hDC,TRANSPARENT);
int x = dis->rcItem.left+extraspace;
diff --git a/plugins/Clist_mw/src/clcfonts.cpp b/plugins/Clist_mw/src/clcfonts.cpp index 1ad20dc2b0..a5baeb4970 100644 --- a/plugins/Clist_mw/src/clcfonts.cpp +++ b/plugins/Clist_mw/src/clcfonts.cpp @@ -96,7 +96,7 @@ void RegisterCListFonts() strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup));
_tcsncpy(fontid.group, _T("Contact List"), SIZEOF(fontid.group));
_tcsncpy(fontid.name, szClistFontIdDescr[fontListOrder[i]], SIZEOF(fontid.name));
- sprintf(idstr, "Font%d", fontListOrder[i]);
+ mir_snprintf(idstr, SIZEOF(idstr), "Font%d", fontListOrder[i]);
strncpy(fontid.prefix, idstr, SIZEOF(fontid.prefix));
fontid.order = fontListOrder[i];
FontRegisterT(&fontid);
diff --git a/plugins/Clist_mw/src/clui.cpp b/plugins/Clist_mw/src/clui.cpp index f96a3a0697..97903b621d 100644 --- a/plugins/Clist_mw/src/clui.cpp +++ b/plugins/Clist_mw/src/clui.cpp @@ -136,7 +136,7 @@ int GetConnectingIconForProtoCount(char *szProto) GetModuleFileNameA(GetModuleHandle(NULL), szPath, MAX_PATH);
str = strrchr(szPath,'\\');
if (str != NULL) *str = 0;
- _snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\proto_conn_%s.dll", szPath, szProto);
+ mir_snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\proto_conn_%s.dll", szPath, szProto);
lstrcpynA(file,szFullPath,SIZEOF(file));
PathToAbsolute(file, fileFull);
@@ -151,25 +151,12 @@ static HICON ExtractIconFromPath(const char *path) char file[MAX_PATH],fileFull[MAX_PATH];
int n;
HICON hIcon;
- {
-// char buf[512];
-// sprintf(buf,"LoadIcon %s\r\n",path);
-// OutputDebugStringA(buf);
- }
lstrcpynA(file,path,SIZEOF(file));
comma = strrchr(file,',');
if (comma == NULL) n = 0;
else {n = atoi(comma+1); *comma = 0;}
PathToAbsolute(file, fileFull);
-#ifdef _DEBUG
- {
-// char buf[512];
-// sprintf(buf,"LoadIconFull %d %s\r\n",n,fileFull);
-// OutputDebugStringA(buf);
- }
-#endif
-
hIcon = NULL;
ExtractIconExA(fileFull,n,NULL,&hIcon,1);
return hIcon;
@@ -189,7 +176,7 @@ HICON LoadIconFromExternalFile(char *filename,int i,boolean UseLibrary,boolean r GetModuleFileNameA(g_hInst, szMyPath, MAX_PATH);
str = strrchr(szPath,'\\');
if (str != NULL) *str = 0;
- _snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
+ mir_snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
}
if ( !UseLibrary) {
@@ -225,8 +212,8 @@ void RegisterProtoIcons (char *protoname) char buf2[256];
for (i = 0;i<8;i++)
{
- sprintf(buf,"%s #%d",protoname,i);
- sprintf(buf2,"Contact List/Connection Icons %s",protoname);
+ mir_snprintf(buf, SIZEOF(buf), "%s #%d", protoname, i);
+ mir_snprintf(buf2, SIZEOF(buf2), "Contact List/Connection Icons %s", protoname);
LoadIconFromExternalFile(NULL,i,TRUE,TRUE,buf,buf2,buf,0,GetConnectingIconForProto_DLL(protoname,i));
}
@@ -250,7 +237,7 @@ HICON GetConnectingIconForProto_DLL(char *szProto,int b) HICON hIcon = NULL;
b = b-1;
- _snprintf(szFullPath, SIZEOF(szFullPath), "proto_conn_%s.dll",szProto);
+ mir_snprintf(szFullPath, SIZEOF(szFullPath), "proto_conn_%s.dll", szProto);
// hIcon = ExtractIconFromPath(szFullPath);
// if (hIcon) return hIcon;
@@ -260,7 +247,7 @@ HICON GetConnectingIconForProto_DLL(char *szProto,int b) #ifdef _DEBUG
{
char buf [256];
- sprintf(buf,"IconNotFound %s %d\r\n",szProto,b);
+ mir_snprintf(buf, SIZEOF(buf), "IconNotFound %s %d\r\n", szProto, b);
// OutputDebugStringA(buf);
}
#endif
@@ -270,7 +257,7 @@ HICON GetConnectingIconForProto_DLL(char *szProto,int b) #ifdef _DEBUG
char buf [256];
- sprintf(buf,"Icon %d %d\r\n",GetTickCount(),b);
+ mir_snprintf(buf, SIZEOF(buf), "Icon %d %d\r\n", GetTickCount(), b);
//OutputDebugStringA(buf);
#endif
return(LoadIconA(g_hInst,(LPCSTR)(IDI_ICQC1+b)));
@@ -284,7 +271,7 @@ HICON GetConnectingIconForProto(char *szProto,int b) if ( db_get_b(NULL,"CList","UseProtoIconFromIcoLib",1)) {
HICON hIcon = 0;
char buf[256];
- sprintf(buf,"%s #%d",szProto,b);
+ mir_snprintf(buf, SIZEOF(buf), "%s #%d", szProto, b);
hIcon = LoadIconFromExternalFile(NULL,b,TRUE,FALSE,buf,"Contact List/Connection Icons",buf,0,NULL);
if (hIcon == NULL) return (GetConnectingIconForProto_DLL(szProto,b));
@@ -459,7 +446,7 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l HANDLE hMap;
char szName[MAX_PATH];
int rc = 0;
- _snprintf(szName,SIZEOF(szName),"Miranda::%u", wParam); // caller will tell us the ID of the map
+ mir_snprintf(szName, SIZEOF(szName), "Miranda::%u", wParam); // caller will tell us the ID of the map
hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS,FALSE,szName);
if (hMap != NULL) {
void *hView = NULL;
@@ -468,7 +455,7 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l char szFilePath[MAX_PATH], szProfile[MAX_PATH];
CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)&szFilePath);
CallService(MS_DB_GETPROFILENAME,MAX_PATH,(LPARAM)&szProfile);
- _snprintf((char*)hView, MAX_PATH, "%s\\%s", szFilePath, szProfile);
+ mir_snprintf((char*)hView, MAX_PATH, "%s\\%s", szFilePath, szProfile);
UnmapViewOfFile(hView);
rc = 1;
}
diff --git a/plugins/Clist_mw/src/commonheaders.cpp b/plugins/Clist_mw/src/commonheaders.cpp index df68c5385c..c76992e096 100644 --- a/plugins/Clist_mw/src/commonheaders.cpp +++ b/plugins/Clist_mw/src/commonheaders.cpp @@ -16,7 +16,7 @@ DWORD exceptFunction(LPEXCEPTION_POINTERS EP) char buf[4096];
- sprintf(buf,"\r\nExceptCode: %x\r\nExceptFlags: %x\r\nExceptAddress: %p\r\n",
+ mir_snprintf(buf, SIZEOF(buf), "\r\nExceptCode: %x\r\nExceptFlags: %x\r\nExceptAddress: %p\r\n",
EP->ExceptionRecord->ExceptionCode,
EP->ExceptionRecord->ExceptionFlags,
EP->ExceptionRecord->ExceptionAddress
diff --git a/plugins/Clist_mw/src/groupmenu.cpp b/plugins/Clist_mw/src/groupmenu.cpp index 01f428247d..821a57d754 100644 --- a/plugins/Clist_mw/src/groupmenu.cpp +++ b/plugins/Clist_mw/src/groupmenu.cpp @@ -103,7 +103,7 @@ static INT_PTR AddGroupMenuItem(WPARAM wParam,LPARAM lParam) tmi.ownerdata = mmep;
char buf[1024];
- sprintf(buf,"%s/%s",mi->pszService,mi->pszName);
+ mir_snprintf(buf, SIZEOF(buf), "%s/%s", mi->pszService, mi->pszName);
OptParam op;
op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hGroupMenuObject,(LPARAM)&tmi);
@@ -472,7 +472,7 @@ static INT_PTR AddSubGroupMenuItem(WPARAM wParam,LPARAM lParam) tmi.ownerdata = mmep;
char buf[1024];
- sprintf(buf,"%s/%s",mi->pszService,mi->pszName);
+ mir_snprintf(buf, SIZEOF(buf), "%s/%s", mi->pszService, mi->pszName);
OptParam op;
op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM,(WPARAM)hSubGroupMenuObject,(LPARAM)&tmi);
diff --git a/plugins/CmdLine/src/utils.cpp b/plugins/CmdLine/src/utils.cpp index 1dddb04310..37514b60d9 100644 --- a/plugins/CmdLine/src/utils.cpp +++ b/plugins/CmdLine/src/utils.cpp @@ -48,7 +48,7 @@ int Log(char *format, ...) fputs(str, fout);
va_start(vararg, format);
- tBytes = _vsnprintf(str, sizeof(str), format, vararg);
+ tBytes = mir_vsnprintf(str, sizeof(str), format, vararg);
if (tBytes > 0)
{
str[tBytes] = 0;
@@ -71,7 +71,7 @@ int Info(char *title, char *format, ...) va_list vararg;
int tBytes;
va_start(vararg, format);
- tBytes = _vsnprintf(str, sizeof(str), format, vararg);
+ tBytes = mir_vsnprintf(str, sizeof(str), format, vararg);
if (tBytes > 0)
{
str[tBytes] = 0;
@@ -102,12 +102,12 @@ char *BinToHex(int size, PBYTE data) int maxSize = size * 2 + HEX_SIZE + 1;
szresult = (char *) new char[ maxSize ];
memset(szresult, 0, maxSize);
- sprintf(buffer, "%0*X", HEX_SIZE, size);
+ mir_snprintf(buffer, SIZEOF(buffer), "%0*X", HEX_SIZE, size);
strcpy(szresult, buffer);
int i;
for (i = 0; i < size; i++)
{
- sprintf(buffer, "%02X", data[i]);
+ mir_snprintf(buffer, SIZEOF(buffer), "%02X", data[i]);
strcpy(szresult + (HEX_SIZE + i * 2), buffer);
}
return szresult;
@@ -290,7 +290,7 @@ TCHAR *GetContactID(HANDLE hContact, char *szProto) {
case CNFT_BYTE:
{
- _stprintf(tmp, _T("%d"), ctInfo.bVal);
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%d"), ctInfo.bVal);
buffer = _tcsdup(tmp);
break;
@@ -298,7 +298,7 @@ TCHAR *GetContactID(HANDLE hContact, char *szProto) case CNFT_WORD:
{
- _stprintf(tmp, _T("%d"), ctInfo.wVal);
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%d"), ctInfo.wVal);
buffer = _tcsdup(tmp);
break;
@@ -306,7 +306,7 @@ TCHAR *GetContactID(HANDLE hContact, char *szProto) case CNFT_DWORD:
{
- _stprintf(tmp, _T("%ld"), ctInfo.dVal);
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%ld"), ctInfo.dVal);
buffer = _tcsdup(tmp);
break;
diff --git a/plugins/DbChecker/src/selectdb.cpp b/plugins/DbChecker/src/selectdb.cpp index dbd7e8baaa..a28d44223a 100644 --- a/plugins/DbChecker/src/selectdb.cpp +++ b/plugins/DbChecker/src/selectdb.cpp @@ -119,10 +119,10 @@ static int AddDatabaseToList(HWND hwndList, const TCHAR* filename, TCHAR* dir) int iNewItem = ListView_InsertItem(hwndList, &lvi);
TCHAR szSize[20];
- _stprintf(szSize, _T("%.2lf MB"), totalSize/1048576.0);
+ mir_sntprintf(szSize, SIZEOF(szSize), _T("%.2lf MB"), totalSize / 1048576.0);
ListView_SetItemText(hwndList, iNewItem, 1, szSize);
if (!broken) {
- _stprintf(szSize, _T("%.2lf MB"), wasted/1048576.0);
+ mir_sntprintf(szSize, SIZEOF(szSize), _T("%.2lf MB"), wasted / 1048576.0);
ListView_SetItemText(hwndList, iNewItem, 2, szSize);
}
return iNewItem;
@@ -143,7 +143,7 @@ void FindAdd(HWND hdlg, TCHAR *szProfileDir, TCHAR *szPrefix) if ( !(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || !_tcscmp(fd.cFileName, _T(".")) || !_tcscmp(fd.cFileName, _T("..")))
continue;
- wsprintf(szFilename, _T("%s\\%s\\%s.dat"), szProfileDir, fd.cFileName, fd.cFileName);
+ mir_sntprintf(szFilename, SIZEOF(szFilename), _T("%s\\%s\\%s.dat"), szProfileDir, fd.cFileName, fd.cFileName);
if ( _taccess(szFilename, 0) == 0)
AddDatabaseToList(GetDlgItem(hdlg, IDC_DBLIST), szFilename, szPrefix);
}
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp index b6e598b39e..7bd1d692b7 100644 --- a/plugins/DbChecker/src/worker.cpp +++ b/plugins/DbChecker/src/worker.cpp @@ -53,8 +53,10 @@ static void Finalize(time_t& ts) dbPath[0] = 0;
}
for (int i = 1;;i++) {
- if (i == 1) wsprintf(opts.backupFilename,TranslateT("%s\\Backup of %s"),dbPath,dbFile);
- else wsprintf(opts.backupFilename,TranslateT("%s\\Backup (%d) of %s"),dbPath,i,dbFile);
+ if (i == 1)
+ mir_sntprintf(opts.backupFilename, SIZEOF(opts.backupFilename), TranslateT("%s\\Backup of %s"), dbPath, dbFile);
+ else
+ mir_sntprintf(opts.backupFilename, SIZEOF(opts.backupFilename), TranslateT("%s\\Backup (%d) of %s"), dbPath, i, dbFile);
if (_taccess(opts.backupFilename,0) == -1) break;
}
diff --git a/plugins/DbEditorPP/src/addeditsettingsdlg.cpp b/plugins/DbEditorPP/src/addeditsettingsdlg.cpp index 1c0b10a32d..72ba0e7e24 100644 --- a/plugins/DbEditorPP/src/addeditsettingsdlg.cpp +++ b/plugins/DbEditorPP/src/addeditsettingsdlg.cpp @@ -1,6 +1,5 @@ #include "headers.h"
-
static BOOL Convert(HANDLE hContact, char* module, char* setting, int value, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string
{
int Result = 1;
@@ -283,7 +282,7 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l setting = (char*)_alloca(settingLength + 1);
if (setting)
{
- // havta convert it with sprintf()
+ // havta convert it with mir_snprintf()
GetWindowText(GetDlgItem(hwnd, IDC_SETTINGVALUE), setting, settingLength+1);
if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL))
{
diff --git a/plugins/HTTPServer/src/IndexHTML.cpp b/plugins/HTTPServer/src/IndexHTML.cpp index 2a5f70f341..651b74c867 100644 --- a/plugins/HTTPServer/src/IndexHTML.cpp +++ b/plugins/HTTPServer/src/IndexHTML.cpp @@ -223,10 +223,6 @@ bool LoadIndexHTMLTemplate() { break; // Error - End missing
}
- //char Temp[100];
- //sprintf(Temp, "Tag: %i Begin: %i End: %i", *(pszBuf-1), pszBuf-szDestBuf, pszBuf-szDestBuf+pszLevelEnd-pszBuf);
- //LogEvent("Jump", Temp);
-
// write jump address
*((WORD*)(pszBuf)) = (WORD)((pszLevelEnd - pszBuf - 1) | 0x8000);
pszBuf += 2;
@@ -414,13 +410,13 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, case SY_FILE_NAME:
case SY_DIR_NAME: {
- pszBuffer += _snprintf(pszBuffer, 250, "%s", szName);
+ pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szName);
break;
}
case SY_DIR_URL: {
case SY_FILE_URL:
- pszBuffer += _snprintf(pszBuffer, 250, "%s", szURL);
+ pszBuffer += mir_snprintf(pszBuffer, 250, "%s", szURL);
break;
}
@@ -431,7 +427,7 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, (*pszPos == SY_FILE_CREATE_TIME) ? &ftFileCreateTime : &ftFileModifyTime,
&systemTime);
- pszBuffer += _snprintf(pszBuffer, 100, "%i/%02i/%02i %i:%02i:%02i",
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%i/%02i/%02i %i:%02i:%02i",
systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond);
break;
@@ -439,11 +435,11 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, case SY_FILE_SIZE: {
if ((iFileSize >> 10) == 0)
- pszBuffer += _snprintf(pszBuffer, 100, "%i Byte", iFileSize);
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%i Byte", iFileSize);
else if ((iFileSize >> 20) == 0)
- pszBuffer += _snprintf(pszBuffer, 100, "%.1f KB", (float)(iFileSize) / 1024.0f);
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f KB", (float)(iFileSize) / 1024.0f);
else
- pszBuffer += _snprintf(pszBuffer, 100, "%.1f MB", (float)(iFileSize) / (1024.0f * 1024.0f));
+ pszBuffer += mir_snprintf(pszBuffer, 100, "%.1f MB", (float)(iFileSize) / (1024.0f * 1024.0f));
break;
}
diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp index 042702089c..b48476b063 100644 --- a/plugins/IEView/src/TemplateHTMLBuilder.cpp +++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp @@ -214,9 +214,9 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr *szNoAvatarPathTmp = 0;
_tcscat(szNoAvatarPath, _T("\\noavatar.png"));
if (_taccess(szNoAvatarPath, 0) == -1)
- sprintf(tempStr, "%snoavatar.jpg", tempBase);
+ mir_snprintf(tempStr, SIZEOF(tempStr), "%snoavatar.jpg", tempBase);
else
- sprintf(tempStr, "%snoavatar.png", tempBase);
+ mir_snprintf(tempStr, SIZEOF(tempStr), "%snoavatar.png", tempBase);
szNoAvatar = mir_utf8encode(tempStr);
szAvatarIn = getAvatar(event->hContact, szRealProto);
if (szAvatarIn == NULL) {
@@ -390,9 +390,9 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, *szNoAvatarPathTmp = 0;
_tcscat(szNoAvatarPath, _T("\\noavatar.png"));
if (_taccess(szNoAvatarPath, 0) == -1)
- sprintf(tempStr, "%snoavatar.jpg", tempBase);
+ mir_snprintf(tempStr, SIZEOF(tempStr), "%snoavatar.jpg", tempBase);
else
- sprintf(tempStr, "%snoavatar.png", tempBase);
+ mir_snprintf(tempStr, SIZEOF(tempStr), "%snoavatar.png", tempBase);
szNoAvatar = mir_utf8encode(tempStr);
if(event->hContact != NULL)
szAvatarIn = getAvatar(event->hContact, szRealProto);
@@ -446,12 +446,12 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, if (isSent) {
szAvatar = szAvatarOut;
szUIN = szUINOut;
- sprintf(szCID, "%d", 0);
+ mir_snprintf(szCID, SIZEOF(szCID), "%d", 0);
}
else {
szAvatar = szAvatarIn;
szUIN = szUINIn;
- sprintf(szCID, "%d", (int)event->hContact);
+ mir_snprintf(szCID, SIZEOF(szCID), "%d", (int)event->hContact);
}
tmpltName[0] = groupTemplate;
tmpltName[1] = NULL;
diff --git a/plugins/MirFox/src/MirfoxMiranda.cpp b/plugins/MirFox/src/MirfoxMiranda.cpp index 13a302996f..0c031276a7 100644 --- a/plugins/MirFox/src/MirfoxMiranda.cpp +++ b/plugins/MirFox/src/MirfoxMiranda.cpp @@ -145,7 +145,7 @@ CMirfoxMiranda::initializeSharedMemoryData(MirfoxData& mirfoxData, SharedMemoryU } else {
mirfoxData.processCsmId = result.processCsmId;
wchar_t prefix[7];
- wsprintf(prefix, L"MNG%d", result.processCsmId);
+ mir_sntprintf(prefix, SIZEOF(prefix), L"MNG%d", result.processCsmId);
logger->set6CharsPrefix(prefix);
}
diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp index 3b4a2f12fb..23398db07f 100755 --- a/plugins/Msg_Export/src/FileViewer.cpp +++ b/plugins/Msg_Export/src/FileViewer.cpp @@ -198,12 +198,12 @@ int CLStreamRTFInfo::nWriteHeader( char *pszTarget, int nLen ) */
char szRtfHeader[400];
- int nSrcLen = _snprintf( szRtfHeader, sizeof( szRtfHeader ),
+ int nSrcLen = mir_snprintf(szRtfHeader, SIZEOF(szRtfHeader),
"{\\rtf1\\ansi\r\n"
"{\\colortbl ;\\red%d\\green%d\\blue%d;\\red%d\\green%d\\blue%d;}\r\n"
"\\viewkind4\\uc1\\pard\\cf2 ",
- GetRValue( cMyText) ,GetGValue( cMyText) ,GetBValue( cMyText ),
- GetRValue( cYourText ),GetGValue( cYourText ),GetBValue( cYourText));
+ GetRValue(cMyText), GetGValue(cMyText), GetBValue(cMyText),
+ GetRValue(cYourText), GetGValue(cYourText), GetBValue(cYourText));
if (nSrcLen > nLen )
{
@@ -377,7 +377,7 @@ int CLStreamRTFInfo::nLoadFileStream( LPBYTE pbBuff, LONG cb ) SetFilePointer(hFile,n-dwRead,NULL,FILE_CURRENT);
break;
}
- dwCurrent += sprintf( (char*)&pbBuff[dwCurrent], "\\u%d?", nValue );
+ dwCurrent += sprintf( (char*)&pbBuff[dwCurrent], "\\u%d?", nValue ); //!!!!!!!!!
//continue;
/* // Then we have an extended char in the UTF8 file.
// we need to convert this to UCS-2 and then to \uN in the RTF
@@ -663,9 +663,9 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg ) TCHAR szTmp[1500];
if (nDBCount == -1 )
- mir_sntprintf(szTmp, 1499, LPGENT("Failed to open file\r\n%s\r\n\r\nContact handle is invalid"), pclDlg->sPath.c_str());
+ mir_sntprintf(szTmp, 1499, TranslateT("Failed to open file\r\n%s\r\n\r\nContact handle is invalid"), pclDlg->sPath.c_str());
else
- mir_sntprintf( szTmp, 1499, LPGENT("Failed to open file\r\n%s\r\n\r\nMiranda database contains %d events"), pclDlg->sPath.c_str(), nDBCount );
+ mir_sntprintf(szTmp, 1499, TranslateT("Failed to open file\r\n%s\r\n\r\nMiranda database contains %d events"), pclDlg->sPath.c_str(), nDBCount);
SETTEXTEX stText = {0};
stText.codepage = CP_ACP;
@@ -730,7 +730,7 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg ) //delete [] pabFileData;
TCHAR szTmp[100];
- mir_sntprintf( szTmp, 99, _T("File open time %d\n"), GetTickCount() - dwStart );
+ mir_sntprintf(szTmp, 99, _T("File open time %d\n"), GetTickCount() - dwStart);
OutputDebugString( szTmp );
GETTEXTLENGTHEX sData = { 0 };
@@ -743,7 +743,7 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg ) if ( !bScrollToBottom )
SendMessage( hRichEdit, EM_SETSCROLLPOS, 0, (LPARAM) &ptOldPos );
- mir_sntprintf( szTmp, 99, LPGENT("With scroll to bottom %d\n"), GetTickCount() - dwStart );
+ mir_sntprintf(szTmp, 99, TranslateT("With scroll to bottom %d\n"), GetTickCount() - dwStart);
OutputDebugString( szTmp );
return true;
@@ -1082,7 +1082,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, if (n != sPath.npos )
sPath.erase( 0, n + 1 );
- if (_sntprintf( szTitle, sizeof( szTitle ), szFormat, pszNick, sPath.c_str(), (pclDlg->bUtf8File ? _T("UTF8"):_T("ANSI"))) > 0 )
+ if (mir_sntprintf(szTitle, SIZEOF(szTitle), szFormat, pszNick, sPath.c_str(), (pclDlg->bUtf8File ? _T("UTF8"):_T("ANSI"))) > 0)
SetWindowText( hwndDlg, szTitle);
}
}
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index adcaf3f94b..a05718e66f 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -235,7 +235,7 @@ void DisplayLastError(const TCHAR *pszError) DWORD error = GetLastError();
TCHAR szTemp[50];
- _sntprintf(szTemp, sizeof(szTemp), _T("\r\nErrorCode: %d\r\n"), error);
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("\r\nErrorCode: %d\r\n"), error);
sError += szTemp;
sError += sGetErrorString(error);
MessageBox(NULL, sError.c_str(), MSG_BOX_TITEL, MB_OK);
@@ -520,7 +520,7 @@ bool bWriteHexToFile( HANDLE hFile, void * pData, int nSize ) BYTE * p = (BYTE*)pData;
for( int n = 0 ; n < nSize ; n++ )
{
- sprintf( cBuf, "%.2X ", p[n] );
+ mir_snprintf(cBuf, SIZEOF(cBuf), "%.2X ", p[n]);
if ( !bWriteToFile( hFile, cBuf, 3))
return false;
}
@@ -651,7 +651,7 @@ tstring GetFilePathFromUser( HANDLE hContact ) if (enRenameAction != eDAAutomatic )
{
tstring sRemoteUser = NickFromHandle(hContact);
- _sntprintf( szTemp, sizeof( szTemp ),
+ mir_sntprintf(szTemp, SIZEOF(szTemp),
TranslateT("File name for the user \"%s\" has changed!\n\nfrom:\t%s\nto:\t%s\n\nDo you wish to rename file?"),
sRemoteUser.c_str(),
sPrevFileName.c_str(),
@@ -672,7 +672,7 @@ tstring GetFilePathFromUser( HANDLE hContact ) while( ! MoveFile( sPrevFileName.c_str(), sFilePath.c_str()))
{
- _sntprintf( szTemp, sizeof( szTemp ),
+ mir_sntprintf(szTemp, SIZEOF(szTemp),
TranslateT("Failed to rename file\n\nfrom:\t%s\nto:\t%s\n\nFailed with error: %s"),
sPrevFileName.c_str(),
sFilePath.c_str(),
@@ -776,7 +776,7 @@ void ReplaceDefines( HANDLE hContact, tstring & sTarget ) if (dwUIN )
{
TCHAR sTmp[20];
- _sntprintf( sTmp, sizeof( sTmp ),_T("%d"), dwUIN );
+ mir_sntprintf(sTmp, SIZEOF(sTmp), _T("%d"), dwUIN);
sReplaceUin = sTmp;
}
else
@@ -873,11 +873,11 @@ void ReplaceTimeVariables( tstring &sRet ) GetLocalTime( &stTime );
TCHAR sTmp[20];
- _sntprintf( sTmp, sizeof( sTmp ),_T("%d"), stTime.wYear );
+ mir_sntprintf(sTmp, SIZEOF(sTmp), _T("%d"), stTime.wYear);
ReplaceAll( sRet, _T("%year%"), sTmp );
- _sntprintf( sTmp, sizeof( sTmp ),_T("%.2d"), stTime.wMonth );
+ mir_sntprintf(sTmp, SIZEOF(sTmp), _T("%.2d"), stTime.wMonth);
ReplaceAll( sRet, _T("%month%"), sTmp );
- _sntprintf( sTmp, sizeof( sTmp ),_T("%.2d"), stTime.wDay );
+ mir_sntprintf(sTmp, SIZEOF(sTmp), _T("%.2d"), stTime.wDay);
ReplaceAll( sRet, _T("%day%"), sTmp );
}
}
@@ -1108,10 +1108,10 @@ void ExportDBEventInfo(HANDLE hContact, DBEVENTINFO &dbei ) ReplaceAll( output, pszReplaceList[nCur], _DBGetString( hContact, sProto.c_str(), pszReplaceListA[nCur], _T("")));
}
- _sntprintf( szTemp, sizeof( szTemp ), _T("%d"), db_get_dw(hContact, sProto.c_str(), "UIN", 0));
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), db_get_dw(hContact, sProto.c_str(), "UIN", 0));
ReplaceAll( output, _T("%UIN%"), szTemp );
- _sntprintf( szTemp, sizeof( szTemp ), _T("%d"), db_get_w(hContact, sProto.c_str(), "Age", 0));
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), db_get_w(hContact, sProto.c_str(), "Age", 0));
ReplaceAll( output, _T("%Age%"), szTemp );
szTemp[0] = (TCHAR)db_get_b(hContact, sProto.c_str(), "Gender", 0);
@@ -1130,7 +1130,7 @@ void ExportDBEventInfo(HANDLE hContact, DBEVENTINFO &dbei ) int nIndent;
{ // Get time stamp
- nIndent = _sntprintf( szTemp, sizeof( szTemp ), _T("%-*s"),
+ nIndent = mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%-*s"),
nFirstColumnWidth,
dbei.flags & DBEF_SENT ? sLocalUser.c_str() : sRemoteUser.c_str());
@@ -1253,7 +1253,7 @@ void ExportDBEventInfo(HANDLE hContact, DBEVENTINFO &dbei ) if (dbei.cbBlob < 8 || dbei.cbBlob > 5000 )
{
- int n = _sntprintf( szTemp, sizeof( szTemp ), LPGENT("Invalid Database event received. Type %d, size %d"),dbei.eventType, dbei.cbBlob );
+ int n = mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Invalid Database event received. Type %d, size %d"), dbei.eventType, dbei.cbBlob);
if ( !bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, n))
DisplayErrorDialog( LPGENT("Failed to write Invalid Database event the file :\n"), sFilePath, &dbei );
break;
@@ -1284,7 +1284,7 @@ void ExportDBEventInfo(HANDLE hContact, DBEVENTINFO &dbei ) bWriteTextToFile( hFile, LPGENT("UIN :"), bWriteUTF8Format))
{
DWORD uin = *((PDWORD)(dbei.pBlob));
- int n = _sntprintf( szTemp, sizeof( szTemp ),_T("%d"), uin );
+ int n = mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), uin);
if (bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, n))
{
char *pszEnd = (char *) (dbei.pBlob + dbei.cbSize);
@@ -1372,7 +1372,7 @@ void ExportDBEventInfo(HANDLE hContact, DBEVENTINFO &dbei ) }
default:
{
- int n = _sntprintf( szTemp, sizeof( szTemp ), LPGENT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob );
+ int n = mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob);
if ( !bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, n))
{
DisplayErrorDialog( LPGENT("Failed to write Unknown event to the file :\n"), sFilePath, &dbei );
@@ -1383,7 +1383,7 @@ void ExportDBEventInfo(HANDLE hContact, DBEVENTINFO &dbei ) }
else
{
- int n = _sntprintf( szTemp, sizeof( szTemp ), LPGENT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob );
+ int n = mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob);
bWriteTextToFile( hFile, szTemp, bWriteUTF8Format, n );
}
bWriteToFile( hFile, bAppendNewLine ? "\r\n\r\n" : "\r\n" );
@@ -1428,7 +1428,7 @@ int nExportEvent(WPARAM wparam,LPARAM lparam) if ( !db_event_get(hDbEvent, &dbei)) {
if (dbei.eventType != EVENTTYPE_STATUSCHANGE) {
char szTemp[500];
- _snprintf( szTemp, sizeof( szTemp ), "DisableProt_%s", dbei.szModule );
+ mir_snprintf(szTemp, SIZEOF(szTemp), "DisableProt_%s", dbei.szModule);
if (db_get_b(NULL,MODULE,szTemp,1))
ExportDBEventInfo( hContact, dbei );
}
@@ -1614,7 +1614,7 @@ int nContactDeleted(WPARAM wparam,LPARAM /*lparam*/) CloseHandle( hPrevFile );
TCHAR szTemp[500];
- _sntprintf( szTemp, sizeof( szTemp ), _T("%s\r\n%s"),
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s\r\n%s"),
TranslateT("User has been deleted do you want to delete the file?"), sFilePath.c_str());
if (enDeleteAction == eDAAutomatic ||
@@ -1622,9 +1622,9 @@ int nContactDeleted(WPARAM wparam,LPARAM /*lparam*/) {
if ( !DeleteFile( sFilePath.c_str()))
{
- _sntprintf( szTemp, sizeof( szTemp ),
+ mir_sntprintf(szTemp, SIZEOF(szTemp),
_T("%s\r\n%s"),
- LPGENT("Failed to delete the file"),
+ TranslateT("Failed to delete the file"),
sFilePath.c_str());
DisplayLastError( szTemp );
diff --git a/plugins/NewXstatusNotify/src/utils.cpp b/plugins/NewXstatusNotify/src/utils.cpp index fddbc148f1..ecbcb36a79 100644 --- a/plugins/NewXstatusNotify/src/utils.cpp +++ b/plugins/NewXstatusNotify/src/utils.cpp @@ -55,7 +55,7 @@ int DBGetStringDefault(HANDLE hContact, const char *szModule, const char *szSett void HigherLower(int maxValue, int minValue)
{
TCHAR str[64] = { 0 };
- wsprintf(str, TranslateT("You cannot specify a value lower than %d and higher than %d."), minValue, maxValue);
+ mir_sntprintf(str, SIZEOF(str), TranslateT("You cannot specify a value lower than %d and higher than %d."), minValue, maxValue);
}
void ShowLog(TCHAR *file)
diff --git a/plugins/Non-IM Contact/src/timer.cpp b/plugins/Non-IM Contact/src/timer.cpp index 0abd79e458..68d91c7c3d 100644 --- a/plugins/Non-IM Contact/src/timer.cpp +++ b/plugins/Non-IM Contact/src/timer.cpp @@ -23,7 +23,7 @@ void timerFunc(LPVOID di) /* update the web pages*/
for (int i=0; ;i++) {
- sprintf(fn, "fn%d", i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
if (!db_get_static(NULL, MODNAME, fn, text))
break;
diff --git a/plugins/Ping/src/pinggraph.cpp b/plugins/Ping/src/pinggraph.cpp index b655cdc24f..59947ed7d9 100644 --- a/plugins/Ping/src/pinggraph.cpp +++ b/plugins/Ping/src/pinggraph.cpp @@ -190,20 +190,20 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar char buff[64];
if(wd->show_grid)
{
- sprintf(buff, Translate("%d ms"), MARK_TIME);
+ mir_snprintf(buff, SIZEOF(buff), Translate("%d ms"), MARK_TIME);
TextOut(hdc, r.right - 100, r.bottom - (int)(unit_height * MARK_TIME + 0.5f), buff, strlen(buff));
}
if (wd->show_stat)
{
SetTextColor(hdc, RGB(255, 0, 0));
- sprintf(buff, Translate("AVG %.1lf ms"), avg);
+ mir_snprintf(buff, SIZEOF(buff), Translate("AVG %.1lf ms"), avg);
TextOut(hdc, r.left + 10, r.bottom - (int)(avg * unit_height + 0.5f), buff, strlen(buff));
if (max_value != avg)
{
- sprintf(buff, Translate("MAX %hd ms"), max_value);
+ mir_snprintf(buff, SIZEOF(buff), Translate("MAX %hd ms"), max_value);
TextOut(hdc, r.left + 10, r.bottom - (int)(max_value * unit_height + 0.5f), buff, strlen(buff));
- sprintf(buff, Translate("MIN %hd ms"), min_value);
+ mir_snprintf(buff, SIZEOF(buff), Translate("MIN %hd ms"), min_value);
TextOut(hdc, r.left + 10, r.bottom - (int)(min_value * unit_height + 0.5f), buff, strlen(buff));
}
}
@@ -232,7 +232,7 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar WindowData *wd = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
{
char buff[30];
- sprintf(buff, "pinggraphwnd%d", wd->item_id);
+ mir_snprintf(buff, SIZEOF(buff), "pinggraphwnd%d", wd->item_id);
Utils_SaveWindowPosition(hwnd, 0, PLUG, buff);
}
}
@@ -242,7 +242,7 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar WindowData *wd = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
{
char buff[30];
- sprintf(buff, "WindowHandle%d", wd->item_id);
+ mir_snprintf(buff, SIZEOF(buff), "WindowHandle%d", wd->item_id);
db_set_dw(0, PLUG, buff, 0);
}
delete wd;
@@ -255,7 +255,7 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) {
char buff[30];
- sprintf(buff, "WindowHandle%d", (DWORD)wParam);
+ mir_snprintf(buff, SIZEOF(buff), "WindowHandle%d", (DWORD)wParam);
HWND hGraphWnd = (HWND)db_get_dw(0, PLUG, buff, 0);
if(hGraphWnd) {
ShowWindow(hGraphWnd, SW_SHOW);
@@ -299,7 +299,7 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) { SetWindowLongPtr(hGraphWnd, GWLP_USERDATA, (LONG_PTR)wd);
- sprintf(buff, "pinggraphwnd%d", wd->item_id);
+ mir_snprintf(buff, SIZEOF(buff), "pinggraphwnd%d", wd->item_id);
Utils_RestoreWindowPosition(hGraphWnd, 0, PLUG, buff);
if(!IsWindowVisible(hGraphWnd))
@@ -315,11 +315,11 @@ void graphs_cleanup() { HWND hwnd;
for(int i = 0; i < list_size; i++) {
- sprintf(buff, "WindowHandle%d", i);
+ mir_snprintf(buff, SIZEOF(buff), "WindowHandle%d", i);
if(hwnd = (HWND)db_get_dw(0, PLUG, buff, 0)) {
DestroyWindow(hwnd);
db_set_dw(0, PLUG, buff, 0);
- sprintf(buff, "WindowWasOpen%d", i);
+ mir_snprintf(buff, SIZEOF(buff), "WindowWasOpen%d", i);
db_set_b(0, PLUG, buff, 1);
}
}
@@ -331,9 +331,9 @@ void graphs_init() { char buff[64];
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
for(pinglist_it i = pl.begin(); i != pl.end(); ++i) {
- sprintf(buff, "WindowHandle%d", i->item_id); // clean up from possible crash
+ mir_snprintf(buff, SIZEOF(buff), "WindowHandle%d", i->item_id); // clean up from possible crash
db_set_dw(0, PLUG, buff, 0);
- sprintf(buff, "WindowWasOpen%d", i->item_id); // restore windows that were open on shutdown
+ mir_snprintf(buff, SIZEOF(buff), "WindowWasOpen%d", i->item_id); // restore windows that were open on shutdown
if(db_get_b(0, PLUG, buff, 0)) {
db_set_b(0, PLUG, buff, 0);
ShowGraph((WPARAM)i->item_id, (LPARAM)i->pszLabel);
diff --git a/plugins/Ping/src/pinglist.cpp b/plugins/Ping/src/pinglist.cpp index 517e984490..1151ba37f6 100644 --- a/plugins/Ping/src/pinglist.cpp +++ b/plugins/Ping/src/pinglist.cpp @@ -57,7 +57,7 @@ INT_PTR GetListSize(WPARAM wParam, LPARAM lParam) void write_ping_address(PINGADDRESS &i)
{
char buff[16];
- sprintf(buff, "PING_DEST_%d", i.index);
+ mir_snprintf(buff, SIZEOF(buff), "PING_DEST_%d", i.index);
if(i.item_id == 0) {
i.item_id = NextID++;
@@ -99,7 +99,7 @@ void write_ping_addresses() do {
found = false;
- sprintf(buff, "PING_DEST_%d", index++);
+ mir_snprintf(buff, SIZEOF(buff), "PING_DEST_%d", index++);
if(db_get_dw(0, buff, "Id", 0) != 0) {
found = true;
db_set_dw(0, buff, "Id", 0);
@@ -111,7 +111,7 @@ bool read_ping_address(PINGADDRESS &pa) { int index = pa.index;
char buff[16];
- sprintf(buff, "PING_DEST_%d", index);
+ mir_snprintf(buff, SIZEOF(buff), "PING_DEST_%d", index);
// return if not more contacts, or only deleted contacts remaining
if((pa.item_id = db_get_dw(0, buff, "Id", 0)) == 0) return false;
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index bf9372c0fa..2d22d3bd81 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -334,9 +334,9 @@ void CALLBACK TimerProc( {
char TBcapt[255];
if (total > 0)
- wsprintf(TBcapt,"Ping (%d/%d)", upCount, total);
+ mir_sntprintf(TBcapt, SIZEOF(TBcapt), "Ping (%d/%d)", upCount, total);
else
- wsprintf(TBcapt,"Ping");
+ mir_sntprintf(TBcapt, SIZEOF(TBcapt), "Ping");
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBNAME,frame_id),(LPARAM)TBcapt);
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME,frame_id),(LPARAM)TBcapt);
diff --git a/plugins/Ping/src/rawping.cpp b/plugins/Ping/src/rawping.cpp index 6b0f152d94..65bc99a775 100644 --- a/plugins/Ping/src/rawping.cpp +++ b/plugins/Ping/src/rawping.cpp @@ -186,7 +186,7 @@ extern int raw_ping(char *host, int timeout) if(reply->type == PT_ICMP_SOURCE_QUENCH) {
char buff[1024];
- sprintf(buff, Translate("Host %s requests that you reduce the amount of traffic you are sending."), host);
+ mir_snprintf(buff, SIZEOF(buff), Translate("Host %s requests that you reduce the amount of traffic you are sending."), host);
MessageBox(0, buff, Translate(PLUG " Warning"), MB_OK | MB_ICONWARNING);
}
diff --git a/plugins/Popup/src/opt_adv.cpp b/plugins/Popup/src/opt_adv.cpp index 33e323618a..6df45bf210 100644 --- a/plugins/Popup/src/opt_adv.cpp +++ b/plugins/Popup/src/opt_adv.cpp @@ -163,7 +163,7 @@ INT_PTR CALLBACK DlgProcPopupAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage(hwnd, IDC_TRANS_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(1,255));
SendDlgItemMessage(hwnd, IDC_TRANS_SLIDER, TBM_SETPOS, TRUE, PopupOptions.Alpha);
mir_subclassWindow(GetDlgItem(hwnd, IDC_TRANS_SLIDER), AlphaTrackBarWndProc);
- wsprintf(tstr, _T("%d%%"), Byte2Percentile(PopupOptions.Alpha));
+ mir_sntprintf(tstr, SIZEOF(tstr), _T("%d%%"), Byte2Percentile(PopupOptions.Alpha));
SetDlgItemText(hwnd, IDC_TRANS_PERCENT, tstr);
CheckDlgButton(hwnd, IDC_TRANS_OPAQUEONHOVER, PopupOptions.OpaqueOnHover);
{
@@ -239,7 +239,7 @@ INT_PTR CALLBACK DlgProcPopupAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDC_TRANS_SLIDER:
PopupOptions.Alpha = (BYTE)SendDlgItemMessage(hwnd,IDC_TRANS_SLIDER, TBM_GETPOS, 0,0);
- wsprintf(tstr, TranslateT("%d%%"), Byte2Percentile(PopupOptions.Alpha));
+ mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("%d%%"), Byte2Percentile(PopupOptions.Alpha));
SetDlgItemText(hwnd, IDC_TRANS_PERCENT, tstr);
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp index 5e87499881..53e9c0028e 100644 --- a/plugins/Popup/src/opt_class.cpp +++ b/plugins/Popup/src/opt_class.cpp @@ -196,11 +196,11 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l case 1: //Treeview part for typ 1 (notification)
mir_snprintf(iconName, sizeof(iconName), "%s_%S_%S", MODULNAME, gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription);
iconIndex = ImageList_ReplaceIcon(hImgLst, -1, IcoLib_GetIcon(iconName));
- wsprintf(itemName, _T("%s/%s"), gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription);
+ mir_sntprintf(itemName, SIZEOF(itemName), _T("%s/%s"), gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription);
break;
case 2: //Treeview part typ 2 (popup class api)
iconIndex = ImageList_ReplaceIcon(hImgLst, -1, gTreeData[i]->pupClass.hIcon);
- wsprintf(itemName, _T("%s/%s"), LPGENT("CLASS Plugins")/*gTreeData[i]->pszTreeRoot*/, gTreeData[i]->pszDescription);
+ mir_sntprintf(itemName, SIZEOF(itemName), _T("%s/%s"), LPGENT("CLASS Plugins")/*gTreeData[i]->pszTreeRoot*/, gTreeData[i]->pszDescription);
break;
}
OptTree_AddItem(hwndTree, itemName, (LPARAM)gTreeData[i], iconIndex);
diff --git a/plugins/Popup/src/opt_skins.cpp b/plugins/Popup/src/opt_skins.cpp index 7d973d90e6..5b3c656684 100644 --- a/plugins/Popup/src/opt_skins.cpp +++ b/plugins/Popup/src/opt_skins.cpp @@ -48,7 +48,7 @@ void RegisterOptPrevBox() err = GetLastError();
if (!g_wndClass.cPopupPreviewBoxWndclass) {
TCHAR msg[1024];
- wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName);
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName);
MSGERROR(msg);
}
@@ -62,7 +62,7 @@ void RegisterOptPrevBox() err = GetLastError();
if (!g_wndClass.cPopupPlusDlgBox) {
TCHAR msg[1024];
- wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName);
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName);
MSGERROR(msg);
}
}
@@ -189,7 +189,7 @@ int SkinOptionList_AddSkin(OPTTREE_OPTION* &options, int *OptionsCount, int pos options[pos].pszOptionName = (LPTSTR)mir_alloc(sizeof(TCHAR)*(
lstrlen(options[pos].pszSettingName)+
lstrlenA(skin->getFlagName(i)) +10 ));
- wsprintf(options[pos].pszOptionName,_T("%s/%hs"), options[pos].pszSettingName, skin->getFlagName(i));
+ wsprintf(options[pos].pszOptionName, _T("%s/%hs"), options[pos].pszSettingName, skin->getFlagName(i)); //!!!!!!!!!!!!!
options[pos].bState = skin->getFlag(i) ? TRUE : FALSE;
options[pos].Data = i; //skin flag index
*dwGlobalOptions |= skin->getFlag(i) ? (1 << (i-1)) : 0;
@@ -252,7 +252,7 @@ int SkinOptionList_AddMain(OPTTREE_OPTION* &options, int *OptionsCount, int pos, options[pos].pszOptionName = (LPTSTR)mir_alloc(sizeof(TCHAR)*(
lstrlen(options[pos].pszSettingName)+
lstrlen(mainOption[i]) + 10));
- wsprintf(options[pos].pszOptionName,_T("%s/%s"), options[pos].pszSettingName, mainOption[i]);
+ wsprintf(options[pos].pszOptionName, _T("%s/%s"), options[pos].pszSettingName, mainOption[i]); //!!!!!!!!!!!!!
options[pos].bState = bCheck;
pos++;
}
diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp index 6bb9084155..cede4d0a00 100644 --- a/plugins/Popup/src/popup_thread.cpp +++ b/plugins/Popup/src/popup_thread.cpp @@ -231,7 +231,7 @@ static void __cdecl PopupThread(void *arg) err = GetLastError();
if (!g_wndClass.cPopupThreadManagerWnd) {
TCHAR msg[1024];
- wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName);
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName);
MSGERROR(msg);
}
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index 158736b427..15dadb8db6 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -71,7 +71,7 @@ bool LoadPopupWnd2() if (!g_wndClass.cPopupWnd2) {
res = false;
TCHAR msg[1024];
- wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName);
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName);
MessageBox(NULL, msg, _T(MODULNAME_LONG), MB_ICONSTOP|MB_OK);
}
@@ -93,7 +93,7 @@ bool LoadPopupWnd2() err = GetLastError();
if (!g_wndClass.cPopupEditBox) {
TCHAR msg[2048];
- wsprintf(msg, LPGENT("Failed to register custom edit box window class.\r\n\r\ncbSize: %i\r\nstyle: %p\r\nlpfnWndProc: %i\r\ncbClsExtra: %i\r\ncbWndExtra: %i\r\nhInstance: %i\r\nhIcon: %i\r\nhCursor: %i\r\nhbrBackground: %i\r\nlpszMenuName: %s\r\nlpszClassName: %s\r\nhIconSm: %i\r\n"),
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register custom edit box window class.\r\n\r\ncbSize: %i\r\nstyle: %p\r\nlpfnWndProc: %i\r\ncbClsExtra: %i\r\ncbWndExtra: %i\r\nhInstance: %i\r\nhIcon: %i\r\nhCursor: %i\r\nhbrBackground: %i\r\nlpszMenuName: %s\r\nlpszClassName: %s\r\nhIconSm: %i\r\n"),
wclw.cbSize, //UINT cbSize;
wclw.style, //UINT style;
wclw.lpfnWndProc, //WNDPROC lpfnWndProc;
@@ -130,7 +130,7 @@ bool LoadPopupWnd2() if (!g_wndClass.cPopupMenuHostWnd) {
res = false;
TCHAR msg[1024];
- wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName);
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName);
MSGERROR(msg);
}
@@ -1182,13 +1182,15 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara char* sztext;
if ((this->m_lpwzText) || (this->m_lpwzTitle))
{
- text = (TCHAR*)mir_alloc((_tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle)+3)*sizeof(TCHAR));
- mir_sntprintf(text, _tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle)+3, _T("%s\n\n%s"), this->m_lpwzTitle, this->m_lpwzText);
+ int size = _tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle) + 3;
+ text = (TCHAR*)mir_alloc(size * sizeof(TCHAR));
+ mir_sntprintf(text, size, _T("%s\n\n%s"), this->m_lpwzTitle, this->m_lpwzText);
}
else if ((this->m_lpzText) || (this->m_lpzTitle))
{
- sztext = (char*)mir_alloc((lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle)+3)*sizeof(char));
- mir_snprintf(sztext, lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle)+3, "%s\n\n%s", this->m_lpzTitle, this->m_lpzText);
+ int size = lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle) + 3;
+ sztext = (char*)mir_alloc(size * sizeof(char));
+ mir_snprintf(sztext, size, "%s\n\n%s", this->m_lpzTitle, this->m_lpzText);
text = mir_a2t(sztext);
}
OpenClipboard(m_hwnd);
diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index 41db518bf8..ef469ca756 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -189,7 +189,7 @@ void RegisterChatFonts( void ) for (i = 0; i < SIZEOF(chatFontOptionsList); i++) {
if (i == 17) continue;
fid.order = index++;
- sprintf(idstr, "Font%d", i);
+ mir_snprintf(idstr, SIZEOF(idstr), "Font%d", i);
strncpy(fid.prefix, idstr, sizeof(fid.prefix));
_tcsncpy(fid.name, chatFontOptionsList[i].szDescr, SIZEOF(fid.name));
fid.deffontsettings.colour = chatFontOptionsList[i].defColour;
@@ -257,16 +257,16 @@ void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour, BOOL chatMode) const FontOptionsList * fontList = chatMode ? chatFontOptionsList : fontOptionsList;
if (colour) {
- wsprintfA(str, "%s%dCol", prefix, i);
+ mir_snprintf(str, SIZEOF(str), "%s%dCol", prefix, i);
*colour = db_get_dw(NULL, module, str, fontList[i].defColour);
}
if (lf) {
- wsprintfA(str, "%s%dSize", prefix, i);
+ mir_snprintf(str, SIZEOF(str), "%s%dSize", prefix, i);
lf->lfHeight = (char) db_get_b(NULL, module, str, fontList[i].defSize);
lf->lfWidth = 0;
lf->lfEscapement = 0;
lf->lfOrientation = 0;
- wsprintfA(str, "%s%dSty", prefix, i);
+ mir_snprintf(str, SIZEOF(str), "%s%dSty", prefix, i);
style = db_get_b(NULL, module, str, fontList[i].defStyle);
lf->lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL;
lf->lfItalic = style & FONTF_ITALIC ? 1 : 0;
@@ -276,14 +276,14 @@ void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour, BOOL chatMode) lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf->lfQuality = DEFAULT_QUALITY;
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- wsprintfA(str, "%s%d", prefix, i);
+ mir_snprintf(str, SIZEOF(str), "%s%d", prefix, i);
if (db_get_ts(NULL, module, str, &dbv))
lstrcpy(lf->lfFaceName, fontList[i].szDefFace);
else {
_tcsncpy(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName));
db_free(&dbv);
}
- wsprintfA(str, "%s%dSet", prefix, i);
+ mir_snprintf(str, SIZEOF(str), "%s%dSet", prefix, i);
lf->lfCharSet = db_get_b(NULL, module, str, MsgDlgGetFontDefaultCharset(lf->lfFaceName));
}
}
@@ -502,9 +502,9 @@ static INT_PTR CALLBACK DlgProcLayoutOptions(HWND hwndDlg, UINT msg, WPARAM wPar SendDlgItemMessage(hwndDlg,IDC_ATRANSPARENCYVALUE,TBM_SETPOS, TRUE, db_get_dw(NULL, SRMMMOD, SRMSGSET_ACTIVEALPHA, SRMSGDEFSET_ACTIVEALPHA));
SendDlgItemMessage(hwndDlg,IDC_ITRANSPARENCYVALUE,TBM_SETRANGE, FALSE, MAKELONG(0,255));
SendDlgItemMessage(hwndDlg,IDC_ITRANSPARENCYVALUE,TBM_SETPOS, TRUE, db_get_dw(NULL, SRMMMOD, SRMSGSET_INACTIVEALPHA, SRMSGDEFSET_INACTIVEALPHA));
- sprintf(str,"%d%%",(int)(100*SendDlgItemMessage(hwndDlg,IDC_ATRANSPARENCYVALUE,TBM_GETPOS,0,0)/255));
+ mir_snprintf(str, SIZEOF(str), "%d%%", (int)(100 * SendDlgItemMessage(hwndDlg, IDC_ATRANSPARENCYVALUE, TBM_GETPOS, 0, 0) / 255));
SetDlgItemTextA(hwndDlg, IDC_ATRANSPARENCYPERC, str);
- sprintf(str,"%d%%",(int)(100*SendDlgItemMessage(hwndDlg,IDC_ITRANSPARENCYVALUE,TBM_GETPOS,0,0)/255));
+ mir_snprintf(str, SIZEOF(str), "%d%%", (int)(100 * SendDlgItemMessage(hwndDlg, IDC_ITRANSPARENCYVALUE, TBM_GETPOS, 0, 0) / 255));
SetDlgItemTextA(hwndDlg, IDC_ITRANSPARENCYPERC, str);
SetDlgItemInt(hwndDlg, IDC_INPUTLINES, db_get_dw(NULL, SRMMMOD, SRMSGSET_AUTORESIZELINES, SRMSGDEFSET_AUTORESIZELINES), FALSE);
SendDlgItemMessage(hwndDlg, IDC_INPUTLINESSPIN, UDM_SETRANGE, 0, MAKELONG(100, 1));
@@ -559,9 +559,9 @@ static INT_PTR CALLBACK DlgProcLayoutOptions(HWND hwndDlg, UINT msg, WPARAM wPar case WM_HSCROLL:
{
char str[10];
- sprintf(str,"%d%%",(int)(100*SendDlgItemMessage(hwndDlg,IDC_ATRANSPARENCYVALUE,TBM_GETPOS,0,0)/256));
+ mir_snprintf(str, SIZEOF(str), "%d%%", (int)(100 * SendDlgItemMessage(hwndDlg, IDC_ATRANSPARENCYVALUE, TBM_GETPOS, 0, 0) / 256));
SetDlgItemTextA(hwndDlg, IDC_ATRANSPARENCYPERC, str);
- sprintf(str,"%d%%",(int)(100*SendDlgItemMessage(hwndDlg,IDC_ITRANSPARENCYVALUE,TBM_GETPOS,0,0)/256));
+ mir_snprintf(str, SIZEOF(str), "%d%%", (int)(100 * SendDlgItemMessage(hwndDlg, IDC_ITRANSPARENCYVALUE, TBM_GETPOS, 0, 0) / 256));
SetDlgItemTextA(hwndDlg, IDC_ITRANSPARENCYPERC, str);
MarkChanges(16, hwndDlg);
}
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 7acb87ab82..3f3a01f577 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -637,13 +637,11 @@ STDMETHODIMP CREOleCallback::GetInPlaceContext(LPOLEINPLACEFRAME * lplpFrame, LP STDMETHODIMP CREOleCallback::GetNewStorage(LPSTORAGE * lplpstg)
{
- WCHAR szwName[64];
- char szName[64];
- wsprintfA(szName, "s%u", nextStgId++);
- MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, SIZEOF(szwName));
+ TCHAR sztName[64];
+ mir_sntprintf(sztName, SIZEOF(sztName), _T("s%u"), nextStgId++);
if (pictStg == NULL)
return STG_E_MEDIUMFULL;
- return pictStg->CreateStorage(szwName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg);
+ return pictStg->CreateStorage(sztName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg);
}
STDMETHODIMP CREOleCallback::QueryAcceptData(LPDATAOBJECT lpdataobj, CLIPFORMAT * lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict)
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index 47d53a7878..2e229a1ccf 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -220,13 +220,13 @@ void getContactUinA(HANDLE hContact, LPSTR szUIN) if (uID == (LPSTR)CALLSERVICE_NOTFOUND ) uID = 0; // Billy_Bons
if (uID && db_get(hContact, ptr->name, uID, &dbv_uniqueid) == 0) {
if (dbv_uniqueid.type == DBVT_WORD)
- sprintf(szUIN, "%u [%s]", dbv_uniqueid.wVal, ptr->name);
+ sprintf(szUIN, "%u [%s]", dbv_uniqueid.wVal, ptr->name); //!!!!!!!!!!!
else if (dbv_uniqueid.type == DBVT_DWORD)
- sprintf(szUIN, "%u [%s]", (UINT)dbv_uniqueid.dVal, ptr->name);
+ sprintf(szUIN, "%u [%s]", (UINT)dbv_uniqueid.dVal, ptr->name); //!!!!!!!!!!!
else if (dbv_uniqueid.type == DBVT_BLOB)
- sprintf(szUIN, "%s [%s]", dbv_uniqueid.pbVal, ptr->name);
+ sprintf(szUIN, "%s [%s]", dbv_uniqueid.pbVal, ptr->name); //!!!!!!!!!!!
else
- sprintf(szUIN, "%s [%s]", dbv_uniqueid.pszVal, ptr->name);
+ sprintf(szUIN, "%s [%s]", dbv_uniqueid.pszVal, ptr->name); //!!!!!!!!!!!
}
else strcpy(szUIN, " == = unknown == =");
diff --git a/plugins/SeenPlugin/src/missed.cpp b/plugins/SeenPlugin/src/missed.cpp index 2ff6abf00c..ae29690d72 100644 --- a/plugins/SeenPlugin/src/missed.cpp +++ b/plugins/SeenPlugin/src/missed.cpp @@ -109,7 +109,7 @@ int ShowMissed(void) for (int loop=0; loop < mcs.count; loop++) {
_tcsncat(sztemp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, mcs.wpcontact[loop], GCDNF_TCHAR), SIZEOF(sztemp));
if ( db_get_b(NULL, S_MOD, "MissedOnes_Count", 0)) {
- wsprintf(szcount, _T(" [%i]"), mcs.times[loop]);
+ mir_sntprintf(szcount, SIZEOF(szcount), _T(" [%i]"), mcs.times[loop]);
_tcscat(sztemp, szcount);
}
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp index 1985c1d31d..6396315d03 100644 --- a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp +++ b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp @@ -86,7 +86,7 @@ void CSendImageShack::Send() { //nlhr.headers[x].szValue = auth; //Basic base-64-authorization
//$header .= "Content-type: multipart/form-data; boundary=" . part::getBoundary() . "\r\n";
- sprintf(m_nlheader_ContentType, "multipart/form-data; boundary=%s", m_MFDRboundary);
+ mir_snprintf(m_nlheader_ContentType, SIZEOF(m_nlheader_ContentType), "multipart/form-data; boundary=%s", m_MFDRboundary);
m_nlhr.headers[m_nlhr.headersCount-1].szName = "Content-Type";
m_nlhr.headers[m_nlhr.headersCount-1].szValue = m_nlheader_ContentType;
} //NETLIBHTTPHEADER end
@@ -235,7 +235,7 @@ void CSendImageShack::MFDR_Reset() { DWORD dwBoundaryRand2 = rand();
mir_freeAndNil(m_MFDRboundary);
- sprintf(Temp, "B-O-U-N-D-A-R-Y%u%u", dwBoundaryRand1, dwBoundaryRand2);
+ mir_snprintf(Temp, SIZEOF(Temp), "B-O-U-N-D-A-R-Y%u%u", dwBoundaryRand1, dwBoundaryRand2);
mir_stradd(m_MFDRboundary,Temp);
}
diff --git a/plugins/TooltipNotify/src/TooltipNotify.cpp b/plugins/TooltipNotify/src/TooltipNotify.cpp index b88f41c71b..f25b549e5a 100644 --- a/plugins/TooltipNotify/src/TooltipNotify.cpp +++ b/plugins/TooltipNotify/src/TooltipNotify.cpp @@ -570,7 +570,7 @@ BOOL CTooltipNotify::OptionsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l case WM_HSCROLL:
{
TCHAR str[10];
- wsprintf(str, _T("%d%%"), 100*SendDlgItemMessage(hDlg, IDC_TRANSPARENCY_SLIDER, TBM_GETPOS, 0, 0)/255);
+ mir_sntprintf(str, SIZEOF(str), _T("%d%%"), 100 * SendDlgItemMessage(hDlg, IDC_TRANSPARENCY_SLIDER, TBM_GETPOS, 0, 0) / 255);
SetDlgItemText(hDlg, IDC_TRANSPERC, str);
if(wParam!=0x12345678) SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
return TRUE;
@@ -934,11 +934,11 @@ TCHAR *CTooltipNotify::MakeTooltipString(HANDLE hContact, int iStatus, TCHAR *sz long lLen = MultiByteToWideChar(CP_ACP, 0, szProto, (int)strlen(szProto), wszProto, SIZEOF(wszProto));
wszProto[lLen] = _T('\0');
- _sntprintf(szString, iBufSize-1, szFormatString, wszProto, _T(": "), szContactName);
+ mir_sntprintf(szString, iBufSize - 1, szFormatString, wszProto, _T(": "), szContactName);
TruncateWithDots(szString, iBufSize-1-_tcslen(szStatus)-_tcslen(szIs)-2); // 2 spaces around szIs
- _sntprintf(szString+_tcslen(szString), iBufSize-1-_tcslen(szString), _T(" %s %s"), szIs, szStatus);
+ mir_sntprintf(szString + _tcslen(szString), iBufSize - 1 - _tcslen(szString), _T(" %s %s"), szIs, szStatus);
return szString;
}
diff --git a/plugins/UserInfoEx/src/ex_import/tinyxml.cpp b/plugins/UserInfoEx/src/ex_import/tinyxml.cpp index b9d491b53e..0faa453a14 100644 --- a/plugins/UserInfoEx/src/ex_import/tinyxml.cpp +++ b/plugins/UserInfoEx/src/ex_import/tinyxml.cpp @@ -1,1955 +1,1934 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier)copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. - -=============================================================================== - -UserinfoEx plugin for Miranda IM - -Copyright: -© 2006-2010 DeathAxe, Yasnovidyashii, Merlin, K. Romanov, Kreol -=============================================================================== - */ - +/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier)copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+
+===============================================================================
+
+UserinfoEx plugin for Miranda IM
+
+Copyright:
+© 2006-2010 DeathAxe, Yasnovidyashii, Merlin, K. Romanov, Kreol
+===============================================================================
+ */
+
#include "..\commonheaders.h"
- -bool TiXmlBase::condenseWhiteSpace = true; - -void TiXmlBase::StreamDepth(TIXML_OSTREAM* stream, int depth) const -{ - for (int i = 0; i < depth; ++i) - { - (*stream) << " "; - } -} - -void TiXmlBase::PutString(const TIXML_STRING& str, TIXML_OSTREAM* stream) -{ - TIXML_STRING buffer; - PutString(str, &buffer); - (*stream) << buffer; -} - -void TiXmlBase::PutString(const TIXML_STRING& str, TIXML_STRING* outString) -{ - int i=0; - - while (i<(int)str.length()) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ((int)str.length() - 2) - && str[i+1] == '#' - && str[i+2] == 'x') - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while (i<(int)str.length()-1) - { - outString->append(str.c_str() + i, 1); - ++i; - if (str[i] == ';') - break; - } - } - else if (c == '&') - { - outString->append(entity[0].str, entity[0].strLength); - ++i; - } - else if (c == '<') - { - outString->append(entity[1].str, entity[1].strLength); - ++i; - } - else if (c == '>') - { - outString->append(entity[2].str, entity[2].strLength); - ++i; - } - else if (c == '\"') - { - outString->append(entity[3].str, entity[3].strLength); - ++i; - } - else if (c == '\'') - { - outString->append(entity[4].str, entity[4].strLength); - ++i; - } - else if (c < 32) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "&#x%02X;", (unsigned) (c & 0xff)); - #else - sprintf(buf, "&#x%02X;", (unsigned) (c & 0xff)); - #endif - - //*ME: warning C4267: convert 'size_t' to 'int' - //*ME: Int-Cast to make compiler happy ... - outString->append(buf, (int)strlen(buf)); - ++i; - } - else - { - //char realc = (char) c; - //outString->append(&realc, 1); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } -} - - -// <-- Strange class for a bug fix. Search for STL_STRING_BUG -TiXmlBase::StringToBuffer::StringToBuffer(const TIXML_STRING& str) -{ - buffer = new char[ str.length()+1 ]; - if (buffer) - { - strcpy(buffer, str.c_str()); - } -} - - -TiXmlBase::StringToBuffer::~StringToBuffer() -{ - delete [] buffer; -} -// End strange bug fix. --> - - -TiXmlNode::TiXmlNode(NodeType _type) : TiXmlBase() -{ - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; -} - - -TiXmlNode::~TiXmlNode() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while (node) - { - temp = node; - node = node->next; - - delete temp; - } -} - - -void TiXmlNode::CopyTo(TiXmlNode* target) const -{ - target->SetValue (value.c_str()); - target->userData = userData; -} - - -void TiXmlNode::Clear() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while (node) - { - temp = node; - node = node->next; - delete temp; - } - - firstChild = 0; - lastChild = 0; -} - - -TiXmlNode* TiXmlNode::LinkEndChild(TiXmlNode* node) -{ - assert(node->parent == 0 || node->parent == this); - assert(node->GetDocument() == 0 || node->GetDocument() == this->GetDocument()); - - if (node->Type() == TiXmlNode::DOCUMENT) - { - delete node; - if (GetDocument()) GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN); - return 0; - } - - node->parent = this; - - node->prev = lastChild; - node->next = 0; - - if (lastChild) - lastChild->next = node; - else - firstChild = node; // it was an empty list. - - lastChild = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertEndChild(const TiXmlNode& addThis) -{ - if (addThis.Type() == TiXmlNode::DOCUMENT) - { - if (GetDocument()) GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN); - return 0; - } - TiXmlNode* node = addThis.Clone(); - if (!node) - return 0; - - return LinkEndChild(node); -} - - -TiXmlNode* TiXmlNode::InsertBeforeChild(TiXmlNode* beforeThis, const TiXmlNode& addThis) -{ - if (!beforeThis || beforeThis->parent != this) { - return 0; - } - if (addThis.Type() == TiXmlNode::DOCUMENT) - { - if (GetDocument()) GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if (!node) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if (beforeThis->prev) - { - beforeThis->prev->next = node; - } - else - { - assert(firstChild == beforeThis); - firstChild = node; - } - beforeThis->prev = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertAfterChild(TiXmlNode* afterThis, const TiXmlNode& addThis) -{ - if (!afterThis || afterThis->parent != this) { - return 0; - } - if (addThis.Type() == TiXmlNode::DOCUMENT) - { - if (GetDocument()) GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if (!node) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if (afterThis->next) - { - afterThis->next->prev = node; - } - else - { - assert(lastChild == afterThis); - lastChild = node; - } - afterThis->next = node; - return node; -} - - -TiXmlNode* TiXmlNode::ReplaceChild(TiXmlNode* replaceThis, const TiXmlNode& withThis) -{ - if (replaceThis->parent != this) - return 0; - - TiXmlNode* node = withThis.Clone(); - if (!node) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if (replaceThis->next) - replaceThis->next->prev = node; - else - lastChild = node; - - if (replaceThis->prev) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; -} - - -bool TiXmlNode::RemoveChild(TiXmlNode* removeThis) -{ - if (removeThis->parent != this) - { - assert(0); - return false; - } - - if (removeThis->next) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if (removeThis->prev) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; - - delete removeThis; - return true; -} - -const TiXmlNode* TiXmlNode::FirstChild(const char * _value) const -{ - const TiXmlNode* node; - for (node = firstChild; node; node = node->next) - { - if (strcmp(node->Value(), _value) == 0) - return node; - } - return 0; -} - - -TiXmlNode* TiXmlNode::FirstChild(const char * _value) -{ - TiXmlNode* node; - for (node = firstChild; node; node = node->next) - { - if (strcmp(node->Value(), _value) == 0) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::LastChild(const char * _value) const -{ - const TiXmlNode* node; - for (node = lastChild; node; node = node->prev) - { - if (strcmp(node->Value(), _value) == 0) - return node; - } - return 0; -} - -TiXmlNode* TiXmlNode::LastChild(const char * _value) -{ - TiXmlNode* node; - for (node = lastChild; node; node = node->prev) - { - if (strcmp(node->Value(), _value) == 0) - return node; - } - return 0; -} - -const TiXmlNode* TiXmlNode::IterateChildren(const TiXmlNode* previous) const -{ - if (!previous) - { - return FirstChild(); - } - else - { - assert(previous->parent == this); - return previous->NextSibling(); - } -} - -TiXmlNode* TiXmlNode::IterateChildren(TiXmlNode* previous) -{ - if (!previous) - { - return FirstChild(); - } - else - { - assert(previous->parent == this); - return previous->NextSibling(); - } -} - -const TiXmlNode* TiXmlNode::IterateChildren(const char * val, const TiXmlNode* previous) const -{ - if (!previous) - { - return FirstChild(val); - } - else - { - assert(previous->parent == this); - return previous->NextSibling(val); - } -} - -TiXmlNode* TiXmlNode::IterateChildren(const char * val, TiXmlNode* previous) -{ - if (!previous) - { - return FirstChild(val); - } - else - { - assert(previous->parent == this); - return previous->NextSibling(val); - } -} - -const TiXmlNode* TiXmlNode::NextSibling(const char * _value) const -{ - const TiXmlNode* node; - for (node = next; node; node = node->next) - { - if (strcmp(node->Value(), _value) == 0) - return node; - } - return 0; -} - -TiXmlNode* TiXmlNode::NextSibling(const char * _value) -{ - TiXmlNode* node; - for (node = next; node; node = node->next) - { - if (strcmp(node->Value(), _value) == 0) - return node; - } - return 0; -} - -const TiXmlNode* TiXmlNode::PreviousSibling(const char * _value) const -{ - const TiXmlNode* node; - for (node = prev; node; node = node->prev) - { - if (strcmp(node->Value(), _value) == 0) - return node; - } - return 0; -} - -TiXmlNode* TiXmlNode::PreviousSibling(const char * _value) -{ - TiXmlNode* node; - for (node = prev; node; node = node->prev) - { - if (strcmp(node->Value(), _value) == 0) - return node; - } - return 0; -} - -void TiXmlElement::RemoveAttribute(const char * name) -{ - TIXML_STRING str(name); - TiXmlAttribute* node = attributeSet.Find(str); - if (node) - { - attributeSet.Remove(node); - delete node; - } -} - -const TiXmlElement* TiXmlNode::FirstChildElement() const -{ - const TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling()) - { - if (node->ToElement()) - return node->ToElement(); - } - return 0; -} - -TiXmlElement* TiXmlNode::FirstChildElement() -{ - TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling()) - { - if (node->ToElement()) - return node->ToElement(); - } - return 0; -} - -const TiXmlElement* TiXmlNode::FirstChildElement(const char * _value) const -{ - const TiXmlNode* node; - - for ( node = FirstChild(_value); - node; - node = node->NextSibling(_value)) - { - if (node->ToElement()) - return node->ToElement(); - } - return 0; -} - -TiXmlElement* TiXmlNode::FirstChildElement(const char * _value) -{ - TiXmlNode* node; - - for ( node = FirstChild(_value); - node; - node = node->NextSibling(_value)) - { - if (node->ToElement()) - return node->ToElement(); - } - return 0; -} - -const TiXmlElement* TiXmlNode::NextSiblingElement() const -{ - const TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling()) - { - if (node->ToElement()) - return node->ToElement(); - } - return 0; -} - -TiXmlElement* TiXmlNode::NextSiblingElement() -{ - TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling()) - { - if (node->ToElement()) - return node->ToElement(); - } - return 0; -} - -const TiXmlElement* TiXmlNode::NextSiblingElement(const char * _value) const -{ - const TiXmlNode* node; - - for ( node = NextSibling(_value); - node; - node = node->NextSibling(_value)) - { - if (node->ToElement()) - return node->ToElement(); - } - return 0; -} - -TiXmlElement* TiXmlNode::NextSiblingElement(const char * _value) -{ - TiXmlNode* node; - - for ( node = NextSibling(_value); - node; - node = node->NextSibling(_value)) - { - if (node->ToElement()) - return node->ToElement(); - } - return 0; -} - - -const TiXmlDocument* TiXmlNode::GetDocument() const -{ - const TiXmlNode* node; - - for (node = this; node; node = node->parent) - { - if (node->ToDocument()) - return node->ToDocument(); - } - return 0; -} - -TiXmlDocument* TiXmlNode::GetDocument() -{ - TiXmlNode* node; - - for (node = this; node; node = node->parent) - { - if (node->ToDocument()) - return node->ToDocument(); - } - return 0; -} - -TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode(TiXmlNode::ELEMENT) -{ - firstChild = lastChild = 0; - value = _value; -} - - -#ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement(const std::string& _value) - : TiXmlNode(TiXmlNode::ELEMENT) -{ - firstChild = lastChild = 0; - value = _value; -} -#endif - - -TiXmlElement::TiXmlElement(const TiXmlElement& copy) - : TiXmlNode(TiXmlNode::ELEMENT) -{ - firstChild = lastChild = 0; - copy.CopyTo(this); -} - - -void TiXmlElement::operator=(const TiXmlElement& base) -{ - ClearThis(); - base.CopyTo(this); -} - - -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} - - -void TiXmlElement::ClearThis() -{ - Clear(); - while (attributeSet.First()) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove(node); - delete node; - } -} - - -const char * TiXmlElement::Attribute(const char * name) const -{ - TIXML_STRING str(name); - const TiXmlAttribute* node = attributeSet.Find(str); - - if (node) - return node->Value(); - - return 0; -} - - -const char * TiXmlElement::Attribute(const char * name, int* i) const -{ - const char * s = Attribute(name); - if (i) - { - if (s) - *i = (int)_atoi64(s); - else - *i = 0; - } - return s; -} - - -const char * TiXmlElement::Attribute(const char * name, double* d) const -{ - const char * s = Attribute(name); - if (d) - { - if (s) - *d = atof(s); - else - *d = 0; - } - return s; -} - - -int TiXmlElement::QueryIntAttribute(const char* name, int* ival) const -{ - TIXML_STRING str(name); - const TiXmlAttribute* node = attributeSet.Find(str); - if (!node) - return TIXML_NO_ATTRIBUTE; - - return node->QueryIntValue(ival); -} - - -int TiXmlElement::QueryDoubleAttribute(const char* name, double* dval) const -{ - TIXML_STRING str(name); - const TiXmlAttribute* node = attributeSet.Find(str); - if (!node) - return TIXML_NO_ATTRIBUTE; - - return node->QueryDoubleValue(dval); -} - - -void TiXmlElement::SetAttribute(const char * name, int val) -{ - char buf[64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", val); - #else - sprintf(buf, "%d", val); - #endif - SetAttribute(name, buf); -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute(const std::string& name, int val) -{ - std::ostringstream oss; - oss << val; - SetAttribute(name, oss.str()); -} -#endif - - -void TiXmlElement::SetDoubleAttribute(const char * name, double val) -{ - char buf[256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%f", val); - #else - sprintf(buf, "%f", val); - #endif - SetAttribute(name, buf); -} - - -void TiXmlElement::SetAttribute(const char * cname, const char * cvalue) -{ - TIXML_STRING _name(cname); - TIXML_STRING _value(cvalue); - - TiXmlAttribute* node = attributeSet.Find(_name); - if (node) - { - node->SetValue(cvalue); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute(cname, cvalue); - if (attrib) - { - attributeSet.Add(attrib); - } - else - { - TiXmlDocument* document = GetDocument(); - if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute(const std::string& name, const std::string& _value) -{ - TiXmlAttribute* node = attributeSet.Find(name); - if (node) - { - node->SetValue(_value); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute(name, _value); - if (attrib) - { - attributeSet.Add(attrib); - } - else - { - TiXmlDocument* document = GetDocument(); - if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN); - } -} -#endif - - -void TiXmlElement::Print(FILE* cfile, int depth) const -{ - int i; - for (i=0; i<depth; i++) - { - fprintf(cfile, " "); - } - - fprintf(cfile, "<%s", value.c_str()); - - const TiXmlAttribute* attrib; - for (attrib = attributeSet.First(); attrib; attrib = attrib->Next()) - { - fprintf(cfile, " "); - attrib->Print(cfile, depth); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a <foo /> node - // 2) An element with only a text child is printed as <foo> text </foo> - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if (!firstChild) - { - fprintf(cfile, " />"); - } - else if (firstChild == lastChild && firstChild->ToText()) - { - fprintf(cfile, ">"); - firstChild->Print(cfile, depth + 1); - fprintf(cfile, "</%s>", value.c_str()); - } - else - { - fprintf(cfile, ">"); - - for (node = firstChild; node; node=node->NextSibling()) - { - if (!node->ToText()) - { - fprintf(cfile, "\n"); - } - node->Print(cfile, depth+1); - } - fprintf(cfile, "\n"); - for (i=0; i<depth; ++i) - fprintf(cfile, " "); - fprintf(cfile, "</%s>", value.c_str()); - } -} - -void TiXmlElement::StreamOut(TIXML_OSTREAM * stream) const -{ - (*stream) << "<" << value; - - const TiXmlAttribute* attrib; - for (attrib = attributeSet.First(); attrib; attrib = attrib->Next()) - { - (*stream) << " "; - attrib->StreamOut(stream); - } - - // If this node has children, give it a closing tag. Else - // make it an empty tag. - TiXmlNode* node; - if (firstChild) - { - (*stream) << ">"; - - for (node = firstChild; node; node=node->NextSibling()) - { - node->StreamOut(stream); - } - (*stream) << "</" << value << ">"; - } - else - { - (*stream) << " />"; - } -} - -void TiXmlElement::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const -{ - // Adding tabs to get the proper tree format - int oldDepth = depth; - StreamDepth(stream, depth); - - // Element name - (*stream) << "<" << value; - - // Attributes - const TiXmlAttribute* attrib; - for (attrib = attributeSet.First(); attrib; attrib = attrib->Next()) - { - (*stream) << " "; - attrib->StreamOut(stream); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a <foo /> node - // 2) An element with only a text child is printed as <foo> text </foo> - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if (!firstChild) - { - (*stream) << " />" << TIXML_ENDL; - } - else if (firstChild == lastChild && firstChild->ToText()) - { - (*stream) << ">"; - firstChild->FormattedStreamOut(stream, depth + 1); - (*stream) << "</" << value << ">" << TIXML_ENDL; - } - else - { - (*stream) << ">" << TIXML_ENDL; - - // Children - depth++; - for (node = firstChild; node; node=node->NextSibling()) - { - node->FormattedStreamOut(stream, depth); - } - StreamDepth(stream, oldDepth); - (*stream) << "</" << value << ">" << TIXML_ENDL; - } -} - -void TiXmlElement::CopyTo(TiXmlElement* target) const -{ - // superclass: - TiXmlNode::CopyTo(target); - - // Element class: - // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; - for ( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next()) - { - target->SetAttribute(attribute->Name(), attribute->Value()); - } - - TiXmlNode* node = 0; - for (node = firstChild; node; node = node->NextSibling()) - { - target->LinkEndChild(node->Clone()); - } -} - - -TiXmlNode* TiXmlElement::Clone() const -{ - TiXmlElement* clone = new TiXmlElement(Value()); - if (!clone) - return 0; - - CopyTo(clone); - return clone; -} - - -const char* TiXmlElement::GetText() const -{ - const TiXmlNode* child = this->FirstChild(); - if (child) { - const TiXmlText* childText = child->ToText(); - if (childText) { - return childText->Value(); - } - } - return 0; -} - - -TiXmlDocument::TiXmlDocument() : TiXmlNode(TiXmlNode::DOCUMENT) -{ - tabsize = 4; - useMicrosoftBOM = false; - ClearError(); -} - -TiXmlDocument::TiXmlDocument(const char * documentName) : TiXmlNode(TiXmlNode::DOCUMENT) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} - - -#ifdef TIXML_USE_STL -TiXmlDocument::TiXmlDocument(const std::string& documentName) : TiXmlNode(TiXmlNode::DOCUMENT) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} -#endif - - -TiXmlDocument::TiXmlDocument(const TiXmlDocument& copy) : TiXmlNode(TiXmlNode::DOCUMENT) -{ - copy.CopyTo(this); -} - - -void TiXmlDocument::operator=(const TiXmlDocument& copy) -{ - Clear(); - copy.CopyTo(this); -} - - -bool TiXmlDocument::LoadFile(TiXmlEncoding encoding) -{ - // See STL_STRING_BUG below. - StringToBuffer buf(value); - - if (buf.buffer && LoadFile(buf.buffer, encoding)) - return true; - - return false; -} - - -bool TiXmlDocument::SaveFile() const -{ - // See STL_STRING_BUG below. - StringToBuffer buf(value); - - if (buf.buffer && SaveFile(buf.buffer)) - return true; - - return false; -} - -#ifdef TIXML_USE_STL -std::string TiXmlDocument::GetAsString() -{ - std::stringstream out; - FormattedStreamOut(&out, 0); - return out.str(); -} -#endif - -bool TiXmlDocument::GetAsCharBuffer(char* buffer, size_t bufferSize) -{ - #ifdef TIXML_USE_STL - std::string data = GetAsString(); - #else - TIXML_OSTREAM data; - FormattedStreamOut(&data, 0); - #endif - - if (bufferSize < data.length()) - { - return false; - } - else - { - strcpy(buffer, data.c_str()); - return true; - } -} - -bool TiXmlDocument::LoadFile(const char* filename, TiXmlEncoding encoding) -{ - // There was a really terrifying little bug here. The code: - // value = filename - // in the STL case, cause the assignment method of the std::string to - // be called. What is strange, is that the std::string had the same - // address as it's c_str() method, and so bad things happen. Looks - // like a bug in the Microsoft STL implementation. - // See STL_STRING_BUG above. - // Fixed with the StringToBuffer class. - value = filename; - - // reading in binary mode so that tinyxml can normalize the EOL - FILE* file = fopen(value.c_str (), "rb"); - - if (file) - { - bool result = LoadFile(file, encoding); - fclose(file); - return result; - } - else - { - SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN); - return false; - } -} - -bool TiXmlDocument::LoadFile(FILE* file, TiXmlEncoding encoding) -{ - if (!file) - { - SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN); - return false; - } - - // Delete the existing data: - Clear(); - location.Clear(); - - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek(file, 0, SEEK_END); - length = ftell(file); - fseek(file, 0, SEEK_SET); - - // Strange case, but good to handle up front. - if (length == 0) - { - SetError(TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN); - return false; - } - - // If we have a file, assume it is all one big XML file, and read it in. - // The document parser may decide the document ends sooner than the entire file, however. - TIXML_STRING data; - data.reserve(length); - - // Subtle bug here. TinyXml did use fgets. But from the XML spec: - // 2.11 End-of-Line Handling - // <snip> - // <quote> - // ...the XML processor MUST behave as if it normalized all line breaks in external - // parsed entities (including the document entity) on input, before parsing, by translating - // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to - // a single #xA character. - // </quote> - // - // It is not clear fgets does that, and certainly isn't clear it works cross platform. - // Generally, you expect fgets to translate from the convention of the OS to the c/unix - // convention, and not work generally. - - /* - while (fgets(buf, sizeof(buf), file)) - { - data += buf; - } - */ - - char* buf = new char[ length+1 ]; - buf[0] = 0; - - if (fread(buf, length, 1, file) != 1) { - delete [] buf; - SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN); - return false; - } - - const char* lastPos = buf; - const char* p = buf; - - buf[length] = 0; - while (*p) { - assert(p < (buf+length)); - if (*p == 0xa) { - // Newline character. No special rules for this. Append all the characters - // since the last string, and include the newline. - data.append(lastPos, (p-lastPos+1)); // append, include the newline - ++p; // move past the newline - lastPos = p; // and point to the new buffer (may be 0) - assert(p <= (buf+length)); - } - else if (*p == 0xd) { - // Carriage return. Append what we have so far, then - // handle moving forward in the buffer. - if ((p-lastPos) > 0) { - data.append(lastPos, p-lastPos); // do not add the CR - } - data += (char)0xa; // a proper newline - - if (*(p+1) == 0xa) { - // Carriage return - new line sequence - p += 2; - lastPos = p; - assert(p <= (buf+length)); - } - else { - // it was followed by something else...that is presumably characters again. - ++p; - lastPos = p; - assert(p <= (buf+length)); - } - } - else { - ++p; - } - } - // Handle any left over characters. - if (p-lastPos) { - data.append(lastPos, p-lastPos); - } - delete [] buf; - buf = 0; - - Parse(data.c_str(), 0, encoding); - - if ( Error()) - return false; - else - return true; -} - - -bool TiXmlDocument::SaveFile(const char * filename) const -{ - // The old c stuff lives on... - FILE* fp = fopen(filename, "w"); - if (fp) - { - bool result = SaveFile(fp); - fclose(fp); - return result; - } - return false; -} - - -bool TiXmlDocument::SaveFile(FILE* fp) const -{ - if (useMicrosoftBOM) - { - const unsigned char TIXML_UTF_LEAD_0 = 0xefU; - const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; - const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - - fputc(TIXML_UTF_LEAD_0, fp); - fputc(TIXML_UTF_LEAD_1, fp); - fputc(TIXML_UTF_LEAD_2, fp); - } - Print(fp, 0); - return true; -} - - -void TiXmlDocument::CopyTo(TiXmlDocument* target) const -{ - TiXmlNode::CopyTo(target); - - target->error = error; - target->errorDesc = errorDesc.c_str (); - - TiXmlNode* node = 0; - for (node = firstChild; node; node = node->NextSibling()) - { - target->LinkEndChild(node->Clone()); - } -} - - -TiXmlNode* TiXmlDocument::Clone() const -{ - TiXmlDocument* clone = new TiXmlDocument(); - if (!clone) - return 0; - - CopyTo(clone); - return clone; -} - - -void TiXmlDocument::Print(FILE* cfile, int depth) const -{ - const TiXmlNode* node; - for (node=FirstChild(); node; node=node->NextSibling()) - { - node->Print(cfile, depth); - fprintf(cfile, "\n"); - } -} - -void TiXmlDocument::StreamOut(TIXML_OSTREAM * out) const -{ - const TiXmlNode* node; - for (node=FirstChild(); node; node=node->NextSibling()) - { - node->StreamOut(out); - - // Special rule for streams: stop after the root element. - // The stream in code will only read one element, so don't - // write more than one. - if (node->ToElement()) - break; - } -} - -void TiXmlDocument::FormattedStreamOut(TIXML_OSTREAM * out, int depth) const -{ - const TiXmlNode* node; - for (node=FirstChild(); node; node=node->NextSibling()) - { - node->FormattedStreamOut(out, depth); - - // Special rule for streams: stop after the root element. - // The stream in code will only read one element, so don't - // write more than one. - if (node->ToElement()) - break; - } -} - -const TiXmlAttribute* TiXmlAttribute::Next() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if (next->value.empty() && next->name.empty()) - return 0; - return next; -} - -TiXmlAttribute* TiXmlAttribute::Next() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if (next->value.empty() && next->name.empty()) - return 0; - return next; -} - -const TiXmlAttribute* TiXmlAttribute::Previous() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if (prev->value.empty() && prev->name.empty()) - return 0; - return prev; -} - -TiXmlAttribute* TiXmlAttribute::Previous() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if (prev->value.empty() && prev->name.empty()) - return 0; - return prev; -} - -void TiXmlAttribute::Print(FILE* cfile, int /*depth*/) const -{ - TIXML_STRING n, v; - - PutString(name, &n); - PutString(value, &v); - - if (value.find ('\"') == TIXML_STRING::npos) - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str()); - else - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str()); -} - - -void TiXmlAttribute::StreamOut(TIXML_OSTREAM * stream) const -{ - if (value.find('\"') != TIXML_STRING::npos) - { - PutString(name, stream); - (*stream) << "=" << "'"; - PutString(value, stream); - (*stream) << "'"; - } - else - { - PutString(name, stream); - (*stream) << "=" << "\""; - PutString(value, stream); - (*stream) << "\""; - } -} - -int TiXmlAttribute::QueryIntValue(int* ival) const -{ - if (sscanf(value.c_str(), "%d", ival) == 1) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -int TiXmlAttribute::QueryDoubleValue(double* dval) const -{ - if (sscanf(value.c_str(), "%lf", dval) == 1) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -void TiXmlAttribute::SetIntValue(int _value) -{ - char buf [64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); - #else - sprintf (buf, "%d", _value); - #endif - SetValue (buf); -} - -void TiXmlAttribute::SetDoubleValue(double _value) -{ - char buf [256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%lf", _value); - #else - sprintf (buf, "%lf", _value); - #endif - SetValue (buf); -} - -int TiXmlAttribute::IntValue() const -{ - return (int)_atoi64(value.c_str ()); -} - -double TiXmlAttribute::DoubleValue() const -{ - return atof (value.c_str ()); -} - - -TiXmlComment::TiXmlComment(const TiXmlComment& copy) : TiXmlNode(TiXmlNode::COMMENT) -{ - copy.CopyTo(this); -} - - -void TiXmlComment::operator=(const TiXmlComment& base) -{ - Clear(); - base.CopyTo(this); -} - - -void TiXmlComment::Print(FILE* cfile, int depth) const -{ - for (int i=0; i<depth; i++) - { - fputs(" ", cfile); - } - fprintf(cfile, "<!--%s-->", value.c_str()); -} - -void TiXmlComment::StreamOut(TIXML_OSTREAM * stream) const -{ - (*stream) << "<!--"; - //PutString(value, stream); - (*stream) << value; - (*stream) << "-->"; -} - -void TiXmlComment::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const -{ - StreamDepth(stream, depth); - - StreamOut(stream); - - (*stream) << TIXML_ENDL; -} - -void TiXmlComment::CopyTo(TiXmlComment* target) const -{ - TiXmlNode::CopyTo(target); -} - - -TiXmlNode* TiXmlComment::Clone() const -{ - TiXmlComment* clone = new TiXmlComment(); - - if (!clone) - return 0; - - CopyTo(clone); - return clone; -} - - -void TiXmlText::Print(FILE* cfile, int depth) const -{ - if (cdata) - { - int i; - fprintf(cfile, "\n"); - for (i=0; i<depth; i++) { - fprintf(cfile, " "); - } - fprintf(cfile, "<![CDATA["); - fprintf(cfile, "%s", value.c_str()); // unformatted output - fprintf(cfile, "]]>\n"); - } - else - { - TIXML_STRING buffer; - PutString(value, &buffer); - fprintf(cfile, "%s", buffer.c_str()); - } -} - - -void TiXmlText::StreamOut(TIXML_OSTREAM * stream) const -{ - if (cdata) - { - (*stream) << "<![CDATA[" << value << "]]>"; - } - else - { - PutString(value, stream); - } -} - -void TiXmlText::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const -{ - if (cdata) - { - (*stream) << TIXML_ENDL; - StreamDepth(stream, depth); - (*stream) << "<![CDATA[" << value << "]]>" << TIXML_ENDL; - } - else - { - PutString(value, stream); - } -} - -void TiXmlText::CopyTo(TiXmlText* target) const -{ - TiXmlNode::CopyTo(target); - target->cdata = cdata; -} - - -TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new TiXmlText(""); - - if (!clone) - return 0; - - CopyTo(clone); - return clone; -} - - -TiXmlDeclaration::TiXmlDeclaration(const char * _version, - const char * _encoding, - const char * _standalone) - : TiXmlNode(TiXmlNode::DECLARATION) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} - - -#ifdef TIXML_USE_STL -TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone) - : TiXmlNode(TiXmlNode::DECLARATION) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} -#endif - - -TiXmlDeclaration::TiXmlDeclaration(const TiXmlDeclaration& copy) - : TiXmlNode(TiXmlNode::DECLARATION) -{ - copy.CopyTo(this); -} - - -void TiXmlDeclaration::operator=(const TiXmlDeclaration& copy) -{ - Clear(); - copy.CopyTo(this); -} - - -void TiXmlDeclaration::Print(FILE* cfile, int /*depth*/) const -{ - fprintf (cfile, "<?xml "); - - if (!version.empty()) - fprintf (cfile, "version=\"%s\" ", version.c_str ()); - if (!encoding.empty()) - fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ()); - if (!standalone.empty()) - fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ()); - fprintf (cfile, "?>"); -} - -void TiXmlDeclaration::StreamOut(TIXML_OSTREAM * stream) const -{ - (*stream) << "<?xml "; - - if (!version.empty()) - { - (*stream) << "version=\""; - PutString(version, stream); - (*stream) << "\" "; - } - if (!encoding.empty()) - { - (*stream) << "encoding=\""; - PutString(encoding, stream); - (*stream) << "\" "; - } - if (!standalone.empty()) - { - (*stream) << "standalone=\""; - PutString(standalone, stream); - (*stream) << "\" "; - } - (*stream) << "?>"; -} - -void TiXmlDeclaration::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const -{ - StreamDepth(stream, depth); - StreamOut(stream); - (*stream) << TIXML_ENDL; -} - -void TiXmlDeclaration::CopyTo(TiXmlDeclaration* target) const -{ - TiXmlNode::CopyTo(target); - - target->version = version; - target->encoding = encoding; - target->standalone = standalone; -} - - -TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new TiXmlDeclaration(); - - if (!clone) - return 0; - - CopyTo(clone); - return clone; -} - - -void TiXmlUnknown::Print(FILE* cfile, int depth) const -{ - for (int i=0; i<depth; i++) - fprintf(cfile, " "); - fprintf(cfile, "<%s>", value.c_str()); -} - - -void TiXmlUnknown::StreamOut(TIXML_OSTREAM * stream) const -{ - (*stream) << "<" << value << ">"; // Don't use entities here! It is unknown. -} - -void TiXmlUnknown::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const -{ - StreamDepth(stream, depth); - (*stream) << "<" << value << ">" << TIXML_ENDL; // Don't use entities here! It is unknown. -} - -void TiXmlUnknown::CopyTo(TiXmlUnknown* target) const -{ - TiXmlNode::CopyTo(target); -} - - -TiXmlNode* TiXmlUnknown::Clone() const -{ - TiXmlUnknown* clone = new TiXmlUnknown(); - - if (!clone) - return 0; - - CopyTo(clone); - return clone; -} - - -TiXmlAttributeSet::TiXmlAttributeSet() -{ - sentinel.next = &sentinel; - sentinel.prev = &sentinel; -} - - -TiXmlAttributeSet::~TiXmlAttributeSet() -{ - assert(sentinel.next == &sentinel); - assert(sentinel.prev == &sentinel); -} - - -void TiXmlAttributeSet::Add(TiXmlAttribute* addMe) -{ - assert(!Find(TIXML_STRING(addMe->Name()))); // Shouldn't be multiply adding to the set. - - addMe->next = &sentinel; - addMe->prev = sentinel.prev; - - sentinel.prev->next = addMe; - sentinel.prev = addMe; -} - -void TiXmlAttributeSet::Remove(TiXmlAttribute* removeMe) -{ - TiXmlAttribute* node; - - for (node = sentinel.next; node != &sentinel; node = node->next) - { - if (node == removeMe) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert(0); // we tried to remove a non-linked attribute. -} - -const TiXmlAttribute* TiXmlAttributeSet::Find(const TIXML_STRING& name) const -{ - const TiXmlAttribute* node; - - for (node = sentinel.next; node != &sentinel; node = node->next) - { - if (node->name == name) - return node; - } - return 0; -} - -TiXmlAttribute* TiXmlAttributeSet::Find(const TIXML_STRING& name) -{ - TiXmlAttribute* node; - - for (node = sentinel.next; node != &sentinel; node = node->next) - { - if (node->name == name) - return node; - } - return 0; -} - -#ifdef TIXML_USE_STL -TIXML_ISTREAM & operator >> (TIXML_ISTREAM & in, TiXmlNode & base) -{ - TIXML_STRING tag; - tag.reserve(8 * 1000); - base.StreamIn(&in, &tag); - - base.Parse(tag.c_str(), 0, TIXML_DEFAULT_ENCODING); - return in; -} -#endif - - -TIXML_OSTREAM & operator<< (TIXML_OSTREAM & out, const TiXmlNode & base) -{ - base.StreamOut (& out); - return out; -} - - -#ifdef TIXML_USE_STL -std::string & operator<< (std::string& out, const TiXmlNode& base) -{ - std::ostringstream os_stream(std::ostringstream::out); - base.StreamOut(&os_stream); - - out.append(os_stream.str()); - return out; -} -#endif - - -TiXmlHandle TiXmlHandle::FirstChild() const -{ - if (node) - { - TiXmlNode* child = node->FirstChild(); - if (child) - return TiXmlHandle(child); - } - return TiXmlHandle(0); -} - - -TiXmlHandle TiXmlHandle::FirstChild(const char * value) const -{ - if (node) - { - TiXmlNode* child = node->FirstChild(value); - if (child) - return TiXmlHandle(child); - } - return TiXmlHandle(0); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement() const -{ - if (node) - { - TiXmlElement* child = node->FirstChildElement(); - if (child) - return TiXmlHandle(child); - } - return TiXmlHandle(0); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement(const char * value) const -{ - if (node) - { - TiXmlElement* child = node->FirstChildElement(value); - if (child) - return TiXmlHandle(child); - } - return TiXmlHandle(0); -} - - -TiXmlHandle TiXmlHandle::Child(int count) const -{ - if (node) - { - int i; - TiXmlNode* child = node->FirstChild(); - for ( i=0; - child && i<count; - child = child->NextSibling(), ++i) - { - // nothing - } - if (child) - return TiXmlHandle(child); - } - return TiXmlHandle(0); -} - - -TiXmlHandle TiXmlHandle::Child(const char* value, int count) const -{ - if (node) - { - int i; - TiXmlNode* child = node->FirstChild(value); - for ( i=0; - child && i<count; - child = child->NextSibling(value), ++i) - { - // nothing - } - if (child) - return TiXmlHandle(child); - } - return TiXmlHandle(0); -} - - -TiXmlHandle TiXmlHandle::ChildElement(int count) const -{ - if (node) - { - int i; - TiXmlElement* child = node->FirstChildElement(); - for ( i=0; - child && i<count; - child = child->NextSiblingElement(), ++i) - { - // nothing - } - if (child) - return TiXmlHandle(child); - } - return TiXmlHandle(0); -} - - -TiXmlHandle TiXmlHandle::ChildElement(const char* value, int count) const -{ - if (node) - { - int i; - TiXmlElement* child = node->FirstChildElement(value); - for ( i=0; - child && i<count; - child = child->NextSiblingElement(value), ++i) - { - // nothing - } - if (child) - return TiXmlHandle(child); - } - return TiXmlHandle(0); -} +
+bool TiXmlBase::condenseWhiteSpace = true;
+
+void TiXmlBase::StreamDepth(TIXML_OSTREAM* stream, int depth) const
+{
+ for (int i = 0; i < depth; ++i)
+ {
+ (*stream) << " ";
+ }
+}
+
+void TiXmlBase::PutString(const TIXML_STRING& str, TIXML_OSTREAM* stream)
+{
+ TIXML_STRING buffer;
+ PutString(str, &buffer);
+ (*stream) << buffer;
+}
+
+void TiXmlBase::PutString(const TIXML_STRING& str, TIXML_STRING* outString)
+{
+ int i=0;
+
+ while (i<(int)str.length())
+ {
+ unsigned char c = (unsigned char) str[i];
+
+ if ( c == '&'
+ && i < ((int)str.length() - 2)
+ && str[i+1] == '#'
+ && str[i+2] == 'x')
+ {
+ // Hexadecimal character reference.
+ // Pass through unchanged.
+ // © -- copyright symbol, for example.
+ //
+ // The -1 is a bug fix from Rob Laveaux. It keeps
+ // an overflow from happening if there is no ';'.
+ // There are actually 2 ways to exit this loop -
+ // while fails (error case) and break (semicolon found).
+ // However, there is no mechanism (currently) for
+ // this function to return an error.
+ while (i<(int)str.length()-1)
+ {
+ outString->append(str.c_str() + i, 1);
+ ++i;
+ if (str[i] == ';')
+ break;
+ }
+ }
+ else if (c == '&')
+ {
+ outString->append(entity[0].str, entity[0].strLength);
+ ++i;
+ }
+ else if (c == '<')
+ {
+ outString->append(entity[1].str, entity[1].strLength);
+ ++i;
+ }
+ else if (c == '>')
+ {
+ outString->append(entity[2].str, entity[2].strLength);
+ ++i;
+ }
+ else if (c == '\"')
+ {
+ outString->append(entity[3].str, entity[3].strLength);
+ ++i;
+ }
+ else if (c == '\'')
+ {
+ outString->append(entity[4].str, entity[4].strLength);
+ ++i;
+ }
+ else if (c < 32)
+ {
+ // Easy pass at non-alpha/numeric/symbol
+ // Below 32 is symbolic.
+ char buf[32];
+ mir_snprintf(buf, SIZEOF(buf), "&#x%02X;", (unsigned) (c & 0xff));
+
+ //*ME: warning C4267: convert 'size_t' to 'int'
+ //*ME: Int-Cast to make compiler happy ...
+ outString->append(buf, (int)strlen(buf));
+ ++i;
+ }
+ else
+ {
+ //char realc = (char) c;
+ //outString->append(&realc, 1);
+ *outString += (char) c; // somewhat more efficient function call.
+ ++i;
+ }
+ }
+}
+
+
+// <-- Strange class for a bug fix. Search for STL_STRING_BUG
+TiXmlBase::StringToBuffer::StringToBuffer(const TIXML_STRING& str)
+{
+ buffer = new char[ str.length()+1 ];
+ if (buffer)
+ {
+ strcpy(buffer, str.c_str());
+ }
+}
+
+
+TiXmlBase::StringToBuffer::~StringToBuffer()
+{
+ delete [] buffer;
+}
+// End strange bug fix. -->
+
+
+TiXmlNode::TiXmlNode(NodeType _type) : TiXmlBase()
+{
+ parent = 0;
+ type = _type;
+ firstChild = 0;
+ lastChild = 0;
+ prev = 0;
+ next = 0;
+}
+
+
+TiXmlNode::~TiXmlNode()
+{
+ TiXmlNode* node = firstChild;
+ TiXmlNode* temp = 0;
+
+ while (node)
+ {
+ temp = node;
+ node = node->next;
+
+ delete temp;
+ }
+}
+
+
+void TiXmlNode::CopyTo(TiXmlNode* target) const
+{
+ target->SetValue (value.c_str());
+ target->userData = userData;
+}
+
+
+void TiXmlNode::Clear()
+{
+ TiXmlNode* node = firstChild;
+ TiXmlNode* temp = 0;
+
+ while (node)
+ {
+ temp = node;
+ node = node->next;
+ delete temp;
+ }
+
+ firstChild = 0;
+ lastChild = 0;
+}
+
+
+TiXmlNode* TiXmlNode::LinkEndChild(TiXmlNode* node)
+{
+ assert(node->parent == 0 || node->parent == this);
+ assert(node->GetDocument() == 0 || node->GetDocument() == this->GetDocument());
+
+ if (node->Type() == TiXmlNode::DOCUMENT)
+ {
+ delete node;
+ if (GetDocument()) GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN);
+ return 0;
+ }
+
+ node->parent = this;
+
+ node->prev = lastChild;
+ node->next = 0;
+
+ if (lastChild)
+ lastChild->next = node;
+ else
+ firstChild = node; // it was an empty list.
+
+ lastChild = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertEndChild(const TiXmlNode& addThis)
+{
+ if (addThis.Type() == TiXmlNode::DOCUMENT)
+ {
+ if (GetDocument()) GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN);
+ return 0;
+ }
+ TiXmlNode* node = addThis.Clone();
+ if (!node)
+ return 0;
+
+ return LinkEndChild(node);
+}
+
+
+TiXmlNode* TiXmlNode::InsertBeforeChild(TiXmlNode* beforeThis, const TiXmlNode& addThis)
+{
+ if (!beforeThis || beforeThis->parent != this) {
+ return 0;
+ }
+ if (addThis.Type() == TiXmlNode::DOCUMENT)
+ {
+ if (GetDocument()) GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN);
+ return 0;
+ }
+
+ TiXmlNode* node = addThis.Clone();
+ if (!node)
+ return 0;
+ node->parent = this;
+
+ node->next = beforeThis;
+ node->prev = beforeThis->prev;
+ if (beforeThis->prev)
+ {
+ beforeThis->prev->next = node;
+ }
+ else
+ {
+ assert(firstChild == beforeThis);
+ firstChild = node;
+ }
+ beforeThis->prev = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertAfterChild(TiXmlNode* afterThis, const TiXmlNode& addThis)
+{
+ if (!afterThis || afterThis->parent != this) {
+ return 0;
+ }
+ if (addThis.Type() == TiXmlNode::DOCUMENT)
+ {
+ if (GetDocument()) GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN);
+ return 0;
+ }
+
+ TiXmlNode* node = addThis.Clone();
+ if (!node)
+ return 0;
+ node->parent = this;
+
+ node->prev = afterThis;
+ node->next = afterThis->next;
+ if (afterThis->next)
+ {
+ afterThis->next->prev = node;
+ }
+ else
+ {
+ assert(lastChild == afterThis);
+ lastChild = node;
+ }
+ afterThis->next = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::ReplaceChild(TiXmlNode* replaceThis, const TiXmlNode& withThis)
+{
+ if (replaceThis->parent != this)
+ return 0;
+
+ TiXmlNode* node = withThis.Clone();
+ if (!node)
+ return 0;
+
+ node->next = replaceThis->next;
+ node->prev = replaceThis->prev;
+
+ if (replaceThis->next)
+ replaceThis->next->prev = node;
+ else
+ lastChild = node;
+
+ if (replaceThis->prev)
+ replaceThis->prev->next = node;
+ else
+ firstChild = node;
+
+ delete replaceThis;
+ node->parent = this;
+ return node;
+}
+
+
+bool TiXmlNode::RemoveChild(TiXmlNode* removeThis)
+{
+ if (removeThis->parent != this)
+ {
+ assert(0);
+ return false;
+ }
+
+ if (removeThis->next)
+ removeThis->next->prev = removeThis->prev;
+ else
+ lastChild = removeThis->prev;
+
+ if (removeThis->prev)
+ removeThis->prev->next = removeThis->next;
+ else
+ firstChild = removeThis->next;
+
+ delete removeThis;
+ return true;
+}
+
+const TiXmlNode* TiXmlNode::FirstChild(const char * _value) const
+{
+ const TiXmlNode* node;
+ for (node = firstChild; node; node = node->next)
+ {
+ if (strcmp(node->Value(), _value) == 0)
+ return node;
+ }
+ return 0;
+}
+
+
+TiXmlNode* TiXmlNode::FirstChild(const char * _value)
+{
+ TiXmlNode* node;
+ for (node = firstChild; node; node = node->next)
+ {
+ if (strcmp(node->Value(), _value) == 0)
+ return node;
+ }
+ return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::LastChild(const char * _value) const
+{
+ const TiXmlNode* node;
+ for (node = lastChild; node; node = node->prev)
+ {
+ if (strcmp(node->Value(), _value) == 0)
+ return node;
+ }
+ return 0;
+}
+
+TiXmlNode* TiXmlNode::LastChild(const char * _value)
+{
+ TiXmlNode* node;
+ for (node = lastChild; node; node = node->prev)
+ {
+ if (strcmp(node->Value(), _value) == 0)
+ return node;
+ }
+ return 0;
+}
+
+const TiXmlNode* TiXmlNode::IterateChildren(const TiXmlNode* previous) const
+{
+ if (!previous)
+ {
+ return FirstChild();
+ }
+ else
+ {
+ assert(previous->parent == this);
+ return previous->NextSibling();
+ }
+}
+
+TiXmlNode* TiXmlNode::IterateChildren(TiXmlNode* previous)
+{
+ if (!previous)
+ {
+ return FirstChild();
+ }
+ else
+ {
+ assert(previous->parent == this);
+ return previous->NextSibling();
+ }
+}
+
+const TiXmlNode* TiXmlNode::IterateChildren(const char * val, const TiXmlNode* previous) const
+{
+ if (!previous)
+ {
+ return FirstChild(val);
+ }
+ else
+ {
+ assert(previous->parent == this);
+ return previous->NextSibling(val);
+ }
+}
+
+TiXmlNode* TiXmlNode::IterateChildren(const char * val, TiXmlNode* previous)
+{
+ if (!previous)
+ {
+ return FirstChild(val);
+ }
+ else
+ {
+ assert(previous->parent == this);
+ return previous->NextSibling(val);
+ }
+}
+
+const TiXmlNode* TiXmlNode::NextSibling(const char * _value) const
+{
+ const TiXmlNode* node;
+ for (node = next; node; node = node->next)
+ {
+ if (strcmp(node->Value(), _value) == 0)
+ return node;
+ }
+ return 0;
+}
+
+TiXmlNode* TiXmlNode::NextSibling(const char * _value)
+{
+ TiXmlNode* node;
+ for (node = next; node; node = node->next)
+ {
+ if (strcmp(node->Value(), _value) == 0)
+ return node;
+ }
+ return 0;
+}
+
+const TiXmlNode* TiXmlNode::PreviousSibling(const char * _value) const
+{
+ const TiXmlNode* node;
+ for (node = prev; node; node = node->prev)
+ {
+ if (strcmp(node->Value(), _value) == 0)
+ return node;
+ }
+ return 0;
+}
+
+TiXmlNode* TiXmlNode::PreviousSibling(const char * _value)
+{
+ TiXmlNode* node;
+ for (node = prev; node; node = node->prev)
+ {
+ if (strcmp(node->Value(), _value) == 0)
+ return node;
+ }
+ return 0;
+}
+
+void TiXmlElement::RemoveAttribute(const char * name)
+{
+ TIXML_STRING str(name);
+ TiXmlAttribute* node = attributeSet.Find(str);
+ if (node)
+ {
+ attributeSet.Remove(node);
+ delete node;
+ }
+}
+
+const TiXmlElement* TiXmlNode::FirstChildElement() const
+{
+ const TiXmlNode* node;
+
+ for ( node = FirstChild();
+ node;
+ node = node->NextSibling())
+ {
+ if (node->ToElement())
+ return node->ToElement();
+ }
+ return 0;
+}
+
+TiXmlElement* TiXmlNode::FirstChildElement()
+{
+ TiXmlNode* node;
+
+ for ( node = FirstChild();
+ node;
+ node = node->NextSibling())
+ {
+ if (node->ToElement())
+ return node->ToElement();
+ }
+ return 0;
+}
+
+const TiXmlElement* TiXmlNode::FirstChildElement(const char * _value) const
+{
+ const TiXmlNode* node;
+
+ for ( node = FirstChild(_value);
+ node;
+ node = node->NextSibling(_value))
+ {
+ if (node->ToElement())
+ return node->ToElement();
+ }
+ return 0;
+}
+
+TiXmlElement* TiXmlNode::FirstChildElement(const char * _value)
+{
+ TiXmlNode* node;
+
+ for ( node = FirstChild(_value);
+ node;
+ node = node->NextSibling(_value))
+ {
+ if (node->ToElement())
+ return node->ToElement();
+ }
+ return 0;
+}
+
+const TiXmlElement* TiXmlNode::NextSiblingElement() const
+{
+ const TiXmlNode* node;
+
+ for ( node = NextSibling();
+ node;
+ node = node->NextSibling())
+ {
+ if (node->ToElement())
+ return node->ToElement();
+ }
+ return 0;
+}
+
+TiXmlElement* TiXmlNode::NextSiblingElement()
+{
+ TiXmlNode* node;
+
+ for ( node = NextSibling();
+ node;
+ node = node->NextSibling())
+ {
+ if (node->ToElement())
+ return node->ToElement();
+ }
+ return 0;
+}
+
+const TiXmlElement* TiXmlNode::NextSiblingElement(const char * _value) const
+{
+ const TiXmlNode* node;
+
+ for ( node = NextSibling(_value);
+ node;
+ node = node->NextSibling(_value))
+ {
+ if (node->ToElement())
+ return node->ToElement();
+ }
+ return 0;
+}
+
+TiXmlElement* TiXmlNode::NextSiblingElement(const char * _value)
+{
+ TiXmlNode* node;
+
+ for ( node = NextSibling(_value);
+ node;
+ node = node->NextSibling(_value))
+ {
+ if (node->ToElement())
+ return node->ToElement();
+ }
+ return 0;
+}
+
+
+const TiXmlDocument* TiXmlNode::GetDocument() const
+{
+ const TiXmlNode* node;
+
+ for (node = this; node; node = node->parent)
+ {
+ if (node->ToDocument())
+ return node->ToDocument();
+ }
+ return 0;
+}
+
+TiXmlDocument* TiXmlNode::GetDocument()
+{
+ TiXmlNode* node;
+
+ for (node = this; node; node = node->parent)
+ {
+ if (node->ToDocument())
+ return node->ToDocument();
+ }
+ return 0;
+}
+
+TiXmlElement::TiXmlElement (const char * _value)
+ : TiXmlNode(TiXmlNode::ELEMENT)
+{
+ firstChild = lastChild = 0;
+ value = _value;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlElement::TiXmlElement(const std::string& _value)
+ : TiXmlNode(TiXmlNode::ELEMENT)
+{
+ firstChild = lastChild = 0;
+ value = _value;
+}
+#endif
+
+
+TiXmlElement::TiXmlElement(const TiXmlElement& copy)
+ : TiXmlNode(TiXmlNode::ELEMENT)
+{
+ firstChild = lastChild = 0;
+ copy.CopyTo(this);
+}
+
+
+void TiXmlElement::operator=(const TiXmlElement& base)
+{
+ ClearThis();
+ base.CopyTo(this);
+}
+
+
+TiXmlElement::~TiXmlElement()
+{
+ ClearThis();
+}
+
+
+void TiXmlElement::ClearThis()
+{
+ Clear();
+ while (attributeSet.First())
+ {
+ TiXmlAttribute* node = attributeSet.First();
+ attributeSet.Remove(node);
+ delete node;
+ }
+}
+
+
+const char * TiXmlElement::Attribute(const char * name) const
+{
+ TIXML_STRING str(name);
+ const TiXmlAttribute* node = attributeSet.Find(str);
+
+ if (node)
+ return node->Value();
+
+ return 0;
+}
+
+
+const char * TiXmlElement::Attribute(const char * name, int* i) const
+{
+ const char * s = Attribute(name);
+ if (i)
+ {
+ if (s)
+ *i = (int)_atoi64(s);
+ else
+ *i = 0;
+ }
+ return s;
+}
+
+
+const char * TiXmlElement::Attribute(const char * name, double* d) const
+{
+ const char * s = Attribute(name);
+ if (d)
+ {
+ if (s)
+ *d = atof(s);
+ else
+ *d = 0;
+ }
+ return s;
+}
+
+
+int TiXmlElement::QueryIntAttribute(const char* name, int* ival) const
+{
+ TIXML_STRING str(name);
+ const TiXmlAttribute* node = attributeSet.Find(str);
+ if (!node)
+ return TIXML_NO_ATTRIBUTE;
+
+ return node->QueryIntValue(ival);
+}
+
+
+int TiXmlElement::QueryDoubleAttribute(const char* name, double* dval) const
+{
+ TIXML_STRING str(name);
+ const TiXmlAttribute* node = attributeSet.Find(str);
+ if (!node)
+ return TIXML_NO_ATTRIBUTE;
+
+ return node->QueryDoubleValue(dval);
+}
+
+
+void TiXmlElement::SetAttribute(const char * name, int val)
+{
+ char buf[64];
+ mir_snprintf(buf, SIZEOF(buf), "%d", val);
+ SetAttribute(name, buf);
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlElement::SetAttribute(const std::string& name, int val)
+{
+ std::ostringstream oss;
+ oss << val;
+ SetAttribute(name, oss.str());
+}
+#endif
+
+
+void TiXmlElement::SetDoubleAttribute(const char * name, double val)
+{
+ char buf[256];
+ mir_snprintf(buf, SIZEOF(buf), "%f", val);
+ SetAttribute(name, buf);
+}
+
+
+void TiXmlElement::SetAttribute(const char * cname, const char * cvalue)
+{
+ TIXML_STRING _name(cname);
+ TIXML_STRING _value(cvalue);
+
+ TiXmlAttribute* node = attributeSet.Find(_name);
+ if (node)
+ {
+ node->SetValue(cvalue);
+ return;
+ }
+
+ TiXmlAttribute* attrib = new TiXmlAttribute(cname, cvalue);
+ if (attrib)
+ {
+ attributeSet.Add(attrib);
+ }
+ else
+ {
+ TiXmlDocument* document = GetDocument();
+ if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN);
+ }
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlElement::SetAttribute(const std::string& name, const std::string& _value)
+{
+ TiXmlAttribute* node = attributeSet.Find(name);
+ if (node)
+ {
+ node->SetValue(_value);
+ return;
+ }
+
+ TiXmlAttribute* attrib = new TiXmlAttribute(name, _value);
+ if (attrib)
+ {
+ attributeSet.Add(attrib);
+ }
+ else
+ {
+ TiXmlDocument* document = GetDocument();
+ if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN);
+ }
+}
+#endif
+
+
+void TiXmlElement::Print(FILE* cfile, int depth) const
+{
+ int i;
+ for (i=0; i<depth; i++)
+ {
+ fprintf(cfile, " ");
+ }
+
+ fprintf(cfile, "<%s", value.c_str());
+
+ const TiXmlAttribute* attrib;
+ for (attrib = attributeSet.First(); attrib; attrib = attrib->Next())
+ {
+ fprintf(cfile, " ");
+ attrib->Print(cfile, depth);
+ }
+
+ // There are 3 different formatting approaches:
+ // 1) An element without children is printed as a <foo /> node
+ // 2) An element with only a text child is printed as <foo> text </foo>
+ // 3) An element with children is printed on multiple lines.
+ TiXmlNode* node;
+ if (!firstChild)
+ {
+ fprintf(cfile, " />");
+ }
+ else if (firstChild == lastChild && firstChild->ToText())
+ {
+ fprintf(cfile, ">");
+ firstChild->Print(cfile, depth + 1);
+ fprintf(cfile, "</%s>", value.c_str());
+ }
+ else
+ {
+ fprintf(cfile, ">");
+
+ for (node = firstChild; node; node=node->NextSibling())
+ {
+ if (!node->ToText())
+ {
+ fprintf(cfile, "\n");
+ }
+ node->Print(cfile, depth+1);
+ }
+ fprintf(cfile, "\n");
+ for (i=0; i<depth; ++i)
+ fprintf(cfile, " ");
+ fprintf(cfile, "</%s>", value.c_str());
+ }
+}
+
+void TiXmlElement::StreamOut(TIXML_OSTREAM * stream) const
+{
+ (*stream) << "<" << value;
+
+ const TiXmlAttribute* attrib;
+ for (attrib = attributeSet.First(); attrib; attrib = attrib->Next())
+ {
+ (*stream) << " ";
+ attrib->StreamOut(stream);
+ }
+
+ // If this node has children, give it a closing tag. Else
+ // make it an empty tag.
+ TiXmlNode* node;
+ if (firstChild)
+ {
+ (*stream) << ">";
+
+ for (node = firstChild; node; node=node->NextSibling())
+ {
+ node->StreamOut(stream);
+ }
+ (*stream) << "</" << value << ">";
+ }
+ else
+ {
+ (*stream) << " />";
+ }
+}
+
+void TiXmlElement::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const
+{
+ // Adding tabs to get the proper tree format
+ int oldDepth = depth;
+ StreamDepth(stream, depth);
+
+ // Element name
+ (*stream) << "<" << value;
+
+ // Attributes
+ const TiXmlAttribute* attrib;
+ for (attrib = attributeSet.First(); attrib; attrib = attrib->Next())
+ {
+ (*stream) << " ";
+ attrib->StreamOut(stream);
+ }
+
+ // There are 3 different formatting approaches:
+ // 1) An element without children is printed as a <foo /> node
+ // 2) An element with only a text child is printed as <foo> text </foo>
+ // 3) An element with children is printed on multiple lines.
+ TiXmlNode* node;
+ if (!firstChild)
+ {
+ (*stream) << " />" << TIXML_ENDL;
+ }
+ else if (firstChild == lastChild && firstChild->ToText())
+ {
+ (*stream) << ">";
+ firstChild->FormattedStreamOut(stream, depth + 1);
+ (*stream) << "</" << value << ">" << TIXML_ENDL;
+ }
+ else
+ {
+ (*stream) << ">" << TIXML_ENDL;
+
+ // Children
+ depth++;
+ for (node = firstChild; node; node=node->NextSibling())
+ {
+ node->FormattedStreamOut(stream, depth);
+ }
+ StreamDepth(stream, oldDepth);
+ (*stream) << "</" << value << ">" << TIXML_ENDL;
+ }
+}
+
+void TiXmlElement::CopyTo(TiXmlElement* target) const
+{
+ // superclass:
+ TiXmlNode::CopyTo(target);
+
+ // Element class:
+ // Clone the attributes, then clone the children.
+ const TiXmlAttribute* attribute = 0;
+ for ( attribute = attributeSet.First();
+ attribute;
+ attribute = attribute->Next())
+ {
+ target->SetAttribute(attribute->Name(), attribute->Value());
+ }
+
+ TiXmlNode* node = 0;
+ for (node = firstChild; node; node = node->NextSibling())
+ {
+ target->LinkEndChild(node->Clone());
+ }
+}
+
+
+TiXmlNode* TiXmlElement::Clone() const
+{
+ TiXmlElement* clone = new TiXmlElement(Value());
+ if (!clone)
+ return 0;
+
+ CopyTo(clone);
+ return clone;
+}
+
+
+const char* TiXmlElement::GetText() const
+{
+ const TiXmlNode* child = this->FirstChild();
+ if (child) {
+ const TiXmlText* childText = child->ToText();
+ if (childText) {
+ return childText->Value();
+ }
+ }
+ return 0;
+}
+
+
+TiXmlDocument::TiXmlDocument() : TiXmlNode(TiXmlNode::DOCUMENT)
+{
+ tabsize = 4;
+ useMicrosoftBOM = false;
+ ClearError();
+}
+
+TiXmlDocument::TiXmlDocument(const char * documentName) : TiXmlNode(TiXmlNode::DOCUMENT)
+{
+ tabsize = 4;
+ useMicrosoftBOM = false;
+ value = documentName;
+ ClearError();
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlDocument::TiXmlDocument(const std::string& documentName) : TiXmlNode(TiXmlNode::DOCUMENT)
+{
+ tabsize = 4;
+ useMicrosoftBOM = false;
+ value = documentName;
+ ClearError();
+}
+#endif
+
+
+TiXmlDocument::TiXmlDocument(const TiXmlDocument& copy) : TiXmlNode(TiXmlNode::DOCUMENT)
+{
+ copy.CopyTo(this);
+}
+
+
+void TiXmlDocument::operator=(const TiXmlDocument& copy)
+{
+ Clear();
+ copy.CopyTo(this);
+}
+
+
+bool TiXmlDocument::LoadFile(TiXmlEncoding encoding)
+{
+ // See STL_STRING_BUG below.
+ StringToBuffer buf(value);
+
+ if (buf.buffer && LoadFile(buf.buffer, encoding))
+ return true;
+
+ return false;
+}
+
+
+bool TiXmlDocument::SaveFile() const
+{
+ // See STL_STRING_BUG below.
+ StringToBuffer buf(value);
+
+ if (buf.buffer && SaveFile(buf.buffer))
+ return true;
+
+ return false;
+}
+
+#ifdef TIXML_USE_STL
+std::string TiXmlDocument::GetAsString()
+{
+ std::stringstream out;
+ FormattedStreamOut(&out, 0);
+ return out.str();
+}
+#endif
+
+bool TiXmlDocument::GetAsCharBuffer(char* buffer, size_t bufferSize)
+{
+ #ifdef TIXML_USE_STL
+ std::string data = GetAsString();
+ #else
+ TIXML_OSTREAM data;
+ FormattedStreamOut(&data, 0);
+ #endif
+
+ if (bufferSize < data.length())
+ {
+ return false;
+ }
+ else
+ {
+ strcpy(buffer, data.c_str());
+ return true;
+ }
+}
+
+bool TiXmlDocument::LoadFile(const char* filename, TiXmlEncoding encoding)
+{
+ // There was a really terrifying little bug here. The code:
+ // value = filename
+ // in the STL case, cause the assignment method of the std::string to
+ // be called. What is strange, is that the std::string had the same
+ // address as it's c_str() method, and so bad things happen. Looks
+ // like a bug in the Microsoft STL implementation.
+ // See STL_STRING_BUG above.
+ // Fixed with the StringToBuffer class.
+ value = filename;
+
+ // reading in binary mode so that tinyxml can normalize the EOL
+ FILE* file = fopen(value.c_str (), "rb");
+
+ if (file)
+ {
+ bool result = LoadFile(file, encoding);
+ fclose(file);
+ return result;
+ }
+ else
+ {
+ SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN);
+ return false;
+ }
+}
+
+bool TiXmlDocument::LoadFile(FILE* file, TiXmlEncoding encoding)
+{
+ if (!file)
+ {
+ SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN);
+ return false;
+ }
+
+ // Delete the existing data:
+ Clear();
+ location.Clear();
+
+ // Get the file size, so we can pre-allocate the string. HUGE speed impact.
+ long length = 0;
+ fseek(file, 0, SEEK_END);
+ length = ftell(file);
+ fseek(file, 0, SEEK_SET);
+
+ // Strange case, but good to handle up front.
+ if (length == 0)
+ {
+ SetError(TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
+ return false;
+ }
+
+ // If we have a file, assume it is all one big XML file, and read it in.
+ // The document parser may decide the document ends sooner than the entire file, however.
+ TIXML_STRING data;
+ data.reserve(length);
+
+ // Subtle bug here. TinyXml did use fgets. But from the XML spec:
+ // 2.11 End-of-Line Handling
+ // <snip>
+ // <quote>
+ // ...the XML processor MUST behave as if it normalized all line breaks in external
+ // parsed entities (including the document entity) on input, before parsing, by translating
+ // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
+ // a single #xA character.
+ // </quote>
+ //
+ // It is not clear fgets does that, and certainly isn't clear it works cross platform.
+ // Generally, you expect fgets to translate from the convention of the OS to the c/unix
+ // convention, and not work generally.
+
+ /*
+ while (fgets(buf, sizeof(buf), file))
+ {
+ data += buf;
+ }
+ */
+
+ char* buf = new char[ length+1 ];
+ buf[0] = 0;
+
+ if (fread(buf, length, 1, file) != 1) {
+ delete [] buf;
+ SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN);
+ return false;
+ }
+
+ const char* lastPos = buf;
+ const char* p = buf;
+
+ buf[length] = 0;
+ while (*p) {
+ assert(p < (buf+length));
+ if (*p == 0xa) {
+ // Newline character. No special rules for this. Append all the characters
+ // since the last string, and include the newline.
+ data.append(lastPos, (p-lastPos+1)); // append, include the newline
+ ++p; // move past the newline
+ lastPos = p; // and point to the new buffer (may be 0)
+ assert(p <= (buf+length));
+ }
+ else if (*p == 0xd) {
+ // Carriage return. Append what we have so far, then
+ // handle moving forward in the buffer.
+ if ((p-lastPos) > 0) {
+ data.append(lastPos, p-lastPos); // do not add the CR
+ }
+ data += (char)0xa; // a proper newline
+
+ if (*(p+1) == 0xa) {
+ // Carriage return - new line sequence
+ p += 2;
+ lastPos = p;
+ assert(p <= (buf+length));
+ }
+ else {
+ // it was followed by something else...that is presumably characters again.
+ ++p;
+ lastPos = p;
+ assert(p <= (buf+length));
+ }
+ }
+ else {
+ ++p;
+ }
+ }
+ // Handle any left over characters.
+ if (p-lastPos) {
+ data.append(lastPos, p-lastPos);
+ }
+ delete [] buf;
+ buf = 0;
+
+ Parse(data.c_str(), 0, encoding);
+
+ if ( Error())
+ return false;
+ else
+ return true;
+}
+
+
+bool TiXmlDocument::SaveFile(const char * filename) const
+{
+ // The old c stuff lives on...
+ FILE* fp = fopen(filename, "w");
+ if (fp)
+ {
+ bool result = SaveFile(fp);
+ fclose(fp);
+ return result;
+ }
+ return false;
+}
+
+
+bool TiXmlDocument::SaveFile(FILE* fp) const
+{
+ if (useMicrosoftBOM)
+ {
+ const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
+ const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
+ const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
+
+ fputc(TIXML_UTF_LEAD_0, fp);
+ fputc(TIXML_UTF_LEAD_1, fp);
+ fputc(TIXML_UTF_LEAD_2, fp);
+ }
+ Print(fp, 0);
+ return true;
+}
+
+
+void TiXmlDocument::CopyTo(TiXmlDocument* target) const
+{
+ TiXmlNode::CopyTo(target);
+
+ target->error = error;
+ target->errorDesc = errorDesc.c_str ();
+
+ TiXmlNode* node = 0;
+ for (node = firstChild; node; node = node->NextSibling())
+ {
+ target->LinkEndChild(node->Clone());
+ }
+}
+
+
+TiXmlNode* TiXmlDocument::Clone() const
+{
+ TiXmlDocument* clone = new TiXmlDocument();
+ if (!clone)
+ return 0;
+
+ CopyTo(clone);
+ return clone;
+}
+
+
+void TiXmlDocument::Print(FILE* cfile, int depth) const
+{
+ const TiXmlNode* node;
+ for (node=FirstChild(); node; node=node->NextSibling())
+ {
+ node->Print(cfile, depth);
+ fprintf(cfile, "\n");
+ }
+}
+
+void TiXmlDocument::StreamOut(TIXML_OSTREAM * out) const
+{
+ const TiXmlNode* node;
+ for (node=FirstChild(); node; node=node->NextSibling())
+ {
+ node->StreamOut(out);
+
+ // Special rule for streams: stop after the root element.
+ // The stream in code will only read one element, so don't
+ // write more than one.
+ if (node->ToElement())
+ break;
+ }
+}
+
+void TiXmlDocument::FormattedStreamOut(TIXML_OSTREAM * out, int depth) const
+{
+ const TiXmlNode* node;
+ for (node=FirstChild(); node; node=node->NextSibling())
+ {
+ node->FormattedStreamOut(out, depth);
+
+ // Special rule for streams: stop after the root element.
+ // The stream in code will only read one element, so don't
+ // write more than one.
+ if (node->ToElement())
+ break;
+ }
+}
+
+const TiXmlAttribute* TiXmlAttribute::Next() const
+{
+ // We are using knowledge of the sentinel. The sentinel
+ // have a value or name.
+ if (next->value.empty() && next->name.empty())
+ return 0;
+ return next;
+}
+
+TiXmlAttribute* TiXmlAttribute::Next()
+{
+ // We are using knowledge of the sentinel. The sentinel
+ // have a value or name.
+ if (next->value.empty() && next->name.empty())
+ return 0;
+ return next;
+}
+
+const TiXmlAttribute* TiXmlAttribute::Previous() const
+{
+ // We are using knowledge of the sentinel. The sentinel
+ // have a value or name.
+ if (prev->value.empty() && prev->name.empty())
+ return 0;
+ return prev;
+}
+
+TiXmlAttribute* TiXmlAttribute::Previous()
+{
+ // We are using knowledge of the sentinel. The sentinel
+ // have a value or name.
+ if (prev->value.empty() && prev->name.empty())
+ return 0;
+ return prev;
+}
+
+void TiXmlAttribute::Print(FILE* cfile, int /*depth*/) const
+{
+ TIXML_STRING n, v;
+
+ PutString(name, &n);
+ PutString(value, &v);
+
+ if (value.find ('\"') == TIXML_STRING::npos)
+ fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str());
+ else
+ fprintf (cfile, "%s='%s'", n.c_str(), v.c_str());
+}
+
+
+void TiXmlAttribute::StreamOut(TIXML_OSTREAM * stream) const
+{
+ if (value.find('\"') != TIXML_STRING::npos)
+ {
+ PutString(name, stream);
+ (*stream) << "=" << "'";
+ PutString(value, stream);
+ (*stream) << "'";
+ }
+ else
+ {
+ PutString(name, stream);
+ (*stream) << "=" << "\"";
+ PutString(value, stream);
+ (*stream) << "\"";
+ }
+}
+
+int TiXmlAttribute::QueryIntValue(int* ival) const
+{
+ if (sscanf(value.c_str(), "%d", ival) == 1)
+ return TIXML_SUCCESS;
+ return TIXML_WRONG_TYPE;
+}
+
+int TiXmlAttribute::QueryDoubleValue(double* dval) const
+{
+ if (sscanf(value.c_str(), "%lf", dval) == 1)
+ return TIXML_SUCCESS;
+ return TIXML_WRONG_TYPE;
+}
+
+void TiXmlAttribute::SetIntValue(int _value)
+{
+ char buf[64];
+ mir_snprintf(buf, SIZEOF(buf), "%d", _value);
+ SetValue(buf);
+}
+
+void TiXmlAttribute::SetDoubleValue(double _value)
+{
+ char buf[256];
+ mir_snprintf(buf, SIZEOF(buf), "%lf", _value);
+ SetValue(buf);
+}
+
+int TiXmlAttribute::IntValue() const
+{
+ return (int)_atoi64(value.c_str ());
+}
+
+double TiXmlAttribute::DoubleValue() const
+{
+ return atof (value.c_str ());
+}
+
+
+TiXmlComment::TiXmlComment(const TiXmlComment& copy) : TiXmlNode(TiXmlNode::COMMENT)
+{
+ copy.CopyTo(this);
+}
+
+
+void TiXmlComment::operator=(const TiXmlComment& base)
+{
+ Clear();
+ base.CopyTo(this);
+}
+
+
+void TiXmlComment::Print(FILE* cfile, int depth) const
+{
+ for (int i=0; i<depth; i++)
+ {
+ fputs(" ", cfile);
+ }
+ fprintf(cfile, "<!--%s-->", value.c_str());
+}
+
+void TiXmlComment::StreamOut(TIXML_OSTREAM * stream) const
+{
+ (*stream) << "<!--";
+ //PutString(value, stream);
+ (*stream) << value;
+ (*stream) << "-->";
+}
+
+void TiXmlComment::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const
+{
+ StreamDepth(stream, depth);
+
+ StreamOut(stream);
+
+ (*stream) << TIXML_ENDL;
+}
+
+void TiXmlComment::CopyTo(TiXmlComment* target) const
+{
+ TiXmlNode::CopyTo(target);
+}
+
+
+TiXmlNode* TiXmlComment::Clone() const
+{
+ TiXmlComment* clone = new TiXmlComment();
+
+ if (!clone)
+ return 0;
+
+ CopyTo(clone);
+ return clone;
+}
+
+
+void TiXmlText::Print(FILE* cfile, int depth) const
+{
+ if (cdata)
+ {
+ int i;
+ fprintf(cfile, "\n");
+ for (i=0; i<depth; i++) {
+ fprintf(cfile, " ");
+ }
+ fprintf(cfile, "<![CDATA[");
+ fprintf(cfile, "%s", value.c_str()); // unformatted output
+ fprintf(cfile, "]]>\n");
+ }
+ else
+ {
+ TIXML_STRING buffer;
+ PutString(value, &buffer);
+ fprintf(cfile, "%s", buffer.c_str());
+ }
+}
+
+
+void TiXmlText::StreamOut(TIXML_OSTREAM * stream) const
+{
+ if (cdata)
+ {
+ (*stream) << "<![CDATA[" << value << "]]>";
+ }
+ else
+ {
+ PutString(value, stream);
+ }
+}
+
+void TiXmlText::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const
+{
+ if (cdata)
+ {
+ (*stream) << TIXML_ENDL;
+ StreamDepth(stream, depth);
+ (*stream) << "<![CDATA[" << value << "]]>" << TIXML_ENDL;
+ }
+ else
+ {
+ PutString(value, stream);
+ }
+}
+
+void TiXmlText::CopyTo(TiXmlText* target) const
+{
+ TiXmlNode::CopyTo(target);
+ target->cdata = cdata;
+}
+
+
+TiXmlNode* TiXmlText::Clone() const
+{
+ TiXmlText* clone = 0;
+ clone = new TiXmlText("");
+
+ if (!clone)
+ return 0;
+
+ CopyTo(clone);
+ return clone;
+}
+
+
+TiXmlDeclaration::TiXmlDeclaration(const char * _version,
+ const char * _encoding,
+ const char * _standalone)
+ : TiXmlNode(TiXmlNode::DECLARATION)
+{
+ version = _version;
+ encoding = _encoding;
+ standalone = _standalone;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
+ const std::string& _encoding,
+ const std::string& _standalone)
+ : TiXmlNode(TiXmlNode::DECLARATION)
+{
+ version = _version;
+ encoding = _encoding;
+ standalone = _standalone;
+}
+#endif
+
+
+TiXmlDeclaration::TiXmlDeclaration(const TiXmlDeclaration& copy)
+ : TiXmlNode(TiXmlNode::DECLARATION)
+{
+ copy.CopyTo(this);
+}
+
+
+void TiXmlDeclaration::operator=(const TiXmlDeclaration& copy)
+{
+ Clear();
+ copy.CopyTo(this);
+}
+
+
+void TiXmlDeclaration::Print(FILE* cfile, int /*depth*/) const
+{
+ fprintf (cfile, "<?xml ");
+
+ if (!version.empty())
+ fprintf (cfile, "version=\"%s\" ", version.c_str ());
+ if (!encoding.empty())
+ fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
+ if (!standalone.empty())
+ fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
+ fprintf (cfile, "?>");
+}
+
+void TiXmlDeclaration::StreamOut(TIXML_OSTREAM * stream) const
+{
+ (*stream) << "<?xml ";
+
+ if (!version.empty())
+ {
+ (*stream) << "version=\"";
+ PutString(version, stream);
+ (*stream) << "\" ";
+ }
+ if (!encoding.empty())
+ {
+ (*stream) << "encoding=\"";
+ PutString(encoding, stream);
+ (*stream) << "\" ";
+ }
+ if (!standalone.empty())
+ {
+ (*stream) << "standalone=\"";
+ PutString(standalone, stream);
+ (*stream) << "\" ";
+ }
+ (*stream) << "?>";
+}
+
+void TiXmlDeclaration::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const
+{
+ StreamDepth(stream, depth);
+ StreamOut(stream);
+ (*stream) << TIXML_ENDL;
+}
+
+void TiXmlDeclaration::CopyTo(TiXmlDeclaration* target) const
+{
+ TiXmlNode::CopyTo(target);
+
+ target->version = version;
+ target->encoding = encoding;
+ target->standalone = standalone;
+}
+
+
+TiXmlNode* TiXmlDeclaration::Clone() const
+{
+ TiXmlDeclaration* clone = new TiXmlDeclaration();
+
+ if (!clone)
+ return 0;
+
+ CopyTo(clone);
+ return clone;
+}
+
+
+void TiXmlUnknown::Print(FILE* cfile, int depth) const
+{
+ for (int i=0; i<depth; i++)
+ fprintf(cfile, " ");
+ fprintf(cfile, "<%s>", value.c_str());
+}
+
+
+void TiXmlUnknown::StreamOut(TIXML_OSTREAM * stream) const
+{
+ (*stream) << "<" << value << ">"; // Don't use entities here! It is unknown.
+}
+
+void TiXmlUnknown::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const
+{
+ StreamDepth(stream, depth);
+ (*stream) << "<" << value << ">" << TIXML_ENDL; // Don't use entities here! It is unknown.
+}
+
+void TiXmlUnknown::CopyTo(TiXmlUnknown* target) const
+{
+ TiXmlNode::CopyTo(target);
+}
+
+
+TiXmlNode* TiXmlUnknown::Clone() const
+{
+ TiXmlUnknown* clone = new TiXmlUnknown();
+
+ if (!clone)
+ return 0;
+
+ CopyTo(clone);
+ return clone;
+}
+
+
+TiXmlAttributeSet::TiXmlAttributeSet()
+{
+ sentinel.next = &sentinel;
+ sentinel.prev = &sentinel;
+}
+
+
+TiXmlAttributeSet::~TiXmlAttributeSet()
+{
+ assert(sentinel.next == &sentinel);
+ assert(sentinel.prev == &sentinel);
+}
+
+
+void TiXmlAttributeSet::Add(TiXmlAttribute* addMe)
+{
+ assert(!Find(TIXML_STRING(addMe->Name()))); // Shouldn't be multiply adding to the set.
+
+ addMe->next = &sentinel;
+ addMe->prev = sentinel.prev;
+
+ sentinel.prev->next = addMe;
+ sentinel.prev = addMe;
+}
+
+void TiXmlAttributeSet::Remove(TiXmlAttribute* removeMe)
+{
+ TiXmlAttribute* node;
+
+ for (node = sentinel.next; node != &sentinel; node = node->next)
+ {
+ if (node == removeMe)
+ {
+ node->prev->next = node->next;
+ node->next->prev = node->prev;
+ node->next = 0;
+ node->prev = 0;
+ return;
+ }
+ }
+ assert(0); // we tried to remove a non-linked attribute.
+}
+
+const TiXmlAttribute* TiXmlAttributeSet::Find(const TIXML_STRING& name) const
+{
+ const TiXmlAttribute* node;
+
+ for (node = sentinel.next; node != &sentinel; node = node->next)
+ {
+ if (node->name == name)
+ return node;
+ }
+ return 0;
+}
+
+TiXmlAttribute* TiXmlAttributeSet::Find(const TIXML_STRING& name)
+{
+ TiXmlAttribute* node;
+
+ for (node = sentinel.next; node != &sentinel; node = node->next)
+ {
+ if (node->name == name)
+ return node;
+ }
+ return 0;
+}
+
+#ifdef TIXML_USE_STL
+TIXML_ISTREAM & operator >> (TIXML_ISTREAM & in, TiXmlNode & base)
+{
+ TIXML_STRING tag;
+ tag.reserve(8 * 1000);
+ base.StreamIn(&in, &tag);
+
+ base.Parse(tag.c_str(), 0, TIXML_DEFAULT_ENCODING);
+ return in;
+}
+#endif
+
+
+TIXML_OSTREAM & operator<< (TIXML_OSTREAM & out, const TiXmlNode & base)
+{
+ base.StreamOut (& out);
+ return out;
+}
+
+
+#ifdef TIXML_USE_STL
+std::string & operator<< (std::string& out, const TiXmlNode& base)
+{
+ std::ostringstream os_stream(std::ostringstream::out);
+ base.StreamOut(&os_stream);
+
+ out.append(os_stream.str());
+ return out;
+}
+#endif
+
+
+TiXmlHandle TiXmlHandle::FirstChild() const
+{
+ if (node)
+ {
+ TiXmlNode* child = node->FirstChild();
+ if (child)
+ return TiXmlHandle(child);
+ }
+ return TiXmlHandle(0);
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChild(const char * value) const
+{
+ if (node)
+ {
+ TiXmlNode* child = node->FirstChild(value);
+ if (child)
+ return TiXmlHandle(child);
+ }
+ return TiXmlHandle(0);
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChildElement() const
+{
+ if (node)
+ {
+ TiXmlElement* child = node->FirstChildElement();
+ if (child)
+ return TiXmlHandle(child);
+ }
+ return TiXmlHandle(0);
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChildElement(const char * value) const
+{
+ if (node)
+ {
+ TiXmlElement* child = node->FirstChildElement(value);
+ if (child)
+ return TiXmlHandle(child);
+ }
+ return TiXmlHandle(0);
+}
+
+
+TiXmlHandle TiXmlHandle::Child(int count) const
+{
+ if (node)
+ {
+ int i;
+ TiXmlNode* child = node->FirstChild();
+ for ( i=0;
+ child && i<count;
+ child = child->NextSibling(), ++i)
+ {
+ // nothing
+ }
+ if (child)
+ return TiXmlHandle(child);
+ }
+ return TiXmlHandle(0);
+}
+
+
+TiXmlHandle TiXmlHandle::Child(const char* value, int count) const
+{
+ if (node)
+ {
+ int i;
+ TiXmlNode* child = node->FirstChild(value);
+ for ( i=0;
+ child && i<count;
+ child = child->NextSibling(value), ++i)
+ {
+ // nothing
+ }
+ if (child)
+ return TiXmlHandle(child);
+ }
+ return TiXmlHandle(0);
+}
+
+
+TiXmlHandle TiXmlHandle::ChildElement(int count) const
+{
+ if (node)
+ {
+ int i;
+ TiXmlElement* child = node->FirstChildElement();
+ for ( i=0;
+ child && i<count;
+ child = child->NextSiblingElement(), ++i)
+ {
+ // nothing
+ }
+ if (child)
+ return TiXmlHandle(child);
+ }
+ return TiXmlHandle(0);
+}
+
+
+TiXmlHandle TiXmlHandle::ChildElement(const char* value, int count) const
+{
+ if (node)
+ {
+ int i;
+ TiXmlElement* child = node->FirstChildElement(value);
+ for ( i=0;
+ child && i<count;
+ child = child->NextSiblingElement(value), ++i)
+ {
+ // nothing
+ }
+ if (child)
+ return TiXmlHandle(child);
+ }
+ return TiXmlHandle(0);
+}
diff --git a/plugins/UserInfoEx/src/ex_import/tinyxml.h b/plugins/UserInfoEx/src/ex_import/tinyxml.h index 98d1784dac..536fabef74 100644 --- a/plugins/UserInfoEx/src/ex_import/tinyxml.h +++ b/plugins/UserInfoEx/src/ex_import/tinyxml.h @@ -68,17 +68,14 @@ Copyright: #ifdef TIXML_SAFE #if defined(_MSC_VER) && (_MSC_VER >= 1400) // Microsoft visual studio, version 2005 and higher. - #define TIXML_SNPRINTF _snprintf_s #define TIXML_SNSCANF _snscanf_s #elif defined(_MSC_VER) && (_MSC_VER >= 1200) // Microsoft visual studio, version 6 and higher. //#pragma message("Using _sn* functions.") - #define TIXML_SNPRINTF _snprintf #define TIXML_SNSCANF _snscanf #elif defined(__GNUC__) && (__GNUC__ >= 3) // GCC version 3 and higher.s //#warning("Using sn* functions.") - #define TIXML_SNPRINTF snprintf #define TIXML_SNSCANF snscanf #endif #endif diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index 132766ee4d..3c05f4b78b 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -284,11 +284,12 @@ int getContactFromString( CONTACTSINFO* ci ) if (cInfo == NULL) {
// <HANDLE:hContact>
cInfo = (TCHAR*)mir_alloc(32);
- _stprintf(cInfo, _T("%p"), hContact);
- szFind = (TCHAR*)mir_alloc((_tcslen(cInfo) + _tcslen(_T(PROTOID_HANDLE)) + 4)*sizeof(TCHAR));
+ mir_sntprintf(cInfo, 32, _T("%p"), hContact);
+ int size = _tcslen(cInfo) + _tcslen(_T(PROTOID_HANDLE)) + 4;
+ szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (szFind != NULL)
{
- wsprintf(szFind, _T("<%s:%s>"), _T(PROTOID_HANDLE), cInfo);
+ mir_sntprintf(szFind, size, _T("<%s:%s>"), _T(PROTOID_HANDLE), cInfo);
if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
bMatch = TRUE;
@@ -297,11 +298,12 @@ int getContactFromString( CONTACTSINFO* ci ) }
}
else {
- szFind = (TCHAR*)mir_alloc((_tcslen(cInfo) + strlen(szProto) + 4)*sizeof(TCHAR));
+ int size = _tcslen(cInfo) + strlen(szProto) + 4;
+ szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (szFind != NULL) {
tszProto = mir_a2t(szProto);
if ((tszProto != NULL) && (szFind != NULL)) {
- wsprintf(szFind, _T("<%s:%s>"), tszProto, cInfo);
+ mir_sntprintf(szFind, size, _T("<%s:%s>"), tszProto, cInfo);
mir_free(cInfo);
mir_free(tszProto);
if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
@@ -488,7 +490,8 @@ TCHAR *encodeContactToString(HANDLE hContact) if (szProto == NULL || tszUniqueId == NULL)
return NULL;
- TCHAR *tszResult = (TCHAR*)mir_calloc((_tcslen(tszUniqueId) + strlen(szProto) + 4) * sizeof(TCHAR));
+ int size = _tcslen(tszUniqueId) + strlen(szProto) + 4;
+ TCHAR *tszResult = (TCHAR *)mir_calloc(size * sizeof(TCHAR));
if (tszResult == NULL)
return NULL;
@@ -497,7 +500,7 @@ TCHAR *encodeContactToString(HANDLE hContact) if (tszProto == NULL)
return NULL;
- wsprintf(tszResult, _T("<%s:%s>"), tszProto, tszUniqueId);
+ mir_sntprintf(tszResult, size, _T("<%s:%s>"), tszProto, tszUniqueId);
mir_free(tszProto);
diff --git a/plugins/Variables/src/help.cpp b/plugins/Variables/src/help.cpp index 59476e1a77..2d787e5c09 100644 --- a/plugins/Variables/src/help.cpp +++ b/plugins/Variables/src/help.cpp @@ -540,7 +540,7 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg,UINT msg,WPARAM wParam break;
}
ZeroMemory(tokenString, (len+1)*sizeof(TCHAR));
- wsprintf(tokenString, _T("%c%s%c"), (tr->flags&TRF_FIELD?_T(FIELD_CHAR):_T(FUNC_CHAR)), tr->tszTokenString, (tr->flags&TRF_FIELD?_T(FIELD_CHAR):_T('(')));
+ mir_sntprintf(tokenString, len + 1, _T("%c%s%c"), (tr->flags & TRF_FIELD ? _T(FIELD_CHAR) : _T(FUNC_CHAR)), tr->tszTokenString, (tr->flags & TRF_FIELD ? _T(FIELD_CHAR) : _T('(')));
SendDlgItemMessage(hwndInputDlg, IDC_TESTSTRING, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)tokenString);
mir_free(tokenString);
SetFocus(GetDlgItem(hwndInputDlg, IDC_TESTSTRING));
diff --git a/plugins/Variables/src/parse_alias.cpp b/plugins/Variables/src/parse_alias.cpp index 233a7f761a..3cbae2373e 100644 --- a/plugins/Variables/src/parse_alias.cpp +++ b/plugins/Variables/src/parse_alias.cpp @@ -192,16 +192,17 @@ static TCHAR *parseAddAlias(ARGUMENTSINFO *ai) { szArgsA = mir_t2a(szArgs);
- szHelp = ( char* )mir_alloc(32 + strlen(szArgsA));
+ int size = 32 + strlen(szArgsA);
+ szHelp = (char *)mir_alloc(size);
memset(szHelp, '\0', 32 + strlen(szArgsA));
- sprintf(szHelp, LPGEN("Alias")"\t(%s)\t"LPGEN("user defined"), szArgsA);
+ mir_snprintf(szHelp, size, LPGEN("Alias")"\t(%s)\t"LPGEN("user defined"), szArgsA);
res = registerIntToken(alias, parseTranslateAlias, TRF_FUNCTION|TRF_UNPARSEDARGS, szHelp);
mir_free(szArgsA);
}
else {
szHelp = ( char* )mir_alloc(32);
memset(szHelp, '\0', 32);
- sprintf(szHelp, LPGEN("Alias")"\t\t"LPGEN("user defined"));
+ mir_snprintf(szHelp, 32, LPGEN("Alias")"\t\t"LPGEN("user defined"));
res = registerIntToken(alias, parseTranslateAlias, TRF_FIELD|TRF_UNPARSEDARGS, szHelp);
}
mir_free(szArgs);
diff --git a/plugins/Variables/src/parse_metacontacts.cpp b/plugins/Variables/src/parse_metacontacts.cpp index dd552ecb9b..40fe04c36b 100644 --- a/plugins/Variables/src/parse_metacontacts.cpp +++ b/plugins/Variables/src/parse_metacontacts.cpp @@ -53,13 +53,14 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai) if (szUniqueID == NULL)
{
szProto = PROTOID_HANDLE;
- szUniqueID = (TCHAR*)mir_alloc(32);
- _stprintf(szUniqueID, _T("%p"), hContact);
+ szUniqueID = (TCHAR *)mir_alloc(32);
+ mir_sntprintf(szUniqueID, 32, _T("%p"), hContact);
if (szProto == NULL || szUniqueID == NULL)
return NULL;
}
- TCHAR *res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ int size = strlen(szProto) + _tcslen(szUniqueID) + 4;
+ TCHAR *res = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
@@ -67,7 +68,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai) TCHAR *tszProto = mir_a2t(szProto);
if (tszProto != NULL && szUniqueID != NULL) {
- wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
+ mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
mir_free(szUniqueID);
mir_free(tszProto);
}
@@ -108,13 +109,14 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai) if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
- szUniqueID = (TCHAR*)mir_alloc(32);
- _stprintf(szUniqueID, _T("%p"), hContact);
+ szUniqueID = (TCHAR *)mir_alloc(32);
+ mir_sntprintf(szUniqueID, 32, _T("%p"), hContact);
if (szProto == NULL || szUniqueID == NULL)
return NULL;
}
- TCHAR* res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ int size = strlen(szProto) + _tcslen(szUniqueID) + 4;
+ TCHAR *res = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
@@ -122,7 +124,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai) TCHAR *tszProto = mir_a2t(szProto);
if (tszProto != NULL && szUniqueID != NULL) {
- wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
+ mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
mir_free(szUniqueID);
mir_free(tszProto);
}
@@ -163,13 +165,14 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai) if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
- szUniqueID = (TCHAR*)mir_alloc(32);
- _stprintf(szUniqueID, _T("%p"), hContact);
+ szUniqueID = (TCHAR *)mir_alloc(32);
+ mir_sntprintf(szUniqueID, 32, _T("%p"), hContact);
if (szProto == NULL || szUniqueID == NULL)
return NULL;
}
- TCHAR *res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ int size = strlen(szProto) + _tcslen(szUniqueID) + 4;
+ TCHAR *res = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
@@ -177,7 +180,7 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai) TCHAR *tszProto = mir_a2t(szProto);
if (tszProto != NULL && szUniqueID != NULL) {
- wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
+ mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
mir_free(szUniqueID);
mir_free(tszProto);
}
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index c686037325..c3c4eb28b0 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -481,12 +481,13 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai) if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
szUniqueID = (TCHAR*)mir_alloc(32);
- _stprintf(szUniqueID, _T("%p"), ai->fi->hContact);
+ mir_sntprintf(szUniqueID, 32, _T("%p"), ai->fi->hContact);
if (szProto == NULL || szUniqueID == NULL)
return NULL;
}
- TCHAR *res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ int size = strlen(szProto) + _tcslen(szUniqueID) + 4;
+ TCHAR *res = (TCHAR*)mir_alloc(size * sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
@@ -494,7 +495,7 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai) TCHAR *tszProto = mir_a2t(szProto);
if (tszProto != NULL && szUniqueID != NULL) {
- wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
+ mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
mir_free(szUniqueID);
mir_free(tszProto);
}
diff --git a/plugins/Variables/src/parse_system.cpp b/plugins/Variables/src/parse_system.cpp index 67ebf3dd0e..026007a10f 100644 --- a/plugins/Variables/src/parse_system.cpp +++ b/plugins/Variables/src/parse_system.cpp @@ -54,11 +54,12 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) { if ( _tcslen(ai->targv[1]) == 0)
szCounter = mir_tstrdup(_T("\\Processor(_Total)\\% Processor Time"));
else {
- szCounter = (TCHAR*)mir_alloc((_tcslen(ai->targv[1]) + 32)*sizeof(TCHAR));
+ int size = _tcslen(ai->targv[1]) + 32;
+ szCounter = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (szCounter == NULL)
return NULL;
- wsprintf(szCounter, _T("\\Process(%s)\\%% Processor Time"), ai->targv[1]);
+ mir_sntprintf(szCounter, size, _T("\\Process(%s)\\%% Processor Time"), ai->targv[1]);
}
PDH_STATUS pdhStatus = PdhValidatePath(szCounter);
if (pdhStatus != ERROR_SUCCESS) {
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index cc51c71e26..25e95846e6 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -110,7 +110,7 @@ INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam) opt.DefStn = hContact;
if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
// notification message box
- wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
@@ -309,7 +309,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR * // replace spaces with %20
char loc[256];
ptrA szSearchName( mir_utf8encodeT(name));
- wsprintfA(loc, sData->SearchURL, ptrA( mir_urlEncode(szSearchName)));
+ mir_snprintf(loc, SIZEOF(loc), sData->SearchURL, ptrA( mir_urlEncode(szSearchName)));
if (InternetDownloadFile(loc, NULL, &szData) == 0) {
TCHAR* szInfo = szData;
search = _tcsstr(szInfo, sData->NotFoundStr); // determine if data is available
@@ -322,14 +322,14 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR * // if station ID appears first in the downloaded data
if ( !_tcsicmp(sData->Single.First, _T("ID"))) {
GetDataValue(&sData->Single.ID, str, &szInfo);
- wsprintf(sID, _T("%s/%s"), svc, str);
+ mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
GetDataValue(&sData->Single.Name, Name, &szInfo);
}
// if station name appears first in the downloaded data
else if ( !_tcsicmp(sData->Single.First, _T("NAME"))) {
GetDataValue(&sData->Single.Name, Name, &szInfo);
GetDataValue(&sData->Single.ID, str, &szInfo);
- wsprintf(sID, _T("%s/%s"), svc, str);
+ mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
}
// if no station ID is obtained, quit the search
if (str[0] == 0) {
@@ -360,14 +360,14 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR * // if station ID appears first in the downloaded data
if ( !_tcsicmp(sData->Multiple.First, _T("ID"))) {
GetDataValue(&sData->Multiple.ID, str, &szInfo);
- wsprintf(sID, _T("%s/%s"), svc, str);
+ mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
GetDataValue(&sData->Multiple.Name, Name, &szInfo);
}
// if station name appears first in the downloaded data
else if ( !_tcsicmp(sData->Multiple.First, _T("NAME"))) {
GetDataValue(&sData->Multiple.Name, Name, &szInfo);
GetDataValue(&sData->Multiple.ID, str, &szInfo);
- wsprintf(sID, _T("%s/%s"), svc, str);
+ mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
}
// if no station ID is obtained, search completed and quit the search
if (str[0] == 0) break;
diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp index 2cc4187bf1..44df9e7386 100644 --- a/plugins/Weather/src/weather_contacts.cpp +++ b/plugins/Weather/src/weather_contacts.cpp @@ -30,7 +30,7 @@ static void OpenUrl( TCHAR* format, TCHAR* id ) TCHAR loc[512];
GetID( id );
- mir_sntprintf( loc, SIZEOF(loc), format, id );
+ mir_sntprintf(loc, SIZEOF(loc), format, id);
CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)loc );
}
@@ -260,7 +260,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa TCHAR *szData = NULL;
// load the page
- wsprintfA(loc, sData->IDSearch.SearchURL, str);
+ mir_snprintf(loc, SIZEOF(loc), sData->IDSearch.SearchURL, str);
str[0] = 0;
if (InternetDownloadFile(loc, NULL, &szData) == 0) {
TCHAR *szInfo = szData;
@@ -370,7 +370,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa }
GetDlgItemText(hwndDlg, IDC_NAME, city, SIZEOF(city));
db_set_ts(hContact, WEATHERPROTONAME, "Nick", city);
- wsprintf(str2, TranslateT("Current weather information for %s."), city);
+ mir_sntprintf(str2, SIZEOF(str2), TranslateT("Current weather information for %s."), city);
if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) {
GetDlgItemText(hwndDlg, IDC_LOG, str, SIZEOF(str));
db_set_ts(hContact, WEATHERPROTONAME, "Log", str);
diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp index 565def07cb..a86ac070c4 100644 --- a/plugins/Weather/src/weather_conv.cpp +++ b/plugins/Weather/src/weather_conv.cpp @@ -65,9 +65,9 @@ static void numToStr(double num, TCHAR* str) if (i < 0 && (w || r)) *(str++) = '-';
if (r)
- wsprintf(str, _T("%i.%i"), w, r);
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i"), w, r);
else
- wsprintf(str, _T("%i"), w);
+ mir_sntprintf(str, SIZEOF(str), _T("%i"), w);
}
//============ UNIT CONVERSIONS ============
@@ -109,17 +109,17 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str) // rounding
numToStr((temp-32)/9*5, tstr);
if (opt.DoNotAppendUnit)
- wsprintf(str, _T("%s"), tstr);
+ mir_sntprintf(str, SIZEOF(str), _T("%s"), tstr);
else
- wsprintf(str, _T("%s%sC"), tstr, opt.DegreeSign);
+ mir_sntprintf(str, SIZEOF(str), _T("%s%sC"), tstr, opt.DegreeSign);
break;
case 2:
numToStr(temp, tstr);
if (opt.DoNotAppendUnit)
- wsprintf(str, _T("%s"), tstr);
+ mir_sntprintf(str, SIZEOF(str), _T("%s"), tstr);
else
- wsprintf(str, _T("%s%sF"), tstr, opt.DegreeSign);
+ mir_sntprintf(str, SIZEOF(str), _T("%s%sF"), tstr, opt.DegreeSign);
break;
}
}
@@ -160,19 +160,19 @@ void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str) switch (opt.pUnit) {
case 1:
intunit = (int)(tempunit + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
break;
case 2:
intunit = (int)(tempunit + 0.5);
- wsprintf(str, _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb"));
break;
case 3:
intunit = (int)((tempunit*10 / 33.86388) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
break;
case 4:
intunit = (int)((tempunit*10 / 1.33322) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
break;
default:
_tcscpy(str, tempchar);
@@ -213,19 +213,19 @@ void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.wUnit) {
case 1:
numToStr(tempunit * 3.6, tstr);
- wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h"));
+ mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h"));
break;
case 2:
numToStr(tempunit, tstr);
- wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s"));
+ mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s"));
break;
case 3:
numToStr(tempunit / 0.44704, tstr);
- wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph"));
+ mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph"));
break;
case 4:
numToStr(tempunit / 0.514444, tstr);
- wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots"));
+ mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots"));
break;
}
}
@@ -258,11 +258,11 @@ void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.vUnit) {
case 1:
intunit = (int)((tempunit*10) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km"));
break;
case 2:
intunit = (int)((tempunit*10 / 1.609) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles"));
break;
default:
_tcscpy(str, tempchar);
@@ -298,11 +298,11 @@ void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.eUnit) {
case 1:
intunit = (int)((tempunit*10 * 3.28) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
break;
case 2:
intunit = (int)((tempunit*10) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
break;
default:
_tcscpy(str, tempchar);
@@ -550,7 +550,7 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str) name[0] = 0;
// read the entire variable name
while (dis[i] != ']' && i < _tcslen(dis)) {
- wsprintfA(temp, "%c", dis[i++]);
+ mir_snprintf(temp, SIZEOF(temp), "%c", dis[i++]);
strcat(name, temp);
}
// access the database to get its value
@@ -564,7 +564,7 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str) }
// if the character is not a variable, write the original character to the new string
else {
- wsprintf( lpzDate, _T("%c"), dis[i]);
+ mir_sntprintf(lpzDate, SIZEOF(lpzDate), _T("%c"), dis[i]);
_tcscat(str, lpzDate);
} }
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp index 935cf33dfd..78ff5e60b4 100644 --- a/plugins/Weather/src/weather_data.cpp +++ b/plugins/Weather/src/weather_data.cpp @@ -154,7 +154,7 @@ void EraseAllInfo() opt.DefStn = hContact;
if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) {
- wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
@@ -181,7 +181,7 @@ void EraseAllInfo() }
opt.DefStn = LastContact;
if ( !db_get_ts(LastContact,WEATHERPROTONAME, "Nick",&dbv)) {
- wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
diff --git a/plugins/Weather/src/weather_http.cpp b/plugins/Weather/src/weather_http.cpp index d9038db9c8..7cf39bfd54 100644 --- a/plugins/Weather/src/weather_http.cpp +++ b/plugins/Weather/src/weather_http.cpp @@ -156,7 +156,7 @@ int InternetDownloadFile (char *szUrl, char* cookie, TCHAR** szData) else {
*szData = ( TCHAR* )mir_alloc(512);
// store the error code in szData
- wsprintf(*szData, _T("Error occured! HTTP Error: %i\n"), nlhrReply->resultCode);
+ mir_sntprintf(*szData, 512, _T("Error occured! HTTP Error: %i\n"), nlhrReply->resultCode);
result = (int)nlhrReply->resultCode;
}
diff --git a/plugins/Weather/src/weather_svcs.cpp b/plugins/Weather/src/weather_svcs.cpp index 34e026b0d5..a398b748b9 100644 --- a/plugins/Weather/src/weather_svcs.cpp +++ b/plugins/Weather/src/weather_svcs.cpp @@ -148,12 +148,12 @@ INT_PTR WeatherGetAvatarInfo(WPARAM wParam, LPARAM lParam) return GAIR_NOAVATAR;
ai->format = PA_FORMAT_PNG;
- wsprintf(ai->filename, _T("%s\\Plugins\\Weather\\%s.png"), szSearchPath, statusStr[i]);
+ mir_sntprintf(ai->filename, SIZEOF(ai->filename), _T("%s\\Plugins\\Weather\\%s.png"), szSearchPath, statusStr[i]);
if ( _taccess(ai->filename, 4) == 0)
return GAIR_SUCCESS;
ai->format = PA_FORMAT_GIF;
- wsprintf(ai->filename, _T("%s\\Plugins\\Weather\\%s.gif"), szSearchPath, statusStr[i]);
+ mir_sntprintf(ai->filename, SIZEOF(ai->filename), _T("%s\\Plugins\\Weather\\%s.gif"), szSearchPath, statusStr[i]);
if ( _taccess(ai->filename, 4) == 0)
return GAIR_SUCCESS;
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index a6cee642ff..72eeb2cbf7 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -58,7 +58,7 @@ int UpdateWeather(HANDLE hContact) // error occurs if the return value is not equals to 0
if (opt.ShowWarnings)
{ // show warnings by popup
- mir_sntprintf(str, SIZEOF(str)-105,
+ mir_sntprintf(str, SIZEOF(str) - 105,
TranslateT("Unable to retrieve weather information for %s"), dbv.ptszVal);
_tcscat(str, _T("\n"));
_tcscat(str, GetError(code));
@@ -104,7 +104,7 @@ int UpdateWeather(HANDLE hContact) if ( !dbres && dbv.ptszVal[0] != 0) {
if (opt.AlertPopup && !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch) {
// display alert popup
- wsprintf(str, _T("Alert for %s%c%s"), winfo.city, 255, dbv.ptszVal);
+ mir_sntprintf(str, SIZEOF(str), _T("Alert for %s%c%s"), winfo.city, 255, dbv.ptszVal);
WPShowMessage(str, SM_WEATHERALERT);
}
// alert issued, set display to italic
@@ -406,19 +406,19 @@ int GetWeatherData(HANDLE hContact) // generate update URL
switch(i) {
case 0:
- _snprintf(loc, SIZEOF(loc), Data->UpdateURL, _T2A(id));
+ mir_snprintf(loc, SIZEOF(loc), Data->UpdateURL, _T2A(id));
break;
case 1:
- _snprintf(loc, SIZEOF(loc), Data->UpdateURL2, _T2A(id));
+ mir_snprintf(loc, SIZEOF(loc), Data->UpdateURL2, _T2A(id));
break;
case 2:
- _snprintf(loc, SIZEOF(loc), Data->UpdateURL3, _T2A(id));
+ mir_snprintf(loc, SIZEOF(loc), Data->UpdateURL3, _T2A(id));
break;
case 3:
- _snprintf(loc, SIZEOF(loc), Data->UpdateURL4, _T2A(id));
+ mir_snprintf(loc, SIZEOF(loc), Data->UpdateURL4, _T2A(id));
break;
default:
diff --git a/plugins/WhenWasIt/src/icons.cpp b/plugins/WhenWasIt/src/icons.cpp index 60afbf4fc4..3a9d670b8a 100644 --- a/plugins/WhenWasIt/src/icons.cpp +++ b/plugins/WhenWasIt/src/icons.cpp @@ -60,11 +60,11 @@ int AddIcons() hDTB[0] = AddIcon("DTB0", LPGEN("Birthday today"), tszPath, IDI_DTB0);
hDTB[1] = AddIcon("DTB1", LPGEN("1 day to birthday"), tszPath, IDI_DTB1);
for (int i = 2; i < cDTB; i++) {
- sprintf(name, "DTB%d", i);
- sprintf(description, Translate("%d days to birthday"), i);
+ mir_snprintf(name, SIZEOF(name), "DTB%d", i);
+ mir_snprintf(description, SIZEOF(description), Translate("%d days to birthday"), i);
hDTB[i] = AddIcon(name, description, tszPath, IDI_DTB0+i);
}
- sprintf(description, Translate("More than %d days to birthday"), cDTB - 1);
+ mir_snprintf(description, SIZEOF(description), Translate("More than %d days to birthday"), cDTB - 1);
hDTBMore = AddIcon("DTBMore", description, tszPath, IDI_DTBMORE);
hWWIExtraIcons = ExtraIcon_Register("WhenWasIt", LPGEN("WhenWasIt birthday reminder"), "MenuCheck");
diff --git a/plugins/WhenWasIt/src/utils.cpp b/plugins/WhenWasIt/src/utils.cpp index 323e63d979..a2f2bb6ade 100644 --- a/plugins/WhenWasIt/src/utils.cpp +++ b/plugins/WhenWasIt/src/utils.cpp @@ -47,7 +47,7 @@ int Log(char *format, ...) fputs(str, fout);
va_start(vararg, format);
- tBytes = _vsnprintf(str, sizeof(str), format, vararg);
+ tBytes = mir_vsnprintf(str, sizeof(str), format, vararg);
if (tBytes > 0)
{
str[tBytes] = 0;
@@ -70,7 +70,7 @@ int Info(char *title, char *format, ...) va_list vararg;
int tBytes;
va_start(vararg, format);
- tBytes = _vsnprintf(str, sizeof(str), format, vararg);
+ tBytes = mir_vsnprintf(str, sizeof(str), format, vararg);
if (tBytes > 0)
{
str[tBytes] = 0;
@@ -88,12 +88,12 @@ char *BinToHex(int size, PBYTE data) int maxSize = size * 2 + HEX_SIZE + 1;
szresult = (char *) new char[ maxSize ];
memset(szresult, 0, maxSize);
- sprintf(buffer, "%0*X", HEX_SIZE, size);
+ mir_snprintf(buffer, SIZEOF(buffer), "%0*X", HEX_SIZE, size);
strcpy(szresult, buffer);
int i;
for (i = 0; i < size; i++)
{
- sprintf(buffer, "%02X", data[i]);
+ mir_snprintf(buffer, SIZEOF(buffer), "%02X", data[i]);
strcpy(szresult + (HEX_SIZE + i * 2), buffer);
}
return szresult;
@@ -193,17 +193,17 @@ TCHAR *GetContactID(HANDLE hContact, char *szProto) TCHAR tmp[16];
switch (ctInfo.type) {
case CNFT_BYTE:
- _stprintf(tmp, _T("%d"), ctInfo.bVal);
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%d"), ctInfo.bVal);
buffer = _tcsdup(tmp);
break;
case CNFT_WORD:
- _stprintf(tmp, _T("%d"), ctInfo.wVal);
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%d"), ctInfo.wVal);
buffer = _tcsdup(tmp);
break;
case CNFT_DWORD:
- _stprintf(tmp, _T("%ld"), ctInfo.dVal);
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%ld"), ctInfo.dVal);
buffer = _tcsdup(tmp);
break;
diff --git a/plugins/WhoUsesMyFiles/src/list.cpp b/plugins/WhoUsesMyFiles/src/list.cpp index fbf898f566..641f8f5e19 100644 --- a/plugins/WhoUsesMyFiles/src/list.cpp +++ b/plugins/WhoUsesMyFiles/src/list.cpp @@ -24,7 +24,7 @@ PWumf new_wumf( DWORD dwID, case PERM_FILE_CREATE: _tcscpy(w->szPerm, _T("Create"));break;
default: _tcscpy(w->szPerm, _T("Execute"));
}
- wsprintf(w->szID, _T("%i"), dwID);
+ mir_sntprintf(w->szID, SIZEOF(w->szID), _T("%i"), dwID);
w->dwID = dwID;
w->dwSess = dwSess;
diff --git a/plugins/YAMN/src/mails/mime.cpp b/plugins/YAMN/src/mails/mime.cpp index 4e29884b14..30706d9cc2 100644 --- a/plugins/YAMN/src/mails/mime.cpp +++ b/plugins/YAMN/src/mails/mime.cpp @@ -661,36 +661,36 @@ FailBackRaw: for (i=0;i<numparts;i++) {
if (i) { // part before first boudary should not have headers
char infoline[1024]; size_t linesize = 0;
- _snprintf(infoline,100,"%s %d",Translate("Part"),i);
+ mir_snprintf(infoline, SIZEOF(infoline), "%s %d", Translate("Part"), i);
linesize = strlen(infoline);
if (partData[i].TransEnc) {
- _snprintf(infoline+linesize, sizeof(infoline)-linesize,"; %s",partData[i].TransEnc);
+ mir_snprintf(infoline + linesize, SIZEOF(infoline) - linesize, "; %s", partData[i].TransEnc);
linesize = strlen(infoline);
}
if (partData[i].ContType) {
char *CharSetStr=strchr(partData[i].ContType,';');
if (CharSetStr) {
CharSetStr[0]=0;
- _snprintf(infoline+linesize,sizeof(infoline)-linesize,"; %s",partData[i].ContType);
+ mir_snprintf(infoline + linesize, SIZEOF(infoline) - linesize, "; %s", partData[i].ContType);
linesize = strlen(infoline);
partData[i].ContType=CharSetStr+1;
if (NULL != (CharSetStr=ExtractFromContentType(partData[i].ContType,"charset="))) {
- _snprintf(infoline+linesize,sizeof(infoline)-linesize,"; %s",CharSetStr);
+ mir_snprintf(infoline + linesize, SIZEOF(infoline) - linesize, "; %s", CharSetStr);
linesize = strlen(infoline);
delete[] CharSetStr;
}
if (NULL != (CharSetStr=ExtractFromContentType(partData[i].ContType,"name="))) {
- _snprintf(infoline+linesize,sizeof(infoline)-linesize,"; \"%s\"",CharSetStr);
+ mir_snprintf(infoline + linesize, SIZEOF(infoline) - linesize, "; \"%s\"", CharSetStr);
linesize = strlen(infoline);
delete[] CharSetStr;
}
}
else {
- _snprintf(infoline+linesize,sizeof(infoline)-linesize,"; %s",partData[i].ContType);
+ mir_snprintf(infoline + linesize, SIZEOF(infoline) - linesize, "; %s", partData[i].ContType);
linesize = strlen(infoline);
}
}
- sprintf(infoline+linesize,".\r\n");
+ mir_snprintf(infoline + linesize, SIZEOF(infoline) - linesize, ".\r\n");
{
WCHAR *temp=0;
dest[destpos] = dest[destpos+1] = dest[destpos+2] = 0x2022; // bullet;
diff --git a/plugins/YAMN/src/proto/netlib.cpp b/plugins/YAMN/src/proto/netlib.cpp index 0ae92f6f33..e9a1f61dd9 100644 --- a/plugins/YAMN/src/proto/netlib.cpp +++ b/plugins/YAMN/src/proto/netlib.cpp @@ -14,11 +14,11 @@ HANDLE hNetlibUser=NULL; void __stdcall SSL_DebugLog(const char *fmt, ...)
{
- char str[ 4096 ];
+ char str[4096];
va_list vararg;
va_start( vararg, fmt );
- int tBytes = _vsnprintf( str, sizeof(str)-1, fmt, vararg );
+ int tBytes = mir_vsnprintf(str, SIZEOF(str), fmt, vararg);
if ( tBytes == 0 )
return;
@@ -36,7 +36,7 @@ HANDLE RegisterNLClient(const char *name) static NETLIBUSER nlu={0};
char desc[128];
- sprintf(desc, Translate("%s connection"),name);
+ mir_snprintf(desc, SIZEOF(desc), Translate("%s connection"), name);
#ifdef DEBUG_COMM
DebugLog(CommFile,"<Register PROXY support>");
diff --git a/plugins/YAMN/src/proto/pop3/pop3.cpp b/plugins/YAMN/src/proto/pop3/pop3.cpp index d3f14af9a1..8ca1f2bfb2 100644 --- a/plugins/YAMN/src/proto/pop3/pop3.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3.cpp @@ -124,7 +124,6 @@ char* CPop3Client::RecvRest(char* prev,int mode,int size) NetClient->Recv(PrevString+RcvAll,SizeLeft); //to Rcv stores received bytes SizeLeft=SizeLeft-NetClient->Rcv; RcvAll+=NetClient->Rcv; -// printf("[Read: %s]\n",PrevString); } NetClient->Rcv=RcvAll; //at the end, store the number of all bytes, no the number of last received bytes return PrevString; @@ -202,7 +201,7 @@ char* CPop3Client::User(char* name) char query[128]; char *Result; - sprintf(query,"USER %s\r\n",name); + mir_snprintf(query, SIZEOF(query), "USER %s\r\n", name); NetClient->Send(query); Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); if (AckFlag==POP3_FERR) @@ -221,7 +220,7 @@ char* CPop3Client::Pass(char* pw) char query[128]; char *Result; - sprintf(query,"PASS %s\r\n",pw); + mir_snprintf(query, SIZEOF(query), "PASS %s\r\n", pw); NetClient->Send(query); Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); if (AckFlag==POP3_FERR) @@ -251,10 +250,10 @@ char* CPop3Client::APOP(char* name, char* pw, char* timestamp) hexdigest[0]='\0'; for (int i=0; i < 16; i++) { char tmp[4]; - sprintf(tmp, "%02x", digest[i]); + mir_snprintf(tmp, SIZEOF(tmp), "%02x", digest[i]); strcat(hexdigest, tmp); } - sprintf(query,"APOP %s %s\r\n",name, hexdigest); + mir_snprintf(query, SIZEOF(query), "APOP %s %s\r\n", name, hexdigest); NetClient->Send(query); Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); if (AckFlag==POP3_FERR) @@ -307,7 +306,7 @@ char* CPop3Client::Top(int nr, int lines) char query[128]; - sprintf(query,"TOP %d %d\r\n",nr,lines); + mir_snprintf(query, SIZEOF(query), "TOP %d %d\r\n", nr, lines); NetClient->Send(query); return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); } @@ -323,11 +322,11 @@ char* CPop3Client::Uidl(int nr) if (nr) { - sprintf(query,"UIDL %d\r\n",nr); + mir_snprintf(query, SIZEOF(query), "UIDL %d\r\n", nr); NetClient->Send(query); return RecvRest(NetClient->Recv(),POP3_SEARCHACK); } - sprintf(query,"UIDL\r\n"); + mir_snprintf(query, SIZEOF(query), "UIDL\r\n"); NetClient->Send(query); return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); } @@ -341,7 +340,7 @@ char* CPop3Client::Dele(int nr) char query[128]; - sprintf(query,"DELE %d\r\n",nr); + mir_snprintf(query, SIZEOF(query), "DELE %d\r\n", nr); NetClient->Send(query); return RecvRest(NetClient->Recv(),POP3_SEARCHACK); } @@ -354,7 +353,7 @@ char* CPop3Client::Retr(int nr) char query[128]; - sprintf(query,"RETR %d\r\n",nr); + mir_snprintf(query, SIZEOF(query), "RETR %d\r\n", nr); NetClient->Send(query); RecvRest(NetClient->Recv(),POP3_SEARCHACK); return NetClient->Recv(); diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp index f34251b1c2..fe1bce4457 100644 --- a/plugins/YAMN/src/proto/pop3/pop3comm.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp @@ -261,7 +261,7 @@ int RegisterPOP3Plugin(WPARAM,LPARAM) if (ERROR_FILE_NOT_FOUND != GetLastError())
{
TCHAR temp[1024] = {0};
- mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"),TranslateT("Reading file error. File already in use?"),FileName);
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"), TranslateT("Reading file error. File already in use?"), FileName);
MessageBox(NULL,temp,TranslateT("YAMN (internal POP3) read error"),MB_OK);
CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
FileName = NULL;
@@ -331,7 +331,7 @@ DWORD WINAPI WritePOP3Accounts() DWORD ReturnValue = CallService(MS_YAMN_WRITEACCOUNTS,(WPARAM)POP3Plugin,(LPARAM)FileName);
if (ReturnValue == EACC_SYSTEM) {
TCHAR temp[1024] = {0};
- mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"), TranslateT("Error while copying data to disk occured. File in use?"), FileName );
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"), TranslateT("Error while copying data to disk occured. File in use?"), FileName);
MessageBox(NULL, temp, TranslateT("POP3 plugin- write file error"), MB_OK );
}
@@ -367,7 +367,7 @@ DWORD WINAPI ReadPOP3Options(HACCOUNT Which,char **Parser,char *End) if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
- _stprintf(Debug,_T("CodePage: %d, remaining %d chars"),((HPOP3ACCOUNT)Which)->CP,End-*Parser);
+ mir_sntprintf(Debug, SIZEOF(Debug), _T("CodePage: %d, remaining %d chars"), ((HPOP3ACCOUNT)Which)->CP, End-*Parser);
MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
return 0;
@@ -699,7 +699,7 @@ DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp) for (NewMsgsPtr=(HYAMNMAIL)NewMails;NewMsgsPtr != NULL;NewMsgsPtr=NewMsgsPtr->Next) {
if (!strcmp(MsgQueuePtr->ID,NewMsgsPtr->ID)) {
TCHAR accstatus[512];
- wsprintf(accstatus,TranslateT("Reading body %s"),NewMsgsPtr->ID);
+ mir_sntprintf(accstatus, SIZEOF(accstatus), TranslateT("Reading body %s"), NewMsgsPtr->ID);
SetAccountStatus(ActualAccount,accstatus);
DataRX=MyClient->Top(MsgQueuePtr->Number,100);
#ifdef DEBUG_DECODE
@@ -772,7 +772,7 @@ DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp) {
BOOL autoretr = (ActualAccount->Flags & YAMN_ACC_BODY) != 0;
DataRX=MyClient->Top(MsgQueuePtr->Number,autoretr?100:0);
- wsprintf(accstatus,TranslateT("Reading new mail messages (%d%% done)"),100*i/msgs);
+ mir_sntprintf(accstatus, SIZEOF(accstatus), TranslateT("Reading new mail messages (%d%% done)"), 100 * i / msgs);
SetAccountStatus(ActualAccount,accstatus);
#ifdef DEBUG_DECODE
@@ -1528,14 +1528,14 @@ TCHAR* WINAPI GetErrorString(DWORD Code) TCHAR *ErrorString = new TCHAR[ERRORSTR_MAXLEN];
POP3_ERRORCODE *ErrorCode=(POP3_ERRORCODE *)(UINT_PTR)Code;
- mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, TranslateT("Error %d-%d-%d-%d:"),ErrorCode->AppError,ErrorCode->POP3Error,ErrorCode->NetError,ErrorCode->SystemError);
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, TranslateT("Error %d-%d-%d-%d:"), ErrorCode->AppError, ErrorCode->POP3Error, ErrorCode->NetError,ErrorCode->SystemError);
if (ErrorCode->POP3Error)
- mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"),ErrorString,TranslateTS(POP3Errors[ErrorCode->POP3Error-1]));
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(POP3Errors[ErrorCode->POP3Error-1]));
if (ErrorCode->NetError) {
if (ErrorCode->SSL)
- mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"),ErrorString, TranslateTS(SSLErrors[ErrorCode->NetError-1]));
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(SSLErrors[ErrorCode->NetError-1]));
else
- mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"),ErrorString, TranslateTS(NetlibErrors[ErrorCode->NetError-4]));
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(NetlibErrors[ErrorCode->NetError-4]));
}
return ErrorString;
diff --git a/plugins/mTextControl/src/FormattedTextDraw.cpp b/plugins/mTextControl/src/FormattedTextDraw.cpp index fe8b0b27ea..247b688189 100644 --- a/plugins/mTextControl/src/FormattedTextDraw.cpp +++ b/plugins/mTextControl/src/FormattedTextDraw.cpp @@ -120,7 +120,7 @@ HRESULT CFormattedTextDraw::putTextA(char *newVal) cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE|CFM_BOLD;
cf.dwEffects = 0;
- wsprintf(cf.szFaceName, _T("MS Shell Dlg"));
+ mir_sntprintf(cf.szFaceName, SIZEOF(cf.szFaceName), _T("MS Shell Dlg"));
m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, (WPARAM)(SCF_ALL), (LPARAM)&cf, &lResult);
return S_OK;
@@ -149,7 +149,7 @@ HRESULT CFormattedTextDraw::putTextW(WCHAR *newVal) cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE|CFM_BOLD;
cf.dwEffects = 0;
- wsprintf(cf.szFaceName, _T("MS Shell Dlg"));
+ mir_sntprintf(cf.szFaceName, SIZEOF(cf.szFaceName), _T("MS Shell Dlg"));
m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, (WPARAM)(SCF_ALL), (LPARAM)&cf, &lResult);
return S_OK;
@@ -173,7 +173,7 @@ HRESULT CFormattedTextDraw::Draw(void *hdcDraw, RECT *prc) cf.crTextColor = GetTextColor((HDC)hdcDraw);
cf.bCharSet = lf.lfCharSet;
cf.yHeight = 1440 * abs(lf.lfHeight) / GetDeviceCaps((HDC)hdcDraw, LOGPIXELSY);
- wsprintf(cf.szFaceName, lf.lfFaceName);
+ mir_sntprintf(cf.szFaceName, SIZEOF(cf.szFaceName), lf.lfFaceName);
m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, (WPARAM)(SCF_ALL), (LPARAM)&cf, &lResult);
m_spTextServices->TxDraw(
@@ -214,7 +214,7 @@ HRESULT CFormattedTextDraw::get_NaturalSize(void *hdcDraw, long *Width, long *He cf.crTextColor = GetTextColor((HDC)hdcDraw);
cf.bCharSet = lf.lfCharSet;
cf.yHeight = 1440 * abs(lf.lfHeight) / GetDeviceCaps((HDC)hdcDraw, LOGPIXELSY);
- wsprintf(cf.szFaceName, lf.lfFaceName);
+ mir_sntprintf(cf.szFaceName, SIZEOF(cf.szFaceName), lf.lfFaceName);
if (!m_spTextServices)
return S_FALSE;
|