You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@locus.apache.org on 2000/09/14 02:34:15 UTC
cvs commit: apache-2.0/src/main util_filter.c
rbb 00/09/13 17:34:15
Modified: src/include util_filter.h
src/main util_filter.c
Log:
Add a pointer to the filter_rec_t from the filter_t. This allows modules
to get to the filter name from the filter itself. This is useful for
modules like mod_perl, which have one filter function that does different
things based on the name used when the filter was inserted.
Revision Changes Path
1.15 +31 -13 apache-2.0/src/include/util_filter.h
Index: util_filter.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/include/util_filter.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- util_filter.h 2000/09/13 23:13:16 1.14
+++ util_filter.h 2000/09/14 00:34:15 1.15
@@ -168,28 +168,46 @@
* the state directly with the request. A callback should not change any of
* the other fields.
*/
+
+typedef struct ap_filter_rec_t ap_filter_rec_t;
+
/**
- * The internal representation of a filter chain. Each request has a list
- * of these structures which are called in turn to filter the data. Sub
- * requests get an exact copy of the main requests filter chain.
+ * This structure is used for recording information about the
+ * registered filters. It associates a name with the filter's callback
+ * and filter type.
+ *
+ * At the moment, these are simply linked in a chain, so a ->next pointer
+ * is available.
*/
-struct ap_filter_t {
- /** The current filter function in the chain. The prototype is:
- * <PRE>
- * apr_status_t (*ap_filter_func)(ap_filter_t *f, ap_bucket_brigade *b);
- * </PRE>
- */
+struct ap_filter_rec_t {
+ /** The registered name for this filter */
+ const char *name;
+ /** The function to call when this filter is invoked. */
ap_filter_func filter_func;
-
- /** A place to store any data associated with the current filter */
- void *ctx;
-
/** The type of filter, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION.
* An AP_FTYPE_CONTENT filter modifies the data based on information
* found in the content. An AP_FTYPE_CONNECTION filter modifies the
* data based on the type of connection.
*/
ap_filter_type ftype;
+
+ /** The next filter_rec in the list */
+ struct ap_filter_rec_t *next;
+};
+
+/**
+ * The representation of a filter chain. Each request has a list
+ * of these structures which are called in turn to filter the data. Sub
+ * requests get an exact copy of the main requests filter chain.
+ */
+struct ap_filter_t {
+ /** The internal representation of this filter. This includes
+ * the filter's name, type, and the actual function pointer.
+ */
+ ap_filter_rec_t *frec;
+
+ /** A place to store any data associated with the current filter */
+ void *ctx;
/** The next filter in the chain */
ap_filter_t *next;
1.17 +4 -23 apache-2.0/src/main/util_filter.c
Index: util_filter.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/util_filter.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- util_filter.c 2000/09/13 23:13:20 1.16
+++ util_filter.c 2000/09/14 00:34:15 1.17
@@ -55,24 +55,6 @@
#include "httpd.h"
#include "util_filter.h"
-/*
- * ap_filter_rec_t:
- *
- * This (internal) structure is used for recording information about the
- * registered filters. It associates a name with the filter's callback
- * and filter type.
- *
- * At the moment, these are simply linked in a chain, so a ->next pointer
- * is available.
- */
-typedef struct ap_filter_rec_t {
- const char *name;
- ap_filter_func filter_func;
- ap_filter_type ftype;
-
- struct ap_filter_rec_t *next;
-} ap_filter_rec_t;
-
/* ### make this visible for direct manipulation?
* ### use a hash table
*/
@@ -91,8 +73,8 @@
** corresponds to a different request.
*/
#define INSERT_BEFORE(f, before_this) ((before_this) == NULL \
- || (before_this)->ftype > (f)->ftype \
- || (before_this)->r != (f)->r)
+ || (before_this)->frec->ftype > (f)->frec->ftype \
+ || (before_this)->r != (f)->r)
static apr_status_t filter_cleanup(void *ctx)
@@ -125,9 +107,8 @@
if (!strcasecmp(name, frec->name)) {
ap_filter_t *f = apr_pcalloc(r->pool, sizeof(*f));
- f->filter_func = frec->filter_func;
+ f->frec = frec;
f->ctx = NULL;
- f->ftype = frec->ftype;
f->r = r;
if (INSERT_BEFORE(f, r->filters)) {
@@ -158,7 +139,7 @@
if (AP_BRIGADE_LAST(bb)->type == AP_BUCKET_EOS) {
next->r->eos_sent = 1;
}
- return next->filter_func(next, bb);
+ return next->frec->filter_func(next, bb);
}
return AP_NOBODY_WROTE;
}
Re: cvs commit: apache-2.0/src/main util_filter.c
Posted by Greg Stein <gs...@lyra.org>.
On Thu, Sep 14, 2000 at 12:34:15AM -0000, rbb@locus.apache.org wrote:
> rbb 00/09/13 17:34:15
>
> Modified: src/include util_filter.h
> src/main util_filter.c
> Log:
> Add a pointer to the filter_rec_t from the filter_t. This allows modules
> to get to the filter name from the filter itself. This is useful for
> modules like mod_perl, which have one filter function that does different
> things based on the name used when the filter was inserted.
Ah. Cool idea. Good call, Ryan.
This would also be a good time to note that the "next" pointer in the
filter_rec_t should probably be toast. When I first wrote the name-based
registration, I think the ap_hash_t stuff was just coming into the codebase.
That should be used rather than a linked list.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/