#./fio-stl/004 urlencoded.h
3 public symbols.
#Types
#fio_url_encoded_parser_callbacks_s
c
typedef struct {
/**
* Called for each name=value pair found.
*
* `name` and `value` point directly into the original input data.
* The data is NOT decoded - caller must decode if needed.
*
* Returns the (possibly updated) udata, or NULL to stop parsing.
*/
void *(*on_pair)(void *udata, fio_buf_info_s name, fio_buf_info_s value);
/**
* Called on parsing error (optional).
*
* Currently not used since URL-encoded parsing is very permissive,
* but reserved for future use.
*/
void (*on_error)(void *udata);
} fio_url_encoded_parser_callbacks_sThe URL-encoded parser callbacks.
Callbacks receive udata as their first argument.
Symbol type: type
#fio_url_encoded_result_s
c
typedef struct {
/** Number of bytes consumed from the buffer. */
size_t consumed;
/** Number of name=value pairs found. */
size_t count;
/** Non-zero if an error occurred (callback returned NULL). */
int err;
} fio_url_encoded_result_sThe URL-encoded parse result type.
Symbol type: type
#Functions
#fio_url_encoded_parse
c
fio_url_encoded_result_s fio_url_encoded_parse(const fio_url_encoded_parser_callbacks_s *callbacks, void *udata, const char *data, size_t len)Parse URL-encoded data from buffer.
callbacks contains the callback functions (should be static const).
udata is user data passed to callbacks.
data is the URL-encoded data to parse.
len is the length of the data.
Returns a result struct containing:
consumed: Number of bytes consumed from the buffercount: Number of name=value pairs founderr: Non-zero if parsing was stopped (callback returned NULL)
Parsing rules:
- Pairs are separated by
& - Name and value are separated by
= - Empty value is valid:
name=→ value.len = 0 - Missing
=means value is empty:name→ name="name", value.len = 0 - Empty name with value:
=value→ name.len = 0, value="value" - Empty pairs (
&&) are skipped
Note: The parser does NOT decode percent-encoded characters.
Use fio_string_write_url_dec to decode if needed.
Symbol type: function