7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# CDDL HEADER START
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# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# and limitations under the License.
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# CDDL HEADER END
dd566498928f08e7c9a79797a40db893c6a4b9fbvn# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi# Use is subject to license terms.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#ident "@(#)mkerror.sh 1.1 06/02/11 SMI"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#pragma ident "%Z%%M% %I% %E% SMI"
c40d7343efa60b18ad1ceb316eb337caeea79046cindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved.\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#pragma ident\t\"@(#)mkerror.sh\t1.2\t05/06/08 SMI\"\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic const char *const _topo_errstrs[] = {"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic const int _topo_nerrstrs =\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi sizeof (_topo_errstrs) / sizeof (_topo_errstrs[0]);\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_hdl_errno(topo_hdl_t *thp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (thp->th_errno);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_hdl_seterrno(topo_hdl_t *thp, int err)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi thp->th_errno = err;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (-1);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiconst char *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_hdl_errmsg(topo_hdl_t *thp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (topo_strerror(thp->th_errno));
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic const char *const _topo_properrstrs[] = {"
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic const int _topo_nproperrstrs =\n\
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi sizeof (_topo_properrstrs) / sizeof (_topo_properrstrs[0]);"
dd566498928f08e7c9a79797a40db893c6a4b9fbvnstatic const char *const _topo_methoderrstrs[] = {"
dd566498928f08e7c9a79797a40db893c6a4b9fbvnstatic const int _topo_nmethoderrstrs =\n\
dd566498928f08e7c9a79797a40db893c6a4b9fbvn sizeof (_topo_methoderrstrs) / sizeof (_topo_methoderrstrs[0]);"
c40d7343efa60b18ad1ceb316eb337caeea79046cindistatic const char *const _topo_fmrierrstrs[] = {"
c40d7343efa60b18ad1ceb316eb337caeea79046cindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
c40d7343efa60b18ad1ceb316eb337caeea79046cindistatic const int _topo_nfmrierrstrs =\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi sizeof (_topo_fmrierrstrs) / sizeof (_topo_fmrierrstrs[0]);"
c40d7343efa60b18ad1ceb316eb337caeea79046cindistatic const char *const _topo_hdlerrstrs[] = {"
c40d7343efa60b18ad1ceb316eb337caeea79046cindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
c40d7343efa60b18ad1ceb316eb337caeea79046cindistatic const int _topo_nhdlerrstrs =\n\
c40d7343efa60b18ad1ceb316eb337caeea79046cindi sizeof (_topo_hdlerrstrs) / sizeof (_topo_hdlerrstrs[0]);"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic const char *const _topo_moderrstrs[] = {"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic const int _topo_nmoderrstrs =\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi sizeof (_topo_moderrstrs) / sizeof (_topo_moderrstrs[0]);\n\
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_mod_errno(topo_mod_t *mp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (mp->tm_errno);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_mod_seterrno(topo_mod_t *mp, int err)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi mp->tm_errno = err;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (-1);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiconst char *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_mod_errmsg(topo_mod_t *mp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (topo_strerror(mp->tm_errno));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiconst char *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_strerror(int err)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi const char *s;
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 s = _topo_errstrs[0];
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (s);