summaryrefslogtreecommitdiffstats
path: root/bstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'bstr.c')
-rw-r--r--bstr.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/bstr.c b/bstr.c
index 2ce5f6787e..bb407a10d8 100644
--- a/bstr.c
+++ b/bstr.c
@@ -185,6 +185,16 @@ struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str)
return r;
}
+struct bstr bstr_getline(struct bstr str, struct bstr *rest)
+{
+ int pos = bstrchr(str, '\n');
+ if (pos < 0)
+ pos = str.len;
+ if (rest)
+ *rest = bstr_cut(str, pos + 1);
+ return bstr_splice(str, 0, pos + 1);
+}
+
bool bstr_eatstart(struct bstr *s, struct bstr prefix)
{
if (!bstr_startswith(*s, prefix))