home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dbmalloc.zip / debug.h < prev    next >
C/C++ Source or Header  |  1993-01-04  |  3KB  |  126 lines

  1. /*
  2.  * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  3.  *
  4.  * This software may be distributed freely as long as the following conditions
  5.  * are met:
  6.  *         * the distribution, or any derivative thereof, may not be
  7.  *          included as part of a commercial product
  8.  *        * full source code is provided including this copyright
  9.  *        * there is no charge for the software itself (there may be
  10.  *          a minimal charge for the copying or distribution effort)
  11.  *        * this copyright notice is not modified or removed from any
  12.  *          source file
  13.  */
  14. /************************************************************************/
  15. /*                                    */
  16. /* this include sets up some macro functions which can be used while    */
  17. /* debugging the program, and then left in the code, but turned of by    */
  18. /* just not defining "DEBUG".  This way your production version of     */
  19. /* the program will not be filled with bunches of debugging junk    */
  20. /*                                    */
  21. /************************************************************************/
  22. /*
  23.  * $Id: debug.h,v 1.5 1992/08/22 16:27:13 cpcahil Exp $
  24.  */
  25.  
  26. #ifdef DEBUG
  27.  
  28. #if DEBUG == 1            /* if default level            */
  29. #undef DEBUG
  30. #define DEBUG    100        /*   use level 100            */
  31. #endif
  32.  
  33. #include <stdio.h>
  34.  
  35. #define DEBUG0(val,str)\
  36.                 {\
  37.                   if( DEBUG > val ) \
  38.                     fprintf(stderr,"%s(%d): %s\n",\
  39.                         __FILE__,__LINE__,str);\
  40.                 }
  41. #define DEBUG1(val,str,a1)\
  42.                     {\
  43.                   char _debugbuf[100];\
  44.                   if( DEBUG > val )\
  45.                    {\
  46.                     sprintf(_debugbuf,str,a1);\
  47.                     fprintf(stderr,"%s(%d): %s\n",\
  48.                         __FILE__,__LINE__,_debugbuf);\
  49.                    }\
  50.                        }
  51.  
  52. #define DEBUG2(val,str,a1,a2)\
  53.                     {\
  54.                  char _debugbuf[100];\
  55.                   if( DEBUG > val )\
  56.                    {\
  57.                     sprintf(_debugbuf,str,a1,a2);\
  58.                     fprintf(stderr,"%s(%d): %s\n",\
  59.                         __FILE__,__LINE__,_debugbuf);\
  60.                    }\
  61.                        }
  62.  
  63. #define DEBUG3(val,str,a1,a2,a3)\
  64.                     {\
  65.                   char _debugbuf[100];\
  66.                   if( DEBUG > val )\
  67.                    {\
  68.                     sprintf(_debugbuf,str,a1,a2,a3);\
  69.                     fprintf(stderr,"%s(%d): %s\n",\
  70.                         __FILE__,__LINE__,_debugbuf);\
  71.                    }\
  72.                        }
  73.  
  74. #define DEBUG4(val,str,a1,a2,a3,a4)\
  75.                      {\
  76.                   char _debugbuf[100];\
  77.                   if( DEBUG > val )\
  78.                    {\
  79.                     sprintf(_debugbuf,str,a1,a2,a3,a4);\
  80.                     fprintf(stderr,"%s(%d): %s\n",\
  81.                         __FILE__,__LINE__,_debugbuf);\
  82.                    }\
  83.                        }
  84.  
  85. #define DEBUG5(val,str,a1,a2,a3,a4,a5)\
  86.                      {\
  87.                   char _debugbuf[100];\
  88.                   if( DEBUG > val )\
  89.                    {\
  90.                     sprintf(_debugbuf,str,a1,a2,a3,a4,a5);\
  91.                     fprintf(stderr,"%s(%d): %s\n",\
  92.                         __FILE__,__LINE__,_debugbuf);\
  93.                    }\
  94.                        }
  95.  
  96. #else
  97.  
  98. #define DEBUG0(val,s)
  99. #define DEBUG1(val,s,a1)
  100. #define DEBUG2(val,s,a1,a2)
  101. #define DEBUG3(val,s,a1,a2,a3)
  102. #define DEBUG4(val,s,a1,a2,a3,a4)
  103. #define DEBUG5(val,s,a1,a2,a3,a4,a5)
  104.  
  105. #endif /* DEBUG */
  106.  
  107.  
  108. /*
  109.  * $Log: debug.h,v $
  110.  * Revision 1.5  1992/08/22  16:27:13  cpcahil
  111.  * final changes for pl14
  112.  *
  113.  * Revision 1.4  1992/04/13  03:06:33  cpcahil
  114.  * Added Stack support, marking of non-leaks, auto-config, auto-testing
  115.  *
  116.  * Revision 1.3  1991/11/25  14:41:51  cpcahil
  117.  * Final changes in preparation for patch 4 release
  118.  *
  119.  * Revision 1.2  90/05/11  00:13:08  cpcahil
  120.  * added copyright statment
  121.  * 
  122.  * Revision 1.1  90/02/23  07:09:01  cpcahil
  123.  * Initial revision
  124.  * 
  125.  */
  126.