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 $
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 = 0
35 dfile="usbdevs_data.h"
40 gsub("\\$", "", VERSION)
43 printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
44 else if (os == "FreeBSD")
45 printf("/*\t\$FreeBSD\$\t*/\n\n") > dfile
46 else if (os == "OpenBSD")
47 printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile
49 printf("/* ??? */\n\n") > dfile
50 printf("/*\n") > dfile
51 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
53 printf(" *\n") > dfile
54 printf(" * generated from:\n") > dfile
55 printf(" *\t%s\n", VERSION) > dfile
56 printf(" */\n") > dfile
59 printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
60 else if (os == "FreeBSD")
61 printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
62 else if (os == "OpenBSD")
63 printf("/*\t\$OpenBSD\$\t*/\n\n") > hfile
65 printf("/* ??? */\n\n") > hfile
66 printf("/*\n") > hfile
67 printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
69 printf(" *\n") > hfile
70 printf(" * generated from:\n") > hfile
71 printf(" *\t%s\n", VERSION) > hfile
72 printf(" */\n") > hfile
79 vendorindex[$2] = nvendors; # record index for this name, for later.
80 vendors[nvendors, 1] = $2; # name
81 vendors[nvendors, 2] = $3; # id
82 printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
83 vendors[nvendors, 2]) > hfile
90 printf("\t/* ") > hfile
101 printf("%s", $f) > hfile
107 vendors[nvendors, i] = $f
108 printf("%s", vendors[nvendors, i]) > hfile
116 printf(" */") > hfile
124 products[nproducts, 1] = $2; # vendor name
125 products[nproducts, 2] = $3; # product id
126 products[nproducts, 3] = $4; # id
127 printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
128 products[nproducts, 2], products[nproducts, 3]) > hfile
133 ocomment = oparen = 0
135 printf("\t/* ") > hfile
146 printf("%s", $f) > hfile
152 products[nproducts, i] = $f
153 printf("%s", products[nproducts, i]) > hfile
161 printf(" */") > hfile
174 # print out the match tables
178 printf("struct usb_knowndev usb_knowndevs[] = {\n") > dfile
179 for (i = 1; i <= nproducts; i++) {
180 printf("\t{\n") > dfile
181 printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
182 products[i, 1], products[i, 1], products[i, 2]) \
184 printf("\t ") > dfile
186 printf(",\n") > dfile
188 vendi = vendorindex[products[i, 1]];
189 printf("\t \"") > dfile
192 while (vendors[vendi, j] != "") {
195 printf("%s", vendors[vendi, j]) > dfile
199 printf("\",\n") > dfile
201 printf("\t \"") > dfile
204 while (products[i, j] != "") {
207 printf("%s", products[i, j]) > dfile
211 printf("\",\n") > dfile
212 printf("\t},\n") > dfile
214 for (i = 1; i <= nvendors; i++) {
215 printf("\t{\n") > dfile
216 printf("\t USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
218 printf("\t USB_KNOWNDEV_NOPROD,\n") \
220 printf("\t \"") > dfile
223 while (vendors[i, j] != "") {
226 printf("%s", vendors[i, j]) > dfile
230 printf("\",\n") > dfile
231 printf("\t NULL,\n") > dfile
232 printf("\t},\n") > dfile
234 printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
235 printf("};\n") > dfile