X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_kdm.cc;h=2c274de423ba0048ce759c5f08c1bcba500f5c19;hb=22917c031a262ce6e90252a65d6f70a340fafbed;hp=2ad07cce7a38bae73c62f2b1824def725e9ada34;hpb=8d58a7c5f4320ad5c111e336c45e44d6b51ab509;p=dcpomatic.git diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 2ad07cce7..2c274de42 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington 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 @@ -17,24 +17,27 @@ */ +/** @file src/tools/dcpomatic_kdm.cc + * @brief Command-line program to generate KDMs. + */ + #include -#include +#include #include "lib/film.h" #include "lib/cinema.h" #include "lib/kdm.h" #include "lib/config.h" #include "lib/exceptions.h" +#include "lib/safe_stringstream.h" +#include using std::string; -using std::stringstream; using std::cout; using std::cerr; using std::list; using std::vector; using boost::shared_ptr; -static string program_name; - static void help () { @@ -76,7 +79,7 @@ time_from_string (string t) static boost::posix_time::time_duration duration_from_string (string d) { - stringstream s (d); + SafeStringStream s (d); int N; string unit; s >> N >> unit; @@ -114,7 +117,7 @@ int main (int argc, char* argv[]) dcp::Formulation formulation = dcp::MODIFIED_TRANSITIONAL_1; program_name = argv[0]; - + int option_index = 0; while (true) { static struct option long_options[] = { @@ -177,7 +180,7 @@ int main (int argc, char* argv[]) } else if (string (optarg) == "dci-specific") { formulation = dcp::DCI_SPECIFIC; } else { - error ("unrecognised KDM formulation " + formulation); + error ("unrecognised KDM formulation " + string (optarg)); } } } @@ -213,7 +216,8 @@ int main (int argc, char* argv[]) } string const film_dir = argv[optind]; - + + dcpomatic_setup_path_encoding (); dcpomatic_setup (); shared_ptr film; @@ -247,8 +251,8 @@ int main (int argc, char* argv[]) if (output.empty ()) { error ("you must specify --output"); } - - shared_ptr certificate (new dcp::Certificate (boost::filesystem::path (certificate_file))); + + dcp::Certificate certificate (dcp::file_to_string (certificate_file)); dcp::EncryptedKDM kdm = film->make_kdm (certificate, cpl, valid_from.get(), valid_to.get(), formulation); kdm.as_xml (output); if (verbose) { @@ -276,7 +280,7 @@ int main (int argc, char* argv[]) write_kdm_zip_files ( film, (*i)->screens(), cpl, dcp::LocalTime (valid_from.get()), dcp::LocalTime (valid_to.get()), formulation, output ); - + if (verbose) { cout << "Wrote ZIP files to " << output << "\n"; } @@ -284,7 +288,7 @@ int main (int argc, char* argv[]) write_kdm_files ( film, (*i)->screens(), cpl, dcp::LocalTime (valid_from.get()), dcp::LocalTime (valid_to.get()), formulation, output ); - + if (verbose) { cout << "Wrote KDM files to " << output << "\n"; }