]>
Commit | Line | Data |
---|---|---|
bebf40d5 SN |
1 | dnl @synopsis AC_raf_FUNC_WHICH_GETSERVBYNAME_R |
2 | dnl | |
3 | dnl Provides a test to determine the correct way to call | |
4 | dnl getservbyname_r: | |
5 | dnl | |
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) | |
9 | dnl | |
10 | dnl An example use can be found at | |
11 | dnl http://raf.org/autoconf/net_getservbyname.c | |
12 | dnl | |
13 | dnl Based on Caolan McNamara's gethostbyname_r macro. Based on David | |
14 | dnl Arnold's autoconf suggestion in the threads faq. | |
15 | dnl | |
16 | dnl @category Misc | |
17 | dnl @author raf <raf@raf.org> | |
18 | dnl @version 2001-08-20 | |
19 | dnl @license GPLWithACException | |
20 | ||
21 | AC_DEFUN([AC_raf_FUNC_WHICH_GETSERVBYNAME_R], | |
9052e07d VZ |
22 | [AC_CHECK_FUNC(getservbyname_r, |
23 | [AC_TRY_COMPILE([#include <netdb.h>], | |
24 | [ | |
25 | char *name; | |
26 | char *proto; | |
27 | struct servent *se; | |
28 | struct servent_data data; | |
29 | (void) getservbyname_r(name, proto, se, &data); | |
30 | ], | |
31 | ac_cv_func_which_getservbyname_r=four, | |
32 | [AC_TRY_COMPILE([#include <netdb.h>], | |
33 | [ | |
34 | char *name; | |
35 | char *proto; | |
36 | struct servent *se, *res; | |
37 | char buffer[2048]; | |
38 | int buflen = 2048; | |
39 | (void) getservbyname_r(name, proto, se, buffer, buflen, &res); | |
40 | ], | |
41 | ac_cv_func_which_getservbyname_r=six, | |
42 | [AC_TRY_COMPILE([#include <netdb.h>], | |
43 | [ | |
44 | char *name; | |
45 | char *proto; | |
46 | struct servent *se; | |
47 | char buffer[2048]; | |
48 | int buflen = 2048; | |
49 | (void) getservbyname_r(name, proto, se, buffer, buflen) | |
50 | ], | |
51 | ac_cv_func_which_getservbyname_r=five, | |
52 | ac_cv_func_which_getservbyname_r=no | |
53 | )] | |
54 | )] | |
55 | )], | |
56 | ac_cv_func_which_getservbyname_r=no) | |
bebf40d5 SN |
57 | |
58 | if test $ac_cv_func_which_getservbyname_r = six; then | |
59 | AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_6) | |
60 | elif test $ac_cv_func_which_getservbyname_r = five; then | |
61 | AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_5) | |
62 | elif test $ac_cv_func_which_getservbyname_r = four; then | |
63 | AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_4) | |
bebf40d5 SN |
64 | fi |
65 | ||
66 | ]) |