X-Git-Url: http://git.madism.org/?a=blobdiff_plain;ds=sidebyside;f=lib-lib%2Frx.h;fp=lib-lib%2Frx.h;h=48e295ba4b7acccef2af9de0ce5942b1040009bc;hb=03fe827a7d4a7ad79ac235654414aa339a9a2c9a;hp=0000000000000000000000000000000000000000;hpb=05a3bbbe420e4afc76e0eea24ce32f859405dc4a;p=apps%2Fmadmutt.git diff --git a/lib-lib/rx.h b/lib-lib/rx.h new file mode 100644 index 0000000..48e295b --- /dev/null +++ b/lib-lib/rx.h @@ -0,0 +1,60 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Copyright © 2006 Pierre Habouzit + */ +/* + * 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 +#include + +#include "../lib/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; /* do not match */ +} rx_t; + +rx_t* rx_compile (const char*, int); +void rx_delete(rx_t **); + +/* for handling lists */ +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, 0, NULL, 0) + +#endif /* !_LIB_RX_H */