* lines. ``line'' must point to a dynamically allocated string; it is
* increased if more space is required to fit the whole line.
*/
-static char *read_rfc822_line (FILE *f, char *line, size_t *linelen)
+char *mutt_read_rfc822_line (FILE *f, char *line, size_t *linelen)
{
char *buf = line;
char ch;
p->type = digest ? TYPEMESSAGE : TYPETEXT;
p->disposition = DISPINLINE;
- while (*(line = read_rfc822_line (fp, line, &linelen)) != 0)
+ while (*(line = mutt_read_rfc822_line (fp, line, &linelen)) != 0)
{
/* Find the value of the current header */
if ((c = strchr (line, ':')))
}
while ((loc = ftell (f)),
- *(line = read_rfc822_line (f, line, &linelen)) != 0)
+ *(line = mutt_read_rfc822_line (f, line, &linelen)) != 0)
{
matched = 0;
}
static int
-msg_search (CONTEXT *ctx, regex_t *rx, char *buf, size_t blen, int op, int msgno)
+msg_search (CONTEXT *ctx, regex_t *rx, int op, int msgno)
{
char tempfile[_POSIX_PATH_MAX];
MESSAGE *msg = NULL;
long lng = 0;
int match = 0;
HEADER *h = ctx->hdrs[msgno];
+ char *buf;
+ size_t blen;
if ((msg = mx_open_message (ctx, msgno)) != NULL)
{
}
}
+ blen = STRING;
+ buf = safe_malloc (blen);
+
/* search the file "fp" */
while (lng > 0)
{
- if (fgets (buf, blen - 1, fp) == NULL)
+ if (op == M_HEADER)
+ {
+ if (*(buf = mutt_read_rfc822_line (fp, buf, &blen)) == '\0')
+ break;
+ }
+ else if (fgets (buf, blen - 1, fp) == NULL)
break; /* don't loop forever */
if (regexec (rx, buf, 0, NULL, 0) == 0)
{
}
lng -= mutt_strlen (buf);
}
+
+ FREE (&buf);
mx_close_message (&msg);
int
mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h)
{
- char buf[STRING];
-
switch (pat->op)
{
case M_AND:
case M_BODY:
case M_HEADER:
case M_WHOLE_MSG:
- return (pat->not ^ msg_search (ctx, pat->rx, buf, sizeof (buf), pat->op, h->msgno));
+ return (pat->not ^ msg_search (ctx, pat->rx, pat->op, h->msgno));
case M_SENDER:
return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
pat->alladdr, 1, h->env->sender));
LIST *mutt_make_references(ENVELOPE *e);
+char *mutt_read_rfc822_line (FILE *, char *, size_t *);
ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
HEADER *mutt_dup_header (HEADER *);