[net.sources] Newsgroup description hack to vnews

riddle@ut-sally.UUCP (05/22/84)

Some time back, someone suggested that a nice feature to add to vnews
would be the display of a short description of each newsgroup as it
comes up.  I've made the necessary changes to visual.c to do this; in
addition, I've written a shell script to automatically grab the
newsgroup description list posted regularly to net.news.group by Adam
Buchsbaum (research!alb) and put it where vnews can get at it.

Here are the sources.  Cut at the dotted line and enjoy!

--- Prentiss Riddle ("Aprendiz de todo, maestro de nada.")
--- {ihnp4,seismo,gatech,ctvax}!ut-sally!riddle

...........................< cut here >..............................
: This is a shar archive.  Extract with sh, not csh.
echo x - README.ngd
cat > README.ngd << '!Funky!Stuff!'
This file describes how to install the "newsgroup description" addition
to vnews.  You will need the following files:

	README.ngd	This file.
	grabngd.sh	The shell script used to "grab" the current newsgroup
			descriptions as they are appear in net.news.group.
	ngdesc		A sample netwide newsgroup description file.
	ngdesc.local	A sample local newsgroup description file.
	visual.c.diff	Diffs to visual.c.

You should follow these steps:

 -- If necessary, change the NGDESC and NGDLOCAL variables in grabngd.sh and
    visual.c.diff to reflect the news library directory on your system.
    (The default is /usr/local/lib/news.)
 -- Make the changes to visual.c described in visual.c.diff.
 -- Modify ngdesc.local to reflect the local newsgroups used at your site.
    (This will probably vary radically from the version provided here.)
 -- Prepend ngdesc.local to ngdesc and copy both files to the news library
    directory; ngdesc should be installed with mode 0664 (or whatever will
    make it writable by the grabngd shell script).  Similarly, install
    grabngd.sh as "grabngd" with mode 0775 in the news library directory.
    (You may want to modify your makefile to do this for you.)
 -- Make the one-line modification to your sys file as described in
    grabngd.sh.
 -- Recompile vnews using the modified visual.c, try it out, and install the
    binary.

Please report problems, bugs, etc. to:

--- Prentiss Riddle ("Aprendiz de todo, maestro de nada.")
--- {ihnp4,seismo,gatech,ctvax}!ut-sally!riddle
!Funky!Stuff!
echo x - grabngd.sh
cat > grabngd.sh << '!Funky!Stuff!'
#! /bin/sh
#
#   grabngd     Prentiss Riddle (ut-sally!riddle)     840521
#
#   Shell script to "grab" the newsgroup descriptions posted monthly
#   to net.news.group by Adam Buchsbaum (research!alb) and install them
#   where vnews can read them.
#
#   This shell script should be activated by the following line in your
#   sys file:
#
#          dummy-ngd:net.news.group:A:/usr/local/lib/news/grabngd
#
#   Note that the pathname in the sys file must agree with the directory
#   where this file is installed.  In addition, the definition of $NGDESC
#   below must agree with that in visual.c.
#
#   The optional file $NGDLOCAL may contain definitions of local newsgroups
#   (as well as descriptions which override those in Buchsbaum's list).
#   Mail is sent to users listed in $INFORM whenever installation is
#   successful.
#
NGDESC= /usr/local/lib/news/ngdesc
NGDLOCAL= /usr/local/lib/news/ngdesc.local
INFORM= "usenet"

# This is ugly, but it works: decode the "A" news header.
read site
read groups
read path
read date
read title
if test "$title" != 'List of Active Newsgroups'; then
	exit
fi

cat </dev/null > $NGDESC
if test -f $NGDLOCAL; then
	echo "# Local newsgroup descriptions:" >>$NGDESC
	cat $NGDLOCAL >> $NGDESC
	echo '#' >>$NGDESC
fi
echo '# Newsgroup description list posted to net.news.group' >>$NGDESC
echo '# by Adam L. Buchsbaum (research!alb):' >>$NGDESC
sed -e '1,/^Newsgroup		Description$/d
	/^-----------------------------*$/d
	/^--------------------$/,$d' >> $NGDESC

