1 |
297 |
jeremybenn |
typedef __SIZE_TYPE__ size_t;
|
2 |
|
|
typedef struct {
|
3 |
|
|
}
|
4 |
|
|
HashTable;
|
5 |
|
|
typedef struct _zval_struct zval;
|
6 |
|
|
typedef struct _zend_guard {
|
7 |
|
|
HashTable *ht;
|
8 |
|
|
}
|
9 |
|
|
zvalue_value;
|
10 |
|
|
struct _zval_struct {
|
11 |
|
|
zvalue_value value;
|
12 |
|
|
}
|
13 |
|
|
php_output_globals;
|
14 |
|
|
typedef struct _php_stream php_stream;
|
15 |
|
|
typedef struct _php_stream_filter php_stream_filter;
|
16 |
|
|
typedef struct _php_stream_bucket_brigade php_stream_bucket_brigade;
|
17 |
|
|
typedef enum {
|
18 |
|
|
PSFS_ERR_FATAL, PSFS_FEED_ME, PSFS_PASS_ON, }
|
19 |
|
|
php_stream_filter_status_t;
|
20 |
|
|
typedef struct _php_stream_filter_ops {
|
21 |
|
|
php_stream_filter_status_t (*filter)( php_stream *stream, php_stream_filter *thisfilter, php_stream_bucket_brigade *buckets_in, php_stream_bucket_brigade *buckets_out, size_t *bytes_consumed, int flags );
|
22 |
|
|
void (*dtor)(php_stream_filter *thisfilter );
|
23 |
|
|
const char *label;
|
24 |
|
|
}
|
25 |
|
|
php_stream_filter_ops;
|
26 |
|
|
struct _php_stream_filter {
|
27 |
|
|
};
|
28 |
|
|
typedef struct _php_stream_filter_factory {
|
29 |
|
|
php_stream_filter *(*create_filter)(const char *filtername, zval *filterparams, int persistent );
|
30 |
|
|
}
|
31 |
|
|
php_stream_filter_factory;
|
32 |
|
|
typedef enum _php_conv_err_t {
|
33 |
|
|
PHP_CONV_ERR_SUCCESS = 0, PHP_CONV_ERR_UNKNOWN, PHP_CONV_ERR_TOO_BIG, PHP_CONV_ERR_INVALID_SEQ, PHP_CONV_ERR_UNEXPECTED_EOS, PHP_CONV_ERR_EXISTS, PHP_CONV_ERR_MORE, PHP_CONV_ERR_ALLOC, PHP_CONV_ERR_NOT_FOUND }
|
34 |
|
|
php_conv_err_t;
|
35 |
|
|
typedef struct _php_conv php_conv;
|
36 |
|
|
typedef php_conv_err_t (*php_conv_convert_func)(php_conv *, const char **, size_t *, char **, size_t *);
|
37 |
|
|
struct _php_conv {
|
38 |
|
|
php_conv_convert_func convert_op;
|
39 |
|
|
}
|
40 |
|
|
php_conv_base64_decode;
|
41 |
|
|
typedef struct _php_conv_qprint_decode {
|
42 |
|
|
php_conv _super;
|
43 |
|
|
const char *lbchars;
|
44 |
|
|
}
|
45 |
|
|
php_conv_qprint_decode;
|
46 |
|
|
static php_conv_err_t php_conv_qprint_decode_convert(php_conv_qprint_decode *inst, const char **in_pp, size_t *in_left_p, char **out_pp, size_t *out_left_p) {
|
47 |
|
|
size_t icnt, ocnt;
|
48 |
|
|
unsigned char *ps, *pd;
|
49 |
|
|
unsigned int scan_stat;
|
50 |
|
|
unsigned int lb_ptr, lb_cnt;
|
51 |
|
|
for (;
|
52 |
|
|
;
|
53 |
|
|
) {
|
54 |
|
|
switch (scan_stat) {
|
55 |
|
|
case 0: {
|
56 |
|
|
if (*ps == '=') {
|
57 |
|
|
scan_stat = 1;
|
58 |
|
|
}
|
59 |
|
|
else {
|
60 |
|
|
if (ocnt < 1) {
|
61 |
|
|
goto out;
|
62 |
|
|
}
|
63 |
|
|
*(pd++) = *ps;
|
64 |
|
|
ocnt--;
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
break;
|
68 |
|
|
case 1: {
|
69 |
|
|
if (*ps == ' ' || *ps == '\t') {
|
70 |
|
|
}
|
71 |
|
|
else if (!inst->lbchars && lb_cnt == 0 && *ps == '\r') {
|
72 |
|
|
lb_cnt++;
|
73 |
|
|
scan_stat = 5;
|
74 |
|
|
break;
|
75 |
|
|
}
|
76 |
|
|
else if (!inst->lbchars && lb_cnt == 0 && *ps == '\n') {
|
77 |
|
|
scan_stat = 0;
|
78 |
|
|
break;
|
79 |
|
|
}
|
80 |
|
|
}
|
81 |
|
|
case 2: {
|
82 |
|
|
if (icnt <= 0) {
|
83 |
|
|
goto out;
|
84 |
|
|
}
|
85 |
|
|
}
|
86 |
|
|
case 3: {
|
87 |
|
|
}
|
88 |
|
|
case 4: {
|
89 |
|
|
ps++, icnt--;
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
}
|
93 |
|
|
out: *in_pp = (const char *)ps;
|
94 |
|
|
}
|
95 |
|
|
static php_conv_err_t php_conv_qprint_decode_ctor(php_conv_qprint_decode *inst, const char *lbchars, size_t lbchars_len, int lbchars_dup, int persistent) {
|
96 |
|
|
inst->_super.convert_op = (php_conv_convert_func) php_conv_qprint_decode_convert;
|
97 |
|
|
}
|
98 |
|
|
typedef struct _php_convert_filter {
|
99 |
|
|
php_conv *cd;
|
100 |
|
|
}
|
101 |
|
|
php_convert_filter;
|
102 |
|
|
static php_conv *php_conv_open(int conv_mode, const HashTable *options, int persistent) {
|
103 |
|
|
php_conv *retval = ((void *)0);
|
104 |
|
|
switch (conv_mode) {
|
105 |
|
|
case 4: {
|
106 |
|
|
char *lbchars = ((void *)0);
|
107 |
|
|
size_t lbchars_len;
|
108 |
|
|
if (lbchars != ((void *)0)) {
|
109 |
|
|
if (php_conv_qprint_decode_ctor((php_conv_qprint_decode *)retval, lbchars, lbchars_len, 1, persistent)) {
|
110 |
|
|
}
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
|
|
static int php_convert_filter_ctor(php_convert_filter *inst, int conv_mode, HashTable *conv_opts, const char *filtername, int persistent) {
|
116 |
|
|
if ((inst->cd = php_conv_open(conv_mode, conv_opts, persistent)) == ((void *)0)) {
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
static php_stream_filter_status_t strfilter_convert_filter( php_stream *stream, php_stream_filter *thisfilter, php_stream_bucket_brigade *buckets_in, php_stream_bucket_brigade *buckets_out, size_t *bytes_consumed, int flags ) {
|
120 |
|
|
}
|
121 |
|
|
static void strfilter_convert_dtor(php_stream_filter *thisfilter ) {
|
122 |
|
|
}
|
123 |
|
|
static php_stream_filter_ops strfilter_convert_ops = {
|
124 |
|
|
strfilter_convert_filter, strfilter_convert_dtor, "convert.*" };
|
125 |
|
|
static php_stream_filter *strfilter_convert_create(const char *filtername, zval *filterparams, int persistent ) {
|
126 |
|
|
php_convert_filter *inst;
|
127 |
|
|
int conv_mode = 0;
|
128 |
|
|
if (php_convert_filter_ctor(inst, conv_mode, (filterparams != ((void *)0) ? (*filterparams).value.ht : ((void *)0)), filtername, persistent) != 0) {
|
129 |
|
|
}
|
130 |
|
|
}
|
131 |
|
|
static php_stream_filter_factory strfilter_convert_factory = {
|
132 |
|
|
strfilter_convert_create };
|
133 |
|
|
static const struct {
|
134 |
|
|
php_stream_filter_ops *ops;
|
135 |
|
|
php_stream_filter_factory *factory;
|
136 |
|
|
}
|
137 |
|
|
standard_filters[] = {
|
138 |
|
|
{
|
139 |
|
|
&strfilter_convert_ops, &strfilter_convert_factory }
|
140 |
|
|
};
|
141 |
|
|
int zm_startup_standard_filters(int type, int module_number ) {
|
142 |
|
|
int i;
|
143 |
|
|
for (i = 0;
|
144 |
|
|
standard_filters[i].ops;
|
145 |
|
|
i++) {
|
146 |
|
|
}
|
147 |
|
|
}
|