2 * Copyright (C) 2006 Thomas Roessler <roessler@does-not-exist.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #include "mutt_curses.h"
26 #include "mutt_regex.h"
31 #include "mutt_crypt.h"
32 #include "mutt_idna.h"
38 #include <sys/utsname.h>
42 group_t *mutt_pattern_group (const char *k)
49 if (!(p = hash_find (Groups, k)))
51 dprint (2, (debugfile, "mutt_pattern_group: Creating group %s.\n", k));
52 p = safe_calloc (1, sizeof (group_t));
53 p->name = safe_strdup (k);
54 hash_insert (Groups, p->name, p, 0);
60 void mutt_group_context_add (group_context_t **ctx, group_t *group)
62 for (; *ctx; ctx = &((*ctx)->next))
64 if ((*ctx)->g == group)
68 *ctx = safe_calloc (1, sizeof (group_context_t));
72 void mutt_group_context_destroy (group_context_t **ctx)
75 for (; *ctx; *ctx = p)
78 FREE (ctx); /* __FREE_CHECKED__ */
82 void mutt_group_add_adrlist (group_t *g, ADDRESS *a)
91 for (p = &g->as; *p; p = &((*p)->next))
94 q = rfc822_cpy_adr (a);
95 q = mutt_remove_xrefs (g->as, q);
99 int mutt_group_add_rx (group_t *g, const char *s, int flags, BUFFER *err)
101 return mutt_add_to_rx_list (&g->rs, s, flags, err);
104 void mutt_group_context_add_adrlist (group_context_t *ctx, ADDRESS *a)
106 for (; ctx; ctx = ctx->next)
107 mutt_group_add_adrlist (ctx->g, a);
110 int mutt_group_context_add_rx (group_context_t *ctx, const char *s, int flags, BUFFER *err)
114 for (; (!rv) && ctx; ctx = ctx->next)
115 rv = mutt_group_add_rx (ctx->g, s, flags, err);
120 int mutt_group_match (group_t *g, const char *s)
126 if (mutt_match_rx_list (s, g->rs))
128 for (ap = g->as; ap; ap = ap->next)
129 if (ap->mailbox && !mutt_strcasecmp (s, ap->mailbox))