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