From 9315bbfd0f9e51da5438d29681cab6f9a6533d89 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 28 Aug 2016 00:30:02 -0400 Subject: split up fhp.c --- env.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 env.c (limited to 'env.c') diff --git a/env.c b/env.c new file mode 100644 index 0000000..721d392 --- /dev/null +++ b/env.c @@ -0,0 +1,44 @@ +#include +#include "fhp/fhp.h" + +static char * const +fhp_strings[] = { + "GET", + "POST", + "HEAD", + "PUT", + "DELETE", + "OPTIONS", + "HTTP/1.0", + "HTTP/1.1", + "content-length", + "transfer-encoding", + "gzip", + "x-gzip", + "deflate", + "x-deflate", + "compress", + "x-compress", + "chunked", + NULL +}; + +void +fhp_env_init(fhp_env_t * const env) { + for (size_t i = 0; fhp_strings[i]; i++) + env->hashes[i] = fhp_lc_hash_string(fhp_strings[i]); +} + +static fhp_env_t fhp_default_env; + +fhp_env_t * +fhp_get_default_env(void) { + static fhp_env_t *r = NULL; + + if (!r) { + r = &fhp_default_env; + fhp_env_init(r); + } + + return r; +} -- cgit v1.2.3