Refactoring unicorn_http C/Ragel code
[unicorn.git] / ext / unicorn_http / c_util.h
blob30e7ae241b942519e8ca65485fcface1fba9cf5e
1 /*
2 * Generic C functions and macros go here, there are no dependencies
3 * on Unicorn internal structures or the Ruby C API in here.
4 */
6 #ifndef UH_util_h
7 #define UH_util_h
9 /*
10 * capitalizes all lower-case ASCII characters and converts dashes
11 * to underscores for HTTP headers. Locale-agnostic.
13 static void snake_upcase_char(char *c)
15 if (*c >= 'a' && *c <= 'z')
16 *c &= ~0x20;
17 else if (*c == '-')
18 *c = '_';
21 /* Downcases a single ASCII character. Locale-agnostic. */
22 static void downcase_char(char *c)
24 if (*c >= 'A' && *c <= 'Z')
25 *c |= 0x20;
28 #endif /* UH_util_h */