X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fbytestring%2Fbytestring.h;fp=ccan%2Fbytestring%2Fbytestring.h;h=5a8d3cd896fb003704bada0f535d4e11c5354171;hp=8aa272755caa90b2ad1c18655a8195093d7ec7cf;hb=309577c4747b9a74b6e55d4a9b760ede84b68b4e;hpb=cb2d540f764b225a068a3cdd1396df4fc8dc6824 diff --git a/ccan/bytestring/bytestring.h b/ccan/bytestring/bytestring.h index 8aa27275..5a8d3cd8 100644 --- a/ccan/bytestring/bytestring.h +++ b/ccan/bytestring/bytestring.h @@ -246,4 +246,34 @@ struct bytestring bytestring_splitchr_next(struct bytestring whole, (_s).ptr; \ (_s) = bytestring_splitchr_next((_w), (_delim), (_s))) +/** + * bytestring_splitchrs_first - split a bytestring on a set of delimiter + * characters + * @whole: a bytestring + * @delim: delimiter characters + * + * Returns the first substring of @whole delimited by any character in + * @delim. + */ +struct bytestring bytestring_splitchrs_first(struct bytestring whole, + struct bytestring delim); + +/** + * bytestring_splitchr_next - split a bytestring on a set of delimiter + * characters + * @whole: a bytestring + * @delim: delimiter character + * @prev: last substring + * + * Returns the next @delim delimited substring of @whole after @prev. + */ +struct bytestring bytestring_splitchrs_next(struct bytestring whole, + struct bytestring delim, + struct bytestring prev); + +#define bytestring_foreach_splitchrs(_s, _w, _delim) \ + for ((_s) = bytestring_splitchrs_first((_w), (_delim)); \ + (_s).ptr; \ + (_s) = bytestring_splitchrs_next((_w), (_delim), (_s))) + #endif /* CCAN_BYTESTRING_H_ */