[master] b6f071a Rename this (minimal) base64 implementation to enforce uniqueness of sourcefile names over the project.
Poul-Henning Kamp
phk at FreeBSD.org
Thu Nov 16 08:03:04 UTC 2017
commit b6f071ad57aa36ee06271e0b224168c2c2af8b95
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Nov 16 08:01:37 2017 +0000
Rename this (minimal) base64 implementation to enforce uniqueness
of sourcefile names over the project.
diff --git a/bin/varnishncsa/Makefile.am b/bin/varnishncsa/Makefile.am
index cbed83b..60345be 100644
--- a/bin/varnishncsa/Makefile.am
+++ b/bin/varnishncsa/Makefile.am
@@ -9,8 +9,8 @@ bin_PROGRAMS = varnishncsa
varnishncsa_SOURCES = \
varnishncsa.c \
varnishncsa_options.h \
- base64.h \
- base64.c
+ b64.h \
+ b64.c
varnishncsa_CFLAGS = \
@SAN_CFLAGS@
diff --git a/bin/varnishncsa/b64.c b/bin/varnishncsa/b64.c
new file mode 100644
index 0000000..5d398f4
--- /dev/null
+++ b/bin/varnishncsa/b64.c
@@ -0,0 +1,90 @@
+/*
+ * Written by Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * This file is in the public domain.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "b64.h"
+
+static const char b64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static char i64[256];
+
+void
+VB64_init(void)
+{
+ int i;
+ const char *p;
+
+ for (i = 0; i < 256; i++)
+ i64[i] = -1;
+ for (p = b64, i = 0; *p; p++, i++)
+ i64[(int)*p] = (char)i;
+ i64['='] = 0;
+}
+
+int
+VB64_decode(char *d, unsigned dlen, const char *s, const char *e)
+{
+ unsigned u, v, l;
+ int i;
+
+ if (e == NULL)
+ e = s + strlen(s);
+ u = 0;
+ l = 0;
+ while (s < e) {
+ for (v = 0; s < e && v < 4; v++) {
+ i = i64[(int)*s++];
+ if (i < 0)
+ return (-1);
+ u <<= 6;
+ u |= i;
+ }
+ for (v = 0; v < 3; v++) {
+ if (l >= dlen - 1)
+ return (-1);
+ *d = (u >> 16) & 0xff;
+ u <<= 8;
+ l++;
+ d++;
+ }
+ }
+ *d = '\0';
+ return (0);
+}
+
+#ifdef TEST_DRIVER
+
+#include <stdio.h> // for test-prog
+
+const char *test1 =
+"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz"
+"IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg"
+"dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu"
+"dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo"
+"ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
+
+int
+main(int argc, char **argv)
+{
+ int i;
+ char buf[BUFSIZ];
+ unsigned l;
+
+ (void)argc;
+ (void)argv;
+
+ VB64_init();
+ l = sizeof buf;
+ VB64_decode(buf, l, test1, NULL);
+ printf("%s\n", buf);
+ return (0);
+}
+#endif
diff --git a/bin/varnishncsa/b64.h b/bin/varnishncsa/b64.h
new file mode 100644
index 0000000..526ae19
--- /dev/null
+++ b/bin/varnishncsa/b64.h
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2011 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * 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.
+ *
+ */
+
+void VB64_init(void);
+int VB64_decode(char *d, unsigned dlen, const char *s, const char *e);
diff --git a/bin/varnishncsa/base64.c b/bin/varnishncsa/base64.c
deleted file mode 100644
index d7b2b89..0000000
--- a/bin/varnishncsa/base64.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Written by Poul-Henning Kamp <phk at phk.freebsd.dk>
- *
- * This file is in the public domain.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "base64.h"
-
-static const char b64[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-static char i64[256];
-
-void
-VB64_init(void)
-{
- int i;
- const char *p;
-
- for (i = 0; i < 256; i++)
- i64[i] = -1;
- for (p = b64, i = 0; *p; p++, i++)
- i64[(int)*p] = (char)i;
- i64['='] = 0;
-}
-
-int
-VB64_decode(char *d, unsigned dlen, const char *s, const char *e)
-{
- unsigned u, v, l;
- int i;
-
- if (e == NULL)
- e = s + strlen(s);
- u = 0;
- l = 0;
- while (s < e) {
- for (v = 0; s < e && v < 4; v++) {
- i = i64[(int)*s++];
- if (i < 0)
- return (-1);
- u <<= 6;
- u |= i;
- }
- for (v = 0; v < 3; v++) {
- if (l >= dlen - 1)
- return (-1);
- *d = (u >> 16) & 0xff;
- u <<= 8;
- l++;
- d++;
- }
- }
- *d = '\0';
- return (0);
-}
-
-#ifdef TEST_DRIVER
-
-#include <stdio.h> // for test-prog
-
-const char *test1 =
-"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz"
-"IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg"
-"dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu"
-"dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo"
-"ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
-
-int
-main(int argc, char **argv)
-{
- int i;
- char buf[BUFSIZ];
- unsigned l;
-
- (void)argc;
- (void)argv;
-
- VB64_init();
- l = sizeof buf;
- VB64_decode(buf, l, test1, NULL);
- printf("%s\n", buf);
- return (0);
-}
-#endif
diff --git a/bin/varnishncsa/base64.h b/bin/varnishncsa/base64.h
deleted file mode 100644
index 526ae19..0000000
--- a/bin/varnishncsa/base64.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2011 Varnish Software AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
- *
- * 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.
- *
- */
-
-void VB64_init(void);
-int VB64_decode(char *d, unsigned dlen, const char *s, const char *e);
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 18eec35..cc5cb05 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -57,7 +57,7 @@
#define VOPT_DEFINITION
#define VOPT_INC "varnishncsa_options.h"
-#include "base64.h"
+#include "b64.h"
#include "vapi/vsl.h"
#include "vapi/voptget.h"
#include "vas.h"
More information about the varnish-commit
mailing list