home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume18 / elm2.2 / part09 < prev    next >
Encoding:
Internet Message Format  |  1989-04-12  |  49.5 KB

  1. Subject:  v18i088:  Elm mail system, release 2.2, Part09/24
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: dsinc!syd@uunet.UU.NET (Syd Weinstein)
  7. Posting-number: Volume 18, Issue 88
  8. Archive-name: elm2.2/part09
  9.  
  10. #!/bin/sh
  11. # this is part 9 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file filter/rules.c continued
  14. #
  15. CurArch=9
  16. if test ! -r s2_seq_.tmp
  17. then echo "Please unpack part 1 first!"
  18.      exit 1; fi
  19. ( read Scheck
  20.   if test "$Scheck" != $CurArch
  21.   then echo "Please unpack part $Scheck next!"
  22.        exit 1;
  23.   else exit 0; fi
  24. ) < s2_seq_.tmp || exit 1
  25. echo "x - Continuing file filter/rules.c"
  26. sed 's/^X//' << 'SHAR_EOF' >> filter/rules.c
  27. X      case LEAVE      : return("Leave"); 
  28. X      case EXEC       : return("Execute");
  29. X      default         : return("?action?");
  30. X    }
  31. X}
  32. X
  33. Xint
  34. Xcompare(line, relop, arg)
  35. Xint line, relop;
  36. Xchar *arg;
  37. X{
  38. X    /** Given the actual number of lines in the message, the relop
  39. X        relation, and the number of lines in the rule, as a string (!),
  40. X           return TRUE or FALSE according to which is correct.
  41. X    **/
  42. X
  43. X    int rule_lines;
  44. X
  45. X    rule_lines = atoi(arg);
  46. X
  47. X    switch (relop) {
  48. X      case LE: return(line <= rule_lines);
  49. X      case LT: return(line <  rule_lines);
  50. X      case GE: return(line >= rule_lines);
  51. X      case GT: return(line >  rule_lines);
  52. X      case NE: return(line != rule_lines);
  53. X      case EQ: return(line == rule_lines);
  54. X    }
  55. X    return(-1);
  56. X}
  57. X
  58. Xchar *listrule(rule)
  59. Xchar *rule;
  60. X{
  61. X    /** simply translates all underscores into spaces again on the
  62. X        way past... **/
  63. X
  64. X    static char buffer[SLEN];
  65. X    register int i;
  66. X
  67. X    for (i=0; i < strlen(rule); i++)
  68. X      buffer[i] = (rule[i] == '_' ? ' ' : rule[i]);
  69. X    buffer[i] = '\0';
  70. X
  71. X    return( (char *) buffer);
  72. X}
  73. SHAR_EOF
  74. echo "File filter/rules.c is complete"
  75. chmod 0444 filter/rules.c || echo "restore of filter/rules.c fails"
  76. echo "x - extracting filter/summarize.c (Text)"
  77. sed 's/^X//' << 'SHAR_EOF' > filter/summarize.c &&
  78. X
  79. Xstatic char rcsid[] ="@(#)$Id: summarize.c,v 2.4 89/03/25 21:45:19 syd Exp $";
  80. X
  81. X/*******************************************************************************
  82. X *  The Elm Mail System  -  $Revision: 2.4 $   $State: Exp $
  83. X *
  84. X *             Copyright (c) 1986, 1987 Dave Taylor
  85. X *             Copyright (c) 1988, 1989 USENET Community Trust
  86. X *******************************************************************************
  87. X * Bug reports, patches, comments, suggestions should be sent to:
  88. X *
  89. X *    Syd Weinstein - elm@dsinc.UUCP
  90. X *            dsinc!elm
  91. X *
  92. X *******************************************************************************
  93. X * $Log:    summarize.c,v $
  94. X * Revision 2.4  89/03/25  21:45:19  syd
  95. X * Initial 2.2 Release checkin
  96. X * 
  97. X *
  98. X ******************************************************************************/
  99. X
  100. X/** This routine is called from the filter program (or can be called
  101. X    directly with the correct arguments) and summarizes the users filterlog
  102. X    file.  To be honest, there are two sorts of summaries that are
  103. X    available - either the '.filterlog' file can be output (filter -S) 
  104. X    or a summary by rule and times acted upon can be output (filter -s).
  105. X    Either way, this program will delete the two associated files each
  106. X    time ($HOME/.filterlog and $HOME/.filtersum) *if* the -c option is
  107. X    used to the program (e.g. clear_logs is set to TRUE).
  108. X
  109. X**/
  110. X
  111. X#include <stdio.h>
  112. X
  113. X#include "defs.h"
  114. X
  115. X#include "filter.h"
  116. X
  117. Xshow_summary()
  118. X{
  119. X    /* Summarize usage of the program... */
  120. X
  121. X    FILE   *fd;                /* for output to temp file! */
  122. X    char filename[SLEN],            /* name of the temp file    */
  123. X         buffer[SLEN];            /* input buffer space       */
  124. X    int  erroneous_rules = 0,
  125. X         default_rules   = 0,
  126. X         messages_filtered = 0,        /* how many have we touched? */
  127. X         rule,
  128. X         applied[MAXRULES];
  129. X
  130. X    sprintf(filename, "%s/%s", home, filtersum);
  131. X
  132. X    if ((fd = fopen(filename, "r")) == NULL) {
  133. X      if (outfd != NULL)
  134. X        fprintf(outfd,"filter (%s): Can't open filtersum file %s!\n",
  135. X
  136. X            username, filename);
  137. X      if (outfd != NULL) fclose(outfd);
  138. X      exit(1);
  139. X    }
  140. X
  141. X    for (rule=0;rule < MAXRULES; rule++)
  142. X      applied[rule] = 0;            /* initialize it all! */
  143. X
  144. X    /** Next we need to read it all in, incrementing by which rule
  145. X        was used.  The format is simple - each line represents a 
  146. X        single application of a rule, or '-1' if the default action
  147. X        was taken.  Simple stuff, eh?  But oftentimes the best.  
  148. X    **/
  149. X
  150. X    while (fgets(buffer, SLEN, fd) != NULL) {
  151. X      if ((rule = atoi(buffer)) > total_rules || rule < -1) {
  152. X        if (outfd != NULL)
  153. X          fprintf(outfd,
  154. X      "filter (%s): Warning - rule #%d is invalid data for short summary!!\n",
  155. X                username, rule);
  156. X        erroneous_rules++;
  157. X      }
  158. X      else if (rule == -1)
  159. X        default_rules++;
  160. X      else
  161. X        applied[rule]++;
  162. X      messages_filtered++;
  163. X    }
  164. X    
  165. X    fclose(fd);
  166. X
  167. X    /** now let's summarize the data... **/
  168. X
  169. X    if (outfd == NULL) return;        /* no reason to go further */
  170. X
  171. X    fprintf(outfd, 
  172. X        "\n\t\t\tA Summary of Filter Activity\n");
  173. X    fprintf(outfd, 
  174. X          "\t\t\t----------------------------\n\n");
  175. X
  176. X    fprintf(outfd,"A total of %d message%s %s filtered:\n\n",
  177. X        messages_filtered, plural(messages_filtered),
  178. X        messages_filtered > 1 ? "were" : "was");
  179. X
  180. X    if (erroneous_rules)
  181. X      fprintf(outfd, 
  182. X              "[Warning: %d erroneous rule%s logged and ignored!]\n\n",
  183. X           erroneous_rules, erroneous_rules > 1? "s were" : " was");
  184. X    
  185. X    if (default_rules) {
  186. X       fprintf(outfd,
  187. X "The default rule of putting mail into your mailbox\n");
  188. X       fprintf(outfd, "\tapplied %d time%s (%d%%)\n\n",
  189. X           default_rules, plural(default_rules),
  190. X           (default_rules*100+(messages_filtered>>1))/messages_filtered
  191. X            );
  192. X    }
  193. X
  194. X     /** and now for each rule we used... **/
  195. X
  196. X     for (rule = 0; rule < total_rules; rule++) {
  197. X       if (applied[rule]) {
  198. X          fprintf(outfd, "Rule #%d: ", rule+1);
  199. X          switch (rules[rule].action) {
  200. X          case LEAVE:        fprintf(outfd, "(leave mail in mailbox)");
  201. X                    break;
  202. X          case DELETE_MSG:  fprintf(outfd, "(delete message)");
  203. X                    break;
  204. X          case SAVE  :      fprintf(outfd, "(save in \"%s\")",
  205. X                        rules[rule].argument2);        break;
  206. X          case SAVECC:      fprintf(outfd, 
  207. X                        "(left in mailbox and saved in \"%s\")",
  208. X                        rules[rule].argument2);        break;
  209. X          case FORWARD:     fprintf(outfd, "(forwarded to \"%s\")",
  210. X                        rules[rule].argument2);        break;
  211. X          case EXEC  :      fprintf(outfd, "(given to command \"%s\")",
  212. X                        rules[rule].argument2);        break;
  213. X         }
  214. X         fprintf(outfd, "\n\tapplied %d time%s (%d%%)\n\n", 
  215. X             applied[rule], plural(applied[rule]),
  216. X                (applied[rule]*100+(messages_filtered>>1))/messages_filtered
  217. X            );
  218. X      }
  219. X    }
  220. X
  221. X    if (long_summary) {
  222. X
  223. X      /* next, after a ^L, include the actual log file... */
  224. X
  225. X      sprintf(filename, "%s/%s", home, filterlog);
  226. X
  227. X      if ((fd = fopen(filename, "r")) == NULL) {
  228. X        fprintf(outfd,"filter (%s): Can't open filterlog file %s!\n",
  229. X              username, filename);
  230. X      }
  231. X      else {
  232. X        fprintf(outfd, "\n\n\n%c\n\nExplicit log of each action;\n\n", 
  233. X            (char) 12);
  234. X        while (fgets(buffer, SLEN, fd) != NULL)
  235. X          fprintf(outfd, "%s", buffer);
  236. X        fprintf(outfd, "\n-----\n");
  237. X        fclose(fd);
  238. X      }
  239. X    }
  240. X
  241. X    /* now remove the log files, please! */
  242. X
  243. X    if (clear_logs) {
  244. X      sprintf(filename, "%s/%s", home, filterlog);
  245. X      unlink(filename);
  246. X      sprintf(filename, "%s/%s", home, filtersum);
  247. X      unlink(filename);
  248. X    }
  249. X
  250. X    return;
  251. X}
  252. SHAR_EOF
  253. chmod 0444 filter/summarize.c || echo "restore of filter/summarize.c fails"
  254. echo "x - extracting filter/utils.c (Text)"
  255. sed 's/^X//' << 'SHAR_EOF' > filter/utils.c &&
  256. X
  257. Xstatic char rcsid[] ="@(#)$Id: utils.c,v 2.5 89/03/25 21:45:20 syd Exp $";
  258. X
  259. X/*******************************************************************************
  260. X *  The Elm Mail System  -  $Revision: 2.5 $   $State: Exp $
  261. X *
  262. X *             Copyright (c) 1986, 1987 Dave Taylor
  263. X *             Copyright (c) 1988, 1989 USENET Community Trust
  264. X *******************************************************************************
  265. X * Bug reports, patches, comments, suggestions should be sent to:
  266. X *
  267. X *    Syd Weinstein - elm@dsinc.UUCP
  268. X *            dsinc!elm
  269. X *
  270. X *******************************************************************************
  271. X * $Log:    utils.c,v $
  272. X * Revision 2.5  89/03/25  21:45:20  syd
  273. X * Initial 2.2 Release checkin
  274. X * 
  275. X *
  276. X ******************************************************************************/
  277. X
  278. X/** Utility routines for the filter program...
  279. X
  280. X**/
  281. X
  282. X#include <stdio.h>
  283. X#include <pwd.h>
  284. X#include <ctype.h>
  285. X#include <fcntl.h>
  286. X
  287. X#include "defs.h"
  288. X#include "filter.h"
  289. X
  290. Xleave(reason)
  291. Xchar *reason;
  292. X{
  293. X    if (outfd != NULL)
  294. X      fprintf(outfd,"filter (%s): LEAVE %s\n", username, reason);
  295. X    if (outfd != NULL) fclose(outfd);
  296. X    exit(1);
  297. X}
  298. X
  299. Xlog(what)
  300. Xint what;
  301. X{
  302. X    /** make an entry in the log files for the specified entry **/
  303. X
  304. X    FILE *fd;
  305. X    char filename[SLEN];
  306. X
  307. X    if (! show_only) {
  308. X      sprintf(filename, "%s/%s", home, filtersum);    /* log action once! */
  309. X      if ((fd = fopen(filename, "a")) == NULL) {
  310. X        if (outfd != NULL)
  311. X          fprintf(outfd, "filter (%s): Couldn't open log file %s\n", 
  312. X            filename);
  313. X        fd = stdout;
  314. X      }
  315. X      fprintf(fd, "%d\n", rule_choosen);
  316. X      fclose(fd);
  317. X    }
  318. X
  319. X    sprintf(filename, "%s/%s", home, filterlog);
  320. X
  321. X    if (show_only)
  322. X      fd = stdout;
  323. X    else if ((fd = fopen(filename, "a")) == NULL) {
  324. X      if (outfd != NULL)
  325. X        fprintf(outfd, "filter (%s): Couldn't open log file %s\n", 
  326. X          filename);
  327. X      fd = stdout;
  328. X    }
  329. X    
  330. X    setvbuf(fd, NULL, _IOFBF, BUFSIZ);
  331. X
  332. X    if (strlen(from) + strlen(subject) > 60)
  333. X      fprintf(fd, "\nMail from %s\n\tabout %s\n", from, subject);
  334. X    else
  335. X      fprintf(fd, "\nMail from %s about %s\n", from, subject);
  336. X
  337. X    if (rule_choosen != -1)
  338. X      if (rules[rule_choosen].condition->matchwhat == TO)
  339. X        fprintf(fd, "\t(addressed to %s)\n", to);
  340. X
  341. X    switch (what) {
  342. X      case DELETE_MSG : fprintf(fd, "\tDELETED");            break;
  343. X      case SAVE       : fprintf(fd, "\tSAVED in file \"%s\"", 
  344. X                rules[rule_choosen].argument2);        break;
  345. X      case SAVECC     : fprintf(fd,"\tSAVED in file \"%s\" AND PUT in mailbox", 
  346. X                rules[rule_choosen].argument2);      break;
  347. X      case FORWARD    : fprintf(fd, "\tFORWARDED to \"%s\"", 
  348. X                rules[rule_choosen].argument2);        break;
  349. X      case EXEC       : fprintf(fd, "\tEXECUTED \"%s\"",
  350. X                rules[rule_choosen].argument2);        break;
  351. X      case LEAVE      : fprintf(fd, "\tPUT in mailbox");        break;
  352. X    }
  353. X
  354. X    if (rule_choosen != -1)
  355. X      fprintf(fd, " by rule #%d\n", rule_choosen+1);
  356. X    else
  357. X      fprintf(fd, ": the default action\n");
  358. X
  359. X    fflush(fd);
  360. X    fclose(fd);
  361. X}
  362. X
  363. Xint
  364. Xcontains(string, pattern)
  365. Xchar *string, *pattern;
  366. X{
  367. X    /** Returns TRUE iff pattern occurs IN IT'S ENTIRETY in buffer. **/ 
  368. X
  369. X    register int i = 0, j = 0;
  370. X
  371. X    while (string[i] != '\0') {
  372. X      while (tolower(string[i++]) == tolower(pattern[j++])) 
  373. X        if (pattern[j] == '\0') 
  374. X          return(TRUE);
  375. X      i = i - j + 1;
  376. X      j = 0;
  377. X    }
  378. X    return(FALSE);
  379. X}
  380. X
  381. Xchar *itoa(i, two_digit)
  382. Xint i, two_digit;
  383. X{    
  384. X    /** return 'i' as a null-terminated string.  If two-digit use that
  385. X        size field explicitly!  **/
  386. X
  387. X    static char value[10];
  388. X    
  389. X    if (two_digit)
  390. X      sprintf(value, "%02d", i);
  391. X    else
  392. X      sprintf(value, "%d", i);
  393. X
  394. X    return( (char *) value);
  395. X}
  396. X
  397. Xlowercase(string)
  398. Xchar *string;
  399. X{
  400. X    /** translate string into all lower case **/
  401. X
  402. X    register int i;
  403. X
  404. X    for (i=0; i < strlen(string); i++)
  405. X      if (isupper(string[i]))
  406. X        string[i] = tolower(string[i]);
  407. X}
  408. SHAR_EOF
  409. chmod 0444 filter/utils.c || echo "restore of filter/utils.c fails"
  410. echo "x - extracting hdrs/curses.h (Text)"
  411. sed 's/^X//' << 'SHAR_EOF' > hdrs/curses.h &&
  412. X
  413. X/* $Id: curses.h,v 2.4 89/03/25 21:45:22 syd Exp $ */
  414. X
  415. X/*******************************************************************************
  416. X *  The Elm Mail System  -  $Revision: 2.4 $   $State: Exp $
  417. X *
  418. X *             Copyright (c) 1986, 1987 Dave Taylor
  419. X *             Copyright (c) 1988, 1989 USENET Community Trust
  420. X *******************************************************************************
  421. X * Bug reports, patches, comments, suggestions should be sent to:
  422. X *
  423. X *    Syd Weinstein, Elm Coordinator
  424. X *    elm@dsinc.UUCP            dsinc!elm
  425. X *
  426. X *******************************************************************************
  427. X * $Log:    curses.h,v $
  428. X * Revision 2.4  89/03/25  21:45:22  syd
  429. X * Initial 2.2 Release checkin
  430. X * 
  431. X *
  432. X ******************************************************************************/
  433. X
  434. X     /*** Include file for seperate compilation.  ***/
  435. X
  436. X#define OFF        0
  437. X#define ON         1
  438. X
  439. Xint  InitScreen(),      /* This must be called before anything else!! */
  440. X
  441. X     ClearScreen(),      CleartoEOLN(),
  442. X
  443. X     MoveCursor(),
  444. X     CursorUp(),         CursorDown(), 
  445. X     CursorLeft(),       CursorRight(), 
  446. X
  447. X     StartBold(),        EndBold(), 
  448. X     StartUnderline(),   EndUnderline(), 
  449. X     StartHalfbright(),  EndHalfbright(),
  450. X     StartInverse(),     EndInverse(),
  451. X    
  452. X     transmit_functions(),
  453. X
  454. X     Raw(),              RawState(),
  455. X     ReadCh();
  456. X
  457. Xchar *return_value_of();
  458. SHAR_EOF
  459. chmod 0444 hdrs/curses.h || echo "restore of hdrs/curses.h fails"
  460. echo "x - extracting hdrs/defs.h (Text)"
  461. sed 's/^X//' << 'SHAR_EOF' > hdrs/defs.h &&
  462. X
  463. X/* $Id: defs.h,v 2.16 89/03/25 21:45:23 syd Exp $ */
  464. X
  465. X/*******************************************************************************
  466. X *  The Elm Mail System  -  $Revision: 2.16 $   $State: Exp $
  467. X *
  468. X *             Copyright (c) 1986, 1987 Dave Taylor
  469. X *             Copyright (c) 1988, 1989 USENET Community Trust
  470. X *******************************************************************************
  471. X * Bug reports, patches, comments, suggestions should be sent to:
  472. X *
  473. X *    Syd Weinstein, Elm Coordinator
  474. X *    elm@dsinc.UUCP            dsinc!elm
  475. X *
  476. X *******************************************************************************
  477. X * $Log:    defs.h,v $
  478. X * Revision 2.16  89/03/25  21:45:23  syd
  479. X * Initial 2.2 Release checkin
  480. X * 
  481. X *
  482. X ******************************************************************************/
  483. X
  484. X/**  define file for ELM mail system.  **/
  485. X
  486. X
  487. X#include "../config.h"
  488. X#include "sysdefs.h"    /* system/configurable defines */
  489. X
  490. X
  491. X# define VERSION         "2.2"    /* Version number... */
  492. X
  493. X# define WHAT_STRING    \
  494. X    "@(#) Version 2.2, USENET supported version, March 1989"
  495. X
  496. X#define KLICK        25
  497. X
  498. X#define SLEN        256        /* long for ensuring no overwrites... */
  499. X#define SHORT        5        /* super short strings!          */
  500. X#define NLEN        48        /* name length for aliases            */
  501. X#define WLEN        20
  502. X#define STRING        128    /* reasonable string length for most..      */
  503. X#define LONG_STRING    512    /* even longer string for group expansion   */
  504. X#define VERY_LONG_STRING 2560    /* huge string for group alias expansion    */
  505. X#define MAX_LINE_LEN    5120    /* even bigger string for "filter" prog..   */
  506. X
  507. X#define BREAK        '\0'          /* default interrupt    */
  508. X#define BACKSPACE    '\b'         /* backspace character  */
  509. X#define TAB        '\t'            /* tab character        */
  510. X#define RETURN        '\r'         /* carriage return char */
  511. X#define LINE_FEED    '\n'         /* line feed character  */
  512. X#define FORMFEED    '\f'         /* form feed (^L) char  */
  513. X#define COMMA        ','        /* comma character      */
  514. X#define SPACE        ' '        /* space character      */
  515. X#define DOT        '.'        /* period/dot character */
  516. X#define BANG        '!'        /* exclaimation mark!   */
  517. X#define AT_SIGN        '@'        /* at-sign character    */
  518. X#define PERCENT        '%'        /* percent sign char.   */
  519. X#define COLON        ':'        /* the colon ..        */
  520. X#define BACKQUOTE    '`'        /* backquote character  */
  521. X#define TILDE_ESCAPE    '~'        /* escape character~    */
  522. X#define ESCAPE        '\033'        /* the escape        */
  523. X
  524. X#define NO_OP_COMMAND    '\0'        /* no-op for timeouts   */
  525. X
  526. X#define STANDARD_INPUT  0        /* file number of stdin */
  527. X
  528. X#ifndef TRUE
  529. X#define TRUE        1
  530. X#define FALSE        0
  531. X#endif
  532. X
  533. X#define NO        0
  534. X#define YES        1
  535. X#define MAYBE        2        /* a definite define, eh?  */
  536. X#define FORM        3        /*      <nevermind>        */
  537. X#define PREFORMATTED    4        /* forwarded form...       */
  538. X
  539. X#define PAD        0        /* for printing name of    */
  540. X#define FULL        1        /*   the sort we're using  */
  541. X
  542. X#define OUTGOING    0        /* defines for lock file   */
  543. X#define INCOMING    1        /* creation..see lock()    */
  544. X
  545. X#define SH        0        /* defines for system_call */
  546. X#define USER_SHELL    1        /* to work correctly!      */
  547. X
  548. X#define EXECUTE_ACCESS    01        /* These five are        */
  549. X#define WRITE_ACCESS    02        /*    for the calls       */
  550. X#define READ_ACCESS    04        /*       to access()       */
  551. X#define ACCESS_EXISTS    00        /*           <etc>         */
  552. X#define EDIT_ACCESS    06        /*  (this is r+w access)   */
  553. X
  554. X#define BIG_NUM        999999        /* big number!             */
  555. X#define BIGGER_NUM    9999999     /* bigger number!          */
  556. X
  557. X#define START_ENCODE    "[encode]"
  558. X#define END_ENCODE    "[clear]"
  559. X
  560. X#define DONT_SAVE    "[no save]"
  561. X#define DONT_SAVE2    "[nosave]"
  562. X
  563. X#define alias_file    ".aliases"
  564. X#define group_file    ".groups"
  565. X#define system_file    ".systems"
  566. X
  567. X#define default_folders        "Mail"
  568. X#define default_recvdmail    "=received"
  569. X#define default_sentmail    "=sent"
  570. X
  571. X/** some defines for the 'userlevel' variable... **/
  572. X
  573. X#define RANK_AMATEUR    0
  574. X#define AMATEUR        1
  575. X#define OKAY_AT_IT    2
  576. X#define GOOD_AT_IT    3
  577. X#define EXPERT        4
  578. X#define SUPER_AT_IT    5
  579. X
  580. X/** some defines for the "status" field of the header record **/
  581. X
  582. X#define ACTION        1        /* bit masks, of course */
  583. X#define CONFIDENTIAL    2
  584. X#define DELETED        4
  585. X#define EXPIRED        8
  586. X#define FORM_LETTER    16
  587. X#define NEW        32
  588. X#define PRIVATE        64
  589. X#define TAGGED        128
  590. X#define URGENT        256
  591. X#define VISIBLE        512
  592. X#define UNREAD        1024
  593. X#define STATUS_CHANGED    2048
  594. X
  595. X#define UNDELETE    0        /* purely for ^U function... */
  596. X
  597. X/** values for headers exit_disposition field */
  598. X#define UNSET    0
  599. X#define KEEP    1
  600. X#define    STORE    2
  601. X#define DELETE    3
  602. X
  603. X/** some months... **/
  604. X
  605. X#define JANUARY        0            /* months of the year */
  606. X#define FEBRUARY    1
  607. X#define MARCH        2
  608. X#define APRIL        3
  609. X#define MAY        4
  610. X#define JUNE        5
  611. X#define JULY        6
  612. X#define AUGUST        7
  613. X#define SEPTEMBER    8
  614. X#define OCTOBER        9
  615. X#define NOVEMBER    10
  616. X#define DECEMBER    11
  617. X
  618. X#define equal(s,w)    (strcmp(s,w) == 0)
  619. X#define min(a,b)    a < b? a : b
  620. X#define ctrl(c)            c - 'A' + 1    /* control character mapping */
  621. X#define plural(n)    n == 1 ? "" : "s"
  622. X#define lastch(s)    s[strlen(s)-1]
  623. X
  624. X/* find tab stops preceding or following a given column position 'a', where
  625. X * the column position starts counting from 1, NOT 0!
  626. X * The external integer "tabspacing" must be declared to use this. */
  627. X#define prev_tab(a)    (((((a-1)/tabspacing))*tabspacing)+1)
  628. X#define next_tab(a)    (((((a-1)/tabspacing)+1)*tabspacing)+1)
  629. X
  630. X#define movement_command(c)    (c == 'j' || c == 'k' || c == ' ' ||           \
  631. X                 c == BACKSPACE || c == ESCAPE || c == '*' || \
  632. X                 c == '-' || c == '+' || c == '=' ||          \
  633. X                 c == '#' || c == '@' || c == 'x' ||           \
  634. X                 c == 'a' || c == 'q')
  635. X
  636. X#define no_ret(s)    { register int xyz; /* varname is for lint */          \
  637. X                  for (xyz=strlen(s)-1; xyz >= 0 &&               \
  638. X                (s[xyz] == '\r' || s[xyz] == '\n'); )          \
  639. X                 s[xyz--] = '\0';                                 \
  640. X            }
  641. X              
  642. X#define first_word(s,w) (strncmp(s,w, strlen(w)) == 0)
  643. X#define ClearLine(n)    MoveCursor(n,0); CleartoEOLN()
  644. X#define whitespace(c)    (c == ' ' || c == '\t')
  645. X#define ok_char(c)    (isalnum(c) || c == '-' || c == '_')
  646. X#define quote(c)    (c == '"' || c == '\'') 
  647. X#define onoff(n)    (n == 0 ? "OFF" : "ON")
  648. X
  649. X/** The next function is so certain commands can be processed from the showmsg
  650. X    routine without rewriting the main menu in between... **/
  651. X
  652. X#define special(c)    (c == 'j' || c == 'k')
  653. X
  654. X/** and a couple for dealing with status flags... **/
  655. X
  656. X#define ison(n,mask)    (n & mask)
  657. X#define isoff(n,mask)    (!ison(n, mask))
  658. X
  659. X#define setit(n,mask)        n |= mask
  660. X#define clearit(n, mask)    n &= ~mask
  661. X
  662. X/** a few for the usage of function keys... **/
  663. X
  664. X#define f1    1
  665. X#define f2    2
  666. X#define f3    3
  667. X#define f4    4
  668. X#define f5    5
  669. X#define f6    6
  670. X#define f7    7
  671. X#define f8    8
  672. X
  673. X#define MAIN    0
  674. X#define ALIAS   1
  675. X#define YESNO    2
  676. X#define CHANGE  3
  677. X#define READ    4
  678. X
  679. X#define MAIN_HELP    0
  680. X#define OPTIONS_HELP 1
  681. X#define ALIAS_HELP   2
  682. X#define PAGER_HELP   3
  683. X
  684. X/** types of folders **/
  685. X#define NO_NAME        0        /* variable contains no file name */
  686. X#define NON_SPOOL    1        /* mailfile not in mailhome */
  687. X#define SPOOL        2        /* mailfile in mailhome */
  688. X
  689. X/* the following is true if the current mailfile is the user's spool file*/
  690. X#define USERS_SPOOL    (strcmp(cur_folder, defaultfile) == 0)
  691. X
  692. X/** some possible sort styles... **/
  693. X
  694. X#define REVERSE        -        /* for reverse sorting           */
  695. X#define SENT_DATE    1        /* the date message was sent     */
  696. X#define RECEIVED_DATE    2        /* the date message was received */
  697. X#define SENDER        3        /* the name/address of sender    */
  698. X#define SIZE        4        /* the # of lines of the message */
  699. X#define SUBJECT        5        /* the subject of the message    */
  700. X#define STATUS        6        /* the status (deleted, etc)     */
  701. X#define MAILBOX_ORDER    7        /* the order it is in the file   */
  702. X
  703. X/* some stuff for our own malloc call - pmalloc */
  704. X
  705. X#define PMALLOC_THRESHOLD    256    /* if greater, then just use malloc */
  706. X#define PMALLOC_BUFFER_SIZE    2048    /* internal [memory] buffer size... */
  707. X
  708. X/** the following macro is as suggested by Larry McVoy.  Thanks! **/
  709. X
  710. X# ifdef DEBUG
  711. X#  define   dprint(n,x)        {                 \
  712. X                   if (debug >= n)  {        \
  713. X                     fprintf x ;         \
  714. X                     fflush(debugfile);         \
  715. X                   }                \
  716. X                }
  717. X# else
  718. X#  define   dprint(n,x)
  719. X# endif
  720. X
  721. X/* some random structs... */
  722. X
  723. Xstruct date_rec {
  724. X    int  month;        /** this record stores a **/
  725. X    int  day;        /**   specific date and  **/
  726. X    int  year;        /**     time...         **/
  727. X    int  hour;
  728. X    int  minute;
  729. X       };
  730. X
  731. Xstruct header_rec {
  732. X    int  lines;        /** # of lines in the message  **/
  733. X    int  status;        /** Urgent, Deleted, Expired?  **/
  734. X    int  index_number;    /** relative loc in file...    **/
  735. X    int  encrypted;        /** whether msg has encryption **/
  736. X    int  exit_disposition;    /** whether to keep, store, delete **/
  737. X    int  status_chgd;    /** whether became read or old, etc. **/
  738. X    long offset;        /** offset in bytes of message **/
  739. X    struct date_rec received; /** when elm received here   **/
  740. X    char from[STRING];    /** who sent the message?      **/
  741. X    char to[STRING];    /** who it was sent to           **/
  742. X    char messageid[STRING];    /** the Message-ID: value      **/
  743. X    char dayname[8];    /**  when the                  **/
  744. X    char month[10];        /**        message             **/
  745. X    char day[3];        /**          was            **/
  746. X    char year[5];        /**            sent            **/
  747. X    char time[NLEN];    /**              to you!       **/
  748. X    char subject[STRING];   /** The subject of the mail    **/
  749. X    char mailx_status[WLEN];/** mailx status flags (RO...) **/
  750. X       };
  751. X
  752. Xstruct alias_rec {
  753. X    char   name[NLEN];    /* alias name                  */
  754. X    long   byte;        /* offset into data file for address */
  755. X       };
  756. X
  757. Xstruct lsys_rec {
  758. X    char   name[NLEN];    /* name of machine connected to      */
  759. X    struct lsys_rec *next;    /* linked list pointer to next       */
  760. X       };
  761. X
  762. Xstruct addr_rec {
  763. X     char   address[NLEN];    /* machine!user you get mail as      */
  764. X     struct addr_rec *next;    /* linked list pointer to next       */
  765. X    };
  766. X
  767. X#ifdef SHORTNAMES    /* map long names to shorter ones */
  768. X# include <shortname.h>
  769. X#endif
  770. X
  771. X/** Let's make sure that we're not going to have any annoying problems with 
  772. X    int pointer sizes versus char pointer sizes by guaranteeing that every-
  773. X    thing vital is predefined... (Thanks go to Detlev Droege for this one)
  774. X**/
  775. X
  776. X#ifdef STRINGS
  777. X#  include <strings.h>
  778. X#else
  779. X#  include <string.h>
  780. X#endif
  781. X
  782. Xchar *argv_zero();
  783. Xchar *bounce_off_remote();
  784. Xchar *ctime();
  785. Xchar *error_description();
  786. Xchar *error_name();
  787. Xchar *error_number();
  788. Xchar *expand_address();
  789. Xchar *expand_domain();
  790. Xchar *expand_group();
  791. Xchar *expand_logname();
  792. Xchar *expand_system();
  793. Xchar *find_path_to();
  794. Xchar *format_long();
  795. Xchar *get_alias_address();
  796. Xchar *get_arpa_date();
  797. Xchar *get_ctime_date();
  798. Xchar *get_date();
  799. Xchar *get_token();
  800. Xchar *getenv();
  801. Xchar *getlogin();
  802. Xchar *level_name();
  803. Xchar *match_and_expand_domain();
  804. Xchar *shift_lower();
  805. Xchar *strip_commas();
  806. Xchar *strip_parens();
  807. Xchar *strpbrk();
  808. Xchar *strtok();
  809. Xchar *tail_of_string();
  810. Xchar *tgetstr();
  811. Xchar *pmalloc();
  812. X
  813. Xlong lseek();
  814. Xlong times();
  815. Xlong ulimit();
  816. SHAR_EOF
  817. chmod 0444 hdrs/defs.h || echo "restore of hdrs/defs.h fails"
  818. echo "x - extracting hdrs/elm.h (Text)"
  819. sed 's/^X//' << 'SHAR_EOF' > hdrs/elm.h &&
  820. X
  821. X/* $Id: elm.h,v 2.21 89/03/25 21:45:26 syd Exp $ */
  822. X
  823. X/*******************************************************************************
  824. X *  The Elm Mail System  -  $Revision: 2.21 $   $State: Exp $
  825. X *
  826. X *             Copyright (c) 1986, 1987 Dave Taylor
  827. X *             Copyright (c) 1988, 1989 USENET Community Trust
  828. X *******************************************************************************
  829. X * Bug reports, patches, comments, suggestions should be sent to:
  830. X *
  831. X *    Syd Weinstein, Elm Coordinator
  832. X *    elm@dsinc.UUCP            dsinc!elm
  833. X *
  834. X *******************************************************************************
  835. X * $Log:    elm.h,v $
  836. X * Revision 2.21  89/03/25  21:45:26  syd
  837. X * Initial 2.2 Release checkin
  838. X * 
  839. X *
  840. X ******************************************************************************/
  841. X
  842. X/**  Main header file for ELM mail system.  **/
  843. X
  844. X
  845. X#include <stdio.h>
  846. X#include <fcntl.h>
  847. X
  848. X#include "../hdrs/curses.h"
  849. X#include "../hdrs/defs.h"
  850. X
  851. X/******** static character string containing the version number  *******/
  852. X
  853. Xstatic char ident[] = { WHAT_STRING };
  854. X
  855. X/******** and another string for the copyright notice            ********/
  856. X
  857. Xstatic char copyright[] = { 
  858. X        "@(#)          (C) Copyright 1986, 1987, Dave Taylor\n@(#)          (C) Copyright 1988, The Usenet Community Trust\n" };
  859. X
  860. X/******** global variables accessable by all pieces of the program *******/
  861. X
  862. Xint check_size = 0;        /* don't start mailer if no mail */
  863. Xint current = 0;        /* current message number  */
  864. Xint header_page = 0;         /* current header page     */
  865. Xint last_header_page = -1;         /* last header page        */
  866. Xint message_count = 0;        /* max message number      */
  867. Xint headers_per_page;        /* number of headers/page  */
  868. Xint sendmail_verbose = 0;       /* Extended mail debugging */
  869. Xchar cur_folder[SLEN] = {0};    /* name of current folder */
  870. Xchar cur_tempfolder[SLEN] = {0}; /* name of temp folder open for a mailbox */
  871. Xchar defaultfile[SLEN] = {0};    /* name of default folder */
  872. Xchar hostname[SLEN] = {0};    /* name of machine we're on*/
  873. Xchar hostdomain[SLEN] = {0};    /* name of domain we're in */
  874. Xchar username[SLEN] = {0};    /* return address name!    */
  875. Xchar full_username[SLEN] = {0};    /* Full username - gecos   */
  876. Xchar home[SLEN] = {0};        /* home directory of user  */
  877. Xchar folders[SLEN] = {0};    /* folder home directory   */
  878. Xchar raw_folders[SLEN] = {0};    /* unexpanded folder home directory   */
  879. Xchar recvd_mail[SLEN] = {0};    /* folder for storing received mail    */
  880. Xchar raw_recvdmail[SLEN] = {0};    /* unexpanded recvd_mail name */
  881. Xchar editor[SLEN] = {0};    /* editor for outgoing mail*/
  882. Xchar raw_editor[SLEN] = {0};    /* unexpanded editor for outgoing mail*/
  883. Xchar alternative_editor[SLEN] = {0};    /* alternative editor...   */
  884. Xchar printout[SLEN] = {0};    /* how to print messages   */
  885. Xchar raw_printout[SLEN] = {0};    /* unexpanded how to print messages   */
  886. Xchar sent_mail[SLEN] = {0};    /* name of file to save copies to */
  887. Xchar raw_sentmail[SLEN] = {0};    /* unexpanded name of file to save to */
  888. Xchar calendar_file[SLEN] = {0};    /* name of file for clndr  */
  889. Xchar raw_calendar_file[SLEN] = {0};    /* unexpanded name of file for clndr  */
  890. Xchar prefixchars[SLEN] = "> ";    /* prefix char(s) for msgs */
  891. Xchar shell[SLEN] = {0};        /* current system shell    */
  892. Xchar raw_shell[SLEN] = {0};    /* unexpanded current system shell    */
  893. Xchar pager[SLEN] = {0};        /* what pager to use       */
  894. Xchar raw_pager[SLEN] = {0};    /* unexpanded what pager to use       */
  895. Xchar batch_subject[SLEN] = {0};    /* subject buffer for batchmail */
  896. Xchar local_signature[SLEN] = {0};    /* local msg signature file     */
  897. Xchar raw_local_signature[SLEN] = {0};    /* unexpanded local msg signature file     */
  898. Xchar remote_signature[SLEN] = {0};    /* remote msg signature file    */
  899. Xchar raw_remote_signature[SLEN] = {0};/* unexpanded remote msg signature file    */
  900. Xchar version_buff[SLEN] = {0};    /* version buffer */
  901. X
  902. Xchar backspace,            /* the current backspace char */
  903. X     escape_char = TILDE_ESCAPE,/* '~' or something else..    */
  904. X     kill_line;            /* the current kill-line char */
  905. X
  906. Xchar up[SHORT], down[SHORT],    /* cursor control seq's    */
  907. X     left[SHORT], right[SHORT];
  908. Xint  cursor_control = FALSE;    /* cursor control avail?   */
  909. X
  910. Xchar start_highlight[SHORT],
  911. X     end_highlight[SHORT];    /* stand out mode...       */
  912. X
  913. Xint  has_highlighting = FALSE;    /* highlighting available? */
  914. X
  915. Xchar *weedlist[MAX_IN_WEEDLIST];
  916. Xint  weedcount;
  917. X
  918. Xint allow_forms = NO;        /* flag: are AT&T Mail forms okay?  */
  919. Xint mini_menu = 1;        /* flag: menu specified?        */
  920. Xint prompt_after_pager = 1;    /* flag: prompt after pager exits   */
  921. Xint folder_type = 0;        /* flag: type of folder            */
  922. Xint auto_copy = 0;        /* flag: automatically copy source? */
  923. Xint filter = 1;            /* flag: weed out header lines?        */
  924. Xint resolve_mode = 1;        /* flag: delete saved mail?        */
  925. Xint auto_cc = 0;        /* flag: mail copy to user?        */
  926. Xint noheader = 1;        /* flag: copy + header to file?     */
  927. Xint title_messages = 1;        /* flag: title message display?     */
  928. Xint forwarding = 0;        /* flag: are we forwarding the msg? */
  929. Xint hp_terminal = 0;        /* flag: are we on HP term?        */
  930. Xint hp_softkeys = 0;        /* flag: are there softkeys?        */
  931. Xint save_by_name = 1;        /* flag: save mail by login name?   */
  932. Xint mail_only = 0;        /* flag: send mail then leave?      */
  933. Xint check_only = 0;        /* flag: check aliases then leave?  */
  934. Xint batch_only = 0;        /* flag: send without prompting?    */
  935. Xint move_when_paged = 0;    /* flag: move when '+' or '-' used? */
  936. Xint point_to_new = 1;        /* flag: start pointing at new msg? */
  937. Xint bounceback = 0;        /* flag: bounce copy off remote?    */
  938. Xint always_keep = 1;        /* flag: always keep unread msgs?   */
  939. Xint always_store = 0;        /* flag: always store read msgs?    */
  940. Xint always_del = 0;        /* flag: always delete marked msgs? */
  941. Xint arrow_cursor = 0;        /* flag: use "->" cursor regardless?*/
  942. Xint debug = 0;             /* flag: default is no debug!       */
  943. Xint read_in_aliases = 0;    /* flag: have we read in aliases??  */
  944. Xint warnings = 1;        /* flag: output connection warnings?*/
  945. Xint user_level = 0;        /* flag: how good is the user?      */
  946. Xint selected = 0;        /* flag: used for select stuff      */
  947. Xint names_only = 1;        /* flag: display user names only?   */
  948. Xint question_me = 1;        /* flag: ask questions as we leave? */
  949. Xint keep_empty_files = 0;    /* flag: leave empty folder files? */
  950. Xint clear_pages = 0;        /* flag: act like "page" (more -c)? */
  951. Xint prompt_for_cc = 1;        /* flag: ask user for "cc:" value?  */
  952. X
  953. Xint sortby = REVERSE SENT_DATE;    /* how to sort incoming mail...     */
  954. X
  955. Xlong timeout = 600L;        /* timeout (secs) on main prompt    */
  956. X
  957. X/** set up some default values for a 'typical' terminal *snicker* **/
  958. X
  959. Xint LINES=23;            /** lines per screen      **/
  960. Xint COLUMNS=80;            /** columns per page      **/
  961. X
  962. Xlong size_of_pathfd;        /** size of pathfile, 0 if none **/
  963. X
  964. XFILE *mailfile;            /* current folder        */
  965. XFILE *debugfile;        /* file for debug output    */
  966. XFILE *pathfd;            /* path alias file          */
  967. XFILE *domainfd;            /* domain file            */
  968. X
  969. Xlong mailfile_size;        /* size of current mailfile */
  970. X
  971. Xint   max_headers;        /* number of headers allocated */
  972. X
  973. Xstruct header_rec **headers;    /* array of header structure pointers */
  974. X
  975. Xstruct alias_rec user_hash_table[MAX_UALIASES];
  976. Xstruct alias_rec system_hash_table[MAX_SALIASES];
  977. X
  978. Xstruct lsys_rec *talk_to_sys;   /* what machines do we talk to? */
  979. X
  980. Xstruct addr_rec *alternative_addresses;    /* how else do we get mail? */
  981. X
  982. Xint system_files = 0;        /* do we have system aliases? */
  983. Xint user_files = 0;        /* do we have user aliases?   */
  984. X
  985. Xint system_data;        /* fileno of system data file */
  986. Xint user_data;            /* fileno of user data file   */
  987. X
  988. Xint userid;            /* uid for current user          */
  989. Xint groupid;            /* groupid for current user   */
  990. SHAR_EOF
  991. chmod 0444 hdrs/elm.h || echo "restore of hdrs/elm.h fails"
  992. echo "x - extracting hdrs/filter.h (Text)"
  993. sed 's/^X//' << 'SHAR_EOF' > hdrs/filter.h &&
  994. X
  995. X/* $Id: filter.h,v 2.4 89/03/25 21:45:30 syd Exp $ */
  996. X
  997. X/*******************************************************************************
  998. X *  The Elm Mail System  -  $Revision: 2.4 $   $State: Exp $
  999. X *
  1000. X *             Copyright (c) 1986, 1987 Dave Taylor
  1001. X *             Copyright (c) 1988, 1989 USENET Community Trust
  1002. X *******************************************************************************
  1003. X * Bug reports, patches, comments, suggestions should be sent to:
  1004. X *
  1005. X *    Syd Weinstein, Elm Coordinator
  1006. X *    elm@dsinc.UUCP            dsinc!elm
  1007. X *
  1008. X *******************************************************************************
  1009. X * $Log:    filter.h,v $
  1010. X * Revision 2.4  89/03/25  21:45:30  syd
  1011. X * Initial 2.2 Release checkin
  1012. X * 
  1013. X *
  1014. X ******************************************************************************/
  1015. X
  1016. X/** Headers for the filter program.
  1017. X
  1018. X**/
  1019. X
  1020. X#ifdef   BSD
  1021. X# undef  tolower
  1022. X#endif
  1023. X
  1024. X/** define a few handy macros for later use... **/
  1025. X
  1026. X#define  the_same(a,b)    (strncmp(a,b,strlen(b)) == 0)
  1027. X
  1028. X#define relationname(x)  (x == 1?"<=":x==2?"<":x==3?">=":x==4?">":x==5?"!=":"=")
  1029. X
  1030. X#define quoteit(x)     (x == LINES? "" : "\"")
  1031. X
  1032. X#define remove_return(s)    { if (s[strlen(s)-1] == '\n') \
  1033. X                    s[strlen(s)-1] = '\0';    \
  1034. X                   }
  1035. X
  1036. X/** some of the files we'll be using, where they are, and so on... **/
  1037. X
  1038. X#define  filter_temp    "/tmp/filter"
  1039. X#define  filterfile    ".filter-rules"
  1040. X#define  filterlog    ".filterlog"
  1041. X#define  filtersum    ".filtersum"
  1042. X
  1043. X#define  EMERGENCY_MAILBOX    "EMERGENCY_MBOX"
  1044. X#define  EMERG_MBOX        "MBOX.EMERGENCY"
  1045. X
  1046. X/** and now the hardwired constraint of the program.. **/
  1047. X
  1048. X#define  MAXRULES    25        /* can't have more den dis, boss! */
  1049. X
  1050. X/** some random defines for mnemonic stuff in the program... **/
  1051. X
  1052. X#ifdef SUBJECT
  1053. X# undef SUBJECT
  1054. X#endif
  1055. X
  1056. X#define  TO        1
  1057. X#define  FROM        2
  1058. X#define  LINES        3
  1059. X#define  SUBJECT    4
  1060. X#define  CONTAINS    5
  1061. X#define  ALWAYS        6
  1062. X
  1063. X#define  DELETE_MSG     7
  1064. X#define  SAVE        8
  1065. X#define  SAVECC        9
  1066. X#define  FORWARD    10
  1067. X#define  LEAVE        11
  1068. X#define  EXEC        12
  1069. X
  1070. X#define  FAILED_SAVE    20
  1071. X
  1072. X/** Some conditionals... **/
  1073. X
  1074. X#define LE        1
  1075. X#define LT        2
  1076. X#define GE        3
  1077. X#define GT        4
  1078. X#define NE        5
  1079. X#define EQ        6
  1080. X
  1081. X/** A funky way to open a file using open() to avoid file locking hassles **/
  1082. X
  1083. X#define  FOLDERMODE    O_WRONLY | O_APPEND | O_CREAT | O_SYNCIO
  1084. X
  1085. X/** cheap but easy way to have two files share the same #include file **/
  1086. X
  1087. X#ifdef MAIN_ROUTINE
  1088. X
  1089. Xchar home[SLEN],                /* the users home directory */
  1090. X     hostname[SLEN],            /* the machine name...      */
  1091. X     username[SLEN];            /* the users login name...  */
  1092. X
  1093. Xchar to[VERY_LONG_STRING], 
  1094. X     from[LONG_STRING], 
  1095. X     subject[LONG_STRING];        /* from current message     */
  1096. X
  1097. XFILE *outfd;
  1098. Xchar outfname[SLEN];
  1099. X
  1100. Xint  total_rules = 0,                /* how many rules to check  */
  1101. X     show_only = FALSE,                /* just for show?           */
  1102. X     long_summary = FALSE,            /* what sorta summary??     */
  1103. X     verbose   = FALSE,                /* spit out lots of stuff   */
  1104. X     lines     = 0,                /* lines in message..       */
  1105. X     clear_logs = FALSE,            /* clear files after sum?   */
  1106. X     already_been_forwarded = FALSE,        /* has this been filtered?  */
  1107. X     log_actions_only = FALSE,            /* log actions | everything */
  1108. X     printing_rules = FALSE,            /* are we just using '-r'?  */
  1109. X     rule_choosen;                /* which one we choose      */
  1110. X
  1111. X#else
  1112. X
  1113. Xextern char home[SLEN],                /* the users home directory */
  1114. X            hostname[SLEN],            /* the machine name...      */
  1115. X            username[SLEN];            /* the users login name...  */
  1116. X
  1117. Xextern char to[VERY_LONG_STRING], 
  1118. X            from[LONG_STRING], 
  1119. X            subject[LONG_STRING];        /* from current message     */
  1120. X
  1121. Xextern FILE *outfd;
  1122. Xextern char outfname[SLEN];
  1123. X
  1124. Xextern int total_rules,                /* how many rules to check  */
  1125. X           show_only,                /* just for show?           */
  1126. X           long_summary,            /* what sorta summary??     */
  1127. X           verbose,                /* spit out lots of stuff   */
  1128. X           lines,                /* lines in message..       */
  1129. X           clear_logs,                    /* clear files after sum?   */
  1130. X       already_been_forwarded,        /* has this been filtered?  */
  1131. X           log_actions_only,            /* log actions | everything */
  1132. X           printing_rules,            /* are we just using '-r'?  */
  1133. X           rule_choosen;            /* which one we choose      */
  1134. X#endif
  1135. X
  1136. X/** and our ruleset record structure... **/
  1137. X
  1138. Xstruct condition_rec {
  1139. X    int     matchwhat;            /* type of 'if' clause      */
  1140. X    int     relation;            /* type of match (eq, etc)  */
  1141. X    char    argument1[SLEN];        /* match against this       */
  1142. X    struct  condition_rec  *next;        /* next condition...        */
  1143. X      };
  1144. X
  1145. Xextern struct ruleset_record {
  1146. X    char      printable[SLEN];        /* straight from file...    */
  1147. X    struct  condition_rec  *condition;
  1148. X    int     action;                /* what action to take      */
  1149. X    char    argument2[SLEN];        /* argument for action      */
  1150. X      };
  1151. X
  1152. X#ifdef MAIN_ROUTINE
  1153. X  struct ruleset_record rules[MAXRULES];
  1154. X#else
  1155. X  extern struct ruleset_record rules[MAXRULES];
  1156. X#endif
  1157. X
  1158. X/** finally let's keep LINT happy with the return values of all these pups! ***/
  1159. X
  1160. Xunsigned short getuid();
  1161. X
  1162. Xunsigned long sleep();
  1163. X
  1164. Xchar *malloc(), *strcpy(), *strcat(), *itoa();
  1165. X
  1166. Xvoid    exit();
  1167. X
  1168. X#ifdef BSD
  1169. X    
  1170. X  FILE *popen();
  1171. X
  1172. X#ifdef MAIN_ROUTINE
  1173. X  char  _vbuf[5*BUFSIZ];              /* space for file buffering */
  1174. X#else
  1175. X  extern char  _vbuf[5*BUFSIZ];        /* space for file buffering */
  1176. X#endif
  1177. X
  1178. X#ifndef _IOFBF
  1179. X# define _IOFBF        0        /* doesn't matter - ignored */
  1180. X#endif
  1181. X
  1182. X# define setvbuf(fd,a,b,c)    setbuffer(fd, _vbuf, 5*BUFSIZ)
  1183. X
  1184. X#endif
  1185. SHAR_EOF
  1186. chmod 0444 hdrs/filter.h || echo "restore of hdrs/filter.h fails"
  1187. echo "x - extracting hdrs/headers.h (Text)"
  1188. sed 's/^X//' << 'SHAR_EOF' > hdrs/headers.h &&
  1189. X
  1190. X/* $Id: headers.h,v 2.18 89/03/25 21:45:31 syd Exp $ */
  1191. X
  1192. X/*******************************************************************************
  1193. X *  The Elm Mail System  -  $Revision: 2.18 $   $State: Exp $
  1194. X *
  1195. X *             Copyright (c) 1986, 1987 Dave Taylor
  1196. X *             Copyright (c) 1988, 1989 USENET Community Trust
  1197. X *******************************************************************************
  1198. X * Bug reports, patches, comments, suggestions should be sent to:
  1199. X *
  1200. X *    Syd Weinstein, Elm Coordinator
  1201. X *    elm@dsinc.UUCP            dsinc!elm
  1202. X *
  1203. X *******************************************************************************
  1204. X * $Log:    headers.h,v $
  1205. X * Revision 2.18  89/03/25  21:45:31  syd
  1206. X * Initial 2.2 Release checkin
  1207. X * 
  1208. X *
  1209. X ******************************************************************************/
  1210. X
  1211. X/**  This is the header file for ELM mail system.  **/
  1212. X
  1213. X
  1214. X#include <stdio.h>
  1215. X#include <fcntl.h>
  1216. X
  1217. X#include "curses.h"
  1218. X#include "defs.h"
  1219. X
  1220. X#ifndef       clearerr
  1221. X#define       clearerr(p)     (void)((p)->_flag &= ~(_IOERR|_IOEOF))
  1222. X#endif
  1223. X
  1224. X/******** global variables accessable by all pieces of the program *******/
  1225. X
  1226. Xextern int check_size;        /* don't start mailer if no mail */
  1227. Xextern int current;        /* current message number  */
  1228. Xextern int header_page;         /* current header page     */
  1229. Xextern int last_header_page;    /* last header page        */
  1230. Xextern int message_count;    /* max message number      */
  1231. Xextern int headers_per_page;    /* number of headers/page  */
  1232. Xextern int sendmail_verbose;    /* Allow extended debugging on sendmail */
  1233. Xextern char cur_folder[SLEN];    /* name of current folder */
  1234. Xextern char cur_tempfolder[SLEN]; /* name of temp folder open for a mailbox */
  1235. Xextern char defaultfile[SLEN];    /* name of default folder */
  1236. Xextern char hostname[SLEN];    /* name of machine we're on*/
  1237. Xextern char hostdomain[SLEN];    /* name of domain we're in */
  1238. Xextern char username[SLEN];    /* return address name!    */
  1239. Xextern char full_username[SLEN];/* Full username - gecos   */
  1240. Xextern char home[SLEN];        /* home directory of user  */
  1241. Xextern char folders[SLEN];    /* folder home directory   */
  1242. Xextern char raw_folders[SLEN];    /* unexpanded folder home directory   */
  1243. Xextern char recvd_mail[SLEN];    /* folder for storing received mail    */
  1244. Xextern char raw_recvdmail[SLEN];/* unexpanded recvd_mail name */
  1245. Xextern char editor[SLEN];    /* default editor for mail */
  1246. Xextern char raw_editor[SLEN];    /* unexpanded default editor for mail */
  1247. Xextern char alternative_editor[SLEN];/* the 'other' editor */
  1248. Xextern char printout[SLEN];    /* how to print messages   */
  1249. Xextern char raw_printout[SLEN];    /* unexpanded how to print messages   */
  1250. Xextern char sent_mail[SLEN];    /* name of file to save copies to */
  1251. Xextern char raw_sentmail[SLEN];    /* unexpanded name of file to save to */
  1252. Xextern char calendar_file[SLEN];/* name of file for clndr  */
  1253. Xextern char raw_calendar_file[SLEN];/* unexpanded name of file for clndr  */
  1254. Xextern char prefixchars[SLEN];    /* prefix char(s) for msgs */
  1255. Xextern char shell[SLEN];    /* default system shell    */
  1256. Xextern char raw_shell[SLEN];    /* unexpanded default system shell    */
  1257. Xextern char pager[SLEN];    /* what pager to use...    */
  1258. Xextern char raw_pager[SLEN];    /* unexpanded what pager to use...    */
  1259. Xextern char batch_subject[SLEN];/* subject buffer for batchmail */
  1260. Xextern char local_signature[SLEN];/* local msg signature file   */
  1261. Xextern char raw_local_signature[SLEN];/* unexpanded local msg signature file */
  1262. Xextern char remote_signature[SLEN];/* remote msg signature file */
  1263. Xextern char raw_remote_signature[SLEN];/* unexpanded remote msg signature file*/
  1264. X
  1265. Xextern char backspace,        /* the current backspace char  */
  1266. X        escape_char,    /* '~' or something else...    */
  1267. X        kill_line;        /* the current kill_line char  */
  1268. X
  1269. Xextern char up[SHORT], 
  1270. X        down[SHORT],
  1271. X        left[SHORT],
  1272. X        right[SHORT];    /* cursor control seq's    */
  1273. Xextern int  cursor_control;    /* cursor control avail?   */
  1274. X
  1275. Xextern char start_highlight[SHORT],
  1276. X        end_highlight[SHORT];  /* standout mode... */
  1277. X
  1278. Xextern int  has_highlighting;    /* highlighting available? */
  1279. X
  1280. X/** the following two are for arbitrary weedout lists.. **/
  1281. X
  1282. Xextern char *weedlist[MAX_IN_WEEDLIST];
  1283. Xextern int  weedcount;        /* how many headers to check?        */
  1284. X
  1285. Xextern int  allow_forms;    /* flag: are AT&T Mail forms okay?    */
  1286. Xextern int  prompt_after_pager;    /* flag: prompt after pager exits     */
  1287. Xextern int  mini_menu;        /* flag: display menu?               */
  1288. Xextern int  folder_type;    /* flag: type of folder              */
  1289. Xextern int  auto_copy;        /* flag: auto copy source into reply? */
  1290. Xextern int  filter;        /* flag: weed out header lines?          */
  1291. Xextern int  resolve_mode;    /* flag: resolve before moving mode?  */
  1292. Xextern int  auto_cc;        /* flag: mail copy to yourself?       */
  1293. Xextern int  noheader;        /* flag: copy + header to file?       */
  1294. Xextern int  title_messages;    /* flag: title message display?       */
  1295. Xextern int  forwarding;        /* flag: are we forwarding the msg?   */
  1296. Xextern int  hp_terminal;    /* flag: are we on an hp terminal?    */
  1297. Xextern int  hp_softkeys;    /* flag: are there softkeys?          */
  1298. Xextern int  save_by_name;      /* flag: save mail by login name?     */
  1299. Xextern int  mail_only;        /* flag: send mail then leave?        */
  1300. Xextern int  check_only;        /* flag: check aliases and leave?     */
  1301. Xextern int  batch_only;        /* flag: send without prompting?      */
  1302. Xextern int  move_when_paged;    /* flag: move when '+' or '-' used?   */
  1303. Xextern int  point_to_new;    /* flag: start pointing at new msgs?  */
  1304. Xextern int  bounceback;        /* flag: bounce copy off remote?      */
  1305. Xextern int  always_keep;    /* flag: always keep unread msgs?     */
  1306. Xextern int  always_store;    /* flag: always store read mail?      */
  1307. Xextern int  always_del;        /* flag: always delete marked msgs?   */
  1308. Xextern int  arrow_cursor;    /* flag: use "->" regardless?          */
  1309. Xextern int  debug;        /* flag: debugging mode on?           */
  1310. Xextern int  read_in_aliases;    /* flag: have we read in aliases yet? */
  1311. Xextern int  warnings;        /* flag: output connection warnings?  */
  1312. Xextern int  user_level;        /* flag: how knowledgable is user?    */
  1313. Xextern int  selected;        /* flag: used for select stuff        */
  1314. Xextern int  names_only;        /* flag: display names but no addrs?  */
  1315. Xextern int  question_me;    /* flag: ask questions as we leave?   */
  1316. Xextern int  keep_empty_files;    /* flag: keep empty files??          */
  1317. Xextern int  clear_pages;    /* flag: clear screen w/ builtin pgr? */
  1318. Xextern int  prompt_for_cc;    /* flag: prompt user for 'cc' value?  */
  1319. X
  1320. Xextern int  sortby;        /* how to sort folders          */
  1321. X
  1322. Xextern long timeout;        /* seconds for main level timeout     */
  1323. X
  1324. Xextern int LINES;        /** lines per screen    **/
  1325. Xextern int COLUMNS;        /** columns per line    **/
  1326. X
  1327. Xextern long size_of_pathfd;    /** size of pathfile, 0 if none **/
  1328. X
  1329. Xextern FILE *mailfile;        /* current folder         */
  1330. Xextern FILE *debugfile;        /* file for debut output    */
  1331. Xextern FILE *pathfd;        /* path alias file          */
  1332. Xextern FILE *domainfd;        /* domains file         */
  1333. X
  1334. Xextern long mailfile_size;    /* size of current mailfile */
  1335. X
  1336. Xextern int  max_headers;    /* number of headers currently allocated */
  1337. X
  1338. Xextern struct header_rec **headers; /* array of header structure pointers */
  1339. X
  1340. Xextern struct alias_rec user_hash_table  [MAX_UALIASES];
  1341. Xextern struct alias_rec system_hash_table[MAX_SALIASES];
  1342. X
  1343. Xextern struct lsys_rec *talk_to_sys;    /* who do we talk to? */
  1344. X
  1345. Xextern struct addr_rec *alternative_addresses;    /* how else do we get mail? */
  1346. X
  1347. Xextern int system_files;    /* do we have system aliases? */
  1348. Xextern int user_files;        /* do we have user aliases?   */
  1349. X
  1350. Xextern int system_data;        /* fileno of system data file */
  1351. Xextern int user_data;        /* fileno of user data file   */
  1352. X
  1353. Xextern int userid;        /* uid for current user          */
  1354. Xextern int groupid;        /* groupid for current user   */
  1355. SHAR_EOF
  1356. chmod 0444 hdrs/headers.h || echo "restore of hdrs/headers.h fails"
  1357. echo "x - extracting hdrs/patchlevel.h (Text)"
  1358. sed 's/^X//' << 'SHAR_EOF' > hdrs/patchlevel.h &&
  1359. X#define PATCHLEVEL 0
  1360. SHAR_EOF
  1361. chmod 0666 hdrs/patchlevel.h || echo "restore of hdrs/patchlevel.h fails"
  1362. echo "x - extracting hdrs/save_opts.h (Text)"
  1363. sed 's/^X//' << 'SHAR_EOF' > hdrs/save_opts.h &&
  1364. X
  1365. X/* @(#)$Id: save_opts.h,v 2.9 89/03/25 21:45:33 syd Exp $ */
  1366. X
  1367. X/*******************************************************************************
  1368. X *  The Elm Mail System  -  $Revision: 2.9 $   $State: Exp $
  1369. X *
  1370. X *             Copyright (c) 1986, 1987 Dave Taylor
  1371. X *             Copyright (c) 1988, 1989 USENET Community Trust
  1372. X *******************************************************************************
  1373. X * Bug reports, patches, comments, suggestions should be sent to:
  1374. X *
  1375. X *    Syd Weinstein, Elm Coordinator
  1376. X *    elm@dsinc.UUCP            dsinc!elm
  1377. X *
  1378. X *******************************************************************************
  1379. X * $Log:    save_opts.h,v $
  1380. X * Revision 2.9  89/03/25  21:45:33  syd
  1381. X * Initial 2.2 Release checkin
  1382. X * 
  1383. X *
  1384. X ******************************************************************************/
  1385. X
  1386. X/** Some crazy includes for the save-opts part of the Elm program!
  1387. X
  1388. X**/
  1389. X
  1390. X#define ALTERNATIVES        0
  1391. X#define ALWAYSDELETE        1
  1392. X#define ALWAYSKEEP        2
  1393. X#define ALWAYSSTORE        3
  1394. X#define ARROW            4
  1395. X#define ASK            5
  1396. X#define ASKCC            6
  1397. X#define AUTOCOPY        7
  1398. X#define BOUNCEBACK        8
  1399. X#define CALENDAR        9
  1400. X#define COPY            10
  1401. X#define EDITOR            11
  1402. X#define ESCAPECHAR        12
  1403. X#define FORMS            13
  1404. X#define FULLNAME        14
  1405. X#define KEEPEMPTY        15
  1406. X#define KEYPAD            16
  1407. X#define LOCALSIGNATURE        17
  1408. X#define MAILDIR            18
  1409. X#define MENU            19
  1410. X#define MOVEPAGE        20
  1411. X#define NAMES            21
  1412. X#define NOHEADER        22
  1413. X#define PAGER            23
  1414. X#define POINTNEW        24
  1415. X#define PREFIX            25
  1416. X#define PRINT            26
  1417. X#define PROMPTAFTER        27
  1418. X#define RECEIVEDMAIL        28
  1419. X#define REMOTESIGNATURE        29
  1420. X#define RESOLVE            30
  1421. X#define SAVENAME        31
  1422. X#define SENTMAIL        32
  1423. X#define SHELL            33
  1424. X#define SIGNATURE        34
  1425. X#define SOFTKEYS        35
  1426. X#define SORTBY            36
  1427. X#define TIMEOUT            37
  1428. X#define TITLES            38
  1429. X#define USERLEVEL        39
  1430. X#define WARNINGS        40
  1431. X#define WEED            41
  1432. X#define WEEDOUT            42
  1433. X
  1434. X#define NUMBER_OF_SAVEABLE_OPTIONS    WEEDOUT+1
  1435. X
  1436. Xstruct save_info_recs { 
  1437. X    char     name[NLEN];     /* name of instruction */
  1438. X    long     offset;        /* offset into elmrc-info file */
  1439. X    } save_info[NUMBER_OF_SAVEABLE_OPTIONS] = 
  1440. X{
  1441. X { "alternatives", -1L }, 
  1442. X { "alwaysdelete", -1L },     
  1443. X { "alwayskeep", -1L },
  1444. X { "alwaysstore", -1L },
  1445. X { "arrow", -1L},         
  1446. X { "ask", -1L },
  1447. X { "askcc", -1L },
  1448. X { "autocopy", -1L },          
  1449. X { "bounceback", -1L },
  1450. X { "calendar", -1L },       
  1451. X { "copy", -1L },              
  1452. X { "editor", -1L },
  1453. X { "escape", -1L },       
  1454. X { "forms", -1L },             
  1455. X { "fullname", -1L },
  1456. X { "keepempty", -1L },       
  1457. X { "keypad", -1L },       
  1458. X { "localsignature", -1L },    
  1459. X { "maildir", -1L },       
  1460. X { "menu", -1L },         
  1461. X { "movepage", -1L }, 
  1462. X { "names", -1L },        
  1463. X { "noheader", -1L },         
  1464. X { "pager", -1L }, 
  1465. X { "pointnew", -1L},      
  1466. X { "prefix", -1L },           
  1467. X { "print", -1L }, 
  1468. X { "promptafter", -1L }, 
  1469. X { "receivedmail", -1L }, 
  1470. X { "remotesignature",-1L},
  1471. X { "resolve", -1L },           
  1472. X { "savename", -1L },     
  1473. X { "sentmail", -1L }, 
  1474. X { "shell", -1L },             
  1475. X { "signature", -1L },
  1476. X { "softkeys", -1L },      
  1477. X { "sortby", -1L },         
  1478. X { "timeout", -1L },
  1479. X { "titles", -1L },       
  1480. X { "userlevel", -1L },     
  1481. X { "warnings", -1L },
  1482. X { "weed", -1L },         
  1483. X { "weedout", -1L },        
  1484. X};
  1485. SHAR_EOF
  1486. chmod 0444 hdrs/save_opts.h || echo "restore of hdrs/save_opts.h fails"
  1487. echo "x - extracting hdrs/shortname.1 (Text)"
  1488. sed 's/^X//' << 'SHAR_EOF' > hdrs/shortname.1 &&
  1489. XNOTE: This file is obsolete and is not being kept uptodate.  It is provided
  1490. Xfor reference only.
  1491. X
  1492. XSyd Weinstein
  1493. XElm Coordinator
  1494. X
  1495. XFrom sun!convex!ndmce!jlsoft!marquez@hplabs.HP.COM  Tue Mar 24 14:55:53 1987
  1496. XReceived: from hplabsc (hplabsc.hpl.hp.com) by hpldat ; Tue, 24 Mar 87 14:55:53 pst
  1497. XReturn-Path: <sun!convex!ndmce!jlsoft!marquez@hplabs.HP.COM>
  1498. XReceived: from hplabs.HP.COM by hplabsc ; Tue, 24 Mar 87 14:54:57 pst
  1499. XReceived: from Sun.COM by hplabs.HP.COM with TCP ; Tue, 24 Mar 87 14:52:11 pst
  1500. XReceived: from sun.Sun.COM by Sun.COM (3.2/SMI-3.2)
  1501. X    id AA01637; Tue, 24 Mar 87 14:46:13 PST
  1502. XReceived: by sun.Sun.COM (3.2/SMI-3.2)
  1503. X    id AA00003; Tue, 24 Mar 87 14:50:23 PST
  1504. XFrom: sun!convex!ndmce!jlsoft!marquez@hplabs.HP.COM
  1505. XMessage-Id: <8703242250.AA00003@sun.Sun.COM>
  1506. SHAR_EOF
  1507. echo "End of part 9"
  1508. echo "File hdrs/shortname.1 is continued in part 10"
  1509. echo "10" > s2_seq_.tmp
  1510. exit 0
  1511.  
  1512.