tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native/common jk_map.c jk_map.h jk_pool.c jk_pool.h
Date Tue, 30 Oct 2001 21:08:39 GMT
costin      01/10/30 13:08:39

  Modified:    jk/native/common jk_map.c jk_map.h jk_pool.c jk_pool.h
  Log:
  In jk_map:
   - expose the method that replaces properties, ant-style ( used internally to read
  worker.properties ). I need it also using http.conf only.
  
   - with some strange properties you can get an infinite loop. Fixed now.
  
  Revision  Changes    Path
  1.7       +16 -8     jakarta-tomcat-connectors/jk/native/common/jk_map.c
  
  Index: jk_map.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_map.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jk_map.c	2001/10/17 20:14:31	1.6
  +++ jk_map.c	2001/10/30 21:08:39	1.7
  @@ -58,7 +58,7 @@
   /***************************************************************************
    * Description: General purpose map object                                 *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.6 $                                           *
  + * Version:     $Revision: 1.7 $                                           *
    ***************************************************************************/
   
   #include "jk_global.h"
  @@ -84,7 +84,6 @@
   static void trim_prp_comment(char *prp);
   static int trim(char *s);
   static int map_realloc(jk_map_t *m);
  -static char *update_env_variables(char *value, jk_map_t *m);
   
   int map_alloc(jk_map_t **m)
   {
  @@ -310,7 +309,7 @@
                           v++;                        
                           if(strlen(v) && strlen(prp)) {
                               char *oldv = map_get_string(m, prp, NULL);
  -                            v = update_env_variables(v, m);
  +                            v = map_replace_properties(v, m);
                               if(oldv) {
                                   char *tmpv = jk_pool_alloc(&m->p, 
                                                              strlen(v) + strlen(oldv) + 3);
  @@ -433,13 +432,19 @@
       return JK_FALSE;
   }
   
  -static char *update_env_variables(char *value, jk_map_t *m)
  -{
  -    char *rc = value;
  -    char *env_start = value;
  +/**
  + *  Replace $(property) in value.
  + * 
  + */
  +char *map_replace_properties(const char *value, jk_map_t *m)
  +{
  +    char *rc = (char *)value;
  +    char *env_start = rc;
  +    int rec = 0;
   
       while(env_start = strstr(env_start, "$(")) {
           char *env_end = strstr(env_start, ")");
  +        if( rec++ > 20 ) return rc;
           if(env_end) {
               char env_name[LENGTH_OF_LINE + 1] = ""; 
               char *env_value;
  @@ -453,6 +458,7 @@
   	      env_value=getenv( env_name );
   	    }
               if(env_value) {
  +                int offset=0;
                   char *new_value = jk_pool_alloc(&m->p, 
                                                   (sizeof(char) * (strlen(rc) + strlen(env_value))));
                   if(!new_value) {
  @@ -462,8 +468,10 @@
                   strcpy(new_value, rc);
                   strcat(new_value, env_value);
                   strcat(new_value, env_end + 1);
  +		offset= env_start - rc + strlen( env_value );
                   rc = new_value;
  -                env_start = rc;
  +		/* Avoid recursive subst */
  +                env_start = rc + offset; 
               } else {
                   env_start = env_end;
               }
  
  
  
  1.4       +8 -1      jakarta-tomcat-connectors/jk/native/common/jk_map.h
  
  Index: jk_map.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_map.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_map.h	2001/09/05 17:05:23	1.3
  +++ jk_map.h	2001/10/30 21:08:39	1.4
  @@ -58,7 +58,7 @@
   /***************************************************************************
    * Description: Map object header file                                     *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.3 $                                           *
  + * Version:     $Revision: 1.4 $                                           *
    ***************************************************************************/
   
   #ifndef JK_MAP_H
  @@ -117,6 +117,13 @@
   
   void *map_value_at(jk_map_t *m,
                      int idex);
  +  
  +/**
  + *  Replace $(property) in value.
  + * 
  + */
  +char *map_replace_properties(const char *value, jk_map_t *m);
  +
   
   #ifdef __cplusplus
   }
  
  
  
  1.3       +5 -1      jakarta-tomcat-connectors/jk/native/common/jk_pool.c
  
  Index: jk_pool.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_pool.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_pool.c	2001/06/18 14:16:01	1.2
  +++ jk_pool.c	2001/10/30 21:08:39	1.3
  @@ -58,13 +58,17 @@
   /***************************************************************************
    * Description: Simple memory pool                                         *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.2 $                                           *
  + * Version:     $Revision: 1.3 $                                           *
    ***************************************************************************/
   
   #include "jk_pool.h"
   
  +#define DEFAULT_DYNAMIC 10
  +
  +
   static void *jk_pool_dyn_alloc(jk_pool_t *p, 
                                  size_t size);
  +
   
   void jk_open_pool(jk_pool_t *p,
                     jk_pool_atom_t *buf,
  
  
  
  1.3       +11 -2     jakarta-tomcat-connectors/jk/native/common/jk_pool.h
  
  Index: jk_pool.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_pool.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_pool.h	2001/06/18 14:16:02	1.2
  +++ jk_pool.h	2001/10/30 21:08:39	1.3
  @@ -58,7 +58,7 @@
   /***************************************************************************
    * Description: Memory Pool object header file                             *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.2 $                                           *
  + * Version:     $Revision: 1.3 $                                           *
    ***************************************************************************/
   #ifndef _JK_POOL_H
   #define _JK_POOL_H
  @@ -69,7 +69,14 @@
   extern "C" {
   #endif /* __cplusplus */
   
  -#define DEFAULT_DYNAMIC 10
  +/**
  + * @file jk_pool.h
  + * @brief Jk memory allocation
  + *
  + * Similar with apr_pools, but completely unsynchronized.
  + * XXX use same names
  + * 
  + */
   
   /*
    * The pool atom (basic pool alocation unit) is an 8 byte long. 
  @@ -109,6 +116,8 @@
   #define BIG_POOL_SIZE   2*SMALL_POOL_SIZE   /* Bigger 1K atom pool. */
   #define HUGE_POOL_SIZE  2*BIG_POOL_SIZE     /* Huge 2K atom pool. */
   
  +  /** XXX Move it to impl, make it incomplete 
  +   */
   struct jk_pool {
       unsigned size;      
       unsigned pos;       
  
  
  

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


Mime
View raw message