home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gdebug.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  5.4 KB  |  127 lines

  1. /* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gdebug.h,v 1.2 2000/09/19 19:00:11 lpd Exp $ */
  20. /* Debugging machinery definitions */
  21.  
  22. #ifndef gdebug_INCLUDED
  23. #  define gdebug_INCLUDED
  24.  
  25. /*
  26.  * The compile-time DEBUG symbol determines whether debugging/tracing
  27.  * code is included in the compiled code.  DEBUG may be set or not set
  28.  * independently for every compilation; however, a small amount of support
  29.  * machinery in gsmisc.c is always included in the executable, just
  30.  * in case *some* file was compiled with DEBUG set.
  31.  *
  32.  * When DEBUG is set, it does not cause debugging/tracing printout to occur.
  33.  * Rather, it includes code that produces such printout *if* (a) given
  34.  * one(s) of 128 debugging flags is set.  In this way, one can selectively
  35.  * turn printout on and off during debugging.  (In fact, we even provide a
  36.  * PostScript operator, .setdebug, that does this.)
  37.  *
  38.  * The debugging flags are normally indexed by character code.  This is more
  39.  * than a convention: gs_debug_c, which tests whether a given flag is set,
  40.  * considers that if a flag named by a given upper-case letter is set, the
  41.  * flag named by the corresponding lower-case letter is also set.
  42.  *
  43.  * If the output selected by a given flag can be printed by a single
  44.  * printf, the conventional way to produce the output is
  45.  *      if_debugN('x', "...format...", v1, ..., vN);
  46.  * Usually the flag appears in the output explicitly:
  47.  *      if_debugN('x', "[x]...format...", v1, ..., vN);
  48.  * If the output is more complex, the conventional way to produce the
  49.  * output is
  50.  *      if ( gs_debug_c('x') ) {
  51.  *        ... start each line with dlprintfN(...)
  52.  *        ... produce additional output within a line with dprintfN(...)
  53.  * } */
  54.  
  55. /* Define the array of debugging flags, indexed by character code. */
  56. extern char gs_debug[128];
  57. bool gs_debug_c(P1(int /*char */ ));
  58.  
  59. /*
  60.  * Define an alias for a specialized debugging flag
  61.  * that used to be a separate variable.
  62.  */
  63. #define gs_log_errors gs_debug['#']
  64.  
  65. /* If debugging, direct all error output to gs_debug_out. */
  66. extern FILE *gs_debug_out;
  67.  
  68. #ifdef DEBUG
  69. #undef dstderr
  70. #define dstderr gs_debug_out
  71. #undef estderr
  72. #define estderr gs_debug_out
  73. #endif
  74.  
  75. /* Debugging printout macros. */
  76. #ifdef DEBUG
  77. #  define if_debug0(c,s)\
  78.     BEGIN if (gs_debug_c(c)) dlprintf(s); END
  79. #  define if_debug1(c,s,a1)\
  80.     BEGIN if (gs_debug_c(c)) dlprintf1(s,a1); END
  81. #  define if_debug2(c,s,a1,a2)\
  82.     BEGIN if (gs_debug_c(c)) dlprintf2(s,a1,a2); END
  83. #  define if_debug3(c,s,a1,a2,a3)\
  84.     BEGIN if (gs_debug_c(c)) dlprintf3(s,a1,a2,a3); END
  85. #  define if_debug4(c,s,a1,a2,a3,a4)\
  86.     BEGIN if (gs_debug_c(c)) dlprintf4(s,a1,a2,a3,a4); END
  87. #  define if_debug5(c,s,a1,a2,a3,a4,a5)\
  88.     BEGIN if (gs_debug_c(c)) dlprintf5(s,a1,a2,a3,a4,a5); END
  89. #  define if_debug6(c,s,a1,a2,a3,a4,a5,a6)\
  90.     BEGIN if (gs_debug_c(c)) dlprintf6(s,a1,a2,a3,a4,a5,a6); END
  91. #  define if_debug7(c,s,a1,a2,a3,a4,a5,a6,a7)\
  92.     BEGIN if (gs_debug_c(c)) dlprintf7(s,a1,a2,a3,a4,a5,a6,a7); END
  93. #  define if_debug8(c,s,a1,a2,a3,a4,a5,a6,a7,a8)\
  94.     BEGIN if (gs_debug_c(c)) dlprintf8(s,a1,a2,a3,a4,a5,a6,a7,a8); END
  95. #  define if_debug9(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
  96.     BEGIN if (gs_debug_c(c)) dlprintf9(s,a1,a2,a3,a4,a5,a6,a7,a8,a9); END
  97. #  define if_debug10(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)\
  98.     BEGIN if (gs_debug_c(c)) dlprintf10(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10); END
  99. #  define if_debug11(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)\
  100.     BEGIN if (gs_debug_c(c)) dlprintf11(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11); END
  101. #  define if_debug12(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)\
  102.     BEGIN if (gs_debug_c(c)) dlprintf12(s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12); END
  103. #else
  104. #  define if_debug0(c,s) DO_NOTHING
  105. #  define if_debug1(c,s,a1) DO_NOTHING
  106. #  define if_debug2(c,s,a1,a2) DO_NOTHING
  107. #  define if_debug3(c,s,a1,a2,a3) DO_NOTHING
  108. #  define if_debug4(c,s,a1,a2,a3,a4) DO_NOTHING
  109. #  define if_debug5(c,s,a1,a2,a3,a4,a5) DO_NOTHING
  110. #  define if_debug6(c,s,a1,a2,a3,a4,a5,a6) DO_NOTHING
  111. #  define if_debug7(c,s,a1,a2,a3,a4,a5,a6,a7) DO_NOTHING
  112. #  define if_debug8(c,s,a1,a2,a3,a4,a5,a6,a7,a8) DO_NOTHING
  113. #  define if_debug9(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9) DO_NOTHING
  114. #  define if_debug10(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) DO_NOTHING
  115. #  define if_debug11(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) DO_NOTHING
  116. #  define if_debug12(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) DO_NOTHING
  117. #endif
  118.  
  119. /* Debugging support procedures in gsmisc.c */
  120. void debug_dump_bytes(P3(const byte * from, const byte * to,
  121.              const char *msg));
  122. void debug_dump_bitmap(P4(const byte * from, uint raster, uint height,
  123.               const char *msg));
  124. void debug_print_string(P2(const byte * str, uint len));
  125.  
  126. #endif /* gdebug_INCLUDED */
  127.