getppds revision c81d47afd05baeb768e2f032636019b717899efd
0N/A#!/usr/bin/ksh
0N/A#
0N/A# CDDL HEADER START
0N/A#
0N/A# The contents of this file are subject to the terms of the
0N/A# Common Development and Distribution License (the "License").
0N/A# You may not use this file except in compliance with the License.
0N/A#
0N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A# or http://www.opensolaris.org/os/licensing.
0N/A# See the License for the specific language governing permissions
0N/A# and limitations under the License.
0N/A#
0N/A# When distributing Covered Code, include this CDDL HEADER in each
0N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0N/A# If applicable, add the following below this CDDL HEADER, with the
0N/A# fields enclosed by brackets "[]" replaced with your own identifying
0N/A# information: Portions Copyright [yyyy] [name of copyright owner]
0N/A#
0N/A# CDDL HEADER END
0N/A#
0N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
0N/A# Use is subject to license terms.
0N/A#
0N/A# ident "%Z%%M% %I% %E% SMI"
0N/A#
0N/A
0N/A#
0N/A# get a list of the Models for this Model from the ppdcache
0N/A#
0N/A
0N/A# Input:
0N/A# make model
0N/A# HP OfficeJet 4200
0N/A# Output:
0N/A# <label>(<repository letter>): <driver>
0N/A# userlabel(U): Foomatic/hpijs (recommended)
0N/A# SUNWhpijs(S): Foomatic/hpijs (recommended)
0N/A
0N/ASaveIFS="$IFS"
0N/ANoSpaceTabIFS='
0N/A'
0N/ASEP=": "
0N/A
0N/A#
0N/A# Return cache entries matching the specified make
0N/A# and model from the specified cache file.
0N/A#
0N/A# $1 - Make
0N/A# $2 - Model
0N/A# $3 - cachefile
0N/Appd_make_entries()
0N/A{
0N/A for hit in $(/bin/grep "${1}" "${3}" | /bin/grep "${2}")
0N/A do
0N/A echo "${hit#*:*:}"
0N/A done
0N/A}
0N/A
0N/Aif [[ $# -lt 2 ]]; then
0N/A exit 1
0N/Afi
0N/A
0N/Acachefile=/var/lp/ppd/ppdcache
0N/A[[ -f $cachefile ]] || exit 1
0N/Amake=$1
0N/Ashift
0N/Amodel="$*"
0N/Asystem=
0N/Avendor=
0N/Aadmin=
0N/Auser=
0N/A
0N/A#
0N/A# Ensure each ppdcache entry is processed as a single string
0N/A# otherwise it would be split up by spaces.
0N/A#
0N/AIFS="$NoSpaceTabIFS"
0N/Afor pentry in $(ppd_make_entries "${make}" "${model}" "${cachefile}")
0N/Ado
0N/A IFS="$SaveIFS"
0N/A ppdpath="${pentry##*:}"
0N/A ppdlpath="${ppdpath%/*/*}"
0N/A ppdlabel="${ppdlpath##*/}"
0N/A driver="${pentry%%:*}"
0N/A
0N/A case "${ppdpath}" in
0N/A "/usr/share/ppd/"*)
0N/A system="${system}${ppdlabel}(S)${SEP}${driver}\n"
0N/A ;;
0N/A "/opt/share/ppd/"*)
0N/A vendor="${vendor}${ppdlabel}(V)${SEP}${driver}\n"
0N/A ;;
0N/A "/usr/local/share/ppd/"*)
0N/A admin="${admin}${ppdlabel}(A)${SEP}${driver}\n"
0N/A ;;
0N/A "/var/lp/ppd/"*)
0N/A user="${user}${ppdlabel}(U)${SEP}${driver}\n"
0N/A ;;
0N/A esac
0N/A IFS="$NoSpaceTabIFS"
0N/Adone
0N/A
0N/AIFS="$SaveIFS"
0N/Aecho "${user}${admin}${vendor}${system}"
0N/Aexit 0
0N/A