raop: Add pulsecore/core-utils a pa_str_in_list function

Reviewed-by: Anton Lundin <glance@acc.umu.se>
This commit is contained in:
Martin Blanchard 2016-01-31 22:16:01 -06:00 committed by Tanu Kaskinen
parent 6665acac56
commit 736fabf0ca
2 changed files with 23 additions and 2 deletions

View file

@ -2981,6 +2981,26 @@ bool pa_in_system_mode(void) {
return !!atoi(e);
}
/* Checks a delimiters-separated list of words in haystack for needle */
bool pa_str_in_list(const char *haystack, const char *delimiters, const char *needle) {
char *s;
const char *state = NULL;
if (!haystack || !needle)
return false;
while ((s = pa_split(haystack, delimiters, &state))) {
if (pa_streq(needle, s)) {
pa_xfree(s);
return true;
}
pa_xfree(s);
}
return false;
}
/* Checks a whitespace-separated list of words in haystack for needle */
bool pa_str_in_list_spaces(const char *haystack, const char *needle) {
char *s;

View file

@ -109,8 +109,8 @@ static inline const char *pa_strna(const char *x) {
return x ? x : "n/a";
}
char *pa_split(const char *c, const char*delimiters, const char **state);
const char *pa_split_in_place(const char *c, const char*delimiters, int *n, const char **state);
char *pa_split(const char *c, const char *delimiters, const char **state);
const char *pa_split_in_place(const char *c, const char *delimiters, int *n, const char **state);
char *pa_split_spaces(const char *c, const char **state);
char *pa_strip_nl(char *s);
@ -228,6 +228,7 @@ static inline bool pa_safe_streq(const char *a, const char *b) {
}
bool pa_str_in_list_spaces(const char *needle, const char *haystack);
bool pa_str_in_list(const char *haystack, const char *delimiters, const char *needle);
char *pa_get_host_name_malloc(void);
char *pa_get_user_name_malloc(void);