summaryrefslogtreecommitdiff
path: root/src/UriParseBase.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/UriParseBase.c')
-rw-r--r--src/UriParseBase.c73
1 files changed, 34 insertions, 39 deletions
diff --git a/src/UriParseBase.c b/src/UriParseBase.c
index 3a4aa08..0ee66d4 100644
--- a/src/UriParseBase.c
+++ b/src/UriParseBase.c
@@ -38,53 +38,48 @@
*/
#ifndef URI_DOXYGEN
-# include "UriParseBase.h"
+# include "UriParseBase.h"
#endif
+void uriWriteQuadToDoubleByte(const unsigned char * hexDigits, int digitCount,
+ unsigned char * output) {
+ switch (digitCount) {
+ case 1:
+ /* 0x___? -> \x00 \x0? */
+ output[0] = 0;
+ output[1] = hexDigits[0];
+ break;
+ case 2:
+ /* 0x__?? -> \0xx \x?? */
+ output[0] = 0;
+ output[1] = 16 * hexDigits[0] + hexDigits[1];
+ break;
-void uriWriteQuadToDoubleByte(const unsigned char * hexDigits, int digitCount, unsigned char * output) {
- switch (digitCount) {
- case 1:
- /* 0x___? -> \x00 \x0? */
- output[0] = 0;
- output[1] = hexDigits[0];
- break;
+ case 3:
+ /* 0x_??? -> \0x? \x?? */
+ output[0] = hexDigits[0];
+ output[1] = 16 * hexDigits[1] + hexDigits[2];
+ break;
- case 2:
- /* 0x__?? -> \0xx \x?? */
- output[0] = 0;
- output[1] = 16 * hexDigits[0] + hexDigits[1];
- break;
-
- case 3:
- /* 0x_??? -> \0x? \x?? */
- output[0] = hexDigits[0];
- output[1] = 16 * hexDigits[1] + hexDigits[2];
- break;
-
- case 4:
- /* 0x???? -> \0?? \x?? */
- output[0] = 16 * hexDigits[0] + hexDigits[1];
- output[1] = 16 * hexDigits[2] + hexDigits[3];
- break;
-
- }
+ case 4:
+ /* 0x???? -> \0?? \x?? */
+ output[0] = 16 * hexDigits[0] + hexDigits[1];
+ output[1] = 16 * hexDigits[2] + hexDigits[3];
+ break;
+ }
}
-
-
unsigned char uriGetOctetValue(const unsigned char * digits, int digitCount) {
- switch (digitCount) {
- case 1:
- return digits[0];
-
- case 2:
- return 10 * digits[0] + digits[1];
+ switch (digitCount) {
+ case 1:
+ return digits[0];
- case 3:
- default:
- return 100 * digits[0] + 10 * digits[1] + digits[2];
+ case 2:
+ return 10 * digits[0] + digits[1];
- }
+ case 3:
+ default:
+ return 100 * digits[0] + 10 * digits[1] + digits[2];
+ }
}