ppdfilename2mmp revision e6917149c742c7b83b952b9933ea0d28a968c4c6
0N/A#!/usr/bin/ksh
661N/A#
661N/A# CDDL HEADER START
0N/A#
0N/A# The contents of this file are subject to the terms of the
661N/A# Common Development and Distribution License, Version 1.0 only
661N/A# (the "License"). You may not use this file except in compliance
661N/A# with the License.
661N/A#
661N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
661N/A# or http://www.opensolaris.org/os/licensing.
661N/A# See the License for the specific language governing permissions
661N/A# and limitations under the License.
661N/A#
661N/A# When distributing Covered Code, include this CDDL HEADER in each
661N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
661N/A# If applicable, add the following below this CDDL HEADER, with the
661N/A# fields enclosed by brackets "[]" replaced with your own identifying
661N/A# information: Portions Copyright [yyyy] [name of copyright owner]
661N/A#
661N/A# CDDL HEADER END
2362N/A#
661N/A#
661N/A# ident "%Z%%M% %I% %E% SMI"
661N/A#
0N/A# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
0N/A# Use is subject to license terms.
0N/A#
0N/A
0N/A#
0N/A# Get the make/model/nickname from ppdfilename
661N/A#
0N/A
0N/Aif [[ $# -lt 1 ]]; then
0N/A exit 1
0N/Afi
0N/A
0N/Aif [[ -f /usr/lib/lp/model/ppd/ppdcache ]]; then
0N/A
0N/A ppdfile=`/bin/grep $1 /usr/lib/lp/model/ppd/ppdcache`
0N/A
0N/A if [[ -z "$ppdfile" ]]; then
0N/A
0N/A # Perhaps this is an old configuration file
0N/A # look for ppd file in new directories
0N/A
0N/A # Get last two fields from arg1: full path/filename of ppd
0N/A # file. Separate with /.
0N/A # arg1: /usr/lib/lp/model/ppd/<MANU>/<filename>
0N/A
0N/A manufile=`echo $1 | /bin/nawk -F/ '{ print $7 "/" $8 }`
0N/A
0N/A # search for ppd file in all the directories under system
0N/A # Use the first one found
0N/A
0N/A for dir in /usr/lib/lp/model/ppd/system/*; do
0N/A if [[ -d "$dir" ]]; then
0N/A target=$dir/$manufile
0N/A found=`/bin/grep $target /usr/lib/lp/model/ppd/ppdcache`
0N/A
0N/A if [[ -z "$ppdfile" && -n "$found" ]]; then
0N/A ppdfile=$found
0N/A fi
0N/A
0N/A
0N/A fi
0N/A done
0N/A
0N/A fi
0N/A
661N/A if [[ -z "$ppdfile" ]]; then
661N/A exit 1
0N/A else
0N/A # Use only first word in manufacturer entry
0N/A echo $ppdfile |
661N/A nawk '{FS=":"; print $1}' |
661N/A nawk '{print $1}'
661N/A
661N/A echo $ppdfile |
661N/A nawk '{FS=":"; print $2; print $3}'
661N/A exit 0
0N/A fi
0N/Afi
0N/A