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 * Destroy the notmuch database, closing it if necessary and freeing
502 * all associated resources.
504 * Return value as in notmuch_database_close if the database was open;
505 * notmuch_database_destroy itself has no failure modes.
508 notmuch_database_destroy (notmuch_database_t *database);
511 * Return the database path of the given database.
513 * The return value is a string owned by notmuch so should not be
514 * modified nor freed by the caller.
517 notmuch_database_get_path (notmuch_database_t *database);
520 * Return the database format version of the given database.
525 notmuch_database_get_version (notmuch_database_t *database);
528 * Can the database be upgraded to a newer database version?
530 * If this function returns TRUE, then the caller may call
531 * notmuch_database_upgrade to upgrade the database. If the caller
532 * does not upgrade an out-of-date database, then some functions may
533 * fail with NOTMUCH_STATUS_UPGRADE_REQUIRED. This always returns
534 * FALSE for a read-only database because there's no way to upgrade a
535 * read-only database.
537 * Also returns FALSE if an error occurs accessing the database.
541 notmuch_database_needs_upgrade (notmuch_database_t *database);
544 * Upgrade the current database to the latest supported version.
546 * This ensures that all current notmuch functionality will be
547 * available on the database. After opening a database in read-write
548 * mode, it is recommended that clients check if an upgrade is needed
549 * (notmuch_database_needs_upgrade) and if so, upgrade with this
550 * function before making any modifications. If
551 * notmuch_database_needs_upgrade returns FALSE, this will be a no-op.
553 * The optional progress_notify callback can be used by the caller to
554 * provide progress indication to the user. If non-NULL it will be
555 * called periodically with 'progress' as a floating-point value in
556 * the range of [0.0 .. 1.0] indicating the progress made so far in
557 * the upgrade process. The argument 'closure' is passed verbatim to
558 * any callback invoked.
561 notmuch_database_upgrade (notmuch_database_t *database,
562 void (*progress_notify)(void *closure,
567 * Begin an atomic database operation.
569 * Any modifications performed between a successful begin and a
570 * notmuch_database_end_atomic will be applied to the database
571 * atomically. Note that, unlike a typical database transaction, this
572 * only ensures atomicity, not durability; neither begin nor end
573 * necessarily flush modifications to disk.
575 * Atomic sections may be nested. begin_atomic and end_atomic must
576 * always be called in pairs.
580 * NOTMUCH_STATUS_SUCCESS: Successfully entered atomic section.
582 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
583 * atomic section not entered.
586 notmuch_database_begin_atomic (notmuch_database_t *notmuch);
589 * Indicate the end of an atomic database operation.
593 * NOTMUCH_STATUS_SUCCESS: Successfully completed atomic section.
595 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
596 * atomic section not ended.
598 * NOTMUCH_STATUS_UNBALANCED_ATOMIC: The database is not currently in
602 notmuch_database_end_atomic (notmuch_database_t *notmuch);
605 * Return the committed database revision and UUID.
607 * The database revision number increases monotonically with each
608 * commit to the database. Hence, all messages and message changes
609 * committed to the database (that is, visible to readers) have a last
610 * modification revision <= the committed database revision. Any
611 * messages committed in the future will be assigned a modification
612 * revision > the committed database revision.
614 * The UUID is a NUL-terminated opaque string that uniquely identifies
615 * this database. Two revision numbers are only comparable if they
616 * have the same database UUID.
619 notmuch_database_get_revision (notmuch_database_t *notmuch,
623 * Retrieve a directory object from the database for 'path'.
625 * Here, 'path' should be a path relative to the path of 'database'
626 * (see notmuch_database_get_path), or else should be an absolute path
627 * with initial components that match the path of 'database'.
629 * If this directory object does not exist in the database, this
630 * returns NOTMUCH_STATUS_SUCCESS and sets *directory to NULL.
632 * Otherwise the returned directory object is owned by the database
633 * and as such, will only be valid until notmuch_database_destroy is
638 * NOTMUCH_STATUS_SUCCESS: Successfully retrieved directory.
640 * NOTMUCH_STATUS_NULL_POINTER: The given 'directory' argument is NULL.
642 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
643 * directory not retrieved.
645 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
646 * database to use this function.
649 notmuch_database_get_directory (notmuch_database_t *database,
651 notmuch_directory_t **directory);
654 * Add a message file to a database, indexing it for retrieval by
655 * future searches. If a message already exists with the same message
656 * ID as the specified file, their indexes will be merged, and this
657 * new filename will also be associated with the existing message.
659 * Here, 'filename' should be a path relative to the path of
660 * 'database' (see notmuch_database_get_path), or else should be an
661 * absolute filename with initial components that match the path of
664 * The file should be a single mail message (not a multi-message mbox)
665 * that is expected to remain at its current location, (since the
666 * notmuch database will reference the filename, and will not copy the
667 * entire contents of the file.
669 * If another message with the same message ID already exists in the
670 * database, rather than creating a new message, this adds the search
671 * terms from the identified file to the existing message's index, and
672 * adds 'filename' to the list of filenames known for the message.
674 * The 'indexopts' parameter can be NULL (meaning, use the indexing
675 * defaults from the database), or can be an explicit choice of
676 * indexing options that should govern the indexing of this specific
679 * If 'message' is not NULL, then, on successful return
680 * (NOTMUCH_STATUS_SUCCESS or NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) '*message'
681 * will be initialized to a message object that can be used for things
682 * such as adding tags to the just-added message. The user should call
683 * notmuch_message_destroy when done with the message. On any failure
684 * '*message' will be set to NULL.
688 * NOTMUCH_STATUS_SUCCESS: Message successfully added to database.
690 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
693 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: Message has the same message
694 * ID as another message already in the database. The new
695 * filename was successfully added to the message in the database
696 * (if not already present) and the existing message is returned.
698 * NOTMUCH_STATUS_FILE_ERROR: an error occurred trying to open the
699 * file, (such as permission denied, or file not found,
700 * etc.). Nothing added to the database.
702 * NOTMUCH_STATUS_FILE_NOT_EMAIL: the contents of filename don't look
703 * like an email message. Nothing added to the database.
705 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
706 * mode so no message can be added.
708 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
709 * database to use this function.
711 * @since libnotmuch 5.1 (notmuch 0.26)
714 notmuch_database_index_file (notmuch_database_t *database,
715 const char *filename,
716 notmuch_indexopts_t *indexopts,
717 notmuch_message_t **message);
720 * Deprecated alias for notmuch_database_index_file called with
723 * @deprecated Deprecated as of libnotmuch 5.1 (notmuch 0.26). Please
724 * use notmuch_database_index_file instead.
727 NOTMUCH_DEPRECATED (5, 1)
729 notmuch_database_add_message (notmuch_database_t *database,
730 const char *filename,
731 notmuch_message_t **message);
734 * Remove a message filename from the given notmuch database. If the
735 * message has no more filenames, remove the message.
737 * If the same message (as determined by the message ID) is still
738 * available via other filenames, then the message will persist in the
739 * database for those filenames. When the last filename is removed for
740 * a particular message, the database content for that message will be
745 * NOTMUCH_STATUS_SUCCESS: The last filename was removed and the
746 * message was removed from the database.
748 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
749 * message not removed.
751 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: This filename was removed but
752 * the message persists in the database with at least one other
755 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
756 * mode so no message can be removed.
758 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
759 * database to use this function.
762 notmuch_database_remove_message (notmuch_database_t *database,
763 const char *filename);
766 * Find a message with the given message_id.
768 * If a message with the given message_id is found then, on successful return
769 * (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to a message
770 * object. The caller should call notmuch_message_destroy when done with the
773 * On any failure or when the message is not found, this function initializes
774 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
775 * caller is supposed to check '*message' for NULL to find out whether the
776 * message with the given message_id was found.
780 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'.
782 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
784 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating message object
786 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
789 notmuch_database_find_message (notmuch_database_t *database,
790 const char *message_id,
791 notmuch_message_t **message);
794 * Find a message with the given filename.
796 * If the database contains a message with the given filename then, on
797 * successful return (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to
798 * a message object. The caller should call notmuch_message_destroy when done
801 * On any failure or when the message is not found, this function initializes
802 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
803 * caller is supposed to check '*message' for NULL to find out whether the
804 * message with the given filename is found.
808 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'
810 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
812 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating the message object
814 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
816 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
817 * database to use this function.
820 notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
821 const char *filename,
822 notmuch_message_t **message);
825 * Return a list of all tags found in the database.
827 * This function creates a list of all tags found in the database. The
828 * resulting list contains all tags from all messages found in the database.
830 * On error this function returns NULL.
833 notmuch_database_get_all_tags (notmuch_database_t *db);
836 * Create a new query for 'database'.
838 * Here, 'database' should be an open database, (see
839 * notmuch_database_open and notmuch_database_create).
841 * For the query string, we'll document the syntax here more
842 * completely in the future, but it's likely to be a specialized
843 * version of the general Xapian query syntax:
845 * https://xapian.org/docs/queryparser.html
847 * As a special case, passing either a length-zero string, (that is ""),
848 * or a string consisting of a single asterisk (that is "*"), will
849 * result in a query that returns all messages in the database.
851 * See notmuch_query_set_sort for controlling the order of results.
852 * See notmuch_query_search_messages and notmuch_query_search_threads
853 * to actually execute the query.
855 * User should call notmuch_query_destroy when finished with this
858 * Will return NULL if insufficient memory is available.
861 notmuch_query_create (notmuch_database_t *database,
862 const char *query_string);
865 * Sort values for notmuch_query_set_sort.
871 NOTMUCH_SORT_OLDEST_FIRST,
875 NOTMUCH_SORT_NEWEST_FIRST,
877 * Sort by message-id.
879 NOTMUCH_SORT_MESSAGE_ID,
883 NOTMUCH_SORT_UNSORTED
887 * Return the query_string of this query. See notmuch_query_create.
890 notmuch_query_get_query_string (const notmuch_query_t *query);
893 * Return the notmuch database of this query. See notmuch_query_create.
896 notmuch_query_get_database (const notmuch_query_t *query);
899 * Exclude values for notmuch_query_set_omit_excluded. The strange
900 * order is to maintain backward compatibility: the old FALSE/TRUE
901 * options correspond to the new
902 * NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options.
905 NOTMUCH_EXCLUDE_FLAG,
906 NOTMUCH_EXCLUDE_TRUE,
907 NOTMUCH_EXCLUDE_FALSE,
912 * Specify whether to omit excluded results or simply flag them. By
913 * default, this is set to TRUE.
915 * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded
916 * messages from the results, and notmuch_query_search_threads will omit
917 * threads that match only in excluded messages. If set to TRUE,
918 * notmuch_query_search_threads will include all messages in threads that
919 * match in at least one non-excluded message. Otherwise, if set to ALL,
920 * notmuch_query_search_threads will omit excluded messages from all threads.
922 * If set to FALSE or FLAG then both notmuch_query_search_messages and
923 * notmuch_query_search_threads will return all matching
924 * messages/threads regardless of exclude status. If set to FLAG then
925 * the exclude flag will be set for any excluded message that is
926 * returned by notmuch_query_search_messages, and the thread counts
927 * for threads returned by notmuch_query_search_threads will be the
928 * number of non-excluded messages/matches. Otherwise, if set to
929 * FALSE, then the exclude status is completely ignored.
931 * The performance difference when calling
932 * notmuch_query_search_messages should be relatively small (and both
933 * should be very fast). However, in some cases,
934 * notmuch_query_search_threads is very much faster when omitting
935 * excluded messages as it does not need to construct the threads that
936 * only match in excluded messages.
939 notmuch_query_set_omit_excluded (notmuch_query_t *query,
940 notmuch_exclude_t omit_excluded);
943 * Specify the sorting desired for this query.
946 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
949 * Return the sort specified for this query. See
950 * notmuch_query_set_sort.
953 notmuch_query_get_sort (const notmuch_query_t *query);
956 * Add a tag that will be excluded from the query results by default.
957 * This exclusion will be ignored if this tag appears explicitly in
962 * NOTMUCH_STATUS_SUCCESS: excluded was added successfully.
964 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occurred.
965 * Most likely a problem lazily parsing the query string.
967 * NOTMUCH_STATUS_IGNORED: tag is explicitly present in the query, so
971 notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
974 * Execute a query for threads, returning a notmuch_threads_t object
975 * which can be used to iterate over the results. The returned threads
976 * object is owned by the query and as such, will only be valid until
977 * notmuch_query_destroy.
979 * Typical usage might be:
981 * notmuch_query_t *query;
982 * notmuch_threads_t *threads;
983 * notmuch_thread_t *thread;
984 * notmuch_status_t stat;
986 * query = notmuch_query_create (database, query_string);
988 * for (stat = notmuch_query_search_threads (query, &threads);
989 * stat == NOTMUCH_STATUS_SUCCESS &&
990 * notmuch_threads_valid (threads);
991 * notmuch_threads_move_to_next (threads))
993 * thread = notmuch_threads_get (threads);
995 * notmuch_thread_destroy (thread);
998 * notmuch_query_destroy (query);
1000 * Note: If you are finished with a thread before its containing
1001 * query, you can call notmuch_thread_destroy to clean up some memory
1002 * sooner (as in the above example). Otherwise, if your thread objects
1003 * are long-lived, then you don't need to call notmuch_thread_destroy
1004 * and all the memory will still be reclaimed when the query is
1007 * Note that there's no explicit destructor needed for the
1008 * notmuch_threads_t object. (For consistency, we do provide a
1009 * notmuch_threads_destroy function, but there's no good reason
1010 * to call it if the query is about to be destroyed).
1012 * @since libnotmuch 5.0 (notmuch 0.25)
1015 notmuch_query_search_threads (notmuch_query_t *query,
1016 notmuch_threads_t **out);
1019 * Deprecated alias for notmuch_query_search_threads.
1021 * @deprecated Deprecated as of libnotmuch 5 (notmuch 0.25). Please
1022 * use notmuch_query_search_threads instead.
1025 NOTMUCH_DEPRECATED (5, 0)
1027 notmuch_query_search_threads_st (notmuch_query_t *query, notmuch_threads_t **out);
1030 * Execute a query for messages, returning a notmuch_messages_t object
1031 * which can be used to iterate over the results. The returned
1032 * messages object is owned by the query and as such, will only be
1033 * valid until notmuch_query_destroy.
1035 * Typical usage might be:
1037 * notmuch_query_t *query;
1038 * notmuch_messages_t *messages;
1039 * notmuch_message_t *message;
1041 * query = notmuch_query_create (database, query_string);
1043 * for (messages = notmuch_query_search_messages (query);
1044 * notmuch_messages_valid (messages);
1045 * notmuch_messages_move_to_next (messages))
1047 * message = notmuch_messages_get (messages);
1049 * notmuch_message_destroy (message);
1052 * notmuch_query_destroy (query);
1054 * Note: If you are finished with a message before its containing
1055 * query, you can call notmuch_message_destroy to clean up some memory
1056 * sooner (as in the above example). Otherwise, if your message
1057 * objects are long-lived, then you don't need to call
1058 * notmuch_message_destroy and all the memory will still be reclaimed
1059 * when the query is destroyed.
1061 * Note that there's no explicit destructor needed for the
1062 * notmuch_messages_t object. (For consistency, we do provide a
1063 * notmuch_messages_destroy function, but there's no good
1064 * reason to call it if the query is about to be destroyed).
1066 * If a Xapian exception occurs this function will return NULL.
1068 * @since libnotmuch 5 (notmuch 0.25)
1071 notmuch_query_search_messages (notmuch_query_t *query,
1072 notmuch_messages_t **out);
1074 * Deprecated alias for notmuch_query_search_messages
1076 * @deprecated Deprecated as of libnotmuch 5 (notmuch 0.25). Please use
1077 * notmuch_query_search_messages instead.
1081 NOTMUCH_DEPRECATED (5, 0)
1083 notmuch_query_search_messages_st (notmuch_query_t *query,
1084 notmuch_messages_t **out);
1087 * Destroy a notmuch_query_t along with any associated resources.
1089 * This will in turn destroy any notmuch_threads_t and
1090 * notmuch_messages_t objects generated by this query, (and in
1091 * turn any notmuch_thread_t and notmuch_message_t objects generated
1092 * from those results, etc.), if such objects haven't already been
1096 notmuch_query_destroy (notmuch_query_t *query);
1099 * Is the given 'threads' iterator pointing at a valid thread.
1101 * When this function returns TRUE, notmuch_threads_get will return a
1102 * valid object. Whereas when this function returns FALSE,
1103 * notmuch_threads_get will return NULL.
1105 * If passed a NULL pointer, this function returns FALSE
1107 * See the documentation of notmuch_query_search_threads for example
1108 * code showing how to iterate over a notmuch_threads_t object.
1111 notmuch_threads_valid (notmuch_threads_t *threads);
1114 * Get the current thread from 'threads' as a notmuch_thread_t.
1116 * Note: The returned thread belongs to 'threads' and has a lifetime
1117 * identical to it (and the query to which it belongs).
1119 * See the documentation of notmuch_query_search_threads for example
1120 * code showing how to iterate over a notmuch_threads_t object.
1122 * If an out-of-memory situation occurs, this function will return
1126 notmuch_threads_get (notmuch_threads_t *threads);
1129 * Move the 'threads' iterator to the next thread.
1131 * If 'threads' is already pointing at the last thread then the
1132 * iterator will be moved to a point just beyond that last thread,
1133 * (where notmuch_threads_valid will return FALSE and
1134 * notmuch_threads_get will return NULL).
1136 * See the documentation of notmuch_query_search_threads for example
1137 * code showing how to iterate over a notmuch_threads_t object.
1140 notmuch_threads_move_to_next (notmuch_threads_t *threads);
1143 * Destroy a notmuch_threads_t object.
1145 * It's not strictly necessary to call this function. All memory from
1146 * the notmuch_threads_t object will be reclaimed when the
1147 * containing query object is destroyed.
1150 notmuch_threads_destroy (notmuch_threads_t *threads);
1153 * Return the number of messages matching a search.
1155 * This function performs a search and returns the number of matching
1160 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1162 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occurred. The
1163 * value of *count is not defined.
1165 * @since libnotmuch 5 (notmuch 0.25)
1168 notmuch_query_count_messages (notmuch_query_t *query, unsigned int *count);
1171 * Deprecated alias for notmuch_query_count_messages
1174 * @deprecated Deprecated since libnotmuch 5.0 (notmuch 0.25). Please
1175 * use notmuch_query_count_messages instead.
1177 NOTMUCH_DEPRECATED (5, 0)
1179 notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
1182 * Return the number of threads matching a search.
1184 * This function performs a search and returns the number of unique thread IDs
1185 * in the matching messages. This is the same as number of threads matching a
1188 * Note that this is a significantly heavier operation than
1189 * notmuch_query_count_messages{_st}().
1193 * NOTMUCH_STATUS_OUT_OF_MEMORY: Memory allocation failed. The value
1194 * of *count is not defined
1196 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1198 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occurred. The
1199 * value of *count is not defined.
1201 * @since libnotmuch 5 (notmuch 0.25)
1204 notmuch_query_count_threads (notmuch_query_t *query, unsigned *count);
1207 * Deprecated alias for notmuch_query_count_threads
1209 * @deprecated Deprecated as of libnotmuch 5.0 (notmuch 0.25). Please
1210 * use notmuch_query_count_threads_st instead.
1212 NOTMUCH_DEPRECATED (5, 0)
1214 notmuch_query_count_threads_st (notmuch_query_t *query, unsigned *count);
1217 * Get the thread ID of 'thread'.
1219 * The returned string belongs to 'thread' and as such, should not be
1220 * modified by the caller and will only be valid for as long as the
1221 * thread is valid, (which is until notmuch_thread_destroy or until
1222 * the query from which it derived is destroyed).
1225 notmuch_thread_get_thread_id (notmuch_thread_t *thread);
1228 * Get the total number of messages in 'thread'.
1230 * This count consists of all messages in the database belonging to
1231 * this thread. Contrast with notmuch_thread_get_matched_messages() .
1234 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
1237 * Get the total number of files in 'thread'.
1239 * This sums notmuch_message_count_files over all messages in the
1241 * @returns Non-negative integer
1242 * @since libnotmuch 5.0 (notmuch 0.25)
1246 notmuch_thread_get_total_files (notmuch_thread_t *thread);
1249 * Get a notmuch_messages_t iterator for the top-level messages in
1250 * 'thread' in oldest-first order.
1252 * This iterator will not necessarily iterate over all of the messages
1253 * in the thread. It will only iterate over the messages in the thread
1254 * which are not replies to other messages in the thread.
1256 * The returned list will be destroyed when the thread is destroyed.
1258 notmuch_messages_t *
1259 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
1262 * Get a notmuch_thread_t iterator for all messages in 'thread' in
1263 * oldest-first order.
1265 * The returned list will be destroyed when the thread is destroyed.
1267 notmuch_messages_t *
1268 notmuch_thread_get_messages (notmuch_thread_t *thread);
1271 * Get the number of messages in 'thread' that matched the search.
1273 * This count includes only the messages in this thread that were
1274 * matched by the search from which the thread was created and were
1275 * not excluded by any exclude tags passed in with the query (see
1276 * notmuch_query_add_tag_exclude). Contrast with
1277 * notmuch_thread_get_total_messages() .
1280 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
1283 * Get the authors of 'thread' as a UTF-8 string.
1285 * The returned string is a comma-separated list of the names of the
1286 * authors of mail messages in the query results that belong to this
1289 * The string contains authors of messages matching the query first, then
1290 * non-matched authors (with the two groups separated by '|'). Within
1291 * each group, authors are ordered by date.
1293 * The returned string belongs to 'thread' and as such, should not be
1294 * modified by the caller and will only be valid for as long as the
1295 * thread is valid, (which is until notmuch_thread_destroy or until
1296 * the query from which it derived is destroyed).
1299 notmuch_thread_get_authors (notmuch_thread_t *thread);
1302 * Get the subject of 'thread' as a UTF-8 string.
1304 * The subject is taken from the first message (according to the query
1305 * order---see notmuch_query_set_sort) in the query results that
1306 * belongs to this thread.
1308 * The returned string belongs to 'thread' and as such, should not be
1309 * modified by the caller and will only be valid for as long as the
1310 * thread is valid, (which is until notmuch_thread_destroy or until
1311 * the query from which it derived is destroyed).
1314 notmuch_thread_get_subject (notmuch_thread_t *thread);
1317 * Get the date of the oldest message in 'thread' as a time_t value.
1320 notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
1323 * Get the date of the newest message in 'thread' as a time_t value.
1326 notmuch_thread_get_newest_date (notmuch_thread_t *thread);
1329 * Get the tags for 'thread', returning a notmuch_tags_t object which
1330 * can be used to iterate over all tags.
1332 * Note: In the Notmuch database, tags are stored on individual
1333 * messages, not on threads. So the tags returned here will be all
1334 * tags of the messages which matched the search and which belong to
1337 * The tags object is owned by the thread and as such, will only be
1338 * valid for as long as the thread is valid, (for example, until
1339 * notmuch_thread_destroy or until the query from which it derived is
1342 * Typical usage might be:
1344 * notmuch_thread_t *thread;
1345 * notmuch_tags_t *tags;
1348 * thread = notmuch_threads_get (threads);
1350 * for (tags = notmuch_thread_get_tags (thread);
1351 * notmuch_tags_valid (tags);
1352 * notmuch_tags_move_to_next (tags))
1354 * tag = notmuch_tags_get (tags);
1358 * notmuch_thread_destroy (thread);
1360 * Note that there's no explicit destructor needed for the
1361 * notmuch_tags_t object. (For consistency, we do provide a
1362 * notmuch_tags_destroy function, but there's no good reason to call
1363 * it if the message is about to be destroyed).
1366 notmuch_thread_get_tags (notmuch_thread_t *thread);
1369 * Destroy a notmuch_thread_t object.
1372 notmuch_thread_destroy (notmuch_thread_t *thread);
1375 * Is the given 'messages' iterator pointing at a valid message.
1377 * When this function returns TRUE, notmuch_messages_get will return a
1378 * valid object. Whereas when this function returns FALSE,
1379 * notmuch_messages_get will return NULL.
1381 * See the documentation of notmuch_query_search_messages for example
1382 * code showing how to iterate over a notmuch_messages_t object.
1385 notmuch_messages_valid (notmuch_messages_t *messages);
1388 * Get the current message from 'messages' as a notmuch_message_t.
1390 * Note: The returned message belongs to 'messages' and has a lifetime
1391 * identical to it (and the query to which it belongs).
1393 * See the documentation of notmuch_query_search_messages for example
1394 * code showing how to iterate over a notmuch_messages_t object.
1396 * If an out-of-memory situation occurs, this function will return
1400 notmuch_messages_get (notmuch_messages_t *messages);
1403 * Move the 'messages' iterator to the next message.
1405 * If 'messages' is already pointing at the last message then the
1406 * iterator will be moved to a point just beyond that last message,
1407 * (where notmuch_messages_valid will return FALSE and
1408 * notmuch_messages_get will return NULL).
1410 * See the documentation of notmuch_query_search_messages for example
1411 * code showing how to iterate over a notmuch_messages_t object.
1414 notmuch_messages_move_to_next (notmuch_messages_t *messages);
1417 * Destroy a notmuch_messages_t object.
1419 * It's not strictly necessary to call this function. All memory from
1420 * the notmuch_messages_t object will be reclaimed when the containing
1421 * query object is destroyed.
1424 notmuch_messages_destroy (notmuch_messages_t *messages);
1427 * Return a list of tags from all messages.
1429 * The resulting list is guaranteed not to contain duplicated tags.
1431 * WARNING: You can no longer iterate over messages after calling this
1432 * function, because the iterator will point at the end of the list.
1433 * We do not have a function to reset the iterator yet and the only
1434 * way how you can iterate over the list again is to recreate the
1437 * The function returns NULL on error.
1440 notmuch_messages_collect_tags (notmuch_messages_t *messages);
1443 * Get the database associated with this message.
1445 * @since libnotmuch 5.2 (notmuch 0.27)
1447 notmuch_database_t *
1448 notmuch_message_get_database (const notmuch_message_t *message);
1451 * Get the message ID of 'message'.
1453 * The returned string belongs to 'message' and as such, should not be
1454 * modified by the caller and will only be valid for as long as the
1455 * message is valid, (which is until the query from which it derived
1458 * This function will return NULL if triggers an unhandled Xapian
1462 notmuch_message_get_message_id (notmuch_message_t *message);
1465 * Get the thread ID of 'message'.
1467 * The returned string belongs to 'message' and as such, should not be
1468 * modified by the caller and will only be valid for as long as the
1469 * message is valid, (for example, until the user calls
1470 * notmuch_message_destroy on 'message' or until a query from which it
1471 * derived is destroyed).
1473 * This function will return NULL if triggers an unhandled Xapian
1477 notmuch_message_get_thread_id (notmuch_message_t *message);
1480 * Get a notmuch_messages_t iterator for all of the replies to
1483 * Note: This call only makes sense if 'message' was ultimately
1484 * obtained from a notmuch_thread_t object, (such as by coming
1485 * directly from the result of calling notmuch_thread_get_
1486 * toplevel_messages or by any number of subsequent
1487 * calls to notmuch_message_get_replies).
1489 * If 'message' was obtained through some non-thread means, (such as
1490 * by a call to notmuch_query_search_messages), then this function
1493 * If there are no replies to 'message', this function will return
1494 * NULL. (Note that notmuch_messages_valid will accept that NULL
1495 * value as legitimate, and simply return FALSE for it.)
1497 * This function also returns NULL if it triggers a Xapian exception.
1499 * The returned list will be destroyed when the thread is
1502 notmuch_messages_t *
1503 notmuch_message_get_replies (notmuch_message_t *message);
1506 * Get the total number of files associated with a message.
1507 * @returns Non-negative integer for file count.
1508 * @returns Negative integer for error.
1509 * @since libnotmuch 5.0 (notmuch 0.25)
1512 notmuch_message_count_files (notmuch_message_t *message);
1515 * Get a filename for the email corresponding to 'message'.
1517 * The returned filename is an absolute filename, (the initial
1518 * component will match notmuch_database_get_path() ).
1520 * The returned string belongs to the message so should not be
1521 * modified or freed by the caller (nor should it be referenced after
1522 * the message is destroyed).
1524 * Note: If this message corresponds to multiple files in the mail
1525 * store, (that is, multiple files contain identical message IDs),
1526 * this function will arbitrarily return a single one of those
1527 * filenames. See notmuch_message_get_filenames for returning the
1528 * complete list of filenames.
1530 * This function returns NULL if it triggers a Xapian exception.
1533 notmuch_message_get_filename (notmuch_message_t *message);
1536 * Get all filenames for the email corresponding to 'message'.
1538 * Returns a notmuch_filenames_t iterator listing all the filenames
1539 * associated with 'message'. These files may not have identical
1540 * content, but each will have the identical Message-ID.
1542 * Each filename in the iterator is an absolute filename, (the initial
1543 * component will match notmuch_database_get_path() ).
1545 * This function returns NULL if it triggers a Xapian exception.
1547 notmuch_filenames_t *
1548 notmuch_message_get_filenames (notmuch_message_t *message);
1551 * Re-index the e-mail corresponding to 'message' using the supplied index options
1553 * Returns the status of the re-index operation. (see the return
1554 * codes documented in notmuch_database_index_file)
1556 * After reindexing, the user should discard the message object passed
1557 * in here by calling notmuch_message_destroy, since it refers to the
1558 * original message, not to the reindexed message.
1561 notmuch_message_reindex (notmuch_message_t *message,
1562 notmuch_indexopts_t *indexopts);
1567 typedef enum _notmuch_message_flag {
1568 NOTMUCH_MESSAGE_FLAG_MATCH,
1569 NOTMUCH_MESSAGE_FLAG_EXCLUDED,
1571 /* This message is a "ghost message", meaning it has no filenames
1572 * or content, but we know it exists because it was referenced by
1573 * some other message. A ghost message has only a message ID and
1576 NOTMUCH_MESSAGE_FLAG_GHOST,
1577 } notmuch_message_flag_t;
1580 * Get a value of a flag for the email corresponding to 'message'.
1582 * returns FALSE in case of errors.
1584 * @deprecated Deprecated as of libnotmuch 5.3 (notmuch 0.31). Please
1585 * use notmuch_message_get_flag_st instead.
1587 NOTMUCH_DEPRECATED(5,3)
1589 notmuch_message_get_flag (notmuch_message_t *message,
1590 notmuch_message_flag_t flag);
1593 * Get a value of a flag for the email corresponding to 'message'.
1595 * @param message a message object
1596 * @param flag flag to check
1597 * @param is_set pointer to boolean to store flag value.
1599 * @retval #NOTMUCH_STATUS_SUCCESS
1600 * @retval #NOTMUCH_STATUS_NULL_POINTER is_set is NULL
1601 * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION Accessing the database
1602 * triggered an exception.
1604 * @since libnotmuch 5.3 (notmuch 0.31)
1607 notmuch_message_get_flag_st (notmuch_message_t *message,
1608 notmuch_message_flag_t flag,
1609 notmuch_bool_t *is_set);
1612 * Set a value of a flag for the email corresponding to 'message'.
1615 notmuch_message_set_flag (notmuch_message_t *message,
1616 notmuch_message_flag_t flag, notmuch_bool_t value);
1619 * Get the date of 'message' as a time_t value.
1621 * For the original textual representation of the Date header from the
1622 * message call notmuch_message_get_header() with a header value of
1625 * Returns 0 in case of error.
1628 notmuch_message_get_date (notmuch_message_t *message);
1631 * Get the value of the specified header from 'message' as a UTF-8 string.
1633 * Common headers are stored in the database when the message is
1634 * indexed and will be returned from the database. Other headers will
1635 * be read from the actual message file.
1637 * The header name is case insensitive.
1639 * The returned string belongs to the message so should not be
1640 * modified or freed by the caller (nor should it be referenced after
1641 * the message is destroyed).
1643 * Returns an empty string ("") if the message does not contain a
1644 * header line matching 'header'. Returns NULL if any error occurs.
1647 notmuch_message_get_header (notmuch_message_t *message, const char *header);
1650 * Get the tags for 'message', returning a notmuch_tags_t object which
1651 * can be used to iterate over all tags.
1653 * The tags object is owned by the message and as such, will only be
1654 * valid for as long as the message is valid, (which is until the
1655 * query from which it derived is destroyed).
1657 * Typical usage might be:
1659 * notmuch_message_t *message;
1660 * notmuch_tags_t *tags;
1663 * message = notmuch_database_find_message (database, message_id);
1665 * for (tags = notmuch_message_get_tags (message);
1666 * notmuch_tags_valid (tags);
1667 * notmuch_tags_move_to_next (tags))
1669 * tag = notmuch_tags_get (tags);
1673 * notmuch_message_destroy (message);
1675 * Note that there's no explicit destructor needed for the
1676 * notmuch_tags_t object. (For consistency, we do provide a
1677 * notmuch_tags_destroy function, but there's no good reason to call
1678 * it if the message is about to be destroyed).
1681 notmuch_message_get_tags (notmuch_message_t *message);
1684 * The longest possible tag value.
1686 #define NOTMUCH_TAG_MAX 200
1689 * Add a tag to the given message.
1693 * NOTMUCH_STATUS_SUCCESS: Tag successfully added to message
1695 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1697 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1698 * (exceeds NOTMUCH_TAG_MAX)
1700 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1701 * mode so message cannot be modified.
1704 notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
1707 * Remove a tag from the given message.
1711 * NOTMUCH_STATUS_SUCCESS: Tag successfully removed from message
1713 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1715 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1716 * (exceeds NOTMUCH_TAG_MAX)
1718 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1719 * mode so message cannot be modified.
1722 notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
1725 * Remove all tags from the given message.
1727 * See notmuch_message_freeze for an example showing how to safely
1728 * replace tag values.
1730 * @retval #NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
1731 * read-only mode so message cannot be modified.
1732 * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION: an exception was thrown
1733 * accessing the database.
1736 notmuch_message_remove_all_tags (notmuch_message_t *message);
1739 * Add/remove tags according to maildir flags in the message filename(s).
1741 * This function examines the filenames of 'message' for maildir
1742 * flags, and adds or removes tags on 'message' as follows when these
1743 * flags are present:
1745 * Flag Action if present
1746 * ---- -----------------
1747 * 'D' Adds the "draft" tag to the message
1748 * 'F' Adds the "flagged" tag to the message
1749 * 'P' Adds the "passed" tag to the message
1750 * 'R' Adds the "replied" tag to the message
1751 * 'S' Removes the "unread" tag from the message
1753 * For each flag that is not present, the opposite action (add/remove)
1754 * is performed for the corresponding tags.
1756 * Flags are identified as trailing components of the filename after a
1757 * sequence of ":2,".
1759 * If there are multiple filenames associated with this message, the
1760 * flag is considered present if it appears in one or more
1761 * filenames. (That is, the flags from the multiple filenames are
1762 * combined with the logical OR operator.)
1764 * A client can ensure that notmuch database tags remain synchronized
1765 * with maildir flags by calling this function after each call to
1766 * notmuch_database_index_file. See also
1767 * notmuch_message_tags_to_maildir_flags for synchronizing tag changes
1768 * back to maildir flags.
1771 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
1774 * return TRUE if any filename of 'message' has maildir flag 'flag',
1777 * Deprecated wrapper for notmuch_message_has_maildir_flag_st
1779 * @returns FALSE in case of error
1780 * @deprecated libnotmuch 5.3 (notmuch 0.31)
1782 NOTMUCH_DEPRECATED(5, 3)
1784 notmuch_message_has_maildir_flag (notmuch_message_t *message, char flag);
1787 * check message for maildir flag
1789 * @param [in,out] message message to check
1790 * @param [in] flag flag to check for
1791 * @param [out] is_set pointer to boolean
1793 * @retval #NOTMUCH_STATUS_SUCCESS
1794 * @retval #NOTMUCH_STATUS_NULL_POINTER is_set is NULL
1795 * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION Accessing the database
1796 * triggered an exception.
1799 notmuch_message_has_maildir_flag_st (notmuch_message_t *message,
1801 notmuch_bool_t *is_set);
1804 * Rename message filename(s) to encode tags as maildir flags.
1806 * Specifically, for each filename corresponding to this message:
1808 * If the filename is not in a maildir directory, do nothing. (A
1809 * maildir directory is determined as a directory named "new" or
1810 * "cur".) Similarly, if the filename has invalid maildir info,
1811 * (repeated or outof-ASCII-order flag characters after ":2,"), then
1814 * If the filename is in a maildir directory, rename the file so that
1815 * its filename ends with the sequence ":2," followed by zero or more
1816 * of the following single-character flags (in ASCII order):
1818 * * flag 'D' iff the message has the "draft" tag
1819 * * flag 'F' iff the message has the "flagged" tag
1820 * * flag 'P' iff the message has the "passed" tag
1821 * * flag 'R' iff the message has the "replied" tag
1822 * * flag 'S' iff the message does not have the "unread" tag
1824 * Any existing flags unmentioned in the list above will be preserved
1827 * Also, if this filename is in a directory named "new", rename it to
1828 * be within the neighboring directory named "cur".
1830 * A client can ensure that maildir filename flags remain synchronized
1831 * with notmuch database tags by calling this function after changing
1832 * tags, (after calls to notmuch_message_add_tag,
1833 * notmuch_message_remove_tag, or notmuch_message_freeze/
1834 * notmuch_message_thaw). See also notmuch_message_maildir_flags_to_tags
1835 * for synchronizing maildir flag changes back to tags.
1838 notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
1841 * Freeze the current state of 'message' within the database.
1843 * This means that changes to the message state, (via
1844 * notmuch_message_add_tag, notmuch_message_remove_tag, and
1845 * notmuch_message_remove_all_tags), will not be committed to the
1846 * database until the message is thawed with notmuch_message_thaw.
1848 * Multiple calls to freeze/thaw are valid and these calls will
1849 * "stack". That is there must be as many calls to thaw as to freeze
1850 * before a message is actually thawed.
1852 * The ability to do freeze/thaw allows for safe transactions to
1853 * change tag values. For example, explicitly setting a message to
1854 * have a given set of tags might look like this:
1856 * notmuch_message_freeze (message);
1858 * notmuch_message_remove_all_tags (message);
1860 * for (i = 0; i < NUM_TAGS; i++)
1861 * notmuch_message_add_tag (message, tags[i]);
1863 * notmuch_message_thaw (message);
1865 * With freeze/thaw used like this, the message in the database is
1866 * guaranteed to have either the full set of original tag values, or
1867 * the full set of new tag values, but nothing in between.
1869 * Imagine the example above without freeze/thaw and the operation
1870 * somehow getting interrupted. This could result in the message being
1871 * left with no tags if the interruption happened after
1872 * notmuch_message_remove_all_tags but before notmuch_message_add_tag.
1876 * NOTMUCH_STATUS_SUCCESS: Message successfully frozen.
1878 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1879 * mode so message cannot be modified.
1882 notmuch_message_freeze (notmuch_message_t *message);
1885 * Thaw the current 'message', synchronizing any changes that may have
1886 * occurred while 'message' was frozen into the notmuch database.
1888 * See notmuch_message_freeze for an example of how to use this
1889 * function to safely provide tag changes.
1891 * Multiple calls to freeze/thaw are valid and these calls with
1892 * "stack". That is there must be as many calls to thaw as to freeze
1893 * before a message is actually thawed.
1897 * NOTMUCH_STATUS_SUCCESS: Message successfully thawed, (or at least
1898 * its frozen count has successfully been reduced by 1).
1900 * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: An attempt was made to thaw
1901 * an unfrozen message. That is, there have been an unbalanced
1902 * number of calls to notmuch_message_freeze and
1903 * notmuch_message_thaw.
1906 notmuch_message_thaw (notmuch_message_t *message);
1909 * Destroy a notmuch_message_t object.
1911 * It can be useful to call this function in the case of a single
1912 * query object with many messages in the result, (such as iterating
1913 * over the entire database). Otherwise, it's fine to never call this
1914 * function and there will still be no memory leaks. (The memory from
1915 * the messages get reclaimed when the containing query is destroyed.)
1918 notmuch_message_destroy (notmuch_message_t *message);
1921 * @name Message Properties
1923 * This interface provides the ability to attach arbitrary (key,value)
1924 * string pairs to a message, to remove such pairs, and to iterate
1925 * over them. The caller should take some care as to what keys they
1926 * add or delete values for, as other subsystems or extensions may
1927 * depend on these properties.
1929 * Please see notmuch-properties(7) for more details about specific
1930 * properties and conventions around their use.
1935 * Retrieve the value for a single property key
1937 * *value* is set to a string owned by the message or NULL if there is
1938 * no such key. In the case of multiple values for the given key, the
1939 * first one is retrieved.
1942 * - NOTMUCH_STATUS_NULL_POINTER: *value* may not be NULL.
1943 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
1944 * @since libnotmuch 4.4 (notmuch 0.23)
1947 notmuch_message_get_property (notmuch_message_t *message, const char *key, const char **value);
1950 * Add a (key,value) pair to a message
1953 * - NOTMUCH_STATUS_ILLEGAL_ARGUMENT: *key* may not contain an '=' character.
1954 * - NOTMUCH_STATUS_NULL_POINTER: Neither *key* nor *value* may be NULL.
1955 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
1956 * @since libnotmuch 4.4 (notmuch 0.23)
1959 notmuch_message_add_property (notmuch_message_t *message, const char *key, const char *value);
1962 * Remove a (key,value) pair from a message.
1964 * It is not an error to remove a non-existent (key,value) pair
1967 * - NOTMUCH_STATUS_ILLEGAL_ARGUMENT: *key* may not contain an '=' character.
1968 * - NOTMUCH_STATUS_NULL_POINTER: Neither *key* nor *value* may be NULL.
1969 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
1970 * @since libnotmuch 4.4 (notmuch 0.23)
1973 notmuch_message_remove_property (notmuch_message_t *message, const char *key, const char *value);
1976 * Remove all (key,value) pairs from the given message.
1978 * @param[in,out] message message to operate on.
1979 * @param[in] key key to delete properties for. If NULL, delete
1980 * properties for all keys
1982 * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
1983 * read-only mode so message cannot be modified.
1984 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
1986 * @since libnotmuch 4.4 (notmuch 0.23)
1989 notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key);
1992 * Remove all (prefix*,value) pairs from the given message
1994 * @param[in,out] message message to operate on.
1995 * @param[in] prefix delete properties with keys that start with prefix.
1996 * If NULL, delete all properties
1998 * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
1999 * read-only mode so message cannot be modified.
2000 * - NOTMUCH_STATUS_SUCCESS: No error occurred.
2002 * @since libnotmuch 5.1 (notmuch 0.26)
2005 notmuch_message_remove_all_properties_with_prefix (notmuch_message_t *message, const char *prefix);
2008 * Opaque message property iterator
2010 typedef struct _notmuch_string_map_iterator notmuch_message_properties_t;
2013 * Get the properties for *message*, returning a
2014 * notmuch_message_properties_t object which can be used to iterate
2015 * over all properties.
2017 * The notmuch_message_properties_t object is owned by the message and
2018 * as such, will only be valid for as long as the message is valid,
2019 * (which is until the query from which it derived is destroyed).
2021 * @param[in] message The message to examine
2022 * @param[in] key key or key prefix
2023 * @param[in] exact if TRUE, require exact match with key. Otherwise
2026 * Typical usage might be:
2028 * notmuch_message_properties_t *list;
2030 * for (list = notmuch_message_get_properties (message, "testkey1", TRUE);
2031 * notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) {
2032 * printf("%s\n", notmuch_message_properties_value(list));
2035 * notmuch_message_properties_destroy (list);
2037 * Note that there's no explicit destructor needed for the
2038 * notmuch_message_properties_t object. (For consistency, we do
2039 * provide a notmuch_message_properities_destroy function, but there's
2040 * no good reason to call it if the message is about to be destroyed).
2042 * @since libnotmuch 4.4 (notmuch 0.23)
2044 notmuch_message_properties_t *
2045 notmuch_message_get_properties (notmuch_message_t *message, const char *key, notmuch_bool_t exact);
2048 * Return the number of properties named "key" belonging to the specific message.
2050 * @param[in] message The message to examine
2051 * @param[in] key key to count
2052 * @param[out] count The number of matching properties associated with this message.
2056 * NOTMUCH_STATUS_SUCCESS: successful count, possibly some other error.
2058 * @since libnotmuch 5.2 (notmuch 0.27)
2061 notmuch_message_count_properties (notmuch_message_t *message, const char *key, unsigned int *count);
2064 * Is the given *properties* iterator pointing at a valid (key,value)
2067 * When this function returns TRUE,
2068 * notmuch_message_properties_{key,value} will return a valid string,
2069 * and notmuch_message_properties_move_to_next will do what it
2070 * says. Whereas when this function returns FALSE, calling any of
2071 * these functions results in undefined behaviour.
2073 * See the documentation of notmuch_message_get_properties for example
2074 * code showing how to iterate over a notmuch_message_properties_t
2077 * @since libnotmuch 4.4 (notmuch 0.23)
2080 notmuch_message_properties_valid (notmuch_message_properties_t *properties);
2083 * Move the *properties* iterator to the next (key,value) pair
2085 * If *properties* is already pointing at the last pair then the iterator
2086 * will be moved to a point just beyond that last pair, (where
2087 * notmuch_message_properties_valid will return FALSE).
2089 * See the documentation of notmuch_message_get_properties for example
2090 * code showing how to iterate over a notmuch_message_properties_t object.
2092 * @since libnotmuch 4.4 (notmuch 0.23)
2095 notmuch_message_properties_move_to_next (notmuch_message_properties_t *properties);
2098 * Return the key from the current (key,value) pair.
2100 * this could be useful if iterating for a prefix
2102 * @since libnotmuch 4.4 (notmuch 0.23)
2105 notmuch_message_properties_key (notmuch_message_properties_t *properties);
2108 * Return the value from the current (key,value) pair.
2110 * This could be useful if iterating for a prefix.
2112 * @since libnotmuch 4.4 (notmuch 0.23)
2115 notmuch_message_properties_value (notmuch_message_properties_t *properties);
2119 * Destroy a notmuch_message_properties_t object.
2121 * It's not strictly necessary to call this function. All memory from
2122 * the notmuch_message_properties_t object will be reclaimed when the
2123 * containing message object is destroyed.
2125 * @since libnotmuch 4.4 (notmuch 0.23)
2128 notmuch_message_properties_destroy (notmuch_message_properties_t *properties);
2133 * Is the given 'tags' iterator pointing at a valid tag.
2135 * When this function returns TRUE, notmuch_tags_get will return a
2136 * valid string. Whereas when this function returns FALSE,
2137 * notmuch_tags_get will return NULL.
2139 * See the documentation of notmuch_message_get_tags for example code
2140 * showing how to iterate over a notmuch_tags_t object.
2143 notmuch_tags_valid (notmuch_tags_t *tags);
2146 * Get the current tag from 'tags' as a string.
2148 * Note: The returned string belongs to 'tags' and has a lifetime
2149 * identical to it (and the query to which it ultimately belongs).
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_get (notmuch_tags_t *tags);
2158 * Move the 'tags' iterator to the next tag.
2160 * If 'tags' is already pointing at the last tag then the iterator
2161 * will be moved to a point just beyond that last tag, (where
2162 * notmuch_tags_valid will return FALSE and notmuch_tags_get will
2165 * See the documentation of notmuch_message_get_tags for example code
2166 * showing how to iterate over a notmuch_tags_t object.
2169 notmuch_tags_move_to_next (notmuch_tags_t *tags);
2172 * Destroy a notmuch_tags_t object.
2174 * It's not strictly necessary to call this function. All memory from
2175 * the notmuch_tags_t object will be reclaimed when the containing
2176 * message or query objects are destroyed.
2179 notmuch_tags_destroy (notmuch_tags_t *tags);
2182 * Store an mtime within the database for 'directory'.
2184 * The 'directory' should be an object retrieved from the database
2185 * with notmuch_database_get_directory for a particular path.
2187 * The intention is for the caller to use the mtime to allow efficient
2188 * identification of new messages to be added to the database. The
2189 * recommended usage is as follows:
2191 * o Read the mtime of a directory from the filesystem
2193 * o Call index_file for all mail files in the directory
2195 * o Call notmuch_directory_set_mtime with the mtime read from the
2198 * Then, when wanting to check for updates to the directory in the
2199 * future, the client can call notmuch_directory_get_mtime and know
2200 * that it only needs to add files if the mtime of the directory and
2201 * files are newer than the stored timestamp.
2203 * Note: The notmuch_directory_get_mtime function does not allow the
2204 * caller to distinguish a timestamp of 0 from a non-existent
2205 * timestamp. So don't store a timestamp of 0 unless you are
2206 * comfortable with that.
2210 * NOTMUCH_STATUS_SUCCESS: mtime successfully stored in database.
2212 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception
2213 * occurred, mtime not stored.
2215 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
2216 * mode so directory mtime cannot be modified.
2219 notmuch_directory_set_mtime (notmuch_directory_t *directory,
2223 * Get the mtime of a directory, (as previously stored with
2224 * notmuch_directory_set_mtime).
2226 * Returns 0 if no mtime has previously been stored for this
2230 notmuch_directory_get_mtime (notmuch_directory_t *directory);
2233 * Get a notmuch_filenames_t iterator listing all the filenames of
2234 * messages in the database within the given directory.
2236 * The returned filenames will be the basename-entries only (not
2239 * Returns NULL if it triggers a Xapian exception
2241 notmuch_filenames_t *
2242 notmuch_directory_get_child_files (notmuch_directory_t *directory);
2245 * Get a notmuch_filenames_t iterator listing all the filenames of
2246 * sub-directories 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_directories (notmuch_directory_t *directory);
2257 * Delete directory document from the database, and destroy the
2258 * notmuch_directory_t object. Assumes any child directories and files
2259 * have been deleted by the caller.
2261 * @since libnotmuch 4.3 (notmuch 0.21)
2264 notmuch_directory_delete (notmuch_directory_t *directory);
2267 * Destroy a notmuch_directory_t object.
2270 notmuch_directory_destroy (notmuch_directory_t *directory);
2273 * Is the given 'filenames' iterator pointing at a valid filename.
2275 * When this function returns TRUE, notmuch_filenames_get will return
2276 * a valid string. Whereas when this function returns FALSE,
2277 * notmuch_filenames_get will return NULL.
2279 * It is acceptable to pass NULL for 'filenames', in which case this
2280 * function will always return FALSE.
2283 notmuch_filenames_valid (notmuch_filenames_t *filenames);
2286 * Get the current filename from 'filenames' as a string.
2288 * Note: The returned string belongs to 'filenames' and has a lifetime
2289 * identical to it (and the directory to which it ultimately belongs).
2291 * It is acceptable to pass NULL for 'filenames', in which case this
2292 * function will always return NULL.
2295 notmuch_filenames_get (notmuch_filenames_t *filenames);
2298 * Move the 'filenames' iterator to the next filename.
2300 * If 'filenames' is already pointing at the last filename then the
2301 * iterator will be moved to a point just beyond that last filename,
2302 * (where notmuch_filenames_valid will return FALSE and
2303 * notmuch_filenames_get will return NULL).
2305 * It is acceptable to pass NULL for 'filenames', in which case this
2306 * function will do nothing.
2309 notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
2312 * Destroy a notmuch_filenames_t object.
2314 * It's not strictly necessary to call this function. All memory from
2315 * the notmuch_filenames_t object will be reclaimed when the
2316 * containing directory object is destroyed.
2318 * It is acceptable to pass NULL for 'filenames', in which case this
2319 * function will do nothing.
2322 notmuch_filenames_destroy (notmuch_filenames_t *filenames);
2326 * set config 'key' to 'value'
2328 * @since libnotmuch 4.4 (notmuch 0.23)
2329 * @retval #NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
2330 * read-only mode so message cannot be modified.
2331 * @retval #NOTMUCH_STATUS_XAPIAN_EXCEPTION: an exception was thrown
2332 * accessing the database.
2333 * @retval #NOTMUCH_STATUS_SUCCESS
2336 notmuch_database_set_config (notmuch_database_t *db, const char *key, const char *value);
2339 * retrieve config item 'key', assign to 'value'
2341 * keys which have not been previously set with n_d_set_config will
2342 * return an empty string.
2344 * return value is allocated by malloc and should be freed by the
2347 * @since libnotmuch 4.4 (notmuch 0.23)
2351 notmuch_database_get_config (notmuch_database_t *db, const char *key, char **value);
2354 * Create an iterator for all config items with keys matching a given prefix
2356 * @since libnotmuch 4.4 (notmuch 0.23)
2359 notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out);
2362 * Is 'config_list' iterator valid (i.e. _key, _value, _move_to_next can be called).
2364 * @since libnotmuch 4.4 (notmuch 0.23)
2367 notmuch_config_list_valid (notmuch_config_list_t *config_list);
2370 * return key for current config pair
2372 * return value is owned by the iterator, and will be destroyed by the
2373 * next call to notmuch_config_list_key or notmuch_config_list_destroy.
2375 * @since libnotmuch 4.4 (notmuch 0.23)
2378 notmuch_config_list_key (notmuch_config_list_t *config_list);
2381 * return 'value' for current config pair
2383 * return value is owned by the iterator, and will be destroyed by the
2384 * next call to notmuch_config_list_value or notmuch config_list_destroy
2386 * @since libnotmuch 4.4 (notmuch 0.23)
2387 * @retval NULL for errors
2390 notmuch_config_list_value (notmuch_config_list_t *config_list);
2394 * move 'config_list' iterator to the next pair
2396 * @since libnotmuch 4.4 (notmuch 0.23)
2399 notmuch_config_list_move_to_next (notmuch_config_list_t *config_list);
2402 * free any resources held by 'config_list'
2404 * @since libnotmuch 4.4 (notmuch 0.23)
2407 notmuch_config_list_destroy (notmuch_config_list_t *config_list);
2411 * Configuration keys known to libnotmuch
2413 typedef enum _notmuch_config_key {
2414 NOTMUCH_CONFIG_FIRST,
2415 NOTMUCH_CONFIG_DATABASE_PATH = NOTMUCH_CONFIG_FIRST,
2416 NOTMUCH_CONFIG_EXCLUDE_TAGS,
2417 NOTMUCH_CONFIG_NEW_TAGS,
2418 NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS,
2419 NOTMUCH_CONFIG_PRIMARY_EMAIL,
2420 NOTMUCH_CONFIG_OTHER_EMAIL,
2421 NOTMUCH_CONFIG_USER_NAME,
2423 } notmuch_config_key_t;
2426 * get a configuration value from an open database.
2428 * This value reflects all configuration information given at the time
2429 * the database was opened.
2431 * @param[in] notmuch database
2432 * @param[in] key configuration key
2434 * @since libnotmuch 5.4 (notmuch 0.32)
2436 * @retval NULL if 'key' unknown or if no value is known for
2437 * 'key'. Otherwise returns a string owned by notmuch which should
2438 * not be modified nor freed by the caller.
2441 notmuch_config_get (notmuch_database_t *notmuch, notmuch_config_key_t key);
2444 * set a configuration value from in an open database.
2446 * This value reflects all configuration information given at the time
2447 * the database was opened.
2449 * @param[in,out] notmuch database open read/write
2450 * @param[in] key configuration key
2451 * @param[in] val configuration value
2453 * @since libnotmuch 5.4 (notmuch 0.32)
2455 * @retval returns any return value for notmuch_database_set_config.
2458 notmuch_config_set (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val);
2461 * Returns an iterator for a ';'-delimited list of configuration values
2463 * These values reflect all configuration information given at the
2464 * time the database was opened.
2466 * @param[in] notmuch database
2467 * @param[in] key configuration key
2469 * @since libnotmuch 5.4 (notmuch 0.32)
2471 * @retval NULL in case of error.
2473 notmuch_config_values_t *
2474 notmuch_config_get_values (notmuch_database_t *notmuch, notmuch_config_key_t key);
2477 * Is the given 'config_values' iterator pointing at a valid element.
2479 * @param[in] values iterator
2481 * @since libnotmuch 5.4 (notmuch 0.32)
2483 * @retval FALSE if passed a NULL pointer, or the iterator is exhausted.
2487 notmuch_config_values_valid (notmuch_config_values_t *values);
2490 * Get the current value from the 'values' iterator
2492 * @param[in] values iterator
2494 * @since libnotmuch 5.4 (notmuch 0.32)
2496 * @retval a string with the same lifetime as the iterator
2499 notmuch_config_values_get (notmuch_config_values_t *values);
2502 * Move the 'values' iterator to the next element
2504 * @param[in,out] values iterator
2506 * @since libnotmuch 5.4 (notmuch 0.32)
2510 notmuch_config_values_move_to_next (notmuch_config_values_t *values);
2514 * reset the 'values' iterator to the first element
2516 * @param[in,out] values iterator. A NULL value is ignored.
2518 * @since libnotmuch 5.4 (notmuch 0.32)
2522 notmuch_config_values_start (notmuch_config_values_t *values);
2525 * Destroy a config values iterator, along with any associated
2528 * @param[in,out] values iterator
2530 * @since libnotmuch 5.4 (notmuch 0.32)
2533 notmuch_config_values_destroy (notmuch_config_values_t *values);
2536 * get the current default indexing options for a given database.
2538 * This object will survive until the database itself is destroyed,
2539 * but the caller may also release it earlier with
2540 * notmuch_indexopts_destroy.
2542 * This object represents a set of options on how a message can be
2543 * added to the index. At the moment it is a featureless stub.
2545 * @since libnotmuch 5.1 (notmuch 0.26)
2546 * @retval NULL in case of error
2548 notmuch_indexopts_t *
2549 notmuch_database_get_default_indexopts (notmuch_database_t *db);
2552 * Stating a policy about how to decrypt messages.
2554 * See index.decrypt in notmuch-config(1) for more details.
2557 NOTMUCH_DECRYPT_FALSE,
2558 NOTMUCH_DECRYPT_TRUE,
2559 NOTMUCH_DECRYPT_AUTO,
2560 NOTMUCH_DECRYPT_NOSTASH,
2561 } notmuch_decryption_policy_t;
2564 * Specify whether to decrypt encrypted parts while indexing.
2566 * Be aware that the index is likely sufficient to reconstruct the
2567 * cleartext of the message itself, so please ensure that the notmuch
2568 * message index is adequately protected. DO NOT SET THIS FLAG TO TRUE
2569 * without considering the security of your index.
2571 * @since libnotmuch 5.1 (notmuch 0.26)
2574 notmuch_indexopts_set_decrypt_policy (notmuch_indexopts_t *indexopts,
2575 notmuch_decryption_policy_t decrypt_policy);
2578 * Return whether to decrypt encrypted parts while indexing.
2579 * see notmuch_indexopts_set_decrypt_policy.
2581 * @since libnotmuch 5.1 (notmuch 0.26)
2583 notmuch_decryption_policy_t
2584 notmuch_indexopts_get_decrypt_policy (const notmuch_indexopts_t *indexopts);
2587 * Destroy a notmuch_indexopts_t object.
2589 * @since libnotmuch 5.1 (notmuch 0.26)
2592 notmuch_indexopts_destroy (notmuch_indexopts_t *options);
2596 * interrogate the library for compile time features
2598 * @since libnotmuch 4.4 (notmuch 0.23)
2601 notmuch_built_with (const char *name);
2604 #pragma GCC visibility pop