[comp.sources.unix] v14i077: Mush updates for SystemV, etc., Patch1

rsalz@bbn.com (Rich Salz) (04/30/88)

Submitted-by: island!argv@sun.com (Dan Heller)
Posting-number: Volume 14, Issue 77
Archive-name: mush6.0/patch1

The patches included here apply mostly to System V sites and Pyramids.
Also included is a file called Mailrc which can be used to make Mush look
very much like ucb's Mail program. It was written by Bart Schaefer
(ogcvax!schaefer@sun.com).  Test your new mush by sending him mail
congratulating him on his upcoming wedding :-)

For more details (and lists of the new features), see README-6.1.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  README-6.1 Mailrc Diffs
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README-6.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README-6.1'\"
else
echo shar: Extracting \"'README-6.1'\" \(3039 characters\)
sed "s/^X//" >'README-6.1' <<'END_OF_FILE'
The patches included here apply mostly to system-v sites.  However,
you should include them if you are going to keep up to date with
future pathes.  Here is a summary of the files and functions that
have changed and why.
X
Also included with these update diffs is a file called Mailrc which
can be used to make Mush look very much like ucb's Mail program. It was
written by Bart Schaefer (ogcvax!schaefer@sun.com).  Test your new mush
by sending him mail congratulating him on his upcoming wedding :-)
X
mush.h --
X    Truncated version ID.
X
X    putchar() redefined fputc(c, stdout), fflush(stdout) because sys-v
X    isn't getting newlines when in curses mode. Isn't stdout supposed
X    to be line buffered?  Does setting cbreak or something change this?
X    If this doesn't fix the problem for sys-v, add setbuf(stdout, NULL) at
X    the top of main.c, but that shouldn't be necessary (in fact, none of
X    this _should_ be necessary).
X
X    SIGCHLD may cause infinite loop on pyramid's cpp cuz they
X    define SIGCHLD to be SIGCLD.  SIGCHLD is now only defined if it's
X    not already defined.  If your system has SIGCHLD and SIGCLD defined
X    to _different values_ and you have SYSV defined, you may need to
X    check into this, but I doubt your system's that weird.
X
X    glob_flags is now u_long (helps lint)
X
loop.c --
X    #ifdef SYSV around signal(SIGCHLD, ...) cuz sys-v doesn't really deal
X    with it correctly.  Best just let it default and forget about it. Note
X    that sys-v'ers won't be able to watch processes die using "debug" anymore.
X
commands.c --
X    Printenv() now takes an argument.  "printenv _var_" will
X    print the varname and value rather than all env variables.
X
mail.c --
X    OLD_MAILER and OLD_MAIL now merged to OLD_MAILER.  Too confusing
X    to have both and if either is used, both tend to be used.  Refer to
X    README-6.0 for details.
X
print.c --
X    yet more fixes for varargs.h people.  It seems that pyramid (sys-v/BSD)
X    now have va_start() defined to have an open brace ( { ) and va_end()
X    has the closing brace ( } ).  So, you can't have a starting block
X    be inbetween each call.  Who writes that stuff?
X
strings.c --
X    Sprintf() now supports varargs and has #ifdef VPRINTF checks.
X    As it turns out, some systems don't have IOSTRG either, but I'm not
X    really up to date on this one.  If you have a problem with it, just
X    remove its reference in the routine and it should work anyway.
X
hdrs.c --
X    compose_hdr() should run faster now (thus, any display of headers:
X    'h', 'z', etc...) should be faster due to the code no longer computes
X    the weekday name (Sun, Mon, etc..) unless specifically requested by %D
X    (in which it takes the same amount of time as before).
X
curs_io.c/signals.c --
X    added new function scrn_line which reads a line of text from a line
X    on the curses screen for use by stdout.  It seems that sys-v curses
X    package uses shorts instead of chars to represent each char on the
X    screen.  I use #ifdef A_CHARTEXT to see if this applies to you.
X
END_OF_FILE
if test 3039 -ne `wc -c <'README-6.1'`; then
    echo shar: \"'README-6.1'\" unpacked with wrong size!
