home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / rn_4_3_blars.lzh / common.h < prev    next >
Text File  |  1991-09-24  |  25KB  |  869 lines

  1. /* $Header: common.h,v 4.3.2.13 90/05/08 22:05:37 sob Exp $
  2.  * 
  3.  * $Log:    common.h,v $
  4.  * Revision 4.3.2.13  90/05/08  22:05:37  sob
  5.  * Added quick startup (-q) flag.
  6.  * 
  7.  * Revision 4.3.2.12  90/04/23  00:32:04  sob
  8.  * More cleanup.
  9.  * 
  10.  * Revision 4.3.2.11  90/04/14  19:37:07  sob
  11.  * Added better support for the NeXT.
  12.  * 
  13.  * Revision 4.3.2.10  90/04/06  20:54:12  sob
  14.  * Corrected forward definition of fseek()
  15.  * 
  16.  * Revision 4.3.2.9  90/03/17  21:19:04  sob
  17.  * Removed the incorrect forward definition of sprintf().
  18.  * 
  19.  * Revision 4.3.2.8  89/12/20  20:40:03  sob
  20.  * Changed ACT_POS from short to long per suggestion from eps@cd.SFSU.EDU.
  21.  * 
  22.  * Revision 4.3.2.7  89/12/08  22:43:12  sob
  23.  * Corrected typo pointed out by weening@gang-of-four.stanford.edu
  24.  * 
  25.  * Revision 4.3.2.6  89/11/28  01:57:31  sob
  26.  * Added initlines_specified variable for use with SIGWINCH support.
  27.  * 
  28.  * Revision 4.3.2.5  89/11/28  00:30:56  sob
  29.  * Reversed the CANCELHEADER definitions.
  30.  * 
  31.  * Revision 4.3.2.4  89/11/27  01:29:23  sob
  32.  * Altered NNTP code per ideas suggested by Bela Lubkin
  33.  * <filbo@gorn.santa-cruz.ca.us>
  34.  * 
  35.  * Revision 4.3.2.3  89/11/26  19:32:06  sob
  36.  * Increased the size of MAXRCLINE from 1000 to 1500
  37.  * Increated HASHSIZ from 1103 to 1693
  38.  * 
  39.  * Revision 4.3.2.2  89/11/07  23:18:49  sob
  40.  * Repaired NEWSHEADER and CANCEL to work correctly with NNTP and INTERNET.
  41.  * 
  42.  * Revision 4.3.2.1  89/11/06  00:12:33  sob
  43.  * Added RRN support from NNTP 1.5
  44.  * 
  45.  * Revision 4.3.1.4  86/10/31  15:46:09  lwall
  46.  * Expanded maximum number of .newsrc lines for net reorganization.
  47.  * 
  48.  * Revision 4.3.1.3  85/05/23  17:19:32  lwall
  49.  * Now allows 'r' and 'f' on null articles.
  50.  * 
  51.  * Revision 4.3.1.2  85/05/13  09:30:39  lwall
  52.  * Added CUSTOMLINES option.
  53.  * 
  54.  * Revision 4.3.1.1  85/05/10  11:32:04  lwall
  55.  * Branch for patches.
  56.  * 
  57.  * Revision 4.3  85/05/01  11:37:11  lwall
  58.  * Baseline for release with 4.3bsd.
  59.  * 
  60.  */
  61.  
  62. #include "config.h"    /* generated by installation script */
  63. #ifdef WHOAMI
  64. #    include <whoami.h>
  65. #endif
  66.  
  67. #include <stdio.h>
  68. #include <sys/types.h>
  69. #include <sys/stat.h>
  70. #include <ctype.h>
  71.  
  72. #ifndef isalnum
  73. #   define isalnum(c) (isalpha(c) || isdigit(c))
  74. #endif
  75.  
  76. #include <errno.h>
  77. #include <signal.h>
  78. #ifdef IOCTL
  79. #include <sys/ioctl.h>
  80. #endif IOCTL
  81.  
  82. #ifdef FCNTL
  83. #   include <fcntl.h>
  84. #endif
  85.  
  86. #ifdef TERMIO
  87. #   include <termio.h>
  88. #else
  89. #   ifndef OSK
  90. #       include <sgtty.h>
  91. #   else
  92. #       include <sgstat.h>
  93. #   endif
  94. #endif
  95.  
  96. #ifdef GETPWENT
  97. #   include <pwd.h>
  98. #endif
  99.  
  100. #define BITSPERBYTE 8
  101. #define LBUFLEN 512    /* line buffer length */
  102.             /* (don't worry, .newsrc lines can exceed this) */
  103. #ifdef pdp11
  104. #   define CBUFLEN 256    /* command buffer length */
  105. #   define PUSHSIZE 128
  106. #else
  107. #   define CBUFLEN 512    /* command buffer length */
  108. #   define PUSHSIZE 256
  109. #endif
  110. #ifdef pdp11
  111. #   define MAXFILENAME 128
  112. #else
  113. #   define MAXFILENAME 512
  114. #endif
  115. #define LONGKEY 15    /* longest keyword: currently "posting-version" */
  116. #define FINISHCMD 0177
  117.  
  118. /* some handy defs */
  119.  
  120. #define bool char
  121. #define TRUE (1)
  122. #define FALSE (0)
  123. #define Null(t) ((t)0)
  124. #define Nullch Null(char *)
  125. #define Nullfp Null(FILE *)
  126.  
  127. #define Ctl(ch) (ch & 037)
  128.  
  129. #define strNE(s1,s2) (strcmp(s1,s2))
  130. #define strEQ(s1,s2) (!strcmp(s1,s2))
  131. #define strnNE(s1,s2,l) (strncmp(s1,s2,l))
  132. #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
  133.  
  134. /* Things we can figure out ourselves */
  135.  
  136. #ifdef SIGTSTP
  137. #   define BERKELEY     /* include job control signals? */
  138. #endif
  139.  
  140. #ifdef FIONREAD
  141. #   define PENDING
  142. #else
  143. #   ifdef O_NDELAY
  144. #    define PENDING
  145. #   endif
  146. #endif
  147.  
  148. #ifdef OSK
  149. #   define PENDING
  150. #endif
  151.  
  152. #ifdef EUNICE
  153. #   define LINKART        /* add 1 level of possible indirection */
  154. #   define UNLINK(victim) while (!unlink(victim))
  155. #else
  156. #   define UNLINK(victim) unlink(victim)
  157. #endif
  158.  
  159. /* Valid substitutions for strings marked with % comment are:
  160.  *    %a    Current article number
  161.  *    %A    Full name of current article (%P/%c/%a)
  162.  *        (if LINKART defined, is the name of the real article)
  163.  *    %b    Destination of a save command, a mailbox or command
  164.  *    %B    The byte offset to the beginning of the article for saves
  165.  *        with or without the header
  166.  *    %c    Current newsgroup, directory form
  167.  *    %C    Current newsgroup, dot form
  168.  *    %d    %P/%c
  169.  *    %D    Old Distribution: line
  170.  *    %f    Old From: line or Reply-To: line
  171.  *    %F    Newsgroups to followup to from Newsgroups: and Followup-To:
  172.  *    %h    Name of header file to pass to mail or news poster
  173.  *    %H    Host name (yours)
  174.  *    %i    Old Message-I.D.: line, with <>
  175.  *    %I    Inclusion indicator
  176.  *    %l    News administrator login name
  177.  *    %L    Login name (yours)
  178.  *    %M    Number of articles markd with M
  179.  *    %n    Newsgroups from source article
  180.  *    %N    Full name (yours)
  181.  *    %o    Organization (yours)
  182.  *    %O    Original working directory (where you ran rn from)
  183.  *    %p    Your private news directory (-d switch)
  184.  *    %P    Public news spool directory (SPOOLDIR)
  185.  *    %r    Last reference (parent article id)
  186.  *    %R    New references list
  187.  *    %s    Subject, with all Re's and (nf)'s stripped off
  188.  *    %S    Subject, with one Re stripped off
  189.  *    %t    New To: line derived from From: and Reply-To (Internet always)
  190.  *    %T    New To: line derived from Path:
  191.  *    %u    Number of unread articles
  192.  *    %U    Number of unread articles disregarding current article
  193.  *    %x    News library directory, usually /usr/lib/news
  194.  *    %X    Rn library directory, usually %x/rn
  195.  *    %z    Size of current article in bytes.
  196.  *    %~    Home directory
  197.  *    %.    Directory containing . files
  198.  *    %$    current process number
  199.  *    %{name} Environment variable "name".  %{name-default} form allowed.
  200.  *    %[name]    Header line beginning with "Name: ", without "Name: " 
  201.  *    %"prompt"
  202.  *        Print prompt and insert what is typed.
  203.  *    %`command`
  204.  *        Insert output of command.
  205.  *    %(test_text=pattern?if_text:else_text)
  206.  *        Substitute if_text if test_text matches pattern, otherwise
  207.  *        substitute else_text.  Use != for negated match.
  208.  *        % substitutions are done on test_text, if_text, and else_text.
  209.  *        (Note: %() only works if CONDSUB defined.)
  210.  *    %digit    Substitute the text matched by the nth bracket in the last
  211.  *        pattern that had brackets.  %0 matches the last bracket
  212.  *        matched, in case you had alternatives.
  213.  *
  214.  *    Put ^ in the middle to capitalize the first letter: %^C = Net.jokes
  215.  *    Put _ in the middle to capitalize last component: %_c = net/Jokes
  216.  *
  217.  *    ~ interpretation in filename expansion happens after % expansion, so
  218.  *    you could put ~%{NEWSLOGNAME-news} and it will expand correctly.
  219.  */
  220.  
  221. /* *** System Dependent Stuff *** */
  222.  
  223. /* NOTE: many of these are defined in the config.h file */
  224.  
  225. /* name of organization */
  226. #ifndef ORGNAME
  227. #   define ORGNAME "ACME Widget Company, Widget Falls, Southern North Dakota"
  228. #endif
  229.  
  230. #ifndef MBOXCHAR
  231. #   define MBOXCHAR 'F'    /* how to recognize a mailbox by 1st char */
  232. #endif
  233.  
  234. #ifndef ROOTID
  235. #   define ROOTID 0        /* uid of superuser */
  236. #endif
  237.  
  238. #ifdef NORMSIG
  239. #   define sigset signal
  240. #   define sigignore(sig) signal(sig,SIG_IGN)
  241. #endif
  242.  
  243. #ifndef LOGDIRFIELD
  244. #   define LOGDIRFIELD 6        /* Which field (origin 1) is the */
  245.                     /* login directory in /etc/passwd? */
  246.                     /* (If it is not kept in passwd, */
  247.                     /* but getpwnam() returns it, */
  248.                     /* define the symbol GETPWENT) */
  249. #endif
  250. #ifndef GCOSFIELD
  251. #   define GCOSFIELD 5
  252. #endif
  253.  
  254. #ifndef NEGCHAR
  255. #   define NEGCHAR '!'
  256. #endif
  257.  
  258. /* Space conservation section */
  259.  
  260. /* To save D space, cut down size of MAXRCLINE, NGMAX, VARYSIZE. */
  261. #define MAXRCLINE 1500    /* number of lines allowed in .newsrc */
  262.             /* several parallel arrays affected. */
  263.             /* (You can have more lines in the active file, */
  264.             /* just not in the .newsrc) */
  265. #define HASHSIZ 1693    /* should be prime, and at least MAXRCLINE + 10% */
  266. #define NGMAX 100    /* number of newsgroups allowed on command line */
  267.             /* undefine ONLY symbol to disable "only" feature */
  268. #define VARYSIZE 256    /* this makes a block 1024 bytes long in DECville */
  269.             /* (used by virtual array routines) */
  270.  
  271. /* Undefine any of the following features to save both I and D space */
  272. /* In general, earlier ones are easier to get along without */
  273. /* Pdp11's without split I and D may have to undefine them all */
  274. #define DEBUGGING    /* include debugging code */
  275. #define CUSTOMLINES    /* include code for HIDELINE and PAGESTOP */
  276. #define PUSHBACK    /* macros and keymaps using pushback buffer */
  277. #define SPEEDOVERMEM    /* use more memory to run faster */
  278. #define WORDERASE    /* enable ^W to erase a word */
  279. #define MAILCALL    /* check periodically for mail */
  280. #define CLEAREOL    /* use clear to end-of-line instead of clear screen */
  281. #define NOFIREWORKS    /* keep whole screen from flashing on certain */
  282.             /* terminals such as older Televideos */
  283. #define VERIFY        /* echo the command they just typed */
  284. #define HASHNG        /* hash newsgroup lines for fast lookup-- */
  285.             /* linear search used if not defined */
  286. #define CONDSUB        /* allow %(cond?text:text) */
  287. #define BACKTICK    /* allow %`command` */
  288. #define PROMPTTTY    /* allow %"prompt" */
  289. #define ULSMARTS    /* catch _^H in text and do underlining */
  290. #define TERMMOD        /* allow terminal type modifier on switches */
  291. #define BAUDMOD        /* allow baudrate modifier on switches */
  292. #ifndef OSK
  293. #define GETLOGIN    /* use getlogin() routine as backup to environment */
  294.             /* variables USER or LOGNAME */
  295. #endif
  296. #define ORGFILE        /* if organization begins with /, look up in file */
  297. #define TILDENAME    /* allow ~logname expansion */
  298. #define SETENV        /* allow command line environment variable setting */
  299. #define GETWD        /* use our getwd() instead of piped in pwd */
  300. #define MAKEDIR        /* use our makedir() instead of shell script */
  301. #define MEMHELP        /* keep help messages in memory */
  302. #define VERBOSE        /* compile in more informative messages */
  303. #define TERSE        /* compile in shorter messages */
  304.             /* (Note: both VERBOSE and TERSE can be defined; -t
  305.              * sets terse mode.  One or the other MUST be defined.
  306.              */
  307. #ifndef pdp11
  308. #   define CACHESUBJ    /* cache subject lines in memory */
  309.             /* without this ^N still works but runs really slow */
  310.             /* but you save lots and lots of D space */
  311. #   define CACHEFIRST    /* keep absolute first article numbers in memory */
  312.             /* cost: about 2k */
  313. #endif
  314. #define ROTATION    /* enable x, X and ^X commands to work */
  315. #define DELBOGUS    /* ask if bogus newsgroups should be deleted */
  316. #define RELOCATE    /* allow newsgroup rearranging */
  317. #define ESCSUBS        /* escape substitutions in multi-character commands */
  318. #define DELAYMARK    /* allow articles to be temporarily marked as read */
  319.             /* until exit from current newsgroup or Y command */
  320. #define MCHASE        /* unmark xrefed articles on m or M */
  321. #define MUNGHEADER    /* allow alternate header formatting via */
  322.             /* environment variable ALTHEADER (not impl) */
  323. #define ASYNC_PARSE    /* allow parsing headers asyncronously to reading */
  324.             /* used by MCHASE and MUNGHEADER */
  325. #define FINDNEWNG    /* check for new newsgroups on startup */
  326. #define FASTNEW        /* do optimizations on FINDNEWNG for faster startup */
  327.             /* (this optimization can make occasional mistakes */
  328.             /* if a group is removed and another group of the */
  329.             /* same length is added, and if no softpointers are */
  330.             /* affected by said change.) */
  331. #define INNERSEARCH    /* search command 'g' with article */
  332. #define CATCHUP        /* catchup command at newsgroup level */
  333. #define NGSEARCH    /* newsgroup pattern matching */
  334. #define ONLY        /* newsgroup restrictions by pattern */
  335. #define KILLFILES    /* automatic article killer files */
  336. #define ARTSEARCH    /* pattern searches among articles */
  337.             /* /, ?, ^N, ^P, k, K */
  338.  
  339. /* some dependencies among options */
  340.  
  341. #ifndef ARTSEARCH
  342. #   undef KILLFILES
  343. #   undef INNERSEARCH
  344. #   undef CACHESUBJ
  345. #endif
  346.  
  347. #ifndef DELAYMARK
  348. #   ifndef MCHASE
  349. #    ifndef MUNGHEADER
  350. #        undef ASYNC_PARSE
  351. #    endif
  352. #   endif
  353. #endif
  354.  
  355. #ifndef SETUIDGID
  356. #   define eaccess access
  357. #endif
  358.  
  359. #ifdef ONLY                /* idiot lint doesn't grok #if */
  360. #   define NGSORONLY
  361. #else
  362. #   ifdef NGSEARCH
  363. #    define NGSORONLY
  364. #   endif
  365. #endif
  366.  
  367. #ifdef VERBOSE
  368. #   ifdef TERSE
  369. #    define IF(c) if (c)
  370. #    define ELSE else
  371. #   else !TERSE
  372. #    define IF(c)
  373. #    define ELSE
  374. #   endif
  375. #else !VERBOSE
  376. #   ifndef TERSE
  377. #    define TERSE
  378. #   endif
  379. #   define IF(c) "IF" outside of VERBOSE???
  380. #   define ELSE "ELSE" outside of VERBOSE???
  381. #endif
  382.  
  383. #ifdef DEBUGGING
  384. #   define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\n", __FILE__, __LINE__);sig_catcher(0);}}
  385. #else
  386. #   define assert(ex) ;
  387. #endif
  388.  
  389. #ifdef SPEEDOVERMEM
  390. #   define OFFSET(x) (x)
  391. #else
  392. #   define OFFSET(x) ((x)-absfirst)
  393. #endif
  394.  
  395. /* If you're strapped for space use the help messages in shell scripts */
  396. /* if {NG,ART,PAGER,SUBS}HELP is undefined, help messages are in memory */
  397. #ifdef MEMHELP  /* undef MEMHELP above to get them all as sh scripts */
  398. #   undef NGHELP
  399. #   undef ARTHELP
  400. #   undef PAGERHELP
  401. #   undef SUBSHELP
  402. #else
  403. #   ifndef NGHELP            /* % and ~ */
  404. #    define NGHELP "%X/ng.help"
  405. #   endif
  406. #   ifndef ARTHELP            /* % and ~ */
  407. #    define ARTHELP "%X/art.help"
  408. #   endif
  409. #   ifndef PAGERHELP        /* % and ~ */
  410. #    define PAGERHELP "%X/pager.help"
  411. #   endif
  412. #   ifndef SUBSHELP        /* % and ~ */
  413. #    define SUBSHELP "%X/subs.help"
  414. #   endif
  415. #endif
  416.  
  417. #ifdef CLEAREOL
  418. #   define TCSIZE 512    /* capacity for termcap strings */
  419. #else
  420. #   ifdef pdp11
  421. #    define TCSIZE 256    /* capacity for termcap strings */
  422. #   else
  423. #    define TCSIZE 512    /* capacity for termcap srings */
  424. #   endif
  425. #endif
  426.  
  427. /* Additional ideas:
  428.  *    Make the do_newsgroup() routine a separate process.
  429.  *    Keep .newsrc on disk instead of in memory.
  430.  *    Overlays, if you have them.
  431.  *    Get a bigger machine.
  432.  */
  433.  
  434. /* End of Space Conservation Section */
  435.  
  436. /* More System Dependencies */
  437.  
  438. /* news library */
  439. #ifndef LIB        /* ~ and %l only ("~%l" is permissable) */
  440. #   define LIB "/usr/lib/news"
  441. #endif
  442.  
  443. /* path to private executables */
  444. #ifndef RNLIB        /* ~, %x and %l only */
  445. #   define RNLIB "%x/rn"
  446. #endif
  447.  
  448. /* system-wide RNINIT switches */
  449. #ifndef GLOBINIT
  450. #   define GLOBINIT "%X/INIT"
  451. #endif
  452.  
  453. /* where to find news files */
  454. #ifndef SPOOL            /* % and ~ */
  455. #   define SPOOL "/usr/spool/news"
  456. #endif
  457.  
  458. /* file containing list of active newsgroups and max article numbers */
  459. #ifndef ACTIVE            /* % and ~ */
  460. #   define ACTIVE "%x/active"
  461. #endif
  462.  
  463. /* location of history file */
  464. #ifndef ARTFILE            /* % and ~ */
  465. #    define ARTFILE "%x/history"
  466. #endif
  467.  
  468. /* command to setup a new .newsrc */
  469. #ifndef NEWSETUP        /* % and ~ */
  470. #   define NEWSETUP "newsetup"
  471. #endif
  472.  
  473. /* command to display a list of un-subscribed-to newsgroups */
  474. #ifndef NEWSGROUPS        /* % and ~ */
  475. #   define NEWSGROUPS "newsgroups"
  476. #endif
  477.  
  478. /* preferred shell for use in doshell routine */
  479. /*  ksh or sh would be okay here */
  480. #ifndef PREFSHELL
  481. #   define PREFSHELL "/bin/csh"
  482. #endif
  483.  
  484. /* path to fastest starting shell */
  485. #ifndef SH
  486. #   define SH "/bin/sh"
  487. #endif
  488.  
  489. /* path to default editor */
  490. #ifndef DEFEDITOR
  491. #   define DEFEDITOR "/usr/ucb/vi"
  492. #endif
  493.  
  494. /* location of macro file */
  495. #ifndef RNMACRO
  496. #   ifdef PUSHBACK
  497. #    define RNMACRO "%./.rnmac"
  498. #   endif
  499. #endif
  500.  
  501. /* location of full name */
  502. #ifndef FULLNAMEFILE
  503. #   ifndef PASSNAMES
  504. #    define FULLNAMEFILE "%./.fullname"
  505. #   endif
  506. #endif
  507.  
  508. /* virtual array file name template */
  509. #ifndef VARYNAME        /* % and ~ */
  510. #   define VARYNAME "/tmp/rnvary.%$"
  511. #endif
  512.  
  513. /* file to pass header to followup article poster */
  514. #ifndef HEADNAME        /* % and ~ */
  515. #   define HEADNAME "%./.rnhead"
  516. /* or alternately #define HEADNAME "/tmp/rnhead.%$" */
  517. #endif
  518.  
  519. /* temporary file for addng.c */
  520. #ifndef RNEWTMP
  521. #define RNEWTMP "/tmp/rnew.%$"
  522. #endif
  523.  
  524. #ifndef MAKEDIR
  525. /* shell script to make n-deep subdirectories */
  526. #   ifndef DIRMAKER        /* % and ~ */
  527. #    define DIRMAKER "%X/makedir"
  528. #   endif
  529. #endif
  530.  
  531. /* location of newsrc file */
  532. #ifndef RCNAME        /* % and ~ */
  533. #   define RCNAME "%./.newsrc"
  534. #endif
  535.  
  536. /* temporary newsrc file in case we crash while writing out */
  537. #ifndef RCTNAME        /* % and ~ */
  538. #   define RCTNAME "%./.newnewsrc"
  539. #endif
  540.  
  541. /* newsrc file at the beginning of this session */
  542. #ifndef RCBNAME        /* % and ~ */
  543. #   define RCBNAME "%./.oldnewsrc"
  544. #endif
  545.  
  546. /* if existent, contains process number of current or crashed rn */
  547. #ifndef LOCKNAME        /* % and ~ */
  548. #   define LOCKNAME "%./.rnlock"
  549. #endif
  550.  
  551. /* information from last invocation of rn */
  552. #ifndef LASTNAME        /* % and ~ */
  553. #   define LASTNAME "%./.rnlast"
  554. #endif
  555.  
  556. /* file with soft pointers into the active file */
  557. #ifndef SOFTNAME        /* % and ~ */
  558. #   define SOFTNAME "%./.rnsoft"
  559. #endif
  560.  
  561. /* list of article numbers to mark as unread later (see M and Y cmmands) */
  562. #ifndef RNDELNAME        /* % and ~ */
  563. #   define RNDELNAME "%./.rndelay"
  564. #endif
  565.  
  566. /* a motd-like file for rn */
  567. #ifndef NEWSNEWSNAME        /* % and ~ */
  568. #   define NEWSNEWSNAME "%X/newsnews"
  569. #endif
  570.  
  571. /* command to send a reply */
  572. #ifndef MAILPOSTER        /* % and ~ */
  573. #   define MAILPOSTER "Rnmail -h %h"
  574. #endif
  575.  
  576. #ifdef INTERNET
  577. #   ifndef MAILHEADER        /* % */
  578. #    ifdef CONDSUB
  579. #        define MAILHEADER "To: %t\nSubject: Re: %S\nNewsgroups: %n\nIn-Reply-To: %i\n%(%[references]!=^$?References\\: %[references]\n)Organization: %o\nCc: \nBcc: \n\n"
  580. #    else
  581. #        define MAILHEADER "To: %t\nSubject: Re: %S\nNewsgroups: %n\nIn-Reply-To: %i\nReferences: %[references]\nCc: \nBcc: \n\n"
  582. #    endif
  583. #   endif
  584. #else
  585. #   ifndef MAILHEADER        /* % */
  586. #    ifdef CONDSUB
  587. #        define MAILHEADER "To: %T\nSubject: %(%i=^$?:Re: %S\nNewsgroups: %n\nIn-Reply-To: %i)\n%(%[references]!=^$?References\\: %[references]\n)Organization: %o\nCc: \nBcc: \n\n"
  588. #    else
  589. #        define MAILHEADER "To: %T\nSubject: Re: %S\nNewsgroups: %n\nIn-Reply-To: %i\nReferences: %[references]\nCc: \nBcc: \n\n"
  590. #    endif
  591. #   endif
  592. #endif
  593.  
  594. #ifndef YOUSAID            /* % */
  595. #   define YOUSAID "In article %i you write:"
  596. #endif
  597.  
  598. /* command to submit a followup article */
  599. #ifndef NEWSPOSTER        /* % and ~ */
  600. #   define NEWSPOSTER "Pnews -h %h"
  601. #endif
  602.  
  603. #ifndef NEWSHEADER        /* % */
  604. #   ifdef CONDSUB
  605. #ifdef INTERNET
  606. #    define NEWSHEADER "Newsgroups: %(%F=^$?%C:%F)\nSubject: %(%S=^$?%\"\n\nSubject: \":Re: %S)\nSummary: \nExpires: \n%(%R=^$?:References: %R\n)Followup-To: \nDistribution: %(%i=^$?%\"Distribution: \":%D)\nOrganization: %o\nKeywords: %[keywords]\n\n"
  607. #else
  608. #    define NEWSHEADER "Newsgroups: %(%F=^$?%C:%F)\nSubject: %(%S=^$?%\"\n\nSubject: \":Re: %S)\nSummary: \nExpires: \n%(%R=^$?:References: %R\n)Reply-To: %L@%H.UUCP (%N)\nFollowup-To: \nDistribution: %(%i=^$?%\"Distribution: \":%D)\nOrganization: %o\nKeywords: %[keywords]\n\n"
  609. #endif
  610. #   else
  611. #    ifdef INTERNET
  612. #        define NEWSHEADER "Newsgroups: %F\nSubject: Re: %S\nSummary: \nExpires: \nReferences: %R\nFollowup-To: \nDistribution: %D\nOrganization: %o\nKeywords: %[keywords]\n\n"
  613. #    else
  614. #        define NEWSHEADER "Newsgroups: %F\nSubject: Re: %S\nSummary: \nExpires: \nReferences: %R\nReply-To:%L@%H.UUCP (%N)\nFollowup-To: \nDistribution: %D\nOrganization: %o\nKeywords: %[keywords]\n\n"
  615. #    endif
  616. #   endif
  617. #endif
  618.  
  619. #ifndef ATTRIBUTION        /* % */
  620. #   define ATTRIBUTION "In article %i %f writes:"
  621. #endif
  622.  
  623. #ifndef PIPESAVER        /* % */
  624. #   ifdef CONDSUB
  625. #       ifdef SERVER
  626. #               define PIPESAVER "%(%B=^0$?<%P/rrn%a.%$:tail +%Bc %P/rrn%a.%$ |) %b"
  627. #       else
  628. #        define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b"
  629. #    endif
  630. #   else
  631. #       ifdef SERVER
  632. #               define PIPESAVER "tail +%Bc %P/rrn%a.%$ | %b"
  633. #       else
  634. #        define PIPESAVER "tail +%Bc %A | %b"
  635. #    endif
  636. #   endif
  637. #endif
  638.  
  639. #ifndef NORMSAVER        /* % and ~ */
  640. #    ifdef SERVER
  641. #    define NORMSAVER "%X/norm.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\""
  642. #    else
  643. #       define NORMSAVER "%X/norm.saver %A %P %c %a %B %C \"%b\""
  644. #    endif
  645. #endif
  646.  
  647. #ifndef MBOXSAVER        /* % and ~ */
  648. #   ifdef MININACT        /* 2.10.2 site? */
  649. #       ifdef SERVER
  650. #           define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\" \"From %T %`date`\""
  651. #       else
  652. #        define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`date`\""
  653. #    endif SERVER
  654. #   else
  655. #    ifdef CONDSUB
  656. #           ifdef SERVER
  657. #               define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\
  658. " \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?
  659. %1 %3 %(%2=..?%2: %2) %5 19%4)\""
  660. #           else
  661. #            define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?%1 %3 %(%2=..?%2: %2) %5 19%4)\""
  662. #        endif
  663.                     /* header munging with a vengeance */
  664. #    else
  665. #           ifdef SERVER
  666. #               define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\" \"From %T %[posted]\""
  667. #           else
  668. #            define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\""
  669. #        endif
  670. #    endif
  671. #   endif
  672. #endif
  673.  
  674. #ifdef MKDIRS
  675.  
  676. #   ifndef SAVEDIR            /* % and ~ */
  677. #    define SAVEDIR "%p/%c"
  678. #   endif
  679. #   ifndef SAVENAME        /* % */
  680. #    define SAVENAME "%a"
  681. #   endif
  682.  
  683. #else
  684.  
  685. #   ifndef SAVEDIR            /* % and ~ */
  686. #    define SAVEDIR "%p"
  687. #   endif
  688. #   ifndef SAVENAME        /* % */
  689. #    define SAVENAME "%^C"
  690. #   endif
  691.  
  692. #endif
  693.  
  694. #ifndef KILLGLOBAL        /* % and ~ */
  695. #   define KILLGLOBAL "%p/KILL"
  696. #endif
  697.  
  698. #ifndef KILLLOCAL        /* % and ~ */
  699. #   define KILLLOCAL "%p/%c/KILL"
  700. #endif
  701.  
  702. /* how to cancel an article */
  703. #ifndef CANCEL
  704. #   ifdef MININACT            /* 2.10.2 ? */
  705. #    define CANCEL "%x/inews -h < %h"
  706. #   else
  707. #    define CANCEL "inews -h < %h"
  708. #   endif
  709. #endif
  710.  
  711. /* how to cancel an article, continued */
  712. #ifndef CANCELHEADER
  713. #ifdef INTERNET
  714. #   define CANCELHEADER "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nDistribution: %D\nOrganization: %o\n\nThis message was cancelled from within rn.\n"
  715. #else
  716. #   define CANCELHEADER "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nReply-To: %L@%H.UUCP (%N)\nDistribution: %D\nOrganization: %o\n"
  717. #endif
  718. #endif
  719.  
  720. /* where to find the mail file */
  721. #ifndef MAILFILE
  722. #   define MAILFILE "/usr/spool/mail/%L"
  723. #endif
  724.  
  725. /* some important types */
  726.  
  727. typedef int        NG_NUM;        /* newsgroup number */
  728. typedef long        ART_NUM;    /* article number */
  729. #ifdef pdp11
  730.     typedef short    ART_UNREAD;    /* ordinarily this should be long */
  731.                     /* like ART_NUM, but assuming that */
  732.                     /* we stay less than 32767 articles */
  733.                     /* behind saves a lot of space. */
  734.                     /* NOTE: do not make unsigned. */
  735. #else
  736.     typedef long    ART_UNREAD;
  737. #endif
  738. #ifdef SERVER
  739. typedef int        ART_PART;    /* for passing to nntpopen() */
  740. #endif
  741. typedef long        ART_POS;    /* char position in article file */
  742. typedef int        ART_LINE;    /* line position in article file */
  743. typedef long        ACT_POS;    /* char position in active file */
  744. typedef unsigned int    MEM_SIZE;    /* for passing to malloc */
  745.  
  746.  
  747. /* *** end of the machine dependent stuff *** */
  748.  
  749. /* GLOBAL THINGS */
  750.  
  751. /* file statistics area */
  752.  
  753. EXT struct stat filestat;
  754.  
  755. /* various things of type char */
  756.  
  757. char    *index();
  758. char    *rindex();
  759. char    *getenv();
  760. char    *strcat();
  761. char    *strcpy();
  762.  
  763. EXT char buf[LBUFLEN+1];    /* general purpose line buffer */
  764. EXT char cmd_buf[CBUFLEN];    /* buffer for formatting system commands */
  765.  
  766. EXT char *indstr INIT(">");    /* indent for old article embedded in followup */
  767.  
  768. EXT char *cwd INIT(Nullch);        /* current working directory */
  769. EXT char *dfltcmd INIT(Nullch);    /* 1st char is default command */
  770.  
  771. /* switches */
  772.  
  773. #ifdef DEBUGGING
  774.     EXT int debug INIT(0);                /* -D */
  775. #   define DEB_HEADER 4
  776. #   define DEB_INTRP 8
  777. #   define DEB_INNERSRCH 32 
  778. #   define DEB_FILEXP 64 
  779. #   define DEB_HASH 128
  780. #   define DEB_XREF_MARKER 256
  781. #   define DEB_CTLAREA_BITMAP 512
  782. #   define DEB_SOFT_POINTERS 1024
  783. #   define DEB_NEWSRC_LINE 2048
  784. #   define DEB_SEARCH_AHEAD 4096
  785. #   define DEB_CHECKPOINTING 8192
  786. #   define DEB_FEED_XREF 16384
  787. #endif
  788.  
  789. #ifdef ARTSEARCH
  790.     EXT int scanon INIT(0);                /* -S */
  791. #endif
  792.  
  793. EXT bool mbox_always INIT(FALSE);            /* -M */
  794. EXT bool norm_always INIT(FALSE);            /* -N */
  795. EXT bool checkflag INIT(FALSE);            /* -c */
  796. EXT bool suppress_cn INIT(FALSE);            /* -s */
  797. EXT int countdown INIT(5);    /* how many lines to list before invoking -s */
  798. EXT bool muck_up_clear INIT(FALSE);            /* -loco */
  799. EXT bool erase_screen INIT(FALSE);            /* -e */
  800. #ifdef CLEAREOL
  801. EXT bool can_home_clear INIT(FALSE);        /* fancy -e -- PWP */
  802. #endif CLEAREOL
  803. EXT bool findlast INIT(FALSE);            /* -r */
  804. EXT bool typeahead INIT(FALSE);            /* -T */
  805. #ifdef VERBOSE
  806. #   ifdef TERSE
  807.     EXT bool verbose INIT(TRUE);            /* +t */
  808. #   endif
  809. #endif
  810. #ifdef VERIFY
  811.     EXT bool verify INIT(FALSE);            /* -v */
  812. #endif
  813.     EXT bool quickstart INIT(FALSE);            /* -q */
  814.  
  815. #define NOMARKING 0
  816. #define STANDOUT 1
  817. #define UNDERLINE 2
  818. EXT int marking INIT(NOMARKING);            /* -m */
  819.  
  820. EXT ART_LINE initlines INIT(0);        /* -i */
  821. EXT bool initlines_specified INIT(FALSE);
  822.  
  823. /* miscellania */
  824.  
  825. int fseek();
  826. long atol(), ftell();
  827. EXT bool in_ng INIT(FALSE);        /* current state of rn */
  828. EXT char mode INIT('i');        /* current state of rn */
  829.  
  830. EXT FILE *tmpfp INIT(Nullfp);    /* scratch fp used for .rnlock, .rnlast, etc. */
  831.  
  832. EXT NG_NUM nextrcline INIT(0);    /* 1st unused slot in rcline array */
  833.             /* startup to avoid checking twice in a row */
  834.  
  835. extern errno;
  836.  
  837. /* Factored strings */
  838.  
  839. EXT char nullstr[] INIT("");
  840. EXT char sh[] INIT(SH);
  841. EXT char defeditor[] INIT(DEFEDITOR);
  842. EXT char hforhelp[] INIT("Type h for help.\n");
  843. #ifdef STRICTCR
  844. EXT char badcr[] INIT("\nUnnecessary CR ignored.\n");
  845. #endif
  846. EXT char readerr[] INIT("rn read error");
  847. EXT char unsubto[] INIT("\n\nUnsubscribed to newsgroup %s\n");
  848. EXT char cantopen[] INIT("Can't open %s\n");
  849. EXT char cantcreate[] INIT("Can't create %s\n");
  850.  
  851. #ifdef VERBOSE
  852.     EXT char nocd[] INIT("Can't chdir to directory %s\n");
  853. #else
  854.     EXT char nocd[] INIT("Can't find %s\n");
  855. #endif
  856.  
  857. #ifdef NOLINEBUF
  858. #define FLUSH ,fflush(stdout)
  859. #else
  860. #define FLUSH
  861. #endif
  862.  
  863. #ifdef lint
  864. #undef FLUSH
  865. #define FLUSH
  866. #undef putchar
  867. #define putchar(c)
  868. #endif
  869.