2022-10-08 17:26:04 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-10-08 17:26:04 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "scsictl_parser.h"
|
2022-10-08 17:26:04 +00:00
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
PbOperation ScsictlParser::ParseOperation(const string& operation) const
|
2022-10-08 17:26:04 +00:00
|
|
|
{
|
|
|
|
const auto& it = operations.find(tolower(operation[0]));
|
|
|
|
return it != operations.end() ? it->second : NO_OPERATION;
|
|
|
|
}
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
PbDeviceType ScsictlParser::ParseType(const string& type) const
|
2022-10-08 17:26:04 +00:00
|
|
|
{
|
|
|
|
string t = type;
|
|
|
|
transform(t.begin(), t.end(), t.begin(), ::toupper);
|
|
|
|
|
|
|
|
if (PbDeviceType parsed_type; PbDeviceType_Parse(t, &parsed_type)) {
|
|
|
|
return parsed_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle convenience device types (shortcuts)
|
|
|
|
const auto& it = device_types.find(tolower(type[0]));
|
|
|
|
return it != device_types.end() ? it->second : UNDEFINED;
|
|
|
|
}
|