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