debug.c revision 1.1.1.1.2.3
1/* $NetBSD: debug.c,v 1.1.1.1.2.3 2012/10/30 18:55:04 yamt Exp $ */ 2 3/* 4 * Copyright (C) 2012 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * Id: debug.c,v 1.1.1.2 2012/07/22 13:44:38 darrenr Exp $ 9 */ 10 11#if defined(__STDC__) 12# include <stdarg.h> 13#else 14# include <varargs.h> 15#endif 16#include <stdio.h> 17 18#include "ipf.h" 19#include "opts.h" 20 21int debuglevel = 0; 22 23 24#ifdef __STDC__ 25void debug(int level, char *fmt, ...) 26#else 27void debug(level, fmt, va_alist) 28 int level; 29 char *fmt; 30 va_dcl 31#endif 32{ 33 va_list pvar; 34 35 va_start(pvar, fmt); 36 37 if ((debuglevel > 0) && (level <= debuglevel)) 38 vfprintf(stderr, fmt, pvar); 39 va_end(pvar); 40} 41 42 43#ifdef __STDC__ 44void ipfkdebug(char *fmt, ...) 45#else 46void ipfkdebug(fmt, va_alist) 47 char *fmt; 48 va_dcl 49#endif 50{ 51 va_list pvar; 52 53 va_start(pvar, fmt); 54 55 if (opts & OPT_DEBUG) 56 debug(0x1fffffff, fmt, pvar); 57 va_end(pvar); 58} 59