/** A debugging crutch: print a hex-escaped version of the match for our * perusal. The start and end offsets are stream offsets. */ static UNUSED void printMatch(const struct core_info *ci, u64a start, u64a end) { assert(start <= end); assert(end <= ci->buf_offset + ci->len); printf("'"); u64a i = start; for (; i <= MIN(ci->buf_offset, end); i++) { u64a h_idx = ci->buf_offset - i; u8 c = h_idx >= ci->hlen ? '?' : ci->hbuf[ci->hlen - h_idx - 1]; if (ourisprint(c) && c != '\'') { printf("%c", c); } else { printf("\\x%02x", c); } } for (; i <= end; i++) { u64a b_idx = i - ci->buf_offset - 1; u8 c = b_idx >= ci->len ? '?' : ci->buf[b_idx]; if (ourisprint(c) && c != '\'') { printf("%c", c); } else { printf("\\x%02x", c); } } printf("'"); }
// A debugging crutch: print a hex-escaped version of the match for our // perusal. static UNUSED void dumpData(const char *data, size_t len) { DEBUG_PRINTF("BUFFER:"); for (size_t i = 0; i < len; i++) { u8 c = data[i]; if (ourisprint(c) && c != '\'') { printf("%c", c); } else { printf("\\x%02x", c); } } printf("\n"); }