#!/bin/ksh
#
#   @(#)svc_devices	1.3 98/03/27 
# 
# Create osprey-1000 SunVideo Compatibility Pseudo Devices
# 
# Copyright (c) 1995 MultiMedia Access Corporation - Osprey Systems Division. 
# 1150 S.E. Maynard Rd., Suite 110, Cary, NC 27511 USA. All Rights Reserved.
# 
# This product and related documentation is protected by copyright laws and 
# international treaties. No part of this product or related documentation  
# may be reproduced, distributed, or decompiled in any form by any means 
# without prior written authorization of MultiMedia Access Corporation. 
# Unauthorized reproduction or distribution of this program, or any part of 
# it, may result in severe civil and criminal penalties, and will be 
# prosecuted to the maximum extent possible under the law.
# 
# MMAC reserves the right to change any products herein at any time and 
# without notice. MMAC does not assume any liability arising from the 
# application or use of this product, except as expressly agreed to in 
# writing by MMAC. Use and purchase of this product does not convey a license
# under any patent rights, copyrights, trademark rights, or any other 
# intellectual property rights of MMAC, Sun Microsystems, or others. 
# 
 
USAGE=\
"usage: $progname  add | remove
    add      -- adds SVC pseudo devices
    remove   -- removes SVC pseudo devices
"

fatal() {
    if [ "$1" ]
    then
        echo $* >&2
    fi
    echo "$USAGE" 1>&2
    exit 1
}

add(){
rtvc_dev="/dev/rtvc0 /dev/rtvc1 /dev/rtvc2 /dev/rtvc3 /dev/rtvc4 /dev/rtvc5 /dev/rtvc6 /dev/rtvc7 /dev/rtvc8 /dev/rtvc9"
for sdev in /dev/o1k[0-9]*
do
    found=0
    for rdev in $rtvc_dev
    do
        if [ "$found" = 0 ] && [ ! -a $rdev ]
        then
            echo "Adding pseudo SVC device $rdev"
            ln -s $sdev $rdev
            found=1
        fi
    done
done
}    

remove(){
for rdev in /dev/rtvc[0-9]
do
    t=`ls -l $rdev | grep "/dev/o1k"`
    if [ "$t" != "" ]
    then
        echo "Removing pseudo SVC device $rdev"
        rm $rdev
    fi
done
}

#
# process options
#

shift `expr $OPTIND - 1`
if [ $# -eq 0 ]
then
    fatal
else
    case "$1" in
        "add")
            add ;;
        "install")
            add ;;
        "remove")
            remove ;;
        *)
            fatal;;
    esac
fi