echo 'Subject: New newsgroup description file installed

A new newsgroup description list has been installed 
	in '"$NGDESC"' .        
                      
 A-format file header: 
	'"$site"'
	'"$groups"'    
	'"$path"'
	'"$date"'
	'"$title"'
' | /bin/mail $INFORM
!Funky!Stuff!
echo x - ngdesc
cat > ngdesc << '!Funky!Stuff!'
#
# Newsgroup description list posted to net.news.group
# by Adam L. Buchsbaum (research!alb):
#
# [This was current as of 21 May 1984 -- you may want to bring it
#  up to date before you install it.]
#
net.abortion		All sorts of discussions on abortion.
net.adm.site		Automatic maintenance of the USENET directory.
			Currently experimental.
net.ai			Artificial intelligence.
net.analog		Analog design developments, ideas, and components.
net.announce		General announcements of interest to all.
			Moderated (Mark Horton -- cbosgd!announce)
	net.announce.newusers	Subgroup for new users.  Monthly postings, etc.
				Moderated (Mark Horton -- cbosgd!announce)
net.arch		Computer architecture.
net.astro		Astronomy.
	net.astro.expert	Subgroup for experts in astronomy.
net.audio		High fidelity audio.
net.auto		Automobiles and automotive products and laws.
net.aviation		Aviation rules, means, and methods.
net.bicycle		Bicycles and related products and laws.
net.bio			Biology and related sciences.
net.books		Books of all genres, shapes, and sizes.
net.bugs		General bug reports and fixes.
	net.bugs.2bsd		Subgroup for UNIX* version 2BSD related bugs.
	net.bugs.4bsd		Subgroup for UNIX version 4BSD related bugs.
	net.bugs.usg		Subgroup for USG (System III, V, etc.) bugs.
	net.bugs.uucp		Subgroup for UUCP related bugs.
	net.bugs.v7		Subgroup for UNIX V7 related bugs.
net.chess		Chess and computer chess.
net.cog-eng		Cognitive engineering.
net.college		College, college activities, campus life, etc.
net.columbia		The space shuttle and the STS program.
net.comics		The funnies, old and new.
net.consumers		Consumer interests, product reviews, etc.
net.cooks		Food, cooking, cookbooks, and recipes.
net.crypt		Different methods of data en/decryption.
net.cse			Computer science education.
net.cycle		Motorcycles and related products and laws.
net.dcom		Data communications hardware and software.
net.decus		DEC* User's Society newsgroup.
net.emacs		EMACS editors of different flavors.
net.eunice		The SRI Eunice system.
net.flame		For flaming on any topic.
net.followup		Followups to articles in net.general.
net.games		Games and computer games.
	net.games.emp		Subgroup for Empire.
	net.games.frp		Subgroup for Fantasy Role Playing games.
	net.games.go		Subgroup for Go.
	net.games.pbm		Subgroup for Play by Mail games.
	net.games.rogue		Subgroup for Rogue.
	net.games.trivia	Subgroup for trivia.
	net.games.video		Subgroup for video games.
net.garden		Gardening, methods and results.
net.general		Important and timely announcements of interest to all.
net.graphics		Computer graphics, art, and animation.
net.ham-radio		Amateur Radio practices, contests, events, rules, etc.
net.info-terms		All sorts of terminals.
net.invest		Investments and the handling of money.
net.jobs		Job announcements, requests, etc.
net.jokes		Jokes and the like.  May be slightly offensive.
	net.jokes.d		Subgroup for discussions on the content
				of submissions to net.jokes.
net.kids		Children, their behavior and activities.
net.lan			Local area network hardware and software.
net.lang		Different computer languages.
	net.lang.ada		Subgroup for Ada*.
	net.lang.apl		Subgroup for APL.
	net.lang.c		Subgroup for C.
	net.lang.f77		Subgroup for FORTRAN.
	net.lang.forth		Subgroup for Forth.
	net.lang.lisp		Subgroup for LISP.
	net.lang.mod2		Subgroup for Modula-2.
	net.lang.pascal		Subgroup for Pascal.
	net.lang.prolog		Subgroup for PROLOG.
	net.lang.st80		Subgroup for Smalltalk 80.
