The big NULL replacement party part 6.
...and ', NULL' had even more to replace.
This commit is contained in:
@@ -21,7 +21,7 @@ RString CrashHandler::GetLogsDirectory()
|
||||
}
|
||||
|
||||
// XXX Can we use LocalizedString here instead?
|
||||
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), NULL, CFSTR("Localizable") )
|
||||
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), nullptr, CFSTR("Localizable") )
|
||||
|
||||
void CrashHandler::InformUserOfCrash( const RString& sPath )
|
||||
{
|
||||
@@ -38,12 +38,12 @@ void CrashHandler::InformUserOfCrash( const RString& sPath )
|
||||
CFStringRef sFormat = LSTRING( bundle, PRODUCT_FAMILY " has crashed. "
|
||||
"Debugging information has been output to\n\n%s\n\n"
|
||||
"Please file a bug report at\n\n%s" );
|
||||
CFStringRef sBody = CFStringCreateWithFormat( kCFAllocatorDefault, NULL, sFormat,
|
||||
CFStringRef sBody = CFStringCreateWithFormat( kCFAllocatorDefault, nullptr, sFormat,
|
||||
sPath.c_str(), REPORT_BUG_URL );
|
||||
CFOptionFlags response = kCFUserNotificationCancelResponse;
|
||||
CFTimeInterval timeout = 0.0; // Should we ever time out?
|
||||
|
||||
CFUserNotificationDisplayAlert( timeout, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL,
|
||||
CFUserNotificationDisplayAlert( timeout, kCFUserNotificationStopAlertLevel, nullptr, nullptr, nullptr,
|
||||
sTitle, sBody, sDefault, sAlternate, sOther, &response );
|
||||
|
||||
switch( response )
|
||||
@@ -83,7 +83,7 @@ bool CrashHandler::IsDebuggerPresent()
|
||||
|
||||
// Call sysctl.
|
||||
size = sizeof( info );
|
||||
ret = sysctl( mib, sizeof(mib)/sizeof(*mib), &info, &size, NULL, 0 );
|
||||
ret = sysctl( mib, sizeof(mib)/sizeof(*mib), &info, &size, nullptr, 0 );
|
||||
|
||||
// We're being debugged if the P_TRACED flag is set.
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ protected:
|
||||
// Perform a synchronous set report on the HID interface.
|
||||
inline IOReturn SetReport( IOHIDReportType type, UInt32 reportID, void *buffer, UInt32 size, UInt32 timeoutMS )
|
||||
{
|
||||
return CALL( m_Interface, setReport, type, reportID, buffer, size, timeoutMS, NULL, NULL, NULL );
|
||||
return CALL( m_Interface, setReport, type, reportID, buffer, size, timeoutMS, nullptr, nullptr, nullptr );
|
||||
}
|
||||
public:
|
||||
HIDDevice();
|
||||
|
||||
@@ -10,7 +10,7 @@ bool Vector::CheckForVector()
|
||||
int32_t result = 0;
|
||||
size_t size = 4;
|
||||
|
||||
return !sysctlbyname( "hw.vectorunit", &result, &size, NULL, 0 ) && result;
|
||||
return !sysctlbyname( "hw.vectorunit", &result, &size, nullptr, 0 ) && result;
|
||||
}
|
||||
|
||||
/* for( unsigned pos = 0; pos < size; ++pos )
|
||||
|
||||
@@ -42,7 +42,7 @@ void BacktraceNames::Demangle()
|
||||
return;
|
||||
|
||||
int status = 0;
|
||||
char *name = abi::__cxa_demangle( Symbol, NULL, NULL, &status );
|
||||
char *name = abi::__cxa_demangle( Symbol, nullptr, nullptr, &status );
|
||||
if( name )
|
||||
{
|
||||
Symbol = name;
|
||||
@@ -375,7 +375,7 @@ void BacktraceNames::FromAddr( const void *p )
|
||||
char *p;
|
||||
asprintf(&p, "%d", ppid);
|
||||
|
||||
execl("/usr/bin/atos", "/usr/bin/atos", "-p", p, addy, NULL);
|
||||
execl("/usr/bin/atos", "/usr/bin/atos", "-p", p, addy, nullptr);
|
||||
|
||||
fprintf(stderr, "execl(atos) failed: %s\n", strerror(errno));
|
||||
free(addy);
|
||||
|
||||
@@ -80,13 +80,13 @@ static void NORETURN spawn_child_process( int from_parent )
|
||||
strncpy( magic, CHILD_MAGIC_PARAMETER, sizeof(magic) );
|
||||
|
||||
/* Use execve; it's the lowest-level of the exec calls. The others may allocate. */
|
||||
char *argv[3] = { path, magic, NULL };
|
||||
char *argv[3] = { path, magic, nullptr };
|
||||
char *envp[1] = { NULL };
|
||||
execve( path, argv, envp );
|
||||
|
||||
/* If we got here, the exec failed. We can't call strerror. */
|
||||
// safe_print(fileno(stderr), "Crash handler execl(", path, ") failed: ", strerror(errno), "\n", NULL);
|
||||
safe_print( fileno(stderr), "Crash handler execl(", path, ") failed: ", itoa( errno ), "\n", NULL );
|
||||
// safe_print(fileno(stderr), "Crash handler execl(", path, ") failed: ", strerror(errno), "\n", nullptr);
|
||||
safe_print( fileno(stderr), "Crash handler execl(", path, ") failed: ", itoa( errno ), "\n", nullptr );
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@@ -108,13 +108,13 @@ static bool parent_write( int to_child, const void *p, size_t size )
|
||||
int ret = retried_write( to_child, p, size );
|
||||
if( ret == -1 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", strerror(errno), ")\n", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", strerror(errno), ")\n", nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( size_t(ret) != size )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
{
|
||||
if( g_pCrashHandlerArgv0 == nullptr )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
@@ -213,9 +213,9 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
struct sigaction sa;
|
||||
memset( &sa, 0, sizeof(sa) );
|
||||
sa.sa_handler = SIG_IGN;
|
||||
if( sigaction( SIGPIPE, &sa, NULL ) != 0 )
|
||||
if( sigaction( SIGPIPE, &sa, nullptr ) != 0 )
|
||||
{
|
||||
safe_print( fileno(stderr), "sigaction() failed: %s", strerror(errno), NULL );
|
||||
safe_print( fileno(stderr), "sigaction() failed: %s", strerror(errno), nullptr );
|
||||
/* non-fatal */
|
||||
}
|
||||
|
||||
@@ -229,22 +229,22 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
switch( crash->type )
|
||||
{
|
||||
case CrashData::SIGNAL:
|
||||
safe_print( fileno(stderr), "Fatal signal (", SignalName(crash->signal), ")", NULL );
|
||||
safe_print( fileno(stderr), "Fatal signal (", SignalName(crash->signal), ")", nullptr );
|
||||
break;
|
||||
|
||||
case CrashData::FORCE_CRASH:
|
||||
safe_print( fileno(stderr), "Crash handler failed: \"", crash->reason, "\"", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler failed: \"", crash->reason, "\"", nullptr );
|
||||
break;
|
||||
|
||||
default:
|
||||
safe_print( fileno(stderr), "Unexpected RunCrashHandler call (", itoa(crash->type), ")", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected RunCrashHandler call (", itoa(crash->type), ")", nullptr );
|
||||
break;
|
||||
}
|
||||
|
||||
if( active == 1 )
|
||||
safe_print( fileno(stderr), " while still in the crash handler\n", NULL);
|
||||
safe_print( fileno(stderr), " while still in the crash handler\n", nullptr);
|
||||
else if( active == 2 )
|
||||
safe_print( fileno(stderr), " while in the crash handler child\n", NULL);
|
||||
safe_print( fileno(stderr), " while in the crash handler child\n", nullptr);
|
||||
|
||||
_exit( 1 );
|
||||
}
|
||||
@@ -259,14 +259,14 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
int fds[2];
|
||||
if( pipe(fds) != 0 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler pipe() failed: ", strerror(errno), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler pipe() failed: ", strerror(errno), "\n", nullptr );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
pid_t childpid = fork();
|
||||
if( childpid == -1 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler fork() failed: ", strerror(errno), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler fork() failed: ", strerror(errno), "\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
RageThread::ResumeAllThreads();
|
||||
|
||||
if( WIFSIGNALED(status) )
|
||||
safe_print( fileno(stderr), "Crash handler child exited with signal ", itoa(WTERMSIG(status)), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler child exited with signal ", itoa(WTERMSIG(status)), "\n", nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ void CrashHandler::ForceCrash( const char *reason )
|
||||
strncpy( crash.reason, reason, sizeof(crash.reason) );
|
||||
crash.reason[ sizeof(crash.reason)-1 ] = 0;
|
||||
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, NULL );
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, nullptr );
|
||||
|
||||
RunCrashHandler( &crash );
|
||||
}
|
||||
@@ -344,7 +344,7 @@ void CrashHandler::ForceDeadlock( RString reason, uint64_t iID )
|
||||
|
||||
crash.type = CrashData::FORCE_CRASH;
|
||||
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, NULL );
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, nullptr );
|
||||
|
||||
if( iID == GetInvalidThreadId() )
|
||||
{
|
||||
@@ -376,7 +376,7 @@ void CrashHandler::CrashSignalHandler( int signal, siginfo_t *si, const ucontext
|
||||
static volatile bool bInCrashSignalHandler = false;
|
||||
if( bInCrashSignalHandler )
|
||||
{
|
||||
safe_print( 2, "Fatal: crash from within the crash signal handler\n", NULL );
|
||||
safe_print( 2, "Fatal: crash from within the crash signal handler\n", nullptr );
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ static void child_process()
|
||||
|
||||
FD_ZERO( &rs );
|
||||
FD_SET( 3, &rs );
|
||||
int ret = select( 4, &rs, NULL, NULL, &timeout );
|
||||
int ret = select( 4, &rs, nullptr, nullptr, &timeout );
|
||||
|
||||
if( ret == 0 )
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ static int waittid( int ThreadID, int *status, int options )
|
||||
static int PtraceAttach( int ThreadID )
|
||||
{
|
||||
int ret;
|
||||
ret = ptrace( PTRACE_ATTACH, ThreadID, NULL, NULL );
|
||||
ret = ptrace( PTRACE_ATTACH, ThreadID, nullptr, nullptr );
|
||||
if( ret == -1 )
|
||||
{
|
||||
printf("ptrace failed: %s\n", strerror(errno) );
|
||||
@@ -114,7 +114,7 @@ static int PtraceAttach( int ThreadID )
|
||||
|
||||
static int PtraceDetach( int ThreadID )
|
||||
{
|
||||
return ptrace( PTRACE_DETACH, ThreadID, NULL, NULL );
|
||||
return ptrace( PTRACE_DETACH, ThreadID, nullptr, nullptr );
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx )
|
||||
|
||||
#if defined(CPU_X86_64) || defined(CPU_X86)
|
||||
user_regs_struct regs;
|
||||
if( ptrace( PTRACE_GETREGS, pid_t(ThreadID), NULL, ®s ) == -1 )
|
||||
if( ptrace( PTRACE_GETREGS, pid_t(ThreadID), nullptr, ®s ) == -1 )
|
||||
return false;
|
||||
|
||||
ctx->pid = pid_t(ThreadID);
|
||||
|
||||
@@ -57,7 +57,7 @@ SaveSignals::SaveSignals()
|
||||
for( int i = 0; signals[i] != -1; ++i )
|
||||
{
|
||||
struct sigaction sa;
|
||||
sigaction( signals[i], NULL, &sa );
|
||||
sigaction( signals[i], nullptr, &sa );
|
||||
old_handlers.push_back( sa );
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ SaveSignals::~SaveSignals()
|
||||
{
|
||||
/* Restore the old signal handlers. */
|
||||
for( unsigned i = 0; i < old_handlers.size(); ++i )
|
||||
sigaction( signals[i], &old_handlers[i], NULL );
|
||||
sigaction( signals[i], &old_handlers[i], nullptr );
|
||||
}
|
||||
|
||||
static void SigHandler( int signal, siginfo_t *si, void *ucp )
|
||||
@@ -86,7 +86,7 @@ static void SigHandler( int signal, siginfo_t *si, void *ucp )
|
||||
struct sigaction old;
|
||||
sigaction( signal, &sa, &old );
|
||||
raise( signal );
|
||||
sigaction( signal, &old, NULL );
|
||||
sigaction( signal, &old, nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ void SignalHandler::OnClose( handler h )
|
||||
ss.ss_sp = (char*)p; /* cast for Darwin */
|
||||
ss.ss_size = AltStackSize;
|
||||
ss.ss_flags = 0;
|
||||
if( sigaltstack( &ss, NULL ) == -1 )
|
||||
if( sigaltstack( &ss, nullptr ) == -1 )
|
||||
{
|
||||
LOG->Info( "sigaltstack failed: %s", strerror(errno) );
|
||||
p = nullptr; /* no SA_ONSTACK */
|
||||
@@ -185,11 +185,11 @@ void SignalHandler::OnClose( handler h )
|
||||
/* Set up our signal handlers. */
|
||||
sa.sa_sigaction = SigHandler;
|
||||
for( int i = 0; signals[i] != -1; ++i )
|
||||
sigaction( signals[i], &sa, NULL );
|
||||
sigaction( signals[i], &sa, nullptr );
|
||||
|
||||
/* Block SIGPIPE, so we get EPIPE. */
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigaction( SIGPIPE, &sa, NULL );
|
||||
sigaction( SIGPIPE, &sa, nullptr );
|
||||
}
|
||||
handlers.push_back(h);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void WriteToChild( HANDLE hPipe, const void *pData, size_t iSize )
|
||||
while( iSize )
|
||||
{
|
||||
DWORD iActual;
|
||||
if( !WriteFile(hPipe, pData, iSize, &iActual, NULL) )
|
||||
if( !WriteFile(hPipe, pData, iSize, &iActual, nullptr) )
|
||||
return;
|
||||
iSize -= iActual;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ void RunChild()
|
||||
* since GetModuleFileNameEx might not be available. Run the requests here. */
|
||||
HMODULE hMod;
|
||||
DWORD iActual;
|
||||
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, NULL) )
|
||||
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, nullptr) )
|
||||
break;
|
||||
|
||||
TCHAR szName[MAX_PATH];
|
||||
@@ -331,7 +331,7 @@ static long MainExceptionHandler( EXCEPTION_POINTERS *pExc )
|
||||
/* Now things get more risky. If we're fullscreen, the window will obscure
|
||||
* the crash dialog. Try to hide the window. Things might blow up here; do
|
||||
* this after DoSave, so we always write a crash dump. */
|
||||
if( GetWindowThreadProcessId( g_hForegroundWnd, NULL ) == GetCurrentThreadId() )
|
||||
if( GetWindowThreadProcessId( g_hForegroundWnd, nullptr ) == GetCurrentThreadId() )
|
||||
{
|
||||
/* The thread that crashed was the thread that created the main window.
|
||||
* Hide the window. This will also restore the video mode, if necessary. */
|
||||
@@ -445,7 +445,7 @@ static bool PointsToValidCall( unsigned long ptr )
|
||||
|
||||
memset( buf, 0, sizeof(buf) );
|
||||
|
||||
while(len > 0 && !ReadProcessMemory(GetCurrentProcess(), (void *)(ptr-len), buf+7-len, len, NULL))
|
||||
while(len > 0 && !ReadProcessMemory(GetCurrentProcess(), (void *)(ptr-len), buf+7-len, len, nullptr))
|
||||
--len;
|
||||
|
||||
return IsValidCall(buf+7, len);
|
||||
@@ -521,7 +521,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
|
||||
break;
|
||||
|
||||
lpAddr += 4;
|
||||
} while( ReadProcessMemory(hProcess, lpAddr-4, &data, 4, NULL));
|
||||
} while( ReadProcessMemory(hProcess, lpAddr-4, &data, 4, nullptr));
|
||||
|
||||
*buf = nullptr;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace VDDebugInfo
|
||||
GetVDIPath( pctx->sFilename, ARRAYLEN(pctx->sFilename) );
|
||||
pctx->sError = RString();
|
||||
|
||||
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
|
||||
if( h == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
pctx->sError = werr_ssprintf( GetLastError(), "CreateFile failed" );
|
||||
@@ -131,7 +131,7 @@ namespace VDDebugInfo
|
||||
}
|
||||
|
||||
do {
|
||||
DWORD dwFileSize = GetFileSize( h, NULL );
|
||||
DWORD dwFileSize = GetFileSize( h, nullptr );
|
||||
if( dwFileSize == INVALID_FILE_SIZE )
|
||||
break;
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace VDDebugInfo
|
||||
break;
|
||||
|
||||
DWORD dwActual;
|
||||
int iRet = ReadFile(h, pBuf, dwFileSize, &dwActual, NULL);
|
||||
int iRet = ReadFile(h, pBuf, dwFileSize, &dwActual, nullptr);
|
||||
CloseHandle(h);
|
||||
pctx->sRawBlock.ReleaseBuffer( dwActual );
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace SymbolLookup
|
||||
{
|
||||
SymSetOptions( SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS );
|
||||
|
||||
if( !SymInitialize(g_hParent, NULL, TRUE) )
|
||||
if( !SymInitialize(g_hParent, nullptr, TRUE) )
|
||||
return false;
|
||||
|
||||
bInitted = true;
|
||||
@@ -745,7 +745,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
|
||||
m_pPost->Start( CRASH_REPORT_HOST, CRASH_REPORT_PORT, CRASH_REPORT_PATH );
|
||||
|
||||
SetTimer( hDlg, 0, 100, NULL );
|
||||
SetTimer( hDlg, 0, 100, nullptr );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -174,7 +174,7 @@ NetworkStream_Win32::NetworkStream_Win32():
|
||||
#if defined(WINDOWS)
|
||||
m_hResolve = nullptr;
|
||||
m_hResolveHwnd = nullptr;
|
||||
m_hCompletionEvent = CreateEvent( NULL, true, false, NULL );
|
||||
m_hCompletionEvent = CreateEvent( NULL, true, false, nullptr );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
#include "global.h"
|
||||
#include "ErrorStrings.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
RString werr_ssprintf( int err, const char *fmt, ... )
|
||||
{
|
||||
char buf[1024] = "";
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0, err, 0, buf, sizeof(buf), NULL);
|
||||
|
||||
// Why is FormatMessage returning text ending with \r\n? (who? -aj)
|
||||
// Perhaps it's because you're on Windows, where newlines are \r\n. -aj
|
||||
RString text = buf;
|
||||
text.Replace( "\n", "" );
|
||||
text.Replace( "\r", " " ); // foo\r\nbar -> foo bar
|
||||
TrimRight( text ); // "foo\r\n" -> "foo"
|
||||
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
RString s = vssprintf( fmt, va );
|
||||
va_end(va);
|
||||
|
||||
return s += ssprintf( " (%s)", text.c_str() );
|
||||
}
|
||||
|
||||
RString ConvertWstringToCodepage( wstring s, int iCodePage )
|
||||
{
|
||||
if( s.empty() )
|
||||
return RString();
|
||||
|
||||
int iBytes = WideCharToMultiByte( iCodePage, 0, s.data(), s.size(),
|
||||
NULL, 0, NULL, FALSE );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "WideCharToMultiByte" ).c_str() );
|
||||
|
||||
RString ret;
|
||||
WideCharToMultiByte( CP_ACP, 0, s.data(), s.size(),
|
||||
ret.GetBuffer( iBytes ), iBytes, NULL, FALSE );
|
||||
ret.ReleaseBuffer( iBytes );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
RString ConvertUTF8ToACP( const RString &s )
|
||||
{
|
||||
return ConvertWstringToCodepage( RStringToWstring(s), CP_ACP );
|
||||
}
|
||||
|
||||
wstring ConvertCodepageToWString( RString s, int iCodePage )
|
||||
{
|
||||
if( s.empty() )
|
||||
return wstring();
|
||||
|
||||
int iBytes = MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), NULL, 0 );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "MultiByteToWideChar" ).c_str() );
|
||||
|
||||
wchar_t *pTemp = new wchar_t[iBytes];
|
||||
MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), pTemp, iBytes );
|
||||
wstring sRet( pTemp, iBytes );
|
||||
delete [] pTemp;
|
||||
|
||||
return sRet;
|
||||
}
|
||||
|
||||
RString ConvertACPToUTF8( const RString &s )
|
||||
{
|
||||
return WStringToRString( ConvertCodepageToWString(s, CP_ACP) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2005 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "ErrorStrings.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
RString werr_ssprintf( int err, const char *fmt, ... )
|
||||
{
|
||||
char buf[1024] = "";
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0, err, 0, buf, sizeof(buf), nullptr);
|
||||
|
||||
// Why is FormatMessage returning text ending with \r\n? (who? -aj)
|
||||
// Perhaps it's because you're on Windows, where newlines are \r\n. -aj
|
||||
RString text = buf;
|
||||
text.Replace( "\n", "" );
|
||||
text.Replace( "\r", " " ); // foo\r\nbar -> foo bar
|
||||
TrimRight( text ); // "foo\r\n" -> "foo"
|
||||
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
RString s = vssprintf( fmt, va );
|
||||
va_end(va);
|
||||
|
||||
return s += ssprintf( " (%s)", text.c_str() );
|
||||
}
|
||||
|
||||
RString ConvertWstringToCodepage( wstring s, int iCodePage )
|
||||
{
|
||||
if( s.empty() )
|
||||
return RString();
|
||||
|
||||
int iBytes = WideCharToMultiByte( iCodePage, 0, s.data(), s.size(),
|
||||
NULL, 0, nullptr, FALSE );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "WideCharToMultiByte" ).c_str() );
|
||||
|
||||
RString ret;
|
||||
WideCharToMultiByte( CP_ACP, 0, s.data(), s.size(),
|
||||
ret.GetBuffer( iBytes ), iBytes, nullptr, FALSE );
|
||||
ret.ReleaseBuffer( iBytes );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
RString ConvertUTF8ToACP( const RString &s )
|
||||
{
|
||||
return ConvertWstringToCodepage( RStringToWstring(s), CP_ACP );
|
||||
}
|
||||
|
||||
wstring ConvertCodepageToWString( RString s, int iCodePage )
|
||||
{
|
||||
if( s.empty() )
|
||||
return wstring();
|
||||
|
||||
int iBytes = MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), nullptr, 0 );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "MultiByteToWideChar" ).c_str() );
|
||||
|
||||
wchar_t *pTemp = new wchar_t[iBytes];
|
||||
MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), pTemp, iBytes );
|
||||
wstring sRet( pTemp, iBytes );
|
||||
delete [] pTemp;
|
||||
|
||||
return sRet;
|
||||
}
|
||||
|
||||
RString ConvertACPToUTF8( const RString &s )
|
||||
{
|
||||
return WStringToRString( ConvertCodepageToWString(s, CP_ACP) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2005 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ static LONG GetRegKey( HKEY key, RString subkey, LPTSTR retdata )
|
||||
bool GotoURL( RString sUrl )
|
||||
{
|
||||
// First try ShellExecute()
|
||||
int iRet = (int) ShellExecute( NULL, "open", sUrl, NULL, NULL, SW_SHOWDEFAULT );
|
||||
int iRet = (int) ShellExecute( NULL, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT );
|
||||
|
||||
// If it failed, get the .htm regkey and lookup the program
|
||||
if( iRet > 32 )
|
||||
|
||||
@@ -283,7 +283,7 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
|
||||
AppInstance inst;
|
||||
HWND hWnd = CreateWindow( g_sClassName, "app", iWindowStyle,
|
||||
0, 0, 0, 0, NULL, NULL, inst, NULL );
|
||||
0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
|
||||
if( hWnd == nullptr )
|
||||
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "CreateWindow" ).c_str() );
|
||||
|
||||
@@ -363,9 +363,9 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
* If we don't do this, then starting up in a D3D fullscreen window may
|
||||
* cause all other windows on the system to be resized. */
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
@@ -399,10 +399,10 @@ void GraphicsWindow::DestroyGraphicsWindow()
|
||||
CHECKPOINT;
|
||||
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
CHECKPOINT;
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
CHECKPOINT;
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
@@ -487,9 +487,9 @@ const VideoModeParams &GraphicsWindow::GetParams()
|
||||
void GraphicsWindow::Update()
|
||||
{
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ MessageWindow::MessageWindow( const RString &sClassName )
|
||||
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "RegisterClass" ).c_str() );
|
||||
|
||||
// XXX: on 2k/XP, use HWND_MESSAGE as parent
|
||||
m_hWnd = CreateWindow( sClassName, sClassName, WS_DISABLED, 0, 0, 0, 0, NULL, NULL, inst, NULL );
|
||||
m_hWnd = CreateWindow( sClassName, sClassName, WS_DISABLED, 0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
|
||||
ASSERT( m_hWnd != nullptr );
|
||||
|
||||
SetProp( m_hWnd, "MessageWindow", this );
|
||||
|
||||
@@ -66,7 +66,7 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, RSt
|
||||
char sBuffer[MAX_PATH];
|
||||
DWORD iSize = sizeof(sBuffer);
|
||||
DWORD iType;
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE)sBuffer, &iSize );
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE)sBuffer, &iSize );
|
||||
RegCloseKey( hKey );
|
||||
if( iRet != ERROR_SUCCESS )
|
||||
return false;
|
||||
@@ -92,7 +92,7 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, int
|
||||
DWORD iValue;
|
||||
DWORD iSize = sizeof(iValue);
|
||||
DWORD iType;
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE) &iValue, &iSize );
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE) &iValue, &iSize );
|
||||
RegCloseKey( hKey );
|
||||
if( iRet != ERROR_SUCCESS )
|
||||
return false;
|
||||
@@ -126,7 +126,7 @@ bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, c
|
||||
FILETIME ft;
|
||||
char szBuffer[MAX_PATH];
|
||||
DWORD iSize = sizeof(szBuffer);
|
||||
LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, NULL, NULL, NULL, &ft);
|
||||
LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, nullptr, nullptr, nullptr, &ft);
|
||||
if( iRet == ERROR_NO_MORE_ITEMS )
|
||||
break;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ static RString GetUSBDevicePath( int iNum )
|
||||
GUID guid;
|
||||
HidD_GetHidGuid( &guid );
|
||||
|
||||
HDEVINFO DeviceInfo = SetupDiGetClassDevs( &guid, NULL, NULL, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
|
||||
HDEVINFO DeviceInfo = SetupDiGetClassDevs( &guid, nullptr, nullptr, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
|
||||
|
||||
SP_DEVICE_INTERFACE_DATA DeviceInterface;
|
||||
DeviceInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
@@ -33,14 +33,14 @@ static RString GetUSBDevicePath( int iNum )
|
||||
}
|
||||
|
||||
unsigned long iSize;
|
||||
SetupDiGetDeviceInterfaceDetail( DeviceInfo, &DeviceInterface, NULL, 0, &iSize, 0 );
|
||||
SetupDiGetDeviceInterfaceDetail( DeviceInfo, &DeviceInterface, nullptr, 0, &iSize, 0 );
|
||||
|
||||
PSP_INTERFACE_DEVICE_DETAIL_DATA DeviceDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc( iSize );
|
||||
DeviceDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
|
||||
|
||||
RString sRet;
|
||||
if( SetupDiGetDeviceInterfaceDetail(DeviceInfo, &DeviceInterface,
|
||||
DeviceDetail, iSize, &iSize, NULL) )
|
||||
DeviceDetail, iSize, &iSize, nullptr) )
|
||||
sRet = DeviceDetail->DevicePath;
|
||||
free( DeviceDetail );
|
||||
|
||||
@@ -56,7 +56,7 @@ bool USBDevice::Open( int iVID, int iPID, int iBlockSize, int iNum, void (*pfnIn
|
||||
while( (path = GetUSBDevicePath(iIndex++)) != "" )
|
||||
{
|
||||
HANDLE h = CreateFile( path, GENERIC_READ,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr );
|
||||
|
||||
if( h == INVALID_HANDLE_VALUE )
|
||||
continue;
|
||||
@@ -138,7 +138,7 @@ bool WindowsFileIO::Open( RString path, int iBlockSize )
|
||||
CloseHandle( m_Handle );
|
||||
|
||||
m_Handle = CreateFile( path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL );
|
||||
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr );
|
||||
|
||||
if( m_Handle == INVALID_HANDLE_VALUE )
|
||||
return false;
|
||||
|
||||
@@ -12,7 +12,7 @@ void WindowsDialogBox::Run( int iDialog )
|
||||
GetModuleFileName( NULL, szFullAppPath, MAX_PATH );
|
||||
HINSTANCE hHandle = LoadLibrary( szFullAppPath );
|
||||
|
||||
DialogBoxParam( hHandle, MAKEINTRESOURCE(iDialog), NULL, DlgProc, (LPARAM) this );
|
||||
DialogBoxParam( hHandle, MAKEINTRESOURCE(iDialog), nullptr, DlgProc, (LPARAM) this );
|
||||
}
|
||||
|
||||
BOOL APIENTRY WindowsDialogBox::DlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
|
||||
Reference in New Issue
Block a user