Apache HTTPD
mod_case_filter.c
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
17#include "httpd.h"
18#include "http_config.h"
19#include "apr_buckets.h"
20#include "apr_general.h"
21#include "apr_lib.h"
22#include "util_filter.h"
23#include "http_request.h"
24
25#include <ctype.h>
26
27static const char s_szCaseFilterName[] = "CaseFilter";
28module AP_MODULE_DECLARE_DATA case_filter_module;
29
30typedef struct
31{
34
36{
38
39 pConfig->bEnabled = 0;
40
41 return pConfig;
42}
43
45{
47 &case_filter_module);
48
49 if (!pConfig->bEnabled)
50 return;
51
53}
54
57{
58 request_rec *r = f->r;
62
63 pbbOut = apr_brigade_create(r->pool, c->bucket_alloc);
67 {
68 const char *data;
70 char *buf;
73
75 apr_bucket *pbktEOS = apr_bucket_eos_create(c->bucket_alloc);
77 continue;
78 }
79
80 /* read */
82
83 /* write */
84 buf = apr_bucket_alloc(len, c->bucket_alloc);
85 for (n=0 ; n < len ; ++n) {
86 buf[n] = apr_toupper(data[n]);
87 }
88
90 c->bucket_alloc);
92 }
93
94 /* Q: is there any advantage to passing a brigade for each bucket?
95 * A: obviously, it can cut down server resource consumption, if this
96 * experimental module was fed a file of 4MB, it would be using 8MB for
97 * the 'read' buckets and the 'write' buckets.
98 *
99 * Note it is more efficient to consume (destroy) each bucket as it's
100 * processed above than to do a single cleanup down here. In any case,
101 * don't let our caller pass the same buckets to us, twice;
102 */
104 return ap_pass_brigade(f->next, pbbOut);
105}
106
107static const char *CaseFilterEnable(cmd_parms *cmd, void *dummy, int arg)
108{
109 CaseFilterConfig *pConfig = ap_get_module_config(cmd->server->module_config,
110 &case_filter_module);
111 pConfig->bEnabled = arg;
112
113 return NULL;
114}
115
117{
119 "Run a case filter on this host"),
120 { NULL }
121};
122
129
131{
133 NULL,
134 NULL,
136 NULL,
139};
int n
Definition ap_regex.h:278
const char apr_size_t len
Definition ap_regex.h:187
APR-UTIL Buckets/Bucket Brigades.
APR Miscellaneous library routines.
APR general purpose library routines.
#define ap_get_module_config(v, m)
#define AP_DECLARE_MODULE(foo)
#define AP_INIT_FLAG(directive, func, mconfig, where, help)
request_rec * r
apr_status_t ap_pass_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket)
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_t * ap_add_output_filter(const char *name, void *ctx, request_rec *r, conn_rec *c)
@ AP_FTYPE_RESOURCE
const unsigned char * buf
Definition util_md5.h:50
void ap_hook_insert_filter(ap_HOOK_insert_filter_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
Definition request.c:96
void * dummy
Definition http_vhost.h:62
void const char * arg
Definition http_vhost.h:63
apr_file_t * f
#define APR_BRIGADE_INSERT_TAIL(b, e)
#define APR_BUCKET_NEXT(e)
#define APR_BRIGADE_SENTINEL(b)
#define APR_BUCKET_IS_EOS(e)
#define APR_BRIGADE_FIRST(b)
#define apr_bucket_read(e, str, len, block)
@ APR_BLOCK_READ
Definition apr_buckets.h:58
#define APR_HOOK_MIDDLE
Definition apr_hooks.h:303
#define RSRC_CONF
#define STANDARD20_MODULE_STUFF
apr_size_t size
#define apr_toupper(c)
Definition apr_lib.h:233
int apr_status_t
Definition apr_errno.h:44
void * data
apr_vformatter_buff_t * c
Definition apr_lib.h:175
#define apr_pcalloc(p, size)
Definition apr_pools.h:465
const char * s
Definition apr_strings.h:95
apr_cmdtype_e cmd
Apache Configuration.
Apache Request library.
HTTP Daemon routines.
apr_pool_t * p
Definition md_event.c:32
static const char * CaseFilterEnable(cmd_parms *cmd, void *dummy, int arg)
static void CaseFilterInsertFilter(request_rec *r)
static const char s_szCaseFilterName[]
static apr_status_t CaseFilterOutFilter(ap_filter_t *f, apr_bucket_brigade *pbbIn)
static void CaseFilterRegisterHooks(apr_pool_t *p)
static void * CaseFilterCreateServerConfig(apr_pool_t *p, server_rec *s)
static const command_rec CaseFilterCmds[]
return NULL
Definition mod_so.c:359
The representation of a filter chain.
Structure to store things which are per connection.
Definition httpd.h:1152
A structure that represents the current request.
Definition httpd.h:845
apr_pool_t * pool
Definition httpd.h:847
conn_rec * connection
Definition httpd.h:849
server_rec * server
Definition httpd.h:851
A structure to store information for each virtual server.
Definition httpd.h:1322
struct ap_conf_vector_t * module_config
Definition httpd.h:1341
Apache filter library.