1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 79E566DE1B83
\r
6 for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 16:01:36 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.564 tagged_above=-999 required=5 tests=[AWL=0.554,
\r
12 T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id bfzld1fAu9Lw for <notmuch@notmuchmail.org>;
\r
16 Sun, 5 Apr 2015 16:01:34 -0700 (PDT)
\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net
\r
19 by arlo.cworth.org (Postfix) with ESMTPS id B0A006DE1B72
\r
20 for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 16:01:34 -0700 (PDT)
\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim
\r
22 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
23 id 1YetXA-0002om-S7; Sun, 05 Apr 2015 23:00:52 +0000
\r
24 Received: (nullmailer pid 2243 invoked by uid 1000); Sun, 05 Apr 2015
\r
26 From: David Bremner <david@tethera.net>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [WIP2 04/12] cli: add type introspection to sprinter type
\r
29 Date: Mon, 6 Apr 2015 07:59:06 +0900
\r
30 Message-Id: <1428274754-1698-5-git-send-email-david@tethera.net>
\r
31 X-Mailer: git-send-email 2.1.4
\r
32 In-Reply-To: <1428274754-1698-1-git-send-email-david@tethera.net>
\r
33 References: <1428274754-1698-1-git-send-email-david@tethera.net>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.18
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Sun, 05 Apr 2015 23:01:36 -0000
\r
48 This will make it easier to skip generating certain output for the
\r
51 sprinter-json.c | 1 +
\r
52 sprinter-sexp.c | 1 +
\r
53 sprinter-text.c | 1 +
\r
54 sprinter.h | 10 ++++++++++
\r
55 4 files changed, 13 insertions(+)
\r
57 diff --git a/sprinter-json.c b/sprinter-json.c
\r
58 index 0a07790..8e5ffbe 100644
\r
59 --- a/sprinter-json.c
\r
60 +++ b/sprinter-json.c
\r
61 @@ -175,6 +175,7 @@ sprinter_json_create (const void *ctx, FILE *stream)
\r
63 static const struct sprinter_json template = {
\r
65 + .type = NOTMUCH_SPRINTER_JSON,
\r
66 .begin_map = json_begin_map,
\r
67 .begin_list = json_begin_list,
\r
69 diff --git a/sprinter-sexp.c b/sprinter-sexp.c
\r
70 index 0aa51e8..e187c05 100644
\r
71 --- a/sprinter-sexp.c
\r
72 +++ b/sprinter-sexp.c
\r
73 @@ -210,6 +210,7 @@ sprinter_sexp_create (const void *ctx, FILE *stream)
\r
75 static const struct sprinter_sexp template = {
\r
77 + .type = NOTMUCH_SPRINTER_SEXP,
\r
78 .begin_map = sexp_begin_map,
\r
79 .begin_list = sexp_begin_list,
\r
81 diff --git a/sprinter-text.c b/sprinter-text.c
\r
82 index 7779488..cd6cd56 100644
\r
83 --- a/sprinter-text.c
\r
84 +++ b/sprinter-text.c
\r
85 @@ -117,6 +117,7 @@ sprinter_text_create (const void *ctx, FILE *stream)
\r
87 static const struct sprinter_text template = {
\r
89 + .type = NOTMUCH_SPRINTER_TEXT,
\r
90 .begin_map = text_begin_map,
\r
91 .begin_list = text_begin_list,
\r
93 diff --git a/sprinter.h b/sprinter.h
\r
94 index f859672..7e58f69 100644
\r
98 /* Necessary for notmuch_bool_t */
\r
99 #include "notmuch-client.h"
\r
101 +enum notmuch_sprinter_type {
\r
102 + NOTMUCH_SPRINTER_JSON,
\r
103 + NOTMUCH_SPRINTER_SEXP,
\r
104 + NOTMUCH_SPRINTER_TEXT
\r
107 /* Structure printer interface. This is used to create output
\r
108 * structured as maps (with key/value pairs), lists and primitives
\r
109 * (strings, integers and booleans).
\r
111 typedef struct sprinter {
\r
112 + /* Identify the type of sprinter
\r
114 + enum notmuch_sprinter_type type;
\r
116 /* Start a new map/dictionary structure. This should be followed by
\r
117 * a sequence of alternating calls to map_key and one of the
\r
118 * value-printing functions until the map is ended by end.
\r