check for gethostbyaddr and gethostbyname as it is done for other functions
[platform/upstream/curl.git] / m4 / curl-functions.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
13 #
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 # $Id$
22 #***************************************************************************
23
24 # File version for 'aclocal' use. Keep it a single number.
25 # serial 43
26
27
28 dnl CURL_INCLUDES_ARPA_INET
29 dnl -------------------------------------------------
30 dnl Set up variable with list of headers that must be
31 dnl included when arpa/inet.h is to be included.
32
33 AC_DEFUN([CURL_INCLUDES_ARPA_INET], [
34 curl_includes_arpa_inet="\
35 /* includes start */
36 #ifdef HAVE_SYS_TYPES_H
37 #  include <sys/types.h>
38 #endif
39 #ifdef HAVE_SYS_SOCKET_H
40 #  include <sys/socket.h>
41 #endif
42 #ifdef HAVE_NETINET_IN_H
43 #  include <netinet/in.h>
44 #endif
45 #ifdef HAVE_ARPA_INET_H
46 #  include <arpa/inet.h>
47 #endif
48 /* includes end */"
49   AC_CHECK_HEADERS(
50     sys/types.h sys/socket.h netinet/in.h arpa/inet.h,
51     [], [], [$curl_includes_arpa_inet])
52 ])
53
54
55 dnl CURL_INCLUDES_FCNTL
56 dnl -------------------------------------------------
57 dnl Set up variable with list of headers that must be
58 dnl included when fcntl.h is to be included.
59
60 AC_DEFUN([CURL_INCLUDES_FCNTL], [
61 curl_includes_fcntl="\
62 /* includes start */
63 #ifdef HAVE_SYS_TYPES_H
64 #  include <sys/types.h>
65 #endif
66 #ifdef HAVE_UNISTD_H
67 #  include <unistd.h>
68 #endif
69 #ifdef HAVE_FCNTL_H
70 #  include <fcntl.h>
71 #endif
72 /* includes end */"
73   AC_CHECK_HEADERS(
74     sys/types.h unistd.h fcntl.h,
75     [], [], [$curl_includes_fcntl])
76 ])
77
78
79 dnl CURL_INCLUDES_IFADDRS
80 dnl -------------------------------------------------
81 dnl Set up variable with list of headers that must be
82 dnl included when ifaddrs.h is to be included.
83
84 AC_DEFUN([CURL_INCLUDES_IFADDRS], [
85 curl_includes_ifaddrs="\
86 /* includes start */
87 #ifdef HAVE_SYS_TYPES_H
88 #  include <sys/types.h>
89 #endif
90 #ifdef HAVE_SYS_SOCKET_H
91 #  include <sys/socket.h>
92 #endif
93 #ifdef HAVE_NETINET_IN_H
94 #  include <netinet/in.h>
95 #endif
96 #ifdef HAVE_IFADDRS_H
97 #  include <ifaddrs.h>
98 #endif
99 /* includes end */"
100   AC_CHECK_HEADERS(
101     sys/types.h sys/socket.h netinet/in.h ifaddrs.h,
102     [], [], [$curl_includes_ifaddrs])
103 ])
104
105
106 dnl CURL_INCLUDES_NETDB
107 dnl -------------------------------------------------
108 dnl Set up variable with list of headers that must be
109 dnl included when netdb.h is to be included.
110
111 AC_DEFUN([CURL_INCLUDES_NETDB], [
112 curl_includes_netdb="\
113 /* includes start */
114 #ifdef HAVE_SYS_TYPES_H
115 #  include <sys/types.h>
116 #endif
117 #ifdef HAVE_NETDB_H
118 #  include <netdb.h>
119 #endif
120 /* includes end */"
121   AC_CHECK_HEADERS(
122     sys/types.h netdb.h,
123     [], [], [$curl_includes_netdb])
124 ])
125
126
127 dnl CURL_INCLUDES_SETJMP
128 dnl -------------------------------------------------
129 dnl Set up variable with list of headers that must be
130 dnl included when setjmp.h is to be included.
131
132 AC_DEFUN([CURL_INCLUDES_SETJMP], [
133 curl_includes_setjmp="\
134 /* includes start */
135 #ifdef HAVE_SYS_TYPES_H
136 #  include <sys/types.h>
137 #endif
138 #ifdef HAVE_SETJMP_H
139 #  include <setjmp.h>
140 #endif
141 /* includes end */"
142   AC_CHECK_HEADERS(
143     sys/types.h setjmp.h,
144     [], [], [$curl_includes_setjmp])
145 ])
146
147
148 dnl CURL_INCLUDES_SIGNAL
149 dnl -------------------------------------------------
150 dnl Set up variable with list of headers that must be
151 dnl included when signal.h is to be included.
152
153 AC_DEFUN([CURL_INCLUDES_SIGNAL], [
154 curl_includes_signal="\
155 /* includes start */
156 #ifdef HAVE_SYS_TYPES_H
157 #  include <sys/types.h>
158 #endif
159 #ifdef HAVE_SIGNAL_H
160 #  include <signal.h>
161 #endif
162 /* includes end */"
163   AC_CHECK_HEADERS(
164     sys/types.h signal.h,
165     [], [], [$curl_includes_signal])
166 ])
167
168
169 dnl CURL_INCLUDES_STDIO
170 dnl -------------------------------------------------
171 dnl Set up variable with list of headers that must be
172 dnl included when stdio.h is to be included.
173
174 AC_DEFUN([CURL_INCLUDES_STDIO], [
175 curl_includes_stdio="\
176 /* includes start */
177 #ifdef HAVE_SYS_TYPES_H
178 #  include <sys/types.h>
179 #endif
180 #ifdef HAVE_STDIO_H
181 #  include <stdio.h>
182 #endif
183 /* includes end */"
184   AC_CHECK_HEADERS(
185     sys/types.h stdio.h,
186     [], [], [$curl_includes_stdio])
187 ])
188
189
190 dnl CURL_INCLUDES_STDLIB
191 dnl -------------------------------------------------
192 dnl Set up variable with list of headers that must be
193 dnl included when stdlib.h is to be included.
194
195 AC_DEFUN([CURL_INCLUDES_STDLIB], [
196 curl_includes_stdlib="\
197 /* includes start */
198 #ifdef HAVE_SYS_TYPES_H
199 #  include <sys/types.h>
200 #endif
201 #ifdef HAVE_STDLIB_H
202 #  include <stdlib.h>
203 #endif
204 /* includes end */"
205   AC_CHECK_HEADERS(
206     sys/types.h stdlib.h,
207     [], [], [$curl_includes_stdlib])
208 ])
209
210
211 dnl CURL_INCLUDES_STRING
212 dnl -------------------------------------------------
213 dnl Set up variable with list of headers that must be
214 dnl included when string(s).h is to be included.
215
216 AC_DEFUN([CURL_INCLUDES_STRING], [
217 curl_includes_string="\
218 /* includes start */
219 #ifdef HAVE_SYS_TYPES_H
220 #  include <sys/types.h>
221 #endif
222 #ifdef HAVE_STRING_H
223 #  include <string.h>
224 #endif
225 #ifdef HAVE_STRINGS_H
226 #  include <strings.h>
227 #endif
228 /* includes end */"
229   AC_CHECK_HEADERS(
230     sys/types.h string.h strings.h,
231     [], [], [$curl_includes_string])
232 ])
233
234
235 dnl CURL_INCLUDES_STROPTS
236 dnl -------------------------------------------------
237 dnl Set up variable with list of headers that must be
238 dnl included when stropts.h is to be included.
239
240 AC_DEFUN([CURL_INCLUDES_STROPTS], [
241 curl_includes_stropts="\
242 /* includes start */
243 #ifdef HAVE_SYS_TYPES_H
244 #  include <sys/types.h>
245 #endif
246 #ifdef HAVE_UNISTD_H
247 #  include <unistd.h>
248 #endif
249 #ifdef HAVE_SYS_SOCKET_H
250 #  include <sys/socket.h>
251 #endif
252 #ifdef HAVE_SYS_IOCTL_H
253 #  include <sys/ioctl.h>
254 #endif
255 #ifdef HAVE_STROPTS_H
256 #  include <stropts.h>
257 #endif
258 /* includes end */"
259   AC_CHECK_HEADERS(
260     sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
261     [], [], [$curl_includes_stropts])
262 ])
263
264
265 dnl CURL_INCLUDES_SYS_SOCKET
266 dnl -------------------------------------------------
267 dnl Set up variable with list of headers that must be
268 dnl included when sys/socket.h is to be included.
269
270 AC_DEFUN([CURL_INCLUDES_SYS_SOCKET], [
271 curl_includes_sys_socket="\
272 /* includes start */
273 #ifdef HAVE_SYS_TYPES_H
274 #  include <sys/types.h>
275 #endif
276 #ifdef HAVE_SYS_SOCKET_H
277 #  include <sys/socket.h>
278 #endif
279 /* includes end */"
280   AC_CHECK_HEADERS(
281     sys/types.h sys/socket.h,
282     [], [], [$curl_includes_sys_socket])
283 ])
284
285
286 dnl CURL_INCLUDES_SYS_UIO
287 dnl -------------------------------------------------
288 dnl Set up variable with list of headers that must be
289 dnl included when sys/uio.h is to be included.
290
291 AC_DEFUN([CURL_INCLUDES_SYS_UIO], [
292 curl_includes_sys_uio="\
293 /* includes start */
294 #ifdef HAVE_SYS_TYPES_H
295 #  include <sys/types.h>
296 #endif
297 #ifdef HAVE_SYS_UIO_H
298 #  include <sys/uio.h>
299 #endif
300 /* includes end */"
301   AC_CHECK_HEADERS(
302     sys/types.h sys/uio.h,
303     [], [], [$curl_includes_sys_uio])
304 ])
305
306
307 dnl CURL_INCLUDES_TIME
308 dnl -------------------------------------------------
309 dnl Set up variable with list of headers that must be
310 dnl included when time.h is to be included.
311
312 AC_DEFUN([CURL_INCLUDES_TIME], [
313 AC_REQUIRE([AC_HEADER_TIME])dnl
314 curl_includes_time="\
315 /* includes start */
316 #ifdef HAVE_SYS_TYPES_H
317 #  include <sys/types.h>
318 #endif
319 #ifdef HAVE_SYS_TIME_H
320 #  include <sys/time.h>
321 #  ifdef TIME_WITH_SYS_TIME
322 #    include <time.h>
323 #  endif
324 #else
325 #  ifdef HAVE_TIME_H
326 #    include <time.h>
327 #  endif
328 #endif
329 /* includes end */"
330   AC_CHECK_HEADERS(
331     sys/types.h sys/time.h time.h,
332     [], [], [$curl_includes_time])
333 ])
334
335
336 dnl CURL_INCLUDES_UNISTD
337 dnl -------------------------------------------------
338 dnl Set up variable with list of headers that must be
339 dnl included when unistd.h is to be included.
340
341 AC_DEFUN([CURL_INCLUDES_UNISTD], [
342 curl_includes_unistd="\
343 /* includes start */
344 #ifdef HAVE_SYS_TYPES_H
345 #  include <sys/types.h>
346 #endif
347 #ifdef HAVE_UNISTD_H
348 #  include <unistd.h>
349 #endif
350 /* includes end */"
351   AC_CHECK_HEADERS(
352     sys/types.h unistd.h,
353     [], [], [$curl_includes_unistd])
354 ])
355
356
357 dnl CURL_INCLUDES_WINSOCK2
358 dnl -------------------------------------------------
359 dnl Set up variable with list of headers that must be
360 dnl included when winsock(2).h is to be included.
361
362 AC_DEFUN([CURL_INCLUDES_WINSOCK2], [
363 curl_includes_winsock2="\
364 /* includes start */
365 #ifdef HAVE_WINDOWS_H
366 #  ifndef WIN32_LEAN_AND_MEAN
367 #    define WIN32_LEAN_AND_MEAN
368 #  endif
369 #  include <windows.h>
370 #  ifdef HAVE_WINSOCK2_H
371 #    include <winsock2.h>
372 #  else
373 #    ifdef HAVE_WINSOCK_H
374 #      include <winsock.h>
375 #    endif
376 #  endif
377 #endif
378 /* includes end */"
379   CURL_CHECK_HEADER_WINDOWS
380   CURL_CHECK_HEADER_WINSOCK
381   CURL_CHECK_HEADER_WINSOCK2
382 ])
383
384
385 dnl CURL_INCLUDES_WS2TCPIP
386 dnl -------------------------------------------------
387 dnl Set up variable with list of headers that must be
388 dnl included when ws2tcpip.h is to be included.
389
390 AC_DEFUN([CURL_INCLUDES_WS2TCPIP], [
391 curl_includes_ws2tcpip="\
392 /* includes start */
393 #ifdef HAVE_WINDOWS_H
394 #  ifndef WIN32_LEAN_AND_MEAN
395 #    define WIN32_LEAN_AND_MEAN
396 #  endif
397 #  include <windows.h>
398 #  ifdef HAVE_WINSOCK2_H
399 #    include <winsock2.h>
400 #    ifdef HAVE_WS2TCPIP_H
401 #       include <ws2tcpip.h>
402 #    endif
403 #  endif
404 #endif
405 /* includes end */"
406   CURL_CHECK_HEADER_WINDOWS
407   CURL_CHECK_HEADER_WINSOCK2
408   CURL_CHECK_HEADER_WS2TCPIP
409 ])
410
411
412 dnl CURL_CHECK_FUNC_ALARM
413 dnl -------------------------------------------------
414 dnl Verify if alarm is available, prototyped, and
415 dnl can be compiled. If all of these are true, and
416 dnl usage has not been previously disallowed with
417 dnl shell variable curl_disallow_alarm, then
418 dnl HAVE_ALARM will be defined.
419
420 AC_DEFUN([CURL_CHECK_FUNC_ALARM], [
421   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
422   #
423   tst_links_alarm="unknown"
424   tst_proto_alarm="unknown"
425   tst_compi_alarm="unknown"
426   tst_allow_alarm="unknown"
427   #
428   AC_MSG_CHECKING([if alarm can be linked])
429   AC_LINK_IFELSE([
430     AC_LANG_FUNC_LINK_TRY([alarm])
431   ],[
432     AC_MSG_RESULT([yes])
433     tst_links_alarm="yes"
434   ],[
435     AC_MSG_RESULT([no])
436     tst_links_alarm="no"
437   ])
438   #
439   if test "$tst_links_alarm" = "yes"; then
440     AC_MSG_CHECKING([if alarm is prototyped])
441     AC_EGREP_CPP([alarm],[
442       $curl_includes_unistd
443     ],[
444       AC_MSG_RESULT([yes])
445       tst_proto_alarm="yes"
446     ],[
447       AC_MSG_RESULT([no])
448       tst_proto_alarm="no"
449     ])
450   fi
451   #
452   if test "$tst_proto_alarm" = "yes"; then
453     AC_MSG_CHECKING([if alarm is compilable])
454     AC_COMPILE_IFELSE([
455       AC_LANG_PROGRAM([[
456         $curl_includes_unistd
457       ]],[[
458         if(0 != alarm(0))
459           return 1;
460       ]])
461     ],[
462       AC_MSG_RESULT([yes])
463       tst_compi_alarm="yes"
464     ],[
465       AC_MSG_RESULT([no])
466       tst_compi_alarm="no"
467     ])
468   fi
469   #
470   if test "$tst_compi_alarm" = "yes"; then
471     AC_MSG_CHECKING([if alarm usage allowed])
472     if test "x$curl_disallow_alarm" != "xyes"; then
473       AC_MSG_RESULT([yes])
474       tst_allow_alarm="yes"
475     else
476       AC_MSG_RESULT([no])
477       tst_allow_alarm="no"
478     fi
479   fi
480   #
481   AC_MSG_CHECKING([if alarm might be used])
482   if test "$tst_links_alarm" = "yes" &&
483      test "$tst_proto_alarm" = "yes" &&
484      test "$tst_compi_alarm" = "yes" &&
485      test "$tst_allow_alarm" = "yes"; then
486     AC_MSG_RESULT([yes])
487     AC_DEFINE_UNQUOTED(HAVE_ALARM, 1,
488       [Define to 1 if you have the alarm function.])
489     ac_cv_func_alarm="yes"
490   else
491     AC_MSG_RESULT([no])
492     ac_cv_func_alarm="no"
493   fi
494 ])
495
496
497 dnl CURL_CHECK_FUNC_FCNTL
498 dnl -------------------------------------------------
499 dnl Verify if fcntl is available, prototyped, and
500 dnl can be compiled. If all of these are true, and
501 dnl usage has not been previously disallowed with
502 dnl shell variable curl_disallow_fcntl, then
503 dnl HAVE_FCNTL will be defined.
504
505 AC_DEFUN([CURL_CHECK_FUNC_FCNTL], [
506   AC_REQUIRE([CURL_INCLUDES_FCNTL])dnl
507   #
508   tst_links_fcntl="unknown"
509   tst_proto_fcntl="unknown"
510   tst_compi_fcntl="unknown"
511   tst_allow_fcntl="unknown"
512   #
513   AC_MSG_CHECKING([if fcntl can be linked])
514   AC_LINK_IFELSE([
515     AC_LANG_FUNC_LINK_TRY([fcntl])
516   ],[
517     AC_MSG_RESULT([yes])
518     tst_links_fcntl="yes"
519   ],[
520     AC_MSG_RESULT([no])
521     tst_links_fcntl="no"
522   ])
523   #
524   if test "$tst_links_fcntl" = "yes"; then
525     AC_MSG_CHECKING([if fcntl is prototyped])
526     AC_EGREP_CPP([fcntl],[
527       $curl_includes_fcntl
528     ],[
529       AC_MSG_RESULT([yes])
530       tst_proto_fcntl="yes"
531     ],[
532       AC_MSG_RESULT([no])
533       tst_proto_fcntl="no"
534     ])
535   fi
536   #
537   if test "$tst_proto_fcntl" = "yes"; then
538     AC_MSG_CHECKING([if fcntl is compilable])
539     AC_COMPILE_IFELSE([
540       AC_LANG_PROGRAM([[
541         $curl_includes_fcntl
542       ]],[[
543         if(0 != fcntl(0, 0, 0))
544           return 1;
545       ]])
546     ],[
547       AC_MSG_RESULT([yes])
548       tst_compi_fcntl="yes"
549     ],[
550       AC_MSG_RESULT([no])
551       tst_compi_fcntl="no"
552     ])
553   fi
554   #
555   if test "$tst_compi_fcntl" = "yes"; then
556     AC_MSG_CHECKING([if fcntl usage allowed])
557     if test "x$curl_disallow_fcntl" != "xyes"; then
558       AC_MSG_RESULT([yes])
559       tst_allow_fcntl="yes"
560     else
561       AC_MSG_RESULT([no])
562       tst_allow_fcntl="no"
563     fi
564   fi
565   #
566   AC_MSG_CHECKING([if fcntl might be used])
567   if test "$tst_links_fcntl" = "yes" &&
568      test "$tst_proto_fcntl" = "yes" &&
569      test "$tst_compi_fcntl" = "yes" &&
570      test "$tst_allow_fcntl" = "yes"; then
571     AC_MSG_RESULT([yes])
572     AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
573       [Define to 1 if you have the fcntl function.])
574     ac_cv_func_fcntl="yes"
575     CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
576   else
577     AC_MSG_RESULT([no])
578     ac_cv_func_fcntl="no"
579   fi
580 ])
581
582
583 dnl CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
584 dnl -------------------------------------------------
585 dnl Verify if fcntl with status flag O_NONBLOCK is
586 dnl available, can be compiled, and seems to work. If
587 dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
588 dnl will be defined.
589
590 AC_DEFUN([CURL_CHECK_FUNC_FCNTL_O_NONBLOCK], [
591   #
592   tst_compi_fcntl_o_nonblock="unknown"
593   tst_allow_fcntl_o_nonblock="unknown"
594   #
595   case $host_os in
596     sunos4* | aix3* | beos*)
597       dnl O_NONBLOCK does not work on these platforms
598       curl_disallow_fcntl_o_nonblock="yes"
599       ;;
600   esac
601   #
602   if test "$ac_cv_func_fcntl" = "yes"; then
603     AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
604     AC_COMPILE_IFELSE([
605       AC_LANG_PROGRAM([[
606         $curl_includes_fcntl
607       ]],[[
608         int flags = 0;
609         if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
610           return 1;
611       ]])
612     ],[
613       AC_MSG_RESULT([yes])
614       tst_compi_fcntl_o_nonblock="yes"
615     ],[
616       AC_MSG_RESULT([no])
617       tst_compi_fcntl_o_nonblock="no"
618     ])
619   fi
620   #
621   if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
622     AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
623     if test "x$curl_disallow_fcntl_o_nonblock" != "xyes"; then
624       AC_MSG_RESULT([yes])
625       tst_allow_fcntl_o_nonblock="yes"
626     else
627       AC_MSG_RESULT([no])
628       tst_allow_fcntl_o_nonblock="no"
629     fi
630   fi
631   #
632   AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
633   if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
634      test "$tst_allow_fcntl_o_nonblock" = "yes"; then
635     AC_MSG_RESULT([yes])
636     AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
637       [Define to 1 if you have a working fcntl O_NONBLOCK function.])
638     ac_cv_func_fcntl_o_nonblock="yes"
639   else
640     AC_MSG_RESULT([no])
641     ac_cv_func_fcntl_o_nonblock="no"
642   fi
643 ])
644
645
646 dnl CURL_CHECK_FUNC_FDOPEN
647 dnl -------------------------------------------------
648 dnl Verify if fdopen is available, prototyped, and
649 dnl can be compiled. If all of these are true, and
650 dnl usage has not been previously disallowed with
651 dnl shell variable curl_disallow_fdopen, then
652 dnl HAVE_FDOPEN will be defined.
653
654 AC_DEFUN([CURL_CHECK_FUNC_FDOPEN], [
655   AC_REQUIRE([CURL_INCLUDES_STDIO])dnl
656   #
657   tst_links_fdopen="unknown"
658   tst_proto_fdopen="unknown"
659   tst_compi_fdopen="unknown"
660   tst_allow_fdopen="unknown"
661   #
662   AC_MSG_CHECKING([if fdopen can be linked])
663   AC_LINK_IFELSE([
664     AC_LANG_FUNC_LINK_TRY([fdopen])
665   ],[
666     AC_MSG_RESULT([yes])
667     tst_links_fdopen="yes"
668   ],[
669     AC_MSG_RESULT([no])
670     tst_links_fdopen="no"
671   ])
672   #
673   if test "$tst_links_fdopen" = "yes"; then
674     AC_MSG_CHECKING([if fdopen is prototyped])
675     AC_EGREP_CPP([fdopen],[
676       $curl_includes_stdio
677     ],[
678       AC_MSG_RESULT([yes])
679       tst_proto_fdopen="yes"
680     ],[
681       AC_MSG_RESULT([no])
682       tst_proto_fdopen="no"
683     ])
684   fi
685   #
686   if test "$tst_proto_fdopen" = "yes"; then
687     AC_MSG_CHECKING([if fdopen is compilable])
688     AC_COMPILE_IFELSE([
689       AC_LANG_PROGRAM([[
690         $curl_includes_stdio
691       ]],[[
692         if(0 != fdopen(0, 0))
693           return 1;
694       ]])
695     ],[
696       AC_MSG_RESULT([yes])
697       tst_compi_fdopen="yes"
698     ],[
699       AC_MSG_RESULT([no])
700       tst_compi_fdopen="no"
701     ])
702   fi
703   #
704   if test "$tst_compi_fdopen" = "yes"; then
705     AC_MSG_CHECKING([if fdopen usage allowed])
706     if test "x$curl_disallow_fdopen" != "xyes"; then
707       AC_MSG_RESULT([yes])
708       tst_allow_fdopen="yes"
709     else
710       AC_MSG_RESULT([no])
711       tst_allow_fdopen="no"
712     fi
713   fi
714   #
715   AC_MSG_CHECKING([if fdopen might be used])
716   if test "$tst_links_fdopen" = "yes" &&
717      test "$tst_proto_fdopen" = "yes" &&
718      test "$tst_compi_fdopen" = "yes" &&
719      test "$tst_allow_fdopen" = "yes"; then
720     AC_MSG_RESULT([yes])
721     AC_DEFINE_UNQUOTED(HAVE_FDOPEN, 1,
722       [Define to 1 if you have the fdopen function.])
723     ac_cv_func_fdopen="yes"
724   else
725     AC_MSG_RESULT([no])
726     ac_cv_func_fdopen="no"
727   fi
728 ])
729
730
731 dnl CURL_CHECK_FUNC_FREEADDRINFO
732 dnl -------------------------------------------------
733 dnl Verify if freeaddrinfo is available, prototyped,
734 dnl and can be compiled. If all of these are true,
735 dnl and usage has not been previously disallowed with
736 dnl shell variable curl_disallow_freeaddrinfo, then
737 dnl HAVE_FREEADDRINFO will be defined.
738
739 AC_DEFUN([CURL_CHECK_FUNC_FREEADDRINFO], [
740   AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
741   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
742   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
743   #
744   tst_links_freeaddrinfo="unknown"
745   tst_proto_freeaddrinfo="unknown"
746   tst_compi_freeaddrinfo="unknown"
747   tst_allow_freeaddrinfo="unknown"
748   #
749   AC_MSG_CHECKING([if freeaddrinfo can be linked])
750   AC_LINK_IFELSE([
751     AC_LANG_PROGRAM([[
752       $curl_includes_ws2tcpip
753       $curl_includes_sys_socket
754       $curl_includes_netdb
755     ]],[[
756       freeaddrinfo(0);
757     ]])
758   ],[
759     AC_MSG_RESULT([yes])
760     tst_links_freeaddrinfo="yes"
761   ],[
762     AC_MSG_RESULT([no])
763     tst_links_freeaddrinfo="no"
764   ])
765   #
766   if test "$tst_links_freeaddrinfo" = "yes"; then
767     AC_MSG_CHECKING([if freeaddrinfo is prototyped])
768     AC_EGREP_CPP([freeaddrinfo],[
769       $curl_includes_ws2tcpip
770       $curl_includes_sys_socket
771       $curl_includes_netdb
772     ],[
773       AC_MSG_RESULT([yes])
774       tst_proto_freeaddrinfo="yes"
775     ],[
776       AC_MSG_RESULT([no])
777       tst_proto_freeaddrinfo="no"
778     ])
779   fi
780   #
781   if test "$tst_proto_freeaddrinfo" = "yes"; then
782     AC_MSG_CHECKING([if freeaddrinfo is compilable])
783     AC_COMPILE_IFELSE([
784       AC_LANG_PROGRAM([[
785         $curl_includes_ws2tcpip
786         $curl_includes_sys_socket
787         $curl_includes_netdb
788       ]],[[
789         freeaddrinfo(0);
790       ]])
791     ],[
792       AC_MSG_RESULT([yes])
793       tst_compi_freeaddrinfo="yes"
794     ],[
795       AC_MSG_RESULT([no])
796       tst_compi_freeaddrinfo="no"
797     ])
798   fi
799   #
800   if test "$tst_compi_freeaddrinfo" = "yes"; then
801     AC_MSG_CHECKING([if freeaddrinfo usage allowed])
802     if test "x$curl_disallow_freeaddrinfo" != "xyes"; then
803       AC_MSG_RESULT([yes])
804       tst_allow_freeaddrinfo="yes"
805     else
806       AC_MSG_RESULT([no])
807       tst_allow_freeaddrinfo="no"
808     fi
809   fi
810   #
811   AC_MSG_CHECKING([if freeaddrinfo might be used])
812   if test "$tst_links_freeaddrinfo" = "yes" &&
813      test "$tst_proto_freeaddrinfo" = "yes" &&
814      test "$tst_compi_freeaddrinfo" = "yes" &&
815      test "$tst_allow_freeaddrinfo" = "yes"; then
816     AC_MSG_RESULT([yes])
817     AC_DEFINE_UNQUOTED(HAVE_FREEADDRINFO, 1,
818       [Define to 1 if you have the freeaddrinfo function.])
819     ac_cv_func_freeaddrinfo="yes"
820   else
821     AC_MSG_RESULT([no])
822     ac_cv_func_freeaddrinfo="no"
823   fi
824 ])
825
826
827 dnl CURL_CHECK_FUNC_FREEIFADDRS
828 dnl -------------------------------------------------
829 dnl Verify if freeifaddrs is available, prototyped, and
830 dnl can be compiled. If all of these are true, and
831 dnl usage has not been previously disallowed with
832 dnl shell variable curl_disallow_freeifaddrs, then
833 dnl HAVE_FREEIFADDRS will be defined.
834
835 AC_DEFUN([CURL_CHECK_FUNC_FREEIFADDRS], [
836   AC_REQUIRE([CURL_INCLUDES_IFADDRS])dnl
837   #
838   tst_links_freeifaddrs="unknown"
839   tst_proto_freeifaddrs="unknown"
840   tst_compi_freeifaddrs="unknown"
841   tst_allow_freeifaddrs="unknown"
842   #
843   AC_MSG_CHECKING([if freeifaddrs can be linked])
844   AC_LINK_IFELSE([
845     AC_LANG_FUNC_LINK_TRY([freeifaddrs])
846   ],[
847     AC_MSG_RESULT([yes])
848     tst_links_freeifaddrs="yes"
849   ],[
850     AC_MSG_RESULT([no])
851     tst_links_freeifaddrs="no"
852   ])
853   #
854   if test "$tst_links_freeifaddrs" = "yes"; then
855     AC_MSG_CHECKING([if freeifaddrs is prototyped])
856     AC_EGREP_CPP([freeifaddrs],[
857       $curl_includes_ifaddrs
858     ],[
859       AC_MSG_RESULT([yes])
860       tst_proto_freeifaddrs="yes"
861     ],[
862       AC_MSG_RESULT([no])
863       tst_proto_freeifaddrs="no"
864     ])
865   fi
866   #
867   if test "$tst_proto_freeifaddrs" = "yes"; then
868     AC_MSG_CHECKING([if freeifaddrs is compilable])
869     AC_COMPILE_IFELSE([
870       AC_LANG_PROGRAM([[
871         $curl_includes_ifaddrs
872       ]],[[
873         freeifaddrs(0);
874       ]])
875     ],[
876       AC_MSG_RESULT([yes])
877       tst_compi_freeifaddrs="yes"
878     ],[
879       AC_MSG_RESULT([no])
880       tst_compi_freeifaddrs="no"
881     ])
882   fi
883   #
884   if test "$tst_compi_freeifaddrs" = "yes"; then
885     AC_MSG_CHECKING([if freeifaddrs usage allowed])
886     if test "x$curl_disallow_freeifaddrs" != "xyes"; then
887       AC_MSG_RESULT([yes])
888       tst_allow_freeifaddrs="yes"
889     else
890       AC_MSG_RESULT([no])
891       tst_allow_freeifaddrs="no"
892     fi
893   fi
894   #
895   AC_MSG_CHECKING([if freeifaddrs might be used])
896   if test "$tst_links_freeifaddrs" = "yes" &&
897      test "$tst_proto_freeifaddrs" = "yes" &&
898      test "$tst_compi_freeifaddrs" = "yes" &&
899      test "$tst_allow_freeifaddrs" = "yes"; then
900     AC_MSG_RESULT([yes])
901     AC_DEFINE_UNQUOTED(HAVE_FREEIFADDRS, 1,
902       [Define to 1 if you have the freeifaddrs function.])
903     ac_cv_func_freeifaddrs="yes"
904   else
905     AC_MSG_RESULT([no])
906     ac_cv_func_freeifaddrs="no"
907   fi
908 ])
909
910
911 dnl CURL_CHECK_FUNC_FTRUNCATE
912 dnl -------------------------------------------------
913 dnl Verify if ftruncate is available, prototyped, and
914 dnl can be compiled. If all of these are true, and
915 dnl usage has not been previously disallowed with
916 dnl shell variable curl_disallow_ftruncate, then
917 dnl HAVE_FTRUNCATE will be defined.
918
919 AC_DEFUN([CURL_CHECK_FUNC_FTRUNCATE], [
920   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
921   #
922   tst_links_ftruncate="unknown"
923   tst_proto_ftruncate="unknown"
924   tst_compi_ftruncate="unknown"
925   tst_allow_ftruncate="unknown"
926   #
927   AC_MSG_CHECKING([if ftruncate can be linked])
928   AC_LINK_IFELSE([
929     AC_LANG_FUNC_LINK_TRY([ftruncate])
930   ],[
931     AC_MSG_RESULT([yes])
932     tst_links_ftruncate="yes"
933   ],[
934     AC_MSG_RESULT([no])
935     tst_links_ftruncate="no"
936   ])
937   #
938   if test "$tst_links_ftruncate" = "yes"; then
939     AC_MSG_CHECKING([if ftruncate is prototyped])
940     AC_EGREP_CPP([ftruncate],[
941       $curl_includes_unistd
942     ],[
943       AC_MSG_RESULT([yes])
944       tst_proto_ftruncate="yes"
945     ],[
946       AC_MSG_RESULT([no])
947       tst_proto_ftruncate="no"
948     ])
949   fi
950   #
951   if test "$tst_proto_ftruncate" = "yes"; then
952     AC_MSG_CHECKING([if ftruncate is compilable])
953     AC_COMPILE_IFELSE([
954       AC_LANG_PROGRAM([[
955         $curl_includes_unistd
956       ]],[[
957         if(0 != ftruncate(0, 0))
958           return 1;
959       ]])
960     ],[
961       AC_MSG_RESULT([yes])
962       tst_compi_ftruncate="yes"
963     ],[
964       AC_MSG_RESULT([no])
965       tst_compi_ftruncate="no"
966     ])
967   fi
968   #
969   if test "$tst_compi_ftruncate" = "yes"; then
970     AC_MSG_CHECKING([if ftruncate usage allowed])
971     if test "x$curl_disallow_ftruncate" != "xyes"; then
972       AC_MSG_RESULT([yes])
973       tst_allow_ftruncate="yes"
974     else
975       AC_MSG_RESULT([no])
976       tst_allow_ftruncate="no"
977     fi
978   fi
979   #
980   AC_MSG_CHECKING([if ftruncate might be used])
981   if test "$tst_links_ftruncate" = "yes" &&
982      test "$tst_proto_ftruncate" = "yes" &&
983      test "$tst_compi_ftruncate" = "yes" &&
984      test "$tst_allow_ftruncate" = "yes"; then
985     AC_MSG_RESULT([yes])
986     AC_DEFINE_UNQUOTED(HAVE_FTRUNCATE, 1,
987       [Define to 1 if you have the ftruncate function.])
988     ac_cv_func_ftruncate="yes"
989   else
990     AC_MSG_RESULT([no])
991     ac_cv_func_ftruncate="no"
992   fi
993 ])
994
995
996 dnl CURL_CHECK_FUNC_GETADDRINFO
997 dnl -------------------------------------------------
998 dnl Verify if getaddrinfo is available, prototyped, can
999 dnl be compiled and seems to work. If all of these are
1000 dnl true, and usage has not been previously disallowed
1001 dnl with shell variable curl_disallow_getaddrinfo, then
1002 dnl HAVE_GETADDRINFO will be defined.
1003
1004 AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
1005   AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
1006   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
1007   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1008   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
1009   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1010   #
1011   tst_links_getaddrinfo="unknown"
1012   tst_proto_getaddrinfo="unknown"
1013   tst_compi_getaddrinfo="unknown"
1014   tst_works_getaddrinfo="unknown"
1015   tst_allow_getaddrinfo="unknown"
1016   #
1017   AC_MSG_CHECKING([if getaddrinfo can be linked])
1018   AC_LINK_IFELSE([
1019     AC_LANG_PROGRAM([[
1020       $curl_includes_ws2tcpip
1021       $curl_includes_sys_socket
1022       $curl_includes_netdb
1023     ]],[[
1024       if(0 != getaddrinfo(0, 0, 0, 0))
1025         return 1;
1026     ]])
1027   ],[
1028     AC_MSG_RESULT([yes])
1029     tst_links_getaddrinfo="yes"
1030   ],[
1031     AC_MSG_RESULT([no])
1032     tst_links_getaddrinfo="no"
1033   ])
1034   #
1035   if test "$tst_links_getaddrinfo" = "yes"; then
1036     AC_MSG_CHECKING([if getaddrinfo is prototyped])
1037     AC_EGREP_CPP([getaddrinfo],[
1038       $curl_includes_ws2tcpip
1039       $curl_includes_sys_socket
1040       $curl_includes_netdb
1041     ],[
1042       AC_MSG_RESULT([yes])
1043       tst_proto_getaddrinfo="yes"
1044     ],[
1045       AC_MSG_RESULT([no])
1046       tst_proto_getaddrinfo="no"
1047     ])
1048   fi
1049   #
1050   if test "$tst_proto_getaddrinfo" = "yes"; then
1051     AC_MSG_CHECKING([if getaddrinfo is compilable])
1052     AC_COMPILE_IFELSE([
1053       AC_LANG_PROGRAM([[
1054         $curl_includes_ws2tcpip
1055         $curl_includes_sys_socket
1056         $curl_includes_netdb
1057       ]],[[
1058         if(0 != getaddrinfo(0, 0, 0, 0))
1059           return 1;
1060       ]])
1061     ],[
1062       AC_MSG_RESULT([yes])
1063       tst_compi_getaddrinfo="yes"
1064     ],[
1065       AC_MSG_RESULT([no])
1066       tst_compi_getaddrinfo="no"
1067     ])
1068   fi
1069   #
1070   dnl only do runtime verification when not cross-compiling
1071   if test "x$cross_compiling" != "xyes" &&
1072     test "$tst_compi_getaddrinfo" = "yes"; then
1073     AC_MSG_CHECKING([if getaddrinfo seems to work])
1074     AC_RUN_IFELSE([
1075       AC_LANG_PROGRAM([[
1076         $curl_includes_ws2tcpip
1077         $curl_includes_stdlib
1078         $curl_includes_string
1079         $curl_includes_sys_socket
1080         $curl_includes_netdb
1081       ]],[[
1082         struct addrinfo hints;
1083         struct addrinfo *ai = 0;
1084         int error;
1085
1086         memset(&hints, 0, sizeof(hints));
1087         hints.ai_flags = AI_NUMERICHOST;
1088         hints.ai_family = AF_UNSPEC;
1089         hints.ai_socktype = SOCK_STREAM;
1090         error = getaddrinfo("127.0.0.1", 0, &hints, &ai);
1091         if(error || !ai)
1092           exit(1); /* fail */
1093         else
1094           exit(0);
1095       ]])
1096     ],[
1097       AC_MSG_RESULT([yes])
1098       tst_works_getaddrinfo="yes"
1099     ],[
1100       AC_MSG_RESULT([no])
1101       tst_works_getaddrinfo="no"
1102     ])
1103   fi
1104   #
1105   if test "$tst_compi_getaddrinfo" = "yes" &&
1106     test "$tst_works_getaddrinfo" != "no"; then
1107     AC_MSG_CHECKING([if getaddrinfo usage allowed])
1108     if test "x$curl_disallow_getaddrinfo" != "xyes"; then
1109       AC_MSG_RESULT([yes])
1110       tst_allow_getaddrinfo="yes"
1111     else
1112       AC_MSG_RESULT([no])
1113       tst_allow_getaddrinfo="no"
1114     fi
1115   fi
1116   #
1117   AC_MSG_CHECKING([if getaddrinfo might be used])
1118   if test "$tst_links_getaddrinfo" = "yes" &&
1119      test "$tst_proto_getaddrinfo" = "yes" &&
1120      test "$tst_compi_getaddrinfo" = "yes" &&
1121      test "$tst_allow_getaddrinfo" = "yes" &&
1122      test "$tst_works_getaddrinfo" != "no"; then
1123     AC_MSG_RESULT([yes])
1124     AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO, 1,
1125       [Define to 1 if you have a working getaddrinfo function.])
1126     ac_cv_func_getaddrinfo="yes"
1127   else
1128     AC_MSG_RESULT([no])
1129     ac_cv_func_getaddrinfo="no"
1130   fi
1131 ])
1132
1133
1134 dnl CURL_CHECK_FUNC_GETHOSTBYADDR
1135 dnl -------------------------------------------------
1136 dnl Verify if gethostbyaddr is available, prototyped,
1137 dnl and can be compiled. If all of these are true,
1138 dnl and usage has not been previously disallowed with
1139 dnl shell variable curl_disallow_gethostbyaddr, then
1140 dnl HAVE_GETHOSTBYADDR will be defined.
1141
1142 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR], [
1143   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1144   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1145   #
1146   tst_links_gethostbyaddr="unknown"
1147   tst_proto_gethostbyaddr="unknown"
1148   tst_compi_gethostbyaddr="unknown"
1149   tst_allow_gethostbyaddr="unknown"
1150   #
1151   AC_MSG_CHECKING([if gethostbyaddr can be linked])
1152   AC_LINK_IFELSE([
1153     AC_LANG_PROGRAM([[
1154       $curl_includes_winsock2
1155       $curl_includes_netdb
1156     ]],[[
1157       if(0 != gethostbyaddr(0, 0, 0))
1158         return 1;
1159     ]])
1160   ],[
1161     AC_MSG_RESULT([yes])
1162     tst_links_gethostbyaddr="yes"
1163   ],[
1164     AC_MSG_RESULT([no])
1165     tst_links_gethostbyaddr="no"
1166   ])
1167   #
1168   if test "$tst_links_gethostbyaddr" = "yes"; then
1169     AC_MSG_CHECKING([if gethostbyaddr is prototyped])
1170     AC_EGREP_CPP([gethostbyaddr],[
1171       $curl_includes_winsock2
1172       $curl_includes_netdb
1173     ],[
1174       AC_MSG_RESULT([yes])
1175       tst_proto_gethostbyaddr="yes"
1176     ],[
1177       AC_MSG_RESULT([no])
1178       tst_proto_gethostbyaddr="no"
1179     ])
1180   fi
1181   #
1182   if test "$tst_proto_gethostbyaddr" = "yes"; then
1183     AC_MSG_CHECKING([if gethostbyaddr is compilable])
1184     AC_COMPILE_IFELSE([
1185       AC_LANG_PROGRAM([[
1186         $curl_includes_winsock2
1187         $curl_includes_netdb
1188       ]],[[
1189         if(0 != gethostbyaddr(0, 0, 0))
1190           return 1;
1191       ]])
1192     ],[
1193       AC_MSG_RESULT([yes])
1194       tst_compi_gethostbyaddr="yes"
1195     ],[
1196       AC_MSG_RESULT([no])
1197       tst_compi_gethostbyaddr="no"
1198     ])
1199   fi
1200   #
1201   if test "$tst_compi_gethostbyaddr" = "yes"; then
1202     AC_MSG_CHECKING([if gethostbyaddr usage allowed])
1203     if test "x$curl_disallow_gethostbyaddr" != "xyes"; then
1204       AC_MSG_RESULT([yes])
1205       tst_allow_gethostbyaddr="yes"
1206     else
1207       AC_MSG_RESULT([no])
1208       tst_allow_gethostbyaddr="no"
1209     fi
1210   fi
1211   #
1212   AC_MSG_CHECKING([if gethostbyaddr might be used])
1213   if test "$tst_links_gethostbyaddr" = "yes" &&
1214      test "$tst_proto_gethostbyaddr" = "yes" &&
1215      test "$tst_compi_gethostbyaddr" = "yes" &&
1216      test "$tst_allow_gethostbyaddr" = "yes"; then
1217     AC_MSG_RESULT([yes])
1218     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR, 1,
1219       [Define to 1 if you have the gethostbyaddr function.])
1220     ac_cv_func_gethostbyaddr="yes"
1221   else
1222     AC_MSG_RESULT([no])
1223     ac_cv_func_gethostbyaddr="no"
1224   fi
1225 ])
1226
1227
1228 dnl CURL_CHECK_FUNC_GETHOSTBYADDR_R
1229 dnl -------------------------------------------------
1230 dnl Verify if gethostbyaddr_r is available, prototyped,
1231 dnl and can be compiled. If all of these are true, and
1232 dnl usage has not been previously disallowed with
1233 dnl shell variable curl_disallow_gethostbyaddr_r, then
1234 dnl HAVE_GETHOSTBYADDR_R will be defined.
1235
1236 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR_R], [
1237   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1238   #
1239   tst_links_gethostbyaddr_r="unknown"
1240   tst_proto_gethostbyaddr_r="unknown"
1241   tst_compi_gethostbyaddr_r="unknown"
1242   tst_allow_gethostbyaddr_r="unknown"
1243   tst_nargs_gethostbyaddr_r="unknown"
1244   #
1245   AC_MSG_CHECKING([if gethostbyaddr_r can be linked])
1246   AC_LINK_IFELSE([
1247     AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
1248   ],[
1249     AC_MSG_RESULT([yes])
1250     tst_links_gethostbyaddr_r="yes"
1251   ],[
1252     AC_MSG_RESULT([no])
1253     tst_links_gethostbyaddr_r="no"
1254   ])
1255   #
1256   if test "$tst_links_gethostbyaddr_r" = "yes"; then
1257     AC_MSG_CHECKING([if gethostbyaddr_r is prototyped])
1258     AC_EGREP_CPP([gethostbyaddr_r],[
1259       $curl_includes_netdb
1260     ],[
1261       AC_MSG_RESULT([yes])
1262       tst_proto_gethostbyaddr_r="yes"
1263     ],[
1264       AC_MSG_RESULT([no])
1265       tst_proto_gethostbyaddr_r="no"
1266     ])
1267   fi
1268   #
1269   if test "$tst_proto_gethostbyaddr_r" = "yes"; then
1270     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
1271       AC_MSG_CHECKING([if gethostbyaddr_r takes 5 args.])
1272       AC_COMPILE_IFELSE([
1273         AC_LANG_PROGRAM([[
1274           $curl_includes_netdb
1275         ]],[[
1276           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0))
1277             return 1;
1278         ]])
1279       ],[
1280         AC_MSG_RESULT([yes])
1281         tst_compi_gethostbyaddr_r="yes"
1282         tst_nargs_gethostbyaddr_r="5"
1283       ],[
1284         AC_MSG_RESULT([no])
1285         tst_compi_gethostbyaddr_r="no"
1286       ])
1287     fi
1288     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
1289       AC_MSG_CHECKING([if gethostbyaddr_r takes 7 args.])
1290       AC_COMPILE_IFELSE([
1291         AC_LANG_PROGRAM([[
1292           $curl_includes_netdb
1293         ]],[[
1294           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0))
1295             return 1;
1296         ]])
1297       ],[
1298         AC_MSG_RESULT([yes])
1299         tst_compi_gethostbyaddr_r="yes"
1300         tst_nargs_gethostbyaddr_r="7"
1301       ],[
1302         AC_MSG_RESULT([no])
1303         tst_compi_gethostbyaddr_r="no"
1304       ])
1305     fi
1306     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
1307       AC_MSG_CHECKING([if gethostbyaddr_r takes 8 args.])
1308       AC_COMPILE_IFELSE([
1309         AC_LANG_PROGRAM([[
1310           $curl_includes_netdb
1311         ]],[[
1312           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0, 0))
1313             return 1;
1314         ]])
1315       ],[
1316         AC_MSG_RESULT([yes])
1317         tst_compi_gethostbyaddr_r="yes"
1318         tst_nargs_gethostbyaddr_r="8"
1319       ],[
1320         AC_MSG_RESULT([no])
1321         tst_compi_gethostbyaddr_r="no"
1322       ])
1323     fi
1324     AC_MSG_CHECKING([if gethostbyaddr_r is compilable])
1325     if test "$tst_compi_gethostbyaddr_r" = "yes"; then
1326       AC_MSG_RESULT([yes])
1327     else
1328       AC_MSG_RESULT([no])
1329     fi
1330   fi
1331   #
1332   if test "$tst_compi_gethostbyaddr_r" = "yes"; then
1333     AC_MSG_CHECKING([if gethostbyaddr_r usage allowed])
1334     if test "x$curl_disallow_gethostbyaddr_r" != "xyes"; then
1335       AC_MSG_RESULT([yes])
1336       tst_allow_gethostbyaddr_r="yes"
1337     else
1338       AC_MSG_RESULT([no])
1339       tst_allow_gethostbyaddr_r="no"
1340     fi
1341   fi
1342   #
1343   AC_MSG_CHECKING([if gethostbyaddr_r might be used])
1344   if test "$tst_links_gethostbyaddr_r" = "yes" &&
1345      test "$tst_proto_gethostbyaddr_r" = "yes" &&
1346      test "$tst_compi_gethostbyaddr_r" = "yes" &&
1347      test "$tst_allow_gethostbyaddr_r" = "yes"; then
1348     AC_MSG_RESULT([yes])
1349     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
1350       [Define to 1 if you have the gethostbyaddr_r function.])
1351     dnl AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_ARGS, $tst_nargs_gethostbyaddr_r,
1352     dnl   [Specifies the number of arguments to gethostbyaddr_r])
1353     #
1354     if test "$tst_nargs_gethostbyaddr_r" -eq "5"; then
1355       AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1356     elif test "$tst_nargs_gethostbyaddr_r" -eq "7"; then
1357       AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
1358     elif test "$tst_nargs_gethostbyaddr_r" -eq "8"; then
1359       AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
1360     fi
1361     #
1362     ac_cv_func_gethostbyaddr_r="yes"
1363   else
1364     AC_MSG_RESULT([no])
1365     ac_cv_func_gethostbyaddr_r="no"
1366   fi
1367 ])
1368
1369
1370 dnl CURL_CHECK_FUNC_GETHOSTBYNAME
1371 dnl -------------------------------------------------
1372 dnl Verify if gethostbyname is available, prototyped,
1373 dnl and can be compiled. If all of these are true,
1374 dnl and usage has not been previously disallowed with
1375 dnl shell variable curl_disallow_gethostbyname, then
1376 dnl HAVE_GETHOSTBYNAME will be defined.
1377
1378 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME], [
1379   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1380   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1381   #
1382   tst_links_gethostbyname="unknown"
1383   tst_proto_gethostbyname="unknown"
1384   tst_compi_gethostbyname="unknown"
1385   tst_allow_gethostbyname="unknown"
1386   #
1387   AC_MSG_CHECKING([if gethostbyname can be linked])
1388   AC_LINK_IFELSE([
1389     AC_LANG_PROGRAM([[
1390       $curl_includes_winsock2
1391       $curl_includes_netdb
1392     ]],[[
1393       if(0 != gethostbyname(0))
1394         return 1;
1395     ]])
1396   ],[
1397     AC_MSG_RESULT([yes])
1398     tst_links_gethostbyname="yes"
1399   ],[
1400     AC_MSG_RESULT([no])
1401     tst_links_gethostbyname="no"
1402   ])
1403   #
1404   if test "$tst_links_gethostbyname" = "yes"; then
1405     AC_MSG_CHECKING([if gethostbyname is prototyped])
1406     AC_EGREP_CPP([gethostbyname],[
1407       $curl_includes_winsock2
1408       $curl_includes_netdb
1409     ],[
1410       AC_MSG_RESULT([yes])
1411       tst_proto_gethostbyname="yes"
1412     ],[
1413       AC_MSG_RESULT([no])
1414       tst_proto_gethostbyname="no"
1415     ])
1416   fi
1417   #
1418   if test "$tst_proto_gethostbyname" = "yes"; then
1419     AC_MSG_CHECKING([if gethostbyname is compilable])
1420     AC_COMPILE_IFELSE([
1421       AC_LANG_PROGRAM([[
1422         $curl_includes_winsock2
1423         $curl_includes_netdb
1424       ]],[[
1425         if(0 != gethostbyname(0))
1426           return 1;
1427       ]])
1428     ],[
1429       AC_MSG_RESULT([yes])
1430       tst_compi_gethostbyname="yes"
1431     ],[
1432       AC_MSG_RESULT([no])
1433       tst_compi_gethostbyname="no"
1434     ])
1435   fi
1436   #
1437   if test "$tst_compi_gethostbyname" = "yes"; then
1438     AC_MSG_CHECKING([if gethostbyname usage allowed])
1439     if test "x$curl_disallow_gethostbyname" != "xyes"; then
1440       AC_MSG_RESULT([yes])
1441       tst_allow_gethostbyname="yes"
1442     else
1443       AC_MSG_RESULT([no])
1444       tst_allow_gethostbyname="no"
1445     fi
1446   fi
1447   #
1448   AC_MSG_CHECKING([if gethostbyname might be used])
1449   if test "$tst_links_gethostbyname" = "yes" &&
1450      test "$tst_proto_gethostbyname" = "yes" &&
1451      test "$tst_compi_gethostbyname" = "yes" &&
1452      test "$tst_allow_gethostbyname" = "yes"; then
1453     AC_MSG_RESULT([yes])
1454     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME, 1,
1455       [Define to 1 if you have the gethostbyname function.])
1456     ac_cv_func_gethostbyname="yes"
1457   else
1458     AC_MSG_RESULT([no])
1459     ac_cv_func_gethostbyname="no"
1460   fi
1461 ])
1462
1463
1464 dnl CURL_CHECK_FUNC_GETHOSTBYNAME_R
1465 dnl -------------------------------------------------
1466 dnl Verify if gethostbyname_r is available, prototyped,
1467 dnl and can be compiled. If all of these are true, and
1468 dnl usage has not been previously disallowed with
1469 dnl shell variable curl_disallow_gethostbyname_r, then
1470 dnl HAVE_GETHOSTBYNAME_R will be defined.
1471
1472 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [
1473   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1474   #
1475   tst_links_gethostbyname_r="unknown"
1476   tst_proto_gethostbyname_r="unknown"
1477   tst_compi_gethostbyname_r="unknown"
1478   tst_allow_gethostbyname_r="unknown"
1479   tst_nargs_gethostbyname_r="unknown"
1480   #
1481   AC_MSG_CHECKING([if gethostbyname_r can be linked])
1482   AC_LINK_IFELSE([
1483     AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
1484   ],[
1485     AC_MSG_RESULT([yes])
1486     tst_links_gethostbyname_r="yes"
1487   ],[
1488     AC_MSG_RESULT([no])
1489     tst_links_gethostbyname_r="no"
1490   ])
1491   #
1492   if test "$tst_links_gethostbyname_r" = "yes"; then
1493     AC_MSG_CHECKING([if gethostbyname_r is prototyped])
1494     AC_EGREP_CPP([gethostbyname_r],[
1495       $curl_includes_netdb
1496     ],[
1497       AC_MSG_RESULT([yes])
1498       tst_proto_gethostbyname_r="yes"
1499     ],[
1500       AC_MSG_RESULT([no])
1501       tst_proto_gethostbyname_r="no"
1502     ])
1503   fi
1504   #
1505   if test "$tst_proto_gethostbyname_r" = "yes"; then
1506     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
1507       AC_MSG_CHECKING([if gethostbyname_r takes 3 args.])
1508       AC_COMPILE_IFELSE([
1509         AC_LANG_PROGRAM([[
1510           $curl_includes_netdb
1511         ]],[[
1512           if(0 != gethostbyname_r(0, 0, 0))
1513             return 1;
1514         ]])
1515       ],[
1516         AC_MSG_RESULT([yes])
1517         tst_compi_gethostbyname_r="yes"
1518         tst_nargs_gethostbyname_r="3"
1519       ],[
1520         AC_MSG_RESULT([no])
1521         tst_compi_gethostbyname_r="no"
1522       ])
1523     fi
1524     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
1525       AC_MSG_CHECKING([if gethostbyname_r takes 5 args.])
1526       AC_COMPILE_IFELSE([
1527         AC_LANG_PROGRAM([[
1528           $curl_includes_netdb
1529         ]],[[
1530           if(0 != gethostbyname_r(0, 0, 0, 0, 0))
1531             return 1;
1532         ]])
1533       ],[
1534         AC_MSG_RESULT([yes])
1535         tst_compi_gethostbyname_r="yes"
1536         tst_nargs_gethostbyname_r="5"
1537       ],[
1538         AC_MSG_RESULT([no])
1539         tst_compi_gethostbyname_r="no"
1540       ])
1541     fi
1542     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
1543       AC_MSG_CHECKING([if gethostbyname_r takes 6 args.])
1544       AC_COMPILE_IFELSE([
1545         AC_LANG_PROGRAM([[
1546           $curl_includes_netdb
1547         ]],[[
1548           if(0 != gethostbyname_r(0, 0, 0, 0, 0, 0))
1549             return 1;
1550         ]])
1551       ],[
1552         AC_MSG_RESULT([yes])
1553         tst_compi_gethostbyname_r="yes"
1554         tst_nargs_gethostbyname_r="6"
1555       ],[
1556         AC_MSG_RESULT([no])
1557         tst_compi_gethostbyname_r="no"
1558       ])
1559     fi
1560     AC_MSG_CHECKING([if gethostbyname_r is compilable])
1561     if test "$tst_compi_gethostbyname_r" = "yes"; then
1562       AC_MSG_RESULT([yes])
1563     else
1564       AC_MSG_RESULT([no])
1565     fi
1566   fi
1567   #
1568   if test "$tst_compi_gethostbyname_r" = "yes"; then
1569     AC_MSG_CHECKING([if gethostbyname_r usage allowed])
1570     if test "x$curl_disallow_gethostbyname_r" != "xyes"; then
1571       AC_MSG_RESULT([yes])
1572       tst_allow_gethostbyname_r="yes"
1573     else
1574       AC_MSG_RESULT([no])
1575       tst_allow_gethostbyname_r="no"
1576     fi
1577   fi
1578   #
1579   AC_MSG_CHECKING([if gethostbyname_r might be used])
1580   if test "$tst_links_gethostbyname_r" = "yes" &&
1581      test "$tst_proto_gethostbyname_r" = "yes" &&
1582      test "$tst_compi_gethostbyname_r" = "yes" &&
1583      test "$tst_allow_gethostbyname_r" = "yes"; then
1584     AC_MSG_RESULT([yes])
1585     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
1586       [Define to 1 if you have the gethostbyname_r function.])
1587     dnl AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_ARGS, $tst_nargs_gethostbyname_r,
1588     dnl   [Specifies the number of arguments to gethostbyname_r])
1589     #
1590     if test "$tst_nargs_gethostbyname_r" -eq "3"; then
1591       AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
1592     elif test "$tst_nargs_gethostbyname_r" -eq "5"; then
1593       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
1594     elif test "$tst_nargs_gethostbyname_r" -eq "6"; then
1595       AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
1596     fi
1597     #
1598     ac_cv_func_gethostbyname_r="yes"
1599   else
1600     AC_MSG_RESULT([no])
1601     ac_cv_func_gethostbyname_r="no"
1602   fi
1603 ])
1604
1605
1606 dnl CURL_CHECK_FUNC_GETHOSTNAME
1607 dnl -------------------------------------------------
1608 dnl Verify if gethostname is available, prototyped, and
1609 dnl can be compiled. If all of these are true, and
1610 dnl usage has not been previously disallowed with
1611 dnl shell variable curl_disallow_gethostname, then
1612 dnl HAVE_GETHOSTNAME will be defined.
1613
1614 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
1615   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1616   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
1617   #
1618   tst_links_gethostname="unknown"
1619   tst_proto_gethostname="unknown"
1620   tst_compi_gethostname="unknown"
1621   tst_allow_gethostname="unknown"
1622   #
1623   AC_MSG_CHECKING([if gethostname can be linked])
1624   AC_LINK_IFELSE([
1625     AC_LANG_PROGRAM([[
1626       $curl_includes_winsock2
1627       $curl_includes_unistd
1628     ]],[[
1629       if(0 != gethostname(0, 0))
1630         return 1;
1631     ]])
1632   ],[
1633     AC_MSG_RESULT([yes])
1634     tst_links_gethostname="yes"
1635   ],[
1636     AC_MSG_RESULT([no])
1637     tst_links_gethostname="no"
1638   ])
1639   #
1640   if test "$tst_links_gethostname" = "yes"; then
1641     AC_MSG_CHECKING([if gethostname is prototyped])
1642     AC_EGREP_CPP([gethostname],[
1643       $curl_includes_winsock2
1644       $curl_includes_unistd
1645     ],[
1646       AC_MSG_RESULT([yes])
1647       tst_proto_gethostname="yes"
1648     ],[
1649       AC_MSG_RESULT([no])
1650       tst_proto_gethostname="no"
1651     ])
1652   fi
1653   #
1654   if test "$tst_proto_gethostname" = "yes"; then
1655     AC_MSG_CHECKING([if gethostname is compilable])
1656     AC_COMPILE_IFELSE([
1657       AC_LANG_PROGRAM([[
1658         $curl_includes_winsock2
1659         $curl_includes_unistd
1660       ]],[[
1661         if(0 != gethostname(0, 0))
1662           return 1;
1663       ]])
1664     ],[
1665       AC_MSG_RESULT([yes])
1666       tst_compi_gethostname="yes"
1667     ],[
1668       AC_MSG_RESULT([no])
1669       tst_compi_gethostname="no"
1670     ])
1671   fi
1672   #
1673   if test "$tst_compi_gethostname" = "yes"; then
1674     AC_MSG_CHECKING([if gethostname usage allowed])
1675     if test "x$curl_disallow_gethostname" != "xyes"; then
1676       AC_MSG_RESULT([yes])
1677       tst_allow_gethostname="yes"
1678     else
1679       AC_MSG_RESULT([no])
1680       tst_allow_gethostname="no"
1681     fi
1682   fi
1683   #
1684   AC_MSG_CHECKING([if gethostname might be used])
1685   if test "$tst_links_gethostname" = "yes" &&
1686      test "$tst_proto_gethostname" = "yes" &&
1687      test "$tst_compi_gethostname" = "yes" &&
1688      test "$tst_allow_gethostname" = "yes"; then
1689     AC_MSG_RESULT([yes])
1690     AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
1691       [Define to 1 if you have the gethostname function.])
1692     ac_cv_func_gethostname="yes"
1693   else
1694     AC_MSG_RESULT([no])
1695     ac_cv_func_gethostname="no"
1696   fi
1697 ])
1698
1699
1700 dnl CURL_CHECK_FUNC_GETIFADDRS
1701 dnl -------------------------------------------------
1702 dnl Verify if getifaddrs is available, prototyped, can
1703 dnl be compiled and seems to work. If all of these are
1704 dnl true, and usage has not been previously disallowed
1705 dnl with shell variable curl_disallow_getifaddrs, then
1706 dnl HAVE_GETIFADDRS will be defined.
1707
1708 AC_DEFUN([CURL_CHECK_FUNC_GETIFADDRS], [
1709   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
1710   AC_REQUIRE([CURL_INCLUDES_IFADDRS])dnl
1711   #
1712   tst_links_getifaddrs="unknown"
1713   tst_proto_getifaddrs="unknown"
1714   tst_compi_getifaddrs="unknown"
1715   tst_works_getifaddrs="unknown"
1716   tst_allow_getifaddrs="unknown"
1717   #
1718   AC_MSG_CHECKING([if getifaddrs can be linked])
1719   AC_LINK_IFELSE([
1720     AC_LANG_FUNC_LINK_TRY([getifaddrs])
1721   ],[
1722     AC_MSG_RESULT([yes])
1723     tst_links_getifaddrs="yes"
1724   ],[
1725     AC_MSG_RESULT([no])
1726     tst_links_getifaddrs="no"
1727   ])
1728   #
1729   if test "$tst_links_getifaddrs" = "yes"; then
1730     AC_MSG_CHECKING([if getifaddrs is prototyped])
1731     AC_EGREP_CPP([getifaddrs],[
1732       $curl_includes_ifaddrs
1733     ],[
1734       AC_MSG_RESULT([yes])
1735       tst_proto_getifaddrs="yes"
1736     ],[
1737       AC_MSG_RESULT([no])
1738       tst_proto_getifaddrs="no"
1739     ])
1740   fi
1741   #
1742   if test "$tst_proto_getifaddrs" = "yes"; then
1743     AC_MSG_CHECKING([if getifaddrs is compilable])
1744     AC_COMPILE_IFELSE([
1745       AC_LANG_PROGRAM([[
1746         $curl_includes_ifaddrs
1747       ]],[[
1748         if(0 != getifaddrs(0))
1749           return 1;
1750       ]])
1751     ],[
1752       AC_MSG_RESULT([yes])
1753       tst_compi_getifaddrs="yes"
1754     ],[
1755       AC_MSG_RESULT([no])
1756       tst_compi_getifaddrs="no"
1757     ])
1758   fi
1759   #
1760   dnl only do runtime verification when not cross-compiling
1761   if test "x$cross_compiling" != "xyes" &&
1762     test "$tst_compi_getifaddrs" = "yes"; then
1763     AC_MSG_CHECKING([if getifaddrs seems to work])
1764     AC_RUN_IFELSE([
1765       AC_LANG_PROGRAM([[
1766         $curl_includes_stdlib
1767         $curl_includes_ifaddrs
1768       ]],[[
1769         struct ifaddrs *ifa = 0;
1770         int error;
1771
1772         error = getifaddrs(&ifa);
1773         if(error || !ifa)
1774           exit(1); /* fail */
1775         else
1776           exit(0);
1777       ]])
1778     ],[
1779       AC_MSG_RESULT([yes])
1780       tst_works_getifaddrs="yes"
1781     ],[
1782       AC_MSG_RESULT([no])
1783       tst_works_getifaddrs="no"
1784     ])
1785   fi
1786   #
1787   if test "$tst_compi_getifaddrs" = "yes" &&
1788     test "$tst_works_getifaddrs" != "no"; then
1789     AC_MSG_CHECKING([if getifaddrs usage allowed])
1790     if test "x$curl_disallow_getifaddrs" != "xyes"; then
1791       AC_MSG_RESULT([yes])
1792       tst_allow_getifaddrs="yes"
1793     else
1794       AC_MSG_RESULT([no])
1795       tst_allow_getifaddrs="no"
1796     fi
1797   fi
1798   #
1799   AC_MSG_CHECKING([if getifaddrs might be used])
1800   if test "$tst_links_getifaddrs" = "yes" &&
1801      test "$tst_proto_getifaddrs" = "yes" &&
1802      test "$tst_compi_getifaddrs" = "yes" &&
1803      test "$tst_allow_getifaddrs" = "yes" &&
1804      test "$tst_works_getifaddrs" != "no"; then
1805     AC_MSG_RESULT([yes])
1806     AC_DEFINE_UNQUOTED(HAVE_GETIFADDRS, 1,
1807       [Define to 1 if you have a working getifaddrs function.])
1808     ac_cv_func_getifaddrs="yes"
1809   else
1810     AC_MSG_RESULT([no])
1811     ac_cv_func_getifaddrs="no"
1812   fi
1813 ])
1814
1815
1816 dnl CURL_CHECK_FUNC_GETSERVBYPORT_R
1817 dnl -------------------------------------------------
1818 dnl Verify if getservbyport_r is available, prototyped,
1819 dnl and can be compiled. If all of these are true, and
1820 dnl usage has not been previously disallowed with
1821 dnl shell variable curl_disallow_getservbyport_r, then
1822 dnl HAVE_GETSERVBYPORT_R will be defined.
1823
1824 AC_DEFUN([CURL_CHECK_FUNC_GETSERVBYPORT_R], [
1825   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1826   #
1827   tst_links_getservbyport_r="unknown"
1828   tst_proto_getservbyport_r="unknown"
1829   tst_compi_getservbyport_r="unknown"
1830   tst_allow_getservbyport_r="unknown"
1831   tst_nargs_getservbyport_r="unknown"
1832   #
1833   AC_MSG_CHECKING([if getservbyport_r can be linked])
1834   AC_LINK_IFELSE([
1835     AC_LANG_FUNC_LINK_TRY([getservbyport_r])
1836   ],[
1837     AC_MSG_RESULT([yes])
1838     tst_links_getservbyport_r="yes"
1839   ],[
1840     AC_MSG_RESULT([no])
1841     tst_links_getservbyport_r="no"
1842   ])
1843   #
1844   if test "$tst_links_getservbyport_r" = "yes"; then
1845     AC_MSG_CHECKING([if getservbyport_r is prototyped])
1846     AC_EGREP_CPP([getservbyport_r],[
1847       $curl_includes_netdb
1848     ],[
1849       AC_MSG_RESULT([yes])
1850       tst_proto_getservbyport_r="yes"
1851     ],[
1852       AC_MSG_RESULT([no])
1853       tst_proto_getservbyport_r="no"
1854     ])
1855   fi
1856   #
1857   if test "$tst_proto_getservbyport_r" = "yes"; then
1858     if test "$tst_nargs_getservbyport_r" = "unknown"; then
1859       AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
1860       AC_COMPILE_IFELSE([
1861         AC_LANG_PROGRAM([[
1862           $curl_includes_netdb
1863         ]],[[
1864           if(0 != getservbyport_r(0, 0, 0, 0))
1865             return 1;
1866         ]])
1867       ],[
1868         AC_MSG_RESULT([yes])
1869         tst_compi_getservbyport_r="yes"
1870         tst_nargs_getservbyport_r="4"
1871       ],[
1872         AC_MSG_RESULT([no])
1873         tst_compi_getservbyport_r="no"
1874       ])
1875     fi
1876     if test "$tst_nargs_getservbyport_r" = "unknown"; then
1877       AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
1878       AC_COMPILE_IFELSE([
1879         AC_LANG_PROGRAM([[
1880           $curl_includes_netdb
1881         ]],[[
1882           if(0 != getservbyport_r(0, 0, 0, 0, 0))
1883             return 1;
1884         ]])
1885       ],[
1886         AC_MSG_RESULT([yes])
1887         tst_compi_getservbyport_r="yes"
1888         tst_nargs_getservbyport_r="5"
1889       ],[
1890         AC_MSG_RESULT([no])
1891         tst_compi_getservbyport_r="no"
1892       ])
1893     fi
1894     if test "$tst_nargs_getservbyport_r" = "unknown"; then
1895       AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
1896       AC_COMPILE_IFELSE([
1897         AC_LANG_PROGRAM([[
1898           $curl_includes_netdb
1899         ]],[[
1900           if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
1901             return 1;
1902         ]])
1903       ],[
1904         AC_MSG_RESULT([yes])
1905         tst_compi_getservbyport_r="yes"
1906         tst_nargs_getservbyport_r="6"
1907       ],[
1908         AC_MSG_RESULT([no])
1909         tst_compi_getservbyport_r="no"
1910       ])
1911     fi
1912     AC_MSG_CHECKING([if getservbyport_r is compilable])
1913     if test "$tst_compi_getservbyport_r" = "yes"; then
1914       AC_MSG_RESULT([yes])
1915     else
1916       AC_MSG_RESULT([no])
1917     fi
1918   fi
1919   #
1920   if test "$tst_compi_getservbyport_r" = "yes"; then
1921     AC_MSG_CHECKING([if getservbyport_r usage allowed])
1922     if test "x$curl_disallow_getservbyport_r" != "xyes"; then
1923       AC_MSG_RESULT([yes])
1924       tst_allow_getservbyport_r="yes"
1925     else
1926       AC_MSG_RESULT([no])
1927       tst_allow_getservbyport_r="no"
1928     fi
1929   fi
1930   #
1931   AC_MSG_CHECKING([if getservbyport_r might be used])
1932   if test "$tst_links_getservbyport_r" = "yes" &&
1933      test "$tst_proto_getservbyport_r" = "yes" &&
1934      test "$tst_compi_getservbyport_r" = "yes" &&
1935      test "$tst_allow_getservbyport_r" = "yes"; then
1936     AC_MSG_RESULT([yes])
1937     AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
1938       [Define to 1 if you have the getservbyport_r function.])
1939     AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
1940       [Specifies the number of arguments to getservbyport_r])
1941     if test "$tst_nargs_getservbyport_r" -eq "4"; then
1942       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
1943         [Specifies the size of the buffer to pass to getservbyport_r])
1944     else
1945       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
1946         [Specifies the size of the buffer to pass to getservbyport_r])
1947     fi
1948     ac_cv_func_getservbyport_r="yes"
1949   else
1950     AC_MSG_RESULT([no])
1951     ac_cv_func_getservbyport_r="no"
1952   fi
1953 ])
1954
1955
1956 dnl CURL_CHECK_FUNC_GMTIME_R
1957 dnl -------------------------------------------------
1958 dnl Verify if gmtime_r is available, prototyped, can
1959 dnl be compiled and seems to work. If all of these are
1960 dnl true, and usage has not been previously disallowed
1961 dnl with shell variable curl_disallow_gmtime_r, then
1962 dnl HAVE_GMTIME_R will be defined.
1963
1964 AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
1965   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
1966   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
1967   #
1968   tst_links_gmtime_r="unknown"
1969   tst_proto_gmtime_r="unknown"
1970   tst_compi_gmtime_r="unknown"
1971   tst_works_gmtime_r="unknown"
1972   tst_allow_gmtime_r="unknown"
1973   #
1974   AC_MSG_CHECKING([if gmtime_r can be linked])
1975   AC_LINK_IFELSE([
1976     AC_LANG_FUNC_LINK_TRY([gmtime_r])
1977   ],[
1978     AC_MSG_RESULT([yes])
1979     tst_links_gmtime_r="yes"
1980   ],[
1981     AC_MSG_RESULT([no])
1982     tst_links_gmtime_r="no"
1983   ])
1984   #
1985   if test "$tst_links_gmtime_r" = "yes"; then
1986     AC_MSG_CHECKING([if gmtime_r is prototyped])
1987     AC_EGREP_CPP([gmtime_r],[
1988       $curl_includes_time
1989     ],[
1990       AC_MSG_RESULT([yes])
1991       tst_proto_gmtime_r="yes"
1992     ],[
1993       AC_MSG_RESULT([no])
1994       tst_proto_gmtime_r="no"
1995     ])
1996   fi
1997   #
1998   if test "$tst_proto_gmtime_r" = "yes"; then
1999     AC_MSG_CHECKING([if gmtime_r is compilable])
2000     AC_COMPILE_IFELSE([
2001       AC_LANG_PROGRAM([[
2002         $curl_includes_time
2003       ]],[[
2004         if(0 != gmtime_r(0, 0))
2005           return 1;
2006       ]])
2007     ],[
2008       AC_MSG_RESULT([yes])
2009       tst_compi_gmtime_r="yes"
2010     ],[
2011       AC_MSG_RESULT([no])
2012       tst_compi_gmtime_r="no"
2013     ])
2014   fi
2015   #
2016   dnl only do runtime verification when not cross-compiling
2017   if test "x$cross_compiling" != "xyes" &&
2018     test "$tst_compi_gmtime_r" = "yes"; then
2019     AC_MSG_CHECKING([if gmtime_r seems to work])
2020     AC_RUN_IFELSE([
2021       AC_LANG_PROGRAM([[
2022         $curl_includes_stdlib
2023         $curl_includes_time
2024       ]],[[
2025         time_t local = 1170352587;
2026         struct tm *gmt = 0;
2027         struct tm result;
2028         gmt = gmtime_r(&local, &result);
2029         if(gmt)
2030           exit(0);
2031         else
2032           exit(1);
2033       ]])
2034     ],[
2035       AC_MSG_RESULT([yes])
2036       tst_works_gmtime_r="yes"
2037     ],[
2038       AC_MSG_RESULT([no])
2039       tst_works_gmtime_r="no"
2040     ])
2041   fi
2042   #
2043   if test "$tst_compi_gmtime_r" = "yes" &&
2044     test "$tst_works_gmtime_r" != "no"; then
2045     AC_MSG_CHECKING([if gmtime_r usage allowed])
2046     if test "x$curl_disallow_gmtime_r" != "xyes"; then
2047       AC_MSG_RESULT([yes])
2048       tst_allow_gmtime_r="yes"
2049     else
2050       AC_MSG_RESULT([no])
2051       tst_allow_gmtime_r="no"
2052     fi
2053   fi
2054   #
2055   AC_MSG_CHECKING([if gmtime_r might be used])
2056   if test "$tst_links_gmtime_r" = "yes" &&
2057      test "$tst_proto_gmtime_r" = "yes" &&
2058      test "$tst_compi_gmtime_r" = "yes" &&
2059      test "$tst_allow_gmtime_r" = "yes" &&
2060      test "$tst_works_gmtime_r" != "no"; then
2061     AC_MSG_RESULT([yes])
2062     AC_DEFINE_UNQUOTED(HAVE_GMTIME_R, 1,
2063       [Define to 1 if you have a working gmtime_r function.])
2064     ac_cv_func_gmtime_r="yes"
2065   else
2066     AC_MSG_RESULT([no])
2067     ac_cv_func_gmtime_r="no"
2068   fi
2069 ])
2070
2071
2072 dnl CURL_CHECK_FUNC_INET_NTOA_R
2073 dnl -------------------------------------------------
2074 dnl Verify if inet_ntoa_r is available, prototyped,
2075 dnl and can be compiled. If all of these are true, and
2076 dnl usage has not been previously disallowed with
2077 dnl shell variable curl_disallow_inet_ntoa_r, then
2078 dnl HAVE_INET_NTOA_R will be defined.
2079
2080 AC_DEFUN([CURL_CHECK_FUNC_INET_NTOA_R], [
2081   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
2082   #
2083   tst_links_inet_ntoa_r="unknown"
2084   tst_proto_inet_ntoa_r="unknown"
2085   tst_compi_inet_ntoa_r="unknown"
2086   tst_allow_inet_ntoa_r="unknown"
2087   tst_nargs_inet_ntoa_r="unknown"
2088   #
2089   AC_MSG_CHECKING([if inet_ntoa_r can be linked])
2090   AC_LINK_IFELSE([
2091     AC_LANG_FUNC_LINK_TRY([inet_ntoa_r])
2092   ],[
2093     AC_MSG_RESULT([yes])
2094     tst_links_inet_ntoa_r="yes"
2095   ],[
2096     AC_MSG_RESULT([no])
2097     tst_links_inet_ntoa_r="no"
2098   ])
2099   #
2100   if test "$tst_links_inet_ntoa_r" = "yes"; then
2101     AC_MSG_CHECKING([if inet_ntoa_r is prototyped])
2102     AC_EGREP_CPP([inet_ntoa_r],[
2103       $curl_includes_arpa_inet
2104     ],[
2105       AC_MSG_RESULT([yes])
2106       tst_proto_inet_ntoa_r="yes"
2107     ],[
2108       AC_MSG_RESULT([no])
2109       tst_proto_inet_ntoa_r="no"
2110     ])
2111   fi
2112   #
2113   if test "$tst_proto_inet_ntoa_r" = "yes"; then
2114     if test "$tst_nargs_inet_ntoa_r" = "unknown"; then
2115       AC_MSG_CHECKING([if inet_ntoa_r takes 2 args.])
2116       AC_COMPILE_IFELSE([
2117         AC_LANG_PROGRAM([[
2118           $curl_includes_arpa_inet
2119         ]],[[
2120           struct in_addr addr;
2121           if(0 != inet_ntoa_r(addr, 0))
2122             return 1;
2123         ]])
2124       ],[
2125         AC_MSG_RESULT([yes])
2126         tst_compi_inet_ntoa_r="yes"
2127         tst_nargs_inet_ntoa_r="2"
2128       ],[
2129         AC_MSG_RESULT([no])
2130         tst_compi_inet_ntoa_r="no"
2131       ])
2132     fi
2133     if test "$tst_nargs_inet_ntoa_r" = "unknown"; then
2134       AC_MSG_CHECKING([if inet_ntoa_r takes 3 args.])
2135       AC_COMPILE_IFELSE([
2136         AC_LANG_PROGRAM([[
2137           $curl_includes_arpa_inet
2138         ]],[[
2139           struct in_addr addr;
2140           if(0 != inet_ntoa_r(addr, 0, 0))
2141             return 1;
2142         ]])
2143       ],[
2144         AC_MSG_RESULT([yes])
2145         tst_compi_inet_ntoa_r="yes"
2146         tst_nargs_inet_ntoa_r="3"
2147       ],[
2148         AC_MSG_RESULT([no])
2149         tst_compi_inet_ntoa_r="no"
2150       ])
2151     fi
2152     AC_MSG_CHECKING([if inet_ntoa_r is compilable])
2153     if test "$tst_compi_inet_ntoa_r" = "yes"; then
2154       AC_MSG_RESULT([yes])
2155     else
2156       AC_MSG_RESULT([no])
2157     fi
2158   fi
2159   #
2160   if test "$tst_compi_inet_ntoa_r" = "yes"; then
2161     AC_MSG_CHECKING([if inet_ntoa_r usage allowed])
2162     if test "x$curl_disallow_inet_ntoa_r" != "xyes"; then
2163       AC_MSG_RESULT([yes])
2164       tst_allow_inet_ntoa_r="yes"
2165     else
2166       AC_MSG_RESULT([no])
2167       tst_allow_inet_ntoa_r="no"
2168     fi
2169   fi
2170   #
2171   AC_MSG_CHECKING([if inet_ntoa_r might be used])
2172   if test "$tst_links_inet_ntoa_r" = "yes" &&
2173      test "$tst_proto_inet_ntoa_r" = "yes" &&
2174      test "$tst_compi_inet_ntoa_r" = "yes" &&
2175      test "$tst_allow_inet_ntoa_r" = "yes"; then
2176     AC_MSG_RESULT([yes])
2177     AC_DEFINE_UNQUOTED(HAVE_INET_NTOA_R, 1,
2178       [Define to 1 if you have the inet_ntoa_r function.])
2179     dnl AC_DEFINE_UNQUOTED(INET_NTOA_R_ARGS, $tst_nargs_inet_ntoa_r,
2180     dnl   [Specifies the number of arguments to inet_ntoa_r])
2181     #
2182     if test "$tst_nargs_inet_ntoa_r" -eq "2"; then
2183       AC_DEFINE(HAVE_INET_NTOA_R_2, 1, [inet_ntoa_r() takes 2 args])
2184     elif test "$tst_nargs_inet_ntoa_r" -eq "3"; then
2185       AC_DEFINE(HAVE_INET_NTOA_R_3, 1, [inet_ntoa_r() takes 3 args])
2186     fi
2187     #
2188     ac_cv_func_inet_ntoa_r="yes"
2189   else
2190     AC_MSG_RESULT([no])
2191     ac_cv_func_inet_ntoa_r="no"
2192   fi
2193 ])
2194
2195
2196 dnl CURL_CHECK_FUNC_INET_NTOP
2197 dnl -------------------------------------------------
2198 dnl Verify if inet_ntop is available, prototyped, can
2199 dnl be compiled and seems to work. If all of these are
2200 dnl true, and usage has not been previously disallowed
2201 dnl with shell variable curl_disallow_inet_ntop, then
2202 dnl HAVE_INET_NTOP will be defined.
2203
2204 AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
2205   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2206   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
2207   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
2208   #
2209   tst_links_inet_ntop="unknown"
2210   tst_proto_inet_ntop="unknown"
2211   tst_compi_inet_ntop="unknown"
2212   tst_works_inet_ntop="unknown"
2213   tst_allow_inet_ntop="unknown"
2214   #
2215   AC_MSG_CHECKING([if inet_ntop can be linked])
2216   AC_LINK_IFELSE([
2217     AC_LANG_FUNC_LINK_TRY([inet_ntop])
2218   ],[
2219     AC_MSG_RESULT([yes])
2220     tst_links_inet_ntop="yes"
2221   ],[
2222     AC_MSG_RESULT([no])
2223     tst_links_inet_ntop="no"
2224   ])
2225   #
2226   if test "$tst_links_inet_ntop" = "yes"; then
2227     AC_MSG_CHECKING([if inet_ntop is prototyped])
2228     AC_EGREP_CPP([inet_ntop],[
2229       $curl_includes_arpa_inet
2230     ],[
2231       AC_MSG_RESULT([yes])
2232       tst_proto_inet_ntop="yes"
2233     ],[
2234       AC_MSG_RESULT([no])
2235       tst_proto_inet_ntop="no"
2236     ])
2237   fi
2238   #
2239   if test "$tst_proto_inet_ntop" = "yes"; then
2240     AC_MSG_CHECKING([if inet_ntop is compilable])
2241     AC_COMPILE_IFELSE([
2242       AC_LANG_PROGRAM([[
2243         $curl_includes_arpa_inet
2244       ]],[[
2245         if(0 != inet_ntop(0, 0, 0, 0))
2246           return 1;
2247       ]])
2248     ],[
2249       AC_MSG_RESULT([yes])
2250       tst_compi_inet_ntop="yes"
2251     ],[
2252       AC_MSG_RESULT([no])
2253       tst_compi_inet_ntop="no"
2254     ])
2255   fi
2256   #
2257   dnl only do runtime verification when not cross-compiling
2258   if test "x$cross_compiling" != "xyes" &&
2259     test "$tst_compi_inet_ntop" = "yes"; then
2260     AC_MSG_CHECKING([if inet_ntop seems to work])
2261     AC_RUN_IFELSE([
2262       AC_LANG_PROGRAM([[
2263         $curl_includes_stdlib
2264         $curl_includes_arpa_inet
2265         $curl_includes_string
2266       ]],[[
2267         char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
2268         char ipv4res[sizeof "255.255.255.255"];
2269         unsigned char ipv6a[26];
2270         unsigned char ipv4a[5];
2271         char *ipv6ptr = 0;
2272         char *ipv4ptr = 0;
2273         /* - */
2274         ipv4res[0] = '\0';
2275         ipv4a[0] = 0xc0;
2276         ipv4a[1] = 0xa8;
2277         ipv4a[2] = 0x64;
2278         ipv4a[3] = 0x01;
2279         ipv4a[4] = 0x01;
2280         /* - */
2281         ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
2282         if(!ipv4ptr)
2283           exit(1); /* fail */
2284         if(ipv4ptr != ipv4res)
2285           exit(1); /* fail */
2286         if(!ipv4ptr[0])
2287           exit(1); /* fail */
2288         if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
2289           exit(1); /* fail */
2290         /* - */
2291         ipv6res[0] = '\0';
2292         memset(ipv6a, 0, sizeof(ipv6a));
2293         ipv6a[0] = 0xfe;
2294         ipv6a[1] = 0x80;
2295         ipv6a[8] = 0x02;
2296         ipv6a[9] = 0x14;
2297         ipv6a[10] = 0x4f;
2298         ipv6a[11] = 0xff;
2299         ipv6a[12] = 0xfe;
2300         ipv6a[13] = 0x0b;
2301         ipv6a[14] = 0x76;
2302         ipv6a[15] = 0xc8;
2303         ipv6a[25] = 0x01;
2304         /* - */
2305         ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
2306         if(!ipv6ptr)
2307           exit(1); /* fail */
2308         if(ipv6ptr != ipv6res)
2309           exit(1); /* fail */
2310         if(!ipv6ptr[0])
2311           exit(1); /* fail */
2312         if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0)
2313           exit(1); /* fail */
2314         /* - */
2315         exit(0);
2316       ]])
2317     ],[
2318       AC_MSG_RESULT([yes])
2319       tst_works_inet_ntop="yes"
2320     ],[
2321       AC_MSG_RESULT([no])
2322       tst_works_inet_ntop="no"
2323     ])
2324   fi
2325   #
2326   if test "$tst_compi_inet_ntop" = "yes" &&
2327     test "$tst_works_inet_ntop" != "no"; then
2328     AC_MSG_CHECKING([if inet_ntop usage allowed])
2329     if test "x$curl_disallow_inet_ntop" != "xyes"; then
2330       AC_MSG_RESULT([yes])
2331       tst_allow_inet_ntop="yes"
2332     else
2333       AC_MSG_RESULT([no])
2334       tst_allow_inet_ntop="no"
2335     fi
2336   fi
2337   #
2338   AC_MSG_CHECKING([if inet_ntop might be used])
2339   if test "$tst_links_inet_ntop" = "yes" &&
2340      test "$tst_proto_inet_ntop" = "yes" &&
2341      test "$tst_compi_inet_ntop" = "yes" &&
2342      test "$tst_allow_inet_ntop" = "yes" &&
2343      test "$tst_works_inet_ntop" != "no"; then
2344     AC_MSG_RESULT([yes])
2345     AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, 1,
2346       [Define to 1 if you have a IPv6 capable working inet_ntop function.])
2347     ac_cv_func_inet_ntop="yes"
2348   else
2349     AC_MSG_RESULT([no])
2350     ac_cv_func_inet_ntop="no"
2351   fi
2352 ])
2353
2354
2355 dnl CURL_CHECK_FUNC_INET_PTON
2356 dnl -------------------------------------------------
2357 dnl Verify if inet_pton is available, prototyped, can
2358 dnl be compiled and seems to work. If all of these are
2359 dnl true, and usage has not been previously disallowed
2360 dnl with shell variable curl_disallow_inet_pton, then
2361 dnl HAVE_INET_PTON will be defined.
2362
2363 AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [
2364   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2365   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
2366   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
2367   #
2368   tst_links_inet_pton="unknown"
2369   tst_proto_inet_pton="unknown"
2370   tst_compi_inet_pton="unknown"
2371   tst_works_inet_pton="unknown"
2372   tst_allow_inet_pton="unknown"
2373   #
2374   AC_MSG_CHECKING([if inet_pton can be linked])
2375   AC_LINK_IFELSE([
2376     AC_LANG_FUNC_LINK_TRY([inet_pton])
2377   ],[
2378     AC_MSG_RESULT([yes])
2379     tst_links_inet_pton="yes"
2380   ],[
2381     AC_MSG_RESULT([no])
2382     tst_links_inet_pton="no"
2383   ])
2384   #
2385   if test "$tst_links_inet_pton" = "yes"; then
2386     AC_MSG_CHECKING([if inet_pton is prototyped])
2387     AC_EGREP_CPP([inet_pton],[
2388       $curl_includes_arpa_inet
2389     ],[
2390       AC_MSG_RESULT([yes])
2391       tst_proto_inet_pton="yes"
2392     ],[
2393       AC_MSG_RESULT([no])
2394       tst_proto_inet_pton="no"
2395     ])
2396   fi
2397   #
2398   if test "$tst_proto_inet_pton" = "yes"; then
2399     AC_MSG_CHECKING([if inet_pton is compilable])
2400     AC_COMPILE_IFELSE([
2401       AC_LANG_PROGRAM([[
2402         $curl_includes_arpa_inet
2403       ]],[[
2404         if(0 != inet_pton(0, 0, 0))
2405           return 1;
2406       ]])
2407     ],[
2408       AC_MSG_RESULT([yes])
2409       tst_compi_inet_pton="yes"
2410     ],[
2411       AC_MSG_RESULT([no])
2412       tst_compi_inet_pton="no"
2413     ])
2414   fi
2415   #
2416   dnl only do runtime verification when not cross-compiling
2417   if test "x$cross_compiling" != "xyes" &&
2418     test "$tst_compi_inet_pton" = "yes"; then
2419     AC_MSG_CHECKING([if inet_pton seems to work])
2420     AC_RUN_IFELSE([
2421       AC_LANG_PROGRAM([[
2422         $curl_includes_stdlib
2423         $curl_includes_arpa_inet
2424         $curl_includes_string
2425       ]],[[
2426         unsigned char ipv6a[16+1];
2427         unsigned char ipv4a[4+1];
2428         const char *ipv6src = "fe80::214:4fff:fe0b:76c8";
2429         const char *ipv4src = "192.168.100.1";
2430         /* - */
2431         memset(ipv4a, 1, sizeof(ipv4a));
2432         if(1 != inet_pton(AF_INET, ipv4src, ipv4a))
2433           exit(1); /* fail */
2434         /* - */
2435         if( (ipv4a[0] != 0xc0) ||
2436             (ipv4a[1] != 0xa8) ||
2437             (ipv4a[2] != 0x64) ||
2438             (ipv4a[3] != 0x01) ||
2439             (ipv4a[4] != 0x01) )
2440           exit(1); /* fail */
2441         /* - */
2442         memset(ipv6a, 1, sizeof(ipv6a));
2443         if(1 != inet_pton(AF_INET6, ipv6src, ipv6a))
2444           exit(1); /* fail */
2445         /* - */
2446         if( (ipv6a[0]  != 0xfe) ||
2447             (ipv6a[1]  != 0x80) ||
2448             (ipv6a[8]  != 0x02) ||
2449             (ipv6a[9]  != 0x14) ||
2450             (ipv6a[10] != 0x4f) ||
2451             (ipv6a[11] != 0xff) ||
2452             (ipv6a[12] != 0xfe) ||
2453             (ipv6a[13] != 0x0b) ||
2454             (ipv6a[14] != 0x76) ||
2455             (ipv6a[15] != 0xc8) ||
2456             (ipv6a[16] != 0x01) )
2457           exit(1); /* fail */
2458         /* - */
2459         if( (ipv6a[2]  != 0x0) ||
2460             (ipv6a[3]  != 0x0) ||
2461             (ipv6a[4]  != 0x0) ||
2462             (ipv6a[5]  != 0x0) ||
2463             (ipv6a[6]  != 0x0) ||
2464             (ipv6a[7]  != 0x0) )
2465           exit(1); /* fail */
2466         /* - */
2467         exit(0);
2468       ]])
2469     ],[
2470       AC_MSG_RESULT([yes])
2471       tst_works_inet_pton="yes"
2472     ],[
2473       AC_MSG_RESULT([no])
2474       tst_works_inet_pton="no"
2475     ])
2476   fi
2477   #
2478   if test "$tst_compi_inet_pton" = "yes" &&
2479     test "$tst_works_inet_pton" != "no"; then
2480     AC_MSG_CHECKING([if inet_pton usage allowed])
2481     if test "x$curl_disallow_inet_pton" != "xyes"; then
2482       AC_MSG_RESULT([yes])
2483       tst_allow_inet_pton="yes"
2484     else
2485       AC_MSG_RESULT([no])
2486       tst_allow_inet_pton="no"
2487     fi
2488   fi
2489   #
2490   AC_MSG_CHECKING([if inet_pton might be used])
2491   if test "$tst_links_inet_pton" = "yes" &&
2492      test "$tst_proto_inet_pton" = "yes" &&
2493      test "$tst_compi_inet_pton" = "yes" &&
2494      test "$tst_allow_inet_pton" = "yes" &&
2495      test "$tst_works_inet_pton" != "no"; then
2496     AC_MSG_RESULT([yes])
2497     AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1,
2498       [Define to 1 if you have a IPv6 capable working inet_pton function.])
2499     ac_cv_func_inet_pton="yes"
2500   else
2501     AC_MSG_RESULT([no])
2502     ac_cv_func_inet_pton="no"
2503   fi
2504 ])
2505
2506
2507 dnl CURL_CHECK_FUNC_IOCTL
2508 dnl -------------------------------------------------
2509 dnl Verify if ioctl is available, prototyped, and
2510 dnl can be compiled. If all of these are true, and
2511 dnl usage has not been previously disallowed with
2512 dnl shell variable curl_disallow_ioctl, then
2513 dnl HAVE_IOCTL will be defined.
2514
2515 AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [
2516   AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
2517   #
2518   tst_links_ioctl="unknown"
2519   tst_proto_ioctl="unknown"
2520   tst_compi_ioctl="unknown"
2521   tst_allow_ioctl="unknown"
2522   #
2523   AC_MSG_CHECKING([if ioctl can be linked])
2524   AC_LINK_IFELSE([
2525     AC_LANG_FUNC_LINK_TRY([ioctl])
2526   ],[
2527     AC_MSG_RESULT([yes])
2528     tst_links_ioctl="yes"
2529   ],[
2530     AC_MSG_RESULT([no])
2531     tst_links_ioctl="no"
2532   ])
2533   #
2534   if test "$tst_links_ioctl" = "yes"; then
2535     AC_MSG_CHECKING([if ioctl is prototyped])
2536     AC_EGREP_CPP([ioctl],[
2537       $curl_includes_stropts
2538     ],[
2539       AC_MSG_RESULT([yes])
2540       tst_proto_ioctl="yes"
2541     ],[
2542       AC_MSG_RESULT([no])
2543       tst_proto_ioctl="no"
2544     ])
2545   fi
2546   #
2547   if test "$tst_proto_ioctl" = "yes"; then
2548     AC_MSG_CHECKING([if ioctl is compilable])
2549     AC_COMPILE_IFELSE([
2550       AC_LANG_PROGRAM([[
2551         $curl_includes_stropts
2552       ]],[[
2553         if(0 != ioctl(0, 0, 0))
2554           return 1;
2555       ]])
2556     ],[
2557       AC_MSG_RESULT([yes])
2558       tst_compi_ioctl="yes"
2559     ],[
2560       AC_MSG_RESULT([no])
2561       tst_compi_ioctl="no"
2562     ])
2563   fi
2564   #
2565   if test "$tst_compi_ioctl" = "yes"; then
2566     AC_MSG_CHECKING([if ioctl usage allowed])
2567     if test "x$curl_disallow_ioctl" != "xyes"; then
2568       AC_MSG_RESULT([yes])
2569       tst_allow_ioctl="yes"
2570     else
2571       AC_MSG_RESULT([no])
2572       tst_allow_ioctl="no"
2573     fi
2574   fi
2575   #
2576   AC_MSG_CHECKING([if ioctl might be used])
2577   if test "$tst_links_ioctl" = "yes" &&
2578      test "$tst_proto_ioctl" = "yes" &&
2579      test "$tst_compi_ioctl" = "yes" &&
2580      test "$tst_allow_ioctl" = "yes"; then
2581     AC_MSG_RESULT([yes])
2582     AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
2583       [Define to 1 if you have the ioctl function.])
2584     ac_cv_func_ioctl="yes"
2585     CURL_CHECK_FUNC_IOCTL_FIONBIO
2586     CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
2587   else
2588     AC_MSG_RESULT([no])
2589     ac_cv_func_ioctl="no"
2590   fi
2591 ])
2592
2593
2594 dnl CURL_CHECK_FUNC_IOCTL_FIONBIO
2595 dnl -------------------------------------------------
2596 dnl Verify if ioctl with the FIONBIO command is
2597 dnl available, can be compiled, and seems to work. If
2598 dnl all of these are true, then HAVE_IOCTL_FIONBIO
2599 dnl will be defined.
2600
2601 AC_DEFUN([CURL_CHECK_FUNC_IOCTL_FIONBIO], [
2602   #
2603   tst_compi_ioctl_fionbio="unknown"
2604   tst_allow_ioctl_fionbio="unknown"
2605   #
2606   if test "$ac_cv_func_ioctl" = "yes"; then
2607     AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
2608     AC_COMPILE_IFELSE([
2609       AC_LANG_PROGRAM([[
2610         $curl_includes_stropts
2611       ]],[[
2612         int flags = 0;
2613         if(0 != ioctl(0, FIONBIO, &flags))
2614           return 1;
2615       ]])
2616     ],[
2617       AC_MSG_RESULT([yes])
2618       tst_compi_ioctl_fionbio="yes"
2619     ],[
2620       AC_MSG_RESULT([no])
2621       tst_compi_ioctl_fionbio="no"
2622     ])
2623   fi
2624   #
2625   if test "$tst_compi_ioctl_fionbio" = "yes"; then
2626     AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
2627     if test "x$curl_disallow_ioctl_fionbio" != "xyes"; then
2628       AC_MSG_RESULT([yes])
2629       tst_allow_ioctl_fionbio="yes"
2630     else
2631       AC_MSG_RESULT([no])
2632       tst_allow_ioctl_fionbio="no"
2633     fi
2634   fi
2635   #
2636   AC_MSG_CHECKING([if ioctl FIONBIO might be used])
2637   if test "$tst_compi_ioctl_fionbio" = "yes" &&
2638      test "$tst_allow_ioctl_fionbio" = "yes"; then
2639     AC_MSG_RESULT([yes])
2640     AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
2641       [Define to 1 if you have a working ioctl FIONBIO function.])
2642     ac_cv_func_ioctl_fionbio="yes"
2643   else
2644     AC_MSG_RESULT([no])
2645     ac_cv_func_ioctl_fionbio="no"
2646   fi
2647 ])
2648
2649
2650 dnl CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
2651 dnl -------------------------------------------------
2652 dnl Verify if ioctl with the SIOCGIFADDR command is
2653 dnl available, can be compiled, and seems to work. If
2654 dnl all of these are true, then HAVE_IOCTL_SIOCGIFADDR
2655 dnl will be defined.
2656
2657 AC_DEFUN([CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR], [
2658   #
2659   tst_compi_ioctl_siocgifaddr="unknown"
2660   tst_allow_ioctl_siocgifaddr="unknown"
2661   #
2662   if test "$ac_cv_func_ioctl" = "yes"; then
2663     AC_MSG_CHECKING([if ioctl SIOCGIFADDR is compilable])
2664     AC_COMPILE_IFELSE([
2665       AC_LANG_PROGRAM([[
2666         $curl_includes_stropts
2667       ]],[[
2668         if(0 != ioctl(0, SIOCGIFADDR, 0))
2669           return 1;
2670       ]])
2671     ],[
2672       AC_MSG_RESULT([yes])
2673       tst_compi_ioctl_siocgifaddr="yes"
2674     ],[
2675       AC_MSG_RESULT([no])
2676       tst_compi_ioctl_siocgifaddr="no"
2677     ])
2678   fi
2679   #
2680   if test "$tst_compi_ioctl_siocgifaddr" = "yes"; then
2681     AC_MSG_CHECKING([if ioctl SIOCGIFADDR usage allowed])
2682     if test "x$curl_disallow_ioctl_siocgifaddr" != "xyes"; then
2683       AC_MSG_RESULT([yes])
2684       tst_allow_ioctl_siocgifaddr="yes"
2685     else
2686       AC_MSG_RESULT([no])
2687       tst_allow_ioctl_siocgifaddr="no"
2688     fi
2689   fi
2690   #
2691   AC_MSG_CHECKING([if ioctl SIOCGIFADDR might be used])
2692   if test "$tst_compi_ioctl_siocgifaddr" = "yes" &&
2693      test "$tst_allow_ioctl_siocgifaddr" = "yes"; then
2694     AC_MSG_RESULT([yes])
2695     AC_DEFINE_UNQUOTED(HAVE_IOCTL_SIOCGIFADDR, 1,
2696       [Define to 1 if you have a working ioctl SIOCGIFADDR function.])
2697     ac_cv_func_ioctl_siocgifaddr="yes"
2698   else
2699     AC_MSG_RESULT([no])
2700     ac_cv_func_ioctl_siocgifaddr="no"
2701   fi
2702 ])
2703
2704
2705 dnl CURL_CHECK_FUNC_IOCTLSOCKET
2706 dnl -------------------------------------------------
2707 dnl Verify if ioctlsocket is available, prototyped, and
2708 dnl can be compiled. If all of these are true, and
2709 dnl usage has not been previously disallowed with
2710 dnl shell variable curl_disallow_ioctlsocket, then
2711 dnl HAVE_IOCTLSOCKET will be defined.
2712
2713 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [
2714   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2715   #
2716   tst_links_ioctlsocket="unknown"
2717   tst_proto_ioctlsocket="unknown"
2718   tst_compi_ioctlsocket="unknown"
2719   tst_allow_ioctlsocket="unknown"
2720   #
2721   AC_MSG_CHECKING([if ioctlsocket can be linked])
2722   AC_LINK_IFELSE([
2723     AC_LANG_PROGRAM([[
2724       $curl_includes_winsock2
2725     ]],[[
2726       if(0 != ioctlsocket(0, 0, 0))
2727         return 1;
2728     ]])
2729   ],[
2730     AC_MSG_RESULT([yes])
2731     tst_links_ioctlsocket="yes"
2732   ],[
2733     AC_MSG_RESULT([no])
2734     tst_links_ioctlsocket="no"
2735   ])
2736   #
2737   if test "$tst_links_ioctlsocket" = "yes"; then
2738     AC_MSG_CHECKING([if ioctlsocket is prototyped])
2739     AC_EGREP_CPP([ioctlsocket],[
2740       $curl_includes_winsock2
2741     ],[
2742       AC_MSG_RESULT([yes])
2743       tst_proto_ioctlsocket="yes"
2744     ],[
2745       AC_MSG_RESULT([no])
2746       tst_proto_ioctlsocket="no"
2747     ])
2748   fi
2749   #
2750   if test "$tst_proto_ioctlsocket" = "yes"; then
2751     AC_MSG_CHECKING([if ioctlsocket is compilable])
2752     AC_COMPILE_IFELSE([
2753       AC_LANG_PROGRAM([[
2754         $curl_includes_winsock2
2755       ]],[[
2756         if(0 != ioctlsocket(0, 0, 0))
2757           return 1;
2758       ]])
2759     ],[
2760       AC_MSG_RESULT([yes])
2761       tst_compi_ioctlsocket="yes"
2762     ],[
2763       AC_MSG_RESULT([no])
2764       tst_compi_ioctlsocket="no"
2765     ])
2766   fi
2767   #
2768   if test "$tst_compi_ioctlsocket" = "yes"; then
2769     AC_MSG_CHECKING([if ioctlsocket usage allowed])
2770     if test "x$curl_disallow_ioctlsocket" != "xyes"; then
2771       AC_MSG_RESULT([yes])
2772       tst_allow_ioctlsocket="yes"
2773     else
2774       AC_MSG_RESULT([no])
2775       tst_allow_ioctlsocket="no"
2776     fi
2777   fi
2778   #
2779   AC_MSG_CHECKING([if ioctlsocket might be used])
2780   if test "$tst_links_ioctlsocket" = "yes" &&
2781      test "$tst_proto_ioctlsocket" = "yes" &&
2782      test "$tst_compi_ioctlsocket" = "yes" &&
2783      test "$tst_allow_ioctlsocket" = "yes"; then
2784     AC_MSG_RESULT([yes])
2785     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
2786       [Define to 1 if you have the ioctlsocket function.])
2787     ac_cv_func_ioctlsocket="yes"
2788     CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
2789   else
2790     AC_MSG_RESULT([no])
2791     ac_cv_func_ioctlsocket="no"
2792   fi
2793 ])
2794
2795
2796 dnl CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
2797 dnl -------------------------------------------------
2798 dnl Verify if ioctlsocket with the FIONBIO command is
2799 dnl available, can be compiled, and seems to work. If
2800 dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
2801 dnl will be defined.
2802
2803 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
2804   #
2805   tst_compi_ioctlsocket_fionbio="unknown"
2806   tst_allow_ioctlsocket_fionbio="unknown"
2807   #
2808   if test "$ac_cv_func_ioctlsocket" = "yes"; then
2809     AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
2810     AC_COMPILE_IFELSE([
2811       AC_LANG_PROGRAM([[
2812         $curl_includes_winsock2
2813       ]],[[
2814         int flags = 0;
2815         if(0 != ioctlsocket(0, FIONBIO, &flags))
2816           return 1;
2817       ]])
2818     ],[
2819       AC_MSG_RESULT([yes])
2820       tst_compi_ioctlsocket_fionbio="yes"
2821     ],[
2822       AC_MSG_RESULT([no])
2823       tst_compi_ioctlsocket_fionbio="no"
2824     ])
2825   fi
2826   #
2827   if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
2828     AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
2829     if test "x$curl_disallow_ioctlsocket_fionbio" != "xyes"; then
2830       AC_MSG_RESULT([yes])
2831       tst_allow_ioctlsocket_fionbio="yes"
2832     else
2833       AC_MSG_RESULT([no])
2834       tst_allow_ioctlsocket_fionbio="no"
2835     fi
2836   fi
2837   #
2838   AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
2839   if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
2840      test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
2841     AC_MSG_RESULT([yes])
2842     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
2843       [Define to 1 if you have a working ioctlsocket FIONBIO function.])
2844     ac_cv_func_ioctlsocket_fionbio="yes"
2845   else
2846     AC_MSG_RESULT([no])
2847     ac_cv_func_ioctlsocket_fionbio="no"
2848   fi
2849 ])
2850
2851
2852 dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
2853 dnl -------------------------------------------------
2854 dnl Verify if IoctlSocket is available, prototyped, and
2855 dnl can be compiled. If all of these are true, and
2856 dnl usage has not been previously disallowed with
2857 dnl shell variable curl_disallow_ioctlsocket_camel,
2858 dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
2859
2860 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
2861   AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
2862   #
2863   tst_links_ioctlsocket_camel="unknown"
2864   tst_proto_ioctlsocket_camel="unknown"
2865   tst_compi_ioctlsocket_camel="unknown"
2866   tst_allow_ioctlsocket_camel="unknown"
2867   #
2868   AC_MSG_CHECKING([if IoctlSocket can be linked])
2869   AC_LINK_IFELSE([
2870     AC_LANG_FUNC_LINK_TRY([IoctlSocket])
2871   ],[
2872     AC_MSG_RESULT([yes])
2873     tst_links_ioctlsocket_camel="yes"
2874   ],[
2875     AC_MSG_RESULT([no])
2876     tst_links_ioctlsocket_camel="no"
2877   ])
2878   #
2879   if test "$tst_links_ioctlsocket_camel" = "yes"; then
2880     AC_MSG_CHECKING([if IoctlSocket is prototyped])
2881     AC_EGREP_CPP([IoctlSocket],[
2882       $curl_includes_stropts
2883     ],[
2884       AC_MSG_RESULT([yes])
2885       tst_proto_ioctlsocket_camel="yes"
2886     ],[
2887       AC_MSG_RESULT([no])
2888       tst_proto_ioctlsocket_camel="no"
2889     ])
2890   fi
2891   #
2892   if test "$tst_proto_ioctlsocket_camel" = "yes"; then
2893     AC_MSG_CHECKING([if IoctlSocket is compilable])
2894     AC_COMPILE_IFELSE([
2895       AC_LANG_PROGRAM([[
2896         $curl_includes_stropts
2897       ]],[[
2898         if(0 != IoctlSocket(0, 0, 0))
2899           return 1;
2900       ]])
2901     ],[
2902       AC_MSG_RESULT([yes])
2903       tst_compi_ioctlsocket_camel="yes"
2904     ],[
2905       AC_MSG_RESULT([no])
2906       tst_compi_ioctlsocket_camel="no"
2907     ])
2908   fi
2909   #
2910   if test "$tst_compi_ioctlsocket_camel" = "yes"; then
2911     AC_MSG_CHECKING([if IoctlSocket usage allowed])
2912     if test "x$curl_disallow_ioctlsocket_camel" != "xyes"; then
2913       AC_MSG_RESULT([yes])
2914       tst_allow_ioctlsocket_camel="yes"
2915     else
2916       AC_MSG_RESULT([no])
2917       tst_allow_ioctlsocket_camel="no"
2918     fi
2919   fi
2920   #
2921   AC_MSG_CHECKING([if IoctlSocket might be used])
2922   if test "$tst_links_ioctlsocket_camel" = "yes" &&
2923      test "$tst_proto_ioctlsocket_camel" = "yes" &&
2924      test "$tst_compi_ioctlsocket_camel" = "yes" &&
2925      test "$tst_allow_ioctlsocket_camel" = "yes"; then
2926     AC_MSG_RESULT([yes])
2927     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
2928       [Define to 1 if you have the IoctlSocket camel case function.])
2929     ac_cv_func_ioctlsocket_camel="yes"
2930     CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
2931   else
2932     AC_MSG_RESULT([no])
2933     ac_cv_func_ioctlsocket_camel="no"
2934   fi
2935 ])
2936
2937
2938 dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
2939 dnl -------------------------------------------------
2940 dnl Verify if IoctlSocket with FIONBIO command is available,
2941 dnl can be compiled, and seems to work. If all of these are
2942 dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
2943
2944 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
2945   #
2946   tst_compi_ioctlsocket_camel_fionbio="unknown"
2947   tst_allow_ioctlsocket_camel_fionbio="unknown"
2948   #
2949   if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then
2950     AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
2951     AC_COMPILE_IFELSE([
2952       AC_LANG_PROGRAM([[
2953         $curl_includes_stropts
2954       ]],[[
2955         long flags = 0;
2956         if(0 != ioctlsocket(0, FIONBIO, &flags))
2957           return 1;
2958       ]])
2959     ],[
2960       AC_MSG_RESULT([yes])
2961       tst_compi_ioctlsocket_camel_fionbio="yes"
2962     ],[
2963       AC_MSG_RESULT([no])
2964       tst_compi_ioctlsocket_camel_fionbio="no"
2965     ])
2966   fi
2967   #
2968   if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
2969     AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
2970     if test "x$curl_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
2971       AC_MSG_RESULT([yes])
2972       tst_allow_ioctlsocket_camel_fionbio="yes"
2973     else
2974       AC_MSG_RESULT([no])
2975       tst_allow_ioctlsocket_camel_fionbio="no"
2976     fi
2977   fi
2978   #
2979   AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
2980   if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
2981      test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
2982     AC_MSG_RESULT([yes])
2983     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
2984       [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
2985     ac_cv_func_ioctlsocket_camel_fionbio="yes"
2986   else
2987     AC_MSG_RESULT([no])
2988     ac_cv_func_ioctlsocket_camel_fionbio="no"
2989   fi
2990 ])
2991
2992
2993 dnl CURL_CHECK_FUNC_LOCALTIME_R
2994 dnl -------------------------------------------------
2995 dnl Verify if localtime_r is available, prototyped, can
2996 dnl be compiled and seems to work. If all of these are
2997 dnl true, and usage has not been previously disallowed
2998 dnl with shell variable curl_disallow_localtime_r, then
2999 dnl HAVE_LOCALTIME_R will be defined.
3000
3001 AC_DEFUN([CURL_CHECK_FUNC_LOCALTIME_R], [
3002   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3003   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
3004   #
3005   tst_links_localtime_r="unknown"
3006   tst_proto_localtime_r="unknown"
3007   tst_compi_localtime_r="unknown"
3008   tst_works_localtime_r="unknown"
3009   tst_allow_localtime_r="unknown"
3010   #
3011   AC_MSG_CHECKING([if localtime_r can be linked])
3012   AC_LINK_IFELSE([
3013     AC_LANG_FUNC_LINK_TRY([localtime_r])
3014   ],[
3015     AC_MSG_RESULT([yes])
3016     tst_links_localtime_r="yes"
3017   ],[
3018     AC_MSG_RESULT([no])
3019     tst_links_localtime_r="no"
3020   ])
3021   #
3022   if test "$tst_links_localtime_r" = "yes"; then
3023     AC_MSG_CHECKING([if localtime_r is prototyped])
3024     AC_EGREP_CPP([localtime_r],[
3025       $curl_includes_time
3026     ],[
3027       AC_MSG_RESULT([yes])
3028       tst_proto_localtime_r="yes"
3029     ],[
3030       AC_MSG_RESULT([no])
3031       tst_proto_localtime_r="no"
3032     ])
3033   fi
3034   #
3035   if test "$tst_proto_localtime_r" = "yes"; then
3036     AC_MSG_CHECKING([if localtime_r is compilable])
3037     AC_COMPILE_IFELSE([
3038       AC_LANG_PROGRAM([[
3039         $curl_includes_time
3040       ]],[[
3041         if(0 != localtime_r(0, 0))
3042           return 1;
3043       ]])
3044     ],[
3045       AC_MSG_RESULT([yes])
3046       tst_compi_localtime_r="yes"
3047     ],[
3048       AC_MSG_RESULT([no])
3049       tst_compi_localtime_r="no"
3050     ])
3051   fi
3052   #
3053   dnl only do runtime verification when not cross-compiling
3054   if test "x$cross_compiling" != "xyes" &&
3055     test "$tst_compi_localtime_r" = "yes"; then
3056     AC_MSG_CHECKING([if localtime_r seems to work])
3057     AC_RUN_IFELSE([
3058       AC_LANG_PROGRAM([[
3059         $curl_includes_stdlib
3060         $curl_includes_time
3061       ]],[[
3062         time_t clock = 1170352587;
3063         struct tm *tmp = 0;
3064         struct tm result;
3065         tmp = localtime_r(&clock, &result);
3066         if(tmp)
3067           exit(0);
3068         else
3069           exit(1);
3070       ]])
3071     ],[
3072       AC_MSG_RESULT([yes])
3073       tst_works_localtime_r="yes"
3074     ],[
3075       AC_MSG_RESULT([no])
3076       tst_works_localtime_r="no"
3077     ])
3078   fi
3079   #
3080   if test "$tst_compi_localtime_r" = "yes" &&
3081     test "$tst_works_localtime_r" != "no"; then
3082     AC_MSG_CHECKING([if localtime_r usage allowed])
3083     if test "x$curl_disallow_localtime_r" != "xyes"; then
3084       AC_MSG_RESULT([yes])
3085       tst_allow_localtime_r="yes"
3086     else
3087       AC_MSG_RESULT([no])
3088       tst_allow_localtime_r="no"
3089     fi
3090   fi
3091   #
3092   AC_MSG_CHECKING([if localtime_r might be used])
3093   if test "$tst_links_localtime_r" = "yes" &&
3094      test "$tst_proto_localtime_r" = "yes" &&
3095      test "$tst_compi_localtime_r" = "yes" &&
3096      test "$tst_allow_localtime_r" = "yes" &&
3097      test "$tst_works_localtime_r" != "no"; then
3098     AC_MSG_RESULT([yes])
3099     AC_DEFINE_UNQUOTED(HAVE_LOCALTIME_R, 1,
3100       [Define to 1 if you have a working localtime_r function.])
3101     ac_cv_func_localtime_r="yes"
3102   else
3103     AC_MSG_RESULT([no])
3104     ac_cv_func_localtime_r="no"
3105   fi
3106 ])
3107
3108
3109 dnl CURL_CHECK_FUNC_SETSOCKOPT
3110 dnl -------------------------------------------------
3111 dnl Verify if setsockopt is available, prototyped, and
3112 dnl can be compiled. If all of these are true, and
3113 dnl usage has not been previously disallowed with
3114 dnl shell variable curl_disallow_setsockopt, then
3115 dnl HAVE_SETSOCKOPT will be defined.
3116
3117 AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT], [
3118   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
3119   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
3120   #
3121   tst_links_setsockopt="unknown"
3122   tst_proto_setsockopt="unknown"
3123   tst_compi_setsockopt="unknown"
3124   tst_allow_setsockopt="unknown"
3125   #
3126   AC_MSG_CHECKING([if setsockopt can be linked])
3127   AC_LINK_IFELSE([
3128     AC_LANG_PROGRAM([[
3129       $curl_includes_winsock2
3130       $curl_includes_sys_socket
3131     ]],[[
3132       if(0 != setsockopt(0, 0, 0, 0, 0))
3133         return 1;
3134     ]])
3135   ],[
3136     AC_MSG_RESULT([yes])
3137     tst_links_setsockopt="yes"
3138   ],[
3139     AC_MSG_RESULT([no])
3140     tst_links_setsockopt="no"
3141   ])
3142   #
3143   if test "$tst_links_setsockopt" = "yes"; then
3144     AC_MSG_CHECKING([if setsockopt is prototyped])
3145     AC_EGREP_CPP([setsockopt],[
3146       $curl_includes_winsock2
3147       $curl_includes_sys_socket
3148     ],[
3149       AC_MSG_RESULT([yes])
3150       tst_proto_setsockopt="yes"
3151     ],[
3152       AC_MSG_RESULT([no])
3153       tst_proto_setsockopt="no"
3154     ])
3155   fi
3156   #
3157   if test "$tst_proto_setsockopt" = "yes"; then
3158     AC_MSG_CHECKING([if setsockopt is compilable])
3159     AC_COMPILE_IFELSE([
3160       AC_LANG_PROGRAM([[
3161         $curl_includes_winsock2
3162         $curl_includes_sys_socket
3163       ]],[[
3164         if(0 != setsockopt(0, 0, 0, 0, 0))
3165           return 1;
3166       ]])
3167     ],[
3168       AC_MSG_RESULT([yes])
3169       tst_compi_setsockopt="yes"
3170     ],[
3171       AC_MSG_RESULT([no])
3172       tst_compi_setsockopt="no"
3173     ])
3174   fi
3175   #
3176   if test "$tst_compi_setsockopt" = "yes"; then
3177     AC_MSG_CHECKING([if setsockopt usage allowed])
3178     if test "x$curl_disallow_setsockopt" != "xyes"; then
3179       AC_MSG_RESULT([yes])
3180       tst_allow_setsockopt="yes"
3181     else
3182       AC_MSG_RESULT([no])
3183       tst_allow_setsockopt="no"
3184     fi
3185   fi
3186   #
3187   AC_MSG_CHECKING([if setsockopt might be used])
3188   if test "$tst_links_setsockopt" = "yes" &&
3189      test "$tst_proto_setsockopt" = "yes" &&
3190      test "$tst_compi_setsockopt" = "yes" &&
3191      test "$tst_allow_setsockopt" = "yes"; then
3192     AC_MSG_RESULT([yes])
3193     AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1,
3194       [Define to 1 if you have the setsockopt function.])
3195     ac_cv_func_setsockopt="yes"
3196     CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
3197   else
3198     AC_MSG_RESULT([no])
3199     ac_cv_func_setsockopt="no"
3200   fi
3201 ])
3202
3203
3204 dnl CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
3205 dnl -------------------------------------------------
3206 dnl Verify if setsockopt with the SO_NONBLOCK command is
3207 dnl available, can be compiled, and seems to work. If
3208 dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK
3209 dnl will be defined.
3210
3211 AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
3212   #
3213   tst_compi_setsockopt_so_nonblock="unknown"
3214   tst_allow_setsockopt_so_nonblock="unknown"
3215   #
3216   if test "$ac_cv_func_setsockopt" = "yes"; then
3217     AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable])
3218     AC_COMPILE_IFELSE([
3219       AC_LANG_PROGRAM([[
3220         $curl_includes_winsock2
3221         $curl_includes_sys_socket
3222       ]],[[
3223         if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
3224           return 1;
3225       ]])
3226     ],[
3227       AC_MSG_RESULT([yes])
3228       tst_compi_setsockopt_so_nonblock="yes"
3229     ],[
3230       AC_MSG_RESULT([no])
3231       tst_compi_setsockopt_so_nonblock="no"
3232     ])
3233   fi
3234   #
3235   if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then
3236     AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed])
3237     if test "x$curl_disallow_setsockopt_so_nonblock" != "xyes"; then
3238       AC_MSG_RESULT([yes])
3239       tst_allow_setsockopt_so_nonblock="yes"
3240     else
3241       AC_MSG_RESULT([no])
3242       tst_allow_setsockopt_so_nonblock="no"
3243     fi
3244   fi
3245   #
3246   AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used])
3247   if test "$tst_compi_setsockopt_so_nonblock" = "yes" &&
3248      test "$tst_allow_setsockopt_so_nonblock" = "yes"; then
3249     AC_MSG_RESULT([yes])
3250     AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1,
3251       [Define to 1 if you have a working setsockopt SO_NONBLOCK function.])
3252     ac_cv_func_setsockopt_so_nonblock="yes"
3253   else
3254     AC_MSG_RESULT([no])
3255     ac_cv_func_setsockopt_so_nonblock="no"
3256   fi
3257 ])
3258
3259
3260 dnl CURL_CHECK_FUNC_SIGACTION
3261 dnl -------------------------------------------------
3262 dnl Verify if sigaction is available, prototyped, and
3263 dnl can be compiled. If all of these are true, and
3264 dnl usage has not been previously disallowed with
3265 dnl shell variable curl_disallow_sigaction, then
3266 dnl HAVE_SIGACTION will be defined.
3267
3268 AC_DEFUN([CURL_CHECK_FUNC_SIGACTION], [
3269   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
3270   #
3271   tst_links_sigaction="unknown"
3272   tst_proto_sigaction="unknown"
3273   tst_compi_sigaction="unknown"
3274   tst_allow_sigaction="unknown"
3275   #
3276   AC_MSG_CHECKING([if sigaction can be linked])
3277   AC_LINK_IFELSE([
3278     AC_LANG_FUNC_LINK_TRY([sigaction])
3279   ],[
3280     AC_MSG_RESULT([yes])
3281     tst_links_sigaction="yes"
3282   ],[
3283     AC_MSG_RESULT([no])
3284     tst_links_sigaction="no"
3285   ])
3286   #
3287   if test "$tst_links_sigaction" = "yes"; then
3288     AC_MSG_CHECKING([if sigaction is prototyped])
3289     AC_EGREP_CPP([sigaction],[
3290       $curl_includes_signal
3291     ],[
3292       AC_MSG_RESULT([yes])
3293       tst_proto_sigaction="yes"
3294     ],[
3295       AC_MSG_RESULT([no])
3296       tst_proto_sigaction="no"
3297     ])
3298   fi
3299   #
3300   if test "$tst_proto_sigaction" = "yes"; then
3301     AC_MSG_CHECKING([if sigaction is compilable])
3302     AC_COMPILE_IFELSE([
3303       AC_LANG_PROGRAM([[
3304         $curl_includes_signal
3305       ]],[[
3306         if(0 != sigaction(0, 0, 0))
3307           return 1;
3308       ]])
3309     ],[
3310       AC_MSG_RESULT([yes])
3311       tst_compi_sigaction="yes"
3312     ],[
3313       AC_MSG_RESULT([no])
3314       tst_compi_sigaction="no"
3315     ])
3316   fi
3317   #
3318   if test "$tst_compi_sigaction" = "yes"; then
3319     AC_MSG_CHECKING([if sigaction usage allowed])
3320     if test "x$curl_disallow_sigaction" != "xyes"; then
3321       AC_MSG_RESULT([yes])
3322       tst_allow_sigaction="yes"
3323     else
3324       AC_MSG_RESULT([no])
3325       tst_allow_sigaction="no"
3326     fi
3327   fi
3328   #
3329   AC_MSG_CHECKING([if sigaction might be used])
3330   if test "$tst_links_sigaction" = "yes" &&
3331      test "$tst_proto_sigaction" = "yes" &&
3332      test "$tst_compi_sigaction" = "yes" &&
3333      test "$tst_allow_sigaction" = "yes"; then
3334     AC_MSG_RESULT([yes])
3335     AC_DEFINE_UNQUOTED(HAVE_SIGACTION, 1,
3336       [Define to 1 if you have the sigaction function.])
3337     ac_cv_func_sigaction="yes"
3338   else
3339     AC_MSG_RESULT([no])
3340     ac_cv_func_sigaction="no"
3341   fi
3342 ])
3343
3344
3345 dnl CURL_CHECK_FUNC_SIGINTERRUPT
3346 dnl -------------------------------------------------
3347 dnl Verify if siginterrupt is available, prototyped, and
3348 dnl can be compiled. If all of these are true, and
3349 dnl usage has not been previously disallowed with
3350 dnl shell variable curl_disallow_siginterrupt, then
3351 dnl HAVE_SIGINTERRUPT will be defined.
3352
3353 AC_DEFUN([CURL_CHECK_FUNC_SIGINTERRUPT], [
3354   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
3355   #
3356   tst_links_siginterrupt="unknown"
3357   tst_proto_siginterrupt="unknown"
3358   tst_compi_siginterrupt="unknown"
3359   tst_allow_siginterrupt="unknown"
3360   #
3361   AC_MSG_CHECKING([if siginterrupt can be linked])
3362   AC_LINK_IFELSE([
3363     AC_LANG_FUNC_LINK_TRY([siginterrupt])
3364   ],[
3365     AC_MSG_RESULT([yes])
3366     tst_links_siginterrupt="yes"
3367   ],[
3368     AC_MSG_RESULT([no])
3369     tst_links_siginterrupt="no"
3370   ])
3371   #
3372   if test "$tst_links_siginterrupt" = "yes"; then
3373     AC_MSG_CHECKING([if siginterrupt is prototyped])
3374     AC_EGREP_CPP([siginterrupt],[
3375       $curl_includes_signal
3376     ],[
3377       AC_MSG_RESULT([yes])
3378       tst_proto_siginterrupt="yes"
3379     ],[
3380       AC_MSG_RESULT([no])
3381       tst_proto_siginterrupt="no"
3382     ])
3383   fi
3384   #
3385   if test "$tst_proto_siginterrupt" = "yes"; then
3386     AC_MSG_CHECKING([if siginterrupt is compilable])
3387     AC_COMPILE_IFELSE([
3388       AC_LANG_PROGRAM([[
3389         $curl_includes_signal
3390       ]],[[
3391         if(0 != siginterrupt(0, 0))
3392           return 1;
3393       ]])
3394     ],[
3395       AC_MSG_RESULT([yes])
3396       tst_compi_siginterrupt="yes"
3397     ],[
3398       AC_MSG_RESULT([no])
3399       tst_compi_siginterrupt="no"
3400     ])
3401   fi
3402   #
3403   if test "$tst_compi_siginterrupt" = "yes"; then
3404     AC_MSG_CHECKING([if siginterrupt usage allowed])
3405     if test "x$curl_disallow_siginterrupt" != "xyes"; then
3406       AC_MSG_RESULT([yes])
3407       tst_allow_siginterrupt="yes"
3408     else
3409       AC_MSG_RESULT([no])
3410       tst_allow_siginterrupt="no"
3411     fi
3412   fi
3413   #
3414   AC_MSG_CHECKING([if siginterrupt might be used])
3415   if test "$tst_links_siginterrupt" = "yes" &&
3416      test "$tst_proto_siginterrupt" = "yes" &&
3417      test "$tst_compi_siginterrupt" = "yes" &&
3418      test "$tst_allow_siginterrupt" = "yes"; then
3419     AC_MSG_RESULT([yes])
3420     AC_DEFINE_UNQUOTED(HAVE_SIGINTERRUPT, 1,
3421       [Define to 1 if you have the siginterrupt function.])
3422     ac_cv_func_siginterrupt="yes"
3423   else
3424     AC_MSG_RESULT([no])
3425     ac_cv_func_siginterrupt="no"
3426   fi
3427 ])
3428
3429
3430 dnl CURL_CHECK_FUNC_SIGNAL
3431 dnl -------------------------------------------------
3432 dnl Verify if signal is available, prototyped, and
3433 dnl can be compiled. If all of these are true, and
3434 dnl usage has not been previously disallowed with
3435 dnl shell variable curl_disallow_signal, then
3436 dnl HAVE_SIGNAL will be defined.
3437
3438 AC_DEFUN([CURL_CHECK_FUNC_SIGNAL], [
3439   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
3440   #
3441   tst_links_signal="unknown"
3442   tst_proto_signal="unknown"
3443   tst_compi_signal="unknown"
3444   tst_allow_signal="unknown"
3445   #
3446   AC_MSG_CHECKING([if signal can be linked])
3447   AC_LINK_IFELSE([
3448     AC_LANG_FUNC_LINK_TRY([signal])
3449   ],[
3450     AC_MSG_RESULT([yes])
3451     tst_links_signal="yes"
3452   ],[
3453     AC_MSG_RESULT([no])
3454     tst_links_signal="no"
3455   ])
3456   #
3457   if test "$tst_links_signal" = "yes"; then
3458     AC_MSG_CHECKING([if signal is prototyped])
3459     AC_EGREP_CPP([signal],[
3460       $curl_includes_signal
3461     ],[
3462       AC_MSG_RESULT([yes])
3463       tst_proto_signal="yes"
3464     ],[
3465       AC_MSG_RESULT([no])
3466       tst_proto_signal="no"
3467     ])
3468   fi
3469   #
3470   if test "$tst_proto_signal" = "yes"; then
3471     AC_MSG_CHECKING([if signal is compilable])
3472     AC_COMPILE_IFELSE([
3473       AC_LANG_PROGRAM([[
3474         $curl_includes_signal
3475       ]],[[
3476         if(0 != signal(0, 0))
3477           return 1;
3478       ]])
3479     ],[
3480       AC_MSG_RESULT([yes])
3481       tst_compi_signal="yes"
3482     ],[
3483       AC_MSG_RESULT([no])
3484       tst_compi_signal="no"
3485     ])
3486   fi
3487   #
3488   if test "$tst_compi_signal" = "yes"; then
3489     AC_MSG_CHECKING([if signal usage allowed])
3490     if test "x$curl_disallow_signal" != "xyes"; then
3491       AC_MSG_RESULT([yes])
3492       tst_allow_signal="yes"
3493     else
3494       AC_MSG_RESULT([no])
3495       tst_allow_signal="no"
3496     fi
3497   fi
3498   #
3499   AC_MSG_CHECKING([if signal might be used])
3500   if test "$tst_links_signal" = "yes" &&
3501      test "$tst_proto_signal" = "yes" &&
3502      test "$tst_compi_signal" = "yes" &&
3503      test "$tst_allow_signal" = "yes"; then
3504     AC_MSG_RESULT([yes])
3505     AC_DEFINE_UNQUOTED(HAVE_SIGNAL, 1,
3506       [Define to 1 if you have the signal function.])
3507     ac_cv_func_signal="yes"
3508   else
3509     AC_MSG_RESULT([no])
3510     ac_cv_func_signal="no"
3511   fi
3512 ])
3513
3514
3515 dnl CURL_CHECK_FUNC_SIGSETJMP
3516 dnl -------------------------------------------------
3517 dnl Verify if sigsetjmp is available, prototyped, and
3518 dnl can be compiled. If all of these are true, and
3519 dnl usage has not been previously disallowed with
3520 dnl shell variable curl_disallow_sigsetjmp, then
3521 dnl HAVE_SIGSETJMP will be defined.
3522
3523 AC_DEFUN([CURL_CHECK_FUNC_SIGSETJMP], [
3524   AC_REQUIRE([CURL_INCLUDES_SETJMP])dnl
3525   #
3526   tst_links_sigsetjmp="unknown"
3527   tst_macro_sigsetjmp="unknown"
3528   tst_proto_sigsetjmp="unknown"
3529   tst_compi_sigsetjmp="unknown"
3530   tst_allow_sigsetjmp="unknown"
3531   #
3532   AC_MSG_CHECKING([if sigsetjmp can be linked])
3533   AC_LINK_IFELSE([
3534     AC_LANG_FUNC_LINK_TRY([sigsetjmp])
3535   ],[
3536     AC_MSG_RESULT([yes])
3537     tst_links_sigsetjmp="yes"
3538   ],[
3539     AC_MSG_RESULT([no])
3540     tst_links_sigsetjmp="no"
3541   ])
3542   #
3543   if test "$tst_links_sigsetjmp" = "no"; then
3544     AC_MSG_CHECKING([if sigsetjmp seems a macro])
3545     AC_LINK_IFELSE([
3546       AC_LANG_PROGRAM([[
3547         $curl_includes_setjmp
3548       ]],[[
3549         sigjmp_buf env;
3550         if(0 != sigsetjmp(env, 0))
3551           return 1;
3552       ]])
3553     ],[
3554       AC_MSG_RESULT([yes])
3555       tst_macro_sigsetjmp="yes"
3556     ],[
3557       AC_MSG_RESULT([no])
3558       tst_macro_sigsetjmp="no"
3559     ])
3560   fi
3561   #
3562   if test "$tst_links_sigsetjmp" = "yes"; then
3563     AC_MSG_CHECKING([if sigsetjmp is prototyped])
3564     AC_EGREP_CPP([sigsetjmp],[
3565       $curl_includes_setjmp
3566     ],[
3567       AC_MSG_RESULT([yes])
3568       tst_proto_sigsetjmp="yes"
3569     ],[
3570       AC_MSG_RESULT([no])
3571       tst_proto_sigsetjmp="no"
3572     ])
3573   fi
3574   #
3575   if test "$tst_proto_sigsetjmp" = "yes" ||
3576      test "$tst_macro_sigsetjmp" = "yes"; then
3577     AC_MSG_CHECKING([if sigsetjmp is compilable])
3578     AC_COMPILE_IFELSE([
3579       AC_LANG_PROGRAM([[
3580         $curl_includes_setjmp
3581       ]],[[
3582         sigjmp_buf env;
3583         if(0 != sigsetjmp(env, 0))
3584           return 1;
3585       ]])
3586     ],[
3587       AC_MSG_RESULT([yes])
3588       tst_compi_sigsetjmp="yes"
3589     ],[
3590       AC_MSG_RESULT([no])
3591       tst_compi_sigsetjmp="no"
3592     ])
3593   fi
3594   #
3595   if test "$tst_compi_sigsetjmp" = "yes"; then
3596     AC_MSG_CHECKING([if sigsetjmp usage allowed])
3597     if test "x$curl_disallow_sigsetjmp" != "xyes"; then
3598       AC_MSG_RESULT([yes])
3599       tst_allow_sigsetjmp="yes"
3600     else
3601       AC_MSG_RESULT([no])
3602       tst_allow_sigsetjmp="no"
3603     fi
3604   fi
3605   #
3606   AC_MSG_CHECKING([if sigsetjmp might be used])
3607   if (test "$tst_proto_sigsetjmp" = "yes" ||
3608       test "$tst_macro_sigsetjmp" = "yes") &&
3609      test "$tst_compi_sigsetjmp" = "yes" &&
3610      test "$tst_allow_sigsetjmp" = "yes"; then
3611     AC_MSG_RESULT([yes])
3612     AC_DEFINE_UNQUOTED(HAVE_SIGSETJMP, 1,
3613       [Define to 1 if you have the sigsetjmp function or macro.])
3614     ac_cv_func_sigsetjmp="yes"
3615   else
3616     AC_MSG_RESULT([no])
3617     ac_cv_func_sigsetjmp="no"
3618   fi
3619 ])
3620
3621
3622 dnl CURL_CHECK_FUNC_STRCASECMP
3623 dnl -------------------------------------------------
3624 dnl Verify if strcasecmp is available, prototyped, and
3625 dnl can be compiled. If all of these are true, and
3626 dnl usage has not been previously disallowed with
3627 dnl shell variable curl_disallow_strcasecmp, then
3628 dnl HAVE_STRCASECMP will be defined.
3629
3630 AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [
3631   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3632   #
3633   tst_links_strcasecmp="unknown"
3634   tst_proto_strcasecmp="unknown"
3635   tst_compi_strcasecmp="unknown"
3636   tst_allow_strcasecmp="unknown"
3637   #
3638   AC_MSG_CHECKING([if strcasecmp can be linked])
3639   AC_LINK_IFELSE([
3640     AC_LANG_FUNC_LINK_TRY([strcasecmp])
3641   ],[
3642     AC_MSG_RESULT([yes])
3643     tst_links_strcasecmp="yes"
3644   ],[
3645     AC_MSG_RESULT([no])
3646     tst_links_strcasecmp="no"
3647   ])
3648   #
3649   if test "$tst_links_strcasecmp" = "yes"; then
3650     AC_MSG_CHECKING([if strcasecmp is prototyped])
3651     AC_EGREP_CPP([strcasecmp],[
3652       $curl_includes_string
3653     ],[
3654       AC_MSG_RESULT([yes])
3655       tst_proto_strcasecmp="yes"
3656     ],[
3657       AC_MSG_RESULT([no])
3658       tst_proto_strcasecmp="no"
3659     ])
3660   fi
3661   #
3662   if test "$tst_proto_strcasecmp" = "yes"; then
3663     AC_MSG_CHECKING([if strcasecmp is compilable])
3664     AC_COMPILE_IFELSE([
3665       AC_LANG_PROGRAM([[
3666         $curl_includes_string
3667       ]],[[
3668         if(0 != strcasecmp(0, 0))
3669           return 1;
3670       ]])
3671     ],[
3672       AC_MSG_RESULT([yes])
3673       tst_compi_strcasecmp="yes"
3674     ],[
3675       AC_MSG_RESULT([no])
3676       tst_compi_strcasecmp="no"
3677     ])
3678   fi
3679   #
3680   if test "$tst_compi_strcasecmp" = "yes"; then
3681     AC_MSG_CHECKING([if strcasecmp usage allowed])
3682     if test "x$curl_disallow_strcasecmp" != "xyes"; then
3683       AC_MSG_RESULT([yes])
3684       tst_allow_strcasecmp="yes"
3685     else
3686       AC_MSG_RESULT([no])
3687       tst_allow_strcasecmp="no"
3688     fi
3689   fi
3690   #
3691   AC_MSG_CHECKING([if strcasecmp might be used])
3692   if test "$tst_links_strcasecmp" = "yes" &&
3693      test "$tst_proto_strcasecmp" = "yes" &&
3694      test "$tst_compi_strcasecmp" = "yes" &&
3695      test "$tst_allow_strcasecmp" = "yes"; then
3696     AC_MSG_RESULT([yes])
3697     AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
3698       [Define to 1 if you have the strcasecmp function.])
3699     ac_cv_func_strcasecmp="yes"
3700   else
3701     AC_MSG_RESULT([no])
3702     ac_cv_func_strcasecmp="no"
3703   fi
3704 ])
3705
3706
3707 dnl CURL_CHECK_FUNC_STRCASESTR
3708 dnl -------------------------------------------------
3709 dnl Verify if strcasestr is available, prototyped, and
3710 dnl can be compiled. If all of these are true, and
3711 dnl usage has not been previously disallowed with
3712 dnl shell variable curl_disallow_strcasestr, then
3713 dnl HAVE_STRCASESTR will be defined.
3714
3715 AC_DEFUN([CURL_CHECK_FUNC_STRCASESTR], [
3716   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3717   #
3718   tst_links_strcasestr="unknown"
3719   tst_proto_strcasestr="unknown"
3720   tst_compi_strcasestr="unknown"
3721   tst_allow_strcasestr="unknown"
3722   #
3723   AC_MSG_CHECKING([if strcasestr can be linked])
3724   AC_LINK_IFELSE([
3725     AC_LANG_FUNC_LINK_TRY([strcasestr])
3726   ],[
3727     AC_MSG_RESULT([yes])
3728     tst_links_strcasestr="yes"
3729   ],[
3730     AC_MSG_RESULT([no])
3731     tst_links_strcasestr="no"
3732   ])
3733   #
3734   if test "$tst_links_strcasestr" = "yes"; then
3735     AC_MSG_CHECKING([if strcasestr is prototyped])
3736     AC_EGREP_CPP([strcasestr],[
3737       $curl_includes_string
3738     ],[
3739       AC_MSG_RESULT([yes])
3740       tst_proto_strcasestr="yes"
3741     ],[
3742       AC_MSG_RESULT([no])
3743       tst_proto_strcasestr="no"
3744     ])
3745   fi
3746   #
3747   if test "$tst_proto_strcasestr" = "yes"; then
3748     AC_MSG_CHECKING([if strcasestr is compilable])
3749     AC_COMPILE_IFELSE([
3750       AC_LANG_PROGRAM([[
3751         $curl_includes_string
3752       ]],[[
3753         if(0 != strcasestr(0, 0))
3754           return 1;
3755       ]])
3756     ],[
3757       AC_MSG_RESULT([yes])
3758       tst_compi_strcasestr="yes"
3759     ],[
3760       AC_MSG_RESULT([no])
3761       tst_compi_strcasestr="no"
3762     ])
3763   fi
3764   #
3765   if test "$tst_compi_strcasestr" = "yes"; then
3766     AC_MSG_CHECKING([if strcasestr usage allowed])
3767     if test "x$curl_disallow_strcasestr" != "xyes"; then
3768       AC_MSG_RESULT([yes])
3769       tst_allow_strcasestr="yes"
3770     else
3771       AC_MSG_RESULT([no])
3772       tst_allow_strcasestr="no"
3773     fi
3774   fi
3775   #
3776   AC_MSG_CHECKING([if strcasestr might be used])
3777   if test "$tst_links_strcasestr" = "yes" &&
3778      test "$tst_proto_strcasestr" = "yes" &&
3779      test "$tst_compi_strcasestr" = "yes" &&
3780      test "$tst_allow_strcasestr" = "yes"; then
3781     AC_MSG_RESULT([yes])
3782     AC_DEFINE_UNQUOTED(HAVE_STRCASESTR, 1,
3783       [Define to 1 if you have the strcasestr function.])
3784     ac_cv_func_strcasestr="yes"
3785   else
3786     AC_MSG_RESULT([no])
3787     ac_cv_func_strcasestr="no"
3788   fi
3789 ])
3790
3791
3792 dnl CURL_CHECK_FUNC_STRCMPI
3793 dnl -------------------------------------------------
3794 dnl Verify if strcmpi is available, prototyped, and
3795 dnl can be compiled. If all of these are true, and
3796 dnl usage has not been previously disallowed with
3797 dnl shell variable curl_disallow_strcmpi, then
3798 dnl HAVE_STRCMPI will be defined.
3799
3800 AC_DEFUN([CURL_CHECK_FUNC_STRCMPI], [
3801   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3802   #
3803   tst_links_strcmpi="unknown"
3804   tst_proto_strcmpi="unknown"
3805   tst_compi_strcmpi="unknown"
3806   tst_allow_strcmpi="unknown"
3807   #
3808   AC_MSG_CHECKING([if strcmpi can be linked])
3809   AC_LINK_IFELSE([
3810     AC_LANG_FUNC_LINK_TRY([strcmpi])
3811   ],[
3812     AC_MSG_RESULT([yes])
3813     tst_links_strcmpi="yes"
3814   ],[
3815     AC_MSG_RESULT([no])
3816     tst_links_strcmpi="no"
3817   ])
3818   #
3819   if test "$tst_links_strcmpi" = "yes"; then
3820     AC_MSG_CHECKING([if strcmpi is prototyped])
3821     AC_EGREP_CPP([strcmpi],[
3822       $curl_includes_string
3823     ],[
3824       AC_MSG_RESULT([yes])
3825       tst_proto_strcmpi="yes"
3826     ],[
3827       AC_MSG_RESULT([no])
3828       tst_proto_strcmpi="no"
3829     ])
3830   fi
3831   #
3832   if test "$tst_proto_strcmpi" = "yes"; then
3833     AC_MSG_CHECKING([if strcmpi is compilable])
3834     AC_COMPILE_IFELSE([
3835       AC_LANG_PROGRAM([[
3836         $curl_includes_string
3837       ]],[[
3838         if(0 != strcmpi(0, 0))
3839           return 1;
3840       ]])
3841     ],[
3842       AC_MSG_RESULT([yes])
3843       tst_compi_strcmpi="yes"
3844     ],[
3845       AC_MSG_RESULT([no])
3846       tst_compi_strcmpi="no"
3847     ])
3848   fi
3849   #
3850   if test "$tst_compi_strcmpi" = "yes"; then
3851     AC_MSG_CHECKING([if strcmpi usage allowed])
3852     if test "x$curl_disallow_strcmpi" != "xyes"; then
3853       AC_MSG_RESULT([yes])
3854       tst_allow_strcmpi="yes"
3855     else
3856       AC_MSG_RESULT([no])
3857       tst_allow_strcmpi="no"
3858     fi
3859   fi
3860   #
3861   AC_MSG_CHECKING([if strcmpi might be used])
3862   if test "$tst_links_strcmpi" = "yes" &&
3863      test "$tst_proto_strcmpi" = "yes" &&
3864      test "$tst_compi_strcmpi" = "yes" &&
3865      test "$tst_allow_strcmpi" = "yes"; then
3866     AC_MSG_RESULT([yes])
3867     AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
3868       [Define to 1 if you have the strcmpi function.])
3869     ac_cv_func_strcmpi="yes"
3870   else
3871     AC_MSG_RESULT([no])
3872     ac_cv_func_strcmpi="no"
3873   fi
3874 ])
3875
3876
3877 dnl CURL_CHECK_FUNC_STRDUP
3878 dnl -------------------------------------------------
3879 dnl Verify if strdup is available, prototyped, and
3880 dnl can be compiled. If all of these are true, and
3881 dnl usage has not been previously disallowed with
3882 dnl shell variable curl_disallow_strdup, then
3883 dnl HAVE_STRDUP will be defined.
3884
3885 AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
3886   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3887   #
3888   tst_links_strdup="unknown"
3889   tst_proto_strdup="unknown"
3890   tst_compi_strdup="unknown"
3891   tst_allow_strdup="unknown"
3892   #
3893   AC_MSG_CHECKING([if strdup can be linked])
3894   AC_LINK_IFELSE([
3895     AC_LANG_FUNC_LINK_TRY([strdup])
3896   ],[
3897     AC_MSG_RESULT([yes])
3898     tst_links_strdup="yes"
3899   ],[
3900     AC_MSG_RESULT([no])
3901     tst_links_strdup="no"
3902   ])
3903   #
3904   if test "$tst_links_strdup" = "yes"; then
3905     AC_MSG_CHECKING([if strdup is prototyped])
3906     AC_EGREP_CPP([strdup],[
3907       $curl_includes_string
3908     ],[
3909       AC_MSG_RESULT([yes])
3910       tst_proto_strdup="yes"
3911     ],[
3912       AC_MSG_RESULT([no])
3913       tst_proto_strdup="no"
3914     ])
3915   fi
3916   #
3917   if test "$tst_proto_strdup" = "yes"; then
3918     AC_MSG_CHECKING([if strdup is compilable])
3919     AC_COMPILE_IFELSE([
3920       AC_LANG_PROGRAM([[
3921         $curl_includes_string
3922       ]],[[
3923         if(0 != strdup(0))
3924           return 1;
3925       ]])
3926     ],[
3927       AC_MSG_RESULT([yes])
3928       tst_compi_strdup="yes"
3929     ],[
3930       AC_MSG_RESULT([no])
3931       tst_compi_strdup="no"
3932     ])
3933   fi
3934   #
3935   if test "$tst_compi_strdup" = "yes"; then
3936     AC_MSG_CHECKING([if strdup usage allowed])
3937     if test "x$curl_disallow_strdup" != "xyes"; then
3938       AC_MSG_RESULT([yes])
3939       tst_allow_strdup="yes"
3940     else
3941       AC_MSG_RESULT([no])
3942       tst_allow_strdup="no"
3943     fi
3944   fi
3945   #
3946   AC_MSG_CHECKING([if strdup might be used])
3947   if test "$tst_links_strdup" = "yes" &&
3948      test "$tst_proto_strdup" = "yes" &&
3949      test "$tst_compi_strdup" = "yes" &&
3950      test "$tst_allow_strdup" = "yes"; then
3951     AC_MSG_RESULT([yes])
3952     AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
3953       [Define to 1 if you have the strdup function.])
3954     ac_cv_func_strdup="yes"
3955   else
3956     AC_MSG_RESULT([no])
3957     ac_cv_func_strdup="no"
3958   fi
3959 ])
3960
3961
3962 dnl CURL_CHECK_FUNC_STRERROR_R
3963 dnl -------------------------------------------------
3964 dnl Verify if strerror_r is available, prototyped, can be compiled and
3965 dnl seems to work. If all of these are true, and usage has not been
3966 dnl previously disallowed with shell variable curl_disallow_strerror_r,
3967 dnl then HAVE_STRERROR_R and STRERROR_R_TYPE_ARG3 will be defined, as
3968 dnl well as one of HAVE_GLIBC_STRERROR_R or HAVE_POSIX_STRERROR_R.
3969 dnl
3970 dnl glibc-style strerror_r:
3971 dnl
3972 dnl      char *strerror_r(int errnum, char *workbuf, size_t bufsize);
3973 dnl
3974 dnl  glibc-style strerror_r returns a pointer to the the error string,
3975 dnl  and might use the provided workbuf as a scratch area if needed. A
3976 dnl  quick test on a few systems shows that it's usually not used at all.
3977 dnl
3978 dnl POSIX-style strerror_r:
3979 dnl
3980 dnl      int strerror_r(int errnum, char *resultbuf, size_t bufsize);
3981 dnl
3982 dnl  POSIX-style strerror_r returns 0 upon successful completion and the
3983 dnl  error string in the provided resultbuf.
3984 dnl
3985
3986 AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
3987   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3988   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3989   #
3990   tst_links_strerror_r="unknown"
3991   tst_proto_strerror_r="unknown"
3992   tst_compi_strerror_r="unknown"
3993   tst_glibc_strerror_r="unknown"
3994   tst_posix_strerror_r="unknown"
3995   tst_allow_strerror_r="unknown"
3996   tst_works_glibc_strerror_r="unknown"
3997   tst_works_posix_strerror_r="unknown"
3998   tst_glibc_strerror_r_type_arg3="unknown"
3999   tst_posix_strerror_r_type_arg3="unknown"
4000   #
4001   AC_MSG_CHECKING([if strerror_r can be linked])
4002   AC_LINK_IFELSE([
4003     AC_LANG_FUNC_LINK_TRY([strerror_r])
4004   ],[
4005     AC_MSG_RESULT([yes])
4006     tst_links_strerror_r="yes"
4007   ],[
4008     AC_MSG_RESULT([no])
4009     tst_links_strerror_r="no"
4010   ])
4011   #
4012   if test "$tst_links_strerror_r" = "yes"; then
4013     AC_MSG_CHECKING([if strerror_r is prototyped])
4014     AC_EGREP_CPP([strerror_r],[
4015       $curl_includes_string
4016     ],[
4017       AC_MSG_RESULT([yes])
4018       tst_proto_strerror_r="yes"
4019     ],[
4020       AC_MSG_RESULT([no])
4021       tst_proto_strerror_r="no"
4022     ])
4023   fi
4024   #
4025   if test "$tst_proto_strerror_r" = "yes"; then
4026     AC_MSG_CHECKING([if strerror_r is compilable])
4027     AC_COMPILE_IFELSE([
4028       AC_LANG_PROGRAM([[
4029         $curl_includes_string
4030       ]],[[
4031         if(0 != strerror_r(0, 0, 0))
4032           return 1;
4033       ]])
4034     ],[
4035       AC_MSG_RESULT([yes])
4036       tst_compi_strerror_r="yes"
4037     ],[
4038       AC_MSG_RESULT([no])
4039       tst_compi_strerror_r="no"
4040     ])
4041   fi
4042   #
4043   if test "$tst_compi_strerror_r" = "yes"; then
4044     AC_MSG_CHECKING([if strerror_r is glibc like])
4045     tst_glibc_strerror_r_type_arg3="unknown"
4046     for arg3 in 'size_t' 'int' 'unsigned int'; do
4047       if test "$tst_glibc_strerror_r_type_arg3" = "unknown"; then
4048         AC_COMPILE_IFELSE([
4049           AC_LANG_PROGRAM([[
4050             $curl_includes_string
4051           ]],[[
4052             char *strerror_r(int errnum, char *workbuf, $arg3 bufsize);
4053             if(0 != strerror_r(0, 0, 0))
4054               return 1;
4055           ]])
4056         ],[
4057           tst_glibc_strerror_r_type_arg3="$arg3"
4058         ])
4059       fi
4060     done
4061     case "$tst_glibc_strerror_r_type_arg3" in
4062       unknown)
4063         AC_MSG_RESULT([no])
4064         tst_glibc_strerror_r="no"
4065         ;;
4066       *)
4067         AC_MSG_RESULT([yes])
4068         tst_glibc_strerror_r="yes"
4069         ;;
4070     esac
4071   fi
4072   #
4073   dnl only do runtime verification when not cross-compiling
4074   if test "x$cross_compiling" != "xyes" &&
4075     test "$tst_glibc_strerror_r" = "yes"; then
4076     AC_MSG_CHECKING([if strerror_r seems to work])
4077     AC_RUN_IFELSE([
4078       AC_LANG_PROGRAM([[
4079         $curl_includes_stdlib
4080         $curl_includes_string
4081 #       include <errno.h>
4082       ]],[[
4083         char buffer[1024];
4084         char *string = 0;
4085         buffer[0] = '\0';
4086         string = strerror_r(EACCES, buffer, sizeof(buffer));
4087         if(!string)
4088           exit(1); /* fail */
4089         if(!string[0])
4090           exit(1); /* fail */
4091         else
4092           exit(0);
4093       ]])
4094     ],[
4095       AC_MSG_RESULT([yes])
4096       tst_works_glibc_strerror_r="yes"
4097     ],[
4098       AC_MSG_RESULT([no])
4099       tst_works_glibc_strerror_r="no"
4100     ])
4101   fi
4102   #
4103   if test "$tst_compi_strerror_r" = "yes" &&
4104     test "$tst_works_glibc_strerror_r" != "yes"; then
4105     AC_MSG_CHECKING([if strerror_r is POSIX like])
4106     tst_posix_strerror_r_type_arg3="unknown"
4107     for arg3 in 'size_t' 'int' 'unsigned int'; do
4108       if test "$tst_posix_strerror_r_type_arg3" = "unknown"; then
4109         AC_COMPILE_IFELSE([
4110           AC_LANG_PROGRAM([[
4111             $curl_includes_string
4112           ]],[[
4113             int strerror_r(int errnum, char *resultbuf, $arg3 bufsize);
4114             if(0 != strerror_r(0, 0, 0))
4115               return 1;
4116           ]])
4117         ],[
4118           tst_posix_strerror_r_type_arg3="$arg3"
4119         ])
4120       fi
4121     done
4122     case "$tst_posix_strerror_r_type_arg3" in
4123       unknown)
4124         AC_MSG_RESULT([no])
4125         tst_posix_strerror_r="no"
4126         ;;
4127       *)
4128         AC_MSG_RESULT([yes])
4129         tst_posix_strerror_r="yes"
4130         ;;
4131     esac
4132   fi
4133   #
4134   dnl only do runtime verification when not cross-compiling
4135   if test "x$cross_compiling" != "xyes" &&
4136     test "$tst_posix_strerror_r" = "yes"; then
4137     AC_MSG_CHECKING([if strerror_r seems to work])
4138     AC_RUN_IFELSE([
4139       AC_LANG_PROGRAM([[
4140         $curl_includes_stdlib
4141         $curl_includes_string
4142 #       include <errno.h>
4143       ]],[[
4144         char buffer[1024];
4145         int error = 1;
4146         buffer[0] = '\0';
4147         error = strerror_r(EACCES, buffer, sizeof(buffer));
4148         if(error)
4149           exit(1); /* fail */
4150         if(buffer[0] == '\0')
4151           exit(1); /* fail */
4152         else
4153           exit(0);
4154       ]])
4155     ],[
4156       AC_MSG_RESULT([yes])
4157       tst_works_posix_strerror_r="yes"
4158     ],[
4159       AC_MSG_RESULT([no])
4160       tst_works_posix_strerror_r="no"
4161     ])
4162   fi
4163   #
4164   if test "$tst_works_glibc_strerror_r" = "yes"; then
4165     tst_posix_strerror_r="no"
4166   fi
4167   if test "$tst_works_posix_strerror_r" = "yes"; then
4168     tst_glibc_strerror_r="no"
4169   fi
4170   if test "$tst_glibc_strerror_r" = "yes" &&
4171     test "$tst_works_glibc_strerror_r" != "no" &&
4172     test "$tst_posix_strerror_r" != "yes"; then
4173     tst_allow_strerror_r="check"
4174   fi
4175   if test "$tst_posix_strerror_r" = "yes" &&
4176     test "$tst_works_posix_strerror_r" != "no" &&
4177     test "$tst_glibc_strerror_r" != "yes"; then
4178     tst_allow_strerror_r="check"
4179   fi
4180   if test "$tst_allow_strerror_r" = "check"; then
4181     AC_MSG_CHECKING([if strerror_r usage allowed])
4182     if test "x$curl_disallow_strerror_r" != "xyes"; then
4183       AC_MSG_RESULT([yes])
4184       tst_allow_strerror_r="yes"
4185     else
4186       AC_MSG_RESULT([no])
4187       tst_allow_strerror_r="no"
4188     fi
4189   fi
4190   #
4191   AC_MSG_CHECKING([if strerror_r might be used])
4192   if test "$tst_links_strerror_r" = "yes" &&
4193      test "$tst_proto_strerror_r" = "yes" &&
4194      test "$tst_compi_strerror_r" = "yes" &&
4195      test "$tst_allow_strerror_r" = "yes"; then
4196     AC_MSG_RESULT([yes])
4197     if test "$tst_glibc_strerror_r" = "yes"; then
4198       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
4199         [Define to 1 if you have the strerror_r function.])
4200       AC_DEFINE_UNQUOTED(HAVE_GLIBC_STRERROR_R, 1,
4201         [Define to 1 if you have a working glibc-style strerror_r function.])
4202       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_glibc_strerror_r_type_arg3,
4203         [Define to the type of arg 3 for strerror_r.])
4204     fi
4205     if test "$tst_posix_strerror_r" = "yes"; then
4206       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
4207         [Define to 1 if you have the strerror_r function.])
4208       AC_DEFINE_UNQUOTED(HAVE_POSIX_STRERROR_R, 1,
4209         [Define to 1 if you have a working POSIX-style strerror_r function.])
4210       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_posix_strerror_r_type_arg3,
4211         [Define to the type of arg 3 for strerror_r.])
4212     fi
4213     ac_cv_func_strerror_r="yes"
4214   else
4215     AC_MSG_RESULT([no])
4216     ac_cv_func_strerror_r="no"
4217   fi
4218   #
4219   if test "$tst_compi_strerror_r" = "yes" &&
4220      test "$tst_allow_strerror_r" = "unknown"; then
4221     AC_MSG_WARN([cannot determine strerror_r() style: edit lib/config.h manually.])
4222   fi
4223   #
4224 ])
4225
4226
4227 dnl CURL_CHECK_FUNC_STRICMP
4228 dnl -------------------------------------------------
4229 dnl Verify if stricmp is available, prototyped, and
4230 dnl can be compiled. If all of these are true, and
4231 dnl usage has not been previously disallowed with
4232 dnl shell variable curl_disallow_stricmp, then
4233 dnl HAVE_STRICMP will be defined.
4234
4235 AC_DEFUN([CURL_CHECK_FUNC_STRICMP], [
4236   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4237   #
4238   tst_links_stricmp="unknown"
4239   tst_proto_stricmp="unknown"
4240   tst_compi_stricmp="unknown"
4241   tst_allow_stricmp="unknown"
4242   #
4243   AC_MSG_CHECKING([if stricmp can be linked])
4244   AC_LINK_IFELSE([
4245     AC_LANG_FUNC_LINK_TRY([stricmp])
4246   ],[
4247     AC_MSG_RESULT([yes])
4248     tst_links_stricmp="yes"
4249   ],[
4250     AC_MSG_RESULT([no])
4251     tst_links_stricmp="no"
4252   ])
4253   #
4254   if test "$tst_links_stricmp" = "yes"; then
4255     AC_MSG_CHECKING([if stricmp is prototyped])
4256     AC_EGREP_CPP([stricmp],[
4257       $curl_includes_string
4258     ],[
4259       AC_MSG_RESULT([yes])
4260       tst_proto_stricmp="yes"
4261     ],[
4262       AC_MSG_RESULT([no])
4263       tst_proto_stricmp="no"
4264     ])
4265   fi
4266   #
4267   if test "$tst_proto_stricmp" = "yes"; then
4268     AC_MSG_CHECKING([if stricmp is compilable])
4269     AC_COMPILE_IFELSE([
4270       AC_LANG_PROGRAM([[
4271         $curl_includes_string
4272       ]],[[
4273         if(0 != stricmp(0, 0))
4274           return 1;
4275       ]])
4276     ],[
4277       AC_MSG_RESULT([yes])
4278       tst_compi_stricmp="yes"
4279     ],[
4280       AC_MSG_RESULT([no])
4281       tst_compi_stricmp="no"
4282     ])
4283   fi
4284   #
4285   if test "$tst_compi_stricmp" = "yes"; then
4286     AC_MSG_CHECKING([if stricmp usage allowed])
4287     if test "x$curl_disallow_stricmp" != "xyes"; then
4288       AC_MSG_RESULT([yes])
4289       tst_allow_stricmp="yes"
4290     else
4291       AC_MSG_RESULT([no])
4292       tst_allow_stricmp="no"
4293     fi
4294   fi
4295   #
4296   AC_MSG_CHECKING([if stricmp might be used])
4297   if test "$tst_links_stricmp" = "yes" &&
4298      test "$tst_proto_stricmp" = "yes" &&
4299      test "$tst_compi_stricmp" = "yes" &&
4300      test "$tst_allow_stricmp" = "yes"; then
4301     AC_MSG_RESULT([yes])
4302     AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
4303       [Define to 1 if you have the stricmp function.])
4304     ac_cv_func_stricmp="yes"
4305   else
4306     AC_MSG_RESULT([no])
4307     ac_cv_func_stricmp="no"
4308   fi
4309 ])
4310
4311
4312 dnl CURL_CHECK_FUNC_STRLCAT
4313 dnl -------------------------------------------------
4314 dnl Verify if strlcat is available, prototyped, and
4315 dnl can be compiled. If all of these are true, and
4316 dnl usage has not been previously disallowed with
4317 dnl shell variable curl_disallow_strlcat, then
4318 dnl HAVE_STRLCAT will be defined.
4319
4320 AC_DEFUN([CURL_CHECK_FUNC_STRLCAT], [
4321   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4322   #
4323   tst_links_strlcat="unknown"
4324   tst_proto_strlcat="unknown"
4325   tst_compi_strlcat="unknown"
4326   tst_allow_strlcat="unknown"
4327   #
4328   AC_MSG_CHECKING([if strlcat can be linked])
4329   AC_LINK_IFELSE([
4330     AC_LANG_FUNC_LINK_TRY([strlcat])
4331   ],[
4332     AC_MSG_RESULT([yes])
4333     tst_links_strlcat="yes"
4334   ],[
4335     AC_MSG_RESULT([no])
4336     tst_links_strlcat="no"
4337   ])
4338   #
4339   if test "$tst_links_strlcat" = "yes"; then
4340     AC_MSG_CHECKING([if strlcat is prototyped])
4341     AC_EGREP_CPP([strlcat],[
4342       $curl_includes_string
4343     ],[
4344       AC_MSG_RESULT([yes])
4345       tst_proto_strlcat="yes"
4346     ],[
4347       AC_MSG_RESULT([no])
4348       tst_proto_strlcat="no"
4349     ])
4350   fi
4351   #
4352   if test "$tst_proto_strlcat" = "yes"; then
4353     AC_MSG_CHECKING([if strlcat is compilable])
4354     AC_COMPILE_IFELSE([
4355       AC_LANG_PROGRAM([[
4356         $curl_includes_string
4357       ]],[[
4358         if(0 != strlcat(0, 0, 0))
4359           return 1;
4360       ]])
4361     ],[
4362       AC_MSG_RESULT([yes])
4363       tst_compi_strlcat="yes"
4364     ],[
4365       AC_MSG_RESULT([no])
4366       tst_compi_strlcat="no"
4367     ])
4368   fi
4369   #
4370   if test "$tst_compi_strlcat" = "yes"; then
4371     AC_MSG_CHECKING([if strlcat usage allowed])
4372     if test "x$curl_disallow_strlcat" != "xyes"; then
4373       AC_MSG_RESULT([yes])
4374       tst_allow_strlcat="yes"
4375     else
4376       AC_MSG_RESULT([no])
4377       tst_allow_strlcat="no"
4378     fi
4379   fi
4380   #
4381   AC_MSG_CHECKING([if strlcat might be used])
4382   if test "$tst_links_strlcat" = "yes" &&
4383      test "$tst_proto_strlcat" = "yes" &&
4384      test "$tst_compi_strlcat" = "yes" &&
4385      test "$tst_allow_strlcat" = "yes"; then
4386     AC_MSG_RESULT([yes])
4387     AC_DEFINE_UNQUOTED(HAVE_STRLCAT, 1,
4388       [Define to 1 if you have the strlcat function.])
4389     ac_cv_func_strlcat="yes"
4390   else
4391     AC_MSG_RESULT([no])
4392     ac_cv_func_strlcat="no"
4393   fi
4394 ])
4395
4396
4397 dnl CURL_CHECK_FUNC_STRNCASECMP
4398 dnl -------------------------------------------------
4399 dnl Verify if strncasecmp is available, prototyped, and
4400 dnl can be compiled. If all of these are true, and
4401 dnl usage has not been previously disallowed with
4402 dnl shell variable curl_disallow_strncasecmp, then
4403 dnl HAVE_STRNCASECMP will be defined.
4404
4405 AC_DEFUN([CURL_CHECK_FUNC_STRNCASECMP], [
4406   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4407   #
4408   tst_links_strncasecmp="unknown"
4409   tst_proto_strncasecmp="unknown"
4410   tst_compi_strncasecmp="unknown"
4411   tst_allow_strncasecmp="unknown"
4412   #
4413   AC_MSG_CHECKING([if strncasecmp can be linked])
4414   AC_LINK_IFELSE([
4415     AC_LANG_FUNC_LINK_TRY([strncasecmp])
4416   ],[
4417     AC_MSG_RESULT([yes])
4418     tst_links_strncasecmp="yes"
4419   ],[
4420     AC_MSG_RESULT([no])
4421     tst_links_strncasecmp="no"
4422   ])
4423   #
4424   if test "$tst_links_strncasecmp" = "yes"; then
4425     AC_MSG_CHECKING([if strncasecmp is prototyped])
4426     AC_EGREP_CPP([strncasecmp],[
4427       $curl_includes_string
4428     ],[
4429       AC_MSG_RESULT([yes])
4430       tst_proto_strncasecmp="yes"
4431     ],[
4432       AC_MSG_RESULT([no])
4433       tst_proto_strncasecmp="no"
4434     ])
4435   fi
4436   #
4437   if test "$tst_proto_strncasecmp" = "yes"; then
4438     AC_MSG_CHECKING([if strncasecmp is compilable])
4439     AC_COMPILE_IFELSE([
4440       AC_LANG_PROGRAM([[
4441         $curl_includes_string
4442       ]],[[
4443         if(0 != strncasecmp(0, 0, 0))
4444           return 1;
4445       ]])
4446     ],[
4447       AC_MSG_RESULT([yes])
4448       tst_compi_strncasecmp="yes"
4449     ],[
4450       AC_MSG_RESULT([no])
4451       tst_compi_strncasecmp="no"
4452     ])
4453   fi
4454   #
4455   if test "$tst_compi_strncasecmp" = "yes"; then
4456     AC_MSG_CHECKING([if strncasecmp usage allowed])
4457     if test "x$curl_disallow_strncasecmp" != "xyes"; then
4458       AC_MSG_RESULT([yes])
4459       tst_allow_strncasecmp="yes"
4460     else
4461       AC_MSG_RESULT([no])
4462       tst_allow_strncasecmp="no"
4463     fi
4464   fi
4465   #
4466   AC_MSG_CHECKING([if strncasecmp might be used])
4467   if test "$tst_links_strncasecmp" = "yes" &&
4468      test "$tst_proto_strncasecmp" = "yes" &&
4469      test "$tst_compi_strncasecmp" = "yes" &&
4470      test "$tst_allow_strncasecmp" = "yes"; then
4471     AC_MSG_RESULT([yes])
4472     AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
4473       [Define to 1 if you have the strncasecmp function.])
4474     ac_cv_func_strncasecmp="yes"
4475   else
4476     AC_MSG_RESULT([no])
4477     ac_cv_func_strncasecmp="no"
4478   fi
4479 ])
4480
4481
4482 dnl CURL_CHECK_FUNC_STRNCMPI
4483 dnl -------------------------------------------------
4484 dnl Verify if strncmpi is available, prototyped, and
4485 dnl can be compiled. If all of these are true, and
4486 dnl usage has not been previously disallowed with
4487 dnl shell variable curl_disallow_strncmpi, then
4488 dnl HAVE_STRNCMPI will be defined.
4489
4490 AC_DEFUN([CURL_CHECK_FUNC_STRNCMPI], [
4491   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4492   #
4493   tst_links_strncmpi="unknown"
4494   tst_proto_strncmpi="unknown"
4495   tst_compi_strncmpi="unknown"
4496   tst_allow_strncmpi="unknown"
4497   #
4498   AC_MSG_CHECKING([if strncmpi can be linked])
4499   AC_LINK_IFELSE([
4500     AC_LANG_FUNC_LINK_TRY([strncmpi])
4501   ],[
4502     AC_MSG_RESULT([yes])
4503     tst_links_strncmpi="yes"
4504   ],[
4505     AC_MSG_RESULT([no])
4506     tst_links_strncmpi="no"
4507   ])
4508   #
4509   if test "$tst_links_strncmpi" = "yes"; then
4510     AC_MSG_CHECKING([if strncmpi is prototyped])
4511     AC_EGREP_CPP([strncmpi],[
4512       $curl_includes_string
4513     ],[
4514       AC_MSG_RESULT([yes])
4515       tst_proto_strncmpi="yes"
4516     ],[
4517       AC_MSG_RESULT([no])
4518       tst_proto_strncmpi="no"
4519     ])
4520   fi
4521   #
4522   if test "$tst_proto_strncmpi" = "yes"; then
4523     AC_MSG_CHECKING([if strncmpi is compilable])
4524     AC_COMPILE_IFELSE([
4525       AC_LANG_PROGRAM([[
4526         $curl_includes_string
4527       ]],[[
4528         if(0 != strncmpi(0, 0))
4529           return 1;
4530       ]])
4531     ],[
4532       AC_MSG_RESULT([yes])
4533       tst_compi_strncmpi="yes"
4534     ],[
4535       AC_MSG_RESULT([no])
4536       tst_compi_strncmpi="no"
4537     ])
4538   fi
4539   #
4540   if test "$tst_compi_strncmpi" = "yes"; then
4541     AC_MSG_CHECKING([if strncmpi usage allowed])
4542     if test "x$curl_disallow_strncmpi" != "xyes"; then
4543       AC_MSG_RESULT([yes])
4544       tst_allow_strncmpi="yes"
4545     else
4546       AC_MSG_RESULT([no])
4547       tst_allow_strncmpi="no"
4548     fi
4549   fi
4550   #
4551   AC_MSG_CHECKING([if strncmpi might be used])
4552   if test "$tst_links_strncmpi" = "yes" &&
4553      test "$tst_proto_strncmpi" = "yes" &&
4554      test "$tst_compi_strncmpi" = "yes" &&
4555      test "$tst_allow_strncmpi" = "yes"; then
4556     AC_MSG_RESULT([yes])
4557     AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
4558       [Define to 1 if you have the strncmpi function.])
4559     ac_cv_func_strncmpi="yes"
4560   else
4561     AC_MSG_RESULT([no])
4562     ac_cv_func_strncmpi="no"
4563   fi
4564 ])
4565
4566
4567 dnl CURL_CHECK_FUNC_STRNICMP
4568 dnl -------------------------------------------------
4569 dnl Verify if strnicmp is available, prototyped, and
4570 dnl can be compiled. If all of these are true, and
4571 dnl usage has not been previously disallowed with
4572 dnl shell variable curl_disallow_strnicmp, then
4573 dnl HAVE_STRNICMP will be defined.
4574
4575 AC_DEFUN([CURL_CHECK_FUNC_STRNICMP], [
4576   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4577   #
4578   tst_links_strnicmp="unknown"
4579   tst_proto_strnicmp="unknown"
4580   tst_compi_strnicmp="unknown"
4581   tst_allow_strnicmp="unknown"
4582   #
4583   AC_MSG_CHECKING([if strnicmp can be linked])
4584   AC_LINK_IFELSE([
4585     AC_LANG_FUNC_LINK_TRY([strnicmp])
4586   ],[
4587     AC_MSG_RESULT([yes])
4588     tst_links_strnicmp="yes"
4589   ],[
4590     AC_MSG_RESULT([no])
4591     tst_links_strnicmp="no"
4592   ])
4593   #
4594   if test "$tst_links_strnicmp" = "yes"; then
4595     AC_MSG_CHECKING([if strnicmp is prototyped])
4596     AC_EGREP_CPP([strnicmp],[
4597       $curl_includes_string
4598     ],[
4599       AC_MSG_RESULT([yes])
4600       tst_proto_strnicmp="yes"
4601     ],[
4602       AC_MSG_RESULT([no])
4603       tst_proto_strnicmp="no"
4604     ])
4605   fi
4606   #
4607   if test "$tst_proto_strnicmp" = "yes"; then
4608     AC_MSG_CHECKING([if strnicmp is compilable])
4609     AC_COMPILE_IFELSE([
4610       AC_LANG_PROGRAM([[
4611         $curl_includes_string
4612       ]],[[
4613         if(0 != strnicmp(0, 0))
4614           return 1;
4615       ]])
4616     ],[
4617       AC_MSG_RESULT([yes])
4618       tst_compi_strnicmp="yes"
4619     ],[
4620       AC_MSG_RESULT([no])
4621       tst_compi_strnicmp="no"
4622     ])
4623   fi
4624   #
4625   if test "$tst_compi_strnicmp" = "yes"; then
4626     AC_MSG_CHECKING([if strnicmp usage allowed])
4627     if test "x$curl_disallow_strnicmp" != "xyes"; then
4628       AC_MSG_RESULT([yes])
4629       tst_allow_strnicmp="yes"
4630     else
4631       AC_MSG_RESULT([no])
4632       tst_allow_strnicmp="no"
4633     fi
4634   fi
4635   #
4636   AC_MSG_CHECKING([if strnicmp might be used])
4637   if test "$tst_links_strnicmp" = "yes" &&
4638      test "$tst_proto_strnicmp" = "yes" &&
4639      test "$tst_compi_strnicmp" = "yes" &&
4640      test "$tst_allow_strnicmp" = "yes"; then
4641     AC_MSG_RESULT([yes])
4642     AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
4643       [Define to 1 if you have the strnicmp function.])
4644     ac_cv_func_strnicmp="yes"
4645   else
4646     AC_MSG_RESULT([no])
4647     ac_cv_func_strnicmp="no"
4648   fi
4649 ])
4650
4651
4652 dnl CURL_CHECK_FUNC_STRSTR
4653 dnl -------------------------------------------------
4654 dnl Verify if strstr is available, prototyped, and
4655 dnl can be compiled. If all of these are true, and
4656 dnl usage has not been previously disallowed with
4657 dnl shell variable curl_disallow_strstr, then
4658 dnl HAVE_STRSTR will be defined.
4659
4660 AC_DEFUN([CURL_CHECK_FUNC_STRSTR], [
4661   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4662   #
4663   tst_links_strstr="unknown"
4664   tst_proto_strstr="unknown"
4665   tst_compi_strstr="unknown"
4666   tst_allow_strstr="unknown"
4667   #
4668   AC_MSG_CHECKING([if strstr can be linked])
4669   AC_LINK_IFELSE([
4670     AC_LANG_FUNC_LINK_TRY([strstr])
4671   ],[
4672     AC_MSG_RESULT([yes])
4673     tst_links_strstr="yes"
4674   ],[
4675     AC_MSG_RESULT([no])
4676     tst_links_strstr="no"
4677   ])
4678   #
4679   if test "$tst_links_strstr" = "yes"; then
4680     AC_MSG_CHECKING([if strstr is prototyped])
4681     AC_EGREP_CPP([strstr],[
4682       $curl_includes_string
4683     ],[
4684       AC_MSG_RESULT([yes])
4685       tst_proto_strstr="yes"
4686     ],[
4687       AC_MSG_RESULT([no])
4688       tst_proto_strstr="no"
4689     ])
4690   fi
4691   #
4692   if test "$tst_proto_strstr" = "yes"; then
4693     AC_MSG_CHECKING([if strstr is compilable])
4694     AC_COMPILE_IFELSE([
4695       AC_LANG_PROGRAM([[
4696         $curl_includes_string
4697       ]],[[
4698         if(0 != strstr(0, 0))
4699           return 1;
4700       ]])
4701     ],[
4702       AC_MSG_RESULT([yes])
4703       tst_compi_strstr="yes"
4704     ],[
4705       AC_MSG_RESULT([no])
4706       tst_compi_strstr="no"
4707     ])
4708   fi
4709   #
4710   if test "$tst_compi_strstr" = "yes"; then
4711     AC_MSG_CHECKING([if strstr usage allowed])
4712     if test "x$curl_disallow_strstr" != "xyes"; then
4713       AC_MSG_RESULT([yes])
4714       tst_allow_strstr="yes"
4715     else
4716       AC_MSG_RESULT([no])
4717       tst_allow_strstr="no"
4718     fi
4719   fi
4720   #
4721   AC_MSG_CHECKING([if strstr might be used])
4722   if test "$tst_links_strstr" = "yes" &&
4723      test "$tst_proto_strstr" = "yes" &&
4724      test "$tst_compi_strstr" = "yes" &&
4725      test "$tst_allow_strstr" = "yes"; then
4726     AC_MSG_RESULT([yes])
4727     AC_DEFINE_UNQUOTED(HAVE_STRSTR, 1,
4728       [Define to 1 if you have the strstr function.])
4729     ac_cv_func_strstr="yes"
4730   else
4731     AC_MSG_RESULT([no])
4732     ac_cv_func_strstr="no"
4733   fi
4734 ])
4735
4736
4737 dnl CURL_CHECK_FUNC_STRTOK_R
4738 dnl -------------------------------------------------
4739 dnl Verify if strtok_r is available, prototyped, and
4740 dnl can be compiled. If all of these are true, and
4741 dnl usage has not been previously disallowed with
4742 dnl shell variable curl_disallow_strtok_r, then
4743 dnl HAVE_STRTOK_R will be defined.
4744
4745 AC_DEFUN([CURL_CHECK_FUNC_STRTOK_R], [
4746   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4747   #
4748   tst_links_strtok_r="unknown"
4749   tst_proto_strtok_r="unknown"
4750   tst_compi_strtok_r="unknown"
4751   tst_allow_strtok_r="unknown"
4752   #
4753   AC_MSG_CHECKING([if strtok_r can be linked])
4754   AC_LINK_IFELSE([
4755     AC_LANG_FUNC_LINK_TRY([strtok_r])
4756   ],[
4757     AC_MSG_RESULT([yes])
4758     tst_links_strtok_r="yes"
4759   ],[
4760     AC_MSG_RESULT([no])
4761     tst_links_strtok_r="no"
4762   ])
4763   #
4764   if test "$tst_links_strtok_r" = "yes"; then
4765     AC_MSG_CHECKING([if strtok_r is prototyped])
4766     AC_EGREP_CPP([strtok_r],[
4767       $curl_includes_string
4768     ],[
4769       AC_MSG_RESULT([yes])
4770       tst_proto_strtok_r="yes"
4771     ],[
4772       AC_MSG_RESULT([no])
4773       tst_proto_strtok_r="no"
4774     ])
4775   fi
4776   #
4777   if test "$tst_proto_strtok_r" = "yes"; then
4778     AC_MSG_CHECKING([if strtok_r is compilable])
4779     AC_COMPILE_IFELSE([
4780       AC_LANG_PROGRAM([[
4781         $curl_includes_string
4782       ]],[[
4783         if(0 != strtok_r(0, 0, 0))
4784           return 1;
4785       ]])
4786     ],[
4787       AC_MSG_RESULT([yes])
4788       tst_compi_strtok_r="yes"
4789     ],[
4790       AC_MSG_RESULT([no])
4791       tst_compi_strtok_r="no"
4792     ])
4793   fi
4794   #
4795   if test "$tst_compi_strtok_r" = "yes"; then
4796     AC_MSG_CHECKING([if strtok_r usage allowed])
4797     if test "x$curl_disallow_strtok_r" != "xyes"; then
4798       AC_MSG_RESULT([yes])
4799       tst_allow_strtok_r="yes"
4800     else
4801       AC_MSG_RESULT([no])
4802       tst_allow_strtok_r="no"
4803     fi
4804   fi
4805   #
4806   AC_MSG_CHECKING([if strtok_r might be used])
4807   if test "$tst_links_strtok_r" = "yes" &&
4808      test "$tst_proto_strtok_r" = "yes" &&
4809      test "$tst_compi_strtok_r" = "yes" &&
4810      test "$tst_allow_strtok_r" = "yes"; then
4811     AC_MSG_RESULT([yes])
4812     AC_DEFINE_UNQUOTED(HAVE_STRTOK_R, 1,
4813       [Define to 1 if you have the strtok_r function.])
4814     ac_cv_func_strtok_r="yes"
4815   else
4816     AC_MSG_RESULT([no])
4817     ac_cv_func_strtok_r="no"
4818   fi
4819 ])
4820
4821
4822 dnl CURL_CHECK_FUNC_STRTOLL
4823 dnl -------------------------------------------------
4824 dnl Verify if strtoll is available, prototyped, and
4825 dnl can be compiled. If all of these are true, and
4826 dnl usage has not been previously disallowed with
4827 dnl shell variable curl_disallow_strtoll, then
4828 dnl HAVE_STRTOLL will be defined.
4829
4830 AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
4831   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4832   #
4833   tst_links_strtoll="unknown"
4834   tst_proto_strtoll="unknown"
4835   tst_compi_strtoll="unknown"
4836   tst_allow_strtoll="unknown"
4837   #
4838   AC_MSG_CHECKING([if strtoll can be linked])
4839   AC_LINK_IFELSE([
4840     AC_LANG_FUNC_LINK_TRY([strtoll])
4841   ],[
4842     AC_MSG_RESULT([yes])
4843     tst_links_strtoll="yes"
4844   ],[
4845     AC_MSG_RESULT([no])
4846     tst_links_strtoll="no"
4847   ])
4848   #
4849   if test "$tst_links_strtoll" = "yes"; then
4850     AC_MSG_CHECKING([if strtoll is prototyped])
4851     AC_EGREP_CPP([strtoll],[
4852       $curl_includes_stdlib
4853     ],[
4854       AC_MSG_RESULT([yes])
4855       tst_proto_strtoll="yes"
4856     ],[
4857       AC_MSG_RESULT([no])
4858       tst_proto_strtoll="no"
4859     ])
4860   fi
4861   #
4862   if test "$tst_proto_strtoll" = "yes"; then
4863     AC_MSG_CHECKING([if strtoll is compilable])
4864     AC_COMPILE_IFELSE([
4865       AC_LANG_PROGRAM([[
4866         $curl_includes_stdlib
4867       ]],[[
4868         if(0 != strtoll(0, 0, 0))
4869           return 1;
4870       ]])
4871     ],[
4872       AC_MSG_RESULT([yes])
4873       tst_compi_strtoll="yes"
4874     ],[
4875       AC_MSG_RESULT([no])
4876       tst_compi_strtoll="no"
4877     ])
4878   fi
4879   #
4880   if test "$tst_compi_strtoll" = "yes"; then
4881     AC_MSG_CHECKING([if strtoll usage allowed])
4882     if test "x$curl_disallow_strtoll" != "xyes"; then
4883       AC_MSG_RESULT([yes])
4884       tst_allow_strtoll="yes"
4885     else
4886       AC_MSG_RESULT([no])
4887       tst_allow_strtoll="no"
4888     fi
4889   fi
4890   #
4891   AC_MSG_CHECKING([if strtoll might be used])
4892   if test "$tst_links_strtoll" = "yes" &&
4893      test "$tst_proto_strtoll" = "yes" &&
4894      test "$tst_compi_strtoll" = "yes" &&
4895      test "$tst_allow_strtoll" = "yes"; then
4896     AC_MSG_RESULT([yes])
4897     AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
4898       [Define to 1 if you have the strtoll function.])
4899     ac_cv_func_strtoll="yes"
4900   else
4901     AC_MSG_RESULT([no])
4902     ac_cv_func_strtoll="no"
4903   fi
4904 ])
4905
4906
4907 dnl CURL_CHECK_FUNC_WRITEV
4908 dnl -------------------------------------------------
4909 dnl Verify if writev is available, prototyped, and
4910 dnl can be compiled. If all of these are true, and
4911 dnl usage has not been previously disallowed with
4912 dnl shell variable curl_disallow_writev, then
4913 dnl HAVE_WRITEV will be defined.
4914
4915 AC_DEFUN([CURL_CHECK_FUNC_WRITEV], [
4916   AC_REQUIRE([CURL_INCLUDES_SYS_UIO])dnl
4917   #
4918   tst_links_writev="unknown"
4919   tst_proto_writev="unknown"
4920   tst_compi_writev="unknown"
4921   tst_allow_writev="unknown"
4922   #
4923   AC_MSG_CHECKING([if writev can be linked])
4924   AC_LINK_IFELSE([
4925     AC_LANG_FUNC_LINK_TRY([writev])
4926   ],[
4927     AC_MSG_RESULT([yes])
4928     tst_links_writev="yes"
4929   ],[
4930     AC_MSG_RESULT([no])
4931     tst_links_writev="no"
4932   ])
4933   #
4934   if test "$tst_links_writev" = "yes"; then
4935     AC_MSG_CHECKING([if writev is prototyped])
4936     AC_EGREP_CPP([writev],[
4937       $curl_includes_sys_uio
4938     ],[
4939       AC_MSG_RESULT([yes])
4940       tst_proto_writev="yes"
4941     ],[
4942       AC_MSG_RESULT([no])
4943       tst_proto_writev="no"
4944     ])
4945   fi
4946   #
4947   if test "$tst_proto_writev" = "yes"; then
4948     AC_MSG_CHECKING([if writev is compilable])
4949     AC_COMPILE_IFELSE([
4950       AC_LANG_PROGRAM([[
4951         $curl_includes_sys_uio
4952       ]],[[
4953         if(0 != writev(0, 0, 0))
4954           return 1;
4955       ]])
4956     ],[
4957       AC_MSG_RESULT([yes])
4958       tst_compi_writev="yes"
4959     ],[
4960       AC_MSG_RESULT([no])
4961       tst_compi_writev="no"
4962     ])
4963   fi
4964   #
4965   if test "$tst_compi_writev" = "yes"; then
4966     AC_MSG_CHECKING([if writev usage allowed])
4967     if test "x$curl_disallow_writev" != "xyes"; then
4968       AC_MSG_RESULT([yes])
4969       tst_allow_writev="yes"
4970     else
4971       AC_MSG_RESULT([no])
4972       tst_allow_writev="no"
4973     fi
4974   fi
4975   #
4976   AC_MSG_CHECKING([if writev might be used])
4977   if test "$tst_links_writev" = "yes" &&
4978      test "$tst_proto_writev" = "yes" &&
4979      test "$tst_compi_writev" = "yes" &&
4980      test "$tst_allow_writev" = "yes"; then
4981     AC_MSG_RESULT([yes])
4982     AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
4983       [Define to 1 if you have the writev function.])
4984     ac_cv_func_writev="yes"
4985   else
4986     AC_MSG_RESULT([no])
4987     ac_cv_func_writev="no"
4988   fi
4989 ])