From c3dce46c5f7cad6bc3cc91cc2c711ac089f25923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Fri, 8 May 2026 11:53:45 +0200 Subject: New upstream version 1.0.1+dfsg --- include/uriparser/COPYING | 36 + include/uriparser/Uri.h | 1685 ++++++++++++++++++++++++++++++------ include/uriparser/UriBase.h | 339 ++++---- include/uriparser/UriDefsAnsi.h | 10 +- include/uriparser/UriDefsConfig.h | 64 +- include/uriparser/UriDefsUnicode.h | 10 +- include/uriparser/UriIp4.h | 87 +- 7 files changed, 1717 insertions(+), 514 deletions(-) create mode 100644 include/uriparser/COPYING (limited to 'include') diff --git a/include/uriparser/COPYING b/include/uriparser/COPYING new file mode 100644 index 0000000..261c741 --- /dev/null +++ b/include/uriparser/COPYING @@ -0,0 +1,36 @@ +uriparser - RFC 3986 URI parsing library + +Copyright (C) 2007, Weijia Song +Copyright (C) 2007, Sebastian Pipping +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + + 2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/include/uriparser/Uri.h b/include/uriparser/Uri.h index b80ac6c..f041f81 100644 --- a/include/uriparser/Uri.h +++ b/include/uriparser/Uri.h @@ -1,4 +1,4 @@ -/* e8e2c75d033ddfe256fe87c3fd5a330a6f2c9cbb376ebd83a1b3263e804c766a (0.9.8+) +/* 53c1cb9f2f728652fe001dc72fa0fa7a0e9fa0b8baaaa9e37561c6cdf88ac4df (1.0.1+) * * uriparser - RFC 3986 URI parsing library * @@ -45,47 +45,41 @@ */ #if (defined(URI_PASS_ANSI) && !defined(URI_H_ANSI)) \ - || (defined(URI_PASS_UNICODE) && !defined(URI_H_UNICODE)) \ - || (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) + || (defined(URI_PASS_UNICODE) && !defined(URI_H_UNICODE)) \ + || (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) /* What encodings are enabled? */ -#include "UriDefsConfig.h" -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) +# include "UriDefsConfig.h" +# if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) /* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "Uri.h" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "Uri.h" -# undef URI_PASS_UNICODE -# endif +# ifdef URI_ENABLE_ANSI +# define URI_PASS_ANSI 1 +# include "Uri.h" +# undef URI_PASS_ANSI +# endif +# ifdef URI_ENABLE_UNICODE +# define URI_PASS_UNICODE 1 +# include "Uri.h" +# undef URI_PASS_UNICODE +# endif /* Only one pass for each encoding */ -#elif (defined(URI_PASS_ANSI) && !defined(URI_H_ANSI) \ - && defined(URI_ENABLE_ANSI)) || (defined(URI_PASS_UNICODE) \ - && !defined(URI_H_UNICODE) && defined(URI_ENABLE_UNICODE)) -# ifdef URI_PASS_ANSI -# define URI_H_ANSI 1 -# include "UriDefsAnsi.h" -# else -# define URI_H_UNICODE 1 -# include "UriDefsUnicode.h" -# endif - - - -#ifdef __cplusplus +# elif (defined(URI_PASS_ANSI) && !defined(URI_H_ANSI) && defined(URI_ENABLE_ANSI)) \ + || (defined(URI_PASS_UNICODE) && !defined(URI_H_UNICODE) \ + && defined(URI_ENABLE_UNICODE)) +# ifdef URI_PASS_ANSI +# define URI_H_ANSI 1 +# include "UriDefsAnsi.h" +# else +# define URI_H_UNICODE 1 +# include "UriDefsUnicode.h" +# endif + +# ifdef __cplusplus extern "C" { -#endif - - - -#ifndef URI_DOXYGEN -# include "UriBase.h" -#endif - +# endif +# ifndef URI_DOXYGEN +# include "UriBase.h" +# endif /** * Specifies a range of characters within a string. @@ -99,12 +93,10 @@ extern "C" { * @since 0.3.0 */ typedef struct URI_TYPE(TextRangeStruct) { - const URI_CHAR * first; /**< Pointer to first character */ - const URI_CHAR * afterLast; /**< Pointer to character after the last one still in */ + const URI_CHAR * first; /**< Pointer to first character */ + const URI_CHAR * afterLast; /**< Pointer to character after the last one still in */ } URI_TYPE(TextRange); /**< @copydoc UriTextRangeStructA */ - - /** * Represents a path segment within a %URI path. * More precisely it is a node in a linked @@ -114,14 +106,13 @@ typedef struct URI_TYPE(TextRangeStruct) { * @since 0.3.0 */ typedef struct URI_TYPE(PathSegmentStruct) { - URI_TYPE(TextRange) text; /**< Path segment name */ - struct URI_TYPE(PathSegmentStruct) * next; /**< Pointer to the next path segment in the list, can be NULL if last already */ + URI_TYPE(TextRange) text; /**< Path segment name */ + struct URI_TYPE(PathSegmentStruct) * next; /**< Pointer to the next path segment in + the list, can be NULL if last already */ - void * reserved; /**< Reserved to the parser */ + void * reserved; /**< Reserved to the parser */ } URI_TYPE(PathSegment); /**< @copydoc UriPathSegmentStructA */ - - /** * Holds structured host information. * This is either a IPv4, IPv6, plain @@ -132,13 +123,16 @@ typedef struct URI_TYPE(PathSegmentStruct) { * @since 0.3.0 */ typedef struct URI_TYPE(HostDataStruct) { - UriIp4 * ip4; /**< IPv4 address */ - UriIp6 * ip6; /**< IPv6 address */ - URI_TYPE(TextRange) ipFuture; /**< IPvFuture address */ + UriIp4 * ip4; /**< IPv4 address */ + UriIp6 * ip6; /**< IPv6 address */ + URI_TYPE(TextRange) + ipFuture; /**< IPvFuture address +@note +With non-NULL members in UriUriStructA.hostData context, +this text range's pointers must be identical to those +of UriUriStructA.hostText at all times. */ } URI_TYPE(HostData); /**< @copydoc UriHostDataStructA */ - - /** * Represents an RFC 3986 %URI. * Missing components can be {NULL, NULL} ranges. @@ -149,24 +143,23 @@ typedef struct URI_TYPE(HostDataStruct) { * @since 0.3.0 */ typedef struct URI_TYPE(UriStruct) { - URI_TYPE(TextRange) scheme; /**< Scheme (e.g. "http") */ - URI_TYPE(TextRange) userInfo; /**< User info (e.g. "user:pass") */ - URI_TYPE(TextRange) hostText; /**< Host text (set for all hosts, excluding square brackets) */ - URI_TYPE(HostData) hostData; /**< Structured host type specific data */ - URI_TYPE(TextRange) portText; /**< Port (e.g. "80") */ - URI_TYPE(PathSegment) * pathHead; /**< Head of a linked list of path segments */ - URI_TYPE(PathSegment) * pathTail; /**< Tail of the list behind pathHead */ - URI_TYPE(TextRange) query; /**< Query without leading "?" */ - URI_TYPE(TextRange) fragment; /**< Query without leading "#" */ - UriBool absolutePath; /**< Absolute path flag, distincting "a" and "/a"; - always URI_FALSE for URIs with host */ - UriBool owner; /**< Memory owner flag */ - - void * reserved; /**< Reserved to the parser */ + URI_TYPE(TextRange) scheme; /**< Scheme (e.g. "http") */ + URI_TYPE(TextRange) userInfo; /**< User info (e.g. "user:pass") */ + URI_TYPE(TextRange) + hostText; /**< Host text (set for all hosts, excluding square brackets) */ + URI_TYPE(HostData) hostData; /**< Structured host type specific data */ + URI_TYPE(TextRange) portText; /**< Port (e.g. "80") */ + URI_TYPE(PathSegment) * pathHead; /**< Head of a linked list of path segments */ + URI_TYPE(PathSegment) * pathTail; /**< Tail of the list behind pathHead */ + URI_TYPE(TextRange) query; /**< Query without leading "?" */ + URI_TYPE(TextRange) fragment; /**< Query without leading "#" */ + UriBool absolutePath; /**< Absolute path flag, distincting "a" and "/a"; always + URI_FALSE for URIs with host */ + UriBool owner; /**< Memory owner flag */ + + void * reserved; /**< Reserved to the parser */ } URI_TYPE(Uri); /**< @copydoc UriUriStructA */ - - /** * Represents a state of the %URI parser. * Missing components can be NULL to reflect @@ -177,15 +170,14 @@ typedef struct URI_TYPE(UriStruct) { * @since 0.3.0 */ typedef struct URI_TYPE(ParserStateStruct) { - URI_TYPE(Uri) * uri; /**< Plug in the %URI structure to be filled while parsing here */ - int errorCode; /**< Code identifying the error which occurred */ - const URI_CHAR * errorPos; /**< Pointer to position in case of a syntax error */ + URI_TYPE(Uri) + *uri; /**< Plug in the %URI structure to be filled while parsing here */ + int errorCode; /**< Code identifying the error which occurred */ + const URI_CHAR * errorPos; /**< Pointer to position in case of a syntax error */ - void * reserved; /**< Reserved to the parser */ + void * reserved; /**< Reserved to the parser */ } URI_TYPE(ParserState); /**< @copydoc UriParserStateStructA */ - - /** * Represents a query element. * More precisely it is a node in a linked @@ -194,13 +186,58 @@ typedef struct URI_TYPE(ParserStateStruct) { * @since 0.7.0 */ typedef struct URI_TYPE(QueryListStruct) { - const URI_CHAR * key; /**< Key of the query element */ - const URI_CHAR * value; /**< Value of the query element, can be NULL */ + const URI_CHAR * key; /**< Key of the query element */ + const URI_CHAR * value; /**< Value of the query element, can be NULL */ - struct URI_TYPE(QueryListStruct) * next; /**< Pointer to the next key/value pair in the list, can be NULL if last already */ + struct URI_TYPE(QueryListStruct) * next; /**< Pointer to the next key/value pair in + the list, can be NULL if last already */ } URI_TYPE(QueryList); /**< @copydoc UriQueryListStructA */ +/** + * Checks if a URI has the host component set. + * + * @param uri IN: %URI to check + * @return URI_TRUE when host is set, URI_FALSE otherwise + * + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(HasHost)(const URI_TYPE(Uri) * uri); +/** + * Converts an IPv6 text representation into 16 bytes. + * + * Uses default libc-based memory manager. + * + * @param output OUT: Output destination, can be NULL + * @param first IN: First character of IPv6 text to parse + * @param afterLast IN: Position to stop parsing at + * @return Error code or URI_SUCCESS on success + * + * @see uriParseIpFourAddressA + * @see uriParseIpSixAddressMmA + * @see uriIsWellFormedHostIp6A + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(ParseIpSixAddress)(UriIp6 * output, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Converts an IPv6 text representation into 16 bytes. + * + * @param output OUT: Output destination, can be NULL + * @param first IN: First character of IPv6 text to parse + * @param afterLast IN: Position to stop parsing at + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or URI_SUCCESS on success + * + * @see uriParseIpFourAddressA + * @see uriParseIpSixAddressA + * @see uriIsWellFormedHostIp6MmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(ParseIpSixAddressMm)(UriIp6 * output, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); /** * Parses a RFC 3986 %URI. @@ -208,7 +245,8 @@ typedef struct URI_TYPE(QueryListStruct) { * * @param state INOUT: Parser state with set output %URI, must not be NULL * @param first IN: Pointer to the first character to parse, must not be NULL - * @param afterLast IN: Pointer to the character after the last to parse, must not be NULL + * @param afterLast IN: Pointer to the character after the last to parse, must + * not be NULL * @return 0 on success, error code otherwise * * @see uriParseUriA @@ -216,12 +254,11 @@ typedef struct URI_TYPE(QueryListStruct) { * @see uriParseSingleUriExA * @see uriToStringA * @since 0.3.0 - * @deprecated Deprecated since 0.9.0, please migrate to uriParseSingleUriExA (with "Single"). + * @deprecated Deprecated since 0.9.0, please migrate to uriParseSingleUriExA (with + * "Single"). */ -URI_PUBLIC int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, const URI_CHAR * afterLast); - - +URI_PUBLIC int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, const URI_CHAR * first, + const URI_CHAR * afterLast); /** * Parses a RFC 3986 %URI. @@ -236,12 +273,10 @@ URI_PUBLIC int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, * @see uriParseSingleUriExA * @see uriToStringA * @since 0.3.0 - * @deprecated Deprecated since 0.9.0, please migrate to uriParseSingleUriA (with "Single"). + * @deprecated Deprecated since 0.9.0, please migrate to uriParseSingleUriA (with + * "Single"). */ -URI_PUBLIC int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, - const URI_CHAR * text); - - +URI_PUBLIC int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text); /** * Parses a single RFC 3986 %URI. @@ -260,10 +295,8 @@ URI_PUBLIC int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, * @see uriToStringA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, - const URI_CHAR * text, const URI_CHAR ** errorPos); - - +URI_PUBLIC int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, const URI_CHAR * text, + const URI_CHAR ** errorPos); /** * Parses a single RFC 3986 %URI. @@ -285,11 +318,9 @@ URI_PUBLIC int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, * @see uriToStringA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, - const URI_CHAR * first, const URI_CHAR * afterLast, - const URI_CHAR ** errorPos); - - +URI_PUBLIC int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + const URI_CHAR ** errorPos); /** * Parses a single RFC 3986 %URI. @@ -311,11 +342,10 @@ URI_PUBLIC int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, * @see uriToStringA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, - const URI_CHAR * first, const URI_CHAR * afterLast, - const URI_CHAR ** errorPos, UriMemoryManager * memory); - - +URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + const URI_CHAR ** errorPos, + UriMemoryManager * memory); /** * Frees all memory associated with the members @@ -323,6 +353,10 @@ URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, * itself is not freed, only its members. * Uses default libc-based memory manager. * + * @remarks + * Calling on an all-zeros structure (e.g. through memset or calloc) is + * safe.
Calling on an uninitialized structure is not safe. + * * @param uri INOUT: %URI structure whose members should be freed * * @see uriFreeUriMembersMmA @@ -330,13 +364,15 @@ URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, */ URI_PUBLIC void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); - - /** * Frees all memory associated with the members * of the %URI structure. Note that the structure * itself is not freed, only its members. * + * @remarks + * Calling on an all-zeros structure (e.g. through memset or calloc) is + * safe.
Calling on an uninitialized structure is not safe. + * * @param uri INOUT: %URI structure whose members should be freed * @param memory IN: Memory manager to use, NULL for default libc * @return 0 on success, error code otherwise @@ -344,13 +380,10 @@ URI_PUBLIC void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); * @see uriFreeUriMembersA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory); - - +URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory); /** - * Percent-encodes all unreserved characters from the input string and + * Percent-encodes all but unreserved characters from the input string and * writes the encoded version to the output string. * * NOTE: Be sure to allocate 3 times the space of the input buffer for @@ -378,13 +411,11 @@ URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, * @since 0.5.2 */ URI_PUBLIC URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, - const URI_CHAR * inAfterLast, URI_CHAR * out, - UriBool spaceToPlus, UriBool normalizeBreaks); - - + const URI_CHAR * inAfterLast, URI_CHAR * out, + UriBool spaceToPlus, UriBool normalizeBreaks); /** - * Percent-encodes all unreserved characters from the input string and + * Percent-encodes all but unreserved characters from the input string and * writes the encoded version to the output string. * * NOTE: Be sure to allocate 3 times the space of the input buffer for @@ -411,9 +442,7 @@ URI_PUBLIC URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, * @since 0.5.0 */ URI_PUBLIC URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, - UriBool spaceToPlus, UriBool normalizeBreaks); - - + UriBool spaceToPlus, UriBool normalizeBreaks); /** * Unescapes percent-encoded groups in a given string. @@ -432,10 +461,9 @@ URI_PUBLIC URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, * @see uriEscapeExA * @since 0.5.0 */ -URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, - UriBool plusToSpace, UriBreakConversion breakConversion); - - +URI_PUBLIC const URI_CHAR * + URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, UriBool plusToSpace, + UriBreakConversion breakConversion); /** * Unescapes percent-encoded groups in a given string. @@ -457,13 +485,11 @@ URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, */ URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlace)(URI_CHAR * inout); - - /** * Performs reference resolution as described in - * section 5.2.2 of RFC 3986. - * Uses default libc-based memory manager. - * NOTE: On success you have to call uriFreeUriMembersA on \p absoluteDest manually later. + * section 5.2.2 of + * RFC 3986. Uses default libc-based memory manager. NOTE: On success you have to call + * uriFreeUriMembersA on \p absoluteDest manually later. * * @param absoluteDest OUT: Result %URI * @param relativeSource IN: Reference to resolve @@ -477,16 +503,14 @@ URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlace)(URI_CHAR * inout); * @since 0.4.0 */ URI_PUBLIC int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest, - const URI_TYPE(Uri) * relativeSource, - const URI_TYPE(Uri) * absoluteBase); - - + const URI_TYPE(Uri) * relativeSource, + const URI_TYPE(Uri) * absoluteBase); /** * Performs reference resolution as described in - * section 5.2.2 of RFC 3986. - * Uses default libc-based memory manager. - * NOTE: On success you have to call uriFreeUriMembersA on \p absoluteDest manually later. + * section 5.2.2 of + * RFC 3986. Uses default libc-based memory manager. NOTE: On success you have to call + * uriFreeUriMembersA on \p absoluteDest manually later. * * @param absoluteDest OUT: Result %URI * @param relativeSource IN: Reference to resolve @@ -500,16 +524,15 @@ URI_PUBLIC int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest, * @since 0.8.1 */ URI_PUBLIC int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absoluteDest, - const URI_TYPE(Uri) * relativeSource, - const URI_TYPE(Uri) * absoluteBase, - UriResolutionOptions options); - - + const URI_TYPE(Uri) * relativeSource, + const URI_TYPE(Uri) * absoluteBase, + UriResolutionOptions options); /** * Performs reference resolution as described in - * section 5.2.2 of RFC 3986. - * NOTE: On success you have to call uriFreeUriMembersMmA on \p absoluteDest manually later. + * section 5.2.2 of + * RFC 3986. NOTE: On success you have to call uriFreeUriMembersMmA on \p absoluteDest + * manually later. * * @param absoluteDest OUT: Result %URI * @param relativeSource IN: Reference to resolve @@ -525,11 +548,10 @@ URI_PUBLIC int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absoluteDest, * @since 0.9.0 */ URI_PUBLIC int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absoluteDest, - const URI_TYPE(Uri) * relativeSource, - const URI_TYPE(Uri) * absoluteBase, - UriResolutionOptions options, UriMemoryManager * memory); - - + const URI_TYPE(Uri) * relativeSource, + const URI_TYPE(Uri) * absoluteBase, + UriResolutionOptions options, + UriMemoryManager * memory); /** * Tries to make a relative %URI (a reference) from an @@ -554,11 +576,9 @@ URI_PUBLIC int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absoluteDest, * @since 0.5.2 */ URI_PUBLIC int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * absoluteSource, - const URI_TYPE(Uri) * absoluteBase, - UriBool domainRootMode); - - + const URI_TYPE(Uri) * absoluteSource, + const URI_TYPE(Uri) * absoluteBase, + UriBool domainRootMode); /** * Tries to make a relative %URI (a reference) from an @@ -583,11 +603,10 @@ URI_PUBLIC int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, * @since 0.9.0 */ URI_PUBLIC int URI_FUNC(RemoveBaseUriMm)(URI_TYPE(Uri) * dest, - const URI_TYPE(Uri) * absoluteSource, - const URI_TYPE(Uri) * absoluteBase, - UriBool domainRootMode, UriMemoryManager * memory); - - + const URI_TYPE(Uri) * absoluteSource, + const URI_TYPE(Uri) * absoluteBase, + UriBool domainRootMode, + UriMemoryManager * memory); /** * Checks two URIs for equivalence. Comparison is done @@ -600,10 +619,7 @@ URI_PUBLIC int URI_FUNC(RemoveBaseUriMm)(URI_TYPE(Uri) * dest, * * @since 0.4.0 */ -URI_PUBLIC UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, - const URI_TYPE(Uri) * b); - - +URI_PUBLIC UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, const URI_TYPE(Uri) * b); /** * Calculates the number of characters needed to store the @@ -611,38 +627,67 @@ URI_PUBLIC UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, * terminator. * * @param uri IN: %URI to measure - * @param charsRequired OUT: Length of the string representation in characters excluding terminator + * @param charsRequired OUT: Length of the string representation in characters + * excluding terminator * @return Error code or 0 on success * * @see uriToStringA * @since 0.5.0 */ URI_PUBLIC int URI_FUNC(ToStringCharsRequired)(const URI_TYPE(Uri) * uri, - int * charsRequired); - - + int * charsRequired); /** * Converts a %URI structure back to text as described in - * section 5.3 of RFC 3986. + * section 5.3 of RFC + * 3986. * * NOTE: Scheme-based normalization - * (section 6.2.3 of RFC 3986) - * is not applied and is considered a responsibility of the application using uriparser. + * (section 6.2.3 of + * RFC 3986) is not applied and is considered a responsibility of the application + * using uriparser. * * @param dest OUT: Output destination * @param uri IN: %URI to convert - * @param maxChars IN: Maximum number of characters to copy including terminator - * @param charsWritten OUT: Number of characters written, can be lower than maxChars even if the %URI is too long! + * @param maxChars IN: Maximum number of characters to copy including + * terminator + * @param charsWritten OUT: Number of characters written, can be lower than + * maxChars even if the %URI is too long! * @return Error code or 0 on success * * @see uriToStringCharsRequiredA * @since 0.4.0 */ URI_PUBLIC int URI_FUNC(ToString)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, - int maxChars, int * charsWritten); + int maxChars, int * charsWritten); +/** + * Copies a %URI structure. + * + * @param destUri OUT: Output destination + * @param sourceUri IN: %URI to copy + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriCopyUriA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(CopyUriMm)(URI_TYPE(Uri) * destUri, + const URI_TYPE(Uri) * sourceUri, + UriMemoryManager * memory); +/** + * Copies a %URI structure. + * + * @param destUri OUT: Output destination + * @param sourceUri IN: %URI to copy + * @return Error code or 0 on success + * + * @see uriCopyUriMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(CopyUri)(URI_TYPE(Uri) * destUri, + const URI_TYPE(Uri) * sourceUri); /** * Determines the components of a %URI that are not normalized. @@ -655,12 +700,10 @@ URI_PUBLIC int URI_FUNC(ToString)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, * @see uriNormalizeSyntaxExMmA * @see uriNormalizeSyntaxMaskRequiredExA * @since 0.5.0 - * @deprecated Deprecated since 0.9.0, please migrate to uriNormalizeSyntaxMaskRequiredExA (with "Ex"). + * @deprecated Deprecated since 0.9.0, please migrate to uriNormalizeSyntaxMaskRequiredExA + * (with "Ex"). */ -URI_PUBLIC unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)( - const URI_TYPE(Uri) * uri); - - +URI_PUBLIC unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)(const URI_TYPE(Uri) * uri); /** * Determines the components of a %URI that are not normalized. @@ -675,10 +718,8 @@ URI_PUBLIC unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)( * @see uriNormalizeSyntaxMaskRequiredA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxMaskRequiredEx)( - const URI_TYPE(Uri) * uri, unsigned int * outMask); - - +URI_PUBLIC int URI_FUNC(NormalizeSyntaxMaskRequiredEx)(const URI_TYPE(Uri) * uri, + unsigned int * outMask); /** * Normalizes a %URI using a normalization mask. @@ -697,10 +738,7 @@ URI_PUBLIC int URI_FUNC(NormalizeSyntaxMaskRequiredEx)( * @see uriNormalizeSyntaxMaskRequiredA * @since 0.5.0 */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, - unsigned int mask); - - +URI_PUBLIC int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, unsigned int mask); /** * Normalizes a %URI using a normalization mask. @@ -719,10 +757,8 @@ URI_PUBLIC int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, * @see uriNormalizeSyntaxMaskRequiredA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxExMm)(URI_TYPE(Uri) * uri, - unsigned int mask, UriMemoryManager * memory); - - +URI_PUBLIC int URI_FUNC(NormalizeSyntaxExMm)(URI_TYPE(Uri) * uri, unsigned int mask, + UriMemoryManager * memory); /** * Normalizes all components of a %URI. @@ -741,8 +777,6 @@ URI_PUBLIC int URI_FUNC(NormalizeSyntaxExMm)(URI_TYPE(Uri) * uri, */ URI_PUBLIC int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); - - /** * Converts a Unix filename to a %URI string. * The destination buffer must be large enough to hold 7 + 3 * len(filename) + 1 @@ -762,9 +796,7 @@ URI_PUBLIC int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); * @since 0.5.2 */ URI_PUBLIC int URI_FUNC(UnixFilenameToUriString)(const URI_CHAR * filename, - URI_CHAR * uriString); - - + URI_CHAR * uriString); /** * Converts a Windows filename to a %URI string. @@ -785,9 +817,7 @@ URI_PUBLIC int URI_FUNC(UnixFilenameToUriString)(const URI_CHAR * filename, * @since 0.5.2 */ URI_PUBLIC int URI_FUNC(WindowsFilenameToUriString)(const URI_CHAR * filename, - URI_CHAR * uriString); - - + URI_CHAR * uriString); /** * Extracts a Unix filename from a %URI string. @@ -804,9 +834,7 @@ URI_PUBLIC int URI_FUNC(WindowsFilenameToUriString)(const URI_CHAR * filename, * @since 0.5.2 */ URI_PUBLIC int URI_FUNC(UriStringToUnixFilename)(const URI_CHAR * uriString, - URI_CHAR * filename); - - + URI_CHAR * filename); /** * Extracts a Windows filename from a %URI string. @@ -823,9 +851,7 @@ URI_PUBLIC int URI_FUNC(UriStringToUnixFilename)(const URI_CHAR * uriString, * @since 0.5.2 */ URI_PUBLIC int URI_FUNC(UriStringToWindowsFilename)(const URI_CHAR * uriString, - URI_CHAR * filename); - - + URI_CHAR * filename); /** * Calculates the number of characters needed to store the @@ -834,17 +860,16 @@ URI_PUBLIC int URI_FUNC(UriStringToWindowsFilename)(const URI_CHAR * uriString, * normalized to "%0D%0A". * * @param queryList IN: Query list to measure - * @param charsRequired OUT: Length of the string representation in characters excluding terminator + * @param charsRequired OUT: Length of the string representation in characters + * excluding terminator * @return Error code or 0 on success * * @see uriComposeQueryCharsRequiredExA * @see uriComposeQueryA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequired)( - const URI_TYPE(QueryList) * queryList, int * charsRequired); - - +URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequired)(const URI_TYPE(QueryList) * queryList, + int * charsRequired); /** * Calculates the number of characters needed to store the @@ -852,7 +877,8 @@ URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequired)( * terminator. * * @param queryList IN: Query list to measure - * @param charsRequired OUT: Length of the string representation in characters excluding terminator + * @param charsRequired OUT: Length of the string representation in characters + * excluding terminator * @param spaceToPlus IN: Whether to convert ' ' to '+' or not * @param normalizeBreaks IN: Whether to convert CR and LF to CR-LF or not. * @return Error code or 0 on success @@ -861,11 +887,10 @@ URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequired)( * @see uriComposeQueryExA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequiredEx)( - const URI_TYPE(QueryList) * queryList, - int * charsRequired, UriBool spaceToPlus, UriBool normalizeBreaks); - - +URI_PUBLIC int + URI_FUNC(ComposeQueryCharsRequiredEx)(const URI_TYPE(QueryList) * queryList, + int * charsRequired, UriBool spaceToPlus, + UriBool normalizeBreaks); /** * Converts a query list structure back to a query string. @@ -875,8 +900,10 @@ URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequiredEx)( * * @param dest OUT: Output destination * @param queryList IN: Query list to convert - * @param maxChars IN: Maximum number of characters to copy including terminator - * @param charsWritten OUT: Number of characters written, can be lower than maxChars even if the query list is too long! + * @param maxChars IN: Maximum number of characters to copy + * including terminator + * @param charsWritten OUT: Number of characters written, can be lower than + * maxChars even if the query list is too long! * @return Error code or 0 on success * * @see uriComposeQueryExA @@ -890,9 +917,8 @@ URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequiredEx)( * @since 0.7.0 */ URI_PUBLIC int URI_FUNC(ComposeQuery)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten); - - + const URI_TYPE(QueryList) * queryList, int maxChars, + int * charsWritten); /** * Converts a query list structure back to a query string. @@ -900,8 +926,10 @@ URI_PUBLIC int URI_FUNC(ComposeQuery)(URI_CHAR * dest, * * @param dest OUT: Output destination * @param queryList IN: Query list to convert - * @param maxChars IN: Maximum number of characters to copy including terminator - * @param charsWritten OUT: Number of characters written, can be lower than maxChars even if the query list is too long! + * @param maxChars IN: Maximum number of characters to copy + * including terminator + * @param charsWritten OUT: Number of characters written, can be lower than + * maxChars even if the query list is too long! * @param spaceToPlus IN: Whether to convert ' ' to '+' or not * @param normalizeBreaks IN: Whether to convert CR and LF to CR-LF or not. * @return Error code or 0 on success @@ -917,10 +945,9 @@ URI_PUBLIC int URI_FUNC(ComposeQuery)(URI_CHAR * dest, * @since 0.7.0 */ URI_PUBLIC int URI_FUNC(ComposeQueryEx)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten, - UriBool spaceToPlus, UriBool normalizeBreaks); - - + const URI_TYPE(QueryList) * queryList, + int maxChars, int * charsWritten, + UriBool spaceToPlus, UriBool normalizeBreaks); /** * Converts a query list structure back to a query string. @@ -943,9 +970,7 @@ URI_PUBLIC int URI_FUNC(ComposeQueryEx)(URI_CHAR * dest, * @since 0.7.0 */ URI_PUBLIC int URI_FUNC(ComposeQueryMalloc)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList); - - + const URI_TYPE(QueryList) * queryList); /** * Converts a query list structure back to a query string. @@ -968,10 +993,9 @@ URI_PUBLIC int URI_FUNC(ComposeQueryMalloc)(URI_CHAR ** dest, * @since 0.7.0 */ URI_PUBLIC int URI_FUNC(ComposeQueryMallocEx)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList, - UriBool spaceToPlus, UriBool normalizeBreaks); - - + const URI_TYPE(QueryList) * queryList, + UriBool spaceToPlus, + UriBool normalizeBreaks); /** * Converts a query list structure back to a query string. @@ -994,11 +1018,10 @@ URI_PUBLIC int URI_FUNC(ComposeQueryMallocEx)(URI_CHAR ** dest, * @since 0.9.0 */ URI_PUBLIC int URI_FUNC(ComposeQueryMallocExMm)(URI_CHAR ** dest, - const URI_TYPE(QueryList) * queryList, - UriBool spaceToPlus, UriBool normalizeBreaks, - UriMemoryManager * memory); - - + const URI_TYPE(QueryList) * queryList, + UriBool spaceToPlus, + UriBool normalizeBreaks, + UriMemoryManager * memory); /** * Constructs a query list from the raw query string of a given URI. @@ -1018,10 +1041,9 @@ URI_PUBLIC int URI_FUNC(ComposeQueryMallocExMm)(URI_CHAR ** dest, * @see uriFreeQueryListMmA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(DissectQueryMalloc)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast); - - +URI_PUBLIC int URI_FUNC(DissectQueryMalloc)(URI_TYPE(QueryList) * *dest, int * itemCount, + const URI_CHAR * first, + const URI_CHAR * afterLast); /** * Constructs a query list from the raw query string of a given URI. @@ -1041,11 +1063,11 @@ URI_PUBLIC int URI_FUNC(DissectQueryMalloc)(URI_TYPE(QueryList) ** dest, * @see uriFreeQueryListA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(DissectQueryMallocEx)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast, - UriBool plusToSpace, UriBreakConversion breakConversion); - - +URI_PUBLIC int URI_FUNC(DissectQueryMallocEx)(URI_TYPE(QueryList) * *dest, + int * itemCount, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriBool plusToSpace, + UriBreakConversion breakConversion); /** * Constructs a query list from the raw query string of a given URI. @@ -1066,12 +1088,12 @@ URI_PUBLIC int URI_FUNC(DissectQueryMallocEx)(URI_TYPE(QueryList) ** dest, * @see uriFreeQueryListMmA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(DissectQueryMallocExMm)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast, - UriBool plusToSpace, UriBreakConversion breakConversion, - UriMemoryManager * memory); - - +URI_PUBLIC int URI_FUNC(DissectQueryMallocExMm)(URI_TYPE(QueryList) * *dest, + int * itemCount, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriBool plusToSpace, + UriBreakConversion breakConversion, + UriMemoryManager * memory); /** * Frees all memory associated with the given query list. @@ -1084,8 +1106,6 @@ URI_PUBLIC int URI_FUNC(DissectQueryMallocExMm)(URI_TYPE(QueryList) ** dest, */ URI_PUBLIC void URI_FUNC(FreeQueryList)(URI_TYPE(QueryList) * queryList); - - /** * Frees all memory associated with the given query list. * The structure itself is freed as well. @@ -1098,9 +1118,7 @@ URI_PUBLIC void URI_FUNC(FreeQueryList)(URI_TYPE(QueryList) * queryList); * @since 0.9.0 */ URI_PUBLIC int URI_FUNC(FreeQueryListMm)(URI_TYPE(QueryList) * queryList, - UriMemoryManager * memory); - - + UriMemoryManager * memory); /** * Makes the %URI hold copies of strings so that it no longer depends @@ -1117,8 +1135,6 @@ URI_PUBLIC int URI_FUNC(FreeQueryListMm)(URI_TYPE(QueryList) * queryList, */ URI_PUBLIC int URI_FUNC(MakeOwner)(URI_TYPE(Uri) * uri); - - /** * Makes the %URI hold copies of strings so that it no longer depends * on the original %URI string. If the %URI is already owner of copies, @@ -1131,16 +1147,1163 @@ URI_PUBLIC int URI_FUNC(MakeOwner)(URI_TYPE(Uri) * uri); * @see uriMakeOwnerA * @since 0.9.4 */ -URI_PUBLIC int URI_FUNC(MakeOwnerMm)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory); +URI_PUBLIC int URI_FUNC(MakeOwnerMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory); +/** + * Determines if the given text range contains a well-formed fragment + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_TRUE if non-NULL and well-formed, else + * URI_FALSE + * + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetFragmentA + * @see uriSetFragmentMmA + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(IsWellFormedFragment)(const URI_CHAR * first, + const URI_CHAR * afterLast); +/** + * Determines if the given text range contains a well-formed IPv4 address + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_TRUE if non-NULL and well-formed, else + * URI_FALSE + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetHostIp4A + * @see uriSetHostIp4MmA + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(IsWellFormedHostIp4)(const URI_CHAR * first, + const URI_CHAR * afterLast); -#ifdef __cplusplus -} -#endif +/** + * Determines if the given text range contains a well-formed IPv6 address + * according to RFC 3986 or not. + * + * Uses default libc-based memory manager. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_SUCCESS if non-NULL and well-formed, else an error + * code + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6MmA + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriParseIpSixAddressA + * @see uriParseIpSixAddressMmA + * @since 0.9.9 + */ +int URI_FUNC(IsWellFormedHostIp6)(const URI_CHAR * first, const URI_CHAR * afterLast); +/** + * Determines if the given text range contains a well-formed IPv6 address + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @param memory IN: Memory manager to use, NULL for default libc + * @return URI_SUCCESS if non-NULL and well-formed, else an error + * code + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureMmA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @since 0.9.9 + */ +int URI_FUNC(IsWellFormedHostIp6Mm)(const URI_CHAR * first, const URI_CHAR * afterLast, + UriMemoryManager * memory); +/** + * Determines if the given text range contains a well-formed IPvFuture address + * according to RFC 3986 or not. + * + * Uses default libc-based memory manager. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_SUCCESS if non-NULL and well-formed, else an error + * code + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureMmA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetHostIpFutureA + * @see uriSetHostIpFutureMmA + * @since 0.9.9 + */ +int URI_FUNC(IsWellFormedHostIpFuture)(const URI_CHAR * first, + const URI_CHAR * afterLast); -#endif +/** + * Determines if the given text range contains a well-formed IPvFuture address + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @param memory IN: Memory manager to use, NULL for default libc + * @return URI_SUCCESS if non-NULL and well-formed, else an error + * code + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetHostIpFutureA + * @see uriSetHostIpFutureMmA + * @since 0.9.9 + */ +int URI_FUNC(IsWellFormedHostIpFutureMm)(const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Determines if the given text range contains a well-formed registered host name + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_TRUE if non-NULL and well-formed, else + * URI_FALSE + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetHostRegNameA + * @see uriSetHostRegNameMmA + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(IsWellFormedHostRegName)(const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Determines if the given text range contains a well-formed path + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @param hasHost IN: Whether the target %URI has a non-NULL host set or + * not + * @return URI_TRUE if non-NULL and well-formed, else + * URI_FALSE + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetPathA + * @see uriSetPathMmA + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(IsWellFormedPath)(const URI_CHAR * first, + const URI_CHAR * afterLast, + UriBool hasHost); + +/** + * Determines if the given text range contains a well-formed port text + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_TRUE if non-NULL and well-formed, else + * URI_FALSE + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetPortTextA + * @see uriSetPortTextMmA + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(IsWellFormedPort)(const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Determines if the given text range contains a well-formed query + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_TRUE if non-NULL and well-formed, else + * URI_FALSE + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetQueryA + * @see uriSetQueryMmA + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(IsWellFormedQuery)(const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Determines if the given text range contains a well-formed scheme + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_TRUE if non-NULL and well-formed, else + * URI_FALSE + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriIsWellFormedUserInfoA + * @see uriSetSchemeA + * @see uriSetSchemeMmA + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(IsWellFormedScheme)(const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Determines if the given text range contains a well-formed user info + * according to RFC 3986 or not. + * + * @param first IN: Pointer to first character + * @param afterLast IN: Pointer to character after the last one still in + * @return URI_TRUE if non-NULL and well-formed, else + * URI_FALSE + * + * @see uriIsWellFormedFragmentA + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostRegNameA + * @see uriIsWellFormedPathA + * @see uriIsWellFormedPortA + * @see uriIsWellFormedQueryA + * @see uriIsWellFormedSchemeA + * @see uriSetUserInfoA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC UriBool URI_FUNC(IsWellFormedUserInfo)(const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the fragment of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedFragmentA + * @see uriSetFragmentMmA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetFragment)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the fragment of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedFragmentA + * @see uriSetFragmentA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetFragmentMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIp6MmA + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostIpFutureMmA + * @see uriIsWellFormedHostRegNameA + * @see uriSetFragmentA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostAuto)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostIp4A + * @see uriIsWellFormedHostIp6A + * @see uriIsWellFormedHostIp6MmA + * @see uriIsWellFormedHostIpFutureA + * @see uriIsWellFormedHostIpFutureMmA + * @see uriIsWellFormedHostRegNameA + * @see uriSetFragmentMmA + * @see uriSetHostAutoA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostAutoMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostRegNameA + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostRegName)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostRegNameA + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostRegNameMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostIp4A + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostIp4)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostIp4A + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4A + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostIp4Mm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostIp6A + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostIp6)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostIp6A + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6A + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostIp6Mm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostIp4A + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostIpFuture)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the host of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedHostIp4A + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetHostIpFutureMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the path of the given %URI to the given value. + * + * Non-NULL values must start with a leading slash for %URIs that have a host. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedPathA + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPathMmA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetPath)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the path of the given %URI to the given value. + * + * Non-NULL values must start with a leading slash for %URIs that have a host. + * + * The %URI must have a non-NULL host set. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedPathA + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPathA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetPathMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, UriMemoryManager * memory); + +/** + * Sets the port text of the given %URI to the given value. + * + * The %URI must have a non-NULL host set. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedPortA + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPortTextMmA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetPortText)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the port text of the given %URI to the given value. + * + * The %URI must have a non-NULL host set. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedPortA + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetPortTextMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the query of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedQueryA + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPortTextA + * @see uriSetQueryMmA + * @see uriSetSchemeA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetQuery)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the query of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedQueryA + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextMmA + * @see uriSetQueryA + * @see uriSetSchemeMmA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetQueryMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the scheme of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedSchemeA + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeMmA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetScheme)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the scheme of the given %URI to the given value. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedSchemeA + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetSchemeMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Sets the user info of the given %URI to the given value. + * + * The %URI must have a non-NULL host set. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * Uses default libc-based memory manager. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @return Error code or 0 on success + * + * @see uriIsWellFormedUserInfoA + * @see uriSetFragmentA + * @see uriSetHostAutoA + * @see uriSetHostIp4A + * @see uriSetHostIp6A + * @see uriSetHostIpFutureA + * @see uriSetHostRegNameA + * @see uriSetPortTextA + * @see uriSetQueryA + * @see uriSetSchemeA + * @see uriSetUserInfoMmA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetUserInfo)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast); + +/** + * Sets the user info of the given %URI to the given value. + * + * The %URI must have a non-NULL host set. + * + * Parameters first and afterLast must both be NULL + * or non-NULL at the same time. + * + * The function may make the %URI own its memory if needed (if it is not already owned). + * + * For all return values but URI_ERROR_MALLOC, all-or-nothing behavior + * can be expected, e.g. trying to apply a malformed value will leave the + * %URI unchanged. + * + * @param uri INOUT: %URI to modify + * @param first IN: Pointer to first character, can be NULL + * @param afterLast IN: Pointer to character after the last one still in, can be + * NULL + * @param memory IN: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriIsWellFormedUserInfoA + * @see uriSetFragmentMmA + * @see uriSetHostAutoMmA + * @see uriSetHostIp4MmA + * @see uriSetHostIp6MmA + * @see uriSetHostIpFutureMmA + * @see uriSetHostRegNameMmA + * @see uriSetPortTextMmA + * @see uriSetQueryMmA + * @see uriSetSchemeMmA + * @see uriSetUserInfoA + * @since 0.9.9 + */ +URI_PUBLIC int URI_FUNC(SetUserInfoMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, + const URI_CHAR * afterLast, + UriMemoryManager * memory); + +/** + * Obtain the base runtime version of uriparser. + * + * The string returned is based on the compile time version + * of uriparser. + * + * @note Distributors may have applied backports of security + * fixes (potentially with adjusting packaging version but often + * without adjusting runtime version) + * or even fully custom patches. As a result, the version string + * returned serves as nothing more than "based on that version", + * it does not guarantee equivalence to vanilla upstream releases + * or absence of additional downstream patches. + * It is nothing more than "a hint" and MUST NEVER be used to + * make decisions on in application code at runtime. + * + * @return Pointer to a read-only zero terminated version string + * + * @since 0.9.9 + */ +URI_PUBLIC const URI_CHAR * URI_FUNC(BaseRuntimeVersion)(void); + +# ifdef __cplusplus +} +# endif + +# endif #endif diff --git a/include/uriparser/UriBase.h b/include/uriparser/UriBase.h index dc3883e..abadcae 100644 --- a/include/uriparser/UriBase.h +++ b/include/uriparser/UriBase.h @@ -43,140 +43,136 @@ */ #ifndef URI_BASE_H -#define URI_BASE_H 1 - - +# define URI_BASE_H 1 /* Version helper macro */ -#define URI_ANSI_TO_UNICODE(x) L##x - - +# define URI_ANSI_TO_UNICODE_HELPER(x) L##x +# define URI_ANSI_TO_UNICODE(x) URI_ANSI_TO_UNICODE_HELPER(x) /* Version */ -#define URI_VER_MAJOR 0 -#define URI_VER_MINOR 9 -#define URI_VER_RELEASE 8 -#define URI_VER_SUFFIX_ANSI "" -#define URI_VER_SUFFIX_UNICODE URI_ANSI_TO_UNICODE(URI_VER_SUFFIX_ANSI) - - +# define URI_VER_MAJOR 1 +# define URI_VER_MINOR 0 +# define URI_VER_RELEASE 1 +# define URI_VER_SUFFIX_ANSI "" +# define URI_VER_SUFFIX_UNICODE URI_ANSI_TO_UNICODE(URI_VER_SUFFIX_ANSI) /* More version helper macros */ -#define URI_INT_TO_ANSI_HELPER(x) #x -#define URI_INT_TO_ANSI(x) URI_INT_TO_ANSI_HELPER(x) - -#define URI_INT_TO_UNICODE_HELPER(x) URI_ANSI_TO_UNICODE(#x) -#define URI_INT_TO_UNICODE(x) URI_INT_TO_UNICODE_HELPER(x) - -#define URI_VER_ANSI_HELPER(ma, mi, r, s) \ - URI_INT_TO_ANSI(ma) "." \ - URI_INT_TO_ANSI(mi) "." \ - URI_INT_TO_ANSI(r) \ - s +# define URI_INT_TO_ANSI_HELPER(x) #x +# define URI_INT_TO_ANSI(x) URI_INT_TO_ANSI_HELPER(x) -#define URI_VER_UNICODE_HELPER(ma, mi, r, s) \ - URI_INT_TO_UNICODE(ma) L"." \ - URI_INT_TO_UNICODE(mi) L"." \ - URI_INT_TO_UNICODE(r) \ - s +# define URI_INT_TO_UNICODE_HELPER(x) URI_ANSI_TO_UNICODE(#x) +# define URI_INT_TO_UNICODE(x) URI_INT_TO_UNICODE_HELPER(x) +# define URI_VER_ANSI_HELPER(ma, mi, r, s) \ + URI_INT_TO_ANSI(ma) "." URI_INT_TO_ANSI(mi) "." URI_INT_TO_ANSI(r) s +# define URI_VER_UNICODE_HELPER(ma, mi, r, s) \ + URI_INT_TO_UNICODE(ma) L"." URI_INT_TO_UNICODE(mi) L"." URI_INT_TO_UNICODE(r) s /* Full version strings */ -#define URI_VER_ANSI URI_VER_ANSI_HELPER(URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, URI_VER_SUFFIX_ANSI) -#define URI_VER_UNICODE URI_VER_UNICODE_HELPER(URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, URI_VER_SUFFIX_UNICODE) - - +# define URI_VER_ANSI \ + URI_VER_ANSI_HELPER(URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, \ + URI_VER_SUFFIX_ANSI) +# define URI_VER_UNICODE \ + URI_VER_UNICODE_HELPER(URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, \ + URI_VER_SUFFIX_UNICODE) /* Unused parameter macro */ -#ifdef __GNUC__ -# define URI_UNUSED(x) unused_##x __attribute__((unused)) -#else -# define URI_UNUSED(x) x -#endif - - +# ifdef __GNUC__ +# define URI_UNUSED(x) unused_##x __attribute__((unused)) +# else +# define URI_UNUSED(x) x +# endif /* Import/export decorator */ -#if defined(_MSC_VER) -# if defined(URI_STATIC_BUILD) -# define URI_PUBLIC -# elif defined(URI_LIBRARY_BUILD) -# define URI_PUBLIC __declspec(dllexport) -# else -# define URI_PUBLIC __declspec(dllimport) -# endif -#else -# if ! defined(URI_LIBRARY_BUILD) || ! defined(URI_VISIBILITY) -# define URI_PUBLIC -# else -# define URI_PUBLIC __attribute__ ((visibility("default"))) -# endif -#endif - - +# if defined(_MSC_VER) +# if defined(URI_STATIC_BUILD) +# define URI_PUBLIC +# elif defined(URI_LIBRARY_BUILD) +# define URI_PUBLIC __declspec(dllexport) +# else +# define URI_PUBLIC __declspec(dllimport) +# endif +# else +# if !defined(URI_LIBRARY_BUILD) || !defined(URI_VISIBILITY) +# define URI_PUBLIC +# else +# define URI_PUBLIC __attribute__((visibility("default"))) +# endif +# endif typedef int UriBool; /**< Boolean type */ -#define URI_TRUE 1 -#define URI_FALSE 0 - - +# define URI_TRUE 1 +# define URI_FALSE 0 /* Shared errors */ -#define URI_SUCCESS 0 -#define URI_ERROR_SYNTAX 1 /* Parsed text violates expected format */ -#define URI_ERROR_NULL 2 /* One of the params passed was NULL - although it mustn't be */ -#define URI_ERROR_MALLOC 3 /* Requested memory could not be allocated */ -#define URI_ERROR_OUTPUT_TOO_LARGE 4 /* Some output is to large for the receiving buffer */ -#define URI_ERROR_NOT_IMPLEMENTED 8 /* The called function is not implemented yet */ -#define URI_ERROR_RANGE_INVALID 9 /* The parameters passed contained invalid ranges */ -#define URI_ERROR_MEMORY_MANAGER_INCOMPLETE 10 /* [>=0.9.0] The UriMemoryManager passed does not implement all needed functions */ - +# define URI_SUCCESS 0 +# define URI_ERROR_SYNTAX 1 /* Parsed text violates expected format */ +# define URI_ERROR_NULL \ + 2 /* One of the params passed was NULL although it mustn't be \ + */ +# define URI_ERROR_MALLOC 3 /* Requested memory could not be allocated */ +# define URI_ERROR_OUTPUT_TOO_LARGE \ + 4 /* Some output is to large for the receiving buffer */ +# define URI_ERROR_NOT_IMPLEMENTED 8 /* The called function is not implemented yet */ +# define URI_ERROR_RANGE_INVALID 9 /* The parameters passed contained invalid ranges */ +# define URI_ERROR_MEMORY_MANAGER_INCOMPLETE \ + 10 /* [>=0.9.0] The UriMemoryManager passed does not implement all needed \ + functions */ /* Errors specific to ToString */ -#define URI_ERROR_TOSTRING_TOO_LONG URI_ERROR_OUTPUT_TOO_LARGE /* Deprecated, test for URI_ERROR_OUTPUT_TOO_LARGE instead */ +# define URI_ERROR_TOSTRING_TOO_LONG \ + URI_ERROR_OUTPUT_TOO_LARGE /* Deprecated, test for URI_ERROR_OUTPUT_TOO_LARGE \ + instead */ /* Errors specific to AddBaseUri */ -#define URI_ERROR_ADDBASE_REL_BASE 5 /* Given base is not absolute */ +# define URI_ERROR_ADDBASE_REL_BASE 5 /* Given base is not absolute */ /* Errors specific to RemoveBaseUri */ -#define URI_ERROR_REMOVEBASE_REL_BASE 6 /* Given base is not absolute */ -#define URI_ERROR_REMOVEBASE_REL_SOURCE 7 /* Given base is not absolute */ +# define URI_ERROR_REMOVEBASE_REL_BASE 6 /* Given base is not absolute */ +# define URI_ERROR_REMOVEBASE_REL_SOURCE 7 /* Given base is not absolute */ /* Error specific to uriTestMemoryManager */ -#define URI_ERROR_MEMORY_MANAGER_FAULTY 11 /* [>=0.9.0] The UriMemoryManager given did not pass the test suite */ - - -#ifndef URI_DOXYGEN -# include /* For NULL, snprintf */ -# include /* For wchar_t */ -# include /* For strlen, memset, memcpy */ -# include /* For malloc */ -#endif /* URI_DOXYGEN */ - - +# define URI_ERROR_MEMORY_MANAGER_FAULTY \ + 11 /* [>=0.9.0] The UriMemoryManager given did not pass the test suite */ + +/* Error specific to uriSetUserInfo */ +# define URI_ERROR_SETUSERINFO_HOST_NOT_SET \ + 12 /* [>=0.9.9] The %URI given does not have the host set */ + +/* Error specific to uriSetPort */ +# define URI_ERROR_SETPORT_HOST_NOT_SET \ + 13 /* [>=0.9.9] The %URI given does not have the host set */ + +/* Error specific to uriSetHost* */ +# define URI_ERROR_SETHOST_USERINFO_SET \ + 14 /* [>=0.9.9] The %URI given does have user info set */ +# define URI_ERROR_SETHOST_PORT_SET \ + 15 /* [>=0.9.9] The %URI given does have a port set */ + +# ifndef URI_DOXYGEN +# include /* For NULL, snprintf */ +# include /* For wchar_t */ +# include /* For strlen, memset, memcpy */ +# include /* For malloc */ +# endif /* URI_DOXYGEN */ /** * Holds an IPv4 address. */ typedef struct UriIp4Struct { - unsigned char data[4]; /**< Each octet in one byte */ + unsigned char data[4]; /**< Each octet in one byte */ } UriIp4; /**< @copydoc UriIp4Struct */ - - /** * Holds an IPv6 address. */ typedef struct UriIp6Struct { - unsigned char data[16]; /**< Each quad in two bytes */ + unsigned char data[16]; /**< Each quad in two bytes */ } UriIp6; /**< @copydoc UriIp6Struct */ - -struct UriMemoryManagerStruct; /* foward declaration to break loop */ - +struct UriMemoryManagerStruct; /* forward declaration to break loop */ /** * Function signature that custom malloc(3) functions must conform to @@ -204,7 +200,8 @@ typedef void * (*UriFuncRealloc)(struct UriMemoryManagerStruct *, void *, size_t * * @since 0.9.0 */ -typedef void * (*UriFuncReallocarray)(struct UriMemoryManagerStruct *, void *, size_t, size_t); +typedef void * (*UriFuncReallocarray)(struct UriMemoryManagerStruct *, void *, size_t, + size_t); /** * Function signature that custom free(3) functions must conform to @@ -213,7 +210,6 @@ typedef void * (*UriFuncReallocarray)(struct UriMemoryManagerStruct *, void *, s */ typedef void (*UriFuncFree)(struct UriMemoryManagerStruct *, void *); - /** * Class-like interface of custom memory managers * @@ -224,78 +220,87 @@ typedef void (*UriFuncFree)(struct UriMemoryManagerStruct *, void *); * @since 0.9.0 */ typedef struct UriMemoryManagerStruct { - UriFuncMalloc malloc; /**< Pointer to custom malloc(3) */ - UriFuncCalloc calloc; /**< Pointer to custom calloc(3); to emulate using malloc and memset see uriEmulateCalloc */ - UriFuncRealloc realloc; /**< Pointer to custom realloc(3) */ - UriFuncReallocarray reallocarray; /**< Pointer to custom reallocarray(3); to emulate using realloc see uriEmulateReallocarray */ - UriFuncFree free; /**< Pointer to custom free(3) */ - void * userData; /**< Pointer to data that the other function members need access to */ + UriFuncMalloc malloc; /**< Pointer to custom malloc(3) */ + UriFuncCalloc calloc; /**< Pointer to custom calloc(3); to emulate using malloc and + memset see uriEmulateCalloc */ + UriFuncRealloc realloc; /**< Pointer to custom realloc(3) */ + UriFuncReallocarray reallocarray; /**< Pointer to custom reallocarray(3); to emulate + using realloc see uriEmulateReallocarray */ + UriFuncFree free; /**< Pointer to custom free(3) */ + void * + userData; /**< Pointer to data that the other function members need access to */ } UriMemoryManager; /**< @copydoc UriMemoryManagerStruct */ - /** * Specifies a line break conversion mode. */ typedef enum UriBreakConversionEnum { - URI_BR_TO_LF, /**< Convert to Unix line breaks ("\\x0a") */ - URI_BR_TO_CRLF, /**< Convert to Windows line breaks ("\\x0d\\x0a") */ - URI_BR_TO_CR, /**< Convert to Macintosh line breaks ("\\x0d") */ - URI_BR_TO_UNIX = URI_BR_TO_LF, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_LF */ - URI_BR_TO_WINDOWS = URI_BR_TO_CRLF, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_CRLF */ - URI_BR_TO_MAC = URI_BR_TO_CR, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_CR */ - URI_BR_DONT_TOUCH /**< Copy line breaks unmodified */ + URI_BR_TO_LF, /**< Convert to Unix line breaks ("\\x0a") */ + URI_BR_TO_CRLF, /**< Convert to Windows line breaks ("\\x0d\\x0a") */ + URI_BR_TO_CR, /**< Convert to Macintosh line breaks ("\\x0d") */ + URI_BR_TO_UNIX = URI_BR_TO_LF, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_LF */ + URI_BR_TO_WINDOWS = + URI_BR_TO_CRLF, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_CRLF */ + URI_BR_TO_MAC = URI_BR_TO_CR, /**< @copydoc UriBreakConversionEnum::URI_BR_TO_CR */ + URI_BR_DONT_TOUCH /**< Copy line breaks unmodified */ } UriBreakConversion; /**< @copydoc UriBreakConversionEnum */ - - /** * Specifies which component of a %URI has to be normalized. */ typedef enum UriNormalizationMaskEnum { - URI_NORMALIZED = 0, /**< Do not normalize anything */ - URI_NORMALIZE_SCHEME = 1 << 0, /**< Normalize scheme (fix uppercase letters) */ - URI_NORMALIZE_USER_INFO = 1 << 1, /**< Normalize user info (fix uppercase percent-encodings) */ - URI_NORMALIZE_HOST = 1 << 2, /**< Normalize host (fix uppercase letters) */ - URI_NORMALIZE_PATH = 1 << 3, /**< Normalize path (fix uppercase percent-encodings and redundant dot segments) */ - URI_NORMALIZE_QUERY = 1 << 4, /**< Normalize query (fix uppercase percent-encodings) */ - URI_NORMALIZE_FRAGMENT = 1 << 5 /**< Normalize fragment (fix uppercase percent-encodings) */ + URI_NORMALIZED = 0, /**< Do not normalize anything */ + URI_NORMALIZE_SCHEME = 1 << 0, /**< Normalize scheme (fix uppercase letters) */ + URI_NORMALIZE_USER_INFO = + 1 << 1, /**< Normalize user info (fix uppercase percent-encodings) */ + URI_NORMALIZE_HOST = 1 << 2, /**< Normalize host (fix uppercase letters) */ + URI_NORMALIZE_PATH = 1 << 3, /**< Normalize path (fix uppercase percent-encodings and + redundant dot segments) */ + URI_NORMALIZE_QUERY = + 1 << 4, /**< Normalize query (fix uppercase percent-encodings) */ + URI_NORMALIZE_FRAGMENT = + 1 << 5, /**< Normalize fragment (fix uppercase percent-encodings) */ + URI_NORMALIZE_PORT = 1 << 6 /**< Normalize port (drop leading zeros) @since 0.9.9 */ } UriNormalizationMask; /**< @copydoc UriNormalizationMaskEnum */ - - /** * Specifies how to resolve %URI references. */ typedef enum UriResolutionOptionsEnum { - URI_RESOLVE_STRICTLY = 0, /**< Full RFC conformance */ - URI_RESOLVE_IDENTICAL_SCHEME_COMPAT = 1 << 0 /**< Treat %URI to resolve with identical scheme as having no scheme */ + URI_RESOLVE_STRICTLY = 0, /**< Full RFC conformance */ + URI_RESOLVE_IDENTICAL_SCHEME_COMPAT = + 1 << 0 /**< Treat %URI to resolve with identical scheme as having no scheme */ } UriResolutionOptions; /**< @copydoc UriResolutionOptionsEnum */ - - /** - * Wraps a memory manager backend that only provides malloc and free - * to make a complete memory manager ready to be used. + * Wraps a memory manager backend that only provides malloc(3) and + * free(3) to make a complete memory manager ready to be used. * * The core feature of this wrapper is that you don't need to implement - * realloc if you don't want to. The wrapped memory manager uses - * backend->malloc, memcpy, and backend->free and soieof(size_t) extra - * bytes per allocation to emulate fallback realloc for you. + * realloc(3) if you don't want to. The wrapped memory manager uses + * backend->malloc, memcpy(3), and backend->free and + * (at least) sizeof(size_t) extra bytes per allocation to emulate + * fallback realloc(3) for you. * - * memory->calloc is uriEmulateCalloc. - * memory->free uses backend->free and handles the size header. - * memory->malloc uses backend->malloc and adds a size header. - * memory->realloc uses memory->malloc, memcpy, and memory->free and reads - * the size header. - * memory->reallocarray is uriEmulateReallocarray. + *
    + *
  • memory->calloc is uriEmulateCalloc.
  • + *
  • memory->free uses backend->free, + * and handles the size header.
  • + *
  • memory->malloc uses backend->malloc, + * and adds a size header.
  • + *
  • memory->realloc uses memory->malloc, + * memcpy(3) and memory->free, + * and reads the size header.
  • + *
  • memory->reallocarray is uriEmulateReallocarray.
  • + *
