home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UUPC11XT.ZIP / RN / COMMON.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-21  |  26.5 KB  |  883 lines

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