[sane-devel] [PATCH v2 12/14] net, call WSAStartup on win32

Chris Bagwell chris at cnpbagwell.com
Tue Jan 24 19:35:24 UTC 2012


On Mon, Jan 23, 2012 at 5:05 PM, Ruediger Meier <sweet_f_a at gmx.de> wrote:
> From: Ruediger Meier <ruediger.meier at ga-group.nl>
>
> We have to do this on win32 before doing winsock2 stuff. It affects the
> whole application so don't know wheather it's right to startup and clean
> it here within the net backend.

Hmm, I wonder if the net.c backend can make more use of functions
defined sanei_tcp.c?  I've added the same logic there to open and
close for use by TCP sockets in epson2 backend.  Maybe the patch with
net_read() and net_write() could make use of something there as well?

Chris

> ---
>  backend/net.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/backend/net.c b/backend/net.c
> index 0cd7f51..228bd59 100644
> --- a/backend/net.c
> +++ b/backend/net.c
> @@ -1016,6 +1016,18 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
>       DBG (3, "sane_init: Client has little endian byte order\n");
>     }
>
> +#ifdef _WIN32
> +    {
> +      /* no much fun on win32 without WSAStartup but is this the right place? */
> +      WSADATA data;
> +      int wsa_err = WSAStartup( MAKEWORD(2, 2), &data) != 0;
> +      if ( wsa_err != 0 )
> +       {
> +         DBG (1, "sane_init: WSAStartup failed with error %d\n", wsa_err );
> +       }
> +    }
> +#endif
> +
>  #ifndef NET_USES_AF_INDEP
>   DBG (2, "sane_init: determining sane service port\n");
>   serv = getservbyname ("sane-port", "tcp");
> @@ -1196,6 +1208,9 @@ sane_exit (void)
>        }
>       free (devlist);
>     }
> +#ifdef _WIN32
> +  WSACleanup();
> +#endif
>   DBG (3, "sane_exit: finished.\n");
>  }
>
> --
> 1.7.6.1
>
>
> --
> sane-devel mailing list: sane-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
> Unsubscribe: Send mail with subject "unsubscribe your_password"
>             to sane-devel-request at lists.alioth.debian.org



More information about the sane-devel mailing list