[master] 38f712a use a table file for vmod enum to c enum
Nils Goroll
nils.goroll at uplex.de
Sun Dec 10 11:45:07 UTC 2017
commit 38f712a62fcfa875d90c41a0f001ce3267e3069a
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Sun Dec 10 12:41:36 2017 +0100
use a table file for vmod enum to c enum
diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am
index 888895a..9be1c7d 100644
--- a/lib/libvmod_blob/Makefile.am
+++ b/lib/libvmod_blob/Makefile.am
@@ -10,7 +10,8 @@ libvmod_blob_la_SOURCES = \
hex.c \
url.c \
wb.h \
- wb.c
+ wb.c \
+ tbl_encodings.h
base64.o: base64.c base64.h
diff --git a/lib/libvmod_blob/tbl_encodings.h b/lib/libvmod_blob/tbl_encodings.h
new file mode 100644
index 0000000..2319e9c
--- /dev/null
+++ b/lib/libvmod_blob/tbl_encodings.h
@@ -0,0 +1,7 @@
+VMODENUM(BASE64)
+VMODENUM(BASE64URL)
+VMODENUM(BASE64URLNOPAD)
+VMODENUM(HEX)
+VMODENUM(IDENTITY)
+VMODENUM(URL)
+#undef VMODENUM
diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c
index 693f994..7819701 100644
--- a/lib/libvmod_blob/vmod_blob.c
+++ b/lib/libvmod_blob/vmod_blob.c
@@ -119,12 +119,8 @@ static const struct vmod_priv null_blob[1] =
static enum encoding
parse_encoding(VCL_ENUM e)
{
- if (e == vmod_enum_BASE64) return(BASE64);
- if (e == vmod_enum_BASE64URL) return(BASE64URL);
- if (e == vmod_enum_BASE64URLNOPAD) return(BASE64URLNOPAD);
- if (e == vmod_enum_HEX) return(HEX);
- if (e == vmod_enum_IDENTITY) return(IDENTITY);
- if (e == vmod_enum_URL) return(URL);
+#define VMODENUM(n) if (e == vmod_enum_ ## n) return(n);
+#include "tbl_encodings.h"
WRONG("illegal encoding enum");
}
More information about the varnish-commit
mailing list