summaryrefslogtreecommitdiff
path: root/source4/lib/util
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2006-09-18 17:32:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:18:56 -0500
commitd630105b563aca913750200ea6e9ad17241ac51d (patch)
treeb74ecdd9874d5c6c356806920f7e7194af952f27 /source4/lib/util
parent57cd2235fa684f55bdeb075daf4b96cf1bf8c79d (diff)
downloadsamba-d630105b563aca913750200ea6e9ad17241ac51d.tar.gz
samba-d630105b563aca913750200ea6e9ad17241ac51d.tar.bz2
samba-d630105b563aca913750200ea6e9ad17241ac51d.zip
r18614: a bit of work done while on the plane.
a new function converting NTTIME to struct timeval rafal (This used to be commit e9ebbb8661ac6efc5bf07798a64cdb9f7c7eea50)
Diffstat (limited to 'source4/lib/util')
-rw-r--r--source4/lib/util/time.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source4/lib/util/time.c b/source4/lib/util/time.c
index 6ad3a229e3..d3cdecdfe3 100644
--- a/source4/lib/util/time.c
+++ b/source4/lib/util/time.c
@@ -566,6 +566,28 @@ _PUBLIC_ NTTIME timeval_to_nttime(const struct timeval *tv)
((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
********************************************************************/