From c66d1f5c0af70161f4ad4c4175f4280e95b55dfd Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Sun, 19 Jun 2016 11:58:16 +0200 Subject: Initial commit of a mz-header parser. --- mz/mz_header_parser.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 mz/mz_header_parser.cpp (limited to 'mz/mz_header_parser.cpp') diff --git a/mz/mz_header_parser.cpp b/mz/mz_header_parser.cpp new file mode 100644 index 0000000..d18a72e --- /dev/null +++ b/mz/mz_header_parser.cpp @@ -0,0 +1,56 @@ + +#include "mz_header.hpp" + +#include +#include + +#include + +int main(int argc, char* argv[]) { + boost::program_options::options_description description; + description.add_options() + ("help,h", "produces this help message") + ("exe,e", boost::program_options::value(), "The MZ executable to parse the header for.") + ; + + boost::program_options::variables_map vm; + boost::program_options::store(boost::program_options::parse_command_line(argc, argv, description), vm); + boost::program_options::notify(vm); + + if(vm.count("help")) { + std::cout << description << std::endl; + return 0; + } + + boost::filesystem::path file_path; + if(vm.count("exe")) { + std::string exe_file = vm["exe"].as(); + + if(boost::filesystem::exists(exe_file)) { + if(!boost::filesystem::is_directory(exe_file)) { + file_path = exe_file; + } else { + std::cerr << exe_file << " is a folder" << std::endl; + std::cerr << std::endl; + std::cerr << description << std::endl; + return -1; + } + } else { + std::cerr << "file: " << exe_file << " does not exist" << std::endl; + std::cerr << std::endl; + std::cerr << description << std::endl; + return -1; + } + } else { + std::cerr << "Option \"exe_file\" is required"; + std::cerr << std::endl; + std::cerr << description << std::endl; + return -1; + } + + std::ifstream file(file_path.string()); + auto x = parse_mz_file(file); + std::cout << x << std::endl; + + return 0; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2