11d96aa5bSmiod#! /usr/bin/awk -f 2*faa11359Smiod# $OpenBSD: devlist2h.awk,v 1.4 2006/08/10 23:44:16 miod Exp $ 31d96aa5bSmiod# 41d96aa5bSmiod# Copyright (c) 2003, Miodrag Vallat. 51d96aa5bSmiod# All rights reserved. 61d96aa5bSmiod# 71d96aa5bSmiod# Redistribution and use in source and binary forms, with or without 81d96aa5bSmiod# modification, are permitted provided that the following conditions 91d96aa5bSmiod# are met: 101d96aa5bSmiod# 1. Redistributions of source code must retain the above copyright 111d96aa5bSmiod# notice, this list of conditions and the following disclaimer. 121d96aa5bSmiod# 2. Redistributions in binary form must reproduce the above copyright 131d96aa5bSmiod# notice, this list of conditions and the following disclaimer in the 141d96aa5bSmiod# documentation and/or other materials provided with the distribution. 151d96aa5bSmiod# 161d96aa5bSmiod# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 171d96aa5bSmiod# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 181d96aa5bSmiod# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 191d96aa5bSmiod# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 201d96aa5bSmiod# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 211d96aa5bSmiod# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 221d96aa5bSmiod# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 231d96aa5bSmiod# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 241d96aa5bSmiod# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 251d96aa5bSmiod# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 261d96aa5bSmiod# 271d96aa5bSmiodBEGIN { 281d96aa5bSmiod header = 0 291d96aa5bSmiod} 301d96aa5bSmiodNR == 1 { 311d96aa5bSmiod VERSION = $0 321d96aa5bSmiod gsub("\\$", "", VERSION) 331d96aa5bSmiod 341d96aa5bSmiod printf("/*\t\$OpenBSD\$\t*/\n\n") 351d96aa5bSmiod printf("/*\n") 361d96aa5bSmiod printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") 371d96aa5bSmiod printf(" *\n") 381d96aa5bSmiod printf(" * generated from:\n") 391d96aa5bSmiod printf(" *\t%s\n", VERSION) 401d96aa5bSmiod printf(" */\n") 411d96aa5bSmiod 421d96aa5bSmiod next 431d96aa5bSmiod} 44ed4260d9Smiod$1 == "keyboard" || $1 == "mouse" || $1 == "idmodule" || $1 == "buttonbox" { 451d96aa5bSmiod 461d96aa5bSmiod if (header == 0) { 471d96aa5bSmiod printf("const struct hildevice hildevs[] = {\n") 481d96aa5bSmiod header = 1 491d96aa5bSmiod } 501d96aa5bSmiod 511d96aa5bSmiod printf("\t{ 0x%s, 0x%s, HIL_DEVICE_%s, \"", 521d96aa5bSmiod $2, $3, toupper($1)) 531d96aa5bSmiod 541d96aa5bSmiod # description, with optional ``#''-prefixed comments 55*faa11359Smiod comment = 0 561d96aa5bSmiod i = 4 571d96aa5bSmiod f = i 581d96aa5bSmiod while (f <= NF) { 591d96aa5bSmiod if ($f == "#") { 60*faa11359Smiod comment = 1 61*faa11359Smiod printf ("\" },\t/*") 62*faa11359Smiod } else { 631d96aa5bSmiod if (f > i) 641d96aa5bSmiod printf(" ") 651d96aa5bSmiod printf("%s", $f) 66*faa11359Smiod } 671d96aa5bSmiod f++ 681d96aa5bSmiod } 69*faa11359Smiod if (comment) 70*faa11359Smiod printf(" */\n"); 71*faa11359Smiod else 721d96aa5bSmiod printf("\" },\n") 731d96aa5bSmiod 741d96aa5bSmiod next 751d96aa5bSmiod} 761d96aa5bSmiod{ 771d96aa5bSmiod if ($0 == "") 781d96aa5bSmiod blanklines++ 791d96aa5bSmiod if (blanklines < 2) 801d96aa5bSmiod print $0 811d96aa5bSmiod} 821d96aa5bSmiodEND { 8356e48520Smiod printf("\t{ -1, -1, -1, NULL }\n") 841d96aa5bSmiod printf("};\n") 851d96aa5bSmiod} 86