nstool/programs/nstool/source/UserSettings.h
jakcron f5997c01f4 [nstool] Add NRO Support.
And cleaned up NSO support.
2018-06-09 23:32:35 +08:00

98 lines
2.9 KiB
C++

#pragma once
#include <string>
#include <fnd/types.h>
#include <nx/npdm.h>
#include "nstool.h"
class UserSettings
{
public:
UserSettings();
void parseCmdArgs(int argc, char** argv);
void showHelp();
// generic options
const std::string getInputPath() const;
const sKeyset& getKeyset() const;
FileType getFileType() const;
bool isVerifyFile() const;
CliOutputType getCliOutputType() const;
// specialised toggles
bool isListFs() const;
bool isListApi() const;
bool isListSymbols() const;
nx::npdm::InstructionType getInstType() const;
// specialised paths
const sOptional<std::string>& getXciUpdatePath() const;
const sOptional<std::string>& getXciNormalPath() const;
const sOptional<std::string>& getXciSecurePath() const;
const sOptional<std::string>& getXciLogoPath() const;
const sOptional<std::string>& getFsPath() const;
const sOptional<std::string>& getNcaPart0Path() const;
const sOptional<std::string>& getNcaPart1Path() const;
const sOptional<std::string>& getNcaPart2Path() const;
const sOptional<std::string>& getNcaPart3Path() const;
private:
const std::string kModuleName = "UserSettings";
struct sCmdArgs
{
sCmdArgs() {}
sOptional<std::string> input_path;
sOptional<bool> devkit_keys;
sOptional<std::string> keyset_path;
sOptional<std::string> file_type;
sOptional<bool> verify_file;
sOptional<bool> verbose_output;
sOptional<bool> minimal_output;
sOptional<bool> list_fs;
sOptional<std::string> update_path;
sOptional<std::string> normal_path;
sOptional<std::string> secure_path;
sOptional<std::string> logo_path;
sOptional<std::string> fs_path;
sOptional<std::string> nca_titlekey;
sOptional<std::string> nca_bodykey;
sOptional<std::string> part0_path;
sOptional<std::string> part1_path;
sOptional<std::string> part2_path;
sOptional<std::string> part3_path;
sOptional<bool> list_api;
sOptional<bool> list_sym;
sOptional<std::string> inst_type;
};
std::string mInputPath;
FileType mFileType;
sKeyset mKeyset;
bool mVerifyFile;
CliOutputType mOutputType;
bool mListFs;
sOptional<std::string> mXciUpdatePath;
sOptional<std::string> mXciNormalPath;
sOptional<std::string> mXciSecurePath;
sOptional<std::string> mXciLogoPath;
sOptional<std::string> mFsPath;
sOptional<std::string> mNcaPart0Path;
sOptional<std::string> mNcaPart1Path;
sOptional<std::string> mNcaPart2Path;
sOptional<std::string> mNcaPart3Path;
bool mListApi;
bool mListSymbols;
nx::npdm::InstructionType mInstructionType;
void populateCmdArgs(int argc, char** argv, sCmdArgs& cmd_args);
void populateKeyset(sCmdArgs& args);
void populateUserSettings(sCmdArgs& args);
void decodeHexStringToBytes(const std::string& name, const std::string& str, byte_t* out, size_t out_len);
FileType getFileTypeFromString(const std::string& type_str);
FileType determineFileTypeFromFile(const std::string& path);
nx::npdm::InstructionType getInstructionTypeFromString(const std::string& type_str);
};