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# 29*c81d47afSceastha# Get the make/model/nickname as well as the repository/label from ppdfilename 30*c81d47afSceastha# 31*c81d47afSceastha 32*c81d47afSceastha# Input 33*c81d47afSceastha# ppdfilename 34*c81d47afSceastha# /var/lp/ppd/user/HP/foo.ppd.gz 35*c81d47afSceastha# Output 36*c81d47afSceastha# make 37*c81d47afSceastha# model 38*c81d47afSceastha# label(repository letter): driver 39*c81d47afSceastha# 40*c81d47afSceastha# Lexmark 41*c81d47afSceastha# IBM Page Printer 3112 42*c81d47afSceastha# foomatic(L): Foomatic/hpijs 437c478bd9Sstevel@tonic-gate# 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gateif [[ $# -lt 1 ]]; then 467c478bd9Sstevel@tonic-gate exit 1 477c478bd9Sstevel@tonic-gatefi 487c478bd9Sstevel@tonic-gate 49*c81d47afSceasthacachefile=/var/lp/ppd/ppdcache 50*c81d47afSceastha[[ -f $cachefile ]] || exit 1 517c478bd9Sstevel@tonic-gate 52*c81d47afSceasthacacheentry=$(/bin/grep "$1" $cachefile) 53*c81d47afSceastha[[ -n "$cacheentry" ]] || exit 1 547c478bd9Sstevel@tonic-gate 55*c81d47afSceastha# 56*c81d47afSceastha# Retrieve the manufacturer (make) 57*c81d47afSceastha# Use only the first word in manufacturer entry 58*c81d47afSceastha# 59*c81d47afSceasthamanuf=$(echo "$cacheentry" | 60e6917149Swendypnawk '{FS=":"; print $1}' | 61*c81d47afSceasthanawk '{print $1}') 62e6917149Swendyp 63*c81d47afSceastha# Retrieve the model 64*c81d47afSceasthamodel=$(echo "$cacheentry" | nawk '{FS=":"; print $2}') 65*c81d47afSceastha 66*c81d47afSceastha# Retrieve the driver 67*c81d47afSceasthadriver=$(echo "$cacheentry" | nawk '{FS=":"; print $3}') 68*c81d47afSceastha 69*c81d47afSceastha# 70*c81d47afSceastha# Retrieve the PPD path. Parse the PPD path to get the 71*c81d47afSceastha# label path and to figure out the repository letter 72*c81d47afSceastha# associated with the label path. Note: 73*c81d47afSceastha# the PPD file name is the 6th colon separated entry 74*c81d47afSceastha# in the cache entry. This is may need to be modified if the 75*c81d47afSceastha# format changes. 76*c81d47afSceastha# 77*c81d47afSceasthappdpath=$(echo "$cacheentry" | /bin/nawk '{FS=":"; print $6}' ) 78*c81d47afSceasthamanupath=$(/bin/dirname "$ppdpath") 79*c81d47afSceasthalabelpath=$(/bin/dirname "$manupath") 80*c81d47afSceastha 81*c81d47afSceasthacase "$labelpath" in 82*c81d47afSceastha/usr/share/ppd/*) 83*c81d47afSceastha repltr=S 84*c81d47afSceastha ;; 85*c81d47afSceastha/opt/share/ppd/*) 86*c81d47afSceastha repltr=V 87*c81d47afSceastha ;; 88*c81d47afSceastha/usr/local/share/ppd/*) 89*c81d47afSceastha repltr=A 90*c81d47afSceastha ;; 91*c81d47afSceastha/var/lp/ppd/*) 92*c81d47afSceastha repltr=U 93*c81d47afSceastha ;; 94*c81d47afSceasthaesac 95*c81d47afSceastha 96*c81d47afSceastha[[ -n "${repltr}" ]] || exit 1 97*c81d47afSceasthaecho "${manuf}\n${model}" 98*c81d47afSceasthaecho "$(/bin/basename "$labelpath")(${repltr}): $driver" 99*c81d47afSceastha 1007c478bd9Sstevel@tonic-gateexit 0 101