home *** CD-ROM | disk | FTP | other *** search
/ nisttime.carsoncity.k12.mi.us / nisttime.carsoncity.k12.mi.us.tar / nisttime.carsoncity.k12.mi.us / pub / autolock / putmsg.c < prev    next >
C/C++ Source or Header  |  2003-12-09  |  638b  |  28 lines

  1. void putmsg(msg)
  2. char *msg;
  3. {
  4. /*
  5.     this subroutine is called if the autolock program finds
  6.     a problem.  it writes the text message contained in
  7.     msg. to the log file and returns.  
  8.     The subroutine returns if the lock file won't open.
  9. */
  10. #include <stdio.h>
  11. #include <sys/time.h>
  12. struct timeval tv;
  13. FILE *lop;
  14. int mjd;
  15. int secoday;
  16.     if( (lop=fopen("autolock.err","a+")) == NULL) return;
  17. /*
  18.     compute the current MJD and time and add them to the
  19.     message.
  20. */
  21.     gettimeofday(&tv,(struct timezone *) NULL);
  22.     mjd= tv.tv_sec/86400 + 40587;
  23.     secoday= tv.tv_sec%86400;
  24.     fprintf(lop,"\n %5d %5d",mjd,secoday);
  25.     fprintf(lop," %s",msg);
  26.     fclose(lop);
  27. }
  28.