Home | History | Annotate | Download | only in common
      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 
     34 if [ $# -ne 1 ]; then
     35 	echo >&2 "USAGE: $0 <path to libimpi.h>"
     36 	exit 1
     37 fi
     38 
     39 if [ -r $1 ]; then
     40 	libipmi_h=$1
     41 else
     42 	echo >&2 "USAGE: $0 <path to libimpi.h>"
     43 	echo >&2 "Make sure libipmi.h exists and is readable"
     44 	exit 1
     45 fi
     46 
     47 echo "\
     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 #
     61 echo "
     62 ipmi_name_trans_t ipmi_errno_table[] = {"
     63 
     64 pattern="	\(EIPMI_[0-9A-Z_]*\)[^ \/]*\/\* \(.*\) \*\/$"
     65 replace="	{ \1, \"\2\" },"
     66 
     67 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
     68 
     69 echo "\t{ 0, NULL }
     70 };"
     71 
     72 #
     73 # Entity table.
     74 #
     75 echo "\nipmi_name_trans_t ipmi_entity_table[] = {"
     76 
     77 pattern="#define	IPMI_ET_\([A-Z0-9_]*\).*\$"
     78 replace="	{ IPMI_ET_\1, \"\1\" },"
     79 
     80 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
     81 
     82 echo "\t{ 0, NULL }
     83 };"
     84 
     85 #
     86 # Sensor types.
     87 #
     88 echo "\nipmi_name_trans_t ipmi_sensor_type_table[] = {"
     89 
     90 pattern="#define	IPMI_ST_\([A-Z0-9_]*\).*\$"
     91 replace="	{ IPMI_ST_\1, \"\1\" },"
     92 
     93 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
     94 
     95 echo "\t{ 0, NULL }
     96 };"
     97 
     98 #
     99 # Reading types.
    100 #
    101 echo "\nipmi_name_trans_t ipmi_reading_type_table[] = {"
    102 
    103 pattern="#define	IPMI_RT_\([A-Z0-9_]*\).*\$"
    104 replace="	{ IPMI_RT_\1, \"\1\" },"
    105 
    106 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
    107 
    108 echo "\t{ 0, NULL }
    109 };"
    110 
    111 #
    112 # Units
    113 #
    114 echo "\nipmi_name_trans_t ipmi_units_type_table[] = {"
    115 
    116 pattern="#define	IPMI_UNITS_\([A-Z0-9_]*\).*\$"
    117 replace="	{ IPMI_UNITS_\1, \"\1\" },"
    118 
    119 cat $libipmi_h | sed -n "s/$pattern/$replace/p" || exit 1
    120 
    121 echo "\t{ 0, NULL }
    122 };"
    123 
    124