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
28*275c9da8Seschrockecho "\
29*275c9da8Seschrock/*
30*275c9da8Seschrock * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
31*275c9da8Seschrock * Use is subject to license terms.
32*275c9da8Seschrock */
33*275c9da8Seschrock
34*275c9da8Seschrock#include <strings.h>
35*275c9da8Seschrock#include <scsi/libscsi.h>
36*275c9da8Seschrock
37*275c9da8Seschrockstatic const struct {
38*275c9da8Seschrock\tchar *name;\t\t/* error name */
39*275c9da8Seschrock\tchar *msg;\t\t/* error message */
40*275c9da8Seschrock} _libscsi_errstr[] = {"
41*275c9da8Seschrock
42*275c9da8Seschrockpattern='^	\(ESCSI_[A-Z0-9_]*\),*'
43*275c9da8Seschrockreplace='	{ "\1",'
44*275c9da8Seschrockopen='	\/\* '
45*275c9da8Seschrockopenrepl='"'
46*275c9da8Seschrockclose=' \*\/$'
47*275c9da8Seschrockcloserepl='" },'
48*275c9da8Seschrock
49*275c9da8Seschrock( sed -n "s/$pattern/$replace/p" | sed -n "s/$open/$openrepl/p" |
50*275c9da8Seschrock    sed -n "s/$close/$closerepl/p" ) || exit 1
51*275c9da8Seschrock
52*275c9da8Seschrockecho "\
53*275c9da8Seschrock};\n\
54*275c9da8Seschrock\n\
55*275c9da8Seschrockstatic int _libscsi_nerrno = sizeof (_libscsi_errstr) /\n\
56*275c9da8Seschrock    sizeof (_libscsi_errstr[0]);\n\
57*275c9da8Seschrock\n\
58*275c9da8Seschrockconst char *
59*275c9da8Seschrocklibscsi_strerror(libscsi_errno_t err)
60*275c9da8Seschrock{
61*275c9da8Seschrock	return (err < 0 || err >= _libscsi_nerrno ? \"unknown error\" :
62*275c9da8Seschrock	     _libscsi_errstr[err].msg);
63*275c9da8Seschrock}
64*275c9da8Seschrock
65*275c9da8Seschrockconst char *
66*275c9da8Seschrocklibscsi_errname(libscsi_errno_t err)
67*275c9da8Seschrock{
68*275c9da8Seschrock	return (err < 0 || err >= _libscsi_nerrno ? NULL :
69*275c9da8Seschrock	     _libscsi_errstr[err].name);
70*275c9da8Seschrock}
71*275c9da8Seschrock
72*275c9da8Seschrocklibscsi_errno_t
73*275c9da8Seschrocklibscsi_errcode(const char *name)
74*275c9da8Seschrock{
75*275c9da8Seschrock	libscsi_errno_t err;
76*275c9da8Seschrock
77*275c9da8Seschrock	for (err = 0; err < _libscsi_nerrno; err++) {
78*275c9da8Seschrock		if (strcmp(name, _libscsi_errstr[err].name) == 0)
79*275c9da8Seschrock			return (err);
80*275c9da8Seschrock	}
81*275c9da8Seschrock
82*275c9da8Seschrock	return (ESCSI_UNKNOWN);
83*275c9da8Seschrock}"
84*275c9da8Seschrock
85*275c9da8Seschrockexit 0
86