-
Notifications
You must be signed in to change notification settings - Fork 9
/
mod_small_light_dummy.c
94 lines (82 loc) · 2.39 KB
/
mod_small_light_dummy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
** mod_small_light_dummy.c -- dummy support
*/
#include "mod_small_light.h"
/*
** defines.
*/
typedef struct {
unsigned char *image;
apr_size_t image_len;
} small_light_module_dummy_ctx_t;
/*
** prototypes.
*/
apr_status_t small_light_filter_dummy_init(
ap_filter_t *f,
apr_bucket_brigade *bb,
void *v_ctx
);
apr_status_t small_light_filter_dummy_receive_data(
ap_filter_t *f,
apr_bucket_brigade *bb,
void *v_ctx,
apr_bucket *e,
const char *data,
apr_size_t len
);
apr_status_t small_light_filter_dummy_output_data(
ap_filter_t *f,
apr_bucket_brigade *bb,
void *v_ctx,
apr_bucket *e
);
/*
** functions.
*/
apr_status_t small_light_filter_dummy_init(
ap_filter_t *f,
apr_bucket_brigade *bb,
void *v_ctx)
{
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "small_light_filter_dummy_init");
request_rec *r = f->r;
small_light_module_ctx_t* ctx = (small_light_module_ctx_t*)v_ctx;
small_light_module_dummy_ctx_t *lctx = ctx->lctx;
// create local context.
if (ctx->lctx == NULL) {
ctx->lctx = lctx =
(small_light_module_dummy_ctx_t *)apr_pcalloc(
r->pool, sizeof(small_light_module_dummy_ctx_t));
}
return APR_SUCCESS;
}
apr_status_t small_light_filter_dummy_receive_data(
ap_filter_t *f,
apr_bucket_brigade *bb,
void *v_ctx,
apr_bucket *e,
const char *data,
apr_size_t len)
{
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "small_light_filter_dummy_receive_data %zd", len);
small_light_module_ctx_t* ctx = (small_light_module_ctx_t*)v_ctx;
small_light_module_dummy_ctx_t *lctx = ctx->lctx;
return small_light_receive_data(&lctx->image, &lctx->image_len, f, bb, data, len);
}
// output data
apr_status_t small_light_filter_dummy_output_data(
ap_filter_t *f,
apr_bucket_brigade *bb,
void *v_ctx,
apr_bucket *e)
{
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "small_light_filter_dummy_output_data");
request_rec *r = f->r;
small_light_module_ctx_t* ctx = (small_light_module_ctx_t*)v_ctx;
small_light_module_dummy_ctx_t *lctx = ctx->lctx;
apr_bucket *b = apr_bucket_pool_create(lctx->image, lctx->image_len, r->pool, ctx->bb->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
APR_BRIGADE_INSERT_TAIL(ctx->bb, apr_bucket_eos_create(ctx->bb->bucket_alloc));
return ap_pass_brigade(f->next, ctx->bb);
}