home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_06 / 2n06020d < prev    next >
Text File  |  1991-04-30  |  994b  |  42 lines

  1. #include <stdio.h>
  2. #include "snooper.h"
  3.  
  4. #ifndef NDEBUG
  5. int dump = 0;       /* use __EXTERN_DECL() to reference */
  6.                     /* 'dump' in other source modules...*/
  7.  
  8. /* Typing "+help" on command line prints out
  9.  * argument explanation strings. .... */
  10. static DEBUG_ARGS Argtab[] = {
  11. "dump", &dump,"Dump called() argument to file 'debug.000'",
  12. 0, 0, 0
  13. };
  14. #endif  /* NDEBUG */
  15.  
  16. static char buffer[BUFSIZ];
  17.  
  18. void print_byte(int x)
  19. {
  20.     /* Prints formatted string to file "debug.000"
  21.      * if 'dump' is non-zero and argument 'x' is
  22.      * negative.
  23.      */
  24.     __WATCH(dump && x < 0,__FIL0__,
  25.                  d_printf("called(): arg = %d\n", x));
  26.  
  27.     /* continue ..... */
  28. }
  29.  
  30. void main(int argc, char **argv )
  31. {
  32.     int i;
  33.     FILE *fp;
  34.  
  35.     __GETARGS(Argtab);  /* extract "dump" from cmd line */
  36.     fp = fopen("testfile", "r" );
  37.     fread(buffer,1,BUFSIZ,fp);
  38.     for( i = 0 ; i < BUFSIZ ; ++i ) {
  39.         print_byte((int) buffer[i]);
  40.     }
  41. }
  42.