#include #include "strv.h" strv_t strv(const char *s) { return (strv_t) { s, strlen(s) }; } int strv_split(strv_t *src, int chr, strv_t *dest) { char *c = memchr(src->s, chr, src->n); *dest = (strv_t) { src->s, c ? c - src->s : src->n }; src->s = c ? c + 1 : &src->s[src->n]; src->n -= dest->n + !!c; return dest->n > 0; }