From: rsalz@rodan.UU.NET (Rich Salz)
Newsgroups: news.software.nntp,news.software.b
Subject: Adding "nov" support to nntp1.5.11
Message-ID: <1ha7fdINNi1l@rodan.UU.NET>
Date: 23 Dec 92 17:26:05 GMT
Organization: UUNET Technologies Inc, Falls Church, VA

The following patch adds a new command to the NNTP reference implementation:
		XOVER [first[-last]]
Where first and last are article numbers; the default is to return data
for all articles.  It returns a 284 code followed by a multi-line
response.  This is a new NNTP response code, so the patch includes a
change to common/nntp.h.  The XOVER command requires read permission,
and it requires you to be in a group.

I have compiled this but I have not tested it.  I am posting it because:
	INN1.3 will be providing the same command; and
	I want to stamp out the "XOVERVIEW" command that tin uses.

I do not wish to maintain this code (I had to unpack a compressed tar file
to get to the distribution :-).  I hope Stan will pick this up for his
next release; if anyone -- anyone at all -- wants to maintain this code,
please start doing so.  I would encourage you to distribute your work as
diffs against nntp1.5.11, and use something like "+XOVER1" each time you
put out a new release.

Happy holidays.
	/r$

diff -rc nntp1.5.11/CHANGES nntp1.5.11+over/CHANGES
*** nntp1.5.11/CHANGES	Fri Feb  8 19:22:39 1991
--- nntp1.5.11+over/CHANGES	Wed Dec 23 11:53:10 1992
***************
*** 2,7 ****
--- 2,19 ----
  since the initial release.  Individuals who either reported the bug or
  inspired the bug fix are in square brackets.
  
+ 1.5.11+XOVER0	(Rich $alz <rsalz@uunet.uu.net> 23 dec 92)
+ 	This adds the XOVER command to the server.  The XOVER command
+ 	is used to retrieve data from the .overview file that is part
+ 	of Geoff Collyer's "nov" package (that package is not provided
+ 	here; the official archive for it is
+ 	world.std.com:pub/src/news/nov.dist.tar.Z).  This command
+ 	has the following syntax:
+ 		XOVER [first[-last]]
+ 	Where first and last are article numbers; the default is to return
+ 	data for all articles.  This command is only valid after a GROUP
+ 	command.  It returns a 284 code followed by a multi-line response.
+ 
  1.5.11
  	Fixes to spawn.c and batch.c for those system that need
  	execle() to specifically call /bin/sh to exectute a sh script.


diff -rc nntp1.5.11/common/README nntp1.5.11+over/common/README
*** nntp1.5.11/common/README	Mon Feb  4 01:41:56 1991
--- nntp1.5.11+over/common/README	Wed Dec 23 11:10:18 1992
***************
*** 340,345 ****
--- 340,349 ----
  Authorization process. Read the file AUTHORIZATION in the root directory of
  the NNTP distribution for more information.
  
+ XOVER		(defined)
+      Defines whether we want to include the XOVER command, described
+ in the top-level README file of this distribution.
+ 
  SERVER_FILE	("/usr/local/lib/rn/server")
  
       This file contains the name of the machine which runs the


diff -rc nntp1.5.11/common/conf.h.dist nntp1.5.11+over/common/conf.h.dist
*** nntp1.5.11/common/conf.h.dist	Fri Feb  8 19:31:07 1991
--- nntp1.5.11+over/common/conf.h.dist	Wed Dec 23 11:54:04 1992
***************
*** 201,206 ****
--- 201,210 ----
  /* Things that relate to authentication and access */
  /* Define AUTH to use the proposed NNTP Version 2 authentication protocol. */
  #define	AUTH	
+ 
+ /* Various protocol extensions */
+ #define XOVER		/* xover -- Return .overview data */
+ 
  /*
   * A file containing the name of the host which is running
   * the news server.  This will have to match what rrn thinks,


diff -rc nntp1.5.11/common/nntp.h nntp1.5.11+over/common/nntp.h
*** nntp1.5.11/common/nntp.h	Fri Dec 21 17:47:29 1990
--- nntp1.5.11+over/common/nntp.h	Wed Dec 23 11:33:09 1992
***************
*** 20,25 ****
--- 20,26 ----
   *	x2x	Article selection
   *	x3x	Distribution
   *	x4x	Posting
+  *	x8x	Authorization
   */
  
  #define	CHAR_INF	'1'
***************
*** 42,47 ****
--- 43,49 ----
  #define	OK_HEAD		221	/* Head follows */
  #define	OK_BODY		222	/* Body follows */
  #define	OK_NOTEXT	223	/* No text sent -- stat, next, last */
