Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
util_filter.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef AP_FILTER_H
23 #define AP_FILTER_H
24 
25 #include "apr.h"
26 #include "apr_buckets.h"
27 
28 #include "httpd.h"
29 
30 #if APR_HAVE_STDARG_H
31 #include <stdarg.h>
32 #endif
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
41 typedef enum {
64 
93 /* forward declare the filter type */
94 typedef struct ap_filter_t ap_filter_t;
95 
135  apr_bucket_brigade *b);
138  ap_input_mode_t mode,
139  apr_read_type_e block,
140  apr_off_t readbytes);
142 
143 typedef union ap_filter_func {
147 
158 typedef enum {
185 
190 typedef enum {
196 
212 
228  const char *name;
229 
232 
242 
245 
248 
255 
257  int debug;
258 
260  unsigned int proto_flags;
261 
264 };
265 
273 struct ap_filter_t {
278 
280  void *ctx;
281 
284 
290 
295 
298 
301 
303  APR_RING_ENTRY(ap_filter_t) pending;
304 };
305 
309 typedef APR_RING_HEAD(ap_filter_ring, ap_filter_t) ap_filter_ring_t;
310 
325  apr_bucket_brigade *bucket,
326  ap_input_mode_t mode,
327  apr_read_type_e block,
328  apr_off_t readbytes);
329 
343  apr_bucket_brigade *bucket);
344 
361  apr_bucket_brigade *bucket,
362  const char *fmt,
363  ...)
364  __attribute__((format(printf,3,4)));
365 
381  ap_in_filter_func filter_func,
382  ap_init_filter_func filter_init,
383  ap_filter_type ftype);
384 
387  ap_out_filter_func filter_func,
388  ap_init_filter_func filter_init,
389  ap_filter_type ftype);
390 
391 /* For httpd-?.? I suggest replacing the above with
392 #define ap_register_output_filter(name,ffunc,init,ftype) \
393  ap_register_output_filter_protocol(name,ffunc,init,ftype,0)
394 */
395 
413  const char *name,
414  ap_out_filter_func filter_func,
415  ap_init_filter_func filter_init,
416  ap_filter_type ftype,
417  unsigned int proto_flags);
418 
437 AP_DECLARE(ap_filter_t *) ap_add_input_filter(const char *name, void *ctx,
438  request_rec *r, conn_rec *c);
439 
450  void *ctx,
451  request_rec *r,
452  conn_rec *c);
453 
460 
473 AP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx,
474  request_rec *r, conn_rec *c);
475 
490  void *ctx,
491  request_rec *r,
492  conn_rec *c);
493 
500 
508 
516 
525  const char *handle);
534  const char *handle);
535 
536 /* The next two filters are for abstraction purposes only. They could be
537  * done away with, but that would require that we break modules if we ever
538  * want to change our filter registration method. The basic idea, is that
539  * all filters have a place to store data, the ctx pointer. These functions
540  * fill out that pointer with a bucket brigade, and retrieve that data on
541  * the next call. The nice thing about these functions, is that they
542  * automatically concatenate the bucket brigades together for you. This means
543  * that if you have already stored a brigade in the filters ctx pointer, then
544  * when you add more it will be tacked onto the end of that brigade. When
545  * you retrieve data, if you pass in a bucket brigade to the get function,
546  * it will append the current brigade onto the one that you are retrieving.
547  */
548 
563  apr_bucket_brigade **save_to,
565 
578 
588 
610  apr_bucket_brigade *bb,
611  apr_bucket **flush_upto);
612 
625 
637 
648 
658  void *ctx);
659 
666 
674 #define ap_fwrite(f, bb, data, nbyte) \
675  apr_brigade_write(bb, ap_filter_flush, f, data, nbyte)
676 
683 #define ap_fputs(f, bb, str) \
684  apr_brigade_write(bb, ap_filter_flush, f, str, strlen(str))
685 
692 #define ap_fputc(f, bb, c) \
693  apr_brigade_putc(bb, ap_filter_flush, f, c)
694 
702  apr_bucket_brigade *bb,
703  ...)
705 
714  apr_bucket_brigade *bb,
715  const char *fmt,
716  ...)
717  __attribute__((format(printf,3,4)));
718 
725 AP_DECLARE(void) ap_filter_protocol(ap_filter_t* f, unsigned int proto_flags);
726 
728 #define AP_FILTER_PROTO_CHANGE 0x1
729 
731 #define AP_FILTER_PROTO_CHANGE_LENGTH 0x2
732 
734 #define AP_FILTER_PROTO_NO_BYTERANGE 0x4
735 
737 #define AP_FILTER_PROTO_NO_PROXY 0x8
738 
740 #define AP_FILTER_PROTO_NO_CACHE 0x10
741 
743 #define AP_FILTER_PROTO_TRANSFORM 0x20
744 
749 #ifdef __cplusplus
750 }
751 #endif
752 
753 #endif /* !AP_FILTER_H */
This structure is used for recording information about the registered filters. It associates a name w...
Definition: util_filter.h:226
ap_filter_t * ap_add_input_filter_handle(ap_filter_rec_t *f, void *ctx, request_rec *r, conn_rec *c)
const char * name
Definition: util_filter.h:228
ap_filter_t * ap_add_output_filter_handle(ap_filter_rec_t *f, void *ctx, request_rec *r, conn_rec *c)
Definition: util_filter.h:165
apr_status_t ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb)
ap_input_mode_t
input filtering modes
Definition: util_filter.h:41
Definition: util_filter.h:48
request_rec * r
Definition: util_filter.h:289
int ap_filter_output_pending(conn_rec *c)
void ap_remove_input_filter(ap_filter_t *f)
conn_rec * c
Definition: util_filter.h:294
Definition: util_filter.h:192
apr_status_t __attribute__((nonnull(1)))
The representation of a filter chain.
Definition: util_filter.h:273
int debug
Definition: util_filter.h:257
#define AP_FN_ATTR_SENTINEL
Definition: ap_config.h:231
ap_init_filter_func filter_init_func
Definition: util_filter.h:241
Definition: util_filter.h:143
#define AP_DECLARE(x)
Definition: macros.h:1
struct ap_filter_rec_t * next
Definition: util_filter.h:244
apr_status_t ap_remove_output_filter_byhandle(ap_filter_t *next, const char *handle)
ap_in_filter_func in_func
Definition: util_filter.h:145
apr_status_t ap_pass_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket)
ap_filter_t * ap_add_input_filter(const char *name, void *ctx, request_rec *r, conn_rec *c)
apr_bucket_brigade * bb
Definition: util_filter.h:297
ap_filter_provider_t * providers
Definition: util_filter.h:247
Definition: util_filter.h:170
#define AP_DECLARE_NONSTD(x)
Definition: macros.h:2
apr_status_t ap_filter_rec_t * ap_register_input_filter(const char *name, ap_in_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype)
ap_filter_rec_t * ap_get_output_filter_handle(const char *name)
ap_filter_type
Definition: util_filter.h:158
ap_filter_t * ap_add_output_filter(const char *name, void *ctx, request_rec *r, conn_rec *c)
ap_filter_direction_e direction
Definition: util_filter.h:263
void * ctx
Definition: util_filter.h:280
Definition: apr_buckets.h:258
Definition: util_filter.h:53
Structure to store things which are per connection.
Definition: httpd.h:1116
apr_status_t ap_fputstrs(ap_filter_t *f, apr_bucket_brigade *bb,...) AP_FN_ATTR_SENTINEL
apr_status_t void ap_filter_protocol(ap_filter_t *f, unsigned int proto_flags)
apr_status_t ap_save_brigade(ap_filter_t *f, apr_bucket_brigade **save_to, apr_bucket_brigade **b, apr_pool_t *p)
int ap_filter_prepare_brigade(ap_filter_t *f, apr_pool_t **p)
int ap_filter_should_yield(ap_filter_t *f)
apr_pool_t * deferred_pool
Definition: util_filter.h:300
apr_status_t(* ap_in_filter_func)(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
Definition: util_filter.h:136
Definition: util_filter.h:43
void ap_remove_output_filter(ap_filter_t *f)
Definition: util_filter.h:180
ap_filter_rec_t * frec
Definition: util_filter.h:277
ap_out_filter_func out_func
Definition: util_filter.h:144
HTTP Daemon routines.
apr_status_t ap_get_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
int
Definition: mod_proxy.h:626
Definition: apr_buckets.h:224
apr_status_t ap_filter_flush(apr_bucket_brigade *bb, void *ctx)
apr_status_t ap_fprintf(ap_filter_t *f, apr_bucket_brigade *bb, const char *fmt,...) __attribute__((format(printf
int ap_filter_input_pending(conn_rec *c)
APR-UTIL Buckets/Bucket Brigades.
ap_filter_type ftype
Definition: util_filter.h:254
APR Platform Definitions.
Definition: util_filter.h:62
int(* ap_init_filter_func)(ap_filter_t *f)
Definition: util_filter.h:141
ap_filter_rec_t * ap_register_output_filter(const char *name, ap_out_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype)
ap_filter_rec_t * ap_get_input_filter_handle(const char *name)
apr_pool_t * p
ap_filter_direction_e
Definition: util_filter.h:190
apr_read_type_e
Definition: apr_buckets.h:57
Definition: util_filter.h:183
Definition: util_filter.h:194
A structure that represents the current request.
Definition: httpd.h:806
ap_filter_rec_t * ap_register_output_filter_protocol(const char *name, ap_out_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype, unsigned int proto_flags)
Definition: util_filter.h:58
Definition: util_filter.h:161
apr_status_t ap_filter_reinstate_brigade(ap_filter_t *f, apr_bucket_brigade *bb, apr_bucket **flush_upto)
const char * name
Definition: mod_dav.h:726
struct ap_filter_provider_t ap_filter_provider_t
Definition: util_filter.h:211
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_status_t ap_remove_input_filter_byhandle(ap_filter_t *next, const char *handle)
ap_filter_func filter_func
Definition: util_filter.h:231
ap_filter_t * next
Definition: util_filter.h:283
int apr_status_t
Definition: apr_errno.h:44
apr_status_t ap_filter_setaside_brigade(ap_filter_t *f, apr_bucket_brigade *bb)
typedef APR_RING_HEAD(ap_filter_ring, ap_filter_t) ap_filter_ring_t
The representation of a filters' ring.
union ap_filter_func ap_filter_func
apr_status_t(* ap_out_filter_func)(ap_filter_t *f, apr_bucket_brigade *b)
Definition: util_filter.h:134
apr_status_t ap_pass_brigade_fchk(request_rec *r, apr_bucket_brigade *bucket, const char *fmt,...) __attribute__((format(printf
Definition: util_filter.h:168
APR_RING_ENTRY(ap_filter_t) pending
off_t apr_off_t
Definition: apr.h:377
unsigned int proto_flags
Definition: util_filter.h:260
Definition: util_filter.h:50