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
|
|
|
|
//
|
2023-10-15 06:38:15 +00:00
|
|
|
// Copyright (C) 2022-2023 Uwe Seimet
|
2022-10-08 17:26:04 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "scsictl_parser.h"
|
2022-10-08 17:26:04 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
PbOperation ScsictlParser::ParseOperation(string_view 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
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
string t;
|
|
|
|
ranges::transform(type, back_inserter(t), ::toupper);
|
2022-10-08 17:26:04 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|