--- /dev/null
+/*\r
+ * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * 3. Neither the name of the project nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+ * SUCH DAMAGE.\r
+ */\r
+\r
+#ifndef HAVE_GETADDRINFO\r
+\r
+/*\r
+ * Error return codes from getaddrinfo()\r
+ */\r
+#ifdef EAI_ADDRFAMILY\r
+/* If this is defined, there is a conflicting implementation\r
+ in the C library, which can't be used for some reason.\r
+ Make sure it won't interfere with this emulation. */\r
+\r
+#undef EAI_ADDRFAMILY\r
+#undef EAI_AGAIN\r
+#undef EAI_BADFLAGS\r
+#undef EAI_FAIL\r
+#undef EAI_FAMILY\r
+#undef EAI_MEMORY\r
+#undef EAI_NODATA\r
+#undef EAI_NONAME\r
+#undef EAI_SERVICE\r
+#undef EAI_SOCKTYPE\r
+#undef EAI_SYSTEM\r
+#undef EAI_BADHINTS\r
+#undef EAI_PROTOCOL\r
+#undef EAI_MAX\r
+#undef getaddrinfo\r
+#define getaddrinfo fake_getaddrinfo\r
+#endif /* EAI_ADDRFAMILY */\r
+\r
+#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */\r
+#define EAI_AGAIN 2 /* temporary failure in name resolution */\r
+#define EAI_BADFLAGS 3 /* invalid value for ai_flags */\r
+#define EAI_FAIL 4 /* non-recoverable failure in name resolution */\r
+#define EAI_FAMILY 5 /* ai_family not supported */\r
+#define EAI_MEMORY 6 /* memory allocation failure */\r
+#define EAI_NODATA 7 /* no address associated with hostname */\r
+#define EAI_NONAME 8 /* hostname nor servname provided, or not known */\r
+#define EAI_SERVICE 9 /* servname not supported for ai_socktype */\r
+#define EAI_SOCKTYPE 10 /* ai_socktype not supported */\r
+#define EAI_SYSTEM 11 /* system error returned in errno */\r
+#define EAI_BADHINTS 12\r
+#define EAI_PROTOCOL 13\r
+#define EAI_MAX 14\r
+\r
+/*\r
+ * Flag values for getaddrinfo()\r
+ */\r
+#ifdef AI_PASSIVE\r
+#undef AI_PASSIVE\r
+#undef AI_CANONNAME\r
+#undef AI_NUMERICHOST\r
+#undef AI_MASK\r
+#undef AI_ALL\r
+#undef AI_V4MAPPED_CFG\r
+#undef AI_ADDRCONFIG\r
+#undef AI_V4MAPPED\r
+#undef AI_DEFAULT\r
+#endif /* AI_PASSIVE */\r
+\r
+#define AI_PASSIVE 0x00000001 /* get address to use bind() */\r
+#define AI_CANONNAME 0x00000002 /* fill ai_canonname */\r
+#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */\r
+/* valid flags for addrinfo */\r
+#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)\r
+\r
+#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */\r
+#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */\r
+#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */\r
+#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */\r
+/* special recommended flags for getipnodebyname */\r
+#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)\r
+\r
+#endif /* !HAVE_GETADDRINFO */\r
+\r
+#ifndef HAVE_GETNAMEINFO\r
+\r
+/*\r
+ * Constants for getnameinfo()\r
+ */\r
+#ifndef NI_MAXHOST\r
+#define NI_MAXHOST 1025\r
+#define NI_MAXSERV 32\r
+#endif /* !NI_MAXHOST */\r
+\r
+/*\r
+ * Flag values for getnameinfo()\r
+ */\r
+#ifndef NI_NOFQDN\r
+#define NI_NOFQDN 0x00000001\r
+#define NI_NUMERICHOST 0x00000002\r
+#define NI_NAMEREQD 0x00000004\r
+#define NI_NUMERICSERV 0x00000008\r
+#define NI_DGRAM 0x00000010\r
+#endif /* !NI_NOFQDN */\r
+\r
+#endif /* !HAVE_GETNAMEINFO */\r
+\r
+#ifndef HAVE_ADDRINFO\r
+struct addrinfo {\r
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME */\r
+ int ai_family; /* PF_xxx */\r
+ int ai_socktype; /* SOCK_xxx */\r
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */\r
+ size_t ai_addrlen; /* length of ai_addr */\r
+ char *ai_canonname; /* canonical name for hostname */\r
+ struct sockaddr *ai_addr; /* binary address */\r
+ struct addrinfo *ai_next; /* next structure in linked list */\r
+};\r
+#endif /* !HAVE_ADDRINFO */\r
+\r
+#ifndef HAVE_SOCKADDR_STORAGE\r
+/*\r
+ * RFC 2553: protocol-independent placeholder for socket addresses\r
+ */\r
+#define _SS_MAXSIZE 128\r
+#ifdef HAVE_LONG_LONG\r
+#define _SS_ALIGNSIZE (sizeof(PY_LONG_LONG))\r
+#else\r
+#define _SS_ALIGNSIZE (sizeof(double))\r
+#endif /* HAVE_LONG_LONG */\r
+#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2)\r
+#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \\r
+ _SS_PAD1SIZE - _SS_ALIGNSIZE)\r
+\r
+struct sockaddr_storage {\r
+#ifdef HAVE_SOCKADDR_SA_LEN\r
+ unsigned char ss_len; /* address length */\r
+ unsigned char ss_family; /* address family */\r
+#else\r
+ unsigned short ss_family; /* address family */\r
+#endif /* HAVE_SOCKADDR_SA_LEN */\r
+ char __ss_pad1[_SS_PAD1SIZE];\r
+#ifdef HAVE_LONG_LONG\r
+ PY_LONG_LONG __ss_align; /* force desired structure storage alignment */\r
+#else\r
+ double __ss_align; /* force desired structure storage alignment */\r
+#endif /* HAVE_LONG_LONG */\r
+ char __ss_pad2[_SS_PAD2SIZE];\r
+};\r
+#endif /* !HAVE_SOCKADDR_STORAGE */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+extern void freehostent Py_PROTO((struct hostent *));\r
+#ifdef __cplusplus\r
+}\r
+#endif\r