ucharn_scan_little.c (366B)
1 /* ISC license. */ 2 3 #include <skalibs/fmtscan.h> 4 5 size_t ucharn_scan_little (char const *s, char *key, size_t n) 6 { 7 size_t i = 0 ; 8 for (; i < n ; i++) 9 { 10 unsigned char c = fmtscan_num(s[(i<<1)+1], 16) ; 11 if (c > 0xF) return 0 ; 12 key[i] = c << 4 ; 13 c = fmtscan_num(s[i<<1], 16) ; 14 if (c > 0xF) return 0 ; 15 key[i] += c ; 16 } 17 return n << 1 ; 18 }