Blob


1 /*
2 * Copyright (c) 2022 Omar Polo <op@omarpolo.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 #ifndef IRI_H
18 #define IRI_H
20 struct iri {
21 char iri_scheme[32];
22 char iri_uinfo[254];
23 char iri_host[1024];
24 char iri_portstr[6];
25 uint16_t iri_port;
26 char iri_path[1024];
27 char iri_query[1024];
28 char iri_fragment[1024];
30 #define IH_SCHEME 0x01
31 #define IH_UINFO 0x02
32 #define IH_HOST 0x04
33 #define IH_PORT 0x08
34 #define IH_AUTHORITY (IH_UINFO|IH_HOST|IH_PORT)
35 #define IH_PATH 0x10
36 #define IH_QUERY 0x20
37 #define IH_FRAGMENT 0x40
38 int iri_flags;
39 };
41 int iri_parse(const char *, const char *, struct iri *);
42 int iri_unparse(const struct iri *, char *, size_t);
43 int iri_human(const struct iri *, char *, size_t);
44 int iri_setquery(struct iri *, const char *);
46 #endif /* IRI_H */