NeoMutt  2021-10-29-43-g6b8931
Teaching an old dog new tricks
DOXYGEN
Body Cache Callback API

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

Functions

static int msg_cache_clean_cb (const char *id, struct BodyCache *bcache, void *data)
 Delete an entry from the message cache - Implements bcache_list_t -. More...
 
static int nntp_bcache_delete (const char *id, struct BodyCache *bcache, void *data)
 Remove bcache file - Implements bcache_list_t -. More...
 
static int msg_cache_check (const char *id, struct BodyCache *bcache, void *data)
 Check the Body Cache for an ID - Implements bcache_list_t -. More...
 

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

◆ msg_cache_clean_cb()

static int msg_cache_clean_cb ( 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 168 of file message.c.

169 {
170  uint32_t uv;
171  unsigned int uid;
172  struct ImapMboxData *mdata = data;
173 
174  if (sscanf(id, "%u-%u", &uv, &uid) != 2)
175  return 0;
176 
177  /* bad UID */
178  if ((uv != mdata->uidvalidity) || !mutt_hash_int_find(mdata->uid_hash, uid))
179  mutt_bcache_del(bcache, id);
180 
181  return 0;
182 }
int mutt_bcache_del(struct BodyCache *bcache, const char *id)
Delete a file from the Body Cache.
Definition: bcache.c:264
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:39
struct BodyCache * bcache
Email body cache.
Definition: mdata.h:60
void * mdata
Driver specific data.
Definition: mailbox.h:136
+ 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

Remove bcache file - Implements bcache_list_t -.

Return values
0Always

Definition at line 785 of file newsrc.c.

786 {
787  struct NntpMboxData *mdata = data;
788  anum_t anum;
789  char c;
790 
791  if (!mdata || (sscanf(id, ANUM "%c", &anum, &c) != 1) ||
792  (anum < mdata->first_message) || (anum > mdata->last_message))
793  {
794  if (mdata)
795  mutt_debug(LL_DEBUG2, "mutt_bcache_del %s\n", id);
796  mutt_bcache_del(bcache, id);
797  }
798  return 0;
799 }
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
#define ANUM
Definition: lib.h:61
#define anum_t
Definition: lib.h:60
NNTP-specific Mailbox data -.
Definition: mdata.h:33
struct BodyCache * bcache
Definition: mdata.h:49
anum_t first_message
Definition: mdata.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msg_cache_check()

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

Check the Body Cache for an ID - Implements bcache_list_t -.

Definition at line 253 of file pop.c.

254 {
255  struct Mailbox *m = data;
256  if (!m)
257  return -1;
258 
259  struct PopAccountData *adata = pop_adata_get(m);
260  if (!adata)
261  return -1;
262 
263 #ifdef USE_HCACHE
264  /* keep hcache file if hcache == bcache */
265  if (strcmp(HC_FNAME "." HC_FEXT, id) == 0)
266  return 0;
267 #endif
268 
269  for (int i = 0; i < m->msg_count; i++)
270  {
271  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
272  /* if the id we get is known for a header: done (i.e. keep in cache) */
273  if (edata->uid && mutt_str_equal(edata->uid, id))
274  return 0;
275  }
276 
277  /* message not found in context -> remove it from cache
278  * return the result of bcache, so we stop upon its first error */
279  return mutt_bcache_del(bcache, cache_id(id));
280 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:715
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:64
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: edata.c:65
#define HC_FNAME
Definition: pop.c:71
static const char * cache_id(const char *id)
Make a message-cache-compatible id.
Definition: pop.c:83
#define HC_FEXT
Definition: pop.c:72
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
void * edata
Driver-specific data.
Definition: email.h:72
A mailbox.
Definition: mailbox.h:82
int msg_count
Total number of messages.
Definition: mailbox.h:91
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
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: