Home | History | Annotate | Line # | Download | only in gio
devlist2h.awk revision 1.2.4.3
      1  1.2.4.2  skrll #! /usr/bin/awk -f
      2  1.2.4.3  skrll #	$NetBSD: devlist2h.awk,v 1.2.4.3 2004/09/18 14:39:43 skrll Exp $
      3  1.2.4.2  skrll #
      4  1.2.4.2  skrll # Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  1.2.4.2  skrll # All rights reserved.
      6  1.2.4.2  skrll #
      7  1.2.4.2  skrll # This code is derived from software contributed to The NetBSD Foundation
      8  1.2.4.2  skrll # by Christos Zoulas.
      9  1.2.4.2  skrll #
     10  1.2.4.2  skrll # Redistribution and use in source and binary forms, with or without
     11  1.2.4.2  skrll # modification, are permitted provided that the following conditions
     12  1.2.4.2  skrll # are met:
     13  1.2.4.2  skrll # 1. Redistributions of source code must retain the above copyright
     14  1.2.4.2  skrll #    notice, this list of conditions and the following disclaimer.
     15  1.2.4.2  skrll # 2. Redistributions in binary form must reproduce the above copyright
     16  1.2.4.2  skrll #    notice, this list of conditions and the following disclaimer in the
     17  1.2.4.2  skrll #    documentation and/or other materials provided with the distribution.
     18  1.2.4.2  skrll # 3. All advertising materials mentioning features or use of this software
     19  1.2.4.2  skrll #    must display the following acknowledgement:
     20  1.2.4.2  skrll #        This product includes software developed by the NetBSD
     21  1.2.4.2  skrll #        Foundation, Inc. and its contributors.
     22  1.2.4.2  skrll # 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.2.4.2  skrll #    contributors may be used to endorse or promote products derived
     24  1.2.4.2  skrll #    from this software without specific prior written permission.
     25  1.2.4.2  skrll #
     26  1.2.4.2  skrll # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.2.4.2  skrll # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.2.4.2  skrll # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.2.4.2  skrll # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.2.4.2  skrll # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.2.4.2  skrll # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.2.4.2  skrll # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.2.4.2  skrll # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.2.4.2  skrll # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.2.4.2  skrll # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.2.4.2  skrll # POSSIBILITY OF SUCH DAMAGE.
     37  1.2.4.2  skrll #
     38  1.2.4.2  skrll # Copyright (c) 1995, 1996 Christopher G. Demetriou
     39  1.2.4.2  skrll # All rights reserved.
     40  1.2.4.2  skrll #
     41  1.2.4.2  skrll # Redistribution and use in source and binary forms, with or without
     42  1.2.4.2  skrll # modification, are permitted provided that the following conditions
     43  1.2.4.2  skrll # are met:
     44  1.2.4.2  skrll # 1. Redistributions of source code must retain the above copyright
     45  1.2.4.2  skrll #    notice, this list of conditions and the following disclaimer.
     46  1.2.4.2  skrll # 2. Redistributions in binary form must reproduce the above copyright
     47  1.2.4.2  skrll #    notice, this list of conditions and the following disclaimer in the
     48  1.2.4.2  skrll #    documentation and/or other materials provided with the distribution.
     49  1.2.4.2  skrll # 3. All advertising materials mentioning features or use of this software
     50  1.2.4.2  skrll #    must display the following acknowledgement:
     51  1.2.4.2  skrll #      This product includes software developed by Christopher G. Demetriou.
     52  1.2.4.2  skrll #      This product includes software developed by Christos Zoulas
     53  1.2.4.2  skrll # 4. The name of the author(s) may not be used to endorse or promote products
     54  1.2.4.2  skrll #    derived from this software without specific prior written permission
     55  1.2.4.2  skrll #
     56  1.2.4.2  skrll # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     57  1.2.4.2  skrll # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     58  1.2.4.2  skrll # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     59  1.2.4.2  skrll # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     60  1.2.4.2  skrll # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     61  1.2.4.2  skrll # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     62  1.2.4.2  skrll # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     63  1.2.4.2  skrll # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     64  1.2.4.2  skrll # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     65  1.2.4.2  skrll # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     66  1.2.4.2  skrll #
     67  1.2.4.2  skrll function collectline(_f, _line) {
     68  1.2.4.2  skrll 	_oparen = 0
     69  1.2.4.2  skrll 	_line = ""
     70  1.2.4.2  skrll 	while (_f <= NF) {
     71  1.2.4.2  skrll 		if ($_f == "#") {
     72  1.2.4.2  skrll 			_line = _line "("
     73  1.2.4.2  skrll 			_oparen = 1
     74  1.2.4.2  skrll 			_f++
     75  1.2.4.2  skrll 			continue
     76  1.2.4.2  skrll 		}
     77  1.2.4.2  skrll 		if (_oparen) {
     78  1.2.4.2  skrll 			_line = _line $_f
     79  1.2.4.2  skrll 			if (_f < NF)
     80  1.2.4.2  skrll 				_line = _line " "
     81  1.2.4.2  skrll 			_f++
     82  1.2.4.2  skrll 			continue
     83  1.2.4.2  skrll 		}
     84  1.2.4.2  skrll 		_line = _line $_f
     85  1.2.4.2  skrll 		if (_f < NF)
     86  1.2.4.2  skrll 			_line = _line " "
     87  1.2.4.2  skrll 		_f++
     88  1.2.4.2  skrll 	}
     89  1.2.4.2  skrll 	if (_oparen)
     90  1.2.4.2  skrll 		_line = _line ")"
     91  1.2.4.2  skrll 	return _line
     92  1.2.4.2  skrll }
     93  1.2.4.2  skrll BEGIN {
     94  1.2.4.2  skrll 	nproducts = nvendors = blanklines = 0
     95  1.2.4.2  skrll 	dfile="giodevs_data.h"
     96  1.2.4.2  skrll 	hfile="giodevs.h"
     97  1.2.4.2  skrll 	line=""
     98  1.2.4.2  skrll }
     99  1.2.4.2  skrll NR == 1 {
    100  1.2.4.2  skrll 	VERSION = $0
    101  1.2.4.2  skrll 	gsub("\\$", "", VERSION)
    102  1.2.4.2  skrll 
    103  1.2.4.2  skrll 	printf("/*\t$NetBSD" "$\t*/\n\n") > hfile
    104  1.2.4.2  skrll 	printf("/*\n") > hfile
    105  1.2.4.2  skrll 	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
    106  1.2.4.2  skrll 	    > hfile
    107  1.2.4.2  skrll 	printf(" */\n") > hfile
    108  1.2.4.2  skrll 
    109  1.2.4.2  skrll 	printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
    110  1.2.4.2  skrll 	printf("/*\n") > dfile
    111  1.2.4.2  skrll 	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
    112  1.2.4.2  skrll 	    > dfile
    113  1.2.4.2  skrll 	printf(" */\n") > dfile
    114  1.2.4.2  skrll 
    115  1.2.4.2  skrll 	next
    116  1.2.4.2  skrll }
    117  1.2.4.2  skrll NF > 0 && $1 == "product" {
    118  1.2.4.2  skrll 	nproducts++
    119  1.2.4.2  skrll 
    120  1.2.4.2  skrll 	products[nproducts, 1] = $2;
    121  1.2.4.2  skrll 	products[nproducts, 2] = $3
    122  1.2.4.2  skrll 	products[nproducts, 3] = collectline(4, line)
    123  1.2.4.2  skrll 
    124  1.2.4.2  skrll 	next
    125  1.2.4.2  skrll }
    126  1.2.4.2  skrll {
    127  1.2.4.2  skrll 	if ($0 == "")
    128  1.2.4.2  skrll 		blanklines++
    129  1.2.4.2  skrll 	if (blanklines < 2)
    130  1.2.4.2  skrll 		print $0 > dfile
    131  1.2.4.2  skrll }
    132  1.2.4.2  skrll END {
    133  1.2.4.2  skrll 	# print out the match tables
    134  1.2.4.2  skrll 
    135  1.2.4.2  skrll 	printf("\n") > dfile
    136  1.2.4.2  skrll 
    137  1.2.4.2  skrll 	printf("struct gio_knowndev {\n") > dfile
    138  1.2.4.2  skrll 	printf("\tint productid;\n") > dfile
    139  1.2.4.2  skrll 	printf("\tchar *product;\n") > dfile
    140  1.2.4.2  skrll 	printf("};\n") > dfile
    141  1.2.4.2  skrll 	printf("\nstruct gio_knowndev gio_knowndevs[] = {\n") > dfile
    142  1.2.4.2  skrll 
    143  1.2.4.2  skrll 	printf("\n") > hfile
    144  1.2.4.2  skrll 	for (i = 1; i <= nproducts; i++) {
    145  1.2.4.2  skrll 		printf("#define %s\t%s\t/* %s */\n", products[i, 1], products[i,2], products[i, 3]) > hfile
    146  1.2.4.2  skrll 
    147  1.2.4.2  skrll 		printf("\t{ %s, \"%s\" },\n",
    148  1.2.4.2  skrll 		    products[i, 2], products[i, 3]) > dfile
    149  1.2.4.2  skrll 	}
    150  1.2.4.2  skrll 	printf("\t{ 0, NULL }\n") > dfile
    151  1.2.4.2  skrll 	printf("};\n") > dfile
    152  1.2.4.2  skrll 	close(dfile)
    153  1.2.4.2  skrll 	close(hfile)
    154  1.2.4.2  skrll }
    155