From: John Ferlan <jferlan(a)redhat.com>
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/virstring.c | 19 +++++++++++++++++++
src/util/virstring.h | 1 +
3 files changed, 21 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ca2b6b8..28c54d6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2302,6 +2302,7 @@ virSkipSpacesBackwards;
virStrcpy;
virStrdup;
virStringArrayHasString;
+virStringBufferIsPrintable;
virStringEncodeBase64;
virStringFreeList;
virStringFreeListCount;
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 2702cec..0177a95 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -1070,6 +1070,25 @@ virStringIsPrintable(const char *str)
/**
+ * virBufferIsPrintable:
+ *
+ * Returns true if @buf of @buflen contains only printable characters
+ */
+bool
+virStringBufferIsPrintable(const uint8_t *buf,
+ size_t buflen)
+{
+ size_t i;
+
+ for (i = 0; i < buflen; i++)
+ if (!c_isprint(buf[i]))
+ return false;
+
+ return true;
+}
+
+
+/**
* virStringEncodeBase64:
* @buf: buffer of bytes to encode
* @buflen: number of bytes to encode
diff --git a/src/util/virstring.h b/src/util/virstring.h
index 6bc2726..040771e 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -276,6 +276,7 @@ bool virStringHasControlChars(const char *str);
void virStringStripControlChars(char *str);
bool virStringIsPrintable(const char *str);
+bool virStringBufferIsPrintable(const uint8_t *buf, size_t buflen);
char *virStringEncodeBase64(const uint8_t *buf, size_t buflen);
--
2.8.2