mkerrno.sh revision 275c9da86e89f8abf71135cf63d9fc23671b2e60
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# CDDL HEADER START
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# The contents of this file are subject to the terms of the
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# Common Development and Distribution License (the "License").
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# You may not use this file except in compliance with the License.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# See the License for the specific language governing permissions
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# and limitations under the License.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# When distributing Covered Code, include this CDDL HEADER in each
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# If applicable, add the following below this CDDL HEADER, with the
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# fields enclosed by brackets "[]" replaced with your own identifying
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# information: Portions Copyright [yyyy] [name of copyright owner]
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# CDDL HEADER END
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock# Use is subject to license terms.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock#ident "%Z%%M% %I% %E% SMI"
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * Use is subject to license terms.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock#pragma ident\t\"%Z%%M%\t%I%\t%E%\tSMI\"
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic const struct {
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock\tchar *name;\t\t/* error name */
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock\tchar *msg;\t\t/* error message */
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock} _libscsi_errstr[] = {"
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock( sed -n "s/$pattern/$replace/p" | sed -n "s/$open/$openrepl/p" |
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic int _libscsi_nerrno = sizeof (_libscsi_errstr) /\n\
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock sizeof (_libscsi_errstr[0]);\n\
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockconst char *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrocklibscsi_strerror(libscsi_errno_t err)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (err < 0 || err >= _libscsi_nerrno ? \"unknown error\" :
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock _libscsi_errstr[err].msg);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockconst char *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrocklibscsi_errname(libscsi_errno_t err)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (err < 0 || err >= _libscsi_nerrno ? NULL :
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock _libscsi_errstr[err].name);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrocklibscsi_errno_t
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrocklibscsi_errcode(const char *name)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock libscsi_errno_t err;
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock for (err = 0; err < _libscsi_nerrno; err++) {
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock if (strcmp(name, _libscsi_errstr[err].name) == 0)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (err);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (ESCSI_UNKNOWN);