home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / elm23-2.zip / patches.os2 < prev    next >
Text File  |  1996-10-12  |  207KB  |  7,438 lines

  1. Only in new: README.OS2
  2. Only in new: README.PGP
  3. Only in new: README.TCP
  4. Only in new: elm-tcp.rc
  5. Only in new: config.h
  6. Only in new: patches.os2
  7. Only in new/utils: sndmail.c
  8. Only in new: os2/*
  9. Only in new: crypt/*
  10. diff -cbr orig/filter/actions.c new/filter/actions.c
  11. *** orig/filter/actions.c    Sat Oct 16 18:43:32 1993
  12. --- new/filter/actions.c    Sun Sep 26 15:13:48 1993
  13. ***************
  14. *** 68,74 ****
  15.              username, address);
  16.   
  17.       if (! show_only) {
  18. !       sprintf(tempfile, "%s.%d", filter_temp, getpid());
  19.   
  20.         if ((tempfd = fopen(tempfile, "r")) == NULL) {
  21.           if (outfd != NULL)
  22. --- 68,74 ----
  23.              username, address);
  24.   
  25.       if (! show_only) {
  26. !       sprintf(tempfile, "%s%d.fil", tempdir, getpid());
  27.   
  28.         if ((tempfd = fopen(tempfile, "r")) == NULL) {
  29.           if (outfd != NULL)
  30. ***************
  31. *** 84,113 ****
  32.             if (contains(from, username)) {
  33.           if (outfd != NULL)
  34.                 fprintf(outfd,
  35. !     "filter (%s): Filter loop detected!  Message left in file %s.%d\n", 
  36. !             username, filter_temp, getpid());
  37.               if (outfd != NULL) fclose(outfd);
  38.               exit(0);
  39.             }
  40.           }
  41.   
  42.           if (strcmp(sendmail, mailer) == 0)
  43. !           sprintf(buffer, "%s %s %s", sendmail, smflags, address);
  44.           else
  45. !           sprintf(buffer, "%s %s", mailer, address);
  46.   
  47.           if ((pipefd = popen(buffer, "w")) == NULL) {
  48.             if (outfd != NULL)
  49.               fprintf(outfd, "filter (%s): popen %s failed!\n", username, buffer);
  50. !           sprintf(buffer, "((%s %s %s ; %s %s) & ) < %s &",
  51. !               sendmail , smflags, address, remove_cmd, tempfile, tempfile);
  52.             system(buffer);
  53.             return;
  54.           }
  55.   
  56.           fprintf(pipefd, "Subject: \"%s\"\n", subject);
  57. !         fprintf(pipefd, "From: The Filter of %s@%s <%s>\n", 
  58. !             username, hostname, username);
  59.           fprintf(pipefd, "To: %s\n", address);
  60.           fprintf(pipefd, "X-Filtered-By: filter, version %s\n\n", VERSION);
  61.   
  62. --- 84,113 ----
  63.             if (contains(from, username)) {
  64.           if (outfd != NULL)
  65.                 fprintf(outfd,
  66. !     "filter (%s): Filter loop detected!  Message left in file %s\n",
  67. !             username, tempfile);
  68.               if (outfd != NULL) fclose(outfd);
  69.               exit(0);
  70.             }
  71.           }
  72.   
  73.           if (strcmp(sendmail, mailer) == 0)
  74. !           sprintf(buffer, "%s -f %s@%s %s", sendmail, username, hostfromname, address);
  75.           else
  76. !           sprintf(buffer, "%s -t", mailer);
  77.   
  78.           if ((pipefd = popen(buffer, "w")) == NULL) {
  79.             if (outfd != NULL)
  80.               fprintf(outfd, "filter (%s): popen %s failed!\n", username, buffer);
  81. !           sprintf(buffer, "%s -t <%s", mailer, tempfile);
  82.             system(buffer);
  83. +               unlink(tempfile);
  84.             return;
  85.           }
  86.   
  87.           fprintf(pipefd, "Subject: \"%s\"\n", subject);
  88. !         fprintf(pipefd, "From: %s@%s (The Filter of %s)\n",
  89. !             username, hostfromname, username);
  90.           fprintf(pipefd, "To: %s\n", address);
  91.           fprintf(pipefd, "X-Filtered-By: filter, version %s\n\n", VERSION);
  92.   
  93. ***************
  94. *** 120,126 ****
  95.               fprintf(pipefd," %s", buffer);
  96.   
  97.           fprintf(pipefd, "\n-- End of filtered message --\n");
  98. !         fclose(pipefd);
  99.           fclose(tempfd);
  100.   
  101.           return;        /* YEAH!  Wot a slick program, eh? */
  102. --- 120,126 ----
  103.               fprintf(pipefd," %s", buffer);
  104.   
  105.           fprintf(pipefd, "\n-- End of filtered message --\n");
  106. !         pclose(pipefd);
  107.           fclose(tempfd);
  108.   
  109.           return;        /* YEAH!  Wot a slick program, eh? */
  110. ***************
  111. *** 146,151 ****
  112. --- 146,155 ----
  113.         else if ((mailfd = emergency_local_delivery()) == NULL)
  114.           exit(1);
  115.   
  116. + #ifdef MMDF
  117. +       fputs(MSG_SEPERATOR, mailfd);
  118. + #endif
  119.         while (fgets(buffer, sizeof(buffer), tempfd) != NULL) {
  120.           line_count++;
  121.           if (the_same(buffer, "From ") && line_count > 1)
  122. ***************
  123. *** 154,160 ****
  124.             fputs(buffer, mailfd);
  125.         }
  126.   
  127. !       fputs("\n", mailfd);
  128.   
  129.         fclose(mailfd);
  130.         unlock();        /* blamo or not?  Let it decide! */
  131. --- 158,164 ----
  132.             fputs(buffer, mailfd);
  133.         }
  134.   
  135. !       fputs("\n\n", mailfd);
  136.   
  137.         fclose(mailfd);
  138.         unlock();        /* blamo or not?  Let it decide! */
  139. ***************
  140. *** 177,183 ****
  141.             username, foldername);
  142.   
  143.       if (!show_only) {
  144. !       sprintf(filename, "%s.%d", filter_temp, getpid());
  145.   
  146.         if ((fdunit = open(foldername, O_APPEND | O_WRONLY | O_CREAT, 0600)) < 0) {
  147.           if (outfd != NULL)
  148. --- 181,187 ----
  149.             username, foldername);
  150.   
  151.       if (!show_only) {
  152. !       sprintf(filename, "%s%d.fil", tempdir, getpid());
  153.   
  154.         if ((fdunit = open(foldername, O_APPEND | O_WRONLY | O_CREAT, 0600)) < 0) {
  155.           if (outfd != NULL)
  156. ***************
  157. *** 196,201 ****
  158. --- 200,209 ----
  159.            return(1);
  160.         }
  161.   
  162. + #ifdef MMDF
  163. +       fputs(MSG_SEPERATOR, fd);
  164. + #endif
  165.         while (fgets(buffer, sizeof(buffer), tempfd) != NULL)
  166.           fputs(buffer, fd);
  167.   
  168. ***************
  169. *** 226,232 ****
  170.         fprintf(outfd, "filter (%s): Executing %s\n", username, command);
  171.   
  172.       if (! show_only) {
  173. !       sprintf(buffer, "%s %s.%d | %s", cat, filter_temp, getpid(), command);
  174.         system(buffer);
  175.       }
  176.   }
  177. --- 234,240 ----
  178.         fprintf(outfd, "filter (%s): Executing %s\n", username, command);
  179.   
  180.       if (! show_only) {
  181. !       sprintf(buffer, "%s <%s%d.fil", command, tempdir, getpid());
  182.         system(buffer);
  183.       }
  184.   }
  185. diff -cbr orig/filter/filter.c new/filter/filter.c
  186. *** orig/filter/filter.c    Sat Oct 16 18:43:34 1993
  187. --- new/filter/filter.c    Fri Dec 31 11:48:22 1993
  188. ***************
  189. *** 59,64 ****
  190. --- 59,66 ----
  191.   #define  MAIN_ROUTINE            /* for the filter.h file, of course! */
  192.   #include "filter.h"
  193.   
  194. + #undef fflush
  195.   main(argc, argv)
  196.   int argc;
  197.   char *argv[];
  198. ***************
  199. *** 76,99 ****
  200.            summary   = FALSE,            /* a summary is requested?  */
  201.            c;                    /* var for getopt routine   */
  202.   
  203. !     /* first off, let's get the info from /etc/passwd */
  204. !     if ((passwd_entry = getpwuid(getuid())) == NULL)
  205. !       leave("Cannot get password entry for this uid!");
  206.   
  207. -     strcpy(home, passwd_entry->pw_dir);
  208. -     strcpy(username, passwd_entry->pw_name);
  209.       outfname[0] = to[0] = '\0';    /* nothing read in yet, right? */
  210.   
  211.   #ifdef HOSTCOMPILED
  212.       strncpy(hostname, HOSTNAME, sizeof(hostname));
  213.   #else
  214.       gethostname(hostname, sizeof(hostname));
  215.   #endif
  216.   
  217.       /* now parse the starting arguments... */
  218.   
  219. !     while ((c = getopt(argc, argv, "clno:rSsv")) != EOF) {
  220.         switch (c) {
  221.           case 'c' : clear_logs = TRUE;            break;
  222.           case 'l' : log_actions_only = TRUE;            break;
  223. --- 78,102 ----
  224.            summary   = FALSE,            /* a summary is requested?  */
  225.            c;                    /* var for getopt routine   */
  226.   
  227. !         initpaths();
  228.   
  229.       outfname[0] = to[0] = '\0';    /* nothing read in yet, right? */
  230.   
  231.   #ifdef HOSTCOMPILED
  232.       strncpy(hostname, HOSTNAME, sizeof(hostname));
  233.   #else
  234.       gethostname(hostname, sizeof(hostname));
  235. + #endif
  236. + #ifdef OS2
  237. +     getfromdomain(hostfromname, sizeof(hostfromname));
  238. + #else
  239. +     strcpy(hostfromname, hostname);
  240.   #endif
  241.   
  242.       /* now parse the starting arguments... */
  243.   
  244. !     while ((c = getopt(argc, argv, "clno:rSsu:v")) != EOF) {
  245.         switch (c) {
  246.           case 'c' : clear_logs = TRUE;            break;
  247.           case 'l' : log_actions_only = TRUE;            break;
  248. ***************
  249. *** 104,118 ****
  250.           case 'S' : long_summary = TRUE;            break;
  251.   
  252.           case 'n' : show_only = TRUE;            break;
  253.           case 'v' : verbose = TRUE;                break;
  254. !         case '?' : fprintf(stderr, 
  255. !                "Usage: | filter [-nrv]\n   or: filter [-c] -[s|S]\n");
  256. !                      exit(1);
  257.         }
  258.       }
  259.   
  260. !     if (c < 0) {
  261. !     }
  262.   
  263.       /* let's open our outfd logfile as needed... */
  264.   
  265. --- 109,130 ----
  266.           case 'S' : long_summary = TRUE;            break;
  267.   
  268.           case 'n' : show_only = TRUE;            break;
  269. +         case 'u' : strcpy(username, optarg);        break;
  270.           case 'v' : verbose = TRUE;                break;
  271. !         case '?' : usage(argv[0]);
  272.         }
  273.       }
  274.   
  275. !     /* first off, let's get the info from /etc/passwd */
  276. !     passwd_entry = username[0] ? getpwnam(username) : getpwuid(getuid());
  277. !     if (passwd_entry == NULL)
  278. !       leave("Cannot get password entry for this uid!");
  279. !     strcpy(home, passwd_entry->pw_dir);
  280. !     strcpy(username, passwd_entry->pw_name);
  281. !     if (isatty(0) && !summary && !long_summary && !printing_rules)
  282. !           usage(argv[0]);
  283.   
  284.       /* let's open our outfd logfile as needed... */
  285.   
  286. ***************
  287. *** 146,152 ****
  288.   
  289.       /* next, create the tempfile and save the incoming message */
  290.   
  291. !     sprintf(filename, "%s.%d", filter_temp, getpid());
  292.   
  293.       if ((fd = fopen(filename,"w")) == NULL)
  294.         leave("Cannot open temporary file!");
  295. --- 158,164 ----
  296.   
  297.       /* next, create the tempfile and save the incoming message */
  298.   
  299. !     sprintf(filename, "%s%d.fil", tempdir, getpid());
  300.   
  301.       if ((fd = fopen(filename,"w")) == NULL)
  302.         leave("Cannot open temporary file!");
  303. ***************
  304. *** 229,234 ****
  305. --- 241,263 ----
  306.       (void) unlink(filename);    /* remove the temp file, please! */
  307.       if (outfd != NULL) fclose(outfd);
  308.       exit(0);
  309. + }
  310. + usage(name)
  311. + char *name;
  312. + {
  313. +   printf("\nUsage: filter [-nrv] [-o output] [-u user]"
  314. +          "\n   or: filter [-s|-S] [-c] [-o output] [-u user]\n"
  315. +          "\nWhere: -n   not really, only output what would happen"
  316. +          "\n       -v   be verbose for each message filtered"
  317. +          "\n       -r   list rules currently beeing used"
  318. +          "\n       -s   list summary of message filtered log"
  319. +          "\n       -S   list more verbose summary that -s"
  320. +          "\n       -c   clear log files after summarizing with -s or -S"
  321. +          "\n       -o output    redirect log message to 'output'"
  322. +      "\n       -u user      work under user ID 'user'\n");
  323. +   exit(1);
  324.   }
  325.   
  326.   save_from(buffer)
  327. diff -cbr orig/filter/lock.c new/filter/lock.c
  328. *** orig/filter/lock.c    Sat Oct 16 18:43:34 1993
  329. --- new/filter/lock.c    Sun Mar 22 15:09:16 1992
  330. ***************
  331. *** 59,66 ****
  332.   static    char flock_name[SLEN];
  333.   #endif
  334.   
  335. - extern  int  errno;
  336.   char *
  337.   mk_lockname(home, user)
  338.   char *home, *user;
  339. --- 59,64 ----
  340. ***************
  341. *** 74,80 ****
  342.       sprintf(lockfile, "/tmp/%.10s.mlk", user);
  343.   #else
  344.       /* lock is [file_to_lock].lock */
  345. !     sprintf(lockfile, "%s%s.lock", home, user);
  346.   #endif
  347.       return(lockfile);
  348.   }
  349. --- 72,78 ----
  350.       sprintf(lockfile, "/tmp/%.10s.mlk", user);
  351.   #else
  352.       /* lock is [file_to_lock].lock */
  353. !     sprintf(lockfile, "%s%s.lck", home, user);
  354.   #endif
  355.       return(lockfile);
  356.   }
  357. ***************
  358. *** 112,118 ****
  359.           }
  360.   #endif
  361.   
  362. !     while ((ret = open(lockfile, O_WRONLY | O_CREAT | O_EXCL, 0444)) < 0 
  363.              && attempts++ < 10) {
  364.         sleep(3);    /* wait three seconds each pass, okay?? */
  365.       }
  366. --- 110,116 ----
  367.           }
  368.   #endif
  369.   
  370. !     while ((ret = open(lockfile, O_WRONLY | O_CREAT | O_EXCL, 0666)) < 0
  371.              && attempts++ < 10) {
  372.         sleep(3);    /* wait three seconds each pass, okay?? */
  373.       }
  374. ***************
  375. *** 128,134 ****
  376.   #endif                    /* } !LOCK_FLOCK_ONLY    */
  377.   #ifdef    LOCK_BY_FLOCK            /* { LOCK_BY_FLOCK    */
  378.       (void)sprintf(flock_name,"%s%s",mailhome,username);
  379. !     flock_fd = open(flock_name, O_RDONLY | O_CREAT, 0600);
  380.       if ( flock_fd >= 0 )
  381.         for (attempts = 0; attempts < 10; attempts++) {
  382.           if ( (ret = flock(flock_fd,LOCK_NB|LOCK_EX)) != -1 )
  383. --- 126,132 ----
  384.   #endif                    /* } !LOCK_FLOCK_ONLY    */
  385.   #ifdef    LOCK_BY_FLOCK            /* { LOCK_BY_FLOCK    */
  386.       (void)sprintf(flock_name,"%s%s",mailhome,username);
  387. !     flock_fd = open(flock_name, O_RDONLY | O_CREAT, 0666);
  388.       if ( flock_fd >= 0 )
  389.         for (attempts = 0; attempts < 10; attempts++) {
  390.           if ( (ret = flock(flock_fd,LOCK_NB|LOCK_EX)) != -1 )
  391. diff -cbr orig/filter/Makefile new/filter/Makefile
  392. *** orig/filter/Makefile    Sat Oct 16 18:43:34 1993
  393. --- new/filter/Makefile    Fri Apr 22 21:19:20 1994
  394. ***************
  395. *** 2,19 ****
  396.   #  Makefile for the Elm system filter program for OS/2
  397.   #
  398.   
  399. ! gcc:
  400.       $(MAKE) all CC="gcc -O -Zomf -Zmtd" O=".obj" \
  401. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm32.def"
  402.   
  403. ! gccdebug:
  404.       $(MAKE) all CC="gcc -g" O=".o" \
  405. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm32.def"
  406. ! msc:
  407. !     $(MAKE) all CC="cl -nologo -AL -Gs -Ocegt" O=".obj" \
  408. !     CFLAGS="-W1 -Zep1 -Gt16 -D__STDC__ -G2 -J" \
  409. !     LFLAGS="-Lp" LIBS="..\os2\elm16.def -link /noe /packc /packd"
  410.   
  411.   # Variables
  412.   
  413. --- 2,14 ----
  414.   #  Makefile for the Elm system filter program for OS/2
  415.   #
  416.   
  417. ! release:
  418.       $(MAKE) all CC="gcc -O -Zomf -Zmtd" O=".obj" \
  419. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm.def"
  420.   
  421. ! debug:
  422.       $(MAKE) all CC="gcc -g" O=".o" \
  423. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm.def"
  424.   
  425.   # Variables
  426.   
  427. ***************
  428. *** 25,31 ****
  429.   
  430.   # Lists
  431.   
  432. ! OS2_OBJ        = getopt$O os2util$O
  433.   FILTER_OBJ    = actions$O buffer$O filter$O lock$O parse$O \
  434.             rules$O summarize$O utils$O opt_utils$O $(OS2_OBJ)
  435.   
  436. --- 20,26 ----
  437.   
  438.   # Lists
  439.   
  440. ! OS2_OBJ        = getopt$O os2util$O movemail$O
  441.   FILTER_OBJ    = actions$O buffer$O filter$O lock$O parse$O \
  442.             rules$O summarize$O utils$O opt_utils$O $(OS2_OBJ)
  443.   
  444. ***************
  445. *** 78,80 ****
  446. --- 73,77 ----
  447.           $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/getopt.c
  448.   os2util$O:    $(OS2DIR)/os2util.c
  449.           $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/os2util.c
  450. + movemail$O:    $(OS2DIR)/movemail.c
  451. +         $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/movemail.c
  452. diff -cbr orig/filter/rules.c new/filter/rules.c
  453. *** orig/filter/rules.c    Sat Oct 16 18:43:34 1993
  454. --- new/filter/rules.c    Sun Oct 04 13:37:56 1992
  455. ***************
  456. *** 120,126 ****
  457.   
  458.   #ifndef    _POSIX_SOURCE
  459.       struct tm *localtime();
  460. !     long    time();
  461.   #endif
  462.       struct tm *timerec;
  463.       long    thetime;
  464. --- 120,126 ----
  465.   
  466.   #ifndef    _POSIX_SOURCE
  467.       struct tm *localtime();
  468. !     time_t time();
  469.   #endif
  470.       struct tm *timerec;
  471.       long    thetime;
  472. diff -cbr orig/filter/utils.c new/filter/utils.c
  473. *** orig/filter/utils.c    Sat Oct 16 18:43:36 1993
  474. --- new/filter/utils.c    Sun Mar 22 14:27:26 1992
  475. ***************
  476. *** 40,45 ****
  477. --- 40,47 ----
  478.   #include "defs.h"
  479.   #include "filter.h"
  480.   
  481. + #undef fflush
  482.   leave(reason)
  483.   char *reason;
  484.   {
  485. diff -cbr orig/src/hdrconfg.c new/src/hdrconfg.c
  486. *** orig/src/hdrconfg.c    Fri Jan 18 10:01:52 1991
  487. --- new/src/hdrconfg.c    Mon Oct  7 22:03:12 1996
  488. ***************
  489. *** 103,108 ****
  490. --- 103,109 ----
  491.   {
  492.       /** Edit headers.  **/
  493.       int c, displayed_error = NO;
  494. +     char expanded_address[VERY_LONG_STRING];
  495.   
  496.       /*  Expand address-type headers for main part of display */
  497.       /*  (Unexpanded ones are used on the 'edit-line') */
  498. ***************
  499. *** 120,126 ****
  500.           displayed_error = NO;
  501.         else
  502.           CleartoEOS();
  503. !       c = getchar();
  504.         if (isupper(c))
  505.           c = tolower(c);
  506.         clear_error();
  507. --- 120,127 ----
  508.           displayed_error = NO;
  509.         else
  510.           CleartoEOS();
  511. !       c = ReadCh();
  512. !       /* c = getchar(); */
  513.         if (isupper(c))
  514.           c = tolower(c);
  515.         clear_error();
  516. ***************
  517. *** 171,176 ****
  518. --- 172,179 ----
  519.                   if(optionally_enter(reply_to,
  520.                     INPUT_LINE, 10, FALSE, FALSE) == -1)
  521.                 return(0);
  522. +             (void) build_address(strip_commas(reply_to), expanded_address);
  523. +             strcpy(reply_to, expanded_address);
  524.               put_replyto();
  525.               break;
  526.   
  527. diff -cbr orig/hdrs/defs.h new/hdrs/defs.h
  528. *** orig/hdrs/defs.h    Sat Oct 16 18:43:36 1993
  529. --- new/hdrs/defs.h    Wed Sep 08 23:26:12 1993
  530. ***************
  531. *** 36,41 ****
  532. --- 36,45 ----
  533.   #include "../config.h"
  534.   #include "sysdefs.h"    /* system/configurable defines */
  535.   
  536. + #ifdef OS2
  537. + #include "../os2/os2elm.h"
  538. + #endif
  539.   
  540.   # define VERSION         "2.3"        /* Version number... */
  541.   # define VERS_DATE    "May 1, 1990"        /* for elm -v option */
  542. ***************
  543. *** 113,125 ****
  544.   #define DONT_SAVE    "[no save]"
  545.   #define DONT_SAVE2    "[nosave]"
  546.   
  547. - #define alias_file    ".aliases"
  548. - #define group_file    ".groups"
  549. - #define system_file    ".systems"
  550. - #define default_folders        "Mail"
  551. - #define default_recvdmail    "=received"
  552. - #define default_sentmail    "=sent"
  553.   
  554.   /** some defines for the 'userlevel' variable... **/
  555.   
  556. --- 117,122 ----
  557. ***************
  558. *** 169,176 ****
  559.   #define DECEMBER    11
  560.   
  561.   #define equal(s,w)    (strcmp(s,w) == 0)
  562. ! #define min(a,b)    a < b? a : b
  563. ! #define ctrl(c)            c - 'A' + 1    /* control character mapping */
  564.   #define plural(n)    n == 1 ? "" : "s"
  565.   #define lastch(s)    s[strlen(s)-1]
  566.   
  567. --- 166,173 ----
  568.   #define DECEMBER    11
  569.   
  570.   #define equal(s,w)    (strcmp(s,w) == 0)
  571. ! #define min(a,b)    (a < b? a : b)
  572. ! #define ctrl(c)            (c == '?' ? 127 : c - 'A' + 1)    /* control character mapping */
  573.   #define plural(n)    n == 1 ? "" : "s"
  574.   #define lastch(s)    s[strlen(s)-1]
  575.   
  576. ***************
  577. *** 258,263 ****
  578. --- 255,261 ----
  579.   
  580.   #define PMALLOC_THRESHOLD    256    /* if greater, then just use malloc */
  581.   #define PMALLOC_BUFFER_SIZE    2048    /* internal [memory] buffer size... */
  582.   
  583.   /** the following macro is as suggested by Larry McVoy.  Thanks! **/
  584.   
  585. diff -cbr orig/hdrs/elm.h new/hdrs/elm.h
  586. *** orig/hdrs/elm.h    Sat Oct 16 18:43:36 1993
  587. --- new/hdrs/elm.h    Tue Sep 28 23:25:40 1993
  588. ***************
  589. *** 34,40 ****
  590.   #include "../hdrs/curses.h"
  591.   #include "../hdrs/defs.h"
  592.   
  593. ! #ifdef    BSD
  594.   #include <setjmp.h>
  595.   #endif
  596.   
  597. --- 34,40 ----
  598.   #include "../hdrs/curses.h"
  599.   #include "../hdrs/defs.h"
  600.   
  601. ! #if defined(BSD) || defined(OS2)
  602.   #include <setjmp.h>
  603.   #endif
  604.   
  605. ***************
  606. *** 57,62 ****
  607. --- 57,64 ----
  608.   int headers_per_page;        /* number of headers/page  */
  609.   int original_umask = 0;        /* original umask, for restore before subshell */
  610.   int sendmail_verbose = 0;       /* Extended mail debugging */
  611. + int no_save = 0;        /* Do not save outgoing mail */
  612. + int mmdf_strict = 0;        /* Strict MMDF mailbox scanning */
  613.   char cur_folder[SLEN];          /* name of current folder */
  614.   char cur_tempfolder[SLEN];      /* name of temp folder open for a mailbox */
  615.   char defaultfile[SLEN];         /* name of default folder */
  616. ***************
  617. *** 64,69 ****
  618. --- 66,72 ----
  619.   char hostname[SLEN];            /* name of machine we're on*/
  620.   char hostdomain[SLEN];          /* name of domain we're in */
  621.   char hostfullname[SLEN];        /* name of FQDN we're in */
  622. + char hostfromname[SLEN];        /* name of FQDN we pretend to be in */
  623.   char username[SLEN];            /* return address name!    */
  624.   char full_username[SLEN];       /* Full username - gecos   */
  625.   char home[SLEN];                /* home directory of user  */
  626. ***************
  627. *** 177,183 ****
  628.   int userid;            /* uid for current user          */
  629.   int groupid;            /* groupid for current user   */
  630.   
  631. ! #ifdef    BSD
  632.   jmp_buf GetPromptBuf;        /* setjmp buffer */
  633.   int InGetPrompt;        /* set if in GetPrompt() in read() */
  634.   #endif
  635. --- 180,186 ----
  636.   int userid;            /* uid for current user          */
  637.   int groupid;            /* groupid for current user   */
  638.   
  639. ! #if defined(BSD) || defined(OS2)
  640.   jmp_buf GetPromptBuf;        /* setjmp buffer */
  641.   int InGetPrompt;        /* set if in GetPrompt() in read() */
  642.   #endif
  643. diff -cbr orig/hdrs/filter.h new/hdrs/filter.h
  644. *** orig/hdrs/filter.h    Sat Oct 16 18:43:36 1993
  645. --- new/hdrs/filter.h    Sun Sep 26 15:16:24 1993
  646. ***************
  647. *** 42,54 ****
  648.   
  649.   /** some of the files we'll be using, where they are, and so on... **/
  650.   
  651. ! #define  filter_temp    "/tmp/filter"
  652. ! #define  filterfile    ".elm/filter-rules"
  653. ! #define  filterlog    ".elm/filterlog"
  654. ! #define  filtersum    ".elm/filtersum"
  655.   
  656. ! #define  EMERGENCY_MAILBOX    "EMERGENCY_MBOX"
  657. ! #define  EMERG_MBOX        "MBOX.EMERGENCY"
  658.   
  659.   /** and now the hardwired constraint of the program.. **/
  660.   
  661. --- 42,54 ----
  662.   
  663.   /** some of the files we'll be using, where they are, and so on... **/
  664.   
  665. ! #define  filter_temp    "filter"
  666. ! #define  filterfile    "elm/filter.rul"
  667. ! #define  filterlog    "elm/filter.log"
  668. ! #define  filtersum    "elm/filter.sum"
  669.   
  670. ! #define  EMERGENCY_MAILBOX      "emergenc.mbx"
  671. ! #define  EMERG_MBOX             "emerg.mbx"
  672.   
  673.   /** and now the hardwired constraint of the program.. **/
  674.   
  675. ***************
  676. *** 87,93 ****
  677.   
  678.   /** A funky way to open a file using open() to avoid file locking hassles **/
  679.   
  680. ! #define  FOLDERMODE    O_WRONLY | O_APPEND | O_CREAT | O_SYNCIO
  681.   
  682.   /** cheap but easy way to have two files share the same #include file **/
  683.   
  684. --- 87,93 ----
  685.   
  686.   /** A funky way to open a file using open() to avoid file locking hassles **/
  687.   
  688. ! #define  FOLDERMODE    O_WRONLY | O_APPEND | O_CREAT
  689.   
  690.   /** cheap but easy way to have two files share the same #include file **/
  691.   
  692. ***************
  693. *** 96,101 ****
  694. --- 96,102 ----
  695.   char home[SLEN],                /* the users home directory */
  696.        hostname[SLEN],            /* the machine name...      */
  697.        username[SLEN];            /* the users login name...  */
  698. + char hostfromname[SLEN];                /* name of FQDN we pretend to be in */
  699.   
  700.   char to[VERY_LONG_STRING],
  701.        from[LONG_STRING],
  702. ***************
  703. *** 120,125 ****
  704. --- 121,127 ----
  705.   extern char home[SLEN],                /* the users home directory */
  706.               hostname[SLEN],            /* the machine name...      */
  707.               username[SLEN];            /* the users login name...  */
  708. + extern char hostfromname[SLEN];         /* name of FQDN we pretend to be in */
  709.   
  710.   extern char to[VERY_LONG_STRING],
  711.               from[LONG_STRING],
  712. diff -cbr orig/hdrs/headers.h new/hdrs/headers.h
  713. *** orig/hdrs/headers.h    Sat Oct 16 18:43:36 1993
  714. --- new/hdrs/headers.h    Tue Sep 28 23:25:40 1993
  715. ***************
  716. *** 33,38 ****
  717. --- 33,43 ----
  718.   #include "curses.h"
  719.   #include "defs.h"
  720.   
  721. + #ifdef OS2
  722. + #include "../os2/os2elm.h"
  723. + #include <setjmp.h>
  724. + #endif
  725.   #ifdef    BSD
  726.   #include <setjmp.h>
  727.   #endif
  728. ***************
  729. *** 51,56 ****
  730. --- 56,63 ----
  731.   extern int headers_per_page;    /* number of headers/page  */
  732.   extern int original_umask;    /* original umask, for restore before subshell */
  733.   extern int sendmail_verbose;    /* Allow extended debugging on sendmail */
  734. + extern int no_save;        /* Do not save outgoing mail */
  735. + extern int mmdf_strict;        /* Strict MMDF mailbox scanning */
  736.   extern char cur_folder[SLEN];    /* name of current folder */
  737.   extern char cur_tempfolder[SLEN]; /* name of temp folder open for a mailbox */
  738.   extern char defaultfile[SLEN];    /* name of default folder */
  739. ***************
  740. *** 58,63 ****
  741. --- 65,71 ----
  742.   extern char hostname[SLEN];    /* name of machine we're on*/
  743.   extern char hostdomain[SLEN];    /* name of domain we're in */
  744.   extern char hostfullname[SLEN]; /* name of FQDN we're in */
  745. + extern char hostfromname[SLEN]; /* name of FQDN we pretend to be in */
  746.   extern char username[SLEN];    /* return address name!    */
  747.   extern char full_username[SLEN];/* Full username - gecos   */
  748.   extern char home[SLEN];        /* home directory of user  */
  749. ***************
  750. *** 172,178 ****
  751.   extern int userid;        /* uid for current user          */
  752.   extern int groupid;        /* groupid for current user   */
  753.   
  754. ! #ifdef    BSD
  755.   extern jmp_buf GetPromptBuf;    /* setjmp buffer */
  756.   extern int InGetPrompt;        /* set if in GetPrompt() in read() */
  757.   #endif
  758. --- 180,186 ----
  759.   extern int userid;        /* uid for current user          */
  760.   extern int groupid;        /* groupid for current user   */
  761.   
  762. ! #if defined(BSD) || defined(OS2)
  763.   extern jmp_buf GetPromptBuf;    /* setjmp buffer */
  764.   extern int InGetPrompt;        /* set if in GetPrompt() in read() */
  765.   #endif
  766. diff -cbr orig/hdrs/sysdefs.h new/hdrs/sysdefs.h
  767. *** orig/hdrs/sysdefs.h    Sat Oct 16 18:43:38 1993
  768. --- new/hdrs/sysdefs.h    Wed Sep 08 23:23:02 1993
  769. ***************
  770. *** 91,105 ****
  771.   
  772.   #define emacs_editor    "emacs"
  773.   
  774. - #define sendmail    ""
  775. - #define smflags        "-oi -oem"    /* ignore dots and mail back errors */
  776. - #define smflagsv          "-oi -oem -v"   /* Verbose voyuer mode */
  777.   #define submitmail      mailer
  778.   #define submitflags     "-t"
  779. ! #define submitflags_s    "-mlrn"
  780. ! /* #define mailer    "rmail" */
  781.   #define mailx        "mail"
  782.   
  783.   #define dotelm          "elm"
  784.   #define helphome        elmhome
  785. --- 91,101 ----
  786.   
  787.   #define emacs_editor    "emacs"
  788.   
  789.   #define submitmail      mailer
  790.   #define submitflags     "-t"
  791. ! #define sendmail    "sendmail"
  792. ! #define rmail        "rmail"
  793.   #define mailx        "mail"
  794.   
  795.   #define dotelm          "elm"
  796.   #define helphome        elmhome
  797. diff -cbr orig/src/addr_util.c new/src/addr_util.c
  798. *** orig/src/addr_util.c    Sat Oct 16 18:43:38 1993
  799. --- new/src/addr_util.c    Wed Apr 01 12:13:50 1992
  800. ***************
  801. *** 109,114 ****
  802. --- 109,115 ----
  803.        (char *) 0, 0
  804.   };
  805.   
  806. + #ifndef OS2
  807.   char *
  808.   gcos_name(gcos_field, logname)
  809.   char *logname, *gcos_field;
  810. ***************
  811. *** 169,174 ****
  812. --- 170,176 ----
  813.   #endif
  814.   #endif
  815.   }
  816. + #endif
  817.   
  818.   char *
  819.   get_full_name(logname)
  820. ***************
  821. *** 493,499 ****
  822.   
  823.       struct header_rec temp_rec, *rec_ptr;
  824.       char junk[STRING], timebuff[STRING], holding_from[SLEN], hold_tz[12];
  825. !     char mybuf[BUFSIZ], *p, *q;
  826.       int  eight_fields = 0;
  827.           int mday, month, year, minutes, seconds, tz, i;
  828.           long gmttime;
  829. --- 495,501 ----
  830.   
  831.       struct header_rec temp_rec, *rec_ptr;
  832.       char junk[STRING], timebuff[STRING], holding_from[SLEN], hold_tz[12];
  833. !     char mybuf[BUFSIZ], timebuf2[STRING], *p, *q;
  834.       int  eight_fields = 0;
  835.           int mday, month, year, minutes, seconds, tz, i;
  836.           long gmttime;
  837. ***************
  838. *** 509,524 ****
  839.   
  840.       /* From <user> <day> <month> <day> <hr:min:sec> <year> */
  841.   
  842. !     sscanf(buffer, "%*s %*s %*s %*s %*s %s %*s %s", timebuff, junk);
  843.   
  844. !     if (strlen(timebuff) < 3) {
  845.         dprint(3,(debugfile,
  846.           "Real_from returns FAIL [no time field] on\n-> %s\n",
  847.           buffer));
  848.         return(FALSE);
  849.       }
  850.   
  851. !     if (timebuff[1] != ':' && timebuff[2] != ':') { 
  852.         dprint(3,(debugfile,
  853.           "Real_from returns FAIL [bad time field] on\n-> %s\n",
  854.           buffer));
  855. --- 511,527 ----
  856.   
  857.       /* From <user> <day> <month> <day> <hr:min:sec> <year> */
  858.   
  859. !     sscanf(buffer, "%*s %*s %*s %*s %*s %s %s %s", timebuff, timebuf2, junk);
  860.   
  861. !     if (strlen(timebuff) < 3 && strlen(timebuf2) < 3) {
  862.         dprint(3,(debugfile,
  863.           "Real_from returns FAIL [no time field] on\n-> %s\n",
  864.           buffer));
  865.         return(FALSE);
  866.       }
  867.   
  868. !     if (timebuff[1] != ':' && timebuff[2] != ':' &&
  869. !         timebuf2[1] != ':' && timebuf2[2] != ':') { /* UUPC ! */
  870.         dprint(3,(debugfile,
  871.           "Real_from returns FAIL [bad time field] on\n-> %s\n",
  872.           buffer));
  873. ***************
  874. *** 524,534 ****
  875.           buffer));
  876.         return(FALSE);
  877.       }
  878. !     if (junk[0] != '\0') {    /* try for 8 field entry */
  879.         junk[0] = '\0';
  880. !       sscanf(buffer, "%*s %*s %*s %*s %*s %s %*s %*s %s", timebuff, junk);
  881. !       if (junk[0] != '\0') {
  882. !         dprint(3, (debugfile, 
  883.             "Real_from returns FAIL [too many fields] on\n-> %s\n",
  884.             buffer));
  885.           return(FALSE);
  886. --- 527,537 ----
  887.           buffer));
  888.         return(FALSE);
  889.       }
  890. !     if (junk[0] != '\0' && strcmp(junk, "remote")) { /* try for 8 field entry */
  891.         junk[0] = '\0';
  892. !       sscanf(buffer, "%*s %*s %*s %*s %*s %*s %*s %*s %s", junk);
  893. !       if (junk[0] != '\0' && strcmp(junk, "remote")) {
  894. !         dprint(3, (debugfile,             /* ^ UUPC ! */
  895.             "Real_from returns FAIL [too many fields] on\n-> %s\n",
  896.             buffer));
  897.           return(FALSE);
  898. ***************
  899. *** 547,552 ****
  900. --- 550,571 ----
  901.                   junk, holding_from, rec_ptr->dayname, rec_ptr->month,
  902.                       rec_ptr->day, rec_ptr->time, rec_ptr->year);
  903.   
  904. +         /* non-standard UUPC From line? */
  905. +         /* This is from UUPC rmail: */
  906. +         /* From fkk Sat, 14 Mar 1992 14:53:27 MET remote from stasys */
  907. +         /* while this were normal: */
  908. +         /* From fkk Sat Mar 14 14:53:27 1992 [MET] */
  909. +         if ( rec_ptr->dayname[strlen(rec_ptr->dayname) - 1] == ',' )
  910. +         {
  911. +       sscanf(buffer, "%s %s %s %s %s %s %s %s",
  912. +              junk, holding_from, rec_ptr->dayname, rec_ptr->day,
  913. +                  rec_ptr->month, rec_ptr->year, rec_ptr->time, hold_tz);
  914. +           rec_ptr->dayname[strlen(rec_ptr->dayname) - 1] = 0;
  915. +         }
  916.       strncpy(rec_ptr->from, holding_from, STRING-1);
  917.       rec_ptr->from[STRING-1] = '\0';
  918.       resolve_received(rec_ptr);
  919. ***************
  920. *** 815,821 ****
  921.   /* Return smallest i such that table[i] is a prefix of str.  Return -1 if not
  922.    * found.
  923.    */
  924. ! static int prefix(table, str)
  925.   char **table;
  926.   char *str;
  927.   {
  928. --- 834,840 ----
  929.   /* Return smallest i such that table[i] is a prefix of str.  Return -1 if not
  930.    * found.
  931.    */
  932. ! int prefix(table, str)
  933.   char **table;
  934.   char *str;
  935.   {
  936. ***************
  937. *** 925,931 ****
  938.    * Unlike the preceding routines, the result is not an updated pointer, but
  939.    * simply 1 for success and 0 for failure.
  940.    */
  941. ! static int
  942.   get_unix_date(p,y,d,m,s,t)
  943.   char *p;
  944.   int *y, *d, *m, *s, *t;
  945. --- 944,950 ----
  946.    * Unlike the preceding routines, the result is not an updated pointer, but
  947.    * simply 1 for success and 0 for failure.
  948.    */
  949. ! int
  950.   get_unix_date(p,y,d,m,s,t)
  951.   char *p;
  952.   int *y, *d, *m, *s, *t;
  953. diff -cbr orig/src/alias.c new/src/alias.c
  954. *** orig/src/alias.c    Sat Oct 16 18:43:40 1993
  955. --- new/src/alias.c    Sun Oct 04 14:35:04 1992
  956. ***************
  957. *** 44,50 ****
  958. --- 44,52 ----
  959.   char *get_alias_address();
  960.   char *error_name(), *error_description(), *strip_parens(), *index();
  961.   
  962. + #ifndef OS2
  963.   extern int errno;
  964. + #endif
  965.   
  966.   #ifndef DONT_TOUCH_ADDRESSES
  967.   char *expand_system();
  968. ***************
  969. *** 80,90 ****
  970.   
  971.       struct stat hst;
  972.       static time_t system_ctime, system_mtime;
  973.   
  974.       /* If hash file hasn't changed, don't bother re-reading. */
  975.   
  976.       if (system_data != -1
  977. !      && stat(system_hash_file, &hst) == 0
  978.        && hst.st_ctime == system_ctime
  979.        && hst.st_mtime == system_mtime)
  980.         return;
  981. --- 82,95 ----
  982.   
  983.       struct stat hst;
  984.       static time_t system_ctime, system_mtime;
  985. +         char syshash[SLEN], sysdata[SLEN];
  986.   
  987.       /* If hash file hasn't changed, don't bother re-reading. */
  988. +         sprintf(syshash, "%s/%s", elmhome, system_hash_file);
  989. +         sprintf(sysdata, "%s/%s", elmhome, system_data_file);
  990.   
  991.       if (system_data != -1
  992. !      && stat(syshash, &hst) == 0
  993.        && hst.st_ctime == system_ctime
  994.        && hst.st_mtime == system_mtime)
  995.         return;
  996. ***************
  997. *** 98,113 ****
  998.   
  999.       /* Read system hash table.  If we can't, just return. */
  1000.   
  1001. !     if (read_hash_file(system_hash_file, (char *) system_hash_table,
  1002.                   sizeof system_hash_table) < 0)
  1003.         return;
  1004.   
  1005.       /* Open system data table. */
  1006.   
  1007. !     if ((system_data = open(system_data_file, O_RDONLY)) == -1) {
  1008.         dprint(1, (debugfile,
  1009.                 "Warning: Can't open system alias data file %s\n",
  1010. !               system_data_file));
  1011.         return;
  1012.       }
  1013.   
  1014. --- 103,118 ----
  1015.   
  1016.       /* Read system hash table.  If we can't, just return. */
  1017.   
  1018. !     if (read_hash_file(syshash, (char *) system_hash_table,
  1019.                   sizeof system_hash_table) < 0)
  1020.         return;
  1021.   
  1022.       /* Open system data table. */
  1023.   
  1024. !     if ((system_data = open(sysdata, O_RDONLY)) == -1) {
  1025.         dprint(1, (debugfile,
  1026.                 "Warning: Can't open system alias data file %s\n",
  1027. !               sysdata));
  1028.         return;
  1029.       }
  1030.   
  1031. ***************
  1032. *** 396,402 ****
  1033.       FILE *file;
  1034.       char fname[SLEN];
  1035.   
  1036. !     sprintf(fname,"%s/%s", home, ALIAS_TEXT);
  1037.   
  1038.       save_file_stats(fname);
  1039.       if ((file = fopen(fname, "a")) == NULL) {
  1040. --- 401,407 ----
  1041.       FILE *file;
  1042.       char fname[SLEN];
  1043.   
  1044. !     sprintf(fname, "%s/%s", home, ALIAS_TEXT);
  1045.   
  1046.       save_file_stats(fname);
  1047.       if ((file = fopen(fname, "a")) == NULL) {
  1048. ***************
  1049. *** 441,448 ****
  1050.       strcpy(name_with_equals, name);
  1051.       strcat(name_with_equals, " =");
  1052.   
  1053. !     sprintf(fname,"%s/%s", home, ALIAS_TEXT);
  1054. !     sprintf(tmpfname,"%s/%s.t", home, ALIAS_TEXT);
  1055.   
  1056.       save_file_stats(fname);
  1057.   
  1058. --- 446,453 ----
  1059.       strcpy(name_with_equals, name);
  1060.       strcat(name_with_equals, " =");
  1061.   
  1062. !     sprintf(fname, "%s/%s", home, ALIAS_TEXT);
  1063. !     sprintf(tmpfname, "%s/%s", home, ALIAS_TEMP);
  1064.   
  1065.       save_file_stats(fname);
  1066.   
  1067. ***************
  1068. *** 485,490 ****
  1069. --- 490,496 ----
  1070.       }
  1071.       fclose(file);
  1072.       fclose(tmp_file);
  1073. +         unlink(fname);
  1074.       if (rename(tmpfname, fname) != 0)
  1075.       {
  1076.           error1("Couldn't rename tempfile %s after deleting alias!", tmpfname);
  1077. ***************
  1078. *** 498,504 ****
  1079.   
  1080.   show_alias_menu()
  1081.   {
  1082. !     MoveCursor(LINES-7,0); CleartoEOS();    
  1083.   
  1084.       PutLine0(LINES-7,COLUMNS-45, "Alias commands");
  1085.       Centerline(LINES-6,
  1086. --- 504,510 ----
  1087.   
  1088.   show_alias_menu()
  1089.   {
  1090. !     MoveCursor(LINES-8,0); CleartoEOS();
  1091.   
  1092.       PutLine0(LINES-7,COLUMNS-45, "Alias commands");
  1093.       Centerline(LINES-6,
  1094. ***************
  1095. *** 645,658 ****
  1096.       /** run the 'newalias' program and update the
  1097.           aliases before going back to the main program!
  1098.       **/
  1099.   
  1100.       error("Updating aliases...");
  1101. !     sleep(2);
  1102.   
  1103. !     if (system_call(newalias, SH, FALSE, FALSE) == 0) {
  1104.         error("Re-reading the database in...");
  1105. !       sleep(2);
  1106.         read_alias_files();
  1107.         set_error("Aliases updated successfully.");
  1108.       }
  1109. --- 651,665 ----
  1110.       /** run the 'newalias' program and update the
  1111.           aliases before going back to the main program!
  1112.       **/
  1113. !         char cmd[SLEN];
  1114.   
  1115.       error("Updating aliases...");
  1116. !     /* sleep(2); */
  1117. !         sprintf(cmd, "%s", newalias);
  1118.   
  1119. !     if (system_call(cmd, SH, FALSE, FALSE) == 0) {
  1120.         error("Re-reading the database in...");
  1121. !       /* sleep(2); */
  1122.         read_alias_files();
  1123.         set_error("Aliases updated successfully.");
  1124.       }
  1125. ***************
  1126. *** 722,728 ****
  1127.   {
  1128.       char fname[SLEN];
  1129.   
  1130. !     sprintf(fname,"%s/%s", home, ALIAS_TEXT);
  1131.       display_file(fname);
  1132.       ClearScreen();
  1133.       return;
  1134. --- 729,735 ----
  1135.   {
  1136.       char fname[SLEN];
  1137.   
  1138. !     sprintf(fname, "%s/%s", home, ALIAS_TEXT);
  1139.       display_file(fname);
  1140.       ClearScreen();
  1141.       return;
  1142. diff -cbr orig/src/aliasdb.c new/src/aliasdb.c
  1143. *** orig/src/aliasdb.c    Sat Oct 16 18:43:40 1993
  1144. --- new/src/aliasdb.c    Mon Mar 16 09:47:44 1992
  1145. ***************
  1146. *** 35,41 ****
  1147. --- 35,43 ----
  1148.   #include <sys/stat.h>
  1149.   #include <errno.h>
  1150.   
  1151. + #ifndef OS2
  1152.   extern int errno;
  1153. + #endif
  1154.   
  1155.   #ifdef USE_DBM
  1156.   # include <dbm.h>
  1157. ***************
  1158. *** 324,338 ****
  1159.   
  1160.       struct stat buffer;
  1161.       char   *path_filename;
  1162. - #ifdef USE_DBM
  1163.       char buf[BUFSIZ];
  1164.   
  1165. !     sprintf(buf,"%s.pag", pathfile);
  1166. !     path_filename = buf;
  1167.   #else
  1168. !     path_filename = pathfile;
  1169.   #endif
  1170.   
  1171.       if (stat(path_filename, &buffer) == -1) {
  1172.         dprint(2, (debugfile,
  1173. --- 326,339 ----
  1174.   
  1175.       struct stat buffer;
  1176.       char   *path_filename;
  1177.       char buf[BUFSIZ];
  1178.   
  1179. ! #ifdef USE_DBM
  1180. !     sprintf(buf,"%s/%s.pag", elmhome, pathfile);
  1181.   #else
  1182. !     sprintf(buf,"%s/%s", elmhome, pathfile);
  1183.   #endif
  1184. +     path_filename = buf;
  1185.   
  1186.       if (stat(path_filename, &buffer) == -1) {
  1187.         dprint(2, (debugfile,
  1188. diff -cbr orig/src/args.c new/src/args.c
  1189. *** orig/src/args.c    Sat Oct 16 18:43:40 1993
  1190. --- new/src/args.c    Sun Aug 16 22:56:28 1992
  1191. ***************
  1192. *** 51,57 ****
  1193.       to_whom[0] = '\0';
  1194.       batch_subject[0] = '\0';
  1195.   
  1196. !         while ((c = getopt(argc, argv, "?acd:f:hkKms:Vvwz")) != EOF) {
  1197.          switch (c) {
  1198.            case 'a' : arrow_cursor++;        break;
  1199.            case 'c' : check_only++;        break;
  1200. --- 51,57 ----
  1201.       to_whom[0] = '\0';
  1202.       batch_subject[0] = '\0';
  1203.   
  1204. !         while ((c = getopt(argc, argv, "?acd:f:hkKmns:uVvwz")) != EOF) {
  1205.          switch (c) {
  1206.            case 'a' : arrow_cursor++;        break;
  1207.            case 'c' : check_only++;        break;
  1208. ***************
  1209. *** 62,68 ****
  1210. --- 62,70 ----
  1211.            case 'k' : hp_terminal++;    break;
  1212.            case 'K' : hp_terminal++; hp_softkeys++;    break;
  1213.            case 'm' : mini_menu = 0;    break;
  1214. +          case 'n' : no_save++;    break;
  1215.            case 's' : strcpy(batch_subject, optarg);    break;
  1216. +          case 'u' : mmdf_strict++;    break; /* i.e. UUPC */
  1217.                case 'V' : sendmail_verbose++;     break;
  1218.            case 'v' : args_version();
  1219.            case 'w' : warnings = 0;    break;
  1220. ***************
  1221. *** 122,128 ****
  1222. --- 124,132 ----
  1223.       printf("\t -k \t\tKeypad - enable HP 2622 terminal keyboard\n");
  1224.       printf("\t -K \t\tKeypad&softkeys - enable use of softkeys + \"-k\"\n");
  1225.       printf("\t -m \t\tMenu - Turn off menu, using more of the screen\n");
  1226. +     printf("\t -n \t\tNosave - Do not save outgoing mail - for batchmailing\n");
  1227.       printf("\t -sx\t\tSubject 'x' - for batchmailing\n");
  1228. +     printf("\t -u \t\tMore restrictive mailbox scanning - for UUPC mailboxes\n");
  1229.           printf("\t -V \t\tEnable sendmail voyeur mode.\n");
  1230.       printf("\t -v \t\tPrint out ELM version information.\n");
  1231.       printf("\t -w \t\tSupress warning messages...\n");
  1232. diff -cbr orig/src/builtin.c new/src/builtin.c
  1233. *** orig/src/builtin.c    Sat Oct 16 18:43:40 1993
  1234. --- new/src/builtin.c    Sun Mar 29 00:05:02 1992
  1235. ***************
  1236. *** 78,84 ****
  1237.        * is removed from input and 1 is returned. Otherwise 0 is returned.
  1238.        */
  1239.   
  1240. !     register char *optr, *iptr;
  1241.       register unsigned chars_output, nt;
  1242.       int ret_val;
  1243.   
  1244. --- 78,84 ----
  1245.        * is removed from input and 1 is returned. Otherwise 0 is returned.
  1246.        */
  1247.   
  1248. !     register unsigned char *optr, *iptr;
  1249.       register unsigned chars_output, nt;
  1250.       int ret_val;
  1251.   
  1252. ***************
  1253. *** 98,105 ****
  1254.             iptr++;
  1255.           break;
  1256.         } else if (*iptr == '\n' || *iptr == '\r') {    /*newline or return */
  1257. -         *optr++ = '\n';
  1258.           *optr++ = '\r';
  1259.           iptr++;
  1260.           break;            /* end of line */
  1261.         } else if(*iptr == '\f') {        /* formfeed */
  1262. --- 98,105 ----
  1263.             iptr++;
  1264.           break;
  1265.         } else if (*iptr == '\n' || *iptr == '\r') {    /*newline or return */
  1266.           *optr++ = '\r';
  1267. +         *optr++ = '\n';
  1268.           iptr++;
  1269.           break;            /* end of line */
  1270.         } else if(*iptr == '\f') {        /* formfeed */
  1271. ***************
  1272. *** 113,120 ****
  1273.           break;
  1274.         } else if(*iptr == '\t') {        /* tab stop */
  1275.           if((nt=next_tab(chars_output+1)) > width) {
  1276. !           *optr++ = '\n';        /* won't fit on this line - autowrap */
  1277. !           *optr++ = '\r';        /* tab by tabbing so-to-speak to 1st */
  1278.             iptr++;            /* column of next line */
  1279.             break;
  1280.           } else {        /* will fit - output proper num of spaces */
  1281. --- 113,122 ----
  1282.           break;
  1283.         } else if(*iptr == '\t') {        /* tab stop */
  1284.           if((nt=next_tab(chars_output+1)) > width) {
  1285. ! #ifndef OS2
  1286. !           *optr++ = '\r';        /* won't fit on this line - autowrap */
  1287. !           *optr++ = '\n';        /* tab by tabbing so-to-speak to 1st */
  1288. ! #endif
  1289.             iptr++;            /* column of next line */
  1290.             break;
  1291.           } else {        /* will fit - output proper num of spaces */
  1292. ***************
  1293. *** 126,132 ****
  1294. --- 126,136 ----
  1295.             }
  1296.             iptr++;
  1297.           }
  1298. + #ifdef OS2
  1299. +       } else if(isprint(*iptr) || (128 <= *iptr && *iptr < 255)) {
  1300. + #else
  1301.         } else if(isprint(*iptr)) {
  1302. + #endif
  1303.           *optr++ = *iptr++;            /* printing character */
  1304.           chars_output++;
  1305.         } else {            /* non-white space control character */
  1306. ***************
  1307. *** 161,166 ****
  1308. --- 163,170 ----
  1309.       char *pending, footer[SLEN], display_buffer[SLEN], ch;
  1310.       int formfeed, lines_more;
  1311.   
  1312. +         fixline(input_line);
  1313.   #ifdef MMDF
  1314.       if (strcmp(input_line, MSG_SEPERATOR) == 0)
  1315.         strcpy(input_line," ");
  1316. ***************
  1317. *** 291,297 ****
  1318.   
  1319.       /* truncate or pad title2 portion on the right
  1320.        * so that line fits exactly to the rightmost column */
  1321. !     padding = COLUMNS - (t1_len + t2_len + strlen(title3));
  1322.   
  1323.       sprintf(titlebuf, "%s%-*.*s%s\n\r\n\r", title1, t2_len+padding,
  1324.           t2_len+padding, title2, title3);
  1325. --- 295,301 ----
  1326.   
  1327.       /* truncate or pad title2 portion on the right
  1328.        * so that line fits exactly to the rightmost column */
  1329. !     padding = COLUMNS - 1 - (t1_len + t2_len + strlen(title3));
  1330.   
  1331.       sprintf(titlebuf, "%s%-*.*s%s\n\r\n\r", title1, t2_len+padding,
  1332.           t2_len+padding, title2, title3);
  1333. diff -cbr orig/src/calendar.c new/src/calendar.c
  1334. *** orig/src/calendar.c    Sat Oct 16 18:43:40 1993
  1335. --- new/src/calendar.c    Sun Mar 29 00:05:10 1992
  1336. ***************
  1337. *** 43,49 ****
  1338. --- 43,51 ----
  1339.   
  1340.   #include <errno.h>
  1341.   
  1342. + #ifndef OS2
  1343.   extern int errno;
  1344. + #endif
  1345.   
  1346.   char *error_name(), *error_description(), *strcpy();
  1347.   
  1348. diff -cbr orig/src/conn_to.c new/src/conn_to.c
  1349. *** orig/src/conn_to.c    Sat Oct 16 18:43:42 1993
  1350. --- new/src/conn_to.c    Sun Mar 15 14:17:04 1992
  1351. ***************
  1352. *** 56,62 ****
  1353.         return;
  1354.       }
  1355.   
  1356. !     sprintf(filename, "%s%s%d", temp_dir, temp_uuname, getpid());
  1357.       sprintf(buffer,"%s > %s", uuname, filename);
  1358.   
  1359.       if (system_call(buffer, SH, FALSE, FALSE) != 0) {
  1360. --- 56,62 ----
  1361.         return;
  1362.       }
  1363.   
  1364. !     sprintf(filename, "%s%d%s", temp_dir, getpid(), temp_uuname);
  1365.       sprintf(buffer,"%s > %s", uuname, filename);
  1366.   
  1367.       if (system_call(buffer, SH, FALSE, FALSE) != 0) {
  1368. diff -cbr orig/src/curses.c new/src/curses.c
  1369. *** orig/src/curses.c    Sat Oct 16 18:43:42 1993
  1370. --- new/src/curses.c    Sat Oct 16 13:27:28 1993
  1371. ***************
  1372. *** 119,127 ****
  1373.        *_setbold, *_clearbold, *_setunderline, *_clearunderline,
  1374.        *_sethalfbright, *_clearhalfbright, *_setinverse, *_clearinverse,
  1375.        *_cleartoeoln, *_cleartoeos, *_transmit_on, *_transmit_off,
  1376. !      *_set_memlock, *_clear_memlock;
  1377.   
  1378. ! static int _lines, _columns, _automargin, _eatnewlineglitch;
  1379.   int tabspacing;
  1380.   
  1381.   static char _terminal[1024];              /* Storage for terminal entry */
  1382. --- 119,127 ----
  1383.        *_setbold, *_clearbold, *_setunderline, *_clearunderline,
  1384.        *_sethalfbright, *_clearhalfbright, *_setinverse, *_clearinverse,
  1385.        *_cleartoeoln, *_cleartoeos, *_transmit_on, *_transmit_off,
  1386. !      *_set_memlock, *_clear_memlock, *_initscreen, *_exitscreen;
  1387.   
  1388. ! static int _lines, _columns, _automargin, _eatnewlineglitch, initialized;
  1389.   int tabspacing;
  1390.   
  1391.   static char _terminal[1024];              /* Storage for terminal entry */
  1392. ***************
  1393. *** 145,154 ****
  1394.       char termname[40];
  1395.       char *strcpy(), *getenv();
  1396.   
  1397. !     if (getenv("TERM") == NULL) return(-1);
  1398. !     if (strcpy(termname, getenv("TERM")) == NULL)
  1399. !         return(-1);
  1400.   
  1401.       if ((err = tgetent(_terminal, termname)) != 1)
  1402.           return(err-2);
  1403. --- 145,154 ----
  1404.       char termname[40];
  1405.       char *strcpy(), *getenv();
  1406.   
  1407. !     if (getenv("TERM") == NULL)
  1408. !             strcpy(termname, "ansi");
  1409. !         else
  1410. !         strcpy(termname, getenv("TERM"));
  1411.   
  1412.       if ((err = tgetent(_terminal, termname)) != 1)
  1413.           return(err-2);
  1414. ***************
  1415. *** 157,162 ****
  1416. --- 157,164 ----
  1417.       _col   =  0;        /* assume zero, zero...     */
  1418.   
  1419.       /* load in all those pesky values */
  1420. +     _initscreen        = tgetstr("ti", &ptr);
  1421. +     _exitscreen        = tgetstr("te", &ptr);
  1422.       _clearscreen       = tgetstr("cl", &ptr);
  1423.       _moveto            = tgetstr("cm", &ptr);
  1424.       _up                = tgetstr("up", &ptr);
  1425. ***************
  1426. *** 188,196 ****
  1427. --- 190,214 ----
  1428.           _left = "\b";
  1429.       }
  1430.   
  1431. +     tputs(_initscreen, 1, outchar);
  1432. +     fflush(stdout);
  1433. +         initialized = 1;
  1434.       return(0);
  1435.   }
  1436.   
  1437. + ExitScreen()
  1438. + {
  1439. +         if ( initialized )
  1440. +         {
  1441. +         tputs(_exitscreen, 1, outchar);
  1442. + #ifdef OS2
  1443. +             tflush();
  1444. + #endif
  1445. +         fflush(stdout);
  1446. +         }
  1447. + }
  1448.   char *return_value_of(termcap_label)
  1449.   char *termcap_label;
  1450.   {
  1451. ***************
  1452. *** 268,273 ****
  1453. --- 283,291 ----
  1454.   {
  1455.       /** returns the number of lines and columns on the display. **/
  1456.   
  1457. + #ifdef OS2
  1458. +         _ScreenSize(&_lines, &_columns);
  1459. + #endif
  1460.   #ifdef TIOCGWINSZ
  1461.       struct winsize w;
  1462.   
  1463. ***************
  1464. *** 717,726 ****
  1465. --- 717,730 ----
  1466.   
  1467.       else {
  1468.         /* if some kind of non-printable character change to a '?' */
  1469. + #ifdef OS2
  1470. +       if(!isprint(ch) && !(128 <= ch && ch < 255))
  1471. + #else
  1472.   #ifdef ASCII_CTYPE
  1473.         if(!isascii(ch) || !isprint(ch))
  1474.   #else
  1475.         if(!isprint(ch))
  1476. + #endif
  1477.   #endif
  1478.           ch = '?';
  1479.   
  1480. ***************
  1481. *** 838,844 ****
  1482. --- 856,874 ----
  1483.       /** clear to end of screen **/
  1484.   
  1485.       if (!_cleartoeos)
  1486. + #ifdef OS2
  1487. +         {
  1488. +           int i;
  1489. +         tflush();
  1490. +           printf("\033[s\033[K");
  1491. +           for ( i = _line + 1; i < _lines; i++ )
  1492. +             printf("\033[%d;1H\033[K", i + 1);
  1493. +           printf("\033[u");
  1494. +           fflush(stdout);
  1495. +         }
  1496. + #else
  1497.           return(-1);
  1498. + #endif
  1499.   
  1500.       tputs(_cleartoeos, 1, outchar);
  1501.       fflush(stdout);  /* clear the output buffer */
  1502. ***************
  1503. *** 861,866 ****
  1504. --- 890,899 ----
  1505.       if (state == OFF && _inraw) {
  1506.         (void) ttsetattr(TTYIN,&_original_tty);
  1507.         _inraw = 0;
  1508. + #ifdef OS2
  1509. +         tflush();
  1510. +           _fsetmode(stdout, "t");
  1511. + #endif
  1512.       }
  1513.       else if (state == ON && ! _inraw) {
  1514.   
  1515. ***************
  1516. *** 879,886 ****
  1517. --- 911,934 ----
  1518.   #endif
  1519.         (void) ttsetattr(TTYIN, &_raw_tty);
  1520.         _inraw = 1;
  1521. + #ifdef OS2
  1522. +           _fsetmode(stdout, "b");
  1523. + #endif
  1524. +     }
  1525. + }
  1526. + #ifdef OS2
  1527. + char cbuffer[1024];
  1528. + int cbufsize;
  1529. + tflush()
  1530. + {
  1531. +         if ( cbufsize ) {
  1532. +           fwrite(cbuffer, cbufsize, 1, stdout);
  1533. +           cbufsize = 0;
  1534.           }
  1535.   }
  1536. + #endif
  1537.   
  1538.   int
  1539.   ReadCh()
  1540. ***************
  1541. *** 889,896 ****
  1542. --- 937,949 ----
  1543.   
  1544.       register int result;
  1545.       char ch;
  1546. + #ifdef OS2
  1547. +         tflush();
  1548. +         return readkey();
  1549. + #else
  1550.       result = read(0, &ch, 1);
  1551.           return((result <= 0 ) ? EOF : ch);
  1552. + #endif
  1553.   }
  1554.   
  1555.   outchar(c)
  1556. ***************
  1557. *** 899,904 ****
  1558. --- 952,964 ----
  1559.       /** output the given character.  From tputs... **/
  1560.       /** Note: this CANNOT be a macro!              **/
  1561.   
  1562. + #ifdef OS2
  1563. +         cbuffer[cbufsize++] = c;
  1564. +         if ( cbufsize == sizeof(cbuffer) )
  1565. +           tflush();
  1566. + #else
  1567.       putc(c, stdout);
  1568. + #endif
  1569.   }
  1570.   
  1571. diff -cbr orig/src/date.c new/src/date.c
  1572. *** orig/src/date.c    Sat Oct 16 18:43:42 1993
  1573. --- new/src/date.c    Wed Feb 09 19:38:30 1994
  1574. ***************
  1575. *** 40,47 ****
  1576.   #include <ctype.h>
  1577.   
  1578.   #ifndef    _POSIX_SOURCE
  1579. ! extern struct tm *localtime();
  1580. ! extern long      time();
  1581.   #endif
  1582.   
  1583.   #ifdef BSD
  1584. --- 40,47 ----
  1585.   #include <ctype.h>
  1586.   
  1587.   #ifndef    _POSIX_SOURCE
  1588. ! extern struct tm *localtime(), *gmtime();
  1589. ! extern time_t      time();
  1590.   #endif
  1591.   
  1592.   #ifdef BSD
  1593. ***************
  1594. *** 66,96 ****
  1595.   int  days_in_month[] = { 31,    28,    31,    30,    31,     30,
  1596.             31,     31,    30,   31,    30,     31,  -1};
  1597.   
  1598. ! #ifdef BSD
  1599. !   char *timezone();
  1600. ! #else
  1601. !   extern char *tzname[];
  1602. ! #endif
  1603.   
  1604.   char *get_arpa_date()
  1605.   {
  1606.       /** returns an ARPA standard date.  The format for the date
  1607. !         according to DARPA document RFC-822 is exemplified by;
  1608.   
  1609. !                      Mon, 12 Aug 85 6:29:08 MST
  1610.   
  1611.       **/
  1612.   
  1613.       static char buffer[SLEN];    /* static character buffer       */
  1614. !     struct tm *the_time;        /* Time structure, see CTIME(3C) */
  1615.       long       junk;        /* time in seconds....         */
  1616.   
  1617.   #ifdef BSD
  1618.   # ifndef TZ_MINUTESWEST
  1619. -     struct timeb    loc_time;
  1620.       junk = time((long *) 0);
  1621. -     ftime(&loc_time);
  1622.   # else
  1623.       struct  timeval  time_val;
  1624.       struct  timezone time_zone;
  1625. --- 66,96 ----
  1626.   int  days_in_month[] = { 31,    28,    31,    30,    31,     30,
  1627.             31,     31,    30,   31,    30,     31,  -1};
  1628.   
  1629. ! char *tzoffset(long time)
  1630. ! {
  1631. !   static char offset[SLEN];
  1632. !   struct tm tm = *localtime(&time);
  1633. !   long utime = mktime(&tm);
  1634. !   sprintf(offset, "%+03d00", (utime - time) / 3600);
  1635. !   return offset;
  1636. ! }
  1637.   
  1638.   char *get_arpa_date()
  1639.   {
  1640.       /** returns an ARPA standard date.  The format for the date
  1641. !         according to DARPA document RFC-822 is exemplified by:
  1642.   
  1643. !                      Mon, 12 Aug 85 6:29:08 -0800
  1644.   
  1645.       **/
  1646.   
  1647.       static char buffer[SLEN];    /* static character buffer       */
  1648. !     struct tm the_time;        /* Time structure, see CTIME(3C) */
  1649.       long       junk;        /* time in seconds....         */
  1650.   
  1651.   #ifdef BSD
  1652.   # ifndef TZ_MINUTESWEST
  1653.       junk = time((long *) 0);
  1654.   # else
  1655.       struct  timeval  time_val;
  1656.       struct  timezone time_zone;
  1657. ***************
  1658. *** 103,131 ****
  1659.       junk = time((long *) 0);    /* this must be here for it to work! */
  1660.   #endif
  1661.   
  1662. !     the_time = localtime(&junk);
  1663.   
  1664.       sprintf(buffer, "%s, %d %s %d %d:%02d:%02d %s",
  1665. !       arpa_dayname[the_time->tm_wday],
  1666. !       the_time->tm_mday % 32,
  1667. !       arpa_monname[the_time->tm_mon],
  1668. !       the_time->tm_year % 100,
  1669. !       the_time->tm_hour % 24,
  1670. !       the_time->tm_min  % 61,
  1671. !       the_time->tm_sec  % 61,
  1672. ! #ifdef BSD
  1673. ! #ifdef TZ_MINUTESWEST
  1674. ! # ifdef GOULD_NP1
  1675. !       the_time->tm_zone);
  1676. ! # else
  1677. !       timezone(time_zone.tz_minuteswest, the_time->tm_isdst));
  1678. ! # endif
  1679. ! #else
  1680. !       timezone(loc_time.timezone, the_time->tm_isdst));
  1681. ! #endif
  1682. ! #else
  1683. !       tzname[the_time->tm_isdst]);
  1684. ! #endif
  1685.   
  1686.       return( (char *) buffer);
  1687.   }
  1688. --- 103,119 ----
  1689.       junk = time((long *) 0);    /* this must be here for it to work! */
  1690.   #endif
  1691.   
  1692. !     the_time = *localtime(&junk);
  1693.   
  1694.       sprintf(buffer, "%s, %d %s %d %d:%02d:%02d %s",
  1695. !       arpa_dayname[the_time.tm_wday],
  1696. !       the_time.tm_mday % 32,
  1697. !       arpa_monname[the_time.tm_mon],
  1698. !       the_time.tm_year % 100,
  1699. !       the_time.tm_hour % 24,
  1700. !       the_time.tm_min  % 61,
  1701. !       the_time.tm_sec  % 61,
  1702. !       tzoffset(junk));
  1703.   
  1704.       return( (char *) buffer);
  1705.   }
  1706. diff -cbr orig/src/domains.c new/src/domains.c
  1707. *** orig/src/domains.c    Sat Oct 16 18:43:42 1993
  1708. --- new/src/domains.c    Mon Mar 16 09:48:44 1992
  1709. ***************
  1710. *** 67,75 ****
  1711.   
  1712.   open_domain_file()
  1713.   {
  1714. !     if ((domainfd = fopen(domains, "r")) == NULL) {
  1715.         dprint(2, (debugfile,"Warning: can't open file %s as domains file\n",
  1716. !         domains));
  1717.       }
  1718.       else {
  1719.         dprint(3, (debugfile,
  1720. --- 67,79 ----
  1721.   
  1722.   open_domain_file()
  1723.   {
  1724. !         char domainsfile[SLEN];
  1725. !         sprintf(domainsfile, "%s/%s", elmhome, domains);
  1726. !     if ((domainfd = fopen(domainsfile, "r")) == NULL) {
  1727.         dprint(2, (debugfile,"Warning: can't open file %s as domains file\n",
  1728. !         domainsfile));
  1729.       }
  1730.       else {
  1731.         dprint(3, (debugfile,
  1732. diff -cbr orig/src/edit.c new/src/edit.c
  1733. *** orig/src/edit.c    Sat Oct 16 18:43:44 1993
  1734. --- new/src/edit.c    Wed Nov 17 10:44:46 1993
  1735. ***************
  1736. *** 38,44 ****
  1737. --- 38,46 ----
  1738.   #include "headers.h"
  1739.   #include <errno.h>
  1740.   
  1741. + #ifndef OS2
  1742.   extern int errno;
  1743. + #endif
  1744.   
  1745.   char   *error_name(), *error_description(), *strcpy();
  1746.   long   bytes();
  1747. ***************
  1748. *** 83,88 ****
  1749. --- 85,95 ----
  1750.   
  1751.       Raw(OFF);
  1752.   
  1753. +     fclose(mailfile);
  1754. +     mailfile = NULL;
  1755. +         os2path(buffer);
  1756. +         
  1757.       if (system_call(buffer, SH, TRUE, FALSE) != 0) {
  1758.         error1("Problems invoking editor %s!", alternative_editor);
  1759.         Raw(ON);
  1760. ***************
  1761. *** 91,96 ****
  1762. --- 98,104 ----
  1763.       }
  1764.   
  1765.       Raw(ON);
  1766. +         ClearScreen();
  1767.       SetXYLocation(0, 40);    /* a location not near the next request, so an absolute is used */
  1768.   
  1769.       if (folder_type == SPOOL) {    /* uh oh... now the toughie...  */
  1770. ***************
  1771. *** 192,198 ****
  1772.       } else
  1773.         error("Resynchronizing with new version of folder...");
  1774.   
  1775. !     sleep(2);
  1776.       ClearScreen();
  1777.       newmbox(cur_folder, FALSE);
  1778.       showscreen();
  1779. --- 200,206 ----
  1780.       } else
  1781.         error("Resynchronizing with new version of folder...");
  1782.   
  1783. !     /* sleep(2); */
  1784.       ClearScreen();
  1785.       newmbox(cur_folder, FALSE);
  1786.       showscreen();
  1787. diff -cbr orig/src/editmsg.c new/src/editmsg.c
  1788. *** orig/src/editmsg.c    Sat Oct 16 18:43:44 1993
  1789. --- new/src/editmsg.c    Tue Dec 14 21:46:06 1993
  1790. ***************
  1791. *** 55,61 ****
  1792. --- 55,63 ----
  1793.   #undef        tolower
  1794.   #endif
  1795.   
  1796. + #ifndef OS2
  1797.   extern int errno;
  1798. + #endif
  1799.   
  1800.   char *error_name(), *error_description(), *strcpy(), *format_long();
  1801.   unsigned long sleep();
  1802. ***************
  1803. *** 86,91 ****
  1804. --- 88,94 ----
  1805.           if (strlen(buffer) == 0)
  1806.             sprintf(buffer,"%s %s", editor, filename);
  1807.   
  1808. +     os2path(buffer);
  1809.       chown(filename, userid, groupid);    /* file was owned by root! */
  1810.   
  1811.       if (( old_raw = RawState()) == ON)
  1812. ***************
  1813. *** 109,114 ****
  1814. --- 112,118 ----
  1815.       if (old_raw == ON)
  1816.          Raw(ON);
  1817.   
  1818. +         ClearScreen();
  1819.       SetXYLocation(0, 40);    /* a location not near the next request, so an absolute is used */
  1820.       MoveCursor(LINES, 0);    /* dont know where we are, force last row, col 0 */
  1821.   
  1822. ***************
  1823. *** 286,299 ****
  1824.                    Write_to_screen(
  1825.            "(You need to use a specific command here. Continue.)\n\r");
  1826.                  else {
  1827. !                  sprintf(buf, " > %s%s.%d 2>&1", temp_dir, temp_edit, getpid());
  1828.                    strcat(buffer, buf);
  1829.                    if (( old_raw = RawState()) == ON)
  1830.                      Raw(OFF);
  1831.                    (void) system_call((char *) buffer+2, SH, TRUE, TRUE);
  1832.                    if (old_raw == ON)
  1833.                       Raw(ON);
  1834. !                  sprintf(buffer, "~r %s%s.%d", temp_dir, temp_edit, getpid());
  1835.                              read_in_file(edit_fd, (char *) buffer + 3, 0);
  1836.                    (void) unlink((char *) buffer+3);
  1837.                    SetXYLocation(0, 40);    /* a location not near the next request, so an absolute is used */
  1838. --- 290,303 ----
  1839.                    Write_to_screen(
  1840.            "(You need to use a specific command here. Continue.)\n\r");
  1841.                  else {
  1842. !                  sprintf(buf, " > %s%d.%s", temp_dir, getpid(), temp_edit);
  1843.                    strcat(buffer, buf);
  1844.                    if (( old_raw = RawState()) == ON)
  1845.                      Raw(OFF);
  1846.                    (void) system_call((char *) buffer+2, SH, TRUE, TRUE);
  1847.                    if (old_raw == ON)
  1848.                       Raw(ON);
  1849. !                  sprintf(buffer, "~r %s%d.%s", temp_dir, getpid(), temp_edit);
  1850.                              read_in_file(edit_fd, (char *) buffer + 3, 0);
  1851.                    (void) unlink((char *) buffer+3);
  1852.                    SetXYLocation(0, 40);    /* a location not near the next request, so an absolute is used */
  1853. ***************
  1854. *** 359,365 ****
  1855.   
  1856.       char    buf[SLEN];
  1857.   
  1858. !     Write_to_screen("\n\r(Available options at this point are:\n\r\n\r", 0);
  1859.       sprintf(buf, "\t%c?\tPrint this help menu.\n\r", escape_char);
  1860.       Write_to_screen(buf, 0);
  1861.       if (escape_char == TILDE_ESCAPE) /* doesn't make sense otherwise... */
  1862. --- 363,369 ----
  1863.   
  1864.       char    buf[SLEN];
  1865.   
  1866. !     Write_to_screen("\n\rAvailable options at this point are:\n\r\n\r", 0);
  1867.       sprintf(buf, "\t%c?\tPrint this help menu.\n\r", escape_char);
  1868.       Write_to_screen(buf, 0);
  1869.       if (escape_char == TILDE_ESCAPE) /* doesn't make sense otherwise... */
  1870. ***************
  1871. *** 423,429 ****
  1872.       sprintf(buf,
  1873.         "\t.  \tby itself on a line (or a control-D) ends the message.\n\r");
  1874.       Write_to_screen(buf, 0);
  1875. !     Write_to_screen("Continue.)\n\r", 0);
  1876.   }
  1877.   
  1878.   read_in_file(fd, filename, show_user_filename)
  1879. --- 427,433 ----
  1880.       sprintf(buf,
  1881.         "\t.  \tby itself on a line (or a control-D) ends the message.\n\r");
  1882.       Write_to_screen(buf, 0);
  1883. !     Write_to_screen("(Continue.)\n\r", 0);
  1884.   }
  1885.   
  1886.   read_in_file(fd, filename, show_user_filename)
  1887. diff -cbr orig/src/elm.c new/src/elm.c
  1888. *** orig/src/elm.c    Sat Oct 16 18:43:44 1993
  1889. --- new/src/elm.c    Sat Oct 02 09:54:00 1993
  1890. ***************
  1891. *** 53,59 ****
  1892. --- 53,63 ----
  1893.            last_in_folder;    /** for when we receive new mail too...      **/
  1894.       long num;        /** another variable for fun..               **/
  1895.       extern char version_buff[];
  1896. + #ifndef OS2
  1897.       extern int errno;
  1898. + #endif
  1899. +         initpaths();
  1900.   
  1901.       req_mfile = parse_arguments(argc, argv, to_whom);
  1902.   
  1903. ***************
  1904. *** 82,87 ****
  1905. --- 86,92 ----
  1906.         redraw = 0;
  1907.         nufoot = 0;
  1908.         nucurr = 0;
  1909. +       /* move_incoming_mail(); */
  1910.         if ((num = bytes(cur_folder)) != mailfile_size) {
  1911.           dprint(2, (debugfile, "Just received %d bytes more mail (elm)\n",
  1912.               num - mailfile_size));
  1913. ***************
  1914. *** 512,517 ****
  1915. --- 512,518 ----
  1916.           case '>'    : /** backwards compatibility **/
  1917.   
  1918.           case 'C'    :
  1919. +         case 'S'    :
  1920.           case 's'    :  if  (message_count < 1) {
  1921.                    error1("No mail to %s!",
  1922.                      ch != 'C' ? "save" : "copy");
  1923. ***************
  1924. *** 523,529 ****
  1925.                         ch != 'C' ? "Save" : "Copy");
  1926.                    PutLine0(LINES-3,COLUMNS-40,
  1927.                   "(Use '?' to list your folders)");
  1928. !                  if (save(&redraw, FALSE, (ch != 'C'))
  1929.                    && resolve_mode && ch != 'C') {
  1930.                      if((i=next_message(current-1, TRUE)) != -1) {
  1931.                    current = i+1;
  1932. --- 524,530 ----
  1933.                         ch != 'C' ? "Save" : "Copy");
  1934.                    PutLine0(LINES-3,COLUMNS-40,
  1935.                   "(Use '?' to list your folders)");
  1936. !                  if (save(&redraw, FALSE, ch)
  1937.                    && resolve_mode && ch != 'C') {
  1938.                      if((i=next_message(current-1, TRUE)) != -1) {
  1939.                    current = i+1;
  1940. ***************
  1941. *** 720,731 ****
  1942.       ClearScreen();
  1943.       Raw(OFF);
  1944.   
  1945. !     PutLine2(0,0,"Current message number = %d\t\t%d message(s) total\n",
  1946.           current, message_count);
  1947. !     PutLine2(2,0,"Header_page = %d           \t\t%d possible page(s)\n",
  1948.           header_page, (int) (message_count / headers_per_page) + 1);
  1949.   
  1950. !     PutLine1(4,0,"\nCurrent mailfile is %s.\n\n", cur_folder);
  1951.   
  1952.       i = header_page*headers_per_page;    /* starting header */
  1953.   
  1954. --- 725,736 ----
  1955.       ClearScreen();
  1956.       Raw(OFF);
  1957.   
  1958. !     PutLine2(0,0,"Current message number = %d\t\t%d message(s) total\r\n",
  1959.           current, message_count);
  1960. !     PutLine2(2,0,"Header_page = %d           \t\t%d possible page(s)\r\n",
  1961.           header_page, (int) (message_count / headers_per_page) + 1);
  1962.   
  1963. !     PutLine1(4,0,"\r\nCurrent mailfile is %s.\n\r\n\r", cur_folder);
  1964.   
  1965.       i = header_page*headers_per_page;    /* starting header */
  1966.   
  1967. ***************
  1968. *** 737,743 ****
  1969.   
  1970.       while (i <= j) {
  1971.          sprintf(buffer,
  1972. !        "%3d  %-16.16s  %-40.40s  %4d  %d\n\r",
  1973.               i+1,
  1974.               headers[i]->from,
  1975.               headers[i]->subject,
  1976. --- 742,748 ----
  1977.   
  1978.       while (i <= j) {
  1979.          sprintf(buffer,
  1980. !        "%3d  %-16.16s  %-40.40s  %4d  %ld\n\r",
  1981.               i+1,
  1982.               headers[i]->from,
  1983.               headers[i]->subject,
  1984. ***************
  1985. *** 837,841 ****
  1986.       dprint(3, (debugfile, "Check-only: checking \n-> \"%s\"\n",
  1987.           format_long(to_whom, 3)));
  1988.       (void) build_address(strip_commas(to_whom), buffer);
  1989. !     printf("Expands to: %s", format_long(buffer, strlen("Expands to: ")));
  1990.       }
  1991. --- 842,846 ----
  1992.       dprint(3, (debugfile, "Check-only: checking \n-> \"%s\"\n",
  1993.           format_long(to_whom, 3)));
  1994.       (void) build_address(strip_commas(to_whom), buffer);
  1995. !     printf("\r\nExpands to: %s\r\n", format_long(buffer, strlen("Expands to: ")));
  1996.       }
  1997. diff -cbr orig/src/expires.c new/src/expires.c
  1998. *** orig/src/expires.c    Sat Oct 16 18:43:46 1993
  1999. --- new/src/expires.c    Sun Oct 04 09:58:02 1992
  2000. ***************
  2001. *** 52,58 ****
  2002.       int  month = 0, day = 0, year = 0, hour = 0, minute = 0;
  2003.   #ifndef    _POSIX_SOURCE
  2004.       struct tm *localtime();
  2005. !     long time();
  2006.   #endif
  2007.   
  2008.       /** first step is to break down the date given into MM DD YY HH MM
  2009. --- 52,58 ----
  2010.       int  month = 0, day = 0, year = 0, hour = 0, minute = 0;
  2011.   #ifndef    _POSIX_SOURCE
  2012.       struct tm *localtime();
  2013. !     time_t time();
  2014.   #endif
  2015.   
  2016.       /** first step is to break down the date given into MM DD YY HH MM
  2017. diff -cbr orig/src/file.c new/src/file.c
  2018. *** orig/src/file.c    Sat Oct 16 18:43:46 1993
  2019. --- new/src/file.c    Sun Aug 22 09:19:44 1993
  2020. ***************
  2021. *** 42,48 ****
  2022. --- 42,50 ----
  2023.   #undef tolower
  2024.   #endif
  2025.   
  2026. + #ifndef OS2
  2027.   extern int errno;
  2028. + #endif
  2029.   
  2030.   char *error_name(), *error_description(), *strcpy(), *getenv(), *nameof();
  2031.   unsigned long sleep();
  2032. ***************
  2033. *** 50,57 ****
  2034.   unsigned long sleep();
  2035.   
  2036.   int
  2037. ! save(redraw, silently, delete)
  2038. ! int *redraw, silently, delete;
  2039.   {
  2040.       /** Save all tagged messages + current in a folder.  If no messages
  2041.           are tagged, save the current message instead!  This routine
  2042. --- 50,57 ----
  2043.   unsigned long sleep();
  2044.   
  2045.   int
  2046. ! save(redraw, silently, type)
  2047. ! int *redraw, silently, type;
  2048.   {
  2049.       /** Save all tagged messages + current in a folder.  If no messages
  2050.           are tagged, save the current message instead!  This routine
  2051. ***************
  2052. *** 69,74 ****
  2053. --- 69,76 ----
  2054.       char filename[SLEN], address[LONG_STRING], buffer[LONG_STRING];
  2055.       static char helpmsg[LONG_STRING];
  2056.       FILE *save_file;
  2057. +     int delete = (type != 'C');
  2058. +     int reverse = (type == 'S');
  2059.   
  2060.       oldstat = headers[current-1]->status;    /* remember */
  2061.       *redraw = FALSE;
  2062. ***************
  2063. *** 98,103 ****
  2064. --- 100,110 ----
  2065.   
  2066.         if (save_by_name) {
  2067.           /** build default filename to save to **/
  2068. +         if (reverse) {
  2069. +           get_existing_address(buffer, mesgnum);
  2070. +           strcpy(address, strip_parens(buffer));
  2071. +         } 
  2072. +         else
  2073.             get_return(address, mesgnum);
  2074.           get_return_name(address, buffer, TRUE);
  2075.           sprintf(filename, "=%s", buffer);
  2076. ***************
  2077. *** 225,231 ****
  2078.        */
  2079.       if(is_new = ison(headers[number]->status, NEW))
  2080.         clearit(headers[number]->status, NEW);
  2081. !     copy_message("", fd, FALSE, FALSE, TRUE, FALSE, FALSE);
  2082.       if(is_new)
  2083.         setit(headers[number]->status, NEW);
  2084.       current = save_current;
  2085. --- 227,233 ----
  2086.        */
  2087.       if(is_new = ison(headers[number]->status, NEW))
  2088.         clearit(headers[number]->status, NEW);
  2089. !       copy_message("", fd, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE);
  2090.       if(is_new)
  2091.         setit(headers[number]->status, NEW);
  2092.       current = save_current;
  2093. diff -cbr orig/src/file_util.c new/src/file_util.c
  2094. *** orig/src/file_util.c    Sat Oct 16 18:43:46 1993
  2095. --- new/src/file_util.c    Fri Mar 20 23:41:52 1992
  2096. ***************
  2097. *** 35,47 ****
  2098.   #endif
  2099.   
  2100.   #include <signal.h>
  2101. - #include <errno.h>
  2102.   
  2103.   #ifdef BSD
  2104.   # include <sys/wait.h>
  2105.   #endif
  2106.   
  2107.   extern int errno;        /* system error number */
  2108.   
  2109.   char *error_name(), *error_description(), *strcpy(), *getlogin();
  2110.   long  fsize();
  2111. --- 35,48 ----
  2112.   #endif
  2113.   
  2114.   #include <signal.h>
  2115.   
  2116.   #ifdef BSD
  2117.   # include <sys/wait.h>
  2118.   #endif
  2119.   
  2120. + #ifndef OS2
  2121.   extern int errno;        /* system error number */
  2122. + #endif
  2123.   
  2124.   char *error_name(), *error_description(), *strcpy(), *getlogin();
  2125.   long  fsize();
  2126. ***************
  2127. *** 57,63 ****
  2128.       **/
  2129.   
  2130.       int ok = 1;
  2131. -     extern int errno;    /* system error number! */
  2132.       struct stat buffer;
  2133.   
  2134.       if (stat(name, &buffer) != 0)
  2135. --- 58,63 ----
  2136. ***************
  2137. *** 86,91 ****
  2138. --- 86,95 ----
  2139.   
  2140.       int the_stat = 0, pid, w;
  2141.       struct stat stat_buf;
  2142. + #ifdef OS2
  2143. +         the_stat = (access(file, mode) == 0) ? 0 : (errno == 0) ? 1 : errno;
  2144. + #else
  2145.       void _exit(), exit();
  2146.   #if defined(BSD) && !defined(WEXITSTATUS)
  2147.       union wait status;
  2148. ***************
  2149. *** 134,139 ****
  2150. --- 138,145 ----
  2151.   
  2152.       signal(SIGINT, istat);
  2153.       signal(SIGQUIT, qstat);
  2154. + #endif
  2155.       if (the_stat == 0) {
  2156.         if (stat(file, &stat_buf) == 0) {
  2157.           w = stat_buf.st_mode & S_IFMT;
  2158. ***************
  2159. *** 159,164 ****
  2160. --- 165,183 ----
  2161.   
  2162.       FILE *fd;
  2163.       int the_stat = 0, pid, w, preexisted = 0;
  2164. + #ifdef OS2
  2165. +     errno = 0;
  2166. +     if (access(file, ACCESS_EXISTS) == 0)
  2167. +       preexisted = 1;
  2168. +     if ((fd = fopen(file, mode)) == NULL)
  2169. +       the_stat = errno;
  2170. +     else {
  2171. +       fclose(fd);        /* don't just leave it open! */
  2172. +       if(!preexisted)    /* don't leave it if this test created it! */
  2173. +         unlink(file);
  2174. +       the_stat = 0;
  2175. +     }
  2176. + #else
  2177.       void _exit(), exit();
  2178.   #if defined(BSD) && !defined(WEXITSTATUS)
  2179.       union wait status;
  2180. ***************
  2181. *** 210,215 ****
  2182. --- 229,235 ----
  2183.   
  2184.       signal(SIGINT, istat);
  2185.       signal(SIGQUIT, qstat);
  2186. + #endif
  2187.   
  2188.       return(the_stat);
  2189.   }
  2190. ***************
  2191. *** 339,347 ****
  2192.       /* now display the appropriate message if there isn't mail in it */
  2193.       switch(retcode) {
  2194.   
  2195. !     case -1:    printf("You have no permission to read %s!\n\r", mfile);
  2196.               break;
  2197. !     case 1:        printf("You have no mail.\n\r");
  2198.               break;
  2199.       case 2:        no_ret(firstline) /* remove newline before using */
  2200.               printf("Your mail is being forwarded to %s.\n\r",
  2201. --- 359,367 ----
  2202.       /* now display the appropriate message if there isn't mail in it */
  2203.       switch(retcode) {
  2204.   
  2205. !     case -1:    printf("\r\nYou have no permission to read %s!\r\n", mfile);
  2206.               break;
  2207. !     case 1:        printf("\r\nYou have no mail.\r\n");
  2208.               break;
  2209.       case 2:        no_ret(firstline) /* remove newline before using */
  2210.               printf("Your mail is being forwarded to %s.\n\r",
  2211. diff -cbr orig/src/fileio.c new/src/fileio.c
  2212. *** orig/src/fileio.c    Sat Oct 16 18:43:46 1993
  2213. --- new/src/fileio.c    Thu May 04 21:32:02 1995
  2214. ***************
  2215. *** 38,44 ****
  2216. --- 38,46 ----
  2217.   #undef tolower
  2218.   #endif
  2219.   
  2220. + #ifndef OS2
  2221.   extern int errno;
  2222. + #endif
  2223.   
  2224.   char *error_name(), *index();
  2225.   
  2226. ***************
  2227. *** 48,57 ****
  2228.            remote,
  2229.            update_status,
  2230.            mmdf_head,
  2231. !          remail)
  2232.   char *prefix;
  2233.   FILE *dest_file;
  2234. ! int  remove_header, remote, update_status, mmdf_head, remail;
  2235.   {
  2236.       /** Copy current message to destination file, with optional 'prefix'
  2237.           as the prefix for each line.  If remove_header is true, it will
  2238. --- 50,60 ----
  2239.            remote,
  2240.            update_status,
  2241.            mmdf_head,
  2242. !            remail,
  2243. !            decrypt)
  2244.   char *prefix;
  2245.   FILE *dest_file;
  2246. ! int  remove_header, remote, update_status, mmdf_head, remail, decrypt;
  2247.   {
  2248.       /** Copy current message to destination file, with optional 'prefix'
  2249.           as the prefix for each line.  If remove_header is true, it will
  2250. ***************
  2251. *** 68,79 ****
  2252.           line at the end of the headers.  It never copies an existing one.
  2253.       **/
  2254.   
  2255. !     char buffer[SLEN];
  2256.       register struct header_rec *current_header = headers[current-1];
  2257.       register int  lines, front_line, next_front,
  2258.             in_header = 1, first_line = TRUE, ignoring = FALSE;
  2259.       int    end_header = 0;
  2260.       int sender_added = 0;
  2261.   
  2262.         /** get to the first line of the message desired **/
  2263.   
  2264. --- 71,86 ----
  2265.           line at the end of the headers.  It never copies an existing one.
  2266.       **/
  2267.   
  2268. !     char buffer[LONG_STRING];
  2269.       register struct header_rec *current_header = headers[current-1];
  2270.       register int  lines, front_line, next_front,
  2271.             in_header = 1, first_line = TRUE, ignoring = FALSE;
  2272.       int    end_header = 0;
  2273.       int sender_added = 0;
  2274. +     FILE *cryptfile;
  2275. +     char cfilename[SLEN], dfilename[SLEN], basefilename[SLEN];
  2276. +     char ans;
  2277. +     int  tlines;
  2278.   
  2279.         /** get to the first line of the message desired **/
  2280.   
  2281. ***************
  2282. *** 100,108 ****
  2283.       next_front = TRUE;
  2284.   
  2285.       while (lines) {
  2286. !       if (fgets(buffer, SLEN, mailfile) == NULL)
  2287.           break;
  2288.   
  2289.         front_line = next_front;
  2290.   
  2291.         if(buffer[strlen(buffer)-1] == '\n') {
  2292. --- 107,116 ----
  2293.       next_front = TRUE;
  2294.   
  2295.       while (lines) {
  2296. !       if (fgets(buffer, sizeof(buffer), mailfile) == NULL)
  2297.           break;
  2298.   
  2299. +       fixline(buffer);
  2300.         front_line = next_front;
  2301.   
  2302.         if(buffer[strlen(buffer)-1] == '\n') {
  2303. ***************
  2304. *** 233,238 ****
  2305. --- 233,239 ----
  2306.         }
  2307.   #else
  2308.         if (first_word(buffer, "From ")) {
  2309. +         if (strcmp(sendmail, mailer) != 0)
  2310.           if (fprintf(dest_file, "%s%s remote from %s\n",
  2311.               prefix, buffer, hostname) == EOF) {
  2312.           Write_to_screen("\n\rWrite in copy_message failed\n\r", 0);
  2313. ***************
  2314. *** 258,263 ****
  2315. --- 266,272 ----
  2316.       else { /* forwarding */
  2317.   
  2318.         if (first_word(buffer, "Received:"   ) ||
  2319. +           first_word(buffer, "From "       ) ||
  2320.             first_word(buffer, ">From"       ) ||
  2321.             first_word(buffer, "Status:"     ) ||
  2322.             first_word(buffer, "Return-Path:"))
  2323. ***************
  2324. *** 278,283 ****
  2325. --- 287,375 ----
  2326.         }
  2327.         else { /* not in header */
  2328.           /* Process checks that occur after the header area */
  2329. +     /***  Check to see if text is a PGP message  ***/
  2330. +     /*  if buffer starts with "-----BEGIN PGP MESSAGE-----"
  2331. +            AND decrypt = TRUE
  2332. +           divert rest of message to cryptfile
  2333. +           decrypt cryptfile file.
  2334. +           if success, copy decrypted file into dest_file, then set
  2335. +               lines = 0 to stop copying from mailfile.
  2336. +           else just continue
  2337. +           continue
  2338. +     */
  2339. +     if( first_word(buffer, "-----BEGIN PGP MESSAGE-----")
  2340. +        && decrypt ) {
  2341. +       PutLine1(LINES-1,0,"Message encrypted with PGP. Do you wish to decrypt? (y/n) y%c", BACKSPACE);
  2342. +       fflush(stdout);
  2343. +       ans = ReadCh();
  2344. +       if( tolower(ans) != 'n' ) {
  2345. +         Write_to_screen("Yes.",0);
  2346. +         sprintf(basefilename,"%s%d", temp_dir, getpid());
  2347. +         strcpy(cfilename,basefilename);
  2348. +         strcpy(dfilename,basefilename);
  2349. +         strcat(cfilename,".asc");
  2350. +         strcat(dfilename,".txt");
  2351. +         if ((cryptfile = fopen(cfilename,"wt")) == NULL) {
  2352. +           if(batch_only)
  2353. +         printf("Could not create file %s (%s).\n", cfilename, error_name(errno));
  2354. +           else
  2355. +         error2("Could not create file %s (%s).", cfilename, error_name(errno));
  2356. +         }
  2357. +         else {
  2358. +           chown(cfilename, userid, groupid);
  2359. +           tlines = lines;
  2360. +           fputs(buffer,cryptfile);
  2361. +           while( tlines )  {
  2362. +         if(fgets(buffer, sizeof(buffer), mailfile) == NULL)
  2363. +           break;
  2364. +         fixline(buffer);
  2365. +         fputs(buffer,cryptfile);
  2366. +         tlines--;
  2367. +           }
  2368. +           fclose(cryptfile);
  2369. +           sprintf(buffer, "pgp %s -o %s", cfilename, dfilename);
  2370. +           puts("\r\n");
  2371. +           if( !system_call(buffer, SH, FALSE, FALSE) ) {
  2372. +         fputs("[pgp-encrypt]\n", dest_file);
  2373. +         if ((cryptfile = fopen(dfilename, "rt")) != NULL)
  2374. +           while( !feof(cryptfile) ) {
  2375. +             if( fgets(buffer, sizeof(buffer), cryptfile) != NULL )
  2376. +               if (strlen(buffer) >= 6 && strncmp(buffer, "[pgp-", 5) == 0
  2377. +               && strncmp(buffer + strlen(buffer) - 2, "]\n", 2) == 0)
  2378. +             /* skip */;
  2379. +               else
  2380. +             fprintf(dest_file, "%s%s", prefix, buffer);
  2381. +           }
  2382. +           }
  2383. +           else {
  2384. +         printf("Error while decrypting.  Copying message as-is.\n\r");
  2385. +         cryptfile = fopen(cfilename, "rt");
  2386. +         while( !feof(cryptfile) ) {
  2387. +           if (fgets(buffer, sizeof(buffer), cryptfile) != NULL)
  2388. +             fprintf(dest_file, "%s%s", prefix, buffer);
  2389. +         }
  2390. +           }
  2391. +           lines = 0;
  2392. +           fclose(cryptfile);
  2393. +           if( !access(cfilename,0) )
  2394. +         if( remove(cfilename) )
  2395. +           printf("Could not delete file %s (%s).\n\r", cfilename, error_name(errno));
  2396. +           if( !access(dfilename,0) )
  2397. +         if( remove(dfilename) )
  2398. +           printf("Could not delete file %s (%s).\n\r", dfilename, error_name(errno));
  2399. +         }
  2400. +       }
  2401. +       else
  2402. +         Write_to_screen("No.",0);
  2403. +     } /*  end check for PGP  */
  2404.   
  2405.   #ifndef MMDF
  2406.       if(first_word(buffer, "From ") && (real_from(buffer, NULL))) {
  2407. diff -cbr orig/src/forms.c new/src/forms.c
  2408. *** orig/src/forms.c    Sat Oct 16 18:43:48 1993
  2409. --- new/src/forms.c    Sun Mar 15 14:19:14 1992
  2410. ***************
  2411. *** 49,55 ****
  2412. --- 49,57 ----
  2413.   #include "headers.h"
  2414.   #include <errno.h>
  2415.   
  2416. + #ifndef OS2
  2417.   extern int errno;
  2418. + #endif
  2419.   
  2420.   char *error_name(), *strcat(), *strcpy();
  2421.   
  2422. ***************
  2423. *** 103,109 ****
  2424.         return(-1);
  2425.       }
  2426.   
  2427. !     sprintf(newfname, "%s%s%d", temp_dir, temp_form_file, getpid());
  2428.   
  2429.       if ((newform = fopen(newfname, "w")) == NULL) {
  2430.         error("Couldn't open newform file for form output!");
  2431. --- 105,111 ----
  2432.         return(-1);
  2433.       }
  2434.   
  2435. !     sprintf(newfname, "%s%d%s", temp_dir, getpid(), temp_form_file);
  2436.   
  2437.       if ((newform = fopen(newfname, "w")) == NULL) {
  2438.         error("Couldn't open newform file for form output!");
  2439. ***************
  2440. *** 136,149 ****
  2441.           error2("Error %s unlinking file %s.", error_name(errno), filename);
  2442.           return(-1);
  2443.         }
  2444. !       if (link(newfname, filename)) {
  2445. !         error3("Error %s linking %s to %s.", error_name(errno), 
  2446.               newfname, filename);
  2447.           return(-1);
  2448.         }
  2449.       }
  2450. !     if (unlink(newfname)) {
  2451.         error2("Error %s unlinking file %s.", error_name(errno), newfname);
  2452.         return(-1);
  2453.       }
  2454. --- 138,150 ----
  2455.           error2("Error %s unlinking file %s.", error_name(errno), filename);
  2456.           return(-1);
  2457.         }
  2458. !       if (rename(newfname, filename)) {
  2459. !         error3("Error %s renaming %s to %s.", error_name(errno),
  2460.               newfname, filename);
  2461.           return(-1);
  2462.         }
  2463.       }
  2464. !         else if (unlink(newfname)) {
  2465.         error2("Error %s unlinking file %s.", error_name(errno), newfname);
  2466.         return(-1);
  2467.       }
  2468. diff -cbr orig/src/in_utils.c new/src/in_utils.c
  2469. *** orig/src/in_utils.c    Sat Oct 16 18:43:48 1993
  2470. --- new/src/in_utils.c    Tue Aug 04 21:45:24 1992
  2471. ***************
  2472. *** 32,40 ****
  2473.   #  undef tolower
  2474.   #endif
  2475.   
  2476.   extern int errno;        /* system error number */
  2477.   unsigned alarm();
  2478.   
  2479.   #define isstopchar(c)        (c == ' ' || c == '\t' || c == '/')
  2480.   #define isslash(c)        (c == '/')
  2481. --- 32,41 ----
  2482.   #  undef tolower
  2483.   #endif
  2484.   
  2485. + #ifndef OS2
  2486.   extern int errno;        /* system error number */
  2487.   unsigned alarm();
  2488. + #endif
  2489.   
  2490.   #define isstopchar(c)        (c == ' ' || c == '\t' || c == '/')
  2491.   #define isslash(c)        (c == '/')
  2492. ***************
  2493. *** 479,485 ****
  2494.   
  2495.       if (timeout > 0) {
  2496.         alarm((unsigned) timeout);
  2497. ! #ifdef    BSD
  2498.         if (setjmp(GetPromptBuf)) {
  2499.           InGetPrompt = 0;
  2500.           ch = NO_OP_COMMAND;
  2501. --- 480,486 ----
  2502.   
  2503.       if (timeout > 0) {
  2504.         alarm((unsigned) timeout);
  2505. ! #if defined(BSD) || defined(OS2)
  2506.         if (setjmp(GetPromptBuf)) {
  2507.           InGetPrompt = 0;
  2508.           ch = NO_OP_COMMAND;
  2509. diff -cbr orig/src/init.c new/src/init.c
  2510. *** orig/src/init.c    Sat Oct 16 18:43:48 1993
  2511. --- new/src/init.c    Sun Aug 22 12:34:08 1993
  2512. ***************
  2513. *** 80,86 ****
  2514. --- 80,88 ----
  2515.   #undef tolower
  2516.   #endif
  2517.   
  2518. + #ifndef OS2
  2519.   extern int errno;        /* system error number on failure */
  2520. + #endif
  2521.   extern char version_buff[];
  2522.   
  2523.   char *error_name(), *error_description();
  2524. ***************
  2525. *** 188,215 ****
  2526.         if ((i = InitScreen()) < 0) {
  2527.           if (i == -1) {
  2528.             printf(
  2529. ! "Sorry, but you must specify what type of terminal you're on if you want to\n");
  2530.             printf(
  2531. ! "run the \"elm\" program. (You need your environment variable \"TERM\" set.)\n"
  2532.                );
  2533.             dprint(1,(debugfile,"No $TERM variable in environment!\n"));
  2534.           }
  2535.           else if (i == -2) {
  2536.             printf(
  2537. ! "You need a cursor-addressable terminal to run \"elm\" and I can't find any\n");
  2538.             printf(
  2539. ! "kind of termcap entry for \"%s\" - check your \"TERM\" setting...\n",
  2540.              getenv("TERM"));
  2541.             dprint(1,
  2542.           (debugfile,"$TERM variable is an unknown terminal type!\n"));
  2543.           } else {
  2544. !           printf("Failed trying to initialize your terminal entry: unknown return code %d\n", i);
  2545. !           dprint(1, (debugfile, "Initscreen returned unknown code: %d\n",
  2546.             i));
  2547.           }
  2548.           Raw(OFF);
  2549.           exit(1);    /* all the errors share this exit statement */
  2550.         }
  2551.       }
  2552.   
  2553.       if (debug < 5) {    /* otherwise let the system trap 'em! */
  2554. --- 190,222 ----
  2555.         if ((i = InitScreen()) < 0) {
  2556.           if (i == -1) {
  2557.             printf(
  2558. ! "Sorry, but you must specify what type of terminal you're on if you want to\r\n");
  2559.             printf(
  2560. ! "run the \"elm\" program. (You need your environment variable \"TERM\" set.)\r\n"
  2561.                );
  2562.             dprint(1,(debugfile,"No $TERM variable in environment!\n"));
  2563.           }
  2564.           else if (i == -2) {
  2565.             printf(
  2566. ! "You need a cursor-addressable terminal to run \"elm\" and I can't find any\r\n");
  2567.             printf(
  2568. ! "kind of termcap entry for \"%s\" - check your \"TERM\" setting...\r\n",
  2569.              getenv("TERM"));
  2570. +           printf(
  2571. + "Or check your TERMCAP setting or termcap database file.\r\n");
  2572.             dprint(1,
  2573.           (debugfile,"$TERM variable is an unknown terminal type!\n"));
  2574.           } else {
  2575. !           printf("Failed trying to initialize your terminal entry: unknown return code %d\r\n", i);
  2576. !           dprint(1, (debugfile, "Initscreen returned unknown code: %d\r\n",
  2577.             i));
  2578.           }
  2579.           Raw(OFF);
  2580.           exit(1);    /* all the errors share this exit statement */
  2581.         }
  2582. +           EndBold();
  2583. +           EndHalfbright();
  2584. +           EndInverse();
  2585.       }
  2586.   
  2587.       if (debug < 5) {    /* otherwise let the system trap 'em! */
  2588. ***************
  2589. *** 217,225 ****
  2590.         signal(SIGTERM, term_signal);     /* Terminate signal         */
  2591.         signal(SIGILL,  ill_signal);        /* Illegal instruction      */
  2592.         signal(SIGFPE,  fpe_signal);        /* Floating point exception */
  2593.         signal(SIGBUS,  bus_signal);        /* Bus error              */
  2594. -       signal(SIGSEGV, segv_signal);        /* Segmentation Violation   */
  2595.         signal(SIGHUP,  hup_signal);        /* HangUp (line dropped)    */
  2596.       }
  2597.       else {
  2598.         dprint(3,(debugfile,
  2599. --- 224,234 ----
  2600.         signal(SIGTERM, term_signal);     /* Terminate signal         */
  2601.         signal(SIGILL,  ill_signal);        /* Illegal instruction      */
  2602.         signal(SIGFPE,  fpe_signal);        /* Floating point exception */
  2603. + #ifndef OS2
  2604.         signal(SIGBUS,  bus_signal);        /* Bus error              */
  2605.         signal(SIGHUP,  hup_signal);        /* HangUp (line dropped)    */
  2606. + #endif
  2607. +       signal(SIGSEGV, segv_signal);        /* Segmentation Violation   */
  2608.       }
  2609.       else {
  2610.         dprint(3,(debugfile,
  2611. ***************
  2612. *** 233,239 ****
  2613. --- 242,250 ----
  2614.   #else
  2615.       signal(SIGALRM, alarm_signal);        /* Process Timer Alarm      */
  2616.   #endif
  2617. + #ifndef OS2
  2618.       signal(SIGPIPE, pipe_signal);        /* Illegal Pipe Operation   */
  2619. + #endif
  2620.   #ifdef SIGTSTP
  2621.       signal(SIGTSTP, sig_user_stop);        /* Suspend signal from tty  */
  2622.       signal(SIGCONT, sig_return_from_user_stop);    /* Continue Process */
  2623. ***************
  2624. *** 295,307 ****
  2625.         }
  2626.       }
  2627.   
  2628.       /* Determine the default mail file name.
  2629.        *
  2630.        * First look for an environment variable MAIL, then
  2631.        * use then mailhome if it is not found
  2632.        */
  2633.       if ((cp = getenv("MAIL")) == NULL)
  2634. !         sprintf(defaultfile, "%s%s", mailhome, username);
  2635.           else
  2636.           strcpy(defaultfile, cp);
  2637.   
  2638. --- 306,329 ----
  2639.         }
  2640.       }
  2641.   
  2642. + #ifdef OS2
  2643. +     getfromdomain(hostfromname, sizeof(hostfromname));
  2644. + #else
  2645. +     strcpy(hostfromname, hostfullname);
  2646. + #endif
  2647.       /* Determine the default mail file name.
  2648.        *
  2649.        * First look for an environment variable MAIL, then
  2650.        * use then mailhome if it is not found
  2651.        */
  2652.       if ((cp = getenv("MAIL")) == NULL)
  2653. ! #ifdef OS2
  2654. !         if (maildir)
  2655. !         sprintf(defaultfile, "%s%s/newmail%s", mailhome, username, mailext);
  2656. !         else
  2657. ! #endif
  2658. !         sprintf(defaultfile, "%s%s%s", mailhome, username, mailext);
  2659.       else
  2660.           strcpy(defaultfile, cp);
  2661.   
  2662. ***************
  2663. *** 352,361 ****
  2664. --- 374,385 ----
  2665.   
  2666.       /** fix the shell if needed **/
  2667.   
  2668. + #ifndef OS2
  2669.       if (shell[0] != '/') {
  2670.          sprintf(buffer, "/bin/%s", shell);
  2671.          strcpy(shell, buffer);
  2672.       }
  2673. + #endif
  2674.   
  2675.       if (! mail_only && ! check_only) {
  2676.   
  2677. diff -cbr orig/src/leavembox.c new/src/leavembox.c
  2678. *** orig/src/leavembox.c    Sat Oct 16 18:43:50 1993
  2679. --- new/src/leavembox.c    Sun Aug 22 09:19:46 1993
  2680. ***************
  2681. *** 51,56 ****
  2682. --- 51,57 ----
  2683.   **/
  2684.   
  2685.   #include "headers.h"
  2686. + #include <string.h>
  2687.   #include <sys/types.h>
  2688.   #include <sys/stat.h>
  2689.   #ifdef LOCK_BY_FLOCK
  2690. ***************
  2691. *** 84,90 ****
  2692. --- 85,93 ----
  2693.   # endif /* NOUTIMBUF */
  2694.   #endif /* BSD */
  2695.   
  2696. + #ifndef OS2
  2697.   extern int errno;
  2698. + #endif
  2699.   
  2700.   char *error_name(), *error_description(), *strcpy(), *rindex();
  2701.   unsigned short getegid();
  2702. ***************
  2703. *** 425,431 ****
  2704.           if(headers[i]->exit_disposition == STORE) {
  2705.             current = i+1;
  2706.             dprint(2, (debugfile, "#%d, ", current));
  2707. !           copy_message("", temp, FALSE, FALSE, TRUE, FALSE, FALSE);
  2708.           }
  2709.         }
  2710.         fclose(temp);
  2711. --- 428,434 ----
  2712.           if(headers[i]->exit_disposition == STORE) {
  2713.             current = i+1;
  2714.             dprint(2, (debugfile, "#%d, ", current));
  2715. !             copy_message("", temp, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE);
  2716.           }
  2717.         }
  2718.         fclose(temp);
  2719. ***************
  2720. *** 437,443 ****
  2721.        * temp file, then remove original and copy whole temp file over.
  2722.        */
  2723.       if (to_keep > 0) {
  2724. !       sprintf(temp_keep_file, "%s%s%d", temp_dir, temp_file, getpid());
  2725.         if ((errno = can_open(temp_keep_file, "w"))) {
  2726.           error1(
  2727.   "Permission to create temp file %s for writing denied! Leaving folder intact.",
  2728. --- 440,446 ----
  2729.        * temp file, then remove original and copy whole temp file over.
  2730.        */
  2731.       if (to_keep > 0) {
  2732. !       sprintf(temp_keep_file, "%s%d%s", temp_dir, getpid(), temp_file);
  2733.         if ((errno = can_open(temp_keep_file, "w"))) {
  2734.           error1(
  2735.   "Permission to create temp file %s for writing denied! Leaving folder intact.",
  2736. ***************
  2737. *** 469,475 ****
  2738.           if(headers[i]->exit_disposition == KEEP) {
  2739.             current = i+1;
  2740.             dprint(2, (debugfile, "#%d, ", current));
  2741. !           copy_message("", temp, FALSE, FALSE, TRUE, FALSE, FALSE);
  2742.           }
  2743.         }
  2744.         if ( fclose(temp) == EOF ) {
  2745. --- 472,478 ----
  2746.           if(headers[i]->exit_disposition == KEEP) {
  2747.             current = i+1;
  2748.             dprint(2, (debugfile, "#%d, ", current));
  2749. !             copy_message("", temp, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE);
  2750.           }
  2751.         }
  2752.         if ( fclose(temp) == EOF ) {
  2753. ***************
  2754. *** 486,491 ****
  2755. --- 489,495 ----
  2756.          * folder and we aren't keeping empty non-spool folders,
  2757.          * simply remove the old original folder and that's it!
  2758.          */
  2759. +           fclose(mailfile);
  2760.         (void)unlink(cur_folder);
  2761.   #ifdef SIGTSTP
  2762.         signal(SIGTSTP, oldstop);
  2763. ***************
  2764. *** 534,539 ****
  2765. --- 538,544 ----
  2766.           need_to_copy = TRUE;
  2767.   
  2768.         if(!need_to_copy) {
  2769. +             fclose(mailfile);
  2770.           unlink(cur_folder);
  2771.           if (link(temp_keep_file, cur_folder) != 0) {
  2772.             if(errno == EXDEV || errno == EEXIST) {
  2773. ***************
  2774. *** 651,663 ****
  2775.           get_folder_type()), and put it in the static area lock_name.
  2776.           Return lock_name for informational purposes.
  2777.        **/
  2778.   
  2779.   #ifdef XENIX
  2780.       /* lock is /tmp/[basename of file_to_lock].mlk */
  2781.       sprintf(lock_name, "/tmp/%.10s.mlk", rindex(file_to_lock, '/')+1);
  2782.   #else
  2783.       /* lock is [file_to_lock].lock */
  2784. !     sprintf(lock_name, "%s.lock", file_to_lock);
  2785.   #endif
  2786.       return(lock_name);
  2787.   }
  2788. --- 656,675 ----
  2789.           get_folder_type()), and put it in the static area lock_name.
  2790.           Return lock_name for informational purposes.
  2791.        **/
  2792. +     char *ptr;
  2793.   
  2794.   #ifdef XENIX
  2795.       /* lock is /tmp/[basename of file_to_lock].mlk */
  2796.       sprintf(lock_name, "/tmp/%.10s.mlk", rindex(file_to_lock, '/')+1);
  2797.   #else
  2798.       /* lock is [file_to_lock].lock */
  2799. !     strcpy(lock_name, file_to_lock);
  2800. ! #ifdef OS2
  2801. !     if ( (ptr = strrchr(lock_name, '.')) != NULL
  2802. !          && strcmp(ptr, mailext) == 0 )
  2803. !       *ptr = 0;
  2804. ! #endif
  2805. !     strcat(lock_name, ".lck");
  2806.   #endif
  2807.       return(lock_name);
  2808.   }
  2809. ***************
  2810. *** 730,736 ****
  2811.         do {
  2812.   
  2813.       errno = 0;
  2814. !     if((create_fd=open(lock_name,O_WRONLY | O_CREAT | O_EXCL,0444)) != -1)
  2815.         break;
  2816.       else {
  2817.         if(errno != EEXIST) {
  2818. --- 742,748 ----
  2819.         do {
  2820.   
  2821.       errno = 0;
  2822. !     if((create_fd=open(lock_name,O_WRONLY | O_CREAT | O_EXCL,0666)) != -1)
  2823.         break;
  2824.       else {
  2825.         if(errno != EEXIST) {
  2826. ***************
  2827. *** 767,773 ****
  2828.         } while (create_iteration++ < MAX_ATTEMPTS);
  2829.         clear_error();
  2830.   
  2831. !       if(errno != 0) {
  2832.   
  2833.       /* we weren't able to create the lock file */
  2834.   
  2835. --- 779,785 ----
  2836.         } while (create_iteration++ < MAX_ATTEMPTS);
  2837.         clear_error();
  2838.   
  2839. !       if(errno != 0 && errno != ENOENT) {
  2840.   
  2841.       /* we weren't able to create the lock file */
  2842.   
  2843. ***************
  2844. *** 796,802 ****
  2845.       }
  2846.   
  2847.       /* we've removed the bad lock, let's try to assert lock once more */
  2848. !     if((create_fd=open(lock_name,O_WRONLY | O_CREAT | O_EXCL,0444)) == -1){
  2849.   
  2850.         /* still can't lock it - just give up */
  2851.         dprint(1, (debugfile,
  2852. --- 808,814 ----
  2853.       }
  2854.   
  2855.       /* we've removed the bad lock, let's try to assert lock once more */
  2856. !     if((create_fd=open(lock_name,O_WRONLY | O_CREAT | O_EXCL,0666)) == -1){
  2857.   
  2858.         /* still can't lock it - just give up */
  2859.         dprint(1, (debugfile,
  2860. diff -cbr orig/src/mailmsg1.c new/src/mailmsg1.c
  2861. *** orig/src/mailmsg1.c    Sat Oct 16 18:43:50 1993
  2862. --- new/src/mailmsg1.c    Thu Sep 16 22:17:42 1993
  2863. ***************
  2864. *** 107,112 ****
  2865. --- 107,121 ----
  2866.       if (is_a_response && replying)
  2867.         generate_reply_to(current-1);
  2868.   
  2869. + #ifdef OS2
  2870. +     /* Reply-To: from UUPC.RC (see os2util.c), from Frank Behrens */
  2871. +     if (strlen(_reply_to) > 0)
  2872. +         {
  2873. +        strcpy(reply_to, _reply_to);
  2874. +        dprint(4, (debugfile, "Add default Reply-To: %s\n", _reply_to));
  2875. +     }
  2876. + #endif
  2877.       /* and mail that puppy outta here! */
  2878.   
  2879.       return(mail(copy_msg, edit_message, form_letter));
  2880. diff -cbr orig/src/mailmsg2.c new/src/mailmsg2.c
  2881. *** orig/src/mailmsg2.c    Sat Oct 16 18:43:52 1993
  2882. --- new/src/mailmsg2.c    Fri Apr 22 21:14:06 1994
  2883. ***************
  2884. *** 68,74 ****
  2885. --- 68,76 ----
  2886.   #undef toupper
  2887.   #endif
  2888.   
  2889. + #ifndef OS2
  2890.   extern int errno;
  2891. + #endif
  2892.   extern char version_buff[];
  2893.   
  2894.   char *error_name(), *error_description(), *strip_parens();
  2895. ***************
  2896. *** 111,117 ****
  2897.       **/
  2898.   
  2899.       FILE *reply, *real_reply; /* second is post-input buffer */
  2900. !     char *whole_msg_file, *tempnam();
  2901.       char filename[SLEN], fname[SLEN], copy_file[SLEN],
  2902.                very_long_buffer[VERY_LONG_STRING], mailerflags[NLEN];
  2903.       int ch, sys_status;
  2904. --- 113,119 ----
  2905.       **/
  2906.   
  2907.       FILE *reply, *real_reply; /* second is post-input buffer */
  2908. !     char *whole_msg_file = NULL, *tempnam();
  2909.       char filename[SLEN], fname[SLEN], copy_file[SLEN],
  2910.                very_long_buffer[VERY_LONG_STRING], mailerflags[NLEN];
  2911.       int ch, sys_status;
  2912. ***************
  2913. *** 119,124 ****
  2914. --- 121,127 ----
  2915.       int      already_has_text = FALSE;        /* we need an ADDRESS */
  2916.       int     signature_done = FALSE;
  2917.       int     need_redraw = 0;
  2918. +     int      resent = forwarding && !edit_message;
  2919.   
  2920.       static int cancelled_msg = 0;
  2921.   
  2922. ***************
  2923. *** 129,135 ****
  2924.   
  2925.       /** first generate the temporary filename **/
  2926.   
  2927. !     sprintf(filename,"%s%s%d", temp_dir, temp_file, getpid());
  2928.   
  2929.       /** if possible, let's try to recall the last message? **/
  2930.   
  2931. --- 132,138 ----
  2932.   
  2933.       /** first generate the temporary filename **/
  2934.   
  2935. !     sprintf(filename,"%s%d%s", temp_dir, getpid(), temp_file);
  2936.   
  2937.       /** if possible, let's try to recall the last message? **/
  2938.   
  2939. ***************
  2940. *** 162,168 ****
  2941.       }
  2942.   
  2943.       if (copy_msg == FORM) {
  2944. !       sprintf(fname, "%s%s%d", temp_dir, temp_form_file, getpid());
  2945.         fclose(reply);    /* we can't retransmit a form! */
  2946.         if (access(fname,ACCESS_EXISTS) != 0) {
  2947.           if(batch_only)
  2948. --- 165,171 ----
  2949.       }
  2950.   
  2951.       if (copy_msg == FORM) {
  2952. !       sprintf(fname, "%s%d%s", temp_dir, getpid(), temp_form_file);
  2953.         fclose(reply);    /* we can't retransmit a form! */
  2954.         if (access(fname,ACCESS_EXISTS) != 0) {
  2955.           if(batch_only)
  2956. ***************
  2957. *** 176,194 ****
  2958.         rename(fname, filename);
  2959.       }
  2960.       else if (copy_msg && ! retransmit) {  /* if retransmit we have it! */
  2961. !       if (attribution[0]) {
  2962.           fprintf(reply, attribution, headers[current-1]->from);
  2963.           fputc('\n', reply);
  2964.         }
  2965. -       else if (forwarding) {
  2966. -         fputs("Forwarded message:\n", reply);
  2967. -       }
  2968.         if (edit_message) {
  2969. !         copy_message(prefixchars, reply, noheader,FALSE,FALSE,TRUE,FALSE);
  2970.           already_has_text = TRUE;    /* we just added it, right? */
  2971.         }
  2972.         else
  2973. !         copy_message("", reply, noheader, FALSE, FALSE, TRUE, FALSE);
  2974.       }
  2975.   
  2976.           /* append signature now if we are going to use an external editor */
  2977. --- 179,198 ----
  2978.         rename(fname, filename);
  2979.       }
  2980.       else if (copy_msg && ! retransmit) {  /* if retransmit we have it! */
  2981. !       if (forwarding) {
  2982. !         if (edit_message)
  2983. !           fputs("Forwarded message:\n", reply);
  2984. !       }
  2985. !       else if (attribution[0]) {
  2986.           fprintf(reply, attribution, headers[current-1]->from);
  2987.           fputc('\n', reply);
  2988.         }
  2989.         if (edit_message) {
  2990. !           copy_message(prefixchars, reply, noheader,FALSE,FALSE,TRUE,FALSE,TRUE);
  2991.           already_has_text = TRUE;    /* we just added it, right? */
  2992.         }
  2993.         else
  2994. !           copy_message("", reply, noheader, FALSE, FALSE, TRUE, FALSE, FALSE);
  2995.       }
  2996.   
  2997.           /* append signature now if we are going to use an external editor */
  2998. ***************
  2999. *** 197,203 ****
  3000.           if (already_has_text ||
  3001.              (strcmp(editor,"builtin") != 0 && strcmp(editor,"none") != 0)) {
  3002.            signature_done = TRUE;
  3003. !              if (!retransmit && copy_msg != FORM)
  3004.              already_has_text |= append_sig(reply);
  3005.       }
  3006.   
  3007. --- 201,208 ----
  3008.           if (already_has_text ||
  3009.              (strcmp(editor,"builtin") != 0 && strcmp(editor,"none") != 0)) {
  3010.            signature_done = TRUE;
  3011. !              if (!(forwarding && !edit_message) &&
  3012. !                  !retransmit && copy_msg != FORM)
  3013.              already_has_text |= append_sig(reply);
  3014.       }
  3015.   
  3016. ***************
  3017. *** 262,267 ****
  3018. --- 267,276 ----
  3019.             return(need_redraw);
  3020.           }
  3021.           
  3022. +         if (ch == 's' && 
  3023. +         perhaps_pgp_encode(filename) == -1)
  3024. +           ch = ' ';
  3025.         } while (ch != 's');
  3026.   
  3027.         if (form == YES)
  3028. ***************
  3029. *** 298,310 ****
  3030.   
  3031.       /** grab a copy if the user so desires... **/
  3032.   
  3033. !     if (*copy_file) /* i.e. if copy_file contains a name */
  3034.         save_copy(expanded_to, expanded_cc, expanded_bcc,
  3035.              filename, copy_file, form);
  3036.   
  3037.       /** write all header information into whole_msg_file **/
  3038.   
  3039. !     if((whole_msg_file=tempnam(temp_dir, "snd.")) == NULL) {
  3040.         dprint(1, (debugfile, "couldn't make temp file nam! (mail)\n"));
  3041.         if(batch_only)
  3042.           printf("Sorry - couldn't make temp file name!\n");
  3043. --- 307,319 ----
  3044.   
  3045.       /** grab a copy if the user so desires... **/
  3046.   
  3047. !     if (*copy_file && !no_save) /* i.e. if copy_file contains a name */
  3048.         save_copy(expanded_to, expanded_cc, expanded_bcc,
  3049.              filename, copy_file, form);
  3050.   
  3051.       /** write all header information into whole_msg_file **/
  3052.   
  3053. !     if((whole_msg_file=tempnam(temp_dir, "snd")) == NULL) {
  3054.         dprint(1, (debugfile, "couldn't make temp file nam! (mail)\n"));
  3055.         if(batch_only)
  3056.           printf("Sorry - couldn't make temp file name!\n");
  3057. ***************
  3058. *** 324,345 ****
  3059.             expanded_to, expanded_cc, expanded_bcc, subject));
  3060.   
  3061.       if ((real_reply=
  3062. !        write_header_info(whole_msg_file, expanded_to,
  3063. !          expanded_cc, expanded_bcc, form == YES, FALSE)) == NULL) {
  3064.   
  3065.         /** IT FAILED!!  MEIN GOTT!  Use a dumb mailer instead! **/
  3066.   
  3067.         dprint(3, (debugfile, "** write_header failed: %s\n",
  3068.            error_name(errno)));
  3069.   
  3070. !       if (cc[0] != '\0')          /* copies! */
  3071. !         sprintf(expanded_to,"%s %s", expanded_to, expanded_cc);
  3072.   
  3073.         quote_args(very_long_buffer, strip_parens(strip_commas(expanded_to)));
  3074.         strcpy(expanded_to, very_long_buffer);
  3075.   
  3076. !       sprintf(very_long_buffer, "( (%s -s \"%s\" %s ; %s %s) & ) < %s",
  3077. !           mailx, subject, expanded_to, remove_cmd, filename, filename);
  3078.   
  3079.         if(batch_only)
  3080.           printf("Message sent using dumb mailer %s.\n", mailx);
  3081. --- 333,356 ----
  3082.             expanded_to, expanded_cc, expanded_bcc, subject));
  3083.   
  3084.       if ((real_reply=
  3085. !        write_header_info(whole_msg_file, expanded_to, expanded_cc, 
  3086. !              expanded_bcc, form == YES, FALSE, resent)) == NULL) {
  3087.   
  3088.         /** IT FAILED!!  MEIN GOTT!  Use a dumb mailer instead! **/
  3089.   
  3090.         dprint(3, (debugfile, "** write_header failed: %s\n",
  3091.            error_name(errno)));
  3092.   
  3093. !       if (cc[0] != '\0') {          /* copies! */
  3094. !         strcat(expanded_to, " ");
  3095. !         strcat(expanded_to, expanded_cc);
  3096. !       }
  3097.   
  3098.         quote_args(very_long_buffer, strip_parens(strip_commas(expanded_to)));
  3099.         strcpy(expanded_to, very_long_buffer);
  3100.   
  3101. !       sprintf(very_long_buffer, "%s -f %s -s \"%s\" %s",
  3102. !           mailx, filename, subject, expanded_to);
  3103.   
  3104.         if(batch_only)
  3105.           printf("Message sent using dumb mailer %s.\n", mailx);
  3106. ***************
  3107. *** 359,366 ****
  3108.   
  3109.         fclose(real_reply);
  3110.   
  3111. !       if (cc[0] != '\0')                           /* copies! */
  3112. !         sprintf(expanded_to,"%s %s", expanded_to, expanded_cc);
  3113.   
  3114.         if (bcc[0] != '\0') {
  3115.           strcat(expanded_to, " ");
  3116. --- 370,379 ----
  3117.   
  3118.         fclose(real_reply);
  3119.   
  3120. !       if (cc[0] != '\0') {                 /* copies! */
  3121. !         strcat(expanded_to, " ");
  3122. !         strcat(expanded_to, expanded_cc);
  3123. !       }
  3124.   
  3125.         if (bcc[0] != '\0') {
  3126.           strcat(expanded_to, " ");
  3127. ***************
  3128. *** 369,403 ****
  3129.   
  3130.         remove_hostbang(expanded_to);
  3131.   
  3132. !       if (strcmp(sendmail, mailer) == 0
  3133. ! #ifdef SITE_HIDING
  3134. !           && ! is_a_hidden_user(username))
  3135. ! #else
  3136. !                              )
  3137. ! #endif
  3138. !         strcpy(mailerflags, (sendmail_verbose ? smflagsv : smflags));
  3139. !       else if (strcmp(submitmail, mailer) == 0)
  3140. !         strcpy(mailerflags, submitflags);
  3141. !       else
  3142. !         mailerflags[0] ='\0';
  3143. !       if (strcmp(submitmail, mailer) == 0)
  3144. !         strcpy(expanded_to, " ");
  3145. !       else {
  3146. !         quote_args(very_long_buffer, strip_parens(strip_commas(expanded_to)));
  3147. !         strcpy(expanded_to, very_long_buffer);
  3148.         }
  3149. -       sprintf(very_long_buffer,"( (%s %s %s ; %s %s) & ) < %s", 
  3150. -         mailer, mailerflags, expanded_to,
  3151. -         remove_cmd, whole_msg_file, whole_msg_file);
  3152.       }
  3153.   
  3154.       fclose(reply);
  3155.   
  3156.       if(batch_only)
  3157. !       printf("Sending mail...\n");
  3158.       else {
  3159.         PutLine0(LINES,0,"Sending mail...");
  3160.         CleartoEOLN();
  3161. --- 382,410 ----
  3162.   
  3163.         remove_hostbang(expanded_to);
  3164.   
  3165. +       sprintf(very_long_buffer,"sndfilt %s %s@%s %s",
  3166. +           whole_msg_file, username, hostfromname, 
  3167. +           strip_parens(strip_commas(expanded_to)));
  3168. +       system_call(very_long_buffer, SH, FALSE, FALSE);
  3169. !       if (strcmp(sendmail, mailer) == 0)
  3170. !       {
  3171. !         sprintf(very_long_buffer,"sndmail %s -af %s -f %s@%s %s >nul 2>&1",
  3172. !             background ? "-bg" : "",
  3173. !             whole_msg_file, username, hostfromname, 
  3174. !             strip_parens(strip_commas(expanded_to)));
  3175. !       }
  3176. !       else
  3177. !       {
  3178. !         sprintf(very_long_buffer,"%s -f %s %s 2>nul",
  3179. !             mailer, whole_msg_file, submitflags);
  3180.         }
  3181.       }
  3182.   
  3183.       fclose(reply);
  3184.   
  3185.       if(batch_only)
  3186. !       printf("Sending mail...\r\n");
  3187.       else {
  3188.         PutLine0(LINES,0,"Sending mail...");
  3189.         CleartoEOLN();
  3190. ***************
  3191. *** 416,422 ****
  3192.       } else {
  3193.           /* Success case: */
  3194.           if(batch_only)
  3195. !           printf("Mail sent!\n");
  3196.           else if(mail_only)
  3197.             error("Mail sent!");
  3198.           else
  3199. --- 418,424 ----
  3200.       } else {
  3201.           /* Success case: */
  3202.           if(batch_only)
  3203. !           printf("Mail sent!\r\n");
  3204.           else if(mail_only)
  3205.             error("Mail sent!");
  3206.           else
  3207. ***************
  3208. *** 430,437 ****
  3209.        * with root privelges. The best we can do is not let this
  3210.        * file just hang after we're finished with it.
  3211.        */
  3212.       (void)unlink(filename);
  3213.       return(need_redraw);
  3214.   }
  3215.   
  3216. --- 432,441 ----
  3217.        * with root privelges. The best we can do is not let this
  3218.        * file just hang after we're finished with it.
  3219.        */
  3220. +     if (!background) /* but only if not using sendmail in background mode */
  3221. +       (void)unlink(whole_msg_file);
  3222.       (void)unlink(filename);
  3223. !         free(whole_msg_file);
  3224.       return(need_redraw);
  3225.   }
  3226.   
  3227. ***************
  3228. *** 565,576 ****
  3229.           } else if (*form_letter == MAYBE)  {
  3230.              strcpy(buffer, "Choose e)dit msg, m)ake form, ");
  3231.           } else {
  3232. !            strcpy(buffer, "Choose e)dit message, ");
  3233.           }
  3234.   #ifdef ALLOW_SUBSHELL
  3235.           strcat(buffer, "!)shell, ");
  3236.   #endif
  3237. !         strcat(buffer, "h)eaders, c)opy file, s)end, or f)orget.");
  3238.           Centerline(LINES-1, buffer);
  3239.         }
  3240.   
  3241. --- 569,580 ----
  3242.           } else if (*form_letter == MAYBE)  {
  3243.              strcpy(buffer, "Choose e)dit msg, m)ake form, ");
  3244.           } else {
  3245. !              strcpy(buffer, "Choose e)dit msg, ");
  3246.           }
  3247.   #ifdef ALLOW_SUBSHELL
  3248.           strcat(buffer, "!)shell, ");
  3249.   #endif
  3250. !           strcat(buffer, "h)drs, c)opy file, s)end, f)orget");
  3251.           Centerline(LINES-1, buffer);
  3252.         }
  3253.   
  3254. ***************
  3255. *** 668,676 ****
  3256.   }
  3257.   
  3258.   FILE *
  3259. ! write_header_info(filename, long_to, long_cc, long_bcc, form, copy)
  3260.   char *filename, *long_to, *long_cc, *long_bcc;
  3261. ! int   form, copy;
  3262.   {
  3263.       /** Try to open filedesc as the specified filename.  If we can,
  3264.           then write all the headers into the file.  The routine returns
  3265. --- 672,680 ----
  3266.   }
  3267.   
  3268.   FILE *
  3269. ! write_header_info(filename, long_to, long_cc, long_bcc, form, copy, resend)
  3270.   char *filename, *long_to, *long_cc, *long_bcc;
  3271. ! int   form, copy, resend;
  3272.   {
  3273.       /** Try to open filedesc as the specified filename.  If we can,
  3274.           then write all the headers into the file.  The routine returns
  3275. ***************
  3276. *** 684,689 ****
  3277. --- 688,694 ----
  3278.       long time(), thetime;
  3279.       char *ctime();
  3280.       static FILE *filedesc;        /* our friendly file descriptor  */
  3281. +     char *resent = resend ? "Resent-" : "";  /* forwarding ? */
  3282.   
  3283.   #ifdef SITE_HIDING
  3284.       char  buffer[SLEN];
  3285. ***************
  3286. *** 750,762 ****
  3287.           of headers is irrelevant).  Gahhhhh....
  3288.       **/
  3289.   
  3290. !     fprintf(filedesc, "Subject: %s\n", subject);
  3291. !       fprintf(filedesc, "To: %s\n", format_long(long_to, strlen("To:")));
  3292. !     fprintf(filedesc,"Date: %s\n", get_arpa_date());
  3293.   
  3294.   #ifndef DONT_ADD_FROM
  3295.   #ifdef MMDF
  3296.       is_submit_mailer = (strcmp(submitmail,mailer) == 0);
  3297.   #endif /* MMDF */
  3298. --- 755,764 ----
  3299.           of headers is irrelevant).  Gahhhhh....
  3300.       **/
  3301.   
  3302. !     fprintf(filedesc,"%sDate: %s\n", resent, get_arpa_date());
  3303.   
  3304.   #ifndef DONT_ADD_FROM
  3305. +     fputs(resent, filedesc);
  3306.   #ifdef MMDF
  3307.       is_submit_mailer = (strcmp(submitmail,mailer) == 0);
  3308.   #endif /* MMDF */
  3309. ***************
  3310. *** 775,789 ****
  3311.   # else
  3312.   #  ifdef  INTERNET
  3313.   #   ifdef  USE_DOMAIN
  3314. ! #    ifdef MMDF
  3315.       if (is_submit_mailer)
  3316.         fprintf(filedesc,"From: %s <%s>\n", full_username, username);
  3317.       else
  3318.   #    endif /* MMDF */
  3319.         fprintf(filedesc,"From: %s <%s@%s>\n", full_username,
  3320. !         username, hostfullname);
  3321.   #   else
  3322. ! #    ifdef MMDF
  3323.       if (is_submit_mailer)
  3324.         fprintf(filedesc,"From: %s <%s>\n", full_username, username);
  3325.       else
  3326. --- 777,791 ----
  3327.   # else
  3328.   #  ifdef  INTERNET
  3329.   #   ifdef  USE_DOMAIN
  3330. ! #    ifdef _MMDF
  3331.       if (is_submit_mailer)
  3332.         fprintf(filedesc,"From: %s <%s>\n", full_username, username);
  3333.       else
  3334.   #    endif /* MMDF */
  3335.         fprintf(filedesc,"From: %s <%s@%s>\n", full_username,
  3336. !         username, hostfromname);
  3337.   #   else
  3338. ! #    ifdef _MMDF
  3339.       if (is_submit_mailer)
  3340.         fprintf(filedesc,"From: %s <%s>\n", full_username, username);
  3341.       else
  3342. ***************
  3343. *** 803,813 ****
  3344.   # endif
  3345.   #endif
  3346.   
  3347.       if (cc[0] != '\0')
  3348. !         fprintf(filedesc, "Cc: %s\n", format_long(long_cc, strlen("Cc: ")));
  3349.   
  3350. !     if (copy && (bcc[0] != '\0'))
  3351. !         fprintf(filedesc, "Bcc: %s\n", format_long(long_bcc, strlen("Bcc: ")));
  3352.   
  3353.       if (strlen(action) > 0)
  3354.           fprintf(filedesc, "Action: %s\n", action);
  3355. --- 805,820 ----
  3356.   # endif
  3357.   #endif
  3358.   
  3359. +     fprintf(filedesc, "%sSubject: %s\n", resent, subject);
  3360. +     fprintf(filedesc, "%sTo: %s\n", resent, format_long(long_to, strlen("To:")));
  3361.       if (cc[0] != '\0')
  3362. !         fprintf(filedesc, "%sCc: %s\n", resent, format_long(long_cc, strlen("Cc: ")));
  3363.   
  3364. !     if ((copy || stricmp(sendmail, mailer) != 0) &&
  3365. !         (bcc[0] != '\0'))
  3366. !         fprintf(filedesc, "%sBcc: %s\n", resent, format_long(long_bcc, strlen("Bcc: ")));
  3367.   
  3368.       if (strlen(action) > 0)
  3369.           fprintf(filedesc, "Action: %s\n", action);
  3370. ***************
  3371. *** 819,825 ****
  3372.           fprintf(filedesc, "Expires: %s\n", expires);
  3373.   
  3374.       if (strlen(reply_to) > 0)
  3375. !         fprintf(filedesc, "Reply-To: %s\n", reply_to);
  3376.   
  3377.       if (strlen(in_reply_to) > 0)
  3378.           fprintf(filedesc, "In-Reply-To: %s\n", in_reply_to);
  3379. --- 826,832 ----
  3380.           fprintf(filedesc, "Expires: %s\n", expires);
  3381.   
  3382.       if (strlen(reply_to) > 0)
  3383. !         fprintf(filedesc, "%sReply-To: %s\n", resent, reply_to);
  3384.   
  3385.       if (strlen(in_reply_to) > 0)
  3386.           fprintf(filedesc, "In-Reply-To: %s\n", in_reply_to);
  3387. ***************
  3388. *** 833,841 ****
  3389.         fprintf(filedesc, "Content-Type: mailform\n");
  3390.   
  3391.   #ifndef NO_XHEADER
  3392. !     fprintf(filedesc, "X-Mailer: ELM [version %s]\n", version_buff);
  3393.   #endif /* !NO_XHEADER */
  3394.   
  3395.          putc('\n', filedesc);
  3396.   
  3397.       return((FILE *) filedesc);
  3398. --- 840,849 ----
  3399.         fprintf(filedesc, "Content-Type: mailform\n");
  3400.   
  3401.   #ifndef NO_XHEADER
  3402. !     fprintf(filedesc, "X-Mailer: ELM [version %s] for OS/2\n", version_buff);
  3403.   #endif /* !NO_XHEADER */
  3404.   
  3405. +         if (!resend)
  3406.          putc('\n', filedesc);
  3407.   
  3408.       return((FILE *) filedesc);
  3409. ***************
  3410. *** 901,907 ****
  3411.           emergency_exit();
  3412.           }
  3413.       }
  3414. ! #ifdef MMDF
  3415.       if (copy) fputs(MSG_SEPERATOR, dest);
  3416.   #else
  3417.       if (copy) fputs("\n", dest);    /* ensure a blank line at the end */
  3418. --- 909,915 ----
  3419.           emergency_exit();
  3420.           }
  3421.       }
  3422. ! #ifdef _MMDF
  3423.       if (copy) fputs(MSG_SEPERATOR, dest);
  3424.   #else
  3425.       if (copy) fputs("\n", dest);    /* ensure a blank line at the end */
  3426. ***************
  3427. *** 997,1003 ****
  3428. --- 1005,1016 ----
  3429.               if (sig[0]) {  /* if there is a signature file */
  3430.             if (sig_dashes) /* dashes are optional */
  3431.               fprintf(file, "\n-- \n");  /* News 2.11 compatibility? */
  3432. + #ifdef OS2
  3433. +           if (sig[0] != '/' && sig[0] != '\\' &&
  3434. +           (!isalpha(sig[0]) || sig[1] != ':'))
  3435. + #else
  3436.             if (sig[0] != '/')
  3437. + #endif
  3438.               sprintf(filename2, "%s/%s", home, sig);
  3439.             else
  3440.               strcpy(filename2, sig);
  3441. ***************
  3442. *** 1009,1012 ****
  3443. --- 1022,1135 ----
  3444.   
  3445.   return FALSE;
  3446.   
  3447. + }
  3448. + perhaps_pgp_encode(filename)
  3449. + char *filename;
  3450. + {
  3451. +   char buffer[VERY_LONG_STRING];
  3452. +   FILE *msg;
  3453. +   int encrypt = 0;
  3454. +   if ((msg = fopen(filename, "r")) == NULL)
  3455. +     return -1;
  3456. +   while (fgets(buffer, sizeof(buffer), msg) != NULL)
  3457. +     if (strncmp(buffer, "[pgp-encrypt]\n", 14) == 0) {
  3458. +       encrypt = 1;
  3459. +       strcpy(buffer, strip_parens(strip_commas(expanded_to)));
  3460. +       if (expanded_cc[0]) {
  3461. +     strcat(buffer, " ");
  3462. +     strcat(buffer, strip_parens(strip_commas(expanded_cc)));
  3463. +       }
  3464. +       if (expanded_bcc[0]) {
  3465. +     strcat(buffer, " ");
  3466. +     strcat(buffer, strip_parens(strip_commas(expanded_bcc)));
  3467. +       }
  3468. +       strcat(buffer, " ");
  3469. +       strcat(buffer, username); /* add sender id too! */
  3470. +       strcat(buffer, "@");
  3471. +       strcat(buffer, hostname);
  3472. +       break;
  3473. +     }
  3474. +     else if (strncmp(buffer, "[pgp-sign]\n", 11) == 0) {
  3475. +       sign = 1;
  3476. +       break;
  3477. +     }
  3478. +     else if (strncmp(buffer, "[pgp-encrypt ", 13) == 0 &&
  3479. +          strncmp(buffer + strlen(buffer) - 2, "]\n", 2) == 0) {
  3480. +       strcpy(buffer, buffer + 13);
  3481. +       buffer[strlen(buffer) - 2] = 0;
  3482. +       encrypt = 1;
  3483. +       break;
  3484. +     }
  3485. +   fclose(msg);
  3486. +   if (encrypt)
  3487. +     return pgp_encrypt(filename, buffer);
  3488. +   if (sign)
  3489. +     return pgp_sign(filename);
  3490. +   return 0;
  3491. + }
  3492. + pgp_encrypt(filename, to)
  3493. + char *filename, *to;
  3494. + {
  3495. +   char  buffer[SLEN];
  3496. +   char  pgpfn[SLEN];
  3497. +   int   dotpos = 0;
  3498. +   sprintf(buffer, "pgp -seaw %s %s", filename, to);
  3499. +   puts("\r\n\n");
  3500. +   if (system_call(buffer, SH, FALSE, FALSE) == 0) {
  3501. +     do { ++dotpos; } while (filename[dotpos] != '.');
  3502. +     strncpy(pgpfn, filename, dotpos);
  3503. +     strcpy(pgpfn + dotpos, ".asc");
  3504. +     if(rename(pgpfn,filename)) {
  3505. +       printf("Error with renaming %s to %s in pgp_encrypt! (%s)\n",
  3506. +          pgpfn, filename, error_name(errno));
  3507. +       return(-1);
  3508. +     }
  3509. +     return(0);
  3510. +   }
  3511. +   else {            /* something went wrong. Bad password or user spec */
  3512. +     printf("Error while encrypting. Try again.");
  3513. +     return(-1);
  3514. +   }
  3515. + }
  3516. + pgp_sign(filename)
  3517. + char *filename;
  3518. + {
  3519. +   char  buffer[SLEN];
  3520. +   char  pgpfn[SLEN];
  3521. +   int   dotpos = 0;
  3522. +   sprintf(buffer, "pgp -sta +clearsig=on %s", filename);
  3523. +   puts("\r\n\n");
  3524. +   if (system_call(buffer, SH, FALSE, FALSE) == 0) {
  3525. +     do { ++dotpos; } while (filename[dotpos] != '.');
  3526. +     strncpy(pgpfn, filename, dotpos);
  3527. +     strcpy(pgpfn + dotpos, ".asc");
  3528. +     if(unlink(filename) || rename(pgpfn,filename)) {
  3529. +       printf("Error with renaming %s to %s in pgp_sign! (%s)\n",
  3530. +          pgpfn, filename, error_name(errno));
  3531. +       return(-1);
  3532. +     }
  3533. +     return(0);
  3534. +   }
  3535. +   else {            /* something went wrong. Bad password or user spec */
  3536. +     printf("Error while signing. Try again.");
  3537. +     return(-1);
  3538. +   }
  3539.   }
  3540. diff -cbr orig/src/Makefile new/src/Makefile
  3541. *** orig/src/Makefile    Sat Oct 16 18:43:52 1993
  3542. --- new/src/Makefile    Fri Apr 22 20:06:06 1994
  3543. ***************
  3544. *** 1,19 ****
  3545.   #
  3546. ! # Makefile for the ELM mail program for OS/2
  3547.   #
  3548.   
  3549. ! gcc:
  3550.       $(MAKE) all CC="gcc -O -Zomf -Zmtd" O=".obj" \
  3551. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm32.def"
  3552.   
  3553. ! gccdebug:
  3554.       $(MAKE) all CC="gcc -g" O=".o" \
  3555. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm32.def"
  3556. ! msc:
  3557. !     $(MAKE) all CC="cl -nologo -AL -Gs -Ocegt" O=".obj" \
  3558. !     CFLAGS="-W1 -Zep1 -Gt16 -D__STDC__ -G2 -J" \
  3559. !     LFLAGS="-Lp" LIBS="..\os2\elm16.def -link /noe /packc /packd"
  3560.   
  3561.   # Variables
  3562.   
  3563. --- 1,14 ----
  3564.   #
  3565. ! # Makefile for the Elm mail program for OS/2
  3566.   #
  3567.   
  3568. ! release:
  3569.       $(MAKE) all CC="gcc -O -Zomf -Zmtd" O=".obj" \
  3570. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm.def"
  3571.   
  3572. ! debug:
  3573.       $(MAKE) all CC="gcc -g" O=".o" \
  3574. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm.def"
  3575.   
  3576.   # Variables
  3577.   
  3578. ***************
  3579. *** 26,32 ****
  3580.   
  3581.   # Lists
  3582.   
  3583. ! OS2_OBJ        = alarm$O getopt$O termcap$O os2util$O
  3584.   CRYPT_OBJ    = crypt$O crypt_util$O
  3585.   
  3586.   ELM_OBJ        = $(OS2_OBJ) $(CRYPT_OBJ) \
  3587. --- 21,27 ----
  3588.   
  3589.   # Lists
  3590.   
  3591. ! OS2_OBJ        = alarm$O getopt$O termcap$O os2util$O movemail$O
  3592.   CRYPT_OBJ    = crypt$O crypt_util$O
  3593.   
  3594.   ELM_OBJ        = $(OS2_OBJ) $(CRYPT_OBJ) \
  3595. ***************
  3596. *** 141,146 ****
  3597. --- 136,143 ----
  3598.           $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/termcap.c
  3599.   os2util$O:    $(OS2DIR)/os2util.c
  3600.           $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/os2util.c
  3601. + movemail$O:    $(OS2DIR)/movemail.c
  3602. +         $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/movemail.c
  3603.   
  3604.   crypt$O:    $(CRYPTDIR)/crypt.c
  3605.           $(CC) $(CFLAGS) $(DEFINES) -c $(CRYPTDIR)/crypt.c
  3606. diff -cbr orig/src/mkhdrs.c new/src/mkhdrs.c
  3607. *** orig/src/mkhdrs.c    Sat Oct 16 18:43:52 1993
  3608. --- new/src/mkhdrs.c    Sun Oct 10 17:22:28 1993
  3609. ***************
  3610. *** 46,52 ****
  3611.           tail_of(headers[msg]->from, buffer, 0);
  3612.         else
  3613.           strcpy(buffer, headers[msg]->from);
  3614. !       sprintf(in_reply_to, "%s; from \"%s\" at %s %s, %s %s",
  3615.                     headers[msg]->messageid[0] == '\0'? "<no.id>":
  3616.             headers[msg]->messageid,
  3617.             buffer,
  3618. --- 46,52 ----
  3619.           tail_of(headers[msg]->from, buffer, 0);
  3620.         else
  3621.           strcpy(buffer, headers[msg]->from);
  3622. !       sprintf(in_reply_to, "%s from \"%s\" at %s %s %s %s",
  3623.                     headers[msg]->messageid[0] == '\0'? "<no.id>":
  3624.             headers[msg]->messageid,
  3625.             buffer,
  3626. ***************
  3627. *** 110,116 ****
  3628.         command[j++] = buffer[i];
  3629.       command[j] = '\0';
  3630.   
  3631. !     sprintf(fname,"%s%s%d", temp_dir, temp_print, getpid());
  3632.   
  3633.       sprintf(command_buffer, "%s > %s", command, fname);
  3634.   
  3635. --- 110,116 ----
  3636.         command[j++] = buffer[i];
  3637.       command[j] = '\0';
  3638.   
  3639. !     sprintf(fname,"%s%d%s", temp_dir, getpid(), temp_print);
  3640.   
  3641.       sprintf(command_buffer, "%s > %s", command, fname);
  3642.   
  3643. diff -cbr orig/src/newmbox.c new/src/newmbox.c
  3644. *** orig/src/newmbox.c    Sat Oct 16 18:43:54 1993
  3645. --- new/src/newmbox.c    Sun Oct 10 17:23:42 1993
  3646. ***************
  3647. *** 62,71 ****
  3648.   #  include <sys/time.h>
  3649.   #endif
  3650.   
  3651.   extern int errno;
  3652.   
  3653.   char *error_name(), *error_description();
  3654. ! char *malloc(), *realloc(), *strcpy(), *strncpy(), *rindex(), *index();
  3655.   unsigned long sleep();
  3656.   void rewind();
  3657.   void exit();
  3658. --- 62,77 ----
  3659.   #  include <sys/time.h>
  3660.   #endif
  3661.   
  3662. + #ifndef OS2
  3663.   extern int errno;
  3664. + #endif
  3665.   
  3666.   char *error_name(), *error_description();
  3667. ! char *malloc(), *realloc();
  3668. ! #ifndef __GNUC__
  3669. ! char *alloca();
  3670. ! #endif
  3671. ! char *strcpy(), *strncpy(), *rindex(), *index();
  3672.   unsigned long sleep();
  3673.   void rewind();
  3674.   void exit();
  3675. ***************
  3676. *** 96,101 ****
  3677. --- 102,115 ----
  3678.       int err;
  3679.       char new_tempfile[SLEN];
  3680.   
  3681. + #ifdef OS2
  3682. +     char *new_file2 = (char *) alloca(SLEN);
  3683. +     _fullpath(new_file2, new_file, SLEN);
  3684. +     strlwr(new_file2);
  3685. +     unixpath(new_file2);
  3686. + #define new_file new_file2
  3687. + #endif
  3688.       /* determine type of new mailfile and calculate temp file name */
  3689.       if((new_folder_type = get_folder_type(new_file)) == SPOOL)
  3690.         mk_temp_mail_fn(new_tempfile, new_file);
  3691. ***************
  3692. *** 124,129 ****
  3693. --- 138,146 ----
  3694.         }
  3695.       }
  3696.   
  3697. +     if (mailfile != NULL)
  3698. +       (void) fclose(mailfile);  /* close it first, to avoid too many open */
  3699.       /* If we were reading a spool file and we are not just reading
  3700.        * in the additional new messages to the same file, we need to
  3701.        * remove the corresponding tempfile.
  3702. ***************
  3703. *** 147,156 ****
  3704.       clear_error();
  3705.       clear_central_message();
  3706.   
  3707. !     if (mailfile != NULL)
  3708. !       (void) fclose(mailfile);  /* close it first, to avoid too many open */
  3709. !     if ((mailfile = fopen(cur_folder,"r")) == NULL)  {
  3710.         if (errno != ENOENT ) { /* error on anything but file not exist */
  3711.           err = errno;
  3712.           Write_to_screen("\n\rfail on open in newmbox, open %s failed!!\n\r", 1,
  3713. --- 164,170 ----
  3714.       clear_error();
  3715.       clear_central_message();
  3716.   
  3717. !     if ((mailfile = fopen(cur_folder,"rb")) == NULL)  {
  3718.         if (errno != ENOENT ) { /* error on anything but file not exist */
  3719.           err = errno;
  3720.           Write_to_screen("\n\rfail on open in newmbox, open %s failed!!\n\r", 1,
  3721. ***************
  3722. *** 200,216 ****
  3723.       if((filename == NULL) || (*filename == '\0'))
  3724.         return(NO_NAME);
  3725.   
  3726.       /* if filename begins with mailhome,
  3727.        * and there is a slash in filename,
  3728.        * and there is a filename after it (i.e. last slash is not last char),
  3729.        * and the last character of mailhome is last slash in filename,
  3730.        * it's a spool file .
  3731.        */
  3732. !     if((first_word(filename, mailhome)) &&
  3733. !       ((last_slash = rindex(filename, '/')) != NULL) &&
  3734. !       (*(last_slash+1) != '\0') &&
  3735. !       (filename + strlen(mailhome) - 1 == last_slash))
  3736.           return(SPOOL);
  3737.       /* if file name == default mailbox, its a spool file also
  3738.        * even if its not in the spool directory. (SVR4)
  3739.        */
  3740. --- 214,253 ----
  3741.       if((filename == NULL) || (*filename == '\0'))
  3742.         return(NO_NAME);
  3743.   
  3744. + #ifdef OS2
  3745. + #define prefix_path(s, w) (strnicmp(s,w, strlen(w)) == 0)
  3746. + #else
  3747. + #define prefix_path(s, w) first_word(s,w)
  3748. + #endif
  3749.       /* if filename begins with mailhome,
  3750.        * and there is a slash in filename,
  3751.        * and there is a filename after it (i.e. last slash is not last char),
  3752.        * and the last character of mailhome is last slash in filename,
  3753.        * it's a spool file .
  3754.        */
  3755. !     if (prefix_path(filename, mailhome) &&
  3756. !         (last_slash = rindex(filename, '/')) != NULL &&
  3757. !         *(last_slash + 1) != '\0') 
  3758. !     {
  3759. ! #ifdef OS2
  3760. !       if (!maildir && filename + strlen(mailhome) - 1 == last_slash)
  3761.           return(SPOOL);
  3762. +       if (maildir && strncmp(last_slash, "/newmail", 8) == 0)
  3763. +       { 
  3764. +         char *previous_slash;
  3765. +         *last_slash = 0;
  3766. +         previous_slash = rindex(filename, '/');
  3767. +             *last_slash = '/';
  3768. +         if (previous_slash != NULL &&
  3769. +         filename + strlen(mailhome) - 1 == previous_slash)
  3770. +           return(SPOOL);
  3771. +       }
  3772. + #else
  3773. +       if (filename + strlen(mailhome) - 1 == last_slash)
  3774. +         return(SPOOL);
  3775. + #endif
  3776. +         }
  3777.       /* if file name == default mailbox, its a spool file also
  3778.        * even if its not in the spool directory. (SVR4)
  3779.        */
  3780. ***************
  3781. *** 228,244 ****
  3782.           Strangeness may result if it is not!
  3783.        **/
  3784.   
  3785. !     char *cp;
  3786.   
  3787. !     sprintf(tempfn, "%s%s", default_temp, temp_mbox);
  3788. !     if((cp = rindex(mbox, '/')) != NULL) {
  3789. !       cp++;
  3790. !       if (strcmp(cp, "mbox") == 0 || strcmp(cp, "mailbox") == 0 ||
  3791. !         strcmp(cp, "inbox") == 0 || *cp == '.')
  3792. !         strcat(tempfn, username);
  3793.       else
  3794. !         strcat(tempfn, cp);
  3795.       }
  3796.   }
  3797.   
  3798.   int
  3799. --- 265,298 ----
  3800.           Strangeness may result if it is not!
  3801.        **/
  3802.   
  3803. !     char *cp, mb[128];
  3804.   
  3805. !         strcpy(tempfn, default_temp);
  3806. !     if (tempfn[strlen (tempfn)-1] != '/')
  3807. !                 strcat(tempfn, "/");
  3808. !     if((cp = rindex(mbox, '/')) != NULL)
  3809. !           strcpy(mb, ++cp);
  3810.       else
  3811. !       strcpy(mb, mbox);
  3812. ! #ifdef OS2
  3813. !     if ( (cp = strrchr(mb, '.')) != NULL && strlen(cp) <= 4 )
  3814. !       *cp = 0;
  3815. ! #endif
  3816. !     if (strcmp(mb, "mbox") == 0 || strcmp(mb, "mailbox") == 0 ||
  3817. !         strcmp(mb, "inbox") == 0)
  3818. !       strcat(tempfn, username);
  3819. ! #ifdef OS2
  3820. !     else if (strcmp(mb, "newmail") == 0) {
  3821. !       strcpy(mb, mbox + strlen(mailhome));
  3822. !       cp = strchr(mb, '/');
  3823. !       if (strncmp(cp, "/newmail", 8) == 0)
  3824. !         *cp = 0;
  3825. !       strcat(tempfn, mb);
  3826.       }
  3827. + #endif
  3828. +     else
  3829. +       strcat(tempfn, mb);
  3830. +         strcat(tempfn, temp_mbox);
  3831.   }
  3832.   
  3833.   int
  3834. ***************
  3835. *** 266,271 ****
  3836. --- 320,326 ----
  3837.       static int first_read = 0;
  3838.   #ifdef MMDF
  3839.           int newheader = 0;
  3840. +         int fromtoo = 1;
  3841.   #endif /* MMDF */
  3842.   
  3843.       if (folder_type == SPOOL) {
  3844. ***************
  3845. *** 280,286 ****
  3846.             error("Ahhhh... I give up.");
  3847.             silently_exit();    /* leave without tampering with it! */
  3848.           }
  3849. !         if ((temp = fopen(cur_tempfolder,"w")) == NULL) {
  3850.            err = errno;
  3851.            unlock();    /* remove lock file! */
  3852.            Raw(OFF);
  3853. --- 335,341 ----
  3854.             error("Ahhhh... I give up.");
  3855.             silently_exit();    /* leave without tampering with it! */
  3856.           }
  3857. !         if ((temp = fopen(cur_tempfolder,"wb")) == NULL) {
  3858.            err = errno;
  3859.            unlock();    /* remove lock file! */
  3860.            Raw(OFF);
  3861. ***************
  3862. *** 299,305 ****
  3863.          chmod(cur_tempfolder, 0700);    /* shut off file for other people! */
  3864.        }
  3865.        else {
  3866. !        if ((temp = fopen(cur_tempfolder,"a")) == NULL) {
  3867.            err = errno;
  3868.            unlock();    /* remove lock file! */
  3869.            Raw(OFF);
  3870. --- 354,360 ----
  3871.          chmod(cur_tempfolder, 0700);    /* shut off file for other people! */
  3872.        }
  3873.        else {
  3874. !        if ((temp = fopen(cur_tempfolder,"ab")) == NULL) {
  3875.            err = errno;
  3876.            unlock();    /* remove lock file! */
  3877.            Raw(OFF);
  3878. ***************
  3879. *** 333,338 ****
  3880. --- 388,402 ----
  3881.         PutLine0(LINES-2, 0, "Reading message: 0");
  3882.       }
  3883.   
  3884. + #ifdef MMDF
  3885. + #ifdef OS2
  3886. +     if (fgets(buffer, LONG_STRING, mailfile)) {
  3887. +           fixline(buffer);
  3888. +           fromtoo = !mmdf_strict || strcmp(buffer, MSG_SEPERATOR) != 0;
  3889. +         }
  3890. +         rewind(mailfile);
  3891. + #endif
  3892. + #endif
  3893.       if (add_new_only) {
  3894.          if (fseek(mailfile, mailfile_size, 0) == -1) {
  3895.            err = errno;
  3896. ***************
  3897. *** 373,378 ****
  3898. --- 437,443 ----
  3899.           rm_temps_exit();
  3900.           }
  3901.         line_bytes = (long) strlen(buffer);
  3902. +           fixline(buffer);
  3903.   
  3904.         /* Fix below to increment line count ONLY if we got a full line.
  3905.          * Input lines longer than the fgets buffer size would
  3906. ***************
  3907. *** 401,407 ****
  3908.             first_line = FALSE;
  3909.   
  3910.   #ifdef MMDF
  3911. !         if (!forwarding_mail && strcmp(buffer, MSG_SEPERATOR) != 0 ) {
  3912.   #else
  3913.           if (! first_word(buffer, "From ") && !forwarding_mail) {
  3914.   #endif /* MMDF */
  3915. --- 466,473 ----
  3916.             first_line = FALSE;
  3917.   
  3918.   #ifdef MMDF
  3919. !         if (!forwarding_mail && strcmp(buffer, MSG_SEPERATOR) != 0
  3920. !             && !first_word(buffer, "From ") ) {
  3921.   #else
  3922.           if (! first_word(buffer, "From ") && !forwarding_mail) {
  3923.   #endif /* MMDF */
  3924. ***************
  3925. *** 417,424 ****
  3926.         }
  3927.   
  3928.   #ifdef MMDF
  3929. !       if (strcmp(buffer, MSG_SEPERATOR) == 0) {
  3930. !             newheader = !newheader;
  3931.   #else
  3932.         if (first_word(buffer,"From ")) {
  3933.   #endif /* MMDF */
  3934. --- 483,492 ----
  3935.         }
  3936.   
  3937.   #ifdef MMDF
  3938. !       if (strcmp(buffer, MSG_SEPERATOR) == 0
  3939. !           || !newheader && fromtoo && first_word(buffer,"From ")
  3940. !                             && real_from(buffer, NULL)) {
  3941. !             newheader = 1; /* !newheader; */
  3942.   #else
  3943.         if (first_word(buffer,"From ")) {
  3944.   #endif /* MMDF */
  3945. ***************
  3946. *** 572,577 ****
  3947. --- 640,646 ----
  3948.           }
  3949.         }
  3950.         else if (in_header) {
  3951. +             newheader = 0;
  3952.   #ifdef MMDF
  3953.           if (first_word(buffer,"From "))
  3954.             real_from(buffer, current_header);
  3955. ***************
  3956. *** 653,658 ****
  3957. --- 722,730 ----
  3958.             c = index(current_header->mailx_status, '\n');
  3959.             if (c != NULL)
  3960.           *c = '\0';
  3961. +           c = index(current_header->mailx_status, '\r');
  3962. +           if (c != NULL)
  3963. +         *c = '\0';
  3964.             remove_possible_trailing_spaces(current_header->mailx_status);
  3965.   
  3966.             /* Okay readjust the status. If there's an 'R', message
  3967. ***************
  3968. *** 688,693 ****
  3969. --- 760,767 ----
  3970.         }
  3971.         if (!in_header && first_word(buffer, START_ENCODE))
  3972.           current_header->encrypted = 1;
  3973. +       if (!in_header && first_word(buffer, "Forwarded "))
  3974. +         in_header = 1;
  3975.         fbytes += (long) line_bytes;
  3976.       }
  3977.   
  3978. ***************
  3979. *** 724,730 ****
  3980.           dprint(0, (debugfile, "newmbox - mbox. != spool mail length"));
  3981.           rm_temps_exit();
  3982.         }
  3983. !       if ((mailfile = fopen(cur_tempfolder,"r")) == NULL) {
  3984.           err = errno;
  3985.           MoveCursor(LINES,0);
  3986.           Raw(OFF);
  3987. --- 798,804 ----
  3988.           dprint(0, (debugfile, "newmbox - mbox. != spool mail length"));
  3989.           rm_temps_exit();
  3990.         }
  3991. !       if ((mailfile = fopen(cur_tempfolder,"rb")) == NULL) {
  3992.           err = errno;
  3993.           MoveCursor(LINES,0);
  3994.           Raw(OFF);
  3995. ***************
  3996. *** 816,821 ****
  3997. --- 816,825 ----
  3998.       else
  3999.             rewind(mailfile);
  4000.   
  4001. + #ifdef OS2
  4002. +     fcntl(fileno(mailfile), F_SETFD, 1);
  4003. + #endif
  4004.       /* Sort folder *before* we establish the current message, so that
  4005.        * the current message is based on the post-sort order.
  4006.        * Note that we have to set the global variable message_count
  4007. diff -cbr orig/src/opt_utils.c new/src/opt_utils.c
  4008. *** orig/src/opt_utils.c    Sat Oct 16 18:43:54 1993
  4009. --- new/src/opt_utils.c    Sun Mar 29 00:06:14 1992
  4010. ***************
  4011. *** 96,101 ****
  4012. --- 96,102 ----
  4013.   #endif  /* GETHOSTNAME */
  4014.   
  4015.   
  4016. + #ifndef OS2
  4017.   gethostdomain(hostdom, size)    /* get domain of current host */
  4018.   char *hostdom;
  4019.   int size;
  4020. ***************
  4021. *** 107,113 ****
  4022.       if (size < 2)
  4023.         return -1;
  4024.   
  4025. !     if ((fp = fopen(hostdomfile, "r")) != 0) {
  4026.         fgets(buf, sizeof(buf) - 1, fp);
  4027.         fclose(fp);
  4028.         if ((p = index(buf, '\n')) != NULL)
  4029. --- 108,116 ----
  4030.       if (size < 2)
  4031.         return -1;
  4032.   
  4033. !         sprintf(buf, "%s/%s", elmhome, hostdomfile);
  4034. !     if ((fp = fopen(buf, "r")) != 0) {
  4035.         fgets(buf, sizeof(buf) - 1, fp);
  4036.         fclose(fp);
  4037.         if ((p = index(buf, '\n')) != NULL)
  4038. ***************
  4039. *** 125,130 ****
  4040. --- 128,134 ----
  4041.   
  4042.       return 0;
  4043.   }
  4044. + #endif
  4045.   
  4046.   
  4047.   #ifdef NEED_CUSERID
  4048. diff -cbr orig/src/options.c new/src/options.c
  4049. *** orig/src/options.c    Sat Oct 16 18:43:54 1993
  4050. --- new/src/options.c    Sun Mar 15 14:35:20 1992
  4051. ***************
  4052. *** 218,223 ****
  4053. --- 218,224 ----
  4054.   change_sort(x, y)
  4055.   int x,y;
  4056.   {
  4057. +     char *sort_name();
  4058.       /** change the sorting scheme... **/
  4059.       /** return !0 if new sort order, else 0 **/
  4060.   
  4061. diff -cbr orig/src/pattern.c new/src/pattern.c
  4062. *** orig/src/pattern.c    Sat Oct 16 18:43:56 1993
  4063. --- new/src/pattern.c    Sat Feb 01 16:02:54 1992
  4064. ***************
  4065. *** 31,37 ****
  4066. --- 31,39 ----
  4067.   static char pattern[SLEN] = { "" };
  4068.   static char alt_pattern[SLEN] = { "" };
  4069.   
  4070. + #ifndef OS2
  4071.   extern int errno;
  4072. + #endif
  4073.   
  4074.   char *error_name(), *shift_lower(), *strcpy();
  4075.   
  4076. ***************
  4077. *** 218,224 ****
  4078.   
  4079.       while (message_number < message_count) {
  4080.   
  4081. !       if (fseek(mailfile, headers[message_number]->offset, 0L) == -1) {
  4082.   
  4083.           dprint(1, (debugfile,
  4084.           "Error: seek %ld bytes into file failed. errno %d (%s)\n",
  4085. --- 220,226 ----
  4086.   
  4087.       while (message_number < message_count) {
  4088.   
  4089. !       if (fseek(mailfile, headers[message_number]->offset, 0) == -1) {
  4090.   
  4091.           dprint(1, (debugfile,
  4092.           "Error: seek %ld bytes into file failed. errno %d (%s)\n",
  4093. diff -cbr orig/src/quit.c new/src/quit.c
  4094. *** orig/src/quit.c    Sat Oct 16 18:43:56 1993
  4095. --- new/src/quit.c    Sat Feb 01 16:01:12 1992
  4096. ***************
  4097. *** 27,33 ****
  4098. --- 27,35 ----
  4099.   #include "headers.h"
  4100.   #include <errno.h>
  4101.   
  4102. + #ifndef OS2
  4103.   extern int errno;        /* system error number on failure */
  4104. + #endif
  4105.   
  4106.   long bytes();
  4107.   
  4108. diff -cbr orig/src/read_rc.c new/src/read_rc.c
  4109. *** orig/src/read_rc.c    Sat Oct 16 18:43:56 1993
  4110. --- new/src/read_rc.c    Sun Mar 29 09:56:34 1992
  4111. ***************
  4112. *** 152,158 ****
  4113.   
  4114.       strcpy(raw_editor,((cp = getenv("EDITOR")) == NULL)? default_editor:cp);
  4115.   
  4116. !     strcpy(temp_dir,((cp = getenv("TMPDIR")) == NULL)? default_temp:cp);
  4117.       if (temp_dir[strlen (temp_dir)-1] != '/')
  4118.                   strcat(temp_dir, "/");
  4119.   
  4120. --- 152,162 ----
  4121.   
  4122.       strcpy(raw_editor,((cp = getenv("EDITOR")) == NULL)? default_editor:cp);
  4123.   
  4124. ! #ifdef OS2
  4125. !         strcpy(temp_dir, tempdir);
  4126. ! #else
  4127. !     strcpy(temp_dir,((cp = getenv("TMP")) == NULL)? default_temp:cp);
  4128. ! #endif
  4129.       if (temp_dir[strlen (temp_dir)-1] != '/')
  4130.                   strcat(temp_dir, "/");
  4131.   
  4132. ***************
  4133. *** 169,175 ****
  4134.       strcpy(calendar_file, raw_calendar_file);
  4135.   
  4136.       /* see if the user has a $HOME/.elm directory */
  4137. !     sprintf(filename, "%s/.elm", home);
  4138.       if (access(filename, 00) == -1) {
  4139.         if(batch_only)  {
  4140.           printf("\n\rNotice:\
  4141. --- 173,180 ----
  4142.       strcpy(calendar_file, raw_calendar_file);
  4143.   
  4144.       /* see if the user has a $HOME/.elm directory */
  4145. !     sprintf(filename, "%s/%s", home, dotelm);
  4146.       if (access(filename, 00) == -1) {
  4147.         if(batch_only)  {
  4148.           printf("\n\rNotice:\
  4149. ***************
  4150. *** 200,210 ****
  4151.   
  4152.       /* Look for the elmrc file */
  4153.       sprintf(filename,"%s/%s", home, elmrcfile);
  4154.       if ((file = fopen(filename, "r")) == NULL) {
  4155.         dprint(2,(debugfile,"Warning:User has no \".elm/elmrc\" file\n\n"));
  4156.   
  4157.         /* look for old-style .elmrc file in $HOME */
  4158. !       sprintf(filename, "%s/.elmrc", home);
  4159.         if (access(filename, 00) != -1) {
  4160.           move_old_files_to_new();
  4161.   
  4162. --- 205,216 ----
  4163.   
  4164.       /* Look for the elmrc file */
  4165.       sprintf(filename,"%s/%s", home, elmrcfile);
  4166.       if ((file = fopen(filename, "r")) == NULL) {
  4167.         dprint(2,(debugfile,"Warning:User has no \".elm/elmrc\" file\n\n"));
  4168.   
  4169.         /* look for old-style .elmrc file in $HOME */
  4170. !       sprintf(filename, "%s/%src", home, dotelm);
  4171.         if (access(filename, 00) != -1) {
  4172.           move_old_files_to_new();
  4173.   
  4174. ***************
  4175. *** 513,518 ****
  4176. --- 519,526 ----
  4177.          * can read them before screen is cleared */
  4178.         if(errors)
  4179.           sleep((errors * 2) + 2);
  4180. +           fclose(file);
  4181.       }
  4182.   
  4183.       /* see if the user has a folders directory */
  4184. diff -cbr orig/src/remail.c new/src/remail.c
  4185. *** orig/src/remail.c    Sat Oct 16 18:43:56 1993
  4186. --- new/src/remail.c    Fri Apr 22 20:43:28 1994
  4187. ***************
  4188. *** 38,44 ****
  4189. --- 38,46 ----
  4190.   #include "headers.h"
  4191.   #include <errno.h>
  4192.   
  4193. + #ifndef OS2
  4194.   extern int errno;
  4195. + #endif
  4196.   
  4197.   char *error_name(), *error_description();
  4198.   
  4199. ***************
  4200. *** 52,57 ****
  4201. --- 54,60 ----
  4202.       char *filename, buffer[VERY_LONG_STRING], ch;
  4203.       char mailerflags[NLEN];
  4204.       extern char *tempnam();
  4205. +         int sys_status;
  4206.   
  4207.       entered[0] = '\0';
  4208.   
  4209. ***************
  4210. *** 61,67 ****
  4211.   
  4212.       display_to(expanded);
  4213.   
  4214. !     if((filename=tempnam(temp_dir, "snd.")) == NULL) {
  4215.         dprint(1, (debugfile, "couldn't make temp file nam! (remail)\n"));
  4216.         sprintf(buffer, "Sorry - couldn't make file temp file name.");
  4217.         set_error(buffer);
  4218. --- 64,70 ----
  4219.   
  4220.       display_to(expanded);
  4221.   
  4222. !     if((filename=tempnam(temp_dir, "snd")) == NULL) {
  4223.         dprint(1, (debugfile, "couldn't make temp file nam! (remail)\n"));
  4224.         sprintf(buffer, "Sorry - couldn't make file temp file name.");
  4225.         set_error(buffer);
  4226. ***************
  4227. *** 84,95 ****
  4228.   
  4229.       chown (filename, userid, groupid);
  4230.   
  4231. ! #ifdef MMDF
  4232.       if (strcmp(submitmail, mailer) == 0)
  4233.         do_mmdf_addresses(mailfd, strip_parens(strip_commas(expanded)));
  4234.   #endif /* MMDF */
  4235.   
  4236. !     copy_message("", mailfd, FALSE, TRUE, FALSE, TRUE, TRUE);
  4237.   
  4238.       fclose(mailfd);
  4239.   
  4240. --- 87,98 ----
  4241.   
  4242.       chown (filename, userid, groupid);
  4243.   
  4244. ! #ifdef _MMDF
  4245.       if (strcmp(submitmail, mailer) == 0)
  4246.         do_mmdf_addresses(mailfd, strip_parens(strip_commas(expanded)));
  4247.   #endif /* MMDF */
  4248.   
  4249. !     copy_message("", mailfd, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE);
  4250.   
  4251.       fclose(mailfd);
  4252.   
  4253. ***************
  4254. *** 112,140 ****
  4255.       }
  4256.       Write_to_screen("Yes.", 0);
  4257.   
  4258. !     if (strcmp(sendmail, mailer) == 0
  4259. ! #ifdef SITE_HIDING
  4260. !         && ! is_a_hidden_user(username))
  4261. ! #else
  4262. !                      )
  4263. ! #endif
  4264. !       strcpy(mailerflags, (sendmail_verbose ? smflagsv : smflags));
  4265. !     else if (strcmp(submitmail, mailer) == 0) {
  4266. !       strcpy(mailerflags, submitflags_s);
  4267. !           strcpy(expanded, " ");
  4268. !     } else
  4269. !       mailerflags[0] = '\0';
  4270. !     sprintf(buffer,"( (%s %s %s ; %s %s) & ) < %s", 
  4271. !           mailer, mailerflags, strip_parens(strip_commas(expanded)), 
  4272. !           remove_cmd, filename, filename);
  4273.   
  4274.       PutLine0(LINES,0,"Resending mail...");
  4275. !     system_call(buffer, SH, FALSE, FALSE);
  4276.               set_error("Mail resent.");
  4277.   
  4278.       return(1);
  4279.   }
  4280.   #ifdef MMDF
  4281.   do_mmdf_addresses(dest_file,buffer)
  4282.   FILE *dest_file;
  4283. --- 115,148 ----
  4284.       }
  4285.       Write_to_screen("Yes.", 0);
  4286.   
  4287. !     if (strcmp(sendmail, mailer) == 0)
  4288. !     {
  4289. !       sprintf(buffer,"sndmail %s -af %s -f %s@%s %s >nul 2>&1", 
  4290. !           background ? "-bg" : "",
  4291. !           filename, username, hostfromname, 
  4292. !           strip_parens(strip_commas(expanded)));
  4293. !     }
  4294. !     else
  4295. !       sprintf(buffer,"%s -f %s %s 2>nul", 
  4296. !           mailer, filename, strip_parens(strip_commas(expanded)));
  4297. !     }
  4298.   
  4299.       PutLine0(LINES,0,"Resending mail...");
  4300. !     if ( sys_status = system_call(buffer, SH, FALSE, FALSE) ) {
  4301. !         /* problem case: */
  4302. !         sprintf(buffer, "mailer returned error status %d", sys_status);
  4303. !         set_error(buffer);
  4304. !     } else {
  4305.               set_error("Mail resent.");
  4306. +         }
  4307. +     if (!background)
  4308. +       unlink(filename);
  4309.   
  4310.       return(1);
  4311.   }
  4312.   #ifdef MMDF
  4313.   do_mmdf_addresses(dest_file,buffer)
  4314.   FILE *dest_file;
  4315. diff -cbr orig/src/reply.c new/src/reply.c
  4316. *** orig/src/reply.c    Sat Oct 16 18:43:58 1993
  4317. --- new/src/reply.c    Sat Feb 01 16:03:14 1992
  4318. ***************
  4319. *** 30,37 ****
  4320. --- 30,39 ----
  4321.   #ifndef BSD
  4322.   #  include <sys/types.h>
  4323.   # ifndef VMS
  4324. + # ifndef OS2
  4325.   #  include <sys/utsname.h>
  4326.   # endif
  4327. + # endif
  4328.   #endif
  4329.   
  4330.   /** Note that this routine generates automatic header information
  4331. ***************
  4332. *** 41,47 ****
  4333. --- 43,51 ----
  4334.   
  4335.   char *strip_parens(), *get_token();
  4336.   
  4337. + #ifndef OS2
  4338.   extern int errno;
  4339. + #endif
  4340.   
  4341.   char *error_name(), *strcat(), *strcpy();
  4342.   
  4343. ***************
  4344. *** 390,395 ****
  4345. --- 390,410 ----
  4346.       dprint(6, (debugfile,"get_return_name called with (%s, <>, shift=%s)\n",
  4347.              address, onoff(trans_to_lowercase)));
  4348.   
  4349. +     /* skip leading white space */
  4350. +     while (whitespace(*address))
  4351. +       address++;
  4352. +     /* skip possible "" quoted full name and possible opening < */
  4353. +     if (*address == '"') {
  4354. +       for (address++; *address != '"' && *address != 0; address++);
  4355. +       if (*address == '"')
  4356. +         address++;
  4357. +       while (whitespace(*address))
  4358. +         address++;
  4359. +     }
  4360. +     if (*address == '<')
  4361. +       address++;
  4362.       /* First step - copy address up to a comma, space, or EOLN */
  4363.   
  4364.       for (i=0; address[i] != ',' && ! whitespace(address[i]) &&
  4365. diff -cbr orig/src/returnadd.c new/src/returnadd.c
  4366. *** orig/src/returnadd.c    Sat Oct 16 18:43:58 1993
  4367. --- new/src/returnadd.c    Sat May 23 18:45:44 1992
  4368. ***************
  4369. *** 48,54 ****
  4370. --- 48,56 ----
  4371.   
  4372.   char *shift_lower();
  4373.   
  4374. + #ifndef OS2
  4375.   extern int errno;
  4376. + #endif
  4377.   
  4378.   char *error_name(), *strcat(), *strcpy();
  4379.   
  4380. ***************
  4381. *** 245,251 ****
  4382.       char buf[SLEN], name1[SLEN], name2[SLEN], lastname[SLEN];
  4383.       char hold_return[SLEN], alt_name2[SLEN], buf2[SLEN];
  4384.       int ok = 1, lines, len_buf, len_buf2;
  4385. !     int using_to = FALSE;
  4386.   
  4387.       /* now initialize all the char buffers [thanks Keith!] */
  4388.   
  4389. --- 247,253 ----
  4390.       char buf[SLEN], name1[SLEN], name2[SLEN], lastname[SLEN];
  4391.       char hold_return[SLEN], alt_name2[SLEN], buf2[SLEN];
  4392.       int ok = 1, lines, len_buf, len_buf2;
  4393. !     int using_to = FALSE, in_header = FALSE;
  4394.   
  4395.       /* now initialize all the char buffers [thanks Keith!] */
  4396.   
  4397. ***************
  4398. *** 275,285 ****
  4399. --- 277,289 ----
  4400.       /** okay!  Now we're there!  **/
  4401.   
  4402.       lines = headers[msgnum]->lines;
  4403. +     in_header = TRUE;
  4404.   
  4405.       buffer[0] = '\0';
  4406.   
  4407.       ok = (int) (fgets(buf2, SLEN, mailfile) != NULL);
  4408.       if (ok) {
  4409. +       fixline(buf2);
  4410.         len_buf2 = strlen(buf2);
  4411.         if(buf2[len_buf2-1] == '\n') lines--; /* got a full line */
  4412.       }
  4413. ***************
  4414. *** 290,295 ****
  4415. --- 294,300 ----
  4416.         len_buf = strlen(buf);
  4417.         ok = (int) (fgets(buf2, SLEN, mailfile) != NULL);
  4418.         if (ok) {
  4419. +         fixline(buf2);
  4420.           len_buf2 = strlen(buf2);
  4421.           if(buf2[len_buf2-1] == '\n') lines--; /* got a full line */
  4422.         }
  4423. ***************
  4424. *** 309,314 ****
  4425. --- 314,331 ----
  4426.   
  4427.   /* At this point, "buf" contains the unfolded header line, while "buf2" contains
  4428.      the next single line of text from the mail file */
  4429. +       if (in_header) {
  4430. +         if (len_buf == 1) /* \n only */
  4431. +           in_header = FALSE;
  4432. +       }
  4433. +       else {
  4434. +         if (first_word(buf, "Forwarded "))
  4435. +           in_header = TRUE;
  4436. +       }
  4437. +       if (!in_header)
  4438. +         continue;
  4439.   
  4440.         if (first_word(buf, "From "))
  4441.           sscanf(buf, "%*s %s", hold_return);
  4442. ***************
  4443. *** 445,451 ****
  4444.             ok = (int) (fgets(mybuf, LONG_STRING, mailfile) != NULL);
  4445.         no_ret(mybuf);    /* remove return character */
  4446.   
  4447. !           if (first_word(mybuf, "To: ")) {
  4448.           in_to = TRUE;
  4449.           strcpy(buffer, (char *) mybuf + strlen("To: "));
  4450.             }
  4451. --- 445,451 ----
  4452.             ok = (int) (fgets(mybuf, LONG_STRING, mailfile) != NULL);
  4453.         no_ret(mybuf);    /* remove return character */
  4454.   
  4455. !           if (first_word(mybuf, "To:")) {
  4456.           in_to = TRUE;
  4457.           strcpy(buffer, (char *) mybuf + strlen("To: "));
  4458.             }
  4459. diff -cbr orig/src/save_opts.c new/src/save_opts.c
  4460. *** orig/src/save_opts.c    Sat Oct 16 18:43:58 1993
  4461. --- new/src/save_opts.c    Wed Apr 01 12:18:02 1992
  4462. ***************
  4463. *** 35,41 ****
  4464. --- 35,43 ----
  4465.   
  4466.   #define absolute(x)        ((x) < 0? -(x) : (x))
  4467.   
  4468. + #ifndef OS2
  4469.   extern  int errno;
  4470. + #endif
  4471.   extern char version_buff[];
  4472.   
  4473.   char *error_name(), *sort_name();
  4474. ***************
  4475. *** 64,70 ****
  4476.       **/
  4477.   
  4478.       FILE *newelmrc;
  4479. !     char  oldfname[SLEN], newfname[SLEN];
  4480.   
  4481.       sprintf(newfname, "%s/%s", home, elmrcfile);
  4482.       sprintf(oldfname, "%s/%s", home, old_elmrcfile);
  4483. --- 66,72 ----
  4484.       **/
  4485.   
  4486.       FILE *newelmrc;
  4487. !     char  oldfname[SLEN], newfname[SLEN], inffname[SLEN];
  4488.   
  4489.       sprintf(newfname, "%s/%s", home, elmrcfile);
  4490.       sprintf(oldfname, "%s/%s", home, old_elmrcfile);
  4491. ***************
  4492. *** 82,91 ****
  4493.       }
  4494.   
  4495.       /** now let's open the datafile if we can... **/
  4496.   
  4497. !     if ((elminfo = fopen(ELMRC_INFO, "r")) == NULL) 
  4498.         error1("Warning: saving without comments! Can't get to %s.",
  4499. !           ELMRC_INFO);
  4500.   
  4501.       /** next, open the new .elm/elmrc file... **/
  4502.   
  4503. --- 84,94 ----
  4504.       }
  4505.   
  4506.       /** now let's open the datafile if we can... **/
  4507. +     sprintf(inffname,"%s/%s", helphome, elmrc_info);
  4508.   
  4509. !     if ((elminfo = fopen(inffname, "r")) == NULL)
  4510.         error1("Warning: saving without comments! Can't get to %s.",
  4511. !           inffname);
  4512.   
  4513.       /** next, open the new .elm/elmrc file... **/
  4514.   
  4515. diff -cbr orig/src/savecopy.c new/src/savecopy.c
  4516. *** orig/src/savecopy.c    Sat Oct 16 18:44:00 1993
  4517. --- new/src/savecopy.c    Tue Sep 28 23:36:40 1993
  4518. ***************
  4519. *** 39,49 ****
  4520.   char *ctime();
  4521.   
  4522.   extern char in_reply_to[SLEN];    /* In-Reply-To: string */
  4523.   extern int errno;
  4524.   
  4525.   char *strcat(), *strcpy();
  4526.   unsigned long sleep();
  4527. ! long  time();
  4528.   
  4529.   save_copy(to, cc, bcc, filename, copy_file, form)
  4530.   char *to, *cc, *bcc, *filename, *copy_file;
  4531. --- 39,51 ----
  4532.   char *ctime();
  4533.   
  4534.   extern char in_reply_to[SLEN];    /* In-Reply-To: string */
  4535. + #ifndef OS2
  4536.   extern int errno;
  4537. + #endif
  4538.   
  4539.   char *strcat(), *strcpy();
  4540.   unsigned long sleep();
  4541. ! time_t time();
  4542.   
  4543.   save_copy(to, cc, bcc, filename, copy_file, form)
  4544.   char *to, *cc, *bcc, *filename, *copy_file;
  4545. ***************
  4546. *** 129,135 ****
  4547.   
  4548.       /* Write header */
  4549.       if ((save = write_header_info(savename, to, cc, bcc,
  4550. !           form == YES, TRUE)) == NULL)
  4551.         return(FALSE);
  4552.   
  4553.       /* Now add file with message as handed to mailer */
  4554. --- 131,137 ----
  4555.   
  4556.       /* Write header */
  4557.       if ((save = write_header_info(savename, to, cc, bcc,
  4558. !           form == YES, TRUE, FALSE)) == NULL)
  4559.         return(FALSE);
  4560.   
  4561.       /* Now add file with message as handed to mailer */
  4562. diff -cbr orig/src/showmsg.c new/src/showmsg.c
  4563. *** orig/src/showmsg.c    Sat Oct 16 18:44:00 1993
  4564. --- new/src/showmsg.c    Wed Nov 17 10:44:46 1993
  4565. ***************
  4566. *** 38,44 ****
  4567. --- 38,48 ----
  4568.   # undef       tolower
  4569.   #endif
  4570.   
  4571. + #ifdef OS2
  4572. + # include <sys/wait.h>
  4573. + #else
  4574.   extern int errno;
  4575. + #endif
  4576.   
  4577.   char *error_name(), *strcat(), *strcpy();
  4578.   void   _exit();
  4579. ***************
  4580. *** 88,93 ****
  4581. --- 90,97 ----
  4582.           buf_len;                /* line length */
  4583.       struct header_rec *current_header = headers[number-1];
  4584.   
  4585. +     FILE *msgfile = mailfile;
  4586. +     char clearfile[SLEN];
  4587.   
  4588.       lines = current_header->lines;
  4589.   
  4590. ***************
  4591. *** 127,132 ****
  4592. --- 131,140 ----
  4593.       if(current_header->encrypted)
  4594.         getkey(OFF);
  4595.   
  4596. +     if (filter)
  4597. +       lines += perhaps_pgp_decode(number, clearfile);
  4598. +     fseek(mailfile, current_header->offset, 0); /* again */
  4599.       if(builtin=(first_word(pager,"builtin")||first_word(pager,"internal")))
  4600.   
  4601.         start_builtin(lines);
  4602. ***************
  4603. *** 136,141 ****
  4604. --- 144,153 ----
  4605.         /* put terminal out of raw mode so external pager has normal env */
  4606.         Raw(OFF);
  4607.   
  4608. + #ifdef OS2
  4609. +           if ( (pipe_wr_fp = popen(pager, "w")) == NULL )
  4610. +             return -1;
  4611. + #else
  4612.         /* create pipe for external pager and fork */
  4613.   
  4614.         if(pipe(pipe_fd) == -1) {
  4615. ***************
  4616. *** 213,218 ****
  4617. --- 225,231 ----
  4618.           Raw(OFF);
  4619.           return(val);    /* pager may have already touched the screen */
  4620.         }
  4621. + #endif
  4622.   
  4623.         /* and that's it! */
  4624.         lines_displayed = 0;
  4625. ***************
  4626. *** 247,253 ****
  4627.         /* truncate or pad title2 portion on the right
  4628.          * so that line fits exactly */
  4629.         padding =
  4630. !         COLUMNS -
  4631.           (strlen(title1) + (buf_len=strlen(title2)) + strlen(title3));
  4632.   
  4633.         sprintf(titlebuf, "%s%-*.*s%s\n", title1, buf_len+padding,
  4634. --- 260,266 ----
  4635.         /* truncate or pad title2 portion on the right
  4636.          * so that line fits exactly */
  4637.         padding =
  4638. !         COLUMNS - 1 -
  4639.           (strlen(title1) + (buf_len=strlen(title2)) + strlen(title3));
  4640.   
  4641.         sprintf(titlebuf, "%s%-*.*s%s\n", title1, buf_len+padding,
  4642. ***************
  4643. *** 356,363 ****
  4644.   
  4645.       while (lines > 0 && pipe_abort == FALSE) {
  4646.   
  4647. !         if (fgets(buffer, VERY_LONG_STRING, mailfile) == NULL) {
  4648.             
  4649.           dprint(1, (debugfile,
  4650.             "Premature end of file! Lines left = %d msg = %s (show_msg)\n",
  4651.             lines, number));
  4652. --- 369,377 ----
  4653.   
  4654.       while (lines > 0 && pipe_abort == FALSE) {
  4655.   
  4656. !         if (fgets(buffer, VERY_LONG_STRING, msgfile) == NULL) {
  4657.             
  4658. +           if (msgfile == mailfile) {
  4659.           dprint(1, (debugfile,
  4660.             "Premature end of file! Lines left = %d msg = %s (show_msg)\n",
  4661.             lines, number));
  4662. ***************
  4663. *** 366,371 ****
  4664. --- 380,393 ----
  4665.           sleep(2);
  4666.           break;
  4667.             }
  4668. +           else {
  4669. +         fclose(msgfile);
  4670. +         unlink(clearfile);
  4671. +         clearfile[0] = 0;
  4672. +         msgfile = mailfile;
  4673. +         continue;
  4674. +           }
  4675. +         }
  4676.           if ((buf_len=strlen(buffer)) > 0)  {
  4677.             if(buffer[buf_len - 1] == '\n') {
  4678.           lines--;
  4679. ***************
  4680. *** 392,397 ****
  4681. --- 414,422 ----
  4682.                   encode(buffer);
  4683.               val = show_line(buffer, builtin);
  4684.             }
  4685. +           else if (strlen(buffer) >= 5 && strncmp(buffer, "[pgp-", 5) == 0
  4686. +             && buffer[strlen(buffer) - 1] == ']')
  4687. +         /* skip */ ;
  4688.             else
  4689.               val = show_line(buffer, builtin);
  4690.           }
  4691. ***************
  4692. *** 412,417 ****
  4693. --- 437,456 ----
  4694.           }
  4695.           else if (form_letter_section == 1 || form_letter_section == 3)
  4696.             /** skip this stuff - we can't deal with it... **/;
  4697. +         else if (strcmp(buffer, "-----BEGIN PGP MESSAGE-----") == 0
  4698. +              && filter) 
  4699. +         {
  4700. +           /* skip PGP block and insert cleartext file for it */
  4701. +           do 
  4702. +           {
  4703. +         if (fgets(buffer, VERY_LONG_STRING, msgfile) == NULL)
  4704. +           break;
  4705. +         if ((buf_len=strlen(buffer)) > 0)
  4706. +           no_ret(buffer);
  4707. +           } while (strcmp(buffer, "-----END PGP MESSAGE-----") != 0);
  4708. +           if (strlen(clearfile) > 0)
  4709. +         msgfile = fopen(clearfile, "r");
  4710. +         }
  4711.           else
  4712.             val = show_line(buffer, builtin);
  4713.   
  4714. ***************
  4715. *** 421,436 ****
  4716. --- 460,487 ----
  4717.   
  4718.           if (cursor_control) transmit_functions(ON);
  4719.   
  4720. +     if (msgfile != mailfile) {
  4721. +       fclose(msgfile);
  4722. +       unlink(clearfile);
  4723. +     }
  4724.       if (!builtin) {
  4725. + #ifdef OS2
  4726. +       wait_stat = pclose(pipe_wr_fp);
  4727. +       val = WIFEXITED(wait_stat) ? WEXITSTATUS(wait_stat) : 0;
  4728. + #else
  4729.         fclose(pipe_wr_fp);
  4730.         while ((wait_ret = wait(&wait_stat)) != fork_ret
  4731.             && wait_ret!= -1)
  4732.           ;
  4733. + #endif
  4734.         /* turn raw on **after** child terminates in case child
  4735.          * doesn't put us back to cooked mode after we return ourselves
  4736.          * to raw.
  4737.          */
  4738.         Raw(ON);
  4739. +       EndBold();
  4740. +       ClearScreen();
  4741.       }
  4742.   
  4743.       /* If we are to prompt for a user input command and we don't
  4744. ***************
  4745. *** 476,479 ****
  4746. --- 526,609 ----
  4747.       if (errno != 0)
  4748.         dprint(1, (debugfile, "\terror %s hit!\n", error_name(errno)));
  4749.       return(0);
  4750. + }
  4751. + perhaps_pgp_decode(number, filename)
  4752. + int number;
  4753. + char *filename;
  4754. + {
  4755. +   char buffer[VERY_LONG_STRING], cryptname[SLEN], clearname[SLEN];
  4756. +   int lines = headers[number-1] -> lines;
  4757. +   int oldlines = 0, pgp = 0, sign = 0;
  4758. +   FILE *tempfile;
  4759. +   filename[0] = 0;
  4760. +   sprintf(cryptname, "%s%d%s", temp_dir, getpid(), temp_file);
  4761. +   sprintf(clearname, "%s%d.msg", temp_dir, getpid());
  4762. +       
  4763. +   if ((tempfile = fopen(cryptname, "w")) == NULL) 
  4764. +   {
  4765. +     if(batch_only)
  4766. +       printf("Could not create file %s (%s).\n", cryptname, error_name(errno));
  4767. +     else
  4768. +       error2("Could not create file %s (%s).", cryptname, error_name(errno));
  4769. +     return 0;
  4770. +   }
  4771. +   while (lines--) 
  4772. +   {
  4773. +     if (fgets(buffer, VERY_LONG_STRING, mailfile) == NULL)
  4774. +       return 0;
  4775. +     no_ret(buffer);
  4776. +     if (pgp)
  4777. +       oldlines++;
  4778. +     if (strcmp(buffer, "-----BEGIN PGP MESSAGE-----") == 0)
  4779. +       pgp = 1;
  4780. +     else if (strcmp(buffer, "-----BEGIN PGP SIGNED MESSAGE-----") == 0)
  4781. +       pgp = sign = 1;
  4782. +     if (pgp)
  4783. +       fprintf(tempfile, "%s\n", buffer);
  4784. +     if (strcmp(buffer, "-----END PGP MESSAGE-----") == 0)
  4785. +       pgp = 0;
  4786. +     else if (strcmp(buffer, "-----END PGP SIGNATURE-----") == 0)
  4787. +       pgp = 0;
  4788. +   }
  4789. +   fclose(tempfile);
  4790. +   if (oldlines == 0)
  4791. +   {
  4792. +     unlink(cryptname);
  4793. +     return 0;
  4794. +   }
  4795. +   sprintf(buffer, "pgp -f <%s >%s", cryptname, clearname);
  4796. +   os2path(buffer);
  4797. +   puts("\r\n");
  4798. +   if (sign)
  4799. +     strcpy(clearname, "nul");
  4800. +   if (system_call(buffer, SH, FALSE, FALSE)) 
  4801. +   {
  4802. +     if (batch_only)
  4803. +       printf("Error while decrypting. Try again.\n");
  4804. +     else
  4805. +       error2("Error while decrypting. Try again.");
  4806. +     return 0;
  4807. +   }
  4808. +   if (sign)
  4809. +   {
  4810. +     puts("");
  4811. +     PutLine0(LINES,0,"Please Press any key to continue.");
  4812. +     (void) ReadCh();
  4813. +     return 0;
  4814. +   }
  4815. +   if ((tempfile = fopen(clearname, "r")) == NULL) 
  4816. +   {
  4817. +     if(batch_only)
  4818. +       printf("Could not read file %s (%s).\n", clearname, error_name(errno));
  4819. +     else
  4820. +       error2("Could not read file %s (%s).", clearname, error_name(errno));
  4821. +     return 0;
  4822. +   }
  4823. +   for (lines = 0; fgets(buffer, VERY_LONG_STRING, tempfile) != NULL; lines++);
  4824. +   fclose(tempfile);
  4825. +   strcpy(filename, clearname);
  4826. +   return lines - oldlines;
  4827.   }
  4828. diff -cbr orig/src/signals.c new/src/signals.c
  4829. *** orig/src/signals.c    Sat Oct 16 18:44:00 1993
  4830. --- new/src/signals.c    Thu Sep 16 23:20:58 1993
  4831. ***************
  4832. *** 94,100 ****
  4833.   alarm_signal()
  4834.   {
  4835.       /** silently process alarm signal for timeouts... **/
  4836. ! #ifdef    BSD
  4837.       if (InGetPrompt)
  4838.           longjmp(GetPromptBuf, 1);
  4839.   #else
  4840. --- 94,104 ----
  4841.   alarm_signal()
  4842.   {
  4843.       /** silently process alarm signal for timeouts... **/
  4844. ! #ifdef OS2
  4845. !     signal(SIGALRM, SIG_ACK);
  4846. !     signal(SIGALRM, alarm_signal);
  4847. ! #endif
  4848. ! #if defined(BSD) || defined(OS2)
  4849.       if (InGetPrompt)
  4850.           longjmp(GetPromptBuf, 1);
  4851.   #else
  4852. ***************
  4853. *** 109,116 ****
  4854.       dprint(2, (debugfile, "*** received SIGPIPE ***\n\n"));
  4855.   
  4856.       pipe_abort = TRUE;    /* internal signal ... wheeee!  */
  4857.       signal(SIGPIPE, pipe_signal);
  4858.   }
  4859.   
  4860.   #ifdef SIGTSTP
  4861. --- 113,122 ----
  4862.       dprint(2, (debugfile, "*** received SIGPIPE ***\n\n"));
  4863.   
  4864.       pipe_abort = TRUE;    /* internal signal ... wheeee!  */
  4865. ! #ifndef OS2
  4866. !     signal(SIGPIPE, SIG_ACK);
  4867.       signal(SIGPIPE, pipe_signal);
  4868. + #endif
  4869.   }
  4870.   
  4871.   #ifdef SIGTSTP
  4872. diff -cbr orig/src/strings.c new/src/strings.c
  4873. *** orig/src/strings.c    Sat Oct 16 18:44:02 1993
  4874. --- new/src/strings.c    Sun Aug 22 13:25:40 1993
  4875. ***************
  4876. *** 219,224 ****
  4877. --- 219,230 ----
  4878.           found in the output stream...
  4879.       **/
  4880.   
  4881. + #ifdef OS2
  4882. + #define MAXLENGTH 1
  4883. + #else
  4884. + #define MAXLENGTH 80
  4885. + #endif
  4886.       static char ret_buffer[VERY_LONG_STRING];
  4887.       register int iindex = 0, current_length = 0, depth=15, i, len;
  4888.       char     buffer[VERY_LONG_STRING];
  4889. ***************
  4890. *** 234,240 ****
  4891.   
  4892.           /* first, decide what sort of separator we need, if any... */
  4893.   
  4894. !       if (strlen(word) + current_length > 80) {
  4895.           if (iindex > 0) {
  4896.             ret_buffer[iindex++] = ',';    /* close 'er up, doctor! */
  4897.             ret_buffer[iindex++] = '\n';
  4898. --- 240,246 ----
  4899.   
  4900.           /* first, decide what sort of separator we need, if any... */
  4901.   
  4902. !       if (strlen(word) + current_length > MAXLENGTH) {
  4903.           if (iindex > 0) {
  4904.             ret_buffer[iindex++] = ',';    /* close 'er up, doctor! */
  4905.             ret_buffer[iindex++] = '\n';
  4906. diff -cbr orig/src/syscall.c new/src/syscall.c
  4907. *** orig/src/syscall.c    Sat Oct 16 18:44:02 1993
  4908. --- new/src/syscall.c    Sun Jan 16 11:31:50 1994
  4909. ***************
  4910. *** 54,59 ****
  4911. --- 54,63 ----
  4912.   #  include <sys/wait.h>
  4913.   #endif
  4914.   
  4915. + #ifdef OS2
  4916. + #  include <process.h>
  4917. + #endif
  4918.   char *argv_zero();
  4919.   void  _exit();
  4920.   
  4921. ***************
  4922. *** 72,82 ****
  4923. --- 76,91 ----
  4924.       helpful = (user_level == 0);
  4925.   
  4926.       if (helpful)
  4927. + #ifdef OS2
  4928. +       PutLine0(LINES-3,COLUMNS-40,"(Enter empty command for a shell.)");
  4929. + #else
  4930.         PutLine0(LINES-3,COLUMNS-40,"(Use the shell name for a shell.)");
  4931. + #endif
  4932.       PutLine0(LINES-2,0,"Shell command: ");
  4933.       CleartoEOS();
  4934.       command[0] = '\0';
  4935.       (void) optionally_enter(command, LINES-2, 15, FALSE, FALSE);
  4936. + #ifndef OS2
  4937.       if (command[0] == 0) {
  4938.         if (helpful)
  4939.           MoveCursor(LINES-3,COLUMNS-40);
  4940. ***************
  4941. *** 85,90 ****
  4942. --- 94,100 ----
  4943.         CleartoEOS();
  4944.         return 0;
  4945.       }
  4946. + #endif
  4947.   
  4948.       MoveCursor(LINES,0);
  4949.       CleartoEOLN();
  4950. ***************
  4951. *** 100,115 ****
  4952.       umask(077);        /* now put it back to private for mail files */
  4953.   
  4954.       SetXYLocation(0, 40);    /* a location not near the next request, so an absolute is used */
  4955. -     PutLine0(LINES, 0, "\n\nPress any key to return to ELM: ");
  4956.       Raw(ON);
  4957.           (void) getchar();
  4958.       if (old_raw == OFF)
  4959.         Raw(OFF);
  4960.       softkeys_on();
  4961.       if (cursor_control)
  4962.         transmit_functions(ON);
  4963.   
  4964. !     if (ret)
  4965.         error1("Return code was %d.", ret);
  4966.   
  4967.       return 1;
  4968. --- 110,127 ----
  4969.       umask(077);        /* now put it back to private for mail files */
  4970.   
  4971.       SetXYLocation(0, 40);    /* a location not near the next request, so an absolute is used */
  4972.       Raw(ON);
  4973. +     if (command[0]) {
  4974. +         PutLine0(LINES, 0, "\r\n\r\nPress any key to return to ELM: ");
  4975.           (void) getchar();
  4976. +     }
  4977.       if (old_raw == OFF)
  4978.         Raw(OFF);
  4979.       softkeys_on();
  4980.       if (cursor_control)
  4981.         transmit_functions(ON);
  4982.   
  4983. !     if (ret && command[0])
  4984.         error1("Return code was %d.", ret);
  4985.   
  4986.       return 1;
  4987. ***************
  4988. *** 151,161 ****
  4989. --- 163,185 ----
  4990.       register int (*oldstop)(), (*oldstart)();
  4991.   # endif
  4992.   #endif
  4993. + #ifndef OS2
  4994.       extern int errno;
  4995. + #endif
  4996.   
  4997.       sh = (shell_type == USER_SHELL) ? shell : "/bin/sh";
  4998.       dprint(2, (debugfile, "System Call: %s\n\t%s\n", sh, string));
  4999.   
  5000. + #ifdef OS2
  5001. +         tflush();
  5002. +     if ( shell_type != USER_SHELL )
  5003. +           if ( (sh = getenv("COMSPEC")) == NULL )
  5004. +             if ( (sh = getenv("SHELL")) == NULL )
  5005. +               sh = default_shell;
  5006. +         stat = spawnlp(P_WAIT, sh, sh, string[0] ? "/c" : NULL, string, NULL);
  5007. + #else
  5008.       /*
  5009.        * Note the neat trick with close-on-exec pipes.
  5010.        * If the child's exec() succeeds, then the pipe read returns zero.
  5011. ***************
  5012. *** 261,266 ****
  5013. --- 285,292 ----
  5014.       (void) signal(SIGCONT, oldstart);
  5015.   #endif
  5016.   
  5017. + #endif  /* OS2 */
  5018.       return(stat);
  5019.   }
  5020.   
  5021. ***************
  5022. *** 318,324 ****
  5023.   
  5024.       char buffer[SLEN], filename[SLEN], printbuffer[SLEN];
  5025.       char message_list[SLEN];
  5026. !     register int  retcode, to_print;
  5027.   
  5028.       if (strlen(printout) == 0) {
  5029.         error("Don't know how to print - option \"printmail\" undefined!");
  5030. --- 344,350 ----
  5031.   
  5032.       char buffer[SLEN], filename[SLEN], printbuffer[SLEN];
  5033.       char message_list[SLEN];
  5034. !     register int  retcode, to_print, cnt;
  5035.   
  5036.       if (strlen(printout) == 0) {
  5037.         error("Don't know how to print - option \"printmail\" undefined!");
  5038. ***************
  5039. *** 327,340 ****
  5040.   
  5041.       to_print = make_msg_list(message_list);
  5042.   
  5043. !     sprintf(filename,"%s%s%d", temp_dir, temp_print, getpid());
  5044.   
  5045.       if (in_string(printout, "%s"))
  5046.         sprintf(printbuffer, printout, filename);
  5047.       else
  5048.         sprintf(printbuffer, "%s %s", printout, filename);
  5049.   
  5050. !     sprintf(buffer,"(%s -p -f %s%s > %s; %s 2>&1) > /dev/null",
  5051.           readmsg,
  5052.           (folder_type == NON_SPOOL ? cur_folder : cur_tempfolder),
  5053.           message_list,
  5054. --- 353,367 ----
  5055.   
  5056.       to_print = make_msg_list(message_list);
  5057.   
  5058. !     sprintf(filename,"%s%d%s", temp_dir, getpid(), temp_print);
  5059. !     os2path(filename);
  5060.   
  5061.       if (in_string(printout, "%s"))
  5062.         sprintf(printbuffer, printout, filename);
  5063.       else
  5064.         sprintf(printbuffer, "%s %s", printout, filename);
  5065.   
  5066. !     sprintf(buffer,"%s -p -f %s %s >%s & %s 1>nul 2>nul",
  5067.           readmsg,
  5068.           (folder_type == NON_SPOOL ? cur_folder : cur_tempfolder),
  5069.           message_list,
  5070. ***************
  5071. *** 398,411 ****
  5072.           Helpmsg is what should be printed before the listing if not NULL.
  5073.       **/
  5074.   
  5075. !     char buffer[SLEN];
  5076.   
  5077.       Raw(OFF);
  5078.       ClearScreen();
  5079. !     MoveCursor(LINES, 0);
  5080.       if(helpmsg)
  5081.         printf(helpmsg);
  5082. !     sprintf(buffer, "dir /w \"%s\"", folders);
  5083.       printf("\n\rContents of your folder directory:\n\r\n\r");
  5084.       system_call(buffer, SH, FALSE, FALSE);
  5085.       while(numlines--)
  5086. --- 425,442 ----
  5087.           Helpmsg is what should be printed before the listing if not NULL.
  5088.       **/
  5089.   
  5090. !         char buffer[SLEN], foldersbs[SLEN];
  5091.   
  5092.       Raw(OFF);
  5093.       ClearScreen();
  5094. !     MoveCursor(0, 0);
  5095.       if(helpmsg)
  5096.         printf(helpmsg);
  5097. !         strcpy(foldersbs,folders);
  5098. !         os2path(foldersbs);
  5099. !         sprintf(buffer, "dir /w %s", foldersbs);
  5100.       printf("\n\rContents of your folder directory:\n\r\n\r");
  5101.       system_call(buffer, SH, FALSE, FALSE);
  5102.       while(numlines--)
  5103. diff -cbr orig/src/utils.c new/src/utils.c
  5104. *** orig/src/utils.c    Sat Oct 16 18:44:02 1993
  5105. --- new/src/utils.c    Mon Apr 06 16:33:04 1992
  5106. ***************
  5107. *** 36,42 ****
  5108. --- 36,44 ----
  5109.   
  5110.   #include <signal.h>
  5111.   
  5112. + #ifndef OS2
  5113.   extern int errno;
  5114. + #endif
  5115.   
  5116.   char *error_name();
  5117.   void   exit();
  5118. ***************
  5119. *** 68,83 ****
  5120.   
  5121.       char source[SLEN];
  5122.   #ifdef MKDIR
  5123. !     sprintf(source, "%s/.elm", home);
  5124.       (void) mkdir(source, 0700);
  5125.   #else
  5126.       char com[SLEN];
  5127.   
  5128.       /** Some systems don't have a mkdir call - how inconvienient! **/
  5129.   
  5130. !     sprintf(com, "mkdir %s/.elm", home);
  5131.       system_call(com, SH, FALSE, FALSE);
  5132. !     sprintf(com, "chmod 700 %s/.elm", home);
  5133.       system_call(com, SH, FALSE, FALSE);
  5134.   #endif /* MKDIR */
  5135.   
  5136. --- 70,85 ----
  5137.   
  5138.       char source[SLEN];
  5139.   #ifdef MKDIR
  5140. !     sprintf(source, "%s/%s", home, dotelm);
  5141.       (void) mkdir(source, 0700);
  5142.   #else
  5143.       char com[SLEN];
  5144.   
  5145.       /** Some systems don't have a mkdir call - how inconvienient! **/
  5146.   
  5147. !     sprintf(com, "mkdir %s/%s", home, dotelm);
  5148.       system_call(com, SH, FALSE, FALSE);
  5149. !     sprintf(com, "chmod 700 %s/%s", home, dotelm);
  5150.       system_call(com, SH, FALSE, FALSE);
  5151.   #endif /* MKDIR */
  5152.   
  5153. ***************
  5154. *** 108,121 ****
  5155.         (void) system_call("newalias", SH, FALSE, FALSE);
  5156.       }
  5157.   
  5158. !     sprintf(source, "%s/.elmheaders", home);
  5159.       if (access(source, ACCESS_EXISTS) != -1) {
  5160.         sprintf(dest,   "%s/%s", home, mailheaders);
  5161.         printf("\n\rCopying from: %s\n\rCopying to:   %s\n\r", source, dest);
  5162.         copy(source, dest);
  5163.       }
  5164.   
  5165. !     sprintf(source, "%s/.elmrc", home);
  5166.       if (access(source, ACCESS_EXISTS) != -1) {
  5167.         sprintf(dest,   "%s/%s", home, elmrcfile);
  5168.         printf("\n\rCopying from: %s\n\rCopying to:   %s\n\r", source, dest);
  5169. --- 110,123 ----
  5170.         (void) system_call("newalias", SH, FALSE, FALSE);
  5171.       }
  5172.   
  5173. !     sprintf(source, "%s/%sheaders", home, dotelm);
  5174.       if (access(source, ACCESS_EXISTS) != -1) {
  5175.         sprintf(dest,   "%s/%s", home, mailheaders);
  5176.         printf("\n\rCopying from: %s\n\rCopying to:   %s\n\r", source, dest);
  5177.         copy(source, dest);
  5178.       }
  5179.   
  5180. !     sprintf(source, "%s/%src", home, dotelm);
  5181.       if (access(source, ACCESS_EXISTS) != -1) {
  5182.         sprintf(dest,   "%s/%s", home, elmrcfile);
  5183.         printf("\n\rCopying from: %s\n\rCopying to:   %s\n\r", source, dest);
  5184. ***************
  5185. *** 142,148 ****
  5186.       if(folder_type == SPOOL) dprint(1, (debugfile,
  5187.            "     The mailbox lock file: %s\n", mk_lockname(cur_folder)));
  5188.       dprint(1, (debugfile,
  5189. !          "     The composition file : %s%s%d\n", temp_dir, temp_file, getpid()));
  5190.       dprint(1, (debugfile,
  5191.            "     The readmsg data file: %s/%s\n", home, readmsg_file));
  5192.   
  5193. --- 144,150 ----
  5194.       if(folder_type == SPOOL) dprint(1, (debugfile,
  5195.            "     The mailbox lock file: %s\n", mk_lockname(cur_folder)));
  5196.       dprint(1, (debugfile,
  5197. !          "     The composition file : %s%d%s\n", temp_dir, getpid(), temp_file));
  5198.       dprint(1, (debugfile,
  5199.            "     The readmsg data file: %s/%s\n", home, readmsg_file));
  5200.   
  5201. ***************
  5202. *** 151,161 ****
  5203.       if (hp_terminal)     softkeys_off();
  5204.   
  5205.       if (cursor_control)
  5206. !       MoveCursor(LINES, 0);
  5207.   
  5208.       PutLine0(LINES,0,
  5209.           "\nEmergency exit taken! All temp files intact!\n\n");
  5210.   
  5211.       exit(1);
  5212.   }
  5213.   rm_temps_exit()
  5214. --- 153,164 ----
  5215.       if (hp_terminal)     softkeys_off();
  5216.   
  5217.       if (cursor_control)
  5218. !       MoveCursor(LINES-1, 0);
  5219.   
  5220.       PutLine0(LINES,0,
  5221.           "\nEmergency exit taken! All temp files intact!\n\n");
  5222.   
  5223. +         ExitScreen();
  5224.       exit(1);
  5225.   }
  5226.   rm_temps_exit()
  5227. ***************
  5228. *** 167,184 ****
  5229.         Raw(OFF);
  5230.         if (cursor_control)  transmit_functions(OFF);
  5231.         if (hp_terminal)     softkeys_off();
  5232. !       sprintf(buffer,"%s%d",temp_file, getpid());  /* editor buffer */
  5233.         (void) unlink(buffer);
  5234.         if (folder_type == SPOOL) {
  5235.           (void) unlink(cur_tempfolder);
  5236.         }
  5237.         sprintf(buffer,"%s/%s", home, readmsg_file);  /* readmsg temp */
  5238.         (void) unlink(buffer);
  5239.         unlock();                               /* remove lock file if any */
  5240.         if(!batch_only) {
  5241. !         MoveCursor(LINES,0);
  5242.           NewLine();
  5243.         }
  5244.         exit(1);
  5245.   }
  5246.   
  5247. --- 170,190 ----
  5248.         Raw(OFF);
  5249.         if (cursor_control)  transmit_functions(OFF);
  5250.         if (hp_terminal)     softkeys_off();
  5251. !       sprintf(buffer,"%d%s", getpid(), temp_file);  /* editor buffer */
  5252.         (void) unlink(buffer);
  5253.         if (folder_type == SPOOL) {
  5254. +         if (mailfile)
  5255. +           fclose(mailfile);
  5256.           (void) unlink(cur_tempfolder);
  5257.         }
  5258.         sprintf(buffer,"%s/%s", home, readmsg_file);  /* readmsg temp */
  5259.         (void) unlink(buffer);
  5260.         unlock();                               /* remove lock file if any */
  5261.         if(!batch_only) {
  5262. !         MoveCursor(LINES-1,0);
  5263.           NewLine();
  5264.         }
  5265. +       ExitScreen();
  5266.         exit(1);
  5267.   }
  5268.   
  5269. ***************
  5270. *** 196,205 ****
  5271.       if (cursor_control)  transmit_functions(OFF);
  5272.       if (hp_terminal)     softkeys_off();
  5273.   
  5274. !     sprintf(buffer,"%s%s%d", temp_dir, temp_file, getpid());  /* editor buffer */
  5275.       (void) unlink(buffer);
  5276.   
  5277.       if (folder_type == SPOOL) {
  5278.         (void) unlink(cur_tempfolder);
  5279.       }
  5280.   
  5281. --- 202,213 ----
  5282.       if (cursor_control)  transmit_functions(OFF);
  5283.       if (hp_terminal)     softkeys_off();
  5284.   
  5285. !     sprintf(buffer,"%s%d%s", temp_dir, getpid(), temp_file);  /* editor buffer */
  5286.       (void) unlink(buffer);
  5287.   
  5288.       if (folder_type == SPOOL) {
  5289. +           if (mailfile)
  5290. +             fclose(mailfile);
  5291.         (void) unlink(cur_tempfolder);
  5292.       }
  5293.   
  5294. ***************
  5295. *** 209,218 ****
  5296.       unlock();                /* remove lock file if any */
  5297.   
  5298.       if(!batch_only) {
  5299. !       MoveCursor(LINES,0);
  5300.         NewLine();
  5301.       }
  5302.   
  5303.       exit(0);
  5304.   }
  5305.   
  5306. --- 217,227 ----
  5307.       unlock();                /* remove lock file if any */
  5308.   
  5309.       if(!batch_only) {
  5310. !       MoveCursor(LINES-1,0);
  5311.         NewLine();
  5312.       }
  5313.   
  5314. +     ExitScreen();
  5315.       exit(0);
  5316.   }
  5317.   
  5318. ***************
  5319. *** 230,241 ****
  5320.       if (cursor_control)  transmit_functions(OFF);
  5321.       if (hp_terminal)     softkeys_off();
  5322.   
  5323. !     sprintf(buffer,"%s%s%d", temp_dir, temp_file, getpid());  /* editor buffer */
  5324.       (void) unlink(buffer);
  5325.   
  5326. !     MoveCursor(LINES,0);
  5327.       NewLine();
  5328.   
  5329.       exit(0);
  5330.   }
  5331.   
  5332. --- 239,251 ----
  5333.       if (cursor_control)  transmit_functions(OFF);
  5334.       if (hp_terminal)     softkeys_off();
  5335.   
  5336. !     sprintf(buffer,"%s%d%s", temp_dir, getpid(), temp_file);  /* editor buffer */
  5337.       (void) unlink(buffer);
  5338.   
  5339. !     MoveCursor(LINES-1,0);
  5340.       NewLine();
  5341.   
  5342. +     ExitScreen();
  5343.       exit(0);
  5344.   }
  5345.   
  5346. ***************
  5347. *** 256,268 ****
  5348.       if (cursor_control)  transmit_functions(OFF);
  5349.       if (hp_terminal)     softkeys_off();
  5350.   
  5351. !     sprintf(buffer,"%s%s%d", temp_dir, temp_file, getpid());  /* editor buffer */
  5352.       (void) unlink(buffer);
  5353.   
  5354.       (void) unlink(cur_tempfolder);            /* temp mailbox */
  5355.   
  5356. !     MoveCursor(LINES,0);
  5357.       NewLine();
  5358.       exit(0);
  5359.   }
  5360.   #endif
  5361. --- 266,281 ----
  5362.       if (cursor_control)  transmit_functions(OFF);
  5363.       if (hp_terminal)     softkeys_off();
  5364.   
  5365. !     sprintf(buffer,"%s%d%s", temp_dir, getpid(), temp_file);  /* editor buffer */
  5366.       (void) unlink(buffer);
  5367.   
  5368. +         if (mailfile)
  5369. +           fclose(mailfile);
  5370.       (void) unlink(cur_tempfolder);            /* temp mailbox */
  5371.   
  5372. !     MoveCursor(LINES-1,0);
  5373.       NewLine();
  5374. +     ExitScreen();
  5375.       exit(0);
  5376.   }
  5377.   #endif
  5378. diff -cbr orig/src/validname.c new/src/validname.c
  5379. *** orig/src/validname.c    Sat Oct 16 18:44:04 1993
  5380. --- new/src/validname.c    Sat May 23 19:38:18 1992
  5381. ***************
  5382. *** 20,27 ****
  5383.    *
  5384.    ******************************************************************************/
  5385.   
  5386. - #include "defs.h"
  5387.   #include <stdio.h>
  5388.   
  5389.   #ifndef NOCHECK_VALIDNAME         /* Force a return of valid */
  5390. --- 20,25 ----
  5391. ***************
  5392. *** 32,37 ****
  5393. --- 30,37 ----
  5394.   # endif
  5395.   #endif
  5396.   
  5397. + #include "defs.h"
  5398.   int
  5399.   valid_name(name)
  5400.   char *name;
  5401. ***************
  5402. *** 53,59 ****
  5403.       if(getpwnam(name) != NULL)
  5404.         return(TRUE);
  5405.   
  5406. !     sprintf(filebuf,"%s/%s", mailhome, name);
  5407.       if (access(filebuf, ACCESS_EXISTS) == 0)
  5408.         return(TRUE);
  5409.   
  5410. --- 53,64 ----
  5411.       if(getpwnam(name) != NULL)
  5412.         return(TRUE);
  5413.   
  5414. ! #ifdef OS2
  5415. !     if (maildir)
  5416. !         sprintf(filebuf, "%s%s/newmail%s", mailhome, name, mailext);
  5417. !     else
  5418. ! #endif
  5419. !     sprintf(filebuf,"%s%s%s", mailhome, name, mailext);
  5420.       if (access(filebuf, ACCESS_EXISTS) == 0)
  5421.         return(TRUE);
  5422.   
  5423. diff -cbr orig/utils/answer.c new/utils/answer.c
  5424. *** orig/utils/answer.c    Sat Oct 16 18:44:04 1993
  5425. --- new/utils/answer.c    Sat Mar 28 17:55:48 1992
  5426. ***************
  5427. *** 32,44 ****
  5428.   #include <stdio.h>
  5429.   #include <fcntl.h>
  5430.   #include <ctype.h>
  5431.   
  5432.   #include "defs.h"            /* ELM system definitions      */
  5433.   
  5434.   #define  ELM        "elm"        /* where the elm program lives */
  5435.   
  5436. - #define  answer_temp_file    "/tmp/answer."
  5437.   static char ident[] = { WHAT_STRING };
  5438.   
  5439.   struct alias_rec user_hash_table  [MAX_UALIASES];
  5440. --- 32,43 ----
  5441.   #include <stdio.h>
  5442.   #include <fcntl.h>
  5443.   #include <ctype.h>
  5444. + #include <pwd.h>
  5445.   
  5446.   #include "defs.h"            /* ELM system definitions      */
  5447.   
  5448.   #define  ELM        "elm"        /* where the elm program lives */
  5449.   
  5450.   static char ident[] = { WHAT_STRING };
  5451.   
  5452.   struct alias_rec user_hash_table  [MAX_UALIASES];
  5453. ***************
  5454. *** 55,60 ****
  5455. --- 54,60 ----
  5456.       char  name[SLEN], user_name[SLEN];
  5457.       int   msgnum = 0, eof;
  5458.   
  5459. +         initpaths();
  5460.       read_alias_files();
  5461.   
  5462.       while (1) {
  5463. ***************
  5464. *** 64,70 ****
  5465.   
  5466.   prompt:   printf("\nMessage to: ");
  5467.         if (fgets(user_name, SLEN, stdin) == NULL) {
  5468. !         putchar('\n');
  5469.           exit(0);
  5470.         }
  5471.         if(user_name[0] == '\0')
  5472. --- 64,70 ----
  5473.   
  5474.   prompt:   printf("\nMessage to: ");
  5475.         if (fgets(user_name, SLEN, stdin) == NULL) {
  5476. !         putc('\n', stdout);
  5477.           exit(0);
  5478.         }
  5479.         if(user_name[0] == '\0')
  5480. ***************
  5481. *** 94,100 ****
  5482.           goto prompt;
  5483.         }
  5484.   
  5485. !       sprintf(tempfile, "%s%d", answer_temp_file, msgnum++);
  5486.   
  5487.         if ((fd = fopen(tempfile,"w")) == NULL)
  5488.           exit(printf("** Fatal Error: could not open %s to write\n",
  5489. --- 94,100 ----
  5490.           goto prompt;
  5491.         }
  5492.   
  5493. !       sprintf(tempfile, "%s%d.ans", tempdir, msgnum++);
  5494.   
  5495.         if ((fd = fopen(tempfile,"w")) == NULL)
  5496.           exit(printf("** Fatal Error: could not open %s to write\n",
  5497. ***************
  5498. *** 115,124 ****
  5499.         fclose(fd);
  5500.   
  5501.         sprintf(buffer,
  5502. !          "((%s -s \"While You Were Out\" %s ; %s %s) & ) < %s > /dev/null",
  5503. !          ELM, strip_parens(address), remove_cmd, tempfile, tempfile);
  5504.   
  5505.         system(buffer);
  5506.       }
  5507.   }
  5508.   
  5509. --- 115,125 ----
  5510.         fclose(fd);
  5511.   
  5512.         sprintf(buffer,
  5513. !          "%s -s \"While You Were Out\" %s <%s >nul",
  5514. !          ELM, strip_parens(address), tempfile);
  5515.   
  5516.         system(buffer);
  5517. +           unlink(tempfile);
  5518.       }
  5519.   }
  5520.   
  5521. ***************
  5522. *** 164,171 ****
  5523.   
  5524.       char fname[SLEN];
  5525.       int  hash;
  5526.   
  5527. !     sprintf(fname,  "%s/.elm/aliases.hash", getenv("HOME")); 
  5528.   
  5529.       if ((hash = open(fname, O_RDONLY)) == -1)
  5530.         exit(printf("** Fatal Error: Could not open %s!\n", fname));
  5531. --- 165,183 ----
  5532.   
  5533.       char fname[SLEN];
  5534.       int  hash;
  5535. +         char *getenv();
  5536. +         struct passwd *getpwuid();
  5537. +         struct passwd *pass;
  5538. +         char *homedir, *name;
  5539. +     name = getenv("LOGNAME");
  5540. +     if((pass = getpwnam(name ? name : "unknown")) == NULL) {
  5541. +       printf("You have no password entry!\n");
  5542. +       exit(1);
  5543. +     }
  5544. +     homedir = pass->pw_dir;
  5545.   
  5546. !     sprintf(fname,  "%s/%s", homedir, ALIAS_HASH);
  5547.   
  5548.       if ((hash = open(fname, O_RDONLY)) == -1)
  5549.         exit(printf("** Fatal Error: Could not open %s!\n", fname));
  5550. ***************
  5551. *** 173,179 ****
  5552.       read(hash, user_hash_table, sizeof user_hash_table);
  5553.       close(hash);
  5554.   
  5555. !     sprintf(fname,  "%s/.elm/aliases.data", getenv("HOME")); 
  5556.   
  5557.       if ((user_data = open(fname, O_RDONLY)) == -1)
  5558.         return;
  5559. --- 185,191 ----
  5560.       read(hash, user_hash_table, sizeof user_hash_table);
  5561.       close(hash);
  5562.   
  5563. !     sprintf(fname,  "%s/%s", homedir, ALIAS_DATA);
  5564.   
  5565.       if ((user_data = open(fname, O_RDONLY)) == -1)
  5566.         return;
  5567. ***************
  5568. *** 317,330 ****
  5569.           space = loc + length;
  5570.           while (buffer[space] != ' ' && space > loc + 50) space--;
  5571.           for (i=loc;i <= space;i++)
  5572. !           putchar(buffer[i]);
  5573. !         putchar('\n');
  5574.           loc = space;
  5575.         }
  5576.         else {
  5577.           for (i=loc, len = strlen(buffer);i < len;i++)
  5578. !           putchar(buffer[i]);
  5579. !         putchar('\n');
  5580.           loc = len;
  5581.         }
  5582.         length = 80;
  5583. --- 329,342 ----
  5584.           space = loc + length;
  5585.           while (buffer[space] != ' ' && space > loc + 50) space--;
  5586.           for (i=loc;i <= space;i++)
  5587. !           putc(buffer[i], stdout);
  5588. !         putc('\n', stdout);
  5589.           loc = space;
  5590.         }
  5591.         else {
  5592.           for (i=loc, len = strlen(buffer);i < len;i++)
  5593. !           putc(buffer[i], stdout);
  5594. !         putc('\n', stdout);
  5595.           loc = len;
  5596.         }
  5597.         length = 80;
  5598. diff -cbr orig/utils/arepdaem.c new/utils/arepdaem.c
  5599. *** orig/utils/arepdaem.c    Sat Oct 16 18:44:04 1993
  5600. --- new/utils/arepdaem.c    Sun Sep 26 16:28:24 1993
  5601. ***************
  5602. *** 83,97 ****
  5603.   
  5604.   static char ident[] = { WHAT_STRING };
  5605.   
  5606. ! #define arep_lock_file    "LCK..arep"
  5607. ! #define autoreply_file    "/etc/autoreply.data"
  5608. ! #define logfile        "/etc/autoreply.log"    /* first choice   */
  5609. ! #define logfile2    "/tmp/autoreply.log"    /* second choice  */
  5610.   
  5611.   #define BEGINNING    0        /* see fseek(3S) for info */
  5612. ! #define SLEEP_TIME    3600        /* run once an hour       */
  5613.   #define MAX_PEOPLE    20        /* max number in program  */
  5614.   
  5615.   #define EXISTS        00        /* lock file exists??     */
  5616. --- 83,95 ----
  5617.   
  5618.   static char ident[] = { WHAT_STRING };
  5619.   
  5620. ! char     arep_lock_file[SLEN];  /* autoreply lock file  */
  5621. ! char     autoreply_file[SLEN];  /* autoreply data file  */
  5622. ! char     logfile[SLEN];         /* first choice   */
  5623. ! #define logfile2    ("/" AUTOREP_LOG)    /* second choice  */
  5624.   
  5625.   #define BEGINNING    0        /* see fseek(3S) for info */
  5626. ! #define SLEEP_TIME    1800 /* 3600        /* run once an hour       */
  5627.   #define MAX_PEOPLE    20        /* max number in program  */
  5628.   
  5629.   #define EXISTS        00        /* lock file exists??     */
  5630. ***************
  5631. *** 130,140 ****
  5632. --- 128,146 ----
  5633.       int  person, data_changed;
  5634.       time_t time;
  5635.   
  5636. +         initpaths();
  5637. +         sprintf(autoreply_file, "%s/%s", elmhome, AUTOREP_FILE);
  5638. +         sprintf(logfile,        "%s/%s", elmhome, AUTOREP_LOG);
  5639. +         sprintf(arep_lock_file, "%s/%s", elmhome, AUTOREP_LOCK);
  5640. + #ifndef OS2
  5641.       if (fork()) exit(0);
  5642. + #endif
  5643.   
  5644.       if (! lock())
  5645.         exit(0);    /* already running! */
  5646.   
  5647. +     signal(SIGINT, term_signal);     /* Terminate signal         */
  5648.       signal(SIGTERM, term_signal);     /* Terminate signal         */
  5649.   
  5650.   /*
  5651. ***************
  5652. *** 143,150 ****
  5653. --- 149,158 ----
  5654.    *    The idea is to disassociate from the terminal to
  5655.    *    prevent signals.
  5656.    */
  5657. + #ifndef OS2
  5658.       person = getpid();
  5659.       setpgrp(person, person);
  5660. + #endif
  5661.   
  5662.       while (1) {
  5663.   
  5664. ***************
  5665. *** 159,164 ****
  5666. --- 167,173 ----
  5667.   
  5668.         /* 2. now for each active person... */
  5669.   
  5670. +       /* move_incoming_mail(); */
  5671.         data_changed = 0;
  5672.   
  5673.         for (person = 0; person < active; person++) {
  5674. ***************
  5675. *** 210,216 ****
  5676.       if ((file = fopen(autoreply_file,"r")) == NULL) {
  5677.         log("No-one is using autoreply...");
  5678.       } else {
  5679. !       while (fscanf(file, "%s %s %dl", username, replyfile, &size) != EOF) {
  5680.           /* check to see if this person is already in the list */
  5681.           if ((person = in_list(username)) != -1) {
  5682.             reply_table[person].in_list = 1;
  5683. --- 219,225 ----
  5684.       if ((file = fopen(autoreply_file,"r")) == NULL) {
  5685.         log("No-one is using autoreply...");
  5686.       } else {
  5687. !       while (fscanf(file, "%s %s %ld", username, replyfile, &size) != EOF) {
  5688.           /* check to see if this person is already in the list */
  5689.           if ((person = in_list(username)) != -1) {
  5690.             reply_table[person].in_list = 1;
  5691. ***************
  5692. *** 307,313 ****
  5693.   
  5694.       log("New mail for %s", reply_table[person].username);
  5695.   
  5696. !         if ((mailfile = fopen(reply_table[person].mailfile,"r")) == NULL)
  5697.              return(log("can't open mailfile for user %s",
  5698.               reply_table[person].username));
  5699.   
  5700. --- 316,322 ----
  5701.   
  5702.       log("New mail for %s", reply_table[person].username);
  5703.   
  5704. !         if ((mailfile = fopen(reply_table[person].mailfile,"rb")) == NULL)
  5705.              return(log("can't open mailfile for user %s",
  5706.               reply_table[person].username));
  5707.   
  5708. ***************
  5709. *** 347,352 ****
  5710. --- 356,363 ----
  5711.         if (fgets(buffer, SLEN, file) == NULL)
  5712.       return(-1);
  5713.   
  5714. +       fixline(buffer);
  5715.         if (first_word(buffer, "From ")) {
  5716.       in_header++;
  5717.       sscanf(buffer, "%*s %s", hold_return);
  5718. ***************
  5719. *** 473,479 ****
  5720.           is to check to see if new mail has arrived....  **/
  5721.   
  5722.       int ok = 1;
  5723. -     extern int errno;    /* system error number! */
  5724.       struct stat buffer;
  5725.   
  5726.       if (stat(name, &buffer) != 0)
  5727. --- 484,489 ----
  5728. ***************
  5729. *** 495,501 ****
  5730.           This is to check to see if autoreply has changed....  **/
  5731.   
  5732.       int ok = 1;
  5733. -     extern int errno;    /* system error number! */
  5734.       struct stat buffer;
  5735.   
  5736.       if (stat(name, &buffer) != 0)
  5737. --- 505,510 ----
  5738. ***************
  5739. *** 517,525 ****
  5740.   
  5741.       char buffer[VERY_LONG_STRING];
  5742.   
  5743. !     sprintf(buffer, "%s/fastmail -f '%s [autoreply]' -s '%s' %s %s",
  5744. !         BIN, reply_table[person].username,
  5745. !             subject, filename, to);
  5746.   
  5747.       system(buffer);
  5748.   }
  5749. --- 526,533 ----
  5750.   
  5751.       char buffer[VERY_LONG_STRING];
  5752.   
  5753. !     sprintf(buffer, "fastmail -f \"%s [autoreply]\" -s \"%s\" %s %s",
  5754. !         reply_table[person].username, subject, filename, to);
  5755.   
  5756.       system(buffer);
  5757.   }
  5758. ***************
  5759. *** 536,542 ****
  5760.       long      clock;
  5761.   #ifndef    _POSIX_SOURCE
  5762.       struct tm *localtime();
  5763. !     long      time();
  5764.   #endif
  5765.       char      buffer[SLEN];
  5766.   
  5767. --- 544,550 ----
  5768.       long      clock;
  5769.   #ifndef    _POSIX_SOURCE
  5770.       struct tm *localtime();
  5771. !     time_t time();
  5772.   #endif
  5773.       char      buffer[SLEN];
  5774.   
  5775. ***************
  5776. *** 608,616 ****
  5777.       char lock_name[SLEN];        /* name of lock file  */
  5778.       char pid_buffer[SHORT];
  5779.       int pid, create_fd;
  5780. -     extern int errno;    /* system error number! */
  5781.   
  5782. !     sprintf(lock_name, "%s/%s", LOCK_DIR, arep_lock_file);
  5783.   #ifdef PIDCHECK
  5784.         /** first, try to read the lock file, and if possible, check the pid.
  5785.         If we can validate that the pid is no longer active, then remove
  5786. --- 616,623 ----
  5787.       char lock_name[SLEN];        /* name of lock file  */
  5788.       char pid_buffer[SHORT];
  5789.       int pid, create_fd;
  5790.   
  5791. !     strcpy(lock_name, arep_lock_file);
  5792.   #ifdef PIDCHECK
  5793.         /** first, try to read the lock file, and if possible, check the pid.
  5794.         If we can validate that the pid is no longer active, then remove
  5795. ***************
  5796. *** 655,660 ****
  5797. --- 662,668 ----
  5798.   {
  5799.       /** remove lock file if it's there! **/
  5800.   
  5801. +         chmod(arep_lock_file, 0666);
  5802.       (void) unlink(arep_lock_file);
  5803.   }
  5804.   
  5805. diff -cbr orig/utils/autoreply.c new/utils/autoreply.c
  5806. *** orig/utils/autoreply.c    Sat Oct 16 18:44:06 1993
  5807. --- new/utils/autoreply.c    Sun Mar 29 10:06:00 1992
  5808. ***************
  5809. *** 46,55 ****
  5810.   
  5811.   static char ident[] = { WHAT_STRING };
  5812.   
  5813. ! #define  tempdir    "/tmp/arep"        /* file prefix          */
  5814. ! #define  autoreply_file    "/etc/autoreply.data"   /* autoreply data file  */
  5815.   
  5816. - extern   int errno;                /* system error code    */
  5817.   char     username[NLEN];    /* login name of user   */
  5818.   
  5819.   main(argc, argv)
  5820. --- 46,53 ----
  5821.   
  5822.   static char ident[] = { WHAT_STRING };
  5823.   
  5824. ! char     autoreply_file[SLEN];    /* autoreply data file  */
  5825.   
  5826.   char     username[NLEN];    /* login name of user   */
  5827.   
  5828.   main(argc, argv)
  5829. ***************
  5830. *** 63,70 ****
  5831.       struct passwd *getpwuid();
  5832.   #endif
  5833.   
  5834.       if (argc > 2) {
  5835. !       printf("Usage: %s <filename>\tto start autoreply,\n", argv[0]);
  5836.         printf("       %s off\t\tto turn off autoreply\n", argv[0]);
  5837.         printf("   or  %s    \t\tto check current status\n", argv[0]);
  5838.         exit(1);
  5839. --- 61,71 ----
  5840.       struct passwd *getpwuid();
  5841.   #endif
  5842.   
  5843. +         initpaths();
  5844. +         sprintf(autoreply_file, "%s/%s", elmhome, AUTOREP_FILE);
  5845.       if (argc > 2) {
  5846. !       printf("\nUsage: %s <filename>\tto start autoreply,\n", argv[0]);
  5847.         printf("       %s off\t\tto turn off autoreply\n", argv[0]);
  5848.         printf("   or  %s    \t\tto check current status\n", argv[0]);
  5849.         exit(1);
  5850. ***************
  5851. *** 86,99 ****
  5852.         remove_user((argc == 1));
  5853.       else {
  5854.         strcpy(filename, argv[1]);
  5855.         if (access(filename,READ_ACCESS) != 0) {
  5856.           printf("Error: Can't read file '%s'\n", filename);
  5857.           exit(1);
  5858.         }
  5859.   
  5860. -       if (filename[0] != '/') /* prefix home directory */
  5861. -         sprintf(filename,"%s/%s", getenv("HOME"), argv[1]);
  5862.         add_user(filename);
  5863.       }
  5864.   
  5865. --- 87,101 ----
  5866.         remove_user((argc == 1));
  5867.       else {
  5868.         strcpy(filename, argv[1]);
  5869. +       if (filename[0] != '/') /* prefix home directory */
  5870. +         sprintf(filename,"%s/%s", pass->pw_dir, argv[1]);
  5871.         if (access(filename,READ_ACCESS) != 0) {
  5872.           printf("Error: Can't read file '%s'\n", filename);
  5873.           exit(1);
  5874.         }
  5875.   
  5876.         add_user(filename);
  5877.       }
  5878.   
  5879. ***************
  5880. *** 113,119 ****
  5881.       long  filesize, bytes();
  5882.   
  5883.       if (! stat_only) {
  5884. !       sprintf(tempfile, "%s.%06d", tempdir, getpid());
  5885.   
  5886.         if ((temp = fopen(tempfile, "w")) == NULL) {
  5887.           printf("Error: couldn't open tempfile '%s'.  Not removed\n",
  5888. --- 115,121 ----
  5889.       long  filesize, bytes();
  5890.   
  5891.       if (! stat_only) {
  5892. !       sprintf(tempfile, "%s%d.ar", tempdir, getpid());
  5893.   
  5894.         if ((temp = fopen(tempfile, "w")) == NULL) {
  5895.           printf("Error: couldn't open tempfile '%s'.  Not removed\n",
  5896. ***************
  5897. *** 124,133 ****
  5898.   
  5899.       if ((repfile = fopen(autoreply_file, "r")) == NULL) {
  5900.         if (stat_only) {
  5901. !         printf("You're not currently autoreplying to mail.\n");
  5902.           exit(0);
  5903.         }
  5904. !       printf("No-one is autoreplying to their mail!\n");
  5905.         exit(0);
  5906.       }
  5907.   
  5908. --- 126,135 ----
  5909.   
  5910.       if ((repfile = fopen(autoreply_file, "r")) == NULL) {
  5911.         if (stat_only) {
  5912. !         printf("\nYou're not currently autoreplying to mail.\n");
  5913.           exit(0);
  5914.         }
  5915. !       printf("\nNo-one is autoreplying to their mail!\n");
  5916.         exit(0);
  5917.       }
  5918.   
  5919. ***************
  5920. *** 143,159 ****
  5921.         }
  5922.         else {
  5923.           if (stat_only) {
  5924. !           printf("You're currently autoreplying to mail with the file %s\n",              filename); 
  5925.             exit(0);
  5926.           }
  5927.           found++;
  5928.         }
  5929.   
  5930.         fclose(temp);
  5931.       fclose(repfile);
  5932.   
  5933.       if (! found) {
  5934. !       printf("You're not currently autoreplying to mail%s\n",
  5935.             stat_only? "." : "!");
  5936.         if (! stat_only)
  5937.           unlink(tempfile);
  5938. --- 145,163 ----
  5939.         }
  5940.         else {
  5941.           if (stat_only) {
  5942. !           printf("\nYou're currently autoreplying to mail with the file %s\n",              filename);
  5943.             exit(0);
  5944.           }
  5945.           found++;
  5946.         }
  5947.   
  5948. +     if (! stat_only)
  5949.         fclose(temp);
  5950.       fclose(repfile);
  5951.   
  5952.       if (! found) {
  5953. !       printf("\nYou're not currently autoreplying to mail%s\n",
  5954.             stat_only? "." : "!");
  5955.         if (! stat_only)
  5956.           unlink(tempfile);
  5957. ***************
  5958. *** 191,200 ****
  5959.       unlink(tempfile);
  5960.   
  5961.       if (found > 1)
  5962. !       printf("Warning: your username appeared %d times!!   Removed all\n", 
  5963.             found);
  5964.       else
  5965. !       printf("You've been removed from the autoreply table.\n");
  5966.   }
  5967.   
  5968.   add_user(filename)
  5969. --- 195,204 ----
  5970.       unlink(tempfile);
  5971.   
  5972.       if (found > 1)
  5973. !       printf("\nWarning: your username appeared %d times!!   Removed all\n",
  5974.             found);
  5975.       else
  5976. !       printf("\nYou've been removed from the autoreply table.\n");
  5977.   }
  5978.   
  5979.   add_user(filename)
  5980. ***************
  5981. *** 217,223 ****
  5982.   
  5983.       fclose(repfile);
  5984.   
  5985. !     printf("You've been added to the autoreply system.\n");
  5986.   }
  5987.   
  5988.   
  5989. --- 221,227 ----
  5990.   
  5991.       fclose(repfile);
  5992.   
  5993. !     printf("\nYou've been added to the autoreply system.\n");
  5994.   }
  5995.   
  5996.   
  5997. ***************
  5998. *** 229,235 ****
  5999.           is to check to see if new mail has arrived....  **/
  6000.   
  6001.       int ok = 1;
  6002. -     extern int errno;    /* system error number! */
  6003.       struct stat buffer;
  6004.   
  6005.       if (stat(name, &buffer) != 0)
  6006. --- 233,238 ----
  6007. diff -cbr orig/utils/expand.c new/utils/expand.c
  6008. *** orig/utils/expand.c    Sat Oct 16 18:44:06 1993
  6009. --- new/utils/expand.c    Sun May 03 16:19:28 1992
  6010. ***************
  6011. *** 28,36 ****
  6012. --- 28,39 ----
  6013.   **/
  6014.   
  6015.   #include <stdio.h>
  6016. + #include <pwd.h>
  6017.   #include "defs.h"
  6018.   
  6019.   char *expand_define();
  6020. + static struct passwd *pass;
  6021. + static char *home;
  6022.   
  6023.   int
  6024.   expand(filename)
  6025. ***************
  6026. *** 46,61 ****
  6027.       **/
  6028.   
  6029.       FILE *rcfile;
  6030. !     char  buffer[SLEN], *expanded_dir, *home, *getenv(), *bufptr;
  6031.       int   foundit = 0;
  6032.   
  6033.       bufptr = (char *) buffer;        /* same address */
  6034.   
  6035. !     if ((home = getenv("HOME")) == NULL) {
  6036. !       printf(
  6037. !          "Can't expand environment variable $HOME to find .elmrc file!\n");
  6038. !       return(NO);
  6039.       }
  6040.   
  6041.       sprintf(buffer, "%s/%s", home, elmrcfile);
  6042.   
  6043. --- 49,64 ----
  6044.       **/
  6045.   
  6046.       FILE *rcfile;
  6047. !     char  buffer[SLEN], *expanded_dir, *bufptr;
  6048.       int   foundit = 0;
  6049.   
  6050.       bufptr = (char *) buffer;        /* same address */
  6051.   
  6052. !     if((pass = getpwuid(getuid())) == NULL) {
  6053. !         printf("You have no password entry!\n");
  6054. !         exit(1);
  6055.       }
  6056. +     home = pass->pw_dir;
  6057.   
  6058.       sprintf(buffer, "%s/%s", home, elmrcfile);
  6059.   
  6060. ***************
  6061. *** 122,128 ****
  6062.              *value;              /* char pointer for munging */
  6063.   
  6064.       if (*maildir == '~')
  6065. !       sprintf(buffer, "%s%s", getenv("HOME"), ++maildir);
  6066.       else if (*maildir == '$') {     /* shell variable */
  6067.   
  6068.         /** break it into a single word - the variable name **/
  6069. --- 125,131 ----
  6070.              *value;              /* char pointer for munging */
  6071.   
  6072.       if (*maildir == '~')
  6073. !       sprintf(buffer, "%s%s", home, ++maildir);
  6074.       else if (*maildir == '$') {     /* shell variable */
  6075.   
  6076.         /** break it into a single word - the variable name **/
  6077. diff -cbr orig/utils/fastmail.c new/utils/fastmail.c
  6078. *** orig/utils/fastmail.c    Sat Oct 16 18:44:06 1993
  6079. --- new/utils/fastmail.c    Sun Sep 26 16:12:56 1993
  6080. ***************
  6081. *** 75,84 ****
  6082.   
  6083.   static char ident[] = { WHAT_STRING };
  6084.   
  6085. - #define  binrmail    "/bin/rmail"
  6086. - #define  temphome    "/tmp/fastmail."
  6087.   char *arpa_dayname[] = { "Sun", "Mon", "Tue", "Wed", "Thu",
  6088.             "Fri", "Sat", "" };
  6089.   
  6090. --- 75,80 ----
  6091. ***************
  6092. *** 90,97 ****
  6093. --- 86,95 ----
  6094.   #if defined(BSD) && !defined(_POSIX_SOURCE)
  6095.     char *timezone();
  6096.   #else
  6097. + #ifndef OS2
  6098.     extern char *tzname[];
  6099.   #endif
  6100. + #endif
  6101.   
  6102.   main(argc, argv)
  6103.   int argc;
  6104. ***************
  6105. *** 100,113 ****
  6106.   
  6107.       extern char *optarg;
  6108.       extern int optind;
  6109. !     FILE *tempfile;
  6110.       char hostname[NLEN], username[NLEN], from_string[SLEN], subject[SLEN];
  6111.       char filename[SLEN], tempfilename[SLEN], command_buffer[256];
  6112.       char replyto[SLEN], cc_list[SLEN], bcc_list[SLEN], to_list[SLEN];
  6113. !     char from_addr[SLEN];
  6114.       char *tmplogname;
  6115.       int  c, sendmail_available, debug = 0;
  6116.   
  6117.       from_string[0] = '\0';
  6118.       subject[0] = '\0';
  6119.       replyto[0] = '\0';
  6120. --- 98,113 ----
  6121.   
  6122.       extern char *optarg;
  6123.       extern int optind;
  6124. !     FILE *tempfile, *mailpipe;
  6125.       char hostname[NLEN], username[NLEN], from_string[SLEN], subject[SLEN];
  6126.       char filename[SLEN], tempfilename[SLEN], command_buffer[256];
  6127.       char replyto[SLEN], cc_list[SLEN], bcc_list[SLEN], to_list[SLEN];
  6128. !     char from_addr[SLEN], buffer[SLEN], hostfromname[SLEN];
  6129.       char *tmplogname;
  6130.       int  c, sendmail_available, debug = 0;
  6131.   
  6132. +         initpaths();
  6133.       from_string[0] = '\0';
  6134.       subject[0] = '\0';
  6135.       replyto[0] = '\0';
  6136. ***************
  6137. *** 126,181 ****
  6138.           case 'r' : strcpy(replyto, optarg);        break;
  6139.           case 's' : strcpy(subject, optarg);        break;
  6140.           case '?' :
  6141. !           fprintf(stderr,"Usage: fastmail {args} filename address(es)\n");
  6142. !           fprintf(stderr, "   where {args} can be;\n");
  6143. !           fprintf(stderr,"\t-b bcc-list\n\t-c cc-list\n\t-d\n");
  6144. !           fprintf(stderr,"\t-f from-name\n\t-F from-addr\n");
  6145. !           fprintf(stderr, "\t-r reply-to\n\t-s subject\n\n");
  6146. !           exit(1);
  6147.          }
  6148.       }
  6149.   
  6150. !     if (optind >= argc) {
  6151. !       fprintf(stderr,"Usage: fastmail {args} filename address(es)\n");
  6152. !       fprintf(stderr, "   where {args} can be;\n");
  6153. !       fprintf(stderr,"\t-b bcc-list\n\t-c cc-list\n\t-d\n\t-f from-name\n");
  6154. !       fprintf(stderr,"\t-F from-addr\n");
  6155. !       fprintf(stderr, "\t-r reply-to\n\t-s subject\n\n");
  6156. !       exit(1);
  6157. !     }
  6158.   
  6159.       strcpy(filename, argv[optind++]);
  6160.   
  6161. !     if (optind >= argc) {
  6162. !       fprintf(stderr,"Usage: fastmail {args} filename address(es)\n");
  6163. !       fprintf(stderr, "   where {args} can be;\n");
  6164. !       fprintf(stderr,"\t-b bcc-list\n\t-c cc-list\n\t-d\n\t-f from-name\n");
  6165. !       fprintf(stderr,"\t-F from-addr\n");
  6166. !       fprintf(stderr,"\t-r reply-to\n\t-s subject\n\n");
  6167. !       exit(1);
  6168. !     }
  6169.   
  6170.   #ifdef HOSTCOMPILED
  6171.       strncpy(hostname, HOSTNAME, sizeof(hostname));
  6172.   #else
  6173.       gethostname(hostname, sizeof(hostname));
  6174.   #endif
  6175.   
  6176. !     tmplogname = getlogin();
  6177.       if (tmplogname != NULL)
  6178.         strcpy(username, tmplogname);
  6179.       else
  6180.         username[0] = '\0';
  6181.   
  6182.       if (strlen(username) == 0)
  6183.         cuserid(username);
  6184.   
  6185.       if (access(filename, READ_ACCESS) == -1) {
  6186.         fprintf(stderr, "Error: can't find file %s!\n", filename);
  6187.         exit(1);
  6188.       }
  6189.   
  6190. !     sprintf(tempfilename, "%s%d", temphome, getpid());
  6191.   
  6192.       if ((tempfile = fopen(tempfilename, "w")) == NULL) {
  6193.         fprintf(stderr, "Couldn't open temp file %s\n", tempfilename);
  6194. --- 126,172 ----
  6195.           case 'r' : strcpy(replyto, optarg);        break;
  6196.           case 's' : strcpy(subject, optarg);        break;
  6197.           case '?' :
  6198. !           usage();
  6199.          }
  6200.       }
  6201.   
  6202. !     if (optind >= argc)
  6203. !       usage();
  6204.   
  6205.       strcpy(filename, argv[optind++]);
  6206.   
  6207. !     if (optind >= argc)
  6208. !           usage();
  6209.   
  6210.   #ifdef HOSTCOMPILED
  6211.       strncpy(hostname, HOSTNAME, sizeof(hostname));
  6212.   #else
  6213.       gethostname(hostname, sizeof(hostname));
  6214. + #endif
  6215. + #ifdef OS2
  6216. +     getfromdomain(hostfromname, sizeof(hostfromname));
  6217. + #else
  6218. +     strcpy(hostfromname, hostname);
  6219.   #endif
  6220.   
  6221. !     tmplogname = getenv("LOGNAME");
  6222.       if (tmplogname != NULL)
  6223.         strcpy(username, tmplogname);
  6224.       else
  6225.         username[0] = '\0';
  6226.   
  6227. + #ifndef OS2
  6228.       if (strlen(username) == 0)
  6229.         cuserid(username);
  6230. + #endif
  6231.   
  6232.       if (access(filename, READ_ACCESS) == -1) {
  6233.         fprintf(stderr, "Error: can't find file %s!\n", filename);
  6234.         exit(1);
  6235.       }
  6236.   
  6237. !     sprintf(tempfilename, "%s%d.fm", tempdir, getpid());
  6238.   
  6239.       if ((tempfile = fopen(tempfilename, "w")) == NULL) {
  6240.         fprintf(stderr, "Couldn't open temp file %s\n", tempfilename);
  6241. ***************
  6242. *** 199,215 ****
  6243.       **/
  6244.       fprintf(tempfile, "Subject: %s\n", subject);
  6245.   
  6246.       if (strlen(from_string) > 0)
  6247. -       if (strlen(from_addr) > 0)
  6248.         fprintf(tempfile, "From: %s (%s)\n", from_addr, from_string);
  6249.       else
  6250. -           fprintf(tempfile, "From: %s!%s (%s)\n", hostname, username, 
  6251. -               from_string);
  6252. -     else
  6253. -       if (strlen(from_addr) > 0)
  6254.         fprintf(tempfile, "From: %s\n", from_addr);
  6255. -       else
  6256. -         fprintf(tempfile, "From: %s!%s\n", hostname, username);
  6257.   
  6258.       fprintf(tempfile, "Date: %s\n", get_arpa_date());
  6259.   
  6260. --- 192,204 ----
  6261.       **/
  6262.       fprintf(tempfile, "Subject: %s\n", subject);
  6263.   
  6264. +     if (strlen(from_addr) == 0)
  6265. +       sprintf(from_addr, "%s@%s", username, hostfromname);
  6266.       if (strlen(from_string) > 0)
  6267.         fprintf(tempfile, "From: %s (%s)\n", from_addr, from_string);
  6268.       else
  6269.         fprintf(tempfile, "From: %s\n", from_addr);
  6270.   
  6271.       fprintf(tempfile, "Date: %s\n", get_arpa_date());
  6272.   
  6273. ***************
  6274. *** 241,257 ****
  6275.           printf("Mailing to %s%s%s%s%s [via %s]\n", to_list,
  6276.               (strlen(cc_list) > 0 ? " ":""), cc_list,
  6277.               (strlen(bcc_list) > 0 ? " ":""), bcc_list,
  6278. !             sendmail_available? "sendmail" : "rmail");
  6279.   
  6280.       sprintf(command_buffer, "cat %s %s | %s %s %s %s",
  6281.           tempfilename, filename,
  6282.               sendmail_available? sendmail : mailer,
  6283.           to_list, cc_list, bcc_list);
  6284.   
  6285.       if (debug)
  6286.         printf("%s\n", command_buffer);
  6287.   
  6288.       c = system(command_buffer);
  6289.   
  6290.       unlink(tempfilename);
  6291.   
  6292. --- 230,267 ----
  6293.           printf("Mailing to %s%s%s%s%s [via %s]\n", to_list,
  6294.               (strlen(cc_list) > 0 ? " ":""), cc_list,
  6295.               (strlen(bcc_list) > 0 ? " ":""), bcc_list,
  6296. !             sendmail_available? "sendmail" : mailer);
  6297.   
  6298. + #ifdef OS2
  6299. +     if (strcmp(sendmail, mailer) == 0)
  6300. +       sprintf(command_buffer, "%s -f %s %s %s %s", mailer, 
  6301. +           from_addr, to_list, cc_list, bcc_list);
  6302. +     else
  6303. +       sprintf(command_buffer, "%s -t", mailer);
  6304. + #else
  6305.       sprintf(command_buffer, "cat %s %s | %s %s %s %s",
  6306.           tempfilename, filename,
  6307.               sendmail_available? sendmail : mailer,
  6308.           to_list, cc_list, bcc_list);
  6309. + #endif
  6310.   
  6311.       if (debug)
  6312.         printf("%s\n", command_buffer);
  6313.   
  6314. + #ifdef OS2
  6315. +         mailpipe = popen(command_buffer, "w");
  6316. +     tempfile = fopen(tempfilename, "r");
  6317. +         while ( fgets(buffer, sizeof(buffer), tempfile) != NULL )
  6318. +           fputs(buffer, mailpipe);
  6319. +         fclose(tempfile);
  6320. +     tempfile = fopen(filename, "r");
  6321. +         while ( fgets(buffer, sizeof(buffer), tempfile) != NULL )
  6322. +           fputs(buffer, mailpipe);
  6323. +         fclose(tempfile);
  6324. +         pclose(mailpipe);
  6325. + #else
  6326.       c = system(command_buffer);
  6327. + #endif
  6328.   
  6329.       unlink(tempfilename);
  6330.   
  6331. ***************
  6332. *** 259,264 ****
  6333. --- 269,289 ----
  6334.   }
  6335.   
  6336.   
  6337. + usage()
  6338. + {
  6339. +   printf("\nUsage: fastmail {args} filename address(es)\n");
  6340. +   printf( "\nwhere {args} can be:\n\n");
  6341. +   printf("\t-b bcc-list       addresses to send blind-carbon copies to\n");
  6342. +   printf("\t-c cc-list        addresses to send carbon copies to\n");
  6343. +   printf("\t-d                debug\n");
  6344. +   printf("\t-f from-name      sender's full name\n");
  6345. +   printf("\t-F from-addr      sender's mail address\n");
  6346. +   printf("\t-r reply-to       reply-to mail address\n");
  6347. +   printf("\t-s subject        subject of the message\n");
  6348. +   exit(1);
  6349. + }
  6350.   char *get_arpa_date()
  6351.   {
  6352.       /** returns an ARPA standard date.  The format for the date
  6353. ***************
  6354. *** 285,291 ****
  6355.       struct  timezone time_zone;
  6356.   #  endif
  6357.   #else
  6358. !     long time();
  6359.   #endif
  6360.   
  6361.   #ifdef BSD
  6362. --- 310,316 ----
  6363.       struct  timezone time_zone;
  6364.   #  endif
  6365.   #else
  6366. !     time_t time();
  6367.   #endif
  6368.   
  6369.   #ifdef BSD
  6370. diff -cbr orig/utils/from.c new/utils/from.c
  6371. *** orig/utils/from.c    Sat Oct 16 18:44:08 1993
  6372. --- new/utils/from.c    Sun Mar 22 11:38:32 1992
  6373. ***************
  6374. *** 56,61 ****
  6375. --- 56,63 ----
  6376.   #endif
  6377.       extern int optind;
  6378.   
  6379. +         initpaths();
  6380.       while ((c = getopt(argc, argv, "nv")) != EOF)
  6381.         switch (c) {
  6382.           case (int)'n': number++;        break;
  6383. ***************
  6384. *** 65,96 ****
  6385.                          exit(1);
  6386.         }
  6387.   
  6388.       infile[0] = '\0';
  6389.       if (optind == argc) {
  6390.       /*
  6391.        *    determine mail file from environment variable if found,
  6392.        *    else use password entry
  6393.        */
  6394. -       if ((cp = getenv("MAIL")) == NULL) {
  6395. -         if((pass = getpwuid(getuid())) == NULL) {
  6396. -           printf("You have no password entry!");
  6397. -           exit(1);
  6398. -         }
  6399. -         sprintf(infile,"%s%s",mailhome, pass->pw_name);
  6400. -       }
  6401. -       else
  6402. -         strcpy(infile, cp);
  6403.         optind -= 1;    /* ensure one pass through loop */
  6404.       }
  6405.   
  6406. - #ifdef MMDF
  6407. -     if((pass = getpwuid(getuid())) == NULL) {
  6408. -       printf("You have no password entry!");
  6409. -       exit(1);
  6410. -     }
  6411. -     strcpy(username,pass->pw_name);
  6412. - #endif /* MMDF */
  6413.       multiple_files = (argc - optind > 1);
  6414.   
  6415.       while (optind < argc) {
  6416. --- 67,91 ----
  6417.                          exit(1);
  6418.         }
  6419.   
  6420. +     if((pass = getpwuid(getuid())) == NULL) {
  6421. +       printf("You have no password entry!");
  6422. +       exit(1);
  6423. +     }
  6424. +     strcpy(username,pass->pw_name);
  6425.       infile[0] = '\0';
  6426.       if (optind == argc) {
  6427.       /*
  6428.        *    determine mail file from environment variable if found,
  6429.        *    else use password entry
  6430.        */
  6431.         optind -= 1;    /* ensure one pass through loop */
  6432. +       if ((cp = getenv("MAIL")) == NULL)
  6433. +         strcpy(infile, argv[optind] = username);
  6434. +       else
  6435. +         strcpy(infile, argv[optind] = cp);
  6436.       }
  6437.   
  6438.       multiple_files = (argc - optind > 1);
  6439.   
  6440.       while (optind < argc) {
  6441. ***************
  6442. *** 111,119 ****
  6443.         }
  6444.   
  6445.         if ((mailfile = fopen(infile,"r")) == NULL) {
  6446. -         if (optind+1 == argc)
  6447. -           printf("No mail.\n");
  6448. -         else {
  6449.             if (infile[0] == '/')
  6450.               printf("Couldn't open folder \"%s\".\n", infile);
  6451.             else {
  6452. --- 106,111 ----
  6453. ***************
  6454. *** 122,138 ****
  6455.                 printf("Couldn't open folders \"%s\" or \"%s\".\n",
  6456.                argv[optind], infile);
  6457.               else {
  6458. !           if (read_headers()==0)
  6459. !                 printf("No messages in that folder!\n");
  6460.                 fclose(mailfile);
  6461.           }
  6462.             }
  6463. -         }
  6464.         } else {
  6465. !         if (read_headers(optind+1 == argc)==0)
  6466. !           if (optind+1 == argc)
  6467. !             printf("No mail\n");
  6468. !           else
  6469.             printf("No messages in that folder!\n");
  6470.           fclose(mailfile);
  6471.         }
  6472. --- 114,126 ----
  6473.                 printf("Couldn't open folders \"%s\" or \"%s\".\n",
  6474.                argv[optind], infile);
  6475.               else {
  6476. !           if (read_headers(1)==0)
  6477. !                 printf("No mail.\n");
  6478.                 fclose(mailfile);
  6479.           }
  6480.             }
  6481.         } else {
  6482. !         if (read_headers(0)==0)
  6483.             printf("No messages in that folder!\n");
  6484.           fclose(mailfile);
  6485.         }
  6486. ***************
  6487. *** 164,176 ****
  6488.         }
  6489.   
  6490.   #ifdef MMDF
  6491. !           if (strcmp(buffer, MSG_SEPERATOR) == 0) {
  6492. !         newheader = !newheader;
  6493. !         if (newheader) {
  6494.           subject[0] = '\0';
  6495.           in_header = 1;
  6496.         }
  6497. -       }
  6498.   #else
  6499.         if (first_word(buffer,"From ")
  6500.          && real_from(buffer, from_whom)) {
  6501. --- 152,163 ----
  6502.         }
  6503.   
  6504.   #ifdef MMDF
  6505. !           if (strcmp(buffer, MSG_SEPERATOR) == 0 || !newheader &&
  6506. !             first_word(buffer,"From ") && real_from(buffer, from_whom)) {
  6507. !         newheader = 1;
  6508.           subject[0] = '\0';
  6509.           in_header = 1;
  6510.         }
  6511.   #else
  6512.         if (first_word(buffer,"From ")
  6513.          && real_from(buffer, from_whom)) {
  6514. ***************
  6515. *** 180,185 ****
  6516. --- 167,173 ----
  6517.   #endif /* MMDF */
  6518.         else if (in_header) {
  6519.   #ifdef MMDF
  6520. +             newheader = 0;
  6521.           if (first_word(buffer,"From "))
  6522.             real_from(buffer, from_whom);
  6523.   #endif /* MMDF */
  6524. diff -cbr orig/utils/listalias.c new/utils/listalias.c
  6525. *** orig/utils/listalias.c    Sat Oct 16 18:44:08 1993
  6526. --- new/utils/listalias.c    Sun Oct 04 14:21:38 1992
  6527. ***************
  6528. *** 27,41 ****
  6529.   
  6530.   #include <stdio.h>
  6531.   #include <fcntl.h>
  6532.   
  6533.   #include "defs.h"
  6534. - #include "sysdefs.h"
  6535.   
  6536.   #ifdef BSD
  6537.     FILE *popen();
  6538.   #endif
  6539.   
  6540.   char *getenv();
  6541.   
  6542.   main(argc, argv)
  6543.   int argc;
  6544. --- 27,44 ----
  6545.   
  6546.   #include <stdio.h>
  6547.   #include <fcntl.h>
  6548. + #include <pwd.h>
  6549.   
  6550.   #include "defs.h"
  6551.   
  6552.   #ifdef BSD
  6553.     FILE *popen();
  6554.   #endif
  6555.   
  6556.   char *getenv();
  6557. + struct passwd *getpwuid();
  6558. + struct passwd *pass;
  6559. + char home[SLEN];        /* the users home directory  */
  6560.   
  6561.   main(argc, argv)
  6562.   int argc;
  6563. ***************
  6564. *** 45,61 ****
  6565.       struct alias_rec hash_record;
  6566.       int hashfile, count = 0;
  6567.       char buffer[SLEN], fd_hash[SLEN],
  6568. !          fd_data[SLEN], *home;
  6569.   
  6570.       if (argc > 2) {
  6571.         printf("Usage: listalias <optional-regular-expression>\n");
  6572.         exit(1);
  6573.       }
  6574.   
  6575. !     home = getenv("HOME");
  6576.   
  6577.       sprintf(fd_hash, "%s/%s", home, ALIAS_HASH);
  6578.       sprintf(fd_data, "%s/%s", home, ALIAS_DATA);
  6579.   
  6580.       if (argc > 1)
  6581.         sprintf(buffer, "egrep \"%s\" | sort", argv[1]);
  6582. --- 48,71 ----
  6583.       struct alias_rec hash_record;
  6584.       int hashfile, count = 0;
  6585.       char buffer[SLEN], fd_hash[SLEN],
  6586. !          fd_data[SLEN];
  6587. !         initpaths();
  6588.   
  6589.       if (argc > 2) {
  6590.         printf("Usage: listalias <optional-regular-expression>\n");
  6591.         exit(1);
  6592.       }
  6593.   
  6594. !     if((pass = getpwuid(getuid())) == NULL) {
  6595. !       printf("You have no password entry!\n");
  6596. !       exit(1);
  6597. !     }
  6598. !     strcpy(home, pass->pw_dir);
  6599.   
  6600.       sprintf(fd_hash, "%s/%s", home, ALIAS_HASH);
  6601.       sprintf(fd_data, "%s/%s", home, ALIAS_DATA);
  6602. +         putc('\n', stdout);
  6603.   
  6604.       if (argc > 1)
  6605.         sprintf(buffer, "egrep \"%s\" | sort", argv[1]);
  6606. ***************
  6607. *** 81,87 ****
  6608.   
  6609.           while (read(hashfile, &hash_record, sizeof (hash_record)) != 0) {
  6610.             if (strlen(hash_record.name) > 0) {
  6611. !             fseek(datafile, ntohl(hash_record.byte), 0L);
  6612.               fgets(buffer, SLEN, datafile);
  6613.               fprintf(fd_pipe, "%-15s  %s", hash_record.name, buffer);
  6614.             }
  6615. --- 91,97 ----
  6616.   
  6617.           while (read(hashfile, &hash_record, sizeof (hash_record)) != 0) {
  6618.             if (strlen(hash_record.name) > 0) {
  6619. !             fseek(datafile, ntohl(hash_record.byte), 0);
  6620.               fgets(buffer, SLEN, datafile);
  6621.               fprintf(fd_pipe, "%-15s  %s", hash_record.name, buffer);
  6622.             }
  6623. diff -cbr orig/utils/Makefile new/utils/Makefile
  6624. *** orig/utils/Makefile    Sat Oct 16 18:44:08 1993
  6625. --- new/utils/Makefile    Fri Apr 22 20:06:18 1994
  6626. ***************
  6627. *** 2,19 ****
  6628.   #  Makefile for the Elm system utilities for OS/2
  6629.   #
  6630.   
  6631. ! gcc:
  6632.       $(MAKE) all CC="gcc -O -Zomf -Zmtd" O=".obj" \
  6633. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm32.def"
  6634.   
  6635. ! gccdebug:
  6636.       $(MAKE) all CC="gcc -g" O=".o" \
  6637. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm32.def"
  6638. ! msc:
  6639. !     $(MAKE) all CC="cl -nologo -AL -Gs -Ocegt" O=".obj" \
  6640. !     CFLAGS="-W1 -Zep1 -Gt16 -D__STDC__ -G2 -J" \
  6641. !     LFLAGS="-Lp" LIBS="..\os2\elm16.def -link /noe /packc /packd"
  6642.   
  6643.   # Variables
  6644.   
  6645. --- 2,14 ----
  6646.   #  Makefile for the Elm system utilities for OS/2
  6647.   #
  6648.   
  6649. ! release:
  6650.       $(MAKE) all CC="gcc -O -Zomf -Zmtd" O=".obj" \
  6651. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm.def"
  6652.   
  6653. ! debug:
  6654.       $(MAKE) all CC="gcc -g" O=".o" \
  6655. !     CFLAGS="" LFLAGS="" LIBS="../os2/elm.def"
  6656.   
  6657.   # Variables
  6658.   
  6659. ***************
  6660. *** 26,49 ****
  6661.   # Lists
  6662.   
  6663.   BINARY_LIST    = answer.exe arepdaemon.exe autoreply.exe fastmail.exe \
  6664. !     from.exe listalias.exe newalias.exe newmail.exe readmsg.exe
  6665.   
  6666. ! OS2_OBJ        = getopt$O os2util$O
  6667.   UTIL_OBJ    = answer$O arepdaem$O autoreply$O expand$O \
  6668.       fastmail$O from$O listalias$O newalias$O newmail$O readmsg$O \
  6669.       opt_utils$O string2$O validname$O errno$O
  6670.   
  6671.   # Lists of source and object files for each C program
  6672.   
  6673. ! ANSWER_OBJ    = answer$O opt_utils$O string2$O os2util$O
  6674. ! AREPDAEMON_OBJ    = arepdaem$O opt_utils$O errno$O os2util$O
  6675. ! AUTOREPLY_OBJ    = autoreply$O opt_utils$O os2util$O
  6676. ! FASTMAIL_OBJ    = fastmail$O opt_utils$O getopt$O os2util$O
  6677. ! FRM_OBJ        = from$O expand$O opt_utils$O string2$O getopt$O os2util$O
  6678. ! LISTALIAS_OBJ    = listalias$O os2util$O
  6679. ! NEWALIAS_OBJ    = newalias$O validname$O opt_utils$O string2$O os2util$O
  6680. ! NEWMAIL_OBJ    = newmail$O expand$O opt_utils$O string2$O getopt$O os2util$O
  6681. ! READMSG_OBJ    = readmsg$O expand$O opt_utils$O string2$O getopt$O os2util$O
  6682.   
  6683.   # Standard targets
  6684.   
  6685. --- 21,45 ----
  6686.   # Lists
  6687.   
  6688.   BINARY_LIST    = answer.exe arepdaemon.exe autoreply.exe fastmail.exe \
  6689. !     from.exe listalias.exe newalias.exe newmail.exe readmsg.exe sndmail.exe
  6690.   
  6691. ! OS2_OBJ        = getopt$O os2util$O movemail$O
  6692.   UTIL_OBJ    = answer$O arepdaem$O autoreply$O expand$O \
  6693.       fastmail$O from$O listalias$O newalias$O newmail$O readmsg$O \
  6694.       opt_utils$O string2$O validname$O errno$O
  6695.   
  6696.   # Lists of source and object files for each C program
  6697.   
  6698. ! ANSWER_OBJ    = answer$O opt_utils$O string2$O $(OS2_OBJ)
  6699. ! AREPDAEMON_OBJ    = arepdaem$O opt_utils$O errno$O $(OS2_OBJ)
  6700. ! AUTOREPLY_OBJ    = autoreply$O opt_utils$O $(OS2_OBJ)
  6701. ! FASTMAIL_OBJ    = fastmail$O opt_utils$O $(OS2_OBJ)
  6702. ! FRM_OBJ        = from$O expand$O opt_utils$O string2$O $(OS2_OBJ)
  6703. ! LISTALIAS_OBJ    = listalias$O $(OS2_OBJ)
  6704. ! NEWALIAS_OBJ    = newalias$O validname$O opt_utils$O string2$O $(OS2_OBJ)
  6705. ! NEWMAIL_OBJ    = newmail$O expand$O opt_utils$O string2$O $(OS2_OBJ)
  6706. ! READMSG_OBJ    = readmsg$O expand$O opt_utils$O string2$O $(OS2_OBJ)
  6707. ! SNDMAIL_OBJ     = sndmail$O
  6708.   
  6709.   # Standard targets
  6710.   
  6711. ***************
  6712. *** 95,100 ****
  6713. --- 91,99 ----
  6714.   readmsg.exe:    $(READMSG_OBJ)
  6715.           $(CC) $(LFLAGS) -o $@ $(READMSG_OBJ) $(LIBS)
  6716.   
  6717. + sndmail.exe:    $(SNDMAIL_OBJ)
  6718. +         $(CC) $(LFLAGS) -o $@ $(SNDMAIL_OBJ) $(LIBS)
  6719.   # Dependencies of header files upon other header files they include
  6720.   
  6721.   $(INCLDIR)/defs.h:    $(INCLDIR)/../config.h $(INCLDIR)/sysdefs.h
  6722. ***************
  6723. *** 132,134 ****
  6724. --- 131,135 ----
  6725.           $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/getopt.c
  6726.   os2util$O:    $(OS2DIR)/os2util.c
  6727.           $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/os2util.c
  6728. + movemail$O:    $(OS2DIR)/movemail.c
  6729. +         $(CC) $(CFLAGS) $(DEFINES) -c $(OS2DIR)/movemail.c
  6730. diff -cbr orig/utils/newalias.c new/utils/newalias.c
  6731. *** orig/utils/newalias.c    Sat Oct 16 18:44:08 1993
  6732. --- new/utils/newalias.c    Sun Mar 29 00:07:34 1992
  6733. ***************
  6734. *** 57,64 ****
  6735.   
  6736.   #include <stdio.h>
  6737.   #include "defs.h"
  6738. - #include "sysdefs.h"        /* ELM system definitions */
  6739.   #include <ctype.h>
  6740.   
  6741.   #ifdef BSD
  6742.   #  include <sys/file.h>
  6743. --- 57,64 ----
  6744.   
  6745.   #include <stdio.h>
  6746.   #include "defs.h"
  6747.   #include <ctype.h>
  6748. + #include <pwd.h>
  6749.   
  6750.   #ifdef BSD
  6751.   #  include <sys/file.h>
  6752. ***************
  6753. *** 85,90 ****
  6754. --- 85,93 ----
  6755.   int  is_system=0;        /* system file updating?     */
  6756.   int  count=0;            /* how many aliases so far?  */
  6757.   long offset = 0L;        /* data file line offset!    */
  6758. + struct passwd *getpwuid();
  6759. + struct passwd *pass;
  6760.   char home[SLEN];        /* the users home directory  */
  6761.   
  6762.   main(argc, argv)
  6763. ***************
  6764. *** 96,126 ****
  6765.       char buffer[LONG_STRING];
  6766.       int  a, hash, count = 0, owner;
  6767.   
  6768.       for (a = 1; a < argc; ++a) {
  6769.         if (strcmp(argv[a], "-g") == 0)
  6770.           is_system = 1;
  6771.         else {
  6772. !         printf("Usage: %s [-g]\n", argv[0]);
  6773.           exit(1);
  6774.         }
  6775.       }
  6776.   
  6777.       if (is_system) {   /* update system aliases */
  6778. !       printf("Updating the system alias file...\n");
  6779.   
  6780. -       strcpy(inputname, system_text_file);
  6781. -       strcpy(hashname,  system_hash_file);
  6782. -       strcpy(dataname,  system_data_file);
  6783.         init_table(shash_table, MAX_SALIASES);
  6784.       }
  6785.       else
  6786. !       printf("Updating your personal alias file...\n");
  6787.   
  6788.       if (! is_system) {
  6789. !       if (strcpy(home, getenv("HOME")) == NULL) {
  6790. !         printf("I'm confused - no HOME variable in environment!\n");
  6791.           exit(1);
  6792.         }
  6793.   
  6794.         sprintf(inputname, "%s/%s", home, ALIAS_TEXT);
  6795.         sprintf(hashname, "%s/%s", home, ALIAS_HASH);
  6796. --- 99,133 ----
  6797.       char buffer[LONG_STRING];
  6798.       int  a, hash, count = 0, owner;
  6799.   
  6800. +         initpaths();
  6801.       for (a = 1; a < argc; ++a) {
  6802.         if (strcmp(argv[a], "-g") == 0)
  6803.           is_system = 1;
  6804.         else {
  6805. !         printf("\nUsage: %s [-g]\n", argv[0]);
  6806.           exit(1);
  6807.         }
  6808.       }
  6809.   
  6810.       if (is_system) {   /* update system aliases */
  6811. !       printf("\nUpdating the system alias file...\n");
  6812. !       sprintf(inputname, "%s/%s", elmhome, system_text_file);
  6813. !       sprintf(hashname, "%s/%s", elmhome, system_hash_file);
  6814. !       sprintf(dataname, "%s/%s", elmhome, system_data_file);
  6815.   
  6816.         init_table(shash_table, MAX_SALIASES);
  6817.       }
  6818.       else
  6819. !       printf("\nUpdating your personal alias file...\n");
  6820.   
  6821.       if (! is_system) {
  6822. !       if((pass = getpwuid(getuid())) == NULL) {
  6823. !         printf("You have no password entry!\n");
  6824.           exit(1);
  6825.         }
  6826. +       strcpy(home, pass->pw_dir);
  6827.   
  6828.         sprintf(inputname, "%s/%s", home, ALIAS_TEXT);
  6829.         sprintf(hashname, "%s/%s", home, ALIAS_HASH);
  6830. ***************
  6831. *** 144,155 ****
  6832.         }
  6833.       }
  6834.   
  6835. !     if ((hash = open(hashname, O_WRONLY | O_TRUNC | O_CREAT, 0644)) == -1) {
  6836.         printf("Couldn't open %s for output!\n", hashname);
  6837.         exit(1);
  6838.       }
  6839.   
  6840. !     if ((data = fopen(dataname,"w")) == NULL) {
  6841.         printf("Couldn't open %s for output!\n", dataname);
  6842.         exit(1);
  6843.       }
  6844. --- 151,162 ----
  6845.         }
  6846.       }
  6847.   
  6848. !     if ((hash = open(hashname, O_WRONLY  | O_BINARY | O_TRUNC | O_CREAT, 0644)) == -1) {
  6849.         printf("Couldn't open %s for output!\n", hashname);
  6850.         exit(1);
  6851.       }
  6852.   
  6853. !     if ((data = fopen(dataname,"wb")) == NULL) {
  6854.         printf("Couldn't open %s for output!\n", dataname);
  6855.         exit(1);
  6856.       }
  6857. diff -cbr orig/utils/newmail.c new/utils/newmail.c
  6858. *** orig/utils/newmail.c    Sat Oct 16 18:44:10 1993
  6859. --- new/utils/newmail.c    Fri Apr 22 18:36:02 1994
  6860. ***************
  6861. *** 83,88 ****
  6862. --- 83,89 ----
  6863.   #include <errno.h>
  6864.   #include <sys/types.h>
  6865.   #include <sys/stat.h>
  6866. + #include <pwd.h>
  6867.   
  6868.   #include "defs.h"
  6869.   
  6870. ***************
  6871. *** 138,143 ****
  6872. --- 139,146 ----
  6873.       long lastsize,
  6874.            newsize;            /* file size for comparison..      */
  6875.   
  6876. +         initpaths();
  6877.   #ifdef HOSTCOMPILED
  6878.       strncpy(hostname, HOSTNAME, sizeof(hostname));
  6879.   #else
  6880. ***************
  6881. *** 166,172 ****
  6882.       if (ptr == argv[0] && i == 0 && argv[0][0] == 'w')
  6883.         in_window = 1;
  6884.   
  6885. !     while ((c = getopt(argc, argv, "di:w")) != EOF) {
  6886.         switch (c) {
  6887.           case 'd' : debug++;                    break;
  6888.           case 'i' : interval_time = atoi(optarg);        break;
  6889. --- 169,175 ----
  6890.       if (ptr == argv[0] && i == 0 && argv[0][0] == 'w')
  6891.         in_window = 1;
  6892.   
  6893. !     while ((c = getopt(argc, argv, "di:wh?")) != EOF) {
  6894.         switch (c) {
  6895.           case 'd' : debug++;                    break;
  6896.           case 'i' : interval_time = atoi(optarg);        break;
  6897. ***************
  6898. *** 199,211 ****
  6899. --- 202,217 ----
  6900.         (void) signal(SIGQUIT, SIG_IGN);
  6901.       }
  6902.   #endif
  6903. + #ifdef SIGHUP
  6904.       (void) signal(SIGHUP, SIG_DFL);
  6905. + #endif
  6906.   
  6907.       if (in_window && ! debug)
  6908.         printf("Incoming mail:\n");
  6909.   
  6910.       while (1) {
  6911.   
  6912. + #ifndef OS2
  6913.   #ifdef PIDCHECK
  6914.       if ( kill(parent_pid,0))
  6915.           exit(0);
  6916. ***************
  6917. *** 215,226 ****
  6918. --- 221,235 ----
  6919.           exit();
  6920.   #endif /* AUTO_BACKGROUND */
  6921.   #endif /* PIDCHECK */
  6922. + #endif
  6923.   
  6924.         if (! isatty(1))    /* we're not sending output to a tty any more */
  6925.            exit();
  6926.   
  6927.         if (debug) printf("\n----\n");
  6928.   
  6929. +       /* move_incoming_mail(); */
  6930.         for (i = 0; i < total_folders; i++) {
  6931.   
  6932.           if (debug)
  6933. ***************
  6934. *** 303,309 ****
  6935.       while (fgets(buffer, SLEN, folders[current_folder].fd) != NULL) {
  6936.   #ifdef MMDF
  6937.             if (strcmp(buffer, MSG_SEPERATOR) == 0) {
  6938. !             newheader = !newheader;
  6939.               if (newheader) {
  6940.   #else
  6941.         if (first_word(buffer,"From ")) {
  6942. --- 312,318 ----
  6943.       while (fgets(buffer, SLEN, folders[current_folder].fd) != NULL) {
  6944.   #ifdef MMDF
  6945.             if (strcmp(buffer, MSG_SEPERATOR) == 0) {
  6946. !             newheader = 1;
  6947.               if (newheader) {
  6948.   #else
  6949.         if (first_word(buffer,"From ")) {
  6950. ***************
  6951. *** 314,320 ****
  6952.             in_header = 1;
  6953.             subject[0] ='\0';
  6954.             if (in_window)
  6955. !             putchar((char) 007);        /* BEEP!*/
  6956.             else
  6957.               printf("\n\r");    /* blank lines surrounding message */
  6958.   
  6959. --- 323,329 ----
  6960.             in_header = 1;
  6961.             subject[0] ='\0';
  6962.             if (in_window)
  6963. !             putc((char) 007, stdout);        /* BEEP!*/
  6964.             else
  6965.               printf("\n\r");    /* blank lines surrounding message */
  6966.   
  6967. ***************
  6968. *** 575,581 ****
  6969.   #ifndef INTERNET
  6970.       /* Remove bogus "@host.domain" string. */
  6971.   
  6972. !     sprintf(buffer, "@%s%s", hostname, hostdomain);
  6973.   
  6974.       if (chloc(from, '!') != -1 && in_string(from, buffer))
  6975.         from[strlen(from) - strlen(buffer)] = '\0';
  6976. --- 575,581 ----
  6977.   #ifndef INTERNET
  6978.       /* Remove bogus "@host.domain" string. */
  6979.   
  6980. !     sprintf(buffer, "@%s", hostname); /* hostname should contain FQDN! */
  6981.   
  6982.       if (chloc(from, '!') != -1 && in_string(from, buffer))
  6983.         from[strlen(from) - strlen(buffer)] = '\0';
  6984. ***************
  6985. *** 703,709 ****
  6986.           is to check to see if new mail has arrived....  **/
  6987.   
  6988.       int ok = 1;
  6989. -     extern int errno;    /* system error number! */
  6990.       struct stat buffer;
  6991.   
  6992.       if (stat(name, &buffer) != 0)
  6993. --- 712,717 ----
  6994. ***************
  6995. *** 722,736 ****
  6996.       /** Getting the username on some systems is a real pain, so...
  6997.          This routine is guaranteed to return a usable username **/
  6998.   
  6999. !     char *return_value, *getlogin(), *cuserid();
  7000. !     if ((return_value = getlogin()) == NULL)
  7001. !       if ((return_value = cuserid(NULL)) == NULL) {
  7002. !         printf("Newmail: I can't get username!\n");
  7003. !         exit(1);
  7004. !       }
  7005.   
  7006. !     return( (char *) return_value);
  7007.   }
  7008.   
  7009.   usage(name)
  7010. --- 730,740 ----
  7011.       /** Getting the username on some systems is a real pain, so...
  7012.          This routine is guaranteed to return a usable username **/
  7013.   
  7014. !   struct passwd *password_entry;
  7015. !   struct passwd *getpwuid();
  7016.   
  7017. !   if (( password_entry = getpwuid(getuid())) != NULL)
  7018. !     return(password_entry->pw_name);
  7019.   }
  7020.   
  7021.   usage(name)
  7022. diff -cbr orig/utils/readmsg.c new/utils/readmsg.c
  7023. *** orig/utils/readmsg.c    Sat Oct 16 18:44:10 1993
  7024. --- new/utils/readmsg.c    Sat Mar 28 23:30:58 1992
  7025. ***************
  7026. *** 44,49 ****
  7027. --- 44,50 ----
  7028.   
  7029.   #include <stdio.h>
  7030.   #include <ctype.h>
  7031. + #include <pwd.h>
  7032.   
  7033.   #include "defs.h"
  7034.   
  7035. ***************
  7036. *** 69,74 ****
  7037. --- 70,78 ----
  7038.   int numcmp();                /* strcmp, but for numbers          */
  7039.   char *words();                /* function defined below...        */
  7040.   
  7041. + struct passwd *getpwuid();
  7042. + struct passwd *pass;
  7043. + char home[SLEN];        /* the users home directory  */
  7044.   
  7045.   extern char *optarg;        /* for parsing the ...             */
  7046.   extern int   optind;            /*  .. starting arguments           */
  7047. ***************
  7048. *** 84,90 ****
  7049.            infile[SLEN],            /* input filename        */
  7050.            buffer[SLEN],             /* file reading buffer      */
  7051.            string[SLEN],            /* string match buffer      */
  7052. !          *cp;
  7053.   
  7054.       int current_in_queue = 0,         /* these are used for...     */
  7055.           current = 0,            /* ...going through msgs     */
  7056. --- 88,95 ----
  7057.            infile[SLEN],            /* input filename        */
  7058.            buffer[SLEN],             /* file reading buffer      */
  7059.            string[SLEN],            /* string match buffer      */
  7060. !          *cp,
  7061. !              *prog = argv[0];
  7062.   
  7063.       int current_in_queue = 0,         /* these are used for...     */
  7064.           current = 0,            /* ...going through msgs     */
  7065. ***************
  7066. *** 102,107 ****
  7067. --- 107,114 ----
  7068.           string[0] = '\0';            /* init match string to empty */
  7069.           infile[0] = '\0';            /* init mail file to empty    */
  7070.   
  7071. +         initpaths();
  7072.       /**** start of the actual program ****/
  7073.   
  7074.       while ((num = getopt(argc, argv, "nhf:p")) != EOF) {
  7075. ***************
  7076. *** 115,123 ****
  7077.                         argv[0], infile);
  7078.                  break;
  7079.           case 'p' : page_breaks++;            break;
  7080. !         case '?' : printf(
  7081. !             "Usage: %s [-n|-h] [-f filename] [-p] <message list>\n",
  7082. !              argv[0]);
  7083.                    exit(1);
  7084.         }
  7085.       }
  7086. --- 122,128 ----
  7087.                         argv[0], infile);
  7088.                  break;
  7089.           case 'p' : page_breaks++;            break;
  7090. !         case '?' : usage(prog);
  7091.                    exit(1);
  7092.         }
  7093.       }
  7094. ***************
  7095. *** 135,148 ****
  7096.       /** now let's figure out the parameters to the program... **/
  7097.   
  7098.       if (argc == 1) {    /* no arguments... called from 'Elm'? */
  7099. !       sprintf(filename, "%s/%s", getenv("HOME"), readmsg_file);
  7100.         if ((file = fopen(filename, "r")) != NULL) {
  7101.           fscanf(file, "%d", &(read_message[messages++]));
  7102.           fclose(file);
  7103.         }
  7104.         else {    /* no arguments AND no .readmsg file!! */
  7105. !         fprintf(stderr,
  7106. !             "Usage: readmsg [-n|-h] [-f filename] [-p] <message list>\n");
  7107.           exit(1);
  7108.         }
  7109.       }
  7110. --- 140,157 ----
  7111.       /** now let's figure out the parameters to the program... **/
  7112.   
  7113.       if (argc == 1) {    /* no arguments... called from 'Elm'? */
  7114. !       if((pass = getpwuid(getuid())) == NULL) {
  7115. !         printf("You have no password entry!\n");
  7116. !         exit(1);
  7117. !       }
  7118. !       strcpy(home, pass->pw_dir);
  7119. !       sprintf(filename, "%s/%s", home, readmsg_file);
  7120.         if ((file = fopen(filename, "r")) != NULL) {
  7121.           fscanf(file, "%d", &(read_message[messages++]));
  7122.           fclose(file);
  7123.         }
  7124.         else {    /* no arguments AND no .readmsg file!! */
  7125. !             usage(prog);
  7126.           exit(1);
  7127.         }
  7128.       }
  7129. ***************
  7130. *** 233,241 ****
  7131.   
  7132.       while (fgets(buffer, SLEN, file) != NULL) {
  7133.   #ifdef MMDF
  7134. !       if (strcmp(buffer, MSG_SEPERATOR) == 0)
  7135. !         newheader = !newheader;
  7136. !       if (newheader && buffer[0] == '\001') {
  7137.   #else
  7138.         if (real_from(buffer)) {
  7139.   #endif /* MMDF */
  7140. --- 242,253 ----
  7141.   
  7142.       while (fgets(buffer, SLEN, file) != NULL) {
  7143.   #ifdef MMDF
  7144. !       if (strcmp(buffer, MSG_SEPERATOR) == 0 ||
  7145. !               !newheader && real_from(buffer))
  7146. !             newheader = 1; /* !newheader; */
  7147. !           else
  7148. !             newheader = 0;
  7149. !       if (newheader) {
  7150.   #else
  7151.         if (real_from(buffer)) {
  7152.   #endif /* MMDF */
  7153. ***************
  7154. *** 248,253 ****
  7155. --- 260,266 ----
  7156.           current++;
  7157.           not_in_header = 0;    /* we're in the header! */
  7158.         }
  7159.         if (current == read_message[current_in_queue] || list_all_messages)
  7160.   #ifdef MMDF
  7161.           if ((include_headers==ALL || not_in_header)
  7162. ***************
  7163. *** 268,273 ****
  7164. --- 281,296 ----
  7165.       exit(0);
  7166.   }
  7167.   
  7168. + usage(prog)
  7169. + char *prog;
  7170. + {
  7171. +   printf("\nUsage: %s [-n|-h] [-f filename] [-p] <message list>\n", prog);
  7172. +   printf("\n  -n   don't print any headers"
  7173. +          "\n  -h   print all headers"
  7174. +          "\n  -p   printf form feeds between messages\n"
  7175. +          "\n  -f filename    use this instead of default mailbox\n");
  7176. + }
  7177.   int
  7178.   count_messages(file)
  7179.   FILE *file;
  7180. ***************
  7181. *** 282,293 ****
  7182.   
  7183.       while (fgets(buffer, SLEN, file) != NULL)
  7184.   #ifdef MMDF
  7185. !       if ((strcmp(buffer, MSG_SEPERATOR) == 0)
  7186. !         && (++newheader % 2))
  7187.   #else
  7188. !       if (real_from(buffer))
  7189.   #endif /* MMDF */
  7190.           count++;
  7191.   
  7192.       rewind( file );
  7193.       return( count );
  7194. --- 305,322 ----
  7195.   
  7196.       while (fgets(buffer, SLEN, file) != NULL)
  7197.   #ifdef MMDF
  7198. !       if (strcmp(buffer, MSG_SEPERATOR) == 0
  7199. !               || !newheader && real_from(buffer)) {
  7200. !         newheader = 1;
  7201.   #else
  7202. !       if (real_from(buffer)) |
  7203.   #endif /* MMDF */
  7204.           count++;
  7205. +           }
  7206. + #ifdef MMDF
  7207. +           else
  7208. +         newheader = 0;
  7209. + #endif /* MMDF */
  7210.   
  7211.       rewind( file );
  7212.       return( count );
  7213. ***************
  7214. *** 309,320 ****
  7215.   
  7216.       while (fgets(buffer, SLEN, mailfile) != NULL) {
  7217.   #ifdef MMDF
  7218. !       if ((strcmp(buffer, MSG_SEPERATOR) == 0)
  7219. !         && (++newheader % 2))
  7220.   #else
  7221. !       if (real_from(buffer))
  7222.   #endif /* MMDF */
  7223.           message_count++;
  7224.   
  7225.         if (in_string(buffer, string)) {
  7226.           read_message[messages++] = message_count;
  7227. --- 338,355 ----
  7228.   
  7229.       while (fgets(buffer, SLEN, mailfile) != NULL) {
  7230.   #ifdef MMDF
  7231. !       if (strcmp(buffer, MSG_SEPERATOR) == 0
  7232. !               || !newheader && real_from(buffer)) {
  7233. !         newheader = 1;
  7234.   #else
  7235. !       if (real_from(buffer)) {
  7236.   #endif /* MMDF */
  7237.           message_count++;
  7238. +           }
  7239. + #ifdef MMDF
  7240. +           else
  7241. +         newheader = 0;
  7242. + #endif /* MMDF */
  7243.   
  7244.         if (in_string(buffer, string)) {
  7245.           read_message[messages++] = message_count;
  7246. ***************
  7247. *** 375,381 ****
  7248.   
  7249.       if (messages_listed++)
  7250.         if (page_break)
  7251. !         putchar(FORMFEED);    
  7252.         else
  7253.           printf(
  7254.   "\n--------------------------------------------------------------------\n\n\n");
  7255. --- 410,416 ----
  7256.   
  7257.       if (messages_listed++)
  7258.         if (page_break)
  7259. !         putc(FORMFEED, stdout);
  7260.         else
  7261.           printf(
  7262.   "\n--------------------------------------------------------------------\n\n\n");
  7263. ***************
  7264. *** 386,392 ****
  7265.       if (strlen(date)    > 0) { printf("%s", date);    displayed_line++;}
  7266.   
  7267.       if (displayed_line)
  7268. !        putchar('\n');
  7269.   }
  7270.   
  7271.   char *words(word, num_words, buffer)
  7272. --- 421,427 ----
  7273.       if (strlen(date)    > 0) { printf("%s", date);    displayed_line++;}
  7274.   
  7275.       if (displayed_line)
  7276. !        putc('\n', stdout);
  7277.   }
  7278.   
  7279.   char *words(word, num_words, buffer)
  7280.