18bd19141Sniklas#! /usr/bin/awk -f 2*fc3d7946Smiod# $OpenBSD: devlist2h.awk,v 1.6 2006/03/13 22:00:31 miod Exp $ 3016fa7cdSniklas# $NetBSD: devlist2h.awk,v 1.3 1996/06/05 18:32:19 cgd Exp $ 48bd19141Sniklas# 58bd19141Sniklas# Copyright (c) 1995, 1996 Christopher G. Demetriou 68bd19141Sniklas# All rights reserved. 78bd19141Sniklas# 88bd19141Sniklas# Redistribution and use in source and binary forms, with or without 98bd19141Sniklas# modification, are permitted provided that the following conditions 108bd19141Sniklas# are met: 118bd19141Sniklas# 1. Redistributions of source code must retain the above copyright 128bd19141Sniklas# notice, this list of conditions and the following disclaimer. 138bd19141Sniklas# 2. Redistributions in binary form must reproduce the above copyright 148bd19141Sniklas# notice, this list of conditions and the following disclaimer in the 158bd19141Sniklas# documentation and/or other materials provided with the distribution. 168bd19141Sniklas# 3. All advertising materials mentioning features or use of this software 178bd19141Sniklas# must display the following acknowledgement: 188bd19141Sniklas# This product includes software developed by Christopher G. Demetriou. 198bd19141Sniklas# 4. The name of the author may not be used to endorse or promote products 208bd19141Sniklas# derived from this software without specific prior written permission 218bd19141Sniklas# 228bd19141Sniklas# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 238bd19141Sniklas# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 248bd19141Sniklas# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 258bd19141Sniklas# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 268bd19141Sniklas# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 278bd19141Sniklas# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 288bd19141Sniklas# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 298bd19141Sniklas# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 308bd19141Sniklas# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 318bd19141Sniklas# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 328bd19141Sniklas# 338bd19141SniklasBEGIN { 348bd19141Sniklas dfile="tcdevs_data.h" 358bd19141Sniklas} 368bd19141SniklasNR == 1 { 378bd19141Sniklas VERSION = $0 388bd19141Sniklas gsub("\\$", "", VERSION) 398bd19141Sniklas 40aa76beb5Smiod printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile 418bd19141Sniklas printf("/*\n") > dfile 428bd19141Sniklas printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ 438bd19141Sniklas > dfile 448bd19141Sniklas printf(" *\n") > dfile 458bd19141Sniklas printf(" * generated from:\n") > dfile 468bd19141Sniklas printf(" *\t%s\n", VERSION) > dfile 478bd19141Sniklas printf(" */\n") > dfile 488bd19141Sniklas 498bd19141Sniklas next 508bd19141Sniklas} 518bd19141Sniklas$1 == "device" { 528bd19141Sniklas ndevices++ 538bd19141Sniklas 54*fc3d7946Smiod devices[ndevices] = $2; # devices id 55*fc3d7946Smiod description[ndevices] = $4 568bd19141Sniklas 57*fc3d7946Smiod f = 5; 588bd19141Sniklas while (f <= NF) { 59*fc3d7946Smiod description[ndevices] = sprintf("%s %s", description[ndevices], $f) 60*fc3d7946Smiod f++; 618bd19141Sniklas } 628bd19141Sniklas 638bd19141Sniklas next 648bd19141Sniklas} 658bd19141SniklasEND { 668bd19141Sniklas # print out the match tables 678bd19141Sniklas 688bd19141Sniklas printf("\n") > dfile 698bd19141Sniklas 708bd19141Sniklas printf("struct tc_knowndev tc_knowndevs[] = {\n") > dfile 718bd19141Sniklas for (i = 1; i <= ndevices; i++) { 728bd19141Sniklas printf("\t{\n") > dfile 73*fc3d7946Smiod printf("\t \"%-8s\",\n", devices[i]) \ 748bd19141Sniklas > dfile 75*fc3d7946Smiod printf("\t \"%s\"\n", description[i]) \ 768bd19141Sniklas > dfile 778bd19141Sniklas 788bd19141Sniklas printf("\t},\n") > dfile 798bd19141Sniklas } 80*fc3d7946Smiod printf("\t{ NULL, NULL }\n") > dfile 818bd19141Sniklas printf("};\n") > dfile 828bd19141Sniklas} 83