Hi,

Frederic, big thanks for your work on this, by a coincedence it's exactly what
i need at work :)

I'm compiling your branch on Debian GNU/Linux with mingw and having some minor
troubles worth mentioning and (i hope) fixing.

I configure with
CC=586-mingw32msvc-gcc ./configure --host=i586-mingw32msvc --prefix=/c/winnut/

Interestingly, there's scripts/Windows/Makefile in the repo but it gets
overwritten by the configure process.

Other minor tweaks i had to do (probably not the most correct way, but i know
just about nothing wrt windows programming):

>From 26ff6d7fb1ffc6421f1f36243ab9166b8544a9ab Mon Sep 17 00:00:00 2001
From: Paul Fertser <[email protected]>
Date: Thu, 16 Dec 2010 12:48:07 +0300
Subject: [PATCH] mingw32 cross-compilation tweaks

This adds defines for usleep (windows lacks that) and also missing
define for SVC_EVENT.
---
 clients/upsclient.h       |    4 ++++
 clients/upsmon.c          |    1 +
 clients/upssched.c        |    1 +
 drivers/main.h            |    1 +
 scripts/Windows/wininit.c |    1 +
 5 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/clients/upsclient.h b/clients/upsclient.h
index 6e23971..9edda90 100644
--- a/clients/upsclient.h
+++ b/clients/upsclient.h
@@ -25,6 +25,10 @@
 #include <openssl/ssl.h>
 #endif
 
+#ifdef WIN32
+#define usleep(n) Sleep(n / 1000)
+#endif
+
 #ifdef __cplusplus
 /* *INDENT-OFF* */
 extern "C" {
diff --git a/clients/upsmon.c b/clients/upsmon.c
index 0248617..ee11324 100644
--- a/clients/upsmon.c
+++ b/clients/upsmon.c
@@ -26,6 +26,7 @@
 #else
 #include <winsock2.h>
 #define sleep(n) Sleep(1000 * n)
+#define usleep(n) Sleep(n / 1000)
 #endif
 
 #include "upsclient.h"
diff --git a/clients/upssched.c b/clients/upssched.c
index 7daf1f9..73e9341 100644
--- a/clients/upssched.c
+++ b/clients/upssched.c
@@ -50,6 +50,7 @@
 #else
 #include <winsock2.h>
 #include <ws2tcpip.h>
+#define usleep(n) Sleep(n / 1000)
 #endif
 
 #include "upssched.h"
diff --git a/drivers/main.h b/drivers/main.h
index 882fe6a..a4ef221 100644
--- a/drivers/main.h
+++ b/drivers/main.h
@@ -8,6 +8,7 @@
 
 #ifdef WIN32
 #define sleep(a) Sleep(a*1000)
+#define usleep(n) Sleep(n / 1000)
 #define strtok_r(a,b,c) strtok(a,b)
 #endif
 
diff --git a/scripts/Windows/wininit.c b/scripts/Windows/wininit.c
index b4f136c..862699c 100644
--- a/scripts/Windows/wininit.c
+++ b/scripts/Windows/wininit.c
@@ -44,6 +44,7 @@ static BOOL                   service_flag = TRUE;
 HANDLE                         svc_stop = NULL;
 static SERVICE_STATUS          SvcStatus;
 static SERVICE_STATUS_HANDLE   SvcStatusHandle;
+#define SVC_EVENT                        ((DWORD)0xC0020001L)
 
 static void print_event(DWORD priority, const char * string)
 {
-- 
1.5.6.5

Thanks again and happy hacking :)

-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:[email protected]

_______________________________________________
Nut-upsdev mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev

Reply via email to