Exemplo n.º 1
0
void UGStr::stprintf(TCHAR * dest, size_t size, const TCHAR * src, ...)
{
	va_list vl;
	va_start( vl, src );

#ifdef _UNICODE
#if _MSC_VER >= 1400
	_vswprintf_s_l(dest, size, src, NULL, vl);
#else
	UNREFERENCED_PARAMETER(size);
	_vstprintf(dest, src, vl);
# endif
#else
#if _MSC_VER >= 1400
    _vsprintf_s_l(dest, size, src, NULL, vl);
#else
	UNREFERENCED_PARAMETER(size);
	_vstprintf(dest, src, vl);
# endif
#endif

	va_end( vl );
}
Exemplo n.º 2
0
int CHgzComboBox::SetWindowsTextFormat( const TCHAR * szFormat, ... )
{
    va_list arglist;
    va_start(arglist, szFormat);
    int len = _vsctprintf(szFormat, arglist)+1;
    TCHAR *buf = new TCHAR[len];
    //TCHAR *buf = (TCHAR *)_alloca((_vsctprintf(szFormat, arglist)+1)*sizeof(TCHAR)); // 动态分配栈内存,无需手动释放。
    _vstprintf(buf, szFormat, arglist);

    SetWindowText(buf);
    delete [] buf;

    return len-1;
}
Exemplo n.º 3
0
void __cdecl AfxTrace( LPCTSTR lpszFormat, ... )
/**********************************************/
{
#ifdef _DEBUG
    va_list args;
    TCHAR   szBuff[1024];
    va_start( args, lpszFormat );
    _vstprintf( szBuff, lpszFormat, args );
    ::OutputDebugString( szBuff );
    va_end( args );
#else
    lpszFormat = lpszFormat;
#endif
}
Exemplo n.º 4
0
	void _cdecl TMSG( const TCHAR *str, ... )
	{
		DWORD dwBytesWritten = 0;

		va_list arglist;

		va_start( arglist, str );

		dwBytesWritten = _vstprintf( temp, str, arglist );

		WriteFile( hTmsgFile, temp, _tcslen(temp), &dwBytesWritten, NULL );

		va_end( arglist );
	}
Exemplo n.º 5
0
/*static*/ int CMisc::Message(LPCTSTR szFmt, ...)
{
	TCHAR	szBuffer[2048];
	va_list args;
	int		bytesWriten = 0;

	va_start(args, szFmt);
	bytesWriten = _vstprintf(szBuffer, szFmt, args);

	va_end(args);


	return ::MessageBox(NULL, szBuffer, NULL, MB_ICONSTOP | MB_OK);
}
Exemplo n.º 6
0
void Msg(TCHAR *szFormat, ...)
{
    TCHAR szBuffer[512];  // Large buffer for very long filenames (like with HTTP)

    va_list pArgs;
    va_start(pArgs, szFormat);
    _vstprintf(szBuffer, szFormat, pArgs);
    va_end(pArgs);

    // This sample uses a simple message box to convey warning and error
    // messages.   You may want to display a debug string or suppress messages
    // altogether, depending on your application.
    MessageBox(NULL, szBuffer, TEXT("PlayCutscene Error"), MB_OK);
}
Exemplo n.º 7
0
// 抛出字符串形式异常
VOID tThrowStringException(LPCTSTR szFmt, ...)
{
	va_list argList;
	va_start(argList, szFmt);

	UINT nSize = _vsctprintf(szFmt, argList);

	STRING strMessage;
	strMessage.assign(nSize+1, _T(' '));
	_vstprintf((LPTSTR)&(strMessage[0]), szFmt, argList);
	va_end(argList);

	throw std::exception(strMessage.c_str());
}
Exemplo n.º 8
0
	//记录日志事件到系统中
	void LogErrorEvent(LPCTSTR pFormat,...)
	{
		_TCHAR pMsg[MAX_PATH];

		va_list pArg;
		va_start(pArg,pFormat);
		_vstprintf(pMsg,pFormat,pArg);
		va_end(pArg);

		LPCTSTR pStr[1] = {pMsg};
		if (hEventSource == NULL)
			hEventSource = RegisterEventSource(NULL,PServiceManage::Instance()->ServiceName());
		ReportEvent(hEventSource,EVENTLOG_ERROR_TYPE,0,EVENTID,NULL,1,0,pStr,NULL);
	}
