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 
302 };
303 
318  apr_bucket_brigade *bucket,
319  ap_input_mode_t mode,
320  apr_read_type_e block,
321  apr_off_t readbytes);
322 
336  apr_bucket_brigade *bucket);
337 
354  apr_bucket_brigade *bucket,
355  const char *fmt,
356  ...)
357  __attribute__((format(printf,3,4)));
358 
374  ap_in_filter_func filter_func,
375  ap_init_filter_func filter_init,
376  ap_filter_type ftype);
377 
380  ap_out_filter_func filter_func,
381  ap_init_filter_func filter_init,
382  ap_filter_type ftype);
383 
384 /* For httpd-?.? I suggest replacing the above with
385 #define ap_register_output_filter(name,ffunc,init,ftype) \
386  ap_register_output_filter_protocol(name,ffunc,init,ftype,0)
387 */
388 
406  const char *name,
407  ap_out_filter_func filter_func,
408  ap_init_filter_func filter_init,
409  ap_filter_type ftype,
410  unsigned int proto_flags);
411 
430 AP_DECLARE(ap_filter_t *) ap_add_input_filter(const char *name, void *ctx,
431  request_rec *r, conn_rec *c);
432 
443  void *ctx,
444  request_rec *r,
445  conn_rec *c);
446 
453 
466 AP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx,
467  request_rec *r, conn_rec *c);
468 
483  void *ctx,
484  request_rec *r,
485  conn_rec *c);
486 
493 
501 
509 
518  const char *handle);
527  const char *handle);
528 
529 /* The next two filters are for abstraction purposes only. They could be
530  * done away with, but that would require that we break modules if we ever
531  * want to change our filter registration method. The basic idea, is that
532  * all filters have a place to store data, the ctx pointer. These functions
533  * fill out that pointer with a bucket brigade, and retrieve that data on
534  * the next call. The nice thing about these functions, is that they
535  * automatically concatenate the bucket brigades together for you. This means
536  * that if you have already stored a brigade in the filters ctx pointer, then
537  * when you add more it will be tacked onto the end of that brigade. When
538  * you retrieve data, if you pass in a bucket brigade to the get function,
539  * it will append the current brigade onto the one that you are retrieving.
540  */
541 
556  apr_bucket_brigade **save_to,
558 
571 
581 
603  apr_bucket_brigade *bb,
604  apr_bucket **flush_upto);
605 
618 
630 
641 
651  void *ctx);
652 
659 
667 #define ap_fwrite(f, bb, data, nbyte) \
668  apr_brigade_write(bb, ap_filter_flush, f, data, nbyte)
669 
676 #define ap_fputs(f, bb, str) \
677  apr_brigade_write(bb, ap_filter_flush, f, str, strlen(str))
678 
685 #define ap_fputc(f, bb, c) \
686  apr_brigade_putc(bb, ap_filter_flush, f, c)
687 
695  apr_bucket_brigade *bb,
696  ...)
698 
707  apr_bucket_brigade *bb,
708  const char *fmt,
709  ...)
710  __attribute__((format(printf,3,4)));
711 
718 AP_DECLARE(void) ap_filter_protocol(ap_filter_t* f, unsigned int proto_flags);
719 
721 #define AP_FILTER_PROTO_CHANGE 0x1
722 
724 #define AP_FILTER_PROTO_CHANGE_LENGTH 0x2
725 
727 #define AP_FILTER_PROTO_NO_BYTERANGE 0x4
728 
730 #define AP_FILTER_PROTO_NO_PROXY 0x8
731 
733 #define AP_FILTER_PROTO_NO_CACHE 0x10
734 
736 #define AP_FILTER_PROTO_TRANSFORM 0x20
737 
742 #ifdef __cplusplus
743 }
744 #endif
745 
746 #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:1110
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
apr_bucket_brigade * bb
Definition: mod_dav.h:556
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:617
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:805
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:730
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
request_rec * r
Definition: mod_dav.h:519
apr_status_t ap_filter_setaside_brigade(ap_filter_t *f, apr_bucket_brigade *bb)
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
off_t apr_off_t
Definition: apr.h:377
unsigned int proto_flags
Definition: util_filter.h:260
Definition: util_filter.h:50