8 * Based on string_quote() from util.c.
9 * Assumes instr is NUL-terminated.
13 print_quoted_string(const char *instr)
15 print_quoted_memory(instr, strlen(instr));
19 print_quoted_memory(const void *const instr, const size_t len)
21 const unsigned char *str = (const unsigned char *) instr;
25 for (i = 0; i < len; ++i) {
50 if (c >= ' ' && c <= 0x7e)
55 char c1 = '0' + (c & 0x7);
56 char c2 = '0' + ((c >> 3) & 0x7);
57 char c3 = '0' + (c >> 6);
59 if (*str >= '0' && *str <= '9') {
67 if (c3 != '0' || c2 != '0')
80 print_quoted_hex(const void *const instr, const size_t len)
82 const unsigned char *str = instr;
86 for (i = 0; i < len; i++)
87 printf("\\x%02x", str[i]);