#!/bin/sh

# Generated by nn release 6.7.3 (NOV) at Jun 25 04:18

VERSION="6.7.3 (NOV)"
AWK="awk"
NOV=true
NNTP=true
ACTIVE=/usr/lib/nn/.nn/ACTIVE
NNTPCACHE=
LOG=null
TMP=${TMPDIR-/var/tmp}
DB=/usr/lib/nn/.nn
BIN=/usr/bin
LIB=/usr/lib/nn
AUTH=false

# ---- end of prefix


# PREFIX is inserted above this line during Make

trap : 2 3

PATH=/bin:$PATH

# The .param file is found in $NNDIR/.param.  Formerly this was
# hardcoded, but with the nn-directory variable that no longer works.

if [ -z "$NNDIR" ]; then NNDIR=$HOME/.nn; fi

# Paramaters transferred from nn via .param file:
#	ART_ID		Article id to cancel
#	GROUP		Group of article to cancel
#	WORK		Temporary file for response (w initial contents)
#	FIRST_ACTION	First action to perform
#	EMPTY_CHECK	[empty-response-check]
#	EDITOR		[editor]
#	ED_LINE		First line of body in WORK file
#	SPELL_CHECKER	[spell-checker]
#	PAGER		[pager]
#	APPEND_SIG	[append-signature]
#	QUERY_SIG	[query-signature]
#	NOVICE		[expert]
#	WAIT_PERIOD 	[response-check-pause]
#	RECORD		[mail/news-record]
#	MMDF_SEP	[mmdf-format = ^A^A^A^A]
#	POST		[inews]
#	POST_PIPE	[inews-pipe-input]
#	POSTER_ADR	Reply address for follow-ups
#	MAILER		[mailer]
#	MAILER_PIPE	[mailer-pipe-input]
#	DFLT_ANSW	[response-default-answer]
#	ALIAS_EXPANDER	[mail-alias-expander]
#	CHSET_NAME	[charset]
#	CHSET_WIDTH	Charset width
#	DIST		distribution of cancelled article

CC=""

case "$1" in
COMPLETE)
  . $NNDIR/hold.param
  WORK="$2"
  EMPTY_CHECK=false
  cp $NNDIR/hold.work $WORK
  rm -f $NNDIR/hold.*
  ;;
*)
  . $NNDIR/.param
  OPERATION=$1
  ;;
esac

# first we handle 'cancel'

case "$OPERATION" in
cancel)
  TRACE="$2"
  CAN=${TRACE}can

  echo "Newsgroups: ${GROUP}" > $CAN
  echo "Subject: cmsg cancel $ART_ID" >> $CAN
  echo "Control: cancel $ART_ID" >> $CAN
  if [ $DIST != "none" ] ; then
    echo "Distribution: $DIST" >> $CAN
  fi
  echo "" >> $CAN
  echo "cancel $ART_ID in newsgroup $GROUP" >> $CAN
  echo "" >> $CAN
  echo "This article was cancelled from within NN version $VERSION" >> $CAN

  $INEWS -h < $CAN > $TRACE 2>&1

  x=$?
  case $x in
  0)
    ;;
  *)
    echo ''
    cat $TRACE
    sleep 2
    ;;
  esac
  rm -f $TRACE
  exit $x
  ;;
post|follow)
  LOOKFOR="Newsgroups:"
  SEND="post"
  SENT="posted"
  SENDPR="p)ost"
  MESSAGE="article"
  ;;
*)
  LOOKFOR="To:"
  SEND="send"
  SENT="sent"
  SENDPR="s)end"
  MESSAGE="letter"
  ;;
esac

TRACE=${WORK}T
FINAL=${WORK}F
TEMP=${WORK}M
COPY=""

case "$FIRST_ACTION" in
send)
  ;;
*)
  COPY=${WORK}C
  cp $WORK $COPY
  ;;
esac

# loop until sent or aborted.

loop=true
changed=true
prompt=false
addchset=false

pr="a)bort"
case "$POSTER_ADR" in
?*)
  pr="$pr c)c"
  ;;
esac
pr="$pr e)dit h)old"
case "$SPELL_CHECKER" in
?*)
  pr="$pr i)spell"
  ;;
esac
pr="$pr S)ign"
pr="$pr m)ail"
case "$OPERATION" in
post|follow)
  pr="$pr p)ost"
  ;;
esac
pr="$pr r)eedit"
case "$OPERATION" in
post|follow)
  ;;
*)
  pr="$pr s)end"
  ;;
esac
pr="$pr v)iew w)rite"

case "$DFLT_ANSW" in
  p*|s*)
    pr1=" ($SEND $MESSAGE)"
    ;;
  "")
    pr1=""
    ;;
  *)
    pr1=" ($DFLT_ANSW)"
    ;;
esac

while $loop ; do
  case $changed in
  true)
    case "$FIRST_ACTION" in
    edit)
      ;;
    *)
      # this works for v6/v7/bsd/sysv tr
      sed -e '1,/^$/d' $WORK | tr -d '[\1-\177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You must delete them or select an 8-bit character set from nn."
          echo "In its current form the $MESSAGE cannot be $SENT."
	  ;;
	esac
	case "$CHSET_NAME" in
	""|unknown)
	  addchset=false
	  ;;
	*)
	  addchset=true
	  ;;
	esac
      else
        pr2=""
	cansend=true
	177]' > $TEMP
      if test -s $TEMP ; then
        pr2=" 7)bit"
        case "$CHSET_WIDTH" in
	8)
	  cansend=true
	  ;;
	*)
	  cansend=false
	  echo
          echo "Warning: body of $MESSAGE contains 8-bit characters"
          echo "You