larryi      01/12/06 16:57:16

  Modified:    jk/native/common jk_uri_worker_map.c
  Log:
  Restore patch supplied by Michael Jennings,
  
  Revision  Changes    Path
  1.13      +57 -15    jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- jk_uri_worker_map.c       2001/12/04 19:44:23     1.12
  +++ jk_uri_worker_map.c       2001/12/07 00:57:16     1.13
  @@ -67,7 +67,7 @@
    * servlet container.                                                      *
    *                                                                         *
    * Author:      Gal Shachor <[EMAIL PROTECTED]>                           *
  - * Version:     $Revision: 1.12 $                                           *
  + * Version:     $Revision: 1.13 $                                           *
    ***************************************************************************/
   
   #include "jk_pool.h"
  @@ -77,6 +77,7 @@
   #define MATCH_TYPE_EXACT    (0)
   #define MATCH_TYPE_CONTEXT  (1)
   #define MATCH_TYPE_SUFFIX   (2)
  +#define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form *ext */
   
   struct uri_worker_record {
       /* Original uri for logging */
  @@ -283,18 +284,31 @@
                       uwr->suffix      = asterisk + 3;
                       uwr->match_type  = MATCH_TYPE_SUFFIX;
                       jk_log(l, JK_LOG_DEBUG,
  -                           "Into jk_uri_worker_map_t::uri_worker_map_open, suffix 
rule %s.%s=%s was added\n",
  -                            uri, asterisk + 3, worker);
  -                } else {
  -                        /* context based */
  -                        asterisk[1]      = '\0';
  -                        uwr->worker_name = worker;
  -                        uwr->context     = uri;
  -                        uwr->suffix      = NULL;
  -                        uwr->match_type  = MATCH_TYPE_CONTEXT;
  -                        jk_log(l, JK_LOG_DEBUG,
  -                              "Into jk_uri_worker_map_t::uri_worker_map_open, match 
rule %s=%s was added\n",
  -                               uri, worker);
  +                           "Into jk_uri_worker_map_t::uri_worker_map_open, "
  +                        "suffix rule %s.%s=%s was added\n",
  +                            uri, asterisk + 3, worker); 
  +             } else if ('\0' != asterisk[2]) {
  +                 /* general suffix rule */
  +                 asterisk[1] = '\0';
  +                 uwr->worker_name = worker;
  +                 uwr->context = uri;
  +                 uwr->suffix  = asterisk + 2;
  +                 uwr->match_type = MATCH_TYPE_GENERAL_SUFFIX;
  +                 jk_log(l, JK_LOG_DEBUG,
  +                        "Into jk_uri_worker_map_t::uri_worker_map_open, "
  +                        "general suffix rule %s*%s=%s was added\n",
  +                        uri, asterisk + 2, worker);
  +             } else {
  +                 /* context based */
  +                 asterisk[1]      = '\0';
  +                 uwr->worker_name = worker;
  +                 uwr->context     = uri;
  +                 uwr->suffix      = NULL;
  +                 uwr->match_type  = MATCH_TYPE_CONTEXT;
  +                 jk_log(l, JK_LOG_DEBUG,
  +                        "Into jk_uri_worker_map_t::uri_worker_map_open, "
  +                        "match rule %s=%s was added\n",
  +                        uri, worker);
                   }
               } else {
                   /* Something like : JkMount /servlets/exampl* ajp13 */
  @@ -396,6 +410,18 @@
       return rc;
   }
   
  +/* returns the index of the last occurrence of the 'ch' character
  +   if ch=='\0' returns the length of the string str  */
  +int last_index_of(const char *str,char ch)
  +{
  +    const char *str_minus_one=str-1;
  +    const char *s=str+strlen(str);
  +    while(s!=str_minus_one && ch!=*s) {
  +     --s;
  +    }
  +    return (s-str);
  +}
  +
   int uri_worker_map_close(jk_uri_worker_map_t *uw_map,
                            jk_logger_t *l)
   {
  @@ -450,7 +476,8 @@
                       if(strlen(uri) == uwr->ctxt_len) {
                        jk_log(l,
                               JK_LOG_DEBUG,
  -                            "jk_uri_worker_map_t::map_uri_to_worker, Found an exact 
match %s -> %s\n",
  +                            "jk_uri_worker_map_t::map_uri_to_worker, "
  +                            "Found an exact match %s -> %s\n",
                               uwr->worker_name,
                               uwr->context );
                           jk_reset_pool(&uw_map->tp);
  @@ -460,11 +487,26 @@
                       if(uwr->ctxt_len > longest_match) {
                        jk_log(l,
                               JK_LOG_DEBUG,
  -                            "jk_uri_worker_map_t::map_uri_to_worker, Found a 
context match %s -> %s\n",
  +                            "jk_uri_worker_map_t::map_uri_to_worker, "
  +                            "Found a context match %s -> %s\n",
                               uwr->worker_name,
                               uwr->context );
                           longest_match = uwr->ctxt_len;
                           best_match = i;
  +                    }
  +             } else if(MATCH_TYPE_GENERAL_SUFFIX == uwr->match_type) {
  +                    int suffix_start=last_index_of(uri,uwr->suffix[0]);
  +                    if (suffix_start>=0 && 0==strcmp(uri+suffix_start,uwr->suffix)) 
{
  +                     if(uwr->ctxt_len >= longest_match) {
  +                         jk_log(l,
  +                                JK_LOG_DEBUG,
  +                                "jk_uri_worker_map_t::map_uri_to_worker, "
  +                                "Found a general suffix match %s -> *%s\n",
  +                                uwr->worker_name,
  +                                uwr->suffix );
  +                         longest_match = uwr->ctxt_len;
  +                         best_match = i;
  +                     }
                       }
                   } else /* suffix match */ {
                       int suffix_start;
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to