提交 d93b9e88 编写于 作者: A Andrea Bolognani

util: Add virStringHasSuffix()

This is the case-sensitive counterpart of the existing
virStringHasCaseSuffix() function.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
ACKed-by: NPeter Krempa <pkrempa@redhat.com>
上级 b5cc0a7f
......@@ -2966,6 +2966,7 @@ virStringFilterChars;
virStringHasCaseSuffix;
virStringHasChars;
virStringHasControlChars;
virStringHasSuffix;
virStringIsEmpty;
virStringIsPrintable;
virStringListAdd;
......
......@@ -1235,6 +1235,19 @@ virStringReplace(const char *haystack,
return virBufferContentAndReset(&buf);
}
bool
virStringHasSuffix(const char *str,
const char *suffix)
{
int len = strlen(str);
int suffixlen = strlen(suffix);
if (len < suffixlen)
return false;
return STREQ(str + len - suffixlen, suffix);
}
int
virStringHasCaseSuffix(const char *str,
const char *suffix)
......
......@@ -288,6 +288,8 @@ char *virStringReplace(const char *haystack,
const char *newneedle)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
bool virStringHasSuffix(const char *str,
const char *suffix);
int virStringHasCaseSuffix(const char *str,
const char *suffix);
int virStringStripSuffix(char *str,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册