4 ffibuilder = cffi.FFI()
12 #if LIBNOTMUCH_MAJOR_VERSION < 5
13 #error libnotmuch version not supported by notmuch2 python bindings
15 #if LIBNOTMUCH_MINOR_VERSION < 1
16 #ERROR libnotmuch version < 5.1 not supported
19 include_dirs=['../../lib'],
20 library_dirs=['../../lib'],
21 libraries=['notmuch'],
26 typedef int... time_t;
28 #define LIBNOTMUCH_MAJOR_VERSION ...
29 #define LIBNOTMUCH_MINOR_VERSION ...
30 #define LIBNOTMUCH_MICRO_VERSION ...
32 #define NOTMUCH_TAG_MAX ...
34 typedef enum _notmuch_status {
35 NOTMUCH_STATUS_SUCCESS = 0,
36 NOTMUCH_STATUS_OUT_OF_MEMORY,
37 NOTMUCH_STATUS_READ_ONLY_DATABASE,
38 NOTMUCH_STATUS_XAPIAN_EXCEPTION,
39 NOTMUCH_STATUS_FILE_ERROR,
40 NOTMUCH_STATUS_FILE_NOT_EMAIL,
41 NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
42 NOTMUCH_STATUS_NULL_POINTER,
43 NOTMUCH_STATUS_TAG_TOO_LONG,
44 NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
45 NOTMUCH_STATUS_UNBALANCED_ATOMIC,
46 NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
47 NOTMUCH_STATUS_UPGRADE_REQUIRED,
48 NOTMUCH_STATUS_PATH_ERROR,
49 NOTMUCH_STATUS_ILLEGAL_ARGUMENT,
50 NOTMUCH_STATUS_MALFORMED_CRYPTO_PROTOCOL,
51 NOTMUCH_STATUS_FAILED_CRYPTO_CONTEXT_CREATION,
52 NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL,
53 NOTMUCH_STATUS_NO_CONFIG,
54 NOTMUCH_STATUS_DATABASE_EXISTS,
55 NOTMUCH_STATUS_LAST_STATUS
58 NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
59 NOTMUCH_DATABASE_MODE_READ_WRITE
60 } notmuch_database_mode_t;
61 typedef int notmuch_bool_t;
62 typedef enum _notmuch_message_flag {
63 NOTMUCH_MESSAGE_FLAG_MATCH,
64 NOTMUCH_MESSAGE_FLAG_EXCLUDED,
65 NOTMUCH_MESSAGE_FLAG_GHOST,
66 } notmuch_message_flag_t;
68 NOTMUCH_SORT_OLDEST_FIRST,
69 NOTMUCH_SORT_NEWEST_FIRST,
70 NOTMUCH_SORT_MESSAGE_ID,
76 NOTMUCH_EXCLUDE_FALSE,
80 NOTMUCH_DECRYPT_FALSE,
83 NOTMUCH_DECRYPT_NOSTASH,
84 } notmuch_decryption_policy_t;
86 // These are fully opaque types for us, we only ever use pointers.
87 typedef struct _notmuch_database notmuch_database_t;
88 typedef struct _notmuch_query notmuch_query_t;
89 typedef struct _notmuch_threads notmuch_threads_t;
90 typedef struct _notmuch_thread notmuch_thread_t;
91 typedef struct _notmuch_messages notmuch_messages_t;
92 typedef struct _notmuch_message notmuch_message_t;
93 typedef struct _notmuch_tags notmuch_tags_t;
94 typedef struct _notmuch_string_map_iterator notmuch_message_properties_t;
95 typedef struct _notmuch_directory notmuch_directory_t;
96 typedef struct _notmuch_filenames notmuch_filenames_t;
97 typedef struct _notmuch_config_list notmuch_config_list_t;
98 typedef struct _notmuch_indexopts notmuch_indexopts_t;
101 notmuch_status_to_string (notmuch_status_t status);
104 notmuch_database_create_verbose (const char *path,
105 notmuch_database_t **database,
106 char **error_message);
108 notmuch_database_create (const char *path, notmuch_database_t **database);
110 notmuch_database_open_verbose (const char *path,
111 notmuch_database_mode_t mode,
112 notmuch_database_t **database,
113 char **error_message);
115 notmuch_database_open (const char *path,
116 notmuch_database_mode_t mode,
117 notmuch_database_t **database);
119 notmuch_database_close (notmuch_database_t *database);
121 notmuch_database_destroy (notmuch_database_t *database);
123 notmuch_database_get_path (notmuch_database_t *database);
125 notmuch_database_get_version (notmuch_database_t *database);
127 notmuch_database_needs_upgrade (notmuch_database_t *database);
129 notmuch_database_begin_atomic (notmuch_database_t *notmuch);
131 notmuch_database_end_atomic (notmuch_database_t *notmuch);
133 notmuch_database_get_revision (notmuch_database_t *notmuch,
136 notmuch_database_index_file (notmuch_database_t *database,
137 const char *filename,
138 notmuch_indexopts_t *indexopts,
139 notmuch_message_t **message);
141 notmuch_database_remove_message (notmuch_database_t *database,
142 const char *filename);
144 notmuch_database_find_message (notmuch_database_t *database,
145 const char *message_id,
146 notmuch_message_t **message);
148 notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
149 const char *filename,
150 notmuch_message_t **message);
152 notmuch_database_get_all_tags (notmuch_database_t *db);
155 notmuch_query_create (notmuch_database_t *database,
156 const char *query_string);
158 notmuch_query_get_query_string (const notmuch_query_t *query);
160 notmuch_query_get_database (const notmuch_query_t *query);
162 notmuch_query_set_omit_excluded (notmuch_query_t *query,
163 notmuch_exclude_t omit_excluded);
165 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
167 notmuch_query_get_sort (const notmuch_query_t *query);
169 notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
171 notmuch_query_search_threads (notmuch_query_t *query,
172 notmuch_threads_t **out);
174 notmuch_query_search_messages (notmuch_query_t *query,
175 notmuch_messages_t **out);
177 notmuch_query_count_messages (notmuch_query_t *query, unsigned int *count);
179 notmuch_query_count_threads (notmuch_query_t *query, unsigned *count);
181 notmuch_query_destroy (notmuch_query_t *query);
184 notmuch_threads_valid (notmuch_threads_t *threads);
186 notmuch_threads_get (notmuch_threads_t *threads);
188 notmuch_threads_move_to_next (notmuch_threads_t *threads);
190 notmuch_threads_destroy (notmuch_threads_t *threads);
193 notmuch_thread_get_thread_id (notmuch_thread_t *thread);
195 notmuch_message_get_replies (notmuch_message_t *message);
197 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
199 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
201 notmuch_thread_get_messages (notmuch_thread_t *thread);
203 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
205 notmuch_thread_get_authors (notmuch_thread_t *thread);
207 notmuch_thread_get_subject (notmuch_thread_t *thread);
209 notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
211 notmuch_thread_get_newest_date (notmuch_thread_t *thread);
213 notmuch_thread_get_tags (notmuch_thread_t *thread);
215 notmuch_thread_destroy (notmuch_thread_t *thread);
218 notmuch_messages_valid (notmuch_messages_t *messages);
220 notmuch_messages_get (notmuch_messages_t *messages);
222 notmuch_messages_move_to_next (notmuch_messages_t *messages);
224 notmuch_messages_destroy (notmuch_messages_t *messages);
226 notmuch_messages_collect_tags (notmuch_messages_t *messages);
229 notmuch_message_get_message_id (notmuch_message_t *message);
231 notmuch_message_get_thread_id (notmuch_message_t *message);
233 notmuch_message_get_filename (notmuch_message_t *message);
234 notmuch_filenames_t *
235 notmuch_message_get_filenames (notmuch_message_t *message);
237 notmuch_message_get_flag (notmuch_message_t *message,
238 notmuch_message_flag_t flag);
240 notmuch_message_set_flag (notmuch_message_t *message,
241 notmuch_message_flag_t flag,
242 notmuch_bool_t value);
244 notmuch_message_get_date (notmuch_message_t *message);
246 notmuch_message_get_header (notmuch_message_t *message,
249 notmuch_message_get_tags (notmuch_message_t *message);
251 notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
253 notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
255 notmuch_message_remove_all_tags (notmuch_message_t *message);
257 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
259 notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
261 notmuch_message_freeze (notmuch_message_t *message);
263 notmuch_message_thaw (notmuch_message_t *message);
265 notmuch_message_get_property (notmuch_message_t *message,
266 const char *key, const char **value);
268 notmuch_message_add_property (notmuch_message_t *message,
269 const char *key, const char *value);
271 notmuch_message_remove_property (notmuch_message_t *message,
272 const char *key, const char *value);
274 notmuch_message_remove_all_properties (notmuch_message_t *message,
276 notmuch_message_properties_t *
277 notmuch_message_get_properties (notmuch_message_t *message,
278 const char *key, notmuch_bool_t exact);
280 notmuch_message_properties_valid (notmuch_message_properties_t
283 notmuch_message_properties_move_to_next (notmuch_message_properties_t
286 notmuch_message_properties_key (notmuch_message_properties_t *properties);
288 notmuch_message_properties_value (notmuch_message_properties_t
291 notmuch_message_properties_destroy (notmuch_message_properties_t
294 notmuch_message_destroy (notmuch_message_t *message);
297 notmuch_tags_valid (notmuch_tags_t *tags);
299 notmuch_tags_get (notmuch_tags_t *tags);
301 notmuch_tags_move_to_next (notmuch_tags_t *tags);
303 notmuch_tags_destroy (notmuch_tags_t *tags);
306 notmuch_filenames_valid (notmuch_filenames_t *filenames);
308 notmuch_filenames_get (notmuch_filenames_t *filenames);
310 notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
312 notmuch_filenames_destroy (notmuch_filenames_t *filenames);
313 notmuch_indexopts_t *
314 notmuch_database_get_default_indexopts (notmuch_database_t *db);
316 notmuch_indexopts_set_decrypt_policy (notmuch_indexopts_t *indexopts,
317 notmuch_decryption_policy_t decrypt_policy);
318 notmuch_decryption_policy_t
319 notmuch_indexopts_get_decrypt_policy (const notmuch_indexopts_t *indexopts);
321 notmuch_indexopts_destroy (notmuch_indexopts_t *options);
324 notmuch_database_set_config (notmuch_database_t *db, const char *key, const char *value);
326 notmuch_database_get_config (notmuch_database_t *db, const char *key, char **value);
328 notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out);
330 notmuch_config_list_valid (notmuch_config_list_t *config_list);
332 notmuch_config_list_key (notmuch_config_list_t *config_list);
334 notmuch_config_list_value (notmuch_config_list_t *config_list);
336 notmuch_config_list_move_to_next (notmuch_config_list_t *config_list);
338 notmuch_config_list_destroy (notmuch_config_list_t *config_list);
343 if __name__ == '__main__':
344 ffibuilder.compile(verbose=True)