xref: /curl/m4/curl-functions.m4 (revision 78c31729)
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21# SPDX-License-Identifier: curl
22#
23#***************************************************************************
24
25# File version for 'aclocal' use. Keep it a single number.
26# serial 73
27
28
29dnl CURL_INCLUDES_ARPA_INET
30dnl -------------------------------------------------
31dnl Set up variable with list of headers that must be
32dnl included when arpa/inet.h is to be included.
33
34AC_DEFUN([CURL_INCLUDES_ARPA_INET], [
35curl_includes_arpa_inet="\
36/* includes start */
37#ifdef HAVE_SYS_TYPES_H
38#  include <sys/types.h>
39#endif
40#ifdef HAVE_SYS_SOCKET_H
41#  include <sys/socket.h>
42#endif
43#ifdef HAVE_NETINET_IN_H
44#  include <netinet/in.h>
45#endif
46#ifdef HAVE_ARPA_INET_H
47#  include <arpa/inet.h>
48#endif
49#ifdef _WIN32
50#include <winsock2.h>
51#include <ws2tcpip.h>
52#endif
53/* includes end */"
54  AC_CHECK_HEADERS(
55    sys/types.h sys/socket.h netinet/in.h arpa/inet.h,
56    [], [], [$curl_includes_arpa_inet])
57])
58
59
60dnl CURL_INCLUDES_FCNTL
61dnl -------------------------------------------------
62dnl Set up variable with list of headers that must be
63dnl included when fcntl.h is to be included.
64
65AC_DEFUN([CURL_INCLUDES_FCNTL], [
66curl_includes_fcntl="\
67/* includes start */
68#ifdef HAVE_SYS_TYPES_H
69#  include <sys/types.h>
70#endif
71#ifdef HAVE_UNISTD_H
72#  include <unistd.h>
73#endif
74#ifdef HAVE_FCNTL_H
75#  include <fcntl.h>
76#endif
77/* includes end */"
78  AC_CHECK_HEADERS(
79    sys/types.h unistd.h fcntl.h,
80    [], [], [$curl_includes_fcntl])
81])
82
83
84dnl CURL_INCLUDES_IFADDRS
85dnl -------------------------------------------------
86dnl Set up variable with list of headers that must be
87dnl included when ifaddrs.h is to be included.
88
89AC_DEFUN([CURL_INCLUDES_IFADDRS], [
90curl_includes_ifaddrs="\
91/* includes start */
92#ifdef HAVE_SYS_TYPES_H
93#  include <sys/types.h>
94#endif
95#ifdef HAVE_SYS_SOCKET_H
96#  include <sys/socket.h>
97#endif
98#ifdef HAVE_NETINET_IN_H
99#  include <netinet/in.h>
100#endif
101#ifdef HAVE_IFADDRS_H
102#  include <ifaddrs.h>
103#endif
104/* includes end */"
105  AC_CHECK_HEADERS(
106    sys/types.h sys/socket.h netinet/in.h ifaddrs.h,
107    [], [], [$curl_includes_ifaddrs])
108])
109
110
111dnl CURL_INCLUDES_LIBGEN
112dnl -------------------------------------------------
113dnl Set up variable with list of headers that must be
114dnl included when libgen.h is to be included.
115
116AC_DEFUN([CURL_INCLUDES_LIBGEN], [
117curl_includes_libgen="\
118/* includes start */
119#ifdef HAVE_SYS_TYPES_H
120#  include <sys/types.h>
121#endif
122#ifdef HAVE_LIBGEN_H
123#  include <libgen.h>
124#endif
125/* includes end */"
126  AC_CHECK_HEADERS(
127    sys/types.h libgen.h,
128    [], [], [$curl_includes_libgen])
129])
130
131
132dnl CURL_INCLUDES_NETDB
133dnl -------------------------------------------------
134dnl Set up variable with list of headers that must be
135dnl included when netdb.h is to be included.
136
137AC_DEFUN([CURL_INCLUDES_NETDB], [
138curl_includes_netdb="\
139/* includes start */
140#ifdef HAVE_SYS_TYPES_H
141#  include <sys/types.h>
142#endif
143#ifdef HAVE_NETDB_H
144#  include <netdb.h>
145#endif
146/* includes end */"
147  AC_CHECK_HEADERS(
148    sys/types.h netdb.h,
149    [], [], [$curl_includes_netdb])
150])
151
152
153dnl CURL_INCLUDES_SETJMP
154dnl -------------------------------------------------
155dnl Set up variable with list of headers that must be
156dnl included when setjmp.h is to be included.
157
158AC_DEFUN([CURL_INCLUDES_SETJMP], [
159curl_includes_setjmp="\
160/* includes start */
161#ifdef HAVE_SYS_TYPES_H
162#  include <sys/types.h>
163#endif
164#include <setjmp.h>
165/* includes end */"
166  AC_CHECK_HEADERS(
167    sys/types.h,
168    [], [], [$curl_includes_setjmp])
169])
170
171
172dnl CURL_INCLUDES_SIGNAL
173dnl -------------------------------------------------
174dnl Set up variable with list of headers that must be
175dnl included when signal.h is to be included.
176
177AC_DEFUN([CURL_INCLUDES_SIGNAL], [
178curl_includes_signal="\
179/* includes start */
180#ifdef HAVE_SYS_TYPES_H
181#  include <sys/types.h>
182#endif
183#include <signal.h>
184/* includes end */"
185  AC_CHECK_HEADERS(
186    sys/types.h,
187    [], [], [$curl_includes_signal])
188])
189
190
191dnl CURL_INCLUDES_STDLIB
192dnl -------------------------------------------------
193dnl Set up variable with list of headers that must be
194dnl included when stdlib.h is to be included.
195
196AC_DEFUN([CURL_INCLUDES_STDLIB], [
197curl_includes_stdlib="\
198/* includes start */
199#ifdef HAVE_SYS_TYPES_H
200#  include <sys/types.h>
201#endif
202#include <stdlib.h>
203/* includes end */"
204  AC_CHECK_HEADERS(
205    sys/types.h,
206    [], [], [$curl_includes_stdlib])
207])
208
209
210dnl CURL_INCLUDES_STRING
211dnl -------------------------------------------------
212dnl Set up variable with list of headers that must be
213dnl included when string(s).h is to be included.
214
215AC_DEFUN([CURL_INCLUDES_STRING], [
216curl_includes_string="\
217/* includes start */
218#ifdef HAVE_SYS_TYPES_H
219#  include <sys/types.h>
220#endif
221#include <string.h>
222#ifdef HAVE_STRINGS_H
223#  include <strings.h>
224#endif
225/* includes end */"
226  AC_CHECK_HEADERS(
227    sys/types.h strings.h,
228    [], [], [$curl_includes_string])
229])
230
231
232dnl CURL_INCLUDES_STROPTS
233dnl -------------------------------------------------
234dnl Set up variable with list of headers that must be
235dnl included when stropts.h is to be included.
236
237AC_DEFUN([CURL_INCLUDES_STROPTS], [
238curl_includes_stropts="\
239/* includes start */
240#ifdef HAVE_SYS_TYPES_H
241#  include <sys/types.h>
242#endif
243#ifdef HAVE_UNISTD_H
244#  include <unistd.h>
245#endif
246#ifdef HAVE_SYS_SOCKET_H
247#  include <sys/socket.h>
248#endif
249#ifdef HAVE_SYS_IOCTL_H
250#  include <sys/ioctl.h>
251#endif
252#ifdef HAVE_STROPTS_H
253#  include <stropts.h>
254#endif
255/* includes end */"
256  AC_CHECK_HEADERS(
257    sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
258    [], [], [$curl_includes_stropts])
259])
260
261
262dnl CURL_INCLUDES_SYS_SOCKET
263dnl -------------------------------------------------
264dnl Set up variable with list of headers that must be
265dnl included when sys/socket.h is to be included.
266
267AC_DEFUN([CURL_INCLUDES_SYS_SOCKET], [
268curl_includes_sys_socket="\
269/* includes start */
270#ifdef HAVE_SYS_TYPES_H
271#  include <sys/types.h>
272#endif
273#ifdef HAVE_SYS_SOCKET_H
274#  include <sys/socket.h>
275#endif
276/* includes end */"
277  AC_CHECK_HEADERS(
278    sys/types.h sys/socket.h,
279    [], [], [$curl_includes_sys_socket])
280])
281
282
283dnl CURL_INCLUDES_SYS_TYPES
284dnl -------------------------------------------------
285dnl Set up variable with list of headers that must be
286dnl included when sys/types.h is to be included.
287
288AC_DEFUN([CURL_INCLUDES_SYS_TYPES], [
289curl_includes_sys_types="\
290/* includes start */
291#ifdef HAVE_SYS_TYPES_H
292#  include <sys/types.h>
293#endif
294/* includes end */"
295  AC_CHECK_HEADERS(
296    sys/types.h,
297    [], [], [$curl_includes_sys_types])
298])
299
300
301dnl CURL_INCLUDES_SYS_XATTR
302dnl -------------------------------------------------
303dnl Set up variable with list of headers that must be
304dnl included when sys/xattr.h is to be included.
305
306AC_DEFUN([CURL_INCLUDES_SYS_XATTR], [
307curl_includes_sys_xattr="\
308/* includes start */
309#ifdef HAVE_SYS_TYPES_H
310#  include <sys/types.h>
311#endif
312#ifdef HAVE_SYS_XATTR_H
313#  include <sys/xattr.h>
314#endif
315/* includes end */"
316  AC_CHECK_HEADERS(
317    sys/types.h sys/xattr.h,
318    [], [], [$curl_includes_sys_xattr])
319])
320
321dnl CURL_INCLUDES_TIME
322dnl -------------------------------------------------
323dnl Set up variable with list of headers that must be
324dnl included when time.h is to be included.
325
326AC_DEFUN([CURL_INCLUDES_TIME], [
327curl_includes_time="\
328/* includes start */
329#ifdef HAVE_SYS_TYPES_H
330#  include <sys/types.h>
331#endif
332#ifdef HAVE_SYS_TIME_H
333#  include <sys/time.h>
334#endif
335#include <time.h>
336/* includes end */"
337  AC_CHECK_HEADERS(
338    sys/types.h sys/time.h,
339    [], [], [$curl_includes_time])
340])
341
342
343dnl CURL_INCLUDES_UNISTD
344dnl -------------------------------------------------
345dnl Set up variable with list of headers that must be
346dnl included when unistd.h is to be included.
347
348AC_DEFUN([CURL_INCLUDES_UNISTD], [
349curl_includes_unistd="\
350/* includes start */
351#ifdef HAVE_SYS_TYPES_H
352#  include <sys/types.h>
353#endif
354#ifdef HAVE_UNISTD_H
355#  include <unistd.h>
356#endif
357/* includes end */"
358  AC_CHECK_HEADERS(
359    sys/types.h unistd.h,
360    [], [], [$curl_includes_unistd])
361])
362
363
364dnl CURL_INCLUDES_WINSOCK2
365dnl -------------------------------------------------
366dnl Set up variable with list of headers that must be
367dnl included when winsock2.h is to be included.
368
369AC_DEFUN([CURL_INCLUDES_WINSOCK2], [
370curl_includes_winsock2="\
371/* includes start */
372#ifdef _WIN32
373#  ifndef WIN32_LEAN_AND_MEAN
374#    define WIN32_LEAN_AND_MEAN
375#  endif
376#  include <winsock2.h>
377#endif
378/* includes end */"
379  CURL_CHECK_NATIVE_WINDOWS
380])
381
382
383dnl CURL_INCLUDES_WS2TCPIP
384dnl -------------------------------------------------
385dnl Set up variable with list of headers that must be
386dnl included when ws2tcpip.h is to be included.
387
388AC_DEFUN([CURL_INCLUDES_WS2TCPIP], [
389curl_includes_ws2tcpip="\
390/* includes start */
391#ifdef _WIN32
392#  ifndef WIN32_LEAN_AND_MEAN
393#    define WIN32_LEAN_AND_MEAN
394#  endif
395#  include <winsock2.h>
396#  include <ws2tcpip.h>
397#endif
398/* includes end */"
399  CURL_CHECK_NATIVE_WINDOWS
400])
401
402
403dnl CURL_INCLUDES_BSDSOCKET
404dnl -------------------------------------------------
405dnl Set up variable with list of headers that must be
406dnl included when bsdsocket.h is to be included.
407
408AC_DEFUN([CURL_INCLUDES_BSDSOCKET], [
409curl_includes_bsdsocket="\
410/* includes start */
411#if defined(HAVE_PROTO_BSDSOCKET_H)
412#  define __NO_NET_API
413#  define __USE_INLINE__
414#  include <proto/bsdsocket.h>
415#  ifdef HAVE_SYS_IOCTL_H
416#    include <sys/ioctl.h>
417#  endif
418#  ifdef __amigaos4__
419struct SocketIFace *ISocket = NULL;
420#  else
421struct Library *SocketBase = NULL;
422#  endif
423#  define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
424#endif
425/* includes end */"
426  AC_CHECK_HEADERS(
427    proto/bsdsocket.h,
428    [], [], [$curl_includes_bsdsocket])
429])
430
431dnl CURL_INCLUDES_NETIF
432dnl -------------------------------------------------
433dnl Set up variable with list of headers that must be
434dnl included when net/if.h is to be included.
435
436AC_DEFUN([CURL_INCLUDES_NETIF], [
437curl_includes_netif="\
438/* includes start */
439#ifdef HAVE_NET_IF_H
440#  include <net/if.h>
441#endif
442/* includes end */"
443  AC_CHECK_HEADERS(
444    net/if.h,
445    [], [], [$curl_includes_netif])
446])
447
448
449dnl CURL_PREPROCESS_CALLCONV
450dnl -------------------------------------------------
451dnl Set up variable with a preprocessor block which
452dnl defines function calling convention.
453
454AC_DEFUN([CURL_PREPROCESS_CALLCONV], [
455curl_preprocess_callconv="\
456/* preprocess start */
457#ifdef _WIN32
458#  define FUNCALLCONV __stdcall
459#else
460#  define FUNCALLCONV
461#endif
462/* preprocess end */"
463])
464
465
466dnl CURL_CHECK_FUNC_ALARM
467dnl -------------------------------------------------
468dnl Verify if alarm is available, prototyped, and
469dnl can be compiled. If all of these are true, and
470dnl usage has not been previously disallowed with
471dnl shell variable curl_disallow_alarm, then
472dnl HAVE_ALARM will be defined.
473
474AC_DEFUN([CURL_CHECK_FUNC_ALARM], [
475  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
476  #
477  tst_links_alarm="unknown"
478  tst_proto_alarm="unknown"
479  tst_compi_alarm="unknown"
480  tst_allow_alarm="unknown"
481  #
482  AC_MSG_CHECKING([if alarm can be linked])
483  AC_LINK_IFELSE([
484    AC_LANG_FUNC_LINK_TRY([alarm])
485  ],[
486    AC_MSG_RESULT([yes])
487    tst_links_alarm="yes"
488  ],[
489    AC_MSG_RESULT([no])
490    tst_links_alarm="no"
491  ])
492  #
493  if test "$tst_links_alarm" = "yes"; then
494    AC_MSG_CHECKING([if alarm is prototyped])
495    AC_EGREP_CPP([alarm],[
496      $curl_includes_unistd
497    ],[
498      AC_MSG_RESULT([yes])
499      tst_proto_alarm="yes"
500    ],[
501      AC_MSG_RESULT([no])
502      tst_proto_alarm="no"
503    ])
504  fi
505  #
506  if test "$tst_proto_alarm" = "yes"; then
507    AC_MSG_CHECKING([if alarm is compilable])
508    AC_COMPILE_IFELSE([
509      AC_LANG_PROGRAM([[
510        $curl_includes_unistd
511      ]],[[
512        if(0 != alarm(0))
513          return 1;
514      ]])
515    ],[
516      AC_MSG_RESULT([yes])
517      tst_compi_alarm="yes"
518    ],[
519      AC_MSG_RESULT([no])
520      tst_compi_alarm="no"
521    ])
522  fi
523  #
524  if test "$tst_compi_alarm" = "yes"; then
525    AC_MSG_CHECKING([if alarm usage allowed])
526    if test "x$curl_disallow_alarm" != "xyes"; then
527      AC_MSG_RESULT([yes])
528      tst_allow_alarm="yes"
529    else
530      AC_MSG_RESULT([no])
531      tst_allow_alarm="no"
532    fi
533  fi
534  #
535  AC_MSG_CHECKING([if alarm might be used])
536  if test "$tst_links_alarm" = "yes" &&
537     test "$tst_proto_alarm" = "yes" &&
538     test "$tst_compi_alarm" = "yes" &&
539     test "$tst_allow_alarm" = "yes"; then
540    AC_MSG_RESULT([yes])
541    AC_DEFINE_UNQUOTED(HAVE_ALARM, 1,
542      [Define to 1 if you have the alarm function.])
543    curl_cv_func_alarm="yes"
544  else
545    AC_MSG_RESULT([no])
546    curl_cv_func_alarm="no"
547  fi
548])
549
550
551dnl CURL_CHECK_FUNC_BASENAME
552dnl -------------------------------------------------
553dnl Verify if basename is available, prototyped, and
554dnl can be compiled. If all of these are true, and
555dnl usage has not been previously disallowed with
556dnl shell variable curl_disallow_basename, then
557dnl HAVE_BASENAME will be defined.
558
559AC_DEFUN([CURL_CHECK_FUNC_BASENAME], [
560  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
561  AC_REQUIRE([CURL_INCLUDES_LIBGEN])dnl
562  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
563  #
564  tst_links_basename="unknown"
565  tst_proto_basename="unknown"
566  tst_compi_basename="unknown"
567  tst_allow_basename="unknown"
568  #
569  AC_MSG_CHECKING([if basename can be linked])
570  AC_LINK_IFELSE([
571    AC_LANG_FUNC_LINK_TRY([basename])
572  ],[
573    AC_MSG_RESULT([yes])
574    tst_links_basename="yes"
575  ],[
576    AC_MSG_RESULT([no])
577    tst_links_basename="no"
578  ])
579  #
580  if test "$tst_links_basename" = "yes"; then
581    AC_MSG_CHECKING([if basename is prototyped])
582    AC_EGREP_CPP([basename],[
583      $curl_includes_string
584      $curl_includes_libgen
585      $curl_includes_unistd
586    ],[
587      AC_MSG_RESULT([yes])
588      tst_proto_basename="yes"
589    ],[
590      AC_MSG_RESULT([no])
591      tst_proto_basename="no"
592    ])
593  fi
594  #
595  if test "$tst_proto_basename" = "yes"; then
596    AC_MSG_CHECKING([if basename is compilable])
597    AC_COMPILE_IFELSE([
598      AC_LANG_PROGRAM([[
599        $curl_includes_string
600        $curl_includes_libgen
601        $curl_includes_unistd
602      ]],[[
603        if(0 != basename(0))
604          return 1;
605      ]])
606    ],[
607      AC_MSG_RESULT([yes])
608      tst_compi_basename="yes"
609    ],[
610      AC_MSG_RESULT([no])
611      tst_compi_basename="no"
612    ])
613  fi
614  #
615  if test "$tst_compi_basename" = "yes"; then
616    AC_MSG_CHECKING([if basename usage allowed])
617    if test "x$curl_disallow_basename" != "xyes"; then
618      AC_MSG_RESULT([yes])
619      tst_allow_basename="yes"
620    else
621      AC_MSG_RESULT([no])
622      tst_allow_basename="no"
623    fi
624  fi
625  #
626  AC_MSG_CHECKING([if basename might be used])
627  if test "$tst_links_basename" = "yes" &&
628     test "$tst_proto_basename" = "yes" &&
629     test "$tst_compi_basename" = "yes" &&
630     test "$tst_allow_basename" = "yes"; then
631    AC_MSG_RESULT([yes])
632    AC_DEFINE_UNQUOTED(HAVE_BASENAME, 1,
633      [Define to 1 if you have the basename function.])
634    curl_cv_func_basename="yes"
635  else
636    AC_MSG_RESULT([no])
637    curl_cv_func_basename="no"
638  fi
639])
640
641
642dnl CURL_CHECK_FUNC_CLOSESOCKET
643dnl -------------------------------------------------
644dnl Verify if closesocket is available, prototyped, and
645dnl can be compiled. If all of these are true, and
646dnl usage has not been previously disallowed with
647dnl shell variable curl_disallow_closesocket, then
648dnl HAVE_CLOSESOCKET will be defined.
649
650AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET], [
651  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
652  #
653  tst_links_closesocket="unknown"
654  tst_proto_closesocket="unknown"
655  tst_compi_closesocket="unknown"
656  tst_allow_closesocket="unknown"
657  #
658  AC_MSG_CHECKING([if closesocket can be linked])
659  AC_LINK_IFELSE([
660    AC_LANG_PROGRAM([[
661      $curl_includes_winsock2
662    ]],[[
663      if(0 != closesocket(0))
664        return 1;
665    ]])
666  ],[
667    AC_MSG_RESULT([yes])
668    tst_links_closesocket="yes"
669  ],[
670    AC_MSG_RESULT([no])
671    tst_links_closesocket="no"
672  ])
673  #
674  if test "$tst_links_closesocket" = "yes"; then
675    AC_MSG_CHECKING([if closesocket is prototyped])
676    AC_EGREP_CPP([closesocket],[
677      $curl_includes_winsock2
678    ],[
679      AC_MSG_RESULT([yes])
680      tst_proto_closesocket="yes"
681    ],[
682      AC_MSG_RESULT([no])
683      tst_proto_closesocket="no"
684    ])
685  fi
686  #
687  if test "$tst_proto_closesocket" = "yes"; then
688    AC_MSG_CHECKING([if closesocket is compilable])
689    AC_COMPILE_IFELSE([
690      AC_LANG_PROGRAM([[
691        $curl_includes_winsock2
692      ]],[[
693        if(0 != closesocket(0))
694          return 1;
695      ]])
696    ],[
697      AC_MSG_RESULT([yes])
698      tst_compi_closesocket="yes"
699    ],[
700      AC_MSG_RESULT([no])
701      tst_compi_closesocket="no"
702    ])
703  fi
704  #
705  if test "$tst_compi_closesocket" = "yes"; then
706    AC_MSG_CHECKING([if closesocket usage allowed])
707    if test "x$curl_disallow_closesocket" != "xyes"; then
708      AC_MSG_RESULT([yes])
709      tst_allow_closesocket="yes"
710    else
711      AC_MSG_RESULT([no])
712      tst_allow_closesocket="no"
713    fi
714  fi
715  #
716  AC_MSG_CHECKING([if closesocket might be used])
717  if test "$tst_links_closesocket" = "yes" &&
718     test "$tst_proto_closesocket" = "yes" &&
719     test "$tst_compi_closesocket" = "yes" &&
720     test "$tst_allow_closesocket" = "yes"; then
721    AC_MSG_RESULT([yes])
722    AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET, 1,
723      [Define to 1 if you have the closesocket function.])
724    curl_cv_func_closesocket="yes"
725  else
726    AC_MSG_RESULT([no])
727    curl_cv_func_closesocket="no"
728  fi
729])
730
731
732dnl CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
733dnl -------------------------------------------------
734dnl Verify if CloseSocket is available, prototyped, and
735dnl can be compiled. If all of these are true, and
736dnl usage has not been previously disallowed with
737dnl shell variable curl_disallow_closesocket_camel,
738dnl then HAVE_CLOSESOCKET_CAMEL will be defined.
739
740AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [
741  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
742  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
743  #
744  tst_links_closesocket_camel="unknown"
745  tst_proto_closesocket_camel="unknown"
746  tst_compi_closesocket_camel="unknown"
747  tst_allow_closesocket_camel="unknown"
748  #
749  AC_MSG_CHECKING([if CloseSocket can be linked])
750  AC_LINK_IFELSE([
751    AC_LANG_PROGRAM([[
752      $curl_includes_bsdsocket
753      $curl_includes_sys_socket
754    ]],[[
755      if(0 != CloseSocket(0))
756        return 1;
757    ]])
758  ],[
759    AC_MSG_RESULT([yes])
760    tst_links_closesocket_camel="yes"
761  ],[
762    AC_MSG_RESULT([no])
763    tst_links_closesocket_camel="no"
764  ])
765  #
766  if test "$tst_links_closesocket_camel" = "yes"; then
767    AC_MSG_CHECKING([if CloseSocket is prototyped])
768    AC_EGREP_CPP([CloseSocket],[
769      $curl_includes_bsdsocket
770      $curl_includes_sys_socket
771    ],[
772      AC_MSG_RESULT([yes])
773      tst_proto_closesocket_camel="yes"
774    ],[
775      AC_MSG_RESULT([no])
776      tst_proto_closesocket_camel="no"
777    ])
778  fi
779  #
780  if test "$tst_proto_closesocket_camel" = "yes"; then
781    AC_MSG_CHECKING([if CloseSocket is compilable])
782    AC_COMPILE_IFELSE([
783      AC_LANG_PROGRAM([[
784        $curl_includes_bsdsocket
785        $curl_includes_sys_socket
786      ]],[[
787        if(0 != CloseSocket(0))
788          return 1;
789      ]])
790    ],[
791      AC_MSG_RESULT([yes])
792      tst_compi_closesocket_camel="yes"
793    ],[
794      AC_MSG_RESULT([no])
795      tst_compi_closesocket_camel="no"
796    ])
797  fi
798  #
799  if test "$tst_compi_closesocket_camel" = "yes"; then
800    AC_MSG_CHECKING([if CloseSocket usage allowed])
801    if test "x$curl_disallow_closesocket_camel" != "xyes"; then
802      AC_MSG_RESULT([yes])
803      tst_allow_closesocket_camel="yes"
804    else
805      AC_MSG_RESULT([no])
806      tst_allow_closesocket_camel="no"
807    fi
808  fi
809  #
810  AC_MSG_CHECKING([if CloseSocket might be used])
811  if test "$tst_links_closesocket_camel" = "yes" &&
812     test "$tst_proto_closesocket_camel" = "yes" &&
813     test "$tst_compi_closesocket_camel" = "yes" &&
814     test "$tst_allow_closesocket_camel" = "yes"; then
815    AC_MSG_RESULT([yes])
816    AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET_CAMEL, 1,
817      [Define to 1 if you have the CloseSocket camel case function.])
818    curl_cv_func_closesocket_camel="yes"
819  else
820    AC_MSG_RESULT([no])
821    curl_cv_func_closesocket_camel="no"
822  fi
823])
824
825dnl CURL_CHECK_FUNC_FCNTL
826dnl -------------------------------------------------
827dnl Verify if fcntl is available, prototyped, and
828dnl can be compiled. If all of these are true, and
829dnl usage has not been previously disallowed with
830dnl shell variable curl_disallow_fcntl, then
831dnl HAVE_FCNTL will be defined.
832
833AC_DEFUN([CURL_CHECK_FUNC_FCNTL], [
834  AC_REQUIRE([CURL_INCLUDES_FCNTL])dnl
835  #
836  tst_links_fcntl="unknown"
837  tst_proto_fcntl="unknown"
838  tst_compi_fcntl="unknown"
839  tst_allow_fcntl="unknown"
840  #
841  AC_MSG_CHECKING([if fcntl can be linked])
842  AC_LINK_IFELSE([
843    AC_LANG_FUNC_LINK_TRY([fcntl])
844  ],[
845    AC_MSG_RESULT([yes])
846    tst_links_fcntl="yes"
847  ],[
848    AC_MSG_RESULT([no])
849    tst_links_fcntl="no"
850  ])
851  #
852  if test "$tst_links_fcntl" = "yes"; then
853    AC_MSG_CHECKING([if fcntl is prototyped])
854    AC_EGREP_CPP([fcntl],[
855      $curl_includes_fcntl
856    ],[
857      AC_MSG_RESULT([yes])
858      tst_proto_fcntl="yes"
859    ],[
860      AC_MSG_RESULT([no])
861      tst_proto_fcntl="no"
862    ])
863  fi
864  #
865  if test "$tst_proto_fcntl" = "yes"; then
866    AC_MSG_CHECKING([if fcntl is compilable])
867    AC_COMPILE_IFELSE([
868      AC_LANG_PROGRAM([[
869        $curl_includes_fcntl
870      ]],[[
871        if(0 != fcntl(0, 0, 0))
872          return 1;
873      ]])
874    ],[
875      AC_MSG_RESULT([yes])
876      tst_compi_fcntl="yes"
877    ],[
878      AC_MSG_RESULT([no])
879      tst_compi_fcntl="no"
880    ])
881  fi
882  #
883  if test "$tst_compi_fcntl" = "yes"; then
884    AC_MSG_CHECKING([if fcntl usage allowed])
885    if test "x$curl_disallow_fcntl" != "xyes"; then
886      AC_MSG_RESULT([yes])
887      tst_allow_fcntl="yes"
888    else
889      AC_MSG_RESULT([no])
890      tst_allow_fcntl="no"
891    fi
892  fi
893  #
894  AC_MSG_CHECKING([if fcntl might be used])
895  if test "$tst_links_fcntl" = "yes" &&
896     test "$tst_proto_fcntl" = "yes" &&
897     test "$tst_compi_fcntl" = "yes" &&
898     test "$tst_allow_fcntl" = "yes"; then
899    AC_MSG_RESULT([yes])
900    AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
901      [Define to 1 if you have the fcntl function.])
902    curl_cv_func_fcntl="yes"
903    CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
904  else
905    AC_MSG_RESULT([no])
906    curl_cv_func_fcntl="no"
907  fi
908])
909
910
911dnl CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
912dnl -------------------------------------------------
913dnl Verify if fcntl with status flag O_NONBLOCK is
914dnl available, can be compiled, and seems to work. If
915dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
916dnl will be defined.
917
918AC_DEFUN([CURL_CHECK_FUNC_FCNTL_O_NONBLOCK], [
919  #
920  tst_compi_fcntl_o_nonblock="unknown"
921  tst_allow_fcntl_o_nonblock="unknown"
922  #
923  case $host_os in
924    sunos4* | aix3*)
925      dnl O_NONBLOCK does not work on these platforms
926      curl_disallow_fcntl_o_nonblock="yes"
927      ;;
928  esac
929  #
930  if test "$curl_cv_func_fcntl" = "yes"; then
931    AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
932    AC_COMPILE_IFELSE([
933      AC_LANG_PROGRAM([[
934        $curl_includes_fcntl
935      ]],[[
936        int flags = 0;
937        if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
938          return 1;
939      ]])
940    ],[
941      AC_MSG_RESULT([yes])
942      tst_compi_fcntl_o_nonblock="yes"
943    ],[
944      AC_MSG_RESULT([no])
945      tst_compi_fcntl_o_nonblock="no"
946    ])
947  fi
948  #
949  if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
950    AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
951    if test "x$curl_disallow_fcntl_o_nonblock" != "xyes"; then
952      AC_MSG_RESULT([yes])
953      tst_allow_fcntl_o_nonblock="yes"
954    else
955      AC_MSG_RESULT([no])
956      tst_allow_fcntl_o_nonblock="no"
957    fi
958  fi
959  #
960  AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
961  if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
962     test "$tst_allow_fcntl_o_nonblock" = "yes"; then
963    AC_MSG_RESULT([yes])
964    AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
965      [Define to 1 if you have a working fcntl O_NONBLOCK function.])
966    curl_cv_func_fcntl_o_nonblock="yes"
967  else
968    AC_MSG_RESULT([no])
969    curl_cv_func_fcntl_o_nonblock="no"
970  fi
971])
972
973
974dnl CURL_CHECK_FUNC_FREEADDRINFO
975dnl -------------------------------------------------
976dnl Verify if freeaddrinfo is available, prototyped,
977dnl and can be compiled. If all of these are true,
978dnl and usage has not been previously disallowed with
979dnl shell variable curl_disallow_freeaddrinfo, then
980dnl HAVE_FREEADDRINFO will be defined.
981
982AC_DEFUN([CURL_CHECK_FUNC_FREEADDRINFO], [
983  AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
984  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
985  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
986  #
987  tst_links_freeaddrinfo="unknown"
988  tst_proto_freeaddrinfo="unknown"
989  tst_compi_freeaddrinfo="unknown"
990  tst_allow_freeaddrinfo="unknown"
991  #
992  AC_MSG_CHECKING([if freeaddrinfo can be linked])
993  AC_LINK_IFELSE([
994    AC_LANG_PROGRAM([[
995      $curl_includes_ws2tcpip
996      $curl_includes_sys_socket
997      $curl_includes_netdb
998    ]],[[
999      freeaddrinfo(0);
1000    ]])
1001  ],[
1002    AC_MSG_RESULT([yes])
1003    tst_links_freeaddrinfo="yes"
1004  ],[
1005    AC_MSG_RESULT([no])
1006    tst_links_freeaddrinfo="no"
1007  ])
1008  #
1009  if test "$tst_links_freeaddrinfo" = "yes"; then
1010    AC_MSG_CHECKING([if freeaddrinfo is prototyped])
1011    AC_EGREP_CPP([freeaddrinfo],[
1012      $curl_includes_ws2tcpip
1013      $curl_includes_sys_socket
1014      $curl_includes_netdb
1015    ],[
1016      AC_MSG_RESULT([yes])
1017      tst_proto_freeaddrinfo="yes"
1018    ],[
1019      AC_MSG_RESULT([no])
1020      tst_proto_freeaddrinfo="no"
1021    ])
1022  fi
1023  #
1024  if test "$tst_proto_freeaddrinfo" = "yes"; then
1025    AC_MSG_CHECKING([if freeaddrinfo is compilable])
1026    AC_COMPILE_IFELSE([
1027      AC_LANG_PROGRAM([[
1028        $curl_includes_ws2tcpip
1029        $curl_includes_sys_socket
1030        $curl_includes_netdb
1031      ]],[[
1032        freeaddrinfo(0);
1033      ]])
1034    ],[
1035      AC_MSG_RESULT([yes])
1036      tst_compi_freeaddrinfo="yes"
1037    ],[
1038      AC_MSG_RESULT([no])
1039      tst_compi_freeaddrinfo="no"
1040    ])
1041  fi
1042  #
1043  if test "$tst_compi_freeaddrinfo" = "yes"; then
1044    AC_MSG_CHECKING([if freeaddrinfo usage allowed])
1045    if test "x$curl_disallow_freeaddrinfo" != "xyes"; then
1046      AC_MSG_RESULT([yes])
1047      tst_allow_freeaddrinfo="yes"
1048    else
1049      AC_MSG_RESULT([no])
1050      tst_allow_freeaddrinfo="no"
1051    fi
1052  fi
1053  #
1054  AC_MSG_CHECKING([if freeaddrinfo might be used])
1055  if test "$tst_links_freeaddrinfo" = "yes" &&
1056     test "$tst_proto_freeaddrinfo" = "yes" &&
1057     test "$tst_compi_freeaddrinfo" = "yes" &&
1058     test "$tst_allow_freeaddrinfo" = "yes"; then
1059    AC_MSG_RESULT([yes])
1060    AC_DEFINE_UNQUOTED(HAVE_FREEADDRINFO, 1,
1061      [Define to 1 if you have the freeaddrinfo function.])
1062    curl_cv_func_freeaddrinfo="yes"
1063  else
1064    AC_MSG_RESULT([no])
1065    curl_cv_func_freeaddrinfo="no"
1066  fi
1067])
1068
1069
1070dnl CURL_CHECK_FUNC_FSETXATTR
1071dnl -------------------------------------------------
1072dnl Verify if fsetxattr is available, prototyped, and
1073dnl can be compiled. If all of these are true, and
1074dnl usage has not been previously disallowed with
1075dnl shell variable curl_disallow_fsetxattr, then
1076dnl HAVE_FSETXATTR will be defined.
1077
1078AC_DEFUN([CURL_CHECK_FUNC_FSETXATTR], [
1079  AC_REQUIRE([CURL_INCLUDES_SYS_XATTR])dnl
1080  #
1081  tst_links_fsetxattr="unknown"
1082  tst_proto_fsetxattr="unknown"
1083  tst_compi_fsetxattr="unknown"
1084  tst_allow_fsetxattr="unknown"
1085  tst_nargs_fsetxattr="unknown"
1086  #
1087  AC_MSG_CHECKING([if fsetxattr can be linked])
1088  AC_LINK_IFELSE([
1089    AC_LANG_FUNC_LINK_TRY([fsetxattr])
1090  ],[
1091    AC_MSG_RESULT([yes])
1092    tst_links_fsetxattr="yes"
1093  ],[
1094    AC_MSG_RESULT([no])
1095    tst_links_fsetxattr="no"
1096  ])
1097  #
1098  if test "$tst_links_fsetxattr" = "yes"; then
1099    AC_MSG_CHECKING([if fsetxattr is prototyped])
1100    AC_EGREP_CPP([fsetxattr],[
1101      $curl_includes_sys_xattr
1102    ],[
1103      AC_MSG_RESULT([yes])
1104      tst_proto_fsetxattr="yes"
1105    ],[
1106      AC_MSG_RESULT([no])
1107      tst_proto_fsetxattr="no"
1108    ])
1109  fi
1110  #
1111  if test "$tst_proto_fsetxattr" = "yes"; then
1112    if test "$tst_nargs_fsetxattr" = "unknown"; then
1113      AC_MSG_CHECKING([if fsetxattr takes 5 args.])
1114      AC_COMPILE_IFELSE([
1115        AC_LANG_PROGRAM([[
1116          $curl_includes_sys_xattr
1117        ]],[[
1118          if(0 != fsetxattr(0, 0, 0, 0, 0))
1119            return 1;
1120        ]])
1121      ],[
1122        AC_MSG_RESULT([yes])
1123        tst_compi_fsetxattr="yes"
1124        tst_nargs_fsetxattr="5"
1125      ],[
1126        AC_MSG_RESULT([no])
1127        tst_compi_fsetxattr="no"
1128      ])
1129    fi
1130    if test "$tst_nargs_fsetxattr" = "unknown"; then
1131      AC_MSG_CHECKING([if fsetxattr takes 6 args.])
1132      AC_COMPILE_IFELSE([
1133        AC_LANG_PROGRAM([[
1134          $curl_includes_sys_xattr
1135        ]],[[
1136          if(0 != fsetxattr(0, 0, 0, 0, 0, 0))
1137            return 1;
1138        ]])
1139      ],[
1140        AC_MSG_RESULT([yes])
1141        tst_compi_fsetxattr="yes"
1142        tst_nargs_fsetxattr="6"
1143      ],[
1144        AC_MSG_RESULT([no])
1145        tst_compi_fsetxattr="no"
1146      ])
1147    fi
1148    AC_MSG_CHECKING([if fsetxattr is compilable])
1149    if test "$tst_compi_fsetxattr" = "yes"; then
1150      AC_MSG_RESULT([yes])
1151    else
1152      AC_MSG_RESULT([no])
1153    fi
1154  fi
1155  #
1156  if test "$tst_compi_fsetxattr" = "yes"; then
1157    AC_MSG_CHECKING([if fsetxattr usage allowed])
1158    if test "x$curl_disallow_fsetxattr" != "xyes"; then
1159      AC_MSG_RESULT([yes])
1160      tst_allow_fsetxattr="yes"
1161    else
1162      AC_MSG_RESULT([no])
1163      tst_allow_fsetxattr="no"
1164    fi
1165  fi
1166  #
1167  AC_MSG_CHECKING([if fsetxattr might be used])
1168  if test "$tst_links_fsetxattr" = "yes" &&
1169     test "$tst_proto_fsetxattr" = "yes" &&
1170     test "$tst_compi_fsetxattr" = "yes" &&
1171     test "$tst_allow_fsetxattr" = "yes"; then
1172    AC_MSG_RESULT([yes])
1173    AC_DEFINE_UNQUOTED(HAVE_FSETXATTR, 1,
1174      [Define to 1 if you have the fsetxattr function.])
1175    dnl AC_DEFINE_UNQUOTED(FSETXATTR_ARGS, $tst_nargs_fsetxattr,
1176    dnl   [Specifies the number of arguments to fsetxattr])
1177    #
1178    if test "$tst_nargs_fsetxattr" -eq "5"; then
1179      AC_DEFINE(HAVE_FSETXATTR_5, 1, [fsetxattr() takes 5 args])
1180    elif test "$tst_nargs_fsetxattr" -eq "6"; then
1181      AC_DEFINE(HAVE_FSETXATTR_6, 1, [fsetxattr() takes 6 args])
1182    fi
1183    #
1184    curl_cv_func_fsetxattr="yes"
1185  else
1186    AC_MSG_RESULT([no])
1187    curl_cv_func_fsetxattr="no"
1188  fi
1189])
1190
1191
1192dnl CURL_CHECK_FUNC_FTRUNCATE
1193dnl -------------------------------------------------
1194dnl Verify if ftruncate is available, prototyped, and
1195dnl can be compiled. If all of these are true, and
1196dnl usage has not been previously disallowed with
1197dnl shell variable curl_disallow_ftruncate, then
1198dnl HAVE_FTRUNCATE will be defined.
1199
1200AC_DEFUN([CURL_CHECK_FUNC_FTRUNCATE], [
1201  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
1202  #
1203  tst_links_ftruncate="unknown"
1204  tst_proto_ftruncate="unknown"
1205  tst_compi_ftruncate="unknown"
1206  tst_allow_ftruncate="unknown"
1207  #
1208  AC_MSG_CHECKING([if ftruncate can be linked])
1209  AC_LINK_IFELSE([
1210    AC_LANG_FUNC_LINK_TRY([ftruncate])
1211  ],[
1212    AC_MSG_RESULT([yes])
1213    tst_links_ftruncate="yes"
1214  ],[
1215    AC_MSG_RESULT([no])
1216    tst_links_ftruncate="no"
1217  ])
1218  #
1219  if test "$tst_links_ftruncate" = "yes"; then
1220    AC_MSG_CHECKING([if ftruncate is prototyped])
1221    AC_EGREP_CPP([ftruncate],[
1222      $curl_includes_unistd
1223    ],[
1224      AC_MSG_RESULT([yes])
1225      tst_proto_ftruncate="yes"
1226    ],[
1227      AC_MSG_RESULT([no])
1228      tst_proto_ftruncate="no"
1229    ])
1230  fi
1231  #
1232  if test "$tst_proto_ftruncate" = "yes"; then
1233    AC_MSG_CHECKING([if ftruncate is compilable])
1234    AC_COMPILE_IFELSE([
1235      AC_LANG_PROGRAM([[
1236        $curl_includes_unistd
1237      ]],[[
1238        if(0 != ftruncate(0, 0))
1239          return 1;
1240      ]])
1241    ],[
1242      AC_MSG_RESULT([yes])
1243      tst_compi_ftruncate="yes"
1244    ],[
1245      AC_MSG_RESULT([no])
1246      tst_compi_ftruncate="no"
1247    ])
1248  fi
1249  #
1250  if test "$tst_compi_ftruncate" = "yes"; then
1251    AC_MSG_CHECKING([if ftruncate usage allowed])
1252    if test "x$curl_disallow_ftruncate" != "xyes"; then
1253      AC_MSG_RESULT([yes])
1254      tst_allow_ftruncate="yes"
1255    else
1256      AC_MSG_RESULT([no])
1257      tst_allow_ftruncate="no"
1258    fi
1259  fi
1260  #
1261  AC_MSG_CHECKING([if ftruncate might be used])
1262  if test "$tst_links_ftruncate" = "yes" &&
1263     test "$tst_proto_ftruncate" = "yes" &&
1264     test "$tst_compi_ftruncate" = "yes" &&
1265     test "$tst_allow_ftruncate" = "yes"; then
1266    AC_MSG_RESULT([yes])
1267    AC_DEFINE_UNQUOTED(HAVE_FTRUNCATE, 1,
1268      [Define to 1 if you have the ftruncate function.])
1269    curl_cv_func_ftruncate="yes"
1270  else
1271    AC_MSG_RESULT([no])
1272    curl_cv_func_ftruncate="no"
1273  fi
1274])
1275
1276
1277dnl CURL_CHECK_FUNC_GETADDRINFO
1278dnl -------------------------------------------------
1279dnl Verify if getaddrinfo is available, prototyped, can
1280dnl be compiled and seems to work. If all of these are
1281dnl true, and usage has not been previously disallowed
1282dnl with shell variable curl_disallow_getaddrinfo, then
1283dnl HAVE_GETADDRINFO will be defined. Additionally when
1284dnl HAVE_GETADDRINFO gets defined this will also attempt
1285dnl to find out if getaddrinfo happens to be threadsafe,
1286dnl defining HAVE_GETADDRINFO_THREADSAFE when true.
1287
1288AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
1289  AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
1290  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
1291  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1292  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
1293  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1294  AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
1295  #
1296  tst_links_getaddrinfo="unknown"
1297  tst_proto_getaddrinfo="unknown"
1298  tst_compi_getaddrinfo="unknown"
1299  tst_works_getaddrinfo="unknown"
1300  tst_allow_getaddrinfo="unknown"
1301  tst_tsafe_getaddrinfo="unknown"
1302  #
1303  AC_MSG_CHECKING([if getaddrinfo can be linked])
1304  AC_LINK_IFELSE([
1305    AC_LANG_PROGRAM([[
1306      $curl_includes_ws2tcpip
1307      $curl_includes_sys_socket
1308      $curl_includes_netdb
1309    ]],[[
1310      if(0 != getaddrinfo(0, 0, 0, 0))
1311        return 1;
1312    ]])
1313  ],[
1314    AC_MSG_RESULT([yes])
1315    tst_links_getaddrinfo="yes"
1316  ],[
1317    AC_MSG_RESULT([no])
1318    tst_links_getaddrinfo="no"
1319  ])
1320  #
1321  if test "$tst_links_getaddrinfo" = "yes"; then
1322    AC_MSG_CHECKING([if getaddrinfo is prototyped])
1323    AC_EGREP_CPP([getaddrinfo],[
1324      $curl_includes_ws2tcpip
1325      $curl_includes_sys_socket
1326      $curl_includes_netdb
1327    ],[
1328      AC_MSG_RESULT([yes])
1329      tst_proto_getaddrinfo="yes"
1330    ],[
1331      AC_MSG_RESULT([no])
1332      tst_proto_getaddrinfo="no"
1333    ])
1334  fi
1335  #
1336  if test "$tst_proto_getaddrinfo" = "yes"; then
1337    AC_MSG_CHECKING([if getaddrinfo is compilable])
1338    AC_COMPILE_IFELSE([
1339      AC_LANG_PROGRAM([[
1340        $curl_includes_ws2tcpip
1341        $curl_includes_sys_socket
1342        $curl_includes_netdb
1343      ]],[[
1344        if(0 != getaddrinfo(0, 0, 0, 0))
1345          return 1;
1346      ]])
1347    ],[
1348      AC_MSG_RESULT([yes])
1349      tst_compi_getaddrinfo="yes"
1350    ],[
1351      AC_MSG_RESULT([no])
1352      tst_compi_getaddrinfo="no"
1353    ])
1354  fi
1355  #
1356  dnl only do runtime verification when not cross-compiling
1357  if test "x$cross_compiling" != "xyes" &&
1358    test "$tst_compi_getaddrinfo" = "yes"; then
1359    AC_MSG_CHECKING([if getaddrinfo seems to work])
1360    CURL_RUN_IFELSE([
1361      AC_LANG_PROGRAM([[
1362        $curl_includes_ws2tcpip
1363        $curl_includes_stdlib
1364        $curl_includes_string
1365        $curl_includes_sys_socket
1366        $curl_includes_netdb
1367      ]],[[
1368        struct addrinfo hints;
1369        struct addrinfo *ai = 0;
1370        int error;
1371
1372        #ifdef _WIN32
1373        WSADATA wsa;
1374        if(WSAStartup(MAKEWORD(2, 2), &wsa))
1375          exit(2);
1376        #endif
1377
1378        memset(&hints, 0, sizeof(hints));
1379        hints.ai_flags = AI_NUMERICHOST;
1380        hints.ai_family = AF_UNSPEC;
1381        hints.ai_socktype = SOCK_STREAM;
1382        error = getaddrinfo("127.0.0.1", 0, &hints, &ai);
1383        if(error || !ai)
1384          exit(1); /* fail */
1385        else
1386          exit(0);
1387      ]])
1388    ],[
1389      AC_MSG_RESULT([yes])
1390      tst_works_getaddrinfo="yes"
1391    ],[
1392      AC_MSG_RESULT([no])
1393      tst_works_getaddrinfo="no"
1394    ])
1395  fi
1396  #
1397  if test "$tst_compi_getaddrinfo" = "yes" &&
1398    test "$tst_works_getaddrinfo" != "no"; then
1399    AC_MSG_CHECKING([if getaddrinfo usage allowed])
1400    if test "x$curl_disallow_getaddrinfo" != "xyes"; then
1401      AC_MSG_RESULT([yes])
1402      tst_allow_getaddrinfo="yes"
1403    else
1404      AC_MSG_RESULT([no])
1405      tst_allow_getaddrinfo="no"
1406    fi
1407  fi
1408  #
1409  AC_MSG_CHECKING([if getaddrinfo might be used])
1410  if test "$tst_links_getaddrinfo" = "yes" &&
1411     test "$tst_proto_getaddrinfo" = "yes" &&
1412     test "$tst_compi_getaddrinfo" = "yes" &&
1413     test "$tst_allow_getaddrinfo" = "yes" &&
1414     test "$tst_works_getaddrinfo" != "no"; then
1415    AC_MSG_RESULT([yes])
1416    AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO, 1,
1417      [Define to 1 if you have a working getaddrinfo function.])
1418    curl_cv_func_getaddrinfo="yes"
1419  else
1420    AC_MSG_RESULT([no])
1421    curl_cv_func_getaddrinfo="no"
1422    curl_cv_func_getaddrinfo_threadsafe="no"
1423  fi
1424  #
1425  if test "$curl_cv_func_getaddrinfo" = "yes"; then
1426    AC_MSG_CHECKING([if getaddrinfo is threadsafe])
1427    case $host in
1428      *-apple-*)
1429        dnl Darwin 6.0 and macOS 10.2.X and newer
1430        tst_tsafe_getaddrinfo="yes"
1431    esac
1432    case $host_os in
1433      aix[[1234]].* | aix5.[[01]].*)
1434        dnl AIX 5.1 and older
1435        tst_tsafe_getaddrinfo="no"
1436        ;;
1437      aix*)
1438        dnl AIX 5.2 and newer
1439        tst_tsafe_getaddrinfo="yes"
1440        ;;
1441      darwin[[12345]].*)
1442        dnl Darwin 5.0 and macOS 10.1.X and older
1443        tst_tsafe_getaddrinfo="no"
1444        ;;
1445      freebsd[[1234]].* | freebsd5.[[1234]]*)
1446        dnl FreeBSD 5.4 and older
1447        tst_tsafe_getaddrinfo="no"
1448        ;;
1449      freebsd*)
1450        dnl FreeBSD 5.5 and newer
1451        tst_tsafe_getaddrinfo="yes"
1452        ;;
1453      hpux[[123456789]].* | hpux10.* | hpux11.0* | hpux11.10*)
1454        dnl HP-UX 11.10 and older
1455        tst_tsafe_getaddrinfo="no"
1456        ;;
1457      hpux*)
1458        dnl HP-UX 11.11 and newer
1459        tst_tsafe_getaddrinfo="yes"
1460        ;;
1461      midnightbsd*)
1462        dnl all MidnightBSD versions
1463        tst_tsafe_getaddrinfo="yes"
1464        ;;
1465      netbsd[[123]].*)
1466        dnl NetBSD 3.X and older
1467        tst_tsafe_getaddrinfo="no"
1468        ;;
1469      netbsd*)
1470        dnl NetBSD 4.X and newer
1471        tst_tsafe_getaddrinfo="yes"
1472        ;;
1473      *bsd*)
1474        dnl All other BSD's
1475        tst_tsafe_getaddrinfo="no"
1476        ;;
1477      solaris2*)
1478        dnl Solaris which have it
1479        tst_tsafe_getaddrinfo="yes"
1480        ;;
1481    esac
1482    if test "$tst_tsafe_getaddrinfo" = "unknown" &&
1483       test "$curl_cv_native_windows" = "yes"; then
1484      tst_tsafe_getaddrinfo="yes"
1485    fi
1486    if test "$tst_tsafe_getaddrinfo" = "unknown"; then
1487      tst_tsafe_getaddrinfo="yes"
1488    fi
1489    AC_MSG_RESULT([$tst_tsafe_getaddrinfo])
1490    if test "$tst_tsafe_getaddrinfo" = "yes"; then
1491      AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO_THREADSAFE, 1,
1492        [Define to 1 if the getaddrinfo function is threadsafe.])
1493      curl_cv_func_getaddrinfo_threadsafe="yes"
1494    else
1495      curl_cv_func_getaddrinfo_threadsafe="no"
1496    fi
1497  fi
1498])
1499
1500
1501dnl CURL_CHECK_FUNC_GETHOSTBYNAME
1502dnl -------------------------------------------------
1503dnl Verify if gethostbyname is available, prototyped,
1504dnl and can be compiled. If all of these are true,
1505dnl and usage has not been previously disallowed with
1506dnl shell variable curl_disallow_gethostbyname, then
1507dnl HAVE_GETHOSTBYNAME will be defined.
1508
1509AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME], [
1510  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1511  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1512  #
1513  tst_links_gethostbyname="unknown"
1514  tst_proto_gethostbyname="unknown"
1515  tst_compi_gethostbyname="unknown"
1516  tst_allow_gethostbyname="unknown"
1517  #
1518  AC_MSG_CHECKING([if gethostbyname can be linked])
1519  AC_LINK_IFELSE([
1520    AC_LANG_PROGRAM([[
1521      $curl_includes_winsock2
1522      $curl_includes_bsdsocket
1523      $curl_includes_netdb
1524    ]],[[
1525      if(0 != gethostbyname(0))
1526        return 1;
1527    ]])
1528  ],[
1529    AC_MSG_RESULT([yes])
1530    tst_links_gethostbyname="yes"
1531  ],[
1532    AC_MSG_RESULT([no])
1533    tst_links_gethostbyname="no"
1534  ])
1535  #
1536  if test "$tst_links_gethostbyname" = "yes"; then
1537    AC_MSG_CHECKING([if gethostbyname is prototyped])
1538    AC_EGREP_CPP([gethostbyname],[
1539      $curl_includes_winsock2
1540      $curl_includes_bsdsocket
1541      $curl_includes_netdb
1542    ],[
1543      AC_MSG_RESULT([yes])
1544      tst_proto_gethostbyname="yes"
1545    ],[
1546      AC_MSG_RESULT([no])
1547      tst_proto_gethostbyname="no"
1548    ])
1549  fi
1550  #
1551  if test "$tst_proto_gethostbyname" = "yes"; then
1552    AC_MSG_CHECKING([if gethostbyname is compilable])
1553    AC_COMPILE_IFELSE([
1554      AC_LANG_PROGRAM([[
1555        $curl_includes_winsock2
1556        $curl_includes_bsdsocket
1557        $curl_includes_netdb
1558      ]],[[
1559        if(0 != gethostbyname(0))
1560          return 1;
1561      ]])
1562    ],[
1563      AC_MSG_RESULT([yes])
1564      tst_compi_gethostbyname="yes"
1565    ],[
1566      AC_MSG_RESULT([no])
1567      tst_compi_gethostbyname="no"
1568    ])
1569  fi
1570  #
1571  if test "$tst_compi_gethostbyname" = "yes"; then
1572    AC_MSG_CHECKING([if gethostbyname usage allowed])
1573    if test "x$curl_disallow_gethostbyname" != "xyes"; then
1574      AC_MSG_RESULT([yes])
1575      tst_allow_gethostbyname="yes"
1576    else
1577      AC_MSG_RESULT([no])
1578      tst_allow_gethostbyname="no"
1579    fi
1580  fi
1581  #
1582  AC_MSG_CHECKING([if gethostbyname might be used])
1583  if test "$tst_links_gethostbyname" = "yes" &&
1584     test "$tst_proto_gethostbyname" = "yes" &&
1585     test "$tst_compi_gethostbyname" = "yes" &&
1586     test "$tst_allow_gethostbyname" = "yes"; then
1587    AC_MSG_RESULT([yes])
1588    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME, 1,
1589      [Define to 1 if you have the gethostbyname function.])
1590    curl_cv_func_gethostbyname="yes"
1591  else
1592    AC_MSG_RESULT([no])
1593    curl_cv_func_gethostbyname="no"
1594  fi
1595])
1596
1597
1598dnl CURL_CHECK_FUNC_GETHOSTBYNAME_R
1599dnl -------------------------------------------------
1600dnl Verify if gethostbyname_r is available, prototyped,
1601dnl and can be compiled. If all of these are true, and
1602dnl usage has not been previously disallowed with
1603dnl shell variable curl_disallow_gethostbyname_r, then
1604dnl HAVE_GETHOSTBYNAME_R will be defined.
1605
1606AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [
1607  AC_REQUIRE([CURL_INCLUDES_NETDB])dnl
1608  #
1609  tst_links_gethostbyname_r="unknown"
1610  tst_proto_gethostbyname_r="unknown"
1611  tst_compi_gethostbyname_r="unknown"
1612  tst_allow_gethostbyname_r="unknown"
1613  tst_nargs_gethostbyname_r="unknown"
1614  #
1615  AC_MSG_CHECKING([if gethostbyname_r can be linked])
1616  AC_LINK_IFELSE([
1617    AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
1618  ],[
1619    AC_MSG_RESULT([yes])
1620    tst_links_gethostbyname_r="yes"
1621  ],[
1622    AC_MSG_RESULT([no])
1623    tst_links_gethostbyname_r="no"
1624  ])
1625  #
1626  if test "$tst_links_gethostbyname_r" = "yes"; then
1627    AC_MSG_CHECKING([if gethostbyname_r is prototyped])
1628    AC_EGREP_CPP([gethostbyname_r],[
1629      $curl_includes_netdb
1630    ],[
1631      AC_MSG_RESULT([yes])
1632      tst_proto_gethostbyname_r="yes"
1633    ],[
1634      AC_MSG_RESULT([no])
1635      tst_proto_gethostbyname_r="no"
1636    ])
1637  fi
1638  #
1639  if test "$tst_proto_gethostbyname_r" = "yes"; then
1640    if test "$tst_nargs_gethostbyname_r" = "unknown"; then
1641      AC_MSG_CHECKING([if gethostbyname_r takes 3 args.])
1642      AC_COMPILE_IFELSE([
1643        AC_LANG_PROGRAM([[
1644          $curl_includes_netdb
1645          $curl_includes_bsdsocket
1646        ]],[[
1647          if(0 != gethostbyname_r(0, 0, 0))
1648            return 1;
1649        ]])
1650      ],[
1651        AC_MSG_RESULT([yes])
1652        tst_compi_gethostbyname_r="yes"
1653        tst_nargs_gethostbyname_r="3"
1654      ],[
1655        AC_MSG_RESULT([no])
1656        tst_compi_gethostbyname_r="no"
1657      ])
1658    fi
1659    if test "$tst_nargs_gethostbyname_r" = "unknown"; then
1660      AC_MSG_CHECKING([if gethostbyname_r takes 5 args.])
1661      AC_COMPILE_IFELSE([
1662        AC_LANG_PROGRAM([[
1663          $curl_includes_netdb
1664          $curl_includes_bsdsocket
1665        ]],[[
1666          if(0 != gethostbyname_r(0, 0, 0, 0, 0))
1667            return 1;
1668        ]])
1669      ],[
1670        AC_MSG_RESULT([yes])
1671        tst_compi_gethostbyname_r="yes"
1672        tst_nargs_gethostbyname_r="5"
1673      ],[
1674        AC_MSG_RESULT([no])
1675        tst_compi_gethostbyname_r="no"
1676      ])
1677    fi
1678    if test "$tst_nargs_gethostbyname_r" = "unknown"; then
1679      AC_MSG_CHECKING([if gethostbyname_r takes 6 args.])
1680      AC_COMPILE_IFELSE([
1681        AC_LANG_PROGRAM([[
1682          $curl_includes_netdb
1683          $curl_includes_bsdsocket
1684        ]],[[
1685          if(0 != gethostbyname_r(0, 0, 0, 0, 0, 0))
1686            return 1;
1687        ]])
1688      ],[
1689        AC_MSG_RESULT([yes])
1690        tst_compi_gethostbyname_r="yes"
1691        tst_nargs_gethostbyname_r="6"
1692      ],[
1693        AC_MSG_RESULT([no])
1694        tst_compi_gethostbyname_r="no"
1695      ])
1696    fi
1697    AC_MSG_CHECKING([if gethostbyname_r is compilable])
1698    if test "$tst_compi_gethostbyname_r" = "yes"; then
1699      AC_MSG_RESULT([yes])
1700    else
1701      AC_MSG_RESULT([no])
1702    fi
1703  fi
1704  #
1705  if test "$tst_compi_gethostbyname_r" = "yes"; then
1706    AC_MSG_CHECKING([if gethostbyname_r usage allowed])
1707    if test "x$curl_disallow_gethostbyname_r" != "xyes"; then
1708      AC_MSG_RESULT([yes])
1709      tst_allow_gethostbyname_r="yes"
1710    else
1711      AC_MSG_RESULT([no])
1712      tst_allow_gethostbyname_r="no"
1713    fi
1714  fi
1715  #
1716  AC_MSG_CHECKING([if gethostbyname_r might be used])
1717  if test "$tst_links_gethostbyname_r" = "yes" &&
1718     test "$tst_proto_gethostbyname_r" = "yes" &&
1719     test "$tst_compi_gethostbyname_r" = "yes" &&
1720     test "$tst_allow_gethostbyname_r" = "yes"; then
1721    AC_MSG_RESULT([yes])
1722    AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
1723      [Define to 1 if you have the gethostbyname_r function.])
1724    dnl AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_ARGS, $tst_nargs_gethostbyname_r,
1725    dnl   [Specifies the number of arguments to gethostbyname_r])
1726    #
1727    if test "$tst_nargs_gethostbyname_r" -eq "3"; then
1728      AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
1729    elif test "$tst_nargs_gethostbyname_r" -eq "5"; then
1730      AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
1731    elif test "$tst_nargs_gethostbyname_r" -eq "6"; then
1732      AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
1733    fi
1734    #
1735    curl_cv_func_gethostbyname_r="yes"
1736  else
1737    AC_MSG_RESULT([no])
1738    curl_cv_func_gethostbyname_r="no"
1739  fi
1740])
1741
1742
1743dnl CURL_CHECK_FUNC_GETHOSTNAME
1744dnl -------------------------------------------------
1745dnl Verify if gethostname is available, prototyped, and
1746dnl can be compiled. If all of these are true, and
1747dnl usage has not been previously disallowed with
1748dnl shell variable curl_disallow_gethostname, then
1749dnl HAVE_GETHOSTNAME will be defined.
1750
1751AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
1752  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1753  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1754  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
1755  AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
1756  #
1757  tst_links_gethostname="unknown"
1758  tst_proto_gethostname="unknown"
1759  tst_compi_gethostname="unknown"
1760  tst_allow_gethostname="unknown"
1761  #
1762  AC_MSG_CHECKING([if gethostname can be linked])
1763  AC_LINK_IFELSE([
1764    AC_LANG_PROGRAM([[
1765      $curl_includes_winsock2
1766      $curl_includes_unistd
1767      $curl_includes_bsdsocket
1768    ]],[[
1769      if(0 != gethostname(0, 0))
1770        return 1;
1771    ]])
1772  ],[
1773    AC_MSG_RESULT([yes])
1774    tst_links_gethostname="yes"
1775  ],[
1776    AC_MSG_RESULT([no])
1777    tst_links_gethostname="no"
1778  ])
1779  #
1780  if test "$tst_links_gethostname" = "yes"; then
1781    AC_MSG_CHECKING([if gethostname is prototyped])
1782    AC_EGREP_CPP([gethostname],[
1783      $curl_includes_winsock2
1784      $curl_includes_unistd
1785      $curl_includes_bsdsocket
1786    ],[
1787      AC_MSG_RESULT([yes])
1788      tst_proto_gethostname="yes"
1789    ],[
1790      AC_MSG_RESULT([no])
1791      tst_proto_gethostname="no"
1792    ])
1793  fi
1794  #
1795  if test "$tst_proto_gethostname" = "yes"; then
1796    AC_MSG_CHECKING([if gethostname is compilable])
1797    AC_COMPILE_IFELSE([
1798      AC_LANG_PROGRAM([[
1799        $curl_includes_winsock2
1800        $curl_includes_unistd
1801        $curl_includes_bsdsocket
1802      ]],[[
1803        if(0 != gethostname(0, 0))
1804          return 1;
1805      ]])
1806    ],[
1807      AC_MSG_RESULT([yes])
1808      tst_compi_gethostname="yes"
1809    ],[
1810      AC_MSG_RESULT([no])
1811      tst_compi_gethostname="no"
1812    ])
1813  fi
1814  #
1815  if test "$tst_compi_gethostname" = "yes"; then
1816    AC_MSG_CHECKING([for gethostname arg 2 data type])
1817    tst_gethostname_type_arg2="unknown"
1818    for tst_arg1 in 'char *' 'unsigned char *' 'void *'; do
1819      for tst_arg2 in 'int' 'unsigned int' 'size_t'; do
1820        if test "$tst_gethostname_type_arg2" = "unknown"; then
1821          AC_COMPILE_IFELSE([
1822            AC_LANG_PROGRAM([[
1823              $curl_includes_winsock2
1824              $curl_includes_unistd
1825              $curl_includes_bsdsocket
1826              $curl_preprocess_callconv
1827              extern int FUNCALLCONV gethostname($tst_arg1, $tst_arg2);
1828            ]],[[
1829              if(0 != gethostname(0, 0))
1830                return 1;
1831            ]])
1832          ],[
1833            tst_gethostname_type_arg2="$tst_arg2"
1834          ])
1835        fi
1836      done
1837    done
1838    AC_MSG_RESULT([$tst_gethostname_type_arg2])
1839    if test "$tst_gethostname_type_arg2" != "unknown"; then
1840      AC_DEFINE_UNQUOTED(GETHOSTNAME_TYPE_ARG2, $tst_gethostname_type_arg2,
1841        [Define to the type of arg 2 for gethostname.])
1842    fi
1843  fi
1844  #
1845  if test "$tst_compi_gethostname" = "yes"; then
1846    AC_MSG_CHECKING([if gethostname usage allowed])
1847    if test "x$curl_disallow_gethostname" != "xyes"; then
1848      AC_MSG_RESULT([yes])
1849      tst_allow_gethostname="yes"
1850    else
1851      AC_MSG_RESULT([no])
1852      tst_allow_gethostname="no"
1853    fi
1854  fi
1855  #
1856  AC_MSG_CHECKING([if gethostname might be used])
1857  if test "$tst_links_gethostname" = "yes" &&
1858     test "$tst_proto_gethostname" = "yes" &&
1859     test "$tst_compi_gethostname" = "yes" &&
1860     test "$tst_allow_gethostname" = "yes"; then
1861    AC_MSG_RESULT([yes])
1862    AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
1863      [Define to 1 if you have the gethostname function.])
1864    curl_cv_func_gethostname="yes"
1865  else
1866    AC_MSG_RESULT([no])
1867    curl_cv_func_gethostname="no"
1868  fi
1869])
1870
1871dnl CURL_CHECK_FUNC_GETPEERNAME
1872dnl -------------------------------------------------
1873dnl Verify if getpeername is available, prototyped, and
1874dnl can be compiled. If all of these are true, and
1875dnl usage has not been previously disallowed with
1876dnl shell variable curl_disallow_getpeername, then
1877dnl HAVE_GETPEERNAME will be defined.
1878
1879AC_DEFUN([CURL_CHECK_FUNC_GETPEERNAME], [
1880  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1881  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
1882  AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
1883  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1884  #
1885  tst_links_getpeername="unknown"
1886  tst_proto_getpeername="unknown"
1887  tst_compi_getpeername="unknown"
1888  tst_allow_getpeername="unknown"
1889  #
1890  AC_MSG_CHECKING([if getpeername can be linked])
1891  AC_LINK_IFELSE([
1892    AC_LANG_PROGRAM([[
1893      $curl_includes_winsock2
1894      $curl_includes_bsdsocket
1895      $curl_includes_sys_socket
1896    ]],[[
1897      if(0 != getpeername(0, (void *)0, (void *)0))
1898        return 1;
1899    ]])
1900  ],[
1901    AC_MSG_RESULT([yes])
1902    tst_links_getpeername="yes"
1903  ],[
1904    AC_MSG_RESULT([no])
1905    tst_links_getpeername="no"
1906  ])
1907  #
1908  if test "$tst_links_getpeername" = "yes"; then
1909    AC_MSG_CHECKING([if getpeername is prototyped])
1910    AC_EGREP_CPP([getpeername],[
1911      $curl_includes_winsock2
1912      $curl_includes_bsdsocket
1913      $curl_includes_sys_socket
1914    ],[
1915      AC_MSG_RESULT([yes])
1916      tst_proto_getpeername="yes"
1917    ],[
1918      AC_MSG_RESULT([no])
1919      tst_proto_getpeername="no"
1920    ])
1921  fi
1922  #
1923  if test "$tst_proto_getpeername" = "yes"; then
1924    AC_MSG_CHECKING([if getpeername is compilable])
1925    AC_COMPILE_IFELSE([
1926      AC_LANG_PROGRAM([[
1927        $curl_includes_winsock2
1928        $curl_includes_bsdsocket
1929        $curl_includes_sys_socket
1930      ]],[[
1931        if(0 != getpeername(0, (void *)0, (void *)0))
1932          return 1;
1933      ]])
1934    ],[
1935      AC_MSG_RESULT([yes])
1936      tst_compi_getpeername="yes"
1937    ],[
1938      AC_MSG_RESULT([no])
1939      tst_compi_getpeername="no"
1940    ])
1941  fi
1942  #
1943  if test "$tst_compi_getpeername" = "yes"; then
1944    AC_MSG_CHECKING([if getpeername usage allowed])
1945    if test "x$curl_disallow_getpeername" != "xyes"; then
1946      AC_MSG_RESULT([yes])
1947      tst_allow_getpeername="yes"
1948    else
1949      AC_MSG_RESULT([no])
1950      tst_allow_getpeername="no"
1951    fi
1952  fi
1953  #
1954  AC_MSG_CHECKING([if getpeername might be used])
1955  if test "$tst_links_getpeername" = "yes" &&
1956     test "$tst_proto_getpeername" = "yes" &&
1957     test "$tst_compi_getpeername" = "yes" &&
1958     test "$tst_allow_getpeername" = "yes"; then
1959    AC_MSG_RESULT([yes])
1960    AC_DEFINE_UNQUOTED(HAVE_GETPEERNAME, 1,
1961      [Define to 1 if you have the getpeername function.])
1962    curl_cv_func_getpeername="yes"
1963  else
1964    AC_MSG_RESULT([no])
1965    curl_cv_func_getpeername="no"
1966  fi
1967])
1968
1969dnl CURL_CHECK_FUNC_GETSOCKNAME
1970dnl -------------------------------------------------
1971dnl Verify if getsockname is available, prototyped, and
1972dnl can be compiled. If all of these are true, and
1973dnl usage has not been previously disallowed with
1974dnl shell variable curl_disallow_getsockname, then
1975dnl HAVE_GETSOCKNAME will be defined.
1976
1977AC_DEFUN([CURL_CHECK_FUNC_GETSOCKNAME], [
1978  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1979  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
1980  AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
1981  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1982  #
1983  tst_links_getsockname="unknown"
1984  tst_proto_getsockname="unknown"
1985  tst_compi_getsockname="unknown"
1986  tst_allow_getsockname="unknown"
1987  #
1988  AC_MSG_CHECKING([if getsockname can be linked])
1989  AC_LINK_IFELSE([
1990    AC_LANG_PROGRAM([[
1991      $curl_includes_winsock2
1992      $curl_includes_bsdsocket
1993      $curl_includes_sys_socket
1994    ]],[[
1995      if(0 != getsockname(0, (void *)0, (void *)0))
1996        return 1;
1997    ]])
1998  ],[
1999    AC_MSG_RESULT([yes])
2000    tst_links_getsockname="yes"
2001  ],[
2002    AC_MSG_RESULT([no])
2003    tst_links_getsockname="no"
2004  ])
2005  #
2006  if test "$tst_links_getsockname" = "yes"; then
2007    AC_MSG_CHECKING([if getsockname is prototyped])
2008    AC_EGREP_CPP([getsockname],[
2009      $curl_includes_winsock2
2010      $curl_includes_bsdsocket
2011      $curl_includes_sys_socket
2012    ],[
2013      AC_MSG_RESULT([yes])
2014      tst_proto_getsockname="yes"
2015    ],[
2016      AC_MSG_RESULT([no])
2017      tst_proto_getsockname="no"
2018    ])
2019  fi
2020  #
2021  if test "$tst_proto_getsockname" = "yes"; then
2022    AC_MSG_CHECKING([if getsockname is compilable])
2023    AC_COMPILE_IFELSE([
2024      AC_LANG_PROGRAM([[
2025        $curl_includes_winsock2
2026        $curl_includes_bsdsocket
2027        $curl_includes_sys_socket
2028      ]],[[
2029        if(0 != getsockname(0, (void *)0, (void *)0))
2030          return 1;
2031      ]])
2032    ],[
2033      AC_MSG_RESULT([yes])
2034      tst_compi_getsockname="yes"
2035    ],[
2036      AC_MSG_RESULT([no])
2037      tst_compi_getsockname="no"
2038    ])
2039  fi
2040  #
2041  if test "$tst_compi_getsockname" = "yes"; then
2042    AC_MSG_CHECKING([if getsockname usage allowed])
2043    if test "x$curl_disallow_getsockname" != "xyes"; then
2044      AC_MSG_RESULT([yes])
2045      tst_allow_getsockname="yes"
2046    else
2047      AC_MSG_RESULT([no])
2048      tst_allow_getsockname="no"
2049    fi
2050  fi
2051  #
2052  AC_MSG_CHECKING([if getsockname might be used])
2053  if test "$tst_links_getsockname" = "yes" &&
2054     test "$tst_proto_getsockname" = "yes" &&
2055     test "$tst_compi_getsockname" = "yes" &&
2056     test "$tst_allow_getsockname" = "yes"; then
2057    AC_MSG_RESULT([yes])
2058    AC_DEFINE_UNQUOTED(HAVE_GETSOCKNAME, 1,
2059      [Define to 1 if you have the getsockname function.])
2060    curl_cv_func_getsockname="yes"
2061  else
2062    AC_MSG_RESULT([no])
2063    curl_cv_func_getsockname="no"
2064  fi
2065])
2066
2067
2068dnl CURL_CHECK_FUNC_GETIFADDRS
2069dnl -------------------------------------------------
2070dnl Verify if getifaddrs is available, prototyped, can
2071dnl be compiled and seems to work. If all of these are
2072dnl true, and usage has not been previously disallowed
2073dnl with shell variable curl_disallow_getifaddrs, then
2074dnl HAVE_GETIFADDRS will be defined.
2075
2076AC_DEFUN([CURL_CHECK_FUNC_GETIFADDRS], [
2077  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2078  AC_REQUIRE([CURL_INCLUDES_IFADDRS])dnl
2079  #
2080  tst_links_getifaddrs="unknown"
2081  tst_proto_getifaddrs="unknown"
2082  tst_compi_getifaddrs="unknown"
2083  tst_works_getifaddrs="unknown"
2084  tst_allow_getifaddrs="unknown"
2085  #
2086  AC_MSG_CHECKING([if getifaddrs can be linked])
2087  AC_LINK_IFELSE([
2088    AC_LANG_FUNC_LINK_TRY([getifaddrs])
2089  ],[
2090    AC_MSG_RESULT([yes])
2091    tst_links_getifaddrs="yes"
2092  ],[
2093    AC_MSG_RESULT([no])
2094    tst_links_getifaddrs="no"
2095  ])
2096  #
2097  if test "$tst_links_getifaddrs" = "yes"; then
2098    AC_MSG_CHECKING([if getifaddrs is prototyped])
2099    AC_EGREP_CPP([getifaddrs],[
2100      $curl_includes_ifaddrs
2101    ],[
2102      AC_MSG_RESULT([yes])
2103      tst_proto_getifaddrs="yes"
2104    ],[
2105      AC_MSG_RESULT([no])
2106      tst_proto_getifaddrs="no"
2107    ])
2108  fi
2109  #
2110  if test "$tst_proto_getifaddrs" = "yes"; then
2111    AC_MSG_CHECKING([if getifaddrs is compilable])
2112    AC_COMPILE_IFELSE([
2113      AC_LANG_PROGRAM([[
2114        $curl_includes_ifaddrs
2115      ]],[[
2116        if(0 != getifaddrs(0))
2117          return 1;
2118      ]])
2119    ],[
2120      AC_MSG_RESULT([yes])
2121      tst_compi_getifaddrs="yes"
2122    ],[
2123      AC_MSG_RESULT([no])
2124      tst_compi_getifaddrs="no"
2125    ])
2126  fi
2127  #
2128  dnl only do runtime verification when not cross-compiling
2129  if test "x$cross_compiling" != "xyes" &&
2130    test "$tst_compi_getifaddrs" = "yes"; then
2131    AC_MSG_CHECKING([if getifaddrs seems to work])
2132    CURL_RUN_IFELSE([
2133      AC_LANG_PROGRAM([[
2134        $curl_includes_stdlib
2135        $curl_includes_ifaddrs
2136      ]],[[
2137        struct ifaddrs *ifa = 0;
2138        int error;
2139
2140        error = getifaddrs(&ifa);
2141        if(error || !ifa)
2142          exit(1); /* fail */
2143        else
2144          exit(0);
2145      ]])
2146    ],[
2147      AC_MSG_RESULT([yes])
2148      tst_works_getifaddrs="yes"
2149    ],[
2150      AC_MSG_RESULT([no])
2151      tst_works_getifaddrs="no"
2152    ])
2153  fi
2154  #
2155  if test "$tst_compi_getifaddrs" = "yes" &&
2156    test "$tst_works_getifaddrs" != "no"; then
2157    AC_MSG_CHECKING([if getifaddrs usage allowed])
2158    if test "x$curl_disallow_getifaddrs" != "xyes"; then
2159      AC_MSG_RESULT([yes])
2160      tst_allow_getifaddrs="yes"
2161    else
2162      AC_MSG_RESULT([no])
2163      tst_allow_getifaddrs="no"
2164    fi
2165  fi
2166  #
2167  AC_MSG_CHECKING([if getifaddrs might be used])
2168  if test "$tst_links_getifaddrs" = "yes" &&
2169     test "$tst_proto_getifaddrs" = "yes" &&
2170     test "$tst_compi_getifaddrs" = "yes" &&
2171     test "$tst_allow_getifaddrs" = "yes" &&
2172     test "$tst_works_getifaddrs" != "no"; then
2173    AC_MSG_RESULT([yes])
2174    AC_DEFINE_UNQUOTED(HAVE_GETIFADDRS, 1,
2175      [Define to 1 if you have a working getifaddrs function.])
2176    curl_cv_func_getifaddrs="yes"
2177  else
2178    AC_MSG_RESULT([no])
2179    curl_cv_func_getifaddrs="no"
2180  fi
2181])
2182
2183
2184dnl CURL_CHECK_FUNC_GMTIME_R
2185dnl -------------------------------------------------
2186dnl Verify if gmtime_r is available, prototyped, can
2187dnl be compiled and seems to work. If all of these are
2188dnl true, and usage has not been previously disallowed
2189dnl with shell variable curl_disallow_gmtime_r, then
2190dnl HAVE_GMTIME_R will be defined.
2191
2192AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
2193  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2194  AC_REQUIRE([CURL_INCLUDES_TIME])dnl
2195  #
2196  tst_links_gmtime_r="unknown"
2197  tst_proto_gmtime_r="unknown"
2198  tst_compi_gmtime_r="unknown"
2199  tst_works_gmtime_r="unknown"
2200  tst_allow_gmtime_r="unknown"
2201  #
2202  AC_MSG_CHECKING([if gmtime_r can be linked])
2203  AC_LINK_IFELSE([
2204    AC_LANG_FUNC_LINK_TRY([gmtime_r])
2205  ],[
2206    AC_MSG_RESULT([yes])
2207    tst_links_gmtime_r="yes"
2208  ],[
2209    AC_MSG_RESULT([no])
2210    tst_links_gmtime_r="no"
2211  ])
2212  #
2213  if test "$tst_links_gmtime_r" = "yes"; then
2214    AC_MSG_CHECKING([if gmtime_r is prototyped])
2215    AC_EGREP_CPP([gmtime_r],[
2216      $curl_includes_time
2217    ],[
2218      AC_MSG_RESULT([yes])
2219      tst_proto_gmtime_r="yes"
2220    ],[
2221      AC_MSG_RESULT([no])
2222      tst_proto_gmtime_r="no"
2223    ])
2224  fi
2225  #
2226  if test "$tst_proto_gmtime_r" = "yes"; then
2227    AC_MSG_CHECKING([if gmtime_r is compilable])
2228    AC_COMPILE_IFELSE([
2229      AC_LANG_PROGRAM([[
2230        $curl_includes_time
2231      ]],[[
2232        if(0 != gmtime_r(0, 0))
2233          return 1;
2234      ]])
2235    ],[
2236      AC_MSG_RESULT([yes])
2237      tst_compi_gmtime_r="yes"
2238    ],[
2239      AC_MSG_RESULT([no])
2240      tst_compi_gmtime_r="no"
2241    ])
2242  fi
2243  #
2244  dnl only do runtime verification when not cross-compiling
2245  if test "x$cross_compiling" != "xyes" &&
2246    test "$tst_compi_gmtime_r" = "yes"; then
2247    AC_MSG_CHECKING([if gmtime_r seems to work])
2248    CURL_RUN_IFELSE([
2249      AC_LANG_PROGRAM([[
2250        $curl_includes_stdlib
2251        $curl_includes_time
2252      ]],[[
2253        time_t local = 1170352587;
2254        struct tm *gmt = 0;
2255        struct tm result;
2256        gmt = gmtime_r(&local, &result);
2257        if(gmt)
2258          exit(0);
2259        else
2260          exit(1);
2261      ]])
2262    ],[
2263      AC_MSG_RESULT([yes])
2264      tst_works_gmtime_r="yes"
2265    ],[
2266      AC_MSG_RESULT([no])
2267      tst_works_gmtime_r="no"
2268    ])
2269  fi
2270  #
2271  if test "$tst_compi_gmtime_r" = "yes" &&
2272    test "$tst_works_gmtime_r" != "no"; then
2273    AC_MSG_CHECKING([if gmtime_r usage allowed])
2274    if test "x$curl_disallow_gmtime_r" != "xyes"; then
2275      AC_MSG_RESULT([yes])
2276      tst_allow_gmtime_r="yes"
2277    else
2278      AC_MSG_RESULT([no])
2279      tst_allow_gmtime_r="no"
2280    fi
2281  fi
2282  #
2283  AC_MSG_CHECKING([if gmtime_r might be used])
2284  if test "$tst_links_gmtime_r" = "yes" &&
2285     test "$tst_proto_gmtime_r" = "yes" &&
2286     test "$tst_compi_gmtime_r" = "yes" &&
2287     test "$tst_allow_gmtime_r" = "yes" &&
2288     test "$tst_works_gmtime_r" != "no"; then
2289    AC_MSG_RESULT([yes])
2290    AC_DEFINE_UNQUOTED(HAVE_GMTIME_R, 1,
2291      [Define to 1 if you have a working gmtime_r function.])
2292    curl_cv_func_gmtime_r="yes"
2293  else
2294    AC_MSG_RESULT([no])
2295    curl_cv_func_gmtime_r="no"
2296  fi
2297])
2298
2299
2300dnl CURL_CHECK_FUNC_INET_NTOP
2301dnl -------------------------------------------------
2302dnl Verify if inet_ntop is available, prototyped, can
2303dnl be compiled and seems to work. If all of these are
2304dnl true, and usage has not been previously disallowed
2305dnl with shell variable curl_disallow_inet_ntop, then
2306dnl HAVE_INET_NTOP will be defined.
2307
2308AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
2309  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2310  AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
2311  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
2312  #
2313  tst_links_inet_ntop="unknown"
2314  tst_proto_inet_ntop="unknown"
2315  tst_compi_inet_ntop="unknown"
2316  tst_works_inet_ntop="unknown"
2317  tst_allow_inet_ntop="unknown"
2318  #
2319  AC_MSG_CHECKING([if inet_ntop can be linked])
2320  AC_LINK_IFELSE([
2321    AC_LANG_FUNC_LINK_TRY([inet_ntop])
2322  ],[
2323    AC_MSG_RESULT([yes])
2324    tst_links_inet_ntop="yes"
2325  ],[
2326    AC_MSG_RESULT([no])
2327    tst_links_inet_ntop="no"
2328  ])
2329  #
2330  if test "$tst_links_inet_ntop" = "yes"; then
2331    AC_MSG_CHECKING([if inet_ntop is prototyped])
2332    AC_EGREP_CPP([inet_ntop],[
2333      $curl_includes_arpa_inet
2334    ],[
2335      AC_MSG_RESULT([yes])
2336      tst_proto_inet_ntop="yes"
2337    ],[
2338      AC_MSG_RESULT([no])
2339      tst_proto_inet_ntop="no"
2340    ])
2341  fi
2342  #
2343  if test "$tst_proto_inet_ntop" = "yes"; then
2344    AC_MSG_CHECKING([if inet_ntop is compilable])
2345    AC_COMPILE_IFELSE([
2346      AC_LANG_PROGRAM([[
2347        $curl_includes_arpa_inet
2348      ]],[[
2349        if(0 != inet_ntop(0, 0, 0, 0))
2350          return 1;
2351      ]])
2352    ],[
2353      AC_MSG_RESULT([yes])
2354      tst_compi_inet_ntop="yes"
2355    ],[
2356      AC_MSG_RESULT([no])
2357      tst_compi_inet_ntop="no"
2358    ])
2359  fi
2360  #
2361  dnl only do runtime verification when not cross-compiling
2362  if test "x$cross_compiling" != "xyes" &&
2363    test "$tst_compi_inet_ntop" = "yes"; then
2364    AC_MSG_CHECKING([if inet_ntop seems to work])
2365    CURL_RUN_IFELSE([
2366      AC_LANG_PROGRAM([[
2367        $curl_includes_stdlib
2368        $curl_includes_arpa_inet
2369        $curl_includes_string
2370      ]],[[
2371        char ipv6res[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
2372        char ipv4res[sizeof "255.255.255.255"];
2373        unsigned char ipv6a[26];
2374        unsigned char ipv4a[5];
2375        char *ipv6ptr = 0;
2376        char *ipv4ptr = 0;
2377        /* - */
2378        ipv4res[0] = '\0';
2379        ipv4a[0] = 0xc0;
2380        ipv4a[1] = 0xa8;
2381        ipv4a[2] = 0x64;
2382        ipv4a[3] = 0x01;
2383        ipv4a[4] = 0x01;
2384        /* - */
2385        ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
2386        if(!ipv4ptr)
2387          exit(1); /* fail */
2388        if(ipv4ptr != ipv4res)
2389          exit(1); /* fail */
2390        if(!ipv4ptr[0])
2391          exit(1); /* fail */
2392        if(memcmp(ipv4res, "192.168.100.1", 13) != 0)
2393          exit(1); /* fail */
2394        /* - */
2395        ipv6res[0] = '\0';
2396        memset(ipv6a, 0, sizeof(ipv6a));
2397        ipv6a[0] = 0xfe;
2398        ipv6a[1] = 0x80;
2399        ipv6a[8] = 0x02;
2400        ipv6a[9] = 0x14;
2401        ipv6a[10] = 0x4f;
2402        ipv6a[11] = 0xff;
2403        ipv6a[12] = 0xfe;
2404        ipv6a[13] = 0x0b;
2405        ipv6a[14] = 0x76;
2406        ipv6a[15] = 0xc8;
2407        ipv6a[25] = 0x01;
2408        /* - */
2409        ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
2410        if(!ipv6ptr)
2411          exit(1); /* fail */
2412        if(ipv6ptr != ipv6res)
2413          exit(1); /* fail */
2414        if(!ipv6ptr[0])
2415          exit(1); /* fail */
2416        if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24) != 0)
2417          exit(1); /* fail */
2418        /* - */
2419        exit(0);
2420      ]])
2421    ],[
2422      AC_MSG_RESULT([yes])
2423      tst_works_inet_ntop="yes"
2424    ],[
2425      AC_MSG_RESULT([no])
2426      tst_works_inet_ntop="no"
2427    ])
2428  fi
2429  #
2430  if test "$tst_compi_inet_ntop" = "yes" &&
2431    test "$tst_works_inet_ntop" != "no"; then
2432    AC_MSG_CHECKING([if inet_ntop usage allowed])
2433    if test "x$curl_disallow_inet_ntop" != "xyes"; then
2434      AC_MSG_RESULT([yes])
2435      tst_allow_inet_ntop="yes"
2436    else
2437      AC_MSG_RESULT([no])
2438      tst_allow_inet_ntop="no"
2439    fi
2440  fi
2441  #
2442  AC_MSG_CHECKING([if inet_ntop might be used])
2443  if test "$tst_links_inet_ntop" = "yes" &&
2444     test "$tst_proto_inet_ntop" = "yes" &&
2445     test "$tst_compi_inet_ntop" = "yes" &&
2446     test "$tst_allow_inet_ntop" = "yes" &&
2447     test "$tst_works_inet_ntop" != "no"; then
2448    AC_MSG_RESULT([yes])
2449    AC_DEFINE_UNQUOTED(HAVE_INET_NTOP, 1,
2450      [Define to 1 if you have a IPv6 capable working inet_ntop function.])
2451    curl_cv_func_inet_ntop="yes"
2452  else
2453    AC_MSG_RESULT([no])
2454    curl_cv_func_inet_ntop="no"
2455  fi
2456])
2457
2458
2459dnl CURL_CHECK_FUNC_INET_PTON
2460dnl -------------------------------------------------
2461dnl Verify if inet_pton is available, prototyped, can
2462dnl be compiled and seems to work. If all of these are
2463dnl true, and usage has not been previously disallowed
2464dnl with shell variable curl_disallow_inet_pton, then
2465dnl HAVE_INET_PTON will be defined.
2466
2467AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [
2468  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
2469  AC_REQUIRE([CURL_INCLUDES_ARPA_INET])dnl
2470  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
2471  #
2472  tst_links_inet_pton="unknown"
2473  tst_proto_inet_pton="unknown"
2474  tst_compi_inet_pton="unknown"
2475  tst_works_inet_pton="unknown"
2476  tst_allow_inet_pton="unknown"
2477  #
2478  AC_MSG_CHECKING([if inet_pton can be linked])
2479  AC_LINK_IFELSE([
2480    AC_LANG_FUNC_LINK_TRY([inet_pton])
2481  ],[
2482    AC_MSG_RESULT([yes])
2483    tst_links_inet_pton="yes"
2484  ],[
2485    AC_MSG_RESULT([no])
2486    tst_links_inet_pton="no"
2487  ])
2488  #
2489  if test "$tst_links_inet_pton" = "yes"; then
2490    AC_MSG_CHECKING([if inet_pton is prototyped])
2491    AC_EGREP_CPP([inet_pton],[
2492      $curl_includes_arpa_inet
2493    ],[
2494      AC_MSG_RESULT([yes])
2495      tst_proto_inet_pton="yes"
2496    ],[
2497      AC_MSG_RESULT([no])
2498      tst_proto_inet_pton="no"
2499    ])
2500  fi
2501  #
2502  if test "$tst_proto_inet_pton" = "yes"; then
2503    AC_MSG_CHECKING([if inet_pton is compilable])
2504    AC_COMPILE_IFELSE([
2505      AC_LANG_PROGRAM([[
2506        $curl_includes_arpa_inet
2507      ]],[[
2508        if(0 != inet_pton(0, 0, 0))
2509          return 1;
2510      ]])
2511    ],[
2512      AC_MSG_RESULT([yes])
2513      tst_compi_inet_pton="yes"
2514    ],[
2515      AC_MSG_RESULT([no])
2516      tst_compi_inet_pton="no"
2517    ])
2518  fi
2519  #
2520  dnl only do runtime verification when not cross-compiling
2521  if test "x$cross_compiling" != "xyes" &&
2522    test "$tst_compi_inet_pton" = "yes"; then
2523    AC_MSG_CHECKING([if inet_pton seems to work])
2524    CURL_RUN_IFELSE([
2525      AC_LANG_PROGRAM([[
2526        $curl_includes_stdlib
2527        $curl_includes_arpa_inet
2528        $curl_includes_string
2529      ]],[[
2530        unsigned char ipv6a[16+1];
2531        unsigned char ipv4a[4+1];
2532        const char *ipv6src = "fe80::214:4fff:fe0b:76c8";
2533        const char *ipv4src = "192.168.100.1";
2534        /* - */
2535        memset(ipv4a, 1, sizeof(ipv4a));
2536        if(1 != inet_pton(AF_INET, ipv4src, ipv4a))
2537          exit(1); /* fail */
2538        /* - */
2539        if( (ipv4a[0] != 0xc0) ||
2540            (ipv4a[1] != 0xa8) ||
2541            (ipv4a[2] != 0x64) ||
2542            (ipv4a[3] != 0x01) ||
2543            (ipv4a[4] != 0x01) )
2544          exit(1); /* fail */
2545        /* - */
2546        memset(ipv6a, 1, sizeof(ipv6a));
2547        if(1 != inet_pton(AF_INET6, ipv6src, ipv6a))
2548          exit(1); /* fail */
2549        /* - */
2550        if( (ipv6a[0]  != 0xfe) ||
2551            (ipv6a[1]  != 0x80) ||
2552            (ipv6a[8]  != 0x02) ||
2553            (ipv6a[9]  != 0x14) ||
2554            (ipv6a[10] != 0x4f) ||
2555            (ipv6a[11] != 0xff) ||
2556            (ipv6a[12] != 0xfe) ||
2557            (ipv6a[13] != 0x0b) ||
2558            (ipv6a[14] != 0x76) ||
2559            (ipv6a[15] != 0xc8) ||
2560            (ipv6a[16] != 0x01) )
2561          exit(1); /* fail */
2562        /* - */
2563        if( (ipv6a[2]  != 0x0) ||
2564            (ipv6a[3]  != 0x0) ||
2565            (ipv6a[4]  != 0x0) ||
2566            (ipv6a[5]  != 0x0) ||
2567            (ipv6a[6]  != 0x0) ||
2568            (ipv6a[7]  != 0x0) )
2569          exit(1); /* fail */
2570        /* - */
2571        exit(0);
2572      ]])
2573    ],[
2574      AC_MSG_RESULT([yes])
2575      tst_works_inet_pton="yes"
2576    ],[
2577      AC_MSG_RESULT([no])
2578      tst_works_inet_pton="no"
2579    ])
2580  fi
2581  #
2582  if test "$tst_compi_inet_pton" = "yes" &&
2583    test "$tst_works_inet_pton" != "no"; then
2584    AC_MSG_CHECKING([if inet_pton usage allowed])
2585    if test "x$curl_disallow_inet_pton" != "xyes"; then
2586      AC_MSG_RESULT([yes])
2587      tst_allow_inet_pton="yes"
2588    else
2589      AC_MSG_RESULT([no])
2590      tst_allow_inet_pton="no"
2591    fi
2592  fi
2593  #
2594  AC_MSG_CHECKING([if inet_pton might be used])
2595  if test "$tst_links_inet_pton" = "yes" &&
2596     test "$tst_proto_inet_pton" = "yes" &&
2597     test "$tst_compi_inet_pton" = "yes" &&
2598     test "$tst_allow_inet_pton" = "yes" &&
2599     test "$tst_works_inet_pton" != "no"; then
2600    AC_MSG_RESULT([yes])
2601    AC_DEFINE_UNQUOTED(HAVE_INET_PTON, 1,
2602      [Define to 1 if you have a IPv6 capable working inet_pton function.])
2603    curl_cv_func_inet_pton="yes"
2604  else
2605    AC_MSG_RESULT([no])
2606    curl_cv_func_inet_pton="no"
2607  fi
2608])
2609
2610
2611dnl CURL_CHECK_FUNC_IOCTL
2612dnl -------------------------------------------------
2613dnl Verify if ioctl is available, prototyped, and
2614dnl can be compiled. If all of these are true, and
2615dnl usage has not been previously disallowed with
2616dnl shell variable curl_disallow_ioctl, then
2617dnl HAVE_IOCTL will be defined.
2618
2619AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [
2620  AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
2621  #
2622  tst_links_ioctl="unknown"
2623  tst_proto_ioctl="unknown"
2624  tst_compi_ioctl="unknown"
2625  tst_allow_ioctl="unknown"
2626  #
2627  AC_MSG_CHECKING([if ioctl can be linked])
2628  AC_LINK_IFELSE([
2629    AC_LANG_FUNC_LINK_TRY([ioctl])
2630  ],[
2631    AC_MSG_RESULT([yes])
2632    tst_links_ioctl="yes"
2633  ],[
2634    AC_MSG_RESULT([no])
2635    tst_links_ioctl="no"
2636  ])
2637  #
2638  if test "$tst_links_ioctl" = "yes"; then
2639    AC_MSG_CHECKING([if ioctl is prototyped])
2640    AC_EGREP_CPP([ioctl],[
2641      $curl_includes_stropts
2642    ],[
2643      AC_MSG_RESULT([yes])
2644      tst_proto_ioctl="yes"
2645    ],[
2646      AC_MSG_RESULT([no])
2647      tst_proto_ioctl="no"
2648    ])
2649  fi
2650  #
2651  if test "$tst_proto_ioctl" = "yes"; then
2652    AC_MSG_CHECKING([if ioctl is compilable])
2653    AC_COMPILE_IFELSE([
2654      AC_LANG_PROGRAM([[
2655        $curl_includes_stropts
2656      ]],[[
2657        if(0 != ioctl(0, 0, 0))
2658          return 1;
2659      ]])
2660    ],[
2661      AC_MSG_RESULT([yes])
2662      tst_compi_ioctl="yes"
2663    ],[
2664      AC_MSG_RESULT([no])
2665      tst_compi_ioctl="no"
2666    ])
2667  fi
2668  #
2669  if test "$tst_compi_ioctl" = "yes"; then
2670    AC_MSG_CHECKING([if ioctl usage allowed])
2671    if test "x$curl_disallow_ioctl" != "xyes"; then
2672      AC_MSG_RESULT([yes])
2673      tst_allow_ioctl="yes"
2674    else
2675      AC_MSG_RESULT([no])
2676      tst_allow_ioctl="no"
2677    fi
2678  fi
2679  #
2680  AC_MSG_CHECKING([if ioctl might be used])
2681  if test "$tst_links_ioctl" = "yes" &&
2682     test "$tst_proto_ioctl" = "yes" &&
2683     test "$tst_compi_ioctl" = "yes" &&
2684     test "$tst_allow_ioctl" = "yes"; then
2685    AC_MSG_RESULT([yes])
2686    AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
2687      [Define to 1 if you have the ioctl function.])
2688    curl_cv_func_ioctl="yes"
2689    CURL_CHECK_FUNC_IOCTL_FIONBIO
2690    CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
2691  else
2692    AC_MSG_RESULT([no])
2693    curl_cv_func_ioctl="no"
2694  fi
2695])
2696
2697
2698dnl CURL_CHECK_FUNC_IOCTL_FIONBIO
2699dnl -------------------------------------------------
2700dnl Verify if ioctl with the FIONBIO command is
2701dnl available, can be compiled, and seems to work. If
2702dnl all of these are true, then HAVE_IOCTL_FIONBIO
2703dnl will be defined.
2704
2705AC_DEFUN([CURL_CHECK_FUNC_IOCTL_FIONBIO], [
2706  #
2707  tst_compi_ioctl_fionbio="unknown"
2708  tst_allow_ioctl_fionbio="unknown"
2709  #
2710  if test "$curl_cv_func_ioctl" = "yes"; then
2711    AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
2712    AC_COMPILE_IFELSE([
2713      AC_LANG_PROGRAM([[
2714        $curl_includes_stropts
2715      ]],[[
2716        int flags = 0;
2717        if(0 != ioctl(0, FIONBIO, &flags))
2718          return 1;
2719      ]])
2720    ],[
2721      AC_MSG_RESULT([yes])
2722      tst_compi_ioctl_fionbio="yes"
2723    ],[
2724      AC_MSG_RESULT([no])
2725      tst_compi_ioctl_fionbio="no"
2726    ])
2727  fi
2728  #
2729  if test "$tst_compi_ioctl_fionbio" = "yes"; then
2730    AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
2731    if test "x$curl_disallow_ioctl_fionbio" != "xyes"; then
2732      AC_MSG_RESULT([yes])
2733      tst_allow_ioctl_fionbio="yes"
2734    else
2735      AC_MSG_RESULT([no])
2736      tst_allow_ioctl_fionbio="no"
2737    fi
2738  fi
2739  #
2740  AC_MSG_CHECKING([if ioctl FIONBIO might be used])
2741  if test "$tst_compi_ioctl_fionbio" = "yes" &&
2742     test "$tst_allow_ioctl_fionbio" = "yes"; then
2743    AC_MSG_RESULT([yes])
2744    AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
2745      [Define to 1 if you have a working ioctl FIONBIO function.])
2746    curl_cv_func_ioctl_fionbio="yes"
2747  else
2748    AC_MSG_RESULT([no])
2749    curl_cv_func_ioctl_fionbio="no"
2750  fi
2751])
2752
2753
2754dnl CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR
2755dnl -------------------------------------------------
2756dnl Verify if ioctl with the SIOCGIFADDR command is available,
2757dnl struct ifreq is defined, they can be compiled, and seem to
2758dnl work. If all of these are true, then HAVE_IOCTL_SIOCGIFADDR
2759dnl will be defined.
2760
2761AC_DEFUN([CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR], [
2762  #
2763  tst_compi_ioctl_siocgifaddr="unknown"
2764  tst_allow_ioctl_siocgifaddr="unknown"
2765  #
2766  if test "$curl_cv_func_ioctl" = "yes"; then
2767    AC_MSG_CHECKING([if ioctl SIOCGIFADDR is compilable])
2768    AC_COMPILE_IFELSE([
2769      AC_LANG_PROGRAM([[
2770        $curl_includes_stropts
2771        #include <net/if.h>
2772      ]],[[
2773        struct ifreq ifr;
2774        if(0 != ioctl(0, SIOCGIFADDR, &ifr))
2775          return 1;
2776      ]])
2777    ],[
2778      AC_MSG_RESULT([yes])
2779      tst_compi_ioctl_siocgifaddr="yes"
2780    ],[
2781      AC_MSG_RESULT([no])
2782      tst_compi_ioctl_siocgifaddr="no"
2783    ])
2784  fi
2785  #
2786  if test "$tst_compi_ioctl_siocgifaddr" = "yes"; then
2787    AC_MSG_CHECKING([if ioctl SIOCGIFADDR usage allowed])
2788    if test "x$curl_disallow_ioctl_siocgifaddr" != "xyes"; then
2789      AC_MSG_RESULT([yes])
2790      tst_allow_ioctl_siocgifaddr="yes"
2791    else
2792      AC_MSG_RESULT([no])
2793      tst_allow_ioctl_siocgifaddr="no"
2794    fi
2795  fi
2796  #
2797  AC_MSG_CHECKING([if ioctl SIOCGIFADDR might be used])
2798  if test "$tst_compi_ioctl_siocgifaddr" = "yes" &&
2799     test "$tst_allow_ioctl_siocgifaddr" = "yes"; then
2800    AC_MSG_RESULT([yes])
2801    AC_DEFINE_UNQUOTED(HAVE_IOCTL_SIOCGIFADDR, 1,
2802      [Define to 1 if you have a working ioctl SIOCGIFADDR function.])
2803    curl_cv_func_ioctl_siocgifaddr="yes"
2804  else
2805    AC_MSG_RESULT([no])
2806    curl_cv_func_ioctl_siocgifaddr="no"
2807  fi
2808])
2809
2810
2811dnl CURL_CHECK_FUNC_IOCTLSOCKET
2812dnl -------------------------------------------------
2813dnl Verify if ioctlsocket is available, prototyped, and
2814dnl can be compiled. If all of these are true, and
2815dnl usage has not been previously disallowed with
2816dnl shell variable curl_disallow_ioctlsocket, then
2817dnl HAVE_IOCTLSOCKET will be defined.
2818
2819AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [
2820  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2821  #
2822  tst_links_ioctlsocket="unknown"
2823  tst_proto_ioctlsocket="unknown"
2824  tst_compi_ioctlsocket="unknown"
2825  tst_allow_ioctlsocket="unknown"
2826  #
2827  AC_MSG_CHECKING([if ioctlsocket can be linked])
2828  AC_LINK_IFELSE([
2829    AC_LANG_PROGRAM([[
2830      $curl_includes_winsock2
2831    ]],[[
2832      if(0 != ioctlsocket(0, 0, 0))
2833        return 1;
2834    ]])
2835  ],[
2836    AC_MSG_RESULT([yes])
2837    tst_links_ioctlsocket="yes"
2838  ],[
2839    AC_MSG_RESULT([no])
2840    tst_links_ioctlsocket="no"
2841  ])
2842  #
2843  if test "$tst_links_ioctlsocket" = "yes"; then
2844    AC_MSG_CHECKING([if ioctlsocket is prototyped])
2845    AC_EGREP_CPP([ioctlsocket],[
2846      $curl_includes_winsock2
2847    ],[
2848      AC_MSG_RESULT([yes])
2849      tst_proto_ioctlsocket="yes"
2850    ],[
2851      AC_MSG_RESULT([no])
2852      tst_proto_ioctlsocket="no"
2853    ])
2854  fi
2855  #
2856  if test "$tst_proto_ioctlsocket" = "yes"; then
2857    AC_MSG_CHECKING([if ioctlsocket is compilable])
2858    AC_COMPILE_IFELSE([
2859      AC_LANG_PROGRAM([[
2860        $curl_includes_winsock2
2861      ]],[[
2862        if(0 != ioctlsocket(0, 0, 0))
2863          return 1;
2864      ]])
2865    ],[
2866      AC_MSG_RESULT([yes])
2867      tst_compi_ioctlsocket="yes"
2868    ],[
2869      AC_MSG_RESULT([no])
2870      tst_compi_ioctlsocket="no"
2871    ])
2872  fi
2873  #
2874  if test "$tst_compi_ioctlsocket" = "yes"; then
2875    AC_MSG_CHECKING([if ioctlsocket usage allowed])
2876    if test "x$curl_disallow_ioctlsocket" != "xyes"; then
2877      AC_MSG_RESULT([yes])
2878      tst_allow_ioctlsocket="yes"
2879    else
2880      AC_MSG_RESULT([no])
2881      tst_allow_ioctlsocket="no"
2882    fi
2883  fi
2884  #
2885  AC_MSG_CHECKING([if ioctlsocket might be used])
2886  if test "$tst_links_ioctlsocket" = "yes" &&
2887     test "$tst_proto_ioctlsocket" = "yes" &&
2888     test "$tst_compi_ioctlsocket" = "yes" &&
2889     test "$tst_allow_ioctlsocket" = "yes"; then
2890    AC_MSG_RESULT([yes])
2891    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
2892      [Define to 1 if you have the ioctlsocket function.])
2893    curl_cv_func_ioctlsocket="yes"
2894    CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
2895  else
2896    AC_MSG_RESULT([no])
2897    curl_cv_func_ioctlsocket="no"
2898  fi
2899])
2900
2901
2902dnl CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
2903dnl -------------------------------------------------
2904dnl Verify if ioctlsocket with the FIONBIO command is
2905dnl available, can be compiled, and seems to work. If
2906dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
2907dnl will be defined.
2908
2909AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
2910  #
2911  tst_compi_ioctlsocket_fionbio="unknown"
2912  tst_allow_ioctlsocket_fionbio="unknown"
2913  #
2914  if test "$curl_cv_func_ioctlsocket" = "yes"; then
2915    AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
2916    AC_COMPILE_IFELSE([
2917      AC_LANG_PROGRAM([[
2918        $curl_includes_winsock2
2919      ]],[[
2920        unsigned long flags = 0;
2921        if(0 != ioctlsocket(0, FIONBIO, &flags))
2922          return 1;
2923      ]])
2924    ],[
2925      AC_MSG_RESULT([yes])
2926      tst_compi_ioctlsocket_fionbio="yes"
2927    ],[
2928      AC_MSG_RESULT([no])
2929      tst_compi_ioctlsocket_fionbio="no"
2930    ])
2931  fi
2932  #
2933  if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
2934    AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
2935    if test "x$curl_disallow_ioctlsocket_fionbio" != "xyes"; then
2936      AC_MSG_RESULT([yes])
2937      tst_allow_ioctlsocket_fionbio="yes"
2938    else
2939      AC_MSG_RESULT([no])
2940      tst_allow_ioctlsocket_fionbio="no"
2941    fi
2942  fi
2943  #
2944  AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
2945  if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
2946     test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
2947    AC_MSG_RESULT([yes])
2948    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
2949      [Define to 1 if you have a working ioctlsocket FIONBIO function.])
2950    curl_cv_func_ioctlsocket_fionbio="yes"
2951  else
2952    AC_MSG_RESULT([no])
2953    curl_cv_func_ioctlsocket_fionbio="no"
2954  fi
2955])
2956
2957
2958dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
2959dnl -------------------------------------------------
2960dnl Verify if IoctlSocket is available, prototyped, and
2961dnl can be compiled. If all of these are true, and
2962dnl usage has not been previously disallowed with
2963dnl shell variable curl_disallow_ioctlsocket_camel,
2964dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
2965
2966AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
2967  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
2968  #
2969  tst_links_ioctlsocket_camel="unknown"
2970  tst_proto_ioctlsocket_camel="unknown"
2971  tst_compi_ioctlsocket_camel="unknown"
2972  tst_allow_ioctlsocket_camel="unknown"
2973  #
2974  AC_MSG_CHECKING([if IoctlSocket can be linked])
2975  AC_LINK_IFELSE([
2976    AC_LANG_PROGRAM([[
2977      $curl_includes_bsdsocket
2978    ]],[[
2979      IoctlSocket(0, 0, 0);
2980    ]])
2981  ],[
2982    AC_MSG_RESULT([yes])
2983    tst_links_ioctlsocket_camel="yes"
2984  ],[
2985    AC_MSG_RESULT([no])
2986    tst_links_ioctlsocket_camel="no"
2987  ])
2988  #
2989  if test "$tst_links_ioctlsocket_camel" = "yes"; then
2990    AC_MSG_CHECKING([if IoctlSocket is prototyped])
2991    AC_EGREP_CPP([IoctlSocket],[
2992      $curl_includes_bsdsocket
2993    ],[
2994      AC_MSG_RESULT([yes])
2995      tst_proto_ioctlsocket_camel="yes"
2996    ],[
2997      AC_MSG_RESULT([no])
2998      tst_proto_ioctlsocket_camel="no"
2999    ])
3000  fi
3001  #
3002  if test "$tst_proto_ioctlsocket_camel" = "yes"; then
3003    AC_MSG_CHECKING([if IoctlSocket is compilable])
3004    AC_COMPILE_IFELSE([
3005      AC_LANG_PROGRAM([[
3006        $curl_includes_bsdsocket
3007      ]],[[
3008        if(0 != IoctlSocket(0, 0, 0))
3009          return 1;
3010      ]])
3011    ],[
3012      AC_MSG_RESULT([yes])
3013      tst_compi_ioctlsocket_camel="yes"
3014    ],[
3015      AC_MSG_RESULT([no])
3016      tst_compi_ioctlsocket_camel="no"
3017    ])
3018  fi
3019  #
3020  if test "$tst_compi_ioctlsocket_camel" = "yes"; then
3021    AC_MSG_CHECKING([if IoctlSocket usage allowed])
3022    if test "x$curl_disallow_ioctlsocket_camel" != "xyes"; then
3023      AC_MSG_RESULT([yes])
3024      tst_allow_ioctlsocket_camel="yes"
3025    else
3026      AC_MSG_RESULT([no])
3027      tst_allow_ioctlsocket_camel="no"
3028    fi
3029  fi
3030  #
3031  AC_MSG_CHECKING([if IoctlSocket might be used])
3032  if test "$tst_links_ioctlsocket_camel" = "yes" &&
3033     test "$tst_proto_ioctlsocket_camel" = "yes" &&
3034     test "$tst_compi_ioctlsocket_camel" = "yes" &&
3035     test "$tst_allow_ioctlsocket_camel" = "yes"; then
3036    AC_MSG_RESULT([yes])
3037    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
3038      [Define to 1 if you have the IoctlSocket camel case function.])
3039    curl_cv_func_ioctlsocket_camel="yes"
3040    CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
3041  else
3042    AC_MSG_RESULT([no])
3043    curl_cv_func_ioctlsocket_camel="no"
3044  fi
3045])
3046
3047
3048dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
3049dnl -------------------------------------------------
3050dnl Verify if IoctlSocket with FIONBIO command is available,
3051dnl can be compiled, and seems to work. If all of these are
3052dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
3053
3054AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
3055  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
3056  #
3057  tst_compi_ioctlsocket_camel_fionbio="unknown"
3058  tst_allow_ioctlsocket_camel_fionbio="unknown"
3059  #
3060  if test "$curl_cv_func_ioctlsocket_camel" = "yes"; then
3061    AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
3062    AC_COMPILE_IFELSE([
3063      AC_LANG_PROGRAM([[
3064        $curl_includes_bsdsocket
3065      ]],[[
3066        long flags = 0;
3067        if(0 != IoctlSocket(0, FIONBIO, &flags))
3068          return 1;
3069      ]])
3070    ],[
3071      AC_MSG_RESULT([yes])
3072      tst_compi_ioctlsocket_camel_fionbio="yes"
3073    ],[
3074      AC_MSG_RESULT([no])
3075      tst_compi_ioctlsocket_camel_fionbio="no"
3076    ])
3077  fi
3078  #
3079  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
3080    AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
3081    if test "x$curl_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
3082      AC_MSG_RESULT([yes])
3083      tst_allow_ioctlsocket_camel_fionbio="yes"
3084    else
3085      AC_MSG_RESULT([no])
3086      tst_allow_ioctlsocket_camel_fionbio="no"
3087    fi
3088  fi
3089  #
3090  AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
3091  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
3092     test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
3093    AC_MSG_RESULT([yes])
3094    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
3095      [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
3096    curl_cv_func_ioctlsocket_camel_fionbio="yes"
3097  else
3098    AC_MSG_RESULT([no])
3099    curl_cv_func_ioctlsocket_camel_fionbio="no"
3100  fi
3101])
3102
3103
3104dnl CURL_CHECK_FUNC_MEMRCHR
3105dnl -------------------------------------------------
3106dnl Verify if memrchr is available, prototyped, and
3107dnl can be compiled. If all of these are true, and
3108dnl usage has not been previously disallowed with
3109dnl shell variable curl_disallow_memrchr, then
3110dnl HAVE_MEMRCHR will be defined.
3111
3112AC_DEFUN([CURL_CHECK_FUNC_MEMRCHR], [
3113  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3114  #
3115  tst_links_memrchr="unknown"
3116  tst_macro_memrchr="unknown"
3117  tst_proto_memrchr="unknown"
3118  tst_compi_memrchr="unknown"
3119  tst_allow_memrchr="unknown"
3120  #
3121  AC_MSG_CHECKING([if memrchr can be linked])
3122  AC_LINK_IFELSE([
3123    AC_LANG_FUNC_LINK_TRY([memrchr])
3124  ],[
3125    AC_MSG_RESULT([yes])
3126    tst_links_memrchr="yes"
3127  ],[
3128    AC_MSG_RESULT([no])
3129    tst_links_memrchr="no"
3130  ])
3131  #
3132  if test "$tst_links_memrchr" = "no"; then
3133    AC_MSG_CHECKING([if memrchr seems a macro])
3134    AC_LINK_IFELSE([
3135      AC_LANG_PROGRAM([[
3136        $curl_includes_string
3137      ]],[[
3138        if(0 != memrchr(0, 0, 0))
3139          return 1;
3140      ]])
3141    ],[
3142      AC_MSG_RESULT([yes])
3143      tst_macro_memrchr="yes"
3144    ],[
3145      AC_MSG_RESULT([no])
3146      tst_macro_memrchr="no"
3147    ])
3148  fi
3149  #
3150  if test "$tst_links_memrchr" = "yes"; then
3151    AC_MSG_CHECKING([if memrchr is prototyped])
3152    AC_EGREP_CPP([memrchr],[
3153      $curl_includes_string
3154    ],[
3155      AC_MSG_RESULT([yes])
3156      tst_proto_memrchr="yes"
3157    ],[
3158      AC_MSG_RESULT([no])
3159      tst_proto_memrchr="no"
3160    ])
3161  fi
3162  #
3163  if test "$tst_proto_memrchr" = "yes" ||
3164     test "$tst_macro_memrchr" = "yes"; then
3165    AC_MSG_CHECKING([if memrchr is compilable])
3166    AC_COMPILE_IFELSE([
3167      AC_LANG_PROGRAM([[
3168        $curl_includes_string
3169      ]],[[
3170        if(0 != memrchr(0, 0, 0))
3171          return 1;
3172      ]])
3173    ],[
3174      AC_MSG_RESULT([yes])
3175      tst_compi_memrchr="yes"
3176    ],[
3177      AC_MSG_RESULT([no])
3178      tst_compi_memrchr="no"
3179    ])
3180  fi
3181  #
3182  if test "$tst_compi_memrchr" = "yes"; then
3183    AC_MSG_CHECKING([if memrchr usage allowed])
3184    if test "x$curl_disallow_memrchr" != "xyes"; then
3185      AC_MSG_RESULT([yes])
3186      tst_allow_memrchr="yes"
3187    else
3188      AC_MSG_RESULT([no])
3189      tst_allow_memrchr="no"
3190    fi
3191  fi
3192  #
3193  AC_MSG_CHECKING([if memrchr might be used])
3194  if (test "$tst_proto_memrchr" = "yes" ||
3195      test "$tst_macro_memrchr" = "yes") &&
3196     test "$tst_compi_memrchr" = "yes" &&
3197     test "$tst_allow_memrchr" = "yes"; then
3198    AC_MSG_RESULT([yes])
3199    AC_DEFINE_UNQUOTED(HAVE_MEMRCHR, 1,
3200      [Define to 1 if you have the memrchr function or macro.])
3201    curl_cv_func_memrchr="yes"
3202  else
3203    AC_MSG_RESULT([no])
3204    curl_cv_func_memrchr="no"
3205  fi
3206])
3207
3208
3209dnl CURL_CHECK_FUNC_SIGACTION
3210dnl -------------------------------------------------
3211dnl Verify if sigaction is available, prototyped, and
3212dnl can be compiled. If all of these are true, and
3213dnl usage has not been previously disallowed with
3214dnl shell variable curl_disallow_sigaction, then
3215dnl HAVE_SIGACTION will be defined.
3216
3217AC_DEFUN([CURL_CHECK_FUNC_SIGACTION], [
3218  AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
3219  #
3220  tst_links_sigaction="unknown"
3221  tst_proto_sigaction="unknown"
3222  tst_compi_sigaction="unknown"
3223  tst_allow_sigaction="unknown"
3224  #
3225  AC_MSG_CHECKING([if sigaction can be linked])
3226  AC_LINK_IFELSE([
3227    AC_LANG_FUNC_LINK_TRY([sigaction])
3228  ],[
3229    AC_MSG_RESULT([yes])
3230    tst_links_sigaction="yes"
3231  ],[
3232    AC_MSG_RESULT([no])
3233    tst_links_sigaction="no"
3234  ])
3235  #
3236  if test "$tst_links_sigaction" = "yes"; then
3237    AC_MSG_CHECKING([if sigaction is prototyped])
3238    AC_EGREP_CPP([sigaction],[
3239      $curl_includes_signal
3240    ],[
3241      AC_MSG_RESULT([yes])
3242      tst_proto_sigaction="yes"
3243    ],[
3244      AC_MSG_RESULT([no])
3245      tst_proto_sigaction="no"
3246    ])
3247  fi
3248  #
3249  if test "$tst_proto_sigaction" = "yes"; then
3250    AC_MSG_CHECKING([if sigaction is compilable])
3251    AC_COMPILE_IFELSE([
3252      AC_LANG_PROGRAM([[
3253        $curl_includes_signal
3254      ]],[[
3255        if(0 != sigaction(0, 0, 0))
3256          return 1;
3257      ]])
3258    ],[
3259      AC_MSG_RESULT([yes])
3260      tst_compi_sigaction="yes"
3261    ],[
3262      AC_MSG_RESULT([no])
3263      tst_compi_sigaction="no"
3264    ])
3265  fi
3266  #
3267  if test "$tst_compi_sigaction" = "yes"; then
3268    AC_MSG_CHECKING([if sigaction usage allowed])
3269    if test "x$curl_disallow_sigaction" != "xyes"; then
3270      AC_MSG_RESULT([yes])
3271      tst_allow_sigaction="yes"
3272    else
3273      AC_MSG_RESULT([no])
3274      tst_allow_sigaction="no"
3275    fi
3276  fi
3277  #
3278  AC_MSG_CHECKING([if sigaction might be used])
3279  if test "$tst_links_sigaction" = "yes" &&
3280     test "$tst_proto_sigaction" = "yes" &&
3281     test "$tst_compi_sigaction" = "yes" &&
3282     test "$tst_allow_sigaction" = "yes"; then
3283    AC_MSG_RESULT([yes])
3284    AC_DEFINE_UNQUOTED(HAVE_SIGACTION, 1,
3285      [Define to 1 if you have the sigaction function.])
3286    curl_cv_func_sigaction="yes"
3287  else
3288    AC_MSG_RESULT([no])
3289    curl_cv_func_sigaction="no"
3290  fi
3291])
3292
3293
3294dnl CURL_CHECK_FUNC_SIGINTERRUPT
3295dnl -------------------------------------------------
3296dnl Verify if siginterrupt is available, prototyped, and
3297dnl can be compiled. If all of these are true, and
3298dnl usage has not been previously disallowed with
3299dnl shell variable curl_disallow_siginterrupt, then
3300dnl HAVE_SIGINTERRUPT will be defined.
3301
3302AC_DEFUN([CURL_CHECK_FUNC_SIGINTERRUPT], [
3303  AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
3304  #
3305  tst_links_siginterrupt="unknown"
3306  tst_proto_siginterrupt="unknown"
3307  tst_compi_siginterrupt="unknown"
3308  tst_allow_siginterrupt="unknown"
3309  #
3310  AC_MSG_CHECKING([if siginterrupt can be linked])
3311  AC_LINK_IFELSE([
3312    AC_LANG_FUNC_LINK_TRY([siginterrupt])
3313  ],[
3314    AC_MSG_RESULT([yes])
3315    tst_links_siginterrupt="yes"
3316  ],[
3317    AC_MSG_RESULT([no])
3318    tst_links_siginterrupt="no"
3319  ])
3320  #
3321  if test "$tst_links_siginterrupt" = "yes"; then
3322    AC_MSG_CHECKING([if siginterrupt is prototyped])
3323    AC_EGREP_CPP([siginterrupt],[
3324      $curl_includes_signal
3325    ],[
3326      AC_MSG_RESULT([yes])
3327      tst_proto_siginterrupt="yes"
3328    ],[
3329      AC_MSG_RESULT([no])
3330      tst_proto_siginterrupt="no"
3331    ])
3332  fi
3333  #
3334  if test "$tst_proto_siginterrupt" = "yes"; then
3335    AC_MSG_CHECKING([if siginterrupt is compilable])
3336    AC_COMPILE_IFELSE([
3337      AC_LANG_PROGRAM([[
3338        $curl_includes_signal
3339      ]],[[
3340        if(0 != siginterrupt(0, 0))
3341          return 1;
3342      ]])
3343    ],[
3344      AC_MSG_RESULT([yes])
3345      tst_compi_siginterrupt="yes"
3346    ],[
3347      AC_MSG_RESULT([no])
3348      tst_compi_siginterrupt="no"
3349    ])
3350  fi
3351  #
3352  if test "$tst_compi_siginterrupt" = "yes"; then
3353    AC_MSG_CHECKING([if siginterrupt usage allowed])
3354    if test "x$curl_disallow_siginterrupt" != "xyes"; then
3355      AC_MSG_RESULT([yes])
3356      tst_allow_siginterrupt="yes"
3357    else
3358      AC_MSG_RESULT([no])
3359      tst_allow_siginterrupt="no"
3360    fi
3361  fi
3362  #
3363  AC_MSG_CHECKING([if siginterrupt might be used])
3364  if test "$tst_links_siginterrupt" = "yes" &&
3365     test "$tst_proto_siginterrupt" = "yes" &&
3366     test "$tst_compi_siginterrupt" = "yes" &&
3367     test "$tst_allow_siginterrupt" = "yes"; then
3368    AC_MSG_RESULT([yes])
3369    AC_DEFINE_UNQUOTED(HAVE_SIGINTERRUPT, 1,
3370      [Define to 1 if you have the siginterrupt function.])
3371    curl_cv_func_siginterrupt="yes"
3372  else
3373    AC_MSG_RESULT([no])
3374    curl_cv_func_siginterrupt="no"
3375  fi
3376])
3377
3378
3379dnl CURL_CHECK_FUNC_SIGNAL
3380dnl -------------------------------------------------
3381dnl Verify if signal is available, prototyped, and
3382dnl can be compiled. If all of these are true, and
3383dnl usage has not been previously disallowed with
3384dnl shell variable curl_disallow_signal, then
3385dnl HAVE_SIGNAL will be defined.
3386
3387AC_DEFUN([CURL_CHECK_FUNC_SIGNAL], [
3388  AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
3389  #
3390  tst_links_signal="unknown"
3391  tst_proto_signal="unknown"
3392  tst_compi_signal="unknown"
3393  tst_allow_signal="unknown"
3394  #
3395  AC_MSG_CHECKING([if signal can be linked])
3396  AC_LINK_IFELSE([
3397    AC_LANG_FUNC_LINK_TRY([signal])
3398  ],[
3399    AC_MSG_RESULT([yes])
3400    tst_links_signal="yes"
3401  ],[
3402    AC_MSG_RESULT([no])
3403    tst_links_signal="no"
3404  ])
3405  #
3406  if test "$tst_links_signal" = "yes"; then
3407    AC_MSG_CHECKING([if signal is prototyped])
3408    AC_EGREP_CPP([signal],[
3409      $curl_includes_signal
3410    ],[
3411      AC_MSG_RESULT([yes])
3412      tst_proto_signal="yes"
3413    ],[
3414      AC_MSG_RESULT([no])
3415      tst_proto_signal="no"
3416    ])
3417  fi
3418  #
3419  if test "$tst_proto_signal" = "yes"; then
3420    AC_MSG_CHECKING([if signal is compilable])
3421    AC_COMPILE_IFELSE([
3422      AC_LANG_PROGRAM([[
3423        $curl_includes_signal
3424      ]],[[
3425        if(0 != signal(0, 0))
3426          return 1;
3427      ]])
3428    ],[
3429      AC_MSG_RESULT([yes])
3430      tst_compi_signal="yes"
3431    ],[
3432      AC_MSG_RESULT([no])
3433      tst_compi_signal="no"
3434    ])
3435  fi
3436  #
3437  if test "$tst_compi_signal" = "yes"; then
3438    AC_MSG_CHECKING([if signal usage allowed])
3439    if test "x$curl_disallow_signal" != "xyes"; then
3440      AC_MSG_RESULT([yes])
3441      tst_allow_signal="yes"
3442    else
3443      AC_MSG_RESULT([no])
3444      tst_allow_signal="no"
3445    fi
3446  fi
3447  #
3448  AC_MSG_CHECKING([if signal might be used])
3449  if test "$tst_links_signal" = "yes" &&
3450     test "$tst_proto_signal" = "yes" &&
3451     test "$tst_compi_signal" = "yes" &&
3452     test "$tst_allow_signal" = "yes"; then
3453    AC_MSG_RESULT([yes])
3454    AC_DEFINE_UNQUOTED(HAVE_SIGNAL, 1,
3455      [Define to 1 if you have the signal function.])
3456    curl_cv_func_signal="yes"
3457  else
3458    AC_MSG_RESULT([no])
3459    curl_cv_func_signal="no"
3460  fi
3461])
3462
3463
3464dnl CURL_CHECK_FUNC_SIGSETJMP
3465dnl -------------------------------------------------
3466dnl Verify if sigsetjmp is available, prototyped, and
3467dnl can be compiled. If all of these are true, and
3468dnl usage has not been previously disallowed with
3469dnl shell variable curl_disallow_sigsetjmp, then
3470dnl HAVE_SIGSETJMP will be defined.
3471
3472AC_DEFUN([CURL_CHECK_FUNC_SIGSETJMP], [
3473  AC_REQUIRE([CURL_INCLUDES_SETJMP])dnl
3474  #
3475  tst_links_sigsetjmp="unknown"
3476  tst_macro_sigsetjmp="unknown"
3477  tst_proto_sigsetjmp="unknown"
3478  tst_compi_sigsetjmp="unknown"
3479  tst_allow_sigsetjmp="unknown"
3480  #
3481  AC_MSG_CHECKING([if sigsetjmp can be linked])
3482  AC_LINK_IFELSE([
3483    AC_LANG_FUNC_LINK_TRY([sigsetjmp])
3484  ],[
3485    AC_MSG_RESULT([yes])
3486    tst_links_sigsetjmp="yes"
3487  ],[
3488    AC_MSG_RESULT([no])
3489    tst_links_sigsetjmp="no"
3490  ])
3491  #
3492  if test "$tst_links_sigsetjmp" = "no"; then
3493    AC_MSG_CHECKING([if sigsetjmp seems a macro])
3494    AC_LINK_IFELSE([
3495      AC_LANG_PROGRAM([[
3496        $curl_includes_setjmp
3497      ]],[[
3498        sigjmp_buf env;
3499        if(0 != sigsetjmp(env, 0))
3500          return 1;
3501      ]])
3502    ],[
3503      AC_MSG_RESULT([yes])
3504      tst_macro_sigsetjmp="yes"
3505    ],[
3506      AC_MSG_RESULT([no])
3507      tst_macro_sigsetjmp="no"
3508    ])
3509  fi
3510  #
3511  if test "$tst_links_sigsetjmp" = "yes"; then
3512    AC_MSG_CHECKING([if sigsetjmp is prototyped])
3513    AC_EGREP_CPP([sigsetjmp],[
3514      $curl_includes_setjmp
3515    ],[
3516      AC_MSG_RESULT([yes])
3517      tst_proto_sigsetjmp="yes"
3518    ],[
3519      AC_MSG_RESULT([no])
3520      tst_proto_sigsetjmp="no"
3521    ])
3522  fi
3523  #
3524  if test "$tst_proto_sigsetjmp" = "yes" ||
3525     test "$tst_macro_sigsetjmp" = "yes"; then
3526    AC_MSG_CHECKING([if sigsetjmp is compilable])
3527    AC_COMPILE_IFELSE([
3528      AC_LANG_PROGRAM([[
3529        $curl_includes_setjmp
3530      ]],[[
3531        sigjmp_buf env;
3532        if(0 != sigsetjmp(env, 0))
3533          return 1;
3534      ]])
3535    ],[
3536      AC_MSG_RESULT([yes])
3537      tst_compi_sigsetjmp="yes"
3538    ],[
3539      AC_MSG_RESULT([no])
3540      tst_compi_sigsetjmp="no"
3541    ])
3542  fi
3543  #
3544  if test "$tst_compi_sigsetjmp" = "yes"; then
3545    AC_MSG_CHECKING([if sigsetjmp usage allowed])
3546    if test "x$curl_disallow_sigsetjmp" != "xyes"; then
3547      AC_MSG_RESULT([yes])
3548      tst_allow_sigsetjmp="yes"
3549    else
3550      AC_MSG_RESULT([no])
3551      tst_allow_sigsetjmp="no"
3552    fi
3553  fi
3554  #
3555  AC_MSG_CHECKING([if sigsetjmp might be used])
3556  if (test "$tst_proto_sigsetjmp" = "yes" ||
3557      test "$tst_macro_sigsetjmp" = "yes") &&
3558     test "$tst_compi_sigsetjmp" = "yes" &&
3559     test "$tst_allow_sigsetjmp" = "yes"; then
3560    AC_MSG_RESULT([yes])
3561    AC_DEFINE_UNQUOTED(HAVE_SIGSETJMP, 1,
3562      [Define to 1 if you have the sigsetjmp function or macro.])
3563    curl_cv_func_sigsetjmp="yes"
3564  else
3565    AC_MSG_RESULT([no])
3566    curl_cv_func_sigsetjmp="no"
3567  fi
3568])
3569
3570
3571dnl CURL_CHECK_FUNC_SOCKET
3572dnl -------------------------------------------------
3573dnl Verify if socket is available, prototyped, and
3574dnl can be compiled. If all of these are true, and
3575dnl usage has not been previously disallowed with
3576dnl shell variable curl_disallow_socket, then
3577dnl HAVE_SOCKET will be defined.
3578
3579AC_DEFUN([CURL_CHECK_FUNC_SOCKET], [
3580  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
3581  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
3582  #
3583  tst_links_socket="unknown"
3584  tst_proto_socket="unknown"
3585  tst_compi_socket="unknown"
3586  tst_allow_socket="unknown"
3587  #
3588  AC_MSG_CHECKING([if socket can be linked])
3589  AC_LINK_IFELSE([
3590    AC_LANG_PROGRAM([[
3591      $curl_includes_winsock2
3592      $curl_includes_bsdsocket
3593      $curl_includes_sys_socket
3594    ]],[[
3595      if(0 != socket(0, 0, 0))
3596        return 1;
3597    ]])
3598  ],[
3599    AC_MSG_RESULT([yes])
3600    tst_links_socket="yes"
3601  ],[
3602    AC_MSG_RESULT([no])
3603    tst_links_socket="no"
3604  ])
3605  #
3606  if test "$tst_links_socket" = "yes"; then
3607    AC_MSG_CHECKING([if socket is prototyped])
3608    AC_EGREP_CPP([socket],[
3609      $curl_includes_winsock2
3610      $curl_includes_bsdsocket
3611      $curl_includes_sys_socket
3612    ],[
3613      AC_MSG_RESULT([yes])
3614      tst_proto_socket="yes"
3615    ],[
3616      AC_MSG_RESULT([no])
3617      tst_proto_socket="no"
3618    ])
3619  fi
3620  #
3621  if test "$tst_proto_socket" = "yes"; then
3622    AC_MSG_CHECKING([if socket is compilable])
3623    AC_COMPILE_IFELSE([
3624      AC_LANG_PROGRAM([[
3625        $curl_includes_winsock2
3626        $curl_includes_bsdsocket
3627        $curl_includes_sys_socket
3628      ]],[[
3629        if(0 != socket(0, 0, 0))
3630          return 1;
3631      ]])
3632    ],[
3633      AC_MSG_RESULT([yes])
3634      tst_compi_socket="yes"
3635    ],[
3636      AC_MSG_RESULT([no])
3637      tst_compi_socket="no"
3638    ])
3639  fi
3640  #
3641  if test "$tst_compi_socket" = "yes"; then
3642    AC_MSG_CHECKING([if socket usage allowed])
3643    if test "x$curl_disallow_socket" != "xyes"; then
3644      AC_MSG_RESULT([yes])
3645      tst_allow_socket="yes"
3646    else
3647      AC_MSG_RESULT([no])
3648      tst_allow_socket="no"
3649    fi
3650  fi
3651  #
3652  AC_MSG_CHECKING([if socket might be used])
3653  if test "$tst_links_socket" = "yes" &&
3654     test "$tst_proto_socket" = "yes" &&
3655     test "$tst_compi_socket" = "yes" &&
3656     test "$tst_allow_socket" = "yes"; then
3657    AC_MSG_RESULT([yes])
3658    AC_DEFINE_UNQUOTED(HAVE_SOCKET, 1,
3659      [Define to 1 if you have the socket function.])
3660    curl_cv_func_socket="yes"
3661  else
3662    AC_MSG_RESULT([no])
3663    curl_cv_func_socket="no"
3664  fi
3665])
3666
3667
3668dnl CURL_CHECK_FUNC_SOCKETPAIR
3669dnl -------------------------------------------------
3670dnl Verify if socketpair is available, prototyped, and
3671dnl can be compiled. If all of these are true, and
3672dnl usage has not been previously disallowed with
3673dnl shell variable curl_disallow_socketpair, then
3674dnl HAVE_SOCKETPAIR will be defined.
3675
3676AC_DEFUN([CURL_CHECK_FUNC_SOCKETPAIR], [
3677  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
3678  #
3679  tst_links_socketpair="unknown"
3680  tst_proto_socketpair="unknown"
3681  tst_compi_socketpair="unknown"
3682  tst_allow_socketpair="unknown"
3683  #
3684  AC_MSG_CHECKING([if socketpair can be linked])
3685  AC_LINK_IFELSE([
3686    AC_LANG_FUNC_LINK_TRY([socketpair])
3687  ],[
3688    AC_MSG_RESULT([yes])
3689    tst_links_socketpair="yes"
3690  ],[
3691    AC_MSG_RESULT([no])
3692    tst_links_socketpair="no"
3693  ])
3694  #
3695  if test "$tst_links_socketpair" = "yes"; then
3696    AC_MSG_CHECKING([if socketpair is prototyped])
3697    AC_EGREP_CPP([socketpair],[
3698      $curl_includes_sys_socket
3699    ],[
3700      AC_MSG_RESULT([yes])
3701      tst_proto_socketpair="yes"
3702    ],[
3703      AC_MSG_RESULT([no])
3704      tst_proto_socketpair="no"
3705    ])
3706  fi
3707  #
3708  if test "$tst_proto_socketpair" = "yes"; then
3709    AC_MSG_CHECKING([if socketpair is compilable])
3710    AC_COMPILE_IFELSE([
3711      AC_LANG_PROGRAM([[
3712        $curl_includes_sys_socket
3713      ]],[[
3714        int sv[2];
3715        if(0 != socketpair(0, 0, 0, sv))
3716          return 1;
3717      ]])
3718    ],[
3719      AC_MSG_RESULT([yes])
3720      tst_compi_socketpair="yes"
3721    ],[
3722      AC_MSG_RESULT([no])
3723      tst_compi_socketpair="no"
3724    ])
3725  fi
3726  #
3727  if test "$tst_compi_socketpair" = "yes"; then
3728    AC_MSG_CHECKING([if socketpair usage allowed])
3729    if test "x$curl_disallow_socketpair" != "xyes"; then
3730      AC_MSG_RESULT([yes])
3731      tst_allow_socketpair="yes"
3732    else
3733      AC_MSG_RESULT([no])
3734      tst_allow_socketpair="no"
3735    fi
3736  fi
3737  #
3738  AC_MSG_CHECKING([if socketpair might be used])
3739  if test "$tst_links_socketpair" = "yes" &&
3740     test "$tst_proto_socketpair" = "yes" &&
3741     test "$tst_compi_socketpair" = "yes" &&
3742     test "$tst_allow_socketpair" = "yes"; then
3743    AC_MSG_RESULT([yes])
3744    AC_DEFINE_UNQUOTED(HAVE_SOCKETPAIR, 1,
3745      [Define to 1 if you have the socketpair function.])
3746    curl_cv_func_socketpair="yes"
3747  else
3748    AC_MSG_RESULT([no])
3749    curl_cv_func_socketpair="no"
3750  fi
3751])
3752
3753
3754dnl CURL_CHECK_FUNC_STRCASECMP
3755dnl -------------------------------------------------
3756dnl Verify if strcasecmp is available, prototyped, and
3757dnl can be compiled. If all of these are true, and
3758dnl usage has not been previously disallowed with
3759dnl shell variable curl_disallow_strcasecmp, then
3760dnl HAVE_STRCASECMP will be defined.
3761
3762AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [
3763  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3764  #
3765  tst_links_strcasecmp="unknown"
3766  tst_proto_strcasecmp="unknown"
3767  tst_compi_strcasecmp="unknown"
3768  tst_allow_strcasecmp="unknown"
3769  #
3770  AC_MSG_CHECKING([if strcasecmp can be linked])
3771  AC_LINK_IFELSE([
3772    AC_LANG_FUNC_LINK_TRY([strcasecmp])
3773  ],[
3774    AC_MSG_RESULT([yes])
3775    tst_links_strcasecmp="yes"
3776  ],[
3777    AC_MSG_RESULT([no])
3778    tst_links_strcasecmp="no"
3779  ])
3780  #
3781  if test "$tst_links_strcasecmp" = "yes"; then
3782    AC_MSG_CHECKING([if strcasecmp is prototyped])
3783    AC_EGREP_CPP([strcasecmp],[
3784      $curl_includes_string
3785    ],[
3786      AC_MSG_RESULT([yes])
3787      tst_proto_strcasecmp="yes"
3788    ],[
3789      AC_MSG_RESULT([no])
3790      tst_proto_strcasecmp="no"
3791    ])
3792  fi
3793  #
3794  if test "$tst_proto_strcasecmp" = "yes"; then
3795    AC_MSG_CHECKING([if strcasecmp is compilable])
3796    AC_COMPILE_IFELSE([
3797      AC_LANG_PROGRAM([[
3798        $curl_includes_string
3799      ]],[[
3800        if(0 != strcasecmp(0, 0))
3801          return 1;
3802      ]])
3803    ],[
3804      AC_MSG_RESULT([yes])
3805      tst_compi_strcasecmp="yes"
3806    ],[
3807      AC_MSG_RESULT([no])
3808      tst_compi_strcasecmp="no"
3809    ])
3810  fi
3811  #
3812  if test "$tst_compi_strcasecmp" = "yes"; then
3813    AC_MSG_CHECKING([if strcasecmp usage allowed])
3814    if test "x$curl_disallow_strcasecmp" != "xyes"; then
3815      AC_MSG_RESULT([yes])
3816      tst_allow_strcasecmp="yes"
3817    else
3818      AC_MSG_RESULT([no])
3819      tst_allow_strcasecmp="no"
3820    fi
3821  fi
3822  #
3823  AC_MSG_CHECKING([if strcasecmp might be used])
3824  if test "$tst_links_strcasecmp" = "yes" &&
3825     test "$tst_proto_strcasecmp" = "yes" &&
3826     test "$tst_compi_strcasecmp" = "yes" &&
3827     test "$tst_allow_strcasecmp" = "yes"; then
3828    AC_MSG_RESULT([yes])
3829    AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
3830      [Define to 1 if you have the strcasecmp function.])
3831    curl_cv_func_strcasecmp="yes"
3832  else
3833    AC_MSG_RESULT([no])
3834    curl_cv_func_strcasecmp="no"
3835  fi
3836])
3837
3838dnl CURL_CHECK_FUNC_STRCMPI
3839dnl -------------------------------------------------
3840dnl Verify if strcmpi is available, prototyped, and
3841dnl can be compiled. If all of these are true, and
3842dnl usage has not been previously disallowed with
3843dnl shell variable curl_disallow_strcmpi, then
3844dnl HAVE_STRCMPI will be defined.
3845
3846AC_DEFUN([CURL_CHECK_FUNC_STRCMPI], [
3847  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3848  #
3849  tst_links_strcmpi="unknown"
3850  tst_proto_strcmpi="unknown"
3851  tst_compi_strcmpi="unknown"
3852  tst_allow_strcmpi="unknown"
3853  #
3854  AC_MSG_CHECKING([if strcmpi can be linked])
3855  AC_LINK_IFELSE([
3856    AC_LANG_FUNC_LINK_TRY([strcmpi])
3857  ],[
3858    AC_MSG_RESULT([yes])
3859    tst_links_strcmpi="yes"
3860  ],[
3861    AC_MSG_RESULT([no])
3862    tst_links_strcmpi="no"
3863  ])
3864  #
3865  if test "$tst_links_strcmpi" = "yes"; then
3866    AC_MSG_CHECKING([if strcmpi is prototyped])
3867    AC_EGREP_CPP([strcmpi],[
3868      $curl_includes_string
3869    ],[
3870      AC_MSG_RESULT([yes])
3871      tst_proto_strcmpi="yes"
3872    ],[
3873      AC_MSG_RESULT([no])
3874      tst_proto_strcmpi="no"
3875    ])
3876  fi
3877  #
3878  if test "$tst_proto_strcmpi" = "yes"; then
3879    AC_MSG_CHECKING([if strcmpi is compilable])
3880    AC_COMPILE_IFELSE([
3881      AC_LANG_PROGRAM([[
3882        $curl_includes_string
3883      ]],[[
3884        if(0 != strcmpi(0, 0))
3885          return 1;
3886      ]])
3887    ],[
3888      AC_MSG_RESULT([yes])
3889      tst_compi_strcmpi="yes"
3890    ],[
3891      AC_MSG_RESULT([no])
3892      tst_compi_strcmpi="no"
3893    ])
3894  fi
3895  #
3896  if test "$tst_compi_strcmpi" = "yes"; then
3897    AC_MSG_CHECKING([if strcmpi usage allowed])
3898    if test "x$curl_disallow_strcmpi" != "xyes"; then
3899      AC_MSG_RESULT([yes])
3900      tst_allow_strcmpi="yes"
3901    else
3902      AC_MSG_RESULT([no])
3903      tst_allow_strcmpi="no"
3904    fi
3905  fi
3906  #
3907  AC_MSG_CHECKING([if strcmpi might be used])
3908  if test "$tst_links_strcmpi" = "yes" &&
3909     test "$tst_proto_strcmpi" = "yes" &&
3910     test "$tst_compi_strcmpi" = "yes" &&
3911     test "$tst_allow_strcmpi" = "yes"; then
3912    AC_MSG_RESULT([yes])
3913    AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
3914      [Define to 1 if you have the strcmpi function.])
3915    curl_cv_func_strcmpi="yes"
3916  else
3917    AC_MSG_RESULT([no])
3918    curl_cv_func_strcmpi="no"
3919  fi
3920])
3921
3922
3923dnl CURL_CHECK_FUNC_STRDUP
3924dnl -------------------------------------------------
3925dnl Verify if strdup is available, prototyped, and
3926dnl can be compiled. If all of these are true, and
3927dnl usage has not been previously disallowed with
3928dnl shell variable curl_disallow_strdup, then
3929dnl HAVE_STRDUP will be defined.
3930
3931AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
3932  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
3933  #
3934  tst_links_strdup="unknown"
3935  tst_proto_strdup="unknown"
3936  tst_compi_strdup="unknown"
3937  tst_allow_strdup="unknown"
3938  #
3939  AC_MSG_CHECKING([if strdup can be linked])
3940  AC_LINK_IFELSE([
3941    AC_LANG_FUNC_LINK_TRY([strdup])
3942  ],[
3943    AC_MSG_RESULT([yes])
3944    tst_links_strdup="yes"
3945  ],[
3946    AC_MSG_RESULT([no])
3947    tst_links_strdup="no"
3948  ])
3949  #
3950  if test "$tst_links_strdup" = "yes"; then
3951    AC_MSG_CHECKING([if strdup is prototyped])
3952    AC_EGREP_CPP([strdup],[
3953      $curl_includes_string
3954    ],[
3955      AC_MSG_RESULT([yes])
3956      tst_proto_strdup="yes"
3957    ],[
3958      AC_MSG_RESULT([no])
3959      tst_proto_strdup="no"
3960    ])
3961  fi
3962  #
3963  if test "$tst_proto_strdup" = "yes"; then
3964    AC_MSG_CHECKING([if strdup is compilable])
3965    AC_COMPILE_IFELSE([
3966      AC_LANG_PROGRAM([[
3967        $curl_includes_string
3968      ]],[[
3969        if(0 != strdup(0))
3970          return 1;
3971      ]])
3972    ],[
3973      AC_MSG_RESULT([yes])
3974      tst_compi_strdup="yes"
3975    ],[
3976      AC_MSG_RESULT([no])
3977      tst_compi_strdup="no"
3978    ])
3979  fi
3980  #
3981  if test "$tst_compi_strdup" = "yes"; then
3982    AC_MSG_CHECKING([if strdup usage allowed])
3983    if test "x$curl_disallow_strdup" != "xyes"; then
3984      AC_MSG_RESULT([yes])
3985      tst_allow_strdup="yes"
3986    else
3987      AC_MSG_RESULT([no])
3988      tst_allow_strdup="no"
3989    fi
3990  fi
3991  #
3992  AC_MSG_CHECKING([if strdup might be used])
3993  if test "$tst_links_strdup" = "yes" &&
3994     test "$tst_proto_strdup" = "yes" &&
3995     test "$tst_compi_strdup" = "yes" &&
3996     test "$tst_allow_strdup" = "yes"; then
3997    AC_MSG_RESULT([yes])
3998    AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
3999      [Define to 1 if you have the strdup function.])
4000    curl_cv_func_strdup="yes"
4001  else
4002    AC_MSG_RESULT([no])
4003    curl_cv_func_strdup="no"
4004  fi
4005])
4006
4007
4008dnl CURL_CHECK_FUNC_STRERROR_R
4009dnl -------------------------------------------------
4010dnl Verify if strerror_r is available, prototyped, can be compiled and
4011dnl seems to work. If all of these are true, and usage has not been
4012dnl previously disallowed with shell variable curl_disallow_strerror_r,
4013dnl then HAVE_STRERROR_R will be defined, as well as one of
4014dnl HAVE_GLIBC_STRERROR_R or HAVE_POSIX_STRERROR_R.
4015dnl
4016dnl glibc-style strerror_r:
4017dnl
4018dnl      char *strerror_r(int errnum, char *workbuf, size_t bufsize);
4019dnl
4020dnl  glibc-style strerror_r returns a pointer to the error string,
4021dnl  and might use the provided workbuf as a scratch area if needed. A
4022dnl  quick test on a few systems shows that it's usually not used at all.
4023dnl
4024dnl POSIX-style strerror_r:
4025dnl
4026dnl      int strerror_r(int errnum, char *resultbuf, size_t bufsize);
4027dnl
4028dnl  POSIX-style strerror_r returns 0 upon successful completion and the
4029dnl  error string in the provided resultbuf.
4030dnl
4031
4032AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
4033  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4034  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4035  #
4036  tst_links_strerror_r="unknown"
4037  tst_proto_strerror_r="unknown"
4038  tst_compi_strerror_r="unknown"
4039  tst_glibc_strerror_r="unknown"
4040  tst_posix_strerror_r="unknown"
4041  tst_allow_strerror_r="unknown"
4042  tst_works_glibc_strerror_r="unknown"
4043  tst_works_posix_strerror_r="unknown"
4044  tst_glibc_strerror_r_type_arg3="unknown"
4045  tst_posix_strerror_r_type_arg3="unknown"
4046  #
4047  AC_MSG_CHECKING([if strerror_r can be linked])
4048  AC_LINK_IFELSE([
4049    AC_LANG_FUNC_LINK_TRY([strerror_r])
4050  ],[
4051    AC_MSG_RESULT([yes])
4052    tst_links_strerror_r="yes"
4053  ],[
4054    AC_MSG_RESULT([no])
4055    tst_links_strerror_r="no"
4056  ])
4057  #
4058  if test "$tst_links_strerror_r" = "yes"; then
4059    AC_MSG_CHECKING([if strerror_r is prototyped])
4060    AC_EGREP_CPP([strerror_r],[
4061      $curl_includes_string
4062    ],[
4063      AC_MSG_RESULT([yes])
4064      tst_proto_strerror_r="yes"
4065    ],[
4066      AC_MSG_RESULT([no])
4067      tst_proto_strerror_r="no"
4068    ])
4069  fi
4070  #
4071  if test "$tst_proto_strerror_r" = "yes"; then
4072    AC_MSG_CHECKING([if strerror_r is compilable])
4073    AC_COMPILE_IFELSE([
4074      AC_LANG_PROGRAM([[
4075        $curl_includes_string
4076      ]],[[
4077        if(0 != strerror_r(0, 0, 0))
4078          return 1;
4079      ]])
4080    ],[
4081      AC_MSG_RESULT([yes])
4082      tst_compi_strerror_r="yes"
4083    ],[
4084      AC_MSG_RESULT([no])
4085      tst_compi_strerror_r="no"
4086    ])
4087  fi
4088  #
4089  if test "$tst_compi_strerror_r" = "yes"; then
4090    AC_MSG_CHECKING([if strerror_r is glibc like])
4091    tst_glibc_strerror_r_type_arg3="unknown"
4092    for arg3 in 'size_t' 'int' 'unsigned int'; do
4093      if test "$tst_glibc_strerror_r_type_arg3" = "unknown"; then
4094        AC_COMPILE_IFELSE([
4095          AC_LANG_PROGRAM([[
4096            $curl_includes_string
4097            char *strerror_r(int errnum, char *workbuf, $arg3 bufsize);
4098          ]],[[
4099            if(0 != strerror_r(0, 0, 0))
4100              return 1;
4101          ]])
4102        ],[
4103          tst_glibc_strerror_r_type_arg3="$arg3"
4104        ])
4105      fi
4106    done
4107    case "$tst_glibc_strerror_r_type_arg3" in
4108      unknown)
4109        AC_MSG_RESULT([no])
4110        tst_glibc_strerror_r="no"
4111        ;;
4112      *)
4113        AC_MSG_RESULT([yes])
4114        tst_glibc_strerror_r="yes"
4115        ;;
4116    esac
4117  fi
4118  #
4119  dnl only do runtime verification when not cross-compiling
4120  if test "x$cross_compiling" != "xyes" &&
4121    test "$tst_glibc_strerror_r" = "yes"; then
4122    AC_MSG_CHECKING([if strerror_r seems to work])
4123    CURL_RUN_IFELSE([
4124      AC_LANG_PROGRAM([[
4125        $curl_includes_stdlib
4126        $curl_includes_string
4127#       include <errno.h>
4128      ]],[[
4129        char buffer[1024];
4130        char *string = 0;
4131        buffer[0] = '\0';
4132        string = strerror_r(EACCES, buffer, sizeof(buffer));
4133        if(!string)
4134          exit(1); /* fail */
4135        if(!string[0])
4136          exit(1); /* fail */
4137        else
4138          exit(0);
4139      ]])
4140    ],[
4141      AC_MSG_RESULT([yes])
4142      tst_works_glibc_strerror_r="yes"
4143    ],[
4144      AC_MSG_RESULT([no])
4145      tst_works_glibc_strerror_r="no"
4146    ])
4147  fi
4148  #
4149  if test "$tst_compi_strerror_r" = "yes" &&
4150    test "$tst_works_glibc_strerror_r" != "yes"; then
4151    AC_MSG_CHECKING([if strerror_r is POSIX like])
4152    tst_posix_strerror_r_type_arg3="unknown"
4153    for arg3 in 'size_t' 'int' 'unsigned int'; do
4154      if test "$tst_posix_strerror_r_type_arg3" = "unknown"; then
4155        AC_COMPILE_IFELSE([
4156          AC_LANG_PROGRAM([[
4157            $curl_includes_string
4158            int strerror_r(int errnum, char *resultbuf, $arg3 bufsize);
4159          ]],[[
4160            if(0 != strerror_r(0, 0, 0))
4161              return 1;
4162          ]])
4163        ],[
4164          tst_posix_strerror_r_type_arg3="$arg3"
4165        ])
4166      fi
4167    done
4168    case "$tst_posix_strerror_r_type_arg3" in
4169      unknown)
4170        AC_MSG_RESULT([no])
4171        tst_posix_strerror_r="no"
4172        ;;
4173      *)
4174        AC_MSG_RESULT([yes])
4175        tst_posix_strerror_r="yes"
4176        ;;
4177    esac
4178  fi
4179  #
4180  dnl only do runtime verification when not cross-compiling
4181  if test "x$cross_compiling" != "xyes" &&
4182    test "$tst_posix_strerror_r" = "yes"; then
4183    AC_MSG_CHECKING([if strerror_r seems to work])
4184    CURL_RUN_IFELSE([
4185      AC_LANG_PROGRAM([[
4186        $curl_includes_stdlib
4187        $curl_includes_string
4188#       include <errno.h>
4189      ]],[[
4190        char buffer[1024];
4191        int error = 1;
4192        buffer[0] = '\0';
4193        error = strerror_r(EACCES, buffer, sizeof(buffer));
4194        if(error)
4195          exit(1); /* fail */
4196        if(buffer[0] == '\0')
4197          exit(1); /* fail */
4198        else
4199          exit(0);
4200      ]])
4201    ],[
4202      AC_MSG_RESULT([yes])
4203      tst_works_posix_strerror_r="yes"
4204    ],[
4205      AC_MSG_RESULT([no])
4206      tst_works_posix_strerror_r="no"
4207    ])
4208  fi
4209  #
4210  if test "$tst_works_glibc_strerror_r" = "yes"; then
4211    tst_posix_strerror_r="no"
4212  fi
4213  if test "$tst_works_posix_strerror_r" = "yes"; then
4214    tst_glibc_strerror_r="no"
4215  fi
4216  if test "$tst_glibc_strerror_r" = "yes" &&
4217    test "$tst_works_glibc_strerror_r" != "no" &&
4218    test "$tst_posix_strerror_r" != "yes"; then
4219    tst_allow_strerror_r="check"
4220  fi
4221  if test "$tst_posix_strerror_r" = "yes" &&
4222    test "$tst_works_posix_strerror_r" != "no" &&
4223    test "$tst_glibc_strerror_r" != "yes"; then
4224    tst_allow_strerror_r="check"
4225  fi
4226  if test "$tst_allow_strerror_r" = "check"; then
4227    AC_MSG_CHECKING([if strerror_r usage allowed])
4228    if test "x$curl_disallow_strerror_r" != "xyes"; then
4229      AC_MSG_RESULT([yes])
4230      tst_allow_strerror_r="yes"
4231    else
4232      AC_MSG_RESULT([no])
4233      tst_allow_strerror_r="no"
4234    fi
4235  fi
4236  #
4237  AC_MSG_CHECKING([if strerror_r might be used])
4238  if test "$tst_links_strerror_r" = "yes" &&
4239     test "$tst_proto_strerror_r" = "yes" &&
4240     test "$tst_compi_strerror_r" = "yes" &&
4241     test "$tst_allow_strerror_r" = "yes"; then
4242    AC_MSG_RESULT([yes])
4243    if test "$tst_glibc_strerror_r" = "yes"; then
4244      AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
4245        [Define to 1 if you have the strerror_r function.])
4246      AC_DEFINE_UNQUOTED(HAVE_GLIBC_STRERROR_R, 1,
4247        [Define to 1 if you have a working glibc-style strerror_r function.])
4248    fi
4249    if test "$tst_posix_strerror_r" = "yes"; then
4250      AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
4251        [Define to 1 if you have the strerror_r function.])
4252      AC_DEFINE_UNQUOTED(HAVE_POSIX_STRERROR_R, 1,
4253        [Define to 1 if you have a working POSIX-style strerror_r function.])
4254    fi
4255    curl_cv_func_strerror_r="yes"
4256  else
4257    AC_MSG_RESULT([no])
4258    curl_cv_func_strerror_r="no"
4259  fi
4260  #
4261  if test "$tst_compi_strerror_r" = "yes" &&
4262     test "$tst_allow_strerror_r" = "unknown"; then
4263    AC_MSG_WARN([cannot determine strerror_r() style: edit lib/curl_config.h manually.])
4264  fi
4265  #
4266])
4267
4268
4269dnl CURL_CHECK_FUNC_STRICMP
4270dnl -------------------------------------------------
4271dnl Verify if stricmp is available, prototyped, and
4272dnl can be compiled. If all of these are true, and
4273dnl usage has not been previously disallowed with
4274dnl shell variable curl_disallow_stricmp, then
4275dnl HAVE_STRICMP will be defined.
4276
4277AC_DEFUN([CURL_CHECK_FUNC_STRICMP], [
4278  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4279  #
4280  tst_links_stricmp="unknown"
4281  tst_proto_stricmp="unknown"
4282  tst_compi_stricmp="unknown"
4283  tst_allow_stricmp="unknown"
4284  #
4285  AC_MSG_CHECKING([if stricmp can be linked])
4286  AC_LINK_IFELSE([
4287    AC_LANG_FUNC_LINK_TRY([stricmp])
4288  ],[
4289    AC_MSG_RESULT([yes])
4290    tst_links_stricmp="yes"
4291  ],[
4292    AC_MSG_RESULT([no])
4293    tst_links_stricmp="no"
4294  ])
4295  #
4296  if test "$tst_links_stricmp" = "yes"; then
4297    AC_MSG_CHECKING([if stricmp is prototyped])
4298    AC_EGREP_CPP([stricmp],[
4299      $curl_includes_string
4300    ],[
4301      AC_MSG_RESULT([yes])
4302      tst_proto_stricmp="yes"
4303    ],[
4304      AC_MSG_RESULT([no])
4305      tst_proto_stricmp="no"
4306    ])
4307  fi
4308  #
4309  if test "$tst_proto_stricmp" = "yes"; then
4310    AC_MSG_CHECKING([if stricmp is compilable])
4311    AC_COMPILE_IFELSE([
4312      AC_LANG_PROGRAM([[
4313        $curl_includes_string
4314      ]],[[
4315        if(0 != stricmp(0, 0))
4316          return 1;
4317      ]])
4318    ],[
4319      AC_MSG_RESULT([yes])
4320      tst_compi_stricmp="yes"
4321    ],[
4322      AC_MSG_RESULT([no])
4323      tst_compi_stricmp="no"
4324    ])
4325  fi
4326  #
4327  if test "$tst_compi_stricmp" = "yes"; then
4328    AC_MSG_CHECKING([if stricmp usage allowed])
4329    if test "x$curl_disallow_stricmp" != "xyes"; then
4330      AC_MSG_RESULT([yes])
4331      tst_allow_stricmp="yes"
4332    else
4333      AC_MSG_RESULT([no])
4334      tst_allow_stricmp="no"
4335    fi
4336  fi
4337  #
4338  AC_MSG_CHECKING([if stricmp might be used])
4339  if test "$tst_links_stricmp" = "yes" &&
4340     test "$tst_proto_stricmp" = "yes" &&
4341     test "$tst_compi_stricmp" = "yes" &&
4342     test "$tst_allow_stricmp" = "yes"; then
4343    AC_MSG_RESULT([yes])
4344    AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
4345      [Define to 1 if you have the stricmp function.])
4346    curl_cv_func_stricmp="yes"
4347  else
4348    AC_MSG_RESULT([no])
4349    curl_cv_func_stricmp="no"
4350  fi
4351])
4352
4353
4354dnl CURL_CHECK_FUNC_STRTOK_R
4355dnl -------------------------------------------------
4356dnl Verify if strtok_r is available, prototyped, and
4357dnl can be compiled. If all of these are true, and
4358dnl usage has not been previously disallowed with
4359dnl shell variable curl_disallow_strtok_r, then
4360dnl HAVE_STRTOK_R will be defined.
4361
4362AC_DEFUN([CURL_CHECK_FUNC_STRTOK_R], [
4363  AC_REQUIRE([CURL_INCLUDES_STRING])dnl
4364  #
4365  tst_links_strtok_r="unknown"
4366  tst_proto_strtok_r="unknown"
4367  tst_compi_strtok_r="unknown"
4368  tst_allow_strtok_r="unknown"
4369  #
4370  AC_MSG_CHECKING([if strtok_r can be linked])
4371  AC_LINK_IFELSE([
4372    AC_LANG_FUNC_LINK_TRY([strtok_r])
4373  ],[
4374    AC_MSG_RESULT([yes])
4375    tst_links_strtok_r="yes"
4376  ],[
4377    AC_MSG_RESULT([no])
4378    tst_links_strtok_r="no"
4379  ])
4380  #
4381  if test "$tst_links_strtok_r" = "yes"; then
4382    AC_MSG_CHECKING([if strtok_r is prototyped])
4383    AC_EGREP_CPP([strtok_r],[
4384      $curl_includes_string
4385    ],[
4386      AC_MSG_RESULT([yes])
4387      tst_proto_strtok_r="yes"
4388    ],[
4389      AC_MSG_RESULT([no])
4390      tst_proto_strtok_r="no"
4391    ])
4392  fi
4393  #
4394  if test "$tst_proto_strtok_r" = "yes"; then
4395    AC_MSG_CHECKING([if strtok_r is compilable])
4396    AC_COMPILE_IFELSE([
4397      AC_LANG_PROGRAM([[
4398        $curl_includes_string
4399      ]],[[
4400        if(0 != strtok_r(0, 0, 0))
4401          return 1;
4402      ]])
4403    ],[
4404      AC_MSG_RESULT([yes])
4405      tst_compi_strtok_r="yes"
4406    ],[
4407      AC_MSG_RESULT([no])
4408      tst_compi_strtok_r="no"
4409    ])
4410  fi
4411  #
4412  if test "$tst_compi_strtok_r" = "yes"; then
4413    AC_MSG_CHECKING([if strtok_r usage allowed])
4414    if test "x$curl_disallow_strtok_r" != "xyes"; then
4415      AC_MSG_RESULT([yes])
4416      tst_allow_strtok_r="yes"
4417    else
4418      AC_MSG_RESULT([no])
4419      tst_allow_strtok_r="no"
4420    fi
4421  fi
4422  #
4423  AC_MSG_CHECKING([if strtok_r might be used])
4424  if test "$tst_links_strtok_r" = "yes" &&
4425     test "$tst_proto_strtok_r" = "yes" &&
4426     test "$tst_compi_strtok_r" = "yes" &&
4427     test "$tst_allow_strtok_r" = "yes"; then
4428    AC_MSG_RESULT([yes])
4429    AC_DEFINE_UNQUOTED(HAVE_STRTOK_R, 1,
4430      [Define to 1 if you have the strtok_r function.])
4431    curl_cv_func_strtok_r="yes"
4432  else
4433    AC_MSG_RESULT([no])
4434    curl_cv_func_strtok_r="no"
4435  fi
4436])
4437
4438
4439dnl CURL_CHECK_FUNC_STRTOLL
4440dnl -------------------------------------------------
4441dnl Verify if strtoll is available, prototyped, and
4442dnl can be compiled. If all of these are true, and
4443dnl usage has not been previously disallowed with
4444dnl shell variable curl_disallow_strtoll, then
4445dnl HAVE_STRTOLL will be defined.
4446
4447AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
4448  AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
4449  #
4450  tst_links_strtoll="unknown"
4451  tst_proto_strtoll="unknown"
4452  tst_compi_strtoll="unknown"
4453  tst_allow_strtoll="unknown"
4454  #
4455  AC_MSG_CHECKING([if strtoll can be linked])
4456  AC_LINK_IFELSE([
4457    AC_LANG_FUNC_LINK_TRY([strtoll])
4458  ],[
4459    AC_MSG_RESULT([yes])
4460    tst_links_strtoll="yes"
4461  ],[
4462    AC_MSG_RESULT([no])
4463    tst_links_strtoll="no"
4464  ])
4465  #
4466  if test "$tst_links_strtoll" = "yes"; then
4467    AC_MSG_CHECKING([if strtoll is prototyped])
4468    AC_EGREP_CPP([strtoll],[
4469      $curl_includes_stdlib
4470    ],[
4471      AC_MSG_RESULT([yes])
4472      tst_proto_strtoll="yes"
4473    ],[
4474      AC_MSG_RESULT([no])
4475      tst_proto_strtoll="no"
4476    ])
4477  fi
4478  #
4479  if test "$tst_proto_strtoll" = "yes"; then
4480    AC_MSG_CHECKING([if strtoll is compilable])
4481    AC_COMPILE_IFELSE([
4482      AC_LANG_PROGRAM([[
4483        $curl_includes_stdlib
4484      ]],[[
4485        if(0 != strtoll(0, 0, 0))
4486          return 1;
4487      ]])
4488    ],[
4489      AC_MSG_RESULT([yes])
4490      tst_compi_strtoll="yes"
4491    ],[
4492      AC_MSG_RESULT([no])
4493      tst_compi_strtoll="no"
4494    ])
4495  fi
4496  #
4497  if test "$tst_compi_strtoll" = "yes"; then
4498    AC_MSG_CHECKING([if strtoll usage allowed])
4499    if test "x$curl_disallow_strtoll" != "xyes"; then
4500      AC_MSG_RESULT([yes])
4501      tst_allow_strtoll="yes"
4502    else
4503      AC_MSG_RESULT([no])
4504      tst_allow_strtoll="no"
4505    fi
4506  fi
4507  #
4508  AC_MSG_CHECKING([if strtoll might be used])
4509  if test "$tst_links_strtoll" = "yes" &&
4510     test "$tst_proto_strtoll" = "yes" &&
4511     test "$tst_compi_strtoll" = "yes" &&
4512     test "$tst_allow_strtoll" = "yes"; then
4513    AC_MSG_RESULT([yes])
4514    AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
4515      [Define to 1 if you have the strtoll function.])
4516    curl_cv_func_strtoll="yes"
4517  else
4518    AC_MSG_RESULT([no])
4519    curl_cv_func_strtoll="no"
4520  fi
4521])
4522
4523dnl CURL_RUN_IFELSE
4524dnl -------------------------------------------------
4525dnl Wrapper macro to use instead of AC_RUN_IFELSE. It
4526dnl sets LD_LIBRARY_PATH locally for this run only, from the
4527dnl CURL_LIBRARY_PATH variable. It keeps the LD_LIBRARY_PATH
4528dnl changes contained within this macro.
4529
4530AC_DEFUN([CURL_RUN_IFELSE], [
4531  case $host in
4532    *-apple-*)
4533      AC_RUN_IFELSE([AC_LANG_SOURCE([$1])], $2, $3, $4)
4534      ;;
4535    *)
4536      oldcc=$CC
4537      old=$LD_LIBRARY_PATH
4538      CC="sh ./run-compiler"
4539      LD_LIBRARY_PATH=$CURL_LIBRARY_PATH:$old
4540      export LD_LIBRARY_PATH
4541      AC_RUN_IFELSE([AC_LANG_SOURCE([$1])], $2, $3, $4)
4542      LD_LIBRARY_PATH=$old # restore
4543      CC=$oldcc
4544      ;;
4545  esac
4546])
4547
4548dnl CURL_COVERAGE
4549dnl --------------------------------------------------
4550dnl Switch on options and libs to build with gcc's code coverage.
4551dnl
4552
4553AC_DEFUN([CURL_COVERAGE],[
4554  AC_REQUIRE([AC_PROG_SED])
4555  AC_REQUIRE([AC_ARG_ENABLE])
4556  AC_MSG_CHECKING([for code coverage support])
4557  coverage="no"
4558  curl_coverage_msg="disabled"
4559
4560  dnl check if enabled by argument
4561  AC_ARG_ENABLE(code-coverage,
4562    AS_HELP_STRING([--enable-code-coverage], [Provide code coverage]),
4563    coverage="$enableval")
4564
4565  dnl if not gcc switch off again
4566  AS_IF([ test "$GCC" != "yes" ], coverage="no" )
4567  AC_MSG_RESULT($coverage)
4568
4569  if test "x$coverage" = "xyes"; then
4570    curl_coverage_msg="enabled"
4571
4572    AC_CHECK_TOOL([GCOV], [gcov], [gcov])
4573    if test -z "$GCOV"; then
4574      AC_MSG_ERROR([needs gcov for code coverage])
4575    fi
4576    AC_CHECK_PROG([LCOV], [lcov], [lcov])
4577    if test -z "$LCOV"; then
4578      AC_MSG_ERROR([needs lcov for code coverage])
4579    fi
4580
4581    CPPFLAGS="$CPPFLAGS -DNDEBUG"
4582    CFLAGS="$CFLAGS -O0 -g -fprofile-arcs -ftest-coverage"
4583    LIBS="$LIBS -lgcov"
4584  fi
4585])
4586
4587dnl CURL_ATOMIC
4588dnl -------------------------------------------------------------
4589dnl Check if _Atomic works. But only check if stdatomic.h exists.
4590dnl
4591AC_DEFUN([CURL_ATOMIC],[
4592  AC_CHECK_HEADERS(stdatomic.h, [
4593    AC_MSG_CHECKING([if _Atomic is available])
4594    AC_LINK_IFELSE([
4595      AC_LANG_PROGRAM([[
4596        $curl_includes_unistd
4597      ]],[[
4598        _Atomic int i = 0;
4599        i = 4;  // Force an atomic-write operation.
4600      ]])
4601    ],[
4602      AC_MSG_RESULT([yes])
4603      AC_DEFINE_UNQUOTED(HAVE_ATOMIC, 1,
4604        [Define to 1 if you have _Atomic support.])
4605      tst_atomic="yes"
4606    ],[
4607      AC_MSG_RESULT([no])
4608      tst_atomic="no"
4609    ])
4610  ])
4611])
4612
4613# Rewrite inspired by the functionality once provided by
4614# AX_COMPILE_CHECK_SIZEOF. Uses the switch() "trick" to find the size of the
4615# given type.
4616#
4617# This code fails to compile:
4618#
4619#   switch() { case 0: case 0: }
4620#
4621# By making the second case number a boolean check, it fails to compile the
4622# test code when the boolean is false and thus creating a zero, making it a
4623# duplicated case label. If the boolean equals true, it becomes a one, the
4624# code compiles and we know it was a match.
4625#
4626# The check iterates over all possible sizes and stops as soon it compiles
4627# error-free.
4628#
4629# Usage:
4630#
4631#   CURL_SIZEOF(TYPE, [HEADERS])
4632#
4633
4634AC_DEFUN([CURL_SIZEOF], [
4635  dnl The #define name to make autoheader put the name in curl_config.h.in
4636  define(TYPE, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
4637
4638  AC_MSG_CHECKING(size of $1)
4639  r=0
4640  dnl Check the sizes in a reasonable order
4641  for typesize in 8 4 2 16 1; do
4642    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4643#include <sys/types.h>
4644$2
4645]],
4646    [switch(0) {
4647      case 0:
4648      case (sizeof($1) == $typesize):;
4649    }
4650    ]) ],
4651      [
4652        r=$typesize],
4653      [
4654        r=0])
4655    dnl get out of the loop once matched
4656    if test $r -gt 0; then
4657      break;
4658    fi
4659  done
4660  if test $r -eq 0; then
4661    AC_MSG_ERROR([Failed to find size of $1])
4662  fi
4663  AC_MSG_RESULT($r)
4664  dnl lowercase and underscore instead of space
4665  tname=`echo "ac_cv_sizeof_$1" | tr A-Z a-z | tr " " "_"`
4666  eval "$tname=$r"
4667
4668  AC_DEFINE_UNQUOTED(TYPE, [$r], [Size of $1 in number of bytes])
4669
4670])
4671