Imported Upstream version 7.53.1
[platform/upstream/curl.git] / m4 / curl-functions.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2016, 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 https://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 #***************************************************************************
22
23 # File version for 'aclocal' use. Keep it a single number.
24 # serial 73
25
26
27 dnl CURL_INCLUDES_ARPA_INET
28 dnl -------------------------------------------------
29 dnl Set up variable with list of headers that must be
30 dnl included when arpa/inet.h is to be included.
31
32 AC_DEFUN([CURL_INCLUDES_ARPA_INET], [
33 curl_includes_arpa_inet="\
34 /* includes start */
35 #ifdef HAVE_SYS_TYPES_H
36 #  include <sys/types.h>
37 #endif
38 #ifdef HAVE_SYS_SOCKET_H
39 #  include <sys/socket.h>
40 #endif
41 #ifdef HAVE_NETINET_IN_H
42 #  include <netinet/in.h>
43 #endif
44 #ifdef HAVE_ARPA_INET_H
45 #  include <arpa/inet.h>
46 #endif
47 #ifdef HAVE_WINSOCK2_H
48 #include <winsock2.h>
49 #include <ws2tcpip.h>
50 #endif
51 /* includes end */"
52   AC_CHECK_HEADERS(
53     sys/types.h sys/socket.h netinet/in.h arpa/inet.h,
54     [], [], [$curl_includes_arpa_inet])
55 ])
56
57
58 dnl CURL_INCLUDES_FCNTL
59 dnl -------------------------------------------------
60 dnl Set up variable with list of headers that must be
61 dnl included when fcntl.h is to be included.
62
63 AC_DEFUN([CURL_INCLUDES_FCNTL], [
64 curl_includes_fcntl="\
65 /* includes start */
66 #ifdef HAVE_SYS_TYPES_H
67 #  include <sys/types.h>
68 #endif
69 #ifdef HAVE_UNISTD_H
70 #  include <unistd.h>
71 #endif
72 #ifdef HAVE_FCNTL_H
73 #  include <fcntl.h>
74 #endif
75 /* includes end */"
76   AC_CHECK_HEADERS(
77     sys/types.h unistd.h fcntl.h,
78     [], [], [$curl_includes_fcntl])
79 ])
80
81
82 dnl CURL_INCLUDES_IFADDRS
83 dnl -------------------------------------------------
84 dnl Set up variable with list of headers that must be
85 dnl included when ifaddrs.h is to be included.
86
87 AC_DEFUN([CURL_INCLUDES_IFADDRS], [
88 curl_includes_ifaddrs="\
89 /* includes start */
90 #ifdef HAVE_SYS_TYPES_H
91 #  include <sys/types.h>
92 #endif
93 #ifdef HAVE_SYS_SOCKET_H
94 #  include <sys/socket.h>
95 #endif
96 #ifdef HAVE_NETINET_IN_H
97 #  include <netinet/in.h>
98 #endif
99 #ifdef HAVE_IFADDRS_H
100 #  include <ifaddrs.h>
101 #endif
102 /* includes end */"
103   AC_CHECK_HEADERS(
104     sys/types.h sys/socket.h netinet/in.h ifaddrs.h,
105     [], [], [$curl_includes_ifaddrs])
106 ])
107
108
109 dnl CURL_INCLUDES_INTTYPES
110 dnl -------------------------------------------------
111 dnl Set up variable with list of headers that must be
112 dnl included when inttypes.h is to be included.
113
114 AC_DEFUN([CURL_INCLUDES_INTTYPES], [
115 curl_includes_inttypes="\
116 /* includes start */
117 #ifdef HAVE_SYS_TYPES_H
118 # include <sys/types.h>
119 #endif
120 #ifdef HAVE_STDINT_H
121 # include <stdint.h>
122 #endif
123 #ifdef HAVE_INTTYPES_H
124 # include <inttypes.h>
125 #endif
126 /* includes end */"
127   case $host_os in
128     irix*)
129       ac_cv_header_stdint_h="no"
130       ;;
131   esac
132   AC_CHECK_HEADERS(
133     sys/types.h stdint.h inttypes.h,
134     [], [], [$curl_includes_inttypes])
135 ])
136
137
138 dnl CURL_INCLUDES_LIBGEN
139 dnl -------------------------------------------------
140 dnl Set up variable with list of headers that must be
141 dnl included when libgen.h is to be included.
142
143 AC_DEFUN([CURL_INCLUDES_LIBGEN], [
144 curl_includes_libgen="\
145 /* includes start */
146 #ifdef HAVE_SYS_TYPES_H
147 #  include <sys/types.h>
148 #endif
149 #ifdef HAVE_LIBGEN_H
150 #  include <libgen.h>
151 #endif
152 /* includes end */"
153   AC_CHECK_HEADERS(
154     sys/types.h libgen.h,
155     [], [], [$curl_includes_libgen])
156 ])
157
158
159 dnl CURL_INCLUDES_NETDB
160 dnl -------------------------------------------------
161 dnl Set up variable with list of headers that must be
162 dnl included when netdb.h is to be included.
163
164 AC_DEFUN([CURL_INCLUDES_NETDB], [
165 curl_includes_netdb="\
166 /* includes start */
167 #ifdef HAVE_SYS_TYPES_H
168 #  include <sys/types.h>
169 #endif
170 #ifdef HAVE_NETDB_H
171 #  include <netdb.h>
172 #endif
173 /* includes end */"
174   AC_CHECK_HEADERS(
175     sys/types.h netdb.h,
176     [], [], [$curl_includes_netdb])
177 ])
178
179
180 dnl CURL_INCLUDES_POLL
181 dnl -------------------------------------------------
182 dnl Set up variable with list of headers that must be
183 dnl included when poll.h is to be included.
184
185 AC_DEFUN([CURL_INCLUDES_POLL], [
186 curl_includes_poll="\
187 /* includes start */
188 #ifdef HAVE_SYS_TYPES_H
189 #  include <sys/types.h>
190 #endif
191 #ifdef HAVE_POLL_H
192 #  include <poll.h>
193 #endif
194 #ifdef HAVE_SYS_POLL_H
195 #  include <sys/poll.h>
196 #endif
197 /* includes end */"
198   AC_CHECK_HEADERS(
199     sys/types.h poll.h sys/poll.h,
200     [], [], [$curl_includes_poll])
201 ])
202
203
204 dnl CURL_INCLUDES_SETJMP
205 dnl -------------------------------------------------
206 dnl Set up variable with list of headers that must be
207 dnl included when setjmp.h is to be included.
208
209 AC_DEFUN([CURL_INCLUDES_SETJMP], [
210 curl_includes_setjmp="\
211 /* includes start */
212 #ifdef HAVE_SYS_TYPES_H
213 #  include <sys/types.h>
214 #endif
215 #ifdef HAVE_SETJMP_H
216 #  include <setjmp.h>
217 #endif
218 /* includes end */"
219   AC_CHECK_HEADERS(
220     sys/types.h setjmp.h,
221     [], [], [$curl_includes_setjmp])
222 ])
223
224
225 dnl CURL_INCLUDES_SIGNAL
226 dnl -------------------------------------------------
227 dnl Set up variable with list of headers that must be
228 dnl included when signal.h is to be included.
229
230 AC_DEFUN([CURL_INCLUDES_SIGNAL], [
231 curl_includes_signal="\
232 /* includes start */
233 #ifdef HAVE_SYS_TYPES_H
234 #  include <sys/types.h>
235 #endif
236 #ifdef HAVE_SIGNAL_H
237 #  include <signal.h>
238 #endif
239 /* includes end */"
240   AC_CHECK_HEADERS(
241     sys/types.h signal.h,
242     [], [], [$curl_includes_signal])
243 ])
244
245
246 dnl CURL_INCLUDES_SOCKET
247 dnl -------------------------------------------------
248 dnl Set up variable with list of headers that must be
249 dnl included when socket.h is to be included.
250
251 AC_DEFUN([CURL_INCLUDES_SOCKET], [
252 curl_includes_socket="\
253 /* includes start */
254 #ifdef HAVE_SYS_TYPES_H
255 #  include <sys/types.h>
256 #endif
257 #ifdef HAVE_SOCKET_H
258 #  include <socket.h>
259 #endif
260 /* includes end */"
261   AC_CHECK_HEADERS(
262     sys/types.h socket.h,
263     [], [], [$curl_includes_socket])
264 ])
265
266
267 dnl CURL_INCLUDES_STDIO
268 dnl -------------------------------------------------
269 dnl Set up variable with list of headers that must be
270 dnl included when stdio.h is to be included.
271
272 AC_DEFUN([CURL_INCLUDES_STDIO], [
273 curl_includes_stdio="\
274 /* includes start */
275 #ifdef HAVE_SYS_TYPES_H
276 #  include <sys/types.h>
277 #endif
278 #ifdef HAVE_STDIO_H
279 #  include <stdio.h>
280 #endif
281 /* includes end */"
282   AC_CHECK_HEADERS(
283     sys/types.h stdio.h,
284     [], [], [$curl_includes_stdio])
285 ])
286
287
288 dnl CURL_INCLUDES_STDLIB
289 dnl -------------------------------------------------
290 dnl Set up variable with list of headers that must be
291 dnl included when stdlib.h is to be included.
292
293 AC_DEFUN([CURL_INCLUDES_STDLIB], [
294 curl_includes_stdlib="\
295 /* includes start */
296 #ifdef HAVE_SYS_TYPES_H
297 #  include <sys/types.h>
298 #endif
299 #ifdef HAVE_STDLIB_H
300 #  include <stdlib.h>
301 #endif
302 /* includes end */"
303   AC_CHECK_HEADERS(
304     sys/types.h stdlib.h,
305     [], [], [$curl_includes_stdlib])
306 ])
307
308
309 dnl CURL_INCLUDES_STRING
310 dnl -------------------------------------------------
311 dnl Set up variable with list of headers that must be
312 dnl included when string(s).h is to be included.
313
314 AC_DEFUN([CURL_INCLUDES_STRING], [
315 curl_includes_string="\
316 /* includes start */
317 #ifdef HAVE_SYS_TYPES_H
318 #  include <sys/types.h>
319 #endif
320 #ifdef HAVE_STRING_H
321 #  include <string.h>
322 #endif
323 #ifdef HAVE_STRINGS_H
324 #  include <strings.h>
325 #endif
326 /* includes end */"
327   AC_CHECK_HEADERS(
328     sys/types.h string.h strings.h,
329     [], [], [$curl_includes_string])
330 ])
331
332
333 dnl CURL_INCLUDES_STROPTS
334 dnl -------------------------------------------------
335 dnl Set up variable with list of headers that must be
336 dnl included when stropts.h is to be included.
337
338 AC_DEFUN([CURL_INCLUDES_STROPTS], [
339 curl_includes_stropts="\
340 /* includes start */
341 #ifdef HAVE_SYS_TYPES_H
342 #  include <sys/types.h>
343 #endif
344 #ifdef HAVE_UNISTD_H
345 #  include <unistd.h>
346 #endif
347 #ifdef HAVE_SYS_SOCKET_H
348 #  include <sys/socket.h>
349 #endif
350 #ifdef HAVE_SYS_IOCTL_H
351 #  include <sys/ioctl.h>
352 #endif
353 #ifdef HAVE_STROPTS_H
354 #  include <stropts.h>
355 #endif
356 /* includes end */"
357   AC_CHECK_HEADERS(
358     sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
359     [], [], [$curl_includes_stropts])
360 ])
361
362
363 dnl CURL_INCLUDES_SYS_SOCKET
364 dnl -------------------------------------------------
365 dnl Set up variable with list of headers that must be
366 dnl included when sys/socket.h is to be included.
367
368 AC_DEFUN([CURL_INCLUDES_SYS_SOCKET], [
369 curl_includes_sys_socket="\
370 /* includes start */
371 #ifdef HAVE_SYS_TYPES_H
372 #  include <sys/types.h>
373 #endif
374 #ifdef HAVE_SYS_SOCKET_H
375 #  include <sys/socket.h>
376 #endif
377 /* includes end */"
378   AC_CHECK_HEADERS(
379     sys/types.h sys/socket.h,
380     [], [], [$curl_includes_sys_socket])
381 ])
382
383
384 dnl CURL_INCLUDES_SYS_TYPES
385 dnl -------------------------------------------------
386 dnl Set up variable with list of headers that must be
387 dnl included when sys/types.h is to be included.
388
389 AC_DEFUN([CURL_INCLUDES_SYS_TYPES], [
390 curl_includes_sys_types="\
391 /* includes start */
392 #ifdef HAVE_SYS_TYPES_H
393 #  include <sys/types.h>
394 #endif
395 /* includes end */"
396   AC_CHECK_HEADERS(
397     sys/types.h,
398     [], [], [$curl_includes_sys_types])
399 ])
400
401
402 dnl CURL_INCLUDES_SYS_UIO
403 dnl -------------------------------------------------
404 dnl Set up variable with list of headers that must be
405 dnl included when sys/uio.h is to be included.
406
407 AC_DEFUN([CURL_INCLUDES_SYS_UIO], [
408 curl_includes_sys_uio="\
409 /* includes start */
410 #ifdef HAVE_SYS_TYPES_H
411 #  include <sys/types.h>
412 #endif
413 #ifdef HAVE_SYS_UIO_H
414 #  include <sys/uio.h>
415 #endif
416 /* includes end */"
417   AC_CHECK_HEADERS(
418     sys/types.h sys/uio.h,
419     [], [], [$curl_includes_sys_uio])
420 ])
421
422
423 dnl CURL_INCLUDES_SYS_XATTR
424 dnl -------------------------------------------------
425 dnl Set up variable with list of headers that must be
426 dnl included when sys/xattr.h is to be included.
427
428 AC_DEFUN([CURL_INCLUDES_SYS_XATTR], [
429 curl_includes_sys_xattr="\
430 /* includes start */
431 #ifdef HAVE_SYS_TYPES_H
432 #  include <sys/types.h>
433 #endif
434 #ifdef HAVE_SYS_XATTR_H
435 #  include <sys/xattr.h>
436 #endif
437 /* includes end */"
438   AC_CHECK_HEADERS(
439     sys/types.h sys/xattr.h,
440     [], [], [$curl_includes_sys_xattr])
441 ])
442
443 dnl CURL_INCLUDES_TIME
444 dnl -------------------------------------------------
445 dnl Set up variable with list of headers that must be
446 dnl included when time.h is to be included.
447
448 AC_DEFUN([CURL_INCLUDES_TIME], [
449 AC_REQUIRE([AC_HEADER_TIME])dnl
450 curl_includes_time="\
451 /* includes start */
452 #ifdef HAVE_SYS_TYPES_H
453 #  include <sys/types.h>
454 #endif
455 #ifdef HAVE_SYS_TIME_H
456 #  include <sys/time.h>
457 #  ifdef TIME_WITH_SYS_TIME
458 #    include <time.h>
459 #  endif
460 #else
461 #  ifdef HAVE_TIME_H
462 #    include <time.h>
463 #  endif
464 #endif
465 /* includes end */"
466   AC_CHECK_HEADERS(
467     sys/types.h sys/time.h time.h,
468     [], [], [$curl_includes_time])
469 ])
470
471
472 dnl CURL_INCLUDES_UNISTD
473 dnl -------------------------------------------------
474 dnl Set up variable with list of headers that must be
475 dnl included when unistd.h is to be included.
476
477 AC_DEFUN([CURL_INCLUDES_UNISTD], [
478 curl_includes_unistd="\
479 /* includes start */
480 #ifdef HAVE_SYS_TYPES_H
481 #  include <sys/types.h>
482 #endif
483 #ifdef HAVE_UNISTD_H
484 #  include <unistd.h>
485 #endif
486 /* includes end */"
487   AC_CHECK_HEADERS(
488     sys/types.h unistd.h,
489     [], [], [$curl_includes_unistd])
490 ])
491
492
493 dnl CURL_INCLUDES_WINSOCK2
494 dnl -------------------------------------------------
495 dnl Set up variable with list of headers that must be
496 dnl included when winsock(2).h is to be included.
497
498 AC_DEFUN([CURL_INCLUDES_WINSOCK2], [
499 curl_includes_winsock2="\
500 /* includes start */
501 #ifdef HAVE_WINDOWS_H
502 #  ifndef WIN32_LEAN_AND_MEAN
503 #    define WIN32_LEAN_AND_MEAN
504 #  endif
505 #  include <windows.h>
506 #  ifdef HAVE_WINSOCK2_H
507 #    include <winsock2.h>
508 #  else
509 #    ifdef HAVE_WINSOCK_H
510 #      include <winsock.h>
511 #    endif
512 #  endif
513 #endif
514 /* includes end */"
515   CURL_CHECK_HEADER_WINDOWS
516   CURL_CHECK_HEADER_WINSOCK
517   CURL_CHECK_HEADER_WINSOCK2
518 ])
519
520
521 dnl CURL_INCLUDES_WS2TCPIP
522 dnl -------------------------------------------------
523 dnl Set up variable with list of headers that must be
524 dnl included when ws2tcpip.h is to be included.
525
526 AC_DEFUN([CURL_INCLUDES_WS2TCPIP], [
527 curl_includes_ws2tcpip="\
528 /* includes start */
529 #ifdef HAVE_WINDOWS_H
530 #  ifndef WIN32_LEAN_AND_MEAN
531 #    define WIN32_LEAN_AND_MEAN
532 #  endif
533 #  include <windows.h>
534 #  ifdef HAVE_WINSOCK2_H
535 #    include <winsock2.h>
536 #    ifdef HAVE_WS2TCPIP_H
537 #       include <ws2tcpip.h>
538 #    endif
539 #  endif
540 #endif
541 /* includes end */"
542   CURL_CHECK_HEADER_WINDOWS
543   CURL_CHECK_HEADER_WINSOCK2
544   CURL_CHECK_HEADER_WS2TCPIP
545 ])
546
547
548 dnl CURL_PREPROCESS_CALLCONV
549 dnl -------------------------------------------------
550 dnl Set up variable with a preprocessor block which
551 dnl defines function calling convention.
552
553 AC_DEFUN([CURL_PREPROCESS_CALLCONV], [
554 curl_preprocess_callconv="\
555 /* preprocess start */
556 #ifdef HAVE_WINDOWS_H
557 #  define FUNCALLCONV __stdcall
558 #else
559 #  define FUNCALLCONV
560 #endif
561 /* preprocess end */"
562 ])
563
564
565 dnl CURL_CHECK_FUNC_ALARM
566 dnl -------------------------------------------------
567 dnl Verify if alarm is available, prototyped, and
568 dnl can be compiled. If all of these are true, and
569 dnl usage has not been previously disallowed with
570 dnl shell variable curl_disallow_alarm, then
571 dnl HAVE_ALARM will be defined.
572
573 AC_DEFUN([CURL_CHECK_FUNC_ALARM], [
574   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
575   #
576   tst_links_alarm="unknown"
577   tst_proto_alarm="unknown"
578   tst_compi_alarm="unknown"
579   tst_allow_alarm="unknown"
580   #
581   AC_MSG_CHECKING([if alarm can be linked])
582   AC_LINK_IFELSE([
583     AC_LANG_FUNC_LINK_TRY([alarm])
584   ],[
585     AC_MSG_RESULT([yes])
586     tst_links_alarm="yes"
587   ],[
588     AC_MSG_RESULT([no])
589     tst_links_alarm="no"
590   ])
591   #
592   if test "$tst_links_alarm" = "yes"; then
593     AC_MSG_CHECKING([if alarm is prototyped])
594     AC_EGREP_CPP([alarm],[
595       $curl_includes_unistd
596     ],[
597       AC_MSG_RESULT([yes])
598       tst_proto_alarm="yes"
599     ],[
600       AC_MSG_RESULT([no])
601       tst_proto_alarm="no"
602     ])
603   fi
604   #
605   if test "$tst_proto_alarm" = "yes"; then
606     AC_MSG_CHECKING([if alarm is compilable])
607     AC_COMPILE_IFELSE([
608       AC_LANG_PROGRAM([[
609         $curl_includes_unistd
610       ]],[[
611         if(0 != alarm(0))
612           return 1;
613       ]])
614     ],[
615       AC_MSG_RESULT([yes])
616       tst_compi_alarm="yes"
617     ],[
618       AC_MSG_RESULT([no])
619       tst_compi_alarm="no"
620     ])
621   fi
622   #
623   if test "$tst_compi_alarm" = "yes"; then
624     AC_MSG_CHECKING([if alarm usage allowed])
625     if test "x$curl_disallow_alarm" != "xyes"; then
626       AC_MSG_RESULT([yes])
627       tst_allow_alarm="yes"
628     else
629       AC_MSG_RESULT([no])
630       tst_allow_alarm="no"
631     fi
632   fi
633   #
634   AC_MSG_CHECKING([if alarm might be used])
635   if test "$tst_links_alarm" = "yes" &&
636      test "$tst_proto_alarm" = "yes" &&
637      test "$tst_compi_alarm" = "yes" &&
638      test "$tst_allow_alarm" = "yes"; then
639     AC_MSG_RESULT([yes])
640     AC_DEFINE_UNQUOTED(HAVE_ALARM, 1,
641       [Define to 1 if you have the alarm function.])
642     curl_cv_func_alarm="yes"
643   else
644     AC_MSG_RESULT([no])
645     curl_cv_func_alarm="no"
646   fi
647 ])
648
649
650 dnl CURL_CHECK_FUNC_BASENAME
651 dnl -------------------------------------------------
652 dnl Verify if basename is available, prototyped, and
653 dnl can be compiled. If all of these are true, and
654 dnl usage has not been previously disallowed with
655 dnl shell variable curl_disallow_basename, then
656 dnl HAVE_BASENAME will be defined.
657
658 AC_DEFUN([CURL_CHECK_FUNC_BASENAME], [
659   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
660   AC_REQUIRE([CURL_INCLUDES_LIBGEN])dnl
661   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
662   #
663   tst_links_basename="unknown"
664   tst_proto_basename="unknown"
665   tst_compi_basename="unknown"
666   tst_allow_basename="unknown"
667   #
668   AC_MSG_CHECKING([if basename can be linked])
669   AC_LINK_IFELSE([
670     AC_LANG_FUNC_LINK_TRY([basename])
671   ],[
672     AC_MSG_RESULT([yes])
673     tst_links_basename="yes"
674   ],[
675     AC_MSG_RESULT([no])
676     tst_links_basename="no"
677   ])
678   #
679   if test "$tst_links_basename" = "yes"; then
680     AC_MSG_CHECKING([if basename is prototyped])
681     AC_EGREP_CPP([basename],[
682       $curl_includes_string
683       $curl_includes_libgen
684       $curl_includes_unistd
685     ],[
686       AC_MSG_RESULT([yes])
687       tst_proto_basename="yes"
688     ],[
689       AC_MSG_RESULT([no])
690       tst_proto_basename="no"
691     ])
692   fi
693   #
694   if test "$tst_proto_basename" = "yes"; then
695     AC_MSG_CHECKING([if basename is compilable])
696     AC_COMPILE_IFELSE([
697       AC_LANG_PROGRAM([[
698         $curl_includes_string
699         $curl_includes_libgen
700         $curl_includes_unistd
701       ]],[[
702         if(0 != basename(0))
703           return 1;
704       ]])
705     ],[
706       AC_MSG_RESULT([yes])
707       tst_compi_basename="yes"
708     ],[
709       AC_MSG_RESULT([no])
710       tst_compi_basename="no"
711     ])
712   fi
713   #
714   if test "$tst_compi_basename" = "yes"; then
715     AC_MSG_CHECKING([if basename usage allowed])
716     if test "x$curl_disallow_basename" != "xyes"; then
717       AC_MSG_RESULT([yes])
718       tst_allow_basename="yes"
719     else
720       AC_MSG_RESULT([no])
721       tst_allow_basename="no"
722     fi
723   fi
724   #
725   AC_MSG_CHECKING([if basename might be used])
726   if test "$tst_links_basename" = "yes" &&
727      test "$tst_proto_basename" = "yes" &&
728      test "$tst_compi_basename" = "yes" &&
729      test "$tst_allow_basename" = "yes"; then
730     AC_MSG_RESULT([yes])
731     AC_DEFINE_UNQUOTED(HAVE_BASENAME, 1,
732       [Define to 1 if you have the basename function.])
733     curl_cv_func_basename="yes"
734   else
735     AC_MSG_RESULT([no])
736     curl_cv_func_basename="no"
737   fi
738 ])
739
740
741 dnl CURL_CHECK_FUNC_CLOSESOCKET
742 dnl -------------------------------------------------
743 dnl Verify if closesocket is available, prototyped, and
744 dnl can be compiled. If all of these are true, and
745 dnl usage has not been previously disallowed with
746 dnl shell variable curl_disallow_closesocket, then
747 dnl HAVE_CLOSESOCKET will be defined.
748
749 AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET], [
750   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
751   AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
752   #
753   tst_links_closesocket="unknown"
754   tst_proto_closesocket="unknown"
755   tst_compi_closesocket="unknown"
756   tst_allow_closesocket="unknown"
757   #
758   AC_MSG_CHECKING([if closesocket can be linked])
759   AC_LINK_IFELSE([
760     AC_LANG_PROGRAM([[
761       $curl_includes_winsock2
762       $curl_includes_socket
763     ]],[[
764       if(0 != closesocket(0))
765         return 1;
766     ]])
767   ],[
768     AC_MSG_RESULT([yes])
769     tst_links_closesocket="yes"
770   ],[
771     AC_MSG_RESULT([no])
772     tst_links_closesocket="no"
773   ])
774   #
775   if test "$tst_links_closesocket" = "yes"; then
776     AC_MSG_CHECKING([if closesocket is prototyped])
777     AC_EGREP_CPP([closesocket],[
778       $curl_includes_winsock2
779       $curl_includes_socket
780     ],[
781       AC_MSG_RESULT([yes])
782       tst_proto_closesocket="yes"
783     ],[
784       AC_MSG_RESULT([no])
785       tst_proto_closesocket="no"
786     ])
787   fi
788   #
789   if test "$tst_proto_closesocket" = "yes"; then
790     AC_MSG_CHECKING([if closesocket is compilable])
791     AC_COMPILE_IFELSE([
792       AC_LANG_PROGRAM([[
793         $curl_includes_winsock2
794         $curl_includes_socket
795       ]],[[
796         if(0 != closesocket(0))
797           return 1;
798       ]])
799     ],[
800       AC_MSG_RESULT([yes])
801       tst_compi_closesocket="yes"
802     ],[
803       AC_MSG_RESULT([no])
804       tst_compi_closesocket="no"
805     ])
806   fi
807   #
808   if test "$tst_compi_closesocket" = "yes"; then
809     AC_MSG_CHECKING([if closesocket usage allowed])
810     if test "x$curl_disallow_closesocket" != "xyes"; then
811       AC_MSG_RESULT([yes])
812       tst_allow_closesocket="yes"
813     else
814       AC_MSG_RESULT([no])
815       tst_allow_closesocket="no"
816     fi
817   fi
818   #
819   AC_MSG_CHECKING([if closesocket might be used])
820   if test "$tst_links_closesocket" = "yes" &&
821      test "$tst_proto_closesocket" = "yes" &&
822      test "$tst_compi_closesocket" = "yes" &&
823      test "$tst_allow_closesocket" = "yes"; then
824     AC_MSG_RESULT([yes])
825     AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET, 1,
826       [Define to 1 if you have the closesocket function.])
827     curl_cv_func_closesocket="yes"
828   else
829     AC_MSG_RESULT([no])
830     curl_cv_func_closesocket="no"
831   fi
832 ])
833
834
835 dnl CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
836 dnl -------------------------------------------------
837 dnl Verify if CloseSocket is available, prototyped, and
838 dnl can be compiled. If all of these are true, and
839 dnl usage has not been previously disallowed with
840 dnl shell variable curl_disallow_closesocket_camel,
841 dnl then HAVE_CLOSESOCKET_CAMEL will be defined.
842
843 AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [
844   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
845   #
846   tst_links_closesocket_camel="unknown"
847   tst_proto_closesocket_camel="unknown"
848   tst_compi_closesocket_camel="unknown"
849   tst_allow_closesocket_camel="unknown"
850   #
851   AC_MSG_CHECKING([if CloseSocket can be linked])
852   AC_LINK_IFELSE([
853     AC_LANG_PROGRAM([[
854       $curl_includes_sys_socket
855     ]],[[
856       if(0 != CloseSocket(0))
857         return 1;
858     ]])
859   ],[
860     AC_MSG_RESULT([yes])
861     tst_links_closesocket_camel="yes"
862   ],[
863     AC_MSG_RESULT([no])
864     tst_links_closesocket_camel="no"
865   ])
866   #
867   if test "$tst_links_closesocket_camel" = "yes"; then
868     AC_MSG_CHECKING([if CloseSocket is prototyped])
869     AC_EGREP_CPP([CloseSocket],[
870       $curl_includes_sys_socket
871     ],[
872       AC_MSG_RESULT([yes])
873       tst_proto_closesocket_camel="yes"
874     ],[
875       AC_MSG_RESULT([no])
876       tst_proto_closesocket_camel="no"
877     ])
878   fi
879   #
880   if test "$tst_proto_closesocket_camel" = "yes"; then
881     AC_MSG_CHECKING([if CloseSocket is compilable])
882     AC_COMPILE_IFELSE([
883       AC_LANG_PROGRAM([[
884         $curl_includes_sys_socket
885       ]],[[
886         if(0 != CloseSocket(0))
887           return 1;
888       ]])
889     ],[
890       AC_MSG_RESULT([yes])
891       tst_compi_closesocket_camel="yes"
892     ],[
893       AC_MSG_RESULT([no])
894       tst_compi_closesocket_camel="no"
895     ])
896   fi
897   #
898   if test "$tst_compi_closesocket_camel" = "yes"; then
899     AC_MSG_CHECKING([if CloseSocket usage allowed])
900     if test "x$curl_disallow_closesocket_camel" != "xyes"; then
901       AC_MSG_RESULT([yes])
902       tst_allow_closesocket_camel="yes"
903     else
904       AC_MSG_RESULT([no])
905       tst_allow_closesocket_camel="no"
906     fi
907   fi
908   #
909   AC_MSG_CHECKING([if CloseSocket might be used])
910   if test "$tst_links_closesocket_camel" = "yes" &&
911      test "$tst_proto_closesocket_camel" = "yes" &&
912      test "$tst_compi_closesocket_camel" = "yes" &&
913      test "$tst_allow_closesocket_camel" = "yes"; then
914     AC_MSG_RESULT([yes])
915     AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET_CAMEL, 1,
916       [Define to 1 if you have the CloseSocket camel case function.])
917     curl_cv_func_closesocket_camel="yes"
918   else
919     AC_MSG_RESULT([no])
920     curl_cv_func_closesocket_camel="no"
921   fi
922 ])
923
924
925 dnl CURL_CHECK_FUNC_CONNECT
926 dnl -------------------------------------------------
927 dnl Verify if connect is available, prototyped, and
928 dnl can be compiled. If all of these are true, and
929 dnl usage has not been previously disallowed with
930 dnl shell variable curl_disallow_connect, then
931 dnl HAVE_CONNECT will be defined.
932
933 AC_DEFUN([CURL_CHECK_FUNC_CONNECT], [
934   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
935   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
936   AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
937   #
938   tst_links_connect="unknown"
939   tst_proto_connect="unknown"
940   tst_compi_connect="unknown"
941   tst_allow_connect="unknown"
942   #
943   AC_MSG_CHECKING([if connect can be linked])
944   AC_LINK_IFELSE([
945     AC_LANG_PROGRAM([[
946       $curl_includes_winsock2
947       $curl_includes_sys_socket
948       $curl_includes_socket
949     ]],[[
950       if(0 != connect(0, 0, 0))
951         return 1;
952     ]])
953   ],[
954     AC_MSG_RESULT([yes])
955     tst_links_connect="yes"
956   ],[
957     AC_MSG_RESULT([no])
958     tst_links_connect="no"
959   ])
960   #
961   if test "$tst_links_connect" = "yes"; then
962     AC_MSG_CHECKING([if connect is prototyped])
963     AC_EGREP_CPP([connect],[
964       $curl_includes_winsock2
965       $curl_includes_sys_socket
966       $curl_includes_socket
967     ],[
968       AC_MSG_RESULT([yes])
969       tst_proto_connect="yes"
970     ],[
971       AC_MSG_RESULT([no])
972       tst_proto_connect="no"
973     ])
974   fi
975   #
976   if test "$tst_proto_connect" = "yes"; then
977     AC_MSG_CHECKING([if connect is compilable])
978     AC_COMPILE_IFELSE([
979       AC_LANG_PROGRAM([[
980         $curl_includes_winsock2
981         $curl_includes_sys_socket
982         $curl_includes_socket
983       ]],[[
984         if(0 != connect(0, 0, 0))
985           return 1;
986       ]])
987     ],[
988       AC_MSG_RESULT([yes])
989       tst_compi_connect="yes"
990     ],[
991       AC_MSG_RESULT([no])
992       tst_compi_connect="no"
993     ])
994   fi
995   #
996   if test "$tst_compi_connect" = "yes"; then
997     AC_MSG_CHECKING([if connect usage allowed])
998     if test "x$curl_disallow_connect" != "xyes"; then
999       AC_MSG_RESULT([yes])
1000       tst_allow_connect="yes"
1001     else
1002       AC_MSG_RESULT([no])
1003       tst_allow_connect="no"
1004     fi
1005   fi
1006   #
1007   AC_MSG_CHECKING([if connect might be used])
1008   if test "$tst_links_connect" = "yes" &&
1009      test "$tst_proto_connect" = "yes" &&
1010      test "$tst_compi_connect" = "yes" &&
1011      test "$tst_allow_connect" = "yes"; then
1012     AC_MSG_RESULT([yes])
1013     AC_DEFINE_UNQUOTED(HAVE_CONNECT, 1,
1014       [Define to 1 if you have the connect function.])
1015     curl_cv_func_connect="yes"
1016   else
1017     AC_MSG_RESULT([no])
1018     curl_cv_func_connect="no"
1019   fi
1020 ])
1021
1022
1023 dnl CURL_CHECK_FUNC_FCNTL
1024 dnl -------------------------------------------------
1025 dnl Verify if fcntl is available, prototyped, and
1026 dnl can be compiled. If all of these are true, and
1027 dnl usage has not been previously disallowed with
1028 dnl shell variable curl_disallow_fcntl, then
1029 dnl HAVE_FCNTL will be defined.
1030
1031 AC_DEFUN([CURL_CHECK_FUNC_FCNTL], [
1032   AC_REQUIRE([CURL_INCLUDES_FCNTL])dnl
1033   #
1034   tst_links_fcntl="unknown"
1035   tst_proto_fcntl="unknown"
1036   tst_compi_fcntl="unknown"
1037   tst_allow_fcntl="unknown"
1038   #
1039   AC_MSG_CHECKING([if fcntl can be linked])
1040   AC_LINK_IFELSE([
1041     AC_LANG_FUNC_LINK_TRY([fcntl])
1042   ],[
1043     AC_MSG_RESULT([yes])
1044     tst_links_fcntl="yes"
1045   ],[
1046     AC_MSG_RESULT([no])
1047     tst_links_fcntl="no"
1048   ])
1049   #
1050   if test "$tst_links_fcntl" = "yes"; then
1051     AC_MSG_CHECKING([if fcntl is prototyped])
1052     AC_EGREP_CPP([fcntl],[
1053       $curl_includes_fcntl
1054     ],[
1055       AC_MSG_RESULT([yes])
1056       tst_proto_fcntl="yes"
1057     ],[
1058       AC_MSG_RESULT([no])
1059       tst_proto_fcntl="no"
1060     ])
1061   fi
1062   #
1063   if test "$tst_proto_fcntl" = "yes"; then
1064     AC_MSG_CHECKING([if fcntl is compilable])
1065     AC_COMPILE_IFELSE([
1066       AC_LANG_PROGRAM([[
1067         $curl_includes_fcntl
1068       ]],[[
1069         if(0 != fcntl(0, 0, 0))
1070           return 1;
1071       ]])
1072     ],[
1073       AC_MSG_RESULT([yes])
1074       tst_compi_fcntl="yes"
1075     ],[
1076       AC_MSG_RESULT([no])
1077       tst_compi_fcntl="no"
1078     ])
1079   fi
1080   #
1081   if test "$tst_compi_fcntl" = "yes"; then
1082     AC_MSG_CHECKING([if fcntl usage allowed])
1083     if test "x$curl_disallow_fcntl" != "xyes"; then
1084       AC_MSG_RESULT([yes])
1085       tst_allow_fcntl="yes"
1086     else
1087       AC_MSG_RESULT([no])
1088       tst_allow_fcntl="no"
1089     fi
1090   fi
1091   #
1092   AC_MSG_CHECKING([if fcntl might be used])
1093   if test "$tst_links_fcntl" = "yes" &&
1094      test "$tst_proto_fcntl" = "yes" &&
1095      test "$tst_compi_fcntl" = "yes" &&
1096      test "$tst_allow_fcntl" = "yes"; then
1097     AC_MSG_RESULT([yes])
1098     AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
1099       [Define to 1 if you have the fcntl function.])
1100     curl_cv_func_fcntl="yes"
1101     CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
1102   else
1103     AC_MSG_RESULT([no])
1104     curl_cv_func_fcntl="no"
1105   fi
1106 ])
1107
1108
1109 dnl CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
1110 dnl -------------------------------------------------
1111 dnl Verify if fcntl with status flag O_NONBLOCK is
1112 dnl available, can be compiled, and seems to work. If
1113 dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
1114 dnl will be defined.
1115
1116 AC_DEFUN([CURL_CHECK_FUNC_FCNTL_O_NONBLOCK], [
1117   #
1118   tst_compi_fcntl_o_nonblock="unknown"
1119   tst_allow_fcntl_o_nonblock="unknown"
1120   #
1121   case $host_os in
1122     sunos4* | aix3* | beos*)
1123       dnl O_NONBLOCK does not work on these platforms
1124       curl_disallow_fcntl_o_nonblock="yes"
1125       ;;
1126   esac
1127   #
1128   if test "$curl_cv_func_fcntl" = "yes"; then
1129     AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
1130     AC_COMPILE_IFELSE([
1131       AC_LANG_PROGRAM([[
1132         $curl_includes_fcntl
1133       ]],[[
1134         int flags = 0;
1135         if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
1136           return 1;
1137       ]])
1138     ],[
1139       AC_MSG_RESULT([yes])
1140       tst_compi_fcntl_o_nonblock="yes"
1141     ],[
1142       AC_MSG_RESULT([no])
1143       tst_compi_fcntl_o_nonblock="no"
1144     ])
1145   fi
1146   #
1147   if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
1148     AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
1149     if test "x$curl_disallow_fcntl_o_nonblock" != "xyes"; then
1150       AC_MSG_RESULT([yes])
1151       tst_allow_fcntl_o_nonblock="yes"
1152     else
1153       AC_MSG_RESULT([no])
1154       tst_allow_fcntl_o_nonblock="no"
1155     fi
1156   fi
1157   #
1158   AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
1159   if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
1160      test "$tst_allow_fcntl_o_nonblock" = "yes"; then
1161     AC_MSG_RESULT([yes])
1162     AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
1163       [Define to 1 if you have a working fcntl O_NONBLOCK function.])
1164     curl_cv_func_fcntl_o_nonblock="yes"
1165   else
1166     AC_MSG_RESULT([no])
1167     curl_cv_func_fcntl_o_nonblock="no"
1168   fi
1169 ])
1170
1171
1172 dnl CURL_CHECK_FUNC_FDOPEN
1173 dnl -------------------------------------------------
1174 dnl Verify if fdopen is available, prototyped, and
1175 dnl can be compiled. If all of these are true, and
1176 dnl usage has not been previously disallowed with
1177 dnl shell variable curl_disallow_fdopen, then
1178 dnl HAVE_FDOPEN will be defined.
1179
1180 AC_DEFUN([CURL_CHECK_FUNC_FDOPEN], [
1181   AC_REQUIRE([CURL_INCLUDES_STDIO])dnl
1182   #
1183   tst_links_fdopen="unknown"
1184   tst_proto_fdopen="unknown"
1185   tst_compi_fdopen="unknown"
1186   tst_allow_fdopen="unknown"
1187   #
1188   AC_MSG_CHECKING([if fdopen can be linked])
1189   AC_LINK_IFELSE([
1190     AC_LANG_FUNC_LINK_TRY([fdopen])
1191   ],[
1192     AC_MSG_RESULT([yes])
1193     tst_links_fdopen="yes"
1194   ],[
1195     AC_MSG_RESULT([no])
1196     tst_links_fdopen="no"
1197   ])
1198   #
1199   if test "$tst_links_fdopen" = "yes"; then
1200     AC_MSG_CHECKING([if fdopen is prototyped])
1201     AC_EGREP_CPP([fdopen],[
1202       $curl_includes_stdio
1203     ],[
1204       AC_MSG_RESULT([yes])
1205       tst_proto_fdopen="yes"
1206     ],[
1207       AC_MSG_RESULT([no])
1208       tst_proto_fdopen="no"
1209     ])
1210   fi
1211   #
1212   if test "$tst_proto_fdopen" = "yes"; then
1213     AC_MSG_CHECKING([if fdopen is compilable])
1214     AC_COMPILE_IFELSE([
1215       AC_LANG_PROGRAM([[
1216         $curl_includes_stdio
1217       ]],[[
1218         if(0 != fdopen(0, 0))
1219           return 1;
1220       ]])
1221     ],[
1222       AC_MSG_RESULT([yes])
1223       tst_compi_fdopen="yes"
1224     ],[
1225       AC_MSG_RESULT([no])
1226       tst_compi_fdopen="no"
1227     ])
1228   fi
1229   #
1230   if test "$tst_compi_fdopen" = "yes"; then
1231     AC_MSG_CHECKING([if fdopen usage allowed])
1232     if test "x$curl_disallow_fdopen" != "xyes"; then
1233       AC_MSG_RESULT([yes])
1234       tst_allow_fdopen="yes"
1235     else
1236       AC_MSG_RESULT([no])
1237       tst_allow_fdopen="no"
1238     fi
1239   fi
1240   #
1241   AC_MSG_CHECKING([if fdopen might be used])
1242   if test "$tst_links_fdopen" = "yes" &&
1243      test "$tst_proto_fdopen" = "yes" &&
1244      test "$tst_compi_fdopen" = "yes" &&
1245      test "$tst_allow_fdopen" = "yes"; then
1246     AC_MSG_RESULT([yes])
1247     AC_DEFINE_UNQUOTED(HAVE_FDOPEN, 1,
1248       [Define to 1 if you have the fdopen function.])
1249     curl_cv_func_fdopen="yes"
1250   else
1251     AC_MSG_RESULT([no])
1252     curl_cv_func_fdopen="no"
1253   fi
1254 ])
1255
1256
1257 dnl CURL_CHECK_FUNC_FGETXATTR
1258 dnl -------------------------------------------------
1259 dnl Verify if fgetxattr is available, prototyped, and
1260 dnl can be compiled. If all of these are true, and
1261 dnl usage has not been previously disallowed with
1262 dnl shell variable curl_disallow_fgetxattr, then
1263 dnl HAVE_FGETXATTR will be defined.
1264
1265 AC_DEFUN([CURL_CHECK_FUNC_FGETXATTR], [
1266   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1267   #
1268   tst_links_fgetxattr="unknown"
1269   tst_proto_fgetxattr="unknown"
1270   tst_compi_fgetxattr="unknown"
1271   tst_allow_fgetxattr="unknown"
1272   tst_nargs_fgetxattr="unknown"
1273   #
1274   AC_MSG_CHECKING([if fgetxattr can be linked])
1275   AC_LINK_IFELSE([
1276     AC_LANG_FUNC_LINK_TRY([fgetxattr])
1277   ],[
1278     AC_MSG_RESULT([yes])
1279     tst_links_fgetxattr="yes"
1280   ],[
1281     AC_MSG_RESULT([no])
1282     tst_links_fgetxattr="no"
1283   ])
1284   #
1285   if test "$tst_links_fgetxattr" = "yes"; then
1286     AC_MSG_CHECKING([if fgetxattr is prototyped])
1287     AC_EGREP_CPP([fgetxattr],[
1288       $curl_includes_sys_xattr
1289     ],[
1290       AC_MSG_RESULT([yes])
1291       tst_proto_fgetxattr="yes"
1292     ],[
1293       AC_MSG_RESULT([no])
1294       tst_proto_fgetxattr="no"
1295     ])
1296   fi
1297   #
1298   if test "$tst_proto_fgetxattr" = "yes"; then
1299     if test "$tst_nargs_fgetxattr" = "unknown"; then
1300       AC_MSG_CHECKING([if fgetxattr takes 4 args.])
1301       AC_COMPILE_IFELSE([
1302         AC_LANG_PROGRAM([[
1303           $curl_includes_sys_xattr
1304         ]],[[
1305           if(0 != fgetxattr(0, 0, 0, 0))
1306             return 1;
1307         ]])
1308       ],[
1309         AC_MSG_RESULT([yes])
1310         tst_compi_fgetxattr="yes"
1311         tst_nargs_fgetxattr="4"
1312       ],[
1313         AC_MSG_RESULT([no])
1314         tst_compi_fgetxattr="no"
1315       ])
1316     fi
1317     if test "$tst_nargs_fgetxattr" = "unknown"; then
1318       AC_MSG_CHECKING([if fgetxattr takes 6 args.])
1319       AC_COMPILE_IFELSE([
1320         AC_LANG_PROGRAM([[
1321           $curl_includes_sys_xattr
1322         ]],[[
1323           if(0 != fgetxattr(0, 0, 0, 0, 0, 0))
1324             return 1;
1325         ]])
1326       ],[
1327         AC_MSG_RESULT([yes])
1328         tst_compi_fgetxattr="yes"
1329         tst_nargs_fgetxattr="6"
1330       ],[
1331         AC_MSG_RESULT([no])
1332         tst_compi_fgetxattr="no"
1333       ])
1334     fi
1335     AC_MSG_CHECKING([if fgetxattr is compilable])
1336     if test "$tst_compi_fgetxattr" = "yes"; then
1337       AC_MSG_RESULT([yes])
1338     else
1339       AC_MSG_RESULT([no])
1340     fi
1341   fi
1342   #
1343   if test "$tst_compi_fgetxattr" = "yes"; then
1344     AC_MSG_CHECKING([if fgetxattr usage allowed])
1345     if test "x$curl_disallow_fgetxattr" != "xyes"; then
1346       AC_MSG_RESULT([yes])
1347       tst_allow_fgetxattr="yes"
1348     else
1349       AC_MSG_RESULT([no])
1350       tst_allow_fgetxattr="no"
1351     fi
1352   fi
1353   #
1354   AC_MSG_CHECKING([if fgetxattr might be used])
1355   if test "$tst_links_fgetxattr" = "yes" &&
1356      test "$tst_proto_fgetxattr" = "yes" &&
1357      test "$tst_compi_fgetxattr" = "yes" &&
1358      test "$tst_allow_fgetxattr" = "yes"; then
1359     AC_MSG_RESULT([yes])
1360     AC_DEFINE_UNQUOTED(HAVE_FGETXATTR, 1,
1361       [Define to 1 if you have the fgetxattr function.])
1362     dnl AC_DEFINE_UNQUOTED(FGETXATTR_ARGS, $tst_nargs_fgetxattr,
1363     dnl   [Specifies the number of arguments to fgetxattr])
1364     #
1365     if test "$tst_nargs_fgetxattr" -eq "4"; then
1366       AC_DEFINE(HAVE_FGETXATTR_4, 1, [fgetxattr() takes 4 args])
1367     elif test "$tst_nargs_fgetxattr" -eq "6"; then
1368       AC_DEFINE(HAVE_FGETXATTR_6, 1, [fgetxattr() takes 6 args])
1369     fi
1370     #
1371     curl_cv_func_fgetxattr="yes"
1372   else
1373     AC_MSG_RESULT([no])
1374     curl_cv_func_fgetxattr="no"
1375   fi
1376 ])
1377
1378
1379 dnl CURL_CHECK_FUNC_FLISTXATTR
1380 dnl -------------------------------------------------
1381 dnl Verify if flistxattr is available, prototyped, and
1382 dnl can be compiled. If all of these are true, and
1383 dnl usage has not been previously disallowed with
1384 dnl shell variable curl_disallow_flistxattr, then
1385 dnl HAVE_FLISTXATTR will be defined.
1386
1387 AC_DEFUN([CURL_CHECK_FUNC_FLISTXATTR], [
1388   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1389   #
1390   tst_links_flistxattr="unknown"
1391   tst_proto_flistxattr="unknown"
1392   tst_compi_flistxattr="unknown"
1393   tst_allow_flistxattr="unknown"
1394   tst_nargs_flistxattr="unknown"
1395   #
1396   AC_MSG_CHECKING([if flistxattr can be linked])
1397   AC_LINK_IFELSE([
1398     AC_LANG_FUNC_LINK_TRY([flistxattr])
1399   ],[
1400     AC_MSG_RESULT([yes])
1401     tst_links_flistxattr="yes"
1402   ],[
1403     AC_MSG_RESULT([no])
1404     tst_links_flistxattr="no"
1405   ])
1406   #
1407   if test "$tst_links_flistxattr" = "yes"; then
1408     AC_MSG_CHECKING([if flistxattr is prototyped])
1409     AC_EGREP_CPP([flistxattr],[
1410       $curl_includes_sys_xattr
1411     ],[
1412       AC_MSG_RESULT([yes])
1413       tst_proto_flistxattr="yes"
1414     ],[
1415       AC_MSG_RESULT([no])
1416       tst_proto_flistxattr="no"
1417     ])
1418   fi
1419   #
1420   if test "$tst_proto_flistxattr" = "yes"; then
1421     if test "$tst_nargs_flistxattr" = "unknown"; then
1422       AC_MSG_CHECKING([if flistxattr takes 3 args.])
1423       AC_COMPILE_IFELSE([
1424         AC_LANG_PROGRAM([[
1425           $curl_includes_sys_xattr
1426         ]],[[
1427           if(0 != flistxattr(0, 0, 0))
1428             return 1;
1429         ]])
1430       ],[
1431         AC_MSG_RESULT([yes])
1432         tst_compi_flistxattr="yes"
1433         tst_nargs_flistxattr="3"
1434       ],[
1435         AC_MSG_RESULT([no])
1436         tst_compi_flistxattr="no"
1437       ])
1438     fi
1439     if test "$tst_nargs_flistxattr" = "unknown"; then
1440       AC_MSG_CHECKING([if flistxattr takes 4 args.])
1441       AC_COMPILE_IFELSE([
1442         AC_LANG_PROGRAM([[
1443           $curl_includes_sys_xattr
1444         ]],[[
1445           if(0 != flistxattr(0, 0, 0, 0))
1446             return 1;
1447         ]])
1448       ],[
1449         AC_MSG_RESULT([yes])
1450         tst_compi_flistxattr="yes"
1451         tst_nargs_flistxattr="4"
1452       ],[
1453         AC_MSG_RESULT([no])
1454         tst_compi_flistxattr="no"
1455       ])
1456     fi
1457     AC_MSG_CHECKING([if flistxattr is compilable])
1458     if test "$tst_compi_flistxattr" = "yes"; then
1459       AC_MSG_RESULT([yes])
1460     else
1461       AC_MSG_RESULT([no])
1462     fi
1463   fi
1464   #
1465   if test "$tst_compi_flistxattr" = "yes"; then
1466     AC_MSG_CHECKING([if flistxattr usage allowed])
1467     if test "x$curl_disallow_flistxattr" != "xyes"; then
1468       AC_MSG_RESULT([yes])
1469       tst_allow_flistxattr="yes"
1470     else
1471       AC_MSG_RESULT([no])
1472       tst_allow_flistxattr="no"
1473     fi
1474   fi
1475   #
1476   AC_MSG_CHECKING([if flistxattr might be used])
1477   if test "$tst_links_flistxattr" = "yes" &&
1478      test "$tst_proto_flistxattr" = "yes" &&
1479      test "$tst_compi_flistxattr" = "yes" &&
1480      test "$tst_allow_flistxattr" = "yes"; then
1481     AC_MSG_RESULT([yes])
1482     AC_DEFINE_UNQUOTED(HAVE_FLISTXATTR, 1,
1483       [Define to 1 if you have the flistxattr function.])
1484     dnl AC_DEFINE_UNQUOTED(FLISTXATTR_ARGS, $tst_nargs_flistxattr,
1485     dnl   [Specifies the number of arguments to flistxattr])
1486     #
1487     if test "$tst_nargs_flistxattr" -eq "3"; then
1488       AC_DEFINE(HAVE_FLISTXATTR_3, 1, [flistxattr() takes 3 args])
1489     elif test "$tst_nargs_flistxattr" -eq "4"; then
1490       AC_DEFINE(HAVE_FLISTXATTR_4, 1, [flistxattr() takes 4 args])
1491     fi
1492     #
1493     curl_cv_func_flistxattr="yes"
1494   else
1495     AC_MSG_RESULT([no])
1496     curl_cv_func_flistxattr="no"
1497   fi
1498 ])
1499
1500
1501 dnl CURL_CHECK_FUNC_FREEADDRINFO
1502 dnl -------------------------------------------------
1503 dnl Verify if freeaddrinfo is available, prototyped,
1504 dnl and can be compiled. If all of these are true,
1505 dnl and usage has not been previously disallowed with
1506 dnl shell variable curl_disallow_freeaddrinfo, then
1507 dnl HAVE_FREEADDRINFO will be defined.
1508
1509 AC_DEFUN([CURL_CHECK_FUNC_FREEADDRINFO], [
1510   AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
1511   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
1512   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1513   #
1514   tst_links_freeaddrinfo="unknown"
1515   tst_proto_freeaddrinfo="unknown"
1516   tst_compi_freeaddrinfo="unknown"
1517   tst_allow_freeaddrinfo="unknown"
1518   #
1519   AC_MSG_CHECKING([if freeaddrinfo can be linked])
1520   AC_LINK_IFELSE([
1521     AC_LANG_PROGRAM([[
1522       $curl_includes_ws2tcpip
1523       $curl_includes_sys_socket
1524       $curl_includes_netdb
1525     ]],[[
1526       freeaddrinfo(0);
1527     ]])
1528   ],[
1529     AC_MSG_RESULT([yes])
1530     tst_links_freeaddrinfo="yes"
1531   ],[
1532     AC_MSG_RESULT([no])
1533     tst_links_freeaddrinfo="no"
1534   ])
1535   #
1536   if test "$tst_links_freeaddrinfo" = "yes"; then
1537     AC_MSG_CHECKING([if freeaddrinfo is prototyped])
1538     AC_EGREP_CPP([freeaddrinfo],[
1539       $curl_includes_ws2tcpip
1540       $curl_includes_sys_socket
1541       $curl_includes_netdb
1542     ],[
1543       AC_MSG_RESULT([yes])
1544       tst_proto_freeaddrinfo="yes"
1545     ],[
1546       AC_MSG_RESULT([no])
1547       tst_proto_freeaddrinfo="no"
1548     ])
1549   fi
1550   #
1551   if test "$tst_proto_freeaddrinfo" = "yes"; then
1552     AC_MSG_CHECKING([if freeaddrinfo is compilable])
1553     AC_COMPILE_IFELSE([
1554       AC_LANG_PROGRAM([[
1555         $curl_includes_ws2tcpip
1556         $curl_includes_sys_socket
1557         $curl_includes_netdb
1558       ]],[[
1559         freeaddrinfo(0);
1560       ]])
1561     ],[
1562       AC_MSG_RESULT([yes])
1563       tst_compi_freeaddrinfo="yes"
1564     ],[
1565       AC_MSG_RESULT([no])
1566       tst_compi_freeaddrinfo="no"
1567     ])
1568   fi
1569   #
1570   if test "$tst_compi_freeaddrinfo" = "yes"; then
1571     AC_MSG_CHECKING([if freeaddrinfo usage allowed])
1572     if test "x$curl_disallow_freeaddrinfo" != "xyes"; then
1573       AC_MSG_RESULT([yes])
1574       tst_allow_freeaddrinfo="yes"
1575     else
1576       AC_MSG_RESULT([no])
1577       tst_allow_freeaddrinfo="no"
1578     fi
1579   fi
1580   #
1581   AC_MSG_CHECKING([if freeaddrinfo might be used])
1582   if test "$tst_links_freeaddrinfo" = "yes" &&
1583      test "$tst_proto_freeaddrinfo" = "yes" &&
1584      test "$tst_compi_freeaddrinfo" = "yes" &&
1585      test "$tst_allow_freeaddrinfo" = "yes"; then
1586     AC_MSG_RESULT([yes])
1587     AC_DEFINE_UNQUOTED(HAVE_FREEADDRINFO, 1,
1588       [Define to 1 if you have the freeaddrinfo function.])
1589     curl_cv_func_freeaddrinfo="yes"
1590   else
1591     AC_MSG_RESULT([no])
1592     curl_cv_func_freeaddrinfo="no"
1593   fi
1594 ])
1595
1596
1597 dnl CURL_CHECK_FUNC_FREEIFADDRS
1598 dnl -------------------------------------------------
1599 dnl Verify if freeifaddrs is available, prototyped, and
1600 dnl can be compiled. If all of these are true, and
1601 dnl usage has not been previously disallowed with
1602 dnl shell variable curl_disallow_freeifaddrs, then
1603 dnl HAVE_FREEIFADDRS will be defined.
1604
1605 AC_DEFUN([CURL_CHECK_FUNC_FREEIFADDRS], [
1606   AC_REQUIRE([CURL_INCLUDES_IFADDRS])dnl
1607   #
1608   tst_links_freeifaddrs="unknown"
1609   tst_proto_freeifaddrs="unknown"
1610   tst_compi_freeifaddrs="unknown"
1611   tst_allow_freeifaddrs="unknown"
1612   #
1613   AC_MSG_CHECKING([if freeifaddrs can be linked])
1614   AC_LINK_IFELSE([
1615     AC_LANG_FUNC_LINK_TRY([freeifaddrs])
1616   ],[
1617     AC_MSG_RESULT([yes])
1618     tst_links_freeifaddrs="yes"
1619   ],[
1620     AC_MSG_RESULT([no])
1621     tst_links_freeifaddrs="no"
1622   ])
1623   #
1624   if test "$tst_links_freeifaddrs" = "yes"; then
1625     AC_MSG_CHECKING([if freeifaddrs is prototyped])
1626     AC_EGREP_CPP([freeifaddrs],[
1627       $curl_includes_ifaddrs
1628     ],[
1629       AC_MSG_RESULT([yes])
1630       tst_proto_freeifaddrs="yes"
1631     ],[
1632       AC_MSG_RESULT([no])
1633       tst_proto_freeifaddrs="no"
1634     ])
1635   fi
1636   #
1637   if test "$tst_proto_freeifaddrs" = "yes"; then
1638     AC_MSG_CHECKING([if freeifaddrs is compilable])
1639     AC_COMPILE_IFELSE([
1640       AC_LANG_PROGRAM([[
1641         $curl_includes_ifaddrs
1642       ]],[[
1643         freeifaddrs(0);
1644       ]])
1645     ],[
1646       AC_MSG_RESULT([yes])
1647       tst_compi_freeifaddrs="yes"
1648     ],[
1649       AC_MSG_RESULT([no])
1650       tst_compi_freeifaddrs="no"
1651     ])
1652   fi
1653   #
1654   if test "$tst_compi_freeifaddrs" = "yes"; then
1655     AC_MSG_CHECKING([if freeifaddrs usage allowed])
1656     if test "x$curl_disallow_freeifaddrs" != "xyes"; then
1657       AC_MSG_RESULT([yes])
1658       tst_allow_freeifaddrs="yes"
1659     else
1660       AC_MSG_RESULT([no])
1661       tst_allow_freeifaddrs="no"
1662     fi
1663   fi
1664   #
1665   AC_MSG_CHECKING([if freeifaddrs might be used])
1666   if test "$tst_links_freeifaddrs" = "yes" &&
1667      test "$tst_proto_freeifaddrs" = "yes" &&
1668      test "$tst_compi_freeifaddrs" = "yes" &&
1669      test "$tst_allow_freeifaddrs" = "yes"; then
1670     AC_MSG_RESULT([yes])
1671     AC_DEFINE_UNQUOTED(HAVE_FREEIFADDRS, 1,
1672       [Define to 1 if you have the freeifaddrs function.])
1673     curl_cv_func_freeifaddrs="yes"
1674   else
1675     AC_MSG_RESULT([no])
1676     curl_cv_func_freeifaddrs="no"
1677   fi
1678 ])
1679
1680
1681 dnl CURL_CHECK_FUNC_FREMOVEXATTR
1682 dnl -------------------------------------------------
1683 dnl Verify if fremovexattr is available, prototyped, and
1684 dnl can be compiled. If all of these are true, and
1685 dnl usage has not been previously disallowed with
1686 dnl shell variable curl_disallow_fremovexattr, then
1687 dnl HAVE_FREMOVEXATTR will be defined.
1688
1689 AC_DEFUN([CURL_CHECK_FUNC_FREMOVEXATTR], [
1690   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1691   #
1692   tst_links_fremovexattr="unknown"
1693   tst_proto_fremovexattr="unknown"
1694   tst_compi_fremovexattr="unknown"
1695   tst_allow_fremovexattr="unknown"
1696   tst_nargs_fremovexattr="unknown"
1697   #
1698   AC_MSG_CHECKING([if fremovexattr can be linked])
1699   AC_LINK_IFELSE([
1700     AC_LANG_FUNC_LINK_TRY([fremovexattr])
1701   ],[
1702     AC_MSG_RESULT([yes])
1703     tst_links_fremovexattr="yes"
1704   ],[
1705     AC_MSG_RESULT([no])
1706     tst_links_fremovexattr="no"
1707   ])
1708   #
1709   if test "$tst_links_fremovexattr" = "yes"; then
1710     AC_MSG_CHECKING([if fremovexattr is prototyped])
1711     AC_EGREP_CPP([fremovexattr],[
1712       $curl_includes_sys_xattr
1713     ],[
1714       AC_MSG_RESULT([yes])
1715       tst_proto_fremovexattr="yes"
1716     ],[
1717       AC_MSG_RESULT([no])
1718       tst_proto_fremovexattr="no"
1719     ])
1720   fi
1721   #
1722   if test "$tst_proto_fremovexattr" = "yes"; then
1723     if test "$tst_nargs_fremovexattr" = "unknown"; then
1724       AC_MSG_CHECKING([if fremovexattr takes 2 args.])
1725       AC_COMPILE_IFELSE([
1726         AC_LANG_PROGRAM([[
1727           $curl_includes_sys_xattr
1728         ]],[[
1729           if(0 != fremovexattr(0, 0))
1730             return 1;
1731         ]])
1732       ],[
1733         AC_MSG_RESULT([yes])
1734         tst_compi_fremovexattr="yes"
1735         tst_nargs_fremovexattr="2"
1736       ],[
1737         AC_MSG_RESULT([no])
1738         tst_compi_fremovexattr="no"
1739       ])
1740     fi
1741     if test "$tst_nargs_fremovexattr" = "unknown"; then
1742       AC_MSG_CHECKING([if fremovexattr takes 3 args.])
1743       AC_COMPILE_IFELSE([
1744         AC_LANG_PROGRAM([[
1745           $curl_includes_sys_xattr
1746         ]],[[
1747           if(0 != fremovexattr(0, 0, 0))
1748             return 1;
1749         ]])
1750       ],[
1751         AC_MSG_RESULT([yes])
1752         tst_compi_fremovexattr="yes"
1753         tst_nargs_fremovexattr="3"
1754       ],[
1755         AC_MSG_RESULT([no])
1756         tst_compi_fremovexattr="no"
1757       ])
1758     fi
1759     AC_MSG_CHECKING([if fremovexattr is compilable])
1760     if test "$tst_compi_fremovexattr" = "yes"; then
1761       AC_MSG_RESULT([yes])
1762     else
1763       AC_MSG_RESULT([no])
1764     fi
1765   fi
1766   #
1767   if test "$tst_compi_fremovexattr" = "yes"; then
1768     AC_MSG_CHECKING([if fremovexattr usage allowed])
1769     if test "x$curl_disallow_fremovexattr" != "xyes"; then
1770       AC_MSG_RESULT([yes])
1771       tst_allow_fremovexattr="yes"
1772     else
1773       AC_MSG_RESULT([no])
1774       tst_allow_fremovexattr="no"
1775     fi
1776   fi
1777   #
1778   AC_MSG_CHECKING([if fremovexattr might be used])
1779   if test "$tst_links_fremovexattr" = "yes" &&
1780      test "$tst_proto_fremovexattr" = "yes" &&
1781      test "$tst_compi_fremovexattr" = "yes" &&
1782      test "$tst_allow_fremovexattr" = "yes"; then
1783     AC_MSG_RESULT([yes])
1784     AC_DEFINE_UNQUOTED(HAVE_FREMOVEXATTR, 1,
1785       [Define to 1 if you have the fremovexattr function.])
1786     dnl AC_DEFINE_UNQUOTED(FREMOVEXATTR_ARGS, $tst_nargs_fremovexattr,
1787     dnl   [Specifies the number of arguments to fremovexattr])
1788     #
1789     if test "$tst_nargs_fremovexattr" -eq "2"; then
1790       AC_DEFINE(HAVE_FREMOVEXATTR_2, 1, [fremovexattr() takes 2 args])
1791     elif test "$tst_nargs_fremovexattr" -eq "3"; then
1792       AC_DEFINE(HAVE_FREMOVEXATTR_3, 1, [fremovexattr() takes 3 args])
1793     fi
1794     #
1795     curl_cv_func_fremovexattr="yes"
1796   else
1797     AC_MSG_RESULT([no])
1798     curl_cv_func_fremovexattr="no"
1799   fi
1800 ])
1801
1802
1803 dnl CURL_CHECK_FUNC_FSETXATTR
1804 dnl -------------------------------------------------
1805 dnl Verify if fsetxattr is available, prototyped, and
1806 dnl can be compiled. If all of these are true, and
1807 dnl usage has not been previously disallowed with
1808 dnl shell variable curl_disallow_fsetxattr, then
1809 dnl HAVE_FSETXATTR will be defined.
1810
1811 AC_DEFUN([CURL_CHECK_FUNC_FSETXATTR], [
1812   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1813   #
1814   tst_links_fsetxattr="unknown"
1815   tst_proto_fsetxattr="unknown"
1816   tst_compi_fsetxattr="unknown"
1817   tst_allow_fsetxattr="unknown"
1818   tst_nargs_fsetxattr="unknown"
1819   #
1820   AC_MSG_CHECKING([if fsetxattr can be linked])
1821   AC_LINK_IFELSE([
1822     AC_LANG_FUNC_LINK_TRY([fsetxattr])
1823   ],[
1824     AC_MSG_RESULT([yes])
1825     tst_links_fsetxattr="yes"
1826   ],[
1827     AC_MSG_RESULT([no])
1828     tst_links_fsetxattr="no"
1829   ])
1830   #
1831   if test "$tst_links_fsetxattr" = "yes"; then
1832     AC_MSG_CHECKING([if fsetxattr is prototyped])
1833     AC_EGREP_CPP([fsetxattr],[
1834       $curl_includes_sys_xattr
1835     ],[
1836       AC_MSG_RESULT([yes])
1837       tst_proto_fsetxattr="yes"
1838     ],[
1839       AC_MSG_RESULT([no])
1840       tst_proto_fsetxattr="no"
1841     ])
1842   fi
1843   #
1844   if test "$tst_proto_fsetxattr" = "yes"; then
1845     if test "$tst_nargs_fsetxattr" = "unknown"; then
1846       AC_MSG_CHECKING([if fsetxattr takes 5 args.])
1847       AC_COMPILE_IFELSE([
1848         AC_LANG_PROGRAM([[
1849           $curl_includes_sys_xattr
1850         ]],[[
1851           if(0 != fsetxattr(0, 0, 0, 0, 0))
1852             return 1;
1853         ]])
1854       ],[
1855         AC_MSG_RESULT([yes])
1856         tst_compi_fsetxattr="yes"
1857         tst_nargs_fsetxattr="5"
1858       ],[
1859         AC_MSG_RESULT([no])
1860         tst_compi_fsetxattr="no"
1861       ])
1862     fi
1863     if test "$tst_nargs_fsetxattr" = "unknown"; then
1864       AC_MSG_CHECKING([if fsetxattr takes 6 args.])
1865       AC_COMPILE_IFELSE([
1866         AC_LANG_PROGRAM([[
1867           $curl_includes_sys_xattr
1868         ]],[[
1869           if(0 != fsetxattr(0, 0, 0, 0, 0, 0))
1870             return 1;
1871         ]])
1872       ],[
1873         AC_MSG_RESULT([yes])
1874         tst_compi_fsetxattr="yes"
1875         tst_nargs_fsetxattr="6"
1876       ],[
1877         AC_MSG_RESULT([no])
1878         tst_compi_fsetxattr="no"
1879       ])
1880     fi
1881     AC_MSG_CHECKING([if fsetxattr is compilable])
1882     if test "$tst_compi_fsetxattr" = "yes"; then
1883       AC_MSG_RESULT([yes])
1884     else
1885       AC_MSG_RESULT([no])
1886     fi
1887   fi
1888   #
1889   if test "$tst_compi_fsetxattr" = "yes"; then
1890     AC_MSG_CHECKING([if fsetxattr usage allowed])
1891     if test "x$curl_disallow_fsetxattr" != "xyes"; then
1892       AC_MSG_RESULT([yes])
1893       tst_allow_fsetxattr="yes"
1894     else
1895       AC_MSG_RESULT([no])
1896       tst_allow_fsetxattr="no"
1897     fi
1898   fi
1899   #
1900   AC_MSG_CHECKING([if fsetxattr might be used])
1901   if test "$tst_links_fsetxattr" = "yes" &&
1902      test "$tst_proto_fsetxattr" = "yes" &&
1903      test "$tst_compi_fsetxattr" = "yes" &&
1904      test "$tst_allow_fsetxattr" = "yes"; then
1905     AC_MSG_RESULT([yes])
1906     AC_DEFINE_UNQUOTED(HAVE_FSETXATTR, 1,
1907       [Define to 1 if you have the fsetxattr function.])
1908     dnl AC_DEFINE_UNQUOTED(FSETXATTR_ARGS, $tst_nargs_fsetxattr,
1909     dnl   [Specifies the number of arguments to fsetxattr])
1910     #
1911     if test "$tst_nargs_fsetxattr" -eq "5"; then
1912       AC_DEFINE(HAVE_FSETXATTR_5, 1, [fsetxattr() takes 5 args])
1913     elif test "$tst_nargs_fsetxattr" -eq "6"; then
1914       AC_DEFINE(HAVE_FSETXATTR_6, 1, [fsetxattr() takes 6 args])
1915     fi
1916     #
1917     curl_cv_func_fsetxattr="yes"
1918   else
1919     AC_MSG_RESULT([no])
1920     curl_cv_func_fsetxattr="no"
1921   fi
1922 ])
1923
1924
1925 dnl CURL_CHECK_FUNC_FTRUNCATE
1926 dnl -------------------------------------------------
1927 dnl Verify if ftruncate is available, prototyped, and
1928 dnl can be compiled. If all of these are true, and
1929 dnl usage has not been previously disallowed with
1930 dnl shell variable curl_disallow_ftruncate, then
1931 dnl HAVE_FTRUNCATE will be defined.
1932
1933 AC_DEFUN([CURL_CHECK_FUNC_FTRUNCATE], [
1934   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
1935   #
1936   tst_links_ftruncate="unknown"
1937   tst_proto_ftruncate="unknown"
1938   tst_compi_ftruncate="unknown"
1939   tst_allow_ftruncate="unknown"
1940   #
1941   AC_MSG_CHECKING([if ftruncate can be linked])
1942   AC_LINK_IFELSE([
1943     AC_LANG_FUNC_LINK_TRY([ftruncate])
1944   ],[
1945     AC_MSG_RESULT([yes])
1946     tst_links_ftruncate="yes"
1947   ],[
1948     AC_MSG_RESULT([no])
1949     tst_links_ftruncate="no"
1950   ])
1951   #
1952   if test "$tst_links_ftruncate" = "yes"; then
1953     AC_MSG_CHECKING([if ftruncate is prototyped])
1954     AC_EGREP_CPP([ftruncate],[
1955       $curl_includes_unistd
1956     ],[
1957       AC_MSG_RESULT([yes])
1958       tst_proto_ftruncate="yes"
1959     ],[
1960       AC_MSG_RESULT([no])
1961       tst_proto_ftruncate="no"
1962     ])
1963   fi
1964   #
1965   if test "$tst_proto_ftruncate" = "yes"; then
1966     AC_MSG_CHECKING([if ftruncate is compilable])
1967     AC_COMPILE_IFELSE([
1968       AC_LANG_PROGRAM([[
1969         $curl_includes_unistd
1970       ]],[[
1971         if(0 != ftruncate(0, 0))
1972           return 1;
1973       ]])
1974     ],[
1975       AC_MSG_RESULT([yes])
1976       tst_compi_ftruncate="yes"
1977     ],[
1978       AC_MSG_RESULT([no])
1979       tst_compi_ftruncate="no"
1980     ])
1981   fi
1982   #
1983   if test "$tst_compi_ftruncate" = "yes"; then
1984     AC_MSG_CHECKING([if ftruncate usage allowed])
1985     if test "x$curl_disallow_ftruncate" != "xyes"; then
1986       AC_MSG_RESULT([yes])
1987       tst_allow_ftruncate="yes"
1988     else
1989       AC_MSG_RESULT([no])
1990       tst_allow_ftruncate="no"
1991     fi
1992   fi
1993   #
1994   AC_MSG_CHECKING([if ftruncate might be used])
1995   if test "$tst_links_ftruncate" = "yes" &&
1996      test "$tst_proto_ftruncate" = "yes" &&
1997      test "$tst_compi_ftruncate" = "yes" &&
1998      test "$tst_allow_ftruncate" = "yes"; then
1999     AC_MSG_RESULT([yes])
2000     AC_DEFINE_UNQUOTED(HAVE_FTRUNCATE, 1,
2001       [Define to 1 if you have the ftruncate function.])
2002     curl_cv_func_ftruncate="yes"
2003   else
2004     AC_MSG_RESULT([no])
2005     curl_cv_func_ftruncate="no"
2006   fi
2007 ])
2008
2009
2010 dnl CURL_CHECK_FUNC_GETADDRINFO
2011 dnl -------------------------------------------------
2012 dnl Verify if getaddrinfo is available, prototyped, can
2013 dnl be compiled and seems to work. If all of these are
2014 dnl true, and usage has not been previously disallowed
2015 dnl with shell variable curl_disallow_getaddrinfo, then
2016 dnl HAVE_GETADDRINFO will be defined. Additionally when
2017 dnl HAVE_GETADDRINFO gets defined this will also attempt
2018 dnl to find out if getaddrinfo happens to be threadsafe,
2019 dnl defining HAVE_GETADDRINFO_THREADSAFE when true.
2020
2021 AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
2022   AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
2023   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2024   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
2025   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
2026   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2027   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
2028   #
2029   tst_links_getaddrinfo="unknown"
2030   tst_proto_getaddrinfo="unknown"
2031   tst_compi_getaddrinfo="unknown"
2032   tst_works_getaddrinfo="unknown"
2033   tst_allow_getaddrinfo="unknown"
2034   tst_tsafe_getaddrinfo="unknown"
2035   #
2036   AC_MSG_CHECKING([if getaddrinfo can be linked])
2037   AC_LINK_IFELSE([
2038     AC_LANG_PROGRAM([[
2039       $curl_includes_ws2tcpip
2040       $curl_includes_sys_socket
2041       $curl_includes_netdb
2042     ]],[[
2043       if(0 != getaddrinfo(0, 0, 0, 0))
2044         return 1;
2045     ]])
2046   ],[
2047     AC_MSG_RESULT([yes])
2048     tst_links_getaddrinfo="yes"
2049   ],[
2050     AC_MSG_RESULT([no])
2051     tst_links_getaddrinfo="no"
2052   ])
2053   #
2054   if test "$tst_links_getaddrinfo" = "yes"; then
2055     AC_MSG_CHECKING([if getaddrinfo is prototyped])
2056     AC_EGREP_CPP([getaddrinfo],[
2057       $curl_includes_ws2tcpip
2058       $curl_includes_sys_socket
2059       $curl_includes_netdb
2060     ],[
2061       AC_MSG_RESULT([yes])
2062       tst_proto_getaddrinfo="yes"
2063     ],[
2064       AC_MSG_RESULT([no])
2065       tst_proto_getaddrinfo="no"
2066     ])
2067   fi
2068   #
2069   if test "$tst_proto_getaddrinfo" = "yes"; then
2070     AC_MSG_CHECKING([if getaddrinfo is compilable])
2071     AC_COMPILE_IFELSE([
2072       AC_LANG_PROGRAM([[
2073         $curl_includes_ws2tcpip
2074         $curl_includes_sys_socket
2075         $curl_includes_netdb
2076       ]],[[
2077         if(0 != getaddrinfo(0, 0, 0, 0))
2078           return 1;
2079       ]])
2080     ],[
2081       AC_MSG_RESULT([yes])
2082       tst_compi_getaddrinfo="yes"
2083     ],[
2084       AC_MSG_RESULT([no])
2085       tst_compi_getaddrinfo="no"
2086     ])
2087   fi
2088   #
2089   dnl only do runtime verification when not cross-compiling
2090   if test "x$cross_compiling" != "xyes" &&
2091     test "$tst_compi_getaddrinfo" = "yes"; then
2092     AC_MSG_CHECKING([if getaddrinfo seems to work])
2093     AC_RUN_IFELSE([
2094       AC_LANG_PROGRAM([[
2095         $curl_includes_ws2tcpip
2096         $curl_includes_stdlib
2097         $curl_includes_string
2098         $curl_includes_sys_socket
2099         $curl_includes_netdb
2100       ]],[[
2101         struct addrinfo hints;
2102         struct addrinfo *ai = 0;
2103         int error;
2104
2105         #ifdef HAVE_WINSOCK2_H
2106         WSADATA wsa;
2107         if (WSAStartup(MAKEWORD(2,2), &wsa))
2108                 exit(2);
2109         #endif
2110
2111         memset(&hints, 0, sizeof(hints));
2112         hints.ai_flags = AI_NUMERICHOST;
2113         hints.ai_family = AF_UNSPEC;
2114         hints.ai_socktype = SOCK_STREAM;
2115         error = getaddrinfo("127.0.0.1", 0, &hints, &ai);
2116         if(error || !ai)
2117           exit(1); /* fail */
2118         else
2119           exit(0);
2120       ]])
2121     ],[
2122       AC_MSG_RESULT([yes])
2123       tst_works_getaddrinfo="yes"
2124     ],[
2125       AC_MSG_RESULT([no])
2126       tst_works_getaddrinfo="no"
2127     ])
2128   fi
2129   #
2130   if test "$tst_compi_getaddrinfo" = "yes" &&
2131     test "$tst_works_getaddrinfo" != "no"; then
2132     AC_MSG_CHECKING([if getaddrinfo usage allowed])
2133     if test "x$curl_disallow_getaddrinfo" != "xyes"; then
2134       AC_MSG_RESULT([yes])
2135       tst_allow_getaddrinfo="yes"
2136     else
2137       AC_MSG_RESULT([no])
2138       tst_allow_getaddrinfo="no"
2139     fi
2140   fi
2141   #
2142   AC_MSG_CHECKING([if getaddrinfo might be used])
2143   if test "$tst_links_getaddrinfo" = "yes" &&
2144      test "$tst_proto_getaddrinfo" = "yes" &&
2145      test "$tst_compi_getaddrinfo" = "yes" &&
2146      test "$tst_allow_getaddrinfo" = "yes" &&
2147      test "$tst_works_getaddrinfo" != "no"; then
2148     AC_MSG_RESULT([yes])
2149     AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO, 1,
2150       [Define to 1 if you have a working getaddrinfo function.])
2151     curl_cv_func_getaddrinfo="yes"
2152   else
2153     AC_MSG_RESULT([no])
2154     curl_cv_func_getaddrinfo="no"
2155     curl_cv_func_getaddrinfo_threadsafe="no"
2156   fi
2157   #
2158   if test "$curl_cv_func_getaddrinfo" = "yes"; then
2159     AC_MSG_CHECKING([if getaddrinfo is threadsafe])
2160     case $host_os in
2161       aix[[1234]].* | aix5.[[01]].*)
2162         dnl aix 5.1 and older
2163         tst_tsafe_getaddrinfo="no"
2164         ;;
2165       aix*)
2166         dnl aix 5.2 and newer
2167         tst_tsafe_getaddrinfo="yes"
2168         ;;
2169       darwin[[12345]].*)
2170         dnl darwin 5.0 and mac os x 10.1.X and older
2171         tst_tsafe_getaddrinfo="no"
2172         ;;
2173       darwin*)
2174         dnl darwin 6.0 and mac os x 10.2.X and newer
2175         tst_tsafe_getaddrinfo="yes"
2176         ;;
2177       freebsd[[1234]].* | freebsd5.[[1234]]*)
2178         dnl freebsd 5.4 and older
2179         tst_tsafe_getaddrinfo="no"
2180         ;;
2181       freebsd*)
2182         dnl freebsd 5.5 and newer
2183         tst_tsafe_getaddrinfo="yes"
2184         ;;
2185       hpux[[123456789]].* | hpux10.* | hpux11.0* | hpux11.10*)
2186         dnl hpux 11.10 and older
2187         tst_tsafe_getaddrinfo="no"
2188         ;;
2189       hpux*)
2190         dnl hpux 11.11 and newer
2191         tst_tsafe_getaddrinfo="yes"
2192         ;;
2193       netbsd[[123]].*)
2194         dnl netbsd 3.X and older
2195         tst_tsafe_getaddrinfo="no"
2196         ;;
2197       netbsd*)
2198         dnl netbsd 4.X and newer
2199         tst_tsafe_getaddrinfo="yes"
2200         ;;
2201       *bsd*)
2202         dnl All other bsd's
2203         tst_tsafe_getaddrinfo="no"
2204         ;;
2205       solaris2*)
2206         dnl solaris which have it
2207         tst_tsafe_getaddrinfo="yes"
2208         ;;
2209     esac
2210     if test "$tst_tsafe_getaddrinfo" = "unknown" &&
2211        test "$curl_cv_native_windows" = "yes"; then
2212       tst_tsafe_getaddrinfo="yes"
2213     fi
2214     if test "$tst_tsafe_getaddrinfo" = "unknown"; then
2215       CURL_CHECK_DEF_CC([h_errno], [
2216         $curl_includes_sys_socket
2217         $curl_includes_netdb
2218         ], [silent])
2219       if test "$curl_cv_have_def_h_errno" = "yes"; then
2220         tst_h_errno_macro="yes"
2221       else
2222         tst_h_errno_macro="no"
2223       fi
2224       AC_COMPILE_IFELSE([
2225         AC_LANG_PROGRAM([[
2226           $curl_includes_sys_socket
2227           $curl_includes_netdb
2228         ]],[[
2229           h_errno = 2;
2230           if(0 != h_errno)
2231             return 1;
2232         ]])
2233       ],[
2234         tst_h_errno_modifiable_lvalue="yes"
2235       ],[
2236         tst_h_errno_modifiable_lvalue="no"
2237       ])
2238       AC_COMPILE_IFELSE([
2239         AC_LANG_PROGRAM([[
2240         ]],[[
2241 #if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
2242           return 0;
2243 #elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 700)
2244           return 0;
2245 #else
2246           force compilation error
2247 #endif
2248         ]])
2249       ],[
2250         tst_h_errno_sbs_issue_7="yes"
2251       ],[
2252         tst_h_errno_sbs_issue_7="no"
2253       ])
2254       if test "$tst_h_errno_macro" = "no" &&
2255          test "$tst_h_errno_modifiable_lvalue" = "no" &&
2256          test "$tst_h_errno_sbs_issue_7" = "no"; then
2257         tst_tsafe_getaddrinfo="no"
2258       else
2259         tst_tsafe_getaddrinfo="yes"
2260       fi
2261     fi
2262     AC_MSG_RESULT([$tst_tsafe_getaddrinfo])
2263     if test "$tst_tsafe_getaddrinfo" = "yes"; then
2264       AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO_THREADSAFE, 1,
2265         [Define to 1 if the getaddrinfo function is threadsafe.])
2266       curl_cv_func_getaddrinfo_threadsafe="yes"
2267     else
2268       curl_cv_func_getaddrinfo_threadsafe="no"
2269     fi
2270   fi
2271 ])
2272
2273
2274 dnl CURL_CHECK_FUNC_GETHOSTBYADDR
2275 dnl -------------------------------------------------
2276 dnl Verify if gethostbyaddr is available, prototyped,
2277 dnl and can be compiled. If all of these are true,
2278 dnl and usage has not been previously disallowed with
2279 dnl shell variable curl_disallow_gethostbyaddr, then
2280 dnl HAVE_GETHOSTBYADDR will be defined.
2281
2282 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR], [
2283   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2284   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2285   #
2286   tst_links_gethostbyaddr="unknown"
2287   tst_proto_gethostbyaddr="unknown"
2288   tst_compi_gethostbyaddr="unknown"
2289   tst_allow_gethostbyaddr="unknown"
2290   #
2291   AC_MSG_CHECKING([if gethostbyaddr can be linked])
2292   AC_LINK_IFELSE([
2293     AC_LANG_PROGRAM([[
2294       $curl_includes_winsock2
2295       $curl_includes_netdb
2296     ]],[[
2297       if(0 != gethostbyaddr(0, 0, 0))
2298         return 1;
2299     ]])
2300   ],[
2301     AC_MSG_RESULT([yes])
2302     tst_links_gethostbyaddr="yes"
2303   ],[
2304     AC_MSG_RESULT([no])
2305     tst_links_gethostbyaddr="no"
2306   ])
2307   #
2308   if test "$tst_links_gethostbyaddr" = "yes"; then
2309     AC_MSG_CHECKING([if gethostbyaddr is prototyped])
2310     AC_EGREP_CPP([gethostbyaddr],[
2311       $curl_includes_winsock2
2312       $curl_includes_netdb
2313     ],[
2314       AC_MSG_RESULT([yes])
2315       tst_proto_gethostbyaddr="yes"
2316     ],[
2317       AC_MSG_RESULT([no])
2318       tst_proto_gethostbyaddr="no"
2319     ])
2320   fi
2321   #
2322   if test "$tst_proto_gethostbyaddr" = "yes"; then
2323     AC_MSG_CHECKING([if gethostbyaddr is compilable])
2324     AC_COMPILE_IFELSE([
2325       AC_LANG_PROGRAM([[
2326         $curl_includes_winsock2
2327         $curl_includes_netdb
2328       ]],[[
2329         if(0 != gethostbyaddr(0, 0, 0))
2330           return 1;
2331       ]])
2332     ],[
2333       AC_MSG_RESULT([yes])
2334       tst_compi_gethostbyaddr="yes"
2335     ],[
2336       AC_MSG_RESULT([no])
2337       tst_compi_gethostbyaddr="no"
2338     ])
2339   fi
2340   #
2341   if test "$tst_compi_gethostbyaddr" = "yes"; then
2342     AC_MSG_CHECKING([if gethostbyaddr usage allowed])
2343     if test "x$curl_disallow_gethostbyaddr" != "xyes"; then
2344       AC_MSG_RESULT([yes])
2345       tst_allow_gethostbyaddr="yes"
2346     else
2347       AC_MSG_RESULT([no])
2348       tst_allow_gethostbyaddr="no"
2349     fi
2350   fi
2351   #
2352   AC_MSG_CHECKING([if gethostbyaddr might be used])
2353   if test "$tst_links_gethostbyaddr" = "yes" &&
2354      test "$tst_proto_gethostbyaddr" = "yes" &&
2355      test "$tst_compi_gethostbyaddr" = "yes" &&
2356      test "$tst_allow_gethostbyaddr" = "yes"; then
2357     AC_MSG_RESULT([yes])
2358     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR, 1,
2359       [Define to 1 if you have the gethostbyaddr function.])
2360     curl_cv_func_gethostbyaddr="yes"
2361   else
2362     AC_MSG_RESULT([no])
2363     curl_cv_func_gethostbyaddr="no"
2364   fi
2365 ])
2366
2367 dnl CURL_CHECK_FUNC_GAI_STRERROR
2368 dnl -------------------------------------------------
2369 dnl Verify if gai_strerror is available, prototyped,
2370 dnl and can be compiled. If all of these are true,
2371 dnl and usage has not been previously disallowed with
2372 dnl shell variable curl_disallow_gai_strerror, then
2373 dnl HAVE_GAI_STRERROR will be defined.
2374
2375 AC_DEFUN([CURL_CHECK_FUNC_GAI_STRERROR], [
2376   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2377   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2378   #
2379   tst_links_gai_strerror="unknown"
2380   tst_proto_gai_strerror="unknown"
2381   tst_compi_gai_strerror="unknown"
2382   tst_allow_gai_strerror="unknown"
2383   #
2384   AC_MSG_CHECKING([if gai_strerror can be linked])
2385   AC_LINK_IFELSE([
2386     AC_LANG_PROGRAM([[
2387       $curl_includes_winsock2
2388       $curl_includes_netdb
2389     ]],[[
2390       if(0 != gai_strerror(0))
2391         return 1;
2392     ]])
2393   ],[
2394     AC_MSG_RESULT([yes])
2395     tst_links_gai_strerror="yes"
2396   ],[
2397     AC_MSG_RESULT([no])
2398     tst_links_gai_strerror="no"
2399   ])
2400   #
2401   if test "$tst_links_gai_strerror" = "yes"; then
2402     AC_MSG_CHECKING([if gai_strerror is prototyped])
2403     AC_EGREP_CPP([gai_strerror],[
2404       $curl_includes_winsock2
2405       $curl_includes_netdb
2406     ],[
2407       AC_MSG_RESULT([yes])
2408       tst_proto_gai_strerror="yes"
2409     ],[
2410       AC_MSG_RESULT([no])
2411       tst_proto_gai_strerror="no"
2412     ])
2413   fi
2414   #
2415   if test "$tst_proto_gai_strerror" = "yes"; then
2416     AC_MSG_CHECKING([if gai_strerror is compilable])
2417     AC_COMPILE_IFELSE([
2418       AC_LANG_PROGRAM([[
2419         $curl_includes_winsock2
2420         $curl_includes_netdb
2421       ]],[[
2422         if(0 != gai_strerror(0))
2423           return 1;
2424       ]])
2425     ],[
2426       AC_MSG_RESULT([yes])
2427       tst_compi_gai_strerror="yes"
2428     ],[
2429       AC_MSG_RESULT([no])
2430       tst_compi_gai_strerror="no"
2431     ])
2432   fi
2433   #
2434   if test "$tst_compi_gai_strerror" = "yes"; then
2435     AC_MSG_CHECKING([if gai_strerror usage allowed])
2436     if test "x$curl_disallow_gai_strerror" != "xyes"; then
2437       AC_MSG_RESULT([yes])
2438       tst_allow_gai_strerror="yes"
2439     else
2440       AC_MSG_RESULT([no])
2441       tst_allow_gai_strerror="no"
2442     fi
2443   fi
2444   #
2445   AC_MSG_CHECKING([if gai_strerror might be used])
2446   if test "$tst_links_gai_strerror" = "yes" &&
2447      test "$tst_proto_gai_strerror" = "yes" &&
2448      test "$tst_compi_gai_strerror" = "yes" &&
2449      test "$tst_allow_gai_strerror" = "yes"; then
2450     AC_MSG_RESULT([yes])
2451     AC_DEFINE_UNQUOTED(HAVE_GAI_STRERROR, 1,
2452       [Define to 1 if you have the gai_strerror function.])
2453     curl_cv_func_gai_strerror="yes"
2454   else
2455     AC_MSG_RESULT([no])
2456     curl_cv_func_gai_strerror="no"
2457   fi
2458 ])
2459
2460
2461 dnl CURL_CHECK_FUNC_GETHOSTBYADDR_R
2462 dnl -------------------------------------------------
2463 dnl Verify if gethostbyaddr_r is available, prototyped,
2464 dnl and can be compiled. If all of these are true, and
2465 dnl usage has not been previously disallowed with
2466 dnl shell variable curl_disallow_gethostbyaddr_r, then
2467 dnl HAVE_GETHOSTBYADDR_R will be defined.
2468
2469 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR_R], [
2470   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2471   #
2472   tst_links_gethostbyaddr_r="unknown"
2473   tst_proto_gethostbyaddr_r="unknown"
2474   tst_compi_gethostbyaddr_r="unknown"
2475   tst_allow_gethostbyaddr_r="unknown"
2476   tst_nargs_gethostbyaddr_r="unknown"
2477   #
2478   AC_MSG_CHECKING([if gethostbyaddr_r can be linked])
2479   AC_LINK_IFELSE([
2480     AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2481   ],[
2482     AC_MSG_RESULT([yes])
2483     tst_links_gethostbyaddr_r="yes"
2484   ],[
2485     AC_MSG_RESULT([no])
2486     tst_links_gethostbyaddr_r="no"
2487   ])
2488   #
2489   if test "$tst_links_gethostbyaddr_r" = "yes"; then
2490     AC_MSG_CHECKING([if gethostbyaddr_r is prototyped])
2491     AC_EGREP_CPP([gethostbyaddr_r],[
2492       $curl_includes_netdb
2493     ],[
2494       AC_MSG_RESULT([yes])
2495       tst_proto_gethostbyaddr_r="yes"
2496     ],[
2497       AC_MSG_RESULT([no])
2498       tst_proto_gethostbyaddr_r="no"
2499     ])
2500   fi
2501   #
2502   if test "$tst_proto_gethostbyaddr_r" = "yes"; then
2503     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2504       AC_MSG_CHECKING([if gethostbyaddr_r takes 5 args.])
2505       AC_COMPILE_IFELSE([
2506         AC_LANG_PROGRAM([[
2507           $curl_includes_netdb
2508         ]],[[
2509           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0))
2510             return 1;
2511         ]])
2512       ],[
2513         AC_MSG_RESULT([yes])
2514         tst_compi_gethostbyaddr_r="yes"
2515         tst_nargs_gethostbyaddr_r="5"
2516       ],[
2517         AC_MSG_RESULT([no])
2518         tst_compi_gethostbyaddr_r="no"
2519       ])
2520     fi
2521     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2522       AC_MSG_CHECKING([if gethostbyaddr_r takes 7 args.])
2523       AC_COMPILE_IFELSE([
2524         AC_LANG_PROGRAM([[
2525           $curl_includes_netdb
2526         ]],[[
2527           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0))
2528             return 1;
2529         ]])
2530       ],[
2531         AC_MSG_RESULT([yes])
2532         tst_compi_gethostbyaddr_r="yes"
2533         tst_nargs_gethostbyaddr_r="7"
2534       ],[
2535         AC_MSG_RESULT([no])
2536         tst_compi_gethostbyaddr_r="no"
2537       ])
2538     fi
2539     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2540       AC_MSG_CHECKING([if gethostbyaddr_r takes 8 args.])
2541       AC_COMPILE_IFELSE([
2542         AC_LANG_PROGRAM([[
2543           $curl_includes_netdb
2544         ]],[[
2545           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0, 0))
2546             return 1;
2547         ]])
2548       ],[
2549         AC_MSG_RESULT([yes])
2550         tst_compi_gethostbyaddr_r="yes"
2551         tst_nargs_gethostbyaddr_r="8"
2552       ],[
2553         AC_MSG_RESULT([no])
2554         tst_compi_gethostbyaddr_r="no"
2555       ])
2556     fi
2557     AC_MSG_CHECKING([if gethostbyaddr_r is compilable])
2558     if test "$tst_compi_gethostbyaddr_r" = "yes"; then
2559       AC_MSG_RESULT([yes])
2560     else
2561       AC_MSG_RESULT([no])
2562     fi
2563   fi
2564   #
2565   if test "$tst_compi_gethostbyaddr_r" = "yes"; then
2566     AC_MSG_CHECKING([if gethostbyaddr_r usage allowed])
2567     if test "x$curl_disallow_gethostbyaddr_r" != "xyes"; then
2568       AC_MSG_RESULT([yes])
2569       tst_allow_gethostbyaddr_r="yes"
2570     else
2571       AC_MSG_RESULT([no])
2572       tst_allow_gethostbyaddr_r="no"
2573     fi
2574   fi
2575   #
2576   AC_MSG_CHECKING([if gethostbyaddr_r might be used])
2577   if test "$tst_links_gethostbyaddr_r" = "yes" &&
2578      test "$tst_proto_gethostbyaddr_r" = "yes" &&
2579      test "$tst_compi_gethostbyaddr_r" = "yes" &&
2580      test "$tst_allow_gethostbyaddr_r" = "yes"; then
2581     AC_MSG_RESULT([yes])
2582     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
2583       [Define to 1 if you have the gethostbyaddr_r function.])
2584     dnl AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_ARGS, $tst_nargs_gethostbyaddr_r,
2585     dnl   [Specifies the number of arguments to gethostbyaddr_r])
2586     #
2587     if test "$tst_nargs_gethostbyaddr_r" -eq "5"; then
2588       AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2589     elif test "$tst_nargs_gethostbyaddr_r" -eq "7"; then
2590       AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2591     elif test "$tst_nargs_gethostbyaddr_r" -eq "8"; then
2592       AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2593     fi
2594     #
2595     curl_cv_func_gethostbyaddr_r="yes"
2596   else
2597     AC_MSG_RESULT([no])
2598     curl_cv_func_gethostbyaddr_r="no"
2599   fi
2600 ])
2601
2602
2603 dnl CURL_CHECK_FUNC_GETHOSTBYNAME
2604 dnl -------------------------------------------------
2605 dnl Verify if gethostbyname is available, prototyped,
2606 dnl and can be compiled. If all of these are true,
2607 dnl and usage has not been previously disallowed with
2608 dnl shell variable curl_disallow_gethostbyname, then
2609 dnl HAVE_GETHOSTBYNAME will be defined.
2610
2611 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME], [
2612   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2613   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2614   #
2615   tst_links_gethostbyname="unknown"
2616   tst_proto_gethostbyname="unknown"
2617   tst_compi_gethostbyname="unknown"
2618   tst_allow_gethostbyname="unknown"
2619   #
2620   AC_MSG_CHECKING([if gethostbyname can be linked])
2621   AC_LINK_IFELSE([
2622     AC_LANG_PROGRAM([[
2623       $curl_includes_winsock2
2624       $curl_includes_netdb
2625     ]],[[
2626       if(0 != gethostbyname(0))
2627         return 1;
2628     ]])
2629   ],[
2630     AC_MSG_RESULT([yes])
2631     tst_links_gethostbyname="yes"
2632   ],[
2633     AC_MSG_RESULT([no])
2634     tst_links_gethostbyname="no"
2635   ])
2636   #
2637   if test "$tst_links_gethostbyname" = "yes"; then
2638     AC_MSG_CHECKING([if gethostbyname is prototyped])
2639     AC_EGREP_CPP([gethostbyname],[
2640       $curl_includes_winsock2
2641       $curl_includes_netdb
2642     ],[
2643       AC_MSG_RESULT([yes])
2644       tst_proto_gethostbyname="yes"
2645     ],[
2646       AC_MSG_RESULT([no])
2647       tst_proto_gethostbyname="no"
2648     ])
2649   fi
2650   #
2651   if test "$tst_proto_gethostbyname" = "yes"; then
2652     AC_MSG_CHECKING([if gethostbyname is compilable])
2653     AC_COMPILE_IFELSE([
2654       AC_LANG_PROGRAM([[
2655         $curl_includes_winsock2
2656         $curl_includes_netdb
2657       ]],[[
2658         if(0 != gethostbyname(0))
2659           return 1;
2660       ]])
2661     ],[
2662       AC_MSG_RESULT([yes])
2663       tst_compi_gethostbyname="yes"
2664     ],[
2665       AC_MSG_RESULT([no])
2666       tst_compi_gethostbyname="no"
2667     ])
2668   fi
2669   #
2670   if test "$tst_compi_gethostbyname" = "yes"; then
2671     AC_MSG_CHECKING([if gethostbyname usage allowed])
2672     if test "x$curl_disallow_gethostbyname" != "xyes"; then
2673       AC_MSG_RESULT([yes])
2674       tst_allow_gethostbyname="yes"
2675     else
2676       AC_MSG_RESULT([no])
2677       tst_allow_gethostbyname="no"
2678     fi
2679   fi
2680   #
2681   AC_MSG_CHECKING([if gethostbyname might be used])
2682   if test "$tst_links_gethostbyname" = "yes" &&
2683      test "$tst_proto_gethostbyname" = "yes" &&
2684      test "$tst_compi_gethostbyname" = "yes" &&
2685      test "$tst_allow_gethostbyname" = "yes"; then
2686     AC_MSG_RESULT([yes])
2687     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME, 1,
2688       [Define to 1 if you have the gethostbyname function.])
2689     curl_cv_func_gethostbyname="yes"
2690   else
2691     AC_MSG_RESULT([no])
2692     curl_cv_func_gethostbyname="no"
2693   fi
2694 ])
2695
2696
2697 dnl CURL_CHECK_FUNC_GETHOSTBYNAME_R
2698 dnl -------------------------------------------------
2699 dnl Verify if gethostbyname_r is available, prototyped,
2700 dnl and can be compiled. If all of these are true, and
2701 dnl usage has not been previously disallowed with
2702 dnl shell variable curl_disallow_gethostbyname_r, then
2703 dnl HAVE_GETHOSTBYNAME_R will be defined.
2704
2705 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [
2706   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2707   #
2708   tst_links_gethostbyname_r="unknown"
2709   tst_proto_gethostbyname_r="unknown"
2710   tst_compi_gethostbyname_r="unknown"
2711   tst_allow_gethostbyname_r="unknown"
2712   tst_nargs_gethostbyname_r="unknown"
2713   #
2714   AC_MSG_CHECKING([if gethostbyname_r can be linked])
2715   AC_LINK_IFELSE([
2716     AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
2717   ],[
2718     AC_MSG_RESULT([yes])
2719     tst_links_gethostbyname_r="yes"
2720   ],[
2721     AC_MSG_RESULT([no])
2722     tst_links_gethostbyname_r="no"
2723   ])
2724   #
2725   if test "$tst_links_gethostbyname_r" = "yes"; then
2726     AC_MSG_CHECKING([if gethostbyname_r is prototyped])
2727     AC_EGREP_CPP([gethostbyname_r],[
2728       $curl_includes_netdb
2729     ],[
2730       AC_MSG_RESULT([yes])
2731       tst_proto_gethostbyname_r="yes"
2732     ],[
2733       AC_MSG_RESULT([no])
2734       tst_proto_gethostbyname_r="no"
2735     ])
2736   fi
2737   #
2738   if test "$tst_proto_gethostbyname_r" = "yes"; then
2739     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2740       AC_MSG_CHECKING([if gethostbyname_r takes 3 args.])
2741       AC_COMPILE_IFELSE([
2742         AC_LANG_PROGRAM([[
2743           $curl_includes_netdb
2744         ]],[[
2745           if(0 != gethostbyname_r(0, 0, 0))
2746             return 1;
2747         ]])
2748       ],[
2749         AC_MSG_RESULT([yes])
2750         tst_compi_gethostbyname_r="yes"
2751         tst_nargs_gethostbyname_r="3"
2752       ],[
2753         AC_MSG_RESULT([no])
2754         tst_compi_gethostbyname_r="no"
2755       ])
2756     fi
2757     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2758       AC_MSG_CHECKING([if gethostbyname_r takes 5 args.])
2759       AC_COMPILE_IFELSE([
2760         AC_LANG_PROGRAM([[
2761           $curl_includes_netdb
2762         ]],[[
2763           if(0 != gethostbyname_r(0, 0, 0, 0, 0))
2764             return 1;
2765         ]])
2766       ],[
2767         AC_MSG_RESULT([yes])
2768         tst_compi_gethostbyname_r="yes"
2769         tst_nargs_gethostbyname_r="5"
2770       ],[
2771         AC_MSG_RESULT([no])
2772         tst_compi_gethostbyname_r="no"
2773       ])
2774     fi
2775     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2776       AC_MSG_CHECKING([if gethostbyname_r takes 6 args.])
2777       AC_COMPILE_IFELSE([
2778         AC_LANG_PROGRAM([[
2779           $curl_includes_netdb
2780         ]],[[
2781           if(0 != gethostbyname_r(0, 0, 0, 0, 0, 0))
2782             return 1;
2783         ]])
2784       ],[
2785         AC_MSG_RESULT([yes])
2786         tst_compi_gethostbyname_r="yes"
2787         tst_nargs_gethostbyname_r="6"
2788       ],[
2789         AC_MSG_RESULT([no])
2790         tst_compi_gethostbyname_r="no"
2791       ])
2792     fi
2793     AC_MSG_CHECKING([if gethostbyname_r is compilable])
2794     if test "$tst_compi_gethostbyname_r" = "yes"; then
2795       AC_MSG_RESULT([yes])
2796     else
2797       AC_MSG_RESULT([no])
2798     fi
2799   fi
2800   #
2801   if test "$tst_compi_gethostbyname_r" = "yes"; then
2802     AC_MSG_CHECKING([if gethostbyname_r usage allowed])
2803     if test "x$curl_disallow_gethostbyname_r" != "xyes"; then
2804       AC_MSG_RESULT([yes])
2805       tst_allow_gethostbyname_r="yes"
2806     else
2807       AC_MSG_RESULT([no])
2808       tst_allow_gethostbyname_r="no"
2809     fi
2810   fi
2811   #
2812   AC_MSG_CHECKING([if gethostbyname_r might be used])
2813   if test "$tst_links_gethostbyname_r" = "yes" &&
2814      test "$tst_proto_gethostbyname_r" = "yes" &&
2815      test "$tst_compi_gethostbyname_r" = "yes" &&
2816      test "$tst_allow_gethostbyname_r" = "yes"; then
2817     AC_MSG_RESULT([yes])
2818     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
2819       [Define to 1 if you have the gethostbyname_r function.])
2820     dnl AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_ARGS, $tst_nargs_gethostbyname_r,
2821     dnl   [Specifies the number of arguments to gethostbyname_r])
2822     #
2823     if test "$tst_nargs_gethostbyname_r" -eq "3"; then
2824       AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2825     elif test "$tst_nargs_gethostbyname_r" -eq "5"; then
2826       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2827     elif test "$tst_nargs_gethostbyname_r" -eq "6"; then
2828       AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2829     fi
2830     #
2831     curl_cv_func_gethostbyname_r="yes"
2832   else
2833     AC_MSG_RESULT([no])
2834     curl_cv_func_gethostbyname_r="no"
2835   fi
2836 ])
2837
2838
2839 dnl CURL_CHECK_FUNC_GETHOSTNAME
2840 dnl -------------------------------------------------
2841 dnl Verify if gethostname is available, prototyped, and
2842 dnl can be compiled. If all of these are true, and
2843 dnl usage has not been previously disallowed with
2844 dnl shell variable curl_disallow_gethostname, then
2845 dnl HAVE_GETHOSTNAME will be defined.
2846
2847 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
2848   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2849   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
2850   AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
2851   #
2852   tst_links_gethostname="unknown"
2853   tst_proto_gethostname="unknown"
2854   tst_compi_gethostname="unknown"
2855   tst_allow_gethostname="unknown"
2856   #
2857   AC_MSG_CHECKING([if gethostname can be linked])
2858   AC_LINK_IFELSE([
2859     AC_LANG_PROGRAM([[
2860       $curl_includes_winsock2
2861       $curl_includes_unistd
2862     ]],[[
2863       if(0 != gethostname(0, 0))
2864         return 1;
2865     ]])
2866   ],[
2867     AC_MSG_RESULT([yes])
2868     tst_links_gethostname="yes"
2869   ],[
2870     AC_MSG_RESULT([no])
2871     tst_links_gethostname="no"
2872   ])
2873   #
2874   if test "$tst_links_gethostname" = "yes"; then
2875     AC_MSG_CHECKING([if gethostname is prototyped])
2876     AC_EGREP_CPP([gethostname],[
2877       $curl_includes_winsock2
2878       $curl_includes_unistd
2879     ],[
2880       AC_MSG_RESULT([yes])
2881       tst_proto_gethostname="yes"
2882     ],[
2883       AC_MSG_RESULT([no])
2884       tst_proto_gethostname="no"
2885     ])
2886   fi
2887   #
2888   if test "$tst_proto_gethostname" = "yes"; then
2889     AC_MSG_CHECKING([if gethostname is compilable])
2890     AC_COMPILE_IFELSE([
2891       AC_LANG_PROGRAM([[
2892         $curl_includes_winsock2
2893         $curl_includes_unistd
2894       ]],[[
2895         if(0 != gethostname(0, 0))
2896           return 1;
2897       ]])
2898     ],[
2899       AC_MSG_RESULT([yes])
2900       tst_compi_gethostname="yes"
2901     ],[
2902       AC_MSG_RESULT([no])
2903       tst_compi_gethostname="no"
2904     ])
2905   fi
2906   #
2907   if test "$tst_compi_gethostname" = "yes"; then
2908     AC_MSG_CHECKING([for gethostname arg 2 data type])
2909     tst_gethostname_type_arg2="unknown"
2910     for tst_arg1 in 'char *' 'unsigned char *' 'void *'; do
2911       for tst_arg2 in 'int' 'unsigned int' 'size_t'; do
2912         if test "$tst_gethostname_type_arg2" = "unknown"; then
2913           AC_COMPILE_IFELSE([
2914             AC_LANG_PROGRAM([[
2915               $curl_includes_winsock2
2916               $curl_includes_unistd
2917               $curl_preprocess_callconv
2918               extern int FUNCALLCONV gethostname($tst_arg1, $tst_arg2);
2919             ]],[[
2920               if(0 != gethostname(0, 0))
2921                 return 1;
2922             ]])
2923           ],[
2924             tst_gethostname_type_arg2="$tst_arg2"
2925           ])
2926         fi
2927       done
2928     done
2929     AC_MSG_RESULT([$tst_gethostname_type_arg2])
2930     if test "$tst_gethostname_type_arg2" != "unknown"; then
2931       AC_DEFINE_UNQUOTED(GETHOSTNAME_TYPE_ARG2, $tst_gethostname_type_arg2,
2932         [Define to the type of arg 2 for gethostname.])
2933     fi
2934   fi
2935   #
2936   if test "$tst_compi_gethostname" = "yes"; then
2937     AC_MSG_CHECKING([if gethostname usage allowed])
2938     if test "x$curl_disallow_gethostname" != "xyes"; then
2939       AC_MSG_RESULT([yes])
2940       tst_allow_gethostname="yes"
2941     else
2942       AC_MSG_RESULT([no])
2943       tst_allow_gethostname="no"
2944     fi
2945   fi
2946   #
2947   AC_MSG_CHECKING([if gethostname might be used])
2948   if test "$tst_links_gethostname" = "yes" &&
2949      test "$tst_proto_gethostname" = "yes" &&
2950      test "$tst_compi_gethostname" = "yes" &&
2951      test "$tst_allow_gethostname" = "yes"; then
2952     AC_MSG_RESULT([yes])
2953     AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
2954       [Define to 1 if you have the gethostname function.])
2955     curl_cv_func_gethostname="yes"
2956   else
2957     AC_MSG_RESULT([no])
2958     curl_cv_func_gethostname="no"
2959   fi
2960 ])
2961
2962
2963 dnl CURL_CHECK_FUNC_GETIFADDRS
2964 dnl -------------------------------------------------
2965 dnl Verify if getifaddrs is available, prototyped, can
2966 dnl be compiled and seems to work. If all of these are
2967 dnl true, and usage has not been previously disallowed
2968 dnl with shell variable curl_disallow_getifaddrs, then
2969 dnl HAVE_GETIFADDRS will be defined.
2970
2971 AC_DEFUN([CURL_CHECK_FUNC_GETIFADDRS], [
2972   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2973   AC_REQUIRE([CURL_INCLUDES_IFADDRS])dnl
2974   #
2975   tst_links_getifaddrs="unknown"
2976   tst_proto_getifaddrs="unknown"
2977   tst_compi_getifaddrs="unknown"
2978   tst_works_getifaddrs="unknown"
2979   tst_allow_getifaddrs="unknown"
2980   #
2981   AC_MSG_CHECKING([if getifaddrs can be linked])
2982   AC_LINK_IFELSE([
2983     AC_LANG_FUNC_LINK_TRY([getifaddrs])
2984   ],[
2985     AC_MSG_RESULT([yes])
2986     tst_links_getifaddrs="yes"
2987   ],[
2988     AC_MSG_RESULT([no])
2989     tst_links_getifaddrs="no"
2990   ])
2991   #
2992   if test "$tst_links_getifaddrs" = "yes"; then
2993     AC_MSG_CHECKING([if getifaddrs is prototyped])
2994     AC_EGREP_CPP([getifaddrs],[
2995       $curl_includes_ifaddrs
2996     ],[
2997       AC_MSG_RESULT([yes])
2998       tst_proto_getifaddrs="yes"
2999     ],[
3000       AC_MSG_RESULT([no])
3001       tst_proto_getifaddrs="no"
3002     ])
3003   fi
3004   #
3005   if test "$tst_proto_getifaddrs" = "yes"; then
3006     AC_MSG_CHECKING([if getifaddrs is compilable])
3007     AC_COMPILE_IFELSE([
3008       AC_LANG_PROGRAM([[
3009         $curl_includes_ifaddrs
3010       ]],[[
3011         if(0 != getifaddrs(0))
3012           return 1;
3013       ]])
3014     ],[
3015       AC_MSG_RESULT([yes])
3016       tst_compi_getifaddrs="yes"
3017     ],[
3018       AC_MSG_RESULT([no])
3019       tst_compi_getifaddrs="no"
3020     ])
3021   fi
3022   #
3023   dnl only do runtime verification when not cross-compiling
3024   if test "x$cross_compiling" != "xyes" &&
3025     test "$tst_compi_getifaddrs" = "yes"; then
3026     AC_MSG_CHECKING([if getifaddrs seems to work])
3027     AC_RUN_IFELSE([
3028       AC_LANG_PROGRAM([[
3029         $curl_includes_stdlib
3030         $curl_includes_ifaddrs
3031       ]],[[
3032         struct ifaddrs *ifa = 0;
3033         int error;
3034
3035         error = getifaddrs(&ifa);
3036         if(error || !ifa)
3037           exit(1); /* fail */
3038         else
3039           exit(0);
3040       ]])
3041     ],[
3042       AC_MSG_RESULT([yes])
3043       tst_works_getifaddrs="yes"
3044     ],[
3045       AC_MSG_RESULT([no])
3046       tst_works_getifaddrs="no"
3047     ])
3048   fi
3049   #
3050   if test "$tst_compi_getifaddrs" = "yes" &&
3051     test "$tst_works_getifaddrs" != "no"; then
3052     AC_MSG_CHECKING([if getifaddrs usage allowed])
3053     if test "x$curl_disallow_getifaddrs" != "xyes"; then
3054       AC_MSG_RESULT([yes])
3055       tst_allow_getifaddrs="yes"
3056     else
3057       AC_MSG_RESULT([no])
3058       tst_allow_getifaddrs="no"
3059     fi
3060   fi
3061   #
3062   AC_MSG_CHECKING([if getifaddrs might be used])
3063   if test "$tst_links_getifaddrs" = "yes" &&
3064      test "$tst_proto_getifaddrs" = "yes" &&
3065      test "$tst_compi_getifaddrs" = "yes" &&
3066      test "$tst_allow_getifaddrs" = "yes" &&
3067      test "$tst_works_getifaddrs" != "no"; then
3068     AC_MSG_RESULT([yes])
3069     AC_DEFINE_UNQUOTED(HAVE_GETIFADDRS, 1,
3070       [Define to 1 if you have a working getifaddrs function.])
3071     curl_cv_func_getifaddrs="yes"
3072   else
3073     AC_MSG_RESULT([no])
3074     curl_cv_func_getifaddrs="no"
3075   fi
3076 ])
3077
3078
3079 dnl CURL_CHECK_FUNC_GETSERVBYPORT_R
3080 dnl -------------------------------------------------
3081 dnl Verify if getservbyport_r is available, prototyped,
3082 dnl and can be compiled. If all of these are true, and
3083 dnl usage has not been previously disallowed with
3084 dnl shell variable curl_disallow_getservbyport_r, then
3085 dnl HAVE_GETSERVBYPORT_R will be defined.
3086
3087 AC_DEFUN([CURL_CHECK_FUNC_GETSERVBYPORT_R], [
3088   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
3089   #
3090   tst_links_getservbyport_r="unknown"
3091   tst_proto_getservbyport_r="unknown"
3092   tst_compi_getservbyport_r="unknown"
3093   tst_allow_getservbyport_r="unknown"
3094   tst_nargs_getservbyport_r="unknown"
3095   #
3096   AC_MSG_CHECKING([if getservbyport_r can be linked])
3097   AC_LINK_IFELSE([
3098     AC_LANG_FUNC_LINK_TRY([getservbyport_r])
3099   ],[
3100     AC_MSG_RESULT([yes])
3101     tst_links_getservbyport_r="yes"
3102   ],[
3103     AC_MSG_RESULT([no])
3104     tst_links_getservbyport_r="no"
3105   ])
3106   #
3107   if test "$tst_links_getservbyport_r" = "yes"; then
3108     AC_MSG_CHECKING([if getservbyport_r is prototyped])
3109     AC_EGREP_CPP([getservbyport_r],[
3110       $curl_includes_netdb
3111     ],[
3112       AC_MSG_RESULT([yes])
3113       tst_proto_getservbyport_r="yes"
3114     ],[
3115       AC_MSG_RESULT([no])
3116       tst_proto_getservbyport_r="no"
3117     ])
3118   fi
3119   #
3120   if test "$tst_proto_getservbyport_r" = "yes"; then
3121     if test "$tst_nargs_getservbyport_r" = "unknown"; then
3122       AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
3123       AC_COMPILE_IFELSE([
3124         AC_LANG_PROGRAM([[
3125           $curl_includes_netdb
3126         ]],[[
3127           if(0 != getservbyport_r(0, 0, 0, 0))
3128             return 1;
3129         ]])
3130       ],[
3131         AC_MSG_RESULT([yes])
3132         tst_compi_getservbyport_r="yes"
3133         tst_nargs_getservbyport_r="4"
3134       ],[
3135         AC_MSG_RESULT([no])
3136         tst_compi_getservbyport_r="no"
3137       ])
3138     fi
3139     if test "$tst_nargs_getservbyport_r" = "unknown"; then
3140       AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
3141       AC_COMPILE_IFELSE([
3142         AC_LANG_PROGRAM([[
3143           $curl_includes_netdb
3144         ]],[[
3145           if(0 != getservbyport_r(0, 0, 0, 0, 0))
3146             return 1;
3147         ]])
3148       ],[
3149         AC_MSG_RESULT([yes])
3150         tst_compi_getservbyport_r="yes"
3151         tst_nargs_getservbyport_r="5"
3152       ],[
3153         AC_MSG_RESULT([no])
3154         tst_compi_getservbyport_r="no"
3155       ])
3156     fi
3157     if test "$tst_nargs_getservbyport_r" = "unknown"; then
3158       AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
3159       AC_COMPILE_IFELSE([
3160         AC_LANG_PROGRAM([[
3161           $curl_includes_netdb
3162         ]],[[
3163           if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
3164             return 1;
3165         ]])
3166       ],[
3167         AC_MSG_RESULT([yes])
3168         tst_compi_getservbyport_r="yes"
3169         tst_nargs_getservbyport_r="6"
3170       ],[
3171         AC_MSG_RESULT([no])
3172         tst_compi_getservbyport_r="no"
3173       ])
3174     fi
3175     AC_MSG_CHECKING([if getservbyport_r is compilable])
3176     if test "$tst_compi_getservbyport_r" = "yes"; then
3177       AC_MSG_RESULT([yes])
3178     else
3179       AC_MSG_RESULT([no])
3180     fi
3181   fi
3182   #
3183   if test "$tst_compi_getservbyport_r" = "yes"; then
3184     AC_MSG_CHECKING([if getservbyport_r usage allowed])
3185     if test "x$curl_disallow_getservbyport_r" != "xyes"; then
3186       AC_MSG_RESULT([yes])
3187       tst_allow_getservbyport_r="yes"
3188     else
3189       AC_MSG_RESULT([no])
3190       tst_allow_getservbyport_r="no"
3191     fi
3192   fi
3193   #
3194   AC_MSG_CHECKING([if getservbyport_r might be used])
3195   if test "$tst_links_getservbyport_r" = "yes" &&
3196      test "$tst_proto_getservbyport_r" = "yes" &&
3197      test "$tst_compi_getservbyport_r" = "yes" &&
3198      test "$tst_allow_getservbyport_r" = "yes"; then
3199     AC_MSG_RESULT([yes])
3200     AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
3201       [Define to 1 if you have the getservbyport_r function.])
3202     AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
3203       [Specifies the number of arguments to getservbyport_r])
3204     if test "$tst_nargs_getservbyport_r" -eq "4"; then
3205       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
3206         [Specifies the size of the buffer to pass to getservbyport_r])
3207     else
3208       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
3209         [Specifies the size of the buffer to pass to getservbyport_r])
3210     fi
3211     curl_cv_func_getservbyport_r="yes"
3212   else
3213     AC_MSG_RESULT([no])
3214     curl_cv_func_getservbyport_r="no"
3215   fi
3216 ])
3217
3218
3219 dnl CURL_CHECK_FUNC_GETXATTR
3220 dnl -------------------------------------------------
3221 dnl Verify if getxattr is available, prototyped, and
3222 dnl can be compiled. If all of these are true, and
3223 dnl usage has not been previously disallowed with
3224 dnl shell variable curl_disallow_getxattr, then
3225 dnl HAVE_GETXATTR will be defined.
3226
3227 AC_DEFUN([CURL_CHECK_FUNC_GETXATTR], [
3228   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
3229   #
3230   tst_links_getxattr="unknown"
3231   tst_proto_getxattr="unknown"
3232   tst_compi_getxattr="unknown"
3233   tst_allow_getxattr="unknown"
3234   tst_nargs_getxattr="unknown"
3235   #
3236   AC_MSG_CHECKING([if getxattr can be linked])
3237   AC_LINK_IFELSE([
3238     AC_LANG_FUNC_LINK_TRY([getxattr])
3239   ],[
3240     AC_MSG_RESULT([yes])
3241     tst_links_getxattr="yes"
3242   ],[
3243     AC_MSG_RESULT([no])
3244     tst_links_getxattr="no"
3245   ])
3246   #
3247   if test "$tst_links_getxattr" = "yes"; then
3248     AC_MSG_CHECKING([if getxattr is prototyped])
3249     AC_EGREP_CPP([getxattr],[
3250       $curl_includes_sys_xattr
3251     ],[
3252       AC_MSG_RESULT([yes])
3253       tst_proto_getxattr="yes"
3254     ],[
3255       AC_MSG_RESULT([no])
3256       tst_proto_getxattr="no"
3257     ])
3258   fi
3259   #
3260   if test "$tst_proto_getxattr" = "yes"; then
3261     if test "$tst_nargs_getxattr" = "unknown"; then
3262       AC_MSG_CHECKING([if getxattr takes 4 args.])
3263       AC_COMPILE_IFELSE([
3264         AC_LANG_PROGRAM([[
3265           $curl_includes_sys_xattr
3266         ]],[[
3267           if(0 != getxattr(0, 0, 0, 0))
3268             return 1;
3269         ]])
3270       ],[
3271         AC_MSG_RESULT([yes])
3272         tst_compi_getxattr="yes"
3273         tst_nargs_getxattr="4"
3274       ],[
3275         AC_MSG_RESULT([no])
3276         tst_compi_getxattr="no"
3277       ])
3278     fi
3279     if test "$tst_nargs_getxattr" = "unknown"; then
3280       AC_MSG_CHECKING([if getxattr takes 6 args.])
3281       AC_COMPILE_IFELSE([
3282         AC_LANG_PROGRAM([[
3283           $curl_includes_sys_xattr
3284         ]],[[
3285           if(0 != getxattr(0, 0, 0, 0, 0, 0))
3286             return 1;
3287         ]])
3288       ],[
3289         AC_MSG_RESULT([yes])
3290         tst_compi_getxattr="yes"
3291         tst_nargs_getxattr="6"
3292       ],[
3293         AC_MSG_RESULT([no])
3294         tst_compi_getxattr="no"
3295       ])
3296     fi
3297     AC_MSG_CHECKING([if getxattr is compilable])
3298     if test "$tst_compi_getxattr" = "yes"; then
3299       AC_MSG_RESULT([yes])
3300     else
3301       AC_MSG_RESULT([no])
3302     fi
3303   fi
3304   #
3305   if test "$tst_compi_getxattr" = "yes"; then
3306     AC_MSG_CHECKING([if getxattr usage allowed])
3307     if test "x$curl_disallow_getxattr" != "xyes"; then
3308       AC_MSG_RESULT([yes])
3309       tst_allow_getxattr="yes"
3310     else
3311       AC_MSG_RESULT([no])
3312       tst_allow_getxattr="no"
3313     fi
3314   fi
3315   #
3316   AC_MSG_CHECKING([if getxattr might be used])
3317   if test "$tst_links_getxattr" = "yes" &&
3318      test "$tst_proto_getxattr" = "yes" &&
3319      test "$tst_compi_getxattr" = "yes" &&
3320      test "$tst_allow_getxattr" = "yes"; then
3321     AC_MSG_RESULT([yes])
3322     AC_DEFINE_UNQUOTED(HAVE_GETXATTR, 1,
3323       [Define to 1 if you have the getxattr function.])
3324     dnl AC_DEFINE_UNQUOTED(GETXATTR_ARGS, $tst_nargs_getxattr,
3325     dnl   [Specifies the number of arguments to getxattr])
3326     #
3327     if test "$tst_nargs_getxattr" -eq "4"; then
3328       AC_DEFINE(HAVE_GETXATTR_4, 1, [getxattr() takes 4 args])
3329     elif test "$tst_nargs_getxattr" -eq "6"; then
3330       AC_DEFINE(HAVE_GETXATTR_6, 1, [getxattr() takes 6 args])
3331     fi
3332     #
3333     curl_cv_func_getxattr="yes"
3334   else
3335     AC_MSG_RESULT([no])
3336     curl_cv_func_getxattr="no"
3337   fi
3338 ])
3339
3340
3341 dnl CURL_CHECK_FUNC_GMTIME_R
3342 dnl -------------------------------------------------
3343 dnl Verify if gmtime_r is available, prototyped, can
3344 dnl be compiled and seems to work. If all of these are
3345 dnl true, and usage has not been previously disallowed
3346 dnl with shell variable curl_disallow_gmtime_r, then
3347 dnl HAVE_GMTIME_R will be defined.
3348
3349 AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
3350   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3351   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
3352   #
3353   tst_links_gmtime_r="unknown"
3354   tst_proto_gmtime_r="unknown"
3355   tst_compi_gmtime_r="unknown"
3356   tst_works_gmtime_r="unknown"
3357   tst_allow_gmtime_r="unknown"
3358   #
3359   AC_MSG_CHECKING([if gmtime_r can be linked])
3360   AC_LINK_IFELSE([
3361     AC_LANG_FUNC_LINK_TRY([gmtime_r])
3362   ],[
3363     AC_MSG_RESULT([yes])
3364     tst_links_gmtime_r="yes"
3365   ],[
3366     AC_MSG_RESULT([no])
3367     tst_links_gmtime_r="no"
3368   ])
3369   #
3370   if test "$tst_links_gmtime_r" = "yes"; then
3371     AC_MSG_CHECKING([if gmtime_r is prototyped])
3372     AC_EGREP_CPP([gmtime_r],[
3373       $curl_includes_time
3374     ],[
3375       AC_MSG_RESULT([yes])
3376       tst_proto_gmtime_r="yes"
3377     ],[
3378       AC_MSG_RESULT([no])
3379       tst_proto_gmtime_r="no"
3380     ])
3381   fi
3382   #
3383   if test "$tst_proto_gmtime_r" = "yes"; then
3384     AC_MSG_CHECKING([if gmtime_r is compilable])
3385     AC_COMPILE_IFELSE([
3386       AC_LANG_PROGRAM([[
3387         $curl_includes_time
3388       ]],[[
3389         if(0 != gmtime_r(0, 0))
3390           return 1;
3391       ]])
3392     ],[
3393       AC_MSG_RESULT([yes])
3394       tst_compi_gmtime_r="yes"
3395     ],[
3396       AC_MSG_RESULT([no])
3397       tst_compi_gmtime_r="no"
3398     ])
3399   fi
3400   #
3401   dnl only do runtime verification when not cross-compiling
3402   if test "x$cross_compiling" != "xyes" &&
3403     test "$tst_compi_gmtime_r" = "yes"; then
3404     AC_MSG_CHECKING([if gmtime_r seems to work])
3405     AC_RUN_IFELSE([
3406       AC_LANG_PROGRAM([[
3407         $curl_includes_stdlib
3408         $curl_includes_time
3409       ]],[[
3410         time_t local = 1170352587;
3411         struct tm *gmt = 0;
3412         struct tm result;
3413         gmt = gmtime_r(&local, &result);
3414         if(gmt)
3415           exit(0);
3416         else
3417           exit(1);
3418       ]])
3419     ],[
3420       AC_MSG_RESULT([yes])
3421       tst_works_gmtime_r="yes"
3422     ],[
3423       AC_MSG_RESULT([no])
3424       tst_works_gmtime_r="no"
3425     ])
3426   fi
3427   #
3428   if test "$tst_compi_gmtime_r" = "yes" &&
3429     test "$tst_works_gmtime_r" != "no"; then
3430     AC_MSG_CHECKING([if gmtime_r usage allowed])
3431     if test "x$curl_disallow_gmtime_r" != "xyes"; then
3432       AC_MSG_RESULT([yes])
3433       tst_allow_gmtime_r="yes"
3434     else
3435       AC_MSG_RESULT([no])
3436       tst_allow_gmtime_r="no"
3437     fi
3438   fi
3439   #
3440   AC_MSG_CHECKING([if gmtime_r might be used])
3441   if test "$tst_links_gmtime_r" = "yes" &&
3442      test "$tst_proto_gmtime_r" = "yes" &&
3443      test "$tst_compi_gmtime_r" = "yes" &&
3444      test "$tst_allow_gmtime_r" = "yes" &&
3445      test "$tst_works_gmtime_r" != "no"; then
3446     AC_MSG_RESULT([yes])
3447     AC_DEFINE_UNQUOTED(HAVE_GMTIME_R, 1,
3448       [Define to 1 if you have a working gmtime_r function.])
3449     curl_cv_func_gmtime_r="yes"
3450   else
3451     AC_MSG_RESULT([no])
3452     curl_cv_func_gmtime_r="no"
3453   fi
3454 ])
3455
3456
3457 dnl CURL_CHECK_FUNC_INET_NTOA_R
3458 dnl -------------------------------------------------
3459 dnl Verify if inet_ntoa_r is available, prototyped,
3460 dnl and can be compiled. If all of these are true, and
3461 dnl usage has not been previously disallowed with
3462 dnl shell variable curl_disallow_inet_ntoa_r, then
3463 dnl HAVE_INET_NTOA_R will be defined.
3464
3465 AC_DEFUN([CURL_CHECK_FUNC_INET_NTOA_R], [
3466   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
3467   #
3468   tst_links_inet_ntoa_r="unknown"
3469   tst_proto_inet_ntoa_r="unknown"
3470   tst_compi_inet_ntoa_r="unknown"
3471   tst_allow_inet_ntoa_r="unknown"
3472   tst_nargs_inet_ntoa_r="unknown"
3473   #
3474   AC_MSG_CHECKING([if inet_ntoa_r can be linked])
3475   AC_LINK_IFELSE([
3476     AC_LANG_FUNC_LINK_TRY([inet_ntoa_r])
3477   ],[
3478     AC_MSG_RESULT([yes])
3479     tst_links_inet_ntoa_r="yes"
3480   ],[
3481     AC_MSG_RESULT([no])
3482     tst_links_inet_ntoa_r="no"
3483   ])
3484   #
3485   if test "$tst_links_inet_ntoa_r" = "yes"; then
3486     AC_MSG_CHECKING([if inet_ntoa_r is prototyped])
3487     AC_EGREP_CPP([inet_ntoa_r],[
3488       $curl_includes_arpa_inet
3489     ],[
3490       AC_MSG_RESULT([yes])
3491       tst_proto_inet_ntoa_r="yes"
3492     ],[
3493       AC_MSG_RESULT([no])
3494       tst_proto_inet_ntoa_r="no"
3495     ])
3496   fi
3497   #
3498   if test "$tst_proto_inet_ntoa_r" = "yes"; then
3499     if test "$tst_nargs_inet_ntoa_r" = "unknown"; then
3500       AC_MSG_CHECKING([if inet_ntoa_r takes 2 args.])
3501       AC_COMPILE_IFELSE([
3502         AC_LANG_PROGRAM([[
3503           $curl_includes_arpa_inet
3504         ]],[[
3505           struct in_addr addr;
3506           if(0 != inet_ntoa_r(addr, 0))
3507             return 1;
3508         ]])
3509       ],[
3510         AC_MSG_RESULT([yes])
3511         tst_compi_inet_ntoa_r="yes"
3512         tst_nargs_inet_ntoa_r="2"
3513       ],[
3514         AC_MSG_RESULT([no])
3515         tst_compi_inet_ntoa_r="no"
3516       ])
3517     fi
3518     if test "$tst_nargs_inet_ntoa_r" = "unknown"; then
3519       AC_MSG_CHECKING([if inet_ntoa_r takes 3 args.])
3520       AC_COMPILE_IFELSE([
3521         AC_LANG_PROGRAM([[
3522           $curl_includes_arpa_inet
3523         ]],[[
3524           struct in_addr addr;
3525           if(0 != inet_ntoa_r(addr, 0, 0))
3526             return 1;
3527         ]])
3528       ],[
3529         AC_MSG_RESULT([yes])
3530         tst_compi_inet_ntoa_r="yes"
3531         tst_nargs_inet_ntoa_r="3"
3532       ],[
3533         AC_MSG_RESULT([no])
3534         tst_compi_inet_ntoa_r="no"
3535       ])
3536     fi
3537     AC_MSG_CHECKING([if inet_ntoa_r is compilable])
3538     if test "$tst_compi_inet_ntoa_r" = "yes"; then
3539       AC_MSG_RESULT([yes])
3540     else
3541       AC_MSG_RESULT([no])
3542     fi
3543   fi
3544   #
3545   if test "$tst_compi_inet_ntoa_r" = "yes"; then
3546     AC_MSG_CHECKING([if inet_ntoa_r usage allowed])
3547     if test "x$curl_disallow_inet_ntoa_r" != "xyes"; then
3548       AC_MSG_RESULT([yes])
3549       tst_allow_inet_ntoa_r="yes"
3550     else
3551       AC_MSG_RESULT([no])
3552       tst_allow_inet_ntoa_r="no"
3553     fi
3554   fi
3555   #
3556   AC_MSG_CHECKING([if inet_ntoa_r might be used])
3557   if test "$tst_links_inet_ntoa_r" = "yes" &&
3558      test "$tst_proto_inet_ntoa_r" = "yes" &&
3559      test "$tst_compi_inet_ntoa_r" = "yes" &&
3560      test "$tst_allow_inet_ntoa_r" = "yes"; then
3561     AC_MSG_RESULT([yes])
3562     AC_DEFINE_UNQUOTED(HAVE_INET_NTOA_R, 1,
3563       [Define to 1 if you have the inet_ntoa_r function.])
3564     dnl AC_DEFINE_UNQUOTED(INET_NTOA_R_ARGS, $tst_nargs_inet_ntoa_r,
3565     dnl   [Specifies the number of arguments to inet_ntoa_r])
3566     #
3567     if test "$tst_nargs_inet_ntoa_r" -eq "2"; then
3568       AC_DEFINE(HAVE_INET_NTOA_R_2, 1, [inet_ntoa_r() takes 2 args])
3569     elif test "$tst_nargs_inet_ntoa_r" -eq "3"; then
3570       AC_DEFINE(HAVE_INET_NTOA_R_3, 1, [inet_ntoa_r() takes 3 args])
3571     fi
3572     #
3573     curl_cv_func_inet_ntoa_r="yes"
3574   else
3575     AC_MSG_RESULT([no])
3576     curl_cv_func_inet_ntoa_r="no"
3577   fi
3578 ])
3579
3580
3581 dnl CURL_CHECK_FUNC_INET_NTOP
3582 dnl -------------------------------------------------
3583 dnl Verify if inet_ntop is available, prototyped, can
3584 dnl be compiled and seems to work. If all of these are
3585 dnl true, and usage has not been previously disallowed
3586 dnl with shell variable curl_disallow_inet_ntop, then
3587 dnl HAVE_INET_NTOP will be defined.
3588
3589 AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
3590   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3591   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
3592   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3593   #
3594   tst_links_inet_ntop="unknown"
3595   tst_proto_inet_ntop="unknown"
3596   tst_compi_inet_ntop="unknown"
3597   tst_works_inet_ntop="unknown"
3598   tst_allow_inet_ntop="unknown"
3599   #
3600   AC_MSG_CHECKING([if inet_ntop can be linked])
3601   AC_LINK_IFELSE([
3602     AC_LANG_FUNC_LINK_TRY([inet_ntop])
3603   ],[
3604     AC_MSG_RESULT([yes])
3605     tst_links_inet_ntop="yes"
3606   ],[
3607     AC_MSG_RESULT([no])
3608     tst_links_inet_ntop="no"
3609   ])
3610   #
3611   if test "$tst_links_inet_ntop" = "yes"; then
3612     AC_MSG_CHECKING([if inet_ntop is prototyped])
3613     AC_EGREP_CPP([inet_ntop],[
3614       $curl_includes_arpa_inet
3615     ],[
3616       AC_MSG_RESULT([yes])
3617       tst_proto_inet_ntop="yes"
3618     ],[
3619       AC_MSG_RESULT([no])
3620       tst_proto_inet_ntop="no"
3621     ])
3622   fi
3623   #
3624   if test "$tst_proto_inet_ntop" = "yes"; then
3625     AC_MSG_CHECKING([if inet_ntop is compilable])
3626     AC_COMPILE_IFELSE([
3627       AC_LANG_PROGRAM([[
3628         $curl_includes_arpa_inet
3629       ]],[[
3630         if(0 != inet_ntop(0, 0, 0, 0))
3631           return 1;
3632       ]])
3633     ],[
3634       AC_MSG_RESULT([yes])
3635       tst_compi_inet_ntop="yes"
3636     ],[
3637       AC_MSG_RESULT([no])
3638       tst_compi_inet_ntop="no"
3639     ])
3640   fi
3641   #
3642   dnl only do runtime verification when not cross-compiling
3643   if test "x$cross_compiling" != "xyes" &&
3644     test "$tst_compi_inet_ntop" = "yes"; then
3645     AC_MSG_CHECKING([if inet_ntop seems to work])
3646     AC_RUN_IFELSE([
3647       AC_LANG_PROGRAM([[
3648         $curl_includes_stdlib
3649         $curl_includes_arpa_inet
3650         $curl_includes_string
3651       ]],[[
3652         char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
3653         char ipv4res[sizeof "255.255.255.255"];
3654         unsigned char ipv6a[26];
3655         unsigned char ipv4a[5];
3656         char *ipv6ptr = 0;
3657         char *ipv4ptr = 0;
3658         /* - */
3659         ipv4res[0] = '\0';
3660         ipv4a[0] = 0xc0;
3661         ipv4a[1] = 0xa8;
3662         ipv4a[2] = 0x64;
3663         ipv4a[3] = 0x01;
3664         ipv4a[4] = 0x01;
3665         /* - */
3666         ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
3667         if(!ipv4ptr)
3668           exit(1); /* fail */
3669         if(ipv4ptr != ipv4res)
3670           exit(1); /* fail */
3671         if(!ipv4ptr[0])
3672           exit(1); /* fail */
3673         if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
3674           exit(1); /* fail */
3675         /* - */
3676         ipv6res[0] = '\0';
3677         memset(ipv6a, 0, sizeof(ipv6a));
3678         ipv6a[0] = 0xfe;
3679         ipv6a[1] = 0x80;
3680         ipv6a[8] = 0x02;
3681         ipv6a[9] = 0x14;
3682         ipv6a[10] = 0x4f;
3683         ipv6a[11] = 0xff;
3684         ipv6a[12] = 0xfe;
3685         ipv6a[13] = 0x0b;
3686         ipv6a[14] = 0x76;
3687         ipv6a[15] = 0xc8;
3688         ipv6a[25] = 0x01;
3689         /* - */
3690         ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
3691         if(!ipv6ptr)
3692           exit(1); /* fail */
3693         if(ipv6ptr != ipv6res)
3694           exit(1); /* fail */
3695         if(!ipv6ptr[0])
3696           exit(1); /* fail */
3697         if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0)
3698           exit(1); /* fail */
3699         /* - */
3700         exit(0);
3701       ]])
3702     ],[
3703       AC_MSG_RESULT([yes])
3704       tst_works_inet_ntop="yes"
3705     ],[
3706       AC_MSG_RESULT([no])
3707       tst_works_inet_ntop="no"
3708     ])
3709   fi
3710   #
3711   if test "$tst_compi_inet_ntop" = "yes" &&
3712     test "$tst_works_inet_ntop" != "no"; then
3713     AC_MSG_CHECKING([if inet_ntop usage allowed])
3714     if test "x$curl_disallow_inet_ntop" != "xyes"; then
3715       AC_MSG_RESULT([yes])
3716       tst_allow_inet_ntop="yes"
3717     else
3718       AC_MSG_RESULT([no])
3719       tst_allow_inet_ntop="no"
3720     fi
3721   fi
3722   #
3723   AC_MSG_CHECKING([if inet_ntop might be used])
3724   if test "$tst_links_inet_ntop" = "yes" &&
3725      test "$tst_proto_inet_ntop" = "yes" &&
3726      test "$tst_compi_inet_ntop" = "yes" &&
3727      test "$tst_allow_inet_ntop" = "yes" &&
3728      test "$tst_works_inet_ntop" != "no"; then
3729     AC_MSG_RESULT([yes])
3730     AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, 1,
3731       [Define to 1 if you have a IPv6 capable working inet_ntop function.])
3732     curl_cv_func_inet_ntop="yes"
3733   else
3734     AC_MSG_RESULT([no])
3735     curl_cv_func_inet_ntop="no"
3736   fi
3737 ])
3738
3739
3740 dnl CURL_CHECK_FUNC_INET_PTON
3741 dnl -------------------------------------------------
3742 dnl Verify if inet_pton is available, prototyped, can
3743 dnl be compiled and seems to work. If all of these are
3744 dnl true, and usage has not been previously disallowed
3745 dnl with shell variable curl_disallow_inet_pton, then
3746 dnl HAVE_INET_PTON will be defined.
3747
3748 AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [
3749   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3750   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
3751   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3752   #
3753   tst_links_inet_pton="unknown"
3754   tst_proto_inet_pton="unknown"
3755   tst_compi_inet_pton="unknown"
3756   tst_works_inet_pton="unknown"
3757   tst_allow_inet_pton="unknown"
3758   #
3759   AC_MSG_CHECKING([if inet_pton can be linked])
3760   AC_LINK_IFELSE([
3761     AC_LANG_FUNC_LINK_TRY([inet_pton])
3762   ],[
3763     AC_MSG_RESULT([yes])
3764     tst_links_inet_pton="yes"
3765   ],[
3766     AC_MSG_RESULT([no])
3767     tst_links_inet_pton="no"
3768   ])
3769   #
3770   if test "$tst_links_inet_pton" = "yes"; then
3771     AC_MSG_CHECKING([if inet_pton is prototyped])
3772     AC_EGREP_CPP([inet_pton],[
3773       $curl_includes_arpa_inet
3774     ],[
3775       AC_MSG_RESULT([yes])
3776       tst_proto_inet_pton="yes"
3777     ],[
3778       AC_MSG_RESULT([no])
3779       tst_proto_inet_pton="no"
3780     ])
3781   fi
3782   #
3783   if test "$tst_proto_inet_pton" = "yes"; then
3784     AC_MSG_CHECKING([if inet_pton is compilable])
3785     AC_COMPILE_IFELSE([
3786       AC_LANG_PROGRAM([[
3787         $curl_includes_arpa_inet
3788       ]],[[
3789         if(0 != inet_pton(0, 0, 0))
3790           return 1;
3791       ]])
3792     ],[
3793       AC_MSG_RESULT([yes])
3794       tst_compi_inet_pton="yes"
3795     ],[
3796       AC_MSG_RESULT([no])
3797       tst_compi_inet_pton="no"
3798     ])
3799   fi
3800   #
3801   dnl only do runtime verification when not cross-compiling
3802   if test "x$cross_compiling" != "xyes" &&
3803     test "$tst_compi_inet_pton" = "yes"; then
3804     AC_MSG_CHECKING([if inet_pton seems to work])
3805     AC_RUN_IFELSE([
3806       AC_LANG_PROGRAM([[
3807         $curl_includes_stdlib
3808         $curl_includes_arpa_inet
3809         $curl_includes_string
3810       ]],[[
3811         unsigned char ipv6a[16+1];
3812         unsigned char ipv4a[4+1];
3813         const char *ipv6src = "fe80::214:4fff:fe0b:76c8";
3814         const char *ipv4src = "192.168.100.1";
3815         /* - */
3816         memset(ipv4a, 1, sizeof(ipv4a));
3817         if(1 != inet_pton(AF_INET, ipv4src, ipv4a))
3818           exit(1); /* fail */
3819         /* - */
3820         if( (ipv4a[0] != 0xc0) ||
3821             (ipv4a[1] != 0xa8) ||
3822             (ipv4a[2] != 0x64) ||
3823             (ipv4a[3] != 0x01) ||
3824             (ipv4a[4] != 0x01) )
3825           exit(1); /* fail */
3826         /* - */
3827         memset(ipv6a, 1, sizeof(ipv6a));
3828         if(1 != inet_pton(AF_INET6, ipv6src, ipv6a))
3829           exit(1); /* fail */
3830         /* - */
3831         if( (ipv6a[0]  != 0xfe) ||
3832             (ipv6a[1]  != 0x80) ||
3833             (ipv6a[8]  != 0x02) ||
3834             (ipv6a[9]  != 0x14) ||
3835             (ipv6a[10] != 0x4f) ||
3836             (ipv6a[11] != 0xff) ||
3837             (ipv6a[12] != 0xfe) ||
3838             (ipv6a[13] != 0x0b) ||
3839             (ipv6a[14] != 0x76) ||
3840             (ipv6a[15] != 0xc8) ||
3841             (ipv6a[16] != 0x01) )
3842           exit(1); /* fail */
3843         /* - */
3844         if( (ipv6a[2]  != 0x0) ||
3845             (ipv6a[3]  != 0x0) ||
3846             (ipv6a[4]  != 0x0) ||
3847             (ipv6a[5]  != 0x0) ||
3848             (ipv6a[6]  != 0x0) ||
3849             (ipv6a[7]  != 0x0) )
3850           exit(1); /* fail */
3851         /* - */
3852         exit(0);
3853       ]])
3854     ],[
3855       AC_MSG_RESULT([yes])
3856       tst_works_inet_pton="yes"
3857     ],[
3858       AC_MSG_RESULT([no])
3859       tst_works_inet_pton="no"
3860     ])
3861   fi
3862   #
3863   if test "$tst_compi_inet_pton" = "yes" &&
3864     test "$tst_works_inet_pton" != "no"; then
3865     AC_MSG_CHECKING([if inet_pton usage allowed])
3866     if test "x$curl_disallow_inet_pton" != "xyes"; then
3867       AC_MSG_RESULT([yes])
3868       tst_allow_inet_pton="yes"
3869     else
3870       AC_MSG_RESULT([no])
3871       tst_allow_inet_pton="no"
3872     fi
3873   fi
3874   #
3875   AC_MSG_CHECKING([if inet_pton might be used])
3876   if test "$tst_links_inet_pton" = "yes" &&
3877      test "$tst_proto_inet_pton" = "yes" &&
3878      test "$tst_compi_inet_pton" = "yes" &&
3879      test "$tst_allow_inet_pton" = "yes" &&
3880      test "$tst_works_inet_pton" != "no"; then
3881     AC_MSG_RESULT([yes])
3882     AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1,
3883       [Define to 1 if you have a IPv6 capable working inet_pton function.])
3884     curl_cv_func_inet_pton="yes"
3885   else
3886     AC_MSG_RESULT([no])
3887     curl_cv_func_inet_pton="no"
3888   fi
3889 ])
3890
3891
3892 dnl CURL_CHECK_FUNC_IOCTL
3893 dnl -------------------------------------------------
3894 dnl Verify if ioctl is available, prototyped, and
3895 dnl can be compiled. If all of these are true, and
3896 dnl usage has not been previously disallowed with
3897 dnl shell variable curl_disallow_ioctl, then
3898 dnl HAVE_IOCTL will be defined.
3899
3900 AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [
3901   AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
3902   #
3903   tst_links_ioctl="unknown"
3904   tst_proto_ioctl="unknown"
3905   tst_compi_ioctl="unknown"
3906   tst_allow_ioctl="unknown"
3907   #
3908   AC_MSG_CHECKING([if ioctl can be linked])
3909   AC_LINK_IFELSE([
3910     AC_LANG_FUNC_LINK_TRY([ioctl])
3911   ],[
3912     AC_MSG_RESULT([yes])
3913     tst_links_ioctl="yes"
3914   ],[
3915     AC_MSG_RESULT([no])
3916     tst_links_ioctl="no"
3917   ])
3918   #
3919   if test "$tst_links_ioctl" = "yes"; then
3920     AC_MSG_CHECKING([if ioctl is prototyped])
3921     AC_EGREP_CPP([ioctl],[
3922       $curl_includes_stropts
3923     ],[
3924       AC_MSG_RESULT([yes])
3925       tst_proto_ioctl="yes"
3926     ],[
3927       AC_MSG_RESULT([no])
3928       tst_proto_ioctl="no"
3929     ])
3930   fi
3931   #
3932   if test "$tst_proto_ioctl" = "yes"; then
3933     AC_MSG_CHECKING([if ioctl is compilable])
3934     AC_COMPILE_IFELSE([
3935       AC_LANG_PROGRAM([[
3936         $curl_includes_stropts
3937       ]],[[
3938         if(0 != ioctl(0, 0, 0))
3939           return 1;
3940       ]])
3941     ],[
3942       AC_MSG_RESULT([yes])
3943       tst_compi_ioctl="yes"
3944     ],[
3945       AC_MSG_RESULT([no])
3946       tst_compi_ioctl="no"
3947     ])
3948   fi
3949   #
3950   if test "$tst_compi_ioctl" = "yes"; then
3951     AC_MSG_CHECKING([if ioctl usage allowed])
3952     if test "x$curl_disallow_ioctl" != "xyes"; then
3953       AC_MSG_RESULT([yes])
3954       tst_allow_ioctl="yes"
3955     else
3956       AC_MSG_RESULT([no])
3957       tst_allow_ioctl="no"
3958     fi
3959   fi
3960   #
3961   AC_MSG_CHECKING([if ioctl might be used])
3962   if test "$tst_links_ioctl" = "yes" &&
3963      test "$tst_proto_ioctl" = "yes" &&
3964      test "$tst_compi_ioctl" = "yes" &&
3965      test "$tst_allow_ioctl" = "yes"; then
3966     AC_MSG_RESULT([yes])
3967     AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
3968       [Define to 1 if you have the ioctl function.])
3969     curl_cv_func_ioctl="yes"
3970     CURL_CHECK_FUNC_IOCTL_FIONBIO
3971     CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
3972   else
3973     AC_MSG_RESULT([no])
3974     curl_cv_func_ioctl="no"
3975   fi
3976 ])
3977
3978
3979 dnl CURL_CHECK_FUNC_IOCTL_FIONBIO
3980 dnl -------------------------------------------------
3981 dnl Verify if ioctl with the FIONBIO command is
3982 dnl available, can be compiled, and seems to work. If
3983 dnl all of these are true, then HAVE_IOCTL_FIONBIO
3984 dnl will be defined.
3985
3986 AC_DEFUN([CURL_CHECK_FUNC_IOCTL_FIONBIO], [
3987   #
3988   tst_compi_ioctl_fionbio="unknown"
3989   tst_allow_ioctl_fionbio="unknown"
3990   #
3991   if test "$curl_cv_func_ioctl" = "yes"; then
3992     AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
3993     AC_COMPILE_IFELSE([
3994       AC_LANG_PROGRAM([[
3995         $curl_includes_stropts
3996       ]],[[
3997         int flags = 0;
3998         if(0 != ioctl(0, FIONBIO, &flags))
3999           return 1;
4000       ]])
4001     ],[
4002       AC_MSG_RESULT([yes])
4003       tst_compi_ioctl_fionbio="yes"
4004     ],[
4005       AC_MSG_RESULT([no])
4006       tst_compi_ioctl_fionbio="no"
4007     ])
4008   fi
4009   #
4010   if test "$tst_compi_ioctl_fionbio" = "yes"; then
4011     AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
4012     if test "x$curl_disallow_ioctl_fionbio" != "xyes"; then
4013       AC_MSG_RESULT([yes])
4014       tst_allow_ioctl_fionbio="yes"
4015     else
4016       AC_MSG_RESULT([no])
4017       tst_allow_ioctl_fionbio="no"
4018     fi
4019   fi
4020   #
4021   AC_MSG_CHECKING([if ioctl FIONBIO might be used])
4022   if test "$tst_compi_ioctl_fionbio" = "yes" &&
4023      test "$tst_allow_ioctl_fionbio" = "yes"; then
4024     AC_MSG_RESULT([yes])
4025     AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
4026       [Define to 1 if you have a working ioctl FIONBIO function.])
4027     curl_cv_func_ioctl_fionbio="yes"
4028   else
4029     AC_MSG_RESULT([no])
4030     curl_cv_func_ioctl_fionbio="no"
4031   fi
4032 ])
4033
4034
4035 dnl CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
4036 dnl -------------------------------------------------
4037 dnl Verify if ioctl with the SIOCGIFADDR command is available,
4038 dnl struct ifreq is defined, they can be compiled, and seem to
4039 dnl work. If all of these are true, then HAVE_IOCTL_SIOCGIFADDR
4040 dnl will be defined.
4041
4042 AC_DEFUN([CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR], [
4043   #
4044   tst_compi_ioctl_siocgifaddr="unknown"
4045   tst_allow_ioctl_siocgifaddr="unknown"
4046   #
4047   if test "$curl_cv_func_ioctl" = "yes"; then
4048     AC_MSG_CHECKING([if ioctl SIOCGIFADDR is compilable])
4049     AC_COMPILE_IFELSE([
4050       AC_LANG_PROGRAM([[
4051         $curl_includes_stropts
4052         #include <net/if.h>
4053       ]],[[
4054         struct ifreq ifr;
4055         if(0 != ioctl(0, SIOCGIFADDR, &ifr))
4056           return 1;
4057       ]])
4058     ],[
4059       AC_MSG_RESULT([yes])
4060       tst_compi_ioctl_siocgifaddr="yes"
4061     ],[
4062       AC_MSG_RESULT([no])
4063       tst_compi_ioctl_siocgifaddr="no"
4064     ])
4065   fi
4066   #
4067   if test "$tst_compi_ioctl_siocgifaddr" = "yes"; then
4068     AC_MSG_CHECKING([if ioctl SIOCGIFADDR usage allowed])
4069     if test "x$curl_disallow_ioctl_siocgifaddr" != "xyes"; then
4070       AC_MSG_RESULT([yes])
4071       tst_allow_ioctl_siocgifaddr="yes"
4072     else
4073       AC_MSG_RESULT([no])
4074       tst_allow_ioctl_siocgifaddr="no"
4075     fi
4076   fi
4077   #
4078   AC_MSG_CHECKING([if ioctl SIOCGIFADDR might be used])
4079   if test "$tst_compi_ioctl_siocgifaddr" = "yes" &&
4080      test "$tst_allow_ioctl_siocgifaddr" = "yes"; then
4081     AC_MSG_RESULT([yes])
4082     AC_DEFINE_UNQUOTED(HAVE_IOCTL_SIOCGIFADDR, 1,
4083       [Define to 1 if you have a working ioctl SIOCGIFADDR function.])
4084     curl_cv_func_ioctl_siocgifaddr="yes"
4085   else
4086     AC_MSG_RESULT([no])
4087     curl_cv_func_ioctl_siocgifaddr="no"
4088   fi
4089 ])
4090
4091
4092 dnl CURL_CHECK_FUNC_IOCTLSOCKET
4093 dnl -------------------------------------------------
4094 dnl Verify if ioctlsocket is available, prototyped, and
4095 dnl can be compiled. If all of these are true, and
4096 dnl usage has not been previously disallowed with
4097 dnl shell variable curl_disallow_ioctlsocket, then
4098 dnl HAVE_IOCTLSOCKET will be defined.
4099
4100 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [
4101   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
4102   #
4103   tst_links_ioctlsocket="unknown"
4104   tst_proto_ioctlsocket="unknown"
4105   tst_compi_ioctlsocket="unknown"
4106   tst_allow_ioctlsocket="unknown"
4107   #
4108   AC_MSG_CHECKING([if ioctlsocket can be linked])
4109   AC_LINK_IFELSE([
4110     AC_LANG_PROGRAM([[
4111       $curl_includes_winsock2
4112     ]],[[
4113       if(0 != ioctlsocket(0, 0, 0))
4114         return 1;
4115     ]])
4116   ],[
4117     AC_MSG_RESULT([yes])
4118     tst_links_ioctlsocket="yes"
4119   ],[
4120     AC_MSG_RESULT([no])
4121     tst_links_ioctlsocket="no"
4122   ])
4123   #
4124   if test "$tst_links_ioctlsocket" = "yes"; then
4125     AC_MSG_CHECKING([if ioctlsocket is prototyped])
4126     AC_EGREP_CPP([ioctlsocket],[
4127       $curl_includes_winsock2
4128     ],[
4129       AC_MSG_RESULT([yes])
4130       tst_proto_ioctlsocket="yes"
4131     ],[
4132       AC_MSG_RESULT([no])
4133       tst_proto_ioctlsocket="no"
4134     ])
4135   fi
4136   #
4137   if test "$tst_proto_ioctlsocket" = "yes"; then
4138     AC_MSG_CHECKING([if ioctlsocket is compilable])
4139     AC_COMPILE_IFELSE([
4140       AC_LANG_PROGRAM([[
4141         $curl_includes_winsock2
4142       ]],[[
4143         if(0 != ioctlsocket(0, 0, 0))
4144           return 1;
4145       ]])
4146     ],[
4147       AC_MSG_RESULT([yes])
4148       tst_compi_ioctlsocket="yes"
4149     ],[
4150       AC_MSG_RESULT([no])
4151       tst_compi_ioctlsocket="no"
4152     ])
4153   fi
4154   #
4155   if test "$tst_compi_ioctlsocket" = "yes"; then
4156     AC_MSG_CHECKING([if ioctlsocket usage allowed])
4157     if test "x$curl_disallow_ioctlsocket" != "xyes"; then
4158       AC_MSG_RESULT([yes])
4159       tst_allow_ioctlsocket="yes"
4160     else
4161       AC_MSG_RESULT([no])
4162       tst_allow_ioctlsocket="no"
4163     fi
4164   fi
4165   #
4166   AC_MSG_CHECKING([if ioctlsocket might be used])
4167   if test "$tst_links_ioctlsocket" = "yes" &&
4168      test "$tst_proto_ioctlsocket" = "yes" &&
4169      test "$tst_compi_ioctlsocket" = "yes" &&
4170      test "$tst_allow_ioctlsocket" = "yes"; then
4171     AC_MSG_RESULT([yes])
4172     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
4173       [Define to 1 if you have the ioctlsocket function.])
4174     curl_cv_func_ioctlsocket="yes"
4175     CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
4176   else
4177     AC_MSG_RESULT([no])
4178     curl_cv_func_ioctlsocket="no"
4179   fi
4180 ])
4181
4182
4183 dnl CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
4184 dnl -------------------------------------------------
4185 dnl Verify if ioctlsocket with the FIONBIO command is
4186 dnl available, can be compiled, and seems to work. If
4187 dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
4188 dnl will be defined.
4189
4190 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
4191   #
4192   tst_compi_ioctlsocket_fionbio="unknown"
4193   tst_allow_ioctlsocket_fionbio="unknown"
4194   #
4195   if test "$curl_cv_func_ioctlsocket" = "yes"; then
4196     AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
4197     AC_COMPILE_IFELSE([
4198       AC_LANG_PROGRAM([[
4199         $curl_includes_winsock2
4200       ]],[[
4201         int flags = 0;
4202         if(0 != ioctlsocket(0, FIONBIO, &flags))
4203           return 1;
4204       ]])
4205     ],[
4206       AC_MSG_RESULT([yes])
4207       tst_compi_ioctlsocket_fionbio="yes"
4208     ],[
4209       AC_MSG_RESULT([no])
4210       tst_compi_ioctlsocket_fionbio="no"
4211     ])
4212   fi
4213   #
4214   if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
4215     AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
4216     if test "x$curl_disallow_ioctlsocket_fionbio" != "xyes"; then
4217       AC_MSG_RESULT([yes])
4218       tst_allow_ioctlsocket_fionbio="yes"
4219     else
4220       AC_MSG_RESULT([no])
4221       tst_allow_ioctlsocket_fionbio="no"
4222     fi
4223   fi
4224   #
4225   AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
4226   if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
4227      test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
4228     AC_MSG_RESULT([yes])
4229     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
4230       [Define to 1 if you have a working ioctlsocket FIONBIO function.])
4231     curl_cv_func_ioctlsocket_fionbio="yes"
4232   else
4233     AC_MSG_RESULT([no])
4234     curl_cv_func_ioctlsocket_fionbio="no"
4235   fi
4236 ])
4237
4238
4239 dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
4240 dnl -------------------------------------------------
4241 dnl Verify if IoctlSocket is available, prototyped, and
4242 dnl can be compiled. If all of these are true, and
4243 dnl usage has not been previously disallowed with
4244 dnl shell variable curl_disallow_ioctlsocket_camel,
4245 dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
4246
4247 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
4248   AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
4249   #
4250   tst_links_ioctlsocket_camel="unknown"
4251   tst_proto_ioctlsocket_camel="unknown"
4252   tst_compi_ioctlsocket_camel="unknown"
4253   tst_allow_ioctlsocket_camel="unknown"
4254   #
4255   AC_MSG_CHECKING([if IoctlSocket can be linked])
4256   AC_LINK_IFELSE([
4257     AC_LANG_FUNC_LINK_TRY([IoctlSocket])
4258   ],[
4259     AC_MSG_RESULT([yes])
4260     tst_links_ioctlsocket_camel="yes"
4261   ],[
4262     AC_MSG_RESULT([no])
4263     tst_links_ioctlsocket_camel="no"
4264   ])
4265   #
4266   if test "$tst_links_ioctlsocket_camel" = "yes"; then
4267     AC_MSG_CHECKING([if IoctlSocket is prototyped])
4268     AC_EGREP_CPP([IoctlSocket],[
4269       $curl_includes_stropts
4270     ],[
4271       AC_MSG_RESULT([yes])
4272       tst_proto_ioctlsocket_camel="yes"
4273     ],[
4274       AC_MSG_RESULT([no])
4275       tst_proto_ioctlsocket_camel="no"
4276     ])
4277   fi
4278   #
4279   if test "$tst_proto_ioctlsocket_camel" = "yes"; then
4280     AC_MSG_CHECKING([if IoctlSocket is compilable])
4281     AC_COMPILE_IFELSE([
4282       AC_LANG_PROGRAM([[
4283         $curl_includes_stropts
4284       ]],[[
4285         if(0 != IoctlSocket(0, 0, 0))
4286           return 1;
4287       ]])
4288     ],[
4289       AC_MSG_RESULT([yes])
4290       tst_compi_ioctlsocket_camel="yes"
4291     ],[
4292       AC_MSG_RESULT([no])
4293       tst_compi_ioctlsocket_camel="no"
4294     ])
4295   fi
4296   #
4297   if test "$tst_compi_ioctlsocket_camel" = "yes"; then
4298     AC_MSG_CHECKING([if IoctlSocket usage allowed])
4299     if test "x$curl_disallow_ioctlsocket_camel" != "xyes"; then
4300       AC_MSG_RESULT([yes])
4301       tst_allow_ioctlsocket_camel="yes"
4302     else
4303       AC_MSG_RESULT([no])
4304       tst_allow_ioctlsocket_camel="no"
4305     fi
4306   fi
4307   #
4308   AC_MSG_CHECKING([if IoctlSocket might be used])
4309   if test "$tst_links_ioctlsocket_camel" = "yes" &&
4310      test "$tst_proto_ioctlsocket_camel" = "yes" &&
4311      test "$tst_compi_ioctlsocket_camel" = "yes" &&
4312      test "$tst_allow_ioctlsocket_camel" = "yes"; then
4313     AC_MSG_RESULT([yes])
4314     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
4315       [Define to 1 if you have the IoctlSocket camel case function.])
4316     curl_cv_func_ioctlsocket_camel="yes"
4317     CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
4318   else
4319     AC_MSG_RESULT([no])
4320     curl_cv_func_ioctlsocket_camel="no"
4321   fi
4322 ])
4323
4324
4325 dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
4326 dnl -------------------------------------------------
4327 dnl Verify if IoctlSocket with FIONBIO command is available,
4328 dnl can be compiled, and seems to work. If all of these are
4329 dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
4330
4331 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
4332   #
4333   tst_compi_ioctlsocket_camel_fionbio="unknown"
4334   tst_allow_ioctlsocket_camel_fionbio="unknown"
4335   #
4336   if test "$curl_cv_func_ioctlsocket_camel" = "yes"; then
4337     AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
4338     AC_COMPILE_IFELSE([
4339       AC_LANG_PROGRAM([[
4340         $curl_includes_stropts
4341       ]],[[
4342         long flags = 0;
4343         if(0 != ioctlsocket(0, FIONBIO, &flags))
4344           return 1;
4345       ]])
4346     ],[
4347       AC_MSG_RESULT([yes])
4348       tst_compi_ioctlsocket_camel_fionbio="yes"
4349     ],[
4350       AC_MSG_RESULT([no])
4351       tst_compi_ioctlsocket_camel_fionbio="no"
4352     ])
4353   fi
4354   #
4355   if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
4356     AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
4357     if test "x$curl_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
4358       AC_MSG_RESULT([yes])
4359       tst_allow_ioctlsocket_camel_fionbio="yes"
4360     else
4361       AC_MSG_RESULT([no])
4362       tst_allow_ioctlsocket_camel_fionbio="no"
4363     fi
4364   fi
4365   #
4366   AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
4367   if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
4368      test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
4369     AC_MSG_RESULT([yes])
4370     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
4371       [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
4372     curl_cv_func_ioctlsocket_camel_fionbio="yes"
4373   else
4374     AC_MSG_RESULT([no])
4375     curl_cv_func_ioctlsocket_camel_fionbio="no"
4376   fi
4377 ])
4378
4379
4380 dnl CURL_CHECK_FUNC_LISTXATTR
4381 dnl -------------------------------------------------
4382 dnl Verify if listxattr is available, prototyped, and
4383 dnl can be compiled. If all of these are true, and
4384 dnl usage has not been previously disallowed with
4385 dnl shell variable curl_disallow_listxattr, then
4386 dnl HAVE_LISTXATTR will be defined.
4387
4388 AC_DEFUN([CURL_CHECK_FUNC_LISTXATTR], [
4389   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
4390   #
4391   tst_links_listxattr="unknown"
4392   tst_proto_listxattr="unknown"
4393   tst_compi_listxattr="unknown"
4394   tst_allow_listxattr="unknown"
4395   tst_nargs_listxattr="unknown"
4396   #
4397   AC_MSG_CHECKING([if listxattr can be linked])
4398   AC_LINK_IFELSE([
4399     AC_LANG_FUNC_LINK_TRY([listxattr])
4400   ],[
4401     AC_MSG_RESULT([yes])
4402     tst_links_listxattr="yes"
4403   ],[
4404     AC_MSG_RESULT([no])
4405     tst_links_listxattr="no"
4406   ])
4407   #
4408   if test "$tst_links_listxattr" = "yes"; then
4409     AC_MSG_CHECKING([if listxattr is prototyped])
4410     AC_EGREP_CPP([listxattr],[
4411       $curl_includes_sys_xattr
4412     ],[
4413       AC_MSG_RESULT([yes])
4414       tst_proto_listxattr="yes"
4415     ],[
4416       AC_MSG_RESULT([no])
4417       tst_proto_listxattr="no"
4418     ])
4419   fi
4420   #
4421   if test "$tst_proto_listxattr" = "yes"; then
4422     if test "$tst_nargs_listxattr" = "unknown"; then
4423       AC_MSG_CHECKING([if listxattr takes 3 args.])
4424       AC_COMPILE_IFELSE([
4425         AC_LANG_PROGRAM([[
4426           $curl_includes_sys_xattr
4427         ]],[[
4428           if(0 != listxattr(0, 0, 0))
4429             return 1;
4430         ]])
4431       ],[
4432         AC_MSG_RESULT([yes])
4433         tst_compi_listxattr="yes"
4434         tst_nargs_listxattr="3"
4435       ],[
4436         AC_MSG_RESULT([no])
4437         tst_compi_listxattr="no"
4438       ])
4439     fi
4440     if test "$tst_nargs_listxattr" = "unknown"; then
4441       AC_MSG_CHECKING([if listxattr takes 4 args.])
4442       AC_COMPILE_IFELSE([
4443         AC_LANG_PROGRAM([[
4444           $curl_includes_sys_xattr
4445         ]],[[
4446           if(0 != listxattr(0, 0, 0, 0))
4447             return 1;
4448         ]])
4449       ],[
4450         AC_MSG_RESULT([yes])
4451         tst_compi_listxattr="yes"
4452         tst_nargs_listxattr="4"
4453       ],[
4454         AC_MSG_RESULT([no])
4455         tst_compi_listxattr="no"
4456       ])
4457     fi
4458     AC_MSG_CHECKING([if listxattr is compilable])
4459     if test "$tst_compi_listxattr" = "yes"; then
4460       AC_MSG_RESULT([yes])
4461     else
4462       AC_MSG_RESULT([no])
4463     fi
4464   fi
4465   #
4466   if test "$tst_compi_listxattr" = "yes"; then
4467     AC_MSG_CHECKING([if listxattr usage allowed])
4468     if test "x$curl_disallow_listxattr" != "xyes"; then
4469       AC_MSG_RESULT([yes])
4470       tst_allow_listxattr="yes"
4471     else
4472       AC_MSG_RESULT([no])
4473       tst_allow_listxattr="no"
4474     fi
4475   fi
4476   #
4477   AC_MSG_CHECKING([if listxattr might be used])
4478   if test "$tst_links_listxattr" = "yes" &&
4479      test "$tst_proto_listxattr" = "yes" &&
4480      test "$tst_compi_listxattr" = "yes" &&
4481      test "$tst_allow_listxattr" = "yes"; then
4482     AC_MSG_RESULT([yes])
4483     AC_DEFINE_UNQUOTED(HAVE_LISTXATTR, 1,
4484       [Define to 1 if you have the listxattr function.])
4485     dnl AC_DEFINE_UNQUOTED(LISTXATTR_ARGS, $tst_nargs_listxattr,
4486     dnl   [Specifies the number of arguments to listxattr])
4487     #
4488     if test "$tst_nargs_listxattr" -eq "3"; then
4489       AC_DEFINE(HAVE_LISTXATTR_3, 1, [listxattr() takes 3 args])
4490     elif test "$tst_nargs_listxattr" -eq "4"; then
4491       AC_DEFINE(HAVE_LISTXATTR_4, 1, [listxattr() takes 4 args])
4492     fi
4493     #
4494     curl_cv_func_listxattr="yes"
4495   else
4496     AC_MSG_RESULT([no])
4497     curl_cv_func_listxattr="no"
4498   fi
4499 ])
4500
4501
4502 dnl CURL_CHECK_FUNC_LOCALTIME_R
4503 dnl -------------------------------------------------
4504 dnl Verify if localtime_r is available, prototyped, can
4505 dnl be compiled and seems to work. If all of these are
4506 dnl true, and usage has not been previously disallowed
4507 dnl with shell variable curl_disallow_localtime_r, then
4508 dnl HAVE_LOCALTIME_R will be defined.
4509
4510 AC_DEFUN([CURL_CHECK_FUNC_LOCALTIME_R], [
4511   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4512   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
4513   #
4514   tst_links_localtime_r="unknown"
4515   tst_proto_localtime_r="unknown"
4516   tst_compi_localtime_r="unknown"
4517   tst_works_localtime_r="unknown"
4518   tst_allow_localtime_r="unknown"
4519   #
4520   AC_MSG_CHECKING([if localtime_r can be linked])
4521   AC_LINK_IFELSE([
4522     AC_LANG_FUNC_LINK_TRY([localtime_r])
4523   ],[
4524     AC_MSG_RESULT([yes])
4525     tst_links_localtime_r="yes"
4526   ],[
4527     AC_MSG_RESULT([no])
4528     tst_links_localtime_r="no"
4529   ])
4530   #
4531   if test "$tst_links_localtime_r" = "yes"; then
4532     AC_MSG_CHECKING([if localtime_r is prototyped])
4533     AC_EGREP_CPP([localtime_r],[
4534       $curl_includes_time
4535     ],[
4536       AC_MSG_RESULT([yes])
4537       tst_proto_localtime_r="yes"
4538     ],[
4539       AC_MSG_RESULT([no])
4540       tst_proto_localtime_r="no"
4541     ])
4542   fi
4543   #
4544   if test "$tst_proto_localtime_r" = "yes"; then
4545     AC_MSG_CHECKING([if localtime_r is compilable])
4546     AC_COMPILE_IFELSE([
4547       AC_LANG_PROGRAM([[
4548         $curl_includes_time
4549       ]],[[
4550         if(0 != localtime_r(0, 0))
4551           return 1;
4552       ]])
4553     ],[
4554       AC_MSG_RESULT([yes])
4555       tst_compi_localtime_r="yes"
4556     ],[
4557       AC_MSG_RESULT([no])
4558       tst_compi_localtime_r="no"
4559     ])
4560   fi
4561   #
4562   dnl only do runtime verification when not cross-compiling
4563   if test "x$cross_compiling" != "xyes" &&
4564     test "$tst_compi_localtime_r" = "yes"; then
4565     AC_MSG_CHECKING([if localtime_r seems to work])
4566     AC_RUN_IFELSE([
4567       AC_LANG_PROGRAM([[
4568         $curl_includes_stdlib
4569         $curl_includes_time
4570       ]],[[
4571         time_t clock = 1170352587;
4572         struct tm *tmp = 0;
4573         struct tm result;
4574         tmp = localtime_r(&clock, &result);
4575         if(tmp)
4576           exit(0);
4577         else
4578           exit(1);
4579       ]])
4580     ],[
4581       AC_MSG_RESULT([yes])
4582       tst_works_localtime_r="yes"
4583     ],[
4584       AC_MSG_RESULT([no])
4585       tst_works_localtime_r="no"
4586     ])
4587   fi
4588   #
4589   if test "$tst_compi_localtime_r" = "yes" &&
4590     test "$tst_works_localtime_r" != "no"; then
4591     AC_MSG_CHECKING([if localtime_r usage allowed])
4592     if test "x$curl_disallow_localtime_r" != "xyes"; then
4593       AC_MSG_RESULT([yes])
4594       tst_allow_localtime_r="yes"
4595     else
4596       AC_MSG_RESULT([no])
4597       tst_allow_localtime_r="no"
4598     fi
4599   fi
4600   #
4601   AC_MSG_CHECKING([if localtime_r might be used])
4602   if test "$tst_links_localtime_r" = "yes" &&
4603      test "$tst_proto_localtime_r" = "yes" &&
4604      test "$tst_compi_localtime_r" = "yes" &&
4605      test "$tst_allow_localtime_r" = "yes" &&
4606      test "$tst_works_localtime_r" != "no"; then
4607     AC_MSG_RESULT([yes])
4608     AC_DEFINE_UNQUOTED(HAVE_LOCALTIME_R, 1,
4609       [Define to 1 if you have a working localtime_r function.])
4610     curl_cv_func_localtime_r="yes"
4611   else
4612     AC_MSG_RESULT([no])
4613     curl_cv_func_localtime_r="no"
4614   fi
4615 ])
4616
4617
4618 dnl CURL_CHECK_FUNC_MEMRCHR
4619 dnl -------------------------------------------------
4620 dnl Verify if memrchr is available, prototyped, and
4621 dnl can be compiled. If all of these are true, and
4622 dnl usage has not been previously disallowed with
4623 dnl shell variable curl_disallow_memrchr, then
4624 dnl HAVE_MEMRCHR will be defined.
4625
4626 AC_DEFUN([CURL_CHECK_FUNC_MEMRCHR], [
4627   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4628   #
4629   tst_links_memrchr="unknown"
4630   tst_macro_memrchr="unknown"
4631   tst_proto_memrchr="unknown"
4632   tst_compi_memrchr="unknown"
4633   tst_allow_memrchr="unknown"
4634   #
4635   AC_MSG_CHECKING([if memrchr can be linked])
4636   AC_LINK_IFELSE([
4637     AC_LANG_FUNC_LINK_TRY([memrchr])
4638   ],[
4639     AC_MSG_RESULT([yes])
4640     tst_links_memrchr="yes"
4641   ],[
4642     AC_MSG_RESULT([no])
4643     tst_links_memrchr="no"
4644   ])
4645   #
4646   if test "$tst_links_memrchr" = "no"; then
4647     AC_MSG_CHECKING([if memrchr seems a macro])
4648     AC_LINK_IFELSE([
4649       AC_LANG_PROGRAM([[
4650         $curl_includes_string
4651       ]],[[
4652         if(0 != memrchr(0, 0, 0))
4653           return 1;
4654       ]])
4655     ],[
4656       AC_MSG_RESULT([yes])
4657       tst_macro_memrchr="yes"
4658     ],[
4659       AC_MSG_RESULT([no])
4660       tst_macro_memrchr="no"
4661     ])
4662   fi
4663   #
4664   if test "$tst_links_memrchr" = "yes"; then
4665     AC_MSG_CHECKING([if memrchr is prototyped])
4666     AC_EGREP_CPP([memrchr],[
4667       $curl_includes_string
4668     ],[
4669       AC_MSG_RESULT([yes])
4670       tst_proto_memrchr="yes"
4671     ],[
4672       AC_MSG_RESULT([no])
4673       tst_proto_memrchr="no"
4674     ])
4675   fi
4676   #
4677   if test "$tst_proto_memrchr" = "yes" ||
4678      test "$tst_macro_memrchr" = "yes"; then
4679     AC_MSG_CHECKING([if memrchr is compilable])
4680     AC_COMPILE_IFELSE([
4681       AC_LANG_PROGRAM([[
4682         $curl_includes_string
4683       ]],[[
4684         if(0 != memrchr(0, 0, 0))
4685           return 1;
4686       ]])
4687     ],[
4688       AC_MSG_RESULT([yes])
4689       tst_compi_memrchr="yes"
4690     ],[
4691       AC_MSG_RESULT([no])
4692       tst_compi_memrchr="no"
4693     ])
4694   fi
4695   #
4696   if test "$tst_compi_memrchr" = "yes"; then
4697     AC_MSG_CHECKING([if memrchr usage allowed])
4698     if test "x$curl_disallow_memrchr" != "xyes"; then
4699       AC_MSG_RESULT([yes])
4700       tst_allow_memrchr="yes"
4701     else
4702       AC_MSG_RESULT([no])
4703       tst_allow_memrchr="no"
4704     fi
4705   fi
4706   #
4707   AC_MSG_CHECKING([if memrchr might be used])
4708   if (test "$tst_proto_memrchr" = "yes" ||
4709       test "$tst_macro_memrchr" = "yes") &&
4710      test "$tst_compi_memrchr" = "yes" &&
4711      test "$tst_allow_memrchr" = "yes"; then
4712     AC_MSG_RESULT([yes])
4713     AC_DEFINE_UNQUOTED(HAVE_MEMRCHR, 1,
4714       [Define to 1 if you have the memrchr function or macro.])
4715     curl_cv_func_memrchr="yes"
4716   else
4717     AC_MSG_RESULT([no])
4718     curl_cv_func_memrchr="no"
4719   fi
4720 ])
4721
4722
4723 dnl CURL_CHECK_FUNC_POLL
4724 dnl -------------------------------------------------
4725 dnl Verify if poll is available, prototyped, can
4726 dnl be compiled and seems to work. If all of these are
4727 dnl true, and usage has not been previously disallowed
4728 dnl with shell variable curl_disallow_poll, then
4729 dnl HAVE_POLL will be defined.
4730
4731 AC_DEFUN([CURL_CHECK_FUNC_POLL], [
4732   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4733   AC_REQUIRE([CURL_INCLUDES_POLL])dnl
4734   #
4735   tst_links_poll="unknown"
4736   tst_proto_poll="unknown"
4737   tst_compi_poll="unknown"
4738   tst_works_poll="unknown"
4739   tst_allow_poll="unknown"
4740   #
4741   case $host_os in
4742     darwin*|interix*)
4743       dnl poll() does not work on these platforms
4744       dnl Interix: "does provide poll(), but the implementing developer must
4745       dnl have been in a bad mood, because poll() only works on the /proc
4746       dnl filesystem here"
4747       dnl macOS: poll() first didn't exist, then was broken until fixed in 10.9
4748       dnl only to break again in 10.12.
4749       curl_disallow_poll="yes"
4750       tst_compi_poll="no"
4751       ;;
4752   esac
4753   #
4754   AC_MSG_CHECKING([if poll can be linked])
4755   AC_LINK_IFELSE([
4756     AC_LANG_PROGRAM([[
4757       $curl_includes_poll
4758     ]],[[
4759       if(0 != poll(0, 0, 0))
4760         return 1;
4761     ]])
4762   ],[
4763     AC_MSG_RESULT([yes])
4764     tst_links_poll="yes"
4765   ],[
4766     AC_MSG_RESULT([no])
4767     tst_links_poll="no"
4768   ])
4769   #
4770   if test "$tst_links_poll" = "yes"; then
4771     AC_MSG_CHECKING([if poll is prototyped])
4772     AC_EGREP_CPP([poll],[
4773       $curl_includes_poll
4774     ],[
4775       AC_MSG_RESULT([yes])
4776       tst_proto_poll="yes"
4777     ],[
4778       AC_MSG_RESULT([no])
4779       tst_proto_poll="no"
4780     ])
4781   fi
4782   #
4783   if test "$tst_proto_poll" = "yes"; then
4784     AC_MSG_CHECKING([if poll is compilable])
4785     AC_COMPILE_IFELSE([
4786       AC_LANG_PROGRAM([[
4787         $curl_includes_poll
4788       ]],[[
4789         if(0 != poll(0, 0, 0))
4790           return 1;
4791       ]])
4792     ],[
4793       AC_MSG_RESULT([yes])
4794       tst_compi_poll="yes"
4795     ],[
4796       AC_MSG_RESULT([no])
4797       tst_compi_poll="no"
4798     ])
4799   fi
4800   #
4801   dnl only do runtime verification when not cross-compiling
4802   if test "x$cross_compiling" != "xyes" &&
4803     test "$tst_compi_poll" = "yes"; then
4804     AC_MSG_CHECKING([if poll seems to work])
4805     AC_RUN_IFELSE([
4806       AC_LANG_PROGRAM([[
4807         $curl_includes_stdlib
4808         $curl_includes_poll
4809         $curl_includes_time
4810       ]],[[
4811         /* detect the original poll() breakage */
4812         if(0 != poll(0, 0, 10))
4813           exit(1); /* fail */
4814         else {
4815           /* detect the 10.12 poll() breakage */
4816           struct timeval before, after;
4817           int rc;
4818           size_t us;
4819
4820           gettimeofday(&before, NULL);
4821           rc = poll(NULL, 0, 500);
4822           gettimeofday(&after, NULL);
4823
4824           us = (after.tv_sec - before.tv_sec) * 1000000 +
4825             (after.tv_usec - before.tv_usec);
4826
4827           if(us < 400000)
4828             exit(1);
4829         }
4830       ]])
4831     ],[
4832       AC_MSG_RESULT([yes])
4833       tst_works_poll="yes"
4834     ],[
4835       AC_MSG_RESULT([no])
4836       tst_works_poll="no"
4837     ])
4838   fi
4839   #
4840   if test "$tst_compi_poll" = "yes" &&
4841     test "$tst_works_poll" != "no"; then
4842     AC_MSG_CHECKING([if poll usage allowed])
4843     if test "x$curl_disallow_poll" != "xyes"; then
4844       AC_MSG_RESULT([yes])
4845       tst_allow_poll="yes"
4846     else
4847       AC_MSG_RESULT([no])
4848       tst_allow_poll="no"
4849     fi
4850   fi
4851   #
4852   AC_MSG_CHECKING([if poll might be used])
4853   if test "$tst_links_poll" = "yes" &&
4854      test "$tst_proto_poll" = "yes" &&
4855      test "$tst_compi_poll" = "yes" &&
4856      test "$tst_allow_poll" = "yes" &&
4857      test "$tst_works_poll" != "no"; then
4858     AC_MSG_RESULT([yes])
4859     AC_DEFINE_UNQUOTED(HAVE_POLL, 1,
4860       [Define to 1 if you have a working poll function.])
4861     AC_DEFINE_UNQUOTED(HAVE_POLL_FINE, 1,
4862       [If you have a fine poll])
4863     curl_cv_func_poll="yes"
4864   else
4865     AC_MSG_RESULT([no])
4866     curl_cv_func_poll="no"
4867   fi
4868 ])
4869
4870
4871 dnl CURL_CHECK_FUNC_REMOVEXATTR
4872 dnl -------------------------------------------------
4873 dnl Verify if removexattr is available, prototyped, and
4874 dnl can be compiled. If all of these are true, and
4875 dnl usage has not been previously disallowed with
4876 dnl shell variable curl_disallow_removexattr, then
4877 dnl HAVE_REMOVEXATTR will be defined.
4878
4879 AC_DEFUN([CURL_CHECK_FUNC_REMOVEXATTR], [
4880   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
4881   #
4882   tst_links_removexattr="unknown"
4883   tst_proto_removexattr="unknown"
4884   tst_compi_removexattr="unknown"
4885   tst_allow_removexattr="unknown"
4886   tst_nargs_removexattr="unknown"
4887   #
4888   AC_MSG_CHECKING([if removexattr can be linked])
4889   AC_LINK_IFELSE([
4890     AC_LANG_FUNC_LINK_TRY([removexattr])
4891   ],[
4892     AC_MSG_RESULT([yes])
4893     tst_links_removexattr="yes"
4894   ],[
4895     AC_MSG_RESULT([no])
4896     tst_links_removexattr="no"
4897   ])
4898   #
4899   if test "$tst_links_removexattr" = "yes"; then
4900     AC_MSG_CHECKING([if removexattr is prototyped])
4901     AC_EGREP_CPP([removexattr],[
4902       $curl_includes_sys_xattr
4903     ],[
4904       AC_MSG_RESULT([yes])
4905       tst_proto_removexattr="yes"
4906     ],[
4907       AC_MSG_RESULT([no])
4908       tst_proto_removexattr="no"
4909     ])
4910   fi
4911   #
4912   if test "$tst_proto_removexattr" = "yes"; then
4913     if test "$tst_nargs_removexattr" = "unknown"; then
4914       AC_MSG_CHECKING([if removexattr takes 2 args.])
4915       AC_COMPILE_IFELSE([
4916         AC_LANG_PROGRAM([[
4917           $curl_includes_sys_xattr
4918         ]],[[
4919           if(0 != removexattr(0, 0))
4920             return 1;
4921         ]])
4922       ],[
4923         AC_MSG_RESULT([yes])
4924         tst_compi_removexattr="yes"
4925         tst_nargs_removexattr="2"
4926       ],[
4927         AC_MSG_RESULT([no])
4928         tst_compi_removexattr="no"
4929       ])
4930     fi
4931     if test "$tst_nargs_removexattr" = "unknown"; then
4932       AC_MSG_CHECKING([if removexattr takes 3 args.])
4933       AC_COMPILE_IFELSE([
4934         AC_LANG_PROGRAM([[
4935           $curl_includes_sys_xattr
4936         ]],[[
4937           if(0 != removexattr(0, 0, 0))
4938             return 1;
4939         ]])
4940       ],[
4941         AC_MSG_RESULT([yes])
4942         tst_compi_removexattr="yes"
4943         tst_nargs_removexattr="3"
4944       ],[
4945         AC_MSG_RESULT([no])
4946         tst_compi_removexattr="no"
4947       ])
4948     fi
4949     AC_MSG_CHECKING([if removexattr is compilable])
4950     if test "$tst_compi_removexattr" = "yes"; then
4951       AC_MSG_RESULT([yes])
4952     else
4953       AC_MSG_RESULT([no])
4954     fi
4955   fi
4956   #
4957   if test "$tst_compi_removexattr" = "yes"; then
4958     AC_MSG_CHECKING([if removexattr usage allowed])
4959     if test "x$curl_disallow_removexattr" != "xyes"; then
4960       AC_MSG_RESULT([yes])
4961       tst_allow_removexattr="yes"
4962     else
4963       AC_MSG_RESULT([no])
4964       tst_allow_removexattr="no"
4965     fi
4966   fi
4967   #
4968   AC_MSG_CHECKING([if removexattr might be used])
4969   if test "$tst_links_removexattr" = "yes" &&
4970      test "$tst_proto_removexattr" = "yes" &&
4971      test "$tst_compi_removexattr" = "yes" &&
4972      test "$tst_allow_removexattr" = "yes"; then
4973     AC_MSG_RESULT([yes])
4974     AC_DEFINE_UNQUOTED(HAVE_REMOVEXATTR, 1,
4975       [Define to 1 if you have the removexattr function.])
4976     dnl AC_DEFINE_UNQUOTED(REMOVEXATTR_ARGS, $tst_nargs_removexattr,
4977     dnl   [Specifies the number of arguments to removexattr])
4978     #
4979     if test "$tst_nargs_removexattr" -eq "2"; then
4980       AC_DEFINE(HAVE_REMOVEXATTR_2, 1, [removexattr() takes 2 args])
4981     elif test "$tst_nargs_removexattr" -eq "3"; then
4982       AC_DEFINE(HAVE_REMOVEXATTR_3, 1, [removexattr() takes 3 args])
4983     fi
4984     #
4985     curl_cv_func_removexattr="yes"
4986   else
4987     AC_MSG_RESULT([no])
4988     curl_cv_func_removexattr="no"
4989   fi
4990 ])
4991
4992
4993 dnl CURL_CHECK_FUNC_SETSOCKOPT
4994 dnl -------------------------------------------------
4995 dnl Verify if setsockopt is available, prototyped, and
4996 dnl can be compiled. If all of these are true, and
4997 dnl usage has not been previously disallowed with
4998 dnl shell variable curl_disallow_setsockopt, then
4999 dnl HAVE_SETSOCKOPT will be defined.
5000
5001 AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT], [
5002   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
5003   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
5004   #
5005   tst_links_setsockopt="unknown"
5006   tst_proto_setsockopt="unknown"
5007   tst_compi_setsockopt="unknown"
5008   tst_allow_setsockopt="unknown"
5009   #
5010   AC_MSG_CHECKING([if setsockopt can be linked])
5011   AC_LINK_IFELSE([
5012     AC_LANG_PROGRAM([[
5013       $curl_includes_winsock2
5014       $curl_includes_sys_socket
5015     ]],[[
5016       if(0 != setsockopt(0, 0, 0, 0, 0))
5017         return 1;
5018     ]])
5019   ],[
5020     AC_MSG_RESULT([yes])
5021     tst_links_setsockopt="yes"
5022   ],[
5023     AC_MSG_RESULT([no])
5024     tst_links_setsockopt="no"
5025   ])
5026   #
5027   if test "$tst_links_setsockopt" = "yes"; then
5028     AC_MSG_CHECKING([if setsockopt is prototyped])
5029     AC_EGREP_CPP([setsockopt],[
5030       $curl_includes_winsock2
5031       $curl_includes_sys_socket
5032     ],[
5033       AC_MSG_RESULT([yes])
5034       tst_proto_setsockopt="yes"
5035     ],[
5036       AC_MSG_RESULT([no])
5037       tst_proto_setsockopt="no"
5038     ])
5039   fi
5040   #
5041   if test "$tst_proto_setsockopt" = "yes"; then
5042     AC_MSG_CHECKING([if setsockopt is compilable])
5043     AC_COMPILE_IFELSE([
5044       AC_LANG_PROGRAM([[
5045         $curl_includes_winsock2
5046         $curl_includes_sys_socket
5047       ]],[[
5048         if(0 != setsockopt(0, 0, 0, 0, 0))
5049           return 1;
5050       ]])
5051     ],[
5052       AC_MSG_RESULT([yes])
5053       tst_compi_setsockopt="yes"
5054     ],[
5055       AC_MSG_RESULT([no])
5056       tst_compi_setsockopt="no"
5057     ])
5058   fi
5059   #
5060   if test "$tst_compi_setsockopt" = "yes"; then
5061     AC_MSG_CHECKING([if setsockopt usage allowed])
5062     if test "x$curl_disallow_setsockopt" != "xyes"; then
5063       AC_MSG_RESULT([yes])
5064       tst_allow_setsockopt="yes"
5065     else
5066       AC_MSG_RESULT([no])
5067       tst_allow_setsockopt="no"
5068     fi
5069   fi
5070   #
5071   AC_MSG_CHECKING([if setsockopt might be used])
5072   if test "$tst_links_setsockopt" = "yes" &&
5073      test "$tst_proto_setsockopt" = "yes" &&
5074      test "$tst_compi_setsockopt" = "yes" &&
5075      test "$tst_allow_setsockopt" = "yes"; then
5076     AC_MSG_RESULT([yes])
5077     AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1,
5078       [Define to 1 if you have the setsockopt function.])
5079     curl_cv_func_setsockopt="yes"
5080     CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
5081   else
5082     AC_MSG_RESULT([no])
5083     curl_cv_func_setsockopt="no"
5084   fi
5085 ])
5086
5087
5088 dnl CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
5089 dnl -------------------------------------------------
5090 dnl Verify if setsockopt with the SO_NONBLOCK command is
5091 dnl available, can be compiled, and seems to work. If
5092 dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK
5093 dnl will be defined.
5094
5095 AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
5096   #
5097   tst_compi_setsockopt_so_nonblock="unknown"
5098   tst_allow_setsockopt_so_nonblock="unknown"
5099   #
5100   if test "$curl_cv_func_setsockopt" = "yes"; then
5101     AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable])
5102     AC_COMPILE_IFELSE([
5103       AC_LANG_PROGRAM([[
5104         $curl_includes_winsock2
5105         $curl_includes_sys_socket
5106       ]],[[
5107         if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
5108           return 1;
5109       ]])
5110     ],[
5111       AC_MSG_RESULT([yes])
5112       tst_compi_setsockopt_so_nonblock="yes"
5113     ],[
5114       AC_MSG_RESULT([no])
5115       tst_compi_setsockopt_so_nonblock="no"
5116     ])
5117   fi
5118   #
5119   if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then
5120     AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed])
5121     if test "x$curl_disallow_setsockopt_so_nonblock" != "xyes"; then
5122       AC_MSG_RESULT([yes])
5123       tst_allow_setsockopt_so_nonblock="yes"
5124     else
5125       AC_MSG_RESULT([no])
5126       tst_allow_setsockopt_so_nonblock="no"
5127     fi
5128   fi
5129   #
5130   AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used])
5131   if test "$tst_compi_setsockopt_so_nonblock" = "yes" &&
5132      test "$tst_allow_setsockopt_so_nonblock" = "yes"; then
5133     AC_MSG_RESULT([yes])
5134     AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1,
5135       [Define to 1 if you have a working setsockopt SO_NONBLOCK function.])
5136     curl_cv_func_setsockopt_so_nonblock="yes"
5137   else
5138     AC_MSG_RESULT([no])
5139     curl_cv_func_setsockopt_so_nonblock="no"
5140   fi
5141 ])
5142
5143
5144 dnl CURL_CHECK_FUNC_SETXATTR
5145 dnl -------------------------------------------------
5146 dnl Verify if setxattr is available, prototyped, and
5147 dnl can be compiled. If all of these are true, and
5148 dnl usage has not been previously disallowed with
5149 dnl shell variable curl_disallow_setxattr, then
5150 dnl HAVE_SETXATTR will be defined.
5151
5152 AC_DEFUN([CURL_CHECK_FUNC_SETXATTR], [
5153   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
5154   #
5155   tst_links_setxattr="unknown"
5156   tst_proto_setxattr="unknown"
5157   tst_compi_setxattr="unknown"
5158   tst_allow_setxattr="unknown"
5159   tst_nargs_setxattr="unknown"
5160   #
5161   AC_MSG_CHECKING([if setxattr can be linked])
5162   AC_LINK_IFELSE([
5163     AC_LANG_FUNC_LINK_TRY([setxattr])
5164   ],[
5165     AC_MSG_RESULT([yes])
5166     tst_links_setxattr="yes"
5167   ],[
5168     AC_MSG_RESULT([no])
5169     tst_links_setxattr="no"
5170   ])
5171   #
5172   if test "$tst_links_setxattr" = "yes"; then
5173     AC_MSG_CHECKING([if setxattr is prototyped])
5174     AC_EGREP_CPP([setxattr],[
5175       $curl_includes_sys_xattr
5176     ],[
5177       AC_MSG_RESULT([yes])
5178       tst_proto_setxattr="yes"
5179     ],[
5180       AC_MSG_RESULT([no])
5181       tst_proto_setxattr="no"
5182     ])
5183   fi
5184   #
5185   if test "$tst_proto_setxattr" = "yes"; then
5186     if test "$tst_nargs_setxattr" = "unknown"; then
5187       AC_MSG_CHECKING([if setxattr takes 5 args.])
5188       AC_COMPILE_IFELSE([
5189         AC_LANG_PROGRAM([[
5190           $curl_includes_sys_xattr
5191         ]],[[
5192           if(0 != setxattr(0, 0, 0, 0, 0))
5193             return 1;
5194         ]])
5195       ],[
5196         AC_MSG_RESULT([yes])
5197         tst_compi_setxattr="yes"
5198         tst_nargs_setxattr="5"
5199       ],[
5200         AC_MSG_RESULT([no])
5201         tst_compi_setxattr="no"
5202       ])
5203     fi
5204     if test "$tst_nargs_setxattr" = "unknown"; then
5205       AC_MSG_CHECKING([if setxattr takes 6 args.])
5206       AC_COMPILE_IFELSE([
5207         AC_LANG_PROGRAM([[
5208           $curl_includes_sys_xattr
5209         ]],[[
5210           if(0 != setxattr(0, 0, 0, 0, 0, 0))
5211             return 1;
5212         ]])
5213       ],[
5214         AC_MSG_RESULT([yes])
5215         tst_compi_setxattr="yes"
5216         tst_nargs_setxattr="6"
5217       ],[
5218         AC_MSG_RESULT([no])
5219         tst_compi_setxattr="no"
5220       ])
5221     fi
5222     AC_MSG_CHECKING([if setxattr is compilable])
5223     if test "$tst_compi_setxattr" = "yes"; then
5224       AC_MSG_RESULT([yes])
5225     else
5226       AC_MSG_RESULT([no])
5227     fi
5228   fi
5229   #
5230   if test "$tst_compi_setxattr" = "yes"; then
5231     AC_MSG_CHECKING([if setxattr usage allowed])
5232     if test "x$curl_disallow_setxattr" != "xyes"; then
5233       AC_MSG_RESULT([yes])
5234       tst_allow_setxattr="yes"
5235     else
5236       AC_MSG_RESULT([no])
5237       tst_allow_setxattr="no"
5238     fi
5239   fi
5240   #
5241   AC_MSG_CHECKING([if setxattr might be used])
5242   if test "$tst_links_setxattr" = "yes" &&
5243      test "$tst_proto_setxattr" = "yes" &&
5244      test "$tst_compi_setxattr" = "yes" &&
5245      test "$tst_allow_setxattr" = "yes"; then
5246     AC_MSG_RESULT([yes])
5247     AC_DEFINE_UNQUOTED(HAVE_SETXATTR, 1,
5248       [Define to 1 if you have the setxattr function.])
5249     dnl AC_DEFINE_UNQUOTED(SETXATTR_ARGS, $tst_nargs_setxattr,
5250     dnl   [Specifies the number of arguments to setxattr])
5251     #
5252     if test "$tst_nargs_setxattr" -eq "5"; then
5253       AC_DEFINE(HAVE_SETXATTR_5, 1, [setxattr() takes 5 args])
5254     elif test "$tst_nargs_setxattr" -eq "6"; then
5255       AC_DEFINE(HAVE_SETXATTR_6, 1, [setxattr() takes 6 args])
5256     fi
5257     #
5258     curl_cv_func_setxattr="yes"
5259   else
5260     AC_MSG_RESULT([no])
5261     curl_cv_func_setxattr="no"
5262   fi
5263 ])
5264
5265
5266 dnl CURL_CHECK_FUNC_SIGACTION
5267 dnl -------------------------------------------------
5268 dnl Verify if sigaction is available, prototyped, and
5269 dnl can be compiled. If all of these are true, and
5270 dnl usage has not been previously disallowed with
5271 dnl shell variable curl_disallow_sigaction, then
5272 dnl HAVE_SIGACTION will be defined.
5273
5274 AC_DEFUN([CURL_CHECK_FUNC_SIGACTION], [
5275   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5276   #
5277   tst_links_sigaction="unknown"
5278   tst_proto_sigaction="unknown"
5279   tst_compi_sigaction="unknown"
5280   tst_allow_sigaction="unknown"
5281   #
5282   AC_MSG_CHECKING([if sigaction can be linked])
5283   AC_LINK_IFELSE([
5284     AC_LANG_FUNC_LINK_TRY([sigaction])
5285   ],[
5286     AC_MSG_RESULT([yes])
5287     tst_links_sigaction="yes"
5288   ],[
5289     AC_MSG_RESULT([no])
5290     tst_links_sigaction="no"
5291   ])
5292   #
5293   if test "$tst_links_sigaction" = "yes"; then
5294     AC_MSG_CHECKING([if sigaction is prototyped])
5295     AC_EGREP_CPP([sigaction],[
5296       $curl_includes_signal
5297     ],[
5298       AC_MSG_RESULT([yes])
5299       tst_proto_sigaction="yes"
5300     ],[
5301       AC_MSG_RESULT([no])
5302       tst_proto_sigaction="no"
5303     ])
5304   fi
5305   #
5306   if test "$tst_proto_sigaction" = "yes"; then
5307     AC_MSG_CHECKING([if sigaction is compilable])
5308     AC_COMPILE_IFELSE([
5309       AC_LANG_PROGRAM([[
5310         $curl_includes_signal
5311       ]],[[
5312         if(0 != sigaction(0, 0, 0))
5313           return 1;
5314       ]])
5315     ],[
5316       AC_MSG_RESULT([yes])
5317       tst_compi_sigaction="yes"
5318     ],[
5319       AC_MSG_RESULT([no])
5320       tst_compi_sigaction="no"
5321     ])
5322   fi
5323   #
5324   if test "$tst_compi_sigaction" = "yes"; then
5325     AC_MSG_CHECKING([if sigaction usage allowed])
5326     if test "x$curl_disallow_sigaction" != "xyes"; then
5327       AC_MSG_RESULT([yes])
5328       tst_allow_sigaction="yes"
5329     else
5330       AC_MSG_RESULT([no])
5331       tst_allow_sigaction="no"
5332     fi
5333   fi
5334   #
5335   AC_MSG_CHECKING([if sigaction might be used])
5336   if test "$tst_links_sigaction" = "yes" &&
5337      test "$tst_proto_sigaction" = "yes" &&
5338      test "$tst_compi_sigaction" = "yes" &&
5339      test "$tst_allow_sigaction" = "yes"; then
5340     AC_MSG_RESULT([yes])
5341     AC_DEFINE_UNQUOTED(HAVE_SIGACTION, 1,
5342       [Define to 1 if you have the sigaction function.])
5343     curl_cv_func_sigaction="yes"
5344   else
5345     AC_MSG_RESULT([no])
5346     curl_cv_func_sigaction="no"
5347   fi
5348 ])
5349
5350
5351 dnl CURL_CHECK_FUNC_SIGINTERRUPT
5352 dnl -------------------------------------------------
5353 dnl Verify if siginterrupt is available, prototyped, and
5354 dnl can be compiled. If all of these are true, and
5355 dnl usage has not been previously disallowed with
5356 dnl shell variable curl_disallow_siginterrupt, then
5357 dnl HAVE_SIGINTERRUPT will be defined.
5358
5359 AC_DEFUN([CURL_CHECK_FUNC_SIGINTERRUPT], [
5360   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5361   #
5362   tst_links_siginterrupt="unknown"
5363   tst_proto_siginterrupt="unknown"
5364   tst_compi_siginterrupt="unknown"
5365   tst_allow_siginterrupt="unknown"
5366   #
5367   AC_MSG_CHECKING([if siginterrupt can be linked])
5368   AC_LINK_IFELSE([
5369     AC_LANG_FUNC_LINK_TRY([siginterrupt])
5370   ],[
5371     AC_MSG_RESULT([yes])
5372     tst_links_siginterrupt="yes"
5373   ],[
5374     AC_MSG_RESULT([no])
5375     tst_links_siginterrupt="no"
5376   ])
5377   #
5378   if test "$tst_links_siginterrupt" = "yes"; then
5379     AC_MSG_CHECKING([if siginterrupt is prototyped])
5380     AC_EGREP_CPP([siginterrupt],[
5381       $curl_includes_signal
5382     ],[
5383       AC_MSG_RESULT([yes])
5384       tst_proto_siginterrupt="yes"
5385     ],[
5386       AC_MSG_RESULT([no])
5387       tst_proto_siginterrupt="no"
5388     ])
5389   fi
5390   #
5391   if test "$tst_proto_siginterrupt" = "yes"; then
5392     AC_MSG_CHECKING([if siginterrupt is compilable])
5393     AC_COMPILE_IFELSE([
5394       AC_LANG_PROGRAM([[
5395         $curl_includes_signal
5396       ]],[[
5397         if(0 != siginterrupt(0, 0))
5398           return 1;
5399       ]])
5400     ],[
5401       AC_MSG_RESULT([yes])
5402       tst_compi_siginterrupt="yes"
5403     ],[
5404       AC_MSG_RESULT([no])
5405       tst_compi_siginterrupt="no"
5406     ])
5407   fi
5408   #
5409   if test "$tst_compi_siginterrupt" = "yes"; then
5410     AC_MSG_CHECKING([if siginterrupt usage allowed])
5411     if test "x$curl_disallow_siginterrupt" != "xyes"; then
5412       AC_MSG_RESULT([yes])
5413       tst_allow_siginterrupt="yes"
5414     else
5415       AC_MSG_RESULT([no])
5416       tst_allow_siginterrupt="no"
5417     fi
5418   fi
5419   #
5420   AC_MSG_CHECKING([if siginterrupt might be used])
5421   if test "$tst_links_siginterrupt" = "yes" &&
5422      test "$tst_proto_siginterrupt" = "yes" &&
5423      test "$tst_compi_siginterrupt" = "yes" &&
5424      test "$tst_allow_siginterrupt" = "yes"; then
5425     AC_MSG_RESULT([yes])
5426     AC_DEFINE_UNQUOTED(HAVE_SIGINTERRUPT, 1,
5427       [Define to 1 if you have the siginterrupt function.])
5428     curl_cv_func_siginterrupt="yes"
5429   else
5430     AC_MSG_RESULT([no])
5431     curl_cv_func_siginterrupt="no"
5432   fi
5433 ])
5434
5435
5436 dnl CURL_CHECK_FUNC_SIGNAL
5437 dnl -------------------------------------------------
5438 dnl Verify if signal is available, prototyped, and
5439 dnl can be compiled. If all of these are true, and
5440 dnl usage has not been previously disallowed with
5441 dnl shell variable curl_disallow_signal, then
5442 dnl HAVE_SIGNAL will be defined.
5443
5444 AC_DEFUN([CURL_CHECK_FUNC_SIGNAL], [
5445   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5446   #
5447   tst_links_signal="unknown"
5448   tst_proto_signal="unknown"
5449   tst_compi_signal="unknown"
5450   tst_allow_signal="unknown"
5451   #
5452   AC_MSG_CHECKING([if signal can be linked])
5453   AC_LINK_IFELSE([
5454     AC_LANG_FUNC_LINK_TRY([signal])
5455   ],[
5456     AC_MSG_RESULT([yes])
5457     tst_links_signal="yes"
5458   ],[
5459     AC_MSG_RESULT([no])
5460     tst_links_signal="no"
5461   ])
5462   #
5463   if test "$tst_links_signal" = "yes"; then
5464     AC_MSG_CHECKING([if signal is prototyped])
5465     AC_EGREP_CPP([signal],[
5466       $curl_includes_signal
5467     ],[
5468       AC_MSG_RESULT([yes])
5469       tst_proto_signal="yes"
5470     ],[
5471       AC_MSG_RESULT([no])
5472       tst_proto_signal="no"
5473     ])
5474   fi
5475   #
5476   if test "$tst_proto_signal" = "yes"; then
5477     AC_MSG_CHECKING([if signal is compilable])
5478     AC_COMPILE_IFELSE([
5479       AC_LANG_PROGRAM([[
5480         $curl_includes_signal
5481       ]],[[
5482         if(0 != signal(0, 0))
5483           return 1;
5484       ]])
5485     ],[
5486       AC_MSG_RESULT([yes])
5487       tst_compi_signal="yes"
5488     ],[
5489       AC_MSG_RESULT([no])
5490       tst_compi_signal="no"
5491     ])
5492   fi
5493   #
5494   if test "$tst_compi_signal" = "yes"; then
5495     AC_MSG_CHECKING([if signal usage allowed])
5496     if test "x$curl_disallow_signal" != "xyes"; then
5497       AC_MSG_RESULT([yes])
5498       tst_allow_signal="yes"
5499     else
5500       AC_MSG_RESULT([no])
5501       tst_allow_signal="no"
5502     fi
5503   fi
5504   #
5505   AC_MSG_CHECKING([if signal might be used])
5506   if test "$tst_links_signal" = "yes" &&
5507      test "$tst_proto_signal" = "yes" &&
5508      test "$tst_compi_signal" = "yes" &&
5509      test "$tst_allow_signal" = "yes"; then
5510     AC_MSG_RESULT([yes])
5511     AC_DEFINE_UNQUOTED(HAVE_SIGNAL, 1,
5512       [Define to 1 if you have the signal function.])
5513     curl_cv_func_signal="yes"
5514   else
5515     AC_MSG_RESULT([no])
5516     curl_cv_func_signal="no"
5517   fi
5518 ])
5519
5520
5521 dnl CURL_CHECK_FUNC_SIGSETJMP
5522 dnl -------------------------------------------------
5523 dnl Verify if sigsetjmp is available, prototyped, and
5524 dnl can be compiled. If all of these are true, and
5525 dnl usage has not been previously disallowed with
5526 dnl shell variable curl_disallow_sigsetjmp, then
5527 dnl HAVE_SIGSETJMP will be defined.
5528
5529 AC_DEFUN([CURL_CHECK_FUNC_SIGSETJMP], [
5530   AC_REQUIRE([CURL_INCLUDES_SETJMP])dnl
5531   #
5532   tst_links_sigsetjmp="unknown"
5533   tst_macro_sigsetjmp="unknown"
5534   tst_proto_sigsetjmp="unknown"
5535   tst_compi_sigsetjmp="unknown"
5536   tst_allow_sigsetjmp="unknown"
5537   #
5538   AC_MSG_CHECKING([if sigsetjmp can be linked])
5539   AC_LINK_IFELSE([
5540     AC_LANG_FUNC_LINK_TRY([sigsetjmp])
5541   ],[
5542     AC_MSG_RESULT([yes])
5543     tst_links_sigsetjmp="yes"
5544   ],[
5545     AC_MSG_RESULT([no])
5546     tst_links_sigsetjmp="no"
5547   ])
5548   #
5549   if test "$tst_links_sigsetjmp" = "no"; then
5550     AC_MSG_CHECKING([if sigsetjmp seems a macro])
5551     AC_LINK_IFELSE([
5552       AC_LANG_PROGRAM([[
5553         $curl_includes_setjmp
5554       ]],[[
5555         sigjmp_buf env;
5556         if(0 != sigsetjmp(env, 0))
5557           return 1;
5558       ]])
5559     ],[
5560       AC_MSG_RESULT([yes])
5561       tst_macro_sigsetjmp="yes"
5562     ],[
5563       AC_MSG_RESULT([no])
5564       tst_macro_sigsetjmp="no"
5565     ])
5566   fi
5567   #
5568   if test "$tst_links_sigsetjmp" = "yes"; then
5569     AC_MSG_CHECKING([if sigsetjmp is prototyped])
5570     AC_EGREP_CPP([sigsetjmp],[
5571       $curl_includes_setjmp
5572     ],[
5573       AC_MSG_RESULT([yes])
5574       tst_proto_sigsetjmp="yes"
5575     ],[
5576       AC_MSG_RESULT([no])
5577       tst_proto_sigsetjmp="no"
5578     ])
5579   fi
5580   #
5581   if test "$tst_proto_sigsetjmp" = "yes" ||
5582      test "$tst_macro_sigsetjmp" = "yes"; then
5583     AC_MSG_CHECKING([if sigsetjmp is compilable])
5584     AC_COMPILE_IFELSE([
5585       AC_LANG_PROGRAM([[
5586         $curl_includes_setjmp
5587       ]],[[
5588         sigjmp_buf env;
5589         if(0 != sigsetjmp(env, 0))
5590           return 1;
5591       ]])
5592     ],[
5593       AC_MSG_RESULT([yes])
5594       tst_compi_sigsetjmp="yes"
5595     ],[
5596       AC_MSG_RESULT([no])
5597       tst_compi_sigsetjmp="no"
5598     ])
5599   fi
5600   #
5601   if test "$tst_compi_sigsetjmp" = "yes"; then
5602     AC_MSG_CHECKING([if sigsetjmp usage allowed])
5603     if test "x$curl_disallow_sigsetjmp" != "xyes"; then
5604       AC_MSG_RESULT([yes])
5605       tst_allow_sigsetjmp="yes"
5606     else
5607       AC_MSG_RESULT([no])
5608       tst_allow_sigsetjmp="no"
5609     fi
5610   fi
5611   #
5612   AC_MSG_CHECKING([if sigsetjmp might be used])
5613   if (test "$tst_proto_sigsetjmp" = "yes" ||
5614       test "$tst_macro_sigsetjmp" = "yes") &&
5615      test "$tst_compi_sigsetjmp" = "yes" &&
5616      test "$tst_allow_sigsetjmp" = "yes"; then
5617     AC_MSG_RESULT([yes])
5618     AC_DEFINE_UNQUOTED(HAVE_SIGSETJMP, 1,
5619       [Define to 1 if you have the sigsetjmp function or macro.])
5620     curl_cv_func_sigsetjmp="yes"
5621   else
5622     AC_MSG_RESULT([no])
5623     curl_cv_func_sigsetjmp="no"
5624   fi
5625 ])
5626
5627
5628 dnl CURL_CHECK_FUNC_SOCKET
5629 dnl -------------------------------------------------
5630 dnl Verify if socket is available, prototyped, and
5631 dnl can be compiled. If all of these are true, and
5632 dnl usage has not been previously disallowed with
5633 dnl shell variable curl_disallow_socket, then
5634 dnl HAVE_SOCKET will be defined.
5635
5636 AC_DEFUN([CURL_CHECK_FUNC_SOCKET], [
5637   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
5638   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
5639   AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
5640   #
5641   tst_links_socket="unknown"
5642   tst_proto_socket="unknown"
5643   tst_compi_socket="unknown"
5644   tst_allow_socket="unknown"
5645   #
5646   AC_MSG_CHECKING([if socket can be linked])
5647   AC_LINK_IFELSE([
5648     AC_LANG_PROGRAM([[
5649       $curl_includes_winsock2
5650       $curl_includes_sys_socket
5651       $curl_includes_socket
5652     ]],[[
5653       if(0 != socket(0, 0, 0))
5654         return 1;
5655     ]])
5656   ],[
5657     AC_MSG_RESULT([yes])
5658     tst_links_socket="yes"
5659   ],[
5660     AC_MSG_RESULT([no])
5661     tst_links_socket="no"
5662   ])
5663   #
5664   if test "$tst_links_socket" = "yes"; then
5665     AC_MSG_CHECKING([if socket is prototyped])
5666     AC_EGREP_CPP([socket],[
5667       $curl_includes_winsock2
5668       $curl_includes_sys_socket
5669       $curl_includes_socket
5670     ],[
5671       AC_MSG_RESULT([yes])
5672       tst_proto_socket="yes"
5673     ],[
5674       AC_MSG_RESULT([no])
5675       tst_proto_socket="no"
5676     ])
5677   fi
5678   #
5679   if test "$tst_proto_socket" = "yes"; then
5680     AC_MSG_CHECKING([if socket is compilable])
5681     AC_COMPILE_IFELSE([
5682       AC_LANG_PROGRAM([[
5683         $curl_includes_winsock2
5684         $curl_includes_sys_socket
5685         $curl_includes_socket
5686       ]],[[
5687         if(0 != socket(0, 0, 0))
5688           return 1;
5689       ]])
5690     ],[
5691       AC_MSG_RESULT([yes])
5692       tst_compi_socket="yes"
5693     ],[
5694       AC_MSG_RESULT([no])
5695       tst_compi_socket="no"
5696     ])
5697   fi
5698   #
5699   if test "$tst_compi_socket" = "yes"; then
5700     AC_MSG_CHECKING([if socket usage allowed])
5701     if test "x$curl_disallow_socket" != "xyes"; then
5702       AC_MSG_RESULT([yes])
5703       tst_allow_socket="yes"
5704     else
5705       AC_MSG_RESULT([no])
5706       tst_allow_socket="no"
5707     fi
5708   fi
5709   #
5710   AC_MSG_CHECKING([if socket might be used])
5711   if test "$tst_links_socket" = "yes" &&
5712      test "$tst_proto_socket" = "yes" &&
5713      test "$tst_compi_socket" = "yes" &&
5714      test "$tst_allow_socket" = "yes"; then
5715     AC_MSG_RESULT([yes])
5716     AC_DEFINE_UNQUOTED(HAVE_SOCKET, 1,
5717       [Define to 1 if you have the socket function.])
5718     curl_cv_func_socket="yes"
5719   else
5720     AC_MSG_RESULT([no])
5721     curl_cv_func_socket="no"
5722   fi
5723 ])
5724
5725
5726 dnl CURL_CHECK_FUNC_SOCKETPAIR
5727 dnl -------------------------------------------------
5728 dnl Verify if socketpair is available, prototyped, and
5729 dnl can be compiled. If all of these are true, and
5730 dnl usage has not been previously disallowed with
5731 dnl shell variable curl_disallow_socketpair, then
5732 dnl HAVE_SOCKETPAIR will be defined.
5733
5734 AC_DEFUN([CURL_CHECK_FUNC_SOCKETPAIR], [
5735   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
5736   AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
5737   #
5738   tst_links_socketpair="unknown"
5739   tst_proto_socketpair="unknown"
5740   tst_compi_socketpair="unknown"
5741   tst_allow_socketpair="unknown"
5742   #
5743   AC_MSG_CHECKING([if socketpair can be linked])
5744   AC_LINK_IFELSE([
5745     AC_LANG_FUNC_LINK_TRY([socketpair])
5746   ],[
5747     AC_MSG_RESULT([yes])
5748     tst_links_socketpair="yes"
5749   ],[
5750     AC_MSG_RESULT([no])
5751     tst_links_socketpair="no"
5752   ])
5753   #
5754   if test "$tst_links_socketpair" = "yes"; then
5755     AC_MSG_CHECKING([if socketpair is prototyped])
5756     AC_EGREP_CPP([socketpair],[
5757       $curl_includes_sys_socket
5758       $curl_includes_socket
5759     ],[
5760       AC_MSG_RESULT([yes])
5761       tst_proto_socketpair="yes"
5762     ],[
5763       AC_MSG_RESULT([no])
5764       tst_proto_socketpair="no"
5765     ])
5766   fi
5767   #
5768   if test "$tst_proto_socketpair" = "yes"; then
5769     AC_MSG_CHECKING([if socketpair is compilable])
5770     AC_COMPILE_IFELSE([
5771       AC_LANG_PROGRAM([[
5772         $curl_includes_sys_socket
5773         $curl_includes_socket
5774       ]],[[
5775         int sv[2];
5776         if(0 != socketpair(0, 0, 0, sv))
5777           return 1;
5778       ]])
5779     ],[
5780       AC_MSG_RESULT([yes])
5781       tst_compi_socketpair="yes"
5782     ],[
5783       AC_MSG_RESULT([no])
5784       tst_compi_socketpair="no"
5785     ])
5786   fi
5787   #
5788   if test "$tst_compi_socketpair" = "yes"; then
5789     AC_MSG_CHECKING([if socketpair usage allowed])
5790     if test "x$curl_disallow_socketpair" != "xyes"; then
5791       AC_MSG_RESULT([yes])
5792       tst_allow_socketpair="yes"
5793     else
5794       AC_MSG_RESULT([no])
5795       tst_allow_socketpair="no"
5796     fi
5797   fi
5798   #
5799   AC_MSG_CHECKING([if socketpair might be used])
5800   if test "$tst_links_socketpair" = "yes" &&
5801      test "$tst_proto_socketpair" = "yes" &&
5802      test "$tst_compi_socketpair" = "yes" &&
5803      test "$tst_allow_socketpair" = "yes"; then
5804     AC_MSG_RESULT([yes])
5805     AC_DEFINE_UNQUOTED(HAVE_SOCKETPAIR, 1,
5806       [Define to 1 if you have the socketpair function.])
5807     curl_cv_func_socketpair="yes"
5808   else
5809     AC_MSG_RESULT([no])
5810     curl_cv_func_socketpair="no"
5811   fi
5812 ])
5813
5814
5815 dnl CURL_CHECK_FUNC_STRCASECMP
5816 dnl -------------------------------------------------
5817 dnl Verify if strcasecmp is available, prototyped, and
5818 dnl can be compiled. If all of these are true, and
5819 dnl usage has not been previously disallowed with
5820 dnl shell variable curl_disallow_strcasecmp, then
5821 dnl HAVE_STRCASECMP will be defined.
5822
5823 AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [
5824   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
5825   #
5826   tst_links_strcasecmp="unknown"
5827   tst_proto_strcasecmp="unknown"
5828   tst_compi_strcasecmp="unknown"
5829   tst_allow_strcasecmp="unknown"
5830   #
5831   AC_MSG_CHECKING([if strcasecmp can be linked])
5832   AC_LINK_IFELSE([
5833     AC_LANG_FUNC_LINK_TRY([strcasecmp])
5834   ],[
5835     AC_MSG_RESULT([yes])
5836     tst_links_strcasecmp="yes"
5837   ],[
5838     AC_MSG_RESULT([no])
5839     tst_links_strcasecmp="no"
5840   ])
5841   #
5842   if test "$tst_links_strcasecmp" = "yes"; then
5843     AC_MSG_CHECKING([if strcasecmp is prototyped])
5844     AC_EGREP_CPP([strcasecmp],[
5845       $curl_includes_string
5846     ],[
5847       AC_MSG_RESULT([yes])
5848       tst_proto_strcasecmp="yes"
5849     ],[
5850       AC_MSG_RESULT([no])
5851       tst_proto_strcasecmp="no"
5852     ])
5853   fi
5854   #
5855   if test "$tst_proto_strcasecmp" = "yes"; then
5856     AC_MSG_CHECKING([if strcasecmp is compilable])
5857     AC_COMPILE_IFELSE([
5858       AC_LANG_PROGRAM([[
5859         $curl_includes_string
5860       ]],[[
5861         if(0 != strcasecmp(0, 0))
5862           return 1;
5863       ]])
5864     ],[
5865       AC_MSG_RESULT([yes])
5866       tst_compi_strcasecmp="yes"
5867     ],[
5868       AC_MSG_RESULT([no])
5869       tst_compi_strcasecmp="no"
5870     ])
5871   fi
5872   #
5873   if test "$tst_compi_strcasecmp" = "yes"; then
5874     AC_MSG_CHECKING([if strcasecmp usage allowed])
5875     if test "x$curl_disallow_strcasecmp" != "xyes"; then
5876       AC_MSG_RESULT([yes])
5877       tst_allow_strcasecmp="yes"
5878     else
5879       AC_MSG_RESULT([no])
5880       tst_allow_strcasecmp="no"
5881     fi
5882   fi
5883   #
5884   AC_MSG_CHECKING([if strcasecmp might be used])
5885   if test "$tst_links_strcasecmp" = "yes" &&
5886      test "$tst_proto_strcasecmp" = "yes" &&
5887      test "$tst_compi_strcasecmp" = "yes" &&
5888      test "$tst_allow_strcasecmp" = "yes"; then
5889     AC_MSG_RESULT([yes])
5890     AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
5891       [Define to 1 if you have the strcasecmp function.])
5892     curl_cv_func_strcasecmp="yes"
5893   else
5894     AC_MSG_RESULT([no])
5895     curl_cv_func_strcasecmp="no"
5896   fi
5897 ])
5898
5899 dnl CURL_CHECK_FUNC_STRCMPI
5900 dnl -------------------------------------------------
5901 dnl Verify if strcmpi is available, prototyped, and
5902 dnl can be compiled. If all of these are true, and
5903 dnl usage has not been previously disallowed with
5904 dnl shell variable curl_disallow_strcmpi, then
5905 dnl HAVE_STRCMPI will be defined.
5906
5907 AC_DEFUN([CURL_CHECK_FUNC_STRCMPI], [
5908   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
5909   #
5910   tst_links_strcmpi="unknown"
5911   tst_proto_strcmpi="unknown"
5912   tst_compi_strcmpi="unknown"
5913   tst_allow_strcmpi="unknown"
5914   #
5915   AC_MSG_CHECKING([if strcmpi can be linked])
5916   AC_LINK_IFELSE([
5917     AC_LANG_FUNC_LINK_TRY([strcmpi])
5918   ],[
5919     AC_MSG_RESULT([yes])
5920     tst_links_strcmpi="yes"
5921   ],[
5922     AC_MSG_RESULT([no])
5923     tst_links_strcmpi="no"
5924   ])
5925   #
5926   if test "$tst_links_strcmpi" = "yes"; then
5927     AC_MSG_CHECKING([if strcmpi is prototyped])
5928     AC_EGREP_CPP([strcmpi],[
5929       $curl_includes_string
5930     ],[
5931       AC_MSG_RESULT([yes])
5932       tst_proto_strcmpi="yes"
5933     ],[
5934       AC_MSG_RESULT([no])
5935       tst_proto_strcmpi="no"
5936     ])
5937   fi
5938   #
5939   if test "$tst_proto_strcmpi" = "yes"; then
5940     AC_MSG_CHECKING([if strcmpi is compilable])
5941     AC_COMPILE_IFELSE([
5942       AC_LANG_PROGRAM([[
5943         $curl_includes_string
5944       ]],[[
5945         if(0 != strcmpi(0, 0))
5946           return 1;
5947       ]])
5948     ],[
5949       AC_MSG_RESULT([yes])
5950       tst_compi_strcmpi="yes"
5951     ],[
5952       AC_MSG_RESULT([no])
5953       tst_compi_strcmpi="no"
5954     ])
5955   fi
5956   #
5957   if test "$tst_compi_strcmpi" = "yes"; then
5958     AC_MSG_CHECKING([if strcmpi usage allowed])
5959     if test "x$curl_disallow_strcmpi" != "xyes"; then
5960       AC_MSG_RESULT([yes])
5961       tst_allow_strcmpi="yes"
5962     else
5963       AC_MSG_RESULT([no])
5964       tst_allow_strcmpi="no"
5965     fi
5966   fi
5967   #
5968   AC_MSG_CHECKING([if strcmpi might be used])
5969   if test "$tst_links_strcmpi" = "yes" &&
5970      test "$tst_proto_strcmpi" = "yes" &&
5971      test "$tst_compi_strcmpi" = "yes" &&
5972      test "$tst_allow_strcmpi" = "yes"; then
5973     AC_MSG_RESULT([yes])
5974     AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
5975       [Define to 1 if you have the strcmpi function.])
5976     curl_cv_func_strcmpi="yes"
5977   else
5978     AC_MSG_RESULT([no])
5979     curl_cv_func_strcmpi="no"
5980   fi
5981 ])
5982
5983
5984 dnl CURL_CHECK_FUNC_STRDUP
5985 dnl -------------------------------------------------
5986 dnl Verify if strdup is available, prototyped, and
5987 dnl can be compiled. If all of these are true, and
5988 dnl usage has not been previously disallowed with
5989 dnl shell variable curl_disallow_strdup, then
5990 dnl HAVE_STRDUP will be defined.
5991
5992 AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
5993   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
5994   #
5995   tst_links_strdup="unknown"
5996   tst_proto_strdup="unknown"
5997   tst_compi_strdup="unknown"
5998   tst_allow_strdup="unknown"
5999   #
6000   AC_MSG_CHECKING([if strdup can be linked])
6001   AC_LINK_IFELSE([
6002     AC_LANG_FUNC_LINK_TRY([strdup])
6003   ],[
6004     AC_MSG_RESULT([yes])
6005     tst_links_strdup="yes"
6006   ],[
6007     AC_MSG_RESULT([no])
6008     tst_links_strdup="no"
6009   ])
6010   #
6011   if test "$tst_links_strdup" = "yes"; then
6012     AC_MSG_CHECKING([if strdup is prototyped])
6013     AC_EGREP_CPP([strdup],[
6014       $curl_includes_string
6015     ],[
6016       AC_MSG_RESULT([yes])
6017       tst_proto_strdup="yes"
6018     ],[
6019       AC_MSG_RESULT([no])
6020       tst_proto_strdup="no"
6021     ])
6022   fi
6023   #
6024   if test "$tst_proto_strdup" = "yes"; then
6025     AC_MSG_CHECKING([if strdup is compilable])
6026     AC_COMPILE_IFELSE([
6027       AC_LANG_PROGRAM([[
6028         $curl_includes_string
6029       ]],[[
6030         if(0 != strdup(0))
6031           return 1;
6032       ]])
6033     ],[
6034       AC_MSG_RESULT([yes])
6035       tst_compi_strdup="yes"
6036     ],[
6037       AC_MSG_RESULT([no])
6038       tst_compi_strdup="no"
6039     ])
6040   fi
6041   #
6042   if test "$tst_compi_strdup" = "yes"; then
6043     AC_MSG_CHECKING([if strdup usage allowed])
6044     if test "x$curl_disallow_strdup" != "xyes"; then
6045       AC_MSG_RESULT([yes])
6046       tst_allow_strdup="yes"
6047     else
6048       AC_MSG_RESULT([no])
6049       tst_allow_strdup="no"
6050     fi
6051   fi
6052   #
6053   AC_MSG_CHECKING([if strdup might be used])
6054   if test "$tst_links_strdup" = "yes" &&
6055      test "$tst_proto_strdup" = "yes" &&
6056      test "$tst_compi_strdup" = "yes" &&
6057      test "$tst_allow_strdup" = "yes"; then
6058     AC_MSG_RESULT([yes])
6059     AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
6060       [Define to 1 if you have the strdup function.])
6061     curl_cv_func_strdup="yes"
6062   else
6063     AC_MSG_RESULT([no])
6064     curl_cv_func_strdup="no"
6065   fi
6066 ])
6067
6068
6069 dnl CURL_CHECK_FUNC_STRERROR_R
6070 dnl -------------------------------------------------
6071 dnl Verify if strerror_r is available, prototyped, can be compiled and
6072 dnl seems to work. If all of these are true, and usage has not been
6073 dnl previously disallowed with shell variable curl_disallow_strerror_r,
6074 dnl then HAVE_STRERROR_R and STRERROR_R_TYPE_ARG3 will be defined, as
6075 dnl well as one of HAVE_GLIBC_STRERROR_R or HAVE_POSIX_STRERROR_R.
6076 dnl
6077 dnl glibc-style strerror_r:
6078 dnl
6079 dnl      char *strerror_r(int errnum, char *workbuf, size_t bufsize);
6080 dnl
6081 dnl  glibc-style strerror_r returns a pointer to the the error string,
6082 dnl  and might use the provided workbuf as a scratch area if needed. A
6083 dnl  quick test on a few systems shows that it's usually not used at all.
6084 dnl
6085 dnl POSIX-style strerror_r:
6086 dnl
6087 dnl      int strerror_r(int errnum, char *resultbuf, size_t bufsize);
6088 dnl
6089 dnl  POSIX-style strerror_r returns 0 upon successful completion and the
6090 dnl  error string in the provided resultbuf.
6091 dnl
6092
6093 AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
6094   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
6095   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6096   #
6097   tst_links_strerror_r="unknown"
6098   tst_proto_strerror_r="unknown"
6099   tst_compi_strerror_r="unknown"
6100   tst_glibc_strerror_r="unknown"
6101   tst_posix_strerror_r="unknown"
6102   tst_allow_strerror_r="unknown"
6103   tst_works_glibc_strerror_r="unknown"
6104   tst_works_posix_strerror_r="unknown"
6105   tst_glibc_strerror_r_type_arg3="unknown"
6106   tst_posix_strerror_r_type_arg3="unknown"
6107   #
6108   AC_MSG_CHECKING([if strerror_r can be linked])
6109   AC_LINK_IFELSE([
6110     AC_LANG_FUNC_LINK_TRY([strerror_r])
6111   ],[
6112     AC_MSG_RESULT([yes])
6113     tst_links_strerror_r="yes"
6114   ],[
6115     AC_MSG_RESULT([no])
6116     tst_links_strerror_r="no"
6117   ])
6118   #
6119   if test "$tst_links_strerror_r" = "yes"; then
6120     AC_MSG_CHECKING([if strerror_r is prototyped])
6121     AC_EGREP_CPP([strerror_r],[
6122       $curl_includes_string
6123     ],[
6124       AC_MSG_RESULT([yes])
6125       tst_proto_strerror_r="yes"
6126     ],[
6127       AC_MSG_RESULT([no])
6128       tst_proto_strerror_r="no"
6129     ])
6130   fi
6131   #
6132   if test "$tst_proto_strerror_r" = "yes"; then
6133     AC_MSG_CHECKING([if strerror_r is compilable])
6134     AC_COMPILE_IFELSE([
6135       AC_LANG_PROGRAM([[
6136         $curl_includes_string
6137       ]],[[
6138         if(0 != strerror_r(0, 0, 0))
6139           return 1;
6140       ]])
6141     ],[
6142       AC_MSG_RESULT([yes])
6143       tst_compi_strerror_r="yes"
6144     ],[
6145       AC_MSG_RESULT([no])
6146       tst_compi_strerror_r="no"
6147     ])
6148   fi
6149   #
6150   if test "$tst_compi_strerror_r" = "yes"; then
6151     AC_MSG_CHECKING([if strerror_r is glibc like])
6152     tst_glibc_strerror_r_type_arg3="unknown"
6153     for arg3 in 'size_t' 'int' 'unsigned int'; do
6154       if test "$tst_glibc_strerror_r_type_arg3" = "unknown"; then
6155         AC_COMPILE_IFELSE([
6156           AC_LANG_PROGRAM([[
6157             $curl_includes_string
6158             char *strerror_r(int errnum, char *workbuf, $arg3 bufsize);
6159           ]],[[
6160             if(0 != strerror_r(0, 0, 0))
6161               return 1;
6162           ]])
6163         ],[
6164           tst_glibc_strerror_r_type_arg3="$arg3"
6165         ])
6166       fi
6167     done
6168     case "$tst_glibc_strerror_r_type_arg3" in
6169       unknown)
6170         AC_MSG_RESULT([no])
6171         tst_glibc_strerror_r="no"
6172         ;;
6173       *)
6174         AC_MSG_RESULT([yes])
6175         tst_glibc_strerror_r="yes"
6176         ;;
6177     esac
6178   fi
6179   #
6180   dnl only do runtime verification when not cross-compiling
6181   if test "x$cross_compiling" != "xyes" &&
6182     test "$tst_glibc_strerror_r" = "yes"; then
6183     AC_MSG_CHECKING([if strerror_r seems to work])
6184     AC_RUN_IFELSE([
6185       AC_LANG_PROGRAM([[
6186         $curl_includes_stdlib
6187         $curl_includes_string
6188 #       include <errno.h>
6189       ]],[[
6190         char buffer[1024];
6191         char *string = 0;
6192         buffer[0] = '\0';
6193         string = strerror_r(EACCES, buffer, sizeof(buffer));
6194         if(!string)
6195           exit(1); /* fail */
6196         if(!string[0])
6197           exit(1); /* fail */
6198         else
6199           exit(0);
6200       ]])
6201     ],[
6202       AC_MSG_RESULT([yes])
6203       tst_works_glibc_strerror_r="yes"
6204     ],[
6205       AC_MSG_RESULT([no])
6206       tst_works_glibc_strerror_r="no"
6207     ])
6208   fi
6209   #
6210   if test "$tst_compi_strerror_r" = "yes" &&
6211     test "$tst_works_glibc_strerror_r" != "yes"; then
6212     AC_MSG_CHECKING([if strerror_r is POSIX like])
6213     tst_posix_strerror_r_type_arg3="unknown"
6214     for arg3 in 'size_t' 'int' 'unsigned int'; do
6215       if test "$tst_posix_strerror_r_type_arg3" = "unknown"; then
6216         AC_COMPILE_IFELSE([
6217           AC_LANG_PROGRAM([[
6218             $curl_includes_string
6219             int strerror_r(int errnum, char *resultbuf, $arg3 bufsize);
6220           ]],[[
6221             if(0 != strerror_r(0, 0, 0))
6222               return 1;
6223           ]])
6224         ],[
6225           tst_posix_strerror_r_type_arg3="$arg3"
6226         ])
6227       fi
6228     done
6229     case "$tst_posix_strerror_r_type_arg3" in
6230       unknown)
6231         AC_MSG_RESULT([no])
6232         tst_posix_strerror_r="no"
6233         ;;
6234       *)
6235         AC_MSG_RESULT([yes])
6236         tst_posix_strerror_r="yes"
6237         ;;
6238     esac
6239   fi
6240   #
6241   dnl only do runtime verification when not cross-compiling
6242   if test "x$cross_compiling" != "xyes" &&
6243     test "$tst_posix_strerror_r" = "yes"; then
6244     AC_MSG_CHECKING([if strerror_r seems to work])
6245     AC_RUN_IFELSE([
6246       AC_LANG_PROGRAM([[
6247         $curl_includes_stdlib
6248         $curl_includes_string
6249 #       include <errno.h>
6250       ]],[[
6251         char buffer[1024];
6252         int error = 1;
6253         buffer[0] = '\0';
6254         error = strerror_r(EACCES, buffer, sizeof(buffer));
6255         if(error)
6256           exit(1); /* fail */
6257         if(buffer[0] == '\0')
6258           exit(1); /* fail */
6259         else
6260           exit(0);
6261       ]])
6262     ],[
6263       AC_MSG_RESULT([yes])
6264       tst_works_posix_strerror_r="yes"
6265     ],[
6266       AC_MSG_RESULT([no])
6267       tst_works_posix_strerror_r="no"
6268     ])
6269   fi
6270   #
6271   if test "$tst_works_glibc_strerror_r" = "yes"; then
6272     tst_posix_strerror_r="no"
6273   fi
6274   if test "$tst_works_posix_strerror_r" = "yes"; then
6275     tst_glibc_strerror_r="no"
6276   fi
6277   if test "$tst_glibc_strerror_r" = "yes" &&
6278     test "$tst_works_glibc_strerror_r" != "no" &&
6279     test "$tst_posix_strerror_r" != "yes"; then
6280     tst_allow_strerror_r="check"
6281   fi
6282   if test "$tst_posix_strerror_r" = "yes" &&
6283     test "$tst_works_posix_strerror_r" != "no" &&
6284     test "$tst_glibc_strerror_r" != "yes"; then
6285     tst_allow_strerror_r="check"
6286   fi
6287   if test "$tst_allow_strerror_r" = "check"; then
6288     AC_MSG_CHECKING([if strerror_r usage allowed])
6289     if test "x$curl_disallow_strerror_r" != "xyes"; then
6290       AC_MSG_RESULT([yes])
6291       tst_allow_strerror_r="yes"
6292     else
6293       AC_MSG_RESULT([no])
6294       tst_allow_strerror_r="no"
6295     fi
6296   fi
6297   #
6298   AC_MSG_CHECKING([if strerror_r might be used])
6299   if test "$tst_links_strerror_r" = "yes" &&
6300      test "$tst_proto_strerror_r" = "yes" &&
6301      test "$tst_compi_strerror_r" = "yes" &&
6302      test "$tst_allow_strerror_r" = "yes"; then
6303     AC_MSG_RESULT([yes])
6304     if test "$tst_glibc_strerror_r" = "yes"; then
6305       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
6306         [Define to 1 if you have the strerror_r function.])
6307       AC_DEFINE_UNQUOTED(HAVE_GLIBC_STRERROR_R, 1,
6308         [Define to 1 if you have a working glibc-style strerror_r function.])
6309       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_glibc_strerror_r_type_arg3,
6310         [Define to the type of arg 3 for strerror_r.])
6311     fi
6312     if test "$tst_posix_strerror_r" = "yes"; then
6313       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
6314         [Define to 1 if you have the strerror_r function.])
6315       AC_DEFINE_UNQUOTED(HAVE_POSIX_STRERROR_R, 1,
6316         [Define to 1 if you have a working POSIX-style strerror_r function.])
6317       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_posix_strerror_r_type_arg3,
6318         [Define to the type of arg 3 for strerror_r.])
6319     fi
6320     curl_cv_func_strerror_r="yes"
6321   else
6322     AC_MSG_RESULT([no])
6323     curl_cv_func_strerror_r="no"
6324   fi
6325   #
6326   if test "$tst_compi_strerror_r" = "yes" &&
6327      test "$tst_allow_strerror_r" = "unknown"; then
6328     AC_MSG_WARN([cannot determine strerror_r() style: edit lib/curl_config.h manually.])
6329   fi
6330   #
6331 ])
6332
6333
6334 dnl CURL_CHECK_FUNC_STRICMP
6335 dnl -------------------------------------------------
6336 dnl Verify if stricmp is available, prototyped, and
6337 dnl can be compiled. If all of these are true, and
6338 dnl usage has not been previously disallowed with
6339 dnl shell variable curl_disallow_stricmp, then
6340 dnl HAVE_STRICMP will be defined.
6341
6342 AC_DEFUN([CURL_CHECK_FUNC_STRICMP], [
6343   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6344   #
6345   tst_links_stricmp="unknown"
6346   tst_proto_stricmp="unknown"
6347   tst_compi_stricmp="unknown"
6348   tst_allow_stricmp="unknown"
6349   #
6350   AC_MSG_CHECKING([if stricmp can be linked])
6351   AC_LINK_IFELSE([
6352     AC_LANG_FUNC_LINK_TRY([stricmp])
6353   ],[
6354     AC_MSG_RESULT([yes])
6355     tst_links_stricmp="yes"
6356   ],[
6357     AC_MSG_RESULT([no])
6358     tst_links_stricmp="no"
6359   ])
6360   #
6361   if test "$tst_links_stricmp" = "yes"; then
6362     AC_MSG_CHECKING([if stricmp is prototyped])
6363     AC_EGREP_CPP([stricmp],[
6364       $curl_includes_string
6365     ],[
6366       AC_MSG_RESULT([yes])
6367       tst_proto_stricmp="yes"
6368     ],[
6369       AC_MSG_RESULT([no])
6370       tst_proto_stricmp="no"
6371     ])
6372   fi
6373   #
6374   if test "$tst_proto_stricmp" = "yes"; then
6375     AC_MSG_CHECKING([if stricmp is compilable])
6376     AC_COMPILE_IFELSE([
6377       AC_LANG_PROGRAM([[
6378         $curl_includes_string
6379       ]],[[
6380         if(0 != stricmp(0, 0))
6381           return 1;
6382       ]])
6383     ],[
6384       AC_MSG_RESULT([yes])
6385       tst_compi_stricmp="yes"
6386     ],[
6387       AC_MSG_RESULT([no])
6388       tst_compi_stricmp="no"
6389     ])
6390   fi
6391   #
6392   if test "$tst_compi_stricmp" = "yes"; then
6393     AC_MSG_CHECKING([if stricmp usage allowed])
6394     if test "x$curl_disallow_stricmp" != "xyes"; then
6395       AC_MSG_RESULT([yes])
6396       tst_allow_stricmp="yes"
6397     else
6398       AC_MSG_RESULT([no])
6399       tst_allow_stricmp="no"
6400     fi
6401   fi
6402   #
6403   AC_MSG_CHECKING([if stricmp might be used])
6404   if test "$tst_links_stricmp" = "yes" &&
6405      test "$tst_proto_stricmp" = "yes" &&
6406      test "$tst_compi_stricmp" = "yes" &&
6407      test "$tst_allow_stricmp" = "yes"; then
6408     AC_MSG_RESULT([yes])
6409     AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
6410       [Define to 1 if you have the stricmp function.])
6411     curl_cv_func_stricmp="yes"
6412   else
6413     AC_MSG_RESULT([no])
6414     curl_cv_func_stricmp="no"
6415   fi
6416 ])
6417
6418 dnl CURL_CHECK_FUNC_STRNCASECMP
6419 dnl -------------------------------------------------
6420 dnl Verify if strncasecmp is available, prototyped, and
6421 dnl can be compiled. If all of these are true, and
6422 dnl usage has not been previously disallowed with
6423 dnl shell variable curl_disallow_strncasecmp, then
6424 dnl HAVE_STRNCASECMP will be defined.
6425
6426 AC_DEFUN([CURL_CHECK_FUNC_STRNCASECMP], [
6427   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6428   #
6429   tst_links_strncasecmp="unknown"
6430   tst_proto_strncasecmp="unknown"
6431   tst_compi_strncasecmp="unknown"
6432   tst_allow_strncasecmp="unknown"
6433   #
6434   AC_MSG_CHECKING([if strncasecmp can be linked])
6435   AC_LINK_IFELSE([
6436     AC_LANG_FUNC_LINK_TRY([strncasecmp])
6437   ],[
6438     AC_MSG_RESULT([yes])
6439     tst_links_strncasecmp="yes"
6440   ],[
6441     AC_MSG_RESULT([no])
6442     tst_links_strncasecmp="no"
6443   ])
6444   #
6445   if test "$tst_links_strncasecmp" = "yes"; then
6446     AC_MSG_CHECKING([if strncasecmp is prototyped])
6447     AC_EGREP_CPP([strncasecmp],[
6448       $curl_includes_string
6449     ],[
6450       AC_MSG_RESULT([yes])
6451       tst_proto_strncasecmp="yes"
6452     ],[
6453       AC_MSG_RESULT([no])
6454       tst_proto_strncasecmp="no"
6455     ])
6456   fi
6457   #
6458   if test "$tst_proto_strncasecmp" = "yes"; then
6459     AC_MSG_CHECKING([if strncasecmp is compilable])
6460     AC_COMPILE_IFELSE([
6461       AC_LANG_PROGRAM([[
6462         $curl_includes_string
6463       ]],[[
6464         if(0 != strncasecmp(0, 0, 0))
6465           return 1;
6466       ]])
6467     ],[
6468       AC_MSG_RESULT([yes])
6469       tst_compi_strncasecmp="yes"
6470     ],[
6471       AC_MSG_RESULT([no])
6472       tst_compi_strncasecmp="no"
6473     ])
6474   fi
6475   #
6476   if test "$tst_compi_strncasecmp" = "yes"; then
6477     AC_MSG_CHECKING([if strncasecmp usage allowed])
6478     if test "x$curl_disallow_strncasecmp" != "xyes"; then
6479       AC_MSG_RESULT([yes])
6480       tst_allow_strncasecmp="yes"
6481     else
6482       AC_MSG_RESULT([no])
6483       tst_allow_strncasecmp="no"
6484     fi
6485   fi
6486   #
6487   AC_MSG_CHECKING([if strncasecmp might be used])
6488   if test "$tst_links_strncasecmp" = "yes" &&
6489      test "$tst_proto_strncasecmp" = "yes" &&
6490      test "$tst_compi_strncasecmp" = "yes" &&
6491      test "$tst_allow_strncasecmp" = "yes"; then
6492     AC_MSG_RESULT([yes])
6493     AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
6494       [Define to 1 if you have the strncasecmp function.])
6495     curl_cv_func_strncasecmp="yes"
6496   else
6497     AC_MSG_RESULT([no])
6498     curl_cv_func_strncasecmp="no"
6499   fi
6500 ])
6501
6502
6503 dnl CURL_CHECK_FUNC_STRNCMPI
6504 dnl -------------------------------------------------
6505 dnl Verify if strncmpi is available, prototyped, and
6506 dnl can be compiled. If all of these are true, and
6507 dnl usage has not been previously disallowed with
6508 dnl shell variable curl_disallow_strncmpi, then
6509 dnl HAVE_STRNCMPI will be defined.
6510
6511 AC_DEFUN([CURL_CHECK_FUNC_STRNCMPI], [
6512   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6513   #
6514   tst_links_strncmpi="unknown"
6515   tst_proto_strncmpi="unknown"
6516   tst_compi_strncmpi="unknown"
6517   tst_allow_strncmpi="unknown"
6518   #
6519   AC_MSG_CHECKING([if strncmpi can be linked])
6520   AC_LINK_IFELSE([
6521     AC_LANG_FUNC_LINK_TRY([strncmpi])
6522   ],[
6523     AC_MSG_RESULT([yes])
6524     tst_links_strncmpi="yes"
6525   ],[
6526     AC_MSG_RESULT([no])
6527     tst_links_strncmpi="no"
6528   ])
6529   #
6530   if test "$tst_links_strncmpi" = "yes"; then
6531     AC_MSG_CHECKING([if strncmpi is prototyped])
6532     AC_EGREP_CPP([strncmpi],[
6533       $curl_includes_string
6534     ],[
6535       AC_MSG_RESULT([yes])
6536       tst_proto_strncmpi="yes"
6537     ],[
6538       AC_MSG_RESULT([no])
6539       tst_proto_strncmpi="no"
6540     ])
6541   fi
6542   #
6543   if test "$tst_proto_strncmpi" = "yes"; then
6544     AC_MSG_CHECKING([if strncmpi is compilable])
6545     AC_COMPILE_IFELSE([
6546       AC_LANG_PROGRAM([[
6547         $curl_includes_string
6548       ]],[[
6549         if(0 != strncmpi(0, 0))
6550           return 1;
6551       ]])
6552     ],[
6553       AC_MSG_RESULT([yes])
6554       tst_compi_strncmpi="yes"
6555     ],[
6556       AC_MSG_RESULT([no])
6557       tst_compi_strncmpi="no"
6558     ])
6559   fi
6560   #
6561   if test "$tst_compi_strncmpi" = "yes"; then
6562     AC_MSG_CHECKING([if strncmpi usage allowed])
6563     if test "x$curl_disallow_strncmpi" != "xyes"; then
6564       AC_MSG_RESULT([yes])
6565       tst_allow_strncmpi="yes"
6566     else
6567       AC_MSG_RESULT([no])
6568       tst_allow_strncmpi="no"
6569     fi
6570   fi
6571   #
6572   AC_MSG_CHECKING([if strncmpi might be used])
6573   if test "$tst_links_strncmpi" = "yes" &&
6574      test "$tst_proto_strncmpi" = "yes" &&
6575      test "$tst_compi_strncmpi" = "yes" &&
6576      test "$tst_allow_strncmpi" = "yes"; then
6577     AC_MSG_RESULT([yes])
6578     AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
6579       [Define to 1 if you have the strncmpi function.])
6580     curl_cv_func_strncmpi="yes"
6581   else
6582     AC_MSG_RESULT([no])
6583     curl_cv_func_strncmpi="no"
6584   fi
6585 ])
6586
6587
6588 dnl CURL_CHECK_FUNC_STRNICMP
6589 dnl -------------------------------------------------
6590 dnl Verify if strnicmp is available, prototyped, and
6591 dnl can be compiled. If all of these are true, and
6592 dnl usage has not been previously disallowed with
6593 dnl shell variable curl_disallow_strnicmp, then
6594 dnl HAVE_STRNICMP will be defined.
6595
6596 AC_DEFUN([CURL_CHECK_FUNC_STRNICMP], [
6597   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6598   #
6599   tst_links_strnicmp="unknown"
6600   tst_proto_strnicmp="unknown"
6601   tst_compi_strnicmp="unknown"
6602   tst_allow_strnicmp="unknown"
6603   #
6604   AC_MSG_CHECKING([if strnicmp can be linked])
6605   AC_LINK_IFELSE([
6606     AC_LANG_FUNC_LINK_TRY([strnicmp])
6607   ],[
6608     AC_MSG_RESULT([yes])
6609     tst_links_strnicmp="yes"
6610   ],[
6611     AC_MSG_RESULT([no])
6612     tst_links_strnicmp="no"
6613   ])
6614   #
6615   if test "$tst_links_strnicmp" = "yes"; then
6616     AC_MSG_CHECKING([if strnicmp is prototyped])
6617     AC_EGREP_CPP([strnicmp],[
6618       $curl_includes_string
6619     ],[
6620       AC_MSG_RESULT([yes])
6621       tst_proto_strnicmp="yes"
6622     ],[
6623       AC_MSG_RESULT([no])
6624       tst_proto_strnicmp="no"
6625     ])
6626   fi
6627   #
6628   if test "$tst_proto_strnicmp" = "yes"; then
6629     AC_MSG_CHECKING([if strnicmp is compilable])
6630     AC_COMPILE_IFELSE([
6631       AC_LANG_PROGRAM([[
6632         $curl_includes_string
6633       ]],[[
6634         if(0 != strnicmp(0, 0))
6635           return 1;
6636       ]])
6637     ],[
6638       AC_MSG_RESULT([yes])
6639       tst_compi_strnicmp="yes"
6640     ],[
6641       AC_MSG_RESULT([no])
6642       tst_compi_strnicmp="no"
6643     ])
6644   fi
6645   #
6646   if test "$tst_compi_strnicmp" = "yes"; then
6647     AC_MSG_CHECKING([if strnicmp usage allowed])
6648     if test "x$curl_disallow_strnicmp" != "xyes"; then
6649       AC_MSG_RESULT([yes])
6650       tst_allow_strnicmp="yes"
6651     else
6652       AC_MSG_RESULT([no])
6653       tst_allow_strnicmp="no"
6654     fi
6655   fi
6656   #
6657   AC_MSG_CHECKING([if strnicmp might be used])
6658   if test "$tst_links_strnicmp" = "yes" &&
6659      test "$tst_proto_strnicmp" = "yes" &&
6660      test "$tst_compi_strnicmp" = "yes" &&
6661      test "$tst_allow_strnicmp" = "yes"; then
6662     AC_MSG_RESULT([yes])
6663     AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
6664       [Define to 1 if you have the strnicmp function.])
6665     curl_cv_func_strnicmp="yes"
6666   else
6667     AC_MSG_RESULT([no])
6668     curl_cv_func_strnicmp="no"
6669   fi
6670 ])
6671
6672
6673 dnl CURL_CHECK_FUNC_STRSTR
6674 dnl -------------------------------------------------
6675 dnl Verify if strstr is available, prototyped, and
6676 dnl can be compiled. If all of these are true, and
6677 dnl usage has not been previously disallowed with
6678 dnl shell variable curl_disallow_strstr, then
6679 dnl HAVE_STRSTR will be defined.
6680
6681 AC_DEFUN([CURL_CHECK_FUNC_STRSTR], [
6682   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6683   #
6684   tst_links_strstr="unknown"
6685   tst_proto_strstr="unknown"
6686   tst_compi_strstr="unknown"
6687   tst_allow_strstr="unknown"
6688   #
6689   AC_MSG_CHECKING([if strstr can be linked])
6690   AC_LINK_IFELSE([
6691     AC_LANG_FUNC_LINK_TRY([strstr])
6692   ],[
6693     AC_MSG_RESULT([yes])
6694     tst_links_strstr="yes"
6695   ],[
6696     AC_MSG_RESULT([no])
6697     tst_links_strstr="no"
6698   ])
6699   #
6700   if test "$tst_links_strstr" = "yes"; then
6701     AC_MSG_CHECKING([if strstr is prototyped])
6702     AC_EGREP_CPP([strstr],[
6703       $curl_includes_string
6704     ],[
6705       AC_MSG_RESULT([yes])
6706       tst_proto_strstr="yes"
6707     ],[
6708       AC_MSG_RESULT([no])
6709       tst_proto_strstr="no"
6710     ])
6711   fi
6712   #
6713   if test "$tst_proto_strstr" = "yes"; then
6714     AC_MSG_CHECKING([if strstr is compilable])
6715     AC_COMPILE_IFELSE([
6716       AC_LANG_PROGRAM([[
6717         $curl_includes_string
6718       ]],[[
6719         if(0 != strstr(0, 0))
6720           return 1;
6721       ]])
6722     ],[
6723       AC_MSG_RESULT([yes])
6724       tst_compi_strstr="yes"
6725     ],[
6726       AC_MSG_RESULT([no])
6727       tst_compi_strstr="no"
6728     ])
6729   fi
6730   #
6731   if test "$tst_compi_strstr" = "yes"; then
6732     AC_MSG_CHECKING([if strstr usage allowed])
6733     if test "x$curl_disallow_strstr" != "xyes"; then
6734       AC_MSG_RESULT([yes])
6735       tst_allow_strstr="yes"
6736     else
6737       AC_MSG_RESULT([no])
6738       tst_allow_strstr="no"
6739     fi
6740   fi
6741   #
6742   AC_MSG_CHECKING([if strstr might be used])
6743   if test "$tst_links_strstr" = "yes" &&
6744      test "$tst_proto_strstr" = "yes" &&
6745      test "$tst_compi_strstr" = "yes" &&
6746      test "$tst_allow_strstr" = "yes"; then
6747     AC_MSG_RESULT([yes])
6748     AC_DEFINE_UNQUOTED(HAVE_STRSTR, 1,
6749       [Define to 1 if you have the strstr function.])
6750     curl_cv_func_strstr="yes"
6751   else
6752     AC_MSG_RESULT([no])
6753     curl_cv_func_strstr="no"
6754   fi
6755 ])
6756
6757
6758 dnl CURL_CHECK_FUNC_STRTOK_R
6759 dnl -------------------------------------------------
6760 dnl Verify if strtok_r is available, prototyped, and
6761 dnl can be compiled. If all of these are true, and
6762 dnl usage has not been previously disallowed with
6763 dnl shell variable curl_disallow_strtok_r, then
6764 dnl HAVE_STRTOK_R will be defined.
6765
6766 AC_DEFUN([CURL_CHECK_FUNC_STRTOK_R], [
6767   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6768   #
6769   tst_links_strtok_r="unknown"
6770   tst_proto_strtok_r="unknown"
6771   tst_compi_strtok_r="unknown"
6772   tst_allow_strtok_r="unknown"
6773   #
6774   AC_MSG_CHECKING([if strtok_r can be linked])
6775   AC_LINK_IFELSE([
6776     AC_LANG_FUNC_LINK_TRY([strtok_r])
6777   ],[
6778     AC_MSG_RESULT([yes])
6779     tst_links_strtok_r="yes"
6780   ],[
6781     AC_MSG_RESULT([no])
6782     tst_links_strtok_r="no"
6783   ])
6784   #
6785   if test "$tst_links_strtok_r" = "yes"; then
6786     AC_MSG_CHECKING([if strtok_r is prototyped])
6787     AC_EGREP_CPP([strtok_r],[
6788       $curl_includes_string
6789     ],[
6790       AC_MSG_RESULT([yes])
6791       tst_proto_strtok_r="yes"
6792     ],[
6793       AC_MSG_RESULT([no])
6794       tst_proto_strtok_r="no"
6795     ])
6796   fi
6797   #
6798   if test "$tst_proto_strtok_r" = "yes"; then
6799     AC_MSG_CHECKING([if strtok_r is compilable])
6800     AC_COMPILE_IFELSE([
6801       AC_LANG_PROGRAM([[
6802         $curl_includes_string
6803       ]],[[
6804         if(0 != strtok_r(0, 0, 0))
6805           return 1;
6806       ]])
6807     ],[
6808       AC_MSG_RESULT([yes])
6809       tst_compi_strtok_r="yes"
6810     ],[
6811       AC_MSG_RESULT([no])
6812       tst_compi_strtok_r="no"
6813     ])
6814   fi
6815   #
6816   if test "$tst_compi_strtok_r" = "yes"; then
6817     AC_MSG_CHECKING([if strtok_r usage allowed])
6818     if test "x$curl_disallow_strtok_r" != "xyes"; then
6819       AC_MSG_RESULT([yes])
6820       tst_allow_strtok_r="yes"
6821     else
6822       AC_MSG_RESULT([no])
6823       tst_allow_strtok_r="no"
6824     fi
6825   fi
6826   #
6827   AC_MSG_CHECKING([if strtok_r might be used])
6828   if test "$tst_links_strtok_r" = "yes" &&
6829      test "$tst_proto_strtok_r" = "yes" &&
6830      test "$tst_compi_strtok_r" = "yes" &&
6831      test "$tst_allow_strtok_r" = "yes"; then
6832     AC_MSG_RESULT([yes])
6833     AC_DEFINE_UNQUOTED(HAVE_STRTOK_R, 1,
6834       [Define to 1 if you have the strtok_r function.])
6835     curl_cv_func_strtok_r="yes"
6836   else
6837     AC_MSG_RESULT([no])
6838     curl_cv_func_strtok_r="no"
6839   fi
6840 ])
6841
6842
6843 dnl CURL_CHECK_FUNC_STRTOLL
6844 dnl -------------------------------------------------
6845 dnl Verify if strtoll is available, prototyped, and
6846 dnl can be compiled. If all of these are true, and
6847 dnl usage has not been previously disallowed with
6848 dnl shell variable curl_disallow_strtoll, then
6849 dnl HAVE_STRTOLL will be defined.
6850
6851 AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
6852   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
6853   #
6854   tst_links_strtoll="unknown"
6855   tst_proto_strtoll="unknown"
6856   tst_compi_strtoll="unknown"
6857   tst_allow_strtoll="unknown"
6858   #
6859   AC_MSG_CHECKING([if strtoll can be linked])
6860   AC_LINK_IFELSE([
6861     AC_LANG_FUNC_LINK_TRY([strtoll])
6862   ],[
6863     AC_MSG_RESULT([yes])
6864     tst_links_strtoll="yes"
6865   ],[
6866     AC_MSG_RESULT([no])
6867     tst_links_strtoll="no"
6868   ])
6869   #
6870   if test "$tst_links_strtoll" = "yes"; then
6871     AC_MSG_CHECKING([if strtoll is prototyped])
6872     AC_EGREP_CPP([strtoll],[
6873       $curl_includes_stdlib
6874     ],[
6875       AC_MSG_RESULT([yes])
6876       tst_proto_strtoll="yes"
6877     ],[
6878       AC_MSG_RESULT([no])
6879       tst_proto_strtoll="no"
6880     ])
6881   fi
6882   #
6883   if test "$tst_proto_strtoll" = "yes"; then
6884     AC_MSG_CHECKING([if strtoll is compilable])
6885     AC_COMPILE_IFELSE([
6886       AC_LANG_PROGRAM([[
6887         $curl_includes_stdlib
6888       ]],[[
6889         if(0 != strtoll(0, 0, 0))
6890           return 1;
6891       ]])
6892     ],[
6893       AC_MSG_RESULT([yes])
6894       tst_compi_strtoll="yes"
6895     ],[
6896       AC_MSG_RESULT([no])
6897       tst_compi_strtoll="no"
6898     ])
6899   fi
6900   #
6901   if test "$tst_compi_strtoll" = "yes"; then
6902     AC_MSG_CHECKING([if strtoll usage allowed])
6903     if test "x$curl_disallow_strtoll" != "xyes"; then
6904       AC_MSG_RESULT([yes])
6905       tst_allow_strtoll="yes"
6906     else
6907       AC_MSG_RESULT([no])
6908       tst_allow_strtoll="no"
6909     fi
6910   fi
6911   #
6912   AC_MSG_CHECKING([if strtoll might be used])
6913   if test "$tst_links_strtoll" = "yes" &&
6914      test "$tst_proto_strtoll" = "yes" &&
6915      test "$tst_compi_strtoll" = "yes" &&
6916      test "$tst_allow_strtoll" = "yes"; then
6917     AC_MSG_RESULT([yes])
6918     AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
6919       [Define to 1 if you have the strtoll function.])
6920     curl_cv_func_strtoll="yes"
6921   else
6922     AC_MSG_RESULT([no])
6923     curl_cv_func_strtoll="no"
6924   fi
6925 ])
6926
6927
6928 dnl CURL_CHECK_FUNC_WRITEV
6929 dnl -------------------------------------------------
6930 dnl Verify if writev is available, prototyped, and
6931 dnl can be compiled. If all of these are true, and
6932 dnl usage has not been previously disallowed with
6933 dnl shell variable curl_disallow_writev, then
6934 dnl HAVE_WRITEV will be defined.
6935
6936 AC_DEFUN([CURL_CHECK_FUNC_WRITEV], [
6937   AC_REQUIRE([CURL_INCLUDES_SYS_UIO])dnl
6938   #
6939   tst_links_writev="unknown"
6940   tst_proto_writev="unknown"
6941   tst_compi_writev="unknown"
6942   tst_allow_writev="unknown"
6943   #
6944   AC_MSG_CHECKING([if writev can be linked])
6945   AC_LINK_IFELSE([
6946     AC_LANG_FUNC_LINK_TRY([writev])
6947   ],[
6948     AC_MSG_RESULT([yes])
6949     tst_links_writev="yes"
6950   ],[
6951     AC_MSG_RESULT([no])
6952     tst_links_writev="no"
6953   ])
6954   #
6955   if test "$tst_links_writev" = "yes"; then
6956     AC_MSG_CHECKING([if writev is prototyped])
6957     AC_EGREP_CPP([writev],[
6958       $curl_includes_sys_uio
6959     ],[
6960       AC_MSG_RESULT([yes])
6961       tst_proto_writev="yes"
6962     ],[
6963       AC_MSG_RESULT([no])
6964       tst_proto_writev="no"
6965     ])
6966   fi
6967   #
6968   if test "$tst_proto_writev" = "yes"; then
6969     AC_MSG_CHECKING([if writev is compilable])
6970     AC_COMPILE_IFELSE([
6971       AC_LANG_PROGRAM([[
6972         $curl_includes_sys_uio
6973       ]],[[
6974         if(0 != writev(0, 0, 0))
6975           return 1;
6976       ]])
6977     ],[
6978       AC_MSG_RESULT([yes])
6979       tst_compi_writev="yes"
6980     ],[
6981       AC_MSG_RESULT([no])
6982       tst_compi_writev="no"
6983     ])
6984   fi
6985   #
6986   if test "$tst_compi_writev" = "yes"; then
6987     AC_MSG_CHECKING([if writev usage allowed])
6988     if test "x$curl_disallow_writev" != "xyes"; then
6989       AC_MSG_RESULT([yes])
6990       tst_allow_writev="yes"
6991     else
6992       AC_MSG_RESULT([no])
6993       tst_allow_writev="no"
6994     fi
6995   fi
6996   #
6997   AC_MSG_CHECKING([if writev might be used])
6998   if test "$tst_links_writev" = "yes" &&
6999      test "$tst_proto_writev" = "yes" &&
7000      test "$tst_compi_writev" = "yes" &&
7001      test "$tst_allow_writev" = "yes"; then
7002     AC_MSG_RESULT([yes])
7003     AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
7004       [Define to 1 if you have the writev function.])
7005     curl_cv_func_writev="yes"
7006   else
7007     AC_MSG_RESULT([no])
7008     curl_cv_func_writev="no"
7009   fi
7010 ])