Skip to content

Commit

Permalink
Update banner handling
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Nov 25, 2023
1 parent 8d8cabe commit 4809fab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
16 changes: 8 additions & 8 deletions cpp/piscsi/piscsi_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ void Piscsi::Banner(span<char *> args) const
cout << piscsi_util::Banner("(Backend Service)");
cout << "Connection type: " << CONNECT_DESC << '\n' << flush;

if ((args.size() > 1 && strcmp(args[1], "-h") == 0) || (args.size() > 1 && strcmp(args[1], "--help") == 0)){
if (args.size() > 1 && (string(args[1]) == "-h" || string(args[1]) == "--help")) {
cout << "\nUsage: " << args[0] << " [-idID[:LUN] FILE] ...\n\n";
cout << " ID is SCSI device ID (0-" << (ControllerManager::GetScsiIdMax() - 1) << ").\n";
cout << " LUN is the optional logical unit (0-" << (ControllerManager::GetScsiLunMax() - 1) <<").\n";
cout << " FILE is a disk image file, \"daynaport\", \"bridge\", \"printer\" or \"services\".\n\n";
cout << " Image type is detected based on file extension if no explicit type is specified.\n";
cout << " hd1 : SCSI-1 HD image (Non-removable generic SCSI-1 HD image)\n";
cout << " hds : SCSI HD image (Non-removable generic SCSI HD image)\n";
cout << " hdr : SCSI HD image (Removable generic HD image)\n";
cout << " hda : SCSI HD image (Apple compatible image)\n";
cout << " mos : SCSI MO image (MO image)\n";
cout << " iso : SCSI CD image (ISO 9660 image)\n";
cout << " is1 : SCSI CD image (ISO 9660 image, SCSI-1)\n" << flush;
cout << " hd1 : SCSI HD image (Non-removable SCSI-1-CCS HD image)\n";
cout << " hds : SCSI HD image (Non-removable SCSI-2 HD image)\n";
cout << " hdr : SCSI HD image (Removable SCSI-2 HD image)\n";
cout << " hda : SCSI HD image (Apple compatible SCSI-2 HD image, same as hdr)\n";
cout << " mos : SCSI MO image (MO SCSI-2 image)\n";
cout << " iso : SCSI CD image (ISO 9660 image, SCSI-2)\n";
cout << " is1 : SCSI CD image (ISO 9660 image, SCSI-1-CCS)\n" << flush;

exit(EXIT_SUCCESS);
}
Expand Down
11 changes: 5 additions & 6 deletions cpp/scsidump/scsidump_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ void ScsiDump::TerminationHandler(int)
// Process will terminate automatically
}

bool ScsiDump::Banner(ostream &console, span<char*> args) const
bool ScsiDump::Banner(span<char*> args) const
{
console << piscsi_util::Banner("(Hard Disk Dump/Restore Utility)");

if (args.size() < 2 || string(args[1]) == "-h" || string(args[1]) == "--help") {
console << "Usage: " << args[0] << " -t ID[:LUN] [-i BID] [-f FILE] [-a] [-r] [-b BUFFER_SIZE]"
if (args.size() > 1 && (string(args[1]) == "-h" || string(args[1]) == "--help")) {
cout << piscsi_util::Banner("(Hard Disk Dump/Restore Utility)")
<< "Usage: " << args[0] << " -t ID[:LUN] [-i BID] [-f FILE] [-a] [-r] [-b BUFFER_SIZE]"
<< " [-L log_level] [-p] [-I] [-s]\n"
<< " ID is the target device ID (0-" << (ControllerManager::GetScsiIdMax() - 1) << ").\n"
<< " LUN is the optional target device LUN (0-" << (ControllerManager::GetScsiLunMax() - 1) << ")."
Expand Down Expand Up @@ -182,7 +181,7 @@ int ScsiDump::run(span<char*> args, bool in_process)
// When dumping to stdout use stderr instead of stdout for console output
ostream &console = to_stdout ? cerr : cout;

if (!Banner(console, args)) {
if (!Banner(args)) {
return EXIT_SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/scsidump/scsidump_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ScsiDump

private:

bool Banner(ostream&, span<char*>) const;
bool Banner(span<char*>) const;
bool Init(bool);
void ParseArguments(span<char*>);
void DisplayBoardId(ostream&) const;
Expand Down
2 changes: 1 addition & 1 deletion cpp/scsiexec/scsiexec_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool ScsiExec::Banner(span<char*> args) const
{
cout << piscsi_util::Banner("(SCSI Command Execution Tool)");

if (args.size() < 2 || string(args[1]) == "-h" || string(args[1]) == "--help") {
if (args.size() > 1 && (string(args[1]) == "-h" || string(args[1]) == "--help")) {
cout << "Usage: " << args[0] << " -t ID[:LUN] [-i BID] [-f INPUT_FILE] [-o OUTPUT_FILE]"
<< " [-L LOG_LEVEL] [-b] [-B] [-F] [-T] [-X]\n"
<< " ID is the target device ID (0-" << (ControllerManager::GetScsiIdMax() - 1) << ").\n"
Expand Down

0 comments on commit 4809fab

Please sign in to comment.