]>
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], | |
81c330c6 VZ |
22 | [ |
23 | AC_CACHE_CHECK(how many arguments getservbyname_r() takes, | |
24 | ac_cv_func_which_getservbyname_r, | |
25 | [ | |
fd5199d6 VZ |
26 | dnl we need to use C++ to detect missing prototypes |
27 | AC_LANG_PUSH(C++) | |
28 | ||
81c330c6 VZ |
29 | AC_TRY_COMPILE([#include <netdb.h>], |
30 | [ | |
31 | char *name; | |
32 | char *proto; | |
33 | struct servent *se, *res; | |
34 | char buffer[2048]; | |
35 | int buflen = 2048; | |
36 | (void) getservbyname_r(name, proto, se, buffer, buflen, &res) | |
37 | ], | |
38 | ac_cv_func_which_getservbyname_r=six, | |
39 | [ | |
40 | AC_TRY_COMPILE([#include <netdb.h>], | |
41 | [ | |
42 | char *name; | |
43 | char *proto; | |
44 | struct servent *se; | |
45 | char buffer[2048]; | |
46 | int buflen = 2048; | |
47 | (void) getservbyname_r(name, proto, se, buffer, buflen) | |
48 | ], | |
49 | ac_cv_func_which_getservbyname_r=five, | |
50 | [ | |
51 | AC_TRY_COMPILE([#include <netdb.h>], | |
52 | [ | |
53 | char *name; | |
54 | char *proto; | |
55 | struct servent *se; | |
56 | struct servent_data data; | |
57 | (void) getservbyname_r(name, proto, se, &data); | |
58 | ], | |
59 | ac_cv_func_which_getservbyname_r=four, | |
60 | ac_cv_func_which_getservbyname_r=no | |
61 | ) | |
62 | ] | |
63 | ) | |
64 | ] | |
65 | ) | |
fd5199d6 | 66 | AC_LANG_POP() |
81c330c6 VZ |
67 | ] |
68 | ) | |
bebf40d5 SN |
69 | |
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) | |
bebf40d5 SN |
76 | fi |
77 | ||
78 | ]) |