2007-07-23 13:04:48 +00:00
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-07-23 13:04:48 +00:00
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
*/
|
|
|
|
/* copyright --> */
|
2010-10-31 07:23:53 +00:00
|
|
|
#ifndef D_A2NETCOMPAT_H
|
|
|
|
#define D_A2NETCOMPAT_H
|
2007-07-23 13:04:48 +00:00
|
|
|
|
2007-07-31 16:45:16 +00:00
|
|
|
#include "a2io.h"
|
|
|
|
|
2010-04-16 09:25:59 +00:00
|
|
|
#ifdef __MINGW32__
|
2015-12-27 09:39:47 +00:00
|
|
|
#ifdef HAVE_WS2TCPIP_H
|
|
|
|
#include <ws2tcpip.h>
|
|
|
|
#endif // HAVE_WS2TCPIP_H
|
2010-04-16 09:25:59 +00:00
|
|
|
#endif // __MINGW32__
|
2007-08-14 14:51:08 +00:00
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
2015-12-27 09:39:47 +00:00
|
|
|
#define a2_sockopt_t char *
|
|
|
|
#ifndef HAVE_GETADDRINFO
|
|
|
|
#define HAVE_GETADDRINFO
|
|
|
|
#endif // !HAVE_GETADDRINFO
|
|
|
|
#undef HAVE_GAI_STRERROR
|
|
|
|
#undef gai_strerror
|
2007-08-14 14:51:08 +00:00
|
|
|
#else
|
2015-12-27 09:39:47 +00:00
|
|
|
#define a2_sockopt_t void *
|
2007-08-14 14:51:08 +00:00
|
|
|
#endif // __MINGW32__
|
|
|
|
|
2007-07-23 13:04:48 +00:00
|
|
|
#ifdef HAVE_NETDB_H
|
2015-12-27 09:39:47 +00:00
|
|
|
#include <netdb.h>
|
2007-07-23 13:04:48 +00:00
|
|
|
#endif // HAVE_NETDB_H
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
2015-12-27 09:39:47 +00:00
|
|
|
#include <sys/socket.h>
|
2007-07-23 13:04:48 +00:00
|
|
|
#endif // HAVE_SYS_SOCKET_H
|
|
|
|
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2015-12-27 09:39:47 +00:00
|
|
|
#include <netinet/in.h>
|
2007-07-23 13:04:48 +00:00
|
|
|
#endif // HAVE_NETINET_IN_H
|
|
|
|
|
2012-03-20 17:08:18 +00:00
|
|
|
#ifdef HAVE_NETINET_TCP_H
|
2015-12-27 09:39:47 +00:00
|
|
|
#include <netinet/tcp.h>
|
2012-03-20 17:08:18 +00:00
|
|
|
#endif // HAVE_NETINET_TCP_H
|
|
|
|
|
2007-07-23 13:04:48 +00:00
|
|
|
#ifdef HAVE_ARPA_INET_H
|
2015-12-27 09:39:47 +00:00
|
|
|
#include <arpa/inet.h>
|
2007-07-23 13:04:48 +00:00
|
|
|
#endif // HAVE_ARPA_INET_H
|
|
|
|
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2015-12-27 09:39:47 +00:00
|
|
|
#include <netinet/in.h>
|
2007-07-23 13:04:48 +00:00
|
|
|
#endif // HAVE_NETINET_IN_H
|
|
|
|
|
2013-01-11 05:20:34 +00:00
|
|
|
#ifdef HAVE_SYS_UIO_H
|
2015-12-27 09:39:47 +00:00
|
|
|
#include <sys/uio.h>
|
2013-01-11 05:20:34 +00:00
|
|
|
#endif // HAVE_SYS_UIO_H
|
|
|
|
|
2007-08-14 14:51:08 +00:00
|
|
|
#ifndef HAVE_GETADDRINFO
|
2015-12-27 09:39:47 +00:00
|
|
|
#include "getaddrinfo.h"
|
|
|
|
#define HAVE_GAI_STRERROR
|
2007-08-14 14:51:08 +00:00
|
|
|
#endif // HAVE_GETADDRINFO
|
2007-07-23 13:04:48 +00:00
|
|
|
|
2007-07-31 16:45:16 +00:00
|
|
|
#ifndef HAVE_GAI_STRERROR
|
2015-12-27 09:39:47 +00:00
|
|
|
#include "gai_strerror.h"
|
2007-07-31 16:45:16 +00:00
|
|
|
#endif // HAVE_GAI_STRERROR
|
|
|
|
|
2008-06-16 14:01:45 +00:00
|
|
|
#ifdef HAVE_WINSOCK2_H
|
2015-12-27 09:39:47 +00:00
|
|
|
#define sock_t SOCKET
|
2008-06-16 14:01:45 +00:00
|
|
|
#else
|
2015-12-27 09:39:47 +00:00
|
|
|
#define sock_t int
|
2008-06-16 14:01:45 +00:00
|
|
|
#endif
|
|
|
|
|
2010-08-05 11:50:46 +00:00
|
|
|
#ifndef AI_ADDRCONFIG
|
2015-12-27 09:39:47 +00:00
|
|
|
#define AI_ADDRCONFIG 0
|
2009-12-24 14:59:47 +00:00
|
|
|
#endif // !AI_ADDRCONFIG
|
|
|
|
|
2010-08-07 14:10:17 +00:00
|
|
|
#define DEFAULT_AI_FLAGS AI_ADDRCONFIG
|
2010-08-05 11:50:46 +00:00
|
|
|
|
2011-07-15 15:58:13 +00:00
|
|
|
#ifdef __MINGW32__
|
2015-12-27 09:39:47 +00:00
|
|
|
#ifndef SHUT_WR
|
|
|
|
#define SHUT_WR SD_SEND
|
|
|
|
#endif // !SHUT_WR
|
2011-07-15 15:58:13 +00:00
|
|
|
#endif // __MINGW32__
|
|
|
|
|
2011-10-19 14:14:13 +00:00
|
|
|
union sockaddr_union {
|
|
|
|
sockaddr sa;
|
|
|
|
sockaddr_storage storage;
|
|
|
|
sockaddr_in6 in6;
|
|
|
|
sockaddr_in in;
|
|
|
|
};
|
|
|
|
|
2016-01-09 08:20:03 +00:00
|
|
|
struct SockAddr {
|
|
|
|
sockaddr_union su;
|
|
|
|
socklen_t suLength;
|
|
|
|
};
|
|
|
|
|
2013-01-11 05:20:34 +00:00
|
|
|
#define A2_DEFAULT_IOV_MAX 128
|
|
|
|
|
|
|
|
#if defined(IOV_MAX) && IOV_MAX < A2_DEFAULT_IOV_MAX
|
2015-12-27 09:39:47 +00:00
|
|
|
#define A2_IOV_MAX IOV_MAX
|
2013-01-11 05:20:34 +00:00
|
|
|
#else
|
2015-12-27 09:39:47 +00:00
|
|
|
#define A2_IOV_MAX A2_DEFAULT_IOV_MAX
|
2013-01-11 05:20:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
typedef WSABUF a2iovec;
|
2015-12-27 09:39:47 +00:00
|
|
|
#define A2IOVEC_BASE buf
|
|
|
|
#define A2IOVEC_LEN len
|
2013-01-11 05:20:34 +00:00
|
|
|
#else // !__MINGW32__
|
|
|
|
typedef struct iovec a2iovec;
|
2015-12-27 09:39:47 +00:00
|
|
|
#define A2IOVEC_BASE iov_base
|
|
|
|
#define A2IOVEC_LEN iov_len
|
2013-01-11 05:20:34 +00:00
|
|
|
#endif // !__MINGW32__
|
|
|
|
|
2010-10-31 07:23:53 +00:00
|
|
|
#endif // D_A2NETCOMPAT_H
|