Quantcast

sane runs in windows without cygwin

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

sane runs in windows without cygwin

Michael Cronenworth
Hello,

I've had success in building sane with MinGW, MSYS, and libusb-win32-0.12. During my initial work I was unable to find much of anything about such a feat as most people settled for Cygwin.

Some caveats:
1. I ripped out all backends except for "fujitsu" as this is the scanner I have. The "fujitsu" code required no modifications to compile.
2. Signals, threading, and scsi are also obviously not available. I put #ifdef 32 or #ifndef WIN32 around the problem areas.
3. I changed sleep() calls to usleep() calls or used the Windows method of sleep.
4. getpass() is used?!?

In retrospect:
1. The rest of the backends seemed to need extensive rework as they use signals and ioctl calls that do not translate at all.
2. Threading and scsi could be made available quite easily by adding Windows equivalents.
3. Platform independent sleep calls should be put in.
4. Obsolete function! This should be replaced with similar functionality.

I have a GTK+2 app that used sane in Linux and it works in Windows without any modification to the app code. I scanned successfully and my program rendered a beautiful PNG to the screen. It should be noted that in order for the scanner to be detected, I had to install the Fujitsu TWAIN driver. I guess libusb-win32 could not detect the device until the appropriate driver was installed? Artefact of using Windows inside of VirtualBox?

If anyone is interested in the changes I've made, I'd be interested in making them available.

Regards,
Michael

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

m. allan noah-3
2009/1/13 Michael Cronenworth <[hidden email]>:
> Hello,
>
> I've had success in building sane with MinGW, MSYS, and libusb-win32-0.12.
> During my initial work I was unable to find much of anything about such a
> feat as most people settled for Cygwin.

Excellent news!

> Some caveats:
> 1. I ripped out all backends except for "fujitsu" as this is the scanner I
> have. The "fujitsu" code required no modifications to compile.

Did you try any others, or start with only fujitsu?

> 2. Signals, threading, and scsi are also obviously not available. I put
> #ifdef 32 or #ifndef WIN32 around the problem areas.

sane-fujitsu does not use signals or threading, so you made a good
choice of backend :)

> 3. I changed sleep() calls to usleep() calls or used the Windows method of
> sleep.

I only see usleep calls in sane, but there is alot of code...

> 4. getpass() is used?!?

By scanimage, yes. SANE includes a rudimentary form of authentication
checking, in case a resource requires more security. I don't know of
anything that uses it.

> In retrospect:
> 1. The rest of the backends seemed to need extensive rework as they use
> signals and ioctl calls that do not translate at all.

There are a few others that dont use threading or signals (canon_dr,
cardscan, ...), it would be nice to see if those compile as well.

> 2. Threading and scsi could be made available quite easily by adding Windows
> equivalents.

Well, we would need a windows expert to do it :)

> 3. Platform independent sleep calls should be put in.
> 4. Obsolete function! This should be replaced with similar functionality.

Certainly these two are easy fixes.

> I have a GTK+2 app that used sane in Linux and it works in Windows without
> any modification to the app code. I scanned successfully and my program
> rendered a beautiful PNG to the screen. It should be noted that in order for
> the scanner to be detected, I had to install the Fujitsu TWAIN driver. I
> guess libusb-win32 could not detect the device until the appropriate driver
> was installed? Artefact of using Windows inside of VirtualBox?

That is odd. I don't know how windows works in that regard. Makes me
wonder if we could produce some sort of prog that would read the sane
.desc files and build a .inf or something to tell windows to talk to
the device?

> If anyone is interested in the changes I've made, I'd be interested in
> making them available.

yes, very much interested. there has been some talk lately about
updating the sane build system, it might be possible to coordinate
with that effort, so that at least minimal win32 support is added to
mainline sane.

allan
--
"The truth is an offense, but not a sin"

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Ilia Sotnikov
On Wed, Jan 14, 2009 at 4:25 PM, m. allan noah <[hidden email]> wrote:

