2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or (at
5 * your option) any later version.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * Copyright © 2006 Pierre Habouzit
20 * This file is part of mutt-ng, see http://www.muttng.org/.
21 * It's licensed under the GNU General Public License,
22 * please see the file GPL in the top level source directory.
26 * this is an internal abstraction layer for regular expressions
29 #ifndef MUTT_LIB_LIB_RX_H
30 #define MUTT_LIB_LIB_RX_H
34 /* this is a non-standard option supported by Solaris 2.5.x which allows
35 * patterns of the form \<...\>
44 unsigned neg : 1; /* do not match */
46 int nmatch; /* nb matches */
48 char *pattern; /* printable version */
49 char *tpl; /* out template */
51 regex_t *rx; /* compiled expression */
54 rx_t *rx_compile(const char*, int);
58 DO_SLIST(rx_t, rx, rx_delete);
60 int rx_validate(const char*, char*, ssize_t);
61 void rx_set_template(rx_t *, const char*);
62 int rx_sanitize_string(char *, ssize_t, const char *);
64 /* for handling lists */
65 rx_t **rx_lookup(rx_t**, const char*); /* lookup pattern */
67 int rx_list_match(rx_t *, const char*); /* match all items list agains string */
68 void rx_list_add(rx_t **, rx_t *);
69 void rx_list_remove(rx_t **, const rx_t *);
71 int rx_list_match2(rx_t *l, const char *s, char *dst, int dlen);
72 void rx_list_add2(rx_t **, rx_t **);
74 #define REGCOMP(X,Y,Z) regcomp(X, Y, REG_WORDS|REG_EXTENDED|(Z))
75 #define REGEXEC(X,Y) regexec(X, Y, 0, NULL, 0)
77 #endif /* !MUTT_LIB_LIB_RX_H */