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