> 2009/1/13 Michael Cronenworth <[hidden email]>:
>> Hello,
>>
>> I've had success in building sane with MinGW, MSYS, and libusb-win32-0.12.
>> During my initial work I was unable to find much of anything about such a
>> feat as most people settled for Cygwin.
>
> Excellent news!
>
>> Some caveats:
>> 1. I ripped out all backends except for "fujitsu" as this is the scanner I
>> have. The "fujitsu" code required no modifications to compile.
>
> Did you try any others, or start with only fujitsu?
>
>> 2. Signals, threading, and scsi are also obviously not available. I put
>> #ifdef 32 or #ifndef WIN32 around the problem areas.
>
> sane-fujitsu does not use signals or threading, so you made a good
> choice of backend :)
>
>> 3. I changed sleep() calls to usleep() calls or used the Windows method of
>> sleep.
>
> I only see usleep calls in sane, but there is alot of code...
>
>> 4. getpass() is used?!?
>
> By scanimage, yes. SANE includes a rudimentary form of authentication
> checking, in case a resource requires more security. I don't know of
> anything that uses it.
>
>> In retrospect:
>> 1. The rest of the backends seemed to need extensive rework as they use
>> signals and ioctl calls that do not translate at all.
>
> There are a few others that dont use threading or signals (canon_dr,
> cardscan, ...), it would be nice to see if those compile as well.
>
>> 2. Threading and scsi could be made available quite easily by adding Windows
>> equivalents.
>
> Well, we would need a windows expert to do it :)
>
>> 3. Platform independent sleep calls should be put in.
>> 4. Obsolete function! This should be replaced with similar functionality.
>
> Certainly these two are easy fixes.
>
>> I have a GTK+2 app that used sane in Linux and it works in Windows without
>> any modification to the app code. I scanned successfully and my program
>> rendered a beautiful PNG to the screen. It should be noted that in order for
>> the scanner to be detected, I had to install the Fujitsu TWAIN driver. I
>> guess libusb-win32 could not detect the device until the appropriate driver
>> was installed? Artefact of using Windows inside of VirtualBox?
>
> That is odd. I don't know how windows works in that regard. Makes me
> wonder if we could produce some sort of prog that would read the sane
> .desc files and build a .inf or something to tell windows to talk to
> the device?
>
>> If anyone is interested in the changes I've made, I'd be interested in
>> making them available.
>
> yes, very much interested. there has been some talk lately about
> updating the sane build system, it might be possible to coordinate
> with that effort, so that at least minimal win32 support is added to
> mainline sane.
>

Well, what about experimental/sane-backends-win32 sitting in CVS for
about 18 months? To be honest, we are using that version of SANE
backends (dll + net) in native Win32 form for more than 2 years. The
version comes even with Inno setup installer support ;) Anyone
interested?

Best regards,
--
 Ilia Sotnikov

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

m. allan noah-3
On Wed, Jan 14, 2009 at 10:45 AM, Ilia Sotnikov <[hidden email]> wrote:

