Files
Aaru/DiscImageChef/Options.cs
Natalia Portillo d777061105 * commandline:
* DiscImageChef.Settings/Settings.cs:
	* DiscImageChef.Settings/docs/README.txt:
	* DiscImageChef.Settings/packages.config:
	* DiscImageChef.Settings/docs/LICENSE.txt:
	* DiscImageChef.Settings/docs/ChangeLog.txt:
	* DiscImageChef.Settings/docs/mono/index.xml:
	* DiscImageChef.Settings/docs/html/index.html:
	* DiscImageChef.Settings/Properties/AssemblyInfo.cs:
	* DiscImageChef.Settings/DiscImageChef.Settings.csproj:
	* DiscImageChef.Settings/docs/mono/ns-Claunia.PropertyList.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/UID.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/UID.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSSet.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/index.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSSet.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDate.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSData.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDate.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSData.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSArray.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSNumber.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSString.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSObject.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSArray.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSNumber.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSString.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSObject.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDictionary.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDictionary.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListParser.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListParser.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/XmlPropertyListParser.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/XmlPropertyListParser.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/ASCIIPropertyListParser.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/ASCIIPropertyListParser.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListParser.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListWriter.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListWriter.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListParser.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListFormatException.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListFormatException.html:
	  Added supports for settings

	* DiscImageChef/Commands/Configure.cs:
	  Added support for settings.

	* DiscImageChef/Core/Statistics.cs:
	* DiscImageChef/Commands/Verify.cs:
	* DiscImageChef/Commands/Entropy.cs:
	* DiscImageChef/Commands/Formats.cs:
	* DiscImageChef/Commands/PrintHex.cs:
	* DiscImageChef/Commands/MediaInfo.cs:
	* DiscImageChef/Commands/Statistics.cs:
	  Added statistics.

	* DiscImageChef.Decoders/SCSI/Inquiry.cs:
	  Corrected bug on inquiry decoding.

	* DiscImageChef.Decoders/SCSI/Modes.cs:
	  Corrected bug on decoding mode page 2Ah without write
	  performance descriptors.
	Corrected bug when there is a vendor page 0 in mode sense
	  decoding.

	* DiscImageChef.Devices/Device/Constructor.cs:
	  Corrected detecting USB or FireWire attached CD/DVD/BD and
	  tape drives.
	Try ATA identify on USB or FireWire that don't have SCSI
	  INQUIRY.

	* DiscImageChef.DiscImages/CDRWin.cs:
	  Corrected CD-ROM XA vs CD-ROM detection.

	* DiscImageChef.Partitions/AppleMap.cs:
	  Corrected big endian working.
	Added debug output.

	* DiscImageChef.sln:
	  Added supports for settings.

	* DiscImageChef/Commands/Decode.cs:
	* DiscImageChef/Commands/Analyze.cs:
	* DiscImageChef/Commands/Compare.cs:
	* DiscImageChef/Commands/Checksum.cs:
	* DiscImageChef/Commands/Benchmark.cs:
	* DiscImageChef/Commands/DeviceInfo.cs:
	* DiscImageChef/Commands/CreateSidecar.cs:
	  Added statistics.

	* DiscImageChef/Commands/DeviceReport.cs:
	  Added statistics.
	Correct handling empty inquiry string fields.
	Suppose it is not removable, til proved wrong.
	Corrected MODE SENSE (6/10) detection and calling order.
	If device is MMC type but reports neither mode page 2Ah
	  neither GET CONFIGURATION, try all CDs (old drives work like
	  that).
	Try reading Lead-In and Lead-Out in Audio CD using Audio READ
	  CD commands.
	Corrected READ LONG information handling, some drives return
	  2s-complement in 32 bit. Upper 16 bits are ignored.
	Added support for DVD raw block (37856 bytes).
	Check READ LONG up to 36 times the cooked block size. That
	  should be enough to detect huge blocked media (like DVD and
	  BD) without taking ages.
	If READ LONG size had to be bruteforced, and debug is
	  activated, save the result.

	* DiscImageChef/Commands/DumpMedia.cs:
	  Added statistics.
	Corrected READ LONG information handling, some drives return
	  2s-complement in 32 bit. Upper 16 bits are ignored.
	Start trying with 64 blocks at a time. Some drives report to
	  be able to read 255 at a time, but they really don't, they
	  take a lot longer to read.

	* DiscImageChef/Commands/MediaScan.cs:
	  Added statistics.
	Start trying with 64 blocks at a time. Some drives report to
	  be able to read 255 at a time, but they really don't, they
	  take a lot longer to read.

	* DiscImageChef/DiscImageChef.csproj:
	  Added support for settings.
	Added statistics.

	* DiscImageChef/Main.cs:
	* DiscImageChef/Options.cs:
	  Added support for settings.
	Added statistics.
