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/dev/podulebus/podulelist2h.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: podulelist2h.awk,v 1.4 2005/12/11 12:23:28 christos Exp $
    3 #       from: devlist2h.awk,v 1.2 1996/01/22 21:08:09 cgd Exp
    4 #
    5 # Copyright (c) 1996 Mark Brinicombe
    6 # Copyright (c) 1995, 1996 Christopher G. Demetriou
    7 # All rights reserved.
    8 #
    9 # Redistribution and use in source and binary forms, with or without
   10 # modification, are permitted provided that the following conditions
   11 # are met:
   12 # 1. Redistributions of source code must retain the above copyright
   13 #    notice, this list of conditions and the following disclaimer.
   14 # 2. Redistributions in binary form must reproduce the above copyright
   15 #    notice, this list of conditions and the following disclaimer in the
   16 #    documentation and/or other materials provided with the distribution.
   17 # 3. All advertising materials mentioning features or use of this software
   18 #    must display the following acknowledgement:
   19 #      This product includes software developed by Mark Brinicombe
   20 # 4. The name of the author may not be used to endorse or promote products
   21 #    derived from this software without specific prior written permission
   22 #
   23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   25 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   26 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   28 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   32 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   33 #
   34 BEGIN {
   35         npodules = nvendors = 0
   36         dfile="podule_data.h"
   37         hfile="podules.h"
   38 }
   39 NR == 1 {
   40         VERSION = $0
   41         gsub("\\$", "", VERSION)
   42         gsub(/ $/, "", VERSION)
   43 
   44         printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
   45         printf("/*\n") > dfile
   46         printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
   47             > dfile
   48         printf(" *\n") > dfile
   49         printf(" * generated from:\n") > dfile
   50         printf(" *\t%s\n", VERSION) > dfile
   51         printf(" */\n") > dfile
   52 
   53         printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
   54         printf("/*\n") > hfile
   55         printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
   56             > hfile
   57         printf(" *\n") > hfile
   58         printf(" * generated from:\n") > hfile
   59         printf(" *\t%s\n", VERSION) > hfile
   60         printf(" */\n") > hfile
   61 
   62         next
   63 }
   64 $1 == "manufacturer" {
   65         nvendors++
   66 
   67         vendorindex[$2] = nvendors;             # record index for this name, for later.
   68         vendors[nvendors, 1] = $2;              # name
   69         vendors[nvendors, 2] = $3;              # id
   70         printf("#define\tMANUFACTURER_%s\t%s\t", vendors[nvendors, 1],
   71             vendors[nvendors, 2]) > hfile
   72         i = 3; f = 4;
   73 
   74         # comments
   75         ocomment = oparen = 0
   76         if (f <= NF) {
   77                 printf("\t/* ") > hfile
   78                 ocomment = 1;
   79         }
   80         while (f <= NF) {
   81                 if ($f == "#") {
   82                         printf("(") > hfile
   83                         oparen = 1
   84                         f++
   85                         continue
   86                 }
   87                 if (oparen) {
   88                         printf("%s", $f) > hfile
   89                         if (f < NF)
   90                                 printf(" ") > hfile
   91                         f++
   92                         continue
   93                 }
   94                 vendors[nvendors, i] = $f
   95                 printf("%s", vendors[nvendors, i]) > hfile
   96                 if (f < NF)
   97                         printf(" ") > hfile
   98                 i++; f++;
   99         }
  100         if (oparen)
  101                 printf(")") > hfile
  102         if (ocomment)
  103                 printf(" */") > hfile
  104         printf("\n") > hfile
  105 
  106         next
  107 }
  108 $1 == "podule" {
  109         npodules++
  110 
  111         podules[npodules, 1] = $2;              # podule id
  112         podules[npodules, 2] = $3;              # id
  113         printf("#define\tPODULE_%s\t%s\t",
  114             podules[npodules, 1], podules[npodules, 2]) > hfile
  115 
  116         i=3; f = 4;
  117 
  118         # comments
  119         ocomment = oparen = 0
  120         if (f <= NF) {
  121                 printf("\t/* ") > hfile
  122                 ocomment = 1;
  123         }
  124         while (f <= NF) {
  125                 if ($f == "#") {
  126                         printf("(") > hfile
  127                         oparen = 1
  128                         f++
  129                         continue
  130                 }
  131                 if (oparen) {
  132                         printf("%s", $f) > hfile
  133                         if (f < NF)
  134                                 printf(" ") > hfile
  135                         f++
  136                         continue
  137                 }
  138                 podules[npodules, i] = $f
  139                 printf("%s", podules[npodules, i]) > hfile
  140                 if (f < NF)
  141                         printf(" ") > hfile
  142                 i++; f++;
  143         }
  144         if (oparen)
  145                 printf(")") > hfile
  146         if (ocomment)
  147                 printf(" */") > hfile
  148         printf("\n") > hfile
  149 
  150         next
  151 }
  152 {
  153         if ($0 == "")
  154                 blanklines++
  155         print $0 > hfile
  156         if (blanklines < 2)
  157                 print $0 > dfile
  158 }
  159 END {
  160         # print out the match tables
  161 
  162         printf("\n") > dfile
  163 
  164         printf("static struct podule_description known_podules[] = {\n") > dfile
  165         for (j = 1; j <= npodules; j++) {
  166                 printf("\t{ PODULE_%s,", podules[j, 1]) > dfile
  167                 printf("\t\"") > dfile
  168                 k = 3;
  169                 needspace = 0;
  170                 while (podules[j, k] != "") {
  171                         if (needspace)
  172                                 printf(" ") > dfile
  173                         printf("%s", podules[j, k]) > dfile
  174                         needspace = 1
  175                         k++
  176                 }
  177                 printf("\" },\n") > dfile
  178         }
  179         printf("\t{ 0x0000, NULL }\n") > dfile
  180         printf("};\n\n") > dfile
  181 
  182         printf("\n") > dfile
  183 
  184         printf("struct manufacturer_description known_manufacturers[] = {\n") > dfile
  185         for (i = 1; i <= nvendors; i++) {
  186                 printf("\t{ MANUFACTURER_%s, \t", vendors[i, 1]) > dfile
  187                 if (length(vendors[i, 1]) < 7)
  188                         printf("\t") > dfile
  189                 printf("\"") > dfile
  190                 j = 3;
  191                 needspace = 0;
  192                 while (vendors[i, j] != "") {
  193                         if (needspace)
  194                                 printf(" ") > dfile
  195                         printf("%s", vendors[i, j]) > dfile
  196                         needspace = 1
  197                         j++
  198                 }
  199                 printf("\" },\n") > dfile
  200         }
  201         printf("\t{ 0, NULL }\n") > dfile
  202         printf("};\n") > dfile
  203 }

Cache object: f2b2277426c061c25186b6da2d457619


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