]> git.notmuchmail.org Git - notmuch/blob - bindings/python-cffi/notmuch2/_build.py
debian: drop patches
[notmuch] / bindings / python-cffi / notmuch2 / _build.py
1 import cffi
2
3
4 ffibuilder = cffi.FFI()
5 ffibuilder.set_source(
6     'notmuch2._capi',
7     r"""
8     #include <stdlib.h>
9     #include <time.h>
10     #include <notmuch.h>
11
12     #if LIBNOTMUCH_MAJOR_VERSION < 5
13         #error libnotmuch version not supported by notmuch2 python bindings
14     #endif
15     #if LIBNOTMUCH_MINOR_VERSION < 1
16         #ERROR libnotmuch  version < 5.1 not supported
17     #endif
18     """,
19     include_dirs=['../../lib'],
20     library_dirs=['../../lib'],
21     libraries=['notmuch'],
22 )
23 ffibuilder.cdef(
24     r"""
25     void free(void *ptr);
26     typedef int... time_t;
27
28     #define LIBNOTMUCH_MAJOR_VERSION ...
29     #define LIBNOTMUCH_MINOR_VERSION ...
30     #define LIBNOTMUCH_MICRO_VERSION ...
31
32     #define NOTMUCH_TAG_MAX ...
33
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_LAST_STATUS
51     } notmuch_status_t;
52     typedef enum {
53         NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
54         NOTMUCH_DATABASE_MODE_READ_WRITE
55     } notmuch_database_mode_t;
56     typedef int notmuch_bool_t;
57     typedef enum _notmuch_message_flag {
58         NOTMUCH_MESSAGE_FLAG_MATCH,
59         NOTMUCH_MESSAGE_FLAG_EXCLUDED,
60         NOTMUCH_MESSAGE_FLAG_GHOST,
61     } notmuch_message_flag_t;
62     typedef enum {
63         NOTMUCH_SORT_OLDEST_FIRST,
64         NOTMUCH_SORT_NEWEST_FIRST,
65         NOTMUCH_SORT_MESSAGE_ID,
66         NOTMUCH_SORT_UNSORTED
67     } notmuch_sort_t;
68     typedef enum {
69         NOTMUCH_EXCLUDE_FLAG,
70         NOTMUCH_EXCLUDE_TRUE,
71         NOTMUCH_EXCLUDE_FALSE,
72         NOTMUCH_EXCLUDE_ALL
73     } notmuch_exclude_t;
74     typedef enum {
75         NOTMUCH_DECRYPT_FALSE,
76         NOTMUCH_DECRYPT_TRUE,
77         NOTMUCH_DECRYPT_AUTO,
78         NOTMUCH_DECRYPT_NOSTASH,
79     } notmuch_decryption_policy_t;
80
81     // These are fully opaque types for us, we only ever use pointers.
82     typedef struct _notmuch_database notmuch_database_t;
83     typedef struct _notmuch_query notmuch_query_t;
84     typedef struct _notmuch_threads notmuch_threads_t;
85     typedef struct _notmuch_thread notmuch_thread_t;
86     typedef struct _notmuch_messages notmuch_messages_t;
87     typedef struct _notmuch_message notmuch_message_t;
88     typedef struct _notmuch_tags notmuch_tags_t;
89     typedef struct _notmuch_string_map_iterator notmuch_message_properties_t;
90     typedef struct _notmuch_directory notmuch_directory_t;
91     typedef struct _notmuch_filenames notmuch_filenames_t;
92     typedef struct _notmuch_config_list notmuch_config_list_t;
93     typedef struct _notmuch_indexopts notmuch_indexopts_t;
94
95     const char *
96     notmuch_status_to_string (notmuch_status_t status);
97
98     notmuch_status_t
99     notmuch_database_create_verbose (const char *path,
100                                      notmuch_database_t **database,
101                                      char **error_message);
102     notmuch_status_t
103     notmuch_database_create (const char *path, notmuch_database_t **database);
104     notmuch_status_t
105     notmuch_database_open_verbose (const char *path,
106                                    notmuch_database_mode_t mode,
107                                    notmuch_database_t **database,
108                                    char **error_message);
109     notmuch_status_t
110     notmuch_database_open (const char *path,
111                            notmuch_database_mode_t mode,
112                            notmuch_database_t **database);
113     notmuch_status_t
114     notmuch_database_close (notmuch_database_t *database);
115     notmuch_status_t
116     notmuch_database_destroy (notmuch_database_t *database);
117     const char *
118     notmuch_database_get_path (notmuch_database_t *database);
119     unsigned int
120     notmuch_database_get_version (notmuch_database_t *database);
121     notmuch_bool_t
122     notmuch_database_needs_upgrade (notmuch_database_t *database);
123     notmuch_status_t
124     notmuch_database_begin_atomic (notmuch_database_t *notmuch);
125     notmuch_status_t
126     notmuch_database_end_atomic (notmuch_database_t *notmuch);
127     unsigned long
128     notmuch_database_get_revision (notmuch_database_t *notmuch,
129                                    const char **uuid);
130     notmuch_status_t
131     notmuch_database_index_file (notmuch_database_t *database,
132                                  const char *filename,
133                                  notmuch_indexopts_t *indexopts,
134                                  notmuch_message_t **message);
135     notmuch_status_t
136     notmuch_database_remove_message (notmuch_database_t *database,
137                                      const char *filename);
138     notmuch_status_t
139     notmuch_database_find_message (notmuch_database_t *database,
140                                    const char *message_id,
141                                    notmuch_message_t **message);
142     notmuch_status_t
143     notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
144                                                const char *filename,
145                                                notmuch_message_t **message);
146     notmuch_tags_t *
147     notmuch_database_get_all_tags (notmuch_database_t *db);
148
149     notmuch_query_t *
150     notmuch_query_create (notmuch_database_t *database,
151                           const char *query_string);
152     const char *
153     notmuch_query_get_query_string (const notmuch_query_t *query);
154     notmuch_database_t *
155     notmuch_query_get_database (const notmuch_query_t *query);
156     void
157     notmuch_query_set_omit_excluded (notmuch_query_t *query,
158                                      notmuch_exclude_t omit_excluded);
159     void
160     notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
161     notmuch_sort_t
162     notmuch_query_get_sort (const notmuch_query_t *query);
163     notmuch_status_t
164     notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
165     notmuch_status_t
166     notmuch_query_search_threads (notmuch_query_t *query,
167                                   notmuch_threads_t **out);
168     notmuch_status_t
169     notmuch_query_search_messages (notmuch_query_t *query,
170                                    notmuch_messages_t **out);
171     notmuch_status_t
172     notmuch_query_count_messages (notmuch_query_t *query, unsigned int *count);
173     notmuch_status_t
174     notmuch_query_count_threads (notmuch_query_t *query, unsigned *count);
175     void
176     notmuch_query_destroy (notmuch_query_t *query);
177
178     notmuch_bool_t
179     notmuch_threads_valid (notmuch_threads_t *threads);
180     notmuch_thread_t *
181     notmuch_threads_get (notmuch_threads_t *threads);
182     void
183     notmuch_threads_move_to_next (notmuch_threads_t *threads);
184     void
185     notmuch_threads_destroy (notmuch_threads_t *threads);
186
187     const char *
188     notmuch_thread_get_thread_id (notmuch_thread_t *thread);
189     notmuch_messages_t *
190     notmuch_message_get_replies (notmuch_message_t *message);
191     int
192     notmuch_thread_get_total_messages (notmuch_thread_t *thread);
193     notmuch_messages_t *
194     notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
195     notmuch_messages_t *
196     notmuch_thread_get_messages (notmuch_thread_t *thread);
197     int
198     notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
199     const char *
200     notmuch_thread_get_authors (notmuch_thread_t *thread);
201     const char *
202     notmuch_thread_get_subject (notmuch_thread_t *thread);
203     time_t
204     notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
205     time_t
206     notmuch_thread_get_newest_date (notmuch_thread_t *thread);
207     notmuch_tags_t *
208     notmuch_thread_get_tags (notmuch_thread_t *thread);
209     void
210     notmuch_thread_destroy (notmuch_thread_t *thread);
211
212     notmuch_bool_t
213     notmuch_messages_valid (notmuch_messages_t *messages);
214     notmuch_message_t *
215     notmuch_messages_get (notmuch_messages_t *messages);
216     void
217     notmuch_messages_move_to_next (notmuch_messages_t *messages);
218     void
219     notmuch_messages_destroy (notmuch_messages_t *messages);
220     notmuch_tags_t *
221     notmuch_messages_collect_tags (notmuch_messages_t *messages);
222
223     const char *
224     notmuch_message_get_message_id (notmuch_message_t *message);
225     const char *
226     notmuch_message_get_thread_id (notmuch_message_t *message);
227     const char *
228     notmuch_message_get_filename (notmuch_message_t *message);
229     notmuch_filenames_t *
230     notmuch_message_get_filenames (notmuch_message_t *message);
231     notmuch_bool_t
232     notmuch_message_get_flag (notmuch_message_t *message,
233                               notmuch_message_flag_t flag);
234     void
235     notmuch_message_set_flag (notmuch_message_t *message,
236                               notmuch_message_flag_t flag,
237                               notmuch_bool_t value);
238     time_t
239     notmuch_message_get_date  (notmuch_message_t *message);
240     const char *
241     notmuch_message_get_header (notmuch_message_t *message,
242                                 const char *header);
243     notmuch_tags_t *
244     notmuch_message_get_tags (notmuch_message_t *message);
245     notmuch_status_t
246     notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
247     notmuch_status_t
248     notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
249     notmuch_status_t
250     notmuch_message_remove_all_tags (notmuch_message_t *message);
251     notmuch_status_t
252     notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
253     notmuch_status_t
254     notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
255     notmuch_status_t
256     notmuch_message_freeze (notmuch_message_t *message);
257     notmuch_status_t
258     notmuch_message_thaw (notmuch_message_t *message);
259     notmuch_status_t
260     notmuch_message_get_property (notmuch_message_t *message,
261                                   const char *key, const char **value);
262     notmuch_status_t
263     notmuch_message_add_property (notmuch_message_t *message,
264                                   const char *key, const char *value);
265     notmuch_status_t
266     notmuch_message_remove_property (notmuch_message_t *message,
267                                      const char *key, const char *value);
268     notmuch_status_t
269     notmuch_message_remove_all_properties (notmuch_message_t *message,
270                                            const char *key);
271     notmuch_message_properties_t *
272     notmuch_message_get_properties (notmuch_message_t *message,
273                                     const char *key, notmuch_bool_t exact);
274     notmuch_bool_t
275     notmuch_message_properties_valid (notmuch_message_properties_t
276                                           *properties);
277     void
278     notmuch_message_properties_move_to_next (notmuch_message_properties_t
279                                                  *properties);
280     const char *
281     notmuch_message_properties_key (notmuch_message_properties_t *properties);
282     const char *
283     notmuch_message_properties_value (notmuch_message_properties_t
284                                           *properties);
285     void
286     notmuch_message_properties_destroy (notmuch_message_properties_t
287                                             *properties);
288     void
289     notmuch_message_destroy (notmuch_message_t *message);
290
291     notmuch_bool_t
292     notmuch_tags_valid (notmuch_tags_t *tags);
293     const char *
294     notmuch_tags_get (notmuch_tags_t *tags);
295     void
296     notmuch_tags_move_to_next (notmuch_tags_t *tags);
297     void
298     notmuch_tags_destroy (notmuch_tags_t *tags);
299
300     notmuch_bool_t
301     notmuch_filenames_valid (notmuch_filenames_t *filenames);
302     const char *
303     notmuch_filenames_get (notmuch_filenames_t *filenames);
304     void
305     notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
306     void
307     notmuch_filenames_destroy (notmuch_filenames_t *filenames);
308     notmuch_indexopts_t *
309     notmuch_database_get_default_indexopts (notmuch_database_t *db);
310     notmuch_status_t
311     notmuch_indexopts_set_decrypt_policy (notmuch_indexopts_t *indexopts,
312                                           notmuch_decryption_policy_t decrypt_policy);
313     notmuch_decryption_policy_t
314     notmuch_indexopts_get_decrypt_policy (const notmuch_indexopts_t *indexopts);
315     void
316     notmuch_indexopts_destroy (notmuch_indexopts_t *options);
317
318     notmuch_status_t
319     notmuch_database_set_config (notmuch_database_t *db, const char *key, const char *value);
320     notmuch_status_t
321     notmuch_database_get_config (notmuch_database_t *db, const char *key, char **value);
322     notmuch_status_t
323     notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out);
324     notmuch_bool_t
325     notmuch_config_list_valid (notmuch_config_list_t *config_list);
326     const char *
327     notmuch_config_list_key (notmuch_config_list_t *config_list);
328     const char *
329     notmuch_config_list_value (notmuch_config_list_t *config_list);
330     void
331     notmuch_config_list_move_to_next (notmuch_config_list_t *config_list);
332     void
333     notmuch_config_list_destroy (notmuch_config_list_t *config_list);
334     """
335 )
336
337
338 if __name__ == '__main__':
339     ffibuilder.compile(verbose=True)