1/*	$FreeBSD: releng/10.3/contrib/ipfilter/lib/debug.c 255332 2013-09-06 23:11:19Z cy $	*/
2
3/*
4 * Copyright (C) 2012 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 *
8 * $Id$
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