8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / scsi / libses / common / mkerrno.sh
bloba796ddee67b6ce19e382395af3e2fab2aaf820a7
1 #!/bin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 echo "/*
30 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
31 * Use is subject to license terms.
34 #pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"
36 #include <strings.h>
37 #include <scsi/libses.h>
39 static const struct {
40 \tchar *se_name;\t\t/* error name */
41 \tchar *se_msg;\t\t/* error message */
42 } _ses_errstr[] = {"
44 pattern='^ \(ESES_[A-Z0-9_]*\),*'
45 replace=' { "\1",'
46 open=' \/\* '
47 openrepl='"'
48 close=' \*\/$'
49 closerepl='" },'
51 ( sed -n "s/$pattern/$replace/p" | sed -n "s/$open/$openrepl/p" |
52 sed -n "s/$close/$closerepl/p" ) || exit 1
54 echo "\
55 };\n\
56 \n\
57 static int _ses_nerrno = sizeof (_ses_errstr) / sizeof (_ses_errstr[0]);\n\
58 \n\
59 const char *
60 ses_strerror(ses_errno_t err)
62 return (err < 0 || err >= _ses_nerrno ? \"unknown error\" :
63 _ses_errstr[err].se_msg);
66 const char *
67 ses_errname(ses_errno_t err)
69 return (err < 0 || err >= _ses_nerrno ? NULL :
70 _ses_errstr[err].se_name);
73 ses_errno_t
74 ses_errcode(const char *name)
76 ses_errno_t err;
78 for (err = 0; err < _ses_nerrno; err++) {
79 if (strcmp(name, _ses_errstr[err].se_name) == 0)
80 return (err);
83 return (ESES_UNKNOWN);
86 exit 0