21 */
22
23 /*
24 * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
30
31 /*
32 * University Copyright- Copyright (c) 1982, 1986, 1988
33 * The Regents of the University of California
34 * All Rights Reserved
35 *
36 * University Acknowledgment- Portions of this document are derived from
37 * software developed by the University of California, Berkeley, and its
38 * contributors.
39 */
40
41 #pragma ident "%Z%%M% %I% %E% SMI"
42
43 /*
44 * mailx -- a modified version of a University of California at Berkeley
45 * mail program
46 *
47 * Handle name lists.
48 */
49
50 #include "rcv.h"
51 #include <locale.h>
52
53 static struct name *nalloc(char str[]);
54 static int isfileaddr(char *name);
55 static int lengthof(struct name *name);
56 static struct name *gexpand(struct name *nlist, struct grouphead *gh, int metoo, int arg_ntype);
57 static char *norm(register char *user, register char *ubuf, int nbangs);
58 static struct name *put(struct name *list, struct name *node);
59
60 /*
61 * Allocate a single element of a name list,
62 * initialize its name field to the passed
590 register struct name *n;
591 char hbuf[10];
592 int t, extra, metoo, verbose;
593
594 n = np;
595 if ((t = lengthof(n)) == 0)
596 panic("No names to unpack");
597
598 /*
599 * Compute the number of extra arguments we will need.
600 * We need at least 2 extra -- one for "mail" and one for
601 * the terminating 0 pointer.
602 * Additional spots may be needed to pass along -r and -f to
603 * the host mailer.
604 */
605
606 extra = 2;
607
608 if (rflag != NOSTR)
609 extra += 2;
610 #ifdef SENDMAIL
611 extra++;
612 metoo = value("metoo") != NOSTR;
613 if (metoo)
614 extra++;
615 verbose = value("verbose") != NOSTR;
616 if (verbose)
617 extra++;
618 if (hflag)
619 extra += 2;
620 #endif /* SENDMAIL */
621 top = (char **) salloc((t + extra) * sizeof (char *));
622 ap = top;
623 *ap++ = "mail";
624 if (rflag != NOSTR) {
625 *ap++ = "-r";
626 *ap++ = rflag;
627 }
628 #ifdef SENDMAIL
629 *ap++ = "-i";
630 if (metoo)
631 *ap++ = "-m";
632 if (verbose)
633 *ap++ = "-v";
634 if (hflag) {
635 *ap++ = "-h";
636 snprintf(hbuf, sizeof (hbuf), "%d", hflag);
637 *ap++ = savestr(hbuf);
638 }
639 #endif /* SENDMAIL */
640 while (n != NIL) {
641 if (n->n_type & GDEL) {
642 n = n->n_flink;
643 continue;
644 }
645 *ap++ = n->n_name;
646 n = n->n_flink;
647 }
648 *ap = NOSTR;
649 return(top);
650 }
651
652 /*
653 * See if the user named himself as a destination
654 * for outgoing mail. If so, set the global flag
655 * selfsent so that we avoid removing his mailbox.
656 */
657
658 void
659 mechk(struct name *names)
|
21 */
22
23 /*
24 * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
30
31 /*
32 * University Copyright- Copyright (c) 1982, 1986, 1988
33 * The Regents of the University of California
34 * All Rights Reserved
35 *
36 * University Acknowledgment- Portions of this document are derived from
37 * software developed by the University of California, Berkeley, and its
38 * contributors.
39 */
40
41 /*
42 * mailx -- a modified version of a University of California at Berkeley
43 * mail program
44 *
45 * Handle name lists.
46 */
47
48 #include "rcv.h"
49 #include <locale.h>
50
51 static struct name *nalloc(char str[]);
52 static int isfileaddr(char *name);
53 static int lengthof(struct name *name);
54 static struct name *gexpand(struct name *nlist, struct grouphead *gh, int metoo, int arg_ntype);
55 static char *norm(register char *user, register char *ubuf, int nbangs);
56 static struct name *put(struct name *list, struct name *node);
57
58 /*
59 * Allocate a single element of a name list,
60 * initialize its name field to the passed
588 register struct name *n;
589 char hbuf[10];
590 int t, extra, metoo, verbose;
591
592 n = np;
593 if ((t = lengthof(n)) == 0)
594 panic("No names to unpack");
595
596 /*
597 * Compute the number of extra arguments we will need.
598 * We need at least 2 extra -- one for "mail" and one for
599 * the terminating 0 pointer.
600 * Additional spots may be needed to pass along -r and -f to
601 * the host mailer.
602 */
603
604 extra = 2;
605
606 if (rflag != NOSTR)
607 extra += 2;
608 extra++;
609 metoo = value("metoo") != NOSTR;
610 if (metoo)
611 extra++;
612 verbose = value("verbose") != NOSTR;
613 if (verbose)
614 extra++;
615 if (hflag)
616 extra += 2;
617 top = (char **) salloc((t + extra) * sizeof (char *));
618 ap = top;
619 *ap++ = "sendmail";
620 if (rflag != NOSTR) {
621 *ap++ = "-r";
622 *ap++ = rflag;
623 }
624 *ap++ = "-i";
625 if (metoo)
626 *ap++ = "-m";
627 if (verbose)
628 *ap++ = "-v";
629 if (hflag) {
630 *ap++ = "-h";
631 snprintf(hbuf, sizeof (hbuf), "%d", hflag);
632 *ap++ = savestr(hbuf);
633 }
634 while (n != NIL) {
635 if (n->n_type & GDEL) {
636 n = n->n_flink;
637 continue;
638 }
639 *ap++ = n->n_name;
640 n = n->n_flink;
641 }
642 *ap = NOSTR;
643 return(top);
644 }
645
646 /*
647 * See if the user named himself as a destination
648 * for outgoing mail. If so, set the global flag
649 * selfsent so that we avoid removing his mailbox.
650 */
651
652 void
653 mechk(struct name *names)
|