1121934Sharti#
2121934Sharti# Copyright (c) 2001-2003
3121934Sharti# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4121934Sharti# 	All rights reserved.
5121934Sharti#
6121934Sharti# Redistribution and use in source and binary forms, with or without
7121934Sharti# modification, are permitted provided that the following conditions
8121934Sharti# are met:
9121934Sharti# 1. Redistributions of source code must retain the above copyright
10121934Sharti#    notice, this list of conditions and the following disclaimer.
11121934Sharti# 2. Redistributions in binary form must reproduce the above copyright
12121934Sharti#    notice, this list of conditions and the following disclaimer in the
13121934Sharti#    documentation and/or other materials provided with the distribution.
14121934Sharti#
15121934Sharti# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16121934Sharti# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17121934Sharti# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18121934Sharti# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19121934Sharti# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20121934Sharti# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21121934Sharti# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22121934Sharti# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23121934Sharti# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24121934Sharti# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25121934Sharti# SUCH DAMAGE.
26121934Sharti#
27121934Sharti# Author: Hartmut Brandt <harti@freebsd.org>
28121934Sharti#
29131826Sharti# $Begemot: libunimsg/netnatm/msg/genmsgh.awk,v 1.4 2004/07/08 08:22:04 brandt Exp $
30121934Sharti#
31121934Sharti# Generate message header
32121934Sharti#
33121934Shartifunction begin() {
34121934Sharti}
35121934Sharti
36121934Shartifunction first_entry() {
37121934Sharti	print "/* This file was created automatically"
38121934Sharti	print " * Source file: " id
39121934Sharti	print " */"
40121934Sharti	print ""
41121934Sharti	print "#ifndef _NETNATM_MSG_UNI_MSG_H_"
42121934Sharti	print "#define _NETNATM_MSG_UNI_MSG_H_"
43121934Sharti}
44121934Sharti
45121934Shartifunction end() {
46121934Sharti	print ""
47121934Sharti	print "union uni_msgall {"
48121934Sharti	print "\tstruct uni_msghdr\thdr;"
49121934Sharti	for(i = 0; i < mcnt; i++) {
50121934Sharti		m = messages[i]
51121934Sharti		if(msgcond[i] == "") {
52121934Sharti			print "\tstruct uni_" m "\t" m ";"
53121934Sharti		} else {
54121934Sharti			print "\tstruct uni_" m "\t" m ";\t/* " msgcond[i] " */"
55121934Sharti		}
56121934Sharti	}
57121934Sharti	print "};"
58121934Sharti	print ""
59121934Sharti	print "#endif"
60121934Sharti}
61121934Sharti
62121934Shartifunction start_message() {
63121934Sharti}
64121934Sharti
65121934Shartifunction end_message() {
66121934Sharti	print ""
67121934Sharti	print "struct uni_" msg " {"
68121934Sharti	print "\tstruct uni_msghdr\thdr;"
69121934Sharti	for(i = 0; i < cnt; i++) {
70121934Sharti		if(ierep[i]) {
71121934Sharti			print "\tstruct uni_ie_repeat\t" iename[i] "_repeat;"
72121934Sharti		}
73121934Sharti		if(ienum[i] != "-") {
74121934Sharti			print "\tstruct uni_ie_" iename[i] "\t" iename[i] "[" ienum[i] "];"
75121934Sharti		} else {
76121934Sharti			print "\tstruct uni_ie_" iename[i] "\t" iename[i] ";"
77121934Sharti		}
78121934Sharti	}
79121934Sharti	print "};"
80121934Sharti}
81