> On Nov 7, 2014, at 8:21 AM, Dongsheng Song <[email protected]> wrote:
> 
> I need some code changes for Windows support.
> e.g.
> 
> --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c
> +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c
> @@ -57,13 +57,17 @@
>  *
>  */
> 
> +#ifdef _WIN32
> +#include <ws2tcpip.h>
> +#else
> #include <sys/socket.h>
> -#include <sys/time.h>
> -
> #include <netinet/in.h>
> +#include <netdb.h>
> +#endif
> +
> +#include <sys/time.h>
> 
> #include <errno.h>
> -#include <netdb.h>
> #include <stdio.h>
> #include <string.h>
> #include <unistd.h>

Thanks for the first set of patches on the portable tree!

I would think the #ifdef _WIN32 is probably the lesser of two evils.

Hopefully this will be largely confined to bio and the openssl app?

You'll also need to audit file descriptor usage carefully, so they
are closed properly:

static void
conn_close_socket(BIO *bio)
{
    BIO_CONNECT *c;

    c = (BIO_CONNECT *)bio->ptr;
    if (bio->num != -1) {
        /* Only do a shutdown if things were established */
        if (c->state == BIO_CONN_S_OK)
            shutdown(bio->num, SHUT_RDWR);
#ifdef _WIN32
        closesocket(bio->num);
#else
        close(bio->num);
#endif
        bio->num = -1;
    }
}


> I think the following patch is ugly:
> 
> +#ifdef HAVE_WS2TCPIP_h
> +#include <ws2tcpip.h>
> +#endif
> 
> +#ifdef HAVE_NETDB_H
> +#include <netdb.h>
> +#endif
> 
> +#ifdef HAVE_NETINET_IN_H
> +#include <netinet/in.h>
> +#endif
> 
> +#ifdef HAVE_SYS_SOCKET_H
> +#include <sys/socket.h>
> +#endif
> 
> 
> Which patch format acceptable, guard _WIN32 or every header file which
> not all platform have ? Or there have another approach ?
> 


Reply via email to