home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / xc-4.1 / part01 / xcdbglog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-13  |  907 b   |  55 lines

  1. /*    xcdbglog.c -- debug logging module for XC
  2.     This file uses 4-character tabstops
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <time.h>
  7. #include <sys/types.h>
  8. #define NODEBUG 1    /* prevents xc.h from defining DEBUG */
  9. #include "xc.h"
  10.  
  11. #if DEBUG
  12. static FILE *dfp;
  13.  
  14. void
  15. dbglog()
  16. {
  17.     long todnow;
  18.  
  19.     time(&todnow);
  20.     if (!access("debug.log",0) && (dfp=fopen("debug.log","w")))
  21.         setbuf(dfp, NIL(char)),
  22.         fprintf(dfp,(char*)asctime(localtime(&todnow)));
  23.     return;
  24. }
  25.  
  26. Fputc(c, stream)
  27. register c;
  28. FILE *stream;
  29. {
  30.     if (!capture && dfp && c != '\r')
  31.         fputc(c,dfp);
  32.     return(fputc(c,stream));
  33. }
  34.  
  35. Fputs(s, stream)
  36. register char *s;
  37. FILE *stream;
  38. {
  39.     if (!capture && dfp)
  40.         fputs(s,dfp);
  41.     return(fputs(s,stream));
  42. }
  43.  
  44. Fprintf(stream, format, a, b, c, d, e, f, g)
  45. FILE *stream;
  46. char *format;
  47. long a, b, c, d, e, f, g;
  48. {
  49.     if (!capture && dfp)
  50.         fprintf(dfp,format,a,b,c,d,e,f,g);
  51.     return(fprintf(stream,format,a,b,c,d,e,f,g));
  52. }
  53.  
  54. #endif
  55.