Add Windows 95/NT time function. (Does this time function work under
authorTheodore Tso <tytso@mit.edu>
Wed, 28 Feb 1996 05:05:58 +0000 (05:05 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 28 Feb 1996 05:05:58 +0000 (05:05 +0000)
Windows?  We'll find out....)

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7564 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/os/ChangeLog
src/lib/crypto/os/c_ustime.c

index 8190c36ef8b0d40f22769b70f3f331620d112f06..d9bb87bbf46e8b5d18b03df2a8e31fe602147eb0 100644 (file)
@@ -1,3 +1,9 @@
+Sat Feb 24 00:34:15 1996  Theodore Y. Ts'o  <tytso@dcl>
+
+       * c_ustime.c (krb5_crypto_us_timeofday): Add Windows 95/NT time
+               function.  (Does this time function work under Windows?
+               We'll find out....)
+
 Thu Feb 15 10:57:27 1996  Ezra Peisach  <epeisach@kangaroo.mit.edu>
 
        * c_localaddr.c: Set magic number in krb5_address.
index 51c90767d771452a9ac634bb237af5ae5c6424d7..2adceaa3389c9ff6fd46b43c51d5514b1ba33e87 100644 (file)
@@ -121,6 +121,44 @@ krb5_crypto_us_timeofday(seconds, microseconds)
 }
 
 
+#elif defined(WIN32) || defined(_WINDOWS)
+
+   /* Microsoft Windows NT and 95   (32bit)  */
+   /* This one works for WOW (Windows on Windows, ntvdm on Win-NT) */
+
+#include <time.h>
+#include <sys/timeb.h>
+#include <string.h>
+
+krb5_error_code
+krb5_crypto_us_timeofday(seconds, microseconds)
+register krb5_int32 *seconds, *microseconds;
+{
+    struct _timeb timeptr;
+    krb5_int32 sec, usec;
+    static krb5_int32 last_sec = 0;
+    static krb5_int32 last_usec = 0;
+
+    _ftime(&timeptr);                           /* Get the current time */
+    sec  = timeptr.time;
+    usec = timeptr.millitm;
+
+    if (sec == last_sec) {                      /* Same as last time??? */
+        usec = ++last_usec;                     /* Yep, so do microseconds */
+        if (usec >= 1000000) {
+            ++sec;
+            usec = 0;
+        }
+    }
+    last_sec = sec;                             /* Remember for next time */
+    last_usec = usec;
+
+    *seconds = sec;                             /* Return the values */
+    *microseconds = usec;
+
+    return 0;
+}
+
 #elif defined (_MSDOS)