.na
.B whom
.RB [ \-tocc " | " \-notocc ]
+.RB [ \-dcc " | " \-nodcc ]
.RB [ \-bcc " | " \-nobcc ]
.RB [ \-alias " | " \-noalias ]
.RB [ \-Version ]
.PP
Per default,
.B whom
-lists both, sighted and hidden, recipients.
+lists sighted and hidden recipients.
The
.BR \-notocc
-option suppresses the listing of sighted recipients.
+option suppresses the listing of sighted recipients (To and Cc).
+The
+.BR \-nodcc
+option suppresses the listing of hidden DCC recipients.
The
.BR \-nobcc
-option suppresses the listing of hidden recipients.
-If the printing of both kinds of recipients, visible and hidden,
-is requested and hidden recipients are present,
-they are separated by a line similar to ``\0==BCC==''.
+option suppresses the listing of hidden BCC recipients.
+If the printing of multiple kinds of recipients
+is requested and hidden ones are present,
+they are separated by a line similar to ``\0==DCC=='' or ``\0==BCC==''.
The actual separator may change, but the regular expression
-/^[\0\\t].*BCC/ should always match.
+/^[\0\\t].*[DB]CC/ should always match.
No separator is printed if only one kind of recipients is requested
-for printing, or if both are requested but no hidden recipients are
+for printing, or if multiple are requested but no hidden recipients are
present.
.PP
With
.SH DEFAULTS
.nf
.RB ` \-tocc '
+.RB ` \-dcc '
.RB ` \-bcc '
.RB ` \-alias '
.fi
--- /dev/null
+# test whom
+
+. "$MH_TEST_COMMON"
+
+
+draft="$MH_TEST_DIR/whom-$$.draft"
+
+
+# to + cc headers
+#
+cat >"$draft" <<!
+To: alice, gill
+Cc: jack, charly
+!
+runandcheck 'whom "$draft"' <<!
+alice
+gill
+jack
+charly
+!
+
+
+runandcheck 'whom -notocc -nodcc -nobcc "$draft"' <<!
+whom: use at least one of: -tocc -dcc -bcc
+!
+
+
+# to + dcc headers
+#
+cat >"$draft" <<!
+To: alice, gill
+Dcc: jack, charly
+!
+runandcheck 'whom "$draft"' <<!
+alice
+gill
+ ==DCC==
+jack
+charly
+!
+
+
+
+
+# to + bcc headers
+#
+cat >"$draft" <<!
+To: alice, gill
+Bcc: jack, charly
+!
+runandcheck 'whom "$draft"' <<!
+alice
+gill
+ ==BCC==
+jack
+charly
+!
+
+
+
+# to + dcc + bcc headers
+#
+cat >"$draft" <<!
+To: alice, gill
+Dcc: jack
+Bcc: charly
+!
+runandcheck 'whom "$draft"' <<!
+alice
+gill
+ ==DCC==
+jack
+ ==BCC==
+charly
+!
+
+
+runandcheck 'whom -nodcc -nobcc "$draft"' <<!
+alice
+gill
+!
+
+runandcheck 'whom -notocc -nobcc "$draft"' <<!
+jack
+!
+
+runandcheck 'whom -notocc -nodcc "$draft"' <<!
+charly
+!
+
+runandcheck 'whom -notocc "$draft"' <<!
+ ==DCC==
+jack
+ ==BCC==
+charly
+!
+
+runandcheck 'whom -nodcc "$draft"' <<!
+alice
+gill
+ ==BCC==
+charly
+!
+
+runandcheck 'whom -nobcc "$draft"' <<!
+alice
+gill
+ ==DCC==
+jack
+!
{ "tocc", 0 },
#define NTOCCSW 3
{ "notocc", 2 },
-#define BCCSW 4
+#define DCCSW 4
+ { "dcc", 0 },
+#define NDCCSW 5
+ { "nodcc", 2 },
+#define BCCSW 6
{ "bcc", 0 },
-#define NBCCSW 5
+#define NBCCSW 7
{ "nobcc", 2 },
-#define ALISW 6
+#define ALISW 8
{ "alias", 0 },
-#define NALISW 7
+#define NALISW 9
{ "noalias", 2 },
{ NULL, 0 }
};
#define HRESENT (1<<1)
#define HTO (1<<2)
#define HCC (1<<3)
-#define HBCC (1<<4)
+#define HDCC (1<<4)
+#define HBCC (1<<5)
struct mailname head = {0};
struct mailname *mp = &head;
static int resent = 0; /* consider normal or resent headers */
static int toccsw = 1; /* list sighted recipients */
-static int bccsw = 1; /* list hidden recipients */
+static int dccsw = 1; /* list hidden dcc recipients */
+static int bccsw = 1; /* list hidden bcc recipients */
static int alisw = 1; /* expand aliases on rcpt addrs */
-static char *separator = "\t==BCC==";
+static char *dccsep = "\t==DCC==";
+static char *bccsep = "\t==BCC==";
/*
static int process(char *);
static void proc_hdr(char *, char *);
static int print(void);
+static int printdcc(void);
static int printbcc(void);
static void printone(struct mailname *);
toccsw = 0;
continue;
+ case DCCSW:
+ dccsw = 1;
+ continue;
+ case NDCCSW:
+ dccsw = 0;
+ continue;
+
case BCCSW:
bccsw = 1;
continue;
if (!filep) {
adios(EX_USAGE, NULL, "usage: %s [switches] file ...", invo_name);
}
- if (!toccsw && !bccsw) {
- adios(EX_USAGE, NULL, "give -tocc or -bcc or both to produce output");
+ if (!toccsw && !dccsw && !bccsw) {
+ adios(EX_USAGE, NULL, "use at least one of: -tocc -dcc -bcc");
}
for (filep=0; files[filep]; filep++) {
process(files[filep]);
naddrs += n;
cmd = add("ali -list", NULL);
+ if ((n=printdcc()) && alisw) {
+ if (!(in = popen(cmd, "r"))) {
+ adios(EX_IOERR, "popen", "unable to");
+ }
+ while (fgets(buf, sizeof buf, in)) {
+ fputs(buf, stdout);
+ }
+ pclose(in);
+ }
+ free(cmd);
+ naddrs += n;
+
+ cmd = add("ali -list", NULL);
if ((n=printbcc()) && alisw) {
if (!(in = popen(cmd, "r"))) {
adios(EX_IOERR, "popen", "unable to");
}
free(cmd);
naddrs += n;
+
return naddrs ? 0 : 1;
}
type = HTO;
} else if (mh_strcasecmp(name, "cc")==0) {
type = HCC;
+ } else if (mh_strcasecmp(name, "dcc")==0) {
+ type = HDCC;
} else if (mh_strcasecmp(name, "bcc")==0) {
type = HBCC;
} else if (mh_strcasecmp(name, "resent-to")==0) {
type = (HRESENT | HTO);
} else if (mh_strcasecmp(name, "resent-cc")==0) {
type = (HRESENT | HCC);
+ } else if (mh_strcasecmp(name, "resent-dcc")==0) {
+ type = (HRESENT | HDCC);
} else if (mh_strcasecmp(name, "resent-bcc")==0) {
type = (HRESENT | HBCC);
}
if ((type&HTO || type&HCC) && !toccsw) {
return;
}
+ if ((type&HDCC) && !dccsw) {
+ return;
+ }
if ((type&HBCC) && !bccsw) {
return;
}
** Walk through the list of addresses and print the right ones.
*/
static int
+printdcc(void)
+{
+ int naddrs = 0;
+
+ for (mp=head.m_next; mp; mp=mp->m_next) {
+ /* skip unless both are resent or neither one is */
+ if (resent != (mp->m_type&HRESENT)) {
+ continue;
+ }
+ if (mp->m_type & HDCC) {
+ if (!naddrs && (toccsw || bccsw)) {
+ puts(dccsep);
+ }
+ naddrs++;
+ printone(mp);
+ }
+ }
+ return naddrs;
+}
+
+/*
+** Walk through the list of addresses and print the right ones.
+*/
+static int
printbcc(void)
{
int naddrs = 0;
continue;
}
if (mp->m_type & HBCC) {
- if (!naddrs && toccsw) {
- puts(separator);
+ if (!naddrs && (toccsw || dccsw)) {
+ puts(bccsep);
}
naddrs++;
printone(mp);