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