Exemplo n.º 9
0
void
trace (LPCTSTR fmt, ...)
{
  static TCHAR buf[1024];
  va_list ap;
  va_start (ap,fmt);
  _vstprintf (buf, fmt, ap);
#if 0
  OutputDebugString(buf);
#else
  _fputts (buf, stderr);
  fputc ('\n', stderr);
#endif
}
void CProgressWnd::SetText(LPCTSTR fmt, ...)
{
    if (!::IsWindow(GetSafeHwnd())) 
        return;

    va_list args;
    TCHAR buffer[512];

    va_start(args, fmt);
    _vstprintf(buffer, fmt, args);
    va_end(args);

    m_Text.SetWindowText(buffer);
}
Exemplo n.º 11
0
/*************************************************************************
	throw a exception
*************************************************************************/
void Util::throwException(const char* szFmt, ...)
{
    va_list argList;
    va_start(argList, szFmt);

    unsigned int nSize = _vsctprintf(szFmt, argList);

    std::string strMessage;
    strMessage.assign(nSize+1, _T(' '));
    _vstprintf((LPTSTR)&(strMessage[0]), szFmt, argList);
    va_end(argList);

    throw std::exception(strMessage.c_str());
}
Exemplo n.º 12
0
void BrowserInfo::OutputString(const TCHAR *szMessage, ...)
{
	TCHAR szBuffer[256];

	va_list cArgs;
	va_start(cArgs, szMessage);
	_vstprintf(szBuffer, szMessage, cArgs);
	va_end(cArgs);

	CString szOutput;
	szOutput.Format(_T("  Test: %s"), szBuffer);

	pBrowseDlg->OutputString(szOutput);
}
Exemplo n.º 13
0
void __cdecl zdlTraceLine2(CString astrFileOrFunc,int anLine,LPCTSTR apszFormat, ...)
{
	va_list  args;

	va_start(args, apszFormat);

	va_list argListSave = args;

	int lnDataLength = GetFormatLength(apszFormat,args);

	CString lstrTempData;

	LPCTSTR lpszBuffer =  lstrTempData.GetBufferSetLength(lnDataLength);

	_vstprintf((TCHAR *)lpszBuffer, apszFormat, argListSave);

	lstrTempData.ReleaseBuffer(lnDataLength);

	CString lstrTemp;

#ifdef _UNICODE
	lstrTemp.Format(_T("[Module: %[email protected]%n ] :%S"),astrFileOrFunc,anLine,lstrTempData);
#else
	lstrTemp.Format(_T("[Module: %[email protected]%n ] :%s"),astrFileOrFunc,anLine,lstrTempData);
#endif
	

#ifdef _UNICODE

	::OutputDebugStringW(lstrTemp.GetBuffer(0));

	::OutputDebugStringW(_T("\r\n"));

#else

	::OutputDebugStringA(lstrTemp.GetBuffer(0));

	::OutputDebugStringA(_T("\r\n"));

#endif

	lstrTempData.ReleaseBuffer();

	va_end(argListSave);

	va_end(args);


}
Exemplo n.º 14
0
VOID WriteLogFormat(WCHAR* msg, ...)
{
	size_t size = 4096;
	wchar_t * buffer = new wchar_t[size];
	ZeroMemory(buffer, size * sizeof(wchar_t));
	va_list params;

	va_start(params, msg);
	_vstprintf(buffer, size, msg, params);
	va_end(params);

	WriteLog(buffer);

	delete[] buffer;
}
Exemplo n.º 15
0
 		void PrintEx(LPCTSTR lpszFormat, ...)
 		{
			va_list args;
			va_start(args, lpszFormat);
			_vstprintf(m_szDebug, lpszFormat, args); 
		//	nBuf = _vsprintf(m_szDebug, lpszFormat, args);
		//	_vsnprintf(m_szDebug, _countof(m_szDebug), lpszFormat, args);
			va_end(args);

#ifdef UNDER_CE
			_tprintf(m_szDebug);
#else
			OutputDebugString(m_szDebug);
#endif
 		}
