Files
RASCSI/cpp/scsictl/scsictl_parser.h
Daniel Markstedt 567dca9cc3 Add device type shorthand 't' for Tape, and change printer to 'p'
The scsictl command parser looks for single letter shorthands for each device type;
this adds 't' for SCTP and changes SCLP to 'p'

Now you can do '-t tape' and '-t printer' for an easy to remember command

Also moves the SCTP default product/vendor into the device factory,
updates the unit tests, and an overhauls the man pages
2025-11-10 19:51:57 +01:00

51 lines
1002 B
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator PiSCSI
// for Raspberry Pi
//
// Copyright (C) 2022 Uwe Seimet
//
//---------------------------------------------------------------------------
#include "generated/piscsi_interface.pb.h"
#include <string>
#include <unordered_map>
using namespace std;
using namespace piscsi_interface;
class ScsictlParser
{
public:
ScsictlParser() = default;
~ScsictlParser() = default;
PbOperation ParseOperation(string_view) const;
PbDeviceType ParseType(const string&) const;
private:
const unordered_map<int, PbOperation> operations = {
{ 'a', ATTACH },
{ 'd', DETACH },
{ 'e', EJECT },
{ 'i', INSERT },
{ 'p', PROTECT },
{ 's', DEVICES_INFO },
{ 'u', UNPROTECT }
};
const unordered_map<int, PbDeviceType> device_types = {
{ 'c', SCCD },
{ 'd', SCDP },
{ 'h', SCHD },
{ 's', SCHS },
{ 'm', SCMO },
{ 'p', SCLP },
{ 'r', SCRM },
{ 't', SCTP }
};
};