Home | History | Annotate | Line # | Download | only in hil
      1  1.1   tsutsui #! /usr/bin/awk -f
      2  1.2  christos #	$NetBSD: devlist2h.awk,v 1.2 2016/10/26 13:47:05 christos Exp $
      3  1.1   tsutsui #	$OpenBSD: devlist2h.awk,v 1.4 2006/08/10 23:44:16 miod Exp $
      4  1.1   tsutsui #
      5  1.1   tsutsui # Copyright (c) 2003, Miodrag Vallat.
      6  1.1   tsutsui # All rights reserved.
      7  1.1   tsutsui #
      8  1.1   tsutsui # Redistribution and use in source and binary forms, with or without
      9  1.1   tsutsui # modification, are permitted provided that the following conditions
     10  1.1   tsutsui # are met:
     11  1.1   tsutsui # 1. Redistributions of source code must retain the above copyright
     12  1.1   tsutsui #    notice, this list of conditions and the following disclaimer.
     13  1.1   tsutsui # 2. Redistributions in binary form must reproduce the above copyright
     14  1.1   tsutsui #    notice, this list of conditions and the following disclaimer in the
     15  1.1   tsutsui #    documentation and/or other materials provided with the distribution.
     16  1.1   tsutsui #
     17  1.1   tsutsui # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  1.1   tsutsui # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  1.1   tsutsui # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.1   tsutsui # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  1.1   tsutsui # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22  1.1   tsutsui # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23  1.1   tsutsui # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24  1.1   tsutsui # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  1.1   tsutsui # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26  1.1   tsutsui # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  1.1   tsutsui #
     28  1.1   tsutsui BEGIN {
     29  1.1   tsutsui 	header = 0
     30  1.1   tsutsui }
     31  1.1   tsutsui NR == 1 {
     32  1.1   tsutsui 	VERSION = $0
     33  1.1   tsutsui 	gsub("\\$", "", VERSION)
     34  1.1   tsutsui 
     35  1.2  christos 	printf("/*\t$NetBSD%s\t*/\n\n", "$")
     36  1.1   tsutsui 	printf("/*\n")
     37  1.1   tsutsui 	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n")
     38  1.1   tsutsui 	printf(" *\n")
     39  1.1   tsutsui 	printf(" * generated from:\n")
     40  1.1   tsutsui 	printf(" *\t%s\n", VERSION)
     41  1.1   tsutsui 	printf(" */\n")
     42  1.1   tsutsui 
     43  1.1   tsutsui 	next
     44  1.1   tsutsui }
     45  1.1   tsutsui $1 == "keyboard" || $1 == "mouse" || $1 == "idmodule" || $1 == "buttonbox" {
     46  1.1   tsutsui 
     47  1.1   tsutsui 	if (header == 0) {
     48  1.1   tsutsui 		printf("const struct hildevice hildevs[] = {\n")
     49  1.1   tsutsui 		header = 1
     50  1.1   tsutsui 	}
     51  1.1   tsutsui 
     52  1.1   tsutsui 	printf("\t{ 0x%s, 0x%s, HIL_DEVICE_%s, \"",
     53  1.1   tsutsui 	    $2, $3, toupper($1))
     54  1.1   tsutsui 
     55  1.1   tsutsui 	# description, with optional ``#''-prefixed comments
     56  1.1   tsutsui 	comment = 0
     57  1.1   tsutsui 	i = 4
     58  1.1   tsutsui 	f = i
     59  1.1   tsutsui 	while (f <= NF) {
     60  1.1   tsutsui 		if ($f == "#") {
     61  1.1   tsutsui 			comment = 1
     62  1.1   tsutsui 			printf ("\" },\t/*")
     63  1.1   tsutsui 		} else {
     64  1.1   tsutsui 			if (f > i)
     65  1.1   tsutsui 				printf(" ")
     66  1.1   tsutsui 			printf("%s", $f)
     67  1.1   tsutsui 		}
     68  1.1   tsutsui 		f++
     69  1.1   tsutsui 	}
     70  1.1   tsutsui 	if (comment)
     71  1.1   tsutsui 		printf(" */\n");
     72  1.1   tsutsui 	else
     73  1.1   tsutsui 		printf("\" },\n")
     74  1.1   tsutsui 
     75  1.1   tsutsui 	next
     76  1.1   tsutsui }
     77  1.1   tsutsui {
     78  1.1   tsutsui 	if ($0 == "")
     79  1.1   tsutsui 		blanklines++
     80  1.1   tsutsui 	if (blanklines < 2)
     81  1.1   tsutsui 		print $0
     82  1.1   tsutsui }
     83  1.1   tsutsui END {
     84  1.1   tsutsui 	printf("\t{ -1, -1, -1, NULL }\n")
     85  1.1   tsutsui 	printf("};\n")
     86  1.1   tsutsui }
     87