Moved all debug functions to from main.cpp to util.cpp

svn-id: r21545
This commit is contained in:
Max Horn 2006-04-02 00:56:53 +00:00
parent d0b8efd575
commit 8a8bdcd1f8
3 changed files with 65 additions and 66 deletions

View File

@ -517,65 +517,3 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
return 0;
}
static void debugHelper(char *buf, bool caret = true) {
#ifndef _WIN32_WCE
if (caret)
printf("%s\n", buf);
else
printf("%s", buf);
#endif
#if defined( USE_WINDBG )
if (caret)
strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
OutputDebugString(buf_unicode);
#else
OutputDebugString(buf);
#endif
#endif
fflush(stdout);
}
void CDECL debug(int level, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
if (level > gDebugLevel)
return;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
debugHelper(buf);
}
void CDECL debugN(int level, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
if (level > gDebugLevel)
return;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
debugHelper(buf, false);
}
void CDECL debug(const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
debugHelper(buf);
}

View File

@ -341,6 +341,68 @@ const Array<EngineDebugLevel> &listSpecialDebugLevels() {
} // End of namespace Common
static void debugHelper(char *buf, bool caret = true) {
#ifndef _WIN32_WCE
if (caret)
printf("%s\n", buf);
else
printf("%s", buf);
#endif
#if defined( USE_WINDBG )
if (caret)
strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
OutputDebugString(buf_unicode);
#else
OutputDebugString(buf);
#endif
#endif
fflush(stdout);
}
void CDECL debug(int level, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
if (level > gDebugLevel)
return;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
debugHelper(buf);
}
void CDECL debugN(int level, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
if (level > gDebugLevel)
return;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
debugHelper(buf, false);
}
void CDECL debug(const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
debugHelper(buf);
}
void CDECL debugC(int level, uint32 engine_level, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
@ -352,6 +414,5 @@ void CDECL debugC(int level, uint32 engine_level, const char *s, ...) {
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
// pass it to debug for now
debug(level, buf);
debugHelper(buf);
}

View File

@ -272,10 +272,10 @@ void CDECL warning(const char *s, ...) GCC_PRINTF(1, 2);
void CDECL debug(int level, const char *s, ...) GCC_PRINTF(2, 3);
void CDECL debug(const char *s, ...) GCC_PRINTF(1, 2);
void CDECL debugN(int level, const char *s, ...) GCC_PRINTF(2, 3);
void checkHeap();
void CDECL debugC(int level, uint32 engine_level, const char *s, ...) GCC_PRINTF(3, 4);
void checkHeap();
extern int gDebugLevel;