[PATCH v2 13/14] cli/reply: pass gmime message to munge detection
[notmuch-archives.git] / bf / 4f3bf0a9e6a68ab544e3c51e93f3a1868e6d5e
1 Return-Path: <markwalters1009@gmail.com>\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 83905431FAF\r
6         for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:12 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 Ze9zCkWgspL2 for <notmuch@notmuchmail.org>;\r
18         Sat, 24 Nov 2012 05:21:10 -0800 (PST)\r
19 Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
20  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  822C5431FC0    for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:05 -0800\r
23  (PST)\r
24 Received: by mail-wg0-f45.google.com with SMTP id dq11so3973532wgb.2\r
25         for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:03 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=FCVh/gxBXG1O6Lt2mYXnoXzaGl1oLD6pAd/1YfJkoYQ=;\r
29         b=P3zP59r3xa6mMS8lmvIgf0p3w9QvSstl9xWYH+x+cQS2TA0tAClDAW35vOvgGp0Ss2\r
30         Ybv6gtR26rT6LN1iLFPyBmb0WjDftRAL3Vlv9Ci4q4yhqoVgM6/b+Zug86tJY9qTlvdf\r
31         G7WTUafRTZGpiScp8JtyOXRHjrJmH3dD6yQZveEMo4QqcQdrwZD39My6VVbkeAZlM0RK\r
32         rbBOqIEw5/AaVJiQbrWK0fB9l7x/cEuuJHRyyzbgId7YAgpiTiBVIHM2O1pRtb8jQVsM\r
33         LAq0MsjZBCgApGg6sCiohiT+KOHzb3Ge5W+2uEeyNi4QAVg67ooc75o1rGLXAeqAq9Br\r
34         YNzw==\r
35 Received: by 10.180.86.7 with SMTP id l7mr10271711wiz.5.1353763262987;\r
36         Sat, 24 Nov 2012 05:21:02 -0800 (PST)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPS id gz3sm12685328wib.2.2012.11.24.05.21.01\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sat, 24 Nov 2012 05:21:02 -0800 (PST)\r
41 From: markwalters1009 <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v2 1/7] cli: allow query to come from stdin\r
44 Date: Sat, 24 Nov 2012 13:20:50 +0000\r
45 Message-Id: <1353763256-32336-2-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sat, 24 Nov 2012 13:21:13 -0000\r
62 \r
63 From: Mark Walters <markwalters1009@gmail.com>\r
64 \r
65 After this series there will be times when a caller will want to pass\r
66 a very large query string to notmuch (eg a list of 10,000 message-ids)\r
67 and this can exceed the size of ARG_MAX. Hence allow notmuch to take\r
68 the query from stdin (if the query is -).\r
69 ---\r
70  query-string.c |   41 +++++++++++++++++++++++++++++++++++++++++\r
71  1 files changed, 41 insertions(+), 0 deletions(-)\r
72 \r
73 diff --git a/query-string.c b/query-string.c\r
74 index 6536512..b1fbdeb 100644\r
75 --- a/query-string.c\r
76 +++ b/query-string.c\r
77 @@ -20,6 +20,44 @@\r
78  \r
79  #include "notmuch-client.h"\r
80  \r
81 +/* Read a single query string from STDIN, using\r
82 + * 'ctx' as the talloc owner for all allocations.\r
83 + *\r
84 + * This function returns NULL in case of insufficient memory or read\r
85 + * errors.\r
86 + */\r
87 +static char *\r
88 +query_string_from_stdin (void *ctx)\r
89 +{\r
90 +    char *query_string;\r
91 +    char buf[4096];\r
92 +    ssize_t remain;\r
93 +\r
94 +    query_string = talloc_strdup (ctx, "");\r
95 +    if (query_string == NULL)\r
96 +       return NULL;\r
97 +\r
98 +    for (;;) {\r
99 +       remain = read (STDIN_FILENO, buf, sizeof(buf) - 1);\r
100 +       if (remain == 0)\r
101 +           break;\r
102 +       if (remain < 0) {\r
103 +           if (errno == EINTR)\r
104 +               continue;\r
105 +           fprintf (stderr, "Error: reading from standard input: %s\n",\r
106 +                    strerror (errno));\r
107 +           return NULL;\r
108 +       }\r
109 +\r
110 +       buf[remain] = '\0';\r
111 +       query_string = talloc_strdup_append (query_string, buf);\r
112 +       if (query_string == NULL)\r
113 +           return NULL;\r
114 +    }\r
115 +\r
116 +    return query_string;\r
117 +}\r
118 +\r
119  /* Construct a single query string from the passed arguments, using\r
120   * 'ctx' as the talloc owner for all allocations.\r
121   *\r
122 @@ -35,6 +73,9 @@ query_string_from_args (void *ctx, int argc, char *argv[])\r
123      char *query_string;\r
124      int i;\r
125  \r
126 +    if ((argc == 1) && (strcmp ("-", argv[0]) == 0))\r
127 +       return query_string_from_stdin (ctx);\r
128 +\r
129      query_string = talloc_strdup (ctx, "");\r
130      if (query_string == NULL)\r
131         return NULL;\r
132 -- \r
133 1.7.9.1\r
134 \r