Commit 22480f2e authored by Nils Goroll's avatar Nils Goroll

straighten out the rest of the blob vmod enum handling

parent 38f712a6
...@@ -11,7 +11,8 @@ libvmod_blob_la_SOURCES = \ ...@@ -11,7 +11,8 @@ libvmod_blob_la_SOURCES = \
url.c \ url.c \
wb.h \ wb.h \
wb.c \ wb.c \
tbl_encodings.h tbl_encodings.h \
tbl_case.h
base64.o: base64.c base64.h base64.o: base64.c base64.h
......
/*
* this order MUST be preserved, since enum case_e LOWER and UPPER are used to
* index the array of cached encodings for the blob object.
*/
VMODENUM(LOWER)
VMODENUM(UPPER)
VMODENUM(DEFAULT)
#undef VMODENUM
...@@ -124,6 +124,15 @@ parse_encoding(VCL_ENUM e) ...@@ -124,6 +124,15 @@ parse_encoding(VCL_ENUM e)
WRONG("illegal encoding enum"); WRONG("illegal encoding enum");
} }
static enum case_e
parse_case(VCL_ENUM e)
{
#define VMODENUM(n) if (e == vmod_enum_ ## n) return(n);
#include "tbl_case.h"
WRONG("illegal case enum");
}
static inline size_t static inline size_t
decode_l_va(enum encoding dec, const char * const p, va_list ap) decode_l_va(enum encoding dec, const char * const p, va_list ap)
{ {
...@@ -154,15 +163,6 @@ err_decode(VRT_CTX, const char *enc) ...@@ -154,15 +163,6 @@ err_decode(VRT_CTX, const char *enc)
} }
} }
static inline enum case_e
parse_case(VCL_ENUM case_s)
{
if (case_s == vmod_enum_DEFAULT) return(DEFAULT);
if (case_s == vmod_enum_LOWER) return(LOWER);
if (case_s == vmod_enum_UPPER) return(UPPER);
WRONG("illegal case enum");
}
static inline int static inline int
encodes_hex(enum encoding enc) encodes_hex(enum encoding enc)
{ {
......
...@@ -31,25 +31,21 @@ ...@@ -31,25 +31,21 @@
#include <sys/types.h> #include <sys/types.h>
enum encoding { enum encoding {
IDENTITY = 1, _INVALID = 0,
BASE64, #define VMODENUM(x) x,
BASE64URL, #include "tbl_encodings.h"
BASE64URLNOPAD,
HEX,
URL,
__MAX_ENCODING __MAX_ENCODING
}; };
#define AENC(enc) assert((enc) >= IDENTITY && (enc) < __MAX_ENCODING) #define AENC(enc) assert((enc) > _INVALID && (enc) < __MAX_ENCODING)
/* /*
* The enums MUST appear in this order, since LOWER and UPPER are used to * The enums MUST appear in this order, since LOWER and UPPER are used to
* index the array of cached encodings for the blob object. * index the array of cached encodings for the blob object.
*/ */
enum case_e { enum case_e {
LOWER, #define VMODENUM(x) x,
UPPER, #include "tbl_case.h"
DEFAULT,
}; };
/* /*
......
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