| 71 | }; // class Params |
| 72 | |
| 73 | int main(int argc, char** const argv) { |
| 74 | Exiv2::XmpParser::initialize(); |
| 75 | ::atexit(Exiv2::XmpParser::terminate); |
| 76 | |
| 77 | int n; |
| 78 | |
| 79 | #if __has_include(<unistd.h>) |
| 80 | std::cout << "standard getopt()" << std::endl; |
| 81 | do { |
| 82 | n = ::getopt(argc, argv, ::optstring); |
| 83 | if (n >= 0) { |
| 84 | auto N = static_cast<char>(n); |
| 85 | std::cout << n << " = " << N; |
| 86 | } else { |
| 87 | std::cout << n; |
| 88 | } |
| 89 | std::cout << " optind = " << ::optind << " opterr = " << ::opterr << " optopt = " << ::optopt |
| 90 | << " optarg = " << Safe(::optarg) << std::endl; |
| 91 | } while (n >= 0); |
| 92 | std::cout << std::endl; |
| 93 | #endif |
| 94 | |
| 95 | std::cout << "homemade getopt()" << std::endl; |
| 96 | do { |
| 97 | n = Util::getopt(argc, argv, ::optstring); |
| 98 | if (n >= 0) { |
| 99 | auto N = static_cast<char>(n); |
| 100 | std::cout << n << " = " << N; |
| 101 | } else { |
| 102 | std::cout << n; |
| 103 | } |
| 104 | std::cout << " optind = " << Util::optind << " opterr = " << Util::opterr << " optopt = " << Util::optopt |
| 105 | << " optarg = " << Safe(Util::optarg) << std::endl; |
| 106 | |
| 107 | } while (n >= 0); |
| 108 | std::cout << std::endl; |
| 109 | |
| 110 | // Handle command line arguments |
| 111 | Params params; |
| 112 | params.getopt(argc, argv); |
| 113 | |
| 114 | return EXIT_SUCCESS; |
| 115 | } |