curl-compilers.m4: -Wno-pedantic-ms-format for Windows gcc 4.5 builds
[platform/upstream/curl.git] / m4 / curl-functions.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2012, 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 70
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   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
2024   #
2025   tst_links_getaddrinfo="unknown"
2026   tst_proto_getaddrinfo="unknown"
2027   tst_compi_getaddrinfo="unknown"
2028   tst_works_getaddrinfo="unknown"
2029   tst_allow_getaddrinfo="unknown"
2030   tst_tsafe_getaddrinfo="unknown"
2031   #
2032   AC_MSG_CHECKING([if getaddrinfo can be linked])
2033   AC_LINK_IFELSE([
2034     AC_LANG_PROGRAM([[
2035       $curl_includes_ws2tcpip
2036       $curl_includes_sys_socket
2037       $curl_includes_netdb
2038     ]],[[
2039       if(0 != getaddrinfo(0, 0, 0, 0))
2040         return 1;
2041     ]])
2042   ],[
2043     AC_MSG_RESULT([yes])
2044     tst_links_getaddrinfo="yes"
2045   ],[
2046     AC_MSG_RESULT([no])
2047     tst_links_getaddrinfo="no"
2048   ])
2049   #
2050   if test "$tst_links_getaddrinfo" = "yes"; then
2051     AC_MSG_CHECKING([if getaddrinfo is prototyped])
2052     AC_EGREP_CPP([getaddrinfo],[
2053       $curl_includes_ws2tcpip
2054       $curl_includes_sys_socket
2055       $curl_includes_netdb
2056     ],[
2057       AC_MSG_RESULT([yes])
2058       tst_proto_getaddrinfo="yes"
2059     ],[
2060       AC_MSG_RESULT([no])
2061       tst_proto_getaddrinfo="no"
2062     ])
2063   fi
2064   #
2065   if test "$tst_proto_getaddrinfo" = "yes"; then
2066     AC_MSG_CHECKING([if getaddrinfo is compilable])
2067     AC_COMPILE_IFELSE([
2068       AC_LANG_PROGRAM([[
2069         $curl_includes_ws2tcpip
2070         $curl_includes_sys_socket
2071         $curl_includes_netdb
2072       ]],[[
2073         if(0 != getaddrinfo(0, 0, 0, 0))
2074           return 1;
2075       ]])
2076     ],[
2077       AC_MSG_RESULT([yes])
2078       tst_compi_getaddrinfo="yes"
2079     ],[
2080       AC_MSG_RESULT([no])
2081       tst_compi_getaddrinfo="no"
2082     ])
2083   fi
2084   #
2085   dnl only do runtime verification when not cross-compiling
2086   if test "x$cross_compiling" != "xyes" &&
2087     test "$tst_compi_getaddrinfo" = "yes"; then
2088     AC_MSG_CHECKING([if getaddrinfo seems to work])
2089     AC_RUN_IFELSE([
2090       AC_LANG_PROGRAM([[
2091         $curl_includes_ws2tcpip
2092         $curl_includes_stdlib
2093         $curl_includes_string
2094         $curl_includes_sys_socket
2095         $curl_includes_netdb
2096       ]],[[
2097         struct addrinfo hints;
2098         struct addrinfo *ai = 0;
2099         int error;
2100
2101         memset(&hints, 0, sizeof(hints));
2102         hints.ai_flags = AI_NUMERICHOST;
2103         hints.ai_family = AF_UNSPEC;
2104         hints.ai_socktype = SOCK_STREAM;
2105         error = getaddrinfo("127.0.0.1", 0, &hints, &ai);
2106         if(error || !ai)
2107           exit(1); /* fail */
2108         else
2109           exit(0);
2110       ]])
2111     ],[
2112       AC_MSG_RESULT([yes])
2113       tst_works_getaddrinfo="yes"
2114     ],[
2115       AC_MSG_RESULT([no])
2116       tst_works_getaddrinfo="no"
2117     ])
2118   fi
2119   #
2120   if test "$tst_compi_getaddrinfo" = "yes" &&
2121     test "$tst_works_getaddrinfo" != "no"; then
2122     AC_MSG_CHECKING([if getaddrinfo usage allowed])
2123     if test "x$curl_disallow_getaddrinfo" != "xyes"; then
2124       AC_MSG_RESULT([yes])
2125       tst_allow_getaddrinfo="yes"
2126     else
2127       AC_MSG_RESULT([no])
2128       tst_allow_getaddrinfo="no"
2129     fi
2130   fi
2131   #
2132   AC_MSG_CHECKING([if getaddrinfo might be used])
2133   if test "$tst_links_getaddrinfo" = "yes" &&
2134      test "$tst_proto_getaddrinfo" = "yes" &&
2135      test "$tst_compi_getaddrinfo" = "yes" &&
2136      test "$tst_allow_getaddrinfo" = "yes" &&
2137      test "$tst_works_getaddrinfo" != "no"; then
2138     AC_MSG_RESULT([yes])
2139     AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO, 1,
2140       [Define to 1 if you have a working getaddrinfo function.])
2141     ac_cv_func_getaddrinfo="yes"
2142   else
2143     AC_MSG_RESULT([no])
2144     ac_cv_func_getaddrinfo="no"
2145     ac_cv_func_getaddrinfo_threadsafe="no"
2146   fi
2147   #
2148   if test "$ac_cv_func_getaddrinfo" = "yes"; then
2149     AC_MSG_CHECKING([if getaddrinfo is threadsafe])
2150     case $host_os in
2151       aix[[1234]].* | aix5.[[01]].*)
2152         dnl aix 5.1 and older
2153         tst_tsafe_getaddrinfo="no"
2154         ;;
2155       aix*)
2156         dnl aix 5.2 and newer
2157         tst_tsafe_getaddrinfo="yes"
2158         ;;
2159       darwin[[12345]].*)
2160         dnl darwin 5.0 and mac os x 10.1.X and older
2161         tst_tsafe_getaddrinfo="no"
2162         ;;
2163       darwin*)
2164         dnl darwin 6.0 and mac os x 10.2.X and newer
2165         tst_tsafe_getaddrinfo="yes"
2166         ;;
2167       freebsd[[1234]].* | freebsd5.[[1234]]*)
2168         dnl freebsd 5.4 and older
2169         tst_tsafe_getaddrinfo="no"
2170         ;;
2171       freebsd*)
2172         dnl freebsd 5.5 and newer
2173         tst_tsafe_getaddrinfo="yes"
2174         ;;
2175       hpux[[123456789]].* | hpux10.* | hpux11.0* | hpux11.10*)
2176         dnl hpux 11.10 and older
2177         tst_tsafe_getaddrinfo="no"
2178         ;;
2179       hpux*)
2180         dnl hpux 11.11 and newer
2181         tst_tsafe_getaddrinfo="yes"
2182         ;;
2183       netbsd[[123]].*)
2184         dnl netbsd 3.X and older
2185         tst_tsafe_getaddrinfo="no"
2186         ;;
2187       netbsd*)
2188         dnl netbsd 4.X and newer
2189         tst_tsafe_getaddrinfo="yes"
2190         ;;
2191       *bsd*)
2192         dnl All other bsd's
2193         tst_tsafe_getaddrinfo="no"
2194         ;;
2195       solaris2*)
2196         dnl solaris which have it
2197         tst_tsafe_getaddrinfo="yes"
2198         ;;
2199     esac
2200     if test "$tst_tsafe_getaddrinfo" = "unknown" &&
2201        test "$ac_cv_native_windows" = "yes"; then
2202       tst_tsafe_getaddrinfo="yes"
2203     fi
2204     if test "$tst_tsafe_getaddrinfo" = "unknown"; then
2205       CURL_CHECK_DEF_CC([h_errno], [
2206         $curl_includes_sys_socket
2207         $curl_includes_netdb
2208         ], [silent])
2209       if test "$curl_cv_have_def_h_errno" = "yes"; then
2210         tst_h_errno_macro="yes"
2211       else
2212         tst_h_errno_macro="no"
2213       fi
2214       AC_COMPILE_IFELSE([
2215         AC_LANG_PROGRAM([[
2216           $curl_includes_sys_socket
2217           $curl_includes_netdb
2218         ]],[[
2219           h_errno = 2;
2220           if(0 != h_errno)
2221             return 1;
2222         ]])
2223       ],[
2224         tst_h_errno_modifiable_lvalue="yes"
2225       ],[
2226         tst_h_errno_modifiable_lvalue="no"
2227       ])
2228       AC_COMPILE_IFELSE([
2229         AC_LANG_PROGRAM([[
2230         ]],[[
2231 #if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
2232           return 0;
2233 #elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 700)
2234           return 0;
2235 #else
2236           force compilation error
2237 #endif
2238         ]])
2239       ],[
2240         tst_h_errno_sbs_issue_7="yes"
2241       ],[
2242         tst_h_errno_sbs_issue_7="no"
2243       ])
2244       if test "$tst_h_errno_macro" = "no" &&
2245          test "$tst_h_errno_modifiable_lvalue" = "no" &&
2246          test "$tst_h_errno_sbs_issue_7" = "no"; then
2247         tst_tsafe_getaddrinfo="no"
2248       else
2249         tst_tsafe_getaddrinfo="yes"
2250       fi
2251     fi
2252     AC_MSG_RESULT([$tst_tsafe_getaddrinfo])
2253     if test "$tst_tsafe_getaddrinfo" = "yes"; then
2254       AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO_THREADSAFE, 1,
2255         [Define to 1 if the getaddrinfo function is threadsafe.])
2256       ac_cv_func_getaddrinfo_threadsafe="yes"
2257     else
2258       ac_cv_func_getaddrinfo_threadsafe="no"
2259     fi
2260   fi
2261 ])
2262
2263
2264 dnl CURL_CHECK_FUNC_GETHOSTBYADDR
2265 dnl -------------------------------------------------
2266 dnl Verify if gethostbyaddr is available, prototyped,
2267 dnl and can be compiled. If all of these are true,
2268 dnl and usage has not been previously disallowed with
2269 dnl shell variable curl_disallow_gethostbyaddr, then
2270 dnl HAVE_GETHOSTBYADDR will be defined.
2271
2272 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR], [
2273   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2274   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2275   #
2276   tst_links_gethostbyaddr="unknown"
2277   tst_proto_gethostbyaddr="unknown"
2278   tst_compi_gethostbyaddr="unknown"
2279   tst_allow_gethostbyaddr="unknown"
2280   #
2281   AC_MSG_CHECKING([if gethostbyaddr can be linked])
2282   AC_LINK_IFELSE([
2283     AC_LANG_PROGRAM([[
2284       $curl_includes_winsock2
2285       $curl_includes_netdb
2286     ]],[[
2287       if(0 != gethostbyaddr(0, 0, 0))
2288         return 1;
2289     ]])
2290   ],[
2291     AC_MSG_RESULT([yes])
2292     tst_links_gethostbyaddr="yes"
2293   ],[
2294     AC_MSG_RESULT([no])
2295     tst_links_gethostbyaddr="no"
2296   ])
2297   #
2298   if test "$tst_links_gethostbyaddr" = "yes"; then
2299     AC_MSG_CHECKING([if gethostbyaddr is prototyped])
2300     AC_EGREP_CPP([gethostbyaddr],[
2301       $curl_includes_winsock2
2302       $curl_includes_netdb
2303     ],[
2304       AC_MSG_RESULT([yes])
2305       tst_proto_gethostbyaddr="yes"
2306     ],[
2307       AC_MSG_RESULT([no])
2308       tst_proto_gethostbyaddr="no"
2309     ])
2310   fi
2311   #
2312   if test "$tst_proto_gethostbyaddr" = "yes"; then
2313     AC_MSG_CHECKING([if gethostbyaddr is compilable])
2314     AC_COMPILE_IFELSE([
2315       AC_LANG_PROGRAM([[
2316         $curl_includes_winsock2
2317         $curl_includes_netdb
2318       ]],[[
2319         if(0 != gethostbyaddr(0, 0, 0))
2320           return 1;
2321       ]])
2322     ],[
2323       AC_MSG_RESULT([yes])
2324       tst_compi_gethostbyaddr="yes"
2325     ],[
2326       AC_MSG_RESULT([no])
2327       tst_compi_gethostbyaddr="no"
2328     ])
2329   fi
2330   #
2331   if test "$tst_compi_gethostbyaddr" = "yes"; then
2332     AC_MSG_CHECKING([if gethostbyaddr usage allowed])
2333     if test "x$curl_disallow_gethostbyaddr" != "xyes"; then
2334       AC_MSG_RESULT([yes])
2335       tst_allow_gethostbyaddr="yes"
2336     else
2337       AC_MSG_RESULT([no])
2338       tst_allow_gethostbyaddr="no"
2339     fi
2340   fi
2341   #
2342   AC_MSG_CHECKING([if gethostbyaddr might be used])
2343   if test "$tst_links_gethostbyaddr" = "yes" &&
2344      test "$tst_proto_gethostbyaddr" = "yes" &&
2345      test "$tst_compi_gethostbyaddr" = "yes" &&
2346      test "$tst_allow_gethostbyaddr" = "yes"; then
2347     AC_MSG_RESULT([yes])
2348     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR, 1,
2349       [Define to 1 if you have the gethostbyaddr function.])
2350     ac_cv_func_gethostbyaddr="yes"
2351   else
2352     AC_MSG_RESULT([no])
2353     ac_cv_func_gethostbyaddr="no"
2354   fi
2355 ])
2356
2357 dnl CURL_CHECK_FUNC_GAI_STRERROR
2358 dnl -------------------------------------------------
2359 dnl Verify if gai_strerror is available, prototyped,
2360 dnl and can be compiled. If all of these are true,
2361 dnl and usage has not been previously disallowed with
2362 dnl shell variable curl_disallow_gai_strerror, then
2363 dnl HAVE_GAI_STRERROR will be defined.
2364
2365 AC_DEFUN([CURL_CHECK_FUNC_GAI_STRERROR], [
2366   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2367   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2368   #
2369   tst_links_gai_strerror="unknown"
2370   tst_proto_gai_strerror="unknown"
2371   tst_compi_gai_strerror="unknown"
2372   tst_allow_gai_strerror="unknown"
2373   #
2374   AC_MSG_CHECKING([if gai_strerror can be linked])
2375   AC_LINK_IFELSE([
2376     AC_LANG_PROGRAM([[
2377       $curl_includes_winsock2
2378       $curl_includes_netdb
2379     ]],[[
2380       if(0 != gai_strerror(0))
2381         return 1;
2382     ]])
2383   ],[
2384     AC_MSG_RESULT([yes])
2385     tst_links_gai_strerror="yes"
2386   ],[
2387     AC_MSG_RESULT([no])
2388     tst_links_gai_strerror="no"
2389   ])
2390   #
2391   if test "$tst_links_gai_strerror" = "yes"; then
2392     AC_MSG_CHECKING([if gai_strerror is prototyped])
2393     AC_EGREP_CPP([gai_strerror],[
2394       $curl_includes_winsock2
2395       $curl_includes_netdb
2396     ],[
2397       AC_MSG_RESULT([yes])
2398       tst_proto_gai_strerror="yes"
2399     ],[
2400       AC_MSG_RESULT([no])
2401       tst_proto_gai_strerror="no"
2402     ])
2403   fi
2404   #
2405   if test "$tst_proto_gai_strerror" = "yes"; then
2406     AC_MSG_CHECKING([if gai_strerror is compilable])
2407     AC_COMPILE_IFELSE([
2408       AC_LANG_PROGRAM([[
2409         $curl_includes_winsock2
2410         $curl_includes_netdb
2411       ]],[[
2412         if(0 != gai_strerror(0))
2413           return 1;
2414       ]])
2415     ],[
2416       AC_MSG_RESULT([yes])
2417       tst_compi_gai_strerror="yes"
2418     ],[
2419       AC_MSG_RESULT([no])
2420       tst_compi_gai_strerror="no"
2421     ])
2422   fi
2423   #
2424   if test "$tst_compi_gai_strerror" = "yes"; then
2425     AC_MSG_CHECKING([if gai_strerror usage allowed])
2426     if test "x$curl_disallow_gai_strerror" != "xyes"; then
2427       AC_MSG_RESULT([yes])
2428       tst_allow_gai_strerror="yes"
2429     else
2430       AC_MSG_RESULT([no])
2431       tst_allow_gai_strerror="no"
2432     fi
2433   fi
2434   #
2435   AC_MSG_CHECKING([if gai_strerror might be used])
2436   if test "$tst_links_gai_strerror" = "yes" &&
2437      test "$tst_proto_gai_strerror" = "yes" &&
2438      test "$tst_compi_gai_strerror" = "yes" &&
2439      test "$tst_allow_gai_strerror" = "yes"; then
2440     AC_MSG_RESULT([yes])
2441     AC_DEFINE_UNQUOTED(HAVE_GAI_STRERROR, 1,
2442       [Define to 1 if you have the gai_strerror function.])
2443     ac_cv_func_gai_strerror="yes"
2444   else
2445     AC_MSG_RESULT([no])
2446     ac_cv_func_gai_strerror="no"
2447   fi
2448 ])
2449
2450
2451 dnl CURL_CHECK_FUNC_GETHOSTBYADDR_R
2452 dnl -------------------------------------------------
2453 dnl Verify if gethostbyaddr_r is available, prototyped,
2454 dnl and can be compiled. If all of these are true, and
2455 dnl usage has not been previously disallowed with
2456 dnl shell variable curl_disallow_gethostbyaddr_r, then
2457 dnl HAVE_GETHOSTBYADDR_R will be defined.
2458
2459 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR_R], [
2460   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2461   #
2462   tst_links_gethostbyaddr_r="unknown"
2463   tst_proto_gethostbyaddr_r="unknown"
2464   tst_compi_gethostbyaddr_r="unknown"
2465   tst_allow_gethostbyaddr_r="unknown"
2466   tst_nargs_gethostbyaddr_r="unknown"
2467   #
2468   AC_MSG_CHECKING([if gethostbyaddr_r can be linked])
2469   AC_LINK_IFELSE([
2470     AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2471   ],[
2472     AC_MSG_RESULT([yes])
2473     tst_links_gethostbyaddr_r="yes"
2474   ],[
2475     AC_MSG_RESULT([no])
2476     tst_links_gethostbyaddr_r="no"
2477   ])
2478   #
2479   if test "$tst_links_gethostbyaddr_r" = "yes"; then
2480     AC_MSG_CHECKING([if gethostbyaddr_r is prototyped])
2481     AC_EGREP_CPP([gethostbyaddr_r],[
2482       $curl_includes_netdb
2483     ],[
2484       AC_MSG_RESULT([yes])
2485       tst_proto_gethostbyaddr_r="yes"
2486     ],[
2487       AC_MSG_RESULT([no])
2488       tst_proto_gethostbyaddr_r="no"
2489     ])
2490   fi
2491   #
2492   if test "$tst_proto_gethostbyaddr_r" = "yes"; then
2493     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2494       AC_MSG_CHECKING([if gethostbyaddr_r takes 5 args.])
2495       AC_COMPILE_IFELSE([
2496         AC_LANG_PROGRAM([[
2497           $curl_includes_netdb
2498         ]],[[
2499           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0))
2500             return 1;
2501         ]])
2502       ],[
2503         AC_MSG_RESULT([yes])
2504         tst_compi_gethostbyaddr_r="yes"
2505         tst_nargs_gethostbyaddr_r="5"
2506       ],[
2507         AC_MSG_RESULT([no])
2508         tst_compi_gethostbyaddr_r="no"
2509       ])
2510     fi
2511     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2512       AC_MSG_CHECKING([if gethostbyaddr_r takes 7 args.])
2513       AC_COMPILE_IFELSE([
2514         AC_LANG_PROGRAM([[
2515           $curl_includes_netdb
2516         ]],[[
2517           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0))
2518             return 1;
2519         ]])
2520       ],[
2521         AC_MSG_RESULT([yes])
2522         tst_compi_gethostbyaddr_r="yes"
2523         tst_nargs_gethostbyaddr_r="7"
2524       ],[
2525         AC_MSG_RESULT([no])
2526         tst_compi_gethostbyaddr_r="no"
2527       ])
2528     fi
2529     if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
2530       AC_MSG_CHECKING([if gethostbyaddr_r takes 8 args.])
2531       AC_COMPILE_IFELSE([
2532         AC_LANG_PROGRAM([[
2533           $curl_includes_netdb
2534         ]],[[
2535           if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0, 0))
2536             return 1;
2537         ]])
2538       ],[
2539         AC_MSG_RESULT([yes])
2540         tst_compi_gethostbyaddr_r="yes"
2541         tst_nargs_gethostbyaddr_r="8"
2542       ],[
2543         AC_MSG_RESULT([no])
2544         tst_compi_gethostbyaddr_r="no"
2545       ])
2546     fi
2547     AC_MSG_CHECKING([if gethostbyaddr_r is compilable])
2548     if test "$tst_compi_gethostbyaddr_r" = "yes"; then
2549       AC_MSG_RESULT([yes])
2550     else
2551       AC_MSG_RESULT([no])
2552     fi
2553   fi
2554   #
2555   if test "$tst_compi_gethostbyaddr_r" = "yes"; then
2556     AC_MSG_CHECKING([if gethostbyaddr_r usage allowed])
2557     if test "x$curl_disallow_gethostbyaddr_r" != "xyes"; then
2558       AC_MSG_RESULT([yes])
2559       tst_allow_gethostbyaddr_r="yes"
2560     else
2561       AC_MSG_RESULT([no])
2562       tst_allow_gethostbyaddr_r="no"
2563     fi
2564   fi
2565   #
2566   AC_MSG_CHECKING([if gethostbyaddr_r might be used])
2567   if test "$tst_links_gethostbyaddr_r" = "yes" &&
2568      test "$tst_proto_gethostbyaddr_r" = "yes" &&
2569      test "$tst_compi_gethostbyaddr_r" = "yes" &&
2570      test "$tst_allow_gethostbyaddr_r" = "yes"; then
2571     AC_MSG_RESULT([yes])
2572     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
2573       [Define to 1 if you have the gethostbyaddr_r function.])
2574     dnl AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_ARGS, $tst_nargs_gethostbyaddr_r,
2575     dnl   [Specifies the number of arguments to gethostbyaddr_r])
2576     #
2577     if test "$tst_nargs_gethostbyaddr_r" -eq "5"; then
2578       AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2579     elif test "$tst_nargs_gethostbyaddr_r" -eq "7"; then
2580       AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2581     elif test "$tst_nargs_gethostbyaddr_r" -eq "8"; then
2582       AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2583     fi
2584     #
2585     ac_cv_func_gethostbyaddr_r="yes"
2586   else
2587     AC_MSG_RESULT([no])
2588     ac_cv_func_gethostbyaddr_r="no"
2589   fi
2590 ])
2591
2592
2593 dnl CURL_CHECK_FUNC_GETHOSTBYNAME
2594 dnl -------------------------------------------------
2595 dnl Verify if gethostbyname is available, prototyped,
2596 dnl and can be compiled. If all of these are true,
2597 dnl and usage has not been previously disallowed with
2598 dnl shell variable curl_disallow_gethostbyname, then
2599 dnl HAVE_GETHOSTBYNAME will be defined.
2600
2601 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME], [
2602   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2603   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2604   #
2605   tst_links_gethostbyname="unknown"
2606   tst_proto_gethostbyname="unknown"
2607   tst_compi_gethostbyname="unknown"
2608   tst_allow_gethostbyname="unknown"
2609   #
2610   AC_MSG_CHECKING([if gethostbyname can be linked])
2611   AC_LINK_IFELSE([
2612     AC_LANG_PROGRAM([[
2613       $curl_includes_winsock2
2614       $curl_includes_netdb
2615     ]],[[
2616       if(0 != gethostbyname(0))
2617         return 1;
2618     ]])
2619   ],[
2620     AC_MSG_RESULT([yes])
2621     tst_links_gethostbyname="yes"
2622   ],[
2623     AC_MSG_RESULT([no])
2624     tst_links_gethostbyname="no"
2625   ])
2626   #
2627   if test "$tst_links_gethostbyname" = "yes"; then
2628     AC_MSG_CHECKING([if gethostbyname is prototyped])
2629     AC_EGREP_CPP([gethostbyname],[
2630       $curl_includes_winsock2
2631       $curl_includes_netdb
2632     ],[
2633       AC_MSG_RESULT([yes])
2634       tst_proto_gethostbyname="yes"
2635     ],[
2636       AC_MSG_RESULT([no])
2637       tst_proto_gethostbyname="no"
2638     ])
2639   fi
2640   #
2641   if test "$tst_proto_gethostbyname" = "yes"; then
2642     AC_MSG_CHECKING([if gethostbyname is compilable])
2643     AC_COMPILE_IFELSE([
2644       AC_LANG_PROGRAM([[
2645         $curl_includes_winsock2
2646         $curl_includes_netdb
2647       ]],[[
2648         if(0 != gethostbyname(0))
2649           return 1;
2650       ]])
2651     ],[
2652       AC_MSG_RESULT([yes])
2653       tst_compi_gethostbyname="yes"
2654     ],[
2655       AC_MSG_RESULT([no])
2656       tst_compi_gethostbyname="no"
2657     ])
2658   fi
2659   #
2660   if test "$tst_compi_gethostbyname" = "yes"; then
2661     AC_MSG_CHECKING([if gethostbyname usage allowed])
2662     if test "x$curl_disallow_gethostbyname" != "xyes"; then
2663       AC_MSG_RESULT([yes])
2664       tst_allow_gethostbyname="yes"
2665     else
2666       AC_MSG_RESULT([no])
2667       tst_allow_gethostbyname="no"
2668     fi
2669   fi
2670   #
2671   AC_MSG_CHECKING([if gethostbyname might be used])
2672   if test "$tst_links_gethostbyname" = "yes" &&
2673      test "$tst_proto_gethostbyname" = "yes" &&
2674      test "$tst_compi_gethostbyname" = "yes" &&
2675      test "$tst_allow_gethostbyname" = "yes"; then
2676     AC_MSG_RESULT([yes])
2677     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME, 1,
2678       [Define to 1 if you have the gethostbyname function.])
2679     ac_cv_func_gethostbyname="yes"
2680   else
2681     AC_MSG_RESULT([no])
2682     ac_cv_func_gethostbyname="no"
2683   fi
2684 ])
2685
2686
2687 dnl CURL_CHECK_FUNC_GETHOSTBYNAME_R
2688 dnl -------------------------------------------------
2689 dnl Verify if gethostbyname_r is available, prototyped,
2690 dnl and can be compiled. If all of these are true, and
2691 dnl usage has not been previously disallowed with
2692 dnl shell variable curl_disallow_gethostbyname_r, then
2693 dnl HAVE_GETHOSTBYNAME_R will be defined.
2694
2695 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [
2696   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
2697   #
2698   tst_links_gethostbyname_r="unknown"
2699   tst_proto_gethostbyname_r="unknown"
2700   tst_compi_gethostbyname_r="unknown"
2701   tst_allow_gethostbyname_r="unknown"
2702   tst_nargs_gethostbyname_r="unknown"
2703   #
2704   AC_MSG_CHECKING([if gethostbyname_r can be linked])
2705   AC_LINK_IFELSE([
2706     AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
2707   ],[
2708     AC_MSG_RESULT([yes])
2709     tst_links_gethostbyname_r="yes"
2710   ],[
2711     AC_MSG_RESULT([no])
2712     tst_links_gethostbyname_r="no"
2713   ])
2714   #
2715   if test "$tst_links_gethostbyname_r" = "yes"; then
2716     AC_MSG_CHECKING([if gethostbyname_r is prototyped])
2717     AC_EGREP_CPP([gethostbyname_r],[
2718       $curl_includes_netdb
2719     ],[
2720       AC_MSG_RESULT([yes])
2721       tst_proto_gethostbyname_r="yes"
2722     ],[
2723       AC_MSG_RESULT([no])
2724       tst_proto_gethostbyname_r="no"
2725     ])
2726   fi
2727   #
2728   if test "$tst_proto_gethostbyname_r" = "yes"; then
2729     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2730       AC_MSG_CHECKING([if gethostbyname_r takes 3 args.])
2731       AC_COMPILE_IFELSE([
2732         AC_LANG_PROGRAM([[
2733           $curl_includes_netdb
2734         ]],[[
2735           if(0 != gethostbyname_r(0, 0, 0))
2736             return 1;
2737         ]])
2738       ],[
2739         AC_MSG_RESULT([yes])
2740         tst_compi_gethostbyname_r="yes"
2741         tst_nargs_gethostbyname_r="3"
2742       ],[
2743         AC_MSG_RESULT([no])
2744         tst_compi_gethostbyname_r="no"
2745       ])
2746     fi
2747     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2748       AC_MSG_CHECKING([if gethostbyname_r takes 5 args.])
2749       AC_COMPILE_IFELSE([
2750         AC_LANG_PROGRAM([[
2751           $curl_includes_netdb
2752         ]],[[
2753           if(0 != gethostbyname_r(0, 0, 0, 0, 0))
2754             return 1;
2755         ]])
2756       ],[
2757         AC_MSG_RESULT([yes])
2758         tst_compi_gethostbyname_r="yes"
2759         tst_nargs_gethostbyname_r="5"
2760       ],[
2761         AC_MSG_RESULT([no])
2762         tst_compi_gethostbyname_r="no"
2763       ])
2764     fi
2765     if test "$tst_nargs_gethostbyname_r" = "unknown"; then
2766       AC_MSG_CHECKING([if gethostbyname_r takes 6 args.])
2767       AC_COMPILE_IFELSE([
2768         AC_LANG_PROGRAM([[
2769           $curl_includes_netdb
2770         ]],[[
2771           if(0 != gethostbyname_r(0, 0, 0, 0, 0, 0))
2772             return 1;
2773         ]])
2774       ],[
2775         AC_MSG_RESULT([yes])
2776         tst_compi_gethostbyname_r="yes"
2777         tst_nargs_gethostbyname_r="6"
2778       ],[
2779         AC_MSG_RESULT([no])
2780         tst_compi_gethostbyname_r="no"
2781       ])
2782     fi
2783     AC_MSG_CHECKING([if gethostbyname_r is compilable])
2784     if test "$tst_compi_gethostbyname_r" = "yes"; then
2785       AC_MSG_RESULT([yes])
2786     else
2787       AC_MSG_RESULT([no])
2788     fi
2789   fi
2790   #
2791   if test "$tst_compi_gethostbyname_r" = "yes"; then
2792     AC_MSG_CHECKING([if gethostbyname_r usage allowed])
2793     if test "x$curl_disallow_gethostbyname_r" != "xyes"; then
2794       AC_MSG_RESULT([yes])
2795       tst_allow_gethostbyname_r="yes"
2796     else
2797       AC_MSG_RESULT([no])
2798       tst_allow_gethostbyname_r="no"
2799     fi
2800   fi
2801   #
2802   AC_MSG_CHECKING([if gethostbyname_r might be used])
2803   if test "$tst_links_gethostbyname_r" = "yes" &&
2804      test "$tst_proto_gethostbyname_r" = "yes" &&
2805      test "$tst_compi_gethostbyname_r" = "yes" &&
2806      test "$tst_allow_gethostbyname_r" = "yes"; then
2807     AC_MSG_RESULT([yes])
2808     AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
2809       [Define to 1 if you have the gethostbyname_r function.])
2810     dnl AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_ARGS, $tst_nargs_gethostbyname_r,
2811     dnl   [Specifies the number of arguments to gethostbyname_r])
2812     #
2813     if test "$tst_nargs_gethostbyname_r" -eq "3"; then
2814       AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2815     elif test "$tst_nargs_gethostbyname_r" -eq "5"; then
2816       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2817     elif test "$tst_nargs_gethostbyname_r" -eq "6"; then
2818       AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2819     fi
2820     #
2821     ac_cv_func_gethostbyname_r="yes"
2822   else
2823     AC_MSG_RESULT([no])
2824     ac_cv_func_gethostbyname_r="no"
2825   fi
2826 ])
2827
2828
2829 dnl CURL_CHECK_FUNC_GETHOSTNAME
2830 dnl -------------------------------------------------
2831 dnl Verify if gethostname is available, prototyped, and
2832 dnl can be compiled. If all of these are true, and
2833 dnl usage has not been previously disallowed with
2834 dnl shell variable curl_disallow_gethostname, then
2835 dnl HAVE_GETHOSTNAME will be defined.
2836
2837 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
2838   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2839   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
2840   #
2841   tst_links_gethostname="unknown"
2842   tst_proto_gethostname="unknown"
2843   tst_compi_gethostname="unknown"
2844   tst_allow_gethostname="unknown"
2845   #
2846   AC_MSG_CHECKING([if gethostname can be linked])
2847   AC_LINK_IFELSE([
2848     AC_LANG_PROGRAM([[
2849       $curl_includes_winsock2
2850       $curl_includes_unistd
2851     ]],[[
2852       if(0 != gethostname(0, 0))
2853         return 1;
2854     ]])
2855   ],[
2856     AC_MSG_RESULT([yes])
2857     tst_links_gethostname="yes"
2858   ],[
2859     AC_MSG_RESULT([no])
2860     tst_links_gethostname="no"
2861   ])
2862   #
2863   if test "$tst_links_gethostname" = "yes"; then
2864     AC_MSG_CHECKING([if gethostname is prototyped])
2865     AC_EGREP_CPP([gethostname],[
2866       $curl_includes_winsock2
2867       $curl_includes_unistd
2868     ],[
2869       AC_MSG_RESULT([yes])
2870       tst_proto_gethostname="yes"
2871     ],[
2872       AC_MSG_RESULT([no])
2873       tst_proto_gethostname="no"
2874     ])
2875   fi
2876   #
2877   if test "$tst_proto_gethostname" = "yes"; then
2878     AC_MSG_CHECKING([if gethostname is compilable])
2879     AC_COMPILE_IFELSE([
2880       AC_LANG_PROGRAM([[
2881         $curl_includes_winsock2
2882         $curl_includes_unistd
2883       ]],[[
2884         if(0 != gethostname(0, 0))
2885           return 1;
2886       ]])
2887     ],[
2888       AC_MSG_RESULT([yes])
2889       tst_compi_gethostname="yes"
2890     ],[
2891       AC_MSG_RESULT([no])
2892       tst_compi_gethostname="no"
2893     ])
2894   fi
2895   #
2896   if test "$tst_compi_gethostname" = "yes"; then
2897     AC_MSG_CHECKING([if gethostname usage allowed])
2898     if test "x$curl_disallow_gethostname" != "xyes"; then
2899       AC_MSG_RESULT([yes])
2900       tst_allow_gethostname="yes"
2901     else
2902       AC_MSG_RESULT([no])
2903       tst_allow_gethostname="no"
2904     fi
2905   fi
2906   #
2907   AC_MSG_CHECKING([if gethostname might be used])
2908   if test "$tst_links_gethostname" = "yes" &&
2909      test "$tst_proto_gethostname" = "yes" &&
2910      test "$tst_compi_gethostname" = "yes" &&
2911      test "$tst_allow_gethostname" = "yes"; then
2912     AC_MSG_RESULT([yes])
2913     AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
2914       [Define to 1 if you have the gethostname function.])
2915     ac_cv_func_gethostname="yes"
2916   else
2917     AC_MSG_RESULT([no])
2918     ac_cv_func_gethostname="no"
2919   fi
2920 ])
2921
2922
2923 dnl CURL_CHECK_FUNC_GETIFADDRS
2924 dnl -------------------------------------------------
2925 dnl Verify if getifaddrs is available, prototyped, can
2926 dnl be compiled and seems to work. If all of these are
2927 dnl true, and usage has not been previously disallowed
2928 dnl with shell variable curl_disallow_getifaddrs, then
2929 dnl HAVE_GETIFADDRS will be defined.
2930
2931 AC_DEFUN([CURL_CHECK_FUNC_GETIFADDRS], [
2932   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2933   AC_REQUIRE([CURL_INCLUDES_IFADDRS])dnl
2934   #
2935   tst_links_getifaddrs="unknown"
2936   tst_proto_getifaddrs="unknown"
2937   tst_compi_getifaddrs="unknown"
2938   tst_works_getifaddrs="unknown"
2939   tst_allow_getifaddrs="unknown"
2940   #
2941   AC_MSG_CHECKING([if getifaddrs can be linked])
2942   AC_LINK_IFELSE([
2943     AC_LANG_FUNC_LINK_TRY([getifaddrs])
2944   ],[
2945     AC_MSG_RESULT([yes])
2946     tst_links_getifaddrs="yes"
2947   ],[
2948     AC_MSG_RESULT([no])
2949     tst_links_getifaddrs="no"
2950   ])
2951   #
2952   if test "$tst_links_getifaddrs" = "yes"; then
2953     AC_MSG_CHECKING([if getifaddrs is prototyped])
2954     AC_EGREP_CPP([getifaddrs],[
2955       $curl_includes_ifaddrs
2956     ],[
2957       AC_MSG_RESULT([yes])
2958       tst_proto_getifaddrs="yes"
2959     ],[
2960       AC_MSG_RESULT([no])
2961       tst_proto_getifaddrs="no"
2962     ])
2963   fi
2964   #
2965   if test "$tst_proto_getifaddrs" = "yes"; then
2966     AC_MSG_CHECKING([if getifaddrs is compilable])
2967     AC_COMPILE_IFELSE([
2968       AC_LANG_PROGRAM([[
2969         $curl_includes_ifaddrs
2970       ]],[[
2971         if(0 != getifaddrs(0))
2972           return 1;
2973       ]])
2974     ],[
2975       AC_MSG_RESULT([yes])
2976       tst_compi_getifaddrs="yes"
2977     ],[
2978       AC_MSG_RESULT([no])
2979       tst_compi_getifaddrs="no"
2980     ])
2981   fi
2982   #
2983   dnl only do runtime verification when not cross-compiling
2984   if test "x$cross_compiling" != "xyes" &&
2985     test "$tst_compi_getifaddrs" = "yes"; then
2986     AC_MSG_CHECKING([if getifaddrs seems to work])
2987     AC_RUN_IFELSE([
2988       AC_LANG_PROGRAM([[
2989         $curl_includes_stdlib
2990         $curl_includes_ifaddrs
2991       ]],[[
2992         struct ifaddrs *ifa = 0;
2993         int error;
2994
2995         error = getifaddrs(&ifa);
2996         if(error || !ifa)
2997           exit(1); /* fail */
2998         else
2999           exit(0);
3000       ]])
3001     ],[
3002       AC_MSG_RESULT([yes])
3003       tst_works_getifaddrs="yes"
3004     ],[
3005       AC_MSG_RESULT([no])
3006       tst_works_getifaddrs="no"
3007     ])
3008   fi
3009   #
3010   if test "$tst_compi_getifaddrs" = "yes" &&
3011     test "$tst_works_getifaddrs" != "no"; then
3012     AC_MSG_CHECKING([if getifaddrs usage allowed])
3013     if test "x$curl_disallow_getifaddrs" != "xyes"; then
3014       AC_MSG_RESULT([yes])
3015       tst_allow_getifaddrs="yes"
3016     else
3017       AC_MSG_RESULT([no])
3018       tst_allow_getifaddrs="no"
3019     fi
3020   fi
3021   #
3022   AC_MSG_CHECKING([if getifaddrs might be used])
3023   if test "$tst_links_getifaddrs" = "yes" &&
3024      test "$tst_proto_getifaddrs" = "yes" &&
3025      test "$tst_compi_getifaddrs" = "yes" &&
3026      test "$tst_allow_getifaddrs" = "yes" &&
3027      test "$tst_works_getifaddrs" != "no"; then
3028     AC_MSG_RESULT([yes])
3029     AC_DEFINE_UNQUOTED(HAVE_GETIFADDRS, 1,
3030       [Define to 1 if you have a working getifaddrs function.])
3031     ac_cv_func_getifaddrs="yes"
3032   else
3033     AC_MSG_RESULT([no])
3034     ac_cv_func_getifaddrs="no"
3035   fi
3036 ])
3037
3038
3039 dnl CURL_CHECK_FUNC_GETSERVBYPORT_R
3040 dnl -------------------------------------------------
3041 dnl Verify if getservbyport_r is available, prototyped,
3042 dnl and can be compiled. If all of these are true, and
3043 dnl usage has not been previously disallowed with
3044 dnl shell variable curl_disallow_getservbyport_r, then
3045 dnl HAVE_GETSERVBYPORT_R will be defined.
3046
3047 AC_DEFUN([CURL_CHECK_FUNC_GETSERVBYPORT_R], [
3048   AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
3049   #
3050   tst_links_getservbyport_r="unknown"
3051   tst_proto_getservbyport_r="unknown"
3052   tst_compi_getservbyport_r="unknown"
3053   tst_allow_getservbyport_r="unknown"
3054   tst_nargs_getservbyport_r="unknown"
3055   #
3056   AC_MSG_CHECKING([if getservbyport_r can be linked])
3057   AC_LINK_IFELSE([
3058     AC_LANG_FUNC_LINK_TRY([getservbyport_r])
3059   ],[
3060     AC_MSG_RESULT([yes])
3061     tst_links_getservbyport_r="yes"
3062   ],[
3063     AC_MSG_RESULT([no])
3064     tst_links_getservbyport_r="no"
3065   ])
3066   #
3067   if test "$tst_links_getservbyport_r" = "yes"; then
3068     AC_MSG_CHECKING([if getservbyport_r is prototyped])
3069     AC_EGREP_CPP([getservbyport_r],[
3070       $curl_includes_netdb
3071     ],[
3072       AC_MSG_RESULT([yes])
3073       tst_proto_getservbyport_r="yes"
3074     ],[
3075       AC_MSG_RESULT([no])
3076       tst_proto_getservbyport_r="no"
3077     ])
3078   fi
3079   #
3080   if test "$tst_proto_getservbyport_r" = "yes"; then
3081     if test "$tst_nargs_getservbyport_r" = "unknown"; then
3082       AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
3083       AC_COMPILE_IFELSE([
3084         AC_LANG_PROGRAM([[
3085           $curl_includes_netdb
3086         ]],[[
3087           if(0 != getservbyport_r(0, 0, 0, 0))
3088             return 1;
3089         ]])
3090       ],[
3091         AC_MSG_RESULT([yes])
3092         tst_compi_getservbyport_r="yes"
3093         tst_nargs_getservbyport_r="4"
3094       ],[
3095         AC_MSG_RESULT([no])
3096         tst_compi_getservbyport_r="no"
3097       ])
3098     fi
3099     if test "$tst_nargs_getservbyport_r" = "unknown"; then
3100       AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
3101       AC_COMPILE_IFELSE([
3102         AC_LANG_PROGRAM([[
3103           $curl_includes_netdb
3104         ]],[[
3105           if(0 != getservbyport_r(0, 0, 0, 0, 0))
3106             return 1;
3107         ]])
3108       ],[
3109         AC_MSG_RESULT([yes])
3110         tst_compi_getservbyport_r="yes"
3111         tst_nargs_getservbyport_r="5"
3112       ],[
3113         AC_MSG_RESULT([no])
3114         tst_compi_getservbyport_r="no"
3115       ])
3116     fi
3117     if test "$tst_nargs_getservbyport_r" = "unknown"; then
3118       AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
3119       AC_COMPILE_IFELSE([
3120         AC_LANG_PROGRAM([[
3121           $curl_includes_netdb
3122         ]],[[
3123           if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
3124             return 1;
3125         ]])
3126       ],[
3127         AC_MSG_RESULT([yes])
3128         tst_compi_getservbyport_r="yes"
3129         tst_nargs_getservbyport_r="6"
3130       ],[
3131         AC_MSG_RESULT([no])
3132         tst_compi_getservbyport_r="no"
3133       ])
3134     fi
3135     AC_MSG_CHECKING([if getservbyport_r is compilable])
3136     if test "$tst_compi_getservbyport_r" = "yes"; then
3137       AC_MSG_RESULT([yes])
3138     else
3139       AC_MSG_RESULT([no])
3140     fi
3141   fi
3142   #
3143   if test "$tst_compi_getservbyport_r" = "yes"; then
3144     AC_MSG_CHECKING([if getservbyport_r usage allowed])
3145     if test "x$curl_disallow_getservbyport_r" != "xyes"; then
3146       AC_MSG_RESULT([yes])
3147       tst_allow_getservbyport_r="yes"
3148     else
3149       AC_MSG_RESULT([no])
3150       tst_allow_getservbyport_r="no"
3151     fi
3152   fi
3153   #
3154   AC_MSG_CHECKING([if getservbyport_r might be used])
3155   if test "$tst_links_getservbyport_r" = "yes" &&
3156      test "$tst_proto_getservbyport_r" = "yes" &&
3157      test "$tst_compi_getservbyport_r" = "yes" &&
3158      test "$tst_allow_getservbyport_r" = "yes"; then
3159     AC_MSG_RESULT([yes])
3160     AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
3161       [Define to 1 if you have the getservbyport_r function.])
3162     AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
3163       [Specifies the number of arguments to getservbyport_r])
3164     if test "$tst_nargs_getservbyport_r" -eq "4"; then
3165       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
3166         [Specifies the size of the buffer to pass to getservbyport_r])
3167     else
3168       AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
3169         [Specifies the size of the buffer to pass to getservbyport_r])
3170     fi
3171     ac_cv_func_getservbyport_r="yes"
3172   else
3173     AC_MSG_RESULT([no])
3174     ac_cv_func_getservbyport_r="no"
3175   fi
3176 ])
3177
3178
3179 dnl CURL_CHECK_FUNC_GETXATTR
3180 dnl -------------------------------------------------
3181 dnl Verify if getxattr is available, prototyped, and
3182 dnl can be compiled. If all of these are true, and
3183 dnl usage has not been previously disallowed with
3184 dnl shell variable curl_disallow_getxattr, then
3185 dnl HAVE_GETXATTR will be defined.
3186
3187 AC_DEFUN([CURL_CHECK_FUNC_GETXATTR], [
3188   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
3189   #
3190   tst_links_getxattr="unknown"
3191   tst_proto_getxattr="unknown"
3192   tst_compi_getxattr="unknown"
3193   tst_allow_getxattr="unknown"
3194   tst_nargs_getxattr="unknown"
3195   #
3196   AC_MSG_CHECKING([if getxattr can be linked])
3197   AC_LINK_IFELSE([
3198     AC_LANG_FUNC_LINK_TRY([getxattr])
3199   ],[
3200     AC_MSG_RESULT([yes])
3201     tst_links_getxattr="yes"
3202   ],[
3203     AC_MSG_RESULT([no])
3204     tst_links_getxattr="no"
3205   ])
3206   #
3207   if test "$tst_links_getxattr" = "yes"; then
3208     AC_MSG_CHECKING([if getxattr is prototyped])
3209     AC_EGREP_CPP([getxattr],[
3210       $curl_includes_sys_xattr
3211     ],[
3212       AC_MSG_RESULT([yes])
3213       tst_proto_getxattr="yes"
3214     ],[
3215       AC_MSG_RESULT([no])
3216       tst_proto_getxattr="no"
3217     ])
3218   fi
3219   #
3220   if test "$tst_proto_getxattr" = "yes"; then
3221     if test "$tst_nargs_getxattr" = "unknown"; then
3222       AC_MSG_CHECKING([if getxattr takes 4 args.])
3223       AC_COMPILE_IFELSE([
3224         AC_LANG_PROGRAM([[
3225           $curl_includes_sys_xattr
3226         ]],[[
3227           if(0 != getxattr(0, 0, 0, 0))
3228             return 1;
3229         ]])
3230       ],[
3231         AC_MSG_RESULT([yes])
3232         tst_compi_getxattr="yes"
3233         tst_nargs_getxattr="4"
3234       ],[
3235         AC_MSG_RESULT([no])
3236         tst_compi_getxattr="no"
3237       ])
3238     fi
3239     if test "$tst_nargs_getxattr" = "unknown"; then
3240       AC_MSG_CHECKING([if getxattr takes 6 args.])
3241       AC_COMPILE_IFELSE([
3242         AC_LANG_PROGRAM([[
3243           $curl_includes_sys_xattr
3244         ]],[[
3245           if(0 != getxattr(0, 0, 0, 0, 0, 0))
3246             return 1;
3247         ]])
3248       ],[
3249         AC_MSG_RESULT([yes])
3250         tst_compi_getxattr="yes"
3251         tst_nargs_getxattr="6"
3252       ],[
3253         AC_MSG_RESULT([no])
3254         tst_compi_getxattr="no"
3255       ])
3256     fi
3257     AC_MSG_CHECKING([if getxattr is compilable])
3258     if test "$tst_compi_getxattr" = "yes"; then
3259       AC_MSG_RESULT([yes])
3260     else
3261       AC_MSG_RESULT([no])
3262     fi
3263   fi
3264   #
3265   if test "$tst_compi_getxattr" = "yes"; then
3266     AC_MSG_CHECKING([if getxattr usage allowed])
3267     if test "x$curl_disallow_getxattr" != "xyes"; then
3268       AC_MSG_RESULT([yes])
3269       tst_allow_getxattr="yes"
3270     else
3271       AC_MSG_RESULT([no])
3272       tst_allow_getxattr="no"
3273     fi
3274   fi
3275   #
3276   AC_MSG_CHECKING([if getxattr might be used])
3277   if test "$tst_links_getxattr" = "yes" &&
3278      test "$tst_proto_getxattr" = "yes" &&
3279      test "$tst_compi_getxattr" = "yes" &&
3280      test "$tst_allow_getxattr" = "yes"; then
3281     AC_MSG_RESULT([yes])
3282     AC_DEFINE_UNQUOTED(HAVE_GETXATTR, 1,
3283       [Define to 1 if you have the getxattr function.])
3284     dnl AC_DEFINE_UNQUOTED(GETXATTR_ARGS, $tst_nargs_getxattr,
3285     dnl   [Specifies the number of arguments to getxattr])
3286     #
3287     if test "$tst_nargs_getxattr" -eq "4"; then
3288       AC_DEFINE(HAVE_GETXATTR_4, 1, [getxattr() takes 4 args])
3289     elif test "$tst_nargs_getxattr" -eq "6"; then
3290       AC_DEFINE(HAVE_GETXATTR_6, 1, [getxattr() takes 6 args])
3291     fi
3292     #
3293     ac_cv_func_getxattr="yes"
3294   else
3295     AC_MSG_RESULT([no])
3296     ac_cv_func_getxattr="no"
3297   fi
3298 ])
3299
3300
3301 dnl CURL_CHECK_FUNC_GMTIME_R
3302 dnl -------------------------------------------------
3303 dnl Verify if gmtime_r is available, prototyped, can
3304 dnl be compiled and seems to work. If all of these are
3305 dnl true, and usage has not been previously disallowed
3306 dnl with shell variable curl_disallow_gmtime_r, then
3307 dnl HAVE_GMTIME_R will be defined.
3308
3309 AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
3310   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3311   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
3312   #
3313   tst_links_gmtime_r="unknown"
3314   tst_proto_gmtime_r="unknown"
3315   tst_compi_gmtime_r="unknown"
3316   tst_works_gmtime_r="unknown"
3317   tst_allow_gmtime_r="unknown"
3318   #
3319   AC_MSG_CHECKING([if gmtime_r can be linked])
3320   AC_LINK_IFELSE([
3321     AC_LANG_FUNC_LINK_TRY([gmtime_r])
3322   ],[
3323     AC_MSG_RESULT([yes])
3324     tst_links_gmtime_r="yes"
3325   ],[
3326     AC_MSG_RESULT([no])
3327     tst_links_gmtime_r="no"
3328   ])
3329   #
3330   if test "$tst_links_gmtime_r" = "yes"; then
3331     AC_MSG_CHECKING([if gmtime_r is prototyped])
3332     AC_EGREP_CPP([gmtime_r],[
3333       $curl_includes_time
3334     ],[
3335       AC_MSG_RESULT([yes])
3336       tst_proto_gmtime_r="yes"
3337     ],[
3338       AC_MSG_RESULT([no])
3339       tst_proto_gmtime_r="no"
3340     ])
3341   fi
3342   #
3343   if test "$tst_proto_gmtime_r" = "yes"; then
3344     AC_MSG_CHECKING([if gmtime_r is compilable])
3345     AC_COMPILE_IFELSE([
3346       AC_LANG_PROGRAM([[
3347         $curl_includes_time
3348       ]],[[
3349         if(0 != gmtime_r(0, 0))
3350           return 1;
3351       ]])
3352     ],[
3353       AC_MSG_RESULT([yes])
3354       tst_compi_gmtime_r="yes"
3355     ],[
3356       AC_MSG_RESULT([no])
3357       tst_compi_gmtime_r="no"
3358     ])
3359   fi
3360   #
3361   dnl only do runtime verification when not cross-compiling
3362   if test "x$cross_compiling" != "xyes" &&
3363     test "$tst_compi_gmtime_r" = "yes"; then
3364     AC_MSG_CHECKING([if gmtime_r seems to work])
3365     AC_RUN_IFELSE([
3366       AC_LANG_PROGRAM([[
3367         $curl_includes_stdlib
3368         $curl_includes_time
3369       ]],[[
3370         time_t local = 1170352587;
3371         struct tm *gmt = 0;
3372         struct tm result;
3373         gmt = gmtime_r(&local, &result);
3374         if(gmt)
3375           exit(0);
3376         else
3377           exit(1);
3378       ]])
3379     ],[
3380       AC_MSG_RESULT([yes])
3381       tst_works_gmtime_r="yes"
3382     ],[
3383       AC_MSG_RESULT([no])
3384       tst_works_gmtime_r="no"
3385     ])
3386   fi
3387   #
3388   if test "$tst_compi_gmtime_r" = "yes" &&
3389     test "$tst_works_gmtime_r" != "no"; then
3390     AC_MSG_CHECKING([if gmtime_r usage allowed])
3391     if test "x$curl_disallow_gmtime_r" != "xyes"; then
3392       AC_MSG_RESULT([yes])
3393       tst_allow_gmtime_r="yes"
3394     else
3395       AC_MSG_RESULT([no])
3396       tst_allow_gmtime_r="no"
3397     fi
3398   fi
3399   #
3400   AC_MSG_CHECKING([if gmtime_r might be used])
3401   if test "$tst_links_gmtime_r" = "yes" &&
3402      test "$tst_proto_gmtime_r" = "yes" &&
3403      test "$tst_compi_gmtime_r" = "yes" &&
3404      test "$tst_allow_gmtime_r" = "yes" &&
3405      test "$tst_works_gmtime_r" != "no"; then
3406     AC_MSG_RESULT([yes])
3407     AC_DEFINE_UNQUOTED(HAVE_GMTIME_R, 1,
3408       [Define to 1 if you have a working gmtime_r function.])
3409     ac_cv_func_gmtime_r="yes"
3410   else
3411     AC_MSG_RESULT([no])
3412     ac_cv_func_gmtime_r="no"
3413   fi
3414 ])
3415
3416
3417 dnl CURL_CHECK_FUNC_INET_NTOA_R
3418 dnl -------------------------------------------------
3419 dnl Verify if inet_ntoa_r is available, prototyped,
3420 dnl and can be compiled. If all of these are true, and
3421 dnl usage has not been previously disallowed with
3422 dnl shell variable curl_disallow_inet_ntoa_r, then
3423 dnl HAVE_INET_NTOA_R will be defined.
3424
3425 AC_DEFUN([CURL_CHECK_FUNC_INET_NTOA_R], [
3426   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
3427   #
3428   tst_links_inet_ntoa_r="unknown"
3429   tst_proto_inet_ntoa_r="unknown"
3430   tst_compi_inet_ntoa_r="unknown"
3431   tst_allow_inet_ntoa_r="unknown"
3432   tst_nargs_inet_ntoa_r="unknown"
3433   #
3434   AC_MSG_CHECKING([if inet_ntoa_r can be linked])
3435   AC_LINK_IFELSE([
3436     AC_LANG_FUNC_LINK_TRY([inet_ntoa_r])
3437   ],[
3438     AC_MSG_RESULT([yes])
3439     tst_links_inet_ntoa_r="yes"
3440   ],[
3441     AC_MSG_RESULT([no])
3442     tst_links_inet_ntoa_r="no"
3443   ])
3444   #
3445   if test "$tst_links_inet_ntoa_r" = "yes"; then
3446     AC_MSG_CHECKING([if inet_ntoa_r is prototyped])
3447     AC_EGREP_CPP([inet_ntoa_r],[
3448       $curl_includes_arpa_inet
3449     ],[
3450       AC_MSG_RESULT([yes])
3451       tst_proto_inet_ntoa_r="yes"
3452     ],[
3453       AC_MSG_RESULT([no])
3454       tst_proto_inet_ntoa_r="no"
3455     ])
3456   fi
3457   #
3458   if test "$tst_proto_inet_ntoa_r" = "yes"; then
3459     if test "$tst_nargs_inet_ntoa_r" = "unknown"; then
3460       AC_MSG_CHECKING([if inet_ntoa_r takes 2 args.])
3461       AC_COMPILE_IFELSE([
3462         AC_LANG_PROGRAM([[
3463           $curl_includes_arpa_inet
3464         ]],[[
3465           struct in_addr addr;
3466           if(0 != inet_ntoa_r(addr, 0))
3467             return 1;
3468         ]])
3469       ],[
3470         AC_MSG_RESULT([yes])
3471         tst_compi_inet_ntoa_r="yes"
3472         tst_nargs_inet_ntoa_r="2"
3473       ],[
3474         AC_MSG_RESULT([no])
3475         tst_compi_inet_ntoa_r="no"
3476       ])
3477     fi
3478     if test "$tst_nargs_inet_ntoa_r" = "unknown"; then
3479       AC_MSG_CHECKING([if inet_ntoa_r takes 3 args.])
3480       AC_COMPILE_IFELSE([
3481         AC_LANG_PROGRAM([[
3482           $curl_includes_arpa_inet
3483         ]],[[
3484           struct in_addr addr;
3485           if(0 != inet_ntoa_r(addr, 0, 0))
3486             return 1;
3487         ]])
3488       ],[
3489         AC_MSG_RESULT([yes])
3490         tst_compi_inet_ntoa_r="yes"
3491         tst_nargs_inet_ntoa_r="3"
3492       ],[
3493         AC_MSG_RESULT([no])
3494         tst_compi_inet_ntoa_r="no"
3495       ])
3496     fi
3497     AC_MSG_CHECKING([if inet_ntoa_r is compilable])
3498     if test "$tst_compi_inet_ntoa_r" = "yes"; then
3499       AC_MSG_RESULT([yes])
3500     else
3501       AC_MSG_RESULT([no])
3502     fi
3503   fi
3504   #
3505   if test "$tst_compi_inet_ntoa_r" = "yes"; then
3506     AC_MSG_CHECKING([if inet_ntoa_r usage allowed])
3507     if test "x$curl_disallow_inet_ntoa_r" != "xyes"; then
3508       AC_MSG_RESULT([yes])
3509       tst_allow_inet_ntoa_r="yes"
3510     else
3511       AC_MSG_RESULT([no])
3512       tst_allow_inet_ntoa_r="no"
3513     fi
3514   fi
3515   #
3516   AC_MSG_CHECKING([if inet_ntoa_r might be used])
3517   if test "$tst_links_inet_ntoa_r" = "yes" &&
3518      test "$tst_proto_inet_ntoa_r" = "yes" &&
3519      test "$tst_compi_inet_ntoa_r" = "yes" &&
3520      test "$tst_allow_inet_ntoa_r" = "yes"; then
3521     AC_MSG_RESULT([yes])
3522     AC_DEFINE_UNQUOTED(HAVE_INET_NTOA_R, 1,
3523       [Define to 1 if you have the inet_ntoa_r function.])
3524     dnl AC_DEFINE_UNQUOTED(INET_NTOA_R_ARGS, $tst_nargs_inet_ntoa_r,
3525     dnl   [Specifies the number of arguments to inet_ntoa_r])
3526     #
3527     if test "$tst_nargs_inet_ntoa_r" -eq "2"; then
3528       AC_DEFINE(HAVE_INET_NTOA_R_2, 1, [inet_ntoa_r() takes 2 args])
3529     elif test "$tst_nargs_inet_ntoa_r" -eq "3"; then
3530       AC_DEFINE(HAVE_INET_NTOA_R_3, 1, [inet_ntoa_r() takes 3 args])
3531     fi
3532     #
3533     ac_cv_func_inet_ntoa_r="yes"
3534   else
3535     AC_MSG_RESULT([no])
3536     ac_cv_func_inet_ntoa_r="no"
3537   fi
3538 ])
3539
3540
3541 dnl CURL_CHECK_FUNC_INET_NTOP
3542 dnl -------------------------------------------------
3543 dnl Verify if inet_ntop is available, prototyped, can
3544 dnl be compiled and seems to work. If all of these are
3545 dnl true, and usage has not been previously disallowed
3546 dnl with shell variable curl_disallow_inet_ntop, then
3547 dnl HAVE_INET_NTOP will be defined.
3548
3549 AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
3550   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3551   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
3552   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3553   #
3554   tst_links_inet_ntop="unknown"
3555   tst_proto_inet_ntop="unknown"
3556   tst_compi_inet_ntop="unknown"
3557   tst_works_inet_ntop="unknown"
3558   tst_allow_inet_ntop="unknown"
3559   #
3560   AC_MSG_CHECKING([if inet_ntop can be linked])
3561   AC_LINK_IFELSE([
3562     AC_LANG_FUNC_LINK_TRY([inet_ntop])
3563   ],[
3564     AC_MSG_RESULT([yes])
3565     tst_links_inet_ntop="yes"
3566   ],[
3567     AC_MSG_RESULT([no])
3568     tst_links_inet_ntop="no"
3569   ])
3570   #
3571   if test "$tst_links_inet_ntop" = "yes"; then
3572     AC_MSG_CHECKING([if inet_ntop is prototyped])
3573     AC_EGREP_CPP([inet_ntop],[
3574       $curl_includes_arpa_inet
3575     ],[
3576       AC_MSG_RESULT([yes])
3577       tst_proto_inet_ntop="yes"
3578     ],[
3579       AC_MSG_RESULT([no])
3580       tst_proto_inet_ntop="no"
3581     ])
3582   fi
3583   #
3584   if test "$tst_proto_inet_ntop" = "yes"; then
3585     AC_MSG_CHECKING([if inet_ntop is compilable])
3586     AC_COMPILE_IFELSE([
3587       AC_LANG_PROGRAM([[
3588         $curl_includes_arpa_inet
3589       ]],[[
3590         if(0 != inet_ntop(0, 0, 0, 0))
3591           return 1;
3592       ]])
3593     ],[
3594       AC_MSG_RESULT([yes])
3595       tst_compi_inet_ntop="yes"
3596     ],[
3597       AC_MSG_RESULT([no])
3598       tst_compi_inet_ntop="no"
3599     ])
3600   fi
3601   #
3602   dnl only do runtime verification when not cross-compiling
3603   if test "x$cross_compiling" != "xyes" &&
3604     test "$tst_compi_inet_ntop" = "yes"; then
3605     AC_MSG_CHECKING([if inet_ntop seems to work])
3606     AC_RUN_IFELSE([
3607       AC_LANG_PROGRAM([[
3608         $curl_includes_stdlib
3609         $curl_includes_arpa_inet
3610         $curl_includes_string
3611       ]],[[
3612         char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
3613         char ipv4res[sizeof "255.255.255.255"];
3614         unsigned char ipv6a[26];
3615         unsigned char ipv4a[5];
3616         char *ipv6ptr = 0;
3617         char *ipv4ptr = 0;
3618         /* - */
3619         ipv4res[0] = '\0';
3620         ipv4a[0] = 0xc0;
3621         ipv4a[1] = 0xa8;
3622         ipv4a[2] = 0x64;
3623         ipv4a[3] = 0x01;
3624         ipv4a[4] = 0x01;
3625         /* - */
3626         ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
3627         if(!ipv4ptr)
3628           exit(1); /* fail */
3629         if(ipv4ptr != ipv4res)
3630           exit(1); /* fail */
3631         if(!ipv4ptr[0])
3632           exit(1); /* fail */
3633         if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
3634           exit(1); /* fail */
3635         /* - */
3636         ipv6res[0] = '\0';
3637         memset(ipv6a, 0, sizeof(ipv6a));
3638         ipv6a[0] = 0xfe;
3639         ipv6a[1] = 0x80;
3640         ipv6a[8] = 0x02;
3641         ipv6a[9] = 0x14;
3642         ipv6a[10] = 0x4f;
3643         ipv6a[11] = 0xff;
3644         ipv6a[12] = 0xfe;
3645         ipv6a[13] = 0x0b;
3646         ipv6a[14] = 0x76;
3647         ipv6a[15] = 0xc8;
3648         ipv6a[25] = 0x01;
3649         /* - */
3650         ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
3651         if(!ipv6ptr)
3652           exit(1); /* fail */
3653         if(ipv6ptr != ipv6res)
3654           exit(1); /* fail */
3655         if(!ipv6ptr[0])
3656           exit(1); /* fail */
3657         if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0)
3658           exit(1); /* fail */
3659         /* - */
3660         exit(0);
3661       ]])
3662     ],[
3663       AC_MSG_RESULT([yes])
3664       tst_works_inet_ntop="yes"
3665     ],[
3666       AC_MSG_RESULT([no])
3667       tst_works_inet_ntop="no"
3668     ])
3669   fi
3670   #
3671   if test "$tst_compi_inet_ntop" = "yes" &&
3672     test "$tst_works_inet_ntop" != "no"; then
3673     AC_MSG_CHECKING([if inet_ntop usage allowed])
3674     if test "x$curl_disallow_inet_ntop" != "xyes"; then
3675       AC_MSG_RESULT([yes])
3676       tst_allow_inet_ntop="yes"
3677     else
3678       AC_MSG_RESULT([no])
3679       tst_allow_inet_ntop="no"
3680     fi
3681   fi
3682   #
3683   AC_MSG_CHECKING([if inet_ntop might be used])
3684   if test "$tst_links_inet_ntop" = "yes" &&
3685      test "$tst_proto_inet_ntop" = "yes" &&
3686      test "$tst_compi_inet_ntop" = "yes" &&
3687      test "$tst_allow_inet_ntop" = "yes" &&
3688      test "$tst_works_inet_ntop" != "no"; then
3689     AC_MSG_RESULT([yes])
3690     AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, 1,
3691       [Define to 1 if you have a IPv6 capable working inet_ntop function.])
3692     ac_cv_func_inet_ntop="yes"
3693   else
3694     AC_MSG_RESULT([no])
3695     ac_cv_func_inet_ntop="no"
3696   fi
3697 ])
3698
3699
3700 dnl CURL_CHECK_FUNC_INET_PTON
3701 dnl -------------------------------------------------
3702 dnl Verify if inet_pton is available, prototyped, can
3703 dnl be compiled and seems to work. If all of these are
3704 dnl true, and usage has not been previously disallowed
3705 dnl with shell variable curl_disallow_inet_pton, then
3706 dnl HAVE_INET_PTON will be defined.
3707
3708 AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [
3709   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
3710   AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
3711   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3712   #
3713   tst_links_inet_pton="unknown"
3714   tst_proto_inet_pton="unknown"
3715   tst_compi_inet_pton="unknown"
3716   tst_works_inet_pton="unknown"
3717   tst_allow_inet_pton="unknown"
3718   #
3719   AC_MSG_CHECKING([if inet_pton can be linked])
3720   AC_LINK_IFELSE([
3721     AC_LANG_FUNC_LINK_TRY([inet_pton])
3722   ],[
3723     AC_MSG_RESULT([yes])
3724     tst_links_inet_pton="yes"
3725   ],[
3726     AC_MSG_RESULT([no])
3727     tst_links_inet_pton="no"
3728   ])
3729   #
3730   if test "$tst_links_inet_pton" = "yes"; then
3731     AC_MSG_CHECKING([if inet_pton is prototyped])
3732     AC_EGREP_CPP([inet_pton],[
3733       $curl_includes_arpa_inet
3734     ],[
3735       AC_MSG_RESULT([yes])
3736       tst_proto_inet_pton="yes"
3737     ],[
3738       AC_MSG_RESULT([no])
3739       tst_proto_inet_pton="no"
3740     ])
3741   fi
3742   #
3743   if test "$tst_proto_inet_pton" = "yes"; then
3744     AC_MSG_CHECKING([if inet_pton is compilable])
3745     AC_COMPILE_IFELSE([
3746       AC_LANG_PROGRAM([[
3747         $curl_includes_arpa_inet
3748       ]],[[
3749         if(0 != inet_pton(0, 0, 0))
3750           return 1;
3751       ]])
3752     ],[
3753       AC_MSG_RESULT([yes])
3754       tst_compi_inet_pton="yes"
3755     ],[
3756       AC_MSG_RESULT([no])
3757       tst_compi_inet_pton="no"
3758     ])
3759   fi
3760   #
3761   dnl only do runtime verification when not cross-compiling
3762   if test "x$cross_compiling" != "xyes" &&
3763     test "$tst_compi_inet_pton" = "yes"; then
3764     AC_MSG_CHECKING([if inet_pton seems to work])
3765     AC_RUN_IFELSE([
3766       AC_LANG_PROGRAM([[
3767         $curl_includes_stdlib
3768         $curl_includes_arpa_inet
3769         $curl_includes_string
3770       ]],[[
3771         unsigned char ipv6a[16+1];
3772         unsigned char ipv4a[4+1];
3773         const char *ipv6src = "fe80::214:4fff:fe0b:76c8";
3774         const char *ipv4src = "192.168.100.1";
3775         /* - */
3776         memset(ipv4a, 1, sizeof(ipv4a));
3777         if(1 != inet_pton(AF_INET, ipv4src, ipv4a))
3778           exit(1); /* fail */
3779         /* - */
3780         if( (ipv4a[0] != 0xc0) ||
3781             (ipv4a[1] != 0xa8) ||
3782             (ipv4a[2] != 0x64) ||
3783             (ipv4a[3] != 0x01) ||
3784             (ipv4a[4] != 0x01) )
3785           exit(1); /* fail */
3786         /* - */
3787         memset(ipv6a, 1, sizeof(ipv6a));
3788         if(1 != inet_pton(AF_INET6, ipv6src, ipv6a))
3789           exit(1); /* fail */
3790         /* - */
3791         if( (ipv6a[0]  != 0xfe) ||
3792             (ipv6a[1]  != 0x80) ||
3793             (ipv6a[8]  != 0x02) ||
3794             (ipv6a[9]  != 0x14) ||
3795             (ipv6a[10] != 0x4f) ||
3796             (ipv6a[11] != 0xff) ||
3797             (ipv6a[12] != 0xfe) ||
3798             (ipv6a[13] != 0x0b) ||
3799             (ipv6a[14] != 0x76) ||
3800             (ipv6a[15] != 0xc8) ||
3801             (ipv6a[16] != 0x01) )
3802           exit(1); /* fail */
3803         /* - */
3804         if( (ipv6a[2]  != 0x0) ||
3805             (ipv6a[3]  != 0x0) ||
3806             (ipv6a[4]  != 0x0) ||
3807             (ipv6a[5]  != 0x0) ||
3808             (ipv6a[6]  != 0x0) ||
3809             (ipv6a[7]  != 0x0) )
3810           exit(1); /* fail */
3811         /* - */
3812         exit(0);
3813       ]])
3814     ],[
3815       AC_MSG_RESULT([yes])
3816       tst_works_inet_pton="yes"
3817     ],[
3818       AC_MSG_RESULT([no])
3819       tst_works_inet_pton="no"
3820     ])
3821   fi
3822   #
3823   if test "$tst_compi_inet_pton" = "yes" &&
3824     test "$tst_works_inet_pton" != "no"; then
3825     AC_MSG_CHECKING([if inet_pton usage allowed])
3826     if test "x$curl_disallow_inet_pton" != "xyes"; then
3827       AC_MSG_RESULT([yes])
3828       tst_allow_inet_pton="yes"
3829     else
3830       AC_MSG_RESULT([no])
3831       tst_allow_inet_pton="no"
3832     fi
3833   fi
3834   #
3835   AC_MSG_CHECKING([if inet_pton might be used])
3836   if test "$tst_links_inet_pton" = "yes" &&
3837      test "$tst_proto_inet_pton" = "yes" &&
3838      test "$tst_compi_inet_pton" = "yes" &&
3839      test "$tst_allow_inet_pton" = "yes" &&
3840      test "$tst_works_inet_pton" != "no"; then
3841     AC_MSG_RESULT([yes])
3842     AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1,
3843       [Define to 1 if you have a IPv6 capable working inet_pton function.])
3844     ac_cv_func_inet_pton="yes"
3845   else
3846     AC_MSG_RESULT([no])
3847     ac_cv_func_inet_pton="no"
3848   fi
3849 ])
3850
3851
3852 dnl CURL_CHECK_FUNC_IOCTL
3853 dnl -------------------------------------------------
3854 dnl Verify if ioctl is available, prototyped, and
3855 dnl can be compiled. If all of these are true, and
3856 dnl usage has not been previously disallowed with
3857 dnl shell variable curl_disallow_ioctl, then
3858 dnl HAVE_IOCTL will be defined.
3859
3860 AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [
3861   AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
3862   #
3863   tst_links_ioctl="unknown"
3864   tst_proto_ioctl="unknown"
3865   tst_compi_ioctl="unknown"
3866   tst_allow_ioctl="unknown"
3867   #
3868   AC_MSG_CHECKING([if ioctl can be linked])
3869   AC_LINK_IFELSE([
3870     AC_LANG_FUNC_LINK_TRY([ioctl])
3871   ],[
3872     AC_MSG_RESULT([yes])
3873     tst_links_ioctl="yes"
3874   ],[
3875     AC_MSG_RESULT([no])
3876     tst_links_ioctl="no"
3877   ])
3878   #
3879   if test "$tst_links_ioctl" = "yes"; then
3880     AC_MSG_CHECKING([if ioctl is prototyped])
3881     AC_EGREP_CPP([ioctl],[
3882       $curl_includes_stropts
3883     ],[
3884       AC_MSG_RESULT([yes])
3885       tst_proto_ioctl="yes"
3886     ],[
3887       AC_MSG_RESULT([no])
3888       tst_proto_ioctl="no"
3889     ])
3890   fi
3891   #
3892   if test "$tst_proto_ioctl" = "yes"; then
3893     AC_MSG_CHECKING([if ioctl is compilable])
3894     AC_COMPILE_IFELSE([
3895       AC_LANG_PROGRAM([[
3896         $curl_includes_stropts
3897       ]],[[
3898         if(0 != ioctl(0, 0, 0))
3899           return 1;
3900       ]])
3901     ],[
3902       AC_MSG_RESULT([yes])
3903       tst_compi_ioctl="yes"
3904     ],[
3905       AC_MSG_RESULT([no])
3906       tst_compi_ioctl="no"
3907     ])
3908   fi
3909   #
3910   if test "$tst_compi_ioctl" = "yes"; then
3911     AC_MSG_CHECKING([if ioctl usage allowed])
3912     if test "x$curl_disallow_ioctl" != "xyes"; then
3913       AC_MSG_RESULT([yes])
3914       tst_allow_ioctl="yes"
3915     else
3916       AC_MSG_RESULT([no])
3917       tst_allow_ioctl="no"
3918     fi
3919   fi
3920   #
3921   AC_MSG_CHECKING([if ioctl might be used])
3922   if test "$tst_links_ioctl" = "yes" &&
3923      test "$tst_proto_ioctl" = "yes" &&
3924      test "$tst_compi_ioctl" = "yes" &&
3925      test "$tst_allow_ioctl" = "yes"; then
3926     AC_MSG_RESULT([yes])
3927     AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
3928       [Define to 1 if you have the ioctl function.])
3929     ac_cv_func_ioctl="yes"
3930     CURL_CHECK_FUNC_IOCTL_FIONBIO
3931     CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
3932   else
3933     AC_MSG_RESULT([no])
3934     ac_cv_func_ioctl="no"
3935   fi
3936 ])
3937
3938
3939 dnl CURL_CHECK_FUNC_IOCTL_FIONBIO
3940 dnl -------------------------------------------------
3941 dnl Verify if ioctl with the FIONBIO command is
3942 dnl available, can be compiled, and seems to work. If
3943 dnl all of these are true, then HAVE_IOCTL_FIONBIO
3944 dnl will be defined.
3945
3946 AC_DEFUN([CURL_CHECK_FUNC_IOCTL_FIONBIO], [
3947   #
3948   tst_compi_ioctl_fionbio="unknown"
3949   tst_allow_ioctl_fionbio="unknown"
3950   #
3951   if test "$ac_cv_func_ioctl" = "yes"; then
3952     AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
3953     AC_COMPILE_IFELSE([
3954       AC_LANG_PROGRAM([[
3955         $curl_includes_stropts
3956       ]],[[
3957         int flags = 0;
3958         if(0 != ioctl(0, FIONBIO, &flags))
3959           return 1;
3960       ]])
3961     ],[
3962       AC_MSG_RESULT([yes])
3963       tst_compi_ioctl_fionbio="yes"
3964     ],[
3965       AC_MSG_RESULT([no])
3966       tst_compi_ioctl_fionbio="no"
3967     ])
3968   fi
3969   #
3970   if test "$tst_compi_ioctl_fionbio" = "yes"; then
3971     AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
3972     if test "x$curl_disallow_ioctl_fionbio" != "xyes"; then
3973       AC_MSG_RESULT([yes])
3974       tst_allow_ioctl_fionbio="yes"
3975     else
3976       AC_MSG_RESULT([no])
3977       tst_allow_ioctl_fionbio="no"
3978     fi
3979   fi
3980   #
3981   AC_MSG_CHECKING([if ioctl FIONBIO might be used])
3982   if test "$tst_compi_ioctl_fionbio" = "yes" &&
3983      test "$tst_allow_ioctl_fionbio" = "yes"; then
3984     AC_MSG_RESULT([yes])
3985     AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
3986       [Define to 1 if you have a working ioctl FIONBIO function.])
3987     ac_cv_func_ioctl_fionbio="yes"
3988   else
3989     AC_MSG_RESULT([no])
3990     ac_cv_func_ioctl_fionbio="no"
3991   fi
3992 ])
3993
3994
3995 dnl CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
3996 dnl -------------------------------------------------
3997 dnl Verify if ioctl with the SIOCGIFADDR command is available,
3998 dnl struct ifreq is defined, they can be compiled, and seem to
3999 dnl work. If all of these are true, then HAVE_IOCTL_SIOCGIFADDR
4000 dnl will be defined.
4001
4002 AC_DEFUN([CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR], [
4003   #
4004   tst_compi_ioctl_siocgifaddr="unknown"
4005   tst_allow_ioctl_siocgifaddr="unknown"
4006   #
4007   if test "$ac_cv_func_ioctl" = "yes"; then
4008     AC_MSG_CHECKING([if ioctl SIOCGIFADDR is compilable])
4009     AC_COMPILE_IFELSE([
4010       AC_LANG_PROGRAM([[
4011         $curl_includes_stropts
4012         #include <net/if.h>
4013       ]],[[
4014         struct ifreq ifr;
4015         if(0 != ioctl(0, SIOCGIFADDR, &ifr))
4016           return 1;
4017       ]])
4018     ],[
4019       AC_MSG_RESULT([yes])
4020       tst_compi_ioctl_siocgifaddr="yes"
4021     ],[
4022       AC_MSG_RESULT([no])
4023       tst_compi_ioctl_siocgifaddr="no"
4024     ])
4025   fi
4026   #
4027   if test "$tst_compi_ioctl_siocgifaddr" = "yes"; then
4028     AC_MSG_CHECKING([if ioctl SIOCGIFADDR usage allowed])
4029     if test "x$curl_disallow_ioctl_siocgifaddr" != "xyes"; then
4030       AC_MSG_RESULT([yes])
4031       tst_allow_ioctl_siocgifaddr="yes"
4032     else
4033       AC_MSG_RESULT([no])
4034       tst_allow_ioctl_siocgifaddr="no"
4035     fi
4036   fi
4037   #
4038   AC_MSG_CHECKING([if ioctl SIOCGIFADDR might be used])
4039   if test "$tst_compi_ioctl_siocgifaddr" = "yes" &&
4040      test "$tst_allow_ioctl_siocgifaddr" = "yes"; then
4041     AC_MSG_RESULT([yes])
4042     AC_DEFINE_UNQUOTED(HAVE_IOCTL_SIOCGIFADDR, 1,
4043       [Define to 1 if you have a working ioctl SIOCGIFADDR function.])
4044     ac_cv_func_ioctl_siocgifaddr="yes"
4045   else
4046     AC_MSG_RESULT([no])
4047     ac_cv_func_ioctl_siocgifaddr="no"
4048   fi
4049 ])
4050
4051
4052 dnl CURL_CHECK_FUNC_IOCTLSOCKET
4053 dnl -------------------------------------------------
4054 dnl Verify if ioctlsocket is available, prototyped, and
4055 dnl can be compiled. If all of these are true, and
4056 dnl usage has not been previously disallowed with
4057 dnl shell variable curl_disallow_ioctlsocket, then
4058 dnl HAVE_IOCTLSOCKET will be defined.
4059
4060 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [
4061   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
4062   #
4063   tst_links_ioctlsocket="unknown"
4064   tst_proto_ioctlsocket="unknown"
4065   tst_compi_ioctlsocket="unknown"
4066   tst_allow_ioctlsocket="unknown"
4067   #
4068   AC_MSG_CHECKING([if ioctlsocket can be linked])
4069   AC_LINK_IFELSE([
4070     AC_LANG_PROGRAM([[
4071       $curl_includes_winsock2
4072     ]],[[
4073       if(0 != ioctlsocket(0, 0, 0))
4074         return 1;
4075     ]])
4076   ],[
4077     AC_MSG_RESULT([yes])
4078     tst_links_ioctlsocket="yes"
4079   ],[
4080     AC_MSG_RESULT([no])
4081     tst_links_ioctlsocket="no"
4082   ])
4083   #
4084   if test "$tst_links_ioctlsocket" = "yes"; then
4085     AC_MSG_CHECKING([if ioctlsocket is prototyped])
4086     AC_EGREP_CPP([ioctlsocket],[
4087       $curl_includes_winsock2
4088     ],[
4089       AC_MSG_RESULT([yes])
4090       tst_proto_ioctlsocket="yes"
4091     ],[
4092       AC_MSG_RESULT([no])
4093       tst_proto_ioctlsocket="no"
4094     ])
4095   fi
4096   #
4097   if test "$tst_proto_ioctlsocket" = "yes"; then
4098     AC_MSG_CHECKING([if ioctlsocket is compilable])
4099     AC_COMPILE_IFELSE([
4100       AC_LANG_PROGRAM([[
4101         $curl_includes_winsock2
4102       ]],[[
4103         if(0 != ioctlsocket(0, 0, 0))
4104           return 1;
4105       ]])
4106     ],[
4107       AC_MSG_RESULT([yes])
4108       tst_compi_ioctlsocket="yes"
4109     ],[
4110       AC_MSG_RESULT([no])
4111       tst_compi_ioctlsocket="no"
4112     ])
4113   fi
4114   #
4115   if test "$tst_compi_ioctlsocket" = "yes"; then
4116     AC_MSG_CHECKING([if ioctlsocket usage allowed])
4117     if test "x$curl_disallow_ioctlsocket" != "xyes"; then
4118       AC_MSG_RESULT([yes])
4119       tst_allow_ioctlsocket="yes"
4120     else
4121       AC_MSG_RESULT([no])
4122       tst_allow_ioctlsocket="no"
4123     fi
4124   fi
4125   #
4126   AC_MSG_CHECKING([if ioctlsocket might be used])
4127   if test "$tst_links_ioctlsocket" = "yes" &&
4128      test "$tst_proto_ioctlsocket" = "yes" &&
4129      test "$tst_compi_ioctlsocket" = "yes" &&
4130      test "$tst_allow_ioctlsocket" = "yes"; then
4131     AC_MSG_RESULT([yes])
4132     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
4133       [Define to 1 if you have the ioctlsocket function.])
4134     ac_cv_func_ioctlsocket="yes"
4135     CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
4136   else
4137     AC_MSG_RESULT([no])
4138     ac_cv_func_ioctlsocket="no"
4139   fi
4140 ])
4141
4142
4143 dnl CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
4144 dnl -------------------------------------------------
4145 dnl Verify if ioctlsocket with the FIONBIO command is
4146 dnl available, can be compiled, and seems to work. If
4147 dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
4148 dnl will be defined.
4149
4150 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
4151   #
4152   tst_compi_ioctlsocket_fionbio="unknown"
4153   tst_allow_ioctlsocket_fionbio="unknown"
4154   #
4155   if test "$ac_cv_func_ioctlsocket" = "yes"; then
4156     AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
4157     AC_COMPILE_IFELSE([
4158       AC_LANG_PROGRAM([[
4159         $curl_includes_winsock2
4160       ]],[[
4161         int flags = 0;
4162         if(0 != ioctlsocket(0, FIONBIO, &flags))
4163           return 1;
4164       ]])
4165     ],[
4166       AC_MSG_RESULT([yes])
4167       tst_compi_ioctlsocket_fionbio="yes"
4168     ],[
4169       AC_MSG_RESULT([no])
4170       tst_compi_ioctlsocket_fionbio="no"
4171     ])
4172   fi
4173   #
4174   if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
4175     AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
4176     if test "x$curl_disallow_ioctlsocket_fionbio" != "xyes"; then
4177       AC_MSG_RESULT([yes])
4178       tst_allow_ioctlsocket_fionbio="yes"
4179     else
4180       AC_MSG_RESULT([no])
4181       tst_allow_ioctlsocket_fionbio="no"
4182     fi
4183   fi
4184   #
4185   AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
4186   if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
4187      test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
4188     AC_MSG_RESULT([yes])
4189     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
4190       [Define to 1 if you have a working ioctlsocket FIONBIO function.])
4191     ac_cv_func_ioctlsocket_fionbio="yes"
4192   else
4193     AC_MSG_RESULT([no])
4194     ac_cv_func_ioctlsocket_fionbio="no"
4195   fi
4196 ])
4197
4198
4199 dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
4200 dnl -------------------------------------------------
4201 dnl Verify if IoctlSocket is available, prototyped, and
4202 dnl can be compiled. If all of these are true, and
4203 dnl usage has not been previously disallowed with
4204 dnl shell variable curl_disallow_ioctlsocket_camel,
4205 dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
4206
4207 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
4208   AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
4209   #
4210   tst_links_ioctlsocket_camel="unknown"
4211   tst_proto_ioctlsocket_camel="unknown"
4212   tst_compi_ioctlsocket_camel="unknown"
4213   tst_allow_ioctlsocket_camel="unknown"
4214   #
4215   AC_MSG_CHECKING([if IoctlSocket can be linked])
4216   AC_LINK_IFELSE([
4217     AC_LANG_FUNC_LINK_TRY([IoctlSocket])
4218   ],[
4219     AC_MSG_RESULT([yes])
4220     tst_links_ioctlsocket_camel="yes"
4221   ],[
4222     AC_MSG_RESULT([no])
4223     tst_links_ioctlsocket_camel="no"
4224   ])
4225   #
4226   if test "$tst_links_ioctlsocket_camel" = "yes"; then
4227     AC_MSG_CHECKING([if IoctlSocket is prototyped])
4228     AC_EGREP_CPP([IoctlSocket],[
4229       $curl_includes_stropts
4230     ],[
4231       AC_MSG_RESULT([yes])
4232       tst_proto_ioctlsocket_camel="yes"
4233     ],[
4234       AC_MSG_RESULT([no])
4235       tst_proto_ioctlsocket_camel="no"
4236     ])
4237   fi
4238   #
4239   if test "$tst_proto_ioctlsocket_camel" = "yes"; then
4240     AC_MSG_CHECKING([if IoctlSocket is compilable])
4241     AC_COMPILE_IFELSE([
4242       AC_LANG_PROGRAM([[
4243         $curl_includes_stropts
4244       ]],[[
4245         if(0 != IoctlSocket(0, 0, 0))
4246           return 1;
4247       ]])
4248     ],[
4249       AC_MSG_RESULT([yes])
4250       tst_compi_ioctlsocket_camel="yes"
4251     ],[
4252       AC_MSG_RESULT([no])
4253       tst_compi_ioctlsocket_camel="no"
4254     ])
4255   fi
4256   #
4257   if test "$tst_compi_ioctlsocket_camel" = "yes"; then
4258     AC_MSG_CHECKING([if IoctlSocket usage allowed])
4259     if test "x$curl_disallow_ioctlsocket_camel" != "xyes"; then
4260       AC_MSG_RESULT([yes])
4261       tst_allow_ioctlsocket_camel="yes"
4262     else
4263       AC_MSG_RESULT([no])
4264       tst_allow_ioctlsocket_camel="no"
4265     fi
4266   fi
4267   #
4268   AC_MSG_CHECKING([if IoctlSocket might be used])
4269   if test "$tst_links_ioctlsocket_camel" = "yes" &&
4270      test "$tst_proto_ioctlsocket_camel" = "yes" &&
4271      test "$tst_compi_ioctlsocket_camel" = "yes" &&
4272      test "$tst_allow_ioctlsocket_camel" = "yes"; then
4273     AC_MSG_RESULT([yes])
4274     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
4275       [Define to 1 if you have the IoctlSocket camel case function.])
4276     ac_cv_func_ioctlsocket_camel="yes"
4277     CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
4278   else
4279     AC_MSG_RESULT([no])
4280     ac_cv_func_ioctlsocket_camel="no"
4281   fi
4282 ])
4283
4284
4285 dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
4286 dnl -------------------------------------------------
4287 dnl Verify if IoctlSocket with FIONBIO command is available,
4288 dnl can be compiled, and seems to work. If all of these are
4289 dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
4290
4291 AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
4292   #
4293   tst_compi_ioctlsocket_camel_fionbio="unknown"
4294   tst_allow_ioctlsocket_camel_fionbio="unknown"
4295   #
4296   if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then
4297     AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
4298     AC_COMPILE_IFELSE([
4299       AC_LANG_PROGRAM([[
4300         $curl_includes_stropts
4301       ]],[[
4302         long flags = 0;
4303         if(0 != ioctlsocket(0, FIONBIO, &flags))
4304           return 1;
4305       ]])
4306     ],[
4307       AC_MSG_RESULT([yes])
4308       tst_compi_ioctlsocket_camel_fionbio="yes"
4309     ],[
4310       AC_MSG_RESULT([no])
4311       tst_compi_ioctlsocket_camel_fionbio="no"
4312     ])
4313   fi
4314   #
4315   if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
4316     AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
4317     if test "x$curl_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
4318       AC_MSG_RESULT([yes])
4319       tst_allow_ioctlsocket_camel_fionbio="yes"
4320     else
4321       AC_MSG_RESULT([no])
4322       tst_allow_ioctlsocket_camel_fionbio="no"
4323     fi
4324   fi
4325   #
4326   AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
4327   if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
4328      test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
4329     AC_MSG_RESULT([yes])
4330     AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
4331       [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
4332     ac_cv_func_ioctlsocket_camel_fionbio="yes"
4333   else
4334     AC_MSG_RESULT([no])
4335     ac_cv_func_ioctlsocket_camel_fionbio="no"
4336   fi
4337 ])
4338
4339
4340 dnl CURL_CHECK_FUNC_LISTXATTR
4341 dnl -------------------------------------------------
4342 dnl Verify if listxattr is available, prototyped, and
4343 dnl can be compiled. If all of these are true, and
4344 dnl usage has not been previously disallowed with
4345 dnl shell variable curl_disallow_listxattr, then
4346 dnl HAVE_LISTXATTR will be defined.
4347
4348 AC_DEFUN([CURL_CHECK_FUNC_LISTXATTR], [
4349   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
4350   #
4351   tst_links_listxattr="unknown"
4352   tst_proto_listxattr="unknown"
4353   tst_compi_listxattr="unknown"
4354   tst_allow_listxattr="unknown"
4355   tst_nargs_listxattr="unknown"
4356   #
4357   AC_MSG_CHECKING([if listxattr can be linked])
4358   AC_LINK_IFELSE([
4359     AC_LANG_FUNC_LINK_TRY([listxattr])
4360   ],[
4361     AC_MSG_RESULT([yes])
4362     tst_links_listxattr="yes"
4363   ],[
4364     AC_MSG_RESULT([no])
4365     tst_links_listxattr="no"
4366   ])
4367   #
4368   if test "$tst_links_listxattr" = "yes"; then
4369     AC_MSG_CHECKING([if listxattr is prototyped])
4370     AC_EGREP_CPP([listxattr],[
4371       $curl_includes_sys_xattr
4372     ],[
4373       AC_MSG_RESULT([yes])
4374       tst_proto_listxattr="yes"
4375     ],[
4376       AC_MSG_RESULT([no])
4377       tst_proto_listxattr="no"
4378     ])
4379   fi
4380   #
4381   if test "$tst_proto_listxattr" = "yes"; then
4382     if test "$tst_nargs_listxattr" = "unknown"; then
4383       AC_MSG_CHECKING([if listxattr takes 3 args.])
4384       AC_COMPILE_IFELSE([
4385         AC_LANG_PROGRAM([[
4386           $curl_includes_sys_xattr
4387         ]],[[
4388           if(0 != listxattr(0, 0, 0))
4389             return 1;
4390         ]])
4391       ],[
4392         AC_MSG_RESULT([yes])
4393         tst_compi_listxattr="yes"
4394         tst_nargs_listxattr="3"
4395       ],[
4396         AC_MSG_RESULT([no])
4397         tst_compi_listxattr="no"
4398       ])
4399     fi
4400     if test "$tst_nargs_listxattr" = "unknown"; then
4401       AC_MSG_CHECKING([if listxattr takes 4 args.])
4402       AC_COMPILE_IFELSE([
4403         AC_LANG_PROGRAM([[
4404           $curl_includes_sys_xattr
4405         ]],[[
4406           if(0 != listxattr(0, 0, 0, 0))
4407             return 1;
4408         ]])
4409       ],[
4410         AC_MSG_RESULT([yes])
4411         tst_compi_listxattr="yes"
4412         tst_nargs_listxattr="4"
4413       ],[
4414         AC_MSG_RESULT([no])
4415         tst_compi_listxattr="no"
4416       ])
4417     fi
4418     AC_MSG_CHECKING([if listxattr is compilable])
4419     if test "$tst_compi_listxattr" = "yes"; then
4420       AC_MSG_RESULT([yes])
4421     else
4422       AC_MSG_RESULT([no])
4423     fi
4424   fi
4425   #
4426   if test "$tst_compi_listxattr" = "yes"; then
4427     AC_MSG_CHECKING([if listxattr usage allowed])
4428     if test "x$curl_disallow_listxattr" != "xyes"; then
4429       AC_MSG_RESULT([yes])
4430       tst_allow_listxattr="yes"
4431     else
4432       AC_MSG_RESULT([no])
4433       tst_allow_listxattr="no"
4434     fi
4435   fi
4436   #
4437   AC_MSG_CHECKING([if listxattr might be used])
4438   if test "$tst_links_listxattr" = "yes" &&
4439      test "$tst_proto_listxattr" = "yes" &&
4440      test "$tst_compi_listxattr" = "yes" &&
4441      test "$tst_allow_listxattr" = "yes"; then
4442     AC_MSG_RESULT([yes])
4443     AC_DEFINE_UNQUOTED(HAVE_LISTXATTR, 1,
4444       [Define to 1 if you have the listxattr function.])
4445     dnl AC_DEFINE_UNQUOTED(LISTXATTR_ARGS, $tst_nargs_listxattr,
4446     dnl   [Specifies the number of arguments to listxattr])
4447     #
4448     if test "$tst_nargs_listxattr" -eq "3"; then
4449       AC_DEFINE(HAVE_LISTXATTR_3, 1, [listxattr() takes 3 args])
4450     elif test "$tst_nargs_listxattr" -eq "4"; then
4451       AC_DEFINE(HAVE_LISTXATTR_4, 1, [listxattr() takes 4 args])
4452     fi
4453     #
4454     ac_cv_func_listxattr="yes"
4455   else
4456     AC_MSG_RESULT([no])
4457     ac_cv_func_listxattr="no"
4458   fi
4459 ])
4460
4461
4462 dnl CURL_CHECK_FUNC_LOCALTIME_R
4463 dnl -------------------------------------------------
4464 dnl Verify if localtime_r is available, prototyped, can
4465 dnl be compiled and seems to work. If all of these are
4466 dnl true, and usage has not been previously disallowed
4467 dnl with shell variable curl_disallow_localtime_r, then
4468 dnl HAVE_LOCALTIME_R will be defined.
4469
4470 AC_DEFUN([CURL_CHECK_FUNC_LOCALTIME_R], [
4471   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4472   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
4473   #
4474   tst_links_localtime_r="unknown"
4475   tst_proto_localtime_r="unknown"
4476   tst_compi_localtime_r="unknown"
4477   tst_works_localtime_r="unknown"
4478   tst_allow_localtime_r="unknown"
4479   #
4480   AC_MSG_CHECKING([if localtime_r can be linked])
4481   AC_LINK_IFELSE([
4482     AC_LANG_FUNC_LINK_TRY([localtime_r])
4483   ],[
4484     AC_MSG_RESULT([yes])
4485     tst_links_localtime_r="yes"
4486   ],[
4487     AC_MSG_RESULT([no])
4488     tst_links_localtime_r="no"
4489   ])
4490   #
4491   if test "$tst_links_localtime_r" = "yes"; then
4492     AC_MSG_CHECKING([if localtime_r is prototyped])
4493     AC_EGREP_CPP([localtime_r],[
4494       $curl_includes_time
4495     ],[
4496       AC_MSG_RESULT([yes])
4497       tst_proto_localtime_r="yes"
4498     ],[
4499       AC_MSG_RESULT([no])
4500       tst_proto_localtime_r="no"
4501     ])
4502   fi
4503   #
4504   if test "$tst_proto_localtime_r" = "yes"; then
4505     AC_MSG_CHECKING([if localtime_r is compilable])
4506     AC_COMPILE_IFELSE([
4507       AC_LANG_PROGRAM([[
4508         $curl_includes_time
4509       ]],[[
4510         if(0 != localtime_r(0, 0))
4511           return 1;
4512       ]])
4513     ],[
4514       AC_MSG_RESULT([yes])
4515       tst_compi_localtime_r="yes"
4516     ],[
4517       AC_MSG_RESULT([no])
4518       tst_compi_localtime_r="no"
4519     ])
4520   fi
4521   #
4522   dnl only do runtime verification when not cross-compiling
4523   if test "x$cross_compiling" != "xyes" &&
4524     test "$tst_compi_localtime_r" = "yes"; then
4525     AC_MSG_CHECKING([if localtime_r seems to work])
4526     AC_RUN_IFELSE([
4527       AC_LANG_PROGRAM([[
4528         $curl_includes_stdlib
4529         $curl_includes_time
4530       ]],[[
4531         time_t clock = 1170352587;
4532         struct tm *tmp = 0;
4533         struct tm result;
4534         tmp = localtime_r(&clock, &result);
4535         if(tmp)
4536           exit(0);
4537         else
4538           exit(1);
4539       ]])
4540     ],[
4541       AC_MSG_RESULT([yes])
4542       tst_works_localtime_r="yes"
4543     ],[
4544       AC_MSG_RESULT([no])
4545       tst_works_localtime_r="no"
4546     ])
4547   fi
4548   #
4549   if test "$tst_compi_localtime_r" = "yes" &&
4550     test "$tst_works_localtime_r" != "no"; then
4551     AC_MSG_CHECKING([if localtime_r usage allowed])
4552     if test "x$curl_disallow_localtime_r" != "xyes"; then
4553       AC_MSG_RESULT([yes])
4554       tst_allow_localtime_r="yes"
4555     else
4556       AC_MSG_RESULT([no])
4557       tst_allow_localtime_r="no"
4558     fi
4559   fi
4560   #
4561   AC_MSG_CHECKING([if localtime_r might be used])
4562   if test "$tst_links_localtime_r" = "yes" &&
4563      test "$tst_proto_localtime_r" = "yes" &&
4564      test "$tst_compi_localtime_r" = "yes" &&
4565      test "$tst_allow_localtime_r" = "yes" &&
4566      test "$tst_works_localtime_r" != "no"; then
4567     AC_MSG_RESULT([yes])
4568     AC_DEFINE_UNQUOTED(HAVE_LOCALTIME_R, 1,
4569       [Define to 1 if you have a working localtime_r function.])
4570     ac_cv_func_localtime_r="yes"
4571   else
4572     AC_MSG_RESULT([no])
4573     ac_cv_func_localtime_r="no"
4574   fi
4575 ])
4576
4577
4578 dnl CURL_CHECK_FUNC_MEMRCHR
4579 dnl -------------------------------------------------
4580 dnl Verify if memrchr is available, prototyped, and
4581 dnl can be compiled. If all of these are true, and
4582 dnl usage has not been previously disallowed with
4583 dnl shell variable curl_disallow_memrchr, then
4584 dnl HAVE_MEMRCHR will be defined.
4585
4586 AC_DEFUN([CURL_CHECK_FUNC_MEMRCHR], [
4587   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4588   #
4589   tst_links_memrchr="unknown"
4590   tst_macro_memrchr="unknown"
4591   tst_proto_memrchr="unknown"
4592   tst_compi_memrchr="unknown"
4593   tst_allow_memrchr="unknown"
4594   #
4595   AC_MSG_CHECKING([if memrchr can be linked])
4596   AC_LINK_IFELSE([
4597     AC_LANG_FUNC_LINK_TRY([memrchr])
4598   ],[
4599     AC_MSG_RESULT([yes])
4600     tst_links_memrchr="yes"
4601   ],[
4602     AC_MSG_RESULT([no])
4603     tst_links_memrchr="no"
4604   ])
4605   #
4606   if test "$tst_links_memrchr" = "no"; then
4607     AC_MSG_CHECKING([if memrchr seems a macro])
4608     AC_LINK_IFELSE([
4609       AC_LANG_PROGRAM([[
4610         $curl_includes_string
4611       ]],[[
4612         if(0 != memrchr(0, 0, 0))
4613           return 1;
4614       ]])
4615     ],[
4616       AC_MSG_RESULT([yes])
4617       tst_macro_memrchr="yes"
4618     ],[
4619       AC_MSG_RESULT([no])
4620       tst_macro_memrchr="no"
4621     ])
4622   fi
4623   #
4624   if test "$tst_links_memrchr" = "yes"; then
4625     AC_MSG_CHECKING([if memrchr is prototyped])
4626     AC_EGREP_CPP([memrchr],[
4627       $curl_includes_string
4628     ],[
4629       AC_MSG_RESULT([yes])
4630       tst_proto_memrchr="yes"
4631     ],[
4632       AC_MSG_RESULT([no])
4633       tst_proto_memrchr="no"
4634     ])
4635   fi
4636   #
4637   if test "$tst_proto_memrchr" = "yes" ||
4638      test "$tst_macro_memrchr" = "yes"; then
4639     AC_MSG_CHECKING([if memrchr is compilable])
4640     AC_COMPILE_IFELSE([
4641       AC_LANG_PROGRAM([[
4642         $curl_includes_string
4643       ]],[[
4644         if(0 != memrchr(0, 0, 0))
4645           return 1;
4646       ]])
4647     ],[
4648       AC_MSG_RESULT([yes])
4649       tst_compi_memrchr="yes"
4650     ],[
4651       AC_MSG_RESULT([no])
4652       tst_compi_memrchr="no"
4653     ])
4654   fi
4655   #
4656   if test "$tst_compi_memrchr" = "yes"; then
4657     AC_MSG_CHECKING([if memrchr usage allowed])
4658     if test "x$curl_disallow_memrchr" != "xyes"; then
4659       AC_MSG_RESULT([yes])
4660       tst_allow_memrchr="yes"
4661     else
4662       AC_MSG_RESULT([no])
4663       tst_allow_memrchr="no"
4664     fi
4665   fi
4666   #
4667   AC_MSG_CHECKING([if memrchr might be used])
4668   if (test "$tst_proto_memrchr" = "yes" ||
4669       test "$tst_macro_memrchr" = "yes") &&
4670      test "$tst_compi_memrchr" = "yes" &&
4671      test "$tst_allow_memrchr" = "yes"; then
4672     AC_MSG_RESULT([yes])
4673     AC_DEFINE_UNQUOTED(HAVE_MEMRCHR, 1,
4674       [Define to 1 if you have the memrchr function or macro.])
4675     ac_cv_func_memrchr="yes"
4676   else
4677     AC_MSG_RESULT([no])
4678     ac_cv_func_memrchr="no"
4679   fi
4680 ])
4681
4682
4683 dnl CURL_CHECK_FUNC_POLL
4684 dnl -------------------------------------------------
4685 dnl Verify if poll is available, prototyped, can
4686 dnl be compiled and seems to work. If all of these are
4687 dnl true, and usage has not been previously disallowed
4688 dnl with shell variable curl_disallow_poll, then
4689 dnl HAVE_POLL will be defined.
4690
4691 AC_DEFUN([CURL_CHECK_FUNC_POLL], [
4692   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4693   AC_REQUIRE([CURL_INCLUDES_POLL])dnl
4694   #
4695   tst_links_poll="unknown"
4696   tst_proto_poll="unknown"
4697   tst_compi_poll="unknown"
4698   tst_works_poll="unknown"
4699   tst_allow_poll="unknown"
4700   #
4701   case $host_os in
4702     darwin*|interix*)
4703       dnl poll() does not work on these platforms
4704       dnl Interix: "does provide poll(), but the implementing developer must
4705       dnl have been in a bad mood, because poll() only works on the /proc
4706       dnl filesystem here"
4707       curl_disallow_poll="yes"
4708       ;;
4709   esac
4710   #
4711   AC_MSG_CHECKING([if poll can be linked])
4712   AC_LINK_IFELSE([
4713     AC_LANG_PROGRAM([[
4714       $curl_includes_poll
4715     ]],[[
4716       if(0 != poll(0, 0, 0))
4717         return 1;
4718     ]])
4719   ],[
4720     AC_MSG_RESULT([yes])
4721     tst_links_poll="yes"
4722   ],[
4723     AC_MSG_RESULT([no])
4724     tst_links_poll="no"
4725   ])
4726   #
4727   if test "$tst_links_poll" = "yes"; then
4728     AC_MSG_CHECKING([if poll is prototyped])
4729     AC_EGREP_CPP([poll],[
4730       $curl_includes_poll
4731     ],[
4732       AC_MSG_RESULT([yes])
4733       tst_proto_poll="yes"
4734     ],[
4735       AC_MSG_RESULT([no])
4736       tst_proto_poll="no"
4737     ])
4738   fi
4739   #
4740   if test "$tst_proto_poll" = "yes"; then
4741     AC_MSG_CHECKING([if poll is compilable])
4742     AC_COMPILE_IFELSE([
4743       AC_LANG_PROGRAM([[
4744         $curl_includes_poll
4745       ]],[[
4746         if(0 != poll(0, 0, 0))
4747           return 1;
4748       ]])
4749     ],[
4750       AC_MSG_RESULT([yes])
4751       tst_compi_poll="yes"
4752     ],[
4753       AC_MSG_RESULT([no])
4754       tst_compi_poll="no"
4755     ])
4756   fi
4757   #
4758   dnl only do runtime verification when not cross-compiling
4759   if test "x$cross_compiling" != "xyes" &&
4760     test "$tst_compi_poll" = "yes"; then
4761     AC_MSG_CHECKING([if poll seems to work])
4762     AC_RUN_IFELSE([
4763       AC_LANG_PROGRAM([[
4764         $curl_includes_stdlib
4765         $curl_includes_poll
4766       ]],[[
4767         if(0 != poll(0, 0, 10))
4768           exit(1); /* fail */
4769         else
4770           exit(0);
4771       ]])
4772     ],[
4773       AC_MSG_RESULT([yes])
4774       tst_works_poll="yes"
4775     ],[
4776       AC_MSG_RESULT([no])
4777       tst_works_poll="no"
4778     ])
4779   fi
4780   #
4781   if test "$tst_compi_poll" = "yes" &&
4782     test "$tst_works_poll" != "no"; then
4783     AC_MSG_CHECKING([if poll usage allowed])
4784     if test "x$curl_disallow_poll" != "xyes"; then
4785       AC_MSG_RESULT([yes])
4786       tst_allow_poll="yes"
4787     else
4788       AC_MSG_RESULT([no])
4789       tst_allow_poll="no"
4790     fi
4791   fi
4792   #
4793   AC_MSG_CHECKING([if poll might be used])
4794   if test "$tst_links_poll" = "yes" &&
4795      test "$tst_proto_poll" = "yes" &&
4796      test "$tst_compi_poll" = "yes" &&
4797      test "$tst_allow_poll" = "yes" &&
4798      test "$tst_works_poll" != "no"; then
4799     AC_MSG_RESULT([yes])
4800     AC_DEFINE_UNQUOTED(HAVE_POLL, 1,
4801       [Define to 1 if you have a working poll function.])
4802     AC_DEFINE_UNQUOTED(HAVE_POLL_FINE, 1,
4803       [If you have a fine poll])
4804     ac_cv_func_poll="yes"
4805   else
4806     AC_MSG_RESULT([no])
4807     ac_cv_func_poll="no"
4808   fi
4809 ])
4810
4811
4812 dnl CURL_CHECK_FUNC_REMOVEXATTR
4813 dnl -------------------------------------------------
4814 dnl Verify if removexattr is available, prototyped, and
4815 dnl can be compiled. If all of these are true, and
4816 dnl usage has not been previously disallowed with
4817 dnl shell variable curl_disallow_removexattr, then
4818 dnl HAVE_REMOVEXATTR will be defined.
4819
4820 AC_DEFUN([CURL_CHECK_FUNC_REMOVEXATTR], [
4821   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
4822   #
4823   tst_links_removexattr="unknown"
4824   tst_proto_removexattr="unknown"
4825   tst_compi_removexattr="unknown"
4826   tst_allow_removexattr="unknown"
4827   tst_nargs_removexattr="unknown"
4828   #
4829   AC_MSG_CHECKING([if removexattr can be linked])
4830   AC_LINK_IFELSE([
4831     AC_LANG_FUNC_LINK_TRY([removexattr])
4832   ],[
4833     AC_MSG_RESULT([yes])
4834     tst_links_removexattr="yes"
4835   ],[
4836     AC_MSG_RESULT([no])
4837     tst_links_removexattr="no"
4838   ])
4839   #
4840   if test "$tst_links_removexattr" = "yes"; then
4841     AC_MSG_CHECKING([if removexattr is prototyped])
4842     AC_EGREP_CPP([removexattr],[
4843       $curl_includes_sys_xattr
4844     ],[
4845       AC_MSG_RESULT([yes])
4846       tst_proto_removexattr="yes"
4847     ],[
4848       AC_MSG_RESULT([no])
4849       tst_proto_removexattr="no"
4850     ])
4851   fi
4852   #
4853   if test "$tst_proto_removexattr" = "yes"; then
4854     if test "$tst_nargs_removexattr" = "unknown"; then
4855       AC_MSG_CHECKING([if removexattr takes 2 args.])
4856       AC_COMPILE_IFELSE([
4857         AC_LANG_PROGRAM([[
4858           $curl_includes_sys_xattr
4859         ]],[[
4860           if(0 != removexattr(0, 0))
4861             return 1;
4862         ]])
4863       ],[
4864         AC_MSG_RESULT([yes])
4865         tst_compi_removexattr="yes"
4866         tst_nargs_removexattr="2"
4867       ],[
4868         AC_MSG_RESULT([no])
4869         tst_compi_removexattr="no"
4870       ])
4871     fi
4872     if test "$tst_nargs_removexattr" = "unknown"; then
4873       AC_MSG_CHECKING([if removexattr takes 3 args.])
4874       AC_COMPILE_IFELSE([
4875         AC_LANG_PROGRAM([[
4876           $curl_includes_sys_xattr
4877         ]],[[
4878           if(0 != removexattr(0, 0, 0))
4879             return 1;
4880         ]])
4881       ],[
4882         AC_MSG_RESULT([yes])
4883         tst_compi_removexattr="yes"
4884         tst_nargs_removexattr="3"
4885       ],[
4886         AC_MSG_RESULT([no])
4887         tst_compi_removexattr="no"
4888       ])
4889     fi
4890     AC_MSG_CHECKING([if removexattr is compilable])
4891     if test "$tst_compi_removexattr" = "yes"; then
4892       AC_MSG_RESULT([yes])
4893     else
4894       AC_MSG_RESULT([no])
4895     fi
4896   fi
4897   #
4898   if test "$tst_compi_removexattr" = "yes"; then
4899     AC_MSG_CHECKING([if removexattr usage allowed])
4900     if test "x$curl_disallow_removexattr" != "xyes"; then
4901       AC_MSG_RESULT([yes])
4902       tst_allow_removexattr="yes"
4903     else
4904       AC_MSG_RESULT([no])
4905       tst_allow_removexattr="no"
4906     fi
4907   fi
4908   #
4909   AC_MSG_CHECKING([if removexattr might be used])
4910   if test "$tst_links_removexattr" = "yes" &&
4911      test "$tst_proto_removexattr" = "yes" &&
4912      test "$tst_compi_removexattr" = "yes" &&
4913      test "$tst_allow_removexattr" = "yes"; then
4914     AC_MSG_RESULT([yes])
4915     AC_DEFINE_UNQUOTED(HAVE_REMOVEXATTR, 1,
4916       [Define to 1 if you have the removexattr function.])
4917     dnl AC_DEFINE_UNQUOTED(REMOVEXATTR_ARGS, $tst_nargs_removexattr,
4918     dnl   [Specifies the number of arguments to removexattr])
4919     #
4920     if test "$tst_nargs_removexattr" -eq "2"; then
4921       AC_DEFINE(HAVE_REMOVEXATTR_2, 1, [removexattr() takes 2 args])
4922     elif test "$tst_nargs_removexattr" -eq "3"; then
4923       AC_DEFINE(HAVE_REMOVEXATTR_3, 1, [removexattr() takes 3 args])
4924     fi
4925     #
4926     ac_cv_func_removexattr="yes"
4927   else
4928     AC_MSG_RESULT([no])
4929     ac_cv_func_removexattr="no"
4930   fi
4931 ])
4932
4933
4934 dnl CURL_CHECK_FUNC_SETSOCKOPT
4935 dnl -------------------------------------------------
4936 dnl Verify if setsockopt is available, prototyped, and
4937 dnl can be compiled. If all of these are true, and
4938 dnl usage has not been previously disallowed with
4939 dnl shell variable curl_disallow_setsockopt, then
4940 dnl HAVE_SETSOCKOPT will be defined.
4941
4942 AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT], [
4943   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
4944   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
4945   #
4946   tst_links_setsockopt="unknown"
4947   tst_proto_setsockopt="unknown"
4948   tst_compi_setsockopt="unknown"
4949   tst_allow_setsockopt="unknown"
4950   #
4951   AC_MSG_CHECKING([if setsockopt can be linked])
4952   AC_LINK_IFELSE([
4953     AC_LANG_PROGRAM([[
4954       $curl_includes_winsock2
4955       $curl_includes_sys_socket
4956     ]],[[
4957       if(0 != setsockopt(0, 0, 0, 0, 0))
4958         return 1;
4959     ]])
4960   ],[
4961     AC_MSG_RESULT([yes])
4962     tst_links_setsockopt="yes"
4963   ],[
4964     AC_MSG_RESULT([no])
4965     tst_links_setsockopt="no"
4966   ])
4967   #
4968   if test "$tst_links_setsockopt" = "yes"; then
4969     AC_MSG_CHECKING([if setsockopt is prototyped])
4970     AC_EGREP_CPP([setsockopt],[
4971       $curl_includes_winsock2
4972       $curl_includes_sys_socket
4973     ],[
4974       AC_MSG_RESULT([yes])
4975       tst_proto_setsockopt="yes"
4976     ],[
4977       AC_MSG_RESULT([no])
4978       tst_proto_setsockopt="no"
4979     ])
4980   fi
4981   #
4982   if test "$tst_proto_setsockopt" = "yes"; then
4983     AC_MSG_CHECKING([if setsockopt is compilable])
4984     AC_COMPILE_IFELSE([
4985       AC_LANG_PROGRAM([[
4986         $curl_includes_winsock2
4987         $curl_includes_sys_socket
4988       ]],[[
4989         if(0 != setsockopt(0, 0, 0, 0, 0))
4990           return 1;
4991       ]])
4992     ],[
4993       AC_MSG_RESULT([yes])
4994       tst_compi_setsockopt="yes"
4995     ],[
4996       AC_MSG_RESULT([no])
4997       tst_compi_setsockopt="no"
4998     ])
4999   fi
5000   #
5001   if test "$tst_compi_setsockopt" = "yes"; then
5002     AC_MSG_CHECKING([if setsockopt usage allowed])
5003     if test "x$curl_disallow_setsockopt" != "xyes"; then
5004       AC_MSG_RESULT([yes])
5005       tst_allow_setsockopt="yes"
5006     else
5007       AC_MSG_RESULT([no])
5008       tst_allow_setsockopt="no"
5009     fi
5010   fi
5011   #
5012   AC_MSG_CHECKING([if setsockopt might be used])
5013   if test "$tst_links_setsockopt" = "yes" &&
5014      test "$tst_proto_setsockopt" = "yes" &&
5015      test "$tst_compi_setsockopt" = "yes" &&
5016      test "$tst_allow_setsockopt" = "yes"; then
5017     AC_MSG_RESULT([yes])
5018     AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1,
5019       [Define to 1 if you have the setsockopt function.])
5020     ac_cv_func_setsockopt="yes"
5021     CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
5022   else
5023     AC_MSG_RESULT([no])
5024     ac_cv_func_setsockopt="no"
5025   fi
5026 ])
5027
5028
5029 dnl CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
5030 dnl -------------------------------------------------
5031 dnl Verify if setsockopt with the SO_NONBLOCK command is
5032 dnl available, can be compiled, and seems to work. If
5033 dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK
5034 dnl will be defined.
5035
5036 AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
5037   #
5038   tst_compi_setsockopt_so_nonblock="unknown"
5039   tst_allow_setsockopt_so_nonblock="unknown"
5040   #
5041   if test "$ac_cv_func_setsockopt" = "yes"; then
5042     AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable])
5043     AC_COMPILE_IFELSE([
5044       AC_LANG_PROGRAM([[
5045         $curl_includes_winsock2
5046         $curl_includes_sys_socket
5047       ]],[[
5048         if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
5049           return 1;
5050       ]])
5051     ],[
5052       AC_MSG_RESULT([yes])
5053       tst_compi_setsockopt_so_nonblock="yes"
5054     ],[
5055       AC_MSG_RESULT([no])
5056       tst_compi_setsockopt_so_nonblock="no"
5057     ])
5058   fi
5059   #
5060   if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then
5061     AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed])
5062     if test "x$curl_disallow_setsockopt_so_nonblock" != "xyes"; then
5063       AC_MSG_RESULT([yes])
5064       tst_allow_setsockopt_so_nonblock="yes"
5065     else
5066       AC_MSG_RESULT([no])
5067       tst_allow_setsockopt_so_nonblock="no"
5068     fi
5069   fi
5070   #
5071   AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used])
5072   if test "$tst_compi_setsockopt_so_nonblock" = "yes" &&
5073      test "$tst_allow_setsockopt_so_nonblock" = "yes"; then
5074     AC_MSG_RESULT([yes])
5075     AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1,
5076       [Define to 1 if you have a working setsockopt SO_NONBLOCK function.])
5077     ac_cv_func_setsockopt_so_nonblock="yes"
5078   else
5079     AC_MSG_RESULT([no])
5080     ac_cv_func_setsockopt_so_nonblock="no"
5081   fi
5082 ])
5083
5084
5085 dnl CURL_CHECK_FUNC_SETXATTR
5086 dnl -------------------------------------------------
5087 dnl Verify if setxattr is available, prototyped, and
5088 dnl can be compiled. If all of these are true, and
5089 dnl usage has not been previously disallowed with
5090 dnl shell variable curl_disallow_setxattr, then
5091 dnl HAVE_SETXATTR will be defined.
5092
5093 AC_DEFUN([CURL_CHECK_FUNC_SETXATTR], [
5094   AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
5095   #
5096   tst_links_setxattr="unknown"
5097   tst_proto_setxattr="unknown"
5098   tst_compi_setxattr="unknown"
5099   tst_allow_setxattr="unknown"
5100   tst_nargs_setxattr="unknown"
5101   #
5102   AC_MSG_CHECKING([if setxattr can be linked])
5103   AC_LINK_IFELSE([
5104     AC_LANG_FUNC_LINK_TRY([setxattr])
5105   ],[
5106     AC_MSG_RESULT([yes])
5107     tst_links_setxattr="yes"
5108   ],[
5109     AC_MSG_RESULT([no])
5110     tst_links_setxattr="no"
5111   ])
5112   #
5113   if test "$tst_links_setxattr" = "yes"; then
5114     AC_MSG_CHECKING([if setxattr is prototyped])
5115     AC_EGREP_CPP([setxattr],[
5116       $curl_includes_sys_xattr
5117     ],[
5118       AC_MSG_RESULT([yes])
5119       tst_proto_setxattr="yes"
5120     ],[
5121       AC_MSG_RESULT([no])
5122       tst_proto_setxattr="no"
5123     ])
5124   fi
5125   #
5126   if test "$tst_proto_setxattr" = "yes"; then
5127     if test "$tst_nargs_setxattr" = "unknown"; then
5128       AC_MSG_CHECKING([if setxattr takes 5 args.])
5129       AC_COMPILE_IFELSE([
5130         AC_LANG_PROGRAM([[
5131           $curl_includes_sys_xattr
5132         ]],[[
5133           if(0 != setxattr(0, 0, 0, 0, 0))
5134             return 1;
5135         ]])
5136       ],[
5137         AC_MSG_RESULT([yes])
5138         tst_compi_setxattr="yes"
5139         tst_nargs_setxattr="5"
5140       ],[
5141         AC_MSG_RESULT([no])
5142         tst_compi_setxattr="no"
5143       ])
5144     fi
5145     if test "$tst_nargs_setxattr" = "unknown"; then
5146       AC_MSG_CHECKING([if setxattr takes 6 args.])
5147       AC_COMPILE_IFELSE([
5148         AC_LANG_PROGRAM([[
5149           $curl_includes_sys_xattr
5150         ]],[[
5151           if(0 != setxattr(0, 0, 0, 0, 0, 0))
5152             return 1;
5153         ]])
5154       ],[
5155         AC_MSG_RESULT([yes])
5156         tst_compi_setxattr="yes"
5157         tst_nargs_setxattr="6"
5158       ],[
5159         AC_MSG_RESULT([no])
5160         tst_compi_setxattr="no"
5161       ])
5162     fi
5163     AC_MSG_CHECKING([if setxattr is compilable])
5164     if test "$tst_compi_setxattr" = "yes"; then
5165       AC_MSG_RESULT([yes])
5166     else
5167       AC_MSG_RESULT([no])
5168     fi
5169   fi
5170   #
5171   if test "$tst_compi_setxattr" = "yes"; then
5172     AC_MSG_CHECKING([if setxattr usage allowed])
5173     if test "x$curl_disallow_setxattr" != "xyes"; then
5174       AC_MSG_RESULT([yes])
5175       tst_allow_setxattr="yes"
5176     else
5177       AC_MSG_RESULT([no])
5178       tst_allow_setxattr="no"
5179     fi
5180   fi
5181   #
5182   AC_MSG_CHECKING([if setxattr might be used])
5183   if test "$tst_links_setxattr" = "yes" &&
5184      test "$tst_proto_setxattr" = "yes" &&
5185      test "$tst_compi_setxattr" = "yes" &&
5186      test "$tst_allow_setxattr" = "yes"; then
5187     AC_MSG_RESULT([yes])
5188     AC_DEFINE_UNQUOTED(HAVE_SETXATTR, 1,
5189       [Define to 1 if you have the setxattr function.])
5190     dnl AC_DEFINE_UNQUOTED(SETXATTR_ARGS, $tst_nargs_setxattr,
5191     dnl   [Specifies the number of arguments to setxattr])
5192     #
5193     if test "$tst_nargs_setxattr" -eq "5"; then
5194       AC_DEFINE(HAVE_SETXATTR_5, 1, [setxattr() takes 5 args])
5195     elif test "$tst_nargs_setxattr" -eq "6"; then
5196       AC_DEFINE(HAVE_SETXATTR_6, 1, [setxattr() takes 6 args])
5197     fi
5198     #
5199     ac_cv_func_setxattr="yes"
5200   else
5201     AC_MSG_RESULT([no])
5202     ac_cv_func_setxattr="no"
5203   fi
5204 ])
5205
5206
5207 dnl CURL_CHECK_FUNC_SIGACTION
5208 dnl -------------------------------------------------
5209 dnl Verify if sigaction is available, prototyped, and
5210 dnl can be compiled. If all of these are true, and
5211 dnl usage has not been previously disallowed with
5212 dnl shell variable curl_disallow_sigaction, then
5213 dnl HAVE_SIGACTION will be defined.
5214
5215 AC_DEFUN([CURL_CHECK_FUNC_SIGACTION], [
5216   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5217   #
5218   tst_links_sigaction="unknown"
5219   tst_proto_sigaction="unknown"
5220   tst_compi_sigaction="unknown"
5221   tst_allow_sigaction="unknown"
5222   #
5223   AC_MSG_CHECKING([if sigaction can be linked])
5224   AC_LINK_IFELSE([
5225     AC_LANG_FUNC_LINK_TRY([sigaction])
5226   ],[
5227     AC_MSG_RESULT([yes])
5228     tst_links_sigaction="yes"
5229   ],[
5230     AC_MSG_RESULT([no])
5231     tst_links_sigaction="no"
5232   ])
5233   #
5234   if test "$tst_links_sigaction" = "yes"; then
5235     AC_MSG_CHECKING([if sigaction is prototyped])
5236     AC_EGREP_CPP([sigaction],[
5237       $curl_includes_signal
5238     ],[
5239       AC_MSG_RESULT([yes])
5240       tst_proto_sigaction="yes"
5241     ],[
5242       AC_MSG_RESULT([no])
5243       tst_proto_sigaction="no"
5244     ])
5245   fi
5246   #
5247   if test "$tst_proto_sigaction" = "yes"; then
5248     AC_MSG_CHECKING([if sigaction is compilable])
5249     AC_COMPILE_IFELSE([
5250       AC_LANG_PROGRAM([[
5251         $curl_includes_signal
5252       ]],[[
5253         if(0 != sigaction(0, 0, 0))
5254           return 1;
5255       ]])
5256     ],[
5257       AC_MSG_RESULT([yes])
5258       tst_compi_sigaction="yes"
5259     ],[
5260       AC_MSG_RESULT([no])
5261       tst_compi_sigaction="no"
5262     ])
5263   fi
5264   #
5265   if test "$tst_compi_sigaction" = "yes"; then
5266     AC_MSG_CHECKING([if sigaction usage allowed])
5267     if test "x$curl_disallow_sigaction" != "xyes"; then
5268       AC_MSG_RESULT([yes])
5269       tst_allow_sigaction="yes"
5270     else
5271       AC_MSG_RESULT([no])
5272       tst_allow_sigaction="no"
5273     fi
5274   fi
5275   #
5276   AC_MSG_CHECKING([if sigaction might be used])
5277   if test "$tst_links_sigaction" = "yes" &&
5278      test "$tst_proto_sigaction" = "yes" &&
5279      test "$tst_compi_sigaction" = "yes" &&
5280      test "$tst_allow_sigaction" = "yes"; then
5281     AC_MSG_RESULT([yes])
5282     AC_DEFINE_UNQUOTED(HAVE_SIGACTION, 1,
5283       [Define to 1 if you have the sigaction function.])
5284     ac_cv_func_sigaction="yes"
5285   else
5286     AC_MSG_RESULT([no])
5287     ac_cv_func_sigaction="no"
5288   fi
5289 ])
5290
5291
5292 dnl CURL_CHECK_FUNC_SIGINTERRUPT
5293 dnl -------------------------------------------------
5294 dnl Verify if siginterrupt is available, prototyped, and
5295 dnl can be compiled. If all of these are true, and
5296 dnl usage has not been previously disallowed with
5297 dnl shell variable curl_disallow_siginterrupt, then
5298 dnl HAVE_SIGINTERRUPT will be defined.
5299
5300 AC_DEFUN([CURL_CHECK_FUNC_SIGINTERRUPT], [
5301   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5302   #
5303   tst_links_siginterrupt="unknown"
5304   tst_proto_siginterrupt="unknown"
5305   tst_compi_siginterrupt="unknown"
5306   tst_allow_siginterrupt="unknown"
5307   #
5308   AC_MSG_CHECKING([if siginterrupt can be linked])
5309   AC_LINK_IFELSE([
5310     AC_LANG_FUNC_LINK_TRY([siginterrupt])
5311   ],[
5312     AC_MSG_RESULT([yes])
5313     tst_links_siginterrupt="yes"
5314   ],[
5315     AC_MSG_RESULT([no])
5316     tst_links_siginterrupt="no"
5317   ])
5318   #
5319   if test "$tst_links_siginterrupt" = "yes"; then
5320     AC_MSG_CHECKING([if siginterrupt is prototyped])
5321     AC_EGREP_CPP([siginterrupt],[
5322       $curl_includes_signal
5323     ],[
5324       AC_MSG_RESULT([yes])
5325       tst_proto_siginterrupt="yes"
5326     ],[
5327       AC_MSG_RESULT([no])
5328       tst_proto_siginterrupt="no"
5329     ])
5330   fi
5331   #
5332   if test "$tst_proto_siginterrupt" = "yes"; then
5333     AC_MSG_CHECKING([if siginterrupt is compilable])
5334     AC_COMPILE_IFELSE([
5335       AC_LANG_PROGRAM([[
5336         $curl_includes_signal
5337       ]],[[
5338         if(0 != siginterrupt(0, 0))
5339           return 1;
5340       ]])
5341     ],[
5342       AC_MSG_RESULT([yes])
5343       tst_compi_siginterrupt="yes"
5344     ],[
5345       AC_MSG_RESULT([no])
5346       tst_compi_siginterrupt="no"
5347     ])
5348   fi
5349   #
5350   if test "$tst_compi_siginterrupt" = "yes"; then
5351     AC_MSG_CHECKING([if siginterrupt usage allowed])
5352     if test "x$curl_disallow_siginterrupt" != "xyes"; then
5353       AC_MSG_RESULT([yes])
5354       tst_allow_siginterrupt="yes"
5355     else
5356       AC_MSG_RESULT([no])
5357       tst_allow_siginterrupt="no"
5358     fi
5359   fi
5360   #
5361   AC_MSG_CHECKING([if siginterrupt might be used])
5362   if test "$tst_links_siginterrupt" = "yes" &&
5363      test "$tst_proto_siginterrupt" = "yes" &&
5364      test "$tst_compi_siginterrupt" = "yes" &&
5365      test "$tst_allow_siginterrupt" = "yes"; then
5366     AC_MSG_RESULT([yes])
5367     AC_DEFINE_UNQUOTED(HAVE_SIGINTERRUPT, 1,
5368       [Define to 1 if you have the siginterrupt function.])
5369     ac_cv_func_siginterrupt="yes"
5370   else
5371     AC_MSG_RESULT([no])
5372     ac_cv_func_siginterrupt="no"
5373   fi
5374 ])
5375
5376
5377 dnl CURL_CHECK_FUNC_SIGNAL
5378 dnl -------------------------------------------------
5379 dnl Verify if signal is available, prototyped, and
5380 dnl can be compiled. If all of these are true, and
5381 dnl usage has not been previously disallowed with
5382 dnl shell variable curl_disallow_signal, then
5383 dnl HAVE_SIGNAL will be defined.
5384
5385 AC_DEFUN([CURL_CHECK_FUNC_SIGNAL], [
5386   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
5387   #
5388   tst_links_signal="unknown"
5389   tst_proto_signal="unknown"
5390   tst_compi_signal="unknown"
5391   tst_allow_signal="unknown"
5392   #
5393   AC_MSG_CHECKING([if signal can be linked])
5394   AC_LINK_IFELSE([
5395     AC_LANG_FUNC_LINK_TRY([signal])
5396   ],[
5397     AC_MSG_RESULT([yes])
5398     tst_links_signal="yes"
5399   ],[
5400     AC_MSG_RESULT([no])
5401     tst_links_signal="no"
5402   ])
5403   #
5404   if test "$tst_links_signal" = "yes"; then
5405     AC_MSG_CHECKING([if signal is prototyped])
5406     AC_EGREP_CPP([signal],[
5407       $curl_includes_signal
5408     ],[
5409       AC_MSG_RESULT([yes])
5410       tst_proto_signal="yes"
5411     ],[
5412       AC_MSG_RESULT([no])
5413       tst_proto_signal="no"
5414     ])
5415   fi
5416   #
5417   if test "$tst_proto_signal" = "yes"; then
5418     AC_MSG_CHECKING([if signal is compilable])
5419     AC_COMPILE_IFELSE([
5420       AC_LANG_PROGRAM([[
5421         $curl_includes_signal
5422       ]],[[
5423         if(0 != signal(0, 0))
5424           return 1;
5425       ]])
5426     ],[
5427       AC_MSG_RESULT([yes])
5428       tst_compi_signal="yes"
5429     ],[
5430       AC_MSG_RESULT([no])
5431       tst_compi_signal="no"
5432     ])
5433   fi
5434   #
5435   if test "$tst_compi_signal" = "yes"; then
5436     AC_MSG_CHECKING([if signal usage allowed])
5437     if test "x$curl_disallow_signal" != "xyes"; then
5438       AC_MSG_RESULT([yes])
5439       tst_allow_signal="yes"
5440     else
5441       AC_MSG_RESULT([no])
5442       tst_allow_signal="no"
5443     fi
5444   fi
5445   #
5446   AC_MSG_CHECKING([if signal might be used])
5447   if test "$tst_links_signal" = "yes" &&
5448      test "$tst_proto_signal" = "yes" &&
5449      test "$tst_compi_signal" = "yes" &&
5450      test "$tst_allow_signal" = "yes"; then
5451     AC_MSG_RESULT([yes])
5452     AC_DEFINE_UNQUOTED(HAVE_SIGNAL, 1,
5453       [Define to 1 if you have the signal function.])
5454     ac_cv_func_signal="yes"
5455   else
5456     AC_MSG_RESULT([no])
5457     ac_cv_func_signal="no"
5458   fi
5459 ])
5460
5461
5462 dnl CURL_CHECK_FUNC_SIGSETJMP
5463 dnl -------------------------------------------------
5464 dnl Verify if sigsetjmp is available, prototyped, and
5465 dnl can be compiled. If all of these are true, and
5466 dnl usage has not been previously disallowed with
5467 dnl shell variable curl_disallow_sigsetjmp, then
5468 dnl HAVE_SIGSETJMP will be defined.
5469
5470 AC_DEFUN([CURL_CHECK_FUNC_SIGSETJMP], [
5471   AC_REQUIRE([CURL_INCLUDES_SETJMP])dnl
5472   #
5473   tst_links_sigsetjmp="unknown"
5474   tst_macro_sigsetjmp="unknown"
5475   tst_proto_sigsetjmp="unknown"
5476   tst_compi_sigsetjmp="unknown"
5477   tst_allow_sigsetjmp="unknown"
5478   #
5479   AC_MSG_CHECKING([if sigsetjmp can be linked])
5480   AC_LINK_IFELSE([
5481     AC_LANG_FUNC_LINK_TRY([sigsetjmp])
5482   ],[
5483     AC_MSG_RESULT([yes])
5484     tst_links_sigsetjmp="yes"
5485   ],[
5486     AC_MSG_RESULT([no])
5487     tst_links_sigsetjmp="no"
5488   ])
5489   #
5490   if test "$tst_links_sigsetjmp" = "no"; then
5491     AC_MSG_CHECKING([if sigsetjmp seems a macro])
5492     AC_LINK_IFELSE([
5493       AC_LANG_PROGRAM([[
5494         $curl_includes_setjmp
5495       ]],[[
5496         sigjmp_buf env;
5497         if(0 != sigsetjmp(env, 0))
5498           return 1;
5499       ]])
5500     ],[
5501       AC_MSG_RESULT([yes])
5502       tst_macro_sigsetjmp="yes"
5503     ],[
5504       AC_MSG_RESULT([no])
5505       tst_macro_sigsetjmp="no"
5506     ])
5507   fi
5508   #
5509   if test "$tst_links_sigsetjmp" = "yes"; then
5510     AC_MSG_CHECKING([if sigsetjmp is prototyped])
5511     AC_EGREP_CPP([sigsetjmp],[
5512       $curl_includes_setjmp
5513     ],[
5514       AC_MSG_RESULT([yes])
5515       tst_proto_sigsetjmp="yes"
5516     ],[
5517       AC_MSG_RESULT([no])
5518       tst_proto_sigsetjmp="no"
5519     ])
5520   fi
5521   #
5522   if test "$tst_proto_sigsetjmp" = "yes" ||
5523      test "$tst_macro_sigsetjmp" = "yes"; then
5524     AC_MSG_CHECKING([if sigsetjmp is compilable])
5525     AC_COMPILE_IFELSE([
5526       AC_LANG_PROGRAM([[
5527         $curl_includes_setjmp
5528       ]],[[
5529         sigjmp_buf env;
5530         if(0 != sigsetjmp(env, 0))
5531           return 1;
5532       ]])
5533     ],[
5534       AC_MSG_RESULT([yes])
5535       tst_compi_sigsetjmp="yes"
5536     ],[
5537       AC_MSG_RESULT([no])
5538       tst_compi_sigsetjmp="no"
5539     ])
5540   fi
5541   #
5542   if test "$tst_compi_sigsetjmp" = "yes"; then
5543     AC_MSG_CHECKING([if sigsetjmp usage allowed])
5544     if test "x$curl_disallow_sigsetjmp" != "xyes"; then
5545       AC_MSG_RESULT([yes])
5546       tst_allow_sigsetjmp="yes"
5547     else
5548       AC_MSG_RESULT([no])
5549       tst_allow_sigsetjmp="no"
5550     fi
5551   fi
5552   #
5553   AC_MSG_CHECKING([if sigsetjmp might be used])
5554   if (test "$tst_proto_sigsetjmp" = "yes" ||
5555       test "$tst_macro_sigsetjmp" = "yes") &&
5556      test "$tst_compi_sigsetjmp" = "yes" &&
5557      test "$tst_allow_sigsetjmp" = "yes"; then
5558     AC_MSG_RESULT([yes])
5559     AC_DEFINE_UNQUOTED(HAVE_SIGSETJMP, 1,
5560       [Define to 1 if you have the sigsetjmp function or macro.])
5561     ac_cv_func_sigsetjmp="yes"
5562   else
5563     AC_MSG_RESULT([no])
5564     ac_cv_func_sigsetjmp="no"
5565   fi
5566 ])
5567
5568
5569 dnl CURL_CHECK_FUNC_SOCKET
5570 dnl -------------------------------------------------
5571 dnl Verify if socket is available, prototyped, and
5572 dnl can be compiled. If all of these are true, and
5573 dnl usage has not been previously disallowed with
5574 dnl shell variable curl_disallow_socket, then
5575 dnl HAVE_SOCKET will be defined.
5576
5577 AC_DEFUN([CURL_CHECK_FUNC_SOCKET], [
5578   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
5579   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
5580   AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
5581   #
5582   tst_links_socket="unknown"
5583   tst_proto_socket="unknown"
5584   tst_compi_socket="unknown"
5585   tst_allow_socket="unknown"
5586   #
5587   AC_MSG_CHECKING([if socket can be linked])
5588   AC_LINK_IFELSE([
5589     AC_LANG_PROGRAM([[
5590       $curl_includes_winsock2
5591       $curl_includes_sys_socket
5592       $curl_includes_socket
5593     ]],[[
5594       if(0 != socket(0, 0, 0))
5595         return 1;
5596     ]])
5597   ],[
5598     AC_MSG_RESULT([yes])
5599     tst_links_socket="yes"
5600   ],[
5601     AC_MSG_RESULT([no])
5602     tst_links_socket="no"
5603   ])
5604   #
5605   if test "$tst_links_socket" = "yes"; then
5606     AC_MSG_CHECKING([if socket is prototyped])
5607     AC_EGREP_CPP([socket],[
5608       $curl_includes_winsock2
5609       $curl_includes_sys_socket
5610       $curl_includes_socket
5611     ],[
5612       AC_MSG_RESULT([yes])
5613       tst_proto_socket="yes"
5614     ],[
5615       AC_MSG_RESULT([no])
5616       tst_proto_socket="no"
5617     ])
5618   fi
5619   #
5620   if test "$tst_proto_socket" = "yes"; then
5621     AC_MSG_CHECKING([if socket is compilable])
5622     AC_COMPILE_IFELSE([
5623       AC_LANG_PROGRAM([[
5624         $curl_includes_winsock2
5625         $curl_includes_sys_socket
5626         $curl_includes_socket
5627       ]],[[
5628         if(0 != socket(0, 0, 0))
5629           return 1;
5630       ]])
5631     ],[
5632       AC_MSG_RESULT([yes])
5633       tst_compi_socket="yes"
5634     ],[
5635       AC_MSG_RESULT([no])
5636       tst_compi_socket="no"
5637     ])
5638   fi
5639   #
5640   if test "$tst_compi_socket" = "yes"; then
5641     AC_MSG_CHECKING([if socket usage allowed])
5642     if test "x$curl_disallow_socket" != "xyes"; then
5643       AC_MSG_RESULT([yes])
5644       tst_allow_socket="yes"
5645     else
5646       AC_MSG_RESULT([no])
5647       tst_allow_socket="no"
5648     fi
5649   fi
5650   #
5651   AC_MSG_CHECKING([if socket might be used])
5652   if test "$tst_links_socket" = "yes" &&
5653      test "$tst_proto_socket" = "yes" &&
5654      test "$tst_compi_socket" = "yes" &&
5655      test "$tst_allow_socket" = "yes"; then
5656     AC_MSG_RESULT([yes])
5657     AC_DEFINE_UNQUOTED(HAVE_SOCKET, 1,
5658       [Define to 1 if you have the socket function.])
5659     ac_cv_func_socket="yes"
5660   else
5661     AC_MSG_RESULT([no])
5662     ac_cv_func_socket="no"
5663   fi
5664 ])
5665
5666
5667 dnl CURL_CHECK_FUNC_SOCKETPAIR
5668 dnl -------------------------------------------------
5669 dnl Verify if socketpair is available, prototyped, and
5670 dnl can be compiled. If all of these are true, and
5671 dnl usage has not been previously disallowed with
5672 dnl shell variable curl_disallow_socketpair, then
5673 dnl HAVE_SOCKETPAIR will be defined.
5674
5675 AC_DEFUN([CURL_CHECK_FUNC_SOCKETPAIR], [
5676   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
5677   AC_REQUIRE([CURL_INCLUDES_SOCKET])dnl
5678   #
5679   tst_links_socketpair="unknown"
5680   tst_proto_socketpair="unknown"
5681   tst_compi_socketpair="unknown"
5682   tst_allow_socketpair="unknown"
5683   #
5684   AC_MSG_CHECKING([if socketpair can be linked])
5685   AC_LINK_IFELSE([
5686     AC_LANG_FUNC_LINK_TRY([socketpair])
5687   ],[
5688     AC_MSG_RESULT([yes])
5689     tst_links_socketpair="yes"
5690   ],[
5691     AC_MSG_RESULT([no])
5692     tst_links_socketpair="no"
5693   ])
5694   #
5695   if test "$tst_links_socketpair" = "yes"; then
5696     AC_MSG_CHECKING([if socketpair is prototyped])
5697     AC_EGREP_CPP([socketpair],[
5698       $curl_includes_sys_socket
5699       $curl_includes_socket
5700     ],[
5701       AC_MSG_RESULT([yes])
5702       tst_proto_socketpair="yes"
5703     ],[
5704       AC_MSG_RESULT([no])
5705       tst_proto_socketpair="no"
5706     ])
5707   fi
5708   #
5709   if test "$tst_proto_socketpair" = "yes"; then
5710     AC_MSG_CHECKING([if socketpair is compilable])
5711     AC_COMPILE_IFELSE([
5712       AC_LANG_PROGRAM([[
5713         $curl_includes_sys_socket
5714         $curl_includes_socket
5715       ]],[[
5716         int sv[2];
5717         if(0 != socketpair(0, 0, 0, sv))
5718           return 1;
5719       ]])
5720     ],[
5721       AC_MSG_RESULT([yes])
5722       tst_compi_socketpair="yes"
5723     ],[
5724       AC_MSG_RESULT([no])
5725       tst_compi_socketpair="no"
5726     ])
5727   fi
5728   #
5729   if test "$tst_compi_socketpair" = "yes"; then
5730     AC_MSG_CHECKING([if socketpair usage allowed])
5731     if test "x$curl_disallow_socketpair" != "xyes"; then
5732       AC_MSG_RESULT([yes])
5733       tst_allow_socketpair="yes"
5734     else
5735       AC_MSG_RESULT([no])
5736       tst_allow_socketpair="no"
5737     fi
5738   fi
5739   #
5740   AC_MSG_CHECKING([if socketpair might be used])
5741   if test "$tst_links_socketpair" = "yes" &&
5742      test "$tst_proto_socketpair" = "yes" &&
5743      test "$tst_compi_socketpair" = "yes" &&
5744      test "$tst_allow_socketpair" = "yes"; then
5745     AC_MSG_RESULT([yes])
5746     AC_DEFINE_UNQUOTED(HAVE_SOCKETPAIR, 1,
5747       [Define to 1 if you have the socketpair function.])
5748     ac_cv_func_socketpair="yes"
5749   else
5750     AC_MSG_RESULT([no])
5751     ac_cv_func_socketpair="no"
5752   fi
5753 ])
5754
5755
5756 dnl CURL_CHECK_FUNC_STRCASECMP
5757 dnl -------------------------------------------------
5758 dnl Verify if strcasecmp is available, prototyped, and
5759 dnl can be compiled. If all of these are true, and
5760 dnl usage has not been previously disallowed with
5761 dnl shell variable curl_disallow_strcasecmp, then
5762 dnl HAVE_STRCASECMP will be defined.
5763
5764 AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [
5765   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
5766   #
5767   tst_links_strcasecmp="unknown"
5768   tst_proto_strcasecmp="unknown"
5769   tst_compi_strcasecmp="unknown"
5770   tst_allow_strcasecmp="unknown"
5771   #
5772   AC_MSG_CHECKING([if strcasecmp can be linked])
5773   AC_LINK_IFELSE([
5774     AC_LANG_FUNC_LINK_TRY([strcasecmp])
5775   ],[
5776     AC_MSG_RESULT([yes])
5777     tst_links_strcasecmp="yes"
5778   ],[
5779     AC_MSG_RESULT([no])
5780     tst_links_strcasecmp="no"
5781   ])
5782   #
5783   if test "$tst_links_strcasecmp" = "yes"; then
5784     AC_MSG_CHECKING([if strcasecmp is prototyped])
5785     AC_EGREP_CPP([strcasecmp],[
5786       $curl_includes_string
5787     ],[
5788       AC_MSG_RESULT([yes])
5789       tst_proto_strcasecmp="yes"
5790     ],[
5791       AC_MSG_RESULT([no])
5792       tst_proto_strcasecmp="no"
5793     ])
5794   fi
5795   #
5796   if test "$tst_proto_strcasecmp" = "yes"; then
5797     AC_MSG_CHECKING([if strcasecmp is compilable])
5798     AC_COMPILE_IFELSE([
5799       AC_LANG_PROGRAM([[
5800         $curl_includes_string
5801       ]],[[
5802         if(0 != strcasecmp(0, 0))
5803           return 1;
5804       ]])
5805     ],[
5806       AC_MSG_RESULT([yes])
5807       tst_compi_strcasecmp="yes"
5808     ],[
5809       AC_MSG_RESULT([no])
5810       tst_compi_strcasecmp="no"
5811     ])
5812   fi
5813   #
5814   if test "$tst_compi_strcasecmp" = "yes"; then
5815     AC_MSG_CHECKING([if strcasecmp usage allowed])
5816     if test "x$curl_disallow_strcasecmp" != "xyes"; then
5817       AC_MSG_RESULT([yes])
5818       tst_allow_strcasecmp="yes"
5819     else
5820       AC_MSG_RESULT([no])
5821       tst_allow_strcasecmp="no"
5822     fi
5823   fi
5824   #
5825   AC_MSG_CHECKING([if strcasecmp might be used])
5826   if test "$tst_links_strcasecmp" = "yes" &&
5827      test "$tst_proto_strcasecmp" = "yes" &&
5828      test "$tst_compi_strcasecmp" = "yes" &&
5829      test "$tst_allow_strcasecmp" = "yes"; then
5830     AC_MSG_RESULT([yes])
5831     AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
5832       [Define to 1 if you have the strcasecmp function.])
5833     ac_cv_func_strcasecmp="yes"
5834   else
5835     AC_MSG_RESULT([no])
5836     ac_cv_func_strcasecmp="no"
5837   fi
5838 ])
5839
5840
5841 dnl CURL_CHECK_FUNC_STRCASESTR
5842 dnl -------------------------------------------------
5843 dnl Verify if strcasestr is available, prototyped, and
5844 dnl can be compiled. If all of these are true, and
5845 dnl usage has not been previously disallowed with
5846 dnl shell variable curl_disallow_strcasestr, then
5847 dnl HAVE_STRCASESTR will be defined.
5848
5849 AC_DEFUN([CURL_CHECK_FUNC_STRCASESTR], [
5850   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
5851   #
5852   tst_links_strcasestr="unknown"
5853   tst_proto_strcasestr="unknown"
5854   tst_compi_strcasestr="unknown"
5855   tst_allow_strcasestr="unknown"
5856   #
5857   AC_MSG_CHECKING([if strcasestr can be linked])
5858   AC_LINK_IFELSE([
5859     AC_LANG_FUNC_LINK_TRY([strcasestr])
5860   ],[
5861     AC_MSG_RESULT([yes])
5862     tst_links_strcasestr="yes"
5863   ],[
5864     AC_MSG_RESULT([no])
5865     tst_links_strcasestr="no"
5866   ])
5867   #
5868   if test "$tst_links_strcasestr" = "yes"; then
5869     AC_MSG_CHECKING([if strcasestr is prototyped])
5870     AC_EGREP_CPP([strcasestr],[
5871       $curl_includes_string
5872     ],[
5873       AC_MSG_RESULT([yes])
5874       tst_proto_strcasestr="yes"
5875     ],[
5876       AC_MSG_RESULT([no])
5877       tst_proto_strcasestr="no"
5878     ])
5879   fi
5880   #
5881   if test "$tst_proto_strcasestr" = "yes"; then
5882     AC_MSG_CHECKING([if strcasestr is compilable])
5883     AC_COMPILE_IFELSE([
5884       AC_LANG_PROGRAM([[
5885         $curl_includes_string
5886       ]],[[
5887         if(0 != strcasestr(0, 0))
5888           return 1;
5889       ]])
5890     ],[
5891       AC_MSG_RESULT([yes])
5892       tst_compi_strcasestr="yes"
5893     ],[
5894       AC_MSG_RESULT([no])
5895       tst_compi_strcasestr="no"
5896     ])
5897   fi
5898   #
5899   if test "$tst_compi_strcasestr" = "yes"; then
5900     AC_MSG_CHECKING([if strcasestr usage allowed])
5901     if test "x$curl_disallow_strcasestr" != "xyes"; then
5902       AC_MSG_RESULT([yes])
5903       tst_allow_strcasestr="yes"
5904     else
5905       AC_MSG_RESULT([no])
5906       tst_allow_strcasestr="no"
5907     fi
5908   fi
5909   #
5910   AC_MSG_CHECKING([if strcasestr might be used])
5911   if test "$tst_links_strcasestr" = "yes" &&
5912      test "$tst_proto_strcasestr" = "yes" &&
5913      test "$tst_compi_strcasestr" = "yes" &&
5914      test "$tst_allow_strcasestr" = "yes"; then
5915     AC_MSG_RESULT([yes])
5916     AC_DEFINE_UNQUOTED(HAVE_STRCASESTR, 1,
5917       [Define to 1 if you have the strcasestr function.])
5918     ac_cv_func_strcasestr="yes"
5919   else
5920     AC_MSG_RESULT([no])
5921     ac_cv_func_strcasestr="no"
5922   fi
5923 ])
5924
5925
5926 dnl CURL_CHECK_FUNC_STRCMPI
5927 dnl -------------------------------------------------
5928 dnl Verify if strcmpi is available, prototyped, and
5929 dnl can be compiled. If all of these are true, and
5930 dnl usage has not been previously disallowed with
5931 dnl shell variable curl_disallow_strcmpi, then
5932 dnl HAVE_STRCMPI will be defined.
5933
5934 AC_DEFUN([CURL_CHECK_FUNC_STRCMPI], [
5935   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
5936   #
5937   tst_links_strcmpi="unknown"
5938   tst_proto_strcmpi="unknown"
5939   tst_compi_strcmpi="unknown"
5940   tst_allow_strcmpi="unknown"
5941   #
5942   AC_MSG_CHECKING([if strcmpi can be linked])
5943   AC_LINK_IFELSE([
5944     AC_LANG_FUNC_LINK_TRY([strcmpi])
5945   ],[
5946     AC_MSG_RESULT([yes])
5947     tst_links_strcmpi="yes"
5948   ],[
5949     AC_MSG_RESULT([no])
5950     tst_links_strcmpi="no"
5951   ])
5952   #
5953   if test "$tst_links_strcmpi" = "yes"; then
5954     AC_MSG_CHECKING([if strcmpi is prototyped])
5955     AC_EGREP_CPP([strcmpi],[
5956       $curl_includes_string
5957     ],[
5958       AC_MSG_RESULT([yes])
5959       tst_proto_strcmpi="yes"
5960     ],[
5961       AC_MSG_RESULT([no])
5962       tst_proto_strcmpi="no"
5963     ])
5964   fi
5965   #
5966   if test "$tst_proto_strcmpi" = "yes"; then
5967     AC_MSG_CHECKING([if strcmpi is compilable])
5968     AC_COMPILE_IFELSE([
5969       AC_LANG_PROGRAM([[
5970         $curl_includes_string
5971       ]],[[
5972         if(0 != strcmpi(0, 0))
5973           return 1;
5974       ]])
5975     ],[
5976       AC_MSG_RESULT([yes])
5977       tst_compi_strcmpi="yes"
5978     ],[
5979       AC_MSG_RESULT([no])
5980       tst_compi_strcmpi="no"
5981     ])
5982   fi
5983   #
5984   if test "$tst_compi_strcmpi" = "yes"; then
5985     AC_MSG_CHECKING([if strcmpi usage allowed])
5986     if test "x$curl_disallow_strcmpi" != "xyes"; then
5987       AC_MSG_RESULT([yes])
5988       tst_allow_strcmpi="yes"
5989     else
5990       AC_MSG_RESULT([no])
5991       tst_allow_strcmpi="no"
5992     fi
5993   fi
5994   #
5995   AC_MSG_CHECKING([if strcmpi might be used])
5996   if test "$tst_links_strcmpi" = "yes" &&
5997      test "$tst_proto_strcmpi" = "yes" &&
5998      test "$tst_compi_strcmpi" = "yes" &&
5999      test "$tst_allow_strcmpi" = "yes"; then
6000     AC_MSG_RESULT([yes])
6001     AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
6002       [Define to 1 if you have the strcmpi function.])
6003     ac_cv_func_strcmpi="yes"
6004   else
6005     AC_MSG_RESULT([no])
6006     ac_cv_func_strcmpi="no"
6007   fi
6008 ])
6009
6010
6011 dnl CURL_CHECK_FUNC_STRDUP
6012 dnl -------------------------------------------------
6013 dnl Verify if strdup is available, prototyped, and
6014 dnl can be compiled. If all of these are true, and
6015 dnl usage has not been previously disallowed with
6016 dnl shell variable curl_disallow_strdup, then
6017 dnl HAVE_STRDUP will be defined.
6018
6019 AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
6020   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6021   #
6022   tst_links_strdup="unknown"
6023   tst_proto_strdup="unknown"
6024   tst_compi_strdup="unknown"
6025   tst_allow_strdup="unknown"
6026   #
6027   AC_MSG_CHECKING([if strdup can be linked])
6028   AC_LINK_IFELSE([
6029     AC_LANG_FUNC_LINK_TRY([strdup])
6030   ],[
6031     AC_MSG_RESULT([yes])
6032     tst_links_strdup="yes"
6033   ],[
6034     AC_MSG_RESULT([no])
6035     tst_links_strdup="no"
6036   ])
6037   #
6038   if test "$tst_links_strdup" = "yes"; then
6039     AC_MSG_CHECKING([if strdup is prototyped])
6040     AC_EGREP_CPP([strdup],[
6041       $curl_includes_string
6042     ],[
6043       AC_MSG_RESULT([yes])
6044       tst_proto_strdup="yes"
6045     ],[
6046       AC_MSG_RESULT([no])
6047       tst_proto_strdup="no"
6048     ])
6049   fi
6050   #
6051   if test "$tst_proto_strdup" = "yes"; then
6052     AC_MSG_CHECKING([if strdup is compilable])
6053     AC_COMPILE_IFELSE([
6054       AC_LANG_PROGRAM([[
6055         $curl_includes_string
6056       ]],[[
6057         if(0 != strdup(0))
6058           return 1;
6059       ]])
6060     ],[
6061       AC_MSG_RESULT([yes])
6062       tst_compi_strdup="yes"
6063     ],[
6064       AC_MSG_RESULT([no])
6065       tst_compi_strdup="no"
6066     ])
6067   fi
6068   #
6069   if test "$tst_compi_strdup" = "yes"; then
6070     AC_MSG_CHECKING([if strdup usage allowed])
6071     if test "x$curl_disallow_strdup" != "xyes"; then
6072       AC_MSG_RESULT([yes])
6073       tst_allow_strdup="yes"
6074     else
6075       AC_MSG_RESULT([no])
6076       tst_allow_strdup="no"
6077     fi
6078   fi
6079   #
6080   AC_MSG_CHECKING([if strdup might be used])
6081   if test "$tst_links_strdup" = "yes" &&
6082      test "$tst_proto_strdup" = "yes" &&
6083      test "$tst_compi_strdup" = "yes" &&
6084      test "$tst_allow_strdup" = "yes"; then
6085     AC_MSG_RESULT([yes])
6086     AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
6087       [Define to 1 if you have the strdup function.])
6088     ac_cv_func_strdup="yes"
6089   else
6090     AC_MSG_RESULT([no])
6091     ac_cv_func_strdup="no"
6092   fi
6093 ])
6094
6095
6096 dnl CURL_CHECK_FUNC_STRERROR_R
6097 dnl -------------------------------------------------
6098 dnl Verify if strerror_r is available, prototyped, can be compiled and
6099 dnl seems to work. If all of these are true, and usage has not been
6100 dnl previously disallowed with shell variable curl_disallow_strerror_r,
6101 dnl then HAVE_STRERROR_R and STRERROR_R_TYPE_ARG3 will be defined, as
6102 dnl well as one of HAVE_GLIBC_STRERROR_R or HAVE_POSIX_STRERROR_R.
6103 dnl
6104 dnl glibc-style strerror_r:
6105 dnl
6106 dnl      char *strerror_r(int errnum, char *workbuf, size_t bufsize);
6107 dnl
6108 dnl  glibc-style strerror_r returns a pointer to the the error string,
6109 dnl  and might use the provided workbuf as a scratch area if needed. A
6110 dnl  quick test on a few systems shows that it's usually not used at all.
6111 dnl
6112 dnl POSIX-style strerror_r:
6113 dnl
6114 dnl      int strerror_r(int errnum, char *resultbuf, size_t bufsize);
6115 dnl
6116 dnl  POSIX-style strerror_r returns 0 upon successful completion and the
6117 dnl  error string in the provided resultbuf.
6118 dnl
6119
6120 AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
6121   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
6122   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6123   #
6124   tst_links_strerror_r="unknown"
6125   tst_proto_strerror_r="unknown"
6126   tst_compi_strerror_r="unknown"
6127   tst_glibc_strerror_r="unknown"
6128   tst_posix_strerror_r="unknown"
6129   tst_allow_strerror_r="unknown"
6130   tst_works_glibc_strerror_r="unknown"
6131   tst_works_posix_strerror_r="unknown"
6132   tst_glibc_strerror_r_type_arg3="unknown"
6133   tst_posix_strerror_r_type_arg3="unknown"
6134   #
6135   AC_MSG_CHECKING([if strerror_r can be linked])
6136   AC_LINK_IFELSE([
6137     AC_LANG_FUNC_LINK_TRY([strerror_r])
6138   ],[
6139     AC_MSG_RESULT([yes])
6140     tst_links_strerror_r="yes"
6141   ],[
6142     AC_MSG_RESULT([no])
6143     tst_links_strerror_r="no"
6144   ])
6145   #
6146   if test "$tst_links_strerror_r" = "yes"; then
6147     AC_MSG_CHECKING([if strerror_r is prototyped])
6148     AC_EGREP_CPP([strerror_r],[
6149       $curl_includes_string
6150     ],[
6151       AC_MSG_RESULT([yes])
6152       tst_proto_strerror_r="yes"
6153     ],[
6154       AC_MSG_RESULT([no])
6155       tst_proto_strerror_r="no"
6156     ])
6157   fi
6158   #
6159   if test "$tst_proto_strerror_r" = "yes"; then
6160     AC_MSG_CHECKING([if strerror_r is compilable])
6161     AC_COMPILE_IFELSE([
6162       AC_LANG_PROGRAM([[
6163         $curl_includes_string
6164       ]],[[
6165         if(0 != strerror_r(0, 0, 0))
6166           return 1;
6167       ]])
6168     ],[
6169       AC_MSG_RESULT([yes])
6170       tst_compi_strerror_r="yes"
6171     ],[
6172       AC_MSG_RESULT([no])
6173       tst_compi_strerror_r="no"
6174     ])
6175   fi
6176   #
6177   if test "$tst_compi_strerror_r" = "yes"; then
6178     AC_MSG_CHECKING([if strerror_r is glibc like])
6179     tst_glibc_strerror_r_type_arg3="unknown"
6180     for arg3 in 'size_t' 'int' 'unsigned int'; do
6181       if test "$tst_glibc_strerror_r_type_arg3" = "unknown"; then
6182         AC_COMPILE_IFELSE([
6183           AC_LANG_PROGRAM([[
6184             $curl_includes_string
6185           ]],[[
6186             char *strerror_r(int errnum, char *workbuf, $arg3 bufsize);
6187             if(0 != strerror_r(0, 0, 0))
6188               return 1;
6189           ]])
6190         ],[
6191           tst_glibc_strerror_r_type_arg3="$arg3"
6192         ])
6193       fi
6194     done
6195     case "$tst_glibc_strerror_r_type_arg3" in
6196       unknown)
6197         AC_MSG_RESULT([no])
6198         tst_glibc_strerror_r="no"
6199         ;;
6200       *)
6201         AC_MSG_RESULT([yes])
6202         tst_glibc_strerror_r="yes"
6203         ;;
6204     esac
6205   fi
6206   #
6207   dnl only do runtime verification when not cross-compiling
6208   if test "x$cross_compiling" != "xyes" &&
6209     test "$tst_glibc_strerror_r" = "yes"; then
6210     AC_MSG_CHECKING([if strerror_r seems to work])
6211     AC_RUN_IFELSE([
6212       AC_LANG_PROGRAM([[
6213         $curl_includes_stdlib
6214         $curl_includes_string
6215 #       include <errno.h>
6216       ]],[[
6217         char buffer[1024];
6218         char *string = 0;
6219         buffer[0] = '\0';
6220         string = strerror_r(EACCES, buffer, sizeof(buffer));
6221         if(!string)
6222           exit(1); /* fail */
6223         if(!string[0])
6224           exit(1); /* fail */
6225         else
6226           exit(0);
6227       ]])
6228     ],[
6229       AC_MSG_RESULT([yes])
6230       tst_works_glibc_strerror_r="yes"
6231     ],[
6232       AC_MSG_RESULT([no])
6233       tst_works_glibc_strerror_r="no"
6234     ])
6235   fi
6236   #
6237   if test "$tst_compi_strerror_r" = "yes" &&
6238     test "$tst_works_glibc_strerror_r" != "yes"; then
6239     AC_MSG_CHECKING([if strerror_r is POSIX like])
6240     tst_posix_strerror_r_type_arg3="unknown"
6241     for arg3 in 'size_t' 'int' 'unsigned int'; do
6242       if test "$tst_posix_strerror_r_type_arg3" = "unknown"; then
6243         AC_COMPILE_IFELSE([
6244           AC_LANG_PROGRAM([[
6245             $curl_includes_string
6246           ]],[[
6247             int strerror_r(int errnum, char *resultbuf, $arg3 bufsize);
6248             if(0 != strerror_r(0, 0, 0))
6249               return 1;
6250           ]])
6251         ],[
6252           tst_posix_strerror_r_type_arg3="$arg3"
6253         ])
6254       fi
6255     done
6256     case "$tst_posix_strerror_r_type_arg3" in
6257       unknown)
6258         AC_MSG_RESULT([no])
6259         tst_posix_strerror_r="no"
6260         ;;
6261       *)
6262         AC_MSG_RESULT([yes])
6263         tst_posix_strerror_r="yes"
6264         ;;
6265     esac
6266   fi
6267   #
6268   dnl only do runtime verification when not cross-compiling
6269   if test "x$cross_compiling" != "xyes" &&
6270     test "$tst_posix_strerror_r" = "yes"; then
6271     AC_MSG_CHECKING([if strerror_r seems to work])
6272     AC_RUN_IFELSE([
6273       AC_LANG_PROGRAM([[
6274         $curl_includes_stdlib
6275         $curl_includes_string
6276 #       include <errno.h>
6277       ]],[[
6278         char buffer[1024];
6279         int error = 1;
6280         buffer[0] = '\0';
6281         error = strerror_r(EACCES, buffer, sizeof(buffer));
6282         if(error)
6283           exit(1); /* fail */
6284         if(buffer[0] == '\0')
6285           exit(1); /* fail */
6286         else
6287           exit(0);
6288       ]])
6289     ],[
6290       AC_MSG_RESULT([yes])
6291       tst_works_posix_strerror_r="yes"
6292     ],[
6293       AC_MSG_RESULT([no])
6294       tst_works_posix_strerror_r="no"
6295     ])
6296   fi
6297   #
6298   if test "$tst_works_glibc_strerror_r" = "yes"; then
6299     tst_posix_strerror_r="no"
6300   fi
6301   if test "$tst_works_posix_strerror_r" = "yes"; then
6302     tst_glibc_strerror_r="no"
6303   fi
6304   if test "$tst_glibc_strerror_r" = "yes" &&
6305     test "$tst_works_glibc_strerror_r" != "no" &&
6306     test "$tst_posix_strerror_r" != "yes"; then
6307     tst_allow_strerror_r="check"
6308   fi
6309   if test "$tst_posix_strerror_r" = "yes" &&
6310     test "$tst_works_posix_strerror_r" != "no" &&
6311     test "$tst_glibc_strerror_r" != "yes"; then
6312     tst_allow_strerror_r="check"
6313   fi
6314   if test "$tst_allow_strerror_r" = "check"; then
6315     AC_MSG_CHECKING([if strerror_r usage allowed])
6316     if test "x$curl_disallow_strerror_r" != "xyes"; then
6317       AC_MSG_RESULT([yes])
6318       tst_allow_strerror_r="yes"
6319     else
6320       AC_MSG_RESULT([no])
6321       tst_allow_strerror_r="no"
6322     fi
6323   fi
6324   #
6325   AC_MSG_CHECKING([if strerror_r might be used])
6326   if test "$tst_links_strerror_r" = "yes" &&
6327      test "$tst_proto_strerror_r" = "yes" &&
6328      test "$tst_compi_strerror_r" = "yes" &&
6329      test "$tst_allow_strerror_r" = "yes"; then
6330     AC_MSG_RESULT([yes])
6331     if test "$tst_glibc_strerror_r" = "yes"; then
6332       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
6333         [Define to 1 if you have the strerror_r function.])
6334       AC_DEFINE_UNQUOTED(HAVE_GLIBC_STRERROR_R, 1,
6335         [Define to 1 if you have a working glibc-style strerror_r function.])
6336       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_glibc_strerror_r_type_arg3,
6337         [Define to the type of arg 3 for strerror_r.])
6338     fi
6339     if test "$tst_posix_strerror_r" = "yes"; then
6340       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
6341         [Define to 1 if you have the strerror_r function.])
6342       AC_DEFINE_UNQUOTED(HAVE_POSIX_STRERROR_R, 1,
6343         [Define to 1 if you have a working POSIX-style strerror_r function.])
6344       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_posix_strerror_r_type_arg3,
6345         [Define to the type of arg 3 for strerror_r.])
6346     fi
6347     ac_cv_func_strerror_r="yes"
6348   else
6349     AC_MSG_RESULT([no])
6350     ac_cv_func_strerror_r="no"
6351   fi
6352   #
6353   if test "$tst_compi_strerror_r" = "yes" &&
6354      test "$tst_allow_strerror_r" = "unknown"; then
6355     AC_MSG_WARN([cannot determine strerror_r() style: edit lib/curl_config.h manually.])
6356   fi
6357   #
6358 ])
6359
6360
6361 dnl CURL_CHECK_FUNC_STRICMP
6362 dnl -------------------------------------------------
6363 dnl Verify if stricmp is available, prototyped, and
6364 dnl can be compiled. If all of these are true, and
6365 dnl usage has not been previously disallowed with
6366 dnl shell variable curl_disallow_stricmp, then
6367 dnl HAVE_STRICMP will be defined.
6368
6369 AC_DEFUN([CURL_CHECK_FUNC_STRICMP], [
6370   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6371   #
6372   tst_links_stricmp="unknown"
6373   tst_proto_stricmp="unknown"
6374   tst_compi_stricmp="unknown"
6375   tst_allow_stricmp="unknown"
6376   #
6377   AC_MSG_CHECKING([if stricmp can be linked])
6378   AC_LINK_IFELSE([
6379     AC_LANG_FUNC_LINK_TRY([stricmp])
6380   ],[
6381     AC_MSG_RESULT([yes])
6382     tst_links_stricmp="yes"
6383   ],[
6384     AC_MSG_RESULT([no])
6385     tst_links_stricmp="no"
6386   ])
6387   #
6388   if test "$tst_links_stricmp" = "yes"; then
6389     AC_MSG_CHECKING([if stricmp is prototyped])
6390     AC_EGREP_CPP([stricmp],[
6391       $curl_includes_string
6392     ],[
6393       AC_MSG_RESULT([yes])
6394       tst_proto_stricmp="yes"
6395     ],[
6396       AC_MSG_RESULT([no])
6397       tst_proto_stricmp="no"
6398     ])
6399   fi
6400   #
6401   if test "$tst_proto_stricmp" = "yes"; then
6402     AC_MSG_CHECKING([if stricmp is compilable])
6403     AC_COMPILE_IFELSE([
6404       AC_LANG_PROGRAM([[
6405         $curl_includes_string
6406       ]],[[
6407         if(0 != stricmp(0, 0))
6408           return 1;
6409       ]])
6410     ],[
6411       AC_MSG_RESULT([yes])
6412       tst_compi_stricmp="yes"
6413     ],[
6414       AC_MSG_RESULT([no])
6415       tst_compi_stricmp="no"
6416     ])
6417   fi
6418   #
6419   if test "$tst_compi_stricmp" = "yes"; then
6420     AC_MSG_CHECKING([if stricmp usage allowed])
6421     if test "x$curl_disallow_stricmp" != "xyes"; then
6422       AC_MSG_RESULT([yes])
6423       tst_allow_stricmp="yes"
6424     else
6425       AC_MSG_RESULT([no])
6426       tst_allow_stricmp="no"
6427     fi
6428   fi
6429   #
6430   AC_MSG_CHECKING([if stricmp might be used])
6431   if test "$tst_links_stricmp" = "yes" &&
6432      test "$tst_proto_stricmp" = "yes" &&
6433      test "$tst_compi_stricmp" = "yes" &&
6434      test "$tst_allow_stricmp" = "yes"; then
6435     AC_MSG_RESULT([yes])
6436     AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
6437       [Define to 1 if you have the stricmp function.])
6438     ac_cv_func_stricmp="yes"
6439   else
6440     AC_MSG_RESULT([no])
6441     ac_cv_func_stricmp="no"
6442   fi
6443 ])
6444
6445
6446 dnl CURL_CHECK_FUNC_STRLCAT
6447 dnl -------------------------------------------------
6448 dnl Verify if strlcat is available, prototyped, and
6449 dnl can be compiled. If all of these are true, and
6450 dnl usage has not been previously disallowed with
6451 dnl shell variable curl_disallow_strlcat, then
6452 dnl HAVE_STRLCAT will be defined.
6453
6454 AC_DEFUN([CURL_CHECK_FUNC_STRLCAT], [
6455   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6456   #
6457   tst_links_strlcat="unknown"
6458   tst_proto_strlcat="unknown"
6459   tst_compi_strlcat="unknown"
6460   tst_allow_strlcat="unknown"
6461   #
6462   AC_MSG_CHECKING([if strlcat can be linked])
6463   AC_LINK_IFELSE([
6464     AC_LANG_FUNC_LINK_TRY([strlcat])
6465   ],[
6466     AC_MSG_RESULT([yes])
6467     tst_links_strlcat="yes"
6468   ],[
6469     AC_MSG_RESULT([no])
6470     tst_links_strlcat="no"
6471   ])
6472   #
6473   if test "$tst_links_strlcat" = "yes"; then
6474     AC_MSG_CHECKING([if strlcat is prototyped])
6475     AC_EGREP_CPP([strlcat],[
6476       $curl_includes_string
6477     ],[
6478       AC_MSG_RESULT([yes])
6479       tst_proto_strlcat="yes"
6480     ],[
6481       AC_MSG_RESULT([no])
6482       tst_proto_strlcat="no"
6483     ])
6484   fi
6485   #
6486   if test "$tst_proto_strlcat" = "yes"; then
6487     AC_MSG_CHECKING([if strlcat is compilable])
6488     AC_COMPILE_IFELSE([
6489       AC_LANG_PROGRAM([[
6490         $curl_includes_string
6491       ]],[[
6492         if(0 != strlcat(0, 0, 0))
6493           return 1;
6494       ]])
6495     ],[
6496       AC_MSG_RESULT([yes])
6497       tst_compi_strlcat="yes"
6498     ],[
6499       AC_MSG_RESULT([no])
6500       tst_compi_strlcat="no"
6501     ])
6502   fi
6503   #
6504   if test "$tst_compi_strlcat" = "yes"; then
6505     AC_MSG_CHECKING([if strlcat usage allowed])
6506     if test "x$curl_disallow_strlcat" != "xyes"; then
6507       AC_MSG_RESULT([yes])
6508       tst_allow_strlcat="yes"
6509     else
6510       AC_MSG_RESULT([no])
6511       tst_allow_strlcat="no"
6512     fi
6513   fi
6514   #
6515   AC_MSG_CHECKING([if strlcat might be used])
6516   if test "$tst_links_strlcat" = "yes" &&
6517      test "$tst_proto_strlcat" = "yes" &&
6518      test "$tst_compi_strlcat" = "yes" &&
6519      test "$tst_allow_strlcat" = "yes"; then
6520     AC_MSG_RESULT([yes])
6521     AC_DEFINE_UNQUOTED(HAVE_STRLCAT, 1,
6522       [Define to 1 if you have the strlcat function.])
6523     ac_cv_func_strlcat="yes"
6524   else
6525     AC_MSG_RESULT([no])
6526     ac_cv_func_strlcat="no"
6527   fi
6528 ])
6529
6530
6531 dnl CURL_CHECK_FUNC_STRNCASECMP
6532 dnl -------------------------------------------------
6533 dnl Verify if strncasecmp is available, prototyped, and
6534 dnl can be compiled. If all of these are true, and
6535 dnl usage has not been previously disallowed with
6536 dnl shell variable curl_disallow_strncasecmp, then
6537 dnl HAVE_STRNCASECMP will be defined.
6538
6539 AC_DEFUN([CURL_CHECK_FUNC_STRNCASECMP], [
6540   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6541   #
6542   tst_links_strncasecmp="unknown"
6543   tst_proto_strncasecmp="unknown"
6544   tst_compi_strncasecmp="unknown"
6545   tst_allow_strncasecmp="unknown"
6546   #
6547   AC_MSG_CHECKING([if strncasecmp can be linked])
6548   AC_LINK_IFELSE([
6549     AC_LANG_FUNC_LINK_TRY([strncasecmp])
6550   ],[
6551     AC_MSG_RESULT([yes])
6552     tst_links_strncasecmp="yes"
6553   ],[
6554     AC_MSG_RESULT([no])
6555     tst_links_strncasecmp="no"
6556   ])
6557   #
6558   if test "$tst_links_strncasecmp" = "yes"; then
6559     AC_MSG_CHECKING([if strncasecmp is prototyped])
6560     AC_EGREP_CPP([strncasecmp],[
6561       $curl_includes_string
6562     ],[
6563       AC_MSG_RESULT([yes])
6564       tst_proto_strncasecmp="yes"
6565     ],[
6566       AC_MSG_RESULT([no])
6567       tst_proto_strncasecmp="no"
6568     ])
6569   fi
6570   #
6571   if test "$tst_proto_strncasecmp" = "yes"; then
6572     AC_MSG_CHECKING([if strncasecmp is compilable])
6573     AC_COMPILE_IFELSE([
6574       AC_LANG_PROGRAM([[
6575         $curl_includes_string
6576       ]],[[
6577         if(0 != strncasecmp(0, 0, 0))
6578           return 1;
6579       ]])
6580     ],[
6581       AC_MSG_RESULT([yes])
6582       tst_compi_strncasecmp="yes"
6583     ],[
6584       AC_MSG_RESULT([no])
6585       tst_compi_strncasecmp="no"
6586     ])
6587   fi
6588   #
6589   if test "$tst_compi_strncasecmp" = "yes"; then
6590     AC_MSG_CHECKING([if strncasecmp usage allowed])
6591     if test "x$curl_disallow_strncasecmp" != "xyes"; then
6592       AC_MSG_RESULT([yes])
6593       tst_allow_strncasecmp="yes"
6594     else
6595       AC_MSG_RESULT([no])
6596       tst_allow_strncasecmp="no"
6597     fi
6598   fi
6599   #
6600   AC_MSG_CHECKING([if strncasecmp might be used])
6601   if test "$tst_links_strncasecmp" = "yes" &&
6602      test "$tst_proto_strncasecmp" = "yes" &&
6603      test "$tst_compi_strncasecmp" = "yes" &&
6604      test "$tst_allow_strncasecmp" = "yes"; then
6605     AC_MSG_RESULT([yes])
6606     AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
6607       [Define to 1 if you have the strncasecmp function.])
6608     ac_cv_func_strncasecmp="yes"
6609   else
6610     AC_MSG_RESULT([no])
6611     ac_cv_func_strncasecmp="no"
6612   fi
6613 ])
6614
6615
6616 dnl CURL_CHECK_FUNC_STRNCMPI
6617 dnl -------------------------------------------------
6618 dnl Verify if strncmpi is available, prototyped, and
6619 dnl can be compiled. If all of these are true, and
6620 dnl usage has not been previously disallowed with
6621 dnl shell variable curl_disallow_strncmpi, then
6622 dnl HAVE_STRNCMPI will be defined.
6623
6624 AC_DEFUN([CURL_CHECK_FUNC_STRNCMPI], [
6625   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6626   #
6627   tst_links_strncmpi="unknown"
6628   tst_proto_strncmpi="unknown"
6629   tst_compi_strncmpi="unknown"
6630   tst_allow_strncmpi="unknown"
6631   #
6632   AC_MSG_CHECKING([if strncmpi can be linked])
6633   AC_LINK_IFELSE([
6634     AC_LANG_FUNC_LINK_TRY([strncmpi])
6635   ],[
6636     AC_MSG_RESULT([yes])
6637     tst_links_strncmpi="yes"
6638   ],[
6639     AC_MSG_RESULT([no])
6640     tst_links_strncmpi="no"
6641   ])
6642   #
6643   if test "$tst_links_strncmpi" = "yes"; then
6644     AC_MSG_CHECKING([if strncmpi is prototyped])
6645     AC_EGREP_CPP([strncmpi],[
6646       $curl_includes_string
6647     ],[
6648       AC_MSG_RESULT([yes])
6649       tst_proto_strncmpi="yes"
6650     ],[
6651       AC_MSG_RESULT([no])
6652       tst_proto_strncmpi="no"
6653     ])
6654   fi
6655   #
6656   if test "$tst_proto_strncmpi" = "yes"; then
6657     AC_MSG_CHECKING([if strncmpi is compilable])
6658     AC_COMPILE_IFELSE([
6659       AC_LANG_PROGRAM([[
6660         $curl_includes_string
6661       ]],[[
6662         if(0 != strncmpi(0, 0))
6663           return 1;
6664       ]])
6665     ],[
6666       AC_MSG_RESULT([yes])
6667       tst_compi_strncmpi="yes"
6668     ],[
6669       AC_MSG_RESULT([no])
6670       tst_compi_strncmpi="no"
6671     ])
6672   fi
6673   #
6674   if test "$tst_compi_strncmpi" = "yes"; then
6675     AC_MSG_CHECKING([if strncmpi usage allowed])
6676     if test "x$curl_disallow_strncmpi" != "xyes"; then
6677       AC_MSG_RESULT([yes])
6678       tst_allow_strncmpi="yes"
6679     else
6680       AC_MSG_RESULT([no])
6681       tst_allow_strncmpi="no"
6682     fi
6683   fi
6684   #
6685   AC_MSG_CHECKING([if strncmpi might be used])
6686   if test "$tst_links_strncmpi" = "yes" &&
6687      test "$tst_proto_strncmpi" = "yes" &&
6688      test "$tst_compi_strncmpi" = "yes" &&
6689      test "$tst_allow_strncmpi" = "yes"; then
6690     AC_MSG_RESULT([yes])
6691     AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
6692       [Define to 1 if you have the strncmpi function.])
6693     ac_cv_func_strncmpi="yes"
6694   else
6695     AC_MSG_RESULT([no])
6696     ac_cv_func_strncmpi="no"
6697   fi
6698 ])
6699
6700
6701 dnl CURL_CHECK_FUNC_STRNICMP
6702 dnl -------------------------------------------------
6703 dnl Verify if strnicmp is available, prototyped, and
6704 dnl can be compiled. If all of these are true, and
6705 dnl usage has not been previously disallowed with
6706 dnl shell variable curl_disallow_strnicmp, then
6707 dnl HAVE_STRNICMP will be defined.
6708
6709 AC_DEFUN([CURL_CHECK_FUNC_STRNICMP], [
6710   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6711   #
6712   tst_links_strnicmp="unknown"
6713   tst_proto_strnicmp="unknown"
6714   tst_compi_strnicmp="unknown"
6715   tst_allow_strnicmp="unknown"
6716   #
6717   AC_MSG_CHECKING([if strnicmp can be linked])
6718   AC_LINK_IFELSE([
6719     AC_LANG_FUNC_LINK_TRY([strnicmp])
6720   ],[
6721     AC_MSG_RESULT([yes])
6722     tst_links_strnicmp="yes"
6723   ],[
6724     AC_MSG_RESULT([no])
6725     tst_links_strnicmp="no"
6726   ])
6727   #
6728   if test "$tst_links_strnicmp" = "yes"; then
6729     AC_MSG_CHECKING([if strnicmp is prototyped])
6730     AC_EGREP_CPP([strnicmp],[
6731       $curl_includes_string
6732     ],[
6733       AC_MSG_RESULT([yes])
6734       tst_proto_strnicmp="yes"
6735     ],[
6736       AC_MSG_RESULT([no])
6737       tst_proto_strnicmp="no"
6738     ])
6739   fi
6740   #
6741   if test "$tst_proto_strnicmp" = "yes"; then
6742     AC_MSG_CHECKING([if strnicmp is compilable])
6743     AC_COMPILE_IFELSE([
6744       AC_LANG_PROGRAM([[
6745         $curl_includes_string
6746       ]],[[
6747         if(0 != strnicmp(0, 0))
6748           return 1;
6749       ]])
6750     ],[
6751       AC_MSG_RESULT([yes])
6752       tst_compi_strnicmp="yes"
6753     ],[
6754       AC_MSG_RESULT([no])
6755       tst_compi_strnicmp="no"
6756     ])
6757   fi
6758   #
6759   if test "$tst_compi_strnicmp" = "yes"; then
6760     AC_MSG_CHECKING([if strnicmp usage allowed])
6761     if test "x$curl_disallow_strnicmp" != "xyes"; then
6762       AC_MSG_RESULT([yes])
6763       tst_allow_strnicmp="yes"
6764     else
6765       AC_MSG_RESULT([no])
6766       tst_allow_strnicmp="no"
6767     fi
6768   fi
6769   #
6770   AC_MSG_CHECKING([if strnicmp might be used])
6771   if test "$tst_links_strnicmp" = "yes" &&
6772      test "$tst_proto_strnicmp" = "yes" &&
6773      test "$tst_compi_strnicmp" = "yes" &&
6774      test "$tst_allow_strnicmp" = "yes"; then
6775     AC_MSG_RESULT([yes])
6776     AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
6777       [Define to 1 if you have the strnicmp function.])
6778     ac_cv_func_strnicmp="yes"
6779   else
6780     AC_MSG_RESULT([no])
6781     ac_cv_func_strnicmp="no"
6782   fi
6783 ])
6784
6785
6786 dnl CURL_CHECK_FUNC_STRSTR
6787 dnl -------------------------------------------------
6788 dnl Verify if strstr is available, prototyped, and
6789 dnl can be compiled. If all of these are true, and
6790 dnl usage has not been previously disallowed with
6791 dnl shell variable curl_disallow_strstr, then
6792 dnl HAVE_STRSTR will be defined.
6793
6794 AC_DEFUN([CURL_CHECK_FUNC_STRSTR], [
6795   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6796   #
6797   tst_links_strstr="unknown"
6798   tst_proto_strstr="unknown"
6799   tst_compi_strstr="unknown"
6800   tst_allow_strstr="unknown"
6801   #
6802   AC_MSG_CHECKING([if strstr can be linked])
6803   AC_LINK_IFELSE([
6804     AC_LANG_FUNC_LINK_TRY([strstr])
6805   ],[
6806     AC_MSG_RESULT([yes])
6807     tst_links_strstr="yes"
6808   ],[
6809     AC_MSG_RESULT([no])
6810     tst_links_strstr="no"
6811   ])
6812   #
6813   if test "$tst_links_strstr" = "yes"; then
6814     AC_MSG_CHECKING([if strstr is prototyped])
6815     AC_EGREP_CPP([strstr],[
6816       $curl_includes_string
6817     ],[
6818       AC_MSG_RESULT([yes])
6819       tst_proto_strstr="yes"
6820     ],[
6821       AC_MSG_RESULT([no])
6822       tst_proto_strstr="no"
6823     ])
6824   fi
6825   #
6826   if test "$tst_proto_strstr" = "yes"; then
6827     AC_MSG_CHECKING([if strstr is compilable])
6828     AC_COMPILE_IFELSE([
6829       AC_LANG_PROGRAM([[
6830         $curl_includes_string
6831       ]],[[
6832         if(0 != strstr(0, 0))
6833           return 1;
6834       ]])
6835     ],[
6836       AC_MSG_RESULT([yes])
6837       tst_compi_strstr="yes"
6838     ],[
6839       AC_MSG_RESULT([no])
6840       tst_compi_strstr="no"
6841     ])
6842   fi
6843   #
6844   if test "$tst_compi_strstr" = "yes"; then
6845     AC_MSG_CHECKING([if strstr usage allowed])
6846     if test "x$curl_disallow_strstr" != "xyes"; then
6847       AC_MSG_RESULT([yes])
6848       tst_allow_strstr="yes"
6849     else
6850       AC_MSG_RESULT([no])
6851       tst_allow_strstr="no"
6852     fi
6853   fi
6854   #
6855   AC_MSG_CHECKING([if strstr might be used])
6856   if test "$tst_links_strstr" = "yes" &&
6857      test "$tst_proto_strstr" = "yes" &&
6858      test "$tst_compi_strstr" = "yes" &&
6859      test "$tst_allow_strstr" = "yes"; then
6860     AC_MSG_RESULT([yes])
6861     AC_DEFINE_UNQUOTED(HAVE_STRSTR, 1,
6862       [Define to 1 if you have the strstr function.])
6863     ac_cv_func_strstr="yes"
6864   else
6865     AC_MSG_RESULT([no])
6866     ac_cv_func_strstr="no"
6867   fi
6868 ])
6869
6870
6871 dnl CURL_CHECK_FUNC_STRTOK_R
6872 dnl -------------------------------------------------
6873 dnl Verify if strtok_r is available, prototyped, and
6874 dnl can be compiled. If all of these are true, and
6875 dnl usage has not been previously disallowed with
6876 dnl shell variable curl_disallow_strtok_r, then
6877 dnl HAVE_STRTOK_R will be defined.
6878
6879 AC_DEFUN([CURL_CHECK_FUNC_STRTOK_R], [
6880   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
6881   #
6882   tst_links_strtok_r="unknown"
6883   tst_proto_strtok_r="unknown"
6884   tst_compi_strtok_r="unknown"
6885   tst_allow_strtok_r="unknown"
6886   #
6887   AC_MSG_CHECKING([if strtok_r can be linked])
6888   AC_LINK_IFELSE([
6889     AC_LANG_FUNC_LINK_TRY([strtok_r])
6890   ],[
6891     AC_MSG_RESULT([yes])
6892     tst_links_strtok_r="yes"
6893   ],[
6894     AC_MSG_RESULT([no])
6895     tst_links_strtok_r="no"
6896   ])
6897   #
6898   if test "$tst_links_strtok_r" = "yes"; then
6899     AC_MSG_CHECKING([if strtok_r is prototyped])
6900     AC_EGREP_CPP([strtok_r],[
6901       $curl_includes_string
6902     ],[
6903       AC_MSG_RESULT([yes])
6904       tst_proto_strtok_r="yes"
6905     ],[
6906       AC_MSG_RESULT([no])
6907       tst_proto_strtok_r="no"
6908     ])
6909   fi
6910   #
6911   if test "$tst_proto_strtok_r" = "yes"; then
6912     AC_MSG_CHECKING([if strtok_r is compilable])
6913     AC_COMPILE_IFELSE([
6914       AC_LANG_PROGRAM([[
6915         $curl_includes_string
6916       ]],[[
6917         if(0 != strtok_r(0, 0, 0))
6918           return 1;
6919       ]])
6920     ],[
6921       AC_MSG_RESULT([yes])
6922       tst_compi_strtok_r="yes"
6923     ],[
6924       AC_MSG_RESULT([no])
6925       tst_compi_strtok_r="no"
6926     ])
6927   fi
6928   #
6929   if test "$tst_compi_strtok_r" = "yes"; then
6930     AC_MSG_CHECKING([if strtok_r usage allowed])
6931     if test "x$curl_disallow_strtok_r" != "xyes"; then
6932       AC_MSG_RESULT([yes])
6933       tst_allow_strtok_r="yes"
6934     else
6935       AC_MSG_RESULT([no])
6936       tst_allow_strtok_r="no"
6937     fi
6938   fi
6939   #
6940   AC_MSG_CHECKING([if strtok_r might be used])
6941   if test "$tst_links_strtok_r" = "yes" &&
6942      test "$tst_proto_strtok_r" = "yes" &&
6943      test "$tst_compi_strtok_r" = "yes" &&
6944      test "$tst_allow_strtok_r" = "yes"; then
6945     AC_MSG_RESULT([yes])
6946     AC_DEFINE_UNQUOTED(HAVE_STRTOK_R, 1,
6947       [Define to 1 if you have the strtok_r function.])
6948     ac_cv_func_strtok_r="yes"
6949   else
6950     AC_MSG_RESULT([no])
6951     ac_cv_func_strtok_r="no"
6952   fi
6953 ])
6954
6955
6956 dnl CURL_CHECK_FUNC_STRTOLL
6957 dnl -------------------------------------------------
6958 dnl Verify if strtoll is available, prototyped, and
6959 dnl can be compiled. If all of these are true, and
6960 dnl usage has not been previously disallowed with
6961 dnl shell variable curl_disallow_strtoll, then
6962 dnl HAVE_STRTOLL will be defined.
6963
6964 AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
6965   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
6966   #
6967   tst_links_strtoll="unknown"
6968   tst_proto_strtoll="unknown"
6969   tst_compi_strtoll="unknown"
6970   tst_allow_strtoll="unknown"
6971   #
6972   AC_MSG_CHECKING([if strtoll can be linked])
6973   AC_LINK_IFELSE([
6974     AC_LANG_FUNC_LINK_TRY([strtoll])
6975   ],[
6976     AC_MSG_RESULT([yes])
6977     tst_links_strtoll="yes"
6978   ],[
6979     AC_MSG_RESULT([no])
6980     tst_links_strtoll="no"
6981   ])
6982   #
6983   if test "$tst_links_strtoll" = "yes"; then
6984     AC_MSG_CHECKING([if strtoll is prototyped])
6985     AC_EGREP_CPP([strtoll],[
6986       $curl_includes_stdlib
6987     ],[
6988       AC_MSG_RESULT([yes])
6989       tst_proto_strtoll="yes"
6990     ],[
6991       AC_MSG_RESULT([no])
6992       tst_proto_strtoll="no"
6993     ])
6994   fi
6995   #
6996   if test "$tst_proto_strtoll" = "yes"; then
6997     AC_MSG_CHECKING([if strtoll is compilable])
6998     AC_COMPILE_IFELSE([
6999       AC_LANG_PROGRAM([[
7000         $curl_includes_stdlib
7001       ]],[[
7002         if(0 != strtoll(0, 0, 0))
7003           return 1;
7004       ]])
7005     ],[
7006       AC_MSG_RESULT([yes])
7007       tst_compi_strtoll="yes"
7008     ],[
7009       AC_MSG_RESULT([no])
7010       tst_compi_strtoll="no"
7011     ])
7012   fi
7013   #
7014   if test "$tst_compi_strtoll" = "yes"; then
7015     AC_MSG_CHECKING([if strtoll usage allowed])
7016     if test "x$curl_disallow_strtoll" != "xyes"; then
7017       AC_MSG_RESULT([yes])
7018       tst_allow_strtoll="yes"
7019     else
7020       AC_MSG_RESULT([no])
7021       tst_allow_strtoll="no"
7022     fi
7023   fi
7024   #
7025   AC_MSG_CHECKING([if strtoll might be used])
7026   if test "$tst_links_strtoll" = "yes" &&
7027      test "$tst_proto_strtoll" = "yes" &&
7028      test "$tst_compi_strtoll" = "yes" &&
7029      test "$tst_allow_strtoll" = "yes"; then
7030     AC_MSG_RESULT([yes])
7031     AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
7032       [Define to 1 if you have the strtoll function.])
7033     ac_cv_func_strtoll="yes"
7034   else
7035     AC_MSG_RESULT([no])
7036     ac_cv_func_strtoll="no"
7037   fi
7038 ])
7039
7040
7041 dnl CURL_CHECK_FUNC_WRITEV
7042 dnl -------------------------------------------------
7043 dnl Verify if writev is available, prototyped, and
7044 dnl can be compiled. If all of these are true, and
7045 dnl usage has not been previously disallowed with
7046 dnl shell variable curl_disallow_writev, then
7047 dnl HAVE_WRITEV will be defined.
7048
7049 AC_DEFUN([CURL_CHECK_FUNC_WRITEV], [
7050   AC_REQUIRE([CURL_INCLUDES_SYS_UIO])dnl
7051   #
7052   tst_links_writev="unknown"
7053   tst_proto_writev="unknown"
7054   tst_compi_writev="unknown"
7055   tst_allow_writev="unknown"
7056   #
7057   AC_MSG_CHECKING([if writev can be linked])
7058   AC_LINK_IFELSE([
7059     AC_LANG_FUNC_LINK_TRY([writev])
7060   ],[
7061     AC_MSG_RESULT([yes])
7062     tst_links_writev="yes"
7063   ],[
7064     AC_MSG_RESULT([no])
7065     tst_links_writev="no"
7066   ])
7067   #
7068   if test "$tst_links_writev" = "yes"; then
7069     AC_MSG_CHECKING([if writev is prototyped])
7070     AC_EGREP_CPP([writev],[
7071       $curl_includes_sys_uio
7072     ],[
7073       AC_MSG_RESULT([yes])
7074       tst_proto_writev="yes"
7075     ],[
7076       AC_MSG_RESULT([no])
7077       tst_proto_writev="no"
7078     ])
7079   fi
7080   #
7081   if test "$tst_proto_writev" = "yes"; then
7082     AC_MSG_CHECKING([if writev is compilable])
7083     AC_COMPILE_IFELSE([
7084       AC_LANG_PROGRAM([[
7085         $curl_includes_sys_uio
7086       ]],[[
7087         if(0 != writev(0, 0, 0))
7088           return 1;
7089       ]])
7090     ],[
7091       AC_MSG_RESULT([yes])
7092       tst_compi_writev="yes"
7093     ],[
7094       AC_MSG_RESULT([no])
7095       tst_compi_writev="no"
7096     ])
7097   fi
7098   #
7099   if test "$tst_compi_writev" = "yes"; then
7100     AC_MSG_CHECKING([if writev usage allowed])
7101     if test "x$curl_disallow_writev" != "xyes"; then
7102       AC_MSG_RESULT([yes])
7103       tst_allow_writev="yes"
7104     else
7105       AC_MSG_RESULT([no])
7106       tst_allow_writev="no"
7107     fi
7108   fi
7109   #
7110   AC_MSG_CHECKING([if writev might be used])
7111   if test "$tst_links_writev" = "yes" &&
7112      test "$tst_proto_writev" = "yes" &&
7113      test "$tst_compi_writev" = "yes" &&
7114      test "$tst_allow_writev" = "yes"; then
7115     AC_MSG_RESULT([yes])
7116     AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
7117       [Define to 1 if you have the writev function.])
7118     ac_cv_func_writev="yes"
7119   else
7120     AC_MSG_RESULT([no])
7121     ac_cv_func_writev="no"
7122   fi
7123 ])