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.
24 #include "mutt_curses.h"
25 #include "mutt_regex.h"
33 #include <sys/utsname.h>
37 group_t *mutt_pattern_group (const char *k)
44 if (!(p = hash_find (Groups, k)))
46 dprint (2, (debugfile, "mutt_pattern_group: Creating group %s.\n", k));
47 p = safe_calloc (1, sizeof (group_t));
48 p->name = safe_strdup (k);
49 hash_insert (Groups, p->name, p, 0);
55 void mutt_group_context_add (group_context_t **ctx, group_t *group)
57 for (; *ctx; ctx = &((*ctx)->next))
59 if ((*ctx)->g == group)
63 *ctx = safe_calloc (1, sizeof (group_context_t));
67 void mutt_group_context_destroy (group_context_t **ctx)
70 for (; *ctx; *ctx = p)
73 FREE (ctx); /* __FREE_CHECKED__ */
77 void mutt_group_add_adrlist (group_t *g, ADDRESS *a)
86 for (p = &g->as; *p; p = &((*p)->next))
89 q = rfc822_cpy_adr (a);
90 q = mutt_remove_xrefs (g->as, q);
94 static int mutt_group_add_rx (group_t *g, const char *s, int flags, BUFFER *err)
96 return mutt_add_to_rx_list (&g->rs, s, flags, err);
99 void mutt_group_context_add_adrlist (group_context_t *ctx, ADDRESS *a)
101 for (; ctx; ctx = ctx->next)
102 mutt_group_add_adrlist (ctx->g, a);
105 int mutt_group_context_add_rx (group_context_t *ctx, const char *s, int flags, BUFFER *err)
109 for (; (!rv) && ctx; ctx = ctx->next)
110 rv = mutt_group_add_rx (ctx->g, s, flags, err);
115 int mutt_group_match (group_t *g, const char *s)
121 if (mutt_match_rx_list (s, g->rs))
123 for (ap = g->as; ap; ap = ap->next)
124 if (ap->mailbox && !mutt_strcasecmp (s, ap->mailbox))