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 
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,
339  ap_input_mode_t mode,
340  apr_read_type_e block,
341  apr_off_t readbytes);
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 
486 AP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx,
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 
597  apr_bucket_brigade *bb);
598 
620  apr_bucket_brigade *bb,
621  apr_bucket **flush_upto);
622 
635 
647 
658 
668  void *ctx);
669 
676 
684 #define ap_fwrite(f, bb, data, nbyte) \
685  apr_brigade_write(bb, ap_filter_flush, f, data, nbyte)
686 
693 #define ap_fputs(f, bb, str) \
694  apr_brigade_write(bb, ap_filter_flush, f, str, strlen(str))
695 
702 #define ap_fputc(f, bb, c) \
703  apr_brigade_putc(bb, ap_filter_flush, f, c)
704 
712  apr_bucket_brigade *bb,
713  ...)
715 
724  apr_bucket_brigade *bb,
725  const char *fmt,
726  ...)
727  __attribute__((format(printf,3,4)));
728 
735 AP_DECLARE(void) ap_filter_protocol(ap_filter_t* f, unsigned int proto_flags);
736 
738 #define AP_FILTER_PROTO_CHANGE 0x1
739 
741 #define AP_FILTER_PROTO_CHANGE_LENGTH 0x2
742 
744 #define AP_FILTER_PROTO_NO_BYTERANGE 0x4
745 
747 #define AP_FILTER_PROTO_NO_PROXY 0x8
748 
750 #define AP_FILTER_PROTO_NO_CACHE 0x10
751 
753 #define AP_FILTER_PROTO_TRANSFORM 0x20
754 
759 #ifdef __cplusplus
760 }
761 #endif
762 
763 #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:294
apr_bucket_brigade * ap_acquire_brigade(conn_rec *c)
int ap_filter_output_pending(conn_rec *c)
void ap_remove_input_filter(ap_filter_t *f)
conn_rec * c
Definition: util_filter.h:299
Definition: util_filter.h:192
The representation of a filter chain.
Definition: util_filter.h:278
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)
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:285
Definition: apr_buckets.h:258
Definition: util_filter.h:53
Structure to store things which are per connection.
Definition: httpd.h:1124
void ap_release_brigade(conn_rec *c, apr_bucket_brigade *bb)
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_should_yield(ap_filter_t *f)
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:282
apr_bucket_brigade * bb
Definition: mod_dav.h:552
ap_out_filter_func out_func
Definition: util_filter.h:144
HTTP Daemon routines.
struct ap_filter_private * priv
Definition: util_filter.h:302
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:811
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)
#define __attribute__(__x)
Definition: apr.h:63
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:288
int apr_status_t
Definition: apr_errno.h:44
request_rec * r
Definition: mod_dav.h:515
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
int ap_filter_prepare_brigade(ap_filter_t *f)
off_t apr_off_t
Definition: apr.h:377
unsigned int proto_flags
Definition: util_filter.h:260
Definition: util_filter.h:50