diff options
author | pixel <pixel> | 2004-05-02 00:41:38 +0000 |
---|---|---|
committer | pixel <pixel> | 2004-05-02 00:41:38 +0000 |
commit | aedffa791e2c28eccf2534eba50b82c3b38fba8b (patch) | |
tree | 96a84ea13aa84778345f52e86ffde4dbb95f836a | |
parent | d834a8d9332f18642c5511cdd56085e366635a61 (diff) |
Final features in cd-tool.
-rw-r--r-- | cd-tool.cpp | 21 | ||||
-rw-r--r-- | cd-tool.lua | 194 | ||||
-rw-r--r-- | lib/luacd.cpp | 4 |
3 files changed, 203 insertions, 16 deletions
diff --git a/cd-tool.cpp b/cd-tool.cpp index efb7bfd..8b4102c 100644 --- a/cd-tool.cpp +++ b/cd-tool.cpp @@ -17,7 +17,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: cd-tool.cpp,v 1.26 2004-05-01 11:48:57 pixel Exp $ */ +/* $Id: cd-tool.cpp,v 1.27 2004-05-02 00:41:38 pixel Exp $ */ + +#define VERSION "0.5" #include <getopt.h> #include "Input.h" @@ -118,8 +120,8 @@ enum cdtool_functions_t { }; struct lua_functypes_t cdtool_functions[] = { - { CDTOOL_PRINT, "print", 0, 1, { LUA_STRING } }, - { CDTOOL_PRINTN, "printn", 1, 1, { LUA_STRING } }, + { CDTOOL_PRINT, "print", 0, 1, { LUA_ANY } }, + { CDTOOL_PRINTN, "printn", 1, 1, { LUA_ANY } }, { CDTOOL_QUIT, "quit", 0, 0, 0 }, { CDTOOL_EXIT, "exit", 0, 0, 0 }, { CDTOOL_INFOS, "infos", 0, 1, { LUA_OBJECT } }, @@ -268,6 +270,13 @@ Lua * start_full_lua(void) { return L; } +void showbanner() { + printm(M_BARE, +"CD-Tool version " VERSION " (c) 2003-2004 Nicolas \"Pixel\" Noble\n" +"This is free software with ABSOLUTELY NO WARRANTY.\n" +"\n"); +} + void showhelp(bool longhelp = false) { printm(M_BARE, "Usage:\n" @@ -284,7 +293,7 @@ void showhelp(bool longhelp = false) { " -i to start interactive mode.\n" " -l to turn off the exec on end line.\n" " -e <cmd> to execute this single command in LUA.\n" -" -h for this help page.\n" +" -h for a help page.\n" , argv[0]); if (longhelp) @@ -333,6 +342,8 @@ virtual int startup() throw (GeneralException) { int pos; verbosity = M_STATUS; + + showbanner(); /* Let's start parsing options */ @@ -341,7 +352,7 @@ virtual int startup() throw (GeneralException) { case 'h': case 'H': case '?': - showhelp(); + showhelp(true); throw Exit(0); case 'v': verbosity = M_INFO; diff --git a/cd-tool.lua b/cd-tool.lua index f935ab0..4e0f0d0 100644 --- a/cd-tool.lua +++ b/cd-tool.lua @@ -1,3 +1,7 @@ + ------------------
+-- misc functions --
+ ------------------
+
function display(inp)
if (type(inp) == "string") then
inp = Input(inp)
@@ -82,6 +86,11 @@ function hexdump(inp, from, to, width) print(outstring)
end
+
+ --------------------------
+-- cdutil object wrappers --
+ --------------------------
+
function cdfile(arg1, arg2, arg3, arg4)
local cdutil_implied = false
@@ -169,12 +178,179 @@ function writesector(array, sector, mode) end end --- { 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_WRITEFILE, "writefile", 1, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, --- { CDUTILS_GETISOINFOS, "getisoinfos", 0, 0, 0 }, --- { CDUTILS_GETPTINFOS, "getptinfos", 0, 0, 0 }, --- { CDUTILS_FINDPATH, "findpath", 1, 1, {LUA_STRING} }, --- { CDUTILS_FINDPARENT, "findparent", 1, 1, {LUA_STRING} }, --- { CDUTILS_FINDDIRENTRY, "finddirentry", 2, 2, {LUA_OBJECT, LUA_STRING} }, --- { CDUTILS_NEWCDFILE, "cdfile", 1, 3, {LUA_ANY, LUA_NUMBER, LUA_NUMBER} }, +function writedatas(array, size, sector, mode) + if (cdutil == nil) then error "cdutil object non existant" end + if (sector == nil) then + return cdutil:writedatas(array, size) + elseif (mode == nil) then + return cdutil:writedatas(array, size, sector) + else + return cdutil:writedatas(array, size, sector, mode) + end +end + +function writefile(handle, size, sector, mode) + if (cdutil == nil) then error "cdutil object non existant" end + if (size == nil) then + return cdutil:writefile(handle) + elseif (sector == nil) then + return cdutil:writefile(handle, size) + elseif (mode == nil) then + return cdutil:writefile(handle, size, sector) + else + return cdutil:writefile(handle, size, sector, mode) + end +end + +function findpath(path) + if (cdutil == nil) then error "cdutil object non existant" end + return cdutil:findpath(path) +end + +function findparent(path) + if (cdutil == nil) then error "cdutil object non existant" end + return cdutil:findparent(path) +end + +function finddirectory(dir, path) + if (cdutil == nil) then error "cdutil object non existant" end + return cdutil:finddirectory(dir, path) +end +
+
+ -----------------------
+-- iso object wrappers --
+ -----------------------
+
+function foreword(lcdutil)
+ if (iso == nil) then error "iso object non existant" end
+ if ((lcdutil == nil) and (cdutil == nil)) then error "cdutil object non existant" end
+ if (lcdutil == nil) then
+ return iso:foreword(cdutil)
+ else
+ return iso:foreword(lcdutil)
+ end
+end
+
+function foreword_handle(handle, mode)
+ if (iso == nil) then error "iso object non existant" end
+ if (mode == nil) then
+ return iso:foreword_handle(handle)
+ else
+ return iso:foreword_handle(handle, mode)
+ end
+end
+
+function foreword_array(array, mode)
+ if (iso == nil) then error "iso object non existant" end
+ if (mode == nil) then
+ return iso:foreword_array(array)
+ else
+ return iso:foreword_array(array, mode)
+ end
+end
+
+function getdispsect()
+ if (iso == nil) then error "iso object non existant" end
+ return iso:getdispsect()
+end
+
+function putfile(handle, mode, sector)
+ if (iso == nil) then error "iso object non existant" end
+ if (mode == nil) then
+ iso:putfile(handle)
+ elseif (sector == nil) then
+ iso:putfile(handle, mode)
+ else
+ iso:putfile(handle, mode, sector)
+ end
+end
+ +function putdatas(array, size, mode, sector) + if (iso == nil) then error "iso object non existant" end
+ if (mode == nil) then + iso:putdatas(array, size) + elseif (sector == nil) then + iso:putdatas(array, size, mode) + else + iso:putdatas(array, size, mode, sector) + end +end + +function createsector(array, mode, sector) + if (iso == nil) then error "iso object non existant" end
+ if (mode == nil) then + iso:createsector(array) + elseif (sector == nil) then + iso:createsector(array, mode) + else + iso:createsector(array, mode, sector) + end +end + +function setEOF() + if (iso == nil) then error "iso object non existant" end
+ iso:setEOF()
+end
+
+function clearEOF()
+ if (iso == nil) then error "iso object non existant" end
+ iso:clearEOF()
+end
+ +function setbasics(pvd, rootsize, ptsize, nvd, rootsect) + if (iso == nil) then error "iso object non existant" end
+ if (rootsize == nil) then
+ iso:setbasics(pvd)
+ elseif (ptsize == nil) then
+ iso:setbasics(pvd, rootsize)
+ elseif (nvd == nil) then
+ iso:setbasics(pvd, rootsize, ptsize)
+ elseif (rootsect) then
+ iso:setbasics(pvd, rootsize, ptsize, nvd)
+ else
+ iso:setbasics(pvd, rootsize, ptsize, nvd, rootsect)
+ end
+end
+ +function createdir(dirtree, name, size, direntry, mode) + if (iso == nil) then error "iso object non existant" end
+ if (size == nil) then
+ iso:createdir(dirtree, name)
+ elseif (mode == nil) then
+ iso:createdir(dirtree, name, size, direntry)
+ else
+ iso:createdir(dirtree, name, size, direntry, mode)
+ end
+end
+ +function createfile(dirtree, name, size, direntry, mode) + if (iso == nil) then error "iso object non existant" end
+ if (mode == nil) then + iso:createfile(dirtree, name, size, direntry) + else + iso:createfile(dirtree, name, size, direntry, mode) + end +end + +function copydir(dirtree, cdutils, direntry, mode) + if (iso == nil) then error "iso object non existant" end
+ if (mode == nil) then + iso:copydir(dirtree, cdutils, direntry) + else + iso:copydir(dirtree, cdutils, direntry, mode) + end +end + +function close(cuefile, mode, nsectors) + if (iso == nil) then error "iso object non existant" end
+ if (cuefile == nil) then
+ iso:close()
+ elseif (mode == nil) then
+ iso:close(cuefile)
+ elseif (nsectors == nil) then
+ iso:close(cuefile, mode)
+ else
+ iso:close(cuefile, mode, nsectors)
+ end
+end
diff --git a/lib/luacd.cpp b/lib/luacd.cpp index 1f3b9fe..453e980 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.10 2004-05-01 11:48:58 pixel Exp $ */ +/* $Id: luacd.cpp,v 1.11 2004-05-02 00:41:39 pixel Exp $ */ #include "luacd.h" @@ -1313,7 +1313,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_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, + { ISOBUILDER_PUTDATAS, "putdatas", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, { ISOBUILDER_CREATESECTOR, "createsector", 1, 3, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER} }, { ISOBUILDER_SETEOF, "setEOF", 0, 0, 0 }, { ISOBUILDER_CLEAREOF, "clearEOF", 0, 0, 0 }, |