home *** CD-ROM | disk | FTP | other *** search
- /* debug.h: Runtime tracing.
-
- Copyright (C) 1993, 94 Karl Berry.
-
- 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- #ifndef KPATHSEA_DEBUG_H
- #define KPATHSEA_DEBUG_H
-
- /* If NO_DEBUG is defined, skip all this. */
- #ifndef NO_DEBUG
-
- #include <kpathsea/c-proto.h>
- #include <kpathsea/c-std.h>
- #include <kpathsea/types.h>
-
- /* OK, we'll have tracing support. */
- #define DEBUG
-
- /* Bit vector defining what we should trace. */
- extern unsigned kpathsea_debug;
-
- /* Set a bit. */
- #define KPSE_DEBUG_SET(bit) kpathsea_debug |= 1 << (bit)
-
- /* Test if a bit is on. */
- #define KPSE_DEBUG_P(bit) (kpathsea_debug & (1 << (bit)))
-
- #define KPSE_DEBUG_STAT 0 /* stat calls */
- #define KPSE_DEBUG_HASH 1 /* hash lookups */
- #define KPSE_DEBUG_FOPEN 2 /* fopen/fclose calls */
- #define KPSE_DEBUG_PATHS 3 /* search path initializations */
- #define KPSE_DEBUG_EXPAND 4 /* path element expansion */
- #define KPSE_DEBUG_SEARCH 5 /* searches */
-
- /* A printf for the debugging. */
- #define DEBUGF_START() do { fputs ("kdebug:", stderr)
- #define DEBUGF_END() fflush (stderr); } while (0)
-
- #define DEBUGF(str) \
- DEBUGF_START (); fputs (str, stderr); DEBUGF_END ()
- #define DEBUGF1(str, e1) \
- DEBUGF_START (); fprintf (stderr, str, e1); DEBUGF_END ()
- #define DEBUGF2(str, e1, e2) \
- DEBUGF_START (); fprintf (stderr, str, e1, e2); DEBUGF_END ()
- #define DEBUGF3(str, e1, e2, e3) \
- DEBUGF_START (); fprintf (stderr, str, e1, e2, e3); DEBUGF_END ()
- #define DEBUGF4(str, e1, e2, e3, e4) \
- DEBUGF_START (); fprintf (stderr, str, e1, e2, e3, e4); DEBUGF_END ()
-
- #undef fopen
- #define fopen kpse_fopen_trace
- extern FILE *fopen P2H(const_string filename, const_string mode);
- #undef fclose
- #define fclose kpse_fclose_trace
- extern int fclose P1H(FILE *);
-
- #endif /* not NO_DEBUG */
-
- #endif /* not KPATHSEA_DEBUG_H */
-