🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #6387

LISTGROUP change

#6387
From: Nick Sayer
Date: Wed, 07 Sep 1994 04:53
192 lines
5503 bytes
Has anyone actually implemented the LISTGROUP suggestion
in the nn nntp.c file?

I ask this because I have (what I hope to be) a better idea of 
how to implement it, at least for nntpd (I don't know about innd's
"mode reader" handler).

If, instead of having LISTGROUP take a group name as an argument,
LISTGROUP takes either no arguments or a range of article IDs, then
it can simply spit out bits of the article-ID array that the GROUP
command builds.

This also has the effect of slightly simplifying the appropriate routine
in nn's nntp.c. The bits of it in the XHDR section that set the group
move outside to the top, and it becomes a simple alternative of sending
LISTGROUP or XHDR.

This implementation reduces expiration time on my spool by no less than
two orders of magnitude.

Here's listgroup.c. It becomes part of nntpd:

----- cut here -----
#ifndef lint
static char	*sccsid = "@(#)$Header: listgroup.c,v 1.00 94/09/04 23:59:53 sob Exp $";
#endif

#include "common.h"

#ifdef LISTGROUP

/*
 * LISTGROUP [range]
 *
 * Just generates a list or article numbers present in the indicated
 * range, or in the entire group.
 *
 * This command is an extension, and not included in RFC 977.
 */

listgroup(argc, argv)
	int		argc;
	char		*argv[];
{
	register int	artptr;
	register int	low, high;
	register char	*cp;

	if (argc>2) {
		printf("%d Usage: LISTGROUP [range]\r\n",
			ERR_CMDSYN);
		(void) fflush(stdout);
		return;
	}

	if (!canread) {
		printf("%d You only have permission to transfer, sorry.\r\n",
			ERR_ACCESS);
		(void) fflush(stdout);
		return;
	}

	if (!ingroup) {
		printf("%d You are not currently in a newsgroup.\r\n",
			ERR_NCING);
		(void) fflush(stdout);
		return;
	}

	if (argc==2) {
		cp = index(argv[1], '-');
                if (cp == NULL)
                        low = high = atoi(argv[1]);
                else {
			*cp = '\0';
			low = atoi(argv[1]);
			cp++;
			high = atoi(cp);
			if (high < low)
				high = art_array[num_arts-1];
		}
	
	} else {
		low=1;
		high = art_array[num_arts-1];
	}


	printf("%d article-IDs follow:\r\n", OK_ARTIDS);


	for (artptr=0;artptr<num_arts; artptr++) 
		if (art_array[artptr] >= low && art_array[artptr] <= high)
			printf("%d\r\n",art_array[artptr]);


	putchar('.');
	putchar('\r');
	putchar('\n');
	(void) fflush(stdout);
}



#else not LISTGROUP

/* Kludge to get around Greenhills C compiler */

listgroup_greenkluydge()
{
}

#endif not LISTGROUP
----- ereh tuc -----

Here's the patch to nntp.c:

*** old/nntp.c	Sun Nov 11 16:01:28 1990
--- nntp.c	Sun Sep  4 12:56:09 1994
***************
*** 890,895 ****
--- 956,971 ----
      if (!is_connected && connect_server() < 0)
  	return NULL;
  
+     if (group_is_set == 0)
+ 	    switch (do_set_group()) {
+ 	     case -1:
+ 		return NULL;
+ 	     case 0:
+ 		goto again;
+ 	     case 1:
+ 		break;
+ 	    }
+ 
      /* it is really an extreme waste of time to use XHDR since all we	*/
      /* are interested in is the article numbers (as we do locally).	*/
      /* If somebody hacks up an nntp server that understands LISTGROUP	*/
***************
*** 898,905 ****
      /* -- they don't even have to be sorted (only XHDR needs that)	*/
  
      if (try_listgroup) {
! 	switch (n = ask_server("LISTGROUP %s", group_hd->group_name)) {
! 	 case OK_GROUP:
  	    break;
  	 default:
  	    if (try_again) goto again; /* Handle nntp server timeouts */
--- 974,981 ----
      /* -- they don't even have to be sorted (only XHDR needs that)	*/
  
      if (try_listgroup) {
! 	switch (n = ask_server("LISTGROUP")) {
! 	 case OK_ARTIDS:
  	    break;
  	 default:
  	    if (try_again) goto again; /* Handle nntp server timeouts */
***************
*** 909,926 ****
  	    try_listgroup = 0;
  	    goto again;	/* error may have closed down server connection */
  	}
!     }
!     if (!try_listgroup) {
! 	if (group_is_set == 0)
! 	    switch (do_set_group()) {
! 	     case -1:
! 		return NULL;
! 	     case 0:
! 		goto again;
! 	     case 1:
! 		break;
! 	    }
! 
  	switch (n = ask_server("XHDR message-id %ld-%ld",
  		(long)gh->first_db_article, (long)gh->last_db_article)) {
  	 case OK_HEAD:
--- 985,991 ----
  	    try_listgroup = 0;
  	    goto again;	/* error may have closed down server connection */
  	}
!     } else {
  	switch (n = ask_server("XHDR message-id %ld-%ld",
  		(long)gh->first_db_article, (long)gh->last_db_article)) {
  	 case OK_HEAD:
 

-- 
Nick Sayer <nsayer@quack.kfu.com>    | "Garcon! More Java, man!"
N6QQQ @ N0ARY.#NOCAL.CA.USA.NOAM     | "It's no use, chick, we're being
+1 408 249 9630, log in as 'guest'   | waited on by Godot."
URL: http://www.kfu.com/~nsayer/     | "Just grin and Becket, cats."
Technical Details
Message-ID: <gmlqPN0@quack.kfu.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!nntp.gmd.de!xlink.net!slsv6bt!slbh01.bln.sel.alcatel.de!rcvie!Austria.EU.net!EU.net!uunet!quack!quack.kfu.com!nsayer

Show Full Headers
Complete Article Headers
Message-ID: <gmlqPN0@quack.kfu.com>
Subject: LISTGROUP change
Date: Wed, 07 Sep 1994 04:53:28 +0000
From: nsayer@quack.kfu.com (Nick Sayer)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!nntp.gmd.de!xlink.net!slsv6bt!slbh01.bln.sel.alcatel.de!rcvie!Austria.EU.net!EU.net!uunet!quack!quack.kfu.com!nsayer
Newsgroups: news.software.nn
Sender: news@quack.kfu.com (0000-News(0000))
Organization: The Duck Pond public unix: +1 408 249 9630, log in as 'guest'.
Lines: 192