#./fio-stl/004 multipart.h
3 public symbols.
#Types
#fio_multipart_parser_callbacks_s
c
typedef struct {
/**
* Called for each regular form field (no filename).
* Returns user-defined context (can be NULL).
*
* Note: If on_field_start is provided, this callback is ignored and the
* streaming field callbacks (on_field_start/on_field_data/on_field_end)
* are used instead.
*/
void *(*on_field)(void *udata,
fio_buf_info_s name,
fio_buf_info_s value,
fio_buf_info_s content_type);
/**
* Called when a large field starts (optional).
* If NULL but on_field exists, on_field is used instead (backward
* compatible). Returns context for this field (passed to
* on_field_data/on_field_end).
*/
void *(*on_field_start)(void *udata,
fio_buf_info_s name,
fio_buf_info_s content_type);
/**
* Called with field data chunk.
* May be called multiple times per field for streaming.
* Returns non-zero to abort parsing.
*/
int (*on_field_data)(void *udata, void *field_ctx, fio_buf_info_s data);
/**
* Called when field ends.
*/
void (*on_field_end)(void *udata, void *field_ctx);
/**
* Called when a file upload starts.
* Returns context for this file (passed to on_file_data/on_file_end).
*/
void *(*on_file_start)(void *udata,
fio_buf_info_s name,
fio_buf_info_s filename,
fio_buf_info_s content_type);
/**
* Called with file data chunk.
* May be called multiple times per file for streaming.
* Returns non-zero to abort parsing.
*/
int (*on_file_data)(void *udata, void *file_ctx, fio_buf_info_s data);
/**
* Called when file upload ends.
*/
void (*on_file_end)(void *udata, void *file_ctx);
/**
* Called on parse error (optional).
*/
void (*on_error)(void *udata);
} fio_multipart_parser_callbacks_sThe MIME multipart parser callbacks.
Symbol type: type
#fio_multipart_result_s
c
typedef struct {
/** Number of bytes consumed from the input buffer. */
size_t consumed;
/** Number of form fields parsed. */
size_t field_count;
/** Number of files parsed. */
size_t file_count;
/** Error code: 0 = success, -1 = error, -2 = need more data. */
int err;
} fio_multipart_result_sThe MIME multipart parse result type.
Symbol type: type
#Functions
#fio_multipart_parse
c
fio_multipart_result_s fio_multipart_parse(const fio_multipart_parser_callbacks_s *callbacks, void *udata, fio_buf_info_s boundary, const char *data, size_t len)Parse MIME multipart data.
callbacks contains the callback functions (should be static const).
udata is user data passed to all callbacks.
boundary is the multipart boundary string (without leading "--").
data is the data to parse.
len is the length of the data.
Returns a result struct containing:
consumed: Number of bytes consumed from the bufferfield_count: Number of form fields parsedfile_count: Number of files parsederr: 0 = success, -1 = error, -2 = need more data
For streaming, call again with remaining data appended to unconsumed data.
Symbol type: function