> On Wed, Jan 14, 2009 at 4:25 PM, m. allan noah <[hidden email]> wrote:
>> 2009/1/13 Michael Cronenworth <[hidden email]>:
>>> Hello,
>>>
>>> I've had success in building sane with MinGW, MSYS, and libusb-win32-0.12.
>>> During my initial work I was unable to find much of anything about such a
>>> feat as most people settled for Cygwin.
>>
>> Excellent news!
>>
>>> Some caveats:
>>> 1. I ripped out all backends except for "fujitsu" as this is the scanner I
>>> have. The "fujitsu" code required no modifications to compile.
>>
>> Did you try any others, or start with only fujitsu?
>>
>>> 2. Signals, threading, and scsi are also obviously not available. I put
>>> #ifdef 32 or #ifndef WIN32 around the problem areas.
>>
>> sane-fujitsu does not use signals or threading, so you made a good
>> choice of backend :)
>>
>>> 3. I changed sleep() calls to usleep() calls or used the Windows method of
>>> sleep.
>>
>> I only see usleep calls in sane, but there is alot of code...
>>
>>> 4. getpass() is used?!?
>>
>> By scanimage, yes. SANE includes a rudimentary form of authentication
>> checking, in case a resource requires more security. I don't know of
>> anything that uses it.
>>
>>> In retrospect:
>>> 1. The rest of the backends seemed to need extensive rework as they use
>>> signals and ioctl calls that do not translate at all.
>>
>> There are a few others that dont use threading or signals (canon_dr,
>> cardscan, ...), it would be nice to see if those compile as well.
>>
>>> 2. Threading and scsi could be made available quite easily by adding Windows
>>> equivalents.
>>
>> Well, we would need a windows expert to do it :)
>>
>>> 3. Platform independent sleep calls should be put in.
>>> 4. Obsolete function! This should be replaced with similar functionality.
>>
>> Certainly these two are easy fixes.
>>
>>> I have a GTK+2 app that used sane in Linux and it works in Windows without
>>> any modification to the app code. I scanned successfully and my program
>>> rendered a beautiful PNG to the screen. It should be noted that in order for
>>> the scanner to be detected, I had to install the Fujitsu TWAIN driver. I
>>> guess libusb-win32 could not detect the device until the appropriate driver
>>> was installed? Artefact of using Windows inside of VirtualBox?
>>
>> That is odd. I don't know how windows works in that regard. Makes me
>> wonder if we could produce some sort of prog that would read the sane
>> .desc files and build a .inf or something to tell windows to talk to
>> the device?
>>
>>> If anyone is interested in the changes I've made, I'd be interested in
>>> making them available.
>>
>> yes, very much interested. there has been some talk lately about
>> updating the sane build system, it might be possible to coordinate
>> with that effort, so that at least minimal win32 support is added to
>> mainline sane.
>>
>
> Well, what about experimental/sane-backends-win32 sitting in CVS for
> about 18 months? To be honest, we are using that version of SANE
> backends (dll + net) in native Win32 form for more than 2 years. The
> version comes even with Inno setup installer support ;) Anyone
> interested?

Yes- I had forgotten about that. So now we have dll, net, and fujitsu
backends, and scanimage natively building?

allan
--
"The truth is an offense, but not a sin"

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Ilia Sotnikov
On Wed, Jan 14, 2009 at 5:51 PM, m. allan noah <[hidden email]> wrote:
>
> Yes- I had forgotten about that. So now we have dll, net, and fujitsu
> backends, and scanimage natively building?
>

Not with 'fujitsu' backend in the version I've mentioned, however, as
Michael got the success with it, would be easy to merge the efforts.
I've also made the Xsane port to Win32 (0.991 to be precise), which
was never been published due to absense of any SCM repository. This
pair (SANE backends Win32 + Xsane Win32) I've mentioned when speaking
about what we are using.

Best regards,
--
 Ilia Sotnikov

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

m. allan noah-3
On Wed, Jan 14, 2009 at 11:05 AM, Ilia Sotnikov <[hidden email]> wrote:

> On Wed, Jan 14, 2009 at 5:51 PM, m. allan noah <[hidden email]> wrote:
>>
>> Yes- I had forgotten about that. So now we have dll, net, and fujitsu
>> backends, and scanimage natively building?
>>
>
> Not with 'fujitsu' backend in the version I've mentioned, however, as
> Michael got the success with it, would be easy to merge the efforts.
> I've also made the Xsane port to Win32 (0.991 to be precise), which
> was never been published due to absense of any SCM repository. This
> pair (SANE backends Win32 + Xsane Win32) I've mentioned when speaking
> about what we are using.

Understood. How complex do you feel your changes were to get the
sane-backends side working? Reasonable to #ifdef into mainline?

allan
--
"The truth is an offense, but not a sin"

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Ilia Sotnikov
On Wed, Jan 14, 2009 at 6:24 PM, m. allan noah <[hidden email]> wrote:
> Understood. How complex do you feel your changes were to get the
> sane-backends side working? Reasonable to #ifdef into mainline?

