]> granicus.if.org Git - apache/commitdiff
Added ap_get_input_filter_handle() and ap_get_output_filter_handle()
authorBrian Pane <brianp@apache.org>
Sat, 23 Feb 2002 03:12:31 +0000 (03:12 +0000)
committerBrian Pane <brianp@apache.org>
Sat, 23 Feb 2002 03:12:31 +0000 (03:12 +0000)
Submitted by: Ryan Morgan
Reviewed by: Brian Pane

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93544 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/util_filter.h
server/util_filter.c

diff --git a/CHANGES b/CHANGES
index 3c29467e79bebf5cbf74a8710a4b4696075361c3..05f4215bbd4a6ef2ba5429d148f334ed1faf1219 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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 <rmorgan@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 <rmorgan@covalent.net>]
index 0af2d373020f964df1a074875ad16a6269a29119..95846f9f9ae1b4030715efb7ad649b2b59b5c1e0 100644 (file)
@@ -365,6 +365,13 @@ AP_DECLARE(ap_filter_t *) ap_add_input_filter_handle(ap_filter_rec_t *f,
                                                      request_rec *r,
                                                      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.
@@ -388,6 +395,12 @@ AP_DECLARE(ap_filter_t *) ap_add_output_filter_handle(ap_filter_rec_t *f,
                                                       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
index ddda05c1d45c2267f291a5f7068a6559b128882b..157519c83c8c192a2c7ecbe02790cf2f2a6578a8 100644 (file)
@@ -183,6 +183,55 @@ static apr_status_t filter_cleanup(void *ctx)
     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,