size_t pathlen;
};
+/**
+ * bcache_path - Create the cache path for a given account/mailbox
+ * @param account Account info
+ * @param mailbox Mailbox name
+ * @param dst Buffer for the name
+ * @param dstlen Length of the buffer
+ * @retval 0 Success
+ * @retval -1 Failure
+ */
static int bcache_path(struct Account *account, const char *mailbox, char *dst, size_t dstlen)
{
char host[STRING];
return 0;
}
+/**
+ * mutt_bcache_move - Change the id of a message in the cache
+ * @param bcache Body cache
+ * @param id Per-mailbox unique identifier for the message
+ * @param newid New id for the message
+ */
static int mutt_bcache_move(struct BodyCache *bcache, const char *id, const char *newid)
{
char path[PATH_MAX];
return rename(path, newpath);
}
+/**
+ * mutt_bcache_open - Open an Email-Body Cache
+ * @param account current mailbox' account (required)
+ * @param mailbox path to the mailbox of the account (optional)
+ * @retval NULL Failure
+ *
+ * The driver using it is responsible for ensuring that hierarchies are
+ * separated by '/' (if it knows of such a concepts like mailboxes or
+ * hierarchies)
+ */
struct BodyCache *mutt_bcache_open(struct Account *account, const char *mailbox)
{
struct BodyCache *bcache = NULL;
return NULL;
}
+/**
+ * mutt_bcache_close - Close an Email-Body Cache
+ * @param bcache Body cache
+ *
+ * Free all memory of bcache and finally FREE() it, too.
+ */
void mutt_bcache_close(struct BodyCache **bcache)
{
if (!bcache || !*bcache)
FREE(bcache);
}
+/**
+ * mutt_bcache_get - Open a file in the Body Cache
+ * @param bcache Body Cache from mutt_bcache_open()
+ * @param id Per-mailbox unique identifier for the message
+ * @retval ptr Success
+ * @retval NULL Failure
+ */
FILE *mutt_bcache_get(struct BodyCache *bcache, const char *id)
{
char path[PATH_MAX];
return fp;
}
+/**
+ * mutt_bcache_put - Create a file in the Body Cache
+ * @param bcache Body Cache from mutt_bcache_open()
+ * @param id Per-mailbox unique identifier for the message
+ * @retval ptr Success
+ * @retval NULL Failure
+ *
+ * The returned FILE* is in a temporary location.
+ * Use mutt_bcache_commit to put it into place
+ */
FILE *mutt_bcache_put(struct BodyCache *bcache, const char *id)
{
char path[PATH_MAX];
return mutt_file_fopen(path, "w+");
}
+/**
+ * mutt_bcache_commit - Move a temporary file into the Body Cache
+ * @param bcache Body Cache from mutt_bcache_open()
+ * @param id Per-mailbox unique identifier for the message
+ * @retval 0 Success
+ * @retval -1 Failure
+ */
int mutt_bcache_commit(struct BodyCache *bcache, const char *id)
{
char tmpid[PATH_MAX];
return mutt_bcache_move(bcache, tmpid, id);
}
+/**
+ * mutt_bcache_del - Delete a file from the Body Cache
+ * @param bcache Body Cache from mutt_bcache_open()
+ * @param id Per-mailbox unique identifier for the message
+ * @retval 0 Success
+ * @retval -1 Failure
+ */
int mutt_bcache_del(struct BodyCache *bcache, const char *id)
{
char path[PATH_MAX];
return unlink(path);
}
+/**
+ * mutt_bcache_exists - Check if a file exists in the Body Cache
+ * @param bcache Body Cache from mutt_bcache_open()
+ * @param id Per-mailbox unique identifier for the message
+ * @retval 0 Success
+ * @retval -1 Failure
+ */
int mutt_bcache_exists(struct BodyCache *bcache, const char *id)
{
char path[PATH_MAX];
return rc;
}
-int mutt_bcache_list(struct BodyCache *bcache,
- int (*want_id)(const char *id, struct BodyCache *bcache, void *data),
- void *data)
+/**
+ * mutt_bcache_list - Find matching entries in the Body Cache
+ * @param bcache Body Cache from mutt_bcache_open()
+ * @param want_id Callback function called for each match
+ * @param data Data to pass to the callback function
+ * @retval -1 Failure
+ * @retval >=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).
+ */
+int mutt_bcache_list(struct BodyCache *bcache, bcache_list_t *want_id, void *data)
{
DIR *d = NULL;
struct dirent *de = NULL;
struct BodyCache;
/**
- * mutt_bcache_open - Open an Email-Body Cache
- * @param account current mailbox' account (required)
- * @param mailbox path to the mailbox of the account (optional)
- * @retval NULL Failure
- *
- * The driver using it is responsible for ensuring that hierarchies are
- * separated by '/' (if it knows of such a concepts like mailboxes or
- * hierarchies)
- */
-struct BodyCache *mutt_bcache_open(struct Account *account, const char *mailbox);
-
-/**
- * mutt_bcache_close - Close an Email-Body Cache
- * @param bcache Body cache
- *
- * Free all memory of bcache and finally FREE() it, too.
- */
-void mutt_bcache_close(struct BodyCache **bcache);
-
-/**
- * mutt_bcache_get - Open a file in the Body Cache
- * @param bcache Body Cache from mutt_bcache_open()
- * @param id Per-mailbox unique identifier for the message
- * @retval ptr Success
- * @retval NULL Failure
+ * Callback function for mutt_bcache_list
*/
-FILE *mutt_bcache_get(struct BodyCache *bcache, const char *id);
+typedef int bcache_list_t(const char *id, struct BodyCache *bcache, void *data);
-/**
- * mutt_bcache_put - Create a file in the Body Cache
- * @param bcache Body Cache from mutt_bcache_open()
- * @param id Per-mailbox unique identifier for the message
- * @retval ptr Success
- * @retval NULL Failure
- *
- * The returned FILE* is in a temporary location.
- * Use mutt_bcache_commit to put it into place
- */
-FILE *mutt_bcache_put(struct BodyCache *bcache, const char *id);
-
-/**
- * mutt_bcache_commit - Move a temporary file into the Body Cache
- * @param bcache Body Cache from mutt_bcache_open()
- * @param id Per-mailbox unique identifier for the message
- * @retval 0 Success
- * @retval -1 Failure
- */
-int mutt_bcache_commit(struct BodyCache *bcache, const char *id);
-
-/**
- * mutt_bcache_del - Delete a file from the Body Cache
- * @param bcache Body Cache from mutt_bcache_open()
- * @param id Per-mailbox unique identifier for the message
- * @retval 0 Success
- * @retval -1 Failure
- */
-int mutt_bcache_del(struct BodyCache *bcache, const char *id);
-
-/**
- * mutt_bcache_exists - Check if a file exists in the Body Cache
- * @param bcache Body Cache from mutt_bcache_open()
- * @param id Per-mailbox unique identifier for the message
- * @retval 0 Success
- * @retval -1 Failure
- */
-int mutt_bcache_exists(struct BodyCache *bcache, const char *id);
-
-/**
- * mutt_bcache_list - Find matching entries in the Body Cache
- * @param bcache Body Cache from mutt_bcache_open()
- * @param want_id Callback function called for each match
- * @param data Data to pass to the callback function
- * @retval -1 Failure
- * @retval >=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).
- */
-int mutt_bcache_list(struct BodyCache *bcache,
- int (*want_id)(const char *id, struct BodyCache *bcache, void *data),
- void *data);
+void mutt_bcache_close(struct BodyCache **bcache);
+int mutt_bcache_commit(struct BodyCache *bcache, const char *id);
+int mutt_bcache_del(struct BodyCache *bcache, const char *id);
+int mutt_bcache_exists(struct BodyCache *bcache, const char *id);
+FILE * mutt_bcache_get(struct BodyCache *bcache, const char *id);
+int mutt_bcache_list(struct BodyCache *bcache, bcache_list_t *want_id, void *data);
+struct BodyCache *mutt_bcache_open(struct Account *account, const char *mailbox);
+FILE * mutt_bcache_put(struct BodyCache *bcache, const char *id);
#endif /* _MUTT_BCACHE_H */