]> Pileus Git - ~andy/fetchmail/blob - m4-local/gethostbyname_r.m4
Complete Dominik's name.
[~andy/fetchmail] / m4-local / gethostbyname_r.m4
1 dnl @synopsis ACX_WHICH_GETHOSTBYNAME_R
2 dnl
3 dnl Provides a test to determine the correct way to call gethostbyname_r
4 dnl
5 dnl defines HAVE_GETHOSTBYNAME_R to the number of arguments required
6 dnl
7 dnl e.g. 6 arguments (linux)
8 dnl e.g. 5 arguments (solaris)
9 dnl e.g. 3 arguments (osf/1)
10 dnl
11 dnl @version $Id: acinclude.m4,v 1.6 2001/10/17 07:19:14 brian Exp $
12 dnl @author Brian Stafford <brian@stafford.uklinux.net>
13 dnl
14 dnl based on version by Caolan McNamara <caolan@skynet.ie>
15 dnl based on David Arnold's autoconf suggestion in the threads faq
16 dnl with fixes and updates by Matthias Andree
17 dnl
18 AC_DEFUN([ACX_WHICH_GETHOSTBYNAME_R],
19 [AC_CACHE_CHECK(number of arguments to gethostbyname_r,
20                 acx_cv_which_gethostbyname_r, [
21         AC_TRY_LINK([
22 #               include <netdb.h> 
23         ],      [
24
25         char *name;
26         struct hostent *he;
27         struct hostent_data data;
28         (void) gethostbyname_r(name, he, &data);
29
30                 ],acx_cv_which_gethostbyname_r=3,
31                         [
32 dnl                     acx_cv_which_gethostbyname_r=0
33   AC_TRY_LINK([
34 #include <stdlib.h>
35 #   include <netdb.h>
36   ], [
37         char *name;
38         struct hostent *he, *res;
39         char *buffer = NULL;
40         int buflen = 2048;
41         int h_errnop;
42         (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
43   ],acx_cv_which_gethostbyname_r=6,
44   
45   [
46 dnl  acx_cv_which_gethostbyname_r=0
47   AC_TRY_LINK([
48 #include <stdlib.h>
49 #   include <netdb.h>
50   ], [
51                         char *name;
52                         struct hostent *he;
53                         char *buffer = NULL;
54                         int buflen = 2048;
55                         int h_errnop;
56                         (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
57   ],acx_cv_which_gethostbyname_r=5,acx_cv_which_gethostbyname_r=0)
58
59   ]
60   
61   )
62                         ]
63                 )
64         ])
65
66 if test $acx_cv_which_gethostbyname_r -gt 0 ; then
67     AC_DEFINE_UNQUOTED([HAVE_GETHOSTBYNAME_R], $acx_cv_which_gethostbyname_r,
68                        [Number of parameters to gethostbyname_r or 0 if not available])
69 fi
70
71 ])