Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-blobcode
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-blobcode
Commits
3d1dfa39
Commit
3d1dfa39
authored
Apr 08, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factor out common code in hex.c and url.c
parent
2040b8a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
42 deletions
+53
-42
Makefile.am
src/Makefile.am
+1
-0
hex.c
src/hex.c
+16
-16
hex.h
src/hex.h
+35
-0
url.c
src/url.c
+1
-26
No files found.
src/Makefile.am
View file @
3d1dfa39
...
...
@@ -11,6 +11,7 @@ libvmod_blobcode_la_SOURCES = \
id.c
\
base64.h
\
base64.c
\
hex.h
\
hex.c
\
url.c
\
wb.h
\
...
...
src/hex.c
View file @
3d1dfa39
/*-
* Copyright 201
5-201
6 UPLEX - Nils Goroll Systemoptimierung
* Copyright 2016 UPLEX - Nils Goroll Systemoptimierung
* All rights reserved.
*
* Authors: Nils Goroll <nils.goroll@uplex.de>
...
...
@@ -28,26 +28,14 @@
#include <ctype.h>
#include <errno.h>
#include <stdint.h>
#include "vmod_blobcode.h"
#include "hex.h"
#include "vrt.h"
#include "vas.h"
size_t
hex_encode_l
(
size_t
l
)
{
return
((
l
)
<<
1
)
+
1
;
}
size_t
hex_decode_l
(
size_t
l
)
{
return
((
l
)
+
1
)
>>
1
;
}
static
const
char
hex_alphabet
[][
16
]
=
{
const
char
hex_alphabet
[][
16
]
=
{
"0123456789abcdef"
,
"0123456789ABCDEF"
};
...
...
@@ -57,7 +45,7 @@ static const char hex_alphabet[][16] = {
* hex digits with their binary values. This fits all of the hex digits
* into 55 bytes (cacheline friendly).
*/
static
const
uint8_t
nibble
[]
=
{
const
uint8_t
nibble
[]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
10
,
11
,
12
,
13
,
14
,
15
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
...
...
@@ -66,6 +54,18 @@ static const uint8_t nibble[] = {
11
,
12
,
13
,
14
,
15
};
size_t
hex_encode_l
(
size_t
l
)
{
return
((
l
)
<<
1
)
+
1
;
}
size_t
hex_decode_l
(
size_t
l
)
{
return
((
l
)
+
1
)
>>
1
;
}
static
inline
char
hex2byte
(
const
unsigned
char
hi
,
const
unsigned
char
lo
)
{
...
...
src/hex.h
0 → 100644
View file @
3d1dfa39
/*-
* Copyright 2016 UPLEX - Nils Goroll Systemoptimierung
* All rights reserved.
*
* Authors: Nils Goroll <nils.goroll@uplex.de>
* Geoffrey Simmons <geoffrey.simmons@uplex.de>
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
#include <stdint.h>
/* These are defined in hex.c */
extern
const
char
hex_alphabet
[][
16
];
extern
const
uint8_t
nibble
[];
src/url.c
View file @
3d1dfa39
...
...
@@ -27,9 +27,9 @@
*/
#include <errno.h>
#include <stdint.h>
#include "vmod_blobcode.h"
#include "hex.h"
#include "vrt.h"
#include "vas.h"
...
...
@@ -63,31 +63,6 @@ static const uint8_t unreserved[] = {
0x0
,
0x0
,
0x0
,
0x0
,
0x0
,
0x0
,
0x0
,
0x0
};
static
const
char
hex_alphabet
[][
16
]
=
{
"0123456789abcdef"
,
"0123456789ABCDEF"
};
/*
* Shift the ASCII table over so that it begins at '0', and replace the
* hex digits with their binary values. This fits all of the hex digits
* into 55 bytes (cacheline friendly).
*/
static
const
uint8_t
nibble
[]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
10
,
11
,
12
,
13
,
14
,
15
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
10
,
11
,
12
,
13
,
14
,
15
};
static
inline
char
hex2byte
(
const
unsigned
char
hi
,
const
unsigned
char
lo
)
{
return
(
nibble
[
hi
-
'0'
]
<<
4
)
|
nibble
[
lo
-
'0'
];
}
static
inline
int
isunreserved
(
const
uint8_t
c
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment