2 PostgreSQL Database Management System
3 (formerly known as Postgres, then as Postgres95)
5 Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
7 Portions Copyright (c) 1994, The Regents of the University of California
9 Permission to use, copy, modify, and distribute this software and its
10 documentation for any purpose, without fee, and without a written agreement
11 is hereby granted, provided that the above copyright notice and this paragraph
12 and the following two paragraphs appear in all copies.
14 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
15 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
16 LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
17 EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
20 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
21 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22 AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
23 ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
24 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
28 /*-------------------------------------------------------------------------
31 * Support getaddrinfo() on platforms that don't have it.
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.
40 * This code will also work on platforms where struct addrinfo is defined
41 * in the system headers but no getaddrinfo() can be located.
43 * Copyright (c) 2003-2007, PostgreSQL Global Development Group
45 *-------------------------------------------------------------------------
51 /* Various macros that ought to be in <netdb.h>, but might not be */
54 #define EAI_BADFLAGS (-1)
55 #define EAI_NONAME (-2)
56 #define EAI_AGAIN (-3)
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 */
66 #define AI_PASSIVE 0x0001
69 #ifndef AI_NUMERICHOST
71 * some platforms don't support AI_NUMERICHOST; define as zero if using
72 * the system version of getaddrinfo...
74 #if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
75 #define AI_NUMERICHOST 0
77 #define AI_NUMERICHOST 0x0004
81 #ifndef NI_NUMERICHOST
82 #define NI_NUMERICHOST 1
85 #ifndef NI_NUMERICSERV
86 #define NI_NUMERICSERV 2
103 #define NI_MAXHOST 1025
107 #define NI_MAXSERV 32
110 #ifndef HAVE_STRUCT_ADDRINFO
119 struct sockaddr *ai_addr;
121 struct addrinfo *ai_next;
123 #endif /* HAVE_STRUCT_ADDRINFO */
126 #ifndef HAVE_GETADDRINFO
128 /* Rename private copies per comments above */
132 #define getaddrinfo pg_getaddrinfo
137 #define freeaddrinfo pg_freeaddrinfo
142 #define gai_strerror pg_gai_strerror
147 #define getnameinfo pg_getnameinfo
149 extern int getaddrinfo(const char *node, const char *service,
150 const struct addrinfo * hints, struct addrinfo ** res);
151 extern void freeaddrinfo(struct addrinfo * res);
152 extern const char *gai_strerror(int errcode);
153 extern int getnameinfo(const struct sockaddr * sa, socklen_t salen,
154 char *node, size_t nodelen,
155 char *service, size_t servicelen, int flags);
156 #endif /* HAVE_GETADDRINFO */
158 #endif /* GETADDRINFO_H */