NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Body Cache Callback API

Prototype for a mutt_bcache_list() callback function. More...

Functions

static int imap_bcache_delete (const char *id, struct BodyCache *bcache, void *data)
 Delete an entry from the message cache - Implements bcache_list_t -.
 
static int nntp_bcache_delete (const char *id, struct BodyCache *bcache, void *data)
 Delete an entry from the message cache - Implements bcache_list_t -.
 
static int pop_bcache_delete (const char *id, struct BodyCache *bcache, void *data)
 Delete an entry from the message cache - Implements bcache_list_t -.
 

Detailed Description

Prototype for a mutt_bcache_list() callback function.

Parameters
idCache id
bcacheBody Cache from mutt_bcache_open()
dataData to pass to the callback function
Return values
-1Failure
>=0count of matching items

mutt_bcache_list() will call this function once for each item in the cache.

Function Documentation

◆ imap_bcache_delete()

static int imap_bcache_delete ( const char *  id,
struct BodyCache bcache,
void *  data 
)
static

Delete an entry from the message cache - Implements bcache_list_t -.

Return values
0Always

Definition at line 169 of file message.c.

170{
171 uint32_t uv = 0;
172 unsigned int uid = 0;
173 struct ImapMboxData *mdata = data;
174
175 if (sscanf(id, "%u-%u", &uv, &uid) != 2)
176 return 0;
177
178 /* bad UID */
179 if ((uv != mdata->uidvalidity) || !mutt_hash_int_find(mdata->uid_hash, uid))
181
182 return 0;
183}
int mutt_bcache_del(struct BodyCache *bcache, const char *id)
Delete a file from the Body Cache.
Definition: bcache.c:269
void * mutt_hash_int_find(const struct HashTable *table, unsigned int intkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:392
IMAP-specific Mailbox data -.
Definition: mdata.h:40
struct BodyCache * bcache
Email body cache.
Definition: mdata.h:61
void * mdata
Driver specific data.
Definition: mailbox.h:132
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nntp_bcache_delete()

static int nntp_bcache_delete ( const char *  id,
struct BodyCache bcache,
void *  data 
)
static

Delete an entry from the message cache - Implements bcache_list_t -.

Return values
0Always

Definition at line 779 of file newsrc.c.

780{
781 struct NntpMboxData *mdata = data;
782 anum_t anum = 0;
783 char c = '\0';
784
785 if (!mdata || (sscanf(id, ANUM_FMT "%c", &anum, &c) != 1) ||
786 (anum < mdata->first_message) || (anum > mdata->last_message))
787 {
788 if (mdata)
789 mutt_debug(LL_DEBUG2, "mutt_bcache_del %s\n", id);
791 }
792 return 0;
793}
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
#define ANUM_FMT
Definition: lib.h:63
#define anum_t
Definition: lib.h:62
NNTP-specific Mailbox data -.
Definition: mdata.h:34
struct BodyCache * bcache
Definition: mdata.h:50
anum_t first_message
Definition: mdata.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_bcache_delete()

static int pop_bcache_delete ( const char *  id,
struct BodyCache bcache,
void *  data 
)
static

Delete an entry from the message cache - Implements bcache_list_t -.

Definition at line 255 of file pop.c.

256{
257 struct Mailbox *m = data;
258 if (!m)
259 return -1;
260
262 if (!adata)
263 return -1;
264
265#ifdef USE_HCACHE
266 /* keep hcache file if hcache == bcache */
267 if (mutt_str_equal(HC_FNAME "." HC_FEXT, id))
268 return 0;
269#endif
270
271 for (int i = 0; i < m->msg_count; i++)
272 {
273 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
274 /* if the id we get is known for a header: done (i.e. keep in cache) */
275 if (edata->uid && mutt_str_equal(edata->uid, id))
276 return 0;
277 }
278
279 /* message not found in context -> remove it from cache
280 * return the result of bcache, so we stop upon its first error */
281 return mutt_bcache_del(bcache, cache_id(id));
282}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:73
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: edata.c:68
#define HC_FNAME
Definition: pop.c:69
static const char * cache_id(const char *id)
Make a message-cache-compatible id.
Definition: pop.c:81
#define HC_FEXT
Definition: pop.c:70
void * adata
Private data (for Mailbox backends)
Definition: account.h:42
void * edata
Driver-specific data.
Definition: email.h:74
A mailbox.
Definition: mailbox.h:79
int msg_count
Total number of messages.
Definition: mailbox.h:88
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
POP-specific Account data -.
Definition: adata.h:37
POP-specific Email data -.
Definition: edata.h:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function: