added extra doignore argument to send() calls
[unix-history] / usr / src / usr.bin / mail / names.c
index d83e1e3..73af4c6 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "rcv.h"
 
 
 #include "rcv.h"
 
-static char *SccsId = "@(#)names.c     1.1 %G%";
+static char *SccsId = "@(#)names.c     2.6 %G%";
 
 /*
  * Allocate a single element of a name list,
 
 /*
  * Allocate a single element of a name list,
@@ -253,7 +253,7 @@ outof(names, fo, hp)
        time(&now);
        date = ctime(&now);
        while (np != NIL) {
        time(&now);
        date = ctime(&now);
        while (np != NIL) {
-               if (!any('/', np->n_name) && np->n_name[0] != '|') {
+               if (!isfileaddr(np->n_name) && np->n_name[0] != '|') {
                        np = np->n_flink;
                        continue;
                }
                        np = np->n_flink;
                        continue;
                }
@@ -306,9 +306,10 @@ outof(names, fo, hp)
                        wait(&s);
                        switch (pid = fork()) {
                        case 0:
                        wait(&s);
                        switch (pid = fork()) {
                        case 0:
-                               signal(SIGHUP, SIG_IGN);
-                               signal(SIGINT, SIG_IGN);
-                               signal(SIGQUIT, SIG_IGN);
+                               sigchild();
+                               sigsys(SIGHUP, SIG_IGN);
+                               sigsys(SIGINT, SIG_IGN);
+                               sigsys(SIGQUIT, SIG_IGN);
                                close(0);
                                dup(image);
                                close(image);
                                close(0);
                                dup(image);
                                close(image);
@@ -381,6 +382,32 @@ cant:
        return(top);
 }
 
        return(top);
 }
 
+/*
+ * Determine if the passed address is a local "send to file" address.
+ * If any of the network metacharacters precedes any slashes, it can't
+ * be a filename.  We cheat with .'s to allow path names like ./...
+ */
+isfileaddr(name)
+       char *name;
+{
+       register char *cp;
+       extern char *metanet;
+
+       if (any('@', name))
+               return(0);
+       if (*name == '+')
+               return(1);
+       for (cp = name; *cp; cp++) {
+               if (*cp == '.')
+                       continue;
+               if (any(*cp, metanet))
+                       return(0);
+               if (*cp == '/')
+                       return(1);
+       }
+       return(0);
+}
+
 /*
  * Map all of the aliased users in the invoker's mailrc
  * file and insert them into the list.
 /*
  * Map all of the aliased users in the invoker's mailrc
  * file and insert them into the list.
@@ -566,10 +593,7 @@ unpack(np)
                        n = n->n_flink;
                        continue;
                }
                        n = n->n_flink;
                        continue;
                }
-               cp = n->n_name;
-               while (*cp == '\\')
-                       cp++;
-               *ap++ = cp;
+               *ap++ = n->n_name;
                n = n->n_flink;
        }
        *ap = NOSTR;
                n = n->n_flink;
        }
        *ap = NOSTR;
@@ -588,7 +612,7 @@ mechk(names)
        register struct name *np;
 
        for (np = names; np != NIL; np = np->n_flink)
        register struct name *np;
 
        for (np = names; np != NIL; np = np->n_flink)
-               if ((np->n_type & GDEL) == 0 && equal(myname, np->n_name)) {
+               if ((np->n_type & GDEL) == 0 && equal(np->n_name, myname)) {
                        selfsent++;
                        return;
                }
                        selfsent++;
                        return;
                }
@@ -747,7 +771,6 @@ count(np)
 /*
  * Delete the given name from a namelist.
  */
 /*
  * Delete the given name from a namelist.
  */
-
 struct name *
 delname(np, name)
        register struct name *np;
 struct name *
 delname(np, name)
        register struct name *np;
@@ -756,7 +779,7 @@ delname(np, name)
        register struct name *p;
 
        for (p = np; p != NIL; p = p->n_flink)
        register struct name *p;
 
        for (p = np; p != NIL; p = p->n_flink)
-               if (equal(p->n_name, name)) {
+               if (icequal(p->n_name, name)) {
                        if (p->n_blink == NIL) {
                                if (p->n_flink != NIL)
                                        p->n_flink->n_blink = NIL;
                        if (p->n_blink == NIL) {
                                if (p->n_flink != NIL)
                                        p->n_flink->n_blink = NIL;