From: davison@borland.com (Wayne Davison)
Subject: Accessing the history file via NNTP
Organization: Borland International
Date: Mon, 4 Jan 1993 20:24:08 GMT

I've been playing around with ideas for more advanced newsreaders, and one
of the things that came up in my investigations is that there's no way in
NNTP to go from message-id to article number.  Thus, this patch.

What I've done only affects the ARTICLE/HEAD/BODY/STAT commands IFF you've
previously issued a GROUP command.  In this case the article number in the
status line (which was previously hard-wired to 0) will be set to the correct
article number in the current group.  If the indicated article is not in
the current group, a 0 is returned as before.

This is a good first step.  However, I can also see needing to go from
message-id to newsgroup list, so perhaps there is a need for a new
command, such as XHIST, to return the portion of the history line that
lists the groups and article numbers?  This would come in handy if a
newsreader was following a back reference, found it to exist but not
in the current group -- where is it?  If it has no xrefs line, you're
currently stuck.

Comments?  Does the spec. for NNTP's successor cover this?
-- 
Wayne Davison
davison@borland.com
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index:server/ahbs.c
***************
*** 57,62 ****
  			return;
  		}
! 		printf("%d 0 %s Article retrieved, %s.\r\n",
! 			OK_ARTICLE + method, argv[1], verbiage[method]);
  		spew(fp, method);
  		(void) fclose(fp);
--- 57,63 ----
  			return;
  		}
! 		printf("%d %ld %s Article retrieved, %s.\r\n",
! 			OK_ARTICLE + method, group_artnum, argv[1],
! 			verbiage[method]);
  		spew(fp, method);
  		(void) fclose(fp);
Index:server/common.h
***************
*** 170,173 ****
--- 170,175 ----
  extern	char	*homedir;
  extern	int	ingroup;
+ extern	char	*group_name;
+ extern	long	group_artnum;
  extern	int	maxgroups;
  #ifdef DYNAMIC_ART_ARRAY
Index:server/globals.c
***************
*** 35,38 ****
--- 35,40 ----
  int	num_groups;
  int	ingroup = 0;
+ char	*group_name = NULL;
+ long	group_artnum = 0;
  int	art_ptr;
  int	num_arts;
Index:server/group.c
***************
*** 70,73 ****
--- 70,75 ----
  	close_crnt();
  	(void) chdir(spooldir);
+ 	if ((group_name = malloc(strlen(argv[1])+1)) != NULL)
+ 		strcpy(group_name, argv[1]);
  
  #ifdef LOG
Index:server/misc.c
***************
*** 101,105 ****
  {
  	char		line[MAXBUFLEN];
! 	char		*tmp;
  	register char	*cp;
  	long		ltmp;
--- 101,105 ----
  {
  	char		line[MAXBUFLEN];
! 	char		*start, *end;
  	register char	*cp;
  	long		ltmp;
***************
*** 119,122 ****
--- 119,123 ----
  	static FILE	*hfp = NULL;	/* history file, text version */
  
+ 	group_artnum = 0;
  #ifdef CNEWS
  	cp = rindex(msg_id,'@');	/* look for @ in message id */
***************
*** 235,244 ****
  #endif SYSLOG
  	if (cp == NULL) return(NULL); /* this article has expired */
- 	tmp = cp+1;
  
! 	if ((cp = index(tmp, ' ')) != NULL)
  		*cp = '\0';
! 	
! 	while ((cp = index(tmp, '.')) != NULL)
  		*cp = '/';
  
--- 236,258 ----
  #endif SYSLOG
  	if (cp == NULL) return(NULL); /* this article has expired */
  
! 	if (group_name) {
! 		end = cp;
! 		do {
! 			if ((end = index(start = end+1, ' ')) != NULL)
! 				*end = '\0';
! 
! 			if ((cp = index(start, '/')) != NULL) {
! 				*cp = '\0';
! 				if (!strcmp(start, group_name))
! 					group_artnum = atol(cp+1);
! 				*cp = '/';
! 			}
! 		} while (!group_artnum && end != NULL);
! 	}
! 	else if ((cp = index(start = cp+1, ' ')) != NULL)
  		*cp = '\0';
! 
! 	while ((cp = index(start, '.')) != NULL)
  		*cp = '/';
  
***************
*** 245,249 ****
  	(void) strcpy(path, spooldir);
  	(void) strcat(path, "/");
! 	(void) strcat(path, tmp);
  #ifdef USGHIST
  	(void) fclose(hfp);
--- 259,263 ----
  	(void) strcpy(path, spooldir);
  	(void) strcat(path, "/");
! 	(void) strcat(path, start);
  #ifdef USGHIST
  	(void) fclose(hfp);
***************
*** 482,488 ****
  close_crnt()
  {
! 	if (art_fp != NULL)
  		(void) fclose(art_fp);
! 	art_fp = NULL;
  }
  
--- 496,507 ----
  close_crnt()
  {
! 	if (art_fp != NULL) {
  		(void) fclose(art_fp);
! 		art_fp = NULL;
! 	}
! 	if (group_name) {
! 		free(group_name);
! 		group_name = NULL;
! 	}
  }
  
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Newsgroups: news.software.nntp