5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
24 #
25 # ident "%Z%%M% %I% %E% SMI"
26 #
27
28 #
29 # Get the path/ppdfilename for this ppd NickName
30 # Input:
31 # make: model: ppdlabel: ppd:
32 # PrintersRus: ABC Model 1234: SUNWfoomatic(S): Foomatic/Postscript (recommended):
33 #
34
35 #
36 # Returns the full path to the repository associated with
37 # the repository letter found between parenthesis in the
38 # extended PPD label.
39 #
40 # $1 - Extended PPD label
41 #
42 rep_path()
43 {
44 case "$(expr \"$1\" : ".*(\(.*\)).*")" in
45 "S")
46 echo "/usr/share/ppd"
47 ;;
48 "V")
49 echo "/opt/share/ppd"
50 ;;
51 "A")
52 echo "/usr/local/share/ppd"
53 ;;
54 "U")
55 echo "/var/lp/ppd"
56 ;;
57 esac
58 }
59
60 if [[ $# -lt 4 ]]; then
61 exit 1
62 fi
63
64 [[ -f /var/lp/ppd/ppdcache ]] || exit 1
65 make=$(echo $* | /usr/bin/nawk '{FS=":"; print $1}')
66 # strip leading blanks
67 model=$(echo $* | /usr/bin/nawk '{FS=":"; print $2}' |
68 /bin/sed -e 's/^[ ]*//')
69 extppdlabel=$(echo $* | /usr/bin/nawk '{FS=":"; print $3}' |
70 /bin/sed -e 's/^[ ]*//')
71 ppd=$(echo $* | /usr/bin/nawk '{FS=":"; print $4}' |
72 /bin/sed -e 's/^[ ]*//')
73
74 #
75 # Do not use ":" with $make. printmgr collapses manufacturer name
76 # to first word, ie PrintersRus and PrintersRus International become
77 # PrintersRus. The full path to the PPD file will be the 6th
78 # colon separated entry in the ppdcache entry. If the format
79 # of a ppdcache entry changes, then this will need to be modified
80 # also.
81 #
82 /bin/grep "${make}" /var/lp/ppd/ppdcache |
83 /bin/grep "${model}:" |
84 /bin/grep "${ppd}:" |
85 /bin/grep "$(rep_path ${extppdlabel})/${extppdlabel%\(*}" |
86 /usr/bin/nawk '{FS=":"; print $6}'
87
88 exit 0
|
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
24 #
25
26 #
27 # Get the path/ppdfilename for this ppd NickName
28 # Input:
29 # make: model: ppdlabel: ppd:
30 # PrintersRus: ABC Model 1234: SUNWfoomatic(S): Foomatic/Postscript (recommended):
31 #
32
33 #
34 # Returns the full path to the repository associated with
35 # the repository letter found between parenthesis in the
36 # extended PPD label.
37 #
38 # $1 - Extended PPD label
39 #
40 rep_path()
41 {
42 case "$(expr \"$1\" : ".*(\(.*\)).*")" in
43 "S")
44 echo "/usr/share/ppd"
45 ;;
46 "V")
47 echo "/opt/share/ppd"
48 ;;
49 "A")
50 echo "/usr/local/share/ppd"
51 ;;
52 "U")
53 echo "/var/lp/ppd"
54 ;;
55 esac
56 }
57
58 if [[ $# -lt 4 ]]; then
59 exit 1
60 fi
61
62 [[ -f /var/lp/ppd/ppdcache ]] || exit 1
63 make=$(echo $* | /usr/xpg4/bin/awk '{FS=":"; print $1}')
64 # strip leading blanks
65 model=$(echo $* | /usr/xpg4/bin/awk '{FS=":"; print $2}' |
66 /bin/sed -e 's/^[ ]*//')
67 extppdlabel=$(echo $* | /usr/xpg4/bin/awk '{FS=":"; print $3}' |
68 /bin/sed -e 's/^[ ]*//')
69 ppd=$(echo $* | /usr/xpg4/bin/awk '{FS=":"; print $4}' |
70 /bin/sed -e 's/^[ ]*//')
71
72 #
73 # Do not use ":" with $make. printmgr collapses manufacturer name
74 # to first word, ie PrintersRus and PrintersRus International become
75 # PrintersRus. The full path to the PPD file will be the 6th
76 # colon separated entry in the ppdcache entry. If the format
77 # of a ppdcache entry changes, then this will need to be modified
78 # also.
79 #
80 /bin/grep "${make}" /var/lp/ppd/ppdcache |
81 /bin/grep "${model}:" |
82 /bin/grep "${ppd}:" |
83 /bin/grep "$(rep_path ${extppdlabel})/${extppdlabel%\(*}" |
84 /usr/xpg4/bin/awk '{FS=":"; print $6}'
85
86 exit 0
|