aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2006-10-18 21:05:40 +0000
committerYang Tse <yangsita@gmail.com>2006-10-18 21:05:40 +0000
commit5df4be11657fc49d74e1e6b39c0003f7cf2f3772 (patch)
tree93d2ef65b7accbd9a6572dbfca634dc69e95ffce /lib
parent96445f1b7da2013c294c541530f0160e248b430e (diff)
Check for USE_WINSOCK instead of WIN32 where the check was done
to verify winsock API availability.
Diffstat (limited to 'lib')
-rw-r--r--lib/connect.c4
-rw-r--r--lib/easy.c10
-rw-r--r--lib/inet_ntop.c2
-rw-r--r--lib/inet_pton.c2
-rw-r--r--lib/select.c4
-rw-r--r--lib/sendf.c2
-rw-r--r--lib/strerror.c10
-rw-r--r--lib/telnet.c9
8 files changed, 22 insertions, 21 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 17dddaf87..1ffb98b37 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -84,7 +84,7 @@
#define FALSE 0
#endif
-#ifdef WIN32
+#ifdef USE_WINSOCK
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EISCONN WSAEISCONN
@@ -121,7 +121,7 @@ singleipconnect(struct connectdata *conn,
*/
int Curl_sockerrno(void)
{
-#ifdef WIN32
+#ifdef USE_WINSOCK
return (int)WSAGetLastError();
#else
return errno;
diff --git a/lib/easy.c b/lib/easy.c
index a400f84f1..b2e026326 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -106,7 +106,7 @@
/* The last #include file should be: */
#include "memdebug.h"
-#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
+#ifdef USE_WINSOCK
/* win32_cleanup() is for win32 socket cleanup functionality, the opposite
of win32_init() */
static void win32_cleanup(void)
@@ -122,12 +122,12 @@ static CURLcode win32_init(void)
WSADATA wsaData;
int err;
-#ifdef ENABLE_IPV6
- wVersionRequested = MAKEWORD(2, 0);
-#else
- wVersionRequested = MAKEWORD(1, 1);
+#if defined(ENABLE_IPV6) && (USE_WINSOCK < 2)
+ Error IPV6_requires_winsock2
#endif
+ wVersionRequested = MAKEWORD(USE_WINSOCK, USE_WINSOCK);
+
err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0)
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index 3bbd9eb14..9381963f5 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -55,7 +55,7 @@
#define INADDRSZ 4
#define INT16SZ 2
-#ifdef WIN32
+#ifdef USE_WINSOCK
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#define SET_ERRNO(e) WSASetLastError(errno = (e))
#else
diff --git a/lib/inet_pton.c b/lib/inet_pton.c
index c290330cb..9b9f88b5e 100644
--- a/lib/inet_pton.c
+++ b/lib/inet_pton.c
@@ -44,7 +44,7 @@
#define INADDRSZ 4
#define INT16SZ 2
-#ifdef WIN32
+#ifdef USE_WINSOCK
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif
diff --git a/lib/select.c b/lib/select.c
index 7c2f2624f..b25067b6c 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -50,7 +50,7 @@
#include "connect.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] */
#else
#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++) {
if (ufds[i].fd == CURL_SOCKET_BAD)
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) {
errno = EINVAL;
return -1;
diff --git a/lib/sendf.c b/lib/sendf.c
index c964849d9..e289e2046 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -500,7 +500,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
if(-1 == nread && bytestocopy == 0) {
int err = Curl_sockerrno();
-#ifdef WIN32
+#ifdef USE_WINSOCK
if(WSAEWOULDBLOCK == err)
#else
if((EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err))
diff --git a/lib/strerror.c b/lib/strerror.c
index 5a1a83dd1..62ccfe9a0 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -382,7 +382,7 @@ curl_share_strerror(CURLSHcode error)
#endif
}
-#ifdef WIN32
+#ifdef USE_WINSOCK
/* 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';
return buf;
}
-#endif /* WIN32 */
+#endif /* USE_WINSOCK */
/*
* 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;
*buf = '\0';
-#ifdef WIN32
+#ifdef USE_WINSOCK
#ifdef _WIN32_WCE
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);
}
#endif
-#else /* not native Windows coming up */
+#else /* not USE_WINSOCK coming up */
/* These should be atomic and hopefully thread-safe */
#ifdef HAVE_STRERROR_R
@@ -647,7 +647,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
#else /* HAVE_STRERROR_R */
strncpy(buf, strerror(err), max);
#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 */
diff --git a/lib/telnet.c b/lib/telnet.c
index 34cb8db20..3d3961078 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -102,7 +102,7 @@
#define CURL_SB_EOF(x) (x->subpointer >= x->subend)
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
-#ifdef WIN32
+#ifdef USE_WINSOCK
typedef FARPROC WSOCK2_FUNC;
static CURLcode check_wsock2 ( struct SessionHandle *data );
#endif
@@ -171,7 +171,7 @@ struct TELNET {
TelnetReceive telrcv_state;
};
-#ifdef WIN32
+#ifdef USE_WINSOCK
static CURLcode
check_wsock2 ( struct SessionHandle *data )
{
@@ -210,6 +210,7 @@ check_wsock2 ( struct SessionHandle *data )
return CURLE_OK;
}
#endif
+
static
CURLcode init_telnet(struct connectdata *conn)
{
@@ -1090,7 +1091,7 @@ CURLcode Curl_telnet(struct connectdata *conn, bool *done)
CURLcode code;
struct SessionHandle *data = conn->data;
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
-#ifdef WIN32
+#ifdef USE_WINSOCK
HMODULE wsock2;
WSOCK2_FUNC close_event_func;
WSOCK2_FUNC create_event_func;
@@ -1125,7 +1126,7 @@ CURLcode Curl_telnet(struct connectdata *conn, bool *done)
if(code)
return code;
-#ifdef WIN32
+#ifdef USE_WINSOCK
/*
** This functionality only works with WinSock >= 2.0. So,
** make sure have it.