home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / from.c < prev    next >
C/C++ Source or Header  |  1980-02-17  |  567b  |  27 lines

  1. /* Copyright (c) 1979 Regents of the University of California */
  2. #include <retrofit.h>
  3. #include <stdio.h>
  4. #include <pwd.h>
  5.  
  6. struct    passwd *getpwuid();
  7.  
  8. main()
  9. {
  10.     char lbuf[BUFSIZ];
  11.     register struct passwd *pp;
  12.  
  13.     if (chdir("/usr/spool/mail") < 0)
  14.         exit(1);
  15.     pp = getpwuid(getuid());
  16.     if (pp == 0) {
  17.         fprintf(stderr, "Who are you?\n");
  18.         exit(1);
  19.     }
  20.     if (freopen(pp->pw_name, "r", stdin) == NULL)
  21.         exit(0);
  22.     while(fgets(lbuf, sizeof lbuf, stdin) != NULL)
  23.         if (lbuf[0] == 'F' && lbuf[1] == 'r' && lbuf[2] == 'o' && lbuf[3] == 'm')
  24.             printf("%s", lbuf);
  25.     exit(0);
  26. }
  27.