#include "internal.h" // // content-type parser // fhp_err_t fhp_ct_parser_init( fhp_ct_parser_t * const p, fhp_env_t * const env ) { // init parser p->env = env; p->hash = fhp_hash_init(); // return succes return FHP_OK; } fhp_err_t fhp_ct_parser_push( fhp_ct_parser_t *p, uint8_t * const buf, size_t len ) { p->hash = fhp_lc_hash_push(p->hash, buf, len); // return succes return FHP_OK; } fhp_err_t fhp_ct_parser_done( fhp_ct_parser_t * const p, fhp_content_type_t * const ret_val ) { if (ret_val) { if (p->hash == p->env->hashes[FHP_STR_APPLICATION_X_WWW_FORM_URLENCODED]) { *ret_val = FHP_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED; } else if (p->hash == p->env->hashes[FHP_STR_MULTIPART_FORM_DATA]) { *ret_val = FHP_CONTENT_TYPE_MULTIPART_FORM_DATA; } else { *ret_val = FHP_CONTENT_TYPE_OTHER; } } // return success return FHP_OK; }