home *** CD-ROM | disk | FTP | other *** search
- From: sob@lib.tmc.edu (Stan Barber)
- Newsgroups: alt.sources
- Subject: rrn/rn combo kit part 6 of 9
- Message-ID: <432@lib.tmc.edu>
- Date: 14 Jun 90 03:28:30 GMT
-
- #! /bin/sh
-
- # Make a new directory for the rn sources, cd to it, and run kits 1 thru 9
- # through sh. When all 9 kits have been run, read README.
-
- echo "This is rn kit 6 (of 9). If kit 6 is complete, the line"
- echo '"'"End of kit 6 (of 9)"'" will echo at the end.'
- echo ""
- export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
- echo Extracting Pnews.SH
- cat >Pnews.SH <<'!STUFFY!FUNK!'
- case $CONFIG in
- '') . config.sh ;;
- esac
- echo "Extracting Pnews (with variable substitutions)"
- $spitshell >Pnews <<!GROK!THIS!
- $startsh
- # $Header: Pnews.SH,v 4.3.2.7 90/05/04 23:14:45 sob Exp $
- #
- # $Log: Pnews.SH,v $
- # Revision 4.3.2.7 90/05/04 23:14:45 sob
- # Expires: line removed from Pnews.header.
- #
- # Revision 4.3.2.6 90/04/21 16:53:43 sob
- # Corrected a typo pointed out by Bill Aten.
- #
- # Revision 4.3.2.5 89/12/17 01:53:48 sob
- # Changed from using ypcat to using ypmatch
- #
- # Revision 4.3.2.4 89/12/09 01:48:30 sob
- # Reply-To: field removed. This makes all the headers created by rn
- # look roughly the same.
- #
- # Revision 4.3.2.3 89/11/26 22:20:04 sob
- # Added support for some of the top level names that are not part of
- # the mainstream.
- #
- # Revision 4.3.2.2 89/11/06 00:25:39 sob
- # Some minor changes to make the help messages more accurate
- #
- # Revision 4.3.2.1 89/11/06 00:21:30 sob
- # Added RRN support from NNTP 1.5
- #
- # Revision 4.3.1.4 86/09/05 15:21:10 lwall
- # Changes for new top-level newsgroup names.
- #
- # Revision 4.3.1.3 85/08/01 14:24:06 lwall
- # Added AUTHORCOPY. Temp file is no longer in /tmp. 'e editor' added.
- #
- # Revision 4.3.1.2 85/05/17 10:36:46 lwall
- # Removed some extra backslashes.
- #
- # Revision 4.3.1.1 85/05/10 11:30:21 lwall
- # Branch for patches.
- #
- # Revision 4.3 85/05/01 12:20:33 lwall
- # Baseline for release with 4.3bsd.
- #
- #
- # syntax: Pnews -h headerfile or
- # Pnews -h headerfile oldarticle or
- # Pnews newsgroup title or just
- # Pnews
-
- export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
-
- # System dependencies
-
- mailer="${mailer-/bin/mail}"
- # if you change this to something that does signatures, take out signature code
-
- case $portable in
- define)
- # your site name
- sitename=\`$hostcmd\`
- case \$sitename in
- *.*)
- ;;
- *)
- sitename=\${sitename}.$domain
- ;;
- esac
- # where recordings, distributions and moderators are kept
- lib=\`$filexp $lib\`
- # where important rn things are kept
- rnlib=\`$filexp $rnlib\`
- ;;
- undef)
- # your site name
- sitename="$sitename"
- # where recordings, distributions and moderators are kept
- lib="$lib"
- # where important rn things are kept
- rnlib="$rnlib"
- ;;
- esac
-
- # your organization name
- orgname="$orgname"
- # what pager you use--if you have kernal paging use cat
- pager="\${PAGER-$pager}"
- # how you derive full names, bsd, usg, or other
- nametype="$nametype"
- # default editor
- defeditor="$defeditor"
- # how not to echo with newline
- n="$n"
- c="$c"
-
- # You should also look at the distribution warnings below marked !DIST!
- # to make sure any distribution regions you are a member of are included.
- # The following are some prototypical distribution groups. If you do not
- # use them all set the unused ones to a non-null string such as 'none'.
- loc="$locpref"
- org="$orgpref"
- city="$citypref"
- state="$statepref"
- cntry="$cntrypref"
- cont="$contpref"
-
- test=${test-test}
- sed=${sed-sed}
- echo=${echo-echo}
- cat=${cat-cat}
- egrep=${egrep-egrep}
- grep=${grep-grep}
- rm=${rm-rm}
- tr=${tr-tr}
- inews=${inews-inews}
- ypmatch=${ypmatch}
-
- !GROK!THIS!
- $spitshell >>Pnews <<'!NO!SUBS!'
- dotdir=${DOTDIR-${HOME-$LOGDIR}}
- tmpart=$dotdir/.article
-
- if $test -f $dotdir/.pnewsexpert; then
- expertise=expert
- else
- $cat <<'EOM'
- I see you've never used this version of Pnews before. I will give you extra
- help this first time through, but then you must remember what you learned.
- If you don't understand any question, type h and a CR (carriage return) for
- help.
-
- If you've never posted an article to the net before, it is HIGHLY recommended
- that you read the netiquette document found in news.announce.newusers so
- that you'll know to avoid the commonest blunders. To do that, interrupt
- Pnews, and get to the top-level prompt of rn. Type "g news.announce.newusers"
- and you are on your way.
-
- EOM
- expertise=beginner
- fi
-
- case $cntry in
- can) stpr=Province ;;
- *) stpr=State ;;
- esac
-
- headerfile=""
- case $# in
- 0) ;;
- *) case $1 in
- -h)
- headerfile="$2"
- shift
- shift
- case $# in
- 0)
- oldart=""
- ;;
- *)
- oldart="$1"
- shift
- ;;
- esac
- ;;
- esac
- ;;
- esac
-
- case $headerfile in
- '')
- . $rnlib/Pnews.header
- ;;
- *)
- $cat < $headerfile > $tmpart
- ;;
- esac
- rescue="sleep 1; $cat $tmpart >>${HOME-$LOGDIR}/dead.article ; $echo Article appended to ${HOME-$LOGDIR}/dead.article ; exit"
- trap "$rescue" 1
- trap "$rescue" 2
-
- $echo ""
- #: play recorded message
- set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
- shift
- case $# in
- 0|1)
- ;;
- *)
- shift
- if $test -s ${lib}/recording ; then
- ng=`$echo $1 | $sed "s/,.*//"`
- _rec1=${lib}/`$sed -n "/^$ng/s/^.* //p" ${lib}/recording`
- _tmp=`$echo $ng |$sed "s/\..*//"`
- _rec2=${lib}/`$cat -s ${lib}/recording|$grep ${_tmp}.all|$sed "s/^.* //"`
- if $test -f ${_rec1} ; then
- $cat -s ${_rec1}
- fi
- if $test -f ${_rec2} ; then
- $cat -s ${_rec2}
- fi
- fi
- ;;
- esac
-
- set X `$sed < $tmpart -n -e '/^Distribution: /{' -e p -e q -e '}' -e '/^$/q'`
- shift
- case $# in
- 0|1)
- set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
- shift
- case $# in
- 0|1)
- set "x misc.whatever"
- ;;
- esac
- ;;
- *)
- set $1 $2.whatever
- ;;
- esac
- shift
-
- #: play recorded message
- #if $test -s ${lib}/recording ; then
- # ng=`$echo $1 | $sed "s/,.*//"`
- # _rec1=${lib}/`$sed -n "/^$ng/s/^.* //p" ${lib}/recording`
- # _tmp=`$echo $ng |$sed "s/\..*//"`
- # _rec2=${lib}/`$cat -s ${lib}/recording|$grep ${_tmp}.all|$sed "s/^.* //"`
- # if $test -f ${_rec1} ; then
- # $cat -s ${_rec1}
- # fi
- # if $test -f ${_rec2} ; then
- # $cat -s ${_rec2}
- # fi
- #fi
-
- # tell them what we think they are doing... !DIST!
- case $1 in
- world.*|comp.*|news.*|sci.*|rec.*|misc.*|soc.*|talk.*|alt.*)
- $cat <<'EOM'
- This program posts news to thousands of machines throughout the entire
- civilized world. Your message will cost the net hundreds if not thousands of
- dollars to send everywhere. Please be sure you know what you are doing.
-
- EOM
- ;;
- vmsnet.*)
- $echo 'This program posts news to many machines.'
- ;;
- bit.*)
- $echo 'This program posts news to many machines on BITNET.'
- ;;
- ddn.*)
- $echo 'This program posts news to many machines throughout the internet.'
- ;;
- $cont.*)
- $echo 'This program posts news to many machines throughout the continent.'
- ;;
- $cntry.*)
- $echo 'This program posts news to many machines throughout the country.'
- ;;
- $state.*)
- $echo 'This program posts news to many machines throughout the state.'
- ;;
- $city.*)
- $echo 'This program posts news to many machines throughout the city.'
- ;;
- $org.*)
- $echo 'This program posts news to machines throughout the organization.'
- ;;
- $loc.*)
- $echo 'This program posts news to machines throughout the local organization.'
- ;;
- *.*)
- $echo 'This program may post news to many machines.'
- ;;
- to.*)
- $echo 'This program may post news to a partcular machine.'
- ;;
- *)
- $echo 'This program posts news to everyone on the machine.'
- ;;
- esac
- ans=""
- while $test "$ans" = "" ; do
- $echo $n "Are you absolutely sure that you want to do this? [ny] $c"
- read ans
- case $ans in
- y*) ;;
- f*) suppressmess=y ;;
- h*) $cat <<'EOH'
-
- Type n or CR to exit, y to post.
-
- EOH
- ans="" ;;
- *) exit ;;
- esac
- done
-
- file=h
- while $test "$file" = h ; do
- $echo ""
- $echo $n "Prepared file to include [none]: $c"
- read file
- case $file in
- h)
- $cat <<'EOH'
-
- If you have already produced the body of your article, type the filename
- for it here. If you just want to proceed directly to the editor, type a
- RETURN. In any event, you will be allowed to edit as many times as you
- want before you send off the article.
- EOH
- ;;
- '')
- $echo "" >> $tmpart
- state=edit
- ;;
- *)
- $cat $file >>$tmpart
- state=ask
- ;;
- esac
- done
-
- $echo ""
-
- while true ; do
- case $state in
- edit)
- case $expertise in
- beginner)
- $cat </dev/null >$dotdir/.pnewsexpert
- $cat <<'EOMessage'
- A temporary file has been created for you to edit. Be sure to leave at
- least one blank line between the header and the body of your message.
- (And until a certain bug is fixed all over the net, don't start the body of
- your message with any indentation, or it may get eaten.)
-
- Within the header may be fields that you don't understand. If you don't
- understand a field (or even if you do), you can simply leave it blank, and
- it will go away when the article is posted.
-
- Type return to get the default editor, or type the name of your favorite
- editor.
-
- EOMessage
- ;;
- esac
- case "${VISUAL-${EDITOR-}}" in
- '')
- tmp=h
- ;;
- *)
- tmp=''
- ;;
- esac
- while $test "$tmp" = h ; do
- $echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c"
- read tmp
- case $tmp in
- h)
- $cat <<'EOH'
-
- Type a return to get the default editor, or type the name of the editor you
- prefer. The default editor depends on the VISUAL and EDITOR environment
- variables.
-
- EOH
- ;;
- '')
- ;;
- *)
- VISUAL=$tmp
- export VISUAL
- ;;
- esac
- done
- trap : 2
- ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart
- trap "$rescue" 2
- state=ask
- ;;
-
- ask)
- $echo ""
- $echo $n "Send, abort, edit, or list? $c"
- read ans
-
- case "$ans" in
- a*)
- state=rescue
- ;;
- e*)
- set $ans
- case $# in
- 2) VISUAL="$2" ;;
- esac
- state=edit
- ;;
- l*)
- $pager $tmpart
- state=ask
- ;;
- s*)
- state=send
- ;;
- h*)
- $cat <<'EOH'
-
- Type s to send the article, a to abort and append the article to dead.article,
- e to edit the article again, or l to list the article.
-
- To invoke an alternate editor, type 'e editor'.
- EOH
- esac
- ;;
-
- send)
- set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
- shift
- case $# in
- 2)
- state=cleanup
- if $test -f $lib/moderators; then
- tryinews=no
- shift
- case "$1" in
- *,*) set `$echo $1 | tr ',' ' '`;;
- esac
- for newsgroup in $*; do
- # the following screwy sed should prevent Eunice from hanging on no match
- moderator=`$sed <$lib/moderators \
- -e "/^$newsgroup[ ]/!s/.*//" \
- -e "s/^$newsgroup[ ]//"`
- case ${moderator}X in
- X) tryinews=yes
- ;;
- *)
- $echo Mailing to moderator $moderator
- case "$sign" in
- n*) ;;
- *)
- if $test -f $dotdir/.signature; then
- echo $n "Append .signature file? [y] $c"
- read ans
- case $ans in
- ''|y*)
- echo "-- " >> $tmpart
- cat $dotdir/.signature >> $tmpart
- ;;
- esac
- fi
- sign=no
- ;;
- esac
- case "$mailer" in
- *recmail)
- $echo To: $moderator | $cat - $tmpart | $mailer
- ;;
- *)
- $mailer $moderator < $tmpart
- ;;
- esac
- case $? in
- 0) ;;
- *)
- $echo Unable to mail to moderator $moderator
- state=rescue
- ;;
- esac
- ;;
- esac
- done
- else
- tryinews=yes
- fi
- case "$tryinews" in
- yes)
- if $inews -h < $tmpart ; then
- : null
- else
- state=rescue
- fi
- ;;
- esac
- ;;
- *)
- $echo ""
- $echo "Malformed Newsgroups line."
- $echo ""
- sleep 1
- state=edit
- ;;
- esac
- ;;
- rescue)
- $cat $tmpart >> ${HOME-$LOGDIR}/dead.article
- $echo "Article appended to ${HOME-$LOGDIR}/dead.article"
- $echo "A copy may be temporarily found in $tmpart"
- exit
- ;;
- cleanup)
- case "${AUTHORCOPY-none}" in
- none)
- ;;
- *) if $echo From $USER `date` >> $AUTHORCOPY; then
- $cat $tmpart >> $AUTHORCOPY
- $echo "Article appended to $AUTHORCOPY"
- $echo "" >> $AUTHORCOPY
- $echo "" >> $AUTHORCOPY
- else
- $echo "Cannot append to $AUTHORCOPY"
- fi
- ;;
- esac
- exit
- ;;
- esac
- done
- !NO!SUBS!
- $eunicefix Pnews
- chmod 755 Pnews
- $spitshell >Pnews.header <<'!NO!SUBS!'
- case $# in
- 0)
- ng=h
- while $test "$ng" = h ; do
- $echo ""
- $echo $n "Newsgroup(s): $c"
- read ng
- case $ng in
- h)
- $cat <<'EOH'
-
- Type the name of one or more newsgroups to which you wish to post an article.
- If you want to post to multiple newsgroups, it is better to do them all at
- once than to post to each newsgroup individually, which defeats the news
- reading programs' strategies of eliminating duplicates.
-
- Separate multiple newsgroup names with commas.
- EOH
- ;;
- esac
- done
- ;;
- *)
- ng=$1
- shift
- ;;
- esac
- case $ng in
- *\ *)
- ng=`$echo "$ng" | $sed 's/[, ] */,/g'`
- ;;
- esac
- case $ng in
- bit.*|pubnet.*|bionet.*|vmsnet.*|comp.*|news.*|sci.*|rec.*|misc.*|soc.*|talk.*|alt.*)
- defdist=world
- dist=h
- ;;
- ddn.*)
- defdist=inet
- dist=h
- ;;
- to.*)
- defdist=''
- dist=''
- ;;
- *.*)
- defdist=`expr "X$ng" : 'X\([a-z0-9]*\)'`
- dist=h
- ;;
- *)
- defdist=''
- dist=''
- ;;
- esac
-
- while $test "$dist" = h ; do
- if $test -f $lib/distributions; then
- $echo " "
- $echo "Your local distribution prefixes are:"
- $cat $lib/distributions
- $echo " "
- else
- $egrep -v '[ ]none$' <<EOM
-
- Your local distribution prefixes are:
- Local organization: $loc
- Organization: $org
- City: $city
- $stpr: $state
- Country: $cntry
- Continent: $cont
- Everywhere: world
-
- EOM
- fi
- $echo $n "Distribution ($defdist): $c"
- read dist
- case $dist in
- '') dist=$defdist ;;
- esac
- case $dist in
- h)
- $cat <<'EOH'
-
- The Distribution line may be used to limit the distribution of an article
- to some subset of the systems that would receive the article based only on
- the Newsgroups line. For example, if you want to sell your car in talk.auto,
- and you live in New Jersey, you might want to put "nj" on the Distribution
- line to avoid advertising in California, which has enough problems of its own.
- The actual area designators to use depend on where you are, of course.
- EOH
- ;;
- ''|$loc*|$org*|$city*|$state*|$cntry*|$cont*|$defdist)
- ;;
- world*|comp*|news*|sci*|rec*|misc*|soc*|talk*|alt*)
- dist=''
- ;;
- *)
- if $test -f $lib/distributions && \
- $egrep "^$dist[ ]" $lib/distributions >$tmpart && \
- $test -s $tmpart; then
- : null
- else
- $echo "Unrecognized distribution prefix--type h for help, CR to use anyway."
- defdist=$dist
- dist=h
- fi
- ;;
- esac
- done
-
- follow=""
-
- case $# in
- 0)
- title=h
- while $test "$title" = h ; do
- $echo ""
- $echo $n "Title/Subject: $c"
- read title
- case $title in
- h)
- $cat <<'EOH'
-
- Type the title for your article. Please make it as informative as possible
- (within reason) so that people who aren't interested won't have to read the
- article to find out they aren't interested. This includes marking movie
- spoilers as (spoiler), and rotated jokes as (rot 13).
- EOH
- ;;
- esac
- done
- ;;
- *)
- title="$*"
- ;;
- esac
-
- # now build a file with a header for them to edit
-
- set X ${USER-${LOGNAME-`who am i`}}
- shift
- logname=$1
- case $logname in
- *!*) logname=`expr "$logname" : '!\(.*\)$'` ;;
- esac
- case ${NAME-$nametype} in
- bsd)
- if $test "$ypmatch" != ""; then
- fullname=`$ypmatch $logname passwd 2>/dev/null | $sed "s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^,:;]*\).*"'$'"/\1/"`
- fi
- if $test "$fullname" = ""; then
- fullname=`$sed </etc/passwd -e "/^$logname:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^,:;]*\).*"'$'"/\1/" -e "q" -e "}" -e "d"`
- fi
- case $fullname in
- *'&'*) : GACK
- lname=`$echo $logname | $tr 'a-z' 'A-Z'`
- lname=`$echo $lname $logname | $sed 's/^\(.\)[^ ]* ./\1/'`
- fullname=`$echo "$fullname" | $sed "s/&/${lname}/"`
- ;;
- esac
- ;;
- usg)
- if $test "$ypmatch" != ""; then
- fullname=`$ypmatch $logname passwd 2>/dev/null | $sed "s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^(:]*\).*"'$'"/\1/" -e "s/^.*-//" -e "q"`
- fi
- if $test "$fullname" = ""; then
- fullname=`$sed </etc/passwd -e "/^$logname:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^(:]*\).*"'$'"/\1/" -e "s/^.*-//" -e "q" -e "}" -e "d"`
- fi
- ;;
- *)
- fullname=${NAME-`$cat $dotdir/.fullname`}
- ;;
- esac
-
- orgname=${ORGANIZATION-$orgname}
- case $orgname in
- /*) orgname=`$cat $orgname` ;;
- esac
-
- $cat > $tmpart <<EOHeader
- From: $logname@$sitename ($fullname)
- Newsgroups: $ng
- Subject: $title
- References:
- Sender:
- Followup-To: $follow
- Distribution: $dist
- Organization: $orgname
- Keywords:
-
- EOHeader
-
- !NO!SUBS!
- case "$isrrn" in
- define) sed < Pnews.header -e '/^#NORMAL/d' > Pnews.h.new ;;
- *) sed < Pnews.header -e '/^#NORMAL/s/^#NORMAL//' > Pnews.h.new ;;
- esac
- mv Pnews.h.new Pnews.header
- $eunicefix Pnews.header
- !STUFFY!FUNK!
- echo Extracting rn.c
- cat >rn.c <<'!STUFFY!FUNK!'
- /* rn -- new readnews program
- *
- * Original Author: lwall@sdcrdcf.UUCP (Larry Wall)
- * Organization: System Development Corporation, Santa Monica
- *
- * begun: 01/14/83
- * 1.0: 04/08/83
- * 2.0: 09/01/83
- * RRN/RN: 11/01/89
- */
-
- static char rnid[] = "@(#)$Header: rn.c,v 4.3.2.4 90/04/03 23:11:33 sob Exp $";
- static char patchlevel[] = "Patch #: 47";
-
- /* $Log: rn.c,v $
- * Revision 4.3.2.4 90/04/03 23:11:33 sob
- * Added more information to the version command.
- *
- * Revision 4.3.2.3 90/03/22 23:05:23 sob
- * Fixes provided by Wayne Davison <drivax!davison>
- *
- * Revision 4.3.2.2 89/11/28 01:51:25 sob
- * Removed redundant #include directive.
- *
- * Revision 4.3.2.1 89/11/08 02:27:38 sob
- * Release of RN 4.3 with RRN that can be compiled from the same
- * sources as either version of the program.
- *
- * Revision 4.3.1.4 85/09/10 11:05:13 lwall
- * Improved %m in in_char().
- *
- * Revision 4.3.1.3 85/05/16 16:47:10 lwall
- * Catchup confirmation didn't grok -t.
- *
- * Revision 4.3.1.2 85/05/13 09:34:53 lwall
- * Fixed default after do_newsgroup() returns from Q command.
- *
- * Revision 4.3.1.1 85/05/10 11:38:08 lwall
- * Branch for patches.
- *
- * Revision 4.3 85/05/01 11:47:56 lwall
- * Baseline for release with 4.3bsd.
- *
- */
-
- #include "INTERN.h"
- #include "common.h"
- #include "rn.h"
- #include "EXTERN.h"
- #include "rcstuff.h"
- #include "term.h"
- #include "final.h"
- #include "ngdata.h"
- #include "util.h"
- #include "only.h"
- #include "ngsrch.h"
- #include "help.h"
- #include "last.h"
- #include "init.h"
- #include "intrp.h"
- #include "rcln.h"
- #include "sw.h"
- #include "addng.h"
- #include "ng.h"
-
- void
- rn_init()
- {
- ;
- }
-
- void
- main(argc,argv)
- int argc;
- char *argv[];
- {
- bool foundany = initialize(argc,argv);
- register char *s;
- bool oh_for_the_good_old_days = FALSE;
-
- if (maxngtodo)
- starthere = 0;
- else if (!foundany) { /* nothing to do? */
- #ifdef VERBOSE
- if (verbose)
- fputs("\
- No unread news in subscribed-to newsgroups. To subscribe to a new\n\
- newsgroup use the g<newsgroup> command.\n\
- ",stdout) FLUSH;
- #endif
- starthere = nextrcline;
- }
-
- /* loop through all unread news */
-
- {
- char promptbuf[80];
- bool special = FALSE; /* temporarily allow newsgroup */
- /* with no unread news? */
- bool retry; /* cycle back to top of list? */
- NG_NUM recent_ng = 0;
-
- current_ng = 0;
- do {
- retry = FALSE;
- if (findlast) {
- findlast = FALSE;
- starthere = 0;
- if (*lastngname) {
- if ((ng = find_ng(lastngname)) == nextrcline)
- ng = 0;
- else {
- set_ngname(lastngname);
- set_toread(ng);
- if (toread[ng] <= TR_NONE)
- ng = 0;
- }
- }
- }
- else {
- ng = starthere;
- starthere = 0;
- }
- while (ng <= nextrcline) { /* for each newsgroup */
- mode = 'n';
- if (ng >= nextrcline) { /* after the last newsgroup? */
- ng = nextrcline; /* force it to 1 after */
- #ifdef ONLY
- if (maxngtodo) {
- if (retry)
- #ifdef VERBOSE
- IF(verbose)
- printf("\nRestriction %s%s still in effect.\n",
- ngtodo[0],
- maxngtodo > 1 ? ", etc." : nullstr) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("\n(\"Only\" mode.)\n",stdout) FLUSH;
- #endif
- else {
- #ifdef VERBOSE
- IF(verbose)
- fputs("\nNo articles under restriction.",
- stdout) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("\nNo \"only\" articles.",stdout) FLUSH;
- #endif
- end_only(); /* release the restriction */
- retry = TRUE;
- }
- }
- #endif
- dfltcmd = (retry ? "npq" : "qnp");
- #ifdef VERBOSE
- IF(verbose)
- sprintf(promptbuf,
- "\n******** End of newsgroups--what next? [%s] ",
- dfltcmd);
- ELSE
- #endif
- #ifdef TERSE
- sprintf(promptbuf,
- "\n**** End--next? [%s] ", dfltcmd);
- #endif
- }
- else {
- bool shoe_fits; /* newsgroup matches restriction? */
-
- if (toread[ng] >= TR_NONE) { /* recalc toread? */
- set_ngname(rcline[ng]);
- if (shoe_fits = (special || inlist(ngname)))
- set_toread(ng);
- if (paranoid) {
- recent_ng = current_ng;
- current_ng = ng;
- cleanup_rc();
- /* this may move newsgroups around */
- ng = current_ng;
- set_ngname(rcline[ng]);
- }
- }
- if (toread[ng] < (maxngtodo||special ? TR_NONE : TR_ONE) || !shoe_fits) {
- /* unwanted newsgroup? */
- ng++; /* then skip it */
- continue;
- }
- reprompt_newsgroup:
- dfltcmd = "ynq";
- #ifdef VERBOSE
- IF(verbose)
- sprintf(promptbuf,
- "\n******** %3ld unread article%c in %s--read now? [%s] ",
- (long)toread[ng], (toread[ng]==TR_ONE ? ' ' : 's'),
- ngname, dfltcmd); /* format prompt string */
- ELSE
- #endif
- #ifdef TERSE
- sprintf(promptbuf,
- "\n**** %3ld in %s--read? [%s] ",
- (long)toread[ng],
- ngname,dfltcmd); /* format prompt string */
- #endif
- }
- special = FALSE; /* go back to normal mode */
- if (ng != current_ng) {
- recent_ng = current_ng;
- /* remember previous newsgroup */
- current_ng = ng; /* remember current newsgroup */
- }
- reask_newsgroup:
- unflush_output(); /* disable any ^O in effect */
- fputs(promptbuf,stdout) FLUSH;/* print prompt */
- fflush(stdout);
- reinp_newsgroup:
- eat_typeahead();
- getcmd(buf);
- if (errno || *buf == '\f') {
- putchar('\n') FLUSH; /* if return from stop signal */
- goto reask_newsgroup; /* give them a prompt again */
- }
- setdef(buf,dfltcmd);
- #ifdef VERIFY
- printcmd();
- #endif
- switch (*buf) {
- case 'p': /* find previous unread newsgroup */
- do {
- if (ng <= 0)
- break;
- ng--;
- if (toread[ng] == TR_NONE)
- set_toread(ng);
- } while (toread[ng] <= TR_NONE);
- break;
- case 'P': /* goto previous newsgroup */
- do {
- if (ng <= 0)
- break;
- ng--;
- } while (toread[ng] < TR_NONE);
- special = TRUE; /* don't skip it if toread==0 */
- break;
- case '-':
- ng = recent_ng; /* recall previous newsgroup */
- special = TRUE; /* don't skip it if toread==0 */
- break;
- case 'q': case 'Q': case 'x': /* quit? */
- oh_for_the_good_old_days = (*buf == 'x');
- putchar('\n') FLUSH;
- ng = nextrcline+1; /* satisfy */
- retry = FALSE; /* loop conditions */
- break;
- case '^':
- putchar('\n') FLUSH;
- ng = 0;
- break;
- case 'n': case '+': /* find next unread newsgroup */
- if (ng == nextrcline) {
- putchar('\n') FLUSH;
- retry = TRUE;
- }
- else if (toread[ng] > TR_NONE)
- retry = TRUE;
- ng++;
- break;
- case 'N': /* goto next newsgroup */
- ng++;
- special = TRUE; /* and don't skip it if toread==0 */
- break;
- case '1': /* goto 1st newsgroup */
- ng = 0;
- special = TRUE; /* and don't skip it if toread==0 */
- break;
- case '$':
- ng = nextrcline; /* goto last newsgroup */
- retry = TRUE;
- break;
- case 'L':
- list_newsgroups();
- goto reask_newsgroup;
- case '/': case '?': /* scan for newsgroup pattern */
- #ifdef NGSEARCH
- switch (ng_search(buf,TRUE)) {
- case NGS_ABORT:
- goto reinp_newsgroup;
- case NGS_INTR:
- #ifdef VERBOSE
- IF(verbose)
- fputs("\n(Interrupted)\n",stdout) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("\n(Intr)\n",stdout) FLUSH;
- #endif
- ng = current_ng;
- goto reask_newsgroup;
- case NGS_FOUND:
- special = TRUE; /* don't skip it if toread==0 */
- break;
- case NGS_NOTFOUND:
- #ifdef VERBOSE
- IF(verbose)
- fputs("\n\nNot found--use g to add newsgroups\n",
- stdout) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("\n\nNot found\n",stdout) FLUSH;
- #endif
- goto reask_newsgroup;
- }
- #else
- notincl("/");
- #endif
- break;
- case 'm':
- #ifndef RELOCATE
- notincl("m");
- break;
- #endif
- case 'g': /* goto named newsgroup */
- if (!finish_command(FALSE))
- /* if they didn't finish command */
- goto reinp_newsgroup; /* go try something else */
- for (s = buf+1; *s == ' '; s++);
- /* skip leading spaces */
- if (!*s)
- strcpy(s,ngname);
- #ifdef RELOCATE
- if (!get_ng(s,*buf=='m')) /* try to find newsgroup */
- #else
- if (!get_ng(s,FALSE)) /* try to find newsgroup */
- #endif
- ng = current_ng;/* if not found, go nowhere */
- special = TRUE; /* don't skip it if toread==0 */
- break;
- #ifdef DEBUGGING
- case 'D':
- printf("\nTries: %d Hits: %d\n",
- softtries,softtries-softmisses) FLUSH;
- goto reask_newsgroup;
- #endif
- case '!': /* shell escape */
- if (escapade()) /* do command */
- goto reinp_newsgroup;
- /* if rubbed out, re input */
- goto reask_newsgroup;
- case Ctl('k'): /* edit global KILL file */
- edit_kfile();
- goto reask_newsgroup;
- case 'c': /* catch up */
- #ifdef CATCHUP
- reask_catchup:
- #ifdef VERBOSE
- IF(verbose)
- in_char("\nDo you really want to mark everything as read? [yn] ", 'C');
- ELSE
- #endif
- #ifdef TERSE
- in_char("\nReally? [ynh] ", 'C');
- #endif
- putchar('\n') FLUSH;
- setdef(buf,"y");
- if (*buf == 'h') {
- #ifdef VERBOSE
- printf("Type y or SP to mark all articles as read.\n");
- printf("Type n to leave articles marked as they are.\n");
- #else
- printf("y or SP to mark all read.\n");
- printf("n to forget it.\n");
- #endif
- goto reask_catchup;
- }
- else if (*buf!=' ' && *buf!='y' && *buf!='n' && *buf!='q') {
- printf(hforhelp);
- settle_down();
- goto reask_catchup;
- } else if ( (*buf == ' ' || *buf == 'y') && ng<nextrcline )
- catch_up(ng);
- else
- retry = TRUE;
- ng++;
- #else
- notincl("c");
- #endif
- break;
- case 'u': /* unsubscribe */
- if (ng < nextrcline && toread[ng] >= TR_NONE) {
- /* unsubscribable? */
- printf(unsubto,rcline[ng]) FLUSH;
- rcchar[ng] = NEGCHAR;
- /* unsubscribe to (from?) it */
- toread[ng] = TR_UNSUB;
- /* and make line invisible */
- ng++; /* do an automatic 'n' */
- }
- break;
- case 'h': { /* help */
- int cmd;
-
- if ((cmd = help_ng()) > 0)
- pushchar(cmd);
- goto reask_newsgroup;
- }
- case 'a':
- #ifndef FINDNEWNG
- notincl("a");
- goto reask_newsgroup;
- #else
- /* FALL THROUGH */
- #endif
- case 'o':
- #ifdef ONLY
- {
- #ifdef FINDNEWNG
- bool doscan = (*buf == 'a');
- #endif
-
- if (!finish_command(TRUE)) /* get rest of command */
- goto reinp_newsgroup; /* if rubbed out, try something else */
- end_only();
- if (buf[1]) {
- bool minusd = instr(buf+1,"-d") != Nullch;
-
- sw_list(buf+1);
- if (minusd)
- cwd_check();
- putchar('\n') FLUSH;
- #ifdef FINDNEWNG
- if (doscan && maxngtodo)
- scanactive();
- #endif
- }
- ng = 0; /* simulate ^ */
- retry = FALSE;
- break;
- }
- #else
- notincl("o");
- goto reask_newsgroup;
- #endif
- case '&':
- if (switcheroo()) /* get rest of command */
- goto reinp_newsgroup; /* if rubbed out, try something else */
- goto reask_newsgroup;
- case 'l': { /* list other newsgroups */
- if (!finish_command(TRUE)) /* get rest of command */
- goto reinp_newsgroup; /* if rubbed out, try something else */
- for (s = buf+1; *s == ' '; s++);
- /* skip leading spaces */
- sprintf(cmd_buf,"%s '%s'",filexp(NEWSGROUPS),s);
- resetty();
- if (doshell(sh,cmd_buf))
- #ifdef VERBOSE
- IF(verbose)
- fputs(" (Error from newsgroups program)\n",
- stdout) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("(Error)\n",stdout) FLUSH;
- #endif
- noecho();
- crmode();
- goto reask_newsgroup;
- }
- case '.': case '=':
- case 'y': case 'Y': /* do normal thing */
- if (ng >= nextrcline) {
- fputs("\nNot on a newsgroup.",stdout) FLUSH;
- goto reask_newsgroup;
- }
- if (*buf == '=')
- s = savestr("=");
- else if (*buf == '.') { /* start command? */
- if (!finish_command(FALSE)) /* get rest of command */
- goto reinp_newsgroup;
- s = savestr(buf+1);
- /* do_newsgroup will free it */
- }
- else
- s = Nullch;
- if (toread[ng])
- retry = TRUE;
- switch (do_newsgroup(s)) {
- case NG_ERROR:
- case NG_NORM:
- ng++;
- break;
- case NG_ASK:
- goto reprompt_newsgroup;
- case NG_MINUS:
- ng = recent_ng; /* recall previous newsgroup */
- special = TRUE; /* don't skip it if toread==0 */
- break;
- }
- break;
- #ifdef STRICTCR
- case '\n':
- fputs(badcr,stdout) FLUSH;
- goto reask_newsgroup;
- #endif
- case 'v':
- printf("\n%s",rnid);
- printf("\n%s",patchlevel);
- printf("\nSend bugs to rrn@lib.tmc.edu\n") FLUSH;
- goto reask_newsgroup;
- default:
- printf("\n%s",hforhelp) FLUSH;
- settle_down();
- goto reask_newsgroup;
- }
- }
- } while (retry);
- }
-
- /* now write .newsrc back out */
-
- write_rc();
-
- if (oh_for_the_good_old_days)
- get_old_rc();
-
- finalize(0); /* and exit */
- }
-
- /* set current newsgroup */
-
- void
- set_ngname(what)
- char *what;
- {
- int len = strlen(what)+1;
-
- growstr(&ngname,&ngnlen,len);
- strcpy(ngname,what);
- growstr(&ngdir,&ngdlen,len);
- strcpy(ngdir,getngdir(ngname));
- }
-
- static char *myngdir;
- static int ngdirlen = 0;
-
- char *
- getngdir(ngnam)
- char *ngnam;
- {
- register char *s;
-
- growstr(&myngdir,&ngdirlen,strlen(ngnam)+1);
- strcpy(myngdir,ngnam);
- for (s = myngdir; *s; s++)
- if (*s == '.')
- *s = '/';
- return myngdir;
- }
-
- !STUFFY!FUNK!
- echo Extracting sw.c
- cat >sw.c <<'!STUFFY!FUNK!'
- /* $Header: sw.c,v 4.3.2.3 90/05/08 22:06:00 sob Exp $
- *
- * $Log: sw.c,v $
- * Revision 4.3.2.3 90/05/08 22:06:00 sob
- * Added quick startup (-q) flag.
- *
- * Revision 4.3.2.2 90/03/22 23:05:34 sob
- * Fixes provided by Wayne Davison <drivax!davison>
- *
- * Revision 4.3.2.1 89/12/09 00:52:40 sob
- * Now handles SIGWINCH correctly.
- *
- * Revision 4.3.1.2 85/05/21 13:36:23 lwall
- * Sped up "rn -c" by not doing unnecessary initialization.
- *
- * Revision 4.3.1.1 85/05/10 11:40:38 lwall
- * Branch for patches.
- *
- * Revision 4.3 85/05/01 11:50:54 lwall
- * Baseline for release with 4.3bsd.
- *
- */
-
- #include "EXTERN.h"
- #include "common.h"
- #include "util.h"
- #include "head.h"
- #include "only.h"
- #include "term.h"
- #include "ng.h"
- #include "intrp.h"
- #include "INTERN.h"
- #include "sw.h"
-
- void
- sw_init(argc,argv,tcbufptr)
- int argc;
- char *argv[];
- char **tcbufptr;
- {
- register int i;
-
- if (argc >= 2 && strEQ(argv[1],"-c"))
- checkflag=TRUE; /* so we can optimize for -c */
- interp(*tcbufptr,1024,GLOBINIT);
- sw_file(tcbufptr,FALSE);
- safecpy(*tcbufptr,getenv("RNINIT"),1024);
- if (**tcbufptr) {
- if (**tcbufptr == '/') {
- sw_file(tcbufptr,TRUE);
- }
- else
- sw_list(*tcbufptr);
- }
-
- for (i = 1; i < argc; i++)
- decode_switch(argv[i]);
- }
-
- void
- sw_file(tcbufptr,bleat)
- char **tcbufptr;
- bool bleat;
- {
- int initfd = open(*tcbufptr,0);
-
- if (initfd >= 0) {
- fstat(initfd,&filestat);
- if (filestat.st_size > 1024)
- *tcbufptr = saferealloc(*tcbufptr,(MEM_SIZE)filestat.st_size);
- if (filestat.st_size) {
- read(initfd,*tcbufptr,(int)filestat.st_size);
- (*tcbufptr)[filestat.st_size-1] = '\0';
- /* wipe out last newline */
- sw_list(*tcbufptr);
- }
- else
- **tcbufptr = '\0';
- close(initfd);
- }
- else {
- if (bleat)
- printf(cantopen,*tcbufptr) FLUSH;
- **tcbufptr = '\0';
- }
- }
-
- /* decode a list of space separated switches */
-
- void
- sw_list(swlist)
- char *swlist;
- {
- char *tmplist = safemalloc((MEM_SIZE) strlen(swlist) + 2);
- /* semi-automatic string */
- register char *p, inquote = 0;
-
- strcpy(tmplist,swlist);
- for (p=tmplist; isspace(*p); p++) ; /* skip any initial spaces */
- while (*p) { /* "String, or nothing" */
- if (!inquote && isspace(*p)) { /* word delimiter? */
- *p++ = '\0'; /* chop here */
- while (isspace(*p)) /* these will be ignored later */
- p++;
- }
- else if (inquote == *p) {
- strcpy(p,p+1); /* delete trailing quote */
- inquote = 0; /* no longer quoting */
- }
- else if (!inquote && *p == '"' || *p == '\'') {
- /* OK, I know when I am not wanted */
- inquote = *p; /* remember single or double */
- strcpy(p,p+1); /* delete the quote */
- } /* (crude, but effective) */
- else if (*p == '\\') { /* quoted something? */
- if (p[1] == '\n') /* newline? */
- strcpy(p,p+2); /* "I didn't see anything" */
- else {
- strcpy(p,p+1); /* delete the backwhack */
- p++; /* leave the whatever alone */
- }
- }
- else
- p++; /* normal char, leave it alone */
- }
- *++p = '\0'; /* put an extra null on the end */
- if (inquote)
- printf("Unmatched %c in switch\n",inquote) FLUSH;
- for (p = tmplist; *p; /* p += strlen(p)+1 */ ) {
- decode_switch(p);
- while (*p++) ; /* point at null + 1 */
- }
- free(tmplist); /* this oughta be in Ada */
- }
-
- /* decode a single switch */
-
- void
- decode_switch(s)
- register char *s;
- {
- while (isspace(*s)) /* ignore leading spaces */
- s++;
- #ifdef DEBUGGING
- if (debug)
- printf("Switch: %s\n",s) FLUSH;
- #endif
- if (*s != '-' && *s != '+') { /* newsgroup pattern */
- setngtodo(s);
- }
- else { /* normal switch */
- bool upordown = *s == '-' ? TRUE : FALSE;
- char tmpbuf[LBUFLEN];
-
- s++;
- switch (*s) {
- #ifdef TERMMOD
- case '=': {
- char *beg = s+1;
-
- while (*s && *s != '-' && *s != '+') s++;
- cpytill(tmpbuf,beg,*s);
- if (upordown ? strEQ(getenv("TERM"),tmpbuf)
- : strNE(getenv("TERM"),tmpbuf) ) {
- decode_switch(s);
- }
- break;
- }
- #endif
- #ifdef BAUDMOD
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- if (upordown ? (just_a_sec*10 <= atoi(s))
- : (just_a_sec*10 >= atoi(s)) ) {
- while (isdigit(*s)) s++;
- decode_switch(s);
- }
- break;
- #endif
- case '/':
- if (checkflag)
- break;
- #ifdef SETENV
- setenv("SAVEDIR", upordown ? "%p/%c" : "%p" );
- setenv("SAVENAME", upordown ? "%a" : "%^C");
- #else
- notincl("-/");
- #endif
- break;
- case 'c':
- checkflag = upordown;
- break;
- case 'C':
- s++;
- if (*s == '=') s++;
- docheckwhen = atoi(s);
- break;
- case 'd': {
- if (checkflag)
- break;
- s++;
- if (*s == '=') s++;
- if (cwd) {
- chdir(cwd);
- free(cwd);
- }
- cwd = savestr(s);
- break;
- }
- #ifdef DEBUGGING
- case 'D':
- s++;
- if (*s == '=') s++;
- if (*s)
- if (upordown)
- debug |= atoi(s);
- else
- debug &= ~atoi(s);
- else
- if (upordown)
- debug |= 1;
- else
- debug = 0;
- break;
- #endif
- case 'e':
- erase_screen = upordown;
- break;
- case 'E':
- #ifdef SETENV
- s++;
- if (*s == '=')
- s++;
- strcpy(tmpbuf,s);
- s = index(tmpbuf,'=');
- if (s) {
- *s++ = '\0';
- setenv(tmpbuf,s);
- }
- else
- setenv(tmpbuf,nullstr);
- #else
- notincl("-E");
- #endif
- break;
- case 'F':
- s++;
- indstr = savestr(s);
- break;
- #ifdef INNERSEARCH
- case 'g':
- gline = atoi(s+1)-1;
- break;
- #endif
- case 'H':
- case 'h': {
- register int len, i;
- char *t;
- int flag = (*s == 'h' ? HT_HIDE : HT_MAGIC);
-
- if (checkflag)
- break;
- s++;
- len = strlen(s);
- for (t=s; *t; t++)
- if (isupper(*t))
- *t = tolower(*t);
- for (i=HEAD_FIRST; i<HEAD_LAST; i++)
- if (!len || strnEQ(s,htype[i].ht_name,len))
- if (upordown)
- htype[i].ht_flags |= flag;
- else
- htype[i].ht_flags &= ~flag;
- break;
- }
- case 'i':
- s++;
- if (*s == '=') s++;
- initlines = atoi(s);
- initlines_specified = TRUE;
- break;
- case 'l':
- muck_up_clear = upordown;
- break;
- case 'L':
- #ifdef CLEAREOL
- can_home_clear = upordown;
- #else
- notincl("-L");
- #endif
- break;
- case 'M':
- mbox_always = upordown;
- break;
- case 'm':
- s++;
- if (*s == '=') s++;
- if (!upordown)
- marking = NOMARKING;
- else if (*s == 'u')
- marking = UNDERLINE;
- else {
- marking = STANDOUT;
- }
- break;
- case 'N':
- norm_always = upordown;
- break;
- #ifdef VERBOSE
- case 'n':
- fputs("This isn't readnews. Don't use -n.\n\n",stdout) FLUSH;
- break;
- #endif
- case 'r':
- findlast = upordown;
- break;
- case 's':
- s++;
- if (*s == '=') s++;
- if (*s) {
- countdown = atoi(s);
- suppress_cn = FALSE;
- }
- else {
- if (!upordown)
- countdown = 5;
- suppress_cn = upordown;
- }
- break;
- case 'S':
- #ifdef ARTSEARCH
- s++;
- if (*s == '=') s++;
- if (*s)
- scanon = atoi(s);
- else
- scanon = upordown*3;
- #else
- notincl("-S");
- #endif
- break;
- case 't':
- #ifdef VERBOSE
- #ifdef TERSE
- verbose = !upordown;
- #else
- notincl("+t");
- #endif
- #else
- notincl("+t");
- #endif
- break;
- case 'T':
- typeahead = upordown;
- break;
- case 'v':
- #ifdef VERIFY
- verify = upordown;
- #else
- notincl("-v");
- #endif
- break;
- /*
- * People want a way to avoid checking for new newsgroups on startup.
- */
- case 'q':
- quickstart = upordown;
- break;
- default:
- #ifdef VERBOSE
- IF(verbose)
- printf("\nIgnoring unrecognized switch: -%c\n", *s) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- printf("\nIgnoring -%c\n", *s) FLUSH;
- #endif
- break;
- }
- }
- }
-
- /* print current switch values */
-
- void
- pr_switches()
- {
- static char mp[2] = {'+','-'};
- register int i;
-
- fputs("\nCurrent switch settings:\n",stdout);
- printf("%c/ ", mp[strEQ(getval("SAVEDIR",SAVEDIR),"%p/%c")]);
- printf("%cc ", mp[checkflag]);
- printf("-C%d ", docheckwhen);
- printf("-d%s ", cwd);
- #ifdef DEBUGGING
- if (debug)
- printf("-D%d ", debug);
- #endif
- printf("%ce ", mp[erase_screen]);
- printf("-F\"%s\" ", indstr);
- #ifdef INNERSEARCH
- printf("-g%d", gline);
- #endif
- putchar('\n');
- #ifdef VERBOSE
- if (verbose) {
- for (i=HEAD_FIRST; i<HEAD_LAST; i++)
- printf("%ch%s%c",
- mp[htype[i].ht_flags & HT_HIDE], htype[i].ht_name,
- (! (i % 5) ? '\n' : ' ') );
- }
- #endif
- printf("-i%d ", initlines);
- printf("%cl ", mp[muck_up_clear]);
- #ifdef CLEAREOL
- printf("%cL ", mp[can_home_clear]);
- #endif CLEAREOL
- if (marking)
- printf("-m%c ",marking==UNDERLINE?'u':'s');
- else
- printf("+m ");
- printf("%cM ", mp[mbox_always]);
- printf("%cN ", mp[norm_always]);
- printf("%cr ", mp[findlast]);
- if (countdown)
- printf("-s%d ", countdown);
- else
- printf("%cs ", mp[suppress_cn]);
- #ifdef ARTSEARCH
- if (scanon)
- printf("-S%d ",scanon);
- else
- printf("+S ");
- #endif
- #ifdef VERBOSE
- #ifdef TERSE
- printf("%ct ", mp[!verbose]);
- #endif
- #endif
- printf("%cT ", mp[typeahead]);
- #ifdef VERIFY
- printf("%cv ", mp[verify]);
- #endif
- fputs("\n\n",stdout) FLUSH;
- #ifdef ONLY
- if (maxngtodo) {
- #ifdef VERBOSE
- IF(verbose)
- fputs("Current restriction:",stdout);
- ELSE
- #endif
- #ifdef TERSE
- fputs("Only:",stdout);
- #endif
- for (i=0; i<maxngtodo; i++)
- printf(" %s",ngtodo[i]);
- fputs("\n\n",stdout) FLUSH;
- }
- #ifdef VERBOSE
- else if (verbose)
- fputs("No restriction.\n\n",stdout) FLUSH;
- #endif
- #endif
- }
-
- void
- cwd_check()
- {
- char tmpbuf[LBUFLEN];
-
- if (!cwd)
- cwd = savestr(filexp("~/News"));
- strcpy(tmpbuf,cwd);
- if (chdir(cwd)) {
- safecpy(tmpbuf,filexp(cwd),sizeof tmpbuf);
- if (makedir(tmpbuf,MD_DIR) < 0 || chdir(tmpbuf) < 0) {
- interp(cmd_buf, (sizeof cmd_buf), "%~/News");
- if (makedir(cmd_buf,MD_DIR) < 0)
- strcpy(tmpbuf,homedir);
- else
- strcpy(tmpbuf,cmd_buf);
- chdir(tmpbuf);
- #ifdef VERBOSE
- IF(verbose)
- printf("\
- Cannot make directory %s--\n\
- articles will be saved to %s\n\
- \n\
- ",cwd,tmpbuf) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- printf("\
- Can't make %s--\n\
- using %s\n\
- \n\
- ",cwd,tmpbuf) FLUSH;
- #endif
- }
- }
- free(cwd);
- getwd(tmpbuf);
- if (eaccess(tmpbuf,2)) {
- #ifdef VERBOSE
- IF(verbose)
- printf("\
- Current directory %s is not writeable--\n\
- articles will be saved to home directory\n\n\
- ",tmpbuf) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- printf("%s not writeable--using ~\n\n",tmpbuf) FLUSH;
- #endif
- strcpy(tmpbuf,homedir);
- }
- cwd = savestr(tmpbuf);
- }
- !STUFFY!FUNK!
- echo Extracting respond.c
- cat >respond.c <<'!STUFFY!FUNK!'
- /* $Header: respond.c,v 4.3.2.3 90/03/22 23:05:19 sob Exp $
- *
- * $Log: respond.c,v $
- * Revision 4.3.2.3 90/03/22 23:05:19 sob
- * Fixes provided by Wayne Davison <drivax!davison>
- *
- * Revision 4.3.2.2 89/11/26 18:25:10 sob
- * Enlarged the size of the header buffer to accomodate long references lines.
- * Fix provided by Joe Buck.
- *
- * Revision 4.3.2.1 89/11/06 01:00:26 sob
- * Added RRN support from NNTP 1.5
- *
- * Revision 4.3.1.5 85/09/10 11:05:00 lwall
- * Improved %m in in_char().
- *
- * Revision 4.3.1.4 85/05/23 17:24:49 lwall
- * Now allows 'r' and 'f' on null articles.
- *
- * Revision 4.3.1.3 85/05/15 14:42:32 lwall
- * Removed duplicate include of intrp.h.
- *
- * Revision 4.3.1.2 85/05/14 08:55:15 lwall
- * Default for normal/mailbox question was applied to wrong buffer.
- *
- * Revision 4.3.1.1 85/05/10 11:37:33 lwall
- * Branch for patches.
- *
- * Revision 4.3 85/05/01 11:47:04 lwall
- * Baseline for release with 4.3bsd.
- *
- */
-
- #include "EXTERN.h"
- #include "common.h"
- #include "intrp.h"
- #include "head.h"
- #include "term.h"
- #include "ng.h"
- #include "util.h"
- #include "rn.h"
- #include "artio.h"
- #include "final.h"
- #include "INTERN.h"
- #include "respond.h"
-
- static char nullart[] = "\nNull article\n";
-
- void
- respond_init()
- {
- ;
- }
-
- int
- save_article()
- {
- bool use_pref;
- register char *s, *c;
- char altbuf[CBUFLEN];
- int iter;
- bool interactive = (buf[1] == FINISHCMD);
-
- if (!finish_command(interactive)) /* get rest of command */
- return SAVE_ABORT;
- use_pref = isupper(*buf);
- #ifdef ASYNC_PARSE
- parse_maybe(art);
- #endif
- savefrom = (*buf=='w' || *buf=='W' ? htype[PAST_HEADER].ht_minpos : 0);
- if (artopen(art) == Nullfp) {
- #ifdef VERBOSE
- IF(verbose)
- fputs("\n\
- Saving null articles is not very productive! :-)\n\
- ",stdout) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs(nullart,stdout) FLUSH;
- #endif
- return SAVE_DONE;
- }
- if (chdir(cwd)) {
- printf(nocd,cwd) FLUSH;
- sig_catcher(0);
- }
- if (savedest)
- free(savedest);
- if ((s = index(buf,'|')) != Nullch) {
- /* is it a pipe command? */
- s++; /* skip the | */
- while (*s == ' ') s++;
- safecpy(altbuf,filexp(s),sizeof altbuf);
- savedest = altbuf;
- interp(cmd_buf, (sizeof cmd_buf), getval("PIPESAVER",PIPESAVER));
- /* then set up for command */
- resetty(); /* restore tty state */
- if (use_pref) /* use preferred shell? */
- doshell(Nullch,cmd_buf);
- /* do command with it */
- else
- doshell(sh,cmd_buf); /* do command with sh */
- noecho(); /* and stop echoing */
- crmode(); /* and start cbreaking */
- savedest = savestr(savedest);
- }
- else { /* normal save */
- bool there, mailbox;
- char *savename = getval("SAVENAME",SAVENAME);
-
- s = buf+1; /* skip s or S */
- if (*s == '-') { /* if they are confused, skip - also */
- #ifdef VERBOSE
- IF(verbose)
- fputs("Warning: '-' ignored. This isn't readnews.\n",stdout)
- FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("'-' ignored.\n",stdout) FLUSH;
- #endif
- s++;
- }
- for (; *s == ' '; s++); /* skip spaces */
- safecpy(altbuf,filexp(s),sizeof altbuf);
- s = altbuf;
- if (! index(s,'/')) {
- interp(buf, (sizeof buf), getval("SAVEDIR",SAVEDIR));
- if (makedir(buf,MD_DIR)) /* ensure directory exists */
- strcpy(buf,cwd);
- if (*s) {
- for (c = buf; *c; c++) ;
- *c++ = '/';
- strcpy(c,s); /* add filename */
- }
- s = buf;
- }
- for (iter = 0;
- (there = stat(s,&filestat) >= 0) &&
- (filestat.st_mode & S_IFDIR);
- iter++) { /* is it a directory? */
-
- c = (s+strlen(s));
- *c++ = '/'; /* put a slash before filename */
- interp(c, s==buf?(sizeof buf):(sizeof altbuf),
- iter ? "News" : savename );
- /* generate a default name somehow or other */
- if (index(c,'/')) { /* yikes, a '/' in the filename */
- makedir(s,MD_FILE);
- }
- }
- if (*s != '/') { /* relative path? */
- c = (s==buf ? altbuf : buf);
- sprintf(c, "%s/%s", cwd, s);
- s = c; /* absolutize it */
- }
- s = savedest = savestr(s); /* doesn't move any more */
- /* make it handy for %b */
- if (!there) {
- if (mbox_always)
- mailbox = TRUE;
- else if (norm_always)
- mailbox = FALSE;
- else {
- char *dflt = (instr(savename,"%a") ? "nyq" : "ynq");
-
- sprintf(cmd_buf,
- "\nFile %s doesn't exist--\n use mailbox format? [%s] ",
- s,dflt);
- reask_save:
- in_char(cmd_buf, 'M');
- putchar('\n') FLUSH;
- setdef(buf,dflt);
- #ifdef VERIFY
- printcmd();
- #endif
- if (*buf == 'h') {
- #ifdef VERBOSE
- IF(verbose)
- printf("\n\
- Type y to create %s as a mailbox.\n\
- Type n to create it as a normal file.\n\
- Type q to abort the save.\n\
- ",s) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("\n\
- y to create mailbox.\n\
- n to create normal file.\n\
- q to abort.\n\
- ",stdout) FLUSH;
- #endif
- goto reask_save;
- }
- else if (*buf == 'n') {
- mailbox = FALSE;
- }
- else if (*buf == 'y') {
- mailbox = TRUE;
- }
- else if (*buf == 'q') {
- goto s_bomb;
- }
- else {
- fputs(hforhelp,stdout) FLUSH;
- settle_down();
- goto reask_save;
- }
- }
- }
- else if (filestat.st_mode & S_IFCHR)
- mailbox = FALSE;
- else {
- int tmpfd;
-
- tmpfd = open(s,0);
- if (tmpfd == -1)
- mailbox = FALSE;
- else {
- read(tmpfd,buf,LBUFLEN);
- c = buf;
- if (!isspace(MBOXCHAR))
- while (isspace(*c))
- c++;
- mailbox = (*c == MBOXCHAR);
- close(tmpfd);
- }
- }
-
- safecpy(cmd_buf, filexp(mailbox ?
- getval("MBOXSAVER",MBOXSAVER) :
- getval("NORMSAVER",NORMSAVER) ), sizeof cmd_buf);
- /* format the command */
- resetty(); /* make terminal behave */
- if (doshell(use_pref?Nullch:SH,cmd_buf))
- fputs("Not saved",stdout);
- else
- printf("%s to %s %s",
- there?"Appended":"Saved",
- mailbox?"mailbox":"file",
- s);
- if (interactive)
- putchar('\n') FLUSH;
- noecho(); /* make terminal do what we want */
- crmode();
- }
- s_bomb:
- #ifdef SERVER
- if (chdir(spool)) {
- #else not SERVER
- if (chdir(spool) || chdir(ngdir)) {
- #endif SERVER
- printf(nocd,ngdir) FLUSH;
- sig_catcher(0);
- }
- return SAVE_DONE;
- }
-
- int
- cancel_article()
- {
- char *artid_buf;
- char *ngs_buf;
- char *from_buf;
- char *reply_buf;
- int myuid = getuid();
- int r = -1;
-
- if (artopen(art) == Nullfp) {
- #ifdef VERBOSE
- IF(verbose)
- fputs("\n\
- Cancelling null articles is your idea of fun? :-)\n\
- ",stdout) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs(nullart,stdout) FLUSH;
- #endif
- return r;
- }
- reply_buf = fetchlines(art,REPLY_LINE);
- from_buf = fetchlines(art,FROM_LINE);
- artid_buf = fetchlines(art,ARTID_LINE);
- ngs_buf = fetchlines(art,NGS_LINE);
- if (!instr(from_buf,sitename) ||
- (!instr(from_buf,logname) &&
- !instr(reply_buf,logname) &&
- #ifdef NEWSADMIN
- myuid != newsuid &&
- #endif
- myuid != ROOTID ) )
- #ifdef VERBOSE
- IF(verbose)
- fputs("\nYou can't cancel someone else's article\n",stdout)
- FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("\nNot your article\n",stdout) FLUSH;
- #endif
- else {
- tmpfp = fopen(headname,"w"); /* open header file */
- if (tmpfp == Nullfp) {
- printf(cantcreate,headname) FLUSH;
- goto no_cancel;
- }
- interp(buf, (sizeof buf), getval("CANCELHEADER",CANCELHEADER));
- fputs(buf,tmpfp);
- fclose(tmpfp);
- fputs("\nCanceling...\n",stdout) FLUSH;
- r = doshell(sh,filexp(getval("CANCEL",CANCEL)));
- }
- no_cancel:
- free(artid_buf);
- free(ngs_buf);
- free(from_buf);
- free(reply_buf);
- return r;
- }
-
- void
- reply()
- {
- bool incl_body = (*buf == 'R');
- char *maildoer = savestr(filexp(getval("MAILPOSTER",MAILPOSTER)));
-
- artopen(art);
- tmpfp = fopen(headname,"w"); /* open header file */
- if (tmpfp == Nullfp) {
- printf(cantcreate,headname) FLUSH;
- goto no_reply;
- }
- interp(buf, (sizeof buf), getval("MAILHEADER",MAILHEADER));
- fputs(buf,tmpfp);
- if (!instr(maildoer,"%h"))
- #ifdef VERBOSE
- IF(verbose)
- printf("\n%s\n(Above lines saved in file %s)\n",buf,headname)
- FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- printf("\n%s\n(Header in %s)\n",buf,headname) FLUSH;
- #endif
- if (incl_body && artfp != Nullfp) {
- interp(buf, (sizeof buf), getval("YOUSAID",YOUSAID));
- fprintf(tmpfp,"%s\n",buf);
- #ifdef ASYNC_PARSE
- parse_maybe(art);
- #endif
- fseek(artfp,(long)htype[PAST_HEADER].ht_minpos,0);
- while (fgets(buf,LBUFLEN,artfp) != Nullch) {
- fprintf(tmpfp,"%s%s",indstr,buf);
- }
- fprintf(tmpfp,"\n");
- }
- fclose(tmpfp);
- interp(cmd_buf, (sizeof cmd_buf), maildoer);
- invoke(cmd_buf,origdir);
- UNLINK(headname); /* kill the header file */
- no_reply:
- free(maildoer);
- }
-
- void
- followup()
- {
- bool incl_body = (*buf == 'F');
- char hbuf[4*LBUFLEN]; /* four times the old size */
-
- artopen(art);
- tmpfp = fopen(headname,"w");
- if (tmpfp == Nullfp) {
- printf(cantcreate,headname) FLUSH;
- return;
- }
- interp(hbuf, (sizeof hbuf), getval("NEWSHEADER",NEWSHEADER));
- fprintf(tmpfp,"%s",hbuf);
- if (incl_body && artfp != Nullfp) {
- #ifdef VERBOSE
- if (verbose)
- fputs("\n\
- (Be sure to double-check the attribution against the signature, and\n\
- trim the quoted article down as much as possible.)\n\
- ",stdout) FLUSH;
- #endif
- interp(buf, (sizeof buf), getval("ATTRIBUTION",ATTRIBUTION));
- fprintf(tmpfp,"%s\n",buf);
- #ifdef ASYNC_PARSE
- parse_maybe(art);
- #endif
- fseek(artfp,(long)htype[PAST_HEADER].ht_minpos,0);
- while (fgets(buf,LBUFLEN,artfp) != Nullch) {
- fprintf(tmpfp,"%s%s",indstr,buf);
- }
- fprintf(tmpfp,"\n");
- }
- fclose(tmpfp);
- safecpy(cmd_buf,filexp(getval("NEWSPOSTER",NEWSPOSTER)),sizeof cmd_buf);
- invoke(cmd_buf,origdir);
- UNLINK(headname);
- }
-
- void
- invoke(cmd,dir)
- char *cmd,*dir;
- {
- if (chdir(dir)) {
- printf(nocd,dir) FLUSH;
- return;
- }
- #ifdef VERBOSE
- IF(verbose)
- printf("\n(leaving cbreak mode; cwd=%s)\nInvoking command: %s\n\n",
- dir,cmd) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- printf("\n(-cbreak; cwd=%s)\nInvoking: %s\n\n",dir,cmd) FLUSH;
- #endif
- resetty(); /* make terminal well-behaved */
- doshell(sh,cmd); /* do the command */
- noecho(); /* set no echo */
- crmode(); /* and cbreak mode */
- #ifdef VERBOSE
- IF(verbose)
- fputs("\n(re-entering cbreak mode)\n",stdout) FLUSH;
- ELSE
- #endif
- #ifdef TERSE
- fputs("\n(+cbreak)\n",stdout) FLUSH;
- #endif
- #ifdef SERVER
- if (chdir(spool)) {
- #else not SERVER
- if (chdir(spool) || chdir(ngdir)) {
- #endif SERVER
- printf(nocd,ngdir) FLUSH;
- sig_catcher(0);
- }
- }
-
- !STUFFY!FUNK!
- echo Extracting util.c
- cat >util.c <<'!STUFFY!FUNK!'
- /* $Header: util.c,v 4.3.2.6 90/04/23 00:24:42 sob Exp $
- *
- * $Log: util.c,v $
- * Revision 4.3.2.6 90/04/23 00:24:42 sob
- * A bit of clean up.
- *
- * Revision 4.3.2.5 90/03/17 21:34:21 sob
- * Reworked VOIDSIG into SIGRET.
- *
- * Revision 4.3.2.4 89/12/14 23:58:54 sob
- * Fixed small bug reported by fletcher@cs.utexas.edu in getwd().
- *
- * Revision 4.3.2.3 89/11/08 04:47:11 sob
- * Added VOIDSIG handling for SunOS 4.X
- *
- * Revision 4.3.2.2 89/11/07 23:19:35 sob
- * Bug fixes for SIGSTP problems
- *
- * Revision 4.3.2.1 89/11/06 01:03:21 sob
- * Added RRN support from NNTP 1.5
- *
- * Revision 4.3.1.2 85/05/15 14:44:27 lwall
- * Last arg of execl changed from 0 to Nullch [(char*)0].
- *
- * Revision 4.3.1.1 85/05/10 11:41:30 lwall
- * Branch for patches.
- *
- * Revision 4.3 85/05/01 11:51:44 lwall
- * Baseline for release with 4.3bsd.
- *
- */
-
- #include "EXTERN.h"
- #include "common.h"
- #include "final.h"
- #include "ndir.h"
- #include "INTERN.h"
- #include "util.h"
-
- void
- util_init()
- {
- ;
- }
-
- /* fork and exec a shell command */
-
- int
- doshell(shl,s)
- char *s, *shl;
- {
- int status, pid, w;
- SIGRET (*signal())();
- char *shell;
-
- #ifdef SIGTSTP
- sigset(SIGTSTP,SIG_DFL);
- sigset(SIGTTOU,SIG_DFL);
- sigset(SIGTTIN,SIG_DFL);
- #endif
- if (shl != Nullch)
- shell = shl;
- else if ((shell = getenv("SHELL")) == Nullch || !*shell)
- shell = PREFSHELL;
- if ((pid = vfork()) == 0) {
- #ifdef SERVER
- int i;
-
- /* This is necessary to keep bourne shell from puking */
-
- for (i = 3; i < 10; ++i)
- close(i);
- #endif SERVER
-
- if (*s)
- execl(shell, shell, "-c", s, Nullch);
- else
- execl(shell, shell, Nullch, Nullch, Nullch);
- _exit(127);
- }
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- waiting = TRUE;
- while ((w = wait(&status)) != pid && w != -1)
- ;
- if (w == -1)
- status = -1;
- waiting = FALSE;
- sigset(SIGINT, int_catcher); /* always catch interrupts */
- signal(SIGQUIT, SIG_DFL);
- #ifdef SIGTSTP
- sigset(SIGTSTP,stop_catcher);
- sigset(SIGTTOU,stop_catcher);
- sigset(SIGTTIN,stop_catcher);
- #endif
- return status;
- }
-
- static char nomem[] = "rn: out of memory!\n";
-
- /* paranoid version of malloc */
-
- char *
- safemalloc(size)
- MEM_SIZE size;
- {
- char *ptr;
- char *malloc();
-
- ptr = malloc(size?size:1); /* malloc(0) is NASTY on our system */
- if (ptr != Nullch)
- return ptr;
- else {
- fputs(nomem,stdout) FLUSH;
- sig_catcher(0);
- }
- /*NOTREACHED*/
- }
-
- /* paranoid version of realloc */
-
- char *
- saferealloc(where,size)
- char *where;
- MEM_SIZE size;
- {
- char *ptr;
- char *realloc();
-
- ptr = realloc(where,size?size:1); /* realloc(0) is NASTY on our system */
- if (ptr != Nullch)
- return ptr;
- else {
- fputs(nomem,stdout) FLUSH;
- sig_catcher(0);
- }
- /*NOTREACHED*/
- }
-
- /* safe version of string copy */
-
- char *
- safecpy(to,from,len)
- char *to;
- register char *from;
- register int len;
- {
- register char *dest = to;
-
- if (from != Nullch)
- for (len--; len && (*dest++ = *from++); len--) ;
- *dest = '\0';
- return to;
- }
-
- /* safe version of string concatenate, with \n deletion and space padding */
-
- char *
- safecat(to,from,len)
- char *to;
- register char *from;
- register int len;
- {
- register char *dest = to;
-
- len--; /* leave room for null */
- if (*dest) {
- while (len && *dest++) len--;
- if (len) {
- len--;
- *(dest-1) = ' ';
- }
- }
- if (from != Nullch)
- while (len && (*dest++ = *from++)) len--;
- if (len)
- dest--;
- if (*(dest-1) == '\n')
- dest--;
- *dest = '\0';
- return to;
- }
-
- /* copy a string up to some (non-backslashed) delimiter, if any */
-
- char *
- cpytill(to,from,delim)
- register char *to, *from;
- register int delim;
- {
- for (; *from; from++,to++) {
- if (*from == '\\' && from[1] == delim)
- from++;
- else if (*from == delim)
- break;
- *to = *from;
- }
- *to = '\0';
- return from;
- }
-
- /* return ptr to little string in big string, NULL if not found */
-
- char *
- instr(big, little)
- char *big, *little;
-
- {
- register char *t, *s, *x;
-
- for (t = big; *t; t++) {
- for (x=t,s=little; *s; x++,s++) {
- if (!*x)
- return Nullch;
- if (*s != *x)
- break;
- }
- if (!*s)
- return t;
- }
- return Nullch;
- }
-
- /* effective access */
-
- #ifdef SETUIDGID
- int
- eaccess(filename, mod)
- char *filename;
- int mod;
- {
- int protection, euid;
-
- mod &= 7; /* remove extraneous garbage */
- if (stat(filename, &filestat) < 0)
- return -1;
- euid = geteuid();
- if (euid == ROOTID)
- return 0;
- protection = 7 & (filestat.st_mode >>
- (filestat.st_uid == euid ? 6 :
- (filestat.st_gid == getegid() ? 3 : 0)
- ));
- if ((mod & protection) == mod)
- return 0;
- errno = EACCES;
- return -1;
- }
- #endif
-
- /*
- * Get working directory
- */
- #ifdef GETCWD
- char *
- getwd(np)
- char *np;
- {
- char * name;
- extern char * getcwd();
- name = getcwd(np,1024);
- return(name);
- }
- #else
- #ifndef GETWD
- char *
- getwd(np) /* shorter but slower */
- char *np;
- {
- FILE *popen();
- FILE *pipefp = popen("/bin/pwd","r");
-
- if (pipefp == Nullfp) {
- printf("Can't run /bin/pwd\n") FLUSH;
- finalize(1);
- }
- fgets(np,512,pipefp);
- np[strlen(np)-1] = '\0'; /* wipe out newline */
- pclose(pipefp);
- return np;
- }
- #endif
- #endif
- /* just like fgets but will make bigger buffer as necessary */
-
- char *
- get_a_line(original_buffer,buffer_length,fp)
- char *original_buffer;
- register int buffer_length;
- FILE *fp;
- {
- register int bufix = 0;
- register int nextch;
- register char *some_buffer_or_other = original_buffer;
-
- do {
- if (bufix >= buffer_length) {
- buffer_length *= 2;
- if (some_buffer_or_other == original_buffer) {
- /* currently static? */
- some_buffer_or_other = safemalloc((MEM_SIZE)buffer_length+1);
- strncpy(some_buffer_or_other,original_buffer,buffer_length/2);
- /* so we must copy it */
- }
- else { /* just grow in place, if possible */
- some_buffer_or_other = saferealloc(some_buffer_or_other,
- (MEM_SIZE)buffer_length+1);
- }
- }
- if ((nextch = getc(fp)) == EOF)
- return Nullch;
- some_buffer_or_other[bufix++] = (char) nextch;
- } while (nextch && nextch != '\n');
- some_buffer_or_other[bufix] = '\0';
- len_last_line_got = bufix;
- return some_buffer_or_other;
- }
-
- /* copy a string to a safe spot */
-
- char *
- savestr(str)
- char *str;
- {
- register char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1));
-
- strcpy(newaddr,str);
- return newaddr;
- }
-
- int
- makedir(dirname,nametype)
- register char *dirname;
- int nametype;
- {
- #ifdef MAKEDIR
- register char *end;
- register char *s;
- char tmpbuf[1024];
- register char *tbptr = tmpbuf+5;
-
- for (end = dirname; *end; end++) ; /* find the end */
- if (nametype == MD_FILE) { /* not to create last component? */
- for (--end; end != dirname && *end != '/'; --end) ;
- if (*end != '/')
- return 0; /* nothing to make */
- *end = '\0'; /* isolate file name */
- }
- strcpy(tmpbuf,"mkdir");
-
- s = end;
- for (;;) {
- if (stat(dirname,&filestat) >= 0) {
- /* does this much exist? */
- *s = '/'; /* mark this as existing */
- break;
- }
- s = rindex(dirname,'/'); /* shorten name */
- if (!s) /* relative path! */
- break; /* hope they know what they are doing */
- *s = '\0'; /* mark as not existing */
- }
-
- for (s=dirname; s <= end; s++) { /* this is grody but efficient */
- if (!*s) { /* something to make? */
- sprintf(tbptr," %s",dirname);
- tbptr += strlen(tbptr); /* make it, sort of */
- *s = '/'; /* mark it made */
- }
- }
- if (nametype == MD_DIR) /* don't need final slash unless */
- *end = '\0'; /* a filename follows the dir name */
-
- return (tbptr==tmpbuf+5 ? 0 : doshell(sh,tmpbuf));
- /* exercise our faith */
- #else
- sprintf(cmd_buf,"%s %s %d", filexp(DIRMAKER), dirname, nametype);
- return doshell(sh,cmd_buf);
- #endif
- }
-
- #ifdef SETENV
- static bool firstsetenv = TRUE;
- extern char **environ;
-
- void
- setenv(nam,val)
- char *nam, *val;
- {
- register int i=envix(nam); /* where does it go? */
-
- if (!environ[i]) { /* does not exist yet */
- if (firstsetenv) { /* need we copy environment? */
- int j;
- #ifndef lint
- char **tmpenv = (char**) /* point our wand at memory */
- safemalloc((MEM_SIZE) (i+2) * sizeof(char*));
- #else
- char **tmpenv = Null(char **);
- #endif lint
-
- firstsetenv = FALSE;
- for (j=0; j<i; j++) /* copy environment */
- tmpenv[j] = environ[j];
- environ = tmpenv; /* tell exec where it is now */
- }
- #ifndef lint
- else
- environ = (char**) saferealloc((char*) environ,
- (MEM_SIZE) (i+2) * sizeof(char*));
- /* just expand it a bit */
- #endif lint
- environ[i+1] = Nullch; /* make sure it's null terminated */
- }
- environ[i] = safemalloc((MEM_SIZE) strlen(nam) + strlen(val) + 2);
- /* this may or may not be in */
- /* the old environ structure */
- sprintf(environ[i],"%s=%s",nam,val);/* all that work just for this */
- }
-
- int
- envix(nam)
- char *nam;
- {
- register int i, len = strlen(nam);
-
- for (i = 0; environ[i]; i++) {
- if (strnEQ(environ[i],nam,len) && environ[i][len] == '=')
- break; /* strnEQ must come first to avoid */
- } /* potential SEGV's */
- return i;
- }
- #endif
-
- void
- notincl(feature)
- char *feature;
- {
- printf("\nNo room for feature \"%s\" on this machine.\n",feature) FLUSH;
- }
-
- char *
- getval(nam,def)
- char *nam,*def;
- {
- char *val;
-
- if ((val = getenv(nam)) == Nullch || !*val)
- val = def;
- return val;
- }
-
- /* grow a static string to at least a certain length */
-
- void
- growstr(strptr,curlen,newlen)
- char **strptr;
- int *curlen;
- int newlen;
- {
- if (newlen > *curlen) { /* need more room? */
- if (*curlen)
- *strptr = saferealloc(*strptr,(MEM_SIZE)newlen);
- else
- *strptr = safemalloc((MEM_SIZE)newlen);
- *curlen = newlen;
- }
- }
-
- void
- setdef(buffer,dflt)
- char *buffer,*dflt;
- {
- #ifdef STRICTCR
- if (*buffer == ' ')
- #else
- if (*buffer == ' ' || *buffer == '\n')
- #endif
- {
- if (*dflt == '^' && isupper(dflt[1]))
- *buffer = Ctl(dflt[1]);
- else
- *buffer = *dflt;
- }
- }
- !STUFFY!FUNK!
- echo Extracting newsetup.1
- cat >newsetup.1 <<'!STUFFY!FUNK!'
- ''' $Header: newsetup.1,v 4.3 85/05/01 11:43:22 lwall Exp $
- '''
- ''' $Log: newsetup.1,v $
- ''' Revision 4.3 85/05/01 11:43:22 lwall
- ''' Baseline for release with 4.3bsd.
- '''
- '''
- .de Sh
- .br
- .ne 5
- .PP
- \fB\\$1\fR
- .PP
- ..
- .de Sp
- .if t .sp .5v
- .if n .sp
- ..
- '''
- ''' Set up \*(-- to give an unbreakable dash;
- ''' string Tr holds user defined translation string.
- ''' Bell System Logo is used as a dummy character.
- '''
- .ie n \{\
- .tr \(bs-\*(Tr
- .ds -- \(bs-
- .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
- .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
- .ds L" ""
- .ds R" ""
- .ds L' '
- .ds R' '
- 'br\}
- .el\{\
- .ds -- \(em\|
- .tr \*(Tr
- .ds L" ``
- .ds R" ''
- .ds L' `
- .ds R' '
- 'br\}
- .TH NEWSETUP 1 LOCAL
- .SH NAME
- newsetup - a program to set up a .newsrc file
- .SH SYNOPSIS
- .B newsetup
- .SH DESCRIPTION
- The
- .I newsetup
- program creates a new .newsrc file containing all of the currently active
- newsgroups.
- It tries to put them in a reasonable order, i.e. local newsgroups earlier,
- but you'll probably want to change the ordering anyway (if you use
- .IR rn )
- in order to put interesting newsgroups first.
- If you already have a .newsrc, it will be backed up with the name
- \*(L".oldnewsrc\*(R".
- .SH ENVIRONMENT
- .IP DOTDIR 8
- Where to put your .newsrc, if not in your home directory.
- .Sp
- Default: $HOME
- .IP HOME 8
- Your home directory.
- .Sp
- Default: $LOGDIR
- .IP LOGDIR 8
- Your home directory if HOME is undefined.
- .SH FILES
- /usr/lib/news/active or a reasonable facsimile
- .br
- ${DOTDIR-{$HOME-$LOGDIR}}/.newsrc
- .SH SEE ALSO
- rn(1), newsrc(5)
- .SH DIAGNOSTICS
- .SH BUGS
- !STUFFY!FUNK!
- echo ""
- echo "End of kit 6 (of 9)"
- cat /dev/null >kit6isdone
- config=true
- for iskit in 1 2 3 4 5 6 7 8 9 ; do
- if test -f kit${iskit}isdone; then
- echo "You have run kit ${iskit}."
- else
- echo "You still need to run kit ${iskit}."
- config=false
- fi
- done
- case $config in
- true)
- echo "You have run all your kits. Please read README and then type Configure."
- chmod 755 Configure
- ;;
- esac
- : I do not append .signature, but someone might mail this.
- exit
-