| 1036 | */ |
| 1037 | |
| 1038 | ssize_t /* O - Number of bytes read */ |
| 1039 | read_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 | /* |
nothing calls this directly
no test coverage detected