提交 1cf5af40 编写于 作者: J John Ferlan 提交者: Peter Krempa

util: string: Introduce helper to determine whether a byte buffer is printable

Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 cb2e3e50
......@@ -2303,6 +2303,7 @@ virSkipSpacesBackwards;
virStrcpy;
virStrdup;
virStringArrayHasString;
virStringBufferIsPrintable;
virStringEncodeBase64;
virStringFreeList;
virStringFreeListCount;
......
......@@ -1069,6 +1069,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
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册