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 https://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
46 #pragma GCC visibility push(default)
57 * The library version number. This must agree with the soname
58 * version in Makefile.local.
60 #define LIBNOTMUCH_MAJOR_VERSION 5
61 #define LIBNOTMUCH_MINOR_VERSION 3
62 #define LIBNOTMUCH_MICRO_VERSION 0
65 #if defined (__clang_major__) && __clang_major__ >= 3 \
66 || defined (__GNUC__) && __GNUC__ >= 5 \
67 || defined (__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5
68 #define NOTMUCH_DEPRECATED(major, minor) \
69 __attribute__ ((deprecated ("function deprecated as of libnotmuch " #major "." #minor)))
71 #define NOTMUCH_DEPRECATED(major, minor) __attribute__ ((deprecated))
75 #endif /* __DOXYGEN__ */
78 * Check the version of the notmuch library being compiled against.
80 * Return true if the library being compiled against is of the
81 * specified version or above. For example:
84 * #if LIBNOTMUCH_CHECK_VERSION(3, 1, 0)
85 * (code requiring libnotmuch 3.1.0 or above)
89 * LIBNOTMUCH_CHECK_VERSION has been defined since version 3.1.0; to
90 * check for versions prior to that, use:
93 * #if !defined(NOTMUCH_CHECK_VERSION)
94 * (code requiring libnotmuch prior to 3.1.0)
98 #define LIBNOTMUCH_CHECK_VERSION(major, minor, micro) \
99 (LIBNOTMUCH_MAJOR_VERSION > (major) || \
100 (LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION > (minor)) || \
101 (LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION == (minor) && \
102 LIBNOTMUCH_MICRO_VERSION >= (micro)))
105 * Notmuch boolean type.
107 typedef int notmuch_bool_t;
110 * Status codes used for the return values of most functions.
112 * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
113 * completed without error. Any other value indicates an error.
115 typedef enum _notmuch_status {
119 NOTMUCH_STATUS_SUCCESS = 0,
123 NOTMUCH_STATUS_OUT_OF_MEMORY,
125 * An attempt was made to write to a database opened in read-only
128 NOTMUCH_STATUS_READ_ONLY_DATABASE,
130 * A Xapian exception occurred.
132 * @todo We don't really want to expose this lame XAPIAN_EXCEPTION
133 * value. Instead we should map to things like DATABASE_LOCKED or
136 NOTMUCH_STATUS_XAPIAN_EXCEPTION,
138 * An error occurred trying to read or write to a file (this could
139 * be file not found, permission denied, etc.)
141 NOTMUCH_STATUS_FILE_ERROR,
143 * A file was presented that doesn't appear to be an email
146 NOTMUCH_STATUS_FILE_NOT_EMAIL,
148 * A file contains a message ID that is identical to a message
149 * already in the database.
151 NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
153 * The user erroneously passed a NULL pointer to a notmuch
156 NOTMUCH_STATUS_NULL_POINTER,
158 * A tag value is too long (exceeds NOTMUCH_TAG_MAX).
160 NOTMUCH_STATUS_TAG_TOO_LONG,
162 * The notmuch_message_thaw function has been called more times
163 * than notmuch_message_freeze.
165 NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
167 * notmuch_database_end_atomic has been called more times than
168 * notmuch_database_begin_atomic.
170 NOTMUCH_STATUS_UNBALANCED_ATOMIC,
172 * The operation is not supported.
174 NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
176 * The operation requires a database upgrade.
178 NOTMUCH_STATUS_UPGRADE_REQUIRED,
180 * There is a problem with the proposed path, e.g. a relative path
181 * passed to a function expecting an absolute path.
183 NOTMUCH_STATUS_PATH_ERROR,
185 * The requested operation was ignored. Depending on the function,
186 * this may not be an actual error.
188 NOTMUCH_STATUS_IGNORED,
190 * One of the arguments violates the preconditions for the
191 * function, in a way not covered by a more specific argument.
193 NOTMUCH_STATUS_ILLEGAL_ARGUMENT,
195 * A MIME object claimed to have cryptographic protection which
196 * notmuch tried to handle, but the protocol was not specified in
197 * an intelligible way.
199 NOTMUCH_STATUS_MALFORMED_CRYPTO_PROTOCOL,
201 * Notmuch attempted to do crypto processing, but could not
202 * initialize the engine needed to do so.
204 NOTMUCH_STATUS_FAILED_CRYPTO_CONTEXT_CREATION,
206 * A MIME object claimed to have cryptographic protection, and
207 * notmuch attempted to process it, but the specific protocol was
208 * something that notmuch doesn't know how to handle.
210 NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL,
212 * Not an actual status value. Just a way to find out how many
213 * valid status values there are.
215 NOTMUCH_STATUS_LAST_STATUS
219 * Get a string representation of a notmuch_status_t value.
221 * The result is read-only.
224 notmuch_status_to_string (notmuch_status_t status);
226 /* Various opaque data types. For each notmuch_<foo>_t see the various
227 * notmuch_<foo> functions below. */
229 typedef struct _notmuch_database notmuch_database_t;
230 typedef struct _notmuch_query notmuch_query_t;
231 typedef struct _notmuch_threads notmuch_threads_t;
232 typedef struct _notmuch_thread notmuch_thread_t;
233 typedef struct _notmuch_messages notmuch_messages_t;
234 typedef struct _notmuch_message notmuch_message_t;
235 typedef struct _notmuch_tags notmuch_tags_t;
236 typedef struct _notmuch_directory notmuch_directory_t;
237 typedef struct _notmuch_filenames notmuch_filenames_t;
238 typedef struct _notmuch_config_list notmuch_config_list_t;
239 typedef struct _notmuch_config_values notmuch_config_values_t;
240 typedef struct _notmuch_indexopts notmuch_indexopts_t;
241 #endif /* __DOXYGEN__ */
244 * Create a new, empty notmuch database located at 'path'.
246 * The path should be a top-level directory to a collection of
247 * plain-text email messages (one message per file). This call will
248 * create a new ".notmuch" directory within 'path' where notmuch will
251 * After a successful call to notmuch_database_create, the returned
252 * database will be open so the caller should call
253 * notmuch_database_destroy when finished with it.
255 * The database will not yet have any data in it
256 * (notmuch_database_create itself is a very cheap function). Messages
257 * contained within 'path' can be added to the database by calling
258 * notmuch_database_index_file.
260 * In case of any failure, this function returns an error status and
261 * sets *database to NULL (after printing an error message on stderr).
265 * NOTMUCH_STATUS_SUCCESS: Successfully created the database.
267 * NOTMUCH_STATUS_NULL_POINTER: The given 'path' argument is NULL.
269 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
271 * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to create the
272 * database file (such as permission denied, or file not found,
273 * etc.), or the database already exists.
275 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred.
278 notmuch_database_create (const char *path, notmuch_database_t **database);
281 * Like notmuch_database_create, except optionally return an error
282 * message. This message is allocated by malloc and should be freed by
286 notmuch_database_create_verbose (const char *path,
287 notmuch_database_t **database,
288 char **error_message);
291 * Database open mode for notmuch_database_open.
295 * Open database for reading only.
297 NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
299 * Open database for reading and writing.
301 NOTMUCH_DATABASE_MODE_READ_WRITE
302 } notmuch_database_mode_t;
305 * Deprecated alias for notmuch_database_open_with_config with
306 * config_path=error_message=NULL
307 * @deprecated Deprecated as of libnotmuch 5.4 (notmuch 0.32)
309 /* NOTMUCH_DEPRECATED(5, 4) */
311 notmuch_database_open (const char *path,
312 notmuch_database_mode_t mode,
313 notmuch_database_t **database);
315 * Deprecated alias for notmuch_database_open_with_config with
318 * @deprecated Deprecated as of libnotmuch 5.4 (notmuch 0.32)
321 /* NOTMUCH_DEPRECATED(5, 4) */
323 notmuch_database_open_verbose (const char *path,
324 notmuch_database_mode_t mode,
325 notmuch_database_t **database,
326 char **error_message);
329 * Open an existing notmuch database located at 'database_path', using
330 * configuration in 'config_path'.
332 * @param[in] database_path
334 * Path to existing database.
336 * A notmuch database is a Xapian database containing appropriate
339 * The database should have been created at some time in the past,
340 * (not necessarily by this process), by calling
341 * notmuch_database_create.
343 * If 'database_path' is NULL, use the location specified
345 * - in the environment variable NOTMUCH_DATABASE, if non-empty
347 * - in a configuration file, located as described under 'config_path'
349 * - by $XDG_DATA_HOME/notmuch/$PROFILE where XDG_DATA_HOME defaults
350 * to "$HOME/.local/share" and PROFILE as as discussed in
353 * If 'database_path' is non-NULL, but does not appear to be a Xapian
354 * database, check for a directory '.notmuch/xapian' below
355 * 'database_path' (this is the behavior of
356 * notmuch_database_open_verbose pre-0.32).
361 * Mode to open database. Use one of #NOTMUCH_DATABASE_MODE_READ_WRITE
362 * or #NOTMUCH_DATABASE_MODE_READ_ONLY
365 * @param[in] config_path
367 * Path to config file.
369 * Config file is key-value, with mandatory sections. See
370 * <em>notmuch-config(5)</em> for more information. The key-value pair
371 * overrides the corresponding configuration data stored in the
372 * database (see <em>notmuch_database_get_config</em>)
374 * If <em>config_path</em> is NULL use the path specified
376 * - in environment variable <em>NOTMUCH_CONFIG</em>, if non-empty
378 * - by <em>XDG_CONFIG_HOME</em>/notmuch/ where
379 * XDG_CONFIG_HOME defaults to "$HOME/.config".
381 * - by $HOME/.notmuch-config
383 * If <em>config_path</em> is "" (empty string) then do not
384 * open any configuration file.
386 * @param[in] profile:
388 * Name of profile (configuration/database variant).
390 * If non-NULL, append to the directory / file path determined for
391 * <em>config_path</em> and <em>database_path</em>.
394 * - environment variable NOTMUCH_PROFILE if defined,
395 * - otherwise "default" for directories and "" (empty string) for paths.
398 * @param[out] database
400 * Pointer to database object. May not be NULL.
402 * The caller should call notmuch_database_destroy when finished with
405 * In case of any failure, this function returns an error status and
406 * sets *database to NULL.
409 * @param[out] error_message
410 * If non-NULL, store error message from opening the database.
411 * Any such message is allocated by \a malloc(3) and should be freed
414 * @retval NOTMUCH_STATUS_SUCCESS: Successfully opened the database.
416 * @retval NOTMUCH_STATUS_NULL_POINTER: The given \a database
419 * @retval NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
421 * @retval NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to open the
422 * database or config file (such as permission denied, or file not found,
423 * etc.), or the database version is unknown.
425 * @retval NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred.
427 * @since libnotmuch 5.4 (notmuch 0.32)
431 notmuch_database_open_with_config (const char *database_path,
432 notmuch_database_mode_t mode,
433 const char *config_path,
435 notmuch_database_t **database,
436 char **error_message);
439 * Retrieve last status string for given database.
443 notmuch_database_status_string (const notmuch_database_t *notmuch);
446 * Commit changes and close the given notmuch database.
448 * After notmuch_database_close has been called, calls to other
449 * functions on objects derived from this database may either behave
450 * as if the database had not been closed (e.g., if the required data
451 * has been cached) or may fail with a
452 * NOTMUCH_STATUS_XAPIAN_EXCEPTION. The only further operation
453 * permitted on the database itself is to call
454 * notmuch_database_destroy.
456 * notmuch_database_close can be called multiple times. Later calls
459 * For writable databases, notmuch_database_close commits all changes
460 * to disk before closing the database. If the caller is currently in
461 * an atomic section (there was a notmuch_database_begin_atomic
462 * without a matching notmuch_database_end_atomic), this will discard
463 * changes made in that atomic section (but still commit changes made
464 * prior to entering the atomic section).
468 * NOTMUCH_STATUS_SUCCESS: Successfully closed the database.
470 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; the
471 * database has been closed but there are no guarantees the
472 * changes to the database, if any, have been flushed to disk.
475 notmuch_database_close (notmuch_database_t *database);
478 * A callback invoked by notmuch_database_compact to notify the user
479 * of the progress of the compaction process.
481 typedef void (*notmuch_compact_status_cb_t)(const char *message, void *closure);
484 * Compact a notmuch database, backing up the original database to the
487 * The database will be opened with NOTMUCH_DATABASE_MODE_READ_WRITE
488 * during the compaction process to ensure no writes are made.
490 * If the optional callback function 'status_cb' is non-NULL, it will
491 * be called with diagnostic and informational messages. The argument
492 * 'closure' is passed verbatim to any callback invoked.
495 notmuch_database_compact (const char *path,
496 const char *backup_path,
497 notmuch_compact_status_cb_t status_cb,
501 * Like notmuch_database_compact, but take an open database as a
504 * @since libnnotmuch 5.4 (notmuch 0.32)
507 notmuch_database_compact_db (notmuch_database_t *database,
508 const char *backup_path,
509 notmuch_compact_status_cb_t status_cb,
513 * Destroy the notmuch database, closing it if necessary and freeing
514 * all associated resources.
516 * Return value as in notmuch_database_close if the database was open;
517 * notmuch_database_destroy itself has no failure modes.
520 notmuch_database_destroy (notmuch_database_t *database);
523 * Return the database path of the given database.
525 * The return value is a string owned by notmuch so should not be
526 * modified nor freed by the caller.
529 notmuch_database_get_path (notmuch_database_t *database);
532 * Return the database format version of the given database.
537 notmuch_database_get_version (notmuch_database_t *database);
540 * Can the database be upgraded to a newer database version?
542 * If this function returns TRUE, then the caller may call
543 * notmuch_database_upgrade to upgrade the database. If the caller
544 * does not upgrade an out-of-date database, then some functions may
545 * fail with NOTMUCH_STATUS_UPGRADE_REQUIRED. This always returns
546 * FALSE for a read-only database because there's no way to upgrade a
547 * read-only database.
549 * Also returns FALSE if an error occurs accessing the database.
553 notmuch_database_needs_upgrade (notmuch_database_t *database);
556 * Upgrade the current database to the latest supported version.
558 * This ensures that all current notmuch functionality will be
559 * available on the database. After opening a database in read-write
560 * mode, it is recommended that clients check if an upgrade is needed
561 * (notmuch_database_needs_upgrade) and if so, upgrade with this
562 * function before making any modifications. If
563 * notmuch_database_needs_upgrade returns FALSE, this will be a no-op.
565 * The optional progress_notify callback can be used by the caller to
566 * provide progress indication to the user. If non-NULL it will be
567 * called periodically with 'progress' as a floating-point value in
568 * the range of [0.0 .. 1.0] indicating the progress made so far in
569 * the upgrade process. The argument 'closure' is passed verbatim to
570 * any callback invoked.
573 notmuch_database_upgrade (notmuch_database_t *database,
574 void (*progress_notify)(void *closure,
579 * Begin an atomic database operation.
581 * Any modifications performed between a successful begin and a
582 * notmuch_database_end_atomic will be applied to the database
583 * atomically. Note that, unlike a typical database transaction, this
584 * only ensures atomicity, not durability; neither begin nor end
585 * necessarily flush modifications to disk.
587 * Atomic sections may be nested. begin_atomic and end_atomic must
588 * always be called in pairs.
592 * NOTMUCH_STATUS_SUCCESS: Successfully entered atomic section.
594 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
595 * atomic section not entered.
598 notmuch_database_begin_atomic (notmuch_database_t *notmuch);
601 * Indicate the end of an atomic database operation.
605 * NOTMUCH_STATUS_SUCCESS: Successfully completed atomic section.
607 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
608 * atomic section not ended.
610 * NOTMUCH_STATUS_UNBALANCED_ATOMIC: The database is not currently in
614 notmuch_database_end_atomic (notmuch_database_t *notmuch);
617 * Return the committed database revision and UUID.
619 * The database revision number increases monotonically with each
620 * commit to the database. Hence, all messages and message changes
621 * committed to the database (that is, visible to readers) have a last
622 * modification revision <= the committed database revision. Any
623 * messages committed in the future will be assigned a modification
624 * revision > the committed database revision.
626 * The UUID is a NUL-terminated opaque string that uniquely identifies
627 * this database. Two revision numbers are only comparable if they
628 * have the same database UUID.
631 notmuch_database_get_revision (notmuch_database_t *notmuch,
635 * Retrieve a directory object from the database for 'path'.
637 * Here, 'path' should be a path relative to the path of 'database'
638 * (see notmuch_database_get_path), or else should be an absolute path
639 * with initial components that match the path of 'database'.
641 * If this directory object does not exist in the database, this
642 * returns NOTMUCH_STATUS_SUCCESS and sets *directory to NULL.
644 * Otherwise the returned directory object is owned by the database
645 * and as such, will only be valid until notmuch_database_destroy is
650 * NOTMUCH_STATUS_SUCCESS: Successfully retrieved directory.
652 * NOTMUCH_STATUS_NULL_POINTER: The given 'directory' argument is NULL.
654 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
655 * directory not retrieved.
657 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
658 * database to use this function.
661 notmuch_database_get_directory (notmuch_database_t *database,
663 notmuch_directory_t **directory);
666 * Add a message file to a database, indexing it for retrieval by
667 * future searches. If a message already exists with the same message
668 * ID as the specified file, their indexes will be merged, and this
669 * new filename will also be associated with the existing message.
671 * Here, 'filename' should be a path relative to the path of
672 * 'database' (see notmuch_database_get_path), or else should be an
673 * absolute filename with initial components that match the path of
676 * The file should be a single mail message (not a multi-message mbox)
677 * that is expected to remain at its current location, (since the
678 * notmuch database will reference the filename, and will not copy the
679 * entire contents of the file.
681 * If another message with the same message ID already exists in the
682 * database, rather than creating a new message, this adds the search
683 * terms from the identified file to the existing message's index, and
684 * adds 'filename' to the list of filenames known for the message.
686 * The 'indexopts' parameter can be NULL (meaning, use the indexing
687 * defaults from the database), or can be an explicit choice of
688 * indexing options that should govern the indexing of this specific
691 * If 'message' is not NULL, then, on successful return
692 * (NOTMUCH_STATUS_SUCCESS or NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) '*message'
693 * will be initialized to a message object that can be used for things
694 * such as adding tags to the just-added message. The user should call
695 * notmuch_message_destroy when done with the message. On any failure
696 * '*message' will be set to NULL.
700 * NOTMUCH_STATUS_SUCCESS: Message successfully added to database.
702 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
705 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: Message has the same message
706 * ID as another message already in the database. The new
707 * filename was successfully added to the message in the database
708 * (if not already present) and the existing message is returned.
710 * NOTMUCH_STATUS_FILE_ERROR: an error occurred trying to open the
711 * file, (such as permission denied, or file not found,
712 * etc.). Nothing added to the database.
714 * NOTMUCH_STATUS_FILE_NOT_EMAIL: the contents of filename don't look
715 * like an email message. Nothing added to the database.
717 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
718 * mode so no message can be added.
720 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
721 * database to use this function.
723 * @since libnotmuch 5.1 (notmuch 0.26)
726 notmuch_database_index_file (notmuch_database_t *database,
727 const char *filename,
728 notmuch_indexopts_t *indexopts,
729 notmuch_message_t **message);
732 * Deprecated alias for notmuch_database_index_file called with
735 * @deprecated Deprecated as of libnotmuch 5.1 (notmuch 0.26). Please
736 * use notmuch_database_index_file instead.
739 NOTMUCH_DEPRECATED (5, 1)
741 notmuch_database_add_message (notmuch_database_t *database,
742 const char *filename,
743 notmuch_message_t **message);
746 * Remove a message filename from the given notmuch database. If the
747 * message has no more filenames, remove the message.
749 * If the same message (as determined by the message ID) is still
750 * available via other filenames, then the message will persist in the
751 * database for those filenames. When the last filename is removed for
752 * a particular message, the database content for that message will be
757 * NOTMUCH_STATUS_SUCCESS: The last filename was removed and the
758 * message was removed from the database.
760 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
761 * message not removed.
763 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: This filename was removed but
764 * the message persists in the database with at least one other
767 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
768 * mode so no message can be removed.
770 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
771 * database to use this function.
774 notmuch_database_remove_message (notmuch_database_t *database,
775 const char *filename);
778 * Find a message with the given message_id.
780 * If a message with the given message_id is found then, on successful return
781 * (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to a message
782 * object. The caller should call notmuch_message_destroy when done with the
785 * On any failure or when the message is not found, this function initializes
786 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
787 * caller is supposed to check '*message' for NULL to find out whether the
788 * message with the given message_id was found.
792 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'.
794 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
796 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating message object
798 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
801 notmuch_database_find_message (notmuch_database_t *database,
802 const char *message_id,
803 notmuch_message_t **message);
806 * Find a message with the given filename.
808 * If the database contains a message with the given filename then, on
809 * successful return (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to
810 * a message object. The caller should call notmuch_message_destroy when done
813 * On any failure or when the message is not found, this function initializes
814 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
815 * caller is supposed to check '*message' for NULL to find out whether the
816 * message with the given filename is found.
820 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'
822 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
824 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating the message object
826 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
828 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
829 * database to use this function.
832 notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
833 const char *filename,
834 notmuch_message_t **message);
837 * Return a list of all tags found in the database.
839 * This function creates a list of all tags found in the database. The
840 * resulting list contains all tags from all messages found in the database.
842 * On error this function returns NULL.
845 notmuch_database_get_all_tags (notmuch_database_t *db);
848 * Create a new query for 'database'.
850 * Here, 'database' should be an open database, (see
851 * notmuch_database_open and notmuch_database_create).
853 * For the query string, we'll document the syntax here more
854 * completely in the future, but it's likely to be a specialized
855 * version of the general Xapian query syntax:
857 * https://xapian.org/docs/queryparser.html
859 * As a special case, passing either a length-zero string, (that is ""),
860 * or a string consisting of a single asterisk (that is "*"), will
861 * result in a query that returns all messages in the database.
863 * See notmuch_query_set_sort for controlling the order of results.
864 * See notmuch_query_search_messages and notmuch_query_search_threads
865 * to actually execute the query.
867 * User should call notmuch_query_destroy when finished with this
870 * Will return NULL if insufficient memory is available.
873 notmuch_query_create (notmuch_database_t *database,
874 const char *query_string);
877 * Sort values for notmuch_query_set_sort.
883 NOTMUCH_SORT_OLDEST_FIRST,
887 NOTMUCH_SORT_NEWEST_FIRST,
889 * Sort by message-id.
891 NOTMUCH_SORT_MESSAGE_ID,
895 NOTMUCH_SORT_UNSORTED
899 * Return the query_string of this query. See notmuch_query_create.
902 notmuch_query_get_query_string (const notmuch_query_t *query);
905 * Return the notmuch database of this query. See notmuch_query_create.
908 notmuch_query_get_database (const notmuch_query_t *query);
911 * Exclude values for notmuch_query_set_omit_excluded. The strange
912 * order is to maintain backward compatibility: the old FALSE/TRUE
913 * options correspond to the new
914 * NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options.
917 NOTMUCH_EXCLUDE_FLAG,
918 NOTMUCH_EXCLUDE_TRUE,
919 NOTMUCH_EXCLUDE_FALSE,
924 * Specify whether to omit excluded results or simply flag them. By
925 * default, this is set to TRUE.
927 * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded
928 * messages from the results, and notmuch_query_search_threads will omit
929 * threads that match only in excluded messages. If set to TRUE,
930 * notmuch_query_search_threads will include all messages in threads that
931 * match in at least one non-excluded message. Otherwise, if set to ALL,
932 * notmuch_query_search_threads will omit excluded messages from all threads.
934 * If set to FALSE or FLAG then both notmuch_query_search_messages and
935 * notmuch_query_search_threads will return all matching
936 * messages/threads regardless of exclude status. If set to FLAG then
937 * the exclude flag will be set for any excluded message that is
938 * returned by notmuch_query_search_messages, and the thread counts
939 * for threads returned by notmuch_query_search_threads will be the
940 * number of non-excluded messages/matches. Otherwise, if set to
941 * FALSE, then the exclude status is completely ignored.
943 * The performance difference when calling
944 * notmuch_query_search_messages should be relatively small (and both
945 * should be very fast). However, in some cases,
946 * notmuch_query_search_threads is very much faster when omitting
947 * excluded messages as it does not need to construct the threads that
948 * only match in excluded messages.
951 notmuch_query_set_omit_excluded (notmuch_query_t *query,
952 notmuch_exclude_t omit_excluded);
955 * Specify the sorting desired for this query.
958 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
961 * Return the sort specified for this query. See
962 * notmuch_query_set_sort.
965 notmuch_query_get_sort (const notmuch_query_t *query);
968 * Add a tag that will be excluded from the query results by default.
969 * This exclusion will be ignored if this tag appears explicitly in
974 * NOTMUCH_STATUS_SUCCESS: excluded was added successfully.
976 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occurred.
977 * Most likely a problem lazily parsing the query string.
979 * NOTMUCH_STATUS_IGNORED: tag is explicitly present in the query, so
983 notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
986 * Execute a query for threads, returning a notmuch_threads_t object
987 * which can be used to iterate over the results. The returned threads
988 * object is owned by the query and as such, will only be valid until
989 * notmuch_query_destroy.
991 * Typical usage might be:
993 * notmuch_query_t *query;
994 * notmuch_threads_t *threads;
995 * notmuch_thread_t *thread;
996 * notmuch_status_t stat;
998 * query = notmuch_query_create (database, query_string);
1000 * for (stat = notmuch_query_search_threads (query, &threads);
1001 * stat == NOTMUCH_STATUS_SUCCESS &&
1002 * notmuch_threads_valid (threads);
1003 * notmuch_threads_move_to_next (threads))
1005 * thread = notmuch_threads_get (threads);
1007 * notmuch_thread_destroy (thread);
1010 * notmuch_query_destroy (query);
1012 * Note: If you are finished with a thread before its containing
1013 * query, you can call notmuch_thread_destroy to clean up some memory
1014 * sooner (as in the above example). Otherwise, if your thread objects
1015 * are long-lived, then you don't need to call notmuch_thread_destroy
1016 * and all the memory will still be reclaimed when the query is
1019 * Note that there's no explicit destructor needed for the
1020 * notmuch_threads_t object. (For consistency, we do provide a
1021 * notmuch_threads_destroy function, but there's no good reason
1022 * to call it if the query is about to be destroyed).
1024 * @since libnotmuch 5.0 (notmuch 0.25)
1027 notmuch_query_search_threads (notmuch_query_t *query,
1028 notmuch_threads_t **out);
1031 * Deprecated alias for notmuch_query_search_threads.
1033 * @deprecated Deprecated as of libnotmuch 5 (notmuch 0.25). Please
1034 * use notmuch_query_search_threads instead.
1037 NOTMUCH_DEPRECATED (5, 0)
1039 notmuch_query_search_threads_st (notmuch_query_t *query, notmuch_threads_t **out);
1042 * Execute a query for messages, returning a notmuch_messages_t object
1043 * which can be used to iterate over the results. The returned
1044 * messages object is owned by the query and as such, will only be
1045 * valid until notmuch_query_destroy.
1047 * Typical usage might be:
1049 * notmuch_query_t *query;
1050 * notmuch_messages_t *messages;
1051 * notmuch_message_t *message;
1053 * query = notmuch_query_create (database, query_string);
1055 * for (messages = notmuch_query_search_messages (query);
1056 * notmuch_messages_valid (messages);
1057 * notmuch_messages_move_to_next (messages))
1059 * message = notmuch_messages_get (messages);
1061 * notmuch_message_destroy (message);
1064 * notmuch_query_destroy (query);
1066 * Note: If you are finished with a message before its containing
1067 * query, you can call notmuch_message_destroy to clean up some memory
1068 * sooner (as in the above example). Otherwise, if your message
1069 * objects are long-lived, then you don't need to call
1070 * notmuch_message_destroy and all the memory will still be reclaimed
1071 * when the query is destroyed.
1073 * Note that there's no explicit destructor needed for the
1074 * notmuch_messages_t object. (For consistency, we do provide a
1075 * notmuch_messages_destroy function, but there's no good
1076 * reason to call it if the query is about to be destroyed).
1078 * If a Xapian exception occurs this function will return NULL.
1080 * @since libnotmuch 5 (notmuch 0.25)
1083 notmuch_query_search_messages (notmuch_query_t *query,
1084 notmuch_messages_t **out);
1086 * Deprecated alias for notmuch_query_search_messages
1088 * @deprecated Deprecated as of libnotmuch 5 (notmuch 0.25). Please use
1089 * notmuch_query_search_messages instead.
1093 NOTMUCH_DEPRECATED (5, 0)
1095 notmuch_query_search_messages_st (notmuch_query_t *query,
1096 notmuch_messages_t **out);
1099 * Destroy a notmuch_query_t along with any associated resources.
1101 * This will in turn destroy any notmuch_threads_t and
1102 * notmuch_messages_t objects generated by this query, (and in
1103 * turn any notmuch_thread_t and notmuch_message_t objects generated
1104 * from those results, etc.), if such objects haven't already been
1108 notmuch_query_destroy (notmuch_query_t *query);
1111 * Is the given 'threads' iterator pointing at a valid thread.
1113 * When this function returns TRUE, notmuch_threads_get will return a
1114 * valid object. Whereas when this function returns FALSE,
1115 * notmuch_threads_get will return NULL.
1117 * If passed a NULL pointer, this function returns FALSE
1119 * See the documentation of notmuch_query_search_threads for example
1120 * code showing how to iterate over a notmuch_threads_t object.
1123 notmuch_threads_valid (notmuch_threads_t *threads);
1126 * Get the current thread from 'threads' as a notmuch_thread_t.
1128 * Note: The returned thread belongs to 'threads' and has a lifetime
1129 * identical to it (and the query to which it belongs).
1131 * See the documentation of notmuch_query_search_threads for example
1132 * code showing how to iterate over a notmuch_threads_t object.
1134 * If an out-of-memory situation occurs, this function will return
1138 notmuch_threads_get (notmuch_threads_t *threads);
1141 * Move the 'threads' iterator to the next thread.
1143 * If 'threads' is already pointing at the last thread then the
1144 * iterator will be moved to a point just beyond that last thread,
1145 * (where notmuch_threads_valid will return FALSE and
1146 * notmuch_threads_get will return NULL).
1148 * See the documentation of notmuch_query_search_threads for example
1149 * code showing how to iterate over a notmuch_threads_t object.
1152 notmuch_threads_move_to_next (notmuch_threads_t *threads);
1155 * Destroy a notmuch_threads_t object.
1157 * It's not strictly necessary to call this function. All memory from
1158 * the notmuch_threads_t object will be reclaimed when the
1159 * containing query object is destroyed.
1162 notmuch_threads_destroy (notmuch_threads_t *threads);
1165 * Return the number of messages matching a search.
1167 * This function performs a search and returns the number of matching
1172 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1174 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occurred. The
1175 * value of *count is not defined.
1177 * @since libnotmuch 5 (notmuch 0.25)
1180 notmuch_query_count_messages (notmuch_query_t *query, unsigned int *count);
1183 * Deprecated alias for notmuch_query_count_messages
1186 * @deprecated Deprecated since libnotmuch 5.0 (notmuch 0.25). Please
1187 * use notmuch_query_count_messages instead.
1189 NOTMUCH_DEPRECATED (5, 0)
1191 notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
1194 * Return the number of threads matching a search.
1196 * This function performs a search and returns the number of unique thread IDs
1197 * in the matching messages. This is the same as number of threads matching a
1200 * Note that this is a significantly heavier operation than
1201 * notmuch_query_count_messages{_st}().
1205 * NOTMUCH_STATUS_OUT_OF_MEMORY: Memory allocation failed. The value
1206 * of *count is not defined
1208 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1210 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occurred. The
1211 * value of *count is not defined.
1213 * @since libnotmuch 5 (notmuch 0.25)
1216 notmuch_query_count_threads (notmuch_query_t *query, unsigned *count);
1219 * Deprecated alias for notmuch_query_count_threads
1221 * @deprecated Deprecated as of libnotmuch 5.0 (notmuch 0.25). Please
1222 * use notmuch_query_count_threads_st instead.
1224 NOTMUCH_DEPRECATED (5, 0)
1226 notmuch_query_count_threads_st (notmuch_query_t *query, unsigned *count);
1229 * Get the thread ID of 'thread'.
1231 * The returned string belongs to 'thread' and as such, should not be
1232 * modified by the caller and will only be valid for as long as the
1233 * thread is valid, (which is until notmuch_thread_destroy or until
1234 * the query from which it derived is destroyed).
1237 notmuch_thread_get_thread_id (notmuch_thread_t *thread);
1240 * Get the total number of messages in 'thread'.
1242 * This count consists of all messages in the database belonging to
1243 * this thread. Contrast with notmuch_thread_get_matched_messages() .
1246 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
1249 * Get the total number of files in 'thread'.
1251 * This sums notmuch_message_count_files over all messages in the
1253 * @returns Non-negative integer
1254 * @since libnotmuch 5.0 (notmuch 0.25)
1258 notmuch_thread_get_total_files (notmuch_thread_t *thread);
1261 * Get a notmuch_messages_t iterator for the top-level messages in
1262 * 'thread' in oldest-first order.
1264 * This iterator will not necessarily iterate over all of the messages
1265 * in the thread. It will only iterate over the messages in the thread
1266 * which are not replies to other messages in the thread.
1268 * The returned list will be destroyed when the thread is destroyed.
1270 notmuch_messages_t *
1271 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
1274 * Get a notmuch_thread_t iterator for all messages in 'thread' in
1275 * oldest-first order.
1277 * The returned list will be destroyed when the thread is destroyed.
1279 notmuch_messages_t *
1280 notmuch_thread_get_messages (notmuch_thread_t *thread);
1283 * Get the number of messages in 'thread' that matched the search.
1285 * This count includes only the messages in this thread that were
1286 * matched by the search from which the thread was created and were
1287 * not excluded by any exclude tags passed in with the query (see
1288 * notmuch_query_add_tag_exclude). Contrast with
1289 * notmuch_thread_get_total_messages() .
1292 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
1295 * Get the authors of 'thread' as a UTF-8 string.
1297 * The returned string is a comma-separated list of the names of the
1298 * authors of mail messages in the query results that belong to this
1301 * The string contains authors of messages matching the query first, then
1302 * non-matched authors (with the two groups separated by '|'). Within
1303 * each group, authors are ordered by date.
1305 * The returned string belongs to 'thread' and as such, should not be
1306 * modified by the caller and will only be valid for as long as the
1307 * thread is valid, (which is until notmuch_thread_destroy or until
1308 * the query from which it derived is destroyed).
1311 notmuch_thread_get_authors (notmuch_thread_t *thread);
1314 * Get the subject of 'thread' as a UTF-8 string.
1316 * The subject is taken from the first message (according to the query
1317 * order---see notmuch_query_set_sort) in the query results that
1318 * belongs to this thread.
1320 * The returned string belongs to 'thread' and as such, should not be
1321 * modified by the caller and will only be valid for as long as the
1322 * thread is valid, (which is until notmuch_thread_destroy or until
1323 * the query from which it derived is destroyed).
1326 notmuch_thread_get_subject (notmuch_thread_t *thread);
1329 * Get the date of the oldest message in 'thread' as a time_t value.
1332 notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
1335 * Get the date of the newest message in 'thread' as a time_t value.
1338 notmuch_thread_get_newest_date (notmuch_thread_t *thread);
1341 * Get the tags for 'thread', returning a notmuch_tags_t object which
1342 * can be used to iterate over all tags.
1344 * Note: In the Notmuch database, tags are stored on individual
1345 * messages, not on threads. So the tags returned here will be all
1346 * tags of the messages which matched the search and which belong to
1349 * The tags object is owned by the thread and as such, will only be
1350 * valid for as long as the thread is valid, (for example, until
1351 * notmuch_thread_destroy or until the query from which it derived is
1354 * Typical usage might be:
1356 * notmuch_thread_t *thread;
1357 * notmuch_tags_t *tags;
1360 * thread = notmuch_threads_get (threads);
1362 * for (tags = notmuch_thread_get_tags (thread);
1363 * notmuch_tags_valid (tags);
1364 * notmuch_tags_move_to_next (tags))
1366 * tag = notmuch_tags_get (tags);
1370 * notmuch_thread_destroy (thread);
1372 * Note that there's no explicit destructor needed for the
1373 * notmuch_tags_t object. (For consistency, we do provide a
1374 * notmuch_tags_destroy function, but there's no good reason to call
1375 * it if the message is about to be destroyed).
1378 notmuch_thread_get_tags (notmuch_thread_t *thread);
1381 * Destroy a notmuch_thread_t object.
1384 notmuch_thread_destroy (notmuch_thread_t *thread);
1387 * Is the given 'messages' iterator pointing at a valid message.
1389 * When this function returns TRUE, notmuch_messages_get will return a
1390 * valid object. Whereas when this function returns FALSE,
1391 * notmuch_messages_get will return NULL.
1393 * See the documentation of notmuch_query_search_messages for example
1394 * code showing how to iterate over a notmuch_messages_t object.
1397 notmuch_messages_valid (notmuch_messages_t *messages);
1400 * Get the current message from 'messages' as a notmuch_message_t.
1402 * Note: The returned message belongs to 'messages' and has a lifetime
1403 * identical to it (and the query to which it belongs).
1405 * See the documentation of notmuch_query_search_messages for example
1406 * code showing how to iterate over a notmuch_messages_t object.
1408 * If an out-of-memory situation occurs, this function will return
1412 notmuch_messages_get (notmuch_messages_t *messages);
1415 * Move the 'messages' iterator to the next message.
1417 * If 'messages' is already pointing at the last message then the
1418 * iterator will be moved to a point just beyond that last message,
1419 * (where notmuch_messages_valid will return FALSE and
1420 * notmuch_messages_get will return NULL).
1422 * See the documentation of notmuch_query_search_messages for example
1423 * code showing how to iterate over a notmuch_messages_t object.
1426 notmuch_messages_move_to_next (notmuch_messages_t *messages);
1429 * Destroy a notmuch_messages_t object.
1431 * It's not strictly necessary to call this function. All memory from
1432 * the notmuch_messages_t object will be reclaimed when the containing
1433 * query object is destroyed.
1436 notmuch_messages_destroy (notmuch_messages_t *messages);
1439 * Return a list of tags from all messages.
1441 * The resulting list is guaranteed not to contain duplicated tags.
1443 * WARNING: You can no longer iterate over messages after calling this
1444 * function, because the iterator will point at the end of the list.
1445 * We do not have a function to reset the iterator yet and the only
1446 * way how you can iterate over the list again is to recreate the
1449 * The function returns NULL on error.
1452 notmuch_messages_collect_tags (notmuch_messages_t *messages);
1455 * Get the database associated with this message.
1457 * @since libnotmuch 5.2 (notmuch 0.27)
1459 notmuch_database_t *
1460 notmuch_message_get_database (const notmuch_message_t *message);
1463 * Get the message ID of 'message'.
1465 * The returned string belongs to 'message' and as such, should not be
1466 * modified by the caller and will only be valid for as long as the
1467 * message is valid, (which is until the query from which it derived
1470 * This function will return NULL if triggers an unhandled Xapian
1474 notmuch_message_get_message_id (notmuch_message_t *message);
1477 * Get the thread ID of 'message'.
1479 * The returned string belongs to 'message' and as such, should not be
1480 * modified by the caller and will only be valid for as long as the
1481 * message is valid, (for example, until the user calls
1482 * notmuch_message_destroy on 'message' or until a query from which it
1483 * derived is destroyed).
1485 * This function will return NULL if triggers an unhandled Xapian
1489 notmuch_message_get_thread_id (notmuch_message_t *message);
1492 * Get a notmuch_messages_t iterator for all of the replies to
1495 * Note: This call only makes sense if 'message' was ultimately
1496 * obtained from a notmuch_thread_t object, (such as by coming
1497 * directly from the result of calling notmuch_thread_get_
1498 * toplevel_messages or by any number of subsequent
1499 * calls to notmuch_message_get_replies).
1501 * If 'message' was obtained through some non-thread means, (such as
1502 * by a call to notmuch_query_search_messages), then this function
1505 * If there are no replies to 'message', this function will return
1506 * NULL. (Note that notmuch_messages_valid will accept that NULL
1507 * value as legitimate, and simply return FALSE for it.)
1509 * This function also returns NULL if it triggers a Xapian exception.
1511 * The returned list will be destroyed when the thread is
1514 notmuch_messages_t *
1515 notmuch_message_get_replies (notmuch_message_t *message);
1518 * Get the total number of files associated with a message.
1519 * @returns Non-negative integer for file count.
1520 * @returns Negative integer for error.
1521 * @since libnotmuch 5.0 (notmuch 0.25)
1524 notmuch_message_count_files (notmuch_message_t *message);
1527 * Get a filename for the email corresponding to 'message'.
1529 * The returned filename is an absolute filename, (the initial
1530 * component will match notmuch_database_get_path() ).
1532 * The returned string belongs to the message so should not be
1533 * modified or freed by the caller (nor should it be referenced after
1534 * the message is destroyed).
1536 * Note: If this message corresponds to multiple files in the mail
1537 * store, (that is, multiple files contain identical message IDs),
1538 * this function will arbitrarily return a single one of those
1539 * filenames. See notmuch_message_get_filenames for returning the
1540 * complete list of filenames.
1542 * This function returns NULL if it triggers a Xapian exception.
1545 notmuch_message_get_filename (notmuch_message_t *message);
1548 * Get all filenames for the email corresponding to 'message'.
1550 * Returns a notmuch_filenames_t iterator listing all the filenames
1551 * associated with 'message'. These files may not have identical
1552 * content, but each will have the identical Message-ID.
1554 * Each filename in the iterator is an absolute filename, (the initial
1555 * component will match notmuch_database_get_path() ).
1557 * This function returns NULL if it triggers a Xapian exception.
1559 notmuch_filenames_t *
1560 notmuch_message_get_filenames (notmuch_message_t *message);
1563 * Re-index the e-mail corresponding to 'message' using the supplied index options
1565 * Returns the status of the re-index operation. (see the return
1566 * codes documented in notmuch_database_index_file)
1568 * After reindexing, the user should discard the message object passed
1569 * in here by calling notmuch_message_destroy, since it refers to the
1570 * original message, not to the reindexed message.
1573 notmuch_message_reindex (notmuch_message_t *message,
1574 notmuch_indexopts_t *indexopts);
1579 typedef enum _notmuch_message_flag {
1580 NOTMUCH_MESSAGE_FLAG_MATCH,
1581 NOTMUCH_MESSAGE_FLAG_EXCLUDED,
1583 /* This message is a "ghost message", meaning it has no filenames
1584 * or content, but we know it exists because it was referenced by
1585 * some other message. A ghost message has only a message ID and
1588 NOTMUCH_MESSAGE_FLAG_GHOST,
1589 } notmuch_message_flag_t;
1592 * Get a value of a flag for the email corresponding to 'message'.
1594 * returns FALSE in case of errors.
1596 * @deprecated Deprecated as of libnotmuch 5.3 (notmuch 0.31). Please
1597 * use notmuch_message_get_flag_st instead.
1599 NOTMUCH_DEPRECATED(5,3)
1601 notmuch_message_get_flag (notmuch_message_t *message,
1602 notmuch_message_flag_t flag);
1605 * Get a value of a flag for the email corresponding to 'message'.
1607 * @param message a message object
1608 * @param flag flag to check
1609 * @param is_set pointer to boolean to store flag value.
1611 * @retval #NOTMUCH_STATUS_SUCCESS
1612 * @retval #NOTMUCH_STATUS_NULL_POINTER is_set is NULL
1613 * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION Accessing the database
1614 * triggered an exception.
1616 * @since libnotmuch 5.3 (notmuch 0.31)
1619 notmuch_message_get_flag_st (notmuch_message_t *message,
1620 notmuch_message_flag_t flag,
1621 notmuch_bool_t *is_set);
1624 * Set a value of a flag for the email corresponding to 'message'.
1627 notmuch_message_set_flag (notmuch_message_t *message,
1628 notmuch_message_flag_t flag, notmuch_bool_t value);
1631 * Get the date of 'message' as a time_t value.
1633 * For the original textual representation of the Date header from the
1634 * message call notmuch_message_get_header() with a header value of
1637 * Returns 0 in case of error.
1640 notmuch_message_get_date (notmuch_message_t *message);
1643 * Get the value of the specified header from 'message' as a UTF-8 string.
1645 * Common headers are stored in the database when the message is
1646 * indexed and will be returned from the database. Other headers will
1647 * be read from the actual message file.
1649 * The header name is case insensitive.
1651 * The returned string belongs to the message so should not be
1652 * modified or freed by the caller (nor should it be referenced after
1653 * the message is destroyed).
1655 * Returns an empty string ("") if the message does not contain a
1656 * header line matching 'header'. Returns NULL if any error occurs.
1659 notmuch_message_get_header (notmuch_message_t *message, const char *header);
1662 * Get the tags for 'message', returning a notmuch_tags_t object which
1663 * can be used to iterate over all tags.
1665 * The tags object is owned by the message and as such, will only be
1666 * valid for as long as the message is valid, (which is until the
1667 * query from which it derived is destroyed).
1669 * Typical usage might be:
1671 * notmuch_message_t *message;
1672 * notmuch_tags_t *tags;
1675 * message = notmuch_database_find_message (database, message_id);
1677 * for (tags = notmuch_message_get_tags (message);
1678 * notmuch_tags_valid (tags);
1679 * notmuch_tags_move_to_next (tags))
1681 * tag = notmuch_tags_get (tags);
1685 * notmuch_message_destroy (message);
1687 * Note that there's no explicit destructor needed for the
1688 * notmuch_tags_t object. (For consistency, we do provide a
1689 * notmuch_tags_destroy function, but there's no good reason to call
1690 * it if the message is about to be destroyed).
1693 notmuch_message_get_tags (notmuch_message_t *message);
1696 * The longest possible tag value.
1698 #define NOTMUCH_TAG_MAX 200
1701 * Add a tag to the given message.
1705 * NOTMUCH_STATUS_SUCCESS: Tag successfully added to message
1707 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1709 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1710 * (exceeds NOTMUCH_TAG_MAX)
1712 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1713 * mode so message cannot be modified.
1716 notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
1719 * Remove a tag from the given message.
1723 * NOTMUCH_STATUS_SUCCESS: Tag successfully removed from message
1725 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1727 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1728 * (exceeds NOTMUCH_TAG_MAX)
1730 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1731 * mode so message cannot be modified.
1734 notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
1737 * Remove all tags from the given message.
1739 * See notmuch_message_freeze for an example showing how to safely
1740 * replace tag values.
1742 * @retval #NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
1743 * read-only mode so message cannot be modified.
1744 * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION: an exception was thrown
1745 * accessing the database.
1748 notmuch_message_remove_all_tags (notmuch_message_t *message);
1751 * Add/remove tags according to maildir flags in the message filename(s).
1753 * This function examines the filenames of 'message' for maildir
1754 * flags, and adds or removes tags on 'message' as follows when these
1755 * flags are present:
1757 * Flag Action if present
1758 * ---- -----------------
1759 * 'D' Adds the "draft" tag to the message
1760 * 'F' Adds the "flagged" tag to the message
1761 * 'P' Adds the "passed" tag to the message
1762 * 'R' Adds the "replied" tag to the message
1763 * 'S' Removes the "unread" tag from the message
1765 * For each flag that is not present, the opposite action (add/remove)
1766 * is performed for the corresponding tags.
1768 * Flags are identified as trailing components of the filename after a
1769 * sequence of ":2,".
1771 * If there are multiple filenames associated with this message, the
1772 * flag is considered present if it appears in one or more
1773 * filenames. (That is, the flags from the multiple filenames are
1774 * combined with the logical OR operator.)
1776 * A client can ensure that notmuch database tags remain synchronized
1777 * with maildir flags by calling this function after each call to
1778 * notmuch_database_index_file. See also
1779 * notmuch_message_tags_to_maildir_flags for synchronizing tag changes
1780 * back to maildir flags.
1783 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
1786 * return TRUE if any filename of 'message' has maildir flag 'flag',
1789 * Deprecated wrapper for notmuch_message_has_maildir_flag_st
1791 * @returns FALSE in case of error
1792 * @deprecated libnotmuch 5.3 (notmuch 0.31)
1794 NOTMUCH_DEPRECATED(5, 3)
1796 notmuch_message_has_maildir_flag (notmuch_message_t *message, char flag);
1799 * check message for maildir flag
1801 * @param [in,out] message message to check
1802 * @param [in] flag flag to check for
1803 * @param [out] is_set pointer to boolean
1805 * @retval #NOTMUCH_STATUS_SUCCESS
1806 * @retval #NOTMUCH_STATUS_NULL_POINTER is_set is NULL
1807 * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION Accessing the database
1808 * triggered an exception.
1811 notmuch_message_has_maildir_flag_st (notmuch_message_t *message,
1813 notmuch_bool_t *is_set);
1816 * Rename message filename(s) to encode tags as maildir flags.
1818 * Specifically, for each filename corresponding to this message:
1820 * If the filename is not in a maildir directory, do nothing. (A
1821 * maildir directory is determined as a directory named "new" or
1822 * "cur".) Similarly, if the filename has invalid maildir info,
1823 * (repeated or outof-ASCII-order flag characters after ":2,"), then
1826 * If the filename is in a maildir directory, rename the file so that
1827 * its filename ends with the sequence ":2," followed by zero or more
1828 * of the following single-character flags (in ASCII order):
1830 * * flag 'D' iff the message has the "draft" tag
1831 * * flag 'F' iff the message has the "flagged" tag
1832 * * flag 'P' iff the message has the "passed" tag
1833 * * flag 'R' iff the message has the "replied" tag
1834 * * flag 'S' iff the message does not have the "unread" tag
1836 * Any existing flags unmentioned in the list above will be preserved
1839 * Also, if this filename is in a directory named "new", rename it to
1840 * be within the neighboring directory named "cur".
1842 * A client can ensure that maildir filename flags remain synchronized
1843 * with notmuch database tags by calling this function after changing
1844 * tags, (after calls to notmuch_message_add_tag,
1845 * notmuch_message_remove_tag, or notmuch_message_freeze/
1846 * notmuch_message_thaw). See also notmuch_message_maildir_flags_to_tags
1847 * for synchronizing maildir flag changes back to tags.
1850 notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
1853 * Freeze the current state of 'message' within the database.
1855 * This means that changes to the message state, (via
1856 * notmuch_message_add_tag, notmuch_message_remove_tag, and
1857 * notmuch_message_remove_all_tags), will not be committed to the
1858 * database until the message is thawed with notmuch_message_thaw.
1860 * Multiple calls to freeze/thaw are valid and these calls will
1861 * "stack". That is there must be as many calls to thaw as to freeze
1862 * before a message is actually thawed.
1864 * The ability to do freeze/thaw allows for safe transactions to
1865 * change tag values. For example, explicitly setting a message to
1866 * have a given set of tags might look like this:
1868 * notmuch_message_freeze (message);
1870 * notmuch_message_remove_all_tags (message);
1872 * for (i = 0; i < NUM_TAGS; i++)
1873 * notmuch_message_add_tag (message, tags[i]);
1875 * notmuch_message_thaw (message);
1877 * With freeze/thaw used like this, the message in the database is
1878 * guaranteed to have either the full set of original tag values, or
1879 * the full set of new tag values, but nothing in between.
1881 * Imagine the example above without freeze/thaw and the operation
1882 * somehow getting interrupted. This could result in the message being
1883 * left with no tags if the interruption happened after
1884 * notmuch_message_remove_all_tags but before notmuch_message_add_tag.
1888 * NOTMUCH_STATUS_SUCCESS: Message successfully frozen.
1890 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1891 * mode so message cannot be modified.
1894 notmuch_message_freeze (notmuch_message_t *message);
1897 * Thaw the current 'message', synchronizing any changes that may have
1898 * occurred while 'message' was frozen into the notmuch database.
1900 * See notmuch_message_freeze for an example of how to use this
1901 * function to safely provide tag changes.
1903 * Multiple calls to freeze/thaw are valid and these calls with
1904 * "stack". That is there must be as many calls to thaw as to freeze
1905 * before a message is actually thawed.
1909 * NOTMUCH_STATUS_SUCCESS: Message successfully thawed, (or at least
1910 * its frozen count has successfully been reduced by 1).
1912 * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: An attempt was made to thaw
1913 * an unfrozen message. That is, there have been an unbalanced
1914 * number of calls to notmuch_message_freeze and
1915 * notmuch_message_thaw.
1918 notmuch_message_thaw (notmuch_message_t *message);
1921 * Destroy a notmuch_message_t object.
1923 * It can be useful to call this function in the case of a single
1924 * query object with many messages in the result, (such as iterating
1925 * over the entire database). Otherwise, it's fine to never call this
1926 * function and there will still be no memory leaks. (The memory from
1927 * the messages get reclaimed when the containing query is destroyed.)
1930 notmuch_message_destroy (notmuch_message_t *message);
1933 * @name Message Properties
1935 * This interface provides the ability to attach arbitrary (key,value)
1936 * string pairs to a message, to remove such pairs, and to iterate
1937 * over them. The caller should take some care as to what keys they
1938 * add or delete values for, as other subsystems or extensions may
1939 * depend on these properties.
1941 * Please see notmuch-properties(7) for more details about specific
1942 * properties and conventions around their use.
1947 * Retrieve the value for a single property key
1949 * *value* is set to a string owned by the message or NULL if there is
1950 * no such key. In the case of multiple values for the given key, the
1951 * first one is retrieved.
1954 * - NOTMUCH_STATUS_NULL_POINTER: *value* may not be NULL.
1955 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
1956 * @since libnotmuch 4.4 (notmuch 0.23)
1959 notmuch_message_get_property (notmuch_message_t *message, const char *key, const char **value);
1962 * Add a (key,value) pair to a message
1965 * - NOTMUCH_STATUS_ILLEGAL_ARGUMENT: *key* may not contain an '=' character.
1966 * - NOTMUCH_STATUS_NULL_POINTER: Neither *key* nor *value* may be NULL.
1967 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
1968 * @since libnotmuch 4.4 (notmuch 0.23)
1971 notmuch_message_add_property (notmuch_message_t *message, const char *key, const char *value);
1974 * Remove a (key,value) pair from a message.
1976 * It is not an error to remove a non-existent (key,value) pair
1979 * - NOTMUCH_STATUS_ILLEGAL_ARGUMENT: *key* may not contain an '=' character.
1980 * - NOTMUCH_STATUS_NULL_POINTER: Neither *key* nor *value* may be NULL.
1981 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
1982 * @since libnotmuch 4.4 (notmuch 0.23)
1985 notmuch_message_remove_property (notmuch_message_t *message, const char *key, const char *value);
1988 * Remove all (key,value) pairs from the given message.
1990 * @param[in,out] message message to operate on.
1991 * @param[in] key key to delete properties for. If NULL, delete
1992 * properties for all keys
1994 * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
1995 * read-only mode so message cannot be modified.
1996 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
1998 * @since libnotmuch 4.4 (notmuch 0.23)
2001 notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key);
2004 * Remove all (prefix*,value) pairs from the given message
2006 * @param[in,out] message message to operate on.
2007 * @param[in] prefix delete properties with keys that start with prefix.
2008 * If NULL, delete all properties
2010 * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
2011 * read-only mode so message cannot be modified.
2012 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
2014 * @since libnotmuch 5.1 (notmuch 0.26)
2017 notmuch_message_remove_all_properties_with_prefix (notmuch_message_t *message, const char *prefix);
2020 * Opaque message property iterator
2022 typedef struct _notmuch_string_map_iterator notmuch_message_properties_t;
2025 * Get the properties for *message*, returning a
2026 * notmuch_message_properties_t object which can be used to iterate
2027 * over all properties.
2029 * The notmuch_message_properties_t object is owned by the message and
2030 * as such, will only be valid for as long as the message is valid,
2031 * (which is until the query from which it derived is destroyed).
2033 * @param[in] message The message to examine
2034 * @param[in] key key or key prefix
2035 * @param[in] exact if TRUE, require exact match with key. Otherwise
2038 * Typical usage might be:
2040 * notmuch_message_properties_t *list;
2042 * for (list = notmuch_message_get_properties (message, "testkey1", TRUE);
2043 * notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) {
2044 * printf("%s\n", notmuch_message_properties_value(list));
2047 * notmuch_message_properties_destroy (list);
2049 * Note that there's no explicit destructor needed for the
2050 * notmuch_message_properties_t object. (For consistency, we do
2051 * provide a notmuch_message_properities_destroy function, but there's
2052 * no good reason to call it if the message is about to be destroyed).
2054 * @since libnotmuch 4.4 (notmuch 0.23)
2056 notmuch_message_properties_t *
2057 notmuch_message_get_properties (notmuch_message_t *message, const char *key, notmuch_bool_t exact);
2060 * Return the number of properties named "key" belonging to the specific message.
2062 * @param[in] message The message to examine
2063 * @param[in] key key to count
2064 * @param[out] count The number of matching properties associated with this message.
2068 * NOTMUCH_STATUS_SUCCESS: successful count, possibly some other error.
2070 * @since libnotmuch 5.2 (notmuch 0.27)
2073 notmuch_message_count_properties (notmuch_message_t *message, const char *key, unsigned int *count);
2076 * Is the given *properties* iterator pointing at a valid (key,value)
2079 * When this function returns TRUE,
2080 * notmuch_message_properties_{key,value} will return a valid string,
2081 * and notmuch_message_properties_move_to_next will do what it
2082 * says. Whereas when this function returns FALSE, calling any of
2083 * these functions results in undefined behaviour.
2085 * See the documentation of notmuch_message_get_properties for example
2086 * code showing how to iterate over a notmuch_message_properties_t
2089 * @since libnotmuch 4.4 (notmuch 0.23)
2092 notmuch_message_properties_valid (notmuch_message_properties_t *properties);
2095 * Move the *properties* iterator to the next (key,value) pair
2097 * If *properties* is already pointing at the last pair then the iterator
2098 * will be moved to a point just beyond that last pair, (where
2099 * notmuch_message_properties_valid will return FALSE).
2101 * See the documentation of notmuch_message_get_properties for example
2102 * code showing how to iterate over a notmuch_message_properties_t object.
2104 * @since libnotmuch 4.4 (notmuch 0.23)
2107 notmuch_message_properties_move_to_next (notmuch_message_properties_t *properties);
2110 * Return the key from the current (key,value) pair.
2112 * this could be useful if iterating for a prefix
2114 * @since libnotmuch 4.4 (notmuch 0.23)
2117 notmuch_message_properties_key (notmuch_message_properties_t *properties);
2120 * Return the value from the current (key,value) pair.
2122 * This could be useful if iterating for a prefix.
2124 * @since libnotmuch 4.4 (notmuch 0.23)
2127 notmuch_message_properties_value (notmuch_message_properties_t *properties);
2131 * Destroy a notmuch_message_properties_t object.
2133 * It's not strictly necessary to call this function. All memory from
2134 * the notmuch_message_properties_t object will be reclaimed when the
2135 * containing message object is destroyed.
2137 * @since libnotmuch 4.4 (notmuch 0.23)
2140 notmuch_message_properties_destroy (notmuch_message_properties_t *properties);
2145 * Is the given 'tags' iterator pointing at a valid tag.
2147 * When this function returns TRUE, notmuch_tags_get will return a
2148 * valid string. Whereas when this function returns FALSE,
2149 * notmuch_tags_get will return NULL.
2151 * See the documentation of notmuch_message_get_tags for example code
2152 * showing how to iterate over a notmuch_tags_t object.
2155 notmuch_tags_valid (notmuch_tags_t *tags);
2158 * Get the current tag from 'tags' as a string.
2160 * Note: The returned string belongs to 'tags' and has a lifetime
2161 * identical to it (and the query to which it ultimately belongs).
2163 * See the documentation of notmuch_message_get_tags for example code
2164 * showing how to iterate over a notmuch_tags_t object.
2167 notmuch_tags_get (notmuch_tags_t *tags);
2170 * Move the 'tags' iterator to the next tag.
2172 * If 'tags' is already pointing at the last tag then the iterator
2173 * will be moved to a point just beyond that last tag, (where
2174 * notmuch_tags_valid will return FALSE and notmuch_tags_get will
2177 * See the documentation of notmuch_message_get_tags for example code
2178 * showing how to iterate over a notmuch_tags_t object.
2181 notmuch_tags_move_to_next (notmuch_tags_t *tags);
2184 * Destroy a notmuch_tags_t object.
2186 * It's not strictly necessary to call this function. All memory from
2187 * the notmuch_tags_t object will be reclaimed when the containing
2188 * message or query objects are destroyed.
2191 notmuch_tags_destroy (notmuch_tags_t *tags);
2194 * Store an mtime within the database for 'directory'.
2196 * The 'directory' should be an object retrieved from the database
2197 * with notmuch_database_get_directory for a particular path.
2199 * The intention is for the caller to use the mtime to allow efficient
2200 * identification of new messages to be added to the database. The
2201 * recommended usage is as follows:
2203 * o Read the mtime of a directory from the filesystem
2205 * o Call index_file for all mail files in the directory
2207 * o Call notmuch_directory_set_mtime with the mtime read from the
2210 * Then, when wanting to check for updates to the directory in the
2211 * future, the client can call notmuch_directory_get_mtime and know
2212 * that it only needs to add files if the mtime of the directory and
2213 * files are newer than the stored timestamp.
2215 * Note: The notmuch_directory_get_mtime function does not allow the
2216 * caller to distinguish a timestamp of 0 from a non-existent
2217 * timestamp. So don't store a timestamp of 0 unless you are
2218 * comfortable with that.
2222 * NOTMUCH_STATUS_SUCCESS: mtime successfully stored in database.
2224 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception
2225 * occurred, mtime not stored.
2227 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
2228 * mode so directory mtime cannot be modified.
2231 notmuch_directory_set_mtime (notmuch_directory_t *directory,
2235 * Get the mtime of a directory, (as previously stored with
2236 * notmuch_directory_set_mtime).
2238 * Returns 0 if no mtime has previously been stored for this
2242 notmuch_directory_get_mtime (notmuch_directory_t *directory);
2245 * Get a notmuch_filenames_t iterator listing all the filenames of
2246 * messages in the database within the given directory.
2248 * The returned filenames will be the basename-entries only (not
2251 * Returns NULL if it triggers a Xapian exception
2253 notmuch_filenames_t *
2254 notmuch_directory_get_child_files (notmuch_directory_t *directory);
2257 * Get a notmuch_filenames_t iterator listing all the filenames of
2258 * sub-directories in the database within the given directory.
2260 * The returned filenames will be the basename-entries only (not
2263 * Returns NULL if it triggers a Xapian exception
2265 notmuch_filenames_t *
2266 notmuch_directory_get_child_directories (notmuch_directory_t *directory);
2269 * Delete directory document from the database, and destroy the
2270 * notmuch_directory_t object. Assumes any child directories and files
2271 * have been deleted by the caller.
2273 * @since libnotmuch 4.3 (notmuch 0.21)
2276 notmuch_directory_delete (notmuch_directory_t *directory);
2279 * Destroy a notmuch_directory_t object.
2282 notmuch_directory_destroy (notmuch_directory_t *directory);
2285 * Is the given 'filenames' iterator pointing at a valid filename.
2287 * When this function returns TRUE, notmuch_filenames_get will return
2288 * a valid string. Whereas when this function returns FALSE,
2289 * notmuch_filenames_get will return NULL.
2291 * It is acceptable to pass NULL for 'filenames', in which case this
2292 * function will always return FALSE.
2295 notmuch_filenames_valid (notmuch_filenames_t *filenames);
2298 * Get the current filename from 'filenames' as a string.
2300 * Note: The returned string belongs to 'filenames' and has a lifetime
2301 * identical to it (and the directory to which it ultimately belongs).
2303 * It is acceptable to pass NULL for 'filenames', in which case this
2304 * function will always return NULL.
2307 notmuch_filenames_get (notmuch_filenames_t *filenames);
2310 * Move the 'filenames' iterator to the next filename.
2312 * If 'filenames' is already pointing at the last filename then the
2313 * iterator will be moved to a point just beyond that last filename,
2314 * (where notmuch_filenames_valid will return FALSE and
2315 * notmuch_filenames_get will return NULL).
2317 * It is acceptable to pass NULL for 'filenames', in which case this
2318 * function will do nothing.
2321 notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
2324 * Destroy a notmuch_filenames_t object.
2326 * It's not strictly necessary to call this function. All memory from
2327 * the notmuch_filenames_t object will be reclaimed when the
2328 * containing directory object is destroyed.
2330 * It is acceptable to pass NULL for 'filenames', in which case this
2331 * function will do nothing.
2334 notmuch_filenames_destroy (notmuch_filenames_t *filenames);
2338 * set config 'key' to 'value'
2340 * @since libnotmuch 4.4 (notmuch 0.23)
2341 * @retval #NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
2342 * read-only mode so message cannot be modified.
2343 * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION: an exception was thrown
2344 * accessing the database.
2345 * @retval #NOTMUCH_STATUS_SUCCESS
2348 notmuch_database_set_config (notmuch_database_t *db, const char *key, const char *value);
2351 * retrieve config item 'key', assign to 'value'
2353 * keys which have not been previously set with n_d_set_config will
2354 * return an empty string.
2356 * return value is allocated by malloc and should be freed by the
2359 * @since libnotmuch 4.4 (notmuch 0.23)
2363 notmuch_database_get_config (notmuch_database_t *db, const char *key, char **value);
2366 * Create an iterator for all config items with keys matching a given prefix
2368 * @since libnotmuch 4.4 (notmuch 0.23)
2371 notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out);
2374 * Is 'config_list' iterator valid (i.e. _key, _value, _move_to_next can be called).
2376 * @since libnotmuch 4.4 (notmuch 0.23)
2379 notmuch_config_list_valid (notmuch_config_list_t *config_list);
2382 * return key for current config pair
2384 * return value is owned by the iterator, and will be destroyed by the
2385 * next call to notmuch_config_list_key or notmuch_config_list_destroy.
2387 * @since libnotmuch 4.4 (notmuch 0.23)
2390 notmuch_config_list_key (notmuch_config_list_t *config_list);
2393 * return 'value' for current config pair
2395 * return value is owned by the iterator, and will be destroyed by the
2396 * next call to notmuch_config_list_value or notmuch config_list_destroy
2398 * @since libnotmuch 4.4 (notmuch 0.23)
2399 * @retval NULL for errors
2402 notmuch_config_list_value (notmuch_config_list_t *config_list);
2406 * move 'config_list' iterator to the next pair
2408 * @since libnotmuch 4.4 (notmuch 0.23)
2411 notmuch_config_list_move_to_next (notmuch_config_list_t *config_list);
2414 * free any resources held by 'config_list'
2416 * @since libnotmuch 4.4 (notmuch 0.23)
2419 notmuch_config_list_destroy (notmuch_config_list_t *config_list);
2423 * Configuration keys known to libnotmuch
2425 typedef enum _notmuch_config_key {
2426 NOTMUCH_CONFIG_FIRST,
2427 NOTMUCH_CONFIG_DATABASE_PATH = NOTMUCH_CONFIG_FIRST,
2428 NOTMUCH_CONFIG_EXCLUDE_TAGS,
2429 NOTMUCH_CONFIG_NEW_TAGS,
2430 NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS,
2431 NOTMUCH_CONFIG_PRIMARY_EMAIL,
2432 NOTMUCH_CONFIG_OTHER_EMAIL,
2433 NOTMUCH_CONFIG_USER_NAME,
2435 } notmuch_config_key_t;
2438 * get a configuration value from an open database.
2440 * This value reflects all configuration information given at the time
2441 * the database was opened.
2443 * @param[in] notmuch database
2444 * @param[in] key configuration key
2446 * @since libnotmuch 5.4 (notmuch 0.32)
2448 * @retval NULL if 'key' unknown or if no value is known for
2449 * 'key'. Otherwise returns a string owned by notmuch which should
2450 * not be modified nor freed by the caller.
2453 notmuch_config_get (notmuch_database_t *notmuch, notmuch_config_key_t key);
2456 * set a configuration value from in an open database.
2458 * This value reflects all configuration information given at the time
2459 * the database was opened.
2461 * @param[in,out] notmuch database open read/write
2462 * @param[in] key configuration key
2463 * @param[in] val configuration value
2465 * @since libnotmuch 5.4 (notmuch 0.32)
2467 * @retval returns any return value for notmuch_database_set_config.
2470 notmuch_config_set (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val);
2473 * Returns an iterator for a ';'-delimited list of configuration values
2475 * These values reflect all configuration information given at the
2476 * time the database was opened.
2478 * @param[in] notmuch database
2479 * @param[in] key configuration key
2481 * @since libnotmuch 5.4 (notmuch 0.32)
2483 * @retval NULL in case of error.
2485 notmuch_config_values_t *
2486 notmuch_config_get_values (notmuch_database_t *notmuch, notmuch_config_key_t key);
2489 * Is the given 'config_values' iterator pointing at a valid element.
2491 * @param[in] values iterator
2493 * @since libnotmuch 5.4 (notmuch 0.32)
2495 * @retval FALSE if passed a NULL pointer, or the iterator is exhausted.
2499 notmuch_config_values_valid (notmuch_config_values_t *values);
2502 * Get the current value from the 'values' iterator
2504 * @param[in] values iterator
2506 * @since libnotmuch 5.4 (notmuch 0.32)
2508 * @retval a string with the same lifetime as the iterator
2511 notmuch_config_values_get (notmuch_config_values_t *values);
2514 * Move the 'values' iterator to the next element
2516 * @param[in,out] values iterator
2518 * @since libnotmuch 5.4 (notmuch 0.32)
2522 notmuch_config_values_move_to_next (notmuch_config_values_t *values);
2526 * reset the 'values' iterator to the first element
2528 * @param[in,out] values iterator. A NULL value is ignored.
2530 * @since libnotmuch 5.4 (notmuch 0.32)
2534 notmuch_config_values_start (notmuch_config_values_t *values);
2537 * Destroy a config values iterator, along with any associated
2540 * @param[in,out] values iterator
2542 * @since libnotmuch 5.4 (notmuch 0.32)
2545 notmuch_config_values_destroy (notmuch_config_values_t *values);
2548 * get a configuration value from an open database as Boolean
2550 * This value reflects all configuration information given at the time
2551 * the database was opened.
2553 * @param[in] notmuch database
2554 * @param[in] key configuration key
2555 * @param[out] val configuration value, converted to Boolean
2557 * @since libnotmuch 5.4 (notmuch 0.32)
2559 * @retval #NOTMUCH_STATUS_ILLEGAL_ARGUMENT if either key is unknown
2560 * or the corresponding value does not convert to Boolean.
2563 notmuch_config_get_bool (notmuch_database_t *notmuch,
2564 notmuch_config_key_t key,
2565 notmuch_bool_t *val);
2567 * get the current default indexing options for a given database.
2569 * This object will survive until the database itself is destroyed,
2570 * but the caller may also release it earlier with
2571 * notmuch_indexopts_destroy.
2573 * This object represents a set of options on how a message can be
2574 * added to the index. At the moment it is a featureless stub.
2576 * @since libnotmuch 5.1 (notmuch 0.26)
2577 * @retval NULL in case of error
2579 notmuch_indexopts_t *
2580 notmuch_database_get_default_indexopts (notmuch_database_t *db);
2583 * Stating a policy about how to decrypt messages.
2585 * See index.decrypt in notmuch-config(1) for more details.
2588 NOTMUCH_DECRYPT_FALSE,
2589 NOTMUCH_DECRYPT_TRUE,
2590 NOTMUCH_DECRYPT_AUTO,
2591 NOTMUCH_DECRYPT_NOSTASH,
2592 } notmuch_decryption_policy_t;
2595 * Specify whether to decrypt encrypted parts while indexing.
2597 * Be aware that the index is likely sufficient to reconstruct the
2598 * cleartext of the message itself, so please ensure that the notmuch
2599 * message index is adequately protected. DO NOT SET THIS FLAG TO TRUE
2600 * without considering the security of your index.
2602 * @since libnotmuch 5.1 (notmuch 0.26)
2605 notmuch_indexopts_set_decrypt_policy (notmuch_indexopts_t *indexopts,
2606 notmuch_decryption_policy_t decrypt_policy);
2609 * Return whether to decrypt encrypted parts while indexing.
2610 * see notmuch_indexopts_set_decrypt_policy.
2612 * @since libnotmuch 5.1 (notmuch 0.26)
2614 notmuch_decryption_policy_t
2615 notmuch_indexopts_get_decrypt_policy (const notmuch_indexopts_t *indexopts);
2618 * Destroy a notmuch_indexopts_t object.
2620 * @since libnotmuch 5.1 (notmuch 0.26)
2623 notmuch_indexopts_destroy (notmuch_indexopts_t *options);
2627 * interrogate the library for compile time features
2629 * @since libnotmuch 4.4 (notmuch 0.23)
2632 notmuch_built_with (const char *name);
2635 #pragma GCC visibility pop