1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
[vset VERSION 2.0]
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin fileutil::magic::rt n [vset VERSION]]
[see_also file(1)]
[see_also fileutil]
[see_also magic(5)]
[keywords {file recognition}]
[keywords {file type}]
[keywords {file utilities}]
[keywords mime]
[keywords type]
[moddesc {file utilities}]
[titledesc {Runtime core for file type recognition engines written in pure Tcl}]
[category {Programming tools}]
[require Tcl 8.5]
[require fileutil::magic::rt [opt [vset VERSION]]]
[description]
[para]
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 [package fileutil::magic::filetype] and the two compiler
packages [package fileutil::magic::cgen] and
[package fileutil::magic::cfront].
[section COMMANDS]
[list_begin definitions]
[call [cmd ::fileutil::magic::rt::>]]
Increment the level and perform related housekeeping
[call [cmd ::fileutil::magic::rt::<]]
Decrement the level and perform related housekeeping
[call [cmd ::fileutil::magic::rt::new] [arg chan] [arg named] [arg analyze]]
Create a new command which returns one description of the file each time it is
called, and a code of [arg break] when there are no more descriptions.
[arg chan] is the channel containing the data to describe. The channel
configuration is then managed as needed.
[arg named] is a dictionary of named tests, as generated by
[cmd fileutil::magic::cfront::compile].
[arg test] is a command prefix for a routine composed of the list of commands
as returned by [cmd fileutil::magic::cfront::compile].
[call [cmd ::fileutil::magic::rt::file_start] [arg name]]
This command marks the start of a magic file when debugging. It
returns the empty string as its result.
[call [cmd ::fileutil::magic::rt::emit] [arg msg]]
This command adds the text [arg 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.
[list_begin definitions]
[def [const \\b]] This sequence is removed
[def [const %s]] Replaced with the last buffered string value.
[def [const %ld]] Replaced with the last buffered numeric value.
[def [const %d]] See above.
[def [const {${x:...?...}}]] Substitute one string if the file is executable, and
another string otherwise.
[list_end]
[call [cmd ::fileutil::magic::rt::O] [arg where]]
Produce an offset from [arg where], relative to the cursor one level up.
[comment [call [cmd ::fileutil::magic::rt::R] [arg where]]]
Produce an offset from [arg where], relative to the offset one level up.
[call [cmd ::fileutil::magic::rt::Nv] [arg type] [arg offset] [
arg compinvert] [arg comp] [arg expected]]
A limited form of [cmd ::fileutile::magic::rt::N] that only checks for
equality and can't be told to invert the test.
[call [cmd ::fileutil::magic::rt::N] [arg type] [arg offset] [arg testinvert] [
arg compinvert] [arg mod] [arg mand] [arg comp] [arg expected]]
Fetch the numeric value with [arg type] from the absolute location
[arg offset], compare it with [arg expected] using [arg comp] as the comparision
operator, and returns the result.
[para]
The argument [arg comp] must be one of Tcl's comparison
operators.
[example {
<comp> <fetched-and-masked-value> <comp> <expected>
}]
[para]
The special comparison operator [const x] signals that no comparison
should be done, or, in other words, that the fetched value will always
match [arg val].
[call [cmd ::fileutil::magic::rt::S] [arg type] [arg offset] [arg testinvert] [
arg mod] [arg mand] [arg comp] [arg val]]
Like [cmd ::fileutil::magic::rt::N] except that it fetches and compares string
types , not numeric data.
[call [cmd ::fileutil::magic::rt::L] [arg newlevel]]
Sets the current level in the calling context to
[arg newlevel]. The command returns the empty string as its result.
[call [cmd ::fileutil::magic::rt::I] [arg offset] [arg it] [arg ioi] [arg ioo] [
arg iir] [arg io]]
Calculates an offset based on an initial offset and the provided modifiers.
[call [cmd ::fileutil::magic::rt::R] [arg offset]]
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.
[para]
[call [cmd ::fileutil::magic::rt::U] [arg fileindex] [arg name]]
Add a level and use a named test script.
[list_end]
[section {NUMERIC TYPES}]
[list_begin definitions]
[def [const byte]] 8-bit integer
[def [const short]] 16-bit integer, stored in native endianess
[def [const beshort]] see above, stored in big endian
[def [const leshort]] see above, stored in small/little endian
[def [const long]] 32-bit integer, stored in native endianess
[def [const belong]] see above, stored in big endian
[def [const lelong]] see above, stored in small/little endian
[list_end]
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.
[list_begin definitions]
[def [const date]] 32-bit integer timestamp, stored in native endianess
[def [const bedate]] see above, stored in big endian
[def [const ledate]] see above, stored in small/little endian
[def [const ldate]] 32-bit integer timestamp, stored in native endianess
[def [const beldate]] see above, stored in big endian
[def [const leldate]] see above, stored in small/little endian
[list_end]
[vset CATEGORY {fileutil :: magic}]
[include ../common-text/feedback.inc]
[manpage_end]
|