Check for USE_WINSOCK instead of WIN32 where the check was done
to verify winsock API availability.
This commit is contained in:
parent
96445f1b7d
commit
5df4be1165
@ -153,8 +153,8 @@ int main(int argc, char **argv)
|
|||||||
fd_set read_fds, write_fds;
|
fd_set read_fds, write_fds;
|
||||||
struct timeval *tvp, tv;
|
struct timeval *tvp, tv;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
WORD wVersionRequested = MAKEWORD(1,1);
|
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
WSAStartup(wVersionRequested, &wsaData);
|
WSAStartup(wVersionRequested, &wsaData);
|
||||||
#endif
|
#endif
|
||||||
|
@ -64,8 +64,8 @@ int main(int argc, char **argv)
|
|||||||
struct in_addr addr4;
|
struct in_addr addr4;
|
||||||
struct in6_addr addr6;
|
struct in6_addr addr6;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
WORD wVersionRequested = MAKEWORD(1,1);
|
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
WSAStartup(wVersionRequested, &wsaData);
|
WSAStartup(wVersionRequested, &wsaData);
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(WIN32) || defined(WATT32)) && !defined(MSDOS)
|
#ifdef USE_WINSOCK
|
||||||
#define GET_ERRNO() WSAGetLastError()
|
#define GET_ERRNO() WSAGetLastError()
|
||||||
#else
|
#else
|
||||||
#define GET_ERRNO() errno
|
#define GET_ERRNO() errno
|
||||||
|
@ -121,7 +121,7 @@
|
|||||||
* Typedef our socket type
|
* Typedef our socket type
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(WATT32)
|
#ifdef USE_WINSOCK
|
||||||
typedef SOCKET ares_socket_t;
|
typedef SOCKET ares_socket_t;
|
||||||
#define ARES_SOCKET_BAD INVALID_SOCKET
|
#define ARES_SOCKET_BAD INVALID_SOCKET
|
||||||
#else
|
#else
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
#define EINPROGRESS WSAEINPROGRESS
|
#define EINPROGRESS WSAEINPROGRESS
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
#define EISCONN WSAEISCONN
|
#define EISCONN WSAEISCONN
|
||||||
@ -121,7 +121,7 @@ singleipconnect(struct connectdata *conn,
|
|||||||
*/
|
*/
|
||||||
int Curl_sockerrno(void)
|
int Curl_sockerrno(void)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
return (int)WSAGetLastError();
|
return (int)WSAGetLastError();
|
||||||
#else
|
#else
|
||||||
return errno;
|
return errno;
|
||||||
|
10
lib/easy.c
10
lib/easy.c
@ -106,7 +106,7 @@
|
|||||||
/* The last #include file should be: */
|
/* The last #include file should be: */
|
||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
|
#ifdef USE_WINSOCK
|
||||||
/* win32_cleanup() is for win32 socket cleanup functionality, the opposite
|
/* win32_cleanup() is for win32 socket cleanup functionality, the opposite
|
||||||
of win32_init() */
|
of win32_init() */
|
||||||
static void win32_cleanup(void)
|
static void win32_cleanup(void)
|
||||||
@ -122,12 +122,12 @@ static CURLcode win32_init(void)
|
|||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#if defined(ENABLE_IPV6) && (USE_WINSOCK < 2)
|
||||||
wVersionRequested = MAKEWORD(2, 0);
|
Error IPV6_requires_winsock2
|
||||||
#else
|
|
||||||
wVersionRequested = MAKEWORD(1, 1);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wVersionRequested = MAKEWORD(USE_WINSOCK, USE_WINSOCK);
|
||||||
|
|
||||||
err = WSAStartup(wVersionRequested, &wsaData);
|
err = WSAStartup(wVersionRequested, &wsaData);
|
||||||
|
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
#define INADDRSZ 4
|
#define INADDRSZ 4
|
||||||
#define INT16SZ 2
|
#define INT16SZ 2
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||||
#define SET_ERRNO(e) WSASetLastError(errno = (e))
|
#define SET_ERRNO(e) WSASetLastError(errno = (e))
|
||||||
#else
|
#else
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#define INADDRSZ 4
|
#define INADDRSZ 4
|
||||||
#define INT16SZ 2
|
#define INT16SZ 2
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
#include "connect.h"
|
#include "connect.h"
|
||||||
#include "select.h"
|
#include "select.h"
|
||||||
|
|
||||||
#if defined(WIN32) || defined(TPF)
|
#if defined(USE_WINSOCK) || defined(TPF)
|
||||||
#define VERIFY_SOCK(x) /* sockets are not in range [0..FD_SETSIZE] */
|
#define VERIFY_SOCK(x) /* sockets are not in range [0..FD_SETSIZE] */
|
||||||
#else
|
#else
|
||||||
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
|
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
|
||||||
@ -224,7 +224,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
for (i = 0; i < nfds; i++) {
|
for (i = 0; i < nfds; i++) {
|
||||||
if (ufds[i].fd == CURL_SOCKET_BAD)
|
if (ufds[i].fd == CURL_SOCKET_BAD)
|
||||||
continue;
|
continue;
|
||||||
#ifndef WIN32 /* This is harmless and wrong on Win32 */
|
#ifndef USE_WINSOCK /* winsock sockets are not in range [0..FD_SETSIZE] */
|
||||||
if (ufds[i].fd >= FD_SETSIZE) {
|
if (ufds[i].fd >= FD_SETSIZE) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -500,7 +500,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
|
|||||||
|
|
||||||
if(-1 == nread && bytestocopy == 0) {
|
if(-1 == nread && bytestocopy == 0) {
|
||||||
int err = Curl_sockerrno();
|
int err = Curl_sockerrno();
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
if(WSAEWOULDBLOCK == err)
|
if(WSAEWOULDBLOCK == err)
|
||||||
#else
|
#else
|
||||||
if((EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err))
|
if((EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err))
|
||||||
|
@ -382,7 +382,7 @@ curl_share_strerror(CURLSHcode error)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
|
|
||||||
/* This function handles most / all (?) Winsock errors cURL is able to produce.
|
/* This function handles most / all (?) Winsock errors cURL is able to produce.
|
||||||
*/
|
*/
|
||||||
@ -570,7 +570,7 @@ get_winsock_error (int err, char *buf, size_t len)
|
|||||||
buf [len-1] = '\0';
|
buf [len-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#endif /* WIN32 */
|
#endif /* USE_WINSOCK */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Our thread-safe and smart strerror() replacement.
|
* Our thread-safe and smart strerror() replacement.
|
||||||
@ -595,7 +595,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||||||
max = sizeof(conn->syserr_buf)-1;
|
max = sizeof(conn->syserr_buf)-1;
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
buf[0]=0;
|
buf[0]=0;
|
||||||
@ -619,7 +619,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||||||
snprintf(buf, max, "Unknown error %d (%#x)", err, err);
|
snprintf(buf, max, "Unknown error %d (%#x)", err, err);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else /* not native Windows coming up */
|
#else /* not USE_WINSOCK coming up */
|
||||||
|
|
||||||
/* These should be atomic and hopefully thread-safe */
|
/* These should be atomic and hopefully thread-safe */
|
||||||
#ifdef HAVE_STRERROR_R
|
#ifdef HAVE_STRERROR_R
|
||||||
@ -647,7 +647,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||||||
#else /* HAVE_STRERROR_R */
|
#else /* HAVE_STRERROR_R */
|
||||||
strncpy(buf, strerror(err), max);
|
strncpy(buf, strerror(err), max);
|
||||||
#endif /* end of HAVE_STRERROR_R */
|
#endif /* end of HAVE_STRERROR_R */
|
||||||
#endif /* end of ! Windows */
|
#endif /* end of ! USE_WINSOCK */
|
||||||
|
|
||||||
buf[max] = '\0'; /* make sure the string is zero terminated */
|
buf[max] = '\0'; /* make sure the string is zero terminated */
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
#define CURL_SB_EOF(x) (x->subpointer >= x->subend)
|
#define CURL_SB_EOF(x) (x->subpointer >= x->subend)
|
||||||
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
|
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
typedef FARPROC WSOCK2_FUNC;
|
typedef FARPROC WSOCK2_FUNC;
|
||||||
static CURLcode check_wsock2 ( struct SessionHandle *data );
|
static CURLcode check_wsock2 ( struct SessionHandle *data );
|
||||||
#endif
|
#endif
|
||||||
@ -171,7 +171,7 @@ struct TELNET {
|
|||||||
TelnetReceive telrcv_state;
|
TelnetReceive telrcv_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
static CURLcode
|
static CURLcode
|
||||||
check_wsock2 ( struct SessionHandle *data )
|
check_wsock2 ( struct SessionHandle *data )
|
||||||
{
|
{
|
||||||
@ -210,6 +210,7 @@ check_wsock2 ( struct SessionHandle *data )
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static
|
static
|
||||||
CURLcode init_telnet(struct connectdata *conn)
|
CURLcode init_telnet(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
@ -1090,7 +1091,7 @@ CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
CURLcode code;
|
CURLcode code;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
|
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
HMODULE wsock2;
|
HMODULE wsock2;
|
||||||
WSOCK2_FUNC close_event_func;
|
WSOCK2_FUNC close_event_func;
|
||||||
WSOCK2_FUNC create_event_func;
|
WSOCK2_FUNC create_event_func;
|
||||||
@ -1125,7 +1126,7 @@ CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
if(code)
|
if(code)
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
/*
|
/*
|
||||||
** This functionality only works with WinSock >= 2.0. So,
|
** This functionality only works with WinSock >= 2.0. So,
|
||||||
** make sure have it.
|
** make sure have it.
|
||||||
|
@ -12,7 +12,7 @@ int test(char *url);
|
|||||||
int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
|
int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
|
||||||
struct timeval *tv)
|
struct timeval *tv)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
/* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is
|
/* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is
|
||||||
* case when 'num_fds <= 0. So sleep.
|
* case when 'num_fds <= 0. So sleep.
|
||||||
*/
|
*/
|
||||||
|
@ -238,7 +238,7 @@ static int juggle(curl_socket_t *sockfdp,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
rc = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
|
rc = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
|
||||||
} while((rc == -1) && (ourerrno() == EINTR));
|
} while((rc == -1) && (our_sockerrno() == EINTR));
|
||||||
|
|
||||||
switch(rc) {
|
switch(rc) {
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -60,13 +60,13 @@ const struct in6_addr in6addr_any = {{ IN6ADDR_ANY_INIT }};
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ourerrno() returns the errno (or equivalent) on this platform to
|
* our_sockerrno() returns the *socket-related* errno (or equivalent) on this
|
||||||
* hide platform specific for the function that calls this.
|
* platform to hide platform specific for the function that calls this.
|
||||||
*/
|
*/
|
||||||
int ourerrno(void)
|
int our_sockerrno(void)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef USE_WINSOCK
|
||||||
return (int)GetLastError();
|
return (int)WSAGetLastError();
|
||||||
#else
|
#else
|
||||||
return errno;
|
return errno;
|
||||||
#endif
|
#endif
|
||||||
@ -115,13 +115,15 @@ void win32_perror (const char *msg)
|
|||||||
fprintf(stderr, "%s: ", msg);
|
fprintf(stderr, "%s: ", msg);
|
||||||
fprintf(stderr, "%s\n", buf);
|
fprintf(stderr, "%s\n", buf);
|
||||||
}
|
}
|
||||||
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
void win32_init(void)
|
void win32_init(void)
|
||||||
{
|
{
|
||||||
WORD wVersionRequested;
|
WORD wVersionRequested;
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
int err;
|
int err;
|
||||||
wVersionRequested = MAKEWORD(2, 0);
|
wVersionRequested = MAKEWORD(USE_WINSOCK, USE_WINSOCK);
|
||||||
|
|
||||||
err = WSAStartup(wVersionRequested, &wsaData);
|
err = WSAStartup(wVersionRequested, &wsaData);
|
||||||
|
|
||||||
@ -131,8 +133,8 @@ void win32_init(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( LOBYTE( wsaData.wVersion ) != 2 ||
|
if ( LOBYTE( wsaData.wVersion ) != USE_WINSOCK ||
|
||||||
HIBYTE( wsaData.wVersion ) != 0 ) {
|
HIBYTE( wsaData.wVersion ) != USE_WINSOCK ) {
|
||||||
|
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
perror("Winsock init failed");
|
perror("Winsock init failed");
|
||||||
@ -145,7 +147,7 @@ void win32_cleanup(void)
|
|||||||
{
|
{
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
}
|
}
|
||||||
#endif /* WIN32 */
|
#endif /* USE_WINSOCK */
|
||||||
|
|
||||||
/* set by the main code to point to where the test dir is */
|
/* set by the main code to point to where the test dir is */
|
||||||
const char *path=".";
|
const char *path=".";
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int ourerrno(void);
|
int our_sockerrno(void);
|
||||||
void logmsg(const char *msg, ...);
|
void logmsg(const char *msg, ...);
|
||||||
|
|
||||||
#ifndef FALSE
|
#ifndef FALSE
|
||||||
@ -44,19 +44,21 @@ extern const char *path;
|
|||||||
|
|
||||||
#define sleep(sec) Sleep ((sec)*1000)
|
#define sleep(sec) Sleep ((sec)*1000)
|
||||||
|
|
||||||
|
#undef perror
|
||||||
|
#define perror(m) win32_perror(m)
|
||||||
|
void win32_perror (const char *msg);
|
||||||
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
#define EINPROGRESS WSAEINPROGRESS
|
#define EINPROGRESS WSAEINPROGRESS
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
#define EISCONN WSAEISCONN
|
#define EISCONN WSAEISCONN
|
||||||
#define ENOTSOCK WSAENOTSOCK
|
#define ENOTSOCK WSAENOTSOCK
|
||||||
#define ECONNREFUSED WSAECONNREFUSED
|
#define ECONNREFUSED WSAECONNREFUSED
|
||||||
|
|
||||||
#undef perror
|
|
||||||
#define perror(m) win32_perror(m)
|
|
||||||
void win32_perror (const char *msg);
|
|
||||||
|
|
||||||
void win32_init(void);
|
void win32_init(void);
|
||||||
void win32_cleanup(void);
|
void win32_cleanup(void);
|
||||||
#endif /* WIN32 */
|
#endif /* USE_WINSOCK */
|
||||||
|
|
||||||
/* returns the path name to the test case file */
|
/* returns the path name to the test case file */
|
||||||
char *test2file(long testno);
|
char *test2file(long testno);
|
||||||
|
Loading…
Reference in New Issue
Block a user