2 * Copyright (C) 2006-7 Brendan Cully <brendan@kublai.com>
3 * Copyright (C) 2006 Rocco Rutte <pdmef@gmx.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * support for body cache
27 typedef struct body_cache body_cache_t;
31 * - 'account' is the current mailbox' account (required)
32 * - 'mailbox' is the path to the mailbox of the account (optional):
33 * the driver using it is responsible for ensuring that hierarchies
34 * are separated by '/' (if it knows of such a concepts like
35 * mailboxes or hierarchies)
36 * Returns NULL on failure.
38 body_cache_t *mutt_bcache_open (ACCOUNT *account, const char *mailbox);
40 /* free all memory of bcache and finally FREE() it, too */
41 void mutt_bcache_close (body_cache_t **bcache);
45 * - 'bcache' is the pointer returned by mutt_bcache_open() (required)
46 * - 'id' is a per-mailbox unique identifier for the message (required)
47 * These return NULL/-1 on failure and FILE pointer/0 on success.
50 FILE* mutt_bcache_get(body_cache_t *bcache, const char *id);
51 /* tmp: the returned FILE* is in a temporary location.
52 * if set, use mutt_bcache_commit to put it into place */
53 FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp);
54 int mutt_bcache_commit(body_cache_t *bcache, const char *id);
55 int mutt_bcache_move(body_cache_t *bcache, const char *id, const char *newid);
56 int mutt_bcache_del(body_cache_t *bcache, const char *id);
57 int mutt_bcache_exists(body_cache_t *bcache, const char *id);
60 * This more or less "examines" the cache and calls a function with
61 * each id it finds if given.
63 * The optional callback function gets the id of a message, the very same
64 * body cache handle mutt_bcache_list() is called with (to, perhaps,
65 * perform further operations on the bcache), and a data cookie which is
66 * just passed as-is. If the return value of the callback is non-zero, the
67 * listing is aborted and continued otherwise. The callback is optional
68 * so that this function can be used to count the items in the cache
69 * (see below for return value).
71 * This returns -1 on failure and the count (>=0) of items processed
74 int mutt_bcache_list(body_cache_t *bcache,
75 int (*want_id)(const char *id, body_cache_t *bcache,
76 void *data), void *data);
78 #endif /* _BCACHE_H_ */