1 /*
2  * uriparser - RFC 3986 URI parsing library
3  *
4  * Copyright (C) 2007, Weijia Song <songweijia@gmail.com>
5  * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org>
6  * All rights reserved.
7  *
8  * Redistribution  and use in source and binary forms, with or without
9  * modification,  are permitted provided that the following conditions
10  * are met:
11  *
12  *     * Redistributions   of  source  code  must  retain  the   above
13  *       copyright  notice, this list of conditions and the  following
14  *       disclaimer.
15  *
16  *     * Redistributions  in  binary  form must  reproduce  the  above
17  *       copyright  notice, this list of conditions and the  following
18  *       disclaimer   in  the  documentation  and/or  other  materials
19  *       provided with the distribution.
20  *
21  *     * Neither  the name of the <ORGANIZATION> nor the names of  its
22  *       contributors  may  be  used to endorse  or  promote  products
23  *       derived  from  this software without specific  prior  written
24  *       permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT  NOT
28  * LIMITED  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS
29  * FOR  A  PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT  SHALL  THE
30  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31  * INCIDENTAL,    SPECIAL,   EXEMPLARY,   OR   CONSEQUENTIAL   DAMAGES
32  * (INCLUDING,  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33  * SERVICES;  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35  * STRICT  LIABILITY,  OR  TORT (INCLUDING  NEGLIGENCE  OR  OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
37  * OF THE POSSIBILITY OF SUCH DAMAGE.
38  */
39 
40 #if (defined(URI_PASS_ANSI) && !defined(URI_COMMON_H_ANSI)) \
41 	|| (defined(URI_PASS_UNICODE) && !defined(URI_COMMON_H_UNICODE)) \
42 	|| (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE))
43 /* What encodings are enabled? */
44 #include "UriDefsConfig.h"
45 #if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE))
46 /* Include SELF twice */
47 # ifdef URI_ENABLE_ANSI
48 #  define URI_PASS_ANSI 1
49 #  include "UriCommon.h"
50 #  undef URI_PASS_ANSI
51 # endif
52 # ifdef URI_ENABLE_UNICODE
53 #  define URI_PASS_UNICODE 1
54 #  include "UriCommon.h"
55 #  undef URI_PASS_UNICODE
56 # endif
57 /* Only one pass for each encoding */
58 #elif (defined(URI_PASS_ANSI) && !defined(URI_COMMON_H_ANSI) \
59 	&& defined(URI_ENABLE_ANSI)) || (defined(URI_PASS_UNICODE) \
60 	&& !defined(URI_COMMON_H_UNICODE) && defined(URI_ENABLE_UNICODE))
61 # ifdef URI_PASS_ANSI
62 #  define URI_COMMON_H_ANSI 1
63 #  include "UriDefsAnsi.h"
64 # else
65 #  define URI_COMMON_H_UNICODE 1
66 #  include "UriDefsUnicode.h"
67 # endif
68 
69 
70 
71 /* Used to point to from empty path segments.
72  * X.first and X.afterLast must be the same non-NULL value then. */
73 extern const URI_CHAR * const URI_FUNC(SafeToPointTo);
74 extern const URI_CHAR * const URI_FUNC(ConstPwd);
75 extern const URI_CHAR * const URI_FUNC(ConstParent);
76 
77 
78 
79 void URI_FUNC(ResetUri)(URI_TYPE(Uri) * uri);
80 
81 int URI_FUNC(CompareRange)(
82 		const URI_TYPE(TextRange) * a,
83 		const URI_TYPE(TextRange) * b);
84 
85 UriBool URI_FUNC(RemoveDotSegmentsAbsolute)(URI_TYPE(Uri) * uri,
86 		UriMemoryManager * memory);
87 UriBool URI_FUNC(RemoveDotSegments)(URI_TYPE(Uri) * uri, UriBool relative,
88 		UriMemoryManager * memory);
89 UriBool URI_FUNC(RemoveDotSegmentsEx)(URI_TYPE(Uri) * uri,
90 		UriBool relative, UriBool pathOwned, UriMemoryManager * memory);
91 
92 unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig);
93 URI_CHAR URI_FUNC(HexToLetter)(unsigned int value);
94 URI_CHAR URI_FUNC(HexToLetterEx)(unsigned int value, UriBool uppercase);
95 
96 UriBool URI_FUNC(IsHostSet)(const URI_TYPE(Uri) * uri);
97 
98 UriBool URI_FUNC(CopyPath)(URI_TYPE(Uri) * dest, const URI_TYPE(Uri) * source,
99 		UriMemoryManager * memory);
100 UriBool URI_FUNC(CopyAuthority)(URI_TYPE(Uri) * dest,
101 		const URI_TYPE(Uri) * source, UriMemoryManager * memory);
102 
103 UriBool URI_FUNC(FixAmbiguity)(URI_TYPE(Uri) * uri, UriMemoryManager * memory);
104 void URI_FUNC(FixEmptyTrailSegment)(URI_TYPE(Uri) * uri,
105 		UriMemoryManager * memory);
106 
107 
108 #endif
109 #endif
110