svn commit: samba r18614 - in branches/SAMBA_4_0/source/lib/util: .

mimir at samba.org mimir at samba.org
Mon Sep 18 17:32:14 GMT 2006


Author: mimir
Date: 2006-09-18 17:32:13 +0000 (Mon, 18 Sep 2006)
New Revision: 18614

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18614

Log:
a bit of work done while on the plane.

a new function converting NTTIME to struct timeval


rafal


Modified:
   branches/SAMBA_4_0/source/lib/util/time.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/util/time.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/time.c	2006-09-18 15:20:33 UTC (rev 18613)
+++ branches/SAMBA_4_0/source/lib/util/time.c	2006-09-18 17:32:13 UTC (rev 18614)
@@ -566,6 +566,28 @@
 		  ((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000));
 }
 
+/**
+  convert a NTTIME to a timeval
+*/
+_PUBLIC_ void nttime_to_timeval(struct timeval *tv, NTTIME t)
+{
+	if (tv == NULL) return;
+
+	t += 10/2;
+	t /= 10;
+	t -= TIME_FIXUP_CONSTANT*1000*1000;
+
+	tv->tv_sec  = t / 1000000;
+
+	if (TIME_T_MIN > tv->tv_sec || tv->tv_sec > TIME_T_MAX) {
+		tv->tv_sec  = 0;
+		tv->tv_usec = 0;
+		return;
+	}
+	
+	tv->tv_usec = t - tv->tv_sec*1000000;
+}
+
 /*******************************************************************
 yield the difference between *A and *B, in seconds, ignoring leap seconds
 ********************************************************************/



More information about the samba-cvs mailing list