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