MEP V1.02B

jantypas at hope.UUCP jantypas at hope.UUCP
Sat Nov 22 11:09:19 AEST 1986


This is not perfect, THIS IS STILL BEING TESTED.  However, some people
have very old copies.  Here's the latest and greatest.  Much thanks to
tim at brlpyr1.UUCP for hours of work and aid.


# To unbundle this package, use sh <name> NOT csh
commands.c
echo commands.c	1>&2
cat >commands.c << 'End of commands.c'
# include <stdio.h>
# include "typedefs.h"
# include "globals.h"
# include "string2.h"

FILE	*popen();

/*
 *  Check command to see if it's OK
 */
ok_command(line)
char line[];
{
	int	i;
	char	*c;

	c = line;
	while (*c != ';') c++;
	*c = '\0';
	for (i=0; i<=num_cmds; i++)
	{
		if ((strindex(line,comlist[i]) != -1) && 
			(strcmp(line,"") != 0))
		{
			return(0);
		}
	}
	return(-1);
}

/*
 * Commands.c -- Does @ checking
 *
 * Called by check_commands()
 *
 */
do_command(line)
char	line[];
{
	char *c;
	FILE *fp, *fopen();
	FILE *wp;			/* for user message on fail */
	char	name[80];
	char	buffer[80], buffer2[80];
	int	proc_id, result;
	int	status;
	char comline[80];

	line[strlen(line)-1] = '\0';
	if (strncmp(line,"@RR",3) == 0)
	{
		sprintf(namet,"/usr/ucb/Mail -s \"Return Receipt\" %s",fromline);
		fp = popen(namet,"w");
		fprintf(fp,"From MEP V. %s\n\n",MEPVERSION);
		fprintf(fp,"\nHere is the return receipt you requested.\n\n");
		fprintf(fp,"Mail From: %s\n",fromline);
		fprintf(fp,"       To: %s\n",toline);
		fprintf(fp,"  Subject: %s\n",subline);
		pclose(fp);
	}
	if ((strncmp(line,"@SH",3) == 0) && 
	    (strcmp(subline,"Command") == 0))
	{
		c = line; c += 4;
		strcpy(buffer,c);
		buffer[strlen(buffer)+1] = '\0';
		buffer[strlen(buffer)] = ';';
		if (ok_command(buffer) == 0)
		{
			char	s1[512], s2[512];
			int	count;
			
			count = 0;
			c = buffer;
			while ((*c != ' ') && (*c != '\0')) 
			{
				count++;
				c++;
			}
			if (*c == ' ')
			{
				strncpy(s1,buffer,count);
				c++;
				strcpy(s2,c);
				sprintf(buffer,"%s '%s'",s1,s2);
			}
			sprintf(buffer2,"%s | /usr/ucb/Mail -s",buffer);
			sprintf(buffer2,"%s \"%s\" %s",buffer2,line,fromline);
			proc_id = fork();
			if (proc_id == 0)
			{ execlp("/bin/sh","sh","-c",buffer2,(char *)0); 	}
			wait(&status);
		} else
		{
			sprintf(namet,"/usr/ucb/Mail -s \"MEP\" %s",fromline);
			fp = popen(namet,"w");

			if ((wp = fopen(MEPFAIL,"r")) != NULL) {
				/* send user specified message for failure */
				while (fgets(buffer2,80,wp) != NULL)
					fprintf(fp,buffer2,buffer);
				fclose(wp);
				}
			else {
				fprintf(fp,"\nYou do not have access to the command:\n");
				fprintf(fp,"\n%s\n",buffer);
				}

			pclose(fp);
		}
	}
}

check_commands()
{
	FILE *md, *fopen();
	char	buffer[512];
	
	md = fopen(namem,"r");
	fgets(buffer,512,md);
	while (!feof(md))
	{
		if (buffer[0] == '@') do_command(buffer);
		fgets(buffer,512,md);
	}
	fclose(md);
}
End of commands.c
mepinit.c
echo mepinit.c	1>&2
cat >mepinit.c << 'End of mepinit.c'
# include <stdio.h>
# include <pwd.h>
# include <utmp.h>
# if USG
# include <string.h>
# else
# include <strings.h>
# endif
# include "typedefs.h"
# include "globals.h"
/*
 * MepInit -- Will load configuration options at runtime
 *
 */

