t5601: exercise clones with "includeIf.*.onbranch"
[alt-git.git] / hex-ll.h
bloba381fa855622349bab94ff8341003bc43cb0515d
1 #ifndef HEX_LL_H
2 #define HEX_LL_H
4 extern const signed char hexval_table[256];
5 static inline unsigned int hexval(unsigned char c)
7 return hexval_table[c];
11 * Convert two consecutive hexadecimal digits into a char. Return a
12 * negative value on error. Don't run over the end of short strings.
14 static inline int hex2chr(const char *s)
16 unsigned int val = hexval(s[0]);
17 return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
21 * Read `len` pairs of hexadecimal digits from `hex` and write the
22 * values to `binary` as `len` bytes. Return 0 on success, or -1 if
23 * the input does not consist of hex digits).
25 int hex_to_bytes(unsigned char *binary, const char *hex, size_t len);
27 #endif