net.legal		Legalities and the ethics of law.
net.lsi			Large scale integrated circuits.
net.mag			Magazine summaries, tables of contents, etc.
net.mail		Proposed new mail/network standards.
	net.mail.headers	Subgroup for the ARPA header-people list.
	net.mail.msggroup	Subgroup for the ARPA MsgGroup list.
net.math		Mathematical discussions and puzzles.
net.med			Medicine and its related products and regulations.
net.micro		Micro computers of all kinds.
	net.micro.16k		Subgroup for 16k's.
	net.micro.432		Subgroup for 432's.
	net.micro.6809		Subgroup for 6809's.
	net.micro.68k		Subgroup for 68k's.
	net.micro.apple		Subgroup for Apple's.
	net.micro.atari		Subgroup for Atari's.
	net.micro.cbm		Subgroup for Commodore's.
	net.micro.cpm		Subgroup for the CP/M operating system.
	net.micro.hp		Subgroup for Hewlett/Packard's.
	net.micro.pc		Subgroup for IBM personal computers.
	net.micro.trs-80	Subgroup for TRS-80's.
	net.micro.zx		Subgroup for zx's.
net.misc		Miscellaneous discussions too short lived for
			their own groups.
net.motss		Issues pertaining to homosexuality.
net.movies		Reviews and discussions of movies.
	net.movies.sw		Subgroup for the Star Wars saga(s).
net.music		Music lovers' group.
	net.music.classical	Subgroup for classical music.
net.net-people		Announcements, requests, pointers, etc. concerning
			people on the net.
net.news		Discussions of USENET itself.
	net.news.adm		Subgroup for news administrators.
	net.news.b		Subgroup for B news software.
	net.news.config		Subgroup for posting of computer down times
				and network interruptions.
	net.news.group		Subgroup for discussions and lists of
				newsgroups.
	net.news.map		Subgroup for maps.
	net.news.newsite	Subgroup for new site announcements.
	net.news.sa		Subgroup for system administrators.
net.nlang		Natural languages, cultures, heritages, etc.
	net.nlang.celts		Subgroup for Celtics.
	net.nlang.greek		Subgroup for Greeks.
net.notes		Notesfile software from the University of Illinois.
net.origins		Evolution versus creationism (hot).
net.periphs		Peripheral devices.
net.pets		Pets, pet care, and household animals in general.
net.philosophy		Philosophical discussions.
net.physics		Physical laws, properties, etc.
net.poems		For the posting of poems.
net.politics		Political discussions.  Could get hot.
net.puzzle		Puzzles, problems, and quizzes.
net.railroad		Real and model train fans' newsgroup.
net.rec			Recreational/participant sports.
	net.rec.birds		Subgroup for bird watching.
	net.rec.boat		Subgroup for boating.
	net.rec.bridge		Subgroup for bridge.
	net.rec.caves		Subgroup for caving.
	net.rec.coins		Subgroup for coin collecting.
	net.rec.disc		Subgroup for disc activities.
	net.rec.nude		Subgroup for naturalist/nudist activities.
	net.rec.photo		Subgroup for photography.
	net.rec.scuba		Subgroup for SCUBA diving.
	net.rec.ski		Subgroup for skiing.
	net.rec.skydive		Subgroup for skydiving.
	net.rec.wood		Subgroup for woodworking.
net.religion		Religious, ethical, and moral implications of actions.
	net.religion.jewish	Subgroup for Judaism.
net.research		Research and computer research.
net.roots		Genealogical matters.
net.rumor		For the posting of rumors.
net.sf-lovers		Science fiction lovers' newsgroup.
net.singles		Newsgroup for single people, their activities, etc.
net.social		Like net.singles, but for everyone.
net.sources		For the posting of software packages.
net.space		Space, space programs, space related research, etc.
net.sport		Spectator sports.
	net.sport.baseball	Subgroup for baseball.
	net.sport.football	Subgroup for football.
	net.sport.hockey	Subgroup for hockey.
	net.sport.hoops		Subgroup for basketball.
