Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/hex-ll.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / hex-ll.h` 27 lines ยท 708 bytes Raw Blame History 1 #ifndef HEX_LL_H 2 #define HEX_LL_H 3 4 extern const signed char hexval_table[256]; 5 static inline unsigned int hexval(unsigned char c) 6 { 7 return hexval_table[c]; 8 } 9 10 /* 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. 13 */ 14 static inline int hex2chr(const char *s) 15 { 16 unsigned int val = hexval(s[0]); 17 return (val & ~0xf) ? val : (val << 4) | hexval(s[1]); 18 } 19 20 /* 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). 24 */ 25 int hex_to_bytes(unsigned char *binary, const char *hex, size_t len); 26 27 #endif