dbus/tools dbus-monitor.c,1.19,1.20

Ralf Habacker rhabacker at kemper.freedesktop.org
Sun Dec 31 04:20:56 PST 2006


Update of /cvs/dbus/dbus/tools
In directory kemper:/tmp/cvs-serv22588/tools

Modified Files:
	dbus-monitor.c 
Log Message:
* tools/dbus-monitor.c: gettimeofday() is not available 
on windows so we have to provide our own. It's taken from 
lgpl'd kdewin32 package. - Patches from Christian Ehrlicher

Index: dbus-monitor.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-monitor.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- dbus-monitor.c	31 Dec 2006 11:31:12 -0000	1.19
+++ dbus-monitor.c	31 Dec 2006 12:20:54 -0000	1.20
@@ -24,13 +24,42 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef DBUS_WIN
+#include <winsock2.h>
+#undef interface
+#else
 #include <sys/time.h>
+#endif
+
 #include <time.h>
 
 #include <signal.h>
 
 #include "dbus-print-message.h"
 
+#ifdef DBUS_WIN
+
+/* gettimeofday is not defined on windows */
+#define DBUS_SECONDS_SINCE_1601 11644473600LL
+#define DBUS_USEC_IN_SEC        1000000LL
+
+static 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) % DBUS_USEC_IN_SEC);
+  __p->tv_sec  = (long)(((now.ns100 / 10LL) / DBUS_SECONDS_SINCE_1601) - DBUS_SECONDS_SINCE_1601);
+
+  return 0;
+}
+#endif
+
 static DBusHandlerResult
 monitor_filter_func (DBusConnection     *connection,
 		     DBusMessage        *message,



More information about the dbus-commit mailing list