No-op: remove all trailing whitespace.
[dcpomatic.git] / src / tools / dcpomatic_kdm.cc
index fa14dd141ad03f210380e76fa1245b534e6d5b96..345b905457d8415ae3b7e7edf78d6e3f054c8a3c 100644 (file)
 
 */
 
+/** @file  src/tools/dcpomatic_kdm.cc
+ *  @brief Command-line program to generate KDMs.
+ */
+
 #include <getopt.h>
 #include <dcp/certificates.h>
 #include "lib/film.h"
 #include "lib/kdm.h"
 #include "lib/config.h"
 #include "lib/exceptions.h"
+#include "lib/safe_stringstream.h"
 
 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 +78,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,9 +116,9 @@ int main (int argc, char* argv[])
        dcp::Formulation formulation = dcp::MODIFIED_TRANSITIONAL_1;
 
        program_name = argv[0];
-       
+
        int option_index = 0;
-       while (1) {
+       while (true) {
                static struct option long_options[] = {
                        { "help", no_argument, 0, 'h'},
                        { "output", required_argument, 0, 'o'},
@@ -177,7 +179,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 +215,7 @@ int main (int argc, char* argv[])
        }
 
        string const film_dir = argv[optind];
-                       
+
        dcpomatic_setup ();
 
        shared_ptr<Film> film;
@@ -247,8 +249,8 @@ int main (int argc, char* argv[])
                if (output.empty ()) {
                        error ("you must specify --output");
                }
-               
-               shared_ptr<dcp::Certificate> 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 +278,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 +286,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";
                                }