BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / vacation / vacation.c
index 334aa4e..681d0ee 100644 (file)
@@ -2,7 +2,19 @@
  * Copyright (c) 1983, 1987 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983, 1987 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -12,7 +24,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)vacation.c 5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)vacation.c 5.17 (Berkeley) 6/1/90";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -156,8 +168,7 @@ usage:                      syslog(LOG_NOTICE, "uid %u: usage: vacation [-i] [-a alias] login\n", g
  * 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;
@@ -217,7 +228,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);
 }
 
 /*
 }
 
 /*
@@ -266,26 +289,31 @@ 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()
 {
        datum key, data;
        time_t then, next, time();
 
 {
        datum key, data;
        time_t then, next, time();
 
-       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.dptr = VIT;
+       key.dsize = sizeof(VIT) - 1;
+       data = dbm_fetch(db, key);
+       if (data.dptr)
+               bcopy(data.dptr, (char *)&next, sizeof(next));
+       else
+               next = SECSPERDAY * DAYSPERWEEK;
 
 
-#ifndef VMUNIX
-bcopy(from, to, size)
-register char *to, *from;
-register unsigned size;
-{
-       while (size-- > 0)
-               *to++ = *from++;
+       /* get record for this address */
+       key.dptr = from;
+       key.dsize = strlen(from);
+       data = dbm_fetch(db, key);
+       if (data.dptr) {
+               bcopy(data.dptr, (char *)&then, sizeof(then));
+               if (next == LONG_MAX || then + next > time((time_t *)NULL))
+                       return(1);
+       }
+       return(0);
 }
 }
-#endif
 
 /*
  * setinterval --
 
 /*
  * setinterval --