/* define this if toupper() requires tolower() check */
#undef C_UPPER_LOWER
+/* define this to the number of arguments ctime_r() expects
+#undef CTIME_R_NARGS
+
/* define this if sys_errlist is not defined in stdio.h or errno.h */
#undef DECL_SYS_ERRLIST
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
+dnl Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
+dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
dnl
dnl OpenLDAP Autoconf Macros
dnl
fi
])
-dnl check arguments for ctime_r - Bart Hartgers
-
-# serial 1
-AC_DEFUN(OL_NARGS_CTIME_R,
- [AC_MSG_CHECKING([number of args for ctime_r])
- AC_TRY_COMPILE([#include <time.h>],
- [time_t ti; char *buffer;
- ctime_r(&ti,buffer,32);],ol_nargs_ctime_r=3,
- ol_nargs_ctime_r=0)
- if test $ol_nargs_ctime_r = 0 ; then
- AC_TRY_COMPILE([#include <time.h>],
- [time_t ti; char *buffer;
- ctime_r(&ti,buffer);],ol_nargs_ctime_r=2 )
- fi
- AC_MSG_RESULT($ol_nargs_ctime_r)
- if test $ol_nargs_ctime_r = 2 ; then
- AC_DEFINE( ARGS_CTIME_R_2 )
- fi
- if test $ol_nargs_ctime_r = 3 ; then
- AC_DEFINE( ARGS_CTIME_R_3 )
- fi
-])
-
-
-
dnl ====================================================================
dnl check no of arguments for ctime_r
-AC_DEFUN(OL_NARGS_CTIME_R,
- [AC_MSG_CHECKING([number of args for ctime_r])
- AC_TRY_COMPILE([#include <time.h>],
- [time_t ti; char *buffer;
- ctime_r(&ti,buffer,32);],ol_nargs_ctime_r=3,
- ol_nargs_ctime_r=0)
- if test $ol_nargs_ctime_r = 0 ; then
- AC_TRY_COMPILE([#include <time.h>],
- [time_t ti; char *buffer;
- ctime_r(&ti,buffer);],ol_nargs_ctime_r=2 )
- fi
- AC_MSG_RESULT($ol_nargs_ctime_r)
- if test $ol_nargs_ctime_r = 2 ; then
- AC_DEFINE( ARGS_CTIME_R_2 )
- fi
- if test $ol_nargs_ctime_r = 3 ; then
- AC_DEFINE( ARGS_CTIME_R_3 )
+AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
+ [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
+ [AC_TRY_COMPILE([#include <time.h>],
+ [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
+ ol_cv_func_ctime_r_nargs=3, ol_cv_func_ctime_r_nargs=0)
+ if test $ol_cv_func_ctime_r_nargs = 0 ; then
+ AC_TRY_COMPILE([#include <time.h>],
+ [time_t ti; char *buffer;
+ ctime_r(&ti,buffer);],
+ ol_cv_func_ctime_r_nargs=2, ol_cv_func_ctime_r_nargs=0)
+ fi
+ ])
+ if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
+ AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs)
fi
])dnl
done
+echo $ac_n "checking number of arguments of ctime_r""... $ac_c" 1>&6
+echo "configure:8196: checking number of arguments of ctime_r" >&5
+if eval "test \"`echo '$''{'ol_cv_func_ctime_r_nargs'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 8201 "configure"
+#include "confdefs.h"
+#include <time.h>
+int main() {
+time_t ti; char *buffer; ctime_r(&ti,buffer,32);
+; return 0; }
+EOF
+if { (eval echo configure:8208: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ol_cv_func_ctime_r_nargs=3
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ol_cv_func_ctime_r_nargs=0
+fi
+rm -f conftest*
+ if test $ol_cv_func_ctime_r_nargs = 0 ; then
+ cat > conftest.$ac_ext <<EOF
+#line 8220 "configure"
+#include "confdefs.h"
+#include <time.h>
+int main() {
+time_t ti; char *buffer;
+ ctime_r(&ti,buffer);
+; return 0; }
+EOF
+if { (eval echo configure:8228: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ol_cv_func_ctime_r_nargs=2
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ol_cv_func_ctime_r_nargs=0
+fi
+rm -f conftest*
+ fi
+
+fi
+
+echo "$ac_t""$ol_cv_func_ctime_r_nargs" 1>&6
+ if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
+ cat >> confdefs.h <<EOF
+#define CTIME_R_NARGS $ol_cv_func_ctime_r_nargs
+EOF
+
+ fi
+
+
if test $ac_cv_func_strtok_r = yes \
-a $ac_cv_func_ctime_r = yes \
+ -a $ol_cv_func_ctime_r_nargs -ge 2 -a $ol_cv_func_ctime_r_nargs -le 3 \
-a $ac_cv_func_gethostbyaddr_r = yes \
-a $ac_cv_func_gethostbyname_r = yes \
; then
for ac_func in getopt strdup tempnam
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8217: checking for $ac_func" >&5
+echo "configure:8274: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 8222 "configure"
+#line 8279 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:8245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
# Check Configuration
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
-echo "configure:8275: checking declaration of sys_errlist" >&5
+echo "configure:8332: checking declaration of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 8281 "configure"
+#line 8338 "configure"
#include "confdefs.h"
#include <stdio.h>
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:8291: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8348: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ol_cv_dcl_sys_errlist=yes
else
EOF
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
-echo "configure:8312: checking existence of sys_errlist" >&5
+echo "configure:8369: checking existence of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 8318 "configure"
+#line 8375 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:8325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ol_cv_have_sys_errlist=yes
else
gethostbyname_r \
)
+OL_FUNC_CTIME_R_NARGS
+
if test $ac_cv_func_strtok_r = yes \
-a $ac_cv_func_ctime_r = yes \
+ -a $ol_cv_func_ctime_r_nargs -ge 2 -a $ol_cv_func_ctime_r_nargs -le 3 \
-a $ac_cv_func_gethostbyaddr_r = yes \
-a $ac_cv_func_gethostbyname_r = yes \
; then
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT, 1)
fi
-OL_NARGS_CTIME_R
-
if test $ol_link_threads != no ; then
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE, 1)
fi
/* define this if toupper() requires tolower() check */
#undef C_UPPER_LOWER
+/* define this to the number of arguments ctime_r() expects
+#undef CTIME_R_NARGS
+
/* define this if sys_errlist is not defined in stdio.h or errno.h */
#undef DECL_SYS_ERRLIST
/* Define if you have the ctime_r function. */
#undef HAVE_CTIME_R
-/* Define if ctime_r takes two arguments */
-#undef ARGS_CTIME_R_2
-
-/* Define if ctime_r takes three arguments */
-#undef ARGS_CTIME_R_3
-
/* Define if you have the flock function. */
#undef HAVE_FLOCK
char *ldap_int_ctime( const time_t *tp, char *buf )
{
-#ifdef HAVE_CTIME_R
-# if defined( ARGS_CTIME_R_2 )
- return ctime_r(tp,buf);
-# elif defined( ARGS_CTIME_R_3 )
+#if defined( HAVE_CTIME_R ) && defined( CTIME_R_NARGS )
+# if (CTIME_R_NARGS > 3) || (CTIME_R_NARGS < 2)
+ choke me! nargs should have 2 or 3
+# elif CTIME_R_NARGS > 2
return ctime_r(tp,buf,26);
# else
- Do not know how many arguments ctime_r takes, so generating error
+ return ctime_r(tp,buf);
# endif
#else
return ctime(tp);