fi
# end of 'README-6.1'
fi
if test -f 'Mailrc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Mailrc'\"
else
echo shar: Extracting \"'Mailrc'\" \(1467 characters\)
sed "s/^X//" >'Mailrc' <<'END_OF_FILE'
X# .mushrc to cause Mush to emulate UCB Mail
X# -- Bart Schaefer (schaefer@cse.ogc.edu)
X#----------------------------------------------------------------------------
X# Shortcomings:
X#  Mush does not support the "noisy phone line" flags of Mail
X#   (-i command line option or "set ignore" to ignore RUBOUT characters)
X#  Mush will never remove a system mailbox (no "unset keep" equivalent)
X#  See comments below on (lack of) command prefix recognition
X#  Date shown in headers ought to be date received, but instead is date sent
X#----------------------------------------------------------------------------
X#
X# Set up prompting, headers
X#
set prompt='& '
set mil_time
set hdr_format='%8.80a %D %M %-2N %5T  %l/%c "%.29s"'
X#
X# Set up mailing/replying miscellaneous
X#
set indent_str = "	"
set reply_to_hdr auto_route
X#
X# Set up command interface
X#  Note that a full emulation is difficult, because Mush does not support
X#  command prefix recognition (e.g., Mail interprets "Rep" as "Reply").
X#
X# No cmd can use '\!*' because ignore_bang must be set.  Yuck.
set ignore_bang
X# This stuff is fine, but really needs prefix recognition.
X#
cmd Reply replysender
cmd R replysender
cmd chdir cd
cmd chd cd
cmd + next
cmd ch cd
cmd c copy
cmd file folder
cmd fi folder
cmd hold preserve
cmd ho preserve
cmd reply replyall
cmd r replyall
cmd se set
cmd shell sh
cmd so source
cmd un undelete
cmd unread "flags U"	# "flags" is undocumented, but so is "unread" in Mail
cmd uns unset
X
END_OF_FILE
if test 1467 -ne `wc -c <'Mailrc'`; then
    echo shar: \"'Mailrc'\" unpacked with wrong size!
