BSD 4_4 release
[unix-history] / usr / src / usr.bin / vacation / vacation.c
index 8615c20..1169b51 100644 (file)
@@ -1,18 +1,44 @@
 /*
 /*
- * Copyright (c) 1983, 1987 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1987, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1983, 1987 Regents of the University of California.\n\
- All rights reserved.\n";
+static char copyright[] =
+"@(#) Copyright (c) 1983, 1987, 1993\n\
      The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)vacation.c 5.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)vacation.c 8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -157,8 +183,7 @@ main(argc, argv)
  * readheaders --
  *     read mail headers
  */
  * readheaders --
  *     read mail headers
  */
-getfrom(shortp)
-char **shortp;
+readheaders()
 {
        register ALIAS *cur;
        register char *p;
 {
        register ALIAS *cur;
        register char *p;
@@ -221,7 +246,19 @@ findme:                    for (cur = names; !tome && cur; cur = cur->next)
        }
 }
 
        }
 }
 
-       return start;
+/*
+ * nsearch --
+ *     do a nice, slow, search of a string for a substring.
+ */
+nsearch(name, str)
+       register char *name, *str;
+{
+       register int len;
+
+       for (len = strlen(name); *str; ++str)
+               if (*str == *name && !strncasecmp(name, str, len))
+                       return(1);
+       return(0);
 }
 
 /*
 }
 
 /*
@@ -272,26 +309,29 @@ junkmail()
  *     find out if user has gotten a vacation message recently.
  *     use bcopy for machines with alignment restrictions
  */
  *     find out if user has gotten a vacation message recently.
  *     use bcopy for machines with alignment restrictions
  */
-char *user;
+recent()
 {
        DBT key, data;
        time_t then, next;
 
 {
        DBT key, data;
        time_t then, next;
 
-       if (d.dptr == NULL)
-               return FALSE;
-       bcopy(d.dptr, (char *)&ldbrec, sizeof ldbrec);  /* realign data */
-       return ldbrec.sentdate + Timeout >= time((time_t *)0);
-}
+       /* get interval time */
+       key.data = VIT;
+       key.size = sizeof(VIT);
+       if ((db->get)(db, &key, &data, 0))
+               next = SECSPERDAY * DAYSPERWEEK;
+       else
+               bcopy(data.data, &next, sizeof(next));
 
 
-#ifndef VMUNIX
-bcopy(from, to, size)
-register char *to, *from;
-register unsigned size;
-{
-       while (size-- > 0)
-               *to++ = *from++;
+       /* get record for this address */
+       key.data = from;
+       key.size = strlen(from);
+       if (!(db->get)(db, &key, &data, 0)) {
+               bcopy(data.data, &then, sizeof(then));
+               if (next == LONG_MAX || then + next > time(NULL))
+                       return(1);
+       }
+       return(0);
 }
 }
-#endif
 
 /*
  * setinterval --
 
 /*
  * setinterval --