summaryrefslogtreecommitdiffstats
path: root/usr.bin/from/from.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-07-26 23:12:12 +0000
committergreen <green@FreeBSD.org>1999-07-26 23:12:12 +0000
commitf54e4029ae10032ebfc72c8c4ac1f8d954ebfe97 (patch)
tree2bea0a9ad4c01bcb3c798858f0cff096b836f494 /usr.bin/from/from.c
parent6eff605357b85284d28c7d3510e9d7370e3196a8 (diff)
downloadFreeBSD-src-f54e4029ae10032ebfc72c8c4ac1f8d954ebfe97.zip
FreeBSD-src-f54e4029ae10032ebfc72c8c4ac1f8d954ebfe97.tar.gz
*** empty log message ***
Diffstat (limited to 'usr.bin/from/from.c')
-rw-r--r--usr.bin/from/from.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/usr.bin/from/from.c b/usr.bin/from/from.c
index c246ad4..bd0e580 100644
--- a/usr.bin/from/from.c
+++ b/usr.bin/from/from.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)from.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: from.c,v 1.5 1997/07/08 10:59:50 charnier Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -66,7 +66,7 @@ main(argc, argv)
extern char *optarg;
extern int optind;
struct passwd *pwd;
- int ch, newline;
+ int ch, count, newline;
char *file, *sender, *p;
#if MAXPATHLEN > BUFSIZ
char buf[MAXPATHLEN];
@@ -75,8 +75,12 @@ main(argc, argv)
#endif
file = sender = NULL;
- while ((ch = getopt(argc, argv, "f:s:")) != -1)
- switch((char)ch) {
+ count = -1;
+ while ((ch = getopt(argc, argv, "cf:s:")) != -1)
+ switch (ch) {
+ case 'c':
+ count = 0;
+ break;
case 'f':
file = optarg;
break;
@@ -120,17 +124,24 @@ main(argc, argv)
continue;
}
if (newline && !strncmp(buf, "From ", 5) &&
- (!sender || match(buf + 5, sender)))
- printf("%s", buf);
+ (!sender || match(buf + 5, sender))) {
+ if (count != -1)
+ count++;
+ else
+ printf("%s", buf);
+ }
newline = 0;
}
+ if (count != -1)
+ printf("There %s %d message%s in your incoming mailbox.\n",
+ count == 1 ? "is" : "are", count, count == 1 ? "" : "s");
exit(0);
}
static void
usage()
{
- fprintf(stderr, "usage: from [-f file] [-s sender] [user]\n");
+ fprintf(stderr, "usage: from [-c] [-f file] [-s sender] [user]\n");
exit(1);
}
OpenPOWER on IntegriCloud