1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Converts hexadecimal input strings to binary
6 // Author: Lasse Collin
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
11 ///////////////////////////////////////////////////////////////////////////////
21 if (x >= '0' && x <= '9')
24 if (x >= 'A' && x <= 'F')
41 const int digit = getchar();
42 if (digit == EOF || !isxdigit(digit)) {
43 fprintf(stderr, "Invalid input\n");
47 byte = (getbin(byte) << 4) | getbin(digit);
48 if (putchar(byte) == EOF) {