4 ffibuilder = cffi.FFI()
12 #if LIBNOTMUCH_MAJOR_VERSION < 5
13 #error libnotmuch version not supported by notdb
16 include_dirs=['../../lib'],
17 library_dirs=['../../lib'],
18 libraries=['notmuch'],
23 typedef int... time_t;
25 #define LIBNOTMUCH_MAJOR_VERSION ...
26 #define LIBNOTMUCH_MINOR_VERSION ...
27 #define LIBNOTMUCH_MICRO_VERSION ...
29 #define NOTMUCH_TAG_MAX ...
31 typedef enum _notmuch_status {
32 NOTMUCH_STATUS_SUCCESS = 0,
33 NOTMUCH_STATUS_OUT_OF_MEMORY,
34 NOTMUCH_STATUS_READ_ONLY_DATABASE,
35 NOTMUCH_STATUS_XAPIAN_EXCEPTION,
36 NOTMUCH_STATUS_FILE_ERROR,
37 NOTMUCH_STATUS_FILE_NOT_EMAIL,
38 NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
39 NOTMUCH_STATUS_NULL_POINTER,
40 NOTMUCH_STATUS_TAG_TOO_LONG,
41 NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
42 NOTMUCH_STATUS_UNBALANCED_ATOMIC,
43 NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
44 NOTMUCH_STATUS_UPGRADE_REQUIRED,
45 NOTMUCH_STATUS_PATH_ERROR,
46 NOTMUCH_STATUS_ILLEGAL_ARGUMENT,
47 NOTMUCH_STATUS_LAST_STATUS
50 NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
51 NOTMUCH_DATABASE_MODE_READ_WRITE
52 } notmuch_database_mode_t;
53 typedef int notmuch_bool_t;
54 typedef enum _notmuch_message_flag {
55 NOTMUCH_MESSAGE_FLAG_MATCH,
56 NOTMUCH_MESSAGE_FLAG_EXCLUDED,
57 NOTMUCH_MESSAGE_FLAG_GHOST,
58 } notmuch_message_flag_t;
60 NOTMUCH_SORT_OLDEST_FIRST,
61 NOTMUCH_SORT_NEWEST_FIRST,
62 NOTMUCH_SORT_MESSAGE_ID,
68 NOTMUCH_EXCLUDE_FALSE,
72 // These are fully opaque types for us, we only ever use pointers.
73 typedef struct _notmuch_database notmuch_database_t;
74 typedef struct _notmuch_query notmuch_query_t;
75 typedef struct _notmuch_threads notmuch_threads_t;
76 typedef struct _notmuch_thread notmuch_thread_t;
77 typedef struct _notmuch_messages notmuch_messages_t;
78 typedef struct _notmuch_message notmuch_message_t;
79 typedef struct _notmuch_tags notmuch_tags_t;
80 typedef struct _notmuch_string_map_iterator notmuch_message_properties_t;
81 typedef struct _notmuch_directory notmuch_directory_t;
82 typedef struct _notmuch_filenames notmuch_filenames_t;
83 typedef struct _notmuch_config_list notmuch_config_list_t;
86 notmuch_status_to_string (notmuch_status_t status);
89 notmuch_database_create_verbose (const char *path,
90 notmuch_database_t **database,
91 char **error_message);
93 notmuch_database_create (const char *path, notmuch_database_t **database);
95 notmuch_database_open_verbose (const char *path,
96 notmuch_database_mode_t mode,
97 notmuch_database_t **database,
98 char **error_message);
100 notmuch_database_open (const char *path,
101 notmuch_database_mode_t mode,
102 notmuch_database_t **database);
104 notmuch_database_close (notmuch_database_t *database);
106 notmuch_database_destroy (notmuch_database_t *database);
108 notmuch_database_get_path (notmuch_database_t *database);
110 notmuch_database_get_version (notmuch_database_t *database);
112 notmuch_database_needs_upgrade (notmuch_database_t *database);
114 notmuch_database_begin_atomic (notmuch_database_t *notmuch);
116 notmuch_database_end_atomic (notmuch_database_t *notmuch);
118 notmuch_database_get_revision (notmuch_database_t *notmuch,
121 notmuch_database_add_message (notmuch_database_t *database,
122 const char *filename,
123 notmuch_message_t **message);
125 notmuch_database_remove_message (notmuch_database_t *database,
126 const char *filename);
128 notmuch_database_find_message (notmuch_database_t *database,
129 const char *message_id,
130 notmuch_message_t **message);
132 notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
133 const char *filename,
134 notmuch_message_t **message);
136 notmuch_database_get_all_tags (notmuch_database_t *db);
139 notmuch_query_create (notmuch_database_t *database,
140 const char *query_string);
142 notmuch_query_get_query_string (const notmuch_query_t *query);
144 notmuch_query_get_database (const notmuch_query_t *query);
146 notmuch_query_set_omit_excluded (notmuch_query_t *query,
147 notmuch_exclude_t omit_excluded);
149 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
151 notmuch_query_get_sort (const notmuch_query_t *query);
153 notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
155 notmuch_query_search_threads (notmuch_query_t *query,
156 notmuch_threads_t **out);
158 notmuch_query_search_messages (notmuch_query_t *query,
159 notmuch_messages_t **out);
161 notmuch_query_count_messages (notmuch_query_t *query, unsigned int *count);
163 notmuch_query_count_threads (notmuch_query_t *query, unsigned *count);
165 notmuch_query_destroy (notmuch_query_t *query);
168 notmuch_threads_valid (notmuch_threads_t *threads);
170 notmuch_threads_get (notmuch_threads_t *threads);
172 notmuch_threads_move_to_next (notmuch_threads_t *threads);
174 notmuch_threads_destroy (notmuch_threads_t *threads);
177 notmuch_thread_get_thread_id (notmuch_thread_t *thread);
179 notmuch_message_get_replies (notmuch_message_t *message);
181 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
183 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
185 notmuch_thread_get_messages (notmuch_thread_t *thread);
187 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
189 notmuch_thread_get_authors (notmuch_thread_t *thread);
191 notmuch_thread_get_subject (notmuch_thread_t *thread);
193 notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
195 notmuch_thread_get_newest_date (notmuch_thread_t *thread);
197 notmuch_thread_get_tags (notmuch_thread_t *thread);
199 notmuch_thread_destroy (notmuch_thread_t *thread);
202 notmuch_messages_valid (notmuch_messages_t *messages);
204 notmuch_messages_get (notmuch_messages_t *messages);
206 notmuch_messages_move_to_next (notmuch_messages_t *messages);
208 notmuch_messages_destroy (notmuch_messages_t *messages);
210 notmuch_messages_collect_tags (notmuch_messages_t *messages);
213 notmuch_message_get_message_id (notmuch_message_t *message);
215 notmuch_message_get_thread_id (notmuch_message_t *message);
217 notmuch_message_get_filename (notmuch_message_t *message);
218 notmuch_filenames_t *
219 notmuch_message_get_filenames (notmuch_message_t *message);
221 notmuch_message_get_flag (notmuch_message_t *message,
222 notmuch_message_flag_t flag);
224 notmuch_message_set_flag (notmuch_message_t *message,
225 notmuch_message_flag_t flag,
226 notmuch_bool_t value);
228 notmuch_message_get_date (notmuch_message_t *message);
230 notmuch_message_get_header (notmuch_message_t *message,
233 notmuch_message_get_tags (notmuch_message_t *message);
235 notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
237 notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
239 notmuch_message_remove_all_tags (notmuch_message_t *message);
241 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
243 notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
245 notmuch_message_freeze (notmuch_message_t *message);
247 notmuch_message_thaw (notmuch_message_t *message);
249 notmuch_message_get_property (notmuch_message_t *message,
250 const char *key, const char **value);
252 notmuch_message_add_property (notmuch_message_t *message,
253 const char *key, const char *value);
255 notmuch_message_remove_property (notmuch_message_t *message,
256 const char *key, const char *value);
258 notmuch_message_remove_all_properties (notmuch_message_t *message,
260 notmuch_message_properties_t *
261 notmuch_message_get_properties (notmuch_message_t *message,
262 const char *key, notmuch_bool_t exact);
264 notmuch_message_properties_valid (notmuch_message_properties_t
267 notmuch_message_properties_move_to_next (notmuch_message_properties_t
270 notmuch_message_properties_key (notmuch_message_properties_t *properties);
272 notmuch_message_properties_value (notmuch_message_properties_t
275 notmuch_message_properties_destroy (notmuch_message_properties_t
278 notmuch_message_destroy (notmuch_message_t *message);
281 notmuch_tags_valid (notmuch_tags_t *tags);
283 notmuch_tags_get (notmuch_tags_t *tags);
285 notmuch_tags_move_to_next (notmuch_tags_t *tags);
287 notmuch_tags_destroy (notmuch_tags_t *tags);
290 notmuch_filenames_valid (notmuch_filenames_t *filenames);
292 notmuch_filenames_get (notmuch_filenames_t *filenames);
294 notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
296 notmuch_filenames_destroy (notmuch_filenames_t *filenames);
301 if __name__ == '__main__':
302 ffibuilder.compile(verbose=True)