mirror of
https://github.com/curl/curl.git
synced 2026-08-24 13:03:35 +03:00
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
16 changed files with 49 additions and 44 deletions
|
|
@ -12,7 +12,7 @@ int test(char *url);
|
|||
int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
|
||||
struct timeval *tv)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#ifdef USE_WINSOCK
|
||||
/* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is
|
||||
* case when 'num_fds <= 0. So sleep.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ static int juggle(curl_socket_t *sockfdp,
|
|||
|
||||
do {
|
||||
rc = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
|
||||
} while((rc == -1) && (ourerrno() == EINTR));
|
||||
} while((rc == -1) && (our_sockerrno() == EINTR));
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
|
|
|
|||
|
|
@ -60,13 +60,13 @@ const struct in6_addr in6addr_any = {{ IN6ADDR_ANY_INIT }};
|
|||
#endif
|
||||
|
||||
/*
|
||||
* ourerrno() returns the errno (or equivalent) on this platform to
|
||||
* hide platform specific for the function that calls this.
|
||||
* our_sockerrno() returns the *socket-related* errno (or equivalent) on this
|
||||
* platform to hide platform specific for the function that calls this.
|
||||
*/
|
||||
int ourerrno(void)
|
||||
int our_sockerrno(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return (int)GetLastError();
|
||||
#ifdef USE_WINSOCK
|
||||
return (int)WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
|
|
@ -115,13 +115,15 @@ void win32_perror (const char *msg)
|
|||
fprintf(stderr, "%s: ", msg);
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
void win32_init(void)
|
||||
{
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
wVersionRequested = MAKEWORD(2, 0);
|
||||
wVersionRequested = MAKEWORD(USE_WINSOCK, USE_WINSOCK);
|
||||
|
||||
err = WSAStartup(wVersionRequested, &wsaData);
|
||||
|
||||
|
|
@ -131,8 +133,8 @@ void win32_init(void)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if ( LOBYTE( wsaData.wVersion ) != 2 ||
|
||||
HIBYTE( wsaData.wVersion ) != 0 ) {
|
||||
if ( LOBYTE( wsaData.wVersion ) != USE_WINSOCK ||
|
||||
HIBYTE( wsaData.wVersion ) != USE_WINSOCK ) {
|
||||
|
||||
WSACleanup();
|
||||
perror("Winsock init failed");
|
||||
|
|
@ -145,7 +147,7 @@ void win32_cleanup(void)
|
|||
{
|
||||
WSACleanup();
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* USE_WINSOCK */
|
||||
|
||||
/* set by the main code to point to where the test dir is */
|
||||
const char *path=".";
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
* $Id$
|
||||
***************************************************************************/
|
||||
|
||||
int ourerrno(void);
|
||||
int our_sockerrno(void);
|
||||
void logmsg(const char *msg, ...);
|
||||
|
||||
#ifndef FALSE
|
||||
|
|
@ -44,19 +44,21 @@ extern const char *path;
|
|||
|
||||
#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 EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define EISCONN WSAEISCONN
|
||||
#define ENOTSOCK WSAENOTSOCK
|
||||
#define ECONNREFUSED WSAECONNREFUSED
|
||||
|
||||
#undef perror
|
||||
#define perror(m) win32_perror(m)
|
||||
void win32_perror (const char *msg);
|
||||
|
||||
void win32_init(void);
|
||||
void win32_cleanup(void);
|
||||
#endif /* WIN32 */
|
||||
#endif /* USE_WINSOCK */
|
||||
|
||||
/* returns the path name to the test case file */
|
||||
char *test2file(long testno);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue