1 /* $Id$ */ 2 /* 3 ** Copyright (C) 2002-2009 Sourcefire, Inc. 4 ** Copyright (C) 1998-2002 Martin Roesch <roesch@sourcefire.com> 5 ** 6 ** This program is free software; you can redistribute it and/or modify 7 ** it under the terms of the GNU General Public License Version 2 as 8 ** published by the Free Software Foundation. You may not use, modify or 9 ** distribute this program under any other version of the GNU General 10 ** Public License. 11 ** 12 ** This program is distributed in the hope that it will be useful, 13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ** GNU General Public License for more details. 16 ** 17 ** You should have received a copy of the GNU General Public License 18 ** along with this program; if not, write to the Free Software 19 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 22 23 #ifndef DEBUG_H 24 #define DEBUG_H 25 26 #ifdef HAVE_CONFIG_H 27 #include "config.h" 28 #endif 29 30 #ifdef WIN32 31 #define INLINE __inline 32 #else /* WIN32 */ 33 #define INLINE inline 34 #endif /* WIN32 */ 35 36 #include <ctype.h> 37 #ifdef HAVE_WCHAR_H 38 /* ISOC99 is defined to get required prototypes */ 39 #ifndef __USE_ISOC99 40 #define __USE_ISOC99 41 #endif 42 #include <wchar.h> 43 #endif 44 45 #define DEBUG_VARIABLE "BARNYARD2_DEBUG" 46 47 #define DEBUG_ALL 0xffffffff /* 4294967295 */ 48 #define DEBUG_INIT 0x00000001 /* 1 */ 49 #define DEBUG_CONFIGRULES 0x00000002 /* 2 */ 50 #define DEBUG_PLUGIN 0x00000004 /* 4 */ 51 #define DEBUG_VARS 0x00000010 /* 16 */ 52 #define DEBUG_LOG 0x00000020 /* 32 */ 53 #define DEBUG_FLOW 0x00000040 54 #define DEBUG_DECODE 0x00000080 55 #define DEBUG_DATALINK 0x00000100 56 #define DEBUG_INPUT_PLUGIN 0x00000200 57 #define DEBUG_OUTPUT_PLUGIN 0x00000400 58 #define DEBUG_SPOOLER 0x00000800 59 #define DEBUG_MAPS 0x00001000 60 #define DEBUG_MAPS_DEEP 0x00002000 61 #define DEBUG_PATTERN_MATCH 0x00080000 62 #define DEBUG_SID_SUPPRESS 0x00100000 63 #define DEBUG_SID_SUPPRESS_PARSE 0x00200000 64 65 void DebugMessageFunc(int dbg,char *fmt, ...); 66 #ifdef HAVE_WCHAR_H 67 void DebugWideMessageFunc(int dbg,wchar_t *fmt, ...); 68 #endif 69 70 #ifdef DEBUG 71 72 extern char *DebugMessageFile; 73 extern int DebugMessageLine; 74 75 #define DebugMessage DebugMessageFile = __FILE__; DebugMessageLine = __LINE__; DebugMessageFunc 76 #define DebugWideMessage DebugMessageFile = __FILE__; DebugMessageLine = __LINE__; DebugWideMessageFunc 77 78 int GetDebugLevel (void); 79 int DebugThis(int level); 80 #else 81 82 #ifdef WIN32 83 /* Visual C++ uses the keyword "__inline" rather than "__inline__" */ 84 #define __inline__ __inline 85 #endif 86 87 #endif /* DEBUG */ 88 89 90 #ifdef DEBUG 91 #define DEBUG_WRAP(code) code 92 void DebugMessageFunc(int dbg,char *fmt, ...); 93 #ifdef HAVE_WCHAR_H 94 void DebugWideMessageFunc(int dbg,wchar_t *fmt, ...); 95 #endif 96 #else 97 #define DEBUG_WRAP(code) 98 /* I would use DebugMessage(dbt,fmt...) but that only works with GCC */ 99 100 #endif 101 102 #endif /* DEBUG_H */ 103