+static void _alternates_clean (void)
+{
+ int i;
+ if (Context && Context->msgcount)
+ {
+ for (i = 0; i < Context->msgcount; i++)
+ Context->hdrs[i]->recip_valid = 0;
+ }
+}
+
+static int parse_alternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+{
+ _alternates_clean();
+ do
+ {
+ mutt_extract_token (buf, s, 0);
+ remove_from_rx_list (&UnAlternates, buf->data);
+
+ if (add_to_rx_list (&Alternates, buf->data, REG_ICASE, err) != 0)
+ return -1;
+ }
+ while (MoreArgs (s));
+
+ return 0;
+}
+
+static int parse_unalternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+{
+ _alternates_clean();
+ do
+ {
+ mutt_extract_token (buf, s, 0);
+ remove_from_rx_list (&Alternates, buf->data);
+
+ if (mutt_strcmp (buf->data, "*") &&
+ add_to_rx_list (&UnAlternates, buf->data, REG_ICASE, err) != 0)
+ return -1;
+
+ }
+ while (MoreArgs (s));
+
+ return 0;
+}
+
+static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+{
+ BUFFER templ;
+
+ memset(&templ, 0, sizeof(templ));
+
+ /* Insist on at least one parameter */
+ if (!MoreArgs(s))
+ {
+ if (data == M_SPAM)
+ strfcpy(err->data, _("spam: no matching pattern"), err->dsize);
+ else
+ strfcpy(err->data, _("nospam: no matching pattern"), err->dsize);
+ return -1;
+ }
+
+ /* Extract the first token, a regexp */
+ mutt_extract_token (buf, s, 0);
+
+ /* data should be either M_SPAM or M_NOSPAM. M_SPAM is for spam commands. */
+ if (data == M_SPAM)
+ {
+ /* If there's a second parameter, it's a template for the spam tag. */
+ if (MoreArgs(s))
+ {
+ mutt_extract_token (&templ, s, 0);
+
+ /* Add to the spam list. */
+ if (add_to_spam_list (&SpamList, buf->data, templ.data, err) != 0) {
+ FREE(&templ.data);
+ return -1;
+ }
+ FREE(&templ.data);
+ }
+
+ /* If not, try to remove from the nospam list. */
+ else
+ {
+ remove_from_rx_list(&NoSpamList, buf->data);
+ }
+
+ return 0;
+ }
+
+ /* M_NOSPAM is for nospam commands. */
+ else if (data == M_NOSPAM)
+ {
+ /* nospam only ever has one parameter. */
+
+ /* "*" is a special case. */
+ if (!mutt_strcmp(buf->data, "*"))
+ {
+ mutt_free_spam_list (&SpamList);
+ mutt_free_rx_list (&NoSpamList);
+ return 0;
+ }
+
+ /* If it's on the spam list, just remove it. */
+ if (remove_from_spam_list(&SpamList, buf->data) != 0)
+ return 0;
+
+ /* Otherwise, add it to the nospam list. */
+ if (add_to_rx_list (&NoSpamList, buf->data, REG_ICASE, err) != 0)
+ return -1;
+
+ return 0;
+ }
+
+ /* This should not happen. */
+ strfcpy(err->data, "This is no good at all.", err->dsize);
+ return -1;
+}
+