1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Converts hexadecimal input strings to binary
6 // This code has been put into the public domain.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 ///////////////////////////////////////////////////////////////////////////////
22 if (x >= '0' && x <= '9')
25 if (x >= 'A' && x <= 'F')
42 const int digit = getchar();
43 if (digit == EOF || !isxdigit(digit)) {
44 fprintf(stderr, "Invalid input\n");
48 byte = (getbin(byte) << 4) | getbin(digit);
49 if (putchar(byte) == EOF) {