home *** CD-ROM | disk | FTP | other *** search
/ nisttime.carsoncity.k12.mi.us / nisttime.carsoncity.k12.mi.us.tar / nisttime.carsoncity.k12.mi.us / pub / lockclock / sett.c < prev    next >
C/C++ Source or Header  |  1996-11-18  |  879b  |  30 lines

  1. int sett(xx)
  2. double xx;
  3. {
  4. /*
  5.     this subroutine adjusts the time of the local clock
  6.     by xx seconds, where a positive value advances the
  7.     time and a negative value retards it. Unlike adjt
  8.     which changes the clock slowly, this subroutine changes
  9.     the time in one step.  It is intended to remove large
  10.     errors only and is used during startup and following
  11.     a large glitch.
  12.     Both calls to get the time and set it return a value
  13.     of 0 so that the return from this subroutine should
  14.     also be 0 if both calls were ok and -2 if both
  15.     failed.  If this subroutine is called with inadequate
  16.     root permissions, the first call will succeed and the
  17.     second will fail, so that the return status will be
  18.     -1.
  19. */
  20. #include <sys/time.h>
  21. #include "sizint.h"
  22. struct timeval tp;
  23. struct timezone tzp;
  24. int j;
  25.     j=gettimeofday(&tp,&tzp);
  26.     tp.tv_sec += (LONG) xx;
  27.     j += settimeofday(&tp,&tzp);
  28.     return(j);
  29. }
  30.