summaryrefslogtreecommitdiff
path: root/mcon/U/d_getnameinfo.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/d_getnameinfo.U')
-rw-r--r--mcon/U/d_getnameinfo.U73
1 files changed, 73 insertions, 0 deletions
diff --git a/mcon/U/d_getnameinfo.U b/mcon/U/d_getnameinfo.U
new file mode 100644
index 0000000..ac8d675
--- /dev/null
+++ b/mcon/U/d_getnameinfo.U
@@ -0,0 +1,73 @@
+?RCS: $Id: d_getnameinfo.U 170 2013-08-30 16:47:47Z rmanfredi $
+?RCS:
+?RCS: Copyright (c) 2013, Raphael Manfredi
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic License,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic License; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?RCS:
+?MAKE:d_getnameinfo: Trylink cat i_arpainet i_netdb i_syssock \
+ i_winsock2 i_ws2tcpip i_niin d_windows
+?MAKE: -pick add $@ %<
+?S:d_getnameinfo:
+?S: This variable conditionally defines the HAS_GETNAMEINFO symbol, which
+?S: indicates to the C program that the getnameinfo() routine is available.
+?S:.
+?C:HAS_GETNAMEINFO:
+?C: This symbol is defined when getnameinfo() can be used.
+?C:.
+?H:#$d_getnameinfo HAS_GETNAMEINFO
+?H:.
+?LINT: set d_getnameinfo
+: can we use getnameinfo?
+$cat >try.c <<EOC
+#$i_syssock I_SYS_SOCKET
+#$i_winsock2 I_WINSOCK2
+#$i_ws2tcpip I_WS2TCPIP
+#$i_niin I_NETINET_IN
+#$i_arpainet I_ARPA_INET
+#$i_netdb I_NETDB
+#$d_windows WINDOWS_SYSTEM
+#ifdef WINDOWS_SYSTEM
+#define WINVER 0x0501
+#endif
+#include <sys/types.h>
+#ifdef I_SYS_SOCKET
+#include <sys/socket.h>
+#endif
+#ifdef I_NETINET_IN
+#include <netinet/in.h>
+#endif
+#ifdef I_ARPA_INET
+#include <arpa/inet.h>
+#endif
+#ifdef I_NETDB
+#include <netdb.h>
+#endif
+#ifdef I_WINSOCK2
+#include <Winsock2.h>
+#endif
+#ifdef I_WS2TCPIP
+#include <Ws2tcpip.h>
+#endif
+int main(void)
+{
+ int ret;
+ static struct sockaddr sa;
+ socklen_t salen;
+ char host[NI_MAXHOST];
+ char serv[NI_MAXSERV];
+
+ salen = sizeof(sa);
+ ret = getnameinfo(&sa, salen,
+ host, sizeof host, serv, sizeof serv,
+ NI_NAMEREQD | NI_DGRAM | NI_NOFQDN | NI_NUMERICHOST | NI_NUMERICSERV);
+ return 0 == ret;
+}
+EOC
+cyn=getnameinfo
+set d_getnameinfo '-lWs2_32'
+eval $trylink
+