Parse and identify different URL schemes. More...
Go to the source code of this file.
Data Structures | |
struct | UrlQuery |
Parsed Query String. More... | |
struct | Url |
A parsed URL proto://user:password@host:port/path?a=1&b=2 More... | |
Macros | |
#define | U_NO_FLAGS 0 |
#define | U_PATH (1 << 1) |
Enumerations | |
enum | UrlScheme { U_UNKNOWN , U_FILE , U_POP , U_POPS , U_IMAP , U_IMAPS , U_NNTP , U_NNTPS , U_SMTP , U_SMTPS , U_MAILTO , U_NOTMUCH } |
All recognised Url types. More... | |
Functions | |
STAILQ_HEAD (UrlQueryList, UrlQuery) | |
enum UrlScheme | url_check_scheme (const char *s) |
Check the protocol of a URL. | |
void | url_free (struct Url **ptr) |
Free the contents of a URL. | |
struct Url * | url_parse (const char *src) |
Fill in Url. | |
int | url_pct_decode (char *s) |
Decode a percent-encoded string. | |
void | url_pct_encode (char *buf, size_t buflen, const char *src) |
Percent-encode a string. | |
int | url_tobuffer (const struct Url *url, struct Buffer *dest, uint8_t flags) |
Output the URL string for a given Url object. | |
int | url_tostring (const struct Url *url, char *buf, size_t buflen, uint8_t flags) |
Output the URL string for a given Url object. | |
Parse and identify different URL schemes.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file url.h.
enum UrlScheme |
All recognised Url types.
Enumerator | |
---|---|
U_UNKNOWN | Url wasn't recognised. |
U_FILE | |
U_POP | Url is pop://. |
U_POPS | Url is pops://. |
U_IMAP | Url is imap://. |
U_IMAPS | Url is imaps://. |
U_NNTP | Url is nntp://. |
U_NNTPS | Url is nntps://. |
U_SMTP | Url is smtp://. |
U_SMTPS | Url is smtps://. |
U_MAILTO | Url is mailto://. |
U_NOTMUCH | Url is notmuch://. |
STAILQ_HEAD | ( | UrlQueryList | , |
UrlQuery | |||
) |
enum UrlScheme url_check_scheme | ( | const char * | str | ) |
Check the protocol of a URL.
str | String to check |
enum | UrlScheme, e.g. U_IMAPS |
Definition at line 226 of file url.c.
void url_free | ( | struct Url ** | ptr | ) |
Free the contents of a URL.
ptr | Url to free |
Definition at line 124 of file url.c.
struct Url * url_parse | ( | const char * | src | ) |
Fill in Url.
src | String to parse |
ptr | Parsed URL |
NULL | Error |
Definition at line 239 of file url.c.
int url_pct_decode | ( | char * | s | ) |
Decode a percent-encoded string.
s | String to decode |
0 | Success |
-1 | Error |
e.g. turn "hello%20world" into "hello world" The string is decoded in-place.
Definition at line 190 of file url.c.
void url_pct_encode | ( | char * | buf, |
size_t | buflen, | ||
const char * | src | ||
) |
Percent-encode a string.
buf | Buffer for the result |
buflen | Length of buffer |
src | String to encode |
e.g. turn "hello world" into "hello%20world"
Definition at line 152 of file url.c.
Output the URL string for a given Url object.
0 | Success |
-1 | Error |
Definition at line 358 of file url.c.
int url_tostring | ( | const struct Url * | url, |
char * | dest, | ||
size_t | len, | ||
uint8_t | flags | ||
) |
Output the URL string for a given Url object.
url | Url to turn into a string |
dest | Buffer for the result |
len | Length of buffer |
flags | Flags, e.g. U_PATH |
0 | Success |
-1 | Error |
Definition at line 423 of file url.c.