Not really complex but would take some time because the abovementioned
repository based on post-1.0.18 SANE backends. As well as merging
Michael's work. As far as I know further porting of the backends
should be straightforward (at least for USB based ones). What makes
the troubles is the fork() absense. One possibility to check all the
backends to be thread safe and use threads instead. Then even saned
could be ported.

I would make the branch in the main repository, commit all changes
there, verify the result and then finally merge it with HEAD.

Any thougths?

Best regards,
--
 Ilia Sotnikov

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Julien BLACHE-2
In reply to this post by m. allan noah-3
"m. allan noah" <[hidden email]> wrote:

> Yes- I had forgotten about that. So now we have dll, net, and fujitsu
> backends, and scanimage natively building?

For some value of "natively" and "building" as far as fujitsu is
concerned, from what I've read. Ugh.

JB.

--
Julien BLACHE                                   <http://www.jblache.org>
<[hidden email]>                                  GPG KeyID 0xF5D65169

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

m. allan noah-3
In reply to this post by Ilia Sotnikov
On Wed, Jan 14, 2009 at 11:38 AM, Ilia Sotnikov <[hidden email]> wrote:

> On Wed, Jan 14, 2009 at 6:24 PM, m. allan noah <[hidden email]> wrote:
>> Understood. How complex do you feel your changes were to get the
>> sane-backends side working? Reasonable to #ifdef into mainline?
>
> Not really complex but would take some time because the abovementioned
> repository based on post-1.0.18 SANE backends. As well as merging
> Michael's work. As far as I know further porting of the backends
> should be straightforward (at least for USB based ones). What makes
> the troubles is the fork() absense. One possibility to check all the
> backends to be thread safe and use threads instead. Then even saned
> could be ported.
>
> I would make the branch in the main repository, commit all changes
> there, verify the result and then finally merge it with HEAD.
>
> Any thougths?

There has been some discussion of moving to some other SCM lately, so
any branching might want to wait for that, but certainly you could try
to apply your changes to a current cvs checkout, and at least produce
a patch?

Most backends should be using sanei_thread, so it is possible to build
them with pthread support instead of fork, so something like
http://sourceware.org/pthreads-win32/ could be useful?

allan
--
"The truth is an offense, but not a sin"

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Ilia Sotnikov
On Wed, Jan 14, 2009 at 7:06 PM, m. allan noah <[hidden email]> wrote:
> There has been some discussion of moving to some other SCM lately, so
> any branching might want to wait for that, but certainly you could try
> to apply your changes to a current cvs checkout, and at least produce
> a patch?

I have CVS write access so why not create a branch? Any objections?

> Most backends should be using sanei_thread, so it is possible to build
> them with pthread support instead of fork, so something like
> http://sourceware.org/pthreads-win32/ could be useful?

I meant the ability for a backend to behave safely when executing in
several different threads. No to mention that thread safeness could be
useful in the future, but for saned porting - it does fork() to handle
client connection and when we will convert in to pthread_create() we
need to be sure that such process is safe.

Best regards,
--
 Ilia Sotnikov

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Michael Cronenworth
In reply to this post by m. allan noah-3
-------- Original Message --------
Subject: Re: [sane-devel] sane runs in windows without cygwin
From: m. allan noah <[hidden email]>
To: Michael Cronenworth <[hidden email]>
CC: [hidden email]
Date: 01/14/2009 08:25 AM

> 2009/1/13 Michael Cronenworth <[hidden email]>:
>> If anyone is interested in the changes I've made, I'd be interested in
>> making them available.
>
> yes, very much interested. there has been some talk lately about
> updating the sane build system, it might be possible to coordinate
> with that effort, so that at least minimal win32 support is added to
> mainline sane.
>
> allan

OK, I wanted to reply before people thought I posted and ran. I'm caught
in some other programming messes at the moment, but I will post a patch
with the changes I had to make. A majority of them were just #ifdef
WIN32 around problem headers or function calls. Give me a few days... or
weeks.

Might I recommend a switch to git. I switched from CVS to git and I'm
quite a happy camper. ^.^

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Julien BLACHE-2
Michael Cronenworth <[hidden email]> wrote:

