/*
* This function does "safe" printing. It will convert non-printable
* ASCII characters using '^' and M- notation.
+ *
+ * If 'esc' is defined then escape all chars from esc by \.
*/
-static void safe_print(const char *cp, int len)
+static void safe_print(const char *cp, int len, const char *esc)
{
unsigned char ch;
if ((ch < 32) || (ch == 0x7f)) {
fputc('^', stdout);
ch ^= 0x40; /* ^@, ^A, ^B; ^? for DEL */
- }
+
+ } else if (esc && strchr(esc, ch))
+ fputc('\\', stdout);
}
fputc(ch, stdout);
}
printf("DEVNAME=%s\n", devname);
fputs(name, stdout);
fputs("=", stdout);
- safe_print(value, valsz);
+ safe_print(value, valsz, NULL);
fputs("\n", stdout);
} else {
printf("%s: ", devname);
fputs(name, stdout);
fputs("=\"", stdout);
- safe_print(value, valsz);
+ safe_print(value, valsz, "\"");
fputs("\" ", stdout);
}
}