On Sun, 2016-01-31 at 22:16 -0600, Hajime Fujita wrote: > From: Martin Blanchard <tinram at gmx.fr> > > --- > Â src/pulsecore/core-util.c | 20 ++++++++++++++++++++ > Â src/pulsecore/core-util.h |Â Â 5 +++-- > Â 2 files changed, 23 insertions(+), 2 deletions(-) > > diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c > index 19c89a9..9fd4301 100644 > --- a/src/pulsecore/core-util.c > +++ b/src/pulsecore/core-util.c > @@ -2977,6 +2977,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))) { Would be nicer to use pa_split_in_place() here. -- Arun > +Â Â Â Â Â Â Â Â 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; > diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h > index d5a2d39..56b527f 100644 > --- a/src/pulsecore/core-util.h > +++ b/src/pulsecore/core-util.h > @@ -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);