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