+ #define	OK_OVER		224	/* Overview data follows */
  #define	OK_NEWNEWS	230	/* New articles by message-id follow */
  #define	OK_NEWGROUPS	231	/* New newsgroups follow */
  #define	OK_XFERED	235	/* Article transferred successfully */


diff -rc nntp1.5.11/server/group.c nntp1.5.11+over/server/group.c
*** nntp1.5.11/server/group.c	Thu Jul  5 03:29:15 1990
--- nntp1.5.11+over/server/group.c	Wed Dec 23 12:00:37 1992
***************
*** 108,110 ****
--- 108,186 ----
  		argv[1]);
  	(void) fflush(stdout);
  }
+ 
+ 
+ #ifdef XOVER
+ doxover(argc, argv)
+ 	int		argc;
+ 	char		*argv[];
+ {
+ 	register FILE	*fp;
+ 	register int	c, first, last;
+ 	int		artnum;
+ 	char		*p;
+ 
+ 	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 != 1 & argc != 2) {
+ 		printf("%d Usage: XOVER [first[-last]].\r\n", ERR_CMDSYN);
+ 		(void) fflush(stdout);
+ 		return;
+ 	}
+ 
+ 	fp = fopen(".overview", "r");
+ 	if (fp == NULL) {
+ 		printf("%d No overview available.\r\n", ERR_FAULT);
+ 		(void) fflush(stdout);
+ #ifdef SYSLOG
+ 		syslog(LOG_ERR, "xover: fopen %s: %m", ".overview");
+ #endif
+ 		return;
+ 	}
+ 
+ 	/* Return the desired data.  This is written carefully to avoid
+ 	 * over-long lines. */
+ 	printf("%d overview data follows\r\n", OK_OVER);
+ 	if (argc == 1) {
+ 		while ((c = getc(fp)) != EOF) {
+ 			if (c == '\n')
+ 				(void) putchar('\n');
+ 			putchar(c);
+ 		}
+ 	}
+ 	else {
+ 		p = index(argv[1], '-');
+ 		if (p == NULL)
+ 			first = last = atoi(argv[1]);
+ 		else {
+ 			*p++ = '\0';
+ 			first = atoi(argv[1]);
+ 			last = atoi(p);
+ 		}
+ 		while (!feof(fp) && fscanf(fp, "%d", &artnum) == 1) {
+ 			if (first <= artnum && artnum <= last) {
+ 				printf("%d", artnum);
+ 				while ((c = getc(fp)) != EOF && c != '\n')
+ 					putchar(c);
+ 				printf("\r\n");
+ 			}
+ 			else
+ 				while ((c = getc(fp)) != EOF && c != '\n')
+ 					continue;
+ 		}
+ 	}
+ 	printf(".\r\n");
+ 	(void) fflush(stdout);
+ }
+ #endif


diff -rc nntp1.5.11/server/help.c nntp1.5.11+over/server/help.c
*** nntp1.5.11/server/help.c	Thu Jul  5 03:29:15 1990
--- nntp1.5.11+over/server/help.c	Wed Dec 23 11:12:17 1992
***************
*** 23,28 ****
--- 23,32 ----
  	printf("IHAVE       NEWNEWS      SLAVE\r\n");
  	printf("\r\nAdditionally, the following extention is supported:\r\n\r\n");
  	printf("XHDR        Retrieve a single header line from a range of articles.\r\n");
+ #ifdef	XOVER
+ 	printf("\r\nAlso supported:\r\n");
+ 	printf("XOVER       Return news overview data\r\n");
+ #endif
  	printf("\r\n");
  	printf("Bugs to Stan Barber (Internet: nntp@tmc.edu; UUCP: ...!bcm!nntp)\r\n");
  	printf(".\r\n");


diff -rc nntp1.5.11/server/serve.c nntp1.5.11+over/server/serve.c
*** nntp1.5.11/server/serve.c	Thu Jan 10 18:20:08 1991
--- nntp1.5.11+over/server/serve.c	Wed Dec 23 11:13:31 1992
***************
*** 33,38 ****
--- 33,41 ----
  #ifdef AUTH
  extern	int	doauth();
  #endif AUTH
+ #ifdef XOVER
+ extern	int	doxover();
+ #endif
  
  static struct cmdent {
  	char	*cmd_name;
***************
*** 61,66 ****
--- 64,72 ----
  #ifdef XHDR
  	"xhdr",		0,	xhdr,
  #endif XHDR
+ #ifdef XOVER
+ 	"xover",	0,	doxover,
+ #endif
  };
  #define NUMCMDS (sizeof(cmdtbl) / sizeof(struct cmdent))
  

