2 # Copyright (c) 2001-2003
3 # Fraunhofer Institute for Open Communication Systems (FhG Fokus).
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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.
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
27 # Author: Hartmut Brandt <harti@freebsd.org>
29 # $Begemot: libunimsg/netnatm/msg/parsemsg.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
31 # Parse the message definition file
33 match($0, "Begemot:")!=0 {
56 state==0 && $1=="start" {
57 if(NF < 3) error("bad number of fields in message start "$0)
66 if(mcnt == 0) first_entry()
71 state==1 && $1=="end" {
80 if(match($2, "[A-Za-z][A-Za-z0-9_]*/R") == 1) {
81 ienum[cnt]=substr($2, 1, length($2)-2)
88 if(ienum[cnt] != "-") msgrep = 1
89 if($3 == "" || $3 == "-") {
92 gsub("[a-zA-Z][a-zA-Z0-9]*", "cx->&", $3)
100 error("bad line: "$0)
103 function parse_hex(str, n)
106 if(substr(str,1,2) != "0x") {
107 error("bad hex number" str)
109 for(i = 3; i <= length(str); i++) {
111 if(match(c,"[0-9]") != 0) {
113 } else if(match(c,"[a-f]")) {
114 if(c == "a") n = 16 * n + 10
115 if(c == "b") n = 16 * n + 11
116 if(c == "c") n = 16 * n + 12
117 if(c == "d") n = 16 * n + 13
118 if(c == "e") n = 16 * n + 14
119 if(c == "f") n = 16 * n + 15
120 } else if(match(c,"[A-F]")) {
121 if(c == "A") n = 16 * n + 10
122 if(c == "B") n = 16 * n + 11
123 if(c == "C") n = 16 * n + 12
124 if(c == "D") n = 16 * n + 13
125 if(c == "E") n = 16 * n + 14
126 if(c == "F") n = 16 * n + 15
128 error("bad hex digit '" c "'")
136 print "error:" str >"/dev/stderr"