genmsgcpyc.awk revision 131827
1285SN/A#
2641Smkos# Copyright (c) 2001-2003
3285SN/A# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4285SN/A# 	All rights reserved.
5285SN/A#
6285SN/A# Redistribution and use in source and binary forms, with or without
7285SN/A# modification, are permitted provided that the following conditions
8285SN/A# are met:
9285SN/A# 1. Redistributions of source code must retain the above copyright
10285SN/A#    notice, this list of conditions and the following disclaimer.
11285SN/A# 2. Redistributions in binary form must reproduce the above copyright
12285SN/A#    notice, this list of conditions and the following disclaimer in the
13285SN/A#    documentation and/or other materials provided with the distribution.
14285SN/A#
15285SN/A# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16285SN/A# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17285SN/A# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18285SN/A# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19285SN/A# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20285SN/A# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21285SN/A# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22285SN/A# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23285SN/A# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24285SN/A# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25285SN/A# SUCH DAMAGE.
26285SN/A#
27285SN/A# Author: Hartmut Brandt <harti@freebsd.org>
28285SN/A# 
29285SN/A# $Begemot: libunimsg/netnatm/sig/genmsgcpyc.awk,v 1.4 2004/07/08 08:22:18 brandt Exp $
30285SN/A#
31285SN/A# Generate copy functions for messages
32285SN/A#
33285SN/Afunction begin() {
34285SN/A}
35285SN/A
36285SN/Afunction first_entry() {
37285SN/A	print "/* This file was created automatically"
38285SN/A	print " * Source file: " id
39285SN/A	print " * $FreeBSD: head/sys/contrib/ngatm/netnatm/sig/genmsgcpyc.awk 131827 2004-07-08 16:39:03Z harti $"
40285SN/A	print " */"
41285SN/A	print ""
42627Savstepan	print "#include <netnatm/msg/unistruct.h>"
43285SN/A	print "#include <netnatm/sig/unimsgcpy.h>"
44285SN/A}
45285SN/A
46285SN/Afunction end() {
47285SN/A}
48285SN/A
49285SN/Afunction start_message() {
50285SN/A}
51285SN/A
52285SN/Afunction end_message() {
53285SN/A	print ""
54285SN/A	print "void"
55285SN/A	print "copy_msg_" msg "(struct uni_" msg " *src, struct uni_" msg " *dst)"
56285SN/A	print "{"
57285SN/A	for(i = 0; i < cnt; i++) {
58285SN/A		if(ienum[i] != "-") {
59285SN/A			print "\tu_int s, d;"
60285SN/A			print ""
61285SN/A			break
62285SN/A		}
63285SN/A	}
64285SN/A	for(i = 0; i < cnt; i++) {
65285SN/A		ie = iename[i]
66285SN/A		if(ierep[i]) {
67285SN/A			print "\tif(IE_ISGOOD(src->" ie "_repeat))"
68285SN/A			print "\t\tdst->" ie "_repeat = src->" ie "_repeat;"
69285SN/A		}
70285SN/A		if(ienum[i] != "-") {
71285SN/A			print "\tfor(s = d = 0; s < "ienum[i]"; s++)"
72285SN/A			print "\t\tif(IE_ISGOOD(src->"ie"[s]))"
73285SN/A			print "\t\t\tdst->"ie"[d++] = src->"ie"[s];"
74285SN/A		} else {
75285SN/A			print "\tif(IE_ISGOOD(src->"ie"))"
76285SN/A			print "\t\tdst->"ie" = src->"ie";"
77285SN/A		}
78285SN/A	}
79285SN/A	print "}"
80285SN/A}
81285SN/A