summaryrefslogtreecommitdiff
path: root/include/mailutils/sys
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-09-16 01:53:04 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-09-16 01:53:04 +0300
commit756eb2bcfb781350f70e77d2e41fa8ae6e692cdd (patch)
treeb446c1e4ba9bf3343e49205abfdd78ae4ce09e4f /include/mailutils/sys
parentec989a562f5a64f36909dc0a151fc24b50a733be (diff)
downloadmailutils-756eb2bcfb781350f70e77d2e41fa8ae6e692cdd.tar.gz
mailutils-756eb2bcfb781350f70e77d2e41fa8ae6e692cdd.tar.bz2
Implement `remove' method for mailboxes.
* include/mailutils/mailbox.h (mu_mailbox_remove): New function. * include/mailutils/stream.h: Add some comments. * include/mailutils/sys/amd.h (_amd_data)<remove>: New method. (amd_remove_dir): New function. * include/mailutils/sys/mailbox.h (_mu_mailbox)<_remove>: New method. * libmailutils/amd.c (amd_remove_mbox): New function. (amd_init_mailbox): Initialize the _remove method. (amd_remove_dir): New function. * libmailutils/errors (MU_ERR_MBX_REMOVED) (MU_ERR_NOT_OPEN, MU_ERR_OPEN): New error codes. * libmailutils/mailbox.c: Keep state of the mailbox (open vs. not open, removed). Check it before doing anything on it. (_MU_MAILBOX_OPEN, _MU_MAILBOX_REMOVED, _MU_MAILBOX_MASK): New defines. (mu_mailbox_open): Set _MU_MAILBOX_OPEN if the operation succeeds. (mu_mailbox_close): Clear _MU_MAILBOX_OPEN if the operation succeeds. Refuse to run if the mailbox was not opened. (mu_mailbox_remove): New function. (all functions): return MU_ERR_MBX_NULL if the mbox argument is NULL. Check mailbox state on entry and proceed accordingly. * libproto/maildir/mbox.c: Implement _remove method. (maildir_remove): New function. (_mailbox_maildir_init): Initialize amd->_remove. * libproto/mbox/mbox.c: Implement _remove method. (mbox_remove): New function. (_mailbox_mbox_init): Initialize amd->_remove. * libproto/mh/mbox.c: Implement _remove method. (mh_remove): New function. (_mailbox_mh_init): Initialize amd->_remove. * libmailutils/tests/mbdel.c: New file. * libmailutils/tests/.gitignore: Add mbdel. * libmailutils/tests/Makefile.am (noinst_PROGRAMS): Likewise. (LDADD): List all mailbox formats. * imap4d/delete.c (imap4d_delete): Use mu_mailbox_remove to delete the folder. Fall back to remove() if it does not appear to be a mailbox.
Diffstat (limited to 'include/mailutils/sys')
-rw-r--r--include/mailutils/sys/amd.h2
-rw-r--r--include/mailutils/sys/mailbox.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/include/mailutils/sys/amd.h b/include/mailutils/sys/amd.h
index b72c3c1ec..52f039515 100644
--- a/include/mailutils/sys/amd.h
+++ b/include/mailutils/sys/amd.h
@@ -82,6 +82,7 @@ struct _amd_data
int (*msg_cmp) (struct _amd_message *, struct _amd_message *);
int (*message_uid) (mu_message_t msg, size_t *puid);
size_t (*next_uid) (struct _amd_data *mhd);
+ int (*remove) (struct _amd_data *);
/* List of messages: */
size_t msg_count; /* number of messages in the list */
@@ -112,5 +113,6 @@ void amd_cleanup (void *arg);
struct _amd_message *_amd_get_message (struct _amd_data *amd, size_t msgno);
int amd_msg_lookup (struct _amd_data *amd, struct _amd_message *msg,
size_t *pret);
+int amd_remove_dir (const char *name);
#endif
diff --git a/include/mailutils/sys/mailbox.h b/include/mailutils/sys/mailbox.h
index 12af8fe48..fe362690f 100644
--- a/include/mailutils/sys/mailbox.h
+++ b/include/mailutils/sys/mailbox.h
@@ -54,6 +54,7 @@ struct _mu_mailbox
int (*_open) (mu_mailbox_t, int);
int (*_close) (mu_mailbox_t);
+ int (*_remove) (mu_mailbox_t);
/* messages */
int (*_get_message) (mu_mailbox_t, size_t, mu_message_t *);

Return to:

Send suggestions and report system problems to the System administrator.