OSDN Git Service

Don't use HAVE_STRUCT_ADDRINFO as a guide to whether netdb.h defines
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Aug 2003 16:45:21 +0000 (16:45 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Aug 2003 16:45:21 +0000 (16:45 +0000)
macros like AI_NUMERICHOST; instead, test the macros individually.
Should fix recent reports of trouble on AIX and Unixware.

src/include/getaddrinfo.h

index 4a12cf4..3699464 100644 (file)
@@ -15,7 +15,7 @@
  *
  * Copyright (c) 2003, PostgreSQL Global Development Group
  *
- * $Id: getaddrinfo.h,v 1.8 2003/08/04 00:43:29 momjian Exp $
+ * $Id: getaddrinfo.h,v 1.9 2003/08/07 16:45:21 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 #endif
 
 
-#ifndef HAVE_STRUCT_ADDRINFO
+/* Various macros that ought to be in <netdb.h>, but might not be */
 
-struct addrinfo
-{
-       int                     ai_flags;
-       int                     ai_family;
-       int                     ai_socktype;
-       int                     ai_protocol;
-       size_t          ai_addrlen;
-       struct sockaddr *ai_addr;
-       char       *ai_canonname;
-       struct addrinfo *ai_next;
-};
+#ifndef EAI_FAIL
 
-#define EAI_BADFLAGS           -1
+#define EAI_BADFLAGS   -1
 #define EAI_NONAME             -2
 #define EAI_AGAIN              -3
 #define EAI_FAIL               -4
 #define EAI_FAMILY             -6
-#define EAI_SOCKTYPE           -7
+#define EAI_SOCKTYPE   -7
 #define EAI_SERVICE            -8
 #define EAI_MEMORY             -10
 #define EAI_SYSTEM             -11
 
+#endif
+
+#ifndef AI_PASSIVE
 #define AI_PASSIVE             0x0001
+#endif
+#ifndef AI_NUMERICHOST
 #define AI_NUMERICHOST 0x0004
+#endif
 
+#ifndef NI_NUMERICHOST
 #define NI_NUMERICHOST 1
+#endif
+#ifndef NI_NUMERICSERV
 #define NI_NUMERICSERV 2
-#endif   /* HAVE_STRUCT_ADDRINFO */
+#endif
 
 #ifndef NI_MAXHOST
 #define NI_MAXHOST     1025
+#endif
+#ifndef NI_MAXSERV
 #define NI_MAXSERV     32
 #endif
 
 
+#ifndef HAVE_STRUCT_ADDRINFO
+
+struct addrinfo
+{
+       int                     ai_flags;
+       int                     ai_family;
+       int                     ai_socktype;
+       int                     ai_protocol;
+       size_t          ai_addrlen;
+       struct sockaddr *ai_addr;
+       char       *ai_canonname;
+       struct addrinfo *ai_next;
+};
+
+#endif /* HAVE_STRUCT_ADDRINFO */
+
 
 #ifndef HAVE_GETADDRINFO
 
@@ -96,6 +113,7 @@ extern const char *gai_strerror(int errcode);
 extern int getnameinfo(const struct sockaddr * sa, int salen,
                        char *node, int nodelen,
                        char *service, int servicelen, int flags);
+
 #endif   /* HAVE_GETADDRINFO */
 
 #endif   /* GETADDRINFO_H */