home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume22 / elm2.3 / part10 < prev    next >
Text File  |  1990-06-07  |  51KB  |  1,557 lines

  1. Subject:  v22i069:  ELM mail syste, release 2.3, Part10/26
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 97a7a5a4 e879e689 c8ffbea8 38f183b1
  5.  
  6. Submitted-by: Syd Weinstein <syd@dsinc.dsi.com>
  7. Posting-number: Volume 22, Issue 69
  8. Archive-name: elm2.3/part10
  9.  
  10. #!/bin/sh
  11. # this is part 10 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file hdrs/defs.h continued
  14. #
  15. CurArch=10
  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 hdrs/defs.h"
  26. sed 's/^X//' << 'SHAR_EOF' >> hdrs/defs.h
  27. X/** a few for the usage of function keys... **/
  28. X
  29. X#define f1    1
  30. X#define f2    2
  31. X#define f3    3
  32. X#define f4    4
  33. X#define f5    5
  34. X#define f6    6
  35. X#define f7    7
  36. X#define f8    8
  37. X
  38. X#define MAIN    0
  39. X#define ALIAS   1
  40. X#define YESNO    2
  41. X#define CHANGE  3
  42. X#define READ    4
  43. X
  44. X#define MAIN_HELP    0
  45. X#define OPTIONS_HELP 1
  46. X#define ALIAS_HELP   2
  47. X#define PAGER_HELP   3
  48. X
  49. X/** types of folders **/
  50. X#define NO_NAME        0        /* variable contains no file name */
  51. X#define NON_SPOOL    1        /* mailfile not in mailhome */
  52. X#define SPOOL        2        /* mailfile in mailhome */
  53. X
  54. X/* the following is true if the current mailfile is the user's spool file*/
  55. X#define USERS_SPOOL    (strcmp(cur_folder, defaultfile) == 0)
  56. X
  57. X/** some possible sort styles... **/
  58. X
  59. X#define REVERSE        -        /* for reverse sorting           */
  60. X#define SENT_DATE    1        /* the date message was sent     */
  61. X#define RECEIVED_DATE    2        /* the date message was received */
  62. X#define SENDER        3        /* the name/address of sender    */
  63. X#define SIZE        4        /* the # of lines of the message */
  64. X#define SUBJECT        5        /* the subject of the message    */
  65. X#define STATUS        6        /* the status (deleted, etc)     */
  66. X#define MAILBOX_ORDER    7        /* the order it is in the file   */
  67. X
  68. X/* some stuff for our own malloc call - pmalloc */
  69. X
  70. X#define PMALLOC_THRESHOLD    256    /* if greater, then just use malloc */
  71. X#define PMALLOC_BUFFER_SIZE    2048    /* internal [memory] buffer size... */
  72. X
  73. X/** the following macro is as suggested by Larry McVoy.  Thanks! **/
  74. X
  75. X# ifdef DEBUG
  76. X#  define   dprint(n,x)        {                 \
  77. X                   if (debug >= n)  {        \
  78. X                     fprintf x ;         \
  79. X                     fflush(debugfile);         \
  80. X                   }                \
  81. X                }
  82. X# else
  83. X#  define   dprint(n,x)
  84. X# endif
  85. X
  86. X/* some random structs... */
  87. X
  88. Xstruct date_rec {
  89. X    int  month;        /** this record stores a **/
  90. X    int  day;        /**   specific date and  **/
  91. X    int  year;        /**     time...         **/
  92. X    int  hour;
  93. X    int  minute;
  94. X       };
  95. X
  96. Xstruct header_rec {
  97. X    int  lines;        /** # of lines in the message  **/
  98. X    int  status;        /** Urgent, Deleted, Expired?  **/
  99. X    int  index_number;    /** relative loc in file...    **/
  100. X    int  encrypted;        /** whether msg has encryption **/
  101. X    int  exit_disposition;    /** whether to keep, store, delete **/
  102. X    int  status_chgd;    /** whether became read or old, etc. **/
  103. X    long offset;        /** offset in bytes of message **/
  104. X    struct date_rec received; /** when elm received here   **/
  105. X    char from[STRING];    /** who sent the message?      **/
  106. X    char to[STRING];    /** who it was sent to           **/
  107. X    char messageid[STRING];    /** the Message-ID: value      **/
  108. X    char dayname[8];    /**  when the                  **/
  109. X    char month[10];        /**        message             **/
  110. X    char day[3];        /**          was            **/
  111. X    char year[5];        /**            sent            **/
  112. X    char time[NLEN];    /**              to you!       **/
  113. X    char time_zone[12];    /**                incl. tz    */
  114. X    long time_sent;        /** gmt when sent for sorting  **/
  115. X    char subject[STRING];   /** The subject of the mail    **/
  116. X    char mailx_status[WLEN];/** mailx status flags (RO...) **/
  117. X       };
  118. X
  119. Xstruct alias_rec {
  120. X    char   name[NLEN];    /* alias name                  */
  121. X    long   byte;        /* offset into data file for address */
  122. X       };
  123. X
  124. Xstruct lsys_rec {
  125. X    char   name[NLEN];    /* name of machine connected to      */
  126. X    struct lsys_rec *next;    /* linked list pointer to next       */
  127. X       };
  128. X
  129. Xstruct addr_rec {
  130. X     char   address[NLEN];    /* machine!user you get mail as      */
  131. X     struct addr_rec *next;    /* linked list pointer to next       */
  132. X    };
  133. X
  134. X#ifdef SHORTNAMES    /* map long names to shorter ones */
  135. X# include <shortname.h>
  136. X#endif
  137. X
  138. X/** Let's make sure that we're not going to have any annoying problems with 
  139. X    int pointer sizes versus char pointer sizes by guaranteeing that every-
  140. X    thing vital is predefined... (Thanks go to Detlev Droege for this one)
  141. X**/
  142. X
  143. X#ifdef STRINGS
  144. X#  include <strings.h>
  145. X#else
  146. X#  include <string.h>
  147. X#endif
  148. X
  149. X/*
  150. X * Macros for network/external number representation conversion.
  151. X */
  152. X#ifdef NETWORK_ORDER
  153. Xunsigned short    ntohs(), htons();
  154. Xunsigned long    ntohl(), htonl();
  155. X#else
  156. X#define    ntohl(x)    (x)
  157. X#define    ntohs(x)    (x)
  158. X#define    htonl(x)    (x)
  159. X#define    htons(x)    (x)
  160. X#endif
  161. X
  162. Xchar *argv_zero();
  163. Xchar *bounce_off_remote();
  164. Xchar *ctime();
  165. Xchar *error_description();
  166. Xchar *error_name();
  167. Xchar *error_number();
  168. Xchar *expand_address();
  169. Xchar *expand_domain();
  170. Xchar *expand_group();
  171. Xchar *expand_logname();
  172. Xchar *expand_system();
  173. Xchar *find_path_to();
  174. Xchar *format_long();
  175. Xchar *get_alias_address();
  176. Xchar *get_arpa_date();
  177. Xchar *get_ctime_date();
  178. Xchar *get_date();
  179. Xchar *get_token();
  180. Xchar *getenv();
  181. Xchar *getlogin();
  182. Xchar *level_name();
  183. Xchar *match_and_expand_domain();
  184. Xchar *shift_lower();
  185. Xchar *strip_commas();
  186. Xchar *strip_parens();
  187. Xchar *strpbrk();
  188. Xchar *strtok();
  189. Xchar *tail_of_string();
  190. Xchar *tgetstr();
  191. Xchar *pmalloc();
  192. X
  193. Xlong lseek();
  194. Xlong times();
  195. Xlong ulimit();
  196. SHAR_EOF
  197. echo "File hdrs/defs.h is complete"
  198. chmod 0444 hdrs/defs.h || echo "restore of hdrs/defs.h fails"
  199. echo "x - extracting hdrs/elm.h (Text)"
  200. sed 's/^X//' << 'SHAR_EOF' > hdrs/elm.h &&
  201. X
  202. X/* $Id: elm.h,v 4.1 90/04/28 22:42:08 syd Exp $ */
  203. X
  204. X/*******************************************************************************
  205. X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  206. X *
  207. X *             Copyright (c) 1986, 1987 Dave Taylor
  208. X *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  209. X *******************************************************************************
  210. X * Bug reports, patches, comments, suggestions should be sent to:
  211. X *
  212. X *    Syd Weinstein, Elm Coordinator
  213. X *    elm@DSI.COM            dsinc!elm
  214. X *
  215. X *******************************************************************************
  216. X * $Log:    elm.h,v $
  217. X * Revision 4.1  90/04/28  22:42:08  syd
  218. X * checkin of Elm 2.3 as of Release PL0
  219. X * 
  220. X *
  221. X ******************************************************************************/
  222. X
  223. X/**  Main header file for ELM mail system.  **/
  224. X
  225. X
  226. X#include <stdio.h>
  227. X#include <fcntl.h>
  228. X#include <errno.h>
  229. X
  230. X#include "../hdrs/curses.h"
  231. X#include "../hdrs/defs.h"
  232. X
  233. X#ifdef    BSD
  234. X#include <setjmp.h>
  235. X#endif
  236. X
  237. X/******** static character string containing the version number  *******/
  238. X
  239. Xstatic char ident[] = { WHAT_STRING };
  240. X
  241. X/******** and another string for the copyright notice            ********/
  242. X
  243. Xstatic char copyright[] = { 
  244. X        "@(#)          (C) Copyright 1986, 1987, Dave Taylor\n@(#)          (C) Copyright 1988, 1989, 1990, The Usenet Community Trust\n" };
  245. X
  246. X/******** global variables accessable by all pieces of the program *******/
  247. X
  248. Xint check_size = 0;        /* don't start mailer if no mail */
  249. Xint current = 0;        /* current message number  */
  250. Xint header_page = 0;         /* current header page     */
  251. Xint last_header_page = -1;         /* last header page        */
  252. Xint message_count = 0;        /* max message number      */
  253. Xint headers_per_page;        /* number of headers/page  */
  254. Xint original_umask = 0;        /* original umask, for restore before subshell */
  255. Xint sendmail_verbose = 0;       /* Extended mail debugging */
  256. Xchar cur_folder[SLEN];          /* name of current folder */
  257. Xchar cur_tempfolder[SLEN];      /* name of temp folder open for a mailbox */
  258. Xchar defaultfile[SLEN];         /* name of default folder */
  259. Xchar temp_dir[SLEN] = {0};      /* name of temp directory */
  260. Xchar hostname[SLEN];            /* name of machine we're on*/
  261. Xchar hostdomain[SLEN];          /* name of domain we're in */
  262. Xchar hostfullname[SLEN];        /* name of FQDN we're in */
  263. Xchar username[SLEN];            /* return address name!    */
  264. Xchar full_username[SLEN];       /* Full username - gecos   */
  265. Xchar home[SLEN];                /* home directory of user  */
  266. Xchar folders[SLEN];             /* folder home directory   */
  267. Xchar raw_folders[SLEN];         /* unexpanded folder home directory   */
  268. Xchar recvd_mail[SLEN];          /* folder for storing received mail     */
  269. Xchar raw_recvdmail[SLEN];       /* unexpanded recvd_mail name */
  270. Xchar editor[SLEN];              /* editor for outgoing mail*/
  271. Xchar raw_editor[SLEN];          /* unexpanded editor for outgoing mail*/
  272. Xchar alternative_editor[SLEN];  /* alternative editor...   */
  273. Xchar printout[SLEN];            /* how to print messages   */
  274. Xchar raw_printout[SLEN];        /* unexpanded how to print messages   */
  275. Xchar sent_mail[SLEN];           /* name of file to save copies to */
  276. Xchar raw_sentmail[SLEN];        /* unexpanded name of file to save to */
  277. Xchar calendar_file[SLEN];       /* name of file for clndr  */
  278. Xchar raw_calendar_file[SLEN];   /* unexpanded name of file for clndr  */
  279. Xchar attribution[SLEN];         /* attribution string for replies     */
  280. Xchar prefixchars[SLEN] = "> ";    /* prefix char(s) for msgs */
  281. Xchar shell[SLEN];               /* current system shell    */
  282. Xchar raw_shell[SLEN];           /* unexpanded current system shell    */
  283. Xchar pager[SLEN];               /* what pager to use       */
  284. Xchar raw_pager[SLEN];           /* unexpanded what pager to use       */
  285. Xchar batch_subject[SLEN];       /* subject buffer for batchmail */
  286. Xchar local_signature[SLEN];     /* local msg signature file     */
  287. Xchar raw_local_signature[SLEN]; /* unexpanded local msg signature file     */
  288. Xchar remote_signature[SLEN];    /* remote msg signature file    */
  289. Xchar raw_remote_signature[SLEN];/* unexpanded remote msg signature file    */
  290. Xchar version_buff[SLEN];        /* version buffer */
  291. X
  292. Xchar backspace,            /* the current backspace char */
  293. X     escape_char = TILDE_ESCAPE,/* '~' or something else..    */
  294. X     kill_line;            /* the current kill-line char */
  295. X
  296. Xchar up[SHORT], down[SHORT],    /* cursor control seq's    */
  297. X     left[SHORT], right[SHORT];
  298. Xint  cursor_control = FALSE;    /* cursor control avail?   */
  299. X
  300. Xchar start_highlight[SHORT],
  301. X     end_highlight[SHORT];    /* stand out mode...       */
  302. X
  303. Xint  has_highlighting = FALSE;    /* highlighting available? */
  304. X
  305. Xchar *weedlist[MAX_IN_WEEDLIST];
  306. Xint  weedcount;
  307. X
  308. Xint allow_forms = NO;        /* flag: are AT&T Mail forms okay?  */
  309. Xint mini_menu = 1;        /* flag: menu specified?        */
  310. Xint prompt_after_pager = 1;    /* flag: prompt after pager exits   */
  311. Xint folder_type = 0;        /* flag: type of folder            */
  312. Xint auto_copy = 0;        /* flag: automatically copy source? */
  313. Xint filter = 1;            /* flag: weed out header lines?        */
  314. Xint resolve_mode = 1;        /* flag: delete saved mail?        */
  315. Xint auto_cc = 0;        /* flag: mail copy to user?        */
  316. Xint noheader = 1;        /* flag: copy + header to file?     */
  317. Xint title_messages = 1;        /* flag: title message display?     */
  318. Xint forwarding = 0;        /* flag: are we forwarding the msg? */
  319. Xint hp_terminal = 0;        /* flag: are we on HP term?        */
  320. Xint hp_softkeys = 0;        /* flag: are there softkeys?        */
  321. Xint save_by_name = 1;        /* flag: save mail by login name?   */
  322. Xint force_name = 0;        /* flag: save by name forced?        */
  323. Xint mail_only = 0;        /* flag: send mail then leave?      */
  324. Xint check_only = 0;        /* flag: check aliases then leave?  */
  325. Xint batch_only = 0;        /* flag: send without prompting?    */
  326. Xint move_when_paged = 0;    /* flag: move when '+' or '-' used? */
  327. Xint point_to_new = 1;        /* flag: start pointing at new msg? */
  328. Xint bounceback = 0;        /* flag: bounce copy off remote?    */
  329. Xint always_keep = 1;        /* flag: always keep unread msgs?   */
  330. Xint always_store = 0;        /* flag: always store read msgs?    */
  331. Xint always_del = 0;        /* flag: always delete marked msgs? */
  332. Xint arrow_cursor = 0;        /* flag: use "->" cursor regardless?*/
  333. Xint debug = 0;             /* flag: default is no debug!       */
  334. Xint warnings = 1;        /* flag: output connection warnings?*/
  335. Xint user_level = 0;        /* flag: how good is the user?      */
  336. Xint selected = 0;        /* flag: used for select stuff      */
  337. Xint names_only = 1;        /* flag: display user names only?   */
  338. Xint question_me = 1;        /* flag: ask questions as we leave? */
  339. Xint keep_empty_files = 0;    /* flag: leave empty folder files? */
  340. Xint clear_pages = 0;        /* flag: act like "page" (more -c)? */
  341. Xint prompt_for_cc = 1;        /* flag: ask user for "cc:" value?  */
  342. Xint sig_dashes = 1;        /* flag: include dashes above sigs? */
  343. X
  344. Xint sortby = REVERSE SENT_DATE;    /* how to sort incoming mail...     */
  345. X
  346. Xlong timeout = 600L;        /* timeout (secs) on main prompt    */
  347. X
  348. X/** set up some default values for a 'typical' terminal *snicker* **/
  349. X
  350. Xint LINES=23;            /** lines per screen      **/
  351. Xint COLUMNS=80;            /** columns per page      **/
  352. X
  353. Xlong size_of_pathfd;        /** size of pathfile, 0 if none **/
  354. X
  355. XFILE *mailfile;            /* current folder        */
  356. XFILE *debugfile;        /* file for debug output    */
  357. XFILE *pathfd;            /* path alias file          */
  358. XFILE *domainfd;            /* domain file            */
  359. X
  360. Xlong mailfile_size;        /* size of current mailfile */
  361. X
  362. Xint   max_headers;        /* number of headers allocated */
  363. X
  364. Xstruct header_rec **headers;    /* array of header structure pointers */
  365. X
  366. Xstruct alias_rec user_hash_table[MAX_UALIASES];
  367. Xstruct alias_rec system_hash_table[MAX_SALIASES];
  368. X
  369. Xstruct lsys_rec *talk_to_sys = NULL; /* what machines do we talk to? */
  370. X
  371. Xstruct addr_rec *alternative_addresses;    /* how else do we get mail? */
  372. X
  373. Xint system_data = -1;        /* fileno of system data file */
  374. Xint user_data = -1;        /* fileno of user data file   */
  375. X
  376. Xint userid;            /* uid for current user          */
  377. Xint groupid;            /* groupid for current user   */
  378. X
  379. X#ifdef    BSD
  380. Xjmp_buf GetPromptBuf;        /* setjmp buffer */
  381. Xint InGetPrompt;        /* set if in GetPrompt() in read() */
  382. X#endif
  383. SHAR_EOF
  384. chmod 0444 hdrs/elm.h || echo "restore of hdrs/elm.h fails"
  385. echo "x - extracting hdrs/filter.h (Text)"
  386. sed 's/^X//' << 'SHAR_EOF' > hdrs/filter.h &&
  387. X
  388. X/* $Id: filter.h,v 4.1 90/04/28 22:42:09 syd Exp $ */
  389. X
  390. X/*******************************************************************************
  391. X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  392. X *
  393. X *             Copyright (c) 1986, 1987 Dave Taylor
  394. X *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  395. X *******************************************************************************
  396. X * Bug reports, patches, comments, suggestions should be sent to:
  397. X *
  398. X *    Syd Weinstein, Elm Coordinator
  399. X *    elm@DSI.COM            dsinc!elm
  400. X *
  401. X *******************************************************************************
  402. X * $Log:    filter.h,v $
  403. X * Revision 4.1  90/04/28  22:42:09  syd
  404. X * checkin of Elm 2.3 as of Release PL0
  405. X * 
  406. X *
  407. X ******************************************************************************/
  408. X
  409. X/** Headers for the filter program.
  410. X
  411. X**/
  412. X
  413. X#ifdef   BSD
  414. X# undef  tolower
  415. X#endif
  416. X
  417. X/** define a few handy macros for later use... **/
  418. X
  419. X#define  the_same(a,b)    (strncmp(a,b,strlen(b)) == 0)
  420. X
  421. X#define relationname(x)  (x == 1?"<=":x==2?"<":x==3?">=":x==4?">":x==5?"!=":"=")
  422. X
  423. X#define quoteit(x)     (x == LINES? "" : "\"")
  424. X
  425. X#define remove_return(s)    { if (s[strlen(s)-1] == '\n') \
  426. X                    s[strlen(s)-1] = '\0';    \
  427. X                   }
  428. X
  429. X/** some of the files we'll be using, where they are, and so on... **/
  430. X
  431. X#define  filter_temp    "/tmp/filter"
  432. X#define  filterfile    ".elm/filter-rules"
  433. X#define  filterlog    ".elm/filterlog"
  434. X#define  filtersum    ".elm/filtersum"
  435. X
  436. X#define  EMERGENCY_MAILBOX    "EMERGENCY_MBOX"
  437. X#define  EMERG_MBOX        "MBOX.EMERGENCY"
  438. X
  439. X/** and now the hardwired constraint of the program.. **/
  440. X
  441. X#define  MAXRULES    25        /* can't have more den dis, boss! */
  442. X
  443. X/** some random defines for mnemonic stuff in the program... **/
  444. X
  445. X#ifdef SUBJECT
  446. X# undef SUBJECT
  447. X#endif
  448. X
  449. X#define  TO        1
  450. X#define  FROM        2
  451. X#define  LINES        3
  452. X#define  SUBJECT    4
  453. X#define  CONTAINS    5
  454. X#define  ALWAYS        6
  455. X
  456. X#define  DELETE_MSG     7
  457. X#define  SAVE        8
  458. X#define  SAVECC        9
  459. X#define  FORWARD    10
  460. X#define  LEAVE        11
  461. X#define  EXEC        12
  462. X
  463. X#define  FAILED_SAVE    20
  464. X
  465. X/** Some conditionals... **/
  466. X
  467. X#define LE        1
  468. X#define LT        2
  469. X#define GE        3
  470. X#define GT        4
  471. X#define NE        5
  472. X#define EQ        6
  473. X
  474. X/** A funky way to open a file using open() to avoid file locking hassles **/
  475. X
  476. X#define  FOLDERMODE    O_WRONLY | O_APPEND | O_CREAT | O_SYNCIO
  477. X
  478. X/** cheap but easy way to have two files share the same #include file **/
  479. X
  480. X#ifdef MAIN_ROUTINE
  481. X
  482. Xchar home[SLEN],                /* the users home directory */
  483. X     hostname[SLEN],            /* the machine name...      */
  484. X     username[SLEN];            /* the users login name...  */
  485. X
  486. Xchar to[VERY_LONG_STRING], 
  487. X     from[LONG_STRING], 
  488. X     subject[LONG_STRING];        /* from current message     */
  489. X
  490. XFILE *outfd;
  491. Xchar outfname[SLEN];
  492. X
  493. Xint  total_rules = 0,                /* how many rules to check  */
  494. X     show_only = FALSE,                /* just for show?           */
  495. X     long_summary = FALSE,            /* what sorta summary??     */
  496. X     verbose   = FALSE,                /* spit out lots of stuff   */
  497. X     lines     = 0,                /* lines in message..       */
  498. X     clear_logs = FALSE,            /* clear files after sum?   */
  499. X     already_been_forwarded = FALSE,        /* has this been filtered?  */
  500. X     log_actions_only = FALSE,            /* log actions | everything */
  501. X     printing_rules = FALSE,            /* are we just using '-r'?  */
  502. X     rule_choosen;                /* which one we choose      */
  503. X
  504. X#else
  505. X
  506. Xextern char home[SLEN],                /* the users home directory */
  507. X            hostname[SLEN],            /* the machine name...      */
  508. X            username[SLEN];            /* the users login name...  */
  509. X
  510. Xextern char to[VERY_LONG_STRING], 
  511. X            from[LONG_STRING], 
  512. X            subject[LONG_STRING];        /* from current message     */
  513. X
  514. Xextern FILE *outfd;
  515. Xextern char outfname[SLEN];
  516. X
  517. Xextern int total_rules,                /* how many rules to check  */
  518. X           show_only,                /* just for show?           */
  519. X           long_summary,            /* what sorta summary??     */
  520. X           verbose,                /* spit out lots of stuff   */
  521. X           lines,                /* lines in message..       */
  522. X           clear_logs,                    /* clear files after sum?   */
  523. X       already_been_forwarded,        /* has this been filtered?  */
  524. X           log_actions_only,            /* log actions | everything */
  525. X           printing_rules,            /* are we just using '-r'?  */
  526. X           rule_choosen;            /* which one we choose      */
  527. X#endif
  528. X
  529. X/** and our ruleset record structure... **/
  530. X
  531. Xstruct condition_rec {
  532. X    int     matchwhat;            /* type of 'if' clause      */
  533. X    int     relation;            /* type of match (eq, etc)  */
  534. X    char    argument1[SLEN];        /* match against this       */
  535. X    struct  condition_rec  *next;        /* next condition...        */
  536. X      };
  537. X
  538. Xstruct ruleset_record {
  539. X    char      printable[SLEN];        /* straight from file...    */
  540. X    struct  condition_rec  *condition;
  541. X    int     action;                /* what action to take      */
  542. X    char    argument2[SLEN];        /* argument for action      */
  543. X      };
  544. X
  545. X#ifdef MAIN_ROUTINE
  546. X  struct ruleset_record rules[MAXRULES];
  547. X#else
  548. X  extern struct ruleset_record rules[MAXRULES];
  549. X#endif
  550. X
  551. X/** finally let's keep LINT happy with the return values of all these pups! ***/
  552. X
  553. Xchar *itoa();
  554. X
  555. X#ifdef    _POSIX_SOURCE        /*{_POSIX_SOURCE*/
  556. X#include <string.h>
  557. X#include <unistd.h>
  558. X#include <stdlib.h>
  559. X#else                /*}_POSIX_SOURCE{*/
  560. Xunsigned short getuid();
  561. X
  562. Xunsigned long sleep();
  563. X
  564. Xchar *malloc(), *strcpy(), *strcat();
  565. X
  566. Xvoid    exit();
  567. X
  568. X#ifdef BSD
  569. X    
  570. X  FILE *popen();
  571. X
  572. X#ifdef MAIN_ROUTINE
  573. X  char  _vbuf[5*BUFSIZ];              /* space for file buffering */
  574. X#else
  575. X  extern char  _vbuf[5*BUFSIZ];        /* space for file buffering */
  576. X#endif
  577. X
  578. X#ifndef _IOFBF
  579. X# define _IOFBF        0        /* doesn't matter - ignored */
  580. X#endif
  581. X
  582. X# define setvbuf(fd,a,b,c)    setbuffer(fd, _vbuf, 5*BUFSIZ)
  583. X
  584. X#endif
  585. X#endif                /*}_POSIX_SOURCE*/
  586. SHAR_EOF
  587. chmod 0444 hdrs/filter.h || echo "restore of hdrs/filter.h fails"
  588. echo "x - extracting hdrs/headers.h (Text)"
  589. sed 's/^X//' << 'SHAR_EOF' > hdrs/headers.h &&
  590. X
  591. X/* $Id: headers.h,v 4.1 90/04/28 22:42:11 syd Exp $ */
  592. X
  593. X/*******************************************************************************
  594. X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  595. X *
  596. X *             Copyright (c) 1986, 1987 Dave Taylor
  597. X *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  598. X *******************************************************************************
  599. X * Bug reports, patches, comments, suggestions should be sent to:
  600. X *
  601. X *    Syd Weinstein, Elm Coordinator
  602. X *    elm@DSI.COM            dsinc!elm
  603. X *
  604. X *******************************************************************************
  605. X * $Log:    headers.h,v $
  606. X * Revision 4.1  90/04/28  22:42:11  syd
  607. X * checkin of Elm 2.3 as of Release PL0
  608. X * 
  609. X *
  610. X ******************************************************************************/
  611. X
  612. X/**  This is the header file for ELM mail system.  **/
  613. X
  614. X
  615. X#include <stdio.h>
  616. X#include <fcntl.h>
  617. X
  618. X#include "curses.h"
  619. X#include "defs.h"
  620. X
  621. X#ifdef    BSD
  622. X#include <setjmp.h>
  623. X#endif
  624. X
  625. X#ifndef       clearerr
  626. X#define       clearerr(p)     (void)((p)->_flag &= ~(_IOERR|_IOEOF))
  627. X#endif
  628. X
  629. X/******** global variables accessable by all pieces of the program *******/
  630. X
  631. Xextern int check_size;        /* don't start mailer if no mail */
  632. Xextern int current;        /* current message number  */
  633. Xextern int header_page;         /* current header page     */
  634. Xextern int last_header_page;    /* last header page        */
  635. Xextern int message_count;    /* max message number      */
  636. Xextern int headers_per_page;    /* number of headers/page  */
  637. Xextern int original_umask;    /* original umask, for restore before subshell */
  638. Xextern int sendmail_verbose;    /* Allow extended debugging on sendmail */
  639. Xextern char cur_folder[SLEN];    /* name of current folder */
  640. Xextern char cur_tempfolder[SLEN]; /* name of temp folder open for a mailbox */
  641. Xextern char defaultfile[SLEN];    /* name of default folder */
  642. Xextern char temp_dir[SLEN];     /* name of temp directory */
  643. Xextern char hostname[SLEN];    /* name of machine we're on*/
  644. Xextern char hostdomain[SLEN];    /* name of domain we're in */
  645. Xextern char hostfullname[SLEN]; /* name of FQDN we're in */
  646. Xextern char username[SLEN];    /* return address name!    */
  647. Xextern char full_username[SLEN];/* Full username - gecos   */
  648. Xextern char home[SLEN];        /* home directory of user  */
  649. Xextern char folders[SLEN];    /* folder home directory   */
  650. Xextern char raw_folders[SLEN];    /* unexpanded folder home directory   */
  651. Xextern char recvd_mail[SLEN];    /* folder for storing received mail    */
  652. Xextern char raw_recvdmail[SLEN];/* unexpanded recvd_mail name */
  653. Xextern char editor[SLEN];    /* default editor for mail */
  654. Xextern char raw_editor[SLEN];    /* unexpanded default editor for mail */
  655. Xextern char alternative_editor[SLEN];/* the 'other' editor */
  656. Xextern char printout[SLEN];    /* how to print messages   */
  657. Xextern char raw_printout[SLEN];    /* unexpanded how to print messages   */
  658. Xextern char sent_mail[SLEN];    /* name of file to save copies to */
  659. Xextern char raw_sentmail[SLEN];    /* unexpanded name of file to save to */
  660. Xextern char calendar_file[SLEN];/* name of file for clndr  */
  661. Xextern char raw_calendar_file[SLEN];/* unexpanded name of file for clndr  */
  662. Xextern char attribution[SLEN];  /* attribution string for replies     */
  663. Xextern char prefixchars[SLEN];    /* prefix char(s) for msgs */
  664. Xextern char shell[SLEN];    /* default system shell    */
  665. Xextern char raw_shell[SLEN];    /* unexpanded default system shell    */
  666. Xextern char pager[SLEN];    /* what pager to use...    */
  667. Xextern char raw_pager[SLEN];    /* unexpanded what pager to use...    */
  668. Xextern char batch_subject[SLEN];/* subject buffer for batchmail */
  669. Xextern char local_signature[SLEN];/* local msg signature file   */
  670. Xextern char raw_local_signature[SLEN];/* unexpanded local msg signature file */
  671. Xextern char remote_signature[SLEN];/* remote msg signature file */
  672. Xextern char raw_remote_signature[SLEN];/* unexpanded remote msg signature file*/
  673. X
  674. Xextern char backspace,        /* the current backspace char  */
  675. X        escape_char,    /* '~' or something else...    */
  676. X        kill_line;        /* the current kill_line char  */
  677. X
  678. Xextern char up[SHORT], 
  679. X        down[SHORT],
  680. X        left[SHORT],
  681. X        right[SHORT];    /* cursor control seq's    */
  682. Xextern int  cursor_control;    /* cursor control avail?   */
  683. X
  684. Xextern char start_highlight[SHORT],
  685. X        end_highlight[SHORT];  /* standout mode... */
  686. X
  687. Xextern int  has_highlighting;    /* highlighting available? */
  688. X
  689. X/** the following two are for arbitrary weedout lists.. **/
  690. X
  691. Xextern char *weedlist[MAX_IN_WEEDLIST];
  692. Xextern int  weedcount;        /* how many headers to check?        */
  693. X
  694. Xextern int  allow_forms;    /* flag: are AT&T Mail forms okay?    */
  695. Xextern int  prompt_after_pager;    /* flag: prompt after pager exits     */
  696. Xextern int  mini_menu;        /* flag: display menu?               */
  697. Xextern int  folder_type;    /* flag: type of folder              */
  698. Xextern int  auto_copy;        /* flag: auto copy source into reply? */
  699. Xextern int  filter;        /* flag: weed out header lines?          */
  700. Xextern int  resolve_mode;    /* flag: resolve before moving mode?  */
  701. Xextern int  auto_cc;        /* flag: mail copy to yourself?       */
  702. Xextern int  noheader;        /* flag: copy + header to file?       */
  703. Xextern int  title_messages;    /* flag: title message display?       */
  704. Xextern int  forwarding;        /* flag: are we forwarding the msg?   */
  705. Xextern int  hp_terminal;    /* flag: are we on an hp terminal?    */
  706. Xextern int  hp_softkeys;    /* flag: are there softkeys?          */
  707. Xextern int  save_by_name;      /* flag: save mail by login name?     */
  708. Xextern int  force_name;        /* flag: save by name forced?          */
  709. Xextern int  mail_only;        /* flag: send mail then leave?        */
  710. Xextern int  check_only;        /* flag: check aliases and leave?     */
  711. Xextern int  batch_only;        /* flag: send without prompting?      */
  712. Xextern int  move_when_paged;    /* flag: move when '+' or '-' used?   */
  713. Xextern int  point_to_new;    /* flag: start pointing at new msgs?  */
  714. Xextern int  bounceback;        /* flag: bounce copy off remote?      */
  715. Xextern int  always_keep;    /* flag: always keep unread msgs?     */
  716. Xextern int  always_store;    /* flag: always store read mail?      */
  717. Xextern int  always_del;        /* flag: always delete marked msgs?   */
  718. Xextern int  arrow_cursor;    /* flag: use "->" regardless?          */
  719. Xextern int  debug;        /* flag: debugging mode on?           */
  720. Xextern int  warnings;        /* flag: output connection warnings?  */
  721. Xextern int  user_level;        /* flag: how knowledgable is user?    */
  722. Xextern int  selected;        /* flag: used for select stuff        */
  723. Xextern int  names_only;        /* flag: display names but no addrs?  */
  724. Xextern int  question_me;    /* flag: ask questions as we leave?   */
  725. Xextern int  keep_empty_files;    /* flag: keep empty files??          */
  726. Xextern int  clear_pages;    /* flag: clear screen w/ builtin pgr? */
  727. Xextern int  prompt_for_cc;    /* flag: prompt user for 'cc' value?  */
  728. Xextern int  sig_dashes;        /* flag: put dashes above signature?  */
  729. X
  730. Xextern int  sortby;        /* how to sort folders          */
  731. X
  732. Xextern long timeout;        /* seconds for main level timeout     */
  733. X
  734. Xextern int LINES;        /** lines per screen    **/
  735. Xextern int COLUMNS;        /** columns per line    **/
  736. X
  737. Xextern long size_of_pathfd;    /** size of pathfile, 0 if none **/
  738. X
  739. Xextern FILE *mailfile;        /* current folder         */
  740. Xextern FILE *debugfile;        /* file for debut output    */
  741. Xextern FILE *pathfd;        /* path alias file          */
  742. Xextern FILE *domainfd;        /* domains file         */
  743. X
  744. Xextern long mailfile_size;    /* size of current mailfile */
  745. X
  746. Xextern int  max_headers;    /* number of headers currently allocated */
  747. X
  748. Xextern struct header_rec **headers; /* array of header structure pointers */
  749. X
  750. Xextern struct alias_rec user_hash_table  [MAX_UALIASES];
  751. Xextern struct alias_rec system_hash_table[MAX_SALIASES];
  752. X
  753. Xextern struct lsys_rec *talk_to_sys;    /* who do we talk to? */
  754. X
  755. Xextern struct addr_rec *alternative_addresses;    /* how else do we get mail? */
  756. X
  757. Xextern int system_data;        /* fileno of system data file */
  758. Xextern int user_data;        /* fileno of user data file   */
  759. X
  760. Xextern int userid;        /* uid for current user          */
  761. Xextern int groupid;        /* groupid for current user   */
  762. X
  763. X#ifdef    BSD
  764. Xextern jmp_buf GetPromptBuf;    /* setjmp buffer */
  765. Xextern int InGetPrompt;        /* set if in GetPrompt() in read() */
  766. X#endif
  767. SHAR_EOF
  768. chmod 0444 hdrs/headers.h || echo "restore of hdrs/headers.h fails"
  769. echo "x - extracting hdrs/patchlevel.h (Text)"
  770. sed 's/^X//' << 'SHAR_EOF' > hdrs/patchlevel.h &&
  771. X#define PATCHLEVEL 0
  772. SHAR_EOF
  773. chmod 0666 hdrs/patchlevel.h || echo "restore of hdrs/patchlevel.h fails"
  774. echo "x - extracting hdrs/save_opts.h (Text)"
  775. sed 's/^X//' << 'SHAR_EOF' > hdrs/save_opts.h &&
  776. X
  777. X/* @(#)$Id: save_opts.h,v 4.1 90/04/28 22:42:12 syd Exp $ */
  778. X
  779. X/*******************************************************************************
  780. X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  781. X *
  782. X *             Copyright (c) 1986, 1987 Dave Taylor
  783. X *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  784. X *******************************************************************************
  785. X * Bug reports, patches, comments, suggestions should be sent to:
  786. X *
  787. X *    Syd Weinstein, Elm Coordinator
  788. X *    elm@DSI.COM            dsinc!elm
  789. X *
  790. X *******************************************************************************
  791. X * $Log:    save_opts.h,v $
  792. X * Revision 4.1  90/04/28  22:42:12  syd
  793. X * checkin of Elm 2.3 as of Release PL0
  794. X * 
  795. X *
  796. X ******************************************************************************/
  797. X
  798. X/** Some crazy includes for the save-opts part of the Elm program!
  799. X
  800. X**/
  801. X
  802. X#define ALTERNATIVES        0
  803. X#define ALWAYSDELETE        1
  804. X#define ALWAYSKEEP        2
  805. X#define ALWAYSSTORE        3
  806. X#define ARROW            4
  807. X#define ASK            5
  808. X#define ASKCC            6
  809. X#define ATTRIBUTION             7
  810. X#define AUTOCOPY                8
  811. X#define BOUNCEBACK              9
  812. X#define CALENDAR                10
  813. X#define COPY                    11
  814. X#define EDITOR                  12
  815. X#define ESCAPECHAR              13
  816. X#define FORCENAME               14
  817. X#define FORMS                   15
  818. X#define FULLNAME                16
  819. X#define KEEPEMPTY               17
  820. X#define KEYPAD                  18
  821. X#define LOCALSIGNATURE          19
  822. X#define MAILDIR                 20
  823. X#define MENU                    21
  824. X#define MOVEPAGE                22
  825. X#define NAMES                   23
  826. X#define NOHEADER                24
  827. X#define PAGER                   25
  828. X#define POINTNEW                26
  829. X#define PREFIX                  27
  830. X#define PRINT                   28
  831. X#define PROMPTAFTER             29
  832. X#define RECEIVEDMAIL            30
  833. X#define REMOTESIGNATURE         31
  834. X#define RESOLVE                 32
  835. X#define SAVENAME                33
  836. X#define SENTMAIL                34
  837. X#define SHELL                   35
  838. X#define SIGDASHES               36
  839. X#define SIGNATURE               37
  840. X#define SOFTKEYS                38
  841. X#define SORTBY                  39
  842. X#define TIMEOUT                 40
  843. X#define TITLES                  41
  844. X#define TMPDIR                  42
  845. X#define USERLEVEL               43
  846. X#define WARNINGS                44
  847. X#define WEED                    45
  848. X#define WEEDOUT                 46
  849. X
  850. X#define NUMBER_OF_SAVEABLE_OPTIONS    WEEDOUT+1
  851. X
  852. Xstruct save_info_recs { 
  853. X    char     name[NLEN];     /* name of instruction */
  854. X    long     offset;        /* offset into elmrc-info file */
  855. X    } save_info[NUMBER_OF_SAVEABLE_OPTIONS] = 
  856. X{
  857. X { "alternatives", -1L }, 
  858. X { "alwaysdelete", -1L },     
  859. X { "alwayskeep", -1L },
  860. X { "alwaysstore", -1L },
  861. X { "arrow", -1L},         
  862. X { "ask", -1L },
  863. X { "askcc", -1L },
  864. X { "attribution", -1L },
  865. X { "autocopy", -1L },          
  866. X { "bounceback", -1L },
  867. X { "calendar", -1L },       
  868. X { "copy", -1L },              
  869. X { "editor", -1L },
  870. X { "escape", -1L },       
  871. X { "forcename", -1L },             
  872. X { "forms", -1L },             
  873. X { "fullname", -1L },
  874. X { "keepempty", -1L },       
  875. X { "keypad", -1L },       
  876. X { "localsignature", -1L },    
  877. X { "maildir", -1L },       
  878. X { "menu", -1L },         
  879. X { "movepage", -1L }, 
  880. X { "names", -1L },        
  881. X { "noheader", -1L },         
  882. X { "pager", -1L }, 
  883. X { "pointnew", -1L},      
  884. X { "prefix", -1L },           
  885. X { "print", -1L }, 
  886. X { "promptafter", -1L }, 
  887. X { "receivedmail", -1L }, 
  888. X { "remotesignature",-1L},
  889. X { "resolve", -1L },           
  890. X { "savename", -1L },     
  891. X { "sentmail", -1L }, 
  892. X { "shell", -1L },             
  893. X { "sigdashes", -1L },
  894. X { "signature", -1L },
  895. X { "softkeys", -1L },      
  896. X { "sortby", -1L },         
  897. X { "timeout", -1L },
  898. X { "titles", -1L },       
  899. X { "tmpdir", -1L },       
  900. X { "userlevel", -1L },     
  901. X { "warnings", -1L },
  902. X { "weed", -1L },         
  903. X { "weedout", -1L },        
  904. X};
  905. SHAR_EOF
  906. chmod 0444 hdrs/save_opts.h || echo "restore of hdrs/save_opts.h fails"
  907. echo "x - extracting hdrs/sysdefs.SH (Text)"
  908. sed 's/^X//' << 'SHAR_EOF' > hdrs/sysdefs.SH &&
  909. Xcase $CONFIG in
  910. X'')
  911. X    if test ! -f config.sh; then
  912. X    ln ../config.sh . || \
  913. X    ln ../../config.sh . || \
  914. X    ln ../../../config.sh . || \
  915. X    (echo "Can't find config.sh."; exit 1)
  916. X    echo "Using config.sh from above..."
  917. X    fi
  918. X    . ./config.sh
  919. X    ;;
  920. Xesac
  921. Xecho "Extracting hdrs/sysdefs.h (with variable substitutions)"
  922. Xsed <<!GROK!THIS! >sysdefs.h -e 's!^#undef!/\*#undef!'
  923. X/* $Id: sysdefs.SH,v 4.1 90/04/28 22:42:14 syd Exp $ */
  924. X/*******************************************************************************
  925. X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  926. X *
  927. X *             Copyright (c) 1986, 1987 Dave Taylor
  928. X *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  929. X *******************************************************************************
  930. X * Bug reports, patches, comments, suggestions should be sent to:
  931. X *
  932. X *    Syd Weinstein, Elm Coordinator
  933. X *    elm@DSI.COM            dsinc!elm
  934. X *
  935. X *******************************************************************************
  936. X * $Log:    sysdefs.SH,v $
  937. X * Revision 4.1  90/04/28  22:42:14  syd
  938. X * checkin of Elm 2.3 as of Release PL0
  939. X * 
  940. X *
  941. X ******************************************************************************/
  942. X
  943. X/**  System level, configurable, defines for the ELM mail system.  **/
  944. X
  945. X
  946. X#define FIND_DELTA    10        /* byte region where the binary search
  947. X                       on the path alias file is fruitless 
  948. X                                           (can't be within this boundary)    */
  949. X
  950. X#define MAX_IN_WEEDLIST 150    /* max headers to weed out               */
  951. X
  952. X#define MAX_HOPS    35    /* max hops in return addr to E)veryone  */
  953. X
  954. X#define DEFAULT_BATCH_SUBJECT  "$defbatsub"
  955. X
  956. X#define DEFAULT_DOMAIN  "$mydomain"  /* if mydomain file is missing */
  957. X
  958. X/** If you want to implement 'site hiding' in the mail, then you'll need to
  959. X    uncomment the following lines and set them to reasonable values.  See 
  960. X    the configuration guide for more details....(actually these are undoc-
  961. X    umented because they're fairly dangerous to use.  Just ignore 'em and
  962. X    perhaps one day you'll find out what they do, ok?)
  963. X**/
  964. X
  965. X/****************************************************************************
  966. X
  967. X#define   SITE_HIDING
  968. X#define   HIDDEN_SITE_NAME    "fake-machine-name"
  969. X#define   HIDDEN_SITE_USERS    "/usr/mail/lists/hidden_site_users"
  970. X
  971. X****************************************************************************/
  972. X
  973. X#define system_text_file        "$lib/aliases.text"
  974. X#define system_hash_file        "$lib/aliases.hash"
  975. X#define system_data_file        "$lib/aliases.data"
  976. X
  977. X#define ALIAS_TEXT        ".elm/aliases.text"
  978. X#define ALIAS_HASH        ".elm/aliases.hash"
  979. X#define ALIAS_DATA        ".elm/aliases.data"
  980. X
  981. X#define pathfile        "$pathalias"
  982. X#define domains            "$domains"
  983. X#define hostdomfile             "$lib/domain"
  984. X
  985. X/** where to put the output of the elm -d command... (in home dir) **/
  986. X#define DEBUGFILE    "ELM:debug.info"
  987. X#define OLDEBUG        "ELM:debug.last"
  988. X
  989. X#define    default_temp       "$tmpdir/"
  990. X#define temp_file    "snd."
  991. X#define temp_form_file    "form."
  992. X#define temp_mbox    "mbox."
  993. X#define temp_print      "print."
  994. X#define temp_edit    "elm-edit"
  995. X#define temp_uuname    "uuname."
  996. X#define readmsg_file    ".elm/readmsg"
  997. X
  998. X#define emacs_editor    "$emacs"
  999. X
  1000. X#define default_editor    "$defeditor"
  1001. X#define mailhome    "$maildir/"
  1002. X
  1003. X#define default_shell    "$prefshell"
  1004. X#define default_pager    "$pager"
  1005. X#define default_printout    "$cat %s | $linepr"
  1006. X
  1007. X#define sendmail    "$sendmail"
  1008. X#define smflags        "-oi -oem"    /* ignore dots and mail back errors */
  1009. X#define smflagsv      "-oi -oem -v"   /* Verbose voyuer mode */
  1010. X#define mailer        "$mailer"
  1011. X
  1012. X#define mailx        "$mailx"
  1013. X
  1014. X#define helphome    "$lib"
  1015. X#define helpfile    "elm-help"
  1016. X
  1017. X#define ELMRC_INFO    "$lib/elmrc-info"
  1018. X
  1019. X#define elmrcfile    ".elm/elmrc"
  1020. X#define old_elmrcfile    ".elm/elmrc.old"
  1021. X#define mailheaders    ".elm/elmheaders"
  1022. X#define dead_letter    "Cancelled.mail"
  1023. X
  1024. X#define unedited_mail    "emergency.mbox"
  1025. X
  1026. X#define newalias    "newalias 1>&2 > /dev/null"
  1027. X#define readmsg        "readmsg"
  1028. X
  1029. X#define remove_cmd    "$rm -f"    /* how to remove a file */
  1030. X#define cat        "$cat"        /* how to display files */
  1031. X#define sed_cmd        "$sed"        /* how to access sed */
  1032. X#define move_cmd    "$mv"        /* how to access sed */
  1033. X#define uuname        "$uuname"    /* how to get a uuname  */
  1034. X
  1035. X#define MSG_SEPERATOR    "\001\001\001\001\n"    /* mmdf message seperator */
  1036. X!GROK!THIS!
  1037. SHAR_EOF
  1038. chmod 0444 hdrs/sysdefs.SH || echo "restore of hdrs/sysdefs.SH fails"
  1039. echo "x - extracting src/Makefile.SH (Text)"
  1040. sed 's/^X//' << 'SHAR_EOF' > src/Makefile.SH &&
  1041. Xcase $CONFIG in
  1042. X'')
  1043. X    if test ! -f config.sh; then
  1044. X    ln ../config.sh . || \
  1045. X    ln ../../config.sh . || \
  1046. X    ln ../../../config.sh . || \
  1047. X    (echo "Can't find config.sh."; exit 1)
  1048. X    fi
  1049. X    . ./config.sh
  1050. X    ;;
  1051. Xesac
  1052. Xcase "$0" in
  1053. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1054. Xesac
  1055. X
  1056. Xecho "Extracting src/Makefile (with variable substitutions)"
  1057. Xcat >Makefile <<!GROK!THIS!
  1058. X# $Id: Makefile.SH,v 4.1 90/04/28 22:42:16 syd Exp $
  1059. X#
  1060. X#  Makefile for the ELM mail program.
  1061. X#
  1062. X#    Copyright (c) 1986, 1987 Dave Taylor
  1063. X#    Copyright (c) 1988, 1989, 1990 USENET Community Trust
  1064. X#
  1065. X# Bug reports, patches, comments, suggestions should be sent to:
  1066. X#
  1067. X#    Syd Weinstein - elm@DSI.COM
  1068. X#            dsinc!elm
  1069. X#
  1070. X# $Log:    Makefile.SH,v $
  1071. X# Revision 4.1  90/04/28  22:42:16  syd
  1072. X# checkin of Elm 2.3 as of Release PL0
  1073. X# 
  1074. X#
  1075. X# Variables
  1076. X#    Variables established by Configure
  1077. XCC        =    $cc
  1078. XCCFLAGS        =    $ccflags $xencf
  1079. XCHGRP        =    $chgrp
  1080. XCHMOD        =    $chmod
  1081. XCP        =    $cp
  1082. XDEST        =    $bin
  1083. XECHO        =    $echo
  1084. XLFLAGS        =    $ldflags $xenlf
  1085. XLIB        =    $lib
  1086. XLIB2        =     $libs
  1087. XLIBS        =    $cryptlib $termlib $dbm
  1088. XLINT        =    $lint
  1089. XMAILGRP        =    $mailgrp
  1090. XMAILERMODE    =    $mailermode
  1091. XMV        =    $mv
  1092. XOPTIMIZE    =    $optimize
  1093. XRM        =     $rm -f
  1094. XTOUCH        =    $touch
  1095. X
  1096. X!GROK!THIS!
  1097. X
  1098. Xcat >>Makefile <<'!NO!SUBS!'
  1099. X
  1100. X#    Variables you may want to manually edit
  1101. X#        If you want debug logging then you'll
  1102. X#        want to uncomment the following.
  1103. X#DEBUG        =    -DDEBUG
  1104. X
  1105. X#        If you're on an ACSnet system (Australia) then
  1106. X#        you'll want to uncomment the following.
  1107. X# DACSNET    =    -DACSNET
  1108. X
  1109. X#    Other general variables
  1110. XBIN        =    ../bin
  1111. XCFLAGS        =    $(CCFLAGS) $(OPTIMIZE) -I$(INCLDIR) $(DEBUG) $(DACSNET) 
  1112. XINCLDIR        =    ../hdrs
  1113. XLINTFLAGS    =    -I$(INCLDIR)
  1114. XSHELL        =    /bin/sh
  1115. X
  1116. X#     Lists
  1117. XELM_SRC        =    addr_util.c    \
  1118. X            alias.c        \
  1119. X            aliasdb.c    \
  1120. X            aliaslib.c    \
  1121. X            args.c        \
  1122. X            bouncebk.c    \
  1123. X            builtin.c    \
  1124. X            calendar.c    \
  1125. X            conn_to.c    \
  1126. X            curses.c    \
  1127. X            date.c        \
  1128. X            delete.c    \
  1129. X            domains.c    \
  1130. X            edit.c        \
  1131. X            editmsg.c    \
  1132. X            elm.c        \
  1133. X            encode.c    \
  1134. X            errno.c        \
  1135. X            exitprog.c    \
  1136. X            expires.c    \
  1137. X            file.c        \
  1138. X            file_util.c    \
  1139. X            fileio.c    \
  1140. X            forms.c        \
  1141. X            hdrconfg.c    \
  1142. X            help.c        \
  1143. X            init.c        \
  1144. X            in_utils.c    \
  1145. X            leavembox.c    \
  1146. X            limit.c        \
  1147. X            mailmsg1.c    \
  1148. X            mailmsg2.c    \
  1149. X            mailtime.c    \
  1150. X            mkhdrs.c    \
  1151. X            newmbox.c    \
  1152. X            opt_utils.c    \
  1153. X            options.c    \
  1154. X            out_utils.c    \
  1155. X            pattern.c    \
  1156. X            pmalloc.c    \
  1157. X            quit.c        \
  1158. X            read_rc.c    \
  1159. X            remail.c    \
  1160. X            reply.c        \
  1161. X            returnadd.c    \
  1162. X            save_opts.c    \
  1163. X            savecopy.c    \
  1164. X            screen.c    \
  1165. X            showmsg.c    \
  1166. X            showmsg_c.c    \
  1167. X            signals.c    \
  1168. X            softkeys.c    \
  1169. X            sort.c        \
  1170. X            string2.c    \
  1171. X            strings.c    \
  1172. X            syscall.c    \
  1173. X            utils.c        \
  1174. X            validname.c
  1175. X
  1176. XELM_OBJ        =    addr_util.o    \
  1177. X            alias.o        \
  1178. X            aliasdb.o    \
  1179. X            aliaslib.o    \
  1180. X            args.o        \
  1181. X            bouncebk.o    \
  1182. X            builtin.o    \
  1183. X            calendar.o    \
  1184. X            conn_to.o    \
  1185. X            curses.o    \
  1186. X            date.o        \
  1187. X            delete.o    \
  1188. X            domains.o    \
  1189. X            edit.o        \
  1190. X            editmsg.o    \
  1191. X            elm.o        \
  1192. X            encode.o    \
  1193. X            errno.o        \
  1194. X            exitprog.o    \
  1195. X            expires.o    \
  1196. X            file.o        \
  1197. X            file_util.o    \
  1198. X            fileio.o    \
  1199. X            forms.o        \
  1200. X            hdrconfg.o    \
  1201. X            help.o        \
  1202. X            init.o        \
  1203. X            in_utils.o    \
  1204. X            leavembox.o    \
  1205. X            limit.o        \
  1206. X            mailmsg1.o    \
  1207. X            mailmsg2.o    \
  1208. X            mailtime.o    \
  1209. X            mkhdrs.o    \
  1210. X            newmbox.o    \
  1211. X            opt_utils.o    \
  1212. X            options.o    \
  1213. X            out_utils.o    \
  1214. X            pattern.o    \
  1215. X            pmalloc.o    \
  1216. X            quit.o        \
  1217. X            read_rc.o    \
  1218. X            remail.o    \
  1219. X            reply.o        \
  1220. X            returnadd.o    \
  1221. X            save_opts.o    \
  1222. X            savecopy.o    \
  1223. X            screen.o    \
  1224. X            showmsg.o    \
  1225. X            showmsg_c.o    \
  1226. X            signals.o    \
  1227. X            softkeys.o    \
  1228. X            sort.o        \
  1229. X            string2.o    \
  1230. X            strings.o    \
  1231. X            syscall.o    \
  1232. X            utils.o        \
  1233. X            validname.o
  1234. X
  1235. X# Standard targets
  1236. Xall:        $(BIN)/elm
  1237. X
  1238. Xinstall:    $(DEST)/elm
  1239. X
  1240. Xuninstall:    
  1241. X        $(RM) $(DEST)/elm
  1242. X
  1243. X#    This is the only target that gets installed even if not out-of-date
  1244. X#    with respect the files from which it is installed.
  1245. Xrmt-install:    rmt-defined
  1246. X        -$(MV) $(DEST)/elm $(DEST)/elm.old
  1247. X        -$(RM) $(DEST)/elm.old
  1248. X        $(CP) $(REMOTE)$(DEST)/elm $(DEST)/elm
  1249. X        $(CHGRP) $(MAILGRP) $(DEST)/elm
  1250. X        $(CHMOD) $(MAILERMODE) $(DEST)/elm
  1251. X
  1252. Xrmt-defined:
  1253. X    @(if [ "$(REMOTE)" = "" ];\
  1254. X      then\
  1255. X        $(ECHO) "You need to define 'REMOTE' as the remote file system";\
  1256. X        $(ECHO) "for this particular command. The easiest way to do this";\
  1257. X        $(ECHO) "to type:";\
  1258. X        $(ECHO) "        make REMOTE=<remote file system> rmt-install";\
  1259. X        exit 1;\
  1260. X    fi);
  1261. X
  1262. Xlint:        
  1263. X        $(LINT) $(LINTFLAGS) $(ELM_SRC) > LINT.OUT
  1264. X
  1265. Xclean:        
  1266. X        $(RM) $(ELM_OBJ) $(BIN)/elm
  1267. X
  1268. X# Dependencies and rules
  1269. X#    Dependencies of header files upon other header files they include
  1270. X.PRECIOUS:        $(INCLDIR)/defs.h $(INCLDIR)/elm.h $(INCLDIR)/headers.h
  1271. X
  1272. X$(INCLDIR)/defs.h:    $(INCLDIR)/../config.h $(INCLDIR)/sysdefs.h
  1273. X            $(CHMOD) u+w $@
  1274. X            $(TOUCH) $@
  1275. X
  1276. X$(INCLDIR)/elm.h:    $(INCLDIR)/curses.h $(INCLDIR)/defs.h
  1277. X            $(CHMOD) u+w $@
  1278. X            $(TOUCH) $@
  1279. X
  1280. X$(INCLDIR)/headers.h:    $(INCLDIR)/curses.h $(INCLDIR)/defs.h
  1281. X            $(CHMOD) u+w $@
  1282. X            $(TOUCH) $@
  1283. X
  1284. X#    Dependencies of C object files
  1285. Xaddr_util.o:    $(INCLDIR)/headers.h
  1286. Xalias.o:    $(INCLDIR)/headers.h
  1287. Xaliasdb.o:    $(INCLDIR)/headers.h
  1288. Xaliaslib.o:    $(INCLDIR)/headers.h
  1289. Xargs.o:        $(INCLDIR)/headers.h $(INCLDIR)/patchlevel.h
  1290. Xbouncebk.o:    $(INCLDIR)/headers.h
  1291. Xbuiltin.o:    $(INCLDIR)/headers.h
  1292. Xcalendar.o:    $(INCLDIR)/headers.h
  1293. Xconn_to.o:    $(INCLDIR)/headers.h
  1294. Xcurses.o:    $(INCLDIR)/headers.h
  1295. Xdate.o:        $(INCLDIR)/headers.h
  1296. Xdelete.o:    $(INCLDIR)/headers.h
  1297. Xdomains.o:    $(INCLDIR)/headers.h
  1298. Xedit.o:        $(INCLDIR)/headers.h
  1299. Xeditmsg.o:    $(INCLDIR)/headers.h
  1300. Xelm.o:        $(INCLDIR)/elm.h
  1301. Xencode.o:    $(INCLDIR)/headers.h
  1302. Xerrno.o:    $(INCLDIR)/headers.h
  1303. Xexitprog.o:    $(INCLDIR)/headers.h
  1304. Xexpires.o:    $(INCLDIR)/headers.h
  1305. Xfile.o:        $(INCLDIR)/headers.h
  1306. Xfile_util.o:    $(INCLDIR)/headers.h
  1307. Xfileio.o:    $(INCLDIR)/headers.h
  1308. Xforms.o:    $(INCLDIR)/headers.h
  1309. Xhdrconfg.o:    $(INCLDIR)/headers.h
  1310. Xhelp.o:        $(INCLDIR)/headers.h
  1311. Xin_utils.o:    $(INCLDIR)/headers.h
  1312. Xinit.o:        $(INCLDIR)/headers.h $(INCLDIR)/patchlevel.h
  1313. Xleavembox.o:    $(INCLDIR)/headers.h
  1314. Xlimit.o:    $(INCLDIR)/headers.h
  1315. Xmailmsg1.o:    $(INCLDIR)/headers.h
  1316. Xmailmsg2.o:    $(INCLDIR)/headers.h
  1317. Xmailtime.o:    $(INCLDIR)/headers.h
  1318. Xmkhdrs.o:    $(INCLDIR)/headers.h
  1319. Xnewmbox.o:    $(INCLDIR)/headers.h
  1320. Xopt_utils.o:    $(INCLDIR)/headers.h
  1321. Xoptions.o:    $(INCLDIR)/headers.h
  1322. Xout_utils.o:    $(INCLDIR)/headers.h
  1323. Xpattern.o:    $(INCLDIR)/headers.h
  1324. Xpmalloc.o:    $(INCLDIR)/defs.h
  1325. Xquit.o:        $(INCLDIR)/headers.h
  1326. Xread_rc.o:    $(INCLDIR)/headers.h
  1327. Xremail.o:    $(INCLDIR)/headers.h
  1328. Xreply.o:    $(INCLDIR)/headers.h
  1329. Xreturnadd.o:    $(INCLDIR)/headers.h
  1330. Xsave_opts.o:    $(INCLDIR)/save_opts.h $(INCLDIR)/headers.h
  1331. Xsavecopy.o:    $(INCLDIR)/headers.h
  1332. Xscreen.o:    $(INCLDIR)/headers.h
  1333. Xshowmsg.o:    $(INCLDIR)/headers.h
  1334. Xshowmsg_c.o:    $(INCLDIR)/headers.h
  1335. Xsignals.o:    $(INCLDIR)/headers.h
  1336. Xsoftkeys.o:    $(INCLDIR)/headers.h
  1337. Xsort.o:        $(INCLDIR)/headers.h
  1338. Xstring2.o:    $(INCLDIR)/headers.h
  1339. Xstrings.o:    $(INCLDIR)/headers.h
  1340. Xsyscall.o:    $(INCLDIR)/headers.h
  1341. Xutils.o:    $(INCLDIR)/headers.h
  1342. Xvalidname.o:    $(INCLDIR)/defs.h
  1343. X
  1344. X#    Dependencies and rules for compiling C programs
  1345. X$(BIN)/elm:    $& $(ELM_OBJ)
  1346. X        $(CC) $(LFLAGS) -o $@ $(ELM_OBJ) $(LIBS) $(LIB2)
  1347. X
  1348. X#    Dependencies and rules for installing C programs
  1349. X$(DEST)/elm:    $(BIN)/elm
  1350. X        -$(MV) $@ $@.old
  1351. X        -$(RM) $@.old
  1352. X        $(CP) $(BIN)/elm $@
  1353. X        $(CHGRP) $(MAILGRP) $@
  1354. X        $(CHMOD) $(MAILERMODE) $@
  1355. X
  1356. X!NO!SUBS!
  1357. SHAR_EOF
  1358. chmod 0444 src/Makefile.SH || echo "restore of src/Makefile.SH fails"
  1359. echo "x - extracting src/addr_util.c (Text)"
  1360. sed 's/^X//' << 'SHAR_EOF' > src/addr_util.c &&
  1361. X
  1362. Xstatic char rcsid[] = "@(#)$Id: addr_util.c,v 4.1 90/04/28 22:42:21 syd Exp $";
  1363. X
  1364. X/*******************************************************************************
  1365. X *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  1366. X *
  1367. X *             Copyright (c) 1986, 1987 Dave Taylor
  1368. X *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  1369. X *******************************************************************************
  1370. X * Bug reports, patches, comments, suggestions should be sent to:
  1371. X *
  1372. X *    Syd Weinstein, Elm Coordinator
  1373. X *    elm@DSI.COM            dsinc!elm
  1374. X *
  1375. X *******************************************************************************
  1376. X * $Log:    addr_util.c,v $
  1377. X * Revision 4.1  90/04/28  22:42:21  syd
  1378. X * checkin of Elm 2.3 as of Release PL0
  1379. X * 
  1380. X *
  1381. X ******************************************************************************/
  1382. X
  1383. X/** This file contains addressing utilities 
  1384. X
  1385. X**/
  1386. X
  1387. X#include "headers.h"
  1388. X
  1389. X#include <sys/types.h>
  1390. X#include <sys/stat.h>
  1391. X#ifdef PWDINSYS
  1392. X#  include <sys/pwd.h>
  1393. X#else
  1394. X#  include <pwd.h>
  1395. X#endif
  1396. X
  1397. X#include <ctype.h>
  1398. X
  1399. X#ifdef BSD 
  1400. X#undef tolower
  1401. X#undef toupper
  1402. X#endif
  1403. X
  1404. Xchar *get_alias_address(), *get_token();
  1405. Xchar *strtok(), *strcpy(), *strcat(), *strncpy(), *index(), *rindex();
  1406. X
  1407. X
  1408. X#define SKIP_WS(p) while (isspace(*p)) p++
  1409. X#define SKIP_ALPHA(p) while (isalpha(*p)) p++
  1410. X#define SKIP_DIGITS(p) while (isdigit(*p)) p++
  1411. X
  1412. Xstatic char *day_name[8] = {
  1413. X    "sun", "mon", "tue", "wed", "thu", "fri", "sat", 0
  1414. X};
  1415. X
  1416. Xstatic char *month_name[13] = {
  1417. X    "jan", "feb", "mar", "apr",
  1418. X    "may", "jun", "jul", "aug",
  1419. X    "sep", "oct", "nov", "dec", 0
  1420. X};
  1421. X
  1422. Xstatic int month_len[12] = {
  1423. X    31, 28, 31, 30, 31, 30, 31,
  1424. X    31, 30, 31, 30, 31 };
  1425. X
  1426. X/* The following time zones are taken from a variety of sources.  They
  1427. X * are by no means exhaustive, but seem to include most of those
  1428. X * in common usage.  A comprehensive list is impossible, since the same
  1429. X * abbreviation is sometimes used to mean different things in different
  1430. X * parts of the world.
  1431. X */
  1432. Xstatic struct tzone {
  1433. X    char *str;
  1434. X    int offset; /* offset, in minutes, EAST of GMT */
  1435. X} tzone_info[] = {
  1436. X    /* the following are from rfc822 */
  1437. X    "ut", 0, "gmt", 0,
  1438. X    "est", -5*60, "edt", -4*60,
  1439. X    "cst", -6*60, "cdt", -5*60,
  1440. X    "mst", -7*60, "mdt", -6*60,
  1441. X    "pst", -8*60, "pdt", -7*60,
  1442. X    "z", 0, /* zulu time (the rest of the military codes are bogus) */
  1443. X
  1444. X    /* these are also popular in Europe */
  1445. X    "wet", 0*60, "wet dst", 1*60, /* western european */
  1446. X    "met", 1*60, "met dst", 2*60, /* middle european */
  1447. X    "eet", 2*60, "eet dst", 3*60, /* eastern european */
  1448. X    "bst", 1*60, /* ??? british summer time (=+0100) */
  1449. X
  1450. X    /* ... and Canada */
  1451. X    "ast", -4*60, "adt", -3*60, /* atlantic */
  1452. X    "nst", -3*60-30, "ndt", -2*60-30, /* newfoundland */
  1453. X    "yst", -9*60, "ydt", -8*60, /* yukon */
  1454. X    "hst", -10*60, /* hawaii (not really canada) */
  1455. X
  1456. X    /* ... and Asia */
  1457. X    "jst", 9*60, /* japan */
  1458. X    "sst", 8*60, /* singapore */
  1459. X
  1460. X    /* ... and the South Pacific */
  1461. X    "nzst", 12*60, "nzdt", 13*60, /* new zealand */
  1462. X    "wst", 8*60, "wdt", 9*60, /* western australia */
  1463. X    /* there's also central and eastern australia, but they insist on using
  1464. X     * cst, est, etc., which would be indistinguishable for the us zones */
  1465. X     (char *) 0, 0
  1466. X};
  1467. X
  1468. Xchar *
  1469. Xgcos_name(gcos_field, logname)
  1470. Xchar *logname, *gcos_field;
  1471. X{
  1472. X    /** Return the full name found in a passwd file gcos field **/
  1473. X
  1474. X#ifdef BERKNAMES
  1475. X
  1476. X    static char fullname[SLEN];
  1477. X    register char *fncp, *gcoscp, *lncp, *end;
  1478. X
  1479. X
  1480. X    /* full name is all chars up to first ',' (or whole gcos, if no ',') */
  1481. X    /* replace any & with logname in upper case */
  1482. X
  1483. X    for(fncp = fullname, gcoscp= gcos_field, end = fullname + SLEN - 1;
  1484. X        (*gcoscp != ',' && *gcoscp != '\0' && fncp != end);
  1485. X    gcoscp++) {
  1486. X
  1487. X    if(*gcoscp == '&') {
  1488. X        for(lncp = logname; *lncp; fncp++, lncp++)
  1489. X        *fncp = toupper(*lncp);
  1490. X    } else {
  1491. X        *fncp++ = *gcoscp;
  1492. X    }
  1493. X    }
  1494. X    
  1495. X    *fncp = '\0';
  1496. X    return(fullname);
  1497. X#else
  1498. X#ifdef USGNAMES
  1499. X
  1500. X    char *firstcp, *lastcp;
  1501. X
  1502. X    /* The last character of the full name is the one preceding the first
  1503. X     * '('. If there is no '(', then the full name ends at the end of the
  1504. X     * gcos field.
  1505. X     */
  1506. X    if(lastcp = index(gcos_field, '('))
  1507. X    *lastcp = '\0';
  1508. X
  1509. X    /* The first character of the full name is the one following the 
  1510. X     * last '-' before that ending character. NOTE: that's why we
  1511. X     * establish the ending character first!
  1512. X     * If there is no '-' before the ending character, then the fullname
  1513. X     * begins at the beginning of the gcos field.
  1514. X     */
  1515. X    if(firstcp = rindex(gcos_field, '-'))
  1516. X    firstcp++;
  1517. X    else
  1518. X    firstcp = gcos_field;
  1519. X
  1520. X    return(firstcp);
  1521. X
  1522. X#else
  1523. X    /* use full gcos field */
  1524. X    return(gcos_field);
  1525. X#endif
  1526. X#endif
  1527. X}
  1528. X        
  1529. Xchar *
  1530. Xget_full_name(logname)
  1531. Xchar *logname;
  1532. X{
  1533. X    /* return a pointer to the full user name for the passed logname
  1534. X     * or NULL if cannot be found
  1535. X     * If PASSNAMES get it from the gcos field, otherwise get it
  1536. X     * from ~/.fullname.
  1537. X     */
  1538. X
  1539. X#ifndef PASSNAMES
  1540. X    FILE *fp;
  1541. X    char fullnamefile[SLEN];
  1542. X#endif
  1543. X    static char fullname[SLEN];
  1544. X    struct passwd *getpwnam(), *pass;
  1545. X
  1546. X    if((pass = getpwnam(logname)) == NULL)
  1547. X      return(NULL);
  1548. X#ifdef PASSNAMES    /* get full_username from gcos field */
  1549. X    strcpy(fullname, gcos_name(pass->pw_gecos, logname));
  1550. X#else            /* get full_username from ~/.fullname file */
  1551. X    sprintf(fullnamefile, "%s/.fullname", pass->pw_dir);
  1552. SHAR_EOF
  1553. echo "End of part 10"
  1554. echo "File src/addr_util.c is continued in part 11"
  1555. echo "11" > s2_seq_.tmp
  1556. exit 0
  1557.