1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
|
/* -*- linux-c -*-
*
* (C) Copyright IBM Corp. 2004
* (C) Copyright Pigeon Point Systems. 2010
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
* file and program are licensed under a BSD style license. See
* the Copying file included with the OpenHPI distribution for
* full licensing terms.
*
* Author(s):
* Steve Sherman <stevees@us.ibm.com>
* Anton Pak <anton.pak@pigeonpoint.com>
*/
#include <strings.h>
#include <SaHpi.h>
#include <oh_utils.h>
/**
* oh_lookup_xtcahpiledcolor:
* @value: enum value of type XtcaHpiLedColorT.
*
* Converts @value into a string based on @value's HPI enum definition.
*
* Returns:
* string - normal operation.
* NULL - if @value not a valid XtcaHpiLedColorT.
**/
char * oh_lookup_xtcahpiledcolor(XtcaHpiLedColorT value)
{
switch (value) {
case XTCAHPI_LED_COLOR_RESERVED:
return "COLOR_RESERVED";
case XTCAHPI_LED_COLOR_BLUE:
return "COLOR_BLUE";
case XTCAHPI_LED_COLOR_RED:
return "COLOR_RED";
case XTCAHPI_LED_COLOR_GREEN:
return "COLOR_GREEN";
case XTCAHPI_LED_COLOR_AMBER:
return "COLOR_AMBER";
case XTCAHPI_LED_COLOR_ORANGE:
return "COLOR_ORANGE";
case XTCAHPI_LED_COLOR_WHITE:
return "COLOR_WHITE";
case XTCAHPI_LED_COLOR_NO_CHANGE:
return "COLOR_NO_CHANGE";
case XTCAHPI_LED_COLOR_USE_DEFAULT:
return "COLOR_USE_DEFAULT";
default:
return NULL;
}
}
struct oh_xtcahpiledcolor_map xtcahpiledcolor_strings[] = {
{XTCAHPI_LED_COLOR_RESERVED, "COLOR_RESERVED"},
{XTCAHPI_LED_COLOR_BLUE, "COLOR_BLUE"},
{XTCAHPI_LED_COLOR_RED, "COLOR_RED"},
{XTCAHPI_LED_COLOR_GREEN, "COLOR_GREEN"},
{XTCAHPI_LED_COLOR_AMBER, "COLOR_AMBER"},
{XTCAHPI_LED_COLOR_ORANGE, "COLOR_ORANGE"},
{XTCAHPI_LED_COLOR_WHITE, "COLOR_WHITE"},
{XTCAHPI_LED_COLOR_NO_CHANGE, "COLOR_NO_CHANGE"},
{XTCAHPI_LED_COLOR_USE_DEFAULT, "COLOR_USE_DEFAULT"},
};
/**
* oh_encode_xtcahpiledcolor:
* @buffer: Pointer to SaHpiTextBufferT that contains enum's string representation.
* @type: Location (of XtcaHpiLedColorT) to place encoded result.
*
* Converts a @buffer->Data string, generated by oh_lookup_xtcahpiledcolor(), back
* into an XtcaHpiLedColorT type.
*
* Returns:
* XtcaHpiLedColorT value - normal operation.
* SA_ERR_HPI_INVALID_PARAMS - if @buffer or @type is NULL or @buffer->Data empty.
* SA_ERR_HPI_INVALID_DATA - if @buffer->Data is invalid.
**/
SaErrorT oh_encode_xtcahpiledcolor(SaHpiTextBufferT *buffer, XtcaHpiLedColorT *type)
{
int i, found;
if (!buffer || !type || buffer->Data == NULL || buffer->Data[0] == '\0') {
return(SA_ERR_HPI_INVALID_PARAMS);
}
found = 0;
for (i=0; i<OH_MAX_XTCAHPILEDCOLOR; i++) {
if (strcasecmp((char *)buffer->Data, xtcahpiledcolor_strings[i].str) == 0) {
found++;
break;
}
}
if (found) {
*type = xtcahpiledcolor_strings[i].entity_type;
}
else {
return(SA_ERR_HPI_INVALID_DATA);
}
return(SA_OK);
}
/**
* oh_lookup_xtcahpiresourceledmode:
* @value: enum value of type XtcaHpiResourceLedModeT.
*
* Converts @value into a string based on @value's HPI enum definition.
*
* Returns:
* string - normal operation.
* NULL - if @value not a valid XtcaHpiResourceLedModeT.
**/
char * oh_lookup_xtcahpiresourceledmode(XtcaHpiResourceLedModeT value)
{
switch (value) {
case XTCAHPI_LED_AUTO:
return "AUTO";
case XTCAHPI_LED_MANUAL:
return "MANUAL";
case XTCAHPI_LED_LAMP_TEST:
return "LAMP_TEST";
default:
return NULL;
}
}
struct oh_xtcahpiresourceledmode_map xtcahpiresourceledmode_strings[] = {
{XTCAHPI_LED_AUTO, "AUTO"},
{XTCAHPI_LED_MANUAL, "MANUAL"},
{XTCAHPI_LED_LAMP_TEST, "LAMP_TEST"},
};
/**
* oh_encode_xtcahpiresourceledmode:
* @buffer: Pointer to SaHpiTextBufferT that contains enum's string representation.
* @type: Location (of XtcaHpiResourceLedModeT) to place encoded result.
*
* Converts a @buffer->Data string, generated by oh_lookup_xtcahpiresourceledmode(), back
* into an XtcaHpiResourceLedModeT type.
*
* Returns:
* XtcaHpiResourceLedModeT value - normal operation.
* SA_ERR_HPI_INVALID_PARAMS - if @buffer or @type is NULL or @buffer->Data empty.
* SA_ERR_HPI_INVALID_DATA - if @buffer->Data is invalid.
**/
SaErrorT oh_encode_xtcahpiresourceledmode(SaHpiTextBufferT *buffer, XtcaHpiResourceLedModeT *type)
{
int i, found;
if (!buffer || !type || buffer->Data == NULL || buffer->Data[0] == '\0') {
return(SA_ERR_HPI_INVALID_PARAMS);
}
found = 0;
for (i=0; i<OH_MAX_XTCAHPIRESOURCELEDMODE; i++) {
if (strcasecmp((char *)buffer->Data, xtcahpiresourceledmode_strings[i].str) == 0) {
found++;
break;
}
}
if (found) {
*type = xtcahpiresourceledmode_strings[i].entity_type;
}
else {
return(SA_ERR_HPI_INVALID_DATA);
}
return(SA_OK);
}
/**
* oh_lookup_xtcahpiledbrsupport:
* @value: enum value of type XtcaHpiLedBrSupportT.
*
* Converts @value into a string based on @value's HPI enum definition.
*
* Returns:
* string - normal operation.
* NULL - if @value not a valid XtcaHpiLedBrSupportT.
**/
char * oh_lookup_xtcahpiledbrsupport(XtcaHpiLedBrSupportT value)
{
switch (value) {
case XTCAHPI_LED_BR_SUPPORTED:
return "BR_SUPPORTED";
case XTCAHPI_LED_BR_NOT_SUPPORTED:
return "BR_NOT_SUPPORTED";
case XTCAHPI_LED_BR_UNKNOWN:
return "BR_UNKNOWN";
default:
return NULL;
}
}
struct oh_xtcahpiledbrsupport_map xtcahpiledbrsupport_strings[] = {
{XTCAHPI_LED_BR_SUPPORTED, "BR_SUPPORTED"},
{XTCAHPI_LED_BR_NOT_SUPPORTED, "BR_NOT_SUPPORTED"},
{XTCAHPI_LED_BR_UNKNOWN, "BR_UNKNOWN"},
};
/**
* oh_encode_xtcahpiledbrsupport:
* @buffer: Pointer to SaHpiTextBufferT that contains enum's string representation.
* @type: Location (of XtcaHpiLedBrSupportT) to place encoded result.
*
* Converts a @buffer->Data string, generated by oh_lookup_xtcahpiledbrsupport(), back
* into an XtcaHpiLedBrSupportT type.
*
* Returns:
* XtcaHpiLedBrSupportT value - normal operation.
* SA_ERR_HPI_INVALID_PARAMS - if @buffer or @type is NULL or @buffer->Data empty.
* SA_ERR_HPI_INVALID_DATA - if @buffer->Data is invalid.
**/
SaErrorT oh_encode_xtcahpiledbrsupport(SaHpiTextBufferT *buffer, XtcaHpiLedBrSupportT *type)
{
int i, found;
if (!buffer || !type || buffer->Data == NULL || buffer->Data[0] == '\0') {
return(SA_ERR_HPI_INVALID_PARAMS);
}
found = 0;
for (i=0; i<OH_MAX_XTCAHPILEDBRSUPPORT; i++) {
if (strcasecmp((char *)buffer->Data, xtcahpiledbrsupport_strings[i].str) == 0) {
found++;
break;
}
}
if (found) {
*type = xtcahpiledbrsupport_strings[i].entity_type;
}
else {
return(SA_ERR_HPI_INVALID_DATA);
}
return(SA_OK);
}
/**
* oh_lookup_xtcahpientitytype:
* @value: enum value of type SaHpiEntityTypeT.
*
* Converts @value into a string based on @value's HPI enum definition.
*
* Returns:
* string - normal operation.
* NULL - if @value not a valid SaHpiEntityTypeT.
**/
char * oh_lookup_xtcahpientitytype(SaHpiEntityTypeT value)
{
switch (value) {
case XTCAHPI_ENT_POWER_SLOT:
return "POWER_SLOT";
case XTCAHPI_ENT_SHELF_FRU_DEVICE_SLOT:
return "SHELF_FRU_DEVICE_SLOT";
case XTCAHPI_ENT_SHELF_MANAGER_SLOT:
return "SHELF_MANAGER_SLOT";
case XTCAHPI_ENT_FAN_TRAY_SLOT:
return "FAN_TRAY_SLOT";
case XTCAHPI_ENT_FAN_FILTER_TRAY_SLOT:
return "FAN_FILTER_TRAY_SLOT";
case XTCAHPI_ENT_ALARM_SLOT:
return "ALARM_SLOT";
case XTCAHPI_ENT_AMC_SLOT:
return "AMC_SLOT";
case XTCAHPI_ENT_PMC_SLOT:
return "PMC_SLOT";
case XTCAHPI_ENT_RTM_SLOT:
return "RTM_SLOT";
case XTCAHPI_ENT_CARRIER_MANAGER_SLOT:
return "CARRIER_MANAGER_SLOT";
case XTCAHPI_ENT_CARRIER_SLOT:
return "CARRIER_SLOT";
case XTCAHPI_ENT_COM_E_SLOT:
return "COM_E_SLOT";
default:
return NULL;
}
}
struct oh_xtcahpientitytype_map xtcahpientitytype_strings[] = {
{XTCAHPI_ENT_POWER_SLOT, "POWER_SLOT"},
{XTCAHPI_ENT_SHELF_FRU_DEVICE_SLOT, "SHELF_FRU_DEVICE_SLOT"},
{XTCAHPI_ENT_SHELF_MANAGER_SLOT, "SHELF_MANAGER_SLOT"},
{XTCAHPI_ENT_FAN_TRAY_SLOT, "FAN_TRAY_SLOT"},
{XTCAHPI_ENT_FAN_FILTER_TRAY_SLOT, "FAN_FILTER_TRAY_SLOT"},
{XTCAHPI_ENT_ALARM_SLOT, "ALARM_SLOT"},
{XTCAHPI_ENT_AMC_SLOT, "AMC_SLOT"},
{XTCAHPI_ENT_PMC_SLOT, "PMC_SLOT"},
{XTCAHPI_ENT_RTM_SLOT, "RTM_SLOT"},
{XTCAHPI_ENT_CARRIER_MANAGER_SLOT, "CARRIER_MANAGER_SLOT"},
{XTCAHPI_ENT_CARRIER_SLOT, "CARRIER_SLOT"},
{XTCAHPI_ENT_COM_E_SLOT, "COM_E_SLOT"},
};
/**
* oh_encode_xtcahpientitytype:
* @buffer: Pointer to SaHpiTextBufferT that contains enum's string representation.
* @type: Location (of SaHpiEntityTypeT) to place encoded result.
*
* Converts a @buffer->Data string, generated by oh_lookup_xtcahpientitytype(), back
* into an SaHpiEntityTypeT type.
*
* Returns:
* SaHpiEntityTypeT value - normal operation.
* SA_ERR_HPI_INVALID_PARAMS - if @buffer or @type is NULL or @buffer->Data empty.
* SA_ERR_HPI_INVALID_DATA - if @buffer->Data is invalid.
**/
SaErrorT oh_encode_xtcahpientitytype(SaHpiTextBufferT *buffer, SaHpiEntityTypeT *type)
{
int i, found;
if (!buffer || !type || buffer->Data == NULL || buffer->Data[0] == '\0') {
return(SA_ERR_HPI_INVALID_PARAMS);
}
found = 0;
for (i=0; i<OH_MAX_XTCAHPIENTITYTYPE; i++) {
if (strcasecmp((char *)buffer->Data, xtcahpientitytype_strings[i].str) == 0) {
found++;
break;
}
}
if (found) {
*type = xtcahpientitytype_strings[i].entity_type;
}
else {
return(SA_ERR_HPI_INVALID_DATA);
}
return(SA_OK);
}
|