1122205Sharti#
2122205Sharti# Copyright (c) 2001-2003
3122205Sharti# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4122205Sharti# 	All rights reserved.
5122205Sharti#
6122205Sharti# Redistribution and use in source and binary forms, with or without
7122205Sharti# modification, are permitted provided that the following conditions
8122205Sharti# are met:
9122205Sharti# 1. Redistributions of source code must retain the above copyright
10122205Sharti#    notice, this list of conditions and the following disclaimer.
11122205Sharti# 2. Redistributions in binary form must reproduce the above copyright
12122205Sharti#    notice, this list of conditions and the following disclaimer in the
13122205Sharti#    documentation and/or other materials provided with the distribution.
14122205Sharti#
15122205Sharti# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16122205Sharti# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17122205Sharti# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18122205Sharti# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19122205Sharti# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20122205Sharti# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21122205Sharti# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22122205Sharti# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23122205Sharti# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24122205Sharti# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25122205Sharti# SUCH DAMAGE.
26122205Sharti#
27122205Sharti# Author: Hartmut Brandt <harti@freebsd.org>
28122205Sharti# 
29131826Sharti# $Begemot: libunimsg/netnatm/sig/genmsgcpyc.awk,v 1.4 2004/07/08 08:22:18 brandt Exp $
30122205Sharti#
31122205Sharti# Generate copy functions for messages
32122205Sharti#
33122205Shartifunction begin() {
34122205Sharti}
35122205Sharti
36122205Shartifunction first_entry() {
37122205Sharti	print "/* This file was created automatically"
38122205Sharti	print " * Source file: " id
39122205Sharti	print " * $FreeBSD$"
40122205Sharti	print " */"
41122205Sharti	print ""
42122205Sharti	print "#include <netnatm/msg/unistruct.h>"
43122205Sharti	print "#include <netnatm/sig/unimsgcpy.h>"
44122205Sharti}
45122205Sharti
46122205Shartifunction end() {
47122205Sharti}
48122205Sharti
49122205Shartifunction start_message() {
50122205Sharti}
51122205Sharti
52122205Shartifunction end_message() {
53122205Sharti	print ""
54122205Sharti	print "void"
55122205Sharti	print "copy_msg_" msg "(struct uni_" msg " *src, struct uni_" msg " *dst)"
56122205Sharti	print "{"
57122205Sharti	for(i = 0; i < cnt; i++) {
58122205Sharti		if(ienum[i] != "-") {
59122205Sharti			print "\tu_int s, d;"
60122205Sharti			print ""
61122205Sharti			break
62122205Sharti		}
63122205Sharti	}
64122205Sharti	for(i = 0; i < cnt; i++) {
65122205Sharti		ie = iename[i]
66122205Sharti		if(ierep[i]) {
67122205Sharti			print "\tif(IE_ISGOOD(src->" ie "_repeat))"
68122205Sharti			print "\t\tdst->" ie "_repeat = src->" ie "_repeat;"
69122205Sharti		}
70122205Sharti		if(ienum[i] != "-") {
71122205Sharti			print "\tfor(s = d = 0; s < "ienum[i]"; s++)"
72122205Sharti			print "\t\tif(IE_ISGOOD(src->"ie"[s]))"
73122205Sharti			print "\t\t\tdst->"ie"[d++] = src->"ie"[s];"
74122205Sharti		} else {
75122205Sharti			print "\tif(IE_ISGOOD(src->"ie"))"
76122205Sharti			print "\t\tdst->"ie" = src->"ie";"
77122205Sharti		}
78122205Sharti	}
79122205Sharti	print "}"
80122205Sharti}
81