--- backend/abaton.c	2007-10-26 09:56:37 -0500
+++ backend/abaton.c	2009-01-12 18:23:47 -0600
@@ -59,7 +59,9 @@
 
 #include <sys/time.h>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/wait.h>
+#endif
 
 #include "sane/sane.h"
 #include "sane/sanei.h"
--- backend/agfafocus.c	2008-02-03 19:20:01 -0600
+++ backend/agfafocus.c	2009-01-13 08:57:10 -0600
@@ -31,6 +31,10 @@
 #include <string.h>
 #include <sys/types.h>
 
+#ifdef WIN32
+#include <windows.h>
+#endif
+
 #include "sane/sane.h"
 #include "sane/sanei.h"
 #include "sane/sanei_config.h"
@@ -352,7 +356,17 @@
 	  else if (left < 200)
 	    usleep (left * 5000);
 	  else
+#ifdef WIN32
+               {
+            HANDLE Handle;
+            if ( ( Handle = CreateSemaphore( NULL, 0, 2, NULL ) ) != NULL ) {
+               WaitForSingleObject( Handle, ( left * 1000000 ) / 200 );
+               CloseHandle( Handle );
+            }
+          }
+#else
 	    sleep (left / 200);
+#endif
 	}
     }
 
@@ -1791,22 +1805,30 @@
   int i;
   sigset_t sigterm_set;
   sigset_t ignore_set;
+#ifndef WIN32
   struct SIGACTION act;
+#endif
 
   if (sanei_thread_is_forked()) close (s->pipe);
 
   sigfillset (&ignore_set);
+#ifndef WIN32
   sigdelset (&ignore_set, SIGTERM);
+#endif
 #if defined (__APPLE__) && defined (__MACH__)
   sigdelset (&ignore_set, SIGUSR2);
 #endif
   sigprocmask (SIG_SETMASK, &ignore_set, 0);
 
+#ifndef WIN32
   memset (&act, 0, sizeof (act));
   sigaction (SIGTERM, &act, 0);
+#endif
 
   sigemptyset (&sigterm_set);
+#ifndef WIN32
   sigaddset (&sigterm_set, SIGTERM);
+#endif
 
   if (!s->hw->disconnect)
     wait_ready (s->fd);
@@ -2002,7 +2024,9 @@
 	}
     }
 
+#ifndef WIN32
   if (pipe (fds) < 0)
+#endif
     return SANE_STATUS_IO_ERROR;
 
   s->pipe = fds[0];
@@ -2065,7 +2089,9 @@
   if (!s->scanning)
     return SANE_STATUS_INVAL;
 