Exemplo n.º 16
0
  void _cdecl TCTrace(LPCTSTR lpszFormat, ...)
  {
    va_list args;
    va_start(args, lpszFormat);

    int nBuf;
    TCHAR szBuffer[512];

    nBuf = _vstprintf(szBuffer, lpszFormat, args);
    assert(nBuf < sizeof(szBuffer));

    USES_CONVERSION;
    ZDebugOutputImpl(T2CA(szBuffer));
    va_end(args);
  }
Exemplo n.º 17
0
//-------------------------------------------------------------------------------------------
//
// Prints a message into a given text box
//
//
void CChildSrvrDlg::PrintMessage(LPCTSTR Format, ...)
{
  TCHAR Buf[1024], Buf2[1024];
  va_list marker;

  va_start(marker, Format);
  _vstprintf(Buf, Format, marker);
  FixMultiLine(Buf, Buf2);

  _tcscat(Buf2, _T("\r\n"));

  int nLen = m_txtChildLog.GetWindowTextLength();
  m_txtChildLog.SetSel(nLen, nLen, TRUE);
  m_txtChildLog.ReplaceSel(Buf2);
}
Exemplo n.º 18
0
void LOG(LPCTSTR fmt, ...)
{
	va_list args;
	va_start(args, fmt);
	if(TCHAR* buff = new TCHAR[_vsctprintf(fmt, args) + 1]) {
		_vstprintf(buff, fmt, args);
		if(FILE* f = _tfopen(LOG_FILE, _T("at"))) {
			fseek(f, 0, 2);
			_ftprintf(f, _T("%s\n"), buff);
			fclose(f);
		}
		delete [] buff;
	}
	va_end(args);
}
Exemplo n.º 19
0
void CxStatic::Format(LPCTSTR szFmt, ...)
{
	ULONG	bytesWriten;
	TCHAR	szBuffer[2048];
	va_list args;

	va_start(args, szFmt);
	bytesWriten = _vstprintf(szBuffer, szFmt, args);

	m_strText = szBuffer;

	va_end(args);

	RedrawWindow();
}
Exemplo n.º 20
0
void FailStore(const TCHAR *Str, ...)
{
  TCHAR buf[MAX_PATH];
  va_list ap;

  va_start(ap, Str);
  _vstprintf(buf, Str, ap);
  va_end(ap);

  FILE *stream=NULL;
  static TCHAR szFileName[MAX_PATH];
  static bool initialised = false;

  if (!initialised) {
	LocalPath(szFileName, TEXT(LKF_FAILLOG));
	stream = _tfopen(szFileName, TEXT("ab+"));
	if (stream) {
		fclose(stream);
	}
	initialised = true;
  } 
  stream = _tfopen(szFileName,TEXT("ab+"));
  if (stream == NULL) {
	StartupStore(_T("------ FailStore failed, cannot open <%s>%s"), szFileName, NEWLINE);
	return;
  }
  fprintf(stream, "------%s%04d%02d%02d-%02d:%02d:%02d [%09u] FailStore Start, Version %s%s (%s %s) FreeRam=%ld %s",SNEWLINE,
	GPS_INFO.Year,GPS_INFO.Month,GPS_INFO.Day, GPS_INFO.Hour,GPS_INFO.Minute,GPS_INFO.Second,
	(unsigned int)GetTickCount(),LKVERSION, LKRELEASE,
	"",
#if WINDOWSPC >0
	"PC",
#else
	#ifdef PNA
	"PNA",
	#else
	"PDA",
	#endif
#endif

CheckFreeRam(),SNEWLINE); 
  fprintf(stream, "Message: %S%s", buf, SNEWLINE);
  fprintf(stream, "GPSINFO: Latitude=%f Longitude=%f Altitude=%f Speed=%f %s", 
	GPS_INFO.Latitude, GPS_INFO.Longitude, GPS_INFO.Altitude, GPS_INFO.Speed, SNEWLINE);

  fclose(stream);
  StartupStore(_T("------ %s%s"),buf,NEWLINE);
}
Exemplo n.º 21
0
	DWORD  CWin32Svr::AddLogToEvent(LPCTSTR fmt, ...)
	{
		HANDLE hEvent = RegisterEventSource(NULL, m_szSvrName);
		
		TCHAR xbuf[1024] = {0};
		va_list marker;
		va_start(marker, fmt);
		int len = _vstprintf(xbuf, fmt, marker);
		va_end(marker);
		LPCTSTR p[1] = {xbuf};
	
		ReportEvent(hEvent, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, p, NULL);
		DeregisterEventSource(hEvent);

		return ERROR_SUCCESS;
	}
