hname = "T:headers.$CLINUM"
aname = "T:article.$CLINUM"
header = yes

while read line
do
	if [ "$line" = "" ]
	then
		header = no
	elif [ "$header" = "yes" ]
	then
#		These are all removed during the filtering that RELAYNEWS does:
#			Xref:, Article-I.D., Lines, Date-Received, Received, Posted,
#			Posting-Version, Relay-Version, Ollegal-Object
		x = $(expr index ':' "$line")
		inc x
		text = $(expr substr "$line" x 9999)
		case "$line" in
		Newsgroups:*)	N_NGRP = $text;;
		From:*)			N_FROM = $text;;
		Date:*)			N_DATE = $text;;
		Subject:*)		N_SUBJECT = $text;;
		Distribution:*)	N_DISTR = $text;;
		Organization:*)	N_ORGAN = $text;;

		Path:*)			true ;;		# Ignore Path: and Message-ID: headers
		Message-ID:*)	true ;;
		Approved:*)		true;; # N_APPROVED = $text;;
		Sender:*)		true;; # N_SENDER = $text;;
		Control:*)		true;; # N_CONTROL = $text;;
		Also-Control:*)	true;; # N_ALSOCONTROL = $text;;
		Keywords:*)		true;; # N_KEYWORD = $text;;
		Comments:*)		true;; # N_COMMENT = $text;;
		Expires:*)		true;; # N_EXPIRE = $text;;
		References:*)	true;; # N_REFER = $text;;
#		X-*:*)			echo "$line" >> $hname;;
		*:*)			echo "$line" >> $hname;;
		esac
	else
		echo "$line" >> $aname
	fi
done

if [ "$N_NEWSGROUP" = "" ]; then Error = "Newsgroup: is required!"; fi
if [ "$N_FROM" = "" ]; then N_FROM = $(C:GetEnv USERNAME); fi
if [ "$N_DATE" = "" ]; then N_DATE = $(parsedate $N_DATE); fi
if [ "$N_DATE" = "" ]; then Error = "Date: is invalid!"; fi
if [ "$N_SUBJECT" = "" ]; then Error = "Subject: is required!"; fi
if [ "$N_DISTR" = "" ]; then N_DISTR = "na"; fi
if [ "$N_ORGAN" = "" ]; then N_ORGAN = "Edwards & Edwards Consulting"; fi

if [ "$Error" != "" ]
then
	echo "$Error"
	return 5
fi
