xref: /titanic_51/usr/src/lib/libipmi/common/mktables.sh (revision 81d9f076db88c1f40c85831ce1ebb444a209c5a8)
12eeaed14Srobj#!/bin/sh
22eeaed14Srobj
32eeaed14Srobj#
42eeaed14Srobj# CDDL HEADER START
52eeaed14Srobj#
62eeaed14Srobj# The contents of this file are subject to the terms of the
72eeaed14Srobj# Common Development and Distribution License (the "License").
82eeaed14Srobj# You may not use this file except in compliance with the License.
92eeaed14Srobj#
102eeaed14Srobj# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
112eeaed14Srobj# or http://www.opensolaris.org/os/licensing.
122eeaed14Srobj# See the License for the specific language governing permissions
132eeaed14Srobj# and limitations under the License.
142eeaed14Srobj#
152eeaed14Srobj# When distributing Covered Code, include this CDDL HEADER in each
162eeaed14Srobj# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
172eeaed14Srobj# If applicable, add the following below this CDDL HEADER, with the
182eeaed14Srobj# fields enclosed by brackets "[]" replaced with your own identifying
192eeaed14Srobj# information: Portions Copyright [yyyy] [name of copyright owner]
202eeaed14Srobj#
212eeaed14Srobj# CDDL HEADER END
222eeaed14Srobj#
232eeaed14Srobj#
24*81d9f076SRobert Johnston# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
252eeaed14Srobj# Use is subject to license terms.
262eeaed14Srobj#
272eeaed14Srobj
282eeaed14Srobj#
292eeaed14Srobj# Construct translation tables for defines in libipmi.h to translate to readable
302eeaed14Srobj# strings.
312eeaed14Srobj#
322eeaed14Srobj
332eeaed14Srobjif [ $# -ne 1 ]; then
342eeaed14Srobj	echo >&2 "USAGE: $0 <path to libimpi.h>"
352eeaed14Srobj	exit 1
362eeaed14Srobjfi
372eeaed14Srobj
382eeaed14Srobjif [ -r $1 ]; then
392eeaed14Srobj	libipmi_h=$1
402eeaed14Srobjelse
412eeaed14Srobj	echo >&2 "USAGE: $0 <path to libimpi.h>"
422eeaed14Srobj	echo >&2 "Make sure libipmi.h exists and is readable"
432eeaed14Srobj	exit 1
442eeaed14Srobjfi
452eeaed14Srobj
462eeaed14Srobjecho "\
472eeaed14Srobj/*
48*81d9f076SRobert Johnston * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
492eeaed14Srobj * Use is subject to license terms.
502eeaed14Srobj */
512eeaed14Srobj
522eeaed14Srobj#include <libipmi.h>
532eeaed14Srobj#include <ipmi_impl.h>"
542eeaed14Srobj
552eeaed14Srobj#
562eeaed14Srobj# Error table.
572eeaed14Srobj#
582eeaed14Srobjecho "
592eeaed14Srobjipmi_name_trans_t ipmi_errno_table[] = {"
602eeaed14Srobj
612eeaed14Srobjpattern="	\(EIPMI_[0-9A-Z_]*\)[^ \/]*\/\* \(.*\) \*\/$"
622eeaed14Srobjreplace="	{ \1, \"\2\" },"
632eeaed14Srobj
642eeaed14Srobjcat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
652eeaed14Srobj
662eeaed14Srobjecho "\t{ 0, NULL }
672eeaed14Srobj};"
682eeaed14Srobj
692eeaed14Srobj#
702eeaed14Srobj# Entity table.
712eeaed14Srobj#
722eeaed14Srobjecho "\nipmi_name_trans_t ipmi_entity_table[] = {"
732eeaed14Srobj
742eeaed14Srobjpattern="#define	IPMI_ET_\([A-Z0-9_]*\).*\$"
752eeaed14Srobjreplace="	{ IPMI_ET_\1, \"\1\" },"
762eeaed14Srobj
772eeaed14Srobjcat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
782eeaed14Srobj
792eeaed14Srobjecho "\t{ 0, NULL }
802eeaed14Srobj};"
812eeaed14Srobj
822eeaed14Srobj#
832eeaed14Srobj# Sensor types.
842eeaed14Srobj#
852eeaed14Srobjecho "\nipmi_name_trans_t ipmi_sensor_type_table[] = {"
862eeaed14Srobj
872eeaed14Srobjpattern="#define	IPMI_ST_\([A-Z0-9_]*\).*\$"
882eeaed14Srobjreplace="	{ IPMI_ST_\1, \"\1\" },"
892eeaed14Srobj
902eeaed14Srobjcat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
912eeaed14Srobj
922eeaed14Srobjecho "\t{ 0, NULL }
932eeaed14Srobj};"
942eeaed14Srobj
952eeaed14Srobj#
962eeaed14Srobj# Reading types.
972eeaed14Srobj#
982eeaed14Srobjecho "\nipmi_name_trans_t ipmi_reading_type_table[] = {"
992eeaed14Srobj
1002eeaed14Srobjpattern="#define	IPMI_RT_\([A-Z0-9_]*\).*\$"
1012eeaed14Srobjreplace="	{ IPMI_RT_\1, \"\1\" },"
1022eeaed14Srobj
1032eeaed14Srobjcat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
1042eeaed14Srobj
1052eeaed14Srobjecho "\t{ 0, NULL }
1062eeaed14Srobj};"
107825ba0f2Srobj
108825ba0f2Srobj#
109825ba0f2Srobj# Units
110825ba0f2Srobj#
111825ba0f2Srobjecho "\nipmi_name_trans_t ipmi_units_type_table[] = {"
112825ba0f2Srobj
113825ba0f2Srobjpattern="#define	IPMI_UNITS_\([A-Z0-9_]*\).*\$"
114825ba0f2Srobjreplace="	{ IPMI_UNITS_\1, \"\1\" },"
115825ba0f2Srobj
116825ba0f2Srobjcat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
117825ba0f2Srobj
118825ba0f2Srobjecho "\t{ 0, NULL }
119825ba0f2Srobj};"
120825ba0f2Srobj
121