1 /* $NetBSD: eltsub.c,v 1.2 2000/02/22 06:06:07 mjacob Exp $ */
5 * Copyright (c) 2000 by Matthew Jacob
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions, and the following disclaimer,
13 * without modification, immediately at the beginning of the file.
14 * 2. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * Alternatively, this software may be distributed under the terms of the
18 * the GNU Public License ("GPL").
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 #include <sys/ioctl.h>
43 char *geteltnm
__P((int));
44 static char *scode2ascii
__P((u_char
));
45 char *stat2ascii
__P((int, u_char
*));
51 static char rbuf
[132];
54 case SESTYP_UNSPECIFIED
:
55 sprintf(rbuf
, "Unspecified");
58 sprintf(rbuf
, "Device");
61 sprintf(rbuf
, "Power supply");
64 sprintf(rbuf
, "Cooling element");
67 sprintf(rbuf
, "Temperature sensors");
70 sprintf(rbuf
, "Door Lock");
73 sprintf(rbuf
, "Audible alarm");
76 sprintf(rbuf
, "Enclosure services controller electronics");
79 sprintf(rbuf
, "SCC controller electronics");
82 sprintf(rbuf
, "Nonvolatile cache");
85 sprintf(rbuf
, "Uninterruptible power supply");
88 sprintf(rbuf
, "Display");
91 sprintf(rbuf
, "Key pad entry device");
94 sprintf(rbuf
, "SCSI port/transceiver");
97 sprintf(rbuf
, "Language");
100 sprintf(rbuf
, "Communication Port");
103 sprintf(rbuf
, "Voltage Sensor");
106 sprintf(rbuf
, "Current Sensor");
108 case SESTYP_SCSI_TGT
:
109 sprintf(rbuf
, "SCSI target port");
111 case SESTYP_SCSI_INI
:
112 sprintf(rbuf
, "SCSI initiator port");
115 sprintf(rbuf
, "Simple sub-enclosure");
118 (void) sprintf(rbuf
, "<Type 0x%x>", type
);
125 scode2ascii(u_char code
)
127 static char rbuf
[32];
128 switch (code
& 0xf) {
129 case SES_OBJSTAT_UNSUPPORTED
:
130 sprintf(rbuf
, "status not supported");
135 case SES_OBJSTAT_CRIT
:
136 sprintf(rbuf
, "critical");
138 case SES_OBJSTAT_NONCRIT
:
139 sprintf(rbuf
, "non-critical");
141 case SES_OBJSTAT_UNRECOV
:
142 sprintf(rbuf
, "unrecoverable");
144 case SES_OBJSTAT_NOTINSTALLED
:
145 sprintf(rbuf
, "not installed");
147 case SES_OBJSTAT_UNKNOWN
:
148 sprintf(rbuf
, "unknown status");
150 case SES_OBJSTAT_NOTAVAIL
:
151 sprintf(rbuf
, "status not available");
154 sprintf(rbuf
, "unknown status code %x", code
& 0xf);
162 stat2ascii(eletype
, cstat
)
166 static char ebuf
[256], *scode
;
168 scode
= scode2ascii(cstat
[0]);
169 sprintf(ebuf
, "Status=%s (bytes=0x%02x 0x%02x 0x%02x 0x%02x)",
170 scode
, cstat
[0], cstat
[1], cstat
[2], cstat
[3]);