home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / condor40.zip / CONDOR / src / util_lib / ctrace.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  3KB  |  99 lines

  1. /* 
  2. ** Copyright 1986, 1987, 1988, 1989 University of Wisconsin
  3. ** 
  4. ** Permission to use, copy, modify, and distribute this software and its
  5. ** documentation for any purpose and without fee is hereby granted,
  6. ** provided that the above copyright notice appear in all copies and that
  7. ** both that copyright notice and this permission notice appear in
  8. ** supporting documentation, and that the name of the University of
  9. ** Wisconsin not be used in advertising or publicity pertaining to
  10. ** distribution of the software without specific, written prior
  11. ** permission.  The University of Wisconsin makes no representations about
  12. ** the suitability of this software for any purpose.  It is provided "as
  13. ** is" without express or implied warranty.
  14. ** 
  15. ** THE UNIVERSITY OF WISCONSIN DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16. ** THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. ** FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF WISCONSIN  BE LIABLE FOR
  18. ** ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19. ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20. ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  21. ** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22. ** 
  23. ** Authors:  Allan Bricker and Michael J. Litzkow,
  24. **              University of Wisconsin, Computer Sciences Dept.
  25. ** 
  26. */ 
  27.  
  28.  
  29. #include <stdio.h>
  30. #include <sys/time.h>
  31. #include "ctrace.h"
  32. #include "globals.h"
  33.  
  34. TraceEntry entry;
  35. long       traceFlag         = 0;
  36. long       numberOfTransfers = 0;
  37.  
  38. void StartRecording()
  39.   {
  40.     if ((traceFlag) || (numberOfTransfers == 0))
  41.     {
  42.       bzero(&entry, sizeof(TraceEntry));
  43.       gettimeofday(&entry.initialTime, 0);
  44.     }
  45.   }
  46.  
  47. void CompleteRecording(numberOfBytes)
  48.   long numberOfBytes;
  49.   {
  50.     if ((traceFlag) || (numberOfTransfers == 0))
  51.     {
  52.       gettimeofday(&entry.completionTime, 0);
  53.       entry.operation     = TRANSFER;
  54.       entry.numberOfBytes = numberOfBytes;
  55.       write(2 /* stderr */, &entry, sizeof(TraceEntry));
  56.     }
  57.     numberOfTransfers++;
  58.   }
  59.  
  60. void ProcessLogging (request, extraInteger)
  61.   int request;
  62.   int extraInteger;
  63.   {
  64.     switch (request)
  65.     {
  66.       case ENABLE_LOGGING :   traceFlag = 1;
  67.                               if (numberOfTransfers == 1)
  68.                               {
  69.                                 write(2 /*stderr*/, &entry, sizeof(TraceEntry));
  70.                               }
  71.                               break;
  72.       case DISABLE_LOGGING  : traceFlag = 0;
  73.                               break;
  74.       case START_LOGGING    : 
  75.                               StartRecording();
  76.                               break;
  77.       case COMPLETE_LOGGING : 
  78.                   if (traceFlag)
  79.                   {
  80.                 gettimeofday(&entry.completionTime, 0);
  81.                 entry.operation     = SENDBACK; 
  82.                 entry.numberOfBytes = extraInteger;
  83.                 write(2 /*stderr*/, &entry, sizeof(TraceEntry));
  84.                   }
  85.                   numberOfTransfers++;
  86.                               break;
  87.       case CATCH_SIGKILL    : 
  88.                   if (traceFlag)
  89.                   {
  90.                 bzero(&entry, sizeof(TraceEntry));
  91.                 gettimeofday(&entry.initialTime, 0);
  92.                 entry.operation = INTERRUPT; 
  93.                 write(2 /*stderr*/, &entry, sizeof(TraceEntry));
  94.                   }
  95.                   numberOfTransfers++;
  96.                   break;
  97.     }
  98.   }
  99.