util: Rename and move virStrIsPrint to virStringIsPrintable

This commit is contained in:
Peter Krempa 2016-04-11 13:35:25 +02:00
parent 1ee1b58fc3
commit dcf02a704f
6 changed files with 23 additions and 17 deletions

View File

@ -7160,7 +7160,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
if (!virStrIsPrint(vendor)) { if (!virStringIsPrintable(vendor)) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("disk vendor is not printable string")); _("disk vendor is not printable string"));
goto error; goto error;
@ -7175,7 +7175,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
if (!virStrIsPrint(product)) { if (!virStringIsPrintable(product)) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("disk product is not printable string")); _("disk product is not printable string"));
goto error; goto error;

View File

@ -2265,6 +2265,7 @@ virStringFreeListCount;
virStringGetFirstWithPrefix; virStringGetFirstWithPrefix;
virStringHasControlChars; virStringHasControlChars;
virStringIsEmpty; virStringIsEmpty;
virStringIsPrintable;
virStringJoin; virStringJoin;
virStringListLength; virStringListLength;
virStringReplace; virStringReplace;
@ -2478,7 +2479,6 @@ virSetNonBlock;
virSetSockReuseAddr; virSetSockReuseAddr;
virSetUIDGID; virSetUIDGID;
virSetUIDGIDWithCaps; virSetUIDGIDWithCaps;
virStrIsPrint;
virTristateBoolTypeFromString; virTristateBoolTypeFromString;
virTristateBoolTypeToString; virTristateBoolTypeToString;
virTristateSwitchTypeFromString; virTristateSwitchTypeFromString;

View File

@ -1048,3 +1048,21 @@ virStringToUpper(char **dst, const char *src)
*dst = cap; *dst = cap;
return 1; return 1;
} }
/**
* virStringIsPrintable:
*
* Returns true @str contains only printable characters.
*/
bool
virStringIsPrintable(const char *str)
{
size_t i;
for (i = 0; str[i]; i++)
if (!c_isprint(str[i]))
return false;
return true;
}

View File

@ -275,4 +275,6 @@ void virStringStripIPv6Brackets(char *str);
bool virStringHasControlChars(const char *str); bool virStringHasControlChars(const char *str);
void virStringStripControlChars(char *str); void virStringStripControlChars(char *str);
bool virStringIsPrintable(const char *str);
#endif /* __VIR_STRING_H__ */ #endif /* __VIR_STRING_H__ */

View File

@ -1600,18 +1600,6 @@ virValidateWWN(const char *wwn)
return true; return true;
} }
bool
virStrIsPrint(const char *str)
{
size_t i;
for (i = 0; str[i]; i++)
if (!c_isprint(str[i]))
return false;
return true;
}
#if defined(major) && defined(minor) #if defined(major) && defined(minor)
int int
virGetDeviceID(const char *path, int *maj, int *min) virGetDeviceID(const char *path, int *maj, int *min)

View File

@ -152,8 +152,6 @@ bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
bool virValidateWWN(const char *wwn); bool virValidateWWN(const char *wwn);
bool virStrIsPrint(const char *str);
int virGetDeviceID(const char *path, int virGetDeviceID(const char *path,
int *maj, int *maj,
int *min); int *min);