|
|
1.1 ! root 1: #ifndef lint ! 2: static char *sccsid = "@(#)svbinmail.c 2.5 (smail) 9/15/87"; ! 3: #endif ! 4: /* */ ! 5: /* This program will be used in place of /bin/mail on SVR2 sites. ! 6: /* It looks at the arguments and decides whether to call ! 7: /* SENDER for sending mail, or READER for reading mail. ! 8: /* ! 9: /* before installing as /bin/mail, move the stock /bin/mail to /bin/lmail ! 10: /* ! 11: /* */ ! 12: ! 13: #include <stdio.h> ! 14: #include "defs.h" ! 15: ! 16: #ifdef SENDMAIL ! 17: #define SENDER SENDMAIL ! 18: #else ! 19: #define SENDER "/bin/rmail" ! 20: #endif ! 21: ! 22: #define READER "/bin/lmail" ! 23: ! 24: #define TRUE 1 ! 25: #define FALSE 0 ! 26: ! 27: char prog[128]; ! 28: ! 29: void perror(), exit(), usage(); ! 30: ! 31: main(argc, argv) ! 32: int argc; ! 33: char *argv[]; ! 34: { ! 35: extern int optind; ! 36: extern char *optarg; ! 37: ! 38: int i, j, c; ! 39: int reading, sending; ! 40: ! 41: reading = sending = FALSE; ! 42: ! 43: (void) strcpy(prog, argv[0]); ! 44: ! 45: if(argc == 1) { ! 46: reading = TRUE; ! 47: } else { ! 48: while((c = getopt(argc, argv, "epqrtf:")) != EOF) { ! 49: switch(c) { ! 50: case 'e': ! 51: case 'p': ! 52: case 'q': ! 53: case 'r': ! 54: case 'f': ! 55: reading = TRUE; ! 56: break; ! 57: case 't': ! 58: sending = TRUE; ! 59: break; ! 60: default: ! 61: usage(); ! 62: return(1); ! 63: } ! 64: } ! 65: } ! 66: ! 67: /* any arguments left over -> sending */ ! 68: if(argc > optind) { ! 69: sending = TRUE; ! 70: } ! 71: ! 72: if((reading == TRUE) && (sending == TRUE)) { ! 73: usage(); ! 74: return(1); ! 75: } ! 76: ! 77: if(sending == TRUE) { ! 78: argv[0] = SENDER; ! 79: for(i = 1, j = optind; j < argc; i++, j++) { ! 80: argv[i] = argv[j]; ! 81: } ! 82: argv[i] = NULL; ! 83: } else { ! 84: argv[0] = READER; ! 85: } ! 86: ! 87: (void) execvp(argv[0], argv); ! 88: (void) fprintf(stderr, "%s: execvp(\"%s\", argv) failed: ", ! 89: prog, argv[0]); ! 90: perror(""); ! 91: return(1); ! 92: } ! 93: ! 94: void ! 95: usage() ! 96: { ! 97: (void) fprintf(stderr, "usage:\t%s [ -epqr ] [ -f file ]\n", prog); ! 98: (void) fprintf(stderr, "\t%s [ -t ] persons\n", prog); ! 99: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.