5
# Converts a printcap into a format suitable for loading into the NIS
6
# printcap map. Use the match_printcap script to extract printer
7
# information from NIS.
9
# Copyright (C) 2000 Massimo Dal Zotto <dz@cs.unitn.it>
10
# This file is distributed under the GNU General Public License version 2
12
BEGIN { FS=":"; OFS="\t"; delim="_"; space="^B"; cont=1 }
14
/^[^\t ]/ { if (!cont) print_entry() }
15
{ sub("^[\t ]+", ":"); cont = sub("\\\\$", ""); entry = entry $0 }
16
END { print_entry(); print_all() }
18
function print_entry() {
19
gsub(":+", ":", entry); sub(":*$", "", entry)
20
split(entry, fields, ":"); n = split(fields[1], names, "|")
21
for (i=1; i<=n; i++) {
22
if (!(name=names[i])) { continue }
23
if (i==1 && !match(name,"^[._@]") && !p[name]++) { all = all "," name }
24
suffix = delim (++count[name])
25
gsub("[ \t]", space, name)
26
print name suffix, name suffix "|" entry
31
function print_all() {
33
if (all) { print "all" delim "1", "all" delim "1|all:all=" all }