1 /* notmuch - Not much of an email library, (just index and search)
3 * Copyright © 2009 Carl Worth
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.
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.
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/ .
18 * Author: Carl Worth <cworth@cworth.org>
22 * @defgroup notmuch The notmuch API
24 * Not much of an email library, (just index and search)
35 # define NOTMUCH_BEGIN_DECLS extern "C" {
36 # define NOTMUCH_END_DECLS }
38 # define NOTMUCH_BEGIN_DECLS
39 # define NOTMUCH_END_DECLS
55 * The library version number. This must agree with the soname
56 * version in Makefile.local.
58 #define LIBNOTMUCH_MAJOR_VERSION 4
59 #define LIBNOTMUCH_MINOR_VERSION 3
60 #define LIBNOTMUCH_MICRO_VERSION 0
63 #if defined (__clang_major__) && __clang_major__ >= 3 \
64 || defined (__GNUC__) && __GNUC__ >= 5 \
65 || defined (__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5
66 #define NOTMUCH_DEPRECATED(major,minor) \
67 __attribute__ ((deprecated ("function deprecated as of libnotmuch " #major "." #minor)))
69 #define NOTMUCH_DEPRECATED(major,minor) __attribute__ ((deprecated))
73 #endif /* __DOXYGEN__ */
76 * Check the version of the notmuch library being compiled against.
78 * Return true if the library being compiled against is of the
79 * specified version or above. For example:
82 * #if LIBNOTMUCH_CHECK_VERSION(3, 1, 0)
83 * (code requiring libnotmuch 3.1.0 or above)
87 * LIBNOTMUCH_CHECK_VERSION has been defined since version 3.1.0; to
88 * check for versions prior to that, use:
91 * #if !defined(NOTMUCH_CHECK_VERSION)
92 * (code requiring libnotmuch prior to 3.1.0)
96 #define LIBNOTMUCH_CHECK_VERSION (major, minor, micro) \
97 (LIBNOTMUCH_MAJOR_VERSION > (major) || \
98 (LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION > (minor)) || \
99 (LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION == (minor) && \
100 LIBNOTMUCH_MICRO_VERSION >= (micro)))
103 * Notmuch boolean type.
105 typedef int notmuch_bool_t;
108 * Status codes used for the return values of most functions.
110 * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
111 * completed without error. Any other value indicates an error.
113 typedef enum _notmuch_status {
117 NOTMUCH_STATUS_SUCCESS = 0,
121 NOTMUCH_STATUS_OUT_OF_MEMORY,
123 * An attempt was made to write to a database opened in read-only
126 NOTMUCH_STATUS_READ_ONLY_DATABASE,
128 * A Xapian exception occurred.
130 NOTMUCH_STATUS_XAPIAN_EXCEPTION,
132 * An error occurred trying to read or write to a file (this could
133 * be file not found, permission denied, etc.)
135 * @todo We don't really want to expose this lame XAPIAN_EXCEPTION
136 * value. Instead we should map to things like DATABASE_LOCKED or
139 NOTMUCH_STATUS_FILE_ERROR,
141 * A file was presented that doesn't appear to be an email
144 NOTMUCH_STATUS_FILE_NOT_EMAIL,
146 * A file contains a message ID that is identical to a message
147 * already in the database.
149 NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
151 * The user erroneously passed a NULL pointer to a notmuch
154 NOTMUCH_STATUS_NULL_POINTER,
156 * A tag value is too long (exceeds NOTMUCH_TAG_MAX).
158 NOTMUCH_STATUS_TAG_TOO_LONG,
160 * The notmuch_message_thaw function has been called more times
161 * than notmuch_message_freeze.
163 NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
165 * notmuch_database_end_atomic has been called more times than
166 * notmuch_database_begin_atomic.
168 NOTMUCH_STATUS_UNBALANCED_ATOMIC,
170 * The operation is not supported.
172 NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
174 * The operation requires a database upgrade.
176 NOTMUCH_STATUS_UPGRADE_REQUIRED,
178 * There is a problem with the proposed path, e.g. a relative path
179 * passed to a function expecting an absolute path.
181 NOTMUCH_STATUS_PATH_ERROR,
183 * Not an actual status value. Just a way to find out how many
184 * valid status values there are.
186 NOTMUCH_STATUS_LAST_STATUS
190 * Get a string representation of a notmuch_status_t value.
192 * The result is read-only.
195 notmuch_status_to_string (notmuch_status_t status);
197 /* Various opaque data types. For each notmuch_<foo>_t see the various
198 * notmuch_<foo> functions below. */
200 typedef struct _notmuch_database notmuch_database_t;
201 typedef struct _notmuch_query notmuch_query_t;
202 typedef struct _notmuch_threads notmuch_threads_t;
203 typedef struct _notmuch_thread notmuch_thread_t;
204 typedef struct _notmuch_messages notmuch_messages_t;
205 typedef struct _notmuch_message notmuch_message_t;
206 typedef struct _notmuch_tags notmuch_tags_t;
207 typedef struct _notmuch_directory notmuch_directory_t;
208 typedef struct _notmuch_filenames notmuch_filenames_t;
209 typedef struct _notmuch_config_list notmuch_config_list_t;
210 #endif /* __DOXYGEN__ */
213 * Create a new, empty notmuch database located at 'path'.
215 * The path should be a top-level directory to a collection of
216 * plain-text email messages (one message per file). This call will
217 * create a new ".notmuch" directory within 'path' where notmuch will
220 * After a successful call to notmuch_database_create, the returned
221 * database will be open so the caller should call
222 * notmuch_database_destroy when finished with it.
224 * The database will not yet have any data in it
225 * (notmuch_database_create itself is a very cheap function). Messages
226 * contained within 'path' can be added to the database by calling
227 * notmuch_database_add_message.
229 * In case of any failure, this function returns an error status and
230 * sets *database to NULL (after printing an error message on stderr).
234 * NOTMUCH_STATUS_SUCCESS: Successfully created the database.
236 * NOTMUCH_STATUS_NULL_POINTER: The given 'path' argument is NULL.
238 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
240 * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to create the
241 * database file (such as permission denied, or file not found,
242 * etc.), or the database already exists.
244 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred.
247 notmuch_database_create (const char *path, notmuch_database_t **database);
250 * Like notmuch_database_create, except optionally return an error
251 * message. This message is allocated by malloc and should be freed by
255 notmuch_database_create_verbose (const char *path,
256 notmuch_database_t **database,
257 char **error_message);
260 * Database open mode for notmuch_database_open.
264 * Open database for reading only.
266 NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
268 * Open database for reading and writing.
270 NOTMUCH_DATABASE_MODE_READ_WRITE
271 } notmuch_database_mode_t;
274 * Open an existing notmuch database located at 'path'.
276 * The database should have been created at some time in the past,
277 * (not necessarily by this process), by calling
278 * notmuch_database_create with 'path'. By default the database should be
279 * opened for reading only. In order to write to the database you need to
280 * pass the NOTMUCH_DATABASE_MODE_READ_WRITE mode.
282 * An existing notmuch database can be identified by the presence of a
283 * directory named ".notmuch" below 'path'.
285 * The caller should call notmuch_database_destroy when finished with
288 * In case of any failure, this function returns an error status and
289 * sets *database to NULL (after printing an error message on stderr).
293 * NOTMUCH_STATUS_SUCCESS: Successfully opened the database.
295 * NOTMUCH_STATUS_NULL_POINTER: The given 'path' argument is NULL.
297 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
299 * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to open the
300 * database file (such as permission denied, or file not found,
301 * etc.), or the database version is unknown.
303 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred.
306 notmuch_database_open (const char *path,
307 notmuch_database_mode_t mode,
308 notmuch_database_t **database);
310 * Like notmuch_database_open, except optionally return an error
311 * message. This message is allocated by malloc and should be freed by
316 notmuch_database_open_verbose (const char *path,
317 notmuch_database_mode_t mode,
318 notmuch_database_t **database,
319 char **error_message);
322 * Retrieve last status string for given database.
326 notmuch_database_status_string (const notmuch_database_t *notmuch);
329 * Commit changes and close the given notmuch database.
331 * After notmuch_database_close has been called, calls to other
332 * functions on objects derived from this database may either behave
333 * as if the database had not been closed (e.g., if the required data
334 * has been cached) or may fail with a
335 * NOTMUCH_STATUS_XAPIAN_EXCEPTION.
337 * notmuch_database_close can be called multiple times. Later calls
340 * For writable databases, notmuch_database_close commits all changes
341 * to disk before closing the database. If the caller is currently in
342 * an atomic section (there was a notmuch_database_begin_atomic
343 * without a matching notmuch_database_end_atomic), this will discard
344 * changes made in that atomic section (but still commit changes made
345 * prior to entering the atomic section).
349 * NOTMUCH_STATUS_SUCCESS: Successfully closed the database.
351 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; the
352 * database has been closed but there are no guarantees the
353 * changes to the database, if any, have been flushed to disk.
356 notmuch_database_close (notmuch_database_t *database);
359 * A callback invoked by notmuch_database_compact to notify the user
360 * of the progress of the compaction process.
362 typedef void (*notmuch_compact_status_cb_t)(const char *message, void *closure);
365 * Compact a notmuch database, backing up the original database to the
368 * The database will be opened with NOTMUCH_DATABASE_MODE_READ_WRITE
369 * during the compaction process to ensure no writes are made.
371 * If the optional callback function 'status_cb' is non-NULL, it will
372 * be called with diagnostic and informational messages. The argument
373 * 'closure' is passed verbatim to any callback invoked.
376 notmuch_database_compact (const char* path,
377 const char* backup_path,
378 notmuch_compact_status_cb_t status_cb,
382 * Destroy the notmuch database, closing it if necessary and freeing
383 * all associated resources.
385 * Return value as in notmuch_database_close if the database was open;
386 * notmuch_database_destroy itself has no failure modes.
389 notmuch_database_destroy (notmuch_database_t *database);
392 * Return the database path of the given database.
394 * The return value is a string owned by notmuch so should not be
395 * modified nor freed by the caller.
398 notmuch_database_get_path (notmuch_database_t *database);
401 * Return the database format version of the given database.
404 notmuch_database_get_version (notmuch_database_t *database);
407 * Can the database be upgraded to a newer database version?
409 * If this function returns TRUE, then the caller may call
410 * notmuch_database_upgrade to upgrade the database. If the caller
411 * does not upgrade an out-of-date database, then some functions may
412 * fail with NOTMUCH_STATUS_UPGRADE_REQUIRED. This always returns
413 * FALSE for a read-only database because there's no way to upgrade a
414 * read-only database.
417 notmuch_database_needs_upgrade (notmuch_database_t *database);
420 * Upgrade the current database to the latest supported version.
422 * This ensures that all current notmuch functionality will be
423 * available on the database. After opening a database in read-write
424 * mode, it is recommended that clients check if an upgrade is needed
425 * (notmuch_database_needs_upgrade) and if so, upgrade with this
426 * function before making any modifications. If
427 * notmuch_database_needs_upgrade returns FALSE, this will be a no-op.
429 * The optional progress_notify callback can be used by the caller to
430 * provide progress indication to the user. If non-NULL it will be
431 * called periodically with 'progress' as a floating-point value in
432 * the range of [0.0 .. 1.0] indicating the progress made so far in
433 * the upgrade process. The argument 'closure' is passed verbatim to
434 * any callback invoked.
437 notmuch_database_upgrade (notmuch_database_t *database,
438 void (*progress_notify) (void *closure,
443 * Begin an atomic database operation.
445 * Any modifications performed between a successful begin and a
446 * notmuch_database_end_atomic will be applied to the database
447 * atomically. Note that, unlike a typical database transaction, this
448 * only ensures atomicity, not durability; neither begin nor end
449 * necessarily flush modifications to disk.
451 * Atomic sections may be nested. begin_atomic and end_atomic must
452 * always be called in pairs.
456 * NOTMUCH_STATUS_SUCCESS: Successfully entered atomic section.
458 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
459 * atomic section not entered.
462 notmuch_database_begin_atomic (notmuch_database_t *notmuch);
465 * Indicate the end of an atomic database operation.
469 * NOTMUCH_STATUS_SUCCESS: Successfully completed atomic section.
471 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
472 * atomic section not ended.
474 * NOTMUCH_STATUS_UNBALANCED_ATOMIC: The database is not currently in
478 notmuch_database_end_atomic (notmuch_database_t *notmuch);
481 * Return the committed database revision and UUID.
483 * The database revision number increases monotonically with each
484 * commit to the database. Hence, all messages and message changes
485 * committed to the database (that is, visible to readers) have a last
486 * modification revision <= the committed database revision. Any
487 * messages committed in the future will be assigned a modification
488 * revision > the committed database revision.
490 * The UUID is a NUL-terminated opaque string that uniquely identifies
491 * this database. Two revision numbers are only comparable if they
492 * have the same database UUID.
495 notmuch_database_get_revision (notmuch_database_t *notmuch,
499 * Retrieve a directory object from the database for 'path'.
501 * Here, 'path' should be a path relative to the path of 'database'
502 * (see notmuch_database_get_path), or else should be an absolute path
503 * with initial components that match the path of 'database'.
505 * If this directory object does not exist in the database, this
506 * returns NOTMUCH_STATUS_SUCCESS and sets *directory to NULL.
508 * Otherwise the returned directory object is owned by the database
509 * and as such, will only be valid until notmuch_database_destroy is
514 * NOTMUCH_STATUS_SUCCESS: Successfully retrieved directory.
516 * NOTMUCH_STATUS_NULL_POINTER: The given 'directory' argument is NULL.
518 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
519 * directory not retrieved.
521 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
522 * database to use this function.
525 notmuch_database_get_directory (notmuch_database_t *database,
527 notmuch_directory_t **directory);
530 * Add a new message to the given notmuch database or associate an
531 * additional filename with an existing message.
533 * Here, 'filename' should be a path relative to the path of
534 * 'database' (see notmuch_database_get_path), or else should be an
535 * absolute filename with initial components that match the path of
538 * The file should be a single mail message (not a multi-message mbox)
539 * that is expected to remain at its current location, (since the
540 * notmuch database will reference the filename, and will not copy the
541 * entire contents of the file.
543 * If another message with the same message ID already exists in the
544 * database, rather than creating a new message, this adds 'filename'
545 * to the list of the filenames for the existing message.
547 * If 'message' is not NULL, then, on successful return
548 * (NOTMUCH_STATUS_SUCCESS or NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) '*message'
549 * will be initialized to a message object that can be used for things
550 * such as adding tags to the just-added message. The user should call
551 * notmuch_message_destroy when done with the message. On any failure
552 * '*message' will be set to NULL.
556 * NOTMUCH_STATUS_SUCCESS: Message successfully added to database.
558 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
561 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: Message has the same message
562 * ID as another message already in the database. The new
563 * filename was successfully added to the message in the database
564 * (if not already present) and the existing message is returned.
566 * NOTMUCH_STATUS_FILE_ERROR: an error occurred trying to open the
567 * file, (such as permission denied, or file not found,
568 * etc.). Nothing added to the database.
570 * NOTMUCH_STATUS_FILE_NOT_EMAIL: the contents of filename don't look
571 * like an email message. Nothing added to the database.
573 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
574 * mode so no message can be added.
576 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
577 * database to use this function.
580 notmuch_database_add_message (notmuch_database_t *database,
581 const char *filename,
582 notmuch_message_t **message);
585 * Remove a message filename from the given notmuch database. If the
586 * message has no more filenames, remove the message.
588 * If the same message (as determined by the message ID) is still
589 * available via other filenames, then the message will persist in the
590 * database for those filenames. When the last filename is removed for
591 * a particular message, the database content for that message will be
596 * NOTMUCH_STATUS_SUCCESS: The last filename was removed and the
597 * message was removed from the database.
599 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
600 * message not removed.
602 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: This filename was removed but
603 * the message persists in the database with at least one other
606 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
607 * mode so no message can be removed.
609 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
610 * database to use this function.
613 notmuch_database_remove_message (notmuch_database_t *database,
614 const char *filename);
617 * Find a message with the given message_id.
619 * If a message with the given message_id is found then, on successful return
620 * (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to a message
621 * object. The caller should call notmuch_message_destroy when done with the
624 * On any failure or when the message is not found, this function initializes
625 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
626 * caller is supposed to check '*message' for NULL to find out whether the
627 * message with the given message_id was found.
631 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'.
633 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
635 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating message object
637 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
640 notmuch_database_find_message (notmuch_database_t *database,
641 const char *message_id,
642 notmuch_message_t **message);
645 * Find a message with the given filename.
647 * If the database contains a message with the given filename then, on
648 * successful return (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to
649 * a message object. The caller should call notmuch_message_destroy when done
652 * On any failure or when the message is not found, this function initializes
653 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
654 * caller is supposed to check '*message' for NULL to find out whether the
655 * message with the given filename is found.
659 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'
661 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
663 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating the message object
665 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
667 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
668 * database to use this function.
671 notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
672 const char *filename,
673 notmuch_message_t **message);
676 * Return a list of all tags found in the database.
678 * This function creates a list of all tags found in the database. The
679 * resulting list contains all tags from all messages found in the database.
681 * On error this function returns NULL.
684 notmuch_database_get_all_tags (notmuch_database_t *db);
687 * Create a new query for 'database'.
689 * Here, 'database' should be an open database, (see
690 * notmuch_database_open and notmuch_database_create).
692 * For the query string, we'll document the syntax here more
693 * completely in the future, but it's likely to be a specialized
694 * version of the general Xapian query syntax:
696 * http://xapian.org/docs/queryparser.html
698 * As a special case, passing either a length-zero string, (that is ""),
699 * or a string consisting of a single asterisk (that is "*"), will
700 * result in a query that returns all messages in the database.
702 * See notmuch_query_set_sort for controlling the order of results.
703 * See notmuch_query_search_messages and notmuch_query_search_threads
704 * to actually execute the query.
706 * User should call notmuch_query_destroy when finished with this
709 * Will return NULL if insufficient memory is available.
712 notmuch_query_create (notmuch_database_t *database,
713 const char *query_string);
716 * Sort values for notmuch_query_set_sort.
722 NOTMUCH_SORT_OLDEST_FIRST,
726 NOTMUCH_SORT_NEWEST_FIRST,
728 * Sort by message-id.
730 NOTMUCH_SORT_MESSAGE_ID,
734 NOTMUCH_SORT_UNSORTED
738 * Return the query_string of this query. See notmuch_query_create.
741 notmuch_query_get_query_string (const notmuch_query_t *query);
744 * Return the notmuch database of this query. See notmuch_query_create.
747 notmuch_query_get_database (const notmuch_query_t *query);
750 * Exclude values for notmuch_query_set_omit_excluded. The strange
751 * order is to maintain backward compatibility: the old FALSE/TRUE
752 * options correspond to the new
753 * NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options.
756 NOTMUCH_EXCLUDE_FLAG,
757 NOTMUCH_EXCLUDE_TRUE,
758 NOTMUCH_EXCLUDE_FALSE,
763 * Specify whether to omit excluded results or simply flag them. By
764 * default, this is set to TRUE.
766 * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded
767 * messages from the results, and notmuch_query_search_threads will omit
768 * threads that match only in excluded messages. If set to TRUE,
769 * notmuch_query_search_threads will include all messages in threads that
770 * match in at least one non-excluded message. Otherwise, if set to ALL,
771 * notmuch_query_search_threads will omit excluded messages from all threads.
773 * If set to FALSE or FLAG then both notmuch_query_search_messages and
774 * notmuch_query_search_threads will return all matching
775 * messages/threads regardless of exclude status. If set to FLAG then
776 * the exclude flag will be set for any excluded message that is
777 * returned by notmuch_query_search_messages, and the thread counts
778 * for threads returned by notmuch_query_search_threads will be the
779 * number of non-excluded messages/matches. Otherwise, if set to
780 * FALSE, then the exclude status is completely ignored.
782 * The performance difference when calling
783 * notmuch_query_search_messages should be relatively small (and both
784 * should be very fast). However, in some cases,
785 * notmuch_query_search_threads is very much faster when omitting
786 * excluded messages as it does not need to construct the threads that
787 * only match in excluded messages.
790 notmuch_query_set_omit_excluded (notmuch_query_t *query,
791 notmuch_exclude_t omit_excluded);
794 * Specify the sorting desired for this query.
797 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
800 * Return the sort specified for this query. See
801 * notmuch_query_set_sort.
804 notmuch_query_get_sort (const notmuch_query_t *query);
807 * Add a tag that will be excluded from the query results by default.
808 * This exclusion will be overridden if this tag appears explicitly in
812 notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
815 * Execute a query for threads, returning a notmuch_threads_t object
816 * which can be used to iterate over the results. The returned threads
817 * object is owned by the query and as such, will only be valid until
818 * notmuch_query_destroy.
820 * Typical usage might be:
822 * notmuch_query_t *query;
823 * notmuch_threads_t *threads;
824 * notmuch_thread_t *thread;
826 * query = notmuch_query_create (database, query_string);
828 * for (threads = notmuch_query_search_threads (query);
829 * notmuch_threads_valid (threads);
830 * notmuch_threads_move_to_next (threads))
832 * thread = notmuch_threads_get (threads);
834 * notmuch_thread_destroy (thread);
837 * notmuch_query_destroy (query);
839 * Note: If you are finished with a thread before its containing
840 * query, you can call notmuch_thread_destroy to clean up some memory
841 * sooner (as in the above example). Otherwise, if your thread objects
842 * are long-lived, then you don't need to call notmuch_thread_destroy
843 * and all the memory will still be reclaimed when the query is
846 * Note that there's no explicit destructor needed for the
847 * notmuch_threads_t object. (For consistency, we do provide a
848 * notmuch_threads_destroy function, but there's no good reason
849 * to call it if the query is about to be destroyed).
851 * @since libnotmuch 4.2 (notmuch 0.20)
854 notmuch_query_search_threads_st (notmuch_query_t *query,
855 notmuch_threads_t **out);
858 * Like notmuch_query_search_threads_st, but without a status return.
860 * If a Xapian exception occurs this function will return NULL.
862 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please
863 * use notmuch_query_search_threads_st instead.
866 NOTMUCH_DEPRECATED(4,3)
868 notmuch_query_search_threads (notmuch_query_t *query);
871 * Execute a query for messages, returning a notmuch_messages_t object
872 * which can be used to iterate over the results. The returned
873 * messages object is owned by the query and as such, will only be
874 * valid until notmuch_query_destroy.
876 * Typical usage might be:
878 * notmuch_query_t *query;
879 * notmuch_messages_t *messages;
880 * notmuch_message_t *message;
882 * query = notmuch_query_create (database, query_string);
884 * for (messages = notmuch_query_search_messages (query);
885 * notmuch_messages_valid (messages);
886 * notmuch_messages_move_to_next (messages))
888 * message = notmuch_messages_get (messages);
890 * notmuch_message_destroy (message);
893 * notmuch_query_destroy (query);
895 * Note: If you are finished with a message before its containing
896 * query, you can call notmuch_message_destroy to clean up some memory
897 * sooner (as in the above example). Otherwise, if your message
898 * objects are long-lived, then you don't need to call
899 * notmuch_message_destroy and all the memory will still be reclaimed
900 * when the query is destroyed.
902 * Note that there's no explicit destructor needed for the
903 * notmuch_messages_t object. (For consistency, we do provide a
904 * notmuch_messages_destroy function, but there's no good
905 * reason to call it if the query is about to be destroyed).
907 * If a Xapian exception occurs this function will return NULL.
909 * @since libnotmuch 4.2 (notmuch 0.20)
912 notmuch_query_search_messages_st (notmuch_query_t *query,
913 notmuch_messages_t **out);
915 * Like notmuch_query_search_messages, but without a status return.
917 * If a Xapian exception occurs this function will return NULL.
919 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please use
920 * notmuch_query_search_messages_st instead.
923 NOTMUCH_DEPRECATED(4,3)
925 notmuch_query_search_messages (notmuch_query_t *query);
928 * Destroy a notmuch_query_t along with any associated resources.
930 * This will in turn destroy any notmuch_threads_t and
931 * notmuch_messages_t objects generated by this query, (and in
932 * turn any notmuch_thread_t and notmuch_message_t objects generated
933 * from those results, etc.), if such objects haven't already been
937 notmuch_query_destroy (notmuch_query_t *query);
940 * Is the given 'threads' iterator pointing at a valid thread.
942 * When this function returns TRUE, notmuch_threads_get will return a
943 * valid object. Whereas when this function returns FALSE,
944 * notmuch_threads_get will return NULL.
946 * If passed a NULL pointer, this function returns FALSE
948 * See the documentation of notmuch_query_search_threads for example
949 * code showing how to iterate over a notmuch_threads_t object.
952 notmuch_threads_valid (notmuch_threads_t *threads);
955 * Get the current thread from 'threads' as a notmuch_thread_t.
957 * Note: The returned thread belongs to 'threads' and has a lifetime
958 * identical to it (and the query to which it belongs).
960 * See the documentation of notmuch_query_search_threads for example
961 * code showing how to iterate over a notmuch_threads_t object.
963 * If an out-of-memory situation occurs, this function will return
967 notmuch_threads_get (notmuch_threads_t *threads);
970 * Move the 'threads' iterator to the next thread.
972 * If 'threads' is already pointing at the last thread then the
973 * iterator will be moved to a point just beyond that last thread,
974 * (where notmuch_threads_valid will return FALSE and
975 * notmuch_threads_get will return NULL).
977 * See the documentation of notmuch_query_search_threads for example
978 * code showing how to iterate over a notmuch_threads_t object.
981 notmuch_threads_move_to_next (notmuch_threads_t *threads);
984 * Destroy a notmuch_threads_t object.
986 * It's not strictly necessary to call this function. All memory from
987 * the notmuch_threads_t object will be reclaimed when the
988 * containing query object is destroyed.
991 notmuch_threads_destroy (notmuch_threads_t *threads);
994 * Return the number of messages matching a search.
996 * This function performs a search and returns the number of matching
1001 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1003 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The
1004 * value of *count is not defined.
1006 * @since libnotmuch 4.3 (notmuch 0.21)
1009 notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
1012 * like notmuch_query_count_messages_st, but without a status return.
1014 * May return 0 in the case of errors.
1016 * @deprecated Deprecated since libnotmuch 4.3 (notmuch 0.21). Please
1017 * use notmuch_query_count_messages_st instead.
1019 NOTMUCH_DEPRECATED(4,3)
1021 notmuch_query_count_messages (notmuch_query_t *query);
1024 * Return the number of threads matching a search.
1026 * This function performs a search and returns the number of unique thread IDs
1027 * in the matching messages. This is the same as number of threads matching a
1030 * Note that this is a significantly heavier operation than
1031 * notmuch_query_count_messages{_st}().
1035 * NOTMUCH_STATUS_OUT_OF_MEMORY: Memory allocation failed. The value
1036 * of *count is not defined
1038 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1040 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The
1041 * value of *count is not defined.
1043 * @since libnotmuch 4.3 (notmuch 0.21)
1046 notmuch_query_count_threads_st (notmuch_query_t *query, unsigned *count);
1049 * like notmuch_query_count_threads, but without a status return.
1051 * May return 0 in case of errors.
1053 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please
1054 * use notmuch_query_count_threads_st instead.
1056 NOTMUCH_DEPRECATED(4,3)
1058 notmuch_query_count_threads (notmuch_query_t *query);
1061 * Get the thread ID of 'thread'.
1063 * The returned string belongs to 'thread' and as such, should not be
1064 * modified by the caller and will only be valid for as long as the
1065 * thread is valid, (which is until notmuch_thread_destroy or until
1066 * the query from which it derived is destroyed).
1069 notmuch_thread_get_thread_id (notmuch_thread_t *thread);
1072 * Get the total number of messages in 'thread'.
1074 * This count consists of all messages in the database belonging to
1075 * this thread. Contrast with notmuch_thread_get_matched_messages() .
1078 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
1081 * Get a notmuch_messages_t iterator for the top-level messages in
1082 * 'thread' in oldest-first order.
1084 * This iterator will not necessarily iterate over all of the messages
1085 * in the thread. It will only iterate over the messages in the thread
1086 * which are not replies to other messages in the thread.
1088 * The returned list will be destroyed when the thread is destroyed.
1090 notmuch_messages_t *
1091 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
1094 * Get a notmuch_thread_t iterator for all messages in 'thread' in
1095 * oldest-first order.
1097 * The returned list will be destroyed when the thread is destroyed.
1099 notmuch_messages_t *
1100 notmuch_thread_get_messages (notmuch_thread_t *thread);
1103 * Get the number of messages in 'thread' that matched the search.
1105 * This count includes only the messages in this thread that were
1106 * matched by the search from which the thread was created and were
1107 * not excluded by any exclude tags passed in with the query (see
1108 * notmuch_query_add_tag_exclude). Contrast with
1109 * notmuch_thread_get_total_messages() .
1112 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
1115 * Get the authors of 'thread' as a UTF-8 string.
1117 * The returned string is a comma-separated list of the names of the
1118 * authors of mail messages in the query results that belong to this
1121 * The string contains authors of messages matching the query first, then
1122 * non-matched authors (with the two groups separated by '|'). Within
1123 * each group, authors are ordered by date.
1125 * The returned string belongs to 'thread' and as such, should not be
1126 * modified by the caller and will only be valid for as long as the
1127 * thread is valid, (which is until notmuch_thread_destroy or until
1128 * the query from which it derived is destroyed).
1131 notmuch_thread_get_authors (notmuch_thread_t *thread);
1134 * Get the subject of 'thread' as a UTF-8 string.
1136 * The subject is taken from the first message (according to the query
1137 * order---see notmuch_query_set_sort) in the query results that
1138 * belongs to this thread.
1140 * The returned string belongs to 'thread' and as such, should not be
1141 * modified by the caller and will only be valid for as long as the
1142 * thread is valid, (which is until notmuch_thread_destroy or until
1143 * the query from which it derived is destroyed).
1146 notmuch_thread_get_subject (notmuch_thread_t *thread);
1149 * Get the date of the oldest message in 'thread' as a time_t value.
1152 notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
1155 * Get the date of the newest message in 'thread' as a time_t value.
1158 notmuch_thread_get_newest_date (notmuch_thread_t *thread);
1161 * Get the tags for 'thread', returning a notmuch_tags_t object which
1162 * can be used to iterate over all tags.
1164 * Note: In the Notmuch database, tags are stored on individual
1165 * messages, not on threads. So the tags returned here will be all
1166 * tags of the messages which matched the search and which belong to
1169 * The tags object is owned by the thread and as such, will only be
1170 * valid for as long as the thread is valid, (for example, until
1171 * notmuch_thread_destroy or until the query from which it derived is
1174 * Typical usage might be:
1176 * notmuch_thread_t *thread;
1177 * notmuch_tags_t *tags;
1180 * thread = notmuch_threads_get (threads);
1182 * for (tags = notmuch_thread_get_tags (thread);
1183 * notmuch_tags_valid (tags);
1184 * notmuch_tags_move_to_next (tags))
1186 * tag = notmuch_tags_get (tags);
1190 * notmuch_thread_destroy (thread);
1192 * Note that there's no explicit destructor needed for the
1193 * notmuch_tags_t object. (For consistency, we do provide a
1194 * notmuch_tags_destroy function, but there's no good reason to call
1195 * it if the message is about to be destroyed).
1198 notmuch_thread_get_tags (notmuch_thread_t *thread);
1201 * Destroy a notmuch_thread_t object.
1204 notmuch_thread_destroy (notmuch_thread_t *thread);
1207 * Is the given 'messages' iterator pointing at a valid message.
1209 * When this function returns TRUE, notmuch_messages_get will return a
1210 * valid object. Whereas when this function returns FALSE,
1211 * notmuch_messages_get will return NULL.
1213 * See the documentation of notmuch_query_search_messages for example
1214 * code showing how to iterate over a notmuch_messages_t object.
1217 notmuch_messages_valid (notmuch_messages_t *messages);
1220 * Get the current message from 'messages' as a notmuch_message_t.
1222 * Note: The returned message belongs to 'messages' and has a lifetime
1223 * identical to it (and the query to which it belongs).
1225 * See the documentation of notmuch_query_search_messages for example
1226 * code showing how to iterate over a notmuch_messages_t object.
1228 * If an out-of-memory situation occurs, this function will return
1232 notmuch_messages_get (notmuch_messages_t *messages);
1235 * Move the 'messages' iterator to the next message.
1237 * If 'messages' is already pointing at the last message then the
1238 * iterator will be moved to a point just beyond that last message,
1239 * (where notmuch_messages_valid will return FALSE and
1240 * notmuch_messages_get will return NULL).
1242 * See the documentation of notmuch_query_search_messages for example
1243 * code showing how to iterate over a notmuch_messages_t object.
1246 notmuch_messages_move_to_next (notmuch_messages_t *messages);
1249 * Destroy a notmuch_messages_t object.
1251 * It's not strictly necessary to call this function. All memory from
1252 * the notmuch_messages_t object will be reclaimed when the containing
1253 * query object is destroyed.
1256 notmuch_messages_destroy (notmuch_messages_t *messages);
1259 * Return a list of tags from all messages.
1261 * The resulting list is guaranteed not to contain duplicated tags.
1263 * WARNING: You can no longer iterate over messages after calling this
1264 * function, because the iterator will point at the end of the list.
1265 * We do not have a function to reset the iterator yet and the only
1266 * way how you can iterate over the list again is to recreate the
1269 * The function returns NULL on error.
1272 notmuch_messages_collect_tags (notmuch_messages_t *messages);
1275 * Get the message ID of 'message'.
1277 * The returned string belongs to 'message' and as such, should not be
1278 * modified by the caller and will only be valid for as long as the
1279 * message is valid, (which is until the query from which it derived
1282 * This function will not return NULL since Notmuch ensures that every
1283 * message has a unique message ID, (Notmuch will generate an ID for a
1284 * message if the original file does not contain one).
1287 notmuch_message_get_message_id (notmuch_message_t *message);
1290 * Get the thread ID of 'message'.
1292 * The returned string belongs to 'message' and as such, should not be
1293 * modified by the caller and will only be valid for as long as the
1294 * message is valid, (for example, until the user calls
1295 * notmuch_message_destroy on 'message' or until a query from which it
1296 * derived is destroyed).
1298 * This function will not return NULL since Notmuch ensures that every
1299 * message belongs to a single thread.
1302 notmuch_message_get_thread_id (notmuch_message_t *message);
1305 * Get a notmuch_messages_t iterator for all of the replies to
1308 * Note: This call only makes sense if 'message' was ultimately
1309 * obtained from a notmuch_thread_t object, (such as by coming
1310 * directly from the result of calling notmuch_thread_get_
1311 * toplevel_messages or by any number of subsequent
1312 * calls to notmuch_message_get_replies).
1314 * If 'message' was obtained through some non-thread means, (such as
1315 * by a call to notmuch_query_search_messages), then this function
1318 * If there are no replies to 'message', this function will return
1319 * NULL. (Note that notmuch_messages_valid will accept that NULL
1320 * value as legitimate, and simply return FALSE for it.)
1322 notmuch_messages_t *
1323 notmuch_message_get_replies (notmuch_message_t *message);
1326 * Get a filename for the email corresponding to 'message'.
1328 * The returned filename is an absolute filename, (the initial
1329 * component will match notmuch_database_get_path() ).
1331 * The returned string belongs to the message so should not be
1332 * modified or freed by the caller (nor should it be referenced after
1333 * the message is destroyed).
1335 * Note: If this message corresponds to multiple files in the mail
1336 * store, (that is, multiple files contain identical message IDs),
1337 * this function will arbitrarily return a single one of those
1338 * filenames. See notmuch_message_get_filenames for returning the
1339 * complete list of filenames.
1342 notmuch_message_get_filename (notmuch_message_t *message);
1345 * Get all filenames for the email corresponding to 'message'.
1347 * Returns a notmuch_filenames_t iterator listing all the filenames
1348 * associated with 'message'. These files may not have identical
1349 * content, but each will have the identical Message-ID.
1351 * Each filename in the iterator is an absolute filename, (the initial
1352 * component will match notmuch_database_get_path() ).
1354 notmuch_filenames_t *
1355 notmuch_message_get_filenames (notmuch_message_t *message);
1360 typedef enum _notmuch_message_flag {
1361 NOTMUCH_MESSAGE_FLAG_MATCH,
1362 NOTMUCH_MESSAGE_FLAG_EXCLUDED,
1364 /* This message is a "ghost message", meaning it has no filenames
1365 * or content, but we know it exists because it was referenced by
1366 * some other message. A ghost message has only a message ID and
1369 NOTMUCH_MESSAGE_FLAG_GHOST,
1370 } notmuch_message_flag_t;
1373 * Get a value of a flag for the email corresponding to 'message'.
1376 notmuch_message_get_flag (notmuch_message_t *message,
1377 notmuch_message_flag_t flag);
1380 * Set a value of a flag for the email corresponding to 'message'.
1383 notmuch_message_set_flag (notmuch_message_t *message,
1384 notmuch_message_flag_t flag, notmuch_bool_t value);
1387 * Get the date of 'message' as a time_t value.
1389 * For the original textual representation of the Date header from the
1390 * message call notmuch_message_get_header() with a header value of
1394 notmuch_message_get_date (notmuch_message_t *message);
1397 * Get the value of the specified header from 'message' as a UTF-8 string.
1399 * Common headers are stored in the database when the message is
1400 * indexed and will be returned from the database. Other headers will
1401 * be read from the actual message file.
1403 * The header name is case insensitive.
1405 * The returned string belongs to the message so should not be
1406 * modified or freed by the caller (nor should it be referenced after
1407 * the message is destroyed).
1409 * Returns an empty string ("") if the message does not contain a
1410 * header line matching 'header'. Returns NULL if any error occurs.
1413 notmuch_message_get_header (notmuch_message_t *message, const char *header);
1416 * Get the tags for 'message', returning a notmuch_tags_t object which
1417 * can be used to iterate over all tags.
1419 * The tags object is owned by the message and as such, will only be
1420 * valid for as long as the message is valid, (which is until the
1421 * query from which it derived is destroyed).
1423 * Typical usage might be:
1425 * notmuch_message_t *message;
1426 * notmuch_tags_t *tags;
1429 * message = notmuch_database_find_message (database, message_id);
1431 * for (tags = notmuch_message_get_tags (message);
1432 * notmuch_tags_valid (tags);
1433 * notmuch_tags_move_to_next (tags))
1435 * tag = notmuch_tags_get (tags);
1439 * notmuch_message_destroy (message);
1441 * Note that there's no explicit destructor needed for the
1442 * notmuch_tags_t object. (For consistency, we do provide a
1443 * notmuch_tags_destroy function, but there's no good reason to call
1444 * it if the message is about to be destroyed).
1447 notmuch_message_get_tags (notmuch_message_t *message);
1450 * The longest possible tag value.
1452 #define NOTMUCH_TAG_MAX 200
1455 * Add a tag to the given message.
1459 * NOTMUCH_STATUS_SUCCESS: Tag successfully added to message
1461 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1463 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1464 * (exceeds NOTMUCH_TAG_MAX)
1466 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1467 * mode so message cannot be modified.
1470 notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
1473 * Remove a tag from the given message.
1477 * NOTMUCH_STATUS_SUCCESS: Tag successfully removed from message
1479 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1481 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1482 * (exceeds NOTMUCH_TAG_MAX)
1484 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1485 * mode so message cannot be modified.
1488 notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
1491 * Remove all tags from the given message.
1493 * See notmuch_message_freeze for an example showing how to safely
1494 * replace tag values.
1496 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1497 * mode so message cannot be modified.
1500 notmuch_message_remove_all_tags (notmuch_message_t *message);
1503 * Add/remove tags according to maildir flags in the message filename(s).
1505 * This function examines the filenames of 'message' for maildir
1506 * flags, and adds or removes tags on 'message' as follows when these
1507 * flags are present:
1509 * Flag Action if present
1510 * ---- -----------------
1511 * 'D' Adds the "draft" tag to the message
1512 * 'F' Adds the "flagged" tag to the message
1513 * 'P' Adds the "passed" tag to the message
1514 * 'R' Adds the "replied" tag to the message
1515 * 'S' Removes the "unread" tag from the message
1517 * For each flag that is not present, the opposite action (add/remove)
1518 * is performed for the corresponding tags.
1520 * Flags are identified as trailing components of the filename after a
1521 * sequence of ":2,".
1523 * If there are multiple filenames associated with this message, the
1524 * flag is considered present if it appears in one or more
1525 * filenames. (That is, the flags from the multiple filenames are
1526 * combined with the logical OR operator.)
1528 * A client can ensure that notmuch database tags remain synchronized
1529 * with maildir flags by calling this function after each call to
1530 * notmuch_database_add_message. See also
1531 * notmuch_message_tags_to_maildir_flags for synchronizing tag changes
1532 * back to maildir flags.
1535 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
1538 * Rename message filename(s) to encode tags as maildir flags.
1540 * Specifically, for each filename corresponding to this message:
1542 * If the filename is not in a maildir directory, do nothing. (A
1543 * maildir directory is determined as a directory named "new" or
1544 * "cur".) Similarly, if the filename has invalid maildir info,
1545 * (repeated or outof-ASCII-order flag characters after ":2,"), then
1548 * If the filename is in a maildir directory, rename the file so that
1549 * its filename ends with the sequence ":2," followed by zero or more
1550 * of the following single-character flags (in ASCII order):
1552 * 'D' iff the message has the "draft" tag
1553 * 'F' iff the message has the "flagged" tag
1554 * 'P' iff the message has the "passed" tag
1555 * 'R' iff the message has the "replied" tag
1556 * 'S' iff the message does not have the "unread" tag
1558 * Any existing flags unmentioned in the list above will be preserved
1561 * Also, if this filename is in a directory named "new", rename it to
1562 * be within the neighboring directory named "cur".
1564 * A client can ensure that maildir filename flags remain synchronized
1565 * with notmuch database tags by calling this function after changing
1566 * tags, (after calls to notmuch_message_add_tag,
1567 * notmuch_message_remove_tag, or notmuch_message_freeze/
1568 * notmuch_message_thaw). See also notmuch_message_maildir_flags_to_tags
1569 * for synchronizing maildir flag changes back to tags.
1572 notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
1575 * Freeze the current state of 'message' within the database.
1577 * This means that changes to the message state, (via
1578 * notmuch_message_add_tag, notmuch_message_remove_tag, and
1579 * notmuch_message_remove_all_tags), will not be committed to the
1580 * database until the message is thawed with notmuch_message_thaw.
1582 * Multiple calls to freeze/thaw are valid and these calls will
1583 * "stack". That is there must be as many calls to thaw as to freeze
1584 * before a message is actually thawed.
1586 * The ability to do freeze/thaw allows for safe transactions to
1587 * change tag values. For example, explicitly setting a message to
1588 * have a given set of tags might look like this:
1590 * notmuch_message_freeze (message);
1592 * notmuch_message_remove_all_tags (message);
1594 * for (i = 0; i < NUM_TAGS; i++)
1595 * notmuch_message_add_tag (message, tags[i]);
1597 * notmuch_message_thaw (message);
1599 * With freeze/thaw used like this, the message in the database is
1600 * guaranteed to have either the full set of original tag values, or
1601 * the full set of new tag values, but nothing in between.
1603 * Imagine the example above without freeze/thaw and the operation
1604 * somehow getting interrupted. This could result in the message being
1605 * left with no tags if the interruption happened after
1606 * notmuch_message_remove_all_tags but before notmuch_message_add_tag.
1610 * NOTMUCH_STATUS_SUCCESS: Message successfully frozen.
1612 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1613 * mode so message cannot be modified.
1616 notmuch_message_freeze (notmuch_message_t *message);
1619 * Thaw the current 'message', synchronizing any changes that may have
1620 * occurred while 'message' was frozen into the notmuch database.
1622 * See notmuch_message_freeze for an example of how to use this
1623 * function to safely provide tag changes.
1625 * Multiple calls to freeze/thaw are valid and these calls with
1626 * "stack". That is there must be as many calls to thaw as to freeze
1627 * before a message is actually thawed.
1631 * NOTMUCH_STATUS_SUCCESS: Message successfully thawed, (or at least
1632 * its frozen count has successfully been reduced by 1).
1634 * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: An attempt was made to thaw
1635 * an unfrozen message. That is, there have been an unbalanced
1636 * number of calls to notmuch_message_freeze and
1637 * notmuch_message_thaw.
1640 notmuch_message_thaw (notmuch_message_t *message);
1643 * Destroy a notmuch_message_t object.
1645 * It can be useful to call this function in the case of a single
1646 * query object with many messages in the result, (such as iterating
1647 * over the entire database). Otherwise, it's fine to never call this
1648 * function and there will still be no memory leaks. (The memory from
1649 * the messages get reclaimed when the containing query is destroyed.)
1652 notmuch_message_destroy (notmuch_message_t *message);
1655 * Is the given 'tags' iterator pointing at a valid tag.
1657 * When this function returns TRUE, notmuch_tags_get will return a
1658 * valid string. Whereas when this function returns FALSE,
1659 * notmuch_tags_get will return NULL.
1661 * See the documentation of notmuch_message_get_tags for example code
1662 * showing how to iterate over a notmuch_tags_t object.
1665 notmuch_tags_valid (notmuch_tags_t *tags);
1668 * Get the current tag from 'tags' as a string.
1670 * Note: The returned string belongs to 'tags' and has a lifetime
1671 * identical to it (and the query to which it ultimately belongs).
1673 * See the documentation of notmuch_message_get_tags for example code
1674 * showing how to iterate over a notmuch_tags_t object.
1677 notmuch_tags_get (notmuch_tags_t *tags);
1680 * Move the 'tags' iterator to the next tag.
1682 * If 'tags' is already pointing at the last tag then the iterator
1683 * will be moved to a point just beyond that last tag, (where
1684 * notmuch_tags_valid will return FALSE and notmuch_tags_get will
1687 * See the documentation of notmuch_message_get_tags for example code
1688 * showing how to iterate over a notmuch_tags_t object.
1691 notmuch_tags_move_to_next (notmuch_tags_t *tags);
1694 * Destroy a notmuch_tags_t object.
1696 * It's not strictly necessary to call this function. All memory from
1697 * the notmuch_tags_t object will be reclaimed when the containing
1698 * message or query objects are destroyed.
1701 notmuch_tags_destroy (notmuch_tags_t *tags);
1704 * Store an mtime within the database for 'directory'.
1706 * The 'directory' should be an object retrieved from the database
1707 * with notmuch_database_get_directory for a particular path.
1709 * The intention is for the caller to use the mtime to allow efficient
1710 * identification of new messages to be added to the database. The
1711 * recommended usage is as follows:
1713 * o Read the mtime of a directory from the filesystem
1715 * o Call add_message for all mail files in the directory
1717 * o Call notmuch_directory_set_mtime with the mtime read from the
1720 * Then, when wanting to check for updates to the directory in the
1721 * future, the client can call notmuch_directory_get_mtime and know
1722 * that it only needs to add files if the mtime of the directory and
1723 * files are newer than the stored timestamp.
1725 * Note: The notmuch_directory_get_mtime function does not allow the
1726 * caller to distinguish a timestamp of 0 from a non-existent
1727 * timestamp. So don't store a timestamp of 0 unless you are
1728 * comfortable with that.
1732 * NOTMUCH_STATUS_SUCCESS: mtime successfully stored in database.
1734 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception
1735 * occurred, mtime not stored.
1737 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1738 * mode so directory mtime cannot be modified.
1741 notmuch_directory_set_mtime (notmuch_directory_t *directory,
1745 * Get the mtime of a directory, (as previously stored with
1746 * notmuch_directory_set_mtime).
1748 * Returns 0 if no mtime has previously been stored for this
1752 notmuch_directory_get_mtime (notmuch_directory_t *directory);
1755 * Get a notmuch_filenames_t iterator listing all the filenames of
1756 * messages in the database within the given directory.
1758 * The returned filenames will be the basename-entries only (not
1761 notmuch_filenames_t *
1762 notmuch_directory_get_child_files (notmuch_directory_t *directory);
1765 * Get a notmuch_filenames_t iterator listing all the filenames of
1766 * sub-directories in the database within the given directory.
1768 * The returned filenames will be the basename-entries only (not
1771 notmuch_filenames_t *
1772 notmuch_directory_get_child_directories (notmuch_directory_t *directory);
1775 * Delete directory document from the database, and destroy the
1776 * notmuch_directory_t object. Assumes any child directories and files
1777 * have been deleted by the caller.
1779 * @since libnotmuch 4.3 (notmuch 0.21)
1782 notmuch_directory_delete (notmuch_directory_t *directory);
1785 * Destroy a notmuch_directory_t object.
1788 notmuch_directory_destroy (notmuch_directory_t *directory);
1791 * Is the given 'filenames' iterator pointing at a valid filename.
1793 * When this function returns TRUE, notmuch_filenames_get will return
1794 * a valid string. Whereas when this function returns FALSE,
1795 * notmuch_filenames_get will return NULL.
1797 * It is acceptable to pass NULL for 'filenames', in which case this
1798 * function will always return FALSE.
1801 notmuch_filenames_valid (notmuch_filenames_t *filenames);
1804 * Get the current filename from 'filenames' as a string.
1806 * Note: The returned string belongs to 'filenames' and has a lifetime
1807 * identical to it (and the directory to which it ultimately belongs).
1809 * It is acceptable to pass NULL for 'filenames', in which case this
1810 * function will always return NULL.
1813 notmuch_filenames_get (notmuch_filenames_t *filenames);
1816 * Move the 'filenames' iterator to the next filename.
1818 * If 'filenames' is already pointing at the last filename then the
1819 * iterator will be moved to a point just beyond that last filename,
1820 * (where notmuch_filenames_valid will return FALSE and
1821 * notmuch_filenames_get will return NULL).
1823 * It is acceptable to pass NULL for 'filenames', in which case this
1824 * function will do nothing.
1827 notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
1830 * Destroy a notmuch_filenames_t object.
1832 * It's not strictly necessary to call this function. All memory from
1833 * the notmuch_filenames_t object will be reclaimed when the
1834 * containing directory object is destroyed.
1836 * It is acceptable to pass NULL for 'filenames', in which case this
1837 * function will do nothing.
1840 notmuch_filenames_destroy (notmuch_filenames_t *filenames);
1844 * set config 'key' to 'value'
1848 notmuch_database_set_config (notmuch_database_t *db, const char *key, const char *value);
1851 * retrieve config item 'key', assign to 'value'
1853 * keys which have not been previously set with n_d_set_config will
1854 * return an empty string.
1856 * return value is allocated by malloc and should be freed by the
1860 notmuch_database_get_config (notmuch_database_t *db, const char *key, char **value);
1863 * Create an iterator for all config items with keys matching a given prefix
1866 notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out);
1869 * Is 'config_list' iterator valid (i.e. _key, _value, _move_to_next can be called).
1872 notmuch_config_list_valid (notmuch_config_list_t *config_list);
1875 * return key for current config pair
1877 * return value is owned by the iterator, and will be destroyed by the
1878 * next call to notmuch_config_list_key or notmuch_config_list_destroy.
1881 notmuch_config_list_key (notmuch_config_list_t *config_list);
1884 * return 'value' for current config pair
1886 * return value is owned by the iterator, and will be destroyed by the
1887 * next call to notmuch_config_list_value or notmuch config_list_destroy
1890 notmuch_config_list_value (notmuch_config_list_t *config_list);
1894 * move 'config_list' iterator to the next pair
1897 notmuch_config_list_move_to_next (notmuch_config_list_t *config_list);
1900 * free any resources held by 'config_list'
1903 notmuch_config_list_destroy (notmuch_config_list_t *config_list);
1906 * interrogate the library for compile time features
1909 notmuch_built_with (const char *name);