Apache2
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);
142 
143 typedef union ap_filter_func {
147 
158 typedef enum {
183  AP_FTYPE_NETWORK = 60
185 
190 typedef enum {
196 
210 typedef struct ap_filter_rec_t ap_filter_rec_t;
212 
228  const char *name;
229 
232 
242 
245 
248 
255 
257  int debug;
258 
260  unsigned int proto_flags;
261 
264 };
265 
269 struct ap_filter_private;
270 
278 struct ap_filter_t {
283 
285  void *ctx;
286 
289 
295 
300 
302  struct ap_filter_private *priv;
303 };
304 
308 struct ap_filter_conn_ctx;
309 
316 
323 
338  apr_bucket_brigade *bucket,
342 
356  apr_bucket_brigade *bucket);
357 
374  apr_bucket_brigade *bucket,
375  const char *fmt,
376  ...)
377  __attribute__((format(printf,3,4)));
378 
394  ap_in_filter_func filter_func,
395  ap_init_filter_func filter_init,
396  ap_filter_type ftype);
397 
400  ap_out_filter_func filter_func,
401  ap_init_filter_func filter_init,
402  ap_filter_type ftype);
403 
404 /* For httpd-?.? I suggest replacing the above with
405 #define ap_register_output_filter(name,ffunc,init,ftype) \
406  ap_register_output_filter_protocol(name,ffunc,init,ftype,0)
407 */
408 
426  const char *name,
427  ap_out_filter_func filter_func,
428  ap_init_filter_func filter_init,
429  ap_filter_type ftype,
430  unsigned int proto_flags);
431 
450 AP_DECLARE(ap_filter_t *) ap_add_input_filter(const char *name, void *ctx,
451  request_rec *r, conn_rec *c);
452 
463  void *ctx,
464  request_rec *r,
465  conn_rec *c);
466 
473 
487  request_rec *r, conn_rec *c);
488 
503  void *ctx,
504  request_rec *r,
505  conn_rec *c);
506 
513 
521 
529 
538  const char *handle);
547  const char *handle);
548 
549 /* The next two filters are for abstraction purposes only. They could be
550  * done away with, but that would require that we break modules if we ever
551  * want to change our filter registration method. The basic idea, is that
552  * all filters have a place to store data, the ctx pointer. These functions
553  * fill out that pointer with a bucket brigade, and retrieve that data on
554  * the next call. The nice thing about these functions, is that they
555  * automatically concatenate the bucket brigades together for you. This means
556  * that if you have already stored a brigade in the filters ctx pointer, then
557  * when you add more it will be tacked onto the end of that brigade. When
558  * you retrieve data, if you pass in a bucket brigade to the get function,
559  * it will append the current brigade onto the one that you are retrieving.
560  */
561 
576  apr_bucket_brigade **save_to,
578 
588 
598 
621  apr_bucket **flush_upto);
622 
633 
646 
658 
669 
679  void *ctx);
680 
687 
695 #define ap_fwrite(f, bb, data, nbyte) \
696  apr_brigade_write(bb, ap_filter_flush, f, data, nbyte)
697 
704 #define ap_fputs(f, bb, str) \
705  apr_brigade_write(bb, ap_filter_flush, f, str, strlen(str))
706 
713 #define ap_fputc(f, bb, c) \
714  apr_brigade_putc(bb, ap_filter_flush, f, c)
715 
724  ...)
726 
736  const char *fmt,
737  ...)
738  __attribute__((format(printf,3,4)));
739 
746 AP_DECLARE(void) ap_filter_protocol(ap_filter_t* f, unsigned int proto_flags);
747 
749 #define AP_FILTER_PROTO_CHANGE 0x1
750 
752 #define AP_FILTER_PROTO_CHANGE_LENGTH 0x2
753 
755 #define AP_FILTER_PROTO_NO_BYTERANGE 0x4
756 
758 #define AP_FILTER_PROTO_NO_PROXY 0x8
759 
761 #define AP_FILTER_PROTO_NO_CACHE 0x10
762 
764 #define AP_FILTER_PROTO_TRANSFORM 0x20
765 
782 AP_DECLARE_DATA extern const char ap_bucket_wc_data;
783 
789 #define AP_BUCKET_IS_WC(e) (APR_BUCKET_IS_FLUSH(e) && \
790  (e)->data == (void *)&ap_bucket_wc_data)
791 
798 
805 
810 #ifdef __cplusplus
811 }
812 #endif
813 
814 #endif /* !AP_FILTER_H */
#define AP_FN_ATTR_SENTINEL
Definition: ap_config.h:231
APR Platform Definitions.
APR-UTIL Buckets/Bucket Brigades.
int ap_filter_input_pending(conn_rec *c)
union ap_filter_func ap_filter_func
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)
apr_status_t ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb)
int ap_filter_should_yield(ap_filter_t *f)
void ap_release_brigade(conn_rec *c, apr_bucket_brigade *bb)
void ap_remove_input_filter(ap_filter_t *f)
ap_filter_t * ap_add_output_filter_handle(ap_filter_rec_t *f, void *ctx, request_rec *r, conn_rec *c)
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)
ap_filter_t * ap_add_output_filter(const char *name, void *ctx, request_rec *r, conn_rec *c)
AP_DECLARE_DATA const char ap_bucket_wc_data
Write Completion (WC) bucket.
ap_filter_direction_e
Definition: util_filter.h:190
apr_status_t(* ap_out_filter_func)(ap_filter_t *f, apr_bucket_brigade *b)
Definition: util_filter.h:134
ap_filter_t * ap_add_input_filter_handle(ap_filter_rec_t *f, void *ctx, request_rec *r, conn_rec *c)
ap_filter_type
Definition: util_filter.h:158
apr_bucket_brigade * ap_acquire_brigade(conn_rec *c)
apr_status_t ap_filter_setaside_brigade(ap_filter_t *f, apr_bucket_brigade *bb)
apr_bucket * ap_bucket_wc_create(apr_bucket_alloc_t *list)
apr_bucket * ap_bucket_wc_make(apr_bucket *b)
apr_status_t ap_pass_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket)
int ap_filter_output_pending(conn_rec *c)
int(* ap_init_filter_func)(ap_filter_t *f)
Definition: util_filter.h:141
apr_status_t ap_remove_input_filter_byhandle(ap_filter_t *next, const char *handle)
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
int ap_filter_prepare_brigade(ap_filter_t *f)
apr_status_t ap_remove_output_filter_byhandle(ap_filter_t *next, const char *handle)
struct ap_filter_provider_t ap_filter_provider_t
Definition: util_filter.h:211
apr_status_t ap_save_brigade(ap_filter_t *f, apr_bucket_brigade **save_to, apr_bucket_brigade **b, apr_pool_t *p)
apr_status_t ap_fputstrs(ap_filter_t *f, apr_bucket_brigade *bb,...) AP_FN_ATTR_SENTINEL
apr_status_t ap_filter_flush(apr_bucket_brigade *bb, void *ctx)
apr_status_t ap_filter_reinstate_brigade(ap_filter_t *f, apr_bucket_brigade *bb, apr_bucket **flush_upto)
apr_status_t ap_pass_brigade_fchk(request_rec *r, apr_bucket_brigade *bucket, const char *fmt,...) __attribute__((format(printf
apr_status_t ap_fprintf(ap_filter_t *f, apr_bucket_brigade *bb, const char *fmt,...) __attribute__((format(printf
ap_filter_t * ap_add_input_filter(const char *name, void *ctx, request_rec *r, conn_rec *c)
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)
apr_status_t void ap_filter_protocol(ap_filter_t *f, unsigned int proto_flags)
void ap_remove_output_filter(ap_filter_t *f)
ap_filter_rec_t * ap_get_output_filter_handle(const char *name)
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)
void ap_filter_adopt_brigade(ap_filter_t *f, apr_bucket_brigade *bb)
@ AP_FILTER_INPUT
Definition: util_filter.h:192
@ AP_FILTER_OUTPUT
Definition: util_filter.h:194
@ AP_FTYPE_TRANSCODE
Definition: util_filter.h:170
@ AP_FTYPE_CONTENT_SET
Definition: util_filter.h:165
@ AP_FTYPE_NETWORK
Definition: util_filter.h:183
@ AP_FTYPE_CONNECTION
Definition: util_filter.h:180
@ AP_FTYPE_PROTOCOL
Definition: util_filter.h:168
@ AP_FTYPE_RESOURCE
Definition: util_filter.h:161
apr_read_type_e
Definition: apr_buckets.h:62
struct apr_bucket_alloc_t apr_bucket_alloc_t
Definition: apr_buckets.h:128
apr_bucket_brigade ap_input_mode_t apr_read_type_e apr_off_t readbytes
Definition: mod_dav.h:2664
request_rec * r
Definition: mod_dav.h:518
apr_bucket_brigade * bb
Definition: mod_dav.h:555
apr_bucket_brigade ap_input_mode_t mode
Definition: mod_dav.h:2662
const char * name
Definition: mod_dav.h:805
apr_bucket_brigade ap_input_mode_t apr_read_type_e block
Definition: mod_dav.h:2663
int
Definition: mod_proxy.h:674
int apr_status_t
Definition: apr_errno.h:44
off_t apr_off_t
Definition: apr.h:396
#define __attribute__(__x)
Definition: apr.h:63
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
HTTP Daemon routines.
#define AP_DECLARE_DATA
Definition: macros.h:15
#define AP_DECLARE(x)
Definition: macros.h:1
#define AP_DECLARE_NONSTD(x)
Definition: macros.h:2
This structure is used for recording information about the registered filters. It associates a name w...
Definition: util_filter.h:226
ap_filter_type ftype
Definition: util_filter.h:254
ap_filter_provider_t * providers
Definition: util_filter.h:247
ap_init_filter_func filter_init_func
Definition: util_filter.h:241
ap_filter_func filter_func
Definition: util_filter.h:231
unsigned int proto_flags
Definition: util_filter.h:260
struct ap_filter_rec_t * next
Definition: util_filter.h:244
const char * name
Definition: util_filter.h:228
int debug
Definition: util_filter.h:257
ap_filter_direction_e direction
Definition: util_filter.h:263
The representation of a filter chain.
Definition: util_filter.h:278
request_rec * r
Definition: util_filter.h:294
struct ap_filter_private * priv
Definition: util_filter.h:302
ap_filter_rec_t * frec
Definition: util_filter.h:282
void * ctx
Definition: util_filter.h:285
ap_filter_t * next
Definition: util_filter.h:288
conn_rec * c
Definition: util_filter.h:299
Definition: apr_buckets.h:263
Definition: apr_buckets.h:229
Structure to store things which are per connection.
Definition: httpd.h:1193
A structure that represents the current request.
Definition: httpd.h:856
apr_pool_t * p
Definition: util_filter.h:143
ap_out_filter_func out_func
Definition: util_filter.h:144
ap_in_filter_func in_func
Definition: util_filter.h:145
ap_input_mode_t
input filtering modes
Definition: util_filter.h:41
@ AP_MODE_SPECULATIVE
Definition: util_filter.h:53
@ AP_MODE_READBYTES
Definition: util_filter.h:43
@ AP_MODE_INIT
Definition: util_filter.h:62
@ AP_MODE_EXHAUSTIVE
Definition: util_filter.h:58
@ AP_MODE_GETLINE
Definition: util_filter.h:48
@ AP_MODE_EATCRLF
Definition: util_filter.h:50