kill_newline(buffer)
char	*buffer;
{
	int i;

	for (i = 0; i< strlen(buffer); i++)
	{
		if (buffer[i] == '\n') 
		{
			buffer[i] = '\0';
			break;
		}
	}
}

parse_config(line, s)
char	line[];
struct persons *s;
{
	char	*c;
	int	s1,s2;	/* Slash pointers	*/

	c = line;
	/* Find position of slashes for later processing	*/
	s1 = strindex(c,"/");		/* Slash 1*/
	if (s1 == 0)
	{
		strcpy(s->pattern,"EMPTY");
	} else
	{
		strncpy(s->pattern,line,s1);
	}
	c += s1 +1;
	s2 = strindex(c,"/");
	if (s2 == 0)
	{
		s->op = 'S';
	} else
	{
		s->op = line[s1+s2];
	}
	c += s2+1;
	kill_newline(c);
	if (strlen(c) == 0)
	{
		strcpy(s->path,"");
	} else
	{
		strcpy(s->path,c);
	}
}
	
char	*logged(name)
char	name[];
{
	long	int	i,	size;
	struct	utmp	rec;
	FILE	*fp, *fopen();
	static	char terminal[9];

	fp = fopen("/etc/utmp","r");
	fseek(fp, 0L, 2);
	size = ftell(fp);
	rewind(fp);
	for (i = 0; i< (size/sizeof(rec)); i++)
	{
		fread(&rec,sizeof(rec),1,fp);
		if (strncmp(rec.ut_name,name,8) == 0)
		{
			strncpy(terminal,rec.ut_line,8);
			terminal[8] = '\0';
			fclose(fp);
			return(&terminal[0]);
		}
	}
	fclose(fp);
	return(NULL);
}

read_config()
{
	int	result;
	FILE	*fp, *gp, *fopen();
	char	buffer[512];
	char	buffer2[80];
	char	*c;
	char ttyname[32];
	
	result = chdir(homedir);
	fp = fopen(MEPCONFIG,"r");
	if (fp != NULL)
	{
		fgets(buffer,512,fp);
		kill_newline(buffer);
		while (!feof(fp))
		{
			if (strncmp(buffer,"biff=",5) == 0)
			{
				strcpy(buffer2,&buffer[5]);
				if (strcmp(buffer2,"yes") == 0)
				{ biffer = TRUE;   	} else 
				{ biffer = FALSE;	}
			}
			if (strncmp(buffer,"notify=",7) == 0)
			{
				strcpy(buffer2,&buffer[7]);
				if (strcmp(buffer2,"yes") == 0)
				{ notify = TRUE; } else { notify = FALSE; }
			}
			if (strncmp(buffer,"stat=",5) == 0)
			{
				strcpy(buffer2,&buffer[5]);
				if (strcmp(buffer2,"none") == 0)
				{
					log = FALSE;
				}
				else
				{
					log = TRUE;
					strcpy(logfile,&buffer[5]);
				}
			}
			fgets(buffer,512,fp);
			kill_newline(buffer);
		}
		fclose(fp);	
	} else
	{
		log = FALSE;
		notify = FALSE;
	}
}

