Patch to change ctime_r to CTIME_R, which is now a macro, which
authoraland <aland>
Fri, 19 Dec 2003 19:25:32 +0000 (19:25 +0000)
committeraland <aland>
Fri, 19 Dec 2003 19:25:32 +0000 (19:25 +0000)
works properly on different platforms.  (Hello, Solaris... who
needs to follow Posix?)

Patch from Oliver Graf

acconfig.h
configure
configure.in
src/include/autoconf.h.in
src/include/libradius.h
src/main/log.c
src/main/xlat.c
src/modules/rlm_detail/rlm_detail.c

index f425ae4..5ea0834 100644 (file)
@@ -15,6 +15,11 @@ config.h - created by autoconf; contains defines generated by autoconf
 #undef GETHOSTBYADDRRSTYLE
 #undef GETHOSTBYNAMERSTYLE
 
+/* style of ctime_r function */
+#define POSIXSTYLE 1
+#define SOLARISSTYLE 2
+#undef CTIMERSTYLE
+
 /* Do we have the crypt function ? */
 #undef HAVE_CRYPT
 
index a6b659f..380a48e 100755 (executable)
--- a/configure
+++ b/configure
@@ -733,7 +733,7 @@ fi
 
 
 
-# From configure.in Revision: 1.189 
+# From configure.in Revision: 1.190 
 RADIUSD_MAJOR_VERSION=1
 RADIUSD_MINOR_VERSION=0.0-pre0
 RADIUSD_VERSION="${RADIUSD_MAJOR_VERSION}.${RADIUSD_MINOR_VERSION}"
@@ -8272,9 +8272,70 @@ if test "x$gethostbynamerstyle" = "xBSD"; then
        echo "configure: warning:  ****** BSD-style gethostbyname might NOT be thread-safe! ****** " 1>&2
 fi
 
+ctimerstyle=""
+echo $ac_n "checking ctime_r() syntax""... $ac_c" 1>&6
+echo "configure:8278: checking ctime_r() syntax" >&5
+cat > conftest.$ac_ext <<EOF
+#line 8280 "configure"
+#include "confdefs.h"
+
+#include <time.h>
+
+int main() {
+ ctime_r(NULL, NULL, 0) 
+; return 0; }
+EOF
+if { (eval echo configure:8289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  
+       cat >> confdefs.h <<\EOF
+#define CTIMERSTYLE SOLARISSTYLE
+EOF
+
+       ctimerstyle="SOLARIS"
+
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+if test "x$ctimerstyle" = "x"; then
+       cat > conftest.$ac_ext <<EOF
+#line 8305 "configure"
+#include "confdefs.h"
+
+#include <time.h>
+
+int main() {
+ ctime_r(NULL, NULL) 
+; return 0; }
+EOF
+if { (eval echo configure:8314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  
+               cat >> confdefs.h <<\EOF
+#define CTIMERSTYLE POSIXSTYLE
+EOF
+
+               ctimerstyle="POSIX"
+       
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+fi
+
+if test "x$ctimerstyle" = "x"; then
+       echo "$ac_t""none!  It must not exist, here." 1>&6
+else
+        echo "$ac_t""${ctimerstyle}-style" 1>&6
+fi
+
+
 if test x"$rad_enable_largefiles" = xyes ; then
     echo $ac_n "checking for largefile linkage""... $ac_c" 1>&6
-echo "configure:8278: checking for largefile linkage" >&5
+echo "configure:8339: checking for largefile linkage" >&5
     case "$host" in
     *-aix4.01*)
         echo "$ac_t""no" 1>&6
@@ -8311,7 +8372,7 @@ EOF
         # Extract the first word of "getconf", so it can be a program name with args.
 set dummy getconf; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:8315: checking for $ac_word" >&5
+echo "configure:8376: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GETCONF'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
index 2900eba..ecdcc65 100644 (file)
@@ -797,6 +797,31 @@ if test "x$gethostbynamerstyle" = "xBSD"; then
        AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
 fi
 
+dnl check for non-posix solaris ctime_r (extra buflen int arg)
+ctimerstyle=""
+AC_MSG_CHECKING([ctime_r() syntax])
+AC_TRY_LINK([
+#include <time.h>
+], [ ctime_r(NULL, NULL, 0) ], [
+       AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE)
+       ctimerstyle="SOLARIS"
+])
+if test "x$ctimerstyle" = "x"; then
+       AC_TRY_LINK([
+#include <time.h>
+], [ ctime_r(NULL, NULL) ], [
+               AC_DEFINE(CTIMERSTYLE, POSIXSTYLE)
+               ctimerstyle="POSIX"
+       ])
+fi
+
+if test "x$ctimerstyle" = "x"; then
+       AC_MSG_RESULT([none!  It must not exist, here.])
+else
+        AC_MSG_RESULT([${ctimerstyle}-style])
+fi
+
+
 dnl If configuring with large file support, determine the right flags to
 dnl use based on the platform.  This is the wrong approach; autoconf 2.50
 dnl comes with a macro that takes the right approach.  But this works well
index 6a3f279..1381dbf 100644 (file)
@@ -52,6 +52,11 @@ config.h - created by autoconf; contains defines generated by autoconf
 #undef GETHOSTBYADDRRSTYLE
 #undef GETHOSTBYNAMERSTYLE
 
+/* style of ctime_r function */
+#define POSIXSTYLE 1
+#define SOLARISSTYLE 2
+#undef CTIMERSTYLE
+
 /* Do we have the crypt function ? */
 #undef HAVE_CRYPT
 
index 6cdd2fc..8a07aa3 100644 (file)
@@ -207,6 +207,17 @@ int                dict_vendorname(const char *name);
 /*#define dict_valget  dict_valbyattr almost but not quite*/
 #endif
 
+/* get around diffrent ctime_r styles */
+#ifdef CTIMERSTYLE
+#if CTIMERSTYLE == SOLARISSTYLE
+#define CTIME_R(a,b,c) ctime_r(a,b,c)
+#else
+#define CTIME_R(a,b,c) ctime_r(a,b)
+#endif
+#else
+#define CTIME_R(a,b,c) ctime_r(a,b)
+#endif
+
 /* md5.c */
 
 void           librad_md5_calc(u_char *, u_char *, u_int);
index 8009943..6937ec2 100644 (file)
@@ -121,7 +121,7 @@ int vradlog(int lvl, const char *fmt, va_list ap)
                time_t timeval;
 
                timeval = time(NULL);
-               ctime_r(&timeval, buffer);
+               CTIME_R(&timeval, buffer, 8192);
 
                s = lrad_int2str(levels, (lvl & ~L_CONS), ": ");
 
index 5252bdd..57ab0e3 100644 (file)
@@ -569,7 +569,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
                                p++;
                                break;
                        case 't': /* request timestamp */
-                               ctime_r(&request->timestamp, q);
+                               CTIME_R(&request->timestamp, q, freespace);
                                q += strlen(q);
                                p++;
                                break;
index 0e02a94..fb41c38 100644 (file)
@@ -269,7 +269,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
         *      Post a timestamp
         */
        fseek(outfp, 0L, SEEK_END);
-       fputs(ctime_r(&request->timestamp, buffer), outfp);
+       fputs(CTIME_R(&request->timestamp, buffer, DIRLEN), outfp);
        
        /* Write each attribute/value to the log file */
        while (pair) {