[net.news.b] Mods to news 2.10 to get rid of ugly notes headers

rees@apollo.uucp (Jim Rees) (02/29/84)

There are sites on the net running notesfiles, which is an alternate
way to get and read the news.  There are two versions of notesfiles,
old and new.  The old style truncates subject lines to 40 characters
and appends " - (nf)" to the subject, and puts three extra lines in
the body of the article that look something like this:

    #R:inuxc:-91400:uicsl:4900006:000:149
    uicsl!wombat    Feb 17 16:02:00 1984

The older notesfiles also throws out many of the useful news 2.10
headers, like "References:".

The newer version of notesfiles, as modified by Tw Cook at HP Portable
Computer Division, hp-pcd!tw, puts those annoying lines into the header
where they belong, doesn't do nasty things to subject lines, and doesn't
drop any of the 2.10 headers.

You can modify your version of news 2.10 to translate old notesfiles
articles into new.  This will rid you of the " - (nf)" on the subject
line and get rid of those two lines that look like a modem spit up.

There are a few cautions, though.  Tw Cook issues the following admonition:

  If you have any immediate neighbors running notes, I'd recommend against
  doing the translation.  The only essential reason for keeping that
  information around is that notes needs to be able to reject as duplicates
  articles that it transmits to news which somehow come back.  Under the old
  system, notes just runs inews (as though it were a user) to newsinput
  articles; this means that it has no control over headers or article-id, so
  the only way it has of recognizing an article that it generated is by those
  lines in the text. Also, since it looks like a user rather than another
  system to the local news software, a copy gets shipped right back into
  notes.  The 2 header lines are essential in detecting this as a duplicate
  article, rather than as some new article from elsewhere.  If you eliminate
  those, and the article somehow gets shipped back to the originating notes
  system (whose notes gateway needs them to recognize duplicates) they'll be
  screwed.  I guess it depends on what your local usenet topology looks
  like.

With that in mind, here is how to notes-proof your news system.

DO NOT INSTALL THESE CHANGES UNLESS YOU HAVE READ AND UNDERSTAND THE
ABOVE WARNING.  The last thing we need is more duplicates on the net.

Here is a sample article, before and after passing through a site running
the modified version of news 2.10:

  Relay-Version: version B 2.10.1 6/24/83; site wivax.UUCP
  Path: wivax!decvax!harpo!ulysses!burl!hou3c!hocda!houxm!ihnp4!inuxc!pur-ee!uiucdcs!uicsl!wombat
  From: wombat@uicsl.UUCP
  Newsgroups: net.games.frp
  Subject: Re: Runequest - Try It! - (nf)
  Message-ID: <5720@uiucdcs.UUCP>
  Date: Fri, 17-Feb-84 22:45:36 EST
  Date-Received: Tue, 21-Feb-84 03:16:14 EST
  Lines: 6

  #R:inuxc:-91400:uicsl:4900006:000:149
  uicsl!wombat    Feb 17 16:02:00 1984

  But from the sounds of RuneQuest III, I'd recommend getting a copy of
  RQ II and using that. RQ III sounds more like D&D than RuneQuest.
  						Wombat

  Relay-Version: version B 2.10 Apollo; site apollo.uucp
  Path: apollo!wivax!decvax!harpo!ulysses!burl!hou3c!hocda!houxm!ihnp4!inuxc!pur-ee!uiucdcs!uicsl!wombat
  From: wombat@uicsl.UUCP
  Newsgroups: net.games.frp
  Subject: Re: Runequest - Try It!
  Message-ID: <5720@uiucdcs.UUCP>
  Date: Fri, 17-Feb-84 22:45:36 EST
  Date-Received: Tue, 21-Feb-84 15:56:49 EST
  Lines: 3
  Nf-ID: #R:inuxc:-91400:uicsl:4900006:000:149
  Nf-From: uicsl!wombat    Feb 17 16:02:00 1984

  But from the sounds of RuneQuest III, I'd recommend getting a copy of
  RQ II and using that. RQ III sounds more like D&D than RuneQuest.
						Wombat

Changes to inews.c, in routine input():

***************
*** 658,663
   				consec_newlines--;
  				linecount++;
   			}
   		}
  		if (mode != PROC && tty && strcmp(bfr, ".\n") == 0)
  			break;

--- 761,772 -----
   				consec_newlines--;
  				linecount++;
   			}
+ #ifdef ZAPNOTES
+ 			if (empty && bfr[0] == '#' && bfr[2] == ':') {
+ 				fixnotes(&header);
+ 				continue;
+ 			}
+ #endif
   		}
  		if (mode != PROC && tty && strcmp(bfr, ".\n") == 0)
  			break;
***************
*** 718,723
  		sprintf(header.numlines, "%d", linecount);
  	}
  }
  
  /*
   * Make the directory for a new newsgroup.  ngname should be the

--- 827,885 -----
  		sprintf(header.numlines, "%d", linecount);
  	}
  }
+ 
+ #ifdef ZAPNOTES
+ /*
+  * Remove that obnoxious " - (nf)" from the title and move those
+  * obnoxious notes headers out of the body of the message.
+  */
+ fixnotes(hp)
+ struct hbuf *hp;
+ {
+ 	int i;
+ 	char *cp;
+ 	char *AlloCatCpy();
+ 
+ 	for (i = 0; i < NUNREC; i++)
+ 		if (hp->unrec[i] == NULL)
+ 			break;
+ 	if (i < NUNREC)
+ 		hp->unrec[i++] = AlloCatCpy("Nf-ID: ", bfr);
+ 	fgets(bfr, BUFLEN, stdin);
+ 	if (i < NUNREC)
+ 		hp->unrec[i++] = AlloCatCpy("Nf-From: ", bfr);
+ 	fgets(bfr, BUFLEN, stdin);
+ 
+ 	/*
+ 	 * Nuke the line count.  Should maybe correct
+ 	 * for the size of the notes header and
+ 	 * regenerate instead, but who cares?
+ 	 */
+ 	hp->numlines[0] = '\0';
+ 
+ 	/* Strip trailing " - (nf)" */
+ 	if ((cp = rindex(hp->title, '-')) != NULL && !strcmp(--cp, " - (nf)"))
+ 		*cp = '\0';
+ 	log("Stripped notes header on %s", hp->ident);
+ }
+ 
+ /*
+  * Concatenate the two arguments into one string, allocate space to
+  * hold it, and copy the string into the allocated space.  Not
+  * very general-purpose, eh?
+  */
+ char *
+ AlloCatCpy(s1, s2)
+ char *s1, *s2;
+ {
+ 	char *cp;
+ 
+ 	if ((cp = malloc(strlen(s1) + strlen(s2) + 1)) == NULL)
+ 		return NULL;
+ 	sprintf(cp, "%s%s", s1, s2);
+ 	return cp;
+ }
+ #endif
  
  /*
   * Make the directory for a new newsgroup.  ngname should be the