int _write(int fd, const void *data, unsigned int count) { if (fd == STDOUT_FILENO) { count = DebugWrite(data, count); } else { DebugWrite("Error: _write\r\n", 15); count = -1; } return(count); }
// Use string table refs to generate and throw an error message with title IDS_ERR_TITLE (see string table in resources) // Also if compiled with DEBUG, will log the message with DebugWrite // uID the string table ref to display // dwError if nonzero, will display a Windows error message using FormatMessage (for use when an API function fails) // fUserChoose if true, display buttons Retry and Cancel. if false, display single button OK. // for fUserChoose==true; ErrorMessage returns true if user selects Retry, and false if user selects Cancel. // for fUserChoose==false; ErrorMessage always returns false. bool ErrorMessage( UINT uID, DWORD dwError, bool fUserChoose ) { TCHAR pszFirstLine[DEFAULT_BUFFER]; bool fReturn = false; int iBytes; TCHAR szError[512]; TCHAR tszErrorTitle[DEFAULT_BUFFER]; LoadString( g_hResourceDLL, uID, pszFirstLine, DEFAULT_BUFFER ); LoadString( g_hResourceDLL, IDS_ERR_TITLE, tszErrorTitle, DEFAULT_BUFFER ); if( dwError ) { iBytes = wsprintf( szError, _T("%s\n\n Error description: "), pszFirstLine ); FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError , 0, &szError[iBytes], sizeof(szError) - iBytes, NULL ); } else lstrcpyn( szError, pszFirstLine, 512 ); DebugWrite(_T("ErrorMessage! ID:%d "), uID); DebugFlush(); if( fUserChoose ) fReturn = MessageBox( g_strEmuInfo.hMainWindow, szError, tszErrorTitle, MB_RETRYCANCEL | MB_ICONERROR ) == IDRETRY; else MessageBox( g_strEmuInfo.hMainWindow, szError, tszErrorTitle, MB_OK | MB_ICONERROR ); DebugWriteA(fReturn ? "(user: retry)\n" : "(user: acknowledge)\n"); return fReturn; }
void WriteLine(const char *fmt, ...) { #ifdef OM_TRACE_ENABLE va_list ap; va_start(ap, fmt); const int SIZ = 10*1024; char buf[SIZ]; #ifdef WIN32 vsnprintf_s(buf, SIZ, SIZ, fmt, ap); #else vsprintf(buf, fmt, ap); #endif DebugWrite(buf); DebugWrite("\n"); #endif }
void DebugLog( TCHAR* lpMessage, ...) { #ifdef _DEBUG static TCHAR buffer[1024]; va_list ap; va_start(ap, lpMessage); _vstprintf(buffer, lpMessage, ap); va_end(ap); DebugWrite( buffer); #endif }
int _fstat (int fd, struct stat * st) { if (fd == STDOUT_FILENO) { memset(st, 0, sizeof (* st)); st->st_mode = S_IFCHR; st->st_blksize = 1024; return 0; } else { DebugWrite("Error: _fstat\r\n", 15); return(-1); } }
void Write(std::string const &T) { DebugWrite(T.c_str()); }
void Write(IToString const &T) { DebugWrite(T.ToString().c_str()); }