net.startrek		Star Trek, the TV show and the movies.
net.std			All sorts of standards.
net.suicide		Suicide, its causes and effects (!).
net.taxes		Tax laws and advice.
net.test		For testing of network software.  Very boring.
net.text		Text processing.
net.travel		Traveling all over the world.
net.tv			The boob tube, its history, and past and current shows.
	net.tv.drwho		Subgroup for Dr. Who.
	net.tv.soaps		Subgroup for soap operas.
net.unix		UNIX neophytes group.
net.unix-wizards	Discussions, bug reports, and fixes on and
			for UNIX.  Not for the weak of heart.
net.usenix		USENIX Association events and announcements.
net.usoft		Universal software packages.
net.veg			Vegetarians.
net.video		Video and video components.
net.vvs			The Vortex Video System for digitized video images.
net.wanted		Requests for things that are needed, e.g. device
			drivers, information, etc.
net.wines		Wines and spirits.
net.wobegon		"The Prairie Home Companion" radio show.
net.women		Women's rights, discrimination, etc.
	net.women.only		Postings by women only (read by all).
net.works		Assorted workstations.
	net.works.apollo	Subgroup for Apollo's.

fa.arms-d		Arms discussion digest.
fa.arpa-bboard		ARPANET bulletin board.
fa.bitgraph		The BBN bitgraph terminal.
fa.digest-p		Digest-people digest.
fa.editor-p		Editor-people digest.
fa.energy		Energy programs, conservation, etc.
fa.human-nets		Computer aided communications digest.
fa.info-terms		All sorts of terminals.
fa.info-vax		DEC's VAX* line of computers.
fa.info-vlsi		Very large scale integrated circuits.
fa.laser-lovers		Laser printers, hardware and software.
fa.poli-sci		Politics and/versus science.
fa.railroad		Real and model train fans' newsgroup.
fa.sf-lovers		Science fiction lovers' digest.
fa.tcp-ip		TCP and IP network protocols.
fa.telecom		Telecommunications digest.
fa.teletext		Teletext digest.

mod.ber			Summaries of discussions from other groups.
			Brian Redman -- harpo!ber

!Funky!Stuff!
echo x - ngdesc.local
cat > ngdesc.local << '!Funky!Stuff!'
# Sample local newsgroup description file -- current on ut-sally as
# of 21 May 1984:
#
system		Important messages about system configuration or policy.
general		Messages of interest to all users on this system.
ut.general	Messages of interest to all users at UT.
ut.r20bboard	Messages forwarded from the R20 bulletin board.
		(Note: the link does not work in the opposite direction!)
ut.followup	Followups to ut.general
ut.flame	Flames, gripes, complaints and arguments related to UT.
ut.mail		Mail software at UT.
ut.stardate	Scripts from the astronomy department's radio show "Stardate".
ut.text		Text processing at UT.
ut.help.general	A self-help forum for all Unix* users on campus. 
ut.help.followup	Followups to ut.help.general
austin.general	Messages of interest to all in Austin.
austin.followup	Followups to austin.general
houston.general	Messages of interest to all in Houston.
tx.general	Messages of interest to all in Texas.
tx.followup	Followups to tx.general
newshelp	How to use Usenet.
to.cyb-eng	For testing the news link to cyb-eng.
to.dummy	For testing the news link to ???
to.kpno		For testing the news link to kpno.
to.seismo	For testing the news link to seismo.
to.shell	For testing the news link to shell.
to.ut-ngp	For testing the news link to ut-ngp.
to.ut-ratliff	For testing the news link to ut-ratliff.
to.ut-sally	For testing the news link to ut-sally.
to.utmbvax	For testing the news link to utmbvax.
test		For testing the news software on this system.
ut.test		For testing the news software at UT.
control		Control messages used by the news software.
junk		Articles posted to illegal newsgroups.
info.kermit	Gatewayed one-way from the ARPA Internet INFO-KERMIT list.
		The info distribution is similar to the ut distribution.
