|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T b
Length: 1878 (0x756)
Types: TextFile
Names: »binmail.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
└─⟦2fafebccf⟧ »EurOpenD3/mail/smail3.1.19.tar.Z«
└─⟦bcd2bc73f⟧
└─⟦this⟧ »pd/binmail/binmail.c«
/* @(#)binmail.c 1.3 7/22/88 02:33:39 */
/* This program will be used in place of /bin/mail on SVR2 sites.
* It looks at the arguments and decides whether to call
* SMAIL for sending mail, or LMAIL for reading mail.
*
* before installing as /bin/mail, move the stock /bin/mail to /bin/lmail
*
*/
#include <stdio.h>
#include "defs.h"
#ifndef LMAIL
#define LMAIL "/bin/lmail"
#endif
#ifndef SMAIL
#define SMAIL "/usr/lib/sendmail"
#endif
#define TRUE 1
#define FALSE 0
char *program;
void perror(), exit(), usage();
main(argc, argv)
int argc;
char *argv[];
{
int i, j, c; /* indexes */
int reading = FALSE; /* TRUE => user read mail, run LMAIL */
int sending = FALSE; /* TRUE => sending mail, call Smail directly */
extern int optind;
extern char *optarg;
/*
* parse args
*/
program = argv[0];
if(argc == 1) {
/* no args means just a user wanting to read their mail */
reading = TRUE;
} else {
while((c = getopt(argc, argv, "epqrtf:")) != EOF) {
switch(c) {
case 'e':
case 'p':
case 'q':
case 'r':
case 'f':
reading = TRUE;
break;
case 't':
sending = TRUE;
break;
default:
usage();
exit(1);
}
}
}
/* any arguments left over -> sending */
if(argc > optind) {
sending = TRUE;
}
if((reading == TRUE) && (sending == TRUE)) {
usage();
exit(1);
}
/*
* form arguments
*/
if(sending == TRUE) {
argv[0] = SMAIL;
for(i = 1, j = optind; i < argc; i++, j++) {
argv[i] = argv[j];
}
argv[i] = NULL;
} else {
argv[0] = LMAIL;
argv[1] = NULL;
}
/*
* exec our real program
*/
(void) execv(argv[0], argv);
(void) fprintf(stderr, "%s: execv(\"%s\", argv) failed: ",
program, argv[0]);
perror("");
exit(1);
}
void
usage()
{
(void) fprintf(stderr, "usage: %s [ -epqr ] [ -f file ]\n", program);
(void) fprintf(stderr, "or usage: %s [ -t ] persons\n", program);
}