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 2CDF6431FBF
\r
6 for <notmuch@notmuchmail.org>; Tue, 25 Mar 2014 10:08:03 -0700 (PDT)
\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
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 RU+4LbszokoC for <notmuch@notmuchmail.org>;
\r
17 Tue, 25 Mar 2014 10:07:59 -0700 (PDT)
\r
18 Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com
\r
19 [74.125.83.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
20 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
21 5BED8431FC0 for <notmuch@notmuchmail.org>; Tue, 25 Mar 2014 10:07:59 -0700
\r
23 Received: by mail-ee0-f52.google.com with SMTP id e49so699698eek.11
\r
24 for <notmuch@notmuchmail.org>; Tue, 25 Mar 2014 10:07:58 -0700 (PDT)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=1e100.net; s=20130820;
\r
27 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
\r
28 :references:in-reply-to:references;
\r
29 bh=eUoxc5Cau1BOQncxLPyJmpBSprrtgIScYhtrM9R6Sm0=;
\r
30 b=RHi3ji1bpszx3hTa2LG9I2oTTM5XjFqfs2EDVQ0iKuY3Jy1OWYtr2er1RCidNYor/j
\r
31 TqnXnJhRpZfyuRwBoVTeD/vg34fe8CL+hnhxouwDXxw6woOmpl0vvu0kSMTBR7Zn10sK
\r
32 /kHi2Jd/S+MBWTm666OTJ9ueeaBv9WByYxUHvq8GseU82Ar3fB2HE+RgJ7bbWIwLi7bj
\r
33 cMGbL26CWVruTzTrg5GFCiCizmbAIxA471w38+Xt+AUbX8nItXq8GNB7N16bQRgNkOOZ
\r
34 UW1mvBQxkPTn9KrxaQVoSZ2FPNAEFLQB13N2Hh0zIJ2WysTmVBznA4ucUcKqJQD2cLsC
\r
37 ALoCoQmbBYXmakBWT57yoJqWXXGI0viTAb2tKrly7rz49KxF7evSigtjkaOhtQkde4uPd9+bvzVI
\r
38 X-Received: by 10.14.39.65 with SMTP id c41mr1262236eeb.97.1395767277975;
\r
39 Tue, 25 Mar 2014 10:07:57 -0700 (PDT)
\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.
\r
42 by mx.google.com with ESMTPSA id y7sm22946700eev.5.2014.03.25.10.07.56
\r
43 for <multiple recipients>
\r
44 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
45 Tue, 25 Mar 2014 10:07:57 -0700 (PDT)
\r
46 From: Jani Nikula <jani@nikula.org>
\r
47 To: notmuch@notmuchmail.org
\r
48 Subject: [PATCH 2/2] cli: abstract dump file open from the dump command
\r
49 Date: Tue, 25 Mar 2014 19:07:50 +0200
\r
51 <92929cc512b9e9cd5ccb7d4e537671ce84de514f.1395767165.git.jani@nikula.org>
\r
52 X-Mailer: git-send-email 1.9.0
\r
53 In-Reply-To: <cover.1395767165.git.jani@nikula.org>
\r
54 References: <cover.1395767165.git.jani@nikula.org>
\r
55 In-Reply-To: <cover.1395767165.git.jani@nikula.org>
\r
56 References: <cover.1395767165.git.jani@nikula.org>
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Tue, 25 Mar 2014 17:08:03 -0000
\r
71 No functional changes, except for slight improvement in error
\r
74 notmuch-dump.c | 43 ++++++++++++++++++++++++++++---------------
\r
75 1 file changed, 28 insertions(+), 15 deletions(-)
\r
77 diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
78 index 179e2e97bf61..88bef3f77e82 100644
\r
79 --- a/notmuch-dump.c
\r
80 +++ b/notmuch-dump.c
\r
81 @@ -115,11 +115,37 @@ database_dump_file (notmuch_database_t *notmuch, FILE *output,
\r
82 return EXIT_SUCCESS;
\r
85 +/* Dump database into output_file_name if it's non-NULL, stdout
\r
89 +database_dump (notmuch_database_t *notmuch, const char *output_file_name,
\r
90 + const char *query_str, int output_format)
\r
92 + FILE *output = stdout;
\r
95 + if (output_file_name) {
\r
96 + output = fopen (output_file_name, "w");
\r
97 + if (output == NULL) {
\r
98 + fprintf (stderr, "Error opening %s for writing: %s\n",
\r
99 + output_file_name, strerror (errno));
\r
100 + return EXIT_FAILURE;
\r
104 + ret = database_dump_file (notmuch, output, query_str, output_format);
\r
106 + if (output != stdout)
\r
113 notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
\r
115 notmuch_database_t *notmuch;
\r
116 - FILE *output = stdout;
\r
117 const char *query_str = NULL;
\r
120 @@ -145,16 +171,6 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
\r
122 return EXIT_FAILURE;
\r
124 - if (output_file_name) {
\r
125 - output = fopen (output_file_name, "w");
\r
126 - if (output == NULL) {
\r
127 - fprintf (stderr, "Error opening %s for writing: %s\n",
\r
128 - output_file_name, strerror (errno));
\r
129 - return EXIT_FAILURE;
\r
134 if (opt_index < argc) {
\r
135 query_str = query_string_from_args (notmuch, argc - opt_index, argv + opt_index);
\r
136 if (query_str == NULL) {
\r
137 @@ -163,10 +179,7 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
\r
141 - ret = database_dump_file (notmuch, output, query_str, output_format);
\r
143 - if (output != stdout)
\r
145 + ret = database_dump (notmuch, output_file_name, query_str, output_format);
\r
147 notmuch_database_destroy (notmuch);
\r