home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume1 / rn / part02 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  61.8 KB

  1. Date: Thu, 9 May 85 11:43:43 pdt
  2. From: allegra!sdcrdcf!RDCF.SDC.UUCP!lwall (Larry Wall)
  3. Newsgroups: mod.sources
  4. Subject: rn version 4.3 (kit 2 of 9)
  5. Reply-To: lwall@sdcrdcf.UUCP
  6. Organization: System Development Corporation R&D, Santa Monica
  7.  
  8. #! /bin/sh
  9.  
  10. # Make a new directory for the rn sources, cd to it, and run kits 1 thru 9 
  11. # through sh.  When all 9 kits have been run, read README.
  12.  
  13. echo "This is rn kit 2 (of 9).  If kit 2 is complete, the line"
  14. echo '"'"End of kit 2 (of 9)"'" will echo at the end.'
  15. echo ""
  16. export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
  17. echo Extracting Configure
  18. cat >Configure <<'!STUFFY!FUNK!'
  19. #! /bin/sh
  20. #
  21. # If these # comments don't work, trim them.  Don't worry about the other
  22. # shell scripts, Configure will trim # comments from them for you.
  23. #
  24. # $Header: Configure,v 4.3 85/05/01 11:31:23 lwall Exp $
  25. #
  26. # $Log:    Configure,v $
  27. # Revision 4.3  85/05/01  11:31:23  lwall
  28. # Baseline for release with 4.3bsd.
  29.  
  30. # Yes, you may rip this off to use in other distribution packages.
  31.  
  32. n=''
  33. c=''
  34. libc=''
  35. eunicefix=''
  36. eunice=''
  37. cpp=''
  38. shsharp=''
  39. spitshell=''
  40. startsh=''
  41. test=''
  42. expr=''
  43. sed=''
  44. echo=''
  45. cat=''
  46. rm=''
  47. mv=''
  48. cp=''
  49. tail=''
  50. tr=''
  51. mkdir=''
  52. sort=''
  53. uniq=''
  54. inews=''
  55. grep=''
  56. egrep=''
  57. contains=''
  58. lib=''
  59. nametype=''
  60. cc=''
  61. iandd=''
  62. termlib=''
  63. jobslib=''
  64. ndirlib=''
  65. libndir=''
  66. usendir=''
  67. ndirc=''
  68. ndiro=''
  69. pager=''
  70. mailer=''
  71. internet=''
  72. rnbin=''
  73. filexp=''
  74. distlist=''
  75. Log=''
  76. Header=''
  77. sitename=''
  78. orgname=''
  79. isadmin=''
  80. newsadmin=''
  81. rnlib=''
  82. mansrc=''
  83. manext=''
  84. maildir=''
  85. spool=''
  86. active=''
  87. myactive=''
  88. mininact=''
  89. pref=''
  90. defeditor=''
  91. rootid=''
  92. mboxchar=''
  93. locpref=''
  94. orgpref=''
  95. citypref=''
  96. statepref=''
  97. cntrypref=''
  98. contpref=''
  99. strchr=''
  100. novoid=''
  101. novfork=''
  102. portable=''
  103. passnam=''
  104. berknam=''
  105. usgnam=''
  106. whoami=''
  107. termio=''
  108. fcntl=''
  109. ioctl=''
  110. normsig=''
  111. havetlib=''
  112. getpwent=''
  113. gethostname=''
  114. douname=''
  115. phostname=''
  116. hostcmd=''
  117. CONFIG=''
  118.  
  119. echo "Beginning of configuration questions for rn kit."
  120. : Eunice requires " " instead of "", can you believe it
  121. echo " "
  122.  
  123. : sanity checks
  124. PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc'
  125. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  126.  
  127. if test ! -t 0; then
  128.     echo "Say 'sh Configure', not 'sh <Configure'"
  129.     exit 1
  130. fi
  131.  
  132. : some greps do not return status, grrr.
  133. echo "grimblepritz" >grimble
  134. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  135.     contains=contains
  136. else
  137.     if grep grimblepritz grimble >/dev/null 2>&1 ; then
  138.     contains=grep
  139.     else
  140.     contains=contains
  141.     fi
  142. fi
  143. rm grimble
  144. : the following should work in any shell
  145. case $contains in
  146. contains*)
  147.     echo " "
  148.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  149.     cat >contains <<'EOSS'
  150. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  151. EOSS
  152. chmod 755 contains
  153. esac
  154.  
  155. : first determine how to suppress newline on echo command
  156. echo "Checking echo to see how to suppress newlines..."
  157. (echo "hi there\c" ; echo " ") >.echotmp
  158. if $contains c .echotmp >/dev/null 2>&1 ; then
  159.     echo "...using -n."
  160.     n='-n'
  161.     c=''
  162. else
  163.     echo "...using \\\c."
  164.     n=''
  165.     c='\c'
  166. fi
  167. echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
  168. read ans
  169. rm .echotmp
  170.  
  171. : now set up to do reads with possible shell escape
  172. : if this does not work on your machine, 1,$s/. myread/read ans/
  173. cat <<EOSC >myread
  174. ans='!'
  175. while expr "X\$ans" : "X!" >/dev/null; do
  176.     read ans
  177.     case "\$ans" in
  178.     !)
  179.     sh
  180.     echo " "
  181.     echo $n "Your answer: $c"
  182.     ;;
  183.     !*)
  184.     set \`expr "X\$ans" : "X!\(.*\)\$"\`
  185.     sh -c "\$*"
  186.     echo " "
  187.     echo $n "Your answer: $c"
  188.     ;;
  189.     esac
  190. done
  191. EOSC
  192.  
  193. : general instructions
  194. cat <<'EOH'
  195.  
  196. This installation shell script will examine your system and ask you questions
  197. to determine how rn and its auxiliary files should be installed.  If you
  198. get stuck on a question, you may use a ! shell escape to start a subshell or
  199. execute a command.  Many of the questions will have default answers in
  200. square brackets--typing carriage return will give you the default.
  201.  
  202. On some of the questions which ask for file or directory names you are
  203. allowed to use the ~name construct to specify the login directory belonging
  204. to "name", even if you don't have a shell which knows about that.  Questions
  205. where this is allowed will be marked "(~name ok)".
  206.  
  207. Much effort has been expended to ensure that this shell script will run
  208. on any Unix system.  If despite that it blows up on you, your best bet is
  209. to edit Configure and run it again.  (Trying to install rn without having run
  210. Configure is well nigh impossible.)  Also, let me (lwall@sdcrdcf.UUCP) know
  211. how I blew it.
  212.  
  213. This installation script affects things in two ways: 1) it does direct
  214. variable substitutions on some of the files included in this kit, and
  215. 2) it builds a config.h file for inclusion in C programs.  You may edit
  216. any of these files as the need arises after running this script.
  217.  
  218. EOH
  219. echo $n "[Type carriage return to continue] $c"
  220. . myread
  221.  
  222. : get old answers, if there is a config file out there
  223. if test -f config.sh; then
  224.     echo " "
  225.     echo "(Fetching default answers from your old config.sh file...)"
  226.     . config.sh
  227. fi
  228.  
  229. : get list of predefined functions in a handy place
  230. echo " "
  231. if test -f /lib/libc.a; then
  232.     echo "Your C library is in /lib/libc.a.  You're normal."
  233.     libc=/lib/libc.a
  234. else
  235.     if test -f /usr/lib/libc.a; then
  236.     echo "Your C library is in /usr/lib/libc.a, of all places."
  237.     libc=/usr/lib/libc.a
  238.     else
  239.     if test -f "$libc"; then
  240.         echo "Your C library is in $libc, like you said before."
  241.     else
  242.         cat <<'EOM'
  243.  
  244. I can't seem to find your C library.  I've looked for /lib/libc.a and
  245. /usr/lib/libc.a, but neither of those are there.  What is the full name
  246. EOM
  247.         echo $n "of your C library? $c"
  248.         . myread
  249.         libc="$ans"
  250.     fi
  251.     fi
  252. fi
  253. echo " "
  254. echo $n "Extracting names from $libc for later perusal...$c"
  255. if ar t $libc > libc.list; then
  256.     echo "done"
  257. else
  258.     echo " "
  259.     echo "The archiver doesn't think $libc is a reasonable library."
  260.     exit 1
  261. fi
  262.  
  263. : make some quick guesses about what we are up against
  264. echo " "
  265. echo $n "Hmm...  $c"
  266. if $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then
  267.     echo "Looks kind of like a BSD system, but we'll see..."
  268.     echo exit 0 >bsd
  269.     echo exit 1 >usg
  270.     echo exit 1 >v7
  271. else
  272.     if $contains fcntl.o libc.list >/dev/null 2>&1 ; then
  273.     echo "Looks kind of like a USG system, but we'll see..."
  274.     echo exit 1 >bsd
  275.     echo exit 0 >usg
  276.     echo exit 1 >v7
  277.     else
  278.     echo "Looks kind of like a version 7 system, but we'll see..."
  279.     echo exit 1 >bsd
  280.     echo exit 1 >usg
  281.     echo exit 0 >v7
  282.     fi
  283. fi
  284. if $contains vmssystem.o libc.list >/dev/null 2>&1 ; then
  285.     cat <<'EOI'
  286. There is, however, a strange, musty smell in the air that reminds me of
  287. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  288. EOI
  289.     echo "exit 0" >eunice
  290.     eunicefix=unixtovms
  291.     eunice=define
  292. : it so happens the Eunice I know will not run shell scripts in Unix format
  293. else
  294.     echo " "
  295.     echo "Congratulations.  You aren't running Eunice."
  296.     eunicefix=':'
  297.     eunice=undef
  298.     echo "exit 1" >eunice
  299. fi
  300. chmod 755 bsd usg v7 eunice
  301. $eunicefix bsd usg v7 eunice
  302.  
  303. : see how we invoke the C preprocessor
  304. echo " "
  305. echo "Checking to see how your C preprocessor is invoked..."
  306. cat <<'EOT' >testcpp.c
  307. #define ABC abc
  308. #define XYZ xyz
  309. ABC+XYZ
  310. EOT
  311. echo 'Maybe "cc -E" will work...'
  312. cc -E testcpp.c >testcpp.out 2>&1
  313. if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  314.     echo "Yup, it does."
  315.     cpp='cc -E'
  316. else
  317.     echo 'Nope...maybe "cc -P" will work...'
  318.     cc -P testcpp.c >testcpp.out 2>&1
  319.     if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  320.     echo "Yup, that does."
  321.     cpp='cc -P'
  322.     else
  323.     echo 'Nixed again...maybe "/lib/cpp" will work...'
  324.     /lib/cpp testcpp.c >testcpp.out 2>&1
  325.     if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  326.         echo "Hooray, it works!  I was beginning to wonder."
  327.         cpp='/lib/cpp'
  328.     else
  329.         echo 'Hmm...maybe you already told me...'
  330.         case "$cpp" in
  331.         '') ;;
  332.         *) $cpp testcpp.c >testcpp.out 2>&1;;
  333.         esac
  334.         if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  335.         echo "Hooray, you did!  I was beginning to wonder."
  336.         else
  337.         echo "Nope. I can't find a C preprocessor.  Name one: $c"
  338.         . myread
  339.         cpp="$ans"
  340.         $cpp testcpp.c >testcpp.out 2>&1
  341.         if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
  342.             echo "OK, that will do."
  343.         else
  344.             echo "Sorry, I can't get that to work.  Go find one."
  345.             exit 1
  346.         fi
  347.         fi
  348.     fi
  349.     fi
  350. fi
  351. rm -f testcpp.c testcpp.out
  352.  
  353. : check for pdp11
  354. echo " "
  355. if usg; then
  356.     : pdp11 is already defined
  357. else
  358.     cat <<'EOT' >pdp11.c
  359. #ifdef pdp11
  360. exit 0
  361. #else
  362. exit 1
  363. #endif
  364. EOT
  365.     $cpp pdp11.c | grep exit >pdp11
  366.     chmod 755 pdp11
  367.     $eunicefix pdp11
  368.     rm pdp11.c
  369. fi
  370. if pdp11; then
  371.     echo "This looks like a pdp11 to me."
  372. else
  373.     echo "This doesn't look like a pdp11 to me."
  374. fi
  375.  
  376. : see if sh knows # comments
  377. echo " "
  378. echo "Checking your sh to see if it knows about # comments..."
  379. if sh -c '#' >/dev/null 2>&1 ; then
  380.     echo "Your sh handles # comments correctly."
  381.     shsharp=true
  382.     spitshell=cat
  383.     echo " "
  384.     echo "Okay, let's see if #! works on this system..."
  385.     echo "#!/bin/echo hi" > try
  386.     $eunicefix try
  387.     chmod 755 try
  388.     try > today
  389.     if test -s today; then
  390.     echo "It does."
  391.     sharpbang='#!'
  392.     else
  393.     echo "#! /bin/echo hi" > try
  394.     $eunicefix try
  395.     chmod 755 try
  396.     try > today
  397.     if test -s today; then
  398.         echo "It does."
  399.         sharpbang='#! '
  400.     else
  401.         echo "It doesn't."
  402.         sharpbang=': use '
  403.     fi
  404.     fi
  405. else
  406.     echo "Your sh doesn't grok # comments--I will strip them later on."
  407.     shsharp=false
  408.     echo "exec grep -v '^#'" >spitshell
  409.     chmod 755 spitshell
  410.     $eunicefix spitshell
  411.     spitshell=`pwd`/spitshell
  412.     echo "I presume that if # doesn't work, #! won't work either!"
  413.     sharpbang=': use '
  414. fi
  415.  
  416. : figure out how to guarantee sh startup
  417. echo " "
  418. echo "Checking out how to guarantee sh startup..."
  419. startsh=$sharpbang'/bin/sh'
  420. echo "Let's see if '$startsh' works..."
  421. cat >try <<EOSS
  422. $startsh
  423. set abc
  424. test "$?abc" != 1
  425. EOSS
  426.  
  427. chmod 755 try
  428. $eunicefix try
  429. if try; then
  430.     echo "Yup, it does."
  431. else
  432.     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  433. fi
  434. rm -f try today
  435.  
  436. : find out where common programs are
  437. echo " "
  438. echo "Locating common programs..."
  439. pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib"
  440. cat <<EOSC >loc
  441. $startsh
  442. thing=\$1
  443. shift
  444. dflt=\$1
  445. shift
  446. for dir in \$*; do
  447.     case "\$thing" in
  448.     .)
  449.     if test -d \$dir/\$thing; then
  450.         echo \$dir
  451.         exit 0
  452.     fi
  453.     ;;
  454.     *)
  455.     if test -f \$dir/\$thing; then
  456.         echo \$dir/\$thing
  457.         exit 0
  458.     fi
  459.     ;;
  460.     esac
  461. done
  462. echo \$dflt
  463. exit 1
  464. EOSC
  465. chmod 755 loc
  466. $eunicefix loc
  467. loclist="expr sed echo cat rm mv cp tail tr mkdir sort uniq grep"
  468. trylist="test inews egrep more pg Mcc"
  469. for file in $loclist; do
  470.     xxx=`loc $file $file $pth`
  471.     eval $file=$xxx
  472.     case "$xxx" in
  473.     /*)
  474.     echo $file is in $xxx.
  475.     ;;
  476.     *)
  477.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  478.     ;;
  479.     esac
  480. done
  481. echo " "
  482. echo "Don't worry if any of the following aren't found..."
  483. for file in $trylist; do
  484.     xxx=`loc $file $file $pth`
  485.     eval $file=$xxx
  486.     case "$xxx" in
  487.     /*)
  488.     echo $file is in $xxx.
  489.     ;;
  490.     *)
  491.     echo "I don't see $file out there, offhand."
  492.     ;;
  493.     esac
  494. done
  495. case $egrep in
  496. egrep)
  497.     echo "Substituting grep for egrep."
  498.     egrep=$grep
  499.     ;;
  500. *)
  501.     case "$contains" in
  502.     grep*) contains=e$contains;;
  503.     esac
  504.     ;;
  505. esac
  506. case $test in
  507. test)
  508.     echo "Hopefully test is built into your sh."
  509.     ;;
  510. /bin/test)
  511.     echo " "
  512.     echo $n 'Is your "test" built into sh? [n] (OK to guess) '"$c"
  513.     . myread
  514.     case $ans in
  515.     y*) test=test ;;
  516.     esac
  517.     ;;
  518. *)
  519.     test=test
  520.     ;;
  521. esac
  522. case $echo in
  523. echo)
  524.     echo "Hopefully echo is built into your sh."
  525.     ;;
  526. /bin/echo)
  527.     echo " "
  528.     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  529.     $echo $n "hi there$c" >foo1
  530.     echo $n "hi there$c" >foo2
  531.     if cmp foo1 foo2 >/dev/null 2>&1; then
  532.     echo "They are compatible.  In fact, they may be identical."
  533.     else
  534.     echo "They are not compatible--the echo builtin will be used."
  535.     echo=echo
  536.     fi
  537.     $rm -f foo1 foo2
  538.     ;;
  539. *)
  540.     echo=echo
  541.     ;;
  542. esac
  543.  
  544. : decide how portable to be
  545. case "$portable" in
  546. define) dflt=y;;
  547. *)    dflt=n;;
  548. esac
  549. $cat <<'EOH'
  550.  
  551. I can set things up so that your shell scripts and binaries are more portable,
  552. at what may be a noticable cost in performance.  In particular, if you
  553. ask to be portable, the following happens:
  554.  
  555.      1) shell scripts will rely on the PATH variable rather than using
  556.     the paths derived above.
  557.      2) ~username interpretations will be done at run time rather than
  558.     by Configure.
  559.      3) the system name will be determined at run time, if at all possible.
  560.  
  561. EOH
  562. $echo $n "Do you expect to run these scripts and binaries on multiple machines? [$dflt] $c"
  563. . myread
  564. case $ans in
  565. '') ans=$dflt;;
  566. esac
  567. case $ans in
  568.     y*) portable=define
  569.     for file in $loclist; do
  570.         eval $file=$file
  571.     done
  572.     ;;
  573.     *)  portable=undef ;;
  574. esac
  575.  
  576. : set up shell script to do ~ expansion
  577. cat >filexp <<EOSS
  578. $startsh
  579. : expand filename
  580. case \$1 in
  581. ~/*|~)
  582.     $echo \$1 | $sed "s/~/\${HOME-\$LOGDIR}/"
  583.     ;;
  584. ~*)
  585.     if $test -f /bin/csh; then
  586.     /bin/csh -f -c "glob \$1"
  587.     $echo " "
  588.     else
  589.     name=\`$expr x\$1 : '..\([^/]*\)'\`
  590.     dir=\`$sed </etc/passwd -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}'\`
  591.     if $test ! -d "\$dir"; then
  592.         me=\`basename \$0\`
  593.         $echo "\$me: can't locate home directory for: \$name" >&2
  594.         exit 1
  595.     fi
  596.     case \$1 in
  597.     */*)
  598.         $echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  599.         ;;
  600.     *)
  601.         $echo \$dir
  602.         ;;
  603.     esac
  604.     fi
  605.     ;;
  606. *)
  607.     $echo \$1
  608.     ;;
  609. esac
  610. EOSS
  611. chmod 755 filexp
  612. $eunicefix filexp
  613.  
  614. : now get the site name
  615. $echo " "
  616. $echo "Figuring out site name..."
  617. $echo 'Maybe "hostname" will work...'
  618. if ans=`sh -c hostname 2>&1` ; then
  619.     sitename=$ans
  620.     hostcmd=hostname
  621. else
  622.     $echo 'No, maybe "uuname -l" will work...'
  623.     if ans=`sh -c 'uuname -l' 2>&1` ; then
  624.     sitename=$ans
  625.     hostcmd='uuname -l'
  626.     else
  627.     $echo 'Strange.  Maybe "uname -n" will work...'
  628.     if ans=`sh -c 'uname -n' 2>&1` ; then
  629.         sitename=$ans
  630.         hostcmd='uname -n'
  631.     else
  632.         $echo 'Oh well, maybe I can mine it out of whoami.h...'
  633.         if ans=`sh -c $contains' sysname /usr/include/whoami.h' 2>&1` ; then
  634.         sitename=`$echo "$ans" | $sed 's/^.*"\(.*\)"/\1/'`
  635.         hostcmd="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' </usr/include/whoami.h"
  636.         else
  637.         case "$sitename" in
  638.         '') echo "Does this machine have an identity crisis or something?"
  639.             hostcmd=''
  640.             ;;
  641.         *)  echo "Well, you said $sitename before...";;
  642.         esac
  643.         fi
  644.     fi
  645.     fi
  646. fi
  647. : you do not want to know about this
  648. set $sitename
  649. sitename=$1
  650.  
  651. : translate upper to lower if necessary
  652. case $sitename in
  653.     *[A-Z]*)
  654.     sitename=`$echo $sitename | tr '[A-Z]' '[a-z]'`
  655.     $echo "(Normalizing case in your site name)"
  656.     ;;
  657. esac
  658.  
  659. : verify guess
  660. if $test "$sitename" ; then
  661.     $echo 'Your site name appears to be "'$sitename'".'
  662.     $echo $n "Is this correct? [y] $c"
  663.     . myread
  664.     case $ans in
  665.       y*|'')  ;;
  666.       *)      sitename='' ;;
  667.     esac
  668. fi
  669.  
  670. : bad guess or no guess
  671. while $test "X$sitename" = X ; do
  672.     $echo $n "Please type the (one word) name of your site: $c"
  673.     . myread
  674.     sitename="$ans"
  675.     case $hostcmd in
  676.     sed*)
  677.     $echo "(That doesn't agree with your whoami.h file, by the way.)"
  678.     ;;
  679.     *)
  680.     $echo "(That doesn't agree with your $hostcmd command, by the way.)"
  681.     ;;
  682.     esac
  683.     hostcmd=''
  684. done
  685.  
  686. : get organizaton name
  687. longshots='/usr/src/new /usr/src/local /usr/local/src'
  688. case "$orgname" in
  689. '') if xxx=`loc news/src/defs.h x $longshots`; then
  690.     dflt=`$sed -n 's/^.*MYORG[     ]*"\(.*\)".*$/\1/p' $xxx`
  691.     else
  692.     dflt='no default'
  693.     fi
  694.     ;;
  695. *)  dflt="$orgname";;
  696. esac
  697. $cat << 'EOH'
  698.  
  699. Please type the name of your organization as you want it to appear on the
  700. Organization line of outgoing articles.  (It's nice if this also specifies
  701. your location.  Your city name is probably sufficient if well known.)
  702. For example:
  703.  
  704.     University of Southern North Dakota, Hoople
  705.  
  706. You may also put the name of a file, as long as it begins with a slash.
  707. For example:
  708.  
  709.     /etc/organization
  710.  
  711. EOH
  712. orgname="no default"
  713. while test "X$orgname" = "Xno default"; do
  714.     $echo $n "Organization: [$dflt] $c"
  715.     . myread
  716.     case "$ans" in
  717.     '') orgname="$dflt";;
  718.     *)  orgname="$ans" ;;
  719.     esac
  720. done
  721.  
  722. : get news administrator name
  723. case "$newsadmin" in
  724. '')
  725.     if $contains "^news:" /etc/passwd >/dev/null 2>&1 ; then
  726.     dflt=news
  727.     else
  728.     if $contains "^usenet:" /etc/passwd >/dev/null 2>&1 ; then
  729.         dflt=news
  730.     else
  731.         if eunice; then
  732.         dflt=system
  733.         else
  734.         dflt=root
  735.         fi
  736.     fi
  737.     fi
  738.     ;;
  739. *)  dflt="$newsadmin"
  740.     ;;
  741. esac
  742. cat <<'EOM'
  743.  
  744. Many systems keep their news in a private directory, or have a non-superuser
  745. in charge of administering news.  (If you don't have such a user, take the
  746. default answer.)  What is the login name (not directory) that is used for news
  747. EOM
  748. echo $n "administration? [$dflt] $c"
  749. . myread
  750. newsadmin="$ans"
  751. case $newsadmin in
  752. '') newsadmin=$dflt ;;
  753. esac
  754. case $newsadmin in
  755. root) isadmin=undef ;;
  756. *)    isadmin=define ;;
  757. esac
  758.  
  759. : figure out news library
  760. case "$lib" in
  761. '')
  762.     dflt=/usr/lib/news
  763.     ;;
  764. *)  dflt=$lib ;;
  765. esac
  766. libexp=$lib
  767. libexp='blurfl/dyick'
  768. while $test ! -d "$libexp"; do
  769.     $echo " "
  770.     case "$libexp" in
  771.     blurfl*) ;;
  772.     *) $echo "Directory $libexp not found";;
  773.     esac
  774.     echo $n "Where is your news library (~name okay)? [$dflt] $c"
  775.     . myread
  776.     case "$ans" in
  777.     '') ans="$dflt";;
  778.     esac
  779.     lib="$ans"
  780.     case $lib in
  781.     ~*)
  782.     libexp=`filexp $lib`
  783.     echo "(That is $libexp on this particular system.)"
  784.     case $portable in
  785.       undef) lib=$libexp ;;
  786.     esac
  787.     ;;
  788.     *)
  789.     libexp=$lib
  790.     ;;
  791.     esac
  792. done
  793. if $test -f $libexp/inews; then
  794.     echo "Aha!  Inews is really in $libexp!  Maybe this is 2.10.2..."
  795.     case $inews in
  796.     inews) 
  797.     : null
  798.     ;;
  799.     *)
  800.     echo "(Make sure $inews isn't an old version.)"
  801.     ;;
  802.     esac
  803.     inews=$libexp/inews
  804. fi
  805.  
  806. : determine where manual pages go
  807. case "$mansrc" in
  808. '')
  809.     dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
  810.     ;;
  811. *)  dflt="$mansrc"
  812.     ;;
  813. esac
  814. mansrc='blurfl/dyick'
  815. while $test ! -d "$mansrc" ; do
  816.     case $mansrc in
  817.       blurfl*) ;;
  818.       *) $echo "$mansrc does not appear to exist." ;;
  819.     esac
  820.     $echo " "
  821.     $echo $n "Where do the manual pages (source) go? [$dflt] $c"
  822.     . myread
  823.     mansrc=`filexp "$ans"`
  824.     case $mansrc in
  825.       '') mansrc=$dflt ;;
  826.     esac
  827. done
  828. case "$mansrc" in
  829. *l)
  830.     manext=l
  831.     ;;
  832. *n)
  833.     manext=n
  834.     ;;
  835. *)
  836.     manext=1
  837.     ;;
  838. esac
  839.  
  840. : determine where mail is spooled
  841. case "$maildir" in
  842. '')
  843.     dflt=`loc . /usr/spool/mail /usr/spool/mail /usr/mail`
  844.     ;;
  845. *)  dflt="$maildir"
  846.     ;;
  847. esac
  848. maildir='blurfl/dyick'
  849. while $test ! -d "$maildir" ; do
  850.     case $maildir in
  851.       blurfl*) ;;
  852.       *) $echo "$maildir does not appear to exist." ;;
  853.     esac
  854.     $echo " "
  855.     $echo $n "Where is yet-to-be-read mail spooled? [$dflt] $c"
  856.     . myread
  857.     maildir=`filexp "$ans"`
  858.     case $maildir in
  859.       '') maildir=$dflt ;;
  860.     esac
  861. done
  862.  
  863. : find out how to find out full name
  864. $echo " "
  865. case "$berkname" in
  866. define)
  867.     dflt=y;;
  868. undef)
  869.     dflt=n;;
  870. *)
  871.     if bsd; then
  872.     dflt=y
  873.     else
  874.     dflt=n
  875.     fi
  876.     ;;
  877. esac
  878. $echo "Does your /etc/passwd file keep full names in Berkeley/V7 format (name first"
  879. $echo $n "thing after ':' in GCOS field)? [$dflt] $c"
  880. . myread
  881. case $ans in
  882.   '') ans=$dflt ;;
  883. esac
  884. case $ans in
  885.   y*)
  886.     passnam=define
  887.     berknam=define
  888.     usgnam=undef
  889.     nametype=bsd
  890.     ;;
  891.   *)
  892.     $echo " "
  893.     case "$usgname" in
  894.     define)
  895.     dflt=y;;
  896.     undef)
  897.     dflt=n;;
  898.     *)
  899.     if usg; then
  900.         dflt=y
  901.     else
  902.         dflt=n
  903.     fi
  904.     ;;
  905.     esac
  906.     $echo "Does your passwd file keep full names in USG format (name sandwiched"
  907.     $echo $n "between a '-' and a '(')? [$dflt] $c"
  908.     . myread
  909.     case $ans in
  910.       '') ans=$dflt ;;
  911.     esac
  912.     case $ans in
  913.       n*)
  914.     $echo "Full name will be taken from ~/.fullname"
  915.     passnam=undef
  916.     berknam=undef
  917.     usgnam=undef
  918.     nametype=other
  919.     ;;
  920.       *)
  921.     passnam=define
  922.     berknam=undef
  923.     usgnam=define
  924.     nametype=usg
  925.     ;;
  926.     esac
  927.     ;;
  928. esac
  929.  
  930. : see if we need a special compiler
  931. $echo " "
  932. if usg; then
  933.     case "$cc" in
  934.     '')
  935.     case "$Mcc" in
  936.     /*) dflt='Mcc'
  937.         ;;
  938.     *)
  939.         if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
  940.         dflt='cc -M'
  941.         else
  942.         dflt='cc'
  943.         fi
  944.         ;;
  945.     esac
  946.     ;;
  947.     *)  dflt="$cc";;
  948.     esac
  949.     $cat <<'EOM'
  950.  
  951. On some systems the default C compiler will not resolve multiple global
  952. references that happen to have the same name.  On some such systems the
  953. "Mcc" command may be used to force these to be resolved.  On other systems
  954. a "cc -M" command is required.  What command will force resolution on
  955. EOM
  956.     $echo $n "this system? [$dflt] $c"
  957.     . myread
  958.     cc="$ans"
  959.     case "$cc" in
  960.     '') cc="$dflt" ;;
  961.     esac
  962. else
  963.     $echo "Not a USG system--assuming cc can resolve multiple definitions."
  964.     cc=cc
  965. fi
  966.  
  967. : see if we should throw a -i into the Makefile
  968. $echo " "
  969. if pdp11; then
  970.     if $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1 ; then
  971.     $echo $n "Your system appears to have separate I and D space.  Is this true? [y] $c"
  972.     . myread
  973.     case $ans in
  974.         n*|f*) iandd='' ;;
  975.         *)     iandd='-i' ;;
  976.     esac
  977.     else
  978.     $echo "Your system appears to NOT have separate I and D space."
  979.     $echo $n "Is this correct? [y] $c"
  980.     . myread
  981.     case $ans in
  982.         n*|f*) iandd='-i' ;;
  983.         *)     iandd='' ;;
  984.     esac
  985.     fi
  986. else
  987.     $echo "Not a pdp11--assuming no separate I and D."
  988. fi
  989.  
  990. : index or strcpy
  991. $echo " "
  992. if $contains index.o libc.list >/dev/null 2>&1 ; then
  993.     $echo "Your system appears to use index() and rindex() rather than strchr()"
  994.     $echo $n "and strrchr().  Is this correct? [y] $c"
  995.     . myread
  996.     case $ans in
  997.     n*|f*) strchr='define' ;;
  998.     *)     strchr='undef' ;;
  999.     esac
  1000. else
  1001.     $echo "Your system appears to use strchr() and strrchr() rather than index()"
  1002.     $echo $n "and rindex().  Is this correct? [y] $c"
  1003.     . myread
  1004.     case $ans in
  1005.     n*|f*) strchr=undef ;;
  1006.     *)     strchr=define ;;
  1007.     esac
  1008. fi
  1009.  
  1010. : determine how to determine when a file is a mailbox
  1011. case "$mboxchar" in
  1012. '') dflt=F;;
  1013. *)  dflt="$mboxchar";;
  1014. esac
  1015. $cat <<'EOM'
  1016.  
  1017. In saving articles, rn wants to differentiate between saving to mailbox
  1018. format files and normal files.  It does this by examining the first character
  1019. of the file in question.  On most systems the first line starts "From...",
  1020. so the first character is F.  On other systems there are magic cookies like
  1021. control codes between articles, so one of those would be first.  On your
  1022. system, if a file is in mailbox format, what is the first character of
  1023. EOM
  1024. echo $n "that file? [$dflt] $c"
  1025. . myread
  1026. mboxchar="$ans"
  1027. case $mboxchar in
  1028. '') mboxchar="$dflt" ;;
  1029. esac
  1030. case $mboxchar in
  1031. 'F') ;;
  1032. *)  cat <<'EOM'
  1033. You will need to edit the shell script mbox.saver to properly append an
  1034. article to a mailbox.  The arguments to the script are documented in
  1035. EOM
  1036.     case $shsharp in
  1037.     false)
  1038.     echo "comments in mbox.saver.std."
  1039.     ;;
  1040.     true)
  1041.     echo "comments in the shell script itself."
  1042.     ;;
  1043.     esac
  1044. esac
  1045.  
  1046. : where do we get termlib routines from
  1047. $echo " "
  1048. if $test -d /usr/lib/terminfo || $test -d /etc/term; then
  1049.     termlib='-lcurses'
  1050.     havetlib=define
  1051.     $echo "Terminfo library found."
  1052. else
  1053.     if loc libtermlib.a x /usr/lib /usr/local/lib /lib >/dev/null; then
  1054.     termlib='-ltermlib'
  1055.     havetlib=define
  1056.     $echo "Termlib library found."
  1057.     else
  1058.     if loc libtermcap.a x /usr/lib /usr/local/lib /lib >/dev/null; then
  1059.         termlib='-ltermcap'
  1060.         havetlib=define
  1061.         $echo "Termcap library found."
  1062.     else
  1063.         case "$termlib" in
  1064.         '')
  1065.         $echo $n "Your system appears to NOT have termlib-style routines.  Is this true? [y] $c"
  1066.         . myread
  1067.         case $ans in
  1068.             n*|f*) havetlib=define
  1069.               $echo "Then where are the termlib-style routines kept (specify either -llibname"
  1070.               $echo $n " or full pathname (~name ok))? $c"
  1071.               . myread
  1072.               termlib=`filexp $ans`
  1073.               ;;
  1074.             *)    havetlib=undef
  1075.               termlib=''
  1076.               $echo "You will have to play around with term.c then."
  1077.               ;;
  1078.         esac
  1079.         $echo " "
  1080.         ;;
  1081.         *)  $echo "You said termlib was $termlib before."
  1082.         ;;
  1083.         esac
  1084.     fi
  1085.     fi
  1086. fi
  1087.  
  1088. : see if there is a whoami file
  1089. if $test -r /usr/include/whoami.h ; then
  1090.     whoami=define
  1091.     $echo "whoami.h found."
  1092. else
  1093.     whoami=undef
  1094. fi
  1095.  
  1096. : see if this is a termio system
  1097. if $test -r /usr/include/termio.h ; then
  1098.     termio=define
  1099.     $echo "termio.h found."
  1100. else
  1101.     if $test -r /usr/include/sgtty.h ; then
  1102.     termio=undef
  1103.     $echo "sgtty.h found."
  1104.     else
  1105.     termio=undef
  1106.     $echo "Neither termio.h nor sgtty.h found--you could have problems."
  1107.     fi
  1108. fi
  1109.  
  1110. : see if this is a termio system
  1111. if $test -r /usr/include/fcntl.h ; then
  1112.     fcntl=define
  1113.     $echo "fcntl.h found."
  1114. else
  1115.     fcntl=undef
  1116.     $echo "No fcntl.h found, but that's ok."
  1117. fi
  1118.  
  1119. : see if ioctl defs are in sgtty/termio or sys/ioctl
  1120. if $test -r /usr/include/sys/ioctl.h ; then
  1121.     ioctl=define
  1122.     $echo "sys/ioctl.h found."
  1123. else
  1124.     ioctl=undef
  1125.     $echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
  1126. fi
  1127.  
  1128. : see if there is a vfork
  1129. if $contains vfork.o libc.list >/dev/null 2>&1 ; then
  1130.     $echo "vfork() found."
  1131.     novfork='undef'
  1132. else
  1133.     $echo "No vfork() found--will use fork() instead."
  1134.     novfork='define'
  1135. fi
  1136.  
  1137. : see if there is a getpw
  1138. if $contains getpw.o libc.list >/dev/null 2>&1 ; then
  1139.     $echo "getpw() found."
  1140.     getpwent='undef'
  1141. else
  1142.     $echo "No getpw() found--will use getpwent() instead."
  1143.     getpwent='define'
  1144. fi
  1145.  
  1146. : see how we will look up site name
  1147. douname=undef
  1148. gethostname=undef
  1149. phostname=undef
  1150. if $contains gethostname.o libc.list >/dev/null 2>&1 ; then
  1151.     $echo "gethostname() found."
  1152.     gethostname=define
  1153. else
  1154.     if $contains uname.o libc.list >/dev/null 2>&1 ; then
  1155.     $echo "uname() found."
  1156.     douname=define
  1157.     else
  1158.     case $hostcmd in
  1159.       '') ;;
  1160.       *)
  1161.         $cat <<EOT
  1162.  
  1163. There is no gethostname() or uname() on this system.  You have two
  1164. possibilites at this point:
  1165.  
  1166. 1)  You can have your site name ($sitename) compiled into rn, which lets rn
  1167.     start up faster, but makes your binaries non-portable, or
  1168. 2)  you can have rn use a
  1169.     
  1170.     popen("$hostcmd","r")
  1171.  
  1172.     which will start slower but be more portable.
  1173.  
  1174. Option 1 will use whoami.h if you have one.  If you want option 2 but with
  1175. a different command, you can edit config.h after this shell script is done.
  1176.  
  1177. EOT
  1178.         case "$phostname" in
  1179.         define) dflt=n;;
  1180.         undef)  dflt=y;;
  1181.         '')
  1182.         case $portable in
  1183.         define) dflt=n ;;
  1184.         *)      dflt=y ;;
  1185.         esac
  1186.         ;;
  1187.         esac
  1188.         $echo $n "Do you want your site name compiled in? [$dflt] $c"
  1189.         . myread
  1190.         case $ans in
  1191.         '') ans=$dflt;;
  1192.         esac
  1193.         case $ans in
  1194.           n*) phostname=define ;;
  1195.           *)  hostcmd='' phostname=undef;;
  1196.         esac
  1197.         ;;
  1198.     esac
  1199.     case $hostcmd in
  1200.       '')
  1201.         case $whoami in
  1202.           define)
  1203.         $echo 'No hostname function--using whoami.h.'
  1204.         ;;
  1205.           undef)
  1206.         $echo 'No hostname function--hardwiring "'$sitename'".'
  1207.         ;;
  1208.         esac
  1209.         ;;
  1210.     esac
  1211.     fi
  1212. fi
  1213.  
  1214. : see if we need -ljobs and if we have sigset, etc.
  1215. if $test -r /usr/lib/libjobs.a || $test -r /usr/local/lib/libjobs.a ; then
  1216.     $echo "Jobs library found."
  1217.     normsig=undef
  1218.     jobslib='-ljobs'
  1219. else
  1220.     if bsd; then
  1221.     $echo "No jobs library found.  (I suppose this is 4.2...)"
  1222.     else
  1223.     $echo "No jobs library found.  (That's okay, we all have our faults.)"
  1224.     fi
  1225.     normsig=define
  1226.     jobslib=''
  1227. fi
  1228.  
  1229. : see if there are directory access routines out there
  1230. if $test -r /usr/lib/libndir.a || $test -r /usr/local/lib/libndir.a ; then
  1231.     $echo "Ndir library found."
  1232.     ndirlib='-lndir'
  1233.     libndir=define
  1234.     usendir=undef
  1235.     ndirc=''
  1236.     ndiro=''
  1237. else
  1238.     ndirlib=''
  1239.     libndir=undef
  1240.     if $contains readdir.o libc.list >/dev/null 2>&1 ; then
  1241.     $echo "No ndir library found, but you have readdir() so we'll use that."
  1242.     usendir=undef
  1243.     ndirc=''
  1244.     ndiro=''
  1245.     else
  1246.     $echo "No ndir library found and no readdir() found--using ./ndir.c."
  1247.     usendir=define
  1248.     ndirc='ndir.c'
  1249.     ndiro='ndir.o'
  1250.     fi
  1251. fi
  1252.  
  1253. : locate spool directory
  1254. case "$spool" in
  1255. '')
  1256.     dflt=/usr/spool/news
  1257.     ;;
  1258. *)  dflt="$spool";;
  1259. esac
  1260. ans='blurfl/dyick'
  1261. while $test ! -d $ans; do
  1262.     $echo " "
  1263.     case "$ans" in
  1264.     blurfl*);;
  1265.     *) echo "Directory $ans not found.";;
  1266.     esac
  1267.     $echo $n "Where is news spooled (~name ok)? [$dflt] $c"
  1268.     . myread
  1269.     case "$ans" in
  1270.     '') ans="$dflt";;
  1271.     esac
  1272.     spool="$ans"
  1273.     case $spool in
  1274.     ~*)
  1275.     ans=`filexp $spool`
  1276.     echo "(That is $ans on this particular system.)"
  1277.     case $portable in
  1278.       undef) spool=$ans ;;
  1279.     esac
  1280.     ;;
  1281.     *)
  1282.     ans=$spool
  1283.     ;;
  1284.     esac
  1285. done
  1286.  
  1287. : locate active file
  1288. case "$active" in
  1289. '')
  1290.     dflt=$lib/active
  1291.     ;;
  1292. *)  dflt="$active";;
  1293. esac
  1294. myactive='blurfl/dyick'
  1295. while $test ! -f "$myactive"; do
  1296.     $echo " "
  1297.     case "$myactive" in
  1298.     blurfl*);;
  1299.     *) "File $myactive not found.";;
  1300.     esac
  1301.     $echo $n "Where is the active file (~name ok)? [$dflt] $c"
  1302.     . myread
  1303.     case "$ans" in
  1304.     '') ans="$dflt";;
  1305.     esac
  1306.     active="$ans"
  1307.     case $active in
  1308.     ~*)
  1309.     myactive=`filexp $active`
  1310.     echo "(That is $myactive on this particular system.)"
  1311.     case $portable in
  1312.       undef) active=$myactive ;;
  1313.     esac
  1314.     ;;
  1315.     *)
  1316.     myactive=$active
  1317.     ;;
  1318.     esac
  1319.     if $test -d $myactive ; then
  1320.     myactive=$myactive/active
  1321.     active=$active/active
  1322.     fi
  1323. done
  1324.  
  1325. : check for 2.10.2
  1326. echo " "
  1327. if $contains ' [0-9][0-9]* [0-9]' "$myactive" >/dev/null 2>&1; then
  1328.     echo "Looks like you are running at least 2.10.2 news."
  1329.     mininact=define
  1330. else
  1331.     echo "It doesn't look like you are running 2.10.2 news yet.  Are you planning"
  1332.     echo $n "to install it in the near future? [y] $c"
  1333.     . myread
  1334.     case $ans in
  1335.     n*) mininact=undef ;;
  1336.     *)  mininact=define ;;
  1337.     esac
  1338. fi
  1339.  
  1340.  
  1341. : check for void type
  1342. $echo " "
  1343. $echo "Checking to see if your C compiler groks the void type..."
  1344. $cat >try.c <<'EOCP'
  1345. void main();
  1346. EOCP
  1347. if cc -c try.c >/dev/null 2>&1 ; then
  1348.     novoid='undef'
  1349.     $echo "Yup, it does."
  1350. else
  1351.     novoid='define'
  1352.     $echo "Nope, it doesn't (boo hiss).  I will substitute int."
  1353. fi
  1354. $rm try.*
  1355.  
  1356. : find out which shell people like to use most
  1357. ans='blurfl/dyick'
  1358. while $test ! -f "$ans" ; do
  1359.     case $ans in
  1360.       blurfl*) ;;
  1361.       *) $echo "$ans does not appear to exist." ;;
  1362.     esac
  1363.     case "$pref" in
  1364.     '')
  1365.     if $test -f /bin/ksh; then
  1366.         dflt='/bin/ksh'
  1367.     else
  1368.         if $test -f /bin/csh; then
  1369.         dflt='/bin/csh'
  1370.         else
  1371.         dflt='/bin/sh'
  1372.         fi
  1373.     fi
  1374.     ;;
  1375.     *)  dflt="$pref";;
  1376.     esac
  1377.     $echo " "
  1378.     $echo "Give the full path name of the shell most people like to use on your"
  1379.     $echo $n "system: [$dflt] $c"
  1380.     . myread
  1381.     case $ans in
  1382.       '') ans=$dflt ;;
  1383.     esac
  1384. done
  1385. pref=$ans
  1386.  
  1387. : locate the preferred pager for this system
  1388. case "$pager" in
  1389. '')
  1390.     case $pg in
  1391.     /*) dflt=$pg
  1392.     ;;
  1393.     esac
  1394.     case $more in
  1395.     /*) dflt=$more
  1396.     ;;
  1397.     esac
  1398.     case $dflt in
  1399.     '') dflt=/usr/ucb/more
  1400.     ;;
  1401.     esac
  1402.     ;;
  1403. *)  dflt="$pager";;
  1404. esac
  1405. pager='blurfl/dyick'
  1406. while $test ! -f "$pager" ; do
  1407.     case $pager in
  1408.       blurfl*)
  1409.     $echo " "
  1410.     $echo "(If your kernel does terminal paging then you may answer this with '/bin/cat'.)"
  1411.     ;;
  1412.       /*) $echo "$pager does not appear to exist."
  1413.     $echo " "
  1414.         ;;
  1415.       *) $echo "Please give the full path name."
  1416.     $echo " "
  1417.         ;;
  1418.     esac
  1419.     $echo $n "What pager is used on your system? [$dflt] $c"
  1420.     . myread
  1421.     pager="$ans"
  1422.     case $pager in
  1423.       '') pager="$dflt" ;;
  1424.     esac
  1425. done
  1426.  
  1427. : determine default editor
  1428. case "$defeditor" in
  1429. '')
  1430.     dflt=/usr/ucb/vi
  1431.     ;;
  1432. *)  dflt="$defeditor"
  1433.     ;;
  1434. esac
  1435. defeditor='blurfl/dyick'
  1436. while $test ! -f "$defeditor" ; do
  1437.     case $defeditor in
  1438.       blurfl*) ;;
  1439.       *) $echo "$defeditor does not appear to exist." ;;
  1440.     esac
  1441.     $echo " "
  1442.     $echo $n "What is the default editor on your system? [$dflt] $c"
  1443.     . myread
  1444.     defeditor="$ans"
  1445.     case $defeditor in
  1446.       '') defeditor=$dflt ;;
  1447.     esac
  1448. done
  1449.  
  1450. : determine mailer for Rnmail to use
  1451. echo " "
  1452. if $test -f /usr/lib/sendmail; then
  1453.     mailer=/usr/lib/sendmail
  1454. else
  1455.     if usg && $test -f $libexp/recmail; then
  1456.     mailer=$libexp/recmail
  1457.     else
  1458.     mailer=/bin/mail
  1459.     fi
  1460. fi
  1461. echo "Mail sender is $mailer"
  1462.  
  1463. : check for internet mailer
  1464. case "$internet" in
  1465. define) dflt=y;;
  1466. undef)    dflt=n;;
  1467. *)    dflt=n;;
  1468. esac
  1469. cat <<EOM
  1470.  
  1471. Some newer mailers can deliver mail to addresses of the INTERNET persuasion,
  1472. such as user@host.UUCP.  Other older mailers require the complete path to
  1473. the destination to be specified in the address.  Does your mailer understand
  1474. EOM
  1475. $echo $n "INTERNET addresses? [$dflt] $c"
  1476. . myread
  1477. case "$ans" in
  1478. '') ans=$dflt;;
  1479. esac
  1480. case "$ans" in
  1481. y*) internet=define;;
  1482. *)  internet=undef;;
  1483. esac
  1484.  
  1485. : determine where public executables go
  1486. case "$rnbin" in
  1487. '')
  1488.     dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
  1489.     ;;
  1490. *)  dflt="$rnbin"
  1491.     ;;
  1492. esac
  1493. rnbin='blurfl/dyick'
  1494. while $test ! -d "$rnbin" ; do
  1495.     case $rnbin in
  1496.       blurfl*) ;;
  1497.       *) $echo "$rnbin does not appear to exist." ;;
  1498.     esac
  1499.     $echo " "
  1500.     $echo $n "Where do you want to put the public executables? [$dflt] $c"
  1501.     . myread
  1502.     rnbin="$ans"
  1503.     rnbin=`filexp $rnbin`
  1504.     case $rnbin in
  1505.       '') rnbin=$dflt ;;
  1506.     esac
  1507. done
  1508.  
  1509. : determine where private executables go
  1510. case "$rnlib" in
  1511. '')
  1512.     dflt=$lib/rn
  1513.     ;;
  1514. *)  dflt="$rnlib"
  1515.     ;;
  1516. esac
  1517. $echo " "
  1518. $echo "Rn has a number of auxiliary programs that need not be visible to the"
  1519. $echo "whole world.  Where do you want to put these private executables?"
  1520. $echo $n "[$dflt] (~name ok) $c"
  1521. . myread
  1522. rnlib="$ans"
  1523. case $rnlib in
  1524.   '') rnlib=$dflt ;;
  1525. esac
  1526. case $portable in
  1527. undef)
  1528.     rnlib=`filexp $rnlib`
  1529.     ;;
  1530. esac
  1531. : must not allow self reference
  1532. case $rnlib in
  1533.   /*)
  1534.     filexp=$rnlib/filexp
  1535.     ;;
  1536.   *)
  1537.     filexp=`pwd`/filexp
  1538.     ;;
  1539. esac
  1540.  
  1541. : get the local distribution prefixes
  1542. if $test -f $libexp/sys ; then
  1543.     $sed <$libexp/sys -n -e "s/^$sitename://p" | \
  1544.     $sed -e "s/:.*//" -e "s/,/ /g" | tr ' ' '\012' | \
  1545.     $sed -e "/^to./d" -e "/^net$/d" -e "/^fa$/d" -e "/^mod$/d" > .distlist
  1546. fi
  1547.  
  1548. $cat <<'EOH'
  1549.  
  1550. Distribution groups are the things you use on the Distribution line to limit
  1551. where an article will go to.  You are likely to be a member of several
  1552. distribution groups, such as organization, city, state, province, country,
  1553. continent, etc.  For example, Los Angeles has the distribution prefix "la",
  1554. New Jersey has the prefix "nj", and Europe has the prefix "eunet".
  1555.  
  1556. The categories you will be asked are: 
  1557.  
  1558. local organization    (Could be just one machine or a cluster or an office)
  1559. organization        att, dec, kgb, ...
  1560. city            la, ny, mosc, ...
  1561. state/province        ca, nj, bc, ...
  1562. country            usa, can, rok, whatever
  1563. continent        na (North America, not "Not Applicable"), asia, etc.
  1564.  
  1565. (If you don't have a distribution prefix in any of these categories then
  1566. just hit return.)
  1567.  
  1568. EOH
  1569. if $test -f .distlist; then
  1570.     distlist=`tr '\012' ' ' <.distlist`
  1571.     if $test "$distlist" ; then
  1572.     $echo "(These are the distributions in your sys file: $distlist)"
  1573.     $echo " "
  1574.     fi
  1575. fi
  1576. case "$locpref" in
  1577. '') dflt="";;
  1578. *)  dflt="[$locpref] ";;
  1579. esac
  1580. $echo $n "What is the distribution prefix for your local organization? $dflt$c"
  1581. . myread
  1582. case "$ans" in
  1583. '') ;;
  1584. *)  locpref="$ans";;
  1585. esac
  1586. case $locpref in
  1587.   '') locpref=none ;;
  1588. esac
  1589. case "$orgpref" in
  1590. '') dflt="";;
  1591. *)  dflt="[$orgpref] ";;
  1592. esac
  1593. $echo $n "What is the distribution prefix for your organization? $dflt$c"
  1594. . myread
  1595. case "$ans" in
  1596. '') ;;
  1597. *)  orgpref="$ans";;
  1598. esac
  1599. case $orgpref in
  1600.   '') orgpref=none ;;
  1601. esac
  1602. case "$citypref" in
  1603. '') dflt="";;
  1604. *)  dflt="[$citypref] ";;
  1605. esac
  1606. $echo $n "What is the distribution prefix for your city? $dflt$c"
  1607. . myread
  1608. case "$ans" in
  1609. '') ;;
  1610. *)  citypref="$ans";;
  1611. esac
  1612. case $citypref in
  1613.   '') citypref=none ;;
  1614. esac
  1615. case "$statepref" in
  1616. '') dflt="";;
  1617. *)  dflt="[$statepref] ";;
  1618. esac
  1619. $echo $n "What is the distribution prefix for your state/province? $dflt$c"
  1620. . myread
  1621. case "$ans" in
  1622. '') ;;
  1623. *)  statepref="$ans";;
  1624. esac
  1625. case $statepref in
  1626.   '') statepref=none ;;
  1627. esac
  1628. case "$cntrypref" in
  1629. '') dflt="";;
  1630. *)  dflt="[$cntrypref] ";;
  1631. esac
  1632. $echo $n "What is the distribution prefix for your country? $dflt$c"
  1633. . myread
  1634. case "$ans" in
  1635. '') ;;
  1636. *)  cntrypref="$ans";;
  1637. esac
  1638. case $cntrypref in
  1639.   '') cntrypref=none ;;
  1640. esac
  1641. case "$contpref" in
  1642. '') dflt="";;
  1643. *)  dflt="[$contpref] ";;
  1644. esac
  1645. $echo $n "What is the distribution prefix for your continent? $dflt$c"
  1646. . myread
  1647. case "$ans" in
  1648. '') ;;
  1649. *)  contpref="$ans";;
  1650. esac
  1651. case $contpref in
  1652.   '') contpref=none ;;
  1653. esac
  1654.  
  1655. $echo " "
  1656. $echo "If you have any other distribution groups you will need to edit Pnews"
  1657. $echo "and newsetup to add them."
  1658. $echo " "
  1659.  
  1660. : determine root id
  1661. rootid=`$sed </etc/passwd -e "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e "q" -e "}" -e "d"`
  1662. case $rootid in
  1663.   '') rootid=0 ;;
  1664.   *)  $echo "Root uid = $rootid" ;;
  1665. esac
  1666.  
  1667. : weed out incompatibilities
  1668. case $douname in
  1669.   define) whoami=undef ;;
  1670. esac
  1671.  
  1672. : preserve RCS keywords in files with variable substitution, grrr
  1673. Log='$Log'
  1674. Header='$Header'
  1675.  
  1676. : Warnings
  1677. if v7; then
  1678.     cat <<'EOM'
  1679.  
  1680. NOTE: the V7 compiler may ignore some #undefs that rn uses.  If so, you will
  1681. get messages about redefining EXT.  Some V7 compilers also have difficulties
  1682. with #defines near buffer boundaries, so beware.  You may have to play with
  1683. the spacing in common.h.
  1684. EOM
  1685. fi
  1686.  
  1687. if pdp11; then
  1688.     cat <<'EOM'
  1689.  
  1690. NOTE: the PDP-11 does not have enough data space to do subject caching
  1691. reliably.  That feature will be disabled automatically.  Subject searching
  1692. will tend to be slow.
  1693. EOM
  1694. fi
  1695.  
  1696. $echo " "
  1697. $echo "End of configuration questions."
  1698. $echo " "
  1699.  
  1700. : create config.sh file
  1701. $echo " "
  1702. $echo "Creating config.sh..."
  1703. $spitshell <<EOT >config.sh
  1704. $startsh
  1705. # config.sh
  1706. # This file was produced by running the Configure script.
  1707.  
  1708. n="$n"
  1709. c="$c"
  1710. libc="$libc"
  1711. eunicefix="$eunicefix"
  1712. eunice="$eunice"
  1713. cpp="$cpp"
  1714. shsharp="$shsharp"
  1715. startsh="$startsh"
  1716. spitshell="$spitshell"
  1717. test="$test"
  1718. expr="$expr"
  1719. sed="$sed"
  1720. echo="$echo"
  1721. cat="$cat"
  1722. rm="$rm"
  1723. mv="$mv"
  1724. cp="$cp"
  1725. tail="$tail"
  1726. tr="$tr"
  1727. mkdir="$mkdir"
  1728. sort="$sort"
  1729. uniq="$uniq"
  1730. inews="$inews"
  1731. grep="$grep"
  1732. egrep="$egrep"
  1733. contains="$contains"
  1734. lib="$lib"
  1735. libexp="$libexp"
  1736. nametype="$nametype"
  1737. cc="$cc"
  1738. iandd="$iandd"
  1739. termlib="$termlib"
  1740. jobslib="$jobslib"
  1741. ndirlib="$ndirlib"
  1742. libndir="$libndir"
  1743. usendir="$usendir"
  1744. ndirc="$ndirc"
  1745. ndiro="$ndiro"
  1746. pager="$pager"
  1747. mailer="$mailer"
  1748. internet="$internet"
  1749. rnbin="$rnbin"
  1750. filexp="$filexp"
  1751. distlist="$distlist"
  1752. Log="$Log"
  1753. Header="$Header"
  1754. sitename="$sitename"
  1755. orgname="$orgname"
  1756. isadmin="$isadmin"
  1757. newsadmin="$newsadmin"
  1758. rnlib="$rnlib"
  1759. mansrc="$mansrc"
  1760. manext="$manext"
  1761. maildir="$maildir"
  1762. spool="$spool"
  1763. active="$active"
  1764. myactive="$myactive"
  1765. mininact="$mininact"
  1766. pref="$pref"
  1767. defeditor="$defeditor"
  1768. rootid="$rootid"
  1769. mboxchar="$mboxchar"
  1770. locpref="$locpref"
  1771. orgpref="$orgpref"
  1772. citypref="$citypref"
  1773. statepref="$statepref"
  1774. cntrypref="$cntrypref"
  1775. contpref="$contpref"
  1776. strchr="$strchr"
  1777. novoid="$novoid"
  1778. novfork="$novfork"
  1779. portable="$portable"
  1780. passnam="$passnam"
  1781. berknam="$berknam"
  1782. usgnam="$usgnam"
  1783. whoami="$whoami"
  1784. termio="$termio"
  1785. fcntl="$fcntl"
  1786. ioctl="$ioctl"
  1787. normsig="$normsig"
  1788. havetlib="$havetlib"
  1789. getpwent="$getpwent"
  1790. gethostname="$gethostname"
  1791. douname="$douname"
  1792. phostname="$phostname"
  1793. hostcmd="$hostcmd"
  1794. CONFIG=true
  1795. EOT
  1796.  
  1797. : create config.h file
  1798. $echo " "
  1799. $echo "Creating config.h..."
  1800. $cat <<EOT >config.h
  1801. /* config.h
  1802.  * This file was produced by running the Configure script.
  1803.  * Feel free to modify any of this as the need arises.
  1804.  */
  1805.  
  1806. /* name of the site.  May be overridden by gethostname, uname, etc. */
  1807. #define SITENAME "$sitename"
  1808.  
  1809. /* name of the organization, may be a file name */
  1810. #define ORGNAME "$orgname"
  1811.  
  1812. /* login name of news administrator, if any. */
  1813. #$isadmin NEWSADMIN "$newsadmin"
  1814.  
  1815. /* news library, may use only ~ and %l expansion */
  1816. #define LIB "$lib"
  1817.  
  1818. /* rn private library, may use ~ expansion, %x and %l */
  1819. #define RNLIB "$rnlib"
  1820.  
  1821. /* location of the news spool directory, may use ~ expansion, %x and %l */
  1822. #define SPOOL "$spool"
  1823.  
  1824. /* location of the active file, may use ~ expansion, %x and %l */
  1825. #define ACTIVE "$active"
  1826.  
  1827. /* location of spooled mail */
  1828. #define MAILFILE "$maildir/%L"
  1829.  
  1830. /* default shell--ok to be a slow shell like csh */
  1831. #define PREFSHELL "$pref"
  1832.  
  1833. /* default editor */
  1834. #define DEFEDITOR "$defeditor"
  1835.  
  1836. /* root uid */
  1837. #define ROOTID $rootid
  1838.  
  1839. /* what is the first character of a mailbox? */
  1840. #define MBOXCHAR '$mboxchar'
  1841.  
  1842. /* how to cancel an article */
  1843. #define CANCEL "$inews -h <%h"
  1844.  
  1845. /* distribution groups */
  1846. #define LOCDIST "$locpref"
  1847. #define ORGDIST "$orgpref"
  1848. #define CITYDIST "$citypref"
  1849. #define STATEDIST "$statepref"
  1850. #define CNTRYDIST "$cntrypref"
  1851. #define CONTDIST "$contpref"
  1852.  
  1853. #$strchr    index strchr    /* cultural */
  1854. #$strchr    rindex strrchr    /*  differences? */
  1855. #$novoid    void int    /* is void to be avoided? */
  1856. #$novfork    vfork fork    /* is vfork too virtual? */
  1857. #$eunice    EUNICE        /* no linking? */
  1858. #$eunice    VMS        /* not currently used, here just in case */
  1859. #$usendir    USENDIR        /* include ndir.c? */
  1860. #$libndir    LIBNDIR        /* include /usr/include/ndir.h? */
  1861. #$mininact    MININACT    /* include 2.10.2 optimization? */
  1862. #$portable    PORTABLE    /* do we do extra lookups to start up? */
  1863. #$passnam    PASSNAMES    /* do names come from the passwd file? */
  1864.                 /*  (undef to take name from ~/.fullname) */
  1865. #$berknam    BERKNAMES    /* if so, are they Berkeley format? */
  1866.                 /* (that is, ":name,stuff:") */
  1867. #$usgnam    USGNAMES    /* or are they USG format? */
  1868.                 /* (that is, ":stuff-name(stuff):") */
  1869. #$whoami    WHOAMI        /* should we include whoami.h? */
  1870. #$termio    TERMIO        /* is this a termio system? */
  1871. #$fcntl        FCNTL        /* should we include fcntl.h? */
  1872. #$ioctl        IOCTL        /* are ioctl args all defined in one place? */
  1873. #$normsig    NORMSIG        /* use signal rather than sigset? */
  1874. #$havetlib    HAVETERMLIB    /* do we have termlib-style routines? */
  1875. #$getpwent    GETPWENT    /* need we include slow getpwent? */
  1876. #$internet    INTERNET    /* does our mailer do INTERNET addressing? */
  1877. #$gethostname    GETHOSTNAME    /* do we have a gethostname function? */
  1878. #$douname    DOUNAME        /* do we have a uname function? */
  1879. #$phostname    PHOSTNAME "$hostcmd"    /* how to get host name with popen */
  1880. EOT
  1881.  
  1882. CONFIG=true
  1883.  
  1884. $rm -f libc.list .distlist kit*isdone
  1885.  
  1886. echo " "
  1887. echo "Doing variable substitutions on various files..."
  1888. echo " "
  1889. set `$grep <MANIFEST '\.SH' | awk '{print $1}'`
  1890. for file in $*; do
  1891.     . $file
  1892. done
  1893.  
  1894. echo " "
  1895. echo 'Now you need to generate make dependencies by running "makedepend".'
  1896. echo 'You might prefer to run it in background: "makedepend > makedepend.out &"'
  1897. echo $n "Would you like me to run it for you (it takes quite a while)? [n] $c" 
  1898. . myread
  1899. case "$ans" in
  1900. y*) makedepend;;
  1901. esac
  1902. : end of Configure
  1903. !STUFFY!FUNK!
  1904. echo Extracting rcstuff.c
  1905. cat >rcstuff.c <<'!STUFFY!FUNK!'
  1906. /* $Header: rcstuff.c,v 4.3 85/05/01 11:45:56 lwall Exp $
  1907.  *
  1908.  * $Log:    rcstuff.c,v $
  1909.  * Revision 4.3  85/05/01  11:45:56  lwall
  1910.  * Baseline for release with 4.3bsd.
  1911.  * 
  1912.  */
  1913.  
  1914. #include "EXTERN.h"
  1915. #include "common.h"
  1916. #include "util.h"
  1917. #include "ngdata.h"
  1918. #include "term.h"
  1919. #include "final.h"
  1920. #include "rn.h"
  1921. #include "intrp.h"
  1922. #include "only.h"
  1923. #include "rcln.h"
  1924. #include "INTERN.h"
  1925. #include "rcstuff.h"
  1926.  
  1927. char *rcname INIT(Nullch);        /* path name of .newsrc file */
  1928. char *rctname INIT(Nullch);        /* path name of temp .newsrc file */
  1929. char *rcbname INIT(Nullch);        /* path name of backup .newsrc file */
  1930. char *softname INIT(Nullch);        /* path name of .rnsoft file */
  1931. FILE *rcfp INIT(Nullfp);            /* .newsrc file pointer */
  1932.  
  1933. #ifdef HASHNG
  1934.     short hashtbl[HASHSIZ];
  1935. #endif
  1936.  
  1937. bool
  1938. rcstuff_init()
  1939. {
  1940.     register NG_NUM newng;
  1941.     register char *s;
  1942.     register int i;
  1943.     register bool foundany = FALSE;
  1944.     char *some_buf;
  1945.     long length;
  1946.  
  1947. #ifdef HASHNG
  1948.     for (i=0; i<HASHSIZ; i++)
  1949.     hashtbl[i] = -1;
  1950. #endif
  1951.  
  1952.     /* make filenames */
  1953.  
  1954.     rcname = savestr(filexp(RCNAME));
  1955.     rctname = savestr(filexp(RCTNAME));
  1956.     rcbname = savestr(filexp(RCBNAME));
  1957.     softname = savestr(filexp(SOFTNAME));
  1958.     
  1959.     /* make sure the .newsrc file exists */
  1960.  
  1961.     newsrc_check();
  1962.  
  1963.     /* open .rnsoft file containing soft ptrs to active file */
  1964.  
  1965.     tmpfp = fopen(softname,"r");
  1966.     if (tmpfp == Nullfp)
  1967.     writesoft = TRUE;
  1968.  
  1969.     /* read in the .newsrc file */
  1970.  
  1971.     for (nextrcline = 0;
  1972.     (some_buf = get_a_line(buf,LBUFLEN,rcfp)) != Nullch;
  1973.     nextrcline++) {
  1974.                     /* for each line in .newsrc */
  1975.     char tmpbuf[10];
  1976.  
  1977.     newng = nextrcline;        /* get it into a register */
  1978.     length = len_last_line_got;    /* side effect of get_a_line */
  1979.     if (length <= 1) {        /* only a newline??? */
  1980.         nextrcline--;        /* compensate for loop increment */
  1981.         continue;
  1982.     }
  1983.     if (newng >= MAXRCLINE) {    /* check for overflow */
  1984.         fputs("Too many lines in .newsrc\n",stdout) FLUSH;
  1985.         finalize(1);
  1986.     }
  1987.     if (tmpfp != Nullfp && fgets(tmpbuf,10,tmpfp) != Nullch)
  1988.         softptr[newng] = atoi(tmpbuf);
  1989.     else
  1990.         softptr[newng] = 0;
  1991.     some_buf[--length] = '\0';    /* wipe out newline */
  1992.     if (some_buf == buf) {
  1993.         rcline[newng] = savestr(some_buf);
  1994.                     /* make a semipermanent copy */
  1995.     }
  1996.     else {
  1997.         /*NOSTRICT*/
  1998. #ifndef lint
  1999.         some_buf = saferealloc(some_buf,(MEM_SIZE)(length+1));
  2000. #endif lint
  2001.         rcline[newng] = some_buf;
  2002.     }
  2003. #ifdef NOTDEF
  2004.     if (strnEQ(some_buf,"to.",3)) {    /* is this a non-newsgroup? */
  2005.         nextrcline--;        /* destroy this line */
  2006.         continue;
  2007.     }
  2008. #endif
  2009.     if (*some_buf == ' ' ||
  2010.       *some_buf == '\t' ||
  2011.       strnEQ(some_buf,"options",7)) {        /* non-useful line? */
  2012.         toread[newng] = TR_JUNK;
  2013.         rcchar[newng] = ' ';
  2014.         rcnums[newng] = 0;
  2015.         continue;
  2016.     }
  2017.     for (s = rcline[newng]; *s && *s != ':' && *s != NEGCHAR; s++) ;
  2018.     if (!*s) {
  2019. #ifndef lint
  2020.         rcline[newng] = saferealloc(rcline[newng],(MEM_SIZE)length+2);
  2021. #endif lint
  2022.         s = rcline[newng] + length;
  2023.         *s = ':';
  2024.         *(s+1) = '\0';
  2025.     }
  2026.     rcchar[newng] = *s;        /* salt away the : or ! */
  2027.     rcnums[newng] = (char)(s - rcline[newng]); 
  2028.     rcnums[newng]++;        /* remember where it was */
  2029.     *s = '\0';            /* null terminate newsgroup name */
  2030. #ifdef HASHNG
  2031.     if (!checkflag)
  2032.         sethash(newng);
  2033. #endif
  2034.     if (rcchar[newng] == NEGCHAR) {
  2035.         toread[newng] = TR_UNSUB;
  2036.         continue;
  2037.     }
  2038.  
  2039.     /* now find out how much there is to read */
  2040.  
  2041.     if (!inlist(buf) || (suppress_cn && foundany && !paranoid))
  2042.         toread[newng] = TR_NONE;    /* no need to calculate now */
  2043.     else
  2044.         set_toread(newng);
  2045. #ifdef VERBOSE
  2046.     if (!checkflag && softmisses == 1) {
  2047.         softmisses++;        /* lie a little */
  2048.         fputs("(Revising soft pointers--be patient.)\n",stdout) FLUSH;
  2049.     }
  2050. #endif
  2051.     if (toread[newng] > TR_NONE) {    /* anything unread? */
  2052.         if (!foundany) {
  2053.         starthere = newng;
  2054.         foundany = TRUE;    /* remember that fact*/
  2055.         }
  2056.         if (suppress_cn) {        /* if no listing desired */
  2057.         if (checkflag) {    /* if that is all they wanted */
  2058.             finalize(1);    /* then bomb out */
  2059.         }
  2060.         }
  2061.         else {
  2062. #ifdef VERBOSE
  2063.         IF(verbose)
  2064.             printf("Unread news in %-20s %5ld article%s\n",
  2065.             rcline[newng],(long)toread[newng],
  2066.             toread[newng]==TR_ONE ? nullstr : "s") FLUSH;
  2067.         ELSE
  2068. #endif
  2069. #ifdef TERSE
  2070.             printf("%s: %ld article%s\n",
  2071.             rcline[newng],(long)toread[newng],
  2072.             toread[newng]==TR_ONE ? nullstr : "s") FLUSH;
  2073. #endif
  2074.         if (int_count) {
  2075.             countdown = 1;
  2076.             int_count = 0;
  2077.         }
  2078.         if (countdown) {
  2079.             if (! --countdown) {
  2080.             fputs("etc.\n",stdout) FLUSH;
  2081.             if (checkflag)
  2082.                 finalize(1);
  2083.             suppress_cn = TRUE;
  2084.             }
  2085.         }
  2086.         }
  2087.     }
  2088.     }
  2089.     fclose(rcfp);            /* close .newsrc */
  2090.     if (tmpfp != Nullfp)
  2091.     fclose(tmpfp);            /* close .rnsoft */
  2092.     if (checkflag) {            /* were we just checking? */
  2093.     finalize(foundany);        /* tell them what we found */
  2094.     }
  2095.     if (paranoid)
  2096.     cleanup_rc();
  2097.  
  2098. #ifdef DEBUGGING
  2099.     if (debug & DEB_HASH) {
  2100.     page_init();
  2101.     for (i=0; i<HASHSIZ; i++) {
  2102.         sprintf(buf,"%d    %d",i,hashtbl[i]);
  2103.         print_lines(buf,NOMARKING);
  2104.     }
  2105.     }
  2106. #endif
  2107.  
  2108.     return foundany;
  2109. }
  2110.  
  2111. /* try to find or add an explicitly specified newsgroup */
  2112. /* returns TRUE if found or added, FALSE if not. */
  2113. /* assumes that we are chdir'ed to SPOOL */
  2114.  
  2115. bool
  2116. get_ng(what,do_reloc)
  2117. char *what;
  2118. bool do_reloc;
  2119. {
  2120.     char *ntoforget;
  2121.     char promptbuf[128];
  2122.  
  2123. #ifdef VERBOSE
  2124.     IF(verbose)
  2125.     ntoforget = "Type n to forget about this newsgroup.\n";
  2126.     ELSE
  2127. #endif
  2128. #ifdef TERSE
  2129.     ntoforget = "n to forget it.\n";
  2130. #endif
  2131.     if (index(what,'/')) {
  2132.     dingaling();
  2133.     printf("\nBad newsgroup name.\n") FLUSH;
  2134.     return FALSE;
  2135.     }
  2136.     set_ngname(what);
  2137.     ng = find_ng(ngname);
  2138.     if (ng == nextrcline) {        /* not in .newsrc? */
  2139.     if (eaccess(ngdir,0) ||
  2140.         (softptr[ng] = findact(buf,ngname,strlen(ngname),0L)) < 0 ) {
  2141.         dingaling();
  2142. #ifdef VERBOSE
  2143.         IF(verbose)
  2144.         printf("\nNewsgroup %s does not exist!\n",ngname) FLUSH;
  2145.         ELSE
  2146. #endif
  2147. #ifdef TERSE
  2148.         printf("\nNo %s!\n",ngname) FLUSH;
  2149. #endif
  2150.         sleep(2);
  2151.         return FALSE;
  2152.     }
  2153. #ifdef VERBOSE
  2154.     IF(verbose)
  2155.         sprintf(promptbuf,"\nNewsgroup %s not in .newsrc--add? [yn] ",ngname);
  2156.     ELSE
  2157. #endif
  2158. #ifdef TERSE
  2159.         sprintf(promptbuf,"\nAdd %s? [yn] ",ngname);
  2160. #endif
  2161. reask_add:
  2162.     in_char(promptbuf);
  2163.     putchar('\n') FLUSH;
  2164.     setdef(buf,"y");
  2165. #ifdef VERIFY
  2166.     printcmd();
  2167. #endif
  2168.     if (*buf == 'h') {
  2169. #ifdef VERBOSE
  2170.         IF(verbose)
  2171.         printf("Type y or SP to add %s to your .newsrc.\n", ngname)
  2172.           FLUSH;
  2173.         ELSE
  2174. #endif
  2175. #ifdef TERSE
  2176.         fputs("y or SP to add\n",stdout) FLUSH;
  2177. #endif
  2178.         fputs(ntoforget,stdout) FLUSH;
  2179.         goto reask_add;
  2180.     }
  2181.     else if (*buf == 'n' || *buf == 'q') {
  2182.         return FALSE;
  2183.     }
  2184.     else if (*buf == 'y') {
  2185.         ng = add_newsgroup(ngname);
  2186.         do_reloc = FALSE;
  2187.     }
  2188.     else {
  2189.         fputs(hforhelp,stdout) FLUSH;
  2190.         settle_down();
  2191.         goto reask_add;
  2192.     }
  2193.     }
  2194.     else if (rcchar[ng] == NEGCHAR) {    /* unsubscribed? */
  2195. #ifdef VERBOSE
  2196.     IF(verbose)
  2197.         sprintf(promptbuf,
  2198. "\nNewsgroup %s is currently unsubscribed to--resubscribe? [yn] ",ngname)
  2199.   FLUSH;
  2200.     ELSE
  2201. #endif
  2202. #ifdef TERSE
  2203.         sprintf(promptbuf,"\n%s unsubscribed--resubscribe? [yn] ",ngname)
  2204.           FLUSH;
  2205. #endif
  2206. reask_unsub:
  2207.     in_char(promptbuf);
  2208.     putchar('\n') FLUSH;
  2209.     setdef(buf,"y");
  2210. #ifdef VERIFY
  2211.     printcmd();
  2212. #endif
  2213.     if (*buf == 'h') {
  2214. #ifdef VERBOSE
  2215.         IF(verbose)
  2216.         printf("Type y or SP to resubscribe to %s.\n", ngname) FLUSH;
  2217.         ELSE
  2218. #endif
  2219. #ifdef TERSE
  2220.         fputs("y or SP to resubscribe.\n",stdout) FLUSH;
  2221. #endif
  2222.         fputs(ntoforget,stdout) FLUSH;
  2223.         goto reask_unsub;
  2224.     }
  2225.     else if (*buf == 'n' || *buf == 'q') {
  2226.         return FALSE;
  2227.     }
  2228.     else if (*buf == 'y') {
  2229.         rcchar[ng] = ':';
  2230.     }
  2231.     else {
  2232.         fputs(hforhelp,stdout) FLUSH;
  2233.         settle_down();
  2234.         goto reask_unsub;
  2235.     }
  2236.     }
  2237.  
  2238.     /* now calculate how many unread articles in newsgroup */
  2239.  
  2240.     set_toread(ng);
  2241. #ifdef RELOCATE
  2242.     if (do_reloc)
  2243.     ng = relocate_newsgroup(ng,-1);
  2244. #endif
  2245.     return toread[ng] >= TR_NONE;
  2246. }
  2247.  
  2248. /* add a newsgroup to the .newsrc file (eventually) */
  2249.  
  2250. NG_NUM
  2251. add_newsgroup(ngn)
  2252. char *ngn;
  2253. {
  2254.     register NG_NUM newng = nextrcline++;
  2255.                     /* increment max rcline index */
  2256.     
  2257.     rcnums[newng] = strlen(ngn) + 1;
  2258.     rcline[newng] = safemalloc((MEM_SIZE)(rcnums[newng] + 1));
  2259.     strcpy(rcline[newng],ngn);        /* and copy over the name */
  2260.     *(rcline[newng] + rcnums[newng]) = '\0';
  2261.     rcchar[newng] = ':';        /* call it subscribed */
  2262.     toread[newng] = TR_NONE;    /* just for prettiness */
  2263. #ifdef HASHNG
  2264.     sethash(newng);            /* so we can find it again */
  2265. #endif
  2266. #ifdef RELOCATE
  2267.     return relocate_newsgroup(newng,-1);
  2268. #else
  2269.     return newng;
  2270. #endif
  2271. }
  2272.  
  2273. #ifdef RELOCATE
  2274. NG_NUM
  2275. relocate_newsgroup(ngx,newng)
  2276. NG_NUM ngx;
  2277. NG_NUM newng;
  2278. {
  2279.     char *dflt = (ngx!=current_ng ? "$^.L" : "$^L");
  2280.     char *tmprcline;
  2281.     ART_UNREAD tmptoread;
  2282.     char tmprcchar;
  2283.     char tmprcnums;
  2284.     ACT_POS tmpsoftptr;
  2285.     register NG_NUM i;
  2286. #ifdef DEBUGGING
  2287.     ART_NUM tmpngmax;
  2288. #endif
  2289. #ifdef CACHEFIRST
  2290.     ART_NUM tmpabs1st;
  2291. #endif
  2292.     
  2293.     starthere = 0;                      /* Disable this optimization */
  2294.     writesoft = TRUE;            /* Update soft pointer file */
  2295.     if (ngx < nextrcline-1) {
  2296. #ifdef HASHNG
  2297.     for (i=0; i<HASHSIZ; i++) {
  2298.         if (hashtbl[i] > ngx)
  2299.         --hashtbl[i];
  2300.         else if (hashtbl[i] == ngx)
  2301.         hashtbl[i] = nextrcline-1;
  2302.     }
  2303. #endif
  2304.     tmprcline = rcline[ngx];
  2305.     tmptoread = toread[ngx];
  2306.     tmprcchar = rcchar[ngx];
  2307.     tmprcnums = rcnums[ngx];
  2308.     tmpsoftptr = softptr[ngx];
  2309. #ifdef DEBUGGING
  2310.     tmpngmax = ngmax[ngx];
  2311. #endif
  2312. #ifdef CACHEFIRST
  2313.     tmpabs1st = abs1st[ngx];
  2314. #endif
  2315.     for (i=ngx+1; i<nextrcline; i++) {
  2316.         rcline[i-1] = rcline[i];
  2317.         toread[i-1] = toread[i];
  2318.         rcchar[i-1] = rcchar[i];
  2319.         rcnums[i-1] = rcnums[i];
  2320.         softptr[i-1] = softptr[i];
  2321. #ifdef DEBUGGING
  2322.         ngmax[i-1] = ngmax[i];
  2323. #endif
  2324. #ifdef CACHEFIRST
  2325.         abs1st[i-1] = abs1st[i];
  2326. #endif
  2327.     }
  2328.     rcline[nextrcline-1] = tmprcline;
  2329.     toread[nextrcline-1] = tmptoread;
  2330.     rcchar[nextrcline-1] = tmprcchar;
  2331.     rcnums[nextrcline-1] = tmprcnums;
  2332.     softptr[nextrcline-1] = tmpsoftptr;
  2333. #ifdef DEBUGGING
  2334.     ngmax[nextrcline-1] = tmpngmax;
  2335. #endif
  2336. #ifdef CACHEFIRST
  2337.     abs1st[nextrcline-1] = tmpabs1st;
  2338. #endif
  2339.     }
  2340.     if (current_ng > ngx)
  2341.     current_ng--;
  2342.     if (newng < 0) {
  2343.       reask_reloc:
  2344.     unflush_output();        /* disable any ^O in effect */
  2345. #ifdef VERBOSE
  2346.     IF(verbose)
  2347.         printf("\nPut newsgroup where? [%s] ", dflt);
  2348.     ELSE
  2349. #endif
  2350. #ifdef TERSE
  2351.         printf("\nPut where? [%s] ", dflt);
  2352. #endif
  2353.     fflush(stdout);
  2354.       reinp_reloc:
  2355.     eat_typeahead();
  2356.     getcmd(buf);
  2357.     if (errno || *buf == '\f') {
  2358.                 /* if return from stop signal */
  2359.         goto reask_reloc;    /* give them a prompt again */
  2360.     }
  2361.     setdef(buf,dflt);
  2362. #ifdef VERIFY
  2363.     printcmd();
  2364. #endif
  2365.     if (*buf == 'h') {
  2366. #ifdef VERBOSE
  2367.         IF(verbose) {
  2368.         printf("\n\n\
  2369. Type ^ to put the newsgroup first (position 0).\n\
  2370. Type $ to put the newsgroup last (position %d).\n", nextrcline-1);
  2371.         printf("\
  2372. Type . to put it before the current newsgroup (position %d).\n", current_ng);
  2373.         printf("\
  2374. Type -newsgroup name to put it before that newsgroup.\n\
  2375. Type +newsgroup name to put it after that newsgroup.\n\
  2376. Type a number between 0 and %d to put it at that position.\n", nextrcline-1);
  2377.         printf("\
  2378. Type L for a listing of newsgroups and their positions.\n") FLUSH;
  2379.         }
  2380.         ELSE
  2381. #endif
  2382. #ifdef TERSE
  2383.         {
  2384.         printf("\n\n\
  2385. ^ to put newsgroup first (pos 0).\n\
  2386. $ to put last (pos %d).\n", nextrcline-1);
  2387.         printf("\
  2388. . to put before current newsgroup (pos %d).\n", current_ng);
  2389.         printf("\
  2390. -newsgroup to put before newsgroup.\n\
  2391. +newsgroup to put after.\n\
  2392. number in 0-%d to put at that pos.\n", nextrcline-1);
  2393.         printf("\
  2394. L for list of .newsrc.\n") FLUSH;
  2395.         }
  2396. #endif
  2397.         goto reask_reloc;
  2398.     }
  2399.     else if (*buf == 'L') {
  2400.         putchar('\n') FLUSH;
  2401.         list_newsgroups();
  2402.         goto reask_reloc;
  2403.     }
  2404.     else if (isdigit(*buf)) {
  2405.         if (!finish_command(TRUE))    /* get rest of command */
  2406.         goto reinp_reloc;
  2407.         newng = atoi(buf);
  2408.         if (newng < 0)
  2409.         newng = 0;
  2410.         if (newng >= nextrcline)
  2411.         return nextrcline-1;
  2412.     }
  2413.     else if (*buf == '^') {
  2414.         putchar('\n') FLUSH;
  2415.         newng = 0;
  2416.     }
  2417.     else if (*buf == '$') {
  2418.         putchar('\n') FLUSH;
  2419.         return nextrcline-1;
  2420.     }
  2421.     else if (*buf == '.') {
  2422.         putchar('\n') FLUSH;
  2423.         newng = current_ng;
  2424.     }
  2425.     else if (*buf == '-' || *buf == '+') {
  2426.         if (!finish_command(TRUE))    /* get rest of command */
  2427.         goto reinp_reloc;
  2428.         newng = find_ng(buf+1);
  2429.         if (newng == nextrcline) {
  2430.         fputs("Not found.",stdout) FLUSH;
  2431.         goto reask_reloc;
  2432.         }
  2433.         if (*buf == '+')
  2434.         newng++;
  2435.     }
  2436.     else {
  2437.         printf("\n%s",hforhelp) FLUSH;
  2438.         settle_down();
  2439.         goto reask_reloc;
  2440.     }
  2441.     }
  2442.     if (newng < nextrcline-1) {
  2443. #ifdef HASHNG
  2444.     for (i=0; i<HASHSIZ; i++) {
  2445.         if (hashtbl[i] == nextrcline-1)
  2446.         hashtbl[i] = newng;
  2447.         else if (hashtbl[i] >= newng)
  2448.         ++hashtbl[i];
  2449.     }
  2450. #endif
  2451.     tmprcline = rcline[nextrcline-1];
  2452.     tmptoread = toread[nextrcline-1];
  2453.     tmprcchar = rcchar[nextrcline-1];
  2454.     tmprcnums = rcnums[nextrcline-1];
  2455.     tmpsoftptr = softptr[nextrcline-1];
  2456. #ifdef DEBUGGING
  2457.     tmpngmax = ngmax[nextrcline-1];
  2458. #endif
  2459. #ifdef CACHEFIRST
  2460.     tmpabs1st = abs1st[nextrcline-1];
  2461. #endif
  2462.     for (i=nextrcline-2; i>=newng; i--) {
  2463.         rcline[i+1] = rcline[i];
  2464.         toread[i+1] = toread[i];
  2465.         rcchar[i+1] = rcchar[i];
  2466.         rcnums[i+1] = rcnums[i];
  2467.         softptr[i+1] = softptr[i];
  2468. #ifdef DEBUGGING
  2469.         ngmax[i+1] = ngmax[i];
  2470. #endif
  2471. #ifdef CACHEFIRST
  2472.         abs1st[i+1] = abs1st[i];
  2473. #endif
  2474.     }
  2475.     rcline[newng] = tmprcline;
  2476.     toread[newng] = tmptoread;
  2477.     rcchar[newng] = tmprcchar;
  2478.     rcnums[newng] = tmprcnums;
  2479.     softptr[newng] = tmpsoftptr;
  2480. #ifdef DEBUGGING
  2481.     ngmax[newng] = tmpngmax;
  2482. #endif
  2483. #ifdef CACHEFIRST
  2484.     abs1st[newng] = tmpabs1st;
  2485. #endif
  2486.     }
  2487.     if (current_ng >= newng)
  2488.     current_ng++;
  2489.     return newng;
  2490. }
  2491. #endif
  2492.  
  2493. /* List out the newsrc with annotations */
  2494.  
  2495. void
  2496. list_newsgroups()
  2497. {
  2498.     register NG_NUM i;
  2499.     char tmpbuf[2048];
  2500.     static char *status[] = {"(READ)","(UNSUB)","(BOGUS)","(JUNK)"};
  2501.     int cmd;
  2502.  
  2503.     page_init();
  2504.     print_lines("\
  2505.   #  Status  Newsgroup\n\
  2506. ",STANDOUT);
  2507.     for (i=0; i<nextrcline && !int_count; i++) {
  2508.     if (toread[i] >= 0)
  2509.         set_toread(i);
  2510.     *(rcline[i] + rcnums[i] - 1) = rcchar[i];
  2511.     if (toread[i] > 0)
  2512.         sprintf(tmpbuf,"%3d %6d   ",i,toread[i]);
  2513.     else
  2514.         sprintf(tmpbuf,"%3d %7s  ",i,status[-toread[i]]);
  2515.     safecpy(tmpbuf+13,rcline[i],2034);
  2516.     *(rcline[i] + rcnums[i] - 1) = '\0';
  2517.     if (cmd = print_lines(tmpbuf,NOMARKING)) {
  2518.         if (cmd > 0)
  2519.         pushchar(cmd);
  2520.         break;
  2521.     }
  2522.     }
  2523.     int_count = 0;
  2524. }
  2525.  
  2526. /* find a newsgroup in .newsrc */
  2527.  
  2528. NG_NUM
  2529. find_ng(ngnam)
  2530. char *ngnam;
  2531. {
  2532.     register NG_NUM ngnum;
  2533. #ifdef HASHNG
  2534.     register int hashix = hash(ngnam);
  2535.     register int incr = 1;
  2536.  
  2537.     while ((ngnum = hashtbl[hashix]) >= 0) {
  2538.     if (strEQ(rcline[ngnum], ngnam) && toread[ngnum] >= TR_UNSUB)
  2539.         return ngnum;
  2540.     hashix = (hashix + incr) % HASHSIZ;
  2541.     incr += 2;            /* offsets from original are in n*2 */
  2542.     }
  2543.     return nextrcline;            /* = notfound */
  2544.  
  2545. #else /* just do linear search */
  2546.  
  2547.     for (ngnum = 0; ngnum < nextrcline; ngnum++) {
  2548.     if (strEQ(rcline[ngnum],ngnam))
  2549.         break;
  2550.     }
  2551.     return ngnum;
  2552. #endif
  2553. }
  2554.  
  2555. void
  2556. cleanup_rc()
  2557. {
  2558.     register NG_NUM ngx;
  2559.     register NG_NUM bogosity = 0;
  2560.  
  2561. #ifdef VERBOSE
  2562.     IF(verbose)
  2563.     fputs("Checking out your .newsrc--hang on a second...\n",stdout)
  2564.       FLUSH;
  2565.     ELSE
  2566. #endif
  2567. #ifdef TERSE
  2568.     fputs("Checking .newsrc--hang on...\n",stdout) FLUSH;
  2569. #endif
  2570.     for (ngx = 0; ngx < nextrcline; ngx++) {
  2571.     if (toread[ngx] >= TR_UNSUB) {
  2572.         set_toread(ngx);        /* this may reset newsgroup */
  2573.                     /* or declare it bogus */
  2574.     }
  2575.     if (toread[ngx] == TR_BOGUS)
  2576.         bogosity++;
  2577.     }
  2578.     for (ngx = nextrcline-1; ngx >= 0 && toread[ngx] == TR_BOGUS; ngx--)
  2579.     bogosity--;            /* discount already moved ones */
  2580.     if (nextrcline > 5 && bogosity > nextrcline / 2) {
  2581.     fputs(
  2582. "It looks like the active file is messed up.  Contact your news administrator,\n\
  2583. ",stdout);
  2584.     fputs(
  2585. "leave the \"bogus\" groups alone, and they may come back to normal.  Maybe.\n\
  2586. ",stdout) FLUSH;
  2587.     }
  2588. #ifdef RELOCATE
  2589.     else if (bogosity) {
  2590. #ifdef VERBOSE
  2591.     IF(verbose)
  2592.         fputs("Moving bogus newsgroups to the end of your .newsrc.\n",
  2593.         stdout) FLUSH;
  2594.     ELSE
  2595. #endif
  2596. #ifdef TERSE
  2597.         fputs("Moving boguses to the end.\n",stdout) FLUSH;
  2598. #endif
  2599.     for (; ngx >= 0; ngx--) {
  2600.         if (toread[ngx] == TR_BOGUS)
  2601.         relocate_newsgroup(ngx,nextrcline-1);
  2602.     }
  2603. #ifdef DELBOGUS
  2604. reask_bogus:
  2605.     in_char("Delete bogus newsgroups? [ny] ");
  2606.     putchar('\n') FLUSH;
  2607.     setdef(buf,"n");
  2608. #ifdef VERIFY
  2609.     printcmd();
  2610. #endif
  2611.     if (*buf == 'h') {
  2612. #ifdef VERBOSE
  2613.         IF(verbose)
  2614.         fputs("\
  2615. Type y to delete bogus newsgroups.\n\
  2616. Type n or SP to leave them at the end in case they return.\n\
  2617. ",stdout) FLUSH;
  2618.         ELSE
  2619. #endif
  2620. #ifdef TERSE
  2621.         fputs("y to delete, n to keep\n",stdout) FLUSH;
  2622. #endif
  2623.         goto reask_bogus;
  2624.     }
  2625.     else if (*buf == 'n' || *buf == 'q')
  2626.         ;
  2627.     else if (*buf == 'y') {
  2628.         while (toread[nextrcline-1] == TR_BOGUS && nextrcline > 0)
  2629.         --nextrcline;        /* real tough, huh? */
  2630.     }
  2631.     else {
  2632.         fputs(hforhelp,stdout) FLUSH;
  2633.         settle_down();
  2634.         goto reask_bogus;
  2635.     }
  2636. #endif
  2637.     }
  2638. #else
  2639. #ifdef VERBOSE
  2640.     IF(verbose)
  2641.     fputs("You should edit bogus newsgroups out of your .newsrc.\n",
  2642.         stdout) FLUSH;
  2643.     ELSE
  2644. #endif
  2645. #ifdef TERSE
  2646.     fputs("Edit boguses from .newsrc.\n",stdout) FLUSH;
  2647. #endif
  2648. #endif
  2649.     paranoid = FALSE;
  2650. }
  2651.  
  2652. #ifdef HASHNG
  2653. /* make an entry in the hash table for the current newsgroup */
  2654.  
  2655. void
  2656. sethash(thisng)
  2657. NG_NUM thisng;
  2658. {
  2659.     register int hashix = hash(rcline[thisng]);
  2660.     register int incr = 1;
  2661. #ifdef DEBUGGING
  2662.     static int hashhits = 0, hashtries = 0;
  2663. #endif
  2664.  
  2665. #ifdef DEBUGGING
  2666.     hashtries++;
  2667. #endif
  2668.     while (hashtbl[hashix] >= 0) {
  2669. #ifdef DEBUGGING
  2670.     hashhits++;
  2671.     if (debug & DEB_HASH) {
  2672.         printf("  Hash hits: %d / %d\n",hashhits, hashtries) FLUSH;
  2673.     }
  2674.     hashtries++;
  2675. #endif
  2676.     hashix = (hashix + incr) % HASHSIZ;
  2677.     incr += 2;            /* offsets from original are in n*2 */
  2678.     }
  2679.     hashtbl[hashix] = thisng;
  2680. }
  2681.  
  2682. short prime[] = {1,2,-3,-5,7,11,-13,-17,19,23,-29,-31,37,41,-43,-47,53,57,-59,
  2683.     -61,67,71,-73,-79,83,89,-97,-101,1,1,1,1,1,1,1,1,1,1,1,1};
  2684.  
  2685. int
  2686. hash(ngnam)
  2687. register char *ngnam;
  2688. {
  2689.     register int i = 0;
  2690.     register int ch;
  2691.     register int sum = 0;
  2692. #ifdef DEBUGGING
  2693.     char *ngn = ngnam;
  2694. #endif
  2695.  
  2696.     while (ch = *ngnam++) {
  2697.     sum += (ch + i) * prime[i];   /* gives ~ 10% hits at 25% full */
  2698.     i++;
  2699.     }
  2700. #ifdef DEBUGGING
  2701.     if (debug & DEB_HASH)
  2702.     printf("hash(%s) => %d => %d\n",ngn, sum, (sum<0?-sum:sum)%HASHSIZ)
  2703.       FLUSH;
  2704. #endif
  2705.     if (sum < 0)
  2706.     sum = -sum;
  2707.     return sum % HASHSIZ;
  2708. }
  2709.  
  2710. #endif
  2711.  
  2712. void
  2713. newsrc_check()
  2714. {
  2715.     rcfp = fopen(rcname,"r");        /* open it */
  2716.     if (rcfp == Nullfp) {            /* not there? */
  2717. #ifdef VERBOSE
  2718.     IF(verbose)
  2719.         fputs("\
  2720. Trying to set up a .newsrc file--running newsetup...\n\n\
  2721. ",stdout) FLUSH;
  2722.     ELSE
  2723. #endif
  2724. #ifdef TERSE
  2725.         fputs("Setting up .newsrc...\n",stdout) FLUSH;
  2726. #endif
  2727.     if (doshell(sh,filexp(NEWSETUP)) ||
  2728.         (rcfp = fopen(rcname,"r")) == Nullfp) {
  2729. #ifdef VERBOSE
  2730.         IF(verbose)
  2731.         fputs("\
  2732. Can't create a .newsrc--you must do it yourself.\n\
  2733. ",stdout) FLUSH;
  2734.         ELSE
  2735. #endif
  2736. #ifdef TERSE
  2737.         fputs("(Fatal)\n",stdout) FLUSH;
  2738. #endif
  2739.         finalize(1);
  2740.     }
  2741.     }
  2742.     else {
  2743.     UNLINK(rcbname);        /* unlink backup file name */
  2744.     link(rcname,rcbname);        /* and backup current name */
  2745.     }
  2746. }
  2747.  
  2748. /* write out the (presumably) revised .newsrc */
  2749.  
  2750. void
  2751. write_rc()
  2752. {
  2753.     register NG_NUM tmpng;
  2754.     register char *delim;
  2755.  
  2756.     rcfp = fopen(rctname, "w");        /* open .newsrc */
  2757.     if (rcfp == Nullfp) {
  2758.     printf("Can't recreate .newsrc\n") FLUSH;
  2759.     finalize(1);
  2760.     }
  2761.  
  2762.     /* write out each line*/
  2763.  
  2764.     for (tmpng = 0; tmpng < nextrcline; tmpng++) {
  2765.     if (rcnums[tmpng]) {
  2766.         delim = rcline[tmpng] + rcnums[tmpng] - 1;
  2767.         *delim = rcchar[tmpng];
  2768.     }
  2769.     else
  2770.         delim = Nullch;
  2771. #ifdef DEBUGGING
  2772.     if (debug & DEB_NEWSRC_LINE)
  2773.         printf("%s\n",rcline[tmpng]) FLUSH;
  2774. #endif
  2775.     fprintf(rcfp,"%s\n",rcline[tmpng]);
  2776.     if (delim)
  2777.         *delim = '\0';        /* might still need this line */
  2778.     }
  2779.  
  2780.     fclose(rcfp);            /* close .newsrc */
  2781.     UNLINK(rcname);
  2782.     link(rctname,rcname);
  2783.     UNLINK(rctname);
  2784.  
  2785.     if (writesoft) {
  2786.     tmpfp = fopen(filexp(softname), "w");    /* open .rnsoft */
  2787.     if (tmpfp == Nullfp) {
  2788.         printf(cantcreate,filexp(softname)) FLUSH;
  2789.         return;
  2790.     }
  2791.     for (tmpng = 0; tmpng < nextrcline; tmpng++) {
  2792.         fprintf(tmpfp,"%ld\n",(long)softptr[tmpng]);
  2793.     }
  2794.     fclose(tmpfp);
  2795.     }
  2796. }
  2797.  
  2798. void
  2799. get_old_rc()
  2800. {
  2801.     UNLINK(rctname);
  2802.     link(rcname,rctname);
  2803.     UNLINK(rcname);
  2804.     link(rcbname,rcname);
  2805.     UNLINK(rcbname);
  2806. }
  2807. !STUFFY!FUNK!
  2808. echo ""
  2809. echo "End of kit 2 (of 9)"
  2810. cat /dev/null >kit2isdone
  2811. config=true
  2812. for iskit in 1 2 3 4 5 6 7 8 9; do
  2813.     if test -f kit${iskit}isdone; then
  2814.     echo "You have run kit ${iskit}."
  2815.     else
  2816.     echo "You still need to run kit ${iskit}."
  2817.     config=false
  2818.     fi
  2819. done
  2820. case $config in
  2821.     true)
  2822.     echo "You have run all your kits.  Please read README and then type Configure."
  2823.     chmod 755 Configure
  2824.     ;;
  2825. esac
  2826. : I do not append .signature, but someone might mail this.
  2827. exit
  2828.  
  2829.