xref: /titanic_52/usr/src/cmd/print/scripts/getppdfile (revision c81d47afd05baeb768e2f032636019b717899efd)
17c478bd9Sstevel@tonic-gate#!/usr/bin/ksh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*c81d47afSceastha# Common Development and Distribution License (the "License").
7*c81d47afSceastha# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
22*c81d47afSceastha# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*c81d47afSceastha# Use is subject to license terms.
247c478bd9Sstevel@tonic-gate#
257c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate#
29e6917149Swendyp# Get the path/ppdfilename for this ppd NickName
30e6917149Swendyp# Input:
31*c81d47afSceastha#	make: model: ppdlabel: ppd:
32*c81d47afSceastha#	PrintersRus: ABC Model 1234: SUNWfoomatic(S): Foomatic/Postscript (recommended):
337c478bd9Sstevel@tonic-gate#
347c478bd9Sstevel@tonic-gate
35*c81d47afSceastha#
36*c81d47afSceastha# Returns the full path to the repository associated with
37*c81d47afSceastha# the repository letter found between parenthesis in the
38*c81d47afSceastha# extended PPD label.
39*c81d47afSceastha#
40*c81d47afSceastha# $1	- Extended PPD label
41*c81d47afSceastha#
42*c81d47afSceastharep_path()
43*c81d47afSceastha{
44*c81d47afSceastha	case "$(expr \"$1\" : ".*(\(.*\)).*")" in
45*c81d47afSceastha	"S")
46*c81d47afSceastha		echo "/usr/share/ppd"
47*c81d47afSceastha		;;
48*c81d47afSceastha	"V")
49*c81d47afSceastha		echo "/opt/share/ppd"
50*c81d47afSceastha		;;
51*c81d47afSceastha	"A")
52*c81d47afSceastha		echo "/usr/local/share/ppd"
53*c81d47afSceastha		;;
54*c81d47afSceastha	"U")
55*c81d47afSceastha		echo "/var/lp/ppd"
56*c81d47afSceastha		;;
57*c81d47afSceastha	esac
58*c81d47afSceastha}
59*c81d47afSceastha
60*c81d47afSceasthaif [[ $# -lt 4 ]]; then
617c478bd9Sstevel@tonic-gate        exit 1
627c478bd9Sstevel@tonic-gatefi
637c478bd9Sstevel@tonic-gate
64*c81d47afSceastha[[ -f /var/lp/ppd/ppdcache ]] || exit 1
65*c81d47afSceasthamake=$(echo $* | /usr/bin/nawk '{FS=":"; print $1}')
66e6917149Swendyp# strip leading blanks
67*c81d47afSceasthamodel=$(echo $* | /usr/bin/nawk '{FS=":"; print $2}' |
68*c81d47afSceastha    /bin/sed -e 's/^[ ]*//')
69*c81d47afSceasthaextppdlabel=$(echo $* | /usr/bin/nawk '{FS=":"; print $3}' |
70*c81d47afSceastha    /bin/sed -e 's/^[ ]*//')
71*c81d47afSceasthappd=$(echo $* | /usr/bin/nawk '{FS=":"; print $4}' |
72*c81d47afSceastha    /bin/sed -e 's/^[ ]*//')
737c478bd9Sstevel@tonic-gate
74*c81d47afSceastha#
75e6917149Swendyp# Do not use ":" with $make. printmgr collapses manufacturer name
76e6917149Swendyp# to first word, ie PrintersRus and PrintersRus International become
77*c81d47afSceastha# PrintersRus.  The full path to the PPD file will be the 6th
78*c81d47afSceastha# colon separated entry in the ppdcache entry.  If the format
79*c81d47afSceastha# of a ppdcache entry changes, then this will need to be modified
80*c81d47afSceastha# also.
81*c81d47afSceastha#
82*c81d47afSceastha/bin/grep "${make}" /var/lp/ppd/ppdcache |
837c478bd9Sstevel@tonic-gate    /bin/grep "${model}:" |
847c478bd9Sstevel@tonic-gate    /bin/grep "${ppd}:"  |
85*c81d47afSceastha    /bin/grep "$(rep_path ${extppdlabel})/${extppdlabel%\(*}" |
86*c81d47afSceastha    /usr/bin/nawk '{FS=":"; print $6}'
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gateexit 0
89