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/tools/pccarddevs2h.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 #! /usr/bin/awk -f
    2 #       $NetBSD: devlist2h.awk,v 1.3 1998/09/05 14:42:06 christos Exp $
    3 # $FreeBSD: releng/11.2/sys/tools/pccarddevs2h.awk 263289 2014-03-18 01:40:25Z emaste $
    4 
    5 #-
    6 # Copyright (c) 1998 The NetBSD Foundation, Inc.
    7 # All rights reserved.
    8 #
    9 # This code is derived from software contributed to The NetBSD Foundation
   10 # by Christos Zoulas.
   11 #
   12 # Redistribution and use in source and binary forms, with or without
   13 # modification, are permitted provided that the following conditions
   14 # are met:
   15 # 1. Redistributions of source code must retain the above copyright
   16 #    notice, this list of conditions and the following disclaimer.
   17 # 2. Redistributions in binary form must reproduce the above copyright
   18 #    notice, this list of conditions and the following disclaimer in the
   19 #    documentation and/or other materials provided with the distribution.
   20 #
   21 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   22 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   23 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   24 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   25 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   26 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   27 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   28 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   29 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   30 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   31 # POSSIBILITY OF SUCH DAMAGE.
   32 #
   33 # Copyright (c) 1995, 1996 Christopher G. Demetriou
   34 # All rights reserved.
   35 #
   36 # Redistribution and use in source and binary forms, with or without
   37 # modification, are permitted provided that the following conditions
   38 # are met:
   39 # 1. Redistributions of source code must retain the above copyright
   40 #    notice, this list of conditions and the following disclaimer.
   41 # 2. Redistributions in binary form must reproduce the above copyright
   42 #    notice, this list of conditions and the following disclaimer in the
   43 #    documentation and/or other materials provided with the distribution.
   44 # 3. All advertising materials mentioning features or use of this software
   45 #    must display the following acknowledgement:
   46 #      This product includes software developed by Christopher G. Demetriou.
   47 #      This product includes software developed by Christos Zoulas
   48 # 4. The name of the author(s) may not be used to endorse or promote products
   49 #    derived from this software without specific prior written permission
   50 #
   51 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   52 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   53 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   54 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   55 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   56 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   57 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   58 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   59 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   60 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   61 #
   62 function collectline(f, line) {
   63         oparen = 0
   64         line = ""
   65         while (f <= NF) {
   66                 if ($f == "#") {
   67                         line = line "("
   68                         oparen = 1
   69                         f++
   70                         continue
   71                 }
   72                 if (oparen) {
   73                         line = line $f
   74                         if (f < NF)
   75                                 line = line " "
   76                         f++
   77                         continue
   78                 }
   79                 line = line $f
   80                 if (f < NF)
   81                         line = line " "
   82                 f++
   83         }
   84         if (oparen)
   85                 line = line ")"
   86         return line
   87 }
   88 BEGIN {
   89         nproducts = nvendors = 0
   90         hfile="pccarddevs.h"
   91 }
   92 NR == 1 {
   93         VERSION = $0
   94         gsub("\\$", "", VERSION)
   95 
   96         printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
   97         printf("/*\n") > hfile
   98         printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
   99             > hfile
  100         printf(" *\n") > hfile
  101         printf(" * generated from:\n") > hfile
  102         printf(" *\t%s\n", VERSION) > hfile
  103         printf(" */\n") > hfile
  104 
  105         next
  106 }
  107 $1 == "vendor" {
  108         nvendors++
  109 
  110         vendorindex[$2] = nvendors;             # record index for this name, for later.
  111         vendors[nvendors, 1] = $2;              # name
  112         if ($3 == "-1")
  113                 $3 = "0xffffffff";
  114         vendors[nvendors, 2] = $3;              # id
  115         printf("#define\tPCMCIA_VENDOR_%s\t%s\t", vendors[nvendors, 1],
  116             vendors[nvendors, 2]) > hfile
  117         vendors[nvendors, 3] = collectline(4, line)
  118         printf("/* %s */\n", vendors[nvendors, 3]) > hfile
  119         next
  120 }
  121 $1 == "product" {
  122         nproducts++
  123 
  124         products[nproducts, 1] = $2;            # vendor name
  125         if ($3 == "-1")
  126                 $3 = "0xffffffff";
  127         products[nproducts, 2] = $3;            # product id
  128         products[nproducts, 3] = $4;            # id
  129 
  130         f = 5;
  131 
  132         if ($4 == "{") {
  133                 products[nproducts, 3] = "0xffffffff";
  134                 z = "{ "
  135                 for (i = 0; i < 4; i++) {
  136                         if (f <= NF) {
  137                                 gsub("&sp", " ", $f)
  138                                 gsub("&tab", "\t", $f)
  139                                 gsub("&nl", "\n", $f)
  140                                 z = z $f " "
  141                                 f++
  142                         }
  143                         else {
  144                                 if (i == 3)
  145                                         z = z "NULL "
  146                                 else
  147                                         z = z "NULL, "
  148                         }
  149                 }
  150                 products[nproducts, 4] = z $f
  151                 f++
  152         }
  153         else {
  154                 products[nproducts, 4] = "{ NULL, NULL, NULL, NULL }"
  155         }
  156         printf("#define\tPCMCIA_CIS_%s_%s\t%s\n",
  157             products[nproducts, 1], products[nproducts, 2],
  158             products[nproducts, 4]) > hfile
  159         printf("#define\tPCMCIA_PRODUCT_%s_%s\t%s\n", products[nproducts, 1],
  160             products[nproducts, 2], products[nproducts, 3]) > hfile
  161 
  162         products[nproducts, 5] = collectline(f, line)
  163 
  164         printf("#define\tPCMCIA_STR_%s_%s\t\"%s\"\n",
  165             products[nproducts, 1], products[nproducts, 2],
  166             products[nproducts, 5]) > hfile
  167 
  168         next
  169 }
  170 {
  171         print $0 > hfile
  172 }

Cache object: aca6c23abf77180b37d6b5fe36ef68bf


[ 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.