2016-02-03 18:58:11 +00:00

389 lines
15 KiB
C#

/***************************************************************************
The Disc Image Chef
----------------------------------------------------------------------------
Filename : Options.cs
Version : 1.0
Author(s) : Natalia Portillo
Component : Main program loop.
Revision : $Revision$
Last change by : $Author$
Date : $Date$
--[ Description ] ----------------------------------------------------------
Defines verbs and options.
--[ License ] --------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
Copyright (C) 2011-2014 Claunia.com
****************************************************************************/
//$Id$
using CommandLine;
using CommandLine.Text;
namespace DiscImageChef
{
public abstract class CommonSubOptions
{
[Option('v', "verbose", DefaultValue = false, HelpText = "Shows verbose output")]
public bool Verbose { get; set; }
[Option('d', "debug", DefaultValue = false, HelpText = "Shows debug output from plugins")]
public bool Debug { get; set; }
}
public class AnalyzeSubOptions : CommonSubOptions
{
[Option('p', "partitions", DefaultValue = true,
HelpText = "Searches and interprets partitions.")]
public bool SearchForPartitions { get; set; }
[Option('f', "filesystems", DefaultValue = true,
HelpText = "Searches and interprets partitions.")]
public bool SearchForFilesystems { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
}
public class CompareSubOptions : CommonSubOptions
{
[Option("input1", Required = true, HelpText = "First disc image.")]
public string InputFile1 { get; set; }
[Option("input2", Required = true, HelpText = "Second disc image.")]
public string InputFile2 { get; set; }
}
public class ChecksumSubOptions : CommonSubOptions
{
[Option('t', "separated-tracks", DefaultValue = true,
HelpText = "Checksums each track separately.")]
public bool SeparatedTracks { get; set; }
[Option('w', "whole-disc", DefaultValue = true,
HelpText = "Checksums the whole disc.")]
public bool WholeDisc { get; set; }
[Option('a', "adler32", DefaultValue = true,
HelpText = "Calculates Adler-32.")]
public bool DoAdler32 { get; set; }
[Option("crc16", DefaultValue = true,
HelpText = "Calculates CRC16.")]
public bool DoCRC16 { get; set; }
[Option('c', "crc32", DefaultValue = true,
HelpText = "Calculates CRC32.")]
public bool DoCRC32 { get; set; }
[Option("crc64", DefaultValue = false,
HelpText = "Calculates CRC64 (ECMA).")]
public bool DoCRC64 { get; set; }
/*[Option("fletcher16", DefaultValue = false,
HelpText = "Calculates Fletcher-16.")]
public bool DoFletcher16 { get; set; }
[Option("fletcher32", DefaultValue = false,
HelpText = "Calculates Fletcher-32.")]
public bool DoFletcher32 { get; set; }*/
[Option('m', "md5", DefaultValue = true,
HelpText = "Calculates MD5.")]
public bool DoMD5 { get; set; }
[Option("ripemd160", DefaultValue = false,
HelpText = "Calculates RIPEMD160.")]
public bool DoRIPEMD160 { get; set; }
[Option('s', "sha1", DefaultValue = true,
HelpText = "Calculates SHA1.")]
public bool DoSHA1 { get; set; }
[Option("sha256", DefaultValue = false,
HelpText = "Calculates SHA256.")]
public bool DoSHA256 { get; set; }
[Option("sha384", DefaultValue = false,
HelpText = "Calculates SHA384.")]
public bool DoSHA384 { get; set; }
[Option("sha512", DefaultValue = false,
HelpText = "Calculates SHA512.")]
public bool DoSHA512 { get; set; }
[Option('f', "spamsum", DefaultValue = true,
HelpText = "Calculates SpamSum fuzzy hash.")]
public bool DoSpamSum { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
}
public class EntropySubOptions : CommonSubOptions
{
[Option('p', "duplicated-sectors", DefaultValue = true,
HelpText = "Calculates how many sectors are duplicated (have same exact data in user area).")]
public bool DuplicatedSectors { get; set; }
[Option('t', "separated-tracks", DefaultValue = true,
HelpText = "Calculates entropy for each track separately.")]
public bool SeparatedTracks { get; set; }
[Option('w', "whole-disc", DefaultValue = true,
HelpText = "Calculates entropy for the whole disc.")]
public bool WholeDisc { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
}
public class VerifySubOptions : CommonSubOptions
{
[Option('w', "verify-disc", DefaultValue = true,
HelpText = "Verify disc image if supported.")]
public bool VerifyDisc { get; set; }
[Option('s', "verify-sectors", DefaultValue = true,
HelpText = "Verify all sectors if supported.")]
public bool VerifySectors { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
}
public class PrintHexSubOptions : CommonSubOptions
{
[Option('s', "start", Required = true,
HelpText = "Start sector.")]
public ulong StartSector { get; set; }
[Option('l', "length", DefaultValue = (ulong)1,
HelpText = "How many sectors to print.")]
public ulong Length { get; set; }
[Option('r', "long-sectors", DefaultValue = false,
HelpText = "Print sectors with tags included.")]
public bool LongSectors { get; set; }
[Option('w', "width", DefaultValue = (ushort)32,
HelpText = "How many bytes to print per line.")]
public ushort WidthBytes { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
}
public class DecodeSubOptions : CommonSubOptions
{
[Option('s', "start", DefaultValue = (ulong)0,
HelpText = "Start sector.")]
public ulong StartSector { get; set; }
[Option('l', "length", DefaultValue = "all",
HelpText = "How many sectors to decode, or \"all\".")]
public string Length { get; set; }
[Option('k', "disk-tags", DefaultValue = true,
HelpText = "Decode disk tags.")]
public bool DiskTags { get; set; }
[Option('t', "sector-tags", DefaultValue = true,
HelpText = "Decode sector tags.")]
public bool SectorTags { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
}
public class DeviceInfoSubOptions : CommonSubOptions
{
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
[Option('w', "output-prefix", Required = false, DefaultValue = "", HelpText = "Write binary responses from device with that prefix.")]
public string OutputPrefix { get; set; }
}
public class MediaInfoSubOptions : CommonSubOptions
{
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
[Option('w', "output-prefix", Required = false, DefaultValue = "", HelpText = "Write binary responses from device with that prefix.")]
public string OutputPrefix { get; set; }
}
public class MediaScanSubOptions : CommonSubOptions
{
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
[Option('m', "mhdd-log", Required = false, DefaultValue = "", HelpText = "Write a log of the scan in the format used by MHDD.")]
public string MHDDLogPath { get; set; }
[Option('b', "ibg-log", Required = false, DefaultValue = "", HelpText = "Write a log of the scan in the format used by ImgBurn.")]
public string IBGLogPath { get; set; }
}
public class FormatsSubOptions : CommonSubOptions
{
}
public class BenchmarkSubOptions : CommonSubOptions
{
[Option('b', "block-size", Required = false, DefaultValue = (int)512, HelpText = "Block size.")]
public int BlockSize { get; set; }
[Option('s', "buffer-size", Required = false, DefaultValue = (int)128, HelpText = "Buffer size in mebibytes.")]
public int BufferSize { get; set; }
}
public class CreateSidecarSubOptions : CommonSubOptions
{
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
}
// TODO: Add more options
public class DumpMediaSubOptions : CommonSubOptions
{
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
[Option('w', "output-prefix", Required = true, HelpText = "Prefix for media dump.")]
public string OutputPrefix { get; set; }
[Option('r', "raw", DefaultValue = false,
HelpText = "Print sectors with tags included.")]
public bool Raw { get; set; }
[Option('s', "stop-on-error", DefaultValue = false,
HelpText = "Print sectors with tags included.")]
public bool StopOnError { get; set; }
[Option('f', "force", DefaultValue = false,
HelpText = "Continue dump whatever happens.")]
public bool Force { get; set; }
[Option("reset", DefaultValue = (ushort)0,
HelpText = "Reset the device after these many errors. 0 to disable.")]
public ushort Reset { get; set; }
}
public class DeviceReportSubOptions : CommonSubOptions
{
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
}
public class ConfigureSubOptions : CommonSubOptions
{
}
public class StatsSubOptions : CommonSubOptions
{
}
public class Options
{
public Options()
{
AnalyzeVerb = new AnalyzeSubOptions();
CompareVerb = new CompareSubOptions();
ChecksumVerb = new ChecksumSubOptions();
EntropyVerb = new EntropySubOptions();
VerifyVerb = new VerifySubOptions();
FormatsVerb = new FormatsSubOptions();
PrintHexVerb = new PrintHexSubOptions();
DecodeVerb = new DecodeSubOptions();
DeviceInfoVerb = new DeviceInfoSubOptions();
MediaInfoVerb = new MediaInfoSubOptions();
BenchmarkVerb = new BenchmarkSubOptions();
CreateSidecarVerb = new CreateSidecarSubOptions();
MediaScanVerb = new MediaScanSubOptions();
DumpMediaVerb = new DumpMediaSubOptions();
DeviceReportVerb = new DeviceReportSubOptions();
ConfigureVerb = new ConfigureSubOptions();
StatsVerb = new StatsSubOptions();
}
[VerbOption("analyze", HelpText = "Analyzes a disc image and searches for partitions and/or filesystems.")]
public AnalyzeSubOptions AnalyzeVerb { get; set; }
[VerbOption("compare", HelpText = "Compares two disc images.")]
public CompareSubOptions CompareVerb { get; set; }
[VerbOption("checksum", HelpText = "Checksums an image.")]
public ChecksumSubOptions ChecksumVerb { get; set; }
[VerbOption("entropy", HelpText = "Calculates entropy and/or duplicated sectors of an image.")]
public EntropySubOptions EntropyVerb { get; set; }
[VerbOption("verify", HelpText = "Verifies a disc image integrity, and if supported, sector integrity.")]
public VerifySubOptions VerifyVerb { get; set; }
[VerbOption("printhex", HelpText = "Prints a sector, in hexadecimal values, to the console.")]
public PrintHexSubOptions PrintHexVerb { get; set; }
[VerbOption("decode", HelpText = "Decodes and pretty prints disk and/or sector tags.")]
public DecodeSubOptions DecodeVerb { get; set; }
[VerbOption("formats", HelpText = "Lists all supported disc images, partition schemes and file systems.")]
public FormatsSubOptions FormatsVerb { get; set; }
[VerbOption("device-info", HelpText = "Gets information about a device.")]
public DeviceInfoSubOptions DeviceInfoVerb { get; set; }
[VerbOption("media-info", HelpText = "Gets information about the media inserted on a device.")]
public MediaInfoSubOptions MediaInfoVerb { get; set; }
[VerbOption("benchmark", HelpText = "Benchmarks hashing and entropy calculation.")]
public BenchmarkSubOptions BenchmarkVerb { get; set; }
[VerbOption("create-sidecar", HelpText = "Creates CICM Metadata XML sidecar.")]
public CreateSidecarSubOptions CreateSidecarVerb { get; set; }
[VerbOption("media-scan", HelpText = "Scans the media inserted on a device.")]
public MediaScanSubOptions MediaScanVerb { get; set; }
[VerbOption("dump-media", HelpText = "Dumps the media inserted on a device to a media image.")]
public DumpMediaSubOptions DumpMediaVerb { get; set; }
[VerbOption("device-report", HelpText = "Tests the device capabilities and creates an XML report of them.")]
public DeviceReportSubOptions DeviceReportVerb { get; set; }
[VerbOption("configure", HelpText = "Configures user settings and statistics.")]
public ConfigureSubOptions ConfigureVerb { get; set; }
[VerbOption("stats", HelpText = "Shows statistics.")]
public StatsSubOptions StatsVerb { get; set; }
[HelpVerbOption]
public string DoHelpForVerb(string verbName)
{
return HelpText.AutoBuild(this, verbName);
}
}
}