getppdfile revision c81d47afd05baeb768e2f032636019b717899efd
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#!/usr/bin/ksh
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# CDDL HEADER START
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# The contents of this file are subject to the terms of the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# Common Development and Distribution License (the "License").
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# You may not use this file except in compliance with the License.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# or http://www.opensolaris.org/os/licensing.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# See the License for the specific language governing permissions
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# and limitations under the License.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# When distributing Covered Code, include this CDDL HEADER in each
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# If applicable, add the following below this CDDL HEADER, with the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# fields enclosed by brackets "[]" replaced with your own identifying
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# CDDL HEADER END
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# Use is subject to license terms.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# ident "%Z%%M% %I% %E% SMI"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# Get the path/ppdfilename for this ppd NickName
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# Input:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# make: model: ppdlabel: ppd:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# PrintersRus: ABC Model 1234: SUNWfoomatic(S): Foomatic/Postscript (recommended):
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# Returns the full path to the repository associated with
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# the repository letter found between parenthesis in the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# extended PPD label.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# $1 - Extended PPD label
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncrep_path()
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync{
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync case "$(expr \"$1\" : ".*(\(.*\)).*")" in
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync "S")
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync echo "/usr/share/ppd"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ;;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync "V")
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync echo "/opt/share/ppd"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ;;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync "A")
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync echo "/usr/local/share/ppd"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ;;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync "U")
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync echo "/var/lp/ppd"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync ;;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync esac
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync}
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncif [[ $# -lt 4 ]]; then
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync exit 1
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncfi
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync[[ -f /var/lp/ppd/ppdcache ]] || exit 1
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncmake=$(echo $* | /usr/bin/nawk '{FS=":"; print $1}')
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# strip leading blanks
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncmodel=$(echo $* | /usr/bin/nawk '{FS=":"; print $2}' |
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /bin/sed -e 's/^[ ]*//')
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncextppdlabel=$(echo $* | /usr/bin/nawk '{FS=":"; print $3}' |
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /bin/sed -e 's/^[ ]*//')
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncppd=$(echo $* | /usr/bin/nawk '{FS=":"; print $4}' |
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /bin/sed -e 's/^[ ]*//')
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# Do not use ":" with $make. printmgr collapses manufacturer name
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# to first word, ie PrintersRus and PrintersRus International become
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# PrintersRus. The full path to the PPD file will be the 6th
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# colon separated entry in the ppdcache entry. If the format
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# of a ppdcache entry changes, then this will need to be modified
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync# also.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/bin/grep "${make}" /var/lp/ppd/ppdcache |
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /bin/grep "${model}:" |
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /bin/grep "${ppd}:" |
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /bin/grep "$(rep_path ${extppdlabel})/${extppdlabel%\(*}" |
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /usr/bin/nawk '{FS=":"; print $6}'
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncexit 0
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync