Project Homepage | Sourceforge Page | CVS Repository | Freshmeat.net Page | Download project | Author's Homepage |
00001 /*! \file debug.h 00002 \brief run-free debug macros 00003 00004 These macros are here for convenience. Mostly I use this kind of 00005 stuff for light debug work here and there. Please feel free to 00006 steal what you need and use it as your own -parasyte. 00007 */ 00008 /* NOTICE: 00009 Copyright (C) 2004 Karl N. Redman (SleepingStill.com) 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 This program is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU General Public License for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with this program; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 For further information contact: parasyte@sleepingstill.com 00026 */ 00027 #ifndef _DEBUG_H_ 00028 #define _DEBUG_H_ 00029 00030 #ifdef HAVE_CONFIG_H 00031 # include <config.h> 00032 #endif 00033 00034 /** 00035 run-free DEBUGING STATEMENTS. 00036 00037 These would be called in the following ways:<br> 00038 dprint("this is a string");<br> 00039 dprint_s1("this is also a string");<br> 00040 dprint_s2("foo", "bar");<br> 00041 dprint_f1("%s", "thing");<br> 00042 dprint_f1("%d", 1);<br> 00043 dprint_f2("%s", "%d", "stuff", 69);<br> 00044 dprint_f2("%s", "%x", "a hex number", 255);<br> 00045 00046 This would be the output (assuming PACKAGE is defined as 00047 "run-free"):<br> 00048 run-free DEBUG(this is a string)<br> 00049 run-free DEBUG(this is also a string)<br> 00050 run-free DEBUG(foo:bar)<br> 00051 run-free DEBUG(thing)<br> 00052 run-free DEBUG(1)<br> 00053 run-free DEBUG(stuff:69)<br> 00054 run-free DEBUG(a hex number:ff) <br> 00055 */ 00056 ///compile time option 00057 #ifdef DEBUG 00058 #define DEBUG_MODE 1 00059 #else 00060 #define DEBUG_MODE 0 00061 #endif 00062 00063 /// The package name 00064 #define DEBUG_PREMSG PACKAGE 00065 00066 /// a submessage 00067 #define DEBUG_SUBMSG "DEBUG" 00068 00069 /** @name Debugging statments 00070 * These macros print statements to the command line when run-free is 00071 * compiled with the --enable-debug=yes directive from configure 00072 */ 00073 //@{ 00074 /// print a string in debug mode -a convenience function 00075 #define dprint(string) dprint_s1(string) 00076 /// single string printing 00077 #define dprint_s1(string) if(DEBUG_MODE) g_print(""DEBUG_PREMSG" "DEBUG_SUBMSG"(%s)\n", string) 00078 /// double string printing 00079 #define dprint_s2(string1, string2) if(DEBUG_MODE) g_print(""DEBUG_PREMSG" "DEBUG_SUBMSG"(%s:%s)\n", string1, string2) 00080 /// single format debugging from gprint 00081 #define dprint_f1(format, data) if(DEBUG_MODE) g_print(""DEBUG_PREMSG" "DEBUG_SUBMSG"("format")\n", data) 00082 /// double format debugging from gprint 00083 #define dprint_f2(format1, format2, data1, data2) if(DEBUG_MODE) g_print(""DEBUG_PREMSG" "DEBUG_SUBMSG"("format1":"format2")\n", data1, data2) 00084 //@} 00085 00086 #endif //_DEBUG_H_