Home | History | Annotate | Download | only in c-ares
      1 
      2 
      3 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
      4 dnl -------------------------------------------------
      5 dnl Use the C preprocessor to find out if the given object-style symbol
      6 dnl is defined and get its expansion. This macro will not use default
      7 dnl includes even if no INCLUDES argument is given. This macro will run
      8 dnl silently when invoked with three arguments. If the expansion would
      9 dnl result in a set of double-quoted strings the returned expansion will
     10 dnl actually be a single double-quoted string concatenating all them.
     11 
     12 AC_DEFUN([CURL_CHECK_DEF], [
     13   AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
     14   AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
     15   if test -z "$SED"; then
     16     AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
     17   fi
     18   if test -z "$GREP"; then
     19     AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
     20   fi
     21   ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
     22   tmp_exp=""
     23   AC_PREPROC_IFELSE([
     24     AC_LANG_SOURCE(
     25 ifelse($2,,,[$2])[[
     26 #ifdef $1
     27 CURL_DEF_TOKEN $1
     28 #endif
     29     ]])
     30   ],[
     31     tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
     32       "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
     33       "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
     34       "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
     35     if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
     36       tmp_exp=""
     37     fi
     38   ])
     39   if test -z "$tmp_exp"; then
     40     AS_VAR_SET(ac_HaveDef, no)
     41     ifelse($3,,[AC_MSG_RESULT([no])])
     42   else
     43     AS_VAR_SET(ac_HaveDef, yes)
     44     AS_VAR_SET(ac_Def, $tmp_exp)
     45     ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
     46   fi
     47   AS_VAR_POPDEF([ac_Def])dnl
     48   AS_VAR_POPDEF([ac_HaveDef])dnl
     49 ])
     50 
     51 
     52 dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
     53 dnl -------------------------------------------------
     54 dnl Use the C compiler to find out only if the given symbol is defined
     55 dnl or not, this can not find out its expansion. This macro will not use
     56 dnl default includes even if no INCLUDES argument is given. This macro
     57 dnl will run silently when invoked with three arguments.
     58 
     59 AC_DEFUN([CURL_CHECK_DEF_CC], [
     60   AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
     61   ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
     62   AC_COMPILE_IFELSE([
     63     AC_LANG_SOURCE(
     64 ifelse($2,,,[$2])[[
     65 int main (void)
     66 {
     67 #ifdef $1
     68   return 0;
     69 #else
     70   force compilation error
     71 #endif
     72 }
     73     ]])
     74   ],[
     75     tst_symbol_defined="yes"
     76   ],[
     77     tst_symbol_defined="no"
     78   ])
     79   if test "$tst_symbol_defined" = "yes"; then
     80     AS_VAR_SET(ac_HaveDef, yes)
     81     ifelse($3,,[AC_MSG_RESULT([yes])])
     82   else
     83     AS_VAR_SET(ac_HaveDef, no)
     84     ifelse($3,,[AC_MSG_RESULT([no])])
     85   fi
     86   AS_VAR_POPDEF([ac_HaveDef])dnl
     87 ])
     88 
     89 
     90 dnl CARES_CHECK_LIB_XNET
     91 dnl -------------------------------------------------
     92 dnl Verify if X/Open network library is required.
     93 
     94 AC_DEFUN([CARES_CHECK_LIB_XNET], [
     95   AC_MSG_CHECKING([if X/Open network library is required])
     96   tst_lib_xnet_required="no"
     97   AC_COMPILE_IFELSE([
     98     AC_LANG_SOURCE([[
     99 int main (void)
    100 {
    101 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
    102   return 0;
    103 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
    104   return 0;
    105 #else
    106   force compilation error
    107 #endif
    108 }
    109     ]])
    110   ],[
    111     tst_lib_xnet_required="yes"
    112     LIBS="$LIBS -lxnet"
    113   ])
    114   AC_MSG_RESULT([$tst_lib_xnet_required])
    115 ])
    116 
    117 
    118 dnl CARES_CHECK_AIX_ALL_SOURCE
    119 dnl -------------------------------------------------
    120 dnl Provides a replacement of traditional AC_AIX with
    121 dnl an uniform behaviour across all autoconf versions,
    122 dnl and with our own placement rules.
    123 
    124 AC_DEFUN([CARES_CHECK_AIX_ALL_SOURCE], [
    125   AH_VERBATIM([_ALL_SOURCE],
    126     [/* Define to 1 if OS is AIX. */
    127 #ifndef _ALL_SOURCE
    128 #  undef _ALL_SOURCE
    129 #endif])
    130   AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
    131   AC_BEFORE([$0], [CARES_CONFIGURE_REENTRANT])dnl
    132   AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
    133   AC_EGREP_CPP([yes_this_is_aix],[
    134 #ifdef _AIX
    135    yes_this_is_aix
    136 #endif
    137   ],[
    138     AC_MSG_RESULT([yes])
    139     AC_DEFINE(_ALL_SOURCE)
    140   ],[
    141     AC_MSG_RESULT([no])
    142   ])
    143 ])
    144 
    145 
    146 dnl CURL_CHECK_HEADER_WINDOWS
    147 dnl -------------------------------------------------
    148 dnl Check for compilable and valid windows.h header
    149 
    150 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
    151   AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
    152     AC_COMPILE_IFELSE([
    153       AC_LANG_PROGRAM([[
    154 #undef inline
    155 #ifndef WIN32_LEAN_AND_MEAN
    156 #define WIN32_LEAN_AND_MEAN
    157 #endif
    158 #include <windows.h>
    159       ]],[[
    160 #if defined(__CYGWIN__) || defined(__CEGCC__)
    161         HAVE_WINDOWS_H shall not be defined.
    162 #else
    163         int dummy=2*WINVER;
    164 #endif
    165       ]])
    166     ],[
    167       ac_cv_header_windows_h="yes"
    168     ],[
    169       ac_cv_header_windows_h="no"
    170     ])
    171   ])
    172   case "$ac_cv_header_windows_h" in
    173     yes)
    174       AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
    175         [Define to 1 if you have the windows.h header file.])
    176       AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
    177         [Define to avoid automatic inclusion of winsock.h])
    178       ;;
    179   esac
    180 ])
    181 
    182 
    183 dnl CURL_CHECK_NATIVE_WINDOWS
    184 dnl -------------------------------------------------
    185 dnl Check if building a native Windows target
    186 
    187 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
    188   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
    189   AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
    190     if test "$ac_cv_header_windows_h" = "no"; then
    191       ac_cv_native_windows="no"
    192     else
    193       AC_COMPILE_IFELSE([
    194         AC_LANG_PROGRAM([[
    195         ]],[[
    196 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
    197    (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
    198           int dummy=1;
    199 #else
    200           Not a native Windows build target.
    201 #endif
    202         ]])
    203       ],[
    204         ac_cv_native_windows="yes"
    205       ],[
    206         ac_cv_native_windows="no"
    207       ])
    208     fi
    209   ])
    210   case "$ac_cv_native_windows" in
    211     yes)
    212       AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
    213         [Define to 1 if you are building a native Windows target.])
    214       ;;
    215   esac
    216 ])
    217 
    218 
    219 dnl CURL_CHECK_HEADER_WINSOCK
    220 dnl -------------------------------------------------
    221 dnl Check for compilable and valid winsock.h header
    222 
    223 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
    224   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
    225   AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
    226     AC_COMPILE_IFELSE([
    227       AC_LANG_PROGRAM([[
    228 #undef inline
    229 #ifndef WIN32_LEAN_AND_MEAN
    230 #define WIN32_LEAN_AND_MEAN
    231 #endif
    232 #include <windows.h>
    233 #include <winsock.h>
    234       ]],[[
    235 #if defined(__CYGWIN__) || defined(__CEGCC__)
    236         HAVE_WINSOCK_H shall not be defined.
    237 #else
    238         int dummy=WSACleanup();
    239 #endif
    240       ]])
    241     ],[
    242       ac_cv_header_winsock_h="yes"
    243     ],[
    244       ac_cv_header_winsock_h="no"
    245     ])
    246   ])
    247   case "$ac_cv_header_winsock_h" in
    248     yes)
    249       AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
    250         [Define to 1 if you have the winsock.h header file.])
    251       ;;
    252   esac
    253 ])
    254 
    255 
    256 dnl CURL_CHECK_HEADER_WINSOCK2
    257 dnl -------------------------------------------------
    258 dnl Check for compilable and valid winsock2.h header
    259 
    260 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
    261   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
    262   AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
    263     AC_COMPILE_IFELSE([
    264       AC_LANG_PROGRAM([[
    265 #undef inline
    266 #ifndef WIN32_LEAN_AND_MEAN
    267 #define WIN32_LEAN_AND_MEAN
    268 #endif
    269 #include <windows.h>
    270 #include <winsock2.h>
    271       ]],[[
    272 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
    273         HAVE_WINSOCK2_H shall not be defined.
    274 #else
    275         int dummy=2*IPPROTO_ESP;
    276 #endif
    277       ]])
    278     ],[
    279       ac_cv_header_winsock2_h="yes"
    280     ],[
    281       ac_cv_header_winsock2_h="no"
    282     ])
    283   ])
    284   case "$ac_cv_header_winsock2_h" in
    285     yes)
    286       AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
    287         [Define to 1 if you have the winsock2.h header file.])
    288       ;;
    289   esac
    290 ])
    291 
    292 
    293 dnl CURL_CHECK_HEADER_WS2TCPIP
    294 dnl -------------------------------------------------
    295 dnl Check for compilable and valid ws2tcpip.h header
    296 
    297 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
    298   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
    299   AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
    300     AC_COMPILE_IFELSE([
    301       AC_LANG_PROGRAM([[
    302 #undef inline
    303 #ifndef WIN32_LEAN_AND_MEAN
    304 #define WIN32_LEAN_AND_MEAN
    305 #endif
    306 #include <windows.h>
    307 #include <winsock2.h>
    308 #include <ws2tcpip.h>
    309       ]],[[
    310 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
    311         HAVE_WS2TCPIP_H shall not be defined.
    312 #else
    313         int dummy=2*IP_PKTINFO;
    314 #endif
    315       ]])
    316     ],[
    317       ac_cv_header_ws2tcpip_h="yes"
    318     ],[
    319       ac_cv_header_ws2tcpip_h="no"
    320     ])
    321   ])
    322   case "$ac_cv_header_ws2tcpip_h" in
    323     yes)
    324       AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
    325         [Define to 1 if you have the ws2tcpip.h header file.])
    326       ;;
    327   esac
    328 ])
    329 
    330 
    331 dnl CURL_CHECK_HEADER_MALLOC
    332 dnl -------------------------------------------------
    333 dnl Check for compilable and valid malloc.h header,
    334 dnl and check if it is needed even with stdlib.h
    335 
    336 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
    337   AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
    338     AC_COMPILE_IFELSE([
    339       AC_LANG_PROGRAM([[
    340 #include <malloc.h>
    341       ]],[[
    342         void *p = malloc(10);
    343         void *q = calloc(10,10);
    344         free(p);
    345         free(q);
    346       ]])
    347     ],[
    348       ac_cv_header_malloc_h="yes"
    349     ],[
    350       ac_cv_header_malloc_h="no"
    351     ])
    352   ])
    353   if test "$ac_cv_header_malloc_h" = "yes"; then
    354     AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
    355       [Define to 1 if you have the malloc.h header file.])
    356     #
    357     AC_COMPILE_IFELSE([
    358       AC_LANG_PROGRAM([[
    359 #include <stdlib.h>
    360       ]],[[
    361         void *p = malloc(10);
    362         void *q = calloc(10,10);
    363         free(p);
    364         free(q);
    365       ]])
    366     ],[
    367       curl_cv_need_header_malloc_h="no"
    368     ],[
    369       curl_cv_need_header_malloc_h="yes"
    370     ])
    371     #
    372     case "$curl_cv_need_header_malloc_h" in
    373       yes)
    374         AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
    375           [Define to 1 if you need the malloc.h header file even with stdlib.h])
    376         ;;
    377     esac
    378   fi
    379 ])
    380 
    381 
    382 dnl CURL_CHECK_HEADER_MEMORY
    383 dnl -------------------------------------------------
    384 dnl Check for compilable and valid memory.h header,
    385 dnl and check if it is needed even with stdlib.h for
    386 dnl memory related functions.
    387 
    388 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
    389   AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
    390     AC_COMPILE_IFELSE([
    391       AC_LANG_PROGRAM([[
    392 #include <memory.h>
    393       ]],[[
    394         void *p = malloc(10);
    395         void *q = calloc(10,10);
    396         free(p);
    397         free(q);
    398       ]])
    399     ],[
    400       ac_cv_header_memory_h="yes"
    401     ],[
    402       ac_cv_header_memory_h="no"
    403     ])
    404   ])
    405   if test "$ac_cv_header_memory_h" = "yes"; then
    406     AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
    407       [Define to 1 if you have the memory.h header file.])
    408     #
    409     AC_COMPILE_IFELSE([
    410       AC_LANG_PROGRAM([[
    411 #include <stdlib.h>
    412       ]],[[
    413         void *p = malloc(10);
    414         void *q = calloc(10,10);
    415         free(p);
    416         free(q);
    417       ]])
    418     ],[
    419       curl_cv_need_header_memory_h="no"
    420     ],[
    421       curl_cv_need_header_memory_h="yes"
    422     ])
    423     #
    424     case "$curl_cv_need_header_memory_h" in
    425       yes)
    426         AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
    427           [Define to 1 if you need the memory.h header file even with stdlib.h])
    428         ;;
    429     esac
    430   fi
    431 ])
    432 
    433 
    434 dnl CURL_CHECK_FUNC_GETNAMEINFO
    435 dnl -------------------------------------------------
    436 dnl Test if the getnameinfo function is available,
    437 dnl and check the types of five of its arguments.
    438 dnl If the function succeeds HAVE_GETNAMEINFO will be
    439 dnl defined, defining the types of the arguments in
    440 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
    441 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
    442 dnl and also defining the type qualifier of first
    443 dnl argument in GETNAMEINFO_QUAL_ARG1.
    444 
    445 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
    446   AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
    447   AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
    448   #
    449   AC_MSG_CHECKING([for getnameinfo])
    450   AC_LINK_IFELSE([
    451     AC_LANG_FUNC_LINK_TRY([getnameinfo])
    452   ],[
    453     AC_MSG_RESULT([yes])
    454     curl_cv_getnameinfo="yes"
    455   ],[
    456     AC_MSG_RESULT([no])
    457     curl_cv_getnameinfo="no"
    458   ])
    459   #
    460   if test "$curl_cv_getnameinfo" != "yes"; then
    461     AC_MSG_CHECKING([deeper for getnameinfo])
    462     AC_LINK_IFELSE([
    463       AC_LANG_PROGRAM([[
    464       ]],[[
    465         getnameinfo();
    466       ]])
    467     ],[
    468       AC_MSG_RESULT([yes])
    469       curl_cv_getnameinfo="yes"
    470     ],[
    471       AC_MSG_RESULT([but still no])
    472       curl_cv_getnameinfo="no"
    473     ])
    474   fi
    475   #
    476   if test "$curl_cv_getnameinfo" != "yes"; then
    477     AC_MSG_CHECKING([deeper and deeper for getnameinfo])
    478     AC_LINK_IFELSE([
    479       AC_LANG_PROGRAM([[
    480 #undef inline
    481 #ifdef HAVE_WINDOWS_H
    482 #ifndef WIN32_LEAN_AND_MEAN
    483 #define WIN32_LEAN_AND_MEAN
    484 #endif
    485 #include <windows.h>
    486 #ifdef HAVE_WINSOCK2_H
    487 #include <winsock2.h>
    488 #ifdef HAVE_WS2TCPIP_H
    489 #include <ws2tcpip.h>
    490 #endif
    491 #endif
    492 #else
    493 #ifdef HAVE_SYS_TYPES_H
    494 #include <sys/types.h>
    495 #endif
    496 #ifdef HAVE_SYS_SOCKET_H
    497 #include <sys/socket.h>
    498 #endif
    499 #ifdef HAVE_NETDB_H
    500 #include <netdb.h>
    501 #endif
    502 #endif
    503       ]],[[
    504         getnameinfo(0, 0, 0, 0, 0, 0, 0);
    505       ]])
    506     ],[
    507       AC_MSG_RESULT([yes])
    508       curl_cv_getnameinfo="yes"
    509     ],[
    510       AC_MSG_RESULT([but still no])
    511       curl_cv_getnameinfo="no"
    512     ])
    513   fi
    514   #
    515   if test "$curl_cv_getnameinfo" = "yes"; then
    516     AC_CACHE_CHECK([types of arguments for getnameinfo],
    517       [curl_cv_func_getnameinfo_args], [
    518       curl_cv_func_getnameinfo_args="unknown"
    519       for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
    520         for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
    521           for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
    522             for gni_arg7 in 'int' 'unsigned int'; do
    523               if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
    524                 AC_COMPILE_IFELSE([
    525                   AC_LANG_PROGRAM([[
    526 #undef inline
    527 #ifdef HAVE_WINDOWS_H
    528 #ifndef WIN32_LEAN_AND_MEAN
    529 #define WIN32_LEAN_AND_MEAN
    530 #endif
    531 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
    532 #undef _WIN32_WINNT
    533 #define _WIN32_WINNT 0x0501
    534 #endif
    535 #include <windows.h>
    536 #ifdef HAVE_WINSOCK2_H
    537 #include <winsock2.h>
    538 #ifdef HAVE_WS2TCPIP_H
    539 #include <ws2tcpip.h>
    540 #endif
    541 #endif
    542 #define GNICALLCONV WSAAPI
    543 #else
    544 #ifdef HAVE_SYS_TYPES_H
    545 #include <sys/types.h>
    546 #endif
    547 #ifdef HAVE_SYS_SOCKET_H
    548 #include <sys/socket.h>
    549 #endif
    550 #ifdef HAVE_NETDB_H
    551 #include <netdb.h>
    552 #endif
    553 #define GNICALLCONV
    554 #endif
    555                     extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
    556                                            char *, $gni_arg46,
    557                                            char *, $gni_arg46,
    558                                            $gni_arg7);
    559                   ]],[[
    560                     $gni_arg2 salen=0;
    561                     $gni_arg46 hostlen=0;
    562                     $gni_arg46 servlen=0;
    563                     $gni_arg7 flags=0;
    564                     int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
    565                   ]])
    566                 ],[
    567                   curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
    568                 ])
    569               fi
    570             done
    571           done
    572         done
    573       done
    574     ]) # AC-CACHE-CHECK
    575     if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
    576       AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
    577       AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
    578     else
    579       gni_prev_IFS=$IFS; IFS=','
    580       set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
    581       IFS=$gni_prev_IFS
    582       shift
    583       #
    584       gni_qual_type_arg1=$[1]
    585       #
    586       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
    587         [Define to the type of arg 2 for getnameinfo.])
    588       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
    589         [Define to the type of args 4 and 6 for getnameinfo.])
    590       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
    591         [Define to the type of arg 7 for getnameinfo.])
    592       #
    593       prev_sh_opts=$-
    594       #
    595       case $prev_sh_opts in
    596         *f*)
    597           ;;
    598         *)
    599           set -f
    600           ;;
    601       esac
    602       #
    603       case "$gni_qual_type_arg1" in
    604         const*)
    605           gni_qual_arg1=const
    606           gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
    607         ;;
    608         *)
    609           gni_qual_arg1=
    610           gni_type_arg1=$gni_qual_type_arg1
    611         ;;
    612       esac
    613       #
    614       AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
    615         [Define to the type qualifier of arg 1 for getnameinfo.])
    616       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
    617         [Define to the type of arg 1 for getnameinfo.])
    618       #
    619       case $prev_sh_opts in
    620         *f*)
    621           ;;
    622         *)
    623           set +f
    624           ;;
    625       esac
    626       #
    627       AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
    628         [Define to 1 if you have the getnameinfo function.])
    629       ac_cv_func_getnameinfo="yes"
    630     fi
    631   fi
    632 ])
    633 
    634 
    635 dnl TYPE_SOCKADDR_STORAGE
    636 dnl -------------------------------------------------
    637 dnl Check for struct sockaddr_storage. Most IPv6-enabled
    638 dnl hosts have it, but AIX 4.3 is one known exception.
    639 
    640 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
    641 [
    642    AC_CHECK_TYPE([struct sockaddr_storage],
    643         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
    644                   [if struct sockaddr_storage is defined]), ,
    645    [
    646 #undef inline
    647 #ifdef HAVE_WINDOWS_H
    648 #ifndef WIN32_LEAN_AND_MEAN
    649 #define WIN32_LEAN_AND_MEAN
    650 #endif
    651 #include <windows.h>
    652 #ifdef HAVE_WINSOCK2_H
    653 #include <winsock2.h>
    654 #endif
    655 #else
    656 #ifdef HAVE_SYS_TYPES_H
    657 #include <sys/types.h>
    658 #endif
    659 #ifdef HAVE_SYS_SOCKET_H
    660 #include <sys/socket.h>
    661 #endif
    662 #ifdef HAVE_NETINET_IN_H
    663 #include <netinet/in.h>
    664 #endif
    665 #ifdef HAVE_ARPA_INET_H
    666 #include <arpa/inet.h>
    667 #endif
    668 #endif
    669    ])
    670 ])
    671 
    672 
    673 dnl CURL_CHECK_NI_WITHSCOPEID
    674 dnl -------------------------------------------------
    675 dnl Check for working NI_WITHSCOPEID in getnameinfo()
    676 
    677 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
    678   AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
    679   AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
    680   AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
    681                    netdb.h netinet/in.h arpa/inet.h)
    682   #
    683   AC_CACHE_CHECK([for working NI_WITHSCOPEID],
    684     [ac_cv_working_ni_withscopeid], [
    685     AC_RUN_IFELSE([
    686       AC_LANG_PROGRAM([[
    687 #ifdef HAVE_STDLIB_H
    688 #include <stdlib.h>
    689 #endif
    690 #ifdef HAVE_STDIO_H
    691 #include <stdio.h>
    692 #endif
    693 #ifdef HAVE_SYS_TYPES_H
    694 #include <sys/types.h>
    695 #endif
    696 #ifdef HAVE_SYS_SOCKET_H
    697 #include <sys/socket.h>
    698 #endif
    699 #ifdef HAVE_NETDB_H
    700 #include <netdb.h>
    701 #endif
    702 #ifdef HAVE_NETINET_IN_H
    703 #include <netinet/in.h>
    704 #endif
    705 #ifdef HAVE_ARPA_INET_H
    706 #include <arpa/inet.h>
    707 #endif
    708       ]],[[
    709 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
    710 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
    711         struct sockaddr_storage sa;
    712 #else
    713         unsigned char sa[256];
    714 #endif
    715         char hostbuf[NI_MAXHOST];
    716         int rc;
    717         GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
    718         GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
    719         GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
    720         int fd = socket(AF_INET6, SOCK_STREAM, 0);
    721         if(fd < 0) {
    722           perror("socket()");
    723           return 1; /* Error creating socket */
    724         }
    725         rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
    726         if(rc) {
    727           perror("getsockname()");
    728           return 2; /* Error retrieving socket name */
    729         }
    730         rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
    731         if(rc) {
    732           printf("rc = %s\n", gai_strerror(rc));
    733           return 3; /* Error translating socket address */
    734         }
    735         return 0; /* Ok, NI_WITHSCOPEID works */
    736 #else
    737         return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
    738 #endif
    739       ]]) # AC-LANG-PROGRAM
    740     ],[
    741       # Exit code == 0. Program worked.
    742       ac_cv_working_ni_withscopeid="yes"
    743     ],[
    744       # Exit code != 0. Program failed.
    745       ac_cv_working_ni_withscopeid="no"
    746     ],[
    747       # Program is not run when cross-compiling. So we assume
    748       # NI_WITHSCOPEID will work if we are able to compile it.
    749       AC_COMPILE_IFELSE([
    750         AC_LANG_PROGRAM([[
    751 #include <sys/types.h>
    752 #include <sys/socket.h>
    753 #include <netdb.h>
    754         ]],[[
    755           unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
    756         ]])
    757       ],[
    758         ac_cv_working_ni_withscopeid="yes"
    759       ],[
    760         ac_cv_working_ni_withscopeid="no"
    761       ]) # AC-COMPILE-IFELSE
    762     ]) # AC-RUN-IFELSE
    763   ]) # AC-CACHE-CHECK
    764   case "$ac_cv_working_ni_withscopeid" in
    765     yes)
    766       AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
    767         [Define to 1 if NI_WITHSCOPEID exists and works.])
    768       ;;
    769   esac
    770 ])
    771 
    772 
    773 dnl CURL_CHECK_FUNC_RECV
    774 dnl -------------------------------------------------
    775 dnl Test if the socket recv() function is available,
    776 dnl and check its return type and the types of its
    777 dnl arguments. If the function succeeds HAVE_RECV
    778 dnl will be defined, defining the types of the arguments
    779 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
    780 dnl and RECV_TYPE_ARG4, defining the type of the function
    781 dnl return value in RECV_TYPE_RETV.
    782 
    783 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
    784   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
    785   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
    786   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
    787   #
    788   AC_MSG_CHECKING([for recv])
    789   AC_LINK_IFELSE([
    790     AC_LANG_PROGRAM([[
    791 #undef inline
    792 #ifdef HAVE_WINDOWS_H
    793 #ifndef WIN32_LEAN_AND_MEAN
    794 #define WIN32_LEAN_AND_MEAN
    795 #endif
    796 #include <windows.h>
    797 #ifdef HAVE_WINSOCK2_H
    798 #include <winsock2.h>
    799 #else
    800 #ifdef HAVE_WINSOCK_H
    801 #include <winsock.h>
    802 #endif
    803 #endif
    804 #else
    805 #ifdef HAVE_SYS_TYPES_H
    806 #include <sys/types.h>
    807 #endif
    808 #ifdef HAVE_SYS_SOCKET_H
    809 #include <sys/socket.h>
    810 #endif
    811 #endif
    812     ]],[[
    813       recv(0, 0, 0, 0);
    814     ]])
    815   ],[
    816     AC_MSG_RESULT([yes])
    817     curl_cv_recv="yes"
    818   ],[
    819     AC_MSG_RESULT([no])
    820     curl_cv_recv="no"
    821   ])
    822   #
    823   if test "$curl_cv_recv" = "yes"; then
    824     AC_CACHE_CHECK([types of args and return type for recv],
    825       [curl_cv_func_recv_args], [
    826       curl_cv_func_recv_args="unknown"
    827       for recv_retv in 'int' 'ssize_t'; do
    828         for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
    829           for recv_arg2 in 'char *' 'void *'; do
    830             for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
    831               for recv_arg4 in 'int' 'unsigned int'; do
    832                 if test "$curl_cv_func_recv_args" = "unknown"; then
    833                   AC_COMPILE_IFELSE([
    834                     AC_LANG_PROGRAM([[
    835 #undef inline
    836 #ifdef HAVE_WINDOWS_H
    837 #ifndef WIN32_LEAN_AND_MEAN
    838 #define WIN32_LEAN_AND_MEAN
    839 #endif
    840 #include <windows.h>
    841 #ifdef HAVE_WINSOCK2_H
    842 #include <winsock2.h>
    843 #else
    844 #ifdef HAVE_WINSOCK_H
    845 #include <winsock.h>
    846 #endif
    847 #endif
    848 #define RECVCALLCONV PASCAL
    849 #else
    850 #ifdef HAVE_SYS_TYPES_H
    851 #include <sys/types.h>
    852 #endif
    853 #ifdef HAVE_SYS_SOCKET_H
    854 #include <sys/socket.h>
    855 #endif
    856 #define RECVCALLCONV
    857 #endif
    858                       extern $recv_retv RECVCALLCONV
    859                       recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
    860                     ]],[[
    861                       $recv_arg1 s=0;
    862                       $recv_arg2 buf=0;
    863                       $recv_arg3 len=0;
    864                       $recv_arg4 flags=0;
    865                       $recv_retv res = recv(s, buf, len, flags);
    866                     ]])
    867                   ],[
    868                     curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
    869                   ])
    870                 fi
    871               done
    872             done
    873           done
    874         done
    875       done
    876     ]) # AC-CACHE-CHECK
    877     if test "$curl_cv_func_recv_args" = "unknown"; then
    878       AC_MSG_ERROR([Cannot find proper types to use for recv args])
    879     else
    880       recv_prev_IFS=$IFS; IFS=','
    881       set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
    882       IFS=$recv_prev_IFS
    883       shift
    884       #
    885       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
    886         [Define to the type of arg 1 for recv.])
    887       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
    888         [Define to the type of arg 2 for recv.])
    889       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
    890         [Define to the type of arg 3 for recv.])
    891       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
    892         [Define to the type of arg 4 for recv.])
    893       AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
    894         [Define to the function return type for recv.])
    895       #
    896       AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
    897         [Define to 1 if you have the recv function.])
    898       ac_cv_func_recv="yes"
    899     fi
    900   else
    901     AC_MSG_ERROR([Unable to link function recv])
    902   fi
    903 ])
    904 
    905 
    906 dnl CURL_CHECK_FUNC_SEND
    907 dnl -------------------------------------------------
    908 dnl Test if the socket send() function is available,
    909 dnl and check its return type and the types of its
    910 dnl arguments. If the function succeeds HAVE_SEND
    911 dnl will be defined, defining the types of the arguments
    912 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
    913 dnl and SEND_TYPE_ARG4, defining the type of the function
    914 dnl return value in SEND_TYPE_RETV, and also defining the
    915 dnl type qualifier of second argument in SEND_QUAL_ARG2.
    916 
    917 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
    918   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
    919   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
    920   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
    921   #
    922   AC_MSG_CHECKING([for send])
    923   AC_LINK_IFELSE([
    924     AC_LANG_PROGRAM([[
    925 #undef inline
    926 #ifdef HAVE_WINDOWS_H
    927 #ifndef WIN32_LEAN_AND_MEAN
    928 #define WIN32_LEAN_AND_MEAN
    929 #endif
    930 #include <windows.h>
    931 #ifdef HAVE_WINSOCK2_H
    932 #include <winsock2.h>
    933 #else
    934 #ifdef HAVE_WINSOCK_H
    935 #include <winsock.h>
    936 #endif
    937 #endif
    938 #else
    939 #ifdef HAVE_SYS_TYPES_H
    940 #include <sys/types.h>
    941 #endif
    942 #ifdef HAVE_SYS_SOCKET_H
    943 #include <sys/socket.h>
    944 #endif
    945 #endif
    946     ]],[[
    947       send(0, 0, 0, 0);
    948     ]])
    949   ],[
    950     AC_MSG_RESULT([yes])
    951     curl_cv_send="yes"
    952   ],[
    953     AC_MSG_RESULT([no])
    954     curl_cv_send="no"
    955   ])
    956   #
    957   if test "$curl_cv_send" = "yes"; then
    958     AC_CACHE_CHECK([types of args and return type for send],
    959       [curl_cv_func_send_args], [
    960       curl_cv_func_send_args="unknown"
    961       for send_retv in 'int' 'ssize_t'; do
    962         for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
    963           for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
    964             for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
    965               for send_arg4 in 'int' 'unsigned int'; do
    966                 if test "$curl_cv_func_send_args" = "unknown"; then
    967                   AC_COMPILE_IFELSE([
    968                     AC_LANG_PROGRAM([[
    969 #undef inline
    970 #ifdef HAVE_WINDOWS_H
    971 #ifndef WIN32_LEAN_AND_MEAN
    972 #define WIN32_LEAN_AND_MEAN
    973 #endif
    974 #include <windows.h>
    975 #ifdef HAVE_WINSOCK2_H
    976 #include <winsock2.h>
    977 #else
    978 #ifdef HAVE_WINSOCK_H
    979 #include <winsock.h>
    980 #endif
    981 #endif
    982 #define SENDCALLCONV PASCAL
    983 #else
    984 #ifdef HAVE_SYS_TYPES_H
    985 #include <sys/types.h>
    986 #endif
    987 #ifdef HAVE_SYS_SOCKET_H
    988 #include <sys/socket.h>
    989 #endif
    990 #define SENDCALLCONV
    991 #endif
    992                       extern $send_retv SENDCALLCONV
    993                       send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
    994                     ]],[[
    995                       $send_arg1 s=0;
    996                       $send_arg3 len=0;
    997                       $send_arg4 flags=0;
    998                       $send_retv res = send(s, 0, len, flags);
    999                     ]])
   1000                   ],[
   1001                     curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
   1002                   ])
   1003                 fi
   1004               done
   1005             done
   1006           done
   1007         done
   1008       done
   1009     ]) # AC-CACHE-CHECK
   1010     if test "$curl_cv_func_send_args" = "unknown"; then
   1011       AC_MSG_ERROR([Cannot find proper types to use for send args])
   1012     else
   1013       send_prev_IFS=$IFS; IFS=','
   1014       set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
   1015       IFS=$send_prev_IFS
   1016       shift
   1017       #
   1018       send_qual_type_arg2=$[2]
   1019       #
   1020       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
   1021         [Define to the type of arg 1 for send.])
   1022       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
   1023         [Define to the type of arg 3 for send.])
   1024       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
   1025         [Define to the type of arg 4 for send.])
   1026       AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
   1027         [Define to the function return type for send.])
   1028       #
   1029       prev_sh_opts=$-
   1030       #
   1031       case $prev_sh_opts in
   1032         *f*)
   1033           ;;
   1034         *)
   1035           set -f
   1036           ;;
   1037       esac
   1038       #
   1039       case "$send_qual_type_arg2" in
   1040         const*)
   1041           send_qual_arg2=const
   1042           send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
   1043         ;;
   1044         *)
   1045           send_qual_arg2=
   1046           send_type_arg2=$send_qual_type_arg2
   1047         ;;
   1048       esac
   1049       #
   1050       AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
   1051         [Define to the type qualifier of arg 2 for send.])
   1052       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
   1053         [Define to the type of arg 2 for send.])
   1054       #
   1055       case $prev_sh_opts in
   1056         *f*)
   1057           ;;
   1058         *)
   1059           set +f
   1060           ;;
   1061       esac
   1062       #
   1063       AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
   1064         [Define to 1 if you have the send function.])
   1065       ac_cv_func_send="yes"
   1066     fi
   1067   else
   1068     AC_MSG_ERROR([Unable to link function send])
   1069   fi
   1070 ])
   1071 
   1072 
   1073 dnl CURL_CHECK_FUNC_RECVFROM
   1074 dnl -------------------------------------------------
   1075 dnl Test if the socket recvfrom() function is available,
   1076 dnl and check its return type and the types of its
   1077 dnl arguments. If the function succeeds HAVE_RECVFROM
   1078 dnl will be defined, defining the types of the arguments
   1079 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
   1080 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
   1081 dnl function return value in RECVFROM_TYPE_RETV.
   1082 dnl Notice that the types returned for pointer arguments
   1083 dnl will actually be the type pointed by the pointer.
   1084 
   1085 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
   1086   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
   1087   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
   1088   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
   1089   #
   1090   AC_MSG_CHECKING([for recvfrom])
   1091   AC_LINK_IFELSE([
   1092     AC_LANG_PROGRAM([[
   1093 #undef inline
   1094 #ifdef HAVE_WINDOWS_H
   1095 #ifndef WIN32_LEAN_AND_MEAN
   1096 #define WIN32_LEAN_AND_MEAN
   1097 #endif
   1098 #include <windows.h>
   1099 #ifdef HAVE_WINSOCK2_H
   1100 #include <winsock2.h>
   1101 #else
   1102 #ifdef HAVE_WINSOCK_H
   1103 #include <winsock.h>
   1104 #endif
   1105 #endif
   1106 #else
   1107 #ifdef HAVE_SYS_TYPES_H
   1108 #include <sys/types.h>
   1109 #endif
   1110 #ifdef HAVE_SYS_SOCKET_H
   1111 #include <sys/socket.h>
   1112 #endif
   1113 #endif
   1114     ]],[[
   1115       recvfrom(0, 0, 0, 0, 0, 0);
   1116     ]])
   1117   ],[
   1118     AC_MSG_RESULT([yes])
   1119     curl_cv_recvfrom="yes"
   1120   ],[
   1121     AC_MSG_RESULT([no])
   1122     curl_cv_recvfrom="no"
   1123   ])
   1124   #
   1125   if test "$curl_cv_recvfrom" = "yes"; then
   1126     AC_CACHE_CHECK([types of args and return type for recvfrom],
   1127       [curl_cv_func_recvfrom_args], [
   1128       curl_cv_func_recvfrom_args="unknown"
   1129       for recvfrom_retv in 'int' 'ssize_t'; do
   1130         for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
   1131           for recvfrom_arg2 in 'char *' 'void *'; do
   1132             for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
   1133               for recvfrom_arg4 in 'int' 'unsigned int'; do
   1134                 for recvfrom_arg5 in 'struct sockaddr *' 'void *' 'const struct sockaddr *'; do
   1135                   for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
   1136                     if test "$curl_cv_func_recvfrom_args" = "unknown"; then
   1137                       AC_COMPILE_IFELSE([
   1138                         AC_LANG_PROGRAM([[
   1139 #undef inline
   1140 #ifdef HAVE_WINDOWS_H
   1141 #ifndef WIN32_LEAN_AND_MEAN
   1142 #define WIN32_LEAN_AND_MEAN
   1143 #endif
   1144 #include <windows.h>
   1145 #ifdef HAVE_WINSOCK2_H
   1146 #include <winsock2.h>
   1147 #else
   1148 #ifdef HAVE_WINSOCK_H
   1149 #include <winsock.h>
   1150 #endif
   1151 #endif
   1152 #define RECVFROMCALLCONV PASCAL
   1153 #else
   1154 #ifdef HAVE_SYS_TYPES_H
   1155 #include <sys/types.h>
   1156 #endif
   1157 #ifdef HAVE_SYS_SOCKET_H
   1158 #include <sys/socket.h>
   1159 #endif
   1160 #define RECVFROMCALLCONV
   1161 #endif
   1162                           extern $recvfrom_retv RECVFROMCALLCONV
   1163                           recvfrom($recvfrom_arg1, $recvfrom_arg2,
   1164                                    $recvfrom_arg3, $recvfrom_arg4,
   1165                                    $recvfrom_arg5, $recvfrom_arg6);
   1166                         ]],[[
   1167                           $recvfrom_arg1 s=0;
   1168                           $recvfrom_arg2 buf=0;
   1169                           $recvfrom_arg3 len=0;
   1170                           $recvfrom_arg4 flags=0;
   1171                           $recvfrom_arg5 addr=0;
   1172                           $recvfrom_arg6 addrlen=0;
   1173                           $recvfrom_retv res=0;
   1174                           res = recvfrom(s, buf, len, flags, addr, addrlen);
   1175                         ]])
   1176                       ],[
   1177                         curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
   1178                       ])
   1179                     fi
   1180                   done
   1181                 done
   1182               done
   1183             done
   1184           done
   1185         done
   1186       done
   1187     ]) # AC-CACHE-CHECK
   1188     # Nearly last minute change for this release starts here
   1189     AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
   1190       [Define to 1 if you have the recvfrom function.])
   1191     ac_cv_func_recvfrom="yes"
   1192     # Nearly last minute change for this release ends here
   1193     if test "$curl_cv_func_recvfrom_args" = "unknown"; then
   1194       AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
   1195     else
   1196       recvfrom_prev_IFS=$IFS; IFS=','
   1197       set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
   1198       IFS=$recvfrom_prev_IFS
   1199       shift
   1200       #
   1201       recvfrom_ptrt_arg2=$[2]
   1202       recvfrom_qual_ptrt_arg5=$[5]
   1203       recvfrom_ptrt_arg6=$[6]
   1204       #
   1205       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
   1206         [Define to the type of arg 1 for recvfrom.])
   1207       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
   1208         [Define to the type of arg 3 for recvfrom.])
   1209       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
   1210         [Define to the type of arg 4 for recvfrom.])
   1211       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
   1212         [Define to the function return type for recvfrom.])
   1213       #
   1214       prev_sh_opts=$-
   1215       #
   1216       case $prev_sh_opts in
   1217         *f*)
   1218           ;;
   1219         *)
   1220           set -f
   1221           ;;
   1222       esac
   1223       #
   1224       case "$recvfrom_qual_ptrt_arg5" in
   1225         const*)
   1226           recvfrom_qual_arg5=const
   1227           recvfrom_ptrt_arg5=`echo $recvfrom_qual_ptrt_arg5 | sed 's/^const //'`
   1228         ;;
   1229         *)
   1230           recvfrom_qual_arg5=
   1231           recvfrom_ptrt_arg5=$recvfrom_qual_ptrt_arg5
   1232         ;;
   1233       esac
   1234       #
   1235       recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
   1236       recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
   1237       recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
   1238       #
   1239       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
   1240         [Define to the type pointed by arg 2 for recvfrom.])
   1241       AC_DEFINE_UNQUOTED(RECVFROM_QUAL_ARG5, $recvfrom_qual_arg5,
   1242         [Define to the type qualifier pointed by arg 5 for recvfrom.])
   1243       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
   1244         [Define to the type pointed by arg 5 for recvfrom.])
   1245       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
   1246         [Define to the type pointed by arg 6 for recvfrom.])
   1247       #
   1248       if test "$recvfrom_type_arg2" = "void"; then
   1249         AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
   1250           [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
   1251       fi
   1252       if test "$recvfrom_type_arg5" = "void"; then
   1253         AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
   1254           [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
   1255       fi
   1256       if test "$recvfrom_type_arg6" = "void"; then
   1257         AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
   1258           [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
   1259       fi
   1260       #
   1261       case $prev_sh_opts in
   1262         *f*)
   1263           ;;
   1264         *)
   1265           set +f
   1266           ;;
   1267       esac
   1268       #
   1269       AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
   1270         [Define to 1 if you have the recvfrom function.])
   1271       ac_cv_func_recvfrom="yes"
   1272     fi
   1273   else
   1274     AC_MSG_WARN([Unable to link function recvfrom])
   1275     AC_MSG_WARN([Your system will be vulnerable to some forms of DNS cache poisoning])
   1276   fi
   1277 ])
   1278 
   1279 
   1280 dnl CURL_CHECK_MSG_NOSIGNAL
   1281 dnl -------------------------------------------------
   1282 dnl Check for MSG_NOSIGNAL
   1283 
   1284 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
   1285   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
   1286   AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
   1287     AC_COMPILE_IFELSE([
   1288       AC_LANG_PROGRAM([[
   1289 #undef inline
   1290 #ifdef HAVE_WINDOWS_H
   1291 #ifndef WIN32_LEAN_AND_MEAN
   1292 #define WIN32_LEAN_AND_MEAN
   1293 #endif
   1294 #include <windows.h>
   1295 #ifdef HAVE_WINSOCK2_H
   1296 #include <winsock2.h>
   1297 #else
   1298 #ifdef HAVE_WINSOCK_H
   1299 #include <winsock.h>
   1300 #endif
   1301 #endif
   1302 #else
   1303 #ifdef HAVE_SYS_TYPES_H
   1304 #include <sys/types.h>
   1305 #endif
   1306 #ifdef HAVE_SYS_SOCKET_H
   1307 #include <sys/socket.h>
   1308 #endif
   1309 #endif
   1310       ]],[[
   1311         int flag=MSG_NOSIGNAL;
   1312       ]])
   1313     ],[
   1314       ac_cv_msg_nosignal="yes"
   1315     ],[
   1316       ac_cv_msg_nosignal="no"
   1317     ])
   1318   ])
   1319   case "$ac_cv_msg_nosignal" in
   1320     yes)
   1321       AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
   1322         [Define to 1 if you have the MSG_NOSIGNAL flag.])
   1323       ;;
   1324   esac
   1325 ])
   1326 
   1327 
   1328 dnl CURL_CHECK_STRUCT_TIMEVAL
   1329 dnl -------------------------------------------------
   1330 dnl Check for timeval struct
   1331 
   1332 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
   1333   AC_REQUIRE([AC_HEADER_TIME])dnl
   1334   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
   1335   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
   1336   AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
   1337   AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
   1338     AC_COMPILE_IFELSE([
   1339       AC_LANG_PROGRAM([[
   1340 #undef inline
   1341 #ifdef HAVE_WINDOWS_H
   1342 #ifndef WIN32_LEAN_AND_MEAN
   1343 #define WIN32_LEAN_AND_MEAN
   1344 #endif
   1345 #include <windows.h>
   1346 #ifdef HAVE_WINSOCK2_H
   1347 #include <winsock2.h>
   1348 #else
   1349 #ifdef HAVE_WINSOCK_H
   1350 #include <winsock.h>
   1351 #endif
   1352 #endif
   1353 #endif
   1354 #ifdef HAVE_SYS_TYPES_H
   1355 #include <sys/types.h>
   1356 #endif
   1357 #ifdef HAVE_SYS_TIME_H
   1358 #include <sys/time.h>
   1359 #ifdef TIME_WITH_SYS_TIME
   1360 #include <time.h>
   1361 #endif
   1362 #else
   1363 #ifdef HAVE_TIME_H
   1364 #include <time.h>
   1365 #endif
   1366 #endif
   1367 #ifdef HAVE_SYS_SOCKET_H
   1368 #include <sys/socket.h>
   1369 #endif
   1370       ]],[[
   1371         struct timeval ts;
   1372         ts.tv_sec  = 0;
   1373         ts.tv_usec = 0;
   1374       ]])
   1375     ],[
   1376       ac_cv_struct_timeval="yes"
   1377     ],[
   1378       ac_cv_struct_timeval="no"
   1379     ])
   1380   ])
   1381   case "$ac_cv_struct_timeval" in
   1382     yes)
   1383       AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
   1384         [Define to 1 if you have the timeval struct.])
   1385       ;;
   1386   esac
   1387 ])
   1388 
   1389 
   1390 dnl TYPE_SIG_ATOMIC_T
   1391 dnl -------------------------------------------------
   1392 dnl Check if the sig_atomic_t type is available, and
   1393 dnl verify if it is already defined as volatile.
   1394 
   1395 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
   1396   AC_CHECK_HEADERS(signal.h)
   1397   AC_CHECK_TYPE([sig_atomic_t],[
   1398     AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
   1399       [Define to 1 if sig_atomic_t is an available typedef.])
   1400   ], ,[
   1401 #ifdef HAVE_SIGNAL_H
   1402 #include <signal.h>
   1403 #endif
   1404   ])
   1405   case "$ac_cv_type_sig_atomic_t" in
   1406     yes)
   1407       #
   1408       AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
   1409       AC_LINK_IFELSE([
   1410         AC_LANG_PROGRAM([[
   1411 #ifdef HAVE_SIGNAL_H
   1412 #include <signal.h>
   1413 #endif
   1414         ]],[[
   1415           static volatile sig_atomic_t dummy = 0;
   1416         ]])
   1417       ],[
   1418         AC_MSG_RESULT([no])
   1419         ac_cv_sig_atomic_t_volatile="no"
   1420       ],[
   1421         AC_MSG_RESULT([yes])
   1422         ac_cv_sig_atomic_t_volatile="yes"
   1423       ])
   1424       #
   1425       if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
   1426         AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
   1427           [Define to 1 if sig_atomic_t is already defined as volatile.])
   1428       fi
   1429       ;;
   1430   esac
   1431 ])
   1432 
   1433 
   1434 dnl TYPE_IN_ADDR_T
   1435 dnl -------------------------------------------------
   1436 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
   1437 dnl and a few other things.
   1438 
   1439 AC_DEFUN([TYPE_IN_ADDR_T], [
   1440   AC_CHECK_TYPE([in_addr_t], ,[
   1441     dnl in_addr_t not available
   1442     AC_CACHE_CHECK([for in_addr_t equivalent],
   1443       [curl_cv_in_addr_t_equiv], [
   1444       curl_cv_in_addr_t_equiv="unknown"
   1445       for t in "unsigned long" int size_t unsigned long; do
   1446         if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
   1447           AC_LINK_IFELSE([
   1448             AC_LANG_PROGRAM([[
   1449 #undef inline
   1450 #ifdef HAVE_WINDOWS_H
   1451 #ifndef WIN32_LEAN_AND_MEAN
   1452 #define WIN32_LEAN_AND_MEAN
   1453 #endif
   1454 #include <windows.h>
   1455 #ifdef HAVE_WINSOCK2_H
   1456 #include <winsock2.h>
   1457 #else
   1458 #ifdef HAVE_WINSOCK_H
   1459 #include <winsock.h>
   1460 #endif
   1461 #endif
   1462 #else
   1463 #ifdef HAVE_SYS_TYPES_H
   1464 #include <sys/types.h>
   1465 #endif
   1466 #ifdef HAVE_SYS_SOCKET_H
   1467 #include <sys/socket.h>
   1468 #endif
   1469 #ifdef HAVE_NETINET_IN_H
   1470 #include <netinet/in.h>
   1471 #endif
   1472 #ifdef HAVE_ARPA_INET_H
   1473 #include <arpa/inet.h>
   1474 #endif
   1475 #endif
   1476             ]],[[
   1477               $t data = inet_addr ("1.2.3.4");
   1478             ]])
   1479           ],[
   1480             curl_cv_in_addr_t_equiv="$t"
   1481           ])
   1482         fi
   1483       done
   1484     ])
   1485     case "$curl_cv_in_addr_t_equiv" in
   1486       unknown)
   1487         AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
   1488         ;;
   1489       *)
   1490         AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
   1491           [Type to use in place of in_addr_t when system does not provide it.])
   1492         ;;
   1493     esac
   1494   ],[
   1495 #undef inline
   1496 #ifdef HAVE_WINDOWS_H
   1497 #ifndef WIN32_LEAN_AND_MEAN
   1498 #define WIN32_LEAN_AND_MEAN
   1499 #endif
   1500 #include <windows.h>
   1501 #ifdef HAVE_WINSOCK2_H
   1502 #include <winsock2.h>
   1503 #else
   1504 #ifdef HAVE_WINSOCK_H
   1505 #include <winsock.h>
   1506 #endif
   1507 #endif
   1508 #else
   1509 #ifdef HAVE_SYS_TYPES_H
   1510 #include <sys/types.h>
   1511 #endif
   1512 #ifdef HAVE_SYS_SOCKET_H
   1513 #include <sys/socket.h>
   1514 #endif
   1515 #ifdef HAVE_NETINET_IN_H
   1516 #include <netinet/in.h>
   1517 #endif
   1518 #ifdef HAVE_ARPA_INET_H
   1519 #include <arpa/inet.h>
   1520 #endif
   1521 #endif
   1522   ])
   1523 ])
   1524 
   1525 
   1526 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
   1527 dnl -------------------------------------------------
   1528 dnl Check if monotonic clock_gettime is available.
   1529 
   1530 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
   1531   AC_REQUIRE([AC_HEADER_TIME])dnl
   1532   AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
   1533   AC_MSG_CHECKING([for monotonic clock_gettime])
   1534   AC_COMPILE_IFELSE([
   1535     AC_LANG_PROGRAM([[
   1536 #ifdef HAVE_SYS_TYPES_H
   1537 #include <sys/types.h>
   1538 #endif
   1539 #ifdef HAVE_SYS_TIME_H
   1540 #include <sys/time.h>
   1541 #ifdef TIME_WITH_SYS_TIME
   1542 #include <time.h>
   1543 #endif
   1544 #else
   1545 #ifdef HAVE_TIME_H
   1546 #include <time.h>
   1547 #endif
   1548 #endif
   1549     ]],[[
   1550       struct timespec ts;
   1551       (void)clock_gettime(CLOCK_MONOTONIC, &ts);
   1552     ]])
   1553   ],[
   1554     AC_MSG_RESULT([yes])
   1555     ac_cv_func_clock_gettime="yes"
   1556   ],[
   1557     AC_MSG_RESULT([no])
   1558     ac_cv_func_clock_gettime="no"
   1559   ])
   1560   dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
   1561   dnl until library linking and run-time checks for clock_gettime succeed.
   1562 ])
   1563 
   1564 
   1565 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
   1566 dnl -------------------------------------------------
   1567 dnl If monotonic clock_gettime is available then,
   1568 dnl check and prepended to LIBS any needed libraries.
   1569 
   1570 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
   1571   AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
   1572   #
   1573   if test "$ac_cv_func_clock_gettime" = "yes"; then
   1574     #
   1575     AC_MSG_CHECKING([for clock_gettime in libraries])
   1576     #
   1577     curl_cv_save_LIBS="$LIBS"
   1578     curl_cv_gclk_LIBS="unknown"
   1579     #
   1580     for x_xlibs in '' '-lrt' '-lposix4' ; do
   1581       if test "$curl_cv_gclk_LIBS" = "unknown"; then
   1582         if test -z "$x_xlibs"; then
   1583           LIBS="$curl_cv_save_LIBS"
   1584         else
   1585           LIBS="$x_xlibs $curl_cv_save_LIBS"
   1586         fi
   1587         AC_LINK_IFELSE([
   1588           AC_LANG_PROGRAM([[
   1589 #ifdef HAVE_SYS_TYPES_H
   1590 #include <sys/types.h>
   1591 #endif
   1592 #ifdef HAVE_SYS_TIME_H
   1593 #include <sys/time.h>
   1594 #ifdef TIME_WITH_SYS_TIME
   1595 #include <time.h>
   1596 #endif
   1597 #else
   1598 #ifdef HAVE_TIME_H
   1599 #include <time.h>
   1600 #endif
   1601 #endif
   1602           ]],[[
   1603             struct timespec ts;
   1604             (void)clock_gettime(CLOCK_MONOTONIC, &ts);
   1605           ]])
   1606         ],[
   1607           curl_cv_gclk_LIBS="$x_xlibs"
   1608         ])
   1609       fi
   1610     done
   1611     #
   1612     LIBS="$curl_cv_save_LIBS"
   1613     #
   1614     case X-"$curl_cv_gclk_LIBS" in
   1615       X-unknown)
   1616         AC_MSG_RESULT([cannot find clock_gettime])
   1617         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
   1618         ac_cv_func_clock_gettime="no"
   1619         ;;
   1620       X-)
   1621         AC_MSG_RESULT([no additional lib required])
   1622         ac_cv_func_clock_gettime="yes"
   1623         ;;
   1624       *)
   1625         if test -z "$curl_cv_save_LIBS"; then
   1626           LIBS="$curl_cv_gclk_LIBS"
   1627         else
   1628           LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
   1629         fi
   1630         AC_MSG_RESULT([$curl_cv_gclk_LIBS])
   1631         ac_cv_func_clock_gettime="yes"
   1632         ;;
   1633     esac
   1634     #
   1635     dnl only do runtime verification when not cross-compiling
   1636     if test "x$cross_compiling" != "xyes" &&
   1637       test "$ac_cv_func_clock_gettime" = "yes"; then
   1638       AC_MSG_CHECKING([if monotonic clock_gettime works])
   1639       AC_RUN_IFELSE([
   1640         AC_LANG_PROGRAM([[
   1641 #ifdef HAVE_STDLIB_H
   1642 #include <stdlib.h>
   1643 #endif
   1644 #ifdef HAVE_SYS_TYPES_H
   1645 #include <sys/types.h>
   1646 #endif
   1647 #ifdef HAVE_SYS_TIME_H
   1648 #include <sys/time.h>
   1649 #ifdef TIME_WITH_SYS_TIME
   1650 #include <time.h>
   1651 #endif
   1652 #else
   1653 #ifdef HAVE_TIME_H
   1654 #include <time.h>
   1655 #endif
   1656 #endif
   1657         ]],[[
   1658           struct timespec ts;
   1659           if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
   1660             exit(0);
   1661           else
   1662             exit(1);
   1663         ]])
   1664       ],[
   1665         AC_MSG_RESULT([yes])
   1666       ],[
   1667         AC_MSG_RESULT([no])
   1668         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
   1669         ac_cv_func_clock_gettime="no"
   1670         LIBS="$curl_cv_save_LIBS"
   1671       ])
   1672     fi
   1673     #
   1674     case "$ac_cv_func_clock_gettime" in
   1675       yes)
   1676         AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
   1677           [Define to 1 if you have the clock_gettime function and monotonic timer.])
   1678         ;;
   1679     esac
   1680     #
   1681   fi
   1682   #
   1683 ])
   1684 
   1685 
   1686 dnl CARES_CHECK_LIBS_CONNECT
   1687 dnl -------------------------------------------------
   1688 dnl Verify if network connect function is already available
   1689 dnl using current libraries or if another one is required.
   1690 
   1691 AC_DEFUN([CARES_CHECK_LIBS_CONNECT], [
   1692   AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
   1693   AC_MSG_CHECKING([for connect in libraries])
   1694   tst_connect_save_LIBS="$LIBS"
   1695   tst_connect_need_LIBS="unknown"
   1696   for tst_lib in '' '-lsocket' ; do
   1697     if test "$tst_connect_need_LIBS" = "unknown"; then
   1698       LIBS="$tst_lib $tst_connect_save_LIBS"
   1699       AC_LINK_IFELSE([
   1700         AC_LANG_PROGRAM([[
   1701           $cares_includes_winsock2
   1702           #ifndef HAVE_WINDOWS_H
   1703             int connect(int, void*, int);
   1704           #endif
   1705         ]],[[
   1706           if(0 != connect(0, 0, 0))
   1707             return 1;
   1708         ]])
   1709       ],[
   1710         tst_connect_need_LIBS="$tst_lib"
   1711       ])
   1712     fi
   1713   done
   1714   LIBS="$tst_connect_save_LIBS"
   1715   #
   1716   case X-"$tst_connect_need_LIBS" in
   1717     X-unknown)
   1718       AC_MSG_RESULT([cannot find connect])
   1719       AC_MSG_ERROR([cannot find connect function in libraries.])
   1720       ;;
   1721     X-)
   1722       AC_MSG_RESULT([yes])
   1723       ;;
   1724     *)
   1725       AC_MSG_RESULT([$tst_connect_need_LIBS])
   1726       LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
   1727       ;;
   1728   esac
   1729 ])
   1730 
   1731 
   1732 dnl CARES_DEFINE_UNQUOTED (VARIABLE, [VALUE])
   1733 dnl -------------------------------------------------
   1734 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
   1735 dnl symbol that can be further used in custom template configuration
   1736 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
   1737 dnl argument for the description. Symbol definitions done with this
   1738 dnl macro are intended to be exclusively used in handcrafted *.h.in
   1739 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
   1740 dnl prevents autoheader generation and insertion of symbol template
   1741 dnl stub and definition into the first configuration header file. Do
   1742 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
   1743 dnl one serves different functional needs.
   1744 
   1745 AC_DEFUN([CARES_DEFINE_UNQUOTED], [
   1746 cat >>confdefs.h <<_EOF
   1747 [@%:@define] $1 ifelse($#, 2, [$2], 1)
   1748 _EOF
   1749 ])
   1750 
   1751 
   1752 dnl CARES_CONFIGURE_LONG
   1753 dnl -------------------------------------------------
   1754 dnl Find out the size of long as reported by sizeof() and define
   1755 dnl CARES_SIZEOF_LONG as appropriate to be used in template file
   1756 dnl ares_build.h.in to properly configure the library.
   1757 dnl The size of long is a build time characteristic and as such
   1758 dnl must be recorded in ares_build.h
   1759 
   1760 AC_DEFUN([CARES_CONFIGURE_LONG], [
   1761   if test -z "$ac_cv_sizeof_long" ||
   1762     test "$ac_cv_sizeof_long" -eq "0"; then
   1763     AC_MSG_ERROR([cannot find out size of long.])
   1764   fi
   1765   CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
   1766 ])
   1767 
   1768 
   1769 dnl CARES_CONFIGURE_ARES_SOCKLEN_T
   1770 dnl -------------------------------------------------
   1771 dnl Find out suitable ares_socklen_t data type definition and size, making
   1772 dnl appropriate definitions for template file ares_build.h.in
   1773 dnl to properly configure and use the library.
   1774 dnl
   1775 dnl The need for the ares_socklen_t definition arises mainly to properly
   1776 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
   1777 dnl data type which is 32 or 64-Bit wide depending on the data model being
   1778 dnl used, and that on the other hand is only actually used when interfacing
   1779 dnl the X/Open sockets provided in the xnet library.
   1780 
   1781 AC_DEFUN([CARES_CONFIGURE_ARES_SOCKLEN_T], [
   1782   AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
   1783   AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
   1784   AC_REQUIRE([CARES_PREPROCESS_CALLCONV])dnl
   1785   #
   1786   AC_MSG_CHECKING([for ares_socklen_t data type])
   1787   cares_typeof_ares_socklen_t="unknown"
   1788   for arg1 in int SOCKET; do
   1789     for arg2 in 'struct sockaddr' void; do
   1790       for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
   1791         if test "$cares_typeof_ares_socklen_t" = "unknown"; then
   1792           AC_COMPILE_IFELSE([
   1793             AC_LANG_PROGRAM([[
   1794               $cares_includes_ws2tcpip
   1795               $cares_includes_sys_socket
   1796               $cares_preprocess_callconv
   1797               extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
   1798             ]],[[
   1799               $t *lenptr = 0;
   1800               if(0 != getpeername(0, 0, lenptr))
   1801                 return 1;
   1802             ]])
   1803           ],[
   1804             cares_typeof_ares_socklen_t="$t"
   1805           ])
   1806         fi
   1807       done
   1808     done
   1809   done
   1810   for t in socklen_t int; do
   1811     if test "$cares_typeof_ares_socklen_t" = "void"; then
   1812       AC_COMPILE_IFELSE([
   1813         AC_LANG_PROGRAM([[
   1814           $cares_includes_sys_socket
   1815           typedef $t ares_socklen_t;
   1816         ]],[[
   1817           ares_socklen_t dummy;
   1818         ]])
   1819       ],[
   1820         cares_typeof_ares_socklen_t="$t"
   1821       ])
   1822     fi
   1823   done
   1824   AC_MSG_RESULT([$cares_typeof_ares_socklen_t])
   1825   if test "$cares_typeof_ares_socklen_t" = "void" ||
   1826     test "$cares_typeof_ares_socklen_t" = "unknown"; then
   1827     AC_MSG_ERROR([cannot find data type for ares_socklen_t.])
   1828   fi
   1829   #
   1830   AC_MSG_CHECKING([size of ares_socklen_t])
   1831   cares_sizeof_ares_socklen_t="unknown"
   1832   cares_pull_headers_socklen_t="unknown"
   1833   if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
   1834     tst_pull_header_checks='none ws2tcpip'
   1835     tst_size_checks='4'
   1836   else
   1837     tst_pull_header_checks='none systypes syssocket'
   1838     tst_size_checks='4 8 2'
   1839   fi
   1840   for tst_size in $tst_size_checks; do
   1841     for tst_pull_headers in $tst_pull_header_checks; do
   1842       if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
   1843         case $tst_pull_headers in
   1844           ws2tcpip)
   1845             tmp_includes="$cares_includes_ws2tcpip"
   1846             ;;
   1847           systypes)
   1848             tmp_includes="$cares_includes_sys_types"
   1849             ;;
   1850           syssocket)
   1851             tmp_includes="$cares_includes_sys_socket"
   1852             ;;
   1853           *)
   1854             tmp_includes=""
   1855             ;;
   1856         esac
   1857         AC_COMPILE_IFELSE([
   1858           AC_LANG_PROGRAM([[
   1859             $tmp_includes
   1860             typedef $cares_typeof_ares_socklen_t ares_socklen_t;
   1861             typedef char dummy_arr[sizeof(ares_socklen_t) == $tst_size ? 1 : -1];
   1862           ]],[[
   1863             ares_socklen_t dummy;
   1864           ]])
   1865         ],[
   1866           cares_sizeof_ares_socklen_t="$tst_size"
   1867           cares_pull_headers_socklen_t="$tst_pull_headers"
   1868         ])
   1869       fi
   1870     done
   1871   done
   1872   AC_MSG_RESULT([$cares_sizeof_ares_socklen_t])
   1873   if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
   1874     AC_MSG_ERROR([cannot find out size of ares_socklen_t.])
   1875   fi
   1876   #
   1877   case $cares_pull_headers_socklen_t in
   1878     ws2tcpip)
   1879       CARES_DEFINE_UNQUOTED([CARES_PULL_WS2TCPIP_H])
   1880       ;;
   1881     systypes)
   1882       CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
   1883       ;;
   1884     syssocket)
   1885       CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
   1886       CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_SOCKET_H])
   1887       ;;
   1888   esac
   1889   CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [$cares_typeof_ares_socklen_t])
   1890   CARES_DEFINE_UNQUOTED([CARES_SIZEOF_ARES_SOCKLEN_T], [$cares_sizeof_ares_socklen_t])
   1891 ])
   1892 
   1893 
   1894 dnl This macro determines if the specified struct exists in the specified file
   1895 dnl Syntax:
   1896 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
   1897 
   1898 AC_DEFUN([CARES_CHECK_STRUCT], [
   1899   AC_MSG_CHECKING([for struct $2])
   1900   AC_TRY_COMPILE([$1],
   1901     [
   1902       struct $2 struct_instance;
   1903     ], ac_struct="yes", ac_found="no")
   1904   if test "$ac_struct" = "yes" ; then
   1905     AC_MSG_RESULT(yes)
   1906     $3
   1907   else
   1908     AC_MSG_RESULT(no)
   1909     $4
   1910   fi
   1911 ])
   1912 
   1913 dnl This macro determines if the specified constant exists in the specified file
   1914 dnl Syntax:
   1915 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
   1916 
   1917 AC_DEFUN([CARES_CHECK_CONSTANT], [
   1918   AC_MSG_CHECKING([for $2])
   1919   AC_EGREP_CPP(VARIABLEWASDEFINED,
   1920    [
   1921       $1
   1922 
   1923       #ifdef $2
   1924         VARIABLEWASDEFINED
   1925       #else
   1926         NJET
   1927       #endif
   1928     ], ac_constant="yes", ac_constant="no"
   1929   )
   1930   if test "$ac_constant" = "yes" ; then
   1931     AC_MSG_RESULT(yes)
   1932     $3
   1933   else
   1934     AC_MSG_RESULT(no)
   1935     $4
   1936   fi
   1937 ])
   1938 
   1939