Commit 9458b528 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

build: rm vmod/hex.h

parent 2a453c87
......@@ -22,7 +22,6 @@ libvmod_blob_la_SOURCES = \
vmod_blob.h \
id.c \
base64.c \
hex.h \
hex.c \
url.c \
tbl_encodings.h \
......
......@@ -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];
......
......@@ -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
......
/*-
* Copyright 2016 UPLEX - Nils Goroll Systemoptimierung
* All rights reserved.
*
* Authors: Nils Goroll <nils.goroll@uplex.de>
* Geoffrey Simmons <geoffrey.simmons@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[];
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment