7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#!/bin/sh
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# CDDL HEADER START
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# The contents of this file are subject to the terms of the
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi# Common Development and Distribution License (the "License").
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi# You may not use this file except in compliance with the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# or http://www.opensolaris.org/os/licensing.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# and limitations under the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# When distributing Covered Code, include this CDDL HEADER in each
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# If applicable, add the following below this CDDL HEADER, with the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# fields enclosed by brackets "[]" replaced with your own identifying
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# information: Portions Copyright [yyyy] [name of copyright owner]
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# CDDL HEADER END
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#
dd566498928f08e7c9a79797a40db893c6a4b9fbvn# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# Use is subject to license terms.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#ident "@(#)mkerror.sh 1.1 06/02/11 SMI"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#pragma ident "%Z%%M% %I% %E% SMI"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiinput="`cat`"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi[ -z "$input" ] && exit 1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiif [ $1 = "liberrors" ] ; then
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiecho "\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved.\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#pragma ident\t\"@(#)mkerror.sh\t1.2\t05/06/08 SMI\"\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <strings.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <topo_error.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <topo_mod.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic const char *const _topo_errstrs[] = {"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindipattern='^[ ]*ETOPO_[A-Z0-9_]*.*\* \(.*\) \*.*'
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindireplace=' "\1",'
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiecho "\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi};\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic const int _topo_nerrstrs =\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi sizeof (_topo_errstrs) / sizeof (_topo_errstrs[0]);\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiint
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_hdl_errno(topo_hdl_t *thp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (thp->th_errno);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiint
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_hdl_seterrno(topo_hdl_t *thp, int err)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi thp->th_errno = err;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (-1);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiconst char *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_hdl_errmsg(topo_hdl_t *thp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (topo_strerror(thp->th_errno));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindielif [ $1 = "properrors" ] ; then
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiecho "\
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi\n\
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic const char *const _topo_properrstrs[] = {"
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindipattern='^[ ]*ETOPO_PROP_[A-Z0-9_]*.*\* \(.*\) \*.*'
0eb822a1c0c2bea495647510b75f77f0e57633ebcindireplace=' "\1",'
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiecho "\
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi};\n\
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi\n\
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic const int _topo_nproperrstrs =\n\
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi sizeof (_topo_properrstrs) / sizeof (_topo_properrstrs[0]);"
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
dd566498928f08e7c9a79797a40db893c6a4b9fbvnelif [ $1 = "methoderrors" ] ; then
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvnecho "\
dd566498928f08e7c9a79797a40db893c6a4b9fbvn\n\
dd566498928f08e7c9a79797a40db893c6a4b9fbvnstatic const char *const _topo_methoderrstrs[] = {"
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvnpattern='^[ ]*ETOPO_METHOD_[A-Z0-9_]*.*\* \(.*\) \*.*'
dd566498928f08e7c9a79797a40db893c6a4b9fbvnreplace=' "\1",'
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvnecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
dd566498928f08e7c9a79797a40db893c6a4b9fbvn
dd566498928f08e7c9a79797a40db893c6a4b9fbvnecho "\
dd566498928f08e7c9a79797a40db893c6a4b9fbvn};\n\
dd566498928f08e7c9a79797a40db893c6a4b9fbvn\n\
dd566498928f08e7c9a79797a40db893c6a4b9fbvnstatic const int _topo_nmethoderrstrs =\n\
dd566498928f08e7c9a79797a40db893c6a4b9fbvn sizeof (_topo_methoderrstrs) / sizeof (_topo_methoderrstrs[0]);"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindielif [ $1 = "fmrierrors" ] ; then
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiecho "\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindistatic const char *const _topo_fmrierrstrs[] = {"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindipattern='^[ ]*ETOPO_FMRI_[A-Z0-9_]*.*\* \(.*\) \*.*'
c40d7343efa60b18ad1ceb316eb337caeea79046cindireplace=' "\1",'
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiecho "\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi};\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindistatic const int _topo_nfmrierrstrs =\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi sizeof (_topo_fmrierrstrs) / sizeof (_topo_fmrierrstrs[0]);"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindielif [ $1 = "hdlerrors" ] ; then
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiecho "\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindistatic const char *const _topo_hdlerrstrs[] = {"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindipattern='^[ ]*ETOPO_HDL_[A-Z0-9_]*.*\* \(.*\) \*.*'
c40d7343efa60b18ad1ceb316eb337caeea79046cindireplace=' "\1",'
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
c40d7343efa60b18ad1ceb316eb337caeea79046cindiecho "\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi};\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindistatic const int _topo_nhdlerrstrs =\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi sizeof (_topo_hdlerrstrs) / sizeof (_topo_hdlerrstrs[0]);"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindielse
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiecho "\
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic const char *const _topo_moderrstrs[] = {"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindipattern='^[ ]*EMOD_[A-Z0-9_]*.*\* \(.*\) \*.*'
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindireplace=' "\1",'
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiecho "\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi};\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic const int _topo_nmoderrstrs =\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi sizeof (_topo_moderrstrs) / sizeof (_topo_moderrstrs[0]);\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiint
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_mod_errno(topo_mod_t *mp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (mp->tm_errno);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiint
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_mod_seterrno(topo_mod_t *mp, int err)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi mp->tm_errno = err;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (-1);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiconst char *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_mod_errmsg(topo_mod_t *mp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (topo_strerror(mp->tm_errno));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiconst char *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_strerror(int err)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi const char *s;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (err >= ETOPO_UNKNOWN && (err - ETOPO_UNKNOWN) < _topo_nerrstrs)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi s = _topo_errstrs[err - ETOPO_UNKNOWN];
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi else if (err >= EMOD_UNKNOWN && (err - EMOD_UNKNOWN) <
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi _topo_nmoderrstrs)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi s = _topo_moderrstrs[err - EMOD_UNKNOWN];
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi else if (err >= ETOPO_PROP_UNKNOWN && (err - ETOPO_PROP_UNKNOWN) <
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi _topo_nproperrstrs)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi s = _topo_properrstrs[err - ETOPO_PROP_UNKNOWN];
dd566498928f08e7c9a79797a40db893c6a4b9fbvn else if (err >= ETOPO_METHOD_UNKNOWN && (err - ETOPO_METHOD_UNKNOWN) <
dd566498928f08e7c9a79797a40db893c6a4b9fbvn _topo_nmethoderrstrs)
15fa52896e9787fce4a833ef05eea383ab22181acindi s = _topo_methoderrstrs[err - ETOPO_METHOD_UNKNOWN];
c40d7343efa60b18ad1ceb316eb337caeea79046cindi else if (err >= ETOPO_HDL_UNKNOWN && (err - ETOPO_HDL_UNKNOWN) <
c40d7343efa60b18ad1ceb316eb337caeea79046cindi _topo_nhdlerrstrs)
15fa52896e9787fce4a833ef05eea383ab22181acindi s = _topo_hdlerrstrs[err - ETOPO_HDL_UNKNOWN];
c40d7343efa60b18ad1ceb316eb337caeea79046cindi else if (err >= ETOPO_FMRI_UNKNOWN && (err - ETOPO_FMRI_UNKNOWN) <
c40d7343efa60b18ad1ceb316eb337caeea79046cindi _topo_nfmrierrstrs)
15fa52896e9787fce4a833ef05eea383ab22181acindi s = _topo_fmrierrstrs[err - ETOPO_FMRI_UNKNOWN];
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi else
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi s = _topo_errstrs[0];
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (s);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindifi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiexit 0