5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 1994, 1995, 1996 by Sun Microsystems, Inc.
27 # ident "%Z%%M% %I% %E% SMI"
29 # Printcap <-> Printers.conf conversion utility...
31 # Usage: conv_lpd [ -c (printers|printcap) ] [ -n ] (file)
34 TEXTDOMAIN
="SUNW_OST_OSCMD"
37 USAGE
=`gettext "Usage: conv_lpd [ -c (printers|printcap) ] [ -n ] (file)\n"`
39 PATH
=/usr
/bin
:/bin
:/usr
/sbin
export PATH
66 # Any remaining arg is the "file" specification. It is a required arg.
78 # First, strip all continuation characters, leaving one, single line
79 # for each printer entry.
81 CONV_FIX
=/usr
/lib
/print
/conv_fix
83 if [ -f $CONV_FIX ]; then
84 $CONV_FIX -f $TMPF1 -o $TMPF2
87 gettext "Fatal Error: $CONV_FIX failed.\n"
88 gettext "Please contact your Sun support representative.\n"
92 gettext "$0: Fatal: Cannot locate $CONV_FIX binary.\n"
93 gettext "Please contact your Sun support representative.\n"
98 # Continuation characters are now stripped. Continue processing.
100 /bin
/sed -e "s/:[ ]*:/:/g" $TMPF2 > $FILE
103 # Empty colons ":[ <TAB>]*:" are now stripped. Continue processing.
108 "uname -n" | getline ;
118 if ($0 ~ /^[_a-zA-Z0-9_]/) { # New entry
120 if ( "'$namelist'" == 1 )
125 if ( "'$conversion'" == "printers" ) {
126 printf "\n%s:", names ;
127 for (key in values) {
130 printf "\\\n\t:%s=%s:",
135 if (values["rm"] != "") {
136 printf "\\\n\t:bsdaddr=%s,%s:", \
139 if (values["rm"] == host) local_pr++;
141 printf "\\\n\t:bsdaddr=%s,%s:", \
148 printf "\n%s:", names ;
149 for (key in values) {
150 if (key == "bsdaddr") {
153 printf "\\\n\t:%s=%s:", \
157 printf "\\\n\t:%s=%s:", \
160 } else if ((key == "br") || \
172 printf "\\\n\t:%s#%s:", \
175 else if (values[key] == "true")
176 printf "\\\n\t:%s:", \
178 else if (values[key] != "false")
179 printf "\\\n\t:%s=%s:", \
186 split( $1, name, "|");
191 for ( i = 1 ; i <= NF ; i++ ) {
192 if (($i == names) || ($i == "") || \
195 if ((split( $i, pair, "=" ) != 2) && \
196 (split( $i, pair, "\#") != 2))
199 if (pair[1] != "" && pair[1] != " ")
200 values[pair[1]] = pair[2] ;
207 printf "One or more printers are local, you may want to run lpadmin to configure LP server side operation\n" | "cat 1>&2" ;
211 /bin
/rm -f ${TMPF1} ${TMP2} ${FILE}