|
cwist
Modern C web framework with libttak runtime
|
RFC 7578 multipart/form-data parser - wrapper around multipart-parser-c. More...
#include <cwist/net/http/multipart.h>#include <cwist/core/mem/alloc.h>#include <stdbool.h>#include <string.h>#include <strings.h>#include <stdio.h>#include <ctype.h>#include "multipart_parser.h"
Go to the source code of this file.
Functions | |
| cwist_multipart_result * | cwist_multipart_parse (const char *body, size_t body_len, const char *boundary) |
| Parse a multipart/form-data body into a field list. | |
| void | cwist_multipart_result_destroy (cwist_multipart_result *result) |
| Destroy a parse result and everything it owns. | |
| char * | cwist_multipart_extract_boundary (const char *content_type) |
| Extract the boundary parameter from a Content-Type header value. | |
RFC 7578 multipart/form-data parser - wrapper around multipart-parser-c.
Definition in file multipart.c.
Extract the boundary parameter from a Content-Type header value.
Extract the boundary string from a Content-Type header value.
Scans semicolon-separated parameters of content_type, skipping optional whitespace, and accepts both quoted and unquoted boundary values.
| content_type | Content-Type header value, e.g. from the request; may be NULL. |
Definition at line 363 of file multipart.c.
References cap, and cwist_alloc().
| cwist_multipart_result * cwist_multipart_parse | ( | const char * | body, |
| size_t | body_len, | ||
| const char * | boundary | ||
| ) |
Parse a multipart/form-data body into a field list.
Parse a multipart/form-data body.
Runs the multipart-parser-c state machine over body with boundary (the boundary without leading dashes). On malformed or truncated input the parser stops early and NULL is returned, with all intermediate state freed.
| body | Raw body bytes; must not be NULL. |
| body_len | Length of body in bytes. |
| boundary | MIME boundary string, without the leading "--". |
Definition at line 269 of file multipart.c.
References cap, cwist_alloc(), cwist_free(), cwist_multipart_result_destroy(), CWIST_SCRATCH_DEFER, and cwist_multipart_result::fields.
| void cwist_multipart_result_destroy | ( | cwist_multipart_result * | result | ) |
Destroy a parse result and everything it owns.
Free all memory associated with a multipart parse result.
Frees every field's name, filename, content_type, and data, then the field nodes and the result itself. Safe to call with NULL.
| result | Result returned by cwist_multipart_parse, or NULL. |
Definition at line 336 of file multipart.c.
References cap, cwist_free(), cwist_multipart_result::fields, and cwist_multipart_field::next.
Referenced by cwist_multipart_parse().