2 # $NetBSD: devlist2h.awk,v 1.6 1999/08/17 16:06:20 augustss Exp $
3 # $FreeBSD: src/sys/dev/usb/devlist2h.awk,v 1.1 1999/11/18 18:02:44 n_hibma Exp $
4 # $DragonFly: src/sys/bus/usb/Attic/devlist2h.awk,v 1.3 2003/08/15 01:19:54 dillon Exp $
6 # Copyright (c) 1995, 1996 Christopher G. Demetriou
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
17 # 3. All advertising materials mentioning features or use of this software
18 # must display the following acknowledgement:
19 # This product includes software developed by Christopher G. Demetriou.
20 # 4. The name of the author may not be used to endorse or promote products
21 # derived from this software without specific prior written permission
23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 nproducts = nvendors = 0
36 dfile="usbdevs_data.h"
40 printf("/*\n") > dfile
41 printf(" *\t\$DragonFly\$\n *\n") > dfile
42 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
44 printf(" *\n") > dfile
45 printf(" */\n") > dfile
47 printf("/*\n") > hfile
48 printf(" *\t\$DragonFly\$\n *\n") > hfile
49 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
51 printf(" *\n") > hfile
52 printf(" */\n") > hfile
57 vendorindex[$2] = nvendors; # record index for this name, for later.
58 vendors[nvendors, 1] = $2; # name
59 vendors[nvendors, 2] = $3; # id
60 printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
61 vendors[nvendors, 2]) > hfile
68 printf("\t/* ") > hfile
79 printf("%s", $f) > hfile
85 vendors[nvendors, i] = $f
86 printf("%s", vendors[nvendors, i]) > hfile
102 products[nproducts, 1] = $2; # vendor name
103 products[nproducts, 2] = $3; # product id
104 products[nproducts, 3] = $4; # id
105 printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
106 products[nproducts, 2], products[nproducts, 3]) > hfile
111 ocomment = oparen = 0
113 printf("\t/* ") > hfile
124 printf("%s", $f) > hfile
130 products[nproducts, i] = $f
131 printf("%s", products[nproducts, i]) > hfile
139 printf(" */") > hfile
152 # print out the match tables
156 printf("struct usb_knowndev usb_knowndevs[] = {\n") > dfile
157 for (i = 1; i <= nproducts; i++) {
158 printf("\t{\n") > dfile
159 printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
160 products[i, 1], products[i, 1], products[i, 2]) \
162 printf("\t ") > dfile
164 printf(",\n") > dfile
166 vendi = vendorindex[products[i, 1]];
167 printf("\t \"") > dfile
170 while (vendors[vendi, j] != "") {
173 printf("%s", vendors[vendi, j]) > dfile
177 printf("\",\n") > dfile
179 printf("\t \"") > dfile
182 while (products[i, j] != "") {
185 printf("%s", products[i, j]) > dfile
189 printf("\",\n") > dfile
190 printf("\t},\n") > dfile
192 for (i = 1; i <= nvendors; i++) {
193 printf("\t{\n") > dfile
194 printf("\t USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
196 printf("\t USB_KNOWNDEV_NOPROD,\n") \
198 printf("\t \"") > dfile
201 while (vendors[i, j] != "") {
204 printf("%s", vendors[i, j]) > dfile
208 printf("\",\n") > dfile
209 printf("\t NULL,\n") > dfile
210 printf("\t},\n") > dfile
212 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
213 printf("};\n") > dfile