1: #ifndef lint
   2: static  char *sccsid = "@(#)prmail.c	4.1 (Berkeley) 10/9/80";
   3: #endif
   4: 
   5: #include <pwd.h>
   6: /*
   7:  * prmail
   8:  */
   9: struct  passwd *getpwuid();
  10: char    *getenv();
  11: 
  12: main(argc, argv)
  13:     int argc;
  14:     char **argv;
  15: {
  16:     register struct passwd *pp;
  17: 
  18:     --argc, ++argv;
  19:     if (chdir("/usr/spool/mail") < 0) {
  20:         perror("/usr/spool/mail");
  21:         exit(1);
  22:     }
  23:     if (argc == 0) {
  24:         char *user = getenv("USER");
  25:         if (user == 0) {
  26:             pp = getpwuid(getuid());
  27:             if (pp == 0) {
  28:                 printf("Who are you?\n");
  29:                 exit(1);
  30:             }
  31:             user = pp->pw_name;
  32:         }
  33:         prmail(user, 0);
  34:     } else
  35:         while (--argc >= 0)
  36:             prmail(*argv++, 1);
  37:     exit(0);
  38: }
  39: 
  40: #include <sys/types.h>
  41: #include <sys/stat.h>
  42: 
  43: prmail(user, other)
  44:     char *user;
  45: {
  46:     struct stat stb;
  47:     char cmdbuf[256];
  48: 
  49:     if (stat(user, &stb) < 0) {
  50:         printf("No mail for %s.\n", user);
  51:         return;
  52:     }
  53:     if (access(user, "4") < 0) {
  54:         printf("Mailbox for %s unreadable\n", user);
  55:         return;
  56:     }
  57:     if (other)
  58:         printf(">>> %s <<<\n", user);
  59:     sprintf(cmdbuf, "more %s", user);
  60:     system(cmdbuf);
  61:     if (other)
  62:         printf("-----\n\n");
  63: }

Defined functions

main defined in line 12; never used
prmail defined in line 43; used 2 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1982-09-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 807
Valid CSS Valid XHTML 1.0 Strict