#ident	"@(#)nlp.admin:menu/packagemgmt/lpmgmt/filters/list_f	1.5"
## IDOC:   SCREEN 2.46: LIST FILTERS
#menu# List available filters

##+++ (help _H136)
#help#        You  use  the  "list"  command in the "filters" menu to  see
#help#        the  definitions  of one or more filters.  You can examine a
#help#        particular filter, or can see all the filters on the system.
##--- (help _H136)

##+++ (general)
echo "
Whenever you want to quit, type \"q\".
If you are not sure how to answer any prompt, type \"?\" for help,
or see the System Administrator's Guide.

If a default appears in the question, press the return key to use it.
"
##--- (general)

trap 'exit 0' 1 2 15
flags="-qq -k$$"

##+++ (functions)
chk_name () {
	RESP=`checkre ${flags} -fe $4 \
		${2:+"-D$2"} -H "$3" \
		"$1${SyStSt:+!name!}" \
		'^[a-zA-Z0-9_]\{1,14\}$' \
			'A name can contain only 1 to 14 letters, digits, and underscores.' \
	`
}
chk_filter_list () {
# listof: filter-name
    while true; do
	RESP=`checkre ${flags} -fe \
		-H "$3" \
		"$1${SyStSt:+!filter-list!}" \
		$4 \
		'.*' ''`
	RESP=`echo "${RESP}" | tr ',' ' '`
	if [ -z "${RESP}" ]; then : ${RESP:="$2"}; fi
	if [ -z "${RESP}" ]; then : ; else if ( set -- ${RESP}
		while [ $# -gt 0 ]; do
			echo "$1" \
			| ( flags="-m1"; chk_name >/dev/null 2>&1 ) || exit 1
			shift
		done; exit 0
	); then return 0; fi
	fi
	echo '	You did not give a valid filter name.
	Separate multiple items with a comma or blank.'
    done
}
##--- (functions)

DEF_f=`cat ${TMPDIR:-/tmp}/FLT.\`basename \\\`tty\\\`\` 2>/dev/null`
while true
do
##+++ (line 1)
echo \
"Enter the names of the filters for which you
want to see a complete description.
Separate multiple names with a space or comma."
##--- (line 3)


##+++ (2.46.4)
chk_filter_list \
	"${DEF_f:+(default: ${DEF_f})}" \
	"${DEF_f}" \
	"\
        You are expected to enter the name of the filter you'd  like
        to  examine.   You can enter the names of several filters by
        separating their names with spaces or commas.  \
"
OPT_f=${RESP}
##--- (2.46.4)

##+++ (line 5)
echo \
"
Filter descriptions:"
##--- (line 9)

	repeat=no
	for filter in ${OPT_f}
	do
		echo "
Filter: ${filter}"
		/usr/lib/lpfilter -f ${filter} -l || repeat=yes
	done

	if [ "no" = "${repeat}" ]
	then
		break
	else
		echo
	fi
done
