devlist2h.awk revision 1.1.10.2 1 1.1.10.2 tron # $NetBSD: devlist2h.awk,v 1.1.10.2 2006/05/24 15:50:27 tron Exp $
2 1.1.10.2 tron # $OpenBSD: devlist2h.awk,v 1.3 2006/03/10 14:36:32 grange Exp $
3 1.1.10.2 tron
4 1.1.10.2 tron #
5 1.1.10.2 tron # Copyright (c) 2006 Alexander Yurchenko <grange (at] openbsd.org>
6 1.1.10.2 tron #
7 1.1.10.2 tron # Permission to use, copy, modify, and distribute this software for any
8 1.1.10.2 tron # purpose with or without fee is hereby granted, provided that the above
9 1.1.10.2 tron # copyright notice and this permission notice appear in all copies.
10 1.1.10.2 tron #
11 1.1.10.2 tron # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 1.1.10.2 tron # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 1.1.10.2 tron # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 1.1.10.2 tron # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 1.1.10.2 tron # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 1.1.10.2 tron # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 1.1.10.2 tron # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 1.1.10.2 tron #
19 1.1.10.2 tron
20 1.1.10.2 tron BEGIN {
21 1.1.10.2 tron hfile = "onewiredevs.h"
22 1.1.10.2 tron dfile = "onewiredevs_data.h"
23 1.1.10.2 tron }
24 1.1.10.2 tron
25 1.1.10.2 tron NR == 1 {
26 1.1.10.2 tron VERSION = $0
27 1.1.10.2 tron gsub("\\$", "", VERSION)
28 1.1.10.2 tron
29 1.1.10.2 tron printf("/*\t\$NetBSD\$\t*/\n\n" \
30 1.1.10.2 tron "/*\n * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n" \
31 1.1.10.2 tron " *\n * Generated from:\n *\t%s\n */\n\n", VERSION) > hfile
32 1.1.10.2 tron printf("/*\t\$NetBSD\$\t*/\n\n" \
33 1.1.10.2 tron "/*\n * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n" \
34 1.1.10.2 tron " *\n * Generated from:\n *\t%s\n */\n\n", VERSION) > dfile
35 1.1.10.2 tron printf("static const struct onewire_family " \
36 1.1.10.2 tron "onewire_famtab[] = {\n") > dfile
37 1.1.10.2 tron }
38 1.1.10.2 tron
39 1.1.10.2 tron $1 == "family" {
40 1.1.10.2 tron printf("#define ONEWIRE_FAMILY_%s\t%s\n", toupper($2), $3) > hfile
41 1.1.10.2 tron printf("\t{ ONEWIRE_FAMILY_%s, \"", toupper($2)) > dfile
42 1.1.10.2 tron
43 1.1.10.2 tron f = 4
44 1.1.10.2 tron while (f <= NF) {
45 1.1.10.2 tron if (f > 4)
46 1.1.10.2 tron printf(" ") > dfile
47 1.1.10.2 tron printf("%s", $f) > dfile
48 1.1.10.2 tron f++
49 1.1.10.2 tron }
50 1.1.10.2 tron printf("\" },\n") > dfile
51 1.1.10.2 tron next
52 1.1.10.2 tron }
53 1.1.10.2 tron
54 1.1.10.2 tron END {
55 1.1.10.2 tron printf("\t{ 0, NULL }\n};\n") > dfile
56 1.1.10.2 tron }
57