dnl @synopsis AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R dnl dnl Provides a test to determine the correct dnl way to call gethostbyname_r: dnl dnl - defines HAVE_FUNC_GETHOSTBYNAME_R_6 if it needs 6 arguments (e.g linux) dnl - defines HAVE_FUNC_GETHOSTBYNAME_R_5 if it needs 5 arguments (e.g. solaris) dnl - defines HAVE_FUNC_GETHOSTBYNAME_R_3 if it needs 3 arguments (e.g. osf/1) dnl dnl If used in conjunction in gethostname.c the api demonstrated dnl in test.c can be used regardless of which gethostbyname_r dnl exists. These example files found at dnl . dnl dnl Based on David Arnold's autoconf suggestion in the threads faq. dnl dnl @version $Id: ac_caolan_func_which_gethostbyname_r.m4,v 1.1.1.1 2001/07/26 00:46 ac-archive-0.5.39 $ dnl @author Caolan McNamara dnl AC_DEFUN(AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R, [AC_CACHE_CHECK(for which type of gethostbyname_r, ac_cv_func_which_gethostname_r, [ AC_CHECK_FUNC(gethostbyname_r, [ AC_TRY_COMPILE([ # include ], [ char *name; struct hostent *he; struct hostent_data data; (void) gethostbyname_r(name, he, &data); ],ac_cv_func_which_gethostname_r=three, [ dnl ac_cv_func_which_gethostname_r=no AC_TRY_COMPILE([ # include ], [ char *name; struct hostent *he, *res; char buffer[2048]; int buflen = 2048; int h_errnop; (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) ],ac_cv_func_which_gethostname_r=six, [ dnl ac_cv_func_which_gethostname_r=no AC_TRY_COMPILE([ # include ], [ char *name; struct hostent *he; char buffer[2048]; int buflen = 2048; int h_errnop; (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) ],ac_cv_func_which_gethostname_r=five,ac_cv_func_which_gethostname_r=no) ] ) ] )] ,ac_cv_func_which_gethostname_r=no)]) if test $ac_cv_func_which_gethostname_r = six; then AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6) elif test $ac_cv_func_which_gethostname_r = five; then AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5) elif test $ac_cv_func_which_gethostname_r = three; then AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3) fi ])