[net.news.b] ARPA std header problem with news 2.10, fix

teus@haring.UUCP (01/29/84)

In a try to send news internaly via sendmail (so via the LAN) to the
different machines, I met the problem that sendmail (according to its
configuration file) gave the "Message-ID:" and news was expecting"Message-Id".
So news cq header.c should accept capitals and non-capitals in the header
keywords. The fix is given below to the routine type() in header.c.

Next certain header lines, which are prepended by sendmail can be handled
by recnews. The article has already seen the internals of news, so
the filter is only small in this case. So via the keyword "Relay-Version:"
recnews switches to the state "has already seen inews internals".
The article can be forwarded to "inews -p".
The fix to recnews.c is given below.

************* CHANGES to header.c, swap the type() routine ***********
#define its(type) (prefix(buff, type))
type(ptr)
char	*ptr;
{
	char	*colon, *space;
	register char *cptr;
	register int i;
	char buff[128];

	if (!isalpha(*ptr) && strncmp(ptr, "From ", 5))
		return FALSE;
	/* this really needs a better fix */
	colon = index(ptr, ':');
	space = index(ptr, ' ');
	if( !space )
		space = index(ptr, '\t');
		
	if (!colon || colon + 1 != space)
		return FALSE;
	for( i = 0, cptr = ptr; cptr <= colon+1 && i<128; cptr++ )
		buff[i++] = isupper(*cptr)?tolower(*cptr):*cptr;
	buff[i] = '\0'; /* just to be sure */
	if (its("from:"))
		if (index(ptr, '@') && !index(ptr, '!') && seenrelay)
			return FROM;
		else
			return PATH;
	if (its("path:"))
		return PATH;
	if (its("newsgroups:"))
		return NEWSGROUP;
	if (its("subject:") || its("title:"))
		return TITLE;
	if (its("posted:") || its("date:"))
		return SUBMIT;
	if (its("date-received:") || its("received:"))
		return RECEIVE;
	if (its("expires:"))
		return EXPIRE;
	if (its("article-i.d.:"))
		return ARTICLEID;
	if (its("message-id:"))
		return MESSAGEID;
	if (its("reply-to:"))
		return REPLYTO;
	if (its("references:"))
		return FOLLOWID;
	if (its("control:"))
		return CONTROL;
	if (its("sender:"))
		return SENDER;
	if (its("followup-to:"))
		return FOLLOWTO;
	if (its("posting-version:"))
		return POSTVERSION;
	if (its("relay-version:"))
		return RELAYVERSION;
	if (its("distribution:"))
		return DISTRIBUTION;
	if (its("organization:"))
		return ORGANIZATION;
	if (its("lines:"))
		return NUMLINES;
	if (its("keywords:"))
		return KEYWORDS;
	if (its("approved:"))
		return APPROVED;
	return OTHER;
}
******************* END of CHANGES to header.c *********************
*** CHANGES to recnews.c **************************************************
***************
  #define EOM	005		/* End of message (4 ctrl A's) */
  #define HEADER	006		/* any unrecognized header */
  #define TEXT	007		/* anything unrecognized */
+ /* fix to spread news internaly via mail */
+ #define	INCLUSIVE 010	/* Subject, newsgroup is included in header */
+ 				/* This has already seen the inside of inews */
  /*
   * Possible states program can be in.
***************
  #endif
  	state = SKIPPING;
  	while (fgets(buf, BFSZ, stdin) != NULL) {
- 		t = type(buf) | state;
  #ifdef debug
- 		printf("%o\t%s", t, buf);
  #endif
***************
  	state = SKIPPING;
  	while (fgets(buf, BFSZ, stdin) != NULL) {
  #ifdef debug
+ 		t = type(buf);
+ 		fprintf(stderr,"type: %o, ", t);
+ 		fprintf(stderr,"state: %s, %s\t",state==READING?"READING":"SKIPPING",buf);
  #endif debug
+ 		if( state == READING )
+ 		{	fputs(buf, pipe);
+ 			continue;
+ 		}
+ #ifdef debug
+ 		switch (t) {
+ #else debug
+ 		switch( type(buf) ) {
  #endif
  
! 		case FROM:

***************
*** 124,129
  #else debug
  		switch( type(buf) ) {
  #endif
! From here remove all "case <TYPE> | READING" statements.
! Change all "case <TYPE> | SKIPPING" to "case <TYPE>:".
***************
*** 147,166
  			to[strlen(to)-1] = 0;	/* strip trailing \n */
  			break;
  			
+ 		case INCLUSIVE: /* just met an article, which
+ 				saw the internals of inews already */
+ 			sprintf(cmdbuf, "%s -p", INEWS);
+ #ifdef debug
+ 			pipe = stdout;
+ 			fprintf(stderr,"INCLUSIVE: %s\n", cmdbuf);
+ #else debug
+ 			pipe = popen(cmdbuf, "w");
+ 			if( pipe == NULL ) {
+ 				perror("recnews: popen failed");
+ 				exit(1);
+ 			}
+ #endif debug
+ 			state = READING;
+ 			fputs(buf, pipe);
+ 			break;
  

 		case HEADER:
  			break;
  
  		case BLANK:
************** END of recnews.c changes *************************
-- 
	Teus Hagen	teus@mcvax.UUCP  (CWI, Amsterdam)
-- 
	Teus Hagen	teus@mcvax.UUCP  (CWI, Amsterdam)