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