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 = \
url.c \
wb.h \
wb.c \
tbl_encodings.h
tbl_encodings.h \
tbl_case.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)
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
decode_l_va(enum encoding dec, const char * const p, va_list ap)
{
......@@ -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
encodes_hex(enum encoding enc)
{
......
......@@ -31,25 +31,21 @@
#include <sys/types.h>
enum encoding {
IDENTITY = 1,
BASE64,
BASE64URL,
BASE64URLNOPAD,
HEX,
URL,
_INVALID = 0,
#define VMODENUM(x) x,
#include "tbl_encodings.h"
__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
* index the array of cached encodings for the blob object.
*/
enum case_e {
LOWER,
UPPER,
DEFAULT,
#define VMODENUM(x) x,
#include "tbl_case.h"
};
/*
......
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