info.mac	Gatewayed one-way from the ARPA Internet INFO-MAC list.
		The info distribution is similar to the ut distribution.
info.nets	Gatewayed one-way from the ARPA Internet INFO-NETS list.
		The info distribution is similar to the ut distribution.

!Funky!Stuff!
echo x - visual.c.diff
cat > visual.c.diff << '!Funky!Stuff!'
*** visual.c.old	Mon Apr 30 11:53:18 1984
--- visual.c	Mon May 14 12:58:12 1984
***************
*** 56,61
   *    the "r" or "f" commands.
   */
  
  #define STATTOP
  #ifdef USG
  #include <termio.h>

--- 56,69 -----
   *    the "r" or "f" commands.
   */
  
+ /*
+  *   Changes made to visual.c by Prentiss Riddle (ut-sally!riddle) 840510:
+  *
+  *   Addition of a newsgroup description to be printed along with the
+  *      newsgroup name.  This consisted of some small modifications to
+  *      "fmthdr()" and the addition of "fmtdesc()" and the file "NGDESC".
+  */
+ 
  #define STATTOP
  #ifdef USG
  #include <termio.h>
***************
*** 117,122
  #ifndef VHELP
  #define VHELP "/usr/local/lib/news/vnews.help"
  #endif
  
  
  

--- 125,133 -----
  #ifndef VHELP
  #define VHELP "/usr/local/lib/news/vnews.help"
  #endif
+ #ifndef NGDESC
+ #define NGDESC "/usr/local/lib/news/ngdesc"		/*PASR 840418*/
+ #endif
  
  
  
***************
*** 1165,1170
  		if (!hflag) {
  			sprintf(linebuf, "Newsgroup %s", groupdir);  tfappend(linebuf);
  			tfappend("");
  		}
  	}
  	hdrstart = lastlin;

--- 1176,1182 -----
  		if (!hflag) {
  			sprintf(linebuf, "Newsgroup %s", groupdir);  tfappend(linebuf);
  			tfappend("");
+                         fmtdesc(groupdir);		/*PASR 840418*/
  		}
  	}
  	hdrstart = lastlin;
***************
*** 1178,1183
  	tfappend("");
  	hdrend = lastlin;
  }
  
  
  

--- 1190,1308 -----
  	tfappend("");
  	hdrend = lastlin;
  }
