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