Exemplo n.º 22
0
//
// Function:  ErrMsg
//
// Purpose:   Insert text for each network component type.
//
// Arguments:
//    hr  [in]  Error code.
//
// Returns:   None.
//
// Notes:
//
VOID ErrMsg(HRESULT hr, LPCTSTR  lpFmt, ...)
{
	LPTSTR lpSysMsg;
	TCHAR buf[400];
	ULONG offset;
	va_list vArgList; 

	if (hr != 0)
	{
		_stprintf(buf, _T("Error %#lx: "), hr);
	}
	else
	{
		buf[0] = 0;
	}

	offset = (ULONG) _tcslen(buf);

	va_start(vArgList, lpFmt);

	_vstprintf(buf + offset, lpFmt, vArgList);

	va_end(vArgList);

	if (hr != 0)
	{
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpSysMsg, 0, NULL);

		if (lpSysMsg)
		{
			offset = (ULONG) _tcslen(buf);

			_stprintf(buf + offset, L"\n\nPossible cause:\n\n");

			offset = (ULONG) _tcslen(buf);

			_tcscat(buf + offset, lpSysMsg);

			LocalFree((HLOCAL)lpSysMsg);
		}
	}

	//_tprintf( buf );
	TRACE_PRINT_WIDECHAR(buf);

	return;
}
Exemplo n.º 23
0
void Log::ReallyPrint(LPTSTR format, va_list ap) 
{
    TCHAR line[LINE_BUFFER_SIZE];
    _vstprintf(line, format, ap);
    if (m_todebug) OutputDebugString(line);

    if (m_toconsole) {
        DWORD byteswritten;
        WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), line, _tcslen(line)*sizeof(TCHAR), &byteswritten, NULL); 
    };

    if (m_tofile && (hlogfile != NULL)) {
        DWORD byteswritten;
        WriteFile(hlogfile, line, _tcslen(line)*sizeof(TCHAR), &byteswritten, NULL); 

    }	
}
Exemplo n.º 24
0
void CWebGrabSession::SetStatus(LPCTSTR fmt, ...)
{
    va_list args;
    TCHAR buffer[512];

    va_start(args, fmt);
    _vstprintf(buffer, fmt, args);
    va_end(args);

    TRACE1("CWebGrabSession::SetStatus: %s\n", buffer);
	errorMessage = (CString) buffer;
    if (m_pStatusWnd)
    {
        m_pStatusWnd->SetWindowText(buffer);
        m_pStatusWnd->RedrawWindow();
    }
}
Exemplo n.º 25
0
void LogToFile(LOG_LEVEL ll, const TCHAR* fmt, ...)
{
    TCHAR text[MAX_LOG_LENGTH] = {};

    va_list vl;
    va_start( vl, fmt );
    _vstprintf(text, fmt , vl);
    va_end( vl);      
    // 最后的字符串处理
#ifdef _DEBUG
    TCHAR dateTime[MAX_LOG_LENGTH] = {};
    GetCurrentDateTime(dateTime);
    _tprintf(_T("%s [%s]  %s\r\n" ), dateTime, s_logInfo[ll], text);
#endif

    Log()->Write(ll, text, _tcsclen(text));
}
Exemplo n.º 26
0
void GC_TRACE(LPCTSTR lpstrTrace,...)
{
	va_list args;
	int len;
	LPTSTR buffer;

	va_start( args, lpstrTrace );
	len = _vsctprintf( lpstrTrace, args ) // _vscprintf doesn't count
		+ 1; // terminating '\0'
	buffer = (LPTSTR)malloc( len * sizeof(LPTSTR) );
	_vstprintf( buffer, lpstrTrace, args );
	::OutputDebugStringA(buffer);

	//errLog("d:\\zzy.log",COleDateTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S").GetBuffer());
	//errLogLn("d:\\zzy.log",buffer);
	free(buffer);
	return;
}
Exemplo n.º 27
0
int AFX_CDECL GraphicsMisc::GetTextWidth(CDC* pDC, LPCTSTR lpszFormat, ...)
{
	static TCHAR BUFFER[2048];

	ASSERT(AfxIsValidString(lpszFormat));

	va_list argList;
	va_start(argList, lpszFormat);
//fabio_2005
#if _MSC_VER >= 1400
	_vstprintf_s(BUFFER, lpszFormat, argList);
#else
	_vstprintf(BUFFER, lpszFormat, argList);
#endif
	va_end(argList);

	return pDC->GetTextExtent(BUFFER).cx;
}
Exemplo n.º 28
0
	void _cdecl Error( const TCHAR *str, ... )
	{
		DWORD dwBytesWritten = 0;

		va_list arglist;

		va_start( arglist, str );

		dwBytesWritten = _vstprintf( temp, str, arglist );

		WriteFile( hFile, temp, _tcslen(temp), &dwBytesWritten, NULL );

		//_tprintf( temp );

		//FlushFileBuffers( hFile );

		va_end( arglist );
	}
