Example #1
0
inline void _cdecl RxTrace(const TCHAR* lpszFormat, ...)
{
	va_list args;
	va_start(args, lpszFormat);
	int nBuf;
	TCHAR szBuffer[512];
	nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args);
	// was there an error?
	RXASSERT(nBuf >= 0);
    ::OutputDebugString(szBuffer);
	va_end(args);
}
Example #2
0
void write_log (const TCHAR *format, ...)
{
	int count;
	TCHAR buffer[WRITE_LOG_BUF_SIZE];
	va_list parms;
	va_start (parms, format);
	if (debug) {
		count = _vsntprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
		_tprintf (buffer);
	}
	va_end (parms);
}
Example #3
0
void write_log (const TCHAR *format, ...)
{
	int count;
	TCHAR buffer[WRITE_LOG_BUF_SIZE], *ts;
	int bufsize = WRITE_LOG_BUF_SIZE;
	TCHAR *bufp;
	va_list parms;

	if (!cs_init)
		return;

	premsg ();

	EnterCriticalSection (&cs);
	va_start (parms, format);
	bufp = buffer;
	for (;;) {
		count = _vsntprintf (bufp, bufsize - 1, format, parms);
		if (count < 0) {
			bufsize *= 10;
			if (bufp != buffer)
				xfree (bufp);
			bufp = xmalloc (TCHAR, bufsize);
			continue;
		}
		break;
	}
	bufp[bufsize - 1] = 0;
	if (!_tcsncmp (bufp, L"write ", 6))
		bufsize--;
	ts = writets ();
	if (bufp[0] == '*')
		count++;
	if (SHOW_CONSOLE || console_logging) {
		if (lfdetected && ts)
			writeconsole (ts);
		writeconsole (bufp);
	}
	if (debugfile) {
		if (lfdetected && ts)
			_ftprintf (debugfile, L"%s", ts);
		_ftprintf (debugfile, L"%s", bufp);
	}
	lfdetected = 0;
	if (_tcslen (bufp) > 0 && bufp[_tcslen (bufp) - 1] == '\n')
		lfdetected = 1;
	va_end (parms);
	if (bufp != buffer)
		xfree (bufp);
	if (always_flush_log)
		flush_log ();
	LeaveCriticalSection (&cs);
}
Example #4
0
INT_PTR PrintMsgBox(HWND hWnd, CTSTRING &tsCap, UINT_PTR uiFlags, PCTSTR szFormat, ...) {

  va_list l;
  va_start(l, szFormat);

  TCHAR pBuf[MAX_PRINTSIZE] = {0};
  _vsntprintf(pBuf, MAX_PRINTSIZE, szFormat, l);

  va_end(l);  

  return MsgBox(hWnd, pBuf, tsCap, uiFlags);
}
Example #5
0
void WINAPI XDebugLog(int nType, LPCTSTR pszFormat, ...)
{
	CSingleLock pLock( &m_pSection, TRUE );
	
	va_list pArgs;
	
	va_start( pArgs, pszFormat );
	_vsntprintf( szMessageBuffer, 16380, pszFormat, pArgs );
	
	OutputDebugString( szMessageBuffer );
	va_end( pArgs );
}
Example #6
0
inline void TraceOutMsgByDebugString(LPCTSTR strFormat, ...)
{
	va_list args;
	TCHAR szText[1024] = {0};
	va_start(args, strFormat); 
	_vsntprintf(szText, 
		1024, 
		strFormat, 
		args);
	va_end(args);
	OutputDebugString(szText);
}
Example #7
0
void dprintf(TCHAR *format, ...)
{
	va_list args;
	va_start(args,format);
	TCHAR buffer[1024*3]={0,};
	_vsntprintf(buffer,sizeof(buffer),format,args);
	va_end(args);
#if DEBUG_LEVEL > 0	
	printf(buffer);
	OutputDebugString(buffer);
#endif
}
Example #8
0
/// <summary>
///	Printf that specifies a different console output </summary>
///
/// <param name="ac">
/// Active console object </param>
/// <param name="format">
/// Format string </param>
///
/// <returns>
/// If string was written </returns>
BOOL Imprintf(IN const IM_CONSOLE* ac, IN const TCHAR* format, ...) {
	va_list vlist;
	TCHAR vargv[BUFSIZ] = {0};
	DWORD dwBytes;
	
	va_start(vlist, format);
	_vsntprintf(vargv, BUFSIZ, format, vlist);
	va_end(vlist);

	BOOL bResult = WriteFile(ac->hWrite, vargv, _tcslen(vargv), &dwBytes, NULL);
	return bResult && (dwBytes == _tcslen(vargv));
}
Example #9
0
File: JChar.c Project: takke/MZ3
s_int _w32_sntprintf(t_code *buf, size_t size, t_code *format, ...)
{
	s_int   ret;
	va_list va;

	va_start(va, format);
	ret = _vsntprintf(buf, size, format, va);
	va_end(va);
	
	if(size > 0) {buf[size - 1] = _T('\0');}
	return(ret);
}
Example #10
0
void TRACE(LPCTSTR szFormat, ...) {
   TCHAR szBuffer[1024] = TEXT("TUXDLL: ");

   va_list pArgs; 
   va_start(pArgs, szFormat);
   _vsntprintf(szBuffer + 9, countof(szBuffer) - 11, szFormat, pArgs);
   va_end(pArgs);

   _tcscat(szBuffer, TEXT("\r\n"));

   OutputDebugString(szBuffer);
}
KString& KString::Format(LPCTSTR pFormat, ...)
{
	va_list ArgList;
	va_start(ArgList, pFormat);

	TCHAR Buf[16384]; // !!!
	_vsntprintf(Buf, sizeof(Buf) - 1, pFormat, ArgList);

	va_end(ArgList);

	return *this = Buf; // +++ use internal known length allocator
}
Example #12
0
// Debug printf to a file
static int __cdecl AppDebugPrintf(int nStatus, TCHAR* pszFormat, ...)
{
	va_list vaFormat;

	va_start(vaFormat, pszFormat);

	if (DebugLog) {

		if (nStatus != nPrevConsoleStatus) {
			switch (nStatus) {
				case PRINT_ERROR:
					_ftprintf(DebugLog, _T("</font><font color=#FF3F3F>"));
					break;
				case PRINT_IMPORTANT:
					_ftprintf(DebugLog, _T("</font><font color=#000000>"));
					break;
				default:
					_ftprintf(DebugLog, _T("</font><font color=#009F00>"));
			}
		}
		_vftprintf(DebugLog, pszFormat, vaFormat);
		fflush(DebugLog);
	}

	if (!DebugLog || bEchoLog) {
		_vsntprintf(szConsoleBuffer, 1024, pszFormat, vaFormat);

		if (nStatus != nPrevConsoleStatus) {
			switch (nStatus) {
				case PRINT_UI:
					SetConsoleTextAttribute(DebugBuffer,                                                       FOREGROUND_INTENSITY);
					break;
				case PRINT_IMPORTANT:
					SetConsoleTextAttribute(DebugBuffer, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
					break;
				case PRINT_ERROR:
					SetConsoleTextAttribute(DebugBuffer, FOREGROUND_RED | FOREGROUND_GREEN |                   FOREGROUND_INTENSITY);
					break;
				default:
					SetConsoleTextAttribute(DebugBuffer,                  FOREGROUND_GREEN |                   FOREGROUND_INTENSITY);
			}
		}

		WriteConsole(DebugBuffer, szConsoleBuffer, _tcslen(szConsoleBuffer), NULL, NULL);
	}

	nPrevConsoleStatus = nStatus;

	va_end(vaFormat);

	return 0;
}
Example #13
0
void _TRACE(LPCTSTR szFormat, ...)
{
	TCHAR szBuffer[1024];
	
	va_list ap;
	va_start(ap, szFormat);
	
	_vsntprintf(szBuffer, sizeof(szBuffer), szFormat, ap);
	
	va_end(ap);
	
	OutputDebugString(szBuffer);
}
Example #14
0
void
LogErrno(const TCHAR *fmt, ...)
{
    const int error = errno;

    TCHAR buffer[1024];
    va_list ap;
    va_start(ap, fmt);
    _vsntprintf(buffer, ARRAY_SIZE(buffer), fmt, ap);
    va_end(ap);

    LogStartUp(_T("%s: %s"), buffer, strerror(error));
}
Example #15
0
void DebugPrintf(LONG lDebugLevel, LPCTSTR pszFormat, ... )
{
    TCHAR szOutput[MAX_PATH];

    if (lDebugLevel <= g_lDebugLevel)    
    {
        va_list argList;
        va_start(argList, pszFormat);
        _vsntprintf(szOutput, MAX_PATH, pszFormat, argList);
        va_end(argList);
        OutputDebugString(szOutput);
    }
}
Example #16
0
TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...)
{
	int count;
	va_list parms;
	va_start (parms, format);

	if (buffer == NULL)
		return 0;
	count = _vsntprintf (buffer, (*bufsize) - 1, format, parms);
	va_end (parms);
	*bufsize -= _tcslen (buffer);
	return buffer + _tcslen (buffer);
}
Example #17
0
/*
 * mswin_tw_printf() - printf version of mswin_tw_puts_lptstr.
 */