mep_init(id)
int id;
{
	int	result;
	char	*p;
	char	buffer[80];
	char	envvalue[80];	/* Variable value	*/
	FILE	*fp, *fopen();
	struct passwd entry;
	
	/* Go to home and try to get the variables */
 	MEMCPY(&entry, getpwuid(id), sizeof(entry));
	strncpy(username,entry.pw_name,8);
	p = entry.pw_dir;
	if (p == NULL)
		error("Can't find home directory!",-1);
	strcpy(envvalue,p);
	result = chdir(envvalue);	/* Change to dir	*/
	if (result != 0)
	{
		fprintf(stderr,"Tried to switch to %s\n",envvalue);
		fprintf(stderr,"Got %d\n",result);
		error("Can't switch to home directory!",-1);
	}
	strcpy(homedir,envvalue);
	strcpy(username,entry.pw_name);

	read_config();
	result = chdir(homedir);
	/*
		 Only 100 twits allowed please.  If you have more 
		than 100 people you don't want mail from, you need
		an agent, not a mail extension
	*/
	num_twits = 0;	/* We assume no twits for now	*/
	fp = fopen(MEPTWIT,"r");
	if (fp == NULL) { /* No twits lucky you	*/ }
	else	/* Oh well, you can't expect perfection	*/
	{
		strcpy(twitlist[0].pattern,"TWITS");
		twitlist[0].op = 'D';
		strcpy(twitlist[0].path,"");
		while (!feof(fp))
		{
			num_twits++;
			fgets(buffer,80,fp);
			parse_config(buffer,&twitlist[num_twits]);
		}
		fclose(fp); 
	}
	num_cmds = 0;
	fp = fopen(MEPCOMMAND,"r");
	if (fp == NULL) { /* No stuff OK */ }
	else
	{
		strcpy(comlist[0],"");
		while (!feof(fp))
		{
			num_cmds++;
			fgets(buffer,80,fp);
			buffer[strlen(buffer)-1] = 0;
			strcpy(comlist[num_cmds],buffer);
		}
		fclose(fp);
	}
}
End of mepinit.c
message.c
echo message.c	1>&2
cat >message.c << 'End of message.c'
/*
 * Message - Gathers incoming mail and sends it to be processed
 * John Antypas
 * ...!ucbvax!ucdavis!ucrmath!hope!jantypas
 *
 * For each message in the input stream, separate off the message and
 * record the following:
 * 
 * From line:
 * user
 * Subject
 *
 * And then process any message for twits and @ commands.
 *
 */
# include <stdio.h>		/* System file and string routines	*/
# include <sys/types.h>
# if USG
# include <string.h>
# else
# include <strings.h>
# endif
# include <fcntl.h>
# include <errno.h>
# include "typedefs.h"
# include "globals.var"
# include "process.h"

extern	mep_init();

/* Error message,  Print message in s and return value v to shell */
error(s,v)
char	s[];
int	v;
{
	fprintf(stderr,"ERROR: \007%s\n",s);
	fprintf(stderr,"MEP returning to shell!\n");
	exit(v);
}

main(argc,argv)
int	argc;
char	*argv[];
{
	FILE	*fp;
	int	pp;
	char	fname[80];
	
	strcpy(fname,mktemp(MEPTEMP));
	fp = fopen(fname,"a");
	fgets(linebuffer,512,stdin);
	while (!feof(stdin))
	{
		fputs(linebuffer,fp);
		fgets(linebuffer,512,stdin);
	}
	fclose(fp);
	pp = fork();
	if (pp == 0)
	{
		mep(fname);
	}
	exit(0);
}

