X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0ea1e09365a5fc1d401a6a7df4e2278820c09d23..2c5c74d8aff556e5cd7bc10c9d555a0b2a026ed7:/sbr/mf.c diff --git a/sbr/mf.c b/sbr/mf.c index fa281766..4d04abb6 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -1,6 +1,4 @@ - -/* - * mf.c -- mail filter subroutines +/* mf.c -- mail filter subroutines * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -23,40 +21,11 @@ static int route (char *); static int my_lex (char *); -int -isfrom(const char *string) -{ - return (strncmp (string, "From ", 5) == 0 - || strncmp (string, ">From ", 6) == 0); -} - - -int -lequal (const char *a, const char *b) -{ - for (; *a; a++, b++) - if (*b == 0) - return FALSE; - else { - char c1 = islower ((unsigned char) *a) ? - toupper ((unsigned char) *a) : *a; - char c2 = islower ((unsigned char) *b) ? - toupper ((unsigned char) *b) : *b; - if (c1 != c2) - return FALSE; - } - - return (*b == 0); -} - - static int isat (const char *p) { - return (strncmp (p, " AT ", 4) - && strncmp (p, " At ", 4) - && strncmp (p, " aT ", 4) - && strncmp (p, " at ", 4) ? FALSE : TRUE); + return has_prefix(p, " AT ") || has_prefix(p, " At ") || + has_prefix(p, " aT ") || has_prefix(p, " at "); } @@ -181,18 +150,12 @@ getadrx (const char *addrs, int eai) char *bp; struct adrx *adrxp = &adrxs2; - if (pers) - free (pers); - if (mbox) - free (mbox); - if (host) - free (host); - if (path) - free (path); - if (grp) - free (grp); - if (note) - free (note); + mh_xfree(pers); + mh_xfree(mbox); + mh_xfree(host); + mh_xfree(path); + mh_xfree(grp); + mh_xfree(note); pers = mbox = host = path = grp = note = NULL; err[0] = 0; @@ -297,11 +260,10 @@ again: ; strcpy (err, "extraneous semi-colon"); return NOTOK; } + /* FALLTHRU */ case LX_COMA: - if (note) { - free (note); - note = NULL; - } + mh_xfree(note); + note = NULL; goto again; case LX_END: @@ -402,6 +364,7 @@ again: ; strcpy (err, "extraneous semi-colon"); return NOTOK; } + /* FALLTHRU */ case LX_COMA: case LX_END: return OK; @@ -543,7 +506,7 @@ domain (char *buffer) static int route (char *buffer) { - path = strdup ("@"); + path = mh_xstrdup ("@"); for (;;) { switch (my_lex (buffer)) { @@ -634,6 +597,7 @@ my_lex (char *buffer) continue; case '(': i++; + /* FALLTHRU */ default: ADDCHR(c); continue; @@ -661,6 +625,7 @@ my_lex (char *buffer) cp = NULL; return (last_lex = LX_ERR); } + /* FALLTHRU */ default: ADDCHR(c); continue; @@ -684,6 +649,7 @@ my_lex (char *buffer) cp = NULL; return (last_lex = LX_ERR); } + /* FALLTHRU */ default: ADDCHR(c); continue; @@ -748,59 +714,3 @@ legal_person (const char *p) return (char *) p; } - - -int -mfgets (FILE *in, char **bp) -{ - int i; - char *cp, *dp, *ep; - static int len = 0; - static char *pp = NULL; - - if (pp == NULL) - pp = mh_xmalloc ((size_t) (len = BUFSIZ)); - - for (ep = (cp = pp) + len - 2;;) { - switch (i = getc (in)) { - case EOF: - eol: ; - if (cp != pp) { - *cp = 0; - *bp = pp; - return OK; - } - eoh: ; - *bp = NULL; - free (pp); - pp = NULL; - return DONE; - - case 0: - continue; - - case '\n': - if (cp == pp) /* end of headers, gobble it */ - goto eoh; - switch (i = getc (in)) { - default: /* end of line */ - case '\n': /* end of headers, save for next call */ - ungetc (i, in); - goto eol; - - case ' ': /* continue headers */ - case '\t': - *cp++ = '\n'; - break; - } /* fall into default case */ - - default: - *cp++ = i; - break; - } - if (cp >= ep) { - dp = mh_xrealloc (pp, (size_t) (len += BUFSIZ)); - cp += dp - pp, ep = (pp = cp) + len - 2; - } - } -}