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 A39B8429E3E
\r
6 for <notmuch@notmuchmail.org>; Sun, 3 Nov 2013 04:25:30 -0800 (PST)
\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 gAUrwLYers1X for <notmuch@notmuchmail.org>;
\r
17 Sun, 3 Nov 2013 04:25:24 -0800 (PST)
\r
18 Received: from mail-ee0-f50.google.com (mail-ee0-f50.google.com
\r
19 [74.125.83.50]) (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 399E8431FDE for <notmuch@notmuchmail.org>; Sun, 3 Nov 2013 04:25:08 -0800
\r
23 Received: by mail-ee0-f50.google.com with SMTP id l10so581664eei.37
\r
24 for <notmuch@notmuchmail.org>; Sun, 03 Nov 2013 04:25:07 -0800 (PST)
\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=DWEBbUuiEDmuadlgd42BYlBJOj0kYq9uRut/OMxFDXU=;
\r
30 b=UZW6cCtVzWaOSxChr+7+NEsrtQbc3t9DKzh0HAUtkx3XpvnKS/h3wTyJmgPSZ8AHtK
\r
31 cX/8niCO5V8FJhP1gAGqhh2MWLxEBkRt9h5I+qNT9Rkq6G1iNY7G3R4orkixQVFCv1H3
\r
32 G+ThAkZfXAPVRW4dRQZ7LSuSmClq7TT04n0saVdIaM0CbgV2vCxGGuwet9KXwghSjg7l
\r
33 y5eMkt+Gxrlpz9mSNHfJSLm4dTNY54VSyhhBkOwf4BhhFd3lxYAKiSohlN58CEupigXu
\r
34 kTgIhQH+G68O936JICRnX3+nHbOs4s7ZQOYGbct4UTqBgAlfm6xy+EyaoviMSgDdV+un
\r
37 ALoCoQmVQBcBe9EnXS5MMzZUqpRurdG/L4vT9Z3KheTbGqSAvH8XmyhYp4DO6VrSdlXNaD5GQZxm
\r
38 X-Received: by 10.14.224.132 with SMTP id x4mr12725741eep.5.1383481506926;
\r
39 Sun, 03 Nov 2013 04:25:06 -0800 (PST)
\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.
\r
42 by mx.google.com with ESMTPSA id k7sm32794500eeg.13.2013.11.03.04.25.05
\r
43 for <multiple recipients>
\r
44 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
45 Sun, 03 Nov 2013 04:25:06 -0800 (PST)
\r
46 From: Jani Nikula <jani@nikula.org>
\r
47 To: notmuch@notmuchmail.org
\r
48 Subject: [PATCH v2 05/11] lib: add closure parameter to compact status update
\r
50 Date: Sun, 3 Nov 2013 14:24:45 +0200
\r
52 <277337f8810959b702ddc657e88577c125cbd15e.1383481295.git.jani@nikula.org>
\r
53 X-Mailer: git-send-email 1.8.4.rc3
\r
54 In-Reply-To: <cover.1383481295.git.jani@nikula.org>
\r
55 References: <cover.1383481295.git.jani@nikula.org>
\r
56 In-Reply-To: <cover.1383481295.git.jani@nikula.org>
\r
57 References: <cover.1383481295.git.jani@nikula.org>
\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, 03 Nov 2013 12:25:31 -0000
\r
72 This provides much more flexibility for the caller.
\r
74 lib/database.cc | 14 +++++++++-----
\r
75 lib/notmuch.h | 5 +++--
\r
76 notmuch-compact.c | 8 +++-----
\r
77 3 files changed, 15 insertions(+), 12 deletions(-)
\r
79 diff --git a/lib/database.cc b/lib/database.cc
\r
80 index eadf8a7..5a01703 100644
\r
81 --- a/lib/database.cc
\r
82 +++ b/lib/database.cc
\r
83 @@ -821,9 +821,11 @@ static int rmtree (const char *path)
\r
84 class NotmuchCompactor : public Xapian::Compactor
\r
86 notmuch_compact_status_cb_t status_cb;
\r
87 + void *status_closure;
\r
90 - NotmuchCompactor(notmuch_compact_status_cb_t cb) : status_cb(cb) { }
\r
91 + NotmuchCompactor(notmuch_compact_status_cb_t cb, void *closure) :
\r
92 + status_cb(cb), status_closure(closure) { }
\r
95 set_status (const std::string &table, const std::string &status)
\r
96 @@ -842,7 +844,7 @@ public:
\r
101 + status_cb(msg, status_closure);
\r
105 @@ -861,7 +863,8 @@ public:
\r
107 notmuch_database_compact (const char* path,
\r
108 const char* backup_path,
\r
109 - notmuch_compact_status_cb_t status_cb)
\r
110 + notmuch_compact_status_cb_t status_cb,
\r
114 char *notmuch_path, *xapian_path, *compact_xapian_path;
\r
115 @@ -913,7 +916,7 @@ notmuch_database_compact (const char* path,
\r
119 - NotmuchCompactor compactor(status_cb);
\r
120 + NotmuchCompactor compactor(status_cb, closure);
\r
122 compactor.set_renumber(false);
\r
123 compactor.add_source(xapian_path);
\r
124 @@ -953,7 +956,8 @@ DONE:
\r
126 notmuch_database_compact (unused (const char* path),
\r
127 unused (const char* backup_path),
\r
128 - unused (notmuch_compact_status_cb_t status_cb))
\r
129 + unused (notmuch_compact_status_cb_t status_cb),
\r
130 + unused (void *closure))
\r
132 fprintf (stderr, "notmuch was compiled against a xapian version lacking compaction support.\n");
\r
133 return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;
\r
134 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
135 index 9dab555..cd301a4 100644
\r
136 --- a/lib/notmuch.h
\r
137 +++ b/lib/notmuch.h
\r
138 @@ -219,7 +219,7 @@ notmuch_database_close (notmuch_database_t *database);
\r
139 /* A callback invoked by notmuch_database_compact to notify the user
\r
140 * of the progress of the compaction process.
\r
142 -typedef void (*notmuch_compact_status_cb_t)(const char*);
\r
143 +typedef void (*notmuch_compact_status_cb_t)(const char *message, void *closure);
\r
145 /* Compact a notmuch database, backing up the original database to the
\r
147 @@ -231,7 +231,8 @@ typedef void (*notmuch_compact_status_cb_t)(const char*);
\r
149 notmuch_database_compact (const char* path,
\r
150 const char* backup_path,
\r
151 - notmuch_compact_status_cb_t status_cb);
\r
152 + notmuch_compact_status_cb_t status_cb,
\r
155 /* Destroy the notmuch database, closing it if necessary and freeing
\r
156 * all associated resources.
\r
157 diff --git a/notmuch-compact.c b/notmuch-compact.c
\r
158 index bfda40e..ee7afcf 100644
\r
159 --- a/notmuch-compact.c
\r
160 +++ b/notmuch-compact.c
\r
163 #include "notmuch-client.h"
\r
165 -void status_update_cb (const char *msg);
\r
168 -status_update_cb (const char *msg)
\r
170 +status_update_cb (const char *msg, unused (void *closure))
\r
172 printf("%s\n", msg);
\r
174 @@ -38,7 +36,7 @@ notmuch_compact_command (notmuch_config_t *config,
\r
175 notmuch_status_t ret;
\r
177 printf ("Compacting database...\n");
\r
178 - ret = notmuch_database_compact (path, backup_path, status_update_cb);
\r
179 + ret = notmuch_database_compact (path, backup_path, status_update_cb, NULL);
\r
181 fprintf (stderr, "Compaction failed: %s\n", notmuch_status_to_string(ret));
\r