xref: /illumos-gate/usr/src/lib/scsi/plugins/ses/libses/common/mkelemtype.sh (revision d583b39bfb4e2571d3e41097c5c357ffe353ad45)
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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
25#
26
27echo "/*
28 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
29 */
30
31#include <sys/types.h>
32#include <string.h>
33#include <scsi/libses.h>
34#include <scsi/plugins/ses/vendor/sun.h>
35
36static const struct {
37\tint se_type;\t/* element type */
38\tconst char *se_name;\t\t/* element type name */
39} _ses_elemtypestr[] = {"
40
41pattern='^	\(SES_ET_\([A-Z0-9_]*\)\).*'
42replace='	{ \1, "\2" },'
43pattern2=', "SUNW_'
44replace2=', "'
45
46( for file in $*
47  do
48    cat $file | sed -n "s/$pattern/$replace/p" | sed "s/$pattern2/$replace2/"
49  done ) || exit 1
50
51echo "\
52};\n\
53\n\
54static uint_t _ses_nelemtypes =\n\
55    sizeof (_ses_elemtypestr) / sizeof (_ses_elemtypestr[0]);\n\
56\n\
57const char *
58ses_element_type_name(uint64_t type)
59{
60	uint_t t;
61
62	for (t = 0; t < _ses_nelemtypes; t++) {
63		if (_ses_elemtypestr[t].se_type == type)
64			return (_ses_elemtypestr[t].se_name);
65	}
66
67	return (NULL);
68}"
69
70exit 0
71