xref: /openbsd-src/usr.sbin/npppd/common/debugutil.h (revision 898184e3e61f9129feb5978fad5a8c6865f00b92)
1 /*-
2  * Copyright (c) 2009 Internet Initiative Japan Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 #ifndef	DEBUG_UTIL_H
27 #define	DEBUG_UTIL_H 1
28 
29 #include "debugmacro.h"
30 
31 #define	DEBUG_LEVEL_1	( 1 << 24)
32 #define	DEBUG_LEVEL_2	( 2 << 24)
33 #define	DEBUG_LEVEL_3	( 3 << 24)
34 #define	DEBUG_LEVEL_4	( 4 << 24)
35 #define	DEBUG_LEVEL_5	( 5 << 24)
36 #define	DEBUG_LEVEL_6	( 6 << 24)
37 #define	DEBUG_LEVEL_7	( 7 << 24)
38 #define	DEBUG_LEVEL_8	( 8 << 24)
39 #define	DEBUG_LEVEL_9	( 9 << 24)
40 #define	DEBUG_LEVEL_10	(10 << 24)
41 #define	DEBUG_LEVEL_11	(11 << 24)
42 #define	DEBUG_LEVEL_12	(12 << 24)
43 #define	DEBUG_LEVEL_13	(13 << 24)
44 #define	DEBUG_LEVEL_14	(14 << 24)
45 #define	DEBUG_LEVEL_15	(15 << 24)
46 
47 extern int debuglevel;
48 
49 /* adapted from FreeBSD:/usr/include/sys/cdefs */
50 #ifndef __printflike
51 #if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7
52 #define __printflike(fmtarg, firstvararg)
53 #else
54 #define __printflike(fmtarg, firstvararg) \
55 		__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
56 #endif
57 #endif
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 #include <stdarg.h>
64 
65 void  debug_set_debugfp (FILE *);
66 FILE  *debug_get_debugfp (void);
67 int   vlog_printf (uint32_t, const char *, va_list);
68 int   log_printf (int, const char *, ...) __printflike(2, 3);
69 void  show_hd (FILE *, const u_char *, int);
70 void  debug_use_syslog (int);
71 void  debug_set_syslog_level_adjust (int);
72 int   debug_get_syslog_level_adjust (void);
73 void  debug_set_no_debuglog (int);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 
80 #endif
81