🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #672

Re: Making Pnews use the "LIST DISTRIBUTIONS" NNTP command...

#672
From: Per Hedeland
Date: Sun, 06 Oct 1991 01:37
285 lines
9620 bytes
In article <VdN_!T@engin.umich.edu> stealth@engin.umich.edu (Mike Pelletier) writes:
>Perhaps this functionality could be taped onto the "getactive" program
>that rrn uses to fetch the active file from the news server?  That way
>the distributions wouldn't be so hardcoded in the Pnews program itself...
>
>Thoughts, comments, etc?

Yes, an excellent idea! (must be, since I had it long ago:-)

A diff to the then-current rn (4.3 at patchlevel 46, I believe) is
below; since the changes are mostly trivial, it shouldn't be too hard to
carry them over into a more current version. I would have sent it to the
rn maintainer, but I believe there was a moratorium on new features at
that time...

--Per Hedeland
per@erix.ericsson.se  or
per%erix.ericsson.se@sunic.sunet.se  or
..uunet!erix.ericsson.se!per

RCS file: getactive.c,v
retrieving revision 1.2.1.1
retrieving revision 1.2.1.2
diff -c -r1.2.1.1 -r1.2.1.2
*** /tmp/,RCSt1a06852	Sun Oct  6 02:03:35 1991
--- /tmp/,RCSt2a06852	Sun Oct  6 02:03:35 1991
***************
*** 1,6 ****
! /* $Header: /usr/local/share/src/rn/getactive.c,v 1.2.1.1 90/05/10 15:36:22 euaphd Exp $
   *
   * $Log:	getactive.c,v $
   * Revision 1.2.1.1  90/05/10  15:36:22  euaphd
   * Branch for LME changes.
   * 
--- 1,12 ----
! /* $Header: /usr/local/share/src/rn/getactive.c,v 1.2.1.2 90/05/11 14:30:52 per Exp Locker: per $
   *
   * $Log:	getactive.c,v $
+  * Revision 1.2.1.2  90/05/11  14:30:52  per
+  * Modified to get alternate list depending on command name, e.g.
+  * 'getdistributions' will do an NNTP 'LIST distributions'
+  * ('getactive' still does just 'LIST', since some servers don't
+  * implement 'LIST active').
+  * 
   * Revision 1.2.1.1  90/05/10  15:36:22  euaphd
   * Branch for LME changes.
   * 
***************
*** 30,40 ****
  	int		response;
  	register char	*server;
  	register FILE	*actfp;
  
  	if (argc != 2) {
! 		fprintf(stderr, "Usage: getactive filename\n");
  		exit(1);
  	}
  
  	server = getserverbyfile(SERVER_FILE);
  	if (server == NULL) {
--- 36,56 ----
  	int		response;
  	register char	*server;
  	register FILE	*actfp;
+ 	register char	*prog, *list;
+ 	extern char	*rindex();
  
+ 	if ((prog = rindex(argv[0], '/')) == NULL)
+ 	    prog = argv[0];
+ 	else
+ 	    prog++;
  	if (argc != 2) {
! 		fprintf(stderr, "Usage: %s filename\n", prog);
  		exit(1);
  	}
+ 	if (strncmp(prog, "get", 3) == 0)
+ 	    list = &prog[3];
+ 	else
+ 	    list = "active";
  
  	server = getserverbyfile(SERVER_FILE);
  	if (server == NULL) {
***************
*** 48,55 ****
  	response = server_init(server);
  	if (response < 0) {
  		fprintf(stderr,
! 			"getactive: Can't get active file from server %s.\n",
! 				server);
  		exit(1);
  	}
  
--- 64,71 ----
  	response = server_init(server);
  	if (response < 0) {
  		fprintf(stderr,
! 			"getactive: Can't get %s file from server %s.\n",
! 				list, server);
  		exit(1);
  	}
  
***************
*** 56,66 ****
  	if (handle_server_response(response, server) < 0)
  		exit(1);
  
! 	put_server("LIST");	/* tell server we want the active file */
  	(void) get_server(ser_line, sizeof(ser_line));
  	if (*ser_line != CHAR_OK) {		/* and then see if that's ok */
  		fprintf(stderr,
! 			"getactive: Can't get active file from server.\n");
  		fprintf(stderr, "Server said: %s\n", ser_line);
  		exit(1);
  	}
--- 72,86 ----
  	if (handle_server_response(response, server) < 0)
  		exit(1);
  
! 	if (strcmp(list, "active") == 0)
! 	    strcpy(ser_line, "LIST");	/* for old servers */
! 	else
! 	    sprintf(ser_line, "LIST %s", list);
! 	put_server(ser_line);	/* tell server what we want */
  	(void) get_server(ser_line, sizeof(ser_line));
  	if (*ser_line != CHAR_OK) {		/* and then see if that's ok */
  		fprintf(stderr,
! 			"getactive: Can't get %s file from server.\n", list);
  		fprintf(stderr, "Server said: %s\n", ser_line);
  		exit(1);
  	}
RCS file: Pnews.SH,v
retrieving revision 4.3.2.6.1.2
retrieving revision 4.3.2.6.1.3
diff -c -r4.3.2.6.1.2 -r4.3.2.6.1.3
*** /tmp/,RCSt1a06868	Sun Oct  6 02:06:16 1991
--- /tmp/,RCSt2a06868	Sun Oct  6 02:06:17 1991
***************
*** 4,12 ****
  echo "Extracting Pnews (with variable substitutions)"
  $spitshell >Pnews <<!GROK!THIS!
  $startsh
! # $Header: /usr/local/share/src/rn/Pnews.SH,v 4.3.2.6.1.2 90/05/10 15:23:01 euaphd Exp $
  #
  # $Log:	Pnews.SH,v $
  # Revision 4.3.2.6.1.2  90/05/10  15:23:01  euaphd
  # Deleted From: from standard header - it shouldn't be there (at least
  # not w/o Path:).
