mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
util: Add virStringHasSuffix()
This is the case-sensitive counterpart of the existing virStringHasCaseSuffix() function. Signed-off-by: Andrea Bolognani <abologna@redhat.com> ACKed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
b5cc0a7f29
commit
d93b9e8829
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user