xref: /titanic_51/usr/src/lib/libipmi/common/mktables.sh (revision 4df55fde49134f9735f84011f23a767c75e393c7)
1#!/bin/sh
2
3#
4# CDDL HEADER START
5#
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.
9#
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.
14#
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]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27#ident	"%Z%%M%	%I%	%E% SMI"
28
29#
30# Construct translation tables for defines in libipmi.h to translate to readable
31# strings.
32#
33
34if [ $# -ne 1 ]; then
35	echo >&2 "USAGE: $0 <path to libimpi.h>"
36	exit 1
37fi
38
39if [ -r $1 ]; then
40	libipmi_h=$1
41else
42	echo >&2 "USAGE: $0 <path to libimpi.h>"
43	echo >&2 "Make sure libipmi.h exists and is readable"
44	exit 1
45fi
46
47echo "\
48/*
49 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
50 * Use is subject to license terms.
51 */
52
53#pragma ident	\"%Z%%M%	%I%	%E% SMI\"
54
55#include <libipmi.h>
56#include <ipmi_impl.h>"
57
58#
59# Error table.
60#
61echo "
62ipmi_name_trans_t ipmi_errno_table[] = {"
63
64pattern="	\(EIPMI_[0-9A-Z_]*\)[^ \/]*\/\* \(.*\) \*\/$"
65replace="	{ \1, \"\2\" },"
66
67cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
68
69echo "\t{ 0, NULL }
70};"
71
72#
73# Entity table.
74#
75echo "\nipmi_name_trans_t ipmi_entity_table[] = {"
76
77pattern="#define	IPMI_ET_\([A-Z0-9_]*\).*\$"
78replace="	{ IPMI_ET_\1, \"\1\" },"
79
80cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
81
82echo "\t{ 0, NULL }
83};"
84
85#
86# Sensor types.
87#
88echo "\nipmi_name_trans_t ipmi_sensor_type_table[] = {"
89
90pattern="#define	IPMI_ST_\([A-Z0-9_]*\).*\$"
91replace="	{ IPMI_ST_\1, \"\1\" },"
92
93cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
94
95echo "\t{ 0, NULL }
96};"
97
98#
99# Reading types.
100#
101echo "\nipmi_name_trans_t ipmi_reading_type_table[] = {"
102
103pattern="#define	IPMI_RT_\([A-Z0-9_]*\).*\$"
104replace="	{ IPMI_RT_\1, \"\1\" },"
105
106cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
107
108echo "\t{ 0, NULL }
109};"
110
111#
112# Units
113#
114echo "\nipmi_name_trans_t ipmi_units_type_table[] = {"
115
116pattern="#define	IPMI_UNITS_\([A-Z0-9_]*\).*\$"
117replace="	{ IPMI_UNITS_\1, \"\1\" },"
118
119cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
120
121echo "\t{ 0, NULL }
122};"
123
124