NMail -- Novice Mail 1.0, patch 1

Scott Reynolds scott at clmqt.marquette.Mi.US
Wed Apr 11 09:16:04 AEST 1990


Patches are inevitable, aren't they...  <sigh>

Well, as Russ Nelson pointed out, tolower() doesn't work the same under
BSD and SysV.  I've included a somewhat modified version of his patch
here with the rest of them (Thanks, Russ!).  If you already applied that
patch, you'll need to remove it first.

Other changes include:

	- fixed a bug that would kill outgoing mail in some situations
		where the QUIT key was used to exit
	- made config.h a little bit smarter for BSD
	- better handling of files that aren't the user's mailbox

In case anyone was wondering about what could be done with the program
once it was on the machine, I've included a slightly more detailed
copyright notice.

*** ../old/Copyright Tue Apr 10 17:25:36 1990
--- Copyright Tue Apr 10 17:25:36 1990
**************
*** 0 ***
--- 1,13 -----
+ NMail -- Novice Mail v1.0
+ Copyright 1990 Scott Reynolds.  All rights reserved.
+ 
+ You are permitted to make copies and freely distribute this software 
+ as long as you keep all parts together (including this copyright 
+ notice) and you aren't making a profit from copying or distributing 
+ it.  Any form of packaging may be used (ARC, ZOO, ZIP, shar, etc.) 
+ provided that all source code and documentation are not altered in any 
+ way from the originals when unpackaged.
+ 
+ This software is provided "as is," without warranty of any kind, 
+ either express or implied, including, but not limited to, the implied 
+ warranties of merchantability and fitness for a particular purpose. 

*** ../old/addr.c Sat Mar 31 01:18:25 1990
--- addr.c Sat Mar 31 01:18:25 1990
**************
*** 7,13
   *	addr.c -- Check for valid/partial addresses
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)addr.c:1.7";
  
  #include "config.h"
  #include <stdio.h>
--- 7,13 -----
   *	addr.c -- Check for valid/partial addresses
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)addr.c:1.8";
  
  #include "config.h"
  #include <stdio.h>
**************
*** 159,165
  
  	strcpy(addr, s);
  	for (p = addr; *p != '\0'; ++p)
