1 -- The getopt-functionality is loaded from pm3/getopt.lua
2 -- Have a look there for further details
3 getopt = require('getopt')
5 dumplib = require('html_dumplib')
7 example = "script run htmldump -o mifarecard_foo.html"
8 author = "Martin Holst Swende"
9 usage = "script run htmldump [-i <file>] [-o <file>]"
11 This script takes a dumpfile and produces a html based dump, which is a
12 bit more easily analyzed.
16 -i <file> Specifies the dump-file (input). If omitted, 'dumpdata.bin' is used
17 -o <filename> Speciies the output file. If omitted, <curtime>.html is used.
21 -------------------------------
23 -------------------------------
26 -- A debug printout-function
33 -- This is only meant to be used when errors occur
41 print("Example usage")
45 local function main(args)
47 local input = "dumpdata.bin"
48 local output = os.date("%Y-%m-%d_%H%M%S.html");
49 for o, a in getopt.getopt(args, 'i:o:h') do
50 if o == "h" then return help() end
51 if o == "i" then input = a end
52 if o == "o" then output = a end
54 local filename, err = dumplib.convert_bin_to_html(input,output,16)
55 if err then return oops(err) end
57 print(("Wrote a HTML dump to the file %s"):format(filename))
61 In the future, we may implement so that scripts are invoked directly
62 into a 'main' function, instead of being executed blindly. For future
63 compatibility, I have done so, but I invoke my main from here.