xref: /onnv-gate/usr/src/uts/common/fs/sockfs/nl7ctokgen (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/bin/ksh
2*0Sstevel@tonic-gate#
3*0Sstevel@tonic-gate# CDDL HEADER START
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*0Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*0Sstevel@tonic-gate# with the License.
9*0Sstevel@tonic-gate#
10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*0Sstevel@tonic-gate# See the License for the specific language governing permissions
13*0Sstevel@tonic-gate# and limitations under the License.
14*0Sstevel@tonic-gate#
15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*0Sstevel@tonic-gate#
21*0Sstevel@tonic-gate# CDDL HEADER END
22*0Sstevel@tonic-gate#
23*0Sstevel@tonic-gate#
24*0Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
25*0Sstevel@tonic-gate#
26*0Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
27*0Sstevel@tonic-gate# Use is subject to license terms.
28*0Sstevel@tonic-gate#
29*0Sstevel@tonic-gate# Executed from appropriate arch build directory, e.g. {intel,sparc}/sockfs,
30*0Sstevel@tonic-gate# to generate the nl7ctokgen.h file from nl7ctok*.txt file(s).
31*0Sstevel@tonic-gate#
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gateEXIT=0
34*0Sstevel@tonic-gateIFS=","
35*0Sstevel@tonic-gatewhile [ "$1" != "" ]
36*0Sstevel@tonic-gatedo
37*0Sstevel@tonic-gateNAME=$1
38*0Sstevel@tonic-gateshift
39*0Sstevel@tonic-gate<$NAME sort -f +1 |{
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gatewhile read IDN STR FLG BAD
42*0Sstevel@tonic-gatedo
43*0Sstevel@tonic-gate	if [ "$IDN" != "${IDN#\#}" ]
44*0Sstevel@tonic-gate	then
45*0Sstevel@tonic-gate		continue
46*0Sstevel@tonic-gate	fi
47*0Sstevel@tonic-gate	if [ -n "$BAD" ]
48*0Sstevel@tonic-gate	then
49*0Sstevel@tonic-gate		echo "$IDN: ${BAD## }: too many arguments"
50*0Sstevel@tonic-gate		EXIT=1
51*0Sstevel@tonic-gate	fi
52*0Sstevel@tonic-gate	echo "static char S$IDN[] = ${STR## };"
53*0Sstevel@tonic-gate	ELE="$ELE
54*0Sstevel@tonic-gate	INIT($IDN, ${FLG## }),"
55*0Sstevel@tonic-gate	ENU="$ENU
56*0Sstevel@tonic-gate	$IDN,"
57*0Sstevel@tonic-gatedone
58*0Sstevel@tonic-gateNAME=${NAME##*nl7c}
59*0Sstevel@tonic-gateNAME=${NAME%.txt}
60*0Sstevel@tonic-gateTOKEN="$TOKEN
61*0Sstevel@tonic-gatetoken_t $NAME[] = {
62*0Sstevel@tonic-gate$ELE
63*0Sstevel@tonic-gate	{NULL}
64*0Sstevel@tonic-gate};
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate#define	${NAME}_cnt (sizeof ($NAME) / sizeof (*$NAME))
67*0Sstevel@tonic-gate"
68*0Sstevel@tonic-gateELE=""
69*0Sstevel@tonic-gate
70*0Sstevel@tonic-gate}
71*0Sstevel@tonic-gatedone
72*0Sstevel@tonic-gate
73*0Sstevel@tonic-gateecho "
74*0Sstevel@tonic-gateenum tokid_e {
75*0Sstevel@tonic-gate	_Hdr_First_,
76*0Sstevel@tonic-gate$ENU
77*0Sstevel@tonic-gate	_Hdr_Last_
78*0Sstevel@tonic-gate};
79*0Sstevel@tonic-gate$TOKEN
80*0Sstevel@tonic-gate"
81*0Sstevel@tonic-gate
82*0Sstevel@tonic-gateexit $EXIT
83