Tizen 2.0 Release
[platform/upstream/libremix.git] / src / libremix / remix_debug.c
1 /*
2  * libremix -- An audio mixing and sequencing library.
3  *
4  * Copyright (C) 2001 Commonwealth Scientific and Industrial Research
5  * Organisation (CSIRO), Australia.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 /*
24  * remix_debug.c -- Debuggin routines for Remix
25  *
26  * Conrad Parker <conrad@metadecks.org>, August 2001
27  *
28  * Description
29  * -----------
30  *
31  * This file contains printing routines for formatted debugging.
32  *
33  */
34
35 #include <string.h>
36 #include <stdarg.h>
37
38 #define __REMIX__
39 #include "remix.h"
40
41 static int indent = 0;
42
43 /*
44  * remix_debug_down (void)
45  */
46 void
47 remix_debug_down (void)
48 {
49   indent ++;
50 }
51
52 /*
53  * remix_debug_up (void)
54  */
55 void
56 remix_debug_up (void)
57 {
58   indent --;
59 }
60
61 /*
62  * remix_dprintf (fmt)
63  *
64  * Print a formatted debugging message to stdout at the current indent
65  */
66 void
67 remix_dprintf (const char * fmt, ...)
68 {
69 #ifdef DEBUG
70   va_list ap;
71   char buf[4096];
72   int i, n;
73
74   va_start (ap, fmt);
75
76   n = MIN (4096, indent);
77
78   for (i = 0; i < n; i++) {
79     buf[i] = ' ';
80   }
81
82   vsnprintf (buf+n, 4096-n, fmt, ap);
83
84   fputs (buf, stdout);
85   fflush (NULL);
86
87   va_end (ap);
88 #endif
89 }