* mswindows.h: Always include <winsock2.h> and <ws2tcpip.h>. Do not
include <winsock.h>.
+ [! INHIBIT_WRAP]: Remove macro's socket, bind, connect, accept, recv,
+ send, select, getsockname, getpeername, setsockopt, closesocket.
+ Remove wrapped_socket, wrapped_bind, wrapped_connect, wrapped_listen,
+ wrapped_accept, wrapped_recv, wrapped_send, wrapped_select,
+ wrapped_getsockname, wrapped_getpeername, wrapped_setsockopt,
+ wrapped_closesocket prototypes.
+
+ * mswindows.c: Remove wrapped_socket, wrapped_bind, wrapped_connect,
+ wrapped_listen, wrapped_accept, wrapped_recv, wrapped_send,
+ wrapped_select, wrapped_getsockname, wrapped_getpeername,
+ wrapped_setsockopt, wrapped_closesocket functions. Remove WRAP macro.
* host.h [WINDOWS]: Include <winsock2.h> not <winsock.h>.
thread_hnd = NULL;
return rc;
}
-\f
-/* Wget expects network calls such as connect, recv, send, etc., to set
- errno on failure. To achieve that, Winsock calls are wrapped with code
- that, in case of error, sets errno to the value of WSAGetLastError().
- In addition, we provide a wrapper around strerror, which recognizes
- Winsock errors and prints the appropriate error message. */
-
-/* Define a macro that creates a function definition that wraps FUN into
- a function that sets errno the way the rest of the code expects. */
-
-#define WRAP(fun, decl, call) int wrapped_##fun decl { \
- int retval = fun call; \
- if (retval < 0) \
- errno = WSAGetLastError (); \
- return retval; \
-}
-
-WRAP (socket, (int domain, int type, int protocol), (domain, type, protocol))
-WRAP (bind, (int s, struct sockaddr *a, int alen), (s, a, alen))
-WRAP (connect, (int s, const struct sockaddr *a, int alen), (s, a, alen))
-WRAP (listen, (int s, int backlog), (s, backlog))
-WRAP (accept, (int s, struct sockaddr *a, int *alen), (s, a, alen))
-WRAP (recv, (int s, void *buf, int len, int flags), (s, buf, len, flags))
-WRAP (send, (int s, const void *buf, int len, int flags), (s, buf, len, flags))
-WRAP (select, (int n, fd_set *r, fd_set *w, fd_set *e, const struct timeval *tm),
- (n, r, w, e, tm))
-WRAP (getsockname, (int s, struct sockaddr *n, int *nlen), (s, n, nlen))
-WRAP (getpeername, (int s, struct sockaddr *n, int *nlen), (s, n, nlen))
-WRAP (setsockopt, (int s, int level, int opt, const void *val, int len),
- (s, level, opt, val, len))
-WRAP (closesocket, (int s), (s))
\f
#ifdef ENABLE_IPV6
# define gai_strerror strerror
#endif
-#ifndef INHIBIT_WRAP
-
-/* Winsock functions don't set errno, so we provide wrappers that do. */
-
-#define socket wrapped_socket
-#define bind wrapped_bind
-#define connect wrapped_connect
-#define listen wrapped_listen
-#define accept wrapped_accept
-#define recv wrapped_recv
-#define send wrapped_send
-#define select wrapped_select
-#define getsockname wrapped_getsockname
-#define getpeername wrapped_getpeername
-#define setsockopt wrapped_setsockopt
-#define closesocket wrapped_closesocket
-
-#endif /* not INHIBIT_WRAP */
-
-int wrapped_socket (int, int, int);
-int wrapped_bind (int, struct sockaddr *, int);
-int wrapped_connect (int, const struct sockaddr *, int);
-int wrapped_listen (int s, int backlog);
-int wrapped_accept (int s, struct sockaddr *a, int *alen);
-int wrapped_recv (int, void *, int, int);
-int wrapped_send (int, const void *, int, int);
-int wrapped_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *);
-int wrapped_getsockname (int, struct sockaddr *, int *);
-int wrapped_getpeername (int, struct sockaddr *, int *);
-int wrapped_setsockopt (int, int, int, const void *, int);
-int wrapped_closesocket (int);
-
/* Public functions. */
void ws_startup (void);