]> git.notmuchmail.org Git - notmuch/blob - notmuch.h
Fix "notmuch new" (bad performance, and no committing of results).
[notmuch] / notmuch.h
1 /* notmuch - Not much of an email library, (just index and search)
2  *
3  * Copyright © 2009 Carl Worth
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see http://www.gnu.org/licenses/ .
17  *
18  * Author: Carl Worth <cworth@cworth.org>
19  */
20
21 #ifndef NOTMUCH_H
22 #define NOTMUCH_H
23
24 #ifdef  __cplusplus
25 # define NOTMUCH_BEGIN_DECLS  extern "C" {
26 # define NOTMUCH_END_DECLS    }
27 #else
28 # define NOTMUCH_BEGIN_DECLS
29 # define NOTMUCH_END_DECLS
30 #endif
31
32 NOTMUCH_BEGIN_DECLS
33
34 #include <time.h>
35
36 #ifndef FALSE
37 #define FALSE 0
38 #endif
39
40 #ifndef TRUE
41 #define TRUE 1
42 #endif
43
44 typedef int notmuch_bool_t;
45
46 /* Status codes used for the return values of most functions.
47  *
48  * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
49  * completed without error. Any other value indicates an error as
50  * follows:
51  *
52  * NOTMUCH_STATUS_SUCCESS: No error occurred.
53  *
54  * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory
55  *
56  * XXX: We don't really want to expose this lame XAPIAN_EXCEPTION
57  * value. Instead we should map to things like DATABASE_LOCKED or
58  * whatever.
59  *
60  * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
61  *
62  * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to read or
63  *      write to a file (this could be file not found, permission
64  *      denied, etc.)
65  *
66  * NOTMUCH_STATUS_FILE_NOT_EMAIL: A file was presented that doesn't
67  *      appear to be an email message.
68  *
69  * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: A file contains a message ID
70  *      that is identical to a message already in the database.
71  *
72  * NOTMUCH_STATUS_NULL_POINTER: The user erroneously passed a NULL
73  *      pointer to a notmuch function.
74  *
75  * NOTMUCH_STATUS_TAG_TOO_LONG: A tag value is too long (exceeds
76  *      NOTMUCH_TAG_MAX)
77  *
78  * NOTMUCH_STATUS_LAST_STATUS: Not an actual status value. Just a way
79  *      to find out how many valid status values there are.
80  */
81 typedef enum _notmuch_status {
82     NOTMUCH_STATUS_SUCCESS = 0,
83     NOTMUCH_STATUS_OUT_OF_MEMORY,
84     NOTMUCH_STATUS_XAPIAN_EXCEPTION,
85     NOTMUCH_STATUS_FILE_ERROR,
86     NOTMUCH_STATUS_FILE_NOT_EMAIL,
87     NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
88     NOTMUCH_STATUS_NULL_POINTER,
89     NOTMUCH_STATUS_TAG_TOO_LONG,
90
91     NOTMUCH_STATUS_LAST_STATUS
92 } notmuch_status_t;
93
94 /* Get a string representation of a notmuch_status_t value.
95  *
96  * The result is readonly.
97  */
98 const char *
99 notmuch_status_to_string (notmuch_status_t status);
100
101 /* Various opaque data types. For each notmuch_<foo>_t see the various
102  * notmuch_<foo> functions below. */
103 typedef struct _notmuch_database notmuch_database_t;
104 typedef struct _notmuch_query notmuch_query_t;
105 typedef struct _notmuch_thread_results notmuch_thread_results_t;
106 typedef struct _notmuch_thread notmuch_thread_t;
107 typedef struct _notmuch_message_results notmuch_message_results_t;
108 typedef struct _notmuch_message notmuch_message_t;
109 typedef struct _notmuch_tags notmuch_tags_t;
110
111 /* Lookup the default database path.
112  *
113  * This is the path that will be used by notmuch_database_create and
114  * notmuch_database_open if given a NULL path. Specifically it will be
115  * the value of the NOTMUCH_BASE environment variable if set,
116  * otherwise ${HOME}/mail
117  *
118  * Returns a newly allocated string which the caller should free()
119  * when finished with it.
120  */
121 char *
122 notmuch_database_default_path (void);
123
124 /* Create a new, empty notmuch database located at 'path'.
125  *
126  * The path should be a top-level directory to a collection of
127  * plain-text email messages (one message per file). This call will
128  * create a new ".notmuch" directory within 'path' where notmuch will
129  * store its data.
130  *
131  * Passing a value of NULL for 'path' will cause notmuch to open the
132  * default database. The default database path can be specified by the
133  * NOTMUCH_BASE environment variable, and is equivalent to
134  * ${HOME}/mail if NOTMUCH_BASE is not set.
135  *
136  * After a successful call to notmuch_database_create, the returned
137  * database will be open so the caller should call
138  * notmuch_database_close when finished with it.
139  *
140  * The database will not yet have any data in it
141  * (notmuch_database_create itself is a very cheap function). Messages
142  * contained within 'path' can be added to the database by calling
143  * notmuch_database_add_message.
144  *
145  * In case of any failure, this function returns NULL, (after printing
146  * an error message on stderr).
147  */
148 notmuch_database_t *
149 notmuch_database_create (const char *path);
150
151 /* XXX: I think I'd like this to take an extra argument of
152  * notmuch_status_t* for returning a status value on failure. */
153
154 /* Open a an existing notmuch database located at 'path'.
155  *
156  * The database should have been created at some time in the past,
157  * (not necessarily by this process), by calling
158  * notmuch_database_create with 'path'.
159  *
160  * An existing notmuch database can be identified by the presence of a
161  * directory named ".notmuch" below 'path'.
162  *
163  * Passing a value of NULL for 'path' will cause notmuch to open the
164  * default database. The default database path can be specified by the
165  * NOTMUCH_BASE environment variable, and is equivalent to
166  * ${HOME}/mail if NOTMUCH_BASE is not set.
167  *
168  * The caller should call notmuch_database_close when finished with
169  * this database.
170  *
171  * In case of any failure, this function returns NULL, (after printing
172  * an error message on stderr).
173  */
174 notmuch_database_t *
175 notmuch_database_open (const char *path);
176
177 /* Close the given notmuch database, freeing all associated
178  * resources. See notmuch_database_open. */
179 void
180 notmuch_database_close (notmuch_database_t *database);
181
182 /* Return the database path of the given database.
183  *
184  * The return value is a string owned by notmuch so should not be
185  * modified nor freed by the caller. */
186 const char *
187 notmuch_database_get_path (notmuch_database_t *database);
188
189 /* Store a timestamp within the database.
190  *
191  * The Notmuch database will not interpret this key nor the timestamp
192  * values at all. It will merely store them together and return the
193  * timestamp when notmuch_database_get_timestamp is called with the
194  * same value for 'key'.
195  *
196  * The intention is for the caller to use the timestamp to allow
197  * efficient identification of new messages to be added to the
198  * database. The recommended usage is as follows:
199  *
200  *   o Read the mtime of a directory from the filesystem
201  *
202  *   o Call add_message for all mail files in the directory
203  *
204  *   o Call notmuch_database_set_timestamp with the path of the
205  *     directory as 'key' and the originally read mtime as 'value'.
206  *
207  * Then, when wanting to check for updates to the directory in the
208  * future, the client can call notmuch_database_get_timestamp and know
209  * that it only needs to add files if the mtime of the directory and
210  * files are newer than the stored timestamp.
211  *
212  * Note: The notmuch_database_get_timestamp function does not allow
213  * the caller to distinguish a timestamp of 0 from a non-existent
214  * timestamp. So don't store a timestamp of 0 unless you are
215  * comfortable with that.
216  *
217  * Return value:
218  *
219  * NOTMUCH_STATUS_SUCCESS: Timestamp successfully stored in database.
220  *
221  * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception
222  *      occurred. Timestamp not stored.
223  */
224 notmuch_status_t
225 notmuch_database_set_timestamp (notmuch_database_t *database,
226                                 const char *key, time_t timestamp);
227
228 /* Retrieve a timestamp from the database.
229  *
230  * Returns the timestamp value previously stored by calling
231  * notmuch_database_set_timestamp with the same value for 'key'.
232  *
233  * Returns 0 if no timestamp is stored for 'key' or if any error
234  * occurred querying the database.
235  */
236 time_t
237 notmuch_database_get_timestamp (notmuch_database_t *database,
238                                 const char *key);
239
240 /* Add a new message to the given notmuch database.
241  *
242  * Here,'filename' should be a path relative to the the path of
243  * 'database' (see notmuch_database_get_path). The file should be a
244  * single mail message (not a multi-message mbox) that is expected to
245  * remain at its current location, (since the notmuch database will
246  * reference the filename, and will not copy the entire contents of
247  * the file.
248  *
249  * If 'message' is not NULL, then '*message' will be initialized to a
250  * message object that can be used for things such as adding tags to
251  * the just-added message. The user should call
252  * notmuch_message_destroy when done with the message.
253  *
254  * Return value:
255  *
256  * NOTMUCH_STATUS_SUCCESS: Message successfully added to database.
257  *
258  * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: Message has the same message
259  *      ID as another message already in the database. Nothing added
260  *      to the database.
261  *
262  * NOTMUCH_STATUS_FILE_ERROR: an error occurred trying to open the
263  *      file, (such as permission denied, or file not found,
264  *      etc.). Nothing added to the database.
265  *
266  * NOTMUCH_STATUS_FILE_NOT_EMAIL: the contents of filename don't look
267  *      like an email message. Nothing added to the database.
268  */
269 notmuch_status_t
270 notmuch_database_add_message (notmuch_database_t *database,
271                               const char *filename,
272                               notmuch_message_t **message);
273
274 /* Find a message with the given messsage_id.
275  *
276  * If the database contains a message with the given message_id, then
277  * a new notmuch_message_t object is returned. The caller should call
278  * notmuch_message_destroy when done with the message.
279  *
280  * If no message is found with the given message_id or if an
281  * out-of-memory situation occurs, this function returns NULL.
282  */
283 notmuch_message_t *
284 notmuch_database_find_message (notmuch_database_t *database,
285                                const char *message_id);
286
287 /* Create a new query for 'database'.
288  *
289  * Here, 'database' should be an open database, (see
290  * notmuch_database_open and notmuch_database_create).
291  *
292  * For the query string, we'll document the syntax here more
293  * completely in the future, but it's likely to be a specialized
294  * version of the general Xapian query syntax:
295  *
296  * http://xapian.org/docs/queryparser.html
297  *
298  * As a special case, passing a length-zero string, (that is ""), will
299  * result in a query that returns all messages in the database.
300  *
301  * See notmuch_query_set_sort for controlling the order of results and
302  * notmuch_query_search to actually execute the query.
303  *
304  * User should call notmuch_query_destroy when finished with this
305  * query.
306  *
307  * Will return NULL if insufficient memory is available.
308  */
309 notmuch_query_t *
310 notmuch_query_create (notmuch_database_t *database,
311                       const char *query_string);
312
313 /* Sort values for notmuch_query_set_sort */
314 typedef enum {
315     NOTMUCH_SORT_DATE_OLDEST_FIRST,
316     NOTMUCH_SORT_DATE_NEWEST_FIRST,
317     NOTMUCH_SORT_MESSAGE_ID
318 } notmuch_sort_t;
319
320 /* Specify the sorting desired for this query. */
321 void
322 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
323
324 /* Execute a query for threads, returning a notmuch_thread_results_t
325  * object which can be used to iterate over the results. The results
326  * object is owned by the query and as such, will only be valid until
327  * notmuch_query_destroy.
328  *
329  * Typical usage might be:
330  *
331  *     notmuch_query_t *query;
332  *     notmuch_thread_results_t *results;
333  *     notmuch_thread_t *thread;
334  *
335  *     query = notmuch_query_create (database, query_string);
336  *
337  *     for (results = notmuch_query_search_threads (query);
338  *          notmuch_thread_results_has_more (results);
339  *          notmuch_thread_results_advance (results))
340  *     {
341  *         thread = notmuch_thread_results_get (results);
342  *         ....
343  *         notmuch_thread_destroy (thread);
344  *     }
345  *
346  *     notmuch_query_destroy (query);
347  *
348  * Note: If you are finished with a thread before its containing
349  * query, you can call notmuch_thread_destroy to clean up some memory
350  * sooner (as in the above example). Otherwise, if your thread objects
351  * are long-lived, then you don't need to call notmuch_thread_destroy
352  * and all the memory will still be reclaimed when the query is
353  * destroyed.
354  *
355  * Note that there's no explicit destructor needed for the
356  * notmuch_thread_results_t object. (For consistency, we do provide a
357  * notmuch_thread_results_destroy function, but there's no good reason
358  * to call it if the query is about to be destroyed).
359  */
360 notmuch_thread_results_t *
361 notmuch_query_search_threads (notmuch_query_t *query);
362
363 /* Execute a query for messages, returning a notmuch_message_results_t
364  * object which can be used to iterate over the results. The results
365  * object is owned by the query and as such, will only be valid until
366  * notmuch_query_destroy.
367  *
368  * Typical usage might be:
369  *
370  *     notmuch_query_t *query;
371  *     notmuch_message_results_t *results;
372  *     notmuch_message_t *message;
373  *
374  *     query = notmuch_query_create (database, query_string);
375  *
376  *     for (results = notmuch_query_search_messages (query);
377  *          notmuch_message_results_has_more (results);
378  *          notmuch_message_results_advance (results))
379  *     {
380  *         message = notmuch_message_results_get (results);
381  *         ....
382  *         notmuch_message_destroy (message);
383  *     }
384  *
385  *     notmuch_query_destroy (query);
386  *
387  * Note: If you are finished with a message before its containing
388  * query, you can call notmuch_message_destroy to clean up some memory
389  * sooner (as in the above example). Otherwise, if your message
390  * objects are long-lived, then you don't need to call
391  * notmuch_message_destroy and all the memory will still be reclaimed
392  * when the query is destroyed.
393  *
394  * Note that there's no explicit destructor needed for the
395  * notmuch_message_results_t object. (For consistency, we do provide a
396  * notmuch_message_results_destroy function, but there's no good
397  * reason to call it if the query is about to be destroyed).
398  */
399 notmuch_message_results_t *
400 notmuch_query_search_messages (notmuch_query_t *query);
401
402 /* Destroy a notmuch_query_t along with any associated resources.
403  *
404  * This will in turn destroy any notmuch_thread_results_t and
405  * notmuch_message_results_t objects generated by this query, (and in
406  * turn any notmuch_thrad_t and notmuch_message_t objects generated
407  * from those results, etc.), if such objects haven't already been
408  * destroyed.
409  */
410 void
411 notmuch_query_destroy (notmuch_query_t *query);
412
413 /* Does the given notmuch_thread_results_t object contain any more
414  * results.
415  *
416  * When this function returns TRUE, notmuch_thread_results_get will
417  * return a valid object. Whereas when this function returns FALSE,
418  * notmuch_thread_results_get will return NULL.
419  *
420  * See the documentation of notmuch_query_search_threads for example
421  * code showing how to iterate over a notmuch_thread_results_t object.
422  */
423 notmuch_bool_t
424 notmuch_thread_results_has_more (notmuch_thread_results_t *results);
425
426 /* Get the current result from 'results' as a notmuch_thread_t.
427  *
428  * Note: The returned thread belongs to 'results' and has a lifetime
429  * identical to it (and the query to which it belongs).
430  *
431  * See the documentation of notmuch_query_search_threads for example
432  * code showing how to iterate over a notmuch_thread_results_t object.
433  *
434  * If an out-of-memory situation occurs, this function will return
435  * NULL.
436  */
437 notmuch_thread_t *
438 notmuch_thread_results_get (notmuch_thread_results_t *results);
439
440 /* Advance the 'results' iterator to the next result.
441  *
442  * See the documentation of notmuch_query_search_threads for example
443  * code showing how to iterate over a notmuch_thread_results_t object.
444  */
445 void
446 notmuch_thread_results_advance (notmuch_thread_results_t *results);
447
448 /* Destroy a notmuch_thread_results_t object.
449  *
450  * It's not strictly necessary to call this function. All memory from
451  * the notmuch_thread_results_t object will be reclaimed when the
452  * containg query object is destroyed.
453  */
454 void
455 notmuch_thread_results_destroy (notmuch_thread_results_t *results);
456
457 /* Get the thread ID of 'thread'.
458  *
459  * The returned string belongs to 'thread' and as such, should not be
460  * modified by the caller and will only be valid for as long as the
461  * thread is valid, (which is until notmuch_thread_destroy or until
462  * the query from which it derived is destroyed).
463  */
464 const char *
465 notmuch_thread_get_thread_id (notmuch_thread_t *thread);
466
467 /* Get the subject of 'thread'
468  *
469  * The subject is taken from the first message (according to the query
470  * order---see notmuch_query_set_sort) in the query results that
471  * belongs to this thread.
472  *
473  * The returned string belongs to 'thread' and as such, should not be
474  * modified by the caller and will only be valid for as long as the
475  * thread is valid, (which is until notmuch_thread_destroy or until
476  * the query from which it derived is destroyed).
477  */
478 const char *
479 notmuch_thread_get_subject (notmuch_thread_t *thread);
480
481 /* Get the tags for 'thread', returning a notmuch_tags_t object which
482  * can be used to iterate over all tags.
483  *
484  * Note: In the Notmuch database, tags are stored on individual
485  * messages, not on threads. So the tags returned here will be all
486  * tags of the messages which matched the search and which belong to
487  * this thread.
488  *
489  * The tags object is owned by the thread and as such, will only be
490  * valid for as long as the thread is valid, (for example, until
491  * notmuch_thread_destroy or until the query from which it derived is
492  * destroyed).
493  *
494  * Typical usage might be:
495  *
496  *     notmuch_thread_t *thread;
497  *     notmuch_tags_t *tags;
498  *     const char *tag;
499  *
500  *     thread = notmuch_thread_results_get (thread_results);
501  *
502  *     for (tags = notmuch_thread_get_tags (thread);
503  *          notmuch_tags_has_more (tags);
504  *          notmuch_result_advance (tags))
505  *     {
506  *         tag = notmuch_tags_get (tags);
507  *         ....
508  *     }
509  *
510  *     notmuch_thread_destroy (thread);
511  *
512  * Note that there's no explicit destructor needed for the
513  * notmuch_tags_t object. (For consistency, we do provide a
514  * notmuch_tags_destroy function, but there's no good reason to call
515  * it if the message is about to be destroyed).
516  */
517 notmuch_tags_t *
518 notmuch_thread_get_tags (notmuch_thread_t *thread);
519
520 /* Destroy a notmuch_thread_t object. */
521 void
522 notmuch_thread_destroy (notmuch_thread_t *thread);
523
524 /* Does the given notmuch_message_results_t object contain any more
525  * results.
526  *
527  * When this function returns TRUE, notmuch_message_results_get will
528  * return a valid object. Whereas when this function returns FALSE,
529  * notmuch_message_results_get will return NULL.
530  *
531  * See the documentation of notmuch_query_search_messages for example
532  * code showing how to iterate over a notmuch_message_results_t
533  * object.
534  */
535 notmuch_bool_t
536 notmuch_message_results_has_more (notmuch_message_results_t *results);
537
538 /* Get the current result from 'results' as a notmuch_message_t.
539  *
540  * Note: The returned message belongs to 'results' and has a lifetime
541  * identical to it (and the query to which it belongs).
542  *
543  * See the documentation of notmuch_query_search_messages for example
544  * code showing how to iterate over a notmuch_message_results_t
545  * object.
546  *
547  * If an out-of-memory situation occurs, this function will return
548  * NULL.
549  */
550 notmuch_message_t *
551 notmuch_message_results_get (notmuch_message_results_t *results);
552
553 /* Advance the 'results' iterator to the next result.
554  *
555  * See the documentation of notmuch_query_search_messages for example
556  * code showing how to iterate over a notmuch_message_results_t
557  * object.
558  */
559 void
560 notmuch_message_results_advance (notmuch_message_results_t *results);
561
562 /* Destroy a notmuch_message_results_t object.
563  *
564  * It's not strictly necessary to call this function. All memory from
565  * the notmuch_message_results_t object will be reclaimed when the
566  * containg query object is destroyed.
567  */
568 void
569 notmuch_message_results_destroy (notmuch_message_results_t *results);
570
571 /* Get the message ID of 'message'.
572  *
573  * The returned string belongs to 'message' and as such, should not be
574  * modified by the caller and will only be valid for as long as the
575  * message is valid, (which is until the query from which it derived
576  * is destroyed).
577  *
578  * This function will not return NULL since Notmuch ensures that every
579  * message has a unique message ID, (Notmuch will generate an ID for a
580  * message if the original file does not contain one).
581  */
582 const char *
583 notmuch_message_get_message_id (notmuch_message_t *message);
584
585 /* Get the thread ID of 'message'.
586  *
587  * The returned string belongs to 'message' and as such, should not be
588  * modified by the caller and will only be valid for as long as the
589  * message is valid, (for example, until the user calls
590  * notmuch_message_destroy on 'message' or until a query from which it
591  * derived is destroyed).
592  *
593  * This function will not return NULL since Notmuch ensures that every
594  * message belongs to a single thread.
595  */
596 const char *
597 notmuch_message_get_thread_id (notmuch_message_t *message);
598
599 /* Get the filename for the email corresponding to 'message'.
600  *
601  * The returned filename is relative to the base of the database from
602  * which 'message' was obtained. See notmuch_database_get_path() .
603  * The returned string belongs to the message so should not be
604  * modified or freed by the caller (nor should it be referenced after
605  * the message is destroyed). */
606 const char *
607 notmuch_message_get_filename (notmuch_message_t *message);
608
609 /* Get the tags for 'message', returning a notmuch_tags_t object which
610  * can be used to iterate over all tags.
611  *
612  * The tags object is owned by the message and as such, will only be
613  * valid for as long as the message is valid, (which is until the
614  * query from which it derived is destroyed).
615  *
616  * Typical usage might be:
617  *
618  *     notmuch_message_t *message;
619  *     notmuch_tags_t *tags;
620  *     const char *tag;
621  *
622  *     message = notmuch_database_find_message (database, message_id);
623  *
624  *     for (tags = notmuch_message_get_tags (message);
625  *          notmuch_tags_has_more (tags);
626  *          notmuch_result_advance (tags))
627  *     {
628  *         tag = notmuch_tags_get (tags);
629  *         ....
630  *     }
631  *
632  *     notmuch_message_destroy (message);
633  *
634  * Note that there's no explicit destructor needed for the
635  * notmuch_tags_t object. (For consistency, we do provide a
636  * notmuch_tags_destroy function, but there's no good reason to call
637  * it if the message is about to be destroyed).
638  */
639 notmuch_tags_t *
640 notmuch_message_get_tags (notmuch_message_t *message);
641
642 /* The longest possible tag value. */
643 #define NOTMUCH_TAG_MAX 200
644
645 /* Add a tag to the given message.
646  *
647  * Return value:
648  *
649  * NOTMUCH_STATUS_SUCCESS: Tag successfully added to message
650  *
651  * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
652  *
653  * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is longer than
654  *      too long (exceeds NOTMUCH_TAG_MAX)
655  */
656 notmuch_status_t
657 notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
658
659 /* Remove a tag from the given message.
660  *
661  * Return value:
662  *
663  * NOTMUCH_STATUS_SUCCESS: Tag successfully added to message
664  *
665  * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
666  *
667  * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is longer than
668  *      too long (exceeds NOTMUCH_TAG_MAX)
669  */
670 notmuch_status_t
671 notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
672
673 /* Destroy a notmuch_message_t object.
674  *
675  * It can be useful to call this function in the case of a single
676  * query object with many messages in the result, (such as iterating
677  * over the entire database). Otherwise, it's fine to never call this
678  * function and there will still be no memory leaks. (The memory from
679  * the messages get reclaimed when the containing query is destroyed.)
680  */
681 void
682 notmuch_message_destroy (notmuch_message_t *message);
683
684 /* Does the given notmuch_tags_t object contain any more tags.
685  *
686  * When this function returns TRUE, notmuch_tags_get will return a
687  * valid string. Whereas when this function returns FALSE,
688  * notmuch_tags_get will return NULL.
689  *
690  * See the documentation of notmuch_message_get_tags for example code
691  * showing how to iterate over a notmuch_tags_t object.
692  */
693 notmuch_bool_t
694 notmuch_tags_has_more (notmuch_tags_t *tags);
695
696 /* Get the current tag from 'tags' as a string.
697  *
698  * Note: The returned string belongs to 'tags' and has a lifetime
699  * identical to it (and the query to which it utlimately belongs).
700  *
701  * See the documentation of notmuch_message_get_tags for example code
702  * showing how to iterate over a notmuch_tags_t object.
703  */
704 const char *
705 notmuch_tags_get (notmuch_tags_t *tags);
706
707 /* Advance the 'tags' iterator to the next tag.
708  *
709  * See the documentation of notmuch_message_get_tags for example code
710  * showing how to iterate over a notmuch_tags_t object.
711  */
712 void
713 notmuch_tags_advance (notmuch_tags_t *tags);
714
715 /* Destroy a notmuch_tags_t object.
716  *
717  * It's not strictly necessary to call this function. All memory from
718  * the notmuch_tags_t object will be reclaimed when the containg
719  * message or query objects are destroyed.
720  */
721 void
722 notmuch_tags_destroy (notmuch_tags_t *tags);
723
724 NOTMUCH_END_DECLS
725
726 #endif