home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / srvtime / srvtime.c < prev    next >
C/C++ Source or Header  |  1989-01-05  |  2KB  |  58 lines

  1. /* Program to set the default file server time to the setting of the
  2.  *  attached workstation clock.  Written by Alan Marshall, Proteon
  3.  *  1/5/89.  The program is accurate to within about 2 seconds between
  4.  *  setting and login to the server.  The resolution seems to be in the
  5.  *  setting algorithm within the file server.  The program uses the
  6.  *  SNIT.LIB routine from the 1988 Developer's Conference programs but
  7.  *  requires a patch to the library file to change an instruction in the
  8.  *  SetFileServerDateAndTime routine to make the year part work with the
  9.  *  Advanced 2.11 server software.  This patch can be made with debug
  10.  *  by searching for the sequence: 80,C0,94.  At that instruction (in the
  11.  *  first segment) change the 94 to 00 and write out the lib file.
  12.  *   The exe file supplied with this C source has the patch made.  It can
  13.  *  be made to the exe file after linking with snit.lib.
  14.  *    Good luck!
  15.  *    -Al Marshall
  16.  */
  17.  
  18. #include <stdio.h>
  19. #include <dos.h>
  20. #include <time.h>
  21. #include <nit.h>
  22.  
  23. main()
  24. {
  25.     struct date today;
  26.     struct time now;
  27.  
  28.  
  29.     int tr_year;
  30.     char *str_now;
  31.     int ccode;
  32.     WORD year, month, day, hour, minute, second = 0;
  33.  
  34.     getdate(&today);
  35.     tr_year = today.da_year % 100;    /* truncate year to 2 digits */
  36.     gettime(&now);
  37.  
  38. /* now set the time in the default file server */
  39.     /* set words to values of current clock */
  40.     year = today.da_year % 100;
  41.     month = today.da_mon;
  42.     day = today.da_day;
  43.     hour = now.ti_hour;
  44.     minute = now.ti_min;
  45.     second = now.ti_sec;
  46.  
  47.  
  48.     ccode = SetFileServerDateAndTime (year, month, day, hour, minute, second);
  49.     if (ccode == 0)
  50.         {
  51.         printf ("Setting server time to:");
  52.     printf(" %02.2d/%02.2d/%02.2d",today.da_mon,today.da_day,tr_year);
  53.     printf(" %02.2d:%02.2d:%02.2d\n", now.ti_hour,now.ti_min,now.ti_sec);
  54.     }
  55.     else
  56.         printf("Operator class is not `CONSOLE', server time NOT set!");
  57. }
  58.