1#! /usr/bin/awk -f 2# $OpenBSD: devlist2h.awk,v 1.6 2006/03/13 22:00:31 miod Exp $ 3# $NetBSD: devlist2h.awk,v 1.3 1996/06/05 18:32:19 cgd Exp $ 4# 5# Copyright (c) 1995, 1996 Christopher G. Demetriou 6# All rights reserved. 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions 10# are met: 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 21# 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. 32# 33BEGIN { 34 dfile="tcdevs_data.h" 35} 36NR == 1 { 37 VERSION = $0 38 gsub("\\$", "", VERSION) 39 40 printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile 41 printf("/*\n") > dfile 42 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ 43 > dfile 44 printf(" *\n") > dfile 45 printf(" * generated from:\n") > dfile 46 printf(" *\t%s\n", VERSION) > dfile 47 printf(" */\n") > dfile 48 49 next 50} 51$1 == "device" { 52 ndevices++ 53 54 devices[ndevices] = $2; # devices id 55 description[ndevices] = $4 56 57 f = 5; 58 while (f <= NF) { 59 description[ndevices] = sprintf("%s %s", description[ndevices], $f) 60 f++; 61 } 62 63 next 64} 65END { 66 # print out the match tables 67 68 printf("\n") > dfile 69 70 printf("struct tc_knowndev tc_knowndevs[] = {\n") > dfile 71 for (i = 1; i <= ndevices; i++) { 72 printf("\t{\n") > dfile 73 printf("\t \"%-8s\",\n", devices[i]) \ 74 > dfile 75 printf("\t \"%s\"\n", description[i]) \ 76 > dfile 77 78 printf("\t},\n") > dfile 79 } 80 printf("\t{ NULL, NULL }\n") > dfile 81 printf("};\n") > dfile 82} 83