[master] 1b1e7892e Kill base64.h from vmod_blob

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Nov 22 14:28:05 UTC 2019


commit 1b1e7892ecb00ddf35b305c439de8f3a5aeb109c
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Nov 22 15:24:23 2019 +0100

    Kill base64.h from vmod_blob
    
    It's only ever used by base64.c, so we might as well put it there.

diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am
index fafce9acd..040b1aceb 100644
--- a/lib/libvmod_blob/Makefile.am
+++ b/lib/libvmod_blob/Makefile.am
@@ -4,7 +4,6 @@ libvmod_blob_la_SOURCES = \
 	vmod_blob.c \
 	vmod_blob.h \
 	id.c \
-	base64.h \
 	base64.c \
 	hex.h \
 	hex.c \
@@ -12,7 +11,5 @@ libvmod_blob_la_SOURCES = \
 	tbl_encodings.h \
 	tbl_case.h
 
-base64.o: base64.c base64.h
-
 # Use vmodtool.py generated automake boilerplate
 include $(srcdir)/automake_boilerplate.am
diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c
index 3c6eb852c..63f45a8c8 100644
--- a/lib/libvmod_blob/base64.c
+++ b/lib/libvmod_blob/base64.c
@@ -32,8 +32,134 @@
 #include "vrt.h"
 #include "vas.h"
 
-#include "base64.h"
+#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];
+	const int padding;
+} b64_alphabet[] = {
+	[BASE64] = {
+		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
+		"ghijklmnopqrstuvwxyz0123456789+/",
+		{
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL,  62, ILL, ILL, ILL,  63, /* +, -    */
+			 52,  53,  54,  55,  56,  57,  58,  59, /* 0 - 7   */
+			 60,  61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */
+			ILL,   0,   1,   2,   3,   4,   5,   6, /* A - G   */
+			  7,   8,   9,  10,  11,  12,  13,  14, /* H - O   */
+			 15,  16,  17,  18,  19,  20,  21,  22, /* P - W   */
+			 23,  24,  25, ILL, ILL, ILL, ILL, ILL, /* X, Y, Z */
+			ILL,  26,  27,  28,  29,  30,  31,  32, /* a - g   */
+			 33,  34,  35,  36,  37,  38,  39,  40, /* h - o   */
+			 41,  42,  43,  44,  45,  46,  47,  48, /* p - w   */
+			 49,  50,  51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+		},
+		'='
+	},
+	[BASE64URL] = {
+		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
+		"ghijklmnopqrstuvwxyz0123456789-_",
+		{
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL,  62, ILL, ILL, /* -       */
+			 52,  53,  54,  55,  56,  57,  58,  59, /* 0 - 7   */
+			 60,  61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */
+			ILL,   0,   1,   2,   3,   4,   5,   6, /* A - G   */
+			  7,   8,   9,  10,  11,  12,  13,  14, /* H - O   */
+			 15,  16,  17,  18,  19,  20,  21,  22, /* P - W   */
+			 23,  24,  25, ILL, ILL, ILL, ILL,  63, /* X-Z, _  */
+			ILL,  26,  27,  28,  29,  30,  31,  32, /* a - g   */
+			 33,  34,  35,  36,  37,  38,  39,  40, /* h - o   */
+			 41,  42,  43,  44,  45,  46,  47,  48, /* p - w   */
+			 49,  50,  51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+		},
+		'='
+	},
+	[BASE64URLNOPAD] = {
+		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
+		"ghijklmnopqrstuvwxyz0123456789-_",
+		{
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL,  62, ILL, ILL, /* -       */
+			 52,  53,  54,  55,  56,  57,  58,  59, /* 0 - 7   */
+			 60,  61, ILL, ILL, ILL, ILL, ILL, ILL, /* 8, 9    */
+			ILL,   0,   1,   2,   3,   4,   5,   6, /* A - G   */
+			  7,   8,   9,  10,  11,  12,  13,  14, /* H - O   */
+			 15,  16,  17,  18,  19,  20,  21,  22, /* P - W   */
+			 23,  24,  25, ILL, ILL, ILL, ILL,  63, /* X-Z, _  */
+			ILL,  26,  27,  28,  29,  30,  31,  32, /* a - g   */
+			 33,  34,  35,  36,  37,  38,  39,  40, /* h - o   */
+			 41,  42,  43,  44,  45,  46,  47,  48, /* p - w   */
+			 49,  50,  51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
+		},
+		0
+	},
+};
 #define base64_l(l)		(((l) << 2) / 3)
 
 size_t
diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h
deleted file mode 100644
index 962ae22cd..000000000
--- a/lib/libvmod_blob/base64.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*-
- * Copyright 2015-2016 UPLEX - Nils Goroll Systemoptimierung
- * All rights reserved.
- *
- * Authors: Nils Goroll <nils.goroll at uplex.de>
- *          Geoffrey Simmons <geoffrey.simmons at 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 "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];
-	const int padding;
-} b64_alphabet[] = {
-	[BASE64] = {
-		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
-		"ghijklmnopqrstuvwxyz0123456789+/",
-		{
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL,  62, ILL, ILL, ILL,  63, /* +, -    */
-			 52,  53,  54,  55,  56,  57,  58,  59, /* 0 - 7   */
-			 60,  61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */
-			ILL,   0,   1,   2,   3,   4,   5,   6, /* A - G   */
-			  7,   8,   9,  10,  11,  12,  13,  14, /* H - O   */
-			 15,  16,  17,  18,  19,  20,  21,  22, /* P - W   */
-			 23,  24,  25, ILL, ILL, ILL, ILL, ILL, /* X, Y, Z */
-			ILL,  26,  27,  28,  29,  30,  31,  32, /* a - g   */
-			 33,  34,  35,  36,  37,  38,  39,  40, /* h - o   */
-			 41,  42,  43,  44,  45,  46,  47,  48, /* p - w   */
-			 49,  50,  51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-		},
-		'='
-	},
-	[BASE64URL] = {
-		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
-		"ghijklmnopqrstuvwxyz0123456789-_",
-		{
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL,  62, ILL, ILL, /* -       */
-			 52,  53,  54,  55,  56,  57,  58,  59, /* 0 - 7   */
-			 60,  61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */
-			ILL,   0,   1,   2,   3,   4,   5,   6, /* A - G   */
-			  7,   8,   9,  10,  11,  12,  13,  14, /* H - O   */
-			 15,  16,  17,  18,  19,  20,  21,  22, /* P - W   */
-			 23,  24,  25, ILL, ILL, ILL, ILL,  63, /* X-Z, _  */
-			ILL,  26,  27,  28,  29,  30,  31,  32, /* a - g   */
-			 33,  34,  35,  36,  37,  38,  39,  40, /* h - o   */
-			 41,  42,  43,  44,  45,  46,  47,  48, /* p - w   */
-			 49,  50,  51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-		},
-		'='
-	},
-	[BASE64URLNOPAD] = {
-		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
-		"ghijklmnopqrstuvwxyz0123456789-_",
-		{
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL,  62, ILL, ILL, /* -       */
-			 52,  53,  54,  55,  56,  57,  58,  59, /* 0 - 7   */
-			 60,  61, ILL, ILL, ILL, ILL, ILL, ILL, /* 8, 9    */
-			ILL,   0,   1,   2,   3,   4,   5,   6, /* A - G   */
-			  7,   8,   9,  10,  11,  12,  13,  14, /* H - O   */
-			 15,  16,  17,  18,  19,  20,  21,  22, /* P - W   */
-			 23,  24,  25, ILL, ILL, ILL, ILL,  63, /* X-Z, _  */
-			ILL,  26,  27,  28,  29,  30,  31,  32, /* a - g   */
-			 33,  34,  35,  36,  37,  38,  39,  40, /* h - o   */
-			 41,  42,  43,  44,  45,  46,  47,  48, /* p - w   */
-			 49,  50,  51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-			ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL,
-		},
-		0
-	},
-};


More information about the varnish-commit mailing list