diff options
Diffstat (limited to 'src/include/gnunet_uri_lib.h')
-rw-r--r-- | src/include/gnunet_uri_lib.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/include/gnunet_uri_lib.h b/src/include/gnunet_uri_lib.h new file mode 100644 index 000000000..86c9c54f4 --- /dev/null +++ b/src/include/gnunet_uri_lib.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2020 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file include/gnunet_uri_lib.h | ||
22 | * @brief generic parser for URIs | ||
23 | * @author Jonathan Buchanan | ||
24 | */ | ||
25 | |||
26 | #ifndef GNUNET_URI_LIB_H | ||
27 | #define GNUNET_URI_LIB_H | ||
28 | |||
29 | /** | ||
30 | * A Universal Resource Identifier (URI). | ||
31 | */ | ||
32 | struct GNUNET_Uri | ||
33 | { | ||
34 | /** | ||
35 | * The scheme of the uri. | ||
36 | */ | ||
37 | char *scheme; | ||
38 | |||
39 | |||
40 | /** | ||
41 | * The authority of the uri. If not present in the uri, NULL. | ||
42 | */ | ||
43 | char *authority; | ||
44 | |||
45 | |||
46 | /** | ||
47 | * The list of path segments in the URI. Note that if the path ends with a | ||
48 | * '/', then this array will end with an empty string to indicate the empty | ||
49 | * segment following the '/'. | ||
50 | */ | ||
51 | char **path_segments; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * The length of @e path_segments. | ||
56 | */ | ||
57 | unsigned int path_segments_count; | ||
58 | |||
59 | |||
60 | /** | ||
61 | * The query of the uri. If not present in the uri, NULL. | ||
62 | */ | ||
63 | const char *query; | ||
64 | |||
65 | |||
66 | /** | ||
67 | * The fragment of the uri. If not present in the uri, NULL. | ||
68 | */ | ||
69 | char *fragment; | ||
70 | }; | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Parse a URI from a string into an internal representation. | ||
75 | * | ||
76 | * @param uri string to parse | ||
77 | * @param emsg where to store the parser error message (if any) | ||
78 | * @return handle to the internal representation of the URI, or NULL on error | ||
79 | */ | ||
80 | struct GNUNET_Uri * | ||
81 | GNUNET_uri_parse (const char *uri, | ||
82 | char **emsg); | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Free URI. | ||
87 | * | ||
88 | * @param uri uri to free | ||
89 | */ | ||
90 | void | ||
91 | GNUNET_uri_destroy (struct GNUNET_Uri *uri); | ||
92 | |||
93 | |||
94 | #endif /* GNUNET_URI_LIB_H */ | ||
95 | |||
96 | /* end of include/gnunet_uri_lib.h */ | ||