1 | dnl Check for a working inet_ntoa. |
---|
2 | dnl |
---|
3 | dnl Check whether inet_ntoa is present and working. Since calling inet_ntoa |
---|
4 | dnl involves passing small structs on the stack, present and working versions |
---|
5 | dnl may still not function with gcc on some platforms (such as IRIX). |
---|
6 | dnl Provides RRA_FUNC_INET_NTOA and defines HAVE_INET_NTOA if inet_ntoa is |
---|
7 | dnl present and working. |
---|
8 | dnl |
---|
9 | dnl Copyright 2008, 2009 Board of Trustees, Leland Stanford Jr. University |
---|
10 | dnl Copyright (c) 2004, 2005, 2006, 2007 |
---|
11 | dnl by Internet Systems Consortium, Inc. ("ISC") |
---|
12 | dnl Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
---|
13 | dnl 2002, 2003 by The Internet Software Consortium and Rich Salz |
---|
14 | dnl |
---|
15 | dnl See LICENSE for licensing terms. |
---|
16 | |
---|
17 | dnl Source used by RRA_FUNC_INET_NTOA. |
---|
18 | AC_DEFUN([_RRA_FUNC_INET_NTOA_SOURCE], [[ |
---|
19 | #include <sys/types.h> |
---|
20 | #include <sys/socket.h> |
---|
21 | #include <netinet/in.h> |
---|
22 | #include <arpa/inet.h> |
---|
23 | #include <string.h> |
---|
24 | |
---|
25 | int |
---|
26 | main(void) |
---|
27 | { |
---|
28 | struct in_addr in; |
---|
29 | in.s_addr = htonl(0x7f000000L); |
---|
30 | return (strcmp(inet_ntoa(in), "127.0.0.0") == 0) ? 0 : 1; |
---|
31 | } |
---|
32 | ]]) |
---|
33 | |
---|
34 | dnl The public macro. |
---|
35 | AC_DEFUN([RRA_FUNC_INET_NTOA], |
---|
36 | [AC_CACHE_CHECK(for working inet_ntoa, rra_cv_func_inet_ntoa_works, |
---|
37 | [AC_RUN_IFELSE([AC_LANG_SOURCE([_RRA_FUNC_INET_NTOA_SOURCE])], |
---|
38 | [rra_cv_func_inet_ntoa_works=yes], |
---|
39 | [rra_cv_func_inet_ntoa_works=no], |
---|
40 | [rra_cv_func_inet_ntoa_works=no])]) |
---|
41 | AS_IF([test "$rra_cv_func_inet_ntoa_works" = yes], |
---|
42 | [AC_DEFINE([HAVE_INET_NTOA], 1, |
---|
43 | [Define if your system has a working inet_ntoa function.])], |
---|
44 | [AC_LIBOBJ([inet_ntoa])])]) |
---|