/* $Id$ */
/*
** Copyright (C) 2002-2012 Sourcefire, Inc.
** Copyright (C) 1998-2002 Martin Roesch <roesch@sourcefire.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License Version 2 as
** published by the Free Software Foundation.  You may not use, modify or
** distribute this program under any other version of the GNU General
** Public License.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/


#ifndef DEBUG_H
#define DEBUG_H

#include <ctype.h>
#ifdef SF_WCHAR
/* ISOC99 is defined to get required prototypes */
#ifndef __USE_ISOC99
#define __USE_ISOC99
#endif
#include <wchar.h>
#endif

// this env var uses the lower 32 bits of the flags:
#define DEBUG_VARIABLE "SNORT_DEBUG"

#define DEBUG_INIT            0x0000000000000001
#define DEBUG_PARSER          0x0000000000000002
#define DEBUG_MSTRING         0x0000000000000004
#define DEBUG_PORTLISTS       0x0000000000000008
#define DEBUG_ATTRIBUTE       0x0000000000000010
#define DEBUG_PLUGIN          0x0000000000000020
#define DEBUG_PLUGBASE        0x0000000000000040
#define DEBUG_DECODE          0x0000000000000080
#define DEBUG_DATALINK        0x0000000000000100
#define DEBUG_CONFIGRULES     0x0000000000000200
#define DEBUG_RULES           0x0000000000000400
#define DEBUG_DETECT          0x0000000000000800
#define DEBUG_PATTERN_MATCH   0x0000000000001000
#define DEBUG_FLOW            0x0000000000002000
#define DEBUG_LOG             0x0000000000004000
#define DEBUG_EXP             0x0000000080000000

// this env var uses the upper 32 bits of the flags:
#define DEBUG_PP_VAR   "SNORT_PP_DEBUG"

#define DEBUG_FRAG            0x0000000100000000
#define DEBUG_STREAM          0x0000000200000000
#define DEBUG_STREAM_STATE    0x0000000400000000
#define DEBUG_STREAM_PAF      0x0000000800000000
#define DEBUG_HTTP_DECODE     0x0000001000000000
#define DEBUG_HTTPINSPECT     0x0000002000000000
#define DEBUG_ASN1            0x0000004000000000
#define DEBUG_DNS             0x0000008000000000
#define DEBUG_FTPTELNET       0x0000010000000000
#define DEBUG_GTP             0x0000020000000000
#define DEBUG_IMAP            0x0000040000000000
#define DEBUG_POP             0x0000080000000000
#define DEBUG_RPC             0x0000100000000000
#define DEBUG_SIP             0x0000200000000000
#define DEBUG_SKYPE           0x0000400000000000
#define DEBUG_SSL             0x0000800000000000
#define DEBUG_SMTP            0x0001000000000000
#define DEBUG_PP_EXP          0x8000000000000000

void DebugMessageFunc(uint64_t dbg,char *fmt, ...);
#ifdef SF_WCHAR
void DebugWideMessageFunc(uint64_t dbg,wchar_t *fmt, ...);
#endif

#ifdef DEBUG_MSGS

    extern char *DebugMessageFile;
    extern int DebugMessageLine;

    #define    DebugMessage    *_dpd.debugMsgFile = __FILE__; *_dpd.debugMsgLine = __LINE__; _dpd.debugMsg
    #define    DebugWideMessage    *_dpd.debugMsgFile = __FILE__; *_dpd.debugMsgLine = __LINE__; _dpd.debugWideMsg

    uint64_t GetDebugLevel (void);
    int DebugThis(uint64_t level);
#else /* DEBUG_MSGS */

#ifdef WIN32
/* Visual C++ uses the keyword "__inline" rather than "__inline__" */
         #define __inline__ __inline
#endif

#endif /* DEBUG_MSGS */


#ifdef DEBUG_MSGS
#define DEBUG_WRAP(code) code
void DebugMessageFunc(uint64_t dbg,char *fmt, ...);
#ifdef SF_WCHAR
void DebugWideMessageFunc(uint64_t dbg,wchar_t *fmt, ...);
#endif
#else /* DEBUG_MSGS */
#define DEBUG_WRAP(code)
/* I would use DebugMessage(dbt,fmt...) but that only works with GCC */

#endif /* DEBUG_MSGS */

#endif /* DEBUG_H */

