2N/A#!/bin/sh
2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
2N/A#
2N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
2N/A# Use is subject to license terms.
2N/A#
2N/A#ident "@(#)mkerror.sh 1.1 06/02/11 SMI"
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A
2N/Ainput="`cat`"
2N/A[ -z "$input" ] && exit 1
2N/A
2N/Aif [ $1 = "liberrors" ] ; then
2N/Aecho "\
2N/A/*\n\
2N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved.\n\
2N/A * Use is subject to license terms.\n\
2N/A */\n\
2N/A\n\
2N/A#pragma ident\t\"@(#)mkerror.sh\t1.2\t05/06/08 SMI\"\n\
2N/A\n\
2N/A#include <strings.h>
2N/A#include <topo_error.h>
2N/A#include <topo_mod.h>
2N/A
2N/A\n\
2N/Astatic const char *const _topo_errstrs[] = {"
2N/A
2N/Apattern='^[ ]*ETOPO_[A-Z0-9_]*.*\* \(.*\) \*.*'
2N/Areplace=' "\1",'
2N/A
2N/Aecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
2N/A
2N/Aecho "\
2N/A};\n\
2N/A\n\
2N/Astatic const int _topo_nerrstrs =\n\
2N/A sizeof (_topo_errstrs) / sizeof (_topo_errstrs[0]);\n\
2N/A\n\
2N/A
2N/Aint
2N/Atopo_hdl_errno(topo_hdl_t *thp)
2N/A{
2N/A return (thp->th_errno);
2N/A}
2N/A
2N/Aint
2N/Atopo_hdl_seterrno(topo_hdl_t *thp, int err)
2N/A{
2N/A thp->th_errno = err;
2N/A return (-1);
2N/A}
2N/A
2N/Aconst char *
2N/Atopo_hdl_errmsg(topo_hdl_t *thp)
2N/A{
2N/A return (topo_strerror(thp->th_errno));
2N/A}"
2N/A
2N/Aelif [ $1 = "properrors" ] ; then
2N/A
2N/Aecho "\
2N/A\n\
2N/Astatic const char *const _topo_properrstrs[] = {"
2N/A
2N/Apattern='^[ ]*ETOPO_PROP_[A-Z0-9_]*.*\* \(.*\) \*.*'
2N/Areplace=' "\1",'
2N/A
2N/Aecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
2N/A
2N/Aecho "\
2N/A};\n\
2N/A\n\
2N/Astatic const int _topo_nproperrstrs =\n\
2N/A sizeof (_topo_properrstrs) / sizeof (_topo_properrstrs[0]);"
2N/A
2N/Aelif [ $1 = "methoderrors" ] ; then
2N/A
2N/Aecho "\
2N/A\n\
2N/Astatic const char *const _topo_methoderrstrs[] = {"
2N/A
2N/Apattern='^[ ]*ETOPO_METHOD_[A-Z0-9_]*.*\* \(.*\) \*.*'
2N/Areplace=' "\1",'
2N/A
2N/Aecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
2N/A
2N/Aecho "\
2N/A};\n\
2N/A\n\
2N/Astatic const int _topo_nmethoderrstrs =\n\
2N/A sizeof (_topo_methoderrstrs) / sizeof (_topo_methoderrstrs[0]);"
2N/A
2N/Aelif [ $1 = "fmrierrors" ] ; then
2N/A
2N/Aecho "\
2N/A\n\
2N/Astatic const char *const _topo_fmrierrstrs[] = {"
2N/A
2N/Apattern='^[ ]*ETOPO_FMRI_[A-Z0-9_]*.*\* \(.*\) \*.*'
2N/Areplace=' "\1",'
2N/A
2N/Aecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
2N/A
2N/Aecho "\
2N/A};\n\
2N/A\n\
2N/Astatic const int _topo_nfmrierrstrs =\n\
2N/A sizeof (_topo_fmrierrstrs) / sizeof (_topo_fmrierrstrs[0]);"
2N/A
2N/Aelif [ $1 = "hdlerrors" ] ; then
2N/A
2N/Aecho "\
2N/A\n\
2N/Astatic const char *const _topo_hdlerrstrs[] = {"
2N/A
2N/Apattern='^[ ]*ETOPO_HDL_[A-Z0-9_]*.*\* \(.*\) \*.*'
2N/Areplace=' "\1",'
2N/A
2N/Aecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
2N/A
2N/Aecho "\
2N/A};\n\
2N/A\n\
2N/Astatic const int _topo_nhdlerrstrs =\n\
2N/A sizeof (_topo_hdlerrstrs) / sizeof (_topo_hdlerrstrs[0]);"
2N/A
2N/Aelse
2N/A
2N/Aecho "\
2N/A\n\
2N/Astatic const char *const _topo_moderrstrs[] = {"
2N/A
2N/Apattern='^[ ]*EMOD_[A-Z0-9_]*.*\* \(.*\) \*.*'
2N/Areplace=' "\1",'
2N/A
2N/Aecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1
2N/A
2N/Aecho "\
2N/A};\n\
2N/Astatic const int _topo_nmoderrstrs =\n\
2N/A sizeof (_topo_moderrstrs) / sizeof (_topo_moderrstrs[0]);\n\
2N/A\n\
2N/A
2N/Aint
2N/Atopo_mod_errno(topo_mod_t *mp)
2N/A{
2N/A return (mp->tm_errno);
2N/A}
2N/A
2N/Aint
2N/Atopo_mod_seterrno(topo_mod_t *mp, int err)
2N/A{
2N/A mp->tm_errno = err;
2N/A return (-1);
2N/A}
2N/A
2N/Aconst char *
2N/Atopo_mod_errmsg(topo_mod_t *mp)
2N/A{
2N/A return (topo_strerror(mp->tm_errno));
2N/A}
2N/A
2N/Aconst char *
2N/Atopo_strerror(int err)
2N/A{
2N/A const char *s;
2N/A
2N/A if (err >= ETOPO_UNKNOWN && (err - ETOPO_UNKNOWN) < _topo_nerrstrs)
2N/A s = _topo_errstrs[err - ETOPO_UNKNOWN];
2N/A else if (err >= EMOD_UNKNOWN && (err - EMOD_UNKNOWN) <
2N/A _topo_nmoderrstrs)
2N/A s = _topo_moderrstrs[err - EMOD_UNKNOWN];
2N/A else if (err >= ETOPO_PROP_UNKNOWN && (err - ETOPO_PROP_UNKNOWN) <
2N/A _topo_nproperrstrs)
2N/A s = _topo_properrstrs[err - ETOPO_PROP_UNKNOWN];
2N/A else if (err >= ETOPO_METHOD_UNKNOWN && (err - ETOPO_METHOD_UNKNOWN) <
2N/A _topo_nmethoderrstrs)
2N/A s = _topo_methoderrstrs[err - ETOPO_METHOD_UNKNOWN];
2N/A else if (err >= ETOPO_HDL_UNKNOWN && (err - ETOPO_HDL_UNKNOWN) <
2N/A _topo_nhdlerrstrs)
2N/A s = _topo_hdlerrstrs[err - ETOPO_HDL_UNKNOWN];
2N/A else if (err >= ETOPO_FMRI_UNKNOWN && (err - ETOPO_FMRI_UNKNOWN) <
2N/A _topo_nfmrierrstrs)
2N/A s = _topo_fmrierrstrs[err - ETOPO_FMRI_UNKNOWN];
2N/A else
2N/A s = _topo_errstrs[0];
2N/A
2N/A return (s);
2N/A}"
2N/A
2N/Afi
2N/A
2N/Aexit 0