1#! /usr/bin/awk -f 2# $MirOS: src/sys/dev/isa/devlist2h.awk,v 1.2 2005/03/14 21:10:36 tg Exp $ 3# $OpenBSD: devlist2h.awk,v 1.6 2001/01/29 06:16:14 mickey Exp $ 4# $NetBSD: devlist2h.awk,v 1.2 1996/01/22 21:08:09 cgd Exp $ 5# 6# Copyright (c) 1995, 1996 Christopher G. Demetriou 7# All rights reserved. 8# 9# Redistribution and use in source and binary forms, with or without 10# modification, are permitted provided that the following conditions 11# are met: 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 22# 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. 33# 34BEGIN { 35 nproducts = 0 36 dfile="pnpdevs.h" 37} 38NR == 1 { 39 VERSION = $0 40 gsub("\\$", "", VERSION) 41 42 printf("/* \$MirOS\$ */\n\n") > dfile 43 printf("/*-\n") > dfile 44 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ 45 > dfile 46 printf(" *\n") > dfile 47 printf(" * generated from:\n") > dfile 48 printf(" *\t%s\n", VERSION) > dfile 49 printf(" */\n") > dfile 50 51 next 52} 53{ 54 if ($1 == "") 55 next 56 if (substr($1,0,1) == "#") 57 next 58 if (substr($2,0,1) == "#") 59 next 60 do { 61 nproducts++ 62 if ((x = index($1, "/"))) 63 products[nproducts, 1] = substr($1, 1, x - 1); 64 else 65 products[nproducts, 1] = $1; # driver name 66 products[nproducts, 2] = $2; # pnp id 67# if ($3 && substr($3,0,1) == "#") 68# products[nproducts, 3] = substr($3, 1); 69# printf("%s %s %s\n", $1, $2, products[nproducts, 3]); 70 } while (x && ($1 = substr($1, x + 1, length($1) - x))); 71 72 next 73} 74END { 75 # print out the match tables 76 77 printf("\n") > dfile 78 79 printf("const struct isapnp_knowndev isapnp_knowndevs[] = {\n") > dfile 80 for (i = 1; i <= nproducts; i++) { 81 printf("\t{ {\"%s\"}, {\"%s\"} },", 82 products[i, 2], products[i, 1]) \ 83 > dfile 84 if (products[i, 3]) 85 printf("\t/* %s */", products[i, 3]) > dfile 86 printf("\n") > dfile 87 } 88 printf("};\n") > dfile 89} 90