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