1 /* debug.c: help the user discover what's going on.
2
3 Copyright 1993, 1994, 2008 Karl Berry.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this library; if not, see <http://www.gnu.org/licenses/>. */
17
18 #include <kpathsea/config.h>
19
20 #ifdef KPSE_DEBUG /* whole file */
21
22 /* If the real definitions of fopen or fclose are macros, we lose -- the
23 #undef won't restore them. */
24
25 FILE *
fopen(const char * filename,const char * mode)26 fopen (const char *filename, const char *mode)
27 {
28 #undef fopen
29 FILE *ret = fopen (filename, mode);
30 #if defined (KPSE_COMPAT_API)
31 kpathsea kpse = kpse_def;
32 if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN))
33 #if defined(_WIN64)
34 DEBUGF3 ("fopen(%s, %s) => 0x%I64x\n", filename, mode, (unsigned __int64) ret);
35 #else
36 DEBUGF3 ("fopen(%s, %s) => 0x%lx\n", filename, mode, (unsigned long) ret);
37 #endif
38 #endif
39 return ret;
40 }
41
42 int
fclose(FILE * f)43 fclose (FILE * f)
44 {
45 #undef fclose
46 int ret = fclose (f);
47 #if defined (KPSE_COMPAT_API)
48 kpathsea kpse = kpse_def;
49 if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN))
50 #if defined(_WIN64)
51 DEBUGF2 ("fclose(0x%I64x) => %d\n", (unsigned __int64) f, ret);
52 #else
53 DEBUGF2 ("fclose(0x%lx) => %d\n", (unsigned long) f, ret);
54 #endif
55 #endif
56 return ret;
57 }
58
59 #endif /* KPSE DEBUG */
60