diff options
-rw-r--r-- | cd-tool.cpp | 61 | ||||
-rw-r--r-- | compile/macosX/Makefile | 3 | ||||
-rw-r--r-- | compile/win32/Makefile | 231 | ||||
-rw-r--r-- | includes/cdutils.h | 18 | ||||
-rw-r--r-- | includes/dvdabstract.h | 56 | ||||
-rw-r--r-- | includes/isobuilder.h | 12 | ||||
-rw-r--r-- | lib/cdutils.cpp | 157 | ||||
-rw-r--r-- | lib/dvdabstract.cpp | 161 | ||||
-rw-r--r-- | lib/isobuilder.cpp | 278 | ||||
-rw-r--r-- | lib/luacd.cpp | 94 |
10 files changed, 693 insertions, 378 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"); diff --git a/compile/macosX/Makefile b/compile/macosX/Makefile index f862add..ab8b399 100644 --- a/compile/macosX/Makefile +++ b/compile/macosX/Makefile @@ -82,7 +82,8 @@ PSX_SOURCES = \ cdabstract.cpp luacd.cpp \ cdreader.cpp luapsx.cpp \ cdutils.cpp lzss.cpp \ -yazedc.cpp isobuilder.cpp +yazedc.cpp isobuilder.cpp \ +dvdabstract.cpp PSXDEV_SOURCES = \ bs.c jfdctint.c xadecode.c \ diff --git a/compile/win32/Makefile b/compile/win32/Makefile index b5dd4b3..f1f35c1 100644 --- a/compile/win32/Makefile +++ b/compile/win32/Makefile @@ -1,170 +1,153 @@ -CC = i586-mingw32msvc-gcc -CXX = i586-mingw32msvc-g++ -LD = i586-mingw32msvc-g++ -STRIP = i586-mingw32msvc-strip +CC = i686-pc-mingw32-gcc +CXX = i686-pc-mingw32-g++ +LD = i686-pc-mingw32-g++ +STRIP = i686-pc-mingw32-strip -INCLUDES = -I../../includes -I../../psxdev -I../../generic/include \ --I../../MSVC/regex -I../../MSVC/readline -I../../MSVC/getopt -I../../MSVC \ +INCLUDES = \ +-I../../includes -I../../psxdev -I../../generic/include \ -I../../generic/lib/zlib/include \ -I../../generic/lib/lua/include -I../../generic/lib/lua/includes \ -I../../mogltk/include \ --I/usr/local/cross-tools/i386-mingw32msvc/include/SDL \ +-I../../MSVC/regex -I../../MSVC/readline -I../../MSVC/getopt -I../../MSVC \ -I../.. -CPPFLAGS = $(INCLUDES) -O4 -march=i686 -DSTDC_HEADERS -DREADLINE_STATIC -fexceptions +CPPFLAGS = $(INCLUDES) -march=i686 -DSTDC_HEADERS -DREADLINE_STATIC -fexceptions -LDFLAGS = +LDFLAGS = -O4 `sdl-config --libs` -SOURCES = \ -../../cd-tool.cpp ../../luapatch.cpp +vpath %.c ../../Dalos:../../:../../mogltk/lib:../../generic/lib:../../lib:../../psxdev:../../generic/lib/zlib/src:../../generic/lib/lua/src:../../generic/lib/lua/src/LuaLib:../../MSVC/regex:../../MSVC/getopt +vpath %.cc ../../Dalos:../../:../../mogltk/lib:../../generic/lib:../../lib:../../psxdev:../../generic/lib/zlib/src:../../generic/lib/lua/src:../../generic/lib/lua/src/LuaLib:../../MSVC/regex:../../MSVC/getopt +vpath %.cpp ../../Dalos:../../:../../mogltk/lib:../../generic/lib:../../lib:../../psxdev:../../generic/lib/zlib/src:../../generic/lib/lua/src:../../generic/lib/lua/src/LuaLib:../../MSVC/regex:../../MSVC/getopt -MOGLTK_SOURCES = \ -../../mogltk/lib/base.cc ../../mogltk/lib/glwidgets.cc \ -../../mogltk/lib/engine.cc ../../mogltk/lib/mcolor.cc \ -../../mogltk/lib/font.cc ../../mogltk/lib/shape.cc \ -../../mogltk/lib/glbase.cc ../../mogltk/lib/sprite.cc \ -../../mogltk/lib/glfont.cc ../../mogltk/lib/texture.cc \ -../../mogltk/lib/glshape.cc ../../mogltk/lib/widgets.cc \ -../../mogltk/lib/glsprite.cc +SOURCES = \ +cd-tool.cpp +#Dalos.cpp + +MOGLTK_SOURCES = +#base.cc glwidgets.cc \ +#engine.cc mcolor.cc \ +#font.cc shape.cc \ +#glbase.cc sprite.cc \ +#glfont.cc texture.cc \ +#glshape.cc widgets.cc \ +#glsprite.cc BALTISOT_SOURCES = \ -../../generic/lib/Image.cc ../../generic/lib/Main.cc \ -../../generic/lib/BLua.cc ../../generic/lib/Buffer.cc \ -../../generic/lib/ConfigFile.cc ../../generic/lib/Output.cc \ -../../generic/lib/Exceptions.cc ../../generic/lib/Regex.cc \ -../../generic/lib/Handle.cc ../../generic/lib/String.cc \ -../../generic/lib/Input.cc ../../generic/lib/fileutils.cc \ -../../generic/lib/LuaHandle.cc ../../generic/lib/generic.cc \ -../../generic/lib/checkargs.c ../../generic/lib/datecalc.c \ -../../generic/lib/LuaRegex.cc ../../generic/lib/LuaConfigFile.cc +Image.cc Main.cc \ +BLua.cc Buffer.cc \ +ConfigFile.cc Output.cc \ +Exceptions.cc Regex.cc \ +Handle.cc String.cc \ +Input.cc fileutils.cc \ +LuaHandle.cc generic.cc \ +checkargs.c datecalc.c \ +LuaRegex.cc LuaConfigFile.cc ZLIB_SOURCES = \ -../../generic/lib/zlib/src/adler32.c ../../generic/lib/zlib/src/inffast.c \ -../../generic/lib/zlib/src/compress.c ../../generic/lib/zlib/src/inflate.c \ -../../generic/lib/zlib/src/crc32.c ../../generic/lib/zlib/src/inftrees.c \ -../../generic/lib/zlib/src/deflate.c \ -../../generic/lib/zlib/src/gzio.c ../../generic/lib/zlib/src/trees.c \ -../../generic/lib/zlib/src/infblock.c ../../generic/lib/zlib/src/uncompr.c \ -../../generic/lib/zlib/src/zutil.c +adler32.c inffast.c \ +compress.c inflate.c \ +crc32.c inftrees.c \ +deflate.c \ +gzio.c trees.c \ +uncompr.c \ +zutil.c LUA_SOURCES = \ -../../generic/lib/lua/src/lapi.c ../../generic/lib/lua/src/lparser.c \ -../../generic/lib/lua/src/lcode.c ../../generic/lib/lua/src/lstate.c \ -../../generic/lib/lua/src/ldebug.c ../../generic/lib/lua/src/lstring.c \ -../../generic/lib/lua/src/ldo.c ../../generic/lib/lua/src/ltable.c \ -../../generic/lib/lua/src/ldump.c ../../generic/lib/lua/src/ltests.c \ -../../generic/lib/lua/src/lfunc.c ../../generic/lib/lua/src/ltm.c \ -../../generic/lib/lua/src/lgc.c ../../generic/lib/lua/src/luacomp.c \ -../../generic/lib/lua/src/llex.c ../../generic/lib/lua/src/lundump.c \ -../../generic/lib/lua/src/lmem.c ../../generic/lib/lua/src/lvm.c \ -../../generic/lib/lua/src/lobject.c ../../generic/lib/lua/src/lzio.c \ -../../generic/lib/lua/src/lopcodes.c \ -../../generic/lib/lua/src/LuaLib/lauxlib.c \ -../../generic/lib/lua/src/LuaLib/lbaselib.c \ -../../generic/lib/lua/src/LuaLib/ldblib.c \ -../../generic/lib/lua/src/LuaLib/liolib.c \ -../../generic/lib/lua/src/LuaLib/lmathlib.c \ -../../generic/lib/lua/src/LuaLib/loadlib.c \ -../../generic/lib/lua/src/LuaLib/lstrlib.c \ -../../generic/lib/lua/src/LuaLib/ltablib.c \ -../../generic/lib/lua/src/LuaLib/ldirlib.c - -HASH_SOURCES = \ -../../generic/lib/hashtab.c ../../generic/lib/lookupa.c \ -../../generic/lib/recycle.c +lapi.c lparser.c \ +lcode.c lstate.c \ +ldebug.c lstring.c \ +ldo.c ltable.c \ +ldump.c ltests.c \ +lfunc.c ltm.c \ +lgc.c luacomp.c \ +llex.c lundump.c \ +lmem.c lvm.c \ +lobject.c lzio.c \ +lopcodes.c \ +lauxlib.c \ +lbaselib.c \ +ldblib.c \ +liolib.c \ +lmathlib.c \ +loadlib.c \ +lstrlib.c \ +ltablib.c \ +ldirlib.c + +#HASH_SOURCES = \ +#hashtab.c lookupa.c \ +#recycle.c +HASH_SOURCES = PSX_SOURCES = \ -../../lib/cdabstract.cpp ../../lib/luacd.cpp \ -../../lib/cdreader.cpp ../../lib/luapsx.cpp \ -../../lib/cdutils.cpp \ - ../../lib/yazedc.cpp ../../lib/isobuilder.cpp +cdabstract.cpp luacd.cpp \ +cdreader.cpp luapsx.cpp \ +cdutils.cpp lzss.cpp \ +yazedc.cpp isobuilder.cpp \ +dvdabstract.cpp PSXDEV_SOURCES = \ -../../psxdev/bs.c ../../psxdev/jfdctint.c ../../psxdev/xadecode.c \ -../../psxdev/idctfst.c ../../psxdev/vlc.c +bs.c jfdctint.c xadecode.c \ +idctfst.c vlc.c -REGEX_SOURCES = \ -../../MSVC/regex/msvc-regex.c +REGEX_SOURCES = msvc-regex.c + +GETOPT_SOURCES = getopt.c getopt1.c -GETOPT_SOURCES = \ -../../MSVC/getopt/getopt.c ../../MSVC/getopt/getopt1.c COMMON_SOURCES = \ $(BALTISOT_SOURCES) $(ZLIB_SOURCES) $(REGEX_SOURCES) $(GETOPT_SOURCES) \ $(LUA_SOURCES) $(PSX_SOURCES) $(PSXDEV_SOURCES) $(READLINE_SOURCES) \ $(HASH_SOURCES) + WHOLE_SOURCES = $(SOURCES) $(COMMON_SOURCES) $(MOGLTK_SOURCES) ALL_OBJECTS = $(addsuffix .o, $(notdir $(basename $(WHOLE_SOURCES)))) - -ALL_DEP = $(addsuffix .dep, $(notdir $(basename $(WHOLE_SOURCES)))) +ALL_DEPS = $(addsuffix .dep, $(notdir $(basename $(WHOLE_SOURCES)))) DALOS_OBJECTS = $(addsuffix .o, $(notdir $(basename $(COMMON_SOURCES) $(MOGLTK_SOURCES)))) Dalos.o CD_TOOL_OBJECTS = $(addsuffix .o, $(notdir $(basename $(COMMON_SOURCES)))) cd-tool.o -CD_TOOL_DEP = $(addsuffix .dep, $(notdir $(basename $(COMMON_SOURCES)))) cd-tool.dep - -LUAPATCH_OBJECTS = $(addsuffix .o, $(notdir $(basename $(COMMON_SOURCES)))) luapatch.o +all: dep cd-tool.exe -LUAPATCH_DEP = $(addsuffix .dep, $(notdir $(basename $(COMMON_SOURCES)))) luapatch.dep +dep: $(ALL_DEPS) -all: cd-tool.exe luapatch.exe +#stats: +# @wc $(WHOLE_SOURCES) -stats: - @wc $(WHOLE_SOURCES) - -dist: all ../../cd-tool.lua ../../COPYING ../../FAQ-cd.txt ../../README-LuaPatch.txt # README-SDL.txt SDL.dll +dist: all ../../cd-tool.lua ../../COPYING ../../FAQ-cd.txt ../../README-LuaPatch.txt zip -j9 ../cd-tool-`date +%Y%m%d`-win32.zip cd-tool.exe ../../cd-tool.lua ../../FAQ-cd.txt ../../COPYING - #zip -j9 ../Dalos-`date +%Y%m%d`-win32.zip Dalos.exe ../../COPYING README-SDL.txt SDL.dll - zip -j9 ../luapatch-`date +%Y%m%d`.zip luapatch.exe ../../FAQ-cd.txt ../../COPYING ../../README-LuaPatch.txt -Dalos.exe: $(DALOS_OBJECTS) - $(LD) $(LDFLAGS) -o Dalos.exe $(DALOS_OBJECTS) -lmingw32 -L/usr/local/cross-tools/i386-mingw32msvc/lib -lmingw32 -lSDLmain -lSDL -mwindows -lopengl32 -lglu32 ../../libreadline-static.a - $(STRIP) Dalos.exe - upx-nrv -9 Dalos.exe - cat ../../Dalos/Dalos.paq >> Dalos.exe +Dalos: $(DALOS_OBJECTS) + $(LD) -o Dalos $(DALOS_OBJECTS) -lGL -lGLU -lreadline -lSDL -lpthread + $(STRIP) Dalos + +Dalos-static: $(DALOS_OBJECTS) + $(LD) -o Dalos-static $(DALOS_OBJECTS) -lGL -lGLU -lreadline -lSDL -lpthread -static -laa -lgpm -lncurses -lX11 -lslang -lXext -ldl -lvga -lasound -L/usr/X11R6/lib + $(STRIP) Dalos-static cd-tool.exe: $(CD_TOOL_OBJECTS) - $(LD) $(LDFLAGS) -o cd-tool.exe $(CD_TOOL_OBJECTS) ../../libreadline-static.a -mconsole + $(LD) -o cd-tool.exe $(CD_TOOL_OBJECTS) ../../libreadline-static.a -mconsole $(STRIP) cd-tool.exe - upx-nrv -9 cd-tool.exe -luapatch.exe: $(LUAPATCH_OBJECTS) - i586-mingw32msvc-windres -I ../../ ../../luapatch.rc luapatch-res.o - $(LD) $(LDFLAGS) -o luapatch.exe $(LUAPATCH_OBJECTS) luapatch-res.o -mconsole -lcomdlg32 - $(STRIP) luapatch.exe - upx-nrv -9 luapatch.exe +cd-tool-static: $(CD_TOOL_OBJECTS) + $(LD) $(LDFLAGS) -o cd-tool-static $(CD_TOOL_OBJECTS) -lreadline -lncurses -static + $(STRIP) cd-tool-static clean: - rm -f *.exe *.o *.dep - -source: dep $(COMMON_SOURCES) ../../cd-tool.cpp - for s in $(COMMON_SOURCES) ../../cd-tool.cpp ; do \ - depfile=$${s/*\//} ; \ - depfile=$${depfile/\.*/}.dep ; \ - for f in `cat $$depfile | sed 's/\\\\//g' | tr \\ '\\012' | grep -v ^$$ | grep -v :` $$s; do \ - install -D $$f tmp/`echo $$f | sed 's/\.\.\/\.\.\///'` ; \ - done ; \ - done - (cd tmp ; zip -r9 ../../cd-tool-`date +%Y%m%d`-win32-fullsrc.zip .) - rm -rf tmp - --include $(ALL_OBJECTS:.o=.dep) - -define OBJECT_C_template - $(addsuffix .o, $(notdir $(basename $(1)))): $(src) - $$(CC) $$(CPPFLAGS) $$(CFLAGS) -c $(src) - $(addsuffix .dep, $(notdir $(basename $(1)))): $(src) - $$(CC) $$(CPPFLAGS) $$(CFLAGS) -MM $(src) -o $$@ -endef - -define OBJECT_CXX_template - $(addsuffix .o, $(notdir $(basename $(1)))): $(src) - $$(CXX) $$(CPPFLAGS) $$(CXXFLAGS) -c $(src) - $(addsuffix .dep, $(notdir $(basename $(1)))): $(src) - $$(CXX) $$(CPPFLAGS) $$(CXXFLAGS) -MM $(src) -o $$@ -endef - -$(foreach src, $(WHOLE_SOURCES), $(if $(filter %.c, $(src)), $(eval $(call OBJECT_C_template, $(src))), $(eval $(call OBJECT_CXX_template, $(src))))) + rm -f cd-tool.exe *.o *.dep + + +%.dep : %.c + $(CC) $(CPPFLAGS) -M -MF $@ $< + +%.dep : %.cpp + $(CXX) $(CPPFLAGS) -M -MF $@ $< + +%.dep : %.cc + $(CXX) $(CPPFLAGS) -M -MF $@ $< + + +-include $(ALL_DEPS) diff --git a/includes/cdutils.h b/includes/cdutils.h index 3e11ca2..c463908 100644 --- a/includes/cdutils.h +++ b/includes/cdutils.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: cdutils.h,v 1.18 2004-11-27 21:47:53 pixel Exp $ */ +/* $Id: cdutils.h,v 1.19 2005-11-02 21:34:02 pixel Exp $ */ #ifndef __CDUTILS_H__ #define __CDUTILS_H__ @@ -76,15 +76,23 @@ class cdutils : public Base { Handle * open_ppf(String ppf, String comment) throw(GeneralException); void close_ppf() throw(GeneralException); void set_iso_w(Handle *); - static unsigned short int swap_word(unsigned short int i); - static unsigned long int swap_dword(unsigned long int i); + static Uint16 swap_word(Uint16 i); + static Uint32 swap_dword(Uint32 i); + static Uint16 from_LE16(Uint16 i); + static Uint32 from_LE32(Uint32 i); + static Uint16 from_BE16(Uint16 i); + static Uint32 from_BE32(Uint32 i); + static Uint16 to_LE16(Uint16 i) { return from_LE16(i); } + static Uint32 to_LE32(Uint32 i) { return from_LE32(i); } + static Uint16 to_BE16(Uint16 i) { return from_BE16(i); } + static Uint32 to_BE32(Uint32 i) { return from_BE32(i); } int guess_type(int number = -1); void sector_seek(long sector); long read_sector(Byte * buffer, int type = GUESS, int number = -1); - void read_datas(Byte * buffer, long size, int type = GUESS, int number = -1); + void read_data(Byte * buffer, long size, int type = GUESS, int number = -1); void read_file(Handle * Handle, long size, int type = GUESS, int number = -1); void write_sector(Byte * buffer, int type = GUESS, int number = -1) throw (GeneralException); - void write_datas(Byte * buffer, long size, int type = GUESS, int number = -1); + void write_data(Byte * buffer, long size, int type = GUESS, int number = -1); void write_file(Handle * Handle, long size = -1, int type = GUESS, int number = -1); void create_sector(int type, int number, bool eof = false) throw (GeneralException); int get_iso_infos(); diff --git a/includes/dvdabstract.h b/includes/dvdabstract.h new file mode 100644 index 0000000..f11f5f6 --- /dev/null +++ b/includes/dvdabstract.h @@ -0,0 +1,56 @@ +/* + * PSX-Tools Bundle Pack + * Copyright (C) 2002-2003 Nicolas "Pixel" Noble + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: dvdabstract.h,v 1.1 2005-11-02 21:34:02 pixel Exp $ */ + +#ifndef __DVDABSTRACT_H__ +#define __DVDABSTRACT_H__ + +#include <Exceptions.h> +#include <Handle.h> +#include <cdutils.h> + +class dvdabstract : public Handle { + public: + dvdabstract(Handle * h, int = MODE2_FORM1); + virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException); + virtual off_t tell() const; + virtual ssize_t read(void * buf, size_t count) throw (GeneralException); + virtual ssize_t write(const void * buf, size_t count) throw (GeneralException); + + virtual bool CanRead() const { return r->CanRead(); } + virtual bool CanWrite() const { return r->CanWrite(); } + virtual bool CanSeek() const { return true; } + virtual String GetName() const { return "DVD abstraction of " + r->GetName(); } + virtual time_t GetModif() const { return r->GetModif(); } + virtual bool CanWatch() const { return false; } + virtual void Flush() { r->Flush(); } + virtual void SetZ(int = 9) throw (GeneralException) { throw GeneralException("Can't SetZ() a dvdabstract."); } + virtual int Dup() const throw (GeneralException) { throw GeneralException("Can't Dup() a dvdabstract."); } + + private: + Handle * r; + off_t v; + int m; + + void write_sector(const char * buf, int sector) throw (GeneralException); + void read_sector(char * buf, int sector); +}; + +#endif diff --git a/includes/isobuilder.h b/includes/isobuilder.h index c01406b..7f86f05 100644 --- a/includes/isobuilder.h +++ b/includes/isobuilder.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: isobuilder.h,v 1.12 2004-12-17 11:48:41 pixel Exp $ */ +/* $Id: isobuilder.h,v 1.13 2005-11-02 21:34:02 pixel Exp $ */ #ifndef __ISOBUILDER_H__ #define __ISOBUILDER_H__ @@ -30,9 +30,9 @@ class isobuilder : public Base { public: struct Date { int year, month, day, hour, minute, second, hundredths, offset; - void dump(Byte * datas); + void dump(Byte * data); Date(int = 0); - Date(Byte * datas); + Date(Byte * data); }; struct PVD { String sysid, volid; @@ -47,7 +47,7 @@ class isobuilder : public Base { virtual ~DirTree(); void fromdir(cdutils::DirEntry *); void dumpdirs(isobuilder *) throw (GeneralException); - int buildpath(Byte * datas, int size, bool bigendian = false) throw (GeneralException); + int buildpath(Byte * data, int size, bool bigendian = false) throw (GeneralException); bool isdir(); void setbasicsxa(); int sector; @@ -76,8 +76,8 @@ class isobuilder : public Base { void foreword(Byte * forewords, int mode = MODE_RAW); int getdispsect(); int putfile(Handle * file, int mode = -1, int sector = -1); - int putdatas(Byte * datas, size_t size, int mode = -1, int sector = -1); - int createsector(Byte * datas, int mode = -1, int sector = -1, int FN = -1, int CN = -1, int SM = -1, int CI = -1); + int putdata(Byte * data, size_t size, int mode = -1, int sector = -1); + int createsector(Byte * data, int mode = -1, int sector = -1, int FN = -1, int CN = -1, int SM = -1, int CI = -1); int createsector(Handle * file, int mode = -1, int sector = -1, int FN = -1, int CN = -1, int SM = -1, int CI = -1); void setEOF(); void clearEOF(); diff --git a/lib/cdutils.cpp b/lib/cdutils.cpp index ea4ff4c..f39114c 100644 --- a/lib/cdutils.cpp +++ b/lib/cdutils.cpp @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: cdutils.cpp,v 1.33 2004-11-27 21:47:56 pixel Exp $ */ +/* $Id: cdutils.cpp,v 1.34 2005-11-02 21:34:02 pixel Exp $ */ #include <stdio.h> #include <string.h> @@ -26,6 +26,14 @@ #include "cdutils.h" #include "Output.h" +#ifdef WORDS_BIGENDIAN +#define IS_LITTLE_ENDIAN 0 +#define IS_BIG_ENDIAN 1 +#else +#define IS_LITTLE_ENDIAN 1 +#define IS_BIG_ENDIAN 0 +#endif + const long sec_sizes[7] = {0, 2048, 2336, 2048, 2324, 2352, 2352}; const long sec_offsts[7] = {0, 16, 16, 24, 24, 0, 0}; const String sec_modes[7] = {"MODE 0 (empty)", "MODE 1", "MODE 2", "MODE 2 FORM 1", "MODE 2 FORM 2", "Raw", "Autodetect"}; @@ -38,24 +46,24 @@ cdutils::~cdutils() { free(rootDir); } -unsigned char cdutils::from_BCD(unsigned char x) { +Uint8 cdutils::from_BCD(Uint8 x) { return ((x & 0xf) + ((x & 0xf0) >> 4) * 10); } -unsigned char cdutils::to_BCD(unsigned char x) { +Uint8 cdutils::to_BCD(Uint8 x) { return ((x / 10) << 4) | (x % 10); } -bool cdutils::is_valid_BCD(unsigned char x) { +bool cdutils::is_valid_BCD(Uint8 x) { return (((x & 15) < 10) && ((x >> 4) < 10)); } -unsigned long cdutils::from_MSF(unsigned char m, unsigned char s, unsigned char f, unsigned long start) { +Uint32 cdutils::from_MSF(Uint8 m, Uint8 s, Uint8 f, Uint32 start) { return (from_BCD(m) * 60 + from_BCD(s)) * 75 + from_BCD(f) - start; } -unsigned long cdutils::from_MSF(unsigned long msf, unsigned long start) { - unsigned char +Uint32 cdutils::from_MSF(Uint32 msf, Uint32 start) { + Uint8 f = msf & 0xff, s = (msf >> 8) & 0xff, m = (msf >> 16) & 0xff; @@ -63,7 +71,7 @@ unsigned long cdutils::from_MSF(unsigned long msf, unsigned long start) { return from_MSF(m, s, f, start); } -void cdutils::to_MSF(int sect, unsigned char & m, unsigned char & s, unsigned char & f, unsigned long start) { +void cdutils::to_MSF(int sect, Uint8 & m, Uint8 & s, Uint8 & f, Uint32 start) { sect += start; f = to_BCD(sect % 75); sect /= 75; @@ -71,8 +79,8 @@ void cdutils::to_MSF(int sect, unsigned char & m, unsigned char & s, unsigned ch m = to_BCD(sect / 60); } -unsigned long cdutils::to_MSF(int sect, unsigned long start) { - unsigned char m, s, f; +Uint32 cdutils::to_MSF(int sect, Uint32 start) { + Uint8 m, s, f; to_MSF(sect, m, s, f, start); return f | (s << 8) | (m << 16); } @@ -165,6 +173,38 @@ Uint32 cdutils::swap_dword(Uint32 i) { return (i >> 24) | ((i >> 8) & 0x0000ff00) | ((i << 8) & 0x00ff0000) | (i << 24); } +Uint16 cdutils::from_LE16(Uint16 i) { +#ifdef WORDS_BIGENDIAN + return swap_word(i); +#else + return i; +#endif +} + +Uint32 cdutils::from_LE32(Uint32 i) { +#ifdef WORDS_BIGENDIAN + return swap_dword(i); +#else + return i; +#endif +} + +Uint16 cdutils::from_BE16(Uint16 i) { +#ifdef WORDS_BIGENDIAN + return i; +#else + return swap_word(i); +#endif +} + +Uint32 cdutils::from_BE32(Uint32 i) { +#ifdef WORDS_BIGENDIAN + return i; +#else + return swap_dword(i); +#endif +} + int cdutils::guess_type(int number) { Byte header[24]; @@ -177,7 +217,7 @@ int cdutils::guess_type(int number) { if (header[15] == 1) { return MODE_1; } else if (header[15] == 2) { - if (*((unsigned long *) &(header[16])) == *((unsigned long *) &(header[20]))) { + if (*((Uint32 *) &(header[16])) == *((Uint32 *) &(header[20]))) { if ((header[16] == 0) && (header[17] == 0) && (header[19] == 0)) { if (header[18] & 0x20) { return MODE_2_FORM_2; @@ -224,7 +264,7 @@ long cdutils::read_sector(Byte * buffer, int type, int number) { return sec_sizes[type]; } -void cdutils::read_datas(Byte * buffer, long size, int type, int number) { +void cdutils::read_data(Byte * buffer, long size, int type, int number) { Byte sector[2352]; int i, n, reste; @@ -312,9 +352,9 @@ void cdutils::write_sector(Byte * buffer, int type, int number) throw (GeneralEx } } -void cdutils::write_datas(Byte * buffer, long size, int type, int number) { +void cdutils::write_data(Byte * buffer, long size, int type, int number) { long nbsectors, i; - unsigned char sector[2352]; + Uint8 sector[2352]; if (type == GUESS) { type = guess_type(number); @@ -339,7 +379,7 @@ void cdutils::write_datas(Byte * buffer, long size, int type, int number) { void cdutils::write_file(Handle * file, long size, int type, int number) { long nbsectors, i; - unsigned char buffer[2352]; + Uint8 buffer[2352]; if (type == GUESS) { type = guess_type(number); @@ -394,10 +434,15 @@ void cdutils::show_head_entry(void) { int cdutils::show_entry(struct DirEntry * dir) { char pbuf[200], pad; int s; + Uint32 Sector, Size; + if ((!dir) || (!dir->R)) { return 1; } + Sector = from_LE32(dir->Sector); + Size = from_LE32(dir->Size); + strncpy(pbuf, dir->id, dir->N); pbuf[dir->N] = 0; if ((dir->N == 1) && (pbuf[0] == 0)) { @@ -433,7 +478,7 @@ int cdutils::show_entry(struct DirEntry * dir) { dir->Year += 100; printm(M_BARE, "%6i %9i %2i/%02i/%04i %2i:%02i:%02i%+03.1f %c%c%c%c%c%c%c%c %s\n", - dir->Sector, dir->Size, dir->Day, dir->Month, dir->Year + 1900, dir->Hour, dir->Minute, dir->Second, ((float) dir->Offset) / 4, + Sector, Size, dir->Day, dir->Month, dir->Year + 1900, dir->Hour, dir->Minute, dir->Second, ((float) dir->Offset) / 4, dir->Flags & 1 ? 'H' : '-', dir->Flags & 2 ? 'D' : '-', dir->Flags & 4 ? 'A' : '-', dir->Flags & 8 ? 'R' : '-', dir->Flags & 16 ? 'P' : '-', dir->Flags & 32 ? '1' : '-', dir->Flags & 64 ? '1' : '-', dir->Flags & 128 ? 'C' : '-', pbuf); return dir->R; @@ -442,16 +487,20 @@ int cdutils::show_entry(struct DirEntry * dir) { int cdutils::show_dir(struct DirEntry * dir) { unsigned int ptr; Byte * buffer; + Uint32 Size, Sector; if (!(dir->Flags & 2)) { return 0; } - buffer = (Byte *) malloc(dir->Size); - read_datas(buffer, dir->Size, GUESS, dir->Sector); + Size = from_LE32(dir->Size); + Sector = from_LE32(dir->Sector); + + buffer = (Byte *) malloc(Size); + read_data(buffer, Size, GUESS, Sector); ptr = 0; - while(ptr < dir->Size) { + while(ptr < Size) { ptr += show_entry((struct DirEntry *) &(buffer[ptr])); } @@ -461,15 +510,19 @@ int cdutils::show_dir(struct DirEntry * dir) { struct cdutils::DirEntry cdutils::find_dir_entry(struct DirEntry * dir, String name) { unsigned int ptr, size; - unsigned char * buffer; + Uint8 * buffer; struct DirEntry r = {0, 0, 0, 0, 0}; + Uint32 Sector; if (!(dir->Flags & 2)) { return r; } - buffer = (unsigned char *) malloc(size = dir->Size); - read_datas(buffer, dir->Size, GUESS, dir->Sector); + Sector = from_LE32(dir->Sector); + size = from_LE32(dir->Size); + + buffer = (Uint8 *) malloc(size); + read_data(buffer, size, GUESS, Sector); ptr = 0; while(ptr < size) { @@ -493,13 +546,17 @@ struct cdutils::DirEntry * cdutils::find_dir_entry(Byte ** bufout, struct cdutil Byte * buffer; struct DirEntry * rdir = 0; *bufout = 0; + Uint32 Sector; if (!(dir->Flags & 2)) { return 0; } - buffer = (Byte *) malloc(size = dir->Size); - read_datas(buffer, dir->Size, GUESS, dir->Sector); + size = from_LE32(dir->Size); + Sector = from_LE32(dir->Sector); + + buffer = (Byte *) malloc(size); + read_data(buffer, size, GUESS, Sector); ptr = 0; while(ptr < size) { @@ -527,7 +584,7 @@ struct cdutils::DirEntry * cdutils::find_dir_entry(Byte ** bufout, struct cdutil int cdutils::show_iso_infos() { char buffer[2048]; char pbuff[130]; - short int s, nogood = 0; + int16 s, nogood = 0; read_sector((Byte *) buffer, GUESS, 16); @@ -537,7 +594,7 @@ int cdutils::show_iso_infos() { memcpy(pbuff, buffer + 1, 5); pbuff[5] = 0; printm(M_BARE, " 1 - 5-`CD001' : %s\n", pbuff); - printm(M_BARE, " 6 - 2- 1 : %i\n", s = *((short int *) &(buffer[6]))); + printm(M_BARE, " 6 - 2- 1 : %i\n", s = from_LE16(*((Uint16 *) &(buffer[6])))); printm(M_BARE, "(*this was the signature*)\n"); if (buffer[0] != 1) nogood = 1; if (strcmp(pbuff, "CD001")) nogood = 1; @@ -554,15 +611,15 @@ int cdutils::show_iso_infos() { memcpy(pbuff, buffer + 40, 32); pbuff[32] = 0; printm(M_BARE, " 40 - 32- VOLID : %s\n", pbuff); - printm(M_BARE, " 80 - 8- SNum : %li\n", *((long int *) &(buffer[80]))); - printm(M_BARE, " 120 - 4- VOLSiz : %i\n", *((short int *) &(buffer[120]))); - printm(M_BARE, " 124 - 4- VOLNum : %i\n", *((short int *) &(buffer[124]))); - printm(M_BARE, " 128 - 4- SSize : %i\n", *((short int *) &(buffer[128]))); - printm(M_BARE, " 132 - 8- PSize : %li\n", *((long int *) &(buffer[132]))); - printm(M_BARE, " 140 - 4- 1SLPath: %i\n", *((long int *) &(buffer[140]))); - printm(M_BARE, " 144 - 4- 2SLPath: %i\n", *((long int *) &(buffer[144]))); - printm(M_BARE, " 148 - 4- 1SBPath: %i\n", swap_word(*((long int *) &(buffer[150])))); - printm(M_BARE, " 152 - 4- 2SBPath: %i\n", swap_word(*((long int *) &(buffer[154])))); + printm(M_BARE, " 80 - 8- SNum : %li\n", from_LE32(*((Uint32 *) &(buffer[80])))); + printm(M_BARE, " 120 - 4- VOLSiz : %i\n", from_LE16(*((Uint16 *) &(buffer[120])))); + printm(M_BARE, " 124 - 4- VOLNum : %i\n", from_LE16(*((Uint16 *) &(buffer[124])))); + printm(M_BARE, " 128 - 4- SSize : %i\n", from_LE16(*((Uint16 *) &(buffer[128])))); + printm(M_BARE, " 132 - 8- PSize : %li\n", from_LE32(*((Uint32 *) &(buffer[132])))); + printm(M_BARE, " 140 - 4- 1SLPath: %li\n", from_LE32(*((Uint32 *) &(buffer[140])))); + printm(M_BARE, " 144 - 4- 2SLPath: %li\n", from_LE32(*((Uint32 *) &(buffer[144])))); + printm(M_BARE, " 148 - 4- 1SBPath: %li\n", from_BE32(*((Uint32 *) &(buffer[148])))); + printm(M_BARE, " 152 - 4- 2SBPath: %li\n", from_BE32(*((Uint32 *) &(buffer[152])))); memcpy(pbuff, buffer + 190, 128); pbuff[128] = 0; printm(M_BARE, " 190 - 128- VStId : %s\n", pbuff); @@ -599,7 +656,7 @@ int cdutils::show_iso_infos() { int cdutils::get_iso_infos() { Byte buffer[2048]; char pbuff[130]; - short int s, nogood = 0; + int16 s, nogood = 0; int rootsec; read_sector(buffer, GUESS, 16); @@ -607,7 +664,7 @@ int cdutils::get_iso_infos() { memcpy(pbuff, buffer + 1, 5); pbuff[5] = 0; - s = *((short int *) &(buffer[6])); + s = from_LE16(*((Uint16 *) &(buffer[6]))); if (buffer[0] != 1) nogood = 1; if (strcmp(pbuff, "CD001")) nogood = 1; if (s != 1) nogood = 1; @@ -617,11 +674,11 @@ int cdutils::get_iso_infos() { return 0; } - pt1 = *((short int *) &(buffer[140])); - pt2 = *((short int *) &(buffer[144])); - snum = *((int *) &(buffer[80])); - ptl = *((long int *) &(buffer[132])); - rootsec = ((struct DirEntry *) (&buffer[156]))->Sector; + pt1 = from_LE16(*((Uint16 *) &(buffer[140]))); + pt2 = from_LE16(*((Uint16 *) &(buffer[144]))); + snum = from_LE32(*((Uint32 *) &(buffer[80]))); + ptl = from_LE32(*((Uint32 *) &(buffer[132]))); + rootsec = from_LE32(((struct DirEntry *) (&buffer[156]))->Sector); read_sector(buffer, GUESS, rootsec); rootDir = (struct DirEntry *) malloc(buffer[0]); memcpy(rootDir, buffer, buffer[0]); @@ -641,7 +698,7 @@ int cdutils::get_pt_infos() { } buffer = (Byte *) malloc(ptl); - read_datas(buffer, ptl, GUESS, !pt1 ? pt2 : pt1); + read_data(buffer, ptl, GUESS, !pt1 ? pt2 : pt1); if (buffer[0] == 1) if (buffer[1] == 0) @@ -649,7 +706,7 @@ int cdutils::get_pt_infos() { if (buffer[7] == 0) if (buffer[8] == 0) if (buffer[9] == 0) - root = *((unsigned long int *) &(buffer[2])); + root = from_LE32(*((Uint32 *) &(buffer[2]))); free(buffer); return root ? 1 : 0; @@ -670,13 +727,13 @@ int cdutils::show_pt_infos() { } buffer = (Byte *) malloc(ptl + 2); - read_datas(buffer, ptl, GUESS, !pt1 ? pt2 : pt1); + read_data(buffer, ptl, GUESS, !pt1 ? pt2 : pt1); printm(M_BARE, "node^paren@sector : name\n"); for (ptr = 0, i = 1; buffer[ptr]; ptr += ptr & 1, i++) { strncpy(pbuf, (char *) &(buffer[8 + ptr]), buffer[ptr]); pbuf[buffer[ptr]] = 0; - printm(M_BARE, "%3i ^ %3i @ %6i: %s\n", i, *((unsigned short *) &(buffer[6 + ptr])), *((unsigned long *) &(buffer[2 + ptr])), pbuf); + printm(M_BARE, "%3i ^ %3i @ %6i: %s\n", i, from_LE16(*((Uint16 *) &(buffer[6 + ptr]))), from_LE32(*((Uint32 *) &(buffer[2 + ptr]))), pbuf); ptr += 8 + buffer[ptr]; } @@ -862,7 +919,7 @@ cdfile::cdfile(cdutils * _cd, const cdutils::DirEntry * d, int _mode) : Handle(- } cdfile::cdfile(cdutils * _cd, int _sector, ssize_t _size, int _mode) : Handle(-1), cd(_cd), sector(_sector), mode(_mode), size(_size), name("raw reading") { - Byte datas[2352]; + Byte data[2352]; bool eof; if (mode == GUESS) { @@ -872,8 +929,8 @@ cdfile::cdfile(cdutils * _cd, int _sector, ssize_t _size, int _mode) : Handle(-1 size = 0; if ((mode == MODE2_FORM1) || (mode == MODE2_FORM2)) { do { - cd->read_sector(datas, MODE_RAW, sector + size++); - eof = datas[18] & 0x80; + cd->read_sector(data, MODE_RAW, sector + size++); + eof = data[18] & 0x80; } while (!eof); size *= sec_sizes[mode]; } @@ -908,7 +965,7 @@ ssize_t cdfile::read(void *buf, size_t count) throw (GeneralException) { buf = (Byte *) buf + nstartbytes; if (count) { - cd->read_datas((Byte *) buf, count, mode, startsec + 1); + cd->read_data((Byte *) buf, count, mode, startsec + 1); } itell += count + nstartbytes; diff --git a/lib/dvdabstract.cpp b/lib/dvdabstract.cpp new file mode 100644 index 0000000..582ad90 --- /dev/null +++ b/lib/dvdabstract.cpp @@ -0,0 +1,161 @@ +/* + * PSX-Tools Bundle Pack + * Copyright (C) 2002-2003 Nicolas "Pixel" Noble + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: dvdabstract.cpp,v 1.1 2005-11-02 21:34:02 pixel Exp $ */ + +#include "dvdabstract.h" + +dvdabstract::dvdabstract(Handle * h, int _m) : Handle(-1), r(h), v(h->tell()), m(_m) { +} + +off_t dvdabstract::seek(off_t offset, int wheel) throw (GeneralException) { + switch (wheel) { + case SEEK_SET: + v = offset; + break; + case SEEK_CUR: + v += offset; + break; + case SEEK_END: + throw IOGeneral("Can't seek from the end of the dvdabstract..."); + } +} + +off_t dvdabstract::tell() const { + return v; +} + +ssize_t dvdabstract::read(void * _buf, size_t count) throw (GeneralException) { + char i_buf[2352], * buf = (char *) _buf; + int sector, start, reminder, i_count; + + if (!count) return 0; + + sector = v / 2352; + start = v % 2352; + + read_sector(i_buf, sector); + + if ((start + count) < 2352) { + memcpy(buf, i_buf + start, count); + return count; + } + + reminder = 2352 - start; + memcpy(buf, i_buf + start, reminder); + sector++; + i_count = count - reminder; + buf += reminder; + + while (i_count >= 2352) { + read_sector(buf, sector); + i_count -= 2352; + sector++; + buf += 2352; + } + + reminder = i_count; + + if (reminder >= 0) { + read_sector(i_buf, sector); + memcpy(buf, i_buf, reminder); + } + + return count; +} + +ssize_t dvdabstract::write(const void * _buf, size_t count) throw (GeneralException) { + char i_buf[2352], * buf = (char *) _buf; + int sector, start, reminder, i_count; + + if (!count) return 0; + + sector = v / 2352; + start = v % 2352; + + memcpy(i_buf + start, buf, 2352 - start); + if (start >= 16) { + i_buf[15] = m; + if (m == MODE2_FORM1) { + i_buf[18] = i_buf[22] = 1; + } + } + write_sector(i_buf, sector); + + if ((start + count) < 2352) { + return count; + } + + reminder = 2352 - start; + sector++; + i_count = count - reminder; + buf += reminder; + + while (i_count >= 2352) { + write_sector(buf, sector); + i_count -= 2352; + sector++; + buf += 2352; + } + + reminder = i_count; + memcpy(i_buf, buf, reminder); + if (reminder >= 0) { + memcpy(buf, i_buf, reminder); + if (reminder <= 22) { + if (reminder <= 15) { + i_buf[15] = m; + if (m == MODE2_FORM1) { + i_buf[18] = i_buf[22] = 1; + } + } else if (i_buf[15] == MODE2_FORM1) { + i_buf[18] = i_buf[22] = 1; + } + } + write_sector(i_buf, sector); + } + + return count; +} + +void dvdabstract::read_sector(char * buf, int sector) { + r->seek(sector * 2048); + r->read(buf + 16, 2048); + buf[0] = buf[11] = 0; + buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = buf[7] = buf[8] = buf[9] = buf[10] = -1; + buf[12] = buf[13] = buf[14] = 0; + buf[15] = 1; +} + +void dvdabstract::write_sector(const char * buf, int sector) throw (GeneralException) { + r->seek(sector * 2048); + switch(buf[15]) { + case 0: + case 1: + r->write(buf + 16, 2048); + break; + case 2: + if ((buf[18] == 1) && (buf[22] == 1)) { + r->write(buf + 24, 2048); + break; + } + default: + throw GeneralException("dvdabstract::write_sector: unknown sector mode."); + } +} diff --git a/lib/isobuilder.cpp b/lib/isobuilder.cpp index 5d72abb..327b55c 100644 --- a/lib/isobuilder.cpp +++ b/lib/isobuilder.cpp @@ -17,68 +17,68 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: isobuilder.cpp,v 1.17 2005-01-30 14:46:24 pixel Exp $ */ +/* $Id: isobuilder.cpp,v 1.18 2005-11-02 21:34:02 pixel Exp $ */ #include "isobuilder.h" -void isobuilder::Date::dump(Byte * datas) { +void isobuilder::Date::dump(Byte * data) { char pbuf[256]; sprintf(pbuf, "%04i", year); - memcpy(datas + 0, pbuf, 4); + memcpy(data + 0, pbuf, 4); sprintf(pbuf, "%02i", month); - memcpy(datas + 4, pbuf, 2); + memcpy(data + 4, pbuf, 2); sprintf(pbuf, "%02i", day); - memcpy(datas + 6, pbuf, 2); + memcpy(data + 6, pbuf, 2); sprintf(pbuf, "%02i", hour); - memcpy(datas + 8, pbuf, 2); + memcpy(data + 8, pbuf, 2); sprintf(pbuf, "%02i", minute); - memcpy(datas + 10, pbuf, 2); + memcpy(data + 10, pbuf, 2); sprintf(pbuf, "%02i", second); - memcpy(datas + 12, pbuf, 2); + memcpy(data + 12, pbuf, 2); sprintf(pbuf, "%02i", hundredths); - memcpy(datas + 14, pbuf, 2); + memcpy(data + 14, pbuf, 2); - *((char *) (datas + 16)) = offset; + *((char *) (data + 16)) = offset; } isobuilder::Date::Date(int) { year = month = day = hour = minute = second = hundredths = offset = 0; } -isobuilder::Date::Date(Byte * datas) { +isobuilder::Date::Date(Byte * data) { char pbuf[256]; - char * cdatas = (char *) datas; + char * cdata = (char *) data; - memcpy(pbuf, cdatas + 0, 4); + memcpy(pbuf, cdata + 0, 4); pbuf[4] = 0; sscanf(pbuf, "%d", &year); - memcpy(pbuf, cdatas + 4, 2); + memcpy(pbuf, cdata + 4, 2); pbuf[2] = 0; sscanf(pbuf, "%d", &month); - memcpy(pbuf, cdatas + 6, 2); + memcpy(pbuf, cdata + 6, 2); pbuf[2] = 0; sscanf(pbuf, "%d", &day); - memcpy(pbuf, cdatas + 8, 2); + memcpy(pbuf, cdata + 8, 2); pbuf[2] = 0; sscanf(pbuf, "%d", &hour); - memcpy(pbuf, cdatas + 10, 2); + memcpy(pbuf, cdata + 10, 2); pbuf[2] = 0; sscanf(pbuf, "%d", &minute); - memcpy(pbuf, cdatas + 12, 2); + memcpy(pbuf, cdata + 12, 2); pbuf[2] = 0; sscanf(pbuf, "%d", &second); - memcpy(pbuf, cdatas + 14, 2); + memcpy(pbuf, cdata + 14, 2); pbuf[2] = 0; sscanf(pbuf, "%d", &hundredths); - offset = *(cdatas + 16); + offset = *(cdata + 16); } isobuilder::DirTree::DirTree(isobuilder::DirTree * _father, bool _dir) : mode(-1), father(_father), dir(_dir) { @@ -164,19 +164,19 @@ void isobuilder::DirTree::dumpdirs(isobuilder * builder) throw (GeneralException dir += R; } - builder->putdatas(odir, size, mode, sector); + builder->putdata(odir, size, mode, sector); free(odir); } -int isobuilder::DirTree::buildpath(Byte * datas, int size, bool bigendian) throw (GeneralException) { +int isobuilder::DirTree::buildpath(Byte * data, int size, bool bigendian) throw (GeneralException) { int N, r, tr; Uint16 pn; char pbuf[256], pad; if (!dir) { if (brother) { - return brother->buildpath(datas, size, bigendian); + return brother->buildpath(data, size, bigendian); } else { return 0; } @@ -199,28 +199,28 @@ int isobuilder::DirTree::buildpath(Byte * datas, int size, bool bigendian) throw if (size < 0) throw GeneralException("Path table too small."); - datas[0] = N; - datas[1] = 0; - *((Uint32 *) (datas + 2)) = bigendian ? cdutils::swap_dword(sector) : sector; - *((Uint16 *) (datas + 6)) = bigendian ? cdutils::swap_word(pn) : pn; - memcpy(datas + 8, pbuf, N); + data[0] = N; + data[1] = 0; + *((Uint32 *) (data + 2)) = bigendian ? cdutils::to_BE32(sector) : cdutils::to_LE32(sector); + *((Uint16 *) (data + 6)) = bigendian ? cdutils::to_BE16(pn) : cdutils::to_LE16(pn); + memcpy(data + 8, pbuf, N); if (pad) - datas[8 + N] = 0; + data[8 + N] = 0; - datas += r; + data += r; if (brother) { - tr = brother->buildpath(datas, size, bigendian); + tr = brother->buildpath(data, size, bigendian); r += tr; size -= tr; - datas += tr; + data += tr; } if (child) { - tr = child->buildpath(datas, size, bigendian); + tr = child->buildpath(data, size, bigendian); r += tr; size -= tr; - datas += tr; + data += tr; } return r; @@ -285,10 +285,10 @@ int isobuilder::DirTree::buildentry(Byte * buffer, int spaceleft, bool put_xa) { d->N = N; memcpy(d->id, pbuf, N + pad + (put_xa ? 14 : 0)); - d->Sector = sector; - d->BESector = cdutils::swap_dword(sector); - d->Size = size; - d->BESize = cdutils::swap_dword(size); + d->Sector = cdutils::to_LE32(sector); + d->BESector = cdutils::to_BE32(sector); + d->Size = cdutils::to_LE32(size); + d->BESize = cdutils::to_BE32(size); if (creation.year >= 1000) { d->Year = creation.year - 1900; } else { @@ -459,7 +459,7 @@ int isobuilder::getdispsect() { } int isobuilder::putfile(Handle * file, int mode, int n) { - Byte datas[2352]; + Byte data[2352]; ssize_t filesize; int fsect; @@ -477,8 +477,8 @@ int isobuilder::putfile(Handle * file, int mode, int n) { filesize = file->GetSize(); while (filesize > 0) { - memset(datas, 0, 2352); - filesize -= file->read(datas, sec_sizes[mode]); + memset(data, 0, 2352); + filesize -= file->read(data, sec_sizes[mode]); if ((mode == MODE2_FORM1) || (mode == MODE2_FORM2)) { if (filesize) { clearEOF(); @@ -486,14 +486,14 @@ int isobuilder::putfile(Handle * file, int mode, int n) { setEOF(); } } - createsector(datas, mode); + createsector(data, mode); } return fsect; } -int isobuilder::putdatas(Byte * _datas, size_t size, int smode, int n) { - Byte datas[2352]; +int isobuilder::putdata(Byte * _data, size_t size, int smode, int n) { + Byte data[2352]; size_t eating; int dsect; if (n >= 0) { @@ -508,11 +508,11 @@ int isobuilder::putdatas(Byte * _datas, size_t size, int smode, int n) { smode = dmode; while (size > 0) { - memset(datas, 0, 2352); + memset(data, 0, 2352); eating = MIN(size, (size_t) sec_sizes[smode]); - memcpy(datas, _datas, eating); + memcpy(data, _data, eating); size -= eating; - _datas += eating; + _data += eating; if ((smode == MODE2_FORM1) || (smode == MODE2_FORM2)) { if (size) { clearEOF(); @@ -520,13 +520,13 @@ int isobuilder::putdatas(Byte * _datas, size_t size, int smode, int n) { setEOF(); } } - createsector(datas, smode); + createsector(data, smode); } return dsect; } -int isobuilder::createsector(Byte * datas, int smode, int n, int FN, int CN, int SM, int CI) { +int isobuilder::createsector(Byte * data, int smode, int n, int FN, int CN, int SM, int CI) { Byte dsector[2352]; int rsector; if (n >= 0) @@ -539,7 +539,7 @@ int isobuilder::createsector(Byte * datas, int smode, int n, int FN, int CN, int w->seek(2352 * sector, SEEK_SET); - memcpy(dsector + sec_offsts[smode], datas, sec_sizes[smode]); + memcpy(dsector + sec_offsts[smode], data, sec_sizes[smode]); if ((smode == MODE2_FORM1) || (smode == MODE2_FORM2)) { // Mode 2 Form 2 would be odd, but well.... @@ -636,7 +636,7 @@ isobuilder::DirTree * isobuilder::createdir(DirTree * p, const String & _name, i r->name = _name; r->size = size * 2048; if (!r->size) - r->size = d->Size; + r->size = cdutils::from_LE32(d->Size); r->sector = lastdispsect; if (mode >= 0) r->mode = mode; @@ -678,18 +678,18 @@ isobuilder::DirTree * isobuilder::createfile(DirTree * p, Handle * file, const S } void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntry * d, int mode) { - Byte datas[2048]; + Byte data[2048]; cdutils::DirEntry * p; - int nsectors = d->Size / 2048, ssize, c = 0; + int nsectors = cdutils::from_LE32(d->Size) / 2048, ssize, c = 0; int fsize, osize; if (mode < 0) mode = dmode; while (nsectors) { - cd->read_sector(datas, mode, d->Sector + c++); + cd->read_sector(data, mode, cdutils::from_LE32(d->Sector) + c++); nsectors--; - p = (cdutils::DirEntry *) datas; + p = (cdutils::DirEntry *) data; ssize = 2048; while ((ssize) && (p->R)) { ssize -= p->R; @@ -698,11 +698,11 @@ void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntr pbuf[p->N] = 0; if (p->Flags & 2) { if (!((p->N == 1) && ((p->id[0] == 0) || (p->id[0] == 1)))) - copydir(createdir(r, "", p->Size / 2048, p, mode), cd, p, mode); + copydir(createdir(r, "", cdutils::from_LE32(p->Size) / 2048, p, mode), cd, p, mode); } else { printm(M_INFO, "Dupping %s\n", pbuf); int fmode; - osize = fsize = p->Size; + osize = fsize = cdutils::from_LE32(p->Size); if (mode == MODE1) { fmode = mode; } else { @@ -718,15 +718,15 @@ void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntr if ((s != p->R) && ((s + 14) == p->R)) { if (!(p->id[p->N + pad + 4] & 8)) { fmode = MODE2; - fsize = (p->Size / 2048) * 2336; + fsize = (cdutils::from_LE32(p->Size) / 2048) * 2336; } } } - p->Size = fsize; + p->Size = cdutils::to_BE32(fsize); cdfile * tmp = new cdfile(cd, p, fmode); createfile(r, tmp, "", p, fmode)->size = osize; delete tmp; - p->Size = osize; + p->Size = cdutils::to_BE32(osize); } p = (cdutils::DirEntry *) (((Byte *) p) + p->R); } @@ -734,15 +734,15 @@ void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntr } isobuilder::PVD isobuilder::createpvd(Handle * f) { - Byte datas[2048]; - f->read(datas, 2048); - return createpvd(datas); + Byte data[2048]; + f->read(data, 2048); + return createpvd(data); } isobuilder::PVD isobuilder::createpvd(cdutils * cd) { - Byte datas[2048]; - cd->read_sector(datas, GUESS, 16); - return createpvd(datas); + Byte data[2048]; + cd->read_sector(data, GUESS, 16); + return createpvd(data); } isobuilder::PVD isobuilder::createpvd(Byte * buffer) { @@ -797,9 +797,9 @@ isobuilder::PVD isobuilder::createpvd(Byte * buffer) { } void isobuilder::close(Handle * cue, int mode, int nsects) throw (GeneralException) { - Byte datas[2048]; - Byte * pdatas; - char * cdatas = (char *) datas; + Byte data[2048]; + Byte * pdata; + char * cdata = (char *) data; int psize; if (!root) { @@ -809,82 +809,82 @@ void isobuilder::close(Handle * cue, int mode, int nsects) throw (GeneralExcepti if (nsects < 0) nsects = nsectors; - memset(datas, 0, 2048); - - pdatas = (Byte *) malloc(ptsize * 2048); - psize = root->buildpath(pdatas, ptsize * 2048); - putdatas(pdatas, ptsize * 2048, mode, ptsect); - putdatas(pdatas, ptsize * 2048, mode, ptsect + ptsize); - root->buildpath(pdatas, ptsize * 2048, true); - putdatas(pdatas, ptsize * 2048, mode, ptsect + ptsize * 2); - putdatas(pdatas, ptsize * 2048, mode, ptsect + ptsize * 3); - free(pdatas); - - datas[0] = 1; - datas[1] = 67; - datas[2] = 68; - datas[3] = 48; - datas[4] = 48; - datas[5] = 49; - datas[6] = 1; - datas[7] = 0; - - sprintf(cdatas + 8, "%-32s", pvd.sysid.to_charp()); - sprintf(cdatas + 40, "%-32s", pvd.volid.to_charp()); - *((Uint32 *) (datas + 80)) = nsects; - *((Uint32 *) (datas + 84)) = cdutils::swap_dword(nsects); - - datas[120] = 1; - datas[121] = 0; - datas[122] = 0; - datas[123] = 1; - datas[124] = 1; - datas[125] = 0; - datas[126] = 0; - datas[127] = 1; - datas[128] = 0; - datas[129] = 8; - datas[130] = 8; - datas[131] = 0; - *((Uint32 *) (datas + 132)) = psize; - *((Uint32 *) (datas + 136)) = cdutils::swap_dword(psize); - *((Uint32 *) (datas + 140)) = ptsect; - *((Uint32 *) (datas + 144)) = ptsect + ptsize; - *((Uint32 *) (datas + 148)) = cdutils::swap_dword(ptsect + ptsize * 2); - *((Uint32 *) (datas + 152)) = cdutils::swap_dword(ptsect + ptsize * 3); - - root->buildentry(datas + 156, 34, false); - - sprintf(cdatas + 190, "%-128s", pvd.volsetid.to_charp()); - sprintf(cdatas + 318, "%-128s", pvd.pubid.to_charp()); - sprintf(cdatas + 446, "%-128s", pvd.prepid.to_charp()); - sprintf(cdatas + 574, "%-128s", pvd.appid.to_charp()); - sprintf(cdatas + 702, "%-37s", pvd.copyright.to_charp()); - sprintf(cdatas + 739, "%-37s", pvd.abstract.to_charp()); - sprintf(cdatas + 776, "%-37s", pvd.biblio.to_charp()); - - pvd.volcreat.dump(datas + 813); - pvd.modif.dump(datas + 830); - pvd.volexp.dump(datas + 847); - pvd.voleff.dump(datas + 864); - - memcpy(datas + 883, pvd.appdata, 512); + memset(data, 0, 2048); + + pdata = (Byte *) malloc(ptsize * 2048); + psize = root->buildpath(pdata, ptsize * 2048); + putdata(pdata, ptsize * 2048, mode, ptsect); + putdata(pdata, ptsize * 2048, mode, ptsect + ptsize); + root->buildpath(pdata, ptsize * 2048, true); + putdata(pdata, ptsize * 2048, mode, ptsect + ptsize * 2); + putdata(pdata, ptsize * 2048, mode, ptsect + ptsize * 3); + free(pdata); + + data[0] = 1; + data[1] = 67; + data[2] = 68; + data[3] = 48; + data[4] = 48; + data[5] = 49; + data[6] = 1; + data[7] = 0; + + sprintf(cdata + 8, "%-32s", pvd.sysid.to_charp()); + sprintf(cdata + 40, "%-32s", pvd.volid.to_charp()); + *((Uint32 *) (data + 80)) = cdutils::to_LE32(nsects); + *((Uint32 *) (data + 84)) = cdutils::to_BE32(nsects); + + data[120] = 1; + data[121] = 0; + data[122] = 0; + data[123] = 1; + data[124] = 1; + data[125] = 0; + data[126] = 0; + data[127] = 1; + data[128] = 0; + data[129] = 8; + data[130] = 8; + data[131] = 0; + *((Uint32 *) (data + 132)) = cdutils::to_LE32(psize); + *((Uint32 *) (data + 136)) = cdutils::to_BE32(psize); + *((Uint32 *) (data + 140)) = cdutils::to_LE32(ptsect); + *((Uint32 *) (data + 144)) = cdutils::to_LE32(ptsect + ptsize); + *((Uint32 *) (data + 148)) = cdutils::to_BE32(ptsect + ptsize * 2); + *((Uint32 *) (data + 152)) = cdutils::to_BE32(ptsect + ptsize * 3); + + root->buildentry(data + 156, 34, false); + + sprintf(cdata + 190, "%-128s", pvd.volsetid.to_charp()); + sprintf(cdata + 318, "%-128s", pvd.pubid.to_charp()); + sprintf(cdata + 446, "%-128s", pvd.prepid.to_charp()); + sprintf(cdata + 574, "%-128s", pvd.appid.to_charp()); + sprintf(cdata + 702, "%-37s", pvd.copyright.to_charp()); + sprintf(cdata + 739, "%-37s", pvd.abstract.to_charp()); + sprintf(cdata + 776, "%-37s", pvd.biblio.to_charp()); + + pvd.volcreat.dump(data + 813); + pvd.modif.dump(data + 830); + pvd.volexp.dump(data + 847); + pvd.voleff.dump(data + 864); + + memcpy(data + 883, pvd.appdata, 512); clearEOF(); sub_EOR = 1; - createsector(datas, mode, 16); + createsector(data, mode, 16); - memset(datas, 0, 2048); - datas[0] =255; - datas[1] = 67; - datas[2] = 68; - datas[3] = 48; - datas[4] = 48; - datas[5] = 49; - datas[6] = 1; + memset(data, 0, 2048); + data[0] =255; + data[1] = 67; + data[2] = 68; + data[3] = 48; + data[4] = 48; + data[5] = 49; + data[6] = 1; setEOF(); - createsector(datas, mode); + createsector(data, mode); root->dumpdirs(this); diff --git a/lib/luacd.cpp b/lib/luacd.cpp index 9e1e698..82c72cd 100644 --- a/lib/luacd.cpp +++ b/lib/luacd.cpp @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: luacd.cpp,v 1.18 2005-02-12 22:56:17 pixel Exp $ */ +/* $Id: luacd.cpp,v 1.19 2005-11-02 21:34:02 pixel Exp $ */ #include "luacd.h" @@ -37,10 +37,10 @@ enum cdutils_methods_t { CDUTILS_GUESSTYPE, CDUTILS_SECTORSEEK, CDUTILS_READSECTOR, - CDUTILS_READDATAS, + CDUTILS_READdata, CDUTILS_READFILE, CDUTILS_WRITESECTOR, - CDUTILS_WRITEDATAS, + CDUTILS_WRITEdata, CDUTILS_WRITEFILE, CDUTILS_GETISOINFOS, CDUTILS_GETPTINFOS, @@ -69,10 +69,10 @@ struct lua_functypes_t cdutils_methods[] = { { CDUTILS_GUESSTYPE, "guessmode", 0, 1, {LUA_NUMBER} }, { CDUTILS_SECTORSEEK, "sectorseek", 1, 1, {LUA_NUMBER} }, { CDUTILS_READSECTOR, "readsector", 0, 2, {LUA_NUMBER, LUA_NUMBER} }, - { CDUTILS_READDATAS, "readdatas", 1, 3, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, + { CDUTILS_READdata, "readdata", 1, 3, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, { CDUTILS_READFILE, "readfile", 2, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, { CDUTILS_WRITESECTOR, "writesector", 1, 3, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER} }, - { CDUTILS_WRITEDATAS, "writedatas", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, + { CDUTILS_WRITEdata, "writedata", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, { CDUTILS_WRITEFILE, "writefile", 1, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, { CDUTILS_GETISOINFOS, "getisoinfos", 0, 0, 0 }, { CDUTILS_GETPTINFOS, "getptinfos", 0, 0, 0 }, @@ -104,10 +104,10 @@ class sLua_cdutils : public Base { DECLARE_METHOD(cdutils, CDUTILS_GUESSTYPE); DECLARE_METHOD(cdutils, CDUTILS_SECTORSEEK); DECLARE_METHOD(cdutils, CDUTILS_READSECTOR); - DECLARE_METHOD(cdutils, CDUTILS_READDATAS); + DECLARE_METHOD(cdutils, CDUTILS_READdata); DECLARE_METHOD(cdutils, CDUTILS_READFILE); DECLARE_METHOD(cdutils, CDUTILS_WRITESECTOR); - DECLARE_METHOD(cdutils, CDUTILS_WRITEDATAS); + DECLARE_METHOD(cdutils, CDUTILS_WRITEdata); DECLARE_METHOD(cdutils, CDUTILS_WRITEFILE); DECLARE_METHOD(cdutils, CDUTILS_GETISOINFOS); DECLARE_METHOD(cdutils, CDUTILS_GETPTINFOS); @@ -140,10 +140,10 @@ void Luacdutils::pushmembers(Lua * L) { PUSH_METHOD(cdutils, CDUTILS_GUESSTYPE); PUSH_METHOD(cdutils, CDUTILS_SECTORSEEK); PUSH_METHOD(cdutils, CDUTILS_READSECTOR); - PUSH_METHOD(cdutils, CDUTILS_READDATAS); + PUSH_METHOD(cdutils, CDUTILS_READdata); PUSH_METHOD(cdutils, CDUTILS_READFILE); PUSH_METHOD(cdutils, CDUTILS_WRITESECTOR); - PUSH_METHOD(cdutils, CDUTILS_WRITEDATAS); + PUSH_METHOD(cdutils, CDUTILS_WRITEdata); PUSH_METHOD(cdutils, CDUTILS_WRITEFILE); PUSH_METHOD(cdutils, CDUTILS_GETISOINFOS); PUSH_METHOD(cdutils, CDUTILS_GETPTINFOS); @@ -230,7 +230,7 @@ void Luacdutils::pushstatics(Lua * L) throw (GeneralException) { int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { int r = 0, sect = -1, mode = GUESS, size = -1, i; Handle * h; - Byte sdatas[2352], * datas; + Byte sdata[2352], * data; String path; cdutils::DirEntry * dir, * bdir, * adir, pdir; bool invalid = false, eof = false; @@ -258,31 +258,31 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { sect = L->tonumber(2); if (n == 2) mode = L->tonumber(3); - size = cd->read_sector(sdatas, mode, sect); + size = cd->read_sector(sdata, mode, sect); L->newtable(); for (i = 0; i < size; i++) { L->push((lua_Number) i); - L->push((lua_Number) sdatas[i]); + L->push((lua_Number) sdata[i]); L->settable(); } r = 1; break; - case CDUTILS_READDATAS: + case CDUTILS_READdata: size = L->tonumber(2); if (n >= 2) sect = L->tonumber(3); if (n == 3) mode = L->tonumber(3); - datas = (Byte *) malloc(size); - cd->read_datas(datas, size, mode, sect); + data = (Byte *) malloc(size); + cd->read_data(data, size, mode, sect); L->newtable(); for (i = 0; i < size; i++) { L->push((lua_Number) i); - L->push((lua_Number) datas[i]); + L->push((lua_Number) data[i]); L->settable(); } r = 1; - free(datas); + free(data); break; case CDUTILS_READFILE: h = (Handle *) LuaObject::getme(L, 2); @@ -301,27 +301,27 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { for (i = 0; i < 2352; i++) { L->push((lua_Number) i); L->gettable(2); - sdatas[i] = L->tonumber(); + sdata[i] = L->tonumber(); L->pop(); } - cd->write_sector(datas, mode, sect); + cd->write_sector(data, mode, sect); break; - case CDUTILS_WRITEDATAS: + case CDUTILS_WRITEdata: size = L->tonumber(3); if (n >= 3) sect = L->tonumber(4); if (n == 4) mode = L->tonumber(5); - datas = (Byte *) malloc(size); + data = (Byte *) malloc(size); for (i = 0; i < size; i++) { L->push((lua_Number) i); L->gettable(2); - sdatas[i] = L->tonumber(); + sdata[i] = L->tonumber(); L->pop(); } - cd->write_datas(datas, size, mode, sect); - free(datas); + cd->write_data(data, size, mode, sect); + free(data); break; case CDUTILS_WRITEFILE: h = (Handle *) LuaObject::getme(L, 2); @@ -343,7 +343,7 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { break; case CDUTILS_FINDPATH: path = L->tostring(2); - bdir = cd->find_path(&datas, path); + bdir = cd->find_path(&data, path); if ((bdir) && bdir->R) { dir = (cdutils::DirEntry *) malloc(bdir->R); memcpy(dir, bdir, bdir->R); @@ -357,11 +357,11 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { L->push(); } r = 1; - free(datas); + free(data); break; case CDUTILS_FINDPARENT: path = L->tostring(2); - bdir = cd->find_parent(&datas, path); + bdir = cd->find_parent(&data, path); if ((bdir) && bdir->R) { dir = (cdutils::DirEntry *) malloc(bdir->R); memcpy(dir, bdir, bdir->R); @@ -375,12 +375,12 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { L->push(); } r = 1; - free(datas); + free(data); break; case CDUTILS_FINDDIRENTRY: adir = (cdutils::DirEntry *) LuaObject::getme(L, 2); path = L->tostring(3); - bdir = cd->find_dir_entry(&datas, adir, path); + bdir = cd->find_dir_entry(&data, adir, path); if ((bdir) && bdir->R) { dir = (cdutils::DirEntry *) malloc(bdir->R); memcpy(dir, bdir, bdir->R); @@ -394,7 +394,7 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { L->push(); } r = 1; - free(datas); + free(data); break; case CDUTILS_NEWCDFILE: if (L->istable(2)) { @@ -432,7 +432,7 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { case CDUTILS_UPDATESECTOR: path = L->tostring(2); pdir = cd->find_parent(path); - dir = cd->find_path(&datas, path); + dir = cd->find_path(&data, path); switch (caller) { case CDUTILS_UPDATESIZE: dir->Size = tolittle((Uint32) L->tonumber(3)); @@ -443,8 +443,8 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { dir->BESector = tobig((Uint32) L->tonumber(3)); break; } - cd->write_datas(datas, pdir.Size, GUESS, pdir.Sector); - free(datas); + cd->write_data(data, pdir.Size, GUESS, pdir.Sector); + free(data); break; case CDUTILS_CREATESECTOR: mode = L->tonumber(2); @@ -1343,7 +1343,7 @@ enum isobuilder_methods_t { ISOBUILDER_FOREWORD_ARRAY, ISOBUILDER_GETDISPSECT, ISOBUILDER_PUTFILE, - ISOBUILDER_PUTDATAS, + ISOBUILDER_PUTdata, ISOBUILDER_CREATESECTOR, ISOBUILDER_SETEOF, ISOBUILDER_CLEAREOF, @@ -1367,7 +1367,7 @@ struct lua_functypes_t isobuilder_methods[] = { { ISOBUILDER_FOREWORD_ARRAY, "foreword_array", 1, 2, {LUA_TABLE, LUA_NUMBER} }, { ISOBUILDER_GETDISPSECT, "getdispsect", 0, 0, 0}, { ISOBUILDER_PUTFILE, "putfile", 1, 3, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER} }, - { ISOBUILDER_PUTDATAS, "putdatas", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, + { ISOBUILDER_PUTdata, "putdata", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, { ISOBUILDER_CREATESECTOR, "createsector", 1, 7, {LUA_TABLE | LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, { ISOBUILDER_SETEOF, "setEOF", 0, 0, 0 }, { ISOBUILDER_CLEAREOF, "clearEOF", 0, 0, 0 }, @@ -1394,7 +1394,7 @@ class sLua_isobuilder : public Base { DECLARE_METHOD(isobuilder, ISOBUILDER_FOREWORD_ARRAY); DECLARE_METHOD(isobuilder, ISOBUILDER_GETDISPSECT); DECLARE_METHOD(isobuilder, ISOBUILDER_PUTFILE); - DECLARE_METHOD(isobuilder, ISOBUILDER_PUTDATAS); + DECLARE_METHOD(isobuilder, ISOBUILDER_PUTdata); DECLARE_METHOD(isobuilder, ISOBUILDER_CREATESECTOR); DECLARE_METHOD(isobuilder, ISOBUILDER_SETEOF); DECLARE_METHOD(isobuilder, ISOBUILDER_CLEAREOF); @@ -1422,7 +1422,7 @@ void Luaisobuilder::pushmembers(Lua * L) { PUSH_METHOD(isobuilder, ISOBUILDER_FOREWORD_ARRAY); PUSH_METHOD(isobuilder, ISOBUILDER_GETDISPSECT); PUSH_METHOD(isobuilder, ISOBUILDER_PUTFILE); - PUSH_METHOD(isobuilder, ISOBUILDER_PUTDATAS); + PUSH_METHOD(isobuilder, ISOBUILDER_PUTdata); PUSH_METHOD(isobuilder, ISOBUILDER_CREATESECTOR); PUSH_METHOD(isobuilder, ISOBUILDER_SETEOF); PUSH_METHOD(isobuilder, ISOBUILDER_CLEAREOF); @@ -1449,7 +1449,7 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca int mode = -1, sector = -1, rootsize = 1, ptsize = 1, nvd = 1, rootsect = -1, nsects = -1; int FN = -1, CN = -1, SM = -1, CI = -1; size_t size; - Byte datas[2352 * 16], * p; + Byte data[2352 * 16], * p; PVD * pvd; DirTree * dirt, * rdir; direntry * dire = 0; @@ -1475,10 +1475,10 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca for (i = 0; i < 16 * 2352; i++) { L->push((lua_Number) i); L->gettable(2); - datas[i] = L->tonumber(); + data[i] = L->tonumber(); L->pop(); } - iso->foreword(datas, mode); + iso->foreword(data, mode); break; case ISOBUILDER_GETDISPSECT: L->push((lua_Number) iso->getdispsect()); @@ -1493,7 +1493,7 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca L->push((lua_Number) iso->putfile(h, mode, sector)); r = 1; break; - case ISOBUILDER_PUTDATAS: + case ISOBUILDER_PUTdata: size = L->tonumber(3); if (n >= 3) mode = L->tonumber(4); @@ -1506,7 +1506,7 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca p[i] = L->tonumber(); L->pop(); } - L->push((lua_Number) iso->putdatas(p, size, mode, sector)); + L->push((lua_Number) iso->putdata(p, size, mode, sector)); r = 1; free(p); break; @@ -1530,10 +1530,10 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca for (i = 0; i < 2352; i++) { L->push((lua_Number) i); L->gettable(2); - datas[i] = L->tonumber(); + data[i] = L->tonumber(); L->pop(); } - L->push((lua_Number) iso->createsector(datas, mode, sector, FN, CN, SM, CI)); + L->push((lua_Number) iso->createsector(data, mode, sector, FN, CN, SM, CI)); } r = 1; break; @@ -1620,7 +1620,7 @@ int sLua_isobuilder::isobuilder_proceed_statics(Lua * L, int n, int caller) { Handle * h; int mode = MODE2_FORM1; cdutils * cd; - Byte datas[2048]; + Byte data[2048]; PVD * pvd; switch (caller) { @@ -1658,11 +1658,11 @@ int sLua_isobuilder::isobuilder_proceed_statics(Lua * L, int n, int caller) { for (i = 0; i < 2048; i++) { L->push((lua_Number) i); L->gettable(1); - datas[i] = L->tonumber(); + data[i] = L->tonumber(); L->pop(); } pvd = (PVD *) malloc(sizeof(PVD)); - *pvd = isobuilder::createpvd(datas); + *pvd = isobuilder::createpvd(data); { LuaPVD t(pvd); t.pushdestruct(L); |