[PATCH v2 1/4] sprinter: add text0 formatter for null character separated text
[notmuch-archives.git] / de / 4a2ca98d9d6812ab7c0a4a3ec6b8557bde3048
1 Return-Path: <jani@nikula.org>\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 olra.theworths.org (Postfix) with ESMTP id 037AD431FB6\r
6         for <notmuch@notmuchmail.org>; Sun,  9 Dec 2012 06:56:08 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id IU2R33PpEXn7 for <notmuch@notmuchmail.org>;\r
17         Sun,  9 Dec 2012 06:56:07 -0800 (PST)\r
18 Received: from mail-la0-f53.google.com (mail-la0-f53.google.com\r
19         [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 59C2B431FAE\r
22         for <notmuch@notmuchmail.org>; Sun,  9 Dec 2012 06:56:07 -0800 (PST)\r
23 Received: by mail-la0-f53.google.com with SMTP id w12so1484159lag.26\r
24         for <notmuch@notmuchmail.org>; Sun, 09 Dec 2012 06:56:05 -0800 (PST)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=google.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
28         :in-reply-to:references:x-gm-message-state;\r
29         bh=oIyKI9+q1AfWdENA+zsqDHraydwElEClbKo9xqgXFaQ=;\r
30         b=QOpRz2qt4oWkMzost+x3YCR+ylKOAoCNwoelZyj6WCNcbSJcNdCE0rmjFKxF0oC0HP\r
31         POChpbr1l5M/gPbkn4kr8EZF72bhFkMAhEqQ9J+v3j7BbkOhVtUmNMV4NZEbLsH3JyOb\r
32         e3pI0I1zbVvs+gMGQueY99l/IgqfWwOzUjd01uu9sU+Jt0JRJpzR0y+JBxbT56T3tQFd\r
33         eN0AsCXLAqhLhCM2jZRsxuvuFWJZ2Y0c9qegQq2/cQ67PiqUCCoAZ4bjwlBa5Q/5Mk9n\r
34         h4pfo1v5zjjcIothJtmjVbhd95R5QaTpR7/B+l0StnGsSgHP7uP9g5FHW8Yj1TLW1MMS\r
35         1opQ==\r
36 Received: by 10.112.31.194 with SMTP id c2mr4745686lbi.44.1355064965775;\r
37         Sun, 09 Dec 2012 06:56:05 -0800 (PST)\r
38 Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
39         [80.223.81.27])\r
40         by mx.google.com with ESMTPS id pz9sm6651897lab.11.2012.12.09.06.56.04\r
41         (version=SSLv3 cipher=OTHER); Sun, 09 Dec 2012 06:56:04 -0800 (PST)\r
42 From: Jani Nikula <jani@nikula.org>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v2 1/4] sprinter: add text0 formatter for null character\r
45         separated text\r
46 Date: Sun,  9 Dec 2012 16:55:56 +0200\r
47 Message-Id:\r
48  <33103d6a747093548d890816bd55314043396cbd.1355064714.git.jani@nikula.org>\r
49 X-Mailer: git-send-email 1.7.10.4\r
50 In-Reply-To: <cover.1355064714.git.jani@nikula.org>\r
51 References: <cover.1355064714.git.jani@nikula.org>\r
52 In-Reply-To: <cover.1355064714.git.jani@nikula.org>\r
53 References: <cover.1355064714.git.jani@nikula.org>\r
54 X-Gm-Message-State:\r
55  ALoCoQnu46/RuFFHCVAo8Y4aahYKhhIBz7RyPnyDlqhOW0aYzhLMUAih4n260AC1lZAxh5Cx8/6P\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Sun, 09 Dec 2012 14:56:08 -0000\r
69 \r
70 Same as the text formatter, but with each field separated by a null\r
71 character rather than a newline character.\r
72 ---\r
73  sprinter-text.c |   22 ++++++++++++++++++++++\r
74  sprinter.h      |    6 ++++++\r
75  2 files changed, 28 insertions(+)\r
76 \r
77 diff --git a/sprinter-text.c b/sprinter-text.c\r
78 index 10343be..7779488 100644\r
79 --- a/sprinter-text.c\r
80 +++ b/sprinter-text.c\r
81 @@ -68,6 +68,14 @@ text_separator (struct sprinter *sp)\r
82  }\r
83  \r
84  static void\r
85 +text0_separator (struct sprinter *sp)\r
86 +{\r
87 +    struct sprinter_text *sptxt = (struct sprinter_text *) sp;\r
88 +\r
89 +    fputc ('\0', sptxt->stream);\r
90 +}\r
91 +\r
92 +static void\r
93  text_set_prefix (struct sprinter *sp, const char *prefix)\r
94  {\r
95      struct sprinter_text *sptxt = (struct sprinter_text *) sp;\r
96 @@ -133,3 +141,17 @@ sprinter_text_create (const void *ctx, FILE *stream)\r
97      res->stream = stream;\r
98      return &res->vtable;\r
99  }\r
100 +\r
101 +struct sprinter *\r
102 +sprinter_text0_create (const void *ctx, FILE *stream)\r
103 +{\r
104 +    struct sprinter *sp;\r
105 +\r
106 +    sp = sprinter_text_create (ctx, stream);\r
107 +    if (! sp)\r
108 +       return NULL;\r
109 +\r
110 +    sp->separator = text0_separator;\r
111 +\r
112 +    return sp;\r
113 +}\r
114 diff --git a/sprinter.h b/sprinter.h\r
115 index 59776a9..f36b999 100644\r
116 --- a/sprinter.h\r
117 +++ b/sprinter.h\r
118 @@ -66,6 +66,12 @@ typedef struct sprinter {\r
119  struct sprinter *\r
120  sprinter_text_create (const void *ctx, FILE *stream);\r
121  \r
122 +/* Create a new unstructured printer that emits the text format for\r
123 + * "notmuch search", with each field separated by a null character\r
124 + * instead of the newline character. */\r
125 +struct sprinter *\r
126 +sprinter_text0_create (const void *ctx, FILE *stream);\r
127 +\r
128  /* Create a new structure printer that emits JSON. */\r
129  struct sprinter *\r
130  sprinter_json_create (const void *ctx, FILE *stream);\r
131 -- \r
132 1.7.10.4\r
133 \r