James Kuszmaul | 82f6c04 | 2021-01-17 11:30:16 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * @file re_uri.h Interface to URI module |
| 3 | * |
| 4 | * Copyright (C) 2010 Creytiv.com |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | /** Defines a URI - Uniform Resource Identifier */ |
| 9 | struct uri { |
| 10 | struct pl scheme; /**< URI scheme e.g. "sip:" "sips:" */ |
| 11 | struct pl user; /**< Username */ |
| 12 | struct pl password; /**< Optional password */ |
| 13 | struct pl host; /**< Hostname or IP-address */ |
| 14 | int af; /**< Address family of host IP-address */ |
| 15 | uint16_t port; /**< Port number */ |
| 16 | struct pl params; /**< Optional URI-parameters */ |
| 17 | struct pl headers; /**< Optional URI-headers */ |
| 18 | }; |
| 19 | |
| 20 | typedef int (uri_apply_h)(const struct pl *name, const struct pl *val, |
| 21 | void *arg); |
| 22 | |
| 23 | struct re_printf; |
| 24 | int uri_encode(struct re_printf *pf, const struct uri *uri); |
| 25 | int uri_decode(struct uri *uri, const struct pl *pl); |
| 26 | int uri_decode_hostport(const struct pl *hostport, struct pl *host, |
| 27 | struct pl *port); |
| 28 | int uri_param_get(const struct pl *pl, const struct pl *pname, |
| 29 | struct pl *pvalue); |
| 30 | int uri_params_apply(const struct pl *pl, uri_apply_h *ah, void *arg); |
| 31 | int uri_header_get(const struct pl *pl, const struct pl *hname, |
| 32 | struct pl *hvalue); |
| 33 | int uri_headers_apply(const struct pl *pl, uri_apply_h *ah, void *arg); |
| 34 | bool uri_cmp(const struct uri *l, const struct uri *r); |
| 35 | |
| 36 | |
| 37 | /* Special URI escaping/unescaping */ |
| 38 | int uri_user_escape(struct re_printf *pf, const struct pl *pl); |
| 39 | int uri_user_unescape(struct re_printf *pf, const struct pl *pl); |
| 40 | int uri_password_escape(struct re_printf *pf, const struct pl *pl); |
| 41 | int uri_password_unescape(struct re_printf *pf, const struct pl *pl); |
| 42 | int uri_param_escape(struct re_printf *pf, const struct pl *pl); |
| 43 | int uri_param_unescape(struct re_printf *pf, const struct pl *pl); |
| 44 | int uri_header_escape(struct re_printf *pf, const struct pl *pl); |
| 45 | int uri_header_unescape(struct re_printf *pf, const struct pl *pl); |