home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-src.tgz / tar.out / contrib / unixtex / kpathsea / debug.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-28  |  2.4 KB  |  73 lines

  1. /* debug.h: Runtime tracing.
  2.  
  3. Copyright (C) 1993, 94 Karl Berry.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef KPATHSEA_DEBUG_H
  20. #define KPATHSEA_DEBUG_H
  21.  
  22. /* If NO_DEBUG is defined, skip all this.  */
  23. #ifndef NO_DEBUG
  24.  
  25. #include <kpathsea/c-proto.h>
  26. #include <kpathsea/c-std.h>
  27. #include <kpathsea/types.h>
  28.  
  29. /* OK, we'll have tracing support.  */
  30. #define DEBUG
  31.  
  32. /* Bit vector defining what we should trace.  */
  33. extern unsigned kpathsea_debug;
  34.  
  35. /* Set a bit.  */
  36. #define KPSE_DEBUG_SET(bit) kpathsea_debug |= 1 << (bit)
  37.  
  38. /* Test if a bit is on.  */
  39. #define KPSE_DEBUG_P(bit) (kpathsea_debug & (1 << (bit)))
  40.  
  41. #define KPSE_DEBUG_STAT 0        /* stat calls */
  42. #define KPSE_DEBUG_HASH 1        /* hash lookups */
  43. #define KPSE_DEBUG_FOPEN 2        /* fopen/fclose calls */
  44. #define KPSE_DEBUG_PATHS 3        /* search path initializations */
  45. #define KPSE_DEBUG_EXPAND 4        /* path element expansion */
  46. #define KPSE_DEBUG_SEARCH 5        /* searches */
  47.  
  48. /* A printf for the debugging.  */
  49. #define DEBUGF_START() do { fputs ("kdebug:", stderr)
  50. #define DEBUGF_END()        fflush (stderr); } while (0)
  51.  
  52. #define DEBUGF(str)                            \
  53.   DEBUGF_START (); fputs (str, stderr); DEBUGF_END ()
  54. #define DEBUGF1(str, e1)                        \
  55.   DEBUGF_START (); fprintf (stderr, str, e1); DEBUGF_END ()
  56. #define DEBUGF2(str, e1, e2)                        \
  57.   DEBUGF_START (); fprintf (stderr, str, e1, e2); DEBUGF_END ()
  58. #define DEBUGF3(str, e1, e2, e3)                    \
  59.   DEBUGF_START (); fprintf (stderr, str, e1, e2, e3); DEBUGF_END ()
  60. #define DEBUGF4(str, e1, e2, e3, e4)                    \
  61.   DEBUGF_START (); fprintf (stderr, str, e1, e2, e3, e4); DEBUGF_END ()
  62.  
  63. #undef fopen
  64. #define fopen kpse_fopen_trace
  65. extern FILE *fopen P2H(const_string filename, const_string mode);
  66. #undef fclose
  67. #define fclose kpse_fclose_trace
  68. extern int fclose P1H(FILE *);
  69.  
  70. #endif /* not NO_DEBUG */
  71.  
  72. #endif /* not KPATHSEA_DEBUG_H */
  73.