8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libipmi / common / mktables.sh
blob0d0211b8b815def408ff6448f6c7016190f09077
1 #!/bin/sh
4 # CDDL HEADER START
6 # The contents of this file are subject to the terms of the
7 # Common Development and Distribution License (the "License").
8 # You may not use this file except in compliance with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
24 # Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Construct translation tables for defines in libipmi.h to translate to readable
30 # strings.
33 if [ $# -ne 1 ]; then
34 echo >&2 "USAGE: $0 <path to libimpi.h>"
35 exit 1
38 if [ -r $1 ]; then
39 libipmi_h=$1
40 else
41 echo >&2 "USAGE: $0 <path to libimpi.h>"
42 echo >&2 "Make sure libipmi.h exists and is readable"
43 exit 1
46 echo "\
48 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
49 * Use is subject to license terms.
52 #include <libipmi.h>
53 #include <ipmi_impl.h>"
56 # Error table.
58 echo "
59 ipmi_name_trans_t ipmi_errno_table[] = {"
61 pattern=" \(EIPMI_[0-9A-Z_]*\)[^ \/]*\/\* \(.*\) \*\/$"
62 replace=" { \1, \"\2\" },"
64 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
66 echo "\t{ 0, NULL }
67 };"
70 # Entity table.
72 echo "\nipmi_name_trans_t ipmi_entity_table[] = {"
74 pattern="#define IPMI_ET_\([A-Z0-9_]*\).*\$"
75 replace=" { IPMI_ET_\1, \"\1\" },"
77 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
79 echo "\t{ 0, NULL }
80 };"
83 # Sensor types.
85 echo "\nipmi_name_trans_t ipmi_sensor_type_table[] = {"
87 pattern="#define IPMI_ST_\([A-Z0-9_]*\).*\$"
88 replace=" { IPMI_ST_\1, \"\1\" },"
90 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
92 echo "\t{ 0, NULL }
93 };"
96 # Reading types.
98 echo "\nipmi_name_trans_t ipmi_reading_type_table[] = {"
100 pattern="#define IPMI_RT_\([A-Z0-9_]*\).*\$"
101 replace=" { IPMI_RT_\1, \"\1\" },"
103 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
105 echo "\t{ 0, NULL }
109 # Units
111 echo "\nipmi_name_trans_t ipmi_units_type_table[] = {"
113 pattern="#define IPMI_UNITS_\([A-Z0-9_]*\).*\$"
114 replace=" { IPMI_UNITS_\1, \"\1\" },"
116 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
118 echo "\t{ 0, NULL }