! 		*p = tolower(*p);
  	(void) setpwent();
  	found = 0;
  	while (!found && (char *)(pwd = getpwent()) != NULL) {
--- 159,166 -----
  
  	strcpy(addr, s);
  	for (p = addr; *p != '\0'; ++p)
! 		if (isupper(*p))
! 			*p = tolower(*p);
  	(void) setpwent();
  	found = 0;
  	while (!found && (char *)(pwd = getpwent()) != NULL) {
**************
*** 175,181
  		}
  		strcpy(prompt, pwd->pw_gecos);
  		for (p = prompt; *p != '\0'; ++p)
! 			*p = tolower(*p);
  		if (strpos(prompt, addr) != NULL) {
  			sprintf(prompt, "Mail to %s (%s)?", pwd->pw_name, pwd->pw_gecos);
  			if (found = response(prompt, NO, YES))
--- 176,183 -----
  		}
  		strcpy(prompt, pwd->pw_gecos);
  		for (p = prompt; *p != '\0'; ++p)
! 			if (isupper(*p))
! 				*p = tolower(*p);
  		if (strpos(prompt, addr) != NULL) {
  			sprintf(prompt, "Mail to %s (%s)?", pwd->pw_name, pwd->pw_gecos);
  			if (found = response(prompt, NO, YES))

*** ../old/config.h Sat Mar 31 01:18:28 1990
--- config.h Sat Mar 31 01:18:28 1990
**************
*** 4,10
   *	Copyright 1990 Scott Reynolds
   *	All rights reserved.
   *
!  *	@(#) config.h 1.13
   *
   *	config.h -- system configuration
   **********************************************************************/
--- 4,10 -----
   *	Copyright 1990 Scott Reynolds
   *	All rights reserved.
   *
!  *	@(#) config.h 1.14
   *
   *	config.h -- system configuration
   **********************************************************************/
**************
*** 20,26
  /* #define	BITFIELDS	/* compiler supports bit fields		*/
  
  #define	SPOOLDIR	"/usr/spool/mail"	/* mail spool directory	*/
- #define	MAILER		"/bin/rmail %s"		/* delivery agent	*/
  #define	TMPFILE 	"/tmp/nmailXXXXXX"	/* template for mailer	*/
  #define	SIGFILE 	".signature"		/* signature file	*/
  #define	EDITOR		"/bin/vi"		/* default text editor	*/
--- 20,25 -----
  /* #define	BITFIELDS	/* compiler supports bit fields		*/
  
  #define	SPOOLDIR	"/usr/spool/mail"	/* mail spool directory	*/
  #define	TMPFILE 	"/tmp/nmailXXXXXX"	/* template for mailer	*/
  #define	SIGFILE 	".signature"		/* signature file	*/
  #define	EDITOR		"/bin/vi"		/* default text editor	*/
**************
*** 24,29
  #define	TMPFILE 	"/tmp/nmailXXXXXX"	/* template for mailer	*/
  #define	SIGFILE 	".signature"		/* signature file	*/
  #define	EDITOR		"/bin/vi"		/* default text editor	*/
  
  #define	DOMAINMAILER		/* mailer recognizes domain names	*/
  
--- 23,33 -----
  #define	TMPFILE 	"/tmp/nmailXXXXXX"	/* template for mailer	*/
  #define	SIGFILE 	".signature"		/* signature file	*/
  #define	EDITOR		"/bin/vi"		/* default text editor	*/
+ #ifdef	M_XENIX
+ #define	MAILER		"/usr/bin/rmail %s"	/* XENIX delivery agent	*/
+ #else
+ #define	MAILER		"/bin/rmail %s"		/* delivery agent	*/
+ #endif
  
  #define	DOMAINMAILER		/* mailer recognizes domain names	*/
  
**************
*** 40,45
   * and to check for local addresses in restricted mode.
   ***/
  /* #define	MYNAME	"foo"	/* override node name from system calls	*/
  #define	UNAME			/* use uname() to get node name		*/
  /* #define	GETHOSTNAME	/* use gethostname() to get node name	*/
  
--- 44,50 -----
   * and to check for local addresses in restricted mode.
   ***/
  /* #define	MYNAME	"foo"	/* override node name from system calls	*/
+ #ifdef	USG
  #define	UNAME			/* use uname() to get node name		*/
  #else /* !USG */
  #define	GETHOSTNAME		/* use gethostname() to get node name	*/
**************
*** 41,47
   ***/
  /* #define	MYNAME	"foo"	/* override node name from system calls	*/
  #define	UNAME			/* use uname() to get node name		*/
! /* #define	GETHOSTNAME	/* use gethostname() to get node name	*/
  
  /***
   * Define MYDOMAIN to be your site's domain.  The system will construct
--- 46,54 -----
  /* #define	MYNAME	"foo"	/* override node name from system calls	*/
  #ifdef	USG
  #define	UNAME			/* use uname() to get node name		*/
! #else /* !USG */
! #define	GETHOSTNAME		/* use gethostname() to get node name	*/
! #endif /* USG */
  
  /***
   * Define MYDOMAIN to be your site's domain.  The system will construct
**************
*** 49,61
   * DOMAINMAILER defined.
   ***/
  #define	MYDOMAIN	".UUCP"	/* set this to your site's domain	*/
- 
- /***
-  * fix the following to reflect your machine
-  ***/
- typedef	unsigned char	byte;	/* 8-bit unsigned integer	*/
- typedef	short int	int16;	/* 16-bit signed integer	*/
- typedef	long		int32;	/* 32-bit signed integer	*/
  
  /***
   * LOW_UID is the lowest user ID that will be considered a partial
--- 56,61 -----
   * DOMAINMAILER defined.
   ***/
  #define	MYDOMAIN	".UUCP"	/* set this to your site's domain	*/
  
  /***
   * LOW_UID is the lowest user ID that will be considered a partial

*** ../old/nmail.1 Sat Mar 31 01:18:34 1990
--- nmail.1 Sat Mar 31 01:18:34 1990
**************
*** 1,4
! .\"@(#)nmail.1:1.9
  .TH NMAIL 1
  .SH NAME
  nmail \- a mail reader for novices (and the rest of us, too)
--- 1,4 -----
! .\"@(#)nmail.1:1.11
  .TH NMAIL 1
  .SH NAME
  nmail \- a mail reader for novices (and the rest of us, too)
**************
*** 13,18
  [
  \-f\^\fIfile\fP
  ]
  .PP
  .B nmail
  [
--- 13,21 -----
  [
  \-f\^\fIfile\fP
  ]
+ [
+ \fI+file\fp
+ ]
  .PP
  .B nmail
  [
**************
*** 105,110
  and
  .B Subject:
  lines in order to send mail.
  .SH READING MESSAGES
  The default action of \fInmail\fP when reading is to display one full
  page of the message,
--- 108,116 -----
  and
  .B Subject:
  lines in order to send mail.
+ .PP
+ Specifying a file on the command line in the form \fI+file\fP
+ is identical to using the \fI\-f\fP option.
  .SH READING MESSAGES
  The default action of \fInmail\fP when reading is to display one full
  page of the message,

*** ../old/nmail.c Sat Mar 31 01:18:54 1990
--- nmail.c Sat Mar 31 01:18:54 1990
**************
*** 7,13
   *	nmail.c -- Main program and mailbox handling
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)nmail.c:1.35";
  
  #include "config.h"
  #include <stdio.h>
--- 7,13 -----
   *	nmail.c -- Main program and mailbox handling
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)nmail.c:1.38";
  
  #include "config.h"
  #include <stdio.h>
**************
*** 44,49
  int	restricted = 0;		/* restricted; local address, no shell	*/
  int	paging = 1;		/* enable paging in text display	*/
  int	partial = 0;		/* check partial addresses locally	*/
  jmp_buf	jmp_intr;		/* jump information for SIGINT		*/
  
  static char	*helpscr[] = {
--- 44,50 -----
  int	restricted = 0;		/* restricted; local address, no shell	*/
  int	paging = 1;		/* enable paging in text display	*/
  int	partial = 0;		/* check partial addresses locally	*/
+ int	folder = 0;		/* reading a folder, not a mailbox	*/
  jmp_buf	jmp_intr;		/* jump information for SIGINT		*/
  
  static char	*helpscr[] = {
**************
*** 136,141
  			break;
  		case 'f':
  			mbox = strdup(optarg);
  			break;
  		case 'h':
  			headermode = 1;
--- 137,143 -----
  			break;
  		case 'f':
  			mbox = strdup(optarg);
+ 			folder = 1;
  			break;
  		case 'h':
  			headermode = 1;
**************
*** 168,174
  			expert = 1;
  			break;
  		default:
! 			fprintf(stderr, "usage: %s [-achHnx] [-pN] [-s subject] [-f file] [user...]\n", argv[0]);
  			ttyexit();
  			cleanup(1);
  		}
--- 170,176 -----
  			expert = 1;
  			break;
  		default:
! 			fprintf(stderr, "usage:\t%s [-achHLnrRtx] [-pN] [-f file] [+file] [-s subject] [user...]\n", argv[0]);
  			ttyexit();
  			cleanup(1);
  		}
**************
*** 174,179
  		}
  	}
  
  	if (send || optind < argc) {
  		if (restricted > 1) {
  			fputs("Permission to originate mail denied.\n", stderr);
--- 176,187 -----
  		}
  	}
  
+ 	if (!send && optind < argc && *argv[optind] == '+') {
+ 		mbox = argv[optind] + 1;
+ 		++optind;
+ 		folder = 1;
+ 	}
+ 
  	if (send || optind < argc) {
  		if (restricted > 1) {
  			fputs("Permission to originate mail denied.\n", stderr);
**************
*** 218,224
  		}
  	}
  	if ((char *)(dfp = fopen(mbox, "r")) == NULL) {
! 		puts("No mail.");
  		ttyexit();
  		cleanup(10);
  	}
--- 226,237 -----
  		}
  	}
  	if ((char *)(dfp = fopen(mbox, "r")) == NULL) {
! 		if (!folder)
! 			puts("No mail.");
! 		else if (errno == ENOENT || errno == ENOTDIR)
! 			printf("File '%s' doesn't exist\n", mbox);
! 		else
! 			printf("File '%s' is unreadable\n", mbox);
  		ttyexit();
  		cleanup(10);
  	}