Exemplo n.º 29
0
void DebugTell(TCHAR* str,...)
{
//#ifdef _DEBUG
	if (!g_bDebugMode)
		return;
	m_dts.Lock();
	TCHAR buf[2048];
	va_list argptr;
	
	va_start(argptr,str);
	_vstprintf(buf,str,argptr);
	va_end(argptr);

	TCHAR cFileName[1024];
	TCHAR cLogOutput[2099];
	SYSTEMTIME thetime;

	_stprintf(cLogOutput,"%s\n",buf);
	OutputDebugString(cLogOutput);


	DWORD dwNumBytesWritten = 0;
	GetLocalTime(&thetime);
	_stprintf(cFileName,"c:\\%s.log",g_cDebugTellAppName);
	_stprintf(cLogOutput,"[%d/%d/%d %02d:%02d:%02d] %s\n",
		thetime.wMonth,thetime.wDay,thetime.wYear,
		thetime.wHour,thetime.wMinute,thetime.wSecond,
		buf);
	HANDLE hFile = CreateFile(cFileName,GENERIC_WRITE,
		0,0,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
	SetFilePointer(hFile,0,0,FILE_END);
	WriteFile(hFile,cLogOutput,strlen(cLogOutput),&dwNumBytesWritten,0);
	CloseHandle(hFile);

	if (m_Socket)
	{
		send(m_Socket,cLogOutput,strlen(cLogOutput),0);
	}
	m_dts.Unlock();
//#else
	UNREFERENCED_PARAMETER(str);
//#endif
}
Exemplo n.º 30
0
void Trace(LPCTSTR lpszFormat, ...)
{
	va_list args;
	va_start(args, lpszFormat);

	int nBuf;
	TCHAR szBuffer[512];

	nBuf = _vstprintf(szBuffer, lpszFormat, args);
	ASSERT(nBuf < (sizeof(szBuffer)/sizeof(szBuffer[0])));

	CString strMessage;

	if (AfxGetApp() != NULL)
		strMessage = ((CString) (AfxGetApp()->m_pszExeName)) + _T(": ");
	strMessage += szBuffer;
	OutputDebugString(strMessage);

	va_end(args);
}