~ubuntu-branches/debian/lenny/freetds/lenny

« back to all changes in this revision

Viewing changes to m4/ac_caolan_func_which_gethostbyname_r.m4

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2008-08-02 11:49:53 UTC
  • mfrom: (2.1.10 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080802114953-0qdeowgl63k42n2c
Tags: 0.82-4
* Fix a typo in the freetds-common description, ugh
* Versioned replaces of libct4 by freetds-common, since the current one
  obviously doesn't have overlapping files.
* tdsodbc: check for /var/lib/odbc existence before removing it in the
  postinst, since there are cases where it won't exist on upgrade (i.e.,
  if the driver was never enabled in the first place).  Closes: #493303.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl $Id: ac_caolan_func_which_gethostbyname_r.m4,v 1.3 2006/03/29 16:24:36 freddy77 Exp $
 
2
##
 
3
# @synopsis AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R
 
4
#
 
5
# Provides a test to determine the correct 
 
6
# way to call gethostbyname_r
 
7
#
 
8
# defines HAVE_FUNC_GETHOSTBYNAME_R_6 if it needs 6 arguments (e.g linux)
 
9
# defines HAVE_FUNC_GETHOSTBYNAME_R_5 if it needs 5 arguments (e.g. solaris)
 
10
# defines HAVE_FUNC_GETHOSTBYNAME_R_3 if it needs 3 arguments (e.g. osf/1)
 
11
#
 
12
# if used in conjunction in gethostname.c the api demonstrated
 
13
# in test.c can be used regardless of which gethostbyname_r 
 
14
# exists. These example files found at
 
15
# http://www.csn.ul.ie/~caolan/publink/gethostbyname_r
 
16
#
 
17
# @author Caolan McNamara <caolan@skynet.ie>
 
18
# updated with AC_LINK_IFELSE March 2006 <jklowden@schemamania.org>.
 
19
# Could probably be replaced with better version: 
 
20
#       http://autoconf-archive.cryp.to/ax_func_which_gethostbyname_r.html
 
21
#
 
22
# based on David Arnold's autoconf suggestion in the threads faq
 
23
##
 
24
AC_DEFUN([AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R],
 
25
[ac_save_CFLAGS=$CFLAGS
 
26
CFLAGS="$CFLAGS $NETWORK_LIBS"
 
27
AC_CACHE_CHECK(for which type of gethostbyname_r, ac_cv_func_which_gethostname_r, [
 
28
        AC_LINK_IFELSE([AC_LANG_PROGRAM([
 
29
#               include <netdb.h> 
 
30
        ],      [
 
31
 
 
32
        char *name;
 
33
        struct hostent *he;
 
34
        struct hostent_data data;
 
35
        (void) gethostbyname_r(name, he, &data);
 
36
 
 
37
                ])],ac_cv_func_which_gethostname_r=three, 
 
38
                        [
 
39
dnl                     ac_cv_func_which_gethostname_r=no
 
40
  AC_LINK_IFELSE([AC_LANG_PROGRAM([
 
41
#   include <netdb.h>
 
42
  ], [[
 
43
        char *name;
 
44
        struct hostent *he, *res;
 
45
        char buffer[2048];
 
46
        int buflen = 2048;
 
47
        int h_errnop;
 
48
        (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
 
49
  ]])],ac_cv_func_which_gethostname_r=six,
 
50
  
 
51
  [
 
52
dnl  ac_cv_func_which_gethostname_r=no
 
53
  AC_LINK_IFELSE([AC_LANG_PROGRAM([
 
54
#   include <netdb.h>
 
55
  ], [[
 
56
                        char *name;
 
57
                        struct hostent *he;
 
58
                        char buffer[2048];
 
59
                        int buflen = 2048;
 
60
                        int h_errnop;
 
61
                        (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
 
62
  ]])],ac_cv_func_which_gethostname_r=five,ac_cv_func_which_gethostname_r=no)
 
63
 
 
64
  ]
 
65
  
 
66
  )
 
67
                        ]
 
68
                )])
 
69
 
 
70
if test $ac_cv_func_which_gethostname_r = six; then
 
71
  AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6, 1, [Define to 1 if your system provides the 6-parameter version of gethostbyname_r().])
 
72
elif test $ac_cv_func_which_gethostname_r = five; then
 
73
  AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5, 1, [Define to 1 if your system provides the 5-parameter version of gethostbyname_r().])
 
74
elif test $ac_cv_func_which_gethostname_r = three; then
 
75
  AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3, 1, [Define to 1 if your system provides the 3-parameter version of gethostbyname_r().])
 
76
 
 
77
fi
 
78
CFLAGS=$ac_save_CFLAGS
 
79
])
 
80
 
 
81