summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Eisentraut2003-03-29 11:31:52 +0000
committerPeter Eisentraut2003-03-29 11:31:52 +0000
commit82a91eb54ed0c6561050a0ae01661ea6302445ba (patch)
tree8c22569ca08a298eeb613ba4ba417ce2df0b6a83 /src/include
parentbf7ca0a7697551aba8e1d8a130c803d4f2c011d4 (diff)
Simplify the socket handling code by supplying a replacement getaddrinfo()
function if the OS doesn't provide one.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/getaddrinfo.h43
-rw-r--r--src/include/libpq/ip.h13
-rw-r--r--src/include/pg_config.h.in5
3 files changed, 53 insertions, 8 deletions
diff --git a/src/include/getaddrinfo.h b/src/include/getaddrinfo.h
new file mode 100644
index 0000000000..7933f93d70
--- /dev/null
+++ b/src/include/getaddrinfo.h
@@ -0,0 +1,43 @@
+/* $Header: /cvsroot/pgsql/src/include/getaddrinfo.h,v 1.1 2003/03/29 11:31:51 petere Exp $ */
+
+#ifndef GETADDRINFO_H
+#define GETADDRINFO_H
+
+#include "c.h"
+#include <netdb.h>
+
+
+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;
+};
+
+
+int getaddrinfo(const char *node, const char *service,
+ const struct addrinfo *hints, struct addrinfo **res);
+void freeaddrinfo(struct addrinfo *res);
+const char *gai_strerror(int errcode);
+
+
+#define EAI_BADFLAGS -1
+#define EAI_NONAME -2
+#define EAI_AGAIN -3
+#define EAI_FAIL -4
+#define EAI_NODATA -5
+#define EAI_FAMILY -6
+#define EAI_SOCKTYPE -7
+#define EAI_SERVICE -8
+#define EAI_ADDRFAMILY -9
+#define EAI_MEMORY -10
+#define EAI_SYSTEM -11
+
+#define AI_PASSIVE 0x0001
+#define AI_NUMERICHOST 0x0004
+
+#endif /* GETADDRINFO_H */
diff --git a/src/include/libpq/ip.h b/src/include/libpq/ip.h
index c9d1b0e466..ac782a0336 100644
--- a/src/include/libpq/ip.h
+++ b/src/include/libpq/ip.h
@@ -1,17 +1,16 @@
#ifndef IP_H
#define IP_H
+#include "c.h"
#include <sys/socket.h>
#include <netdb.h>
#include "libpq/pqcomm.h"
+#ifndef HAVE_GETADDRINFO
+#include "getaddrinfo.h"
+#endif
-#ifdef HAVE_IPV6
-void freeaddrinfo2(int hint_ai_family, struct addrinfo *ai);
int getaddrinfo2(const char *hostname, const char *servname,
- const struct addrinfo *hintp, struct addrinfo **result);
-#else
-int getaddrinfo2(const char *hostname, const char *servname,
- int family, SockAddr *result);
-#endif
+ const struct addrinfo *hintp, struct addrinfo **result);
+void freeaddrinfo2(int hint_ai_family, struct addrinfo *ai);
char *SockAddr_ntop(const SockAddr *sa, char *dst, size_t cnt, int v4conv);
int SockAddr_pton(SockAddr *sa, const char *src);
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 3c8e0b5d50..f515c6cff1 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -8,7 +8,7 @@
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
* changes will be overwritten the next time you run configure.
*
- * $Id: pg_config.h.in,v 1.41 2003/03/06 03:16:55 tgl Exp $
+ * $Id: pg_config.h.in,v 1.42 2003/03/29 11:31:51 petere Exp $
*/
#ifndef PG_CONFIG_H
@@ -459,6 +459,9 @@
#undef HAVE_FP_CLASS_D
#undef HAVE_CLASS
+/* Set to 1 if you have getaddrinfo() */
+#undef HAVE_GETADDRINFO
+
/* Set to 1 if you have gethostname() */
#undef HAVE_GETHOSTNAME