#!/bin/csh -f 
# @(#)show	31.1 96/04/03
#

# make sure path contains necessary directories

set docmd = (shotga) 
set doinfo = 

# command line parsing
  set arguments = `getopt hit $*`
  if ( $status != 0 ) then
    echo usage: "$0 [-h][-i] targa/vista-file ..."
    exit 2
  endif
  foreach i ( $arguments )
    shift arguments
    switch ( $i ) 
      case '-h':
        echo usage: "$0 [-h][-i] targa/vista-file ..."
        echo usage: "   -h: help"
        echo usage: "   -t: converteer tga to tiff"
        echo usage: "   -i: show header"
        exit 0
      case '-t':
        set dotiff  
        breaksw
      case '-i':
        set doinfo = (-v -T)
        set docmd = (shohdr tga) 
        breaksw
      case '-f':
        set nr_tape=$arguments[1]
        shift arguments
        breaksw
      case '--':
       break
    endsw
  end

if ($?dotiff) then
  foreach i ($arguments)
    echo $i
    set b = $i
    set j = $b:r
    if ($i:e == 'Z') then
      set b = $i:r
      set j = $b:r
      compress -d < $i > $b
    else if ($i:e == 'rgb') then
      set j = $i:r
      set b = "$j".vst
      gig_conv sgi tga < $i > $b
    else if ($i:e == 'sgi') then
      set j = $i:r
      set b = "$j".vst
      gig_conv sgi tga < $i > $b
    else if ($i:e == 'gz') then
      set b = $i:r
      set j = $b:r
      gzip -d < $i > $b
    endif
    tga2tiff -i $b -o "$j".tif
  end
  exit
endif

foreach i ($arguments)
  echo $i
  if ($i:e == 'tif') then
    showtiff $doinfo $i
  else if ($i:e == 'Z') then
    compress -d < $i | $docmd
  else if ($i:e == 'rgb') then
    gig_conv sgi tga < $i | $docmd
  else if ($i:e == 'sgi') then
    gig_conv sgi tga < $i | $docmd
  else if ($i:e == 'gz') then
    gzip -d < $i | $docmd
  else
    $docmd < $i
  endif
end
