#! /bin/ksh

Report-header Programs

line1=.LN1
line2=.LN2

echo "$line1
This report contains details of all the programs in the survey,
sorted by program code.  The report begins with a table of
contents containing:
.IB
the 'code' for the program, based on the institution and unit
.IB
the 'shortname' for the institution and academic unit
.lp
Entries in the main part of the report begin with the program
code, the shortname, and:
.lp
.IP CONTACT
the name and title of the person to contact
about the HCI program (see the Data file for
the program for application information)
.IP EMAIL
the electronic mail address of the contact
.IP PHONE
the phone number of the contact
.IP FAX
the FAX number of the contact
.IP ADDRESS
tha mailing address of the contact
.IP DEGREES
degrees offered by the program
.IP HCI_THESES
recent (last five years) theses in HCI
.IP HCI_STUDENTS
current HCI students at PhD and Masters levels
.IP DESCRIPTION
description of the program's academic unit
.IP FACILITIES
computing and other facilities of the unit
.IP PROGRAM
description of the HCI program in the unit
.IP HCI_FACULTY
name (and email) of HCI faculty in the unit
.IP OTHER_FACULTY
names (and possibly other information) of
other HCI faculty at the institution, but not
in the academic unit
.lp
$line2"

echo '.uh "Table of Contents"'
for i in ${*-*}
do
	sssearch section=unit $i |
		ssadd -f codename -t "${i##*/}"
done | ssformat -t '.TC .35i "%codename" +1.5i "%shortname"'

template_contact="$line1
.IP CONTACT:
%contact, %title
.IP EMAIL:
%email
.IP PHONE:
%phone
.IP FAX:
%fax
.IP ADDRESS:
.nf
%address
.fi"

template_unit="\
.IP DEGREES:
%degrees
.nf
.if n .ta 1.5i +10n +10n +10n
.if n .ta 25n +10n +10n +10n
.lp
.nf
\s-2RECENT_HCI_THESES:\s0	PhD:	%3HCI_PhD_Theses	Masters:	%3HCI_MS_Theses
\s-2CURRENT_HCI_STUDENTS:\s0	PhD:	%3HCI_PhD_Curren	Masters:	%3HCI_MS_Current
.fi
.IP DESCRIPTION:
%description
.br
.IP FACILITIES:
%facilities
.br"

template_program=".IP PROGRAM:
%Program"

function clean
	{
	sed '/^+$/d
		s/ \([*-]\) /.ip " \1"\
/' $*
	}

for i in ${*-*}
do
	# INSTITUTION BANNER
	echo .bp
	echo "$line2 ${i##*/}"
	sssearch section=unit $i |
		ssformat -t '.sh 1 "%shortname"'
	# CONTACT SECTION
	sssearch section=program $i |
		ssformat -t "$template_contact" |
			clean
	# UNIT INFO
	sssearch section=unit $i |
		ssfill -f degrees,desc,facil -w 1000 |
			ssformat -t "$template_unit" |
				clean
	sssearch section=program $i |
		ssfill -f program -w 1000 |
			ssformat -t "$template_program" |
				clean
	# FACULTY INFO
	echo ".IP HCI_FACULTY:"
	sssearch section=faculty $i |
		ssformat -t ".IB
%name (%email)"
	other=`sssearch section=program $i | ssformat -t "%other" | clean`
	if test "$other" != ""
	then
		echo ".IP OTHER_FACULTY:
$other" | clean
	fi
done 

exit
