arc.c: Rearranged some functions
[deark.git] / readme.md
blobedcf4bb24088b59ee0be6cd108e169bc46b92890
1 # Deark #
3 Deark is a command-line utility that can decode certain types of files, and
4 either:
6 1. convert them to a more-modern or more-readable format; or
7 2. extract embedded files from them
9 The files it writes are usually named "output.*".
11 This program is still being developed, and its features are subject to change
12 without notice.
14 For additional information, see the [technical.md](technical.md) file.
16 ## Usage ##
18     deark [options] [-file] <input-file> [options]
19     deark <-h|-version|-modules>
21 Command-line options:
22 <pre>
23 -m &lt;module>
24    The "module" to use to process the input file. The default is to autodetect.
25    A module may represent one file format, or a group of related formats, or
26    may have some special purpose.
27    See formats.txt for a list of modules. You usually don't need to use -m,
28    unless the format can't be detected, or you want to use a special-purpose
29    module such as "copy". See also the -onlydetect option.
31    Don't extract, but list the files that would be extracted.
32    This option is not necessarily very efficient. Deark will still go through
33    all the motions of extracting the files, but will not actually write them.
34 -main
35    Extract only "primary" files (e.g. not thumbnail images).
36 -aux
37    Extract only "auxiliary" files, such as thumbnail images.
38 -a, -extractall
39    Extract more data than usual, including things that are rarely of interest,
40    such as comments. See also the "-opt extract..." options, and the format-
41    specific options in technical.md.
42 -o &lt;name>
43    Output filenames begin with this string. This can include a directory
44    path. Default is "output", except in some cases when using -zip/-tar.
45 -t &lt;name>
46    Use exactly this filename for the first (and presumably only) output file.
47    The "-maxfiles 1" option is enabled automatically. Including the -main
48    option is suggested.
49 -k, -k2, -k3
50    "Keep" the input filename, and use it as the initial part of the output
51    filename(s). Incompatible with -o.
52    -k: Use only the base filename.
53    -k2: Use the full path, but not as an actual path.
54    -k3: Use the full path, as-is.
55 -od &lt;directory>
56    The directory in which to write output files. The directory must exist.
57    This affects only files that Deark writes directly, not e.g. the names of
58    ZIP member files when using -zip.
60    Do not overwrite existing output files.
61 -file &lt;input-file>
62    This is an alternate syntax for specifying the primary input file. It works
63    even if the filename begins with "-".
64 -file2 &lt;file>
65    Some formats are composed of more than one file. In some cases, you can
66    use the -file2 option to specify the secondary file. Refer to the
67    formats.txt file for details.
68 -zip
69    Write output files to a .zip file, instead of to individual files.
70    If the input format is an "archive" format (e.g. "ar" or "zoo"), then
71    by default, the filenames in the ZIP archive might not include the usual
72    "output.NNN" prefix.
73 -tar
74    Write output files to a .tar file, instead of to individual files.
75    Similar to -zip, but may work better with large files.
76    The -tostdout option is not currently supported when using -tar.
77 -ta &lt;filename> (alias: -arcfn)
78    When using -zip/-tar, use this name for the output file. Default is
79    "output.zip" or "output.tar".
80 -ka, -ka2, -ka3
81    When uzing -zip/-tar, "keep" the input filename, and use it as the initial
82    part of the archive output filename. A suitable filename extenson like
83    ".zip" will be appended. Incompatible with -arcfn.
84    -ka: Use only the base filename.
85    -ka2: Use the full path, but not as an actual path.
86    -ka3: Use the full path, as-is.
87 -extrlist &lt;filename>
88    Also create a text file containing a list of the names of the extracted
89    files. Format is UTF-8, no BOM, LF terminators. To append to the file
90    instead of overwriting, use with "-opt extrlist:append".
91 -tostdout
92    Write the output file(s) to the standard output stream (stdout).
93    It is recommended to put -tostdout early on the command line. The
94    -msgstostderr option is enabled automatically.
95    If used with -zip: Write the ZIP file to standard output.
96    Otherwise: The "-maxfiles 1" option is enabled automatically. Including the
97    -main option is recommended.
98 -fromstdin
99    Read the input file from the standard input stream (stdin).
100    If you use -fromstdin, supplying an input filename is optional. If it is
101    supplied, the file will not be read (and need not exist), but the name
102    might be used to help guess the file format.
103    This option might not be very efficient, and might not work with extremely
104    large files.
105 -start &lt;n>
106    Pretend that the input file starts at byte offset &lt;n>.
107 -size &lt;n>
108    Pretend that the input file contains only (up to) &lt;n> bytes.
109 -firstfile &lt;n>
110    Don't extract the first &lt;n> files found.
111 -maxfiles &lt;n>
112    Extract at most &lt;n> files. The normal default is 1000, or effectively
113    unlimited if using -zip.
114 -get &lt;n>
115    Extract only the file identifed by &lt;n>. The first file is 0.
116    Equivalent to "-firstfile &lt;n> -maxfiles 1".
117    To unconditionally show the file identifiers, use "-l -opt list:fileid".
118 -maxfilesize &lt;n>
119    Do not write a file larger than &lt;n> bytes. The default is 10 GiB.
120    This is an "emergency brake". If the limit is exceeded, Deark will stop all
121    processing.
122    This setting is for physical output files, so if you use -zip/-tar, it
123    applies to the ZIP/tar file, not to the individual member files.
124    This option implicitly increases the -maxtotalsize setting to be at least
125    &lt;n>.
126 -maxtotalsize &lt;n>
127    Do not write files totaling more than about &lt;n> bytes. The default is
128    15 GiB.
129    Currently, this feature is not implemented very precisely. The limit is only
130    checked when an output file is completed.
131 -maxdim &lt;n>
132    Allow image dimensions up to &lt;n> pixels.
133    By default, Deark refuses to generate images with a dimension larger than
134    10000 pixels. You can use -maxdim to decrease or increase the limit.
135    Increase the limit at your own risk. Deark does not generate large images
136    efficiently. In practice, a large dimension will only work if the other
137    dimension is very small.
138 -padpix
139    Include "padding" pixels/bits in the image output.
140    Some images have extra bits at the end of each row that are used for
141    alignment, and are not normally made visible.
142    This option is not implemented for all formats.
143 -nobom
144    Do not add a BOM to UTF-8 output files generated or converted by Deark. Note
145    that if a BOM already exists in the source data, it will not necessarily be
146    removed.
147 -nodens
148    Do not try to record the original aspect ratio and pixel density in output
149    image files.
150 -asciihtml
151    When generating an HTML document, use ASCII encoding instead of UTF-8. This
152    does not change how a browser will render the file; it just makes it larger
153    and very slightly more portable.
154 -nonames
155    Make Deark less likely to try to improve output filenames by using names
156    from the contents of the input file. The output filenames will be more
157    predictable, but less informative.
158 -nomodtime
159    In some cases, mainly when reading archive formats, a last-modified
160    timestamp contained in an input file will be used to set the timestamp of an
161    output file written directly to your computer (or with -zip/-tar, of a
162    member file inside that file). Use -nomodtime to disable this.
163    This does not affect internal timestamps that may be maintained when Deark
164    converts an item to some other format (such as PNG or HTML).
165 -opt &lt;module:option>=&lt;value>
166    Module-specific and feature-specific options. See formats.txt.
167    Caution: Unrecognized or misspelled options will be silently ignored.
168    Options not specific to one format:
169     -opt font:charsperrow=&lt;n>
170        The number of characters per row, when rendering a font to a bitmap
171     -opt font:tounicode=&lt;0|1>
172        [Don't] Try to translate a font's codepoints to Unicode codepoints.
173     -opt char:output=&lt;html|image>
174        The output format for character graphics (such as ANSI Art).
175     -opt char:charwidth=&lt;8|9>
176        The VGA character cell width for character graphics, when the output
177        format is "image".
178     -opt archive:subdirs=0
179        When using -zip/-tar, disallow subdirectories (the "/" character) in
180        member filenames.
181     -opt archive:zipcmprlevel=&lt;n>
182        When using -zip, the compression level to use, from 0 (none) to 9 (max).
183     -opt pngcmprlevel=&lt;n>
184        When generating a PNG file, the compression level to use, from 0 (low)
185        to 10 (max).
186     -opt archive:timestamp=&lt;n>
187     -opt archive:repro
188        Make the -zip/-tar output reproducible, by not including modification
189        times that are not contained in the source file. (That is, don't use the
190        current time, or the source file's timestamp.) If you use "repro", the
191        times will be set to some arbitrary value. If you use "timestamp", the
192        times will be set to the value you supply, in Unix time format (the
193        number of seconds since the beginning of 1970).
194     -opt keepdirentries=&lt;0|1>
195        Select whether an archive file's directory entries are ignored (0), or
196        "extracted" (1). For details, see the technical.md file.
197     -opt list:fileid=&lt;0|1>
198        Select whether the -l (list) option also prints the numeric file
199        identifiers.
200     -opt extrlist:append
201        Affects the -extrlist option.
202     -opt extractexif[=0]
203     -opt extract8bim
204     -opt extractiptc[=0]
205     -opt extractplist
206        Extract the specified type of data to a file, instead of decoding it.
207        For more about the ".8bimtiff" and ".iptctiff" formats, see the
208        technical.md file.
209     -opt atari:palbits=&lt;9|12|15>
210        For some Atari image formats, the number of significant bits per
211        palette color. The default is to autodetect.
212     -opt macrsrc=&lt;raw|as|ad|mbin>
213        The preferred way to extract Macintosh resource forks, and data files
214        associated with a non-empty resource fork.
215         raw = Write the raw resource fork to a separate .rsrc file.
216         ad = Put the resource fork in an AppleDouble container (default).
217         as = Put both forks in an AppleSingle container.
218         mbin = Put both forks in a MacBinary container.
219        For input files already in AppleDouble or AppleSingle format, see the
220        formats.txt file for more information.
221     -opt deflatecodec=native
222        Use Deark's native "Deflate" decompressor when possible, instead of
223        miniz. It is experimental and much slower, but could be useful for
224        debugging and educational purposes.
226    Stop after the format identification phase. This can be used to show what
227    module Deark will run, without actually running it.
228 -h, -?, -help:
229    Print the help message.
230    Use with -m to get help for a specific module. Use with a filename to get
231    help for the detected format of that file. Note that most modules have no
232    module-specific help to speak of.
233 -version
234    Print the version number, and other version information.
235 -modules
236    Print the names of the available modules.
237    With -a, list all modules, including internal modules, and modules that
238    don't work.
239 -noinfo
240    Suppress informational messages.
241 -nowarn
242    Suppress warning messages.
244    Suppress informational and warning messages.
245 -d, -d2, -d3, -d4
246    Print technical information about the contents of the file. -d2 is more
247    verbose. -d3 are -d4 are mainly for debugging.
248 -dprefix &lt;msg>
249    Start each line printed by -d with this prefix. Default is "DEBUG: ".
250 -colormode &lt;none|auto|ansi|ansi24|winconsole>
251    Control whether Deark uses color and similar features in its debug output.
252    Currently, this is mainly used to highlight unprintable characters, and
253    preview color palettes (usually requires -d2).
254    none: No color (default).
255    ansi: Use ANSI codes, but not the less-standard ones for 24-bit color.
256    ansi24: Use ANSI codes, including codes for 24-bit color. Works on most
257      Linux terminals, and on sufficiently new versions of Windows 10.
258    winconsole: Use Windows console commands. Works on all versions of Windows,
259      but does not support 24-bit color.
260    auto: Request color. Let Deark decide how to do it.
261 -color
262    Same as "-colormode auto".
263 -enc &lt;ascii|oem>
264    Set the encoding of the messages that are printed to the console. This does
265    not affect the extracted data files.
266    The default is to use Unicode (UTF-8, when the encoding is relevant).
267    ascii: Use ASCII characters only.
268    oem: [Windows only; has no effect on other platforms] Use the "OEM"
269      character set. This may be useful when paging the output with "|more".
270 -nochcp
271    [Windows only] Never change the console OEM code page (to UTF-8).
272    For technical reasons, Deark sometimes changes the code page of the Windows
273    console it is running in, when its output is going to a pipe or file.
274 -inenc &lt;ascii|utf8|latin1|latin2|cp437|windows874|windows1250|windows1251|
275      windows1252|windows1253|windows1254|macroman|palm|riscos|atarist>
276    Supply a hint as to the encoding of the text contained in the input file.
277    This option is not supported by all formats, and may be ignored if the
278    encoding can be reliably determined by other means. Admittedly, it would be
279    nice if Deark knew more encodings than this.
280 -intz &lt;offset>
281    Supply a hint as to the time zone used by timestamps contained in the input
282    file.
283    Many file formats unfortunately contain timestamps in "local time", with no
284    information about their time zone. In such cases, the supplied -intz offset
285    will be used to convert the timestamp to UTC.
286    The "offset" parameter is in hours east of UTC. For example, New York City
287    is -5.0, or -4.0 when Daylight Saving Time is in effect.
288    This option does not respect Daylight Saving Time. It cannot deal with the
289    case where some of the timestamps in a file are in DST, and others are not.
290 -msgstostderr
291    Print all messages to stderr, instead of stdout. This option should be
292    placed early on the command line, as it might not affect messages
293    related to options that appear before it.
294 -nodetect &lt;module1,module2,...>
295 -onlydetect &lt;module1,module2,...>
296    Disable autodetection of the formats in the list (or for -onlydetect, the
297    formats *not* in the list).
298 -disablemods &lt;module1,module2,...>
299 -onlymods &lt;module1,module2,...>
300    Completely disable the main functionality, and the autodetection
301    functionality, of the modules in the list (or for -onlymods, the modules
302    *not* in the list). This can have unexpected side effects, because modules
303    often use other modules internally. These options exist mainly to help
304    address potential security-related concerns in some workflows.
305 -modcodes &lt;codes>
306    Run the module in a non-default "mode".
307    The existence of this option (though not its details) is documented in the
308    interest of transparency, but it is mainly for developers, and to make it
309    possible to do things whose usefulness was not anticipated.
310 </pre>
312 ## Exit status ##
314 Deark sets the exit status to nonzero only if it wasn't able to do its job,
315 e.g. due to a read or write failure. A malformed input file usually does not
316 cause such an error, and the exit status will be zero even if an error message
317 was printed.
319 However, all fatal errors result in a nonzero exit status, and in extreme cases
320 it is possible for the input file to cause a fatal error, due to certain
321 resource limits being exceeded.
323 ## Terms of use ##
325 Starting with version 1.4.x, Deark is distributed under an MIT-style license.
326 See the [COPYING](COPYING) file for the license text.
328 The main Deark license does not necessarily apply to the code in the "foreign"
329 subdirectory. Each file there may have its own licensing terms. In particular:
331 uncompface.h: Copyright (c) James Ashton - Sydney University - June 1990
332 (See the file foreign/readme-compface.txt for details.)
334 By necessity, Deark contains knowledge about how to decode various
335 third-party file formats. This knowledge includes data structures,
336 algorithms, tables, color palettes, etc. The author(s) of Deark make no
337 intellectual property claims to this essential knowledge, but they cannot
338 guarantee that no one else will attempt to do so.
340 Deark contains VGA and CGA bitmapped fonts, which have no known copyright
341 claims.
343 Be particularly wary of relying on Deark to decode archive and compression
344 formats (tar, ar, gzip, cpio, ...). For example, to decode tar format, you
345 really should use a battle-hardened application like GNU Tar, not Deark.
346 Deark's support for such formats is often incomplete, and it does not always
347 do integrity checking.
349 ## Feedback and contributions ##
351 (As of 2020-09.) Suggestions and bug reports are welcome. This can be done by
352 opening a GitHub issue, or by email. If you prefer to do it in the form of a
353 GitHub "pull request", that's fine too, but as a general rule, such requests
354 won't be merged directly.
356 Deark is not really a collaborative project at this time. Unsolicited
357 contributions of more than a few lines of code are unlikely to be accepted.
358 It's okay to offer them, but please don't do a lot of work with the
359 expectation that it will be accepted.
361 Any code copyrighted by someone other than the main Deark developer(s) is only
362 allowed in the "foreign" section of the project. Pointers to existing open
363 source format decoders, that might be useful in Deark, are welcome. However,
364 most such code will be rejected for one reason or another (incompatible
365 license, too large, too trivial, etc.).
367 ## How to build ##
369 See the [technical.md](technical.md) file.
371 ## Acknowledgements ##
373 Thanks to Rich Geldreich for the miniz library.
375 Thanks to the author of dskdcmps for the code used to decompress LoadDskF
376 files.
378 Thanks to James Ashton for much of the code used by the X-Face format decoder.
380 Thanks to Haruyasu Yoshizaki and Haruhiko Okumura for the lzhuf.c decompressor.
382 Thanks to countless others who have documented the supported file formats.
384 ## Authors ##
386 Written by Jason Summers, 2014-2021.<br>
387 Copyright &copy; 2016-2021 Jason Summers<br>
388 [https://entropymine.com/deark/](https://entropymine.com/deark/)<br>
389 [https://github.com/jsummers/deark](https://github.com/jsummers/deark)