2 * Copyright (c) 1998,1999,2000
3 * Traakan, Inc., Los Altos, CA
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice unmodified, this list of conditions, and the following
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 static char *strend(char *s);
45 smc_elem_type_code_to_str(int code)
48 case SMC_ELEM_TYPE_ALL: return "ALL";
49 case SMC_ELEM_TYPE_MTE: return "ARM";
50 case SMC_ELEM_TYPE_SE: return "SLOT";
51 case SMC_ELEM_TYPE_IEE: return "IEE";
52 case SMC_ELEM_TYPE_DTE: return "TAPE";
53 default: return "???";
58 smc_pp_element_address_assignments (struct smc_element_address_assignment *eaa,
59 int lineno, char *buf)
61 sprintf (buf, "slots %d@%d drive %d@%d arm %d@%d i/e %d@%d",
62 eaa->se_count, eaa->se_addr,
63 eaa->dte_count, eaa->dte_addr,
64 eaa->mte_count, eaa->mte_addr,
65 eaa->iee_count, eaa->iee_addr);
71 smc_pp_element_descriptor (struct smc_element_descriptor *edp,
72 int lineno, char *ret_buf)
80 sprintf (buf, "@%-3d %-4s",
82 smc_elem_type_code_to_str(edp->element_type_code));
85 strcat (buf, " Full ");
87 strcat (buf, " Empty");
89 if (edp->element_type_code == SMC_ELEM_TYPE_MTE) {
92 /* actually not defined */
93 strcat (buf, " ?access=granted?");
97 /* unusual for all non-MTE elements */
98 strcat (buf, " ?access=denied?");
102 if (edp->PVolTag && edp->Full) {
103 sprintf (strend(buf), " PVolTag(%s,#%d)",
104 edp->primary_vol_tag.volume_id,
105 edp->primary_vol_tag.volume_seq);
109 sprintf (strend(buf), " Except(asc=%02x,ascq=%02x)",
110 edp->asc, edp->ascq);
113 if (*buf && nline++ == lineno) strcpy (ret_buf, buf);
116 #define INDENT_SPACES " " /* 10 spaces */
119 sprintf (buf, INDENT_SPACES "AVolTag(%s,#%d)",
120 edp->alternate_vol_tag.volume_id,
121 edp->alternate_vol_tag.volume_seq);
124 if (*buf && nline++ == lineno) strcpy (ret_buf, buf);
128 sprintf (buf, INDENT_SPACES "SValid(src=%d,%sinvert)",
130 edp->Invert ? "" : "!");
133 if (*buf && nline++ == lineno) strcpy (ret_buf, buf);
136 if (edp->element_type_code == SMC_ELEM_TYPE_DTE) {
137 strcpy (buf, INDENT_SPACES);
139 sprintf (strend(buf), "ID sid=%d", edp->scsi_sid);
141 strcat (buf, "no-sid-data");
144 sprintf (strend(buf), " lun=%d", edp->scsi_lun);
146 strcat (buf, " no-lun-data");
149 if (edp->ID_valid && edp->Not_bus) {
150 strcat (buf, " not-same-bus");
154 if (*buf && nline++ == lineno) strcpy (ret_buf, buf);
157 if (edp->element_type_code == SMC_ELEM_TYPE_IEE) {
158 strcpy (buf, INDENT_SPACES);
161 strcat (buf, " can-import");
163 strcat (buf, " can-not-import");
166 strcat (buf, " can-export");
168 strcat (buf, " can-not-export");
171 strcat (buf, " by-oper");
173 strcat (buf, " by-mte");
176 if (*buf && nline++ == lineno) strcpy (ret_buf, buf);