Experimenting with USER
[kugel-rb.git] / uisimulator / win32 / debug-win32.c
blob520473dd71dab02ed43c2c81e8dfda37ac881076
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Felix Arends
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include <windows.h>
21 #include <stdio.h>
23 char debugmembuf[100];
24 char debugbuf[200];
27 void debug( const char *message )
29 static int debugger = -1;
31 if (debugger == -1)
33 HINSTANCE hInst = LoadLibrary("kernel32.dll");
34 debugger = 0;
36 if (hInst != NULL)
38 FARPROC pIsDebuggerPresent = GetProcAddress(hInst, "IsDebuggerPresent");
39 if (pIsDebuggerPresent != NULL)
40 debugger = pIsDebuggerPresent();
44 if (debugger)
45 OutputDebugString (message);
46 else
47 printf("%s", message);
50 void debugf(char *fmt, ...)
52 va_list ap;
54 va_start( ap, fmt );
55 wvsprintf( debugmembuf, fmt, ap );
56 va_end( ap );
57 debug ( debugmembuf );
60 void Logf(char *fmt, ...)
62 va_list ap;
64 va_start( ap, fmt );
65 wvsprintf( debugmembuf, fmt, ap );
66 va_end( ap );
67 debug ( debugmembuf );