fileutil::magic::rt - Runtime core for file type recognition engines written in pure Tcl
This package provides the runtime core for file type recognition engines written in pure Tcl and is thus used by all other packages in this module such as fileutil::magic::filetype and the two compiler packages fileutil::magic::cgen and fileutil::magic::cfront.
Increment the level and perform related housekeeping
Decrement the level and perform related housekeeping
Create a new command which returns one description of the file each time it is called, and a code of break when there are no more descriptions. chan is the channel containing the data to describe. The channel configuration is then managed as needed. named is a dictionary of named tests, as generated by fileutil::magic::cfront::compile. test is a command prefix for a routine composed of the list of commands as returned by fileutil::magic::cfront::compile.
This command marks the start of a magic file when debugging. It returns the empty string as its result.
This command adds the text msg to the result buffer. The message may contain the following special character sequences. They will be replaced with buffered values before the message is added to the result. The command returns the empty string as its result.
This sequence is removed
Replaced with the last buffered string value.
Replaced with the last buffered numeric value.
See above.
Substitute one string if the file is executable, and another string otherwise.
Produce an offset from where, relative to the cursor one level up. Produce an offset from where, relative to the offset one level up.
A limited form of ::fileutile::magic::rt::N that only checks for equality and can't be told to invert the test.
Fetch the numeric value with type from the absolute location offset, compare it with expected using comp as the comparision operator, and returns the result.
The argument comp must be one of Tcl's comparison operators.
<comp> <fetched-and-masked-value> <comp> <expected>
The special comparison operator x signals that no comparison should be done, or, in other words, that the fetched value will always match val.
Like ::fileutil::magic::rt::N except that it fetches and compares string types , not numeric data.
Sets the current level in the calling context to newlevel. The command returns the empty string as its result.
Calculates an offset based on an initial offset and the provided modifiers.
Given an initial offset, calculates an offset relative to the cursor at the next level up. The cursor is the position in the data one character after the data extracted from the file one level up.
Add a level and use a named test script.
8-bit integer
16-bit integer, stored in native endianess
see above, stored in big endian
see above, stored in small/little endian
32-bit integer, stored in native endianess
see above, stored in big endian
see above, stored in small/little endian
All of the types above exit in an unsigned form as well. The type names are the same, with the character "u" added as prefix.
32-bit integer timestamp, stored in native endianess
see above, stored in big endian
see above, stored in small/little endian
32-bit integer timestamp, stored in native endianess
see above, stored in big endian
see above, stored in small/little endian
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category fileutil :: magic of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
Programming tools