1*275c9da8Seschrock#!/bin/sh 2*275c9da8Seschrock# 3*275c9da8Seschrock# CDDL HEADER START 4*275c9da8Seschrock# 5*275c9da8Seschrock# The contents of this file are subject to the terms of the 6*275c9da8Seschrock# Common Development and Distribution License (the "License"). 7*275c9da8Seschrock# You may not use this file except in compliance with the License. 8*275c9da8Seschrock# 9*275c9da8Seschrock# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*275c9da8Seschrock# or http://www.opensolaris.org/os/licensing. 11*275c9da8Seschrock# See the License for the specific language governing permissions 12*275c9da8Seschrock# and limitations under the License. 13*275c9da8Seschrock# 14*275c9da8Seschrock# When distributing Covered Code, include this CDDL HEADER in each 15*275c9da8Seschrock# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*275c9da8Seschrock# If applicable, add the following below this CDDL HEADER, with the 17*275c9da8Seschrock# fields enclosed by brackets "[]" replaced with your own identifying 18*275c9da8Seschrock# information: Portions Copyright [yyyy] [name of copyright owner] 19*275c9da8Seschrock# 20*275c9da8Seschrock# CDDL HEADER END 21*275c9da8Seschrock# 22*275c9da8Seschrock 23*275c9da8Seschrock# 24*275c9da8Seschrock# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25*275c9da8Seschrock# Use is subject to license terms. 26*275c9da8Seschrock# 27*275c9da8Seschrock#ident "%Z%%M% %I% %E% SMI" 28*275c9da8Seschrock 29*275c9da8Seschrockecho "\ 30*275c9da8Seschrock/* 31*275c9da8Seschrock * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 32*275c9da8Seschrock * Use is subject to license terms. 33*275c9da8Seschrock */ 34*275c9da8Seschrock 35*275c9da8Seschrock#pragma ident\t\"%Z%%M%\t%I%\t%E%\tSMI\" 36*275c9da8Seschrock 37*275c9da8Seschrock#include <strings.h> 38*275c9da8Seschrock#include <scsi/libscsi.h> 39*275c9da8Seschrock 40*275c9da8Seschrockstatic const struct { 41*275c9da8Seschrock\tchar *name;\t\t/* error name */ 42*275c9da8Seschrock\tchar *msg;\t\t/* error message */ 43*275c9da8Seschrock} _libscsi_errstr[] = {" 44*275c9da8Seschrock 45*275c9da8Seschrockpattern='^ \(ESCSI_[A-Z0-9_]*\),*' 46*275c9da8Seschrockreplace=' { "\1",' 47*275c9da8Seschrockopen=' \/\* ' 48*275c9da8Seschrockopenrepl='"' 49*275c9da8Seschrockclose=' \*\/$' 50*275c9da8Seschrockcloserepl='" },' 51*275c9da8Seschrock 52*275c9da8Seschrock( sed -n "s/$pattern/$replace/p" | sed -n "s/$open/$openrepl/p" | 53*275c9da8Seschrock sed -n "s/$close/$closerepl/p" ) || exit 1 54*275c9da8Seschrock 55*275c9da8Seschrockecho "\ 56*275c9da8Seschrock};\n\ 57*275c9da8Seschrock\n\ 58*275c9da8Seschrockstatic int _libscsi_nerrno = sizeof (_libscsi_errstr) /\n\ 59*275c9da8Seschrock sizeof (_libscsi_errstr[0]);\n\ 60*275c9da8Seschrock\n\ 61*275c9da8Seschrockconst char * 62*275c9da8Seschrocklibscsi_strerror(libscsi_errno_t err) 63*275c9da8Seschrock{ 64*275c9da8Seschrock return (err < 0 || err >= _libscsi_nerrno ? \"unknown error\" : 65*275c9da8Seschrock _libscsi_errstr[err].msg); 66*275c9da8Seschrock} 67*275c9da8Seschrock 68*275c9da8Seschrockconst char * 69*275c9da8Seschrocklibscsi_errname(libscsi_errno_t err) 70*275c9da8Seschrock{ 71*275c9da8Seschrock return (err < 0 || err >= _libscsi_nerrno ? NULL : 72*275c9da8Seschrock _libscsi_errstr[err].name); 73*275c9da8Seschrock} 74*275c9da8Seschrock 75*275c9da8Seschrocklibscsi_errno_t 76*275c9da8Seschrocklibscsi_errcode(const char *name) 77*275c9da8Seschrock{ 78*275c9da8Seschrock libscsi_errno_t err; 79*275c9da8Seschrock 80*275c9da8Seschrock for (err = 0; err < _libscsi_nerrno; err++) { 81*275c9da8Seschrock if (strcmp(name, _libscsi_errstr[err].name) == 0) 82*275c9da8Seschrock return (err); 83*275c9da8Seschrock } 84*275c9da8Seschrock 85*275c9da8Seschrock return (ESCSI_UNKNOWN); 86*275c9da8Seschrock}" 87*275c9da8Seschrock 88*275c9da8Seschrockexit 0 89