Commit Diff


commit - 77f619a8442c52e9c02e8060b76c25def0b5f1c6
commit + 389a68d86df4adffefba4050e86cd6a8fe6de36d
blob - 34c1b6df1b13b23dea3ca12f6a6cdaf82e3106f4
blob + 9d11c8f4f518f5f911295671d3aafcb494a7ec10
--- include/got_object.h
+++ include/got_object.h
@@ -296,6 +296,12 @@ void got_object_blob_rewind(struct got_blob_object *);
  */
 const struct got_error *got_object_blob_is_binary(int *,
     struct got_blob_object *);
+
+/*
+ * getline(3) for blobs.
+ */
+const struct got_error *got_object_blob_getline(char **, ssize_t *,
+    size_t *, struct got_blob_object *);
 
 /*
  * Read the entire content of a blob and write it to the specified file.
blob - 4d1c1cdecf129d5464dd74b1c503a6164e6939b5
blob + 9834b049e72a099055a8c44dc2b896abe7ad2ec3
--- lib/object.c
+++ lib/object.c
@@ -421,6 +421,16 @@ got_object_blob_is_binary(int *binary, struct got_blob
 
 	if (fseeko(blob->f, hdrlen, SEEK_SET) == -1)
 		return got_error_from_errno("fseeko");
+	return NULL;
+}
+
+const struct got_error *
+got_object_blob_getline(char **line, ssize_t *linelen, size_t *linesize,
+    struct got_blob_object *blob)
+{
+	*linelen = getline(line, linesize, blob->f);
+	if (*linelen == -1 && !feof(blob->f))
+		return got_error_from_errno("getline");
 	return NULL;
 }