Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/openal-0.0.8/src/al_debug.c @ 17

Last change on this file since 17 was 17, checked in by landauf, 16 years ago

added openal

File size: 3.1 KB
Line 
1/* -*- mode: C; tab-width:8; c-basic-offset:8 -*-
2 * vi:set ts=8:
3 *
4 * al_debug.c
5 *
6 * openal custom debug messages.
7 */
8#define _GNU_SOURCE
9
10#include "al_siteconfig.h"
11
12#include <stdio.h>
13#include <stdarg.h>
14
15#include "al_debug.h"
16
17#ifdef NEED_DEBUG
18/*
19 * ald2str( aldEnum type )
20 *
21 * Returns a const char * string giving a readable representation of the debug
22 * type, or NULL if type is not a valid debug message type.  This string does
23 * not need to be free'd.
24 */
25static const char *ald2str( aldEnum l ) {
26        switch( l ) {
27                case ALD_INVALID:   return "INVALID";
28                case ALD_CONVERT:   return "CONVERT";
29                case ALD_CONFIG:    return "CONFIG";
30                case ALD_SOURCE:    return "SOURCE";
31                case ALD_LOOP:      return "LOOP";
32                case ALD_STUB:      return "STUB";
33                case ALD_CONTEXT:   return "CONTEXT";
34                case ALD_MATH:      return "MATH";
35                case ALD_MIXER:     return "MIXER";
36                case ALD_ERROR:     return "ERROR";
37                case ALD_EXT:       return "EXT";
38                case ALD_LOCK:      return "LOCK";
39                case ALD_MAXIMUS:   return "MAXIMUS";
40                case ALD_STREAMING: return "STREAM";
41                case ALD_MEM:       return "MEM";
42                case ALD_QUEUE:     return "QUEUE";
43                case ALD_FILTER:     return "FILTER";
44                default: break;
45        }
46
47        return NULL;
48}
49#endif
50
51/*
52 * _alDebug( aldEnum level, const char *fn, int ln, const char *format, ... )
53 *
54 * If debugging messages for the type level are enabled, print the debugging
55 * message specified by format, ... ( printf format ).  Otherwise, return.
56 *
57 */
58int _alDebug( aldEnum level, const char *fn, int ln, const char *format, ... )
59{
60#ifndef NEED_DEBUG
61        (void)level; (void)fn; (void)ln; (void)format;
62        return 0;
63#else
64        static char formatbuf[256];
65        int count;
66        va_list ap;
67#ifndef DEBUG_MAXIMUS /* DEBUG_MAXIMUS enables all debugging */
68
69#ifndef DEBUG_LOOP
70        if(level == ALD_LOOP) return 0;
71#endif
72#ifndef DEBUG_STUB
73        if(level == ALD_STUB) return 0;
74#endif
75#ifndef DEBUG_CONVERT
76        if(level == ALD_CONVERT) return 0;
77#endif
78#ifndef DEBUG_CONFIG
79        if(level == ALD_CONFIG) return 0;
80#endif
81#ifndef DEBUG_MATH
82        if(level == ALD_MATH) return 0;
83#endif
84#ifndef DEBUG_EXT
85        if(level == ALD_EXT) return 0;
86#endif
87#ifndef DEBUG_CONTEXT
88        if(level == ALD_CONTEXT) return 0;
89#endif
90#ifndef DEBUG_SOURCE
91        if(level == ALD_SOURCE) return 0;
92#endif
93#ifndef DEBUG_LOCK
94        if(level == ALD_LOCK) return 0;
95#endif
96#ifndef DEBUG_MAXIMUS
97        if(level == ALD_MAXIMUS) return 0;
98#endif
99#ifndef DEBUG_STREAMING
100        if(level == ALD_STREAMING) return 0;
101#endif
102#ifndef DEBUG_MEM
103        if(level == ALD_MEM) return 0;
104#endif
105#ifndef DEBUG_BUFFER
106        if(level == ALD_BUFFER) return 0;
107#endif
108#ifndef DEBUG_LISTENER
109        if(level == ALD_LISTENER) return 0;
110#endif
111#ifndef DEBUG_QUEUE
112        if(level == ALD_QUEUE) return 0;
113#endif
114#ifndef DEBUG_FILTER
115        if(level == ALD_FILTER) return 0;
116#endif
117#ifndef DEBUG_MIXER
118        if(level == ALD_MIXER) return 0;
119#endif
120
121#endif /* DEBUG_MAXIMUS */
122
123        count = snprintf(formatbuf, sizeof(formatbuf), "%s\t[%s:%d] ", ald2str(level), fn, ln);
124        if(count < 0)
125        {
126                return count;
127        }
128
129        va_start(ap, format);
130        vsnprintf(formatbuf, sizeof formatbuf, format, ap);
131        va_end(ap);
132
133        return fprintf(stderr, "%s\t[%s:%d] %s\n",
134                       ald2str(level), fn, ln, formatbuf );
135#endif /* NEED_DEBUG */
136}
Note: See TracBrowser for help on using the repository browser.