File: apreq_parser.h.3

package info (click to toggle)
libapreq2 2.17-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,164 kB
  • sloc: ansic: 8,283; perl: 5,451; sh: 4,627; cpp: 380; makefile: 270; javascript: 186
file content (297 lines) | stat: -rw-r--r-- 10,382 bytes parent folder | download | duplicates (3)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
.TH "include/apreq_parser.h" 3 "Thu Aug 18 2022" "Version 2.17" "libapreq2" \" -*- nroff -*-
.ad l
.nh
.SH NAME
include/apreq_parser.h \- Request body parser API\&.  

.SH SYNOPSIS
.br
.PP
\fC#include 'apreq_param\&.h'\fP
.br

.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBapreq_hook_t\fP"
.br
.ti -1c
.RI "struct \fBapreq_parser_t\fP"
.br
.ti -1c
.RI "struct \fBapreq_hook_find_param_ctx_t\fP"
.br
.in -1c
.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBAPREQ_PARSER_ARGS\fP"
.br
.ti -1c
.RI "#define \fBAPREQ_HOOK_ARGS\fP"
.br
.ti -1c
.RI "#define \fBAPREQ_DECLARE_PARSER\fP(f)"
.br
.ti -1c
.RI "#define \fBAPREQ_DECLARE_HOOK\fP(f)"
.br
.in -1c
.SS "Typedefs"

.in +1c
.ti -1c
.RI "typedef struct \fBapreq_hook_t\fP \fBapreq_hook_t\fP"
.br
.ti -1c
.RI "typedef struct \fBapreq_parser_t\fP \fBapreq_parser_t\fP"
.br
.ti -1c
.RI "typedef apr_status_t(* \fBapreq_parser_function_t\fP) (\fBAPREQ_PARSER_ARGS\fP)"
.br
.ti -1c
.RI "typedef apr_status_t(* \fBapreq_hook_function_t\fP) (\fBAPREQ_HOOK_ARGS\fP)"
.br
.ti -1c
.RI "typedef struct \fBapreq_hook_find_param_ctx_t\fP \fBapreq_hook_find_param_ctx_t\fP"
.br
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "static APR_INLINE apr_status_t \fBapreq_parser_run\fP (struct \fBapreq_parser_t\fP *psr, apr_table_t *t, apr_bucket_brigade *bb)"
.br
.ti -1c
.RI "static APR_INLINE apr_status_t \fBapreq_hook_run\fP (struct \fBapreq_hook_t\fP *h, \fBapreq_param_t\fP *param, apr_bucket_brigade *bb)"
.br
.ti -1c
.RI "\fBAPREQ_DECLARE_PARSER\fP (apreq_parse_headers)"
.br
.ti -1c
.RI "\fBAPREQ_DECLARE_PARSER\fP (apreq_parse_urlencoded)"
.br
.ti -1c
.RI "\fBAPREQ_DECLARE_PARSER\fP (apreq_parse_multipart)"
.br
.ti -1c
.RI "\fBAPREQ_DECLARE_PARSER\fP (apreq_parse_generic)"
.br
.ti -1c
.RI "\fBAPREQ_DECLARE_HOOK\fP (apreq_hook_apr_xml_parser)"
.br
.ti -1c
.RI "\fBapreq_parser_t\fP * \fBapreq_parser_make\fP (apr_pool_t *pool, apr_bucket_alloc_t *ba, const char *content_type, \fBapreq_parser_function_t\fP pfn, apr_size_t brigade_limit, const char *temp_dir, \fBapreq_hook_t\fP *hook, void *ctx)"
.br
.ti -1c
.RI "\fBapreq_hook_t\fP * \fBapreq_hook_make\fP (apr_pool_t *pool, \fBapreq_hook_function_t\fP hook, \fBapreq_hook_t\fP *next, void *ctx)"
.br
.ti -1c
.RI "apr_status_t \fBapreq_parser_add_hook\fP (\fBapreq_parser_t\fP *p, \fBapreq_hook_t\fP *h)"
.br
.ti -1c
.RI "\fBapreq_parser_function_t\fP \fBapreq_parser\fP (const char *enctype)"
.br
.ti -1c
.RI "apr_status_t \fBapreq_register_parser\fP (const char *enctype, \fBapreq_parser_function_t\fP pfn)"
.br
.ti -1c
.RI "\fBAPREQ_DECLARE_HOOK\fP (apreq_hook_disable_uploads)"
.br
.ti -1c
.RI "\fBAPREQ_DECLARE_HOOK\fP (apreq_hook_discard_brigade)"
.br
.ti -1c
.RI "\fBAPREQ_DECLARE_HOOK\fP (apreq_hook_find_param)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Request body parser API\&. 


