From 1bc717dc54b9964e7c62082b34d2d74e3daaa6a6 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 28 Aug 2016 00:20:02 -0400 Subject: add te parser (not working) --- include/fhp/fhp.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'include/fhp/fhp.h') diff --git a/include/fhp/fhp.h b/include/fhp/fhp.h index 9d680a9..d537a6e 100644 --- a/include/fhp/fhp.h +++ b/include/fhp/fhp.h @@ -34,6 +34,11 @@ typedef enum { FHP_ERR_INVALID_ERROR, FHP_ERR_BUFFER_TOO_SMALL, FHP_ERR_INVALID_BODY_TYPE, + FHP_ERR_TOO_MANY_TES, + FHP_ERR_INVALID_CHAR_IN_TE_NAME, + FHP_ERR_INVALID_CHAR_IN_TE, + FHP_ERR_BAD_TE_STATE, + FHP_ERR_TE_PARSER_DONE, FHP_ERR_LAST } fhp_err_t; @@ -103,6 +108,46 @@ typedef struct { void fhp_env_init(fhp_env_t * const env); fhp_env_t *fhp_get_default_env(void); +// +// transfer encoding parser functions +// + +typedef enum { + FHP_TE_STATE_INIT, + FHP_TE_STATE_NAME, + FHP_TE_STATE_IGNORE_UNTIL_COMMA, + FHP_TE_STATE_SPACE, + FHP_TE_STATE_ERROR, + FHP_TE_STATE_DONE, + FHP_TE_STATE_LAST +} fhp_te_state_t; + +#define FHP_TE_MAX_BUF_SIZE 16 +#define FHP_TE_MAX_TES 4 + +typedef struct { + fhp_te_state_t state; + + uint8_t buf[FHP_TE_MAX_BUF_SIZE]; + size_t len; + + uint32_t buf_hash; + + uint32_t tes[FHP_TE_MAX_TES]; + size_t num_tes; + + fhp_err_t err; +} fhp_te_parser_t; + +fhp_err_t +fhp_te_parser_init(fhp_te_parser_t * const te); + +fhp_err_t +fhp_te_parser_push(fhp_te_parser_t *, uint8_t * const, size_t); + +fhp_err_t +fhp_te_parser_done(fhp_te_parser_t * const); + // // context functions // -- cgit v1.2.3