1 Return-Path: <novalazy@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 89D44431FC7
\r
6 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:43:34 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, 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 nFaOfaNTjffL for <notmuch@notmuchmail.org>;
\r
17 Wed, 25 Jul 2012 06:43:34 -0700 (PDT)
\r
18 Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com
\r
19 [209.85.160.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 CE6DC431FC0
\r
22 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:43:33 -0700 (PDT)
\r
23 Received: by pbbrr13 with SMTP id rr13so1767731pbb.26
\r
24 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:43:32 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
27 bh=FDzi2AF74nfQDqwhuBLhWA2JoXw1SZxEaoP74HHfBMM=;
\r
28 b=EqsEh9z1sLN8NcuTLr2YCY8Z6uOUGf+OorDUMZQAKStvR1JcdRG8MWFKCTPnaFRp8i
\r
29 oPcqknqoSl4ASVLX73eq3RWFHUE7wdlF/W8Id5V089StT1B7skJzBbNx1wQRh2aFIE8W
\r
30 4G6iobs74mcd/wuM/18KCPfd2D9Z5AU+j9ADsn2HeWJyTfr0mqIghLlDCtiU2YdPsohO
\r
31 Q5T0R9wwnm68fW12YBySbC22UR+vaubtIF5iOA20uqyuuhDbuvqVDmIKXbPi6qL3G9yM
\r
32 ij6TAeIqwrTLHJofPegRC5zCxdhP3p8hu3e3MQZ7lyBFsqcpjN0a3yR+9Ecfa99pKqql
\r
34 Received: by 10.68.223.198 with SMTP id qw6mr53562392pbc.94.1343223812044;
\r
35 Wed, 25 Jul 2012 06:43:32 -0700 (PDT)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id nv6sm14410633pbc.42.2012.07.25.06.43.29
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Wed, 25 Jul 2012 06:43:31 -0700 (PDT)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 04/18] insert: copy stdin to Maildir tmp file
\r
44 Date: Wed, 25 Jul 2012 23:42:33 +1000
\r
45 Message-Id: <1343223767-9812-4-git-send-email-novalazy@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.4.4
\r
47 In-Reply-To: <1343223767-9812-1-git-send-email-novalazy@gmail.com>
\r
48 References: <1343223767-9812-1-git-send-email-novalazy@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\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: Wed, 25 Jul 2012 13:43:34 -0000
\r
63 Read the new message from standard input into the Maildir tmp file.
\r
65 notmuch-insert.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
\r
66 1 files changed, 49 insertions(+), 2 deletions(-)
\r
68 diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
69 index f01a6f2..340f7e4 100644
\r
70 --- a/notmuch-insert.c
\r
71 +++ b/notmuch-insert.c
\r
72 @@ -75,21 +75,68 @@ maildir_open_tmp (void *ctx, const char *dir, char **tmppath, char **newpath)
\r
75 static notmuch_bool_t
\r
76 +copy_fd_data (int fdin, int fdout)
\r
84 + remain = read (fdin, buf, sizeof(buf));
\r
88 + if (errno == EINTR)
\r
90 + fprintf (stderr, "Error: reading from standard input: %s\n",
\r
91 + strerror (errno));
\r
97 + written = write (fdout, p, remain);
\r
100 + if (written < 0) {
\r
101 + if (errno == EINTR)
\r
103 + fprintf (stderr, "Error: writing to temporary file: %s",
\r
104 + strerror (errno));
\r
108 + remain -= written;
\r
109 + } while (remain > 0);
\r
115 +static notmuch_bool_t
\r
116 insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
122 + notmuch_bool_t ret;
\r
124 fdout = maildir_open_tmp (ctx, dir, &tmppath, &newpath);
\r
129 + ret = copy_fd_data (fdin, fdout);
\r
132 - unlink (tmppath);
\r
136 + unlink (tmppath);
\r