]> git.ipfire.org Git - thirdparty/squid.git/blob - compat/getaddrinfo.h
Merged from trunk.
[thirdparty/squid.git] / compat / getaddrinfo.h
1 #ifndef SQUID_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #ifndef _getaddrinfo_h
6 #define _getaddrinfo_h
7
8 /*
9 * Shamelessly duplicated from the fetchmail public sources
10 * for use by the Squid Project under GNU Public License.
11 *
12 * Update/Maintenance History:
13 *
14 * 15-Aug-2007 : Copied from fetchmail 6.3.8
15 * - added protection around libray headers
16 *
17 * 16-Aug-2007 : Altered configure checks
18 * Un-hacked slightly to use system gethostbyname()
19 *
20 * Squid CVS $Id$
21 *
22 * Original License and code follows.
23 */
24
25 /*
26 * This file is part of libESMTP, a library for submission of RFC 2822
27 * formatted electronic mail messages using the SMTP protocol described
28 * in RFC 2821.
29 *
30 * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
31 *
32 * This library is free software; you can redistribute it and/or
33 * modify it under the terms of the GNU Lesser General Public
34 * License as published by the Free Software Foundation; either
35 * version 2.1 of the License, or (at your option) any later version.
36 *
37 * This library is distributed in the hope that it will be useful,
38 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40 * Lesser General Public License for more details.
41 *
42 * You should have received a copy of the GNU Lesser General Public
43 * License along with this library; if not, write to the Free Software
44 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45 */
46
47 /* Structure and prototypes taken from RFC 2553 */
48
49 /* These functions are provided by the OS */
50 #if !HAVE_GETADDRINFO
51
52 /* SG 23/09/2007:
53 On Windows the following definitions are already available, may be that
54 this could be needed on some other platform */
55 #if 0
56 struct addrinfo {
57 int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
58 int ai_family; /* PF_xxx */
59 int ai_socktype; /* SOCK_xxx */
60 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
61 size_t ai_addrlen; /* length of ai_addr */
62 char *ai_canonname; /* canonical name for nodename */
63 struct sockaddr *ai_addr; /* binary address */
64 struct addrinfo *ai_next; /* next structure in linked list */
65 };
66
67 /* Supposed to be defined in <netdb.h> */
68 #define AI_PASSIVE 1 /* Socket address is intended for `bind'. */
69 #define AI_CANONNAME 2 /* Request for canonical name. */
70 #define AI_NUMERICHOST 4 /* Don't use name resolution. */
71
72 /* Supposed to be defined in <netdb.h> */
73 #define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
74 #define EAI_AGAIN 2 /* temporary failure in name resolution */
75 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
76 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
77 #define EAI_FAMILY 5 /* ai_family not supported */
78 #define EAI_MEMORY 6 /* memory allocation failure */
79 #define EAI_NODATA 7 /* no address associated with nodename */
80 #define EAI_NONAME 8 /* nodename nor servname provided, or not known */
81 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
82 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
83 #endif
84 #ifndef EAI_SYSTEM
85 /* Not defined on mingw32. */
86 #define EAI_SYSTEM 11 /* System error returned in `errno'. */
87 #endif
88 #ifndef EAI_OVERFLOW
89 /* Not defined on mingw32. */
90 #define EAI_OVERFLOW 12 /* Argument buffer overflow. */
91 #endif
92
93 #ifndef IN_EXPERIMENTAL
94 #define IN_EXPERIMENTAL(a) \
95 ((((long int) (a)) & 0xf0000000) == 0xf0000000)
96 #endif
97
98 /* RFC 2553 / Posix resolver */
99 SQUIDCEXTERN int xgetaddrinfo (const char *nodename, const char *servname,
100 const struct addrinfo *hints, struct addrinfo **res);
101 #define getaddrinfo xgetaddrinfo
102
103 /* Free addrinfo structure and associated storage */
104 SQUIDCEXTERN void xfreeaddrinfo (struct addrinfo *ai);
105 #define freeaddrinfo xfreeaddrinfo
106
107 /* Convert error return from getaddrinfo() to string */
108 SQUIDCEXTERN const char *xgai_strerror (int code);
109 #define gai_strerror xgai_strerror
110
111 #endif /* HAVE_GETADDRINFO */
112 #endif /* _getaddrinfo_h */