mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
string: Add first_substring().
This commit is contained in:
parent
5af311ddd8
commit
12925d8b70
@ -243,3 +243,19 @@ char *build_dm_uuid(struct dm_pool *mem, const struct logical_volume *lv,
|
|||||||
|
|
||||||
return dlid;
|
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;
|
||||||
|
}
|
||||||
|
@ -49,4 +49,12 @@ void copy_systemid_chars(const char *src, char *dst);
|
|||||||
int apply_lvname_restrictions(const char *name);
|
int apply_lvname_restrictions(const char *name);
|
||||||
int is_reserved_lvname(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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user