mep(mailfile)
char	mailfile[];
{
	char	*c, buffer[80];
	FILE	*inf;	/* Spool file	*/
	int	gfd;		/* Generic file descripter	*/
	int loop;
	int id;
	
	id = getuid();
	mep_init(id);
	firstmessage	= TRUE;	/* No messages read yet		*/
	inf = fopen(mailfile,"r");
	while (!feof(inf)) /* As long as we have input	*/
	{
		fgets(linebuffer,512,inf);	/* Get line	*/
		/* Now see if this is a From line		*/
		/* If it is a From line, word = 'From '		*/
		if ((strncmp(linebuffer, "From ", 5) == 0) &&
		    (strlen(linebuffer) > 5))
		{
			/* Now see if this is our first From	*/
			if (!firstmessage)
			{
				/* This is after a previous 	*/
				/* Message, process the old one	*/
				fclose(md);
				process_message();
				strcpy(namem,mktemp(MEPTEMP));
				md = fopen(namem,"w+");
			}
			/* New message, so open needed files,	*/
			/* and start gathering fields etc.	*/
			c = linebuffer;
			c += 5;
			strcpy(fromline,c);
			fromline[strlen(fromline)-1] = 0;
			for (loop = 0; (fromline[loop] != ' ') 
				&& (fromline[loop] != '\0'); loop++) ;
			fromline[loop] = '\0';
			strcpy(namem,mktemp(MEPTEMP));
			md = fopen(namem,"w+");
			firstmessage = FALSE;
		}
		/* Not a from line so check To:/Subject:	*/
		if (strncmp(linebuffer, "To:", 3) == 0)
		{
			c = linebuffer; c += 3;
			strcpy(toline,c);
			toline[strlen(toline)-1] = 0;
		}
		/* Not a To: line so check subject		*/
		if (strncmp(linebuffer, "Subject:", 8) == 0)
		{
			c = linebuffer;
			if (strlen(linebuffer) > 9) 
			{ c += 9; } else {c += 8; }
			strcpy(subline,c);
			subline[strlen(subline)-1] = 0;
		}
		/* Not any of these so just copy to message	*/
		if (!feof(inf))
		{
			fputs(linebuffer,md);
		}
	}
	if (!firstmessage) 
	{
		fclose(md);
		process_message();
	}
	unlink(mailfile);
	exit(0);
}
End of message.c
process.c
echo process.c	1>&2
cat >process.c << 'End of process.c'
# include	<stdio.h>
# include	"typedefs.h"
# include	"globals.h"
# include	"string2.h"

extern	int	check_commands();
extern	FILE	*popen();

/* 
 * Twit(name)
 *
 * Returns TRUE if name is a twit, false otherwise
 *
 */
twit(name,mpath)
char	name[];
char	*mpath;
{
	int	loop = 1;

	while (loop <= num_twits)
	{
		if (strindex(name,twitlist[loop].pattern) != -1)
		{ 
			switch(twitlist[loop].op)
			{
				case 'D' : return(1); 
				case 'T' : return(2);
				case 'S' : {
							strcpy(mpath,twitlist[loop].path);
							return(3);
						}
			}
		}
		loop++;
	}
	return(0);
}

/*
 * Do_Notify.  Notify user if twit sends mail if NOTIFY variable is set
 */
do_notify()
{
	FILE	*od, *md, *fopen();
	char buffer[80];
	
	if (notify == TRUE)
	{
		strcpy(namet,mktemp(MEPTEMP));
		md = fopen(namet,"w+");
		fprintf(md,"\nFor: %s@%s\n\n",username,homedir);
		fprintf(md,"\nSomeone at address:\n");
		fprintf(md,"\t%s\n",fromline);
		fprintf(md,"has tried to send you mail.  ");
		fprintf(md,"TwitMinder has discarded it.\n\n");
		fclose(md);
		sprintf(buffer,"/usr/ucb/Mail -s \"MEP Twit Alert\" %s",username);
		od = popen(buffer,"w");
		md = fopen(namet,"r");
		fgets(buffer,512,md);
		while (!feof(md))
		{
			fputs(buffer,od);
			fgets(buffer,512,md);
		}
		fclose(md);
		pclose(od);
		unlink(namet);
		sprintf(buffer,"%s/%s",homedir,MEPTOTWIT);
		od = fopen(buffer,"r");
		if (od != NULL)
		{
			fclose(od);
sprintf(buffer,"cat %s/%s | /usr/ucb/Mail -s \"Your message\" %s", homedir, MEPTOTWIT, fromline);
			system(buffer);
		}
	}
}

/*
 * Process_message
 *
 * When given a message, performs the following:
 *
 * - Checks to see if person wants logging done
 *   If so, performs the log entry
 * - Checks to see if sender is on twitlist and if
 *   so, will discard mail to bit bucket and if notify
 *   option is set will send mail to that effect
 * - Process @commands
 * 
 */
