xref: /freebsd/sbin/ipf/libipf/debug.c (revision 2a63c3be158216222d89a073dcbd6a72ee4aab5a)
1*41edb306SCy Schubert 
2*41edb306SCy Schubert /*
3*41edb306SCy Schubert  * Copyright (C) 2012 by Darren Reed.
4*41edb306SCy Schubert  *
5*41edb306SCy Schubert  * See the IPFILTER.LICENCE file for details on licencing.
6*41edb306SCy Schubert  *
7*41edb306SCy Schubert  * $Id$
8*41edb306SCy Schubert  */
9*41edb306SCy Schubert 
10*41edb306SCy Schubert # include <stdarg.h>
11*41edb306SCy Schubert #include <stdio.h>
12*41edb306SCy Schubert 
13*41edb306SCy Schubert #include "ipf.h"
14*41edb306SCy Schubert #include "opts.h"
15*41edb306SCy Schubert 
16*41edb306SCy Schubert int	debuglevel = 0;
17*41edb306SCy Schubert 
18*41edb306SCy Schubert 
19*41edb306SCy Schubert void
debug(int level,char * fmt,...)20*41edb306SCy Schubert debug(int level, char *fmt, ...)
21*41edb306SCy Schubert {
22*41edb306SCy Schubert 	va_list pvar;
23*41edb306SCy Schubert 
24*41edb306SCy Schubert 	va_start(pvar, fmt);
25*41edb306SCy Schubert 
26*41edb306SCy Schubert 	if ((debuglevel > 0) && (level <= debuglevel))
27*41edb306SCy Schubert 		vfprintf(stderr, fmt, pvar);
28*41edb306SCy Schubert 	va_end(pvar);
29*41edb306SCy Schubert }
30*41edb306SCy Schubert 
31*41edb306SCy Schubert 
32*41edb306SCy Schubert void
ipfkdebug(char * fmt,...)33*41edb306SCy Schubert ipfkdebug(char *fmt, ...)
34*41edb306SCy Schubert {
35*41edb306SCy Schubert 	va_list pvar;
36*41edb306SCy Schubert 
37*41edb306SCy Schubert 	va_start(pvar, fmt);
38*41edb306SCy Schubert 
39*41edb306SCy Schubert 	if (opts & OPT_DEBUG)
40*41edb306SCy Schubert 		debug(0x1fffffff, fmt, pvar);
41*41edb306SCy Schubert 	va_end(pvar);
42*41edb306SCy Schubert }
43