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