diff options
author | mikeh <mikeh@FreeBSD.org> | 2001-12-18 20:52:09 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2001-12-18 20:52:09 +0000 |
commit | e4034fe298af9398dae0cac602d8a28ec6e51489 (patch) | |
tree | 89731abafbceb13b0e7b78a6e281339c99fbfef9 /usr.bin/mail/list.c | |
parent | 1750942f6f64d20cc8853d2d1a60a3daaeeb1110 (diff) | |
download | FreeBSD-src-e4034fe298af9398dae0cac602d8a28ec6e51489.zip FreeBSD-src-e4034fe298af9398dae0cac602d8a28ec6e51489.tar.gz |
Sync with most of NetBSD's changes, including:
*) Sync with 4.4BSD-Lite2
*) Set usecs for utimes()
*) Add 'inc' command and 'autoinc' option that check for new mail
manually and automatically, respectively
*) Use POSIX signal handling and tty semantics
*) Handle long lines correctly when paging messages
*) Add ability to explicitly search 'To:' line
*) Various manpage cleanups
*) Support overriding '~/.mailrc' with $MAILRC
*) Support 'askbcc' and 'asksub' options
*) Fix various bugs
Reviewed by: ru (mail.1)
Obtained from: NetBSD
Diffstat (limited to 'usr.bin/mail/list.c')
-rw-r--r-- | usr.bin/mail/list.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/usr.bin/mail/list.c b/usr.bin/mail/list.c index 04b1586..1dbc587 100644 --- a/usr.bin/mail/list.c +++ b/usr.bin/mail/list.c @@ -33,7 +33,7 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)list.c 8.2 (Berkeley) 4/19/94"; +static char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95"; #endif static const char rcsid[] = "$FreeBSD$"; @@ -687,6 +687,49 @@ matchsender(str, mesg) } /* + * See if the passed name received the passed message number. Return true + * if so. + */ + +static char *to_fields[] = { "to", "cc", "bcc", NULL }; + +int +matchto(str, mesg) + char *str; + int mesg; +{ + struct message *mp; + char *cp, *cp2, *backup, **to; + + str++; + + /* null string matches nothing instead of everything */ + if (*str == '\0') + return (0); + + mp = &message[mesg - 1]; + + for (to = to_fields; *to != NULL; to++) { + cp = str; + cp2 = hfield(*to, mp); + if (cp2 != NULL) { + backup = cp2; + while (*cp2 != '\0') { + if (*cp == '\0') + return (1); + if (toupper(*cp++) != toupper(*cp2++)) { + cp2 = ++backup; + cp = str; + } + } + if (*cp == '\0') + return (1); + } + } + return (0); +} + +/* * See if the given string matches inside the subject field of the * given message. For the purpose of the scan, we ignore case differences. * If it does, return true. The string search argument is assumed to @@ -715,8 +758,11 @@ matchsubj(str, mesg) */ if (value("searchheaders") && (cp = strchr(str, ':')) != NULL) { + /* Check for special case "/To:" */ + if (strncasecmp(str, "To:", 3) == 0) + return (matchto(cp, mesg)); *cp++ = '\0'; - cp2 = hfield(str, mp); + cp2 = hfield(*str != '\0' ? str : "subject", mp); cp[-1] = ':'; str = cp; } else { |