okra | C99 URI parser library. |
| download: http://git.y1.nz/archives/okra.tar.gz | |
| README | Files | Log | Refs |
okra.h
1 #ifndef OKRA_OKRA_H_
2 #define OKRA_OKRA_H_
3
4 /**
5 * A convenient API for accessing the internal structure of a URI.
6 * All char * members can be NULL. All member data is read-only and
7 * owned by the Okra library.
8 */
9 typedef struct {
10 /** The URI, recomposed after parsing, stored in a fresh buffer. */
11 char *uri;
12
13 /** The scheme component of the URI according to section 3.1. */
14 char *scheme;
15
16 /** The authority component of the URI according to section 3.2. */
17 char *authority;
18
19 // TODO decide whether/how to include substructure like this
20 char *host;
21 char *userinfo;
22 char *port;
23
24 /** The path component of the URI according to section 3.3. */
25 char *path;
26 // TODO vector of path segments?
27
28 /** The path component of the URI according to section 3.4. */
29 char *query;
30
31 /** The path component of the URI according to section 3.5. */
32 char *fragment;
33 } OkraUri;
34
35 /**
36 * Parse a string into an OkraUri struct. Returns NULL if the input
37 * is not a valid URI. The returned data should be considered read-only and must
38 * be freed using okra_free().
39 */
40 OkraUri *okra_parse(const char *input);
41
42 /**
43 * Resolve a relative URI according to some base uri. Both arguments
44 * must be non-NULL. The returned data is independent of the
45 * arguments and must be freed using okra_free.
46 */
47 OkraUri *okra_merge(const OkraUri *base, const OkraUri *ref);
48
49 /**
50 * Returns a fresh string buffer containing the uri expressed
51 * as a string. The buffer is owned by the caller.
52 */
53 char *okra_recompose(OkraUri *uri);
54
55 /**
56 * Free all memory associated with an OkraUri.
57 */
58 void okra_free(OkraUri *uri);
59
60 #endif // OKRA_OKRA_H_
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.