home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume6 / elm / part06 < prev    next >
Text File  |  1986-11-30  |  59KB  |  2,011 lines

  1. Subject: v06i031:  Elm mail system (elm), Part06/14
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.UUCP
  4.  
  5. Submitted by: Dave Taylor <pyramid!hplabs!hpldat!taylor>
  6. Mod.sources: Volume 6, Issue 31
  7. Archive-name: elm/Part06
  8.  
  9. # Continuation of Shell Archive, created by hpldat!taylor
  10.  
  11. # This is part 6
  12.  
  13. # To unpack the enclosed files, please use this file as input to the
  14. # Bourne (sh) shell.  This can be most easily done by the command;
  15. #     sh < thisfilename
  16.  
  17.  
  18. if [ ! -d src ]
  19. then
  20.   echo creating directory src
  21.   mkdir src
  22. fi
  23.  
  24. # ---------- file src/read_rc.c ----------
  25.  
  26. filename="src/read_rc.c"
  27.  
  28. if [ -f $filename ]
  29. then
  30.   echo File \"$filename\" already exists\!  Skipping...
  31.   filename=/dev/null        # throw it away
  32. else
  33.   echo extracting file src/read_rc.c...
  34. fi
  35.  
  36. cat << 'END-OF-FILE' > $filename
  37. /**            read_rc.c            **/
  38.  
  39. /** (C) Copyright 1985, Dave Taylor            **/
  40.  
  41. /** This file contains programs to allow the user to have a .elmrc file
  42.     in their home directory containing any of the following: 
  43.  
  44.     fullname= <username string>
  45.     maildir = <directory>
  46.     mailbox = <file>
  47.     editor  = <editor>
  48.     savemail= <savefile>
  49.     calendar= <calendar file name>
  50.     shell   = <shell>
  51.     print   = <print command>
  52.     weedout = <list of headers to weed out>
  53.     prefix  = <copied message prefix string>
  54.     pager   = <command to use for displaying messages>
  55.  
  56.     bounceback= <hop count threshold, or zero to disable>
  57.     timeout = <seconds for main menu timeout or zero to disable>
  58.  
  59.     sortby  = <sent, received, from, size, subject>
  60.  
  61.     alternatives = <list of addresses that forward to us>
  62.  
  63.     and/or the logical arguments:
  64.     
  65.     autocopy    [on|off]
  66.     copy        [on|off]    
  67.     resolve     [on|off]
  68.     weed        [on|off]
  69.     noheader    [on|off]
  70.     titles      [on|off]
  71.     editout     [on|off]
  72.     savebyname  [on|off]
  73.     movepage    [on|off]
  74.     pointnew    [on|off]
  75.     hpkeypad    [on|off]
  76.     hpsoftkeys  [on|off]
  77.     signature   [on|off]
  78.     alwaysleave [on|off]
  79.     alwaysdel   [on|off]
  80.     arrow        [on|off]
  81.  
  82.     Lines starting with '#' are considered comments and are not checked
  83.     any further!
  84.  
  85.     Modified 10/85 to know about "Environment" variables..
  86.     Modified 12/85 for the 'prefix' option
  87.     Modified  2/86 for the new 3.3 flags
  88. **/
  89.  
  90. #include <stdio.h>
  91. #include <ctype.h>
  92.  
  93. #ifdef BSD
  94. #undef tolower
  95. #endif
  96.  
  97. #include "headers.h"
  98.  
  99. char *shift_lower(), *strtok(), *getenv(), *malloc();
  100.  
  101. #define NOTWEEDOUT    0
  102. #define WEEDOUT        1
  103. #define ALTERNATIVES    2
  104.  
  105. read_rc_file()
  106. {
  107.     /** this routine does all the actual work of reading in the
  108.         .rc file... **/
  109.  
  110.     FILE *file;
  111.     char buffer[SLEN], filename[SLEN];
  112.     char word1[SLEN], word2[SLEN];
  113.     int  errors = 0, last = NOTWEEDOUT;
  114.  
  115.     sprintf(filename,"%s/%s", home, elmrcfile);
  116.  
  117.     default_weedlist();
  118.  
  119.     alternative_addresses = NULL;     /* none yet! */
  120.  
  121.     if ((file = fopen(filename, "r")) == NULL) {
  122.       dprint0(2,"Warning: User has no \".elmrc\" file (read_rc_file)\n");
  123.       return;    /* we're done! */
  124.     }
  125.  
  126.     while (fgets(buffer, SLEN, file) != NULL) {
  127.       no_ret(buffer);         /* remove return */
  128.       if (buffer[0] == '#') {     /* comment       */
  129.         last = NOTWEEDOUT;
  130.         continue;
  131.       }
  132.       if (strlen(buffer) < 2) {    /* empty line    */
  133.         last = NOTWEEDOUT;
  134.         continue;
  135.       }
  136.  
  137.       breakup(buffer, word1, word2);
  138.  
  139.       strcpy(word1, shift_lower(word1));    /* to lower case */
  140.  
  141.       if (word2[0] == 0 && (last != WEEDOUT || last != ALTERNATIVES)) {
  142.         dprint1(2,"Error: Bad .elmrc entry in users file;\n-> \"%s\"\n",
  143.              buffer);
  144.         fprintf(stderr, "Badly formed line in \".elmrc\": %s\n", buffer);
  145.         errors++;
  146.         continue;
  147.       }
  148.     
  149.       if (equal(word1,"maildir") || equal(word1,"folders")) {
  150.         expand_env(folders, word2);
  151.         last = NOTWEEDOUT;
  152.       }
  153.       else if (equal(word1, "fullname") || equal(word1,"username") ||
  154.            equal(word1, "name")) {
  155.         strcpy(full_username, word2);
  156.         last = NOTWEEDOUT;
  157.       }
  158.       else if (equal(word1, "prefix")) {
  159.         strcpy(prefixchars, word2);
  160.         last = NOTWEEDOUT;
  161.       }
  162.       else if (equal(word1, "shell")) {
  163.         expand_env(shell, word2);
  164.         last = NOTWEEDOUT;
  165.       }
  166.       else if (equal(word1, "sort") || equal(word1, "sortby")) {
  167.         strcpy(word2, shift_lower(word2));
  168.         if (equal(word2, "sent"))
  169.            sortby = SENT_DATE;
  170.         else if (equal(word2, "received") || equal(word2,"recieved"))
  171.            sortby = RECEIVED_DATE;
  172.         else if (equal(word2, "from") || equal(word2, "sender"))
  173.            sortby = SENDER;
  174.         else if (equal(word2, "size") || equal(word2, "lines"))
  175.           sortby = SIZE;
  176.         else if (equal(word2, "subject"))
  177.           sortby = SUBJECT;
  178.         else if (equal(word2, "reverse-sent") || equal(word2,"rev-sent"))
  179.            sortby = - SENT_DATE;
  180.         else if (strncmp(word2, "reverse-rec",11) == 0 || 
  181.              strncmp(word2,"rev-rec",7) == 0)
  182.            sortby = - RECEIVED_DATE;
  183.         else if (equal(word2, "reverse-from") || equal(word2, "rev-from")
  184.               || equal(word2,"reverse-sender")|| equal(word2,"rev-sender"))
  185.            sortby = - SENDER;
  186.         else if (equal(word2, "reverse-size") || equal(word2, "rev-size")
  187.               || equal(word2, "reverse-lines")|| equal(word2,"rev-lines"))
  188.           sortby = - SIZE;
  189.         else if (equal(word2, "reverse-subject") || 
  190.              equal(word2, "rev-subject"))
  191.           sortby = - SUBJECT;
  192.         else {
  193.          if (! errors)
  194.            printf("Error reading '.elmrc' file;\n");
  195.          printf("Don't know what sort key '%s' specifies!\n", word2);
  196.          errors++;
  197.          continue;
  198.        }
  199.       }
  200.       else if (equal(word1, "mailbox")) {
  201.         expand_env(mailbox, word2);
  202.         last = NOTWEEDOUT;
  203.       }
  204.       else if (equal(word1, "editor") || equal(word1,"mailedit")) {
  205.         expand_env(editor, word2);
  206.         last = NOTWEEDOUT;
  207.       }
  208.       else if (equal(word1, "savemail") || equal(word1, "saveto")) {
  209.         expand_env(savefile, word2);
  210.         last = NOTWEEDOUT;
  211.       }
  212.       else if (equal(word1, "calendar")) {
  213.         expand_env(calendar_file, word2);
  214.         last = NOTWEEDOUT;
  215.       }
  216.       else if (equal(word1, "print") || equal(word1, "printmail")) {
  217.         expand_env(printout, word2);
  218.         last = NOTWEEDOUT;
  219.       }
  220.       else if (equal(word1, "pager") || equal(word1, "page")) {
  221.         expand_env(pager, word2);
  222.         last = NOTWEEDOUT;
  223.       }
  224.       else if (equal(word1, "autocopy")) {
  225.         auto_copy = equal(shift_lower(word2), "on");
  226.         last = NOTWEEDOUT;
  227.       }
  228.       else if (equal(word1, "copy") || equal(word1, "auto_cc")) {
  229.         auto_cc = equal(shift_lower(word2), "on");
  230.         last = NOTWEEDOUT;
  231.       }
  232.       else if (equal(word1, "resolve")) {
  233.         resolve_mode = equal(shift_lower(word2), "on");
  234.         last = NOTWEEDOUT;
  235.       }
  236.       else if (equal(word1, "weed")) {
  237.         filter = equal(shift_lower(word2), "on");
  238.         last = NOTWEEDOUT;
  239.       }
  240.       else if (equal(word1, "noheader")) {
  241.         noheader = equal(shift_lower(word2), "on");
  242.         last = NOTWEEDOUT;
  243.       }
  244.       else if (equal(word1, "titles")) {
  245.         title_messages = equal(shift_lower(word2), "on");
  246.         last = NOTWEEDOUT;
  247.       }
  248.       else if (equal(word1, "editout")) {
  249.         edit_outbound = equal(shift_lower(word2), "on");
  250.         last = NOTWEEDOUT;
  251.       }
  252.       else if (equal(word1, "savebyname") || equal(word1, "savename")) {
  253.         save_by_name = equal(shift_lower(word2), "on");
  254.         last = NOTWEEDOUT;
  255.       }
  256.       else if (equal(word1, "movepage") || equal(word1, "page") ||
  257.            equal(word1, "movewhenpaged")) {
  258.         move_when_paged = equal(shift_lower(word2), "on");
  259.         last = NOTWEEDOUT;
  260.       }
  261.       else if (equal(word1, "pointnew") || equal(word1, "pointtonew")) {
  262.         point_to_new = equal(shift_lower(word2), "on");
  263.         last = NOTWEEDOUT;
  264.       }
  265.       else if (equal(word1, "keypad") || equal(word1, "hpkeypad")) {
  266.         hp_terminal = equal(shift_lower(word2), "on");
  267.         last = NOTWEEDOUT;
  268.       }
  269.       else if (equal(word1, "softkeys") || equal(word1, "hpsoftkeys")) {
  270.         hp_softkeys = hp_terminal = equal(shift_lower(word2), "on");
  271.         last = NOTWEEDOUT;
  272.       }
  273.       else if (equal(word1, "signature")) {
  274.         signature = equal(shift_lower(word2), "on");
  275.         last = NOTWEEDOUT;
  276.       }
  277.       else if (equal(word1, "arrow")) {
  278.         arrow_cursor = equal(shift_lower(word2), "on");
  279.         last = NOTWEEDOUT;
  280.       }
  281.       else if (equal(word1, "alwaysleave") || equal(word1, "leave")) {
  282.         always_leave = equal(shift_lower(word2), "on");
  283.         last = NOTWEEDOUT;
  284.       }
  285.       else if (equal(word1, "alwaysdelete") || equal(word1, "delete")) {
  286.         always_del = equal(shift_lower(word2), "on");
  287.         last = NOTWEEDOUT;
  288.       }
  289.       else if (equal(word1, "bounce") || equal(word1, "bounceback")) {
  290.         bounceback = atoi(word2);
  291.         if (bounceback > MAX_HOPS) {
  292.           fprintf(stderr,
  293.     "Warning: bounceback is set to greater than %d (max-hops) - Ignored.\n",
  294.                MAX_HOPS);
  295.           bounceback = 0;
  296.         }
  297.         last = NOTWEEDOUT;
  298.       }
  299.       else if (equal(word1, "timeout")) {
  300.         timeout = atoi(word2);
  301.         if (timeout < 10) {
  302.           fprintf(stderr,
  303.        "Warning: timeout is set to less than 10 seconds - Ignored.\n");
  304.           timeout = 0;
  305.         }
  306.         last = NOTWEEDOUT;
  307.       }
  308.       else if (equal(word1, "weedout")) {
  309.         weedout(word2);
  310.         last = WEEDOUT;
  311.       }
  312.       else if (equal(word1, "alternatives")) {
  313.         alternatives(word2);
  314.         last = ALTERNATIVES;
  315.       }
  316.       else if (last == WEEDOUT)    /* could be multiple line weedout */
  317.         weedout(buffer);
  318.       else if (last == ALTERNATIVES)    /* multi-line addresses   */
  319.         alternatives(buffer);
  320.       else {
  321.         fprintf(stderr, "Unknown line from .rc file: %s\n", buffer);
  322.         errors++;
  323.       }
  324.     }
  325.  
  326.     if (errors) 
  327.       exit(errors);
  328. }
  329.     
  330. weedout(string)
  331. char *string;
  332. {
  333.     /** This routine is called with a list of headers to weed out.   **/
  334.  
  335.     char *strptr, *header, *cp, *wp;
  336.  
  337.     strptr = string;
  338.  
  339.     while ((header = strtok(strptr, "\t ,\"'")) != NULL) {
  340.       if (strlen(header) > 0) {
  341.         if ((weedlist[weedcount] = malloc(strlen(header) + 1)) == NULL) {
  342.           fprintf(stderr,
  343.               "Too many weed headers - out of memory!  Leaving...\n");
  344.           exit(1);
  345.         }
  346.         for (cp = header, wp = weedlist[weedcount]; *cp != '\0'; cp++)
  347.           *wp++ = (*cp == '_') ? ' ' : *cp;
  348.         weedcount++;
  349.       }
  350.       strptr = NULL;
  351.     }
  352. }
  353.  
  354. alternatives(string)
  355. char *string;
  356. {
  357.     /** This routine is called with a list of alternative addresses
  358.         that you may receive mail from (forwarded) **/
  359.  
  360.     char *strptr, *address;
  361.     struct addr_rec *current_record, *previous_record;
  362.  
  363.     previous_record = NULL;
  364.  
  365.     strptr = (char *) string;
  366.  
  367.     while ((address = strtok(strptr, "\t ,\"'")) != NULL) {
  368.       if (previous_record == NULL) {
  369.         previous_record = (struct addr_rec *) 
  370.                    malloc(sizeof *alternative_addresses);
  371.  
  372.         strcpy(previous_record->address, address);
  373.         previous_record->next = NULL;
  374.         alternative_addresses = previous_record;
  375.       }
  376.       else {
  377.         current_record = (struct addr_rec *) 
  378.                    malloc(sizeof *alternative_addresses);
  379.       
  380.         strcpy(current_record->address, address);
  381.         current_record->next = NULL;
  382.         previous_record->next = current_record;
  383.         previous_record = current_record;
  384.       }
  385.       strptr = (char *) NULL;
  386.     }
  387. }
  388.  
  389. default_weedlist()
  390. {
  391.     /** Install the default headers to weed out!  Many gracious 
  392.         thanks to John Lebovitz for this dynamic method of 
  393.         allocation!
  394.     **/
  395.  
  396.     static char *default_list[] = { ">From", "In-Reply-To:",
  397.                "References:", "Newsgroups:", "Received:",
  398.                "Apparently-To:", "Message-Id:", NULL
  399.              };
  400.  
  401.     for (weedcount = 0; default_list[weedcount] != NULL; weedcount++) {
  402.       if ((weedlist[weedcount] = 
  403.           malloc(strlen(default_list[weedcount]) + 1)) == NULL) {
  404.         fprintf(stderr, 
  405.            "\n\rNot enough memory for default weedlist.  Leaving.\n\r");
  406.         leave(1);
  407.       }
  408.       strcpy(weedlist[weedcount], default_list[weedcount]);
  409.     }
  410. }
  411.  
  412. int
  413. matches_weedlist(buffer)
  414. char *buffer;
  415. {
  416.     /** returns true iff the first 'n' characters of 'buffer' 
  417.         match an entry of the weedlist **/
  418.     
  419.     register int i;
  420.  
  421.     for (i=0;i < weedcount; i++)
  422.       if (strncmp(buffer, weedlist[i], strlen(weedlist[i])) == 0) 
  423.         return(1);
  424.  
  425.     return(0);
  426. }
  427.  
  428. breakup(buffer, word1, word2)
  429. char *buffer, *word1, *word2;
  430. {
  431.     /** This routine breaks buffer down into word1, word2 where 
  432.         word1 is alpha characters only, and there is an equal
  433.         sign delimiting the two...
  434.         alpha = beta
  435.         For lines with more than one 'rhs', word2 is set to the
  436.         entire string...
  437.     **/
  438.  
  439.     register int i;
  440.     
  441.     for (i=0;i<strlen(buffer) && isalpha(buffer[i]); i++)
  442.       word1[i] = buffer[i];
  443.  
  444.     word1[i++] = '\0';    /* that's the first word! */
  445.  
  446.     /** spaces before equal sign? **/
  447.  
  448.     while (buffer[i] == ' ' || buffer[i] == '\t') i++;
  449.  
  450.     if (buffer[i] == '=') i++;
  451.  
  452.     /** spaces after equal sign? **/
  453.  
  454.     while (buffer[i] == ' ' || buffer[i] == '\t') i++;
  455.  
  456.     if (i < strlen(buffer))
  457.       strcpy(word2, (char *) (buffer + i));
  458.     else
  459.       word2[0] = '\0';
  460. }
  461.  
  462. expand_env(dest, buffer)
  463. char *dest, *buffer;
  464. {
  465.     /** expand possible metacharacters in buffer and then copy
  466.         to dest... 
  467.         This routine knows about "~" being the home directory,
  468.         and "$xxx" being an environment variable.
  469.     **/
  470.  
  471.     char  *word, *string, next_word[SLEN];
  472.     
  473.     if (buffer[0] == '/') {
  474.       dest[0] = '/';
  475.       dest[1] = '\0';
  476.     }
  477.     else
  478.       dest[0] = '\0';
  479.     string = (char *) buffer;
  480.  
  481.     while ((word = strtok(string, "/")) != NULL) {
  482.       if (word[0] == '$') {
  483. #ifdef SUN
  484.         next_word[0] = '\0';
  485.         if (getenv((char *) (word + 1)) != NULL)
  486. #endif
  487.         strcpy(next_word, getenv((char *) (word + 1)));
  488.         if (strlen(next_word) == 0)
  489.           leave(fprintf(stderr, 
  490.             "\n\rCan't expand environment variable '%s'\n\r",
  491.             word));
  492.       }
  493.       else if (word[0] == '~' && word[1] == '\0')
  494.         strcpy(next_word, home);
  495.       else
  496.         strcpy(next_word, word);
  497.  
  498.       sprintf(dest, "%s%s%s", dest, (strlen(dest) > 0? "/":""),
  499.                   next_word);
  500.  
  501.       string = (char *) NULL;
  502.     }
  503. }
  504. END-OF-FILE
  505.  
  506. if [ "$filename" != "/dev/null" ]
  507. then
  508.   size=`wc -c < $filename`
  509.  
  510.   if [ $size != 12722 ]
  511.   then
  512.     echo $filename changed - should be 12722 bytes, not $size bytes
  513.   fi
  514.  
  515.   chmod 644 $filename
  516. fi
  517.  
  518. # ---------- file src/hdrconfg.c ----------
  519.  
  520. filename="src/hdrconfg.c"
  521.  
  522. if [ -f $filename ]
  523. then
  524.   echo File \"$filename\" already exists\!  Skipping...
  525.   filename=/dev/null        # throw it away
  526. else
  527.   echo extracting file src/hdrconfg.c...
  528. fi
  529.  
  530. cat << 'END-OF-FILE' > $filename
  531.  
  532. /**            hdrconfg.c            **/
  533.  
  534. /**   This file contains the routines necessary to be able to modify
  535.       the mail headers of messages on the way off the machine.  The
  536.       headers currently supported for modification are:
  537.  
  538.     Subject:
  539.     To:
  540.     Cc:
  541.     Reply-To:
  542.  
  543.     Expiration-Date:
  544.     Priority:
  545.         In-Reply-To:
  546.     Action:
  547.     Security:
  548.     
  549.       (C) Copyright 1985, Dave Taylor
  550. **/
  551.  
  552. #include <stdio.h>
  553. #include "headers.h"
  554.  
  555. #include <ctype.h>
  556.  
  557. #ifdef BSD
  558. #undef toupper
  559. #endif
  560.  
  561. /* these are all defined in the mailout file! */
  562.  
  563. extern char subject[SLEN], action[SLEN], in_reply_to[SLEN], expires[SLEN], 
  564.         priority[SLEN], reply_to[SLEN];
  565. extern char to[VERY_LONG_STRING], cc[VERY_LONG_STRING];
  566.  
  567. edit_headers()
  568. {
  569.     /** Edit headers.  **/
  570.  
  571.     int unexpanded_to = TRUE, unexpanded_cc = TRUE;
  572.     char c, expanded_to[VERY_LONG_STRING], expanded_cc[VERY_LONG_STRING];
  573.     
  574.     if (mail_only) goto outta_here;        /* how did we get HERE??? */
  575.  
  576. #ifdef INTERNET_ADDRESS_FORMAT
  577. # ifdef DOMAINS
  578.     sprintf(reply_to, "%s <%s@%s%s>", full_username,
  579.         username, hostname, DOMAIN);
  580. # else
  581.     sprintf(reply_to, "%s <%s@%s>", full_username,
  582.         username, hostname);
  583. # endif
  584. #else
  585.     sprintf(reply_to, "%s <%s!%s>", full_username,
  586.         hostname, username);
  587. #endif
  588.  
  589.     display_headers();
  590.  
  591.     do {
  592.       PutLine0(LINES-1,0,"Choice: ");
  593.       CleartoEOLN();
  594.       c = toupper(getchar());
  595.       clear_error();
  596.       switch (c) {
  597.         case ctrl('M'):
  598.         case 'Q' : goto outta_here;
  599.         case ctrl('L') : display_headers();
  600.                break;
  601.         case 'T' : if (optionally_enter(to, 2, 9, TRUE) == -1)
  602.                      goto outta_here;
  603.                    build_address(strip_commas(to), expanded_to);
  604.                unexpanded_to = FALSE; 
  605.                break;
  606.         case 'S' : if (optionally_enter(subject, 4, 9, FALSE) == -1)
  607.              goto outta_here;
  608.                break;
  609.         case 'C' : if (optionally_enter(cc, 5, 9, TRUE) == -1)
  610.              goto outta_here;
  611.                  build_address(strip_commas(cc), expanded_cc);
  612.                unexpanded_cc = FALSE;
  613.                break;
  614.         case 'R' : if (optionally_enter(reply_to, 7, 11, FALSE) == -1)
  615.              goto outta_here;
  616.                break;
  617.         case 'A' : if (optionally_enter(action, 8, 9, FALSE) == -1)
  618.              goto outta_here;
  619.                break;
  620.         case 'E' : enter_date(9, 17, expires);
  621.                break;
  622.         case 'P' : if (optionally_enter(priority, 10,10, FALSE) == -1)
  623.              goto outta_here;
  624.                break;
  625.         case 'I' : if (strlen(in_reply_to > 0)) {
  626.                      if (optionally_enter(in_reply_to, 11,13, FALSE) == -1)
  627.                goto outta_here;
  628.              break;        
  629.                }
  630.                /** else fall through as an error **/
  631.         default  : error("Unknown header being specified!");
  632.       }
  633.     } while (TRUE);
  634.  
  635. outta_here:    /* this section re-expands aliases before we leave... */
  636.  
  637.     if (unexpanded_to)
  638.       build_address(strip_commas(to), expanded_to);
  639.     if (unexpanded_cc)
  640.       build_address(strip_commas(cc), expanded_cc);
  641.  
  642.     strcpy(to, expanded_to);
  643.     strcpy(cc, expanded_cc);
  644. }
  645.  
  646. display_headers()
  647. {
  648.     ClearScreen();
  649.  
  650.     Centerline(0,"Message Header Edit Screen");
  651.  
  652.     PutLine1(2,0,"To     : %s", to);
  653.     PutLine1(4,0,"Subject: %s", subject);
  654.     PutLine1(5,0,"Cc     : %s", cc);
  655.     PutLine1(7,0,"Reply-To: %s", reply_to);
  656.     PutLine1(8,0,"Action : %s", action);
  657.     PutLine1(9,0,"Expiration-Date: %s", expires);
  658.     PutLine1(10,0,"Priority: %s", priority);
  659.     if (strlen(in_reply_to) > 0)
  660.       PutLine1(11,0,"In-Reply-To: %s", in_reply_to);
  661.  
  662.     Centerline(LINES-5, 
  663.     "Choose First Letter of Header or <return> from Editing Headers");
  664. }
  665.  
  666. enter_date(x, y, buffer)
  667. int x, y;
  668. char *buffer;
  669. {
  670.     /** Enter the number of days this message is valid for, then
  671.         display at (x,y) the actual date of expiration.  This 
  672.         routine relies heavily on the routine 'days_ahead()' in
  673.         the file date.c
  674.     **/
  675.  
  676.     int days;
  677.  
  678.     PutLine0(LINES-1,0, "How many days in the future should it expire? ");
  679.     CleartoEOLN();
  680.     Raw(OFF);
  681.     gets(buffer, SLEN);
  682.     Raw(ON);
  683.     sscanf(buffer, "%d", &days);
  684.     if (days < 1)
  685.       error("That doesn't make sense!");
  686.     else if (days > 14)
  687.       error("Expiration date must be within two weeks of today");
  688.     else {
  689.       days_ahead(days, buffer);
  690.       PutLine0(x, y, buffer);
  691.     }
  692. }
  693. END-OF-FILE
  694.  
  695. if [ "$filename" != "/dev/null" ]
  696. then
  697.   size=`wc -c < $filename`
  698.  
  699.   if [ $size != 4054 ]
  700.   then
  701.     echo $filename changed - should be 4054 bytes, not $size bytes
  702.   fi
  703.  
  704.   chmod 644 $filename
  705. fi
  706.  
  707. # ---------- file src/help.c ----------
  708.  
  709. filename="src/help.c"
  710.  
  711. if [ -f $filename ]
  712. then
  713.   echo File \"$filename\" already exists\!  Skipping...
  714.   filename=/dev/null        # throw it away
  715. else
  716.   echo extracting file src/help.c...
  717. fi
  718.  
  719. cat << 'END-OF-FILE' > $filename
  720. /**            help.c            **/
  721.  
  722. /*** help routine for ELM program 
  723.  
  724.      (C) Copyright 1985, Dave Taylor
  725.  
  726. ***/
  727.  
  728. #include <ctype.h>
  729. #include "headers.h"
  730.  
  731. help()
  732. {
  733.     /** Process the top-level request for help from the user **/
  734.  
  735.     char ch;        /* character buffer for input */
  736.     char *s;        /* string pointer...          */
  737.  
  738.     MoveCursor(LINES-7,0);
  739.     CleartoEOS();
  740.  
  741.     Centerline(LINES-7, "ELM Help System");
  742.     Centerline(LINES-5,
  743.            "Press keys you want help for, '?' for a list, or '.' to end");
  744.  
  745.     PutLine0(LINES-3, 0, "Help on key: ");
  746.  
  747.     do {
  748.       MoveCursor(LINES-3, strlen("Help on key: "));
  749.       ch = tolower(ReadCh());
  750.       
  751.       if (ch == '.') return(0);    /* zero means footer rewrite only */
  752.  
  753.       s = "Unknown command.  Use '?' for a list of commands...";
  754.  
  755.       switch (ch) {
  756.  
  757.         case '?': display_helpfile();    return(1);
  758.  
  759.         case '!': s = 
  760.    "! = Escape to the Unix shell of your choice, or just to enter commands";
  761.            break;
  762.         case '@': s = 
  763.        "@ = Debug - display a summary of the notes on the header page";
  764.            break;
  765.         case '|': s = 
  766.  "| = Pipe the current message or tagged messages to the command specified";
  767.            break;
  768.         case '#': s = 
  769.       "# = Debug - display all information known about current message";
  770.           break;
  771.         case '%': s = 
  772.    "% = Debug - display the computed return address of the current message";
  773.            break;
  774.         case '*': s = "* = Go to the last message in the current mailbox";
  775.            break;
  776.         case '-': s = 
  777.            "- = Go to the previous page of messages in the current mailbox";
  778.            break;
  779.         case '=': s = 
  780.                   "'=' = Go to the first message in the current mailbox";
  781.            break;
  782.         case ' ': 
  783.         case '+': s = 
  784.         "+ = Go to the next page of messages in the current mailbox";
  785.            break;
  786.         case '/': s = "/ = Search for specified pattern in mailbox";
  787.            break;
  788.         case '<': s = 
  789.            "< = Scan current message for calendar entries (if enabled)";
  790.            break;
  791.         case '>': s = 
  792.            "> = Save current message or tagged messages to specified file";
  793.            break;
  794.         case '^': s = 
  795.            "^ = Toggle the Delete/Undelete status of the current message";
  796.            break;
  797.         case 'a': s = 
  798.        "a = Enter the alias sub-menu section.  Create and display aliases";
  799.            break;
  800.         case 'b': s = 
  801.     "b = Bounce (remail) a message to someone as if you have never seen it";
  802.            break;
  803.         case 'c': s = 
  804.        "c = Change mailboxes, leaving the current mailbox as if 'quitting'";
  805.            break;
  806.         case 'd': s = "d = Mark the current message for future deletion";
  807.            break;
  808.         case 'e': s = 
  809.        "e = Invoke the editor on the entire mailbox, resync'ing when done";
  810.            break;
  811.         case 'f': s = 
  812.       "f = Forward the current message to someone, return address is yours";
  813.            break;
  814.         case 'g': s = 
  815.  "g = Group reply not only to the sender, but to everyone who received msg";
  816.            break;
  817.         case 'h': s = 
  818.            "h = Display message with all Headers (ignore weedout list)";
  819.            break;
  820.         case 'j': s = 
  821.        "j = Go to the next message.  This is the same as the DOWN arrow";
  822.            break;
  823.         case 'k': s = 
  824.        "k = Go to the previous message.  This is the same as the UP arrow";
  825.            break;
  826.         case 'm': s = 
  827.                "m = Create and send mail to the specified person or persons";
  828.            break;
  829.         case 'n': s = 
  830.                "n = Read the current message, then move current to next messge";
  831.            break;
  832.         case 'o': s = "o = Go to the options submenu";
  833.            break;
  834.         case 'p': s = 
  835.         "p = Print the current message or the tagged messages";
  836.            break;
  837.         case 'q': s = 
  838.         "q = Quit the mailer, asking about deletion, saving, etc";
  839.            break;
  840.         case 'r': s = 
  841.   "r = Reply to the message.  This only sends to the originator of the message";
  842.            break;
  843.         case 's': s = 
  844.                "s = Save current message or tagged messages to specified file";
  845.            break;
  846.         case 't': s = 
  847.                "t = Tag a message for further operations (or untag if tagged)";
  848.            break;
  849.         case 'u': s = "u = Undelete - remove the deletion mark on the message";
  850.            break;
  851.         case 'x': s = "x = Exit the mail system quickly";
  852.            break;
  853.         
  854.         case '\n':
  855.         case '\r': s = "<return> = Read the current message";
  856.            break;
  857.     
  858.         case ctrl('L'): s = "^L = Rewrite the screen";    
  859.            break;
  860.             case ctrl('?'):                        /* DEL */
  861.         case ctrl('Q'): s = "Exit the mail system quickly";
  862.            break;
  863.         default : if (isdigit(ch)) 
  864.                 s = "<number> = Make specified number the current message";
  865.       }
  866.  
  867.       ClearLine(LINES-1);
  868.       Centerline(LINES-1, s);
  869.  
  870.     } while (ch != '.');
  871.     
  872.     /** we'll never actually get here, but that's okay... **/
  873.  
  874.     return(0);
  875. }
  876.  
  877. display_helpfile()
  878. {
  879.     /*** Help me!  Read file 'helpfile' and echo to screen ***/
  880.  
  881.     FILE *hfile;
  882.     char buffer[SLEN];
  883.     int  lines=0;
  884.  
  885.     sprintf(buffer, "%s/%s", helphome, helpfile);
  886.     if ((hfile = fopen(buffer,"r")) == NULL) {
  887.       dprint1(1,"Error: Couldn't open helpfile %s (help)\n", buffer);
  888.       error1("couldn't open helpfile %s",buffer);
  889.       return(FALSE);
  890.     }
  891.     
  892.     ClearScreen();
  893.  
  894.     while (fgets(buffer, SLEN, hfile) != NULL) {
  895.       if (lines > LINES-3) {
  896.         PutLine0(LINES,0,"Press any key to continue: ");
  897.         (void) ReadCh();
  898.         lines = 0;
  899.         ClearScreen();
  900.         Write_to_screen("%s\r", 1, buffer);
  901.       }
  902.       else 
  903.         Write_to_screen("%s\r", 1, buffer);
  904.  
  905.       lines++;
  906.     }
  907.  
  908.         PutLine0(LINES,0,"Press any key to return: ");
  909.  
  910.     (void) ReadCh();
  911.     clear_error();
  912.  
  913.     return(TRUE);
  914. }
  915. END-OF-FILE
  916.  
  917. if [ "$filename" != "/dev/null" ]
  918. then
  919.   size=`wc -c < $filename`
  920.  
  921.   if [ $size != 5576 ]
  922.   then
  923.     echo $filename changed - should be 5576 bytes, not $size bytes
  924.   fi
  925.  
  926.   chmod 644 $filename
  927. fi
  928.  
  929. # ---------- file src/initialize.c ----------
  930.  
  931. filename="src/initialize.c"
  932.  
  933. if [ -f $filename ]
  934. then
  935.   echo File \"$filename\" already exists\!  Skipping...
  936.   filename=/dev/null        # throw it away
  937. else
  938.   echo extracting file src/initialize.c...
  939. fi
  940.  
  941. cat << 'END-OF-FILE' > $filename
  942. /**        initialize.c        **/
  943.  
  944. /***** Initialize - read in all the defaults etc etc 
  945.        (C) Copyright 1985 Dave Taylor
  946. *****/
  947.  
  948. #include "headers.h"
  949.  
  950. #ifdef BSD
  951. #  include <sgtty.h>
  952. #else
  953. #  include <termio.h>
  954. #endif
  955.  
  956. #include <pwd.h>
  957.  
  958. #ifdef BSD
  959. #  include <sys/time.h>
  960. #else
  961. #  include <time.h>
  962. #endif
  963.  
  964. #include <signal.h>
  965. #include <ctype.h>
  966. #include <errno.h>
  967.  
  968. #ifdef BSD
  969. #undef tolower
  970. #endif
  971.  
  972.  
  973. extern int errno;        /* system error number on failure */
  974.  
  975. char *error_name(), *error_description();
  976.  
  977. char *expand_logname(), *getenv(), *getlogin();
  978.  
  979. initialize(initscreen_too)
  980. int initscreen_too;
  981. {
  982.     /** initialize the whole ball of wax.   If "initscreen_too" then
  983.         call init_screen where appropriate..
  984.     **/
  985.     struct passwd *pass, *getpwnam();
  986.  
  987.     register int i;
  988.     int      quit_signal(), term_signal(), ill_signal(),
  989.          fpe_signal(),  bus_signal(),  segv_signal(),
  990.              alarm_signal(), pipe_signal();
  991.     char     buffer[SLEN], *cp;
  992.     
  993.     userid  = getuid();
  994.     groupid = getgid();    
  995.  
  996.     strcpy(home,((cp = getenv("HOME")) == NULL)? "" : cp);
  997.     strcpy(shell,((cp = getenv("SHELL")) == NULL)? "" : cp);
  998.     strcpy(pager,((cp = getenv("PAGER")) == NULL)? default_pager : cp);
  999.  
  1000.     if (debug) {        /* setup for dprintf statements! */
  1001.       char filename[SLEN];
  1002.       sprintf(filename, "%s/%s", home, DEBUG);
  1003.       if ((debugfile = fopen(filename, "w")) == NULL) {
  1004.         debug = 0;    /* otherwise 'leave' will try to log! */
  1005.         leave(fprintf(stderr,"Could not open file %s for debug output!\n",
  1006.           filename));
  1007.       }
  1008.       chown(filename, userid, groupid); /* file owned by user */
  1009.  
  1010.       fprintf(debugfile, "Debug output of the ELM program.  Version %s\n\n",
  1011.           VERSION);
  1012.     }
  1013.  
  1014.     if (initscreen_too)    /* don't set up unless we need to! */
  1015.       InitScreen();
  1016.  
  1017.     signal(SIGINT,  SIG_IGN);
  1018.     signal(SIGQUIT, quit_signal);        /* Quit signal                 */
  1019.     signal(SIGTERM, term_signal);         /* Terminate signal         */
  1020.     signal(SIGILL,  ill_signal);        /* Illegal instruction      */
  1021.     signal(SIGFPE,  fpe_signal);        /* Floating point exception */
  1022.     signal(SIGBUS,  bus_signal);        /* Bus error              */
  1023.     signal(SIGSEGV, segv_signal);        /* Segmentation Violation   */
  1024.     signal(SIGALRM, alarm_signal);        /* Process Timer Alarm        */
  1025.     signal(SIGPIPE, pipe_signal);        /* Illegal Pipe Operation   */
  1026.  
  1027.     get_connections();          /* who do we talk to directly?? */
  1028.  
  1029.     open_domain_file();        /* if we got it, we want it!  */
  1030.  
  1031.     get_term_chars();
  1032.     
  1033.     gethostname(hostname, sizeof(hostname));
  1034.     if ((cp = getlogin()) == NULL)
  1035.       cuserid(username);
  1036.     else
  1037.       strcpy(username, cp);
  1038.  
  1039.     /* now let's get the full username.. */
  1040.  
  1041.     if ((pass = getpwnam(username)) == NULL) {
  1042.       error("Couldn't read password entry??");
  1043.       strcpy(full_username, username);
  1044.     }
  1045.     else {
  1046.       for (i=0; pass->pw_gecos[i] != '\0' && pass->pw_gecos[i] != ',';
  1047.            i++)
  1048.           if (pass->pw_gecos[i] == '&') {
  1049.             full_username[i] = '\0';
  1050.             strcat(full_username, expand_logname());
  1051.             i = strlen(full_username) - 2;
  1052.           }
  1053.           else
  1054.             full_username[i] = pass->pw_gecos[i];
  1055.       full_username[i] = '\0'; 
  1056.     }
  1057.  
  1058.     if ((cp = getenv("EDITOR")) == NULL)
  1059.       strcpy(editor,default_editor);
  1060.     else
  1061.       strcpy(editor, cp);
  1062.  
  1063.     if (! mail_only) {
  1064.       mailbox[0] = '\0';
  1065.       strcpy(prefixchars, "> ");     /* default message prefix */
  1066.     }
  1067.  
  1068.     /* get the default calendar file name loaded... */
  1069.  
  1070.     sprintf(calendar_file, "%s/%s", home, dflt_calendar_file);
  1071.  
  1072.     read_rc_file();        /* reading the .elmrc next... */
  1073.  
  1074.     /** now try to expand the specified filename... **/
  1075.  
  1076.     if (strlen(infile) > 0) {
  1077.       (void) expand_filename(infile);
  1078.       if ((errno = can_access(infile, READ_ACCESS))) {
  1079.         dprint2(1,"Error: given file %s as mailbox - unreadable (%s)!\n", 
  1080.              infile, error_name(errno));
  1081.         fprintf(stderr,"Can't open mailbox '%s' for reading!\n", infile);
  1082.         exit(1);
  1083.       }
  1084.     }
  1085.  
  1086.     /** check to see if the user has defined a LINES or COLUMNS
  1087.         value different to that in the termcap entry (for
  1088.         windowing systems, of course!) **/
  1089.  
  1090.     if ((cp = getenv("LINES")) != NULL && isdigit(*cp)) {
  1091.       sscanf(cp, "%d", &LINES);
  1092.       LINES -= 1;    /* kludge for HP Window system? ... */
  1093.     }
  1094.  
  1095.     if ((cp = getenv("COLUMNS")) != NULL && isdigit(*cp))
  1096.       sscanf(cp, "%d", &COLUMNS);
  1097.  
  1098.     /** fix the shell if needed **/
  1099.  
  1100.     if (shell[0] != '/') {
  1101.        sprintf(buffer, "/bin/%s", shell);
  1102.        strcpy(shell, buffer);
  1103.     }
  1104.  
  1105.     if (! mail_only) {
  1106.       mailbox_defined = (mailbox[0] != '\0'); 
  1107.  
  1108.       /* get the cursor control keys... */
  1109.  
  1110.       if ((cp = return_value_of("ku")) == NULL || strlen(cp) != 2)
  1111.         cursor_control = FALSE;
  1112.       else {
  1113.         strcpy(up, cp);
  1114.         if ((cp = return_value_of("kd")) == NULL || strlen(cp) != 2)
  1115.           cursor_control = FALSE;
  1116.         else {
  1117.           strcpy(down, cp);
  1118.           cursor_control = TRUE;
  1119.           transmit_functions(ON);
  1120.         }
  1121.       }
  1122.  
  1123.       strcpy(start_highlight, "->");
  1124.       end_highlight[0] = '\0';
  1125.  
  1126.       if (!arrow_cursor) {    /* try to use inverse bar instead */
  1127.         if ((cp = return_value_of("so")) != NULL) {
  1128.           strcpy(start_highlight, cp);
  1129.           if ((cp = return_value_of("se")) == NULL)
  1130.             strcpy(start_highlight, "->");
  1131.           else {
  1132.             strcpy(end_highlight, cp);
  1133.             has_highlighting = TRUE;
  1134.           }
  1135.         }
  1136.       }
  1137.     }
  1138.  
  1139.     if (read_aliases)
  1140.         read_alias_files();
  1141.  
  1142.     if (! mail_only) {
  1143.       if (mini_menu)
  1144.         headers_per_page = LINES - 13;
  1145.       else
  1146.         headers_per_page = LINES -  8;    /* 5 more headers! */
  1147.  
  1148.       newmbox(1,FALSE, TRUE);    /* read in the mailbox! */
  1149.     }
  1150.  
  1151.     init_findnode();    /* set up the path alias stuff */
  1152.  
  1153.     dprint0(2,"\n-- end of initialization phase --\n");
  1154.  
  1155.     dprint3(2,"\thostname = %s\n\tusername = %s\n\tfull_username = \"%s\"\n",
  1156.              hostname, username, full_username);
  1157.  
  1158.     dprint3(2,"\thome = %s\n\teditor = %s\n\tmailbox = %s\n",
  1159.          home, editor, mailbox);
  1160.  
  1161.     dprint3(2,"\tinfile = %s\n\tfolder-dir = %s\n\tprintout = \"%s\"\n",
  1162.          infile, folders, printout);
  1163.     
  1164.     dprint3(2,"\tsavefile = %s\n\tprefix = \"%s\"\n\tshell = %s\n",
  1165.         savefile, prefixchars, shell);
  1166.     
  1167.     dprint0(1,"-- beginning execution phase --\n\n");
  1168. }
  1169.  
  1170. get_term_chars()
  1171. {
  1172.     /** This routine sucks out the special terminal characters
  1173.         ERASE and KILL for use in the input routine.  The meaning 
  1174.             of the characters are (dare I say it?) fairly obvious... **/
  1175.  
  1176. #ifdef BSD
  1177.     struct sgttyb term_buffer;
  1178.  
  1179. # define TCGETA    TIOCGETP
  1180.  
  1181. #else 
  1182.     struct termio term_buffer;
  1183. #endif
  1184.  
  1185.     if (ioctl(STANDARD_INPUT, TCGETA, &term_buffer) == -1) {
  1186.       dprint1(1,"Error: %s encountered on ioctl call (get_term_chars)\n", 
  1187.            error_name(errno));
  1188.       /* set to defaults for terminal driver */
  1189.       backspace = BACKSPACE;
  1190.       kill_line = ctrl('U');
  1191.     }
  1192.     else {
  1193. #ifdef BSD
  1194.       backspace = term_buffer.sg_erase;
  1195.       kill_line = term_buffer.sg_kill;
  1196. #else
  1197.       backspace = term_buffer.c_cc[VERASE];
  1198.       kill_line = term_buffer.c_cc[VKILL];
  1199. #endif
  1200.     }
  1201. }
  1202.  
  1203. char *expand_logname()
  1204. {
  1205.     /** Return logname in a nice format (for expanding "&" in the
  1206.         /etc/passwd file) **/
  1207.  
  1208.     static char buffer[SLEN];
  1209.     register int i;
  1210.  
  1211.     if (strlen(username) == 0)
  1212.       buffer[0] = '\0';
  1213.     else {
  1214.       buffer[0] = toupper(username[0]);
  1215.  
  1216.       for (i=1; username[i] != '\0'; i++)
  1217.         buffer[i] = tolower(username[i]);
  1218.  
  1219.       buffer[i] = '\0';
  1220.     }
  1221.  
  1222.     return( (char *) buffer);    
  1223. }
  1224. END-OF-FILE
  1225.  
  1226. if [ "$filename" != "/dev/null" ]
  1227. then
  1228.   size=`wc -c < $filename`
  1229.  
  1230.   if [ $size != 7108 ]
  1231.   then
  1232.     echo $filename changed - should be 7108 bytes, not $size bytes
  1233.   fi
  1234.  
  1235.   chmod 644 $filename
  1236. fi
  1237.  
  1238. # ---------- file src/args.c ----------
  1239.  
  1240. filename="src/args.c"
  1241.  
  1242. if [ -f $filename ]
  1243. then
  1244.   echo File \"$filename\" already exists\!  Skipping...
  1245.   filename=/dev/null        # throw it away
  1246. else
  1247.   echo extracting file src/args.c...
  1248. fi
  1249.  
  1250. cat << 'END-OF-FILE' > $filename
  1251. /**            args.c            **/
  1252.  
  1253. /** starting argument parsing routines for ELM system...
  1254.  
  1255.     (C) Copyright 1986 Dave Taylor
  1256. **/
  1257.  
  1258. #include "headers.h"
  1259.  
  1260. #define DONE        0
  1261. #define ERROR        -1
  1262.  
  1263. extern char *optional_arg;        /* optional argument as we go */
  1264. extern int   opt_index;            /* argnum + 1 when we leave   */
  1265.  
  1266. parse_arguments(argc, argv, to_whom)
  1267. int argc;
  1268. char *argv[], *to_whom;
  1269. {
  1270.     /** set flags according to what was given to program.  If we are 
  1271.         fed a name or series of names, put them into the 'to_whom' buffer
  1272.         and set "mail_only" to TRUE **/
  1273.  
  1274.     register int c = 0, check_size = 0;
  1275.  
  1276.     infile[0] = '\0';
  1277.     to_whom[0] = '\0';
  1278.     batch_subject[0] = '\0';
  1279.  
  1280.     while ((c = get_options(argc, argv, "?acd:f:hkKms:z")) > 0) {
  1281.        switch (c) {
  1282.          case 'a' : arrow_cursor++;        break;
  1283.          case 'c' : check_only++;        break;
  1284.          case 'd' : debug = atoi(optional_arg);    break;
  1285.          case 'f' : strcpy(infile, optional_arg); 
  1286.                     mbox_specified = 2;  break;
  1287.          case '?' :
  1288.          case 'h' : args_help();
  1289.          case 'k' : hp_terminal++;    break;
  1290.          case 'K' : hp_terminal++; hp_softkeys++;    break;
  1291.          case 'm' : mini_menu = 0;    break;
  1292.          case 's' : strcpy(batch_subject, optional_arg);    break;
  1293.          case 'z' : check_size++;   break;
  1294.         }
  1295.      }
  1296.  
  1297.      if (c == ERROR) {
  1298.        printf(
  1299.         "Usage: %s [achkKmz] [-d level] [-f file] [-s subject] <names>\n\n",
  1300.          argv[0]);
  1301.        args_help();
  1302.     }
  1303.  
  1304.     if (opt_index < argc) {
  1305.       while (opt_index < argc) {
  1306.         sprintf(to_whom, "%s%s%s", to_whom, 
  1307.                 to_whom[0] != '\0'? " " : "", argv[opt_index]);
  1308.         mail_only++;
  1309.         opt_index++;
  1310.       }
  1311.       check_size = 0;    /* NEVER do this if we're mailing!! */
  1312.     }
  1313.  
  1314.      if (strlen(batch_subject) > 0 && ! mail_only) 
  1315.        exit(printf(
  1316.      "\n\rDon't understand specifying a subject and no-one to send to!\n\r"));
  1317.  
  1318.     if (!isatty(fileno(stdin)) && strlen(batch_subject) == 0 && !check_only)
  1319.       strcpy(batch_subject, DEFAULT_BATCH_SUBJECT);
  1320.  
  1321.     if (check_size)
  1322.       check_mailfile_size();
  1323. }
  1324.  
  1325. args_help()
  1326. {
  1327.     /**  print out possible starting arguments... **/
  1328.  
  1329.     printf("\nPossible Starting Arguments for ELM program:\n\n");
  1330.     printf("\targ\t\t\tMeaning\n");
  1331.     printf("\t -a \t\tArrow - use the arrow pointer regardless\n");
  1332.     printf("\t -c \t\tCheckalias - check the given aliases only\n");
  1333.     printf("\t -dn\t\tDebug - set debug level to 'n'\n");
  1334.     printf("\t -fx\t\tFile - read file 'x' rather than mailbox\n");
  1335.     printf("\t -h \t\tHelp - give this list of options\n");
  1336.     printf("\t -k \t\tKeypad - enable HP 2622 terminal keyboard\n");
  1337.     printf("\t -K \t\tKeypad&softkeys - enable use of softkeys + \"-k\"\n");
  1338.     printf("\t -m \t\tMenu - Turn off menu, using more of the screen\n");
  1339.     printf("\t -sx\t\tSubject 'x' - for batchmailing\n");
  1340.     printf("\t -z \t\tZero - don't enter Elm if no mail is pending\n");
  1341.     printf("\n");
  1342.     printf("\n");
  1343.     exit(1);
  1344. }
  1345. END-OF-FILE
  1346.  
  1347. if [ "$filename" != "/dev/null" ]
  1348. then
  1349.   size=`wc -c < $filename`
  1350.  
  1351.   if [ $size != 2813 ]
  1352.   then
  1353.     echo $filename changed - should be 2813 bytes, not $size bytes
  1354.   fi
  1355.  
  1356.   chmod 644 $filename
  1357. fi
  1358.  
  1359. # ---------- file src/INDEX ----------
  1360.  
  1361. filename="src/INDEX"
  1362.  
  1363. if [ -f $filename ]
  1364. then
  1365.   echo File \"$filename\" already exists\!  Skipping...
  1366.   filename=/dev/null        # throw it away
  1367. else
  1368.   echo extracting file src/INDEX...
  1369. fi
  1370.  
  1371. cat << 'END-OF-FILE' > $filename
  1372. Centerline()                             strings.c:411
  1373. ClearScreen()                            curses.c:208
  1374. CleartoEOLN()                            curses.c:716
  1375. CleartoEOS()                             curses.c:751
  1376. CursorDown()                             curses.c:317
  1377. CursorLeft()                             curses.c:344
  1378. CursorRight()                            curses.c:371
  1379. CursorUp()                               curses.c:291
  1380. EndBold()                                curses.c:411
  1381. EndHalfbright()                          curses.c:462
  1382. EndInverse()                             curses.c:487
  1383. EndMemlock()                             curses.c:538
  1384. EndUnderline()                           curses.c:437
  1385. HasMemlock()                             curses.c:500
  1386. InitScreen()                             curses.c:85
  1387. MoveCursor()                             curses.c:232
  1388. PutLine0()                               curses.c:614
  1389. PutLine1()                               curses.c:668
  1390. PutLine2()                               curses.c:684
  1391. PutLine3()                               curses.c:700
  1392. Raw()                                    curses.c:782
  1393. ReadCh()                                 curses.c:821
  1394. ScreenSize()                             curses.c:197
  1395. StartBold()                              curses.c:398
  1396. StartHalfbright()                        curses.c:450
  1397. StartInverse()                           curses.c:474
  1398. StartMemlock()                           curses.c:512
  1399. StartUnderline()                         curses.c:424
  1400. Write_to_screen()                        curses.c:588
  1401. Writechar()                              curses.c:556
  1402. add_alias()                              alias.c:69
  1403. add_current_alias()                      alias.c:115
  1404. add_site()                               addr_utils.c:62
  1405. add_to_alias_text()                      alias.c:163
  1406. alarm_signal()                           signals.c:52
  1407. alias()                                  alias.c:203
  1408. args_help()                              args.c:74
  1409. argv_zero()                              strings.c:429
  1410. binary_search()                          aliasdb.c:141
  1411. bounce_off_remote()                      bounceback.c:37
  1412. build_address()                          addr_utils.c:172
  1413. build_header_line()                      screen.c:197
  1414. bus_signal()                             signals.c:38
  1415. bytes()                                  file_utils.c:24
  1416. calendar_line()                          calendar.c:133
  1417. can_access()                             file_utils.c:51
  1418. change_sort()                            options.c:178
  1419. chloc()                                  strings.c:334
  1420. clean_up()                               strings.c:391
  1421. clear_bottom_of_screen()                 showmsg_cmd.c:116
  1422. clear_central_message()                  output_utils.c:107
  1423. clear_error()                            output_utils.c:22
  1424. clear_key()                              softkeys.c:113
  1425. compare_dates()                          date.c:291
  1426. compare_headers()                        sort.c:41
  1427. copy_message()                           fileio.c:14
  1428. copy_message_across()                    mailmsg2.c:452
  1429. copy_the_msg()                           mailmsg1.c:212
  1430. copy_to_self()                           utils.c:133
  1431. cuserid()                                opt_utils.c:67
  1432. days_ahead()                             date.c:180
  1433. define_key()                             softkeys.c:78
  1434. define_softkeys()                        softkeys.c:7
  1435. delete()                                 delete.c:10
  1436. display()                                showmsg.c:100
  1437. display_central_message()                output_utils.c:96
  1438. display_headers()                        hdrconfg.c:115
  1439. display_options()                        options.c:106
  1440. display_title()                          showmsg.c:351
  1441. display_to()                             mailmsg1.c:236
  1442. edit_headers()                           hdrconfg.c:36
  1443. edit_mailbox()                           edit.c:15
  1444. edit_the_message()                       mailmsg2.c:261
  1445. emergency_exit()                         utils.c:18
  1446. encode()                                 encode.c:81
  1447. enter_date()                             hdrconfg.c:135
  1448. error()                                  output_utils.c:35
  1449. error1()                                 output_utils.c:47
  1450. error2()                                 output_utils.c:57
  1451. error_description()                      errno.c:69
  1452. error_name()                             errno.c:54
  1453. expand_domain()                          domains.c:53
  1454. expand_filename()                        file.c:144
  1455. expand_group()                           aliaslib.c:66
  1456. expand_site()                            aliasdb.c:52
  1457. expand_system()                          aliaslib.c:51
  1458. explode()                                domains.c:76
  1459. extract_info()                           calendar.c:77
  1460. find()                                   aliaslib.c:107
  1461. find_old_current()                       sort.c:130
  1462. find_path_to()                           aliasdb.c:217
  1463. findnode()                               aliasdb.c:15
  1464. fix_date()                               date.c:257
  1465. fix_header_page()                        screen.c:259
  1466. fix_time()                               date.c:270
  1467. format_long()                            strings.c:134
  1468. format_long()                            strings.c:22
  1469. forward()                                reply.c:94
  1470. forwarded()                              addr_utils.c:295
  1471. fpe_signal()                             signals.c:31
  1472. from_matches()                           pattern.c:124
  1473. full_month()                             date.c:153
  1474. generate_reply_to()                      mkhdrs.c:14
  1475. get_address_from()                       addr_utils.c:87
  1476. get_alias_address()                      aliaslib.c:12
  1477. get_and_expand_everyone()                reply.c:124
  1478. get_arpa_date()                          date.c:110
  1479. get_connections()                        connect_to.c:13
  1480. get_copies()                             mailmsg1.c:167
  1481. get_date()                               date.c:50
  1482. get_entry()                              aliasdb.c:173
  1483. get_existing_address()                   return_addr.c:271
  1484. get_key_no_prompt()                      encode.c:66
  1485. get_line()                               aliaslib.c:148
  1486. get_mailtime()                           mailtime.c:63
  1487. get_options()                            args.c:98
  1488. get_page()                               utils.c:108
  1489. get_return()                             return_addr.c:195
  1490. get_return_name()                        reply.c:289
  1491. get_subject()                            mailmsg1.c:118
  1492. get_to()                                 mailmsg1.c:89
  1493. get_word()                               strings.c:309
  1494. gethostname()                            opt_utils.c:21
  1495. getkey()                                 encode.c:25
  1496. hash_it()                                aliaslib.c:133
  1497. help()                                   help.c:11
  1498. if()                                     addr_utils.c:548
  1499. if()                                     strings.c:488
  1500. ill_signal()                             signals.c:24
  1501. in_string()                              strings.c:74
  1502. init_findnode()                          aliasdb.c:191
  1503. initialize()                             initialize.c:37
  1504. install_aliases()                        alias.c:294
  1505. isa3270()                                opt_utils.c:40
  1506. leave()                                  utils.c:44
  1507. leave_locked()                           utils.c:78
  1508. leave_mbox()                             leavembox.c:26
  1509. lock()                                   leavembox.c:306
  1510. mail()                                   mailmsg2.c:24
  1511. main()                                   elm.c:12
  1512. makekey()                                encode.c:123
  1513. match_and_expand_domain()                domains.c:123
  1514. match_in_message()                       pattern.c:147
  1515. meta_match()                             pattern.c:18
  1516. month_number()                           date.c:342
  1517. move_left()                              strings.c:223
  1518. new_msg()                                mailtime.c:120
  1519. newmbox()                                newmbox.c:27
  1520. notes_machine()                          notesfile.c:117
  1521. num_enter()                              options.c:161
  1522. okay_address()                           reply.c:188
  1523. on_or_off()                              options.c:137
  1524. on_page()                                screen.c:280
  1525. one_liner()                              options.c:225
  1526. open_domain_file()                       domains.c:37
  1527. optimize_and_add()                       reply.c:222
  1528. optimize_arpa()                          return_addr.c:112
  1529. optimize_cmplx_arpa()                    return_addr.c:48
  1530. optimize_return()                        return_addr.c:28
  1531. optimize_usenet()                        return_addr.c:148
  1532. optionally_enter()                       input_utils.c:65
  1533. options()                                options.c:30
  1534. outchar()                                curses.c:837
  1535. parse_arguments()                        args.c:15
  1536. parse_arpa_date()                        addr_utils.c:388
  1537. parse_arpa_from()                        addr_utils.c:331
  1538. pattern_enter()                          input_utils.c:185
  1539. pattern_match()                          pattern.c:82
  1540. printable_chars()                        strings.c:54
  1541. process_showmsg_command()                showmsg_cmd.c:32
  1542. prompt()                                 output_utils.c:67
  1543. prompt1()                                output_utils.c:76
  1544. quit()                                   quit.c:13
  1545. quit_signal()                            signals.c:12
  1546. read_alias_files()                       alias.c:15
  1547. read_headers()                           newmbox.c:138
  1548. read_notesfile()                         notesfile.c:18
  1549. read_number()                            input_utils.c:40
  1550. read_rc_file()                           read_rc.c:68
  1551. read_uuname()                            connect_to.c:79
  1552. real_from()                              addr_utils.c:244
  1553. real_notes_header()                      notesfile.c:78
  1554. recall_last_msg()                        mailmsg2.c:224
  1555. remail()                                 remail.c:16
  1556. remove_domains()                         addr_utils.c:47
  1557. remove_first_word()                      strings.c:239
  1558. remove_through_ch()                      calendar.c:167
  1559. reply()                                  reply.c:26
  1560. reply_to_everyone()                      reply.c:58
  1561. resolve_received()                       mailtime.c:18
  1562. resync()                                 quit.c:23
  1563. return_value_of()                        curses.c:158
  1564. reverse()                                strings.c:292
  1565. save()                                   file.c:20
  1566. save_copy()                              savecopy.c:24
  1567. save_message()                           file.c:106
  1568. scan_calendar()                          calendar.c:44
  1569. segv_signal()                            signals.c:45
  1570. send()                                   mailmsg1.c:16
  1571. set_central_message()                    output_utils.c:87
  1572. set_error()                              output_utils.c:29
  1573. setup()                                  encode.c:144
  1574. shift_lower()                            strings.c:345
  1575. show_alias_menu()                        alias.c:191
  1576. show_current()                           screen.c:140
  1577. show_headers()                           screen.c:74
  1578. show_last_error()                        output_utils.c:15
  1579. show_line()                              showmsg.c:260
  1580. show_menu()                              screen.c:59
  1581. show_message()                           showmsg.c:62
  1582. show_msg()                               showmsg.c:24
  1583. show_msg_status()                        delete.c:36
  1584. show_msg_tag()                           delete.c:59
  1585. show_new_status()                        delete.c:70
  1586. show_status()                            screen.c:292
  1587. showscreen()                             screen.c:11
  1588. softkeys_off()                           softkeys.c:103
  1589. softkeys_on()                            softkeys.c:92
  1590. sort_mailbox()                           sort.c:14
  1591. sort_name()                              sort.c:78
  1592. sort_one_liner()                         options.c:233
  1593. strchr()                                 opt_utils.c:194
  1594. strcspn()                                opt_utils.c:106
  1595. strip_commas()                           strings.c:185
  1596. strip_parens()                           strings.c:200
  1597. strpbrk()                                opt_utils.c:173
  1598. strspn()                                 opt_utils.c:84
  1599. strtok()                                 opt_utils.c:129
  1600. subject_matches()                        pattern.c:136
  1601. subshell()                               syscall.c:15
  1602. suffix()                                 date.c:85
  1603. system_call()                            syscall.c:49
  1604. tag_message()                            delete.c:47
  1605. tail_of()                                strings.c:91
  1606. tail_of_string()                         strings.c:255
  1607. talk_to()                                addr_utils.c:20
  1608. term_signal()                            signals.c:18
  1609. tgetstr()                                curses.c:82
  1610. tolower()                                strings.c:28
  1611. toupper()                                strings.c:43
  1612. translate_return()                       addr_utils.c:118
  1613. transmit_functions()                     curses.c:177
  1614. undelete()                               delete.c:27
  1615. unlock()                                 leavembox.c:414
  1616. update_mailtime()                        mailtime.c:94
  1617. update_title()                           screen.c:39
  1618. uucp_hops()                              bounceback.c:17
  1619. valid_date()                             date.c:230
  1620. valid_name()                             validname.c:17
  1621. verify_bounceback()                      mailmsg2.c:484
  1622. verify_transmission()                    mailmsg2.c:297
  1623. want_to()                                input_utils.c:13
  1624. weedout()                                read_rc.c:293
  1625. words_in_string()                        strings.c:366
  1626. write_header_info()                      mailmsg2.c:363
  1627. END-OF-FILE
  1628.  
  1629. if [ "$filename" != "/dev/null" ]
  1630. then
  1631.   size=`wc -c < $filename`
  1632.  
  1633.   if [ $size != 13953 ]
  1634.   then
  1635.     echo $filename changed - should be 13953 bytes, not $size bytes
  1636.   fi
  1637.  
  1638.   chmod 644 $filename
  1639. fi
  1640.  
  1641. # ---------- file src/showmsg.c ----------
  1642.  
  1643. filename="src/showmsg.c"
  1644.  
  1645. if [ -f $filename ]
  1646. then
  1647.   echo File \"$filename\" already exists\!  Skipping...
  1648.   filename=/dev/null        # throw it away
  1649. else
  1650.   echo extracting file src/showmsg.c...
  1651. fi
  1652.  
  1653. cat << 'END-OF-FILE' > $filename
  1654. /**             showmsg.c            **/
  1655.  
  1656. /** This file contains all the routines needed to display the specified
  1657.     message.
  1658.  
  1659.    These routines (C) Copyright 1986 Dave Taylor 
  1660.  
  1661.    Modified 6/86 to use pager variable!!!   Hurrah!!!!
  1662. **/
  1663.  
  1664.  
  1665. #include "headers.h"
  1666. #include <ctype.h>
  1667. #include <errno.h>
  1668.  
  1669. #ifdef BSD
  1670. #undef tolower
  1671. #endif
  1672.  
  1673. extern int errno;
  1674.  
  1675. char *error_name();
  1676.  
  1677. int    memory_lock = FALSE;    /* is it available?? */
  1678. int    pipe_abort  = FALSE;    /* did we receive a SIGNAL(SIGPIPE)? */
  1679.  
  1680. int
  1681. show_msg(number)
  1682. int number;
  1683. {
  1684.     /*** display number'th message.  Get starting and ending lines
  1685.          of message from headers data structure, then fly through
  1686.          the file, displaying only those lines that are between the
  1687.          two!
  1688.         Returns non-zero iff screen was changed
  1689.     ***/
  1690.  
  1691.     dprint0(8, "show_msg called\n");
  1692.  
  1693.     if (number > message_count) {
  1694.       error1("Only %d messages!", message_count);
  1695.       return(0);
  1696.     }
  1697.     else if (number < 1) {
  1698.       error("you can't read THAT message!");
  1699.       return(0);
  1700.     }
  1701.  
  1702.     clearit(header_table[number-1].status, NEW);   /* it's been read now! */
  1703.  
  1704.     memory_lock = FALSE;
  1705.  
  1706.     /* some explaination for that last one - We COULD use memory locking
  1707.        to speed up the paging, but the action of "ClearScreen" on a screen
  1708.        with memory lock turned on seems to vary considerably (amazingly so)
  1709.        so it's safer to only allow memory lock to be a viable bit of
  1710.        trickery when dumping text to the screen in scroll mode.
  1711.        Philosophical arguments should be forwarded to Bruce at the 
  1712.        University of Walamazoo, Australia, via ACSNet  *wry chuckle* */
  1713.  
  1714.     return(show_message(header_table[number-1].lines, 
  1715.            header_table[number-1].offset,number));
  1716. }
  1717.  
  1718. int
  1719. show_message(lines, file_loc, msgnumber)
  1720. int lines, msgnumber;
  1721. long file_loc;
  1722. {
  1723.     /*** Show the indicated range of lines from mailfile
  1724.          for message 'msgnumber' by using 'display'
  1725.          Returns non-zero iff screen was altered.
  1726.     ***/
  1727.  
  1728.     dprint3(9,"show_message(%d,%ld,%d)\n", lines, file_loc, msgnumber);
  1729.  
  1730.     if (fseek(mailfile, file_loc, 0) != 0) {
  1731.       dprint2(1,"Error: seek %d bytes into file, errno %s (show_message)\n",
  1732.           file_loc, error_name(errno));
  1733.       error1("ELM failed seeking %d bytes into file (%s)",
  1734.           file_loc, error_name(errno));    
  1735.       return(0);
  1736.     }
  1737.  
  1738.     /* next read will get 'this' line so must be at end of previous */
  1739.  
  1740.     Raw(OFF);
  1741.     display(lines, msgnumber);
  1742.     Raw(ON);
  1743.     if (memory_lock) EndMemlock();    /* turn it off!! */
  1744.  
  1745.     return(1);    /* we did it boss! */
  1746. }
  1747.     
  1748.  
  1749. /** This next one is the 'pipe' file descriptor for writing to the 
  1750.     pager process... **/
  1751.  
  1752. FILE   *output_pipe;        
  1753.  
  1754. int
  1755. display(lines, msgnum)
  1756. int lines, msgnum;
  1757. {
  1758.     /** Display specified number of lines from file mailfile.
  1759.         Note: This routine MUST be placed at the first line 
  1760.         of the input file! 
  1761.         Returns the same as the routine above (namely zero or one)
  1762.     **/
  1763.  
  1764.     char buffer[VERY_LONG_STRING], *full_month();
  1765.  
  1766.     int lines_displayed = 0;    
  1767.     int lines_on_screen = 0;        /* display    */
  1768.     int crypted = 0, gotten_key = 0;    /* encryption */
  1769.     int weed_header, weeding_out = 0;    /* weeding    */ 
  1770.     int mail_sent;                /* misc use   */
  1771.  
  1772.     dprint3(4,"displaying %d lines from message %d using %s\n", 
  1773.         lines, msgnum, pager);
  1774.  
  1775.     pipe_abort = FALSE;
  1776.  
  1777.     if ((output_pipe = popen(pager,"w")) == NULL) {
  1778.       error2("Can't create pipe to %s [%s]", pager, 
  1779.           error_name(errno));
  1780.       dprint2(1,"\n*** Can't create pipe to %s - error %s ***\n\n",
  1781.              pager, error_name(errno));
  1782.       return(0);
  1783.     }
  1784.     dprint1(4,"Opened a write-only pipe to routine %s \n", pager);
  1785.  
  1786.     if (title_messages) {
  1787.  
  1788.       mail_sent = (strncmp(header_table[msgnum-1].from, "To:", 3) == 0);
  1789.  
  1790.       tail_of(header_table[msgnum-1].from, buffer, FALSE);
  1791.       fprintf(output_pipe, "%s #%d %s %s\t%s", 
  1792.            notesfile? "Note" : "Message", msgnum, 
  1793.            mail_sent? "to" : "from", buffer,
  1794.            strlen(buffer) > 16? "" : "\t");
  1795.       fprintf(output_pipe," %s %s %s, %d at %s\n\r%s",
  1796.           notesfile? "Posted" : "Mailed",
  1797.                full_month(header_table[msgnum-1].month), 
  1798.           header_table[msgnum-1].day, 
  1799.               atoi(header_table[msgnum-1].year) + 1900,
  1800.               header_table[msgnum-1].time,
  1801.           filter? "": "\n\n");
  1802.  
  1803.       if (! mail_sent && matches_weedlist("To:") && filter &&
  1804.           strcmp(header_table[current-1].to,username) != 0 &&
  1805.           strlen(header_table[current-1].to) > 0)
  1806.         fprintf(output_pipe, "\n(message addressed to %s)\n\n", 
  1807.             header_table[current-1].to);
  1808.     
  1809.       /** The test above is: if we didn't originally send the mail
  1810.           (e.g. we're not reading "mail.sent") AND the user is currently
  1811.           weeding out the "To:" line (otherwise they'll get it twice!)
  1812.           AND the user is actually weeding out headers AND the message 
  1813.           wasn't addressed to the user AND the 'to' address is non-zero 
  1814.           (consider what happens when the message doesn't HAVE a "To:" 
  1815.           line...the value is NULL but it doesn't match the username 
  1816.           either.  We don't want to display something ugly like 
  1817.           "(message addressed to )" which will just clutter up the 
  1818.           display!).
  1819.  
  1820.           And you thought programming was EASY!!!!
  1821.       **/
  1822.     }
  1823.  
  1824.     weed_header = filter;    /* allow us to change it after header */
  1825.  
  1826.     ClearScreen();
  1827.  
  1828.     if (cursor_control) transmit_functions(OFF);
  1829.  
  1830.     while (lines > 0 && pipe_abort == FALSE) {
  1831.  
  1832.         if (fgets(buffer, VERY_LONG_STRING, mailfile) == NULL) {
  1833.           if (lines_displayed == 0) {
  1834.  
  1835.         /* AUGH!  Why do we get this occasionally???  */
  1836.  
  1837.             dprint0(1,
  1838.              "\n\n** Out of Sync!!  EOF with nothing read (display) **\n");
  1839.         dprint0(1,"\nLeaving with all temp files intact!\n");
  1840.         error("Internal error: out of sync!");
  1841.             pclose(output_pipe);    /* close pipe NOW! */
  1842.         emergency_exit();
  1843.  
  1844.           }
  1845.           pclose(output_pipe);
  1846.           if (lines == 0 && pipe_abort == FALSE) {    /* displayed it all */
  1847.             PutLine0(LINES,0,"Press <return> to return to Elm: ");
  1848.             Raw(ON);
  1849.             (void) ReadCh();
  1850.             Raw(OFF);
  1851.           }
  1852.           return(TRUE);
  1853.         }
  1854.  
  1855.         if (strlen(buffer) > 0) 
  1856.               no_ret(buffer);
  1857.  
  1858.         if (strlen(buffer) == 0) {
  1859.           weed_header = 0;        /* past header! */
  1860.           weeding_out = 0;
  1861.         }
  1862.  
  1863.         lines--;
  1864.         lines_displayed++;
  1865.  
  1866.         if (notesfile) {    /* treat notes differently! */
  1867.  
  1868.           if (filter && (first_word(buffer, NOTES_HEADER) ||
  1869.               first_word(buffer, NOTES_FOOTER)) ) 
  1870.  
  1871.             /*** weed this line out of the display! ***/;
  1872.  
  1873.           else 
  1874.         show_line(buffer);
  1875.         }
  1876.  
  1877.         else { /* "normal" message */
  1878.  
  1879.           if (weed_header && matches_weedlist(buffer)) 
  1880.             weeding_out = 1;     /* aha!  We don't want to see this! */
  1881.           else if (buffer[0] == '[') {
  1882.             if (strcmp(buffer, START_ENCODE)==0)
  1883.           crypted++;
  1884.             else if (strcmp(buffer, END_ENCODE)==0)
  1885.               crypted--;
  1886.             else if (crypted) {
  1887.                   encode(buffer);
  1888.               show_line(buffer);
  1889.             }
  1890.             else
  1891.               show_line(buffer);
  1892.           }
  1893.           else if (crypted) {
  1894.             if (! gotten_key++) getkey(OFF);
  1895.             encode(buffer);
  1896.             show_line(buffer); 
  1897.           }
  1898.           else if (weeding_out) {
  1899.             weeding_out = (whitespace(buffer[0]));    /* 'n' line weed */
  1900.             if (! weeding_out)     /* just turned on! */
  1901.               show_line(buffer);
  1902.           } 
  1903.           else
  1904.             show_line(buffer);
  1905.         }
  1906.       }
  1907.  
  1908.         if (cursor_control) transmit_functions(ON);
  1909.  
  1910.     pclose(output_pipe);
  1911.     if (lines == 0 && pipe_abort == FALSE) {      /* displayed it all! */
  1912.       PutLine0(LINES,0,"Press <return> to return to Elm: ");
  1913.       Raw(ON);
  1914.       (void) ReadCh();
  1915.       Raw(OFF);
  1916.     }
  1917.     return(TRUE);
  1918. }
  1919.  
  1920. show_line(buffer)     
  1921. char *buffer;
  1922. {
  1923.     /** Hands the given line to the output pipe **/ 
  1924.     
  1925.     errno = 0;
  1926.     fprintf(output_pipe, "%s\n", buffer);
  1927.     
  1928.     if (errno != 0)
  1929.       dprint1(1,"\terror %s hit!\n", error_name(errno));
  1930. }
  1931. END-OF-FILE
  1932.  
  1933. if [ "$filename" != "/dev/null" ]
  1934. then
  1935.   size=`wc -c < $filename`
  1936.  
  1937.   if [ $size != 7704 ]
  1938.   then
  1939.     echo $filename changed - should be 7704 bytes, not $size bytes
  1940.   fi
  1941.  
  1942.   chmod 666 $filename
  1943. fi
  1944.  
  1945. # ---------- file src/mkhdrs.c ----------
  1946.  
  1947. filename="src/mkhdrs.c"
  1948.  
  1949. if [ -f $filename ]
  1950. then
  1951.   echo File \"$filename\" already exists\!  Skipping...
  1952.   filename=/dev/null        # throw it away
  1953. else
  1954.   echo extracting file src/mkhdrs.c...
  1955. fi
  1956.  
  1957. cat << 'END-OF-FILE' > $filename
  1958. /**            mkhdrs.c        **/
  1959.  
  1960. /** This contains all the header generating routines for the ELM
  1961.     program.
  1962.  
  1963.     (C) Copyright 1985 Dave Taylor
  1964.  
  1965. **/
  1966.  
  1967. #include <stdio.h>
  1968. #include "headers.h"
  1969.  
  1970. extern char in_reply_to[SLEN];
  1971.  
  1972. generate_reply_to(msg)
  1973. int msg;
  1974. {
  1975.     /** Generate an 'in-reply-to' message... **/
  1976.     char buffer[SLEN];
  1977.  
  1978.  
  1979.     if (msg == -1)        /* not a reply! */
  1980.       in_reply_to[0] = '\0';
  1981.     else {
  1982.       if (chloc(header_table[msg].from, '!') != -1)
  1983.         tail_of(header_table[msg].from, buffer, FALSE);
  1984.       else
  1985.         strcpy(buffer, header_table[msg].from);
  1986.       sprintf(in_reply_to, "Message from \"%s\" of %s %s, %s at %s",
  1987.           buffer,
  1988.           header_table[msg].month,
  1989.           header_table[msg].day,
  1990.           header_table[msg].year,
  1991.           header_table[msg].time);
  1992.     }
  1993. }
  1994. END-OF-FILE
  1995.  
  1996. if [ "$filename" != "/dev/null" ]
  1997. then
  1998.   size=`wc -c < $filename`
  1999.  
  2000.   if [ $size != 737 ]
  2001.   then
  2002.     echo $filename changed - should be 737 bytes, not $size bytes
  2003.   fi
  2004.  
  2005.   chmod 644 $filename
  2006. fi
  2007.  
  2008. echo end of this archive file....
  2009. exit 0
  2010.  
  2011.