* - * The internal workings behind memory->free, memory->malloc, and - * memory->realloc may change so the functions exposed by these function - * pointer sshould be consided internal and not public API. + * The internal workings behind memory->free, memory->malloc, + * and memory->realloc may change, and the functions exposed by these + * function pointers should be considered internal and not public API. * * @param memory OUT: Where to write the wrapped memory manager to * @param backend IN: Memory manager to use as a backend - * @return Error code or 0 on success + * @return Error code or 0 on success * * @see uriEmulateCalloc * @see uriEmulateReallocarray @@ -303,12 +308,10 @@ typedef enum UriResolutionOptionsEnum { * @since 0.9.0 */ URI_PUBLIC int uriCompleteMemoryManager(UriMemoryManager * memory, - UriMemoryManager * backend); - - + UriMemoryManager * backend); /** - * Offers emulation of calloc(3) based on memory->malloc and memset. + * Offers emulation of calloc(3) based on memory->malloc and memset. * See "man 3 calloc" as well. * * @param memory IN: Memory manager to use, should not be NULL @@ -321,17 +324,14 @@ URI_PUBLIC int uriCompleteMemoryManager(UriMemoryManager * memory, * @see UriMemoryManager * @since 0.9.0 */ -URI_PUBLIC void * uriEmulateCalloc(UriMemoryManager * memory, - size_t nmemb, size_t size); - - +URI_PUBLIC void * uriEmulateCalloc(UriMemoryManager * memory, size_t nmemb, size_t size); /** - * Offers emulation of reallocarray(3) based on memory->realloc. + * Offers emulation of reallocarray(3) based on memory->realloc. * See "man 3 reallocarray" as well. * * @param memory IN: Memory manager to use, should not be NULL - * @param ptr IN: Pointer allocated using memory->malloc/... or NULL + * @param ptr IN: Pointer allocated using memory->malloc/... or NULL * @param nmemb IN: Number of elements to allocate * @param size IN: Size in bytes per element * @return Pointer to allocated memory or NULL @@ -341,10 +341,8 @@ URI_PUBLIC void * uriEmulateCalloc(UriMemoryManager * memory, * @see UriMemoryManager * @since 0.9.0 */ -URI_PUBLIC void * uriEmulateReallocarray(UriMemoryManager * memory, - void * ptr, size_t nmemb, size_t size); - - +URI_PUBLIC void * uriEmulateReallocarray(UriMemoryManager * memory, void * ptr, + size_t nmemb, size_t size); /** * Run multiple tests against a given memory manager. @@ -356,7 +354,11 @@ URI_PUBLIC void * uriEmulateReallocarray(UriMemoryManager * memory, * 5. and frees that memory. * * It is recommended to compile with AddressSanitizer enabled - * to take full advantage of uriTestMemoryManager. + * to take full advantage of uriTestMemoryManager. + * + * For backwards-compatibility, uriTestMemoryManager + * does not challenge pointer alignment; please see + * uriTestMemoryManagerEx for that feature. * * @param memory IN: Memory manager to use, should not be NULL * @return Error code or 0 on success @@ -364,10 +366,37 @@ URI_PUBLIC void * uriEmulateReallocarray(UriMemoryManager * memory, * @see uriEmulateCalloc * @see uriEmulateReallocarray * @see UriMemoryManager + * @see uriTestMemoryManagerEx * @since 0.9.0 */ URI_PUBLIC int uriTestMemoryManager(UriMemoryManager * memory); - +/** + * Run multiple tests against a given memory manager. + * For example, one test + * 1. allocates a small amount of memory, + * 2. writes some magic bytes to it, + * 3. reallocates it, + * 4. checks that previous values are still present, + * 5. and frees that memory. + * + * It is recommended to compile with both AddressSanitizer and + * UndefinedBehaviorSanitizer enabled to take full advantage of + * uriTestMemoryManagerEx. Note that environment variable + * UBSAN_OPTIONS may need adjustment to make UndefinedBehaviorSanitizer + * fatal (which by default it is not). + * + * @param memory IN: Memory manager to use, should not be NULL + * @param challengeAlignment IN: Whether to challenge pointer alignment + * @return Error code or 0 on success + * + * @see uriEmulateCalloc + * @see uriEmulateReallocarray + * @see UriMemoryManager + * @see uriTestMemoryManager + * @since 1.0.0 + */ +URI_PUBLIC int uriTestMemoryManagerEx(UriMemoryManager * memory, + UriBool challengeAlignment); #endif /* URI_BASE_H */ diff --git a/include/uriparser/UriDefsAnsi.h b/include/uriparser/UriDefsAnsi.h index af581b9..17aed1b 100644 --- a/include/uriparser/UriDefsAnsi.h +++ b/include/uriparser/UriDefsAnsi.h @@ -46,24 +46,18 @@ /* Allow multi inclusion */ #include "UriDefsConfig.h" - - #undef URI_CHAR #define URI_CHAR char #undef _UT #define _UT(x) x - - #undef URI_FUNC #define URI_FUNC(x) uri##x##A #undef URI_TYPE #define URI_TYPE(x) Uri##x##A - - #undef URI_STRLEN #define URI_STRLEN strlen #undef URI_STRCPY @@ -76,7 +70,7 @@ /* TODO Remove on next source-compatibility break */ #undef URI_SNPRINTF #if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) -# define URI_SNPRINTF _snprintf +# define URI_SNPRINTF _snprintf #else -# define URI_SNPRINTF snprintf +# define URI_SNPRINTF snprintf #endif diff --git a/include/uriparser/UriDefsConfig.h b/include/uriparser/UriDefsConfig.h index 51bc93e..79d485d 100644 --- a/include/uriparser/UriDefsConfig.h +++ b/include/uriparser/UriDefsConfig.h @@ -43,59 +43,51 @@ */ #ifndef URI_DEFS_CONFIG_H -#define URI_DEFS_CONFIG_H 1 - - +# define URI_DEFS_CONFIG_H 1 /* Deny external overriding */ -#undef URI_ENABLE_ANSI /* Internal for !URI_NO_ANSI */ -#undef URI_ENABLE_UNICODE /* Internal for !URI_NO_UNICODE */ - - +# undef URI_ENABLE_ANSI /* Internal for !URI_NO_ANSI */ +# undef URI_ENABLE_UNICODE /* Internal for !URI_NO_UNICODE */ /* Encoding */ -#ifdef URI_NO_ANSI -# ifdef URI_NO_UNICODE +# ifdef URI_NO_ANSI +# ifdef URI_NO_UNICODE /* No encoding at all */ -# error URI_NO_ANSI and URI_NO_UNICODE cannot go together. -# else +# error URI_NO_ANSI and URI_NO_UNICODE cannot go together. +# else /* Wide strings only */ -# define URI_ENABLE_UNICODE 1 -# endif -#else -# ifdef URI_NO_UNICODE +# define URI_ENABLE_UNICODE 1 +# endif +# else +# ifdef URI_NO_UNICODE /* Narrow strings only */ -# define URI_ENABLE_ANSI 1 -# else +# define URI_ENABLE_ANSI 1 +# else /* Both narrow and wide strings */ -# define URI_ENABLE_ANSI 1 -# define URI_ENABLE_UNICODE 1 -# endif -#endif - - +# define URI_ENABLE_ANSI 1 +# define URI_ENABLE_UNICODE 1 +# endif +# endif /* Function inlining, not ANSI/ISO C! */ -#if defined(URI_DOXYGEN) -# define URI_INLINE -#elif defined(__INTEL_COMPILER) +# if defined(URI_DOXYGEN) +# define URI_INLINE +# elif defined(__INTEL_COMPILER) /* Intel C/C++ */ /* http://predef.sourceforge.net/precomp.html#sec20 */ /* http://www.intel.com/support/performancetools/c/windows/sb/CS-007751.htm#2 */ -# define URI_INLINE __forceinline -#elif defined(_MSC_VER) +# define URI_INLINE __forceinline +# elif defined(_MSC_VER) /* Microsoft Visual C++ */ /* http://predef.sourceforge.net/precomp.html#sec32 */ /* http://msdn2.microsoft.com/en-us/library/ms882281.aspx */ -# define URI_INLINE __forceinline -#elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) +# define URI_INLINE __forceinline +# elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) /* C99, "inline" is a keyword */ -# define URI_INLINE inline -#else +# define URI_INLINE inline +# else /* No inlining */ -# define URI_INLINE -#endif - - +# define URI_INLINE +# endif #endif /* URI_DEFS_CONFIG_H */ diff --git a/include/uriparser/UriDefsUnicode.h b/include/uriparser/UriDefsUnicode.h index 01421f5..6fce672 100644 --- a/include/uriparser/UriDefsUnicode.h +++ b/include/uriparser/UriDefsUnicode.h @@ -46,24 +46,18 @@ /* Allow multi inclusion */ #include "UriDefsConfig.h" - - #undef URI_CHAR #define URI_CHAR wchar_t #undef _UT #define _UT(x) L##x - - #undef URI_FUNC #define URI_FUNC(x) uri##x##W #undef URI_TYPE #define URI_TYPE(x) Uri##x##W - - #undef URI_STRLEN #define URI_STRLEN wcslen #undef URI_STRCPY @@ -76,7 +70,7 @@ /* TODO Remove on next source-compatibility break */ #undef URI_SNPRINTF #if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) -# define URI_SNPRINTF _snwprintf +# define URI_SNPRINTF _snwprintf #else -# define URI_SNPRINTF swprintf +# define URI_SNPRINTF swprintf #endif diff --git a/include/uriparser/UriIp4.h b/include/uriparser/UriIp4.h index c2e59a6..5f84b62 100644 --- a/include/uriparser/UriIp4.h +++ b/include/uriparser/UriIp4.h @@ -44,67 +44,62 @@ */ #if (defined(URI_PASS_ANSI) && !defined(URI_IP4_TWICE_H_ANSI)) \ - || (defined(URI_PASS_UNICODE) && !defined(URI_IP4_TWICE_H_UNICODE)) \ - || (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) + || (defined(URI_PASS_UNICODE) && !defined(URI_IP4_TWICE_H_UNICODE)) \ + || (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) /* What encodings are enabled? */ -#include "UriDefsConfig.h" -#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) +# include "UriDefsConfig.h" +# if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) /* Include SELF twice */ -# ifdef URI_ENABLE_ANSI -# define URI_PASS_ANSI 1 -# include "UriIp4.h" -# undef URI_PASS_ANSI -# endif -# ifdef URI_ENABLE_UNICODE -# define URI_PASS_UNICODE 1 -# include "UriIp4.h" -# undef URI_PASS_UNICODE -# endif +# ifdef URI_ENABLE_ANSI +# define URI_PASS_ANSI 1 +# include "UriIp4.h" +# undef URI_PASS_ANSI +# endif +# ifdef URI_ENABLE_UNICODE +# define URI_PASS_UNICODE 1 +# include "UriIp4.h" +# undef URI_PASS_UNICODE +# endif /* Only one pass for each encoding */ -#elif (defined(URI_PASS_ANSI) && !defined(URI_IP4_TWICE_H_ANSI) \ - && defined(URI_ENABLE_ANSI)) || (defined(URI_PASS_UNICODE) \ - && !defined(URI_IP4_TWICE_H_UNICODE) && defined(URI_ENABLE_UNICODE)) -# ifdef URI_PASS_ANSI -# define URI_IP4_TWICE_H_ANSI 1 -# include "UriDefsAnsi.h" -# else -# define URI_IP4_TWICE_H_UNICODE 1 -# include "UriDefsUnicode.h" -# include -# endif - - - -#ifdef __cplusplus +# elif (defined(URI_PASS_ANSI) && !defined(URI_IP4_TWICE_H_ANSI) \ + && defined(URI_ENABLE_ANSI)) \ + || (defined(URI_PASS_UNICODE) && !defined(URI_IP4_TWICE_H_UNICODE) \ + && defined(URI_ENABLE_UNICODE)) +# ifdef URI_PASS_ANSI +# define URI_IP4_TWICE_H_ANSI 1 +# include "UriDefsAnsi.h" +# else +# define URI_IP4_TWICE_H_UNICODE 1 +# include "UriDefsUnicode.h" +# include +# endif + +# ifdef __cplusplus extern "C" { -#endif - - - -#ifndef URI_DOXYGEN -# include "UriBase.h" -#endif - +# endif +# ifndef URI_DOXYGEN +# include "UriBase.h" +# endif /** - * Converts a IPv4 text representation into four bytes. + * Converts an IPv4 text representation into four bytes. * * @param octetOutput Output destination * @param first First character of IPv4 text to parse * @param afterLast Position to stop parsing at * @return Error code or 0 on success + * + * @see uriParseIpSixAddressA + * @see uriParseIpSixAddressMmA */ URI_PUBLIC int URI_FUNC(ParseIpFourAddress)(unsigned char * octetOutput, - const URI_CHAR * first, const URI_CHAR * afterLast); - - + const URI_CHAR * first, + const URI_CHAR * afterLast); -#ifdef __cplusplus +# ifdef __cplusplus } -#endif - +# endif - -#endif +# endif #endif -- cgit v1.2.3