aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-12-01 16:57:49 +0100
committerAndreas Schneider <mail@cynapses.org>2009-12-01 16:57:49 +0100
commitf83f837de7ca51306a538e6b5185d231193a30f0 (patch)
tree00f96b63fbdc92979873119577e366558e42bc5c
parent48b719cf68db72f77a650e235ffa87bdd925ed6b (diff)
downloadlibssh-f83f837de7ca51306a538e6b5185d231193a30f0.tar.gz
libssh-f83f837de7ca51306a538e6b5185d231193a30f0.tar.xz
libssh-f83f837de7ca51306a538e6b5185d231193a30f0.zip
Added gettimeofday for Windows.
Thanks to Patrick Spendrin.
-rw-r--r--include/libssh/priv.h5
-rw-r--r--libssh/misc.c16
-rw-r--r--libssh/pcap.c2
3 files changed, 23 insertions, 0 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 97500fd4..d86c0d96 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -203,6 +203,11 @@ int match_hostname(const char *host, const char *pattern, unsigned int len);
int message_handle(ssh_session session, void *user, uint8_t type, ssh_buffer packet);
/* log.c */
+/* misc.c */
+#ifdef _WIN32
+int gettimeofday(struct timeval *__p, void *__t);
+#endif /* _WIN32 */
+
#ifndef __FUNCTION__
#if defined(__SUNPRO_C)
#define __FUNCTION__ __func__
diff --git a/libssh/misc.c b/libssh/misc.c
index 63ba9465..f2bd5edf 100644
--- a/libssh/misc.c
+++ b/libssh/misc.c
@@ -95,6 +95,22 @@ char *ssh_get_user_home_dir(void) {
return 1;
}
+
+#define SSH_USEC_IN_SEC 1000000LL
+#define SSH_SECONDS_SINCE_1601 11644473600LL
+
+int gettimeofday(struct timeval *__p, void *__t) {
+ union {
+ unsigned long long ns100; /* time since 1 Jan 1601 in 100ns units */
+ FILETIME ft;
+ } now;
+
+ GetSystemTimeAsFileTime (&now.ft);
+ __p->tv_usec = (long) ((now.ns100 / 10LL) % SSH_USEC_IN_SEC);
+ __p->tv_sec = (long)(((now.ns100 / 10LL ) / SSH_USEC_IN_SEC) - SSH_SECONDS_SINCE_1601);
+
+ return (0);
+}
#else /* _WIN32 */
char *ssh_get_user_home_dir(void) {
char *szPath = NULL;
diff --git a/libssh/pcap.c b/libssh/pcap.c
index c7cff7de..a9b00539 100644
--- a/libssh/pcap.c
+++ b/libssh/pcap.c
@@ -30,8 +30,10 @@
#ifdef WITH_PCAP
#include <stdio.h>
+#ifndef _WIN32
#include <sys/time.h>
#include <sys/socket.h>
+#endif
#include <errno.h>