.SH "Macro Definition Documentation"
.PP 
.SS "#define APREQ_DECLARE_HOOK(f)"
\fBValue:\fP
.PP
.nf
                                APREQ_DECLARE_NONSTD(apr_status_t) \
                                f (APREQ_HOOK_ARGS)
.fi
Declares an API hook\&. 
.SS "#define APREQ_DECLARE_PARSER(f)"
\fBValue:\fP
.PP
.nf
                                APREQ_DECLARE_NONSTD(apr_status_t) \
                                f (APREQ_PARSER_ARGS)
.fi
Declares a API parser\&. 
.SS "#define APREQ_HOOK_ARGS"
\fBValue:\fP
.PP
.nf
                           apreq_hook_t *hook,         \
                           apreq_param_t *param,       \
                           apr_bucket_brigade *bb
.fi
Hook arguments 
.SS "#define APREQ_PARSER_ARGS"
\fBValue:\fP
.PP
.nf
                           apreq_parser_t *parser,     \
                           apr_table_t *t,             \
                           apr_bucket_brigade *bb
.fi
Parser arguments\&. 
.SH "Typedef Documentation"
.PP 
.SS "typedef struct \fBapreq_hook_find_param_ctx_t\fP \fBapreq_hook_find_param_ctx_t\fP"
Context struct for the apreq_hook_find_param hook\&. 
.SS "typedef apr_status_t(* apreq_hook_function_t) (\fBAPREQ_HOOK_ARGS\fP)"
The callback function of a hook\&. See \fBapreq_hook_t\fP\&. 
.SS "typedef struct \fBapreq_hook_t\fP \fBapreq_hook_t\fP"
A hook is called by the parser whenever data arrives in a file upload parameter of the request body\&. You may associate any number of hooks with a parser instance with \fBapreq_parser_add_hook()\fP\&. 
.SS "typedef apr_status_t(* apreq_parser_function_t) (\fBAPREQ_PARSER_ARGS\fP)"
The callback function implementing a request body parser\&. 
.SS "typedef struct \fBapreq_parser_t\fP \fBapreq_parser_t\fP"
A request body parser instance\&. 
.SH "Function Documentation"
.PP 
.SS "APREQ_DECLARE_HOOK (apreq_hook_apr_xml_parser)"
apr_xml_parser hook\&. It will parse until EOS appears\&. The parsed document isn't available until parsing has completed successfully\&. The hook's ctx pointer may be cast as (apr_xml_doc **) to retrieve the parsed document\&. 
.SS "APREQ_DECLARE_HOOK (apreq_hook_disable_uploads)"
Returns APREQ_ERROR_GENERAL\&. Effectively disables mfd parser if a file-upload field is present\&. 
.SS "APREQ_DECLARE_HOOK (apreq_hook_discard_brigade)"
Calls apr_brigade_cleanup on the incoming brigade after passing the brigade to any subsequent hooks\&. 
.SS "APREQ_DECLARE_HOOK (apreq_hook_find_param)"
Special purpose utility for locating a parameter during parsing\&. The hook's ctx should be initialized to an \fBapreq_hook_find_param_ctx_t\fP *, with the name attribute set to the sought parameter name, the param attribute set to NULL, and the prev attribute set to the address of the previous hook\&. The param attribute will be reassigned to the first param found, and once that happens this hook is immediately removed from the chain\&.
.PP
\fBRemarks\fP
.RS 4
When used, this should always be the first hook invoked, so add it manually with ctx->prev = &parser->hook instead of using apreq_parser_add_hook\&. 
.RE
.PP

.SS "APREQ_DECLARE_PARSER (apreq_parse_generic)"
Generic parser\&. No table entries will be added to the req->body table by this parser\&. The parser creates a dummy \fBapreq_param_t\fP to pass to any configured hooks\&. If no hooks are configured, the dummy param's bb slot will contain a copy of the request body\&. It can be retrieved by casting the parser's ctx pointer to (\fBapreq_param_t\fP **)\&. 
.SS "APREQ_DECLARE_PARSER (apreq_parse_headers)"
RFC 822 Header parser\&. It will reject all data after the first CRLF CRLF sequence (an empty line)\&. See \fBapreq_parser_run()\fP for more info on rejected data\&. 
.SS "APREQ_DECLARE_PARSER (apreq_parse_multipart)"
RFC 2388 multipart/form-data (and XForms 1\&.0 multipart/related) parser\&. It will reject any buckets representing preamble and postamble text (this is normal behavior, not an error condition)\&. See \fBapreq_parser_run()\fP for more info on rejected data\&. 
.SS "APREQ_DECLARE_PARSER (apreq_parse_urlencoded)"
RFC 2396 application/x-www-form-urlencoded parser\&. 
.SS "\fBapreq_hook_t\fP* apreq_hook_make (apr_pool_t * pool, \fBapreq_hook_function_t\fP hook, \fBapreq_hook_t\fP * next, void * ctx)"
Construct a hook\&.
.PP
\fBParameters\fP
.RS 4
\fIpool\fP used to allocate the hook\&. 
.br
\fIhook\fP The hook function\&. 
.br
\fInext\fP List of other hooks for this hook to call on\&. 
.br
\fIctx\fP Hook's internal scratch pad\&. 
.RE
.PP
\fBReturns\fP
.RS 4
New hook\&. 
.RE
.PP

