diff options
| author | Theodore Tso <tytso@mit.edu> | 1996-02-28 05:05:58 +0000 |
|---|---|---|
| committer | Theodore Tso <tytso@mit.edu> | 1996-02-28 05:05:58 +0000 |
| commit | 37657fbefc2c9f8ed59bd42ffabeec2f27a57f47 (patch) | |
| tree | 0f5069ddfdf155d1c964f481a325815ee40c2a9c | |
| parent | 20905e373121539ed798f3d1e5588363cfaca888 (diff) | |
| download | krb5-37657fbefc2c9f8ed59bd42ffabeec2f27a57f47.tar.gz krb5-37657fbefc2c9f8ed59bd42ffabeec2f27a57f47.tar.xz krb5-37657fbefc2c9f8ed59bd42ffabeec2f27a57f47.zip | |
Add Windows 95/NT time function. (Does this time function work under
Windows? We'll find out....)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7564 dc483132-0cff-0310-8789-dd5450dbe970
| -rw-r--r-- | src/lib/crypto/os/ChangeLog | 6 | ||||
| -rw-r--r-- | src/lib/crypto/os/c_ustime.c | 38 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/lib/crypto/os/ChangeLog b/src/lib/crypto/os/ChangeLog index 8190c36ef..d9bb87bbf 100644 --- a/src/lib/crypto/os/ChangeLog +++ b/src/lib/crypto/os/ChangeLog @@ -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. diff --git a/src/lib/crypto/os/c_ustime.c b/src/lib/crypto/os/c_ustime.c index 51c90767d..2adceaa33 100644 --- a/src/lib/crypto/os/c_ustime.c +++ b/src/lib/crypto/os/c_ustime.c @@ -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) |
