WHERE rx_t *UnMailLists INITVAL (0);
WHERE rx_t *SubscribedLists INITVAL (0);
WHERE rx_t *UnSubscribedLists INITVAL (0);
-WHERE rx_t *SpamList INITVAL (0);
-WHERE rx_t *NoSpamList INITVAL (0);
/* bit vector for boolean variables */
#ifdef MAIN_C
return 0;
}
-static int add_to_spam_list(rx_t **list, const char *pat,
- const char *templ, BUFFER * err)
-{
- rx_t *rx;
-
- if (m_strisempty(pat) || !templ)
- return 0;
-
- if (!(rx = rx_compile (pat, REG_ICASE))) {
- snprintf (err->data, err->dsize, _("Bad regexp: %s"), pat);
- return -1;
- }
-
- /* check to make sure the item is not already on this list */
- while (*list) {
- if (!ascii_strcasecmp(rx->pattern, (*list)->pattern)) {
- rx_t *tmp = rx_list_pop(list);
- rx_delete(&tmp);
- } else {
- list = &(*list)->next;
- }
- }
-
- *list = rx;
- rx_set_template(rx, templ);
- return 0;
-}
-
-static int remove_from_spam_list (rx_t ** list, const char *pat)
-{
- int nremoved = 0;
-
- while (*list) {
- if (!m_strcmp((*list)->pattern, pat)) {
- rx_t *spam = rx_list_pop(list);
- rx_delete(&spam);
- nremoved++;
- } else {
- list = &(*list)->next;
- }
- }
-
- return nremoved;
-}
-
-
static void remove_from_list(string_list_t **l, const char *str)
{
if (!m_strcmp("*", str)) {
return 0;
}
-static int parse_spam_list (BUFFER * buf, BUFFER * s, unsigned long data,
- BUFFER * err)
-{
- BUFFER templ;
-
- p_clear(&templ, 1);
-
- /* Insist on at least one parameter */
- if (!MoreArgs (s)) {
- if (data == M_SPAM)
- m_strcpy(err->data, err->dsize, _("spam: no matching pattern"));
- else
- m_strcpy(err->data, err->dsize, _("nospam: no matching pattern"));
- 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) {
- p_delete(&templ.data);
- return -1;
- }
- p_delete(&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 (!m_strcmp(buf->data, "*")) {
- rx_list_wipe(&SpamList);
- rx_list_wipe(&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. */
- m_strcpy(err->data, err->dsize, "This is no good at all.");
- return -1;
-}
-
static int parse_unlist (BUFFER * buf, BUFFER * s, unsigned long data,
BUFFER * err __attribute__ ((unused)))
{
** top of threads in the thread tree. Note that when $$hide_limited is
** \fIset\fP, this option will have no effect.
*/
+ {"history", DT_NUM, R_NONE, UL &HistSize, "10" },
/*
** .pp
** This variable controls the size (in number of strings remembered) of
/* functions used to parse commands in a rc file */
static int parse_list (BUFFER *, BUFFER *, unsigned long, BUFFER *);
-static int parse_spam_list (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unlist (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_attachments (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unattachments (BUFFER *, BUFFER *, unsigned long, BUFFER *);
{"toggle", parse_set, M_SET_INV},
{"unset", parse_set, M_SET_UNSET},
{"source", parse_source, 0},
- {"nospam", parse_spam_list, M_NOSPAM},
- {"spam", parse_spam_list, M_SPAM},
{"subscribe", parse_subscribe, 0},
{"unalias", parse_unalias, 0},
{"unalternates", parse_unalternates, 0},
"x-uuencoded",
};
+rx_t *SpamList = NULL, *NoSpamList = NULL;
+
@package Mime {
/*
** .pp
** separator.
*/
string_t spam_separator = m_strdup(",");
+
+ void spam(rx_t rx, const string_t tpl) {
+ rx_set_template(rx, tpl);
+ rx_list_append(&SpamList, rx);
+ RETURN();
+ };
+
+ void nospam(rx_t rx) {
+ if (!m_strcmp(rx->pattern, "*")) {
+ rx_list_wipe(&SpamList);
+ rx_list_wipe(&NoSpamList);
+ rx_delete(&rx);
+ } else {
+ rx_list_append(&NoSpamList, rx);
+ }
+ RETURN();
+ };
};
/****************************************************************************/
extern const char MimeSpecials[];
extern const char *BodyTypes[];
extern const char *BodyEncodings[];
+extern rx_t *SpamList, *NoSpamList;
/* MIME encoding/decoding global vars */
#define M_SEL_MULTI (1<<1)
#define M_SEL_FOLDER (1<<2)
-/* flags for parse_spam_list */
-#define M_SPAM 1
-#define M_NOSPAM 2
-
/* boolean vars */
enum {
OPTALLOW8BIT,