1*b44cb2caSratchov /* $OpenBSD: debug.h,v 1.5 2015/10/02 09:48:22 ratchov Exp $ */ 282bfc72bSratchov /* 382bfc72bSratchov * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> 482bfc72bSratchov * 582bfc72bSratchov * Permission to use, copy, modify, and distribute this software for any 682bfc72bSratchov * purpose with or without fee is hereby granted, provided that the above 782bfc72bSratchov * copyright notice and this permission notice appear in all copies. 882bfc72bSratchov * 982bfc72bSratchov * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1082bfc72bSratchov * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1182bfc72bSratchov * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1282bfc72bSratchov * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1382bfc72bSratchov * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1482bfc72bSratchov * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1582bfc72bSratchov * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1682bfc72bSratchov */ 1782bfc72bSratchov #ifndef DEBUG_H 1882bfc72bSratchov #define DEBUG_H 1982bfc72bSratchov 2082bfc72bSratchov #ifdef DEBUG 2182bfc72bSratchov #include <stdio.h> 2282bfc72bSratchov 23b3956098Sratchov #define DPRINTFN(n, ...) \ 24b3956098Sratchov do { \ 25d418f94bSratchov if (_sndio_debug >= (n)) \ 26b3956098Sratchov fprintf(stderr, __VA_ARGS__); \ 27b3956098Sratchov } while(0) 28b3956098Sratchov 2982bfc72bSratchov #define DPRINTF(...) \ 3082bfc72bSratchov do { \ 31d418f94bSratchov if (_sndio_debug > 0) \ 3282bfc72bSratchov fprintf(stderr, __VA_ARGS__); \ 3382bfc72bSratchov } while(0) 3482bfc72bSratchov 3582bfc72bSratchov #define DPERROR(s) \ 3682bfc72bSratchov do { \ 37d418f94bSratchov if (_sndio_debug > 0) \ 3882bfc72bSratchov perror(s); \ 3982bfc72bSratchov } while(0) 4082bfc72bSratchov 41d418f94bSratchov void _sndio_debug_init(void); 42d418f94bSratchov extern int _sndio_debug; 4382bfc72bSratchov #else 4482bfc72bSratchov #define DPRINTF(...) do {} while(0) 45b3956098Sratchov #define DPRINTFN(...) do {} while(0) 4682bfc72bSratchov #define DPERROR(s) do {} while(0) 4782bfc72bSratchov #endif 4882bfc72bSratchov 49d418f94bSratchov const char *_sndio_parsetype(const char *, char *); 50*b44cb2caSratchov const char *_sndio_parsenum(const char *, unsigned int *, unsigned int); 51b3956098Sratchov 5282bfc72bSratchov #endif 53