Back out 1.16.2.3:
[samba.git] / source3 / lib / time.c
1 /* 
2    Unix SMB/CIFS implementation.
3    time handling functions
4    Copyright (C) Andrew Tridgell 1992-1998
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22
23 /*
24   This stuff was largely rewritten by Paul Eggert <eggert@twinsun.com>
25   in May 1996 
26   */
27
28
29 int extra_time_offset = 0;
30
31 #ifndef CHAR_BIT
32 #define CHAR_BIT 8
33 #endif
34
35 #ifndef TIME_T_MIN
36 #define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \
37                     : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
38 #endif
39 #ifndef TIME_T_MAX
40 #define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
41 #endif
42
43 /*******************************************************************
44  External access to time_t_min and time_t_max.
45 ********************************************************************/
46
47 time_t get_time_t_min(void)
48 {
49         return TIME_T_MIN;
50 }
51
52 time_t get_time_t_max(void)
53 {
54         return TIME_T_MAX;
55 }
56
57 /*******************************************************************
58 a gettimeofday wrapper
59 ********************************************************************/
60 void GetTimeOfDay(struct timeval *tval)
61 {
62 #ifdef HAVE_GETTIMEOFDAY_TZ
63         gettimeofday(tval,NULL);
64 #else
65         gettimeofday(tval);
66 #endif
67 }
68
69 #define TM_YEAR_BASE 1900
70
71 /*******************************************************************
72 yield the difference between *A and *B, in seconds, ignoring leap seconds
73 ********************************************************************/
74 static int tm_diff(struct tm *a, struct tm *b)
75 {
76   int ay = a->tm_year + (TM_YEAR_BASE - 1);
77   int by = b->tm_year + (TM_YEAR_BASE - 1);
78   int intervening_leap_days =
79     (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
80   int years = ay - by;
81   int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
82   int hours = 24*days + (a->tm_hour - b->tm_hour);
83   int minutes = 60*hours + (a->tm_min - b->tm_min);
84   int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
85
86   return seconds;
87 }
88
89 /*******************************************************************
90   return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
91   ******************************************************************/
92 static int TimeZone(time_t t)
93 {
94   struct tm *tm = gmtime(&t);
95   struct tm tm_utc;
96   if (!tm)
97     return 0;
98   tm_utc = *tm;
99   tm = localtime(&t);
100   if (!tm)
101     return 0;
102   return tm_diff(&tm_utc,tm);
103
104 }
105
106 static BOOL done_serverzone_init;
107
108 /* Return the smb serverzone value */
109
110 static int get_serverzone(void)
111 {
112         static int serverzone;
113
114         if (!done_serverzone_init) {
115                 serverzone = TimeZone(time(NULL));
116
117                 if ((serverzone % 60) != 0) {
118                         DEBUG(1,("WARNING: Your timezone is not a multiple of 1 minute.\n"));
119                 }
120
121                 DEBUG(4,("Serverzone is %d\n",serverzone));
122
123                 done_serverzone_init = True;
124         }
125
126         return serverzone;
127 }
128
129 /* Re-read the smb serverzone value */
130
131 static struct timeval start_time_hires;
132
133 void TimeInit(void)
134 {
135         done_serverzone_init = False;
136         get_serverzone();
137         /* Save the start time of this process. */
138         if (start_time_hires.tv_sec == 0 && start_time_hires.tv_usec == 0)
139                 GetTimeOfDay(&start_time_hires);
140 }
141
142 /**********************************************************************
143  Return a timeval struct of the uptime of this process. As TimeInit is
144  done before a daemon fork then this is the start time from the parent
145  daemon start. JRA.
146 ***********************************************************************/
147
148 void get_process_uptime(struct timeval *ret_time)
149 {
150         struct timeval time_now_hires;
151
152         GetTimeOfDay(&time_now_hires);
153         ret_time->tv_sec = time_now_hires.tv_sec - start_time_hires.tv_sec;
154         ret_time->tv_usec = time_now_hires.tv_usec - start_time_hires.tv_usec;
155         if (time_now_hires.tv_usec < start_time_hires.tv_usec) {
156                 ret_time->tv_sec -= 1;
157                 ret_time->tv_usec = 1000000 + (time_now_hires.tv_usec - start_time_hires.tv_usec);
158         } else
159                 ret_time->tv_usec = time_now_hires.tv_usec - start_time_hires.tv_usec;
160 }
161
162 /*******************************************************************
163 return the same value as TimeZone, but it should be more efficient.
164
165 We keep a table of DST offsets to prevent calling localtime() on each 
166 call of this function. This saves a LOT of time on many unixes.
167
168 Updated by Paul Eggert <eggert@twinsun.com>
169 ********************************************************************/
170 static int TimeZoneFaster(time_t t)
171 {
172   static struct dst_table {time_t start,end; int zone;} *tdt, *dst_table = NULL;
173   static int table_size = 0;
174   int i;
175   int zone = 0;
176
177   if (t == 0) t = time(NULL);
178
179   /* Tunis has a 8 day DST region, we need to be careful ... */
180 #define MAX_DST_WIDTH (365*24*60*60)
181 #define MAX_DST_SKIP (7*24*60*60)
182
183   for (i=0;i<table_size;i++)
184     if (t >= dst_table[i].start && t <= dst_table[i].end) break;
185
186   if (i<table_size) {
187     zone = dst_table[i].zone;
188   } else {
189     time_t low,high;
190
191     zone = TimeZone(t);
192     tdt = (struct dst_table *)Realloc(dst_table,
193                                               sizeof(dst_table[0])*(i+1));
194     if (!tdt) {
195       DEBUG(0,("TimeZoneFaster: out of memory!\n"));
196       SAFE_FREE(dst_table);
197       table_size = 0;
198     } else {
199       dst_table = tdt;
200       table_size++;
201
202       dst_table[i].zone = zone; 
203       dst_table[i].start = dst_table[i].end = t;
204     
205       /* no entry will cover more than 6 months */
206       low = t - MAX_DST_WIDTH/2;
207       if (t < low)
208         low = TIME_T_MIN;
209       
210       high = t + MAX_DST_WIDTH/2;
211       if (high < t)
212         high = TIME_T_MAX;
213       
214       /* widen the new entry using two bisection searches */
215       while (low+60*60 < dst_table[i].start) {
216         if (dst_table[i].start - low > MAX_DST_SKIP*2)
217           t = dst_table[i].start - MAX_DST_SKIP;
218         else
219           t = low + (dst_table[i].start-low)/2;
220         if (TimeZone(t) == zone)
221           dst_table[i].start = t;
222         else
223           low = t;
224       }
225
226       while (high-60*60 > dst_table[i].end) {
227         if (high - dst_table[i].end > MAX_DST_SKIP*2)
228           t = dst_table[i].end + MAX_DST_SKIP;
229         else
230           t = high - (high-dst_table[i].end)/2;
231         if (TimeZone(t) == zone)
232           dst_table[i].end = t;
233         else
234           high = t;
235       }
236 #if 0
237       DEBUG(1,("Added DST entry from %s ",
238                asctime(localtime(&dst_table[i].start))));
239       DEBUG(1,("to %s (%d)\n",asctime(localtime(&dst_table[i].end)),
240                dst_table[i].zone));
241 #endif
242     }
243   }
244   return zone;
245 }
246
247 /****************************************************************************
248   return the UTC offset in seconds west of UTC, adjusted for extra time offset
249   **************************************************************************/
250 int TimeDiff(time_t t)
251 {
252   return TimeZoneFaster(t) + 60*extra_time_offset;
253 }
254
255
256 /****************************************************************************
257   return the UTC offset in seconds west of UTC, adjusted for extra time
258   offset, for a local time value.  If ut = lt + LocTimeDiff(lt), then
259   lt = ut - TimeDiff(ut), but the converse does not necessarily hold near
260   daylight savings transitions because some local times are ambiguous.
261   LocTimeDiff(t) equals TimeDiff(t) except near daylight savings transitions.
262   +**************************************************************************/
263 static int LocTimeDiff(time_t lte)
264 {
265   time_t lt = lte - 60*extra_time_offset;
266   int d = TimeZoneFaster(lt);
267   time_t t = lt + d;
268
269   /* if overflow occurred, ignore all the adjustments so far */
270   if (((lte < lt) ^ (extra_time_offset < 0))  |  ((t < lt) ^ (d < 0)))
271     t = lte;
272
273   /* now t should be close enough to the true UTC to yield the right answer */
274   return TimeDiff(t);
275 }
276
277
278 /****************************************************************************
279 try to optimise the localtime call, it can be quite expensive on some machines
280 ****************************************************************************/
281 struct tm *LocalTime(time_t *t)
282 {
283   time_t t2 = *t;
284
285   t2 -= TimeDiff(t2);
286
287   return(gmtime(&t2));
288 }
289
290 #define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
291
292 /****************************************************************************
293 interpret an 8 byte "filetime" structure to a time_t
294 It's originally in "100ns units since jan 1st 1601"
295
296 It appears to be kludge-GMT (at least for file listings). This means
297 its the GMT you get by taking a localtime and adding the
298 serverzone. This is NOT the same as GMT in some cases. This routine
299 converts this to real GMT.
300 ****************************************************************************/
301 time_t nt_time_to_unix(NTTIME *nt)
302 {
303   double d;
304   time_t ret;
305   /* The next two lines are a fix needed for the 
306      broken SCO compiler. JRA. */
307   time_t l_time_min = TIME_T_MIN;
308   time_t l_time_max = TIME_T_MAX;
309
310   if (nt->high == 0) return(0);
311
312   d = ((double)nt->high)*4.0*(double)(1<<30);
313   d += (nt->low&0xFFF00000);
314   d *= 1.0e-7;
315  
316   /* now adjust by 369 years to make the secs since 1970 */
317   d -= TIME_FIXUP_CONSTANT;
318
319   if (!(l_time_min <= d && d <= l_time_max))
320     return(0);
321
322   ret = (time_t)(d+0.5);
323
324   /* this takes us from kludge-GMT to real GMT */
325   ret -= get_serverzone();
326   ret += LocTimeDiff(ret);
327
328   return(ret);
329 }
330
331 /****************************************************************************
332 convert a NTTIME structure to a time_t
333 It's originally in "100ns units"
334
335 this is an absolute version of the one above.
336 By absolute I mean, it doesn't adjust from 1/1/1601 to 1/1/1970
337 if the NTTIME was 5 seconds, the time_t is 5 seconds. JFM
338 ****************************************************************************/
339 time_t nt_time_to_unix_abs(NTTIME *nt)
340 {
341         double d;
342         time_t ret;
343         /* The next two lines are a fix needed for the 
344            broken SCO compiler. JRA. */
345         time_t l_time_min = TIME_T_MIN;
346         time_t l_time_max = TIME_T_MAX;
347
348         if (nt->high == 0)
349                 return(0);
350
351         if (nt->high==0x80000000 && nt->low==0)
352                 return -1;
353
354         /* reverse the time */
355         /* it's a negative value, turn it to positive */
356         nt->high=~nt->high;
357         nt->low=~nt->low;
358
359         d = ((double)nt->high)*4.0*(double)(1<<30);
360         d += (nt->low&0xFFF00000);
361         d *= 1.0e-7;
362   
363         if (!(l_time_min <= d && d <= l_time_max))
364                 return(0);
365
366         ret = (time_t)(d+0.5);
367
368         /* this takes us from kludge-GMT to real GMT */
369         ret -= get_serverzone();
370         ret += LocTimeDiff(ret);
371
372         return(ret);
373 }
374
375
376
377 /****************************************************************************
378 interprets an nt time into a unix time_t
379 ****************************************************************************/
380 time_t interpret_long_date(char *p)
381 {
382         NTTIME nt;
383         nt.low = IVAL(p,0);
384         nt.high = IVAL(p,4);
385         return nt_time_to_unix(&nt);
386 }
387
388 /****************************************************************************
389 put a 8 byte filetime from a time_t
390 This takes real GMT as input and converts to kludge-GMT
391 ****************************************************************************/
392 void unix_to_nt_time(NTTIME *nt, time_t t)
393 {
394         double d;
395
396         if (t==0)
397         {
398                 nt->low = 0;
399                 nt->high = 0;
400                 return;
401         }
402         if (t == TIME_T_MAX)
403         {
404                 nt->low = 0xffffffff;
405                 nt->high = 0x7fffffff;
406                 return;
407         }               
408         if (t == -1)
409         {
410                 nt->low = 0xffffffff;
411                 nt->high = 0xffffffff;
412                 return;
413         }               
414
415         /* this converts GMT to kludge-GMT */
416         t -= LocTimeDiff(t) - get_serverzone(); 
417
418         d = (double)(t);
419         d += TIME_FIXUP_CONSTANT;
420         d *= 1.0e7;
421
422         nt->high = (uint32)(d * (1.0/(4.0*(double)(1<<30))));
423         nt->low  = (uint32)(d - ((double)nt->high)*4.0*(double)(1<<30));
424 }
425
426 /****************************************************************************
427 convert a time_t to a NTTIME structure
428
429 this is an absolute version of the one above.
430 By absolute I mean, it doesn't adjust from 1/1/1970 to 1/1/1601
431 if the nttime_t was 5 seconds, the NTTIME is 5 seconds. JFM
432 ****************************************************************************/
433 void unix_to_nt_time_abs(NTTIME *nt, time_t t)
434 {
435         double d;
436
437         if (t==0) {
438                 nt->low = 0;
439                 nt->high = 0;
440                 return;
441         }
442
443         if (t == TIME_T_MAX) {
444                 nt->low = 0xffffffff;
445                 nt->high = 0x7fffffff;
446                 return;
447         }
448                 
449         if (t == -1) {
450                 /* that's what NT uses for infinite */
451                 nt->low = 0x0;
452                 nt->high = 0x80000000;
453                 return;
454         }               
455
456         /* this converts GMT to kludge-GMT */
457         t -= LocTimeDiff(t) - get_serverzone(); 
458
459         d = (double)(t);
460         d *= 1.0e7;
461
462         nt->high = (uint32)(d * (1.0/(4.0*(double)(1<<30))));
463         nt->low  = (uint32)(d - ((double)nt->high)*4.0*(double)(1<<30));
464
465         /* convert to a negative value */
466         nt->high=~nt->high;
467         nt->low=~nt->low;
468 }
469
470
471 /****************************************************************************
472 take an NTTIME structure, containing high / low time.  convert to unix time.
473 lkclXXXX this may need 2 SIVALs not a memcpy.  we'll see...
474 ****************************************************************************/
475 void put_long_date(char *p,time_t t)
476 {
477         NTTIME nt;
478         unix_to_nt_time(&nt, t);
479         SIVAL(p, 0, nt.low);
480         SIVAL(p, 4, nt.high);
481 }
482
483 /****************************************************************************
484 check if it's a null mtime
485 ****************************************************************************/
486 BOOL null_mtime(time_t mtime)
487 {
488   if (mtime == 0 || mtime == 0xFFFFFFFF || mtime == (time_t)-1)
489     return(True);
490   return(False);
491 }
492
493 /*******************************************************************
494   create a 16 bit dos packed date
495 ********************************************************************/
496 static uint16 make_dos_date1(struct tm *t)
497 {
498   uint16 ret=0;
499   ret = (((unsigned)(t->tm_mon+1)) >> 3) | ((t->tm_year-80) << 1);
500   ret = ((ret&0xFF)<<8) | (t->tm_mday | (((t->tm_mon+1) & 0x7) << 5));
501   return(ret);
502 }
503
504 /*******************************************************************
505   create a 16 bit dos packed time
506 ********************************************************************/
507 static uint16 make_dos_time1(struct tm *t)
508 {
509   uint16 ret=0;
510   ret = ((((unsigned)t->tm_min >> 3)&0x7) | (((unsigned)t->tm_hour) << 3));
511   ret = ((ret&0xFF)<<8) | ((t->tm_sec/2) | ((t->tm_min & 0x7) << 5));
512   return(ret);
513 }
514
515 /*******************************************************************
516   create a 32 bit dos packed date/time from some parameters
517   This takes a GMT time and returns a packed localtime structure
518 ********************************************************************/
519 static uint32 make_dos_date(time_t unixdate)
520 {
521   struct tm *t;
522   uint32 ret=0;
523
524   t = LocalTime(&unixdate);
525   if (!t)
526     return 0xFFFFFFFF;
527
528   ret = make_dos_date1(t);
529   ret = ((ret&0xFFFF)<<16) | make_dos_time1(t);
530
531   return(ret);
532 }
533
534 /*******************************************************************
535 put a dos date into a buffer (time/date format)
536 This takes GMT time and puts local time in the buffer
537 ********************************************************************/
538 void put_dos_date(char *buf,int offset,time_t unixdate)
539 {
540   uint32 x = make_dos_date(unixdate);
541   SIVAL(buf,offset,x);
542 }
543
544 /*******************************************************************
545 put a dos date into a buffer (date/time format)
546 This takes GMT time and puts local time in the buffer
547 ********************************************************************/
548 void put_dos_date2(char *buf,int offset,time_t unixdate)
549 {
550   uint32 x = make_dos_date(unixdate);
551   x = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
552   SIVAL(buf,offset,x);
553 }
554
555 /*******************************************************************
556 put a dos 32 bit "unix like" date into a buffer. This routine takes
557 GMT and converts it to LOCAL time before putting it (most SMBs assume
558 localtime for this sort of date)
559 ********************************************************************/
560 void put_dos_date3(char *buf,int offset,time_t unixdate)
561 {
562   if (!null_mtime(unixdate))
563     unixdate -= TimeDiff(unixdate);
564   SIVAL(buf,offset,unixdate);
565 }
566
567 /*******************************************************************
568   interpret a 32 bit dos packed date/time to some parameters
569 ********************************************************************/
570 static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *hour,int *minute,int *second)
571 {
572   uint32 p0,p1,p2,p3;
573
574   p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF; 
575   p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
576
577   *second = 2*(p0 & 0x1F);
578   *minute = ((p0>>5)&0xFF) + ((p1&0x7)<<3);
579   *hour = (p1>>3)&0xFF;
580   *day = (p2&0x1F);
581   *month = ((p2>>5)&0xFF) + ((p3&0x1)<<3) - 1;
582   *year = ((p3>>1)&0xFF) + 80;
583 }
584
585 /*******************************************************************
586   create a unix date (int GMT) from a dos date (which is actually in
587   localtime)
588 ********************************************************************/
589 time_t make_unix_date(void *date_ptr)
590 {
591   uint32 dos_date=0;
592   struct tm t;
593   time_t ret;
594
595   dos_date = IVAL(date_ptr,0);
596
597   if (dos_date == 0) return(0);
598   
599   interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
600                      &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
601   t.tm_isdst = -1;
602   
603   /* mktime() also does the local to GMT time conversion for us */
604   ret = mktime(&t);
605
606   return(ret);
607 }
608
609 /*******************************************************************
610 like make_unix_date() but the words are reversed
611 ********************************************************************/
612 time_t make_unix_date2(void *date_ptr)
613 {
614   uint32 x,x2;
615
616   x = IVAL(date_ptr,0);
617   x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
618   SIVAL(&x,0,x2);
619
620   return(make_unix_date((void *)&x));
621 }
622
623 /*******************************************************************
624   create a unix GMT date from a dos date in 32 bit "unix like" format
625   these generally arrive as localtimes, with corresponding DST
626   ******************************************************************/
627 time_t make_unix_date3(void *date_ptr)
628 {
629   time_t t = (time_t)IVAL(date_ptr,0);
630   if (!null_mtime(t))
631     t += LocTimeDiff(t);
632   return(t);
633 }
634
635
636 /***************************************************************************
637 return a HTTP/1.0 time string
638   ***************************************************************************/
639 char *http_timestring(time_t t)
640 {
641   static fstring buf;
642   struct tm *tm = LocalTime(&t);
643
644   if (!tm)
645     slprintf(buf,sizeof(buf)-1,"%ld seconds since the Epoch",(long)t);
646   else
647 #ifndef HAVE_STRFTIME
648   fstrcpy(buf, asctime(tm));
649   if(buf[strlen(buf)-1] == '\n')
650     buf[strlen(buf)-1] = 0;
651 #else /* !HAVE_STRFTIME */
652   strftime(buf, sizeof(buf)-1, "%a, %d %b %Y %H:%M:%S %Z", tm);
653 #endif /* !HAVE_STRFTIME */
654   return buf;
655 }
656
657
658
659 /****************************************************************************
660  Return the date and time as a string
661 ****************************************************************************/
662
663 char *timestring(BOOL hires)
664 {
665         static fstring TimeBuf;
666         struct timeval tp;
667         time_t t;
668         struct tm *tm;
669
670         if (hires) {
671                 GetTimeOfDay(&tp);
672                 t = (time_t)tp.tv_sec;
673         } else {
674                 t = time(NULL);
675         }
676         tm = LocalTime(&t);
677         if (!tm) {
678                 if (hires) {
679                         slprintf(TimeBuf,
680                                  sizeof(TimeBuf)-1,
681                                  "%ld.%06ld seconds since the Epoch",
682                                  (long)tp.tv_sec, 
683                                  (long)tp.tv_usec);
684                 } else {
685                         slprintf(TimeBuf,
686                                  sizeof(TimeBuf)-1,
687                                  "%ld seconds since the Epoch",
688                                  (long)t);
689                 }
690         } else {
691 #ifdef HAVE_STRFTIME
692                 if (hires) {
693                         strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm);
694                         slprintf(TimeBuf+strlen(TimeBuf),
695                                  sizeof(TimeBuf)-1 - strlen(TimeBuf), 
696                                  ".%06ld", 
697                                  (long)tp.tv_usec);
698                 } else {
699                         strftime(TimeBuf,100,"%Y/%m/%d %H:%M:%S",tm);
700                 }
701 #else
702                 if (hires) {
703                         slprintf(TimeBuf, 
704                                  sizeof(TimeBuf)-1, 
705                                  "%s.%06ld", 
706                                  asctime(tm), 
707                                  (long)tp.tv_usec);
708                 } else {
709                         fstrcpy(TimeBuf, asctime(tm));
710                 }
711 #endif
712         }
713         return(TimeBuf);
714 }
715
716 /****************************************************************************
717   return the best approximation to a 'create time' under UNIX from a stat
718   structure.
719 ****************************************************************************/
720
721 time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs)
722 {
723   time_t ret, ret1;
724
725   if(S_ISDIR(st->st_mode) && fake_dirs)
726     return (time_t)315493200L;          /* 1/1/1980 */
727     
728   ret = MIN(st->st_ctime, st->st_mtime);
729   ret1 = MIN(ret, st->st_atime);
730
731   if(ret1 != (time_t)0)
732     return ret1;
733
734   /*
735    * One of ctime, mtime or atime was zero (probably atime).
736    * Just return MIN(ctime, mtime).
737    */
738   return ret;
739 }
740
741 /****************************************************************************
742 initialise an NTTIME to -1, which means "unknown" or "don't expire"
743 ****************************************************************************/
744
745 void init_nt_time(NTTIME *nt)
746 {
747         nt->high = 0x7FFFFFFF;
748         nt->low = 0xFFFFFFFF;
749 }