Fixed get_xattr_acl() -- it needed to zero *len_p.
[rsync/rsync.git] / lib / addrinfo.h
CommitLineData
9f802c72
WD
1/*
2PostgreSQL Database Management System
3(formerly known as Postgres, then as Postgres95)
4
5Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
6
7Portions Copyright (c) 1994, The Regents of the University of California
8
9Permission to use, copy, modify, and distribute this software and its
10documentation for any purpose, without fee, and without a written agreement
11is hereby granted, provided that the above copyright notice and this paragraph
12and the following two paragraphs appear in all copies.
13
14IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
15DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
16LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
17EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
18SUCH DAMAGE.
19
20THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
21INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
23ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
24TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25
26*/
27
28/*-------------------------------------------------------------------------
29 *
30 * getaddrinfo.h
31 * Support getaddrinfo() on platforms that don't have it.
32 *
33 * Note: we use our own routines on platforms that don't HAVE_STRUCT_ADDRINFO,
34 * whether or not the library routine getaddrinfo() can be found. This
35 * policy is needed because on some platforms a manually installed libbind.a
36 * may provide getaddrinfo(), yet the system headers may not provide the
37 * struct definitions needed to call it. To avoid conflict with the libbind
38 * definition in such cases, we rename our routines to pg_xxx() via macros.
39 *
40 * This code will also work on platforms where struct addrinfo is defined
41 * in the system headers but no getaddrinfo() can be located.
42 *
43 * Copyright (c) 2003-2007, PostgreSQL Global Development Group
44 *
45 *-------------------------------------------------------------------------
46 */
47#ifndef ADDRINFO_H
48#define ADDRINFO_H
49
50
51/* Various macros that ought to be in <netdb.h>, but might not be */
52
53#ifndef EAI_FAIL
54#define EAI_BADFLAGS (-1)
55#define EAI_NONAME (-2)
56#define EAI_AGAIN (-3)
57#define EAI_FAIL (-4)
58#define EAI_FAMILY (-6)
59#define EAI_SOCKTYPE (-7)
60#define EAI_SERVICE (-8)
61#define EAI_MEMORY (-10)
62#define EAI_SYSTEM (-11)
63#endif /* !EAI_FAIL */
64
65#ifndef AI_PASSIVE
66#define AI_PASSIVE 0x0001
67#endif
68
69#ifndef AI_NUMERICHOST
70/*
71 * some platforms don't support AI_NUMERICHOST; define as zero if using
72 * the system version of getaddrinfo...
73 */
74#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
75#define AI_NUMERICHOST 0
76#else
77#define AI_NUMERICHOST 0x0004
78#endif
79#endif
80
81#ifndef AI_CANONNAME
82#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
83#define AI_CANONNAME 0
84#else
85#define AI_CANONNAME 0x0008
86#endif
87#endif
88
89#ifndef AI_NUMERICSERV
90#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
91#define AI_NUMERICSERV 0
92#else
93#define AI_NUMERICSERV 0x0010
94#endif
95#endif
96
97#ifndef NI_NUMERICHOST
98#define NI_NUMERICHOST 1
99#endif
100
101#ifndef NI_NUMERICSERV
102#define NI_NUMERICSERV 2
103#endif
104
105#ifndef NI_NOFQDN
106#define NI_NOFQDN 4
107#endif
108
109#ifndef NI_NAMEREQD
110#define NI_NAMEREQD 8
111#endif
112
113#ifndef NI_DGRAM
114#define NI_DGRAM 16
115#endif
116
117
118#ifndef NI_MAXHOST
119#define NI_MAXHOST 1025
120#endif
121
122#ifndef NI_MAXSERV
123#define NI_MAXSERV 32
124#endif
125
126#ifndef HAVE_STRUCT_ADDRINFO
127
128struct addrinfo
129{
130 int ai_flags;
131 int ai_family;
132 int ai_socktype;
133 int ai_protocol;
134 size_t ai_addrlen;
135 struct sockaddr *ai_addr;
136 char *ai_canonname;
137 struct addrinfo *ai_next;
138};
139#endif /* HAVE_STRUCT_ADDRINFO */
140
141
142#ifndef HAVE_GETADDRINFO
143
144/* Rename private copies per comments above */
145#ifdef getaddrinfo
146#undef getaddrinfo
147#endif
148#define getaddrinfo pg_getaddrinfo
149
150#ifdef freeaddrinfo
151#undef freeaddrinfo
152#endif
153#define freeaddrinfo pg_freeaddrinfo
154
155#ifdef gai_strerror
156#undef gai_strerror
157#endif
158#define gai_strerror pg_gai_strerror
159
160#ifdef getnameinfo
161#undef getnameinfo
162#endif
163#define getnameinfo pg_getnameinfo
164
165extern int getaddrinfo(const char *node, const char *service,
166 const struct addrinfo * hints, struct addrinfo ** res);
167extern void freeaddrinfo(struct addrinfo * res);
168extern const char *gai_strerror(int errcode);
169extern int getnameinfo(const struct sockaddr * sa, socklen_t salen,
170 char *node, size_t nodelen,
171 char *service, size_t servicelen, int flags);
172#endif /* HAVE_GETADDRINFO */
173
174#endif /* ADDRINFO_H */