int
mswin_tw_printf(MSWIN_TEXTWINDOW *mswin_tw, LPCTSTR fmt, ...)
{
    TCHAR msg[1024];
    va_list  vlist;

    va_start(vlist, fmt);
    _vsntprintf(msg, ARRAYSIZE(msg), fmt, vlist);
    va_end(vlist);

    msg[ARRAYSIZE(msg) - 1] = 0;
    return mswin_tw_puts_lptstr(mswin_tw, msg);
}
Example #18
0
void odsf(PCTSTR format, ...) {

  TCHAR szBuf[MAX_AGMSGLEN] = {0};

  va_list l;
  va_start(l, format);

  _vsntprintf(szBuf, MAX_AGMSGLEN, format, l);
  OutputDebugString(szBuf);

  va_end(l);

}
Example #19
0
void Trace(TCHAR* lpszFormat, ...)
{
    va_list args;
    int nBuf;
    TCHAR szBuffer[512];

    va_start(args, lpszFormat);
    nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
    OutputDebugString(szBuffer);
    // was there an error? was the expanded string too long?
    //ASSERT(nBuf >= 0);
    va_end(args);
}
Example #20
0
void CCmdDlg::PrintLine(LPCTSTR fmt, ...)
{
	TCHAR str[2048];

	va_list varg;
	va_start(varg, fmt);
	_vsntprintf(str, _countof(str), fmt, varg);
	va_end(varg);

	lstrcat(str, CRLF);

	m_editlog.AddText(str);
}
Example #21
0
int IMsgRelayStream::WriteV (LPCTSTR lpszFmt, va_list ap)
{
	if (IsEmptyStr(lpszFmt))
		return (-3);

	TCHAR	szLine[POP3_MAX_LINE_LENGTH+2]=_T("");
	int	wLen=_vsntprintf(szLine, POP3_MAX_LINE_LENGTH, lpszFmt, ap);
	if (wLen < 0)
		return wLen;
	szLine[wLen] = _T('\0');

	return Write(szLine, wLen);
}
Example #22
0
void f_out (void *f, const TCHAR *format, ...)
{
	int count;
	TCHAR buffer[WRITE_LOG_BUF_SIZE];
	va_list parms;
	va_start (parms, format);

	if (f == NULL)
		return;
	count = _vsntprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
	openconsole ();
	writeconsole (buffer);
	va_end (parms);
}
Example #23
0
static void
debug_printf(LPCTSTR format, ...)
{
	va_list va;
	TCHAR buf[80*25];

	va_start(va, format);
	_vsntprintf(buf, NUMBER_OF(buf), format, va);
	buf[NUMBER_OF(buf) - 1] = T('\0');
	va_end(va);

	SendMessage(g_DebugWindow, EM_REPLACESEL, 0, (LPARAM)buf);
	SendMessage(g_DebugWindow, EM_REPLACESEL, 0, (LPARAM)T("\r\n"));
}
Example #24
0
int CDECL MessageBoxPrintf (TCHAR * szCaption, TCHAR * szFormat, ...)  
{      
  TCHAR  szBuffer [1024] ;  
  va_list pArgList ;  
  // The va_start macro (defined in STDARG.H) is usually equivalent to:  
  // pArgList = (char *) &szFormat + sizeof (szFormat) ;  
  va_start (pArgList, szFormat) ;  
  // The last argument to wvsprintf points to the arguments  
  _vsntprintf ( szBuffer, sizeof (szBuffer) / sizeof (TCHAR),  
    szFormat, pArgList) ;  
  // The va_end macro just zeroes out pArgList for no good reason  
  va_end (pArgList) ;  //Defoe.Tu  [email protected] Windows 程序设计 PDF 美化版 
  return MessageBox (NULL, szBuffer, szCaption, 0) ;  
}
Example #25
0
EXC_TYPE IMsgRelayStream::LogVMsg (const UINT32		ulLevel,
											  const EXC_TYPE	rexc,
											  LPCTSTR			lpszFmt,
											  va_list			ap)
{
	TCHAR	szLogMsg[POP3_MAX_LINE_LENGTH+2]=_T("");
	int	wLen=_vsntprintf(szLogMsg, POP3_MAX_LINE_LENGTH, lpszFmt, ap);
	if (wLen <= 0)
		wLen = POP3_MAX_LINE_LENGTH;
	szLogMsg[wLen] = _T('\0');

	HandleProtoState(szPOP3HelpCmd, ulLevel, szLogMsg);
	return rexc;
}
Example #26
0
int debug_printf(const _TCHAR * format, ...)
{
     int i;
     va_list args;
     _TCHAR buf[DEBUG_MESSAGE_BUF_SIZE];

     va_start(args, format);
     i = _vsntprintf(buf, DEBUG_MESSAGE_BUF_SIZE, format, args);
     va_end(args);

     sys_output_debug_string(buf);

     return i;
}
Example #27
0
//-----------------------------------------------------------------------------
// Name: DXUtil_Trace()
// Desc: Outputs to the debug stream a formatted string with a variable-
//       argument list.
//-----------------------------------------------------------------------------
VOID DXUtil_Trace( LPCTSTR strMsg, ... )
{
#if defined(DEBUG) | defined(_DEBUG)
    TCHAR strBuffer[512];
    
    va_list args;
    va_start(args, strMsg);
    _vsntprintf( strBuffer, 512, strMsg, args );
    va_end(args);

    OutputDebugString( strBuffer );
#else
    UNREFERENCED_PARAMETER(strMsg);
#endif
}
Example #28
0
void ODS(const TCHAR * fmt,...)
{
	va_list		argptr;
	TCHAR		text[1024];

	va_start (argptr, fmt);
#if defined(_MSC_VER)
	_vstprintf_s(text,1023, fmt, argptr);
#else
	_vsntprintf(text,1023, fmt, argptr);
#endif
	va_end (argptr);

	add_log(text);
}
void SetLogInfo( LOGTYPE type, LPCTSTR lpszFormat, ... )
{
	if( type == LOGTYPE_REDRAW )
	{
		InvalidateRect( g_hMainWnd, NULL, TRUE );
		return;
	}

	va_list args;
	va_start(args, lpszFormat);

	_vsntprintf( g_szBuffer[ type ], 255, lpszFormat, args );

	va_end(args);
}
Example #30
0
/********************************************************************
purpose:		记录事件日志,仿Printf版	
Parameters:		
Return Value: 	
*********************************************************************/
void PrintEventLog(LPCSTR msg, ...)
{
	va_list args;
	va_start(args, msg);

	int nBuf;
	TCHAR szBuffer[512];

	nBuf = _vsntprintf(szBuffer, sizeof(szBuffer), msg, args);

	// was there an error? was the expanded string too long?
	ASSERT(nBuf >= 0);
	va_end(args);
	WriteLog(szBuffer, NULL, LOG_LEVEL_EVENT);
}