diff --git a/thin_dump.cc b/thin_dump.cc index 2750aa1..594882c 100644 --- a/thin_dump.cc +++ b/thin_dump.cc @@ -24,14 +24,10 @@ #include "metadata.h" #include "xml_format.h" -#include - using namespace persistent_data; using namespace std; using namespace thin_provisioning; -namespace po = boost::program_options; - //---------------------------------------------------------------- namespace { @@ -54,7 +50,7 @@ namespace { void usage(void) { cerr << "Usage: thin_dump [options] " << endl << endl; cerr << "Options:" << endl; - cerr << " --help Produce help message" << endl; + cerr << " -h [ --help ] Produce help message" << endl; cerr << " -f [ --format ] arg (=xml) Select format (human_readable|xml)" << endl; cerr << " -i [ --input ] arg Input file" << endl; } @@ -63,7 +59,7 @@ namespace { int main(int argc, char **argv) { int c; - const char shortopts[] = "hfi"; + const char shortopts[] = "hf:i:"; string filename, format = "xml"; const struct option longopts[] = { { "help", no_argument, NULL, 'h'}, diff --git a/thin_restore.cc b/thin_restore.cc index a9538c3..674ecb4 100644 --- a/thin_restore.cc +++ b/thin_restore.cc @@ -24,14 +24,12 @@ #include #include -#include +#include using namespace persistent_data; using namespace std; using namespace thin_provisioning; -namespace po = boost::program_options; - //---------------------------------------------------------------- namespace { @@ -53,45 +51,57 @@ namespace { #endif } - void usage(po::options_description const &desc) { + void usage(void) { cerr << "Usage: thin_restore [options]" << endl << endl; - cerr << desc; + cerr << "Options:" << endl; + cerr << " -h [ --help ] Produce help message" << endl; + cerr << " -i [ --input ] arg Input file" << endl; + cerr << " -o [ --output ] arg Output file" << endl; } } int main(int argc, char **argv) { - po::options_description desc("Options"); - desc.add_options() - ("help", "Produce help message") - ("input,i", po::value(), "Input file") - ("output,o", po::value(), "Output file") - ; + int c; + const char *shortopts = "hi:o:"; + string input, output; + const struct option longopts[] = { + { "help", no_argument, NULL, 'h'}, + { "input", required_argument, NULL, 'i' }, + { "output", required_argument, NULL, 'o'}, + { NULL, no_argument, NULL, 0 } + }; - po::variables_map vm; - po::store(po::command_line_parser(argc, argv).options(desc).run(), vm); - po::notify(vm); - - if (vm.count("help")) { - usage(desc); - return 0; + while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) { + switch(c) { + case 'h': + usage(); + return 1; + case 'i': + input = optarg; + break; + case 'o': + output = optarg; + break; + } } - if (vm.count("input") != 1) { - cerr << "No input file provided." << endl; - usage(desc); + if (argc == 1) { + usage(); return 1; } - if (vm.count("output") != 1) { - cerr << "No output file provided." << endl; - usage(desc); + if (input.empty()) { + cerr << "No input file name" << endl; return 1; } - restore(vm["input"].as(), - vm["output"].as()); + if (output.empty()) { + cerr << "No output file name" << endl; + return 1; + } + restore(input, output); return 0; }