-static boolean
-GREPaction(struct field *f, int msgnum, void *data)
-{
- struct grep_data *g = data;
- int ret;
- char *buf;
-
- if (!g->header && *f->name) {
- return FALSE;
- }
-
- /* check for the right field */
- if (g->header && *g->header && mh_strcasecmp(g->header, f->name)==0) {
- return FALSE;
- }
-
- ret = regexec(g->preg, f->value, 0, NULL, 0) == REG_NOMATCH;
- switch (ret) {
- case 0:
- return TRUE;
- case REG_NOMATCH:
- return FALSE;
- default:
- buf = mh_xcalloc(BUFSIZ, sizeof(char));
- regerror(ret, g->preg, buf, BUFSIZ*sizeof(char));
- fprintf(stderr, "%s\n", buf);
- return FALSE;
- }
-
-}
-
-static void
-GREPfree(struct nexus **n)
-{
- struct grep_data *gd;
- if (!(*n)) {
- return;
- }
- gd = (*n)->data;
- mh_free0(&gd->header);
- regfree(gd->preg);
- mh_free0(n);
-}
-
-static void
-GREPdebug(void *data, size_t level)
-{
- struct grep_data *gd = data;
- char *buf, *buf2, *pbuf, *pbuf2;
-
- pbuf = pbuf2 = mh_xstrdup(gd->pattern);
-
- for (;*pbuf2; pbuf2++) {
- *pbuf2 = tolower(*pbuf2);
- }
-
- print_debug_level(level);
-
- if (gd->header) {
- buf = buf2 = mh_xstrdup(gd->header);
- for (;*buf2; buf2++) {
- *buf2 = tolower(*buf2);
- }
- fprintf(stderr, "PETTERN(%s) %s\n", buf, pbuf);
- } else {
- fprintf(stderr, "PETTERN(BODY) %s\n", pbuf);
- }
- mh_free0(&buf);
- mh_free0(&pbuf);
-}
-