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

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

Loading…
Cancel
Save