debug.h revision 1.2
1/*	$OpenBSD: debug.h,v 1.2 2011/11/15 08:05:22 ratchov Exp $	*/
2/*
3 * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17#ifndef DEBUG_H
18#define DEBUG_H
19
20#ifdef DEBUG
21#include <stdio.h>
22
23#define DPRINTFN(n, ...)					\
24	do {							\
25		if (sndio_debug >= (n))				\
26			fprintf(stderr, __VA_ARGS__);		\
27	} while(0)
28
29#define DPRINTF(...)						\
30	do {							\
31		if (sndio_debug > 0)				\
32			fprintf(stderr, __VA_ARGS__);		\
33	} while(0)
34
35#define DPERROR(s)						\
36	do {							\
37		if (sndio_debug > 0)				\
38			perror(s);				\
39	} while(0)
40
41void sndio_debug_init(void);
42extern int sndio_debug;
43#else
44#define DPRINTF(...) do {} while(0)
45#define DPRINTFN(...) do {} while(0)
46#define DPERROR(s) do {} while(0)
47#endif
48
49const char *sndio_parsetype(const char *, char *);
50
51#endif
52