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_cstring(const char *instr, const size_t size)
21 const size_t len = strnlen(instr, size);
23 print_quoted_memory(instr, len);
25 print_quoted_memory(instr, size - 1);
31 print_quoted_memory(const void *const instr, const size_t len)
33 const unsigned char *str = (const unsigned char *) instr;
37 for (i = 0; i < len; ++i) {
62 if (c >= ' ' && c <= 0x7e)
67 char c1 = '0' + (c & 0x7);
68 char c2 = '0' + ((c >> 3) & 0x7);
69 char c3 = '0' + (c >> 6);
81 if (c3 != '0' || c2 != '0')
94 print_quoted_hex(const void *const instr, const size_t len)
96 const unsigned char *str = instr;
100 for (i = 0; i < len; i++)
101 printf("\\x%02x", str[i]);