**************
*** 223,229
  		cleanup(10);
  	}
  
! 	mtime = modtime(dfp);
  	findhdr(dfp);
  
  	for (mcount = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp)
--- 236,247 -----
  		cleanup(10);
  	}
  
! 	if (folder) {
! 		printf("Reading '%s'...", mbox);
! 		fflush(stdout);
! 	} else {
! 		mtime = modtime(dfp);
! 	}
  	findhdr(dfp);
  	if (folder)
  		putchar('\n');
**************
*** 225,230
  
  	mtime = modtime(dfp);
  	findhdr(dfp);
  
  	for (mcount = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp)
  		if (!new || !hdrp->o_read)
--- 243,250 -----
  		mtime = modtime(dfp);
  	}
  	findhdr(dfp);
+ 	if (folder)
+ 		putchar('\n');
  
  	for (mcount = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp)
  		if (!new || !hdrp->o_read)
**************
*** 244,250
  		cleanup(11);
  	}
  
! 	if (!new) {
  		printf("Your mailbox contains %u message%s.\n", mcount, (mcount > 1) ? "s" : "");
  		sprintf(input, "Do you wish to read %s now?", (mcount > 1) ? "them" : "it");
  		if (!response(input, YES, YES)) {
--- 264,270 -----
  		cleanup(11);
  	}
  
! 	if (!(new || folder)) {
  		printf("Your mailbox contains %u message%s.\n", mcount, (mcount > 1) ? "s" : "");
  		sprintf(input, "Do you wish to read %s now?", (mcount > 1) ? "them" : "it");
  		if (!response(input, YES, YES)) {
**************
*** 320,326
  			if (!(headermode || hdrp->deleted)) {
  				putchar('\n');
  				++curline;
! 				if (displaytext(dfp, hdrp, &info))
  					hdrp->read = 1;
  			}
  		}
--- 340,346 -----
  			if (!(headermode || hdrp->deleted)) {
  				putchar('\n');
  				++curline;
! 				if (displaytext(dfp, hdrp, &info) && !folder)
  					hdrp->read = 1;
  			}
  		}
**************
*** 349,355
  			do {
  				invalid = 0;
  				c = getchar();
! 				switch (tolower(c)) {
  				case '\f':
  					done = 1;
  					break;
--- 369,375 -----
  			do {
  				invalid = 0;
  				c = getchar();
! 				switch (isupper(c) ? tolower(c) : c) {
  				case '\f':
  					done = 1;
  					break;
**************
*** 492,500
  					brkenable(msg_intr);
  					if (setjmp(jmp_intr))
  						putchar('\n');
! 					else
! 						if (displaytext(dfp, hdrp, &info))
! 							hdrp->read = 1;
  					brkdisable();
  					break;
  				case 'x':
--- 512,519 -----
  					brkenable(msg_intr);
  					if (setjmp(jmp_intr))
  						putchar('\n');
! 					else if (displaytext(dfp, hdrp, &info) && !folder)
! 						hdrp->read = 1;
  					brkdisable();
  					break;
  				case 'x':
**************
*** 549,554
  	}
  	(void) fclose(dfp);
  	
  	for (mcount = 0, update = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp) {
  		if (!hdrp->deleted)
  			++mcount;
--- 568,576 -----
  	}
  	(void) fclose(dfp);
  	
+ 	if (sendcount)
+ 		printf("You sent %d message%s.\n", sendcount, (sendcount == 1) ? "" : "s");
+ 
  	for (mcount = 0, update = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp) {
  		if (!hdrp->deleted)
  			++mcount;
**************
*** 558,569
  	if (update || mcount < count)
  		if ((mcount = savemail(mbox)) == (-1))
  			mcount = count;
! 	if (mcount)
! 		printf("%d message%s saved in mailbox.\n", mcount, (mcount == 1) ? "" : "s");
! 	else
! 		puts("Your mailbox is empty.");
! 	if (sendcount)
! 		printf("You sent %d message%s.\n", sendcount, (sendcount == 1) ? "" : "s");
  	ttyexit();
  	cleanup(0);
  /*NOTREACHED*/
--- 580,600 -----
  	if (update || mcount < count)
  		if ((mcount = savemail(mbox)) == (-1))
  			mcount = count;
! 	if (folder) {
! 		if (mcount) {
! 			printf("%d message%s saved in '%s'\n",
! 				mcount, (mcount == 1) ? "" : "s", mbox);
! 		} else {
! 			(void) unlink(mbox);
! 			printf("Empty file '%s' deleted.\n", mbox);
! 		}
! 	} else {
! 		if (mcount)
! 			printf("%d message%s saved in mailbox.\n",
! 				mcount, (mcount == 1) ? "" : "s");
! 		else
! 			puts("Your mailbox is empty.");
! 	}
  	ttyexit();
  	cleanup(0);
  /*NOTREACHED*/

*** ../old/opt.c Sat Mar 31 01:18:56 1990
--- opt.c Sat Mar 31 01:18:56 1990
**************
*** 7,13
   *	opt.c - Functions to manage default options
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)opt.c:1.6";
  
  #include "config.h"
  #include <stdio.h>
--- 7,13 -----
   *	opt.c - Functions to manage default options
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)opt.c:1.7";
  
  #include "config.h"
  #include <stdio.h>
**************
*** 44,50
  		do {
  			invalid = 0;
  			c = getchar();
! 			switch (tolower(c)) {
  			case 'q':
  			case '\b':
  			case '\033':
--- 44,50 -----
  		do {
  			invalid = 0;
  			c = getchar();
! 			switch (isupper(c) ? tolower(c) : c) {
  			case 'q':
  			case '\b':
  			case '\033':

*** ../old/patchlevel.h Sat Mar 31 01:18:58 1990
--- patchlevel.h Sat Mar 31 01:18:58 1990
**************
*** 7,10
   *	patchlevel.h -- current release patch level
   **********************************************************************/
  
! #define	PATCHLEVEL	0
--- 7,10 -----
   *	patchlevel.h -- current release patch level
   **********************************************************************/
  
! #define	PATCHLEVEL	1

*** ../old/proc.c Sat Mar 31 01:19:06 1990
--- proc.c Sat Mar 31 01:19:06 1990
**************
*** 7,13
   *	proc.c -- process individual messages
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)proc.c:1.2";
  
  #include "config.h"
  #include <stdio.h>
--- 7,13 -----
   *	proc.c -- process individual messages
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)proc.c:1.4";
  
  #include "config.h"
  #include <stdio.h>
**************
*** 12,17
  #include "config.h"
  #include <stdio.h>
  #include <string.h>
  #include <ctype.h>
  #include <errno.h>
  #include <sys/types.h>
--- 12,18 -----
  #include "config.h"
  #include <stdio.h>
  #include <string.h>
+ #include <signal.h>
  #include <ctype.h>
  #include <errno.h>
  #include <sys/types.h>
**************
*** 244,251
  			done = save = send = pipe = restart = forward = 0;
  			do {
  				c = getchar();
! 				c = tolower(c);
! 				switch (c) {
  				case '^':
  					thispage = start;
  				case '\f':
--- 245,251 -----
  			done = save = send = pipe = restart = forward = 0;
  			do {
  				c = getchar();
! 				switch (isupper(c) ? tolower(c) : c) {
  				case '^':
  					thispage = start;
  				case '\f':
**************
*** 348,353
  
  void runshell()
  {
  	cmd[0] = '\0';
  	(void) ttgets("! ", cmd, LEN);
  	if (pid > 0)
--- 348,356 -----
  
  void runshell()
  {
+ 	int	(*qstat)();
+ 	int	(*istat)();
+ 
  	cmd[0] = '\0';
  	(void) ttgets("!", cmd, LEN);
  	if (pid > 0)
**************
*** 349,355
  void runshell()
  {
  	cmd[0] = '\0';
! 	(void) ttgets("! ", cmd, LEN);
  	if (pid > 0)
  		(void) wait((int *)0);
  	ttyexit();
--- 352,358 -----
  	int	(*istat)();
  
  	cmd[0] = '\0';
! 	(void) ttgets("!", cmd, LEN);
  	if (pid > 0)
  		(void) wait((int *)0);
  	qstat = signal(SIGQUIT, SIG_IGN);
**************
*** 352,358
  	(void) ttgets("! ", cmd, LEN);
  	if (pid > 0)
  		(void) wait((int *)0);
! 	ttyexit();
  	if ((pid = fork()) == 0) {
  		if (cmd[0] == '\0')
  			(void) execlp("/bin/sh", "sh", NULL);
--- 355,363 -----
  	(void) ttgets("!", cmd, LEN);
  	if (pid > 0)
  		(void) wait((int *)0);
! 	qstat = signal(SIGQUIT, SIG_IGN);
! 	istat = signal(SIGINT, SIG_IGN);
! 	ttysane();
  	if ((pid = fork()) == 0) {
  		(void) signal(SIGINT, SIG_DFL);
  		(void) signal(SIGQUIT, SIG_DFL);
**************
*** 354,359
  		(void) wait((int *)0);
  	ttyexit();
  	if ((pid = fork()) == 0) {
  		if (cmd[0] == '\0')
  			(void) execlp("/bin/sh", "sh", NULL);
  		else
--- 359,367 -----
  	istat = signal(SIGINT, SIG_IGN);
  	ttysane();
  	if ((pid = fork()) == 0) {
+ 		(void) signal(SIGINT, SIG_DFL);
+ 		(void) signal(SIGQUIT, SIG_DFL);
+ 		(void) signal(SIGHUP, SIG_DFL);
  		if (cmd[0] == '\0')
  			(void) execlp("/bin/sh", "sh", NULL);
  		else
**************
*** 376,381
  		fflush(stdout);
  		(void) getchar();
  	}
  }
  
  void pipecmd(fp, hdrp)
--- 384,391 -----
  		fflush(stdout);
  		(void) getchar();
  	}
+ 	(void) signal(SIGINT, istat);
+ 	(void) signal(SIGQUIT, qstat);
  }
  
  void pipecmd(fp, hdrp)
**************
*** 471,476
  	if (pid > 0)
  		(void) wait((int *)0);
  	if ((pid = fork()) == 0) {
  		sprintf(cmd, MAILER, address);
  		if ((char *)(pfp = popen(cmd, "w")) == NULL) {
  			perror("popen(MAILER)");
--- 481,488 -----
  	if (pid > 0)
  		(void) wait((int *)0);
  	if ((pid = fork()) == 0) {
+ 		(void) signal(SIGINT, SIG_IGN);
+ 		(void) signal(SIGQUIT, SIG_IGN);
  		sprintf(cmd, MAILER, address);
  		if ((char *)(pfp = popen(cmd, "w")) == NULL) {
  			perror("popen(MAILER)");
**************
*** 671,676
  		if (pid > 0)
  			(void) wait((int *)0);
  		if ((pid = fork()) == 0) {
  			sprintf(cmd, MAILER, address);
  			if ((char *)(pfp = popen(cmd, "w")) == NULL) {
  				perror("popen(MAILER)");
--- 683,690 -----
  		if (pid > 0)
  			(void) wait((int *)0);
  		if ((pid = fork()) == 0) {
+ 			(void) signal(SIGINT, SIG_IGN);
+ 			(void) signal(SIGQUIT, SIG_IGN);
  			sprintf(cmd, MAILER, address);
  			if ((char *)(pfp = popen(cmd, "w")) == NULL) {
  				perror("popen(MAILER)");
**************
*** 676,682
  				perror("popen(MAILER)");
  				retval = 28;
  			} else {
- 				fprintf(pfp, "To: %s\n", address);
  				fprintf(pfp, "From: %s", myaddr());
  				if ((s = username()) != NULL && *s != '\0')
  					(void) fprintf(pfp, " (%s)", s);
--- 690,695 -----
  				perror("popen(MAILER)");
  				retval = 28;
  			} else {
  				fprintf(pfp, "From: %s", myaddr());
  				if ((s = username()) != NULL && *s != '\0')
  					(void) fprintf(pfp, " (%s)", s);

*** ../old/tty.c Sat Mar 31 01:19:11 1990
--- tty.c Sat Mar 31 01:19:11 1990
**************
*** 7,13
   *	tty.c - Basic tty input/output
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)tty.c:1.9";
  
  #include "config.h"
  #include <stdio.h>
--- 7,13 -----
   *	tty.c - Basic tty input/output
   **********************************************************************/
  
! static char	SCCSID[] = "@(#)tty.c:1.11";
  
  #include "config.h"
  #include <stdio.h>
**************
*** 33,38
  static char	*send_str = NULL;
  static char	*sout_str = NULL;
  static struct termio	trm;
  static struct termio	oldtrm;
  
  #define	EVER	(;;)
--- 33,39 -----
  static char	*send_str = NULL;
  static char	*sout_str = NULL;
  static struct termio	trm;
+ static struct termio	strm;
  static struct termio	oldtrm;
  
  #define	EVER	(;;)
**************
*** 204,210
  		fputs(" (y/[N]) ", stdout);
  	do {
  		c = getchar();
! 		c = tolower(c);
  		if (c == '\n')
  			c = (defval == YES) ? 'y' : 'n';
  		if (c != 'y' && c != 'n')
--- 205,212 -----
  		fputs(" (y/[N]) ", stdout);
  	do {
  		c = getchar();
! 		if (isupper(c))
! 			c = tolower(c);
  		if (c == '\n')
  			c = (defval == YES) ? 'y' : 'n';
  		if (c != 'y' && c != 'n')
**************
*** 234,240
  			lcase = 0;
  	for EVER {
  		c = getchar();
! 		if (lcase)
  			c = tolower(c);
  		if (c == EOF || strchr(target, c) != NULL)
  			break;
--- 236,242 -----
  			lcase = 0;
  	for EVER {
  		c = getchar();
! 		if (lcase && isupper(c))
  			c = tolower(c);
  		if (c == EOF || strchr(target, c) != NULL)
  			break;
**************
*** 266,272
  		if ((cols = tgetnum("co")) == EOF)
  			cols = 80;
  		if ((rows = tgetnum("li")) == EOF)
! 			rows = 80;
  	}
  #ifdef	USG
  	(void)ioctl(0, TCGETA, &oldtrm);
--- 268,274 -----
  		if ((cols = tgetnum("co")) == EOF)
  			cols = 80;
  		if ((rows = tgetnum("li")) == EOF)
! 			rows = 24;
  	}
  #ifdef	USG
  	(void)ioctl(0, TCGETA, &oldtrm);
**************
*** 270,276
  	}
  #ifdef	USG
  	(void)ioctl(0, TCGETA, &oldtrm);
! 	trm=oldtrm;
  	trm.c_lflag &= ~(ICANON | ECHO);
  	trm.c_cc[VMIN] = 1;
  	(void)ioctl(0, TCSETA, &trm);
--- 272,278 -----
  	}
  #ifdef	USG
  	(void)ioctl(0, TCGETA, &oldtrm);
! 	trm = strm = oldtrm;
  	trm.c_lflag &= ~(ICANON | ECHO);
  	trm.c_cc[VMIN] = 1;
  	strm.c_lflag |= (ICANON | ECHO);
**************
*** 273,278
  	trm=oldtrm;
  	trm.c_lflag &= ~(ICANON | ECHO);
  	trm.c_cc[VMIN] = 1;
  	(void)ioctl(0, TCSETA, &trm);
  	linefeeds = (trm.c_oflag & ONLCR);
  	destruct = !(trm.c_lflag & ECHOE);
--- 275,281 -----
  	trm = strm = oldtrm;
  	trm.c_lflag &= ~(ICANON | ECHO);
  	trm.c_cc[VMIN] = 1;
+ 	strm.c_lflag |= (ICANON | ECHO);
  	(void)ioctl(0, TCSETA, &trm);
  	linefeeds = (trm.c_oflag & ONLCR);
  	destruct = !(trm.c_lflag & ECHOE);
**************
*** 279,285
  #endif
  #ifdef	BSD
  	(void)ioctl(0, TIOCGETP, &oldtrm);
! 	trm=oldtrm;
  	trm.sg_flags &= ~ECHO;
  	trm.sg_flags |= CBREAK;
  	(void)ioctl(0, TIOCSETP, &trm);
--- 282,288 -----
  #endif
  #ifdef	BSD
  	(void)ioctl(0, TIOCGETP, &oldtrm);
! 	trm = strm = oldtrm;
  	trm.sg_flags &= ~ECHO;
  	trm.sg_flags |= CBREAK;
  	strm.sg_flags |= ECHO;
**************
*** 282,287
  	trm=oldtrm;
  	trm.sg_flags &= ~ECHO;
  	trm.sg_flags |= CBREAK;
  	(void)ioctl(0, TIOCSETP, &trm);
  	linefeeds = (trm.sg_flags & CRMOD);
  #endif
--- 285,291 -----
  	trm = strm = oldtrm;
  	trm.sg_flags &= ~ECHO;
  	trm.sg_flags |= CBREAK;
+ 	strm.sg_flags |= ECHO;
  	(void)ioctl(0, TIOCSETP, &trm);
  	linefeeds = (trm.sg_flags & CRMOD);
  #endif
**************
*** 316,321
  		putchar('\n');
  	else
  		outs(ceol_str);
  }
  
  void ttyreinit()
--- 320,335 -----
  		putchar('\n');
  	else
  		outs(ceol_str);
+ }
+ 
+ void ttysane()
+ {
+ #ifdef	USG
+ 	(void)ioctl(0, TCSETA, &strm);
+ #endif
+ #ifdef	BSD
+ 	(void)ioctl(0, TIOCSETP, &strm);
+ #endif
  }
  
  void ttyreinit()

*** ../old/tty.h Sat Mar 31 01:19:12 1990
--- tty.h Sat Mar 31 01:19:12 1990
**************
*** 4,10
   *	Copyright 1990 Scott Reynolds
   *	All rights reserved.
   *
!  *	@(#) tty.h 1.5
   *
   *	tty.h - function definitions for tty i/o
   **********************************************************************/
--- 4,10 -----
   *	Copyright 1990 Scott Reynolds
   *	All rights reserved.
   *
!  *	@(#) tty.h 1.6
   *
   *	tty.h - function definitions for tty i/o
   **********************************************************************/
**************
*** 15,20
  void	ttback();
  void	putwrap();
  void	ttyinit();
  void	ttyreinit();
  void	ttyexit();
  void	initscr();
--- 15,21 -----
  void	ttback();
  void	putwrap();
  void	ttyinit();
+ void	ttysane();
  void	ttyreinit();
  void	ttyexit();
  void	initscr();
-- 
Scott Reynolds			=	"You just gotta _know_."
Enterprise Information System	=			-anon
scott at clmqt.marquette.Mi.US	..rutgers!mailrus!sharkey!clmqt!scott



More information about the Alt.sources mailing list