home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1162 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  24.8 KB

  1. From: scott@clmqt.marquette.Mi.US (Scott Reynolds)
  2. Newsgroups: alt.sources
  3. Subject: NMail -- Novice Mail 1.0, patch 1
  4. Message-ID: <1990Apr10.231604.1367@clmqt.marquette.Mi.US>
  5. Date: 10 Apr 90 23:16:04 GMT
  6.  
  7. Patches are inevitable, aren't they...  <sigh>
  8.  
  9. Well, as Russ Nelson pointed out, tolower() doesn't work the same under
  10. BSD and SysV.  I've included a somewhat modified version of his patch
  11. here with the rest of them (Thanks, Russ!).  If you already applied that
  12. patch, you'll need to remove it first.
  13.  
  14. Other changes include:
  15.  
  16.     - fixed a bug that would kill outgoing mail in some situations
  17.         where the QUIT key was used to exit
  18.     - made config.h a little bit smarter for BSD
  19.     - better handling of files that aren't the user's mailbox
  20.  
  21. In case anyone was wondering about what could be done with the program
  22. once it was on the machine, I've included a slightly more detailed
  23. copyright notice.
  24.  
  25. *** ../old/Copyright Tue Apr 10 17:25:36 1990
  26. --- Copyright Tue Apr 10 17:25:36 1990
  27. **************
  28. *** 0 ***
  29. --- 1,13 -----
  30. + NMail -- Novice Mail v1.0
  31. + Copyright 1990 Scott Reynolds.  All rights reserved.
  32. + You are permitted to make copies and freely distribute this software 
  33. + as long as you keep all parts together (including this copyright 
  34. + notice) and you aren't making a profit from copying or distributing 
  35. + it.  Any form of packaging may be used (ARC, ZOO, ZIP, shar, etc.) 
  36. + provided that all source code and documentation are not altered in any 
  37. + way from the originals when unpackaged.
  38. + This software is provided "as is," without warranty of any kind, 
  39. + either express or implied, including, but not limited to, the implied 
  40. + warranties of merchantability and fitness for a particular purpose. 
  41.  
  42. *** ../old/addr.c Sat Mar 31 01:18:25 1990
  43. --- addr.c Sat Mar 31 01:18:25 1990
  44. **************
  45. *** 7,13
  46.    *    addr.c -- Check for valid/partial addresses
  47.    **********************************************************************/
  48.   
  49. ! static char    SCCSID[] = "@(#)addr.c:1.7";
  50.   
  51.   #include "config.h"
  52.   #include <stdio.h>
  53. --- 7,13 -----
  54.    *    addr.c -- Check for valid/partial addresses
  55.    **********************************************************************/
  56.   
  57. ! static char    SCCSID[] = "@(#)addr.c:1.8";
  58.   
  59.   #include "config.h"
  60.   #include <stdio.h>
  61. **************
  62. *** 159,165
  63.   
  64.       strcpy(addr, s);
  65.       for (p = addr; *p != '\0'; ++p)
  66. !         *p = tolower(*p);
  67.       (void) setpwent();
  68.       found = 0;
  69.       while (!found && (char *)(pwd = getpwent()) != NULL) {
  70. --- 159,166 -----
  71.   
  72.       strcpy(addr, s);
  73.       for (p = addr; *p != '\0'; ++p)
  74. !         if (isupper(*p))
  75. !             *p = tolower(*p);
  76.       (void) setpwent();
  77.       found = 0;
  78.       while (!found && (char *)(pwd = getpwent()) != NULL) {
  79. **************
  80. *** 175,181
  81.           }
  82.           strcpy(prompt, pwd->pw_gecos);
  83.           for (p = prompt; *p != '\0'; ++p)
  84. !             *p = tolower(*p);
  85.           if (strpos(prompt, addr) != NULL) {
  86.               sprintf(prompt, "Mail to %s (%s)?", pwd->pw_name, pwd->pw_gecos);
  87.               if (found = response(prompt, NO, YES))
  88. --- 176,183 -----
  89.           }
  90.           strcpy(prompt, pwd->pw_gecos);
  91.           for (p = prompt; *p != '\0'; ++p)
  92. !             if (isupper(*p))
  93. !                 *p = tolower(*p);
  94.           if (strpos(prompt, addr) != NULL) {
  95.               sprintf(prompt, "Mail to %s (%s)?", pwd->pw_name, pwd->pw_gecos);
  96.               if (found = response(prompt, NO, YES))
  97.  
  98. *** ../old/config.h Sat Mar 31 01:18:28 1990
  99. --- config.h Sat Mar 31 01:18:28 1990
  100. **************
  101. *** 4,10
  102.    *    Copyright 1990 Scott Reynolds
  103.    *    All rights reserved.
  104.    *
  105. !  *    @(#) config.h 1.13
  106.    *
  107.    *    config.h -- system configuration
  108.    **********************************************************************/
  109. --- 4,10 -----
  110.    *    Copyright 1990 Scott Reynolds
  111.    *    All rights reserved.
  112.    *
  113. !  *    @(#) config.h 1.14
  114.    *
  115.    *    config.h -- system configuration
  116.    **********************************************************************/
  117. **************
  118. *** 20,26
  119.   /* #define    BITFIELDS    /* compiler supports bit fields        */
  120.   
  121.   #define    SPOOLDIR    "/usr/spool/mail"    /* mail spool directory    */
  122. - #define    MAILER        "/bin/rmail %s"        /* delivery agent    */
  123.   #define    TMPFILE     "/tmp/nmailXXXXXX"    /* template for mailer    */
  124.   #define    SIGFILE     ".signature"        /* signature file    */
  125.   #define    EDITOR        "/bin/vi"        /* default text editor    */
  126. --- 20,25 -----
  127.   /* #define    BITFIELDS    /* compiler supports bit fields        */
  128.   
  129.   #define    SPOOLDIR    "/usr/spool/mail"    /* mail spool directory    */
  130.   #define    TMPFILE     "/tmp/nmailXXXXXX"    /* template for mailer    */
  131.   #define    SIGFILE     ".signature"        /* signature file    */
  132.   #define    EDITOR        "/bin/vi"        /* default text editor    */
  133. **************
  134. *** 24,29
  135.   #define    TMPFILE     "/tmp/nmailXXXXXX"    /* template for mailer    */
  136.   #define    SIGFILE     ".signature"        /* signature file    */
  137.   #define    EDITOR        "/bin/vi"        /* default text editor    */
  138.   
  139.   #define    DOMAINMAILER        /* mailer recognizes domain names    */
  140.   
  141. --- 23,33 -----
  142.   #define    TMPFILE     "/tmp/nmailXXXXXX"    /* template for mailer    */
  143.   #define    SIGFILE     ".signature"        /* signature file    */
  144.   #define    EDITOR        "/bin/vi"        /* default text editor    */
  145. + #ifdef    M_XENIX
  146. + #define    MAILER        "/usr/bin/rmail %s"    /* XENIX delivery agent    */
  147. + #else
  148. + #define    MAILER        "/bin/rmail %s"        /* delivery agent    */
  149. + #endif
  150.   
  151.   #define    DOMAINMAILER        /* mailer recognizes domain names    */
  152.   
  153. **************
  154. *** 40,45
  155.    * and to check for local addresses in restricted mode.
  156.    ***/
  157.   /* #define    MYNAME    "foo"    /* override node name from system calls    */
  158.   #define    UNAME            /* use uname() to get node name        */
  159.   /* #define    GETHOSTNAME    /* use gethostname() to get node name    */
  160.   
  161. --- 44,50 -----
  162.    * and to check for local addresses in restricted mode.
  163.    ***/
  164.   /* #define    MYNAME    "foo"    /* override node name from system calls    */
  165. + #ifdef    USG
  166.   #define    UNAME            /* use uname() to get node name        */
  167.   #else /* !USG */
  168.   #define    GETHOSTNAME        /* use gethostname() to get node name    */
  169. **************
  170. *** 41,47
  171.    ***/
  172.   /* #define    MYNAME    "foo"    /* override node name from system calls    */
  173.   #define    UNAME            /* use uname() to get node name        */
  174. ! /* #define    GETHOSTNAME    /* use gethostname() to get node name    */
  175.   
  176.   /***
  177.    * Define MYDOMAIN to be your site's domain.  The system will construct
  178. --- 46,54 -----
  179.   /* #define    MYNAME    "foo"    /* override node name from system calls    */
  180.   #ifdef    USG
  181.   #define    UNAME            /* use uname() to get node name        */
  182. ! #else /* !USG */
  183. ! #define    GETHOSTNAME        /* use gethostname() to get node name    */
  184. ! #endif /* USG */
  185.   
  186.   /***
  187.    * Define MYDOMAIN to be your site's domain.  The system will construct
  188. **************
  189. *** 49,61
  190.    * DOMAINMAILER defined.
  191.    ***/
  192.   #define    MYDOMAIN    ".UUCP"    /* set this to your site's domain    */
  193. - /***
  194. -  * fix the following to reflect your machine
  195. -  ***/
  196. - typedef    unsigned char    byte;    /* 8-bit unsigned integer    */
  197. - typedef    short int    int16;    /* 16-bit signed integer    */
  198. - typedef    long        int32;    /* 32-bit signed integer    */
  199.   
  200.   /***
  201.    * LOW_UID is the lowest user ID that will be considered a partial
  202. --- 56,61 -----
  203.    * DOMAINMAILER defined.
  204.    ***/
  205.   #define    MYDOMAIN    ".UUCP"    /* set this to your site's domain    */
  206.   
  207.   /***
  208.    * LOW_UID is the lowest user ID that will be considered a partial
  209.  
  210. *** ../old/nmail.1 Sat Mar 31 01:18:34 1990
  211. --- nmail.1 Sat Mar 31 01:18:34 1990
  212. **************
  213. *** 1,4
  214. ! .\"@(#)nmail.1:1.9
  215.   .TH NMAIL 1
  216.   .SH NAME
  217.   nmail \- a mail reader for novices (and the rest of us, too)
  218. --- 1,4 -----
  219. ! .\"@(#)nmail.1:1.11
  220.   .TH NMAIL 1
  221.   .SH NAME
  222.   nmail \- a mail reader for novices (and the rest of us, too)
  223. **************
  224. *** 13,18
  225.   [
  226.   \-f\^\fIfile\fP
  227.   ]
  228.   .PP
  229.   .B nmail
  230.   [
  231. --- 13,21 -----
  232.   [
  233.   \-f\^\fIfile\fP
  234.   ]
  235. + [
  236. + \fI+file\fp
  237. + ]
  238.   .PP
  239.   .B nmail
  240.   [
  241. **************
  242. *** 105,110
  243.   and
  244.   .B Subject:
  245.   lines in order to send mail.
  246.   .SH READING MESSAGES
  247.   The default action of \fInmail\fP when reading is to display one full
  248.   page of the message,
  249. --- 108,116 -----
  250.   and
  251.   .B Subject:
  252.   lines in order to send mail.
  253. + .PP
  254. + Specifying a file on the command line in the form \fI+file\fP
  255. + is identical to using the \fI\-f\fP option.
  256.   .SH READING MESSAGES
  257.   The default action of \fInmail\fP when reading is to display one full
  258.   page of the message,
  259.  
  260. *** ../old/nmail.c Sat Mar 31 01:18:54 1990
  261. --- nmail.c Sat Mar 31 01:18:54 1990
  262. **************
  263. *** 7,13
  264.    *    nmail.c -- Main program and mailbox handling
  265.    **********************************************************************/
  266.   
  267. ! static char    SCCSID[] = "@(#)nmail.c:1.35";
  268.   
  269.   #include "config.h"
  270.   #include <stdio.h>
  271. --- 7,13 -----
  272.    *    nmail.c -- Main program and mailbox handling
  273.    **********************************************************************/
  274.   
  275. ! static char    SCCSID[] = "@(#)nmail.c:1.38";
  276.   
  277.   #include "config.h"
  278.   #include <stdio.h>
  279. **************
  280. *** 44,49
  281.   int    restricted = 0;        /* restricted; local address, no shell    */
  282.   int    paging = 1;        /* enable paging in text display    */
  283.   int    partial = 0;        /* check partial addresses locally    */
  284.   jmp_buf    jmp_intr;        /* jump information for SIGINT        */
  285.   
  286.   static char    *helpscr[] = {
  287. --- 44,50 -----
  288.   int    restricted = 0;        /* restricted; local address, no shell    */
  289.   int    paging = 1;        /* enable paging in text display    */
  290.   int    partial = 0;        /* check partial addresses locally    */
  291. + int    folder = 0;        /* reading a folder, not a mailbox    */
  292.   jmp_buf    jmp_intr;        /* jump information for SIGINT        */
  293.   
  294.   static char    *helpscr[] = {
  295. **************
  296. *** 136,141
  297.               break;
  298.           case 'f':
  299.               mbox = strdup(optarg);
  300.               break;
  301.           case 'h':
  302.               headermode = 1;
  303. --- 137,143 -----
  304.               break;
  305.           case 'f':
  306.               mbox = strdup(optarg);
  307. +             folder = 1;
  308.               break;
  309.           case 'h':
  310.               headermode = 1;
  311. **************
  312. *** 168,174
  313.               expert = 1;
  314.               break;
  315.           default:
  316. !             fprintf(stderr, "usage: %s [-achHnx] [-pN] [-s subject] [-f file] [user...]\n", argv[0]);
  317.               ttyexit();
  318.               cleanup(1);
  319.           }
  320. --- 170,176 -----
  321.               expert = 1;
  322.               break;
  323.           default:
  324. !             fprintf(stderr, "usage:\t%s [-achHLnrRtx] [-pN] [-f file] [+file] [-s subject] [user...]\n", argv[0]);
  325.               ttyexit();
  326.               cleanup(1);
  327.           }
  328. **************
  329. *** 174,179
  330.           }
  331.       }
  332.   
  333.       if (send || optind < argc) {
  334.           if (restricted > 1) {
  335.               fputs("Permission to originate mail denied.\n", stderr);
  336. --- 176,187 -----
  337.           }
  338.       }
  339.   
  340. +     if (!send && optind < argc && *argv[optind] == '+') {
  341. +         mbox = argv[optind] + 1;
  342. +         ++optind;
  343. +         folder = 1;
  344. +     }
  345.       if (send || optind < argc) {
  346.           if (restricted > 1) {
  347.               fputs("Permission to originate mail denied.\n", stderr);
  348. **************
  349. *** 218,224
  350.           }
  351.       }
  352.       if ((char *)(dfp = fopen(mbox, "r")) == NULL) {
  353. !         puts("No mail.");
  354.           ttyexit();
  355.           cleanup(10);
  356.       }
  357. --- 226,237 -----
  358.           }
  359.       }
  360.       if ((char *)(dfp = fopen(mbox, "r")) == NULL) {
  361. !         if (!folder)
  362. !             puts("No mail.");
  363. !         else if (errno == ENOENT || errno == ENOTDIR)
  364. !             printf("File '%s' doesn't exist\n", mbox);
  365. !         else
  366. !             printf("File '%s' is unreadable\n", mbox);
  367.           ttyexit();
  368.           cleanup(10);
  369.       }
  370. **************
  371. *** 223,229
  372.           cleanup(10);
  373.       }
  374.   
  375. !     mtime = modtime(dfp);
  376.       findhdr(dfp);
  377.   
  378.       for (mcount = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp)
  379. --- 236,247 -----
  380.           cleanup(10);
  381.       }
  382.   
  383. !     if (folder) {
  384. !         printf("Reading '%s'...", mbox);
  385. !         fflush(stdout);
  386. !     } else {
  387. !         mtime = modtime(dfp);
  388. !     }
  389.       findhdr(dfp);
  390.       if (folder)
  391.           putchar('\n');
  392. **************
  393. *** 225,230
  394.   
  395.       mtime = modtime(dfp);
  396.       findhdr(dfp);
  397.   
  398.       for (mcount = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp)
  399.           if (!new || !hdrp->o_read)
  400. --- 243,250 -----
  401.           mtime = modtime(dfp);
  402.       }
  403.       findhdr(dfp);
  404. +     if (folder)
  405. +         putchar('\n');
  406.   
  407.       for (mcount = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp)
  408.           if (!new || !hdrp->o_read)
  409. **************
  410. *** 244,250
  411.           cleanup(11);
  412.       }
  413.   
  414. !     if (!new) {
  415.           printf("Your mailbox contains %u message%s.\n", mcount, (mcount > 1) ? "s" : "");
  416.           sprintf(input, "Do you wish to read %s now?", (mcount > 1) ? "them" : "it");
  417.           if (!response(input, YES, YES)) {
  418. --- 264,270 -----
  419.           cleanup(11);
  420.       }
  421.   
  422. !     if (!(new || folder)) {
  423.           printf("Your mailbox contains %u message%s.\n", mcount, (mcount > 1) ? "s" : "");
  424.           sprintf(input, "Do you wish to read %s now?", (mcount > 1) ? "them" : "it");
  425.           if (!response(input, YES, YES)) {
  426. **************
  427. *** 320,326
  428.               if (!(headermode || hdrp->deleted)) {
  429.                   putchar('\n');
  430.                   ++curline;
  431. !                 if (displaytext(dfp, hdrp, &info))
  432.                       hdrp->read = 1;
  433.               }
  434.           }
  435. --- 340,346 -----
  436.               if (!(headermode || hdrp->deleted)) {
  437.                   putchar('\n');
  438.                   ++curline;
  439. !                 if (displaytext(dfp, hdrp, &info) && !folder)
  440.                       hdrp->read = 1;
  441.               }
  442.           }
  443. **************
  444. *** 349,355
  445.               do {
  446.                   invalid = 0;
  447.                   c = getchar();
  448. !                 switch (tolower(c)) {
  449.                   case '\f':
  450.                       done = 1;
  451.                       break;
  452. --- 369,375 -----
  453.               do {
  454.                   invalid = 0;
  455.                   c = getchar();
  456. !                 switch (isupper(c) ? tolower(c) : c) {
  457.                   case '\f':
  458.                       done = 1;
  459.                       break;
  460. **************
  461. *** 492,500
  462.                       brkenable(msg_intr);
  463.                       if (setjmp(jmp_intr))
  464.                           putchar('\n');
  465. !                     else
  466. !                         if (displaytext(dfp, hdrp, &info))
  467. !                             hdrp->read = 1;
  468.                       brkdisable();
  469.                       break;
  470.                   case 'x':
  471. --- 512,519 -----
  472.                       brkenable(msg_intr);
  473.                       if (setjmp(jmp_intr))
  474.                           putchar('\n');
  475. !                     else if (displaytext(dfp, hdrp, &info) && !folder)
  476. !                         hdrp->read = 1;
  477.                       brkdisable();
  478.                       break;
  479.                   case 'x':
  480. **************
  481. *** 549,554
  482.       }
  483.       (void) fclose(dfp);
  484.       
  485.       for (mcount = 0, update = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp) {
  486.           if (!hdrp->deleted)
  487.               ++mcount;
  488. --- 568,576 -----
  489.       }
  490.       (void) fclose(dfp);
  491.       
  492. +     if (sendcount)
  493. +         printf("You sent %d message%s.\n", sendcount, (sendcount == 1) ? "" : "s");
  494.       for (mcount = 0, update = 0, hdrp = hdr; hdrp->offset >= 0L; ++hdrp) {
  495.           if (!hdrp->deleted)
  496.               ++mcount;
  497. **************
  498. *** 558,569
  499.       if (update || mcount < count)
  500.           if ((mcount = savemail(mbox)) == (-1))
  501.               mcount = count;
  502. !     if (mcount)
  503. !         printf("%d message%s saved in mailbox.\n", mcount, (mcount == 1) ? "" : "s");
  504. !     else
  505. !         puts("Your mailbox is empty.");
  506. !     if (sendcount)
  507. !         printf("You sent %d message%s.\n", sendcount, (sendcount == 1) ? "" : "s");
  508.       ttyexit();
  509.       cleanup(0);
  510.   /*NOTREACHED*/
  511. --- 580,600 -----
  512.       if (update || mcount < count)
  513.           if ((mcount = savemail(mbox)) == (-1))
  514.               mcount = count;
  515. !     if (folder) {
  516. !         if (mcount) {
  517. !             printf("%d message%s saved in '%s'\n",
  518. !                 mcount, (mcount == 1) ? "" : "s", mbox);
  519. !         } else {
  520. !             (void) unlink(mbox);
  521. !             printf("Empty file '%s' deleted.\n", mbox);
  522. !         }
  523. !     } else {
  524. !         if (mcount)
  525. !             printf("%d message%s saved in mailbox.\n",
  526. !                 mcount, (mcount == 1) ? "" : "s");
  527. !         else
  528. !             puts("Your mailbox is empty.");
  529. !     }
  530.       ttyexit();
  531.       cleanup(0);
  532.   /*NOTREACHED*/
  533.  
  534. *** ../old/opt.c Sat Mar 31 01:18:56 1990
  535. --- opt.c Sat Mar 31 01:18:56 1990
  536. **************
  537. *** 7,13
  538.    *    opt.c - Functions to manage default options
  539.    **********************************************************************/
  540.   
  541. ! static char    SCCSID[] = "@(#)opt.c:1.6";
  542.   
  543.   #include "config.h"
  544.   #include <stdio.h>
  545. --- 7,13 -----
  546.    *    opt.c - Functions to manage default options
  547.    **********************************************************************/
  548.   
  549. ! static char    SCCSID[] = "@(#)opt.c:1.7";
  550.   
  551.   #include "config.h"
  552.   #include <stdio.h>
  553. **************
  554. *** 44,50
  555.           do {
  556.               invalid = 0;
  557.               c = getchar();
  558. !             switch (tolower(c)) {
  559.               case 'q':
  560.               case '\b':
  561.               case '\033':
  562. --- 44,50 -----
  563.           do {
  564.               invalid = 0;
  565.               c = getchar();
  566. !             switch (isupper(c) ? tolower(c) : c) {
  567.               case 'q':
  568.               case '\b':
  569.               case '\033':
  570.  
  571. *** ../old/patchlevel.h Sat Mar 31 01:18:58 1990
  572. --- patchlevel.h Sat Mar 31 01:18:58 1990
  573. **************
  574. *** 7,10
  575.    *    patchlevel.h -- current release patch level
  576.    **********************************************************************/
  577.   
  578. ! #define    PATCHLEVEL    0
  579. --- 7,10 -----
  580.    *    patchlevel.h -- current release patch level
  581.    **********************************************************************/
  582.   
  583. ! #define    PATCHLEVEL    1
  584.  
  585. *** ../old/proc.c Sat Mar 31 01:19:06 1990
  586. --- proc.c Sat Mar 31 01:19:06 1990
  587. **************
  588. *** 7,13
  589.    *    proc.c -- process individual messages
  590.    **********************************************************************/
  591.   
  592. ! static char    SCCSID[] = "@(#)proc.c:1.2";
  593.   
  594.   #include "config.h"
  595.   #include <stdio.h>
  596. --- 7,13 -----
  597.    *    proc.c -- process individual messages
  598.    **********************************************************************/
  599.   
  600. ! static char    SCCSID[] = "@(#)proc.c:1.4";
  601.   
  602.   #include "config.h"
  603.   #include <stdio.h>
  604. **************
  605. *** 12,17
  606.   #include "config.h"
  607.   #include <stdio.h>
  608.   #include <string.h>
  609.   #include <ctype.h>
  610.   #include <errno.h>
  611.   #include <sys/types.h>
  612. --- 12,18 -----
  613.   #include "config.h"
  614.   #include <stdio.h>
  615.   #include <string.h>
  616. + #include <signal.h>
  617.   #include <ctype.h>
  618.   #include <errno.h>
  619.   #include <sys/types.h>
  620. **************
  621. *** 244,251
  622.               done = save = send = pipe = restart = forward = 0;
  623.               do {
  624.                   c = getchar();
  625. !                 c = tolower(c);
  626. !                 switch (c) {
  627.                   case '^':
  628.                       thispage = start;
  629.                   case '\f':
  630. --- 245,251 -----
  631.               done = save = send = pipe = restart = forward = 0;
  632.               do {
  633.                   c = getchar();
  634. !                 switch (isupper(c) ? tolower(c) : c) {
  635.                   case '^':
  636.                       thispage = start;
  637.                   case '\f':
  638. **************
  639. *** 348,353
  640.   
  641.   void runshell()
  642.   {
  643.       cmd[0] = '\0';
  644.       (void) ttgets("! ", cmd, LEN);
  645.       if (pid > 0)
  646. --- 348,356 -----
  647.   
  648.   void runshell()
  649.   {
  650. +     int    (*qstat)();
  651. +     int    (*istat)();
  652.       cmd[0] = '\0';
  653.       (void) ttgets("!", cmd, LEN);
  654.       if (pid > 0)
  655. **************
  656. *** 349,355
  657.   void runshell()
  658.   {
  659.       cmd[0] = '\0';
  660. !     (void) ttgets("! ", cmd, LEN);
  661.       if (pid > 0)
  662.           (void) wait((int *)0);
  663.       ttyexit();
  664. --- 352,358 -----
  665.       int    (*istat)();
  666.   
  667.       cmd[0] = '\0';
  668. !     (void) ttgets("!", cmd, LEN);
  669.       if (pid > 0)
  670.           (void) wait((int *)0);
  671.       qstat = signal(SIGQUIT, SIG_IGN);
  672. **************
  673. *** 352,358
  674.       (void) ttgets("! ", cmd, LEN);
  675.       if (pid > 0)
  676.           (void) wait((int *)0);
  677. !     ttyexit();
  678.       if ((pid = fork()) == 0) {
  679.           if (cmd[0] == '\0')
  680.               (void) execlp("/bin/sh", "sh", NULL);
  681. --- 355,363 -----
  682.       (void) ttgets("!", cmd, LEN);
  683.       if (pid > 0)
  684.           (void) wait((int *)0);
  685. !     qstat = signal(SIGQUIT, SIG_IGN);
  686. !     istat = signal(SIGINT, SIG_IGN);
  687. !     ttysane();
  688.       if ((pid = fork()) == 0) {
  689.           (void) signal(SIGINT, SIG_DFL);
  690.           (void) signal(SIGQUIT, SIG_DFL);
  691. **************
  692. *** 354,359
  693.           (void) wait((int *)0);
  694.       ttyexit();
  695.       if ((pid = fork()) == 0) {
  696.           if (cmd[0] == '\0')
  697.               (void) execlp("/bin/sh", "sh", NULL);
  698.           else
  699. --- 359,367 -----
  700.       istat = signal(SIGINT, SIG_IGN);
  701.       ttysane();
  702.       if ((pid = fork()) == 0) {
  703. +         (void) signal(SIGINT, SIG_DFL);
  704. +         (void) signal(SIGQUIT, SIG_DFL);
  705. +         (void) signal(SIGHUP, SIG_DFL);
  706.           if (cmd[0] == '\0')
  707.               (void) execlp("/bin/sh", "sh", NULL);
  708.           else
  709. **************
  710. *** 376,381
  711.           fflush(stdout);
  712.           (void) getchar();
  713.       }
  714.   }
  715.   
  716.   void pipecmd(fp, hdrp)
  717. --- 384,391 -----
  718.           fflush(stdout);
  719.           (void) getchar();
  720.       }
  721. +     (void) signal(SIGINT, istat);
  722. +     (void) signal(SIGQUIT, qstat);
  723.   }
  724.   
  725.   void pipecmd(fp, hdrp)
  726. **************
  727. *** 471,476
  728.       if (pid > 0)
  729.           (void) wait((int *)0);
  730.       if ((pid = fork()) == 0) {
  731.           sprintf(cmd, MAILER, address);
  732.           if ((char *)(pfp = popen(cmd, "w")) == NULL) {
  733.               perror("popen(MAILER)");
  734. --- 481,488 -----
  735.       if (pid > 0)
  736.           (void) wait((int *)0);
  737.       if ((pid = fork()) == 0) {
  738. +         (void) signal(SIGINT, SIG_IGN);
  739. +         (void) signal(SIGQUIT, SIG_IGN);
  740.           sprintf(cmd, MAILER, address);
  741.           if ((char *)(pfp = popen(cmd, "w")) == NULL) {
  742.               perror("popen(MAILER)");
  743. **************
  744. *** 671,676
  745.           if (pid > 0)
  746.               (void) wait((int *)0);
  747.           if ((pid = fork()) == 0) {
  748.               sprintf(cmd, MAILER, address);
  749.               if ((char *)(pfp = popen(cmd, "w")) == NULL) {
  750.                   perror("popen(MAILER)");
  751. --- 683,690 -----
  752.           if (pid > 0)
  753.               (void) wait((int *)0);
  754.           if ((pid = fork()) == 0) {
  755. +             (void) signal(SIGINT, SIG_IGN);
  756. +             (void) signal(SIGQUIT, SIG_IGN);
  757.               sprintf(cmd, MAILER, address);
  758.               if ((char *)(pfp = popen(cmd, "w")) == NULL) {
  759.                   perror("popen(MAILER)");
  760. **************
  761. *** 676,682
  762.                   perror("popen(MAILER)");
  763.                   retval = 28;
  764.               } else {
  765. -                 fprintf(pfp, "To: %s\n", address);
  766.                   fprintf(pfp, "From: %s", myaddr());
  767.                   if ((s = username()) != NULL && *s != '\0')
  768.                       (void) fprintf(pfp, " (%s)", s);
  769. --- 690,695 -----
  770.                   perror("popen(MAILER)");
  771.                   retval = 28;
  772.               } else {
  773.                   fprintf(pfp, "From: %s", myaddr());
  774.                   if ((s = username()) != NULL && *s != '\0')
  775.                       (void) fprintf(pfp, " (%s)", s);
  776.  
  777. *** ../old/tty.c Sat Mar 31 01:19:11 1990
  778. --- tty.c Sat Mar 31 01:19:11 1990
  779. **************
  780. *** 7,13
  781.    *    tty.c - Basic tty input/output
  782.    **********************************************************************/
  783.   
  784. ! static char    SCCSID[] = "@(#)tty.c:1.9";
  785.   
  786.   #include "config.h"
  787.   #include <stdio.h>
  788. --- 7,13 -----
  789.    *    tty.c - Basic tty input/output
  790.    **********************************************************************/
  791.   
  792. ! static char    SCCSID[] = "@(#)tty.c:1.11";
  793.   
  794.   #include "config.h"
  795.   #include <stdio.h>
  796. **************
  797. *** 33,38
  798.   static char    *send_str = NULL;
  799.   static char    *sout_str = NULL;
  800.   static struct termio    trm;
  801.   static struct termio    oldtrm;
  802.   
  803.   #define    EVER    (;;)
  804. --- 33,39 -----
  805.   static char    *send_str = NULL;
  806.   static char    *sout_str = NULL;
  807.   static struct termio    trm;
  808. + static struct termio    strm;
  809.   static struct termio    oldtrm;
  810.   
  811.   #define    EVER    (;;)
  812. **************
  813. *** 204,210
  814.           fputs(" (y/[N]) ", stdout);
  815.       do {
  816.           c = getchar();
  817. !         c = tolower(c);
  818.           if (c == '\n')
  819.               c = (defval == YES) ? 'y' : 'n';
  820.           if (c != 'y' && c != 'n')
  821. --- 205,212 -----
  822.           fputs(" (y/[N]) ", stdout);
  823.       do {
  824.           c = getchar();
  825. !         if (isupper(c))
  826. !             c = tolower(c);
  827.           if (c == '\n')
  828.               c = (defval == YES) ? 'y' : 'n';
  829.           if (c != 'y' && c != 'n')
  830. **************
  831. *** 234,240
  832.               lcase = 0;
  833.       for EVER {
  834.           c = getchar();
  835. !         if (lcase)
  836.               c = tolower(c);
  837.           if (c == EOF || strchr(target, c) != NULL)
  838.               break;
  839. --- 236,242 -----
  840.               lcase = 0;
  841.       for EVER {
  842.           c = getchar();
  843. !         if (lcase && isupper(c))
  844.               c = tolower(c);
  845.           if (c == EOF || strchr(target, c) != NULL)
  846.               break;
  847. **************
  848. *** 266,272
  849.           if ((cols = tgetnum("co")) == EOF)
  850.               cols = 80;
  851.           if ((rows = tgetnum("li")) == EOF)
  852. !             rows = 80;
  853.       }
  854.   #ifdef    USG
  855.       (void)ioctl(0, TCGETA, &oldtrm);
  856. --- 268,274 -----
  857.           if ((cols = tgetnum("co")) == EOF)
  858.               cols = 80;
  859.           if ((rows = tgetnum("li")) == EOF)
  860. !             rows = 24;
  861.       }
  862.   #ifdef    USG
  863.       (void)ioctl(0, TCGETA, &oldtrm);
  864. **************
  865. *** 270,276
  866.       }
  867.   #ifdef    USG
  868.       (void)ioctl(0, TCGETA, &oldtrm);
  869. !     trm=oldtrm;
  870.       trm.c_lflag &= ~(ICANON | ECHO);
  871.       trm.c_cc[VMIN] = 1;
  872.       (void)ioctl(0, TCSETA, &trm);
  873. --- 272,278 -----
  874.       }
  875.   #ifdef    USG
  876.       (void)ioctl(0, TCGETA, &oldtrm);
  877. !     trm = strm = oldtrm;
  878.       trm.c_lflag &= ~(ICANON | ECHO);
  879.       trm.c_cc[VMIN] = 1;
  880.       strm.c_lflag |= (ICANON | ECHO);
  881. **************
  882. *** 273,278
  883.       trm=oldtrm;
  884.       trm.c_lflag &= ~(ICANON | ECHO);
  885.       trm.c_cc[VMIN] = 1;
  886.       (void)ioctl(0, TCSETA, &trm);
  887.       linefeeds = (trm.c_oflag & ONLCR);
  888.       destruct = !(trm.c_lflag & ECHOE);
  889. --- 275,281 -----
  890.       trm = strm = oldtrm;
  891.       trm.c_lflag &= ~(ICANON | ECHO);
  892.       trm.c_cc[VMIN] = 1;
  893. +     strm.c_lflag |= (ICANON | ECHO);
  894.       (void)ioctl(0, TCSETA, &trm);
  895.       linefeeds = (trm.c_oflag & ONLCR);
  896.       destruct = !(trm.c_lflag & ECHOE);
  897. **************
  898. *** 279,285
  899.   #endif
  900.   #ifdef    BSD
  901.       (void)ioctl(0, TIOCGETP, &oldtrm);
  902. !     trm=oldtrm;
  903.       trm.sg_flags &= ~ECHO;
  904.       trm.sg_flags |= CBREAK;
  905.       (void)ioctl(0, TIOCSETP, &trm);
  906. --- 282,288 -----
  907.   #endif
  908.   #ifdef    BSD
  909.       (void)ioctl(0, TIOCGETP, &oldtrm);
  910. !     trm = strm = oldtrm;
  911.       trm.sg_flags &= ~ECHO;
  912.       trm.sg_flags |= CBREAK;
  913.       strm.sg_flags |= ECHO;
  914. **************
  915. *** 282,287
  916.       trm=oldtrm;
  917.       trm.sg_flags &= ~ECHO;
  918.       trm.sg_flags |= CBREAK;
  919.       (void)ioctl(0, TIOCSETP, &trm);
  920.       linefeeds = (trm.sg_flags & CRMOD);
  921.   #endif
  922. --- 285,291 -----
  923.       trm = strm = oldtrm;
  924.       trm.sg_flags &= ~ECHO;
  925.       trm.sg_flags |= CBREAK;
  926. +     strm.sg_flags |= ECHO;
  927.       (void)ioctl(0, TIOCSETP, &trm);
  928.       linefeeds = (trm.sg_flags & CRMOD);
  929.   #endif
  930. **************
  931. *** 316,321
  932.           putchar('\n');
  933.       else
  934.           outs(ceol_str);
  935.   }
  936.   
  937.   void ttyreinit()
  938. --- 320,335 -----
  939.           putchar('\n');
  940.       else
  941.           outs(ceol_str);
  942. + }
  943. + void ttysane()
  944. + {
  945. + #ifdef    USG
  946. +     (void)ioctl(0, TCSETA, &strm);
  947. + #endif
  948. + #ifdef    BSD
  949. +     (void)ioctl(0, TIOCSETP, &strm);
  950. + #endif
  951.   }
  952.   
  953.   void ttyreinit()
  954.  
  955. *** ../old/tty.h Sat Mar 31 01:19:12 1990
  956. --- tty.h Sat Mar 31 01:19:12 1990
  957. **************
  958. *** 4,10
  959.    *    Copyright 1990 Scott Reynolds
  960.    *    All rights reserved.
  961.    *
  962. !  *    @(#) tty.h 1.5
  963.    *
  964.    *    tty.h - function definitions for tty i/o
  965.    **********************************************************************/
  966. --- 4,10 -----
  967.    *    Copyright 1990 Scott Reynolds
  968.    *    All rights reserved.
  969.    *
  970. !  *    @(#) tty.h 1.6
  971.    *
  972.    *    tty.h - function definitions for tty i/o
  973.    **********************************************************************/
  974. **************
  975. *** 15,20
  976.   void    ttback();
  977.   void    putwrap();
  978.   void    ttyinit();
  979.   void    ttyreinit();
  980.   void    ttyexit();
  981.   void    initscr();
  982. --- 15,21 -----
  983.   void    ttback();
  984.   void    putwrap();
  985.   void    ttyinit();
  986. + void    ttysane();
  987.   void    ttyreinit();
  988.   void    ttyexit();
  989.   void    initscr();
  990. -- 
  991. Scott Reynolds            =    "You just gotta _know_."
  992. Enterprise Information System    =            -anon
  993. scott@clmqt.marquette.Mi.US    ..rutgers!mailrus!sharkey!clmqt!scott
  994.