process_message()
{
	int	i;
	FILE	*of, *fp, *md, *fopen();
	char	ppath[512], buffer[512];
	char	term[9];
	
	switch(twit(fromline,ppath))
	{
		case 2 : {
			do_notify();
			unlink(namem);
			return(0);
		}
		case 1 : {
			unlink(namem);
			return(0);
		}
		case 3 : {
			 /* Special */
			strcpy(term,logged(username));
			if (term != NULL)
			{
				sprintf(buffer,"/dev/%s",term);
				fp = fopen(buffer,"w");
				fprintf(fp,"\007\007Express mail has arrived.\n");
				fclose(fp);
			}
			/* See if forward is required	*/
			i = strlen(ppath);
			if (i != 0)
			{
	sprintf(buffer,"cat %s | /usr/ucb/Mail -s Forward-Mail %s",namem,ppath);
				system(buffer);
			}	
	}
	case 0 : {
			 /* Normal */ 
			if (biffer == TRUE)
			{
				strcpy(term,logged(username));
				if (strlen(term) != 0)
				{
					sprintf(buffer,"/dev/%s",term);
					fp = fopen(buffer,"w");
					fprintf(fp,"\007You have new mail.\n");
					fclose(fp);
				}
			}
		}
		if (log == TRUE)
		{
		/* 
			Ok, so write down in log file when each message
			arrives and the sender.
		*/
			char	buffer2[80];
			FILE *pd;
	
			pd = popen("date","r");
			fgets(buffer2,80,pd);
			pclose(pd);
			md = fopen(logfile,"a");
			sprintf(buffer,"From: %s @ %s",fromline,buffer2);
			fputs(buffer,md);
			fclose(md);
		}
	}
	check_commands();
	fp = fopen(namem,"r");
	sprintf(buffer,"/usr/spool/mail/%s",username);
	of = fopen(buffer,"a");
	fgets(buffer,512,fp);
	while (!feof(fp))
	{
		fputs(buffer,of);
		fgets(buffer,512,fp);
	}
	fclose(fp);
	unlink(namem);
	fputs("\n",of);		/* message break */
	fclose(of);
}
End of process.c
string2.c
echo string2.c	1>&2
cat >string2.c << 'End of string2.c'
/*
      Strings2 - Provides even more string functions for C.
      I don't know why these weren't included in strings(3).

      John Antypas -- ...!sdcsvax!jantypas
      
     strword1(r,s,c,i) -- Returns 1st word in s to r.  c is the character
                          which separates words.
     strindex(s,t) -- returns first occurrence of t in s or -1.
     strreplace(s,p,r) -- replace first pattern p with pattern r.
          This can be used to strinsert and delete functions.
          It returns a pointer to the new string s.

     All parameters are character pointers.

*/

#define		NULL	0

#if USG
#include	<string.h>	/* Need strcat, strcpy	*/
#else
#include	<strings.h>
#endif

int	strindex(s,t)
char *s, *t;
{
	int loop, n;		/* Loop counter		*/

	n = strlen(t);
	for (loop=0; s[loop] != '\0'; loop++)
	{
        if ((strncmp(s+loop, t, n) == 0) && (n != 0)) { return(loop); }
	}
	return (-1);
}

char	*strreplace(s,p,r)
char	*s, *p, *r;
{
	int	f, n;
	char	*m;		/* Used for temporary	*/

	m = (char *)malloc( strlen(s) + strlen(r) - strlen(p) );
	/* Get enough memory for the new string		*/
	/* If it doesn't work, die here			*/
	if (m == NULL) return(m);

	f = strindex(s,p);
	strncpy(m,s,f);	/* Copy up to p.	*/
	strcat(m,r);		/* Add in r.		*/
	
        /* Now add the part after the replacement	*/
	strcat(m,s+f+strlen(p));
	/* Copy it back to s				*/
	strcpy(s,m);
	free(m);
	return(s);
}

