520e99a29b4c6b7dff5a98a96f929dc8894b6e99
[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 8
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_NETDB
50 dnl -------------------------------------------------
51 dnl Set up variable with list of headers that must be
52 dnl included when netdb.h is to be included.
53
54 AC_DEFUN([CARES_INCLUDES_NETDB], [
55 cares_includes_netdb="\
56 /* includes start */
57 #ifdef HAVE_SYS_TYPES_H
58 #  include <sys/types.h>
59 #endif
60 #ifdef HAVE_NETDB_H
61 #  include <netdb.h>
62 #endif
63 /* includes end */"
64   AC_CHECK_HEADERS(
65     sys/types.h netdb.h,
66     [], [], [$cares_includes_netdb])
67 ])
68
69
70 dnl CARES_INCLUDES_STRING
71 dnl -------------------------------------------------
72 dnl Set up variable with list of headers that must be
73 dnl included when string(s).h is to be included.
74
75 AC_DEFUN([CARES_INCLUDES_STRING], [
76 cares_includes_string="\
77 /* includes start */
78 #ifdef HAVE_SYS_TYPES_H
79 #  include <sys/types.h>
80 #endif
81 #ifdef HAVE_STRING_H
82 #  include <string.h>
83 #endif
84 #ifdef HAVE_STRINGS_H
85 #  include <strings.h>
86 #endif
87 /* includes end */"
88   AC_CHECK_HEADERS(
89     sys/types.h string.h strings.h,
90     [], [], [$cares_includes_string])
91 ])
92
93
94 dnl CARES_INCLUDES_SYS_UIO
95 dnl -------------------------------------------------
96 dnl Set up variable with list of headers that must be
97 dnl included when sys/uio.h is to be included.
98
99 AC_DEFUN([CARES_INCLUDES_SYS_UIO], [
100 cares_includes_sys_uio="\
101 /* includes start */
102 #ifdef HAVE_SYS_TYPES_H
103 #  include <sys/types.h>
104 #endif
105 #ifdef HAVE_SYS_UIO_H
106 #  include <sys/uio.h>
107 #endif
108 /* includes end */"
109   AC_CHECK_HEADERS(
110     sys/types.h sys/uio.h,
111     [], [], [$cares_includes_sys_uio])
112 ])
113
114
115 dnl CARES_INCLUDES_UNISTD
116 dnl -------------------------------------------------
117 dnl Set up variable with list of headers that must be
118 dnl included when unistd.h is to be included.
119
120 AC_DEFUN([CARES_INCLUDES_UNISTD], [
121 cares_includes_unistd="\
122 /* includes start */
123 #ifdef HAVE_SYS_TYPES_H
124 #  include <sys/types.h>
125 #endif
126 #ifdef HAVE_UNISTD_H
127 #  include <unistd.h>
128 #endif
129 /* includes end */"
130   AC_CHECK_HEADERS(
131     sys/types.h unistd.h,
132     [], [], [$cares_includes_unistd])
133 ])
134
135
136 dnl CARES_INCLUDES_WINSOCK2
137 dnl -------------------------------------------------
138 dnl Set up variable with list of headers that must be
139 dnl included when winsock(2).h is to be included.
140
141 AC_DEFUN([CARES_INCLUDES_WINSOCK2], [
142 cares_includes_winsock2="\
143 /* includes start */
144 #ifdef HAVE_WINDOWS_H
145 #  ifndef WIN32_LEAN_AND_MEAN
146 #    define WIN32_LEAN_AND_MEAN
147 #  endif
148 #  include <windows.h>
149 #  ifdef HAVE_WINSOCK2_H
150 #    include <winsock2.h>
151 #  else
152 #    ifdef HAVE_WINSOCK_H
153 #      include <winsock.h>
154 #    endif
155 #  endif
156 #endif
157 /* includes end */"
158   CURL_CHECK_HEADER_WINDOWS
159   CURL_CHECK_HEADER_WINSOCK
160   CURL_CHECK_HEADER_WINSOCK2
161 ])
162
163
164 dnl CARES_CHECK_FUNC_GETHOSTNAME
165 dnl -------------------------------------------------
166 dnl Verify if gethostname is available, prototyped, and
167 dnl can be compiled. If all of these are true, and
168 dnl usage has not been previously disallowed with
169 dnl shell variable cares_disallow_gethostname, then
170 dnl HAVE_GETHOSTNAME will be defined.
171
172 AC_DEFUN([CARES_CHECK_FUNC_GETHOSTNAME], [
173   AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
174   AC_REQUIRE([CARES_INCLUDES_UNISTD])dnl
175   #
176   tst_links_gethostname="unknown"
177   tst_proto_gethostname="unknown"
178   tst_compi_gethostname="unknown"
179   tst_allow_gethostname="unknown"
180   #
181   AC_MSG_CHECKING([if gethostname can be linked])
182   AC_LINK_IFELSE([
183     AC_LANG_PROGRAM([[
184       $cares_includes_winsock2
185       $cares_includes_unistd
186     ]],[[
187       if(0 != gethostname(0, 0))
188         return 1;
189     ]])
190   ],[
191     AC_MSG_RESULT([yes])
192     tst_links_gethostname="yes"
193   ],[
194     AC_MSG_RESULT([no])
195     tst_links_gethostname="no"
196   ])
197   #
198   if test "$tst_links_gethostname" = "yes"; then
199     AC_MSG_CHECKING([if gethostname is prototyped])
200     AC_EGREP_CPP([gethostname],[
201       $cares_includes_winsock2
202       $cares_includes_unistd
203     ],[
204       AC_MSG_RESULT([yes])
205       tst_proto_gethostname="yes"
206     ],[
207       AC_MSG_RESULT([no])
208       tst_proto_gethostname="no"
209     ])
210   fi
211   #
212   if test "$tst_proto_gethostname" = "yes"; then
213     AC_MSG_CHECKING([if gethostname is compilable])
214     AC_COMPILE_IFELSE([
215       AC_LANG_PROGRAM([[
216         $cares_includes_winsock2
217         $cares_includes_unistd
218       ]],[[
219         if(0 != gethostname(0, 0))
220           return 1;
221       ]])
222     ],[
223       AC_MSG_RESULT([yes])
224       tst_compi_gethostname="yes"
225     ],[
226       AC_MSG_RESULT([no])
227       tst_compi_gethostname="no"
228     ])
229   fi
230   #
231   if test "$tst_compi_gethostname" = "yes"; then
232     AC_MSG_CHECKING([if gethostname usage allowed])
233     if test "x$cares_disallow_gethostname" != "xyes"; then
234       AC_MSG_RESULT([yes])
235       tst_allow_gethostname="yes"
236     else
237       AC_MSG_RESULT([no])
238       tst_allow_gethostname="no"
239     fi
240   fi
241   #
242   AC_MSG_CHECKING([if gethostname might be used])
243   if test "$tst_links_gethostname" = "yes" &&
244      test "$tst_proto_gethostname" = "yes" &&
245      test "$tst_compi_gethostname" = "yes" &&
246      test "$tst_allow_gethostname" = "yes"; then
247     AC_MSG_RESULT([yes])
248     AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
249       [Define to 1 if you have the gethostname function.])
250     ac_cv_func_gethostname="yes"
251   else
252     AC_MSG_RESULT([no])
253     ac_cv_func_gethostname="no"
254   fi
255 ])
256
257
258 dnl CARES_CHECK_FUNC_GETSERVBYPORT_R
259 dnl -------------------------------------------------
260 dnl Verify if getservbyport_r is available, prototyped,
261 dnl and can be compiled. If all of these are true, and
262 dnl usage has not been previously disallowed with
263 dnl shell variable cares_disallow_getservbyport_r, then
264 dnl HAVE_GETSERVBYPORT_R will be defined.
265
266 AC_DEFUN([CARES_CHECK_FUNC_GETSERVBYPORT_R], [
267   AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
268   #
269   tst_links_getservbyport_r="unknown"
270   tst_proto_getservbyport_r="unknown"
271   tst_compi_getservbyport_r="unknown"
272   tst_allow_getservbyport_r="unknown"
273   tst_nargs_getservbyport_r="unknown"
274   #
275   AC_MSG_CHECKING([if getservbyport_r can be linked])
276   AC_LINK_IFELSE([
277     AC_LANG_FUNC_LINK_TRY([getservbyport_r])
278   ],[
279     AC_MSG_RESULT([yes])
280     tst_links_getservbyport_r="yes"
281   ],[
282     AC_MSG_RESULT([no])
283     tst_links_getservbyport_r="no"
284   ])
285   #
286   if test "$tst_links_getservbyport_r" = "yes"; then
287     AC_MSG_CHECKING([if getservbyport_r is prototyped])
288     AC_EGREP_CPP([getservbyport_r],[
289       $cares_includes_netdb
290     ],[
291       AC_MSG_RESULT([yes])
292       tst_proto_getservbyport_r="yes"
293     ],[
294       AC_MSG_RESULT([no])
295       tst_proto_getservbyport_r="no"
296     ])
297   fi
298   #
299   if test "$tst_proto_getservbyport_r" = "yes"; then
300     if test "$tst_nargs_getservbyport_r" = "unknown"; then
301       AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
302       AC_COMPILE_IFELSE([
303         AC_LANG_PROGRAM([[
304           $cares_includes_netdb
305         ]],[[
306           if(0 != getservbyport_r(0, 0, 0, 0))
307             return 1;
308         ]])
309       ],[
310         AC_MSG_RESULT([yes])
311         tst_compi_getservbyport_r="yes"
312         tst_nargs_getservbyport_r="4"
313       ],[
314         AC_MSG_RESULT([no])
315         tst_compi_getservbyport_r="no"
316       ])
317     fi
318     if test "$tst_nargs_getservbyport_r" = "unknown"; then
319       AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
320       AC_COMPILE_IFELSE([
321         AC_LANG_PROGRAM([[
322           $cares_includes_netdb
323         ]],[[
324           if(0 != getservbyport_r(0, 0, 0, 0, 0))
325             return 1;
326         ]])
327       ],[
328         AC_MSG_RESULT([yes])
329         tst_compi_getservbyport_r="yes"
330         tst_nargs_getservbyport_r="5"
331       ],[
332         AC_MSG_RESULT([no])
333         tst_compi_getservbyport_r="no"
334       ])
335     fi
336     if test "$tst_nargs_getservbyport_r" = "unknown"; then
337       AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
338       AC_COMPILE_IFELSE([
339         AC_LANG_PROGRAM([[
340           $cares_includes_netdb
341         ]],[[
342           if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
343             return 1;
344         ]])
345       ],[
346         AC_MSG_RESULT([yes])
347         tst_compi_getservbyport_r="yes"
348         tst_nargs_getservbyport_r="6"
349       ],[
350         AC_MSG_RESULT([no])
351         tst_compi_getservbyport_r="no"
352       ])
353     fi
354     AC_MSG_CHECKING([if getservbyport_r is compilable])
355     if test "$tst_compi_getservbyport_r" = "yes"; then
356       AC_MSG_RESULT([yes])
357     else
358       AC_MSG_RESULT([no])
359     fi
360   fi
361   #
362   if test "$tst_compi_getservbyport_r" = "yes"; then
363     AC_MSG_CHECKING([if getservbyport_r usage allowed])
364     if test "x$cares_disallow_getservbyport_r" != "xyes"; then
365       AC_MSG_RESULT([yes])
366       tst_allow_getservbyport_r="yes"
367     else
368       AC_MSG_RESULT([no])
369       tst_allow_getservbyport_r="no"
370     fi
371   fi
372   #
373   AC_MSG_CHECKING([if getservbyport_r might be used])
374   if test "$tst_links_getservbyport_r" = "yes" &&
375      test "$tst_proto_getservbyport_r" = "yes" &&
376      test "$tst_compi_getservbyport_r" = "yes" &&
377      test "$tst_allow_getservbyport_r" = "yes"; then
378     AC_MSG_RESULT([yes])
379     AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
380       [Define to 1 if you have the getservbyport_r function.])
381     AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
382       [Specifies the number of arguments to getservbyport_r])
383     if test "$tst_nargs_getservbyport_r" -eq "4"; then
384       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
385         [Specifies the size of the buffer to pass to getservbyport_r])
386     else
387       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
388         [Specifies the size of the buffer to pass to getservbyport_r])
389     fi
390     ac_cv_func_getservbyport_r="yes"
391   else
392     AC_MSG_RESULT([no])
393     ac_cv_func_getservbyport_r="no"
394   fi
395 ])
396
397
398 dnl CARES_CHECK_FUNC_INET_NTOP
399 dnl -------------------------------------------------
400 dnl Verify if inet_ntop is available, prototyped, can
401 dnl be compiled and seems to work. If all of these are
402 dnl true, and usage has not been previously disallowed
403 dnl with shell variable cares_disallow_inet_ntop, then
404 dnl HAVE_INET_NTOP will be defined.
405
406 AC_DEFUN([CARES_CHECK_FUNC_INET_NTOP], [
407   AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
408   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
409   #
410   tst_links_inet_ntop="unknown"
411   tst_proto_inet_ntop="unknown"
412   tst_compi_inet_ntop="unknown"
413   tst_works_inet_ntop="unknown"
414   tst_allow_inet_ntop="unknown"
415   #
416   AC_MSG_CHECKING([if inet_ntop can be linked])
417   AC_LINK_IFELSE([
418     AC_LANG_FUNC_LINK_TRY([inet_ntop])
419   ],[
420     AC_MSG_RESULT([yes])
421     tst_links_inet_ntop="yes"
422   ],[
423     AC_MSG_RESULT([no])
424     tst_links_inet_ntop="no"
425   ])
426   #
427   if test "$tst_links_inet_ntop" = "yes"; then
428     AC_MSG_CHECKING([if inet_ntop is prototyped])
429     AC_EGREP_CPP([inet_ntop],[
430       $cares_includes_arpa_inet
431     ],[
432       AC_MSG_RESULT([yes])
433       tst_proto_inet_ntop="yes"
434     ],[
435       AC_MSG_RESULT([no])
436       tst_proto_inet_ntop="no"
437     ])
438   fi
439   #
440   if test "$tst_proto_inet_ntop" = "yes"; then
441     AC_MSG_CHECKING([if inet_ntop is compilable])
442     AC_COMPILE_IFELSE([
443       AC_LANG_PROGRAM([[
444         $cares_includes_arpa_inet
445       ]],[[
446         if(0 != inet_ntop(0, 0, 0, 0))
447           return 1;
448       ]])
449     ],[
450       AC_MSG_RESULT([yes])
451       tst_compi_inet_ntop="yes"
452     ],[
453       AC_MSG_RESULT([no])
454       tst_compi_inet_ntop="no"
455     ])
456   fi
457   #
458   dnl only do runtime verification when not cross-compiling
459   if test "x$cross_compiling" != "xyes" &&
460     test "$tst_compi_inet_ntop" = "yes"; then
461     AC_MSG_CHECKING([if inet_ntop seems to work])
462     AC_RUN_IFELSE([
463       AC_LANG_PROGRAM([[
464         $cares_includes_arpa_inet
465         $cares_includes_string
466       ]],[[
467         char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
468         char ipv4res[sizeof "255.255.255.255"];
469         unsigned char ipv6a[26];
470         unsigned char ipv4a[5];
471         char *ipv6ptr = 0;
472         char *ipv4ptr = 0;
473         /* - */
474         ipv4res[0] = '\0';
475         ipv4a[0] = 0xc0;
476         ipv4a[1] = 0xa8;
477         ipv4a[2] = 0x64;
478         ipv4a[3] = 0x01;
479         ipv4a[4] = 0x01;
480         /* - */
481         ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
482         if(!ipv4ptr)
483           exit(1); /* fail */
484         if(ipv4ptr != ipv4res)
485           exit(1); /* fail */
486         if(!ipv4ptr[0])
487           exit(1); /* fail */
488         if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
489           exit(1); /* fail */
490         /* - */
491         ipv6res[0] = '\0';
492         memset(ipv6a, 0, sizeof(ipv6a));
493         ipv6a[0] = 0xfe;
494         ipv6a[1] = 0x80;
495         ipv6a[8] = 0x02;
496         ipv6a[9] = 0x14;
497         ipv6a[10] = 0x4f;
498         ipv6a[11] = 0xff;
499         ipv6a[12] = 0xfe;
500         ipv6a[13] = 0x0b;
501         ipv6a[14] = 0x76;
502         ipv6a[15] = 0xc8;
503         ipv6a[25] = 0x01;
504         /* - */
505         ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
506         if(!ipv6ptr)
507           exit(1); /* fail */
508         if(ipv6ptr != ipv6res)
509           exit(1); /* fail */
510         if(!ipv6ptr[0])
511           exit(1); /* fail */
512         if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0)
513           exit(1); /* fail */
514         /* - */
515         exit(0);
516       ]])
517     ],[
518       AC_MSG_RESULT([yes])
519       tst_works_inet_ntop="yes"
520     ],[
521       AC_MSG_RESULT([no])
522       tst_works_inet_ntop="no"
523     ])
524   fi
525   #
526   if test "$tst_compi_inet_ntop" = "yes" &&
527     test "$tst_works_inet_ntop" != "no"; then
528     AC_MSG_CHECKING([if inet_ntop usage allowed])
529     if test "x$cares_disallow_inet_ntop" != "xyes"; then
530       AC_MSG_RESULT([yes])
531       tst_allow_inet_ntop="yes"
532     else
533       AC_MSG_RESULT([no])
534       tst_allow_inet_ntop="no"
535     fi
536   fi
537   #
538   AC_MSG_CHECKING([if inet_ntop might be used])
539   if test "$tst_links_inet_ntop" = "yes" &&
540      test "$tst_proto_inet_ntop" = "yes" &&
541      test "$tst_compi_inet_ntop" = "yes" &&
542      test "$tst_allow_inet_ntop" = "yes" &&
543      test "$tst_works_inet_ntop" != "no"; then
544     AC_MSG_RESULT([yes])
545     AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, 1,
546       [Define to 1 if you have a IPv6 capable working inet_ntop function.])
547     ac_cv_func_inet_ntop="yes"
548   else
549     AC_MSG_RESULT([no])
550     ac_cv_func_inet_ntop="no"
551   fi
552 ])
553
554
555 dnl CARES_CHECK_FUNC_INET_PTON
556 dnl -------------------------------------------------
557 dnl Verify if inet_pton is available, prototyped, can
558 dnl be compiled and seems to work. If all of these are
559 dnl true, and usage has not been previously disallowed
560 dnl with shell variable cares_disallow_inet_pton, then
561 dnl HAVE_INET_PTON will be defined.
562
563 AC_DEFUN([CARES_CHECK_FUNC_INET_PTON], [
564   AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
565   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
566   #
567   tst_links_inet_pton="unknown"
568   tst_proto_inet_pton="unknown"
569   tst_compi_inet_pton="unknown"
570   tst_works_inet_pton="unknown"
571   tst_allow_inet_pton="unknown"
572   #
573   AC_MSG_CHECKING([if inet_pton can be linked])
574   AC_LINK_IFELSE([
575     AC_LANG_FUNC_LINK_TRY([inet_pton])
576   ],[
577     AC_MSG_RESULT([yes])
578     tst_links_inet_pton="yes"
579   ],[
580     AC_MSG_RESULT([no])
581     tst_links_inet_pton="no"
582   ])
583   #
584   if test "$tst_links_inet_pton" = "yes"; then
585     AC_MSG_CHECKING([if inet_pton is prototyped])
586     AC_EGREP_CPP([inet_pton],[
587       $cares_includes_arpa_inet
588     ],[
589       AC_MSG_RESULT([yes])
590       tst_proto_inet_pton="yes"
591     ],[
592       AC_MSG_RESULT([no])
593       tst_proto_inet_pton="no"
594     ])
595   fi
596   #
597   if test "$tst_proto_inet_pton" = "yes"; then
598     AC_MSG_CHECKING([if inet_pton is compilable])
599     AC_COMPILE_IFELSE([
600       AC_LANG_PROGRAM([[
601         $cares_includes_arpa_inet
602       ]],[[
603         if(0 != inet_pton(0, 0, 0))
604           return 1;
605       ]])
606     ],[
607       AC_MSG_RESULT([yes])
608       tst_compi_inet_pton="yes"
609     ],[
610       AC_MSG_RESULT([no])
611       tst_compi_inet_pton="no"
612     ])
613   fi
614   #
615   dnl only do runtime verification when not cross-compiling
616   if test "x$cross_compiling" != "xyes" &&
617     test "$tst_compi_inet_pton" = "yes"; then
618     AC_MSG_CHECKING([if inet_pton seems to work])
619     AC_RUN_IFELSE([
620       AC_LANG_PROGRAM([[
621         $cares_includes_arpa_inet
622         $cares_includes_string
623       ]],[[
624         unsigned char ipv6a[26];
625         unsigned char ipv4a[5];
626         const char *ipv6src = "fe80::214:4fff:fe0b:76c8";
627         const char *ipv4src = "192.168.100.1";
628         /* - */
629         memset(ipv4a, 1, sizeof(ipv4a));
630         if(1 != inet_pton(AF_INET, ipv4src, ipv4a))
631           exit(1); /* fail */
632         /* - */
633         if( (ipv4a[0] != 0xc0) ||
634             (ipv4a[1] != 0xa8) ||
635             (ipv4a[2] != 0x64) ||
636             (ipv4a[3] != 0x01) ||
637             (ipv4a[4] != 0x01) )
638           exit(1); /* fail */
639         /* - */
640         memset(ipv6a, 1, sizeof(ipv6a));
641         if(1 != inet_pton(AF_INET6, ipv6src, ipv6a))
642           exit(1); /* fail */
643         /* - */
644         ipv6res[0] = '\0';
645         memset(ipv6a, 0, sizeof(ipv6a));
646         if( (ipv6a[0]  != 0xfe) ||
647             (ipv6a[1]  != 0x80) ||
648             (ipv6a[8]  != 0x02) ||
649             (ipv6a[9]  != 0x14) ||
650             (ipv6a[10] != 0x4f) ||
651             (ipv6a[11] != 0xff) ||
652             (ipv6a[12] != 0xfe) ||
653             (ipv6a[13] != 0x0b) ||
654             (ipv6a[14] != 0x76) ||
655             (ipv6a[15] != 0xc8) ||
656             (ipv6a[25] != 0x01) )
657           exit(1); /* fail */
658         /* - */
659         if( (ipv6a[2]  != 0x0) ||
660             (ipv6a[3]  != 0x0) ||
661             (ipv6a[4]  != 0x0) ||
662             (ipv6a[5]  != 0x0) ||
663             (ipv6a[6]  != 0x0) ||
664             (ipv6a[7]  != 0x0) ||
665             (ipv6a[16] != 0x0) ||
666             (ipv6a[17] != 0x0) ||
667             (ipv6a[18] != 0x0) ||
668             (ipv6a[19] != 0x0) ||
669             (ipv6a[20] != 0x0) ||
670             (ipv6a[21] != 0x0) ||
671             (ipv6a[22] != 0x0) ||
672             (ipv6a[23] != 0x0) ||
673             (ipv6a[24] != 0x0) )
674           exit(1); /* fail */
675         /* - */
676         exit(0);
677       ]])
678     ],[
679       AC_MSG_RESULT([yes])
680       tst_works_inet_pton="yes"
681     ],[
682       AC_MSG_RESULT([no])
683       tst_works_inet_pton="no"
684     ])
685   fi
686   #
687   if test "$tst_compi_inet_pton" = "yes" &&
688     test "$tst_works_inet_pton" != "no"; then
689     AC_MSG_CHECKING([if inet_pton usage allowed])
690     if test "x$cares_disallow_inet_pton" != "xyes"; then
691       AC_MSG_RESULT([yes])
692       tst_allow_inet_pton="yes"
693     else
694       AC_MSG_RESULT([no])
695       tst_allow_inet_pton="no"
696     fi
697   fi
698   #
699   AC_MSG_CHECKING([if inet_pton might be used])
700   if test "$tst_links_inet_pton" = "yes" &&
701      test "$tst_proto_inet_pton" = "yes" &&
702      test "$tst_compi_inet_pton" = "yes" &&
703      test "$tst_allow_inet_pton" = "yes" &&
704      test "$tst_works_inet_pton" != "no"; then
705     AC_MSG_RESULT([yes])
706     AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1,
707       [Define to 1 if you have a IPv6 capable working inet_pton function.])
708     ac_cv_func_inet_pton="yes"
709   else
710     AC_MSG_RESULT([no])
711     ac_cv_func_inet_pton="no"
712   fi
713 ])
714
715
716 dnl CARES_CHECK_FUNC_STRCASECMP
717 dnl -------------------------------------------------
718 dnl Verify if strcasecmp is available, prototyped, and
719 dnl can be compiled. If all of these are true, and
720 dnl usage has not been previously disallowed with
721 dnl shell variable cares_disallow_strcasecmp, then
722 dnl HAVE_STRCASECMP will be defined.
723
724 AC_DEFUN([CARES_CHECK_FUNC_STRCASECMP], [
725   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
726   #
727   tst_links_strcasecmp="unknown"
728   tst_proto_strcasecmp="unknown"
729   tst_compi_strcasecmp="unknown"
730   tst_allow_strcasecmp="unknown"
731   #
732   AC_MSG_CHECKING([if strcasecmp can be linked])
733   AC_LINK_IFELSE([
734     AC_LANG_FUNC_LINK_TRY([strcasecmp])
735   ],[
736     AC_MSG_RESULT([yes])
737     tst_links_strcasecmp="yes"
738   ],[
739     AC_MSG_RESULT([no])
740     tst_links_strcasecmp="no"
741   ])
742   #
743   if test "$tst_links_strcasecmp" = "yes"; then
744     AC_MSG_CHECKING([if strcasecmp is prototyped])
745     AC_EGREP_CPP([strcasecmp],[
746       $cares_includes_string
747     ],[
748       AC_MSG_RESULT([yes])
749       tst_proto_strcasecmp="yes"
750     ],[
751       AC_MSG_RESULT([no])
752       tst_proto_strcasecmp="no"
753     ])
754   fi
755   #
756   if test "$tst_proto_strcasecmp" = "yes"; then
757     AC_MSG_CHECKING([if strcasecmp is compilable])
758     AC_COMPILE_IFELSE([
759       AC_LANG_PROGRAM([[
760         $cares_includes_string
761       ]],[[
762         if(0 != strcasecmp(0, 0))
763           return 1;
764       ]])
765     ],[
766       AC_MSG_RESULT([yes])
767       tst_compi_strcasecmp="yes"
768     ],[
769       AC_MSG_RESULT([no])
770       tst_compi_strcasecmp="no"
771     ])
772   fi
773   #
774   if test "$tst_compi_strcasecmp" = "yes"; then
775     AC_MSG_CHECKING([if strcasecmp usage allowed])
776     if test "x$cares_disallow_strcasecmp" != "xyes"; then
777       AC_MSG_RESULT([yes])
778       tst_allow_strcasecmp="yes"
779     else
780       AC_MSG_RESULT([no])
781       tst_allow_strcasecmp="no"
782     fi
783   fi
784   #
785   AC_MSG_CHECKING([if strcasecmp might be used])
786   if test "$tst_links_strcasecmp" = "yes" &&
787      test "$tst_proto_strcasecmp" = "yes" &&
788      test "$tst_compi_strcasecmp" = "yes" &&
789      test "$tst_allow_strcasecmp" = "yes"; then
790     AC_MSG_RESULT([yes])
791     AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
792       [Define to 1 if you have the strcasecmp function.])
793     ac_cv_func_strcasecmp="yes"
794   else
795     AC_MSG_RESULT([no])
796     ac_cv_func_strcasecmp="no"
797   fi
798 ])
799
800
801 dnl CARES_CHECK_FUNC_STRCMPI
802 dnl -------------------------------------------------
803 dnl Verify if strcmpi is available, prototyped, and
804 dnl can be compiled. If all of these are true, and
805 dnl usage has not been previously disallowed with
806 dnl shell variable cares_disallow_strcmpi, then
807 dnl HAVE_STRCMPI will be defined.
808
809 AC_DEFUN([CARES_CHECK_FUNC_STRCMPI], [
810   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
811   #
812   tst_links_strcmpi="unknown"
813   tst_proto_strcmpi="unknown"
814   tst_compi_strcmpi="unknown"
815   tst_allow_strcmpi="unknown"
816   #
817   AC_MSG_CHECKING([if strcmpi can be linked])
818   AC_LINK_IFELSE([
819     AC_LANG_FUNC_LINK_TRY([strcmpi])
820   ],[
821     AC_MSG_RESULT([yes])
822     tst_links_strcmpi="yes"
823   ],[
824     AC_MSG_RESULT([no])
825     tst_links_strcmpi="no"
826   ])
827   #
828   if test "$tst_links_strcmpi" = "yes"; then
829     AC_MSG_CHECKING([if strcmpi is prototyped])
830     AC_EGREP_CPP([strcmpi],[
831       $cares_includes_string
832     ],[
833       AC_MSG_RESULT([yes])
834       tst_proto_strcmpi="yes"
835     ],[
836       AC_MSG_RESULT([no])
837       tst_proto_strcmpi="no"
838     ])
839   fi
840   #
841   if test "$tst_proto_strcmpi" = "yes"; then
842     AC_MSG_CHECKING([if strcmpi is compilable])
843     AC_COMPILE_IFELSE([
844       AC_LANG_PROGRAM([[
845         $cares_includes_string
846       ]],[[
847         if(0 != strcmpi(0, 0))
848           return 1;
849       ]])
850     ],[
851       AC_MSG_RESULT([yes])
852       tst_compi_strcmpi="yes"
853     ],[
854       AC_MSG_RESULT([no])
855       tst_compi_strcmpi="no"
856     ])
857   fi
858   #
859   if test "$tst_compi_strcmpi" = "yes"; then
860     AC_MSG_CHECKING([if strcmpi usage allowed])
861     if test "x$cares_disallow_strcmpi" != "xyes"; then
862       AC_MSG_RESULT([yes])
863       tst_allow_strcmpi="yes"
864     else
865       AC_MSG_RESULT([no])
866       tst_allow_strcmpi="no"
867     fi
868   fi
869   #
870   AC_MSG_CHECKING([if strcmpi might be used])
871   if test "$tst_links_strcmpi" = "yes" &&
872      test "$tst_proto_strcmpi" = "yes" &&
873      test "$tst_compi_strcmpi" = "yes" &&
874      test "$tst_allow_strcmpi" = "yes"; then
875     AC_MSG_RESULT([yes])
876     AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
877       [Define to 1 if you have the strcmpi function.])
878     ac_cv_func_strcmpi="yes"
879   else
880     AC_MSG_RESULT([no])
881     ac_cv_func_strcmpi="no"
882   fi
883 ])
884
885
886 dnl CARES_CHECK_FUNC_STRDUP
887 dnl -------------------------------------------------
888 dnl Verify if strdup is available, prototyped, and
889 dnl can be compiled. If all of these are true, and
890 dnl usage has not been previously disallowed with
891 dnl shell variable cares_disallow_strdup, then
892 dnl HAVE_STRDUP will be defined.
893
894 AC_DEFUN([CARES_CHECK_FUNC_STRDUP], [
895   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
896   #
897   tst_links_strdup="unknown"
898   tst_proto_strdup="unknown"
899   tst_compi_strdup="unknown"
900   tst_allow_strdup="unknown"
901   #
902   AC_MSG_CHECKING([if strdup can be linked])
903   AC_LINK_IFELSE([
904     AC_LANG_FUNC_LINK_TRY([strdup])
905   ],[
906     AC_MSG_RESULT([yes])
907     tst_links_strdup="yes"
908   ],[
909     AC_MSG_RESULT([no])
910     tst_links_strdup="no"
911   ])
912   #
913   if test "$tst_links_strdup" = "yes"; then
914     AC_MSG_CHECKING([if strdup is prototyped])
915     AC_EGREP_CPP([strdup],[
916       $cares_includes_string
917     ],[
918       AC_MSG_RESULT([yes])
919       tst_proto_strdup="yes"
920     ],[
921       AC_MSG_RESULT([no])
922       tst_proto_strdup="no"
923     ])
924   fi
925   #
926   if test "$tst_proto_strdup" = "yes"; then
927     AC_MSG_CHECKING([if strdup is compilable])
928     AC_COMPILE_IFELSE([
929       AC_LANG_PROGRAM([[
930         $cares_includes_string
931       ]],[[
932         if(0 != strdup(0))
933           return 1;
934       ]])
935     ],[
936       AC_MSG_RESULT([yes])
937       tst_compi_strdup="yes"
938     ],[
939       AC_MSG_RESULT([no])
940       tst_compi_strdup="no"
941     ])
942   fi
943   #
944   if test "$tst_compi_strdup" = "yes"; then
945     AC_MSG_CHECKING([if strdup usage allowed])
946     if test "x$cares_disallow_strdup" != "xyes"; then
947       AC_MSG_RESULT([yes])
948       tst_allow_strdup="yes"
949     else
950       AC_MSG_RESULT([no])
951       tst_allow_strdup="no"
952     fi
953   fi
954   #
955   AC_MSG_CHECKING([if strdup might be used])
956   if test "$tst_links_strdup" = "yes" &&
957      test "$tst_proto_strdup" = "yes" &&
958      test "$tst_compi_strdup" = "yes" &&
959      test "$tst_allow_strdup" = "yes"; then
960     AC_MSG_RESULT([yes])
961     AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
962       [Define to 1 if you have the strdup function.])
963     ac_cv_func_strdup="yes"
964   else
965     AC_MSG_RESULT([no])
966     ac_cv_func_strdup="no"
967   fi
968 ])
969
970
971 dnl CARES_CHECK_FUNC_STRICMP
972 dnl -------------------------------------------------
973 dnl Verify if stricmp is available, prototyped, and
974 dnl can be compiled. If all of these are true, and
975 dnl usage has not been previously disallowed with
976 dnl shell variable cares_disallow_stricmp, then
977 dnl HAVE_STRICMP will be defined.
978
979 AC_DEFUN([CARES_CHECK_FUNC_STRICMP], [
980   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
981   #
982   tst_links_stricmp="unknown"
983   tst_proto_stricmp="unknown"
984   tst_compi_stricmp="unknown"
985   tst_allow_stricmp="unknown"
986   #
987   AC_MSG_CHECKING([if stricmp can be linked])
988   AC_LINK_IFELSE([
989     AC_LANG_FUNC_LINK_TRY([stricmp])
990   ],[
991     AC_MSG_RESULT([yes])
992     tst_links_stricmp="yes"
993   ],[
994     AC_MSG_RESULT([no])
995     tst_links_stricmp="no"
996   ])
997   #
998   if test "$tst_links_stricmp" = "yes"; then
999     AC_MSG_CHECKING([if stricmp is prototyped])
1000     AC_EGREP_CPP([stricmp],[
1001       $cares_includes_string
1002     ],[
1003       AC_MSG_RESULT([yes])
1004       tst_proto_stricmp="yes"
1005     ],[
1006       AC_MSG_RESULT([no])
1007       tst_proto_stricmp="no"
1008     ])
1009   fi
1010   #
1011   if test "$tst_proto_stricmp" = "yes"; then
1012     AC_MSG_CHECKING([if stricmp is compilable])
1013     AC_COMPILE_IFELSE([
1014       AC_LANG_PROGRAM([[
1015         $cares_includes_string
1016       ]],[[
1017         if(0 != stricmp(0, 0))
1018           return 1;
1019       ]])
1020     ],[
1021       AC_MSG_RESULT([yes])
1022       tst_compi_stricmp="yes"
1023     ],[
1024       AC_MSG_RESULT([no])
1025       tst_compi_stricmp="no"
1026     ])
1027   fi
1028   #
1029   if test "$tst_compi_stricmp" = "yes"; then
1030     AC_MSG_CHECKING([if stricmp usage allowed])
1031     if test "x$cares_disallow_stricmp" != "xyes"; then
1032       AC_MSG_RESULT([yes])
1033       tst_allow_stricmp="yes"
1034     else
1035       AC_MSG_RESULT([no])
1036       tst_allow_stricmp="no"
1037     fi
1038   fi
1039   #
1040   AC_MSG_CHECKING([if stricmp might be used])
1041   if test "$tst_links_stricmp" = "yes" &&
1042      test "$tst_proto_stricmp" = "yes" &&
1043      test "$tst_compi_stricmp" = "yes" &&
1044      test "$tst_allow_stricmp" = "yes"; then
1045     AC_MSG_RESULT([yes])
1046     AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
1047       [Define to 1 if you have the stricmp function.])
1048     ac_cv_func_stricmp="yes"
1049   else
1050     AC_MSG_RESULT([no])
1051     ac_cv_func_stricmp="no"
1052   fi
1053 ])
1054
1055
1056 dnl CARES_CHECK_FUNC_STRNCASECMP
1057 dnl -------------------------------------------------
1058 dnl Verify if strncasecmp is available, prototyped, and
1059 dnl can be compiled. If all of these are true, and
1060 dnl usage has not been previously disallowed with
1061 dnl shell variable cares_disallow_strncasecmp, then
1062 dnl HAVE_STRNCASECMP will be defined.
1063
1064 AC_DEFUN([CARES_CHECK_FUNC_STRNCASECMP], [
1065   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
1066   #
1067   tst_links_strncasecmp="unknown"
1068   tst_proto_strncasecmp="unknown"
1069   tst_compi_strncasecmp="unknown"
1070   tst_allow_strncasecmp="unknown"
1071   #
1072   AC_MSG_CHECKING([if strncasecmp can be linked])
1073   AC_LINK_IFELSE([
1074     AC_LANG_FUNC_LINK_TRY([strncasecmp])
1075   ],[
1076     AC_MSG_RESULT([yes])
1077     tst_links_strncasecmp="yes"
1078   ],[
1079     AC_MSG_RESULT([no])
1080     tst_links_strncasecmp="no"
1081   ])
1082   #
1083   if test "$tst_links_strncasecmp" = "yes"; then
1084     AC_MSG_CHECKING([if strncasecmp is prototyped])
1085     AC_EGREP_CPP([strncasecmp],[
1086       $cares_includes_string
1087     ],[
1088       AC_MSG_RESULT([yes])
1089       tst_proto_strncasecmp="yes"
1090     ],[
1091       AC_MSG_RESULT([no])
1092       tst_proto_strncasecmp="no"
1093     ])
1094   fi
1095   #
1096   if test "$tst_proto_strncasecmp" = "yes"; then
1097     AC_MSG_CHECKING([if strncasecmp is compilable])
1098     AC_COMPILE_IFELSE([
1099       AC_LANG_PROGRAM([[
1100         $cares_includes_string
1101       ]],[[
1102         if(0 != strncasecmp(0, 0, 0))
1103           return 1;
1104       ]])
1105     ],[
1106       AC_MSG_RESULT([yes])
1107       tst_compi_strncasecmp="yes"
1108     ],[
1109       AC_MSG_RESULT([no])
1110       tst_compi_strncasecmp="no"
1111     ])
1112   fi
1113   #
1114   if test "$tst_compi_strncasecmp" = "yes"; then
1115     AC_MSG_CHECKING([if strncasecmp usage allowed])
1116     if test "x$cares_disallow_strncasecmp" != "xyes"; then
1117       AC_MSG_RESULT([yes])
1118       tst_allow_strncasecmp="yes"
1119     else
1120       AC_MSG_RESULT([no])
1121       tst_allow_strncasecmp="no"
1122     fi
1123   fi
1124   #
1125   AC_MSG_CHECKING([if strncasecmp might be used])
1126   if test "$tst_links_strncasecmp" = "yes" &&
1127      test "$tst_proto_strncasecmp" = "yes" &&
1128      test "$tst_compi_strncasecmp" = "yes" &&
1129      test "$tst_allow_strncasecmp" = "yes"; then
1130     AC_MSG_RESULT([yes])
1131     AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
1132       [Define to 1 if you have the strncasecmp function.])
1133     ac_cv_func_strncasecmp="yes"
1134   else
1135     AC_MSG_RESULT([no])
1136     ac_cv_func_strncasecmp="no"
1137   fi
1138 ])
1139
1140
1141 dnl CARES_CHECK_FUNC_STRNCMPI
1142 dnl -------------------------------------------------
1143 dnl Verify if strncmpi is available, prototyped, and
1144 dnl can be compiled. If all of these are true, and
1145 dnl usage has not been previously disallowed with
1146 dnl shell variable cares_disallow_strncmpi, then
1147 dnl HAVE_STRNCMPI will be defined.
1148
1149 AC_DEFUN([CARES_CHECK_FUNC_STRNCMPI], [
1150   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
1151   #
1152   tst_links_strncmpi="unknown"
1153   tst_proto_strncmpi="unknown"
1154   tst_compi_strncmpi="unknown"
1155   tst_allow_strncmpi="unknown"
1156   #
1157   AC_MSG_CHECKING([if strncmpi can be linked])
1158   AC_LINK_IFELSE([
1159     AC_LANG_FUNC_LINK_TRY([strncmpi])
1160   ],[
1161     AC_MSG_RESULT([yes])
1162     tst_links_strncmpi="yes"
1163   ],[
1164     AC_MSG_RESULT([no])
1165     tst_links_strncmpi="no"
1166   ])
1167   #
1168   if test "$tst_links_strncmpi" = "yes"; then
1169     AC_MSG_CHECKING([if strncmpi is prototyped])
1170     AC_EGREP_CPP([strncmpi],[
1171       $cares_includes_string
1172     ],[
1173       AC_MSG_RESULT([yes])
1174       tst_proto_strncmpi="yes"
1175     ],[
1176       AC_MSG_RESULT([no])
1177       tst_proto_strncmpi="no"
1178     ])
1179   fi
1180   #
1181   if test "$tst_proto_strncmpi" = "yes"; then
1182     AC_MSG_CHECKING([if strncmpi is compilable])
1183     AC_COMPILE_IFELSE([
1184       AC_LANG_PROGRAM([[
1185         $cares_includes_string
1186       ]],[[
1187         if(0 != strncmpi(0, 0))
1188           return 1;
1189       ]])
1190     ],[
1191       AC_MSG_RESULT([yes])
1192       tst_compi_strncmpi="yes"
1193     ],[
1194       AC_MSG_RESULT([no])
1195       tst_compi_strncmpi="no"
1196     ])
1197   fi
1198   #
1199   if test "$tst_compi_strncmpi" = "yes"; then
1200     AC_MSG_CHECKING([if strncmpi usage allowed])
1201     if test "x$cares_disallow_strncmpi" != "xyes"; then
1202       AC_MSG_RESULT([yes])
1203       tst_allow_strncmpi="yes"
1204     else
1205       AC_MSG_RESULT([no])
1206       tst_allow_strncmpi="no"
1207     fi
1208   fi
1209   #
1210   AC_MSG_CHECKING([if strncmpi might be used])
1211   if test "$tst_links_strncmpi" = "yes" &&
1212      test "$tst_proto_strncmpi" = "yes" &&
1213      test "$tst_compi_strncmpi" = "yes" &&
1214      test "$tst_allow_strncmpi" = "yes"; then
1215     AC_MSG_RESULT([yes])
1216     AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
1217       [Define to 1 if you have the strncmpi function.])
1218     ac_cv_func_strncmpi="yes"
1219   else
1220     AC_MSG_RESULT([no])
1221     ac_cv_func_strncmpi="no"
1222   fi
1223 ])
1224
1225
1226 dnl CARES_CHECK_FUNC_STRNICMP
1227 dnl -------------------------------------------------
1228 dnl Verify if strnicmp is available, prototyped, and
1229 dnl can be compiled. If all of these are true, and
1230 dnl usage has not been previously disallowed with
1231 dnl shell variable cares_disallow_strnicmp, then
1232 dnl HAVE_STRNICMP will be defined.
1233
1234 AC_DEFUN([CARES_CHECK_FUNC_STRNICMP], [
1235   AC_REQUIRE([CARES_INCLUDES_STRING])dnl
1236   #
1237   tst_links_strnicmp="unknown"
1238   tst_proto_strnicmp="unknown"
1239   tst_compi_strnicmp="unknown"
1240   tst_allow_strnicmp="unknown"
1241   #
1242   AC_MSG_CHECKING([if strnicmp can be linked])
1243   AC_LINK_IFELSE([
1244     AC_LANG_FUNC_LINK_TRY([strnicmp])
1245   ],[
1246     AC_MSG_RESULT([yes])
1247     tst_links_strnicmp="yes"
1248   ],[
1249     AC_MSG_RESULT([no])
1250     tst_links_strnicmp="no"
1251   ])
1252   #
1253   if test "$tst_links_strnicmp" = "yes"; then
1254     AC_MSG_CHECKING([if strnicmp is prototyped])
1255     AC_EGREP_CPP([strnicmp],[
1256       $cares_includes_string
1257     ],[
1258       AC_MSG_RESULT([yes])
1259       tst_proto_strnicmp="yes"
1260     ],[
1261       AC_MSG_RESULT([no])
1262       tst_proto_strnicmp="no"
1263     ])
1264   fi
1265   #
1266   if test "$tst_proto_strnicmp" = "yes"; then
1267     AC_MSG_CHECKING([if strnicmp is compilable])
1268     AC_COMPILE_IFELSE([
1269       AC_LANG_PROGRAM([[
1270         $cares_includes_string
1271       ]],[[
1272         if(0 != strnicmp(0, 0))
1273           return 1;
1274       ]])
1275     ],[
1276       AC_MSG_RESULT([yes])
1277       tst_compi_strnicmp="yes"
1278     ],[
1279       AC_MSG_RESULT([no])
1280       tst_compi_strnicmp="no"
1281     ])
1282   fi
1283   #
1284   if test "$tst_compi_strnicmp" = "yes"; then
1285     AC_MSG_CHECKING([if strnicmp usage allowed])
1286     if test "x$cares_disallow_strnicmp" != "xyes"; then
1287       AC_MSG_RESULT([yes])
1288       tst_allow_strnicmp="yes"
1289     else
1290       AC_MSG_RESULT([no])
1291       tst_allow_strnicmp="no"
1292     fi
1293   fi
1294   #
1295   AC_MSG_CHECKING([if strnicmp might be used])
1296   if test "$tst_links_strnicmp" = "yes" &&
1297      test "$tst_proto_strnicmp" = "yes" &&
1298      test "$tst_compi_strnicmp" = "yes" &&
1299      test "$tst_allow_strnicmp" = "yes"; then
1300     AC_MSG_RESULT([yes])
1301     AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
1302       [Define to 1 if you have the strnicmp function.])
1303     ac_cv_func_strnicmp="yes"
1304   else
1305     AC_MSG_RESULT([no])
1306     ac_cv_func_strnicmp="no"
1307   fi
1308 ])
1309
1310
1311 dnl CARES_CHECK_FUNC_WRITEV
1312 dnl -------------------------------------------------
1313 dnl Verify if writev is available, prototyped, and
1314 dnl can be compiled. If all of these are true, and
1315 dnl usage has not been previously disallowed with
1316 dnl shell variable cares_disallow_writev, then
1317 dnl HAVE_WRITEV will be defined.
1318
1319 AC_DEFUN([CARES_CHECK_FUNC_WRITEV], [
1320   AC_REQUIRE([CARES_INCLUDES_SYS_UIO])dnl
1321   #
1322   tst_links_writev="unknown"
1323   tst_proto_writev="unknown"
1324   tst_compi_writev="unknown"
1325   tst_allow_writev="unknown"
1326   #
1327   AC_MSG_CHECKING([if writev can be linked])
1328   AC_LINK_IFELSE([
1329     AC_LANG_FUNC_LINK_TRY([writev])
1330   ],[
1331     AC_MSG_RESULT([yes])
1332     tst_links_writev="yes"
1333   ],[
1334     AC_MSG_RESULT([no])
1335     tst_links_writev="no"
1336   ])
1337   #
1338   if test "$tst_links_writev" = "yes"; then
1339     AC_MSG_CHECKING([if writev is prototyped])
1340     AC_EGREP_CPP([writev],[
1341       $cares_includes_sys_uio
1342     ],[
1343       AC_MSG_RESULT([yes])
1344       tst_proto_writev="yes"
1345     ],[
1346       AC_MSG_RESULT([no])
1347       tst_proto_writev="no"
1348     ])
1349   fi
1350   #
1351   if test "$tst_proto_writev" = "yes"; then
1352     AC_MSG_CHECKING([if writev is compilable])
1353     AC_COMPILE_IFELSE([
1354       AC_LANG_PROGRAM([[
1355         $cares_includes_sys_uio
1356       ]],[[
1357         if(0 != writev(0, 0, 0))
1358           return 1;
1359       ]])
1360     ],[
1361       AC_MSG_RESULT([yes])
1362       tst_compi_writev="yes"
1363     ],[
1364       AC_MSG_RESULT([no])
1365       tst_compi_writev="no"
1366     ])
1367   fi
1368   #
1369   if test "$tst_compi_writev" = "yes"; then
1370     AC_MSG_CHECKING([if writev usage allowed])
1371     if test "x$cares_disallow_writev" != "xyes"; then
1372       AC_MSG_RESULT([yes])
1373       tst_allow_writev="yes"
1374     else
1375       AC_MSG_RESULT([no])
1376       tst_allow_writev="no"
1377     fi
1378   fi
1379   #
1380   AC_MSG_CHECKING([if writev might be used])
1381   if test "$tst_links_writev" = "yes" &&
1382      test "$tst_proto_writev" = "yes" &&
1383      test "$tst_compi_writev" = "yes" &&
1384      test "$tst_allow_writev" = "yes"; then
1385     AC_MSG_RESULT([yes])
1386     AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
1387       [Define to 1 if you have the writev function.])
1388     ac_cv_func_writev="yes"
1389   else
1390     AC_MSG_RESULT([no])
1391     ac_cv_func_writev="no"
1392   fi
1393 ])