]> git.cworth.org Git - notmuch/blobdiff - sprinter-text.c
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / sprinter-text.c
index 10343be4b4f1dafe514afa25281586631b376a89..99330a94768605ebbd9977ae2563b90c7cda4e15 100644 (file)
@@ -1,3 +1,4 @@
+#include <inttypes.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <talloc.h>
@@ -21,7 +22,7 @@ struct sprinter_text {
     /* A flag to indicate if this is the first tag. Used in list of tags
      * for summary.
      */
-    notmuch_bool_t first_tag;
+    bool first_tag;
 };
 
 static void
@@ -44,15 +45,15 @@ text_string (struct sprinter *sp, const char *val)
 }
 
 static void
-text_integer (struct sprinter *sp, int val)
+text_integer (struct sprinter *sp, int64_t val)
 {
     struct sprinter_text *sptxt = (struct sprinter_text *) sp;
 
-    fprintf (sptxt->stream, "%d", val);
+    fprintf (sptxt->stream, "%" PRId64, val);
 }
 
 static void
-text_boolean (struct sprinter *sp, notmuch_bool_t val)
+text_boolean (struct sprinter *sp, bool val)
 {
     struct sprinter_text *sptxt = (struct sprinter_text *) sp;
 
@@ -67,6 +68,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)
 {
@@ -105,7 +114,7 @@ text_map_key (unused (struct sprinter *sp), unused (const char *key))
 }
 
 struct sprinter *
-sprinter_text_create (const void *ctx, FILE *stream)
+sprinter_text_create (notmuch_database_t *db, FILE *stream)
 {
     static const struct sprinter_text template = {
        .vtable = {
@@ -120,16 +129,31 @@ sprinter_text_create (const void *ctx, FILE *stream)
            .map_key = text_map_key,
            .separator = text_separator,
            .set_prefix = text_set_prefix,
-           .is_text_printer = TRUE,
+           .is_text_printer = true,
        },
     };
     struct sprinter_text *res;
 
-    res = talloc (ctx, struct sprinter_text);
+    res = talloc (db, struct sprinter_text);
     if (! res)
        return NULL;
 
     *res = template;
+    res->vtable.notmuch = db;
     res->stream = stream;
     return &res->vtable;
 }
+
+struct sprinter *
+sprinter_text0_create (notmuch_database_t *db, FILE *stream)
+{
+    struct sprinter *sp;
+
+    sp = sprinter_text_create (db, stream);
+    if (! sp)
+       return NULL;
+
+    sp->separator = text0_separator;
+
+    return sp;
+}