int	strword(r,s,c,i)
char	*s, *r, c;
int	i;
/*
	Function: Returns number of words/specific word in string s.
                  Returns in string r the word requested.  If i<0;
                  returns # words in s, else reurns ith word in r.
		  c is the character used to mark separate words.
		  Usually is a space (32).
*/
{
	int l;

	l = strlen(s);
	if (i<0)		/* Count words		*/
	{
		int nw,j;	/* # words and loop var	*/

		for (j=0,nw=0; j<l; j++)
		{
			if (*(s+j) == c) nw++;
		}
		if (nw != 0) nw++;
		return(nw);
	}
	else
	{
		char *sp,t[2];
		int nw,m;		/* Loops and length(s)	*/

		t[0] = c;  t[1] = 0;
		/* Find begining of ith word		*/
		nw = 0; sp = s;
		while ((nw<i) && (*sp != NULL))
		{
			if ((*sp) == c) nw++;
			sp++;
		}
		/* Now find end of that word		*/
		m = strindex(sp,t);
		if (m>0) { strncpy(r,sp,m); } else { strcpy(r,sp); }
		return(0);
	}
}
End of string2.c
globals.var
echo globals.var	1>&2
cat >globals.var << 'End of globals.var'
# define	TRUE	1
# define	FALSE	0
# define MEPTEMP	"/tmp/mep-XXXXXX"	/* temp files */

int	biffer, notify, log = FALSE;
int	firstmessage;		/* First message read = 1 else 0	*/

char	fromline[512];	/* From line from message		*/
char namem[80], names[80], namet[80];
char	toline[512],		/* To: line from message		*/
	subline[512],		/* Message subject			*/
	linebuffer[512],	/* Big buffer for messages	*/
	logfile[80];

char username[20], homedir[80];

typedef struct persons
{
	char	pattern[512];
	char	op;
	char	path[512];
};

FILE	*md;			/* Message file, item file		*/
FILE	*fopen();

int num_cmds;
int	num_twits;	/* # of twits in twitlist		*/
STRING	comlist[100];
struct persons twitlist[100];
End of globals.var
globals.h
echo globals.h	1>&2
cat >globals.h << 'End of globals.h'
# define	TRUE	1
# define	FALSE	0

#if USG
# define	MEMCPY(a,b,c)	memcpy(a,b,c)
#else
# define	MEMCPY(a,b,c)	bcopy(b,a,c)
#endif
 
# define MEPTEMP	"/tmp/mep-XXXXXX"	/* temp files */

# define MEPCONFIG	".meprc"	/* notify/stat setting*/
# define MEPTWIT	".meptwits"	/* twitlist file */
# define MEPCOMMAND	".mepcmds"	/* valid commands */
# define MEPTOTWIT	".meptwitmsg"	/* sent to twits */
# define MEPFAIL	".mepfailmsg"	/* sent on command fail */
# define MEPVERSION	"1.02B"

typedef	struct	persons
{
	char	pattern[512];
	char	op;
	char	path[512];
};

extern	int	biffer, notify, log;
extern	int	firstmessage;	/* First message read = 1 else 0	*/

extern	char	fromline[512],/* From line from message	*/
		toline[512],		/* To: line from message		*/
		subline[512],		/* Message subject			*/
		linebuffer[512],	/* Big buffer for messages	*/
		logfile[80];

extern	char	namem[80], names[80], namet[80];
extern	char	username[20], homedir[80];

extern	int	num_cmds;
extern	int	num_twits;
extern	struct  persons twitlist[100];	/* Twit list	*/
extern	STRING	comlist[100];
extern	error();			/* Error messages			*/
extern	char *logged();
End of globals.h
process.h
echo process.h	1>&2
cat >process.h << 'End of process.h'
/*
 * Process.c header file process.h
 * John Antypas
 * Used in message.c to handle each individual mail message
 * All messages are passed through process_message here.
 * It can call features such as twit_list(name) which will 
 * return TRUE if that person is on the twitlist and
 * command(line) which will handle the @ commands
 */

extern	void	proces_message();	/* Handles message	*/

