1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

string: Add first_substring().

This commit is contained in:
Alasdair G Kergon 2016-07-14 14:46:38 +01:00
parent 5af311ddd8
commit 12925d8b70
2 changed files with 24 additions and 0 deletions

View File

@ -243,3 +243,19 @@ char *build_dm_uuid(struct dm_pool *mem, const struct logical_volume *lv,
return dlid;
}
char *first_substring(const char *str, ...)
{
char *substr, *r = NULL;
va_list ap;
va_start(ap, str);
while ((substr = va_arg(ap, char *)))
if ((r = strstr(str, substr)))
break;
va_end(ap);
return r;
}

View File

@ -49,4 +49,12 @@ void copy_systemid_chars(const char *src, char *dst);
int apply_lvname_restrictions(const char *name);
int is_reserved_lvname(const char *name);
/*
* Provided with a NULL-terminated argument list of const char *
* substrings that might be contained within the string str, use
* strstr() to search str for each in turn and return a pointer to the
* first match or else NULL.
*/
char *first_substring(const char *str, ...);
#endif