1*c839d22fShelg /* $OpenBSD: debug.h,v 1.2 2017/12/13 12:30:18 helg Exp $ */ 275af46c2Stedu /* 375af46c2Stedu * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> 475af46c2Stedu * 575af46c2Stedu * Permission to use, copy, modify, and distribute this software for any 675af46c2Stedu * purpose with or without fee is hereby granted, provided that the above 775af46c2Stedu * copyright notice and this permission notice appear in all copies. 875af46c2Stedu * 975af46c2Stedu * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1075af46c2Stedu * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1175af46c2Stedu * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1275af46c2Stedu * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1375af46c2Stedu * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1475af46c2Stedu * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1575af46c2Stedu * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1675af46c2Stedu */ 1775af46c2Stedu #ifndef _DEBUG_H_ 1875af46c2Stedu #define _DEBUG_H_ 1975af46c2Stedu 2075af46c2Stedu #include <stdio.h> 2175af46c2Stedu 2275af46c2Stedu #define DPRINTFN(n, ...) \ 2375af46c2Stedu do { \ 2475af46c2Stedu if (ifuse_debug >= (n)) \ 2575af46c2Stedu fprintf(stderr, __VA_ARGS__); \ 2675af46c2Stedu } while(0) 2775af46c2Stedu 2875af46c2Stedu #define DPRINTF(...) \ 2975af46c2Stedu do { \ 3075af46c2Stedu if (ifuse_debug > 0) \ 3175af46c2Stedu fprintf(stderr, __VA_ARGS__); \ 3275af46c2Stedu } while(0) 3375af46c2Stedu 3475af46c2Stedu #define DPERROR(s) \ 3575af46c2Stedu do { \ 3675af46c2Stedu if (ifuse_debug > 0) \ 3775af46c2Stedu perror(s); \ 3875af46c2Stedu } while(0) 3975af46c2Stedu 4075af46c2Stedu void ifuse_debug_init(void); 4175af46c2Stedu extern int ifuse_debug; 4275af46c2Stedu 4375af46c2Stedu #endif /* _DEBUG_H_ */ 44