842ae4bd224140319ae7feec1872b93dfd491143fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
842ae4bd224140319ae7feec1872b93dfd491143fielding * contributor license agreements. See the NOTICE file distributed with
842ae4bd224140319ae7feec1872b93dfd491143fielding * this work for additional information regarding copyright ownership.
842ae4bd224140319ae7feec1872b93dfd491143fielding * The ASF licenses this file to You under the Apache License, Version 2.0
842ae4bd224140319ae7feec1872b93dfd491143fielding * (the "License"); you may not use this file except in compliance with
842ae4bd224140319ae7feec1872b93dfd491143fielding * the License. You may obtain a copy of the License at
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * http://www.apache.org/licenses/LICENSE-2.0
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * See the License for the specific language governing permissions and
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * limitations under the License.
777a2b42697cb8cb94ac4e73774862f879259c45rbb */
777a2b42697cb8cb94ac4e73774862f879259c45rbb
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh/**
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @file util_filter.h
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @brief Apache filter library
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh */
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh
777a2b42697cb8cb94ac4e73774862f879259c45rbb#ifndef AP_FILTER_H
777a2b42697cb8cb94ac4e73774862f879259c45rbb#define AP_FILTER_H
777a2b42697cb8cb94ac4e73774862f879259c45rbb
1b21d7b3d97def358b2e923655edeb16613a1c31gstein#include "apr.h"
1b21d7b3d97def358b2e923655edeb16613a1c31gstein#include "apr_buckets.h"
1b21d7b3d97def358b2e923655edeb16613a1c31gstein
1b21d7b3d97def358b2e923655edeb16613a1c31gstein#include "httpd.h"
777a2b42697cb8cb94ac4e73774862f879259c45rbb
1b21d7b3d97def358b2e923655edeb16613a1c31gstein#if APR_HAVE_STDARG_H
777a2b42697cb8cb94ac4e73774862f879259c45rbb#include <stdarg.h>
777a2b42697cb8cb94ac4e73774862f879259c45rbb#endif
777a2b42697cb8cb94ac4e73774862f879259c45rbb
1b21d7b3d97def358b2e923655edeb16613a1c31gstein#ifdef __cplusplus
1b21d7b3d97def358b2e923655edeb16613a1c31gsteinextern "C" {
1b21d7b3d97def358b2e923655edeb16613a1c31gstein#endif
777a2b42697cb8cb94ac4e73774862f879259c45rbb
3956c8e2379e6e93304feb84c68aadb77ffed7c1ben/**
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @brief input filtering modes
adf7d02333af28c448efc203c1d2edbc8f38a27btrawick */
adf7d02333af28c448efc203c1d2edbc8f38a27btrawicktypedef enum {
7727f4c9a1ac856edd057f21c4b8dbf63c6c9eefjerenkrantz /** The filter should return at most readbytes data. */
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz AP_MODE_READBYTES,
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz /** The filter should return at most one line of CRLF data.
742318b93e89c311f66b55f426c4d9cf2c14628bjim * (If a potential line is too long or no CRLF is found, the
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * filter may return partial data).
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz */
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz AP_MODE_GETLINE,
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz /** The filter should implicitly eat any CRLF pairs that it sees. */
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz AP_MODE_EATCRLF,
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz /** The filter read should be treated as speculative and any returned
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * data should be stored for later retrieval in another mode. */
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz AP_MODE_SPECULATIVE,
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz /** The filter read should be exhaustive and read until it can not
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * read any more.
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * Use this mode with extreme caution.
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz */
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz AP_MODE_EXHAUSTIVE,
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz /** The filter should initialize the connection if needed,
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * NNTP or FTP over SSL for example.
549e2baf2aacee81cef45f4684520691bacf35f9dougm */
549e2baf2aacee81cef45f4684520691bacf35f9dougm AP_MODE_INIT
adf7d02333af28c448efc203c1d2edbc8f38a27btrawick} ap_input_mode_t;
3515be87ebb5aa9a49f8a782d0d657d0d064be08rbb
0e26447b7de129241ee60331f51b17f0cdf19825ben/**
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @defgroup APACHE_CORE_FILTER Filter Chain
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @ingroup APACHE_CORE
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * Filters operate using a "chaining" mechanism. The filters are chained
777a2b42697cb8cb94ac4e73774862f879259c45rbb * together into a sequence. When output is generated, it is passed through
777a2b42697cb8cb94ac4e73774862f879259c45rbb * each of the filters on this chain, until it reaches the end (or "bottom")
777a2b42697cb8cb94ac4e73774862f879259c45rbb * and is placed onto the network.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * The top of the chain, the code generating the output, is typically called
777a2b42697cb8cb94ac4e73774862f879259c45rbb * a "content generator." The content generator's output is fed into the
777a2b42697cb8cb94ac4e73774862f879259c45rbb * filter chain using the standard Apache output mechanisms: ap_rputs(),
777a2b42697cb8cb94ac4e73774862f879259c45rbb * ap_rprintf(), ap_rwrite(), etc.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * Each filter is defined by a callback. This callback takes the output from
777a2b42697cb8cb94ac4e73774862f879259c45rbb * the previous filter (or the content generator if there is no previous
777a2b42697cb8cb94ac4e73774862f879259c45rbb * filter), operates on it, and passes the result to the next filter in the
777a2b42697cb8cb94ac4e73774862f879259c45rbb * chain. This pass-off is performed using the ap_fc_* functions, such as
777a2b42697cb8cb94ac4e73774862f879259c45rbb * ap_fc_puts(), ap_fc_printf(), ap_fc_write(), etc.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * When content generation is complete, the system will pass an "end of
777a2b42697cb8cb94ac4e73774862f879259c45rbb * stream" marker into the filter chain. The filters will use this to flush
777a2b42697cb8cb94ac4e73774862f879259c45rbb * out any internal state and to detect incomplete syntax (for example, an
777a2b42697cb8cb94ac4e73774862f879259c45rbb * unterminated SSI directive).
8c2acc2f875e661fd34f233553d90c58894d5b1bpoirier *
8c2acc2f875e661fd34f233553d90c58894d5b1bpoirier * @{
777a2b42697cb8cb94ac4e73774862f879259c45rbb */
777a2b42697cb8cb94ac4e73774862f879259c45rbb
777a2b42697cb8cb94ac4e73774862f879259c45rbb/* forward declare the filter type */
5ec83c51991ec074c58c0bc68f5842628a9179darbbtypedef struct ap_filter_t ap_filter_t;
777a2b42697cb8cb94ac4e73774862f879259c45rbb
0e26447b7de129241ee60331f51b17f0cdf19825ben/**
0e26447b7de129241ee60331f51b17f0cdf19825ben * @name Filter callbacks
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * This function type is used for filter callbacks. It will be passed a
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * pointer to "this" filter, and a "bucket brigade" containing the content
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * to be filtered.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * In filter->ctx, the callback will find its context. This context is
777a2b42697cb8cb94ac4e73774862f879259c45rbb * provided here, so that a filter may be installed multiple times, each
777a2b42697cb8cb94ac4e73774862f879259c45rbb * receiving its own per-install context pointer.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * Callbacks are associated with a filter definition, which is specified
dddcaef56e65bdada3dde770f59c1838320f362etrawick * by name. See ap_register_input_filter() and ap_register_output_filter()
742318b93e89c311f66b55f426c4d9cf2c14628bjim * for setting the association between a name for a filter and its
dddcaef56e65bdada3dde770f59c1838320f362etrawick * associated callback (and other information).
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz * If the initialization function argument passed to the registration
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz * functions is non-NULL, it will be called iff the filter is in the input
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz * or output filter chains and before any data is generated to allow the
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz * filter to prepare for processing.
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz *
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * The bucket brigade always belongs to the caller, but the filter
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * is free to use the buckets within it as it sees fit. Normally,
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * the brigade will be returned empty. Buckets *may not* be retained
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * between successive calls to the filter unless they have been
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * "set aside" with a call apr_bucket_setaside. Typically this will
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * be done with ap_save_brigade(). Buckets removed from the brigade
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * become the responsibility of the filter, which must arrange for
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * them to be deleted, either by doing so directly or by inserting
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * them in a brigade which will subsequently be destroyed.
e485880d90245d55fd2f6808fd81819a31feef89trawick *
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz * For the input and output filters, the return value of a filter should be
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz * an APR status value. For the init function, the return value should
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz * be an HTTP error code or OK if it was successful.
742318b93e89c311f66b55f426c4d9cf2c14628bjim *
0e26447b7de129241ee60331f51b17f0cdf19825ben * @ingroup filter
0e26447b7de129241ee60331f51b17f0cdf19825ben * @{
777a2b42697cb8cb94ac4e73774862f879259c45rbb */
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantztypedef apr_status_t (*ap_out_filter_func)(ap_filter_t *f,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz apr_bucket_brigade *b);
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantztypedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f,
742318b93e89c311f66b55f426c4d9cf2c14628bjim apr_bucket_brigade *b,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz ap_input_mode_t mode,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz apr_read_type_e block,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz apr_off_t readbytes);
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantztypedef int (*ap_init_filter_func)(ap_filter_t *f);
a3a9ceac1bc30598c594c89e1382609496b7752brbb
3515be87ebb5aa9a49f8a782d0d657d0d064be08rbbtypedef union ap_filter_func {
3515be87ebb5aa9a49f8a782d0d657d0d064be08rbb ap_out_filter_func out_func;
3515be87ebb5aa9a49f8a782d0d657d0d064be08rbb ap_in_filter_func in_func;
3515be87ebb5aa9a49f8a782d0d657d0d064be08rbb} ap_filter_func;
777a2b42697cb8cb94ac4e73774862f879259c45rbb
0e26447b7de129241ee60331f51b17f0cdf19825ben/** @} */
0e26447b7de129241ee60331f51b17f0cdf19825ben
3956c8e2379e6e93304feb84c68aadb77ffed7c1ben/**
777a2b42697cb8cb94ac4e73774862f879259c45rbb * Filters have different types/classifications. These are used to group
777a2b42697cb8cb94ac4e73774862f879259c45rbb * and sort the filters to properly sequence their operation.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * The types have a particular sort order, which allows us to insert them
777a2b42697cb8cb94ac4e73774862f879259c45rbb * into the filter chain in a determistic order. Within a particular grouping,
d025a1bfef81af5c3a1e784762bf27971114b6e3trawick * the ordering is equivalent to the order of calls to ap_add_*_filter().
777a2b42697cb8cb94ac4e73774862f879259c45rbb */
777a2b42697cb8cb94ac4e73774862f879259c45rbbtypedef enum {
0e26447b7de129241ee60331f51b17f0cdf19825ben /** These filters are used to alter the content that is passed through
0e26447b7de129241ee60331f51b17f0cdf19825ben * them. Examples are SSI or PHP. */
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz AP_FTYPE_RESOURCE = 10,
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz /** These filters are used to alter the content as a whole, but after all
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz * AP_FTYPE_RESOURCE filters are executed. These filters should not
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz * change the content-type. An example is deflate. */
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz AP_FTYPE_CONTENT_SET = 20,
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz /** These filters are used to handle the protocol between server and
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz * client. Examples are HTTP and POP. */
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz AP_FTYPE_PROTOCOL = 30,
0e26447b7de129241ee60331f51b17f0cdf19825ben /** These filters implement transport encodings (e.g., chunking). */
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz AP_FTYPE_TRANSCODE = 40,
0e26447b7de129241ee60331f51b17f0cdf19825ben /** These filters will alter the content, but in ways that are
0e26447b7de129241ee60331f51b17f0cdf19825ben * more strongly associated with the connection. Examples are
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz * splitting an HTTP connection into multiple requests and
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz * buffering HTTP responses across multiple requests.
0e26447b7de129241ee60331f51b17f0cdf19825ben *
0e26447b7de129241ee60331f51b17f0cdf19825ben * It is important to note that these types of filters are not
0e26447b7de129241ee60331f51b17f0cdf19825ben * allowed in a sub-request. A sub-request's output can certainly
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz * be filtered by ::AP_FTYPE_RESOURCE filters, but all of the "final
0e26447b7de129241ee60331f51b17f0cdf19825ben * processing" is determined by the main request. */
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz AP_FTYPE_CONNECTION = 50,
0e26447b7de129241ee60331f51b17f0cdf19825ben /** These filters don't alter the content. They are responsible for
0e26447b7de129241ee60331f51b17f0cdf19825ben * sending/receiving data to/from the client. */
1f863242c3901a633082bab8a34e8cb7422ab421jerenkrantz AP_FTYPE_NETWORK = 60
777a2b42697cb8cb94ac4e73774862f879259c45rbb} ap_filter_type;
777a2b42697cb8cb94ac4e73774862f879259c45rbb
0e26447b7de129241ee60331f51b17f0cdf19825ben/**
777a2b42697cb8cb94ac4e73774862f879259c45rbb * This is the request-time context structure for an installed filter (in
777a2b42697cb8cb94ac4e73774862f879259c45rbb * the output filter chain). It provides the callback to use for filtering,
777a2b42697cb8cb94ac4e73774862f879259c45rbb * the request this filter is associated with (which is important when
777a2b42697cb8cb94ac4e73774862f879259c45rbb * an output chain also includes sub-request filters), the context for this
777a2b42697cb8cb94ac4e73774862f879259c45rbb * installed filter, and the filter ordering/chaining fields.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * Filter callbacks are free to use ->ctx as they please, to store context
777a2b42697cb8cb94ac4e73774862f879259c45rbb * during the filter process. Generally, this is superior over associating
777a2b42697cb8cb94ac4e73774862f879259c45rbb * the state directly with the request. A callback should not change any of
777a2b42697cb8cb94ac4e73774862f879259c45rbb * the other fields.
777a2b42697cb8cb94ac4e73774862f879259c45rbb */
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbbtypedef struct ap_filter_rec_t ap_filter_rec_t;
ae3dea49b7dbd3cdf991225881cf01e62689af2bniqtypedef struct ap_filter_provider_t ap_filter_provider_t;
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb/**
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * @brief This structure is used for recording information about the
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb * registered filters. It associates a name with the filter's callback
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb * and filter type.
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb *
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb * At the moment, these are simply linked in a chain, so a ->next pointer
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb * is available.
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq *
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * It is used for any filter that can be inserted in the filter chain.
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * This may be either a httpd-2.0 filter or a mod_filter harness.
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * In the latter case it contains dispatch, provider and protocol information.
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * In the former case, the new fields (from dispatch) are ignored.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb */
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbbstruct ap_filter_rec_t {
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb /** The registered name for this filter */
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb const char *name;
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb /** The function to call when this filter is invoked. */
5ec83c51991ec074c58c0bc68f5842628a9179darbb ap_filter_func filter_func;
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
f55c048e33a905f9f771b3aed309373bdf547944jorton /** The function to call directly before the handlers are invoked
f55c048e33a905f9f771b3aed309373bdf547944jorton * for a request. The init function is called once directly
f55c048e33a905f9f771b3aed309373bdf547944jorton * before running the handlers for a request or subrequest. The
f55c048e33a905f9f771b3aed309373bdf547944jorton * init function is never called for a connection filter (with
f55c048e33a905f9f771b3aed309373bdf547944jorton * ftype >= AP_FTYPE_CONNECTION). Any use of this function for
f55c048e33a905f9f771b3aed309373bdf547944jorton * filters for protocols other than HTTP is specified by the
f55c048e33a905f9f771b3aed309373bdf547944jorton * module supported that protocol.
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd */
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz ap_init_filter_func filter_init_func;
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
78b8e4dd910f03af0a602bc4b63ad7bc69868ee3sf /** The next filter_rec in the list */
78b8e4dd910f03af0a602bc4b63ad7bc69868ee3sf struct ap_filter_rec_t *next;
78b8e4dd910f03af0a602bc4b63ad7bc69868ee3sf
78b8e4dd910f03af0a602bc4b63ad7bc69868ee3sf /** Providers for this filter */
78b8e4dd910f03af0a602bc4b63ad7bc69868ee3sf ap_filter_provider_t *providers;
78b8e4dd910f03af0a602bc4b63ad7bc69868ee3sf
742318b93e89c311f66b55f426c4d9cf2c14628bjim /** The type of filter, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION.
742318b93e89c311f66b55f426c4d9cf2c14628bjim * An AP_FTYPE_CONTENT filter modifies the data based on information
742318b93e89c311f66b55f426c4d9cf2c14628bjim * found in the content. An AP_FTYPE_CONNECTION filter modifies the
202c633165f350489d9636eb4ef13382d4a63a37trawick * data based on the type of connection.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb */
777a2b42697cb8cb94ac4e73774862f879259c45rbb ap_filter_type ftype;
39ea23a6f1e9f16523562766f568d039b1bd9224gstein
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq /** Trace level for this filter */
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd int debug;
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq /** Protocol flags for this filter */
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd unsigned int proto_flags;
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq};
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb/**
742318b93e89c311f66b55f426c4d9cf2c14628bjim * @brief The representation of a filter chain.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh *
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * Each request has a list
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb * of these structures which are called in turn to filter the data. Sub
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb * requests get an exact copy of the main requests filter chain.
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb */
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbbstruct ap_filter_t {
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz /** The internal representation of this filter. This includes
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz * the filter's name, type, and the actual function pointer.
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb */
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb ap_filter_rec_t *frec;
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb /** A place to store any data associated with the current filter */
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb void *ctx;
018c3674550f6780e0cebce1f4ffeb9c7674a5c5rbb
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb /** The next filter in the chain */
5ec83c51991ec074c58c0bc68f5842628a9179darbb ap_filter_t *next;
39ea23a6f1e9f16523562766f568d039b1bd9224gstein
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb /** The request_rec associated with the current filter. If a sub-request
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb * adds filters, then the sub-request is the request associated with the
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb * filter.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb */
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb request_rec *r;
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb /** The conn_rec associated with the current filter. This is analogous
a48b22d9c123cf19ee68a5023d3906e197ff50a8niq * to the request_rec, except that it is used for connection filters.
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb */
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb conn_rec *c;
777a2b42697cb8cb94ac4e73774862f879259c45rbb};
777a2b42697cb8cb94ac4e73774862f879259c45rbb
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb/**
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb * Get the current bucket brigade from the next filter on the filter
742318b93e89c311f66b55f426c4d9cf2c14628bjim * stack. The filter returns an apr_status_t value. If the bottom-most
778f64d5286aec7d63f91a8d6143daba9f713f9cianh * filter doesn't read from the network, then ::AP_NOBODY_READ is returned.
8262e4bc77385e421302dd4d719e1182a910de1daaron * The bucket brigade will be empty when there is nothing left to get.
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb * @param filter The next filter in the chain
a80bebbcea891b0c9c73a49872c64a137f84fffabrianp * @param bucket The current bucket brigade. The original brigade passed
a80bebbcea891b0c9c73a49872c64a137f84fffabrianp * to ap_get_brigade() must be empty.
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * @param mode The way in which the data should be read
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * @param block How the operations should be performed
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * ::APR_BLOCK_READ, ::APR_NONBLOCK_READ
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz * @param readbytes How many bytes to read from the next filter.
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb */
742318b93e89c311f66b55f426c4d9cf2c14628bjimAP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *filter,
742318b93e89c311f66b55f426c4d9cf2c14628bjim apr_bucket_brigade *bucket,
3fde4c273ea649d1320ec9c51e7d096cd9340a94jerenkrantz ap_input_mode_t mode,
742318b93e89c311f66b55f426c4d9cf2c14628bjim apr_read_type_e block,
7727f4c9a1ac856edd057f21c4b8dbf63c6c9eefjerenkrantz apr_off_t readbytes);
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb/**
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb * Pass the current bucket brigade down to the next filter on the filter
742318b93e89c311f66b55f426c4d9cf2c14628bjim * stack. The filter returns an apr_status_t value. If the bottom-most
0e26447b7de129241ee60331f51b17f0cdf19825ben * filter doesn't write to the network, then ::AP_NOBODY_WROTE is returned.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb * @param filter The next filter in the chain
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb * @param bucket The current bucket brigade
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf *
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * @remark Ownership of the brigade is retained by the caller. On return,
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * the contents of the brigade are UNDEFINED, and the caller must
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * either call apr_brigade_cleanup or apr_brigade_destroy on
08cbd6e24e1253e030bd7a29f95f98f8d4164c14sf * the brigade.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb */
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantzAP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *filter,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz apr_bucket_brigade *bucket);
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim/**
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * Pass the current bucket brigade down to the next filter on the filter
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * stack checking for filter errors. The filter returns an apr_status_t value.
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * Returns ::OK if the brigade is successfully passed
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * ::AP_FILTER_ERROR on a filter error
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * ::HTTP_INTERNAL_SERVER_ERROR on all other errors
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * @param r The request rec
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * @param bucket The current bucket brigade
eed23c0ffbac879e3502737c44070dc1212daeb0jim * @param fmt The format string. If NULL defaults to "ap_pass_brigade returned"
eed23c0ffbac879e3502737c44070dc1212daeb0jim * @param ... The arguments to use to fill out the format string
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * @remark Ownership of the brigade is retained by the caller. On return,
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * the contents of the brigade are UNDEFINED, and the caller must
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * either call apr_brigade_cleanup or apr_brigade_destroy on
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim * the brigade.
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim */
5fcee27172ebd5529ba056deaf01a3755fc4ae05jimAP_DECLARE(apr_status_t) ap_pass_brigade_fchk(request_rec *r,
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim apr_bucket_brigade *bucket,
eed23c0ffbac879e3502737c44070dc1212daeb0jim const char *fmt,
4c6374798c9e6c0fc3b42dbc5a7225f67d27cb9fjailletc ...)
4c6374798c9e6c0fc3b42dbc5a7225f67d27cb9fjailletc __attribute__((format(printf,3,4)));
5fcee27172ebd5529ba056deaf01a3755fc4ae05jim
3956c8e2379e6e93304feb84c68aadb77ffed7c1ben/**
742318b93e89c311f66b55f426c4d9cf2c14628bjim * This function is used to register an input filter with the system.
742318b93e89c311f66b55f426c4d9cf2c14628bjim * After this registration is performed, then a filter may be added
742318b93e89c311f66b55f426c4d9cf2c14628bjim * into the filter chain by using ap_add_input_filter() and simply
d025a1bfef81af5c3a1e784762bf27971114b6e3trawick * specifying the name.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb * @param name The name to attach to the filter function
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb * @param filter_func The filter function to name
742318b93e89c311f66b55f426c4d9cf2c14628bjim * @param filter_init The function to call before the filter handlers
d035ac1624529ffe2b40d3e4d59c8fe731e4f396jerenkrantz are invoked
3bd0e50248c06f4a61404a93f9e1acc7f26c8464sf * @param ftype The type of filter function, either ::AP_FTYPE_CONTENT_SET or
d035ac1624529ffe2b40d3e4d59c8fe731e4f396jerenkrantz * ::AP_FTYPE_CONNECTION
0e26447b7de129241ee60331f51b17f0cdf19825ben * @see add_input_filter()
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb */
fd492f9543f14fb5bae78e04b135c3448eb9cc56rbbAP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz ap_in_filter_func filter_func,
0fdf8c342123fde84405b885fb1720ebc652e10djerenkrantz ap_init_filter_func filter_init,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz ap_filter_type ftype);
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
d6f31486d449475eb8656f3f6dc874cac70a12eaniq/** @deprecated @see ap_register_output_filter_protocol */
d6f31486d449475eb8656f3f6dc874cac70a12eaniqAP_DECLARE(ap_filter_rec_t *) ap_register_output_filter(const char *name,
d6f31486d449475eb8656f3f6dc874cac70a12eaniq ap_out_filter_func filter_func,
d6f31486d449475eb8656f3f6dc874cac70a12eaniq ap_init_filter_func filter_init,
d6f31486d449475eb8656f3f6dc874cac70a12eaniq ap_filter_type ftype);
d6f31486d449475eb8656f3f6dc874cac70a12eaniq
d6f31486d449475eb8656f3f6dc874cac70a12eaniq/* For httpd-?.? I suggest replacing the above with
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq#define ap_register_output_filter(name,ffunc,init,ftype) \
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq ap_register_output_filter_protocol(name,ffunc,init,ftype,0)
d6f31486d449475eb8656f3f6dc874cac70a12eaniq*/
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq/**
742318b93e89c311f66b55f426c4d9cf2c14628bjim * This function is used to register an output filter with the system.
742318b93e89c311f66b55f426c4d9cf2c14628bjim * After this registration is performed, then a filter may be added
d6f31486d449475eb8656f3f6dc874cac70a12eaniq * directly to the filter chain by using ap_add_output_filter() and
d6f31486d449475eb8656f3f6dc874cac70a12eaniq * simply specifying the name, or as a provider under mod_filter.
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq *
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * @param name The name to attach to the filter function
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * @param filter_func The filter function to name
742318b93e89c311f66b55f426c4d9cf2c14628bjim * @param filter_init The function to call before the filter handlers
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * are invoked
3bd0e50248c06f4a61404a93f9e1acc7f26c8464sf * @param ftype The type of filter function, either ::AP_FTYPE_CONTENT_SET or
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * ::AP_FTYPE_CONNECTION
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * @param proto_flags Protocol flags: logical OR of AP_FILTER_PROTO_* bits
d6f31486d449475eb8656f3f6dc874cac70a12eaniq * @return the filter rec
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * @see ap_add_output_filter()
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq */
ae3dea49b7dbd3cdf991225881cf01e62689af2bniqAP_DECLARE(ap_filter_rec_t *) ap_register_output_filter_protocol(
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq const char *name,
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq ap_out_filter_func filter_func,
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq ap_init_filter_func filter_init,
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq ap_filter_type ftype,
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq unsigned int proto_flags);
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq
0e26447b7de129241ee60331f51b17f0cdf19825ben/**
777a2b42697cb8cb94ac4e73774862f879259c45rbb * Adds a named filter into the filter chain on the specified request record.
777a2b42697cb8cb94ac4e73774862f879259c45rbb * The filter will be installed with the specified context pointer.
777a2b42697cb8cb94ac4e73774862f879259c45rbb *
777a2b42697cb8cb94ac4e73774862f879259c45rbb * Filters added in this way will always be placed at the end of the filters
777a2b42697cb8cb94ac4e73774862f879259c45rbb * that have the same type (thus, the filters have the same order as the
777a2b42697cb8cb94ac4e73774862f879259c45rbb * calls to ap_add_filter). If the current filter chain contains filters
777a2b42697cb8cb94ac4e73774862f879259c45rbb * from another request, then this filter will be added before those other
777a2b42697cb8cb94ac4e73774862f879259c45rbb * filters.
742318b93e89c311f66b55f426c4d9cf2c14628bjim *
2960eb12428663adcf10ae5b21fcc2b7d85267b9gstein * To re-iterate that last comment. This function is building a FIFO
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * list of filters. Take note of that when adding your filter to the chain.
0e26447b7de129241ee60331f51b17f0cdf19825ben *
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb * @param name The name of the filter to add
555821af769fb8ba20263265e9ea631037fc129btrawick * @param ctx Context data to provide to the filter
5fac642ef2ee110540c3a391e4cf1d166ba57d0ftrawick * @param r The request to add this filter for (or NULL if it isn't associated with a request)
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb * @param c The connection to add the fillter for
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb */
2a0c3663b66c9af764267ac3c4e140e659598474benAP_DECLARE(ap_filter_t *) ap_add_input_filter(const char *name, void *ctx,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz request_rec *r, conn_rec *c);
91f8fecd254fcdfcde4607b28ee192276c29c1a2rbb
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp/**
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp * Variant of ap_add_input_filter() that accepts a registered filter handle
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp * (as returned by ap_register_input_filter()) rather than a filter name
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp *
637cc23fb69802467f54ab3a3cc3b9d96df66471jerenkrantz * @param f The filter handle to add
555821af769fb8ba20263265e9ea631037fc129btrawick * @param ctx Context data to provide to the filter
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp * @param r The request to add this filter for (or NULL if it isn't associated with a request)
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp * @param c The connection to add the fillter for
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp */
435c423bdcfa61ff871a9e289d1140f2bac839b8brianpAP_DECLARE(ap_filter_t *) ap_add_input_filter_handle(ap_filter_rec_t *f,
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp void *ctx,
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp request_rec *r,
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp conn_rec *c);
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp/**
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp * Returns the filter handle for use with ap_add_input_filter_handle.
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp *
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp * @param name The filter name to look up
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp */
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianpAP_DECLARE(ap_filter_rec_t *) ap_get_input_filter_handle(const char *name);
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb/**
2960eb12428663adcf10ae5b21fcc2b7d85267b9gstein * Add a filter to the current request. Filters are added in a FIFO manner.
2960eb12428663adcf10ae5b21fcc2b7d85267b9gstein * The first filter added will be the first filter called.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb * @param name The name of the filter to add
d025a1bfef81af5c3a1e784762bf27971114b6e3trawick * @param ctx Context data to set in the filter
d025a1bfef81af5c3a1e784762bf27971114b6e3trawick * @param r The request to add this filter for (or NULL if it isn't associated with a request)
d025a1bfef81af5c3a1e784762bf27971114b6e3trawick * @param c The connection to add this filter for
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * @note If adding a connection-level output filter (i.e. where the type
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * is >= AP_FTYPE_CONNECTION) during processing of a request, the request
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * object r must be passed in to ensure the filter chains are modified
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * correctly. f->r will still be initialized as NULL in the new filter.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb */
742318b93e89c311f66b55f426c4d9cf2c14628bjimAP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz request_rec *r, conn_rec *c);
777a2b42697cb8cb94ac4e73774862f879259c45rbb
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp/**
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp * Variant of ap_add_output_filter() that accepts a registered filter handle
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp * (as returned by ap_register_output_filter()) rather than a filter name
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp *
637cc23fb69802467f54ab3a3cc3b9d96df66471jerenkrantz * @param f The filter handle to add
c779aea0c9b7c47c2e4fd258e3f54835a849625dpoirier * @param ctx Context data to set in the filter
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp * @param r The request to add this filter for (or NULL if it isn't associated with a request)
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * @param c The connection to add the filter for
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * @note If adding a connection-level output filter (i.e. where the type
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * is >= AP_FTYPE_CONNECTION) during processing of a request, the request
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * object r must be passed in to ensure the filter chains are modified
bc0ebf8a6b6f96df7f05ced975fc5fd4f5846607jorton * correctly. f->r will still be initialized as NULL in the new filter.
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp */
435c423bdcfa61ff871a9e289d1140f2bac839b8brianpAP_DECLARE(ap_filter_t *) ap_add_output_filter_handle(ap_filter_rec_t *f,
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp void *ctx,
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp request_rec *r,
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp conn_rec *c);
637cc23fb69802467f54ab3a3cc3b9d96df66471jerenkrantz
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp/**
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp * Returns the filter handle for use with ap_add_output_filter_handle.
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp *
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp * @param name The filter name to look up
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianp */
7a8a0744e378f2343c3ee6787fac0f8f959d2141brianpAP_DECLARE(ap_filter_rec_t *) ap_get_output_filter_handle(const char *name);
435c423bdcfa61ff871a9e289d1140f2bac839b8brianp
13bac43a0f21d8c6401debc1baa76be984474074rbb/**
13bac43a0f21d8c6401debc1baa76be984474074rbb * Remove an input filter from either the request or connection stack
13bac43a0f21d8c6401debc1baa76be984474074rbb * it is associated with.
13bac43a0f21d8c6401debc1baa76be984474074rbb * @param f The filter to remove
13bac43a0f21d8c6401debc1baa76be984474074rbb */
13bac43a0f21d8c6401debc1baa76be984474074rbb
13bac43a0f21d8c6401debc1baa76be984474074rbbAP_DECLARE(void) ap_remove_input_filter(ap_filter_t *f);
13bac43a0f21d8c6401debc1baa76be984474074rbb
0e26447b7de129241ee60331f51b17f0cdf19825ben/**
0e26447b7de129241ee60331f51b17f0cdf19825ben * Remove an output filter from either the request or connection stack
0e26447b7de129241ee60331f51b17f0cdf19825ben * it is associated with.
0e26447b7de129241ee60331f51b17f0cdf19825ben * @param f The filter to remove
0e26447b7de129241ee60331f51b17f0cdf19825ben */
0e26447b7de129241ee60331f51b17f0cdf19825ben
bffadf7ad3d13f1141c0d681d033d2eaf55562e8rbbAP_DECLARE(void) ap_remove_output_filter(ap_filter_t *f);
bffadf7ad3d13f1141c0d681d033d2eaf55562e8rbb
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim/**
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * Remove an input filter from either the request or connection stack
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * it is associated with.
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * @param next The filter stack to search
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * @param handle The filter handle (name) to remove
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * @return APR_SUCCESS on removal or error
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim */
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejimAP_DECLARE(apr_status_t) ap_remove_input_filter_byhandle(ap_filter_t *next,
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim const char *handle);
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim/**
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * Remove an output filter from either the request or connection stack
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * it is associated with.
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * @param next The filter stack to search
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * @param handle The filter handle (name) to remove
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim * @return APR_SUCCESS on removal or error
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim */
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejimAP_DECLARE(apr_status_t) ap_remove_output_filter_byhandle(ap_filter_t *next,
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim const char *handle);
b1de4d11181d00bd6a3bf45b4b5a7a5f30b2714ejim
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb/* The next two filters are for abstraction purposes only. They could be
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * done away with, but that would require that we break modules if we ever
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * want to change our filter registration method. The basic idea, is that
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * all filters have a place to store data, the ctx pointer. These functions
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * fill out that pointer with a bucket brigade, and retrieve that data on
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * the next call. The nice thing about these functions, is that they
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * automatically concatenate the bucket brigades together for you. This means
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * that if you have already stored a brigade in the filters ctx pointer, then
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * when you add more it will be tacked onto the end of that brigade. When
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * you retrieve data, if you pass in a bucket brigade to the get function,
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * it will append the current brigade onto the one that you are retrieving.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb */
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb/**
742318b93e89c311f66b55f426c4d9cf2c14628bjim * prepare a bucket brigade to be setaside. If a different brigade was
d5c441f3a1b7ba48984481b8e29427f7edefbfb4rbb * set-aside earlier, then the two brigades are concatenated together.
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb * @param f The current filter
d5c441f3a1b7ba48984481b8e29427f7edefbfb4rbb * @param save_to The brigade that was previously set-aside. Regardless, the
d5c441f3a1b7ba48984481b8e29427f7edefbfb4rbb * new bucket brigade is returned in this location.
d5c441f3a1b7ba48984481b8e29427f7edefbfb4rbb * @param b The bucket brigade to save aside. This brigade is always empty
d5c441f3a1b7ba48984481b8e29427f7edefbfb4rbb * on return
9ce0a03f13db4815dd3e554409d672caa1a4671drbb * @param p Ensure that all data in the brigade lives as long as this pool
b48e8c04bf8b674b2b355c11aeef7f84d609fb85rbb */
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantzAP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz apr_bucket_brigade **save_to,
742318b93e89c311f66b55f426c4d9cf2c14628bjim apr_bucket_brigade **b, apr_pool_t *p);
777a2b42697cb8cb94ac4e73774862f879259c45rbb
2d87d8f191175a0683f430d790d81a5604b74ec6rbb/**
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * Flush function for apr_brigade_* calls. This calls ap_pass_brigade
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * to flush the brigade if the brigade buffer overflows.
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param bb The brigade to flush
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param ctx The filter to pass the brigade to
4d8204ebc873f65aa26f36f3285b1581d22242bbgstein * @note this function has nothing to do with FLUSH buckets. It is simply
4d8204ebc873f65aa26f36f3285b1581d22242bbgstein * a way to flush content out of a brigade and down a filter stack.
2d87d8f191175a0683f430d790d81a5604b74ec6rbb */
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantzAP_DECLARE_NONSTD(apr_status_t) ap_filter_flush(apr_bucket_brigade *bb,
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz void *ctx);
2d87d8f191175a0683f430d790d81a5604b74ec6rbb
2d87d8f191175a0683f430d790d81a5604b74ec6rbb/**
0e26447b7de129241ee60331f51b17f0cdf19825ben * Flush the current brigade down the filter stack.
20cd21b6e63b2e3ac3df0626367ea36e84ff6a2fniq * @param f The filter we are passing to
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param bb The brigade to flush
2d87d8f191175a0683f430d790d81a5604b74ec6rbb */
39d25d098171c176443e752773a644c429e88394gsteinAP_DECLARE(apr_status_t) ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb);
2d87d8f191175a0683f430d790d81a5604b74ec6rbb
2d87d8f191175a0683f430d790d81a5604b74ec6rbb/**
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * Write a buffer for the current filter, buffering if possible.
20cd21b6e63b2e3ac3df0626367ea36e84ff6a2fniq * @param f the filter we are writing to
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param bb The brigade to buffer into
39d25d098171c176443e752773a644c429e88394gstein * @param data The data to write
39d25d098171c176443e752773a644c429e88394gstein * @param nbyte The number of bytes in the data
2d87d8f191175a0683f430d790d81a5604b74ec6rbb */
39d25d098171c176443e752773a644c429e88394gstein#define ap_fwrite(f, bb, data, nbyte) \
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz apr_brigade_write(bb, ap_filter_flush, f, data, nbyte)
2d87d8f191175a0683f430d790d81a5604b74ec6rbb
2d87d8f191175a0683f430d790d81a5604b74ec6rbb/**
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * Write a buffer for the current filter, buffering if possible.
20cd21b6e63b2e3ac3df0626367ea36e84ff6a2fniq * @param f the filter we are writing to
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param bb The brigade to buffer into
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param str The string to write
2d87d8f191175a0683f430d790d81a5604b74ec6rbb */
2d87d8f191175a0683f430d790d81a5604b74ec6rbb#define ap_fputs(f, bb, str) \
5008d6f7f93079b4e95ffd605979de930f8cd657jailletc apr_brigade_write(bb, ap_filter_flush, f, str, strlen(str))
2d87d8f191175a0683f430d790d81a5604b74ec6rbb
2d87d8f191175a0683f430d790d81a5604b74ec6rbb/**
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * Write a character for the current filter, buffering if possible.
20cd21b6e63b2e3ac3df0626367ea36e84ff6a2fniq * @param f the filter we are writing to
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param bb The brigade to buffer into
39d25d098171c176443e752773a644c429e88394gstein * @param c The character to write
2d87d8f191175a0683f430d790d81a5604b74ec6rbb */
39d25d098171c176443e752773a644c429e88394gstein#define ap_fputc(f, bb, c) \
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz apr_brigade_putc(bb, ap_filter_flush, f, c)
2d87d8f191175a0683f430d790d81a5604b74ec6rbb
2d87d8f191175a0683f430d790d81a5604b74ec6rbb/**
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * Write an unspecified number of strings to the current filter
20cd21b6e63b2e3ac3df0626367ea36e84ff6a2fniq * @param f the filter we are writing to
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param bb The brigade to buffer into
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param ... The strings to write
2d87d8f191175a0683f430d790d81a5604b74ec6rbb */
7928dad64ccfb725ff5a76c4dfd15ddc5d5d439fgsteinAP_DECLARE_NONSTD(apr_status_t) ap_fputstrs(ap_filter_t *f,
7928dad64ccfb725ff5a76c4dfd15ddc5d5d439fgstein apr_bucket_brigade *bb,
737e3a0da69952cf2eedef43b703d8c2b62ea09fjorton ...)
a054609255eb3b10ed30e5471b18ea0e7d5f735esf AP_FN_ATTR_SENTINEL;
2d87d8f191175a0683f430d790d81a5604b74ec6rbb
2d87d8f191175a0683f430d790d81a5604b74ec6rbb/**
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * Output data to the filter in printf format
20cd21b6e63b2e3ac3df0626367ea36e84ff6a2fniq * @param f the filter we are writing to
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param bb The brigade to buffer into
2d87d8f191175a0683f430d790d81a5604b74ec6rbb * @param fmt The format string
eed23c0ffbac879e3502737c44070dc1212daeb0jim * @param ... The arguments to use to fill out the format string
2d87d8f191175a0683f430d790d81a5604b74ec6rbb */
7928dad64ccfb725ff5a76c4dfd15ddc5d5d439fgsteinAP_DECLARE_NONSTD(apr_status_t) ap_fprintf(ap_filter_t *f,
7928dad64ccfb725ff5a76c4dfd15ddc5d5d439fgstein apr_bucket_brigade *bb,
7928dad64ccfb725ff5a76c4dfd15ddc5d5d439fgstein const char *fmt,
7928dad64ccfb725ff5a76c4dfd15ddc5d5d439fgstein ...)
742318b93e89c311f66b55f426c4d9cf2c14628bjim __attribute__((format(printf,3,4)));
2d87d8f191175a0683f430d790d81a5604b74ec6rbb
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq/**
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * set protocol requirements for an output content filter
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * (only works with AP_FTYPE_RESOURCE and AP_FTYPE_CONTENT_SET)
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * @param f the filter in question
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq * @param proto_flags Logical OR of AP_FILTER_PROTO_* bits
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq */
ae3dea49b7dbd3cdf991225881cf01e62689af2bniqAP_DECLARE(void) ap_filter_protocol(ap_filter_t* f, unsigned int proto_flags);
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq/** Filter changes contents (so invalidating checksums/etc) */
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq#define AP_FILTER_PROTO_CHANGE 0x1
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq/** Filter changes length of contents (so invalidating content-length/etc) */
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq#define AP_FILTER_PROTO_CHANGE_LENGTH 0x2
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq/** Filter requires complete input and can't work on byteranges */
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq#define AP_FILTER_PROTO_NO_BYTERANGE 0x4
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq/** Filter should not run in a proxy */
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq#define AP_FILTER_PROTO_NO_PROXY 0x8
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq/** Filter makes output non-cacheable */
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq#define AP_FILTER_PROTO_NO_CACHE 0x10
52778e46cc370ef8b054674c1176dd3a6d4f25d8nd
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq/** Filter is incompatible with "Cache-Control: no-transform" */
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq#define AP_FILTER_PROTO_TRANSFORM 0x20
ae3dea49b7dbd3cdf991225881cf01e62689af2bniq
8c2acc2f875e661fd34f233553d90c58894d5b1bpoirier/**
8c2acc2f875e661fd34f233553d90c58894d5b1bpoirier * @}
8c2acc2f875e661fd34f233553d90c58894d5b1bpoirier */
8c2acc2f875e661fd34f233553d90c58894d5b1bpoirier
777a2b42697cb8cb94ac4e73774862f879259c45rbb#ifdef __cplusplus
777a2b42697cb8cb94ac4e73774862f879259c45rbb}
777a2b42697cb8cb94ac4e73774862f879259c45rbb#endif
777a2b42697cb8cb94ac4e73774862f879259c45rbb
aa8acb43aef774a5669edf897ccb782a3f667cb8jerenkrantz#endif /* !AP_FILTER_H */