2 * This file is part of mutt-ng, see http://www.muttng.org/.
3 * It's licensed under the GNU General Public License,
4 * please see the file GPL in the top level source directory.
11 #include <lib-lib/mem.h>
18 rx_t *rx_compile (const char *s, int flags) {
19 rx_t *pp = mem_calloc (1, sizeof (rx_t));
21 pp->pattern = str_dup (s);
22 pp->rx = mem_calloc (1, sizeof (regex_t));
23 if (REGCOMP(pp->rx, NONULL (s), flags) != 0)
29 void rx_free (rx_t** p) {
30 p_delete(&(*p)->pattern);
36 int rx_compare (const rx_t* r1, const rx_t* r2) {
37 return (str_cmp (r1->pattern, r2->pattern));
40 int rx_list_match (list2_t* l, const char* pat) {
42 if (!pat || !*pat || list_empty(l))
44 for (i = 0; i < l->length; i++)
45 if (REGEXEC(((rx_t*) l->data[i])->rx, pat) == 0)
50 int rx_lookup (list2_t* l, const char* pat) {
52 if (!pat || !*pat || list_empty(l))
54 for (i = 0; i < l->length; i++)
55 if (str_cmp (((rx_t*) l->data[i])->pattern, pat) == 0)