+ 
+ 
+ 
+ 
+ /*
+  * format description of next newsgroup
+  */
+ fmtdesc(groupdir)				/* PASR 840510 */
+ char	*groupdir;
+ 
+ #define NGDINDENT 10	/* number of characters to indent group descriptions */
+ {
+ 	FILE *groupf;
+ 	register
+ 	int	i;
+ 	register
+ 	char	*ngdp;		  /* pointer into ngdbuf */
+ 	char	ngdbuf[BUFLEN];	  /* group description file line buffer */
+ 	char	block1[BUFLEN];	  /* first block of text on line */
+ 	char	block2[BUFLEN];	  /* second block of text on line */
+ 	int	match;
+ 
+ /*
+  *  The format of the NGDESC file was chosen so that the list of active
+  *  newsgroups posted regularly to net.news.group by Adam Buchsbaum
+  *  (research!alb) could be used as a basis for it.  Briefly, the format
+  *  can be described as follows:
+  *
+  *  -- Blank lines and lines beginning with '#' are ignored.
+  *  -- An entry must begin with a line consisting of two blocks of text:
+  *          [<tabs>] <newsgroup> <tabs> <description> <newline>
+  *  -- An entry may include any number of continuation lines, each
+  *     consisting of a single block of text:
+  *          [<tabs>] <description> <newline>
+  */
+ 
+ 	if ((groupf = fopen(NGDESC, "r")) == NULL)
+ 		return;
+ 
+ 	/* main loop -- look through description file */
+ 	match = 0;
+ 	do {
+ 		if (fgets (ngdbuf, BUFLEN, groupf) == NULL) {
+ 			fclose (groupf);
+ 			return;
+ 		}
+ 		/* skip initial white space */
+ 		ngdp = (char *)ngdbuf;
+ 		while (*ngdp == '\t')
+ 			++ngdp;
+ 		/* ignore blank lines and comments */
+ 		if (ngdbuf[0] != '#' && *ngdp != '\n') {
+ 			/* get the first block of text */
+ 			for (i = 0; *ngdp != '\t' && *ngdp != '\n'; ++ngdp)
+ 				block1[i++] = *ngdp;
+ 			block1[i] = '\0';
+ 			/* if we're not at the end of the line, we've */
+ 			/* found a newsgroup name.                    */
+ 			if (*ngdp == '\t')
+ 				/* check for match */
+ 				match = (strcmp(block1, groupdir) == 0);
+ 		}
+ 	} while (!match);
+ 
+ 	/* matching group found -- skip to the beginning of the description */
+ 	while (*ngdp == '\t')
+ 		ngdp++ ;
+ 	/* copy the description, indenting and eliminating newline */
+ 	for (i=0; i < NGDINDENT; ++i)
+ 		block2[i] = ' ';
+ 	while (*ngdp != '\n' && *ngdp != '\0') {
+ 		block2[i++] = *ngdp;
+ 		ngdp++;
+ 	}
+ 	block2[i] = '\0';
+ 	/* output the description line */
+ 	tfappend ( block2 );
+ 
+ 	/* look for continuation lines */
+         match = 1;
+ 	do {
+ 		if (fgets (ngdbuf, BUFLEN, groupf) == NULL)
+ 			match = 0;
+ 		else {
+ 			/* skip initial white space. */
+ 			ngdp = (char *)ngdbuf;
+ 			while (*ngdp == '\t')
+ 				++ngdp;
+ 			if (ngdbuf[0] != '#' && *ngdp != '\n') {
+ 				/* indent and grab the first block of text */
+ 				for (i=0; i<NGDINDENT; ++i)
+ 					block1[i] = ' ';
+ 				while (*ngdp != '\t' && *ngdp != '\n') {
+ 					block1[i++] = *ngdp;
+ 					ngdp++;
+ 				}
+ 				block1[i] = '\0';
+ 				/* if there is no second block, we have  */
+ 				/* found a description continuation line */
+ 				if (*ngdp == '\n')
+ 					/* output it */
+ 					tfappend ( block1 );
+ 				else
+ 					match = 0;
+ 			}
+ 		}
+ 	} while (match);
+ 
+ 	tfappend ("");
+ 
+ 	fclose (groupf);
+ }						/* PASR 840510 */
+ 
  
  
  
!Funky!Stuff!

riddle@ut-sally.UUCP (05/22/84)

Sigh.  In the age-old Usenet tradition, within minutes of posting to
net.sources I noticed a bug.  The three lines in grabngd.sh which read:

<< NGDESC= /usr/local/lib/news/ngdesc
<< NGDLOCAL= /usr/local/lib/news/ngdesc.local
<< INFORM= "usenet"

should be changed to read:

>> NGDESC=/usr/local/lib/news/ngdesc
>> NGDLOCAL=/usr/local/lib/news/ngdesc.local
>> INFORM="usenet"

In other words, I ran afoul of the Bourne shell's dislike of blanks in
assignments.

As you may have gathered, I goofed in the testing of the "grabngd" shell
script -- since the script depends on an event which only occurs every
two weeks, it's not the easiest thing to test.  I thought that I had
run the posted version of grabngd.sh through its paces as best I could,
but obviously I hadn't.  So please, watch for bugs in it and let me know
if you find any.  I'll post a corrected version if necessary as problems
arise.

In the meantime, the hack to vnews itself is quite usable without the
automatic description grabber.  It's been running here on ut-sally with
no complaints for weeks.

Shamefacedly yours,

--- Prentiss Riddle ("Aprendiz de todo, maestro de nada.")
--- {ihnp4,seismo,gatech,ctvax}!ut-sally!riddle