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 0285B429E42
\r
6 for <notmuch@notmuchmail.org>; Sun, 31 Mar 2013 02:46:18 -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 TkkLLiEWwB7K for <notmuch@notmuchmail.org>;
\r
17 Sun, 31 Mar 2013 02:46:16 -0700 (PDT)
\r
18 Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com
\r
19 [209.85.217.173]) (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 64F4E429E31
\r
22 for <notmuch@notmuchmail.org>; Sun, 31 Mar 2013 02:46:13 -0700 (PDT)
\r
23 Received: by mail-lb0-f173.google.com with SMTP id w20so1236208lbh.4
\r
24 for <notmuch@notmuchmail.org>; Sun, 31 Mar 2013 02:46:12 -0700 (PDT)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=google.com; s=20120113;
\r
27 h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to
\r
28 :references:in-reply-to:references:x-gm-message-state;
\r
29 bh=0J6jsAbnii4LrMwbBNnf/7MJgkQV9xH0Nm1qFiQY0zc=;
\r
30 b=G3W6t8+6yp44tV6iehQ6aDTXTqTe/xrFrADKAERW8rmWF8W64XiGrq5t5ygpsMGEAO
\r
31 sLYb3+mq26otu2gDjFX5gSdLr59UFlRAccoPgQVfareUBCP2uqvJL+vGYn4t0vpM9RNg
\r
32 Z+DoLnMbikkvsB9AgzpLcjNLvddjTdEtAJF1ThrUcIeishgie73Bt6LwJvJu3l+h3eHY
\r
33 CZAJ2TZni8n5u8ppF3KBPi/XysQOTM6eIGB+L6yD0tw8Mem3DjnvRtakSxMx6Wgyeief
\r
34 /p6L6MVL3oY5I2eLjMcmerD+jsG81yHIJL6E9Bw6AprEfuzhyk8Kv+rjX3wzWssLgFcs
\r
36 X-Received: by 10.112.125.129 with SMTP id mq1mr3998724lbb.116.1364723171953;
\r
37 Sun, 31 Mar 2013 02:46:11 -0700 (PDT)
\r
38 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.
\r
40 by mx.google.com with ESMTPS id sl5sm3723030lbb.10.2013.03.31.02.46.10
\r
41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
42 Sun, 31 Mar 2013 02:46:11 -0700 (PDT)
\r
43 From: Jani Nikula <jani@nikula.org>
\r
44 To: notmuch@notmuchmail.org
\r
45 Subject: [PATCH v3 2/6] cli: extract count printing to a separate function in
\r
47 Date: Sun, 31 Mar 2013 12:45:59 +0300
\r
49 <a669137c4eef2c91f9572f5dc97b9ad115280e2a.1364722841.git.jani@nikula.org>
\r
50 X-Mailer: git-send-email 1.7.10.4
\r
51 In-Reply-To: <cover.1364722841.git.jani@nikula.org>
\r
52 References: <cover.1364722841.git.jani@nikula.org>
\r
53 In-Reply-To: <cover.1364722841.git.jani@nikula.org>
\r
54 References: <cover.1364722841.git.jani@nikula.org>
\r
56 ALoCoQmqUuy7YcoV3j8yXVjQm+wSHi3fSRjYVmCotCXgyVtNMawOkZY+8fD00cekM2QKYHEEpG70
\r
57 Cc: Tomi Ollila <tomi.ollila@iki.fi>
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.13
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Sun, 31 Mar 2013 09:46:18 -0000
\r
72 Make count printing on a query string reusable. No functional changes.
\r
74 notmuch-count.c | 59 +++++++++++++++++++++++++++++++++----------------------
\r
75 1 file changed, 36 insertions(+), 23 deletions(-)
\r
77 diff --git a/notmuch-count.c b/notmuch-count.c
\r
78 index c2f1b7d..630f036 100644
\r
79 --- a/notmuch-count.c
\r
80 +++ b/notmuch-count.c
\r
81 @@ -32,16 +32,47 @@ enum {
\r
86 +print_count (notmuch_database_t *notmuch, const char *query_str,
\r
87 + const char **exclude_tags, size_t exclude_tags_length, int output)
\r
89 + notmuch_query_t *query;
\r
92 + query = notmuch_query_create (notmuch, query_str);
\r
93 + if (query == NULL) {
\r
94 + fprintf (stderr, "Out of memory\n");
\r
98 + for (i = 0; i < exclude_tags_length; i++)
\r
99 + notmuch_query_add_tag_exclude (query, exclude_tags[i]);
\r
101 + switch (output) {
\r
102 + case OUTPUT_MESSAGES:
\r
103 + printf ("%u\n", notmuch_query_count_messages (query));
\r
105 + case OUTPUT_THREADS:
\r
106 + printf ("%u\n", notmuch_query_count_threads (query));
\r
110 + notmuch_query_destroy (query);
\r
116 notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
\r
118 notmuch_database_t *notmuch;
\r
119 - notmuch_query_t *query;
\r
122 int output = OUTPUT_MESSAGES;
\r
123 int exclude = EXCLUDE_TRUE;
\r
125 + const char **search_exclude_tags = NULL;
\r
126 + size_t search_exclude_tags_length = 0;
\r
129 notmuch_opt_desc_t options[] = {
\r
130 { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',
\r
131 @@ -71,33 +102,15 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
\r
135 - query = notmuch_query_create (notmuch, query_str);
\r
136 - if (query == NULL) {
\r
137 - fprintf (stderr, "Out of memory\n");
\r
141 if (exclude == EXCLUDE_TRUE) {
\r
142 - const char **search_exclude_tags;
\r
143 - size_t search_exclude_tags_length;
\r
145 search_exclude_tags = notmuch_config_get_search_exclude_tags
\r
146 (config, &search_exclude_tags_length);
\r
147 - for (i = 0; i < search_exclude_tags_length; i++)
\r
148 - notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
\r
151 - switch (output) {
\r
152 - case OUTPUT_MESSAGES:
\r
153 - printf ("%u\n", notmuch_query_count_messages (query));
\r
155 - case OUTPUT_THREADS:
\r
156 - printf ("%u\n", notmuch_query_count_threads (query));
\r
159 + ret = print_count (notmuch, query_str, search_exclude_tags,
\r
160 + search_exclude_tags_length, output);
\r
162 - notmuch_query_destroy (query);
\r
163 notmuch_database_destroy (notmuch);
\r