HomePort
|
Go to the source code of this file.
Data Structures | |
struct | up |
An URL Parser instance. More... | |
Macros | |
#define | UP_CALL(X, ...) |
Enumerations | |
enum | up_state { S_START, S_PROTOCOL, S_SLASH1, S_SLASH2, S_HOST, S_PREPORT, S_PORT, S_SEGMENT, S_KEY, S_VALUE, S_ERROR } |
The possible states of the URL Parser. More... | |
Functions | |
hpd_error_t | up_add_chunk (struct up *instance, const char *chunk, size_t len) |
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... | |
static int | up_isLegalURLChar (char c) |
Check if a given char is valid in an URL. More... | |
struct up |
An URL Parser instance.
Definition at line 50 of file httpd_url_parser.c.
Data Fields | ||
---|---|---|
char * | buffer | URL Buffer. |
const hpd_module_t * | context | |
void * | data | User data. |
size_t | end | Length of full URL. |
size_t | host | Host start. |
size_t | host_l | Host length. |
size_t | insert | Location to insert new chunks. |
size_t | key_value | Arguments start. |
size_t | last_key | Last seen key start. |
size_t | last_key_l | Last seen key length. |
size_t | last_path | Last seen path segment start. |
size_t | last_path_l | Last seen path segment length. |
size_t | last_value | Last seen value start. |
size_t | last_value_l | Last seen value length. |
size_t | parser | Location of parser. |
size_t | path | Path start. |
size_t | path_l | Path length. |
size_t | port | Port start. |
size_t | port_l | Port length. |
size_t | protocol | Protocol start. |
size_t | protocol_l | Protocol length. |
struct up_settings * | settings | Settings. |
enum up_state | state | State. |
#define UP_CALL | ( | X, | |
... | |||
) |
Definition at line 186 of file httpd_url_parser.c.
enum up_state |
The possible states of the URL Parser.
Definition at line 35 of file httpd_url_parser.c.
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.
|
static |
Check if a given char is valid in an URL.
This method checks if a char is valid in an URL. Only specific chars are valid, others have to be encoded properly.
c | A char to check |
Definition at line 172 of file httpd_url_parser.c.