]> git.cworth.org Git - notmuch/commitdiff
sprinter: add text0 formatter for null character separated text
authorJani Nikula <jani@nikula.org>
Sun, 16 Dec 2012 22:05:10 +0000 (00:05 +0200)
committerDavid Bremner <bremner@debian.org>
Tue, 18 Dec 2012 21:03:34 +0000 (17:03 -0400)
Same as the text formatter, but with each field separated by a null
character rather than a newline character.

sprinter-text.c
sprinter.h

index 10343be4b4f1dafe514afa25281586631b376a89..7779488f99a3db4c7919e93210e86acccf9c8949 100644 (file)
@@ -67,6 +67,14 @@ text_separator (struct sprinter *sp)
     fputc ('\n', sptxt->stream);
 }
 
+static void
+text0_separator (struct sprinter *sp)
+{
+    struct sprinter_text *sptxt = (struct sprinter_text *) sp;
+
+    fputc ('\0', sptxt->stream);
+}
+
 static void
 text_set_prefix (struct sprinter *sp, const char *prefix)
 {
@@ -133,3 +141,17 @@ sprinter_text_create (const void *ctx, FILE *stream)
     res->stream = stream;
     return &res->vtable;
 }
+
+struct sprinter *
+sprinter_text0_create (const void *ctx, FILE *stream)
+{
+    struct sprinter *sp;
+
+    sp = sprinter_text_create (ctx, stream);
+    if (! sp)
+       return NULL;
+
+    sp->separator = text0_separator;
+
+    return sp;
+}
index f43a8443f2352b3583e2f976b501907164373724..f859672f8b3f23342c25b5d50f6e64437c03dac7 100644 (file)
@@ -67,6 +67,12 @@ typedef struct sprinter {
 struct sprinter *
 sprinter_text_create (const void *ctx, FILE *stream);
 
+/* Create a new unstructured printer that emits the text format for
+ * "notmuch search", with each field separated by a null character
+ * instead of the newline character. */
+struct sprinter *
+sprinter_text0_create (const void *ctx, FILE *stream);
+
 /* Create a new structure printer that emits JSON. */
 struct sprinter *
 sprinter_json_create (const void *ctx, FILE *stream);