diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-02-06 11:59:20 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-02-06 11:59:20 +0200 |
commit | 8b573cdca1f2d71184531a2bbeb1263b116d1dac (patch) | |
tree | 02e327b33a55b4a6f924f775b533e8cf545c152c /movemail | |
parent | 94c35a24f30d8c61c1306f59979ae13ffb80fdb3 (diff) | |
download | mailutils-8b573cdca1f2d71184531a2bbeb1263b116d1dac.tar.gz mailutils-8b573cdca1f2d71184531a2bbeb1263b116d1dac.tar.bz2 |
Move biff notification to the library. Implement it in inc and movemail.
* include/mailutils/mailbox.h (mu_mailbox_set_notify)
(mu_mailbox_unset_notify): New protos.
* include/mailutils/sys/mailbox.h (_mu_mailbox) <notify_user>
<notify_fd,notify_sa>: New members.
* libmailutils/mailbox/Makefile.am (libmailbox_la_SOURCES): Add
biffnotify.c
* libmailutils/mailbox/biffnotify.c: New file.
* libmailutils/mailbox/mailbox.c (_mailbox_create_from_record): Initialize
notify_fd.
(mu_mailbox_destroy): Free notify_sa.
(mu_mailbox_close): Close notify_fd.
(mu_mailbox_flush): Rewrite to handle append-only mailboxes effectively.
* libmailutils/server/msrv.c (server_cfg_param): Fix docstring.
* libmailutils/stream/file_stream.c (fd_open): Open fd read-write if
both MU_STREAM_APPEND and MU_STREAM_READ are requested.
* libproto/mbox/mbox.c (mbox_expunge0): Rescan the mailbox if
messages_count == 0. Special handling for append-only mailboxes.
* maidag/deliver.c: Use library notification mechanism.
* mh/inc.c: New option --notify.
* movemail/movemail.c: Likewise.
Diffstat (limited to 'movemail')
-rw-r--r-- | movemail/movemail.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/movemail/movemail.c b/movemail/movemail.c index cf0cb317b..bad7bca40 100644 --- a/movemail/movemail.c +++ b/movemail/movemail.c @@ -37,7 +37,8 @@ enum { IGNORE_ERRORS_OPTION, PROGRAM_ID_OPTION, MAX_MESSAGES_OPTION, - ONERROR_OPTION + ONERROR_OPTION, + NOTIFY_OPTION }; static struct argp_option options[] = { @@ -60,6 +61,8 @@ static struct argp_option options[] = { N_("set program identifier for diagnostics (default: program name)") }, { "max-messages", MAX_MESSAGES_OPTION, N_("NUMBER"), 0, N_("process at most NUMBER messages") }, + { "notify", NOTIFY_OPTION, NULL, 0, + N_("enable biff notification") }, { NULL, 0, NULL, 0, NULL, 0 } }; @@ -71,6 +74,7 @@ static int verbose_option; static int ignore_errors; static char *program_id_option; static size_t max_messages_option; +static int notify; /* These bits tell what to do when an error occurs: */ #define ONERROR_SKIP 0x01 /* Skip to the next message */ @@ -166,6 +170,10 @@ parse_opt (int key, char *arg, struct argp_state *state) mu_argp_node_list_new (lst, "ignore-errors", "yes"); break; + case NOTIFY_OPTION: + notify = 1; + break; + case ONERROR_OPTION: mu_argp_node_list_new (lst, "onerror", arg); break; @@ -893,11 +901,20 @@ main (int argc, char **argv) switch_owner (source); - open_mailbox (&dest, dest_name, MU_STREAM_RDWR | MU_STREAM_CREAT, NULL); + open_mailbox (&dest, dest_name, + MU_STREAM_APPEND | MU_STREAM_READ | MU_STREAM_CREAT, NULL); if (program_id_option) set_program_id (source_name, dest_name); + if (notify) + { + rc = mu_mailbox_set_notify (dest, NULL); + if (rc) + mu_error (_("failed to set up notification: %s"), + mu_strerror (rc)); + } + rc = mu_mailbox_messages_count (source, &total); if (rc) { |