Refactor configure script detection of functions used to set sockets into
[platform/upstream/curl.git] / ares / m4 / cares-functions.m4
1 #***************************************************************************
2 # $Id$
3 #
4 # Copyright (C) 2008 by Daniel Stenberg et al
5 #
6 # Permission to use, copy, modify, and distribute this software and its
7 # documentation for any purpose and without fee is hereby granted, provided
8 # that the above copyright notice appear in all copies and that both that
9 # copyright notice and this permission notice appear in supporting
10 # documentation, and that the name of M.I.T. not be used in advertising or
11 # publicity pertaining to distribution of the software without specific,
12 # written prior permission.  M.I.T. makes no representations about the
13 # suitability of this software for any purpose.  It is provided "as is"
14 # without express or implied warranty.
15 #
16 #***************************************************************************
17
18 # File version for 'aclocal' use. Keep it a single number.
19 # serial 19
20
21
22 dnl CARES_INCLUDES_ARPA_INET
23 dnl -------------------------------------------------
24 dnl Set up variable with list of headers that must be
25 dnl included when arpa/inet.h is to be included.
26
27 AC_DEFUN([CARES_INCLUDES_ARPA_INET], [
28 cares_includes_arpa_inet="\
29 /* includes start */
30 #ifdef HAVE_SYS_TYPES_H
31 #  include <sys/types.h>
32 #endif
33 #ifdef HAVE_SYS_SOCKET_H
34 #  include <sys/socket.h>
35 #endif
36 #ifdef HAVE_NETINET_IN_H
37 #  include <netinet/in.h>
38 #endif
39 #ifdef HAVE_ARPA_INET_H
40 #  include <arpa_inet.h>
41 #endif
42 /* includes end */"
43   AC_CHECK_HEADERS(
44     sys/types.h sys/socket.h netinet/in.h arpa/inet.h,
45     [], [], [$cares_includes_arpa_inet])
46 ])
47
48
49 dnl CARES_INCLUDES_FCNTL
50 dnl -------------------------------------------------
51 dnl Set up variable with list of headers that must be
52 dnl included when fcntl.h is to be included.
53
54 AC_DEFUN([CARES_INCLUDES_FCNTL], [
55 cares_includes_fcntl="\
56 /* includes start */
57 #ifdef HAVE_SYS_TYPES_H
58 #  include <sys/types.h>
59 #endif
60 #ifdef HAVE_UNISTD_H
61 #  include <unistd.h>
62 #endif
63 #ifdef HAVE_STROPTS_H
64 #  include <fcntl.h>
65 #endif
66 /* includes end */"
67   AC_CHECK_HEADERS(
68     sys/types.h unistd.h fcntl.h,
69     [], [], [$cares_includes_fcntl])
70 ])
71
72
73 dnl CARES_INCLUDES_NETDB
74 dnl -------------------------------------------------
75 dnl Set up variable with list of headers that must be
76 dnl included when netdb.h is to be included.
77
78 AC_DEFUN([CARES_INCLUDES_NETDB], [
79 cares_includes_netdb="\
80 /* includes start */
81 #ifdef HAVE_SYS_TYPES_H
82 #  include <sys/types.h>
83 #endif
84 #ifdef HAVE_NETDB_H
85 #  include <netdb.h>
86 #endif
87 /* includes end */"
88   AC_CHECK_HEADERS(
89     sys/types.h netdb.h,
90     [], [], [$cares_includes_netdb])
91 ])
92
93
94 dnl CARES_INCLUDES_STDLIB
95 dnl -------------------------------------------------
96 dnl Set up variable with list of headers that must be
97 dnl included when stdlib.h is to be included.
98
99 AC_DEFUN([CARES_INCLUDES_STDLIB], [
100 cares_includes_stdlib="\
101 /* includes start */
102 #ifdef HAVE_SYS_TYPES_H
103 #  include <sys/types.h>
104 #endif
105 #ifdef HAVE_STDLIB_H
106 #  include <stdlib.h>
107 #endif
108 /* includes end */"
109   AC_CHECK_HEADERS(
110     sys/types.h stdlib.h,
111     [], [], [$cares_includes_stdlib])
112 ])
113
114
115 dnl CARES_INCLUDES_STRING
116 dnl -------------------------------------------------
117 dnl Set up variable with list of headers that must be
118 dnl included when string(s).h is to be included.
119
120 AC_DEFUN([CARES_INCLUDES_STRING], [
121 cares_includes_string="\
122 /* includes start */
123 #ifdef HAVE_SYS_TYPES_H
124 #  include <sys/types.h>
125 #endif
126 #ifdef HAVE_STRING_H
127 #  include <string.h>
128 #endif
129 #ifdef HAVE_STRINGS_H
130 #  include <strings.h>
131 #endif
132 /* includes end */"
133   AC_CHECK_HEADERS(
134     sys/types.h string.h strings.h,
135     [], [], [$cares_includes_string])
136 ])
137
138
139 dnl CARES_INCLUDES_STROPTS
140 dnl -------------------------------------------------
141 dnl Set up variable with list of headers that must be
142 dnl included when stropts.h is to be included.
143
144 AC_DEFUN([CARES_INCLUDES_STROPTS], [
145 cares_includes_stropts="\
146 /* includes start */
147 #ifdef HAVE_SYS_TYPES_H
148 #  include <sys/types.h>
149 #endif
150 #ifdef HAVE_UNISTD_H
151 #  include <unistd.h>
152 #endif
153 #ifdef HAVE_SYS_SOCKET_H
154 #  include <sys/socket.h>
155 #endif
156 #ifdef HAVE_SYS_IOCTL_H
157 #  include <sys/ioctl.h>
158 #endif
159 #ifdef HAVE_STROPTS_H
160 #  include <stropts.h>
161 #endif
162 /* includes end */"
163   AC_CHECK_HEADERS(
164     sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
165     [], [], [$cares_includes_stropts])
166 ])
167
168
169 dnl CARES_INCLUDES_SYS_SOCKET
170 dnl -------------------------------------------------
171 dnl Set up variable with list of headers that must be
172 dnl included when sys/socket.h is to be included.
173
174 AC_DEFUN([CARES_INCLUDES_SYS_SOCKET], [
175 cares_includes_sys_socket="\
176 /* includes start */
177 #ifdef HAVE_SYS_TYPES_H
178 #  include <sys/types.h>
179 #endif
180 #ifdef HAVE_SYS_SOCKET_H
181 #  include <sys/socket.h>
182 #endif
183 /* includes end */"
184   AC_CHECK_HEADERS(
185     sys/types.h sys/socket.h,
186     [], [], [$cares_includes_sys_socket])
187 ])
188
189
190 dnl CARES_INCLUDES_SYS_UIO
191 dnl -------------------------------------------------
192 dnl Set up variable with list of headers that must be
193 dnl included when sys/uio.h is to be included.
194
195 AC_DEFUN([CARES_INCLUDES_SYS_UIO], [
196 cares_includes_sys_uio="\
197 /* includes start */
198 #ifdef HAVE_SYS_TYPES_H
199 #  include <sys/types.h>
200 #endif
201 #ifdef HAVE_SYS_UIO_H
202 #  include <sys/uio.h>
203 #endif
204 /* includes end */"
205   AC_CHECK_HEADERS(
206     sys/types.h sys/uio.h,
207     [], [], [$cares_includes_sys_uio])
208 ])
209
210
211 dnl CARES_INCLUDES_UNISTD
212 dnl -------------------------------------------------
213 dnl Set up variable with list of headers that must be
214 dnl included when unistd.h is to be included.
215
216 AC_DEFUN([CARES_INCLUDES_UNISTD], [
217 cares_includes_unistd="\
218 /* includes start */
219 #ifdef HAVE_SYS_TYPES_H
220 #  include <sys/types.h>
221 #endif
222 #ifdef HAVE_UNISTD_H
223 #  include <unistd.h>
224 #endif
225 /* includes end */"
226   AC_CHECK_HEADERS(
227     sys/types.h unistd.h,
228     [], [], [$cares_includes_unistd])
229 ])
230
231
232 dnl CARES_INCLUDES_WINSOCK2
233 dnl -------------------------------------------------
234 dnl Set up variable with list of headers that must be
235 dnl included when winsock(2).h is to be included.
236
237 AC_DEFUN([CARES_INCLUDES_WINSOCK2], [
238 cares_includes_winsock2="\
239 /* includes start */
240 #ifdef HAVE_WINDOWS_H
241 #  ifndef WIN32_LEAN_AND_MEAN
242 #    define WIN32_LEAN_AND_MEAN
243 #  endif
244 #  include <windows.h>
245 #  ifdef HAVE_WINSOCK2_H
246 #    include <winsock2.h>
247 #  else
248 #    ifdef HAVE_WINSOCK_H
249 #      include <winsock.h>
250 #    endif
251 #  endif
252 #endif
253 /* includes end */"
254   CURL_CHECK_HEADER_WINDOWS
255   CURL_CHECK_HEADER_WINSOCK
256   CURL_CHECK_HEADER_WINSOCK2
257 ])
258
259
260 dnl CARES_INCLUDES_WS2TCPIP
261 dnl -------------------------------------------------
262 dnl Set up variable with list of headers that must be
263 dnl included when ws2tcpip.h is to be included.
264
265 AC_DEFUN([CARES_INCLUDES_WS2TCPIP], [
266 cares_includes_ws2tcpip="\
267 /* includes start */
268 #ifdef HAVE_WINDOWS_H
269 #  ifndef WIN32_LEAN_AND_MEAN
270 #    define WIN32_LEAN_AND_MEAN
271 #  endif
272 #  include <windows.h>
273 #  ifdef HAVE_WINSOCK2_H
274 #    include <winsock2.h>
275 #    ifdef HAVE_WS2TCPIP_H
276 #       include <ws2tcpip.h>
277 #    endif
278 #  endif
279 #endif
280 /* includes end */"
281   CURL_CHECK_HEADER_WINDOWS
282   CURL_CHECK_HEADER_WINSOCK2
283   CURL_CHECK_HEADER_WS2TCPIP
284 ])
285
286
287 dnl CARES_CHECK_FUNC_FCNTL
288 dnl -------------------------------------------------
289 dnl Verify if fcntl is available, prototyped, and
290 dnl can be compiled. If all of these are true, and
291 dnl usage has not been previously disallowed with
292 dnl shell variable cares_disallow_fcntl, then
293 dnl HAVE_FCNTL will be defined.
294
295 AC_DEFUN([CARES_CHECK_FUNC_FCNTL], [
296   AC_REQUIRE([CARES_INCLUDES_FCNTL])dnl
297   #
298   tst_links_fcntl="unknown"
299   tst_proto_fcntl="unknown"
300   tst_compi_fcntl="unknown"
301   tst_allow_fcntl="unknown"
302   #
303   AC_MSG_CHECKING([if fcntl can be linked])
304   AC_LINK_IFELSE([
305     AC_LANG_FUNC_LINK_TRY([fcntl])
306   ],[
307     AC_MSG_RESULT([yes])
308     tst_links_fcntl="yes"
309   ],[
310     AC_MSG_RESULT([no])
311     tst_links_fcntl="no"
312   ])
313   #
314   if test "$tst_links_fcntl" = "yes"; then
315     AC_MSG_CHECKING([if fcntl is prototyped])
316     AC_EGREP_CPP([fcntl],[
317       $cares_includes_fcntl
318     ],[
319       AC_MSG_RESULT([yes])
320       tst_proto_fcntl="yes"
321     ],[
322       AC_MSG_RESULT([no])
323       tst_proto_fcntl="no"
324     ])
325   fi
326   #
327   if test "$tst_proto_fcntl" = "yes"; then
328     AC_MSG_CHECKING([if fcntl is compilable])
329     AC_COMPILE_IFELSE([
330       AC_LANG_PROGRAM([[
331         $cares_includes_fcntl
332       ]],[[
333         if(0 != fcntl(0, 0, 0))
334           return 1;
335       ]])
336     ],[
337       AC_MSG_RESULT([yes])
338       tst_compi_fcntl="yes"
339     ],[
340       AC_MSG_RESULT([no])
341       tst_compi_fcntl="no"
342     ])
343   fi
344   #
345   if test "$tst_compi_fcntl" = "yes"; then
346     AC_MSG_CHECKING([if fcntl usage allowed])
347     if test "x$cares_disallow_fcntl" != "xyes"; then
348       AC_MSG_RESULT([yes])
349       tst_allow_fcntl="yes"
350     else
351       AC_MSG_RESULT([no])
352       tst_allow_fcntl="no"
353     fi
354   fi
355   #
356   AC_MSG_CHECKING([if fcntl might be used])
357   if test "$tst_links_fcntl" = "yes" &&
358      test "$tst_proto_fcntl" = "yes" &&
359      test "$tst_compi_fcntl" = "yes" &&
360      test "$tst_allow_fcntl" = "yes"; then
361     AC_MSG_RESULT([yes])
362     AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
363       [Define to 1 if you have the fcntl function.])
364     ac_cv_func_fcntl="yes"
365     CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
366   else
367     AC_MSG_RESULT([no])
368     ac_cv_func_fcntl="no"
369   fi
370 ])
371
372
373 dnl CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
374 dnl -------------------------------------------------
375 dnl Verify if fcntl with status flag O_NONBLOCK is
376 dnl available, can be compiled, and seems to work. If
377 dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
378 dnl will be defined.
379
380 AC_DEFUN([CARES_CHECK_FUNC_FCNTL_O_NONBLOCK], [
381   #
382   tst_compi_fcntl_o_nonblock="unknown"
383   tst_allow_fcntl_o_nonblock="unknown"
384   #
385   case $host_os in
386     sunos4* | aix3* | beos*)
387       dnl O_NONBLOCK does not work on these platforms
388       cares_disallow_fcntl_o_nonblock="yes"
389       ;;
390   esac
391   #
392   if test "$ac_cv_func_fcntl" = "yes"; then
393     AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
394     AC_COMPILE_IFELSE([
395       AC_LANG_PROGRAM([[
396         $cares_includes_fcntl
397       ]],[[
398         int flags = 0;
399         if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
400           return 1;
401       ]])
402     ],[
403       AC_MSG_RESULT([yes])
404       tst_compi_fcntl_o_nonblock="yes"
405     ],[
406       AC_MSG_RESULT([no])
407       tst_compi_fcntl_o_nonblock="no"
408     ])
409   fi
410   #
411   if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
412     AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
413     if test "x$cares_disallow_fcntl_o_nonblock" != "xyes"; then
414       AC_MSG_RESULT([yes])
415       tst_allow_fcntl_o_nonblock="yes"
416     else
417       AC_MSG_RESULT([no])
418       tst_allow_fcntl_o_nonblock="no"
419     fi
420   fi
421   #
422   AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
423   if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
424      test "$tst_allow_fcntl_o_nonblock" = "yes"; then
425     AC_MSG_RESULT([yes])
426     AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
427       [Define to 1 if you have a working fcntl O_NONBLOCK function.])
428     ac_cv_func_fcntl_o_nonblock="yes"
429   else
430     AC_MSG_RESULT([no])
431     ac_cv_func_fcntl_o_nonblock="no"
432   fi
433 ])
434
435
436 dnl CARES_CHECK_FUNC_FREEADDRINFO
437 dnl -------------------------------------------------
438 dnl Verify if freeaddrinfo is available, prototyped,
439 dnl and can be compiled. If all of these are true,
440 dnl and usage has not been previously disallowed with
441 dnl shell variable cares_disallow_freeaddrinfo, then
442 dnl HAVE_FREEADDRINFO will be defined.
443
444 AC_DEFUN([CARES_CHECK_FUNC_FREEADDRINFO], [
445   AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
446   AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
447   AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
448   #
449   tst_links_freeaddrinfo="unknown"
450   tst_proto_freeaddrinfo="unknown"
451   tst_compi_freeaddrinfo="unknown"
452   tst_allow_freeaddrinfo="unknown"
453   #
454   AC_MSG_CHECKING([if freeaddrinfo can be linked])
455   AC_LINK_IFELSE([
456     AC_LANG_PROGRAM([[
457       $cares_includes_ws2tcpip
458       $cares_includes_sys_socket
459       $cares_includes_netdb
460     ]],[[
461       freeaddrinfo(0);
462     ]])
463   ],[
464     AC_MSG_RESULT([yes])
465     tst_links_freeaddrinfo="yes"
466   ],[
467     AC_MSG_RESULT([no])
468     tst_links_freeaddrinfo="no"
469   ])
470   #
471   if test "$tst_links_freeaddrinfo" = "yes"; then
472     AC_MSG_CHECKING([if freeaddrinfo is prototyped])
473     AC_EGREP_CPP([freeaddrinfo],[
474       $cares_includes_ws2tcpip
475       $cares_includes_sys_socket
476       $cares_includes_netdb
477     ],[
478       AC_MSG_RESULT([yes])
479       tst_proto_freeaddrinfo="yes"
480     ],[
481       AC_MSG_RESULT([no])
482       tst_proto_freeaddrinfo="no"
483     ])
484   fi
485   #
486   if test "$tst_proto_freeaddrinfo" = "yes"; then
487     AC_MSG_CHECKING([if freeaddrinfo is compilable])
488     AC_COMPILE_IFELSE([
489       AC_LANG_PROGRAM([[
490         $cares_includes_ws2tcpip
491         $cares_includes_sys_socket
492         $cares_includes_netdb
493       ]],[[
494         freeaddrinfo(0);
495       ]])
496     ],[
497       AC_MSG_RESULT([yes])
498       tst_compi_freeaddrinfo="yes"
499     ],[
500       AC_MSG_RESULT([no])
501       tst_compi_freeaddrinfo="no"
502     ])
503   fi
504   #
505   if test "$tst_compi_freeaddrinfo" = "yes"; then
506     AC_MSG_CHECKING([if freeaddrinfo usage allowed])
507     if test "x$cares_disallow_freeaddrinfo" != "xyes"; then
508       AC_MSG_RESULT([yes])
509       tst_allow_freeaddrinfo="yes"
510     else
511       AC_MSG_RESULT([no])
512       tst_allow_freeaddrinfo="no"
513     fi
514   fi
515   #
516   AC_MSG_CHECKING([if freeaddrinfo might be used])
517   if test "$tst_links_freeaddrinfo" = "yes" &&
518      test "$tst_proto_freeaddrinfo" = "yes" &&
519      test "$tst_compi_freeaddrinfo" = "yes" &&
520      test "$tst_allow_freeaddrinfo" = "yes"; then
521     AC_MSG_RESULT([yes])
522     AC_DEFINE_UNQUOTED(HAVE_FREEADDRINFO, 1,
523       [Define to 1 if you have the freeaddrinfo function.])
524     ac_cv_func_freeaddrinfo="yes"
525   else
526     AC_MSG_RESULT([no])
527     ac_cv_func_freeaddrinfo="no"
528   fi
529 ])
530
531
532 dnl CARES_CHECK_FUNC_GETADDRINFO
533 dnl -------------------------------------------------
534 dnl Verify if getaddrinfo is available, prototyped, can
535 dnl be compiled and seems to work. If all of these are
536 dnl true, and usage has not been previously disallowed
537 dnl with shell variable cares_disallow_getaddrinfo, then
538 dnl HAVE_GETADDRINFO will be defined.
539
540 AC_DEFUN([CARES_CHECK_FUNC_GETADDRINFO], [
541   AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
542   AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
543   AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
544   AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
545   #
546   tst_links_getaddrinfo="unknown"
547   tst_proto_getaddrinfo="unknown"
548   tst_compi_getaddrinfo="unknown"
549   tst_works_getaddrinfo="unknown"
550   tst_allow_getaddrinfo="unknown"
551   #
552   AC_MSG_CHECKING([if getaddrinfo can be linked])
553   AC_LINK_IFELSE([
554     AC_LANG_PROGRAM([[
555       $cares_includes_ws2tcpip
556       $cares_includes_sys_socket
557       $cares_includes_netdb
558     ]],[[
559       if(0 != getaddrinfo(0, 0, 0, 0))
560         return 1;
561     ]])
562   ],[
563     AC_MSG_RESULT([yes])
564     tst_links_getaddrinfo="yes"
565   ],[
566     AC_MSG_RESULT([no])
567     tst_links_getaddrinfo="no"
568   ])
569   #
570   if test "$tst_links_getaddrinfo" = "yes"; then
571     AC_MSG_CHECKING([if getaddrinfo is prototyped])
572     AC_EGREP_CPP([getaddrinfo],[
573       $cares_includes_ws2tcpip
574       $cares_includes_sys_socket
575       $cares_includes_netdb
576     ],[
577       AC_MSG_RESULT([yes])
578       tst_proto_getaddrinfo="yes"
579     ],[
580       AC_MSG_RESULT([no])
581       tst_proto_getaddrinfo="no"
582     ])
583   fi
584   #
585   if test "$tst_proto_getaddrinfo" = "yes"; then
586     AC_MSG_CHECKING([if getaddrinfo is compilable])
587     AC_COMPILE_IFELSE([
588       AC_LANG_PROGRAM([[
589         $cares_includes_ws2tcpip
590         $cares_includes_sys_socket
591         $cares_includes_netdb
592       ]],[[
593         if(0 != getaddrinfo(0, 0, 0, 0))
594           return 1;
595       ]])
596     ],[
597       AC_MSG_RESULT([yes])
598       tst_compi_getaddrinfo="yes"
599     ],[
600       AC_MSG_RESULT([no])
601       tst_compi_getaddrinfo="no"
602     ])
603   fi
604   #
605   dnl only do runtime verification when not cross-compiling
606   if test "x$cross_compiling" != "xyes" &&
607     test "$tst_compi_getaddrinfo" = "yes"; then
608     AC_MSG_CHECKING([if getaddrinfo seems to work])
609     AC_RUN_IFELSE([
610       AC_LANG_PROGRAM([[
611         $cares_includes_ws2tcpip
612         $cares_includes_stdlib
613         $cares_includes_sys_socket
614         $cares_includes_netdb
615       ]],[[
616         struct addrinfo hints;
617         struct addrinfo *ai = 0;
618         int error;
619
620         memset(&hints, 0, sizeof(hints));
621         hints.ai_flags = AI_NUMERICHOST;
622         hints.ai_family = AF_UNSPEC;
623         hints.ai_socktype = SOCK_STREAM;
624         error = getaddrinfo("127.0.0.1", 0, &hints, &ai);
625         if(error || !ai)
626           exit(1); /* fail */
627         else
628           exit(0);
629       ]])
630     ],[
631       AC_MSG_RESULT([yes])
632       tst_works_getaddrinfo="yes"
633     ],[
634       AC_MSG_RESULT([no])
635       tst_works_getaddrinfo="no"
636     ])
637   fi
638   #
639   if test "$tst_compi_getaddrinfo" = "yes" &&
640     test "$tst_works_getaddrinfo" != "no"; then
641     AC_MSG_CHECKING([if getaddrinfo usage allowed])
642     if test "x$cares_disallow_getaddrinfo" != "xyes"; then
643       AC_MSG_RESULT([yes])
644       tst_allow_getaddrinfo="yes"
645     else
646       AC_MSG_RESULT([no])
647       tst_allow_getaddrinfo="no"
648     fi
649   fi
650   #
651   AC_MSG_CHECKING([if getaddrinfo might be used])
652   if test "$tst_links_getaddrinfo" = "yes" &&
653      test "$tst_proto_getaddrinfo" = "yes" &&
654      test "$tst_compi_getaddrinfo" = "yes" &&
655      test "$tst_allow_getaddrinfo" = "yes" &&
656      test "$tst_works_getaddrinfo" != "no"; then
657     AC_MSG_RESULT([yes])
658     AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO, 1,
659       [Define to 1 if you have a working getaddrinfo function.])
660     ac_cv_func_getaddrinfo="yes"
661   else
662     AC_MSG_RESULT([no])
663     ac_cv_func_getaddrinfo="no"
664   fi
665 ])
666
667
668 dnl CARES_CHECK_FUNC_GETHOSTNAME
669 dnl -------------------------------------------------
670 dnl Verify if gethostname is available, prototyped, and
671 dnl can be compiled. If all of these are true, and
672 dnl usage has not been previously disallowed with
673 dnl shell variable cares_disallow_gethostname, then
674 dnl HAVE_GETHOSTNAME will be defined.
675
676 AC_DEFUN([CARES_CHECK_FUNC_GETHOSTNAME], [
677   AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
678   AC_REQUIRE([CARES_INCLUDES_UNISTD])dnl
679   #
680   tst_links_gethostname="unknown"
681   tst_proto_gethostname="unknown"
682   tst_compi_gethostname="unknown"
683   tst_allow_gethostname="unknown"
684   #
685   AC_MSG_CHECKING([if gethostname can be linked])
686   AC_LINK_IFELSE([
687     AC_LANG_PROGRAM([[
688       $cares_includes_winsock2
689       $cares_includes_unistd
690     ]],[[
691       if(0 != gethostname(0, 0))
692         return 1;
693     ]])
694   ],[
695     AC_MSG_RESULT([yes])
696     tst_links_gethostname="yes"
697   ],[
698     AC_MSG_RESULT([no])
699     tst_links_gethostname="no"
700   ])
701   #
702   if test "$tst_links_gethostname" = "yes"; then
703     AC_MSG_CHECKING([if gethostname is prototyped])
704     AC_EGREP_CPP([gethostname],[
705       $cares_includes_winsock2
706       $cares_includes_unistd
707     ],[
708       AC_MSG_RESULT([yes])
709       tst_proto_gethostname="yes"
710     ],[
711       AC_MSG_RESULT([no])
712       tst_proto_gethostname="no"
713     ])
714   fi
715   #
716   if test "$tst_proto_gethostname" = "yes"; then
717     AC_MSG_CHECKING([if gethostname is compilable])
718     AC_COMPILE_IFELSE([
719       AC_LANG_PROGRAM([[
720         $cares_includes_winsock2
721         $cares_includes_unistd
722       ]],[[
723         if(0 != gethostname(0, 0))
724           return 1;
725       ]])
726     ],[
727       AC_MSG_RESULT([yes])
728       tst_compi_gethostname="yes"
729     ],[
730       AC_MSG_RESULT([no])
731       tst_compi_gethostname="no"
732     ])
733   fi
734   #
735   if test "$tst_compi_gethostname" = "yes"; then
736     AC_MSG_CHECKING([if gethostname usage allowed])
737     if test "x$cares_disallow_gethostname" != "xyes"; then
738       AC_MSG_RESULT([yes])
739       tst_allow_gethostname="yes"
740     else
741       AC_MSG_RESULT([no])
742       tst_allow_gethostname="no"
743     fi
744   fi
745   #
746   AC_MSG_CHECKING([if gethostname might be used])
747   if test "$tst_links_gethostname" = "yes" &&
748      test "$tst_proto_gethostname" = "yes" &&
749      test "$tst_compi_gethostname" = "yes" &&
750      test "$tst_allow_gethostname" = "yes"; then
751     AC_MSG_RESULT([yes])
752     AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
753       [Define to 1 if you have the gethostname function.])
754     ac_cv_func_gethostname="yes"
755   else
756     AC_MSG_RESULT([no])
757     ac_cv_func_gethostname="no"
758   fi
759 ])
760
761
762 dnl CARES_CHECK_FUNC_GETSERVBYPORT_R
763 dnl -------------------------------------------------
764 dnl Verify if getservbyport_r is available, prototyped,
765 dnl and can be compiled. If all of these are true, and
766 dnl usage has not been previously disallowed with
767 dnl shell variable cares_disallow_getservbyport_r, then
768 dnl HAVE_GETSERVBYPORT_R will be defined.
769
770 AC_DEFUN([CARES_CHECK_FUNC_GETSERVBYPORT_R], [
771   AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
772   #
773   tst_links_getservbyport_r="unknown"
774   tst_proto_getservbyport_r="unknown"
775   tst_compi_getservbyport_r="unknown"
776   tst_allow_getservbyport_r="unknown"
777   tst_nargs_getservbyport_r="unknown"
778   #
779   AC_MSG_CHECKING([if getservbyport_r can be linked])
780   AC_LINK_IFELSE([
781     AC_LANG_FUNC_LINK_TRY([getservbyport_r])
782   ],[
783     AC_MSG_RESULT([yes])
784     tst_links_getservbyport_r="yes"
785   ],[
786     AC_MSG_RESULT([no])
787     tst_links_getservbyport_r="no"
788   ])
789   #
790   if test "$tst_links_getservbyport_r" = "yes"; then
791     AC_MSG_CHECKING([if getservbyport_r is prototyped])
792     AC_EGREP_CPP([getservbyport_r],[
793       $cares_includes_netdb
794     ],[
795       AC_MSG_RESULT([yes])
796       tst_proto_getservbyport_r="yes"
797     ],[
798       AC_MSG_RESULT([no])
799       tst_proto_getservbyport_r="no"
800     ])
801   fi
802   #
803   if test "$tst_proto_getservbyport_r" = "yes"; then
804     if test "$tst_nargs_getservbyport_r" = "unknown"; then
805       AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
806       AC_COMPILE_IFELSE([
807         AC_LANG_PROGRAM([[
808           $cares_includes_netdb
809         ]],[[
810           if(0 != getservbyport_r(0, 0, 0, 0))
811             return 1;
812         ]])
813       ],[
814         AC_MSG_RESULT([yes])
815         tst_compi_getservbyport_r="yes"
816         tst_nargs_getservbyport_r="4"
817       ],[
818         AC_MSG_RESULT([no])
819         tst_compi_getservbyport_r="no"
820       ])
821     fi
822     if test "$tst_nargs_getservbyport_r" = "unknown"; then
823       AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
824       AC_COMPILE_IFELSE([
825         AC_LANG_PROGRAM([[
826           $cares_includes_netdb
827         ]],[[
828           if(0 != getservbyport_r(0, 0, 0, 0, 0))
829             return 1;
830         ]])
831       ],[
832         AC_MSG_RESULT([yes])
833         tst_compi_getservbyport_r="yes"
834         tst_nargs_getservbyport_r="5"
835       ],[
836         AC_MSG_RESULT([no])
837         tst_compi_getservbyport_r="no"
838       ])
839     fi
840     if test "$tst_nargs_getservbyport_r" = "unknown"; then
841       AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
842       AC_COMPILE_IFELSE([
843         AC_LANG_PROGRAM([[
844           $cares_includes_netdb
845         ]],[[
846           if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
847             return 1;
848         ]])
849       ],[
850         AC_MSG_RESULT([yes])
851         tst_compi_getservbyport_r="yes"
852         tst_nargs_getservbyport_r="6"
853       ],[
854         AC_MSG_RESULT([no])
855         tst_compi_getservbyport_r="no"
856       ])
857     fi
858     AC_MSG_CHECKING([if getservbyport_r is compilable])
859     if test "$tst_compi_getservbyport_r" = "yes"; then
860       AC_MSG_RESULT([yes])
861     else
862       AC_MSG_RESULT([no])
863     fi
864   fi
865   #
866   if test "$tst_compi_getservbyport_r" = "yes"; then
867     AC_MSG_CHECKING([if getservbyport_r usage allowed])
868     if test "x$cares_disallow_getservbyport_r" != "xyes"; then
869       AC_MSG_RESULT([yes])
870       tst_allow_getservbyport_r="yes"
871     else
872       AC_MSG_RESULT([no])
873       tst_allow_getservbyport_r="no"
874     fi
875   fi
876   #
877   AC_MSG_CHECKING([if getservbyport_r might be used])
878   if test "$tst_links_getservbyport_r" = "yes" &&
879      test "$tst_proto_getservbyport_r" = "yes" &&
880      test "$tst_compi_getservbyport_r" = "yes" &&
881      test "$tst_allow_getservbyport_r" = "yes"; then
882     AC_MSG_RESULT([yes])
883     AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
884       [Define to 1 if you have the getservbyport_r function.])
885     AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
886       [Specifies the number of arguments to getservbyport_r])
887     if test "$tst_nargs_getservbyport_r" -eq "4"; then
888       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
889         [Specifies the size of the buffer to pass to getservbyport_r])
890     else
891       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
892         [Specifies the size of the buffer to pass to getservbyport_r])
893     fi
894     ac_cv_func_getservbyport_r="yes"
895   else
896     AC_MSG_RESULT([no])
897     ac_cv_func_getservbyport_r="no"
898   fi
899 ])
900
901
902 dnl CARES_CHECK_FUNC_INET_NTOP
903 dnl -------------------------------------------------
904 dnl Verify if inet_ntop is available, prototyped, can
905 dnl be compiled and seems to work. If all of these are
906 dnl true, and usage has not been previously disallowed
907 dnl with shell variable cares_disallow_inet_ntop, then
908 dnl HAVE_INET_NTOP will be defined.
909
910 AC_DEFUN([CARES_CHECK_FUNC_INET_NTOP], [
911   AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
912   AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
913   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
914   #
915   tst_links_inet_ntop="unknown"
916   tst_proto_inet_ntop="unknown"
917   tst_compi_inet_ntop="unknown"
918   tst_works_inet_ntop="unknown"
919   tst_allow_inet_ntop="unknown"
920   #
921   AC_MSG_CHECKING([if inet_ntop can be linked])
922   AC_LINK_IFELSE([
923     AC_LANG_FUNC_LINK_TRY([inet_ntop])
924   ],[
925     AC_MSG_RESULT([yes])
926     tst_links_inet_ntop="yes"
927   ],[
928     AC_MSG_RESULT([no])
929     tst_links_inet_ntop="no"
930   ])
931   #
932   if test "$tst_links_inet_ntop" = "yes"; then
933     AC_MSG_CHECKING([if inet_ntop is prototyped])
934     AC_EGREP_CPP([inet_ntop],[
935       $cares_includes_arpa_inet
936     ],[
937       AC_MSG_RESULT([yes])
938       tst_proto_inet_ntop="yes"
939     ],[
940       AC_MSG_RESULT([no])
941       tst_proto_inet_ntop="no"
942     ])
943   fi
944   #
945   if test "$tst_proto_inet_ntop" = "yes"; then
946     AC_MSG_CHECKING([if inet_ntop is compilable])
947     AC_COMPILE_IFELSE([
948       AC_LANG_PROGRAM([[
949         $cares_includes_arpa_inet
950       ]],[[
951         if(0 != inet_ntop(0, 0, 0, 0))
952           return 1;
953       ]])
954     ],[
955       AC_MSG_RESULT([yes])
956       tst_compi_inet_ntop="yes"
957     ],[
958       AC_MSG_RESULT([no])
959       tst_compi_inet_ntop="no"
960     ])
961   fi
962   #
963   dnl only do runtime verification when not cross-compiling
964   if test "x$cross_compiling" != "xyes" &&
965     test "$tst_compi_inet_ntop" = "yes"; then
966     AC_MSG_CHECKING([if inet_ntop seems to work])
967     AC_RUN_IFELSE([
968       AC_LANG_PROGRAM([[
969         $cares_includes_stdlib
970         $cares_includes_arpa_inet
971         $cares_includes_string
972       ]],[[
973         char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
974         char ipv4res[sizeof "255.255.255.255"];
975         unsigned char ipv6a[26];
976         unsigned char ipv4a[5];
977         char *ipv6ptr = 0;
978         char *ipv4ptr = 0;
979         /* - */
980         ipv4res[0] = '\0';
981         ipv4a[0] = 0xc0;
982         ipv4a[1] = 0xa8;
983         ipv4a[2] = 0x64;
984         ipv4a[3] = 0x01;
985         ipv4a[4] = 0x01;
986         /* - */
987         ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
988         if(!ipv4ptr)
989           exit(1); /* fail */
990         if(ipv4ptr != ipv4res)
991           exit(1); /* fail */
992         if(!ipv4ptr[0])
993           exit(1); /* fail */
994         if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
995           exit(1); /* fail */
996         /* - */
997         ipv6res[0] = '\0';
998         memset(ipv6a, 0, sizeof(ipv6a));
999         ipv6a[0] = 0xfe;
1000         ipv6a[1] = 0x80;
1001         ipv6a[8] = 0x02;
1002         ipv6a[9] = 0x14;
1003         ipv6a[10] = 0x4f;
1004         ipv6a[11] = 0xff;
1005         ipv6a[12] = 0xfe;
1006         ipv6a[13] = 0x0b;
1007         ipv6a[14] = 0x76;
1008         ipv6a[15] = 0xc8;
1009         ipv6a[25] = 0x01;
1010         /* - */
1011         ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
1012         if(!ipv6ptr)
1013           exit(1); /* fail */
1014         if(ipv6ptr != ipv6res)
1015           exit(1); /* fail */
1016         if(!ipv6ptr[0])
1017           exit(1); /* fail */
1018         if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0)
1019           exit(1); /* fail */
1020         /* - */
1021         exit(0);
1022       ]])
1023     ],[
1024       AC_MSG_RESULT([yes])
1025       tst_works_inet_ntop="yes"
1026     ],[
1027       AC_MSG_RESULT([no])
1028       tst_works_inet_ntop="no"
1029     ])
1030   fi
1031   #
1032   if test "$tst_compi_inet_ntop" = "yes" &&
1033     test "$tst_works_inet_ntop" != "no"; then
1034     AC_MSG_CHECKING([if inet_ntop usage allowed])
1035     if test "x$cares_disallow_inet_ntop" != "xyes"; then
1036       AC_MSG_RESULT([yes])
1037       tst_allow_inet_ntop="yes"
1038     else
1039       AC_MSG_RESULT([no])
1040       tst_allow_inet_ntop="no"
1041     fi
1042   fi
1043   #
1044   AC_MSG_CHECKING([if inet_ntop might be used])
1045   if test "$tst_links_inet_ntop" = "yes" &&
1046      test "$tst_proto_inet_ntop" = "yes" &&
1047      test "$tst_compi_inet_ntop" = "yes" &&
1048      test "$tst_allow_inet_ntop" = "yes" &&
1049      test "$tst_works_inet_ntop" != "no"; then
1050     AC_MSG_RESULT([yes])
1051     AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, 1,
1052       [Define to 1 if you have a IPv6 capable working inet_ntop function.])
1053     ac_cv_func_inet_ntop="yes"
1054   else
1055     AC_MSG_RESULT([no])
1056     ac_cv_func_inet_ntop="no"
1057   fi
1058 ])
1059
1060
1061 dnl CARES_CHECK_FUNC_INET_PTON
1062 dnl -------------------------------------------------
1063 dnl Verify if inet_pton is available, prototyped, can
1064 dnl be compiled and seems to work. If all of these are
1065 dnl true, and usage has not been previously disallowed
1066 dnl with shell variable cares_disallow_inet_pton, then
1067 dnl HAVE_INET_PTON will be defined.
1068
1069 AC_DEFUN([CARES_CHECK_FUNC_INET_PTON], [
1070   AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
1071   AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
1072   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
1073   #
1074   tst_links_inet_pton="unknown"
1075   tst_proto_inet_pton="unknown"
1076   tst_compi_inet_pton="unknown"
1077   tst_works_inet_pton="unknown"
1078   tst_allow_inet_pton="unknown"
1079   #
1080   AC_MSG_CHECKING([if inet_pton can be linked])
1081   AC_LINK_IFELSE([
1082     AC_LANG_FUNC_LINK_TRY([inet_pton])
1083   ],[
1084     AC_MSG_RESULT([yes])
1085     tst_links_inet_pton="yes"
1086   ],[
1087     AC_MSG_RESULT([no])
1088     tst_links_inet_pton="no"
1089   ])
1090   #
1091   if test "$tst_links_inet_pton" = "yes"; then
1092     AC_MSG_CHECKING([if inet_pton is prototyped])
1093     AC_EGREP_CPP([inet_pton],[
1094       $cares_includes_arpa_inet
1095     ],[
1096       AC_MSG_RESULT([yes])
1097       tst_proto_inet_pton="yes"
1098     ],[
1099       AC_MSG_RESULT([no])
1100       tst_proto_inet_pton="no"
1101     ])
1102   fi
1103   #
1104   if test "$tst_proto_inet_pton" = "yes"; then
1105     AC_MSG_CHECKING([if inet_pton is compilable])
1106     AC_COMPILE_IFELSE([
1107       AC_LANG_PROGRAM([[
1108         $cares_includes_arpa_inet
1109       ]],[[
1110         if(0 != inet_pton(0, 0, 0))
1111           return 1;
1112       ]])
1113     ],[
1114       AC_MSG_RESULT([yes])
1115       tst_compi_inet_pton="yes"
1116     ],[
1117       AC_MSG_RESULT([no])
1118       tst_compi_inet_pton="no"
1119     ])
1120   fi
1121   #
1122   dnl only do runtime verification when not cross-compiling
1123   if test "x$cross_compiling" != "xyes" &&
1124     test "$tst_compi_inet_pton" = "yes"; then
1125     AC_MSG_CHECKING([if inet_pton seems to work])
1126     AC_RUN_IFELSE([
1127       AC_LANG_PROGRAM([[
1128         $cares_includes_stdlib
1129         $cares_includes_arpa_inet
1130         $cares_includes_string
1131       ]],[[
1132         unsigned char ipv6a[26];
1133         unsigned char ipv4a[5];
1134         const char *ipv6src = "fe80::214:4fff:fe0b:76c8";
1135         const char *ipv4src = "192.168.100.1";
1136         /* - */
1137         memset(ipv4a, 1, sizeof(ipv4a));
1138         if(1 != inet_pton(AF_INET, ipv4src, ipv4a))
1139           exit(1); /* fail */
1140         /* - */
1141         if( (ipv4a[0] != 0xc0) ||
1142             (ipv4a[1] != 0xa8) ||
1143             (ipv4a[2] != 0x64) ||
1144             (ipv4a[3] != 0x01) ||
1145             (ipv4a[4] != 0x01) )
1146           exit(1); /* fail */
1147         /* - */
1148         memset(ipv6a, 1, sizeof(ipv6a));
1149         if(1 != inet_pton(AF_INET6, ipv6src, ipv6a))
1150           exit(1); /* fail */
1151         /* - */
1152         ipv6res[0] = '\0';
1153         memset(ipv6a, 0, sizeof(ipv6a));
1154         if( (ipv6a[0]  != 0xfe) ||
1155             (ipv6a[1]  != 0x80) ||
1156             (ipv6a[8]  != 0x02) ||
1157             (ipv6a[9]  != 0x14) ||
1158             (ipv6a[10] != 0x4f) ||
1159             (ipv6a[11] != 0xff) ||
1160             (ipv6a[12] != 0xfe) ||
1161             (ipv6a[13] != 0x0b) ||
1162             (ipv6a[14] != 0x76) ||
1163             (ipv6a[15] != 0xc8) ||
1164             (ipv6a[25] != 0x01) )
1165           exit(1); /* fail */
1166         /* - */
1167         if( (ipv6a[2]  != 0x0) ||
1168             (ipv6a[3]  != 0x0) ||
1169             (ipv6a[4]  != 0x0) ||
1170             (ipv6a[5]  != 0x0) ||
1171             (ipv6a[6]  != 0x0) ||
1172             (ipv6a[7]  != 0x0) ||
1173             (ipv6a[16] != 0x0) ||
1174             (ipv6a[17] != 0x0) ||
1175             (ipv6a[18] != 0x0) ||
1176             (ipv6a[19] != 0x0) ||
1177             (ipv6a[20] != 0x0) ||
1178             (ipv6a[21] != 0x0) ||
1179             (ipv6a[22] != 0x0) ||
1180             (ipv6a[23] != 0x0) ||
1181             (ipv6a[24] != 0x0) )
1182           exit(1); /* fail */
1183         /* - */
1184         exit(0);
1185       ]])
1186     ],[
1187       AC_MSG_RESULT([yes])
1188       tst_works_inet_pton="yes"
1189     ],[
1190       AC_MSG_RESULT([no])
1191       tst_works_inet_pton="no"
1192     ])
1193   fi
1194   #
1195   if test "$tst_compi_inet_pton" = "yes" &&
1196     test "$tst_works_inet_pton" != "no"; then
1197     AC_MSG_CHECKING([if inet_pton usage allowed])
1198     if test "x$cares_disallow_inet_pton" != "xyes"; then
1199       AC_MSG_RESULT([yes])
1200       tst_allow_inet_pton="yes"
1201     else
1202       AC_MSG_RESULT([no])
1203       tst_allow_inet_pton="no"
1204     fi
1205   fi
1206   #
1207   AC_MSG_CHECKING([if inet_pton might be used])
1208   if test "$tst_links_inet_pton" = "yes" &&
1209      test "$tst_proto_inet_pton" = "yes" &&
1210      test "$tst_compi_inet_pton" = "yes" &&
1211      test "$tst_allow_inet_pton" = "yes" &&
1212      test "$tst_works_inet_pton" != "no"; then
1213     AC_MSG_RESULT([yes])
1214     AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1,
1215       [Define to 1 if you have a IPv6 capable working inet_pton function.])
1216     ac_cv_func_inet_pton="yes"
1217   else
1218     AC_MSG_RESULT([no])
1219     ac_cv_func_inet_pton="no"
1220   fi
1221 ])
1222
1223
1224 dnl CARES_CHECK_FUNC_IOCTL
1225 dnl -------------------------------------------------
1226 dnl Verify if ioctl is available, prototyped, and
1227 dnl can be compiled. If all of these are true, and
1228 dnl usage has not been previously disallowed with
1229 dnl shell variable cares_disallow_ioctl, then
1230 dnl HAVE_IOCTL will be defined.
1231
1232 AC_DEFUN([CARES_CHECK_FUNC_IOCTL], [
1233   AC_REQUIRE([CARES_INCLUDES_STROPTS])dnl
1234   #
1235   tst_links_ioctl="unknown"
1236   tst_proto_ioctl="unknown"
1237   tst_compi_ioctl="unknown"
1238   tst_allow_ioctl="unknown"
1239   #
1240   AC_MSG_CHECKING([if ioctl can be linked])
1241   AC_LINK_IFELSE([
1242     AC_LANG_FUNC_LINK_TRY([ioctl])
1243   ],[
1244     AC_MSG_RESULT([yes])
1245     tst_links_ioctl="yes"
1246   ],[
1247     AC_MSG_RESULT([no])
1248     tst_links_ioctl="no"
1249   ])
1250   #
1251   if test "$tst_links_ioctl" = "yes"; then
1252     AC_MSG_CHECKING([if ioctl is prototyped])
1253     AC_EGREP_CPP([ioctl],[
1254       $cares_includes_stropts
1255     ],[
1256       AC_MSG_RESULT([yes])
1257       tst_proto_ioctl="yes"
1258     ],[
1259       AC_MSG_RESULT([no])
1260       tst_proto_ioctl="no"
1261     ])
1262   fi
1263   #
1264   if test "$tst_proto_ioctl" = "yes"; then
1265     AC_MSG_CHECKING([if ioctl is compilable])
1266     AC_COMPILE_IFELSE([
1267       AC_LANG_PROGRAM([[
1268         $cares_includes_stropts
1269       ]],[[
1270         if(0 != ioctl(0, 0, 0))
1271           return 1;
1272       ]])
1273     ],[
1274       AC_MSG_RESULT([yes])
1275       tst_compi_ioctl="yes"
1276     ],[
1277       AC_MSG_RESULT([no])
1278       tst_compi_ioctl="no"
1279     ])
1280   fi
1281   #
1282   if test "$tst_compi_ioctl" = "yes"; then
1283     AC_MSG_CHECKING([if ioctl usage allowed])
1284     if test "x$cares_disallow_ioctl" != "xyes"; then
1285       AC_MSG_RESULT([yes])
1286       tst_allow_ioctl="yes"
1287     else
1288       AC_MSG_RESULT([no])
1289       tst_allow_ioctl="no"
1290     fi
1291   fi
1292   #
1293   AC_MSG_CHECKING([if ioctl might be used])
1294   if test "$tst_links_ioctl" = "yes" &&
1295      test "$tst_proto_ioctl" = "yes" &&
1296      test "$tst_compi_ioctl" = "yes" &&
1297      test "$tst_allow_ioctl" = "yes"; then
1298     AC_MSG_RESULT([yes])
1299     AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
1300       [Define to 1 if you have the ioctl function.])
1301     ac_cv_func_ioctl="yes"
1302     CARES_CHECK_FUNC_IOCTL_FIONBIO
1303   else
1304     AC_MSG_RESULT([no])
1305     ac_cv_func_ioctl="no"
1306   fi
1307 ])
1308
1309
1310 dnl CARES_CHECK_FUNC_IOCTL_FIONBIO
1311 dnl -------------------------------------------------
1312 dnl Verify if ioctl with the FIONBIO command is
1313 dnl available, can be compiled, and seems to work. If
1314 dnl all of these are true, then HAVE_IOCTL_FIONBIO
1315 dnl will be defined.
1316
1317 AC_DEFUN([CARES_CHECK_FUNC_IOCTL_FIONBIO], [
1318   #
1319   tst_compi_ioctl_fionbio="unknown"
1320   tst_allow_ioctl_fionbio="unknown"
1321   #
1322   if test "$ac_cv_func_ioctl" = "yes"; then
1323     AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
1324     AC_COMPILE_IFELSE([
1325       AC_LANG_PROGRAM([[
1326         $cares_includes_stropts
1327       ]],[[
1328         int flags = 0;
1329         if(0 != ioctl(0, FIONBIO, &flags))
1330           return 1;
1331       ]])
1332     ],[
1333       AC_MSG_RESULT([yes])
1334       tst_compi_ioctl_fionbio="yes"
1335     ],[
1336       AC_MSG_RESULT([no])
1337       tst_compi_ioctl_fionbio="no"
1338     ])
1339   fi
1340   #
1341   if test "$tst_compi_ioctl_fionbio" = "yes"; then
1342     AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
1343     if test "x$cares_disallow_ioctl_fionbio" != "xyes"; then
1344       AC_MSG_RESULT([yes])
1345       tst_allow_ioctl_fionbio="yes"
1346     else
1347       AC_MSG_RESULT([no])
1348       tst_allow_ioctl_fionbio="no"
1349     fi
1350   fi
1351   #
1352   AC_MSG_CHECKING([if ioctl FIONBIO might be used])
1353   if test "$tst_compi_ioctl_fionbio" = "yes" &&
1354      test "$tst_allow_ioctl_fionbio" = "yes"; then
1355     AC_MSG_RESULT([yes])
1356     AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
1357       [Define to 1 if you have a working ioctl FIONBIO function.])
1358     ac_cv_func_ioctl_fionbio="yes"
1359   else
1360     AC_MSG_RESULT([no])
1361     ac_cv_func_ioctl_fionbio="no"
1362   fi
1363 ])
1364
1365
1366 dnl CARES_CHECK_FUNC_IOCTLSOCKET
1367 dnl -------------------------------------------------
1368 dnl Verify if ioctlsocket is available, prototyped, and
1369 dnl can be compiled. If all of these are true, and
1370 dnl usage has not been previously disallowed with
1371 dnl shell variable cares_disallow_ioctlsocket, then
1372 dnl HAVE_IOCTLSOCKET will be defined.
1373
1374 AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET], [
1375   AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
1376   #
1377   tst_links_ioctlsocket="unknown"
1378   tst_proto_ioctlsocket="unknown"
1379   tst_compi_ioctlsocket="unknown"
1380   tst_allow_ioctlsocket="unknown"
1381   #
1382   AC_MSG_CHECKING([if ioctlsocket can be linked])
1383   AC_LINK_IFELSE([
1384     AC_LANG_PROGRAM([[
1385       $cares_includes_winsock2
1386     ]],[[
1387       if(0 != ioctlsocket(0, 0, 0))
1388         return 1;
1389     ]])
1390   ],[
1391     AC_MSG_RESULT([yes])
1392     tst_links_ioctlsocket="yes"
1393   ],[
1394     AC_MSG_RESULT([no])
1395     tst_links_ioctlsocket="no"
1396   ])
1397   #
1398   if test "$tst_links_ioctlsocket" = "yes"; then
1399     AC_MSG_CHECKING([if ioctlsocket is prototyped])
1400     AC_EGREP_CPP([ioctlsocket],[
1401       $cares_includes_winsock2
1402     ],[
1403       AC_MSG_RESULT([yes])
1404       tst_proto_ioctlsocket="yes"
1405     ],[
1406       AC_MSG_RESULT([no])
1407       tst_proto_ioctlsocket="no"
1408     ])
1409   fi
1410   #
1411   if test "$tst_proto_ioctlsocket" = "yes"; then
1412     AC_MSG_CHECKING([if ioctlsocket is compilable])
1413     AC_COMPILE_IFELSE([
1414       AC_LANG_PROGRAM([[
1415         $cares_includes_winsock2
1416       ]],[[
1417         if(0 != ioctlsocket(0, 0, 0))
1418           return 1;
1419       ]])
1420     ],[
1421       AC_MSG_RESULT([yes])
1422       tst_compi_ioctlsocket="yes"
1423     ],[
1424       AC_MSG_RESULT([no])
1425       tst_compi_ioctlsocket="no"
1426     ])
1427   fi
1428   #
1429   if test "$tst_compi_ioctlsocket" = "yes"; then
1430     AC_MSG_CHECKING([if ioctlsocket usage allowed])
1431     if test "x$cares_disallow_ioctlsocket" != "xyes"; then
1432       AC_MSG_RESULT([yes])
1433       tst_allow_ioctlsocket="yes"
1434     else
1435       AC_MSG_RESULT([no])
1436       tst_allow_ioctlsocket="no"
1437     fi
1438   fi
1439   #
1440   AC_MSG_CHECKING([if ioctlsocket might be used])
1441   if test "$tst_links_ioctlsocket" = "yes" &&
1442      test "$tst_proto_ioctlsocket" = "yes" &&
1443      test "$tst_compi_ioctlsocket" = "yes" &&
1444      test "$tst_allow_ioctlsocket" = "yes"; then
1445     AC_MSG_RESULT([yes])
1446     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
1447       [Define to 1 if you have the ioctlsocket function.])
1448     ac_cv_func_ioctlsocket="yes"
1449     CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO
1450   else
1451     AC_MSG_RESULT([no])
1452     ac_cv_func_ioctlsocket="no"
1453   fi
1454 ])
1455
1456
1457 dnl CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO
1458 dnl -------------------------------------------------
1459 dnl Verify if ioctlsocket with the FIONBIO command is
1460 dnl available, can be compiled, and seems to work. If
1461 dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
1462 dnl will be defined.
1463
1464 AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
1465   #
1466   tst_compi_ioctlsocket_fionbio="unknown"
1467   tst_allow_ioctlsocket_fionbio="unknown"
1468   #
1469   if test "$ac_cv_func_ioctlsocket" = "yes"; then
1470     AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
1471     AC_COMPILE_IFELSE([
1472       AC_LANG_PROGRAM([[
1473         $cares_includes_winsock2
1474       ]],[[
1475         int flags = 0;
1476         if(0 != ioctlsocket(0, FIONBIO, &flags))
1477           return 1;
1478       ]])
1479     ],[
1480       AC_MSG_RESULT([yes])
1481       tst_compi_ioctlsocket_fionbio="yes"
1482     ],[
1483       AC_MSG_RESULT([no])
1484       tst_compi_ioctlsocket_fionbio="no"
1485     ])
1486   fi
1487   #
1488   if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
1489     AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
1490     if test "x$cares_disallow_ioctlsocket_fionbio" != "xyes"; then
1491       AC_MSG_RESULT([yes])
1492       tst_allow_ioctlsocket_fionbio="yes"
1493     else
1494       AC_MSG_RESULT([no])
1495       tst_allow_ioctlsocket_fionbio="no"
1496     fi
1497   fi
1498   #
1499   AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
1500   if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
1501      test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
1502     AC_MSG_RESULT([yes])
1503     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
1504       [Define to 1 if you have a working ioctlsocket FIONBIO function.])
1505     ac_cv_func_ioctlsocket_fionbio="yes"
1506   else
1507     AC_MSG_RESULT([no])
1508     ac_cv_func_ioctlsocket_fionbio="no"
1509   fi
1510 ])
1511
1512
1513 dnl CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
1514 dnl -------------------------------------------------
1515 dnl Verify if IoctlSocket is available, prototyped, and
1516 dnl can be compiled. If all of these are true, and
1517 dnl usage has not been previously disallowed with
1518 dnl shell variable cares_disallow_ioctlsocket_camel,
1519 dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
1520
1521 AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
1522   AC_REQUIRE([CARES_INCLUDES_STROPTS])dnl
1523   #
1524   tst_links_ioctlsocket_camel="unknown"
1525   tst_proto_ioctlsocket_camel="unknown"
1526   tst_compi_ioctlsocket_camel="unknown"
1527   tst_allow_ioctlsocket_camel="unknown"
1528   #
1529   AC_MSG_CHECKING([if IoctlSocket can be linked])
1530   AC_LINK_IFELSE([
1531     AC_LANG_FUNC_LINK_TRY([IoctlSocket])
1532   ],[
1533     AC_MSG_RESULT([yes])
1534     tst_links_ioctlsocket_camel="yes"
1535   ],[
1536     AC_MSG_RESULT([no])
1537     tst_links_ioctlsocket_camel="no"
1538   ])
1539   #
1540   if test "$tst_links_ioctlsocket_camel" = "yes"; then
1541     AC_MSG_CHECKING([if IoctlSocket is prototyped])
1542     AC_EGREP_CPP([IoctlSocket],[
1543       $cares_includes_stropts
1544     ],[
1545       AC_MSG_RESULT([yes])
1546       tst_proto_ioctlsocket_camel="yes"
1547     ],[
1548       AC_MSG_RESULT([no])
1549       tst_proto_ioctlsocket_camel="no"
1550     ])
1551   fi
1552   #
1553   if test "$tst_proto_ioctlsocket_camel" = "yes"; then
1554     AC_MSG_CHECKING([if IoctlSocket is compilable])
1555     AC_COMPILE_IFELSE([
1556       AC_LANG_PROGRAM([[
1557         $cares_includes_stropts
1558       ]],[[
1559         if(0 != IoctlSocket(0, 0, 0))
1560           return 1;
1561       ]])
1562     ],[
1563       AC_MSG_RESULT([yes])
1564       tst_compi_ioctlsocket_camel="yes"
1565     ],[
1566       AC_MSG_RESULT([no])
1567       tst_compi_ioctlsocket_camel="no"
1568     ])
1569   fi
1570   #
1571   if test "$tst_compi_ioctlsocket_camel" = "yes"; then
1572     AC_MSG_CHECKING([if IoctlSocket usage allowed])
1573     if test "x$cares_disallow_ioctlsocket_camel" != "xyes"; then
1574       AC_MSG_RESULT([yes])
1575       tst_allow_ioctlsocket_camel="yes"
1576     else
1577       AC_MSG_RESULT([no])
1578       tst_allow_ioctlsocket_camel="no"
1579     fi
1580   fi
1581   #
1582   AC_MSG_CHECKING([if IoctlSocket might be used])
1583   if test "$tst_links_ioctlsocket_camel" = "yes" &&
1584      test "$tst_proto_ioctlsocket_camel" = "yes" &&
1585      test "$tst_compi_ioctlsocket_camel" = "yes" &&
1586      test "$tst_allow_ioctlsocket_camel" = "yes"; then
1587     AC_MSG_RESULT([yes])
1588     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
1589       [Define to 1 if you have the IoctlSocket camel case function.])
1590     ac_cv_func_ioctlsocket_camel="yes"
1591     CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
1592   else
1593     AC_MSG_RESULT([no])
1594     ac_cv_func_ioctlsocket_camel="no"
1595   fi
1596 ])
1597
1598
1599 dnl CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
1600 dnl -------------------------------------------------
1601 dnl Verify if IoctlSocket with FIONBIO command is available,
1602 dnl can be compiled, and seems to work. If all of these are
1603 dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
1604
1605 AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
1606   #
1607   tst_compi_ioctlsocket_camel_fionbio="unknown"
1608   tst_allow_ioctlsocket_camel_fionbio="unknown"
1609   #
1610   if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then
1611     AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
1612     AC_COMPILE_IFELSE([
1613       AC_LANG_PROGRAM([[
1614         $cares_includes_stropts
1615       ]],[[
1616         long flags = 0;
1617         if(0 != ioctlsocket(0, FIONBIO, &flags))
1618           return 1;
1619       ]])
1620     ],[
1621       AC_MSG_RESULT([yes])
1622       tst_compi_ioctlsocket_camel_fionbio="yes"
1623     ],[
1624       AC_MSG_RESULT([no])
1625       tst_compi_ioctlsocket_camel_fionbio="no"
1626     ])
1627   fi
1628   #
1629   if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
1630     AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
1631     if test "x$cares_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
1632       AC_MSG_RESULT([yes])
1633       tst_allow_ioctlsocket_camel_fionbio="yes"
1634     else
1635       AC_MSG_RESULT([no])
1636       tst_allow_ioctlsocket_camel_fionbio="no"
1637     fi
1638   fi
1639   #
1640   AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
1641   if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
1642      test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
1643     AC_MSG_RESULT([yes])
1644     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
1645       [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
1646     ac_cv_func_ioctlsocket_camel_fionbio="yes"
1647   else
1648     AC_MSG_RESULT([no])
1649     ac_cv_func_ioctlsocket_camel_fionbio="no"
1650   fi
1651 ])
1652
1653
1654 dnl CARES_CHECK_FUNC_SETSOCKOPT
1655 dnl -------------------------------------------------
1656 dnl Verify if setsockopt is available, prototyped, and
1657 dnl can be compiled. If all of these are true, and
1658 dnl usage has not been previously disallowed with
1659 dnl shell variable cares_disallow_setsockopt, then
1660 dnl HAVE_SETSOCKOPT will be defined.
1661
1662 AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT], [
1663   AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
1664   AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
1665   #
1666   tst_links_setsockopt="unknown"
1667   tst_proto_setsockopt="unknown"
1668   tst_compi_setsockopt="unknown"
1669   tst_allow_setsockopt="unknown"
1670   #
1671   AC_MSG_CHECKING([if setsockopt can be linked])
1672   AC_LINK_IFELSE([
1673     AC_LANG_PROGRAM([[
1674       $cares_includes_winsock2
1675       $cares_includes_sys_socket
1676     ]],[[
1677       if(0 != setsockopt(0, 0, 0, 0, 0))
1678         return 1;
1679     ]])
1680   ],[
1681     AC_MSG_RESULT([yes])
1682     tst_links_setsockopt="yes"
1683   ],[
1684     AC_MSG_RESULT([no])
1685     tst_links_setsockopt="no"
1686   ])
1687   #
1688   if test "$tst_links_setsockopt" = "yes"; then
1689     AC_MSG_CHECKING([if setsockopt is prototyped])
1690     AC_EGREP_CPP([setsockopt],[
1691       $cares_includes_winsock2
1692       $cares_includes_sys_socket
1693     ],[
1694       AC_MSG_RESULT([yes])
1695       tst_proto_setsockopt="yes"
1696     ],[
1697       AC_MSG_RESULT([no])
1698       tst_proto_setsockopt="no"
1699     ])
1700   fi
1701   #
1702   if test "$tst_proto_setsockopt" = "yes"; then
1703     AC_MSG_CHECKING([if setsockopt is compilable])
1704     AC_COMPILE_IFELSE([
1705       AC_LANG_PROGRAM([[
1706         $cares_includes_winsock2
1707         $cares_includes_sys_socket
1708       ]],[[
1709         if(0 != setsockopt(0, 0, 0, 0, 0))
1710           return 1;
1711       ]])
1712     ],[
1713       AC_MSG_RESULT([yes])
1714       tst_compi_setsockopt="yes"
1715     ],[
1716       AC_MSG_RESULT([no])
1717       tst_compi_setsockopt="no"
1718     ])
1719   fi
1720   #
1721   if test "$tst_compi_setsockopt" = "yes"; then
1722     AC_MSG_CHECKING([if setsockopt usage allowed])
1723     if test "x$cares_disallow_setsockopt" != "xyes"; then
1724       AC_MSG_RESULT([yes])
1725       tst_allow_setsockopt="yes"
1726     else
1727       AC_MSG_RESULT([no])
1728       tst_allow_setsockopt="no"
1729     fi
1730   fi
1731   #
1732   AC_MSG_CHECKING([if setsockopt might be used])
1733   if test "$tst_links_setsockopt" = "yes" &&
1734      test "$tst_proto_setsockopt" = "yes" &&
1735      test "$tst_compi_setsockopt" = "yes" &&
1736      test "$tst_allow_setsockopt" = "yes"; then
1737     AC_MSG_RESULT([yes])
1738     AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1,
1739       [Define to 1 if you have the setsockopt function.])
1740     ac_cv_func_setsockopt="yes"
1741     CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
1742   else
1743     AC_MSG_RESULT([no])
1744     ac_cv_func_setsockopt="no"
1745   fi
1746 ])
1747
1748
1749 dnl CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
1750 dnl -------------------------------------------------
1751 dnl Verify if setsockopt with the SO_NONBLOCK command is
1752 dnl available, can be compiled, and seems to work. If
1753 dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK
1754 dnl will be defined.
1755
1756 AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
1757   #
1758   tst_compi_setsockopt_so_nonblock="unknown"
1759   tst_allow_setsockopt_so_nonblock="unknown"
1760   #
1761   if test "$ac_cv_func_setsockopt" = "yes"; then
1762     AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable])
1763     AC_COMPILE_IFELSE([
1764       AC_LANG_PROGRAM([[
1765         $cares_includes_winsock2
1766         $cares_includes_sys_socket
1767       ]],[[
1768         if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
1769           return 1;
1770       ]])
1771     ],[
1772       AC_MSG_RESULT([yes])
1773       tst_compi_setsockopt_so_nonblock="yes"
1774     ],[
1775       AC_MSG_RESULT([no])
1776       tst_compi_setsockopt_so_nonblock="no"
1777     ])
1778   fi
1779   #
1780   if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then
1781     AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed])
1782     if test "x$cares_disallow_setsockopt_so_nonblock" != "xyes"; then
1783       AC_MSG_RESULT([yes])
1784       tst_allow_setsockopt_so_nonblock="yes"
1785     else
1786       AC_MSG_RESULT([no])
1787       tst_allow_setsockopt_so_nonblock="no"
1788     fi
1789   fi
1790   #
1791   AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used])
1792   if test "$tst_compi_setsockopt_so_nonblock" = "yes" &&
1793      test "$tst_allow_setsockopt_so_nonblock" = "yes"; then
1794     AC_MSG_RESULT([yes])
1795     AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1,
1796       [Define to 1 if you have a working setsockopt SO_NONBLOCK function.])
1797     ac_cv_func_setsockopt_so_nonblock="yes"
1798   else
1799     AC_MSG_RESULT([no])
1800     ac_cv_func_setsockopt_so_nonblock="no"
1801   fi
1802 ])
1803
1804
1805 dnl CARES_CHECK_FUNC_STRCASECMP
1806 dnl -------------------------------------------------
1807 dnl Verify if strcasecmp is available, prototyped, and
1808 dnl can be compiled. If all of these are true, and
1809 dnl usage has not been previously disallowed with
1810 dnl shell variable cares_disallow_strcasecmp, then
1811 dnl HAVE_STRCASECMP will be defined.
1812
1813 AC_DEFUN([CARES_CHECK_FUNC_STRCASECMP], [
1814   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
1815   #
1816   tst_links_strcasecmp="unknown"
1817   tst_proto_strcasecmp="unknown"
1818   tst_compi_strcasecmp="unknown"
1819   tst_allow_strcasecmp="unknown"
1820   #
1821   AC_MSG_CHECKING([if strcasecmp can be linked])
1822   AC_LINK_IFELSE([
1823     AC_LANG_FUNC_LINK_TRY([strcasecmp])
1824   ],[
1825     AC_MSG_RESULT([yes])
1826     tst_links_strcasecmp="yes"
1827   ],[
1828     AC_MSG_RESULT([no])
1829     tst_links_strcasecmp="no"
1830   ])
1831   #
1832   if test "$tst_links_strcasecmp" = "yes"; then
1833     AC_MSG_CHECKING([if strcasecmp is prototyped])
1834     AC_EGREP_CPP([strcasecmp],[
1835       $cares_includes_string
1836     ],[
1837       AC_MSG_RESULT([yes])
1838       tst_proto_strcasecmp="yes"
1839     ],[
1840       AC_MSG_RESULT([no])
1841       tst_proto_strcasecmp="no"
1842     ])
1843   fi
1844   #
1845   if test "$tst_proto_strcasecmp" = "yes"; then
1846     AC_MSG_CHECKING([if strcasecmp is compilable])
1847     AC_COMPILE_IFELSE([
1848       AC_LANG_PROGRAM([[
1849         $cares_includes_string
1850       ]],[[
1851         if(0 != strcasecmp(0, 0))
1852           return 1;
1853       ]])
1854     ],[
1855       AC_MSG_RESULT([yes])
1856       tst_compi_strcasecmp="yes"
1857     ],[
1858       AC_MSG_RESULT([no])
1859       tst_compi_strcasecmp="no"
1860     ])
1861   fi
1862   #
1863   if test "$tst_compi_strcasecmp" = "yes"; then
1864     AC_MSG_CHECKING([if strcasecmp usage allowed])
1865     if test "x$cares_disallow_strcasecmp" != "xyes"; then
1866       AC_MSG_RESULT([yes])
1867       tst_allow_strcasecmp="yes"
1868     else
1869       AC_MSG_RESULT([no])
1870       tst_allow_strcasecmp="no"
1871     fi
1872   fi
1873   #
1874   AC_MSG_CHECKING([if strcasecmp might be used])
1875   if test "$tst_links_strcasecmp" = "yes" &&
1876      test "$tst_proto_strcasecmp" = "yes" &&
1877      test "$tst_compi_strcasecmp" = "yes" &&
1878      test "$tst_allow_strcasecmp" = "yes"; then
1879     AC_MSG_RESULT([yes])
1880     AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
1881       [Define to 1 if you have the strcasecmp function.])
1882     ac_cv_func_strcasecmp="yes"
1883   else
1884     AC_MSG_RESULT([no])
1885     ac_cv_func_strcasecmp="no"
1886   fi
1887 ])
1888
1889
1890 dnl CARES_CHECK_FUNC_STRCMPI
1891 dnl -------------------------------------------------
1892 dnl Verify if strcmpi is available, prototyped, and
1893 dnl can be compiled. If all of these are true, and
1894 dnl usage has not been previously disallowed with
1895 dnl shell variable cares_disallow_strcmpi, then
1896 dnl HAVE_STRCMPI will be defined.
1897
1898 AC_DEFUN([CARES_CHECK_FUNC_STRCMPI], [
1899   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
1900   #
1901   tst_links_strcmpi="unknown"
1902   tst_proto_strcmpi="unknown"
1903   tst_compi_strcmpi="unknown"
1904   tst_allow_strcmpi="unknown"
1905   #
1906   AC_MSG_CHECKING([if strcmpi can be linked])
1907   AC_LINK_IFELSE([
1908     AC_LANG_FUNC_LINK_TRY([strcmpi])
1909   ],[
1910     AC_MSG_RESULT([yes])
1911     tst_links_strcmpi="yes"
1912   ],[
1913     AC_MSG_RESULT([no])
1914     tst_links_strcmpi="no"
1915   ])
1916   #
1917   if test "$tst_links_strcmpi" = "yes"; then
1918     AC_MSG_CHECKING([if strcmpi is prototyped])
1919     AC_EGREP_CPP([strcmpi],[
1920       $cares_includes_string
1921     ],[
1922       AC_MSG_RESULT([yes])
1923       tst_proto_strcmpi="yes"
1924     ],[
1925       AC_MSG_RESULT([no])
1926       tst_proto_strcmpi="no"
1927     ])
1928   fi
1929   #
1930   if test "$tst_proto_strcmpi" = "yes"; then
1931     AC_MSG_CHECKING([if strcmpi is compilable])
1932     AC_COMPILE_IFELSE([
1933       AC_LANG_PROGRAM([[
1934         $cares_includes_string
1935       ]],[[
1936         if(0 != strcmpi(0, 0))
1937           return 1;
1938       ]])
1939     ],[
1940       AC_MSG_RESULT([yes])
1941       tst_compi_strcmpi="yes"
1942     ],[
1943       AC_MSG_RESULT([no])
1944       tst_compi_strcmpi="no"
1945     ])
1946   fi
1947   #
1948   if test "$tst_compi_strcmpi" = "yes"; then
1949     AC_MSG_CHECKING([if strcmpi usage allowed])
1950     if test "x$cares_disallow_strcmpi" != "xyes"; then
1951       AC_MSG_RESULT([yes])
1952       tst_allow_strcmpi="yes"
1953     else
1954       AC_MSG_RESULT([no])
1955       tst_allow_strcmpi="no"
1956     fi
1957   fi
1958   #
1959   AC_MSG_CHECKING([if strcmpi might be used])
1960   if test "$tst_links_strcmpi" = "yes" &&
1961      test "$tst_proto_strcmpi" = "yes" &&
1962      test "$tst_compi_strcmpi" = "yes" &&
1963      test "$tst_allow_strcmpi" = "yes"; then
1964     AC_MSG_RESULT([yes])
1965     AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
1966       [Define to 1 if you have the strcmpi function.])
1967     ac_cv_func_strcmpi="yes"
1968   else
1969     AC_MSG_RESULT([no])
1970     ac_cv_func_strcmpi="no"
1971   fi
1972 ])
1973
1974
1975 dnl CARES_CHECK_FUNC_STRDUP
1976 dnl -------------------------------------------------
1977 dnl Verify if strdup is available, prototyped, and
1978 dnl can be compiled. If all of these are true, and
1979 dnl usage has not been previously disallowed with
1980 dnl shell variable cares_disallow_strdup, then
1981 dnl HAVE_STRDUP will be defined.
1982
1983 AC_DEFUN([CARES_CHECK_FUNC_STRDUP], [
1984   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
1985   #
1986   tst_links_strdup="unknown"
1987   tst_proto_strdup="unknown"
1988   tst_compi_strdup="unknown"
1989   tst_allow_strdup="unknown"
1990   #
1991   AC_MSG_CHECKING([if strdup can be linked])
1992   AC_LINK_IFELSE([
1993     AC_LANG_FUNC_LINK_TRY([strdup])
1994   ],[
1995     AC_MSG_RESULT([yes])
1996     tst_links_strdup="yes"
1997   ],[
1998     AC_MSG_RESULT([no])
1999     tst_links_strdup="no"
2000   ])
2001   #
2002   if test "$tst_links_strdup" = "yes"; then
2003     AC_MSG_CHECKING([if strdup is prototyped])
2004     AC_EGREP_CPP([strdup],[
2005       $cares_includes_string
2006     ],[
2007       AC_MSG_RESULT([yes])
2008       tst_proto_strdup="yes"
2009     ],[
2010       AC_MSG_RESULT([no])
2011       tst_proto_strdup="no"
2012     ])
2013   fi
2014   #
2015   if test "$tst_proto_strdup" = "yes"; then
2016     AC_MSG_CHECKING([if strdup is compilable])
2017     AC_COMPILE_IFELSE([
2018       AC_LANG_PROGRAM([[
2019         $cares_includes_string
2020       ]],[[
2021         if(0 != strdup(0))
2022           return 1;
2023       ]])
2024     ],[
2025       AC_MSG_RESULT([yes])
2026       tst_compi_strdup="yes"
2027     ],[
2028       AC_MSG_RESULT([no])
2029       tst_compi_strdup="no"
2030     ])
2031   fi
2032   #
2033   if test "$tst_compi_strdup" = "yes"; then
2034     AC_MSG_CHECKING([if strdup usage allowed])
2035     if test "x$cares_disallow_strdup" != "xyes"; then
2036       AC_MSG_RESULT([yes])
2037       tst_allow_strdup="yes"
2038     else
2039       AC_MSG_RESULT([no])
2040       tst_allow_strdup="no"
2041     fi
2042   fi
2043   #
2044   AC_MSG_CHECKING([if strdup might be used])
2045   if test "$tst_links_strdup" = "yes" &&
2046      test "$tst_proto_strdup" = "yes" &&
2047      test "$tst_compi_strdup" = "yes" &&
2048      test "$tst_allow_strdup" = "yes"; then
2049     AC_MSG_RESULT([yes])
2050     AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
2051       [Define to 1 if you have the strdup function.])
2052     ac_cv_func_strdup="yes"
2053   else
2054     AC_MSG_RESULT([no])
2055     ac_cv_func_strdup="no"
2056   fi
2057 ])
2058
2059
2060 dnl CARES_CHECK_FUNC_STRICMP
2061 dnl -------------------------------------------------
2062 dnl Verify if stricmp is available, prototyped, and
2063 dnl can be compiled. If all of these are true, and
2064 dnl usage has not been previously disallowed with
2065 dnl shell variable cares_disallow_stricmp, then
2066 dnl HAVE_STRICMP will be defined.
2067
2068 AC_DEFUN([CARES_CHECK_FUNC_STRICMP], [
2069   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
2070   #
2071   tst_links_stricmp="unknown"
2072   tst_proto_stricmp="unknown"
2073   tst_compi_stricmp="unknown"
2074   tst_allow_stricmp="unknown"
2075   #
2076   AC_MSG_CHECKING([if stricmp can be linked])
2077   AC_LINK_IFELSE([
2078     AC_LANG_FUNC_LINK_TRY([stricmp])
2079   ],[
2080     AC_MSG_RESULT([yes])
2081     tst_links_stricmp="yes"
2082   ],[
2083     AC_MSG_RESULT([no])
2084     tst_links_stricmp="no"
2085   ])
2086   #
2087   if test "$tst_links_stricmp" = "yes"; then
2088     AC_MSG_CHECKING([if stricmp is prototyped])
2089     AC_EGREP_CPP([stricmp],[
2090       $cares_includes_string
2091     ],[
2092       AC_MSG_RESULT([yes])
2093       tst_proto_stricmp="yes"
2094     ],[
2095       AC_MSG_RESULT([no])
2096       tst_proto_stricmp="no"
2097     ])
2098   fi
2099   #
2100   if test "$tst_proto_stricmp" = "yes"; then
2101     AC_MSG_CHECKING([if stricmp is compilable])
2102     AC_COMPILE_IFELSE([
2103       AC_LANG_PROGRAM([[
2104         $cares_includes_string
2105       ]],[[
2106         if(0 != stricmp(0, 0))
2107           return 1;
2108       ]])
2109     ],[
2110       AC_MSG_RESULT([yes])
2111       tst_compi_stricmp="yes"
2112     ],[
2113       AC_MSG_RESULT([no])
2114       tst_compi_stricmp="no"
2115     ])
2116   fi
2117   #
2118   if test "$tst_compi_stricmp" = "yes"; then
2119     AC_MSG_CHECKING([if stricmp usage allowed])
2120     if test "x$cares_disallow_stricmp" != "xyes"; then
2121       AC_MSG_RESULT([yes])
2122       tst_allow_stricmp="yes"
2123     else
2124       AC_MSG_RESULT([no])
2125       tst_allow_stricmp="no"
2126     fi
2127   fi
2128   #
2129   AC_MSG_CHECKING([if stricmp might be used])
2130   if test "$tst_links_stricmp" = "yes" &&
2131      test "$tst_proto_stricmp" = "yes" &&
2132      test "$tst_compi_stricmp" = "yes" &&
2133      test "$tst_allow_stricmp" = "yes"; then
2134     AC_MSG_RESULT([yes])
2135     AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
2136       [Define to 1 if you have the stricmp function.])
2137     ac_cv_func_stricmp="yes"
2138   else
2139     AC_MSG_RESULT([no])
2140     ac_cv_func_stricmp="no"
2141   fi
2142 ])
2143
2144
2145 dnl CARES_CHECK_FUNC_STRNCASECMP
2146 dnl -------------------------------------------------
2147 dnl Verify if strncasecmp is available, prototyped, and
2148 dnl can be compiled. If all of these are true, and
2149 dnl usage has not been previously disallowed with
2150 dnl shell variable cares_disallow_strncasecmp, then
2151 dnl HAVE_STRNCASECMP will be defined.
2152
2153 AC_DEFUN([CARES_CHECK_FUNC_STRNCASECMP], [
2154   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
2155   #
2156   tst_links_strncasecmp="unknown"
2157   tst_proto_strncasecmp="unknown"
2158   tst_compi_strncasecmp="unknown"
2159   tst_allow_strncasecmp="unknown"
2160   #
2161   AC_MSG_CHECKING([if strncasecmp can be linked])
2162   AC_LINK_IFELSE([
2163     AC_LANG_FUNC_LINK_TRY([strncasecmp])
2164   ],[
2165     AC_MSG_RESULT([yes])
2166     tst_links_strncasecmp="yes"
2167   ],[
2168     AC_MSG_RESULT([no])
2169     tst_links_strncasecmp="no"
2170   ])
2171   #
2172   if test "$tst_links_strncasecmp" = "yes"; then
2173     AC_MSG_CHECKING([if strncasecmp is prototyped])
2174     AC_EGREP_CPP([strncasecmp],[
2175       $cares_includes_string
2176     ],[
2177       AC_MSG_RESULT([yes])
2178       tst_proto_strncasecmp="yes"
2179     ],[
2180       AC_MSG_RESULT([no])
2181       tst_proto_strncasecmp="no"
2182     ])
2183   fi
2184   #
2185   if test "$tst_proto_strncasecmp" = "yes"; then
2186     AC_MSG_CHECKING([if strncasecmp is compilable])
2187     AC_COMPILE_IFELSE([
2188       AC_LANG_PROGRAM([[
2189         $cares_includes_string
2190       ]],[[
2191         if(0 != strncasecmp(0, 0, 0))
2192           return 1;
2193       ]])
2194     ],[
2195       AC_MSG_RESULT([yes])
2196       tst_compi_strncasecmp="yes"
2197     ],[
2198       AC_MSG_RESULT([no])
2199       tst_compi_strncasecmp="no"
2200     ])
2201   fi
2202   #
2203   if test "$tst_compi_strncasecmp" = "yes"; then
2204     AC_MSG_CHECKING([if strncasecmp usage allowed])
2205     if test "x$cares_disallow_strncasecmp" != "xyes"; then
2206       AC_MSG_RESULT([yes])
2207       tst_allow_strncasecmp="yes"
2208     else
2209       AC_MSG_RESULT([no])
2210       tst_allow_strncasecmp="no"
2211     fi
2212   fi
2213   #
2214   AC_MSG_CHECKING([if strncasecmp might be used])
2215   if test "$tst_links_strncasecmp" = "yes" &&
2216      test "$tst_proto_strncasecmp" = "yes" &&
2217      test "$tst_compi_strncasecmp" = "yes" &&
2218      test "$tst_allow_strncasecmp" = "yes"; then
2219     AC_MSG_RESULT([yes])
2220     AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
2221       [Define to 1 if you have the strncasecmp function.])
2222     ac_cv_func_strncasecmp="yes"
2223   else
2224     AC_MSG_RESULT([no])
2225     ac_cv_func_strncasecmp="no"
2226   fi
2227 ])
2228
2229
2230 dnl CARES_CHECK_FUNC_STRNCMPI
2231 dnl -------------------------------------------------
2232 dnl Verify if strncmpi is available, prototyped, and
2233 dnl can be compiled. If all of these are true, and
2234 dnl usage has not been previously disallowed with
2235 dnl shell variable cares_disallow_strncmpi, then
2236 dnl HAVE_STRNCMPI will be defined.
2237
2238 AC_DEFUN([CARES_CHECK_FUNC_STRNCMPI], [
2239   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
2240   #
2241   tst_links_strncmpi="unknown"
2242   tst_proto_strncmpi="unknown"
2243   tst_compi_strncmpi="unknown"
2244   tst_allow_strncmpi="unknown"
2245   #
2246   AC_MSG_CHECKING([if strncmpi can be linked])
2247   AC_LINK_IFELSE([
2248     AC_LANG_FUNC_LINK_TRY([strncmpi])
2249   ],[
2250     AC_MSG_RESULT([yes])
2251     tst_links_strncmpi="yes"
2252   ],[
2253     AC_MSG_RESULT([no])
2254     tst_links_strncmpi="no"
2255   ])
2256   #
2257   if test "$tst_links_strncmpi" = "yes"; then
2258     AC_MSG_CHECKING([if strncmpi is prototyped])
2259     AC_EGREP_CPP([strncmpi],[
2260       $cares_includes_string
2261     ],[
2262       AC_MSG_RESULT([yes])
2263       tst_proto_strncmpi="yes"
2264     ],[
2265       AC_MSG_RESULT([no])
2266       tst_proto_strncmpi="no"
2267     ])
2268   fi
2269   #
2270   if test "$tst_proto_strncmpi" = "yes"; then
2271     AC_MSG_CHECKING([if strncmpi is compilable])
2272     AC_COMPILE_IFELSE([
2273       AC_LANG_PROGRAM([[
2274         $cares_includes_string
2275       ]],[[
2276         if(0 != strncmpi(0, 0))
2277           return 1;
2278       ]])
2279     ],[
2280       AC_MSG_RESULT([yes])
2281       tst_compi_strncmpi="yes"
2282     ],[
2283       AC_MSG_RESULT([no])
2284       tst_compi_strncmpi="no"
2285     ])
2286   fi
2287   #
2288   if test "$tst_compi_strncmpi" = "yes"; then
2289     AC_MSG_CHECKING([if strncmpi usage allowed])
2290     if test "x$cares_disallow_strncmpi" != "xyes"; then
2291       AC_MSG_RESULT([yes])
2292       tst_allow_strncmpi="yes"
2293     else
2294       AC_MSG_RESULT([no])
2295       tst_allow_strncmpi="no"
2296     fi
2297   fi
2298   #
2299   AC_MSG_CHECKING([if strncmpi might be used])
2300   if test "$tst_links_strncmpi" = "yes" &&
2301      test "$tst_proto_strncmpi" = "yes" &&
2302      test "$tst_compi_strncmpi" = "yes" &&
2303      test "$tst_allow_strncmpi" = "yes"; then
2304     AC_MSG_RESULT([yes])
2305     AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
2306       [Define to 1 if you have the strncmpi function.])
2307     ac_cv_func_strncmpi="yes"
2308   else
2309     AC_MSG_RESULT([no])
2310     ac_cv_func_strncmpi="no"
2311   fi
2312 ])
2313
2314
2315 dnl CARES_CHECK_FUNC_STRNICMP
2316 dnl -------------------------------------------------
2317 dnl Verify if strnicmp is available, prototyped, and
2318 dnl can be compiled. If all of these are true, and
2319 dnl usage has not been previously disallowed with
2320 dnl shell variable cares_disallow_strnicmp, then
2321 dnl HAVE_STRNICMP will be defined.
2322
2323 AC_DEFUN([CARES_CHECK_FUNC_STRNICMP], [
2324   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
2325   #
2326   tst_links_strnicmp="unknown"
2327   tst_proto_strnicmp="unknown"
2328   tst_compi_strnicmp="unknown"
2329   tst_allow_strnicmp="unknown"
2330   #
2331   AC_MSG_CHECKING([if strnicmp can be linked])
2332   AC_LINK_IFELSE([
2333     AC_LANG_FUNC_LINK_TRY([strnicmp])
2334   ],[
2335     AC_MSG_RESULT([yes])
2336     tst_links_strnicmp="yes"
2337   ],[
2338     AC_MSG_RESULT([no])
2339     tst_links_strnicmp="no"
2340   ])
2341   #
2342   if test "$tst_links_strnicmp" = "yes"; then
2343     AC_MSG_CHECKING([if strnicmp is prototyped])
2344     AC_EGREP_CPP([strnicmp],[
2345       $cares_includes_string
2346     ],[
2347       AC_MSG_RESULT([yes])
2348       tst_proto_strnicmp="yes"
2349     ],[
2350       AC_MSG_RESULT([no])
2351       tst_proto_strnicmp="no"
2352     ])
2353   fi
2354   #
2355   if test "$tst_proto_strnicmp" = "yes"; then
2356     AC_MSG_CHECKING([if strnicmp is compilable])
2357     AC_COMPILE_IFELSE([
2358       AC_LANG_PROGRAM([[
2359         $cares_includes_string
2360       ]],[[
2361         if(0 != strnicmp(0, 0))
2362           return 1;
2363       ]])
2364     ],[
2365       AC_MSG_RESULT([yes])
2366       tst_compi_strnicmp="yes"
2367     ],[
2368       AC_MSG_RESULT([no])
2369       tst_compi_strnicmp="no"
2370     ])
2371   fi
2372   #
2373   if test "$tst_compi_strnicmp" = "yes"; then
2374     AC_MSG_CHECKING([if strnicmp usage allowed])
2375     if test "x$cares_disallow_strnicmp" != "xyes"; then
2376       AC_MSG_RESULT([yes])
2377       tst_allow_strnicmp="yes"
2378     else
2379       AC_MSG_RESULT([no])
2380       tst_allow_strnicmp="no"
2381     fi
2382   fi
2383   #
2384   AC_MSG_CHECKING([if strnicmp might be used])
2385   if test "$tst_links_strnicmp" = "yes" &&
2386      test "$tst_proto_strnicmp" = "yes" &&
2387      test "$tst_compi_strnicmp" = "yes" &&
2388      test "$tst_allow_strnicmp" = "yes"; then
2389     AC_MSG_RESULT([yes])
2390     AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
2391       [Define to 1 if you have the strnicmp function.])
2392     ac_cv_func_strnicmp="yes"
2393   else
2394     AC_MSG_RESULT([no])
2395     ac_cv_func_strnicmp="no"
2396   fi
2397 ])
2398
2399
2400 dnl CARES_CHECK_FUNC_WRITEV
2401 dnl -------------------------------------------------
2402 dnl Verify if writev is available, prototyped, and
2403 dnl can be compiled. If all of these are true, and
2404 dnl usage has not been previously disallowed with
2405 dnl shell variable cares_disallow_writev, then
2406 dnl HAVE_WRITEV will be defined.
2407
2408 AC_DEFUN([CARES_CHECK_FUNC_WRITEV], [
2409   AC_REQUIRE([CARES_INCLUDES_SYS_UIO])dnl
2410   #
2411   tst_links_writev="unknown"
2412   tst_proto_writev="unknown"
2413   tst_compi_writev="unknown"
2414   tst_allow_writev="unknown"
2415   #
2416   AC_MSG_CHECKING([if writev can be linked])
2417   AC_LINK_IFELSE([
2418     AC_LANG_FUNC_LINK_TRY([writev])
2419   ],[
2420     AC_MSG_RESULT([yes])
2421     tst_links_writev="yes"
2422   ],[
2423     AC_MSG_RESULT([no])
2424     tst_links_writev="no"
2425   ])
2426   #
2427   if test "$tst_links_writev" = "yes"; then
2428     AC_MSG_CHECKING([if writev is prototyped])
2429     AC_EGREP_CPP([writev],[
2430       $cares_includes_sys_uio
2431     ],[
2432       AC_MSG_RESULT([yes])
2433       tst_proto_writev="yes"
2434     ],[
2435       AC_MSG_RESULT([no])
2436       tst_proto_writev="no"
2437     ])
2438   fi
2439   #
2440   if test "$tst_proto_writev" = "yes"; then
2441     AC_MSG_CHECKING([if writev is compilable])
2442     AC_COMPILE_IFELSE([
2443       AC_LANG_PROGRAM([[
2444         $cares_includes_sys_uio
2445       ]],[[
2446         if(0 != writev(0, 0, 0))
2447           return 1;
2448       ]])
2449     ],[
2450       AC_MSG_RESULT([yes])
2451       tst_compi_writev="yes"
2452     ],[
2453       AC_MSG_RESULT([no])
2454       tst_compi_writev="no"
2455     ])
2456   fi
2457   #
2458   if test "$tst_compi_writev" = "yes"; then
2459     AC_MSG_CHECKING([if writev usage allowed])
2460     if test "x$cares_disallow_writev" != "xyes"; then
2461       AC_MSG_RESULT([yes])
2462       tst_allow_writev="yes"
2463     else
2464       AC_MSG_RESULT([no])
2465       tst_allow_writev="no"
2466     fi
2467   fi
2468   #
2469   AC_MSG_CHECKING([if writev might be used])
2470   if test "$tst_links_writev" = "yes" &&
2471      test "$tst_proto_writev" = "yes" &&
2472      test "$tst_compi_writev" = "yes" &&
2473      test "$tst_allow_writev" = "yes"; then
2474     AC_MSG_RESULT([yes])
2475     AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
2476       [Define to 1 if you have the writev function.])
2477     ac_cv_func_writev="yes"
2478   else
2479     AC_MSG_RESULT([no])
2480     ac_cv_func_writev="no"
2481   fi
2482 ])