[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / a6 / 7cd38bbc89187bf74aecf31f51a4699f815b38
1 Return-Path: <ethan.glasser.camp@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 1C210431FB6\r
6         for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:54:08 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 1.061\r
10 X-Spam-Level: *\r
11 X-Spam-Status: No, score=1.061 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_BL_SPAMCOP_NET=1.246,\r
14         RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=0.614] 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 1mh-z2GsTlVk for <notmuch@notmuchmail.org>;\r
18         Mon, 25 Jun 2012 13:54:07 -0700 (PDT)\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
20         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 09637431FAF\r
23         for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:54:06 -0700 (PDT)\r
24 Received: by werj55 with SMTP id j55so3649559wer.26\r
25         for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:54:05 -0700 (PDT)\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=nrU9nVmzJXJsXKqS8m11Z17v5gUa/3MWhEq27JiKUS0=;\r
29         b=06M9rpHV51pq0hSDUnstkj43T96lpndJYsr7E4fkp9ggg47Cp1277Rs7O7Zu4gO0DC\r
30         L6D7d1TdJztUdDfVcBItE86vII7fymd9GecWXTJ3JRBu87qq5ACbwnXBbGdrYkAA2FwX\r
31         ef33s8OZ4w3CvknGX55pWvnQsgeewwGZzyr3ONT5sdV+qg69wgxEi575UFTOl8Y+1h9M\r
32         WhfK3Z/jNHZx1dl4KWBRY8nPLKJr9ndIwvY8+EjOVUtI3HFK/DKPlqnylUrYPksaCU6c\r
33         p3isfgN7zSTp9hCeQ90zLZRjfFN7TCWYmLuiOwZNMljTiWH0R7uPFaq1qVDiAR2s3/VW\r
34         Ga0A==\r
35 Received: by 10.180.24.39 with SMTP id r7mr27675594wif.9.1340657645740;\r
36         Mon, 25 Jun 2012 13:54:05 -0700 (PDT)\r
37 Received: from localhost ([195.24.209.21])\r
38         by mx.google.com with ESMTPS id t8sm34175wiy.3.2012.06.25.13.54.00\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Mon, 25 Jun 2012 13:54:04 -0700 (PDT)\r
41 From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [RFC PATCH 11/14] notmuch-new: pull out useful bits of\r
44         add_files_recursive\r
45 Date: Mon, 25 Jun 2012 16:51:54 -0400\r
46 Message-Id: <1340657517-6539-7-git-send-email-ethan@betacantrips.com>\r
47 X-Mailer: git-send-email 1.7.9.5\r
48 In-Reply-To: <1340657517-6539-1-git-send-email-ethan@betacantrips.com>\r
49 References: <1340657517-6539-1-git-send-email-ethan@betacantrips.com>\r
50 X-Mailman-Approved-At: Tue, 26 Jun 2012 03:51:54 -0700\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Mon, 25 Jun 2012 20:54:08 -0000\r
64 \r
65 This is part of notmuch-new refactor phase 1: make add_files stuff\r
66 safe for other backends. add_files_recursive is essentially a\r
67 maildir-crawling function that periodically adds files to the database\r
68 or adds filenames to remove_files or remove_directory lists. I don't\r
69 see an easy way to adapt add_files_recursive for other backends who\r
70 might not have concepts of directories with other directories inside\r
71 of them, so instead just provide an add_files method for each backend.\r
72 \r
73 This patch pulls some bits out of add_files_recursive which will be\r
74 useful for other backends: two reporting functions\r
75 _report_before_adding_file and _report_added_file, as well as\r
76 _add_message, which actually does the message adding.\r
77 \r
78 Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
79 ---\r
80  notmuch-new.c |  192 +++++++++++++++++++++++++++++++++++----------------------\r
81  1 file changed, 119 insertions(+), 73 deletions(-)\r
82 \r
83 diff --git a/notmuch-new.c b/notmuch-new.c\r
84 index 57b27bf..1bf4e25 100644\r
85 --- a/notmuch-new.c\r
86 +++ b/notmuch-new.c\r
87 @@ -249,6 +249,122 @@ add_files_uri (unused(notmuch_database_t *notmuch),\r
88      return NOTMUCH_STATUS_SUCCESS;\r
89  }\r
90  \r
91 +/* Progress-reporting function.\r
92 + *\r
93 + * Can be used by any mailstore-crawling function that wants to alert\r
94 + * users what message it's about to add. Subsequent errors will be due\r
95 + * to this message ;)\r
96 + */\r
97 +static void\r
98 +_report_before_adding_file (add_files_state_t *state, const char *filename)\r
99 +{\r
100 +    state->processed_files++;\r
101 +\r
102 +    if (state->verbose) {\r
103 +       if (state->output_is_a_tty)\r
104 +           printf("\r\033[K");\r
105 +\r
106 +       printf ("%i/%i: %s",\r
107 +               state->processed_files,\r
108 +               state->total_files,\r
109 +               filename);\r
110 +\r
111 +       putchar((state->output_is_a_tty) ? '\r' : '\n');\r
112 +       fflush (stdout);\r
113 +    }\r
114 +}\r
115 +\r
116 +/* Progress-reporting function.\r
117 + *\r
118 + * Call this to respond to the signal handler for SIGALRM.\r
119 + */\r
120 +static void\r
121 +_report_added_file (add_files_state_t *state)\r
122 +{\r
123 +    if (do_print_progress) {\r
124 +       do_print_progress = 0;\r
125 +       generic_print_progress ("Processed", "files", state->tv_start,\r
126 +                               state->processed_files, state->total_files);\r
127 +    }\r
128 +}\r
129 +\r
130 +\r
131 +/* Atomically handles adding a message to the database.\r
132 + *\r
133 + * Should be used by any mailstore-crawling function that finds a new\r
134 + * message to add.\r
135 + */\r
136 +static notmuch_status_t\r
137 +_add_message (add_files_state_t *state, notmuch_database_t *notmuch,\r
138 +             const char *filename)\r
139 +{\r
140 +    notmuch_status_t status, ret = NOTMUCH_STATUS_SUCCESS;\r
141 +    notmuch_message_t *message;\r
142 +    const char **tag;\r
143 +\r
144 +    status = notmuch_database_begin_atomic (notmuch);\r
145 +    if (status) {\r
146 +       ret = status;\r
147 +       goto DONE;\r
148 +    }\r
149 +\r
150 +    status = notmuch_database_add_message (notmuch, filename, &message);\r
151 +\r
152 +    switch (status) {\r
153 +    /* success */\r
154 +    case NOTMUCH_STATUS_SUCCESS:\r
155 +       state->added_messages++;\r
156 +       notmuch_message_freeze (message);\r
157 +       for (tag=state->new_tags; *tag != NULL; tag++)\r
158 +           notmuch_message_add_tag (message, *tag);\r
159 +       if (state->synchronize_flags == TRUE)\r
160 +           notmuch_message_maildir_flags_to_tags (message);\r
161 +       notmuch_message_thaw (message);\r
162 +       break;\r
163 +    /* Non-fatal issues (go on to next file) */\r
164 +    case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
165 +       if (state->synchronize_flags == TRUE)\r
166 +           notmuch_message_maildir_flags_to_tags (message);\r
167 +       break;\r
168 +    case NOTMUCH_STATUS_FILE_NOT_EMAIL:\r
169 +       fprintf (stderr, "Note: Ignoring non-mail file: %s\n",\r
170 +                filename);\r
171 +       break;\r
172 +    /* Fatal issues. Don't process anymore. */\r
173 +    case NOTMUCH_STATUS_READ_ONLY_DATABASE:\r
174 +    case NOTMUCH_STATUS_XAPIAN_EXCEPTION:\r
175 +    case NOTMUCH_STATUS_OUT_OF_MEMORY:\r
176 +       fprintf (stderr, "Error: %s. Halting processing.\n",\r
177 +                notmuch_status_to_string (status));\r
178 +       ret = status;\r
179 +       goto DONE;\r
180 +    default:\r
181 +    case NOTMUCH_STATUS_FILE_ERROR:\r
182 +    case NOTMUCH_STATUS_NULL_POINTER:\r
183 +    case NOTMUCH_STATUS_TAG_TOO_LONG:\r
184 +    case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:\r
185 +    case NOTMUCH_STATUS_UNBALANCED_ATOMIC:\r
186 +    case NOTMUCH_STATUS_LAST_STATUS:\r
187 +       INTERNAL_ERROR ("add_message returned unexpected value: %d",  status);\r
188 +       ret = status;\r
189 +       goto DONE;\r
190 +    }\r
191 +\r
192 +    status = notmuch_database_end_atomic (notmuch);\r
193 +    if (status) {\r
194 +       ret = status;\r
195 +       goto DONE;\r
196 +    }\r
197 +\r
198 +  DONE:\r
199 +    if (message) {\r
200 +       notmuch_message_destroy (message);\r
201 +       message = NULL;\r
202 +    }\r
203 +\r
204 +    return ret;\r
205 +}\r
206 +\r
207  /* Examine 'path' recursively as follows:\r
208   *\r
209   *   o Ask the filesystem for the mtime of 'path' (fs_mtime)\r
210 @@ -300,7 +416,6 @@ add_files (notmuch_database_t *notmuch,\r
211      char *next = NULL, *path_uri = NULL;\r
212      time_t fs_mtime, db_mtime;\r
213      notmuch_status_t status, ret = NOTMUCH_STATUS_SUCCESS;\r
214 -    notmuch_message_t *message = NULL;\r
215      struct dirent **fs_entries = NULL;\r
216      int i, num_fs_entries = 0, entry_type;\r
217      notmuch_directory_t *directory;\r
218 @@ -309,7 +424,6 @@ add_files (notmuch_database_t *notmuch,\r
219      time_t stat_time;\r
220      struct stat st;\r
221      notmuch_bool_t is_maildir;\r
222 -    const char **tag;\r
223  \r
224      if (stat (path, &st)) {\r
225         fprintf (stderr, "Error reading directory %s: %s\n",\r
226 @@ -488,83 +602,15 @@ add_files (notmuch_database_t *notmuch,\r
227          * in the database, so add it. */\r
228         next = talloc_asprintf (notmuch, "%s/%s", path_uri, entry->d_name);\r
229  \r
230 -       state->processed_files++;\r
231 -\r
232 -       if (state->verbose) {\r
233 -           if (state->output_is_a_tty)\r
234 -               printf("\r\033[K");\r
235 -\r
236 -           printf ("%i/%i: %s",\r
237 -                   state->processed_files,\r
238 -                   state->total_files,\r
239 -                   next);\r
240 -\r
241 -           putchar((state->output_is_a_tty) ? '\r' : '\n');\r
242 -           fflush (stdout);\r
243 -       }\r
244 +       _report_before_adding_file (state, next);\r
245  \r
246 -       status = notmuch_database_begin_atomic (notmuch);\r
247 +       status = _add_message (state, notmuch, next);\r
248         if (status) {\r
249             ret = status;\r
250             goto DONE;\r
251         }\r
252  \r
253 -       status = notmuch_database_add_message (notmuch, next, &message);\r
254 -       switch (status) {\r
255 -       /* success */\r
256 -       case NOTMUCH_STATUS_SUCCESS:\r
257 -           state->added_messages++;\r
258 -           notmuch_message_freeze (message);\r
259 -           for (tag=state->new_tags; *tag != NULL; tag++)\r
260 -               notmuch_message_add_tag (message, *tag);\r
261 -           if (state->synchronize_flags == TRUE)\r
262 -               notmuch_message_maildir_flags_to_tags (message);\r
263 -           notmuch_message_thaw (message);\r
264 -           break;\r
265 -       /* Non-fatal issues (go on to next file) */\r
266 -       case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
267 -           if (state->synchronize_flags == TRUE)\r
268 -               notmuch_message_maildir_flags_to_tags (message);\r
269 -           break;\r
270 -       case NOTMUCH_STATUS_FILE_NOT_EMAIL:\r
271 -           fprintf (stderr, "Note: Ignoring non-mail file: %s\n",\r
272 -                    next);\r
273 -           break;\r
274 -       /* Fatal issues. Don't process anymore. */\r
275 -       case NOTMUCH_STATUS_READ_ONLY_DATABASE:\r
276 -       case NOTMUCH_STATUS_XAPIAN_EXCEPTION:\r
277 -       case NOTMUCH_STATUS_OUT_OF_MEMORY:\r
278 -           fprintf (stderr, "Error: %s. Halting processing.\n",\r
279 -                    notmuch_status_to_string (status));\r
280 -           ret = status;\r
281 -           goto DONE;\r
282 -       default:\r
283 -       case NOTMUCH_STATUS_FILE_ERROR:\r
284 -       case NOTMUCH_STATUS_NULL_POINTER:\r
285 -       case NOTMUCH_STATUS_TAG_TOO_LONG:\r
286 -       case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:\r
287 -       case NOTMUCH_STATUS_UNBALANCED_ATOMIC:\r
288 -       case NOTMUCH_STATUS_LAST_STATUS:\r
289 -           INTERNAL_ERROR ("add_message returned unexpected value: %d",  status);\r
290 -           goto DONE;\r
291 -       }\r
292 -\r
293 -       status = notmuch_database_end_atomic (notmuch);\r
294 -       if (status) {\r
295 -           ret = status;\r
296 -           goto DONE;\r
297 -       }\r
298 -\r
299 -       if (message) {\r
300 -           notmuch_message_destroy (message);\r
301 -           message = NULL;\r
302 -       }\r
303 -\r
304 -       if (do_print_progress) {\r
305 -           do_print_progress = 0;\r
306 -           generic_print_progress ("Processed", "files", state->tv_start,\r
307 -                                   state->processed_files, state->total_files);\r
308 -       }\r
309 +       _report_added_file (state);\r
310  \r
311         talloc_free (next);\r
312         next = NULL;\r
313 -- \r
314 1.7.9.5\r
315 \r