unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ioan-Adrian Ratiu <adi@adirat.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 06/11] sprinter: add unsigned_long printer function
Date: Fri, 19 May 2017 01:27:03 +0300	[thread overview]
Message-ID: <20170518222708.30032-7-adi@adirat.com> (raw)
In-Reply-To: <20170518222708.30032-1-adi@adirat.com>

We need to output unsigned long values for message and thread
(sum of all message's) file sizes.

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
---
 sprinter-json.c | 9 +++++++++
 sprinter-sexp.c | 9 +++++++++
 sprinter-text.c | 9 +++++++++
 sprinter.h      | 1 +
 4 files changed, 28 insertions(+)

diff --git a/sprinter-json.c b/sprinter-json.c
index 0a077907..de1dbec2 100644
--- a/sprinter-json.c
+++ b/sprinter-json.c
@@ -132,6 +132,14 @@ json_integer (struct sprinter *sp, int val)
 }
 
 static void
+json_unsigned_long (struct sprinter *sp, unsigned long val)
+{
+    struct sprinter_json *spj = json_begin_value (sp);
+
+    fprintf (spj->stream, "%lu", val);
+}
+
+static void
 json_boolean (struct sprinter *sp, notmuch_bool_t val)
 {
     struct sprinter_json *spj = json_begin_value (sp);
@@ -181,6 +189,7 @@ sprinter_json_create (const void *ctx, FILE *stream)
 	    .string = json_string,
 	    .string_len = json_string_len,
 	    .integer = json_integer,
+	    .unsigned_long = json_unsigned_long,
 	    .boolean = json_boolean,
 	    .null = json_null,
 	    .map_key = json_map_key,
diff --git a/sprinter-sexp.c b/sprinter-sexp.c
index 08783e11..3162ad9c 100644
--- a/sprinter-sexp.c
+++ b/sprinter-sexp.c
@@ -169,6 +169,14 @@ sexp_integer (struct sprinter *sp, int val)
 }
 
 static void
+sexp_unsigned_long (struct sprinter *sp, unsigned long val)
+{
+    struct sprinter_sexp *sps = sexp_begin_value (sp);
+
+    fprintf (sps->stream, "%lu", val);
+}
+
+static void
 sexp_boolean (struct sprinter *sp, notmuch_bool_t val)
 {
     struct sprinter_sexp *sps = sexp_begin_value (sp);
@@ -216,6 +224,7 @@ sprinter_sexp_create (const void *ctx, FILE *stream)
 	    .string = sexp_string,
 	    .string_len = sexp_string_len,
 	    .integer = sexp_integer,
+	    .unsigned_long = sexp_unsigned_long,
 	    .boolean = sexp_boolean,
 	    .null = sexp_null,
 	    .map_key = sexp_map_key,
diff --git a/sprinter-text.c b/sprinter-text.c
index 7779488f..5d1607e9 100644
--- a/sprinter-text.c
+++ b/sprinter-text.c
@@ -52,6 +52,14 @@ text_integer (struct sprinter *sp, int val)
 }
 
 static void
+text_unsigned_long (struct sprinter *sp, unsigned long val)
+{
+    struct sprinter_text *sptxt = (struct sprinter_text *) sp;
+
+    fprintf (sptxt->stream, "%lu", val);
+}
+
+static void
 text_boolean (struct sprinter *sp, notmuch_bool_t val)
 {
     struct sprinter_text *sptxt = (struct sprinter_text *) sp;
@@ -123,6 +131,7 @@ sprinter_text_create (const void *ctx, FILE *stream)
 	    .string = text_string,
 	    .string_len = text_string_len,
 	    .integer = text_integer,
+	    .unsigned_long = text_unsigned_long,
 	    .boolean = text_boolean,
 	    .null = text_null,
 	    .map_key = text_map_key,
diff --git a/sprinter.h b/sprinter.h
index f859672f..2495a7d1 100644
--- a/sprinter.h
+++ b/sprinter.h
@@ -34,6 +34,7 @@ typedef struct sprinter {
     void (*string) (struct sprinter *, const char *);
     void (*string_len) (struct sprinter *, const char *, size_t);
     void (*integer) (struct sprinter *, int);
+    void (*unsigned_long) (struct sprinter *, unsigned long);
     void (*boolean) (struct sprinter *, notmuch_bool_t);
     void (*null) (struct sprinter *);
 
-- 
2.13.0

  parent reply	other threads:[~2017-05-18 22:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18 22:26 [PATCH v2 00/11] Add filesize index, search, sort & emacs UI Ioan-Adrian Ratiu
2017-05-18 22:26 ` [PATCH v2 01/11] lib: message: index message file sizes Ioan-Adrian Ratiu
2017-06-06 23:47   ` David Bremner
2017-06-08 11:39   ` David Bremner
2017-05-18 22:26 ` [PATCH v2 02/11] lib: database: store message filesize & add range processor Ioan-Adrian Ratiu
2017-06-09 23:18   ` David Bremner
2017-05-18 22:27 ` [PATCH v2 03/11] notmuch-search: add filesize based sort order Ioan-Adrian Ratiu
2017-05-19  9:42   ` Tomi Ollila
2017-05-22 13:37     ` Ioan-Adrian Ratiu
2017-06-10  0:30   ` David Bremner
2017-05-18 22:27 ` [PATCH v2 04/11] emacs: make notmuch-search-oldest-first generic Ioan-Adrian Ratiu
2017-06-11  0:13   ` David Bremner
2017-05-18 22:27 ` [PATCH v2 05/11] emacs: notmuch-search: add filesize sorting Ioan-Adrian Ratiu
2017-06-11  0:15   ` David Bremner
2017-05-18 22:27 ` Ioan-Adrian Ratiu [this message]
2017-05-23 16:53   ` [PATCH v2 06/11] sprinter: add unsigned_long printer function Jani Nikula
2017-05-18 22:27 ` [PATCH v2 07/11] lib: thread: add thread total size function Ioan-Adrian Ratiu
2017-06-11  0:16   ` David Bremner
2017-05-18 22:27 ` [PATCH v2 08/11] notmuch-search: output total_filesize thread result Ioan-Adrian Ratiu
2017-06-11  0:22   ` David Bremner
2017-05-18 22:27 ` [PATCH v2 09/11] notmuch-show: export message filesize Ioan-Adrian Ratiu
2017-06-11  0:42   ` David Bremner
2017-05-18 22:27 ` [PATCH v2 10/11] emacs: notmuch-search: add display thread sizes capability Ioan-Adrian Ratiu
2017-06-11  0:24   ` David Bremner
2017-06-11  0:40   ` David Bremner
2017-05-18 22:27 ` [PATCH v2 11/11] emacs: notmuch-show: add filesize to headerline Ioan-Adrian Ratiu
2017-06-11  0:55   ` David Bremner
2017-05-23 17:19 ` [PATCH v2 00/11] Add filesize index, search, sort & emacs UI Jani Nikula
2017-05-23 19:20   ` Ioan-Adrian Ratiu
2017-06-06 18:51 ` David Bremner
2017-06-06 23:11   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170518222708.30032-7-adi@adirat.com \
    --to=adi@adirat.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).