Add printstr_ex which allows for providing user quotation style
This is useful for providing QUOTE_OMIT_TRAILING_0 and maybe other
flags.
* defs.h (printstr_ex): New prototype.
(printstr): Change to a wrapper around printstr_ex with zero user style.
* util.c (printstr): Rename to ...
(printstr_ex) ... new function, add user_style argument which is or'ed
with computed style.
diff --git a/defs.h b/defs.h
index d35d7cf..62f38b2 100644
--- a/defs.h
+++ b/defs.h
@@ -563,7 +563,8 @@
#define dumpiov(tcp, len, addr) \
dumpiov_upto((tcp), (len), (addr), (unsigned long) -1L)
extern void dumpstr(struct tcb *, long, int);
-extern void printstr(struct tcb *, long, long);
+extern void printstr_ex(struct tcb *, long addr, long len,
+ unsigned int user_style);
extern bool printnum_short(struct tcb *, long, const char *)
ATTRIBUTE_FORMAT((printf, 3, 0));
extern bool printnum_int(struct tcb *, long, const char *)
@@ -669,6 +670,12 @@
extern void unwind_capture_stacktrace(struct tcb* tcp);
#endif
+static inline void
+printstr(struct tcb *tcp, long addr, long len)
+{
+ printstr_ex(tcp, addr, len, 0);
+}
+
static inline int
printflags(const struct xlat *x, unsigned int flags, const char *dflt)
{
diff --git a/util.c b/util.c
index 39abcc6..23a5fdb 100644
--- a/util.c
+++ b/util.c
@@ -798,7 +798,7 @@
* If string length exceeds `max_strlen', append `...' to the output.
*/
void
-printstr(struct tcb *tcp, long addr, long len)
+printstr_ex(struct tcb *tcp, long addr, long len, unsigned int user_style)
{
static char *str = NULL;
static char *outstr;
@@ -842,6 +842,8 @@
style = 0;
}
+ style |= user_style;
+
/* If string_quote didn't see NUL and (it was supposed to be ASCIZ str
* or we were requested to print more than -s NUM chars)...
*/