MCPcopy Create free account
hub / github.com/OpenPrinting/cups / read_hex

Function read_hex

cups/testipp.c:1038–1073  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1036 */
1037
1038ssize_t /* O - Number of bytes read */
1039read_hex(cups_file_t *fp, /* I - File to read from */
1040 ipp_uchar_t *buffer, /* I - Buffer to read */
1041 size_t bytes) /* I - Number of bytes to read */
1042{
1043 size_t total = 0; /* Total bytes read */
1044 static char hex[256] = ""; /* Line from file */
1045 static char *hexptr = NULL; /* Pointer in line */
1046
1047
1048 while (total < bytes)
1049 {
1050 if (!hexptr || (isspace(hexptr[0] & 255) && isspace(hexptr[1] & 255)))
1051 {
1052 if (!cupsFileGets(fp, hex, sizeof(hex)))
1053 break;
1054
1055 hexptr = hex;
1056 while (isxdigit(*hexptr & 255))
1057 hexptr ++;
1058 while (isspace(*hexptr & 255))
1059 hexptr ++;
1060
1061 if (!isxdigit(*hexptr & 255))
1062 {
1063 hexptr = NULL;
1064 continue;
1065 }
1066 }
1067
1068 *buffer++ = (ipp_uchar_t)strtol(hexptr, &hexptr, 16);
1069 total ++;
1070 }
1071
1072 return (total == 0 ? -1 : (ssize_t)total);
1073}
1074
1075
1076/*

Callers

nothing calls this directly

Calls 1

cupsFileGetsFunction · 0.85

Tested by

no test coverage detected