--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Copyright © 2006 Pierre Habouzit
+ */
+/*
+ * written for mutt-ng by:
+ * Rocco Rutte <pdmef@cs.tu-berlin.de>
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+
+/* generic interface for debug messages */
+
+#ifndef _LIB_DEBUG_H
+#define _LIB_DEBUG_H
+
+#include <stdio.h>
+
+#define DEBUG_MIN_LEVEL 1
+#define DEBUG_MIN_LEVEL_S "1"
+#define DEBUG_MAX_LEVEL 5
+#define DEBUG_MAX_LEVEL_S "5"
+
+#ifdef DEBUG
+
+extern short DebugLevel;
+extern FILE* DebugFile;
+
+void debug_setlevel (short);
+void debug_start (const char*);
+
+void _debug_print_intro (const char*, int, const char*, int);
+void _debug_print_msg (const char*, ...);
+
+/*
+ * the debug_print() macro will (in the end) print debug messages of the
+ * following format:
+ *
+ * (file:line:function:level): message
+ *
+ * for GCC and:
+ *
+ * (file:line:level): message
+ *
+ * otherwise
+ */
+#ifdef __GNUC__
+
+#define debug_print(level,msg) \
+ do { \
+ if (DebugLevel >= level) { \
+ _debug_print_intro (__FILE__,__LINE__,__func__,level); \
+ _debug_print_msg msg; \
+ } \
+ } while(0)
+
+#else /* __GNUC__ */
+
+#define debug_print(level,msg) \
+ do { \
+ if (DebugLevel >= level) { \
+ _debug_print_intro (__FILE__,__LINE__,NULL,level); \
+ _debug_print_msg msg; \
+ } \
+ } while(0)
+
+#endif /* !__GNUC__ */
+
+#else /* DEBUG */
+
+/*
+ * without debug support, we don't need these
+ * (this also kills the dozens of #ifdef for debug...
+ */
+#define debug_start(basedir)
+#define debug_setlevel(level)
+#define debug_print(level,msg)
+
+#endif /* !DEBUG */
+
+#endif /* !_LIB_DEBUG_H */