00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00022 #ifndef AP_FILTER_H
00023 #define AP_FILTER_H
00024
00025 #include "apr.h"
00026 #include "apr_buckets.h"
00027
00028 #include "httpd.h"
00029
00030 #if APR_HAVE_STDARG_H
00031 #include <stdarg.h>
00032 #endif
00033
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037
00040 #define AP_NOBODY_WROTE -1
00041
00043 #define AP_NOBODY_READ -2
00044
00045 #define AP_FILTER_ERROR -3
00046
00050 typedef enum {
00052 AP_MODE_READBYTES,
00057 AP_MODE_GETLINE,
00059 AP_MODE_EATCRLF,
00062 AP_MODE_SPECULATIVE,
00067 AP_MODE_EXHAUSTIVE,
00071 AP_MODE_INIT
00072 } ap_input_mode_t;
00073
00100
00101 typedef struct ap_filter_t ap_filter_t;
00102
00136 typedef apr_status_t (*ap_out_filter_func)(ap_filter_t *f,
00137 apr_bucket_brigade *b);
00138 typedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f,
00139 apr_bucket_brigade *b,
00140 ap_input_mode_t mode,
00141 apr_read_type_e block,
00142 apr_off_t readbytes);
00143 typedef int (*ap_init_filter_func)(ap_filter_t *f);
00144
00145 typedef union ap_filter_func {
00146 ap_out_filter_func out_func;
00147 ap_in_filter_func in_func;
00148 } ap_filter_func;
00149
00160 typedef enum {
00163 AP_FTYPE_RESOURCE = 10,
00167 AP_FTYPE_CONTENT_SET = 20,
00170 AP_FTYPE_PROTOCOL = 30,
00172 AP_FTYPE_TRANSCODE = 40,
00182 AP_FTYPE_CONNECTION = 50,
00185 AP_FTYPE_NETWORK = 60
00186 } ap_filter_type;
00187
00201 typedef struct ap_filter_rec_t ap_filter_rec_t;
00202 typedef struct ap_filter_provider_t ap_filter_provider_t;
00203
00217 struct ap_filter_rec_t {
00219 const char *name;
00220
00222 ap_filter_func filter_func;
00223
00229 ap_init_filter_func filter_init_func;
00230
00236 ap_filter_type ftype;
00237
00239 struct ap_filter_rec_t *next;
00240
00242 ap_filter_provider_t *providers;
00243
00245 int debug;
00246
00248 unsigned int proto_flags;
00249 };
00250
00258 struct ap_filter_t {
00262 ap_filter_rec_t *frec;
00263
00265 void *ctx;
00266
00268 ap_filter_t *next;
00269
00274 request_rec *r;
00275
00279 conn_rec *c;
00280 };
00281
00295 AP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *filter,
00296 apr_bucket_brigade *bucket,
00297 ap_input_mode_t mode,
00298 apr_read_type_e block,
00299 apr_off_t readbytes);
00300
00309 AP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *filter,
00310 apr_bucket_brigade *bucket);
00311
00326 AP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name,
00327 ap_in_filter_func filter_func,
00328 ap_init_filter_func filter_init,
00329 ap_filter_type ftype);
00330
00347 AP_DECLARE(ap_filter_rec_t *) ap_register_output_filter(const char *name,
00348 ap_out_filter_func filter_func,
00349 ap_init_filter_func filter_init,
00350 ap_filter_type ftype);
00351
00352
00353
00354
00355
00356
00372 AP_DECLARE(ap_filter_rec_t *) ap_register_output_filter_protocol(
00373 const char *name,
00374 ap_out_filter_func filter_func,
00375 ap_init_filter_func filter_init,
00376 ap_filter_type ftype,
00377 unsigned int proto_flags);
00378
00397 AP_DECLARE(ap_filter_t *) ap_add_input_filter(const char *name, void *ctx,
00398 request_rec *r, conn_rec *c);
00399
00409 AP_DECLARE(ap_filter_t *) ap_add_input_filter_handle(ap_filter_rec_t *f,
00410 void *ctx,
00411 request_rec *r,
00412 conn_rec *c);
00413
00419 AP_DECLARE(ap_filter_rec_t *) ap_get_input_filter_handle(const char *name);
00420
00429 AP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx,
00430 request_rec *r, conn_rec *c);
00431
00440 AP_DECLARE(ap_filter_t *) ap_add_output_filter_handle(ap_filter_rec_t *f,
00441 void *ctx,
00442 request_rec *r,
00443 conn_rec *c);
00444
00450 AP_DECLARE(ap_filter_rec_t *) ap_get_output_filter_handle(const char *name);
00451
00458 AP_DECLARE(void) ap_remove_input_filter(ap_filter_t *f);
00459
00466 AP_DECLARE(void) ap_remove_output_filter(ap_filter_t *f);
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00491 AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f,
00492 apr_bucket_brigade **save_to,
00493 apr_bucket_brigade **b, apr_pool_t *p);
00494
00503 AP_DECLARE_NONSTD(apr_status_t) ap_filter_flush(apr_bucket_brigade *bb,
00504 void *ctx);
00505
00511 AP_DECLARE(apr_status_t) ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb);
00512
00520 #define ap_fwrite(f, bb, data, nbyte) \
00521 apr_brigade_write(bb, ap_filter_flush, f, data, nbyte)
00522
00529 #define ap_fputs(f, bb, str) \
00530 apr_brigade_puts(bb, ap_filter_flush, f, str)
00531
00538 #define ap_fputc(f, bb, c) \
00539 apr_brigade_putc(bb, ap_filter_flush, f, c)
00540
00547 AP_DECLARE_NONSTD(apr_status_t) ap_fputstrs(ap_filter_t *f,
00548 apr_bucket_brigade *bb,
00549 ...);
00550
00558 AP_DECLARE_NONSTD(apr_status_t) ap_fprintf(ap_filter_t *f,
00559 apr_bucket_brigade *bb,
00560 const char *fmt,
00561 ...)
00562 __attribute__((format(printf,3,4)));
00563
00570 AP_DECLARE(void) ap_filter_protocol(ap_filter_t* f, unsigned int proto_flags);
00571
00573 #define AP_FILTER_PROTO_CHANGE 0x1
00574
00576 #define AP_FILTER_PROTO_CHANGE_LENGTH 0x2
00577
00579 #define AP_FILTER_PROTO_NO_BYTERANGE 0x4
00580
00582 #define AP_FILTER_PROTO_NO_PROXY 0x8
00583
00585 #define AP_FILTER_PROTO_NO_CACHE 0x10
00586
00588 #define AP_FILTER_PROTO_TRANSFORM 0x20
00589
00590 #ifdef __cplusplus
00591 }
00592 #endif
00593
00594 #endif