+/* Transform non-printable chars to '\xNN' presentation. */
+static char *printable_name(const char *name)
+{
+ size_t l, i;
+ char *s, *p;
+
+ if (!name)
+ return NULL;
+ l = strlen(name);
+ s = g_malloc0(l * strlen("\\x00") + 1);
+ for (p = s, i = 0; i < l; i++) {
+ if (g_ascii_isprint(name[i])) {
+ *p++ = name[i];
+ } else {
+ snprintf(p, 5, "\\x%02x", name[i]);
+ p += strlen("\\x00");
+ }
+ }
+ *p = '\0';
+
+ return s;
+}
+