blob: d323e5cc5aa45319a73b9a7d34d42ad4e017f537 [file] [log] [blame]
James Kuszmaul82f6c042021-01-17 11:30:16 -08001/**
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 */
9struct 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
20typedef int (uri_apply_h)(const struct pl *name, const struct pl *val,
21 void *arg);
22
23struct re_printf;
24int uri_encode(struct re_printf *pf, const struct uri *uri);
25int uri_decode(struct uri *uri, const struct pl *pl);
26int uri_decode_hostport(const struct pl *hostport, struct pl *host,
27 struct pl *port);
28int uri_param_get(const struct pl *pl, const struct pl *pname,
29 struct pl *pvalue);
30int uri_params_apply(const struct pl *pl, uri_apply_h *ah, void *arg);
31int uri_header_get(const struct pl *pl, const struct pl *hname,
32 struct pl *hvalue);
33int uri_headers_apply(const struct pl *pl, uri_apply_h *ah, void *arg);
34bool uri_cmp(const struct uri *l, const struct uri *r);
35
36
37/* Special URI escaping/unescaping */
38int uri_user_escape(struct re_printf *pf, const struct pl *pl);
39int uri_user_unescape(struct re_printf *pf, const struct pl *pl);
40int uri_password_escape(struct re_printf *pf, const struct pl *pl);
41int uri_password_unescape(struct re_printf *pf, const struct pl *pl);
42int uri_param_escape(struct re_printf *pf, const struct pl *pl);
43int uri_param_unescape(struct re_printf *pf, const struct pl *pl);
44int uri_header_escape(struct re_printf *pf, const struct pl *pl);
45int uri_header_unescape(struct re_printf *pf, const struct pl *pl);