From davison@borland.com Sat Nov 26 21:35:09 EST 1994
Article: 6951 of news.software.nntp
Newsgroups: news.software.nntp
Path: news.pop.psu.edu!news.cac.psu.edu!howland.reston.ans.net!gatech!concert!decwrl!borland.com!davison
From: davison@borland.com (Wayne Davison)
Subject: Patch for INN 1.4: LIST ACTIVE wildspec
Message-ID: <CzqpFz.GG1@borland.com>
Organization: Borland International
Date: Wed, 23 Nov 1994 21:38:23 GMT
Lines: 152

This is a patch for INN 1.4 that modifies nnrpd to support the command
LIST ACTIVE <wildspec> where wildspec is a group name to match, possibly
containing wildcards.  Also added was LIST NEWSGROUPS <wildspec> with
the same support.  These extensions are going to be in nntp-1.5.12, and
(as far as I know) also in INN 1.5.

>list active rec.humor
<215 list:
<rec.humor 0000103632 102318 y
<.

>list active rec.humor*
<215 list:
<rec.humor 0000103632 102318 y
<rec.humor.d 0000004830 04807 y
<rec.humor.funny 0000002962 02929 m
<rec.humor.oracle 0000000301 00301 m
<rec.humor.oracle.d 0000002195 02174 y
<.

>list active rec.humor.foo
<215 list:
<.

To apply this patch use:  patch -p <this.file

So far the only newsreader to support this extension is trn 3.6 (just
released -- see news.software.readers for the announcement), but since
it makes reading news over a slow net connection more efficient it will
hopefully be more widely supported soon.
-- 
Wayne Davison
davison@borland.com
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index:nnrpd/commands.c
***************
*** 127,140 ****
      register char	*save;
      char		*grplist[2];
      LISTINFO		*lp;
  
      p = av[1];
      if (p == NULL || caseEQ(p, "active")) {
! 	if (!GetGroupList()) {
! 	    syslog(L_NOTICE, "%s cant getgroupslist for list %m", ClientHost);
! 	    Reply("%d Group update failed. Try later.\r\n", NNTP_TEMPERR_VAL);
! 	    ExitWithStats(1);
  	}
  	lp = &INFOactive;
      }
      else if (caseEQ(p, "active.times"))
--- 127,158 ----
      register char	*save;
      char		*grplist[2];
      LISTINFO		*lp;
+     char		*wildarg = NULL;
  
      p = av[1];
      if (p == NULL || caseEQ(p, "active")) {
! 	static time_t	last_time;
! 	time_t		now;
! 	(void)time(&now);
! 	if (ac < 3 || now > last_time + NNRP_RESCAN_DELAY * 3) {
! 	    if (last_time && !GetGroupList()) {
! 		syslog(L_NOTICE, "%s cant getgroupslist for list %m", ClientHost);
! 		Reply("%d Group update failed. Try later.\r\n", NNTP_TEMPERR_VAL);
! 		ExitWithStats(1);
! 	    }
! 	    last_time = now;
  	}
+ 	if (ac == 3) {
+ 	    GROUPENTRY *gp = GRPfind(av[2]);
+ 	    if (gp) {
+ 		Reply("%d list:\r\n", NNTP_LIST_FOLLOWS_VAL);
+ 		Printf("%s %ld %ld %c%s\r\n.\r\n",
+ 		      gp->Name, (long)gp->High, (long)gp->Low,
+ 		      gp->Flag, gp->Alias ? gp->Alias : "");
+ 		return;
+ 	    }
+ 	    wildarg = av[2];
+ 	}
  	lp = &INFOactive;
      }
      else if (caseEQ(p, "active.times"))
***************
*** 143,156 ****
  	lp = &INFOdistribs;
      else if (caseEQ(p, "distrib.pats"))
  	lp = &INFOdistribpats;
!     else if (caseEQ(p, "newsgroups"))
  	lp = &INFOgroups;
      else if (caseEQ(p, "overview.fmt"))
  	lp = &INFOschema;
      else {
  	Reply("%s\r\n", NNTP_SYNTAX_USE);
  	return;
      }
  
      if ((qp = QIOopen(lp->File, QIO_BUFFER)) == NULL) {
  	syslog(L_ERROR, "%s cant fopen %s %m", ClientHost, lp->File);
--- 161,181 ----
  	lp = &INFOdistribs;
      else if (caseEQ(p, "distrib.pats"))
  	lp = &INFOdistribpats;
!     else if (caseEQ(p, "newsgroups")) {
! 	if (ac == 3)
! 	    wildarg = av[2];
  	lp = &INFOgroups;
+     }
      else if (caseEQ(p, "overview.fmt"))
  	lp = &INFOschema;
      else {
  	Reply("%s\r\n", NNTP_SYNTAX_USE);
  	return;
      }
+     if (ac > 2 && !wildarg) {
+ 	Reply("%s\r\n", NNTP_SYNTAX_USE);
+ 	return;
+     }
  
      if ((qp = QIOopen(lp->File, QIO_BUFFER)) == NULL) {
  	syslog(L_ERROR, "%s cant fopen %s %m", ClientHost, lp->File);
***************
*** 186,191 ****
--- 211,218 ----
  	    if (!PERMmatch(PERMdefault, PERMlist, grplist))
  		continue;
  	}
+ 	if (wildarg && !wildmat(p, wildarg))
+ 	    continue;
  	if (save != NULL)
  	    *save = ' ';
  	Printf("%s\r\n", p);
Index:nnrpd/nnrpd.c
***************
*** 85,91 ****
  	NULL },
      {	"last",		CMDnextlast,	FALSE,	1,	1,
  	NULL },
!     {	"list",		CMDlist,	FALSE,	1,	2,
  	"[active|newsgroups|distributions|schema]" },
      {	"listgroup",	CMDgroup,	FALSE,	1,	2,
  	"newsgroup" },
--- 85,91 ----
  	NULL },
      {	"last",		CMDnextlast,	FALSE,	1,	1,
  	NULL },
!     {	"list",		CMDlist,	FALSE,	1,	3,
  	"[active|newsgroups|distributions|schema]" },
      {	"listgroup",	CMDgroup,	FALSE,	1,	2,
  	"newsgroup" },
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---


