home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / cake / part03 / trail.c < prev   
Encoding:
C/C++ Source or Header  |  1987-10-14  |  1.0 KB  |  56 lines

  1. /*
  2. **    Trail module.
  3. */
  4.  
  5. static    char
  6. rcs_id[] = "$Header: /mip/zs/src/sys/cake/RCS/trail.c,v 1.14 86/07/19 12:24:19 zs Exp $";
  7.  
  8. #ifdef    CAKEDEBUG
  9. #include    "cake.h"
  10.  
  11. #define        TRAILSIZE    100
  12.  
  13. static    int    trail_entries = 0;    /* no. of calls to put_tr */
  14. static    int    slot = 0;        /* next slot          */
  15. static    char    *trailfunc[TRAILSIZE];    /* functions and events      */
  16. static    char    *trailevent[TRAILSIZE];    /* init to NULL by C      */
  17.  
  18. /*
  19. **    Register this function on the trail.
  20. */
  21.  
  22. put_trail(func, event)
  23. reg    char    *func;
  24. reg    char    *event;
  25. {
  26.     trailfunc[slot]  = func;
  27.     trailevent[slot] = event;
  28.  
  29.     trail_entries++;
  30.     if (++slot == TRAILSIZE)
  31.         slot = 0;
  32. }
  33.  
  34. /*
  35. **    Print the trail on the given file.
  36. */
  37.  
  38. get_trail(fp)
  39. reg    FILE    *fp;
  40. {
  41.     reg    int    maxent;
  42.  
  43.     fprintf(fp, "^^^^^^^^^^^^^^^^^^^ TRAIL ^^^^^^^^^^^^^^^^^^^\n");
  44.     fprintf(fp, "%d entries\n", trail_entries);
  45.  
  46.     maxent = (trail_entries < TRAILSIZE)? trail_entries: TRAILSIZE;
  47.     while (maxent-- > 0)
  48.     {
  49.         if (--slot == -1)
  50.             slot = TRAILSIZE - 1;
  51.  
  52.         fprintf(fp, "%s %s\n", trailfunc[slot], trailevent[slot]);
  53.     }
  54. }
  55. #endif
  56.