[comp.sources.unix] v19i080: Cnews production release, Part03/19

rsalz@uunet.uu.net (Rich Salz) (06/27/89)

Submitted-by: utzoo!henry
Posting-number: Volume 19, Issue 80
Archive-name: cnews2/part03

: ---CUT HERE---
echo 'conf/build':
sed 's/^X//' >'conf/build' <<'!'
X#! /bin/sh
X
X# functions and headers we are prepared to fake
Xmightfake='fsync getopt index memcpy memcmp memchr memset mkdir
X	putenv rindex strchr strrchr strpbrk strspn strcspn strtok symlink'
Xmightfakehdrs='stdlib.h string.h'
X
X# directories in which to do makes
X# batch must precede input; relay must precede misc
Xpgmdirs='conf batch expire input relay misc rna'
X
X# control files built in conf
Xctlf="active allowed errlog history history.pag history.dir localgroups"
Xctlf="$ctlf log mailname mailpaths organization postdefltdist postdefltgroup"
Xctlf="$ctlf replyusepath server sys whoami"
X
Xecho 'This interactive command will build shell files named doit.root,'
Xecho 'doit.bin, doit.news, and again.root to do all the work.  It will not'
Xecho 'actually do anything itself, so feel free to abort and start again.'
Xecho
Xecho 'You probably need your system manuals handy.'
Xecho
Xecho 'When a question is asked in the form "How are you [okay]? ", the'
Xecho 'answer in brackets is what you will get if you just hit RETURN.'
X
Xchmod +x query			# just in case
Xif test " `./query hi | wc -c`" -ne 2
Xthen
X	echo 'The "query" utility that this command needs does not seem to'
X	echo 'be working properly.  It is supposed to work like "echo"'
X	echo 'except not produce a newline at the end.  You will have to fix'
X	echo 'it (it is a shell file).  (Most versions of "echo" have a way'
X	echo 'to suppress the newline, but unfortunately there are at least'
X	echo 'two different incompatible ways.)'
X	exit 1
Xfi
X
Xecho
Xecho 'C News wants to keep most of its files under a uid which preferably'
Xecho 'should be all its own.  Its programs, however, can and probably should'
Xecho 'be owned by another user, typically the same one who owns most of the'
Xecho 'rest of the system.'
X./query 'What user id should be used for news files [news]? '
Xread newsuid
Xcase "$newsuid" in
X'')	newsuid=news	;;
Xesac
X./query 'What group id should be used for news files [news]? '
Xread newsgid
Xcase "$newsgid" in
X'')	newsgid=news	;;
Xesac
X./query 'What user id should be used for news programs [bin]? '
Xread binuid
Xcase "$binuid" in
X'')	binuid=bin	;;
Xesac
X./query 'What group id should be used for news programs [bin]? '
Xread bingid
Xcase "$bingid" in
X'')	bingid=bin	;;
Xesac
X
Xanswer=
Xif test -d /var -a -d /usr/share
Xthen
X	echo
X	echo 'It would appear that your system is among the victims of the'
X	echo '4.4BSD / SVR4 directory reorganization, with (e.g.) shared'
X	./query 'data in /usr/share.  Is this correct [yes]? '
X	read answer
X	case "$answer" in
X	y*|Y*|'')	answer=y	;;
X	esac
Xfi
Xif test " $answer" = " y"
Xthen
X	echo 'This will affect where C News directories go.  We recommend'
X	echo 'making the directories wherever they have to go and then making'
X	echo 'symbolic links to them under the standard names that are used'
X	echo 'as defaults in the following questions.  Should such links'
X	./query 'be made [yes]? '
X	read makelinks
X	case "$makelinks" in
X	y*|Y*|'')	makelinks=y	;;
X	esac
X	echo 'Our 4.4ish friends suggest putting articles in /var/spool/news'
X	echo 'and control files in /usr/share/news, with programs left where'
X	echo 'they are in /usr/lib/newsbin.'
Xfi
X
Xneedsubst=
Xecho
Xecho 'C News lives primarily under three directories:  one for articles (and'
Xecho 'incoming and outgoing spooling), one for control files, and one for'
Xecho 'programs.'
X./query 'Where should articles live [/usr/spool/news]? '
Xread newsarts
Xcase "$newsarts" in
X'')	newsarts=/usr/spool/news	;;
X*)	needsubst=y	;;
Xesac
X./query 'Where should control files live [/usr/lib/news]? '
Xread newsctl
Xcase "$newsctl" in
X'')	newsctl=/usr/lib/news	;;
X*)	needsubst=y	;;
Xesac
X./query 'Where should programs live [/usr/lib/newsbin]? '
Xread newsbin
Xcase "$newsbin" in
X'')	newsbin=/usr/lib/newsbin	;;
X*)	needsubst=y	;;
Xesac
Xif test " $makelinks" = " y"
Xthen
X	realarts="$newsarts"
X	realctl="$newsctl"
X	realbin="$newsbin"
X	newsarts="/usr/spool/news"
X	newsctl="/usr/lib/news"
X	newsbin="/usr/lib/newsbin"
Xfi
X
Xecho
Xecho 'C News by default assumes that all normal Unix programs can be found'
Xecho 'in /bin or /usr/bin.  This is naive, especially on Berkeley-derived'
Xecho 'systems where some standard programs inexplicably moved to /usr/ucb.'
Xnewspath='/bin:/usr/bin'
Xif test '(' ! -f /bin/wc -a ! -f /usr/bin/wc ')' -o \
X			'(' ! -f /bin/hostname -a ! -f /usr/bin/hostname -a \
X						-f /usr/ucb/hostname ')'
Xthen
X	echo 'It would appear that some standard programs live in /usr/ucb'
X	./query 'on your system.  Is that right [yes]? '
X	read ucb
Xelse
X	echo 'It would appear that /usr/ucb does not exist or is not needed'
X	./query 'for normal operation on your system.  Is that right [yes]? '
X	read ucb
X	case "$ucb" in
X	y*|Y*|'')	ucb=no	;;
X	n*|N*)		ucb=yes	;;
X	esac
Xfi
Xcase "$ucb" in
Xy*|Y*|'')	./query 'Should /usr/ucb go before or after /bin and /usr/bin [after]? '
X		read answer
X		case "$answer" in
X		a*|A*|'')	newspath="$newspath:/usr/ucb"	;;
X		*)		newspath="/usr/ucb:$newspath"	;;
X		esac
X		needsubst=y
X		;;
Xesac
Xwhile true
Xdo
X	echo 'Is there any other directory which should be searched to find'
X	./query 'standard programs on your system [no]? '
X	read answer
X	case "$answer" in
X	n*|N*|'')	break	;;
X	*)		needsubst=y	;;
X	esac
X	./query 'What is the full name of the directory? '
X	read dir
X	./query 'Should it go before or after the others [after]? '
X	read answer
X	case "$answer" in
X	a*|A*|'')	newspath="$newspath:$dir"	;;
X	*)		newspath="$dir:$newspath"	;;
X	esac
Xdone
X
Xecho
Xecho 'C News normally uses a umask of 002, turning off only the others-write'
Xecho 'bit in the permissions of files used.  (The correspondence between bits'
Xecho 'and number is:  rwx = 421, so turning off group-write bits and all'
Xecho 'others-access bits would be a mask of 027, for example.)  Usually'
Xecho 'a umask of 002 or 022 is appropriate.'
X./query 'What umask should C News use [002]? '
Xread newsumask
Xcase "$newsumask" in
X'')	newsumask=002	;;
X*)	needsubst=y	;;
Xesac
X
Xecho
Xecho 'C News wants to mail some forms of trouble reports to an administrator.'
Xecho 'You probably want to make this a system mailbox, rather than that of a'
Xecho "specific user, so you won't have to change the software when you get a"
Xecho 'new administrator.'
X./query 'Where should C News mail trouble reports [usenet]? '
Xread newsmaster
Xcase "$newsmaster" in
X'')	newsmaster=usenet	;;
X*)	needsubst=y	;;
Xesac
X
Xecho
Xecho 'The shell files that are everywhere in C News want to pick up their'
Xecho 'configuration parameters (mostly, the last few questions you have'
Xecho 'answered) from a file at a known location; this is very hard to avoid'
Xecho 'unless you play tricks with environment variables (see documentation).'
Xecho 'Where should the shell configuration file be'
X./query "located [$newsctl/bin/config]? "
Xread newsconfig
Xcase "$newsconfig" in
X'')	newsconfig=$newsctl/bin/config	;;
X*)	needsubst=y	;;
Xesac
X
Xecho
X./query 'What is the full pathname of the chown command [/etc/chown]? '
Xread chown
Xcase "$chown" in
X'')	chown=/etc/chown	;;
Xesac
Xecho "Can I say '$chown $newsuid.$newsgid file' to change both the user id"
X./query 'and group id of a file [yes]? '
Xread chboth
Xcase "$chboth" in
Xy*|Y*|'')	chboth=y	;;
Xesac
Xif test " $chboth" != " y"
Xthen
X	./query 'Is there a chgrp command to change the group of a file [yes]? '
X	read chgrp
X	case "$chgrp" in
X	n*|N*)	echo 'You will need to edit doit.root by hand before running it.'
X		echo "It will assume that 'chown $newsuid.$newsgid' works."
X		chboth=y
X		;;
X	*)	./query 'What is the full pathname of the chgrp command [/etc/chgrp]? '
X		read chgrp
X		case "$chgrp" in
X		'')	chgrp=/etc/chgrp	;;
X		esac
X		;;
X	esac
Xfi
X
Xecho
Xecho 'building doit.root...'
X>doit.root
Xif test ! -w doit.root
Xthen
X	echo 'It appears that I cannot create doit.root.  Aborting.'
X	exit 1
Xfi
X(
X	echo "umask $newsumask"
X	echo 'set -x'
X	echo ": making directories..."
X	if test " $makelinks" = " y"
X	then
X		echo "mkdir $realarts $realctl $realbin"
X		if test " $realarts" != " $newsarts"
X		then
X			echo "ln -s $realarts $newsarts"
X		fi
X		if test " $realctl" != " $newsctl"
X		then
X			echo "ln -s $realctl $newsctl"
X		fi
X		if test " $realbin" != " $newsbin"
X		then
X			echo "ln -s $realbin $newsbin"
X		fi
X	fi
X	n="$newsarts $newsarts/in.coming $newsarts/in.coming/bad"
X	n="$n $newsarts/out.going $newsctl $newsctl/bin"
X	b="$newsbin"
X	echo "for d in $n $b"
X	echo "do"
X	echo "	if test ! -d \$d"
X	echo "	then"
X	echo "		mkdir \$d"
X	echo "	fi"
X	echo "done"
X	if test " $chboth" = " y"
X	then
X		echo "$chown $newsuid.$newsgid $n"
X		echo "$chown $binuid.$bingid $b"
X	else
X		echo "$chown $newsuid $n"
X		echo "$chgrp $newsgid $n"
X		echo "$chown $binuid $b"
X		echo "$chgrp $bingid $b"
X	fi
X	echo ": done"
X) >>doit.root
Xecho 'done'
X
Xecho
Xecho 'C News has libraries for several kinds of Unix:'
Xecho '	bsd42	4.2BSD and successors'
Xecho '	usg	AT&T System V'
Xecho '	v7	Version 7 (4.1BSD is pretty close, ditto Xenix)'
Xecho '	v8	Version 8, aka Eighth Edition'
Xwhile true
Xdo
X	./query 'Which best describes your system [v7]? '
X	read unixkind
X	if test " $unixkind" = " "
X	then
X		unixkind=v7
X	fi
X	if test -d ../lib$unixkind
X	then
X		break
X	fi
X	echo 'Sorry, no such library is supplied.'
Xdone
X
Xecho
Xecho 'C News has libraries for small address spaces (16 bits) and big'
Xecho 'ones (preferably 32 bits, but anything rather bigger than 16).'
Xwhile true
Xdo
X	./query 'Which best describes your system [big]? '
X	read addrsize
X	if test " $addrsize" = " "
X	then
X		addrsize=big
X	fi
X	if test -d ../lib$addrsize
X	then
X		break
X	fi
X	echo 'Sorry, no such library is supplied.'
Xdone
X
Xecho
Xecho 'Systems vary in whether certain library functions and system calls'
Xecho 'are present.  C News contains reasonably-portable versions of the'
Xecho 'possibly-missing library functions, and fake versions of the'
Xecho 'possibly-missing system calls, but it needs to know which are missing.'
Xfake=
Xfor fn in $mightfake
Xdo
X	./query "Does your system have  $fn() [yes]? "
X	read answer
X	case "$answer" in
X	y*|Y*|'')	;;
X	*)	fake="$fake $fn.o"	;;
X	esac
Xdone
X./query "Does your system have a library function ldiv() as in ANSI C? [no]? "
Xread answer
Xcase "$answer" in
Xn*|N*|'')	fake="$fake ldiv.o"	;;
Xesac
X./query 'Does your system have the "dbm" library [yes]? '
Xread answer
Xcase "$answer" in
Xy*|Y*|'')	./query 'What is the compile option needed to get it [-ldbm]? '
X		read answer
X		case "$answer" in
X		'')	answer=-ldbm	;;
X		esac
X		dbm="DBM=$answer"
X		;;
X*)	fake="$fake dbm.o"
X	dbm='DBM='
X	echo "Okay, we'll fake it for you.  You might want to look at"
X	echo "contrib/dbz, which is a probably-superior fake that we have"
X	echo "not examined closely."
X	;;
Xesac
X
Xecho
Xecho 'Many systems, notably older ones, have implementations of the Standard'
Xecho 'I/O library ("stdio") in which fgets, fputs, fread, and fwrite, although'
Xecho 'correct, are quite slow.  We supply versions of these functions which'
Xecho 'are faster than those in any stdio we know; they are compatible with'
Xecho 'most AT&T-derived stdios.  If they work on your system, they are a'
Xecho 'major performance win for C News.  There is a simple compatibility'
Xecho 'check run after the library is built.  The only system we know of'
Xecho 'where the test works but the functions do not is SunOS 4.0.'
X./query 'Do you want to use our fast stdio library [yes]? '
Xread libstdio
Xcase "$libstdio" in
Xy*|Y*|'')	libstdio=libstdio	;;
X*)		libstdio=		;;
Xesac
X
Xif test " $dbm" != " DBM="
Xthen
X	echo
X	echo 'Does the store() function in your dbm library return a'
X	./query 'value (some old ones did not) [yes]? '
X	read storeval
X	case "$storeval" in
X	y*|Y*|'')	storeval=y	;;
X	esac
Xelse
X	storeval=y
Xfi
X
Xfound=
Xfor f in $fake dummy
Xdo
X	if test " $f" = " index.o"
X	then
X		found=y
X	fi
Xdone
Xif test " $found" = " "
Xthen
X	echo
X	echo 'A well-tuned index() function customized to a particular machine'
X	echo 'is usually faster than portable C.  Is your index() function'
X	./query 'indeed fast (okay to guess) [yes]? '
X	read fastindex
X	case "$fastindex" in
X	y*|Y*|'')	fastindex=y	;;
X	esac
Xfi
X
Xecho
Xecho 'Modern Unixes can generally use the setuid() system call to set the'
Xecho 'real and effective user ids to the current effective user id.  In'
Xecho 'old Unixes, only "root" can change the real user id.  This causes'
Xecho 'various problems for C News.  C News provides a small program named'
Xecho '"setnewsids" to run setuserid-root; all it does is change user and'
Xecho 'group ids and then execute C News "relaynews".  It is needed only in'
Xecho 'systems that are too old to do setuid(geteuid()).  Relaynews invokes'
Xecho 'it automatically if needed (and it then invokes relaynews in return).'
X./query 'Can this system do setuid(geteuid()) [yes]? '
Xread sete
Xcase "$sete" in
Xy*|Y*|'')	sete=y	;;
Xesac
X
Xecho
Xecho 'Some systems have header files that others lack, and C News'
Xecho 'is prepared to fake missing ones.'
Xfakehdrs=
Xfor h in $mightfakehdrs
Xdo
X	./query "Does your system have an ANSI-C-conforming <$h> [yes]? "
X	read answer
X	case "$answer" in
X	y*|Y*|'')	;;
X	*)	fakehdrs="$fakehdrs ../include/$h"	;;
X	esac
Xdone
X./query "Does your system have <sys/timeb.h> [yes]? "
Xread answer
Xcase "$answer" in
Xn*|N*)	fakehdrs="$fakehdrs ../include/sys/timeb.h"	;;
Xesac
X
Xecho
Xecho 'Some old systems think sprintf() returns a value of type "char *".'
Xecho 'The modern standard is that it returns "int".  Does your sprintf()'
X./query 'return "char *" [no]? '
Xread answer
Xcase "$answer" in
Xn*|N*|'')	;;
X*)		echo 'You may have to hand-edit our "libc.h" include file if'
X		echo 'your compiler objects to us declaring sprintf() to'
X		echo 'return "int".  (This will usually happen only if your'
X		echo '<stdio.h> header file declares sprintf() -- some do,'
X		echo 'some do not.)  If you do need to edit "libc.h", look'
X		echo 'for the definition of "sprvalue".'
X		;;
Xesac
X
Xecho
Xecho 'Very old Unix systems needed the order of object modules in a library'
Xecho 'chosen very carefully.  V7 introduced "ranlib" which removes the need'
Xecho 'for this.  Recent System Vs have had the same facility built into "ar"'
Xecho '(look for "symdef" in the "ar" manual page) so "ranlib" is not needed.'
X./query "Does your system have a 'ranlib' command [no]? "
Xread ranlib
Xcase "$ranlib" in
Xn*|N*|'')
X	./query 'Does your "ar" have a "symdef" feature [yes]? '
X	read answer
X	case "$answer" in
X	n*|N*)	echo 'You have trouble and may need to modify doit.bin before'
X		echo 'running it.  It will assume "ranlib" is present.'
X		ranlib=y
X		;;
X	*)	ranlib=
X		;;
X	esac
X	;;
X*)	ranlib=y
X	;;
Xesac
X
Xecho
Xecho 'Historically the C compiler is named "cc", but this is not true on'
Xecho 'some systems, and on others there are several different C compilers.'
X./query 'What is the name of the C compiler to be used [cc]? '
Xread cc
Xcase "$cc" in
X'')	cc=	;;
X*)	cc="CC=$cc"	;;
Xesac
X
Xecho
Xecho 'Historically the only normal compilation option needed for most'
Xecho 'programs is -O, but again compilers, especially newer ones, differ.'
X./query "What options should be given to the compiler [-O]? "
Xread copts
Xcase "$copts" in
X'')	copts=	;;
X*)	copts="COPTS='$copts'"	;;
Xesac
X
Xecho
X./query 'Does your system have a "hostname" command [yes]? '
Xread hostname
Xcase "$hostname" in
Xy*|Y*|'')	hostname=y	;;
X*)	./query 'Does it have a "uname" command with a "-n" option [yes]? '
X	read hostname
X	case "$hostname" in
X	y*|Y*|'')	hostname=u	;;
X	*)		hostname=	;;
X	esac
X	;;
Xesac
X
Xecho
Xecho 'C News tries to limit the backlog of news batches spooled up for'
Xecho 'transmission to a site, to control use of disk space.  To do this,'
Xecho 'it needs to be able to determine the length of the queue of news'
Xecho 'batches for a particular site.  This is UUCP-version-dependent.'
Xecho 'There is a good chance that you will have to customize the "queuelen"'
Xecho 'program.  C News knows about several versions:'
Xecho '	hdb	Honey DanBer, aka Basic Networking Utilities'
Xecho '	sub	old uucp with subdirectories (e.g. /usr/spool/uucp/C.)'
Xecho "	null	don't run uucp or don't care about queue lengths"
Xwhile true
Xdo
X	./query 'Which one is most appropriate [hdb]? '
X	read uucptype
X	case "$uucptype" in
X	'')	uucptype=hdb	;;
X	sub)	echo 'Beware -- test "queuelen" to make sure it works.'	;;
X	esac
X	case "$uucptype" in
X	hdb|sub|null)	break	;;
X	esac
X	echo 'Sorry, no such choice is available.'
Xdone
X
Xecho
Xecho 'C News often wants to ask how much disk space is available.  The'
Xecho 'format of output from the "df" command unfortunately varies a lot.'
Xecho 'C News knows about several different versions:'
Xecho '	bsd	4.2BSD and later'
Xecho '	sysv	most System Vs'
Xecho '	sgi	Silicon Graphics Iris systems'
Xecho '	v7	plain old style:  no headers or fluff, just name and number'
Xecho "	null	don't know or don't care how much space is available"
Xwhile true
Xdo
X	./query 'Which one is most appropriate [bsd]? '
X	read dftype
X	case "$dftype" in
X	'')	dftype=bsd	;;
X	sysv)	echo 'Beware -- test "spacefor" to make sure it works.'
X		echo 'System V "df" formats vary widely, indeed wildly.'
X		echo '"Consider it standard".  Sure.'
X		;;
X	esac
X	case "$dftype" in
X	bsd|sysv|sgi|v7|null)	break	;;
X	esac
X	echo 'Sorry, no such choice is available.'
Xdone
X
Xecho
Xecho 'Some "df" commands, especially on old systems, must be given the'
Xecho 'name of a device.  Modern ones can be given any directory name and'
Xecho 'the system handles the details of figuring out what device is meant.'
X./query 'Does your "df" accept a directory name as an argument [yes]? '
Xread answer
Xcase "$answer" in
Xn*|N*)	echo 'You are going to have to customize "spacefor" for your system.'
X	echo 'It will be generated assuming that directory names do work.'
X	;;
Xesac
X
Xecho
X./query 'Are you planning to use expire to archive news on disk [no]? '
Xread answer
Xcase "$answer" in
Xy*|Y*)	echo 'You probably want to customize the "archive" entry in'
X	echo '"spacefor" so it knows where your archiving is done and how'
X	echo 'much space you want free there.'
X	;;
Xesac
X
Xecho
X./query 'Are you particularly short of disk space [no]? '
Xread answer
Xcase "$answer" in
Xy*|Y*)	echo 'You may want to reconsider whether you really want to get'
X	echo 'news, unless you are getting only a very small set of groups.'
X	echo 'In any case, you definitely want to inspect "spacefor" and'
X	echo 'change some of its thresholds for free space.'
X	;;
X*)	echo 'You may want to inspect "spacefor" to make sure its defaults'
X	echo 'for things like desired free space are appropriate for your'
X	echo 'system, although the defaults are fairly conservative.'
X	;;
Xesac
X
Xecho
Xecho 'Are you running C News on a group of machines hooked together with'
X./query 'NFS, with articles filed on only one "server" machine [no]? '
Xread answer
Xserver=
Xcase "$answer" in
Xy*|Y*)	if test " $hostname" = " "
X	then
X		echo 'With a server but no "hostname" command, you will have'
X		echo 'problems and will probably have to tinker by hand to'
X		echo 'get a fake "hostname" that does the right thing.  The'
X		echo 'generated files will assume you have "hostname".'
X		hostname=y
X	fi
X	if test " $hostname" = " u"
X	then
X		./query 'What is the "uname -n" name of the server? '
X	else
X		./query 'What is the "hostname" name of the server? '
X	fi
X	read server
X	;;
Xesac
X
Xecho
Xecho 'Several programs need to know an overall name for the system news is'
Xecho 'being run on, where "system" may include multiple machines if they'
Xecho 'share a common set of control files and articles; this is used in'
Xecho 'article headers and related places.  For uucp sites, this usually'
Xecho 'should be the uucp name.  What is the name of the overall system'
X./query 'for news purposes? '
Xread whoami
X
Xecho
Xecho 'The "From:" lines of news postings, on the other hand, should carry'
Xecho 'a mailing address, which in particular should be a domain address'
Xecho 'for sites that have one.  What is the mailing-address name of this'
X./query "system, preferably a domain address [$whoami.uucp]? "
Xread mailname
Xcase "$mailname" in
X'')	mailname="$whoami.uucp"	;;
Xesac
X
Xecho
Xecho 'What is the name of the organization, for insertion into articles'
X./query 'posted from here? '
Xread organization
X
Xecho
Xecho 'What user other than root (if any) should be allowed to create'
X./query 'new news groups [no such user]? '
Xread allowed
X
Xecho
Xecho 'Manual pages are normally stored in a tree structure under /usr/man.'
Xecho 'Local practices vary a great deal, however, and System V has also'
Xecho 'introduced some bizarre distortions into this once-simple structure.'
X./query 'What is the top-level manual-page directory [/usr/man]? '
Xread manpages
Xcase "$manpages" in
X'')	manpages=/usr/man	;;
Xesac
X
Xecho
Xchaps='1 5 8'
Xecho 'C News adds manual pages to chapters 1 (programs), 5 (files), and'
Xecho '8 (administrative programs).  These chapter numbers have changed'
Xecho 'in some variants of Unix.  Also, originally pages from chapter 5 (for'
Xecho "example) were stored in $manpages/man5.  This has also changed in"
X./query 'some variants.  Has your system made either of these changes [no]? '
Xread answer
Xcase "$answer" in
Xy*|Y*)	echo 'You will have to hand-edit the last few lines of doit.bin'
X	echo 'to install the manual pages where they belong on your system.'
X	;;
Xesac
X
Xecho
Xecho 'The "rnews" and "cunbatch" commands (which are identical, the latter'
Xecho 'being purely for backward compatibility with seriously-old systems)'
Xecho 'have to be installed somewhere where uucp can find them to execute'
Xecho 'them.  It is not normally necessary for users to be able to run'
Xecho 'them, so they need not go in the directories searched for normal'
Xecho 'commands... although uucp often searches only those directories.'
X./query 'What directory should "rnews" and "cunbatch" go in [/bin]? '
Xread rbin
Xcase "$rbin" in
X'')	rbin=/bin	;;
Xesac
X
Xecho
Xecho 'The "inews", "postnews", "readnews", and "checknews" commands should'
Xecho 'go in one of the directories searched for normal commands, so users'
Xecho 'can run them without special arrangements.  What directory should'
X./query 'these commands go in [/bin]? '
Xread bin
Xcase "$bin" in
X'')	bin=/bin	;;
Xesac
X
Xecho
Xecho 'For replies to control messages, C News invokes "mail" (typically'
Xecho '/bin/mail unless you make special arrangements) with either an'
Xecho 'Internet-style "@" address or a uucp-style "!" address.  Internet'
Xecho 'style is probably better... if your mailer supports it at all.'
X./query 'Will "mail" handle "@" addresses [no]? '
Xread atok
Xcase "$atok" in
Xy*|Y*)	atok=y	;;
X*)	atok=	;;
Xesac
X
Xecho
Xecho 'Postnews can supply a default newsgroup, to assist naive users in'
Xecho 'getting the group right for simple postings.  What should the default'
X./query 'newsgroup for postnews be [no default]? '
Xread postdefltgroup
X
Xecho
Xecho 'Postnews can supply a default distribution, to restrict news to a'
Xecho 'local area unless the user specifically changes it.  This is probably'
Xecho 'a good idea.  What should the default distribution for postnews'
X./query 'be [world]? '
Xread postdefltdist
X
Xecho
Xecho 'building doit.bin...'
X>doit.bin
Xif test ! -w doit.bin
Xthen
X	echo 'It appears that I cannot create doit.bin.  Aborting.'
X	exit 1
Xfi
X(
X	echo "umask $newsumask"
X	echo "set -x"
X	echo ': setting up for substitutions'
X	echo "cat >nsubstitutions <<'!'"
X	cat <<!
X# master substitutions file
X#
X# where the programs live (see also NEWSCONFIG)
XNEWSBIN		$newsbin
X# where the control files live
XNEWSCTL		$newsctl
X# where the articles live
XNEWSARTS	$newsarts
X# what PATH should be used for finding normal programs
X# (things not in NEWSBIN, that is)
XNEWSPATH	$newspath
X# the umask under which files should be created
XNEWSUMASK	$newsumask
X# who to send mail to when there is trouble
XNEWSMASTER	$newsmaster
X# configuration file that lets shell files pick up all of this
XNEWSCONFIG	$newsconfig
X!
X	echo '!'
X	echo 'if test -r substitutions && cmp -s nsubstitutions substitutions'
X	echo 'then'
X	echo '	rm nsubstitutions'
X	echo 'else'
X	echo '	mv nsubstitutions substitutions'
X	echo 'fi'
X	echo ': done'
X	echo ': building headers'
X	echo 'cd ..'
X	echo 'if test ! -d include'
X	echo 'then'
X	echo '	mkdir include include/sys'
X	echo 'fi'
X	echo 'cd h'
X	echo 'rm -f nnewshsed'
X	if test " $fastindex" != " y"
X	then
X		echo 'echo "/FASTINDEX.*qqq/s;^;/* ;" >>nnewshsed'
X	fi
X	if test " $storeval" = " y"
X	then
X		echo 'echo "/NOSTOREVAL.*qqq/s;^;/* ;" >>nnewshsed'
X	fi
X	if test " $addrsize" = " big"
X	then
X		echo 'echo "/SMALLMEM.*qqq/s;^;/* ;" >>nnewshsed'
X	fi
X	echo 'if test -f newshsed && cmp -s nnewshsed newshsed'
X	echo 'then'
X	echo '	rm -f nnewshsed'
X	echo 'else'
X	echo '	mv nnewshsed newshsed'
X	echo 'fi'
X	echo 'make all || exit 1'
X	echo 'cd ../hfake'
X	echo "ed - Makefile <<'!'"
X	echo "/NEEDED =/s~.*~NEEDED = $fakehdrs~"
X	echo "w"
X	echo "!"
X	echo "make all || exit 1"
X	echo ": done"
X	echo ": making substitutions..."
X	echo "cd ../conf"
X	if test " $needsubst" = " y"
X	then
X		echo "make substs"
X	else
X		echo ": make substs		not necessary, defaults used"
X	fi
X	echo ": done"
X	echo ": making spacefor, queuelen, etc...."
X	echo "rm -f spacefor queuelen hostname setnewsids"
X	echo "make spacefor.$dftype"
X	echo "cp spacefor.$dftype spacefor"
X	echo "make queuelen.$uucptype"
X	echo "cp queuelen.$uucptype queuelen"
X	if test " $hostname" = " y"
X	then
X		echo "# ( echo '#! /bin/sh' ; echo 'echo $whoami' ) >hostname"
X	elif test " $hostname" = " u"
X	then
X		echo "( echo '#! /bin/sh' ; echo 'uname -n' ) >hostname"
X	else
X		echo "( echo '#! /bin/sh' ; echo 'echo $whoami' ) >hostname"
X	fi
X	echo ': done'
X	echo ': making library...'
X	if test " $ranlib" = " y"
X	then
X		echo "touch ../ranlibed"
X		echo "sleep 2"
X	fi
X	echo "for dir in lib$unixkind lib$addrsize libc libcnews $libstdio"
X	echo "do"
X	echo "	cd ../\$dir"
X	echo "	make u $cc $copts || exit 1"
X	echo "done"
X	echo "cd ../libfake"
X	echo "ed - Makefile <<'!'"
X	echo "/NEEDED =/s/.*/NEEDED = $fake/"
X	echo "w"
X	echo "!"
X	echo "make u $cc $copts || exit 1"
X	echo "cd ../conf"
X	if test " $ranlib" = " y"
X	then
X		echo "make ../ranlibed"
X	fi
X	echo ': library done'
X	if test " $libstdio" != " "
X	then
X		echo ': testing libstdio'
X		echo 'cd ../libstdio'
X		echo "make trials $cc $copts || exit 1"
X		echo ': done'
X	fi
X	echo ': building programs'
X	echo 'cd ../conf'
X	if test " $sete" != " y"
X	then
X		echo "make setnewsids NEWSUSER=$newsuid NEWSGROUP=$newsgid $cc $copts"
X	fi
X	echo "for dir in $pgmdirs"
X	echo "do"
X	echo "	cd ../\$dir"
X	echo "	make all $dbm $cc $copts"
X	echo "done"
X	echo ": done"
X	echo ": building prototype control files"
X	echo "cd ../conf"
X	echo "rm -f $ctlf"
X	echo "cp config.proto config"
X	echo "echo '$mailname' >mailname"
X	echo "cat <<'!' >organization"
X	echo "$organization"
X	echo '!'
X	if test " $allowed" != " "
X	then
X		echo "echo '$allowed' >allowed"
X	fi
X	if test " $server" != " "
X	then
X		echo "echo '$server' >server"
X	fi
X	if test " $atok" != " y"
X	then
X		echo echo "'replies must use "!" addresses' >replyusepath"
X	fi
X	if test " $postdefltdist" != " "
X	then
X		echo "echo '$postdefltdist' >>postdefltdist"
X	fi
X	if test " $postdefltgroup" != " "
X	then
X		echo "echo '$postdefltgroup' >>postdefltgroup"
X	fi
X	echo "echo '$whoami' >whoami"
X	echo "echo 'general 00000 00000 y' >active"
X	echo "echo 'news.announce.newusers 00000 00000 y' >>active"
X	echo ">errlog"
X	echo ">history"
X	echo ">history.pag"
X	echo ">history.dir"
X	echo "echo 'general	general local news' >localgroups"
X	echo ">log"
X	echo "echo 'all	uunet!%s' >mailpaths"	# crude
X	echo "cp sys.proto sys"
X	echo "cat >cron <<'!'"
X	cat <<!
X15 *	1-31 *	0-6	su news -c '$newsbin/input/newsrun'
X30 8	1-31 *	1-5	su news -c '$newsbin/input/newsrunning off'
X00 17	1-31 *	1-5	su news -c '$newsbin/input/newsrunning on'
X40 *	1-31 *	0-6	su news -c '$newsbin/batch/sendbatches'
X59 0	1-31 *	0-6	su news -c '$newsbin/expire/doexpire'
X45 3	1-31 *	0-6	su news -c '$newsbin/expire/superkludge comp.mail.maps'
X10 8	1-31 *	0-6	su news -c '$newsbin/maint/newsdaily'
X00 5,13,21	1-31 *	0-6	su news -c '$newsbin/maint/newswatch'
X!
X	echo "!"
X	echo "echo 'su news -c $newsbin/maint/newsboot' >rc"
X	echo ": done"
X	echo ': installing programs'
X	echo "for dir in $pgmdirs"
X	echo "do"
X	echo "	cd ../\$dir"
X	echo "	make bininstall BIN=$bin RBIN=$rbin $dbm"
X	echo "done"
X	echo ": done"
X	echo ': installing manual pages'
X	echo 'cd ../man'
X	for chap in $chaps
X	do
X		for f in `ls ../man | egrep "\.$chap\$"`
X		do
X			echo "cp $f $manpages/man$chap/$f"
X		done
X	done
X	echo ': done'
X) >>doit.bin
Xecho 'done'
X
Xecho
Xecho 'building doit.news...'
X>doit.news
Xif test ! -w doit.news
Xthen
X	echo 'It appears that I cannot create doit.news.  Aborting.'
X	exit 1
Xfi
X(
X	echo "umask $newsumask"
X	echo 'set -x'
X	echo ': installing programs'
X	echo "for dir in $pgmdirs"
X	echo "do"
X	echo "	cd ../\$dir"
X	echo "	make newsinstall BIN=$bin RBIN=$rbin $dbm"
X	echo "done"
X	echo ": done"
X	echo ": installing control files"
X	echo "cd ../conf"
X	echo "for f in $ctlf"
X	echo "do"
X	echo "	if test -r $newsctl/\$f"
X	echo "	then"
X	echo "		echo \"$newsctl/\$f already exists; left unchanged\""
X	echo "	elif test ! -r \$f"
X	echo "	then"
X	echo "		: \"\$f\" not wanted"
X	echo "	else"
X	echo "		cp \$f $newsctl/\$f"
X	echo "	fi"
X	echo "done"
X	echo "if test -r $newsconfig"
X	echo "then"
X	echo "	echo '$newsconfig already exists; left unchanged'"
X	echo "else"
X	echo "	cp config $newsconfig"
X	echo "	chmod +x $newsconfig"
X	echo "fi"
X	echo ": It is virtually certain that some of those control files"
X	echo ": need modifying to suit your system.  In particular, you"
X	echo ": should pick up a current 'active' file from your neighbors."
X	echo ": done"
X) >>doit.news
Xecho 'done'
X
Xecho
Xecho 'building again.root...'
X>again.root
Xif test ! -w again.root
Xthen
X	echo 'It appears that I cannot create again.root.  Aborting.'
X	exit 1
Xfi
X(
X	echo "umask $newsumask"
X	echo 'set -x'
X	if test " $sete" != " y"
X	then
X		echo ": installing setnewsids"
X		echo "cp setnewsids $newsctl"
X		echo "$chown root $newsctl/setnewsids"
X		echo "chmod u+s $newsctl/setnewsids"
X		echo ": done"
X	fi
X	echo ": setting uids for setuid programs..."
X	them="$newsbin/input/newsspool $newsbin/relay/relaynews"
X	if test " $chboth" = " y"
X	then
X		echo "$chown $newsuid.$newsgid $them"
X	else
X		echo "$chown $newsuid $them"
X		echo "$chgrp $newsgid $them"
X	fi
X	echo "chmod u+s,g+s $them"
X	echo ": done"
X) >>again.root
Xecho 'done'
X
Xecho
Xchmod +x doit.root doit.bin doit.news again.root
Xecho 'You should now run doit.root as root (or as somebody with the power'
Xecho "to create $newsctl, $newsarts, and $newsbin"
Xecho "and run chown), doit.bin as $binuid, doit.news as $newsuid, and"
Xecho "again.root as root (or as somebody with the power to run chown),"
Xecho 'in that order.  Finally, you will want to add the contents of'
Xecho "'cron', or something similar, to your cron's work-to-be-done"
Xecho "file(s), and the contents of 'rc', or something similar, to"
Xecho '/etc/rc or whatever your system executes when booting.'
Xecho
Xecho '"make gclean" will clean up everything afterwards.  "make lclean"'
Xecho 'does a less drastic cleanup affecting only the library directories.'
Xecho '"make spotless" does "make gclean" and also removes the doit files.'
Xecho
Xecho 'Good luck and happy news reading.'
!
echo 'conf/setnewsids.c':
sed 's/^X//' >'conf/setnewsids.c' <<'!'
X/*
X * setnewsids - sets ids to news/news, execs relay/relaynews.  Should be setuid-root.
X *	also add NEWSPERMS to the environment.
X */
X
X#include <stdio.h>
X#include <errno.h>
X#include <pwd.h>
X#include <grp.h>
X#include <sys/types.h>
X
X#include "news.h"
X#include "libc.h"
X#include "config.h"
X
X#ifndef RELAYNEWS
X#define RELAYNEWS binfile("relay/relaynews")
X#endif
X#ifndef NEWSUSER
X#define NEWSUSER "news"
X#endif
X#ifndef NEWSGROUP
X#define NEWSGROUP "news"
X#endif
X
Xchar *progname;
X
Xstatic int userealids = NO;
X
X/*
X * main - parse arguments and handle options
X */
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	extern int optind;
X	extern char *optarg;
X
X	progname = argv[0];
X
X	/* setuid daemon prelude; various precautions */
X	(void) umask(2);	/* undo silly umasks, ignore newsumask() */
X	(void) alarm(0);	/* cancel any pending alarm */
X	/*
X	 * Reset certain environment variables to sane values.
X	 */
X	if (putenv("PATH=/bin:/usr/bin") ||
X	    putenv("IFS= \t\n"))
X		exit(1);
X	closeall(1);		/* closes all but std descriptors */
X	stdfdopen();		/* ensure standard descriptors are open */
X
X	setids();		/* change of real and effective ids */
X	/* we are now running as news, so you can all relax */
X
X	if (putenv("NEWSPERMS="))	/* avoid loops with this marker */
X		exit(1);
X	execv(RELAYNEWS, argv);	/* re-run relaynews */
X	error("can't exec %s", RELAYNEWS);
X}
X
Xsetids()			/* change of real and effective ids */
X{
X	int newsuid = getuid(), newsgid = getgid();	/* default to real ids */
X
X	(void) ctlfile((char *)NULL);	/* trigger unprivileged(), set userealids */
X	if (!userealids) {
X		register struct passwd *pwp;
X		register struct group *grp;
X
X		pwp = getpwnam(NEWSUSER);
X		if (pwp != NULL) {
X			newsuid = pwp->pw_uid;
X			newsgid = pwp->pw_gid;
X		}
X		(void) endpwent();
X		grp = getgrnam(NEWSGROUP);
X		if (grp != NULL)
X			newsgid = grp->gr_gid;
X		(void) endgrent();
X	}
X	if (setgid(newsgid) < 0 || setuid(newsuid) < 0 ||
X	    getgid() != newsgid || getuid() != newsuid)	/* xenix workaround */
X		error("set[ug]id failed", "");
X	/* we are now running as news, so you can all relax */
X}
X
Xvoid
Xunprivileged()			/* called if NEWSARTS, NEWSCTL or NEWSBIN present */
X{
X	userealids = YES;
X}
!
echo 'conf/spacefor.proto':
sed 's/^X//' >'conf/spacefor.proto' <<'!'
X#! /bin/sh
X# spacefor - determine available disk space
X# About how many things of $1 bytes will fit in the available space for
X# stuff of type $2 ("incoming", "articles", "control", "outbound $3",
X# or "archive") without cramping things too badly?
X#
X# You'll have to change this -- your blocksize, minimum-free-desired amounts,
X# and df output format will probably differ, and you may need to name
X# your filesystems explicitly.
X
X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
X. ${NEWSCONFIG-/usr/lib/news/bin/config}
X
XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
Xumask $NEWSUMASK
X
X# punt to server if necessary
Xif test -r $NEWSCTL/server
Xthen
X	server="`cat $NEWSCTL/server`"
X	me="`hostname`"
X	if test " $server" != " $me"
X	then
X		exec rsh $server "PATH=$PATH `basename $0` $*"
X		# does not return
X	fi
Xfi
X
X# head off special case
Xcase "$1" in
X0)	echo 10000 ; exit 0 ;;
Xesac
X
X# argument to df, df units, and free space desired (in df units)
Xdfunit=1024			# default unit (bytes)
Xcase "$2" in
Xincoming)	arg="$NEWSARTS/in.coming" ; desire=5000 ;;
Xarticles)	arg="$NEWSARTS" ; desire=5000 ;;
Xcontrol)	arg="$NEWSCTL" ; desire=3000 ;;
Xoutbound)	arg="/usr/spool/uucp" ; desire=10000 ;;	# ignore $3
Xarchive)	arg="$NEWSARTS" ; desire=1 ;;		# system-specific
X*)		echo "$0: bad type argument \`$2'!!" >&2
X		exit 2 ;;
Xesac
X
X# this is set up for the stupid 4BSD df
Xdf $arg | awk "BEGIN { nf = 4 ; nr = 2 }
X	NR == nr && NF >= nf {
X		nb = (\$nf - $desire) * $dfunit / $1
X		if (nb > 10000)
X			nb = 10000	# ensure representable as integer
X		nb = int(nb)
X		if (nb <= 0)
X			print 0
X		else
X			print nb
X		exit
X	}
X	NR == nr && NF < nf {		# idiotic Berkeley continuation
X		nr += 1
X		nf -= 1
X	}"
!
echo 'notebook/dirs':
sed 's/^X//' >'notebook/dirs' <<'!'
X.DA "12 Dec 1988"
X.TL
XDirectory Layout and PATH in C News
X.AU
XHenry Spencer
X.AI
XDept. of Zoology
XUniversity of Toronto
X.SH
XIntro
X.LP
XC News is constrained by historical compatibility with B News,
Xbut we also want to provide more flexibility for local news administrators.
XAccordingly, our directory organization is a little different from that
Xof B News.
XWe also make a lot of use of subordinate programs rather than lumping
Xeverything into a few giant lumps, and this means we need a notion of
Xsearch paths.
X.LP
XSee also ``Configuration Mechanisms in C News'', which talks about how
Xto alter the defaults for these paths and such.
X.SH
XDirectory organization
X.LP
XWe retain the notion that a single directory (usually /usr/spool/news)
Xis the top of the news-article database.
XWe also use subdirectories of this directory, using names including `.' to
Xensure that they cannot collide with newsgroup names,
Xto hold incoming batches and outgoing batch control files.
XOne can debate whether this is the right place for these activities,
Xbut in practice /usr/spool/news tends to be where people want to put
Xpotentially-big traffic-handling directories,
Xand it's not worth providing for separate variation of the location.
X.LP
XWe do split the former /usr/lib/news into two, however.
XWe reserve /usr/lib/news itself for control files that are logically
Xpart of the database.
X(It would make sense to put those under some subdirectory of
X/usr/spool/news, but that would break a lot of programs that think these
Xfiles live in /usr/lib/news.)
XThe programs\(emthose which don't need to be directly executable by
Xusers or \fIuucp\fR\(emlive in /usr/lib/newsbin.
XActually, they usually live in subdirectories thereof,
Xwith each significant subsystem having its own subdirectory to keep the
Xindividual directories manageable in complexity.
XThere are occasional general-purpose utilities at the top level;
Xthere aren't enough of them to be worth a separate directory.
X.SH
XPATH
X.LP
XIn general, things are organized to permit sharing of /usr/lib/newsbin
Xamong multiple databases.
XIt doesn't make sense to share /usr/lib/news among multiple databases,
Xas much of the stuff that lives there is logically part of the database.
X.LP
XThere is a possibility that an individual database will want to override
Xspecific decisions made by the programs, i.e. will want its own version
Xof some programs.
XAccordingly, provision is made for a `bin' directory under /usr/lib/news.
XNews software should set its PATH to something on the order of
X.DS
X/usr/lib/news/bin:/usr/lib/newsbin/xxx:/usr/lib/newsbin:/bin:/usr/bin
X.DE
X(See the ``Configuration Mechanisms'' document for how this
Xshould \fIactually\fR be written, to facilitate configuration changes
Xand local customization.)
XThat is, first look in the database's bin directory for overrides,
Xthen in some subdirectory of /usr/lib/newsbin for the subsystem's
Xprograms, then in newsbin itself for news-wide utilities,
Xthen in the standard system directories for standard Unix utilities.
!
echo 'notebook/bdiffs':
sed 's/^X//' >'notebook/bdiffs' <<'!'
X.TL
XDifferences between B 2.11 news and C news
X.AU
XGeoff Collyer
X.AI
XDepartment of Statistics
XUniversity of Toronto
X.SH
XIntroduction
X.PP
XThis document attempts to describe the major
Xdifferences between
XB 2.11 news
Xand
XC news;
Xit cannot pretend to be complete.
XSince the message format of both is the one described in
XARPA Internet RFC 1036,
Xthe differences arise primarily in how the software is set up
Xand administered.
X.PP
XC news
Xwas begun before
XB 2.11 news
Xwas released,
Xand later updated to match the worthwhile changes in
XB 2.11 news.
X.SH
XDifferences in files
X.PP
X.I Locking.
XC news
Xlocks are intended to be compatible with those of
XB 2.10 news.
XC news
Xlocks out
X.I expire
Xand
X.I rnews
Xby linking to the name
X.I /usr/lib/news/LOCK
Xand repeating until successful;
Xthere is no time-out
Xsuch as the one in
XB 2.10 news,
Xso humans can lock the news system and
Xperform surgery on it with confidence.
XB 2.11 news
Xis believed to use more modern kernel locking facilities
Xsuch as
X.I flock (2)
Xand
X.I lockf (2).
XOne important difference is that
XC news's
Xlocks will work across network file systems,
Xmodulo problems caused by lock removal in
X.I /etc/rc .
X.PP
X.I "Log files."
XC news's
Xare terse.
X.PP
X.I "History file."
XC news
Xuses an extended
XB 2.10 news
Xformat:
Xthe second field consists of two subfields
Xseparated by a tilde:
Xtime received as an integer (a
X.I time_t
Xin fact),
Xand
Xthe value of the
X.I Expires:
Xheader,
X"-" if none.
XB 2.11 news
Xdoes not record the
X.I Expires:
Xvalue and stores the time received in a peculiar variant of
X.I ctime (3)
Xformat,
Xwhich cannot be parsed by
X.I getdate (3),
Xto the annoyance of
X.I nntp .
XYou must lock the news system with
X.I locknews
Xbefore editing the history file.
X.PP
X.I "active file."
XC news
Xwill tolerate two,
Xthree,
Xor
Xfour
Xfields in the
X.I active
Xfile,
Xand
Xany number of digits in the article-number fields
X(hint: five is too few).
XC news
Xalso supports two new values for the fourth field:
X.B x ,
Xmeaning
X``quietly discard articles for this group'',
Xand
X.B = realgroup
Xmeaning
X``file articles for this group under
X.I realgroup
Xinstead''.
X.B =
Xis useful for coping with badly-run
Xlocal newsgroups,
Xoften created from mailing lists.
XYou must lock the news system with
X.I locknews
Xbefore editing the active file.
X.PP
X.I "sys file."
XC news
Xignores blank lines and
X.B #
Xcomment lines in the
X.I sys
Xfile.
XMany obsolete flags draw fatal diagnostics,
Xnotably
X.B N ,
Xthe old,
Xunbatched ihave/sendme flag.
XIf the fourth field is a relative command name,
X.B /usr/lib/news/bin
Xand
X.B /usr/lib/newsbin/relay
Xwill be searched before the standard search path.
XIf the fourth field is a relative file name,
X.B /usr/spool/news/out.going
Xwill be prepended.
XThe ihave/sendme kludges of B news
Xhave been expunged;
Xone must say what one means,
Xusing three to five entries,
Xtypically.
X.SH
XDifferences in behaviour
X.PP
X.I "Control messages."
X.I Checkgroups
Xis non-destructive in C news;
Xit merely mails its output to
X.B $NEWSMASTER
X(e.g.
X.B usenet ).
XThe superfluous
X.I Supersedes:
Xheader is not honoured.
X.PP
X.I "Newsgroup aliases."
XC news
Xdoes not implement newsgroup aliases,
Xsince we believe that header munging is to be avoided
Xexcept under extreme duress.
XIt is possible to file articles locally under different newsgroups
Xby use of the active file
X.B =
Xflag.
!
echo 'notebook/libs':
sed 's/^X//' >'notebook/libs' <<'!'
X.TL
XA Tour Through the C News Libraries and Include Files
X.AU
XGeoff Collyer
X.AI
XDepartment of Statistics
XUniversity of Toronto
X.SH
Xlibc and friends
X.LP
X.I libc
Xcontains routines that are sufficiently useful
Xand general that they could profitably be added to
Xone's C library.
XIndeed,
Xon some systems they are in the C library.
XNotable inventions include
X.I fgetmfs
Xwhich safely reads arbitrarily-long input lines;
Xit has an
X.B fgetmfs.h
Xover in the header directories.
X.I ldiv
Xis the ANSI one,
Xif you need it.
X.I memlist
Xis a
Xpackage to ease keeping track of a lot of allocated memory.
X.I stdfdopen
Xis invoked by setuid programs
Xto ensure that the standard file descriptors are indeed open,
Xopening
X.B /dev/null
Xon each closed standard descriptor.
X.\".B libc/memcpy.fast
X.\"contains some alternate
X.\"implementations of
X.\".I memcpy (3)
X.\"which may be faster than the ones in your local C library.
X.LP
X.B libstdio
Xcontains new (faster) guts for
Xthe original
X.UX
X.I stdio
Xlibrary;
Xif they compile on your V7,
X4BSD
Xor System III
Xsystem,
Xyou may want to use them instead of the default versions
Xin your C library.
XOn System V,
Xthese routines are only slightly faster than the versions in the C library.
X.LP
X.B libfake
Xcontains things that probably should be in your C library,
Xbut might not be, and a couple of fake routines for system calls
Xyou might not have.
X.SH
Xlibcnews
X.LP
X.B libcnews
Xcontains functions of general use to news software,
Xbut not the world at large.
X.I complain
Xis like
X.I warning ,
Xbut never prints the symbolic value of
X.I errno .
X.PP
XThere is a locking package,
Xcontaining
X.I lockdebug ,
X.I newslock ,
X.I newsunlock ,
X.I errunlock ,
Xand
X.I nemalloc .
X.I lockdebug
Xenables or disables lock debugging.
X.I newslock
Xattempts to lock
Xthe news transport layer
Xagainst
Xread-then-write access to the
X.B active
Xfile,
Xwriting to the
X.B history *,
X.B log ,
X.B errlog ,
Xand batch files.
XIt returns only when it has the lock;
Xin the meantime it sleeps and retries until it gets the lock.
XThere is no timeout;
Xthis is a feature.
X.I newsunlock
Xremoves the above-mentioned lock
Xif this process locked the news system.
X.I errunlock
Xis like
X.I error
Xexcept that it
Xunlocks the news system
X(via
X.I newsunlock)
Xbefore exiting;
Xit is should always be called instead of
X.I exit (3)
Xor
X.I exit (2)
Xif there is any chance that this process has locked the news system.
X.I nemalloc
Xis like
X.I emalloc
Xbut it calls
X.I errunlock
Xif it can't allocate memory.
X.PP
X.I ltoza
Xconverts a
X.B "long int"
Xto a string of a given width,
Xcontaining the decimal representation,
Xzero-padding as needed on the left.
X.I ltozan
Xis like
X.I ltoza
Xbut omits the terminating NUL,
Xso it can be used to overwrite a string without truncating it.
X.I ngmatch
Xreturns a truth-value
Xresulting from comparing
Xa list of newsgroup patterns
Xand
Xa list of newsgroups.
XOne may substitute ``distribution'' for ``newsgroup''.
X.PP
XThere is a package of pathname manipulators.
X.I artfile
Xreturns a name for its filename argument,
Xassumed to be relative to
X.I $NEWSARTS ;
X.I fullartfile
Xpromises to return a fully-qualified path name.
X.I ctlfile
Xreturns a name for its filename argument,
Xassumed to be relative to
X.I $NEWSCTL .
X.I binfile
Xreturns a name for its filename argument,
Xassumed to be relative to
X.I $NEWSBIN .
X.I cd
Xchanges to its argument directory,
Xcheck for errors,
Xand notes the directory name,
Xby making a private copy,
Xfor later optimisations.
X.I newsumask
Xreturns the value of
X.I $NEWSUMASK .
X.I newspath
Xreturns the value of
X.I $NEWSPATH .
X.I newsmaster
Xreturns the value of
X.I $NEWSMASTER .
XAll these functions
Xsupply default values for the
X.I NEWS *
Xvariables if none are found in the environment.
XIf values are found in the environment,
Xthey are used,
Xand a function named
X.I unprivileged
Xis called.
X.PP
X.I readline
Xis like
X.I fgets ,
Xbut executes
X.I newslock
Xupon encountering EOF
Xand retries the read.
XThis is used when reading growing files
Xsuch as
X.B history
Xor
Xbatch files.
X.I strlower
Xdown-cases an entire string,
Xin place.
X.I strsave
Xis like
X.I strdup
Xbut it calls
X.I nemalloc
Xrather than
X.I emalloc .
X.I str3save
Xtakes three strings,
Xallocates space for their concatenation
Xvia
X.I nemalloc ,
Xincluding terminating NUL,
Xand concatenates them onto it.
XA
X.I NULL
Xargument will be replaced by an empty string.
X.I timestamp
Xwrites a timestamp on a given stream,
Xand returns the current time via an argument
Xfor later use.
X.SH
XUnix-variant-specific libraries
X.LP
XThere are several libraries that provide functions
Xfor talking to specific Unix variants.
XThese are basically functions that change from one variant to another.
X.B libfake
X(see above) contains things which simply might not be there in a
Xparticular system.
X.LP
XThese libraries all provide the same virtual interface to
Xoperating-system-dependent services:
X.I fclsexec ,
X.I fopenexcl ,
X.I getcwd (3),
Xand
X.I gethostname (3).
XImplementations for vanilla implementations of these
X.UX
Xvariants are provided:
XSeventh Edition,
Xincluding 4.1BSD
X(\c
X.B libv7 );
XEighth
Xand Ninth Editions
X(\c
X.B libv8 );
X4.2BSD and later
X(\c
X.B libbsd42 );
XSystem III and System V
X(\c
X.B libusg ).
X.I fclsexec
Xsets the close-on-exec flag
Xfor a given
X.I stdio
Xstream.
X.I fopenexcl
Xperforms an ``exclusive create'' open:
Xthe open fails if the file already exists.
X.SH
XAddress-space-size-specific libraries
X.LP
XThese libraries provide alternate versions of the
X.B active
Xand
X.B sys
Xfile code:
X.B libsmall
Xshould work on any machine,
Xbut is suboptimally fast;
X.B libbig
Xhas worked even on PDP-11s,
Xand is quite fast,
Xbut consumes memory without apology.
X.SH
XInclude files
X.LP
X.B libh
Xcontains include files
Xunique to C news.
X.B news.h
Xdefines a few limits,
Xsome file names,
Xsome types
X(\c
X.B boolean
Xand
X.B statust ),
Xsome characters,
Xsome status bits,
Xsome macros for speed,
Xand
Xdeclares functions in
X.B libcnews
Xor miscellaneous functions in
X.I relaynews
X(oops!).
X.B config.h
Xdeclares the pathname functions in
X.B libcnews .
X.B fgetmfs.h
Xdeclares symbolic values and macros for using
X.B fgetmfs .
X.B libc.h
Xis a start at a V9-like declaration of all of the C library.
X.B memlist.h
Xdefines the interface to
X.B memlist .
X.LP
X.B hfake
Xcontains a few include files that your system ought to have but might not.
X.B stdlib.h
Xis a degenerate ANSI
X.B stdlib.h .
X.B string.h
Xdeclares the string functions.
X.B timeb.h
Xdeclares the structure used by
X.I ftime .
!
echo done


-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.