0eee105db645eb0b8c34a1a7b1cc4e9a83a3a95a
[apps/madmutt.git] / lib / rx.h
1 /*
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.
5  */
6
7 /*
8  * this is an internal abstraction layer for regular expressions
9  */
10
11 #ifndef _LIB_RX_H
12 #define _LIB_RX_H
13
14 #include <sys/types.h>
15 #ifdef USE_GNU_REGEX
16 #include "_regex.h"
17 #else
18 #include <regex.h>
19 #endif
20
21 #include "list.h"
22
23 /* this is a non-standard option supported by Solaris 2.5.x which allows
24  * patterns of the form \<...\>
25  */
26 #ifndef REG_WORDS
27 #define REG_WORDS 0
28 #endif
29
30 typedef struct rx_t {
31   char *pattern;                /* printable version */
32   regex_t *rx;                  /* compiled expression */
33   int not;                      /* do not match */
34 } rx_t;
35
36 void rx_free (rx_t**);
37 rx_t* rx_compile (const char*, int);
38
39 /* for handling lists */
40 int rx_compare (const rx_t*, const rx_t*);      /* compare two patterns */
41 int rx_list_match (list2_t*, const char*);      /* match all items list agains string */
42 int rx_lookup (list2_t*, const char*);          /* lookup pattern */
43
44 #define REGCOMP(X,Y,Z) regcomp(X, Y, REG_WORDS|REG_EXTENDED|(Z))
45 #define REGEXEC(X,Y) regexec(X, Y, (size_t)0, (regmatch_t *)0, (int)0)
46
47 #endif /* !_LIB_RX_H */