summaryrefslogtreecommitdiff
path: root/usr.bin/from/from.c
diff options
context:
space:
mode:
authorBrian Feldman <green@FreeBSD.org>1999-07-26 23:12:12 +0000
committerBrian Feldman <green@FreeBSD.org>1999-07-26 23:12:12 +0000
commit82753326e883f5c3771b6b324c0f9b7bead8e5fb (patch)
tree3518350eb58d4aefc0dc1a480ab8a3979a2fb7b4 /usr.bin/from/from.c
parent73fac075b24476924bc2eef76ef193fb079647ad (diff)
downloadsrc-test2-82753326e883f5c3771b6b324c0f9b7bead8e5fb.tar.gz
src-test2-82753326e883f5c3771b6b324c0f9b7bead8e5fb.zip
Notes
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 c246ad4e150a..bd0e5804e4cf 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);
}