summaryrefslogtreecommitdiffstats
path: root/usr.bin/mail/head.c
diff options
context:
space:
mode:
authormikeh <mikeh@FreeBSD.org>2001-06-18 04:28:03 +0000
committermikeh <mikeh@FreeBSD.org>2001-06-18 04:28:03 +0000
commit016a180889afc782f8623f7e5da350d91da1d032 (patch)
tree1204d7024b8707331d68bbe46083dc5f15f8628a /usr.bin/mail/head.c
parent98c48a5fa1ca5e8b5ae3c0666ee551fa1d7a7135 (diff)
downloadFreeBSD-src-016a180889afc782f8623f7e5da350d91da1d032.zip
FreeBSD-src-016a180889afc782f8623f7e5da350d91da1d032.tar.gz
Support mail boxes that have dates without seconds (SysV) and those
that have a timezone as <-|+>nnnn (eg. imapd). PR: bin/11746 Obtained from: OpenBSD MFC after: 2 weeks
Diffstat (limited to 'usr.bin/mail/head.c')
-rw-r--r--usr.bin/mail/head.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/usr.bin/mail/head.c b/usr.bin/mail/head.c
index b3a3b71..0f214d7 100644
--- a/usr.bin/mail/head.c
+++ b/usr.bin/mail/head.c
@@ -150,6 +150,11 @@ copyin(src, space)
* below is used as the criterion of correctness.
* Also, we check for a possible trailing time zone using
* the tmztype template.
+ *
+ * If the mail file is created by Sys V (Solaris), there are
+ * no seconds in the time. If the mail is created by another
+ * program such as imapd, it might have timezone as
+ * <-|+>nnnn (-0800 for instance) at the end.
*/
/*
@@ -157,19 +162,34 @@ copyin(src, space)
* 'a' A lower case char
* ' ' A space
* '0' A digit
- * 'O' An optional digit or space
+ * 'O' A digit or space
+ * 'p' A punctuation char
+ * 'P' A punctuation char or space
* ':' A colon
* 'N' A new line
*/
-char ctype[] = "Aaa Aaa O0 00:00:00 0000";
-char tmztype[] = "Aaa Aaa O0 00:00:00 AAA 0000";
+
+static char *date_formats[] = {
+ "Aaa Aaa O0 00:00:00 0000", /* Mon Jan 01 23:59:59 2001 */
+ "Aaa Aaa O0 00:00:00 AAA 0000", /* Mon Jan 01 23:59:59 PST 2001 */
+ "Aaa Aaa O0 00:00:00 0000 p0000", /* Mon Jan 01 23:59:59 2001 -0800 */
+ "Aaa Aaa O0 00:00 0000", /* Mon Jan 01 23:59 2001 */
+ "Aaa Aaa O0 00:00 AAA 0000", /* Mon Jan 01 23:59 PST 2001 */
+ "Aaa Aaa O0 00:00 0000 p0000", /* Mon Jan 01 23:59 2001 -0800 */
+ NULL
+};
int
isdate(date)
char date[];
{
+ int i;
- return (cmatch(date, ctype) || cmatch(date, tmztype));
+ for(i = 0; date_formats[i] != NULL; i++) {
+ if (cmatch(date, date_formats[i]))
+ return (1);
+ }
+ return (0);
}
/*
@@ -204,6 +224,15 @@ cmatch(cp, tp)
return (0);
cp++;
break;
+ case 'p':
+ if (!ispunct(*cp++))
+ return (0);
+ break;
+ case 'P':
+ if (*cp != ' ' && !ispunct(*cp))
+ return (0);
+ cp++;
+ break;
case ':':
if (*cp++ != ':')
return (0);
OpenPOWER on IntegriCloud