+/*
+ * 'read_hex()' - Read a hex dump of an IPP request.
+ */
+
+ssize_t /* O - Number of bytes read */
+read_hex(cups_file_t *fp, /* I - File to read from */
+ ipp_uchar_t *buffer, /* I - Buffer to read */
+ size_t bytes) /* I - Number of bytes to read */
+{
+ size_t total = 0; /* Total bytes read */
+ static char hex[256] = ""; /* Line from file */
+ static char *hexptr = NULL; /* Pointer in line */
+
+
+ while (total < bytes)
+ {
+ if (!hexptr || (isspace(hexptr[0] & 255) && isspace(hexptr[1] & 255)))
+ {
+ if (!cupsFileGets(fp, hex, sizeof(hex)))
+ break;
+
+ hexptr = hex;
+ while (isxdigit(*hexptr & 255))
+ hexptr ++;
+ while (isspace(*hexptr & 255))
+ hexptr ++;
+
+ if (!isxdigit(*hexptr & 255))
+ {
+ hexptr = NULL;
+ continue;
+ }
+ }
+
+ *buffer++ = (ipp_uchar_t)strtol(hexptr, &hexptr, 16);
+ total ++;
+ }
+
+ return (total == 0 ? -1 : (ssize_t)total);
+}
+
+