11414Scindi#!/bin/sh 21414Scindi# 31414Scindi# CDDL HEADER START 41414Scindi# 51414Scindi# The contents of this file are subject to the terms of the 63062Scindi# Common Development and Distribution License (the "License"). 73062Scindi# You may not use this file except in compliance with the License. 81414Scindi# 91414Scindi# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 101414Scindi# or http://www.opensolaris.org/os/licensing. 111414Scindi# See the License for the specific language governing permissions 121414Scindi# and limitations under the License. 131414Scindi# 141414Scindi# When distributing Covered Code, include this CDDL HEADER in each 151414Scindi# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 161414Scindi# If applicable, add the following below this CDDL HEADER, with the 171414Scindi# fields enclosed by brackets "[]" replaced with your own identifying 181414Scindi# information: Portions Copyright [yyyy] [name of copyright owner] 191414Scindi# 201414Scindi# CDDL HEADER END 211414Scindi# 221414Scindi# 233681Svn83148# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 241414Scindi# Use is subject to license terms. 251414Scindi# 263062Scindi#ident "@(#)mkerror.sh 1.1 06/02/11 SMI" 271414Scindi 281414Scindi#pragma ident "%Z%%M% %I% %E% SMI" 291414Scindi 301414Scindi 311414Scindiinput="`cat`" 321414Scindi[ -z "$input" ] && exit 1 331414Scindi 343062Scindiif [ $1 = "liberrors" ] ; then 351414Scindiecho "\ 361414Scindi/*\n\ 374087Scindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved.\n\ 381414Scindi * Use is subject to license terms.\n\ 391414Scindi */\n\ 401414Scindi\n\ 411414Scindi#pragma ident\t\"@(#)mkerror.sh\t1.2\t05/06/08 SMI\"\n\ 421414Scindi\n\ 431414Scindi#include <strings.h> 441414Scindi#include <topo_error.h> 451414Scindi#include <topo_mod.h> 461414Scindi 471414Scindi\n\ 481414Scindistatic const char *const _topo_errstrs[] = {" 491414Scindi 501414Scindipattern='^[ ]*ETOPO_[A-Z0-9_]*.*\* \(.*\) \*.*' 511414Scindireplace=' "\1",' 521414Scindi 531414Scindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1 541414Scindi 551414Scindiecho "\ 561414Scindi};\n\ 571414Scindi\n\ 581414Scindistatic const int _topo_nerrstrs =\n\ 591414Scindi sizeof (_topo_errstrs) / sizeof (_topo_errstrs[0]);\n\ 601414Scindi\n\ 611414Scindi 621414Scindiint 631414Scinditopo_hdl_errno(topo_hdl_t *thp) 641414Scindi{ 651414Scindi return (thp->th_errno); 661414Scindi} 671414Scindi 681414Scindiint 691414Scinditopo_hdl_seterrno(topo_hdl_t *thp, int err) 701414Scindi{ 711414Scindi thp->th_errno = err; 721414Scindi return (-1); 731414Scindi} 741414Scindi 751414Scindiconst char * 761414Scinditopo_hdl_errmsg(topo_hdl_t *thp) 771414Scindi{ 781414Scindi return (topo_strerror(thp->th_errno)); 791414Scindi}" 801414Scindi 813062Scindielif [ $1 = "properrors" ] ; then 823062Scindi 833062Scindiecho "\ 843062Scindi\n\ 853062Scindistatic const char *const _topo_properrstrs[] = {" 863062Scindi 873062Scindipattern='^[ ]*ETOPO_PROP_[A-Z0-9_]*.*\* \(.*\) \*.*' 883062Scindireplace=' "\1",' 893062Scindi 903062Scindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1 913062Scindi 923062Scindiecho "\ 933062Scindi};\n\ 943062Scindi\n\ 953062Scindistatic const int _topo_nproperrstrs =\n\ 963062Scindi sizeof (_topo_properrstrs) / sizeof (_topo_properrstrs[0]);" 973062Scindi 983681Svn83148elif [ $1 = "methoderrors" ] ; then 993681Svn83148 1003681Svn83148echo "\ 1013681Svn83148\n\ 1023681Svn83148static const char *const _topo_methoderrstrs[] = {" 1033681Svn83148 1043681Svn83148pattern='^[ ]*ETOPO_METHOD_[A-Z0-9_]*.*\* \(.*\) \*.*' 1053681Svn83148replace=' "\1",' 1063681Svn83148 1073681Svn83148echo "$input" | sed -n "s/$pattern/$replace/p" || exit 1 1083681Svn83148 1093681Svn83148echo "\ 1103681Svn83148};\n\ 1113681Svn83148\n\ 1123681Svn83148static const int _topo_nmethoderrstrs =\n\ 1133681Svn83148 sizeof (_topo_methoderrstrs) / sizeof (_topo_methoderrstrs[0]);" 1144087Scindi 1154087Scindielif [ $1 = "fmrierrors" ] ; then 1164087Scindi 1174087Scindiecho "\ 1184087Scindi\n\ 1194087Scindistatic const char *const _topo_fmrierrstrs[] = {" 1204087Scindi 1214087Scindipattern='^[ ]*ETOPO_FMRI_[A-Z0-9_]*.*\* \(.*\) \*.*' 1224087Scindireplace=' "\1",' 1234087Scindi 1244087Scindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1 1254087Scindi 1264087Scindiecho "\ 1274087Scindi};\n\ 1284087Scindi\n\ 1294087Scindistatic const int _topo_nfmrierrstrs =\n\ 1304087Scindi sizeof (_topo_fmrierrstrs) / sizeof (_topo_fmrierrstrs[0]);" 1314087Scindi 1324087Scindielif [ $1 = "hdlerrors" ] ; then 1334087Scindi 1344087Scindiecho "\ 1354087Scindi\n\ 1364087Scindistatic const char *const _topo_hdlerrstrs[] = {" 1374087Scindi 1384087Scindipattern='^[ ]*ETOPO_HDL_[A-Z0-9_]*.*\* \(.*\) \*.*' 1394087Scindireplace=' "\1",' 1404087Scindi 1414087Scindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1 1424087Scindi 1434087Scindiecho "\ 1444087Scindi};\n\ 1454087Scindi\n\ 1464087Scindistatic const int _topo_nhdlerrstrs =\n\ 1474087Scindi sizeof (_topo_hdlerrstrs) / sizeof (_topo_hdlerrstrs[0]);" 1484087Scindi 1491414Scindielse 1501414Scindi 1511414Scindiecho "\ 1523062Scindi\n\ 1531414Scindistatic const char *const _topo_moderrstrs[] = {" 1541414Scindi 1551414Scindipattern='^[ ]*EMOD_[A-Z0-9_]*.*\* \(.*\) \*.*' 1561414Scindireplace=' "\1",' 1571414Scindi 1581414Scindiecho "$input" | sed -n "s/$pattern/$replace/p" || exit 1 1591414Scindi 1601414Scindiecho "\ 1611414Scindi};\n\ 1621414Scindistatic const int _topo_nmoderrstrs =\n\ 1631414Scindi sizeof (_topo_moderrstrs) / sizeof (_topo_moderrstrs[0]);\n\ 1641414Scindi\n\ 1651414Scindi 1661414Scindiint 1671414Scinditopo_mod_errno(topo_mod_t *mp) 1681414Scindi{ 1691414Scindi return (mp->tm_errno); 1701414Scindi} 1711414Scindi 1721414Scindiint 1731414Scinditopo_mod_seterrno(topo_mod_t *mp, int err) 1741414Scindi{ 1751414Scindi mp->tm_errno = err; 1761414Scindi return (-1); 1771414Scindi} 1781414Scindi 1791414Scindiconst char * 1801414Scinditopo_mod_errmsg(topo_mod_t *mp) 1811414Scindi{ 1821414Scindi return (topo_strerror(mp->tm_errno)); 1831414Scindi} 1841414Scindi 1851414Scindiconst char * 1861414Scinditopo_strerror(int err) 1871414Scindi{ 1881414Scindi const char *s; 1891414Scindi 1901414Scindi if (err >= ETOPO_UNKNOWN && (err - ETOPO_UNKNOWN) < _topo_nerrstrs) 1911414Scindi s = _topo_errstrs[err - ETOPO_UNKNOWN]; 1923062Scindi else if (err >= EMOD_UNKNOWN && (err - EMOD_UNKNOWN) < 1933062Scindi _topo_nmoderrstrs) 1941414Scindi s = _topo_moderrstrs[err - EMOD_UNKNOWN]; 1953062Scindi else if (err >= ETOPO_PROP_UNKNOWN && (err - ETOPO_PROP_UNKNOWN) < 1963062Scindi _topo_nproperrstrs) 1973062Scindi s = _topo_properrstrs[err - ETOPO_PROP_UNKNOWN]; 1983681Svn83148 else if (err >= ETOPO_METHOD_UNKNOWN && (err - ETOPO_METHOD_UNKNOWN) < 1993681Svn83148 _topo_nmethoderrstrs) 200*4117Scindi s = _topo_methoderrstrs[err - ETOPO_METHOD_UNKNOWN]; 2014087Scindi else if (err >= ETOPO_HDL_UNKNOWN && (err - ETOPO_HDL_UNKNOWN) < 2024087Scindi _topo_nhdlerrstrs) 203*4117Scindi s = _topo_hdlerrstrs[err - ETOPO_HDL_UNKNOWN]; 2044087Scindi else if (err >= ETOPO_FMRI_UNKNOWN && (err - ETOPO_FMRI_UNKNOWN) < 2054087Scindi _topo_nfmrierrstrs) 206*4117Scindi s = _topo_fmrierrstrs[err - ETOPO_FMRI_UNKNOWN]; 2071414Scindi else 2081414Scindi s = _topo_errstrs[0]; 2091414Scindi 2101414Scindi return (s); 2111414Scindi}" 2121414Scindi 2131414Scindifi 2141414Scindi 2151414Scindiexit 0 216