Hi,

> Might I recommend a switch to git. I switched from CVS to git and I'm
> quite a happy camper. ^.^

Working on it.

JB.

--
Julien BLACHE                                   <http://www.jblache.org>
<[hidden email]>                                  GPG KeyID 0xF5D65169

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Ivan Boldyrev-3
On Thu, Jan 15, 2009 at 9:36 PM, Julien BLACHE <[hidden email]> wrote:
>> Might I recommend a switch to git. I switched from CVS to git and I'm
>> quite a happy camper. ^.^
>
> Working on it.

I'd vote for switching to Mercurial.  Git is usability disaster, it
even worse than tla.  Mercurial is much SANEr :D

I'm in process of converting SANE CVS repo to Mercurial, but doing it
locally would be much faster.

Anyway, I'm glad you are looking toward distributed VCS.

--
Ivan Boldyrev

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Michael Cronenworth
In reply to this post by Michael Cronenworth
-------- Original Message --------
Subject: Re: [sane-devel] sane runs in windows without cygwin
From: Michael Cronenworth <[hidden email]>
To: m. allan noah <[hidden email]>
CC: [hidden email]
Date: 01/15/2009 09:15 AM

>
> OK, I wanted to reply before people thought I posted and ran. I'm caught
> in some other programming messes at the moment, but I will post a patch
> with the changes I had to make. A majority of them were just #ifdef
> WIN32 around problem headers or function calls. Give me a few days... or
> weeks.
>

Without further delay, I bring you patches.

Remember: fujitsu was the only backend I compiled. All others are
untested/won't compile.

--- sane-backends-1.0.19.orig/frontend/scanimage.c 2007-12-29 15:36:25 -0600
+++ sane-backends-1.0.19/frontend/scanimage.c 2009-01-13 10:17:06 -0600
@@ -278,7 +278,9 @@
 
   if (query_user == 1)
     {
+#ifndef WIN32
       strcpy (password, (wipe = getpass ("Enter password: ")));
+#endif
       memset (wipe, 0, strlen (password));
     }
 
@@ -2109,10 +2111,12 @@
   if (output_format != OUTPUT_PNM)
     resolution_value = get_resolution ();
 
+#ifndef WIN32
   signal (SIGHUP, sighandler);
   signal (SIGINT, sighandler);
   signal (SIGPIPE, sighandler);
   signal (SIGTERM, sighandler);
