#include "envelope.h"
#include "globals.h"
#include "hcache.h"
-#include "hcache/hcversion.h"
+#include "hcversion.h"
#include "header.h"
#include "protos.h"
#include "tags.h"
HCACHE_BACKEND_LIST
#undef HCACHE_BACKEND
-/* Keep this list sorted as it is in configure.ac to avoid user surprise if no
- * header_cache_backend is specified. */
+#define hcache_get_ops() hcache_get_backend_ops(HeaderCacheBackend)
+
+/**
+ * hcache_ops - Backend implementations
+ *
+ * Keep this list sorted as it is in configure.ac to avoid user surprise if no
+ * header_cache_backend is specified.
+ */
const struct HcacheOps *hcache_ops[] = {
#ifdef HAVE_TC
&hcache_tokyocabinet_ops,
};
/**
- * hcache_get_backend_ops
- * @param backend
- * @retval ptr
+ * hcache_get_backend_ops - Get the API functions for an hcache backend
+ * @param backend Name of the backend
+ * @retval ptr Set of function pointers
*/
static const struct HcacheOps *hcache_get_backend_ops(const char *backend)
{
return *ops;
}
-#define hcache_get_ops() hcache_get_backend_ops(HeaderCacheBackend)
-
/**
- * lazy_malloc
- * @retval ptr
- * @param siz
+ * lazy_malloc - Allocate some memory
+ * @param siz Minimum size to allocate
+ * @retval ptr Allocated memory
+ *
+ * This block is likely to be lazy_realloc()'d repeatedly.
+ * It starts off with a minimum size of 4KiB.
*/
static void *lazy_malloc(size_t siz)
{
}
/**
- * lazy_realloc
- * @param ptr
- * @param siz
+ * lazy_realloc - Reallocate some memory
+ * @param ptr Pointer to resize
+ * @param siz Minimum size
+ *
+ * The minimum size is 4KiB to avoid repeated resizing.
*/
static void lazy_realloc(void *ptr, size_t siz)
{
}
/**
- * dump_int
- * @param i
- * @param d
- * @param off
- * @retval ptr
+ * dump_int - Pack an integer into a binary blob
+ * @param i Integer to save
+ * @param d Binary blob to add to
+ * @param off Offset into the blob
+ * @retval ptr End of the newly packed binary
*/
static unsigned char *dump_int(unsigned int i, unsigned char *d, int *off)
{
}
/**
- * restore_int
- * @param i
- * @param d
- * @param off
+ * restore_int - Unpack an integer from a binary blob
+ * @param i Integer to write to
+ * @param d Binary blob to read from
+ * @param off Offset into the blob
*/
static void restore_int(unsigned int *i, const unsigned char *d, int *off)
{
}
/**
- * dump_char_size
- * @param c
- * @param d
- * @param off
- * @param size
- * @param convert
- * @retval ptr
+ * dump_char_size - Pack a fixed-length string into a binary blob
+ * @param c String to pack
+ * @param d Binary blob to add to
+ * @param off Offset into the blob
+ * @param size Size of the string
+ * @param convert If true, the strings will be converted to utf-8
+ * @retval ptr End of the newly packed binary
*/
static unsigned char *dump_char_size(char *c, unsigned char *d, int *off,
ssize_t size, bool convert)
}
/**
- * dump_char
- * @param c
- * @param d
- * @param off
- * @param convert
- * @retval ptr
+ * dump_char - Pack a variable-length string into a binary blob
+ * @param c String to pack
+ * @param d Binary blob to add to
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted to utf-8
+ * @retval ptr End of the newly packed binary
*/
static unsigned char *dump_char(char *c, unsigned char *d, int *off, bool convert)
{
}
/**
- * restore_char
- * @param c
- * @param d
- * @param off
- * @param convert
+ * restore_char - Unpack a variable-length string from a binary blob
+ * @param c Store the unpacked string here
+ * @param d Binary blob to read from
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted to utf-8
*/
static void restore_char(char **c, const unsigned char *d, int *off, bool convert)
{
}
/**
- * dump_address
- * @param a
- * @param d
- * @param off
- * @param convert
- * @retval ptr
+ * dump_address - Pack an Address into a binary blob
+ * @param a Address to pack
+ * @param d Binary blob to add to
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted to utf-8
+ * @retval ptr End of the newly packed binary
*/
static unsigned char *dump_address(struct Address *a, unsigned char *d, int *off, bool convert)
{
}
/**
- * restore_address
- * @param a
- * @param d
- * @param off
- * @param convert
+ * restore_address - Unpack an Address from a binary blob
+ * @param a Store the unpacked Address here
+ * @param d Binary blob to read from
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted from utf-8
*/
static void restore_address(struct Address **a, const unsigned char *d, int *off, bool convert)
{
* restore_stailq - Unpack a STAILQ from a binary blob
* @param l List to add to
* @param d Binary blob to read from
- * @param off Offset into blob
+ * @param off Offset into the blob
* @param convert If true, the strings will be converted from utf-8
*/
static void restore_stailq(struct ListHead *l, const unsigned char *d, int *off, bool convert)
}
/**
- * dump_buffer
- * @param b
- * @param d
- * @param off
- * @param convert
- * @retval ptr
+ * dump_buffer - Pack a Buffer into a binary blob
+ * @param b Buffer to pack
+ * @param d Binary blob to add to
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted to utf-8
+ * @retval ptr End of the newly packed binary
*/
static unsigned char *dump_buffer(struct Buffer *b, unsigned char *d, int *off, bool convert)
{
}
/**
- * restore_buffer
- * @param b
- * @param d
- * @param off
- * @param convert
+ * restore_buffer - Unpack a Buffer from a binary blob
+ * @param b Store the unpacked Buffer here
+ * @param d Binary blob to read from
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted from utf-8
*/
static void restore_buffer(struct Buffer **b, const unsigned char *d, int *off, bool convert)
{
}
/**
- * dump_parameter
- * @param p
- * @param d
- * @param off
- * @param convert
- * @retval ptr
+ * dump_parameter - Pack a Parameter into a binary blob
+ * @param p Parameter to pack
+ * @param d Binary blob to add to
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted to utf-8
+ * @retval ptr End of the newly packed binary
*/
static unsigned char *dump_parameter(struct ParameterList *p, unsigned char *d,
int *off, bool convert)
}
/**
- * restore_parameter
- * @param p
- * @param d
- * @param off
- * @param convert
+ * restore_parameter - Unpack a Parameter from a binary blob
+ * @param p Store the unpacked Parameter here
+ * @param d Binary blob to read from
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted from utf-8
*/
static void restore_parameter(struct ParameterList *p, const unsigned char *d,
int *off, bool convert)
}
/**
- * dump_body
- * @param c
- * @param d
- * @param off
- * @param convert
- * @retval ptr
+ * dump_body - Pack an Body into a binary blob
+ * @param c Body to pack
+ * @param d Binary blob to add to
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted to utf-8
+ * @retval ptr End of the newly packed binary
*/
static unsigned char *dump_body(struct Body *c, unsigned char *d, int *off, bool convert)
{
}
/**
- * restore_body
- * @param c
- * @param d
- * @param off
- * @param convert
+ * restore_body - Unpack a Body from a binary blob
+ * @param c Store the unpacked Body here
+ * @param d Binary blob to read from
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted from utf-8
*/
static void restore_body(struct Body *c, const unsigned char *d, int *off, bool convert)
{
}
/**
- * dump_envelope
- * @param e
- * @param d
- * @param off
- * @param convert
- * @retval ptr
+ * dump_envelope - Pack an Envelope into a binary blob
+ * @param e Envelope to pack
+ * @param d Binary blob to add to
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted to utf-8
+ * @retval ptr End of the newly packed binary
*/
static unsigned char *dump_envelope(struct Envelope *e, unsigned char *d, int *off, bool convert)
{
}
/**
- * restore_envelope
- * @param e
- * @param d
- * @param off
- * @param convert
+ * restore_envelope - Unpack an Envelope from a binary blob
+ * @param e Store the unpacked Envelope here
+ * @param d Binary blob to read from
+ * @param off Offset into the blob
+ * @param convert If true, the strings will be converted from utf-8
*/
static void restore_envelope(struct Envelope *e, const unsigned char *d, int *off, bool convert)
{
}
/**
- * crc_matches
- * @param d
- * @param crc
- * @retval num
+ * crc_matches - Is the CRC number correct?
+ * @param d Binary blob to read CRC from
+ * @param crc CRC to compare
+ * @retval num 1 if true, 0 if not
*/
static int crc_matches(const char *d, unsigned int crc)
{
* Generate the pathname for the hcache database, it will be of the form:
* BASE/FOLDER/NAME-SUFFIX
*
- * * BASE: Base directory (@a path)
+ * * BASE: Base directory (@a path)
* * FOLDER: Mailbox name (@a folder)
* * NAME: Create by @a namer, or md5sum of @a folder
* * SUFFIX: Character set (if ICONV isn't being used)
/**
* hcache_dump - Serialise a Header object
- * @param h
- * @param header
- * @param off
- * @param uidvalidity
- * @retval ptr
+ * @param h Header cache handle
+ * @param header Header to serialise
+ * @param off Size of the binary blob
+ * @param uidvalidity IMAP server identifier
+ * @retval ptr Binary blob representing the Header
*
* This function transforms a header into a char so that it is useable by
* db_store.
return d;
}
+/**
+ * mutt_hcache_restore - Deserialise a Header object
+ * @param d Binary blob
+ * @retval ptr Reconstructed Header
+ */
struct Header *mutt_hcache_restore(const unsigned char *d)
{
int off = 0;
}
/**
- * get_foldername
- * @param folder
- * @retval ptr
+ * get_foldername - Where should the cache be stored?
+ * @param folder Path to be canonicalised
+ * @retval ptr New string with canonical path
*/
static char *get_foldername(const char *folder)
{
return p;
}
+/**
+ * mutt_hcache_open - Multiplexor for #hcache_open_t
+ */
header_cache_t *mutt_hcache_open(const char *path, const char *folder, hcache_namer_t namer)
{
const struct HcacheOps *ops = hcache_get_ops();
}
}
+/**
+ * mutt_hcache_close - Multiplexor for #hcache_close_t
+ */
void mutt_hcache_close(header_cache_t *h)
{
const struct HcacheOps *ops = hcache_get_ops();
FREE(&h);
}
+/**
+ * mutt_hcache_fetch - Multiplexor for #hcache_fetch_t
+ */
void *mutt_hcache_fetch(header_cache_t *h, const char *key, size_t keylen)
{
void *data = mutt_hcache_fetch_raw(h, key, keylen);
return data;
}
+/**
+ * mutt_hcache_fetch_raw - Find the data for a key in a database backend
+ * @param h Header cache handle
+ * @param key A message identification string
+ * @param keylen The length of the string pointed to by key
+ */
void *mutt_hcache_fetch_raw(header_cache_t *h, const char *key, size_t keylen)
{
char path[_POSIX_PATH_MAX];
return ops->fetch(h->ctx, path, keylen);
}
+/**
+ * mutt_hcache_free - Multiplexor for #hcache_free_t
+ */
void mutt_hcache_free(header_cache_t *h, void **data)
{
const struct HcacheOps *ops = hcache_get_ops();
ops->free(h->ctx, data);
}
+/**
+ * mutt_hcache_store - Multiplexor for #hcache_store_t
+ */
int mutt_hcache_store(header_cache_t *h, const char *key, size_t keylen,
struct Header *header, unsigned int uidvalidity)
{
return ret;
}
+/**
+ * mutt_hcache_store_raw - Store some data in a database backend
+ * @param h Header cache handle
+ * @param key A message identification string
+ * @param keylen The length of the string pointed to by key
+ * @param data Binary blob
+ * @param dlen Length of binary blob
+ * @retval 0 Success
+ * @retval num Generic or backend-specific error code otherwise
+ */
int mutt_hcache_store_raw(header_cache_t *h, const char *key, size_t keylen,
void *data, size_t dlen)
{
return ops->store(h->ctx, path, keylen, data, dlen);
}
+/**
+ * mutt_hcache_delete - Multiplexor for #hcache_delete_t
+ */
int mutt_hcache_delete(header_cache_t *h, const char *key, size_t keylen)
{
char path[_POSIX_PATH_MAX];
return ops->delete (h->ctx, path, keylen);
}
+/**
+ * mutt_hcache_backend_list - Get a list of backend names
+ * @retval ptr Comma-space-separated list of names
+ *
+ * The caller should free the string.
+ */
const char *mutt_hcache_backend_list(void)
{
char tmp[STRING] = { 0 };
return mutt_str_strdup(tmp);
}
+/**
+ * mutt_hcache_is_valid_backend - Is this a valid hcache backend name?
+ * @param s Name to check
+ * @retval num 1 if valid, 0 if not
+ */
int mutt_hcache_is_valid_backend(const char *s)
{
return hcache_get_backend_ops(s) != NULL;