fi
# end of 'Mailrc'
fi
if test -f 'Diffs' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Diffs'\"
else
echo shar: Extracting \"'Diffs'\" \(12806 characters\)
sed "s/^X//" >'Diffs' <<'END_OF_FILE'
X
X*** OLD/commands.c	Wed Apr  6 22:47:58 1988
X--- commands.c	Tue Apr 26 20:08:49 1988
X***************
X*** 747,757 ****
X      return -1;
X  }
X  
X! Printenv()
X  {
X!     char **e = environ;
X!     while (*e)
X! 	wprint("%s\n", *e++);
X      return -1;
X  }
X  
X--- 747,759 ----
X      return -1;
X  }
X  
X! Printenv(argc, argv)
X! char **argv;
X  {
X!     char **e;
X!     for (e = environ; *e; e++)
X! 	if (argc < 1 || !strncmp(*e, argv[1]))
X! 	    wprint("%s\n", *e);
X      return -1;
X  }
X  
X*** OLD/curses.c	Wed Apr  6 22:47:58 1988
X--- curses.c	Wed Apr 27 21:48:35 1988
X***************
X*** 120,127 ****
X      if (isoff(glob_flags, CNTD_CMD)) {
X  	(void) check_new_mail();
X  	curlin = max(1, current_msg - n_array[0] + 1);
X! 	(void) strncpy(buf, stdscr->_y[curlin], COLS-1);
X! 	buf[COLS-1] = 0; /* strncpy does not null terminate */
X  	if (ison(glob_flags, REV_VIDEO) && msg_cnt)
X  	    STANDOUT(curlin, 0, buf);
X  	mail_status(0);
X--- 120,126 ----
X      if (isoff(glob_flags, CNTD_CMD)) {
X  	(void) check_new_mail();
X  	curlin = max(1, current_msg - n_array[0] + 1);
X! 	scrn_line(curlin, buf);
X  	if (ison(glob_flags, REV_VIDEO) && msg_cnt)
X  	    STANDOUT(curlin, 0, buf);
X  	mail_status(0);
X***************
X*** 707,711 ****
X--- 706,726 ----
X      }
X      turnoff(glob_flags, DO_UPDATE);
X      return 1; /* make sure bottom line is clear and no reverse video */
X+ }
X+ 
X+ scrn_line(line, buf)
X+ char *buf;
X+ {
X+ #ifndef A_CHARTEXT
X+     (void) strncpy(buf, stdscr->_y[line], COLS-1);
X+     buf[COLS-1] = 0; /* strncpy does not null terminate */
X+ #else
X+     int n;
X+ 
X+     for (n = 0; n < COLS; n++)
X+ 	if ((buf = mvinch(curline, n) & A_CHARTEXT) == '\0')
X+ 	    break;
X+     buf[n] = '\0';
X+ #endif /* A_CHARTEXT */
X  }
X  #endif /* CURSES */
X*** OLD/hdrs.c	Wed Apr  6 22:48:00 1988
X--- hdrs.c	Tue Apr 26 19:32:11 1988
X***************
X*** 253,259 ****
X      register char *p, *b;
X      char from[256], subject[256], date[17], lines[16], chars[16], line[256];
X      char to[256], addr[256], name[256], status[2];
X!     char Day[3], Mon[4], Tm[8], Yr[5], Wkday[4];
X  
X      /* status of the message */
X      if (ison(msg[cnt].m_flags, DELETE))
X--- 253,259 ----
X      register char *p, *b;
X      char from[256], subject[256], date[17], lines[16], chars[16], line[256];
X      char to[256], addr[256], name[256], status[2];
X!     char Day[3], Mon[4], Tm[8], Yr[5], Wkday[4], *date_p;
X  
X      /* status of the message */
X      if (ison(msg[cnt].m_flags, DELETE))
X***************
X*** 319,326 ****
X  	(void) get_name_n_addr(from, name, addr);
X      }
X  
X!     if (p = msg_date(cnt))
X! 	date_to_string(p, Yr, Mon, Day, Wkday, Tm, date);
X  
X      (void) sprintf(lines, "%d", msg[cnt].m_lines);
X      (void) sprintf(chars, "%ld", msg[cnt].m_size);
X--- 319,327 ----
X  	(void) get_name_n_addr(from, name, addr);
X      }
X  
X!     if (date_p = msg_date(cnt))
X! 	/* don't take weekday unless specified explicitly.  See 'D' below */
X! 	date_to_string(date_p, Yr, Mon, Day, NULL, Tm, date);
X  
X      (void) sprintf(lines, "%d", msg[cnt].m_lines);
X      (void) sprintf(chars, "%ld", msg[cnt].m_size);
X***************
X*** 394,400 ****
X  		when 'M': p2 = Mon;
X  		when 'Y': p2 = Yr;
X  		when 'N': p2 = Day;
X! 		when 'D': p2 = Wkday;
X  		otherwise: continue; /* unknown formatting char */
X  	    }
X  	    len = strlen(sprintf(b, fmt, p2));
X--- 395,409 ----
X  		when 'M': p2 = Mon;
X  		when 'Y': p2 = Yr;
X  		when 'N': p2 = Day;
X! 		when 'D': {
X! 		    /* specifying weekday name (sun, mon, tue, etc..) can be
X! 		     * very slow due to lots of *,/, and % operators.
X! 		     */
X! 		    char unused[16]; /* for date_to_string */
X! 		    if (*(p2 = Wkday) == '\0')
X! 			(void) date_to_string(date_p, NULL, NULL, NULL,
X! 					      p2, NULL, unused);
X! 		}
X  		otherwise: continue; /* unknown formatting char */
X  	    }
X  	    len = strlen(sprintf(b, fmt, p2));
X*** OLD/loop.c	Wed Apr  6 22:48:00 1988
X--- loop.c	Tue Apr 26 18:49:13 1988
X***************
X*** 51,57 ****
X      (void) signal(SIGQUIT, catch);
X      (void) signal(SIGHUP, catch);
X      (void) signal(SIGTERM, catch);
X!     (void) signal(SIGCHLD, sigchldcatcher);
X      (void) signal(SIGPIPE, SIG_IGN); /* if pager is terminated before end */
X  
X      turnoff(glob_flags, IGN_SIGS);
X--- 51,63 ----
X      (void) signal(SIGQUIT, catch);
X      (void) signal(SIGHUP, catch);
X      (void) signal(SIGTERM, catch);
X!     (void) signal(SIGCHLD,
X! #ifndef SYSV
X! 			   sigchldcatcher
X! #else /* SYSV */
X! 			   SIG_DFL
X! #endif /* SYSV */
X! 			   );
X      (void) signal(SIGPIPE, SIG_IGN); /* if pager is terminated before end */
X  
X      turnoff(glob_flags, IGN_SIGS);
X***************
X*** 97,103 ****
X  	 * (current message, deleted, unread, etc) are found in mail_status.
X  	 */
X  	mail_status(1);
X! 	if (Getstr(line, 256, 0) > -1)
X  	    p = line;
X  	else {
X  	    if (p = do_set(set_options, "ignoreeof")) {
X--- 103,109 ----
X  	 * (current message, deleted, unread, etc) are found in mail_status.
X  	 */
X  	mail_status(1);
X! 	if (Getstr(line, sizeof(line), 0) > -1)
X  	    p = line;
X  	else {
X  	    if (p = do_set(set_options, "ignoreeof")) {
X*** OLD/mail.c	Wed Apr  6 22:48:01 1988
X--- mail.c	Tue Apr 26 20:09:58 1988
X***************
X*** 1137,1150 ****
X  
X      /* Make folders conform to RFC-822 by adding From: and Date: headers.
X       * Some older mailers (binmail, execmail, delivermail), don't add
X!      * these headers to the MTA, so add them for OLD_MAIL systems.
X       */
X      for (size = 0; size < next_file; size++) {
X  	time_t t;
X! #ifndef OLD_MAIL
X  	if (size == 0)
X  	    continue;
X! #endif /* OLD_MAIL */
X  	(void) time(&t);
X  	if (size > 0) {
X  #ifndef MSG_SEPARATOR
X--- 1137,1150 ----
X  
X      /* Make folders conform to RFC-822 by adding From: and Date: headers.
X       * Some older mailers (binmail, execmail, delivermail), don't add
X!      * these headers to the MTA, so add them for OLD_MAILER systems.
X       */
X      for (size = 0; size < next_file; size++) {
X  	time_t t;
X! #ifndef OLD_MAILER
X  	if (size == 0)
X  	    continue;
X! #endif /* OLD_MAILER */
X  	(void) time(&t);
X  	if (size > 0) {
X  #ifndef MSG_SEPARATOR
X*** OLD/msgs.c  Wed Apr  6 22:48:02 1988
X--- msgs.c      Tue Apr 26 20:14:45 1988
X***************
X*** 305,310 ****
X--- 307,313 ----
X  	    (void) fclose(mail_fp);
X  	    return;
X  	}
X+ 	(void) fseek(tmpf, 0L, 2); /* assure we're at the end of the file */
X      } else if (msg_cnt)
X  	(void) fseek(tmpf, msg[msg_cnt-1].m_offset+msg[msg_cnt-1].m_size,L_SET);
X  
X*** OLD/mush.h	Wed Apr  6 22:48:02 1988
X--- mush.h	Tue Apr 26 21:09:52 1988
X***************
X*** 1,6 ****
X  /* @(#)mush.h	(c) copyright 1986 (Dan Heller) */
X  
X! #define VERSION "Mail User's Shell (Vers 6.0) Sat Apr  2 19:36:07 PST 1988"
X  
X  #include "config.h"
X  
X--- 1,6 ----
X  /* @(#)mush.h	(c) copyright 1986 (Dan Heller) */
X  
X! #define VERSION "Mail User's Shell (6.1 4/26/88)"
X  
X  #include "config.h"
X  
X***************
X*** 78,85 ****
X  #ifdef putchar
X  #undef putchar
X  #endif /* putchar */
X! #define putchar(c)	fputc(c, stdout)
X! #define bell() 		fputc('\007', stderr)
X  
X  /* For error recovery purposes, send keyboard generated signals to a special
X   * routine (interrupt) to set a global flag (WAS_INTR) and return to the
X--- 78,85 ----
X  #ifdef putchar
X  #undef putchar
X  #endif /* putchar */
X! #define putchar(c)	fputc(c, stdout), fflush(stdout)
X! #define bell() 		fputc('\007', stderr), fflush(stderr)
X  
X  /* For error recovery purposes, send keyboard generated signals to a special
X   * routine (interrupt) to set a global flag (WAS_INTR) and return to the
X***************
X*** 181,190 ****
X  #endif /* F_OK */
X  typedef	unsigned long	u_long;
X  #define vfork   fork
X! #ifdef SIGCHLD
X! #undef SIGCHLD
X! #endif /* SIGCHLD */
X  #define SIGCHLD SIGCLD
X  #endif /* SYSV */
X  
X  #if !defined(SUNTOOL) && !defined(CURSES)
X--- 181,189 ----
X  #endif /* F_OK */
X  typedef	unsigned long	u_long;
X  #define vfork   fork
X! #ifndef SIGCHLD
X  #define SIGCHLD SIGCLD
X+ #endif /* SIGCHLD */
X  #endif /* SYSV */
X  
X  #if !defined(SUNTOOL) && !defined(CURSES)
X***************
X*** 277,283 ****
X  #define NO_FLG		0
X  
X  /* various flags */
X! long   glob_flags;	/* global boolean flags thruout the whole program */
X  #define DO_UPDATE   1	/* check for changes to avoid unnecessary copyback */
X  #define REV_VIDEO   2	/* reverse video for curses or toolmode */
X  #define CONT_PRNT   3	/* continue to print (maybe a printf) without a '\n' */
X--- 276,282 ----
X  #define NO_FLG		0
X  
X  /* various flags */
X! u_long   glob_flags;	/* global boolean flags thruout the whole program */
X  #define DO_UPDATE   1	/* check for changes to avoid unnecessary copyback */
X  #define REV_VIDEO   2	/* reverse video for curses or toolmode */
X  #define CONT_PRNT   3	/* continue to print (maybe a printf) without a '\n' */
X*** OLD/signals.c	Wed Apr  6 22:48:03 1988
X--- signals.c	Wed Apr 27 21:36:43 1988
X***************
X*** 179,186 ****
X  		    msg_cnt) {
X  		int curlin = max(1, current_msg - n_array[0] + 1);
X  		char buf[256];
X! 		(void) strncpy(buf, stdscr->_y[curlin], COLS-1);
X! 		buf[COLS-1] = 0; /* strncpy does not null terminate */
X  		STANDOUT(curlin, 0, buf);
X  	    }
X  	    print("Stopping...");
X--- 179,185 ----
X  		    msg_cnt) {
X  		int curlin = max(1, current_msg - n_array[0] + 1);
X  		char buf[256];
X! 		scrn_line(curlin, buf);
X  		STANDOUT(curlin, 0, buf);
X  	    }
X  	    print("Stopping...");
X
X*** OLD/print.c	Thu Apr 28 22:45:28 1988
X--- print.c	Thu Apr 28 22:45:59 1988
X***************
X*** 1,3 ****
X--- 1,4 ----
X+ 
X  /* @(#)print.c	2.4	(c) copyright 10/15/86 (Dan Heller) */
X  
X  #include "mush.h"
X***************
X*** 36,43 ****
X      static int x; /* position on line saved for continued prints */
X      char *p; /* same type as struct file _ptr,_buf in stdio.h */
X  
X-     va_start(args); /* have args point to the beginning of argument stack */
X- 
X  #ifdef CURSES
X      if (iscurses) {
X  	if (isoff(glob_flags, CONT_PRNT))
X--- 37,42 ----
X***************
X*** 45,72 ****
X      } else
X  #endif /* CURSES */
X  	if (istool < 2) {
X  #ifdef VPRINTF
X  	    vprintf(fmt, args);
X  #else /* VPRINTF */
X  	    _doprnt(fmt, args, stdout);
X  #endif /* VPRINTF */
X- 	    fflush(stdout);
X  	    va_end(args);
X  	    return;
X  	}
X  #ifdef VPRINTF
X!     if (fmt)
X! 	vsprintf(msgbuf, fmt, args); /* NULL in fmt reprints last msg */
X  #else /* VPRINTF */
X!     foo._cnt = BUFSIZ;
X!     foo._base = foo._ptr = msgbuf; /* may have to be cast(unsigned char *) */
X!     foo._flag = _IOWRT+_IOSTRG;
X!     if (fmt) {   /* passing NULL (not "") reprints last message */
X! 	(void) _doprnt(fmt, args, &foo);
X! 	*foo._ptr = '\0'; /* plant terminating null character */
X      }
X- #endif /* VPIRNTF */
X-     va_end(args);
X      p = msgbuf;
X      if (iscurses || istool)
X  	while (p = index(p, '\n'))
X--- 44,72 ----
X      } else
X  #endif /* CURSES */
X  	if (istool < 2) {
X+ 	    va_start(args);
X  #ifdef VPRINTF
X  	    vprintf(fmt, args);
X  #else /* VPRINTF */
X  	    _doprnt(fmt, args, stdout);
X  #endif /* VPRINTF */
X  	    va_end(args);
X+ 	    fflush(stdout);
X  	    return;
X  	}
X+     if (fmt) {
X+ 	    va_start(args);
X  #ifdef VPRINTF
X! 	    vsprintf(msgbuf, fmt, args); /* NULL in fmt reprints last msg */
X  #else /* VPRINTF */
X! 	    foo._cnt = BUFSIZ;
X! 	    foo._base = foo._ptr = msgbuf; /* may have to be cast(unsigned char *) */
X! 	    foo._flag = _IOWRT+_IOSTRG;
X! 	    (void) _doprnt(fmt, args, &foo);
X! 	    *foo._ptr = '\0'; /* plant terminating null character */
X! #endif /* VPRINTF */
X! 	    va_end(args);
X      }
X      p = msgbuf;
X      if (iscurses || istool)
X  	while (p = index(p, '\n'))
X***************
X*** 88,93 ****
X--- 88,94 ----
X  	    turnon(glob_flags, CNTD_CMD); /* display ...continue... prompt */
X  	}
X  	turnoff(glob_flags, CONT_PRNT);
X+ 	fflush(stdout); /* some sys-v's aren't fflushing \n's */
X  	return;
X      }
X  #endif /* CURSES */
X***************
X*** 117,125 ****
X      char msgbuf[BUFSIZ]; /* we're not getting huge strings */
X      va_list args;
X  
X-     va_start(args);
X- 
X      if (istool < 2) {
X  #ifdef VPRINTF
X  	vprintf(fmt, args);
X  #else /* VPRINTF */
X--- 118,125 ----
X      char msgbuf[BUFSIZ]; /* we're not getting huge strings */
X      va_list args;
X  
X      if (istool < 2) {
X+ 	va_start(args);
X  #ifdef VPRINTF
X  	vprintf(fmt, args);
X  #else /* VPRINTF */
X***************
X*** 131,136 ****
X--- 131,137 ----
X      }
X      if (!fmt)
X  	return;
X+     va_start(args);
X  #ifdef VPRINTF
X      vsprintf(msgbuf, fmt, args); /* NULL in fmt reprints last msg */
X  #else /* VPRINTF */
X***************
X*** 140,145 ****
X--- 141,147 ----
X      _doprnt(fmt, args, &foo); /* format like printf into msgbuf via foo */
X      *foo._ptr = '\0'; /* plant terminating null character */
X  #endif /* VPRINTF */
X+     va_end(args);
X      Addstr(msgbuf);  /* addstr() will scroll if necessary */
X  }
X  
X***************
X*** 183,185 ****
X--- 185,188 ----
X  {
X      print("");
X  }
X+ 
END_OF_FILE
if test 12806 -ne `wc -c <'Diffs'`; then
    echo shar: \"'Diffs'\" unpacked with wrong size!
fi
# end of 'Diffs'
fi
echo shar: End of shell archive.
exit 0
-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.