sclose() function-like macro definition used to close a socket,

now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL
config file preprocessor definitions.
This commit is contained in:
Yang Tse 2009-06-19 00:41:03 +00:00
Родитель d6d63147b6
Коммит 2c0c05e96d
11 изменённых файлов: 45 добавлений и 39 удалений

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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

Просмотреть файл

@ -222,6 +222,19 @@ struct timeval {
#endif /* if 0 */
/*
* 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.

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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__)

Просмотреть файл

@ -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);

Просмотреть файл

@ -229,6 +229,19 @@ struct timeval {
#endif /* if 0 */
/*
* 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.

Просмотреть файл

@ -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