| 5670 | } |
| 5671 | |
| 5672 | static void |
| 5673 | print_string(const u_int8_t *buf, int len) |
| 5674 | { |
| 5675 | int i; |
| 5676 | int hasspc; |
| 5677 | int utf8; |
| 5678 | |
| 5679 | i = 0; |
| 5680 | hasspc = 0; |
| 5681 | |
| 5682 | setlocale(LC_CTYPE, ""); |
| 5683 | utf8 = strncmp("UTF-8", nl_langinfo(CODESET), 5) == 0; |
| 5684 | |
| 5685 | for (; i < len; i++) { |
| 5686 | if (!isprint(buf[i]) && buf[i] != '\0' && !utf8) |
| 5687 | break; |
| 5688 | if (isspace(buf[i])) |
| 5689 | hasspc++; |
| 5690 | } |
| 5691 | if (i == len || utf8) { |
| 5692 | if (hasspc || len == 0 || buf[0] == '\0') |
| 5693 | printf("\"%.*s\"", len, buf); |
| 5694 | else |
| 5695 | printf("%.*s", len, buf); |
| 5696 | } else { |
| 5697 | printf("0x"); |
| 5698 | for (i = 0; i < len; i++) |
| 5699 | printf("%02x", buf[i]); |
| 5700 | } |
| 5701 | } |
| 5702 | |
| 5703 | static void |
| 5704 | setdefregdomain(int s) |
no test coverage detected