unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 5e1fcac15f3fbbf5c57dd0210d6f563f3f379b98 12585 bytes (raw)
name: bindings/python-cffi/notmuch2/_build.py 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
 
import cffi


ffibuilder = cffi.FFI()
ffibuilder.set_source(
    'notmuch2._capi',
    r"""
    #include <stdlib.h>
    #include <time.h>
    #include <notmuch.h>

    #if LIBNOTMUCH_MAJOR_VERSION < 5
        #error libnotmuch version not supported by notmuch2 python bindings
    #endif
    #if LIBNOTMUCH_MINOR_VERSION < 1
        #ERROR libnotmuch  version < 5.1 not supported
    #endif
    """,
    include_dirs=['../../lib'],
    library_dirs=['../../lib'],
    libraries=['notmuch'],
)
ffibuilder.cdef(
    r"""
    void free(void *ptr);
    typedef int... time_t;

    #define LIBNOTMUCH_MAJOR_VERSION ...
    #define LIBNOTMUCH_MINOR_VERSION ...
    #define LIBNOTMUCH_MICRO_VERSION ...

    #define NOTMUCH_TAG_MAX ...

    typedef enum _notmuch_status {
        NOTMUCH_STATUS_SUCCESS = 0,
        NOTMUCH_STATUS_OUT_OF_MEMORY,
        NOTMUCH_STATUS_READ_ONLY_DATABASE,
        NOTMUCH_STATUS_XAPIAN_EXCEPTION,
        NOTMUCH_STATUS_FILE_ERROR,
        NOTMUCH_STATUS_FILE_NOT_EMAIL,
        NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
        NOTMUCH_STATUS_NULL_POINTER,
        NOTMUCH_STATUS_TAG_TOO_LONG,
        NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
        NOTMUCH_STATUS_UNBALANCED_ATOMIC,
        NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
        NOTMUCH_STATUS_UPGRADE_REQUIRED,
        NOTMUCH_STATUS_PATH_ERROR,
        NOTMUCH_STATUS_ILLEGAL_ARGUMENT,
        NOTMUCH_STATUS_LAST_STATUS
    } notmuch_status_t;
    typedef enum {
        NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
        NOTMUCH_DATABASE_MODE_READ_WRITE
    } notmuch_database_mode_t;
    typedef int notmuch_bool_t;
    typedef enum _notmuch_message_flag {
        NOTMUCH_MESSAGE_FLAG_MATCH,
        NOTMUCH_MESSAGE_FLAG_EXCLUDED,
        NOTMUCH_MESSAGE_FLAG_GHOST,
    } notmuch_message_flag_t;
    typedef enum {
        NOTMUCH_SORT_OLDEST_FIRST,
        NOTMUCH_SORT_NEWEST_FIRST,
        NOTMUCH_SORT_MESSAGE_ID,
        NOTMUCH_SORT_UNSORTED
    } notmuch_sort_t;
    typedef enum {
        NOTMUCH_EXCLUDE_FLAG,
        NOTMUCH_EXCLUDE_TRUE,
        NOTMUCH_EXCLUDE_FALSE,
        NOTMUCH_EXCLUDE_ALL
    } notmuch_exclude_t;
    typedef enum {
        NOTMUCH_DECRYPT_FALSE,
        NOTMUCH_DECRYPT_TRUE,
        NOTMUCH_DECRYPT_AUTO,
        NOTMUCH_DECRYPT_NOSTASH,
    } notmuch_decryption_policy_t;

    // These are fully opaque types for us, we only ever use pointers.
    typedef struct _notmuch_database notmuch_database_t;
    typedef struct _notmuch_query notmuch_query_t;
    typedef struct _notmuch_threads notmuch_threads_t;
    typedef struct _notmuch_thread notmuch_thread_t;
    typedef struct _notmuch_messages notmuch_messages_t;
    typedef struct _notmuch_message notmuch_message_t;
    typedef struct _notmuch_tags notmuch_tags_t;
    typedef struct _notmuch_string_map_iterator notmuch_message_properties_t;
    typedef struct _notmuch_directory notmuch_directory_t;
    typedef struct _notmuch_filenames notmuch_filenames_t;
    typedef struct _notmuch_config_list notmuch_config_list_t;
    typedef struct _notmuch_indexopts notmuch_indexopts_t;

    const char *
    notmuch_status_to_string (notmuch_status_t status);

    notmuch_status_t
    notmuch_database_create_verbose (const char *path,
                                     notmuch_database_t **database,
                                     char **error_message);
    notmuch_status_t
    notmuch_database_create (const char *path, notmuch_database_t **database);
    notmuch_status_t
    notmuch_database_open_verbose (const char *path,
                                   notmuch_database_mode_t mode,
                                   notmuch_database_t **database,
                                   char **error_message);
    notmuch_status_t
    notmuch_database_open (const char *path,
                           notmuch_database_mode_t mode,
                           notmuch_database_t **database);
    notmuch_status_t
    notmuch_database_close (notmuch_database_t *database);
    notmuch_status_t
    notmuch_database_destroy (notmuch_database_t *database);
    const char *
    notmuch_database_get_path (notmuch_database_t *database);
    unsigned int
    notmuch_database_get_version (notmuch_database_t *database);
    notmuch_bool_t
    notmuch_database_needs_upgrade (notmuch_database_t *database);
    notmuch_status_t
    notmuch_database_begin_atomic (notmuch_database_t *notmuch);
    notmuch_status_t
    notmuch_database_end_atomic (notmuch_database_t *notmuch);
    unsigned long
    notmuch_database_get_revision (notmuch_database_t *notmuch,
                                   const char **uuid);
    notmuch_status_t
    notmuch_database_index_file (notmuch_database_t *database,
                                 const char *filename,
                                 notmuch_indexopts_t *indexopts,
                                 notmuch_message_t **message);
    notmuch_status_t
    notmuch_database_remove_message (notmuch_database_t *database,
                                     const char *filename);
    notmuch_status_t
    notmuch_database_find_message (notmuch_database_t *database,
                                   const char *message_id,
                                   notmuch_message_t **message);
    notmuch_status_t
    notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
                                               const char *filename,
                                               notmuch_message_t **message);
    notmuch_tags_t *
    notmuch_database_get_all_tags (notmuch_database_t *db);

    notmuch_query_t *
    notmuch_query_create (notmuch_database_t *database,
                          const char *query_string);
    const char *
    notmuch_query_get_query_string (const notmuch_query_t *query);
    notmuch_database_t *
    notmuch_query_get_database (const notmuch_query_t *query);
    void
    notmuch_query_set_omit_excluded (notmuch_query_t *query,
                                     notmuch_exclude_t omit_excluded);
    void
    notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
    notmuch_sort_t
    notmuch_query_get_sort (const notmuch_query_t *query);
    notmuch_status_t
    notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
    notmuch_status_t
    notmuch_query_search_threads (notmuch_query_t *query,
                                  notmuch_threads_t **out);
    notmuch_status_t
    notmuch_query_search_messages (notmuch_query_t *query,
                                   notmuch_messages_t **out);
    notmuch_status_t
    notmuch_query_count_messages (notmuch_query_t *query, unsigned int *count);
    notmuch_status_t
    notmuch_query_count_threads (notmuch_query_t *query, unsigned *count);
    void
    notmuch_query_destroy (notmuch_query_t *query);

    notmuch_bool_t
    notmuch_threads_valid (notmuch_threads_t *threads);
    notmuch_thread_t *
    notmuch_threads_get (notmuch_threads_t *threads);
    void
    notmuch_threads_move_to_next (notmuch_threads_t *threads);
    void
    notmuch_threads_destroy (notmuch_threads_t *threads);

    const char *
    notmuch_thread_get_thread_id (notmuch_thread_t *thread);
    notmuch_messages_t *
    notmuch_message_get_replies (notmuch_message_t *message);
    int
    notmuch_thread_get_total_messages (notmuch_thread_t *thread);
    notmuch_messages_t *
    notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
    notmuch_messages_t *
    notmuch_thread_get_messages (notmuch_thread_t *thread);
    int
    notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
    const char *
    notmuch_thread_get_authors (notmuch_thread_t *thread);
    const char *
    notmuch_thread_get_subject (notmuch_thread_t *thread);
    time_t
    notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
    time_t
    notmuch_thread_get_newest_date (notmuch_thread_t *thread);
    notmuch_tags_t *
    notmuch_thread_get_tags (notmuch_thread_t *thread);
    void
    notmuch_thread_destroy (notmuch_thread_t *thread);

    notmuch_bool_t
    notmuch_messages_valid (notmuch_messages_t *messages);
    notmuch_message_t *
    notmuch_messages_get (notmuch_messages_t *messages);
    void
    notmuch_messages_move_to_next (notmuch_messages_t *messages);
    void
    notmuch_messages_destroy (notmuch_messages_t *messages);
    notmuch_tags_t *
    notmuch_messages_collect_tags (notmuch_messages_t *messages);

    const char *
    notmuch_message_get_message_id (notmuch_message_t *message);
    const char *
    notmuch_message_get_thread_id (notmuch_message_t *message);
    const char *
    notmuch_message_get_filename (notmuch_message_t *message);
    notmuch_filenames_t *
    notmuch_message_get_filenames (notmuch_message_t *message);
    notmuch_bool_t
    notmuch_message_get_flag (notmuch_message_t *message,
                              notmuch_message_flag_t flag);
    void
    notmuch_message_set_flag (notmuch_message_t *message,
                              notmuch_message_flag_t flag,
                              notmuch_bool_t value);
    time_t
    notmuch_message_get_date  (notmuch_message_t *message);
    const char *
    notmuch_message_get_header (notmuch_message_t *message,
                                const char *header);
    notmuch_tags_t *
    notmuch_message_get_tags (notmuch_message_t *message);
    notmuch_status_t
    notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
    notmuch_status_t
    notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
    notmuch_status_t
    notmuch_message_remove_all_tags (notmuch_message_t *message);
    notmuch_status_t
    notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
    notmuch_status_t
    notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
    notmuch_status_t
    notmuch_message_freeze (notmuch_message_t *message);
    notmuch_status_t
    notmuch_message_thaw (notmuch_message_t *message);
    notmuch_status_t
    notmuch_message_get_property (notmuch_message_t *message,
                                  const char *key, const char **value);
    notmuch_status_t
    notmuch_message_add_property (notmuch_message_t *message,
                                  const char *key, const char *value);
    notmuch_status_t
    notmuch_message_remove_property (notmuch_message_t *message,
                                     const char *key, const char *value);
    notmuch_status_t
    notmuch_message_remove_all_properties (notmuch_message_t *message,
                                           const char *key);
    notmuch_message_properties_t *
    notmuch_message_get_properties (notmuch_message_t *message,
                                    const char *key, notmuch_bool_t exact);
    notmuch_bool_t
    notmuch_message_properties_valid (notmuch_message_properties_t
                                          *properties);
    void
    notmuch_message_properties_move_to_next (notmuch_message_properties_t
                                                 *properties);
    const char *
    notmuch_message_properties_key (notmuch_message_properties_t *properties);
    const char *
    notmuch_message_properties_value (notmuch_message_properties_t
                                          *properties);
    void
    notmuch_message_properties_destroy (notmuch_message_properties_t
                                            *properties);
    void
    notmuch_message_destroy (notmuch_message_t *message);

    notmuch_bool_t
    notmuch_tags_valid (notmuch_tags_t *tags);
    const char *
    notmuch_tags_get (notmuch_tags_t *tags);
    void
    notmuch_tags_move_to_next (notmuch_tags_t *tags);
    void
    notmuch_tags_destroy (notmuch_tags_t *tags);

    notmuch_bool_t
    notmuch_filenames_valid (notmuch_filenames_t *filenames);
    const char *
    notmuch_filenames_get (notmuch_filenames_t *filenames);
    void
    notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
    void
    notmuch_filenames_destroy (notmuch_filenames_t *filenames);
    notmuch_indexopts_t *
    notmuch_database_get_default_indexopts (notmuch_database_t *db);
    notmuch_status_t
    notmuch_indexopts_set_decrypt_policy (notmuch_indexopts_t *indexopts,
                                          notmuch_decryption_policy_t decrypt_policy);
    notmuch_decryption_policy_t
    notmuch_indexopts_get_decrypt_policy (const notmuch_indexopts_t *indexopts);
    void
    notmuch_indexopts_destroy (notmuch_indexopts_t *options);
    """
)


if __name__ == '__main__':
    ffibuilder.compile(verbose=True)

debug log:

solving 5e1fcac1 ...
found 5e1fcac1 in https://yhetil.org/notmuch.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).