about summary refs log tree commit homepage
path: root/ext/unicorn_http/c_util.h
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-08-02 13:39:21 -0700
committerEric Wong <normalperson@yhbt.net>2009-08-09 01:24:30 -0700
commitca3fd8acb4bc3f5125a9f0f281951fb8f03778e5 (patch)
tree42752ea26cf989d9a8d02d750a87aff0d15dc1d8 /ext/unicorn_http/c_util.h
parente1d67bef994587ba77e1a3575773755b2b5e1558 (diff)
downloadunicorn-ca3fd8acb4bc3f5125a9f0f281951fb8f03778e5.tar.gz
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.
Diffstat (limited to 'ext/unicorn_http/c_util.h')
-rw-r--r--ext/unicorn_http/c_util.h28
1 files changed, 28 insertions, 0 deletions
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 */