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