void Logger::reportLog(DWORD type, DWORD msgId, LPCWSTR message, va_list ap) { if (m_hEventSrc && m_reportLogBuf) { ZeroMemory(m_reportLogBuf, REPORT_LOG_BUF_SIZE); int sprintfResult = wvsprintfW(m_reportLogBuf, message, ap); if (sprintfResult > -1) ReportEventW(m_hEventSrc, type & 0xFFFF, 0, msgId, NULL, 1, 0, const_cast<const WCHAR **>(&m_reportLogBuf), NULL); } }
int WINAPIV wsprintfWInternal( LPWSTR wszOut, LPCWSTR pszFmt, ...) { va_list va; va_start(va, pszFmt); int i = wvsprintfW(wszOut, pszFmt, va); va_end(va); return i; }
void wdbg_printf(const wchar_t* fmt, ...) { wchar_t buf[1024+1]; // wvsprintfW will truncate to this size va_list ap; va_start(ap, fmt); wvsprintfW(buf, fmt, ap); // (return value doesn't indicate whether truncation occurred) va_end(ap); OutputDebugStringW(buf); }
void DebugOutW(const wchar_t *format, ...) { wchar_t out[256]; va_list ap = { 0 }; va_start(ap, format); wvsprintfW(out, format, ap); va_end(ap); OutputDebugStringW(out); }
// 渲染文本 void GdiFont::Printf( float x, float y, const wchar_t *format, ... ) { va_list l; va_start( l, format ); wchar_t text[10240]; wvsprintfW( text, format, l ); Render( x, y, text ); }
int vwprintf(const wchar_t *format, va_list args) { wchar_t buf[1024]; int ret = wvsprintfW(buf, format, args); char ansibuf[1024]; WideCharToMultiByte(CP_ACP, 0, buf, -1, ansibuf, sizeof(ansibuf), 0, 0); fwrite(ansibuf, ret, 1, stdout); return ret; }
LIBUTILS_API int debug_printfW(const wchar_t * s,...) { wchar_t ss[MAX_LINE_LENGTH]; int len; va_list arg; va_start(arg,s); len=wvsprintfW(ss,s,arg); va_end(arg); OutputDebugStringW(ss); return len; }
void win_traceW(const WCHAR *pszFmt, ...){ WCHAR tchbuf[1024]; va_list argList = NULL; va_start(argList, pszFmt); wvsprintfW(tchbuf, pszFmt, argList); va_end(argList); if(IsDebuggerPresent()){ OutputDebugStringW(tchbuf); }else{ DWORD dwWrt; WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), tchbuf, lstrlenW(tchbuf), &dwWrt, NULL); } }
void _cdecl _DebugWriteW( const LPCWSTR szFormat, ... ) { if( szFormat != NULL ) { WCHAR szBuffer[4096]; va_list val; va_start( val,szFormat ); wvsprintfW( szBuffer, szFormat, val ); va_end( val ); szBuffer[(sizeof(szBuffer) / sizeof(WCHAR))-1] = L'\0'; char szAnsi[sizeof(szBuffer) / sizeof(WCHAR)]; WideCharToMultiByte( CP_ACP, 0, szBuffer, -1, szAnsi, sizeof(szAnsi), NULL, NULL ); _DebugAnsiFileWrite( szAnsi ); } else _DebugAnsiFileWrite( NULL ); }
/* 010510 Carl Corcoran */ void CCString::FormatvW(PCWSTR wszFormat, va_list arg) { WCHAR wsz[1024]; wvsprintfW(wsz, wszFormat, arg); this->cpy(wsz); }
/* ========================================================================= * Output a unicode string. Ideally this will go to the console * and hence required WriteConsoleW to output it, however if file i/o is * redirected, it needs to be WriteFile'd using OEM (not ANSI) format * ========================================================================= */ static int __cdecl NETSTAT_wprintf(const WCHAR *format, ...) { static WCHAR *output_bufW = NULL; static char *output_bufA = NULL; static BOOL toConsole = TRUE; static BOOL traceOutput = FALSE; #define MAX_WRITECONSOLE_SIZE 65535 __ms_va_list parms; DWORD nOut; int len; DWORD res = 0; /* * Allocate buffer to use when writing to console * Note: Not freed - memory will be allocated once and released when * xcopy ends */ if (!output_bufW) output_bufW = HeapAlloc(GetProcessHeap(), 0, MAX_WRITECONSOLE_SIZE); if (!output_bufW) { WINE_FIXME("Out of memory - could not allocate 2 x 64K buffers\n"); return 0; } __ms_va_start(parms, format); len = wvsprintfW(output_bufW, format, parms); __ms_va_end(parms); /* Try to write as unicode all the time we think its a console */ if (toConsole) { res = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), output_bufW, len, &nOut, NULL); } /* If writing to console has failed (ever) we assume its file i/o so convert to OEM codepage and output */ if (!res) { BOOL usedDefaultChar = FALSE; DWORD convertedChars; toConsole = FALSE; /* * Allocate buffer to use when writing to file. Not freed, as above */ if (!output_bufA) output_bufA = HeapAlloc(GetProcessHeap(), 0, MAX_WRITECONSOLE_SIZE); if (!output_bufA) { WINE_FIXME("Out of memory - could not allocate 2 x 64K buffers\n"); return 0; } /* Convert to OEM, then output */ convertedChars = WideCharToMultiByte(GetConsoleOutputCP(), 0, output_bufW, len, output_bufA, MAX_WRITECONSOLE_SIZE, "?", &usedDefaultChar); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), output_bufA, convertedChars, &nOut, FALSE); } /* Trace whether screen or console */ if (!traceOutput) { WINE_TRACE("Writing to console? (%d)\n", toConsole); traceOutput = TRUE; } return nOut; }