mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
util: string: Introduce helper to determine whether a byte buffer is printable
Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
cb2e3e50ee
commit
1cf5af40b9
@ -2303,6 +2303,7 @@ virSkipSpacesBackwards;
|
|||||||
virStrcpy;
|
virStrcpy;
|
||||||
virStrdup;
|
virStrdup;
|
||||||
virStringArrayHasString;
|
virStringArrayHasString;
|
||||||
|
virStringBufferIsPrintable;
|
||||||
virStringEncodeBase64;
|
virStringEncodeBase64;
|
||||||
virStringFreeList;
|
virStringFreeList;
|
||||||
virStringFreeListCount;
|
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:
|
* virStringEncodeBase64:
|
||||||
* @buf: buffer of bytes to encode
|
* @buf: buffer of bytes to encode
|
||||||
|
@ -276,6 +276,7 @@ bool virStringHasControlChars(const char *str);
|
|||||||
void virStringStripControlChars(char *str);
|
void virStringStripControlChars(char *str);
|
||||||
|
|
||||||
bool virStringIsPrintable(const 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);
|
char *virStringEncodeBase64(const uint8_t *buf, size_t buflen);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user