3 # $NetBSD: usb/devlist2h.awk,v 1.9 2001/01/18 20:28:22 jdolecek Exp $
4 # $FreeBSD: src/sys/dev/usb/devlist2h.awk,v 1.2 2002/04/01 19:22:04 joe Exp $
5 # $DragonFly: src/sys/bus/usb/Attic/devlist2h.awk,v 1.4 2003/12/30 01:01:44 dillon Exp $
7 # Copyright (c) 1995, 1996 Christopher G. Demetriou
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
13 # 1. Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in the
17 # documentation and/or other materials provided with the distribution.
18 # 3. All advertising materials mentioning features or use of this software
19 # must display the following acknowledgement:
20 # This product includes software developed by Christopher G. Demetriou.
21 # 4. The name of the author may not be used to endorse or promote products
22 # derived from this software without specific prior written permission
24 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 nproducts = nvendors = 0
37 dfile="usbdevs_data.h"
41 printf("/*\n") > dfile
42 printf(" *\t\$DragonFly\$\n *\n") > dfile
43 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
45 printf(" *\n") > dfile
46 printf(" */\n") > dfile
48 printf("/*\n") > hfile
49 printf(" *\t\$DragonFly\$\n *\n") > hfile
50 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
52 printf(" *\n") > hfile
53 printf(" */\n") > hfile
58 vendorindex[$2] = nvendors; # record index for this name, for later.
59 vendors[nvendors, 1] = $2; # name
60 vendors[nvendors, 2] = $3; # id
61 printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
62 vendors[nvendors, 2]) > hfile
69 printf("\t/* ") > hfile
80 printf("%s", $f) > hfile
86 vendors[nvendors, i] = $f
87 printf("%s", vendors[nvendors, i]) > hfile
103 products[nproducts, 1] = $2; # vendor name
104 products[nproducts, 2] = $3; # product id
105 products[nproducts, 3] = $4; # id
106 printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
107 products[nproducts, 2], products[nproducts, 3]) > hfile
112 ocomment = oparen = 0
114 printf("\t/* ") > hfile
125 printf("%s", $f) > hfile
131 products[nproducts, i] = $f
132 printf("%s", products[nproducts, i]) > hfile
140 printf(" */") > hfile
153 # print out the match tables
157 printf("const struct usb_knowndev usb_knowndevs[] = {\n") > dfile
158 for (i = 1; i <= nproducts; i++) {
159 printf("\t{\n") > dfile
160 printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
161 products[i, 1], products[i, 1], products[i, 2]) \
163 printf("\t ") > dfile
165 printf(",\n") > dfile
167 vendi = vendorindex[products[i, 1]];
168 printf("\t \"") > dfile
171 while (vendors[vendi, j] != "") {
174 printf("%s", vendors[vendi, j]) > dfile
178 printf("\",\n") > dfile
180 printf("\t \"") > dfile
183 while (products[i, j] != "") {
186 printf("%s", products[i, j]) > dfile
190 printf("\",\n") > dfile
191 printf("\t},\n") > dfile
193 for (i = 1; i <= nvendors; i++) {
194 printf("\t{\n") > dfile
195 printf("\t USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
197 printf("\t USB_KNOWNDEV_NOPROD,\n") \
199 printf("\t \"") > dfile
202 while (vendors[i, j] != "") {
205 printf("%s", vendors[i, j]) > dfile
209 printf("\",\n") > dfile
210 printf("\t NULL,\n") > dfile
211 printf("\t},\n") > dfile
213 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
214 printf("};\n") > dfile