From 2df244dfda8d0c0ea8458fbde65321a4e85b4824 Mon Sep 17 00:00:00 2001 From: Brian Pane Date: Sat, 23 Feb 2002 03:12:31 +0000 Subject: [PATCH] Added ap_get_input_filter_handle() and ap_get_output_filter_handle() 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 | 5 +++++ include/util_filter.h | 13 ++++++++++++ server/util_filter.c | 49 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/CHANGES b/CHANGES index 3c29467e79..05f4215bbd 100644 --- 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 ] + *) 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 ] diff --git a/include/util_filter.h b/include/util_filter.h index 0af2d37302..95846f9f9a 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -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 diff --git a/server/util_filter.c b/server/util_filter.c index ddda05c1d4..157519c83c 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -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, -- 2.50.1