home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1465 < prev    next >
Internet Message Format  |  1990-12-28  |  63KB

  1. From: sob@lib.tmc.edu (Stan Barber)
  2. Newsgroups: alt.sources
  3. Subject: rrn/rn combo kit part 8 of 9
  4. Message-ID: <434@lib.tmc.edu>
  5. Date: 14 Jun 90 03:29:24 GMT
  6.  
  7. #! /bin/sh
  8.  
  9. # Make a new directory for the rn sources, cd to it, and run kits 1 thru 9 
  10. # through sh.  When all 9 kits have been run, read README.
  11.  
  12. echo "This is rn kit 8 (of 9).  If kit 8 is complete, the line"
  13. echo '"'"End of kit 8 (of 9)"'" will echo at the end.'
  14. echo ""
  15. export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
  16. echo Extracting MANIFEST
  17. cat >MANIFEST <<'!STUFFY!FUNK!'
  18. After all the rn kits are run you should have the following files:
  19.  
  20. Filename    Kit Description
  21. --------    --- -----------
  22. Configure        2  A shell script that installs everything system dependent.
  23. EXTERN.h         9  When included, makes other includes not belong to me.
  24. HACKERSGUIDE     8  A brief guide to the contorted innards of rn.
  25. INIT             5  Sample system-wide switch file. (NEW)
  26. INTERN.h         9  When included, makes other includes belong to me.
  27. MANIFEST         8  This list of files.
  28. Makefile.SH      8  The makefile.
  29. NEW              8  List of new features with 4.3 rn.
  30. Pnews.1          8  Manual page for Pnews.
  31. Pnews.SH         6  A news posting shell script that knows about -h.
  32. README           8  Installation instructions.
  33. Rnmail.1         8  Manual page for Rnmail.
  34. Rnmail.SH        7  A mailer that knows about -h.
  35. Wishlist         9  What the next version wants in it.
  36. addng.c          1  Routines for scanning the active file for new newsgroups.
  37. addng.h          9  Public info regarding addng.c.
  38. art.c            5  Routines to display an article.
  39. art.h            7  Public info regarding art.c.
  40. art.help.SH      8  Shell script for help at the article level.
  41. artio.c          8  Reserved for the article abstract type, someday.
  42. artio.h          9  Public info regarding artio.c.
  43. artsrch.c        7  Routines for searching among articles.
  44. artsrch.h        4  Public info regarding artsrch.c.
  45. artstate.h       9  Info on the current state of the article.
  46. backpage.c       9  Routines for paging backwards in articles.
  47. backpage.h       9  Public info regarding backpage.c.
  48. bits.c           5  Bitmap management functions.
  49. bits.h           9  Public info regarding bits.c.
  50. cheat.c          8  Routines to do lookahead of several types.
  51. cheat.h          9  Public info regarding cheat.c.
  52. common.h         3  Global info.
  53. final.c          8  Finalization (exit) routines.
  54. final.h          9  Public info regarding final.c.
  55. getactive.c      9  Program used by shell scripts to the active file (RRN only)
  56. head.c           7  Header parsing routines.
  57. head.h           8  Public info regarding head.c.
  58. help.c           7  Help routines.
  59. help.h           9  Public info regarding help.c.
  60. init.c           7  Initialization (startup) routines.
  61. init.h           9  Public info regarding init.c.
  62. intrp.c          4  Filename expansion and % interpretation routines.
  63. intrp.h          9  Public info regarding intrp.c.
  64. kfile.c          7  KILL file routines.
  65. kfile.h          9  Public info regarding kfile.c.
  66. kitleader        2  Shell script to produce front of kit.
  67. kitlists.c       9  Knapsack packer.
  68. kittrailer       9  Shell script to produce end of kit.
  69. last.c           9  Routines for handling the .rnlast file.
  70. last.h           9  Public info regarding last.c.
  71. makedepend.SH    8  Shell script to generate make dependencies.
  72. makedir.SH       9  Shell script to make nested subdirectories.
  73. makedist         9  Shell script to make a distribution kit.
  74. makekit          9  Shell script to make a kit file.
  75. manifake         9  Shell script to make MANIFEST.new file.
  76. manimake         9  Shell script to make MANIFEST file.
  77. mbox.saver.SH    9  Shell script to save an article to a mailbox.
  78. ndir.c           9  4.2 directory routine emulation.
  79. ndir.h           8  Public info regarding ndir.c.
  80. newsetup.1       6  Manual page for newsetup.
  81. newsetup.SH      8  Shell script to create a .newsrc file.
  82. newsgroups.1     9  Manual page for newsgroups.
  83. newsgroups.SH    8  Shell script to list unsubscribed newsgroups.
  84. newsnews.SH      9  A motd-like file that rn may print at startup.
  85. ng.c             3  Routines to display a newsgroup.
  86. ng.h             9  Public info regarding ng.c.
  87. ng.help.SH       9  Shell script to do newsgroup selection help.
  88. ngdata.c         7  General data fetching routines for a newsgroup.
  89. ngdata.h         9  Public info regarding ngdata.c.
  90. ngsrch.c         8  Routines to search among newsgroups.
  91. ngsrch.h         9  Public info regarding ngsrch.c.
  92. ngstuff.c        2  Support routines for ng.c.
  93. ngstuff.h        3  Public info regarding ng.c.
  94. norm.saver.SH    9  Shell script to save an article to a normal file.
  95. only.c           9  Routines to perform newsgroup restriction.
  96. only.h           9  Public info regarding only.c.
  97. pager.help.SH    9  Shell script for help at the pager level.
  98. patchlevel       2  Indicates current patch level.
  99. range.c          9  Used when rebuilding the rn kit.
  100. rcln.c           3  Routines to mung a .newsrc line.
  101. rcln.h           9  Public info regarding rcln.c.
  102. rcstuff.c        5  Routines to mung the .newsrc file.
  103. rcstuff.h        9  Public info regarding rcstuff.c.
  104. respond.c        6  Various routines for doing things with articles.
  105. respond.h        9  Public info regarding respond.c.
  106. rn.1             1  Manual pages for rn. PLEASE READ.
  107. rn.c             6  Main program.
  108. rn.h             9  Public info regarding rn.c.
  109. search.c         4  Regular expression processing ala emacs.
  110. search.h         9  Public info regarding search.c.
  111. subs.help.SH     9  Shell script for help for escape substitutions.
  112. sw.c             6  Switch processing routines.
  113. sw.h             9  Public info regarding switch.c.
  114. term.c           4  Terminal interface routines.
  115. term.h           7  Public info regarding term.c.
  116. util.c           6  Utility routines.
  117. util.h           9  Public info regarding util.c.
  118. !STUFFY!FUNK!
  119. echo Extracting Makefile.SH
  120. cat >Makefile.SH <<'!STUFFY!FUNK!'
  121. case $CONFIG in
  122.     '') . ./config.sh ;;
  123. esac
  124. echo "Extracting Makefile (with variable substitutions)"
  125. cat >Makefile <<!GROK!THIS!
  126. # $Header: Makefile.SH,v 4.3.2.10 90/05/04 00:44:51 sob Exp $
  127. #
  128. # $Log:    Makefile.SH,v $
  129. # Revision 4.3.2.10  90/05/04  00:44:51  sob
  130. # Added socketlib to list of libs.
  131. # Revision 4.3.2.9  90/04/23  00:27:12  sob
  132. # Added better support for XENIX
  133. # Revision 4.3.2.8  89/12/20  23:20:14  sob
  134. # Added "hp-ux" to the list of files created by Configure.
  135. # Revision 4.3.2.7  89/12/09  01:49:48  sob
  136. # make clean cleans up better.
  137. # Revision 4.3.2.6  89/12/08  22:43:45  sob
  138. # Added suggestions by weening@gang-of-four.stanford.edu and 
  139. # jik@pit-manager.mit.edu. rrn manual page is now created when
  140. # doing an installation. getactive will only be made when rrn is being
  141. # created.
  142. # Revision 4.3.2.5  89/11/08  04:47:38  sob
  143. # Added VOIDSIG handling for SunOS 4.X
  144. # Revision 4.3.2.4  89/11/08  03:16:29  sob
  145. # Added server.h to list of things created by Configure
  146. # Revision 4.3.2.3  89/11/08  01:05:52  sob
  147. # Updated to work with RRN or RN
  148. # Revision 4.3.2.2  89/11/06  00:03:19  sob
  149. # Added RRN support originally distributed with NNTP 1.5
  150. # Revision 4.3.2.1  89/11/05  23:55:09  sob
  151. # RRN support branch
  152. #
  153. # Revision 4.3.1.2  85/05/13  17:21:18  lwall
  154. # System V make needs space before line-continuing backslash.
  155. # Revision 4.3.1.1  85/05/10  11:30:15  lwall
  156. # Branch for patches.
  157. # Revision 4.3  85/05/01  11:33:26  lwall
  158. # Baseline for release with 4.3bsd.
  159.  
  160. CC = $cc
  161. rnbin = $rnbin
  162. rnlib = $rnlib
  163. mansrc = $mansrc
  164. manext = $manext
  165. #NNTPNNTPDIR = $NNTPSRC
  166. #NNTPNNTPINC = $rrninclude
  167. CFLAGS = $iandd -O $include
  168. LDFLAGS = $iandd
  169. NDIRC = $ndirc
  170. NDIRO = $ndiro
  171.  
  172. libs = $ndirlib $termlib $jobslib $socketlib
  173. !GROK!THIS!
  174. cat >>Makefile <<'!NO!SUBS!'
  175. #NNTPnntp=getactive
  176. public = rn newsetup newsgroups Pnews Rnmail
  177. private = norm.saver mbox.saver ng.help art.help pager.help subs.help makedir filexp Pnews.header $(nntp)
  178. manpages = rn.1 Pnews.1 Rnmail.1 newsetup.1 newsgroups.1
  179. util = Makefile makedepend newsnews
  180.  
  181.  
  182. h1 = addng.h art.h artio.h artsrch.h backpage.h bits.h cheat.h common.h
  183. h2 = final.h head.h help.h init.h intrp.h kfile.h last.h ndir.h ng.h
  184. h3 = ngdata.h ngsrch.h ngstuff.h only.h rcln.h rcstuff.h
  185. h4 = respond.h rn.h search.h sw.h term.h util.h
  186. #NNTPh5 = server.h
  187.  
  188. h = $(h1) $(h2) $(h3) $(h4) $(h5)
  189.  
  190. c1 = addng.c art.c artio.c artsrch.c backpage.c bits.c cheat.c
  191. c2 = final.c head.c help.c init.c intrp.c kfile.c last.c $(NDIRC) ng.c
  192. c3 = ngdata.c ngsrch.c ngstuff.c only.c rcln.c rcstuff.c
  193. c4 = respond.c rn.c search.c sw.c term.c util.c
  194. #NNTPc5 = $(NNTPDIR)/common/clientlib.c
  195.  
  196. c = $(c1) $(c2) $(c3) $(c4) $(c5)
  197.  
  198. obj1 = addng.o art.o artio.o artsrch.o backpage.o bits.o cheat.o
  199. obj2 = final.o head.o help.o init.o intrp.o kfile.o last.o $(NDIRO) ng.o
  200. obj3 = ngdata.o ngsrch.o ngstuff.o only.o rcln.o rcstuff.o
  201. obj4 = respond.o rn.o search.o sw.o term.o util.o
  202. #NNTPobj5 =  $(NNTPDIR)/common/clientlib.o
  203.  
  204. obj = $(obj1) $(obj2) $(obj3) $(obj4) $(obj5)
  205.  
  206. lintflags = -phbvxac
  207.  
  208. add1 = Makefile.old Pnews Rnmail art.help
  209. add2 = bsd config.h config.sh eunice filexp
  210. add3 = loc makedepend makedir mbox.saver newsetup
  211. add4 = newsgroups newsnews ng.help norm.saver pager.help
  212. add5 = pdp11 rn subs.help usg v7 ultrix sun hp-ux sgi xenix server.h
  213.  
  214. addedbyconf = $(add1) $(add2) $(add3) $(add4) $(add5)
  215.  
  216. # grrr
  217. SHELL = /bin/sh
  218.  
  219. .c.o:
  220.     $(CC) -c $(CFLAGS) $*.c
  221.  
  222. all: $(public) $(private) $(util)
  223.     touch all
  224.  
  225. rn: $(obj)
  226.     $(CC) $(LDFLAGS) $(obj) $(libs) -o rn
  227.  
  228. #NNTPgetactive: getactive.o $(NNTPDIR)/common/clientlib.o
  229. #NNTP    $(CC) $(LDFLAGS) getactive.o $(NNTPDIR)/common/clientlib.o -o getactive $(libs)
  230.  
  231. # Eek! This is gross.
  232. $(NNTPDIR)/common/clientlib.o:
  233.     $(CC) -c $(CFLAGS) $(NNTPINC) $(NNTPDIR)/common/clientlib.c
  234.     mv clientlib.o $(NNTPDIR)/common/clientlib.o
  235.  
  236. # if a .h file depends on another .h file...
  237. $(h):
  238.     touch $@
  239.  
  240. install: rn
  241. # won't work with csh
  242.     export PATH || exit 1
  243.     - mv $(rnbin)/rn $(rnbin)/rn.old
  244. #NNTP    - ln -s rn $(rnbin)/rrn
  245.     - if test `pwd` != $(rnbin); then cp $(public) $(rnbin); fi
  246.     cd $(rnbin); chmod 755 $(public)
  247.     chmod 755 makedir
  248.     - ./makedir `./filexp $(rnlib)`
  249.     - if test `pwd` != `./filexp $(rnlib)`; then cp INIT $(private) `./filexp $(rnlib)`; fi
  250.     cd `./filexp $(rnlib)`; chmod 755 $(private)
  251.     - if test ! -f `./filexp $(rnlib)/newsnews`; then cp newsnews `./filexp $(rnlib)`; fi
  252.     - if test `pwd` != $(mansrc); then \
  253. for page in $(manpages); do \
  254. cp $$page $(mansrc)/`basename $$page .1`.$(manext); \
  255. done; \
  256. #NNTPecho ".so man$(manext)/rn.$(manext)" > $(mansrc)/rrn.$(manext) ; \
  257. fi
  258.  
  259. clean:
  260.     rm -f *.o
  261.  
  262. realclean:
  263.     rm -f rn *.o core $(addedbyconf) 
  264. #NNTP    rm -f $(NNTPDIR)/common/clientlib.o getactive
  265.  
  266. # The following lint has practically everything turned on.  Unfortunately,
  267. # you have to wade through a lot of mumbo jumbo that can't be suppressed.
  268. # If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
  269. # for that spot.
  270.  
  271. lint:
  272.     lint $(lintflags) $(defs) $(c) > rn.fuzz
  273.  
  274. depend:
  275.     ./makedepend
  276.  
  277. # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
  278. $(obj):
  279.     @ echo "You haven't done a "'"make depend" yet!'; exit 1
  280. !NO!SUBS!
  281. case "$isrrn" in
  282. define)  sed < Makefile -e '/^#NNTP/s/^#NNTP//' > Makefile.new ;;
  283. *) sed < Makefile -e '/^#NNTP/d' > Makefile.new ;;
  284. esac
  285. mv Makefile.new Makefile
  286. $eunicefix Makefile
  287. !STUFFY!FUNK!
  288. echo Extracting newsetup.SH
  289. cat >newsetup.SH <<'!STUFFY!FUNK!'
  290. case $CONFIG in
  291.     '') . ./config.sh ;;
  292. esac
  293. echo "Extracting newsetup (with variable substitutions)"
  294. $spitshell >newsetup <<!GROK!THIS!
  295. $startsh
  296.  
  297. # $Header: newsetup.SH,v 4.3.2.7 90/03/17 20:34:48 sob Exp $
  298. # $Log:    newsetup.SH,v $
  299. # Revision 4.3.2.7  90/03/17  20:34:48  sob
  300. # Remove the /tmp/n.* files created when generating the .newsrc.
  301. # Revision 4.3.2.6  90/03/17  17:26:42  sob
  302. # Some versions of sed only take 9 wfiles.
  303. # Revision 4.3.2.5  89/11/28  01:15:32  sob
  304. # Fixed a bug that caused the active file to be removed on non-NNTP-based
  305. # systems.
  306. # Revision 4.3.2.4  89/11/28  00:31:20  sob
  307. # Changed news.announce.newuser to news.announce.newusers.
  308. # Revision 4.3.2.3  89/11/08  01:13:15  sob
  309. # Finished modifications to make work with RN and RRN
  310. #
  311. # Revision 4.3.2.2  89/11/07  23:25:50  sob
  312. #
  313. # Added support such that RN and RRN can be made from the same sources.
  314. # Revision 4.3.1.2  86/09/05  15:41:04  lwall
  315. # Changes for newsgroup renaming.
  316. # Revision 4.3.1.1  85/05/10  11:35:43  lwall
  317. # Branch for patches.
  318. # Revision 4.3  85/05/01  11:43:05  lwall
  319. # Baseline for release with 4.3bsd.
  320.  
  321. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  322.  
  323. : syntax: newsetup
  324.  
  325. : System dependencies
  326. : You will want to change the definitions below to reflect the distribution
  327. : areas around you.  If you have more areas than this you will need to modify
  328. : the sed below.
  329.  
  330. locorg="$locpref"
  331. organization="$orgpref"
  332. city="$citypref"
  333. state="$statepref"
  334. cntry="$cntrypref"
  335. cont="$contpref"
  336. #NORMALactive="${active-/usr/lib/news/active}"
  337. #NNTPactive="/tmp/active.\$\$"
  338.  
  339. dotdir="\${DOTDIR-\${HOME-\$LOGDIR}}"
  340. $rm -f \$dotdir/.oldnewsrc
  341. $echo "Creating .newsrc in \$dotdir to be used by news programs."
  342. #NNTPrnlib=$rnlib
  343. #NNTPcase \$rnlib in
  344. #NNTP~*) rnlib=\`$filexp \$rnlib\` ;;
  345. #NNTPesac
  346. #NNTP\$rnlib/getactive \$active
  347. #NORMALcase \$active in
  348. #NORMAL~*) active=\`$filexp \$active\` ;;
  349. #NORMALesac
  350.  
  351. : NOTE: SED WILL NOT TAKE MORE THAN 9 WFILES, SO BEWARE   
  352.  
  353. $sort <\$active | $sed >/tmp/n.tmp\$\$    \\
  354.     -e 's/^\([^ ]*\) .*\$/\1:/'    \\
  355.     -e '/^control:/{'        \\
  356.      -e "  s/:/!/"    \\
  357.     -e "  w /tmp/n.test\$\$"    \\
  358.     -e '  d'            \\
  359.     -e '}'                \\
  360.     -e '/^junk:/{'            \\
  361.      -e "  s/:/!/"    \\
  362.     -e "  w /tmp/n.test\$\$"    \\
  363.     -e '  d'            \\
  364.     -e '}'                \\
  365.     -e '/test:/{'            \\
  366.      -e "  s/:/!/"    \\
  367.     -e "  w /tmp/n.test\$\$"    \\
  368.     -e '  d'            \\
  369.     -e '}'                \\
  370.     -e "/^\$locorg\./{"        \\
  371.     -e "  w /tmp/n.\$locorg\$\$"    \\
  372.     -e '  d'            \\
  373.     -e '}'                \\
  374.     -e "/^\$organization\./{"    \\
  375.     -e "  w /tmp/n.\$organization\$\$"    \\
  376.     -e '  d'            \\
  377.     -e '}'                \\
  378.     -e "/^\$city\./{"        \\
  379.     -e "  w /tmp/n.\$city\$\$"    \\
  380.     -e '  d'            \\
  381.     -e '}'                \\
  382.     -e "/^\$cntry\./{"         \\
  383.     -e "  w /tmp/n.\$cntry\$\$"    \\
  384.     -e '  d'            \\
  385.     -e '}'                \\
  386.     -e "/^\$state\./{"         \\
  387.     -e "  w /tmp/n.\$state\$\$"    \\
  388.     -e '  d'            \\
  389.     -e '}'
  390.  
  391. $sed </tmp/n.tmp\$\$ >/tmp/n.local\$\$    \\
  392.     -e "/^\$cont\./{"         \\
  393.     -e "  w /tmp/n.\$cont\$\$"    \\
  394.     -e '  d'            \\
  395.     -e '}'
  396.  
  397. $sed </tmp/n.tmp\$\$ >/tmp/n.local\$\$    \\
  398.     -e "/^to\./{"            \\
  399.     -e "  s/:/!/"    \\
  400.     -e "  w /tmp/n.to\$\$"        \\
  401.     -e '  d'            \\
  402.     -e '}'                \\
  403.     -e "/^comp\./{"            \\
  404.     -e "  w /tmp/n.comp\$\$"    \\
  405.     -e '  d'            \\
  406.     -e '}'                \\
  407.     -e "/^news\./{"            \\
  408.     -e "  w /tmp/n.news\$\$"    \\
  409.     -e '  d'            \\
  410.     -e '}'                \\
  411.     -e "/^rec\./{"            \\
  412.     -e "  w /tmp/n.rec\$\$"        \\
  413.     -e '  d'            \\
  414.     -e '}'                \\
  415.     -e "/^sci\./{"            \\
  416.     -e "  w /tmp/n.sci\$\$"        \\
  417.     -e '  d'            \\
  418.     -e '}'                \\
  419.     -e "/^soc\./{"            \\
  420.     -e "  w /tmp/n.soc\$\$"        \\
  421.     -e '  d'            \\
  422.     -e '}'                \\
  423.     -e "/\./{"            \\
  424.     -e "  w /tmp/n.misc\$\$"    \\
  425.     -e '  d'            \\
  426.     -e '}'
  427.  
  428.  
  429. if $test -s \$dotdir/.newsrc ; then
  430.     $echo "Saving your current .newsrc as .oldnewsrc..."
  431.     $mv -f \$dotdir/.newsrc \$dotdir/.oldnewsrc
  432. fi
  433.  
  434. : newsrc order determined here
  435.  
  436. $sed <\$active '
  437.     /^to\./d
  438.     s/ .*//
  439.     s/^/ /
  440.     s/^ '\$locorg'\./01&/
  441.     s/^ '\$organization'\./02&/
  442.     s/^ '\$city'\./03&/
  443.     s/^ '\$state'\./04&/
  444.     s/^ '\$cntry'\./05&/
  445.     s/^ '\$cont'\./06&/
  446.     s/^ news\./07&/
  447.     s/^ comp\./08&/
  448.     s/^ sci\./09&/
  449.     s/^ rec\./10&/
  450.     s/^ soc\./11&/
  451.     s/^ talk\./13&/
  452.     s/^ control\$/14&/
  453.     s/^ junk\$/14&/
  454.     s/^ test\$/14&/
  455.     /\.test\$/s/^[0-9]*/14/
  456.     s/^ .*\./12&/
  457.     s/^ /00&/
  458. ' |
  459. $sort -u |
  460. $sed '
  461.     /^14 /!s/\$/:/
  462.     /^14 /s/\$/!/
  463.     s/^[0-9][0-9] //
  464. ' >\$dotdir/.newsrc
  465.  
  466. #NNTP$rm -f \$active
  467. $rm -f /tmp/n.misc\$\$ /tmp/n.sci\$\$ /tmp/n.soc\$\$ /tmp/n.news\$\$ /tmp/n.comp\$\$
  468. $rm -f /tmp/n.\$cont\$\$ /tmp/n.\$city\$\$ /tmp/n.\$cntry\$\$ /tmp/n.\$state\$\$
  469. $rm -f /tmp/n.to\$\$ /tmp/n.\$organization\$\$ /tmp/n.\$locorg\$\$ /tmp/n.test\$\$
  470. $rm -f /tmp/n.tmp\$\$ /tmp/n.local\$\$ /tmp/n.rec\$\$
  471.  
  472. $cat <<'EOH'
  473. Done.
  474.  
  475. If you have never used the news system before, you may find the articles
  476. in news.announce.newusers to be helpful.  There is also a manual entry for rn.
  477.  
  478. To get rid of newsgroups you aren't interested in, use the 'u' command.
  479. Type h for help at any time while running rn.
  480. EOH
  481. !GROK!THIS!
  482. case "$isrrn" in
  483. define)  sed < newsetup -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsetup.new ;;
  484. *) sed < newsetup -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsetup.new ;;
  485. esac
  486. mv newsetup.new newsetup
  487. $eunicefix newsetup
  488. chmod 755 newsetup
  489. !STUFFY!FUNK!
  490. echo Extracting final.c
  491. cat >final.c <<'!STUFFY!FUNK!'
  492. /* $Header: final.c,v 4.3.2.8 90/04/14 19:37:14 sob Exp $
  493.  *
  494.  * $Log:    final.c,v $
  495.  * Revision 4.3.2.8  90/04/14  19:37:14  sob
  496.  * Added better support for the NeXT.
  497.  * 
  498.  * Revision 4.3.2.7  90/03/17  21:33:49  sob
  499.  * cleaned up a bit
  500.  * 
  501.  * Revision 4.3.2.6  90/03/17  16:48:25  sob
  502.  * Added changes to insure that rrn cleans up its temporary files when
  503.  * exiting.
  504.  * 
  505.  * Revision 4.3.2.5  89/11/28  01:51:28  sob
  506.  * Now handles SIGWINCH correctly.
  507.  * 
  508.  * Revision 4.3.2.4  89/11/27  01:30:24  sob
  509.  * Altered NNTP code per ideas suggested by Bela Lubkin
  510.  * <filbo@gorn.santa-cruz.ca.us>
  511.  * 
  512.  * Revision 4.3.2.3  89/11/08  02:25:07  sob
  513.  * Integrated modifications from other RRN patches colleceted from USENET
  514.  * 
  515.  * Revision 4.3.2.2  89/11/07  23:26:31  sob
  516.  * Added some fixes that relate to SIGSTP
  517.  * 
  518.  * Revision 4.3.2.1  89/11/06  00:16:08  sob
  519.  * Added RRN support from NNTP 1.5
  520.  *
  521.  * Revision 4.3  85/05/01  11:38:08  lwall
  522.  * Baseline for release with 4.3bsd.
  523.  * 
  524.  */
  525.  
  526. #include "EXTERN.h"
  527. #include "common.h"
  528. #include "util.h"
  529. #include "term.h"
  530. #include "ng.h"
  531. #include "init.h"
  532. #include "bits.h"
  533. #include "last.h"
  534. #include "rcstuff.h"
  535. #include "ngdata.h"
  536. #include "artio.h"
  537. #include "INTERN.h"
  538. #include "final.h"
  539.  
  540. void
  541. final_init()
  542. {
  543. #ifdef SIGTSTP
  544.     sigset(SIGTSTP, stop_catcher);    /* job control signals */
  545.     sigset(SIGTTOU, stop_catcher);    /* job control signals */
  546.     sigset(SIGTTIN, stop_catcher);    /* job control signals */
  547. #endif
  548.  
  549.     sigset(SIGINT, int_catcher);    /* always catch interrupts */
  550.     sigset(SIGHUP, sig_catcher);    /* and hangups */
  551. #ifndef lint
  552.     sigignore(SIGEMT);
  553. #endif lint
  554.  
  555.     sigset(SIGILL, sig_catcher);
  556.     sigset(SIGTRAP, sig_catcher);
  557.     sigset(SIGFPE, sig_catcher);
  558.     sigset(SIGBUS, sig_catcher);
  559.     sigset(SIGSEGV, sig_catcher);
  560.     sigset(SIGSYS, sig_catcher);
  561.     sigset(SIGTERM, sig_catcher);
  562. #ifdef SIGXCPU
  563.     sigset(SIGXCPU, sig_catcher);
  564. #endif
  565. #ifdef SIGXFSZ
  566.     sigset(SIGXFSZ, sig_catcher);
  567. #endif
  568. #ifdef SIGWINCH
  569.     sigset(SIGWINCH, winch_catcher);
  570. #endif
  571. }
  572.  
  573. void                    /* very much void */
  574. finalize(status)
  575. int status;
  576. {
  577. #ifdef SERVER
  578.     char artname[32];
  579. #endif SERVER
  580.  
  581.     if (bizarre)
  582.     resetty();
  583.     if (lockname && *lockname)
  584.      UNLINK(lockname);
  585. #ifdef SERVER
  586.     if (*active_name)
  587.     UNLINK(active_name);
  588.     if (openart) {
  589.      char artname[32];
  590.      sprintf(artname, "/tmp/rrn%ld.%d", (long)openart, getpid());
  591.      UNLINK(artname);
  592.     }
  593.     close_server();
  594. #endif SERVER
  595.     if (status < 0) {
  596.     chdir("/usr/tmp");
  597.     sigset(SIGILL,SIG_DFL);
  598.     abort();
  599.     }
  600.     exit(status);
  601. }
  602.  
  603. /* come here on interrupt */
  604.  
  605. int
  606. int_catcher()
  607. {
  608.     sigset(SIGINT,int_catcher);
  609. #ifdef DEBUGGING
  610.     if (debug)
  611.     write(2,"int_catcher\n",12);
  612. #endif
  613.     if (!waiting) {
  614.     if (int_count) {        /* was there already an interrupt? */
  615.         write(2,"\nBye-bye.\n",10);
  616.         sig_catcher(0);        /* emulate the other signals */
  617.     }
  618.     int_count++;
  619.     }
  620. }
  621.  
  622. /* come here on signal other than interrupt, stop, or cont */
  623.  
  624. int
  625. sig_catcher(signo)
  626. {
  627. #ifdef VERBOSE
  628.     static char *signame[] = {
  629.     "",
  630.     "HUP",
  631.     "INT",
  632.     "QUIT",
  633.     "ILL",
  634.     "TRAP",
  635.     "IOT",
  636.     "EMT",
  637.     "FPE",
  638.     "KILL",
  639.     "BUS",
  640.     "SEGV",
  641.     "SYS",
  642.     "PIPE",
  643.     "ALRM",
  644.     "TERM",
  645.     "???"
  646. #ifdef SIGTSTP
  647.     ,"STOP",
  648.     "TSTP",
  649.     "CONT",
  650.     "CHLD",
  651.     "TTIN",
  652.     "TTOU",
  653.     "TINT",
  654.     "XCPU",
  655.     "XFSZ"
  656. #ifdef SIGPROF
  657.     ,"VTALARM",
  658.     "PROF"
  659. #endif
  660. #endif
  661.     };
  662. #endif
  663.  
  664. #ifdef DEBUGGING
  665.     if (debug) {
  666.     printf("\nSIG%s--.newsrc not restored in debug\n",signame[signo]);
  667.     finalize(-1);
  668.     }
  669. #endif
  670.     if (panic)
  671.     abort();
  672.     (void) sigset(SIGILL,SIG_DFL);
  673.     panic = TRUE;            /* disable terminal I/O */
  674.     if (doing_ng) {            /* need we reconstitute rc line? */
  675.     yankback();
  676.     restore_ng();            /* then do so (hope this works) */
  677.     }
  678.     doing_ng = FALSE;
  679.     if (rc_changed)            /* need we write .newsrc out? */
  680.     write_rc();            /* then do so */
  681.     rc_changed = FALSE;
  682.     if (signo != SIGHUP)
  683. #ifdef VERBOSE
  684.     IF(verbose)
  685.         printf("\nCaught %s%s--.newsrc restored\n",
  686.         signo ? "a SIG" : "an internal error", signame[signo]);
  687.     ELSE
  688. #endif
  689. #ifdef TERSE
  690.         printf("\nSignal %d--bye bye\n",signo);
  691. #endif
  692.     switch (signo) {
  693.     case SIGBUS:
  694.     case SIGILL:
  695.     case SIGSEGV:
  696.     finalize(-signo);
  697.     }
  698.     finalize(1);                /* and blow up */
  699. }
  700.  
  701. #ifdef SIGTSTP
  702. /* come here on stop signal */
  703.  
  704. int
  705. stop_catcher(signo)
  706. int signo;
  707. {
  708.     if (!waiting) {
  709.     checkpoint_rc();        /* good chance of crash while stopped */
  710.     resetty();            /* this is the point of all this */
  711. #ifdef DEBUGGING
  712.     if (debug)
  713.         write(2,"stop_catcher\n",13);
  714. #endif
  715.     sigset(signo,SIG_DFL);    /* enable stop */
  716. #ifdef SIGBLOCK
  717.     sigsetmask(sigblock(0) & ~(1 << (signo-1)));
  718. #endif
  719.     kill(0,signo);        /* and do the stop */
  720.         savetty();
  721. #ifdef MAILCALL
  722.         mailcount = 0;            /* force recheck */
  723. #endif
  724.         if (!panic) {
  725.         if (!waiting) {
  726.             noecho();            /* set no echo */
  727.             crmode();            /* set cbreak mode */
  728.             forceme("\f");        /* cause a refresh */
  729.                     /* (defined only if TIOCSTI defined) */
  730.         errno = 0;            /* needed for getcmd */
  731.         }
  732.         }
  733.     }
  734.     sigset(signo,stop_catcher);    /* unenable the stop */
  735. }
  736. #endif
  737. !STUFFY!FUNK!
  738. echo Extracting artio.c
  739. cat >artio.c <<'!STUFFY!FUNK!'
  740. /* $Header: artio.c,v 4.3.2.5 90/03/22 23:04:04 sob Exp $
  741.  *
  742.  * $Log:    artio.c,v $
  743.  * Revision 4.3.2.5  90/03/22  23:04:04  sob
  744.  * Fixes provided by Wayne Davison <drivax!davison>
  745.  * 
  746.  * Revision 4.3.2.4  89/11/27  01:29:57  sob
  747.  * Altered NNTP code per ideas suggested by Bela Lubkin
  748.  * <filbo@gorn.santa-cruz.ca.us>
  749.  * 
  750.  * Revision 4.3.2.3  89/11/26  22:55:31  sob
  751.  * Add nntpopen() and nntpclose() routines to cut down on size of rrn
  752.  * 
  753.  * Revision 4.3.2.2  89/11/08  01:17:12  sob
  754.  * Added changes to insure that this will compile for RN or RRN with no
  755.  * changes to the source code.
  756.  * 
  757.  * Revision 4.3.2.1  89/11/06  00:07:25  sob
  758.  * Added RRN support from NNTP 1.5
  759.  * 
  760.  * Revision 4.3  85/05/01  11:35:39  lwall
  761.  * Baseline for release with 4.3bsd.
  762.  * 
  763.  */
  764.  
  765. #include "EXTERN.h"
  766. #include "common.h"
  767. #ifdef SERVER
  768. #include "server.h"
  769. #endif
  770. #include "INTERN.h"
  771. #include "artio.h"
  772.  
  773. void
  774. artio_init()
  775. {
  776.     ;
  777. }
  778.  
  779. /* open an article, unless it's already open */
  780.  
  781. FILE *
  782. artopen(artnum)
  783. ART_NUM artnum;
  784. {
  785. #ifdef SERVER
  786.     nntpopen(artnum,ARTICLE);
  787. #else
  788.     char artname[32];            /* filename of current article */
  789.  
  790.     if (artnum < 1)
  791.     return Nullfp;
  792.     if (openart == artnum) {        /* this article is already open? */
  793.     fseek(artfp,0L,0);        /* just get to the beginning */
  794.     return artfp;            /* and say we succeeded */
  795.     }
  796.     if (artfp != Nullfp) {        /* it was somebody else? */
  797.     fclose(artfp);            /* put them out of their misery */
  798.     openart = 0;            /* and remember them no more */
  799.     }
  800.     sprintf(artname,"%ld",(long)artnum);
  801.                     /* produce the name of the article */
  802.     if (artfp = fopen(artname,"r"))    /* if we can open it */
  803.     openart = artnum;        /* remember what we did here */
  804. #endif SERVER
  805. #ifdef LINKART
  806.     {
  807.     char tmpbuf[256];
  808.     char *s;
  809.  
  810.     if (fstat(artfp->_file,&filestat))
  811.         return artfp;
  812.     if (filestat.st_size < (sizeof tmpbuf)) {
  813.         fgets(tmpbuf,(sizeof tmpbuf),artfp);
  814.         if (*tmpbuf == '/') {    /* is a "link" to another article */
  815.         fclose(artfp);
  816.         if (s=index(tmpbuf,'\n'))
  817.             *s = '\0';
  818.         if (!(artfp = fopen(tmpbuf,"r")))
  819.             openart = 0;
  820.         else {
  821.             if (*linkartname)
  822.             free(linkartname);
  823.             linkartname = savestr(tmpbuf);
  824.         }
  825.         }
  826.         else
  827.         fseek(artfp,0L,0);        /* get back to the beginning */
  828.     }
  829.     }
  830. #endif
  831.     return artfp;            /* and return either fp or NULL */
  832. }
  833.  
  834. #ifdef SERVER
  835. static long our_pid;
  836.  
  837. FILE *
  838. nntpopen(artnum,function)
  839. ART_NUM artnum;
  840. ART_PART function;
  841. {
  842.     char ser_line[256];
  843.     char artname[32];            /* filename of current article */
  844.     if (our_pid == 0)
  845.     our_pid = getpid();
  846.     if (artnum < 1)
  847.     return Nullfp;
  848.     if ((openart == artnum) && (openpart >= function))
  849.     {                    /* this article is already open? */
  850.     fseek(artfp,0L,0);        /* just get to the beginning */
  851.     return artfp;            /* and say we succeeded */
  852.     }
  853.     if (artfp != Nullfp) {        /* it was somebody else? */
  854.     fclose(artfp);            /* put them out of their misery */
  855.     nntpclose();
  856.     openart = 0;            /* and remember them no more */
  857.     }
  858.     sprintf(artname,"/tmp/rrn%ld.%ld", (long) artnum, our_pid);
  859.     artfp = fopen(artname, "w+");    /* create the temporary article */
  860.     if (artfp == Nullfp) {
  861.     UNLINK(artname);
  862.     return Nullfp;
  863.     }
  864.     switch (function){
  865.         case STAT:
  866.         function = HEAD;    /* fall through */
  867.         case HEAD:
  868.         sprintf(ser_line, "HEAD %ld", (long)artnum);
  869.         break;
  870.         case ARTICLE:
  871.         sprintf(ser_line, "ARTICLE %ld", (long)artnum);
  872.         break;
  873.     }        
  874.     put_server(ser_line);        /* ask the server for the article */
  875.     if (get_server(ser_line, sizeof(ser_line)) < 0) {
  876.     fprintf(stderr, "rrn: Unexpected close of server socket.\n");
  877.     finalize(1);
  878.     }
  879.     if (*ser_line != CHAR_OK) {        /* and get it's reaction */
  880.     fclose(artfp);
  881.     artfp = Nullfp;
  882.     UNLINK(artname);
  883.      errno = ENOENT;        /* Simulate file-not-found */
  884.         return Nullfp;
  885.     }
  886.  
  887.     for (;;) {
  888.         if (get_server(ser_line, sizeof(ser_line)) < 0) {
  889.         fprintf(stderr, "rrn: Unexpected close of server socket.\n");
  890.         finalize(1);
  891.     }
  892.     if (ser_line[0] == '.' && ser_line[1] == '\0')
  893.         break;
  894.     fputs((ser_line[0] == '.' ? ser_line + 1 : ser_line), artfp);
  895.     putc('\n', artfp);
  896.     }
  897.     openpart = function;
  898.     if (function == HEAD)
  899.      putc('\n', artfp); /* req'd blank line after header */
  900.     fseek(artfp, 0L, 0);        /* Then get back to the start */
  901.     openart = artnum;
  902.     return artfp;            /* and return either fp or NULL */
  903. }
  904.  
  905. void
  906. nntpclose()
  907. {
  908.     char artname[32];            /* filename of current article */
  909.     if (our_pid == 0)
  910.     our_pid = getpid();
  911.     sprintf(artname, "/tmp/rrn%ld.%ld", (long) openart, our_pid);
  912.     UNLINK(artname);
  913. }
  914. #endif
  915. !STUFFY!FUNK!
  916. echo Extracting HACKERSGUIDE
  917. cat >HACKERSGUIDE <<'!STUFFY!FUNK!'
  918. Hacking Notes
  919.  
  920. If you aren't interested in mucking with the innards of rn, don't read this.
  921.  
  922. In the interests of both space and time optimization, things are done inside
  923. rn that don't always conform to the highest ideals of programming.  To the
  924. extent I felt it was practical, I've tried to conform to good programming
  925. practice, but you must realize that my goal was to make a better mousetrap,
  926. so certain conscious tradeoffs were made in the design of rn right from the
  927. start.  In particular, if you want to hack on rn (and I wouldn't blame you,
  928. it's fun), beware of the following:
  929.   
  930.   * buf and cmd_buf are reused all over the place.  11-squishing is a good
  931.     term for it.  No, I'm on a Vax now, but I've been there.
  932.  
  933.   * The article header is parsed on the fly, while it is being displayed.
  934.     In fact, practically everything is done on the fly within the article
  935.     display loop, and there are plenty of state variables.  The header
  936.     is never explicitly stored in memory; rather, pointers are kept into
  937.     the file.  The information required to backup pages is not stored in
  938.     memory, except for 1 buffer's worth.  The information required to do
  939.     the delayed mark as unread (M) is not stored in memory either.
  940.  
  941.   * Lots of contortions are gone through to avoid using static memory, or
  942.     allocating unnecessary memory, or losing track of allocated memory,
  943.     while at the same time allowing .newsrc lines and header lines to be
  944.     ANY length up to the amount of memory you have.  Rn spends a great deal
  945.     of effort being lazy.  Do not use a static buffer when you can use
  946.     growstr().
  947.  
  948.   * Lots of contortions are gone through to try to do things when people
  949.     aren't waiting, or have only been waiting a very short time.  Guessing
  950.     the next article to be opened and opening it, searching ahead for the
  951.     next article with the same subject, delaying the look up of the number
  952.     of articles in a newsgroup, writing the rest of the page while the
  953.     reader is examining the header, cacheing up subjects while the user
  954.     is reading, checkpointing the .newsrc only while the reader is in the
  955.     middle of an interesting article, are some of the strategies employed.
  956.   
  957.   * There are plenty of goto's.  Most of them involve going back to reprompt,
  958.     to reask for input, or to just plain do the unstructured things people
  959.     want to do when they are glaring at a terminal.  If they bother you
  960.     too much, just think of rn as a big state machine.  If they don't bother
  961.     you at all, I don't want you hacking on rn.
  962.  
  963.   * Put all includes at the front of the file, before the first function,
  964.     or makedepend will not work right.  I could relax this, but makedepend
  965.     would take about 5 times longer to run.
  966.  
  967. In general then, feel free to hack on rn.  Just don't broadcast untested
  968. patches to the net.  Remember that there are people with limited address
  969. spaces and limited cpu cycles.  If you add a wonderful new feature and
  970. want to publish a patch, put #ifdef's around it so that people who don't
  971. want it or can't afford it can work around it.  THIS MEANS YOU.  We don't
  972. need 57 varieties of mutually incompatible and incomprehensible rn floating
  973. about the net.  Consider telling me about your patch so that I can consider
  974. including it in the standard version.  A COMPLETE PATCH TAKES INTO ACCOUNT
  975. SYSTEM DEPENDENCIES AS DETERMINED BY THE CONFIGURE SCRIPT.
  976.  
  977. * Don't use ints where rn uses typedefs, in particular, for article numbers.
  978. * Don't use %d anywhere that someone might need a %ld.  (Just because YOU
  979.     typedefed it as an int doesn't mean someone else won't need a long.)
  980. * Don't use %D, that's archaic.
  981. * Put FLUSHes after printf()s, fputs()es and putchar('\n')s for our poor
  982.     brethern and sistern without line buffering.
  983. * Declare the type of every function.  Use void, even if your C compiler
  984.     doesn't.
  985. * Follow the style that rn already uses!  This is my pet peeve.  Well, one of
  986.     them, anyway.  I follow other people's strange styles when modifying
  987.     their programs, so I'd be much obliged if you did likewise.
  988. * Use lint.
  989. * Use RCS.  Start a new branch, like 4.3.[2-9].  (I will use 4.3.1 myself.)
  990. * Be structured wherever it doesn't interfere with practicality.
  991. * Long live paranoid programming.  The rest of the program is out to get you.
  992.     The world is out to destroy the program, not to mention the .newsrc.
  993.     And then there's always bitrot...
  994. * Stop reading this lugubrious trash and start thinking for yourself.
  995. * Thank you and good night.
  996. !STUFFY!FUNK!
  997. echo Extracting README
  998. cat >README <<'!STUFFY!FUNK!'
  999.             Rn Kit, Version 4.3
  1000.  
  1001.             Copyright (c) 1985, Larry Wall
  1002.  
  1003. You may copy the rn kit in whole or in part as long as you don't try to
  1004. make money off it, or pretend that you wrote it.
  1005. --------------------------------------------------------------------------
  1006.  
  1007. Please read all the directions below before you proceed any further, and
  1008. then follow them carefully.  Failure to do so may void your warranty. :-)
  1009.  
  1010. After you have unpacked your kit, you should have all the files listed
  1011. in MANIFEST.
  1012.  
  1013. Installation
  1014.  
  1015. 1)  Run Configure.  This will figure out various things about your system.
  1016.     Some things Configure will figure out for itself, other things it will
  1017.     ask you about.  It will then proceed to make config.h, config.sh, Makefile,
  1018.     and a bunch of shell scripts.  It will also do a make depend for you.
  1019.     You might possibly have to trim # comments from the front of Configure
  1020.     if your sh doesn't handle them, but all other # comments will be taken
  1021.     care of.
  1022.  
  1023. 2)  Glance through config.h and common.h to make sure system dependencies
  1024.     are correct.  Most of them should have been taken care of by running
  1025.     the Configure script.
  1026.  
  1027.     If you have any additional changes to make to the C definitions, they
  1028.     can be done in the Makefile, in config.h, or in common.h.  If you have
  1029.     strange mailboxes on your system you should modify mbox.saver to correctly
  1030.     append an article to a mailbox or folder.
  1031.  
  1032.     If you are on a machine with limited address space, you may have to
  1033.     remove some of the special functions of rn to make it fit.  This is
  1034.     easily done by undefining symbols in the System Dependencies section
  1035.     of common.h.  You should run "make depend" again to be safe.
  1036.  
  1037. 3)  make
  1038.  
  1039.     This will attempt to make rn in the current directory.
  1040.  
  1041. 4)  make install
  1042.  
  1043.     This will put rn, newsetup, newsgroups, Pnews, and Rnmail into a public
  1044.     directory (normally /usr/local/bin), and put a number of files into the
  1045.     private rn library (normally /usr/lib/news/rn).  It will also try to put
  1046.     the man pages in a reasonable place.
  1047.  
  1048. 5)  Read the manual entry before running rn.  It's quite different from
  1049.     readnews.
  1050.  
  1051. 6)  If you are trying to make it work with NNTP, be sure you have 
  1052.     installed the NNTP inews and the file that contains the name of the
  1053.     NNTP server. RRN expects that the NNTP is at least version 1.5.
  1054.  
  1055. 7)  Try rn, and play with some of the switches.  You may want to make -/
  1056.     default on your system.  This is done in common.h.  You may want to modify
  1057.     which header lines are displayed by default--this is done in head.h.
  1058.  
  1059.     To change default values of enviroment variables on a system-wide basis
  1060.     without recompiling rn, put switches into file INIT in the rn library.
  1061.  
  1062. 8)  IMPORTANT!  Help save the world!  Communicate any problems and
  1063.     suggested patches to my faithful servant, sob@bcm.tmc.edu, so we can
  1064.     keep the world in sync.  If you have a problem, there's someone else
  1065.     out there who either has had or will have the same problem.
  1066.  
  1067.     If possible, send in patches such that the patch program will apply them.
  1068.     Context diffs are the best, then normal diffs.  Don't send ed scripts--
  1069.     I've probably changed my copy since the version you have.
  1070.  
  1071.     Watch for rn patches in news.software.b.  Patches will generally be
  1072.     applyable (is that a word?) by the patch program.  If you are just
  1073.     now bringing up news and aren't sure how many patches there are, write
  1074.     to sob@bcm.tmc.edu and he'll send any you don't have.
  1075.  
  1076. 9)  If you are going to hack on rn, please read the HACKERSGUIDE first.
  1077. !STUFFY!FUNK!
  1078. echo Extracting head.h
  1079. cat >head.h <<'!STUFFY!FUNK!'
  1080. /* $Header: head.h,v 4.3 85/05/01 11:38:31 lwall Exp $
  1081.  *
  1082.  * $Log:    head.h,v $
  1083.  * Revision 4.3  85/05/01  11:38:31  lwall
  1084.  * Baseline for release with 4.3bsd.
  1085.  * 
  1086.  */
  1087.  
  1088. #define HEAD_FIRST 1
  1089.  
  1090. /* types of header lines (if only C really believed in enums)
  1091.  * (These must stay in alphabetic order at least in the first letter.
  1092.  * Within each letter it helps to arrange in increasing likelihood.)
  1093.  */
  1094.  
  1095. #define PAST_HEADER    0    /* body */
  1096. #define SOME_LINE    1    /* unrecognized */
  1097. #define ARTID_LINE    2    /* article-i.d. */
  1098. #define APPR_LINE    3    /* approved */
  1099. #define DIST_LINE    4    /* distribution */
  1100. #define DATE_LINE    5    /* date */
  1101. #define RECEIVED_LINE    6    /* date-received */
  1102. #define EXPIR_LINE    7    /* expires */
  1103. #define FOLLOW_LINE    8    /* followup-to */
  1104. #define FROM_LINE    9    /* from */
  1105. #define KEYW_LINE    10    /* keywords */
  1106. #define LINES_LINE    11    /* lines */
  1107. #define MESSID_LINE    12    /* message-id */
  1108. #define NFFR_LINE    13    /* nf-from */
  1109. #define NFID_LINE    14    /* nf-id */
  1110. #define NGS_LINE    15    /* newsgroups */
  1111. #define ORG_LINE    16    /* organization */
  1112. #define PATH_LINE    17    /* path */
  1113. #define POSTED_LINE    18    /* posted */
  1114. #define PVER_LINE    19    /* posting-version */
  1115. #define REPLY_LINE    20    /* reply-to */
  1116. #define REFS_LINE    21    /* references */
  1117. #define RVER_LINE    22    /* relay-version */
  1118. #define SENDER_LINE    23    /* sender */
  1119. #define SUMRY_LINE    24    /* summary */
  1120. #define SUBJ_LINE    25    /* subject */
  1121. #define XREF_LINE    26    /* xref */
  1122.  
  1123. #define HEAD_LAST    27    /* one more than the last one above */
  1124.  
  1125. struct headtype {
  1126.     char *ht_name;        /* header line identifier */
  1127. #ifdef pdp11
  1128.     short ht_minpos;
  1129.     short ht_maxpos;
  1130. #else
  1131.     ART_POS ht_minpos;        /* pointer to beginning of line in article */
  1132.     ART_POS ht_maxpos;        /* pointer to end of line in article */
  1133. #endif
  1134.     char ht_length;        /* could make these into nybbles but */
  1135.     char ht_flags;        /* it wouldn't save space normally */
  1136. };                /* due to alignment considerations */
  1137.  
  1138. #define HT_HIDE 1    /* -h on this line */
  1139. #define HT_MAGIC 2    /* do any special processing on this line */
  1140.  
  1141. /* This array must stay in the same order as the list above */
  1142.  
  1143. #ifndef DOINIT
  1144. EXT struct headtype htype[HEAD_LAST];
  1145. #else
  1146. struct headtype htype[HEAD_LAST] = {
  1147.  /* name             minpos   maxpos  length   flag */
  1148.     {"BODY",        0,    0,    4,    0        },
  1149.     {"unrecognized",    0,    0,    12,    0        },
  1150.     {"article-i.d.",    0,    0,    12,    HT_HIDE        },
  1151.     {"approved",    0,    0,    8,    HT_HIDE        },
  1152.     {"distribution",    0,    0,    12,    0        },
  1153.     {"date",        0,    0,    4,    0        },
  1154.     {"date-received",    0,    0,    13,    0        },
  1155.     {"expires",        0,    0,    7,    HT_HIDE|HT_MAGIC},
  1156.     {"followup-to",    0,    0,    11,    0        },
  1157.     {"from",        0,    0,    4,    0        },
  1158.     {"keywords",    0,    0,    8,    0        },
  1159.     {"lines",        0,    0,    5,    0        },
  1160.     {"message-id",    0,    0,    10,    0        },
  1161.     {"nf-from",        0,    0,    7,    HT_HIDE        },
  1162.     {"nf-id",        0,    0,    5,    HT_HIDE        },
  1163.     {"newsgroups",    0,    0,    10,    HT_MAGIC|HT_HIDE},
  1164.     {"organization",    0,    0,    12,    0        },
  1165.     {"path",        0,    0,    4,    HT_HIDE        },
  1166.     {"posted",        0,    0,    6,    HT_HIDE        },
  1167.     {"posting-version",    0,    0,    15,    HT_HIDE        },
  1168.     {"reply-to",    0,    0,    8,    0        },
  1169.     {"references",    0,    0,    10,    0        },
  1170.     {"relay-version",    0,    0,    13,    HT_HIDE        },
  1171.     {"sender",        0,    0,    6,    0        },
  1172.     {"summary",        0,    0,    7,    0        },
  1173.     {"subject",        0,    0,    7,    HT_MAGIC    },
  1174.     {"xref",        0,    0,    4,    HT_HIDE        }
  1175. };
  1176. #endif
  1177.  
  1178. #ifdef ASYNC_PARSE
  1179. EXT ART_NUM parsed_art INIT(0);
  1180. #endif
  1181.  
  1182. EXT char in_header INIT(0);        /* are we decoding the header? */
  1183.  
  1184. #ifdef CACHESUBJ
  1185.     EXT char **subj_list INIT(Null(char **));
  1186. #endif
  1187.  
  1188. void    head_init();
  1189. int    set_line_type();
  1190. void    start_header();
  1191. bool    parseline();
  1192. #ifdef ASYNC_PARSE
  1193.     int        parse_maybe();
  1194. #endif
  1195. char    *fetchsubj();
  1196. char    *fetchlines();
  1197. !STUFFY!FUNK!
  1198. echo Extracting cheat.c
  1199. cat >cheat.c <<'!STUFFY!FUNK!'
  1200. /* $Header: cheat.c,v 4.3.2.2 89/11/27 01:30:18 sob Locked $
  1201.  *
  1202.  * $Log:    cheat.c,v $
  1203.  * Revision 4.3.2.2  89/11/27  01:30:18  sob
  1204.  * Altered NNTP code per ideas suggested by Bela Lubkin
  1205.  * <filbo@gorn.santa-cruz.ca.us>
  1206.  * 
  1207.  * Revision 4.3.2.1  89/11/26  22:54:21  sob
  1208.  * Added RRN support
  1209.  * 
  1210.  * Revision 4.3  85/05/01  11:36:46  lwall
  1211.  * Baseline for release with 4.3bsd.
  1212.  * 
  1213.  */
  1214.  
  1215. #include "EXTERN.h"
  1216. #include "common.h"
  1217. #include "intrp.h"
  1218. #include "search.h"
  1219. #include "ng.h"
  1220. #include "bits.h"
  1221. #include "artio.h"
  1222. #include "term.h"
  1223. #include "artsrch.h"
  1224. #include "head.h"
  1225. #include "INTERN.h"
  1226. #include "cheat.h"
  1227.  
  1228. /* see what we can do while they are reading */
  1229.  
  1230. #ifdef PENDING
  1231. #   ifdef ARTSEARCH
  1232.     COMPEX srchcompex;        /* compiled regex for searchahead */
  1233. #   endif
  1234. #endif
  1235.  
  1236. void
  1237. cheat_init()
  1238. {
  1239.     ;
  1240. }
  1241.  
  1242. #ifdef PENDING
  1243. void
  1244. look_ahead()
  1245. {
  1246. #ifdef ARTSEARCH
  1247.     register char *h, *s;
  1248.  
  1249. #ifdef DEBUGGING
  1250.     if (debug && srchahead) {
  1251.     printf("(%ld)",(long)srchahead);
  1252.     fflush(stdout);
  1253.     }
  1254. #endif
  1255.     if (srchahead && srchahead < art) {    /* in ^N mode? */
  1256.     char *pattern;
  1257.  
  1258.     pattern = buf+1;
  1259.     strcpy(pattern,": *");
  1260.     h = pattern + strlen(pattern);
  1261.     interp(h,(sizeof buf) - (h-buf),"%s");
  1262.     h[24] = '\0';        /* compensate for notesfiles */
  1263.     while (*h) {
  1264.         if (index("\\[.^*$'\"",*h) != Nullch)
  1265.         *h++ = '.';
  1266.         else
  1267.         h++;
  1268.     }
  1269. #ifdef DEBUGGING
  1270.     if (debug & DEB_SEARCH_AHEAD) {
  1271.         fputs("(hit CR)",stdout);
  1272.         fflush(stdout);
  1273.         gets(buf+128);
  1274.         printf("\npattern = %s\n",pattern);
  1275.     }
  1276. #endif
  1277.     if ((s = compile(&srchcompex,pattern,TRUE,TRUE)) != Nullch) {
  1278.                     /* compile regular expression */
  1279.         printf("\n%s\n",s);
  1280.         srchahead = 0;
  1281.     }
  1282.     if (srchahead) {
  1283.         srchahead = art;
  1284.         for (;;) {
  1285.         srchahead++;    /* go forward one article */
  1286.         if (srchahead > lastart) { /* out of articles? */
  1287. #ifdef DEBUGGING
  1288.             if (debug)
  1289.             fputs("(not found)",stdout);
  1290. #endif
  1291.             break;
  1292.         }
  1293.         if (!was_read(srchahead) &&
  1294.             wanted(&srchcompex,srchahead,0)) {
  1295.                     /* does the shoe fit? */
  1296. #ifdef DEBUGGING
  1297.             if (debug)
  1298.             printf("(%ld)",(long)srchahead);
  1299. #endif
  1300. #ifdef SERVER
  1301.             nntpopen(srchahead,HEAD);
  1302. #else
  1303.             artopen(srchahead);
  1304. #endif
  1305.             break;
  1306.         }
  1307.         if (input_pending())
  1308.             break;
  1309.         }
  1310.         fflush(stdout);
  1311.     }
  1312.     }
  1313.     else
  1314. #endif
  1315.     {
  1316.     if (art+1 <= lastart)/* how about a pre-fetch? */
  1317. #ifdef SERVER
  1318.         nntpopen(art+1,HEAD);    /* look for the next article */
  1319. #else
  1320.         artopen(art+1);    /* look for the next article */
  1321. #endif
  1322.     }
  1323. }
  1324. #endif
  1325.  
  1326. /* see what else we can do while they are reading */
  1327.  
  1328. void
  1329. collect_subjects()
  1330. {
  1331. #ifdef PENDING
  1332. # ifdef CACHESUBJ
  1333.     ART_NUM oldart = openart;
  1334.     ART_POS oldartpos;
  1335.  
  1336.     if (!in_ng || !srchahead)
  1337.     return;
  1338.     if (oldart)            /* remember where we were in art */
  1339.     oldartpos = ftell(artfp);
  1340.     if (srchahead >= subj_to_get)
  1341.     subj_to_get = srchahead+1;
  1342.     while (!input_pending() && subj_to_get <= lastart)
  1343.     fetchsubj(subj_to_get++,FALSE,FALSE);
  1344.     if (oldart) {
  1345.     artopen(oldart);
  1346.     fseek(artfp,oldartpos,0);    /* do not screw the pager */
  1347.     }
  1348. # endif
  1349. #endif
  1350. }
  1351.  
  1352. !STUFFY!FUNK!
  1353. echo Extracting Pnews.1
  1354. cat >Pnews.1 <<'!STUFFY!FUNK!'
  1355. ''' $Header: Pnews.1,v 4.3.1.2 85/08/01 14:22:48 lwall Exp $
  1356. ''' 
  1357. ''' $Log:    Pnews.1,v $
  1358. ''' Revision 4.3.1.2  85/08/01  14:22:48  lwall
  1359. ''' Added AUTHORCOPY.
  1360. ''' 
  1361. ''' Revision 4.3.1.1  85/05/10  11:30:30  lwall
  1362. ''' Branch for patches.
  1363. ''' 
  1364. ''' Revision 4.3  85/05/01  11:33:50  lwall
  1365. ''' Baseline for release with 4.3bsd.
  1366. ''' 
  1367. .de Sh
  1368. .br
  1369. .ne 5
  1370. .PP
  1371. \fB\\$1\fR
  1372. .PP
  1373. ..
  1374. .de Sp
  1375. .if t .sp .5v
  1376. .if n .sp
  1377. ..
  1378. '''
  1379. '''     Set up \*(-- to give an unbreakable dash;
  1380. '''     string Tr holds user defined translation string.
  1381. '''     Bell System Logo is used as a dummy character.
  1382. '''
  1383. .ie n \{\
  1384. .tr \(bs-\*(Tr
  1385. .ds -- \(bs-
  1386. .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  1387. .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  1388. .ds L" ""
  1389. .ds R" ""
  1390. .ds L' '
  1391. .ds R' '
  1392. 'br\}
  1393. .el\{\
  1394. .ds -- \(em\|
  1395. .tr \*(Tr
  1396. .ds L" ``
  1397. .ds R" ''
  1398. .ds L' `
  1399. .ds R' '
  1400. 'br\}
  1401. .TH PNEWS 1 LOCAL
  1402. .SH NAME
  1403. Pnews - a program for posting news articles
  1404. .SH SYNOPSIS
  1405. .B Pnews newsgroup title
  1406. .br
  1407.   or
  1408. .br
  1409. .B Pnews -h headerfile [oldarticle]
  1410. .br
  1411.   or
  1412. .br
  1413. .B Pnews
  1414. .SH DESCRIPTION
  1415. Pnews is a friendly interface for posting news articles.
  1416. It will ask several questions, then allow you to enter your article,
  1417. and then post it using the inews(1) program.
  1418. If you type h and a carriage return at any point,
  1419. .I Pnews
  1420. will tell you what it wants to know.
  1421. .PP
  1422. The -h form is used when invoked from
  1423. .IR rn .
  1424. If your editor can edit multiple files, and you want the article to which
  1425. you are replying to show up as an alternate file, define the environment
  1426. variable NEWSPOSTER as \*(L"Pnews -h %h %A\*(R".
  1427. You can also modify the the NEWSHEADER environment variable to change the
  1428. header file that
  1429. .I rn
  1430. passes to Pnews.
  1431. .SH ENVIRONMENT
  1432. .IP AUTHORCOPY 8
  1433. If defined, contains the name of a file to which the finished article will
  1434. be appended.
  1435. .Sp
  1436. Default: article not saved
  1437. .IP DOTDIR 8
  1438. Where to find your dot files, if they aren't in your home directory.
  1439. This is primarily for accounts which are shared by more than one person.
  1440. .Sp
  1441. Default: $HOME
  1442. .IP EDITOR 8
  1443. The editor you want to use, if VISUAL is undefined.
  1444. .Sp
  1445. Default: whatever your news administrator installed, usually vi.
  1446. .IP HOME 8
  1447. Your home directory.
  1448. .Sp
  1449. Default: $LOGDIR
  1450. .IP LOGDIR 8
  1451. Your home directory if HOME is undefined.
  1452. .IP LOGNAME 8
  1453. Your login name, if USER is undefined.
  1454. .Sp
  1455. Default: value of \*(L"whoami\*(R".
  1456. .IP NAME 8
  1457. Your full name.
  1458. .Sp
  1459. Default: name from /etc/passwd, or ~/.fullname.
  1460. .IP ORGANIZATION 8
  1461. Either the name of your organization, or the name of a file containing the
  1462. name of your organization.
  1463. .Sp
  1464. Default: whatever your news administrator chose.
  1465. .IP USER 8
  1466. Your login name.
  1467. .Sp
  1468. Default: $LOGNAME
  1469. .IP VISUAL 8
  1470. The editor you want to use.
  1471. .Sp
  1472. Default: $EDITOR
  1473. .SH FILES
  1474. $DOTDIR/.article
  1475. .br
  1476. ~/dead.article
  1477. .SH SEE ALSO
  1478. rn(1), Rnmail(1), inews(1)
  1479. .SH DIAGNOSTICS
  1480. .SH BUGS
  1481. Not the speediest program in the world, but maybe that's a blessing to the
  1482. net.
  1483. !STUFFY!FUNK!
  1484. echo Extracting NEW
  1485. cat >NEW <<'!STUFFY!FUNK!'
  1486.             NEW FEATURES WITH RN/RRN 4.3
  1487.  
  1488. New commands
  1489.     TAB (pager)    scan for end of quoted text.
  1490.     && (anywhere)    set or display macros.
  1491.     Q (art level)    exit this newsgroup but stay on it.
  1492.     x (ng level)    exit rn without changing .newsrc.
  1493.  
  1494. New switch
  1495.     -=TERM-switch    apply switch if terminal is TERM.        
  1496.  
  1497. New environment variables
  1498.     RNMACRO        name of your macro and keymap file, if any.
  1499.     SUBJLINE    controls format of = article listing.
  1500.  
  1501. New % interpolations.
  1502.     %I        inclusion indicator (-F argument).
  1503.     %m        current mode of rn (newsgroup, pager, etc.)
  1504.     %z        length of current article.
  1505.     %"prompt"    prompt for input from keyboard.
  1506.     %`command`    same as shell backquotes.
  1507.     ^char        now produces control-char.
  1508.  
  1509. Macros and Keymaps
  1510.     You may now define macros of any reasonable length and map those
  1511.     macros onto your keyboard in any way.  You can completely remap the
  1512.     keyboard if you wish.  Macros may contain % interpolations.
  1513.  
  1514. Global RNINIT file
  1515.     You can now set pseudo-environment variables on a system-wide basis
  1516.     in the file %X/INIT.  You don't have to recompile rn when you want 
  1517.     to try something different.
  1518.  
  1519. Pnews
  1520.     Can append your .signature if you like.
  1521.     Now knows how to mail to moderators.
  1522.     Runs somewhat faster now when invoked with -h.
  1523.     Will use %x/distributions if it exists.
  1524.     Doesn't ask for Distribution on local newsgroups.
  1525.     Doesn't ask for editor if EDITOR or VISUAL is set.
  1526.  
  1527. Terminal handling
  1528.     -L switch uses erase-to-end-of-line to leave info on screen as long
  1529.         as possible.
  1530.     rn -c will not flush typeahead in your login script now.
  1531.     In multi-character commands, \ now quotes the next character.
  1532.     Support for non-line-buffered machines.  Certain V7 machines will
  1533.         appreciate the speedup.
  1534.  
  1535. Configure
  1536.     Lets the poor people without job control do shell escapes.
  1537.     Now remembers your old answers and uses them for defaults.
  1538.     Searches much more widely for libraries.
  1539.     Looks for Mcc or cc -M if it needs to.
  1540.     Finds pg if it needs to.  (Note, pg users: you can use macros to
  1541.         reverse the sense of CR and SP in rn now.)
  1542.     Figures out where manual pages go.
  1543.     Figures out where mail is spooled.
  1544.     Looks for ioctl.h, if any.
  1545.     Determines if you have a builtin echo that works differently than
  1546.         /bin/echo.
  1547.     Asks if your mail takes Internet addresses.
  1548.     Works reasonably on more systems, such as "Pyramids".
  1549.  
  1550. Miscellaneous
  1551.     Commands may be typed directly to a help menu or subject list without
  1552.         having to type 'q' first.
  1553.     - command on first displayed article of a newsgroup takes you out to
  1554.         the previous newsgroup.  (Someday it will take you to the
  1555.         previous article in the previous newsgroup.)
  1556.     You can now easily get into a newsgroup with a KILL file and no
  1557.         unread articles.
  1558.     The catchup command at the top level now asks for confirmation.
  1559.     Interpretation routines now check for output buffer overflow.
  1560.     The pager no longer get hung up on non-initial ^L.
  1561.     The negative unread articles bug was fixed.
  1562.     Numerous small bug fixes.
  1563. !STUFFY!FUNK!
  1564. echo Extracting Rnmail.1
  1565. cat >Rnmail.1 <<'!STUFFY!FUNK!'
  1566. ''' $Header: Rnmail.1,v 4.3.1.2 85/08/01 14:22:08 lwall Exp $
  1567. ''' 
  1568. ''' $Log:    Rnmail.1,v $
  1569. ''' Revision 4.3.1.2  85/08/01  14:22:08  lwall
  1570. ''' Added MAILRECORD, DOTDIR.
  1571. ''' 
  1572. ''' Revision 4.3.1.1  85/05/10  11:30:44  lwall
  1573. ''' Branch for patches.
  1574. ''' 
  1575. ''' Revision 4.3  85/05/01  11:34:28  lwall
  1576. ''' Baseline for release with 4.3bsd.
  1577. ''' 
  1578. .de Sh
  1579. .br
  1580. .ne 5
  1581. .PP
  1582. \fB\\$1\fR
  1583. .PP
  1584. ..
  1585. .de Sp
  1586. .if t .sp .5v
  1587. .if n .sp
  1588. ..
  1589. '''
  1590. '''     Set up \*(-- to give an unbreakable dash;
  1591. '''     string Tr holds user defined translation string.
  1592. '''     Bell System Logo is used as a dummy character.
  1593. '''
  1594. .ie n \{\
  1595. .tr \(bs-\*(Tr
  1596. .ds -- \(bs-
  1597. .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  1598. .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  1599. .ds L" ""
  1600. .ds R" ""
  1601. .ds L' '
  1602. .ds R' '
  1603. 'br\}
  1604. .el\{\
  1605. .ds -- \(em\|
  1606. .tr \*(Tr
  1607. .ds L" ``
  1608. .ds R" ''
  1609. .ds L' `
  1610. .ds R' '
  1611. 'br\}
  1612. .TH RNMAIL 1 LOCAL
  1613. .SH NAME
  1614. Rnmail - a program for replying via mail
  1615. .SH SYNOPSIS
  1616. .B Rnmail destination_list
  1617. .br
  1618.   or
  1619. .br
  1620. .B Rnmail -h headerfile [oldarticle]
  1621. .br
  1622.   or
  1623. .br
  1624. .B Rnmail
  1625. .SH DESCRIPTION
  1626. Rnmail is a friendly interface for mailing replies to news articles.
  1627. It will ask several questions, then allow you to enter your letter,
  1628. and then mail it off.
  1629. If you type h and a carriage return at any point,
  1630. .I Rnmail
  1631. will tell you what it wants to know.
  1632. .PP
  1633. The -h form is used when invoked from
  1634. .IR rn .
  1635. If your editor can edit multiple files, and you want the article to which
  1636. you are replying to show up as an alternate file, define the environment
  1637. variable MAILPOSTER as \*(L"Rnmail -h %h %A\*(R".
  1638. You can also modify the the MAILHEADER environment variable to change the
  1639. header file that
  1640. .I rn
  1641. passes to Rnmail.
  1642. .SH ENVIRONMENT
  1643. .IP DOTDIR 8
  1644. If defined, specifies a place other than your home directory where 'dot' files
  1645. may be stored.
  1646. This is primarily for accounts which are shared by more than one person.
  1647. .Sp
  1648. Default: $HOME
  1649. .IP EDITOR 8
  1650. The editor you want to use, if VISUAL is undefined.
  1651. .Sp
  1652. Default: whatever your news administrator installed, usually vi.
  1653. .IP HOME 8
  1654. Your home directory.
  1655. .Sp
  1656. Default: $LOGDIR
  1657. .IP LOGDIR 8
  1658. Your home directory if HOME is undefined.
  1659. .IP LOGNAME 8
  1660. Your login name, if USER is undefined.
  1661. .Sp
  1662. Default: value of \*(L"whoami\*(R".
  1663. .IP MAILRECORD 8
  1664. If defined, contains the name of a file to which the finished message will
  1665. be appended.
  1666. .Sp
  1667. Default: message not saved
  1668. .IP ORGANIZATION 8
  1669. Either the name of your organization, or the name of a file containing the
  1670. name of your organization.
  1671. .Sp
  1672. Default: whatever your news administrator chose.
  1673. .IP USER 8
  1674. Your login name.
  1675. .Sp
  1676. Default: $LOGNAME
  1677. .IP VISUAL 8
  1678. The editor you want to use.
  1679. .Sp
  1680. Default: $EDITOR
  1681. .SH FILES
  1682. $DOTDIR/.letter
  1683. .br
  1684. ~/dead.letter
  1685. .SH SEE ALSO
  1686. rn(1), Pnews(1), mail(1)
  1687. .SH DIAGNOSTICS
  1688. .SH BUGS
  1689. Uses /bin/mail in the absence of sendmail.
  1690. !STUFFY!FUNK!
  1691. echo Extracting ngsrch.c
  1692. cat >ngsrch.c <<'!STUFFY!FUNK!'
  1693. /* $Header: ngsrch.c,v 4.3 85/05/01 11:44:51 lwall Exp $
  1694.  *
  1695.  * $Log:    ngsrch.c,v $
  1696.  * Revision 4.3  85/05/01  11:44:51  lwall
  1697.  * Baseline for release with 4.3bsd.
  1698.  * 
  1699.  */
  1700.  
  1701. #include "EXTERN.h"
  1702. #include "common.h"
  1703. #include "rcstuff.h"
  1704. #include "final.h"
  1705. #include "search.h"
  1706. #include "rn.h"
  1707. #include "util.h"
  1708. #include "term.h"
  1709. #include "rcln.h"
  1710. #include "INTERN.h"
  1711. #include "ngsrch.h"
  1712.  
  1713. #ifdef NGSORONLY
  1714.     COMPEX ngcompex;
  1715. #endif
  1716.  
  1717. void
  1718. ngsrch_init()
  1719. {
  1720. #ifdef ZEROGLOB
  1721.     init_compex(&ngcompex);
  1722. #endif    /* ZEROGLOB */
  1723.     ;
  1724. }
  1725.  
  1726. #ifdef NGSEARCH
  1727. int
  1728. ng_search(patbuf,get_cmd)
  1729. char *patbuf;                /* if patbuf != buf, get_cmd must */
  1730. int get_cmd;                /*   be set to FALSE!!! */
  1731. {
  1732.     char *pattern;            /* unparsed pattern */
  1733.     register char cmdchr = *patbuf;    /* what kind of search? */
  1734.     register char *s;
  1735.     bool backward = cmdchr == '?';    /* direction of search */
  1736.  
  1737.     int_count = 0;
  1738.     if (get_cmd && buf == patbuf)
  1739.     if (!finish_command(FALSE))        /* get rest of command */
  1740.         return NGS_ABORT;
  1741.     for (pattern = patbuf+1; *pattern == ' '; pattern++) ;
  1742.     if (*pattern) {
  1743.     ng_doread = FALSE;
  1744.     }
  1745.     s = rindex(pattern,cmdchr);
  1746.     if (s != Nullch && *(s-1) != '\\') {
  1747.     *s++ = '\0';
  1748.     if (index(s,'r') != Nullch)
  1749.         ng_doread = TRUE;
  1750.     }
  1751.     if ((s = ng_comp(&ngcompex,pattern,TRUE,TRUE)) != Nullch) {
  1752.                     /* compile regular expression */
  1753.     printf("\n%s\n",s) FLUSH;
  1754.     return NGS_ABORT;
  1755.     }
  1756.     fputs("\nSearching...",stdout) FLUSH;    /* give them something to read */
  1757.     fflush(stdout);
  1758.     for (;;) {
  1759.     if (int_count) {
  1760.         int_count = 0;
  1761.         return NGS_INTR;
  1762.     }
  1763.     if (backward) {
  1764.         if (ng > 0)
  1765.         --ng;
  1766.         else
  1767.         ng = nextrcline;
  1768.     }
  1769.     else {
  1770.         if (ng >= nextrcline)
  1771.         ng = 0;
  1772.         else
  1773.         ++ng;
  1774.     }
  1775.     if (ng == current_ng)
  1776.         return NGS_NOTFOUND;
  1777.     if (ng == nextrcline || toread[ng] < TR_NONE || !ng_wanted())
  1778.         continue;
  1779.     if (toread[ng] == TR_NONE)
  1780.         set_toread(ng);
  1781.     
  1782.     if (toread[ng] > TR_NONE)
  1783.         return NGS_FOUND;
  1784.     else if (toread[ng] == TR_NONE)
  1785.         if (ng_doread)
  1786.         return NGS_FOUND;
  1787.         else
  1788.         printf("\n[0 unread in %s--skipping]",rcline[ng]) FLUSH;
  1789.     }
  1790. }
  1791.  
  1792. bool
  1793. ng_wanted()
  1794. {
  1795.     return execute(&ngcompex,rcline[ng]) != Nullch;
  1796. }
  1797. #endif
  1798.  
  1799. #ifdef NGSORONLY
  1800. char *
  1801. ng_comp(compex,pattern,RE,fold)
  1802. COMPEX *compex;
  1803. char *pattern;
  1804. bool RE;
  1805. bool fold;
  1806. {
  1807.     char ng_pattern[128];
  1808.     register char *s = pattern, *d = ng_pattern;
  1809.  
  1810.     if (!*s)
  1811.     return Nullch;            /* reuse old pattern */
  1812.     for (; *s; s++) {
  1813.     if (*s == '.') {
  1814.         *d++ = '\\';
  1815.         *d++ = *s;
  1816.     }
  1817.     else if (*s == '?') {
  1818.         *d++ = '.';
  1819.     }
  1820.     else if (*s == '*') {
  1821.         *d++ = '.';
  1822.         *d++ = *s;
  1823.     }
  1824.     else if (strnEQ(s,"all",3)) {
  1825.         *d++ = '.';
  1826.         *d++ = '*';
  1827.         s += 2;
  1828.     }
  1829.     else
  1830.         *d++ = *s;
  1831.     }
  1832.     *d = '\0';
  1833.     return compile(compex,ng_pattern,RE,fold);
  1834. }
  1835. #endif
  1836.  
  1837. !STUFFY!FUNK!
  1838. echo Extracting art.help.SH
  1839. cat >art.help.SH <<'!STUFFY!FUNK!'
  1840. case $CONFIG in
  1841.     '') . config.sh ;;
  1842. esac
  1843. echo "Extracting art.help (with variable substitutions)"
  1844. $spitshell >art.help <<!GROK!THIS!
  1845. $startsh
  1846. # $Header: art.help.SH,v 4.3 85/05/01 11:35:34 lwall Exp $
  1847. # $Log:    art.help.SH,v $
  1848. # Revision 4.3  85/05/01  11:35:34  lwall
  1849. # Baseline for release with 4.3bsd.
  1850. $pager <<'EOT'
  1851. Article Selection commands:
  1852.  
  1853. n,SP    Scan forward for next unread article.
  1854. N    Go to next article.
  1855. ^N    Scan forward for next unread article with same subject.
  1856. p,P,^P    Same as n,N,^N, only going backwards.
  1857. -    Go to previously displayed article.
  1858. number    Go to specified article.
  1859. range{,range} command{:command}
  1860.     Apply one or more commands to one or more ranges of articles.
  1861.     Ranges are of the form: number | number-number.  You may use . for
  1862.     the current article, and $ for the last article.
  1863.      Valid commands are: j, m, M, s, S, and !.
  1864. /pattern/modifiers
  1865.     Scan forward for article containing pattern in the subject line.
  1866.     (Use ?pat? to scan backwards; append h to scan headers, a to scan
  1867.     entire articles, r to scan read articles, c to make case sensitive.
  1868. /pattern/modifiers:command{:command}
  1869.     Apply one or more commands to the set of articles matching pattern.
  1870.     Use a K modifier to save entire command to the KILL file for this
  1871.     newsgroup.  Commands m and M, if first, imply an r modifier.
  1872.      Valid commands are: j, m, M, s, S, and !.
  1873. f,F    Submit a followup article (F = include this article).
  1874. r,R    Reply through net mail (R = include this article).
  1875. s ...    Save to file or pipe via sh.
  1876. S ...    Save via preferred shell.
  1877. w,W    Like s and S but save without the header.
  1878. | ...    Same as s|...
  1879. C    Cancel this article, if yours.
  1880. ^R,v    Restart article (v=verbose).
  1881. ^X    Restart article, rot13 mode.
  1882. c    Catch up (mark all articles as read).
  1883. ^B    Back up one page.
  1884. ^L    Refresh the screen.  You can get back to the pager with this.
  1885. X    Refresh screen in rot13 mode.
  1886. ^    Go to first unread article.  Disables subject search mode.
  1887. $    Go to end of newsgroup.  Disables subject search mode.
  1888. #       Print last article number.
  1889. &    Print current values of command-line switches.
  1890. &switch {switch}
  1891.     Set or unset more switches.
  1892. &&    Print current macro definitions.
  1893. &&def    Define a new macro.
  1894. j    Junk this article (mark it read).  Stays at end of article.
  1895. m    Mark article as still unread.
  1896. M    Mark article as still unread upon exiting newsgroup or Y command.
  1897. Y    Yank back articles marked temporarily read via M.
  1898. k    Mark current SUBJECT as read.
  1899. K    Mark current SUBJECT as read, and save command in KILL file.
  1900. =    List subjects of unread articles.
  1901. u    Unsubscribe to this newsgroup.
  1902. ^K    Edit local KILL file (the one for this newsgroup).
  1903. q    Quit this newsgroup for now.
  1904. Q    Quit newsgroup, staying at current newsgroup.
  1905. EOT
  1906.  
  1907. !GROK!THIS!
  1908. $eunicefix art.help
  1909. chmod 755 art.help
  1910. !STUFFY!FUNK!
  1911. echo Extracting newsgroups.SH
  1912. cat >newsgroups.SH <<'!STUFFY!FUNK!'
  1913. case $CONFIG in
  1914.     '') . ./config.sh ;;
  1915. esac
  1916. echo "Extracting newsgroups (with variable substitutions)"
  1917. $spitshell >newsgroups <<!GROK!THIS!
  1918. $startsh
  1919. # $Header: newsgroups.SH,v 4.3.2.7 90/04/23 19:30:41 sob Exp $
  1920. # $Log:    newsgroups.SH,v $
  1921. # Revision 4.3.2.7  90/04/23  19:30:41  sob
  1922. # Extra space removed to make second part of newsgroups work.
  1923. # Sigh.
  1924. # Revision 4.3.2.6  90/04/06  20:35:37  sob
  1925. # Added fixes for SCO Xenix sent by ronald@robobar.co.uk.
  1926. # Revision 4.3.2.5  90/03/17  17:27:00  sob
  1927. # System V sed and BSD sed don't work quite alike. This change uses a
  1928. # syntax that is common between them.
  1929. # Revision 4.3.2.4  89/11/08  01:13:35  sob
  1930. # Finished modifications to make work with RN and RRN
  1931. # Revision 4.3.2.3  89/11/07  22:58:04  sob
  1932. # Added final changes to allow rn and rrn to be built from same sources.
  1933. # Revision 4.3.2.2  89/11/07  22:52:22  sob
  1934. # Added prelimiary support to allow both rrn and rn to be built from same
  1935. # sources.
  1936. # Revision 4.3.2.1  89/11/06  01:04:39  sob
  1937. # Added RRN support from NNTP 1.5
  1938. # Revision 4.3  85/05/01  11:43:27  lwall
  1939. # Baseline for release with 4.3bsd.
  1940.  
  1941. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  1942.  
  1943. : syntax: newsgroups [pattern] [pipeflag]
  1944.  
  1945. : System Dependencies
  1946.  
  1947. : You might want to change pager to a "make column" program if you have one.
  1948. : On the other hand, if your kernel does paging, cat would probably do.
  1949. pager="${pager-/usr/ucb/more}"
  1950. #NORMALactive="${active-/usr/lib/news/active}"
  1951.  
  1952. #NORMALcase \$active in
  1953. #NORMAL~*) active=\`$filexp \$active\` ;;
  1954. #NORMALesac
  1955.  
  1956. #NNTPactive="/tmp/active.\$\$"
  1957.  
  1958. : End of system dependencies, hopefully
  1959.  
  1960. #NNTP$rnlib/getactive \$active
  1961.  
  1962. if $test \$# -ge 2 ; then
  1963.     pager=$cat
  1964. else
  1965.     $echo "Completely unsubscribed newsgroups:"
  1966. fi
  1967.  
  1968. dotdir=\${DOTDIR-\${HOME-\$LOGDIR}}
  1969.  
  1970. : Throwing .newsrc into the pot twice is a lovely hack to prevent
  1971. : bogus newsgroups from showing up as unsubscribed.
  1972.  
  1973. $cat \$dotdir/.newsrc \$dotdir/.newsrc \$active | \\
  1974. $sed -n    -e '/^options/d' \\
  1975.     -e '/^[     ]/d' \\
  1976.     -e '/^control/d' \\
  1977.     -e '/^to\./d' \\
  1978.     -e 's/^\([^ !:]*\)[ !:].*\$/\1/' \\
  1979.     -e "/.*\$1/p" | \\
  1980. $sort | $uniq -u | \$pager
  1981. if $test \$# -ge 2 ; then
  1982.     exit
  1983. fi
  1984. $echo $n "[Type return to continue] $c"
  1985. read tmp
  1986. $echo ""
  1987. $echo "Unsubscribed but mentioned in .newsrc:"
  1988. $sed -n < \$dotdir/.newsrc \\
  1989.     -e "/\$1.*!/"'s/^\([^!]*\)!.*\$/\1/p' | \\
  1990. $sort | \$pager
  1991. !GROK!THIS!
  1992. case "$isrrn" in
  1993. define)  sed < newsgroups -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsgroups.new ;;
  1994. *) sed < newsgroups -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsgroups.new ;;
  1995. esac
  1996. mv newsgroups.new newsgroups
  1997. $eunicefix newsgroups
  1998. chmod 755 newsgroups
  1999. !STUFFY!FUNK!
  2000. echo Extracting makedepend.SH
  2001. cat >makedepend.SH <<'!STUFFY!FUNK!'
  2002. case $CONFIG in
  2003.     '') . ./config.sh ;;
  2004. esac
  2005. echo "Extracting makedepend (with variable substitutions)"
  2006. $spitshell >makedepend <<!GROK!THIS!
  2007. $startsh
  2008. # $Header: makedepend.SH,v 4.3.2.2 90/04/21 14:24:58 sob Exp $
  2009. #
  2010. # $Log:    makedepend.SH,v $
  2011. # Revision 4.3.2.2  90/04/21  14:24:58  sob
  2012. # Added a fix to deal with XENIX cc -E output.
  2013. # Revision 4.3.2.1  89/12/17  02:52:46  sob
  2014. # Will only read config.sh from local directory.
  2015. # Revision 4.3.1.2  85/05/13  15:53:42  lwall
  2016. # Made cpp look in /usr/local/include too.
  2017. # Revision 4.3.1.1  85/05/10  11:35:10  lwall
  2018. # Branch for patches.
  2019. # Revision 4.3  85/05/01  11:42:26  lwall
  2020. # Baseline for release with 4.3bsd.
  2021.  
  2022. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  2023.  
  2024. $cat /dev/null >.deptmp
  2025. $echo "(Note: this is going to take a while.)"
  2026. $rm -f X*.c
  2027. for file in *.c; do
  2028.     filebase=\`basename \$file .c\`
  2029.     $echo "Finding dependencies for \$filebase.o."
  2030.     $sed -n <\$file >X\$file \\
  2031.     -e "/^\${filebase}_init(/q" \\
  2032.     -e '/^#/{' \\
  2033.     -e 's|/\*.*$||' \\
  2034.     -e p \\
  2035.     -e '}'
  2036.     $cpp -I/usr/local/include X\$file | $sed  \\
  2037.     -e '/^#line/s/line//' \
  2038.     -e '/^# *[0-9]/!d' \\
  2039.     -e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
  2040.     -e 's|: \./|: |' \\
  2041.     -e 's|: X|: |' | \\
  2042.     $uniq | $sort | $uniq >> .deptmp
  2043. done
  2044.  
  2045. for file in *.SH; do
  2046.     $echo \`basename \$file .SH\`: \$file config.sh \; /bin/sh \$file >> .deptmp
  2047. done
  2048.  
  2049. $sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
  2050.  
  2051. if $test -s .deptmp; then
  2052.     echo "Updating Makefile..."
  2053.     echo "# If this runs make out of memory, delete /usr/include lines." >>Makefile.new
  2054.     $cat .deptmp >>Makefile.new
  2055. else
  2056.     $echo "You don't seem to have a proper C preprocessor.  Using grep instead."
  2057.     $egrep '^#include ' *.c *.h >.deptmp
  2058.     echo "Updating Makefile..."
  2059.     <.deptmp $sed -n 's|c:#include "\(.*\)".*\$\$|o: \1|p' >> Makefile.new
  2060.     <.deptmp $sed -n 's|c:#include <\(.*\)>.*\$\$|o: /usr/include/\1|p' >> Makefile.new
  2061.     <.deptmp $sed -n 's|h:#include "\(.*\)".*\$\$|h: \1|p' >> Makefile.new
  2062.     <.deptmp $sed -n 's|h:#include <\(.*\)>.*\$\$|h: /usr/include/\1|p' >> Makefile.new
  2063. fi
  2064. $mv Makefile Makefile.old
  2065. $mv Makefile.new Makefile
  2066. $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> Makefile
  2067. rm .deptmp X*.c
  2068.  
  2069. !GROK!THIS!
  2070. $eunicefix makedepend
  2071. chmod 755 makedepend
  2072. !STUFFY!FUNK!
  2073. echo Extracting ndir.h
  2074. cat >ndir.h <<'!STUFFY!FUNK!'
  2075. /* $Header: ndir.h,v 4.3.2.1 90/04/17 15:28:13 sob Exp $
  2076.  *
  2077.  * $Log:    ndir.h,v $
  2078.  * Revision 4.3.2.1  90/04/17  15:28:13  sob
  2079.  * Altered to include correct directory include file.
  2080.  * 
  2081.  * Revision 4.3  85/05/01  11:43:00  lwall
  2082.  * Baseline for release with 4.3bsd.
  2083.  * 
  2084.  */
  2085.  
  2086. #ifdef LIBNDIR
  2087. #   include <ndir.h>
  2088. #else
  2089. #   ifndef USENDIR
  2090. #    include DIRINC
  2091. #   else
  2092.  
  2093. #ifndef DEV_BSIZE
  2094. #define    DEV_BSIZE    512
  2095. #endif
  2096. #define DIRBLKSIZ    DEV_BSIZE
  2097. #define    MAXNAMLEN    255
  2098.  
  2099. struct    direct {
  2100.     long    d_ino;            /* inode number of entry */
  2101.     short    d_reclen;        /* length of this record */
  2102.     short    d_namlen;        /* length of string in d_name */
  2103.     char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  2104. };
  2105.  
  2106. /*
  2107.  * The DIRSIZ macro gives the minimum record length which will hold
  2108.  * the directory entry.  This requires the amount of space in struct direct
  2109.  * without the d_name field, plus enough space for the name with a terminating
  2110.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  2111.  */
  2112. #undef DIRSIZ
  2113. #define DIRSIZ(dp) \
  2114.     ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  2115.  
  2116. /*
  2117.  * Definitions for library routines operating on directories.
  2118.  */
  2119. typedef struct _dirdesc {
  2120.     int    dd_fd;
  2121.     long    dd_loc;
  2122.     long    dd_size;
  2123.     char    dd_buf[DIRBLKSIZ];
  2124. } DIR;
  2125. #ifndef NULL
  2126. #define NULL 0
  2127. #endif
  2128. extern    DIR *opendir();
  2129. extern    struct direct *readdir();
  2130. extern    long telldir();
  2131. extern    void seekdir();
  2132. #define rewinddir(dirp)    seekdir((dirp), (long)0)
  2133. extern    void closedir();
  2134.  
  2135. #   endif
  2136. #endif
  2137. !STUFFY!FUNK!
  2138. echo ""
  2139. echo "End of kit 8 (of 9)"
  2140. cat /dev/null >kit8isdone
  2141. config=true
  2142. for iskit in 1 2 3 4 5 6 7 8 9 ; do
  2143.     if test -f kit${iskit}isdone; then
  2144.     echo "You have run kit ${iskit}."
  2145.     else
  2146.     echo "You still need to run kit ${iskit}."
  2147.     config=false
  2148.     fi
  2149. done
  2150. case $config in
  2151.     true)
  2152.     echo "You have run all your kits.  Please read README and then type Configure."
  2153.     chmod 755 Configure
  2154.     ;;
  2155. esac
  2156. : I do not append .signature, but someone might mail this.
  2157. exit
  2158.