xref: /csrg-svn/old/vpr/vtroff.sh (revision 42855)
14008Ssklower#! /bin/csh -f
27692Smckusick#
3*42855Skarels#	@(#)vtroff.sh	4.5	(Berkeley)	06/02/90
47692Smckusick#
51860Srootumask 0
69330Speterset flags=() noglob length=() fonts=() fontf=()
71860Srootunset t
8*42855Skarelsset macp = (/usr/share/tmac/tmac.vcat)
9*42855Skarelsset sort = (/usr/libexec/rvsort)
10*42855Skarelsset lpr = (/usr/bin/lpr -Pvarian)
1116438Sralphset troff = (/usr/bin/troff)
121860Sroottop:
131860Sroot	if ($#argv > 0) then
141860Sroot		switch ($argv[1])
151860Sroot		case -t:
161860Sroot			set t
171860Sroot			shift argv
181860Sroot			goto top
191860Sroot		case -l*:
201860Sroot			set length = $argv[1]
211860Sroot			shift argv
221860Sroot			goto top
231860Sroot		case -V:
24*42855Skarels			set sort = (/usr/libexec/rvsort)
25*42855Skarels			set lpr = (/usr/bin/lpr -Pvarian)
261860Sroot			shift argv
271860Sroot			goto top
281860Sroot		case -W:
29*42855Skarels			set sort = (/usr/libexec/vsort -W)
30*42855Skarels			set lpr = (/usr/bin/lpr -Pversatec)
311860Sroot			shift argv
321860Sroot			goto top
3316438Sralph		case -h:
3416438Sralph			if ($#argv < 2) then
3516438Sralph				echo -h takes following host name.
3616438Sralph				exit(1)
3716438Sralph			endif
3816438Sralph			set host = $argv[2]
3916438Sralph			shift argv
4016438Sralph			shift argv
4116438Sralph			goto top
421860Sroot		case -F:
431860Sroot			if ($#argv < 2) then
441860Sroot				echo -F takes following font name.
451860Sroot				exit(1)
461860Sroot			endif
471860Sroot			set argv=(-1 $2.r -2 $2.i -3 $2.b $argv[3-])
481860Sroot			goto top
491860Sroot		case -1:
501860Sroot		case -2:
511860Sroot		case -3:
521860Sroot			if ($#argv < 2) then
531860Sroot				echo $1 takes following font name.
541860Sroot				exit(1)
551860Sroot			endif
561860Sroot			if (! -r /usr/lib/fontinfo/$2) then
571860Sroot				if (! -r /usr/lib/fontinfo/$2.r) then
581860Sroot					echo ${2}: font not found.
591860Sroot					exit(1)
601860Sroot				endif
611860Sroot				set argv[2] = $2.r
621860Sroot			endif
631860Sroot			if ($#fonts == 0) then
641860Sroot				set fontf=/usr/tmp/fnt$$
651860Sroot				cp /dev/null $fontf
661860Sroot			endif
671860Sroot			@ fnum = 0 - $1
681860Sroot			echo .nr p $fnum >> $fontf
691860Sroot			cat /usr/lib/fontinfo/$2 >> $fontf
701860Sroot			set fonts=($fonts $1 $2)
711860Sroot			shift argv
721860Sroot			shift argv
731860Sroot			goto top
741860Sroot		case -x:
751860Sroot			set macp=()
761860Sroot			shift argv
771860Sroot			goto top
781860Sroot		case -*:
791860Sroot			set flags = ($flags $argv[1])
801860Sroot			shift argv
811860Sroot			goto top
8215215Sralph		case -:
8315215Sralph			breaksw
841860Sroot		endsw
851860Sroot	endif
8616438Sralph
871860Srootif ($#argv == 0) then
881860Sroot	set argv=(-)
8912735Sralph	set banner=vtroff
9012735Sralphelse
9112735Sralph	set banner=$argv[1]
921860Srootendif
9316438Sralph
9416438Sralphset tflags=(-t -rv1 $flags $macp $fontf)
9516438Sralph
9616438Sralphif ($?host) then
9716438Sralph    if ($#fontf) then
9816438Sralph	echo vtroff -h does not support changing fonts -- run vtroff locally
9916438Sralph	exit(1)
10016438Sralph    endif
10116438Sralph    if ($?t) then
10216438Sralph	soelim $* | rsh $host \"$troff $tflags - | $sort $length\"
10316438Sralph    else
10416438Sralph	soelim $* | rsh $host \"$troff $tflags - | $sort $length | $lpr -J$banner -t $fonts\"
10516438Sralph    endif
1061860Srootelse
10716438Sralph    if ($?t) then
10816438Sralph	$troff $tflags $* | $sort $length
10916438Sralph    else
11016438Sralph	$troff $tflags $* | $sort $length | $lpr -J$banner -t $fonts
11116438Sralph    endif
1121860Srootendif
11316438Sralph
1141860Srootif ($#fontf) then
11512735Sralph    /bin/rm $fontf
1161860Srootendif
117