| 1459 | #define LOG_BYTES_BUFFER_SIZE (BYTES_LOGGED_PER_LINE * 3 + 2) |
| 1460 | |
| 1461 | static void fmt_data(unsigned char *buf, const void *vdata, apr_size_t len, apr_size_t *off) |
| 1462 | { |
| 1463 | const unsigned char *data = (const unsigned char *)vdata; |
| 1464 | unsigned char *chars; |
| 1465 | unsigned char *hex; |
| 1466 | apr_size_t this_time = 0; |
| 1467 | |
| 1468 | memset(buf, ' ', LOG_BYTES_BUFFER_SIZE - 1); |
| 1469 | buf[LOG_BYTES_BUFFER_SIZE - 1] = '\0'; |
| 1470 | |
| 1471 | chars = buf; /* start character dump here */ |
| 1472 | hex = buf + BYTES_LOGGED_PER_LINE + 1; /* start hex dump here */ |
| 1473 | while (*off < len && this_time < BYTES_LOGGED_PER_LINE) { |
| 1474 | unsigned char c = data[*off]; |
| 1475 | |
| 1476 | if (apr_isprint(c) |
| 1477 | && c != '\\') { /* backslash will be escaped later, which throws |
| 1478 | * off the formatting |
| 1479 | */ |
| 1480 | *chars = c; |
| 1481 | } |
| 1482 | else { |
| 1483 | *chars = '.'; |
| 1484 | } |
| 1485 | |
| 1486 | if ((c >> 4) >= 10) { |
| 1487 | *hex = 'a' + ((c >> 4) - 10); |
| 1488 | } |
| 1489 | else { |
| 1490 | *hex = '0' + (c >> 4); |
| 1491 | } |
| 1492 | |
| 1493 | if ((c & 0x0F) >= 10) { |
| 1494 | *(hex + 1) = 'a' + ((c & 0x0F) - 10); |
| 1495 | } |
| 1496 | else { |
| 1497 | *(hex + 1) = '0' + (c & 0x0F); |
| 1498 | } |
| 1499 | |
| 1500 | chars += 1; |
| 1501 | hex += 2; |
| 1502 | *off += 1; |
| 1503 | ++this_time; |
| 1504 | } |
| 1505 | } |
| 1506 | |
| 1507 | static void log_data_core(const char *file, int line, int module_index, |
| 1508 | int level, const server_rec *s, |