2 # $NetBSD: devlist2h.awk,v 1.9 2005/12/11 12:21:20 christos Exp $
5 # Copyright (c) 1995, 1996 Christopher G. Demetriou
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # 3. All advertising materials mentioning features or use of this software
17 # must display the following acknowledgement:
18 # This product includes software developed by Christopher G. Demetriou.
19 # 4. The name of the author may not be used to endorse or promote products
20 # derived from this software without specific prior written permission
22 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 nproducts = nvendors = blanklines = 0
35 dfile="ediddevs_data.h"
40 gsub("\\$", "", VERSION)
41 gsub(/ $/, "", VERSION)
43 printf("/*\t$FreeBSD" "$\t*/\n\n") > dfile
44 printf("/*\n") > dfile
45 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
47 printf(" *\n") > dfile
48 printf(" * generated from:\n") > dfile
49 printf(" *\t%s\n", VERSION) > dfile
50 printf(" */\n") > dfile
52 printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
53 printf("/*\n") > hfile
54 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
56 printf(" *\n") > hfile
57 printf(" * generated from:\n") > hfile
58 printf(" *\t%s\n", VERSION) > hfile
59 printf(" */\n") > hfile
64 NF > 0 && $1 == "vendor" {
67 vendorindex[$2] = nvendors; # record index for this name, for later.
68 vendors[nvendors, 1] = $2; # name/ID
71 printf("#define\tEDID_VENDOR_%s\t\"", vendors[nvendors, 1]) > hfile
83 printf("%s", $f) > hfile
87 vendors[nvendors, i] = $f
88 printf("%s", vendors[nvendors, i]) > hfile
101 NF > 0 && $1 == "product" {
104 products[nproducts, 1] = $2; # vendor name
105 products[nproducts, 2] = $3; # product id
106 products[nproducts, 3] = $4; # id
107 printf("#define\tEDID_PRODUCT_%s_%s\t%s", products[nproducts, 1],
108 products[nproducts, 2], products[nproducts, 3]) > hfile
112 ocomment = oparen = 0
114 printf("\t\t/* ") > hfile
125 printf("%s", $f) > hfile
131 products[nproducts, i] = $f
132 printf("%s", products[nproducts, i]) > hfile
140 printf(" */") > hfile
148 if (blanklines != 2 && blanklines != 3)
154 # print out the match tables
157 printf("const struct edid_vendor edid_vendors[] = {\n") > dfile
159 for (i = 1; i <= nvendors; i++) {
160 printf("\t{") > dfile
161 printf(" \"%s\", EDID_VENDOR_%s", vendors[i, 1], \
162 vendors[i, 1]) > dfile
163 printf(" },\n") > dfile
165 printf("};\n") > dfile
166 printf("const int edid_nvendors = %d;\n", nvendors) > dfile
170 printf("const struct edid_product edid_products[] = {\n") > dfile
171 for (i = 1; i <= nproducts; i++) {
172 printf("\t{\n") > dfile
173 printf("\t \"%s\", EDID_PRODUCT_%s_%s,\n", \
174 products[i, 1], products[i, 1], products[i, 2]) > dfile
175 printf("\t \"") > dfile
178 while ((i, j) in products) {
181 printf("%s", products[i, j]) > dfile
185 printf("\",\n") > dfile
186 printf("\t},\n") > dfile
188 printf("};\n") > dfile
189 printf("const int edid_nproducts = %d;\n", nproducts) >dfile