VirtualBox

source: vbox/trunk/include/iprt/uri.h@ 57720

最後變更 在這個檔案從57720是 57720,由 vboxsync 提交於 10 年 前

RTUri: Preps for parsing the authority bits into smaller pieces for cURL proxy config.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.0 KB
 
1/** @file
2 * IPRT - Uniform Resource Identifier handling.
3 */
4
5/*
6 * Copyright (C) 2011-2015 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.alldomusa.eu.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_uri_h
27#define ___iprt_uri_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32RT_C_DECLS_BEGIN
33
34/** @defgroup grp_rt_uri RTUri - Uri parsing and creation
35 * URI parsing and creation based on RFC 3986.
36 * See http://datatracker.ietf.org/doc/rfc3986/ for the full specification.
37 * @note Currently it isn't the full specification implemented.
38 * @note Currently only some generic URI support and a minimum File(file:) URI
39 * support is implemented. Other specific scheme support, like html:, ldap:,
40 * data:, ..., is missing.
41 * @see grp_rt_uri_file
42 * @ingroup grp_rt
43 * @{
44 */
45
46/**
47 * Creates a generic URI. The returned pointer must be freed
48 * using RTStrFree().
49 *
50 * @returns the new URI on success, NULL otherwise.
51 * @param pszScheme The URI scheme.
52 * @param pszAuthority The authority part of the URI (optional).
53 * @param pszPath The path part of the URI (optional).
54 * @param pszQuery The query part of the URI (optional).
55 * @param pszFragment The fragment part of the URI (optional).
56 */
57RTR3DECL(char *) RTUriCreate(const char *pszScheme, const char *pszAuthority, const char *pszPath, const char *pszQuery,
58 const char *pszFragment);
59
60/**
61 * Check an string for a specific URI scheme.
62 *
63 * @returns true if the scheme match, false if not.
64 * @param pszUri The URI to check.
65 * @param pszScheme The scheme to compare with.
66 */
67RTR3DECL(bool) RTUriHasScheme(const char *pszUri, const char *pszScheme);
68
69/**
70 * Extract the scheme out of an URI.
71 *
72 * @returns the scheme if the URI is valid, NULL otherwise.
73 * @param pszUri The URI to extract from.
74 */
75RTR3DECL(char *) RTUriScheme(const char *pszUri);
76
77/**
78 * Extract the authority out of an URI.
79 *
80 * @returns the authority if the URI contains one, NULL otherwise.
81 * @param pszUri The URI to extract from.
82 * @remarks The authority can have a zero length.
83 */
84RTR3DECL(char *) RTUriAuthority(const char *pszUri);
85
86/**
87 * Extract the username out of the authority component in an URI.
88 *
89 * @returns The username if the URI contains one, otherwise NULL.
90 * @param pszUri The URI to extract from.
91 */
92RTR3DECL(char *) RTUriAuthorityUsername(const char *pszUri);
93
94/**
95 * Extract the password out of the authority component in an URI.
96 *
97 * @returns The password if the URI contains one, otherwise NULL.
98 * @param pszUri The URI to extract from.
99 */
100RTR3DECL(char *) RTUriAuthorityPassword(const char *pszUri);
101
102/**
103 * Extract the port number out of the authority component in an URI.
104 *
105 * @returns The port number if the URI contains one, otherwise UINT32_MAX.
106 * @param pszUri The URI to extract from.
107 */
108RTR3DECL(uint32_t) RTUriAuthorityPort(const char *pszUri);
109
110/**
111 * Extract the path out of an URI.
112 *
113 * @returns the path if the URI contains one, NULL otherwise.
114 * @param pszUri The URI to extract from.
115 */
116RTR3DECL(char *) RTUriPath(const char *pszUri);
117
118/**
119 * Extract the query out of an URI.
120 *
121 * @returns the query if the URI contains one, NULL otherwise.
122 * @param pszUri The URI to extract from.
123 */
124RTR3DECL(char *) RTUriQuery(const char *pszUri);
125
126/**
127 * Extract the fragment out of an URI.
128 *
129 * @returns the fragment if the URI contains one, NULL otherwise.
130 * @param pszUri The URI to extract from.
131 */
132RTR3DECL(char *) RTUriFragment(const char *pszUri);
133
134/** @defgroup grp_rt_uri_file RTUriFile - Uri file parsing and creation
135 * Adds file: scheme support to the generic RTUri interface. This is partly
136 * documented in http://datatracker.ietf.org/doc/rfc1738/.
137 * @{
138 */
139
140/** Auto detect in which format a path is returned. */
141#define URI_FILE_FORMAT_AUTO UINT32_C(0)
142/** Return a path in UNIX format style. */
143#define URI_FILE_FORMAT_UNIX UINT32_C(1)
144/** Return a path in Windows format style. */
145#define URI_FILE_FORMAT_WIN UINT32_C(2)
146
147/**
148 * Creates a file URI.
149 *
150 * The returned pointer must be freed using RTStrFree().
151 *
152 * @see RTUriCreate
153 *
154 * @returns The new URI on success, NULL otherwise. Free With RTStrFree.
155 * @param pszPath The path of the URI.
156 */
157RTR3DECL(char *) RTUriFileCreate(const char *pszPath);
158
159/**
160 * Returns the file path encoded in the URI.
161 *
162 * @returns the path if the URI contains one, NULL otherwise.
163 * @param pszUri The URI to extract from.
164 * @param uFormat In which format should the path returned.
165 */
166RTR3DECL(char *) RTUriFilePath(const char *pszUri, uint32_t uFormat);
167
168/**
169 * Returns the file path encoded in the URI, given a max string length.
170 *
171 * @returns the path if the URI contains one, NULL otherwise.
172 * @param pszUri The URI to extract from.
173 * @param uFormat In which format should the path returned.
174 * @param cbMax The max string length to inspect.
175 */
176RTR3DECL(char *) RTUriFileNPath(const char *pszUri, uint32_t uFormat, size_t cchMax);
177
178/** @} */
179
180/** @} */
181
182RT_C_DECLS_END
183
184#endif
185
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette