2
* uriparser - RFC 3986 URI parsing library
4
* Copyright (C) 2007, Weijia Song <songweijia@gmail.com>
5
* Copyright (C) 2007, Sebastian Pipping <webmaster@hartwork.org>
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
12
* * Redistributions of source code must retain the above
13
* copyright notice, this list of conditions and the following
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.
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
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.
41
# include "UriParseBase.h"
46
void uriWriteQuadToDoubleByte(const unsigned char * hexDigits, int digitCount, unsigned char * output) {
49
/* 0x___? -> \x00 \x0? */
51
output[1] = hexDigits[0];
55
/* 0x__?? -> \0xx \x?? */
57
output[1] = 16 * hexDigits[0] + hexDigits[1];
61
/* 0x_??? -> \0x? \x?? */
62
output[0] = hexDigits[0];
63
output[1] = 16 * hexDigits[1] + hexDigits[2];
67
/* 0x???? -> \0?? \x?? */
68
output[0] = 16 * hexDigits[0] + hexDigits[1];
69
output[1] = 16 * hexDigits[2] + hexDigits[3];
77
unsigned char uriGetOctetValue(const unsigned char * digits, int digitCount) {
83
return 10 * digits[0] + digits[1];
87
return 100 * digits[0] + 10 * digits[1] + digits[2];