+#endif
 
   if (test == 0)
     {

--- sane-backends-1.0.19.orig/lib/inet_ntop.c 2002-02-14 13:53:37 -0600
+++ sane-backends-1.0.19/lib/inet_ntop.c 2009-01-12 17:22:16 -0600
@@ -3,10 +3,14 @@
 #ifndef HAVE_INET_NTOP
 
 #include <string.h>
+#ifdef WIN32
+#include <winsock2.h>
+#else
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#endif
 
 
 const char *
--- sane-backends-1.0.19.orig/lib/inet_pton.c 2002-02-19 13:30:47 -0600
+++ sane-backends-1.0.19/lib/inet_pton.c 2009-01-12 17:24:01 -0600
@@ -3,10 +3,14 @@
 #ifndef HAVE_INET_PTON
 
 #include <string.h>
+#ifdef WIN32
+#include <winsock.h>
+#else
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#endif
 
 int
 inet_pton (int af, const char *src, void *dst)
--- sane-backends-1.0.19.orig/lib/sigprocmask.c 2001-05-31 12:36:38 -0500
+++ sane-backends-1.0.19/lib/sigprocmask.c 2009-01-12 18:27:34 -0600
@@ -33,9 +33,11 @@
 
   switch (how)
     {
+#ifndef WIN32
     case 1: o = sigblock (n); break;
     case 2: o = sigsetmask (sigblock (0) & ~n); break;
     case 3: o = sigsetmask (n); break;
+#endif
     default:
       errno = EINVAL;
       return -1;
--- sane-backends-1.0.19.orig/lib/vsyslog.c 2001-05-31 12:36:39 -0500
+++ sane-backends-1.0.19/lib/vsyslog.c 2009-01-12 17:26:36 -0600
@@ -1,7 +1,9 @@
 #include "../include/sane/config.h"
 
 #include "stdio.h"
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #include <stdarg.h>
 
 #ifndef HAVE_VSYSLOG
@@ -9,9 +11,11 @@
 void
 vsyslog(int priority, const char *format, va_list args)
 {
+#ifndef WIN32
   char buf[1024];
   vsnprintf(buf, sizeof(buf), format, args);
   syslog(priority, "%s", buf);
+#endif
 }
 
 #endif /* !HAVE_VSYSLOG */

--- sane-backends-1.0.19.orig/sanei/sanei_ab306.c 2007-10-25 08:23:52 -0500
+++ sane-backends-1.0.19/sanei/sanei_ab306.c 2009-01-12 17:39:08 -0600
@@ -55,6 +55,10 @@
 # include <asm/io.h> /* ugly, but backwards compatible */
 #elif defined (__i386__)  && defined (__GNUC__)
 
+#ifdef WIN32
+typedef unsigned short int u_short;
+#endif
+
 static __inline__ void
 outb (u_char value, u_long port)
 {
--- sane-backends-1.0.19.orig/sanei/sanei_init_debug.c 2005-07-15 16:59:25 -0500
+++ sane-backends-1.0.19/sanei/sanei_init_debug.c 2009-01-12 17:41:45 -0600
@@ -48,7 +48,9 @@
 #endif
 #include <string.h>
 #include <stdarg.h>
+#ifndef WIN32
 #include <syslog.h>
+#endif
 #ifdef HAVE_OS2_H
 #include <sys/types.h>
 #endif
@@ -106,13 +108,17 @@
   msg = (char *)malloc (sizeof(char) * (strlen(be) + strlen(fmt) + 4));
   if (msg == NULL)
     {
+#ifndef WIN32
       syslog (LOG_DEBUG, "[sanei_debug] malloc() failed\n");
       vsyslog (LOG_DEBUG, fmt, ap);
+#endif
     }
   else
     {
+#ifndef WIN32
       sprintf (msg, "[%s] %s", be, fmt);
               vsyslog(LOG_DEBUG, msg, ap);
+#endif
       free (msg);
     }
  }
--- sane-backends-1.0.19.orig/sanei/sanei_pio.c 2006-06-11 14:46:09 -0500
+++ sane-backends-1.0.19/sanei/sanei_pio.c 2009-01-12 17:53:26 -0600
@@ -66,6 +66,10 @@
 # include <sys/hw.h>
 #elif defined(__i386__)  && defined (__GNUC__)
 
+#ifdef WIN32
+typedef unsigned short int u_short;
+#endif
+
 static __inline__ void
 outb (u_char value, u_long port)
 {
--- sane-backends-1.0.19.orig/sanei/sanei_scsi.c 2007-11-16 12:37:07 -0600
+++ sane-backends-1.0.19/sanei/sanei_scsi.c 2009-01-12 17:52:00 -0600
@@ -56,7 +56,9 @@
 #include <string.h>
 #include <unistd.h>
 
+#ifndef WIN32
 #include <sys/ioctl.h>
+#endif
 #include <sys/param.h>
 #include <sys/types.h>
 
@@ -4754,6 +4756,7 @@
                 const void *src, size_t src_size,
  void *dst, size_t * dst_size)
 {
+#ifndef WIN32
   struct pkt {
     SCSI_PASS_THROUGH_DIRECT sptd;
     unsigned char sense[255];
@@ -4827,6 +4830,7 @@
   if (dst_size) {
     *dst_size = pkt.sptd.DataTransferLength;
   }
+#endif
 
   return SANE_STATUS_GOOD;
 }
--- sane-backends-1.0.19.orig/sanei/sanei_tcp.c 2008-01-08 17:04:04 -0600
+++ sane-backends-1.0.19/sanei/sanei_tcp.c 2009-01-12 18:19:18 -0600
@@ -46,7 +46,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef WIN32
+#include <winsock2.h>
+#else
 #include <sys/socket.h>
+#endif
 
 #if defined(__CYGWIN__) && !defined(MSG_WAITALL)
 #define MSG_WAITALL  0x08
@@ -110,5 +114,9 @@
 ssize_t
 sanei_tcp_read(int fd, u_char * buf, int count)
 {
+#ifdef WIN32
+ return recv(fd, buf, count, 0);
+#else
  return recv(fd, buf, count, MSG_WAITALL);
+#endif
 }
--- sane-backends-1.0.19.orig/sanei/sanei_thread.c 2005-07-15 16:59:25 -0500
+++ sane-backends-1.0.19/sanei/sanei_thread.c 2009-01-13 08:53:48 -0600
@@ -69,8 +69,10 @@
 # include <kernel/OS.h>
 #endif
 #if !defined USE_PTHREAD && !defined HAVE_OS2_H && !defined __BEOS__
+#ifndef WIN32
 # include <sys/wait.h>
 #endif
+#endif
 #if defined USE_PTHREAD
 # include <pthread.h>
 #endif
@@ -129,8 +131,12 @@
 #elif defined HAVE_OS2_H
  return DosKillThread(pid);
 #else
+#ifdef WIN32
+ return -1;
+#else
  return kill( pid, SIGTERM );
 #endif
+#endif
 }
 
 #ifdef HAVE_OS2_H
@@ -245,7 +251,11 @@
 {
  if (sig == SIGKILL)
  sig = SIGKILLTHR;
+#ifdef WIN32
+ return -1;
+#else
  return kill(pid, sig);
+#endif
 }
 
 #else /* HAVE_OS2_H, __BEOS__ */
@@ -329,6 +339,7 @@
 {
  int retval = SANE_STATUS_IO_ERROR;
 
+#ifndef WIN32
  if( wpres == pid ) {
 
  if( WIFEXITED(pf)) {
@@ -344,6 +355,7 @@
  }
  }
  }
+#endif
  return retval;
 }
 #endif
@@ -383,11 +395,15 @@
  DBG( 2, "pthread_create() created thread %d\n", (int)thread );
  return (int)thread;
 #else
+#ifdef WIN32
+        pid = 0;
+#else
  pid = fork();
  if( pid < 0 ) {
  DBG( 1, "fork() failed\n" );
  return -1;
  }
+#endif
 
  if( pid == 0 ) {
 
@@ -411,7 +427,11 @@
  return pthread_kill((pthread_t)pid, sig );
 #else
  DBG(2, "sanei_thread_sendsig() %d to process (id=%d)\n", sig, pid);
- return kill( pid, sig );
+#ifdef WIN32
+ return -1;
+#else
+ return kill(pid, sig);
+#endif
 #endif
 }
 
@@ -451,7 +471,11 @@
 
  restore_sigpipe();
 #else
+#ifdef WIN32
+        result = -1;
+#else
  result = waitpid( pid, &ls, 0 );
+#endif
  if((result < 0) && (errno == ECHILD)) {
  stat   = SANE_STATUS_GOOD;
  result = pid;
@@ -478,12 +502,14 @@
  int ls, stat, result;
 
  stat = SANE_STATUS_IO_ERROR;
+#ifndef WIN32
  if( pid > 0 ) {
 
  result = waitpid( pid, &ls, WNOHANG );
 
  stat = eval_wp_result( pid, result, ls );
  }
+#endif
  return stat;
 #endif
 }
--- sane-backends-1.0.19.orig/sanei/sanei_udp.c 2007-12-26 05:18:26 -0600
+++ sane-backends-1.0.19/sanei/sanei_udp.c 2009-01-12 18:21:46 -0600
@@ -46,10 +46,14 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef WIN32
+#include <winsock2.h>
+#else
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
 #include <arpa/inet.h>
+#endif
 
 #define BACKEND_NAME sanei_udp
 
@@ -172,7 +176,11 @@
 ssize_t
 sanei_udp_read(int fd, u_char * buf, int count)
 {
+#ifdef WIN32
+ return recv(fd, buf, count, 0);
+#else
  return recv(fd, buf, count, MSG_WAITALL);
+#endif
 }
 
 ssize_t
@@ -184,8 +192,13 @@
 
  fl = sizeof(from);
 
+#ifdef WIN32
+ l = recvfrom(fd, buf, count, 0,
+ (struct sockaddr *) &from, &fl);
+#else
  l = recvfrom(fd, buf, count, MSG_DONTWAIT,
  (struct sockaddr *) &from, &fl);
+#endif
 
  if (l > 0 && fromp) {
  *fromp = inet_ntoa(from.sin_addr);
--- sane-backends-1.0.19.orig/sanei/sanei_usb.c 2007-11-16 02:46:32 -0600
+++ sane-backends-1.0.19/sanei/sanei_usb.c 2009-01-13 10:08:21 -0600
@@ -52,7 +52,9 @@
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
+#ifndef WIN32
 #include <sys/ioctl.h>
+#endif
 #include <stdio.h>
 #include <dirent.h>
 
@@ -1046,6 +1048,7 @@
        devname, strerror (errno));
   return status;
  }
