150120Swpaul#! /usr/bin/awk -f 250120Swpaul# $NetBSD: devlist2h.awk,v 1.2 1998/09/05 14:42:06 christos Exp $ 3139825Simp 4139825Simp#- 550120Swpaul# Copyright (c) 1998 The NetBSD Foundation, Inc. 650120Swpaul# All rights reserved. 750120Swpaul# 850120Swpaul# This code is derived from software contributed to The NetBSD Foundation 950120Swpaul# by Christos Zoulas. 1050120Swpaul# 1150120Swpaul# Redistribution and use in source and binary forms, with or without 1250120Swpaul# modification, are permitted provided that the following conditions 1350120Swpaul# are met: 1450120Swpaul# 1. Redistributions of source code must retain the above copyright 1550120Swpaul# notice, this list of conditions and the following disclaimer. 1650120Swpaul# 2. Redistributions in binary form must reproduce the above copyright 1750120Swpaul# notice, this list of conditions and the following disclaimer in the 1850120Swpaul# documentation and/or other materials provided with the distribution. 1950120Swpaul# 2050120Swpaul# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2150120Swpaul# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2250120Swpaul# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2350120Swpaul# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2450120Swpaul# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2550120Swpaul# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2650120Swpaul# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2750120Swpaul# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2850120Swpaul# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2950120Swpaul# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3050120Swpaul# POSSIBILITY OF SUCH DAMAGE. 3150120Swpaul# 3250120Swpaul# Copyright (c) 1995, 1996 Christopher G. Demetriou 3350120Swpaul# All rights reserved. 3450120Swpaul# 3550120Swpaul# Redistribution and use in source and binary forms, with or without 3650120Swpaul# modification, are permitted provided that the following conditions 3750120Swpaul# are met: 3850120Swpaul# 1. Redistributions of source code must retain the above copyright 3950120Swpaul# notice, this list of conditions and the following disclaimer. 4050120Swpaul# 2. Redistributions in binary form must reproduce the above copyright 4150120Swpaul# notice, this list of conditions and the following disclaimer in the 4250120Swpaul# documentation and/or other materials provided with the distribution. 4350120Swpaul# 3. All advertising materials mentioning features or use of this software 4450120Swpaul# must display the following acknowledgement: 4550120Swpaul# This model includes software developed by Christopher G. Demetriou. 4650120Swpaul# This model includes software developed by Christos Zoulas 4750120Swpaul# 4. The name of the author(s) may not be used to endorse or promote models 4850120Swpaul# derived from this software without specific prior written permission 4950120Swpaul# 5050120Swpaul# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 5150120Swpaul# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 5250120Swpaul# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 5350120Swpaul# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 5450120Swpaul# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 5550120Swpaul# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 5650120Swpaul# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 5750120Swpaul# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 5850120Swpaul# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 5950120Swpaul# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6050120Swpaul# 6150477Speter# $FreeBSD$ 6250120Swpaul# 6350120Swpaulfunction collectline(f, line) { 6450120Swpaul oparen = 0 6550120Swpaul line = "" 6650120Swpaul while (f <= NF) { 6750120Swpaul if ($f == "#") { 6850120Swpaul line = line "(" 6950120Swpaul oparen = 1 7050120Swpaul f++ 7150120Swpaul continue 7250120Swpaul } 7350120Swpaul if (oparen) { 7450120Swpaul line = line $f 7550120Swpaul if (f < NF) 7650120Swpaul line = line " " 7750120Swpaul f++ 7850120Swpaul continue 7950120Swpaul } 8050120Swpaul line = line $f 8150120Swpaul if (f < NF) 8250120Swpaul line = line " " 8350120Swpaul f++ 8450120Swpaul } 8550120Swpaul if (oparen) 8650120Swpaul line = line ")" 8750120Swpaul return line 8850120Swpaul} 8950120SwpaulBEGIN { 9050120Swpaul nmodels = nouis = 0 9150120Swpaul hfile="miidevs.h" 9250120Swpaul} 9350120SwpaulNR == 1 { 9450120Swpaul VERSION = $0 9550120Swpaul gsub("\\$", "", VERSION) 9650120Swpaul 97109514Sobrien printf("/* \$FreeBSD\$ */\n\n") > hfile 9850120Swpaul printf("/*\n") > hfile 9950120Swpaul printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ 10050120Swpaul > hfile 10150120Swpaul printf(" *\n") > hfile 10250120Swpaul printf(" * generated from:\n") > hfile 10350120Swpaul printf(" *\t%s\n", VERSION) > hfile 10450120Swpaul printf(" */\n") > hfile 10550120Swpaul 10650120Swpaul next 10750120Swpaul} 10850120Swpaul$1 == "oui" { 10950120Swpaul nuios++ 11050120Swpaul 11150120Swpaul ouiindex[$2] = nouis; # record index for this name, for later. 11250120Swpaul 11350120Swpaul ouis[nouis, 1] = $2; # name 11450120Swpaul ouis[nouis, 2] = $3; # id 11550120Swpaul printf("#define\tMII_OUI_%s\t%s\t", ouis[nouis, 1], 11650120Swpaul ouis[nouis, 2]) > hfile 11750120Swpaul ouis[nouis, 3] = collectline(4, line) 11850120Swpaul printf("/* %s */\n", ouis[nouis, 3]) > hfile 11950120Swpaul next 12050120Swpaul} 12150120Swpaul$1 == "model" { 12250120Swpaul nmodels++ 12350120Swpaul 12450120Swpaul models[nmodels, 1] = $2; # oui name 12550120Swpaul models[nmodels, 2] = $3; # model id 12650120Swpaul models[nmodels, 3] = $4; # id 12750120Swpaul 12850120Swpaul printf("#define\tMII_MODEL_%s_%s\t%s\n", models[nmodels, 1], 12950120Swpaul models[nmodels, 2], models[nmodels, 3]) > hfile 13050120Swpaul 13150120Swpaul models[nmodels, 4] = collectline(5, line) 13250120Swpaul 13350120Swpaul printf("#define\tMII_STR_%s_%s\t\"%s\"\n", 13450120Swpaul models[nmodels, 1], models[nmodels, 2], 13550120Swpaul models[nmodels, 4]) > hfile 13650120Swpaul 13750120Swpaul next 13850120Swpaul} 13950120Swpaul{ 14050120Swpaul print $0 > hfile 14150120Swpaul} 142