You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by br...@apache.org on 2002/02/23 04:12:31 UTC

cvs commit: httpd-2.0/server util_filter.c

brianp      02/02/22 19:12:31

  Modified:    .        CHANGES
               include  util_filter.h
               server   util_filter.c
  Log:
  Added ap_get_input_filter_handle() and ap_get_output_filter_handle()
  Submitted by:	Ryan Morgan
  Reviewed by:	Brian Pane
  
  Revision  Changes    Path
  1.605     +5 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.604
  retrieving revision 1.605
  diff -u -r1.604 -r1.605
  --- CHANGES	22 Feb 2002 05:51:44 -0000	1.604
  +++ CHANGES	23 Feb 2002 03:12:30 -0000	1.605
  @@ -1,5 +1,10 @@
   Changes with Apache 2.0.33-dev
   
  +  *) ap_get_*_filter_handle() functions to allow 3rd party modules
  +     to lookup filter handles so they can bypass the filter name
  +     lookup when adding filters to a request (via ap_add_*_filter_handle())
  +     [Ryan Morgan <rm...@covalent.net>]
  +
     *) Fix for multiple file buckets on Win32, where the first file
        bucket would cause the immediate closure of the socket on any
        non-keepalive requests.  [Ryan Morgan <rm...@covalent.net>]
  
  
  
  1.65      +13 -0     httpd-2.0/include/util_filter.h
  
  Index: util_filter.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/util_filter.h,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- util_filter.h	27 Jan 2002 01:54:54 -0000	1.64
  +++ util_filter.h	23 Feb 2002 03:12:31 -0000	1.65
  @@ -366,6 +366,13 @@
                                                        conn_rec *c);
   
   /**
  + * Returns the filter handle for use with ap_add_input_filter_handle.
  + *
  + * @param name The filter name to look up
  + */
  +AP_DECLARE(ap_filter_rec_t *) ap_get_input_filter_handle(const char *name);
  +
  +/**
    * Add a filter to the current request.  Filters are added in a FIFO manner.
    * The first filter added will be the first filter called.
    * @param name The name of the filter to add
  @@ -388,6 +395,12 @@
                                                         void *ctx,
                                                         request_rec *r,
                                                         conn_rec *c);
  +/**
  + * Returns the filter handle for use with ap_add_output_filter_handle.
  + *
  + * @param name The filter name to look up
  + */
  +AP_DECLARE(ap_filter_rec_t *) ap_get_output_filter_handle(const char *name);
   
   /**
    * Remove an input filter from either the request or connection stack
  
  
  
  1.77      +49 -0     httpd-2.0/server/util_filter.c
  
  Index: util_filter.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/util_filter.c,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- util_filter.c	27 Jan 2002 01:54:54 -0000	1.76
  +++ util_filter.c	23 Feb 2002 03:12:31 -0000	1.77
  @@ -183,6 +183,55 @@
       return APR_SUCCESS;
   }
   
  +static ap_filter_rec_t *get_filter_handle(const char *name,
  +                                          const filter_trie_node *filter_set)
  +{
  +    if (filter_set) {
  +        const char *n;
  +        const filter_trie_node *node;
  +
  +        node = filter_set;
  +        for (n = name; *n; n++) {
  +            int start, end;
  +            start = 0;
  +            end = node->nchildren - 1;
  +            while (end >= start) {
  +                int middle = (end + start) / 2;
  +                char ch = node->children[middle].c;
  +                if (*n == ch) {
  +                    node = node->children[middle].child;
  +                    break;
  +                }
  +                else if (*n < ch) {
  +                    end = middle - 1;
  +                }
  +                else {
  +                    start = middle + 1;
  +                }
  +            }
  +            if (end < start) {
  +                node = NULL;
  +                break;
  +            }
  +        }
  +
  +        if (node && node->frec) {
  +            return node->frec;
  +        }
  +    }
  +    return NULL;
  +}
  +
  +ap_filter_rec_t *ap_get_output_filter_handle(const char *name)
  +{
  +    return get_filter_handle(name, registered_output_filters);
  +}
  +
  +ap_filter_rec_t *ap_get_input_filter_handle(const char *name)
  +{
  +    return get_filter_handle(name, registered_input_filters);
  +}
  +
   static ap_filter_rec_t *register_filter(const char *name,
                               ap_filter_func filter_func,
                               ap_filter_type ftype,