~ubuntu-branches/ubuntu/oneiric/nis/oneiric-proposed

« back to all changes in this revision

Viewing changes to ypserv-2.18/scripts/create_printcap.in

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2005-11-16 23:42:06 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20051116234206-p00omaw5ji5q0qhr
Tags: 3.15-3ubuntu1
Resynchronise with Debian.  (me)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/awk -f
 
2
#
 
3
# create_printcap
 
4
#
 
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.
 
8
#
 
9
# Copyright (C) 2000  Massimo Dal Zotto <dz@cs.unitn.it>
 
10
# This file is distributed under the GNU General Public License version 2
 
11
 
 
12
BEGIN       { FS=":"; OFS="\t"; delim="_"; space="^B"; cont=1 }
 
13
/^[\t ]*#/  { next }
 
14
/^[^\t ]/   { if (!cont) print_entry() }
 
15
            { sub("^[\t ]+", ":"); cont = sub("\\\\$", ""); entry = entry $0 }
 
16
END         { print_entry(); print_all() }
 
17
 
 
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
 
27
    }
 
28
    entry = ""
 
29
}
 
30
 
 
31
function print_all() {
 
32
    sub("^,", "", all)
 
33
    if (all) { print "all" delim "1", "all" delim "1|all:all=" all }
 
34
}
 
35
 
 
36
# end of file