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.2 2003/06/17 04:28:32 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"
41 gsub("\\$", "", VERSION)
44 printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
45 else if (os == "FreeBSD")
46 printf("/*\t\$FreeBSD\$\t*/\n\n") > dfile
47 else if (os == "OpenBSD")
48 printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile
50 printf("/* ??? */\n\n") > dfile
51 printf("/*\n") > dfile
52 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
54 printf(" *\n") > dfile
55 printf(" * generated from:\n") > dfile
56 printf(" *\t%s\n", VERSION) > dfile
57 printf(" */\n") > dfile
60 printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
61 else if (os == "FreeBSD")
62 printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
63 else if (os == "OpenBSD")
64 printf("/*\t\$OpenBSD\$\t*/\n\n") > hfile
66 printf("/* ??? */\n\n") > hfile
67 printf("/*\n") > hfile
68 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
70 printf(" *\n") > hfile
71 printf(" * generated from:\n") > hfile
72 printf(" *\t%s\n", VERSION) > hfile
73 printf(" */\n") > hfile
80 vendorindex[$2] = nvendors; # record index for this name, for later.
81 vendors[nvendors, 1] = $2; # name
82 vendors[nvendors, 2] = $3; # id
83 printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
84 vendors[nvendors, 2]) > hfile
91 printf("\t/* ") > hfile
102 printf("%s", $f) > hfile
108 vendors[nvendors, i] = $f
109 printf("%s", vendors[nvendors, i]) > hfile
117 printf(" */") > hfile
125 products[nproducts, 1] = $2; # vendor name
126 products[nproducts, 2] = $3; # product id
127 products[nproducts, 3] = $4; # id
128 printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
129 products[nproducts, 2], products[nproducts, 3]) > hfile
134 ocomment = oparen = 0
136 printf("\t/* ") > hfile
147 printf("%s", $f) > hfile
153 products[nproducts, i] = $f
154 printf("%s", products[nproducts, i]) > hfile
162 printf(" */") > hfile
175 # print out the match tables
179 printf("struct usb_knowndev usb_knowndevs[] = {\n") > dfile
180 for (i = 1; i <= nproducts; i++) {
181 printf("\t{\n") > dfile
182 printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
183 products[i, 1], products[i, 1], products[i, 2]) \
185 printf("\t ") > dfile
187 printf(",\n") > dfile
189 vendi = vendorindex[products[i, 1]];
190 printf("\t \"") > dfile
193 while (vendors[vendi, j] != "") {
196 printf("%s", vendors[vendi, j]) > dfile
200 printf("\",\n") > dfile
202 printf("\t \"") > dfile
205 while (products[i, j] != "") {
208 printf("%s", products[i, j]) > dfile
212 printf("\",\n") > dfile
213 printf("\t},\n") > dfile
215 for (i = 1; i <= nvendors; i++) {
216 printf("\t{\n") > dfile
217 printf("\t USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
219 printf("\t USB_KNOWNDEV_NOPROD,\n") \
221 printf("\t \"") > dfile
224 while (vendors[i, j] != "") {
227 printf("%s", vendors[i, j]) > dfile
231 printf("\",\n") > dfile
232 printf("\t NULL,\n") > dfile
233 printf("\t},\n") > dfile
235 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
236 printf("};\n") > dfile