mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
dirmngr: Fix for Windows.
* dirmngr/http.c (EHOSTUNREACH, EAFNOSUPPORT): Define when not available. [HTTP_USE_GNUTLS] (my_gnutls_read): Use recv for Windows. [HTTP_USE_GNUTLS] (my_gnutls_write): Use send for Windows. -- Reported-by: Eli Zaretskii GnuPG-bug-id: 5899 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
09df630e4b
commit
14068dfc74
@ -64,6 +64,12 @@
|
||||
# include <winsock2.h>
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# ifndef EHOSTUNREACH
|
||||
# define EHOSTUNREACH WSAEHOSTUNREACH
|
||||
# endif
|
||||
# ifndef EAFNOSUPPORT
|
||||
# define EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||
# endif
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
@ -440,20 +446,48 @@ static ssize_t
|
||||
my_gnutls_read (gnutls_transport_ptr_t ptr, void *buffer, size_t size)
|
||||
{
|
||||
my_socket_t sock = ptr;
|
||||
#if USE_NPTH
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* Under Windows we need to use recv for a socket. */
|
||||
int nread;
|
||||
# if USE_NPTH
|
||||
npth_unprotect ();
|
||||
# endif
|
||||
nread = recv (FD2INT (sock->fd), buffer, size, 0);
|
||||
# if USE_NPTH
|
||||
npth_protect ();
|
||||
# endif
|
||||
return nread;
|
||||
|
||||
#else /* !HAVE_W32_SYSTEM */
|
||||
# if USE_NPTH
|
||||
return npth_read (sock->fd, buffer, size);
|
||||
#else
|
||||
# else
|
||||
return read (sock->fd, buffer, size);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
static ssize_t
|
||||
my_gnutls_write (gnutls_transport_ptr_t ptr, const void *buffer, size_t size)
|
||||
{
|
||||
my_socket_t sock = ptr;
|
||||
#if USE_NPTH
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
int nwritten;
|
||||
# if USE_NPTH
|
||||
npth_unprotect ();
|
||||
# endif
|
||||
nwritten = send (FD2INT (sock->fd), buffer, size, 0);
|
||||
# if USE_NPTH
|
||||
npth_protect ();
|
||||
# endif
|
||||
return nwritten;
|
||||
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
|
||||
# if USE_NPTH
|
||||
return npth_write (sock->fd, buffer, size);
|
||||
#else
|
||||
# else
|
||||
return write (sock->fd, buffer, size);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#endif /*HTTP_USE_GNUTLS*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user