summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2009-06-19 00:41:03 +0000
committerYang Tse <yangsita@gmail.com>2009-06-19 00:41:03 +0000
commit2c0c05e96d8b611e1f5eedea518fa1a7857804c9 (patch)
tree2003c508150ca0dfb70ff71bbdd2be0fae76d314
parentd6d63147b6a5f425b1601b0576483937fe9f99d1 (diff)
downloadcurl-2c0c05e96d8b611e1f5eedea518fa1a7857804c9.tar.gz
sclose() function-like macro definition used to close a socket,
now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL config file preprocessor definitions.
-rw-r--r--ares/ares__close_sockets.c4
-rw-r--r--ares/ares_private.h7
-rw-r--r--ares/ares_process.c14
-rw-r--r--ares/config.dos2
-rw-r--r--ares/setup_once.h13
-rw-r--r--lib/config-amigaos.h1
-rw-r--r--lib/config.dos5
-rw-r--r--lib/memdebug.h3
-rw-r--r--lib/setup.h21
-rw-r--r--lib/setup_once.h13
-rw-r--r--src/config-amigaos.h1
11 files changed, 45 insertions, 39 deletions
diff --git a/ares/ares__close_sockets.c b/ares/ares__close_sockets.c
index c2588663d..1becf9ab3 100644
--- a/ares/ares__close_sockets.c
+++ b/ares/ares__close_sockets.c
@@ -54,14 +54,14 @@ void ares__close_sockets(ares_channel channel, struct server_state *server)
if (server->tcp_socket != ARES_SOCKET_BAD)
{
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 0, 0);
- closesocket(server->tcp_socket);
+ sclose(server->tcp_socket);
server->tcp_socket = ARES_SOCKET_BAD;
server->tcp_connection_generation = ++channel->tcp_connection_generation;
}
if (server->udp_socket != ARES_SOCKET_BAD)
{
SOCK_STATE_CALLBACK(channel, server->udp_socket, 0, 0);
- closesocket(server->udp_socket);
+ sclose(server->udp_socket);
server->udp_socket = ARES_SOCKET_BAD;
}
}
diff --git a/ares/ares_private.h b/ares/ares_private.h
index 794844039..e70bdb5c0 100644
--- a/ares/ares_private.h
+++ b/ares/ares_private.h
@@ -4,7 +4,7 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
- * Copyright (C) 2004-2008 by Daniel Stenberg
+ * Copyright (C) 2004-2009 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -32,16 +32,11 @@
#if !defined(WIN32) || defined(WATT32)
#include <netinet/in.h>
-/* We define closesocket() here so that we can use this function all over
- the source code for closing sockets. */
-#define closesocket(x) close(x)
#endif
#ifdef WATT32
#include <tcp.h>
#include <sys/ioctl.h>
-#undef closesocket
-#define closesocket(s) close_s(s)
#define writev(s,v,c) writev_s(s,v,c)
#define HAVE_WRITEV 1
#endif
diff --git a/ares/ares_process.c b/ares/ares_process.c
index c4848108a..41d181132 100644
--- a/ares/ares_process.c
+++ b/ares/ares_process.c
@@ -896,7 +896,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
/* Configure it. */
if (configure_socket(s, channel) < 0)
{
- closesocket(s);
+ sclose(s);
return -1;
}
@@ -911,7 +911,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY,
(void *)&opt, sizeof(opt)) == -1)
{
- closesocket(s);
+ sclose(s);
return -1;
}
#endif
@@ -927,7 +927,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
if (err != EINPROGRESS && err != EWOULDBLOCK)
{
- closesocket(s);
+ sclose(s);
return -1;
}
}
@@ -938,7 +938,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
channel->sock_create_cb_data);
if (err < 0)
{
- closesocket(s);
+ sclose(s);
return err;
}
}
@@ -963,7 +963,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
/* Set the socket non-blocking. */
if (configure_socket(s, channel) < 0)
{
- closesocket(s);
+ sclose(s);
return -1;
}
@@ -978,7 +978,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
if (err != EINPROGRESS && err != EWOULDBLOCK)
{
- closesocket(s);
+ sclose(s);
return -1;
}
}
@@ -989,7 +989,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
channel->sock_create_cb_data);
if (err < 0)
{
- closesocket(s);
+ sclose(s);
return err;
}
}
diff --git a/ares/config.dos b/ares/config.dos
index 98b176545..96baa9cc4 100644
--- a/ares/config.dos
+++ b/ares/config.dos
@@ -154,6 +154,7 @@
#define HAVE_AF_INET6 1
#define HAVE_ARPA_INET_H 1
#define HAVE_ARPA_NAMESER_H 1
+ #define HAVE_CLOSESOCKET_CAMEL 1
#define HAVE_GETHOSTNAME 1
#define HAVE_NETDB_H 1
#define HAVE_NETINET_IN_H 1
@@ -167,6 +168,7 @@
#define HAVE_SYS_UIO_H 1
#define NS_INADDRSZ 4
#define HAVE_STRUCT_SOCKADDR_IN6 1
+ #define CloseSocket(s) close_s((s))
#endif
#undef word
diff --git a/ares/setup_once.h b/ares/setup_once.h
index de6c632be..f7d45a232 100644
--- a/ares/setup_once.h
+++ b/ares/setup_once.h
@@ -223,6 +223,19 @@ struct timeval {
/*
+ * Function-like macro definition used to close a socket.
+ */
+
+#if defined(HAVE_CLOSESOCKET)
+# define sclose(x) closesocket((x))
+#elif defined(HAVE_CLOSESOCKET_CAMEL)
+# define sclose(x) CloseSocket((x))
+#else
+# define sclose(x) close((x))
+#endif
+
+
+/*
* Uppercase macro versions of ANSI/ISO is*() functions/macros which
* avoid negative number inputs with argument byte codes > 127.
*/
diff --git a/lib/config-amigaos.h b/lib/config-amigaos.h
index 3da27426d..189a0a6a0 100644
--- a/lib/config-amigaos.h
+++ b/lib/config-amigaos.h
@@ -26,6 +26,7 @@
#ifdef __AMIGA__ /* Any AmigaOS flavour */
#define HAVE_ARPA_INET_H 1
+#define HAVE_CLOSESOCKET_CAMEL 1
#define HAVE_GETHOSTBYADDR 1
#define HAVE_INET_ADDR 1
#define HAVE_INTTYPES_H 1
diff --git a/lib/config.dos b/lib/config.dos
index 26f25fd51..df4809133 100644
--- a/lib/config.dos
+++ b/lib/config.dos
@@ -155,6 +155,11 @@
#define HAVE_SYS_TIME_H 1
#endif
+#ifdef MSDOS /* Watt-32 */
+ #define HAVE_CLOSESOCKET_CAMEL 1
+ #define CloseSocket(s) close_s((s))
+#endif
+
#undef word
#undef byte
diff --git a/lib/memdebug.h b/lib/memdebug.h
index 4c84247b1..96cf4ad38 100644
--- a/lib/memdebug.h
+++ b/lib/memdebug.h
@@ -116,9 +116,6 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
/* sclose is probably already defined, redefine it! */
#undef sclose
#define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
-/* ares-adjusted define: */
-#undef closesocket
-#define closesocket(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
#undef fopen
#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
diff --git a/lib/setup.h b/lib/setup.h
index 1ca3e9b9d..25ca451f3 100644
--- a/lib/setup.h
+++ b/lib/setup.h
@@ -341,7 +341,6 @@
#endif
/* Below we define some functions. They should
- 1. close a socket
4. set the SIGALRM signal timeout
5. set dir/file naming defines
@@ -349,12 +348,6 @@
#ifdef WIN32
-# if !defined(__CYGWIN__)
-# define sclose(x) closesocket(x)
-# else
-# define sclose(x) close(x)
-# endif
-
# define DIR_CHAR "\\"
# define DOT_CHAR "_"
@@ -363,7 +356,6 @@
# ifdef MSDOS /* Watt-32 */
# include <sys/ioctl.h>
-# define sclose(x) close_s(x)
# define select(n,r,w,x,t) select_s(n,r,w,x,t)
# define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
# include <tcp.h>
@@ -374,21 +366,8 @@
# undef byte
# endif
-# else /* MSDOS */
-
-# ifdef __BEOS__
-# define sclose(x) closesocket(x)
-# else /* __BEOS__ */
-# define sclose(x) close(x)
-# endif /* __BEOS__ */
-
# endif /* MSDOS */
-# ifdef _AMIGASF
-# undef sclose
-# define sclose(x) CloseSocket(x)
-# endif
-
# ifdef __minix
/* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
extern char * strtok_r(char *s, const char *delim, char **last);
diff --git a/lib/setup_once.h b/lib/setup_once.h
index 4c4d3f599..9ad69e58d 100644
--- a/lib/setup_once.h
+++ b/lib/setup_once.h
@@ -230,6 +230,19 @@ struct timeval {
/*
+ * Function-like macro definition used to close a socket.
+ */
+
+#if defined(HAVE_CLOSESOCKET)
+# define sclose(x) closesocket((x))
+#elif defined(HAVE_CLOSESOCKET_CAMEL)
+# define sclose(x) CloseSocket((x))
+#else
+# define sclose(x) close((x))
+#endif
+
+
+/*
* Uppercase macro versions of ANSI/ISO is*() functions/macros which
* avoid negative number inputs with argument byte codes > 127.
*/
diff --git a/src/config-amigaos.h b/src/config-amigaos.h
index 75b1fb82f..01cc7da18 100644
--- a/src/config-amigaos.h
+++ b/src/config-amigaos.h
@@ -30,6 +30,7 @@
#define OS "AmigaOS"
+#define HAVE_CLOSESOCKET_CAMEL 1
#define HAVE_UNISTD_H 1
#define HAVE_STRDUP 1
#define HAVE_UTIME 1