|
static int | bcache_path (struct ConnAccount *account, const char *mailbox, struct BodyCache *bcache) |
| Create the cache path for a given account/mailbox.
|
|
static int | mutt_bcache_move (struct BodyCache *bcache, const char *id, const char *newid) |
| Change the id of a message in the cache.
|
|
struct BodyCache * | mutt_bcache_open (struct ConnAccount *account, const char *mailbox) |
| Open an Email-Body Cache.
|
|
void | mutt_bcache_close (struct BodyCache **ptr) |
| Close an Email-Body Cache.
|
|
FILE * | mutt_bcache_get (struct BodyCache *bcache, const char *id) |
| Open a file in the Body Cache.
|
|
FILE * | mutt_bcache_put (struct BodyCache *bcache, const char *id) |
| Create a file in the Body Cache.
|
|
int | mutt_bcache_commit (struct BodyCache *bcache, const char *id) |
| Move a temporary file into the Body Cache.
|
|
int | mutt_bcache_del (struct BodyCache *bcache, const char *id) |
| Delete a file from the Body Cache.
|
|
int | mutt_bcache_exists (struct BodyCache *bcache, const char *id) |
| Check if a file exists in the Body Cache.
|
|
int | mutt_bcache_list (struct BodyCache *bcache, bcache_list_t want_id, void *data) |
| Find matching entries in the Body Cache.
|
|
Body Caching (local copies of email bodies)
- Authors
- Richard Russon
- Pietro Cerutti
- Copyright
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file bcache.c.
Find matching entries in the Body Cache.
- Parameters
-
bcache | Body Cache from mutt_bcache_open() |
want_id | Callback function called for each match |
data | Data to pass to the callback function |
- Return values
-
-1 | Failure |
>=0 | count of matching items |
This more or less "examines" the cache and calls a function with each id it finds if given.
The optional callback function gets the id of a message, the very same body cache handle mutt_bcache_list() is called with (to, perhaps, perform further operations on the bcache), and a data cookie which is just passed as-is. If the return value of the callback is non-zero, the listing is aborted and continued otherwise. The callback is optional so that this function can be used to count the items in the cache (see below for return value).
Definition at line 334 of file bcache.c.
335{
336 DIR *dir = NULL;
337 struct dirent *de = NULL;
338 int rc = -1;
339
341 goto out;
342
343 rc = 0;
344
346
347 while ((de = readdir(dir)))
348 {
350 {
351 continue;
352 }
353
355
356 if (want_id && (want_id(de->d_name, bcache, data) != 0))
357 goto out;
358
359 rc++;
360 }
361
362out:
363 if (dir)
364 {
365 if (closedir(dir) < 0)
366 rc = -1;
367 }
369 return rc;
370}
DIR * mutt_file_opendir(const char *path, enum MuttOpenDirMode mode)
Open a directory.
@ MUTT_OPENDIR_NONE
Plain opendir()
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.