From b477f7b16f4b7a08d6eaf7f2b6093f14a13123ea Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 28 Aug 2016 15:35:37 -0400 Subject: reorganize methods --- ctx.c | 72 +++++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 32 deletions(-) (limited to 'ctx.c') diff --git a/ctx.c b/ctx.c index e73fba8..3f2f98f 100644 --- a/ctx.c +++ b/ctx.c @@ -1,40 +1,9 @@ #include "internal.h" // -// context functions +// context buffer functions // -static const fhp_ctx_t FHP_DEFAULT_CONTEXT = { - .state = FHP_STATE_INIT, - .user_data = NULL, - .cb = NULL, - .err = FHP_OK, - .ofs = 0, - .buf_len = 0, - .is_hashing = false, - .header_name_hash = 0, - .header_value_parser = FHP_HEADER_VALUE_PARSER_NONE, - .body_type = FHP_BODY_TYPE_NONE, - .content_length = 0, - .num_tes = 0, -}; - -fhp_err_t -fhp_ctx_init( - fhp_ctx_t * const ctx, - fhp_env_t * const env, - fhp_cb_t cb, - void * const user_data -) { - *ctx = FHP_DEFAULT_CONTEXT; - ctx->env = env ? env : fhp_get_default_env(); - ctx->user_data = user_data; - ctx->cb = cb; - - /* return success */ - return FHP_OK; -} - static void fhp_ctx_buf_clear(fhp_ctx_t * const ctx) { // clear buffer @@ -89,6 +58,10 @@ fhp_ctx_buf_push( return FHP_OK; } +// +// method functions +// + static fhp_err_t fhp_ctx_handle_method(fhp_ctx_t * const ctx) { // get method token @@ -115,6 +88,41 @@ fhp_ctx_handle_method(fhp_ctx_t * const ctx) { return FHP_OK; } +// +// context functions +// + +static const fhp_ctx_t FHP_DEFAULT_CONTEXT = { + .state = FHP_STATE_INIT, + .user_data = NULL, + .cb = NULL, + .err = FHP_OK, + .ofs = 0, + .buf_len = 0, + .is_hashing = false, + .header_name_hash = 0, + .header_value_parser = FHP_HEADER_VALUE_PARSER_NONE, + .body_type = FHP_BODY_TYPE_NONE, + .content_length = 0, + .num_tes = 0, +}; + +fhp_err_t +fhp_ctx_init( + fhp_ctx_t * const ctx, + fhp_env_t * const env, + fhp_cb_t cb, + void * const user_data +) { + *ctx = FHP_DEFAULT_CONTEXT; + ctx->env = env ? env : fhp_get_default_env(); + ctx->user_data = user_data; + ctx->cb = cb; + + /* return success */ + return FHP_OK; +} + static fhp_err_t fhp_ctx_push_byte( fhp_ctx_t * const ctx, -- cgit v1.2.3