added "more" command
[unix-history] / usr / src / usr.bin / mail / names.c
index 73af4c6..cb7e24d 100644 (file)
@@ -1,4 +1,12 @@
-#
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)names.c    5.1 (Berkeley) %G%";
+#endif not lint
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -8,8 +16,6 @@
 
 #include "rcv.h"
 
 
 #include "rcv.h"
 
-static char *SccsId = "@(#)names.c     2.6 %G%";
-
 /*
  * Allocate a single element of a name list,
  * initialize its name field to the passed
 /*
  * Allocate a single element of a name list,
  * initialize its name field to the passed
@@ -180,7 +186,7 @@ verify(names)
        register struct name *np, *top, *t, *x;
        register char *cp;
 
        register struct name *np, *top, *t, *x;
        register char *cp;
 
-#ifdef DELIVERMAIL
+#ifdef SENDMAIL
        return(names);
 #else
        top = names;
        return(names);
 #else
        top = names;
@@ -547,7 +553,7 @@ unpack(np)
        register struct name *n;
        char *cp;
        char hbuf[10];
        register struct name *n;
        char *cp;
        char hbuf[10];
-       int t, extra, metoo;
+       int t, extra, metoo, verbose;
 
        n = np;
        if ((t = lengthof(n)) == 0)
 
        n = np;
        if ((t = lengthof(n)) == 0)
@@ -563,12 +569,15 @@ unpack(np)
        extra = 2;
        if (rflag != NOSTR)
                extra += 2;
        extra = 2;
        if (rflag != NOSTR)
                extra += 2;
-#ifdef DELIVERMAIL
+#ifdef SENDMAIL
        extra++;
        metoo = value("metoo") != NOSTR;
        if (metoo)
                extra++;
        extra++;
        metoo = value("metoo") != NOSTR;
        if (metoo)
                extra++;
-#endif DELIVERMAIL
+       verbose = value("verbose") != NOSTR;
+       if (verbose)
+               extra++;
+#endif SENDMAIL
        if (hflag)
                extra += 2;
        top = (char **) salloc((t + extra) * sizeof cp);
        if (hflag)
                extra += 2;
        top = (char **) salloc((t + extra) * sizeof cp);
@@ -578,11 +587,13 @@ unpack(np)
                *ap++ = "-r";
                *ap++ = rflag;
        }
                *ap++ = "-r";
                *ap++ = rflag;
        }
-#ifdef DELIVERMAIL
+#ifdef SENDMAIL
        *ap++ = "-i";
        if (metoo)
                *ap++ = "-m";
        *ap++ = "-i";
        if (metoo)
                *ap++ = "-m";
-#endif DELIVERMAIL
+       if (verbose)
+               *ap++ = "-v";
+#endif SENDMAIL
        if (hflag) {
                *ap++ = "-h";
                sprintf(hbuf, "%d", hflag);
        if (hflag) {
                *ap++ = "-h";
                sprintf(hbuf, "%d", hflag);
@@ -768,18 +779,30 @@ count(np)
        return(c);
 }
 
        return(c);
 }
 
+cmpdomain(name, dname)
+       register char *name, *dname;
+{
+       char buf[BUFSIZ];
+
+       strcpy(buf, dname);
+       buf[strlen(name)] = '\0';
+       return(icequal(name, buf));
+}
+
 /*
 /*
- * Delete the given name from a namelist.
+ * Delete the given name from a namelist, using the passed
+ * function to compare the names.
  */
 struct name *
  */
 struct name *
-delname(np, name)
+delname(np, name, cmpfun)
        register struct name *np;
        char name[];
        register struct name *np;
        char name[];
+       int (* cmpfun)();
 {
        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 (icequal(p->n_name, name)) {
+               if ((* cmpfun)(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;