X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fnotmuch.h;h=29713ae2e82dbadf41e9be7083e610794b10615f;hp=c8edc84dcbd702a3916b6204a6171d786b9956d2;hb=6a833a6e83865f6999707cc30768d07e1351c2cb;hpb=8cca886b10c5ec44f3214701c0c1e3c896d53d5c diff --git a/lib/notmuch.h b/lib/notmuch.h index c8edc84d..29713ae2 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -56,9 +56,20 @@ NOTMUCH_BEGIN_DECLS * version in Makefile.local. */ #define LIBNOTMUCH_MAJOR_VERSION 4 -#define LIBNOTMUCH_MINOR_VERSION 2 +#define LIBNOTMUCH_MINOR_VERSION 3 #define LIBNOTMUCH_MICRO_VERSION 0 + +#if defined (__clang_major__) && __clang_major__ >= 3 \ + || defined (__GNUC__) && __GNUC__ >= 5 \ + || defined (__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5 +#define NOTMUCH_DEPRECATED(major,minor) \ + __attribute__ ((deprecated ("function deprecated as of libnotmuch " #major "." #minor))) +#else +#define NOTMUCH_DEPRECATED(major,minor) __attribute__ ((deprecated)) +#endif + + #endif /* __DOXYGEN__ */ /** @@ -195,6 +206,7 @@ typedef struct _notmuch_message notmuch_message_t; typedef struct _notmuch_tags notmuch_tags_t; typedef struct _notmuch_directory notmuch_directory_t; typedef struct _notmuch_filenames notmuch_filenames_t; +typedef struct _notmuch_config_list notmuch_config_list_t; #endif /* __DOXYGEN__ */ /** @@ -311,7 +323,7 @@ notmuch_database_open_verbose (const char *path, * */ const char * -notmuch_database_status_string (notmuch_database_t *notmuch); +notmuch_database_status_string (const notmuch_database_t *notmuch); /** * Commit changes and close the given notmuch database. @@ -465,6 +477,24 @@ notmuch_database_begin_atomic (notmuch_database_t *notmuch); notmuch_status_t notmuch_database_end_atomic (notmuch_database_t *notmuch); +/** + * Return the committed database revision and UUID. + * + * The database revision number increases monotonically with each + * commit to the database. Hence, all messages and message changes + * committed to the database (that is, visible to readers) have a last + * modification revision <= the committed database revision. Any + * messages committed in the future will be assigned a modification + * revision > the committed database revision. + * + * The UUID is a NUL-terminated opaque string that uniquely identifies + * this database. Two revision numbers are only comparable if they + * have the same database UUID. + */ +unsigned long +notmuch_database_get_revision (notmuch_database_t *notmuch, + const char **uuid); + /** * Retrieve a directory object from the database for 'path'. * @@ -663,7 +693,7 @@ notmuch_database_get_all_tags (notmuch_database_t *db); * completely in the future, but it's likely to be a specialized * version of the general Xapian query syntax: * - * http://xapian.org/docs/queryparser.html + * https://xapian.org/docs/queryparser.html * * As a special case, passing either a length-zero string, (that is ""), * or a string consisting of a single asterisk (that is "*"), will @@ -708,7 +738,13 @@ typedef enum { * Return the query_string of this query. See notmuch_query_create. */ const char * -notmuch_query_get_query_string (notmuch_query_t *query); +notmuch_query_get_query_string (const notmuch_query_t *query); + +/** + * Return the notmuch database of this query. See notmuch_query_create. + */ +notmuch_database_t * +notmuch_query_get_database (const notmuch_query_t *query); /** * Exclude values for notmuch_query_set_omit_excluded. The strange @@ -765,7 +801,7 @@ notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort); * notmuch_query_set_sort. */ notmuch_sort_t -notmuch_query_get_sort (notmuch_query_t *query); +notmuch_query_get_sort (const notmuch_query_t *query); /** * Add a tag that will be excluded from the query results by default. @@ -812,19 +848,25 @@ notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag); * notmuch_threads_destroy function, but there's no good reason * to call it if the query is about to be destroyed). * - * If a Xapian exception occurs this function will return NULL. - * For better error reporting, use the _st variant. - */ -notmuch_threads_t * -notmuch_query_search_threads (notmuch_query_t *query); - -/** - * Like notmuch_query_search_threads, but with a status return. + * @since libnotmuch 4.2 (notmuch 0.20) */ notmuch_status_t notmuch_query_search_threads_st (notmuch_query_t *query, notmuch_threads_t **out); +/** + * Like notmuch_query_search_threads_st, but without a status return. + * + * If a Xapian exception occurs this function will return NULL. + * + * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please + * use notmuch_query_search_threads_st instead. + * + */ +NOTMUCH_DEPRECATED(4,3) +notmuch_threads_t * +notmuch_query_search_threads (notmuch_query_t *query); + /** * Execute a query for messages, returning a notmuch_messages_t object * which can be used to iterate over the results. The returned @@ -863,17 +905,24 @@ notmuch_query_search_threads_st (notmuch_query_t *query, * reason to call it if the query is about to be destroyed). * * If a Xapian exception occurs this function will return NULL. - * For better error reporting, use the _st variant. - */ -notmuch_messages_t * -notmuch_query_search_messages (notmuch_query_t *query); - -/** - * Like notmuch_query_search_messages, but with a status return. + * + * @since libnotmuch 4.2 (notmuch 0.20) */ notmuch_status_t notmuch_query_search_messages_st (notmuch_query_t *query, notmuch_messages_t **out); +/** + * Like notmuch_query_search_messages, but without a status return. + * + * If a Xapian exception occurs this function will return NULL. + * + * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please use + * notmuch_query_search_messages_st instead. + * + */ +NOTMUCH_DEPRECATED(4,3) +notmuch_messages_t * +notmuch_query_search_messages (notmuch_query_t *query); /** * Destroy a notmuch_query_t along with any associated resources. @@ -947,10 +996,28 @@ notmuch_threads_destroy (notmuch_threads_t *threads); * This function performs a search and returns the number of matching * messages. * - * If a Xapian exception occurs, this function may return 0 (after - * printing a message). + * @returns + * + * NOTMUCH_STATUS_SUCCESS: query completed successfully. + * + * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The + * value of *count is not defined. + * + * @since libnotmuch 4.3 (notmuch 0.21) + */ +notmuch_status_t +notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count); + +/** + * like notmuch_query_count_messages_st, but without a status return. + * + * May return 0 in the case of errors. + * + * @deprecated Deprecated since libnotmuch 4.3 (notmuch 0.21). Please + * use notmuch_query_count_messages_st instead. */ -unsigned +NOTMUCH_DEPRECATED(4,3) +unsigned int notmuch_query_count_messages (notmuch_query_t *query); /** @@ -961,11 +1028,33 @@ notmuch_query_count_messages (notmuch_query_t *query); * search. * * Note that this is a significantly heavier operation than - * notmuch_query_count_messages(). + * notmuch_query_count_messages{_st}(). + * + * @returns + * + * NOTMUCH_STATUS_OUT_OF_MEMORY: Memory allocation failed. The value + * of *count is not defined + + * NOTMUCH_STATUS_SUCCESS: query completed successfully. + * + * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The + * value of *count is not defined. * - * If an error occurs, this function may return 0. + * @since libnotmuch 4.3 (notmuch 0.21) */ -unsigned +notmuch_status_t +notmuch_query_count_threads_st (notmuch_query_t *query, unsigned *count); + +/** + * like notmuch_query_count_threads, but without a status return. + * + * May return 0 in case of errors. + * + * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please + * use notmuch_query_count_threads_st instead. + */ +NOTMUCH_DEPRECATED(4,3) +unsigned int notmuch_query_count_threads (notmuch_query_t *query); /** @@ -1673,7 +1762,7 @@ notmuch_filenames_t * notmuch_directory_get_child_files (notmuch_directory_t *directory); /** - * Get a notmuch_filenams_t iterator listing all the filenames of + * Get a notmuch_filenames_t iterator listing all the filenames of * sub-directories in the database within the given directory. * * The returned filenames will be the basename-entries only (not @@ -1682,6 +1771,16 @@ notmuch_directory_get_child_files (notmuch_directory_t *directory); notmuch_filenames_t * notmuch_directory_get_child_directories (notmuch_directory_t *directory); +/** + * Delete directory document from the database, and destroy the + * notmuch_directory_t object. Assumes any child directories and files + * have been deleted by the caller. + * + * @since libnotmuch 4.3 (notmuch 0.21) + */ +notmuch_status_t +notmuch_directory_delete (notmuch_directory_t *directory); + /** * Destroy a notmuch_directory_t object. */ @@ -1740,6 +1839,74 @@ notmuch_filenames_move_to_next (notmuch_filenames_t *filenames); void notmuch_filenames_destroy (notmuch_filenames_t *filenames); + +/** + * set config 'key' to 'value' + * + */ +notmuch_status_t +notmuch_database_set_config (notmuch_database_t *db, const char *key, const char *value); + +/** + * retrieve config item 'key', assign to 'value' + * + * keys which have not been previously set with n_d_set_config will + * return an empty string. + * + * return value is allocated by malloc and should be freed by the + * caller. + */ +notmuch_status_t +notmuch_database_get_config (notmuch_database_t *db, const char *key, char **value); + +/** + * Create an iterator for all config items with keys matching a given prefix + */ +notmuch_status_t +notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out); + +/** + * Is 'config_list' iterator valid (i.e. _key, _value, _move_to_next can be called). + */ +notmuch_bool_t +notmuch_config_list_valid (notmuch_config_list_t *config_list); + +/** + * return key for current config pair + * + * return value is owned by the iterator, and will be destroyed by the + * next call to notmuch_config_list_key or notmuch_config_list_destroy. + */ +const char * +notmuch_config_list_key (notmuch_config_list_t *config_list); + +/** + * return 'value' for current config pair + * + * return value is owned by the iterator, and will be destroyed by the + * next call to notmuch_config_list_value or notmuch config_list_destroy + */ +const char * +notmuch_config_list_value (notmuch_config_list_t *config_list); + + +/** + * move 'config_list' iterator to the next pair + */ +void +notmuch_config_list_move_to_next (notmuch_config_list_t *config_list); + +/** + * free any resources held by 'config_list' + */ +void +notmuch_config_list_destroy (notmuch_config_list_t *config_list); + +/** + * interrogate the library for compile time features + */ +notmuch_bool_t +notmuch_built_with (const char *name); /* @} */ NOTMUCH_END_DECLS