]> git.cworth.org Git - notmuch/blobdiff - sprinter-sexp.c
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / sprinter-sexp.c
index 08783e11d3bd37ddef3a02fdb606164008edfa89..e37cb1f97e30cc48366fdf7fc4ae0c00fe6efa0d 100644 (file)
@@ -18,6 +18,7 @@
  * Author: Peter Feigl <peter.feigl@gmx.at>
  */
 
+#include <inttypes.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <talloc.h>
@@ -33,7 +34,7 @@ struct sprinter_sexp {
 
     /* A flag to signify that a separator should be inserted in the
      * output as soon as possible. */
-    notmuch_bool_t insert_separator;
+    bool insert_separator;
 };
 
 struct sexp_state {
@@ -41,7 +42,7 @@ struct sexp_state {
 
     /* True if nothing has been printed in this aggregate yet.
      * Suppresses the space before a value. */
-    notmuch_bool_t first;
+    bool first;
 };
 
 /* Helper function to set up the stream to print a value.  If this
@@ -55,12 +56,12 @@ sexp_begin_value (struct sprinter *sp)
        if (! sps->state->first) {
            if (sps->insert_separator) {
                fputc ('\n', sps->stream);
-               sps->insert_separator = FALSE;
+               sps->insert_separator = false;
            } else {
                fputc (' ', sps->stream);
            }
        } else {
-           sps->state->first = FALSE;
+           sps->state->first = false;
        }
     }
     return sps;
@@ -76,7 +77,7 @@ sexp_begin_aggregate (struct sprinter *sp)
 
     fputc ('(', sps->stream);
     state->parent = sps->state;
-    state->first = TRUE;
+    state->first = true;
     sps->state = state;
 }
 
@@ -161,15 +162,15 @@ sexp_keyword (struct sprinter *sp, const char *val)
 }
 
 static void
-sexp_integer (struct sprinter *sp, int val)
+sexp_integer (struct sprinter *sp, int64_t val)
 {
     struct sprinter_sexp *sps = sexp_begin_value (sp);
 
-    fprintf (sps->stream, "%d", val);
+    fprintf (sps->stream, "%" PRId64, val);
 }
 
 static void
-sexp_boolean (struct sprinter *sp, notmuch_bool_t val)
+sexp_boolean (struct sprinter *sp, bool val)
 {
     struct sprinter_sexp *sps = sexp_begin_value (sp);
 
@@ -202,11 +203,11 @@ sexp_separator (struct sprinter *sp)
 {
     struct sprinter_sexp *sps = (struct sprinter_sexp *) sp;
 
-    sps->insert_separator = TRUE;
+    sps->insert_separator = true;
 }
 
 struct sprinter *
-sprinter_sexp_create (const void *ctx, FILE *stream)
+sprinter_sexp_create (notmuch_database_t *db, FILE *stream)
 {
     static const struct sprinter_sexp template = {
        .vtable = {
@@ -221,16 +222,17 @@ sprinter_sexp_create (const void *ctx, FILE *stream)
            .map_key = sexp_map_key,
            .separator = sexp_separator,
            .set_prefix = sexp_set_prefix,
-           .is_text_printer = FALSE,
+           .is_text_printer = false,
        }
     };
     struct sprinter_sexp *res;
 
-    res = talloc (ctx, struct sprinter_sexp);
+    res = talloc (db, struct sprinter_sexp);
     if (! res)
        return NULL;
 
     *res = template;
+    res->vtable.notmuch = db;
     res->stream = stream;
     return &res->vtable;
 }