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