The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/ngatm/netnatm/msg/parseie.awk

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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/parseie.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
   30 #
   31 # Parse the IE definition file
   32 #
   33 match($0, "Begemot:")!=0 {
   34         gsub("^[^$]*", "")
   35         gsub("[^$]*$", "")
   36         id = $0
   37         next
   38 }
   39 
   40 /^#/ {
   41         next
   42 }
   43 NF == 0 {
   44         next
   45 }
   46 
   47 BEGIN {
   48         iecnt = 0
   49         id = " * ???"
   50         begin()
   51 }
   52 
   53 END {
   54         end()
   55 }
   56 
   57 #
   58 # Syntax is:
   59 # element <name> <code> <coding> [<maxlen> [<options>*]]
   60 #
   61 $1=="element" {
   62         if(iecnt == 0) first_element()
   63         if(NF < 4) {
   64                 error("Bad number of args: " $0)
   65         }
   66         ie = $2
   67         file = $2
   68         number = parse_hex($3)
   69         coding = $4
   70         if(coding == "itu") {
   71                 ncoding = 0
   72         } else if(coding == "net") {
   73                 ncoding = 3
   74         } else {
   75                 error("bad coding " coding)
   76         }
   77         if(NF == 4) {
   78                 element_default()
   79                 file=""
   80         } else {
   81                 len = $5
   82                 parse_options()
   83                 element()
   84         }
   85         ies[iecnt] = ie
   86         codings[iecnt] = coding
   87         files[iecnt] = file
   88         iecnt++
   89         next
   90 }
   91 
   92 {
   93         error("Bad line: " $0)
   94 }
   95 
   96 function parse_options() {
   97         access = 0
   98         cond = ""
   99         for(i = 6; i <= NF; i++) {
  100                 if($i == "access") {
  101                         access = 1
  102                 } else if($i == "-") {
  103                 } else if(index($i, "file=") == 1) {
  104                         file=substr($i, 6)
  105                 } else {
  106                         if(cond != "") {
  107                                 error("Too many conditions: "$0)
  108                         }
  109                         cond = $i
  110                 }
  111         }
  112 }
  113 
  114 function parse_hex(str,         n)
  115 {
  116         n = 0
  117         if(substr(str,1,2) != "0x") {
  118                 error("bad hex number" str)
  119         }
  120         for(i = 3; i <= length(str); i++) {
  121                 c = substr(str,i,1)
  122                 if(match(c,"[0-9]") != 0) {
  123                         n = 16 * n + c
  124                 } else if(match(c,"[a-f]")) {
  125                         if(c == "a") n = 16 * n + 10
  126                         if(c == "b") n = 16 * n + 11
  127                         if(c == "c") n = 16 * n + 12
  128                         if(c == "d") n = 16 * n + 13
  129                         if(c == "e") n = 16 * n + 14
  130                         if(c == "f") n = 16 * n + 15
  131                 } else if(match(c,"[A-F]")) {
  132                         if(c == "A") n = 16 * n + 10
  133                         if(c == "B") n = 16 * n + 11
  134                         if(c == "C") n = 16 * n + 12
  135                         if(c == "D") n = 16 * n + 13
  136                         if(c == "E") n = 16 * n + 14
  137                         if(c == "F") n = 16 * n + 15
  138                 } else {
  139                         error("bad hex digit '" c "'")
  140                 }
  141         }
  142         return n
  143 }
  144 
  145 # function error(str)
  146 # {
  147 #       print "error:" str >"/dev/stderr"
  148 #       exit 1
  149 # }
  150 

Cache object: b164444f332347b2feb875d2e7cfad8a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.