1 /* ---------------------------------------------------------------------
2    $Id: reddeb.c 3634 2016-04-25 21:13:23Z arthurcnorman $
3    ---------------------------------------------------------------------
4    (c) 1999-2009 A. Dolzmann and T. Sturm, 1999-2014 T. Sturm
5    ---------------------------------------------------------------------
6    Redistribution and use in source and binary forms, with or without
7    modification, are permitted provided that the following conditions
8    are met:
9 
10       * Redistributions of source code must retain the relevant
11         copyright notice, this list of conditions and the following
12         disclaimer.
13       * Redistributions in binary form must reproduce the above
14         copyright notice, this list of conditions and the following
15         disclaimer in the documentation and/or other materials provided
16         with the distribution.
17 
18    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22    OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #include "redfront.h"
32 
33 #ifdef DEBUG
34 
35 
36 /*
37  * There used to be code involving a mutex here, but that would not have
38  * been effective across the two branches of a fork, even if it had
39  * really been needed!
40  */
41 
42 int debug = 1;
43 
44 extern int redfrontcolor;
45 extern int normalcolor;
46 extern int promptcolor;
47 extern int inputcolor;
48 extern int outputcolor;
49 extern int debugcolor;
50 
51 void deb_init(void);
52 int deb_fprintf(FILE *,const char *msg,...);
53 void deb_cleanup(void);
54 
deb_init(void)55 void deb_init(void) {
56 }
57 
deb_fprintf(FILE * file,const char * msg,...)58 int deb_fprintf(FILE *file,const char *msg,...) {
59   int ecode=0;
60   int oldcolor;
61   va_list ap;
62 
63   va_start(ap,msg);
64   if (debug && file) {
65     oldcolor = textcolor(debugcolor);
66     ecode = vfprintf(file,msg,ap);
67     textcolor(oldcolor);
68     fflush(file);
69   }
70   va_end(ap);
71 
72   return ecode;
73 }
74 
deb_cleanup()75 void deb_cleanup() {
76 }
77 
78 #else
79 
80 int debug = 0;
81 
deb_init(void)82 void deb_init(void) {
83 }
84 
deb_fprintf(FILE * file,const char * msg,...)85 int deb_fprintf(FILE *file,const char *msg,...) {
86   return 0;
87 }
88 
deb_cleanup()89 void deb_cleanup() {
90 }
91 
92 #endif
93 
94 /* end of reddeb.c */
95