--- 4,18 ----
  echo "Extracting Pnews (with variable substitutions)"
  $spitshell >Pnews <<!GROK!THIS!
  $startsh
! # $Header: /usr/local/share/src/rn/Pnews.SH,v 4.3.2.6.1.3 90/05/11 14:13:22 per Exp Locker: per $
  #
  # $Log:	Pnews.SH,v $
+ # Revision 4.3.2.6.1.3  90/05/11  14:13:22  per
+ # Modified to try to get distributions from server (if $lib/distributions
+ # doesn't exist); requires "enhanced getactive" (but will fall back if it
+ # isn't found) - includes some reorg of that code, e.g. removing unnecessary
+ # use of $tmpart, to be able to use it for distribution list.
+ # 
  # Revision 4.3.2.6.1.2  90/05/10  15:23:01  euaphd
  # Deleted From: from standard header - it shouldn't be there (at least
  # not w/o Path:).
***************
*** 588,603 ****
      ;;
  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
--- 598,614 ----
      ;;
  esac
  
! serverdist=''
! if $test -f $lib/distributions; then
!     distfile=$lib/distributions
! else
!     distfile=$tmpart
!     if $test -f $lib/getdistributions && \
!       $lib/getdistributions $tmpart >/dev/null 2>&1 && \
!       $test -s $tmpart; then
! 	serverdist=$tmpart
      else
! 	$egrep -v '[	 ]none$' <<EOM >$tmpart
      Local organization:	$loc
      Organization:	$org
      City:		$city
***************
*** 605,613 ****
      Country:		$cntry
      Continent:		$cont
      Everywhere:		world
- 
  EOM
      fi
      $echo $n "Distribution ($defdist): $c"
      read dist
      case $dist in
--- 616,629 ----
      Country:		$cntry
      Continent:		$cont
      Everywhere:		world
  EOM
      fi
+ fi
+ while $test "$dist" = h ; do
+     $echo " "
+     $echo "Your local distribution prefixes are:"
+     $cat $distfile
+     $echo " "
      $echo $n "Distribution ($defdist): $c"
      read dist
      case $dist in
***************
*** 631,639 ****
  	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."
--- 647,654 ----
  	dist=''
  	;;
      *)  
! 	if $test -f $lib/distributions -o "$serverdist" && \
! 	  $egrep "^$dist[ 	]" $distfile >/dev/null; then
  	    : null
  	else
  	    $echo "Unrecognized distribution prefix--type h for help, CR to use anyway."
RCS file: Makefile.SH,v
retrieving revision 4.3.2.9.1.1
retrieving revision 4.3.2.9.1.2
diff -c -r4.3.2.9.1.1 -r4.3.2.9.1.2
*** /tmp/,RCSt1a06879	Sun Oct  6 02:11:38 1991
--- /tmp/,RCSt2a06879	Sun Oct  6 02:11:38 1991
***************
*** 3,11 ****
  esac
  echo "Extracting Makefile (with variable substitutions)"
  cat >Makefile <<!GROK!THIS!
! # $Header: /usr/local/share/src/rn/Makefile.SH,v 4.3.2.9.1.1 90/05/10 17:50:38 euaphd Exp $
  #
  # $Log:	Makefile.SH,v $
  # Revision 4.3.2.9.1.1  90/05/10  17:50:38  euaphd
  # RCSified. Branch for LME changes.
  # 
--- 3,14 ----
  esac
  echo "Extracting Makefile (with variable substitutions)"
  cat >Makefile <<!GROK!THIS!
! # $Header: /usr/local/share/src/rn/Makefile.SH,v 4.3.2.9.1.2 90/05/11 14:38:03 per Exp Locker: per $
  #
  # $Log:	Makefile.SH,v $
+ # Revision 4.3.2.9.1.2  90/05/11  14:38:03  per
+ # Added symlink to allow calling getactive as 'getdistributions'
+ # 
  # Revision 4.3.2.9.1.1  90/05/10  17:50:38  euaphd
  # RCSified. Branch for LME changes.
  # 
***************
*** 143,148 ****
--- 146,152 ----
  	- ./makedir `./filexp $(rnlib)`
  	- if test `pwd` != `./filexp $(rnlib)`; then cp INIT $(private) `./filexp $(rnlib)`; fi
  	cd `./filexp $(rnlib)`; chmod 755 $(private)
+ #NNTP	- ln -s getactive $(rnlib)/getdistributions
  	- if test ! -f `./filexp $(rnlib)/newsnews`; then cp newsnews `./filexp $(rnlib)`; fi
  	- if test `pwd` != $(mansrc); then \
  for page in $(manpages); do \
Technical Details
Message-ID: <1991Oct6.013748.25153@eua.ericsson.se>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmdzi!unido!mcsun!news.funet.fi!sunic!seunet!ericom!eua.ericsson.se!erix.ericsson.se!per
References: <VdN_!T@engin.umich.edu>

Show Full Headers
Complete Article Headers
Message-ID: <1991Oct6.013748.25153@eua.ericsson.se>
Subject: Re: Making Pnews use the "LIST DISTRIBUTIONS" NNTP command...
Date: Sun, 06 Oct 1991 01:37:48 +0000
From: per@erix.ericsson.se (Per Hedeland)
References: <VdN_!T@engin.umich.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmdzi!unido!mcsun!news.funet.fi!sunic!seunet!ericom!eua.ericsson.se!erix.ericsson.se!per
Newsgroups: news.software.readers
Sender: news@eua.ericsson.se
Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
Lines: 285
Nntp-Posting-Host: super.eua.ericsson.se