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/native2/common jk_uriMap.c
Date Sat, 02 Mar 2002 06:12:05 GMT
costin      02/03/01 22:12:05

  Modified:    jk/native2/common jk_uriMap.c
  Log:
  setProperty(), initial code to support setting various properties per
  uri.
  
  Need to finish it up and make sure the /vhost/path format that
  Nacho mentioned works in jk2 the same as before.
  
  Revision  Changes    Path
  1.17      +68 -33    jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c
  
  Index: jk_uriMap.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- jk_uriMap.c	1 Mar 2002 00:45:58 -0000	1.16
  +++ jk_uriMap.c	2 Mar 2002 06:12:05 -0000	1.17
  @@ -67,7 +67,7 @@
    * servlet container.                                                      
    *                                                                         
    * Author:      Gal Shachor <shachor@il.ibm.com>                           
  - * Version:     $Revision: 1.16 $                                           
  + * Version:     $Revision: 1.17 $                                           
    */
   
   #include "jk_pool.h"
  @@ -170,8 +170,8 @@
   
   static jk_uriEnv_t *jk2_uriEnv_createUriEnv(jk_env_t *env,
                                               jk_uriMap_t *uriMap,
  -                                            char *vhost,
  -                                            char *path) 
  +                                            const char *vhost,
  +                                            const char *path) 
   {
       int err;
       jk_uriEnv_t *uriEnv;
  @@ -216,45 +216,80 @@
           return NULL;
       }
   
  -    uwr->setProperty( env, uwr, "worker", pworker );
  +    uwr->setProperty( env, uwr, "worker", (char *)pworker );
   
       return uwr;
   }
   
  -static int jk2_uriMap_init(jk_env_t *env, jk_uriMap_t *_this,
  -                           jk_workerEnv_t *workerEnv,
  -                           jk_map_t *init_data)
  +
  +static int jk2_uriMap_setUriProperty( struct jk_env *env,
  +                                      struct jk_uriMap *uMap,
  +                                      char *name, char *val)
  +
   {
  -    int rc=JK_TRUE;
  -    int sz;
  -    int err;
  +    jk_worker_t *w = NULL;
  +    char *uname=NULL;
  +    char *pname=NULL;
  +    char *dot=0;
       int i;
  +    jk_uriEnv_t *uriEnv;
   
  -    _this->workerEnv = workerEnv;
  -                                           
  -    sz = init_data->size(env, init_data);
  -
  -    _this->debug=jk2_map_getIntProp(env,
  -                                   init_data,"urimap", "default", "debug", 0 );
  -    
  -    for(i = 0; i < sz ; i++) {
  -        char *name=init_data->nameAt(env, init_data, i);
  -        if( name!=NULL && name[0]=='/' ) {
  -            jk_uriEnv_t *uriEnv=_this->addMapping(env, _this,NULL,name,
  -                                    init_data->valueAt(env, init_data, i));
  -            if ( uriEnv==NULL) {
  -                env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                              "uriMap.init() error adding %s\n",
  -                         init_data->nameAt(env, init_data, i));
  -                rc=JK_FALSE;
  -            }
  +    if( strncmp( name, "uri.", 4 ) != 0 )
  +        return JK_FALSE;
  +
  +    pname=uMap->pool->pstrdup( env, uMap->pool, name + 4);
  +    dot=strchr( pname, '.' );
  +    if( dot== NULL )
  +        return JK_FALSE;
  +    *dot='\0';
  +    uname= dot+1;
  +    env->l->jkLog(env, env->l, JK_LOG_ERROR, "UriMap: wname1= %s pname=%s\n",
uname, pname); 
  +
  +    /* Get mapping */
  +    uriEnv=uMap->addMapping(env, uMap, NULL, uname, NULL);
  +
  +    if( uriEnv != NULL ) {
  +        /* If we have an object with that name, set the prop */
  +        return uriEnv->setProperty( env, uriEnv, pname, val );
  +    }
  +    return JK_TRUE;
  +}
  +
  +
  +
  +static int jk2_uriMap_setProperty(jk_env_t *env, jk_uriMap_t *_this,
  +                                  char *name, char *value)
  +{
  +    int rc=JK_TRUE;
  +    
  +    if( strcmp( name, "uriMap.debug" )==0 ) {
  +        _this->debug=atoi( value );
  +    } else if( name[0]=='/' ) {
  +        jk_uriEnv_t *uriEnv=_this->addMapping(env, _this, NULL, name, value);
  +        if ( uriEnv==NULL) {
  +            env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                          "uriMap.init() error adding %s %s\n", name, value);
  +            rc=JK_FALSE;
           }
  +    } else if ( strncmp( name, "uri.", 4) == 0 ) {
  +        return jk2_uriMap_setUriProperty( env, _this, name, value );
  +    } else {
  +        return JK_FALSE;
       }
   
  -    if( _this->debug > 0 )  
  -        env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                      "uriMap.init(): rules=%d properties=\n",
  -                      _this->size, sz );
  +    return rc;
  +}
  +
  +
  +
  +static int jk2_uriMap_init(jk_env_t *env, jk_uriMap_t *_this)
  +{
  +    int rc=JK_TRUE;
  +    int sz;
  +    int err;
  +    int i;
  +    jk_workerEnv_t *workerEnv=_this->workerEnv;
  +
   
       /* Set uriEnv->worker ( can't be done earlier since we might not have
          the workers set up */
  @@ -271,7 +306,6 @@
           }
       }
       
  -    
       return rc;
   }
   
  @@ -491,6 +525,7 @@
       *result=_this;
   
       _this->init=jk2_uriMap_init;
  +    _this->setProperty=jk2_uriMap_setProperty;
       _this->destroy=jk2_uriMap_destroy;
       _this->createUriEnv=jk2_uriEnv_createUriEnv;
       _this->addMapping=jk2_uriMap_addMapping;
  
  
  

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