4 * Glue code for pasting Kerberos into the Unix environment.
6 * Originally written by John Gilmore, Cygnus Support, May '94.
9 * Required for use by the Cygnus krb.a.
19 unix_time_gmt_unixsec (usecptr)
24 (void) gettimeofday (&now, (struct timezone *)0);
26 *usecptr = now.tv_usec;
33 * Originally written by John Gilmore, Cygnus Support, May '94.
38 #include <sys/timeb.h>
43 * Due to the fact that DOS time can be unreliable we have reverted
44 * to using the AT hardware clock and converting it to Unix time.
46 static long win_time_get_epoch(void);
49 unix_time_gmt_unixsec (usecptr)
53 union _REGS inregs; /* For calling BIOS */
57 long convert; /* MSC 7.00 bug work around */
58 krb5_ui_4 retval; /* What we return */
60 _ftime(&now); /* Daylight savings time */
62 /* Get time from AT hardware clock INT 0x1A, AH=2 */
63 memset(&inregs, 0, sizeof(inregs));
65 _int86(0x1a, &inregs, &outregs);
67 /* 0x13 = decimal 13, hence the decoding below */
68 tm.tm_sec = 10 * ((outregs.h.dh & 0xF0) >> 4) + (outregs.h.dh & 0x0F);
69 tm.tm_min = 10 * ((outregs.h.cl & 0xF0) >> 4) + (outregs.h.cl & 0x0F);
70 tm.tm_hour = 10 * ((outregs.h.ch & 0xF0) >> 4) + (outregs.h.ch & 0x0F);
72 /* Get date from AT hardware clock INT 0x1A, AH=4 */
73 memset(&inregs, 0, sizeof(inregs));
75 _int86(0x1a, &inregs, &outregs);
77 tm.tm_mday = 10 * ((outregs.h.dl & 0xF0) >> 4) + (outregs.h.dl & 0x0F);
78 tm.tm_mon = 10 * ((outregs.h.dh & 0xF0) >> 4) + (outregs.h.dh & 0x0F) - 1;
79 tm.tm_year = 10 * ((outregs.h.cl & 0xF0) >> 4) + (outregs.h.cl & 0x0F);
80 tm.tm_year += 100 * ((10 * (outregs.h.ch & 0xF0) >> 4)
81 + (outregs.h.ch & 0x0F) - 19);
85 tm.tm_isdst = now.dstflag;
89 convert = win_time_get_epoch();
90 retval = time + convert;
98 * This routine figures out the current time epoch and returns the
99 * conversion factor. It exists because
100 * Microloss screwed the pooch on the time() and _ftime() calls in
101 * its release 7.0 libraries. They changed the epoch to Dec 31, 1899!
102 * Idiots... We try to cope.
105 static struct tm jan_1_70 = {0, 0, 0, 1, 0, 70};
106 static long epoch = 0;
107 static int epoch_set = 0;
114 epoch = 0 - mktime (&jan_1_70); /* Seconds til 1970 localtime */
115 epoch += _timezone; /* Seconds til 1970 GMT */