2 # $NetBSD: devlist2h.awk,v 1.11 2003/12/15 07:32:21 jmc Exp $
4 # Copyright (c) 1995, 1996 Christopher G. Demetriou
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgement:
17 # This product includes software developed by Christopher G. Demetriou.
18 # 4. The name of the author may not be used to endorse or promote products
19 # derived from this software without specific prior written permission
21 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 nproducts = nvendors = blanklines =
0
39 gsub("\\$", "", VERSION
)
41 printf("/*\n") > dfile
42 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
44 printf(" *\n") > dfile
45 printf(" * generated from:\n") > dfile
46 printf(" *\t%s\n", VERSION
) > dfile
47 printf(" */\n") > dfile
49 printf("/*\n") > hfile
50 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
52 printf(" *\n") > hfile
53 printf(" * generated from:\n") > hfile
54 printf(" *\t%s\n", VERSION
) > hfile
55 printf(" */\n") > hfile
59 NF > 0 && $
1 ==
"vendor" {
62 vendorindex
[$
2] = nvendors
; # record index for this name, for later.
63 vendors
[nvendors
, 1] = $
2; # name
64 vendors
[nvendors
, 2] = $
3; # id
65 printf("#define\tUSB_VENDOR_%s\t%s\t", vendors
[nvendors
, 1],
66 vendors
[nvendors
, 2]) > hfile
73 printf("\t/* ") > hfile
84 printf("%s", $f
) > hfile
90 vendors
[nvendors
, i
] = $f
91 printf("%s", vendors
[nvendors
, i
]) > hfile
104 NF > 0 && $
1 ==
"product" {
107 products
[nproducts
, 1] = $
2; # vendor name
108 products
[nproducts
, 2] = $
3; # product id
109 products
[nproducts
, 3] = $
4; # id
110 printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products
[nproducts
, 1],
111 products
[nproducts
, 2], products
[nproducts
, 3]) > hfile
116 ocomment = oparen =
0
118 printf("\t/* ") > hfile
129 printf("%s", $f
) > hfile
135 products
[nproducts
, i
] = $f
136 printf("%s", products
[nproducts
, i
]) > hfile
144 printf(" */") > hfile
157 # print out the match tables
160 printf("typedef uint16 usb_vendor_id_t;\n") > dfile
161 printf("typedef uint16 usb_product_id_t;\n") > dfile
162 printf("struct usb_knowndev {\n") > dfile
163 printf(" usb_vendor_id_t vendor;\n") > dfile
164 printf(" usb_product_id_t product;\n") > dfile
165 printf(" int flags;\n") > dfile
166 printf(" char *vendorname, *productname;\n") > dfile
167 printf("};\n") > dfile
169 printf("#define USB_KNOWNDEV_NOPROD 0x01 /* match on vendor only */\n") > dfile
172 printf("const struct usb_knowndev usb_knowndevs[] = {\n") > dfile
173 for (i =
1; i
<= nproducts
; i
++) {
174 printf("\t{\n") > dfile
175 printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
176 products
[i
, 1], products
[i
, 1], products
[i
, 2]) \
178 printf("\t ") > dfile
180 printf(",\n") > dfile
182 vendi = vendorindex
[products
[i
, 1]];
183 printf("\t \"") > dfile
186 while ((vendi
, j
) in vendors
) {
189 printf("%s", vendors
[vendi
, j
]) > dfile
193 printf("\",\n") > dfile
195 printf("\t \"") > dfile
198 while ((i
, j
) in products
) {
201 printf("%s", products
[i
, j
]) > dfile
205 printf("\",\n") > dfile
206 printf("\t},\n") > dfile
208 for (i =
1; i
<= nvendors
; i
++) {
209 printf("\t{\n") > dfile
210 printf("\t USB_VENDOR_%s, 0,\n", vendors
[i
, 1]) \
212 printf("\t USB_KNOWNDEV_NOPROD,\n") \
214 printf("\t \"") > dfile
217 while ((i
, j
) in vendors
) {
220 printf("%s", vendors
[i
, j
]) > dfile
224 printf("\",\n") > dfile
225 printf("\t NULL,\n") > dfile
226 printf("\t},\n") > dfile
228 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
229 printf("};\n") > dfile