X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=sprinter-text.c;h=7b68f98ccbb17e7a494cbc925e954af6347e3b91;hp=dfa54b5706981293ea5cf14a91ceb28137a081fb;hb=f3a56b5f6d02d72c53ae22be9a4c65c86c2faffc;hpb=14883b07003b9ed4223cd8f2c03b301fddae07bd diff --git a/sprinter-text.c b/sprinter-text.c index dfa54b57..7b68f98c 100644 --- a/sprinter-text.c +++ b/sprinter-text.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -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 @@ -38,19 +39,21 @@ text_string_len (struct sprinter *sp, const char *val, size_t len) static void text_string (struct sprinter *sp, const char *val) { + if (val == NULL) + val = ""; text_string_len (sp, val, strlen (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; @@ -65,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) { @@ -118,7 +129,7 @@ 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; @@ -131,3 +142,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; +}