X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib%2Frx.h;fp=lib%2Frx.h;h=f098311336e7bc3e9a413fe9db0623e3dec70b67;hb=fa7f733a61a6fe3143198791ab470ddf4d08fdbe;hp=0000000000000000000000000000000000000000;hpb=34cf6d8df073a949b69970327314e2355dbccabc;p=apps%2Fmadmutt.git diff --git a/lib/rx.h b/lib/rx.h new file mode 100644 index 0000000..f098311 --- /dev/null +++ b/lib/rx.h @@ -0,0 +1,47 @@ +/* + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. + */ + +/* + * this is an internal abstraction layer for regular expressions + */ + +#ifndef _LIB_RX_H +#define _LIB_RX_H + +#include +#ifdef USE_GNU_REGEX +#include "_regex.h" +#else +#include +#endif + +#include "list.h" + +/* this is a non-standard option supported by Solaris 2.5.x which allows + * patterns of the form \<...\> + */ +#ifndef REG_WORDS +#define REG_WORDS 0 +#endif + +typedef struct rx_t { + char *pattern; /* printable version */ + regex_t *rx; /* compiled expression */ + int not : 1; /* do not match */ +} rx_t; + +void rx_free (rx_t**); +rx_t* rx_compile (const char*, int); + +/* for handling lists */ +int rx_compare (const rx_t*, const rx_t*); /* compare two patterns */ +int rx_list_match (list2_t*, const char*); /* match all items list agains string */ +int rx_lookup (list2_t*, const char*); /* lookup pattern */ + +#define REGCOMP(X,Y,Z) regcomp(X, Y, REG_WORDS|REG_EXTENDED|(Z)) +#define REGEXEC(X,Y) regexec(X, Y, (size_t)0, (regmatch_t *)0, (int)0) + +#endif /* !_LIB_RX_H */