Created
March 5, 2014 21:29
-
-
Save denisvm/9377022 to your computer and use it in GitHub Desktop.
Revisions
-
denisvm created this gist
Mar 5, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ static void hex2bin(unsigned char *to, const char *p, size_t len) { register char c1, c2; for (; *p; to++) { c1 = *p++; c2 = *p++; if (!c1 || !isxdigit(c1)) return; else if (!c2 || !isxdigit(c2)) *to = (unsigned char) digittoint(c1); else *to = (unsigned char) (digittoint(c1) << 4) | digittoint(c2); } }