From 0089842c454e51367a10dd86856cca8884bd2f01 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 28 Aug 2016 00:37:50 -0400 Subject: add internal.h and te-parser.c --- internal.h | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 internal.h (limited to 'internal.h') diff --git a/internal.h b/internal.h new file mode 100644 index 0000000..94caebd --- /dev/null +++ b/internal.h @@ -0,0 +1,200 @@ +#include +#include "fhp/fhp.h" + +#define UNUSED(a) ((void) (a)) + +#define CASE_ALNUM_CHARS \ + case '0': \ + case '1': \ + case '2': \ + case '3': \ + case '4': \ + case '5': \ + case '6': \ + case '7': \ + case '8': \ + case '9': \ + case 'a': \ + case 'b': \ + case 'c': \ + case 'd': \ + case 'e': \ + case 'f': \ + case 'g': \ + case 'h': \ + case 'i': \ + case 'j': \ + case 'k': \ + case 'l': \ + case 'm': \ + case 'n': \ + case 'o': \ + case 'p': \ + case 'q': \ + case 'r': \ + case 's': \ + case 't': \ + case 'u': \ + case 'v': \ + case 'w': \ + case 'x': \ + case 'y': \ + case 'z': \ + case 'A': \ + case 'B': \ + case 'C': \ + case 'D': \ + case 'E': \ + case 'F': \ + case 'G': \ + case 'H': \ + case 'I': \ + case 'J': \ + case 'K': \ + case 'L': \ + case 'M': \ + case 'N': \ + case 'O': \ + case 'P': \ + case 'Q': \ + case 'R': \ + case 'S': \ + case 'T': \ + case 'U': \ + case 'V': \ + case 'W': \ + case 'X': \ + case 'Y': \ + case 'Z': + +#define CASE_DIGIT_CHARS \ + case '0': \ + case '1': \ + case '2': \ + case '3': \ + case '4': \ + case '5': \ + case '6': \ + case '7': \ + case '8': \ + case '9': + +#define CASE_HEX_ALPHA_CHARS \ + case 'a': \ + case 'b': \ + case 'c': \ + case 'd': \ + case 'e': \ + case 'f': \ + case 'A': \ + case 'B': \ + case 'C': \ + case 'D': \ + case 'E': \ + case 'F': + +// +// rfc7230, Appendix B +// https://tools.ietf.org/html/rfc7230 +// +// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / +// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA +// token = 1*tchar +// +#define CASE_TOKEN_CHARS \ + CASE_ALNUM_CHARS \ + case '!': \ + case '#': \ + case '$': \ + case '%': \ + case '&': \ + case '\'': \ + case '*': \ + case '+': \ + case '-': \ + case '.': \ + case '^': \ + case '_': \ + case '|': \ + case '~': \ + +#define CASE_URL_CHARS \ + CASE_ALNUM_CHARS \ + case '!': \ + case '"': \ + case '#': \ + case '$': \ + case '&': \ + case '\'': \ + case '(': \ + case ')': \ + case '*': \ + case '+': \ + case ',': \ + case '-': \ + case '.': \ + case '/': \ + case ':': \ + case ';': \ + case '<': \ + case '=': \ + case '>': \ + case '?': \ + case '@': \ + case '[': \ + case '\\': \ + case ']': \ + case '^': \ + case '_': \ + case '`': \ + case '{': \ + case '|': \ + case '}': \ + case '~': + +#define CASE_VISUAL_CHARS \ + CASE_URL_CHARS \ + case '%': + +#define CASE_VERSION_CHARS \ + CASE_TOKEN_CHARS \ + case '/': + +#define CASE_TE_CHARS \ + CASE_ALNUM_CHARS \ + case '-': + +// +// rfc7230, Appendix B +// https://tools.ietf.org/html/rfc7230 +// +// OWS = *( SP / HTAB ) +// +#define CASE_OWS_CHARS \ + case ' ': \ + case '\t': + +// +// strings +// + +typedef enum { + FHP_STR_GET, + FHP_STR_POST, + FHP_STR_HEAD, + FHP_STR_PUT, + FHP_STR_DELETE, + FHP_STR_OPTIONS, + FHP_STR_HTTP_10, + FHP_STR_HTTP_11, + FHP_STR_CONTENT_LENGTH, + FHP_STR_TRANSFER_ENCODING, + FHP_STR_GZIP, + FHP_STR_X_GZIP, + FHP_STR_DEFLATE, + FHP_STR_X_DEFLATE, + FHP_STR_COMPRESS, + FHP_STR_X_COMPRESS, + FHP_STR_CHUNKED, + FHP_STR_LAST +} fhp_str_t; -- cgit v1.2.3