summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-05-27 16:56:34 +0100
committerCarl Hetherington <cth@carlh.net>2014-05-27 16:56:34 +0100
commitbc419bd953dc31184aa3f3a6a3c9b8693bc34b7c (patch)
tree6858141a99a7d92b1c071048d678614ddc28ae26 /tools
parentf0de0c63504446714ab642f9db872bd31f9c070b (diff)
Start of STL binary reader; start of dumpsubs.
Diffstat (limited to 'tools')
-rw-r--r--tools/dumpsubs.cc83
-rw-r--r--tools/wscript6
2 files changed, 89 insertions, 0 deletions
diff --git a/tools/dumpsubs.cc b/tools/dumpsubs.cc
new file mode 100644
index 0000000..159af25
--- /dev/null
+++ b/tools/dumpsubs.cc
@@ -0,0 +1,83 @@
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <map>
+#include <getopt.h>
+#include "reader_factory.h"
+#include "reader.h"
+
+using std::string;
+using std::cerr;
+using std::cout;
+using std::map;
+using boost::shared_ptr;
+using namespace sub;
+
+static void
+help (string n)
+{
+ cerr << "Syntax: " << n << " <file>\n";
+}
+
+int
+main (int argc, char* argv[])
+{
+ int option_index = 0;
+ while (1) {
+ static struct option long_options[] = {
+ { "help", no_argument, 0, 'h'},
+ { 0, 0, 0, 0 }
+ };
+
+ int c = getopt_long (argc, argv, "h", long_options, &option_index);
+
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 'h':
+ help (argv[0]);
+ exit (EXIT_SUCCESS);
+ }
+ }
+
+ if (argc <= optind || argc > (optind + 1)) {
+ help (argv[0]);
+ exit (EXIT_FAILURE);
+ }
+
+ if (access (argv[optind], F_OK) == -1) {
+ cerr << argv[0] << ": file " << argv[optind] << " not found.\n";
+ exit (EXIT_FAILURE);
+ }
+
+ shared_ptr<Reader> reader = reader_factory (argv[optind]);
+ if (!reader) {
+ cerr << argv[0] << ": could not read subtitle file " << argv[optind] << "\n";
+ exit (EXIT_FAILURE);
+ }
+
+ map<string, string> metadata = reader->metadata ();
+ for (map<string, string>::const_iterator i = metadata.begin(); i != metadata.end(); ++i) {
+ cout << i->first << ": " << i->second << "\n";
+ }
+
+ return 0;
+}
diff --git a/tools/wscript b/tools/wscript
new file mode 100644
index 0000000..3db10b2
--- /dev/null
+++ b/tools/wscript
@@ -0,0 +1,6 @@
+def build(bld):
+ obj = bld(features = 'cxx cxxprogram')
+ obj.use = ['libsub']
+ obj.uselib = 'OPENJPEG CXML'
+ obj.source = 'dumpsubs.cc'
+ obj.target = 'dumpsubs'