home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / vim-2.0.lha / Vim-2.0 / src / debug.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-28  |  865 b   |  32 lines

  1. /*
  2.  * debug.h -- my debug header for just any program.
  3.  * use:
  4.  * place the statement OPENDEBUG("/tmp/programdebug"); inside main.
  5.  * Nothing will happen, unless you compile the source with -DDEBUG.
  6.  * 
  7.  * jw. 13.4.91.
  8.  */
  9. #ifndef FILE
  10. # include <stdio.h>
  11. #endif
  12.  
  13. #ifdef DEBUG
  14. #    define debug(x) {fprintf(debugfp,x);fflush(debugfp);}
  15. #    define debug1(x,a) {fprintf(debugfp,x,a);fflush(debugfp);}
  16. #    define debug2(x,a,b) {fprintf(debugfp,x,a,b);fflush(debugfp);}
  17. #    define debug3(x,a,b,c) {fprintf(debugfp,x,a,b,c);fflush(debugfp);}
  18. #    define OPENDEBUG(file)\
  19.     if ((debugfp = fopen(file,"w")) == NULL)\
  20.     {    debugfp = stderr;\
  21.         debug1("OPENDEBUG: sorry, cannot open '%s'\n", file);\
  22.         debug("           beware, using stderr!\n");\
  23.         sleep(3);\
  24.     }
  25. #else
  26. #    define debug(x)
  27. #    define debug1(x,a)
  28. #    define debug2(x,a,b)
  29. #    define debug3(x,a,b,c)
  30. #    define OPENDEBUG(file)
  31. #endif
  32.