1#***************************************************************************
2#
3# Copyright (C) 2008 - 2012 by Daniel Stenberg et al
4#
5# Permission to use, copy, modify, and distribute this software and its
6# documentation for any purpose and without fee is hereby granted, provided
7# that the above copyright notice appear in all copies and that both that
8# copyright notice and this permission notice appear in supporting
9# documentation, and that the name of M.I.T. not be used in advertising or
10# publicity pertaining to distribution of the software without specific,
11# written prior permission.  M.I.T. makes no representations about the
12# suitability of this software for any purpose.  It is provided "as is"
13# without express or implied warranty.
14#
15#***************************************************************************
16
17# File version for 'aclocal' use. Keep it a single number.
18# serial 46
19
20
21dnl CARES_INCLUDES_ARPA_INET
22dnl -------------------------------------------------
23dnl Set up variable with list of headers that must be
24dnl included when arpa/inet.h is to be included.
25
26AC_DEFUN([CARES_INCLUDES_ARPA_INET], [
27cares_includes_arpa_inet="\
28/* includes start */
29#ifdef HAVE_SYS_TYPES_H
30#  include <sys/types.h>
31#endif
32#ifdef HAVE_SYS_SOCKET_H
33#  include <sys/socket.h>
34#endif
35#ifdef HAVE_NETINET_IN_H
36#  include <netinet/in.h>
37#endif
38#ifdef HAVE_ARPA_INET_H
39#  include <arpa/inet.h>
40#endif
41/* includes end */"
42  AC_CHECK_HEADERS(
43    sys/types.h sys/socket.h netinet/in.h arpa/inet.h,
44    [], [], [$cares_includes_arpa_inet])
45])
46
47
48dnl CARES_INCLUDES_FCNTL
49dnl -------------------------------------------------
50dnl Set up variable with list of headers that must be
51dnl included when fcntl.h is to be included.
52
53AC_DEFUN([CARES_INCLUDES_FCNTL], [
54cares_includes_fcntl="\
55/* includes start */
56#ifdef HAVE_SYS_TYPES_H
57#  include <sys/types.h>
58#endif
59#ifdef HAVE_UNISTD_H
60#  include <unistd.h>
61#endif
62#ifdef HAVE_FCNTL_H
63#  include <fcntl.h>
64#endif
65/* includes end */"
66  AC_CHECK_HEADERS(
67    sys/types.h unistd.h fcntl.h,
68    [], [], [$cares_includes_fcntl])
69])
70
71
72dnl CARES_INCLUDES_NETDB
73dnl -------------------------------------------------
74dnl Set up variable with list of headers that must be
75dnl included when netdb.h is to be included.
76
77AC_DEFUN([CARES_INCLUDES_NETDB], [
78cares_includes_netdb="\
79/* includes start */
80#ifdef HAVE_SYS_TYPES_H
81#  include <sys/types.h>
82#endif
83#ifdef HAVE_NETDB_H
84#  include <netdb.h>
85#endif
86/* includes end */"
87  AC_CHECK_HEADERS(
88    sys/types.h netdb.h,
89    [], [], [$cares_includes_netdb])
90])
91
92
93dnl CARES_INCLUDES_SOCKET
94dnl -------------------------------------------------
95dnl Set up variable with list of headers that must be
96dnl included when socket.h is to be included.
97
98AC_DEFUN([CARES_INCLUDES_SOCKET], [
99cares_includes_socket="\
100/* includes start */
101#ifdef HAVE_SYS_TYPES_H
102#  include <sys/types.h>
103#endif
104#ifdef HAVE_SOCKET_H
105#  include <socket.h>
106#endif
107/* includes end */"
108  AC_CHECK_HEADERS(
109    sys/types.h socket.h,
110    [], [], [$cares_includes_socket])
111])
112
113
114dnl CARES_INCLUDES_STDLIB
115dnl -------------------------------------------------
116dnl Set up variable with list of headers that must be
117dnl included when stdlib.h is to be included.
118
119AC_DEFUN([CARES_INCLUDES_STDLIB], [
120cares_includes_stdlib="\
121/* includes start */
122#ifdef HAVE_SYS_TYPES_H
123#  include <sys/types.h>
124#endif
125#ifdef HAVE_STDLIB_H
126#  include <stdlib.h>
127#endif
128/* includes end */"
129  AC_CHECK_HEADERS(
130    sys/types.h stdlib.h,
131    [], [], [$cares_includes_stdlib])
132])
133
134
135dnl CARES_INCLUDES_STRING
136dnl -------------------------------------------------
137dnl Set up variable with list of headers that must be
138dnl included when string(s).h is to be included.
139
140AC_DEFUN([CARES_INCLUDES_STRING], [
141cares_includes_string="\
142/* includes start */
143#ifdef HAVE_SYS_TYPES_H
144#  include <sys/types.h>
145#endif
146#ifdef HAVE_STRING_H
147#  include <string.h>
148#endif
149#ifdef HAVE_STRINGS_H
150#  include <strings.h>
151#endif
152/* includes end */"
153  AC_CHECK_HEADERS(
154    sys/types.h string.h strings.h,
155    [], [], [$cares_includes_string])
156])
157
158
159dnl CARES_INCLUDES_STROPTS
160dnl -------------------------------------------------
161dnl Set up variable with list of headers that must be
162dnl included when stropts.h is to be included.
163
164AC_DEFUN([CARES_INCLUDES_STROPTS], [
165cares_includes_stropts="\
166/* includes start */
167#ifdef HAVE_SYS_TYPES_H
168#  include <sys/types.h>
169#endif
170#ifdef HAVE_UNISTD_H
171#  include <unistd.h>
172#endif
173#ifdef HAVE_SYS_SOCKET_H
174#  include <sys/socket.h>
175#endif
176#ifdef HAVE_SYS_IOCTL_H
177#  include <sys/ioctl.h>
178#endif
179#ifdef HAVE_STROPTS_H
180#  include <stropts.h>
181#endif
182/* includes end */"
183  AC_CHECK_HEADERS(
184    sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
185    [], [], [$cares_includes_stropts])
186])
187
188
189dnl CARES_INCLUDES_SYS_SOCKET
190dnl -------------------------------------------------
191dnl Set up variable with list of headers that must be
192dnl included when sys/socket.h is to be included.
193
194AC_DEFUN([CARES_INCLUDES_SYS_SOCKET], [
195cares_includes_sys_socket="\
196/* includes start */
197#ifdef HAVE_SYS_TYPES_H
198#  include <sys/types.h>
199#endif
200#ifdef HAVE_SYS_SOCKET_H
201#  include <sys/socket.h>
202#endif
203/* includes end */"
204  AC_CHECK_HEADERS(
205    sys/types.h sys/socket.h,
206    [], [], [$cares_includes_sys_socket])
207])
208
209
210dnl CARES_INCLUDES_SYS_TYPES
211dnl -------------------------------------------------
212dnl Set up variable with list of headers that must be
213dnl included when sys/types.h is to be included.
214
215AC_DEFUN([CARES_INCLUDES_SYS_TYPES], [
216cares_includes_sys_types="\
217/* includes start */
218#ifdef HAVE_SYS_TYPES_H
219#  include <sys/types.h>
220#endif
221/* includes end */"
222  AC_CHECK_HEADERS(
223    sys/types.h,
224    [], [], [$cares_includes_sys_types])
225])
226
227
228dnl CARES_INCLUDES_SYS_UIO
229dnl -------------------------------------------------
230dnl Set up variable with list of headers that must be
231dnl included when sys/uio.h is to be included.
232
233AC_DEFUN([CARES_INCLUDES_SYS_UIO], [
234cares_includes_sys_uio="\
235/* includes start */
236#ifdef HAVE_SYS_TYPES_H
237#  include <sys/types.h>
238#endif
239#ifdef HAVE_SYS_UIO_H
240#  include <sys/uio.h>
241#endif
242/* includes end */"
243  AC_CHECK_HEADERS(
244    sys/types.h sys/uio.h,
245    [], [], [$cares_includes_sys_uio])
246])
247
248
249dnl CARES_INCLUDES_UNISTD
250dnl -------------------------------------------------
251dnl Set up variable with list of headers that must be
252dnl included when unistd.h is to be included.
253
254AC_DEFUN([CARES_INCLUDES_UNISTD], [
255cares_includes_unistd="\
256/* includes start */
257#ifdef HAVE_SYS_TYPES_H
258#  include <sys/types.h>
259#endif
260#ifdef HAVE_UNISTD_H
261#  include <unistd.h>
262#endif
263/* includes end */"
264  AC_CHECK_HEADERS(
265    sys/types.h unistd.h,
266    [], [], [$cares_includes_unistd])
267])
268
269
270dnl CARES_INCLUDES_WINSOCK2
271dnl -------------------------------------------------
272dnl Set up variable with list of headers that must be
273dnl included when winsock(2).h is to be included.
274
275AC_DEFUN([CARES_INCLUDES_WINSOCK2], [
276cares_includes_winsock2="\
277/* includes start */
278#ifdef HAVE_WINDOWS_H
279#  ifndef WIN32_LEAN_AND_MEAN
280#    define WIN32_LEAN_AND_MEAN
281#  endif
282#  include <windows.h>
283#  ifdef HAVE_WINSOCK2_H
284#    include <winsock2.h>
285#  else
286#    ifdef HAVE_WINSOCK_H
287#      include <winsock.h>
288#    endif
289#  endif
290#endif
291/* includes end */"
292  CURL_CHECK_HEADER_WINDOWS
293  CURL_CHECK_HEADER_WINSOCK
294  CURL_CHECK_HEADER_WINSOCK2
295])
296
297
298dnl CARES_INCLUDES_WS2TCPIP
299dnl -------------------------------------------------
300dnl Set up variable with list of headers that must be
301dnl included when ws2tcpip.h is to be included.
302
303AC_DEFUN([CARES_INCLUDES_WS2TCPIP], [
304cares_includes_ws2tcpip="\
305/* includes start */
306#ifdef HAVE_WINDOWS_H
307#  ifndef WIN32_LEAN_AND_MEAN
308#    define WIN32_LEAN_AND_MEAN
309#  endif
310#  include <windows.h>
311#  ifdef HAVE_WINSOCK2_H
312#    include <winsock2.h>
313#    ifdef HAVE_WS2TCPIP_H
314#       include <ws2tcpip.h>
315#    endif
316#  endif
317#endif
318/* includes end */"
319  CURL_CHECK_HEADER_WINDOWS
320  CURL_CHECK_HEADER_WINSOCK2
321  CURL_CHECK_HEADER_WS2TCPIP
322])
323
324
325dnl CARES_PREPROCESS_CALLCONV
326dnl -------------------------------------------------
327dnl Set up variable with a preprocessor block which
328dnl defines function calling convention.
329
330AC_DEFUN([CARES_PREPROCESS_CALLCONV], [
331cares_preprocess_callconv="\
332/* preprocess start */
333#ifdef HAVE_WINDOWS_H
334#  define FUNCALLCONV __stdcall
335#else
336#  define FUNCALLCONV
337#endif
338/* preprocess end */"
339])
340
341
342dnl CARES_CHECK_FUNC_CLOSESOCKET
343dnl -------------------------------------------------
344dnl Verify if closesocket is available, prototyped, and
345dnl can be compiled. If all of these are true, and
346dnl usage has not been previously disallowed with
347dnl shell variable cares_disallow_closesocket, then
348dnl HAVE_CLOSESOCKET will be defined.
349
350AC_DEFUN([CARES_CHECK_FUNC_CLOSESOCKET], [
351  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
352  AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
353  #
354  tst_links_closesocket="unknown"
355  tst_proto_closesocket="unknown"
356  tst_compi_closesocket="unknown"
357  tst_allow_closesocket="unknown"
358  #
359  AC_MSG_CHECKING([if closesocket can be linked])
360  AC_LINK_IFELSE([
361    AC_LANG_PROGRAM([[
362      $cares_includes_winsock2
363      $cares_includes_socket
364    ]],[[
365      if(0 != closesocket(0))
366        return 1;
367    ]])
368  ],[
369    AC_MSG_RESULT([yes])
370    tst_links_closesocket="yes"
371  ],[
372    AC_MSG_RESULT([no])
373    tst_links_closesocket="no"
374  ])
375  #
376  if test "$tst_links_closesocket" = "yes"; then
377    AC_MSG_CHECKING([if closesocket is prototyped])
378    AC_EGREP_CPP([closesocket],[
379      $cares_includes_winsock2
380      $cares_includes_socket
381    ],[
382      AC_MSG_RESULT([yes])
383      tst_proto_closesocket="yes"
384    ],[
385      AC_MSG_RESULT([no])
386      tst_proto_closesocket="no"
387    ])
388  fi
389  #
390  if test "$tst_proto_closesocket" = "yes"; then
391    AC_MSG_CHECKING([if closesocket is compilable])
392    AC_COMPILE_IFELSE([
393      AC_LANG_PROGRAM([[
394        $cares_includes_winsock2
395        $cares_includes_socket
396      ]],[[
397        if(0 != closesocket(0))
398          return 1;
399      ]])
400    ],[
401      AC_MSG_RESULT([yes])
402      tst_compi_closesocket="yes"
403    ],[
404      AC_MSG_RESULT([no])
405      tst_compi_closesocket="no"
406    ])
407  fi
408  #
409  if test "$tst_compi_closesocket" = "yes"; then
410    AC_MSG_CHECKING([if closesocket usage allowed])
411    if test "x$cares_disallow_closesocket" != "xyes"; then
412      AC_MSG_RESULT([yes])
413      tst_allow_closesocket="yes"
414    else
415      AC_MSG_RESULT([no])
416      tst_allow_closesocket="no"
417    fi
418  fi
419  #
420  AC_MSG_CHECKING([if closesocket might be used])
421  if test "$tst_links_closesocket" = "yes" &&
422     test "$tst_proto_closesocket" = "yes" &&
423     test "$tst_compi_closesocket" = "yes" &&
424     test "$tst_allow_closesocket" = "yes"; then
425    AC_MSG_RESULT([yes])
426    AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET, 1,
427      [Define to 1 if you have the closesocket function.])
428    ac_cv_func_closesocket="yes"
429  else
430    AC_MSG_RESULT([no])
431    ac_cv_func_closesocket="no"
432  fi
433])
434
435
436dnl CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
437dnl -------------------------------------------------
438dnl Verify if CloseSocket is available, prototyped, and
439dnl can be compiled. If all of these are true, and
440dnl usage has not been previously disallowed with
441dnl shell variable cares_disallow_closesocket_camel,
442dnl then HAVE_CLOSESOCKET_CAMEL will be defined.
443
444AC_DEFUN([CARES_CHECK_FUNC_CLOSESOCKET_CAMEL], [
445  AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
446  #
447  tst_links_closesocket_camel="unknown"
448  tst_proto_closesocket_camel="unknown"
449  tst_compi_closesocket_camel="unknown"
450  tst_allow_closesocket_camel="unknown"
451  #
452  AC_MSG_CHECKING([if CloseSocket can be linked])
453  AC_LINK_IFELSE([
454    AC_LANG_PROGRAM([[
455      $cares_includes_sys_socket
456    ]],[[
457      if(0 != CloseSocket(0))
458        return 1;
459    ]])
460  ],[
461    AC_MSG_RESULT([yes])
462    tst_links_closesocket_camel="yes"
463  ],[
464    AC_MSG_RESULT([no])
465    tst_links_closesocket_camel="no"
466  ])
467  #
468  if test "$tst_links_closesocket_camel" = "yes"; then
469    AC_MSG_CHECKING([if CloseSocket is prototyped])
470    AC_EGREP_CPP([CloseSocket],[
471      $cares_includes_sys_socket
472    ],[
473      AC_MSG_RESULT([yes])
474      tst_proto_closesocket_camel="yes"
475    ],[
476      AC_MSG_RESULT([no])
477      tst_proto_closesocket_camel="no"
478    ])
479  fi
480  #
481  if test "$tst_proto_closesocket_camel" = "yes"; then
482    AC_MSG_CHECKING([if CloseSocket is compilable])
483    AC_COMPILE_IFELSE([
484      AC_LANG_PROGRAM([[
485        $cares_includes_sys_socket
486      ]],[[
487        if(0 != CloseSocket(0))
488          return 1;
489      ]])
490    ],[
491      AC_MSG_RESULT([yes])
492      tst_compi_closesocket_camel="yes"
493    ],[
494      AC_MSG_RESULT([no])
495      tst_compi_closesocket_camel="no"
496    ])
497  fi
498  #
499  if test "$tst_compi_closesocket_camel" = "yes"; then
500    AC_MSG_CHECKING([if CloseSocket usage allowed])
501    if test "x$cares_disallow_closesocket_camel" != "xyes"; then
502      AC_MSG_RESULT([yes])
503      tst_allow_closesocket_camel="yes"
504    else
505      AC_MSG_RESULT([no])
506      tst_allow_closesocket_camel="no"
507    fi
508  fi
509  #
510  AC_MSG_CHECKING([if CloseSocket might be used])
511  if test "$tst_links_closesocket_camel" = "yes" &&
512     test "$tst_proto_closesocket_camel" = "yes" &&
513     test "$tst_compi_closesocket_camel" = "yes" &&
514     test "$tst_allow_closesocket_camel" = "yes"; then
515    AC_MSG_RESULT([yes])
516    AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET_CAMEL, 1,
517      [Define to 1 if you have the CloseSocket camel case function.])
518    ac_cv_func_closesocket_camel="yes"
519  else
520    AC_MSG_RESULT([no])
521    ac_cv_func_closesocket_camel="no"
522  fi
523])
524
525
526dnl CARES_CHECK_FUNC_CONNECT
527dnl -------------------------------------------------
528dnl Verify if connect is available, prototyped, and
529dnl can be compiled. If all of these are true, and
530dnl usage has not been previously disallowed with
531dnl shell variable cares_disallow_connect, then
532dnl HAVE_CONNECT will be defined.
533
534AC_DEFUN([CARES_CHECK_FUNC_CONNECT], [
535  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
536  AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
537  AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
538  #
539  tst_links_connect="unknown"
540  tst_proto_connect="unknown"
541  tst_compi_connect="unknown"
542  tst_allow_connect="unknown"
543  #
544  AC_MSG_CHECKING([if connect can be linked])
545  AC_LINK_IFELSE([
546    AC_LANG_PROGRAM([[
547      $cares_includes_winsock2
548      $cares_includes_sys_socket
549      $cares_includes_socket
550    ]],[[
551      if(0 != connect(0, 0, 0))
552        return 1;
553    ]])
554  ],[
555    AC_MSG_RESULT([yes])
556    tst_links_connect="yes"
557  ],[
558    AC_MSG_RESULT([no])
559    tst_links_connect="no"
560  ])
561  #
562  if test "$tst_links_connect" = "yes"; then
563    AC_MSG_CHECKING([if connect is prototyped])
564    AC_EGREP_CPP([connect],[
565      $cares_includes_winsock2
566      $cares_includes_sys_socket
567      $cares_includes_socket
568    ],[
569      AC_MSG_RESULT([yes])
570      tst_proto_connect="yes"
571    ],[
572      AC_MSG_RESULT([no])
573      tst_proto_connect="no"
574    ])
575  fi
576  #
577  if test "$tst_proto_connect" = "yes"; then
578    AC_MSG_CHECKING([if connect is compilable])
579    AC_COMPILE_IFELSE([
580      AC_LANG_PROGRAM([[
581        $cares_includes_winsock2
582        $cares_includes_sys_socket
583        $cares_includes_socket
584      ]],[[
585        if(0 != connect(0, 0, 0))
586          return 1;
587      ]])
588    ],[
589      AC_MSG_RESULT([yes])
590      tst_compi_connect="yes"
591    ],[
592      AC_MSG_RESULT([no])
593      tst_compi_connect="no"
594    ])
595  fi
596  #
597  if test "$tst_compi_connect" = "yes"; then
598    AC_MSG_CHECKING([if connect usage allowed])
599    if test "x$cares_disallow_connect" != "xyes"; then
600      AC_MSG_RESULT([yes])
601      tst_allow_connect="yes"
602    else
603      AC_MSG_RESULT([no])
604      tst_allow_connect="no"
605    fi
606  fi
607  #
608  AC_MSG_CHECKING([if connect might be used])
609  if test "$tst_links_connect" = "yes" &&
610     test "$tst_proto_connect" = "yes" &&
611     test "$tst_compi_connect" = "yes" &&
612     test "$tst_allow_connect" = "yes"; then
613    AC_MSG_RESULT([yes])
614    AC_DEFINE_UNQUOTED(HAVE_CONNECT, 1,
615      [Define to 1 if you have the connect function.])
616    ac_cv_func_connect="yes"
617  else
618    AC_MSG_RESULT([no])
619    ac_cv_func_connect="no"
620  fi
621])
622
623
624dnl CARES_CHECK_FUNC_FCNTL
625dnl -------------------------------------------------
626dnl Verify if fcntl is available, prototyped, and
627dnl can be compiled. If all of these are true, and
628dnl usage has not been previously disallowed with
629dnl shell variable cares_disallow_fcntl, then
630dnl HAVE_FCNTL will be defined.
631
632AC_DEFUN([CARES_CHECK_FUNC_FCNTL], [
633  AC_REQUIRE([CARES_INCLUDES_FCNTL])dnl
634  #
635  tst_links_fcntl="unknown"
636  tst_proto_fcntl="unknown"
637  tst_compi_fcntl="unknown"
638  tst_allow_fcntl="unknown"
639  #
640  AC_MSG_CHECKING([if fcntl can be linked])
641  AC_LINK_IFELSE([
642    AC_LANG_FUNC_LINK_TRY([fcntl])
643  ],[
644    AC_MSG_RESULT([yes])
645    tst_links_fcntl="yes"
646  ],[
647    AC_MSG_RESULT([no])
648    tst_links_fcntl="no"
649  ])
650  #
651  if test "$tst_links_fcntl" = "yes"; then
652    AC_MSG_CHECKING([if fcntl is prototyped])
653    AC_EGREP_CPP([fcntl],[
654      $cares_includes_fcntl
655    ],[
656      AC_MSG_RESULT([yes])
657      tst_proto_fcntl="yes"
658    ],[
659      AC_MSG_RESULT([no])
660      tst_proto_fcntl="no"
661    ])
662  fi
663  #
664  if test "$tst_proto_fcntl" = "yes"; then
665    AC_MSG_CHECKING([if fcntl is compilable])
666    AC_COMPILE_IFELSE([
667      AC_LANG_PROGRAM([[
668        $cares_includes_fcntl
669      ]],[[
670        if(0 != fcntl(0, 0, 0))
671          return 1;
672      ]])
673    ],[
674      AC_MSG_RESULT([yes])
675      tst_compi_fcntl="yes"
676    ],[
677      AC_MSG_RESULT([no])
678      tst_compi_fcntl="no"
679    ])
680  fi
681  #
682  if test "$tst_compi_fcntl" = "yes"; then
683    AC_MSG_CHECKING([if fcntl usage allowed])
684    if test "x$cares_disallow_fcntl" != "xyes"; then
685      AC_MSG_RESULT([yes])
686      tst_allow_fcntl="yes"
687    else
688      AC_MSG_RESULT([no])
689      tst_allow_fcntl="no"
690    fi
691  fi
692  #
693  AC_MSG_CHECKING([if fcntl might be used])
694  if test "$tst_links_fcntl" = "yes" &&
695     test "$tst_proto_fcntl" = "yes" &&
696     test "$tst_compi_fcntl" = "yes" &&
697     test "$tst_allow_fcntl" = "yes"; then
698    AC_MSG_RESULT([yes])
699    AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
700      [Define to 1 if you have the fcntl function.])
701    ac_cv_func_fcntl="yes"
702    CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
703  else
704    AC_MSG_RESULT([no])
705    ac_cv_func_fcntl="no"
706  fi
707])
708
709
710dnl CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
711dnl -------------------------------------------------
712dnl Verify if fcntl with status flag O_NONBLOCK is
713dnl available, can be compiled, and seems to work. If
714dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
715dnl will be defined.
716
717AC_DEFUN([CARES_CHECK_FUNC_FCNTL_O_NONBLOCK], [
718  #
719  tst_compi_fcntl_o_nonblock="unknown"
720  tst_allow_fcntl_o_nonblock="unknown"
721  #
722  case $host_os in
723    sunos4* | aix3* | beos*)
724      dnl O_NONBLOCK does not work on these platforms
725      cares_disallow_fcntl_o_nonblock="yes"
726      ;;
727  esac
728  #
729  if test "$ac_cv_func_fcntl" = "yes"; then
730    AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
731    AC_COMPILE_IFELSE([
732      AC_LANG_PROGRAM([[
733        $cares_includes_fcntl
734      ]],[[
735        int flags = 0;
736        if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
737          return 1;
738      ]])
739    ],[
740      AC_MSG_RESULT([yes])
741      tst_compi_fcntl_o_nonblock="yes"
742    ],[
743      AC_MSG_RESULT([no])
744      tst_compi_fcntl_o_nonblock="no"
745    ])
746  fi
747  #
748  if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
749    AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
750    if test "x$cares_disallow_fcntl_o_nonblock" != "xyes"; then
751      AC_MSG_RESULT([yes])
752      tst_allow_fcntl_o_nonblock="yes"
753    else
754      AC_MSG_RESULT([no])
755      tst_allow_fcntl_o_nonblock="no"
756    fi
757  fi
758  #
759  AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
760  if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
761     test "$tst_allow_fcntl_o_nonblock" = "yes"; then
762    AC_MSG_RESULT([yes])
763    AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
764      [Define to 1 if you have a working fcntl O_NONBLOCK function.])
765    ac_cv_func_fcntl_o_nonblock="yes"
766  else
767    AC_MSG_RESULT([no])
768    ac_cv_func_fcntl_o_nonblock="no"
769  fi
770])
771
772
773dnl CARES_CHECK_FUNC_FREEADDRINFO
774dnl -------------------------------------------------
775dnl Verify if freeaddrinfo is available, prototyped,
776dnl and can be compiled. If all of these are true,
777dnl and usage has not been previously disallowed with
778dnl shell variable cares_disallow_freeaddrinfo, then
779dnl HAVE_FREEADDRINFO will be defined.
780
781AC_DEFUN([CARES_CHECK_FUNC_FREEADDRINFO], [
782  AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
783  AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
784  AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
785  #
786  tst_links_freeaddrinfo="unknown"
787  tst_proto_freeaddrinfo="unknown"
788  tst_compi_freeaddrinfo="unknown"
789  tst_allow_freeaddrinfo="unknown"
790  #
791  AC_MSG_CHECKING([if freeaddrinfo can be linked])
792  AC_LINK_IFELSE([
793    AC_LANG_PROGRAM([[
794      $cares_includes_ws2tcpip
795      $cares_includes_sys_socket
796      $cares_includes_netdb
797    ]],[[
798      freeaddrinfo(0);
799    ]])
800  ],[
801    AC_MSG_RESULT([yes])
802    tst_links_freeaddrinfo="yes"
803  ],[
804    AC_MSG_RESULT([no])
805    tst_links_freeaddrinfo="no"
806  ])
807  #
808  if test "$tst_links_freeaddrinfo" = "yes"; then
809    AC_MSG_CHECKING([if freeaddrinfo is prototyped])
810    AC_EGREP_CPP([freeaddrinfo],[
811      $cares_includes_ws2tcpip
812      $cares_includes_sys_socket
813      $cares_includes_netdb
814    ],[
815      AC_MSG_RESULT([yes])
816      tst_proto_freeaddrinfo="yes"
817    ],[
818      AC_MSG_RESULT([no])
819      tst_proto_freeaddrinfo="no"
820    ])
821  fi
822  #
823  if test "$tst_proto_freeaddrinfo" = "yes"; then
824    AC_MSG_CHECKING([if freeaddrinfo is compilable])
825    AC_COMPILE_IFELSE([
826      AC_LANG_PROGRAM([[
827        $cares_includes_ws2tcpip
828        $cares_includes_sys_socket
829        $cares_includes_netdb
830      ]],[[
831        freeaddrinfo(0);
832      ]])
833    ],[
834      AC_MSG_RESULT([yes])
835      tst_compi_freeaddrinfo="yes"
836    ],[
837      AC_MSG_RESULT([no])
838      tst_compi_freeaddrinfo="no"
839    ])
840  fi
841  #
842  if test "$tst_compi_freeaddrinfo" = "yes"; then
843    AC_MSG_CHECKING([if freeaddrinfo usage allowed])
844    if test "x$cares_disallow_freeaddrinfo" != "xyes"; then
845      AC_MSG_RESULT([yes])
846      tst_allow_freeaddrinfo="yes"
847    else
848      AC_MSG_RESULT([no])
849      tst_allow_freeaddrinfo="no"
850    fi
851  fi
852  #
853  AC_MSG_CHECKING([if freeaddrinfo might be used])
854  if test "$tst_links_freeaddrinfo" = "yes" &&
855     test "$tst_proto_freeaddrinfo" = "yes" &&
856     test "$tst_compi_freeaddrinfo" = "yes" &&
857     test "$tst_allow_freeaddrinfo" = "yes"; then
858    AC_MSG_RESULT([yes])
859    AC_DEFINE_UNQUOTED(HAVE_FREEADDRINFO, 1,
860      [Define to 1 if you have the freeaddrinfo function.])
861    ac_cv_func_freeaddrinfo="yes"
862  else
863    AC_MSG_RESULT([no])
864    ac_cv_func_freeaddrinfo="no"
865  fi
866])
867
868
869dnl CARES_CHECK_FUNC_GETADDRINFO
870dnl -------------------------------------------------
871dnl Verify if getaddrinfo is available, prototyped, can
872dnl be compiled and seems to work. If all of these are
873dnl true, and usage has not been previously disallowed
874dnl with shell variable cares_disallow_getaddrinfo, then
875dnl HAVE_GETADDRINFO will be defined. Additionally when
876dnl HAVE_GETADDRINFO gets defined this will also attempt
877dnl to find out if getaddrinfo happens to be threadsafe,
878dnl defining HAVE_GETADDRINFO_THREADSAFE when true.
879
880AC_DEFUN([CARES_CHECK_FUNC_GETADDRINFO], [
881  AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
882  AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
883  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
884  AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
885  AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
886  AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
887  #
888  tst_links_getaddrinfo="unknown"
889  tst_proto_getaddrinfo="unknown"
890  tst_compi_getaddrinfo="unknown"
891  tst_works_getaddrinfo="unknown"
892  tst_allow_getaddrinfo="unknown"
893  tst_tsafe_getaddrinfo="unknown"
894  #
895  AC_MSG_CHECKING([if getaddrinfo can be linked])
896  AC_LINK_IFELSE([
897    AC_LANG_PROGRAM([[
898      $cares_includes_ws2tcpip
899      $cares_includes_sys_socket
900      $cares_includes_netdb
901    ]],[[
902      if(0 != getaddrinfo(0, 0, 0, 0))
903        return 1;
904    ]])
905  ],[
906    AC_MSG_RESULT([yes])
907    tst_links_getaddrinfo="yes"
908  ],[
909    AC_MSG_RESULT([no])
910    tst_links_getaddrinfo="no"
911  ])
912  #
913  if test "$tst_links_getaddrinfo" = "yes"; then
914    AC_MSG_CHECKING([if getaddrinfo is prototyped])
915    AC_EGREP_CPP([getaddrinfo],[
916      $cares_includes_ws2tcpip
917      $cares_includes_sys_socket
918      $cares_includes_netdb
919    ],[
920      AC_MSG_RESULT([yes])
921      tst_proto_getaddrinfo="yes"
922    ],[
923      AC_MSG_RESULT([no])
924      tst_proto_getaddrinfo="no"
925    ])
926  fi
927  #
928  if test "$tst_proto_getaddrinfo" = "yes"; then
929    AC_MSG_CHECKING([if getaddrinfo is compilable])
930    AC_COMPILE_IFELSE([
931      AC_LANG_PROGRAM([[
932        $cares_includes_ws2tcpip
933        $cares_includes_sys_socket
934        $cares_includes_netdb
935      ]],[[
936        if(0 != getaddrinfo(0, 0, 0, 0))
937          return 1;
938      ]])
939    ],[
940      AC_MSG_RESULT([yes])
941      tst_compi_getaddrinfo="yes"
942    ],[
943      AC_MSG_RESULT([no])
944      tst_compi_getaddrinfo="no"
945    ])
946  fi
947  #
948  dnl only do runtime verification when not cross-compiling
949  if test "x$cross_compiling" != "xyes" &&
950    test "$tst_compi_getaddrinfo" = "yes"; then
951    AC_MSG_CHECKING([if getaddrinfo seems to work])
952    AC_RUN_IFELSE([
953      AC_LANG_PROGRAM([[
954        $cares_includes_ws2tcpip
955        $cares_includes_stdlib
956        $cares_includes_string
957        $cares_includes_sys_socket
958        $cares_includes_netdb
959      ]],[[
960        struct addrinfo hints;
961        struct addrinfo *ai = 0;
962        int error;
963
964        memset(&hints, 0, sizeof(hints));
965        hints.ai_flags = AI_NUMERICHOST;
966        hints.ai_family = AF_UNSPEC;
967        hints.ai_socktype = SOCK_STREAM;
968        error = getaddrinfo("127.0.0.1", 0, &hints, &ai);
969        if(error || !ai)
970          exit(1); /* fail */
971        else
972          exit(0);
973      ]])
974    ],[
975      AC_MSG_RESULT([yes])
976      tst_works_getaddrinfo="yes"
977    ],[
978      AC_MSG_RESULT([no])
979      tst_works_getaddrinfo="no"
980    ])
981  fi
982  #
983  if test "$tst_compi_getaddrinfo" = "yes" &&
984    test "$tst_works_getaddrinfo" != "no"; then
985    AC_MSG_CHECKING([if getaddrinfo usage allowed])
986    if test "x$cares_disallow_getaddrinfo" != "xyes"; then
987      AC_MSG_RESULT([yes])
988      tst_allow_getaddrinfo="yes"
989    else
990      AC_MSG_RESULT([no])
991      tst_allow_getaddrinfo="no"
992    fi
993  fi
994  #
995  AC_MSG_CHECKING([if getaddrinfo might be used])
996  if test "$tst_links_getaddrinfo" = "yes" &&
997     test "$tst_proto_getaddrinfo" = "yes" &&
998     test "$tst_compi_getaddrinfo" = "yes" &&
999     test "$tst_allow_getaddrinfo" = "yes" &&
1000     test "$tst_works_getaddrinfo" != "no"; then
1001    AC_MSG_RESULT([yes])
1002    AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO, 1,
1003      [Define to 1 if you have a working getaddrinfo function.])
1004    ac_cv_func_getaddrinfo="yes"
1005  else
1006    AC_MSG_RESULT([no])
1007    ac_cv_func_getaddrinfo="no"
1008    ac_cv_func_getaddrinfo_threadsafe="no"
1009  fi
1010  #
1011  if test "$ac_cv_func_getaddrinfo" = "yes"; then
1012    AC_MSG_CHECKING([if getaddrinfo is threadsafe])
1013    case $host_os in
1014      aix[[1234]].* | aix5.[[01]].*)
1015        dnl aix 5.1 and older
1016        tst_tsafe_getaddrinfo="no"
1017        ;;
1018      aix*)
1019        dnl aix 5.2 and newer
1020        tst_tsafe_getaddrinfo="yes"
1021        ;;
1022      darwin[[12345]].*)
1023        dnl darwin 5.0 and mac os x 10.1.X and older
1024        tst_tsafe_getaddrinfo="no"
1025        ;;
1026      darwin*)
1027        dnl darwin 6.0 and mac os x 10.2.X and newer
1028        tst_tsafe_getaddrinfo="yes"
1029        ;;
1030      freebsd[[1234]].* | freebsd5.[[1234]]*)
1031        dnl freebsd 5.4 and older
1032        tst_tsafe_getaddrinfo="no"
1033        ;;
1034      freebsd*)
1035        dnl freebsd 5.5 and newer
1036        tst_tsafe_getaddrinfo="yes"
1037        ;;
1038      hpux[[123456789]].* | hpux10.* | hpux11.0* | hpux11.10*)
1039        dnl hpux 11.10 and older
1040        tst_tsafe_getaddrinfo="no"
1041        ;;
1042      hpux*)
1043        dnl hpux 11.11 and newer
1044        tst_tsafe_getaddrinfo="yes"
1045        ;;
1046      netbsd[[123]].*)
1047        dnl netbsd 3.X and older
1048        tst_tsafe_getaddrinfo="no"
1049        ;;
1050      netbsd*)
1051        dnl netbsd 4.X and newer
1052        tst_tsafe_getaddrinfo="yes"
1053        ;;
1054      *bsd*)
1055        dnl All other bsd's
1056        tst_tsafe_getaddrinfo="no"
1057        ;;
1058      solaris2*)
1059        dnl solaris which have it
1060        tst_tsafe_getaddrinfo="yes"
1061        ;;
1062    esac
1063    if test "$tst_tsafe_getaddrinfo" = "unknown" &&
1064       test "$ac_cv_native_windows" = "yes"; then
1065      tst_tsafe_getaddrinfo="yes"
1066    fi
1067    if test "$tst_tsafe_getaddrinfo" = "unknown"; then
1068      CURL_CHECK_DEF_CC([h_errno], [
1069        $cares_includes_sys_socket
1070        $cares_includes_netdb
1071        ], [silent])
1072      if test "$curl_cv_have_def_h_errno" = "yes"; then
1073        tst_h_errno_macro="yes"
1074      else
1075        tst_h_errno_macro="no"
1076      fi
1077      AC_COMPILE_IFELSE([
1078        AC_LANG_PROGRAM([[
1079          $cares_includes_sys_socket
1080          $cares_includes_netdb
1081        ]],[[
1082          h_errno = 2;
1083          if(0 != h_errno)
1084            return 1;
1085        ]])
1086      ],[
1087        tst_h_errno_modifiable_lvalue="yes"
1088      ],[
1089        tst_h_errno_modifiable_lvalue="no"
1090      ])
1091      AC_COMPILE_IFELSE([
1092        AC_LANG_PROGRAM([[
1093        ]],[[
1094#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
1095          return 0;
1096#elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 700)
1097          return 0;
1098#else
1099          force compilation error
1100#endif
1101        ]])
1102      ],[
1103        tst_h_errno_sbs_issue_7="yes"
1104      ],[
1105        tst_h_errno_sbs_issue_7="no"
1106      ])
1107      if test "$tst_h_errno_macro" = "no" &&
1108         test "$tst_h_errno_modifiable_lvalue" = "no" &&
1109         test "$tst_h_errno_sbs_issue_7" = "no"; then
1110        tst_tsafe_getaddrinfo="no"
1111      else
1112        tst_tsafe_getaddrinfo="yes"
1113      fi
1114    fi
1115    AC_MSG_RESULT([$tst_tsafe_getaddrinfo])
1116    if test "$tst_tsafe_getaddrinfo" = "yes"; then
1117      AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO_THREADSAFE, 1,
1118        [Define to 1 if the getaddrinfo function is threadsafe.])
1119      ac_cv_func_getaddrinfo_threadsafe="yes"
1120    else
1121      ac_cv_func_getaddrinfo_threadsafe="no"
1122    fi
1123  fi
1124])
1125
1126
1127dnl CARES_CHECK_FUNC_GETENV
1128dnl -------------------------------------------------
1129dnl Verify if getenv is available, prototyped, and
1130dnl can be compiled. If all of these are true, and
1131dnl usage has not been previously disallowed with
1132dnl shell variable cares_disallow_getenv, then
1133dnl HAVE_GETENV will be defined.
1134
1135AC_DEFUN([CARES_CHECK_FUNC_GETENV], [
1136  AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
1137  #
1138  tst_links_getenv="unknown"
1139  tst_proto_getenv="unknown"
1140  tst_compi_getenv="unknown"
1141  tst_allow_getenv="unknown"
1142  #
1143  AC_MSG_CHECKING([if getenv can be linked])
1144  AC_LINK_IFELSE([
1145    AC_LANG_FUNC_LINK_TRY([getenv])
1146  ],[
1147    AC_MSG_RESULT([yes])
1148    tst_links_getenv="yes"
1149  ],[
1150    AC_MSG_RESULT([no])
1151    tst_links_getenv="no"
1152  ])
1153  #
1154  if test "$tst_links_getenv" = "yes"; then
1155    AC_MSG_CHECKING([if getenv is prototyped])
1156    AC_EGREP_CPP([getenv],[
1157      $cares_includes_stdlib
1158    ],[
1159      AC_MSG_RESULT([yes])
1160      tst_proto_getenv="yes"
1161    ],[
1162      AC_MSG_RESULT([no])
1163      tst_proto_getenv="no"
1164    ])
1165  fi
1166  #
1167  if test "$tst_proto_getenv" = "yes"; then
1168    AC_MSG_CHECKING([if getenv is compilable])
1169    AC_COMPILE_IFELSE([
1170      AC_LANG_PROGRAM([[
1171        $cares_includes_stdlib
1172      ]],[[
1173        if(0 != getenv(0))
1174          return 1;
1175      ]])
1176    ],[
1177      AC_MSG_RESULT([yes])
1178      tst_compi_getenv="yes"
1179    ],[
1180      AC_MSG_RESULT([no])
1181      tst_compi_getenv="no"
1182    ])
1183  fi
1184  #
1185  if test "$tst_compi_getenv" = "yes"; then
1186    AC_MSG_CHECKING([if getenv usage allowed])
1187    if test "x$cares_disallow_getenv" != "xyes"; then
1188      AC_MSG_RESULT([yes])
1189      tst_allow_getenv="yes"
1190    else
1191      AC_MSG_RESULT([no])
1192      tst_allow_getenv="no"
1193    fi
1194  fi
1195  #
1196  AC_MSG_CHECKING([if getenv might be used])
1197  if test "$tst_links_getenv" = "yes" &&
1198     test "$tst_proto_getenv" = "yes" &&
1199     test "$tst_compi_getenv" = "yes" &&
1200     test "$tst_allow_getenv" = "yes"; then
1201    AC_MSG_RESULT([yes])
1202    AC_DEFINE_UNQUOTED(HAVE_GETENV, 1,
1203      [Define to 1 if you have the getenv function.])
1204    ac_cv_func_getenv="yes"
1205  else
1206    AC_MSG_RESULT([no])
1207    ac_cv_func_getenv="no"
1208  fi
1209])
1210
1211
1212dnl CARES_CHECK_FUNC_GETHOSTBYADDR
1213dnl -------------------------------------------------
1214dnl Verify if gethostbyaddr is available, prototyped,
1215dnl and can be compiled. If all of these are true,
1216dnl and usage has not been previously disallowed with
1217dnl shell variable cares_disallow_gethostbyaddr, then
1218dnl HAVE_GETHOSTBYADDR will be defined.
1219
1220AC_DEFUN([CARES_CHECK_FUNC_GETHOSTBYADDR], [
1221  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
1222  AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
1223  #
1224  tst_links_gethostbyaddr="unknown"
1225  tst_proto_gethostbyaddr="unknown"
1226  tst_compi_gethostbyaddr="unknown"
1227  tst_allow_gethostbyaddr="unknown"
1228  #
1229  AC_MSG_CHECKING([if gethostbyaddr can be linked])
1230  AC_LINK_IFELSE([
1231    AC_LANG_PROGRAM([[
1232      $cares_includes_winsock2
1233      $cares_includes_netdb
1234    ]],[[
1235      if(0 != gethostbyaddr(0, 0, 0))
1236        return 1;
1237    ]])
1238  ],[
1239    AC_MSG_RESULT([yes])
1240    tst_links_gethostbyaddr="yes"
1241  ],[
1242    AC_MSG_RESULT([no])
1243    tst_links_gethostbyaddr="no"
1244  ])
1245  #
1246  if test "$tst_links_gethostbyaddr" = "yes"; then
1247    AC_MSG_CHECKING([if gethostbyaddr is prototyped])
1248    AC_EGREP_CPP([gethostbyaddr],[
1249      $cares_includes_winsock2
1250      $cares_includes_netdb
1251    ],[
1252      AC_MSG_RESULT([yes])
1253      tst_proto_gethostbyaddr="yes"
1254    ],[
1255      AC_MSG_RESULT([no])
1256      tst_proto_gethostbyaddr="no"
1257    ])
1258  fi
1259  #
1260  if test "$tst_proto_gethostbyaddr" = "yes"; then
1261    AC_MSG_CHECKING([if gethostbyaddr is compilable])
1262    AC_COMPILE_IFELSE([
1263      AC_LANG_PROGRAM([[
1264        $cares_includes_winsock2
1265        $cares_includes_netdb
1266      ]],[[
1267        if(0 != gethostbyaddr(0, 0, 0))
1268          return 1;
1269      ]])
1270    ],[
1271      AC_MSG_RESULT([yes])
1272      tst_compi_gethostbyaddr="yes"
1273    ],[
1274      AC_MSG_RESULT([no])
1275      tst_compi_gethostbyaddr="no"
1276    ])
1277  fi
1278  #
1279  if test "$tst_compi_gethostbyaddr" = "yes"; then
1280    AC_MSG_CHECKING([if gethostbyaddr usage allowed])
1281    if test "x$cares_disallow_gethostbyaddr" != "xyes"; then
1282      AC_MSG_RESULT([yes])
1283      tst_allow_gethostbyaddr="yes"
1284    else
1285      AC_MSG_RESULT([no])
1286      tst_allow_gethostbyaddr="no"
1287    fi
1288  fi
1289  #
1290  AC_MSG_CHECKING([if gethostbyaddr might be used])
1291  if test "$tst_links_gethostbyaddr" = "yes" &&
1292     test "$tst_proto_gethostbyaddr" = "yes" &&
1293     test "$tst_compi_gethostbyaddr" = "yes" &&
1294     test "$tst_allow_gethostbyaddr" = "yes"; then
1295    AC_MSG_RESULT([yes])
1296    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR, 1,
1297      [Define to 1 if you have the gethostbyaddr function.])
1298    ac_cv_func_gethostbyaddr="yes"
1299  else
1300    AC_MSG_RESULT([no])
1301    ac_cv_func_gethostbyaddr="no"
1302  fi
1303])
1304
1305
1306dnl CARES_CHECK_FUNC_GETHOSTBYNAME
1307dnl -------------------------------------------------
1308dnl Verify if gethostbyname is available, prototyped,
1309dnl and can be compiled. If all of these are true,
1310dnl and usage has not been previously disallowed with
1311dnl shell variable cares_disallow_gethostbyname, then
1312dnl HAVE_GETHOSTBYNAME will be defined.
1313
1314AC_DEFUN([CARES_CHECK_FUNC_GETHOSTBYNAME], [
1315  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
1316  AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
1317  #
1318  tst_links_gethostbyname="unknown"
1319  tst_proto_gethostbyname="unknown"
1320  tst_compi_gethostbyname="unknown"
1321  tst_allow_gethostbyname="unknown"
1322  #
1323  AC_MSG_CHECKING([if gethostbyname can be linked])
1324  AC_LINK_IFELSE([
1325    AC_LANG_PROGRAM([[
1326      $cares_includes_winsock2
1327      $cares_includes_netdb
1328    ]],[[
1329      if(0 != gethostbyname(0))
1330        return 1;
1331    ]])
1332  ],[
1333    AC_MSG_RESULT([yes])
1334    tst_links_gethostbyname="yes"
1335  ],[
1336    AC_MSG_RESULT([no])
1337    tst_links_gethostbyname="no"
1338  ])
1339  #
1340  if test "$tst_links_gethostbyname" = "yes"; then
1341    AC_MSG_CHECKING([if gethostbyname is prototyped])
1342    AC_EGREP_CPP([gethostbyname],[
1343      $cares_includes_winsock2
1344      $cares_includes_netdb
1345    ],[
1346      AC_MSG_RESULT([yes])
1347      tst_proto_gethostbyname="yes"
1348    ],[
1349      AC_MSG_RESULT([no])
1350      tst_proto_gethostbyname="no"
1351    ])
1352  fi
1353  #
1354  if test "$tst_proto_gethostbyname" = "yes"; then
1355    AC_MSG_CHECKING([if gethostbyname is compilable])
1356    AC_COMPILE_IFELSE([
1357      AC_LANG_PROGRAM([[
1358        $cares_includes_winsock2
1359        $cares_includes_netdb
1360      ]],[[
1361        if(0 != gethostbyname(0))
1362          return 1;
1363      ]])
1364    ],[
1365      AC_MSG_RESULT([yes])
1366      tst_compi_gethostbyname="yes"
1367    ],[
1368      AC_MSG_RESULT([no])
1369      tst_compi_gethostbyname="no"
1370    ])
1371  fi
1372  #
1373  if test "$tst_compi_gethostbyname" = "yes"; then
1374    AC_MSG_CHECKING([if gethostbyname usage allowed])
1375    if test "x$cares_disallow_gethostbyname" != "xyes"; then
1376      AC_MSG_RESULT([yes])
1377      tst_allow_gethostbyname="yes"
1378    else
1379      AC_MSG_RESULT([no])
1380      tst_allow_gethostbyname="no"
1381    fi
1382  fi
1383  #
1384  AC_MSG_CHECKING([if gethostbyname might be used])
1385  if test "$tst_links_gethostbyname" = "yes" &&
1386     test "$tst_proto_gethostbyname" = "yes" &&
1387     test "$tst_compi_gethostbyname" = "yes" &&
1388     test "$tst_allow_gethostbyname" = "yes"; then
1389    AC_MSG_RESULT([yes])
1390    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME, 1,
1391      [Define to 1 if you have the gethostbyname function.])
1392    ac_cv_func_gethostbyname="yes"
1393  else
1394    AC_MSG_RESULT([no])
1395    ac_cv_func_gethostbyname="no"
1396  fi
1397])
1398
1399
1400dnl CARES_CHECK_FUNC_GETHOSTNAME
1401dnl -------------------------------------------------
1402dnl Verify if gethostname is available, prototyped, and
1403dnl can be compiled. If all of these are true, and
1404dnl usage has not been previously disallowed with
1405dnl shell variable cares_disallow_gethostname, then
1406dnl HAVE_GETHOSTNAME will be defined.
1407
1408AC_DEFUN([CARES_CHECK_FUNC_GETHOSTNAME], [
1409  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
1410  AC_REQUIRE([CARES_INCLUDES_UNISTD])dnl
1411  AC_REQUIRE([CARES_PREPROCESS_CALLCONV])dnl
1412  #
1413  tst_links_gethostname="unknown"
1414  tst_proto_gethostname="unknown"
1415  tst_compi_gethostname="unknown"
1416  tst_allow_gethostname="unknown"
1417  #
1418  AC_MSG_CHECKING([if gethostname can be linked])
1419  AC_LINK_IFELSE([
1420    AC_LANG_PROGRAM([[
1421      $cares_includes_winsock2
1422      $cares_includes_unistd
1423    ]],[[
1424      if(0 != gethostname(0, 0))
1425        return 1;
1426    ]])
1427  ],[
1428    AC_MSG_RESULT([yes])
1429    tst_links_gethostname="yes"
1430  ],[
1431    AC_MSG_RESULT([no])
1432    tst_links_gethostname="no"
1433  ])
1434  #
1435  if test "$tst_links_gethostname" = "yes"; then
1436    AC_MSG_CHECKING([if gethostname is prototyped])
1437    AC_EGREP_CPP([gethostname],[
1438      $cares_includes_winsock2
1439      $cares_includes_unistd
1440    ],[
1441      AC_MSG_RESULT([yes])
1442      tst_proto_gethostname="yes"
1443    ],[
1444      AC_MSG_RESULT([no])
1445      tst_proto_gethostname="no"
1446    ])
1447  fi
1448  #
1449  if test "$tst_proto_gethostname" = "yes"; then
1450    AC_MSG_CHECKING([if gethostname is compilable])
1451    AC_COMPILE_IFELSE([
1452      AC_LANG_PROGRAM([[
1453        $cares_includes_winsock2
1454        $cares_includes_unistd
1455      ]],[[
1456        if(0 != gethostname(0, 0))
1457          return 1;
1458      ]])
1459    ],[
1460      AC_MSG_RESULT([yes])
1461      tst_compi_gethostname="yes"
1462    ],[
1463      AC_MSG_RESULT([no])
1464      tst_compi_gethostname="no"
1465    ])
1466  fi
1467  #
1468  if test "$tst_compi_gethostname" = "yes"; then
1469    AC_MSG_CHECKING([for gethostname arg 2 data type])
1470    tst_gethostname_type_arg2="unknown"
1471    for tst_arg1 in 'char *' 'unsigned char *' 'void *'; do
1472      for tst_arg2 in 'int' 'unsigned int' 'size_t'; do
1473        if test "$tst_gethostname_type_arg2" = "unknown"; then
1474          AC_COMPILE_IFELSE([
1475            AC_LANG_PROGRAM([[
1476              $cares_includes_winsock2
1477              $cares_includes_unistd
1478              $cares_preprocess_callconv
1479              extern int FUNCALLCONV gethostname($tst_arg1, $tst_arg2);
1480            ]],[[
1481              if(0 != gethostname(0, 0))
1482                return 1;
1483            ]])
1484          ],[
1485            tst_gethostname_type_arg2="$tst_arg2"
1486          ])
1487        fi
1488      done
1489    done
1490    AC_MSG_RESULT([$tst_gethostname_type_arg2])
1491    if test "$tst_gethostname_type_arg2" != "unknown"; then
1492      AC_DEFINE_UNQUOTED(GETHOSTNAME_TYPE_ARG2, $tst_gethostname_type_arg2,
1493        [Define to the type of arg 2 for gethostname.])
1494    fi
1495  fi
1496  #
1497  if test "$tst_compi_gethostname" = "yes"; then
1498    AC_MSG_CHECKING([if gethostname usage allowed])
1499    if test "x$cares_disallow_gethostname" != "xyes"; then
1500      AC_MSG_RESULT([yes])
1501      tst_allow_gethostname="yes"
1502    else
1503      AC_MSG_RESULT([no])
1504      tst_allow_gethostname="no"
1505    fi
1506  fi
1507  #
1508  AC_MSG_CHECKING([if gethostname might be used])
1509  if test "$tst_links_gethostname" = "yes" &&
1510     test "$tst_proto_gethostname" = "yes" &&
1511     test "$tst_compi_gethostname" = "yes" &&
1512     test "$tst_allow_gethostname" = "yes"; then
1513    AC_MSG_RESULT([yes])
1514    AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
1515      [Define to 1 if you have the gethostname function.])
1516    ac_cv_func_gethostname="yes"
1517  else
1518    AC_MSG_RESULT([no])
1519    ac_cv_func_gethostname="no"
1520  fi
1521])
1522
1523
1524dnl CARES_CHECK_FUNC_GETSERVBYPORT_R
1525dnl -------------------------------------------------
1526dnl Verify if getservbyport_r is available, prototyped,
1527dnl and can be compiled. If all of these are true, and
1528dnl usage has not been previously disallowed with
1529dnl shell variable cares_disallow_getservbyport_r, then
1530dnl HAVE_GETSERVBYPORT_R will be defined.
1531
1532AC_DEFUN([CARES_CHECK_FUNC_GETSERVBYPORT_R], [
1533  AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
1534  #
1535  tst_links_getservbyport_r="unknown"
1536  tst_proto_getservbyport_r="unknown"
1537  tst_compi_getservbyport_r="unknown"
1538  tst_allow_getservbyport_r="unknown"
1539  tst_nargs_getservbyport_r="unknown"
1540  #
1541  AC_MSG_CHECKING([if getservbyport_r can be linked])
1542  AC_LINK_IFELSE([
1543    AC_LANG_FUNC_LINK_TRY([getservbyport_r])
1544  ],[
1545    AC_MSG_RESULT([yes])
1546    tst_links_getservbyport_r="yes"
1547  ],[
1548    AC_MSG_RESULT([no])
1549    tst_links_getservbyport_r="no"
1550  ])
1551  #
1552  if test "$tst_links_getservbyport_r" = "yes"; then
1553    AC_MSG_CHECKING([if getservbyport_r is prototyped])
1554    AC_EGREP_CPP([getservbyport_r],[
1555      $cares_includes_netdb
1556    ],[
1557      AC_MSG_RESULT([yes])
1558      tst_proto_getservbyport_r="yes"
1559    ],[
1560      AC_MSG_RESULT([no])
1561      tst_proto_getservbyport_r="no"
1562    ])
1563  fi
1564  #
1565  if test "$tst_proto_getservbyport_r" = "yes"; then
1566    if test "$tst_nargs_getservbyport_r" = "unknown"; then
1567      AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
1568      AC_COMPILE_IFELSE([
1569        AC_LANG_PROGRAM([[
1570          $cares_includes_netdb
1571        ]],[[
1572          if(0 != getservbyport_r(0, 0, 0, 0))
1573            return 1;
1574        ]])
1575      ],[
1576        AC_MSG_RESULT([yes])
1577        tst_compi_getservbyport_r="yes"
1578        tst_nargs_getservbyport_r="4"
1579      ],[
1580        AC_MSG_RESULT([no])
1581        tst_compi_getservbyport_r="no"
1582      ])
1583    fi
1584    if test "$tst_nargs_getservbyport_r" = "unknown"; then
1585      AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
1586      AC_COMPILE_IFELSE([
1587        AC_LANG_PROGRAM([[
1588          $cares_includes_netdb
1589        ]],[[
1590          if(0 != getservbyport_r(0, 0, 0, 0, 0))
1591            return 1;
1592        ]])
1593      ],[
1594        AC_MSG_RESULT([yes])
1595        tst_compi_getservbyport_r="yes"
1596        tst_nargs_getservbyport_r="5"
1597      ],[
1598        AC_MSG_RESULT([no])
1599        tst_compi_getservbyport_r="no"
1600      ])
1601    fi
1602    if test "$tst_nargs_getservbyport_r" = "unknown"; then
1603      AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
1604      AC_COMPILE_IFELSE([
1605        AC_LANG_PROGRAM([[
1606          $cares_includes_netdb
1607        ]],[[
1608          if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
1609            return 1;
1610        ]])
1611      ],[
1612        AC_MSG_RESULT([yes])
1613        tst_compi_getservbyport_r="yes"
1614        tst_nargs_getservbyport_r="6"
1615      ],[
1616        AC_MSG_RESULT([no])
1617        tst_compi_getservbyport_r="no"
1618      ])
1619    fi
1620    AC_MSG_CHECKING([if getservbyport_r is compilable])
1621    if test "$tst_compi_getservbyport_r" = "yes"; then
1622      AC_MSG_RESULT([yes])
1623    else
1624      AC_MSG_RESULT([no])
1625    fi
1626  fi
1627  #
1628  if test "$tst_compi_getservbyport_r" = "yes"; then
1629    AC_MSG_CHECKING([if getservbyport_r usage allowed])
1630    if test "x$cares_disallow_getservbyport_r" != "xyes"; then
1631      AC_MSG_RESULT([yes])
1632      tst_allow_getservbyport_r="yes"
1633    else
1634      AC_MSG_RESULT([no])
1635      tst_allow_getservbyport_r="no"
1636    fi
1637  fi
1638  #
1639  AC_MSG_CHECKING([if getservbyport_r might be used])
1640  if test "$tst_links_getservbyport_r" = "yes" &&
1641     test "$tst_proto_getservbyport_r" = "yes" &&
1642     test "$tst_compi_getservbyport_r" = "yes" &&
1643     test "$tst_allow_getservbyport_r" = "yes"; then
1644    AC_MSG_RESULT([yes])
1645    AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
1646      [Define to 1 if you have the getservbyport_r function.])
1647    AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
1648      [Specifies the number of arguments to getservbyport_r])
1649    if test "$tst_nargs_getservbyport_r" -eq "4"; then
1650      AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
1651        [Specifies the size of the buffer to pass to getservbyport_r])
1652    else
1653      AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
1654        [Specifies the size of the buffer to pass to getservbyport_r])
1655    fi
1656    ac_cv_func_getservbyport_r="yes"
1657  else
1658    AC_MSG_RESULT([no])
1659    ac_cv_func_getservbyport_r="no"
1660  fi
1661])
1662
1663
1664dnl CARES_CHECK_FUNC_GETSERVBYNAME_R
1665dnl -------------------------------------------------
1666dnl Verify if getservbyname_r is available, prototyped,
1667dnl and can be compiled. If all of these are true, and
1668dnl usage has not been previously disallowed with
1669dnl shell variable cares_disallow_getservbyname_r, then
1670dnl HAVE_GETSERVBYNAME_R will be defined.
1671
1672AC_DEFUN([CARES_CHECK_FUNC_GETSERVBYNAME_R], [
1673  AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
1674  #
1675  tst_links_getservbyname_r="unknown"
1676  tst_proto_getservbyname_r="unknown"
1677  tst_compi_getservbyname_r="unknown"
1678  tst_allow_getservbyname_r="unknown"
1679  tst_nargs_getservbyname_r="unknown"
1680  #
1681  AC_MSG_CHECKING([if getservbyname_r can be linked])
1682  AC_LINK_IFELSE([
1683    AC_LANG_FUNC_LINK_TRY([getservbyname_r])
1684  ],[
1685    AC_MSG_RESULT([yes])
1686    tst_links_getservbyname_r="yes"
1687  ],[
1688    AC_MSG_RESULT([no])
1689    tst_links_getservbyname_r="no"
1690  ])
1691  #
1692  if test "$tst_links_getservbyname_r" = "yes"; then
1693    AC_MSG_CHECKING([if getservbyname_r is prototyped])
1694    AC_EGREP_CPP([getservbyname_r],[
1695      $cares_includes_netdb
1696    ],[
1697      AC_MSG_RESULT([yes])
1698      tst_proto_getservbyname_r="yes"
1699    ],[
1700      AC_MSG_RESULT([no])
1701      tst_proto_getservbyname_r="no"
1702    ])
1703  fi
1704  #
1705  if test "$tst_proto_getservbyname_r" = "yes"; then
1706    if test "$tst_nargs_getservbyname_r" = "unknown"; then
1707      AC_MSG_CHECKING([if getservbyname_r takes 4 args.])
1708      AC_COMPILE_IFELSE([
1709        AC_LANG_PROGRAM([[
1710          $cares_includes_netdb
1711        ]],[[
1712          if(0 != getservbyname_r(0, 0, 0, 0))
1713            return 1;
1714        ]])
1715      ],[
1716        AC_MSG_RESULT([yes])
1717        tst_compi_getservbyname_r="yes"
1718        tst_nargs_getservbyname_r="4"
1719      ],[
1720        AC_MSG_RESULT([no])
1721        tst_compi_getservbyname_r="no"
1722      ])
1723    fi
1724    if test "$tst_nargs_getservbyname_r" = "unknown"; then
1725      AC_MSG_CHECKING([if getservbyname_r takes 5 args.])
1726      AC_COMPILE_IFELSE([
1727        AC_LANG_PROGRAM([[
1728          $cares_includes_netdb
1729        ]],[[
1730          if(0 != getservbyname_r(0, 0, 0, 0, 0))
1731            return 1;
1732        ]])
1733      ],[
1734        AC_MSG_RESULT([yes])
1735        tst_compi_getservbyname_r="yes"
1736        tst_nargs_getservbyname_r="5"
1737      ],[
1738        AC_MSG_RESULT([no])
1739        tst_compi_getservbyname_r="no"
1740      ])
1741    fi
1742    if test "$tst_nargs_getservbyname_r" = "unknown"; then
1743      AC_MSG_CHECKING([if getservbyname_r takes 6 args.])
1744      AC_COMPILE_IFELSE([
1745        AC_LANG_PROGRAM([[
1746          $cares_includes_netdb
1747        ]],[[
1748          if(0 != getservbyname_r(0, 0, 0, 0, 0, 0))
1749            return 1;
1750        ]])
1751      ],[
1752        AC_MSG_RESULT([yes])
1753        tst_compi_getservbyname_r="yes"
1754        tst_nargs_getservbyname_r="6"
1755      ],[
1756        AC_MSG_RESULT([no])
1757        tst_compi_getservbyname_r="no"
1758      ])
1759    fi
1760    AC_MSG_CHECKING([if getservbyname_r is compilable])
1761    if test "$tst_compi_getservbyname_r" = "yes"; then
1762      AC_MSG_RESULT([yes])
1763    else
1764      AC_MSG_RESULT([no])
1765    fi
1766  fi
1767  #
1768  if test "$tst_compi_getservbyname_r" = "yes"; then
1769    AC_MSG_CHECKING([if getservbyname_r usage allowed])
1770    if test "x$cares_disallow_getservbyname_r" != "xyes"; then
1771      AC_MSG_RESULT([yes])
1772      tst_allow_getservbyname_r="yes"
1773    else
1774      AC_MSG_RESULT([no])
1775      tst_allow_getservbyname_r="no"
1776    fi
1777  fi
1778  #
1779  AC_MSG_CHECKING([if getservbyname_r might be used])
1780  if test "$tst_links_getservbyname_r" = "yes" &&
1781     test "$tst_proto_getservbyname_r" = "yes" &&
1782     test "$tst_compi_getservbyname_r" = "yes" &&
1783     test "$tst_allow_getservbyname_r" = "yes"; then
1784    AC_MSG_RESULT([yes])
1785    AC_DEFINE_UNQUOTED(HAVE_GETSERVBYNAME_R, 1,
1786      [Define to 1 if you have the getservbyname_r function.])
1787    AC_DEFINE_UNQUOTED(GETSERVBYNAME_R_ARGS, $tst_nargs_getservbyname_r,
1788      [Specifies the number of arguments to getservbyname_r])
1789    if test "$tst_nargs_getservbyname_r" -eq "4"; then
1790      AC_DEFINE(GETSERVBYNAME_R_BUFSIZE, sizeof(struct servent_data),
1791        [Specifies the size of the buffer to pass to getservbyname_r])
1792    else
1793      AC_DEFINE(GETSERVBYNAME_R_BUFSIZE, 4096,
1794        [Specifies the size of the buffer to pass to getservbyname_r])
1795    fi
1796    ac_cv_func_getservbyname_r="yes"
1797  else
1798    AC_MSG_RESULT([no])
1799    ac_cv_func_getservbyname_r="no"
1800  fi
1801])
1802
1803
1804dnl CARES_CHECK_FUNC_INET_NET_PTON
1805dnl -------------------------------------------------
1806dnl Verify if inet_net_pton is available, prototyped, can
1807dnl be compiled and seems to work. If all of these are
1808dnl true, and usage has not been previously disallowed
1809dnl with shell variable cares_disallow_inet_net_pton, then
1810dnl HAVE_INET_NET_PTON will be defined.
1811
1812AC_DEFUN([CARES_CHECK_FUNC_INET_NET_PTON], [
1813  AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
1814  AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
1815  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
1816  #
1817  tst_links_inet_net_pton="unknown"
1818  tst_proto_inet_net_pton="unknown"
1819  tst_compi_inet_net_pton="unknown"
1820  tst_works_inet_net_pton="unknown"
1821  tst_allow_inet_net_pton="unknown"
1822  #
1823  AC_MSG_CHECKING([if inet_net_pton can be linked])
1824  AC_LINK_IFELSE([
1825    AC_LANG_FUNC_LINK_TRY([inet_net_pton])
1826  ],[
1827    AC_MSG_RESULT([yes])
1828    tst_links_inet_net_pton="yes"
1829  ],[
1830    AC_MSG_RESULT([no])
1831    tst_links_inet_net_pton="no"
1832  ])
1833  #
1834  if test "$tst_links_inet_net_pton" = "yes"; then
1835    AC_MSG_CHECKING([if inet_net_pton is prototyped])
1836    AC_EGREP_CPP([inet_net_pton],[
1837      $cares_includes_arpa_inet
1838    ],[
1839      AC_MSG_RESULT([yes])
1840      tst_proto_inet_net_pton="yes"
1841    ],[
1842      AC_MSG_RESULT([no])
1843      tst_proto_inet_net_pton="no"
1844    ])
1845  fi
1846  #
1847  if test "$tst_proto_inet_net_pton" = "yes"; then
1848    AC_MSG_CHECKING([if inet_net_pton is compilable])
1849    AC_COMPILE_IFELSE([
1850      AC_LANG_PROGRAM([[
1851        $cares_includes_arpa_inet
1852      ]],[[
1853        if(0 != inet_net_pton(0, 0, 0, 0))
1854          return 1;
1855      ]])
1856    ],[
1857      AC_MSG_RESULT([yes])
1858      tst_compi_inet_net_pton="yes"
1859    ],[
1860      AC_MSG_RESULT([no])
1861      tst_compi_inet_net_pton="no"
1862    ])
1863  fi
1864  #
1865  dnl only do runtime verification when not cross-compiling
1866  if test "x$cross_compiling" != "xyes" &&
1867    test "$tst_compi_inet_net_pton" = "yes"; then
1868    AC_MSG_CHECKING([if inet_net_pton seems to work])
1869    AC_RUN_IFELSE([
1870      AC_LANG_PROGRAM([[
1871        $cares_includes_stdlib
1872        $cares_includes_arpa_inet
1873        $cares_includes_string
1874      ]],[[
1875        unsigned char ipv6a[16+1];
1876        unsigned char ipv4a[4+1];
1877        const char *ipv6net1 = "fe80::214:4fff:fe0b:76c8";
1878        const char *ipv6net2 = "::fffe:7f00:1";
1879        const char *ipv6net3 = "7f20:1::/64";
1880        const char *ipv6net4 = "7f20:1::/2147483649";
1881        const char *ipv4net1 = "192.168.100.1";
1882        const char *ipv4net2 = "192.168.100/32";
1883        const char *ipv4net3 = "192.168.100.1/2147483649";
1884        /* - */
1885        memset(ipv4a, 1, sizeof(ipv4a));
1886        if(32 != inet_net_pton(AF_INET, ipv4net1, ipv4a, 4))
1887          exit(1); /* fail */
1888        /* - */
1889        if( (ipv4a[0x00] != 0xc0) ||
1890            (ipv4a[0x01] != 0xa8) ||
1891            (ipv4a[0x02] != 0x64) ||
1892            (ipv4a[0x03] != 0x01) ||
1893            (ipv4a[0x04] != 0x01) )
1894          exit(1); /* fail */
1895        /* - */
1896        memset(ipv4a, 1, sizeof(ipv4a));
1897        if(32 != inet_net_pton(AF_INET, ipv4net2, ipv4a, 4))
1898          exit(1); /* fail */
1899        /* - */
1900        if( (ipv4a[0x00] != 0xc0) ||
1901            (ipv4a[0x01] != 0xa8) ||
1902            (ipv4a[0x02] != 0x64) ||
1903            (ipv4a[0x03] != 0x00) ||
1904            (ipv4a[0x04] != 0x01) )
1905          exit(1); /* fail */
1906        /* - */
1907        memset(ipv4a, 1, sizeof(ipv4a));
1908        if(-1 != inet_net_pton(AF_INET, ipv4net3, ipv4a, 4))
1909          exit(1); /* fail */
1910        /* - */
1911        memset(ipv6a, 1, sizeof(ipv6a));
1912        if(128 != inet_net_pton(AF_INET6, ipv6net1, ipv6a, 16))
1913          exit(1); /* fail */
1914        /* - */
1915        if( (ipv6a[0x00] != 0xfe) ||
1916            (ipv6a[0x01] != 0x80) ||
1917            (ipv6a[0x08] != 0x02) ||
1918            (ipv6a[0x09] != 0x14) ||
1919            (ipv6a[0x0a] != 0x4f) ||
1920            (ipv6a[0x0b] != 0xff) ||
1921            (ipv6a[0x0c] != 0xfe) ||
1922            (ipv6a[0x0d] != 0x0b) ||
1923            (ipv6a[0x0e] != 0x76) ||
1924            (ipv6a[0x0f] != 0xc8) ||
1925            (ipv6a[0x10] != 0x01) )
1926          exit(1); /* fail */
1927        /* - */
1928        if( (ipv6a[0x02] != 0x0) ||
1929            (ipv6a[0x03] != 0x0) ||
1930            (ipv6a[0x04] != 0x0) ||
1931            (ipv6a[0x05] != 0x0) ||
1932            (ipv6a[0x06] != 0x0) ||
1933            (ipv6a[0x07] != 0x0) )
1934          exit(1); /* fail */
1935        /* - */
1936        memset(ipv6a, 0, sizeof(ipv6a));
1937        ipv6a[0x10] = 0x01;
1938        if(128 != inet_net_pton(AF_INET6, ipv6net2, ipv6a, 16))
1939          exit(1); /* fail */
1940        /* - */
1941        if( (ipv6a[0x0a] != 0xff) ||
1942            (ipv6a[0x0b] != 0xfe) ||
1943            (ipv6a[0x0c] != 0x7f) ||
1944            (ipv6a[0x0f] != 0x01) ||
1945            (ipv6a[0x10] != 0x01) )
1946          exit(1); /* fail */
1947        /* - */
1948        if( (ipv6a[0x00] != 0x0) ||
1949            (ipv6a[0x01] != 0x0) ||
1950            (ipv6a[0x02] != 0x0) ||
1951            (ipv6a[0x03] != 0x0) ||
1952            (ipv6a[0x04] != 0x0) ||
1953            (ipv6a[0x05] != 0x0) ||
1954            (ipv6a[0x06] != 0x0) ||
1955            (ipv6a[0x07] != 0x0) ||
1956            (ipv6a[0x08] != 0x0) ||
1957            (ipv6a[0x09] != 0x0) ||
1958            (ipv6a[0x0d] != 0x0) ||
1959            (ipv6a[0x0e] != 0x0) )
1960          exit(1); /* fail */
1961        /* - */
1962        memset(ipv6a, 1, sizeof(ipv6a));
1963        if(64 != inet_net_pton(AF_INET6, ipv6net3, ipv6a, 16))
1964          exit(1); /* fail */
1965        if( (ipv6a[0x00] != 0x7f) ||
1966            (ipv6a[0x01] != 0x20) ||
1967            (ipv6a[0x03] != 0x01) ||
1968            (ipv6a[0x08] != 0x01) ||
1969            (ipv6a[0x09] != 0x01) ||
1970            (ipv6a[0x0a] != 0x01) ||
1971            (ipv6a[0x0b] != 0x01) ||
1972            (ipv6a[0x0c] != 0x01) ||
1973            (ipv6a[0x0d] != 0x01) ||
1974            (ipv6a[0x0e] != 0x01) ||
1975            (ipv6a[0x0f] != 0x01) ||
1976            (ipv6a[0x10] != 0x01) )
1977          exit(1); /* fail */
1978        if( (ipv6a[0x02] != 0x0) ||
1979            (ipv6a[0x04] != 0x0) ||
1980            (ipv6a[0x05] != 0x0) ||
1981            (ipv6a[0x06] != 0x0) ||
1982            (ipv6a[0x07] != 0x0) ||
1983            (ipv6a[0x07] != 0x0) )
1984          exit(1); /* fail */
1985        /* - */
1986        memset(ipv6a, 1, sizeof(ipv6a));
1987        if(-1 != inet_net_pton(AF_INET6, ipv6net4, ipv6a, 16))
1988          exit(1); /* fail */
1989        /* - */
1990        exit(0);
1991      ]])
1992    ],[
1993      AC_MSG_RESULT([yes])
1994      tst_works_inet_net_pton="yes"
1995    ],[
1996      AC_MSG_RESULT([no])
1997      tst_works_inet_net_pton="no"
1998    ])
1999  fi
2000  #
2001  if test "$tst_compi_inet_net_pton" = "yes" &&
2002    test "$tst_works_inet_net_pton" != "no"; then
2003    AC_MSG_CHECKING([if inet_net_pton usage allowed])
2004    if test "x$cares_disallow_inet_net_pton" != "xyes"; then
2005      AC_MSG_RESULT([yes])
2006      tst_allow_inet_net_pton="yes"
2007    else
2008      AC_MSG_RESULT([no])
2009      tst_allow_inet_net_pton="no"
2010    fi
2011  fi
2012  #
2013  AC_MSG_CHECKING([if inet_net_pton might be used])
2014  if test "$tst_links_inet_net_pton" = "yes" &&
2015     test "$tst_proto_inet_net_pton" = "yes" &&
2016     test "$tst_compi_inet_net_pton" = "yes" &&
2017     test "$tst_allow_inet_net_pton" = "yes" &&
2018     test "$tst_works_inet_net_pton" != "no"; then
2019    AC_MSG_RESULT([yes])
2020    AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON, 1,
2021      [Define to 1 if you have a IPv6 capable working inet_net_pton function.])
2022    ac_cv_func_inet_net_pton="yes"
2023  else
2024    AC_MSG_RESULT([no])
2025    ac_cv_func_inet_net_pton="no"
2026  fi
2027])
2028
2029
2030dnl CARES_CHECK_FUNC_INET_NTOP
2031dnl -------------------------------------------------
2032dnl Verify if inet_ntop is available, prototyped, can
2033dnl be compiled and seems to work. If all of these are
2034dnl true, and usage has not been previously disallowed
2035dnl with shell variable cares_disallow_inet_ntop, then
2036dnl HAVE_INET_NTOP will be defined.
2037
2038AC_DEFUN([CARES_CHECK_FUNC_INET_NTOP], [
2039  AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
2040  AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
2041  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
2042  #
2043  tst_links_inet_ntop="unknown"
2044  tst_proto_inet_ntop="unknown"
2045  tst_compi_inet_ntop="unknown"
2046  tst_works_inet_ntop="unknown"
2047  tst_allow_inet_ntop="unknown"
2048  #
2049  AC_MSG_CHECKING([if inet_ntop can be linked])
2050  AC_LINK_IFELSE([
2051    AC_LANG_FUNC_LINK_TRY([inet_ntop])
2052  ],[
2053    AC_MSG_RESULT([yes])
2054    tst_links_inet_ntop="yes"
2055  ],[
2056    AC_MSG_RESULT([no])
2057    tst_links_inet_ntop="no"
2058  ])
2059  #
2060  if test "$tst_links_inet_ntop" = "yes"; then
2061    AC_MSG_CHECKING([if inet_ntop is prototyped])
2062    AC_EGREP_CPP([inet_ntop],[
2063      $cares_includes_arpa_inet
2064    ],[
2065      AC_MSG_RESULT([yes])
2066      tst_proto_inet_ntop="yes"
2067    ],[
2068      AC_MSG_RESULT([no])
2069      tst_proto_inet_ntop="no"
2070    ])
2071  fi
2072  #
2073  if test "$tst_proto_inet_ntop" = "yes"; then
2074    AC_MSG_CHECKING([if inet_ntop is compilable])
2075    AC_COMPILE_IFELSE([
2076      AC_LANG_PROGRAM([[
2077        $cares_includes_arpa_inet
2078      ]],[[
2079        if(0 != inet_ntop(0, 0, 0, 0))
2080          return 1;
2081      ]])
2082    ],[
2083      AC_MSG_RESULT([yes])
2084      tst_compi_inet_ntop="yes"
2085    ],[
2086      AC_MSG_RESULT([no])
2087      tst_compi_inet_ntop="no"
2088    ])
2089  fi
2090  #
2091  dnl only do runtime verification when not cross-compiling
2092  if test "x$cross_compiling" != "xyes" &&
2093    test "$tst_compi_inet_ntop" = "yes"; then
2094    AC_MSG_CHECKING([if inet_ntop seems to work])
2095    AC_RUN_IFELSE([
2096      AC_LANG_PROGRAM([[
2097        $cares_includes_stdlib
2098        $cares_includes_arpa_inet
2099        $cares_includes_string
2100      ]],[[
2101        char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
2102        char ipv4res[sizeof "255.255.255.255"];
2103        unsigned char ipv6a[26];
2104        unsigned char ipv4a[5];
2105        char *ipv6ptr = 0;
2106        char *ipv4ptr = 0;
2107        /* - */
2108        ipv4res[0] = '\0';
2109        ipv4a[0] = 0xc0;
2110        ipv4a[1] = 0xa8;
2111        ipv4a[2] = 0x64;
2112        ipv4a[3] = 0x01;
2113        ipv4a[4] = 0x01;
2114        /* - */
2115        ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
2116        if(!ipv4ptr)
2117          exit(1); /* fail */
2118        if(ipv4ptr != ipv4res)
2119          exit(1); /* fail */
2120        if(!ipv4ptr[0])
2121          exit(1); /* fail */
2122        if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
2123          exit(1); /* fail */
2124        /* - */
2125        ipv6res[0] = '\0';
2126        memset(ipv6a, 0, sizeof(ipv6a));
2127        ipv6a[0] = 0xfe;
2128        ipv6a[1] = 0x80;
2129        ipv6a[8] = 0x02;
2130        ipv6a[9] = 0x14;
2131        ipv6a[10] = 0x4f;
2132        ipv6a[11] = 0xff;
2133        ipv6a[12] = 0xfe;
2134        ipv6a[13] = 0x0b;
2135        ipv6a[14] = 0x76;
2136        ipv6a[15] = 0xc8;
2137        ipv6a[25] = 0x01;
2138        /* - */
2139        ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
2140        if(!ipv6ptr)
2141          exit(1); /* fail */
2142        if(ipv6ptr != ipv6res)
2143          exit(1); /* fail */
2144        if(!ipv6ptr[0])
2145          exit(1); /* fail */
2146        if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0)
2147          exit(1); /* fail */
2148        /* - */
2149        exit(0);
2150      ]])
2151    ],[
2152      AC_MSG_RESULT([yes])
2153      tst_works_inet_ntop="yes"
2154    ],[
2155      AC_MSG_RESULT([no])
2156      tst_works_inet_ntop="no"
2157    ])
2158  fi
2159  #
2160  if test "$tst_compi_inet_ntop" = "yes" &&
2161    test "$tst_works_inet_ntop" != "no"; then
2162    AC_MSG_CHECKING([if inet_ntop usage allowed])
2163    if test "x$cares_disallow_inet_ntop" != "xyes"; then
2164      AC_MSG_RESULT([yes])
2165      tst_allow_inet_ntop="yes"
2166    else
2167      AC_MSG_RESULT([no])
2168      tst_allow_inet_ntop="no"
2169    fi
2170  fi
2171  #
2172  AC_MSG_CHECKING([if inet_ntop might be used])
2173  if test "$tst_links_inet_ntop" = "yes" &&
2174     test "$tst_proto_inet_ntop" = "yes" &&
2175     test "$tst_compi_inet_ntop" = "yes" &&
2176     test "$tst_allow_inet_ntop" = "yes" &&
2177     test "$tst_works_inet_ntop" != "no"; then
2178    AC_MSG_RESULT([yes])
2179    AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, 1,
2180      [Define to 1 if you have a IPv6 capable working inet_ntop function.])
2181    ac_cv_func_inet_ntop="yes"
2182  else
2183    AC_MSG_RESULT([no])
2184    ac_cv_func_inet_ntop="no"
2185  fi
2186])
2187
2188
2189dnl CARES_CHECK_FUNC_INET_PTON
2190dnl -------------------------------------------------
2191dnl Verify if inet_pton is available, prototyped, can
2192dnl be compiled and seems to work. If all of these are
2193dnl true, and usage has not been previously disallowed
2194dnl with shell variable cares_disallow_inet_pton, then
2195dnl HAVE_INET_PTON will be defined.
2196
2197AC_DEFUN([CARES_CHECK_FUNC_INET_PTON], [
2198  AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
2199  AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
2200  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
2201  #
2202  tst_links_inet_pton="unknown"
2203  tst_proto_inet_pton="unknown"
2204  tst_compi_inet_pton="unknown"
2205  tst_works_inet_pton="unknown"
2206  tst_allow_inet_pton="unknown"
2207  #
2208  AC_MSG_CHECKING([if inet_pton can be linked])
2209  AC_LINK_IFELSE([
2210    AC_LANG_FUNC_LINK_TRY([inet_pton])
2211  ],[
2212    AC_MSG_RESULT([yes])
2213    tst_links_inet_pton="yes"
2214  ],[
2215    AC_MSG_RESULT([no])
2216    tst_links_inet_pton="no"
2217  ])
2218  #
2219  if test "$tst_links_inet_pton" = "yes"; then
2220    AC_MSG_CHECKING([if inet_pton is prototyped])
2221    AC_EGREP_CPP([inet_pton],[
2222      $cares_includes_arpa_inet
2223    ],[
2224      AC_MSG_RESULT([yes])
2225      tst_proto_inet_pton="yes"
2226    ],[
2227      AC_MSG_RESULT([no])
2228      tst_proto_inet_pton="no"
2229    ])
2230  fi
2231  #
2232  if test "$tst_proto_inet_pton" = "yes"; then
2233    AC_MSG_CHECKING([if inet_pton is compilable])
2234    AC_COMPILE_IFELSE([
2235      AC_LANG_PROGRAM([[
2236        $cares_includes_arpa_inet
2237      ]],[[
2238        if(0 != inet_pton(0, 0, 0))
2239          return 1;
2240      ]])
2241    ],[
2242      AC_MSG_RESULT([yes])
2243      tst_compi_inet_pton="yes"
2244    ],[
2245      AC_MSG_RESULT([no])
2246      tst_compi_inet_pton="no"
2247    ])
2248  fi
2249  #
2250  dnl only do runtime verification when not cross-compiling
2251  if test "x$cross_compiling" != "xyes" &&
2252    test "$tst_compi_inet_pton" = "yes"; then
2253    AC_MSG_CHECKING([if inet_pton seems to work])
2254    AC_RUN_IFELSE([
2255      AC_LANG_PROGRAM([[
2256        $cares_includes_stdlib
2257        $cares_includes_arpa_inet
2258        $cares_includes_string
2259      ]],[[
2260        unsigned char ipv6a[16+1];
2261        unsigned char ipv4a[4+1];
2262        const char *ipv6src = "fe80::214:4fff:fe0b:76c8";
2263        const char *ipv4src = "192.168.100.1";
2264        /* - */
2265        memset(ipv4a, 1, sizeof(ipv4a));
2266        if(1 != inet_pton(AF_INET, ipv4src, ipv4a))
2267          exit(1); /* fail */
2268        /* - */
2269        if( (ipv4a[0] != 0xc0) ||
2270            (ipv4a[1] != 0xa8) ||
2271            (ipv4a[2] != 0x64) ||
2272            (ipv4a[3] != 0x01) ||
2273            (ipv4a[4] != 0x01) )
2274          exit(1); /* fail */
2275        /* - */
2276        memset(ipv6a, 1, sizeof(ipv6a));
2277        if(1 != inet_pton(AF_INET6, ipv6src, ipv6a))
2278          exit(1); /* fail */
2279        /* - */
2280        if( (ipv6a[0]  != 0xfe) ||
2281            (ipv6a[1]  != 0x80) ||
2282            (ipv6a[8]  != 0x02) ||
2283            (ipv6a[9]  != 0x14) ||
2284            (ipv6a[10] != 0x4f) ||
2285            (ipv6a[11] != 0xff) ||
2286            (ipv6a[12] != 0xfe) ||
2287            (ipv6a[13] != 0x0b) ||
2288            (ipv6a[14] != 0x76) ||
2289            (ipv6a[15] != 0xc8) ||
2290            (ipv6a[16] != 0x01) )
2291          exit(1); /* fail */
2292        /* - */
2293        if( (ipv6a[2]  != 0x0) ||
2294            (ipv6a[3]  != 0x0) ||
2295            (ipv6a[4]  != 0x0) ||
2296            (ipv6a[5]  != 0x0) ||
2297            (ipv6a[6]  != 0x0) ||
2298            (ipv6a[7]  != 0x0) )
2299          exit(1); /* fail */
2300        /* - */
2301        exit(0);
2302      ]])
2303    ],[
2304      AC_MSG_RESULT([yes])
2305      tst_works_inet_pton="yes"
2306    ],[
2307      AC_MSG_RESULT([no])
2308      tst_works_inet_pton="no"
2309    ])
2310  fi
2311  #
2312  if test "$tst_compi_inet_pton" = "yes" &&
2313    test "$tst_works_inet_pton" != "no"; then
2314    AC_MSG_CHECKING([if inet_pton usage allowed])
2315    if test "x$cares_disallow_inet_pton" != "xyes"; then
2316      AC_MSG_RESULT([yes])
2317      tst_allow_inet_pton="yes"
2318    else
2319      AC_MSG_RESULT([no])
2320      tst_allow_inet_pton="no"
2321    fi
2322  fi
2323  #
2324  AC_MSG_CHECKING([if inet_pton might be used])
2325  if test "$tst_links_inet_pton" = "yes" &&
2326     test "$tst_proto_inet_pton" = "yes" &&
2327     test "$tst_compi_inet_pton" = "yes" &&
2328     test "$tst_allow_inet_pton" = "yes" &&
2329     test "$tst_works_inet_pton" != "no"; then
2330    AC_MSG_RESULT([yes])
2331    AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1,
2332      [Define to 1 if you have a IPv6 capable working inet_pton function.])
2333    ac_cv_func_inet_pton="yes"
2334  else
2335    AC_MSG_RESULT([no])
2336    ac_cv_func_inet_pton="no"
2337  fi
2338])
2339
2340
2341dnl CARES_CHECK_FUNC_IOCTL
2342dnl -------------------------------------------------
2343dnl Verify if ioctl is available, prototyped, and
2344dnl can be compiled. If all of these are true, and
2345dnl usage has not been previously disallowed with
2346dnl shell variable cares_disallow_ioctl, then
2347dnl HAVE_IOCTL will be defined.
2348
2349AC_DEFUN([CARES_CHECK_FUNC_IOCTL], [
2350  AC_REQUIRE([CARES_INCLUDES_STROPTS])dnl
2351  #
2352  tst_links_ioctl="unknown"
2353  tst_proto_ioctl="unknown"
2354  tst_compi_ioctl="unknown"
2355  tst_allow_ioctl="unknown"
2356  #
2357  AC_MSG_CHECKING([if ioctl can be linked])
2358  AC_LINK_IFELSE([
2359    AC_LANG_FUNC_LINK_TRY([ioctl])
2360  ],[
2361    AC_MSG_RESULT([yes])
2362    tst_links_ioctl="yes"
2363  ],[
2364    AC_MSG_RESULT([no])
2365    tst_links_ioctl="no"
2366  ])
2367  #
2368  if test "$tst_links_ioctl" = "yes"; then
2369    AC_MSG_CHECKING([if ioctl is prototyped])
2370    AC_EGREP_CPP([ioctl],[
2371      $cares_includes_stropts
2372    ],[
2373      AC_MSG_RESULT([yes])
2374      tst_proto_ioctl="yes"
2375    ],[
2376      AC_MSG_RESULT([no])
2377      tst_proto_ioctl="no"
2378    ])
2379  fi
2380  #
2381  if test "$tst_proto_ioctl" = "yes"; then
2382    AC_MSG_CHECKING([if ioctl is compilable])
2383    AC_COMPILE_IFELSE([
2384      AC_LANG_PROGRAM([[
2385        $cares_includes_stropts
2386      ]],[[
2387        if(0 != ioctl(0, 0, 0))
2388          return 1;
2389      ]])
2390    ],[
2391      AC_MSG_RESULT([yes])
2392      tst_compi_ioctl="yes"
2393    ],[
2394      AC_MSG_RESULT([no])
2395      tst_compi_ioctl="no"
2396    ])
2397  fi
2398  #
2399  if test "$tst_compi_ioctl" = "yes"; then
2400    AC_MSG_CHECKING([if ioctl usage allowed])
2401    if test "x$cares_disallow_ioctl" != "xyes"; then
2402      AC_MSG_RESULT([yes])
2403      tst_allow_ioctl="yes"
2404    else
2405      AC_MSG_RESULT([no])
2406      tst_allow_ioctl="no"
2407    fi
2408  fi
2409  #
2410  AC_MSG_CHECKING([if ioctl might be used])
2411  if test "$tst_links_ioctl" = "yes" &&
2412     test "$tst_proto_ioctl" = "yes" &&
2413     test "$tst_compi_ioctl" = "yes" &&
2414     test "$tst_allow_ioctl" = "yes"; then
2415    AC_MSG_RESULT([yes])
2416    AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
2417      [Define to 1 if you have the ioctl function.])
2418    ac_cv_func_ioctl="yes"
2419    CARES_CHECK_FUNC_IOCTL_FIONBIO
2420    CARES_CHECK_FUNC_IOCTL_SIOCGIFADDR
2421  else
2422    AC_MSG_RESULT([no])
2423    ac_cv_func_ioctl="no"
2424  fi
2425])
2426
2427
2428dnl CARES_CHECK_FUNC_IOCTL_FIONBIO
2429dnl -------------------------------------------------
2430dnl Verify if ioctl with the FIONBIO command is
2431dnl available, can be compiled, and seems to work. If
2432dnl all of these are true, then HAVE_IOCTL_FIONBIO
2433dnl will be defined.
2434
2435AC_DEFUN([CARES_CHECK_FUNC_IOCTL_FIONBIO], [
2436  #
2437  tst_compi_ioctl_fionbio="unknown"
2438  tst_allow_ioctl_fionbio="unknown"
2439  #
2440  if test "$ac_cv_func_ioctl" = "yes"; then
2441    AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
2442    AC_COMPILE_IFELSE([
2443      AC_LANG_PROGRAM([[
2444        $cares_includes_stropts
2445      ]],[[
2446        int flags = 0;
2447        if(0 != ioctl(0, FIONBIO, &flags))
2448          return 1;
2449      ]])
2450    ],[
2451      AC_MSG_RESULT([yes])
2452      tst_compi_ioctl_fionbio="yes"
2453    ],[
2454      AC_MSG_RESULT([no])
2455      tst_compi_ioctl_fionbio="no"
2456    ])
2457  fi
2458  #
2459  if test "$tst_compi_ioctl_fionbio" = "yes"; then
2460    AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
2461    if test "x$cares_disallow_ioctl_fionbio" != "xyes"; then
2462      AC_MSG_RESULT([yes])
2463      tst_allow_ioctl_fionbio="yes"
2464    else
2465      AC_MSG_RESULT([no])
2466      tst_allow_ioctl_fionbio="no"
2467    fi
2468  fi
2469  #
2470  AC_MSG_CHECKING([if ioctl FIONBIO might be used])
2471  if test "$tst_compi_ioctl_fionbio" = "yes" &&
2472     test "$tst_allow_ioctl_fionbio" = "yes"; then
2473    AC_MSG_RESULT([yes])
2474    AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
2475      [Define to 1 if you have a working ioctl FIONBIO function.])
2476    ac_cv_func_ioctl_fionbio="yes"
2477  else
2478    AC_MSG_RESULT([no])
2479    ac_cv_func_ioctl_fionbio="no"
2480  fi
2481])
2482
2483
2484dnl CARES_CHECK_FUNC_IOCTL_SIOCGIFADDR
2485dnl -------------------------------------------------
2486dnl Verify if ioctl with the SIOCGIFADDR command is available,
2487dnl struct ifreq is defined, they can be compiled, and seem to
2488dnl work. If all of these are true, then HAVE_IOCTL_SIOCGIFADDR
2489dnl will be defined.
2490
2491AC_DEFUN([CARES_CHECK_FUNC_IOCTL_SIOCGIFADDR], [
2492  #
2493  tst_compi_ioctl_siocgifaddr="unknown"
2494  tst_allow_ioctl_siocgifaddr="unknown"
2495  #
2496  if test "$ac_cv_func_ioctl" = "yes"; then
2497    AC_MSG_CHECKING([if ioctl SIOCGIFADDR is compilable])
2498    AC_COMPILE_IFELSE([
2499      AC_LANG_PROGRAM([[
2500        $cares_includes_stropts
2501        #include <net/if.h>
2502      ]],[[
2503        struct ifreq ifr;
2504        if(0 != ioctl(0, SIOCGIFADDR, &ifr))
2505          return 1;
2506      ]])
2507    ],[
2508      AC_MSG_RESULT([yes])
2509      tst_compi_ioctl_siocgifaddr="yes"
2510    ],[
2511      AC_MSG_RESULT([no])
2512      tst_compi_ioctl_siocgifaddr="no"
2513    ])
2514  fi
2515  #
2516  if test "$tst_compi_ioctl_siocgifaddr" = "yes"; then
2517    AC_MSG_CHECKING([if ioctl SIOCGIFADDR usage allowed])
2518    if test "x$cares_disallow_ioctl_siocgifaddr" != "xyes"; then
2519      AC_MSG_RESULT([yes])
2520      tst_allow_ioctl_siocgifaddr="yes"
2521    else
2522      AC_MSG_RESULT([no])
2523      tst_allow_ioctl_siocgifaddr="no"
2524    fi
2525  fi
2526  #
2527  AC_MSG_CHECKING([if ioctl SIOCGIFADDR might be used])
2528  if test "$tst_compi_ioctl_siocgifaddr" = "yes" &&
2529     test "$tst_allow_ioctl_siocgifaddr" = "yes"; then
2530    AC_MSG_RESULT([yes])
2531    AC_DEFINE_UNQUOTED(HAVE_IOCTL_SIOCGIFADDR, 1,
2532      [Define to 1 if you have a working ioctl SIOCGIFADDR function.])
2533    ac_cv_func_ioctl_siocgifaddr="yes"
2534  else
2535    AC_MSG_RESULT([no])
2536    ac_cv_func_ioctl_siocgifaddr="no"
2537  fi
2538])
2539
2540
2541dnl CARES_CHECK_FUNC_IOCTLSOCKET
2542dnl -------------------------------------------------
2543dnl Verify if ioctlsocket is available, prototyped, and
2544dnl can be compiled. If all of these are true, and
2545dnl usage has not been previously disallowed with
2546dnl shell variable cares_disallow_ioctlsocket, then
2547dnl HAVE_IOCTLSOCKET will be defined.
2548
2549AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET], [
2550  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
2551  #
2552  tst_links_ioctlsocket="unknown"
2553  tst_proto_ioctlsocket="unknown"
2554  tst_compi_ioctlsocket="unknown"
2555  tst_allow_ioctlsocket="unknown"
2556  #
2557  AC_MSG_CHECKING([if ioctlsocket can be linked])
2558  AC_LINK_IFELSE([
2559    AC_LANG_PROGRAM([[
2560      $cares_includes_winsock2
2561    ]],[[
2562      if(0 != ioctlsocket(0, 0, 0))
2563        return 1;
2564    ]])
2565  ],[
2566    AC_MSG_RESULT([yes])
2567    tst_links_ioctlsocket="yes"
2568  ],[
2569    AC_MSG_RESULT([no])
2570    tst_links_ioctlsocket="no"
2571  ])
2572  #
2573  if test "$tst_links_ioctlsocket" = "yes"; then
2574    AC_MSG_CHECKING([if ioctlsocket is prototyped])
2575    AC_EGREP_CPP([ioctlsocket],[
2576      $cares_includes_winsock2
2577    ],[
2578      AC_MSG_RESULT([yes])
2579      tst_proto_ioctlsocket="yes"
2580    ],[
2581      AC_MSG_RESULT([no])
2582      tst_proto_ioctlsocket="no"
2583    ])
2584  fi
2585  #
2586  if test "$tst_proto_ioctlsocket" = "yes"; then
2587    AC_MSG_CHECKING([if ioctlsocket is compilable])
2588    AC_COMPILE_IFELSE([
2589      AC_LANG_PROGRAM([[
2590        $cares_includes_winsock2
2591      ]],[[
2592        if(0 != ioctlsocket(0, 0, 0))
2593          return 1;
2594      ]])
2595    ],[
2596      AC_MSG_RESULT([yes])
2597      tst_compi_ioctlsocket="yes"
2598    ],[
2599      AC_MSG_RESULT([no])
2600      tst_compi_ioctlsocket="no"
2601    ])
2602  fi
2603  #
2604  if test "$tst_compi_ioctlsocket" = "yes"; then
2605    AC_MSG_CHECKING([if ioctlsocket usage allowed])
2606    if test "x$cares_disallow_ioctlsocket" != "xyes"; then
2607      AC_MSG_RESULT([yes])
2608      tst_allow_ioctlsocket="yes"
2609    else
2610      AC_MSG_RESULT([no])
2611      tst_allow_ioctlsocket="no"
2612    fi
2613  fi
2614  #
2615  AC_MSG_CHECKING([if ioctlsocket might be used])
2616  if test "$tst_links_ioctlsocket" = "yes" &&
2617     test "$tst_proto_ioctlsocket" = "yes" &&
2618     test "$tst_compi_ioctlsocket" = "yes" &&
2619     test "$tst_allow_ioctlsocket" = "yes"; then
2620    AC_MSG_RESULT([yes])
2621    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
2622      [Define to 1 if you have the ioctlsocket function.])
2623    ac_cv_func_ioctlsocket="yes"
2624    CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO
2625  else
2626    AC_MSG_RESULT([no])
2627    ac_cv_func_ioctlsocket="no"
2628  fi
2629])
2630
2631
2632dnl CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO
2633dnl -------------------------------------------------
2634dnl Verify if ioctlsocket with the FIONBIO command is
2635dnl available, can be compiled, and seems to work. If
2636dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
2637dnl will be defined.
2638
2639AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
2640  #
2641  tst_compi_ioctlsocket_fionbio="unknown"
2642  tst_allow_ioctlsocket_fionbio="unknown"
2643  #
2644  if test "$ac_cv_func_ioctlsocket" = "yes"; then
2645    AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
2646    AC_COMPILE_IFELSE([
2647      AC_LANG_PROGRAM([[
2648        $cares_includes_winsock2
2649      ]],[[
2650        int flags = 0;
2651        if(0 != ioctlsocket(0, FIONBIO, &flags))
2652          return 1;
2653      ]])
2654    ],[
2655      AC_MSG_RESULT([yes])
2656      tst_compi_ioctlsocket_fionbio="yes"
2657    ],[
2658      AC_MSG_RESULT([no])
2659      tst_compi_ioctlsocket_fionbio="no"
2660    ])
2661  fi
2662  #
2663  if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
2664    AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
2665    if test "x$cares_disallow_ioctlsocket_fionbio" != "xyes"; then
2666      AC_MSG_RESULT([yes])
2667      tst_allow_ioctlsocket_fionbio="yes"
2668    else
2669      AC_MSG_RESULT([no])
2670      tst_allow_ioctlsocket_fionbio="no"
2671    fi
2672  fi
2673  #
2674  AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
2675  if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
2676     test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
2677    AC_MSG_RESULT([yes])
2678    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
2679      [Define to 1 if you have a working ioctlsocket FIONBIO function.])
2680    ac_cv_func_ioctlsocket_fionbio="yes"
2681  else
2682    AC_MSG_RESULT([no])
2683    ac_cv_func_ioctlsocket_fionbio="no"
2684  fi
2685])
2686
2687
2688dnl CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
2689dnl -------------------------------------------------
2690dnl Verify if IoctlSocket is available, prototyped, and
2691dnl can be compiled. If all of these are true, and
2692dnl usage has not been previously disallowed with
2693dnl shell variable cares_disallow_ioctlsocket_camel,
2694dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
2695
2696AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
2697  AC_REQUIRE([CARES_INCLUDES_STROPTS])dnl
2698  #
2699  tst_links_ioctlsocket_camel="unknown"
2700  tst_proto_ioctlsocket_camel="unknown"
2701  tst_compi_ioctlsocket_camel="unknown"
2702  tst_allow_ioctlsocket_camel="unknown"
2703  #
2704  AC_MSG_CHECKING([if IoctlSocket can be linked])
2705  AC_LINK_IFELSE([
2706    AC_LANG_FUNC_LINK_TRY([IoctlSocket])
2707  ],[
2708    AC_MSG_RESULT([yes])
2709    tst_links_ioctlsocket_camel="yes"
2710  ],[
2711    AC_MSG_RESULT([no])
2712    tst_links_ioctlsocket_camel="no"
2713  ])
2714  #
2715  if test "$tst_links_ioctlsocket_camel" = "yes"; then
2716    AC_MSG_CHECKING([if IoctlSocket is prototyped])
2717    AC_EGREP_CPP([IoctlSocket],[
2718      $cares_includes_stropts
2719    ],[
2720      AC_MSG_RESULT([yes])
2721      tst_proto_ioctlsocket_camel="yes"
2722    ],[
2723      AC_MSG_RESULT([no])
2724      tst_proto_ioctlsocket_camel="no"
2725    ])
2726  fi
2727  #
2728  if test "$tst_proto_ioctlsocket_camel" = "yes"; then
2729    AC_MSG_CHECKING([if IoctlSocket is compilable])
2730    AC_COMPILE_IFELSE([
2731      AC_LANG_PROGRAM([[
2732        $cares_includes_stropts
2733      ]],[[
2734        if(0 != IoctlSocket(0, 0, 0))
2735          return 1;
2736      ]])
2737    ],[
2738      AC_MSG_RESULT([yes])
2739      tst_compi_ioctlsocket_camel="yes"
2740    ],[
2741      AC_MSG_RESULT([no])
2742      tst_compi_ioctlsocket_camel="no"
2743    ])
2744  fi
2745  #
2746  if test "$tst_compi_ioctlsocket_camel" = "yes"; then
2747    AC_MSG_CHECKING([if IoctlSocket usage allowed])
2748    if test "x$cares_disallow_ioctlsocket_camel" != "xyes"; then
2749      AC_MSG_RESULT([yes])
2750      tst_allow_ioctlsocket_camel="yes"
2751    else
2752      AC_MSG_RESULT([no])
2753      tst_allow_ioctlsocket_camel="no"
2754    fi
2755  fi
2756  #
2757  AC_MSG_CHECKING([if IoctlSocket might be used])
2758  if test "$tst_links_ioctlsocket_camel" = "yes" &&
2759     test "$tst_proto_ioctlsocket_camel" = "yes" &&
2760     test "$tst_compi_ioctlsocket_camel" = "yes" &&
2761     test "$tst_allow_ioctlsocket_camel" = "yes"; then
2762    AC_MSG_RESULT([yes])
2763    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
2764      [Define to 1 if you have the IoctlSocket camel case function.])
2765    ac_cv_func_ioctlsocket_camel="yes"
2766    CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
2767  else
2768    AC_MSG_RESULT([no])
2769    ac_cv_func_ioctlsocket_camel="no"
2770  fi
2771])
2772
2773
2774dnl CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
2775dnl -------------------------------------------------
2776dnl Verify if IoctlSocket with FIONBIO command is available,
2777dnl can be compiled, and seems to work. If all of these are
2778dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
2779
2780AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
2781  #
2782  tst_compi_ioctlsocket_camel_fionbio="unknown"
2783  tst_allow_ioctlsocket_camel_fionbio="unknown"
2784  #
2785  if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then
2786    AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
2787    AC_COMPILE_IFELSE([
2788      AC_LANG_PROGRAM([[
2789        $cares_includes_stropts
2790      ]],[[
2791        long flags = 0;
2792        if(0 != ioctlsocket(0, FIONBIO, &flags))
2793          return 1;
2794      ]])
2795    ],[
2796      AC_MSG_RESULT([yes])
2797      tst_compi_ioctlsocket_camel_fionbio="yes"
2798    ],[
2799      AC_MSG_RESULT([no])
2800      tst_compi_ioctlsocket_camel_fionbio="no"
2801    ])
2802  fi
2803  #
2804  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
2805    AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
2806    if test "x$cares_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
2807      AC_MSG_RESULT([yes])
2808      tst_allow_ioctlsocket_camel_fionbio="yes"
2809    else
2810      AC_MSG_RESULT([no])
2811      tst_allow_ioctlsocket_camel_fionbio="no"
2812    fi
2813  fi
2814  #
2815  AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
2816  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
2817     test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
2818    AC_MSG_RESULT([yes])
2819    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
2820      [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
2821    ac_cv_func_ioctlsocket_camel_fionbio="yes"
2822  else
2823    AC_MSG_RESULT([no])
2824    ac_cv_func_ioctlsocket_camel_fionbio="no"
2825  fi
2826])
2827
2828
2829dnl CARES_CHECK_FUNC_SETSOCKOPT
2830dnl -------------------------------------------------
2831dnl Verify if setsockopt is available, prototyped, and
2832dnl can be compiled. If all of these are true, and
2833dnl usage has not been previously disallowed with
2834dnl shell variable cares_disallow_setsockopt, then
2835dnl HAVE_SETSOCKOPT will be defined.
2836
2837AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT], [
2838  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
2839  AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
2840  #
2841  tst_links_setsockopt="unknown"
2842  tst_proto_setsockopt="unknown"
2843  tst_compi_setsockopt="unknown"
2844  tst_allow_setsockopt="unknown"
2845  #
2846  AC_MSG_CHECKING([if setsockopt can be linked])
2847  AC_LINK_IFELSE([
2848    AC_LANG_PROGRAM([[
2849      $cares_includes_winsock2
2850      $cares_includes_sys_socket
2851    ]],[[
2852      if(0 != setsockopt(0, 0, 0, 0, 0))
2853        return 1;
2854    ]])
2855  ],[
2856    AC_MSG_RESULT([yes])
2857    tst_links_setsockopt="yes"
2858  ],[
2859    AC_MSG_RESULT([no])
2860    tst_links_setsockopt="no"
2861  ])
2862  #
2863  if test "$tst_links_setsockopt" = "yes"; then
2864    AC_MSG_CHECKING([if setsockopt is prototyped])
2865    AC_EGREP_CPP([setsockopt],[
2866      $cares_includes_winsock2
2867      $cares_includes_sys_socket
2868    ],[
2869      AC_MSG_RESULT([yes])
2870      tst_proto_setsockopt="yes"
2871    ],[
2872      AC_MSG_RESULT([no])
2873      tst_proto_setsockopt="no"
2874    ])
2875  fi
2876  #
2877  if test "$tst_proto_setsockopt" = "yes"; then
2878    AC_MSG_CHECKING([if setsockopt is compilable])
2879    AC_COMPILE_IFELSE([
2880      AC_LANG_PROGRAM([[
2881        $cares_includes_winsock2
2882        $cares_includes_sys_socket
2883      ]],[[
2884        if(0 != setsockopt(0, 0, 0, 0, 0))
2885          return 1;
2886      ]])
2887    ],[
2888      AC_MSG_RESULT([yes])
2889      tst_compi_setsockopt="yes"
2890    ],[
2891      AC_MSG_RESULT([no])
2892      tst_compi_setsockopt="no"
2893    ])
2894  fi
2895  #
2896  if test "$tst_compi_setsockopt" = "yes"; then
2897    AC_MSG_CHECKING([if setsockopt usage allowed])
2898    if test "x$cares_disallow_setsockopt" != "xyes"; then
2899      AC_MSG_RESULT([yes])
2900      tst_allow_setsockopt="yes"
2901    else
2902      AC_MSG_RESULT([no])
2903      tst_allow_setsockopt="no"
2904    fi
2905  fi
2906  #
2907  AC_MSG_CHECKING([if setsockopt might be used])
2908  if test "$tst_links_setsockopt" = "yes" &&
2909     test "$tst_proto_setsockopt" = "yes" &&
2910     test "$tst_compi_setsockopt" = "yes" &&
2911     test "$tst_allow_setsockopt" = "yes"; then
2912    AC_MSG_RESULT([yes])
2913    AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1,
2914      [Define to 1 if you have the setsockopt function.])
2915    ac_cv_func_setsockopt="yes"
2916    CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
2917  else
2918    AC_MSG_RESULT([no])
2919    ac_cv_func_setsockopt="no"
2920  fi
2921])
2922
2923
2924dnl CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
2925dnl -------------------------------------------------
2926dnl Verify if setsockopt with the SO_NONBLOCK command is
2927dnl available, can be compiled, and seems to work. If
2928dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK
2929dnl will be defined.
2930
2931AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
2932  #
2933  tst_compi_setsockopt_so_nonblock="unknown"
2934  tst_allow_setsockopt_so_nonblock="unknown"
2935  #
2936  if test "$ac_cv_func_setsockopt" = "yes"; then
2937    AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable])
2938    AC_COMPILE_IFELSE([
2939      AC_LANG_PROGRAM([[
2940        $cares_includes_winsock2
2941        $cares_includes_sys_socket
2942      ]],[[
2943        if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
2944          return 1;
2945      ]])
2946    ],[
2947      AC_MSG_RESULT([yes])
2948      tst_compi_setsockopt_so_nonblock="yes"
2949    ],[
2950      AC_MSG_RESULT([no])
2951      tst_compi_setsockopt_so_nonblock="no"
2952    ])
2953  fi
2954  #
2955  if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then
2956    AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed])
2957    if test "x$cares_disallow_setsockopt_so_nonblock" != "xyes"; then
2958      AC_MSG_RESULT([yes])
2959      tst_allow_setsockopt_so_nonblock="yes"
2960    else
2961      AC_MSG_RESULT([no])
2962      tst_allow_setsockopt_so_nonblock="no"
2963    fi
2964  fi
2965  #
2966  AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used])
2967  if test "$tst_compi_setsockopt_so_nonblock" = "yes" &&
2968     test "$tst_allow_setsockopt_so_nonblock" = "yes"; then
2969    AC_MSG_RESULT([yes])
2970    AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1,
2971      [Define to 1 if you have a working setsockopt SO_NONBLOCK function.])
2972    ac_cv_func_setsockopt_so_nonblock="yes"
2973  else
2974    AC_MSG_RESULT([no])
2975    ac_cv_func_setsockopt_so_nonblock="no"
2976  fi
2977])
2978
2979
2980dnl CARES_CHECK_FUNC_SOCKET
2981dnl -------------------------------------------------
2982dnl Verify if socket is available, prototyped, and
2983dnl can be compiled. If all of these are true, and
2984dnl usage has not been previously disallowed with
2985dnl shell variable cares_disallow_socket, then
2986dnl HAVE_SOCKET will be defined.
2987
2988AC_DEFUN([CARES_CHECK_FUNC_SOCKET], [
2989  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
2990  AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
2991  AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
2992  #
2993  tst_links_socket="unknown"
2994  tst_proto_socket="unknown"
2995  tst_compi_socket="unknown"
2996  tst_allow_socket="unknown"
2997  #
2998  AC_MSG_CHECKING([if socket can be linked])
2999  AC_LINK_IFELSE([
3000    AC_LANG_PROGRAM([[
3001      $cares_includes_winsock2
3002      $cares_includes_sys_socket
3003      $cares_includes_socket
3004    ]],[[
3005      if(0 != socket(0, 0, 0))
3006        return 1;
3007    ]])
3008  ],[
3009    AC_MSG_RESULT([yes])
3010    tst_links_socket="yes"
3011  ],[
3012    AC_MSG_RESULT([no])
3013    tst_links_socket="no"
3014  ])
3015  #
3016  if test "$tst_links_socket" = "yes"; then
3017    AC_MSG_CHECKING([if socket is prototyped])
3018    AC_EGREP_CPP([socket],[
3019      $cares_includes_winsock2
3020      $cares_includes_sys_socket
3021      $cares_includes_socket
3022    ],[
3023      AC_MSG_RESULT([yes])
3024      tst_proto_socket="yes"
3025    ],[
3026      AC_MSG_RESULT([no])
3027      tst_proto_socket="no"
3028    ])
3029  fi
3030  #
3031  if test "$tst_proto_socket" = "yes"; then
3032    AC_MSG_CHECKING([if socket is compilable])
3033    AC_COMPILE_IFELSE([
3034      AC_LANG_PROGRAM([[
3035        $cares_includes_winsock2
3036        $cares_includes_sys_socket
3037        $cares_includes_socket
3038      ]],[[
3039        if(0 != socket(0, 0, 0))
3040          return 1;
3041      ]])
3042    ],[
3043      AC_MSG_RESULT([yes])
3044      tst_compi_socket="yes"
3045    ],[
3046      AC_MSG_RESULT([no])
3047      tst_compi_socket="no"
3048    ])
3049  fi
3050  #
3051  if test "$tst_compi_socket" = "yes"; then
3052    AC_MSG_CHECKING([if socket usage allowed])
3053    if test "x$cares_disallow_socket" != "xyes"; then
3054      AC_MSG_RESULT([yes])
3055      tst_allow_socket="yes"
3056    else
3057      AC_MSG_RESULT([no])
3058      tst_allow_socket="no"
3059    fi
3060  fi
3061  #
3062  AC_MSG_CHECKING([if socket might be used])
3063  if test "$tst_links_socket" = "yes" &&
3064     test "$tst_proto_socket" = "yes" &&
3065     test "$tst_compi_socket" = "yes" &&
3066     test "$tst_allow_socket" = "yes"; then
3067    AC_MSG_RESULT([yes])
3068    AC_DEFINE_UNQUOTED(HAVE_SOCKET, 1,
3069      [Define to 1 if you have the socket function.])
3070    ac_cv_func_socket="yes"
3071  else
3072    AC_MSG_RESULT([no])
3073    ac_cv_func_socket="no"
3074  fi
3075])
3076
3077
3078dnl CARES_CHECK_FUNC_STRCASECMP
3079dnl -------------------------------------------------
3080dnl Verify if strcasecmp is available, prototyped, and
3081dnl can be compiled. If all of these are true, and
3082dnl usage has not been previously disallowed with
3083dnl shell variable cares_disallow_strcasecmp, then
3084dnl HAVE_STRCASECMP will be defined.
3085
3086AC_DEFUN([CARES_CHECK_FUNC_STRCASECMP], [
3087  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
3088  #
3089  tst_links_strcasecmp="unknown"
3090  tst_proto_strcasecmp="unknown"
3091  tst_compi_strcasecmp="unknown"
3092  tst_allow_strcasecmp="unknown"
3093  #
3094  AC_MSG_CHECKING([if strcasecmp can be linked])
3095  AC_LINK_IFELSE([
3096    AC_LANG_FUNC_LINK_TRY([strcasecmp])
3097  ],[
3098    AC_MSG_RESULT([yes])
3099    tst_links_strcasecmp="yes"
3100  ],[
3101    AC_MSG_RESULT([no])
3102    tst_links_strcasecmp="no"
3103  ])
3104  #
3105  if test "$tst_links_strcasecmp" = "yes"; then
3106    AC_MSG_CHECKING([if strcasecmp is prototyped])
3107    AC_EGREP_CPP([strcasecmp],[
3108      $cares_includes_string
3109    ],[
3110      AC_MSG_RESULT([yes])
3111      tst_proto_strcasecmp="yes"
3112    ],[
3113      AC_MSG_RESULT([no])
3114      tst_proto_strcasecmp="no"
3115    ])
3116  fi
3117  #
3118  if test "$tst_proto_strcasecmp" = "yes"; then
3119    AC_MSG_CHECKING([if strcasecmp is compilable])
3120    AC_COMPILE_IFELSE([
3121      AC_LANG_PROGRAM([[
3122        $cares_includes_string
3123      ]],[[
3124        if(0 != strcasecmp(0, 0))
3125          return 1;
3126      ]])
3127    ],[
3128      AC_MSG_RESULT([yes])
3129      tst_compi_strcasecmp="yes"
3130    ],[
3131      AC_MSG_RESULT([no])
3132      tst_compi_strcasecmp="no"
3133    ])
3134  fi
3135  #
3136  if test "$tst_compi_strcasecmp" = "yes"; then
3137    AC_MSG_CHECKING([if strcasecmp usage allowed])
3138    if test "x$cares_disallow_strcasecmp" != "xyes"; then
3139      AC_MSG_RESULT([yes])
3140      tst_allow_strcasecmp="yes"
3141    else
3142      AC_MSG_RESULT([no])
3143      tst_allow_strcasecmp="no"
3144    fi
3145  fi
3146  #
3147  AC_MSG_CHECKING([if strcasecmp might be used])
3148  if test "$tst_links_strcasecmp" = "yes" &&
3149     test "$tst_proto_strcasecmp" = "yes" &&
3150     test "$tst_compi_strcasecmp" = "yes" &&
3151     test "$tst_allow_strcasecmp" = "yes"; then
3152    AC_MSG_RESULT([yes])
3153    AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
3154      [Define to 1 if you have the strcasecmp function.])
3155    ac_cv_func_strcasecmp="yes"
3156  else
3157    AC_MSG_RESULT([no])
3158    ac_cv_func_strcasecmp="no"
3159  fi
3160])
3161
3162
3163dnl CARES_CHECK_FUNC_STRCMPI
3164dnl -------------------------------------------------
3165dnl Verify if strcmpi is available, prototyped, and
3166dnl can be compiled. If all of these are true, and
3167dnl usage has not been previously disallowed with
3168dnl shell variable cares_disallow_strcmpi, then
3169dnl HAVE_STRCMPI will be defined.
3170
3171AC_DEFUN([CARES_CHECK_FUNC_STRCMPI], [
3172  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
3173  #
3174  tst_links_strcmpi="unknown"
3175  tst_proto_strcmpi="unknown"
3176  tst_compi_strcmpi="unknown"
3177  tst_allow_strcmpi="unknown"
3178  #
3179  AC_MSG_CHECKING([if strcmpi can be linked])
3180  AC_LINK_IFELSE([
3181    AC_LANG_FUNC_LINK_TRY([strcmpi])
3182  ],[
3183    AC_MSG_RESULT([yes])
3184    tst_links_strcmpi="yes"
3185  ],[
3186    AC_MSG_RESULT([no])
3187    tst_links_strcmpi="no"
3188  ])
3189  #
3190  if test "$tst_links_strcmpi" = "yes"; then
3191    AC_MSG_CHECKING([if strcmpi is prototyped])
3192    AC_EGREP_CPP([strcmpi],[
3193      $cares_includes_string
3194    ],[
3195      AC_MSG_RESULT([yes])
3196      tst_proto_strcmpi="yes"
3197    ],[
3198      AC_MSG_RESULT([no])
3199      tst_proto_strcmpi="no"
3200    ])
3201  fi
3202  #
3203  if test "$tst_proto_strcmpi" = "yes"; then
3204    AC_MSG_CHECKING([if strcmpi is compilable])
3205    AC_COMPILE_IFELSE([
3206      AC_LANG_PROGRAM([[
3207        $cares_includes_string
3208      ]],[[
3209        if(0 != strcmpi(0, 0))
3210          return 1;
3211      ]])
3212    ],[
3213      AC_MSG_RESULT([yes])
3214      tst_compi_strcmpi="yes"
3215    ],[
3216      AC_MSG_RESULT([no])
3217      tst_compi_strcmpi="no"
3218    ])
3219  fi
3220  #
3221  if test "$tst_compi_strcmpi" = "yes"; then
3222    AC_MSG_CHECKING([if strcmpi usage allowed])
3223    if test "x$cares_disallow_strcmpi" != "xyes"; then
3224      AC_MSG_RESULT([yes])
3225      tst_allow_strcmpi="yes"
3226    else
3227      AC_MSG_RESULT([no])
3228      tst_allow_strcmpi="no"
3229    fi
3230  fi
3231  #
3232  AC_MSG_CHECKING([if strcmpi might be used])
3233  if test "$tst_links_strcmpi" = "yes" &&
3234     test "$tst_proto_strcmpi" = "yes" &&
3235     test "$tst_compi_strcmpi" = "yes" &&
3236     test "$tst_allow_strcmpi" = "yes"; then
3237    AC_MSG_RESULT([yes])
3238    AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
3239      [Define to 1 if you have the strcmpi function.])
3240    ac_cv_func_strcmpi="yes"
3241  else
3242    AC_MSG_RESULT([no])
3243    ac_cv_func_strcmpi="no"
3244  fi
3245])
3246
3247
3248dnl CARES_CHECK_FUNC_STRDUP
3249dnl -------------------------------------------------
3250dnl Verify if strdup is available, prototyped, and
3251dnl can be compiled. If all of these are true, and
3252dnl usage has not been previously disallowed with
3253dnl shell variable cares_disallow_strdup, then
3254dnl HAVE_STRDUP will be defined.
3255
3256AC_DEFUN([CARES_CHECK_FUNC_STRDUP], [
3257  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
3258  #
3259  tst_links_strdup="unknown"
3260  tst_proto_strdup="unknown"
3261  tst_compi_strdup="unknown"
3262  tst_allow_strdup="unknown"
3263  #
3264  AC_MSG_CHECKING([if strdup can be linked])
3265  AC_LINK_IFELSE([
3266    AC_LANG_FUNC_LINK_TRY([strdup])
3267  ],[
3268    AC_MSG_RESULT([yes])
3269    tst_links_strdup="yes"
3270  ],[
3271    AC_MSG_RESULT([no])
3272    tst_links_strdup="no"
3273  ])
3274  #
3275  if test "$tst_links_strdup" = "yes"; then
3276    AC_MSG_CHECKING([if strdup is prototyped])
3277    AC_EGREP_CPP([strdup],[
3278      $cares_includes_string
3279    ],[
3280      AC_MSG_RESULT([yes])
3281      tst_proto_strdup="yes"
3282    ],[
3283      AC_MSG_RESULT([no])
3284      tst_proto_strdup="no"
3285    ])
3286  fi
3287  #
3288  if test "$tst_proto_strdup" = "yes"; then
3289    AC_MSG_CHECKING([if strdup is compilable])
3290    AC_COMPILE_IFELSE([
3291      AC_LANG_PROGRAM([[
3292        $cares_includes_string
3293      ]],[[
3294        if(0 != strdup(0))
3295          return 1;
3296      ]])
3297    ],[
3298      AC_MSG_RESULT([yes])
3299      tst_compi_strdup="yes"
3300    ],[
3301      AC_MSG_RESULT([no])
3302      tst_compi_strdup="no"
3303    ])
3304  fi
3305  #
3306  if test "$tst_compi_strdup" = "yes"; then
3307    AC_MSG_CHECKING([if strdup usage allowed])
3308    if test "x$cares_disallow_strdup" != "xyes"; then
3309      AC_MSG_RESULT([yes])
3310      tst_allow_strdup="yes"
3311    else
3312      AC_MSG_RESULT([no])
3313      tst_allow_strdup="no"
3314    fi
3315  fi
3316  #
3317  AC_MSG_CHECKING([if strdup might be used])
3318  if test "$tst_links_strdup" = "yes" &&
3319     test "$tst_proto_strdup" = "yes" &&
3320     test "$tst_compi_strdup" = "yes" &&
3321     test "$tst_allow_strdup" = "yes"; then
3322    AC_MSG_RESULT([yes])
3323    AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
3324      [Define to 1 if you have the strdup function.])
3325    ac_cv_func_strdup="yes"
3326  else
3327    AC_MSG_RESULT([no])
3328    ac_cv_func_strdup="no"
3329  fi
3330])
3331
3332
3333dnl CARES_CHECK_FUNC_STRICMP
3334dnl -------------------------------------------------
3335dnl Verify if stricmp is available, prototyped, and
3336dnl can be compiled. If all of these are true, and
3337dnl usage has not been previously disallowed with
3338dnl shell variable cares_disallow_stricmp, then
3339dnl HAVE_STRICMP will be defined.
3340
3341AC_DEFUN([CARES_CHECK_FUNC_STRICMP], [
3342  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
3343  #
3344  tst_links_stricmp="unknown"
3345  tst_proto_stricmp="unknown"
3346  tst_compi_stricmp="unknown"
3347  tst_allow_stricmp="unknown"
3348  #
3349  AC_MSG_CHECKING([if stricmp can be linked])
3350  AC_LINK_IFELSE([
3351    AC_LANG_FUNC_LINK_TRY([stricmp])
3352  ],[
3353    AC_MSG_RESULT([yes])
3354    tst_links_stricmp="yes"
3355  ],[
3356    AC_MSG_RESULT([no])
3357    tst_links_stricmp="no"
3358  ])
3359  #
3360  if test "$tst_links_stricmp" = "yes"; then
3361    AC_MSG_CHECKING([if stricmp is prototyped])
3362    AC_EGREP_CPP([stricmp],[
3363      $cares_includes_string
3364    ],[
3365      AC_MSG_RESULT([yes])
3366      tst_proto_stricmp="yes"
3367    ],[
3368      AC_MSG_RESULT([no])
3369      tst_proto_stricmp="no"
3370    ])
3371  fi
3372  #
3373  if test "$tst_proto_stricmp" = "yes"; then
3374    AC_MSG_CHECKING([if stricmp is compilable])
3375    AC_COMPILE_IFELSE([
3376      AC_LANG_PROGRAM([[
3377        $cares_includes_string
3378      ]],[[
3379        if(0 != stricmp(0, 0))
3380          return 1;
3381      ]])
3382    ],[
3383      AC_MSG_RESULT([yes])
3384      tst_compi_stricmp="yes"
3385    ],[
3386      AC_MSG_RESULT([no])
3387      tst_compi_stricmp="no"
3388    ])
3389  fi
3390  #
3391  if test "$tst_compi_stricmp" = "yes"; then
3392    AC_MSG_CHECKING([if stricmp usage allowed])
3393    if test "x$cares_disallow_stricmp" != "xyes"; then
3394      AC_MSG_RESULT([yes])
3395      tst_allow_stricmp="yes"
3396    else
3397      AC_MSG_RESULT([no])
3398      tst_allow_stricmp="no"
3399    fi
3400  fi
3401  #
3402  AC_MSG_CHECKING([if stricmp might be used])
3403  if test "$tst_links_stricmp" = "yes" &&
3404     test "$tst_proto_stricmp" = "yes" &&
3405     test "$tst_compi_stricmp" = "yes" &&
3406     test "$tst_allow_stricmp" = "yes"; then
3407    AC_MSG_RESULT([yes])
3408    AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
3409      [Define to 1 if you have the stricmp function.])
3410    ac_cv_func_stricmp="yes"
3411  else
3412    AC_MSG_RESULT([no])
3413    ac_cv_func_stricmp="no"
3414  fi
3415])
3416
3417
3418dnl CARES_CHECK_FUNC_STRNCASECMP
3419dnl -------------------------------------------------
3420dnl Verify if strncasecmp is available, prototyped, and
3421dnl can be compiled. If all of these are true, and
3422dnl usage has not been previously disallowed with
3423dnl shell variable cares_disallow_strncasecmp, then
3424dnl HAVE_STRNCASECMP will be defined.
3425
3426AC_DEFUN([CARES_CHECK_FUNC_STRNCASECMP], [
3427  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
3428  #
3429  tst_links_strncasecmp="unknown"
3430  tst_proto_strncasecmp="unknown"
3431  tst_compi_strncasecmp="unknown"
3432  tst_allow_strncasecmp="unknown"
3433  #
3434  AC_MSG_CHECKING([if strncasecmp can be linked])
3435  AC_LINK_IFELSE([
3436    AC_LANG_FUNC_LINK_TRY([strncasecmp])
3437  ],[
3438    AC_MSG_RESULT([yes])
3439    tst_links_strncasecmp="yes"
3440  ],[
3441    AC_MSG_RESULT([no])
3442    tst_links_strncasecmp="no"
3443  ])
3444  #
3445  if test "$tst_links_strncasecmp" = "yes"; then
3446    AC_MSG_CHECKING([if strncasecmp is prototyped])
3447    AC_EGREP_CPP([strncasecmp],[
3448      $cares_includes_string
3449    ],[
3450      AC_MSG_RESULT([yes])
3451      tst_proto_strncasecmp="yes"
3452    ],[
3453      AC_MSG_RESULT([no])
3454      tst_proto_strncasecmp="no"
3455    ])
3456  fi
3457  #
3458  if test "$tst_proto_strncasecmp" = "yes"; then
3459    AC_MSG_CHECKING([if strncasecmp is compilable])
3460    AC_COMPILE_IFELSE([
3461      AC_LANG_PROGRAM([[
3462        $cares_includes_string
3463      ]],[[
3464        if(0 != strncasecmp(0, 0, 0))
3465          return 1;
3466      ]])
3467    ],[
3468      AC_MSG_RESULT([yes])
3469      tst_compi_strncasecmp="yes"
3470    ],[
3471      AC_MSG_RESULT([no])
3472      tst_compi_strncasecmp="no"
3473    ])
3474  fi
3475  #
3476  if test "$tst_compi_strncasecmp" = "yes"; then
3477    AC_MSG_CHECKING([if strncasecmp usage allowed])
3478    if test "x$cares_disallow_strncasecmp" != "xyes"; then
3479      AC_MSG_RESULT([yes])
3480      tst_allow_strncasecmp="yes"
3481    else
3482      AC_MSG_RESULT([no])
3483      tst_allow_strncasecmp="no"
3484    fi
3485  fi
3486  #
3487  AC_MSG_CHECKING([if strncasecmp might be used])
3488  if test "$tst_links_strncasecmp" = "yes" &&
3489     test "$tst_proto_strncasecmp" = "yes" &&
3490     test "$tst_compi_strncasecmp" = "yes" &&
3491     test "$tst_allow_strncasecmp" = "yes"; then
3492    AC_MSG_RESULT([yes])
3493    AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
3494      [Define to 1 if you have the strncasecmp function.])
3495    ac_cv_func_strncasecmp="yes"
3496  else
3497    AC_MSG_RESULT([no])
3498    ac_cv_func_strncasecmp="no"
3499  fi
3500])
3501
3502
3503dnl CARES_CHECK_FUNC_STRNCMPI
3504dnl -------------------------------------------------
3505dnl Verify if strncmpi is available, prototyped, and
3506dnl can be compiled. If all of these are true, and
3507dnl usage has not been previously disallowed with
3508dnl shell variable cares_disallow_strncmpi, then
3509dnl HAVE_STRNCMPI will be defined.
3510
3511AC_DEFUN([CARES_CHECK_FUNC_STRNCMPI], [
3512  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
3513  #
3514  tst_links_strncmpi="unknown"
3515  tst_proto_strncmpi="unknown"
3516  tst_compi_strncmpi="unknown"
3517  tst_allow_strncmpi="unknown"
3518  #
3519  AC_MSG_CHECKING([if strncmpi can be linked])
3520  AC_LINK_IFELSE([
3521    AC_LANG_FUNC_LINK_TRY([strncmpi])
3522  ],[
3523    AC_MSG_RESULT([yes])
3524    tst_links_strncmpi="yes"
3525  ],[
3526    AC_MSG_RESULT([no])
3527    tst_links_strncmpi="no"
3528  ])
3529  #
3530  if test "$tst_links_strncmpi" = "yes"; then
3531    AC_MSG_CHECKING([if strncmpi is prototyped])
3532    AC_EGREP_CPP([strncmpi],[
3533      $cares_includes_string
3534    ],[
3535      AC_MSG_RESULT([yes])
3536      tst_proto_strncmpi="yes"
3537    ],[
3538      AC_MSG_RESULT([no])
3539      tst_proto_strncmpi="no"
3540    ])
3541  fi
3542  #
3543  if test "$tst_proto_strncmpi" = "yes"; then
3544    AC_MSG_CHECKING([if strncmpi is compilable])
3545    AC_COMPILE_IFELSE([
3546      AC_LANG_PROGRAM([[
3547        $cares_includes_string
3548      ]],[[
3549        if(0 != strncmpi(0, 0))
3550          return 1;
3551      ]])
3552    ],[
3553      AC_MSG_RESULT([yes])
3554      tst_compi_strncmpi="yes"
3555    ],[
3556      AC_MSG_RESULT([no])
3557      tst_compi_strncmpi="no"
3558    ])
3559  fi
3560  #
3561  if test "$tst_compi_strncmpi" = "yes"; then
3562    AC_MSG_CHECKING([if strncmpi usage allowed])
3563    if test "x$cares_disallow_strncmpi" != "xyes"; then
3564      AC_MSG_RESULT([yes])
3565      tst_allow_strncmpi="yes"
3566    else
3567      AC_MSG_RESULT([no])
3568      tst_allow_strncmpi="no"
3569    fi
3570  fi
3571  #
3572  AC_MSG_CHECKING([if strncmpi might be used])
3573  if test "$tst_links_strncmpi" = "yes" &&
3574     test "$tst_proto_strncmpi" = "yes" &&
3575     test "$tst_compi_strncmpi" = "yes" &&
3576     test "$tst_allow_strncmpi" = "yes"; then
3577    AC_MSG_RESULT([yes])
3578    AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
3579      [Define to 1 if you have the strncmpi function.])
3580    ac_cv_func_strncmpi="yes"
3581  else
3582    AC_MSG_RESULT([no])
3583    ac_cv_func_strncmpi="no"
3584  fi
3585])
3586
3587
3588dnl CARES_CHECK_FUNC_STRNICMP
3589dnl -------------------------------------------------
3590dnl Verify if strnicmp is available, prototyped, and
3591dnl can be compiled. If all of these are true, and
3592dnl usage has not been previously disallowed with
3593dnl shell variable cares_disallow_strnicmp, then
3594dnl HAVE_STRNICMP will be defined.
3595
3596AC_DEFUN([CARES_CHECK_FUNC_STRNICMP], [
3597  AC_REQUIRE([CARES_INCLUDES_STRING])dnl
3598  #
3599  tst_links_strnicmp="unknown"
3600  tst_proto_strnicmp="unknown"
3601  tst_compi_strnicmp="unknown"
3602  tst_allow_strnicmp="unknown"
3603  #
3604  AC_MSG_CHECKING([if strnicmp can be linked])
3605  AC_LINK_IFELSE([
3606    AC_LANG_FUNC_LINK_TRY([strnicmp])
3607  ],[
3608    AC_MSG_RESULT([yes])
3609    tst_links_strnicmp="yes"
3610  ],[
3611    AC_MSG_RESULT([no])
3612    tst_links_strnicmp="no"
3613  ])
3614  #
3615  if test "$tst_links_strnicmp" = "yes"; then
3616    AC_MSG_CHECKING([if strnicmp is prototyped])
3617    AC_EGREP_CPP([strnicmp],[
3618      $cares_includes_string
3619    ],[
3620      AC_MSG_RESULT([yes])
3621      tst_proto_strnicmp="yes"
3622    ],[
3623      AC_MSG_RESULT([no])
3624      tst_proto_strnicmp="no"
3625    ])
3626  fi
3627  #
3628  if test "$tst_proto_strnicmp" = "yes"; then
3629    AC_MSG_CHECKING([if strnicmp is compilable])
3630    AC_COMPILE_IFELSE([
3631      AC_LANG_PROGRAM([[
3632        $cares_includes_string
3633      ]],[[
3634        if(0 != strnicmp(0, 0))
3635          return 1;
3636      ]])
3637    ],[
3638      AC_MSG_RESULT([yes])
3639      tst_compi_strnicmp="yes"
3640    ],[
3641      AC_MSG_RESULT([no])
3642      tst_compi_strnicmp="no"
3643    ])
3644  fi
3645  #
3646  if test "$tst_compi_strnicmp" = "yes"; then
3647    AC_MSG_CHECKING([if strnicmp usage allowed])
3648    if test "x$cares_disallow_strnicmp" != "xyes"; then
3649      AC_MSG_RESULT([yes])
3650      tst_allow_strnicmp="yes"
3651    else
3652      AC_MSG_RESULT([no])
3653      tst_allow_strnicmp="no"
3654    fi
3655  fi
3656  #
3657  AC_MSG_CHECKING([if strnicmp might be used])
3658  if test "$tst_links_strnicmp" = "yes" &&
3659     test "$tst_proto_strnicmp" = "yes" &&
3660     test "$tst_compi_strnicmp" = "yes" &&
3661     test "$tst_allow_strnicmp" = "yes"; then
3662    AC_MSG_RESULT([yes])
3663    AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
3664      [Define to 1 if you have the strnicmp function.])
3665    ac_cv_func_strnicmp="yes"
3666  else
3667    AC_MSG_RESULT([no])
3668    ac_cv_func_strnicmp="no"
3669  fi
3670])
3671
3672
3673dnl CARES_CHECK_FUNC_WRITEV
3674dnl -------------------------------------------------
3675dnl Verify if writev is available, prototyped, and
3676dnl can be compiled. If all of these are true, and
3677dnl usage has not been previously disallowed with
3678dnl shell variable cares_disallow_writev, then
3679dnl HAVE_WRITEV will be defined.
3680
3681AC_DEFUN([CARES_CHECK_FUNC_WRITEV], [
3682  AC_REQUIRE([CARES_INCLUDES_SYS_UIO])dnl
3683  #
3684  tst_links_writev="unknown"
3685  tst_proto_writev="unknown"
3686  tst_compi_writev="unknown"
3687  tst_allow_writev="unknown"
3688  #
3689  AC_MSG_CHECKING([if writev can be linked])
3690  AC_LINK_IFELSE([
3691    AC_LANG_FUNC_LINK_TRY([writev])
3692  ],[
3693    AC_MSG_RESULT([yes])
3694    tst_links_writev="yes"
3695  ],[
3696    AC_MSG_RESULT([no])
3697    tst_links_writev="no"
3698  ])
3699  #
3700  if test "$tst_links_writev" = "yes"; then
3701    AC_MSG_CHECKING([if writev is prototyped])
3702    AC_EGREP_CPP([writev],[
3703      $cares_includes_sys_uio
3704    ],[
3705      AC_MSG_RESULT([yes])
3706      tst_proto_writev="yes"
3707    ],[
3708      AC_MSG_RESULT([no])
3709      tst_proto_writev="no"
3710    ])
3711  fi
3712  #
3713  if test "$tst_proto_writev" = "yes"; then
3714    AC_MSG_CHECKING([if writev is compilable])
3715    AC_COMPILE_IFELSE([
3716      AC_LANG_PROGRAM([[
3717        $cares_includes_sys_uio
3718      ]],[[
3719        if(0 != writev(0, 0, 0))
3720          return 1;
3721      ]])
3722    ],[
3723      AC_MSG_RESULT([yes])
3724      tst_compi_writev="yes"
3725    ],[
3726      AC_MSG_RESULT([no])
3727      tst_compi_writev="no"
3728    ])
3729  fi
3730  #
3731  if test "$tst_compi_writev" = "yes"; then
3732    AC_MSG_CHECKING([if writev usage allowed])
3733    if test "x$cares_disallow_writev" != "xyes"; then
3734      AC_MSG_RESULT([yes])
3735      tst_allow_writev="yes"
3736    else
3737      AC_MSG_RESULT([no])
3738      tst_allow_writev="no"
3739    fi
3740  fi
3741  #
3742  AC_MSG_CHECKING([if writev might be used])
3743  if test "$tst_links_writev" = "yes" &&
3744     test "$tst_proto_writev" = "yes" &&
3745     test "$tst_compi_writev" = "yes" &&
3746     test "$tst_allow_writev" = "yes"; then
3747    AC_MSG_RESULT([yes])
3748    AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
3749      [Define to 1 if you have the writev function.])
3750    ac_cv_func_writev="yes"
3751  else
3752    AC_MSG_RESULT([no])
3753    ac_cv_func_writev="no"
3754  fi
3755])
3756