[build-vmoddir] 1a7aff5f2 build: rm vmod/hex.h
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Thu Jan 7 11:40:10 UTC 2021
commit 1a7aff5f23066d8fa005ffd2250948b6bf70d5fa
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Thu Jan 7 11:38:48 2021 +0100
build: rm vmod/hex.h
diff --git a/vmod/Makefile.am b/vmod/Makefile.am
index 8a4ab5f41..8888a24c0 100644
--- a/vmod/Makefile.am
+++ b/vmod/Makefile.am
@@ -22,7 +22,6 @@ libvmod_blob_la_SOURCES = \
vmod_blob.h \
id.c \
base64.c \
- hex.h \
hex.c \
url.c \
tbl_encodings.h \
diff --git a/vmod/base64.c b/vmod/base64.c
index 909dc11e3..06d6b6cef 100644
--- a/vmod/base64.c
+++ b/vmod/base64.c
@@ -36,9 +36,6 @@
#include "vmod_blob.h"
-#define ILL ((int8_t) 127)
-#define PAD ((int8_t) 126)
-
static const struct b64_alphabet {
const char b64[64];
const int8_t i64[256];
diff --git a/vmod/hex.c b/vmod/hex.c
index b95e45e90..539ab87a7 100644
--- a/vmod/hex.c
+++ b/vmod/hex.c
@@ -38,8 +38,6 @@
#include "vmod_blob.h"
-#include "hex.h"
-
const char hex_alphabet[][16] = {
"0123456789abcdef",
"0123456789ABCDEF"
@@ -50,7 +48,7 @@ const char hex_alphabet[][16] = {
* hex digits with their binary values. This fits all of the hex digits
* into 55 bytes (cacheline friendly).
*/
-const uint8_t nibble[] = {
+const uint8_t hex_nibble[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10, 11, 12,
13, 14, 15, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
@@ -74,7 +72,7 @@ hex_decode_l(size_t l)
static inline char
hex2byte(const unsigned char hi, const unsigned char lo)
{
- return ((nibble[hi - '0'] << 4) | nibble[lo - '0']);
+ return ((hex_nibble[hi - '0'] << 4) | hex_nibble[lo - '0']);
}
ssize_t
diff --git a/vmod/hex.h b/vmod/hex.h
deleted file mode 100644
index 203a95aaa..000000000
--- a/vmod/hex.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * Copyright 2016 UPLEX - Nils Goroll Systemoptimierung
- * All rights reserved.
- *
- * Authors: Nils Goroll <nils.goroll at uplex.de>
- * Geoffrey Simmons <geoffrey.simmons at uplex.de>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * 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>
-
-#define ILL ((int8_t) 127)
-
-/* These are defined in hex.c */
-
-extern const char hex_alphabet[][16];
-
-extern const uint8_t nibble[];
diff --git a/vmod/url.c b/vmod/url.c
index 79fdc39b5..9ce272ed8 100644
--- a/vmod/url.c
+++ b/vmod/url.c
@@ -36,8 +36,6 @@
#include "vmod_blob.h"
-#include "hex.h"
-
/* Decoder states */
enum state_e {
NORMAL,
@@ -155,7 +153,7 @@ url_decode(const enum encoding dec, blob_dest_t buf,
break;
case PERCENT:
if (isoutofrange(*s) ||
- (nib = nibble[*s - '0']) == ILL) {
+ (nib = hex_nibble[*s - '0']) == ILL) {
errno = EINVAL;
return (-1);
}
@@ -167,7 +165,7 @@ url_decode(const enum encoding dec, blob_dest_t buf,
return (-1);
}
if (isoutofrange(*s) ||
- (nib2 = nibble[*s - '0']) == ILL) {
+ (nib2 = hex_nibble[*s - '0']) == ILL) {
errno = EINVAL;
return (-1);
}
diff --git a/vmod/vmod_blob.h b/vmod/vmod_blob.h
index fd728a93f..4574bdf9f 100644
--- a/vmod/vmod_blob.h
+++ b/vmod/vmod_blob.h
@@ -91,6 +91,11 @@ ssize_t encode_f(const enum encoding enc, const enum case_e kase,
blob_dest_t buf, blob_len_t buflen,
blob_src_t in, blob_len_t inlen);
+/* Special lookup characters */
+
+#define ILL ((int8_t) 127)
+#define PAD ((int8_t) 126)
+
/*
* General interface for a decoder: decode the concatenation of strings
* (obtained from STRANDS) into buf, and return the length of decoded
@@ -135,6 +140,9 @@ len_f hex_decode_l;
encode_f hex_encode;
decode_f hex_decode;
+extern const char hex_alphabet[][16];
+extern const uint8_t hex_nibble[];
+
/* url.c */
len_f url_encode_l;
len_f url_decode_l;
More information about the varnish-commit
mailing list