+#ifndef WIN32
   if (fcntl (s->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0)
+#endif
     return SANE_STATUS_IO_ERROR;
 
   return SANE_STATUS_GOOD;
--- backend/apple.c	2007-10-26 09:56:37 -0500
+++ backend/apple.c	2009-01-13 08:58:50 -0600
@@ -57,7 +57,9 @@
 
 #include <sys/time.h>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/wait.h>
+#endif
 
 #include "sane/sane.h"
 #include "sane/sanei.h"
--- backend/artec.c	2007-10-26 09:56:37 -0500
+++ backend/artec.c	2009-01-13 09:01:27 -0600
@@ -629,7 +629,11 @@
 
       if (status == SANE_STATUS_DEVICE_BUSY)
 	{
+#ifdef WIN32
+          usleep(999999);
+#else
 	  sleep (1);
+#endif
 	  continue;
 	}
 
--- backend/artec_eplus48u.c	2007-11-18 04:59:17 -0600
+++ backend/artec_eplus48u.c	2009-01-13 10:05:47 -0600
@@ -85,7 +85,9 @@
 #include <sys/time.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/ioctl.h>
+#endif
 
 
 #include "../include/sane/sane.h"
@@ -3394,7 +3396,9 @@
   int fd = s->reader_pipe;
 
   SANE_Status status;
+#ifndef WIN32
   struct SIGACTION act;
+#endif
   sigset_t ignore_set;
   ssize_t bytes_written = 0;
 
@@ -3403,13 +3407,16 @@
   if (sanei_thread_is_forked()) close (s->pipe);
 
   sigfillset (&ignore_set);
+#ifndef WIN32
   sigdelset (&ignore_set, SIGTERM);
   sigdelset (&ignore_set, SIGUSR1);
+#endif
 #if defined (__APPLE__) && defined (__MACH__)
   sigdelset (&ignore_set, SIGUSR2);
 #endif
   sigprocmask (SIG_SETMASK, &ignore_set, 0);
 
+#ifndef WIN32
   memset (&act, 0, sizeof (act));
   sigaction (SIGTERM, &act, 0);
   sigaction (SIGUSR1, &act, 0);
@@ -3430,6 +3437,7 @@
 
   XDBG ((2, "(child) reader_process: s=%p, fd=%d\n", (void *) s, fd));
 
+#endif 
   /*read line by line into buffer */
   /*copy buffer pointers to line_buffer */
   XDBG ((2, "(child) reader_process: byte_cnt %d\n", (int) s->byte_cnt));
@@ -3477,7 +3485,9 @@
 static SANE_Status
 do_cancel (Artec48U_Scanner * s, SANE_Bool closepipe)
 {
+#ifndef WIN32
   struct SIGACTION act;
+#endif
   pid_t res;
   XDBG ((1, "do_cancel\n"));
 
@@ -3487,6 +3497,7 @@
     {
       /*parent */
       XDBG ((1, "killing reader_process\n"));
+#ifndef WIN32
       /* tell the driver to stop scanning */
       sigemptyset (&(act.sa_mask));
       act.sa_flags = 0;
@@ -3502,6 +3513,7 @@
 	XDBG ((1, "sanei_thread_kill() failed !\n"));
       res = sanei_thread_waitpid (s->reader_pid, 0);
       alarm (0);
+#endif
 
       if (res != s->reader_pid)
 	{
@@ -4269,6 +4281,7 @@
 	    s->lineart_buffer = (SANE_Byte *) malloc (s->params.pixel_xs * 2);
 	}
     }
+#ifndef WIN32
   if (pipe (fds) < 0)
     {
       s->scanning = SANE_FALSE;
@@ -4296,6 +4309,7 @@
   if (sanei_thread_is_forked()) close (s->reader_pipe);
 
   XDBG ((1, "sane_start done\n"));
+#endif
 
   return SANE_STATUS_GOOD;	/* parent */
 }
@@ -4390,11 +4404,13 @@
       return SANE_STATUS_UNSUPPORTED;
     }
 
+#ifndef WIN32
   if (fcntl (s->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0)
     {
       XDBG ((4, "ERROR: can?t set to non-blocking mode !\n"));
       return SANE_STATUS_IO_ERROR;
     }
+#endif
 
   XDBG ((1, "sane_set_io_mode done\n"));
   return SANE_STATUS_GOOD;
--- backend/umax_pp_low.c	2006-09-17 23:59:52 -0500
+++ backend/umax_pp_low.c	2009-01-13 10:24:58 -0600
@@ -6049,7 +6049,12 @@
       CMDSETGET (4, 0x08, op03);
       CMDSYNC (0x40);
       CMDSYNC (0xC2);
+#ifdef WIN32
+      usleep (999999);
+      usleep (999999);
+#else
       sleep (2);
+#endif
     }
 
   /* move backward */
@@ -6061,7 +6066,12 @@
   CMDSETGET (4, 0x08, op03);
   CMDSYNC (0x40);
   CMDSYNC (0xC2);
+#ifdef WIN32
+  usleep (999999);
+  usleep (999999);
+#else
   sleep (2);
+#endif
 
   /* means 'CONTINUE MOVE' */
   CMDSYNC (0x00);
@@ -6091,7 +6101,19 @@
       CMDSETGET (4, 0x08, op03);
       CMDSYNC (0x40);
       CMDSYNC (0xC2);
+#ifdef WIN32
+      usleep (999999);
+      usleep (999999);
+      usleep (999999);
+      usleep (999999);
+      usleep (999999);
+      usleep (999999);
+      usleep (999999);
+      usleep (999999);
+      usleep (999999);
+#else
       sleep (9);
+#endif
     }
 
   CMDSYNC (0x00);
@@ -6224,7 +6246,11 @@
 	  CMDSYNC (0x40);
 	  do
 	    {
+#ifdef WIN32
+              usleep (999999);
+#else
 	      sleep (1);
+#endif
 	      CMDSYNC (0xC2);
 	    }
 	  while ((sanei_umax_pp_scannerStatus () & 0x90) != 0x90);
@@ -6240,7 +6266,11 @@
 	  CMDSYNC (0x40);
 	  do
 	    {
+#ifdef WIN32
+              usleep (999999);
+#else
 	      sleep (1);
+#endif
 	      CMDSYNC (0xC2);
 	    }
 	  while ((sanei_umax_pp_scannerStatus () & 0x90) != 0x90);
@@ -6320,7 +6350,13 @@
 	      /* the sleep is here to prevent */
 	      /* excessive CPU usage, can be  */
 	      /* removed, if we don't care    */
+#ifdef WIN32
+              usleep (999999);
+              usleep (999999);
+              usleep (999999);
+#else
 	      sleep (3);
+#endif
 	      CMDSYNC (0xC2);
 	      DBG (16, "PARKING polling status is 0x%02X   (%s:%d)\n",
 		   sanei_umax_pp_scannerStatus (), __FILE__, __LINE__);
@@ -11672,7 +11708,11 @@
       /* poll parking */
       do
 	{
-	  sleep (1);
+#ifdef WIN32
+          usleep (999999);
+#else
+          sleep (1);
+#endif
 	  CMDSYNC (0x40);
 	}
       while ((sanei_umax_pp_scannerStatus () & MOTOR_BIT) == 0x00);
