1 dnl @synopsis AC_raf_FUNC_WHICH_GETSERVBYNAME_R
3 dnl Provides a test to determine the correct way to call
6 dnl - defines HAVE_FUNC_GETSERVBYNAME_R_6 if it needs 6 arguments (e.g linux)
7 dnl - defines HAVE_FUNC_GETSERVBYNAME_R_5 if it needs 5 arguments (e.g. solaris)
8 dnl - defines HAVE_FUNC_GETSERVBYNAME_R_4 if it needs 4 arguments (e.g. osf/1)
10 dnl An example use can be found at
11 dnl http://raf.org/autoconf/net_getservbyname.c
13 dnl Based on Caolan McNamara's gethostbyname_r macro. Based on David
14 dnl Arnold's autoconf suggestion in the threads faq.
17 dnl @author raf <raf@raf.org>
18 dnl @version 2001-08-20
19 dnl @license GPLWithACException
21 AC_DEFUN([AC_raf_FUNC_WHICH_GETSERVBYNAME_R],
23 AC_CACHE_CHECK(how many arguments getservbyname_r() takes,
24 ac_cv_func_which_getservbyname_r,
26 dnl we need to use C++ to detect missing prototypes
29 AC_TRY_COMPILE([#include <netdb.h>],
33 struct servent *se, *res;
36 (void) getservbyname_r(name, proto, se, buffer, buflen, &res)
38 ac_cv_func_which_getservbyname_r=six,
40 AC_TRY_COMPILE([#include <netdb.h>],
47 (void) getservbyname_r(name, proto, se, buffer, buflen)
49 ac_cv_func_which_getservbyname_r=five,
51 AC_TRY_COMPILE([#include <netdb.h>],
56 struct servent_data data;
57 (void) getservbyname_r(name, proto, se, &data);
59 ac_cv_func_which_getservbyname_r=four,
60 ac_cv_func_which_getservbyname_r=no
70 if test $ac_cv_func_which_getservbyname_r = six; then
71 AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_6)
72 elif test $ac_cv_func_which_getservbyname_r = five; then
73 AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_5)
74 elif test $ac_cv_func_which_getservbyname_r = four; then
75 AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_4)