summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/debug-hosted.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/debug-hosted.c')
-rw-r--r--firmware/target/hosted/debug-hosted.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/firmware/target/hosted/debug-hosted.c b/firmware/target/hosted/debug-hosted.c
new file mode 100644
index 0000000000..35c487958b
--- /dev/null
+++ b/firmware/target/hosted/debug-hosted.c
@@ -0,0 +1,65 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2002 Daniel Stenberg
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdarg.h>
23#include <stdio.h>
24#include <string.h>
25
26#ifdef WIN32
27static unsigned old_cp;
28
29void debug_exit(void)
30{
31 /* Reset console output codepage */
32 SetConsoleOutputCP(old_cp);
33}
34
35void debug_init(void)
36{
37 old_cp = GetConsoleOutputCP();
38 /* Set console output codepage to UTF8. Only works
39 * correctly when the console uses a truetype font. */
40 SetConsoleOutputCP(65001);
41 atexit(debug_exit);
42}
43#else
44void debug_init(void)
45{
46 /* nothing to be done */
47}
48#endif
49
50void debugf(const char *fmt, ...)
51{
52 va_list ap;
53 va_start( ap, fmt );
54 vfprintf( stderr, fmt, ap );
55 va_end( ap );
56}
57
58void ldebugf(const char* file, int line, const char *fmt, ...)
59{
60 va_list ap;
61 va_start( ap, fmt );
62 fprintf( stderr, "%s:%d ", file, line );
63 vfprintf( stderr, fmt, ap );
64 va_end( ap );
65}