+#ifndef WIN32
       flag = fcntl (devices[devcount].fd, F_GETFD);
       if (flag >= 0)
  {
@@ -1053,6 +1056,7 @@
     DBG (1, "sanei_usb_open: fcntl of `%s' failed: %s\n",
  devname, strerror (errno));
  }
+#endif
     }
   else if (devices[devcount].method == sanei_usb_method_usbcalls)
     {

--- sane-backends-1.0.19.orig/tools/sane-find-scanner.c 2007-11-10 09:44:41 -0600
+++ sane-backends-1.0.19/tools/sane-find-scanner.c 2009-01-13 10:18:49 -0600
@@ -1593,12 +1593,14 @@
   if (verbose > 0)
     printf ("\n  # Most Scanners connected to the parallel port or other "
     "proprietary ports\n  # can't be detected by this program.\n");
+#ifndef WIN32
   if (getuid ())
     if (verbose > 0)
       printf
  ("\n  # You may want to run this program as root to find all devices. "
  "Once you\n  # found the scanner devices, be sure to adjust access "
  "permissions as\n  # necessary.\n");
+#endif
 
   if (verbose > 1)
     printf ("done\n");

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sane runs in windows without cygwin

Chris Bagwell
On 2/4/2009 10:27 AM, Michael Cronenworth wrote:

> -------- Original Message --------
> Subject: Re: [sane-devel] sane runs in windows without cygwin
> From: Michael Cronenworth <[hidden email]>
> To: m. allan noah <[hidden email]>
> CC: [hidden email]
> Date: 01/15/2009 09:15 AM
>
>>
>> OK, I wanted to reply before people thought I posted and ran. I'm
>> caught in some other programming messes at the moment, but I will
>> post a patch with the changes I had to make. A majority of them were
>> just #ifdef WIN32 around problem headers or function calls. Give me a
>> few days... or weeks.
>>
>
> Without further delay, I bring you patches.
>
> Remember: fujitsu was the only backend I compiled. All others are
> untested/won't compile.
I can ACK the sane-wine32-lib.patch looks good... I can ACK bits and
pieces of the rest because I don't know any cleaner way to do it.  A few
specific comments on remaining patches follows.

+#ifdef WIN32
+typedef unsigned short int u_short;
+#endif
+

I recommend changing offending code to use a type from _stdint.h instead
of trying to maintain this type of code.  If that has issues then at
least move this code to acinclude.m4 where there is similar logic to
define u_int16_t.

I'm not qualified to comment on sanei functions yet... but  I wanted to
point out I submitted code in last week to remove MSG_WAITALL and
MSG_NOWAIT from all platforms since its not in cygwin either.  So those
pieces of the patches are no longer needed.

Chris

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Loading...