tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfcl...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native/common jk_global.h jk_util.c jk_version.h
Date Tue, 13 Jul 2004 13:58:10 GMT
jfclere     2004/07/13 06:58:10

  Modified:    jk/native/common jk_global.h jk_util.c jk_version.h
  Log:
  Use portable.h to detect snprint() and vsnprintf().
  Add replacement code for them when they are not available.
  
  Revision  Changes    Path
  1.29      +20 -2     jakarta-tomcat-connectors/jk/native/common/jk_global.h
  
  Index: jk_global.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_global.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- jk_global.h	24 Feb 2004 08:45:47 -0000	1.28
  +++ jk_global.h	13 Jul 2004 13:58:10 -0000	1.29
  @@ -24,6 +24,8 @@
   #ifndef JK_GLOBAL_H
   #define JK_GLOBAL_H
   
  +#include "portable.h"
  +
   #include "jk_version.h"
   
   #include <stdio.h>
  @@ -179,12 +181,28 @@
   #ifdef WIN32
   /* For WIN32, emulate gettimeofday() using _ftime() */
   #define gettimeofday(tv,tz) { struct _timeb tb; _ftime(&tb); (tv)->tv_sec = tb.time;
(tv)->tv_usec = tb.millitm * 1000; }
  +#ifdef HAVE_APR
  +#define snprintf apr_snprintf
  +#define vsnprintf apr_vsnprintf
  +#else
   /* define snprint to match windows version */
   #define snprintf _snprintf
  -/* define vsnprint to match windows version */
   #define vsnprintf _vsnprintf
   #endif
  +#endif
  +
  +/* Use apr snprintf() and vsnprintf() when needed */
  +#if defined(HAVE_APR)
  +#if !defined(HAVE_SNPRINTF)
  +#define snprintf apr_snprintf
  +#endif
  +#if !defined(HAVE_VSNPRINTF)
  +#define vsnprintf apr_vsnprintf
  +#endif
  +#endif
   
  +/* XXXX There is a snprintf() and vsnprintf() in jk_util.c */
  +/* if those work remove the #define. */
   #if defined(NETWARE) || defined(AS400)
   #define USE_SPRINTF
   #define USE_VSPRINTF
  
  
  
  1.28      +41 -1     jakarta-tomcat-connectors/jk/native/common/jk_util.c
  
  Index: jk_util.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_util.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- jk_util.c	24 Feb 2004 08:45:48 -0000	1.27
  +++ jk_util.c	13 Jul 2004 13:58:10 -0000	1.28
  @@ -94,6 +94,46 @@
       strftime(str, len, jk_log_fmt, tms);
   }
   
  +/* Write at most n characters to the buffer in str, return the
  + * number of chars written or -1 if the buffer would have been
  + * overflowed.
  + *
  + * This is portable to any POSIX-compliant system that has /dev/null
  + */
  +#if !defined(HAVE_VSNPRINTF) && !defined(HAVE_APR)
  +static FILE *f=NULL;
  +int vsnprintf( char *str, size_t n, const char *fmt, va_list ap )
  +{
  +       int res;
  +
  +       if (f == NULL)
  +               f = fopen("/dev/null","w");
  +       if (f == NULL)
  +               return -1;
  +
  +       setvbuf( f, str, _IOFBF, n );
  +
  +       res = vfprintf( f, fmt, ap );
  +
  +       if ( res > 0 && res < n ) {
  +               res = vsprintf( str, fmt, ap );
  +       }
  +       return res;
  +}
  +#endif
  +#if !defined(HAVE_SNPRINTF) && !defined(HAVE_APR)
  +int snprintf( char *str, size_t n, const char *fmt, ... )
  +{
  +        va_list ap;
  +        int res;
  + 
  +        va_start( ap, fmt );
  +        res = vsnprintf( str, n, fmt, ap );
  +        va_end( ap );
  +        return res;
  +}
  +#endif
  +
   static int JK_METHOD log_to_file(jk_logger_t *l,                                 
                                    int level,
                                    const char *what)
  
  
  
  1.18      +6 -4      jakarta-tomcat-connectors/jk/native/common/jk_version.h
  
  Index: jk_version.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_version.h,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- jk_version.h	24 Feb 2004 08:45:46 -0000	1.17
  +++ jk_version.h	13 Jul 2004 13:58:10 -0000	1.18
  @@ -16,7 +16,6 @@
   
   /***************************************************************************
    * Description: JK version header file                                     *
  - * Author:      Jean-Frederic Clere <jfrederic.clere@fujitsu-siemens.com>  *
    * Version:     $Revision$                                           *
    ***************************************************************************/
   
  @@ -36,9 +35,12 @@
   #define JK_VERISRELEASE 0
   /************** END OF AREA TO MODIFY BEFORE RELEASING *************/
   
  -#define PACKAGE "mod_jk/"
  +#if !defined(PACKAGE)
  +#define PACKAGE "mod_jk"
  +#endif
  +
   /* Build JK_EXPOSED_VERSION and JK_VERSION */
  -#define JK_EXPOSED_VERSION_INT PACKAGE JK_VERSTRING
  +#define JK_EXPOSED_VERSION_INT PACKAGE "/" JK_VERSTRING
   
   #if ( JK_VERISRELEASE == 1 )
     #define JK_RELEASE_STR  JK_EXPOSED_VERSION_INT
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message