| 67 | } |
| 68 | |
| 69 | static int get_hex_color(const char **inp, int width, unsigned char *out) |
| 70 | { |
| 71 | const char *in = *inp; |
| 72 | unsigned int val; |
| 73 | |
| 74 | assert(width == 1 || width == 2); |
| 75 | val = (hexval(in[0]) << 4) | hexval(in[width - 1]); |
| 76 | if (val & ~0xff) |
| 77 | return -1; |
| 78 | *inp += width; |
| 79 | *out = val; |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * If an ANSI color is recognized in "name", fill "out" and return 0. |