From ca3fd8acb4bc3f5125a9f0f281951fb8f03778e5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 2 Aug 2009 13:39:21 -0700 Subject: Refactoring unicorn_http C/Ragel code More tightly integrate the C/Ruby portions with C/Ragel to avoid the confusing the flow. Split out some files into hopefully logical areas so it's easier to focus on more interesting/volatile code. --- ext/unicorn_http/c_util.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ext/unicorn_http/c_util.h (limited to 'ext/unicorn_http/c_util.h') diff --git a/ext/unicorn_http/c_util.h b/ext/unicorn_http/c_util.h new file mode 100644 index 0000000..30e7ae2 --- /dev/null +++ b/ext/unicorn_http/c_util.h @@ -0,0 +1,28 @@ +/* + * Generic C functions and macros go here, there are no dependencies + * on Unicorn internal structures or the Ruby C API in here. + */ + +#ifndef UH_util_h +#define UH_util_h + +/* + * capitalizes all lower-case ASCII characters and converts dashes + * to underscores for HTTP headers. Locale-agnostic. + */ +static void snake_upcase_char(char *c) +{ + if (*c >= 'a' && *c <= 'z') + *c &= ~0x20; + else if (*c == '-') + *c = '_'; +} + +/* Downcases a single ASCII character. Locale-agnostic. */ +static void downcase_char(char *c) +{ + if (*c >= 'A' && *c <= 'Z') + *c |= 0x20; +} + +#endif /* UH_util_h */ -- cgit v1.2.3-24-ge0c7