End of process.h
string2.h
echo string2.h	1>&2
cat >string2.h << 'End of string2.h'
/*
      String2 -- String2 header file

      Make sure to link with string2.o

      strindex(s,t) -- Return index to pattern t in string s or -1
      strreplace(s,p,r) -- Replace pattern p by pattern r in string s.
                           Return char pointer to s or NULL if error.
      strword(r,s,c,i) -- Returns:
            If (i<0) ; the number of words in string s is returned sa result.
               (i>0) ; the ith word is returned in r from string s.
*/
extern	int	strword();
extern	int	strindex();
extern	char	*strreplace();
#define	strdelete(s,p,q)	strreplace(s,p,q,"");
End of string2.h
typedefs.h
echo typedefs.h	1>&2
cat >typedefs.h << 'End of typedefs.h'
/* 
 * System data types
 */

typedef	char	STRING[255];
End of typedefs.h
.mepcmds
echo .mepcmds	1>&2
cat >.mepcmds << 'End of .mepcmds'
mepmail
End of .mepcmds
.meprc
echo .meprc	1>&2
cat >.meprc << 'End of .meprc'
notify=yes
stat=.logfile
biff=yes
End of .meprc
.meptotwits
echo .meptotwits	1>&2
cat >.meptotwits << 'End of .meptotwits'

Dear User

We thank you for your mail but it is unnecessary at this time.
We will keep it on file for 60 days and let you know if something
opens up.

					Sincerely
						The Management

				HAVE A HAPPY DAY
End of .meptotwits
.meptwits
echo .meptwits	1>&2
cat >.meptwits << 'End of .meptwits'
thoma/S/ucrmath!ucdavis!harpo:u566654244ea
victor/T/
End of .meptwits
.forward
echo .forward	1>&2
cat >.forward << 'End of .forward'
"|/class/maj/jantypas/src/mailer/mep"
End of .forward
Makefile
echo Makefile	1>&2
cat >Makefile << 'End of Makefile'
# Makefile for Mail Extensions Package
# John Antypas
# Redone (a bit) -- Tim Northrup -- 11/3/86
OFILES	= message.o process.o commands.o mepinit.o string2.o
CC	= cc
CFLAGS	= -O 
#CFLAGS = -g
LFLAGS	= -n


mep:	$(OFILES)
	$(CC) $(LFLAGS) $(OFILES) -o mep

commands.o: commands.c $(H)typedefs.h $(H)globals.h $(H)string2.h
mepinit.o: mepinit.c $(H)string2.h $(H)typedefs.h $(H)globals.h
message.o: message.c $(H)string2.h $(H)typedefs.h $(H)globals.var \
	$(H)process.h 
process.o: process.c $(H)typedefs.h $(H)globals.h $(H)string2.h
string2.o: string2.c $(H)string2.h
End of Makefile
README
echo README	1>&2
cat >README << 'End of README'
.nf
.sp 2
.ce
Instructions for Installing MEP:
.sp 2
.NH 
Run the makefile.
.NH 
Put the following line in your .forward home in your home directory 
.sp 1
.LP
.nf
.nj
"|/fullpathnameforyou/youruserid/mep"
.sp 1
.NH 
Place mep in /pathname/youruserid/
.fi
.PP
Example:  Let us say your account is frob and the full path from root
(easily obtained by saying ~<return>) is /usr/acct/frob.
Compile the code above and place mep in /usr/acct/frob
.sp 1
.nf
	cd ~
	ls
	....files
	mep