.SS "static APR_INLINE apr_status_t apreq_hook_run (struct \fBapreq_hook_t\fP * h, \fBapreq_param_t\fP * param, apr_bucket_brigade * bb)\fC [static]\fP"
Run the hook with the current parameter and the incoming bucket brigade\&. The hook may modify the brigade if necessary\&. Once all hooks have completed, the contents of the brigade will be added to the parameter's bb attribute\&. 
.PP
\fBReturns\fP
.RS 4
APR_SUCCESS on success\&. All other values represent errors\&. 
.RE
.PP

.SS "\fBapreq_parser_function_t\fP apreq_parser (const char * enctype)"
Fetch the default parser function associated with the given MIME type\&. 
.PP
\fBParameters\fP
.RS 4
\fIenctype\fP The desired enctype (can also be a full 'Content-Type' header)\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The parser function, or NULL if the enctype is unrecognized\&. 
.RE
.PP

.SS "apr_status_t apreq_parser_add_hook (\fBapreq_parser_t\fP * p, \fBapreq_hook_t\fP * h)"
Add a new hook to the end of the parser's hook list\&.
.PP
\fBParameters\fP
.RS 4
\fIp\fP Parser\&. 
.br
\fIh\fP Hook to append\&. 
.RE
.PP

.SS "\fBapreq_parser_t\fP* apreq_parser_make (apr_pool_t * pool, apr_bucket_alloc_t * ba, const char * content_type, \fBapreq_parser_function_t\fP pfn, apr_size_t brigade_limit, const char * temp_dir, \fBapreq_hook_t\fP * hook, void * ctx)"
Construct a parser\&.
.PP
\fBParameters\fP
.RS 4
\fIpool\fP Pool used to allocate the parser\&. 
.br
\fIba\fP bucket allocator used to create bucket brigades 
.br
\fIcontent_type\fP Content-type that this parser can deal with\&. 
.br
\fIpfn\fP The parser function\&. 
.br
\fIbrigade_limit\fP the maximum in-memory bytes a brigade may use 
.br
\fItemp_dir\fP the directory used by the parser for temporary files 
.br
\fIhook\fP Hooks to associate this parser with\&. 
.br
\fIctx\fP Parser's internal scratch pad\&. 
.RE
.PP
\fBReturns\fP
.RS 4
New parser\&. 
.RE
.PP

.SS "static APR_INLINE apr_status_t apreq_parser_run (struct \fBapreq_parser_t\fP * psr, apr_table_t * t, apr_bucket_brigade * bb)\fC [static]\fP"
Parse the incoming brigade into a table\&. Parsers normally consume all the buckets of the brigade during parsing\&. However parsers may leave 'rejected' data in the brigade, even during a successful parse, so callers may need to clean up the brigade themselves (in particular, rejected buckets should not be passed back to the parser again)\&. 
.PP
\fBRemarks\fP
.RS 4
bb == NULL is valid: the parser should return its public status: APR_INCOMPLETE, APR_SUCCESS, or an error code\&. 
.RE
.PP

.SS "apr_status_t apreq_register_parser (const char * enctype, \fBapreq_parser_function_t\fP pfn)"
Register a new parsing function with a MIME enctype\&. Registered parsers are added to \fBapreq_parser()\fP's internal lookup table\&.
.PP
\fBParameters\fP
.RS 4
\fIenctype\fP The MIME type\&. 
.br
\fIpfn\fP The function to use during parsing\&. Setting parser == NULL will remove an existing parser\&.
.RE
.PP
\fBReturns\fP
.RS 4
APR_SUCCESS or error\&. 
.RE
.PP

.SH "Author"
.PP 
Generated automatically by Doxygen for libapreq2 from the source code\&.