HomePort
|
Go to the source code of this file.
Data Structures | |
struct | up_settings |
Settings struct for the URL Parser. More... | |
Macros | |
#define | UP_SETTINGS_DEFAULT |
Typedefs | |
typedef hpd_error_t(* | up_pair_cb) (void *data, const char *key, size_t key_length, const char *value, size_t value_length) |
typedef hpd_error_t(* | up_string_cb) (void *data, const char *parsedSegment, size_t segment_length) |
typedef hpd_error_t(* | up_void_cb) (void *data) |
Functions | |
hpd_error_t | up_add_chunk (struct up *instance, const char *chunk, size_t chunk_size) |
Parse a chunk of an URL. More... | |
hpd_error_t | up_complete (struct up *instance) |
Informs the parser that the URL is complete. More... | |
hpd_error_t | up_create (struct up **instance, struct up_settings *settings, const hpd_module_t *context, void *data) |
Create URL parser instance. More... | |
hpd_error_t | up_destroy (struct up *instance) |
Destroy URL parser instance. More... | |
struct up_settings |
Settings struct for the URL Parser.
Please initialise this struct as following, to ensure that all settings have acceptable default values:
The settings hold a series of callbacks of type either up_string_cb, up_pair_cb or up_void_cb. Strings received in up_pair_cb and up_string_cb are never null-terminated, and they always have a length. The callbacks are called when the URL parser finishes parsing a specific chunk. The callback with the last part of a segment (e.g. the c in /a/b/c) might first be called when up_complete has been called, as it cannot know if c is the last character of the segment unless it terminates with a /.
Definition at line 59 of file httpd_url_parser.h.
Data Fields | ||
---|---|---|
up_void_cb | on_begin | |
up_string_cb | on_complete | |
up_string_cb | on_host | |
up_pair_cb | on_key_value | |
up_string_cb | on_path_complete | |
up_string_cb | on_path_segment | |
up_string_cb | on_port | |
up_string_cb | on_protocol |
#define UP_SETTINGS_DEFAULT |
Definition at line 70 of file httpd_url_parser.h.
typedef hpd_error_t(* up_pair_cb) (void *data, const char *key, size_t key_length, const char *value, size_t value_length) |
Definition at line 34 of file httpd_url_parser.h.
typedef hpd_error_t(* up_string_cb) (void *data, const char *parsedSegment, size_t segment_length) |
Definition at line 33 of file httpd_url_parser.h.
typedef hpd_error_t(* up_void_cb) (void *data) |
Definition at line 35 of file httpd_url_parser.h.
hpd_error_t up_add_chunk | ( | struct up * | instance, |
const char * | chunk, | ||
size_t | len | ||
) |
Parse a chunk of an URL.
This method receives a chunk of an URL, and calls the appropriate callbacks. It increases the size of buffer, copies the new chunk to it and then parses each character and changes state accordingly. A chunk may of course be a complete URL, all of which will be parsed immediately.
instance | A pointer to an URL Parser instance |
chunk | A pointer to the chunk (non zero terminated) |
chunk_size | The size of the chunk |
Definition at line 209 of file httpd_url_parser.c.
hpd_error_t up_complete | ( | struct up * | instance | ) |
Informs the parser that the URL is complete.
This method will let the parser know that the URL is complete. This always results in the on_complete callback being called, but it may also inflict two others: on_path_segment and on_key_value. This is due to the nature of the URL parser being able to receive in chunks: it can simply now know if an URL path is complete without a slash at the end. It also cannot know if a value part of a key is done before being told.
instance | A pointer to an URL Parser instance |
Definition at line 377 of file httpd_url_parser.c.
hpd_error_t up_create | ( | struct up ** | instance, |
struct up_settings * | settings, | ||
const hpd_module_t * | context, | ||
void * | data | ||
) |
Create URL parser instance.
This method creates an URL Parser instance. It allocates memory for itself and copy the settings struct. It also sets all values to default.
The instance should be destroyed using up_destroy when it is no longer needed.
settings | A pointer to a url_parser_settings struct |
data | Pointer to user data, will be supplied to callbacks |
Definition at line 96 of file httpd_url_parser.c.
hpd_error_t up_destroy | ( | struct up * | instance | ) |
Destroy URL parser instance.
This method destroys an URL Parser instance, including the buffer and settings struct.
instance | A pointer to an url_parser_instance to destroy |
Definition at line 152 of file httpd_url_parser.c.