.nf
.NH
Fix the .forward file
.sp 1
.LP
.nf
vi .forward
a
"|/usr/acct/frob/mep"
<esc>
:wq
.NH
Test
.fi
.PP
This is not the complete version of MEP.  It only support three of the
four functions in plan. twitlist, logging and @RR.
.nf
.NH 
Twitlist:
.PP
There are people you want mail from and people you DON'T want mail
from.  TwitMinder will handle that.  All twits will be discarded.
Merely place a file called .meptwits containing the userids (one/line)
in the file.  If the file is absent or empty, MEP will assume you
don't have any twits to worry about.  The format of the file is as
follows. pattern/op/[path]<return>  The pattern is the pattern to scan
for if the person is a twit, the op is a code of the type T,D, or S.
T = a twit.  Discard the mail, warn the user of the twit, exit. D =
Discard.  Discard this mail -- no questions asked.  S = Special.  This
mail is important.  If a path exists, forward mail on that path, biff
the user even if biff is off. ("Express mail has arrived")
.nf
.sp 1
bob/S/path!user
ralph/T/
MAILER-DAEMON/D/
root/S/
.sp 1
.fi
then if any of these people send you mail, that mail will be
discarded.  If you want to still be told that they tried, but don't
want to actually READ their mail, set the notify option in .meprc.
You can put a file .totwits in your home directory which will be sent
to twits whenever they send you mail.  This should be something nice,
but something which will make the point.  Mine is:
.br
.sp 1
Dear User
.br
.PP
We thank you for your mail but it is unnecessary at this time.
We will keep it on file for 60 days and let you know if something
opens up.

					Sincerely
.sp 1
					The Management
.sp 1
				HAVE A HAPPY DAY
.br
.sp 1
.fi
If this file is absent, no message will be sent.  NOTE:  You are
only allowed to have 100 twits.  If you have more,
contact me for a bigger version or so I can modify the code to
discard everyone BUT the people in the twitlist.
.nf
.sp 1
.NH
Configuration:
.sp 1
.LP
.nf 
A file .meprc contains commands used on startup.  They are:
.sp 1
stat=<file>/none
biff=<yes>/<no>
notify=<yes>/<no>
.sp 1
.fi
The first command specifies where you want the mail log to go.  
biff specifies whether you want the Unix BSD "biff" feaature active.
notify specifies whether you want to be notified if a twit  sends you
mail.  If this file is absent, the options are set as stat=none,
biff=no, notify=no.  Thus, a maillog will not be kept, you will NOT be
notified about TWITS or incoming mail.
.nf
.NH
Logging:
.PP
.fi
When this is set, all mail coming in will have a timestamp put into a
file at /pathname/filename.  (Usually just filename will do as it will
go into your home directory.)  Entries are:
.sp 1
.nf
>From <path!user> @ Date/Time
>From <path!user> @ Date/Time
...
.sp 1
The correct sytax is:

stat=<filename> where <filename> is path/name of logfile
stat=none	(Do NOT log mail)
.sp 1
.NH
 @RR:  This should be in column one.
.fi
.PP
This is a neat little feature which allows you ask someone who is
running this mailer (or for them to ask you) to mail you notification
that they received your mail.
Just include @RR at the begginning of a line by itself somewhere in
your mail to them.
.sp 1
.nf
Mail frob
Subject: Test
This is a  test
This is a new test
 @RR This should be in column one
This is a test
.
.sp 1
.fi
This will send them the mail above, but will also (because of @RR)
send you a notice that they received it. 
.nf
.NH 
 @SH line
.PP
This allows certain programs to be run by the mailer.  In your home
directory, there is a file .mepcmds.   In this file are the names
of programs which can be run. (One/line).
Example:
.nf
.sp 1
mep<return>
mydate<return>
etc.
.sp 1
.fi
You just can't issue shell commands, because something has to mail
the results back to you.  Notice the copy of mepmail as an example.
The line is the command line you are sending.  Remember, the program
will start the search in your $HOME directory.  If this file is empty
or missing, the system will not allow ANY commands via MEP.
.sp 2
.nf
John Antypas

UUCP: ...!{ucbvax!ucdavis, sdcsvax}!ucrmath!hope!jantypas
ARPA: ucrmath!hope!jantypas at sdcsvax.ucsd.edu
BITNET: ucdavis!ucrmath!hope!jantypas at Berkeley
CSNET: ucbvax!ucdavis!ucrmath!hope!jantypas at Tektronix.CSNET
End of README



More information about the Comp.sources.unix mailing list