From 51af89dc9d475cf40751eaee8401fbc8a272a0da Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 11 Jan 2009 13:00:33 +0000 Subject: Beginnings of a colour specifier parser. svn path=/trunk/libcss/; revision=6037 --- src/utils/utils.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/utils/utils.h') diff --git a/src/utils/utils.h b/src/utils/utils.h index a8848e3..9fc4424 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -124,4 +124,44 @@ static inline fixed number_from_css_string(const css_string *string, return FMULI(((intpart << 10) | fracpart), sign); } +static inline uint32_t charToHex(uint8_t c) +{ + switch (c) { + case 'a': case 'A': + return 0xa; + case 'b': case 'B': + return 0xb; + case 'c': case 'C': + return 0xc; + case 'd': case 'D': + return 0xd; + case 'e': case 'E': + return 0xe; + case 'f': case 'F': + return 0xf; + case '0': + return 0x0; + case '1': + return 0x1; + case '2': + return 0x2; + case '3': + return 0x3; + case '4': + return 0x4; + case '5': + return 0x5; + case '6': + return 0x6; + case '7': + return 0x7; + case '8': + return 0x8; + case '9': + return 0x9; + } + + return 0; +} + #endif -- cgit v1.2.3