1#!/bin/sh 2# 3# CDDL HEADER START 4# 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. 8# 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. 13# 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] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28echo "/* 29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 30 * Use is subject to license terms. 31 */ 32 33#include <strings.h> 34#include <scsi/libses.h> 35 36static const struct { 37\tchar *se_name;\t\t/* error name */ 38\tchar *se_msg;\t\t/* error message */ 39} _ses_errstr[] = {" 40 41pattern='^ \(ESES_[A-Z0-9_]*\),*' 42replace=' { "\1",' 43open=' \/\* ' 44openrepl='"' 45close=' \*\/$' 46closerepl='" },' 47 48( sed -n "s/$pattern/$replace/p" | sed -n "s/$open/$openrepl/p" | 49 sed -n "s/$close/$closerepl/p" ) || exit 1 50 51echo "\ 52};\n\ 53\n\ 54static int _ses_nerrno = sizeof (_ses_errstr) / sizeof (_ses_errstr[0]);\n\ 55\n\ 56const char * 57ses_strerror(ses_errno_t err) 58{ 59 return (err < 0 || err >= _ses_nerrno ? \"unknown error\" : 60 _ses_errstr[err].se_msg); 61} 62 63const char * 64ses_errname(ses_errno_t err) 65{ 66 return (err < 0 || err >= _ses_nerrno ? NULL : 67 _ses_errstr[err].se_name); 68} 69 70ses_errno_t 71ses_errcode(const char *name) 72{ 73 ses_errno_t err; 74 75 for (err = 0; err < _ses_nerrno; err++) { 76 if (strcmp(name, _ses_errstr[err].se_name) == 0) 77 return (err); 78 } 79 80 return (ESES_UNKNOWN); 81}" 82 83exit 0 84