diff options
-rw-r--r-- | Makefile.am | 18 | ||||
-rw-r--r-- | TODO.txt | 3 | ||||
-rw-r--r-- | include/uriparser.h | 2 | ||||
-rw-r--r-- | include/uriparser/Uri.h | 34 | ||||
-rw-r--r-- | lib/UriResolve.c | 13 | ||||
-rw-r--r-- | test/test.cpp | 4 |
6 files changed, 57 insertions, 17 deletions
diff --git a/Makefile.am b/Makefile.am index 14eb742..3ffddf7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,8 +17,7 @@ include_uriparser_HEADERS = \ include/uriparser/UriDefsAnsi.h \ include/uriparser/UriDefsConfig.h \ include/uriparser/UriDefsUnicode.h \ - include/uriparser/UriIp4.h \ - include/uriparser/UriIp4Base.h + include/uriparser/UriIp4.h @@ -32,10 +31,21 @@ include_HEADERS = \ liburiparser_la_CFLAGS = -Iinclude liburiparser_la_SOURCES = \ - lib/Uri.c \ - lib/UriBase.c \ + lib/UriCommon.c \ + lib/UriCommon.h \ + lib/UriCompare.c \ + lib/UriEscape.c \ lib/UriIp4.c \ lib/UriIp4Base.c \ + lib/UriIp4Base.h \ + lib/UriNormalize.c \ + lib/UriNormalizeBase.c \ + lib/UriNormalizeBase.h \ + lib/UriParse.c \ + lib/UriParseBase.c \ + lib/UriParseBase.h \ + lib/UriRecompose.c \ + lib/UriResolve.c \ lib/uriparser.c @@ -3,7 +3,7 @@ * Merge cases lists to sets using the preprocessor
* Prevent inlining for "less space" compile mode?
* Fix vs2k5 warnings
- * Finish owner thing
+ * Test owner code
== SOON ==
* More features:
@@ -14,7 +14,6 @@ * Code TODOs
* Add external documentation
* Make hostText from hostData?
- * Take care of deep/shallow distinction
* Add specific URI support (callbacks?)
== LATER ==
diff --git a/include/uriparser.h b/include/uriparser.h index c9a365c..0dfeb2a 100644 --- a/include/uriparser.h +++ b/include/uriparser.h @@ -47,7 +47,7 @@ -#include <uriparser/UriDefsConfig.h> +#include "uriparser/UriDefsConfig.h" #ifdef URI_ENABLE_LEGACY diff --git a/include/uriparser/Uri.h b/include/uriparser/Uri.h index 195a003..95e5b58 100644 --- a/include/uriparser/Uri.h +++ b/include/uriparser/Uri.h @@ -138,7 +138,6 @@ typedef struct URI_TYPE(UriStruct) { URI_TYPE(TextRange) query; /**< Query without leading "?" */ URI_TYPE(TextRange) fragment; /**< Query without leading "#" */ UriBool absolutePath; /**< Absolute path flag, meaningless if %URI is absolute */ -/* TODO */ UriBool owner; /**< Memory owner flag */ void * reserved; /**< Reserved to the parser */ @@ -308,9 +307,40 @@ int URI_FUNC(ToString)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, int maxChars, -/* TODO write comments */ +/** + * Determines the components of a %URI that are not normalized. + * + * @param uri %URI to check + * @return Normalization job mask + */ unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)(const URI_TYPE(Uri) * uri); + + + +/** + * Normalizes a %URI using a normalization mask. + * The normalization mask decides what components are normalized. + * + * NOTE: If necessary the %URI becomes owner of all memory + * behind the text pointed to. Text is duplicated in that case. + * + * @param uri %URI to normalize + * @param mask Normalization mask + * @return Error code or 0 on success + */ int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, unsigned int mask); + + + +/** + * Normalizes all components of a %URI. + * + * NOTE: If necessary the %URI becomes owner of all memory + * behind the text pointed to. Text is duplicated in that case. + * + * @param uri %URI to normalize + * @return Error code or 0 on success + */ int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); diff --git a/lib/UriResolve.c b/lib/UriResolve.c index a710c62..3022d90 100644 --- a/lib/UriResolve.c +++ b/lib/UriResolve.c @@ -90,6 +90,9 @@ static URI_INLINE UriBool URI_FUNC(CopyPath)(URI_TYPE(Uri) * dest, }
return URI_FALSE; /* Raises malloc error */
}
+
+ /* From this functions usage we know that *
+ * the dest URI cannot be uri->owner */
cur->text = sourceWalker->text;
if (destPrev == NULL) {
/* First segment ever */
@@ -111,7 +114,8 @@ static URI_INLINE UriBool URI_FUNC(CopyPath)(URI_TYPE(Uri) * dest, /* Copies the authority part of an URI over to another. */
static URI_INLINE UriBool URI_FUNC(CopyAuthority)(URI_TYPE(Uri) * dest,
const URI_TYPE(Uri) * source) {
- /* TODO dest shallow or deep? */
+ /* From this functions usage we know that *
+ * the dest URI cannot be uri->owner */
/* Copy userInfo */
dest->userInfo = source->userInfo;
@@ -204,12 +208,7 @@ int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absDest, }
URI_FUNC(ResetUri)(absDest);
- /*
- TODO
- absBase absolute
-
- SHALLOW wherever possible!
- */
+ /* TODO check absBase absolute */
/* [01/32] if defined(R.scheme) then */
if (relSource->scheme.first != NULL) {
diff --git a/test/test.cpp b/test/test.cpp index 2ada23c..1d91022 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,4 +1,4 @@ -/* +f/* * uriparser - RFC 3986 URI parsing library * * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> @@ -23,6 +23,8 @@ #include <uriparser/Uri.h> #include "CppTest/cpptest.h" #include <memory> +#include <stdio.h> +#include <wchar.h> using namespace Test; using namespace std; |