1 #
2 # Copyright (c) 2001-2003
3 # Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 # SUCH DAMAGE.
26 #
27 # Author: Hartmut Brandt <harti@freebsd.org>
28 #
29 # $Begemot: libunimsg/netnatm/msg/geniec.awk,v 1.4 2003/10/10 14:50:05 hbb Exp $
30 #
31 # Generate table for IE parsing.
32 #
33 # This function is called before the first line
34 #
35 function begin() {
36 for(i = 0; i < 256; i++) {
37 for(j = 0; j < 4; j++) {
38 decl[i,j] = ""
39 }
40 }
41 }
42
43 #
44 # This function is called after the last line.
45 #
46 function end() {
47 print ""
48 print "const struct iedecl *uni_ietable[256][4] = {"
49 for(i = 0; i < 256; i++) {
50 printf "\t{"
51 for(j = 0; j < 4; j++) {
52 if(decl[i,j] == "") {
53 printf " NULL,"
54 } else {
55 printf " &%s,", decl[i,j]
56 }
57 }
58 printf " }, /* 0x%02x */\n", i
59 }
60 print "};"
61 }
62
63 #
64 # This function is called just when the first information element was found
65 #
66 function first_element() {
67 print "/* This file was created automatically"
68 print " * Source file: " id
69 print " */"
70 print ""
71 }
72
73 #
74 # This is called, when the information element is defaulted (there is
75 # only the name and the coding scheme
76 #
77 function element_default() {
78 print ""
79 print "static const struct iedecl decl_" coding "_" ie " = {"
80 print "\tUNIFL_DEFAULT,"
81 print "\t0,"
82 print "\t(uni_print_f)NULL,"
83 print "\t(uni_check_f)NULL,"
84 print "\t(uni_encode_f)NULL,"
85 print "\t(uni_decode_f)NULL"
86 print "};"
87 decl[number,ncoding] = "decl_" coding "_" ie
88 }
89
90 #
91 # This is found for a real, non-default IE
92 #
93 function element() {
94 print ""
95 print "static void uni_ie_print_" coding "_" ie "(struct uni_ie_" ie " *, struct unicx *);"
96 print "static int uni_ie_check_" coding "_" ie "(struct uni_ie_" ie " *, struct unicx *);"
97 print "static int uni_ie_encode_" coding "_" ie "(struct uni_msg *, struct uni_ie_" ie " *, struct unicx *);"
98 print "static int uni_ie_decode_" coding "_" ie "(struct uni_ie_" ie " *, struct uni_msg *, u_int, struct unicx *);"
99 print ""
100 print "static struct iedecl decl_" coding "_" ie " = {"
101 if(access) print "\tUNIFL_ACCESS,"
102 else print "\t0,"
103 print "\t" len ","
104 print "\t(uni_print_f)uni_ie_print_" coding "_" ie ","
105 print "\t(uni_check_f)uni_ie_check_" coding "_" ie ","
106 print "\t(uni_encode_f)uni_ie_encode_" coding "_" ie ","
107 print "\t(uni_decode_f)uni_ie_decode_" coding "_" ie ""
108 print "};"
109 decl[number,ncoding] = "decl_" coding "_" ie
110 }
Cache object: bc1a5997969273bada3f8e44c2dac7b6
|