4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / mail / head.c
index ca78f6e..73c73d8 100644 (file)
@@ -1,14 +1,16 @@
 /*
 /*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)head.c      5.3 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)head.c     8.1 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "rcv.h"
 
 #include "rcv.h"
+#include "extern.h"
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -21,6 +23,7 @@ static char *sccsid = "@(#)head.c     5.3 (Berkeley) %G%";
  * Return true if yes.  Note the extreme pains to
  * accomodate all funny formats.
  */
  * Return true if yes.  Note the extreme pains to
  * accomodate all funny formats.
  */
+int
 ishead(linebuf)
        char linebuf[];
 {
 ishead(linebuf)
        char linebuf[];
 {
@@ -48,6 +51,7 @@ ishead(linebuf)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
+void
 fail(linebuf, reason)
        char linebuf[], reason[];
 {
 fail(linebuf, reason)
        char linebuf[], reason[];
 {
@@ -65,6 +69,7 @@ fail(linebuf, reason)
  * pointers into the copied line in the passed headline
  * structure.  Actually, it scans.
  */
  * pointers into the copied line in the passed headline
  * structure.  Actually, it scans.
  */
+void
 parse(line, hl, pbuf)
        char line[], pbuf[];
        register struct headline *hl;
 parse(line, hl, pbuf)
        char line[], pbuf[];
        register struct headline *hl;
@@ -119,66 +124,66 @@ copyin(src, space)
  * date string as documented in the manual.  The template
  * below is used as the criterion of correctness.
  * Also, we check for a possible trailing time zone using
  * date string as documented in the manual.  The template
  * below is used as the criterion of correctness.
  * Also, we check for a possible trailing time zone using
- * the auxtype template.
+ * the tmztype template.
  */
 
  */
 
-#define        L       1               /* A lower case char */
-#define        S       2               /* A space */
-#define        D       3               /* A digit */
-#define        O       4               /* An optional digit or space */
-#define        C       5               /* A colon */
-#define        N       6               /* A new line */
-#define U      7               /* An upper case char */
-
-char ctypes[] = { U,L,L,S,U,L,L,S,O,D,S,D,D,C,D,D,C,D,D,S,D,D,D,D,0 };
-char tmztypes[] = { U,L,L,S,U,L,L,S,O,D,S,D,D,C,D,D,C,D,D,S,U,U,U,S,D,D,D,D,0 };
+/*
+ * 'A' An upper case char
+ * 'a' A lower case char
+ * ' ' A space
+ * '0' A digit
+ * 'O' An optional digit 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";
 
 
+int
 isdate(date)
        char date[];
 {
 
 isdate(date)
        char date[];
 {
 
-       if (cmatch(date, ctypes))
-               return (1);
-       return (cmatch(date, tmztypes));
+       return cmatch(date, ctype) || cmatch(date, tmztype);
 }
 
 /*
  * Match the given string (cp) against the given template (tp).
  * Return 1 if they match, 0 if they don't
  */
 }
 
 /*
  * Match the given string (cp) against the given template (tp).
  * Return 1 if they match, 0 if they don't
  */
-
+int
 cmatch(cp, tp)
        register char *cp, *tp;
 {
 
        while (*cp && *tp)
                switch (*tp++) {
 cmatch(cp, tp)
        register char *cp, *tp;
 {
 
        while (*cp && *tp)
                switch (*tp++) {
-               case L:
+               case 'a':
                        if (!islower(*cp++))
                                return 0;
                        break;
                        if (!islower(*cp++))
                                return 0;
                        break;
-               case U:
+               case 'A':
                        if (!isupper(*cp++))
                                return 0;
                        break;
                        if (!isupper(*cp++))
                                return 0;
                        break;
-               case S:
+               case ' ':
                        if (*cp++ != ' ')
                                return 0;
                        break;
                        if (*cp++ != ' ')
                                return 0;
                        break;
-               case D:
+               case '0':
                        if (!isdigit(*cp++))
                                return 0;
                        break;
                        if (!isdigit(*cp++))
                                return 0;
                        break;
-               case O:
+               case 'O':
                        if (*cp != ' ' && !isdigit(*cp))
                                return 0;
                        cp++;
                        break;
                        if (*cp != ' ' && !isdigit(*cp))
                                return 0;
                        cp++;
                        break;
-               case C:
+               case ':':
                        if (*cp++ != ':')
                                return 0;
                        break;
                        if (*cp++ != ':')
                                return 0;
                        break;
-               case N:
+               case 'N':
                        if (*cp++ != '\n')
                                return 0;
                        break;
                        if (*cp++ != '\n')
                                return 0;
                        break;
@@ -221,17 +226,3 @@ nextword(wp, wbuf)
                return (NOSTR);
        return (wp - 1);
 }
                return (NOSTR);
        return (wp - 1);
 }
-
-/*
- * Is c contained in s?
- */
-any(c, s)
-       register c;
-       register char *s;
-{
-
-       while (*s)
-               if (*s++ == c)
-                       return 1;
-       return 0;
-}