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