improve detection of gethostname(), localtime_r() and strstr()
[platform/upstream/curl.git] / m4 / curl-functions.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2008, 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 # $Id$
22 #***************************************************************************
23
24 # File version for 'aclocal' use. Keep it a single number.
25 # serial 8
26
27
28 dnl CURL_INCLUDES_SIGNAL
29 dnl -------------------------------------------------
30 dnl Set up variable with list of headers that must be
31 dnl included when signal.h is to be included.
32
33 AC_DEFUN([CURL_INCLUDES_SIGNAL], [
34 curl_includes_signal="\
35 /* includes start */
36 #ifdef HAVE_SYS_TYPES_H
37 #  include <sys/types.h>
38 #endif
39 #ifdef HAVE_SIGNAL_H
40 #  include <signal.h>
41 #endif
42 /* includes end */"
43   AC_CHECK_HEADERS(
44     sys/types.h signal.h,
45     [], [], [$curl_includes_signal])
46 ])
47
48
49 dnl CURL_INCLUDES_STDIO
50 dnl -------------------------------------------------
51 dnl Set up variable with list of headers that must be
52 dnl included when stdio.h is to be included.
53
54 AC_DEFUN([CURL_INCLUDES_STDIO], [
55 curl_includes_stdio="\
56 /* includes start */
57 #ifdef HAVE_SYS_TYPES_H
58 #  include <sys/types.h>
59 #endif
60 #ifdef HAVE_STDIO_H
61 #  include <stdio.h>
62 #endif
63 /* includes end */"
64   AC_CHECK_HEADERS(
65     sys/types.h stdio.h,
66     [], [], [$curl_includes_stdio])
67 ])
68
69
70 dnl CURL_INCLUDES_STDLIB
71 dnl -------------------------------------------------
72 dnl Set up variable with list of headers that must be
73 dnl included when stdlib.h is to be included.
74
75 AC_DEFUN([CURL_INCLUDES_STDLIB], [
76 curl_includes_stdlib="\
77 /* includes start */
78 #ifdef HAVE_SYS_TYPES_H
79 #  include <sys/types.h>
80 #endif
81 #ifdef HAVE_STDLIB_H
82 #  include <stdlib.h>
83 #endif
84 /* includes end */"
85   AC_CHECK_HEADERS(
86     sys/types.h stdlib.h,
87     [], [], [$curl_includes_stdlib])
88 ])
89
90
91 dnl CURL_INCLUDES_STRING
92 dnl -------------------------------------------------
93 dnl Set up variable with list of headers that must be
94 dnl included when string(s).h is to be included.
95
96 AC_DEFUN([CURL_INCLUDES_STRING], [
97 curl_includes_string="\
98 /* includes start */
99 #ifdef HAVE_SYS_TYPES_H
100 #  include <sys/types.h>
101 #endif
102 #ifdef HAVE_STRING_H
103 #  include <string.h>
104 #endif
105 #ifdef HAVE_STRINGS_H
106 #  include <strings.h>
107 #endif
108 /* includes end */"
109   AC_CHECK_HEADERS(
110     sys/types.h string.h strings.h,
111     [], [], [$curl_includes_string])
112 ])
113
114
115 dnl CURL_INCLUDES_SYS_UIO
116 dnl -------------------------------------------------
117 dnl Set up variable with list of headers that must be
118 dnl included when sys/uio.h is to be included.
119
120 AC_DEFUN([CURL_INCLUDES_SYS_UIO], [
121 curl_includes_sys_uio="\
122 /* includes start */
123 #ifdef HAVE_SYS_TYPES_H
124 #  include <sys/types.h>
125 #endif
126 #ifdef HAVE_SYS_UIO_H
127 #  include <sys/uio.h>
128 #endif
129 /* includes end */"
130   AC_CHECK_HEADERS(
131     sys/types.h sys/uio.h,
132     [], [], [$curl_includes_sys_uio])
133 ])
134
135
136 dnl CURL_INCLUDES_TIME
137 dnl -------------------------------------------------
138 dnl Set up variable with list of headers that must be
139 dnl included when time.h is to be included.
140
141 AC_DEFUN([CURL_INCLUDES_TIME], [
142 AC_REQUIRE([AC_HEADER_TIME])dnl
143 curl_includes_time="\
144 /* includes start */
145 #ifdef HAVE_SYS_TYPES_H
146 #  include <sys/types.h>
147 #endif
148 #ifdef HAVE_SYS_TIME_H
149 #  include <sys/time.h>
150 #  ifdef TIME_WITH_SYS_TIME
151 #    include <time.h>
152 #  endif
153 #else
154 #  ifdef HAVE_TIME_H
155 #    include <time.h>
156 #  endif
157 #endif
158 /* includes end */"
159   AC_CHECK_HEADERS(
160     sys/types.h sys/time.h time.h,
161     [], [], [$curl_includes_time])
162 ])
163
164
165 dnl CURL_INCLUDES_UNISTD
166 dnl -------------------------------------------------
167 dnl Set up variable with list of headers that must be
168 dnl included when unistd.h is to be included.
169
170 AC_DEFUN([CURL_INCLUDES_UNISTD], [
171 curl_includes_unistd="\
172 /* includes start */
173 #ifdef HAVE_SYS_TYPES_H
174 #  include <sys/types.h>
175 #endif
176 #ifdef HAVE_UNISTD_H
177 #  include <unistd.h>
178 #endif
179 /* includes end */"
180   AC_CHECK_HEADERS(
181     sys/types.h unistd.h,
182     [], [], [$curl_includes_unistd])
183 ])
184
185
186 dnl CURL_CHECK_FUNC_FDOPEN
187 dnl -------------------------------------------------
188 dnl Verify if fdopen is available, prototyped, and
189 dnl can be compiled. If all of these are true, and
190 dnl usage has not been previously disallowed with
191 dnl shell variable curl_disallow_fdopen, then
192 dnl HAVE_FDOPEN will be defined.
193
194 AC_DEFUN([CURL_CHECK_FUNC_FDOPEN], [
195   AC_REQUIRE([CURL_INCLUDES_STDIO])dnl
196   #
197   tst_links_fdopen="unknown"
198   tst_proto_fdopen="unknown"
199   tst_compi_fdopen="unknown"
200   tst_allow_fdopen="unknown"
201   #
202   AC_MSG_CHECKING([if fdopen can be linked])
203   AC_LINK_IFELSE([
204     AC_LANG_FUNC_LINK_TRY([fdopen])
205   ],[
206     AC_MSG_RESULT([yes])
207     tst_links_fdopen="yes"
208   ],[
209     AC_MSG_RESULT([no])
210     tst_links_fdopen="no"
211   ])
212   #
213   if test "$tst_links_fdopen" = "yes"; then
214     AC_MSG_CHECKING([if fdopen is prototyped])
215     AC_EGREP_CPP([fdopen],[
216       $curl_includes_stdio
217     ],[
218       AC_MSG_RESULT([yes])
219       tst_proto_fdopen="yes"
220     ],[
221       AC_MSG_RESULT([no])
222       tst_proto_fdopen="no"
223     ])
224   fi
225   #
226   if test "$tst_proto_fdopen" = "yes"; then
227     AC_MSG_CHECKING([if fdopen is compilable])
228     AC_COMPILE_IFELSE([
229       AC_LANG_PROGRAM([[
230         $curl_includes_stdio
231       ]],[[
232         if(0 != fdopen(0, 0))
233           return 1;
234       ]])
235     ],[
236       AC_MSG_RESULT([yes])
237       tst_compi_fdopen="yes"
238     ],[
239       AC_MSG_RESULT([no])
240       tst_compi_fdopen="no"
241     ])
242   fi
243   #
244   if test "$tst_compi_fdopen" = "yes"; then
245     AC_MSG_CHECKING([if fdopen usage allowed])
246     if test "x$curl_disallow_fdopen" != "xyes"; then
247       AC_MSG_RESULT([yes])
248       tst_allow_fdopen="yes"
249     else
250       AC_MSG_RESULT([no])
251       tst_allow_fdopen="no"
252     fi
253   fi
254   #
255   AC_MSG_CHECKING([if fdopen might be used])
256   if test "$tst_links_fdopen" = "yes" &&
257      test "$tst_proto_fdopen" = "yes" &&
258      test "$tst_compi_fdopen" = "yes" &&
259      test "$tst_allow_fdopen" = "yes"; then
260     AC_MSG_RESULT([yes])
261     AC_DEFINE_UNQUOTED(HAVE_FDOPEN, 1,
262       [Define to 1 if you have the fdopen function.])
263     ac_cv_func_fdopen="yes"
264   else
265     AC_MSG_RESULT([no])
266     ac_cv_func_fdopen="no"
267   fi
268 ])
269
270
271 dnl CURL_CHECK_FUNC_FTRUNCATE
272 dnl -------------------------------------------------
273 dnl Verify if ftruncate is available, prototyped, and
274 dnl can be compiled. If all of these are true, and
275 dnl usage has not been previously disallowed with
276 dnl shell variable curl_disallow_ftruncate, then
277 dnl HAVE_FTRUNCATE will be defined.
278
279 AC_DEFUN([CURL_CHECK_FUNC_FTRUNCATE], [
280   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
281   #
282   tst_links_ftruncate="unknown"
283   tst_proto_ftruncate="unknown"
284   tst_compi_ftruncate="unknown"
285   tst_allow_ftruncate="unknown"
286   #
287   AC_MSG_CHECKING([if ftruncate can be linked])
288   AC_LINK_IFELSE([
289     AC_LANG_FUNC_LINK_TRY([ftruncate])
290   ],[
291     AC_MSG_RESULT([yes])
292     tst_links_ftruncate="yes"
293   ],[
294     AC_MSG_RESULT([no])
295     tst_links_ftruncate="no"
296   ])
297   #
298   if test "$tst_links_ftruncate" = "yes"; then
299     AC_MSG_CHECKING([if ftruncate is prototyped])
300     AC_EGREP_CPP([ftruncate],[
301       $curl_includes_unistd
302     ],[
303       AC_MSG_RESULT([yes])
304       tst_proto_ftruncate="yes"
305     ],[
306       AC_MSG_RESULT([no])
307       tst_proto_ftruncate="no"
308     ])
309   fi
310   #
311   if test "$tst_proto_ftruncate" = "yes"; then
312     AC_MSG_CHECKING([if ftruncate is compilable])
313     AC_COMPILE_IFELSE([
314       AC_LANG_PROGRAM([[
315         $curl_includes_unistd
316       ]],[[
317         if(0 != ftruncate(0, 0))
318           return 1;
319       ]])
320     ],[
321       AC_MSG_RESULT([yes])
322       tst_compi_ftruncate="yes"
323     ],[
324       AC_MSG_RESULT([no])
325       tst_compi_ftruncate="no"
326     ])
327   fi
328   #
329   if test "$tst_compi_ftruncate" = "yes"; then
330     AC_MSG_CHECKING([if ftruncate usage allowed])
331     if test "x$curl_disallow_ftruncate" != "xyes"; then
332       AC_MSG_RESULT([yes])
333       tst_allow_ftruncate="yes"
334     else
335       AC_MSG_RESULT([no])
336       tst_allow_ftruncate="no"
337     fi
338   fi
339   #
340   AC_MSG_CHECKING([if ftruncate might be used])
341   if test "$tst_links_ftruncate" = "yes" &&
342      test "$tst_proto_ftruncate" = "yes" &&
343      test "$tst_compi_ftruncate" = "yes" &&
344      test "$tst_allow_ftruncate" = "yes"; then
345     AC_MSG_RESULT([yes])
346     AC_DEFINE_UNQUOTED(HAVE_FTRUNCATE, 1,
347       [Define to 1 if you have the ftruncate function.])
348     ac_cv_func_ftruncate="yes"
349   else
350     AC_MSG_RESULT([no])
351     ac_cv_func_ftruncate="no"
352   fi
353 ])
354
355
356 dnl CURL_CHECK_FUNC_GETHOSTNAME
357 dnl -------------------------------------------------
358 dnl Verify if gethostname is available, prototyped, and
359 dnl can be compiled. If all of these are true, and
360 dnl usage has not been previously disallowed with
361 dnl shell variable curl_disallow_gethostname, then
362 dnl HAVE_GETHOSTNAME will be defined.
363
364 AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
365   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
366   #
367   tst_links_gethostname="unknown"
368   tst_proto_gethostname="unknown"
369   tst_compi_gethostname="unknown"
370   tst_allow_gethostname="unknown"
371   #
372   AC_MSG_CHECKING([if gethostname can be linked])
373   AC_LINK_IFELSE([
374     AC_LANG_FUNC_LINK_TRY([gethostname])
375   ],[
376     AC_MSG_RESULT([yes])
377     tst_links_gethostname="yes"
378   ],[
379     AC_MSG_RESULT([no])
380     tst_links_gethostname="no"
381   ])
382   #
383   if test "$tst_links_gethostname" = "yes"; then
384     AC_MSG_CHECKING([if gethostname is prototyped])
385     AC_EGREP_CPP([gethostname],[
386       $curl_includes_unistd
387     ],[
388       AC_MSG_RESULT([yes])
389       tst_proto_gethostname="yes"
390     ],[
391       AC_MSG_RESULT([no])
392       tst_proto_gethostname="no"
393     ])
394   fi
395   #
396   if test "$tst_proto_gethostname" = "yes"; then
397     AC_MSG_CHECKING([if gethostname is compilable])
398     AC_COMPILE_IFELSE([
399       AC_LANG_PROGRAM([[
400         $curl_includes_unistd
401       ]],[[
402         if(0 != gethostname(0, 0))
403           return 1;
404       ]])
405     ],[
406       AC_MSG_RESULT([yes])
407       tst_compi_gethostname="yes"
408     ],[
409       AC_MSG_RESULT([no])
410       tst_compi_gethostname="no"
411     ])
412   fi
413   #
414   if test "$tst_compi_gethostname" = "yes"; then
415     AC_MSG_CHECKING([if gethostname usage allowed])
416     if test "x$curl_disallow_gethostname" != "xyes"; then
417       AC_MSG_RESULT([yes])
418       tst_allow_gethostname="yes"
419     else
420       AC_MSG_RESULT([no])
421       tst_allow_gethostname="no"
422     fi
423   fi
424   #
425   AC_MSG_CHECKING([if gethostname might be used])
426   if test "$tst_links_gethostname" = "yes" &&
427      test "$tst_proto_gethostname" = "yes" &&
428      test "$tst_compi_gethostname" = "yes" &&
429      test "$tst_allow_gethostname" = "yes"; then
430     AC_MSG_RESULT([yes])
431     AC_DEFINE_UNQUOTED(HAVE_GETHOSTNAME, 1,
432       [Define to 1 if you have the gethostname function.])
433     ac_cv_func_gethostname="yes"
434   else
435     AC_MSG_RESULT([no])
436     ac_cv_func_gethostname="no"
437   fi
438 ])
439
440
441 dnl CURL_CHECK_FUNC_GMTIME_R
442 dnl -------------------------------------------------
443 dnl Verify if gmtime_r is available, prototyped, can
444 dnl be compiled and seems to work. If all of these are
445 dnl true, and usage has not been previously disallowed
446 dnl with shell variable curl_disallow_gmtime_r, then
447 dnl HAVE_GMTIME_R will be defined.
448
449 AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
450   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
451   #
452   tst_links_gmtime_r="unknown"
453   tst_proto_gmtime_r="unknown"
454   tst_compi_gmtime_r="unknown"
455   tst_works_gmtime_r="unknown"
456   tst_allow_gmtime_r="unknown"
457   #
458   AC_MSG_CHECKING([if gmtime_r can be linked])
459   AC_LINK_IFELSE([
460     AC_LANG_FUNC_LINK_TRY([gmtime_r])
461   ],[
462     AC_MSG_RESULT([yes])
463     tst_links_gmtime_r="yes"
464   ],[
465     AC_MSG_RESULT([no])
466     tst_links_gmtime_r="no"
467   ])
468   #
469   if test "$tst_links_gmtime_r" = "yes"; then
470     AC_MSG_CHECKING([if gmtime_r is prototyped])
471     AC_EGREP_CPP([gmtime_r],[
472       $curl_includes_time
473     ],[
474       AC_MSG_RESULT([yes])
475       tst_proto_gmtime_r="yes"
476     ],[
477       AC_MSG_RESULT([no])
478       tst_proto_gmtime_r="no"
479     ])
480   fi
481   #
482   if test "$tst_proto_gmtime_r" = "yes"; then
483     AC_MSG_CHECKING([if gmtime_r is compilable])
484     AC_COMPILE_IFELSE([
485       AC_LANG_PROGRAM([[
486         $curl_includes_time
487       ]],[[
488         if(0 != gmtime_r(0, 0))
489           return 1;
490       ]])
491     ],[
492       AC_MSG_RESULT([yes])
493       tst_compi_gmtime_r="yes"
494     ],[
495       AC_MSG_RESULT([no])
496       tst_compi_gmtime_r="no"
497     ])
498   fi
499   #
500   dnl only do runtime verification when not cross-compiling
501   if test "x$cross_compiling" != "xyes" &&
502     test "$tst_compi_gmtime_r" = "yes"; then
503     AC_MSG_CHECKING([if gmtime_r seems to work])
504     AC_RUN_IFELSE([
505       AC_LANG_PROGRAM([[
506         $curl_includes_time
507       ]],[[
508         time_t local = 1170352587;
509         struct tm *gmt = 0;
510         struct tm result;
511         gmt = gmtime_r(&local, &result);
512         if(gmt)
513           exit(0);
514         else
515           exit(1);
516       ]])
517     ],[
518       AC_MSG_RESULT([yes])
519       tst_works_gmtime_r="yes"
520     ],[
521       AC_MSG_RESULT([no])
522       tst_works_gmtime_r="no"
523     ])
524   fi
525   #
526   if test "$tst_compi_gmtime_r" = "yes" &&
527     test "$tst_works_gmtime_r" != "no"; then
528     AC_MSG_CHECKING([if gmtime_r usage allowed])
529     if test "x$curl_disallow_gmtime_r" != "xyes"; then
530       AC_MSG_RESULT([yes])
531       tst_allow_gmtime_r="yes"
532     else
533       AC_MSG_RESULT([no])
534       tst_allow_gmtime_r="no"
535     fi
536   fi
537   #
538   AC_MSG_CHECKING([if gmtime_r might be used])
539   if test "$tst_links_gmtime_r" = "yes" &&
540      test "$tst_proto_gmtime_r" = "yes" &&
541      test "$tst_compi_gmtime_r" = "yes" &&
542      test "$tst_allow_gmtime_r" = "yes" &&
543      test "$tst_works_gmtime_r" != "no"; then
544     AC_MSG_RESULT([yes])
545     AC_DEFINE_UNQUOTED(HAVE_GMTIME_R, 1,
546       [Define to 1 if you have a working gmtime_r function.])
547     ac_cv_func_gmtime_r="yes"
548   else
549     AC_MSG_RESULT([no])
550     ac_cv_func_gmtime_r="no"
551   fi
552 ])
553
554
555 dnl CURL_CHECK_FUNC_LOCALTIME_R
556 dnl -------------------------------------------------
557 dnl Verify if localtime_r is available, prototyped, can
558 dnl be compiled and seems to work. If all of these are
559 dnl true, and usage has not been previously disallowed
560 dnl with shell variable curl_disallow_localtime_r, then
561 dnl HAVE_LOCALTIME_R will be defined.
562
563 AC_DEFUN([CURL_CHECK_FUNC_LOCALTIME_R], [
564   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
565   #
566   tst_links_localtime_r="unknown"
567   tst_proto_localtime_r="unknown"
568   tst_compi_localtime_r="unknown"
569   tst_works_localtime_r="unknown"
570   tst_allow_localtime_r="unknown"
571   #
572   AC_MSG_CHECKING([if localtime_r can be linked])
573   AC_LINK_IFELSE([
574     AC_LANG_FUNC_LINK_TRY([localtime_r])
575   ],[
576     AC_MSG_RESULT([yes])
577     tst_links_localtime_r="yes"
578   ],[
579     AC_MSG_RESULT([no])
580     tst_links_localtime_r="no"
581   ])
582   #
583   if test "$tst_links_localtime_r" = "yes"; then
584     AC_MSG_CHECKING([if localtime_r is prototyped])
585     AC_EGREP_CPP([localtime_r],[
586       $curl_includes_time
587     ],[
588       AC_MSG_RESULT([yes])
589       tst_proto_localtime_r="yes"
590     ],[
591       AC_MSG_RESULT([no])
592       tst_proto_localtime_r="no"
593     ])
594   fi
595   #
596   if test "$tst_proto_localtime_r" = "yes"; then
597     AC_MSG_CHECKING([if localtime_r is compilable])
598     AC_COMPILE_IFELSE([
599       AC_LANG_PROGRAM([[
600         $curl_includes_time
601       ]],[[
602         if(0 != localtime_r(0, 0))
603           return 1;
604       ]])
605     ],[
606       AC_MSG_RESULT([yes])
607       tst_compi_localtime_r="yes"
608     ],[
609       AC_MSG_RESULT([no])
610       tst_compi_localtime_r="no"
611     ])
612   fi
613   #
614   dnl only do runtime verification when not cross-compiling
615   if test "x$cross_compiling" != "xyes" &&
616     test "$tst_compi_localtime_r" = "yes"; then
617     AC_MSG_CHECKING([if localtime_r seems to work])
618     AC_RUN_IFELSE([
619       AC_LANG_PROGRAM([[
620         $curl_includes_time
621       ]],[[
622         time_t clock = 1170352587;
623         struct tm *tmp = 0;
624         struct tm result;
625         tmp = localtime_r(&clock, &result);
626         if(tmp)
627           exit(0);
628         else
629           exit(1);
630       ]])
631     ],[
632       AC_MSG_RESULT([yes])
633       tst_works_localtime_r="yes"
634     ],[
635       AC_MSG_RESULT([no])
636       tst_works_localtime_r="no"
637     ])
638   fi
639   #
640   if test "$tst_compi_localtime_r" = "yes" &&
641     test "$tst_works_localtime_r" != "no"; then
642     AC_MSG_CHECKING([if localtime_r usage allowed])
643     if test "x$curl_disallow_localtime_r" != "xyes"; then
644       AC_MSG_RESULT([yes])
645       tst_allow_localtime_r="yes"
646     else
647       AC_MSG_RESULT([no])
648       tst_allow_localtime_r="no"
649     fi
650   fi
651   #
652   AC_MSG_CHECKING([if localtime_r might be used])
653   if test "$tst_links_localtime_r" = "yes" &&
654      test "$tst_proto_localtime_r" = "yes" &&
655      test "$tst_compi_localtime_r" = "yes" &&
656      test "$tst_allow_localtime_r" = "yes" &&
657      test "$tst_works_localtime_r" != "no"; then
658     AC_MSG_RESULT([yes])
659     AC_DEFINE_UNQUOTED(HAVE_LOCALTIME_R, 1,
660       [Define to 1 if you have a working localtime_r function.])
661     ac_cv_func_localtime_r="yes"
662   else
663     AC_MSG_RESULT([no])
664     ac_cv_func_localtime_r="no"
665   fi
666 ])
667
668
669 dnl CURL_CHECK_FUNC_SIGACTION
670 dnl -------------------------------------------------
671 dnl Verify if sigaction is available, prototyped, and
672 dnl can be compiled. If all of these are true, and
673 dnl usage has not been previously disallowed with
674 dnl shell variable curl_disallow_sigaction, then
675 dnl HAVE_SIGACTION will be defined.
676
677 AC_DEFUN([CURL_CHECK_FUNC_SIGACTION], [
678   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
679   #
680   tst_links_sigaction="unknown"
681   tst_proto_sigaction="unknown"
682   tst_compi_sigaction="unknown"
683   tst_allow_sigaction="unknown"
684   #
685   AC_MSG_CHECKING([if sigaction can be linked])
686   AC_LINK_IFELSE([
687     AC_LANG_FUNC_LINK_TRY([sigaction])
688   ],[
689     AC_MSG_RESULT([yes])
690     tst_links_sigaction="yes"
691   ],[
692     AC_MSG_RESULT([no])
693     tst_links_sigaction="no"
694   ])
695   #
696   if test "$tst_links_sigaction" = "yes"; then
697     AC_MSG_CHECKING([if sigaction is prototyped])
698     AC_EGREP_CPP([sigaction],[
699       $curl_includes_signal
700     ],[
701       AC_MSG_RESULT([yes])
702       tst_proto_sigaction="yes"
703     ],[
704       AC_MSG_RESULT([no])
705       tst_proto_sigaction="no"
706     ])
707   fi
708   #
709   if test "$tst_proto_sigaction" = "yes"; then
710     AC_MSG_CHECKING([if sigaction is compilable])
711     AC_COMPILE_IFELSE([
712       AC_LANG_PROGRAM([[
713         $curl_includes_signal
714       ]],[[
715         if(0 != sigaction(0, 0, 0))
716           return 1;
717       ]])
718     ],[
719       AC_MSG_RESULT([yes])
720       tst_compi_sigaction="yes"
721     ],[
722       AC_MSG_RESULT([no])
723       tst_compi_sigaction="no"
724     ])
725   fi
726   #
727   if test "$tst_compi_sigaction" = "yes"; then
728     AC_MSG_CHECKING([if sigaction usage allowed])
729     if test "x$curl_disallow_sigaction" != "xyes"; then
730       AC_MSG_RESULT([yes])
731       tst_allow_sigaction="yes"
732     else
733       AC_MSG_RESULT([no])
734       tst_allow_sigaction="no"
735     fi
736   fi
737   #
738   AC_MSG_CHECKING([if sigaction might be used])
739   if test "$tst_links_sigaction" = "yes" &&
740      test "$tst_proto_sigaction" = "yes" &&
741      test "$tst_compi_sigaction" = "yes" &&
742      test "$tst_allow_sigaction" = "yes"; then
743     AC_MSG_RESULT([yes])
744     AC_DEFINE_UNQUOTED(HAVE_SIGACTION, 1,
745       [Define to 1 if you have the sigaction function.])
746     ac_cv_func_sigaction="yes"
747   else
748     AC_MSG_RESULT([no])
749     ac_cv_func_sigaction="no"
750   fi
751 ])
752
753
754 dnl CURL_CHECK_FUNC_STRCASECMP
755 dnl -------------------------------------------------
756 dnl Verify if strcasecmp is available, prototyped, and
757 dnl can be compiled. If all of these are true, and
758 dnl usage has not been previously disallowed with
759 dnl shell variable curl_disallow_strcasecmp, then
760 dnl HAVE_STRCASECMP will be defined.
761
762 AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [
763   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
764   #
765   tst_links_strcasecmp="unknown"
766   tst_proto_strcasecmp="unknown"
767   tst_compi_strcasecmp="unknown"
768   tst_allow_strcasecmp="unknown"
769   #
770   AC_MSG_CHECKING([if strcasecmp can be linked])
771   AC_LINK_IFELSE([
772     AC_LANG_FUNC_LINK_TRY([strcasecmp])
773   ],[
774     AC_MSG_RESULT([yes])
775     tst_links_strcasecmp="yes"
776   ],[
777     AC_MSG_RESULT([no])
778     tst_links_strcasecmp="no"
779   ])
780   #
781   if test "$tst_links_strcasecmp" = "yes"; then
782     AC_MSG_CHECKING([if strcasecmp is prototyped])
783     AC_EGREP_CPP([strcasecmp],[
784       $curl_includes_string
785     ],[
786       AC_MSG_RESULT([yes])
787       tst_proto_strcasecmp="yes"
788     ],[
789       AC_MSG_RESULT([no])
790       tst_proto_strcasecmp="no"
791     ])
792   fi
793   #
794   if test "$tst_proto_strcasecmp" = "yes"; then
795     AC_MSG_CHECKING([if strcasecmp is compilable])
796     AC_COMPILE_IFELSE([
797       AC_LANG_PROGRAM([[
798         $curl_includes_string
799       ]],[[
800         if(0 != strcasecmp(0, 0))
801           return 1;
802       ]])
803     ],[
804       AC_MSG_RESULT([yes])
805       tst_compi_strcasecmp="yes"
806     ],[
807       AC_MSG_RESULT([no])
808       tst_compi_strcasecmp="no"
809     ])
810   fi
811   #
812   if test "$tst_compi_strcasecmp" = "yes"; then
813     AC_MSG_CHECKING([if strcasecmp usage allowed])
814     if test "x$curl_disallow_strcasecmp" != "xyes"; then
815       AC_MSG_RESULT([yes])
816       tst_allow_strcasecmp="yes"
817     else
818       AC_MSG_RESULT([no])
819       tst_allow_strcasecmp="no"
820     fi
821   fi
822   #
823   AC_MSG_CHECKING([if strcasecmp might be used])
824   if test "$tst_links_strcasecmp" = "yes" &&
825      test "$tst_proto_strcasecmp" = "yes" &&
826      test "$tst_compi_strcasecmp" = "yes" &&
827      test "$tst_allow_strcasecmp" = "yes"; then
828     AC_MSG_RESULT([yes])
829     AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
830       [Define to 1 if you have the strcasecmp function.])
831     ac_cv_func_strcasecmp="yes"
832   else
833     AC_MSG_RESULT([no])
834     ac_cv_func_strcasecmp="no"
835   fi
836 ])
837
838
839 dnl CURL_CHECK_FUNC_STRCASESTR
840 dnl -------------------------------------------------
841 dnl Verify if strcasestr is available, prototyped, and
842 dnl can be compiled. If all of these are true, and
843 dnl usage has not been previously disallowed with
844 dnl shell variable curl_disallow_strcasestr, then
845 dnl HAVE_STRCASESTR will be defined.
846
847 AC_DEFUN([CURL_CHECK_FUNC_STRCASESTR], [
848   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
849   #
850   tst_links_strcasestr="unknown"
851   tst_proto_strcasestr="unknown"
852   tst_compi_strcasestr="unknown"
853   tst_allow_strcasestr="unknown"
854   #
855   AC_MSG_CHECKING([if strcasestr can be linked])
856   AC_LINK_IFELSE([
857     AC_LANG_FUNC_LINK_TRY([strcasestr])
858   ],[
859     AC_MSG_RESULT([yes])
860     tst_links_strcasestr="yes"
861   ],[
862     AC_MSG_RESULT([no])
863     tst_links_strcasestr="no"
864   ])
865   #
866   if test "$tst_links_strcasestr" = "yes"; then
867     AC_MSG_CHECKING([if strcasestr is prototyped])
868     AC_EGREP_CPP([strcasestr],[
869       $curl_includes_string
870     ],[
871       AC_MSG_RESULT([yes])
872       tst_proto_strcasestr="yes"
873     ],[
874       AC_MSG_RESULT([no])
875       tst_proto_strcasestr="no"
876     ])
877   fi
878   #
879   if test "$tst_proto_strcasestr" = "yes"; then
880     AC_MSG_CHECKING([if strcasestr is compilable])
881     AC_COMPILE_IFELSE([
882       AC_LANG_PROGRAM([[
883         $curl_includes_string
884       ]],[[
885         if(0 != strcasestr(0, 0))
886           return 1;
887       ]])
888     ],[
889       AC_MSG_RESULT([yes])
890       tst_compi_strcasestr="yes"
891     ],[
892       AC_MSG_RESULT([no])
893       tst_compi_strcasestr="no"
894     ])
895   fi
896   #
897   if test "$tst_compi_strcasestr" = "yes"; then
898     AC_MSG_CHECKING([if strcasestr usage allowed])
899     if test "x$curl_disallow_strcasestr" != "xyes"; then
900       AC_MSG_RESULT([yes])
901       tst_allow_strcasestr="yes"
902     else
903       AC_MSG_RESULT([no])
904       tst_allow_strcasestr="no"
905     fi
906   fi
907   #
908   AC_MSG_CHECKING([if strcasestr might be used])
909   if test "$tst_links_strcasestr" = "yes" &&
910      test "$tst_proto_strcasestr" = "yes" &&
911      test "$tst_compi_strcasestr" = "yes" &&
912      test "$tst_allow_strcasestr" = "yes"; then
913     AC_MSG_RESULT([yes])
914     AC_DEFINE_UNQUOTED(HAVE_STRCASESTR, 1,
915       [Define to 1 if you have the strcasestr function.])
916     ac_cv_func_strcasestr="yes"
917   else
918     AC_MSG_RESULT([no])
919     ac_cv_func_strcasestr="no"
920   fi
921 ])
922
923
924 dnl CURL_CHECK_FUNC_STRCMPI
925 dnl -------------------------------------------------
926 dnl Verify if strcmpi is available, prototyped, and
927 dnl can be compiled. If all of these are true, and
928 dnl usage has not been previously disallowed with
929 dnl shell variable curl_disallow_strcmpi, then
930 dnl HAVE_STRCMPI will be defined.
931
932 AC_DEFUN([CURL_CHECK_FUNC_STRCMPI], [
933   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
934   #
935   tst_links_strcmpi="unknown"
936   tst_proto_strcmpi="unknown"
937   tst_compi_strcmpi="unknown"
938   tst_allow_strcmpi="unknown"
939   #
940   AC_MSG_CHECKING([if strcmpi can be linked])
941   AC_LINK_IFELSE([
942     AC_LANG_FUNC_LINK_TRY([strcmpi])
943   ],[
944     AC_MSG_RESULT([yes])
945     tst_links_strcmpi="yes"
946   ],[
947     AC_MSG_RESULT([no])
948     tst_links_strcmpi="no"
949   ])
950   #
951   if test "$tst_links_strcmpi" = "yes"; then
952     AC_MSG_CHECKING([if strcmpi is prototyped])
953     AC_EGREP_CPP([strcmpi],[
954       $curl_includes_string
955     ],[
956       AC_MSG_RESULT([yes])
957       tst_proto_strcmpi="yes"
958     ],[
959       AC_MSG_RESULT([no])
960       tst_proto_strcmpi="no"
961     ])
962   fi
963   #
964   if test "$tst_proto_strcmpi" = "yes"; then
965     AC_MSG_CHECKING([if strcmpi is compilable])
966     AC_COMPILE_IFELSE([
967       AC_LANG_PROGRAM([[
968         $curl_includes_string
969       ]],[[
970         if(0 != strcmpi(0, 0))
971           return 1;
972       ]])
973     ],[
974       AC_MSG_RESULT([yes])
975       tst_compi_strcmpi="yes"
976     ],[
977       AC_MSG_RESULT([no])
978       tst_compi_strcmpi="no"
979     ])
980   fi
981   #
982   if test "$tst_compi_strcmpi" = "yes"; then
983     AC_MSG_CHECKING([if strcmpi usage allowed])
984     if test "x$curl_disallow_strcmpi" != "xyes"; then
985       AC_MSG_RESULT([yes])
986       tst_allow_strcmpi="yes"
987     else
988       AC_MSG_RESULT([no])
989       tst_allow_strcmpi="no"
990     fi
991   fi
992   #
993   AC_MSG_CHECKING([if strcmpi might be used])
994   if test "$tst_links_strcmpi" = "yes" &&
995      test "$tst_proto_strcmpi" = "yes" &&
996      test "$tst_compi_strcmpi" = "yes" &&
997      test "$tst_allow_strcmpi" = "yes"; then
998     AC_MSG_RESULT([yes])
999     AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
1000       [Define to 1 if you have the strcmpi function.])
1001     ac_cv_func_strcmpi="yes"
1002   else
1003     AC_MSG_RESULT([no])
1004     ac_cv_func_strcmpi="no"
1005   fi
1006 ])
1007
1008
1009 dnl CURL_CHECK_FUNC_STRDUP
1010 dnl -------------------------------------------------
1011 dnl Verify if strdup is available, prototyped, and
1012 dnl can be compiled. If all of these are true, and
1013 dnl usage has not been previously disallowed with
1014 dnl shell variable curl_disallow_strdup, then
1015 dnl HAVE_STRDUP will be defined.
1016
1017 AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
1018   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1019   #
1020   tst_links_strdup="unknown"
1021   tst_proto_strdup="unknown"
1022   tst_compi_strdup="unknown"
1023   tst_allow_strdup="unknown"
1024   #
1025   AC_MSG_CHECKING([if strdup can be linked])
1026   AC_LINK_IFELSE([
1027     AC_LANG_FUNC_LINK_TRY([strdup])
1028   ],[
1029     AC_MSG_RESULT([yes])
1030     tst_links_strdup="yes"
1031   ],[
1032     AC_MSG_RESULT([no])
1033     tst_links_strdup="no"
1034   ])
1035   #
1036   if test "$tst_links_strdup" = "yes"; then
1037     AC_MSG_CHECKING([if strdup is prototyped])
1038     AC_EGREP_CPP([strdup],[
1039       $curl_includes_string
1040     ],[
1041       AC_MSG_RESULT([yes])
1042       tst_proto_strdup="yes"
1043     ],[
1044       AC_MSG_RESULT([no])
1045       tst_proto_strdup="no"
1046     ])
1047   fi
1048   #
1049   if test "$tst_proto_strdup" = "yes"; then
1050     AC_MSG_CHECKING([if strdup is compilable])
1051     AC_COMPILE_IFELSE([
1052       AC_LANG_PROGRAM([[
1053         $curl_includes_string
1054       ]],[[
1055         if(0 != strdup(0))
1056           return 1;
1057       ]])
1058     ],[
1059       AC_MSG_RESULT([yes])
1060       tst_compi_strdup="yes"
1061     ],[
1062       AC_MSG_RESULT([no])
1063       tst_compi_strdup="no"
1064     ])
1065   fi
1066   #
1067   if test "$tst_compi_strdup" = "yes"; then
1068     AC_MSG_CHECKING([if strdup usage allowed])
1069     if test "x$curl_disallow_strdup" != "xyes"; then
1070       AC_MSG_RESULT([yes])
1071       tst_allow_strdup="yes"
1072     else
1073       AC_MSG_RESULT([no])
1074       tst_allow_strdup="no"
1075     fi
1076   fi
1077   #
1078   AC_MSG_CHECKING([if strdup might be used])
1079   if test "$tst_links_strdup" = "yes" &&
1080      test "$tst_proto_strdup" = "yes" &&
1081      test "$tst_compi_strdup" = "yes" &&
1082      test "$tst_allow_strdup" = "yes"; then
1083     AC_MSG_RESULT([yes])
1084     AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
1085       [Define to 1 if you have the strdup function.])
1086     ac_cv_func_strdup="yes"
1087   else
1088     AC_MSG_RESULT([no])
1089     ac_cv_func_strdup="no"
1090   fi
1091 ])
1092
1093
1094 dnl CURL_CHECK_FUNC_STRERROR_R
1095 dnl -------------------------------------------------
1096 dnl Verify if strerror_r is available, prototyped, can be compiled and
1097 dnl seems to work. If all of these are true, and usage has not been
1098 dnl previously disallowed with shell variable curl_disallow_strerror_r,
1099 dnl then HAVE_STRERROR_R and STRERROR_R_TYPE_ARG3 will be defined, as
1100 dnl well as one of HAVE_GLIBC_STRERROR_R or HAVE_POSIX_STRERROR_R.
1101 dnl
1102 dnl glibc-style strerror_r:
1103 dnl
1104 dnl      char *strerror_r(int errnum, char *workbuf, size_t bufsize);
1105 dnl
1106 dnl  glibc-style strerror_r returns a pointer to the the error string,
1107 dnl  and might use the provided workbuf as a scratch area if needed. A
1108 dnl  quick test on a few systems shows that it's usually not used at all.
1109 dnl
1110 dnl POSIX-style strerror_r:
1111 dnl
1112 dnl      int strerror_r(int errnum, char *resultbuf, size_t bufsize);
1113 dnl
1114 dnl  POSIX-style strerror_r returns 0 upon successful completion and the
1115 dnl  error string in the provided resultbuf.
1116 dnl
1117
1118 AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
1119   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1120   #
1121   tst_links_strerror_r="unknown"
1122   tst_proto_strerror_r="unknown"
1123   tst_compi_strerror_r="unknown"
1124   tst_glibc_strerror_r="unknown"
1125   tst_posix_strerror_r="unknown"
1126   tst_allow_strerror_r="unknown"
1127   tst_works_glibc_strerror_r="unknown"
1128   tst_works_posix_strerror_r="unknown"
1129   tst_glibc_strerror_r_type_arg3="unknown"
1130   tst_posix_strerror_r_type_arg3="unknown"
1131   #
1132   AC_MSG_CHECKING([if strerror_r can be linked])
1133   AC_LINK_IFELSE([
1134     AC_LANG_FUNC_LINK_TRY([strerror_r])
1135   ],[
1136     AC_MSG_RESULT([yes])
1137     tst_links_strerror_r="yes"
1138   ],[
1139     AC_MSG_RESULT([no])
1140     tst_links_strerror_r="no"
1141   ])
1142   #
1143   if test "$tst_links_strerror_r" = "yes"; then
1144     AC_MSG_CHECKING([if strerror_r is prototyped])
1145     AC_EGREP_CPP([strerror_r],[
1146       $curl_includes_string
1147     ],[
1148       AC_MSG_RESULT([yes])
1149       tst_proto_strerror_r="yes"
1150     ],[
1151       AC_MSG_RESULT([no])
1152       tst_proto_strerror_r="no"
1153     ])
1154   fi
1155   #
1156   if test "$tst_proto_strerror_r" = "yes"; then
1157     AC_MSG_CHECKING([if strerror_r is compilable])
1158     AC_COMPILE_IFELSE([
1159       AC_LANG_PROGRAM([[
1160         $curl_includes_string
1161       ]],[[
1162         if(0 != strerror_r(0, 0, 0))
1163           return 1;
1164       ]])
1165     ],[
1166       AC_MSG_RESULT([yes])
1167       tst_compi_strerror_r="yes"
1168     ],[
1169       AC_MSG_RESULT([no])
1170       tst_compi_strerror_r="no"
1171     ])
1172   fi
1173   #
1174   if test "$tst_compi_strerror_r" = "yes"; then
1175     AC_MSG_CHECKING([if strerror_r is glibc like])
1176     tst_glibc_strerror_r_type_arg3="unknown"
1177     for arg3 in 'size_t' 'int' 'unsigned int'; do
1178       if test "$tst_glibc_strerror_r_type_arg3" = "unknown"; then
1179         AC_COMPILE_IFELSE([
1180           AC_LANG_PROGRAM([[
1181             $curl_includes_string
1182           ]],[[
1183             char *strerror_r(int errnum, char *workbuf, $arg3 bufsize);
1184             if(0 != strerror_r(0, 0, 0))
1185               return 1;
1186           ]])
1187         ],[
1188           tst_glibc_strerror_r_type_arg3="$arg3"
1189         ])
1190       fi
1191     done
1192     case "$tst_glibc_strerror_r_type_arg3" in
1193       unknown)
1194         AC_MSG_RESULT([no])
1195         tst_glibc_strerror_r="no"
1196         ;;
1197       *)
1198         AC_MSG_RESULT([yes])
1199         tst_glibc_strerror_r="yes"
1200         ;;
1201     esac
1202   fi
1203   #
1204   dnl only do runtime verification when not cross-compiling
1205   if test "x$cross_compiling" != "xyes" &&
1206     test "$tst_glibc_strerror_r" = "yes"; then
1207     AC_MSG_CHECKING([if strerror_r seems to work])
1208     AC_RUN_IFELSE([
1209       AC_LANG_PROGRAM([[
1210         $curl_includes_string
1211 #       include <errno.h>
1212       ]],[[
1213         char buffer[1024];
1214         char *string = 0;
1215         buffer[0] = '\0';
1216         string = strerror_r(EACCES, buffer, sizeof(buffer));
1217         if(!string)
1218           exit(1); /* fail */
1219         if(!string[0])
1220           exit(1); /* fail */
1221         else
1222           exit(0);
1223       ]])
1224     ],[
1225       AC_MSG_RESULT([yes])
1226       tst_works_glibc_strerror_r="yes"
1227     ],[
1228       AC_MSG_RESULT([no])
1229       tst_works_glibc_strerror_r="no"
1230     ])
1231   fi
1232   #
1233   if test "$tst_compi_strerror_r" = "yes" &&
1234     test "$tst_works_glibc_strerror_r" != "yes"; then
1235     AC_MSG_CHECKING([if strerror_r is POSIX like])
1236     tst_posix_strerror_r_type_arg3="unknown"
1237     for arg3 in 'size_t' 'int' 'unsigned int'; do
1238       if test "$tst_posix_strerror_r_type_arg3" = "unknown"; then
1239         AC_COMPILE_IFELSE([
1240           AC_LANG_PROGRAM([[
1241             $curl_includes_string
1242           ]],[[
1243             int strerror_r(int errnum, char *resultbuf, $arg3 bufsize);
1244             if(0 != strerror_r(0, 0, 0))
1245               return 1;
1246           ]])
1247         ],[
1248           tst_posix_strerror_r_type_arg3="$arg3"
1249         ])
1250       fi
1251     done
1252     case "$tst_posix_strerror_r_type_arg3" in
1253       unknown)
1254         AC_MSG_RESULT([no])
1255         tst_posix_strerror_r="no"
1256         ;;
1257       *)
1258         AC_MSG_RESULT([yes])
1259         tst_posix_strerror_r="yes"
1260         ;;
1261     esac
1262   fi
1263   #
1264   dnl only do runtime verification when not cross-compiling
1265   if test "x$cross_compiling" != "xyes" &&
1266     test "$tst_posix_strerror_r" = "yes"; then
1267     AC_MSG_CHECKING([if strerror_r seems to work])
1268     AC_RUN_IFELSE([
1269       AC_LANG_PROGRAM([[
1270         $curl_includes_string
1271 #       include <errno.h>
1272       ]],[[
1273         char buffer[1024];
1274         int error = 1;
1275         buffer[0] = '\0';
1276         error = strerror_r(EACCES, buffer, sizeof(buffer));
1277         if(error)
1278           exit(1); /* fail */
1279         if(buffer[0] == '\0')
1280           exit(1); /* fail */
1281         else
1282           exit(0);
1283       ]])
1284     ],[
1285       AC_MSG_RESULT([yes])
1286       tst_works_posix_strerror_r="yes"
1287     ],[
1288       AC_MSG_RESULT([no])
1289       tst_works_posix_strerror_r="no"
1290     ])
1291   fi
1292   #
1293   if test "$tst_glibc_strerror_r" = "yes" &&
1294     test "$tst_works_glibc_strerror_r" != "no" &&
1295     test "$tst_posix_strerror_r" != "yes"; then
1296     tst_allow_strerror_r="check"
1297   fi
1298   if test "$tst_posix_strerror_r" = "yes" &&
1299     test "$tst_works_posix_strerror_r" != "no" &&
1300     test "$tst_glibc_strerror_r" != "yes"; then
1301     tst_allow_strerror_r="check"
1302   fi
1303   if test "$tst_allow_strerror_r" = "check"; then
1304     AC_MSG_CHECKING([if strerror_r usage allowed])
1305     if test "x$curl_disallow_strerror_r" != "xyes"; then
1306       AC_MSG_RESULT([yes])
1307       tst_allow_strerror_r="yes"
1308     else
1309       AC_MSG_RESULT([no])
1310       tst_allow_strerror_r="no"
1311     fi
1312   fi
1313   #
1314   AC_MSG_CHECKING([if strerror_r might be used])
1315   if test "$tst_links_strerror_r" = "yes" &&
1316      test "$tst_proto_strerror_r" = "yes" &&
1317      test "$tst_compi_strerror_r" = "yes" &&
1318      test "$tst_allow_strerror_r" = "yes"; then
1319     AC_MSG_RESULT([yes])
1320     if test "$tst_glibc_strerror_r" = "yes"; then
1321       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
1322         [Define to 1 if you have the strerror_r function.])
1323       AC_DEFINE_UNQUOTED(HAVE_GLIBC_STRERROR_R, 1,
1324         [Define to 1 if you have a working glibc-style strerror_r function.])
1325       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_glibc_strerror_r_type_arg3,
1326         [Define to the type of arg 3 for strerror_r.])
1327     fi
1328     if test "$tst_posix_strerror_r" = "yes"; then
1329       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
1330         [Define to 1 if you have the strerror_r function.])
1331       AC_DEFINE_UNQUOTED(HAVE_POSIX_STRERROR_R, 1,
1332         [Define to 1 if you have a working POSIX-style strerror_r function.])
1333       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_posix_strerror_r_type_arg3,
1334         [Define to the type of arg 3 for strerror_r.])
1335     fi
1336     ac_cv_func_strerror_r="yes"
1337   else
1338     AC_MSG_RESULT([no])
1339     ac_cv_func_strerror_r="no"
1340   fi
1341   #
1342   if test "$tst_compi_strerror_r" = "yes" &&
1343      test "$tst_allow_strerror_r" = "unknown"; then
1344     AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually.])
1345   fi
1346   #
1347 ])
1348
1349
1350 dnl CURL_CHECK_FUNC_STRICMP
1351 dnl -------------------------------------------------
1352 dnl Verify if stricmp is available, prototyped, and
1353 dnl can be compiled. If all of these are true, and
1354 dnl usage has not been previously disallowed with
1355 dnl shell variable curl_disallow_stricmp, then
1356 dnl HAVE_STRICMP will be defined.
1357
1358 AC_DEFUN([CURL_CHECK_FUNC_STRICMP], [
1359   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1360   #
1361   tst_links_stricmp="unknown"
1362   tst_proto_stricmp="unknown"
1363   tst_compi_stricmp="unknown"
1364   tst_allow_stricmp="unknown"
1365   #
1366   AC_MSG_CHECKING([if stricmp can be linked])
1367   AC_LINK_IFELSE([
1368     AC_LANG_FUNC_LINK_TRY([stricmp])
1369   ],[
1370     AC_MSG_RESULT([yes])
1371     tst_links_stricmp="yes"
1372   ],[
1373     AC_MSG_RESULT([no])
1374     tst_links_stricmp="no"
1375   ])
1376   #
1377   if test "$tst_links_stricmp" = "yes"; then
1378     AC_MSG_CHECKING([if stricmp is prototyped])
1379     AC_EGREP_CPP([stricmp],[
1380       $curl_includes_string
1381     ],[
1382       AC_MSG_RESULT([yes])
1383       tst_proto_stricmp="yes"
1384     ],[
1385       AC_MSG_RESULT([no])
1386       tst_proto_stricmp="no"
1387     ])
1388   fi
1389   #
1390   if test "$tst_proto_stricmp" = "yes"; then
1391     AC_MSG_CHECKING([if stricmp is compilable])
1392     AC_COMPILE_IFELSE([
1393       AC_LANG_PROGRAM([[
1394         $curl_includes_string
1395       ]],[[
1396         if(0 != stricmp(0, 0))
1397           return 1;
1398       ]])
1399     ],[
1400       AC_MSG_RESULT([yes])
1401       tst_compi_stricmp="yes"
1402     ],[
1403       AC_MSG_RESULT([no])
1404       tst_compi_stricmp="no"
1405     ])
1406   fi
1407   #
1408   if test "$tst_compi_stricmp" = "yes"; then
1409     AC_MSG_CHECKING([if stricmp usage allowed])
1410     if test "x$curl_disallow_stricmp" != "xyes"; then
1411       AC_MSG_RESULT([yes])
1412       tst_allow_stricmp="yes"
1413     else
1414       AC_MSG_RESULT([no])
1415       tst_allow_stricmp="no"
1416     fi
1417   fi
1418   #
1419   AC_MSG_CHECKING([if stricmp might be used])
1420   if test "$tst_links_stricmp" = "yes" &&
1421      test "$tst_proto_stricmp" = "yes" &&
1422      test "$tst_compi_stricmp" = "yes" &&
1423      test "$tst_allow_stricmp" = "yes"; then
1424     AC_MSG_RESULT([yes])
1425     AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
1426       [Define to 1 if you have the stricmp function.])
1427     ac_cv_func_stricmp="yes"
1428   else
1429     AC_MSG_RESULT([no])
1430     ac_cv_func_stricmp="no"
1431   fi
1432 ])
1433
1434
1435 dnl CURL_CHECK_FUNC_STRLCAT
1436 dnl -------------------------------------------------
1437 dnl Verify if strlcat is available, prototyped, and
1438 dnl can be compiled. If all of these are true, and
1439 dnl usage has not been previously disallowed with
1440 dnl shell variable curl_disallow_strlcat, then
1441 dnl HAVE_STRLCAT will be defined.
1442
1443 AC_DEFUN([CURL_CHECK_FUNC_STRLCAT], [
1444   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1445   #
1446   tst_links_strlcat="unknown"
1447   tst_proto_strlcat="unknown"
1448   tst_compi_strlcat="unknown"
1449   tst_allow_strlcat="unknown"
1450   #
1451   AC_MSG_CHECKING([if strlcat can be linked])
1452   AC_LINK_IFELSE([
1453     AC_LANG_FUNC_LINK_TRY([strlcat])
1454   ],[
1455     AC_MSG_RESULT([yes])
1456     tst_links_strlcat="yes"
1457   ],[
1458     AC_MSG_RESULT([no])
1459     tst_links_strlcat="no"
1460   ])
1461   #
1462   if test "$tst_links_strlcat" = "yes"; then
1463     AC_MSG_CHECKING([if strlcat is prototyped])
1464     AC_EGREP_CPP([strlcat],[
1465       $curl_includes_string
1466     ],[
1467       AC_MSG_RESULT([yes])
1468       tst_proto_strlcat="yes"
1469     ],[
1470       AC_MSG_RESULT([no])
1471       tst_proto_strlcat="no"
1472     ])
1473   fi
1474   #
1475   if test "$tst_proto_strlcat" = "yes"; then
1476     AC_MSG_CHECKING([if strlcat is compilable])
1477     AC_COMPILE_IFELSE([
1478       AC_LANG_PROGRAM([[
1479         $curl_includes_string
1480       ]],[[
1481         if(0 != strlcat(0, 0, 0))
1482           return 1;
1483       ]])
1484     ],[
1485       AC_MSG_RESULT([yes])
1486       tst_compi_strlcat="yes"
1487     ],[
1488       AC_MSG_RESULT([no])
1489       tst_compi_strlcat="no"
1490     ])
1491   fi
1492   #
1493   if test "$tst_compi_strlcat" = "yes"; then
1494     AC_MSG_CHECKING([if strlcat usage allowed])
1495     if test "x$curl_disallow_strlcat" != "xyes"; then
1496       AC_MSG_RESULT([yes])
1497       tst_allow_strlcat="yes"
1498     else
1499       AC_MSG_RESULT([no])
1500       tst_allow_strlcat="no"
1501     fi
1502   fi
1503   #
1504   AC_MSG_CHECKING([if strlcat might be used])
1505   if test "$tst_links_strlcat" = "yes" &&
1506      test "$tst_proto_strlcat" = "yes" &&
1507      test "$tst_compi_strlcat" = "yes" &&
1508      test "$tst_allow_strlcat" = "yes"; then
1509     AC_MSG_RESULT([yes])
1510     AC_DEFINE_UNQUOTED(HAVE_STRLCAT, 1,
1511       [Define to 1 if you have the strlcat function.])
1512     ac_cv_func_strlcat="yes"
1513   else
1514     AC_MSG_RESULT([no])
1515     ac_cv_func_strlcat="no"
1516   fi
1517 ])
1518
1519
1520 dnl CURL_CHECK_FUNC_STRNCASECMP
1521 dnl -------------------------------------------------
1522 dnl Verify if strncasecmp is available, prototyped, and
1523 dnl can be compiled. If all of these are true, and
1524 dnl usage has not been previously disallowed with
1525 dnl shell variable curl_disallow_strncasecmp, then
1526 dnl HAVE_STRNCASECMP will be defined.
1527
1528 AC_DEFUN([CURL_CHECK_FUNC_STRNCASECMP], [
1529   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1530   #
1531   tst_links_strncasecmp="unknown"
1532   tst_proto_strncasecmp="unknown"
1533   tst_compi_strncasecmp="unknown"
1534   tst_allow_strncasecmp="unknown"
1535   #
1536   AC_MSG_CHECKING([if strncasecmp can be linked])
1537   AC_LINK_IFELSE([
1538     AC_LANG_FUNC_LINK_TRY([strncasecmp])
1539   ],[
1540     AC_MSG_RESULT([yes])
1541     tst_links_strncasecmp="yes"
1542   ],[
1543     AC_MSG_RESULT([no])
1544     tst_links_strncasecmp="no"
1545   ])
1546   #
1547   if test "$tst_links_strncasecmp" = "yes"; then
1548     AC_MSG_CHECKING([if strncasecmp is prototyped])
1549     AC_EGREP_CPP([strncasecmp],[
1550       $curl_includes_string
1551     ],[
1552       AC_MSG_RESULT([yes])
1553       tst_proto_strncasecmp="yes"
1554     ],[
1555       AC_MSG_RESULT([no])
1556       tst_proto_strncasecmp="no"
1557     ])
1558   fi
1559   #
1560   if test "$tst_proto_strncasecmp" = "yes"; then
1561     AC_MSG_CHECKING([if strncasecmp is compilable])
1562     AC_COMPILE_IFELSE([
1563       AC_LANG_PROGRAM([[
1564         $curl_includes_string
1565       ]],[[
1566         if(0 != strncasecmp(0, 0, 0))
1567           return 1;
1568       ]])
1569     ],[
1570       AC_MSG_RESULT([yes])
1571       tst_compi_strncasecmp="yes"
1572     ],[
1573       AC_MSG_RESULT([no])
1574       tst_compi_strncasecmp="no"
1575     ])
1576   fi
1577   #
1578   if test "$tst_compi_strncasecmp" = "yes"; then
1579     AC_MSG_CHECKING([if strncasecmp usage allowed])
1580     if test "x$curl_disallow_strncasecmp" != "xyes"; then
1581       AC_MSG_RESULT([yes])
1582       tst_allow_strncasecmp="yes"
1583     else
1584       AC_MSG_RESULT([no])
1585       tst_allow_strncasecmp="no"
1586     fi
1587   fi
1588   #
1589   AC_MSG_CHECKING([if strncasecmp might be used])
1590   if test "$tst_links_strncasecmp" = "yes" &&
1591      test "$tst_proto_strncasecmp" = "yes" &&
1592      test "$tst_compi_strncasecmp" = "yes" &&
1593      test "$tst_allow_strncasecmp" = "yes"; then
1594     AC_MSG_RESULT([yes])
1595     AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
1596       [Define to 1 if you have the strncasecmp function.])
1597     ac_cv_func_strncasecmp="yes"
1598   else
1599     AC_MSG_RESULT([no])
1600     ac_cv_func_strncasecmp="no"
1601   fi
1602 ])
1603
1604
1605 dnl CURL_CHECK_FUNC_STRNCMPI
1606 dnl -------------------------------------------------
1607 dnl Verify if strncmpi is available, prototyped, and
1608 dnl can be compiled. If all of these are true, and
1609 dnl usage has not been previously disallowed with
1610 dnl shell variable curl_disallow_strncmpi, then
1611 dnl HAVE_STRNCMPI will be defined.
1612
1613 AC_DEFUN([CURL_CHECK_FUNC_STRNCMPI], [
1614   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1615   #
1616   tst_links_strncmpi="unknown"
1617   tst_proto_strncmpi="unknown"
1618   tst_compi_strncmpi="unknown"
1619   tst_allow_strncmpi="unknown"
1620   #
1621   AC_MSG_CHECKING([if strncmpi can be linked])
1622   AC_LINK_IFELSE([
1623     AC_LANG_FUNC_LINK_TRY([strncmpi])
1624   ],[
1625     AC_MSG_RESULT([yes])
1626     tst_links_strncmpi="yes"
1627   ],[
1628     AC_MSG_RESULT([no])
1629     tst_links_strncmpi="no"
1630   ])
1631   #
1632   if test "$tst_links_strncmpi" = "yes"; then
1633     AC_MSG_CHECKING([if strncmpi is prototyped])
1634     AC_EGREP_CPP([strncmpi],[
1635       $curl_includes_string
1636     ],[
1637       AC_MSG_RESULT([yes])
1638       tst_proto_strncmpi="yes"
1639     ],[
1640       AC_MSG_RESULT([no])
1641       tst_proto_strncmpi="no"
1642     ])
1643   fi
1644   #
1645   if test "$tst_proto_strncmpi" = "yes"; then
1646     AC_MSG_CHECKING([if strncmpi is compilable])
1647     AC_COMPILE_IFELSE([
1648       AC_LANG_PROGRAM([[
1649         $curl_includes_string
1650       ]],[[
1651         if(0 != strncmpi(0, 0))
1652           return 1;
1653       ]])
1654     ],[
1655       AC_MSG_RESULT([yes])
1656       tst_compi_strncmpi="yes"
1657     ],[
1658       AC_MSG_RESULT([no])
1659       tst_compi_strncmpi="no"
1660     ])
1661   fi
1662   #
1663   if test "$tst_compi_strncmpi" = "yes"; then
1664     AC_MSG_CHECKING([if strncmpi usage allowed])
1665     if test "x$curl_disallow_strncmpi" != "xyes"; then
1666       AC_MSG_RESULT([yes])
1667       tst_allow_strncmpi="yes"
1668     else
1669       AC_MSG_RESULT([no])
1670       tst_allow_strncmpi="no"
1671     fi
1672   fi
1673   #
1674   AC_MSG_CHECKING([if strncmpi might be used])
1675   if test "$tst_links_strncmpi" = "yes" &&
1676      test "$tst_proto_strncmpi" = "yes" &&
1677      test "$tst_compi_strncmpi" = "yes" &&
1678      test "$tst_allow_strncmpi" = "yes"; then
1679     AC_MSG_RESULT([yes])
1680     AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
1681       [Define to 1 if you have the strncmpi function.])
1682     ac_cv_func_strncmpi="yes"
1683   else
1684     AC_MSG_RESULT([no])
1685     ac_cv_func_strncmpi="no"
1686   fi
1687 ])
1688
1689
1690 dnl CURL_CHECK_FUNC_STRNICMP
1691 dnl -------------------------------------------------
1692 dnl Verify if strnicmp is available, prototyped, and
1693 dnl can be compiled. If all of these are true, and
1694 dnl usage has not been previously disallowed with
1695 dnl shell variable curl_disallow_strnicmp, then
1696 dnl HAVE_STRNICMP will be defined.
1697
1698 AC_DEFUN([CURL_CHECK_FUNC_STRNICMP], [
1699   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1700   #
1701   tst_links_strnicmp="unknown"
1702   tst_proto_strnicmp="unknown"
1703   tst_compi_strnicmp="unknown"
1704   tst_allow_strnicmp="unknown"
1705   #
1706   AC_MSG_CHECKING([if strnicmp can be linked])
1707   AC_LINK_IFELSE([
1708     AC_LANG_FUNC_LINK_TRY([strnicmp])
1709   ],[
1710     AC_MSG_RESULT([yes])
1711     tst_links_strnicmp="yes"
1712   ],[
1713     AC_MSG_RESULT([no])
1714     tst_links_strnicmp="no"
1715   ])
1716   #
1717   if test "$tst_links_strnicmp" = "yes"; then
1718     AC_MSG_CHECKING([if strnicmp is prototyped])
1719     AC_EGREP_CPP([strnicmp],[
1720       $curl_includes_string
1721     ],[
1722       AC_MSG_RESULT([yes])
1723       tst_proto_strnicmp="yes"
1724     ],[
1725       AC_MSG_RESULT([no])
1726       tst_proto_strnicmp="no"
1727     ])
1728   fi
1729   #
1730   if test "$tst_proto_strnicmp" = "yes"; then
1731     AC_MSG_CHECKING([if strnicmp is compilable])
1732     AC_COMPILE_IFELSE([
1733       AC_LANG_PROGRAM([[
1734         $curl_includes_string
1735       ]],[[
1736         if(0 != strnicmp(0, 0))
1737           return 1;
1738       ]])
1739     ],[
1740       AC_MSG_RESULT([yes])
1741       tst_compi_strnicmp="yes"
1742     ],[
1743       AC_MSG_RESULT([no])
1744       tst_compi_strnicmp="no"
1745     ])
1746   fi
1747   #
1748   if test "$tst_compi_strnicmp" = "yes"; then
1749     AC_MSG_CHECKING([if strnicmp usage allowed])
1750     if test "x$curl_disallow_strnicmp" != "xyes"; then
1751       AC_MSG_RESULT([yes])
1752       tst_allow_strnicmp="yes"
1753     else
1754       AC_MSG_RESULT([no])
1755       tst_allow_strnicmp="no"
1756     fi
1757   fi
1758   #
1759   AC_MSG_CHECKING([if strnicmp might be used])
1760   if test "$tst_links_strnicmp" = "yes" &&
1761      test "$tst_proto_strnicmp" = "yes" &&
1762      test "$tst_compi_strnicmp" = "yes" &&
1763      test "$tst_allow_strnicmp" = "yes"; then
1764     AC_MSG_RESULT([yes])
1765     AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
1766       [Define to 1 if you have the strnicmp function.])
1767     ac_cv_func_strnicmp="yes"
1768   else
1769     AC_MSG_RESULT([no])
1770     ac_cv_func_strnicmp="no"
1771   fi
1772 ])
1773
1774
1775 dnl CURL_CHECK_FUNC_STRSTR
1776 dnl -------------------------------------------------
1777 dnl Verify if strstr is available, prototyped, and
1778 dnl can be compiled. If all of these are true, and
1779 dnl usage has not been previously disallowed with
1780 dnl shell variable curl_disallow_strstr, then
1781 dnl HAVE_STRSTR will be defined.
1782
1783 AC_DEFUN([CURL_CHECK_FUNC_STRSTR], [
1784   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1785   #
1786   tst_links_strstr="unknown"
1787   tst_proto_strstr="unknown"
1788   tst_compi_strstr="unknown"
1789   tst_allow_strstr="unknown"
1790   #
1791   AC_MSG_CHECKING([if strstr can be linked])
1792   AC_LINK_IFELSE([
1793     AC_LANG_FUNC_LINK_TRY([strstr])
1794   ],[
1795     AC_MSG_RESULT([yes])
1796     tst_links_strstr="yes"
1797   ],[
1798     AC_MSG_RESULT([no])
1799     tst_links_strstr="no"
1800   ])
1801   #
1802   if test "$tst_links_strstr" = "yes"; then
1803     AC_MSG_CHECKING([if strstr is prototyped])
1804     AC_EGREP_CPP([strstr],[
1805       $curl_includes_string
1806     ],[
1807       AC_MSG_RESULT([yes])
1808       tst_proto_strstr="yes"
1809     ],[
1810       AC_MSG_RESULT([no])
1811       tst_proto_strstr="no"
1812     ])
1813   fi
1814   #
1815   if test "$tst_proto_strstr" = "yes"; then
1816     AC_MSG_CHECKING([if strstr is compilable])
1817     AC_COMPILE_IFELSE([
1818       AC_LANG_PROGRAM([[
1819         $curl_includes_string
1820       ]],[[
1821         if(0 != strstr(0, 0))
1822           return 1;
1823       ]])
1824     ],[
1825       AC_MSG_RESULT([yes])
1826       tst_compi_strstr="yes"
1827     ],[
1828       AC_MSG_RESULT([no])
1829       tst_compi_strstr="no"
1830     ])
1831   fi
1832   #
1833   if test "$tst_compi_strstr" = "yes"; then
1834     AC_MSG_CHECKING([if strstr usage allowed])
1835     if test "x$curl_disallow_strstr" != "xyes"; then
1836       AC_MSG_RESULT([yes])
1837       tst_allow_strstr="yes"
1838     else
1839       AC_MSG_RESULT([no])
1840       tst_allow_strstr="no"
1841     fi
1842   fi
1843   #
1844   AC_MSG_CHECKING([if strstr might be used])
1845   if test "$tst_links_strstr" = "yes" &&
1846      test "$tst_proto_strstr" = "yes" &&
1847      test "$tst_compi_strstr" = "yes" &&
1848      test "$tst_allow_strstr" = "yes"; then
1849     AC_MSG_RESULT([yes])
1850     AC_DEFINE_UNQUOTED(HAVE_STRSTR, 1,
1851       [Define to 1 if you have the strstr function.])
1852     ac_cv_func_strstr="yes"
1853   else
1854     AC_MSG_RESULT([no])
1855     ac_cv_func_strstr="no"
1856   fi
1857 ])
1858
1859
1860 dnl CURL_CHECK_FUNC_STRTOK_R
1861 dnl -------------------------------------------------
1862 dnl Verify if strtok_r is available, prototyped, and
1863 dnl can be compiled. If all of these are true, and
1864 dnl usage has not been previously disallowed with
1865 dnl shell variable curl_disallow_strtok_r, then
1866 dnl HAVE_STRTOK_R will be defined.
1867
1868 AC_DEFUN([CURL_CHECK_FUNC_STRTOK_R], [
1869   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1870   #
1871   tst_links_strtok_r="unknown"
1872   tst_proto_strtok_r="unknown"
1873   tst_compi_strtok_r="unknown"
1874   tst_allow_strtok_r="unknown"
1875   #
1876   AC_MSG_CHECKING([if strtok_r can be linked])
1877   AC_LINK_IFELSE([
1878     AC_LANG_FUNC_LINK_TRY([strtok_r])
1879   ],[
1880     AC_MSG_RESULT([yes])
1881     tst_links_strtok_r="yes"
1882   ],[
1883     AC_MSG_RESULT([no])
1884     tst_links_strtok_r="no"
1885   ])
1886   #
1887   if test "$tst_links_strtok_r" = "yes"; then
1888     AC_MSG_CHECKING([if strtok_r is prototyped])
1889     AC_EGREP_CPP([strtok_r],[
1890       $curl_includes_string
1891     ],[
1892       AC_MSG_RESULT([yes])
1893       tst_proto_strtok_r="yes"
1894     ],[
1895       AC_MSG_RESULT([no])
1896       tst_proto_strtok_r="no"
1897     ])
1898   fi
1899   #
1900   if test "$tst_proto_strtok_r" = "yes"; then
1901     AC_MSG_CHECKING([if strtok_r is compilable])
1902     AC_COMPILE_IFELSE([
1903       AC_LANG_PROGRAM([[
1904         $curl_includes_string
1905       ]],[[
1906         if(0 != strtok_r(0, 0, 0))
1907           return 1;
1908       ]])
1909     ],[
1910       AC_MSG_RESULT([yes])
1911       tst_compi_strtok_r="yes"
1912     ],[
1913       AC_MSG_RESULT([no])
1914       tst_compi_strtok_r="no"
1915     ])
1916   fi
1917   #
1918   if test "$tst_compi_strtok_r" = "yes"; then
1919     AC_MSG_CHECKING([if strtok_r usage allowed])
1920     if test "x$curl_disallow_strtok_r" != "xyes"; then
1921       AC_MSG_RESULT([yes])
1922       tst_allow_strtok_r="yes"
1923     else
1924       AC_MSG_RESULT([no])
1925       tst_allow_strtok_r="no"
1926     fi
1927   fi
1928   #
1929   AC_MSG_CHECKING([if strtok_r might be used])
1930   if test "$tst_links_strtok_r" = "yes" &&
1931      test "$tst_proto_strtok_r" = "yes" &&
1932      test "$tst_compi_strtok_r" = "yes" &&
1933      test "$tst_allow_strtok_r" = "yes"; then
1934     AC_MSG_RESULT([yes])
1935     AC_DEFINE_UNQUOTED(HAVE_STRTOK_R, 1,
1936       [Define to 1 if you have the strtok_r function.])
1937     ac_cv_func_strtok_r="yes"
1938   else
1939     AC_MSG_RESULT([no])
1940     ac_cv_func_strtok_r="no"
1941   fi
1942 ])
1943
1944
1945 dnl CURL_CHECK_FUNC_STRTOLL
1946 dnl -------------------------------------------------
1947 dnl Verify if strtoll is available, prototyped, and
1948 dnl can be compiled. If all of these are true, and
1949 dnl usage has not been previously disallowed with
1950 dnl shell variable curl_disallow_strtoll, then
1951 dnl HAVE_STRTOLL will be defined.
1952
1953 AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
1954   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
1955   #
1956   tst_links_strtoll="unknown"
1957   tst_proto_strtoll="unknown"
1958   tst_compi_strtoll="unknown"
1959   tst_allow_strtoll="unknown"
1960   #
1961   AC_MSG_CHECKING([if strtoll can be linked])
1962   AC_LINK_IFELSE([
1963     AC_LANG_FUNC_LINK_TRY([strtoll])
1964   ],[
1965     AC_MSG_RESULT([yes])
1966     tst_links_strtoll="yes"
1967   ],[
1968     AC_MSG_RESULT([no])
1969     tst_links_strtoll="no"
1970   ])
1971   #
1972   if test "$tst_links_strtoll" = "yes"; then
1973     AC_MSG_CHECKING([if strtoll is prototyped])
1974     AC_EGREP_CPP([strtoll],[
1975       $curl_includes_stdlib
1976     ],[
1977       AC_MSG_RESULT([yes])
1978       tst_proto_strtoll="yes"
1979     ],[
1980       AC_MSG_RESULT([no])
1981       tst_proto_strtoll="no"
1982     ])
1983   fi
1984   #
1985   if test "$tst_proto_strtoll" = "yes"; then
1986     AC_MSG_CHECKING([if strtoll is compilable])
1987     AC_COMPILE_IFELSE([
1988       AC_LANG_PROGRAM([[
1989         $curl_includes_stdlib
1990       ]],[[
1991         if(0 != strtoll(0, 0, 0))
1992           return 1;
1993       ]])
1994     ],[
1995       AC_MSG_RESULT([yes])
1996       tst_compi_strtoll="yes"
1997     ],[
1998       AC_MSG_RESULT([no])
1999       tst_compi_strtoll="no"
2000     ])
2001   fi
2002   #
2003   if test "$tst_compi_strtoll" = "yes"; then
2004     AC_MSG_CHECKING([if strtoll usage allowed])
2005     if test "x$curl_disallow_strtoll" != "xyes"; then
2006       AC_MSG_RESULT([yes])
2007       tst_allow_strtoll="yes"
2008     else
2009       AC_MSG_RESULT([no])
2010       tst_allow_strtoll="no"
2011     fi
2012   fi
2013   #
2014   AC_MSG_CHECKING([if strtoll might be used])
2015   if test "$tst_links_strtoll" = "yes" &&
2016      test "$tst_proto_strtoll" = "yes" &&
2017      test "$tst_compi_strtoll" = "yes" &&
2018      test "$tst_allow_strtoll" = "yes"; then
2019     AC_MSG_RESULT([yes])
2020     AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
2021       [Define to 1 if you have the strtoll function.])
2022     ac_cv_func_strtoll="yes"
2023   else
2024     AC_MSG_RESULT([no])
2025     ac_cv_func_strtoll="no"
2026   fi
2027 ])
2028
2029
2030 dnl CURL_CHECK_FUNC_WRITEV
2031 dnl -------------------------------------------------
2032 dnl Verify if writev is available, prototyped, and
2033 dnl can be compiled. If all of these are true, and
2034 dnl usage has not been previously disallowed with
2035 dnl shell variable curl_disallow_writev, then
2036 dnl HAVE_WRITEV will be defined.
2037
2038 AC_DEFUN([CURL_CHECK_FUNC_WRITEV], [
2039   AC_REQUIRE([CURL_INCLUDES_SYS_UIO])dnl
2040   #
2041   tst_links_writev="unknown"
2042   tst_proto_writev="unknown"
2043   tst_compi_writev="unknown"
2044   tst_allow_writev="unknown"
2045   #
2046   AC_MSG_CHECKING([if writev can be linked])
2047   AC_LINK_IFELSE([
2048     AC_LANG_FUNC_LINK_TRY([writev])
2049   ],[
2050     AC_MSG_RESULT([yes])
2051     tst_links_writev="yes"
2052   ],[
2053     AC_MSG_RESULT([no])
2054     tst_links_writev="no"
2055   ])
2056   #
2057   if test "$tst_links_writev" = "yes"; then
2058     AC_MSG_CHECKING([if writev is prototyped])
2059     AC_EGREP_CPP([writev],[
2060       $curl_includes_sys_uio
2061     ],[
2062       AC_MSG_RESULT([yes])
2063       tst_proto_writev="yes"
2064     ],[
2065       AC_MSG_RESULT([no])
2066       tst_proto_writev="no"
2067     ])
2068   fi
2069   #
2070   if test "$tst_proto_writev" = "yes"; then
2071     AC_MSG_CHECKING([if writev is compilable])
2072     AC_COMPILE_IFELSE([
2073       AC_LANG_PROGRAM([[
2074         $curl_includes_sys_uio
2075       ]],[[
2076         if(0 != writev(0, 0, 0))
2077           return 1;
2078       ]])
2079     ],[
2080       AC_MSG_RESULT([yes])
2081       tst_compi_writev="yes"
2082     ],[
2083       AC_MSG_RESULT([no])
2084       tst_compi_writev="no"
2085     ])
2086   fi
2087   #
2088   if test "$tst_compi_writev" = "yes"; then
2089     AC_MSG_CHECKING([if writev usage allowed])
2090     if test "x$curl_disallow_writev" != "xyes"; then
2091       AC_MSG_RESULT([yes])
2092       tst_allow_writev="yes"
2093     else
2094       AC_MSG_RESULT([no])
2095       tst_allow_writev="no"
2096     fi
2097   fi
2098   #
2099   AC_MSG_CHECKING([if writev might be used])
2100   if test "$tst_links_writev" = "yes" &&
2101      test "$tst_proto_writev" = "yes" &&
2102      test "$tst_compi_writev" = "yes" &&
2103      test "$tst_allow_writev" = "yes"; then
2104     AC_MSG_RESULT([yes])
2105     AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
2106       [Define to 1 if you have the writev function.])
2107     ac_cv_func_writev="yes"
2108   else
2109     AC_MSG_RESULT([no])
2110     ac_cv_func_writev="no"
2111   fi
2112 ])