maddr: -a to only print address part

pull/2/head
Christian Neukirchen 8 years ago
parent cfec8ca377
commit edf4458016

@ -8,6 +8,7 @@
#include "blaze822.h"
static int aflag;
static char defaulthflags[] = "from:sender:reply-to:to:cc:bcc:"
"resent-from:resent-sender:resent-to:resent-cc:resent-bcc:";
static char *hflag = defaulthflags;
@ -40,7 +41,11 @@ addr(char *file)
sizeof dispdec - 1, "UTF-8");
dispdec[sizeof dispdec - 1] = 0;
printf("%s <%s>\n", dispdec, addr);
if (aflag)
printf("%s\n", addr);
else
printf("%s <%s>\n",
dispdec, addr);
} else if (addr) {
printf("%s\n", addr);
}
@ -59,11 +64,13 @@ int
main(int argc, char *argv[])
{
int c;
while ((c = getopt(argc, argv, "h:")) != -1)
while ((c = getopt(argc, argv, "ah:")) != -1)
switch(c) {
case 'a': aflag = 1; break;
case 'h': hflag = optarg; break;
default:
fprintf(stderr, "Usage: maddr [-h headers] [msgs...]\n");
fprintf(stderr,
"Usage: maddr [-a] [-h headers] [msgs...]\n");
exit(1);
}

@ -6,6 +6,7 @@
.Nd extract mail addresses from messages
.Sh SYNOPSIS
.Nm
.Op Fl a
.Op Fl h Ar headers
.Op Ar msgs\ ...
.Sh DESCRIPTION
@ -33,6 +34,8 @@ will read filenames from standard input.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl a
Only print the address part of the address, not the display name.
.It Fl h Ar headers
Only search the colon-separated list of
.Ar headers

Loading…
Cancel
Save