long timeout_ms,
bool *connected);
-/*
- * Curl_sockerrno() returns the *socket-related* errno (or equivalent) on this
- * platform to hide platform specific for the function that calls this.
- */
-int Curl_sockerrno(void)
-{
-#ifdef USE_WINSOCK
- return (int)WSAGetLastError();
-#else
- return errno;
-#endif
-}
-
/*
* Curl_nonblock() set the given socket to either blocking or non-blocking
* mode based on the 'nonblock' boolean argument. This function is highly
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
data->set.device, strlen(data->set.device)+1) != 0) {
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
- sockfd, data->set.device, Curl_strerror(Curl_sockerrno())); */
+ sockfd, data->set.device, Curl_strerror(SOCKERRNO)); */
infof(data, "SO_BINDTODEVICE %s failed\n",
data->set.device);
/* This is typically "errno 1, error: Operation not permitted" if
break;
} while(1);
- data->state.os_errno = Curl_sockerrno();
+ data->state.os_errno = SOCKERRNO;
failf(data, "bind failure: %s",
Curl_strerror(conn, data->state.os_errno));
return CURLE_HTTP_PORT_FAILED;
if( -1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR,
(void *)&err, &errSize))
- err = Curl_sockerrno();
+ err = SOCKERRNO;
#ifdef _WIN32_WCE
/* Always returns this error, bug in CE? */
#else
(void)sockfd;
if (error)
- *error = Curl_sockerrno();
+ *error = SOCKERRNO;
#endif
return rc;
}
infof(data, "Connection failed\n");
if(trynextip(conn, sockindex, connected)) {
- error = Curl_sockerrno();
+ error = SOCKERRNO;
data->state.os_errno = error;
failf(data, "Failed connect to %s:%d; %s",
conn->host.name, conn->port, Curl_strerror(conn,error));
if(setsockopt(sockfd, proto, TCP_NODELAY, (void *)&onoff,
sizeof(onoff)) < 0)
infof(data, "Could not set TCP_NODELAY: %s\n",
- Curl_strerror(conn, Curl_sockerrno()));
+ Curl_strerror(conn, SOCKERRNO));
else
infof(data,"TCP_NODELAY set\n");
#else
if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff,
sizeof(onoff)) < 0)
infof(data, "Could not set SO_NOSIGPIPE: %s\n",
- Curl_strerror(conn, Curl_sockerrno()));
+ Curl_strerror(conn, SOCKERRNO));
}
#else
#define nosigpipe(x,y)
rc = 0;
if(-1 == rc) {
- error = Curl_sockerrno();
+ error = SOCKERRNO;
switch (error) {
case EINPROGRESS:
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
bool *connected /* truly connected? */
);
-int Curl_sockerrno(void);
-
CURLcode Curl_store_ip_addr(struct connectdata *conn);
#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
/* do the translation ourselves */
char *input_ptr, *output_ptr;
size_t in_bytes, out_bytes, rc;
+ int error;
/* open an iconv conversion descriptor if necessary */
if(data->outbound_cd == (iconv_t)-1) {
data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
CURL_ICONV_CODESET_OF_HOST);
if(data->outbound_cd == (iconv_t)-1) {
+ error = ERRNO;
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_NETWORK,
CURL_ICONV_CODESET_OF_HOST,
- errno, strerror(errno));
+ error, strerror(error));
return CURLE_CONV_FAILED;
}
}
rc = iconv(data->outbound_cd, (const char**)&input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
+ error = ERRNO;
failf(data,
"The Curl_convert_to_network iconv call failed with errno %i: %s",
- errno, strerror(errno));
+ error, strerror(error));
return CURLE_CONV_FAILED;
}
#else
/* do the translation ourselves */
char *input_ptr, *output_ptr;
size_t in_bytes, out_bytes, rc;
+ int error;
/* open an iconv conversion descriptor if necessary */
if(data->inbound_cd == (iconv_t)-1) {
data->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_OF_NETWORK);
if(data->inbound_cd == (iconv_t)-1) {
+ error = ERRNO;
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_OF_NETWORK,
- errno, strerror(errno));
+ error, strerror(error));
return CURLE_CONV_FAILED;
}
}
rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
+ error = ERRNO;
failf(data,
"The Curl_convert_from_network iconv call failed with errno %i: %s",
- errno, strerror(errno));
+ error, strerror(error));
return CURLE_CONV_FAILED;
}
#else
/* do the translation ourselves */
char *input_ptr, *output_ptr;
size_t in_bytes, out_bytes, rc;
+ int error;
/* open an iconv conversion descriptor if necessary */
if(data->utf8_cd == (iconv_t)-1) {
data->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_FOR_UTF8);
if(data->utf8_cd == (iconv_t)-1) {
+ error = ERRNO;
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_FOR_UTF8,
- errno, strerror(errno));
+ error, strerror(error));
return CURLE_CONV_FAILED;
}
}
rc = iconv(data->utf8_cd, (const char**)&input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
+ error = ERRNO;
failf(data,
"The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
- errno, strerror(errno));
+ error, strerror(error));
return CURLE_CONV_FAILED;
}
if (output_ptr < input_ptr) {
case -1: /* select() error, stop reading */
result = CURLE_RECV_ERROR;
failf(data, "FTP response aborted due to select() error: %d",
- Curl_sockerrno());
+ SOCKERRNO);
break;
case 0: /* timeout */
if(Curl_pgrsUpdate(conn))
sslen = sizeof(ss);
if (getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen)) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, Curl_sockerrno()) );
+ Curl_strerror(conn, SOCKERRNO) );
return CURLE_FTP_PORT_FAILED;
}
portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (portsock == CURL_SOCKET_BAD) {
- error = Curl_sockerrno();
+ error = SOCKERRNO;
continue;
}
break;
if (getsockname(conn->sock[FIRSTSOCKET],
(struct sockaddr *)sa, &sslen)) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, Curl_sockerrno()) );
+ Curl_strerror(conn, SOCKERRNO) );
sclose(portsock);
return CURLE_FTP_PORT_FAILED;
}
sslen = sizeof(ss);
if(bind(portsock, (struct sockaddr *)sa, sslen)) {
- failf(data, "bind failed: %s", Curl_strerror(conn, Curl_sockerrno()));
+ failf(data, "bind failed: %s", Curl_strerror(conn, SOCKERRNO));
sclose(portsock);
return CURLE_FTP_PORT_FAILED;
}
sslen = sizeof(ss);
if(getsockname(portsock, (struct sockaddr *)sa, &sslen)) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, Curl_sockerrno()) );
+ Curl_strerror(conn, SOCKERRNO) );
sclose(portsock);
return CURLE_FTP_PORT_FAILED;
}
/* step 4, listen on the socket */
if (listen(portsock, 1)) {
- failf(data, "socket failure: %s", Curl_strerror(conn, Curl_sockerrno()));
+ failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO));
sclose(portsock);
return CURLE_FTP_PORT_FAILED;
}
if (getsockname(conn->sock[FIRSTSOCKET],
(struct sockaddr *)&sa, &sslen)) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, Curl_sockerrno()) );
+ Curl_strerror(conn, SOCKERRNO) );
return CURLE_FTP_PORT_FAILED;
}
if (sslen > (socklen_t)sizeof(sa))
if(getsockname(portsock, (struct sockaddr *) &add,
&socksize)) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, Curl_sockerrno()) );
+ Curl_strerror(conn, SOCKERRNO) );
return CURLE_FTP_PORT_FAILED;
}
porttouse = ntohs(add.sin_port);
}
else {
/* anything that gets here is fatally bad */
- failf(data, "select on SSL socket, errno: %d", Curl_sockerrno());
+ failf(data, "select on SSL socket, errno: %d", SOCKERRNO);
return CURLE_SSL_CONNECT_ERROR;
}
}
}
else {
/* anything that gets here is fatally bad */
- failf(data, "select on SSL socket, errno: %d", Curl_sockerrno());
+ failf(data, "select on SSL socket, errno: %d", SOCKERRNO);
retval = -1;
done = 1;
}
#include "strerror.h"
#include "url.h"
#include "multiif.h"
-#include "connect.h" /* for the Curl_sockerrno() proto */
+#include "connect.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
break;
tvp = ares_timeout(data->state.areschannel, &store, &tv);
count = select(nfds, &read_fds, &write_fds, NULL, tvp);
- if (count < 0 && Curl_sockerrno() != EINVAL)
+ if ((count < 0) && (SOCKERRNO != EINVAL))
break;
ares_process(data->state.areschannel, &read_fds, &write_fds);
(struct hostent *)buf,
(struct hostent_data *)((char *)buf +
sizeof(struct hostent)));
- h_errnop= errno; /* we don't deal with this, but set it anyway */
+ h_errnop = SOCKERRNO; /* we don't deal with this, but set it anyway */
}
else
res = -1; /* failure, too smallish buffer size */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
if (Curl_printable_address(ai, buf, sizeof(buf)))
printf("%s\n", buf);
else
- printf("failed; %s\n", Curl_strerror(conn, Curl_sockerrno()));
+ printf("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
}
}
#else
if (Curl_printable_address(ai, buf, sizeof(buf)))
trace_it("%s\n", buf);
else
- trace_it("failed; %s\n", Curl_strerror(conn,WSAGetLastError()));
+ trace_it("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
}
}
#endif
return (unsigned)-1;
}
- WSASetLastError (conn->async.status = NO_DATA); /* pending status */
+ conn->async.status = NO_DATA; /* pending status */
+ SET_SOCKERRNO(conn->async.status);
/* Signaling that we have initialized all copies of data and handles we
need */
rc = Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he);
}
else {
- rc = Curl_addrinfo4_callback(conn, (int)WSAGetLastError(), NULL);
+ rc = Curl_addrinfo4_callback(conn, SOCKERRNO, NULL);
}
TRACE(("Winsock-error %d, addr %s\n", conn->async.status,
he ? inet_ntoa(*(struct in_addr*)he->h_addr) : "unknown"));
itoa(conn->async.port, service, 10);
- WSASetLastError(conn->async.status = NO_DATA); /* pending status */
+ conn->async.status = NO_DATA; /* pending status */
+ SET_SOCKERRNO(conn->async.status);
/* Signaling that we have initialized all copies of data and handles we
need */
rc = Curl_addrinfo6_callback(conn, CURL_ASYNC_SUCCESS, res);
}
else {
- rc = Curl_addrinfo6_callback(conn, (int)WSAGetLastError(), NULL);
+ rc = Curl_addrinfo6_callback(conn, SOCKERRNO, NULL);
TRACE(("Winsock-error %d, no address\n", conn->async.status));
}
release_thread_sync(&tsd);
HANDLE thread_and_event[2] = {0};
if (!td) {
- SetLastError(ENOMEM);
+ SET_ERRNO(ENOMEM);
return FALSE;
}
conn->async.hostname = strdup(hostname);
if (!conn->async.hostname) {
free(td);
- SetLastError(ENOMEM);
+ SET_ERRNO(ENOMEM);
return FALSE;
}
td->mutex_waiting = CreateMutex(NULL, TRUE, NULL);
if (td->mutex_waiting == NULL) {
Curl_destroy_thread_data(&conn->async);
- SetLastError(EAGAIN);
+ SET_ERRNO(EAGAIN);
return FALSE;
}
td->event_resolved = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_resolved == NULL) {
Curl_destroy_thread_data(&conn->async);
- SetLastError(EAGAIN);
+ SET_ERRNO(EAGAIN);
return FALSE;
}
/* Create the mutex used to serialize access to event_terminated
td->mutex_terminate = CreateMutex(NULL, FALSE, NULL);
if (td->mutex_terminate == NULL) {
Curl_destroy_thread_data(&conn->async);
- SetLastError(EAGAIN);
+ SET_ERRNO(EAGAIN);
return FALSE;
}
/* Create the event used to signal thread that it should terminate.
td->event_terminate = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_terminate == NULL) {
Curl_destroy_thread_data(&conn->async);
- SetLastError(EAGAIN);
+ SET_ERRNO(EAGAIN);
return FALSE;
}
/* Create the event used by thread to inform it has initialized its own data.
td->event_thread_started = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_thread_started == NULL) {
Curl_destroy_thread_data(&conn->async);
- SetLastError(EAGAIN);
+ SET_ERRNO(EAGAIN);
return FALSE;
}
if (!td->thread_hnd) {
#ifdef _WIN32_WCE
- TRACE(("CreateThread() failed; %s\n", Curl_strerror(conn,GetLastError())));
+ TRACE(("CreateThread() failed; %s\n", Curl_strerror(conn, ERRNO)));
#else
- SetLastError(errno);
- TRACE(("_beginthreadex() failed; %s\n", Curl_strerror(conn,errno)));
+ SET_ERRNO(errno);
+ TRACE(("_beginthreadex() failed; %s\n", Curl_strerror(conn, ERRNO)));
#endif
Curl_destroy_thread_data(&conn->async);
return FALSE;
* thread. 'conn->async.done = TRUE' is set in
* Curl_addrinfo4/6_callback().
*/
- WSASetLastError(conn->async.status);
+ SET_SOCKERRNO(conn->async.status);
GetExitCodeThread(td->thread_hnd, &td->thread_status);
TRACE(("%s() status %lu, thread retval %lu, ",
THREAD_NAME, status, td->thread_status));
/* fall-back to blocking version */
infof(data, "init_resolve_thread() failed for %s; %s\n",
- hostname, Curl_strerror(conn,GetLastError()));
+ hostname, Curl_strerror(conn, ERRNO));
h = gethostbyname(hostname);
if (!h) {
infof(data, "gethostbyname(2) failed for %s:%d; %s\n",
- hostname, port, Curl_strerror(conn,WSAGetLastError()));
+ hostname, port, Curl_strerror(conn, SOCKERRNO));
return NULL;
}
return Curl_he2ai(h, port);
/* fall-back to blocking version */
infof(data, "init_resolve_thread() failed for %s; %s\n",
- hostname, Curl_strerror(conn,GetLastError()));
+ hostname, Curl_strerror(conn, ERRNO));
error = getaddrinfo(hostname, sbuf, &hints, &res);
if (error) {
infof(data, "getaddrinfo() failed for %s:%d; %s\n",
- hostname, port, Curl_strerror(conn,WSAGetLastError()));
+ hostname, port, Curl_strerror(conn, SOCKERRNO));
return NULL;
}
return res;
* 1 if the address was valid for the specified address family
* 0 if the address wasn't valid (`dst' is untouched in this case)
* -1 if some other error occurred (`dst' is untouched in this case, too)
+ * notice:
+ * On Windows we store the error in the thread errno, not
+ * in the winsock error code. This is to avoid loosing the
+ * actual last winsock error. So use macro ERRNO to fetch the
+ * errno this funtion sets when returning (-1), not SOCKERRNO.
* author:
* Paul Vixie, 1996.
*/
return (inet_pton6(src, (unsigned char *)dst));
#endif
default:
- errno = EAFNOSUPPORT;
+ SET_ERRNO(EAFNOSUPPORT);
return (-1);
}
/* NOTREACHED */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
if(source)
fprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
source, line, func);
- errno = ENOMEM;
+ SET_ERRNO(ENOMEM);
return TRUE; /* RETURN ERROR! */
}
else
#include "sendf.h"
#include "formdata.h" /* for the boundary function */
#include "url.h" /* for the ssl config check function */
-#include "connect.h" /* Curl_sockerrno() proto */
+#include "connect.h"
#include "strequal.h"
#include "select.h"
#include "sslgen.h"
#include "connect.h"
#include "select.h"
+/* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1] */
+
#if defined(USE_WINSOCK) || defined(TPF)
-#define VERIFY_SOCK(x) /* sockets are not in range [0..FD_SETSIZE] */
+#define VERIFY_SOCK(x) do { } while (0)
#else
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
#define VERIFY_SOCK(x) do { \
if(!VALID_SOCK(x)) { \
- errno = EINVAL; \
+ SET_SOCKERRNO(EINVAL); \
return -1; \
} \
} while(0)
num++;
}
-#ifdef HAVE_POLL_FINE
do {
- r = poll(pfd, num, timeout_ms);
- } while((r == -1) && (errno == EINTR));
+#ifdef CURL_HAVE_WSAPOLL
+ r = WSAPoll(pfd, num, timeout_ms);
#else
- r = WSAPoll(pfd, num, timeout_ms);
+ r = poll(pfd, num, timeout_ms);
#endif
+ } while((r == -1) && (SOCKERRNO == EINTR));
if (r < 0)
return -1;
if (pfd[num].revents & POLLERR) {
#ifdef __CYGWIN__
/* Cygwin 1.5.21 needs this hack to pass test 160 */
- if (errno == EINPROGRESS)
+ if (ERRNO == EINPROGRESS)
ret |= CSELECT_IN;
else
#endif
do {
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
- } while((r == -1) && (Curl_sockerrno() == EINTR));
+ } while((r == -1) && (SOCKERRNO == EINTR));
if (r < 0)
return -1;
int r;
#ifdef HAVE_POLL_FINE
do {
- r = poll(ufds, nfds, timeout_ms);
- } while((r == -1) && (errno == EINTR));
-#elif defined(CURL_HAVE_WSAPOLL)
- r = WSAPoll(ufds, nfds, timeout_ms);
+#ifdef CURL_HAVE_WSAPOLL
+ r = WSAPoll(ufds, nfds, timeout_ms);
#else
+ r = poll(ufds, nfds, timeout_ms);
+#endif
+ } while((r == -1) && (SOCKERRNO == EINTR));
+#else /* HAVE_POLL_FINE */
struct timeval timeout;
struct timeval *ptimeout;
fd_set fds_read;
for (i = 0; i < nfds; i++) {
if (ufds[i].fd == CURL_SOCKET_BAD)
continue;
-#ifndef USE_WINSOCK /* winsock sockets are not in range [0..FD_SETSIZE] */
+#if !defined(USE_WINSOCK) && !defined(TPF)
+ /* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1] */
if (ufds[i].fd >= FD_SETSIZE) {
- errno = EINVAL;
+ SET_SOCKERRNO(EINVAL);
return -1;
}
#endif
do {
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
- } while((r == -1) && (Curl_sockerrno() == EINTR));
+ } while((r == -1) && (SOCKERRNO == EINTR));
if (r < 0)
return -1;
if (ufds[i].revents != 0)
r++;
}
-#endif
+#endif /* HAVE_POLL_FINE */
return r;
}
#include <curl/curl.h>
#include "urldata.h"
#include "sendf.h"
-#include "connect.h" /* for the Curl_sockerrno() proto */
+#include "connect.h"
#include "sslgen.h"
#include "ssh.h"
#include "multiif.h"
ssize_t bytes_written = swrite(sockfd, mem, len);
if(-1 == bytes_written) {
- int err = Curl_sockerrno();
+ int err = SOCKERRNO;
if(
#ifdef WSAEWOULDBLOCK
nread = sread(sockfd, buffertofill, bytesfromsocket);
if(-1 == nread) {
- int err = Curl_sockerrno();
+ int err = SOCKERRNO;
#ifdef USE_WINSOCK
if(WSAEWOULDBLOCK == err)
#else
#include "url.h" /* for the ssl config check function */
#include "inet_pton.h"
#include "ssluse.h"
-#include "connect.h" /* Curl_sockerrno() proto */
+#include "connect.h"
#include "strequal.h"
#include "select.h"
#include "sslgen.h"
sslerror = ERR_get_error();
failf(conn->data, "SSL read: %s, errno %d",
ERR_error_string(sslerror, buf),
- Curl_sockerrno() );
+ SOCKERRNO);
done = 1;
break;
}
}
else {
/* anything that gets here is fatally bad */
- failf(data, "select on SSL socket, errno: %d", Curl_sockerrno());
+ failf(data, "select on SSL socket, errno: %d", SOCKERRNO);
retval = -1;
done = 1;
}
}
else {
/* anything that gets here is fatally bad */
- failf(data, "select on SSL socket, errno: %d", Curl_sockerrno());
+ failf(data, "select on SSL socket, errno: %d", SOCKERRNO);
return CURLE_SSL_CONNECT_ERROR;
}
} /* while()-loop for the select() */
return 0;
case SSL_ERROR_SYSCALL:
failf(conn->data, "SSL_write() returned SYSCALL, errno = %d\n",
- Curl_sockerrno());
+ SOCKERRNO);
return -1;
case SSL_ERROR_SSL:
/* A failure in the SSL library occurred, usually a protocol error.
sslerror = ERR_get_error();
failf(conn->data, "SSL read: %s, errno %d",
ERR_error_string(sslerror, error_buffer),
- Curl_sockerrno() );
+ SOCKERRNO);
return -1;
}
}
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
else
value = CURL_LLONG_MAX;
- errno = ERANGE;
+ SET_ERRNO(ERANGE);
}
if (endptr)
bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
if(bytes_written < 0) {
- err = Curl_sockerrno();
+ err = SOCKERRNO;
failf(data,"Sending data failed (%d)",err);
}
CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, CURL_SE);
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
if(bytes_written < 0) {
- err = Curl_sockerrno();
+ err = SOCKERRNO;
failf(data,"Sending data failed (%d)",err);
}
printsub(data, '>', &temp[2], len-2);
CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, CURL_SE);
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
if(bytes_written < 0) {
- err = Curl_sockerrno();
+ err = SOCKERRNO;
failf(data,"Sending data failed (%d)",err);
}
printsub(data, '>', &temp[2], len-2);
len += 2;
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
if(bytes_written < 0) {
- err = Curl_sockerrno();
+ err = SOCKERRNO;
failf(data,"Sending data failed (%d)",err);
}
printsub(data, '>', &temp[2], len-2);
/* load ws2_32.dll and get the function pointers we need. */
wsock2 = LoadLibrary("WS2_32.DLL");
if (wsock2 == NULL) {
- failf(data,"failed to load WS2_32.DLL (%d)",GetLastError());
+ failf(data,"failed to load WS2_32.DLL (%d)", ERRNO);
return CURLE_FAILED_INIT;
}
create_event_func = GetProcAddress(wsock2,"WSACreateEvent");
if (create_event_func == NULL) {
failf(data,"failed to find WSACreateEvent function (%d)",
- GetLastError());
+ ERRNO);
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
close_event_func = GetProcAddress(wsock2,"WSACloseEvent");
if (close_event_func == NULL) {
failf(data,"failed to find WSACloseEvent function (%d)",
- GetLastError());
+ ERRNO);
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
event_select_func = GetProcAddress(wsock2,"WSAEventSelect");
if (event_select_func == NULL) {
failf(data,"failed to find WSAEventSelect function (%d)",
- GetLastError());
+ ERRNO);
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
enum_netevents_func = GetProcAddress(wsock2,"WSAEnumNetworkEvents");
if (enum_netevents_func == NULL) {
failf(data,"failed to find WSAEnumNetworkEvents function (%d)",
- GetLastError());
+ ERRNO);
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
/* First, create a sockets event object */
event_handle = (WSAEVENT)create_event_func();
if (event_handle == WSA_INVALID_EVENT) {
- failf(data,"WSACreateEvent failed (%d)",WSAGetLastError());
+ failf(data,"WSACreateEvent failed (%d)", SOCKERRNO);
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
/* We called WSACreateEvent, so call WSACloseEvent */
if (close_event_func(event_handle) == FALSE) {
- infof(data,"WSACloseEvent failed (%d)",WSAGetLastError());
+ infof(data,"WSACloseEvent failed (%d)", SOCKERRNO);
}
/* "Forget" pointers into the library we're about to free */
/* We called LoadLibrary, so call FreeLibrary */
if (!FreeLibrary(wsock2))
- infof(data,"FreeLibrary(wsock2) failed (%d)",GetLastError());
+ infof(data,"FreeLibrary(wsock2) failed (%d)", ERRNO);
#else
pfd[0].fd = sockfd;
pfd[0].events = POLLIN;
state->conn->ip_addr->ai_addr,
state->conn->ip_addr->ai_addrlen);
if(sbytes < 0) {
- failf(data, "%s\n", Curl_strerror(state->conn, Curl_sockerrno()));
+ failf(data, "%s\n", Curl_strerror(state->conn, SOCKERRNO));
}
Curl_safefree(filename);
break;
(struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
if(sbytes < 0) {
- failf(data, "%s\n", Curl_strerror(state->conn, Curl_sockerrno()));
+ failf(data, "%s\n", Curl_strerror(state->conn, SOCKERRNO));
}
/* Check if completed (That is, a less than full packet is received) */
state->remote_addrlen);
/* Check all sbytes were sent */
if(sbytes<0) {
- failf(data, "%s\n", Curl_strerror(state->conn, Curl_sockerrno()));
+ failf(data, "%s\n", Curl_strerror(state->conn, SOCKERRNO));
}
}
break;
state->remote_addrlen);
/* Check all sbytes were sent */
if(sbytes<0) {
- failf(data, "%s\n", Curl_strerror(state->conn, Curl_sockerrno()));
+ failf(data, "%s\n", Curl_strerror(state->conn, SOCKERRNO));
res = CURLE_SEND_ERROR;
}
}
state->remote_addrlen);
/* Check all sbytes were sent */
if(sbytes<0) {
- failf(data, "%s\n", Curl_strerror(state->conn, Curl_sockerrno()));
+ failf(data, "%s\n", Curl_strerror(state->conn, SOCKERRNO));
}
break;
state->remote_addrlen);
/* Check all sbytes were sent */
if(sbytes<0) {
- failf(data, "%s\n", Curl_strerror(state->conn, Curl_sockerrno()));
+ failf(data, "%s\n", Curl_strerror(state->conn, SOCKERRNO));
}
}
break;
conn->ip_addr->ai_addrlen);
if(rc) {
failf(conn->data, "bind() failed; %s\n",
- Curl_strerror(conn, Curl_sockerrno()));
+ Curl_strerror(conn, SOCKERRNO));
return CURLE_COULDNT_CONNECT;
}
}
if(rc == -1) {
/* bail out */
- int error = Curl_sockerrno();
+ int error = SOCKERRNO;
failf(data, "%s\n", Curl_strerror(conn, error));
event = TFTP_EVENT_ERROR;
}
#ifdef EINTR
/* The EINTR is not serious, and it seems you might get this more
ofen when using the lib in a multi-threaded environment! */
- if(errno == EINTR)
+ if(SOCKERRNO == EINTR)
;
else
#endif
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
void win32_perror (const char *msg)
{
char buf[256];
- DWORD err = WSAGetLastError();
+ DWORD err = SOCKERRNO;
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
LANG_NEUTRAL, buf, sizeof(buf), NULL))
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms