#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
|
struct HeaderCache * | mutt_hcache_open (const char *path, const char *folder, hcache_namer_t namer) |
| open the connection to the header cache More...
|
|
void | mutt_hcache_close (struct HeaderCache *hc) |
| close the connection to the header cache More...
|
|
int | mutt_hcache_store (struct HeaderCache *hc, const char *key, size_t keylen, struct Email *e, uint32_t uidvalidity) |
| store a Header along with a validity datum More...
|
|
struct HCacheEntry | mutt_hcache_fetch (struct HeaderCache *hc, const char *key, size_t keylen, uint32_t uidvalidity) |
| fetch and validate a message's header from the cache More...
|
|
int | mutt_hcache_store_raw (struct HeaderCache *hc, const char *key, size_t keylen, void *data, size_t dlen) |
| store a key / data pair More...
|
|
void * | mutt_hcache_fetch_raw (struct HeaderCache *hc, const char *key, size_t keylen, size_t *dlen) |
| Fetch a message's header from the cache. More...
|
|
void | mutt_hcache_free_raw (struct HeaderCache *hc, void **data) |
| free data fetched with mutt_hcache_fetch_raw() More...
|
|
int | mutt_hcache_delete_record (struct HeaderCache *hc, const char *key, size_t keylen) |
| delete a key / data pair More...
|
|
Header cache multiplexor
- Authors
- Thomas Glanzmann
- Tobias Werth
- Brian Fundakowski Feldman
- Pietro Cerutti
- Tino Reichardt
- 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 lib.h.
◆ hcache_namer_t
typedef void(* hcache_namer_t) (const char *path, struct Buffer *dest) |
Prototype for function to compose hcache file names.
- Parameters
-
path | Path of message |
dest | Buffer for filename |
Definition at line 108 of file lib.h.
◆ mutt_hcache_open()
open the connection to the header cache
- Parameters
-
path | Location of the header cache (often as specified by the user) |
folder | Name of the folder containing the messages |
namer | Optional (might be NULL) client-specific function to form the final name of the hcache database file. |
- Return values
-
open the connection to the header cache
Definition at line 322 of file hcache.c.
335 unsigned char charval[16];
367 #ifdef USE_HCACHE_COMPRESSION
387 if (!path || (path[0] ==
'\0'))
◆ mutt_hcache_close()
close the connection to the header cache
- Parameters
-
close the connection to the header cache
Definition at line 419 of file hcache.c.
425 #ifdef USE_HCACHE_COMPRESSION
◆ mutt_hcache_store()
int mutt_hcache_store |
( |
struct HeaderCache * |
hc, |
|
|
const char * |
key, |
|
|
size_t |
keylen, |
|
|
struct Email * |
e, |
|
|
uint32_t |
uidvalidity |
|
) |
| |
store a Header along with a validity datum
- Parameters
-
hc | Pointer to the struct HeaderCache structure got by mutt_hcache_open() |
key | Message identification string |
keylen | Length of the key string |
e | Email to store |
uidvalidity | IMAP-specific UIDVALIDITY value, or 0 to use the current time |
- Return values
-
0 | Success |
num | Generic or backend-specific error code otherwise |
store a Header along with a validity datum
Definition at line 527 of file hcache.c.
534 char *data =
dump(hc, e, &dlen, uidvalidity);
536 #ifdef USE_HCACHE_COMPRESSION
547 void *cdata = cops->
compress(hc->
cctx, data + hlen, dlen - hlen, &clen);
555 memcpy(whole, data, hlen);
556 memcpy(whole + hlen, cdata, clen);
◆ mutt_hcache_fetch()
struct HCacheEntry mutt_hcache_fetch |
( |
struct HeaderCache * |
hc, |
|
|
const char * |
key, |
|
|
size_t |
keylen, |
|
|
uint32_t |
uidvalidity |
|
) |
| |
fetch and validate a message's header from the cache
- Parameters
-
hc | Pointer to the struct HeaderCache structure got by mutt_hcache_open() |
key | Message identification string |
keylen | Length of the string pointed to by key |
uidvalidity | Only restore if it matches the stored uidvalidity |
- Return values
-
- Note
- This function performs a check on the validity of the data found by comparing it with the crc value of the struct HeaderCache structure.
fetch and validate a message's header from the cache
Definition at line 438 of file hcache.c.
446 void *to_free = data;
457 assert((
size_t) off == hlen);
463 #ifdef USE_HCACHE_COMPRESSION
468 void *dblob = cops->
decompress(hc->
cctx, (
char *) data + hlen, dlen - hlen);
473 data = (
char *) dblob - hlen;
◆ mutt_hcache_store_raw()
int mutt_hcache_store_raw |
( |
struct HeaderCache * |
hc, |
|
|
const char * |
key, |
|
|
size_t |
keylen, |
|
|
void * |
data, |
|
|
size_t |
dlen |
|
) |
| |
store a key / data pair
- Parameters
-
hc | Pointer to the struct HeaderCache structure got by mutt_hcache_open() |
key | Message identification string |
keylen | Length of the string pointed to by key |
data | Payload to associate with key |
dlen | Length of the buffer pointed to by the data parameter |
- Return values
-
0 | Success |
num | Generic or backend-specific error code otherwise |
Definition at line 584 of file hcache.c.
◆ mutt_hcache_fetch_raw()
void* mutt_hcache_fetch_raw |
( |
struct HeaderCache * |
hc, |
|
|
const char * |
key, |
|
|
size_t |
keylen, |
|
|
size_t * |
dlen |
|
) |
| |
Fetch a message's header from the cache.
- Parameters
-
[in] | hc | Pointer to the struct HeaderCache structure got by mutt_hcache_open() |
[in] | key | Message identification string |
[in] | keylen | Length of the string pointed to by key |
[out] | dlen | Length of the fetched data |
- Return values
-
ptr | Success, the data if found |
NULL | Otherwise |
- Note
- This function does not perform any check on the validity of the data found.
-
The returned data must be free with mutt_hcache_free_raw().
Definition at line 496 of file hcache.c.
◆ mutt_hcache_free_raw()
void mutt_hcache_free_raw |
( |
struct HeaderCache * |
hc, |
|
|
void ** |
data |
|
) |
| |
◆ mutt_hcache_delete_record()
int mutt_hcache_delete_record |
( |
struct HeaderCache * |
hc, |
|
|
const char * |
key, |
|
|
size_t |
keylen |
|
) |
| |
delete a key / data pair
- Parameters
-
- Return values
-
0 | Success |
num | Generic or backend-specific error code otherwise |
delete a key / data pair
Definition at line 604 of file hcache.c.
◆ C_HeaderCache
Config: (hcache) Directory/file for the header cache database.
Definition at line 40 of file config.c.
◆ C_HeaderCacheBackend
char* C_HeaderCacheBackend |
Config: (hcache) Header cache backend to use.
Definition at line 41 of file config.c.
◆ C_HeaderCacheCompressLevel
short C_HeaderCacheCompressLevel |
Config: (hcache) Level of compression for method.
Definition at line 43 of file config.c.
◆ C_HeaderCacheCompressMethod
char* C_HeaderCacheCompressMethod |
Config: (hcache) Enable generic hcache database compression.
Definition at line 44 of file config.c.
static void * dump(struct HeaderCache *hc, const struct Email *e, int *off, uint32_t uidvalidity)
Serialise an Email object.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
static struct Email * restore(const unsigned char *d)
Restore an Email from data retrieved from the cache.
int mutt_hcache_store_raw(struct HeaderCache *hc, const char *key, size_t keylen, void *data, size_t dlen)
store a key / data pair
void serial_restore_uint32_t(uint32_t *s, const unsigned char *d, int *off)
Unpack an uint32_t from a binary blob.
String manipulation buffer.
@ LL_DEBUG3
Log at debug level 3.
Cursor for the MD5 hashing.
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
const char * name
Compression name.
void *(* open)(short level)
Open a compression context.
void * mutt_md5_finish_ctx(struct Md5Ctx *md5ctx, void *resbuf)
Process the remaining bytes in the buffer.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
void(* free)(void *store, void **ptr)
Free a Value returned by fetch()
#define STAILQ_FOREACH(var, head, field)
void mutt_md5_init_ctx(struct Md5Ctx *md5ctx)
Initialise the MD5 computation.
struct RegexList NoSpamList
List of regexes to whitelist non-spam emails.
static size_t header_size(void)
Compute the size of the header with uuid validity and crc.
void mutt_md5_process(const char *str, struct Md5Ctx *md5ctx)
Process a NULL-terminated string.
List of regular expressions.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
static unsigned int hcachever
void serial_restore_int(unsigned int *i, const unsigned char *d, int *off)
Unpack an integer from a binary blob.
void *(* decompress)(void *cctx, const char *cbuf, size_t clen)
Decompress header cache data.
void(* close)(void **ptr)
Close a Store connection.
void mutt_hcache_free_raw(struct HeaderCache *hc, void **data)
Multiplexor for StoreOps::free.
struct Email * email
Retrieved email.
#define mutt_debug(LEVEL,...)
char * C_HeaderCacheCompressMethod
Config: (hcache) Enable generic hcache database compression.
Wrapper for Email retrieved from the header cache.
Header Cache Compression API.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
void mutt_md5_process_bytes(const void *buf, size_t buflen, struct Md5Ctx *md5ctx)
Process a block of data.
void *(* fetch)(void *store, const char *key, size_t klen, size_t *vlen)
Fetch a Value from the Store.
static char * get_foldername(const char *folder)
Where should the cache be stored?
void *(* compress)(void *cctx, const char *data, size_t dlen, size_t *clen)
Compress header cache data.
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
static void hcache_per_folder(struct Buffer *hcpath, const char *path, const char *folder, hcache_namer_t namer)
Generate the hcache pathname.
int(* delete_record)(void *store, const char *key, size_t klen)
Delete a record from the Store.
int(* store)(void *store, const char *key, size_t klen, void *value, size_t vlen)
Write a Value to the Store.
struct Regex * regex
Regex containing a regular expression.
List of regular expressions.
char * pattern
printable version
void * mutt_hcache_fetch_raw(struct HeaderCache *hc, const char *key, size_t keylen, size_t *dlen)
Fetch a message's header from the cache.
void *(* open)(const char *path)
Open a connection to a Store.
short C_HeaderCacheCompressLevel
Config: (hcache) Level of compression for method.
uint32_t uidvalidity
IMAP-specific UIDVALIDITY.
struct ReplaceList SpamList
List of regexes and patterns to match spam emails.
char * data
Pointer to data.
static struct RealKey * realkey(const char *key, size_t keylen)
Compute the real key used in the backend, taking into account the compression method.
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
struct Regex * regex
Regex containing a regular expression.
unsigned int crc
CRC of Email/Body/etc structs.
char * templ
Template to match.