summaryrefslogtreecommitdiff
path: root/cd-tool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cd-tool.cpp')
-rw-r--r--cd-tool.cpp61
1 files changed, 55 insertions, 6 deletions
diff --git a/cd-tool.cpp b/cd-tool.cpp
index 8161e39..4cd7c1d 100644
--- a/cd-tool.cpp
+++ b/cd-tool.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: cd-tool.cpp,v 1.44 2005-10-13 16:00:37 pixel Exp $ */
+/* $Id: cd-tool.cpp,v 1.45 2005-11-02 21:34:01 pixel Exp $ */
#define WIP
@@ -35,6 +35,7 @@
#include "generic.h"
#include "Main.h"
#include "cdabstract.h"
+#include "dvdabstract.h"
#include "isobuilder.h"
#include "luacd.h"
#include "luapsx.h"
@@ -333,6 +334,14 @@ int sLua_cdtool::cdtool_proceed_statics(Lua * L, int n, int caller) {
}
int lga = 0;
+enum {
+ NO_OPTION = 0,
+ DVD_IN,
+ DVD_OUT,
+};
+
+int getopt_flag = NO_OPTION;
+
struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"verbose", 0, NULL, 'v'},
@@ -348,6 +357,8 @@ struct option long_options[] = {
{"built-in", 0, NULL, 'b'},
{"probe", 0, NULL, 'p'},
{"log", 1, NULL, 'g'},
+ {"dvd_in", 1, &getopt_flag, DVD_IN},
+ {"dvd_out", 1, &getopt_flag, DVD_OUT},
{0, 0, NULL, 0 }
};
@@ -422,6 +433,8 @@ void showhelp(bool longhelp = false) {
" -p to run a CD device probe.\n"
" -g <log> to log into a file.\n"
" -h for a help page.\n"
+" --dvd_in <iso> replaces -f with a 2048-bytes iso.\n"
+" --dvd_out <iso> replaces -o with a 2048-bytes iso.\n"
, argv[0]);
if (longhelp)
@@ -476,11 +489,10 @@ virtual int startup() throw (GeneralException) {
char c;
bool auto_exec = true, strip = true, todo = false, runit, write = false, builtin = false;
- char * file = 0, * output = 0, * compile = 0, * exec = 0, * line_read = 0;
+ char * file = 0, * output = 0, * compile = 0, * exec = 0, * line_read = 0, * dvd_in = 0, * dvd_out = 0;
char prompt[10];
Lua * L = 0;
- Handle * read_iso = 0;
- Output * build_iso = 0, * write_iso = 0;
+ Handle * read_iso = 0, * build_iso = 0, * write_iso = 0;
Buffer command;
String line, endline;
int pos;
@@ -539,6 +551,21 @@ virtual int startup() throw (GeneralException) {
case 'g':
printer = new cd_tool_printer_t(new Output(optarg));
break;
+ case 0:
+ if (!getopt_flag) {
+ showhelp();
+ throw Exit(-1);
+ }
+ switch(getopt_flag) {
+ case DVD_IN:
+ dvd_in = strdup(optarg);
+ break;
+ case DVD_OUT:
+ dvd_out = strdup(optarg);
+ break;
+ }
+ getopt_flag = NO_OPTION;
+ break;
default:
showhelp();
throw Exit(-1);
@@ -593,6 +620,13 @@ virtual int startup() throw (GeneralException) {
throw Exit(0);
}
+ /* Sanity checks */
+ if (dvd_in && file)
+ throw GeneralException("Error: you can't have both --dvd_in and -f at the same time.");
+
+ if (dvd_out && output)
+ throw GeneralException("Error: you can't have both --dvd_out and -o at the same time.");
+
/* The basic input (and eventually output) iso file */
if (file) {
/* The write mode can't apply on a CD of course... */
@@ -602,6 +636,18 @@ virtual int startup() throw (GeneralException) {
} else {
read_iso = cdabstract::open_cd(file);
}
+ }
+
+ /* Same as above, but with dvd stuff */
+ if (dvd_in) {
+ read_iso = new dvdabstract(new Input(dvd_in));
+ if (write) {
+ write_iso = new dvdabstract(new Output(dvd_in, 0, 0));
+ }
+ }
+
+ /* Let's create the cdutils object and push it to the LUA stack. */
+ if (read_iso) {
cdutil = new cdutils(read_iso, write_iso);
if (!cdutil->get_iso_infos())
throw Exit(-1);
@@ -612,8 +658,11 @@ virtual int startup() throw (GeneralException) {
}
/* The generated iso file */
- if (output) {
- build_iso = new Output(output);
+ if (output || dvd_out) {
+ if (output)
+ build_iso = new Output(output);
+ else
+ build_iso = new dvdabstract(new Output(dvd_out));
build = new isobuilder(build_iso);
Luaisobuilder lbuild(build);
L->push("iso");