![]() |
BSB Developer Docs
|
URL parsing library. More...
Go to the source code of this file.
Typedefs | |
| typedef struct Url | Url |
| Url opaque type. | |
Enumerations | |
| enum | UrlPartId { UrlPartIdHref , UrlPartIdRequest , UrlPartIdOrigin , UrlPartIdProtocol , UrlPartIdHost , UrlPartIdHostname , UrlPartIdPort , UrlPartIdPathname , UrlPartIdSearch , UrlPartIdHash , UrlPartIdMax } |
| Enumeration of available URL part identifiers. More... | |
Functions | |
| Url * | url_alloc (void) |
| Create an URL instance. | |
| void | url_free (Url *instance) |
| Delete an URL instance. | |
| bool | url_parse (Url *instance, const char *source) |
| Parse and encode an URL from a string. | |
| const StringSlice * | url_get_part (const Url *instance, UrlPartId part_id) |
| Get a URL part via its identifier. | |
URL parsing library.
| enum UrlPartId |
Enumeration of available URL part identifiers.
| Url * url_alloc | ( | void | ) |
Create an URL instance.
| void url_free | ( | Url * | instance | ) |
Delete an URL instance.
All part pointers obtained via url_get_part will become INVALID after this call.
| [in,out] | instance | pointer to the instance to be deleted |
| const StringSlice * url_get_part | ( | const Url * | instance, |
| UrlPartId | part_id ) |
Get a URL part via its identifier.
The return value is guaranteed to be non-NULL and valid until url_free is called.
If a part is not present, the returned slice will represent an empty string.
| [in] | instance | pointer to the instance to be queried |
| [in] | part_id | numeric identifier of the part in question |
| bool url_parse | ( | Url * | instance, |
| const char * | source ) |
Parse and encode an URL from a string.
The following URL parts are required:
All part pointers obtained via url_get_part will remain VALID after this call, but their underlying values might silently change.
Percent encoding will be performed where applicable. Non-ASCII hostnames are NOT supported. If a Unicode hostname is needed, it must be supplied in the punycode-encoded form.
| [in,out] | instance | pointer to the instance to contain the parsed data |
| [in] | source | pointer to a zero-terminated URL string |
true if the URL could be parsed, false otherwise