1 Return-Path: <m.walters@qmul.ac.uk>
\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 0DD9D431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:24:41 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=1.401 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 FREEMAIL_REPLY=2.499, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3]
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id nj46y3h3PQo2 for <notmuch@notmuchmail.org>;
\r
18 Sat, 24 Nov 2012 05:24:40 -0800 (PST)
\r
19 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
20 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id 31EC5431FAE
\r
23 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:24:40 -0800 (PST)
\r
24 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
25 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
26 (envelope-from <m.walters@qmul.ac.uk>)
\r
27 id 1TcFii-0001xt-U8; Sat, 24 Nov 2012 13:24:35 +0000
\r
28 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
29 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
30 (envelope-from <m.walters@qmul.ac.uk>)
\r
31 id 1TcFii-0007Ms-JS; Sat, 24 Nov 2012 13:24:32 +0000
\r
32 From: Mark Walters <markwalters1009@gmail.com>
\r
33 To: notmuch@notmuchmail.org
\r
34 Subject: Re: [PATCH v2 1/7] cli: allow query to come from stdin
\r
35 In-Reply-To: <1353763256-32336-2-git-send-email-markwalters1009@gmail.com>
\r
36 References: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>
\r
37 <1353763256-32336-2-git-send-email-markwalters1009@gmail.com>
\r
38 User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1
\r
39 (x86_64-pc-linux-gnu)
\r
40 Date: Sat, 24 Nov 2012 13:24:33 +0000
\r
41 Message-ID: <87mwy7jfqm.fsf@qmul.ac.uk>
\r
43 Content-Type: text/plain; charset=us-ascii
\r
44 X-Sender-Host-Address: 93.97.24.31
\r
45 X-QM-SPAM-Info: Sender has good ham record. :)
\r
46 X-QM-Body-MD5: 9fbe8b4722f780f6d807d328c7aee5c2 (of first 20000 bytes)
\r
47 X-SpamAssassin-Score: -1.2
\r
48 X-SpamAssassin-SpamBar: -
\r
49 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
51 spam. We require at least 5.0 points to mark a message as spam.
\r
52 This message scored -1.2 points.
\r
53 Summary of the scoring:
\r
54 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
56 * [138.37.6.40 listed in list.dnswl.org]
\r
57 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
58 provider * (markwalters1009[at]gmail.com)
\r
59 * 1.0 FREEMAIL_REPLY From and body contain different freemails
\r
60 * 0.1 AWL AWL: From: address is in the auto white-list
\r
61 X-QM-Scan-Virus: ClamAV says the message is clean
\r
62 X-BeenThere: notmuch@notmuchmail.org
\r
63 X-Mailman-Version: 2.1.13
\r
65 List-Id: "Use and development of the notmuch mail system."
\r
66 <notmuch.notmuchmail.org>
\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
70 List-Post: <mailto:notmuch@notmuchmail.org>
\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
74 X-List-Received-Date: Sat, 24 Nov 2012 13:24:41 -0000
\r
77 I should have said the code for reading from stdin was
\r
78 stolen from Peter's patch for notmuch-insert
\r
79 id:1343223767-9812-4-git-send-email-novalazy@gmail.com
\r
80 (errors are of course mine)
\r
82 My apologies for not mentioning this in the commit message.
\r
88 On Sat, 24 Nov 2012, markwalters1009 <markwalters1009@gmail.com> wrote:
\r
89 > From: Mark Walters <markwalters1009@gmail.com>
\r
91 > After this series there will be times when a caller will want to pass
\r
92 > a very large query string to notmuch (eg a list of 10,000 message-ids)
\r
93 > and this can exceed the size of ARG_MAX. Hence allow notmuch to take
\r
94 > the query from stdin (if the query is -).
\r
96 > query-string.c | 41 +++++++++++++++++++++++++++++++++++++++++
\r
97 > 1 files changed, 41 insertions(+), 0 deletions(-)
\r
99 > diff --git a/query-string.c b/query-string.c
\r
100 > index 6536512..b1fbdeb 100644
\r
101 > --- a/query-string.c
\r
102 > +++ b/query-string.c
\r
103 > @@ -20,6 +20,44 @@
\r
105 > #include "notmuch-client.h"
\r
107 > +/* Read a single query string from STDIN, using
\r
108 > + * 'ctx' as the talloc owner for all allocations.
\r
110 > + * This function returns NULL in case of insufficient memory or read
\r
114 > +query_string_from_stdin (void *ctx)
\r
116 > + char *query_string;
\r
117 > + char buf[4096];
\r
118 > + ssize_t remain;
\r
120 > + query_string = talloc_strdup (ctx, "");
\r
121 > + if (query_string == NULL)
\r
125 > + remain = read (STDIN_FILENO, buf, sizeof(buf) - 1);
\r
126 > + if (remain == 0)
\r
128 > + if (remain < 0) {
\r
129 > + if (errno == EINTR)
\r
131 > + fprintf (stderr, "Error: reading from standard input: %s\n",
\r
132 > + strerror (errno));
\r
136 > + buf[remain] = '\0';
\r
137 > + query_string = talloc_strdup_append (query_string, buf);
\r
138 > + if (query_string == NULL)
\r
142 > + return query_string;
\r
145 > /* Construct a single query string from the passed arguments, using
\r
146 > * 'ctx' as the talloc owner for all allocations.
\r
148 > @@ -35,6 +73,9 @@ query_string_from_args (void *ctx, int argc, char *argv[])
\r
149 > char *query_string;
\r
152 > + if ((argc == 1) && (strcmp ("-", argv[0]) == 0))
\r
153 > + return query_string_from_stdin (ctx);
\r
155 > query_string = talloc_strdup (ctx, "");
\r
156 > if (query_string == NULL)
\r