aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2013-01-09 15:10:23 +0100
committerYang Tse <yangsita@gmail.com>2013-01-09 22:23:50 +0100
commita6848250d279026252aa35cd9f93fafccc76333c (patch)
tree6cec3bacd94bd87c52b9e4bd3b73fe47704fbd3d
parenta9ca5e61e533def9e430597e36d70e96aee8e27a (diff)
test servers: fix errno, ERRNO and SOCKERRNO usage for W32/W64
-rw-r--r--tests/server/fake_ntlm.c10
-rw-r--r--tests/server/rtspd.c45
-rw-r--r--tests/server/sockfilt.c45
-rw-r--r--tests/server/sws.c47
-rw-r--r--tests/server/tftpd.c20
-rw-r--r--tests/server/util.c23
6 files changed, 112 insertions, 78 deletions
diff --git a/tests/server/fake_ntlm.c b/tests/server/fake_ntlm.c
index 64f0675e7..799f573af 100644
--- a/tests/server/fake_ntlm.c
+++ b/tests/server/fake_ntlm.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010, Mandy Wu, <mandy.wu@intel.com>
- * Copyright (C) 2011 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2013, 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
@@ -184,7 +184,7 @@ int main(int argc, char *argv[])
filename = test2file(testnum);
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", testnum);
@@ -202,7 +202,7 @@ int main(int argc, char *argv[])
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", testnum);
@@ -222,7 +222,7 @@ int main(int argc, char *argv[])
if(strcmp(buf, type1_input) == 0) {
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", testnum);
@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
else if(strncmp(buf, type3_input, strlen(type3_input)) == 0) {
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", testnum);
diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c
index 3c55eff35..294dc700d 100644
--- a/tests/server/rtspd.c
+++ b/tests/server/rtspd.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, 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
@@ -54,6 +54,13 @@
/* include memdebug.h last */
#include "memdebug.h"
+#ifdef USE_WINSOCK
+#undef EINTR
+#define EINTR 4 /* errno.h value */
+#undef ERANGE
+#define ERANGE 34 /* errno.h value */
+#endif
+
#ifdef ENABLE_IPV6
static bool use_ipv6 = FALSE;
#endif
@@ -236,13 +243,13 @@ static volatile int exit_signal = 0;
static RETSIGTYPE exit_signal_handler(int signum)
{
- int old_errno = ERRNO;
+ int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
- SET_ERRNO(old_errno);
+ errno = old_errno;
}
static void install_signal_handlers(void)
@@ -250,29 +257,29 @@ static void install_signal_handlers(void)
#ifdef SIGHUP
/* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGHUP handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif
#ifdef SIGPIPE
/* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGPIPE handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif
#ifdef SIGALRM
/* ignore SIGALRM signal */
if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGALRM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGALRM handler: %s", strerror(errno));
#endif
#ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGINT handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGINT handler: %s", strerror(errno));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGTERM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else
siginterrupt(SIGTERM, 1);
#endif
@@ -395,7 +402,7 @@ static int ProcessRequest(struct httprequest *req)
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", req->testno);
@@ -575,9 +582,9 @@ static int ProcessRequest(struct httprequest *req)
while(*ptr && ISSPACE(*ptr))
ptr++;
endptr = ptr;
- SET_ERRNO(0);
+ errno = 0;
clen = strtoul(ptr, &endptr, 10);
- if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == ERRNO)) {
+ if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == errno)) {
/* this assumes that a zero Content-Length is valid */
logmsg("Found invalid Content-Length: (%s) in the request", ptr);
req->open = FALSE; /* closes connection */
@@ -709,7 +716,7 @@ static void storerequest(char *reqbuf, size_t totalsize)
do {
dump = fopen(REQUEST_DUMP, "ab");
- } while ((dump == NULL) && ((error = ERRNO) == EINTR));
+ } while ((dump == NULL) && ((error = errno) == EINTR));
if (dump == NULL) {
logmsg("Error opening file %s error: %d %s",
REQUEST_DUMP, error, strerror(error));
@@ -725,7 +732,7 @@ static void storerequest(char *reqbuf, size_t totalsize)
goto storerequest_cleanup;
if(written > 0)
writeleft -= written;
- } while ((writeleft > 0) && ((error = ERRNO) == EINTR));
+ } while ((writeleft > 0) && ((error = errno) == EINTR));
if(writeleft == 0)
logmsg("Wrote request (%zu bytes) input to " REQUEST_DUMP, totalsize);
@@ -740,7 +747,7 @@ storerequest_cleanup:
do {
res = fclose(dump);
- } while(res && ((error = ERRNO) == EINTR));
+ } while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
REQUEST_DUMP, error, strerror(error));
@@ -954,7 +961,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
@@ -979,7 +986,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
/* re-open the same file again */
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
@@ -1024,7 +1031,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
dump = fopen(RESPONSE_DUMP, "ab");
if(!dump) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", RESPONSE_DUMP);
logmsg("couldn't create logfile: " RESPONSE_DUMP);
@@ -1082,7 +1089,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
do {
res = fclose(dump);
- } while(res && ((error = ERRNO) == EINTR));
+ } while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
RESPONSE_DUMP, error, strerror(error));
@@ -1128,7 +1135,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
break;
if(res) {
/* should not happen */
- error = SOCKERRNO;
+ error = errno;
logmsg("wait_ms() failed with error: (%d) %s",
error, strerror(error));
break;
diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c
index 44d2a0167..911285348 100644
--- a/tests/server/sockfilt.c
+++ b/tests/server/sockfilt.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, 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
@@ -109,6 +109,17 @@
/* include memdebug.h last */
#include "memdebug.h"
+#ifdef USE_WINSOCK
+#undef EINTR
+#define EINTR 4 /* errno.h value */
+#undef EAGAIN
+#define EAGAIN 11 /* errno.h value */
+#undef ENOMEM
+#define ENOMEM 12 /* errno.h value */
+#undef EINVAL
+#define EINVAL 22 /* errno.h value */
+#endif
+
#define DEFAULT_PORT 8999
#ifndef DEFAULT_LOGFILE
@@ -178,13 +189,13 @@ static volatile int exit_signal = 0;
static RETSIGTYPE exit_signal_handler(int signum)
{
- int old_errno = ERRNO;
+ int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
- SET_ERRNO(old_errno);
+ errno = old_errno;
}
static void install_signal_handlers(void)
@@ -192,29 +203,29 @@ static void install_signal_handlers(void)
#ifdef SIGHUP
/* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGHUP handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif
#ifdef SIGPIPE
/* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGPIPE handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif
#ifdef SIGALRM
/* ignore SIGALRM signal */
if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGALRM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGALRM handler: %s", strerror(errno));
#endif
#ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGINT handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGINT handler: %s", strerror(errno));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGTERM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else
siginterrupt(SIGTERM, 1);
#endif
@@ -266,7 +277,7 @@ static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
}
if(rc < 0) {
- error = ERRNO;
+ error = errno;
if((error == EINTR) || (error == EAGAIN))
continue;
logmsg("unrecoverable read() failure: (%d) %s",
@@ -311,7 +322,7 @@ static ssize_t fullwrite(int filedes, const void *buffer, size_t nbytes)
}
if(wc < 0) {
- error = ERRNO;
+ error = errno;
if((error == EINTR) || (error == EAGAIN))
continue;
logmsg("unrecoverable write() failure: (%d) %s",
@@ -435,7 +446,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
/* check if the input value is valid */
if(nfds < 0) {
- SET_SOCKERRNO(EINVAL);
+ errno = EINVAL;
return -1;
}
@@ -448,28 +459,28 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
/* allocate internal array for the original input handles */
fdarr = malloc(nfds * sizeof(curl_socket_t));
if(fdarr == NULL) {
- SET_SOCKERRNO(ENOMEM);
+ errno = ENOMEM;
return -1;
}
/* allocate internal array for the internal event handles */
handles = malloc(nfds * sizeof(HANDLE));
if(handles == NULL) {
- SET_SOCKERRNO(ENOMEM);
+ errno = ENOMEM;
return -1;
}
/* allocate internal array for the internal socket handles */
wsasocks = malloc(nfds * sizeof(curl_socket_t));
if(wsasocks == NULL) {
- SET_SOCKERRNO(ENOMEM);
+ errno = ENOMEM;
return -1;
}
/* allocate internal array for the internal WINSOCK2 events */
wsaevents = malloc(nfds * sizeof(WSAEVENT));
if(wsaevents == NULL) {
- SET_SOCKERRNO(ENOMEM);
+ errno = ENOMEM;
return -1;
}
@@ -743,7 +754,7 @@ static bool juggle(curl_socket_t *sockfdp,
return FALSE;
}
- } while((rc == -1) && ((error = SOCKERRNO) == EINTR));
+ } while((rc == -1) && ((error = errno) == EINTR));
if(rc < 0) {
logmsg("select() failed with error: (%d) %s",
@@ -933,7 +944,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
rc = wait_ms(delay);
if(rc) {
/* should not happen */
- error = SOCKERRNO;
+ error = errno;
logmsg("wait_ms() failed with error: (%d) %s",
error, strerror(error));
sclose(sock);
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 44d899fd7..6d478c76c 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, 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
@@ -56,6 +56,15 @@
/* include memdebug.h last */
#include "memdebug.h"
+#ifdef USE_WINSOCK
+#undef EINTR
+#define EINTR 4 /* errno.h value */
+#undef EAGAIN
+#define EAGAIN 11 /* errno.h value */
+#undef ERANGE
+#define ERANGE 34 /* errno.h value */
+#endif
+
#ifdef ENABLE_IPV6
static bool use_ipv6 = FALSE;
#endif
@@ -239,13 +248,13 @@ static volatile int exit_signal = 0;
static RETSIGTYPE exit_signal_handler(int signum)
{
- int old_errno = ERRNO;
+ int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
- SET_ERRNO(old_errno);
+ errno = old_errno;
}
static void install_signal_handlers(void)
@@ -253,29 +262,29 @@ static void install_signal_handlers(void)
#ifdef SIGHUP
/* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGHUP handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif
#ifdef SIGPIPE
/* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGPIPE handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif
#ifdef SIGALRM
/* ignore SIGALRM signal */
if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGALRM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGALRM handler: %s", strerror(errno));
#endif
#ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGINT handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGINT handler: %s", strerror(errno));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGTERM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else
siginterrupt(SIGTERM, 1);
#endif
@@ -316,7 +325,7 @@ static int parse_servercmd(struct httprequest *req)
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", req->testno);
@@ -617,9 +626,9 @@ static int ProcessRequest(struct httprequest *req)
while(*ptr && ISSPACE(*ptr))
ptr++;
endptr = ptr;
- SET_ERRNO(0);
+ errno = 0;
clen = strtoul(ptr, &endptr, 10);
- if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == ERRNO)) {
+ if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == errno)) {
/* this assumes that a zero Content-Length is valid */
logmsg("Found invalid Content-Length: (%s) in the request", ptr);
req->open = FALSE; /* closes connection */
@@ -756,7 +765,7 @@ static void storerequest(char *reqbuf, size_t totalsize)
do {
dump = fopen(dumpfile, "ab");
- } while ((dump == NULL) && ((error = ERRNO) == EINTR));
+ } while ((dump == NULL) && ((error = errno) == EINTR));
if (dump == NULL) {
logmsg("Error opening file %s error: %d %s",
dumpfile, error, strerror(error));
@@ -772,7 +781,7 @@ static void storerequest(char *reqbuf, size_t totalsize)
goto storerequest_cleanup;
if(written > 0)
writeleft -= written;
- } while ((writeleft > 0) && ((error = ERRNO) == EINTR));
+ } while ((writeleft > 0) && ((error = errno) == EINTR));
if(writeleft == 0)
logmsg("Wrote request (%zu bytes) input to %s", totalsize, dumpfile);
@@ -787,7 +796,7 @@ storerequest_cleanup:
do {
res = fclose(dump);
- } while(res && ((error = ERRNO) == EINTR));
+ } while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
dumpfile, error, strerror(error));
@@ -1020,7 +1029,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
@@ -1045,7 +1054,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
/* re-open the same file again */
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
@@ -1090,7 +1099,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
dump = fopen(responsedump, "ab");
if(!dump) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", responsedump);
if(ptr)
@@ -1134,7 +1143,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
do {
res = fclose(dump);
- } while(res && ((error = ERRNO) == EINTR));
+ } while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
responsedump, error, strerror(error));
@@ -1178,7 +1187,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
res = wait_ms(250);
if(res) {
/* should not happen */
- error = SOCKERRNO;
+ error = errno;
logmsg("wait_ms() failed with error: (%d) %s",
error, strerror(error));
break;
diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c
index e8c3c2d82..15c92778f 100644
--- a/tests/server/tftpd.c
+++ b/tests/server/tftpd.c
@@ -365,13 +365,13 @@ static void justtimeout(int signum)
static RETSIGTYPE exit_signal_handler(int signum)
{
- int old_errno = ERRNO;
+ int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
- SET_ERRNO(old_errno);
+ errno = old_errno;
}
static void install_signal_handlers(void)
@@ -379,24 +379,24 @@ static void install_signal_handlers(void)
#ifdef SIGHUP
/* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGHUP handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif
#ifdef SIGPIPE
/* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGPIPE handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif
#ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGINT handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGINT handler: %s", strerror(errno));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGTERM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else
siginterrupt(SIGTERM, 1);
#endif
@@ -953,7 +953,7 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
/* Open request dump file. */
server = fopen(REQUEST_DUMP, "ab");
if(!server) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", REQUEST_DUMP);
return -1;
@@ -1071,7 +1071,7 @@ static int validate_access(struct testcase *test,
if(file) {
FILE *stream=fopen(file, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", file);
logmsg("Couldn't open test file: %s", file);
@@ -1123,7 +1123,7 @@ static void sendtftp(struct testcase *test, struct formats *pf)
do {
size = readit(test, &sdp, pf->f_convert);
if (size < 0) {
- nak(ERRNO + 100);
+ nak(errno + 100);
return;
}
sdp->th_opcode = htons((unsigned short)opcode_DATA);
@@ -1234,7 +1234,7 @@ send_ack:
size = writeit(test, &rdp, (int)(n - 4), pf->f_convert);
if (size != (n-4)) { /* ahem */
if (size < 0)
- nak(ERRNO + 100);
+ nak(errno + 100);
else
nak(ENOSPACE);
goto abort;
diff --git a/tests/server/util.c b/tests/server/util.c
index 30766d80f..06f3ce10d 100644
--- a/tests/server/util.c
+++ b/tests/server/util.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, 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
@@ -48,6 +48,13 @@
#include "util.h"
#include "timeval.h"
+#ifdef USE_WINSOCK
+#undef EINTR
+#define EINTR 4 /* errno.h value */
+#undef EINVAL
+#define EINVAL 22 /* errno.h value */
+#endif
+
#if defined(ENABLE_IPV6) && defined(__MINGW32__)
const struct in6_addr in6addr_any = {{ IN6ADDR_ANY_INIT }};
#endif
@@ -118,7 +125,7 @@ void logmsg(const char *msg, ...)
fclose(logfp);
}
else {
- error = ERRNO;
+ error = errno;
fprintf(stderr, "fopen() failed with error: %d %s\n",
error, strerror(error));
fprintf(stderr, "Error opening file: %s\n", serverlogfile);
@@ -208,7 +215,7 @@ int wait_ms(int timeout_ms)
if(!timeout_ms)
return 0;
if(timeout_ms < 0) {
- SET_SOCKERRNO(EINVAL);
+ errno = EINVAL;
return -1;
}
#if defined(MSDOS)
@@ -228,7 +235,7 @@ int wait_ms(int timeout_ms)
#endif /* HAVE_POLL_FINE */
if(r != -1)
break;
- error = SOCKERRNO;
+ error = errno;
if(error && (error != EINTR))
break;
pending_ms = timeout_ms - (int)curlx_tvdiff(curlx_tvnow(), initial_tv);
@@ -249,7 +256,7 @@ int write_pidfile(const char *filename)
pid = (long)getpid();
pidfile = fopen(filename, "wb");
if(!pidfile) {
- logmsg("Couldn't write pid file: %s %s", filename, strerror(ERRNO));
+ logmsg("Couldn't write pid file: %s %s", filename, strerror(errno));
return 0; /* fail */
}
fprintf(pidfile, "%ld\n", pid);
@@ -266,7 +273,7 @@ void set_advisor_read_lock(const char *filename)
do {
lockfile = fopen(filename, "wb");
- } while((lockfile == NULL) && ((error = ERRNO) == EINTR));
+ } while((lockfile == NULL) && ((error = errno) == EINTR));
if(lockfile == NULL) {
logmsg("Error creating lock file %s error: %d %s",
filename, error, strerror(error));
@@ -275,7 +282,7 @@ void set_advisor_read_lock(const char *filename)
do {
res = fclose(lockfile);
- } while(res && ((error = ERRNO) == EINTR));
+ } while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing lock file %s error: %d %s",
filename, error, strerror(error));
@@ -294,7 +301,7 @@ void clear_advisor_read_lock(const char *filename)
do {
res = unlink(filename);
- } while(res && ((error = ERRNO) == EINTR));
+ } while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error removing lock file %s error: %d %s",
filename, error, strerror(error));