tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jni/native/src error.c
Date Fri, 03 Jun 2005 07:35:07 GMT
mturk       2005/06/03 00:35:07

  Modified:    jni/native/include tcn.h
               jni/native/src error.c
  Log:
  Add generic throw for printf style arguments.
  
  Revision  Changes    Path
  1.11      +2 -2      jakarta-tomcat-connectors/jni/native/include/tcn.h
  
  Index: tcn.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/include/tcn.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- tcn.h	1 Jun 2005 06:38:09 -0000	1.10
  +++ tcn.h	3 Jun 2005 07:35:07 -0000	1.11
  @@ -56,7 +56,7 @@
       JNIEXPORT RT JNICALL Java_org_apache_tomcat_jni_##CL##_##FN
   
   /* Private helper functions */
  -void tcn_Throw(JNIEnv *env, const char *cname, const char *msg);
  +void tcn_Throw(JNIEnv *env, const char *fmt, ...);
   void tcn_ThrowException(JNIEnv *env, const char *msg);
   void tcn_ThrowAPRException(JNIEnv *env, apr_status_t err);
   jstring tcn_new_string(JNIEnv *env, const char *str, int l);
  
  
  
  1.8       +17 -4     jakarta-tomcat-connectors/jni/native/src/error.c
  
  Index: error.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/error.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- error.c	24 May 2005 09:24:40 -0000	1.7
  +++ error.c	3 Jun 2005 07:35:07 -0000	1.8
  @@ -18,9 +18,10 @@
    * @author Mladen Turk
    * @version $Revision$, $Date$
    */
  - 
  +
   #include "apr.h"
   #include "apr_pools.h"
  +#include "apr_strings.h"
   #include "tcn.h"
   
   /* Merge IS_ETIMEDOUT with APR_TIMEUP
  @@ -29,7 +30,7 @@
   /*
    * Convenience function to help throw an Exception.
    */
  -void tcn_Throw(JNIEnv *env, const char *cname, const char *msg)
  +static void do_throw(JNIEnv *env, const char *cname, const char *msg)
   {
       jclass javaExceptionClass;
   
  @@ -47,7 +48,19 @@
    */
   void tcn_ThrowException(JNIEnv *env, const char *msg)
   {
  -    tcn_Throw(env, "java/lang/Exception", msg);
  +    do_throw(env, "java/lang/Exception", msg);
  +}
  +
  +void tcn_Throw(JNIEnv *env, const char *fmt, ...)
  +{
  +    char msg[TCN_BUFFER_SZ] = {'\0'};
  +    va_list ap;
  +
  +    va_start(ap, fmt);
  +    apr_vsnprintf(msg, TCN_BUFFER_SZ, fmt, ap);
  +    do_throw(env, "java/lang/Exception", msg);
  +    va_end(ap);
  +    free(msg);
   }
   
   /*
  
  
  

---------------------------------------------------------------------
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